From 7f966c9d874be8231805f713e78f664583f3b155 Mon Sep 17 00:00:00 2001 From: jyha00 Date: Thu, 19 Jun 2025 16:34:36 +0900 Subject: [PATCH] =?UTF-8?q?=EC=A4=91=EC=88=98=EB=8F=84=ED=86=B5=EA=B3=84?= =?UTF-8?q?=20=EC=A1=B0=ED=9A=8C,=20=EC=97=91=EC=85=80=20=EC=99=84?= =?UTF-8?q?=EB=A3=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/wr/app/stats/rswtStat/page.tsx | 43 +++++++++++++++++++--- apps/wr/app/store/stats/rswtStat/index.tsx | 2 - 2 files changed, 38 insertions(+), 7 deletions(-) diff --git a/apps/wr/app/stats/rswtStat/page.tsx b/apps/wr/app/stats/rswtStat/page.tsx index 74a8a3c82..37e48a308 100644 --- a/apps/wr/app/stats/rswtStat/page.tsx +++ b/apps/wr/app/stats/rswtStat/page.tsx @@ -1,9 +1,10 @@ "use client"; import { useWrStore } from "@/app/store"; -import type { ExcelType, RswtStatProps } from "@/app/store/stats/rswtStat"; +import type { RswtStatProps } from "@/app/store/stats/rswtStat"; import { tableData, yearOptions } from "@/components/lib/func/commom"; import { ContentsDiv, + downloadExcel, SearchDiv, SelectBox, Title, @@ -21,7 +22,20 @@ export default function RswtStat() { const [searchYear, setSearchYear] = useState( String(new Date().getFullYear()) ); - const [excelData, setExceData] = useState(); + const [excelData, setExceData] = useState(); + + useEffect(() => { + searchRswtStatList(searchYear) + }, [searchRswtStatList, searchYear]) + + const excelClick = () => { + downloadExcel({ + data: (excelData as unknown as JSON[]) ?? [], + fileName: "중수도재이용통계", + sheetNameArray: ["Sheet1"], + headerRange: "A1:O1" + }) + } useEffect(() => { const transData = Array.isArray(rswtStatList) ? rswtStatList : [rswtStatList]; @@ -40,7 +54,27 @@ export default function RswtStat() { useEffect(() => { const transExcel = Array.isArray(excelList) ? excelList : [excelList]; const exData = tableData(transExcel, { code }); - const tbData = Array.isArray(excelData) + const tbData = Array.isArray(exData) ? + exData.map((item: RswtStatProps) => { + return { + "시도": item.cityText, + "개소": item.ctpvCnt, + "건축연면적(m³)": item.archArea, + "처리용량(m³)": item.filtrTrtmfctCpct, + "물사용량(m³/년)": item.wtrUsqty, + "중수도+대체수이용량(m³/년)": item.rswtAltSum, + "중수도이용량(m³/년)": item.rswtrUsqty, + "대체수이용량(m³/년)": item.altUswtrUtztnQnt, + "조경용수": item.lndwtr, + "청소화장실용수": item.cleanToilUswtr, + "농업용수": item.farmUswtr, + "공업용수": item.indstUswtr, + "친수용수": item.hydUswtr, + "기타": item.ithlEtcUswtr, + "연간운영비(백만원/년)": item.anlOperCst, + }; + }) : []; + setExceData(tbData); }, [excelList]) return (<> @@ -65,7 +99,6 @@ export default function RswtStat() { className="" size="sm" onClick={() => { - console.log("searchYear", searchYear) searchRswtStatList(searchYear) }} > @@ -74,7 +107,7 @@ export default function RswtStat() { diff --git a/apps/wr/app/store/stats/rswtStat/index.tsx b/apps/wr/app/store/stats/rswtStat/index.tsx index f1b09354e..b270d31aa 100644 --- a/apps/wr/app/store/stats/rswtStat/index.tsx +++ b/apps/wr/app/store/stats/rswtStat/index.tsx @@ -62,8 +62,6 @@ export const rswtStatActionsExport: (set: any) => rswtStatActions = ( return { searchRswtStatList: async (year: string) => { const res = await getFetch(fetchType.WR, `/reuseChk/reuseWater/stat/${year}`) - - const rswtStatList: RswtStatProps[] = []; let cityArr: any[] = []; res.forEach((item: RswtStatProps) => {