From d52f0137ca8782af64fe85bcea1ae69c2a1fa8c5 Mon Sep 17 00:00:00 2001 From: jyha00 Date: Wed, 18 Jun 2025 16:48:03 +0900 Subject: [PATCH] =?UTF-8?q?=EB=B9=97=EB=AC=BC=ED=86=B5=EA=B3=84=20?= =?UTF-8?q?=EC=A7=84=ED=96=89=EC=A4=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/wr/app/stats/rainStat/page.tsx | 10 ++- apps/wr/app/store/stats/rainStat/headList.tsx | 16 +++-- apps/wr/app/store/stats/rainStat/index.tsx | 62 ++++++++++--------- 3 files changed, 51 insertions(+), 37 deletions(-) diff --git a/apps/wr/app/stats/rainStat/page.tsx b/apps/wr/app/stats/rainStat/page.tsx index 7b822875a..26fc6340a 100644 --- a/apps/wr/app/stats/rainStat/page.tsx +++ b/apps/wr/app/stats/rainStat/page.tsx @@ -1,6 +1,7 @@ "use client"; import { useWrStore } from "@/app/store"; +import type { RainStatProps } from "@/app/store/stats/rainStat"; import { yearOptions } from "@/components/lib/func/commom"; import { ContentsDiv, @@ -14,7 +15,9 @@ import { Button } from "@common/components/ui"; import { useEffect, useState } from "react"; export default function RainStat() { - const { rainStat, searchRainStatList } = useWrStore((state) => state) + const { rainStat, searchRainStatList } = useWrStore((state) => state); + const { rainStatHeadList, rainStatList } = rainStat; + const [ pageNation, setPageNation] = useState(1); const [searchYear, setSearchYear] = useState( String(new Date().getFullYear()) @@ -22,6 +25,7 @@ export default function RainStat() { useEffect(() => { searchRainStatList(searchYear); + console.log("rainStatList", rainStatList) }, [searchRainStatList, searchYear]) return ( @@ -66,11 +70,11 @@ export default function RainStat() { {/* */} {}} onPageChange={setPageNation} > diff --git a/apps/wr/app/store/stats/rainStat/headList.tsx b/apps/wr/app/store/stats/rainStat/headList.tsx index 412b79178..3b01c40c5 100644 --- a/apps/wr/app/store/stats/rainStat/headList.tsx +++ b/apps/wr/app/store/stats/rainStat/headList.tsx @@ -2,29 +2,35 @@ import type { TableUpperProps } from "../../common/type/header"; export const rainStatHeadListExport: TableUpperProps[] = [ { - id: "시도", + id: "ctpvCd", title: "시도", row:0, rowSpan:2 }, { - id: "개소", + id: "tmp", title: "개소", row:0, rowSpan:2 }, { - id: "설치비", + id: "instlCst", title: "설치비(백만원)", row:0, rowSpan:2 }, { - id: "저류조용량", + id: "dtfcltCpct", title: "저류조용량(m³/년)", row:0, rowSpan:2 }, + { + id: "wtrUsqty", + title: "연간사용량(㎥/년)", + row:0, + rowSpan:2 + }, { id: "이용용도", title: "이용용도", @@ -67,7 +73,7 @@ export const rainStatHeadListExport: TableUpperProps[] = [ row:1, }, { - id: "연간운영비", + id: "anlOperCst", title: "연간운영비(백만원/년)", row:0, rowSpan:2 diff --git a/apps/wr/app/store/stats/rainStat/index.tsx b/apps/wr/app/store/stats/rainStat/index.tsx index 08e17b2ce..d22ae7a1a 100644 --- a/apps/wr/app/store/stats/rainStat/index.tsx +++ b/apps/wr/app/store/stats/rainStat/index.tsx @@ -22,6 +22,7 @@ export type RainStatProps = { way5 : number //방법5 way6 : number //방법6 way7 : number //방법7 + tmp : number //개소 } const fetchRainStatList = async (year:string) => { @@ -54,17 +55,19 @@ export const rainStatActionsExport = ( return { searchRainStatList: async (year: string) => { const res = await fetchRainStatList(year); - const rainStatList: never[] = []; + const rainStatList: RainStatProps[] = []; const grouped = Object.groupBy(res, (item: RainStatProps) => item.ctpvCd); console.log("grouped", grouped); Object.values(grouped).forEach((item) => { if (!item) return; + let ctpvCd = ""; let instlCst = 0; - let dtfcltCpct = 0; - let wtrUsqty = 0; - let anlOperCst = 0; + let tmp = 0; //개소 + let dtfcltCpct = 0; //설치비용 + let wtrUsqty = 0; //연간사용량 + let anlOperCst = 0; //연간운영비 let way1 = 0; let way2 = 0; let way3 = 0; @@ -74,7 +77,9 @@ export const rainStatActionsExport = ( let way7 = 0; item.forEach((element) => { + ctpvCd = element.ctpvCd; instlCst += element.instlCst; + tmp += 1; dtfcltCpct += element.dtfcltCpct; wtrUsqty += element.wtrUsqty; anlOperCst += element.anlOperCst; @@ -85,34 +90,33 @@ export const rainStatActionsExport = ( way5 += element.way5; way6 += element.way6; way7 += element.way7; + + }) + + rainStatList.push({ + instlCst, + tmp, + dtfcltCpct, + wtrUsqty, + anlOperCst, + way1, + way2, + way3, + way4, + way5, + way6, + way7, + ctpvCd, + // sggCd: "", + // areaNm: "", + // bdstNm: "", + // archArea: 0, + // annRnwtQty: 0, + // jungsudo: 0, + // dachae: 0 }) - - console.log("instlCst", instlCst) - console.log("dtfcltCpct", dtfcltCpct) - }) - - - /* const rainStatHeadList = data.map((item:RainStatProps) => ({ - ...item, - ctpvCd:item.ctpvCd, - sggCd:item.sggCd, - areaNm:item.areaNm, - archArea:item.archArea, - dtfcltCpct:item.dtfcltCpct, - annRnwtQty:item.annRnwtQty, - jungsudo:item.jungsudo, - dachae:item.dachae, - way1:item.way1, - way2:item.way2, - way3:item.way3, - way4:item.way4, - way5:item.way5, - way6:item.way6, - way7:item.way7, - yearMoney:item.yearMoney, - })) */ set((state: rainStatState) => ({ rainStat: { ...state.rainStat,