엑셀 등록 하는 부분 aoa로 수정.
This commit is contained in:
@@ -2,17 +2,15 @@
|
||||
"use client";
|
||||
import { useWrStore } from "@/app/store";
|
||||
import { btnClass } from "@/app/store/common/code";
|
||||
import type { TableTripleProps } from "@/app/store/ruseFcltMng/fcltReg/rainReg";
|
||||
import { excelDownload, tableData } from "@/components/lib/func/commom";
|
||||
import HeadChModal from "@/components/ui/modal/headChModal/headChModal";
|
||||
import {
|
||||
ContentsDiv,
|
||||
filePickedBlob,
|
||||
SearchBaseForm,
|
||||
Title,
|
||||
UiModal,
|
||||
UiTable,
|
||||
type ReturnType,
|
||||
type ReturnType
|
||||
} from "@common/business_components/ui";
|
||||
import ListDiv from "@common/business_components/ui/list_div";
|
||||
import { Button } from "@common/components/ui";
|
||||
@@ -65,11 +63,11 @@ export default function RainSttn() {
|
||||
}, [code, rainRes, sttnCommon.rainSttHeadList]);
|
||||
useEffect(() => {
|
||||
if(sttnCommon.excelList.length>0){
|
||||
if (sttnCommon.excelList.length === 0) return;
|
||||
excelDownload(sttnCommon.excelList , '빗물재이용시설 현황','sample_rainSttn_test.xlsx')
|
||||
console.log('sttnCommon.excelList', sttnCommon.excelList);
|
||||
|
||||
if (sttnCommon.excelList.length === 0) return;
|
||||
excelDownload(sttnCommon.excelList , '빗물재이용시설 현황','sample_rainSttn.xlsx')
|
||||
}
|
||||
|
||||
|
||||
}, [sttnCommon.excelList]);
|
||||
|
||||
const excelClick = useCallback((returnType:ReturnType) => {
|
||||
|
||||
@@ -1,166 +1,33 @@
|
||||
import type { customRainBdst } from "../../fcltReg/rainReg"
|
||||
import type { customRainBdst } from "../../fcltReg/rainReg";
|
||||
|
||||
export type ExcelSttnRainType={
|
||||
"1.건축물정보": {
|
||||
"행정구역":{"시도": string, "시군구": string},
|
||||
"건축물명": string,
|
||||
"주소": string,
|
||||
"건축물용도코드": string,
|
||||
"최초건축허가일": string,
|
||||
"건축면적": string,
|
||||
"법적의무대상": string,
|
||||
"설치완료일시": string,
|
||||
},
|
||||
"2.빗물이용시설정보":{
|
||||
"설치비용": string,
|
||||
"집수면":{
|
||||
"집수지점종류": string,
|
||||
"집수지점면적": string,
|
||||
},
|
||||
"여과등 처리시설":{
|
||||
"여과처리시설유무": string,
|
||||
"여과처리시설용량": string,
|
||||
"여과처리시설처리공정": string,
|
||||
},
|
||||
"저류조용량": string,
|
||||
},
|
||||
|
||||
"3.인센티브 정보":{
|
||||
"설치비지원":{
|
||||
"설치지원비용여부": string,
|
||||
"설치지원비용": string,
|
||||
},
|
||||
|
||||
"녹색건축물인증여부":{
|
||||
"녹색건축물인증여부": string,
|
||||
"녹색건축물인증년도": string,
|
||||
"녹색건축물인증번호": string,
|
||||
"녹색건축물인증등급": string,
|
||||
}
|
||||
}
|
||||
}
|
||||
export const excelSttnParsing = (data: customRainBdst[]): string[][] => {
|
||||
const excelExportData: string[][] = [];
|
||||
|
||||
export const excelSttnParsing = (data: customRainBdst[]): ExcelSttnRainType[] => {
|
||||
const excelExportData: ExcelSttnRainType[] = []
|
||||
data.forEach((item) => {
|
||||
excelExportData.push(
|
||||
{
|
||||
"1.건축물정보": {
|
||||
"행정구역":{"시도": String(item.ctpvCd), "시군구": String(item.sggCd)},
|
||||
"건축물명": item.bdstNm,
|
||||
"주소": item.daddr,
|
||||
"건축물용도코드": String(item.bdstInfoPk),
|
||||
"최초건축허가일":String(item.frstArchPrmsnDt),
|
||||
"건축면적": String(item.archArea),
|
||||
"법적의무대상": String(item.reuseBuilding[0]?.lawTrgtYn??''),
|
||||
"설치완료일시": String(item.reuseBuilding[0]?.instlCmptnDt??''),
|
||||
},
|
||||
"2.빗물이용시설정보":{
|
||||
"설치비용": String(item.reuseBuilding[0]?.instlCst??''),
|
||||
"집수면":{
|
||||
"집수지점종류": item.reuseBuilding[0]?.rainyObj.pntfColKnd??'',
|
||||
"집수지점면적": String(item.reuseBuilding[0]?.rainyObj.pntfColArea??''),
|
||||
},
|
||||
"여과등 처리시설":{
|
||||
"여과처리시설유무": String(item.reuseBuilding[0]?.rainyObj.filtrTrtmfctYn??''),
|
||||
"여과처리시설용량": String(item.reuseBuilding[0]?.rainyObj.filtrTrtmfctCpct??''),
|
||||
"여과처리시설처리공정":String(item.reuseBuilding[0]?.rainyObj.filtrTrtmfctPrs??''),
|
||||
},
|
||||
"저류조용량": String(item.reuseBuilding[0]?.rainyObj.dtfcltCpct??''),
|
||||
},
|
||||
"3.인센티브 정보":{
|
||||
"설치비지원":{
|
||||
"설치지원비용여부": String(item.reuseBuilding[0]?.instlCstSprtYn ) ,
|
||||
"설치지원비용": String(item.reuseBuilding[0]?.instlCstSprtAmt ),
|
||||
},
|
||||
"녹색건축물인증여부":{
|
||||
"녹색건축물인증여부": String(item.reuseBuilding[0]?.grntchBdstCertYn) ,
|
||||
"녹색건축물인증년도": String(item.reuseBuilding[0]?.grntchBdstCertYr),
|
||||
"녹색건축물인증번호": String(item.reuseBuilding[0]?.grntchBdstCertNo),
|
||||
"녹색건축물인증등급": String(item.reuseBuilding[0]?.grntchBdstCertGrd),
|
||||
}
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
console.log(excelExportData)
|
||||
// excelItem = {} as ExcelSttnRainType
|
||||
// excelItem["1.건축물정보"]["행정구역"]["시도"] = item.sidoNm
|
||||
// excelItem["1.건축물정보"]["행정구역"]["시군구"] = item.sggNm
|
||||
return excelExportData;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
export type ExcelSttnRainTypeFlat = {
|
||||
행정구역: string;
|
||||
건축물명: string;
|
||||
주소: string;
|
||||
건축물용도코드: string;
|
||||
최초건축허가일: string;
|
||||
건축면적: string;
|
||||
법적의무대상: string;
|
||||
설치완료일시: string;
|
||||
|
||||
설치비용: string;
|
||||
집수면: string;
|
||||
여과등처리시설: string;
|
||||
저류조용량: string;
|
||||
|
||||
운영관리코드?: string;
|
||||
연간빗물운영량?: string;
|
||||
|
||||
설치지원비용여부: string;
|
||||
설치지원비용: string;
|
||||
|
||||
녹색건축물인증여부: string;
|
||||
};
|
||||
|
||||
|
||||
export const excelSttnParsingJson = (data: customRainBdst[]): ExcelSttnRainTypeFlat[] => {
|
||||
const excelExportData: ExcelSttnRainTypeFlat[] = [];
|
||||
|
||||
data.forEach((item) => {
|
||||
excelExportData.push({
|
||||
// 1.건축물정보
|
||||
"행정구역": JSON.stringify({
|
||||
시도: String(item.ctpvCd),
|
||||
시군구: String(item.sggCd)
|
||||
}),
|
||||
"건축물명": item.bdstNm ?? "",
|
||||
"주소": item.daddr ?? "",
|
||||
"건축물용도코드": String(item.bdstInfoPk ?? ""),
|
||||
"최초건축허가일": String(item.frstArchPrmsnDt ?? ""),
|
||||
"건축면적": String(item.archArea ?? ""),
|
||||
"법적의무대상": String(item.reuseBuilding?.[0]?.lawTrgtYn ?? ""),
|
||||
"설치완료일시": String(item.reuseBuilding?.[0]?.instlCmptnDt ?? ""),
|
||||
|
||||
// 2.빗물이용시설정보
|
||||
"설치비용": String(item.reuseBuilding?.[0]?.instlCst ?? ""),
|
||||
"집수면": JSON.stringify({
|
||||
집수지점종류: item.reuseBuilding?.[0]?.rainyObj?.pntfColKnd ?? "",
|
||||
집수지점면적: String(item.reuseBuilding?.[0]?.rainyObj?.pntfColArea ?? "")
|
||||
}),
|
||||
"여과등처리시설": JSON.stringify({
|
||||
여과처리시설유무: String(item.reuseBuilding?.[0]?.rainyObj?.filtrTrtmfctYn ?? ""),
|
||||
여과처리시설용량: String(item.reuseBuilding?.[0]?.rainyObj?.filtrTrtmfctCpct ?? ""),
|
||||
여과처리시설처리공정: String(item.reuseBuilding?.[0]?.rainyObj?.filtrTrtmfctPrs ?? "")
|
||||
}),
|
||||
"저류조용량": String(item.reuseBuilding?.[0]?.rainyObj?.dtfcltCpct ?? ""),
|
||||
|
||||
// 3.인센티브 정보
|
||||
"설치지원비용여부": String(item.reuseBuilding?.[0]?.instlCstSprtYn ?? ""),
|
||||
"설치지원비용": String(item.reuseBuilding?.[0]?.instlCstSprtAmt ?? ""),
|
||||
|
||||
"녹색건축물인증여부": JSON.stringify({
|
||||
녹색건축물인증여부: String(item.reuseBuilding?.[0]?.grntchBdstCertYn ?? ""),
|
||||
녹색건축물인증년도: String(item.reuseBuilding?.[0]?.grntchBdstCertYr ?? ""),
|
||||
녹색건축물인증번호: String(item.reuseBuilding?.[0]?.grntchBdstCertNo ?? ""),
|
||||
녹색건축물인증등급: String(item.reuseBuilding?.[0]?.grntchBdstCertGrd ?? "")
|
||||
}),
|
||||
excelExportData.push([
|
||||
String(item.ctpvCd),
|
||||
String(item.sggCd),
|
||||
item.bdstNm ?? "",
|
||||
item.daddr ?? "",
|
||||
String(item.bdstInfoPk ?? ""),
|
||||
String(item.frstArchPrmsnDt ?? ""),
|
||||
String(item.archArea ?? ""),
|
||||
String(item.reuseBuilding?.[0]?.lawTrgtYn ?? ""),
|
||||
String(item.reuseBuilding?.[0]?.instlCmptnDt ?? ""),
|
||||
String(item.reuseBuilding?.[0]?.instlCst ?? ""),
|
||||
item.reuseBuilding?.[0]?.rainyObj?.pntfColKnd ?? "",
|
||||
String(item.reuseBuilding?.[0]?.rainyObj?.pntfColArea ?? ""),
|
||||
String(item.reuseBuilding?.[0]?.rainyObj?.filtrTrtmfctYn ?? ""),
|
||||
String(item.reuseBuilding?.[0]?.rainyObj?.filtrTrtmfctCpct ?? ""),
|
||||
String(item.reuseBuilding?.[0]?.rainyObj?.filtrTrtmfctPrs ?? ""),
|
||||
String(item.reuseBuilding?.[0]?.rainyObj?.dtfcltCpct ?? ""),
|
||||
String(item.reuseBuilding?.[0]?.instlCstSprtYn ?? ""),
|
||||
String(item.reuseBuilding?.[0]?.instlCstSprtAmt ?? ""),
|
||||
String(item.reuseBuilding?.[0]?.grntchBdstCertYn ?? ""),
|
||||
String(item.reuseBuilding?.[0]?.grntchBdstCertYr ?? ""),
|
||||
String(item.reuseBuilding?.[0]?.grntchBdstCertNo ?? ""),
|
||||
String(item.reuseBuilding?.[0]?.grntchBdstCertGrd ?? "")
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
return excelExportData;
|
||||
};
|
||||
return excelExportData;
|
||||
};
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import type { chHeadType } from "@/app/store/prfmncReg/chkgdnReg/rainChkgdn";
|
||||
import { fetchType, getFetch } from "@/components/lib/api";
|
||||
import {
|
||||
type customRainBdst,
|
||||
type TableTripleProps,
|
||||
type TableUpperProps,
|
||||
} from "../../fcltReg/rainReg";
|
||||
import { excelSttnParsing, excelSttnParsingJson, type ExcelSttnRainType, type FlatExcelSttnRainType } from "./excel";
|
||||
import { fetchType, getFetch } from "@/components/lib/api";
|
||||
import { excelSttnParsing, type ExcelSttnRainType } from "./excel";
|
||||
|
||||
const pbnSttHeadNm: chHeadType[] = [
|
||||
{ headNm: "catchment", text: "유역", length: 3 },
|
||||
@@ -341,7 +341,6 @@ export const sttnActionsExport: (set: any) => sttnActions = (set: any) => {
|
||||
`/reuseFc/rainyInfoList/${page}/${total}/${con}`
|
||||
);
|
||||
if(Number(total) > 9000){
|
||||
//const rainExcel= excelSttnParsing(rainRes)
|
||||
const rainExcel= excelSttnParsing(rainRes)
|
||||
set((state: sttnState) => {
|
||||
return {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { comCodeState, } from "@/app/store/common/code";
|
||||
import type { comCodeState, } from "@/app/store/common/code";
|
||||
import { filePickedBlob, type SelectDataType } from "@common/business_components/ui";
|
||||
|
||||
|
||||
@@ -49,8 +49,7 @@ export const getCity = (val: string, sggCd: SelectDataType[]) => {
|
||||
|
||||
|
||||
|
||||
export const excelDownload =(excelList: JSON[], fileNm:string ,sampleFile:string ) =>{
|
||||
console.log("excelList", excelList);
|
||||
export const excelDownload =(excelList: [][], fileNm:string ,sampleFile:string ) =>{
|
||||
if (excelList.length === 0) return;
|
||||
fetch(`/${sampleFile}`, {})
|
||||
.then(async (response) => {
|
||||
@@ -60,7 +59,6 @@ export const getCity = (val: string, sggCd: SelectDataType[]) => {
|
||||
// 받은 파일 바인너리 처리
|
||||
const blobRet = await response.arrayBuffer()
|
||||
// 버퍼에 있는 엑셀데이터 전달 후 json으로 변환
|
||||
const ret =await filePickedBlob(blobRet, excelList,fileNm )
|
||||
|
||||
await filePickedBlob(blobRet, excelList,fileNm, 4)
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user