2194 lines
115 KiB
TypeScript
2194 lines
115 KiB
TypeScript
/**
|
|
* Store - 타입
|
|
*/
|
|
|
|
import { getFetch } from "@/app/components/api";
|
|
import CalcRainEffect from "@/app/components/common/CalcRainEffect";
|
|
import DataForm from "@/app/components/common/DataForm";
|
|
import { fetchPlanInfo, OSU_PERCENT, roundUp } from "../common";
|
|
import type { FacilityWaterQltyProps } from "../facilityWaterQlty";
|
|
import { fetchFlowRateModalList } from "../flowRate";
|
|
|
|
// selectBox
|
|
export type SelectDataType = {
|
|
text: string;
|
|
val: string;
|
|
}
|
|
|
|
// grid header
|
|
export type TableUpperProps = {
|
|
id: string;
|
|
title: string;
|
|
upName?: string;
|
|
upSequnce?: number;
|
|
align? : string;
|
|
row? : number;
|
|
rowSpan?: number;
|
|
colSpan?: number;
|
|
}
|
|
|
|
// ===TAB1
|
|
// main fclty
|
|
export type mainFcltyProps = {
|
|
fcltyNm : string,
|
|
facilityCapacity : string,
|
|
publicMethod : string,
|
|
location : string
|
|
}
|
|
|
|
// 시설계획
|
|
export type planFcltyListProps = {
|
|
item : string,
|
|
provisionalApproval : string | number | '',
|
|
now : string | number | '',
|
|
stepOne : string | number | '',
|
|
stepTwo : string | number | '',
|
|
stepThree : string | number | '',
|
|
stepFour : string | number | '',
|
|
}
|
|
|
|
// 운영실태
|
|
export type OperationalStatusListProps = {
|
|
flowRate : string,
|
|
waterQlty : string,
|
|
yearAvg : number | string | '',
|
|
yearMax : number | string | '',
|
|
yearMin : number | string | '',
|
|
summerAll : number | string | '',
|
|
summerThree : number | string | '',
|
|
summerRain : number | string | '',
|
|
winterAll : number | string | '',
|
|
winterSunnyAvg : number | string | '',
|
|
winterSunnyMax : number | string | '',
|
|
winterSunnyMin : number | string | '',
|
|
groundWaterAvg : number | string | '',
|
|
groundWaterSummer : number | string | '',
|
|
groundWaterWinter : number | string | '',
|
|
rdi : number | string | '',
|
|
rdiRain : number | string | '',
|
|
}
|
|
|
|
export interface operationalStatusListProps {
|
|
flowRate : string,
|
|
waterQlty : string,
|
|
yearAvg : number | '',
|
|
yearMax : number | '',
|
|
yearMin : number | '',
|
|
summerAll : number | '',
|
|
summerThree : number | '',
|
|
summerRain : number | '',
|
|
winterAll : number | '',
|
|
winterSunnyAvg : number | '',
|
|
winterSunnyMax : number | '',
|
|
winterSunnyMin : number | '',
|
|
groundWaterAvg : number | string | '',
|
|
groundWaterSummer : number | string | '',
|
|
groundWaterWinter : number | string | '',
|
|
rdi : number | '',
|
|
}
|
|
|
|
// 차트
|
|
export type lineBarChartDataProps = {
|
|
label : string,
|
|
lineVal : number
|
|
barVal : number
|
|
barVal0 : number
|
|
barVal1 : number
|
|
lineVal0 : number
|
|
lineVal1 : number
|
|
}
|
|
|
|
export type lineChartDataProps = {
|
|
label : string,
|
|
val : number
|
|
}
|
|
|
|
export interface RainManageListProps {
|
|
rainItem : string,
|
|
rainRate : string,
|
|
rainDay : number,
|
|
bscFctCd?: string,
|
|
bscFctNm?: string,
|
|
msrDt?: string
|
|
sidoNm?: string,
|
|
sggNm?: string,
|
|
addr?: string,
|
|
fctCpc?: number,
|
|
inflAssctBfrWqltBod: number | '',
|
|
inflAssctBfrWqltToc: number | '',
|
|
inflAssctBfrWqltSs: number | '',
|
|
inflAssctBfrWqltTn: number | '',
|
|
inflAssctBfrWqltTp: number | '',
|
|
efflWqltBod: number | '',
|
|
efflWqltToc: number | '',
|
|
efflWqltSs: number | '',
|
|
efflWqltTn: number | '',
|
|
efflWqltTp: number | '',
|
|
rgnNm?:string|'',
|
|
rvbsn?:string|'',
|
|
lgbsn?:string|'',
|
|
mdmbsn?:string|'',
|
|
inflAmnt: number | '',
|
|
lclgvrnmntNm?: string,
|
|
infoRnDay?: number | '',
|
|
tpInflWqltTmprtr?: number | '',
|
|
tpInflWqltPh?: number | '',
|
|
tpInflWqltBod?: number | '',
|
|
tpInflWqltCod?: number | '',
|
|
tpInflWqltSs?: number | '',
|
|
tpInflWqltTn?: number | '',
|
|
tpInflWqltTp?: number | '',
|
|
tpInflWqltEclgyTox?: number | '',
|
|
tpInflWqltClfgrpcnt?: number | '',
|
|
dsInflWqltBod: number | '',
|
|
dsInflWqltCod: number | '',
|
|
dsInflWqltSs: number | '',
|
|
dsInflWqltTn: number | '',
|
|
dsInflWqltTp: number | '',
|
|
extnsSeqno?: number | '',
|
|
rainEffectDay?: number | '',
|
|
}
|
|
|
|
export interface RainManageExcelType {
|
|
강우량: string,
|
|
강우조건비율: number | '',
|
|
일수: number | '',
|
|
유입유량: 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 | '',
|
|
}
|
|
|
|
/**
|
|
* Store - data
|
|
*/
|
|
// Main
|
|
const DashBoardTopLabelArray:string[] = ['구분', '시도', '시군구', '년도', '시설명'];
|
|
|
|
// === Tab1
|
|
// grid header
|
|
const upHeadListFclty:TableUpperProps[] = [
|
|
{ id : "fcltyNm", title : "시설명"},
|
|
{ id : "facilityCapacity", title : "시설용량(m³/일)"},
|
|
{ id : "publicMethod", title : "공법"},
|
|
{ id : "location", title : "지역구"},
|
|
]
|
|
|
|
const fcltyList : mainFcltyProps[] = [
|
|
]
|
|
|
|
let planYearList : string[] = [
|
|
"2021",
|
|
"2022",
|
|
"2023",
|
|
"2024",
|
|
"2025",
|
|
"2026"
|
|
]
|
|
|
|
const upHeadListPlanFclty : TableUpperProps[] = [
|
|
{ id: "item", title: "", upName:"upChangeRe", upSequnce:1 },
|
|
{ id: "provisionalApproval", title: "기승인\n4단계", upName:"upChangeRe", upSequnce:2 },
|
|
{ id: "now", title: "현재", upName:"upChangeRe", upSequnce:3 },
|
|
{ id: "stepOne", title: "1단계", upName:"upChangeRe", upSequnce:4 },
|
|
{ id: "stepTwo", title: "2단계", upName:"upChangeRe", upSequnce:5 },
|
|
{ id: "stepThree", title: "3단계", upName:"upChangeRe", upSequnce:6 },
|
|
{ id: "stepFour", title: "4단계", upName:"upChangeRe", upSequnce:7 },
|
|
]
|
|
|
|
const planFcltyList:planFcltyListProps[] = [
|
|
{
|
|
item : "1.증설계획\n(㎥/일)",
|
|
provisionalApproval: "",
|
|
now: "",
|
|
stepOne: "",
|
|
stepTwo: "",
|
|
stepThree: "",
|
|
stepFour : "",
|
|
},
|
|
{
|
|
item : "2.처리인구(인)",
|
|
provisionalApproval: "",
|
|
now: "",
|
|
stepOne: "",
|
|
stepTwo: "",
|
|
stepThree: "",
|
|
stepFour : "",
|
|
},
|
|
{
|
|
item : "3.처리구역\n(km²)",
|
|
provisionalApproval: "",
|
|
now: "",
|
|
stepOne: "",
|
|
stepTwo: "",
|
|
stepThree: "",
|
|
stepFour : "",
|
|
},
|
|
{
|
|
item : "4.분류식화율\n(%)",
|
|
provisionalApproval: "",
|
|
now: "",
|
|
stepOne: "",
|
|
stepTwo: "",
|
|
stepThree: "",
|
|
stepFour : "",
|
|
},
|
|
{
|
|
item : "5.물사용량",
|
|
provisionalApproval: "",
|
|
now: "",
|
|
stepOne: "",
|
|
stepTwo: "",
|
|
stepThree: "",
|
|
stepFour : "",
|
|
},
|
|
{
|
|
item : "년도\n(최근 3개년)",
|
|
provisionalApproval: "물사용량\n(㎥/일)",
|
|
now: "",
|
|
stepOne: "",
|
|
stepTwo: "비고",
|
|
stepThree: "",
|
|
stepFour : "",
|
|
},
|
|
{
|
|
item : "2021",
|
|
provisionalApproval: "",
|
|
now: "",
|
|
stepOne: "",
|
|
stepTwo: "",
|
|
stepThree: "",
|
|
stepFour : "",
|
|
},
|
|
{
|
|
item : "2022",
|
|
provisionalApproval: "",
|
|
now: "",
|
|
stepOne: "",
|
|
stepTwo: "",
|
|
stepThree: "",
|
|
stepFour : "",
|
|
},
|
|
{
|
|
item : "2023",
|
|
provisionalApproval: "",
|
|
now: "",
|
|
stepOne: "",
|
|
stepTwo: "",
|
|
stepThree: "",
|
|
stepFour : "",
|
|
},
|
|
]
|
|
|
|
const upHeadListOperationStatus : TableUpperProps[] = [
|
|
{ id: "flowRate", title: "유량 및 수질", upName:"upChangeRe1", upSequnce:1 },
|
|
{ id: "waterQlty", title: "유량 및 수질", upName:"upChangeRe1", upSequnce:2 },
|
|
{ id: "yearAvg", title: "평균", upName:"upChangeRe2", upSequnce:1 },
|
|
{ id: "yearMax", title: "최대", upName:"upChangeRe2", upSequnce:2 },
|
|
{ id: "yearMin", title: "최소", upName:"upChangeRe2", upSequnce:3 },
|
|
{ id: "summerAll", title: "전기간", upName:"upChangeRe3", upSequnce:1 },
|
|
{ id: "summerThree", title: "강우시\n(3mm이상)", upName:"upChangeRe3", upSequnce:2 },
|
|
{ id: "summerRain", title: "청천시", upName:"upChangeRe3", upSequnce:3 },
|
|
{ id: "winterAll", title: "전기간", upName:"upChangeRe4", upSequnce:1 },
|
|
{ id: "winterSunnyAvg", title: "청천시\n평균", upName:"upChangeRe4", upSequnce:2 },
|
|
{ id: "winterSunnyMax", title: "청천시\n최대", upName:"upChangeRe4", upSequnce:3 },
|
|
{ id: "winterSunnyMin", title: "청천시\n최소", upName:"upChangeRe4", upSequnce:4 },
|
|
{ id: "groundWaterAvg", title: "연평균", upName:"upChangeRe5", upSequnce:1 },
|
|
{ id: "groundWaterSummer", title: "하절기\n평균", upName:"upChangeRe5", upSequnce:2 },
|
|
{ id: "groundWaterWinter", title: "동절기\n평균", upName:"upChangeRe5", upSequnce:3 },
|
|
{ id: "rdi", title: "RDII 추정" },
|
|
{ id: "rdiRain", title: "RDII 추정시\n일강수량(mm)" },
|
|
]
|
|
|
|
const upHeadListRainManage : TableUpperProps[] = [
|
|
{ id: "rainItem", title: "강우량", row:0, rowSpan:2 },
|
|
{ id: "rainRate", title: "강우조건\n비율(%)", row:0, rowSpan:2, align: "right" },
|
|
{ id: "rainDay", title: "일수", row:0, rowSpan:2, align: "right" },
|
|
{ id: "A", title: "유입(㎥/일)", row:0, colSpan:2 },
|
|
{ id: "inflAmnt", title: "유입유량", row:1, align: "right" },
|
|
{ id: "fctCpc", title: "시설용량대비", row:1, align: "right" },
|
|
{ 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 },
|
|
]
|
|
|
|
let operationalStatusList : OperationalStatusListProps[] = [
|
|
{
|
|
flowRate : '유량\n(㎥/일)',
|
|
waterQlty : '유입',
|
|
yearAvg : '',
|
|
yearMax : '',
|
|
yearMin : '',
|
|
summerAll : '',
|
|
summerThree : '',
|
|
summerRain : '',
|
|
winterAll : '',
|
|
winterSunnyAvg : '',
|
|
winterSunnyMax : '',
|
|
winterSunnyMin : '',
|
|
groundWaterAvg : '',
|
|
groundWaterSummer : '',
|
|
groundWaterWinter : '',
|
|
rdi : '',
|
|
rdiRain : '',
|
|
},
|
|
{
|
|
flowRate : '유량\n(㎥/일)',
|
|
waterQlty : '순수하수',
|
|
yearAvg : '',
|
|
yearMax : '',
|
|
yearMin : '',
|
|
summerAll : '',
|
|
summerThree : '',
|
|
summerRain : '',
|
|
winterAll : '',
|
|
winterSunnyAvg : '',
|
|
winterSunnyMax : '',
|
|
winterSunnyMin : '',
|
|
groundWaterAvg : '',
|
|
groundWaterSummer : '',
|
|
groundWaterWinter : '',
|
|
rdi : '',
|
|
rdiRain : '',
|
|
},
|
|
{
|
|
flowRate : '유량\n(㎥/일)',
|
|
waterQlty : '연계처리수',
|
|
yearAvg : '',
|
|
yearMax : '',
|
|
yearMin : '',
|
|
summerAll : '',
|
|
summerThree : '',
|
|
summerRain : '',
|
|
winterAll : '',
|
|
winterSunnyAvg : '',
|
|
winterSunnyMax : '',
|
|
winterSunnyMin : '',
|
|
groundWaterAvg : '',
|
|
groundWaterSummer : '',
|
|
groundWaterWinter : '',
|
|
rdi : '',
|
|
rdiRain : '',
|
|
},
|
|
{
|
|
flowRate : '유량\n(㎥/일)',
|
|
waterQlty : '총인설비\n반류수',
|
|
yearAvg : '',
|
|
yearMax : '',
|
|
yearMin : '',
|
|
summerAll : '',
|
|
summerThree : '',
|
|
summerRain : '',
|
|
winterAll : '',
|
|
winterSunnyAvg : '',
|
|
winterSunnyMax : '',
|
|
winterSunnyMin : '',
|
|
groundWaterAvg : '',
|
|
groundWaterSummer : '',
|
|
groundWaterWinter : '',
|
|
rdi : '',
|
|
rdiRain : '',
|
|
},
|
|
{
|
|
flowRate : '유량\n(㎥/일)',
|
|
waterQlty : '방류',
|
|
yearAvg : '',
|
|
yearMax : '',
|
|
yearMin : '',
|
|
summerAll : '',
|
|
summerThree : '',
|
|
summerRain : '',
|
|
winterAll : '',
|
|
winterSunnyAvg : '',
|
|
winterSunnyMax : '',
|
|
winterSunnyMin : '',
|
|
groundWaterAvg : '',
|
|
groundWaterSummer : '',
|
|
groundWaterWinter : '',
|
|
rdi : '',
|
|
rdiRain : '',
|
|
},
|
|
{
|
|
flowRate : '수질\n(mg/L)',
|
|
waterQlty : '유입\n(BOD)',
|
|
yearAvg : '',
|
|
yearMax : '',
|
|
yearMin : '',
|
|
summerAll : '',
|
|
summerThree : '',
|
|
summerRain : '',
|
|
winterAll : '',
|
|
winterSunnyAvg : '',
|
|
winterSunnyMax : '',
|
|
winterSunnyMin : '',
|
|
groundWaterAvg : '',
|
|
groundWaterSummer : '',
|
|
groundWaterWinter : '',
|
|
rdi : '',
|
|
rdiRain : '',
|
|
},
|
|
{
|
|
flowRate : '수질\n(mg/L)',
|
|
waterQlty : '방류\n(BOD)',
|
|
yearAvg : '',
|
|
yearMax : '',
|
|
yearMin : '',
|
|
summerAll : '',
|
|
summerThree : '',
|
|
summerRain : '',
|
|
winterAll : '',
|
|
winterSunnyAvg : '',
|
|
winterSunnyMax : '',
|
|
winterSunnyMin : '',
|
|
groundWaterAvg : '',
|
|
groundWaterSummer : '',
|
|
groundWaterWinter : '',
|
|
rdi : '',
|
|
rdiRain : '',
|
|
},
|
|
{
|
|
flowRate : '수질\n(mg/L)',
|
|
waterQlty : '유입\n(T-N)',
|
|
yearAvg : '',
|
|
yearMax : '',
|
|
yearMin : '',
|
|
summerAll : '',
|
|
summerThree : '',
|
|
summerRain : '',
|
|
winterAll : '',
|
|
winterSunnyAvg : '',
|
|
winterSunnyMax : '',
|
|
winterSunnyMin : '',
|
|
groundWaterAvg : '',
|
|
groundWaterSummer : '',
|
|
groundWaterWinter : '',
|
|
rdi : '',
|
|
rdiRain : '',
|
|
},
|
|
{
|
|
flowRate : '수질\n(mg/L)',
|
|
waterQlty : '방류\n(T-N)',
|
|
yearAvg : '',
|
|
yearMax : '',
|
|
yearMin : '',
|
|
summerAll : '',
|
|
summerThree : '',
|
|
summerRain : '',
|
|
winterAll : '',
|
|
winterSunnyAvg : '',
|
|
winterSunnyMax : '',
|
|
winterSunnyMin : '',
|
|
groundWaterAvg : '',
|
|
groundWaterSummer : '',
|
|
groundWaterWinter : '',
|
|
rdi : '',
|
|
rdiRain : '',
|
|
},
|
|
{
|
|
flowRate : '수질\n(mg/L)',
|
|
waterQlty : '유입\n(T-P)',
|
|
yearAvg : '',
|
|
yearMax : '',
|
|
yearMin : '',
|
|
summerAll : '',
|
|
summerThree : '',
|
|
summerRain : '',
|
|
winterAll : '',
|
|
winterSunnyAvg : '',
|
|
winterSunnyMax : '',
|
|
winterSunnyMin : '',
|
|
groundWaterAvg : '',
|
|
groundWaterSummer : '',
|
|
groundWaterWinter : '',
|
|
rdi : '',
|
|
rdiRain : '',
|
|
},
|
|
{
|
|
flowRate : '수질\n(mg/L)',
|
|
waterQlty : '방류\n(T-P)',
|
|
yearAvg : '',
|
|
yearMax : '',
|
|
yearMin : '',
|
|
summerAll : '',
|
|
summerThree : '',
|
|
summerRain : '',
|
|
winterAll : '',
|
|
winterSunnyAvg : '',
|
|
winterSunnyMax : '',
|
|
winterSunnyMin : '',
|
|
groundWaterAvg : '',
|
|
groundWaterSummer : '',
|
|
groundWaterWinter : '',
|
|
rdi : '',
|
|
rdiRain : '',
|
|
},
|
|
{
|
|
flowRate : '총인\n시설\n수질\n(mg/L)',
|
|
waterQlty : '총인설비\n유입(T-P)',
|
|
yearAvg : '',
|
|
yearMax : '',
|
|
yearMin : '',
|
|
summerAll : '',
|
|
summerThree : '',
|
|
summerRain : '',
|
|
winterAll : '',
|
|
winterSunnyAvg : '',
|
|
winterSunnyMax : '',
|
|
winterSunnyMin : '',
|
|
groundWaterAvg : '',
|
|
groundWaterSummer : '',
|
|
groundWaterWinter : '',
|
|
rdi : '',
|
|
rdiRain : '',
|
|
},
|
|
{
|
|
flowRate : '총인\n시설\n수질\n(mg/L)',
|
|
waterQlty : '총인설비\n방류(T-P)',
|
|
yearAvg : '',
|
|
yearMax : '',
|
|
yearMin : '',
|
|
summerAll : '',
|
|
summerThree : '',
|
|
summerRain : '',
|
|
winterAll : '',
|
|
winterSunnyAvg : '',
|
|
winterSunnyMax : '',
|
|
winterSunnyMin : '',
|
|
groundWaterAvg : '',
|
|
groundWaterSummer : '',
|
|
groundWaterWinter : '',
|
|
rdi : '',
|
|
rdiRain : '',
|
|
},
|
|
]
|
|
|
|
const chart_inflowRain : lineBarChartDataProps[] = [];
|
|
const chart_bodRain : lineBarChartDataProps[] = [];
|
|
const chart_inflTp : lineChartDataProps[] = [];
|
|
const chart_chongInTp : lineChartDataProps[] = [];
|
|
const chart_efflTp : lineChartDataProps[] = [];
|
|
const chart_inflTn : lineChartDataProps[] = [];
|
|
const chart_efflTn : lineChartDataProps[] = [];
|
|
const chart_inflBod : lineChartDataProps[] = [];
|
|
const chart_efflBod : lineChartDataProps[] = [];
|
|
|
|
const rainManageList : RainManageListProps[] = [];
|
|
|
|
const drainageEquipmentList : DrainageEquipmentListProps[] = [
|
|
{
|
|
part1 : '청천시청',
|
|
part2 : '청천시청',
|
|
nowSum : 101,
|
|
nowJoin : 102,
|
|
nowSep : 103,
|
|
stepOneSum : 104,
|
|
stepOneJoin : 105,
|
|
stepOneSep : 106,
|
|
stepTwoSum : 107,
|
|
stepTwoJoin : 108,
|
|
stepTwoSep : 109,
|
|
stepThreeSum : 110,
|
|
stepThreeJoin : 111,
|
|
stepThreeSep : 112,
|
|
stepFourSum : 113,
|
|
stepFourJoin : 114,
|
|
stepFourSep : 115,
|
|
etc : '1050',
|
|
}
|
|
];
|
|
|
|
/**====================================
|
|
* Store - api (데이터 호출)
|
|
====================================*/
|
|
/* 시설정보 및 운영현황 - 계획 */
|
|
const fetchFacilityPlan = async (targetYear : string | undefined, fcltyCd : string | undefined, set : (fn: (state: DashBoardType) => DashBoardType) => void) => {
|
|
try {
|
|
const res = await fetchPlanInfo(undefined, undefined, undefined, fcltyCd);
|
|
return res;
|
|
} catch (error) {
|
|
console.error('시설계획정보를 가져오는데 실패했습니다:', error);
|
|
set((state) => ({
|
|
...state,
|
|
PlanFclty : {
|
|
...state.PlanFclty,
|
|
isLoadingPlanFclty : false,
|
|
isLoadingOperationStatus : false
|
|
}
|
|
}));
|
|
return {data: [], count: 0};
|
|
}
|
|
};
|
|
|
|
/* 시설정보 및 운영현황 - 운영실태 */
|
|
const fetchOperationStatus = async (searchYear: string|undefined, fcltyCd: string|undefined) => {
|
|
try{
|
|
const url = '/dashBoard/mngInfo/' + (searchYear?searchYear:'2023') + '/' + (fcltyCd?fcltyCd:'');
|
|
const res = await getFetch('fo', url);
|
|
return { data: res.data, count: res.count }
|
|
} catch (error) {
|
|
console.error('운영실태 데이터를 가져오는데 실패했습니다:', error);
|
|
return { data: [], count: 0 };
|
|
}
|
|
}
|
|
|
|
// 주요그래프 데이터
|
|
const fetchMainGraph = async (searchYear: string|undefined, fcltyCd: string|undefined) => {
|
|
try {
|
|
const url = '/fclt/qlty/hist/' + (searchYear?searchYear:'2023') + '/' + (fcltyCd?fcltyCd:'11680PB001R');
|
|
const res = await getFetch('fo', url);
|
|
return { data: res.data, count: res.count }
|
|
} catch (error) {
|
|
console.error('주요그래프 데이터를 가져오는데 실패했습니다:', error);
|
|
return { data: [], count: 0 };
|
|
}
|
|
}
|
|
|
|
// 수질 데이터 청천시, 강우시 재계산
|
|
/* const calcWaterQltyData = async (data: any[], searchYear : string|undefined, fcltyCd : string|undefined) => {
|
|
let orgData = data;
|
|
console.log('orgData', orgData);
|
|
await fetchMainGraph(searchYear, fcltyCd).then(res => {
|
|
if(res.data.count > 0) {
|
|
const clone = (arr: any[]) => arr?.map(v => ({ ...v })) ?? [];
|
|
const qltyData = res.data;
|
|
const qltyChungchunData = CalcRainEffect(clone(qltyData), 'SUNNY', 'RAIN_DAY');
|
|
const qltyRainData = CalcRainEffect(clone(qltyData), 'RAIN', 'RAIN_DAY');
|
|
|
|
// 청천시 변수
|
|
let chungchunAllDay = 0;
|
|
let chungchunSummerDay = 0;
|
|
let chungchunWinterDay = 0;
|
|
|
|
let chungchunInflBodAvg = 0;
|
|
let chungchunInflTnAvg = 0;
|
|
let chungchunInflTpAvg = 0;
|
|
let chungchunInflBodMax = 0;
|
|
let chungchunInflTnMax= 0;
|
|
let chungchunInflTpMax = 0;
|
|
let chungchunInflBodMin = 99999999;
|
|
let chungchunInflTnMin = 99999999;
|
|
let chungchunInflTpMin = 99999999;
|
|
|
|
let chungchunEfflBodAvg = 0;
|
|
let chungchunEfflTnAvg = 0;
|
|
let chungchunEfflTpAvg = 0;
|
|
let chungchunEfflBodMax = 0;
|
|
let chungchunEfflTnMax= 0;
|
|
let chungchunEfflTpMax = 0;
|
|
let chungchunEfflBodMin = 99999999;
|
|
let chungchunEfflTnMin = 99999999;
|
|
let chungchunEfflTpMin = 99999999;
|
|
|
|
// 강우시 변수
|
|
let rainAllDay = 0;
|
|
let rainSummerDay = 0;
|
|
let rainWinterDay = 0;
|
|
|
|
let rainInflBodAvg = 0;
|
|
let rainInflTnAvg = 0;
|
|
let rainInflTpAvg = 0;
|
|
let rainInflBodMax = 0;
|
|
let rainInflTnMax= 0;
|
|
let rainInflTpMax = 0;
|
|
let rainInflBodMin = 99999999;
|
|
let rainInflTnMin = 99999999;
|
|
let rainInflTpMin = 99999999;
|
|
|
|
const nullToZero = (value: any) => {
|
|
return value === null || value === undefined || value === '' ? 0 : Number(value);
|
|
};
|
|
|
|
// 청천시
|
|
qltyChungchunData.forEach((item: any) => {
|
|
chungchunAllDay += 1;
|
|
const month = item.msrdt.substring(4, 6); // 월 추출
|
|
if(month === '01' || month === '02'){
|
|
chungchunWinterDay += 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);
|
|
|
|
chungchunInflBodAvg += inflbod;
|
|
chungchunInflTnAvg += infltn;
|
|
chungchunInflTpAvg += infltp;
|
|
chungchunEfflBodAvg += effbod;
|
|
chungchunEfflTnAvg += efftn;
|
|
chungchunEfflTpAvg += efftp;
|
|
|
|
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(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;
|
|
}else if(month === '06' || month === '07' || month === '08'){
|
|
chungchunSummerDay += 1;
|
|
}
|
|
});
|
|
|
|
orgData[5].winterSunnyAvg = chungchunAllDay > 0 ? '999' : 0;
|
|
|
|
// 강우시
|
|
qltyRainData.forEach((item: any) => {
|
|
const month = item.msrdt.substring(4, 6); // 월 추출
|
|
if(month === '01' || month === '02'){
|
|
}else if(month === '06' || month === '07' || month === '08'){
|
|
}
|
|
});
|
|
|
|
return orgData;
|
|
} else {
|
|
return orgData;
|
|
}
|
|
});
|
|
}; */
|
|
|
|
/**====================================
|
|
* Store - action
|
|
====================================*/
|
|
export type DashBoardActions = {
|
|
initializeDashBoardData(): Promise<void>;
|
|
/** 시설정보 및 운영현황 - 계획정보 */
|
|
searchPlanInfo(targetYear: string, fcltyCd: string): Promise<void>;
|
|
/** 시설정보 및 운영현황 - 운영실태 */
|
|
searchOperationStatus(isExcel: boolean, searchYear: string, fcltyCd: string): Promise<void>;
|
|
/** 주요그래프 데이터 */
|
|
searchMainGraph(searchYear: string, fcltyCd: string): Promise<void>;
|
|
/**강우일 운영현황 */
|
|
searchRainManage(searchYear: string, fcltyCd: string, isExcel: boolean): Promise<void>;
|
|
}
|
|
|
|
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[];
|
|
isLoadingMainGraph : boolean;
|
|
},
|
|
|
|
RainManage : {
|
|
isInit : boolean;
|
|
upHeadListRainManage : TableUpperProps[];
|
|
rainManageList : RainManageListProps[];
|
|
excelList : RainManageExcelType[];
|
|
isLoadingRainManage : boolean;
|
|
},
|
|
|
|
DrainageEquipment : {
|
|
isInit : boolean;
|
|
upHeadListDrainageEquipment : TableUpperProps[];
|
|
drainageEquipmentList : DrainageEquipmentListProps[];
|
|
drainageEquipmentExcelList : DrainageEquipmentExcelType[];
|
|
}
|
|
}
|
|
|
|
export type DashBoardStore = DashBoardType & DashBoardActions;
|
|
|
|
export const dashBoardInitState:DashBoardType = {
|
|
DashboardMain: {
|
|
isInit: false,
|
|
topLabelArray: DashBoardTopLabelArray,
|
|
},
|
|
|
|
FcltyMain : {
|
|
isInit : false,
|
|
upHeadListFclty : upHeadListFclty,
|
|
fcltyList : fcltyList,
|
|
},
|
|
|
|
PlanFclty : {
|
|
isInit : true,
|
|
planYearList : planYearList,
|
|
upHeadListPlanFclty : upHeadListPlanFclty,
|
|
planFcltyList : planFcltyList,
|
|
waterUsage1 : 0,
|
|
waterUsage2 : 0,
|
|
waterUsage3 : 0,
|
|
isLoadingPlanFclty : false,
|
|
},
|
|
|
|
OperationStatus : {
|
|
isInit : false,
|
|
upHeadListOperationStatus : upHeadListOperationStatus,
|
|
operationalStatusList : operationalStatusList,
|
|
isLoadingOperationStatus : false,
|
|
},
|
|
|
|
MainGraph : {
|
|
isInit : false,
|
|
chart_inflowRain : chart_inflowRain,
|
|
chart_bodRain : chart_bodRain,
|
|
chart_inflTp : chart_inflTp,
|
|
chart_chongInTp : chart_chongInTp,
|
|
chart_efflTp : chart_efflTp,
|
|
chart_inflTn : chart_inflTn,
|
|
chart_efflTn : chart_efflTn,
|
|
chart_inflBod : chart_inflBod,
|
|
chart_efflBod : chart_efflBod,
|
|
isLoadingMainGraph : false,
|
|
},
|
|
|
|
RainManage : {
|
|
isInit : false,
|
|
upHeadListRainManage : upHeadListRainManage,
|
|
rainManageList : rainManageList,
|
|
excelList : [],
|
|
isLoadingRainManage : false,
|
|
},
|
|
|
|
DrainageEquipment : {
|
|
isInit : false,
|
|
upHeadListDrainageEquipment : upHeadListDrainageEquipment,
|
|
drainageEquipmentList : drainageEquipmentList,
|
|
drainageEquipmentExcelList : []
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 데이터 폼 포맷설정
|
|
*/
|
|
export const dataFormSettingPlan=(item : planFcltyListProps, decmials : number) => {
|
|
DataForm({ type: 'float'+decmials, column: 'provisionalApproval', item: item as unknown as Record<string, unknown> });
|
|
DataForm({ type: 'float'+decmials, column: 'now', item: item as unknown as Record<string, unknown>});
|
|
DataForm({ type: 'float'+decmials, column: 'stepOne', item: item as unknown as Record<string, unknown>});
|
|
DataForm({ type: 'float'+decmials, column: 'stepTwo', item: item as unknown as Record<string, unknown>});
|
|
DataForm({ type: 'float'+decmials, column: 'stepThree', item: item as unknown as Record<string, unknown>});
|
|
DataForm({ type: 'float'+decmials, column: 'stepFour', item: item as unknown as Record<string, unknown>});
|
|
}
|
|
|
|
export const dataFormSetting=(item : OperationalStatusListProps)=> {
|
|
DataForm({ type: 'float0', column: 'yearAvg', item: item as unknown as Record<string, unknown> });
|
|
DataForm({ type: 'float0', column: 'yearMax', item: item as unknown as Record<string, unknown>});
|
|
DataForm({ type: 'float0', column: 'yearMin', item: item as unknown as Record<string, unknown>});
|
|
DataForm({ type: 'float0', column: 'summerAll', item: item as unknown as Record<string, unknown>});
|
|
DataForm({ type: 'float0', column: 'summerThree', item: item as unknown as Record<string, unknown>});
|
|
DataForm({ type: 'float0', column: 'summerRain', item: item as unknown as Record<string, unknown>});
|
|
DataForm({ type: 'float0', column: 'winterAll', item: item as unknown as Record<string, unknown>});
|
|
DataForm({ type: 'float0', column: 'winterSunnyAvg', item: item as unknown as Record<string, unknown>});
|
|
DataForm({ type: 'float0', column: 'winterSunnyMax', item: item as unknown as Record<string, unknown>});
|
|
DataForm({ type: 'float0', column: 'winterSunnyMin', item: item as unknown as Record<string, unknown>});
|
|
DataForm({ type: 'float0', column: 'groundWaterAvg', item: item as unknown as Record<string, unknown>});
|
|
DataForm({ type: 'float0', column: 'groundWaterSummer', item: item as unknown as Record<string, unknown>});
|
|
DataForm({ type: 'float0', column: 'groundWaterWinter', item: item as unknown as Record<string, unknown>});
|
|
DataForm({ type: 'float0', column: 'rainRate', item: item as unknown as Record<string, unknown>});
|
|
DataForm({ type: 'float0', column: 'rdi', item: item as unknown as Record<string, unknown>});
|
|
};
|
|
|
|
export const dataFormSettingWqlty=(item : OperationalStatusListProps)=> {
|
|
DataForm({ type: 'float1', column: 'yearAvg', item: item as unknown as Record<string, unknown> });
|
|
DataForm({ type: 'float1', column: 'yearMax', item: item as unknown as Record<string, unknown>});
|
|
DataForm({ type: 'float1', column: 'yearMin', item: item as unknown as Record<string, unknown>});
|
|
DataForm({ type: 'float1', column: 'summerAll', item: item as unknown as Record<string, unknown>});
|
|
DataForm({ type: 'float1', column: 'summerThree', item: item as unknown as Record<string, unknown>});
|
|
DataForm({ type: 'float1', column: 'summerRain', item: item as unknown as Record<string, unknown>});
|
|
DataForm({ type: 'float1', column: 'winterAll', item: item as unknown as Record<string, unknown>});
|
|
DataForm({ type: 'float1', column: 'winterSunnyAvg', item: item as unknown as Record<string, unknown>});
|
|
DataForm({ type: 'float1', column: 'winterSunnyMax', item: item as unknown as Record<string, unknown>});
|
|
DataForm({ type: 'float1', column: 'winterSunnyMin', item: item as unknown as Record<string, unknown>});
|
|
DataForm({ type: 'float1', column: 'groundWaterAvg', item: item as unknown as Record<string, unknown>});
|
|
DataForm({ type: 'float1', column: 'groundWaterSummer', item: item as unknown as Record<string, unknown>});
|
|
DataForm({ type: 'float1', column: 'groundWaterWinter', item: item as unknown as Record<string, unknown>});
|
|
DataForm({ type: 'float1', column: 'rainRate', item: item as unknown as Record<string, unknown>});
|
|
DataForm({ type: 'float1', column: 'rdi', item: item as unknown as Record<string, unknown>});
|
|
};
|
|
|
|
const changeValue=(operationalStatus, data, keyTxt = 'INFL_AMNT')=>{
|
|
operationalStatus.yearAvg = data.yearData ? (keyTxt.includes('_TP') || keyTxt.includes("_TN"))? data.yearData?Number(Math.round(data.yearData['AVG_'+keyTxt] * 1000) / 1000).toFixed(3).toString():'': data.yearData['AVG_'+keyTxt] : '';
|
|
operationalStatus.yearMax = data.yearData ? (keyTxt.includes('_TP') || keyTxt.includes("_TN"))? data.yearData?Number(Math.round(data.yearData['MAX_'+keyTxt] * 1000) / 1000).toFixed(3).toString():'': data.yearData['MAX_'+keyTxt] : '';
|
|
operationalStatus.yearMin = data.yearData ? (keyTxt.includes('_TP') || keyTxt.includes("_TN"))? data.yearData?Number(Math.round(data.yearData['MIN_'+keyTxt] * 1000) / 1000).toFixed(3).toString():'': data.yearData['MIN_'+keyTxt] : '';
|
|
// 여름
|
|
operationalStatus.summerAll = data.summer ? (keyTxt.includes('_TP') || keyTxt.includes("_TN"))? data.summer?Number(Math.round(data.summer['AVG_'+keyTxt] * 1000) / 1000).toFixed(3).toString():'': data.summer['AVG_'+keyTxt] : '';
|
|
operationalStatus.summerThree = data.summerRainy ? (keyTxt.includes('_TP') || keyTxt.includes("_TN"))? data.summerRainy?Number(Math.round(data.summerRainy["AVG_" + keyTxt] * 1000) / 1000).toFixed(3).toString():'': data.summerRainy["AVG_" + keyTxt] : '';
|
|
operationalStatus.summerRain = data.summerSunny ? (keyTxt.includes('_TP') || keyTxt.includes("_TN"))? data.summerSunny?Number(Math.round(data.summerSunny["AVG_" + keyTxt] * 1000) / 1000).toFixed(3).toString():'': data.summerSunny["AVG_" + keyTxt] : '';
|
|
// 겨울
|
|
operationalStatus.winterAll = data.winter ? (keyTxt.includes('_TP') || keyTxt.includes("_TN"))? data.winter?Number(Math.round(data.winter["AVG_" + keyTxt] * 1000) / 1000).toFixed(3).toString():'': data.winter["AVG_" + keyTxt] : '';
|
|
operationalStatus.winterSunnyMin = data.winterSunny ? (keyTxt.includes('_TP') || keyTxt.includes("_TN"))? data.winterSunny?Number(Math.round(data.winterSunny["MIN_" + keyTxt] * 1000) / 1000).toFixed(3).toString():'': data.winterSunny["MIN_" + keyTxt] : '';
|
|
operationalStatus.winterSunnyAvg = data.winterSunny ? (keyTxt.includes('_TP') || keyTxt.includes("_TN"))? data.winterSunny?Number(Math.round(data.winterSunny["AVG_" + keyTxt] * 1000) / 1000).toFixed(3).toString():'': data.winterSunny["AVG_" + keyTxt] : '';
|
|
operationalStatus.winterSunnyMax = data.winterSunny ? (keyTxt.includes('_TP') || keyTxt.includes("_TN"))? data.winterSunny?Number(Math.round(data.winterSunny["MAX_" + keyTxt] * 1000) / 1000).toFixed(3).toString():'': data.winterSunny["MAX_" + keyTxt] : '';
|
|
// 지하수
|
|
operationalStatus.groundWaterAvg = 10;
|
|
operationalStatus.groundWaterSummer = 11;
|
|
operationalStatus.groundWaterWinter = 12;
|
|
// 오염물질
|
|
// RDII 추정 = 하절기(6~8월) 중 최저 유입 BOD일때 유입유량 x ((동절기 청천시 유입BOD - 하절기(6~8월) 중 최저 유입BOD) / (동절기 청천시 유입BOD))
|
|
const summerLowFlow = data.summerBod && data.summerBod.INFL_AMNT && data.summerBod.INFL_AMNT != 'null' ? Number(data.summerBod.INFL_AMNT) : 0;
|
|
const winterAvgBod = data.winterSunny && data.winterSunny.AVG_INFL_ASSCT_BFR_WQLT_BOD && data.winterSunny.AVG_INFL_ASSCT_BFR_WQLT_BOD != 'null' ? Number(data.winterSunny.AVG_INFL_ASSCT_BFR_WQLT_BOD) : 0;
|
|
const summerLowBod = data.summerBod && data.summerBod.MIN_INFL_ASSCT_BFR_WQLT_BOD && data.summerBod.MIN_INFL_ASSCT_BFR_WQLT_BOD != 'null' ? Number(data.summerBod.MIN_INFL_ASSCT_BFR_WQLT_BOD) : 0;
|
|
const summerLowRain = data.summerBod && data.summerBod.INFO_RN_DAY && data.summerBod.INFO_RN_DAY != 'null' ? Number(data.summerBod.INFO_RN_DAY) : 0;
|
|
operationalStatus.rdi = winterAvgBod === 0 ? 0 : 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 RtnFlowType = {
|
|
inflAmnt: string | number;
|
|
infoRnDay: string | number;
|
|
bscFctCd: string;
|
|
msrDt: string;
|
|
}
|
|
|
|
type RtnFlowResponse = {
|
|
data: RtnFlowType[];
|
|
count: number;
|
|
}
|
|
|
|
const searchWaterUsage = async (searchYear: string, fcltyCd: string) => {
|
|
const waterUsage = [0, 0, 0];
|
|
|
|
for (let i = 0; i < 3; i++) {
|
|
try {
|
|
const res = await getFetch('fo', '/fclt/flow/' + fcltyCd + '/' + (Number(searchYear)-i)) as RtnFlowResponse;
|
|
let totWaterUsage = 0;
|
|
|
|
if (res && res.data && Array.isArray(res.data)) {
|
|
res.data.forEach((item: RtnFlowType) => {
|
|
totWaterUsage += Number(item.inflAmnt);
|
|
});
|
|
|
|
if (res.count > 0) {
|
|
const avg = totWaterUsage / res.count;
|
|
waterUsage[i] = parseFloat((avg * 0.65).toFixed(2));
|
|
}
|
|
}
|
|
} catch (error) {
|
|
console.error(`Error fetching water usage for year ${Number(searchYear)-i}:`, error);
|
|
waterUsage[i] = 0;
|
|
}
|
|
}
|
|
|
|
return waterUsage;
|
|
}
|
|
|
|
export const dashBoardReducer:(set:(fn: (state: DashBoardType) => DashBoardType) => void)=>DashBoardActions=(set: (fn: (state: DashBoardType) => DashBoardType) => void) => {
|
|
return {
|
|
initializeDashBoardData: async () => {
|
|
set((state: DashBoardType) => ({
|
|
...state,
|
|
DashboardMain: {
|
|
...state.DashboardMain,
|
|
isInit: true,
|
|
}
|
|
}));
|
|
},
|
|
|
|
/** 시설정보 및 운영현황 - 계획정보 */
|
|
searchPlanInfo : async (targetYear: string, fcltyCd: string) => {
|
|
set((state: DashBoardType) => ({
|
|
...state,
|
|
PlanFclty: {
|
|
...state.PlanFclty,
|
|
isLoadingPlanFclty: true,
|
|
},
|
|
}));
|
|
let waterUsage = [0, 0, 0];
|
|
waterUsage = await searchWaterUsage(targetYear, fcltyCd);
|
|
|
|
set((state: DashBoardType) => ({
|
|
...state,
|
|
PlanFclty : {
|
|
...state.PlanFclty,
|
|
waterUsage1 : waterUsage[0] || 0,
|
|
waterUsage2 : waterUsage[1] || 0,
|
|
waterUsage3 : waterUsage[2] || 0,
|
|
},
|
|
}));
|
|
|
|
const res = await fetchFacilityPlan(targetYear, fcltyCd, set);
|
|
|
|
let minDiff=9999999;
|
|
let minIndex;
|
|
res.forEach((el:any, idx) => {
|
|
if(minDiff>Math.abs(Number(targetYear) - Number(el.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:'';
|
|
el.now = rtnPlanData?rtnPlanData.planSwageQntSum:'';
|
|
el.stepOne = rtnPlanData?rtnPlanData.planSwageQntSumDc1:'';
|
|
el.stepTwo = rtnPlanData?rtnPlanData.planSwageQntSumDc2:'';
|
|
el.stepThree = rtnPlanData?rtnPlanData.planSwageQntSumDc3:'';
|
|
el.stepFour = rtnPlanData?rtnPlanData.planSwageQntSumDc4:'';
|
|
}
|
|
if(index === 1){
|
|
el.provisionalApproval = rtnPlanData?rtnPlanData.swtrmtPpltnCntDt4:'';
|
|
el.now = rtnPlanData?rtnPlanData.swtrmtPpltnCnt:'';
|
|
el.stepOne = rtnPlanData?rtnPlanData.swtrmtPpltnCntDc1:'';
|
|
el.stepTwo = rtnPlanData?rtnPlanData.swtrmtPpltnCntDc2:'';
|
|
el.stepThree = rtnPlanData?rtnPlanData.swtrmtPpltnCntDc3:'';
|
|
el.stepFour = rtnPlanData?rtnPlanData.swtrmtPpltnCntDc4:'';
|
|
}
|
|
if(index === 2){
|
|
el.provisionalApproval = rtnPlanData?rtnPlanData.swtrmtZoneAreaDt4:'';
|
|
el.now = rtnPlanData?rtnPlanData.swtrmtZoneArea:'';
|
|
el.stepOne = rtnPlanData?rtnPlanData.swtrmtZoneAreaDc1:'';
|
|
el.stepTwo = rtnPlanData?rtnPlanData.swtrmtZoneAreaDc2:'';
|
|
el.stepThree = rtnPlanData?rtnPlanData.swtrmtZoneAreaDc3:'';
|
|
el.stepFour = rtnPlanData?rtnPlanData.swtrmtZoneAreaDc4:'';
|
|
}
|
|
if(index === 4){
|
|
el.provisionalApproval = rtnPlanData?rtnPlanData.ugwtUseSum:'';
|
|
}
|
|
|
|
if(index === 2){
|
|
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) => {
|
|
set((state: DashBoardType) => ({
|
|
...state,
|
|
OperationStatus: {
|
|
...state.OperationStatus,
|
|
isLoadingOperationStatus: true,
|
|
},
|
|
}));
|
|
const res = await fetchOperationStatus(searchYear, fcltyCd);
|
|
const data = res.data;
|
|
|
|
let yearMaxSumFlow = 1;
|
|
let yearMinSumFlow = 1;
|
|
let yearAvgSumFlow = 1;
|
|
let summerAll = 1;
|
|
let summerThree = 1;
|
|
let summerRain = 1;
|
|
let winterAll = 1;
|
|
let winterSunnyMin = 1;
|
|
let winterSunnyAvg = 1;
|
|
let winterSunnyMax = 1;
|
|
|
|
// 최대, 최소 총 유입량 (1년 하루 합계의 최대, 최소)
|
|
|
|
// 하절기 청천시, 강우시 재계산 리턴값
|
|
let summerChungchunFlow = 1
|
|
let summerChungchunReturnAmnt = 1;
|
|
let summerChungchunEfflAmnt = 1;
|
|
let summerRainInflAmnt = 1;
|
|
let summerRainReturnAmnt = 1;
|
|
let summerRainEfflAmnt = 1;
|
|
|
|
// 동절기 청천시 최대, 최소, 평균 리턴값
|
|
let winterChungchunFlowAvg = 1 ;
|
|
let winterChungchunFlowMax = 1 ;
|
|
let winterChungchunFlowMin = 1 ;
|
|
let winterChungchunReturnAvg = 1 ;
|
|
let winterChungchunReturnMax = 1 ;
|
|
let winterChungchunReturnMin = 1 ;
|
|
let winterChungchunEfflAvg = 1 ;
|
|
let winterChungchunEfflMax = 1 ;
|
|
let winterChungchunEfflMin = 1 ;
|
|
|
|
if(data && operationalStatusList){
|
|
// 유량 - 유입
|
|
if (operationalStatusList?.[0]) {
|
|
// 연간
|
|
const yearAvg = data.yearData===null ? '' : (
|
|
(data.yearData.AVG_INFL_AMNT?data.yearData.AVG_INFL_AMNT:0) +
|
|
(data.yearData.AVG_SUM_FLOW?data.yearData.AVG_SUM_FLOW:0) +
|
|
(data.yearData.AVG_RETURN_AMNT?data.yearData.AVG_RETURN_AMNT:0)
|
|
);
|
|
const yearMax = data.yearData===null ? '' : (
|
|
(data.yearData.MAX_INFL_AMNT?data.yearData.MAX_INFL_AMNT:0) +
|
|
(data.yearData.MAX_SUM_FLOW?data.yearData.MAX_SUM_FLOW:0) +
|
|
(data.yearData.MAX_RETURN_AMNT?data.yearData.MAX_RETURN_AMNT:0)
|
|
);
|
|
const yearMin = data.yearData===null ? '' : (
|
|
(data.yearData.MIN_INFL_AMNT?data.yearData.MIN_INFL_AMNT:0) +
|
|
(data.yearData.MIN_SUM_FLOW?data.yearData.MIN_SUM_FLOW:0) +
|
|
(data.yearData.MIN_RETURN_AMNT?data.yearData.MIN_RETURN_AMNT:0)
|
|
);
|
|
|
|
operationalStatusList[0].yearAvg = yearAvg;
|
|
operationalStatusList[0].yearMax = yearMax;
|
|
operationalStatusList[0].yearMin = yearMin;
|
|
// 여름
|
|
operationalStatusList[0].summerAll = data.summer === null ? '' : (
|
|
(data.summer.AVG_INFL_AMNT ? data.summer.AVG_INFL_AMNT : 0) +
|
|
(data.summer.AVG_SUM_FLOW ? data.summer.AVG_SUM_FLOW : 0)
|
|
);
|
|
operationalStatusList[0].summerThree = data.summerRainy === null ? '' : (
|
|
(data.summerRainy.AVG_INFL_AMNT ? data.summerRainy.AVG_INFL_AMNT : 0) +
|
|
(data.summerRainy.AVG_SUM_FLOW ? data.summerRainy.AVG_SUM_FLOW : 0)
|
|
);
|
|
operationalStatusList[0].summerRain = data.summerSunny === null ? '' : (
|
|
(data.summerSunny.AVG_INFL_AMNT ? data.summerSunny.AVG_INFL_AMNT : 0) +
|
|
(data.summerSunny.AVG_SUM_FLOW ? data.summerSunny.AVG_SUM_FLOW : 0)
|
|
);
|
|
// 겨울
|
|
operationalStatusList[0].winterAll = data.winter === null ? '' : (
|
|
(data.winter.AVG_INFL_AMNT ? data.winter.AVG_INFL_AMNT : 0) +
|
|
(data.winter.AVG_SUM_FLOW ? data.winter.AVG_SUM_FLOW : 0) +
|
|
(data.winter.AVG_TP_INFL_WQLT_TP ? data.winter.AVG_TP_INFL_WQLT_TP : 0)
|
|
);
|
|
operationalStatusList[0].winterSunnyMin = data.winterSunny === null ? '' : (
|
|
(data.winterSunny.MIN_INFL_AMNT ? data.winterSunny.MIN_INFL_AMNT : 0) +
|
|
(data.winterSunny.MIN_SUM_FLOW ? data.winterSunny.MIN_SUM_FLOW : 0) +
|
|
(data.winterSunny.MIN_TP_INFL_WQLT_TP ? data.winterSunny.MIN_TP_INFL_WQLT_TP : 0)
|
|
);
|
|
operationalStatusList[0].winterSunnyAvg = data.winterSunny === null ? '' : (
|
|
(data.winterSunny.AVG_INFL_AMNT ? data.winterSunny.AVG_INFL_AMNT : 0) +
|
|
(data.winterSunny.AVG_SUM_FLOW ? data.winterSunny.AVG_SUM_FLOW : 0) +
|
|
(data.winterSunny.AVG_TP_INFL_WQLT_TP ? data.winterSunny.AVG_TP_INFL_WQLT_TP : 0)
|
|
);
|
|
operationalStatusList[0].winterSunnyMax = data.winterSunny === null ? '' : (
|
|
(data.winterSunny.MAX_INFL_AMNT ? data.winterSunny.MAX_INFL_AMNT : 0) +
|
|
(data.winterSunny.MAX_SUM_FLOW ? data.winterSunny.MAX_SUM_FLOW : 0) +
|
|
(data.winterSunny.MAX_TP_INFL_WQLT_TP ? data.winterSunny.MAX_TP_INFL_WQLT_TP : 0)
|
|
);
|
|
// 연계처리수
|
|
let yearDay = 0;
|
|
let summerDay = 0;
|
|
let winterDay = 0;
|
|
let summerRainDay = 0;
|
|
let summerChungchunDay = 0;
|
|
let winterChungchuDay = 0;
|
|
|
|
let totFlowMax = 0;
|
|
let totFlowMin = 9999999;
|
|
|
|
let yearSumFlow = 0;
|
|
let maxYearSumFlow = 0;
|
|
let minYearSumFlow = 9999999;
|
|
let summerSumFlow = 0;
|
|
let summerChungchunSumFlow = 0;
|
|
let summerRainDaySumFlow = 0;
|
|
let summerRainDayFlow = 0;
|
|
let summerRainDayReturnFlow = 0;
|
|
let summerRainDayEfflFlow = 0;
|
|
|
|
let winterSumFlow = 0;
|
|
let winterChungchunSumFlow = 0;
|
|
let minWinterChungchunSumFlow = 9999999;
|
|
let maxWinterChungchunSumFlow = 0;
|
|
|
|
// 연계처리수,지하수유입량
|
|
const bscFctCd = fcltyCd;
|
|
const res2 = await fetchFlowRateModalList(bscFctCd, searchYear);
|
|
yearDay = res2.data?res2.data.length:1;
|
|
res2.data.forEach((item: any) => {
|
|
yearSumFlow += item.sumFlow && item.sumFlow !== 'x' ? Number(item.sumFlow.toString().trim()) : 0;
|
|
if(maxYearSumFlow < (item.sumFlow && item.sumFlow !== 'x' ? Number(item.sumFlow.toString().trim()) : 0)) {
|
|
maxYearSumFlow = item.sumFlow && item.sumFlow !== 'x' ? Number(item.sumFlow.toString().trim()) : 0;
|
|
}
|
|
if(minYearSumFlow > (item.sumFlow && item.sumFlow !== 'x' ? Number(item.sumFlow.toString().trim()) : 0)) {
|
|
minYearSumFlow = item.sumFlow && item.sumFlow !== 'x' ? Number(item.sumFlow.toString().trim()) : 0;
|
|
}
|
|
|
|
// 1년 최대 총 하수유입량
|
|
let totYearFlow = 0;
|
|
totYearFlow = (item.inflAmnt && item.inflAmnt !== 'x' ? Number(item.inflAmnt.toString().trim()) : 0) + (item.sumFlow && item.sumFlow !== 'x' ? Number(item.sumFlow.toString().trim()) : 0) + (item.returnAmnt && item.returnAmnt !== 'x' ? Number(item.returnAmnt.toString().trim()) : 0);
|
|
if(totFlowMax < totYearFlow) {
|
|
totFlowMax = totYearFlow;
|
|
}
|
|
if(totFlowMin > totYearFlow || totFlowMin === 0) {
|
|
totFlowMin = totYearFlow;
|
|
}
|
|
|
|
if(item.msrDt.substring(4,6) === '06' || item.msrDt.substring(4,6) === '07' || item.msrDt.substring(4,6) === '08') {
|
|
summerDay += 1;
|
|
summerSumFlow += item.sumFlow && item.sumFlow !== 'x' ? Number(item.sumFlow.toString().trim()) : 0;
|
|
} else if(item.msrDt.substring(4,6) === '01' || item.msrDt.substring(4,6) === '02') {
|
|
winterDay += 1;
|
|
winterSumFlow += item.sumFlow && item.sumFlow !== 'x' ? Number(item.sumFlow.toString().trim()) : 0;
|
|
}
|
|
});
|
|
|
|
const clone = (arr: any[]) => arr?.map(v => ({ ...v })) ?? [];
|
|
const calData = CalcRainEffect(clone(res2.data), 'SUNNY');
|
|
const calRainDate = CalcRainEffect(clone(res2.data), 'RAIN', 'RAIN_DAY');
|
|
|
|
// 지하수유입량 - 청천시 기준
|
|
let chungcunSumFlow = 0;
|
|
let sumSummerChungcunFlow = 0;
|
|
let sumWinterChungcunFlow = 0;
|
|
|
|
// 하절기 청천시 총인설비 반류수
|
|
let summerChungchunDayReturnAmnt = 0;
|
|
// 하절기 청천시 방류수
|
|
let summerChungchunDayEfflAmnt = 0;
|
|
|
|
// 동절기 총 유입량 최대, 최소
|
|
let winterChungchunTotalInflAmntMax = 0 ;
|
|
let winterChungchunTotalInflAmntMin = 9999999 ;
|
|
// 동절기 청천시 하수유입량 최대, 최소
|
|
let winterChungchunDayFlowMax = 0 ;
|
|
let winterChungchunDayFlowMin = 9999999 ;
|
|
// 동절기 청천시 총인반류수 최대, 최소, 평균
|
|
let winterChungchunDayReturnMax = 0 ;
|
|
let winterChungchunDayReturnMin = 9999999 ;
|
|
let winterChungchunDayReturnAvg = 0 ;
|
|
// 동절기 청천시 방류량 최대, 최소, 평균
|
|
let winterChungchunDayEfflMax = 0 ;
|
|
let winterChungchunDayEfflMin = 9999999 ;
|
|
let winterChungchunDayEfflAvg = 0;
|
|
|
|
// 하절기, 동절기 청천시 계산
|
|
calData.forEach((flowItem: any) => {
|
|
chungcunSumFlow += flowItem.inflAmnt && flowItem.inflAmnt !== 'x' ? Number(flowItem.inflAmnt.toString().trim()) : 0;
|
|
|
|
if(flowItem.msrDt.substring(4,6) ==='06' || flowItem.msrDt.substring(4,6) ==='07' || flowItem.msrDt.substring(4,6) ==='08'){
|
|
summerChungchunDay += 1;
|
|
summerChungchunSumFlow += flowItem.sumFlow && flowItem.sumFlow !== 'x' ? Number(flowItem.sumFlow.toString().trim()) : 0;
|
|
sumSummerChungcunFlow += flowItem.inflAmnt && flowItem.inflAmnt !== 'x' ? Number(flowItem.inflAmnt.toString().trim()) : 0;
|
|
summerChungchunDayReturnAmnt += flowItem.returnAmnt && flowItem.returnAmnt !== 'x' ? Number(flowItem.returnAmnt.toString().trim()) : 0;
|
|
summerChungchunDayEfflAmnt += flowItem.efflAmnt && flowItem.efflAmnt !== 'x' ? Number(flowItem.efflAmnt.toString().trim()) : 0;
|
|
|
|
}else if(flowItem.msrDt.substring(4,6) ==='01' || flowItem.msrDt.substring(4,6) ==='02'){
|
|
winterChungchuDay += 1;
|
|
winterChungchunSumFlow += flowItem.sumFlow && flowItem.sumFlow !== 'x' ? Number(flowItem.sumFlow.toString().trim()) : 0;
|
|
sumWinterChungcunFlow += flowItem.inflAmnt && flowItem.inflAmnt !== 'x' ? Number(flowItem.inflAmnt.toString().trim()) : 0;
|
|
winterChungchunDayReturnAvg += flowItem.returnAmnt && flowItem.returnAmnt !== 'x' ? Number(flowItem.returnAmnt.toString().trim()) : 0;
|
|
winterChungchunDayEfflAvg += flowItem.efflAmnt && flowItem.efflAmnt !== 'x' ? Number(flowItem.efflAmnt.toString().trim()) : 0;
|
|
|
|
let totWinterTotalInflAmnt = 0;
|
|
totWinterTotalInflAmnt = (flowItem.inflAmnt && flowItem.inflAmnt !== 'x' ? Number(flowItem.inflAmnt.toString().trim()) : 0) + (flowItem.sumFlow && flowItem.sumFlow !== 'x' ? Number(flowItem.sumFlow.toString().trim()) : 0) + (flowItem.returnAmnt && flowItem.returnAmnt !== 'x' ? Number(flowItem.returnAmnt.toString().trim()) : 0);
|
|
if(winterChungchunTotalInflAmntMax < totWinterTotalInflAmnt) {
|
|
winterChungchunTotalInflAmntMax = totWinterTotalInflAmnt;
|
|
}
|
|
if(winterChungchunTotalInflAmntMin > totWinterTotalInflAmnt || winterChungchunTotalInflAmntMin === 0) {
|
|
winterChungchunTotalInflAmntMin = totWinterTotalInflAmnt;
|
|
}
|
|
|
|
if(winterChungchunDayFlowMin > (flowItem.inflAmnt && flowItem.inflAmnt !== 'x' ? Number(flowItem.inflAmnt.toString().trim()) : 0)) {
|
|
winterChungchunDayFlowMin = flowItem.inflAmnt && flowItem.inflAmnt !== 'x' ? Number(flowItem.inflAmnt.toString().trim()) : 0;
|
|
}
|
|
if(winterChungchunDayFlowMax < (flowItem.inflAmnt && flowItem.inflAmnt !== 'x' ? Number(flowItem.inflAmnt.toString().trim()) : 0)) {
|
|
winterChungchunDayFlowMax = flowItem.inflAmnt && flowItem.inflAmnt !== 'x' ? Number(flowItem.inflAmnt.toString().trim()) : 0;
|
|
}
|
|
|
|
if(minWinterChungchunSumFlow > (flowItem.sumFlow && flowItem.sumFlow !== 'x' ? Number(flowItem.sumFlow.toString().trim()) : 0) ) {
|
|
minWinterChungchunSumFlow = flowItem.sumFlow && flowItem.sumFlow !== 'x' ? Number(flowItem.sumFlow.toString().trim()) : 0;
|
|
}
|
|
if(maxWinterChungchunSumFlow < (flowItem.sumFlow && flowItem.sumFlow !== 'x' ? Number(flowItem.sumFlow.toString().trim()) : 0)) {
|
|
maxWinterChungchunSumFlow = flowItem.sumFlow && flowItem.sumFlow !== 'x' ? Number(flowItem.sumFlow.toString().trim()) : 0;
|
|
}
|
|
|
|
if(winterChungchunDayReturnMin > (flowItem.returnAmnt && flowItem.returnAmnt !== 'x' ? Number(flowItem.returnAmnt.toString().trim()) : 0)) {
|
|
winterChungchunDayReturnMin = flowItem.returnAmnt && flowItem.returnAmnt !== 'x' ? Number(flowItem.returnAmnt.toString().trim()) : 0;
|
|
}
|
|
if(winterChungchunDayReturnMax < (flowItem.returnAmnt && flowItem.returnAmnt !== 'x' ? Number(flowItem.returnAmnt.toString().trim()) : 0)) {
|
|
winterChungchunDayReturnMax = flowItem.returnAmnt && flowItem.returnAmnt !== 'x' ? Number(flowItem.returnAmnt.toString().trim()) : 0;
|
|
}
|
|
|
|
if(winterChungchunDayEfflMin > (flowItem.efflAmnt && flowItem.efflAmnt !== 'x' ? Number(flowItem.efflAmnt.toString().trim()) : 0)) {
|
|
winterChungchunDayEfflMin = flowItem.efflAmnt && flowItem.efflAmnt !== 'x' ? Number(flowItem.efflAmnt.toString().trim()) : 0;
|
|
}
|
|
if(winterChungchunDayEfflMax < (flowItem.efflAmnt && flowItem.efflAmnt !== 'x' ? Number(flowItem.efflAmnt.toString().trim()) : 0)) {
|
|
winterChungchunDayEfflMax = flowItem.efflAmnt && flowItem.efflAmnt !== 'x' ? Number(flowItem.efflAmnt.toString().trim()) : 0;
|
|
}
|
|
}
|
|
});
|
|
|
|
// 하절기 강우시 계산
|
|
calRainDate.forEach((flowItem: any) => {
|
|
if(flowItem.msrDt.substring(4,6) === '06' || flowItem.msrDt.substring(4,6) === '07' || flowItem.msrDt.substring(4,6) === '08') {
|
|
summerRainDay += 1;
|
|
summerRainDaySumFlow += flowItem.sumFlow && flowItem.sumFlow !== 'x' ? Number(flowItem.sumFlow.toString().trim()) : 0;
|
|
summerRainDayFlow += flowItem.inflAmnt && flowItem.inflAmnt !== 'x' ? Number(flowItem.inflAmnt.toString().trim()) : 0;
|
|
summerRainDayReturnFlow += flowItem.returnAmnt && flowItem.returnAmnt !== 'x' ? Number(flowItem.returnAmnt.toString().trim()) : 0;
|
|
summerRainDayEfflFlow += flowItem.efflAmnt && flowItem.efflAmnt !== 'x' ? Number(flowItem.efflAmnt.toString().trim()) : 0;
|
|
}
|
|
});
|
|
|
|
// 연계처리수
|
|
yearAvgSumFlow = Number((yearSumFlow&&Number(yearSumFlow)!=0)?(yearSumFlow / yearDay):'');
|
|
yearMaxSumFlow = maxYearSumFlow;
|
|
yearMinSumFlow = minYearSumFlow;
|
|
summerAll = summerSumFlow&&Number(summerSumFlow)!=0?Number(summerSumFlow / summerDay):0
|
|
summerThree= summerRainDaySumFlow&&Number(summerRainDaySumFlow)!=0?Number(summerRainDaySumFlow / summerRainDay):0;
|
|
summerRain = summerChungchunSumFlow&&Number(summerChungchunSumFlow)!=0?Number(summerChungchunSumFlow / summerChungchunDay):0;
|
|
winterAll = winterSumFlow&&Number(winterSumFlow)!=0?Number(winterSumFlow / winterDay):0;
|
|
winterSunnyMin = minWinterChungchunSumFlow;
|
|
winterSunnyAvg = winterChungchunSumFlow&&Number(winterChungchunSumFlow)!=0?(winterChungchunSumFlow / winterChungchuDay):0;
|
|
winterSunnyMax = maxWinterChungchunSumFlow;
|
|
|
|
// 하절기 강우시 계산
|
|
// 하수유입량 (강우시)
|
|
summerRainInflAmnt = summerRainDayFlow&&Number(summerRainDayFlow)!=0?Number(summerRainDayFlow / summerRainDay):0;
|
|
// 총인설비방류수 (강우시)
|
|
summerRainReturnAmnt = summerRainDayReturnFlow&&Number(summerRainDayReturnFlow)!=0?Number(summerRainDayReturnFlow / summerRainDay):0;
|
|
// 방루량 (강우시)
|
|
summerRainEfflAmnt = summerRainDayEfflFlow&&summerRainDayEfflFlow!=0?summerRainDayEfflFlow / summerRainDay:0;
|
|
|
|
// 동절기 청천시 계산
|
|
// 하수유입량 (청천시) 평균
|
|
winterChungchunFlowAvg = sumWinterChungcunFlow&&Number(sumWinterChungcunFlow)!=0?(sumWinterChungcunFlow / winterChungchuDay):0;
|
|
// 총인반류수 (청천시) 평균
|
|
winterChungchunReturnAvg = winterChungchunDayReturnAvg&&Number(winterChungchunDayReturnAvg)!=0?(winterChungchunDayReturnAvg / winterChungchuDay):0;
|
|
// 방류량 (청천시) 평균
|
|
winterChungchunEfflAvg = winterChungchunDayEfflAvg&&Number(winterChungchunDayEfflAvg)!=0?(winterChungchunDayEfflAvg / winterChungchuDay):0;
|
|
// 하수유입량 (청천시) 최대
|
|
winterChungchunFlowMax = winterChungchunDayFlowMax;
|
|
// 총인반류수 (청천시) 최대
|
|
winterChungchunReturnMax = winterChungchunDayReturnMax;
|
|
// 방류량 (청천시) 최대
|
|
winterChungchunEfflMax = winterChungchunDayEfflMax;
|
|
// 하수유입량 (청천시) 최소
|
|
winterChungchunFlowMin = winterChungchunDayFlowMin;
|
|
// 총인반류수 (청천시) 최소
|
|
winterChungchunReturnMin = winterChungchunDayReturnMin;
|
|
// 방류량 (청천시) 최소
|
|
winterChungchunEfflMin = winterChungchunDayEfflMin
|
|
|
|
operationalStatusList[0].yearAvg = roundUp(Number(operationalStatusList[0].yearAvg), 0) + roundUp(yearAvgSumFlow, 0);
|
|
operationalStatusList[0].yearMax = roundUp(totFlowMax, 0); // + roundUp(yearMaxSumFlow, 0);
|
|
operationalStatusList[0].yearMin = roundUp(totFlowMin, 0);
|
|
operationalStatusList[0].summerAll = roundUp(Number(operationalStatusList[0].summerAll), 0) + roundUp(summerAll, 0);
|
|
operationalStatusList[0].summerThree = roundUp(Number(operationalStatusList[0].summerThree), 0) + roundUp(summerThree, 0);
|
|
operationalStatusList[0].summerRain = roundUp(Number(operationalStatusList[0].summerRain), 0) + roundUp(summerRain, 0);
|
|
operationalStatusList[0].winterAll = roundUp(Number(operationalStatusList[0].winterAll), 0) + roundUp(winterAll, 0);
|
|
operationalStatusList[0].winterSunnyMin = roundUp(winterChungchunTotalInflAmntMin, 0);
|
|
operationalStatusList[0].winterSunnyMax = roundUp(winterChungchunTotalInflAmntMax, 0);
|
|
operationalStatusList[0].winterSunnyAvg = roundUp(Number(operationalStatusList[0].winterSunnyAvg), 0) + roundUp(winterSunnyAvg, 0);
|
|
|
|
// 지하수유입량
|
|
const usage = chungcunSumFlow / calData.length;
|
|
const summerUsage = sumSummerChungcunFlow / summerChungchunDay;
|
|
const winterUsage = sumWinterChungcunFlow / winterChungchuDay;
|
|
|
|
// 임시 계산변수값들 메인에 대입
|
|
summerChungchunFlow = summerUsage;
|
|
summerChungchunReturnAmnt = summerChungchunDayReturnAmnt / summerChungchunDay;
|
|
summerChungchunEfflAmnt = summerChungchunDayEfflAmnt / summerChungchunDay;
|
|
|
|
operationalStatusList[0].groundWaterAvg = Math.round((usage-(usage*0.65*OSU_PERCENT)) * 100) / 100;
|
|
operationalStatusList[0].groundWaterSummer = Math.round((summerUsage-(summerUsage*0.65*OSU_PERCENT)) * 100) / 100;
|
|
operationalStatusList[0].groundWaterWinter = Math.round((winterUsage-(winterUsage*0.65*OSU_PERCENT)) * 100) / 100;
|
|
|
|
//operationalStatusList[0].groundWaterAvg = calData.length === 0 ? '' : Number(calData[0].inflAmnt) - (Number(calData[0].inflAmnt)*0.65*0.8);
|
|
//operationalStatusList[0].groundWaterSummer = calData.length === 0 ? '' : Number(calData[0].inflAmnt) - (Number(calData[0].inflAmnt)*0.65*0.8);
|
|
//operationalStatusList[0].groundWaterWinter = calData.length === 0 ? '' : Number(calData[0].inflAmnt) - (Number(calData[0].inflAmnt)*0.65*0.8);
|
|
|
|
// 오염물질
|
|
// RDII 추정 = 하절기(6~8월) 중 최저 유입 BOD일때 유입유량 x ((동절기 청천시 유입BOD - 하절기(6~8월) 중 최저 유입BOD) / (동절기 청천시 유입BOD))
|
|
const summerLowFlow = data.summerBod&&data.summerBod.INFL_AMNT&&data.summerBod.INFL_AMNT!='null'?Number(data.summerBod.INFL_AMNT):0;
|
|
const winterAvgBod = data.winterSunny&&data.winterSunny.AVG_INFL_ASSCT_BFR_WQLT_BOD&&data.winterSunny.AVG_INFL_ASSCT_BFR_WQLT_BOD!='null'?Number(data.winterSunny.AVG_INFL_ASSCT_BFR_WQLT_BOD):0;
|
|
const summerLowBod = data.summerBod&&data.summerBod.MIN_INFL_ASSCT_BFR_WQLT_BOD&&data.summerBod.MIN_INFL_ASSCT_BFR_WQLT_BOD!='null'?Number(data.summerBod.MIN_INFL_ASSCT_BFR_WQLT_BOD):0;
|
|
const summerLowRain = data.summerBod&&data.summerBod.INFO_RN_DAY&&data.summerBod.INFO_RN_DAY!='null'?Number(data.summerBod.INFO_RN_DAY):0;
|
|
operationalStatusList[0].rdi = winterAvgBod===0?0:roundUp(summerLowFlow * ((winterAvgBod - summerLowBod) / winterAvgBod), 2);
|
|
operationalStatusList[0].rdiRain = summerLowRain;
|
|
}
|
|
|
|
if(operationalStatusList[0] && operationalStatusList[7]){
|
|
operationalStatusList[7].groundWaterAvg = operationalStatusList[0].groundWaterAvg === null ? '' : data.yearData && data.yearData.AVG_INFL_AMNT === 0 ? '' : Math.round((Number(operationalStatusList[0].groundWaterAvg.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].rdi = operationalStatusList[0].rdi === null ? '' : data.summerBod && data.summerBod.INFL_AMNT === 0 ? '' : Math.round((Number(operationalStatusList[0].rdi.toString().replaceAll(',','')) / (data.summerBod&&data.summerBod.INFL_AMNT&&data.summerBod.INFL_AMNT!='null'?Number(data.summerBod.INFL_AMNT.toString().replaceAll(',','')):0) * 100) * 10) / 10+'%';
|
|
/* operationalStatusList[7].groundWaterAvg = operationalStatusList[0].groundWaterAvg === null ? '' : Number(Number(operationalStatusList[0].groundWaterAvg) / Number(data.yearData.AVG_INFL_AMNT)) * 100;
|
|
operationalStatusList[7].groundWaterSummer = operationalStatusList[0].groundWaterSummer === null ? '' : Number(Number(operationalStatusList[0].groundWaterSummer) / Number(data.summer.AVG_INFL_AMNT)) * 100;
|
|
operationalStatusList[7].groundWaterWinter = operationalStatusList[0].groundWaterWinter === null ? '' : Number(Number(operationalStatusList[0].groundWaterWinter) / Number(data.winter.AVG_INFL_AMNT)) * 100;*/
|
|
}
|
|
|
|
for(let i=1; i<operationalStatusList.length; i++){
|
|
const txtArray = ['1', 'INFL_AMNT', 'SUM_FLOW', 'RETURN_AMNT', 'EFFL_AMNT', 'INFL_ASSCT_BFR_WQLT_BOD', 'EFFL_WQLT_BOD', 'INFL_ASSCT_BFR_WQLT_TN', 'EFFL_WQLT_TN', 'INFL_ASSCT_BFR_WQLT_TP', 'EFFL_WQLT_TP', 'TP_INFL_WQLT_TP', 'EFFL_WQLT_TP'];
|
|
if(operationalStatusList[i]){
|
|
if(i < 7){
|
|
changeValue(operationalStatusList[i], data, txtArray[i]);
|
|
if(i < 5){
|
|
dataFormSetting(operationalStatusList[i]!);
|
|
}else{
|
|
dataFormSettingWqlty(operationalStatusList[i]!);
|
|
}
|
|
|
|
}else{
|
|
calcValue(operationalStatusList[i], data, txtArray[i]);
|
|
}
|
|
}
|
|
}
|
|
|
|
// 순수하수량
|
|
if(operationalStatusList[1]){
|
|
operationalStatusList[1].summerThree = summerRainInflAmnt;
|
|
operationalStatusList[1].summerRain = summerChungchunFlow;
|
|
operationalStatusList[1].winterSunnyAvg = winterChungchunFlowAvg;
|
|
operationalStatusList[1].winterSunnyMax = winterChungchunFlowMax;
|
|
operationalStatusList[1].winterSunnyMin = winterChungchunFlowMin;
|
|
dataFormSetting(operationalStatusList[1]);
|
|
}
|
|
|
|
// 연계처리수
|
|
if(operationalStatusList[2]){
|
|
operationalStatusList[2].yearAvg = yearAvgSumFlow;
|
|
operationalStatusList[2].yearMax = yearMaxSumFlow;
|
|
operationalStatusList[2].yearMin = yearMinSumFlow;
|
|
operationalStatusList[2].summerAll = summerAll;
|
|
operationalStatusList[2].summerThree = summerThree;
|
|
operationalStatusList[2].summerRain = summerRain;
|
|
operationalStatusList[2].winterAll = winterAll;
|
|
operationalStatusList[2].winterSunnyMin = winterSunnyMin;
|
|
operationalStatusList[2].winterSunnyAvg = winterSunnyAvg;
|
|
operationalStatusList[2].winterSunnyMax = winterSunnyMax;
|
|
dataFormSetting(operationalStatusList[2]);
|
|
}
|
|
|
|
// 총인설비방류수
|
|
if(operationalStatusList[3]){
|
|
operationalStatusList[3].summerThree = summerRainReturnAmnt;
|
|
operationalStatusList[3].summerRain = summerChungchunReturnAmnt;
|
|
operationalStatusList[3].winterSunnyAvg = winterChungchunReturnAvg;
|
|
operationalStatusList[3].winterSunnyMax = winterChungchunReturnMax;
|
|
operationalStatusList[3].winterSunnyMin = winterChungchunReturnMin;
|
|
dataFormSetting(operationalStatusList[3]);
|
|
}
|
|
|
|
// 방류수
|
|
if(operationalStatusList[4]){
|
|
operationalStatusList[4].summerThree = summerRainEfflAmnt;
|
|
operationalStatusList[4].summerRain = summerChungchunEfflAmnt;
|
|
operationalStatusList[4].winterSunnyAvg = winterChungchunEfflAvg;
|
|
operationalStatusList[4].winterSunnyMax = winterChungchunEfflMax;
|
|
operationalStatusList[4].winterSunnyMin = winterChungchunEfflMin;
|
|
dataFormSetting(operationalStatusList[4]);
|
|
}
|
|
|
|
if (operationalStatusList[0]) {
|
|
// 안전하게 숫자 변환하는 함수
|
|
const toNum = (val) => {
|
|
if (val === null || val === undefined || val === '' || val === '0') return 0;
|
|
return Number(val.toString().replaceAll(',', '')) || 0;
|
|
};
|
|
|
|
operationalStatusList[0].summerAll =
|
|
toNum(operationalStatusList[1]?.summerAll) +
|
|
toNum(operationalStatusList[2]?.summerAll) +
|
|
toNum(operationalStatusList[3]?.summerAll);
|
|
|
|
operationalStatusList[0].summerThree =
|
|
toNum(operationalStatusList[1]?.summerThree) +
|
|
toNum(operationalStatusList[2]?.summerThree) +
|
|
toNum(operationalStatusList[3]?.summerThree);
|
|
|
|
operationalStatusList[0].summerRain =
|
|
toNum(operationalStatusList[1]?.summerRain) +
|
|
toNum(operationalStatusList[2]?.summerRain) +
|
|
toNum(operationalStatusList[3]?.summerRain);
|
|
|
|
operationalStatusList[0].winterAll =
|
|
toNum(operationalStatusList[1]?.winterAll) +
|
|
toNum(operationalStatusList[2]?.winterAll) +
|
|
toNum(operationalStatusList[3]?.winterAll);
|
|
|
|
operationalStatusList[0].winterSunnyAvg =
|
|
toNum(operationalStatusList[1]?.winterSunnyAvg) +
|
|
toNum(operationalStatusList[2]?.winterSunnyAvg) +
|
|
toNum(operationalStatusList[3]?.winterSunnyAvg);
|
|
|
|
dataFormSetting(operationalStatusList[0]);
|
|
}
|
|
}
|
|
// 총인설비가 없을 경우 제외
|
|
if(data.yearData.TP_INFL_WQLT_TP === null || data.yearData.TP_INFL_WQLT_TP === undefined || data.yearData.TP_INFL_WQLT_TP === 'null') {
|
|
operationalStatusList = operationalStatusList.slice(0, 11);
|
|
}
|
|
set((state: DashBoardType) => ({
|
|
...state,
|
|
OperationStatus: {
|
|
...state.OperationStatus,
|
|
operationalStatusList: operationalStatusList,
|
|
operationalStatusCount: res.count,
|
|
isLoadingOperationStatus : false,
|
|
},
|
|
}))
|
|
},
|
|
|
|
searchMainGraph: async (searchYear: string, fcltyCd: string) => {
|
|
set((state: DashBoardType) => ({
|
|
...state,
|
|
MainGraph: {
|
|
...state.MainGraph,
|
|
isLoadingMainGraph: true,
|
|
},
|
|
}));
|
|
const res = await fetchMainGraph(searchYear, fcltyCd);
|
|
if(res == null || res.data == null || res.data.length === 0) {
|
|
set((state: DashBoardType) => ({
|
|
...state,
|
|
MainGraph: {
|
|
...state.MainGraph,
|
|
chart_inflowRain: [],
|
|
chart_bodRain: [],
|
|
chart_inflTp: [],
|
|
chart_chongInTp: [],
|
|
chart_efflTp: [],
|
|
chart_inflTn: [],
|
|
chart_efflTn: [],
|
|
chart_inflBod: [],
|
|
chart_efflBod: [],
|
|
isLoadingMainGraph : false,
|
|
}
|
|
}));
|
|
return;
|
|
}
|
|
|
|
const chart_inflowRain = res.data.wqltObjs.map((item: FacilityWaterQltyProps) => ({
|
|
label: item.msrDt.substring(0, 4)+"-"+item.msrDt.substring(4, 6)+"-"+item.msrDt.substring(6, 8),
|
|
barVal0: item.infoRnDay ?? 0,
|
|
lineVal0: item.fctCpc ?? 0,
|
|
lineVal1: item.inflAmnt ?? 0,
|
|
}));
|
|
|
|
const chart_bodRain = res.data.wqltObjs.map((item: FacilityWaterQltyProps) => ({
|
|
label: item.msrDt.substring(0, 4)+"-"+item.msrDt.substring(4, 6)+"-"+item.msrDt.substring(6, 8),
|
|
barVal0: item.infoRnDay ?? 0,
|
|
lineVal0: item.inflAssctBfrWqltBod ?? 0,
|
|
}));
|
|
|
|
const chart_inflTp = res.data.wqltObjs.map((item: FacilityWaterQltyProps) => ({
|
|
label: item.msrDt.substring(0, 4)+"-"+item.msrDt.substring(4, 6)+"-"+item.msrDt.substring(6, 8),
|
|
val : item.inflAssctBfrWqltTp ?? 0
|
|
}));
|
|
|
|
const chart_chongInTp = res.data.wqltObjs.map((item: FacilityWaterQltyProps) => ({
|
|
label: item.msrDt.substring(0, 4)+"-"+item.msrDt.substring(4, 6)+"-"+item.msrDt.substring(6, 8),
|
|
val : item.tpInflWqltTp ?? 0
|
|
}));
|
|
|
|
const chart_efflTp = res.data.wqltObjs.map((item: FacilityWaterQltyProps) => ({
|
|
label: item.msrDt.substring(0, 4)+"-"+item.msrDt.substring(4, 6)+"-"+item.msrDt.substring(6, 8),
|
|
val : item.efflWqltTp ?? 0
|
|
}));
|
|
|
|
const chart_inflTn = res.data.wqltObjs.map((item: FacilityWaterQltyProps) => ({
|
|
label: item.msrDt.substring(0, 4)+"-"+item.msrDt.substring(4, 6)+"-"+item.msrDt.substring(6, 8),
|
|
val : item.inflAssctBfrWqltTn ?? 0
|
|
}));
|
|
|
|
const chart_efflTn = res.data.wqltObjs.map((item: FacilityWaterQltyProps) => ({
|
|
label: item.msrDt.substring(0, 4)+"-"+item.msrDt.substring(4, 6)+"-"+item.msrDt.substring(6, 8),
|
|
val : item.efflWqltTn ?? 0
|
|
}));
|
|
|
|
const chart_inflBod = res.data.wqltObjs.map((item: FacilityWaterQltyProps) => ({
|
|
label: item.msrDt.substring(0, 4)+"-"+item.msrDt.substring(4, 6)+"-"+item.msrDt.substring(6, 8),
|
|
val : item.inflAssctBfrWqltBod ?? 0
|
|
}));
|
|
|
|
const chart_efflBod = res.data.wqltObjs.map((item: FacilityWaterQltyProps) => ({
|
|
label: item.msrDt.substring(0, 4)+"-"+item.msrDt.substring(4, 6)+"-"+item.msrDt.substring(6, 8),
|
|
val : item.efflWqltBod ?? 0
|
|
}));
|
|
|
|
set((state: DashBoardType) => ({
|
|
...state,
|
|
MainGraph: {
|
|
...state.MainGraph,
|
|
chart_inflowRain: chart_inflowRain,
|
|
chart_bodRain: chart_bodRain,
|
|
chart_inflTp: chart_inflTp,
|
|
chart_chongInTp : chart_chongInTp,
|
|
chart_efflTp: chart_efflTp,
|
|
chart_inflTn: chart_inflTn,
|
|
chart_efflTn: chart_efflTn,
|
|
chart_inflBod: chart_inflBod,
|
|
chart_efflBod: chart_efflBod,
|
|
isLoadingMainGraph : false,
|
|
},
|
|
}))
|
|
},
|
|
|
|
searchRainManage: async (searchYear: string, fcltyCd: string, isExcel : boolean) => {
|
|
set((state: DashBoardType) => ({
|
|
...state,
|
|
RainManage: {
|
|
...state.RainManage,
|
|
isLoadingRainManage: true,
|
|
},
|
|
}));
|
|
const res = await fetchMainGraph(searchYear, fcltyCd);
|
|
if(res == null || res.data.wqltObjs == null || res.data.wqltObjs.length === 0) {
|
|
set((state: DashBoardType) => ({
|
|
...state,
|
|
RainManage: {
|
|
...state.RainManage,
|
|
rainManageList: [],
|
|
isLoadingRainManage : false,
|
|
}
|
|
}));
|
|
return;
|
|
}
|
|
const fcltyCpcValue = res.data.wqltObjs[0].fctCpc;
|
|
|
|
const itemList = ['계', '3~10mm 미만', '10~20mm 미만', '20~30mm 미만', '30~40mm 미만', '40~50mm 미만', '50mm~60mm 미만', '60mm 이상'];
|
|
const rainRate = ['0', '0', '0', '0', '0', '0', '0', '0'];
|
|
const rainDate = [0, 0, 0, 0, 0, 0, 0, 0];
|
|
const inflAmtCnt = [0, 0, 0, 0, 0, 0, 0, 0];
|
|
const inflAmnt = [0, 0, 0, 0, 0, 0, 0, 0];
|
|
const fcltyCpct = [0, 0, 0, 0, 0, 0, 0, 0];
|
|
const dsInflWqltBod: number[] = [0, 0, 0, 0, 0, 0, 0, 0];
|
|
const dsInflWqltCod: number[] = [0, 0, 0, 0, 0, 0, 0, 0];
|
|
const dsInflWqltSs: number[] = [0, 0, 0, 0, 0, 0, 0, 0];
|
|
const dsInflWqltTn: number[] = [0, 0, 0, 0, 0, 0, 0, 0];
|
|
const dsInflWqltTp: number[] = [0, 0, 0, 0, 0, 0, 0, 0];
|
|
const inflAssctBfrWqltBodCnt = [0, 0, 0, 0, 0, 0, 0, 0];
|
|
const inflAssctBfrWqltBod = [0, 0, 0, 0, 0, 0, 0, 0];
|
|
const inflAssctBfrWqltTocCnt = [0, 0, 0, 0, 0, 0, 0, 0];
|
|
const inflAssctBfrWqltToc = [0, 0, 0, 0, 0, 0, 0, 0];
|
|
const inflAssctBfrWqltSsCnt = [0, 0, 0, 0, 0, 0, 0, 0];
|
|
const inflAssctBfrWqltSs = [0, 0, 0, 0, 0, 0, 0, 0];
|
|
const inflAssctBfrWqltTnCnt = [0, 0, 0, 0, 0, 0, 0, 0];
|
|
const inflAssctBfrWqltTn = [0, 0, 0, 0, 0, 0, 0, 0];
|
|
const inflAssctBfrWqltTpCnt = [0, 0, 0, 0, 0, 0, 0, 0];
|
|
const inflAssctBfrWqltTp = [0, 0, 0, 0, 0, 0, 0, 0];
|
|
const efflWqltBodCnt = [0, 0, 0, 0, 0, 0, 0, 0];
|
|
const efflWqltBod = [0, 0, 0, 0, 0, 0, 0, 0];
|
|
const efflWqltTocCnt = [0, 0, 0, 0, 0, 0, 0, 0];
|
|
const efflWqltToc = [0, 0, 0, 0, 0, 0, 0, 0];
|
|
const efflWqltSsCnt = [0, 0, 0, 0, 0, 0, 0, 0];
|
|
const efflWqltSs = [0, 0, 0, 0, 0, 0, 0, 0];
|
|
const efflWqltTnCnt = [0, 0, 0, 0, 0, 0, 0, 0];
|
|
const efflWqltTn = [0, 0, 0, 0, 0, 0, 0, 0];
|
|
const efflWqltTpCnt = [0, 0, 0, 0, 0, 0, 0, 0];
|
|
const efflWqltTp = [0, 0, 0, 0, 0, 0, 0, 0];
|
|
|
|
// 청천시 중 강우영향일인 날짜는 이전의 강우량을 대입해 리스트 수정
|
|
|
|
const rainEffectList = CalcRainEffect(res.data.wqltObjs);
|
|
// 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;
|
|
|
|
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;
|
|
|
|
if(Number(item.infoRnDay) >= 3 && Number(item.infoRnDay) < 10){
|
|
rainDate[1] = Number(rainDate[1] || 0) + 1;
|
|
inflAmtCnt[1] = Number(inflAmtCnt[1] || 0) + 1;
|
|
inflAmnt[1] = Number(inflAmnt[1] || 0) + Number(item.inflAmnt || 0);
|
|
fcltyCpct[1] = 0;
|
|
inflAssctBfrWqltBodCnt[1] = Number(inflAssctBfrWqltBodCnt[1] || 0) + 1;
|
|
inflAssctBfrWqltBod[1] = Number(inflAssctBfrWqltBod[1] || 0) + Number(item.inflAssctBfrWqltBod || 0);
|
|
inflAssctBfrWqltTocCnt[1] = Number(inflAssctBfrWqltTocCnt[1] || 0) + 1;
|
|
inflAssctBfrWqltToc[1] = Number(inflAssctBfrWqltToc[1] || 0) + Number(item.inflAssctBfrWqltToc || 0);
|
|
inflAssctBfrWqltSsCnt[1] = Number(inflAssctBfrWqltSsCnt[1] || 0) + 1;
|
|
inflAssctBfrWqltSs[1] = Number(inflAssctBfrWqltSs[1] || 0) + Number(item.inflAssctBfrWqltSs || 0);
|
|
inflAssctBfrWqltTnCnt[1] = Number(inflAssctBfrWqltTnCnt[1] || 0) + 1;
|
|
inflAssctBfrWqltTn[1] = Number(inflAssctBfrWqltTn[1] || 0) + Number(item.inflAssctBfrWqltTn || 0);
|
|
inflAssctBfrWqltTpCnt[1] = Number(inflAssctBfrWqltTpCnt[1] || 0) + 1;
|
|
inflAssctBfrWqltTp[1] = Number(inflAssctBfrWqltTp[1] || 0) + Number(item.inflAssctBfrWqltTp || 0);
|
|
efflWqltBodCnt[1] = Number(efflWqltBodCnt[1] || 0) + 1;
|
|
efflWqltBod[1] = Number(efflWqltBod[1] || 0) + Number(item.efflWqltBod || 0);
|
|
efflWqltTocCnt[1] = Number(efflWqltTocCnt[1] || 0) + 1;
|
|
efflWqltToc[1] = Number(efflWqltToc[1] || 0) + Number(item.efflWqltToc || 0);
|
|
efflWqltSsCnt[1] = Number(efflWqltSsCnt[1] || 0) + 1;
|
|
efflWqltSs[1] = Number(efflWqltSs[1] || 0) + Number(item.efflWqltSs || 0);
|
|
efflWqltTnCnt[1] = Number(efflWqltTnCnt[1] || 0) + 1;
|
|
efflWqltTn[1] = Number(efflWqltTn[1] || 0) + Number(item.efflWqltTn || 0);
|
|
efflWqltTpCnt[1] = Number(efflWqltTpCnt[1] || 0) + 1;
|
|
efflWqltTp[1] = Number(efflWqltTp[1] || 0) + Number(item.efflWqltTp || 0);
|
|
}else if(Number(item.infoRnDay) >= 10 && Number(item.infoRnDay) < 20){
|
|
rainDate[2] = Number(rainDate[2] || 0) + 1;
|
|
inflAmtCnt[2] = Number(inflAmtCnt[2] || 0) + 1;
|
|
inflAmnt[2] = Number(inflAmnt[2] || 0) + Number(item.inflAmnt || 0);
|
|
fcltyCpct[2] = 0;
|
|
inflAssctBfrWqltBodCnt[2] = Number(inflAssctBfrWqltBodCnt[2] || 0) + 1;
|
|
inflAssctBfrWqltBod[2] = Number(inflAssctBfrWqltBod[2] || 0) + Number(item.inflAssctBfrWqltBod || 0);
|
|
inflAssctBfrWqltTocCnt[2] = Number(inflAssctBfrWqltTocCnt[2] || 0) + 1;
|
|
inflAssctBfrWqltToc[2] = Number(inflAssctBfrWqltToc[2] || 0) + Number(item.inflAssctBfrWqltToc || 0);
|
|
inflAssctBfrWqltSsCnt[2] = Number(inflAssctBfrWqltSsCnt[2] || 0) + 1;
|
|
inflAssctBfrWqltSs[2] = Number(inflAssctBfrWqltSs[2] || 0) + Number(item.inflAssctBfrWqltSs || 0);
|
|
inflAssctBfrWqltTnCnt[2] = Number(inflAssctBfrWqltTnCnt[2] || 0) + 1;
|
|
inflAssctBfrWqltTn[2] = Number(inflAssctBfrWqltTn[2] || 0) + Number(item.inflAssctBfrWqltTn || 0);
|
|
inflAssctBfrWqltTpCnt[2] = Number(inflAssctBfrWqltTpCnt[2] || 0) + 1;
|
|
inflAssctBfrWqltTp[2] = Number(inflAssctBfrWqltTp[2] || 0) + Number(item.inflAssctBfrWqltTp || 0);
|
|
efflWqltBodCnt[2] = Number(efflWqltBodCnt[2] || 0) + 1;
|
|
efflWqltBod[2] = Number(efflWqltBod[2] || 0) + Number(item.efflWqltBod || 0);
|
|
efflWqltTocCnt[2] = Number(efflWqltTocCnt[2] || 0) + 1;
|
|
efflWqltToc[2] = Number(efflWqltToc[2] || 0) + Number(item.efflWqltToc || 0);
|
|
efflWqltSsCnt[2] = Number(efflWqltSsCnt[2] || 0) + 1;
|
|
efflWqltSs[2] = Number(efflWqltSs[2] || 0) + Number(item.efflWqltSs || 0);
|
|
efflWqltTnCnt[2] = Number(efflWqltTnCnt[2] || 0) + 1;
|
|
efflWqltTn[2] = Number(efflWqltTn[2] || 0) + Number(item.efflWqltTn || 0);
|
|
efflWqltTpCnt[2] = Number(efflWqltTpCnt[2] || 0) + 1;
|
|
efflWqltTp[2] = Number(efflWqltTp[2] || 0) + Number(item.efflWqltTp || 0);
|
|
}else if(Number(item.infoRnDay) >= 20 && Number(item.infoRnDay) < 30){
|
|
rainDate[3] = Number(rainDate[3] || 0) + 1;
|
|
inflAmtCnt[3] = Number(inflAmtCnt[3] || 0) + 1;
|
|
inflAmnt[3] = Number(inflAmnt[3] || 0) + Number(item.inflAmnt || 0);
|
|
fcltyCpct[3] = 0;
|
|
inflAssctBfrWqltBodCnt[3] = Number(inflAssctBfrWqltBodCnt[3] || 0) + 1;
|
|
inflAssctBfrWqltBod[3] = Number(inflAssctBfrWqltBod[3] || 0) + Number(item.inflAssctBfrWqltBod || 0);
|
|
inflAssctBfrWqltTocCnt[3] = Number(inflAssctBfrWqltTocCnt[3] || 0) + 1;
|
|
inflAssctBfrWqltToc[3] = Number(inflAssctBfrWqltToc[3] || 0) + Number(item.inflAssctBfrWqltToc || 0);
|
|
inflAssctBfrWqltSsCnt[3] = Number(inflAssctBfrWqltSsCnt[3] || 0) + 1;
|
|
inflAssctBfrWqltSs[3] = Number(inflAssctBfrWqltSs[3] || 0) + Number(item.inflAssctBfrWqltSs || 0);
|
|
inflAssctBfrWqltTnCnt[3] = Number(inflAssctBfrWqltTnCnt[3] || 0) + 1;
|
|
inflAssctBfrWqltTn[3] = Number(inflAssctBfrWqltTn[3] || 0) + Number(item.inflAssctBfrWqltTn || 0);
|
|
inflAssctBfrWqltTpCnt[3] = Number(inflAssctBfrWqltTpCnt[3] || 0) + 1;
|
|
inflAssctBfrWqltTp[3] = Number(inflAssctBfrWqltTp[3] || 0) + Number(item.inflAssctBfrWqltTp || 0);
|
|
efflWqltBodCnt[3] = Number(efflWqltBodCnt[3] || 0) + 1;
|
|
efflWqltBod[3] = Number(efflWqltBod[3] || 0) + Number(item.efflWqltBod || 0);
|
|
efflWqltTocCnt[3] = Number(efflWqltTocCnt[3] || 0) + 1;
|
|
efflWqltToc[3] = Number(efflWqltToc[3] || 0) + Number(item.efflWqltToc || 0);
|
|
efflWqltSsCnt[3] = Number(efflWqltSsCnt[3] || 0) + 1;
|
|
efflWqltSs[3] = Number(efflWqltSs[3] || 0) + Number(item.efflWqltSs || 0);
|
|
efflWqltTnCnt[3] = Number(efflWqltTnCnt[3] || 0) + 1;
|
|
efflWqltTn[3] = Number(efflWqltTn[3] || 0) + Number(item.efflWqltTn || 0);
|
|
efflWqltTpCnt[3] = Number(efflWqltTpCnt[3] || 0) + 1;
|
|
efflWqltTp[3] = Number(efflWqltTp[3] || 0) + Number(item.efflWqltTp || 0);
|
|
}else if(Number(item.infoRnDay) >= 30 && Number(item.infoRnDay) < 40){
|
|
rainDate[4] = Number(rainDate[4] || 0) + 1;
|
|
inflAmtCnt[4] = Number(inflAmtCnt[4] || 0) + 1;
|
|
inflAmnt[4] = Number(inflAmnt[4] || 0) + Number(item.inflAmnt || 0);
|
|
fcltyCpct[4] = item.inflAmnt&&Number(item.inflAmnt) !== 0 ? Number(Math.round(Number(item.inflAmnt) / Number(item.fctCpc) * 10) / 10) : 0;
|
|
inflAssctBfrWqltBodCnt[4] = Number(inflAssctBfrWqltBodCnt[4] || 0) + 1;
|
|
inflAssctBfrWqltBod[4] = Number(inflAssctBfrWqltBod[4] || 0) + Number(item.inflAssctBfrWqltBod || 0);
|
|
inflAssctBfrWqltTocCnt[4] = Number(inflAssctBfrWqltTocCnt[4] || 0) + 1;
|
|
inflAssctBfrWqltToc[4] = Number(inflAssctBfrWqltToc[4] || 0) + Number(item.inflAssctBfrWqltToc || 0);
|
|
inflAssctBfrWqltSsCnt[4] = Number(inflAssctBfrWqltSsCnt[4] || 0) + 1;
|
|
inflAssctBfrWqltSs[4] = Number(inflAssctBfrWqltSs[4] || 0) + Number(item.inflAssctBfrWqltSs || 0);
|
|
inflAssctBfrWqltTnCnt[4] = Number(inflAssctBfrWqltTnCnt[4] || 0) + 1;
|
|
inflAssctBfrWqltTn[4] = Number(inflAssctBfrWqltTn[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(Number(item.infoRnDay) >= 40 && Number(item.infoRnDay) < 50){
|
|
rainDate[5] = Number(rainDate[5] || 0) + 1;
|
|
inflAmtCnt[5] = Number(inflAmtCnt[5] || 0) + 1;
|
|
inflAmnt[5] = Number(inflAmnt[5] || 0) + Number(item.inflAmnt || 0);
|
|
fcltyCpct[5] = 0;
|
|
inflAssctBfrWqltBodCnt[5] = Number(inflAssctBfrWqltBodCnt[5] || 0) + 1;
|
|
inflAssctBfrWqltBod[5] = Number(inflAssctBfrWqltBod[5] || 0) + Number(item.inflAssctBfrWqltBod || 0);
|
|
inflAssctBfrWqltTocCnt[5] = Number(inflAssctBfrWqltTocCnt[5] || 0) + 1;
|
|
inflAssctBfrWqltToc[5] = Number(inflAssctBfrWqltToc[5] || 0) + Number(item.inflAssctBfrWqltToc || 0);
|
|
inflAssctBfrWqltSsCnt[5] = Number(inflAssctBfrWqltSsCnt[5] || 0) + 1;
|
|
inflAssctBfrWqltSs[5] = Number(inflAssctBfrWqltSs[5] || 0) + Number(item.inflAssctBfrWqltSs || 0);
|
|
inflAssctBfrWqltTnCnt[5] = Number(inflAssctBfrWqltTnCnt[5] || 0) + 1;
|
|
inflAssctBfrWqltTn[5] = Number(inflAssctBfrWqltTn[5] || 0) + Number(item.inflAssctBfrWqltTn || 0);
|
|
inflAssctBfrWqltTpCnt[5] = Number(inflAssctBfrWqltTpCnt[5] || 0) + 1;
|
|
inflAssctBfrWqltTp[5] = Number(inflAssctBfrWqltTp[5] || 0) + Number(item.inflAssctBfrWqltTp || 0);
|
|
efflWqltBodCnt[5] = Number(efflWqltBodCnt[5] || 0) + 1;
|
|
efflWqltBod[5] = Number(efflWqltBod[5] || 0) + Number(item.efflWqltBod || 0);
|
|
efflWqltTocCnt[5] = Number(efflWqltTocCnt[5] || 0) + 1;
|
|
efflWqltToc[5] = Number(efflWqltToc[5] || 0) + Number(item.efflWqltToc || 0);
|
|
efflWqltSsCnt[5] = Number(efflWqltSsCnt[5] || 0) + 1;
|
|
efflWqltSs[5] = Number(efflWqltSs[5] || 0) + Number(item.efflWqltSs || 0);
|
|
efflWqltTnCnt[5] = Number(efflWqltTnCnt[5] || 0) + 1;
|
|
efflWqltTn[5] = Number(efflWqltTn[5] || 0) + Number(item.efflWqltTn || 0);
|
|
efflWqltTpCnt[5] = Number(efflWqltTpCnt[5] || 0) + 1;
|
|
efflWqltTp[5] = Number(efflWqltTp[5] || 0) + Number(item.efflWqltTp || 0);
|
|
}else if(Number(item.infoRnDay) >= 50 && Number(item.infoRnDay) < 60){
|
|
rainDate[6] = Number(rainDate[6] || 0) + 1;
|
|
inflAmtCnt[6] = Number(inflAmtCnt[6] || 0) + 1;
|
|
inflAmnt[6] = Number(inflAmnt[6] || 0) + Number(item.inflAmnt || 0);
|
|
fcltyCpct[6] = 0;
|
|
inflAssctBfrWqltBodCnt[6] = Number(inflAssctBfrWqltBodCnt[6] || 0) + 1;
|
|
inflAssctBfrWqltBod[6] = Number(inflAssctBfrWqltBod[6] || 0) + Number(item.inflAssctBfrWqltBod || 0);
|
|
inflAssctBfrWqltTocCnt[6] = Number(inflAssctBfrWqltTocCnt[6] || 0) + 1;
|
|
inflAssctBfrWqltToc[6] = Number(inflAssctBfrWqltToc[6] || 0) + Number(item.inflAssctBfrWqltToc || 0);
|
|
inflAssctBfrWqltSsCnt[6] = Number(inflAssctBfrWqltSsCnt[6] || 0) + 1;
|
|
inflAssctBfrWqltSs[6] = Number(inflAssctBfrWqltSs[6] || 0) + Number(item.inflAssctBfrWqltSs || 0);
|
|
inflAssctBfrWqltTnCnt[6] = Number(inflAssctBfrWqltTnCnt[6] || 0) + 1;
|
|
inflAssctBfrWqltTn[6] = Number(inflAssctBfrWqltTn[6] || 0) + Number(item.inflAssctBfrWqltTn || 0);
|
|
inflAssctBfrWqltTpCnt[6] = Number(inflAssctBfrWqltTpCnt[6] || 0) + 1;
|
|
inflAssctBfrWqltTp[6] = Number(inflAssctBfrWqltTp[6] || 0) + Number(item.inflAssctBfrWqltTp || 0);
|
|
efflWqltBodCnt[6] = Number(efflWqltBodCnt[6] || 0) + 1;
|
|
efflWqltBod[6] = Number(efflWqltBod[6] || 0) + Number(item.efflWqltBod || 0);
|
|
efflWqltTocCnt[6] = Number(efflWqltTocCnt[6] || 0) + 1;
|
|
efflWqltToc[6] = Number(efflWqltToc[6] || 0) + Number(item.efflWqltToc || 0);
|
|
efflWqltSsCnt[6] = Number(efflWqltSsCnt[6] || 0) + 1;
|
|
efflWqltSs[6] = Number(efflWqltSs[6] || 0) + Number(item.efflWqltSs || 0);
|
|
efflWqltTnCnt[6] = Number(efflWqltTnCnt[6] || 0) + 1;
|
|
efflWqltTn[6] = Number(efflWqltTn[6] || 0) + Number(item.efflWqltTn || 0);
|
|
efflWqltTpCnt[6] = Number(efflWqltTpCnt[6] || 0) + 1;
|
|
efflWqltTp[6] = Number(efflWqltTp[6] || 0) + Number(item.efflWqltTp || 0);
|
|
}else if(Number(item.infoRnDay) >= 60){
|
|
rainDate[7] = Number(rainDate[7] || 0) + 1;
|
|
inflAmtCnt[7] = Number(inflAmtCnt[7] || 0) + 1;
|
|
inflAmnt[7] = Number(inflAmnt[7] || 0) + Number(item.inflAmnt || 0);
|
|
fcltyCpct[7] = 0;
|
|
inflAssctBfrWqltBodCnt[7] = Number(inflAssctBfrWqltBodCnt[7] || 0) + 1;
|
|
inflAssctBfrWqltBod[7] = Number(inflAssctBfrWqltBod[7] || 0) + Number(item.inflAssctBfrWqltBod || 0);
|
|
inflAssctBfrWqltTocCnt[7] = Number(inflAssctBfrWqltTocCnt[7] || 0) + 1;
|
|
inflAssctBfrWqltToc[7] = Number(inflAssctBfrWqltToc[7] || 0) + Number(item.inflAssctBfrWqltToc || 0);
|
|
inflAssctBfrWqltSsCnt[7] = Number(inflAssctBfrWqltSsCnt[7] || 0) + 1;
|
|
inflAssctBfrWqltSs[7] = Number(inflAssctBfrWqltSs[7] || 0) + Number(item.inflAssctBfrWqltSs || 0);
|
|
inflAssctBfrWqltTnCnt[7] = Number(inflAssctBfrWqltTnCnt[7] || 0) + 1;
|
|
inflAssctBfrWqltTn[7] = Number(inflAssctBfrWqltTn[7] || 0) + Number(item.inflAssctBfrWqltTn || 0);
|
|
inflAssctBfrWqltTpCnt[7] = Number(inflAssctBfrWqltTpCnt[7] || 0) + 1;
|
|
inflAssctBfrWqltTp[7] = Number(inflAssctBfrWqltTp[7] || 0) + Number(item.inflAssctBfrWqltTp || 0);
|
|
efflWqltBodCnt[7] = Number(efflWqltBodCnt[7] || 0) + 1;
|
|
efflWqltBod[7] = Number(efflWqltBod[7] || 0) + Number(item.efflWqltBod || 0);
|
|
efflWqltTocCnt[7] = Number(efflWqltTocCnt[7] || 0) + 1;
|
|
efflWqltToc[7] = Number(efflWqltToc[7] || 0) + Number(item.efflWqltToc || 0);
|
|
efflWqltSsCnt[7] = Number(efflWqltSsCnt[7] || 0) + 1;
|
|
efflWqltSs[7] = Number(efflWqltSs[7] || 0) + Number(item.efflWqltSs || 0);
|
|
efflWqltTnCnt[7] = Number(efflWqltTnCnt[7] || 0) + 1;
|
|
efflWqltTn[7] = Number(efflWqltTn[7] || 0) + Number(item.efflWqltTn || 0);
|
|
efflWqltTpCnt[7] = Number(efflWqltTpCnt[7] || 0) + 1;
|
|
efflWqltTp[7] = Number(efflWqltTp[7] || 0) + Number(item.efflWqltTp || 0);
|
|
}
|
|
});
|
|
|
|
// Process the data and create rain management list
|
|
if(res.data&&res.data.dsWqltObjs&&res.data.dsWqltObjs.length > 0){
|
|
// 설계 유입수질 데이터 가져오기 - 0값이 있으면 이전 차수에서 가져오기
|
|
const getDesignWaterQualityData = (stepIndex: number, maxPreviousSteps: number = 3) => {
|
|
for (let i = 0; i <= maxPreviousSteps && stepIndex - i >= 0; i++) {
|
|
const currentStep = res.data.dsWqltObjs[stepIndex - i];
|
|
if (currentStep &&
|
|
currentStep.dsInflWqltBod > 0 &&
|
|
currentStep.dsInflWqltCod > 0 &&
|
|
currentStep.dsInflWqltSs > 0 &&
|
|
currentStep.dsInflWqltTn > 0 &&
|
|
currentStep.dsInflWqltTp > 0) {
|
|
return {
|
|
dsInflWqltBod: currentStep.dsInflWqltBod,
|
|
dsInflWqltCod: currentStep.dsInflWqltCod,
|
|
dsInflWqltSs: currentStep.dsInflWqltSs,
|
|
dsInflWqltTn: currentStep.dsInflWqltTn,
|
|
dsInflWqltTp: currentStep.dsInflWqltTp
|
|
};
|
|
}
|
|
}
|
|
// 모든 차수에서 유효한 데이터를 찾지 못한 경우 기본값 반환
|
|
return {
|
|
dsInflWqltBod: 0,
|
|
dsInflWqltCod: 0,
|
|
dsInflWqltSs: 0,
|
|
dsInflWqltTn: 0,
|
|
dsInflWqltTp: 0
|
|
};
|
|
};
|
|
|
|
const lastStepIndex = res.data.dsWqltObjs.length - 1;
|
|
const designData = getDesignWaterQualityData(lastStepIndex);
|
|
|
|
dsInflWqltBod[0] = designData.dsInflWqltBod;
|
|
dsInflWqltCod[0] = designData.dsInflWqltCod;
|
|
dsInflWqltSs[0] = designData.dsInflWqltSs;
|
|
dsInflWqltTn[0] = designData.dsInflWqltTn;
|
|
dsInflWqltTp[0] = designData.dsInflWqltTp;
|
|
}
|
|
|
|
rainDate[0] = (Number(rainDate[1]) || 0) + (Number(rainDate[2]) || 0) + (Number(rainDate[3]) || 0) +
|
|
(Number(rainDate[4]) || 0) + (Number(rainDate[5]) || 0) + (Number(rainDate[6]) || 0) +
|
|
(Number(rainDate[7]) || 0);
|
|
|
|
// 강수비율
|
|
for(let idx=0; idx<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;
|
|
};
|
|
|
|
// 데이터 있는 항목만 계산
|
|
let dataIsCount = 0;
|
|
for(let idx=0; idx<inflAmnt.length; idx++){
|
|
if(Number(inflAmnt[idx]) > 0){
|
|
dataIsCount++;
|
|
}
|
|
}
|
|
|
|
for(let idx=0; idx<inflAmnt.length; idx++){
|
|
inflAmnt[idx] = calculateAverage(Number(inflAmnt[idx]), Number(inflAmtCnt[idx]));
|
|
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)));
|
|
};
|
|
|
|
inflAmnt[0] = calculateAverage(calculateTotal(inflAmnt), dataIsCount);
|
|
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,
|
|
}
|
|
}));
|
|
},
|
|
}
|
|
} |