빗물통계 진행중

This commit is contained in:
jyha00
2025-06-18 16:48:03 +09:00
parent dd89796b89
commit d52f0137ca
3 changed files with 51 additions and 37 deletions
+7 -3
View File
@@ -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>(
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() {
<ListDiv className="min-h-0">
{/* <ScrollArea className="h-[60vh]"> */}
<UiTable
tableData={[]}
tableData={rainStatList || []}
headlist={rainStat.rainStatHeadList}
pageSize={20}
total={10000}
headName={"건축물 목록"}
headName={""}
cellClick={(val, headId) => {}}
onPageChange={setPageNation}
></UiTable>
+11 -5
View File
@@ -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
+33 -29
View File
@@ -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,