/** * Store - 타입 */ import { getFetch } from "@/app/components/api"; import CalcRainEffect from "@/app/components/common/CalcRainEffect"; import DataForm, { roundNumber } from "@/app/components/common/DataForm"; // import { getDaysInMonth } from "@/app/components/common/DataForm"; import { fetchPlanInfo, OSU_PERCENT, qltyDataSetting, roundUp } from "../common"; import { type FacilityWaterQltyProps } from "../facilityWaterQlty"; import { fetchFlowRateModalList } from "../flowRate"; import { fetchFacilityWaterQltyInfo } from "../processFacility"; // 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; widthPercent?: 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 | '', // 평균 yearMax: number | '', // 최대 yearMin: number | '', // 최소 summerAll: number | string | '', // 하절기 전체 summerThree: number | string | '', // 하절기 3mm이상 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 | '', // RDII 추정 rdiRain: number | string | '', // RDII 추정시 일강수량(mm) } 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 | '', toBeInfoRnDay?: number | '', } export interface RainManageExcelType { 강우량: string, 강우조건비율: number | '', 일수: number | '', 유입유량: string | number | '', 시설용량대비: string | number | '', 설계유입수질BOD: string | number | '', 설계유입수질TOC: string | number | '', 설계유입수질SS: string | number | '', 설계유입수질TN: string | number | '', 설계유입수질TP: string | number | '', 유입수질BOD: string | number | '', 유입수질TOC: string | number | '', 유입수질SS: string | number | '', 유입수질TN: string | number | '', 유입수질TP: string | number | '', 방류수질BOD: string | number | '', 방류수질TOC: string | number | '', 방류수질SS: string | 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 | '', } // type WtrUsgYmProps = { // bscFctCd: string, // 처리구역시설코드 // levyYm: string, // 부과년월 // wtrUsg: number, // 월별 물사용량(m³/월) // } /** * 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[] = [ ] function getPlanYearList(): string[] { const currentYear = new Date().getFullYear(); // 올해 const startYear = currentYear - 4; // 5년 전 const endYear = currentYear + 1; // 내년 const years: string[] = []; for (let y = startYear; y <= endYear; y++) { years.push(String(y)); // 혹은 y.toString() } return years; } let planYearList: string[] = getPlanYearList(); 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, widthPercent: 8 }, { id: "rainRate", title: "강우조건\n비율(%)", row: 0, rowSpan: 2, align: "right", widthPercent: 5 }, { id: "rainDay", title: "일수", row: 0, rowSpan: 2, align: "right", widthPercent: 5 }, { id: "A", title: "유입(㎥/일)", row: 0, colSpan: 2 }, { id: "inflAmnt", title: "유입유량", row: 1, align: "right", widthPercent: 6 }, { id: "fctCpc", title: "시설용량대비", row: 1, align: "right", widthPercent: 6 }, { id: "B", title: "설계유입수질(㎎/L)", row: 0, colSpan: 5 }, { id: "dsInflWqltBod", title: "BOD", row: 1, align: "right" }, { id: "dsInflWqltCod", title: "TOC\n(COD)", row: 1, align: "right" }, { id: "dsInflWqltSs", title: "SS", row: 1, align: "right" }, { id: "dsInflWqltTn", title: "T-N", row: 1, align: "right" }, { id: "dsInflWqltTp", title: "T-P", row: 1, align: "right" }, { id: "C", title: "유입수질(㎎/L)", row: 0, colSpan: 5 }, { id: "inflAssctBfrWqltBod", title: "BOD", row: 1, align: "right" }, { id: "inflAssctBfrWqltToc", title: "TOC\n(COD)", row: 1, align: "right" }, { id: "inflAssctBfrWqltSs", title: "SS", row: 1, align: "right" }, { id: "inflAssctBfrWqltTn", title: "T-N", row: 1, align: "right" }, { id: "inflAssctBfrWqltTp", title: "T-P", row: 1, align: "right" }, { id: "D", title: "방류수질(㎎/L)", row: 0, colSpan: 5 }, { id: "efflWqltBod", title: "BOD", row: 1, align: "right" }, { id: "efflWqltToc", title: "TOC\n(COD)", row: 1, align: "right" }, { id: "efflWqltSs", title: "SS", row: 1, align: "right" }, { id: "efflWqltTn", title: "T-N", row: 1, align: "right" }, { id: "efflWqltTp", title: "T-P", row: 1, align: "right" }, ] 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 operationalStatusListOrg: 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 waterQltyStandartd: any = []; 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', } ]; type ApiRes = { data: any; count: any; } /**==================================== * 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 fetchWtrUsgYmList = async (searchYear: string | undefined, fcltCdList: string[]): Promise => { // try { // const res = await postFetch('fo', '/fclt/flow/wtrUsgYm/' + searchYear, fcltCdList); // return res; // } catch (error) { // console.error('시설들 월별 물사용량 데이터를 가져오는데 실패했습니다:', error); // return null; // } // }; // 주요그래프 데이터 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 }; } } // 수질 데이터 청천시, 강우시 재계산 const calcWaterQltyData = async (data: any[], searchYear: string | undefined, fcltyCd: string | undefined, mainGraphData: any) => { const operList = { inflBod: { yearTot: 0, yearAvg: 0, yearMax: 0, yearMin: 9999999 }, // 유입BOD inflTN: { yearTot: 0, yearAvg: 0, yearMax: 0, yearMin: 9999999 }, // 유입TN inflTP: { yearTot: 0, yearAvg: 0, yearMax: 0, yearMin: 9999999 }, // 유입TP efflBod: { yearTot: 0, yearAvg: 0, yearMax: 0, yearMin: 9999999 }, // 방류BOD efflTN: { yearTot: 0, yearAvg: 0, yearMax: 0, yearMin: 9999999 }, // 방류TN efflTP: { yearTot: 0, yearAvg: 0, yearMax: 0, yearMin: 9999999 }, // 방류TP tpInflTp: { yearTot: 0, yearAvg: 0, yearMax: 0, yearMin: 9999999 }, //총인 유입수질 TP(mg/L) }; const nullToZero = (value: any) => { return value === null || value === undefined || value === '' ? 0 : Number(value); }; const orgData = data; // const res = await fetchMainGraph(searchYear, fcltyCd); // /fclt/qlty/hist/{year}/{fcltyCd} const res = mainGraphData; if (res.data.wqltObjs.length > 0) { // const clone = (arr: any[]) => arr?.map(v => ({ ...v })) ?? []; const qltyData = res.data.wqltObjs; // const qltyChungchunData = CalcRainEffect(clone(qltyData), 'SUNNY'); // 강우시 변수 const rainEffectDayArray: string[] = []; // (0) 전체변수 let summerDay = 0, noNullSummerDay = 0; let totalInflBodAvgSummer = 0, totalInflTnAvgSummer = 0, totalInflTpAvgSummer = 0; let totalEfflBodAvgSummer = 0, totalEfflTnAvgSummer = 0, totalEfflTpAvgSummer = 0, totalTpInflAvgSummer = 0; let winterDay = 0, noNullWinterDay = 0; let totalInflBodAvgWinter = 0, totalInflTnAvgWinter = 0, totalInflTpAvgWinter = 0; let totalEfflBodAvgWinter = 0, totalEfflTnAvgWinter = 0, totalEfflTpAvgWinter = 0, totalTpInflAvgWinter = 0; // (1) 청천시 변수 // (1-1) 날짜 count let chungchunSummerDay = 0, noNullChungchunSummerDay = 0; let chungchunWinterDay = 0, noNullChungchunWinterDay = 0; // (1-2) 하절기 let chungchunInflBodAvgSummer = 0, chungchunInflTnAvgSummer = 0, chungchunInflTpAvgSummer = 0; let chungchunEfflBodAvgSummer = 0, chungchunEfflTnAvgSummer = 0, chungchunEfflTpAvgSummer = 0; let chungchunTpInflAvgSummer = 0; // 하절기 청천시 총인설비 유입TP // (1-3) 동절기 (최대, 최소, 평균 다 필요) let chungchunInflBodAvg = 0, chungchunInflTnAvg = 0, chungchunInflTpAvg = 0, chungchunTpInflAvg = 0; let chungchunInflBodMax = 0, chungchunInflTnMax = 0, chungchunInflTpMax = 0, chungchunTpInflMax = 0; let chungchunInflBodMin = 99999999; let chungchunInflTnMin = 99999999; let chungchunInflTpMin = 99999999; let chungchunTpInflMin = 99999999; let chungchunEfflBodAvg = 0, chungchunEfflTnAvg = 0, chungchunEfflTpAvg = 0; let chungchunEfflBodMax = 0, chungchunEfflTnMax = 0, chungchunEfflTpMax = 0; let chungchunEfflBodMin = 99999999; let chungchunEfflTnMin = 99999999; let chungchunEfflTpMin = 99999999; // 강우시 변수 let rainSummerDay = 0, noNullRainSummerDay = 0; let rainInflBodAvg = 0, rainInflTnAvg = 0, rainInflTpAvg = 0; let rainEfflBodAvg = 0, rainEfflTnAvg = 0, rainEfflTpAvg = 0, rainTpInflAvg = 0; let rainEffectDay = 0; // 전체 대상 const totalDay = qltyData.length; let noNullYearDay = 0; qltyData.forEach((item: any) => { if (item.infoRnDay == null) item.infoRnDay = 0; const month = item.msrDt.substring(4, 6); // 월 추출 if (item.infoRnDay >= 3) { rainEffectDay = 2; } else { rainEffectDay--; } if (rainEffectDay >= 0) { rainEffectDayArray.push(item.msrDt); // 강우영향일 if (month === '06' || month === '07' || month === '08') { rainSummerDay += 1; if (item.tpInflWqltTp != null && item.tpInflWqltTp != 0) { noNullRainSummerDay += 1; } rainInflBodAvg += nullToZero(item.inflAssctBfrWqltBod); rainInflTnAvg += nullToZero(item.inflAssctBfrWqltTn); rainInflTpAvg += nullToZero(item.inflAssctBfrWqltTp); rainEfflBodAvg += nullToZero(item.efflWqltBod); rainEfflTnAvg += nullToZero(item.efflWqltTn); rainEfflTpAvg += nullToZero(item.efflWqltTp); rainTpInflAvg += nullToZero(item.tpInflWqltTp); } } else if (rainEffectDay < 0) { //청천시 if (month === '01' || month === '02') { chungchunWinterDay += 1; if (item.tpInflWqltTp != null && item.tpInflWqltTp != 0) { noNullChungchunWinterDay += 1; } const inflbod = nullToZero(item.inflAssctBfrWqltBod); const infltn = nullToZero(item.inflAssctBfrWqltTn); const infltp = nullToZero(item.inflAssctBfrWqltTp); const effbod = nullToZero(item.efflWqltBod); const efftn = nullToZero(item.efflWqltTn); const efftp = nullToZero(item.efflWqltTp); const tpInfl = nullToZero(item.tpInflWqltTp); chungchunInflBodAvg += inflbod; chungchunInflTnAvg += infltn; chungchunInflTpAvg += infltp; chungchunEfflBodAvg += effbod; chungchunEfflTnAvg += efftn; chungchunEfflTpAvg += efftp; chungchunTpInflAvg += tpInfl; if (chungchunInflBodMax < inflbod) chungchunInflBodMax = inflbod; if (chungchunInflTnMax < infltn) chungchunInflTnMax = infltn; if (chungchunInflTpMax < infltp) chungchunInflTpMax = infltp; if (chungchunEfflBodMax < effbod) chungchunEfflBodMax = effbod; if (chungchunEfflTnMax < efftn) chungchunEfflTnMax = efftn; if (chungchunEfflTpMax < efftp) chungchunEfflTpMax = efftp; if (chungchunTpInflMax < tpInfl) chungchunTpInflMax = tpInfl; if (chungchunInflBodMin > inflbod) chungchunInflBodMin = inflbod; if (chungchunInflTnMin > infltn) chungchunInflTnMin = infltn; if (chungchunInflTpMin > infltp) chungchunInflTpMin = infltp; if (chungchunEfflBodMin > effbod) chungchunEfflBodMin = effbod; if (chungchunEfflTnMin > efftn) chungchunEfflTnMin = efftn; if (chungchunEfflTpMin > efftp) chungchunEfflTpMin = efftp; if (chungchunTpInflMin > tpInfl) chungchunTpInflMin = tpInfl; } else if (month === '06' || month === '07' || month === '08') { chungchunSummerDay += 1; if (item.tpInflWqltTp != null && item.tpInflWqltTp != 0) { noNullChungchunSummerDay += 1; } chungchunInflBodAvgSummer += nullToZero(item.inflAssctBfrWqltBod); chungchunInflTnAvgSummer += nullToZero(item.inflAssctBfrWqltTn); chungchunInflTpAvgSummer += nullToZero(item.inflAssctBfrWqltTp); chungchunEfflBodAvgSummer += nullToZero(item.efflWqltBod); chungchunEfflTnAvgSummer += nullToZero(item.efflWqltTn); chungchunEfflTpAvgSummer += nullToZero(item.efflWqltTp); chungchunTpInflAvgSummer += nullToZero(item.tpInflWqltTp); } } if (month === '01' || month === '02') { winterDay += 1; if (item.tpInflWqltTp != null && item.tpInflWqltTp != 0) { noNullWinterDay += 1; } totalInflBodAvgWinter += nullToZero(item.inflAssctBfrWqltBod); totalInflTnAvgWinter += nullToZero(item.inflAssctBfrWqltTn); totalInflTpAvgWinter += nullToZero(item.inflAssctBfrWqltTp); totalEfflBodAvgWinter += nullToZero(item.efflWqltBod); totalEfflTnAvgWinter += nullToZero(item.efflWqltTn); totalEfflTpAvgWinter += nullToZero(item.efflWqltTp); totalTpInflAvgWinter += nullToZero(item.tpInflWqltTp); //총인 유입수질 TP(mg/L) } else if (month === '06' || month === '07' || month === '08') { summerDay += 1; if (item.tpInflWqltTp != null && item.tpInflWqltTp != 0) { noNullSummerDay += 1; } totalInflBodAvgSummer += nullToZero(item.inflAssctBfrWqltBod); totalInflTnAvgSummer += nullToZero(item.inflAssctBfrWqltTn); totalInflTpAvgSummer += nullToZero(item.inflAssctBfrWqltTp); totalEfflBodAvgSummer += nullToZero(item.efflWqltBod); totalEfflTnAvgSummer += nullToZero(item.efflWqltTn); totalEfflTpAvgSummer += nullToZero(item.efflWqltTp); totalTpInflAvgSummer += nullToZero(item.tpInflWqltTp); } if (item.tpInflWqltTp != null && item.tpInflWqltTp != 0) { noNullYearDay += 1; } operList.inflBod.yearTot += nullToZero(item.inflAssctBfrWqltBod); operList.inflTN.yearTot += nullToZero(item.inflAssctBfrWqltTn); operList.inflTP.yearTot += nullToZero(item.inflAssctBfrWqltTp); operList.efflBod.yearTot += nullToZero(item.efflWqltBod); operList.efflTN.yearTot += nullToZero(item.efflWqltTn); operList.efflTP.yearTot += nullToZero(item.efflWqltTp); operList.tpInflTp.yearTot += nullToZero(item.tpInflWqltTp); // 최대 최소 operList.inflBod.yearMax = Math.max(operList.inflBod.yearMax, nullToZero(item.inflAssctBfrWqltBod)); operList.inflBod.yearMin = Math.min(operList.inflBod.yearMin, nullToZero(item.inflAssctBfrWqltBod)); operList.inflTN.yearMax = Math.max(operList.inflTN.yearMax, nullToZero(item.inflAssctBfrWqltTn)); operList.inflTN.yearMin = Math.min(operList.inflTN.yearMin, nullToZero(item.inflAssctBfrWqltTn)); operList.inflTP.yearMax = Math.max(operList.inflTP.yearMax, nullToZero(item.inflAssctBfrWqltTp)); operList.inflTP.yearMin = Math.min(operList.inflTP.yearMin, nullToZero(item.inflAssctBfrWqltTp)); operList.efflBod.yearMax = Math.max(operList.efflBod.yearMax, nullToZero(item.efflWqltBod)); operList.efflBod.yearMin = Math.min(operList.efflBod.yearMin, nullToZero(item.efflWqltBod)); operList.efflTN.yearMax = Math.max(operList.efflTN.yearMax, nullToZero(item.efflWqltTn)); operList.efflTN.yearMin = Math.min(operList.efflTN.yearMin, nullToZero(item.efflWqltTn)); operList.efflTP.yearMax = Math.max(operList.efflTP.yearMax, nullToZero(item.efflWqltTp)); operList.efflTP.yearMin = Math.min(operList.efflTP.yearMin, nullToZero(item.efflWqltTp)); operList.tpInflTp.yearMax = Math.max(operList.tpInflTp.yearMax, nullToZero(item.tpInflWqltTp)); operList.tpInflTp.yearMin = Math.min(operList.tpInflTp.yearMin, nullToZero(item.tpInflWqltTp)); }); operList.inflBod.yearAvg = operList.inflBod.yearTot / totalDay; operList.inflTN.yearAvg = operList.inflTN.yearTot / totalDay; operList.inflTP.yearAvg = operList.inflTP.yearTot / totalDay; operList.efflBod.yearAvg = operList.efflBod.yearTot / totalDay; operList.efflTN.yearAvg = operList.efflTN.yearTot / totalDay; operList.efflTP.yearAvg = operList.efflTP.yearTot / totalDay; operList.tpInflTp.yearAvg = operList.tpInflTp.yearTot / totalDay; orgData[5].yearAvg = qltyDataSetting(operList.inflBod.yearTot, totalDay, 1); // 연간 유입BOD orgData[6].yearAvg = qltyDataSetting(operList.efflBod.yearTot, totalDay, 1); // 연간 방류BOD orgData[7].yearAvg = qltyDataSetting(operList.inflTN.yearTot, totalDay, 3); // 연간 유입TN orgData[8].yearAvg = qltyDataSetting(operList.efflTN.yearTot, totalDay, 3); // 연간 방류TN orgData[9].yearAvg = qltyDataSetting(operList.inflTP.yearTot, totalDay, 3); // 연간 유입TP orgData[10].yearAvg = qltyDataSetting(operList.efflTP.yearTot, totalDay, 3); // 연간 방류TP //총인설비 orgData[11].yearAvg = qltyDataSetting(operList.tpInflTp.yearTot, noNullYearDay, 3); // 연간 총인 유입수질 TP orgData[12].yearAvg = qltyDataSetting(operList.efflTP.yearTot, totalDay, 3); // 연간 총인 유입수질 TP orgData[5].yearMax = roundUp(operList.inflBod.yearMax, 1); // 연간 유입BOD orgData[6].yearMax = roundUp(operList.efflBod.yearMax, 1); // 연간 방류BOD orgData[7].yearMax = roundUp(operList.inflTN.yearMax, 3).toFixed(3); // 연간 유입TN orgData[8].yearMax = roundUp(operList.efflTN.yearMax, 3).toFixed(3); // 연간 방류TN orgData[9].yearMax = roundUp(operList.inflTP.yearMax, 3).toFixed(3); // 연간 유입TP orgData[10].yearMax = roundUp(operList.efflTP.yearMax, 3).toFixed(3); // 연간 방류TP orgData[11].yearMax = roundUp(operList.tpInflTp.yearMax, 3).toFixed(3); // 연간 총인 유입수질 TP orgData[12].yearMax = roundUp(operList.efflTP.yearMax, 3).toFixed(3); // 연간 총인 유입수질 TP orgData[5].yearMin = roundUp(operList.inflBod.yearMin, 1); // 연간 유입BOD orgData[6].yearMin = roundUp(operList.efflBod.yearMin, 1); // 연간 방류BOD orgData[7].yearMin = roundUp(operList.inflTN.yearMin, 3).toFixed(3); // 연간 유입TN orgData[8].yearMin = roundUp(operList.efflTN.yearMin, 3).toFixed(3); // 연간 방류TN orgData[9].yearMin = roundUp(operList.inflTP.yearMin, 3).toFixed(3); // 연간 유입TP orgData[10].yearMin = roundUp(operList.efflTP.yearMin, 3).toFixed(3); // 연간 방류TP orgData[11].yearMin = roundUp(operList.tpInflTp.yearMin, 3).toFixed(3); // 연간 총인 유입수질 TP orgData[12].yearMin = roundUp(operList.efflTP.yearMin, 3).toFixed(3); // 연간 총인 유입수질 TP orgData[5].summerAll = qltyDataSetting(totalInflBodAvgSummer, summerDay, 1); // 하절기 전기간 유입BOD orgData[6].summerAll = qltyDataSetting(totalEfflBodAvgSummer, summerDay, 1); // 하절기 전기간 방류BOD orgData[7].summerAll = qltyDataSetting(totalInflTnAvgSummer, summerDay, 3); // 하절기 전기간 유입TN orgData[8].summerAll = qltyDataSetting(totalEfflTnAvgSummer, summerDay, 3); // 하절기 전기간 방류TN orgData[9].summerAll = qltyDataSetting(totalInflTpAvgSummer, summerDay, 3); // 하절기 전기간 유입TP orgData[10].summerAll = qltyDataSetting(totalEfflTpAvgSummer, summerDay, 3); // 하절기 전기간 방류TP //총인설비 orgData[11].summerAll = qltyDataSetting(totalTpInflAvgSummer, noNullSummerDay, 3); orgData[12].summerAll = qltyDataSetting(totalEfflTpAvgSummer, summerDay, 3); // 강우시 수질 데이터 수정 orgData[5].summerThree = qltyDataSetting(rainInflBodAvg, rainSummerDay, 1); orgData[6].summerThree = qltyDataSetting(rainEfflBodAvg, rainSummerDay, 1); orgData[7].summerThree = qltyDataSetting(rainInflTnAvg, rainSummerDay, 3); orgData[8].summerThree = qltyDataSetting(rainEfflTnAvg, rainSummerDay, 3); orgData[9].summerThree = qltyDataSetting(rainInflTpAvg, rainSummerDay, 3); orgData[10].summerThree = qltyDataSetting(rainEfflTpAvg, rainSummerDay, 3); // 총인설비 orgData[11].summerThree = qltyDataSetting(rainTpInflAvg, noNullRainSummerDay, 3); orgData[12].summerThree = qltyDataSetting(rainEfflTpAvg, rainSummerDay, 3); // 하절기 청천시 수질 데이터 orgData[5].summerRain = qltyDataSetting(chungchunInflBodAvgSummer, chungchunSummerDay, 1); orgData[6].summerRain = qltyDataSetting(chungchunEfflBodAvgSummer, chungchunSummerDay, 1); orgData[7].summerRain = qltyDataSetting(chungchunInflTnAvgSummer, chungchunSummerDay, 3); orgData[8].summerRain = qltyDataSetting(chungchunEfflTnAvgSummer, chungchunSummerDay, 3); orgData[9].summerRain = qltyDataSetting(chungchunInflTpAvgSummer, chungchunSummerDay, 3); orgData[10].summerRain = qltyDataSetting(chungchunEfflTpAvgSummer, chungchunSummerDay, 3); // 총인설비 orgData[11].summerRain = qltyDataSetting(chungchunTpInflAvgSummer, noNullChungchunSummerDay, 3); orgData[12].summerRain = qltyDataSetting(chungchunEfflTpAvgSummer, chungchunSummerDay, 3); orgData[5].winterAll = qltyDataSetting(totalInflBodAvgWinter, winterDay, 1); // 동절기 전기간 유입BOD orgData[6].winterAll = qltyDataSetting(totalEfflBodAvgWinter, winterDay, 1); // 동절기 전기간 방류BOD orgData[7].winterAll = qltyDataSetting(totalInflTnAvgWinter, winterDay, 3); // 동절기 전기간 유입TN orgData[8].winterAll = qltyDataSetting(totalEfflTnAvgWinter, winterDay, 3); // 동절기 전기간 방류TN orgData[9].winterAll = qltyDataSetting(totalInflTpAvgWinter, winterDay, 3); // 동절기 전기간 유입TP orgData[10].winterAll = qltyDataSetting(totalEfflTpAvgWinter, winterDay, 3); // 동절기 전기간 방류TP //총인설비 orgData[11].winterAll = qltyDataSetting(totalTpInflAvgWinter, noNullWinterDay, 3); orgData[12].winterAll = qltyDataSetting(totalEfflTpAvgWinter, winterDay, 3); // 동절기 청천시 수질 데이터 orgData[5].winterSunnyAvg = qltyDataSetting(chungchunInflBodAvg, chungchunWinterDay, 1); orgData[6].winterSunnyAvg = qltyDataSetting(chungchunEfflBodAvg, chungchunWinterDay, 1); orgData[7].winterSunnyAvg = qltyDataSetting(chungchunInflTnAvg, chungchunWinterDay, 3); orgData[8].winterSunnyAvg = qltyDataSetting(chungchunEfflTnAvg, chungchunWinterDay, 3); orgData[9].winterSunnyAvg = qltyDataSetting(chungchunInflTpAvg, chungchunWinterDay, 3); orgData[10].winterSunnyAvg = qltyDataSetting(chungchunEfflTpAvg, chungchunWinterDay, 3); // 총인설비 orgData[11].winterSunnyAvg = qltyDataSetting(chungchunTpInflAvg, noNullChungchunWinterDay, 3); orgData[12].winterSunnyAvg = qltyDataSetting(chungchunEfflTpAvg, chungchunWinterDay, 3); orgData[5].winterSunnyMax = roundUp(chungchunInflBodMax, 1).toFixed(1); orgData[6].winterSunnyMax = roundUp(chungchunEfflBodMax, 1).toFixed(1); orgData[7].winterSunnyMax = roundUp(chungchunInflTnMax, 3).toFixed(3); orgData[8].winterSunnyMax = roundUp(chungchunEfflTnMax, 3).toFixed(3); orgData[9].winterSunnyMax = roundUp(chungchunInflTpMax, 3).toFixed(3); orgData[10].winterSunnyMax = roundUp(chungchunEfflTpMax, 3).toFixed(3); orgData[11].winterSunnyMax = roundUp(chungchunTpInflMax, 3).toFixed(3); orgData[12].winterSunnyMax = roundUp(chungchunEfflTpMax, 3).toFixed(3); orgData[5].winterSunnyMin = chungchunInflBodMin === 99999999 ? '0.0' : roundUp(chungchunInflBodMin, 1).toFixed(1); orgData[6].winterSunnyMin = chungchunEfflBodMin === 99999999 ? '0.0' : roundUp(chungchunEfflBodMin, 1).toFixed(1); orgData[7].winterSunnyMin = chungchunInflTnMin === 99999999 ? '0.000' : roundUp(chungchunInflTnMin, 3).toFixed(3); orgData[8].winterSunnyMin = chungchunEfflTnMin === 99999999 ? '0.000' : roundUp(chungchunEfflTnMin, 3).toFixed(3); orgData[9].winterSunnyMin = chungchunInflTpMin === 99999999 ? '0.000' : roundUp(chungchunInflTpMin, 3).toFixed(3); orgData[10].winterSunnyMin = chungchunEfflTpMin === 99999999 ? '0.000' : roundUp(chungchunEfflTpMin, 3).toFixed(3); orgData[11].winterSunnyMin = chungchunTpInflMin === 99999999 ? '0.000' : roundUp(chungchunTpInflMin, 3).toFixed(3); orgData[12].winterSunnyMin = chungchunEfflTpMin === 99999999 ? '0.000' : roundUp(chungchunEfflTpMin, 3).toFixed(3); return orgData; } else { return orgData; } }; /**==================================== * 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: any; 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[]; waterQltyStandartd: any; isLoadingMainGraph: boolean; }, RainManage: { isInit: boolean; upHeadListRainManage: TableUpperProps[]; rainManageList: RainManageListProps[]; excelList: RainManageExcelType[]; isLoadingRainManage: boolean; mainGraphData: any; mainGraphYear: string; mainGraphFcltyCd: string; flowRateData: any; flowRateYear: string; flowRateFcltyCd: string; }, 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: operationalStatusListOrg, 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, waterQltyStandartd: waterQltyStandartd, isLoadingMainGraph: false, }, RainManage: { isInit: false, upHeadListRainManage: upHeadListRainManage, rainManageList: rainManageList, excelList: [], isLoadingRainManage: false, mainGraphData: null, mainGraphYear: '', mainGraphFcltyCd: '', flowRateData: null, flowRateYear: '', flowRateFcltyCd: '', }, DrainageEquipment: { isInit: false, upHeadListDrainageEquipment: upHeadListDrainageEquipment, drainageEquipmentList: drainageEquipmentList, drainageEquipmentExcelList: [] } } /** * 데이터 폼 포맷설정 */ export const dataFormSettingPlan = (item: planFcltyListProps, decmials: number) => { DataForm({ type: 'float' + decmials, column: 'provisionalApproval', item: item as unknown as Record }); DataForm({ type: 'float' + decmials, column: 'now', item: item as unknown as Record }); DataForm({ type: 'float' + decmials, column: 'stepOne', item: item as unknown as Record }); DataForm({ type: 'float' + decmials, column: 'stepTwo', item: item as unknown as Record }); DataForm({ type: 'float' + decmials, column: 'stepThree', item: item as unknown as Record }); DataForm({ type: 'float' + decmials, column: 'stepFour', item: item as unknown as Record }); } export const dataFormSetting = (item: OperationalStatusListProps) => { DataForm({ type: 'float0', column: 'yearAvg', item: item as unknown as Record }); DataForm({ type: 'float0', column: 'yearMax', item: item as unknown as Record }); DataForm({ type: 'float0', column: 'yearMin', item: item as unknown as Record }); DataForm({ type: 'float0', column: 'summerAll', item: item as unknown as Record }); DataForm({ type: 'float0', column: 'summerThree', item: item as unknown as Record }); DataForm({ type: 'float0', column: 'summerRain', item: item as unknown as Record }); DataForm({ type: 'float0', column: 'winterAll', item: item as unknown as Record }); DataForm({ type: 'float0', column: 'winterSunnyAvg', item: item as unknown as Record }); DataForm({ type: 'float0', column: 'winterSunnyMax', item: item as unknown as Record }); DataForm({ type: 'float0', column: 'winterSunnyMin', item: item as unknown as Record }); DataForm({ type: 'float0', column: 'groundWaterAvg', item: item as unknown as Record }); DataForm({ type: 'float0', column: 'groundWaterSummer', item: item as unknown as Record }); DataForm({ type: 'float0', column: 'groundWaterWinter', item: item as unknown as Record }); DataForm({ type: 'float0', column: 'rainRate', item: item as unknown as Record }); DataForm({ type: 'float0', column: 'rdi', item: item as unknown as Record }); }; export const dataFormSettingWqlty = (item: OperationalStatusListProps) => { DataForm({ type: 'float1', column: 'yearAvg', item: item as unknown as Record }); DataForm({ type: 'float1', column: 'yearMax', item: item as unknown as Record }); DataForm({ type: 'float1', column: 'yearMin', item: item as unknown as Record }); DataForm({ type: 'float1', column: 'summerAll', item: item as unknown as Record }); DataForm({ type: 'float1', column: 'summerThree', item: item as unknown as Record }); DataForm({ type: 'float1', column: 'summerRain', item: item as unknown as Record }); DataForm({ type: 'float1', column: 'winterAll', item: item as unknown as Record }); DataForm({ type: 'float1', column: 'winterSunnyAvg', item: item as unknown as Record }); DataForm({ type: 'float1', column: 'winterSunnyMax', item: item as unknown as Record }); DataForm({ type: 'float1', column: 'winterSunnyMin', item: item as unknown as Record }); DataForm({ type: 'float1', column: 'groundWaterAvg', item: item as unknown as Record }); DataForm({ type: 'float1', column: 'groundWaterSummer', item: item as unknown as Record }); DataForm({ type: 'float1', column: 'groundWaterWinter', item: item as unknown as Record }); DataForm({ type: 'float1', column: 'rainRate', item: item as unknown as Record }); DataForm({ type: 'float1', column: 'rdi', item: item as unknown as Record }); }; // const changeValue = (operationalStatus, data, keyTxt = 'INFL_AMNT') => { // //console.log('data.yearData', data.yearData); // 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] : ''; // // 지하수 // // 오염물질 // // 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 : roundUp(summerLowFlow * ((winterAvgBod - summerLowBod) / winterAvgBod), 1); // 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 wtrUsgYearsType = { YEAR: string; WTR_USG: number; } type wtrUsgYearsResponse = { data: wtrUsgYearsType[]; count: number; } const searchWaterUsage = async (searchYear: string, fcltyCd: string) => { const waterUsage = [0, 0, 0]; // searchYear, searchYear-1, searchYear-2 const res = await getFetch('fo', '/dashBoard/wtrUsgYears/' + searchYear + '/' + fcltyCd) as wtrUsgYearsResponse; let i = 0; if (res && res.data && Array.isArray(res.data)) { res.data.forEach((item: wtrUsgYearsType) => { waterUsage[i] = item.WTR_USG; i++; }); } return waterUsage; } export const dashBoardReducer = ( set: (fn: (state: DashBoardType) => DashBoardType) => void, get: () => DashBoardType ): DashBoardActions => { 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); // /fclt/flow/{fcltyCd}/{year} 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); // /dc-service/api/v1/nowDmgMtncGnsvy let minDiff = 9999999; let minIndex; res.forEach((el: any, idx) => { if (minDiff > Math.abs(Number(targetYear) - Number(el.planYr))) { minDiff = Math.abs(Number(targetYear) - Number(el.planYr)); minIndex = idx; } }); const rtnPlanData = res[minIndex]; planFcltyList.map((el, index) => { planYearList = []; planYearList.push(rtnPlanData ? rtnPlanData.planYrDt4.toString() : ""); planYearList.push(rtnPlanData ? rtnPlanData.planYr.toString() : ""); planYearList.push(rtnPlanData ? rtnPlanData.planYrDc1.toString() : ""); planYearList.push(rtnPlanData ? rtnPlanData.planYrDc2.toString() : ""); planYearList.push(rtnPlanData ? rtnPlanData.planYrDc3.toString() : ""); planYearList.push(rtnPlanData ? rtnPlanData.planYrDc4.toString() : ""); if (index === 0) { // 증설계획(㎥/일) el.provisionalApproval = rtnPlanData ? rtnPlanData.planSwageQntSumDt4 : ''; // 기승인4단계 el.now = rtnPlanData ? rtnPlanData.planSwageQntSum : ''; // 현재 el.stepOne = rtnPlanData ? rtnPlanData.planSwageQntSumDc1 : ''; // 1단계 el.stepTwo = rtnPlanData ? rtnPlanData.planSwageQntSumDc2 : ''; // 2단계 el.stepThree = rtnPlanData ? rtnPlanData.planSwageQntSumDc3 : ''; // 3단계 el.stepFour = rtnPlanData ? rtnPlanData.planSwageQntSumDc4 : ''; // 4단계 } 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) { // 처리구역(km²) 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 : ''; } if (index === 2) { // 처리구역(km²) dataFormSettingPlan(el, 1); } else if (index == 4) { // 물사용량 } else { dataFormSettingPlan(el, 0); } set((state: DashBoardType) => ({ ...state, PlanFclty: { ...state.PlanFclty, planFcltyList: planFcltyList, isLoadingPlanFclty: false, planYearList: planYearList, }, })); }); }, /** 시설정보 및 운영현황 - 운영실태 */ searchOperationStatus: async (isExcel: boolean, searchYear: string, fcltyCd: string) => { const state = get(); let mainGraphData: ApiRes = { data: [], count: 0 }; // 이미 조회된 데이터가 있는지 확인 (연도와 시설코드가 같을 때만) if (state.RainManage.mainGraphYear === searchYear && state.RainManage.mainGraphFcltyCd === fcltyCd && state.RainManage.mainGraphData) { mainGraphData = state.RainManage.mainGraphData; } else { mainGraphData = await fetchMainGraph(searchYear, fcltyCd); // 조회된 데이터 저장 set((state: DashBoardType) => ({ ...state, RainManage: { ...state.RainManage, mainGraphData: mainGraphData, mainGraphYear: searchYear, mainGraphFcltyCd: fcltyCd, } })); } set((state: DashBoardType) => ({ ...state, OperationStatus: { ...state.OperationStatus, isLoadingOperationStatus: true, }, })); // const fcltCdList = [fcltyCd]; //const wtrUsgRes: any = await fetchWtrUsgYmList(searchYear, fcltCdList); // 수용가의 실제 물사용량 const operList = { inFlow: { yearTot: 0, yearAvg: 0, yearMax: 0, yearMin: 9999999 , summerTot: 0, summerAvg: 0, summerRainy: 0, summerSunny: 0 , winterTot: 0, winterAvg: 0, winterSunny: 0, winterSunnyMax: 0, winterSunnyMin: 9999999 , groundTot: 0, groundSummer: 0, groundWinter: 0, rdii: 0, rdiiRainAmt: 0 }, inflAmt: { yearTot: 0, yearAvg: 0, yearMax: 0, yearMin: 9999999, yearSunny: 0 , summerTot: 0, summerAvg: 0, summerRainy: 0, summerSunny: 0 , winterTot: 0, winterAvg: 0, winterSunny: 0, winterSunnyMax: 0, winterSunnyMin: 9999999 , groundTot: 0, groundSummer: 0, groundWinter: 0, rdii: 0, rdiiRainAmt: 0 }, sumFlow: { yearTot: 0, yearAvg: 0, yearMax: 0, yearMin: 9999999 , summerTot: 0, summerAvg: 0, summerRainy: 0, summerSunny: 0 , winterTot: 0, winterAvg: 0, winterSunny: 0, winterSunnyMax: 0, winterSunnyMin: 9999999 , groundTot: 0, groundSummer: 0, groundWinter: 0, rdii: 0, rdiiRainAmt: 0 }, returnFlow: { yearTot: 0, yearAvg: 0, yearMax: 0, yearMin: 9999999 , summerTot: 0, summerAvg: 0, summerRainy: 0, summerSunny: 0 , winterTot: 0, winterAvg: 0, winterSunny: 0, winterSunnyMax: 0, winterSunnyMin: 9999999 , groundTot: 0, groundSummer: 0, groundWinter: 0, rdii: 0, rdiiRainAmt: 0 }, efflFlow: { yearTot: 0, yearAvg: 0, yearMax: 0, yearMin: 9999999 , summerTot: 0, summerAvg: 0, summerRainy: 0, summerSunny: 0 , winterTot: 0, winterAvg: 0, winterSunny: 0, winterSunnyMax: 0, winterSunnyMin: 9999999 , groundTot: 0, groundSummer: 0, groundWinter: 0, rdii: 0, rdiiRainAmt: 0 }, }; const clone = (arr: any[]) => arr?.map(v => ({ ...v })) ?? []; let rdiPercent = 0; let operationalStatusList = clone(operationalStatusListOrg); if (operationalStatusList) { // 유량 - 유입 if (operationalStatusList?.[0]) { // 연계처리수 let yearDay = 0, summerDay = 0, winterDay = 0; // 연간 일수, 하절기 일수, 동절기 일수 let summerRainDay = 0, summerChungchunDay = 0, winterChungchuDay = 0; // 하절기 강우 일수, 하절기 청천 일수, 동절기 청천 일수 // 연계처리수,지하수유입량 const bscFctCd = fcltyCd; let res2: any = { data: [] }; // 이미 조회된 데이터가 있는지 확인 (연도와 시설코드가 같을 때만) if (state.RainManage.flowRateYear === searchYear && state.RainManage.flowRateFcltyCd === fcltyCd && state.RainManage.flowRateData) { res2 = state.RainManage.flowRateData; } else { res2 = await fetchFlowRateModalList(bscFctCd, searchYear); // /fclt/flow/ - 일별 유량 조회 // 조회된 데이터 저장 set((state: DashBoardType) => ({ ...state, RainManage: { ...state.RainManage, flowRateData: res2, flowRateYear: searchYear, flowRateFcltyCd: fcltyCd, } })); } //const calData = CalcRainEffect(clone(res2.data), 'SUNNY'); //const calRainData = CalcRainEffect(clone(res2.data), 'RAIN'); let cntSunnyDay = 0; // 청천일 수 // let chungcunSumFlow = 0; // 연간 청천 순수하수 let rainEffectDay = 0; yearDay = res2.data ? res2.data.length : 1; res2.data.forEach((item: any) => { // --일별 유량 start const month = item.msrDt.substring(4, 6); // 월 추출 const sumFlow = item.sumFlow && item.sumFlow !== 'x' ? Number(item.sumFlow.toString().trim()) : 0; const inflAmnt = item.inflAmnt && item.inflAmnt !== 'x' ? Number(item.inflAmnt.toString().trim()) : 0; const returnAmnt = item.returnAmnt && item.returnAmnt !== 'x' ? Number(item.returnAmnt.toString().trim()) : 0; const efflAmnt = item.efflAmnt && item.efflAmnt !== 'x' ? Number(item.efflAmnt.toString().trim()) : 0; if (item.infoRnDay == null) item.infoRnDay = 0; if (item.infoRnDay >= 3) { rainEffectDay = 2; // 강우시 } else { rainEffectDay--; } if (rainEffectDay >= 0) { // 강우영향일 if (month === '06' || month === '07' || month === '08') { // 하절기 강우영향일 summerRainDay += 1; operList.inFlow.summerRainy += inflAmnt + sumFlow + returnAmnt; operList.inflAmt.summerRainy += inflAmnt; operList.sumFlow.summerRainy += sumFlow; operList.returnFlow.summerRainy += returnAmnt; operList.efflFlow.summerRainy += efflAmnt; } } else if (rainEffectDay < 0) { cntSunnyDay += 1; // 청천일수 // 청천시 // chungcunSumFlow += inflAmnt; // 연간 청천 순수하수 operList.inflAmt.yearSunny += inflAmnt; // 연간 청천 순수하수 if (month === '06' || month === '07' || month === '08') { // 하절기 청천 summerChungchunDay += 1; operList.inFlow.summerSunny += inflAmnt + sumFlow + returnAmnt; operList.inflAmt.summerSunny += inflAmnt; operList.sumFlow.summerSunny += sumFlow; operList.returnFlow.summerSunny += returnAmnt; operList.efflFlow.summerSunny += efflAmnt; } else if (month === '01' || month === '02') { // 동절기 청천 winterChungchuDay += 1; const inflowOne = inflAmnt + sumFlow + returnAmnt; operList.inFlow.winterSunny += inflAmnt + sumFlow + returnAmnt; operList.inflAmt.winterSunny += inflAmnt; operList.sumFlow.winterSunny += sumFlow; operList.returnFlow.winterSunny += returnAmnt; operList.efflFlow.winterSunny += efflAmnt; if (operList.inFlow.winterSunnyMax < inflowOne) operList.inFlow.winterSunnyMax = inflowOne; if (operList.inflAmt.winterSunnyMax < inflAmnt) operList.inflAmt.winterSunnyMax = inflAmnt; if (operList.sumFlow.winterSunnyMax < sumFlow) operList.sumFlow.winterSunnyMax = sumFlow; if (operList.returnFlow.winterSunnyMax < returnAmnt) operList.returnFlow.winterSunnyMax = returnAmnt; if (operList.efflFlow.winterSunnyMax < efflAmnt) operList.efflFlow.winterSunnyMax = efflAmnt; if (operList.inFlow.winterSunnyMin > inflowOne) operList.inFlow.winterSunnyMin = inflowOne; if (operList.inflAmt.winterSunnyMin > inflAmnt) operList.inflAmt.winterSunnyMin = inflAmnt; if (operList.sumFlow.winterSunnyMin > sumFlow) operList.sumFlow.winterSunnyMin = sumFlow; if (operList.returnFlow.winterSunnyMin > returnAmnt) operList.returnFlow.winterSunnyMin = returnAmnt; if (operList.efflFlow.winterSunnyMin > efflAmnt) operList.efflFlow.winterSunnyMin = efflAmnt; } } const inflowOne = inflAmnt + sumFlow + returnAmnt; operList.inFlow.yearTot += inflAmnt + sumFlow + returnAmnt; operList.inflAmt.yearTot += inflAmnt; operList.sumFlow.yearTot += sumFlow; operList.returnFlow.yearTot += returnAmnt; operList.efflFlow.yearTot += efflAmnt; if (operList.inFlow.yearMax < inflowOne) operList.inFlow.yearMax = inflowOne; if (operList.inflAmt.yearMax < inflAmnt) operList.inflAmt.yearMax = inflAmnt; if (operList.sumFlow.yearMax < sumFlow) operList.sumFlow.yearMax = sumFlow; if (operList.returnFlow.yearMax < returnAmnt) operList.returnFlow.yearMax = returnAmnt; if (operList.efflFlow.yearMax < efflAmnt) operList.efflFlow.yearMax = efflAmnt; if (operList.inFlow.yearMin > inflowOne) operList.inFlow.yearMin = inflowOne; if (operList.inflAmt.yearMin > inflAmnt) operList.inflAmt.yearMin = inflAmnt; if (operList.sumFlow.yearMin > sumFlow) operList.sumFlow.yearMin = sumFlow; if (operList.returnFlow.yearMin > returnAmnt) operList.returnFlow.yearMin = returnAmnt; if (operList.efflFlow.yearMin > efflAmnt) operList.efflFlow.yearMin = efflAmnt; if (month === '06' || month === '07' || month === '08') { summerDay += 1; operList.inFlow.summerTot += inflAmnt + sumFlow + returnAmnt; operList.inflAmt.summerTot += inflAmnt; operList.sumFlow.summerTot += sumFlow; operList.returnFlow.summerTot += returnAmnt; operList.efflFlow.summerTot += efflAmnt; } else if (month === '01' || month === '02') { winterDay += 1; operList.inFlow.winterTot += inflAmnt + sumFlow + returnAmnt; operList.inflAmt.winterTot += inflAmnt; operList.sumFlow.winterTot += sumFlow; operList.returnFlow.winterTot += returnAmnt; operList.efflFlow.winterTot += efflAmnt; } }); // --일별 유량 end // 연간 평균 operList.inFlow.yearAvg = (yearDay > 0) ? operList.inFlow.yearTot / yearDay : 0; operList.inflAmt.yearAvg = (yearDay > 0) ? operList.inflAmt.yearTot / yearDay : 0; operList.sumFlow.yearAvg = (yearDay > 0) ? operList.sumFlow.yearTot / yearDay : 0; operList.returnFlow.yearAvg = (yearDay > 0) ? operList.returnFlow.yearTot / yearDay : 0; operList.efflFlow.yearAvg = (yearDay > 0) ? operList.efflFlow.yearTot / yearDay : 0; // 하절기 전기간 평균 operList.inFlow.summerAvg = (summerDay > 0) ? operList.inFlow.summerTot / summerDay : 0; operList.inflAmt.summerAvg = (summerDay > 0) ? operList.inflAmt.summerTot / summerDay : 0; operList.sumFlow.summerAvg = (summerDay > 0) ? operList.sumFlow.summerTot / summerDay : 0; operList.returnFlow.summerAvg = (summerDay > 0) ? operList.returnFlow.summerTot / summerDay : 0; operList.efflFlow.summerAvg = (summerDay > 0) ? operList.efflFlow.summerTot / summerDay : 0; // 하절기 강우시 평균 operList.inFlow.summerRainy = (summerRainDay > 0) ? operList.inFlow.summerRainy / summerRainDay : 0; operList.inflAmt.summerRainy = (summerRainDay > 0) ? operList.inflAmt.summerRainy / summerRainDay : 0; operList.sumFlow.summerRainy = (summerRainDay > 0) ? operList.sumFlow.summerRainy / summerRainDay : 0; operList.returnFlow.summerRainy = (summerRainDay > 0) ? operList.returnFlow.summerRainy / summerRainDay : 0; operList.efflFlow.summerRainy = (summerRainDay > 0) ? operList.efflFlow.summerRainy / summerRainDay : 0; // 하절기 청천시 평균 operList.inFlow.summerSunny = (summerChungchunDay > 0) ? operList.inFlow.summerSunny / summerChungchunDay : 0; operList.inflAmt.summerSunny = (summerChungchunDay > 0) ? operList.inflAmt.summerSunny / summerChungchunDay : 0; operList.sumFlow.summerSunny = (summerChungchunDay > 0) ? operList.sumFlow.summerSunny / summerChungchunDay : 0; operList.returnFlow.summerSunny = (summerChungchunDay > 0) ? operList.returnFlow.summerSunny / summerChungchunDay : 0; operList.efflFlow.summerSunny = (summerChungchunDay > 0) ? operList.efflFlow.summerSunny / summerChungchunDay : 0; // 동절기 전기간 평균 operList.inFlow.winterAvg = (winterDay > 0) ? operList.inFlow.winterTot / winterDay : 0; operList.inflAmt.winterAvg = (winterDay > 0) ? operList.inflAmt.winterTot / winterDay : 0; operList.sumFlow.winterAvg = (winterDay > 0) ? operList.sumFlow.winterTot / winterDay : 0; operList.returnFlow.winterAvg = (winterDay > 0) ? operList.returnFlow.winterTot / winterDay : 0; operList.efflFlow.winterAvg = (winterDay > 0) ? operList.efflFlow.winterTot / winterDay : 0; // 동절기 청천시 평균 operList.inFlow.winterSunny = (winterChungchuDay > 0) ? operList.inFlow.winterSunny / winterChungchuDay : 0; operList.inflAmt.winterSunny = (winterChungchuDay > 0) ? operList.inflAmt.winterSunny / winterChungchuDay : 0; operList.sumFlow.winterSunny = (winterChungchuDay > 0) ? operList.sumFlow.winterSunny / winterChungchuDay : 0; operList.returnFlow.winterSunny = (winterChungchuDay > 0) ? operList.returnFlow.winterSunny / winterChungchuDay : 0; operList.efflFlow.winterSunny = (winterChungchuDay > 0) ? operList.efflFlow.winterSunny / winterChungchuDay : 0; // 연간 유입 평균 = 하수유입량(순수하수유입량) + 연계처리량 + 반류수유량(m³/일) operationalStatusList[0].yearAvg = roundUp(operList.inFlow.yearAvg, 0); // 연간 유입 평균 = 하수유입량(순수하수유입량) + 연계처리량 + 반류수유량(m³/일) operationalStatusList[0].yearMax = roundUp(operList.inFlow.yearMax, 0); // 연간 유입 최대 operationalStatusList[0].yearMin = roundUp(operList.inFlow.yearMin, 0); // 연간 유입 최소 operationalStatusList[0].summerAll = roundUp(operList.inFlow.summerAvg, 0); // 하절기 유입 전기간 operationalStatusList[0].summerThree = roundUp(operList.inFlow.summerRainy, 0); // 하절기 유입 강우시(강우영향일) operationalStatusList[0].summerRain = roundUp(operList.inFlow.summerSunny, 0); // 하절기 유입 청천시 operationalStatusList[0].winterAll = roundUp(operList.inFlow.winterAvg, 0); // 동절기 유입 전기간 operationalStatusList[0].winterSunnyMin = roundUp(operList.inFlow.winterSunnyMin, 0); // 동절기 유입 최소 operationalStatusList[0].winterSunnyMax = roundUp(operList.inFlow.winterSunnyMax, 0); // 동절기 유입 최대 operationalStatusList[0].winterSunnyAvg = roundUp(operList.inFlow.winterAvg, 0); // 동절기 유입 평균 // 청천시 유입(순수하수) 평균 const usage = operList.inflAmt.yearSunny / cntSunnyDay; // 연간 청천 순수하수 평균 const summerUsage = operList.inflAmt.summerSunny; // 하절기 청천 순수하수 평균 const winterUsage = operList.inflAmt.winterSunny; // 동절기 청천 순수하수 평균 // 물사용량 = 유입평균 * 0.65 const wtrUsg = operList.inflAmt.yearAvg * 0.65; // 연간 물사용량 평균 const wtrUsgSummer = operList.inflAmt.summerAvg * 0.65; // 하절기 물사용량 평균 const wtrUsgWinter = operList.inflAmt.winterAvg * 0.65; // 동절기 물사용량 평균 // 지하수유입량 operationalStatusList[0].groundWaterAvg = Math.round((usage - (wtrUsg * OSU_PERCENT)) * 100) / 100; operationalStatusList[0].groundWaterSummer = Math.round((summerUsage - (wtrUsgSummer * OSU_PERCENT)) * 100) / 100; operationalStatusList[0].groundWaterWinter = Math.round((winterUsage - (wtrUsgWinter * OSU_PERCENT)) * 100) / 100; // 오염물질 // RDII 추정 = 하절기(6~8월) 중 최저 유입 BOD일때 유입유량 x ((동절기 청천시 유입BOD - 하절기(6~8월) 중 최저 유입BOD) / (동절기 청천시 유입BOD)) // const resp = await fetchMainGraph(searchYear, fcltyCd); const resp = mainGraphData; if (resp && resp.data && resp.data.wqltObjs && resp.data.wqltObjs.length > 0) { const wqltData = resp.data.wqltObjs; const wqltDataTot = CalcRainEffect(clone(wqltData)); const wqltDataSunny = CalcRainEffect(clone(wqltData), 'SUNNY'); let minSummerBod = 99999999; let minSummerBodInfl = 99999999; let winterCnt = 0; let winterBodSunny = 0; let rdiRain = 0; const summerMonth = ['06', '07', '08']; const winterMonth = ['01', '02']; wqltDataTot.filter(item => summerMonth.includes(item.msrDt.toString().replaceAll('-', '').substring(4, 6))).forEach(item2 => { if (Number(item2.infoRnDay) >= 3) { // 3mm 이상 강우일 const inflBod = Number(item2.inflAssctBfrWqltBod); //유입연계전수질_BOD(mg/L) const infl = Number(item2.inflAmnt); //실제유입량(반류수제거)(m³/일) const rain = Number(item2.infoRnDay); //강우량 if (inflBod < minSummerBod) { minSummerBodInfl = infl; minSummerBod = inflBod; rdiRain = rain; // 하절기 최소 bod일때의 일강수량 } } }); wqltDataSunny.filter(item => winterMonth.includes(item.msrDt.toString().replaceAll('-', '').substring(4, 6))).forEach(item2 => { winterBodSunny += Number(item2.inflAssctBfrWqltBod); // 동절기 청천시 유입BOD(mg/L) winterCnt += 1; }); const roundMinSummerBodInfl = Number(roundNumber(minSummerBodInfl, 0).toString().replaceAll(',', '')); const roundMinSummerBod = Number(roundNumber(minSummerBod, 1).toString().replaceAll(',', '')); const roundWinterBodSunny = Number(roundNumber(winterBodSunny, 1).toString().replaceAll(',', '')); const winterBodAvg = Number(roundNumber((roundWinterBodSunny / winterCnt), 1).toString().replaceAll(',', '')); // 하절기(6~8월) 중 최저 유입 BOD일때 유입유량 x ((동절기 청천시 유입BOD - 하절기(6~8월) 중 최저 유입BOD) / (동절기 청천시 유입BOD)) const winMinusSum = winterBodAvg - roundMinSummerBod; const rdiValue = winMinusSum === 0 ? 0 : roundMinSummerBodInfl * (winMinusSum / winterBodAvg); rdiPercent = (rdiValue / minSummerBodInfl) * 100; operationalStatusList[0].rdi = rdiValue; // RDII 추정 operationalStatusList[0].rdiRain = rdiRain; // RDII 추정시 일강수량(mm) } } if (operationalStatusList[0] && operationalStatusList[7]) { // operationalStatusList[7].groundWaterAvg = operationalStatusList[0].groundWaterAvg === null ? '' : operList.inFlow.yearTot && data.yearData.AVG_INFL_AMNT === 0 ? '' : Math.round((Number(operationalStatusList[0].groundWaterAvg.toString().replaceAll(',', '')) / (data.yearData && data.yearData.AVG_INFL_AMNT ? Number(data.yearData.AVG_INFL_AMNT.toString().replaceAll(',', '')) : 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.toString().replaceAll(',', '')) / (data.summer && data.summer.AVG_INFL_AMNT ? Number(data.summer.AVG_INFL_AMNT.toString().replaceAll(',', '')) : 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.toString().replaceAll(',', '')) / (data.winter && data.winter.AVG_INFL_AMNT ? Number(data.winter.AVG_INFL_AMNT.toString().replaceAll(',', '')) : 0) * 100) * 10) / 10 + '%'; operationalStatusList[7].groundWaterAvg = operList.inflAmt.yearAvg === 0 ? '' : Math.round((Number(operationalStatusList[0].groundWaterAvg.toString().replaceAll(',', '')) / operList.inflAmt.yearAvg * 100) * 10) / 10 + '%'; operationalStatusList[7].groundWaterSummer = operList.inflAmt.summerAvg === 0 ? '' : Math.round((Number(operationalStatusList[0].groundWaterSummer.toString().replaceAll(',', '')) / operList.inflAmt.summerAvg * 100) * 10) / 10 + '%'; operationalStatusList[7].groundWaterWinter = operList.inflAmt.winterAvg === 0 ? '' : Math.round((Number(operationalStatusList[0].groundWaterWinter.toString().replaceAll(',', '')) / operList.inflAmt.winterAvg * 100) * 10) / 10 + '%'; operationalStatusList[7].rdi = roundNumber(rdiPercent, 1) + '%'; } // 순수하수량(1), 연계처리수(2), 총인설비방류수(3), 방류수(4) 데이터 매핑 const flowMappings = [ { index: 0, source: operList.inFlow }, { index: 1, source: operList.inflAmt }, { index: 2, source: operList.sumFlow }, { index: 3, source: operList.returnFlow }, { index: 4, source: operList.efflFlow }, ]; flowMappings.forEach(({ index, source }) => { const item = operationalStatusList[index]; if (item) { item.yearAvg = source.yearAvg; item.yearMax = source.yearMax; item.yearMin = source.yearMin; item.summerAll = source.summerAvg; item.summerThree = source.summerRainy; item.summerRain = source.summerSunny; item.winterSunnyAvg = source.winterSunny; item.winterSunnyMax = source.winterSunnyMax; item.winterSunnyMin = source.winterSunnyMin; item.winterAll = source.winterAvg; dataFormSetting(item); } }); } const rtnData = await calcWaterQltyData(operationalStatusList, searchYear, fcltyCd, mainGraphData); // 수질 데이터 청천시, 강우시 재계산 let tpFctYn = 'N'; if (mainGraphData.data.wqltObjs && mainGraphData.data.wqltObjs.length > 0) tpFctYn = mainGraphData.data.wqltObjs?.[0].tpFctYn; // 총인설비가 없을 경우 제외 console.log('총인시설 여부 : ', tpFctYn); // console.log('rtnData : ', rtnData); if (tpFctYn !== 'Y') { operationalStatusList = rtnData.slice(0, 11); } else { operationalStatusList = rtnData; } set((state: DashBoardType) => ({ ...state, OperationStatus: { ...state.OperationStatus, operationalStatusList: operationalStatusList, operationalStatusCount: 0, isLoadingOperationStatus: false, }, })) }, searchMainGraph: async (searchYear: string, fcltyCd: string) => { const state = get(); let res: any = null; // 이미 조회된 데이터가 있는지 확인 if (state.RainManage.mainGraphYear === searchYear && state.RainManage.mainGraphFcltyCd === fcltyCd && state.RainManage.mainGraphData) { res = state.RainManage.mainGraphData; } else { res = await fetchMainGraph(searchYear, fcltyCd); // 데이터 저장 set((state: DashBoardType) => ({ ...state, RainManage: { ...state.RainManage, mainGraphData: res, mainGraphYear: searchYear, mainGraphFcltyCd: fcltyCd, } })); } set((state: DashBoardType) => ({ ...state, MainGraph: { ...state.MainGraph, isLoadingMainGraph: true, }, })); // const res = await fetchMainGraph(searchYear, fcltyCd); const res2 = await fetchFacilityWaterQltyInfo(fcltyCd); let chungcunSumFlow = 0; const calData = CalcRainEffect(res.data.wqltObjs, 'SUNNY') calData.forEach((flowItem: any) => { chungcunSumFlow += flowItem.inflAmnt && flowItem.inflAmnt !== 'x' ? Number(flowItem.inflAmnt.toString().trim()) : 0; }); const usage = chungcunSumFlow && chungcunSumFlow > 0 ? chungcunSumFlow / calData.length : 0; //bscFctCd === '11200PB001R') 중랑 - 테스트할 때 코드넣고 해야 보기편해요~ /* if(bscFctCd === '11200PB001R') { console.log('calData.length : ', calData.length); console.log('usage : ', usage, 'summerUsage : ', summerUsage, 'winterUsage : ', winterUsage); } */ const underWaterInputYear = Math.round((usage - (usage * 0.65 * OSU_PERCENT)) * 1) / 1; // 법적방류수질 데이터 const sortedWaterQltyInfo = [...res2].sort((a, b) => { // 숫자로 변환하여 비교 const numA = Number(a.extnsSeqno); const numB = Number(b.extnsSeqno); if (!isNaN(numA) && !isNaN(numB)) { return numA - numB; } // 숫자 변환이 실패하면 문자열로 비교 return String(a.extnsSeqno).localeCompare(String(b.extnsSeqno)); }); const waterQltyStandartd: any = sortedWaterQltyInfo && sortedWaterQltyInfo.length > 0 ? sortedWaterQltyInfo[sortedWaterQltyInfo.length - 1] : []; 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: [], waterQltyStandartd: [], 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: underWaterInputYear, 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: Number(item.tpInflWqltTp) == 0 ? null : item.tpInflWqltTp })); 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, waterQltyStandartd: waterQltyStandartd, isLoadingMainGraph: false, }, })) }, searchRainManage: async (searchYear: string, fcltyCd: string, isExcel: boolean) => { const state = get(); let res: any = null; if (state.RainManage.mainGraphYear === searchYear && state.RainManage.mainGraphFcltyCd === fcltyCd && state.RainManage.mainGraphData) { res = state.RainManage.mainGraphData; } else { res = await fetchMainGraph(searchYear, fcltyCd); set((state: DashBoardType) => ({ ...state, RainManage: { ...state.RainManage, mainGraphData: res, mainGraphYear: searchYear, mainGraphFcltyCd: fcltyCd, } })); } let res2: any = { data: [] }; // 이미 조회된 데이터가 있는지 확인 (연도와 시설코드가 같을 때만) if (state.RainManage.flowRateYear === searchYear && state.RainManage.flowRateFcltyCd === fcltyCd && state.RainManage.flowRateData) { res2 = state.RainManage.flowRateData; } else { res2 = await fetchFlowRateModalList(fcltyCd, searchYear); // /fclt/flow/ - 일별 유량 조회 // 조회된 데이터 저장 set((state: DashBoardType) => ({ ...state, RainManage: { ...state.RainManage, flowRateData: res2, flowRateYear: searchYear, flowRateFcltyCd: fcltyCd, } })); } 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 미만', '50~60mm 미만', '60mm 이상']; const rainRate = ['0', '0', '0', '0', '0', '0', '0', '0']; const rainDate: number[] = [0, 0, 0, 0, 0, 0, 0, 0]; const inflAmnt: number[] = [0, 0, 0, 0, 0, 0, 0, 0]; const fcltyCpct: number[] = [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 = CalcRainEffect(res.data.wqltObjs, 'RAIN_DAY'); // Process the data and create rain management list const totItemCnt = rainEffectList ? rainEffectList.length : 1; let totInflAssctBfrWqltBod = 0; let totInflAssctBfrWqltToc = 0; let totInflAssctBfrWqltSs = 0; let totInflAssctBfrWqltTn = 0; let totInflAssctBfrWqltTp = 0; let totEfflWqltBod = 0; let totEfflWqltToc = 0; let totEfflWqltSs = 0; let totEfflWqltTn = 0; let totEfflWqltTp = 0; let totInflAmnt = 0; rainEffectList.forEach((item: RainManageListProps) => { totInflAssctBfrWqltBod += item.inflAssctBfrWqltBod ? Number(item.inflAssctBfrWqltBod.toString().trim()) : 0; totInflAssctBfrWqltToc += item.inflAssctBfrWqltToc ? Number(item.inflAssctBfrWqltToc.toString().trim()) : 0; totInflAssctBfrWqltSs += item.inflAssctBfrWqltSs ? Number(item.inflAssctBfrWqltSs.toString().trim()) : 0; totInflAssctBfrWqltTn += item.inflAssctBfrWqltTn ? Number(item.inflAssctBfrWqltTn.toString().trim()) : 0; totInflAssctBfrWqltTp += item.inflAssctBfrWqltTp ? Number(item.inflAssctBfrWqltTp.toString().trim()) : 0; totEfflWqltBod += item.efflWqltBod ? Number(item.efflWqltBod.toString().trim()) : 0; totEfflWqltToc += item.efflWqltToc ? Number(item.efflWqltToc.toString().trim()) : 0; totEfflWqltSs += item.efflWqltSs ? Number(item.efflWqltSs.toString().trim()) : 0; totEfflWqltTn += item.efflWqltTn ? Number(item.efflWqltTn.toString().trim()) : 0; totEfflWqltTp += item.efflWqltTp ? Number(item.efflWqltTp.toString().trim()) : 0; totInflAmnt += item.inflAmnt ? Number(item.inflAmnt.toString().trim()) : 0; const toBeRain = item.toBeInfoRnDay ? Number(item.toBeInfoRnDay) : 0; if (toBeRain >= 3 && toBeRain < 10) { rainDate[1] = (rainDate[1] || 0) + 1; inflAmnt[1] = (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 (toBeRain >= 10 && toBeRain < 20) { rainDate[2] = (rainDate[2] || 0) + 1; inflAmnt[2] = (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 (toBeRain >= 20 && toBeRain < 30) { rainDate[3] = (rainDate[3] || 0) + 1; inflAmnt[3] = (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 (toBeRain >= 30 && toBeRain < 40) { rainDate[4] = (rainDate[4] || 0) + 1; inflAmnt[4] = (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[4] || 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[4] || 0) + 1; efflWqltTn[4] = Number(efflWqltTn[4] || 0) + Number(item.efflWqltTn || 0); efflWqltTpCnt[4] = Number(efflWqltTpCnt[4] || 0) + 1; efflWqltTp[4] = Number(efflWqltTp[4] || 0) + Number(item.efflWqltTp || 0); } else if (toBeRain >= 40 && toBeRain < 50) { rainDate[5] = (rainDate[5] || 0) + 1; inflAmnt[5] = (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 (toBeRain >= 50 && toBeRain < 60) { rainDate[6] = (rainDate[6] || 0) + 1; inflAmnt[6] = (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 (toBeRain >= 60) { rainDate[7] = (rainDate[7] || 0) + 1; inflAmnt[7] = (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); } }); // 유량 = 순수하수 + 연계처리수 + 총인설비반류수 const rainEffFlowList: any[] = CalcRainEffect(res2.data, 'RAIN_DAY'); totInflAmnt = 0; inflAmnt.fill(0); rainDate.fill(0); rainEffFlowList.forEach((item: any) => { // --일별 유량 start const toBeRain = item.toBeInfoRnDay ? Number(item.toBeInfoRnDay) : 0; const inflAmntOne = item.inflAmnt && item.inflAmnt !== 'x' ? Number(item.inflAmnt.toString().trim()) : 0; const sumFlowOne = item.sumFlow && item.sumFlow !== 'x' ? Number(item.sumFlow.toString().trim()) : 0; const returnAmntOne = item.returnAmnt && item.returnAmnt !== 'x' ? Number(item.returnAmnt.toString().trim()) : 0; const inflowOne = inflAmntOne + sumFlowOne + returnAmntOne; totInflAmnt = totInflAmnt + inflowOne; // 유량합계 if (toBeRain >= 3 && toBeRain < 10) { inflAmnt[1] = (inflAmnt[1] || 0) + inflowOne; rainDate[1] = (rainDate[1] || 0) + 1; } else if (toBeRain >= 10 && toBeRain < 20) { inflAmnt[2] = (inflAmnt[2] || 0) + inflowOne; rainDate[2] = (rainDate[2] || 0) + 1; } else if (toBeRain >= 20 && toBeRain < 30) { inflAmnt[3] = (inflAmnt[3] || 0) + inflowOne; rainDate[3] = (rainDate[3] || 0) + 1; } else if (toBeRain >= 30 && toBeRain < 40) { inflAmnt[4] = (inflAmnt[4] || 0) + inflowOne; rainDate[4] = (rainDate[4] || 0) + 1; } else if (toBeRain >= 40 && toBeRain < 50) { inflAmnt[5] = (inflAmnt[5] || 0) + inflowOne; rainDate[5] = (rainDate[5] || 0) + 1; } else if (toBeRain >= 50 && toBeRain < 60) { inflAmnt[6] = (inflAmnt[6] || 0) + inflowOne; rainDate[6] = (rainDate[6] || 0) + 1; } else if (toBeRain >= 60) { inflAmnt[7] = (inflAmnt[7] || 0) + inflowOne; rainDate[7] = (rainDate[7] || 0) + 1; } }); // --일별 유량 end // 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 < rainDate.length; idx++) { if (Number(rainDate[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)) : 0; }; for (let idx = 1; idx < inflAmnt.length; idx++) { inflAmnt[idx] = rainDate[idx] ? Math.round((inflAmnt[idx] || 0) / (rainDate[idx] || 0)) : 0; inflAssctBfrWqltBod[idx] = calculateAverage(Number(inflAssctBfrWqltBod[idx]), Number(inflAssctBfrWqltBodCnt[idx])); inflAssctBfrWqltToc[idx] = calculateAverage(Number(inflAssctBfrWqltToc[idx]), Number(inflAssctBfrWqltTocCnt[idx])); inflAssctBfrWqltSs[idx] = calculateAverage(Number(inflAssctBfrWqltSs[idx]), Number(inflAssctBfrWqltSsCnt[idx])); inflAssctBfrWqltTn[idx] = calculateAverage(Number(inflAssctBfrWqltTn[idx]), Number(inflAssctBfrWqltTnCnt[idx])); inflAssctBfrWqltTp[idx] = calculateAverage(Number(inflAssctBfrWqltTp[idx]), Number(inflAssctBfrWqltTpCnt[idx])); efflWqltBod[idx] = calculateAverage(Number(efflWqltBod[idx]), Number(efflWqltBodCnt[idx])); efflWqltToc[idx] = calculateAverage(Number(efflWqltToc[idx]), Number(efflWqltTocCnt[idx])); efflWqltSs[idx] = calculateAverage(Number(efflWqltSs[idx]), Number(efflWqltSsCnt[idx])); efflWqltTn[idx] = calculateAverage(Number(efflWqltTn[idx]), Number(efflWqltTnCnt[idx])); efflWqltTp[idx] = calculateAverage(Number(efflWqltTp[idx]), Number(efflWqltTpCnt[idx])); } // 합계 계산 (index 0) const calculateTotal = (arr: number[]) => { return Number((arr.slice(1).reduce((sum, val) => sum + Number(val), 0))); }; // console.log(totInflAmnt); inflAmnt[0] = Math.round((totInflAmnt / totItemCnt)); // calculateAverage(totInflAmnt, totItemCnt); fcltyCpct[0] = calculateTotal(fcltyCpct); inflAssctBfrWqltBod[0] = Number((Math.round((totInflAssctBfrWqltBod / totItemCnt) * 10) / 10).toFixed(1)); inflAssctBfrWqltToc[0] = Number((Math.round((totInflAssctBfrWqltToc / totItemCnt) * 10) / 10).toFixed(1)); inflAssctBfrWqltSs[0] = Number((Math.round((totInflAssctBfrWqltSs / totItemCnt) * 10) / 10).toFixed(1)); inflAssctBfrWqltTn[0] = Number((Math.round((totInflAssctBfrWqltTn / totItemCnt) * 1000) / 1000).toFixed(3)); inflAssctBfrWqltTp[0] = Number((Math.round((totInflAssctBfrWqltTp / totItemCnt) * 1000) / 1000).toFixed(3)); efflWqltBod[0] = Number((Math.round((totEfflWqltBod / totItemCnt) * 10) / 10).toFixed(1)); efflWqltToc[0] = Number((Math.round((totEfflWqltToc / totItemCnt) * 10) / 10).toFixed(1)); efflWqltSs[0] = Number((Math.round((totEfflWqltSs / totItemCnt) * 10) / 10).toFixed(1)); efflWqltTn[0] = Number((Math.round((totEfflWqltTn / totItemCnt) * 1000) / 1000).toFixed(3)); efflWqltTp[0] = Number((Math.round((totEfflWqltTp / totItemCnt) * 1000) / 1000).toFixed(3)); // 최종 리스트 const filteredData = itemList.map((item, index) => ({ rainItem: item, rainRate: rainRate[index] || '0', rainDay: rainDate[index] ? Number(rainDate[index].toFixed(1)) : '0', inflAmnt: inflAmnt[index] ? Number((Math.round(inflAmnt[index] * 1) / 1)) : '', fctCpc: inflAmnt[index] ? (Math.round((inflAmnt[index] / fcltyCpcValue) * 10) / 10).toFixed(1) : '', dsInflWqltBod: dsInflWqltBod[index] ? (Math.round(dsInflWqltBod[index] * 10) / 10).toFixed(1) : '', dsInflWqltCod: dsInflWqltCod[index] ? (Math.round(dsInflWqltCod[index] * 10) / 10).toFixed(1) : '', dsInflWqltSs: dsInflWqltSs[index] ? (Math.round(dsInflWqltSs[index] * 10) / 10).toFixed(1) : '', dsInflWqltTn: dsInflWqltTn[index] ? (Math.round(dsInflWqltTn[index] * 1000) / 1000).toFixed(3) : '', dsInflWqltTp: dsInflWqltTp[index] ? (Math.round(dsInflWqltTp[index] * 1000) / 1000).toFixed(3) : '', inflAssctBfrWqltBod: inflAssctBfrWqltBod[index] ? (Math.round(inflAssctBfrWqltBod[index] * 10) / 10).toFixed(1) : '', inflAssctBfrWqltToc: inflAssctBfrWqltToc[index] ? (Math.round(inflAssctBfrWqltToc[index] * 10) / 10).toFixed(1) : '', inflAssctBfrWqltSs: inflAssctBfrWqltSs[index] ? (Math.round(inflAssctBfrWqltSs[index] * 10) / 10).toFixed(1) : '', inflAssctBfrWqltTn: inflAssctBfrWqltTn[index] ? (Math.round(inflAssctBfrWqltTn[index] * 1000) / 1000).toFixed(3) : '', inflAssctBfrWqltTp: inflAssctBfrWqltTp[index] ? (Math.round(inflAssctBfrWqltTp[index] * 1000) / 1000).toFixed(3) : '', efflWqltBod: efflWqltBod[index] ? (Math.round(efflWqltBod[index] * 10) / 10).toFixed(1) : '', efflWqltToc: efflWqltToc[index] ? (Math.round(efflWqltToc[index] * 10) / 10).toFixed(1) : '', efflWqltSs: efflWqltSs[index] ? (Math.round(efflWqltSs[index] * 10) / 10).toFixed(1) : '', efflWqltTn: efflWqltTn[index] ? (Math.round(efflWqltTn[index] * 1000) / 1000).toFixed(3) : '', efflWqltTp: efflWqltTp[index] ? (Math.round(efflWqltTp[index] * 1000) / 1000).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)) : 0, 유입유량: item.inflAmnt ? Number((Math.round(Number(item.inflAmnt) * 1) / 1)) : '', 시설용량대비: item.fctCpc ? (Math.round(Number(item.fctCpc) * 10) / 10).toFixed(1) : '', 설계유입수질BOD: item.dsInflWqltBod ? (Math.round(Number(item.dsInflWqltBod) * 10) / 10).toFixed(1) : '', 설계유입수질TOC: item.dsInflWqltCod ? (Math.round(Number(item.dsInflWqltCod) * 10) / 10).toFixed(1) : '', 설계유입수질SS: item.dsInflWqltSs ? (Math.round(Number(item.dsInflWqltSs) * 10) / 10).toFixed(1) : '', 설계유입수질TN: item.dsInflWqltTn ? (Math.round(Number(item.dsInflWqltTn) * 1000) / 1000).toFixed(3) : '', 설계유입수질TP: item.dsInflWqltTp ? (Math.round(Number(item.dsInflWqltTp) * 1000) / 1000).toFixed(3) : '', 유입수질BOD: item.inflAssctBfrWqltBod ? (Math.round(Number(item.inflAssctBfrWqltBod) * 10) / 10).toFixed(1) : '', 유입수질TOC: item.inflAssctBfrWqltToc ? (Math.round(Number(item.inflAssctBfrWqltToc) * 10) / 10).toFixed(1) : '', 유입수질SS: item.inflAssctBfrWqltSs ? (Math.round(Number(item.inflAssctBfrWqltSs) * 10) / 10).toFixed(1) : '', 유입수질TN: item.inflAssctBfrWqltTn ? (Math.round(Number(item.inflAssctBfrWqltTn) * 1000) / 1000).toFixed(3) : '', 유입수질TP: item.inflAssctBfrWqltTp ? (Math.round(Number(item.inflAssctBfrWqltTp) * 1000) / 1000).toFixed(3) : '', 방류수질BOD: item.efflWqltBod ? (Math.round(Number(item.efflWqltBod) * 10) / 10).toFixed(1) : '', 방류수질TOC: item.efflWqltToc ? (Math.round(Number(item.efflWqltToc) * 10) / 10).toFixed(1) : '', 방류수질SS: item.efflWqltSs ? (Math.round(Number(item.efflWqltSs) * 10) / 10).toFixed(1) : '', 방류수질TN: item.efflWqltTn ? (Math.round(Number(item.efflWqltTn) * 1000) / 1000).toFixed(3) : '', 방류수질TP: item.efflWqltTp ? (Math.round(Number(item.efflWqltTp) * 1000) / 1000).toFixed(3) : '', }); }); } set((state: DashBoardType) => ({ ...state, RainManage: isExcel ? { ...state.RainManage, rainManageList: filteredData as any[], excelList: excelList, isLoadingRainManage: false, } : { ...state.RainManage, rainManageList: filteredData as any[], isLoadingRainManage: false, } })); }, } }