재이용시설 현황 조회 데이터 조립
This commit is contained in:
@@ -18,7 +18,7 @@ import type { customPbnst } from "@/app/store/ruseFcltMng/fcltReg/pbnstReg/type"
|
||||
import { excelDownload, getCityOrSgg } from "@/components/lib/func/commom";
|
||||
|
||||
export default function PbnstSttn() {
|
||||
const { code, pbnstSttn, pbnstSttnSearch } = useWrStore((state) => state);
|
||||
const { code, pbnstSttn, pbnstSttnSearch,pbnSttnInit } = useWrStore((state) => state);
|
||||
|
||||
const ref = useRef<ReturnType>({} as ReturnType);
|
||||
const codeData = getCityOrSgg(ref);
|
||||
@@ -28,15 +28,37 @@ export default function PbnstSttn() {
|
||||
const [bdstTable, setBdstTable] = useState<customPbnst[]>();
|
||||
|
||||
const excelClick = useCallback(() => {
|
||||
// if (codeData) pbnstSttnSearch(1, "10000", codeData);
|
||||
excelDownload(
|
||||
[[]],
|
||||
"하수재이용시설 현황",
|
||||
"sample_pbnstSttn.xlsx",
|
||||
"A1:U2"
|
||||
);
|
||||
if (codeData) pbnstSttnSearch('1', "10000", codeData);
|
||||
|
||||
}, [pbnstSttnSearch, codeData]);
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
if(pbnstSttn.excelList.length > 0){
|
||||
excelDownload(
|
||||
pbnstSttn.excelList,
|
||||
"하수재이용시설 현황",
|
||||
"sample_pbnstSttn.xlsx",
|
||||
"A1:U2"
|
||||
);
|
||||
}
|
||||
|
||||
}, [pbnstSttn.excelList]);
|
||||
useEffect(() => {
|
||||
if (!pbnstSttn.isInit) {
|
||||
pbnSttnInit('1','11')
|
||||
}
|
||||
|
||||
},[pbnstSttn.isInit,pbnSttnInit])
|
||||
useEffect(() => {
|
||||
console.log('pbnstSttn.pbnstSttnRes ', pbnstSttn.pbnstSttnRes)
|
||||
|
||||
|
||||
|
||||
setBdstTable(pbnstSttn.pbnstSttnRes)
|
||||
|
||||
},[pbnstSttn.pbnstSttnRes])
|
||||
|
||||
return (
|
||||
<>
|
||||
<ContentsDiv>
|
||||
|
||||
@@ -5,23 +5,23 @@ export const excelPbnstSttnParsing = (data: any[]): string[][] => {
|
||||
|
||||
data.forEach((item) => {
|
||||
excelExportData.push([
|
||||
item.a,
|
||||
String(item.aaa),
|
||||
item.aaaa ?? "",
|
||||
item.operMngCd ?? "",
|
||||
String(item.cityText ?? ""),
|
||||
String(item.sggText ?? ""),
|
||||
String(item.bdnstNm ?? ""),
|
||||
String(item.archArea ?? ""),
|
||||
String(item.archArea ?? ""),
|
||||
String(item.archArea ?? ""),
|
||||
String(item.archArea ?? ""),
|
||||
String(item.archArea ?? ""),
|
||||
String(item.archArea ?? ""),
|
||||
String(item.archArea ?? ""),
|
||||
String(item.archArea ?? ""),
|
||||
String(item.archArea ?? ""),
|
||||
String(item.archArea ?? ""),
|
||||
item.rvbsn,
|
||||
String(item.lgbsn),
|
||||
item.mdmbsn ?? "",
|
||||
item.rgnNm ?? "",
|
||||
String(item.sido ?? ""),
|
||||
String(item.gugun ?? ""),
|
||||
String(item.bscFctNm ?? ""),
|
||||
String(item.efflWqltStndrdNm ?? ""),
|
||||
String(item.fctCpc ?? ""),
|
||||
String(item.tel ?? ""),
|
||||
String(item.ruseUtztnFcltNm ?? ""),
|
||||
String(item.fcltCpct ?? ""),
|
||||
String(item.splyExtraCpct ?? ""),
|
||||
String(item.ruseCpct ?? ""),
|
||||
String(item.usageTotal ?? ""),
|
||||
String(item.inUsage ?? ""),
|
||||
String(item.outUsage ?? ""),
|
||||
])
|
||||
})
|
||||
return excelExportData;
|
||||
|
||||
@@ -3,34 +3,34 @@ import type { CommonTableProps } from "@/app/store/common/type/header";
|
||||
import { z } from "zod";
|
||||
|
||||
export const pbnSttHeadListExport: z.infer<typeof sttnHeadListType> = [
|
||||
{ id: "a", title: "권역", visible: true },
|
||||
{ id: "rvbsn", title: "권역", visible: true },
|
||||
{
|
||||
id: "aaa",
|
||||
id: "lgbsn",
|
||||
title: "단위유역",
|
||||
visible: true,
|
||||
},
|
||||
{
|
||||
id: "aaaa",
|
||||
id: "mdmbsn",
|
||||
title: "중권역",
|
||||
visible: true,
|
||||
},
|
||||
{ id: "operMngCd", title: "환경청", visible: true },
|
||||
{ id: "rgnNm", title: "환경청", visible: true },
|
||||
{
|
||||
id: "cityText",
|
||||
id: "sido",
|
||||
title: "시도",
|
||||
visible: true,
|
||||
},
|
||||
{
|
||||
id: "sggText",
|
||||
id: "gugun",
|
||||
title: "시군구",
|
||||
visible: true,
|
||||
},
|
||||
{ id: "bdnstNm", title: "시설명", visible: true },
|
||||
{ id: "locDiv", title: "지역구분", visible: true },
|
||||
{ id: "phone", title: "전화번호", visible: true },
|
||||
|
||||
{ id: "fcltQuantity", title: "시설용량(톤/일)", visible: true },
|
||||
{ id: "rusNm", title: "재이용시설명", visible: true },
|
||||
{ id: "bscFctNm", title: "시설명", visible: true },
|
||||
{ id: "efflWqltStndrdNm", title: "지역구분", visible: true },
|
||||
|
||||
{ id: "fctCpc", title: "시설용량(톤/일)", visible: true },
|
||||
{ id: "tel", title: "전화번호", visible: true },
|
||||
{ id: "ruseUtztnFcltNm", title: "재이용시설명", visible: true },
|
||||
|
||||
{
|
||||
id: "fcltCpct",
|
||||
@@ -38,7 +38,7 @@ export const pbnSttHeadListExport: z.infer<typeof sttnHeadListType> = [
|
||||
visible: true,
|
||||
},
|
||||
{
|
||||
id: "trbt",
|
||||
id: "splyExtraCpct",
|
||||
title: "하수처리량(m³/일)",
|
||||
visible: true,
|
||||
},
|
||||
@@ -49,17 +49,17 @@ export const pbnSttHeadListExport: z.infer<typeof sttnHeadListType> = [
|
||||
},
|
||||
|
||||
{
|
||||
id: "total",
|
||||
id: "usageTotal",
|
||||
title: "합계",
|
||||
visible: true,
|
||||
},
|
||||
{
|
||||
id: "ithlWtr",
|
||||
id: "inUsage",
|
||||
title: "장내용수",
|
||||
visible: true,
|
||||
},
|
||||
{
|
||||
id: "othlWtr",
|
||||
id: "outUsage",
|
||||
title: "장외용수",
|
||||
visible: true,
|
||||
},
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
import type { CommonTableProps } from "@/app/store/common/type/header";
|
||||
import type { z } from "zod";
|
||||
import {
|
||||
pbnSttHeadListExport,
|
||||
pbnstSttNodeListExport
|
||||
} from "./headList";
|
||||
import { fetchType, getFetch } from "@/components/lib/api";
|
||||
import { pbnSttHeadListExport, pbnstSttNodeListExport } from "./headList";
|
||||
import { fetchType, getFetch, postFectch } from "@/components/lib/api";
|
||||
import { controlHeadView } from "../rainSttn";
|
||||
import type { sttnHeadListType } from "../rainSttn/headList";
|
||||
import type { customPbnst } from "../../fcltReg/pbnstReg/type";
|
||||
import type { customPbnst, pubHasuType } from "../../fcltReg/pbnstReg/type";
|
||||
import { excelPbnstSttnParsing } from "./excel";
|
||||
import type { FcPrfType } from "@/app/store/prfmncReg/pbnstPrfmncReg/type";
|
||||
|
||||
const pbnstSttHeadList = pbnSttHeadListExport;
|
||||
const pbnstSttNodeList = pbnstSttNodeListExport;
|
||||
@@ -24,10 +22,9 @@ export type pbnstSttnState = {
|
||||
};
|
||||
|
||||
type pbnstSttnActions = {
|
||||
pbnstChSttnHead: (
|
||||
headList: z.infer<typeof sttnHeadListType>,
|
||||
) => void;
|
||||
pbnstSttnSearch: (page: number, total: string, con: string) => void;
|
||||
pbnstChSttnHead: (headList: z.infer<typeof sttnHeadListType>) => void;
|
||||
pbnstSttnSearch: (page: string, total: string, con: string) => void;
|
||||
pbnSttnInit: (page: string, sggOrCity: string) => void;
|
||||
};
|
||||
|
||||
export type pbnstSttnType = pbnstSttnState & pbnstSttnActions;
|
||||
@@ -42,6 +39,72 @@ export const pbnstSttnStateExport: pbnstSttnState = {
|
||||
},
|
||||
};
|
||||
|
||||
const checkWrRegList = async () => {
|
||||
const wrRegList = await getFetch("wr", `/reuseFc/pubDetailList`);
|
||||
return wrRegList;
|
||||
};
|
||||
const hasuListFetch = async (page: string, sggOrCity: string) => {
|
||||
const checkWrRegListRes = await checkWrRegList();
|
||||
const rainRes = await postFectch(
|
||||
`/prcsFclt/ruseInfo/${page ? page : 1}/10/A/${sggOrCity ? sggOrCity : "11"}/0/1/SW`,
|
||||
checkWrRegListRes?.fcltCds,
|
||||
fetchType.COMMON
|
||||
);
|
||||
const data = checkWrRegListRes.fcPrfList.map((item: FcPrfType) => {
|
||||
const findData = rainRes.data.find(
|
||||
(fclt: pubHasuType) =>
|
||||
fclt.bscFctCd === item.pbnstRuseFcltPk.substring(0, 11)
|
||||
);
|
||||
const usage = item.prfList.reduce(
|
||||
(acc, cur) => {
|
||||
acc.inUsage +=
|
||||
cur.wshwtr +
|
||||
cur.coolUswtr +
|
||||
cur.cleanUswtr +
|
||||
cur.drwtUswtr +
|
||||
cur.dltnUswtr +
|
||||
cur.ithlRswtr +
|
||||
cur.ithlEtcUswtr +
|
||||
cur.cleanToilUswtr +
|
||||
cur.resn;
|
||||
acc.outUsage +=
|
||||
cur.lndwtr +
|
||||
cur.hydUswtr +
|
||||
cur.ugwtChr +
|
||||
cur.farmUswtr +
|
||||
cur.rvrKeepUswtr +
|
||||
cur.indstUswtr;
|
||||
acc.total = acc.inUsage + acc.outUsage;
|
||||
|
||||
return acc;
|
||||
},
|
||||
{ total: 0, inUsage: 0, outUsage: 0 }
|
||||
);
|
||||
return {
|
||||
rvbsn: findData?.rvbsn,
|
||||
lgbsn: findData?.lgbsn,
|
||||
mdmbsn: findData?.mdmbsn,
|
||||
rgnNm: findData?.rgnNm,
|
||||
sido: findData?.sido,
|
||||
gugun: findData?.gugun,
|
||||
bscFctNm: findData?.bscFctNm,
|
||||
efflWqltStndrdNm: findData?.efflWqltStndrdNm,
|
||||
fctCpc: findData.fctCpc,
|
||||
tel: findData?.lclgvrnmnt ?? "-",
|
||||
ruseUtztnFcltNm: item.ruseUtztnFcltNm,
|
||||
fcltCpct: item.fcltCpct,
|
||||
splyExtraCpct: item.splyExtraCpct,
|
||||
ruseCpct: item.ruseCpct,
|
||||
pbnstRuseFcltPk: item.pbnstRuseFcltPk,
|
||||
usageTotal: usage.total,
|
||||
inUsage: usage.inUsage,
|
||||
outUsage: usage.outUsage,
|
||||
fcOpers: item?.fcOpers ?? [],
|
||||
};
|
||||
});
|
||||
return data;
|
||||
};
|
||||
|
||||
export const pbnstSttnActionsExport: (set: any) => pbnstSttnActions = (
|
||||
set: any
|
||||
) => {
|
||||
@@ -49,9 +112,7 @@ export const pbnstSttnActionsExport: (set: any) => pbnstSttnActions = (
|
||||
pbnstChSttnHead: async (
|
||||
headList: z.infer<typeof sttnHeadListType>
|
||||
): Promise<void> => {
|
||||
|
||||
console.log('head ', headList)
|
||||
const changeNodeList = controlHeadView(headList, pbnstSttNodeList)
|
||||
const changeNodeList = controlHeadView(headList, pbnstSttNodeList);
|
||||
|
||||
return set((state: pbnstSttnState) => ({
|
||||
pbnstSttn: {
|
||||
@@ -61,12 +122,11 @@ export const pbnstSttnActionsExport: (set: any) => pbnstSttnActions = (
|
||||
},
|
||||
}));
|
||||
},
|
||||
pbnstSttnSearch: async (page: number, total: string, con: string) => {
|
||||
pbnstSttnSearch: async (page: string, total: string, con: string) => {
|
||||
try {
|
||||
const pbnstSttnRes = await getFetch(
|
||||
fetchType.WR,
|
||||
`/reuseFc/waterreuseFc/${page}/${total}/${con}`
|
||||
);
|
||||
|
||||
const pbnstSttnRes = await hasuListFetch(page, con);
|
||||
console.log("pbnstSttnRes", pbnstSttnRes);
|
||||
if (Number(total) > 9000) {
|
||||
const pbnstExcel = excelPbnstSttnParsing(pbnstSttnRes);
|
||||
set((state: pbnstSttnState) => {
|
||||
@@ -80,7 +140,6 @@ export const pbnstSttnActionsExport: (set: any) => pbnstSttnActions = (
|
||||
});
|
||||
} else
|
||||
set((state: pbnstSttnState) => {
|
||||
|
||||
return {
|
||||
...state,
|
||||
pbnstSttn: {
|
||||
@@ -94,5 +153,23 @@ export const pbnstSttnActionsExport: (set: any) => pbnstSttnActions = (
|
||||
console.log("error", erTxt);
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
pbnSttnInit: async (page: string, sggOrCity: string) => {
|
||||
try {
|
||||
const pbnstSttnRes = await hasuListFetch(page, sggOrCity);
|
||||
console.log("pbnstSttnRes", pbnstSttnRes);
|
||||
set((state: pbnstSttnState) => {
|
||||
return {
|
||||
...state,
|
||||
pbnstSttn: {
|
||||
...state.pbnstSttn,
|
||||
pbnstSttnRes: pbnstSttnRes,
|
||||
isInit: false,
|
||||
},
|
||||
};
|
||||
});
|
||||
} catch (erTxt) {
|
||||
console.log("error", erTxt);
|
||||
}
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user