실적현황 조회 완료
This commit is contained in:
@@ -3,39 +3,43 @@
|
||||
import { useWrStore } from "@/app/store";
|
||||
import { btnClass } from "@/app/store/common/code";
|
||||
import type { FcPrfType, PrfType } from "@/app/store/prfmncReg/pbnstPrfmncReg/type";
|
||||
import type { prfmncType } from "@/app/store/prfmncSttn/pbnstPrfmncSttn/headList";
|
||||
import { yearOptions } from "@/components/lib/func/commom";
|
||||
import { ContentsDiv, Title, SearchBaseForm, SelectBox, SearchInput, UiTable } from "@common/business_components";
|
||||
import { ContentsDiv, Title, SearchBaseForm, SelectBox, SearchInput, UiTable, type ReturnType, } from "@common/business_components";
|
||||
import DoughnutChart from "@common/business_components/ui/chart/DoughnutChart";
|
||||
import ListDiv from "@common/business_components/ui/list_div";
|
||||
import { Button, Label } from "@common/components/ui";
|
||||
import { useEffect, useState } from "react";
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
|
||||
|
||||
|
||||
export default function PbnstPrfmncSttn() {
|
||||
const { code, tableHeadMaker, pbnstPrfmncSttn, pbnstPrfmncInit } = useWrStore((state) => state);
|
||||
const { code, tableHeadMaker, pbnstPrfmncSttn, pbnstPrfmncInit, pbnstPrfmncSearch } = useWrStore((state) => state);
|
||||
const { pbnstPrfHeadList, pbnstPrfmncRes, prfmncRes } = pbnstPrfmncSttn;
|
||||
const [isChHead, setIsChHead] = useState(false);
|
||||
const [fromDate, setFromDate] = useState<string>(String(new Date().getFullYear()));
|
||||
const [toDate, setToDate] = useState<string>(String(new Date().getFullYear()));
|
||||
const [pbnstTable, setPbnstTable] = useState<PrfType[]>();
|
||||
const [year, setYear] = useState<string>(String(new Date().getFullYear()));
|
||||
const [pbnstTable, setPbnstTable] = useState<prfmncType[]>();
|
||||
const [bdstTable, setbdstTable] = useState<FcPrfType[]>();
|
||||
const ref = useRef<ReturnType>({} as ReturnType);
|
||||
const [swtrmtFcltNm, setSwtrmtFcltNm] = useState<string>();
|
||||
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
console.log("pbnstPrfmncRes", pbnstPrfmncRes )
|
||||
setPbnstTable([]);
|
||||
}, [pbnstPrfmncRes]);
|
||||
|
||||
if (!pbnstPrfmncSttn.isInit) {
|
||||
pbnstPrfmncInit("1", "11");
|
||||
}
|
||||
}, [pbnstPrfmncSttn.isInit, pbnstPrfmncInit]);
|
||||
useEffect(() => {
|
||||
console.log("prfmncRes",prfmncRes)
|
||||
console.log("prfmncRes", prfmncRes)
|
||||
setbdstTable(prfmncRes);
|
||||
}, [prfmncRes]);
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
pbnstPrfmncInit();
|
||||
}, [pbnstPrfmncInit]);
|
||||
|
||||
|
||||
}, [ref.current]);
|
||||
return (
|
||||
<>
|
||||
<ContentsDiv>
|
||||
@@ -79,8 +83,9 @@ export default function PbnstPrfmncSttn() {
|
||||
<SearchInput
|
||||
className={"text-2xl"}
|
||||
label="시설명"
|
||||
textValue={""}
|
||||
textValue={swtrmtFcltNm}
|
||||
setText={(e) => {
|
||||
setSwtrmtFcltNm(e)
|
||||
}} />
|
||||
<SelectBox
|
||||
className="h-full text-2xl"
|
||||
@@ -91,7 +96,8 @@ export default function PbnstPrfmncSttn() {
|
||||
onSelectValue={() => { }} />
|
||||
</div>
|
||||
</div>}
|
||||
queryClick={function (): void {
|
||||
queryClick={function (returnType: ReturnType): void {
|
||||
pbnstPrfmncSearch(returnType, swtrmtFcltNm ?? "", fromDate, toDate);
|
||||
if (fromDate && toDate) {
|
||||
const fromNum = Number(fromDate);
|
||||
const toNum = Number(toDate);
|
||||
@@ -109,7 +115,7 @@ export default function PbnstPrfmncSttn() {
|
||||
excelClick={() => { }}
|
||||
initClick={function (): void { }}
|
||||
btnClass={btnClass}
|
||||
/>
|
||||
ref={ref} />
|
||||
</div>
|
||||
</div>
|
||||
<div className="grid grid-cols-6 gap-4 ">
|
||||
@@ -117,17 +123,38 @@ export default function PbnstPrfmncSttn() {
|
||||
<ListDiv>
|
||||
<UiTable
|
||||
headName={[]}
|
||||
tableData={pbnstTable || []}
|
||||
tableData={bdstTable || []}
|
||||
headlist={pbnstPrfHeadList}
|
||||
pageSize={20}
|
||||
total={10000}
|
||||
cellClick={() => { }}
|
||||
onPageChange={() => { }}
|
||||
/>
|
||||
|
||||
<hr />
|
||||
<h3 className="mt-4 ml-2 text-2xl font-medium text-label">하수재이용실적 상세현황</h3>
|
||||
|
||||
<SelectBox
|
||||
className="h-full w-1/12 text-2xl"
|
||||
label=""
|
||||
selectClass={""}
|
||||
selectArray={yearOptions}
|
||||
value={year}
|
||||
onSelectValue={(val: string | number) => setYear(String(val))} />
|
||||
<h1 className="">장내·외 용도별 하수재이용실적 현황(계)</h1>
|
||||
|
||||
<div className="flex">
|
||||
<div className="w-1/3"><DoughnutChart chartConfig={() => { }} chartData={[]} chartTitle={"장내·외 용수 총 실적"}>
|
||||
</DoughnutChart></div>
|
||||
<div className="w-1/3"><DoughnutChart chartConfig={() => { }} chartData={[]} chartTitle={"장내용수 실적"}>
|
||||
</DoughnutChart></div>
|
||||
<div className="w-1/3"><DoughnutChart chartConfig={() => { }} chartData={[]} chartTitle={"장외용수 실적"}>
|
||||
</DoughnutChart></div>
|
||||
</div>
|
||||
<h1 className="">장내·외 월별 하수재이용실적 현황</h1>
|
||||
</ListDiv>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</ContentsDiv>
|
||||
</>
|
||||
)
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { z } from "zod";
|
||||
import type { TableUpperProps } from "../../ruseFcltMng/fcltReg/rainReg";
|
||||
|
||||
export const pbnstPrfmncSttnHeadListExport: TableUpperProps[] = [
|
||||
@@ -5,55 +6,54 @@ export const pbnstPrfmncSttnHeadListExport: TableUpperProps[] = [
|
||||
id: "number",
|
||||
title: "No",
|
||||
rowSpan: 2,
|
||||
row:0
|
||||
row: 0
|
||||
},
|
||||
{
|
||||
id: "sido",
|
||||
title: "시도",
|
||||
rowSpan: 2,
|
||||
row:0
|
||||
row: 0
|
||||
},
|
||||
{
|
||||
id: "gugun",
|
||||
title: "시군구",
|
||||
rowSpan: 2,
|
||||
row:0
|
||||
row: 0
|
||||
},
|
||||
{
|
||||
id: "bscFctNm",
|
||||
title: "시설명",
|
||||
rowSpan: 2,
|
||||
row:0
|
||||
row: 0
|
||||
},
|
||||
{
|
||||
id: "ruseUtztnFcltNm",
|
||||
title: "재이용시설명",
|
||||
rowSpan: 2,
|
||||
row:0
|
||||
row: 0
|
||||
},
|
||||
|
||||
]
|
||||
|
||||
export const pbnstYearHeadListExport: TableUpperProps[] = [
|
||||
{
|
||||
id: "ym",
|
||||
title: "년도",
|
||||
colSpan: 3,
|
||||
row:0
|
||||
row: 0
|
||||
},
|
||||
{
|
||||
id: "total",
|
||||
title: "계",
|
||||
row:1
|
||||
row: 1
|
||||
},
|
||||
{
|
||||
id: "jangnae",
|
||||
id: "inUsage",
|
||||
title: "장내용수",
|
||||
row:1
|
||||
row: 1
|
||||
},
|
||||
{
|
||||
id: "jangoi",
|
||||
id: "outUsage",
|
||||
title: "장외용수",
|
||||
row:1
|
||||
row: 1
|
||||
},
|
||||
]
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
import { fetchType, getFetch } from "@/components/lib/api";
|
||||
import { fetchType, getFetch, postFectch } from "@/components/lib/api";
|
||||
import type { TableUpperProps } from "../../common/type/headder";
|
||||
import { pbnstPrfmncSttnHeadListExport, pbnstYearHeadListExport } from "./headList";
|
||||
import type { FcPrfType, PrfType } from "../../prfmncReg/pbnstPrfmncReg/type";
|
||||
import type { pubHasuType } from "../../ruseFcltMng/fcltReg/pbnstReg/type";
|
||||
import type { ReturnType } from "@common/business_components";
|
||||
|
||||
type pbnstPrfmncSttnActions = {
|
||||
tableHeadMaker: (startYear: number, endYear: number) => void;
|
||||
pbnstPrfmncInit: () => void;
|
||||
pbnstPrfmncInit: (page: string, sggOrCity: string) => void;
|
||||
pbnstPrfmncSearch: (returnType: ReturnType, swtrmtFcltNm: string, fromDate: string, toDate: string) => void;
|
||||
}
|
||||
|
||||
const pbnstPrfmncRes: PrfType[] = [];
|
||||
@@ -15,7 +18,7 @@ export type pbnstPrfmncSttnState = {
|
||||
pbnstPrfmncSttn: {
|
||||
pbnstPrfHeadList: TableUpperProps[];
|
||||
pbnstPrfmncRes: PrfType[];
|
||||
prfmncRes: FcPrfType[];
|
||||
prfmncRes: any[];
|
||||
isInit: boolean;
|
||||
}
|
||||
}
|
||||
@@ -31,6 +34,33 @@ export const pbnstPrfmncSttnExport: pbnstPrfmncSttnState = {
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
);
|
||||
return {
|
||||
sido: findData?.sido,
|
||||
gugun: findData?.gugun,
|
||||
bscFctNm: findData?.bscFctNm,
|
||||
ruseUtztnFcltNm: item.ruseUtztnFcltNm,
|
||||
pbnstRuseFcltPk: item.pbnstRuseFcltPk,
|
||||
};
|
||||
});
|
||||
return data;
|
||||
}
|
||||
|
||||
export const pbnstPrfmncSttnActionsExport: (set: any) => pbnstPrfmncSttnActions = (
|
||||
set: any
|
||||
) => {
|
||||
@@ -40,7 +70,7 @@ export const pbnstPrfmncSttnActionsExport: (set: any) => pbnstPrfmncSttnActions
|
||||
for (let i = startYear; i <= endYear; i++) {
|
||||
const yearHead = JSON.parse(JSON.stringify(pbnstYearHeadListExport));
|
||||
if (yearHead) {
|
||||
yearHead.forEach((item: { id: number; }) => (item.id = i + item.id))
|
||||
yearHead.forEach((item: { id?: number; }) => {if(item.id)item.id = i + item.id;})
|
||||
if (yearHead[0])
|
||||
yearHead[0].title = i + "년도"
|
||||
}
|
||||
@@ -55,31 +85,93 @@ export const pbnstPrfmncSttnActionsExport: (set: any) => pbnstPrfmncSttnActions
|
||||
};
|
||||
});
|
||||
},
|
||||
pbnstPrfmncInit: async () => {
|
||||
pbnstPrfmncInit: async (page: string, sggOrCity: string) => {
|
||||
try {
|
||||
const pbnstPrfmncSttnRes = await getFetch('wr', `/reuseFc/pubDetailList`);
|
||||
console.log("이안에", pbnstPrfmncSttnRes)
|
||||
const ruseFcltPk = pbnstPrfmncSttnRes.fcltCds;
|
||||
console.log("이거다", ruseFcltPk)
|
||||
const ruseFcltRes = await getFetch('wr', `/reuseFc/pubFc/${ruseFcltPk}`);
|
||||
console.log("이제나올듯", ruseFcltRes)
|
||||
|
||||
|
||||
set((state: pbnstPrfmncSttnState) => {
|
||||
return {
|
||||
...state,
|
||||
pbnstPrfmncSttn: {
|
||||
...state.pbnstPrfmncSttn,
|
||||
pbnstPrfmncSttnRes: pbnstPrfmncSttnRes,
|
||||
ruseFcltRes: ruseFcltRes,
|
||||
isInit: false,
|
||||
},
|
||||
};
|
||||
});
|
||||
const prfmncRes = await hasuListFetch(page, sggOrCity);
|
||||
return set((state: pbnstPrfmncSttnState) => ({
|
||||
...state,
|
||||
pbnstPrfmncSttn: {
|
||||
...state.pbnstPrfmncSttn,
|
||||
prfmncRes: prfmncRes,
|
||||
isInit: false,
|
||||
},
|
||||
}));
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
}
|
||||
},
|
||||
pbnstPrfmncSearch: async (returnType: ReturnType, swtrmtFcltNm: string, fromDate: string, toDate: string) => {
|
||||
let searchUrl = "";
|
||||
|
||||
if (returnType.sigunValue !== undefined) {
|
||||
if (swtrmtFcltNm !== "") {
|
||||
searchUrl = `/prcsFclt/info/1/20/${returnType.partValue}/${returnType.sigunValue}/0/1/SW${'/' + swtrmtFcltNm}`;
|
||||
} else {
|
||||
searchUrl = `/prcsFclt/info/1/20/${returnType.partValue}/${returnType.sigunValue}/0/1/SW`;
|
||||
}
|
||||
} else {
|
||||
if (swtrmtFcltNm !== "") {
|
||||
searchUrl = `/prcsFclt/info/1/20/${returnType.partValue}/${returnType.sidoValue}/0/1/SW${'/' + swtrmtFcltNm}`;
|
||||
} else {
|
||||
searchUrl = `/prcsFclt/info/1/20/${returnType.partValue}/${returnType.sidoValue}/0/1/SW`;
|
||||
}
|
||||
}
|
||||
|
||||
const pbnstRes = await getFetch(
|
||||
fetchType.COMMON,
|
||||
searchUrl
|
||||
);
|
||||
const bscFctCdList = pbnstRes.map((item: any) => {
|
||||
return item.bscFctCd;
|
||||
})
|
||||
const res = await postFectch(
|
||||
`/reuseFc/pubDetailList/${fromDate}/${toDate}`,
|
||||
bscFctCdList,
|
||||
`wr`,
|
||||
)
|
||||
|
||||
let inUsageSum = 0;
|
||||
let outUsageSum = 0;
|
||||
let usageSum = 0;
|
||||
let year = "";
|
||||
const yearsData = []
|
||||
res.data.forEach((item) => {
|
||||
item.prfList.forEach((acc) => {
|
||||
year = acc.ym.substring(0, 4);
|
||||
inUsageSum = acc.wshwtr + acc.coolUswtr + acc.cleanUswtr + acc.drwtUswtr +
|
||||
acc.dltnUswtr + acc.ithlRswtr + acc.ithlEtcUswtr + acc.cleanToilUswtr + acc.resn;
|
||||
outUsageSum = acc.lndwtr + acc.hydUswtr + acc.ugwtChr + acc.farmUswtr + acc.rvrKeepUswtr + acc.indstUswtr;
|
||||
const yearData = yearsData.find(yearItem => yearItem.year === year && yearItem.pbnstRuseFcltPk == acc.pbnstRuseFcltPk)
|
||||
|
||||
if (yearData) {
|
||||
yearData.inUsageSum += inUsageSum;
|
||||
yearData.outUsageSum += outUsageSum;
|
||||
} else {
|
||||
const yearVal = { year: year, pbnstRuseFcltPk: acc.pbnstRuseFcltFk }
|
||||
yearVal[year + 'inUsage'] = inUsageSum;
|
||||
yearVal[year + 'outUsage'] = outUsageSum;
|
||||
yearVal[year + 'total'] = inUsageSum+outUsageSum;
|
||||
yearsData.push(yearVal);
|
||||
}
|
||||
|
||||
})
|
||||
})
|
||||
const resData:any[] = []
|
||||
pbnstRes.forEach((acc) => { let data = yearsData.find((item) => item.pbnstRuseFcltPk.substring(0, 11) === acc.bscFctCd)
|
||||
if(data){
|
||||
resData.push({...data, ...acc})
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
|
||||
return set((state: pbnstPrfmncSttnState) => ({
|
||||
...state,
|
||||
pbnstPrfmncSttn: {
|
||||
...state.pbnstPrfmncSttn,
|
||||
prfmncRes:resData
|
||||
},
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -83,7 +83,7 @@ export type chgBuilding={
|
||||
}
|
||||
export type customRainBdst = z.infer<typeof rainZod>
|
||||
export type TableUpperProps = {
|
||||
id: string;
|
||||
id?: string;
|
||||
title: string;
|
||||
upName?: string;
|
||||
upSequnce?: number;
|
||||
|
||||
Reference in New Issue
Block a user