/** * Store - 타입 */ import { getFetch } from "@/app/components/api"; import DataForm from "@/app/components/common/DataForm"; import { fetchPlanInfo } from "../common"; import type { FacilityWaterQltyProps } from "../facilityWaterQlty"; import { calRainEffectDay, type ApiResponse, type FlowDataItem } from "../underWaterInput"; // selectBox export type SelectDataType = { text: string; val: string; } // grid header export type TableUpperProps = { id: string; title: string; upName?: string; upSequnce?: number; align? : string; row? : number; rowSpan?: number; colSpan?: number; } // ===TAB1 // main fclty export type mainFcltyProps = { fcltyNm : string, facilityCapacity : string, publicMethod : string, location : string } // 시설계획 export type planFcltyListProps = { item : string, provisionalApproval : string | number | '', now : string | number | '', stepOne : string | number | '', stepTwo : string | number | '', stepThree : string | number | '', stepFour : string | number | '', } // 운영실태 export type OperationalStatusListProps = { flowRate : string, waterQlty : string, yearAvg : number | string | '', yearMax : number | string | '', yearMin : number | string | '', summerAll : number | string | '', summerThree : number | string | '', summerRain : number | string | '', winterAll : number | string | '', winterSunnyAvg : number | string | '', winterSunnyMax : number | string | '', winterSunnyMin : number | string | '', groundWaterAvg : number | string | '', groundWaterSummer : number | string | '', groundWaterWinter : number | string | '', rdi : number | string | '', rdiRain : number | string | '', } export interface operationalStatusListProps { flowRate : string, waterQlty : string, yearAvg : number | '', yearMax : number | '', yearMin : number | '', summerAll : number | '', summerThree : number | '', summerRain : number | '', winterAll : number | '', winterSunnyAvg : number | '', winterSunnyMax : number | '', winterSunnyMin : number | '', groundWaterAvg : number | string | '', groundWaterSummer : number | string | '', groundWaterWinter : number | string | '', rdi : number | '', } // 차트 export type lineBarChartDataProps = { label : string, lineVal : number barVal : number barVal0 : number barVal1 : number lineVal0 : number lineVal1 : number } export type lineChartDataProps = { label : string, val : number } export interface RainManageListProps { rainItem : string, rainRate : string, rainDay : number, bscFctCd?: string, bscFctNm?: string, msrDt?: string sidoNm?: string, sggNm?: string, addr?: string, fctCpc?: number, inflAssctBfrWqltBod: number | '', inflAssctBfrWqltToc: number | '', inflAssctBfrWqltSs: number | '', inflAssctBfrWqltTn: number | '', inflAssctBfrWqltTp: number | '', efflWqltBod: number | '', efflWqltToc: number | '', efflWqltSs: number | '', efflWqltTn: number | '', efflWqltTp: number | '', rgnNm?:string|'', rvbsn?:string|'', lgbsn?:string|'', mdmbsn?:string|'', inflAmnt: number | '', lclgvrnmntNm?: string, infoRnDay?: number | '', tpInflWqltTmprtr?: number | '', tpInflWqltPh?: number | '', tpInflWqltBod?: number | '', tpInflWqltCod?: number | '', tpInflWqltSs?: number | '', tpInflWqltTn?: number | '', tpInflWqltTp?: number | '', tpInflWqltEclgyTox?: number | '', tpInflWqltClfgrpcnt?: number | '', dsInflWqltBod: number | '', dsInflWqltCod: number | '', dsInflWqltSs: number | '', dsInflWqltTn: number | '', dsInflWqltTp: number | '', extnsSeqno?: number | '', rainEffectDay?: number | '', } export interface RainManageExcelType { 강우량: string, 강우조건비율: number | '', 일수: number | '', 유입유량: number | '', 시설용량대비: number | '', 설계유입수질BOD: number | '', 설계유입수질TOC: number | '', 설계유입수질SS: number | '', 설계유입수질TN: string | number | '', 설계유입수질TP: string | number | '', 유입수질BOD: number | '', 유입수질TOC: number | '', 유입수질SS: number | '', 유입수질TN: string | number | '', 유입수질TP: string | number | '', 방류수질BOD: number | '', 방류수질TOC: number | '', 방류수질SS: number | '', 방류수질TN: string | number | '', 방류수질TP: string | number | '', } export interface DrainageEquipmentListProps { part1 : string | '', part2 : string | '', nowSum : number | '', nowJoin : number | '', nowSep : number | '', stepOneSum : number | '', stepOneJoin : number | '', stepOneSep : number | '', stepTwoSum : number | '', stepTwoJoin : number | '', stepTwoSep : number | '', stepThreeSum : number | '', stepThreeJoin : number | '', stepThreeSep : number | '', stepFourSum : number | '', stepFourJoin : number | '', stepFourSep : number | '', etc : string | '', } export interface DrainageEquipmentExcelType { partOne : string | '', partTwo : string | '', nowSum : number | '', nowJoin : number | '', nowSep : number | '', stepOneSum : number | '', stepOneJoin : number | '', stepOneSep : number | '', stepTwoSum : number | '', stepTwoJoin : number | '', stepTwoSep : number | '', stepThreeSum : number | '', stepThreeJoin : number | '', stepThreeSep : number | '', stepFourSum : number | '', stepFourJoin : number | '', stepFourSep : number | '', } /** * Store - data */ // Main const DashBoardTopLabelArray:string[] = ['구분', '시도', '시군구', '년도', '시설명']; // === Tab1 // grid header const upHeadListFclty:TableUpperProps[] = [ { id : "fcltyNm", title : "시설명"}, { id : "facilityCapacity", title : "시설용량(m³/일)"}, { id : "publicMethod", title : "공법"}, { id : "location", title : "지역구"}, ] const fcltyList : mainFcltyProps[] = [ ] let planYearList : string[] = [ "2021", "2022", "2023", "2024", "2025", "2026" ] const upHeadListPlanFclty : TableUpperProps[] = [ { id: "item", title: "", upName:"upChangeRe", upSequnce:1 }, { id: "provisionalApproval", title: "기승인\n4단계", upName:"upChangeRe", upSequnce:2 }, { id: "now", title: "현재", upName:"upChangeRe", upSequnce:3 }, { id: "stepOne", title: "1단계", upName:"upChangeRe", upSequnce:4 }, { id: "stepTwo", title: "2단계", upName:"upChangeRe", upSequnce:5 }, { id: "stepThree", title: "3단계", upName:"upChangeRe", upSequnce:6 }, { id: "stepFour", title: "4단계", upName:"upChangeRe", upSequnce:7 }, ] const planFcltyList:planFcltyListProps[] = [ { item : "1.증설계획\n(㎥/일)", provisionalApproval: "", now: "", stepOne: "", stepTwo: "", stepThree: "", stepFour : "", }, { item : "2.처리인구(인)", provisionalApproval: "", now: "", stepOne: "", stepTwo: "", stepThree: "", stepFour : "", }, { item : "3.처리구역\n(km²)", provisionalApproval: "", now: "", stepOne: "", stepTwo: "", stepThree: "", stepFour : "", }, { item : "4.분류식화율\n(%)", provisionalApproval: "", now: "", stepOne: "", stepTwo: "", stepThree: "", stepFour : "", }, { item : "5.물사용량", provisionalApproval: "", now: "", stepOne: "", stepTwo: "", stepThree: "", stepFour : "", }, { item : "년도\n(최근 3개년)", provisionalApproval: "물사용량\n(㎥/일)", now: "", stepOne: "", stepTwo: "비고", stepThree: "", stepFour : "", }, { item : "2021", provisionalApproval: "", now: "", stepOne: "", stepTwo: "", stepThree: "", stepFour : "", }, { item : "2022", provisionalApproval: "", now: "", stepOne: "", stepTwo: "", stepThree: "", stepFour : "", }, { item : "2023", provisionalApproval: "", now: "", stepOne: "", stepTwo: "", stepThree: "", stepFour : "", }, ] const upHeadListOperationStatus : TableUpperProps[] = [ { id: "flowRate", title: "유량 및 수질", upName:"upChangeRe1", upSequnce:1 }, { id: "waterQlty", title: "유량 및 수질", upName:"upChangeRe1", upSequnce:2 }, { id: "yearAvg", title: "평균", upName:"upChangeRe2", upSequnce:1 }, { id: "yearMax", title: "최대", upName:"upChangeRe2", upSequnce:2 }, { id: "yearMin", title: "최소", upName:"upChangeRe2", upSequnce:3 }, { id: "summerAll", title: "전기간", upName:"upChangeRe3", upSequnce:1 }, { id: "summerThree", title: "강우시\n(3mm이상)", upName:"upChangeRe3", upSequnce:2 }, { id: "summerRain", title: "청천시", upName:"upChangeRe3", upSequnce:3 }, { id: "winterAll", title: "전기간", upName:"upChangeRe4", upSequnce:1 }, { id: "winterSunnyAvg", title: "청천시\n평균", upName:"upChangeRe4", upSequnce:2 }, { id: "winterSunnyMax", title: "청천시\n최대", upName:"upChangeRe4", upSequnce:3 }, { id: "winterSunnyMin", title: "청천시\n최소", upName:"upChangeRe4", upSequnce:4 }, { id: "groundWaterAvg", title: "연평균", upName:"upChangeRe5", upSequnce:1 }, { id: "groundWaterSummer", title: "하절기\n평균", upName:"upChangeRe5", upSequnce:2 }, { id: "groundWaterWinter", title: "동절기\n평균", upName:"upChangeRe5", upSequnce:3 }, { id: "rdi", title: "RDII 추정" }, { id: "rdiRain", title: "RDII 추정시\n일강수량(mm)" }, ] const upHeadListRainManage : TableUpperProps[] = [ { id: "rainItem", title: "강우량", row:0, rowSpan:2 }, { id: "rainRate", title: "강우조건\n비율(%)", row:0, rowSpan:2 }, { id: "rainDay", title: "일수", row:0, rowSpan:2 }, { id: "A", title: "유입(㎥/일)", row:0, colSpan:2 }, { id: "inflAmnt", title: "유입유량", row:1 }, { id: "fctCpc", title: "시설용량대비", row:1 }, { id: "B", title: "설계유입수질(㎎/L)", row:0, colSpan:5 }, { id: "dsInflWqltBod", title: "BOD", row:1 }, { id: "dsInflWqltCod", title: "TOC\n(COD)", row:1 }, { id: "dsInflWqltSs", title: "SS", row:1 }, { id: "dsInflWqltTn", title: "T-N", row:1 }, { id: "dsInflWqltTp", title: "T-P", row:1 }, { id: "C", title: "유입수질(㎎/L)", row:0, colSpan:5 }, { id: "inflAssctBfrWqltBod", title: "BOD", row:1 }, { id: "inflAssctBfrWqltToc", title: "TOC\n(COD)", row:1 }, { id: "inflAssctBfrWqltSs", title: "SS", row:1 }, { id: "inflAssctBfrWqltTn", title: "T-N", row:1 }, { id: "inflAssctBfrWqltTp", title: "T-P", row:1 }, { id: "D", title: "방류수질(㎎/L)", row:0, colSpan:5 }, { id: "efflWqltBod", title: "BOD", row:1 }, { id: "efflWqltToc", title: "TOC\n(COD)", row:1 }, { id: "efflWqltSs", title: "SS", row:1 }, { id: "efflWqltTn", title: "T-N", row:1 }, { id: "efflWqltTp", title: "T-P", row:1 }, ] const upHeadListDrainageEquipment : TableUpperProps[] = [ { id: "part1", title: "구분", row:0, upName:"upChangeRe1", upSequnce:1 }, { id: "part2", title: "구분", row:0, upName:"upChangeRe1", upSequnce:2 }, { id: "nowSum", title: "계", row:2, upName:"upChangeRe2", upSequnce:1 }, { id: "nowJoin", title: "합류식\n가구수", row:2, upName:"upChangeRe2", upSequnce:2 }, { id: "nowSep", title: "분리식\n가구수", row:2, upName:"upChangeRe2", upSequnce:3 }, { id: "stepOneSum", title: "계", row:2, upName:"upChangeRe3", upSequnce:1 }, { id: "stepOneJoin", title: "합류식\n가구수", row:2, upName:"upChangeRe3", upSequnce:2 }, { id: "stepOneSep", title: "분리식\n가구수", row:2, upName:"upChangeRe3", upSequnce:3 }, { id: "stepTwoSum", title: "계", row:2, upName:"upChangeRe4", upSequnce:1 }, { id: "stepTwoJoin", title: "합류식\n가구수", row:2, upName:"upChangeRe4", upSequnce:2 }, { id: "stepTwoSep", title: "분리식\n가구수", row:2, upName:"upChangeRe4", upSequnce:3 }, { id: "stepThreeSum", title: "계", row:2, upName:"upChangeRe5", upSequnce:1 }, { id: "stepThreeJoin", title: "합류식\n가구수", row:2, upName:"upChangeRe5", upSequnce:2 }, { id: "stepThreeSep", title: "분리식\n가구수", row:2, upName:"upChangeRe5", upSequnce:3 }, { id: "stepFourSum", title: "계", row:2, upName:"upChangeRe6", upSequnce:1 }, { id: "stepFourJoin", title: "합류식\n가구수", row:2, upName:"upChangeRe6", upSequnce:2 }, { id: "stepFourSep", title: "분리식\n가구수", row:2, upName:"upChangeRe6", upSequnce:3 }, { id: "etc", title: "비고", row:0, upName:"upChangeRe7", upSequnce:1 }, ] const operationalStatusList : OperationalStatusListProps[] = [ { flowRate : '유량\n(㎥/일)', waterQlty : '유입', yearAvg : '', yearMax : '', yearMin : '', summerAll : '', summerThree : '', summerRain : '', winterAll : '', winterSunnyAvg : '', winterSunnyMax : '', winterSunnyMin : '', groundWaterAvg : '', groundWaterSummer : '', groundWaterWinter : '', rdi : '', rdiRain : '', }, { flowRate : '유량\n(㎥/일)', waterQlty : '순수하수', yearAvg : '', yearMax : '', yearMin : '', summerAll : '', summerThree : '', summerRain : '', winterAll : '', winterSunnyAvg : '', winterSunnyMax : '', winterSunnyMin : '', groundWaterAvg : '', groundWaterSummer : '', groundWaterWinter : '', rdi : '', rdiRain : '', }, { flowRate : '유량\n(㎥/일)', waterQlty : '연계처리수', yearAvg : '', yearMax : '', yearMin : '', summerAll : '', summerThree : '', summerRain : '', winterAll : '', winterSunnyAvg : '', winterSunnyMax : '', winterSunnyMin : '', groundWaterAvg : '', groundWaterSummer : '', groundWaterWinter : '', rdi : '', rdiRain : '', }, { flowRate : '유량\n(㎥/일)', waterQlty : '총인설비\n반류수', yearAvg : '', yearMax : '', yearMin : '', summerAll : '', summerThree : '', summerRain : '', winterAll : '', winterSunnyAvg : '', winterSunnyMax : '', winterSunnyMin : '', groundWaterAvg : '', groundWaterSummer : '', groundWaterWinter : '', rdi : '', rdiRain : '', }, { flowRate : '유량\n(㎥/일)', waterQlty : '방류', yearAvg : '', yearMax : '', yearMin : '', summerAll : '', summerThree : '', summerRain : '', winterAll : '', winterSunnyAvg : '', winterSunnyMax : '', winterSunnyMin : '', groundWaterAvg : '', groundWaterSummer : '', groundWaterWinter : '', rdi : '', rdiRain : '', }, { flowRate : '수질\n(mg/L)', waterQlty : '유입\n(BOD)', yearAvg : '', yearMax : '', yearMin : '', summerAll : '', summerThree : '', summerRain : '', winterAll : '', winterSunnyAvg : '', winterSunnyMax : '', winterSunnyMin : '', groundWaterAvg : '', groundWaterSummer : '', groundWaterWinter : '', rdi : '', rdiRain : '', }, { flowRate : '수질\n(mg/L)', waterQlty : '방류\n(BOD)', yearAvg : '', yearMax : '', yearMin : '', summerAll : '', summerThree : '', summerRain : '', winterAll : '', winterSunnyAvg : '', winterSunnyMax : '', winterSunnyMin : '', groundWaterAvg : '', groundWaterSummer : '', groundWaterWinter : '', rdi : '', rdiRain : '', }, { flowRate : '수질\n(mg/L)', waterQlty : '유입\n(T-N)', yearAvg : '', yearMax : '', yearMin : '', summerAll : '', summerThree : '', summerRain : '', winterAll : '', winterSunnyAvg : '', winterSunnyMax : '', winterSunnyMin : '', groundWaterAvg : '', groundWaterSummer : '', groundWaterWinter : '', rdi : '', rdiRain : '', }, { flowRate : '수질\n(mg/L)', waterQlty : '방류\n(T-N)', yearAvg : '', yearMax : '', yearMin : '', summerAll : '', summerThree : '', summerRain : '', winterAll : '', winterSunnyAvg : '', winterSunnyMax : '', winterSunnyMin : '', groundWaterAvg : '', groundWaterSummer : '', groundWaterWinter : '', rdi : '', rdiRain : '', }, { flowRate : '수질\n(mg/L)', waterQlty : '유입\n(T-P)', yearAvg : '', yearMax : '', yearMin : '', summerAll : '', summerThree : '', summerRain : '', winterAll : '', winterSunnyAvg : '', winterSunnyMax : '', winterSunnyMin : '', groundWaterAvg : '', groundWaterSummer : '', groundWaterWinter : '', rdi : '', rdiRain : '', }, { flowRate : '수질\n(mg/L)', waterQlty : '방류\n(T-P)', yearAvg : '', yearMax : '', yearMin : '', summerAll : '', summerThree : '', summerRain : '', winterAll : '', winterSunnyAvg : '', winterSunnyMax : '', winterSunnyMin : '', groundWaterAvg : '', groundWaterSummer : '', groundWaterWinter : '', rdi : '', rdiRain : '', }, { flowRate : '총인\n시설\n수질\n(mg/L)', waterQlty : '총인설비\n유입(T-P)', yearAvg : '', yearMax : '', yearMin : '', summerAll : '', summerThree : '', summerRain : '', winterAll : '', winterSunnyAvg : '', winterSunnyMax : '', winterSunnyMin : '', groundWaterAvg : '', groundWaterSummer : '', groundWaterWinter : '', rdi : '', rdiRain : '', }, { flowRate : '총인\n시설\n수질\n(mg/L)', waterQlty : '총인설비\n방류(T-P)', yearAvg : '', yearMax : '', yearMin : '', summerAll : '', summerThree : '', summerRain : '', winterAll : '', winterSunnyAvg : '', winterSunnyMax : '', winterSunnyMin : '', groundWaterAvg : '', groundWaterSummer : '', groundWaterWinter : '', rdi : '', rdiRain : '', }, ] const chart_inflowRain : lineBarChartDataProps[] = []; const chart_bodRain : lineBarChartDataProps[] = []; const chart_inflTp : lineChartDataProps[] = []; const chart_chongInTp : lineChartDataProps[] = []; const chart_efflTp : lineChartDataProps[] = []; const chart_inflTn : lineChartDataProps[] = []; const chart_efflTn : lineChartDataProps[] = []; const chart_inflBod : lineChartDataProps[] = []; const chart_efflBod : lineChartDataProps[] = []; const rainManageList : RainManageListProps[] = []; const drainageEquipmentList : DrainageEquipmentListProps[] = [ { part1 : '청천시청', part2 : '청천시청', nowSum : 101, nowJoin : 102, nowSep : 103, stepOneSum : 104, stepOneJoin : 105, stepOneSep : 106, stepTwoSum : 107, stepTwoJoin : 108, stepTwoSep : 109, stepThreeSum : 110, stepThreeJoin : 111, stepThreeSep : 112, stepFourSum : 113, stepFourJoin : 114, stepFourSep : 115, etc : '1050', } ]; /**==================================== * Store - api (데이터 호출) ====================================*/ /* 시설정보 및 운영현황 - 계획 */ const fetchFacilityPlan = async (targetYear : string | undefined, fcltyCd : string | undefined, set : (fn: (state: DashBoardType) => DashBoardType) => void) => { try { const res = await fetchPlanInfo(undefined, undefined, undefined, fcltyCd); return res; } catch (error) { console.error('시설계획정보를 가져오는데 실패했습니다:', error); set((state) => ({ ...state, PlanFclty : { ...state.PlanFclty, isLoadingPlanFclty : false, isLoadingOperationStatus : false } })); return {data: [], count: 0}; } }; /* 시설정보 및 운영현황 - 운영실태 */ const fetchOperationStatus = async (searchYear: string|undefined, fcltyCd: string|undefined) => { try{ const url = '/dashBoard/mngInfo/' + (searchYear?searchYear:'2023') + '/' + (fcltyCd?fcltyCd:''); const res = await getFetch('fo', url); return { data: res.data, count: res.count } } catch (error) { console.error('운영실태 데이터를 가져오는데 실패했습니다:', error); return { data: [], count: 0 }; } } // 주요그래프 데이터 const fetchMainGraph = async (searchYear: string|undefined, fcltyCd: string|undefined) => { try { const url = '/fclt/qlty/hist/' + (searchYear?searchYear:'2023') + '/' + (fcltyCd?fcltyCd:'11680PB001R'); const res = await getFetch('fo', url); return { data: res.data, count: res.count } } catch (error) { console.error('주요그래프 데이터를 가져오는데 실패했습니다:', error); return { data: [], count: 0 }; } } /**==================================== * Store - action ====================================*/ export type DashBoardActions = { initializeDashBoardData(): Promise; /** 시설정보 및 운영현황 - 계획정보 */ searchPlanInfo(targetYear: string, fcltyCd: string): Promise; /** 시설정보 및 운영현황 - 운영실태 */ searchOperationStatus(isExcel: boolean, searchYear: string, fcltyCd: string): Promise; /** 주요그래프 데이터 */ searchMainGraph(searchYear: string, fcltyCd: string): Promise; /**강우일 운영현황 */ searchRainManage(searchYear: string, fcltyCd: string, isExcel: boolean): Promise; } export type DashBoardType = { DashboardMain: { isInit: boolean; topLabelArray:string[]; }, FcltyMain : { isInit : boolean; upHeadListFclty : TableUpperProps[]; fcltyList : mainFcltyProps[]; }, PlanFclty : { isInit : boolean; planYearList : string[]; upHeadListPlanFclty : TableUpperProps[]; planFcltyList : planFcltyListProps[]; waterUsage1 : number | '', waterUsage2 : number | '', waterUsage3 : number | '', isLoadingPlanFclty : boolean; }, OperationStatus : { isInit : boolean; upHeadListOperationStatus : TableUpperProps[]; operationalStatusList : OperationalStatusListProps[]; isLoadingOperationStatus : boolean; } MainGraph : { isInit : boolean; chart_inflowRain : lineBarChartDataProps[]; chart_bodRain : lineBarChartDataProps[]; chart_inflTp : lineChartDataProps[]; chart_chongInTp : lineChartDataProps[]; chart_efflTp : lineChartDataProps[]; chart_inflTn : lineChartDataProps[]; chart_efflTn : lineChartDataProps[]; chart_inflBod : lineChartDataProps[]; chart_efflBod : lineChartDataProps[]; isLoadingMainGraph : boolean; }, RainManage : { isInit : boolean; upHeadListRainManage : TableUpperProps[]; rainManageList : RainManageListProps[]; excelList : RainManageExcelType[]; isLoadingRainManage : boolean; }, DrainageEquipment : { isInit : boolean; upHeadListDrainageEquipment : TableUpperProps[]; drainageEquipmentList : DrainageEquipmentListProps[]; drainageEquipmentExcelList : DrainageEquipmentExcelType[]; } } export type DashBoardStore = DashBoardType & DashBoardActions; export const dashBoardInitState:DashBoardType = { DashboardMain: { isInit: false, topLabelArray: DashBoardTopLabelArray, }, FcltyMain : { isInit : false, upHeadListFclty : upHeadListFclty, fcltyList : fcltyList, }, PlanFclty : { isInit : true, planYearList : planYearList, upHeadListPlanFclty : upHeadListPlanFclty, planFcltyList : planFcltyList, waterUsage1 : 0, waterUsage2 : 0, waterUsage3 : 0, isLoadingPlanFclty : false, }, OperationStatus : { isInit : false, upHeadListOperationStatus : upHeadListOperationStatus, operationalStatusList : operationalStatusList, isLoadingOperationStatus : false, }, MainGraph : { isInit : false, chart_inflowRain : chart_inflowRain, chart_bodRain : chart_bodRain, chart_inflTp : chart_inflTp, chart_chongInTp : chart_chongInTp, chart_efflTp : chart_efflTp, chart_inflTn : chart_inflTn, chart_efflTn : chart_efflTn, chart_inflBod : chart_inflBod, chart_efflBod : chart_efflBod, isLoadingMainGraph : false, }, RainManage : { isInit : false, upHeadListRainManage : upHeadListRainManage, rainManageList : rainManageList, excelList : [], isLoadingRainManage : false, }, DrainageEquipment : { isInit : false, upHeadListDrainageEquipment : upHeadListDrainageEquipment, drainageEquipmentList : drainageEquipmentList, drainageEquipmentExcelList : [] } } /** * 데이터 폼 포맷설정 */ export const dataFormSettingPlan=(item : planFcltyListProps) => { DataForm({ type: 'float2', column: 'provisionalApproval', item: item as unknown as Record }); DataForm({ type: 'float2', column: 'now', item: item as unknown as Record}); DataForm({ type: 'float2', column: 'stepOne', item: item as unknown as Record}); DataForm({ type: 'float2', column: 'stepTwo', item: item as unknown as Record}); DataForm({ type: 'float2', column: 'stepThree', item: item as unknown as Record}); DataForm({ type: 'float2', column: 'stepFour', item: item as unknown as Record}); } export const dataFormSetting=(item : OperationalStatusListProps)=> { DataForm({ type: 'float2', column: 'yearAvg', item: item as unknown as Record }); DataForm({ type: 'float2', column: 'yearMax', item: item as unknown as Record}); DataForm({ type: 'float2', column: 'yearMin', item: item as unknown as Record}); DataForm({ type: 'float2', column: 'summerAll', item: item as unknown as Record}); DataForm({ type: 'float2', column: 'summerThree', item: item as unknown as Record}); DataForm({ type: 'float2', column: 'summerRain', item: item as unknown as Record}); DataForm({ type: 'float2', column: 'winterAll', item: item as unknown as Record}); DataForm({ type: 'float2', column: 'winterSunnyAvg', item: item as unknown as Record}); DataForm({ type: 'float2', column: 'winterSunnyMax', item: item as unknown as Record}); DataForm({ type: 'float2', column: 'winterSunnyMin', item: item as unknown as Record}); DataForm({ type: 'float2', column: 'groundWaterAvg', item: item as unknown as Record}); DataForm({ type: 'float2', column: 'groundWaterSummer', item: item as unknown as Record}); DataForm({ type: 'float2', column: 'groundWaterWinter', item: item as unknown as Record}); DataForm({ type: 'float2', column: 'rainRate', item: item as unknown as Record}); }; const changeValue=(operationalStatus, data, keyTxt = 'INFL_AMNT')=>{ operationalStatus.yearAvg = data.yearData ? (keyTxt.includes('_TP') || keyTxt.includes("_TN"))? data.yearData?Number(Math.round(data.yearData['AVG_'+keyTxt] * 1000) / 1000).toFixed(3).toString():'': data.yearData['AVG_'+keyTxt] : ''; operationalStatus.yearMax = data.yearData ? (keyTxt.includes('_TP') || keyTxt.includes("_TN"))? data.yearData?Number(Math.round(data.yearData['MAX_'+keyTxt] * 1000) / 1000).toFixed(3).toString():'': data.yearData['MAX_'+keyTxt] : ''; operationalStatus.yearMin = data.yearData ? (keyTxt.includes('_TP') || keyTxt.includes("_TN"))? data.yearData?Number(Math.round(data.yearData['MIN_'+keyTxt] * 1000) / 1000).toFixed(3).toString():'': data.yearData['MIN_'+keyTxt] : ''; // 여름 operationalStatus.summerAll = data.summer ? (keyTxt.includes('_TP') || keyTxt.includes("_TN"))? data.summer?Number(Math.round(data.summer['AVG_'+keyTxt] * 1000) / 1000).toFixed(3).toString():'': data.summer['AVG_'+keyTxt] : ''; operationalStatus.summerThree = data.summerRainy ? (keyTxt.includes('_TP') || keyTxt.includes("_TN"))? data.summerRainy?Number(Math.round(data.summerRainy["AVG_" + keyTxt] * 1000) / 1000).toFixed(3).toString():'': data.summerRainy["AVG_" + keyTxt] : ''; operationalStatus.summerRain = data.summerSunny ? (keyTxt.includes('_TP') || keyTxt.includes("_TN"))? data.summerSunny?Number(Math.round(data.summerSunny["AVG_" + keyTxt] * 1000) / 1000).toFixed(3).toString():'': data.summerSunny["AVG_" + keyTxt] : ''; // 겨울 operationalStatus.winterAll = data.winter ? (keyTxt.includes('_TP') || keyTxt.includes("_TN"))? data.winter?Number(Math.round(data.winter["AVG_" + keyTxt] * 1000) / 1000).toFixed(3).toString():'': data.winter["AVG_" + keyTxt] : ''; operationalStatus.winterSunnyMin = data.winterSunny ? (keyTxt.includes('_TP') || keyTxt.includes("_TN"))? data.winterSunny?Number(Math.round(data.winterSunny["MIN_" + keyTxt] * 1000) / 1000).toFixed(3).toString():'': data.winterSunny["MIN_" + keyTxt] : ''; operationalStatus.winterSunnyAvg = data.winterSunny ? (keyTxt.includes('_TP') || keyTxt.includes("_TN"))? data.winterSunny?Number(Math.round(data.winterSunny["AVG_" + keyTxt] * 1000) / 1000).toFixed(3).toString():'': data.winterSunny["AVG_" + keyTxt] : ''; operationalStatus.winterSunnyMax = data.winterSunny ? (keyTxt.includes('_TP') || keyTxt.includes("_TN"))? data.winterSunny?Number(Math.round(data.winterSunny["MAX_" + keyTxt] * 1000) / 1000).toFixed(3).toString():'': data.winterSunny["MAX_" + keyTxt] : ''; // 지하수 operationalStatus.groundWaterAvg = 10; operationalStatus.groundWaterSummer = 11; operationalStatus.groundWaterWinter = 12; // 오염물질 // RDII 추정 = 하절기(6~8월) 중 최저 유입 BOD일때 유입유량 x ((동절기 청천시 유입BOD - 하절기(6~8월) 중 최저 유입BOD) / (동절기 청천시 유입BOD)) const summerLowFlow = data.summerBod && data.summerBod.INFL_AMNT && data.summerBod.INFL_AMNT != 'null' ? Number(data.summerBod.INFL_AMNT) : 0; const winterAvgBod = data.winterSunny && data.winterSunny.AVG_INFL_ASSCT_BFR_WQLT_BOD && data.winterSunny.AVG_INFL_ASSCT_BFR_WQLT_BOD != 'null' ? Number(data.winterSunny.AVG_INFL_ASSCT_BFR_WQLT_BOD) : 0; const summerLowBod = data.summerBod && data.summerBod.MIN_INFL_ASSCT_BFR_WQLT_BOD && data.summerBod.MIN_INFL_ASSCT_BFR_WQLT_BOD != 'null' ? Number(data.summerBod.MIN_INFL_ASSCT_BFR_WQLT_BOD) : 0; const summerLowRain = data.summerBod && data.summerBod.INFO_RN_DAY && data.summerBod.INFO_RN_DAY != 'null' ? Number(data.summerBod.INFO_RN_DAY) : 0; operationalStatus.rdi = winterAvgBod === 0 ? 0 : summerLowFlow * ((winterAvgBod - summerLowBod) / winterAvgBod); operationalStatus.rdiRain = summerLowRain; } const calcValue = (operationalStatus, data, keyTxt='INFL_ASSCT_BFR_WQLT_TP') => { // 연간 operationalStatus.yearAvg = data.yearData && data.yearData['AVG_'+keyTxt] ? Number(Math.round(data.yearData['AVG_'+keyTxt] * 1000) / 1000).toFixed(3).toString() : ''; operationalStatus.yearMax = data.yearData && data.yearData['MAX_'+keyTxt] ? Number(Math.round(data.yearData['MAX_'+keyTxt] * 1000) / 1000).toFixed(3).toString() : ''; operationalStatus.yearMin = data.yearData && data.yearData['MIN_'+keyTxt] ? Number(Math.round(data.yearData['MIN_'+keyTxt] * 1000) / 1000).toFixed(3).toString() : ''; // 여름 operationalStatus.summerAll = data.summer && data.summer['AVG_'+keyTxt] ? Number(Math.round(data.summer['AVG_'+keyTxt] * 0.8 * 1000) / 1000).toFixed(3).toString() : ''; operationalStatus.summerThree = data.summerRainy && data.summerRainy['AVG_'+keyTxt] ? Number(Math.round(data.summerRainy['AVG_'+keyTxt] * 0.82 * 1000) / 1000).toFixed(3).toString() : ''; operationalStatus.summerRain = data.summerSunny && data.summerSunny['AVG_'+keyTxt] ? Number(Math.round(data.summerSunny['AVG_'+keyTxt] * 0.74 * 1000) / 1000).toFixed(3).toString() : ''; // 겨울 operationalStatus.winterAll = data.winter && data.winter['AVG_'+keyTxt] ? Number(Math.round(data.winter['AVG_'+keyTxt] * 1.16*1000) / 1000).toFixed(3).toString() : ''; operationalStatus.winterSunnyMin = data.winterSunny && data.winterSunny['MIN_'+keyTxt] ? Number(Math.round(data.winterSunny['MIN_'+keyTxt] * 1.2 * 1000) / 1000).toFixed(3).toString() : ''; operationalStatus.winterSunnyAvg = data.winterSunny && data.winterSunny['AVG_'+keyTxt] ? Number(Math.round(data.winterSunny['AVG_'+keyTxt] * 1.25 *1000) / 1000).toFixed(3).toString() : ''; operationalStatus.winterSunnyMax = data.winterSunny && data.winterSunny['MAX_'+keyTxt] ? Number(Math.round(data.winterSunny['MAX_'+keyTxt] * 1.3 *1000) / 1000).toFixed(3).toString() : ''; } type RtnFlowType = { inflAmnt: string | number; infoRnDay: string | number; bscFctCd: string; msrDt: string; } type RtnFlowResponse = { data: RtnFlowType[]; count: number; } const searchWaterUsage = async (searchYear: string, fcltyCd: string) => { const waterUsage = [0, 0, 0]; for (let i = 0; i < 3; i++) { try { const res = await getFetch('fo', '/fclt/flow/' + fcltyCd + '/' + (Number(searchYear)-i)) as RtnFlowResponse; let totWaterUsage = 0; if (res && res.data && Array.isArray(res.data)) { res.data.forEach((item: RtnFlowType) => { totWaterUsage += Number(item.inflAmnt); }); if (res.count > 0) { const avg = totWaterUsage / res.count; waterUsage[i] = parseFloat((avg * 0.65).toFixed(2)); } } } catch (error) { console.error(`Error fetching water usage for year ${Number(searchYear)-i}:`, error); waterUsage[i] = 0; } } return waterUsage; } // 강우영향일 계산 및 강우량 덮어씌우기 export const calRainEffectDayRainManage = (data: RainManageListProps[]) => { // 강우영향일 계산 (강우량이 3 초과이면 무조건 강우영향일) for(let idx = 0; idx < data.length; idx++) { const item = data[idx]; if(item){ if(item.infoRnDay && Number(item.infoRnDay) >= 3) { item.rainEffectDay = 1; } else { item.rainEffectDay = 0; } } } // 이틀 전, 하루 전이 강우영향일(3 이상)인 경우 해당 날도 강우영향일로 설정 for(let idx = 0; idx < data.length; idx++) { if(data[idx]) { // 하루 전이 강우영향일(3 이상)인 경우 if(idx > 0 && data[idx-1]?.infoRnDay && Number(data[idx-1]?.infoRnDay) >= 3) { data[idx]!.rainEffectDay = 1; } // 이틀 전이 강우영향일(3 이상)인 경우 if(idx > 1 && data[idx-2]?.infoRnDay && Number(data[idx-2]?.infoRnDay) >= 3) { data[idx]!.rainEffectDay = 1; } } } for(let idx = 0; idx < data.length; idx++) { if(data[idx] && data[idx]?.rainEffectDay === 1) { if(idx > 1){ if(data[idx-1]?.infoRnDay && Number(data[idx-1]?.infoRnDay) >= 3) { data[idx]!.infoRnDay = data[idx-1]!.infoRnDay; } } if(idx > 2){ if(data[idx-2]?.infoRnDay && Number(data[idx-2]?.infoRnDay) >= 3) { data[idx]!.infoRnDay = data[idx-2]!.infoRnDay; } } } } let rtnData : RainManageListProps[] = []; rtnData = data.filter((item: RainManageListProps) => item.rainEffectDay === 1); return rtnData; } export const dashBoardReducer:(set:(fn: (state: DashBoardType) => DashBoardType) => void)=>DashBoardActions=(set: (fn: (state: DashBoardType) => DashBoardType) => void) => { return { initializeDashBoardData: async () => { set((state: DashBoardType) => ({ ...state, DashboardMain: { ...state.DashboardMain, isInit: true, } })); }, /** 시설정보 및 운영현황 - 계획정보 */ searchPlanInfo : async (targetYear: string, fcltyCd: string) => { set((state: DashBoardType) => ({ ...state, PlanFclty: { ...state.PlanFclty, isLoadingPlanFclty: true, }, })); let waterUsage = [0, 0, 0]; waterUsage = await searchWaterUsage(targetYear, fcltyCd); set((state: DashBoardType) => ({ ...state, PlanFclty : { ...state.PlanFclty, waterUsage1 : waterUsage[0] || 0, waterUsage2 : waterUsage[1] || 0, waterUsage3 : waterUsage[2] || 0, }, })); const res = await fetchFacilityPlan(targetYear, fcltyCd, set); let minDiff=9999999; let minIndex; res.forEach((el:any, idx) => { if(minDiff>Math.abs(Number(targetYear) - Number(el.yr))){ minDiff=Math.abs(Number(targetYear) - Number(el.yr)); minIndex=idx; } }); const rtnPlanData = res[minIndex]; planFcltyList.map((el, index) => { planYearList = []; planYearList.push(rtnPlanData?rtnPlanData.yrDt4.toString():""); planYearList.push(rtnPlanData?rtnPlanData.yrDc1.toString():""); planYearList.push(rtnPlanData?rtnPlanData.yrDc2.toString():""); planYearList.push(rtnPlanData?rtnPlanData.yrDc3.toString():""); planYearList.push(rtnPlanData?rtnPlanData.yrDc4.toString():""); if(index === 0){ el.provisionalApproval = rtnPlanData?rtnPlanData.planSwageQntSumDt4:''; el.now = rtnPlanData?rtnPlanData.planSwageQntSum:''; el.stepOne = rtnPlanData?rtnPlanData.planSwageQntSumDc1:''; el.stepTwo = rtnPlanData?rtnPlanData.planSwageQntSumDc2:''; el.stepThree = rtnPlanData?rtnPlanData.planSwageQntSumDc3:''; el.stepFour = rtnPlanData?rtnPlanData.planSwageQntSumDc4:''; } if(index === 1){ el.provisionalApproval = rtnPlanData?rtnPlanData.swtrmtPpltnCntDt4:''; el.now = rtnPlanData?rtnPlanData.swtrmtPpltnCnt:''; el.stepOne = rtnPlanData?rtnPlanData.swtrmtPpltnCntDc1:''; el.stepTwo = rtnPlanData?rtnPlanData.swtrmtPpltnCntDc2:''; el.stepThree = rtnPlanData?rtnPlanData.swtrmtPpltnCntDc3:''; el.stepFour = rtnPlanData?rtnPlanData.swtrmtPpltnCntDc4:''; } if(index === 2){ el.provisionalApproval = rtnPlanData?rtnPlanData.swtrmtZoneAreaDt4:''; el.now = rtnPlanData?rtnPlanData.swtrmtZoneArea:''; el.stepOne = rtnPlanData?rtnPlanData.swtrmtZoneAreaDc1:''; el.stepTwo = rtnPlanData?rtnPlanData.swtrmtZoneAreaDc2:''; el.stepThree = rtnPlanData?rtnPlanData.swtrmtZoneAreaDc3:''; el.stepFour = rtnPlanData?rtnPlanData.swtrmtZoneAreaDc4:''; } if(index === 4){ el.provisionalApproval = rtnPlanData?rtnPlanData.ugwtUseSum:''; } // 임시시 dataFormSettingPlan(el); console.log('planFcltyList', planFcltyList); console.log('rtnPlanData', rtnPlanData); set((state: DashBoardType) => ({ ...state, PlanFclty: { ...state.PlanFclty, planFcltyList: planFcltyList, isLoadingPlanFclty: false, }, })); }); }, /** 시설정보 및 운영현황 - 운영실태 */ searchOperationStatus: async (isExcel: boolean, searchYear: string, fcltyCd: string) => { set((state: DashBoardType) => ({ ...state, OperationStatus: { ...state.OperationStatus, isLoadingOperationStatus: true, }, })); const res = await fetchOperationStatus(searchYear, fcltyCd); const data = res.data; if(data && operationalStatusList){ // 유량 - 유입 if (operationalStatusList?.[0]) { // 연간 const yearAvg = data.yearData===null?'':(data.yearData.AVG_INFL_AMNT?data.yearData.AVG_INFL_AMNT:0)+(data.yearData.AVG_SUM_FLOW?data.yearData.AVG_SUM_FLOW:0)+(data.yearData.AVG_RETURN_AMNT?data.yearData.AVG_RETURN_AMNT:0); const yearMax = data.yearData===null?'':(data.yearData.MAX_INFL_AMNT?data.yearData.MAX_INFL_AMNT:0)+(data.yearData.MAX_SUM_FLOW?data.yearData.MAX_SUM_FLOW:0)+(data.yearData.MAX_RETURN_AMNT?data.yearData.MAX_RETURN_AMNT:0); const yearMin = data.yearData===null?'':(data.yearData.MIN_INFL_AMNT?data.yearData.MIN_INFL_AMNT:0)+(data.yearData.MIN_SUM_FLOW?data.yearData.MIN_SUM_FLOW:0)+(data.yearData.MIN_RETURN_AMNT?data.yearData.MIN_RETURN_AMNT:0); operationalStatusList[0].yearAvg = yearAvg; operationalStatusList[0].yearMax = yearMax; operationalStatusList[0].yearMin = yearMin; // 여름 operationalStatusList[0].summerAll = data.summer === null ? '' : ( (data.summer.AVG_INFL_AMNT ? data.summer.AVG_INFL_AMNT : 0) + (data.summer.AVG_SUM_FLOW ? data.summer.AVG_SUM_FLOW : 0) + (data.summer.AVG_TP_INFL_WQLT_TP ? data.summer.AVG_TP_INFL_WQLT_TP : 0) ); operationalStatusList[0].summerThree = data.summerRainy === null ? '' : ( (data.summerRainy.AVG_INFL_AMNT ? data.summerRainy.AVG_INFL_AMNT : 0) + (data.summerRainy.AVG_SUM_FLOW ? data.summerRainy.AVG_SUM_FLOW : 0) + (data.summerRainy.AVG_TP_INFL_WQLT_TP ? data.summerRainy.AVG_TP_INFL_WQLT_TP : 0) ); operationalStatusList[0].summerRain = data.summerSunny === null ? '' : ( (data.summerSunny.AVG_INFL_AMNT ? data.summerSunny.AVG_INFL_AMNT : 0) + (data.summerSunny.AVG_SUM_FLOW ? data.summerSunny.AVG_SUM_FLOW : 0) + (data.summerSunny.AVG_TP_INFL_WQLT_TP ? data.summerSunny.AVG_TP_INFL_WQLT_TP : 0) ); // 겨울 operationalStatusList[0].winterAll = data.winter === null ? '' : (data.winter.AVG_INFL_AMNT ? data.winter.AVG_INFL_AMNT : 0) + (data.winter.AVG_SUM_FLOW ? data.winter.AVG_SUM_FLOW : 0) + (data.winter.AVG_TP_INFL_WQLT_TP ? data.winter.AVG_TP_INFL_WQLT_TP : 0); operationalStatusList[0].winterSunnyMin = data.winterSunny === null ? '' : (data.winterSunny.MIN_INFL_AMNT ? data.winterSunny.MIN_INFL_AMNT : 0) + (data.winterSunny.MIN_SUM_FLOW ? data.winterSunny.MIN_SUM_FLOW : 0) + (data.winterSunny.MIN_TP_INFL_WQLT_TP ? data.winterSunny.MIN_TP_INFL_WQLT_TP : 0); operationalStatusList[0].winterSunnyAvg = data.winterSunny === null ? '' : (data.winterSunny.AVG_INFL_AMNT ? data.winterSunny.AVG_INFL_AMNT : 0) + (data.winterSunny.AVG_SUM_FLOW ? data.winterSunny.AVG_SUM_FLOW : 0) + (data.winterSunny.AVG_TP_INFL_WQLT_TP ? data.winterSunny.AVG_TP_INFL_WQLT_TP : 0); operationalStatusList[0].winterSunnyMax = data.winterSunny === null ? '' : (data.winterSunny.MAX_INFL_AMNT ? data.winterSunny.MAX_INFL_AMNT : 0) + (data.winterSunny.MAX_SUM_FLOW ? data.winterSunny.MAX_SUM_FLOW : 0) + (data.winterSunny.MAX_TP_INFL_WQLT_TP ? data.winterSunny.MAX_TP_INFL_WQLT_TP : 0); // 연계처리수,지하수유입량 const bscFctCd = fcltyCd; const res2 = await getFetch('fo', '/fclt/flow/' + bscFctCd + '/' + searchYear) as ApiResponse; const calData = calRainEffectDay(res2.data, 'SUNNY'); let chungcunSumFlow = 0; let sumSummerChungcunDay = 0; let sumSummerChungcunFlow = 0; let sumWinterChungcunDay = 0; let sumWinterChungcunFlow = 0; /* let yearSumFlow = 0; let summerSumFlow = 0; let winterSumFlow = 0; */ calData.forEach((flowItem: FlowDataItem) => { chungcunSumFlow += flowItem.inflAmnt && flowItem.inflAmnt !== 'x' ? Number(flowItem.inflAmnt.toString().trim()) : 0; //yearSumFlow += flowItem.sumFlow && flowItem.sumFlow !== 'x' ? Number(flowItem.sumFlow.toString().trim()) : 0; if(flowItem.msrDt.substring(4,6) ==='06' || flowItem.msrDt.substring(4,6) ==='07' || flowItem.msrDt.substring(4,6) ==='08'){ sumSummerChungcunDay += 1; sumSummerChungcunFlow += flowItem.inflAmnt && flowItem.inflAmnt !== 'x' ? Number(flowItem.inflAmnt.toString().trim()) : 0; //summerSumFlow += flowItem.sumFlow && flowItem.sumFlow !== 'x' ? Number(flowItem.sumFlow.toString().trim()) : 0; }else if(flowItem.msrDt.substring(4,6) ==='01' || flowItem.msrDt.substring(4,6) ==='02'){ sumWinterChungcunDay += 1; sumWinterChungcunFlow += flowItem.inflAmnt && flowItem.inflAmnt !== 'x' ? Number(flowItem.inflAmnt.toString().trim()) : 0; // winterSumFlow += flowItem.sumFlow && flowItem.sumFlow !== 'x' ? Number(flowItem.sumFlow.toString().trim()) : 0; } }); // 연계처리수 /* const avgYearSumFlow = yearSumFlow / calData.length; const avgSummerSumFlow = summerSumFlow / calData.length; const avgWinterSumFlow = winterSumFlow / calData.length; */ // 지하수유입량 const usage = chungcunSumFlow / calData.length; const summerUsage = sumSummerChungcunFlow / sumSummerChungcunDay; const winterUsage = sumWinterChungcunFlow / sumWinterChungcunDay; operationalStatusList[0].groundWaterAvg = Math.round((usage-(usage*0.65*0.8)) * 100) / 100; operationalStatusList[0].groundWaterSummer = Math.round((summerUsage-(summerUsage*0.65*0.8)) * 100) / 100; operationalStatusList[0].groundWaterWinter = Math.round((winterUsage-(winterUsage*0.65*0.8)) * 100) / 100; //operationalStatusList[0].groundWaterAvg = calData.length === 0 ? '' : Number(calData[0].inflAmnt) - (Number(calData[0].inflAmnt)*0.65*0.8); //operationalStatusList[0].groundWaterSummer = calData.length === 0 ? '' : Number(calData[0].inflAmnt) - (Number(calData[0].inflAmnt)*0.65*0.8); //operationalStatusList[0].groundWaterWinter = calData.length === 0 ? '' : Number(calData[0].inflAmnt) - (Number(calData[0].inflAmnt)*0.65*0.8); // 오염물질 // RDII 추정 = 하절기(6~8월) 중 최저 유입 BOD일때 유입유량 x ((동절기 청천시 유입BOD - 하절기(6~8월) 중 최저 유입BOD) / (동절기 청천시 유입BOD)) const summerLowFlow = data.summerBod&&data.summerBod.INFL_AMNT&&data.summerBod.INFL_AMNT!='null'?Number(data.summerBod.INFL_AMNT):0; const winterAvgBod = data.winterSunny&&data.winterSunny.AVG_INFL_ASSCT_BFR_WQLT_BOD&&data.winterSunny.AVG_INFL_ASSCT_BFR_WQLT_BOD!='null'?Number(data.winterSunny.AVG_INFL_ASSCT_BFR_WQLT_BOD):0; const summerLowBod = data.summerBod&&data.summerBod.MIN_INFL_ASSCT_BFR_WQLT_BOD&&data.summerBod.MIN_INFL_ASSCT_BFR_WQLT_BOD!='null'?Number(data.summerBod.MIN_INFL_ASSCT_BFR_WQLT_BOD):0; const summerLowRain = data.summerBod&&data.summerBod.INFO_RN_DAY&&data.summerBod.INFO_RN_DAY!='null'?Number(data.summerBod.INFO_RN_DAY):0; operationalStatusList[0].rdi = winterAvgBod===0?0:summerLowFlow * ((winterAvgBod - summerLowBod) / winterAvgBod); operationalStatusList[0].rdiRain = summerLowRain; } if(operationalStatusList[0] && operationalStatusList[7]){ operationalStatusList[7].groundWaterAvg = operationalStatusList[0].groundWaterAvg === null ? '' : data.yearData && data.yearData.AVG_INFL_AMNT === 0 ? '' : Math.round((Number(operationalStatusList[0].groundWaterAvg) / (data.yearData && data.yearData.AVG_INFL_AMNT ? Number(data.yearData.AVG_INFL_AMNT) : 0) * 100) * 10) / 10+'%'; operationalStatusList[7].groundWaterSummer = operationalStatusList[0].groundWaterSummer === null ? '' : data.summer && data.summer.AVG_INFL_AMNT === 0 ? '' : Math.round((Number(operationalStatusList[0].groundWaterSummer) / (data.summer && data.summer.AVG_INFL_AMNT ? Number(data.summer.AVG_INFL_AMNT) : 0) * 100) * 10) / 10+'%'; operationalStatusList[7].groundWaterWinter = operationalStatusList[0].groundWaterWinter === null ? '' : data.winter && data.winter.AVG_INFL_AMNT === 0 ? '' : Math.round((Number(operationalStatusList[0].groundWaterWinter) / (data.winter && data.winter.AVG_INFL_AMNT ? Number(data.winter.AVG_INFL_AMNT) : 0) * 100) * 10) / 10+'%'; operationalStatusList[7].rdi = operationalStatusList[0].rdi === null ? '' : data.summerBod && data.summerBod.INFL_AMNT === 0 ? '' : Math.round((Number(operationalStatusList[0].rdi) / (data.summerBod&&data.summerBod.INFL_AMNT&&data.summerBod.INFL_AMNT!='null'?Number(data.summerBod.INFL_AMNT):0) * 100) * 10) / 10+'%'; /* operationalStatusList[7].groundWaterAvg = operationalStatusList[0].groundWaterAvg === null ? '' : Number(Number(operationalStatusList[0].groundWaterAvg) / Number(data.yearData.AVG_INFL_AMNT)) * 100; operationalStatusList[7].groundWaterSummer = operationalStatusList[0].groundWaterSummer === null ? '' : Number(Number(operationalStatusList[0].groundWaterSummer) / Number(data.summer.AVG_INFL_AMNT)) * 100; operationalStatusList[7].groundWaterWinter = operationalStatusList[0].groundWaterWinter === null ? '' : Number(Number(operationalStatusList[0].groundWaterWinter) / Number(data.winter.AVG_INFL_AMNT)) * 100;*/ dataFormSetting(operationalStatusList[0]); } for(let i=1; i { dataFormSetting(item) item.fctCpc = parseFloat(item.fctCpc.toString().replace(/,/g, '')); item.sidoNm = item.lclgvrnmntNm.split(' ')[0]?.toString() || ''; item.sggNm = item.lclgvrnmntNm.split(' ')[1]?.toString() || ''; excelDownList.push({ 시설코드: item.bscFctCd, 시설이름: item.bscFctNm, 측정일자: item.msrDt, 시도: item.sidoNm, 시군구: item.sggNm, 주소: item.addr, 용량: item.fctCpc, 유입BOD: item.inflAssctBfrWqltBod, 유입TN: item.inflAssctBfrWqltTn, 유입TP: item.inflAssctBfrWqltTp, 유출BOD: item.efflWqltBod, 유출TN: item.efflWqltTn, 유출TP: item.efflWqltTp, 환경청: item.rgnNm, 유역: item.rvbsn, 대유역: item.lgbsn, 중유역: item.mdmbsn, }); }); }else{ */ /* data.forEach((item: OperationalStatusListProps) => { }); */ /* } */ set((state: DashBoardType) => ({ ...state, OperationStatus: { ...state.OperationStatus, operationalStatusList: operationalStatusList, operationalStatusCount: res.count, isLoadingOperationStatus : false, }, })) }, searchMainGraph: async (searchYear: string, fcltyCd: string) => { set((state: DashBoardType) => ({ ...state, MainGraph: { ...state.MainGraph, isLoadingMainGraph: true, }, })); const res = await fetchMainGraph(searchYear, fcltyCd); if(res == null || res.data == null || res.data.length === 0) { set((state: DashBoardType) => ({ ...state, MainGraph: { ...state.MainGraph, chart_inflowRain: [], chart_bodRain: [], chart_inflTp: [], chart_chongInTp: [], chart_efflTp: [], chart_inflTn: [], chart_efflTn: [], chart_inflBod: [], chart_efflBod: [], isLoadingMainGraph : false, } })); return; } const chart_inflowRain = res.data.wqltObjs.map((item: FacilityWaterQltyProps) => ({ label: item.msrDt.substring(0, 4)+"-"+item.msrDt.substring(4, 6)+"-"+item.msrDt.substring(6, 8), barVal0: item.infoRnDay ?? 0, lineVal0: item.fctCpc ?? 0, lineVal1: item.inflAmnt ?? 0, })); const chart_bodRain = res.data.wqltObjs.map((item: FacilityWaterQltyProps) => ({ label: item.msrDt.substring(0, 4)+"-"+item.msrDt.substring(4, 6)+"-"+item.msrDt.substring(6, 8), barVal0: item.infoRnDay ?? 0, lineVal0: item.inflAssctBfrWqltBod ?? 0, })); const chart_inflTp = res.data.wqltObjs.map((item: FacilityWaterQltyProps) => ({ label: item.msrDt.substring(0, 4)+"-"+item.msrDt.substring(4, 6)+"-"+item.msrDt.substring(6, 8), val : item.inflAssctBfrWqltTp ?? 0 })); const chart_chongInTp = res.data.wqltObjs.map((item: FacilityWaterQltyProps) => ({ label: item.msrDt.substring(0, 4)+"-"+item.msrDt.substring(4, 6)+"-"+item.msrDt.substring(6, 8), val : item.tpInflWqltTp ?? 0 })); const chart_efflTp = res.data.wqltObjs.map((item: FacilityWaterQltyProps) => ({ label: item.msrDt.substring(0, 4)+"-"+item.msrDt.substring(4, 6)+"-"+item.msrDt.substring(6, 8), val : item.efflWqltTp ?? 0 })); const chart_inflTn = res.data.wqltObjs.map((item: FacilityWaterQltyProps) => ({ label: item.msrDt.substring(0, 4)+"-"+item.msrDt.substring(4, 6)+"-"+item.msrDt.substring(6, 8), val : item.inflAssctBfrWqltTn ?? 0 })); const chart_efflTn = res.data.wqltObjs.map((item: FacilityWaterQltyProps) => ({ label: item.msrDt.substring(0, 4)+"-"+item.msrDt.substring(4, 6)+"-"+item.msrDt.substring(6, 8), val : item.efflWqltTn ?? 0 })); const chart_inflBod = res.data.wqltObjs.map((item: FacilityWaterQltyProps) => ({ label: item.msrDt.substring(0, 4)+"-"+item.msrDt.substring(4, 6)+"-"+item.msrDt.substring(6, 8), val : item.inflAssctBfrWqltBod ?? 0 })); const chart_efflBod = res.data.wqltObjs.map((item: FacilityWaterQltyProps) => ({ label: item.msrDt.substring(0, 4)+"-"+item.msrDt.substring(4, 6)+"-"+item.msrDt.substring(6, 8), val : item.efflWqltBod ?? 0 })); set((state: DashBoardType) => ({ ...state, MainGraph: { ...state.MainGraph, chart_inflowRain: chart_inflowRain, chart_bodRain: chart_bodRain, chart_inflTp: chart_inflTp, chart_chongInTp : chart_chongInTp, chart_efflTp: chart_efflTp, chart_inflTn: chart_inflTn, chart_efflTn: chart_efflTn, chart_inflBod: chart_inflBod, chart_efflBod: chart_efflBod, isLoadingMainGraph : false, }, })) }, searchRainManage: async (searchYear: string, fcltyCd: string, isExcel : boolean) => { set((state: DashBoardType) => ({ ...state, RainManage: { ...state.RainManage, isLoadingRainManage: true, }, })); const res = await fetchMainGraph(searchYear, fcltyCd); if(res == null || res.data.wqltObjs == null || res.data.wqltObjs.length === 0) { set((state: DashBoardType) => ({ ...state, RainManage: { ...state.RainManage, rainManageList: [], isLoadingRainManage : false, } })); return; } const fcltyCpcValue = res.data.wqltObjs[0].fctCpc; const itemList = ['계', '3~10mm 미만', '10~20mm 미만', '20~30mm 미만', '30~40mm 미만', '40~50mm 미만', '50mm~60mm 미만', '60mm 이상']; const rainRate = ['0', '0', '0', '0', '0', '0', '0', '0']; const rainDate = [0, 0, 0, 0, 0, 0, 0, 0]; const inflAmtCnt = [0, 0, 0, 0, 0, 0, 0, 0]; const inflAmnt = [0, 0, 0, 0, 0, 0, 0, 0]; const fcltyCpct = [0, 0, 0, 0, 0, 0, 0, 0]; const dsInflWqltBod: number[] = [0, 0, 0, 0, 0, 0, 0, 0]; const dsInflWqltCod: number[] = [0, 0, 0, 0, 0, 0, 0, 0]; const dsInflWqltSs: number[] = [0, 0, 0, 0, 0, 0, 0, 0]; const dsInflWqltTn: number[] = [0, 0, 0, 0, 0, 0, 0, 0]; const dsInflWqltTp: number[] = [0, 0, 0, 0, 0, 0, 0, 0]; const inflAssctBfrWqltBodCnt = [0, 0, 0, 0, 0, 0, 0, 0]; const inflAssctBfrWqltBod = [0, 0, 0, 0, 0, 0, 0, 0]; const inflAssctBfrWqltTocCnt = [0, 0, 0, 0, 0, 0, 0, 0]; const inflAssctBfrWqltToc = [0, 0, 0, 0, 0, 0, 0, 0]; const inflAssctBfrWqltSsCnt = [0, 0, 0, 0, 0, 0, 0, 0]; const inflAssctBfrWqltSs = [0, 0, 0, 0, 0, 0, 0, 0]; const inflAssctBfrWqltTnCnt = [0, 0, 0, 0, 0, 0, 0, 0]; const inflAssctBfrWqltTn = [0, 0, 0, 0, 0, 0, 0, 0]; const inflAssctBfrWqltTpCnt = [0, 0, 0, 0, 0, 0, 0, 0]; const inflAssctBfrWqltTp = [0, 0, 0, 0, 0, 0, 0, 0]; const efflWqltBodCnt = [0, 0, 0, 0, 0, 0, 0, 0]; const efflWqltBod = [0, 0, 0, 0, 0, 0, 0, 0]; const efflWqltTocCnt = [0, 0, 0, 0, 0, 0, 0, 0]; const efflWqltToc = [0, 0, 0, 0, 0, 0, 0, 0]; const efflWqltSsCnt = [0, 0, 0, 0, 0, 0, 0, 0]; const efflWqltSs = [0, 0, 0, 0, 0, 0, 0, 0]; const efflWqltTnCnt = [0, 0, 0, 0, 0, 0, 0, 0]; const efflWqltTn = [0, 0, 0, 0, 0, 0, 0, 0]; const efflWqltTpCnt = [0, 0, 0, 0, 0, 0, 0, 0]; const efflWqltTp = [0, 0, 0, 0, 0, 0, 0, 0]; // 청천시 중 강우영향일인 날짜는 이전의 강우량을 대입해 리스트 수정 const rainEffectList = calRainEffectDayRainManage(res.data.wqltObjs); // Process the data and create rain management list rainEffectList.forEach((item: RainManageListProps) => { if(Number(item.infoRnDay) >= 3 && Number(item.infoRnDay) < 10){ rainDate[1] = Number(rainDate[1] || 0) + 1; inflAmtCnt[1] = Number(inflAmtCnt[1] || 0) + 1; inflAmnt[1] = Number(inflAmnt[1] || 0) + Number(item.inflAmnt || 0); fcltyCpct[1] = 0; inflAssctBfrWqltBodCnt[1] = Number(inflAssctBfrWqltBodCnt[1] || 0) + 1; inflAssctBfrWqltBod[1] = Number(inflAssctBfrWqltBod[1] || 0) + Number(item.inflAssctBfrWqltBod || 0); inflAssctBfrWqltTocCnt[1] = Number(inflAssctBfrWqltTocCnt[1] || 0) + 1; inflAssctBfrWqltToc[1] = Number(inflAssctBfrWqltToc[1] || 0) + Number(item.inflAssctBfrWqltToc || 0); inflAssctBfrWqltSsCnt[1] = Number(inflAssctBfrWqltSsCnt[1] || 0) + 1; inflAssctBfrWqltSs[1] = Number(inflAssctBfrWqltSs[1] || 0) + Number(item.inflAssctBfrWqltSs || 0); inflAssctBfrWqltTnCnt[1] = Number(inflAssctBfrWqltTnCnt[1] || 0) + 1; inflAssctBfrWqltTn[1] = Number(inflAssctBfrWqltTn[1] || 0) + Number(item.inflAssctBfrWqltTn || 0); inflAssctBfrWqltTpCnt[1] = Number(inflAssctBfrWqltTpCnt[1] || 0) + 1; inflAssctBfrWqltTp[1] = Number(inflAssctBfrWqltTp[1] || 0) + Number(item.inflAssctBfrWqltTp || 0); efflWqltBodCnt[1] = Number(efflWqltBodCnt[1] || 0) + 1; efflWqltBod[1] = Number(efflWqltBod[1] || 0) + Number(item.efflWqltBod || 0); efflWqltTocCnt[1] = Number(efflWqltTocCnt[1] || 0) + 1; efflWqltToc[1] = Number(efflWqltToc[1] || 0) + Number(item.efflWqltToc || 0); efflWqltSsCnt[1] = Number(efflWqltSsCnt[1] || 0) + 1; efflWqltSs[1] = Number(efflWqltSs[1] || 0) + Number(item.efflWqltSs || 0); efflWqltTnCnt[1] = Number(efflWqltTnCnt[1] || 0) + 1; efflWqltTn[1] = Number(efflWqltTn[1] || 0) + Number(item.efflWqltTn || 0); efflWqltTpCnt[1] = Number(efflWqltTpCnt[1] || 0) + 1; efflWqltTp[1] = Number(efflWqltTp[1] || 0) + Number(item.efflWqltTp || 0); }else if(Number(item.infoRnDay) >= 10 && Number(item.infoRnDay) < 20){ rainDate[2] = Number(rainDate[2] || 0) + 1; inflAmtCnt[2] = Number(inflAmtCnt[2] || 0) + 1; inflAmnt[2] = Number(inflAmnt[2] || 0) + Number(item.inflAmnt || 0); fcltyCpct[2] = 0; inflAssctBfrWqltBodCnt[2] = Number(inflAssctBfrWqltBodCnt[2] || 0) + 1; inflAssctBfrWqltBod[2] = Number(inflAssctBfrWqltBod[2] || 0) + Number(item.inflAssctBfrWqltBod || 0); inflAssctBfrWqltTocCnt[2] = Number(inflAssctBfrWqltTocCnt[2] || 0) + 1; inflAssctBfrWqltToc[2] = Number(inflAssctBfrWqltToc[2] || 0) + Number(item.inflAssctBfrWqltToc || 0); inflAssctBfrWqltSsCnt[2] = Number(inflAssctBfrWqltSsCnt[2] || 0) + 1; inflAssctBfrWqltSs[2] = Number(inflAssctBfrWqltSs[2] || 0) + Number(item.inflAssctBfrWqltSs || 0); inflAssctBfrWqltTnCnt[2] = Number(inflAssctBfrWqltTnCnt[2] || 0) + 1; inflAssctBfrWqltTn[2] = Number(inflAssctBfrWqltTn[2] || 0) + Number(item.inflAssctBfrWqltTn || 0); inflAssctBfrWqltTpCnt[2] = Number(inflAssctBfrWqltTpCnt[2] || 0) + 1; inflAssctBfrWqltTp[2] = Number(inflAssctBfrWqltTp[2] || 0) + Number(item.inflAssctBfrWqltTp || 0); efflWqltBodCnt[2] = Number(efflWqltBodCnt[2] || 0) + 1; efflWqltBod[2] = Number(efflWqltBod[2] || 0) + Number(item.efflWqltBod || 0); efflWqltTocCnt[2] = Number(efflWqltTocCnt[2] || 0) + 1; efflWqltToc[2] = Number(efflWqltToc[2] || 0) + Number(item.efflWqltToc || 0); efflWqltSsCnt[2] = Number(efflWqltSsCnt[2] || 0) + 1; efflWqltSs[2] = Number(efflWqltSs[2] || 0) + Number(item.efflWqltSs || 0); efflWqltTnCnt[2] = Number(efflWqltTnCnt[2] || 0) + 1; efflWqltTn[2] = Number(efflWqltTn[2] || 0) + Number(item.efflWqltTn || 0); efflWqltTpCnt[2] = Number(efflWqltTpCnt[2] || 0) + 1; efflWqltTp[2] = Number(efflWqltTp[2] || 0) + Number(item.efflWqltTp || 0); }else if(Number(item.infoRnDay) >= 20 && Number(item.infoRnDay) < 30){ rainDate[3] = Number(rainDate[3] || 0) + 1; inflAmtCnt[3] = Number(inflAmtCnt[3] || 0) + 1; inflAmnt[3] = Number(inflAmnt[3] || 0) + Number(item.inflAmnt || 0); fcltyCpct[3] = 0; inflAssctBfrWqltBodCnt[3] = Number(inflAssctBfrWqltBodCnt[3] || 0) + 1; inflAssctBfrWqltBod[3] = Number(inflAssctBfrWqltBod[3] || 0) + Number(item.inflAssctBfrWqltBod || 0); inflAssctBfrWqltTocCnt[3] = Number(inflAssctBfrWqltTocCnt[3] || 0) + 1; inflAssctBfrWqltToc[3] = Number(inflAssctBfrWqltToc[3] || 0) + Number(item.inflAssctBfrWqltToc || 0); inflAssctBfrWqltSsCnt[3] = Number(inflAssctBfrWqltSsCnt[3] || 0) + 1; inflAssctBfrWqltSs[3] = Number(inflAssctBfrWqltSs[3] || 0) + Number(item.inflAssctBfrWqltSs || 0); inflAssctBfrWqltTnCnt[3] = Number(inflAssctBfrWqltTnCnt[3] || 0) + 1; inflAssctBfrWqltTn[3] = Number(inflAssctBfrWqltTn[3] || 0) + Number(item.inflAssctBfrWqltTn || 0); inflAssctBfrWqltTpCnt[3] = Number(inflAssctBfrWqltTpCnt[3] || 0) + 1; inflAssctBfrWqltTp[3] = Number(inflAssctBfrWqltTp[3] || 0) + Number(item.inflAssctBfrWqltTp || 0); efflWqltBodCnt[3] = Number(efflWqltBodCnt[3] || 0) + 1; efflWqltBod[3] = Number(efflWqltBod[3] || 0) + Number(item.efflWqltBod || 0); efflWqltTocCnt[3] = Number(efflWqltTocCnt[3] || 0) + 1; efflWqltToc[3] = Number(efflWqltToc[3] || 0) + Number(item.efflWqltToc || 0); efflWqltSsCnt[3] = Number(efflWqltSsCnt[3] || 0) + 1; efflWqltSs[3] = Number(efflWqltSs[3] || 0) + Number(item.efflWqltSs || 0); efflWqltTnCnt[3] = Number(efflWqltTnCnt[3] || 0) + 1; efflWqltTn[3] = Number(efflWqltTn[3] || 0) + Number(item.efflWqltTn || 0); efflWqltTpCnt[3] = Number(efflWqltTpCnt[3] || 0) + 1; efflWqltTp[3] = Number(efflWqltTp[3] || 0) + Number(item.efflWqltTp || 0); }else if(Number(item.infoRnDay) >= 30 && Number(item.infoRnDay) < 40){ rainDate[4] = Number(rainDate[4] || 0) + 1; inflAmtCnt[4] = Number(inflAmtCnt[4] || 0) + 1; inflAmnt[4] = Number(inflAmnt[4] || 0) + Number(item.inflAmnt || 0); fcltyCpct[4] = item.inflAmnt&&Number(item.inflAmnt) !== 0 ? Number(Math.round(Number(item.inflAmnt) / Number(item.fctCpc) * 10) / 10) : 0; inflAssctBfrWqltBodCnt[4] = Number(inflAssctBfrWqltBodCnt[4] || 0) + 1; inflAssctBfrWqltBod[4] = Number(inflAssctBfrWqltBod[4] || 0) + Number(item.inflAssctBfrWqltBod || 0); inflAssctBfrWqltTocCnt[4] = Number(inflAssctBfrWqltTocCnt[4] || 0) + 1; inflAssctBfrWqltToc[4] = Number(inflAssctBfrWqltToc[4] || 0) + Number(item.inflAssctBfrWqltToc || 0); inflAssctBfrWqltSsCnt[4] = Number(inflAssctBfrWqltSsCnt[4] || 0) + 1; inflAssctBfrWqltSs[4] = Number(inflAssctBfrWqltSs[4] || 0) + Number(item.inflAssctBfrWqltSs || 0); inflAssctBfrWqltTnCnt[4] = Number(inflAssctBfrWqltTnCnt[4] || 0) + 1; inflAssctBfrWqltTn[4] = Number(inflAssctBfrWqltTn[5] || 0) + Number(item.inflAssctBfrWqltTn || 0); inflAssctBfrWqltTpCnt[4] = Number(inflAssctBfrWqltTpCnt[4] || 0) + 1; inflAssctBfrWqltTp[4] = Number(inflAssctBfrWqltTp[4] || 0) + Number(item.inflAssctBfrWqltTp || 0); efflWqltBodCnt[4] = Number(efflWqltBodCnt[4] || 0) + 1; efflWqltBod[4] = Number(efflWqltBod[4] || 0) + Number(item.efflWqltBod || 0); efflWqltTocCnt[4] = Number(efflWqltTocCnt[4] || 0) + 1; efflWqltToc[4] = Number(efflWqltToc[4] || 0) + Number(item.efflWqltToc || 0); efflWqltSsCnt[4] = Number(efflWqltSsCnt[4] || 0) + 1; efflWqltSs[4] = Number(efflWqltSs[4] || 0) + Number(item.efflWqltSs || 0); efflWqltTnCnt[4] = Number(efflWqltTnCnt[5] || 0) + 1; efflWqltTn[4] = Number(efflWqltTn[4] || 0) + Number(item.efflWqltTn || 0); efflWqltTpCnt[4] = Number(efflWqltTpCnt[5] || 0) + 1; efflWqltTp[4] = Number(efflWqltTp[4] || 0) + Number(item.efflWqltTp || 0); }else if(Number(item.infoRnDay) >= 40 && Number(item.infoRnDay) < 50){ rainDate[5] = Number(rainDate[5] || 0) + 1; inflAmtCnt[5] = Number(inflAmtCnt[5] || 0) + 1; inflAmnt[5] = Number(inflAmnt[5] || 0) + Number(item.inflAmnt || 0); fcltyCpct[5] = 0; inflAssctBfrWqltBodCnt[5] = Number(inflAssctBfrWqltBodCnt[5] || 0) + 1; inflAssctBfrWqltBod[5] = Number(inflAssctBfrWqltBod[5] || 0) + Number(item.inflAssctBfrWqltBod || 0); inflAssctBfrWqltTocCnt[5] = Number(inflAssctBfrWqltTocCnt[5] || 0) + 1; inflAssctBfrWqltToc[5] = Number(inflAssctBfrWqltToc[5] || 0) + Number(item.inflAssctBfrWqltToc || 0); inflAssctBfrWqltSsCnt[5] = Number(inflAssctBfrWqltSsCnt[5] || 0) + 1; inflAssctBfrWqltSs[5] = Number(inflAssctBfrWqltSs[5] || 0) + Number(item.inflAssctBfrWqltSs || 0); inflAssctBfrWqltTnCnt[5] = Number(inflAssctBfrWqltTnCnt[5] || 0) + 1; inflAssctBfrWqltTn[5] = Number(inflAssctBfrWqltTn[5] || 0) + Number(item.inflAssctBfrWqltTn || 0); inflAssctBfrWqltTpCnt[5] = Number(inflAssctBfrWqltTpCnt[5] || 0) + 1; inflAssctBfrWqltTp[5] = Number(inflAssctBfrWqltTp[5] || 0) + Number(item.inflAssctBfrWqltTp || 0); efflWqltBodCnt[5] = Number(efflWqltBodCnt[5] || 0) + 1; efflWqltBod[5] = Number(efflWqltBod[5] || 0) + Number(item.efflWqltBod || 0); efflWqltTocCnt[5] = Number(efflWqltTocCnt[5] || 0) + 1; efflWqltToc[5] = Number(efflWqltToc[5] || 0) + Number(item.efflWqltToc || 0); efflWqltSsCnt[5] = Number(efflWqltSsCnt[5] || 0) + 1; efflWqltSs[5] = Number(efflWqltSs[5] || 0) + Number(item.efflWqltSs || 0); efflWqltTnCnt[5] = Number(efflWqltTnCnt[5] || 0) + 1; efflWqltTn[5] = Number(efflWqltTn[5] || 0) + Number(item.efflWqltTn || 0); efflWqltTpCnt[5] = Number(efflWqltTpCnt[5] || 0) + 1; efflWqltTp[5] = Number(efflWqltTp[5] || 0) + Number(item.efflWqltTp || 0); }else if(Number(item.infoRnDay) >= 50 && Number(item.infoRnDay) < 60){ rainDate[6] = Number(rainDate[6] || 0) + 1; inflAmtCnt[6] = Number(inflAmtCnt[6] || 0) + 1; inflAmnt[6] = Number(inflAmnt[6] || 0) + Number(item.inflAmnt || 0); fcltyCpct[6] = 0; inflAssctBfrWqltBodCnt[6] = Number(inflAssctBfrWqltBodCnt[6] || 0) + 1; inflAssctBfrWqltBod[6] = Number(inflAssctBfrWqltBod[6] || 0) + Number(item.inflAssctBfrWqltBod || 0); inflAssctBfrWqltTocCnt[6] = Number(inflAssctBfrWqltTocCnt[6] || 0) + 1; inflAssctBfrWqltToc[6] = Number(inflAssctBfrWqltToc[6] || 0) + Number(item.inflAssctBfrWqltToc || 0); inflAssctBfrWqltSsCnt[6] = Number(inflAssctBfrWqltSsCnt[6] || 0) + 1; inflAssctBfrWqltSs[6] = Number(inflAssctBfrWqltSs[6] || 0) + Number(item.inflAssctBfrWqltSs || 0); inflAssctBfrWqltTnCnt[6] = Number(inflAssctBfrWqltTnCnt[6] || 0) + 1; inflAssctBfrWqltTn[6] = Number(inflAssctBfrWqltTn[6] || 0) + Number(item.inflAssctBfrWqltTn || 0); inflAssctBfrWqltTpCnt[6] = Number(inflAssctBfrWqltTpCnt[6] || 0) + 1; inflAssctBfrWqltTp[6] = Number(inflAssctBfrWqltTp[6] || 0) + Number(item.inflAssctBfrWqltTp || 0); efflWqltBodCnt[6] = Number(efflWqltBodCnt[6] || 0) + 1; efflWqltBod[6] = Number(efflWqltBod[6] || 0) + Number(item.efflWqltBod || 0); efflWqltTocCnt[6] = Number(efflWqltTocCnt[6] || 0) + 1; efflWqltToc[6] = Number(efflWqltToc[6] || 0) + Number(item.efflWqltToc || 0); efflWqltSsCnt[6] = Number(efflWqltSsCnt[6] || 0) + 1; efflWqltSs[6] = Number(efflWqltSs[6] || 0) + Number(item.efflWqltSs || 0); efflWqltTnCnt[6] = Number(efflWqltTnCnt[6] || 0) + 1; efflWqltTn[6] = Number(efflWqltTn[6] || 0) + Number(item.efflWqltTn || 0); efflWqltTpCnt[6] = Number(efflWqltTpCnt[6] || 0) + 1; efflWqltTp[6] = Number(efflWqltTp[6] || 0) + Number(item.efflWqltTp || 0); }else if(Number(item.infoRnDay) >= 60){ rainDate[7] = Number(rainDate[7] || 0) + 1; inflAmtCnt[7] = Number(inflAmtCnt[7] || 0) + 1; inflAmnt[7] = Number(inflAmnt[7] || 0) + Number(item.inflAmnt || 0); fcltyCpct[7] = 0; inflAssctBfrWqltBodCnt[7] = Number(inflAssctBfrWqltBodCnt[7] || 0) + 1; inflAssctBfrWqltBod[7] = Number(inflAssctBfrWqltBod[7] || 0) + Number(item.inflAssctBfrWqltBod || 0); inflAssctBfrWqltTocCnt[7] = Number(inflAssctBfrWqltTocCnt[7] || 0) + 1; inflAssctBfrWqltToc[7] = Number(inflAssctBfrWqltToc[7] || 0) + Number(item.inflAssctBfrWqltToc || 0); inflAssctBfrWqltSsCnt[7] = Number(inflAssctBfrWqltSsCnt[7] || 0) + 1; inflAssctBfrWqltSs[7] = Number(inflAssctBfrWqltSs[7] || 0) + Number(item.inflAssctBfrWqltSs || 0); inflAssctBfrWqltTnCnt[7] = Number(inflAssctBfrWqltTnCnt[7] || 0) + 1; inflAssctBfrWqltTn[7] = Number(inflAssctBfrWqltTn[7] || 0) + Number(item.inflAssctBfrWqltTn || 0); inflAssctBfrWqltTpCnt[7] = Number(inflAssctBfrWqltTpCnt[7] || 0) + 1; inflAssctBfrWqltTp[7] = Number(inflAssctBfrWqltTp[7] || 0) + Number(item.inflAssctBfrWqltTp || 0); efflWqltBodCnt[7] = Number(efflWqltBodCnt[7] || 0) + 1; efflWqltBod[7] = Number(efflWqltBod[7] || 0) + Number(item.efflWqltBod || 0); efflWqltTocCnt[7] = Number(efflWqltTocCnt[7] || 0) + 1; efflWqltToc[7] = Number(efflWqltToc[7] || 0) + Number(item.efflWqltToc || 0); efflWqltSsCnt[7] = Number(efflWqltSsCnt[7] || 0) + 1; efflWqltSs[7] = Number(efflWqltSs[7] || 0) + Number(item.efflWqltSs || 0); efflWqltTnCnt[7] = Number(efflWqltTnCnt[7] || 0) + 1; efflWqltTn[7] = Number(efflWqltTn[7] || 0) + Number(item.efflWqltTn || 0); efflWqltTpCnt[7] = Number(efflWqltTpCnt[7] || 0) + 1; efflWqltTp[7] = Number(efflWqltTp[7] || 0) + Number(item.efflWqltTp || 0); } }); // Process the data and create rain management list if(res.data&&res.data.dsWqltObjs&&res.data.dsWqltObjs.length > 0){ // 설계 유입수질 데이터 가져오기 - 0값이 있으면 이전 차수에서 가져오기 const getDesignWaterQualityData = (stepIndex: number, maxPreviousSteps: number = 3) => { for (let i = 0; i <= maxPreviousSteps && stepIndex - i >= 0; i++) { const currentStep = res.data.dsWqltObjs[stepIndex - i]; if (currentStep && currentStep.dsInflWqltBod > 0 && currentStep.dsInflWqltCod > 0 && currentStep.dsInflWqltSs > 0 && currentStep.dsInflWqltTn > 0 && currentStep.dsInflWqltTp > 0) { return { dsInflWqltBod: currentStep.dsInflWqltBod, dsInflWqltCod: currentStep.dsInflWqltCod, dsInflWqltSs: currentStep.dsInflWqltSs, dsInflWqltTn: currentStep.dsInflWqltTn, dsInflWqltTp: currentStep.dsInflWqltTp }; } } // 모든 차수에서 유효한 데이터를 찾지 못한 경우 기본값 반환 return { dsInflWqltBod: 0, dsInflWqltCod: 0, dsInflWqltSs: 0, dsInflWqltTn: 0, dsInflWqltTp: 0 }; }; const lastStepIndex = res.data.dsWqltObjs.length - 1; const designData = getDesignWaterQualityData(lastStepIndex); dsInflWqltBod[0] = designData.dsInflWqltBod; dsInflWqltCod[0] = designData.dsInflWqltCod; dsInflWqltSs[0] = designData.dsInflWqltSs; dsInflWqltTn[0] = designData.dsInflWqltTn; dsInflWqltTp[0] = designData.dsInflWqltTp; } rainDate[0] = (Number(rainDate[1]) || 0) + (Number(rainDate[2]) || 0) + (Number(rainDate[3]) || 0) + (Number(rainDate[4]) || 0) + (Number(rainDate[5]) || 0) + (Number(rainDate[6]) || 0) + (Number(rainDate[7]) || 0); // 강수비율 for(let idx=0; idx 0){ rainRate[0] = '100'; rainRate[idx] = (Math.round(Number(rainDate[idx])/Number(rainDate[0])*100*100)/100).toString(); } } // 평균 및 합계 계산 const calculateAverage = (value: number, count: number) => { return count > 0 ? Number((value / count).toFixed(1)) : 0; }; // 데이터 있는 항목만 계산 let dataIsCount = 0; for(let idx=0; idx 0){ dataIsCount++; } } for(let idx=0; idx { return Number((arr.slice(1).reduce((sum, val) => sum + Number(val), 0)).toFixed(1)); }; inflAmnt[0] = calculateAverage(calculateTotal(inflAmnt), dataIsCount); fcltyCpct[0] = calculateTotal(fcltyCpct); inflAssctBfrWqltBod[0] = Number((calculateTotal(inflAssctBfrWqltBod)/7).toFixed(1)); inflAssctBfrWqltToc[0] = Number((calculateTotal(inflAssctBfrWqltToc)/7).toFixed(1)); inflAssctBfrWqltSs[0] = Number((calculateTotal(inflAssctBfrWqltSs)/7).toFixed(1)); inflAssctBfrWqltTn[0] = Number((calculateTotal(inflAssctBfrWqltTn)/7).toFixed(3)); inflAssctBfrWqltTp[0] = Number((calculateTotal(inflAssctBfrWqltTp)/7).toFixed(3)); efflWqltBod[0] = Number((calculateTotal(efflWqltBod)/7).toFixed(1)); efflWqltToc[0] = Number((calculateTotal(efflWqltToc)/7).toFixed(1)); efflWqltSs[0] = Number((calculateTotal(efflWqltSs as number[])/7).toFixed(1)); efflWqltTn[0] = Number((calculateTotal(efflWqltTn as number[])/7).toFixed(3)); efflWqltTp[0] = Number((calculateTotal(efflWqltTp as number[])/7).toFixed(3)); // 최종 리스트 const filteredData = itemList.map((item, index) => ({ rainItem: item, rainRate: rainRate[index] || '0', rainDay: rainDate[index] ? Number(rainDate[index].toFixed(1)) : '', inflAmnt: inflAmnt[index] ? Number(inflAmnt[index].toFixed(1)) : '', fctCpc: inflAmnt[index] ? Number((inflAmnt[index] / fcltyCpcValue).toFixed(1)) : '', dsInflWqltBod: dsInflWqltBod[index] ? Number(dsInflWqltBod[index].toFixed(1)) : '', dsInflWqltCod: dsInflWqltCod[index] ? Number(dsInflWqltCod[index].toFixed(1)) : '', dsInflWqltSs: dsInflWqltSs[index] ? Number(dsInflWqltSs[index].toFixed(1)) : '', dsInflWqltTn: dsInflWqltTn[index] ? dsInflWqltTn[index].toFixed(3) : '', dsInflWqltTp: dsInflWqltTp[index] ? dsInflWqltTp[index].toFixed(3) : '', inflAssctBfrWqltBod: inflAssctBfrWqltBod[index] ? Number(inflAssctBfrWqltBod[index].toFixed(1)) : '', inflAssctBfrWqltToc: inflAssctBfrWqltToc[index] ? Number(inflAssctBfrWqltToc[index].toFixed(1)) : '', inflAssctBfrWqltSs: inflAssctBfrWqltSs[index] ? Number(inflAssctBfrWqltSs[index].toFixed(1)) : '', inflAssctBfrWqltTn: inflAssctBfrWqltTn[index] ? inflAssctBfrWqltTn[index].toFixed(3) : '', inflAssctBfrWqltTp: inflAssctBfrWqltTp[index] ? inflAssctBfrWqltTp[index].toFixed(3) : '', efflWqltBod: efflWqltBod[index] ? Number(efflWqltBod[index].toFixed(1)) : '', efflWqltToc: efflWqltToc[index] ? Number(efflWqltToc[index].toFixed(1)) : '', efflWqltSs: efflWqltSs[index] ? Number(efflWqltSs[index].toFixed(1)) : '', efflWqltTn: efflWqltTn[index] ? efflWqltTn[index].toFixed(3) : '', efflWqltTp: efflWqltTp[index] ? efflWqltTp[index].toFixed(3) : '' })); const excelList : RainManageExcelType[] = []; if(isExcel){ filteredData.forEach((item) => { excelList.push({ 강우량: item.rainItem, 강우조건비율: item.rainRate ? Number(Number(item.rainRate).toFixed(1)) : '', 일수: item.rainDay ? Number(Number(item.rainDay).toFixed(1)) : '', 유입유량: item.inflAmnt ? Number(Number(item.inflAmnt).toFixed(1)) : '', 시설용량대비: item.fctCpc ? Number(Number(item.fctCpc).toFixed(1)) : '', 설계유입수질BOD: item.dsInflWqltBod ? Number(Number(item.dsInflWqltBod).toFixed(1)) : '', 설계유입수질TOC: item.dsInflWqltCod ? Number(Number(item.dsInflWqltCod).toFixed(1)) : '', 설계유입수질SS: item.dsInflWqltSs ? Number(Number(item.dsInflWqltSs).toFixed(1)) : '', 설계유입수질TN: item.dsInflWqltTn ? Number(item.dsInflWqltTn).toFixed(3) : '', 설계유입수질TP: item.dsInflWqltTp ? Number(item.dsInflWqltTp).toFixed(3) : '', 유입수질BOD: item.inflAssctBfrWqltBod ? Number(Number(item.inflAssctBfrWqltBod).toFixed(1)) : '', 유입수질TOC: item.inflAssctBfrWqltToc ? Number(Number(item.inflAssctBfrWqltToc).toFixed(1)) : '', 유입수질SS: item.inflAssctBfrWqltSs ? Number(Number(item.inflAssctBfrWqltSs).toFixed(1)) : '', 유입수질TN: item.inflAssctBfrWqltTn ? Number(item.inflAssctBfrWqltTn).toFixed(3) : '', 유입수질TP: item.inflAssctBfrWqltTp ? Number(item.inflAssctBfrWqltTp).toFixed(3) : '', 방류수질BOD: item.efflWqltBod ? Number(Number(item.efflWqltBod).toFixed(1)) : '', 방류수질TOC: item.efflWqltToc ? Number(Number(item.efflWqltToc).toFixed(1)) : '', 방류수질SS: item.efflWqltSs ? Number(Number(item.efflWqltSs).toFixed(1)) : '', 방류수질TN: item.efflWqltTn ? Number(item.efflWqltTn).toFixed(3) : '', 방류수질TP: item.efflWqltTp ? Number(item.efflWqltTp).toFixed(3) : '', }); }); } set((state: DashBoardType) => ({ ...state, RainManage: isExcel ? { ...state.RainManage, rainManageList: filteredData as RainManageListProps[], excelList: excelList, isLoadingRainManage : false, } : { ...state.RainManage, rainManageList: filteredData as RainManageListProps[], isLoadingRainManage : false, } })); }, } }