sn: wtrUsgYears try catch

This commit is contained in:
2026-11-24 23:45:59 +09:00
parent 9c9a40714d
commit 3a4e581a93
+449 -419
View File
@@ -1326,13 +1326,18 @@ type wtrUsgYearsResponse = {
const searchWaterUsage = async (searchYear: string, fcltyCd: string) => {
const waterUsage = [0, 0, 0]; // searchYear, searchYear-1, searchYear-2
const res = await getFetch('fo', '/dashBoard/wtrUsgYears/' + searchYear + '/' + fcltyCd) as wtrUsgYearsResponse;
let i = 0;
if (res && res.data && Array.isArray(res.data)) {
res.data.forEach((item: wtrUsgYearsType) => {
waterUsage[i] = item.WTR_USG;
i++;
});
try {
const res = await getFetch('fo', '/dashBoard/wtrUsgYears/' + searchYear + '/' + fcltyCd) as wtrUsgYearsResponse;
let i = 0;
if (res && res.data && Array.isArray(res.data)) {
res.data.forEach((item: wtrUsgYearsType) => {
waterUsage[i] = item.WTR_USG;
i++;
});
}
} catch (error) {
// 물사용량 조회 실패 시 0으로 두고 계획정보 조회는 계속 진행한다.
console.error('연도별 물사용량 데이터를 가져오는데 실패했습니다:', error);
}
return waterUsage;
@@ -1362,108 +1367,103 @@ export const dashBoardReducer = (
isLoadingPlanFclty: true,
},
}));
let waterUsage = [0, 0, 0];
waterUsage = await searchWaterUsage(targetYear, fcltyCd); // /fclt/flow/{fcltyCd}/{year}
set((state: DashBoardType) => ({
...state,
PlanFclty: {
...state.PlanFclty,
waterUsage1: waterUsage[0] || 0,
waterUsage2: waterUsage[1] || 0,
waterUsage3: waterUsage[2] || 0,
},
}));
const res = await fetchFacilityPlan(targetYear, fcltyCd, set); // /dc-service/api/v1/nowDmgMtncGnsvy
let minDiff = 9999999;
let minIndex;
res.forEach((el: any, idx) => {
if (minDiff > Math.abs(Number(targetYear) - Number(el.planYr))) {
minDiff = Math.abs(Number(targetYear) - Number(el.planYr));
minIndex = idx;
}
});
const rtnPlanData = res[minIndex];
planFcltyList.map((el, index) => {
planYearList = [];
planYearList.push(rtnPlanData ? rtnPlanData.planYrDt4.toString() : "");
planYearList.push(rtnPlanData ? rtnPlanData.planYr.toString() : "");
planYearList.push(rtnPlanData ? rtnPlanData.planYrDc1.toString() : "");
planYearList.push(rtnPlanData ? rtnPlanData.planYrDc2.toString() : "");
planYearList.push(rtnPlanData ? rtnPlanData.planYrDc3.toString() : "");
planYearList.push(rtnPlanData ? rtnPlanData.planYrDc4.toString() : "");
if (index === 0) { // 증설계획(㎥/일)
el.provisionalApproval = rtnPlanData ? rtnPlanData.planSwageQntSumDt4 : ''; // 기승인4단계
el.now = rtnPlanData ? rtnPlanData.planSwageQntSum : ''; // 현재
el.stepOne = rtnPlanData ? rtnPlanData.planSwageQntSumDc1 : ''; // 1단계
el.stepTwo = rtnPlanData ? rtnPlanData.planSwageQntSumDc2 : ''; // 2단계
el.stepThree = rtnPlanData ? rtnPlanData.planSwageQntSumDc3 : ''; // 3단계
el.stepFour = rtnPlanData ? rtnPlanData.planSwageQntSumDc4 : ''; // 4단계
}
if (index === 1) { // 처리인구(인)
el.provisionalApproval = rtnPlanData ? rtnPlanData.swtrmtPpltnCntDt4 : '';
el.now = rtnPlanData ? rtnPlanData.swtrmtPpltnCnt : '';
el.stepOne = rtnPlanData ? rtnPlanData.swtrmtPpltnCntDc1 : '';
el.stepTwo = rtnPlanData ? rtnPlanData.swtrmtPpltnCntDc2 : '';
el.stepThree = rtnPlanData ? rtnPlanData.swtrmtPpltnCntDc3 : '';
el.stepFour = rtnPlanData ? rtnPlanData.swtrmtPpltnCntDc4 : '';
}
if (index === 2) { // 처리구역(km²)
el.provisionalApproval = rtnPlanData ? rtnPlanData.swtrmtZoneAreaDt4 : '';
el.now = rtnPlanData ? rtnPlanData.swtrmtZoneArea : '';
el.stepOne = rtnPlanData ? rtnPlanData.swtrmtZoneAreaDc1 : '';
el.stepTwo = rtnPlanData ? rtnPlanData.swtrmtZoneAreaDc2 : '';
el.stepThree = rtnPlanData ? rtnPlanData.swtrmtZoneAreaDc3 : '';
el.stepFour = rtnPlanData ? rtnPlanData.swtrmtZoneAreaDc4 : '';
}
if (index === 4) { // 물사용량
el.provisionalApproval = rtnPlanData ? rtnPlanData.ugwtUseSum : '';
}
if (index === 2) { // 처리구역(km²)
dataFormSettingPlan(el, 1);
} else if (index == 4) { // 물사용량
} else {
dataFormSettingPlan(el, 0);
}
try {
let waterUsage = [0, 0, 0];
waterUsage = await searchWaterUsage(targetYear, fcltyCd); // /fclt/flow/{fcltyCd}/{year}
set((state: DashBoardType) => ({
...state,
PlanFclty: {
...state.PlanFclty,
planFcltyList: planFcltyList,
isLoadingPlanFclty: false,
planYearList: planYearList,
waterUsage1: waterUsage[0] || 0,
waterUsage2: waterUsage[1] || 0,
waterUsage3: waterUsage[2] || 0,
},
}));
});
const res = await fetchFacilityPlan(targetYear, fcltyCd, set); // /dc-service/api/v1/nowDmgMtncGnsvy
// 조회 실패 시 { data: [], count: 0 } 이 올 수 있으므로 배열일 때만 사용한다.
const planList: any[] = Array.isArray(res) ? res : [];
let minDiff = 9999999;
let minIndex;
planList.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 = minIndex !== undefined ? planList[minIndex] : undefined;
planFcltyList.map((el, index) => {
planYearList = [];
planYearList.push(rtnPlanData ? rtnPlanData.planYrDt4.toString() : "");
planYearList.push(rtnPlanData ? rtnPlanData.planYr.toString() : "");
planYearList.push(rtnPlanData ? rtnPlanData.planYrDc1.toString() : "");
planYearList.push(rtnPlanData ? rtnPlanData.planYrDc2.toString() : "");
planYearList.push(rtnPlanData ? rtnPlanData.planYrDc3.toString() : "");
planYearList.push(rtnPlanData ? rtnPlanData.planYrDc4.toString() : "");
if (index === 0) { // 증설계획(㎥/일)
el.provisionalApproval = rtnPlanData ? rtnPlanData.planSwageQntSumDt4 : ''; // 기승인4단계
el.now = rtnPlanData ? rtnPlanData.planSwageQntSum : ''; // 현재
el.stepOne = rtnPlanData ? rtnPlanData.planSwageQntSumDc1 : ''; // 1단계
el.stepTwo = rtnPlanData ? rtnPlanData.planSwageQntSumDc2 : ''; // 2단계
el.stepThree = rtnPlanData ? rtnPlanData.planSwageQntSumDc3 : ''; // 3단계
el.stepFour = rtnPlanData ? rtnPlanData.planSwageQntSumDc4 : ''; // 4단계
}
if (index === 1) { // 처리인구(인)
el.provisionalApproval = rtnPlanData ? rtnPlanData.swtrmtPpltnCntDt4 : '';
el.now = rtnPlanData ? rtnPlanData.swtrmtPpltnCnt : '';
el.stepOne = rtnPlanData ? rtnPlanData.swtrmtPpltnCntDc1 : '';
el.stepTwo = rtnPlanData ? rtnPlanData.swtrmtPpltnCntDc2 : '';
el.stepThree = rtnPlanData ? rtnPlanData.swtrmtPpltnCntDc3 : '';
el.stepFour = rtnPlanData ? rtnPlanData.swtrmtPpltnCntDc4 : '';
}
if (index === 2) { // 처리구역(km²)
el.provisionalApproval = rtnPlanData ? rtnPlanData.swtrmtZoneAreaDt4 : '';
el.now = rtnPlanData ? rtnPlanData.swtrmtZoneArea : '';
el.stepOne = rtnPlanData ? rtnPlanData.swtrmtZoneAreaDc1 : '';
el.stepTwo = rtnPlanData ? rtnPlanData.swtrmtZoneAreaDc2 : '';
el.stepThree = rtnPlanData ? rtnPlanData.swtrmtZoneAreaDc3 : '';
el.stepFour = rtnPlanData ? rtnPlanData.swtrmtZoneAreaDc4 : '';
}
if (index === 4) { // 물사용량
el.provisionalApproval = rtnPlanData ? rtnPlanData.ugwtUseSum : '';
}
if (index === 2) { // 처리구역(km²)
dataFormSettingPlan(el, 1);
} else if (index == 4) { // 물사용량
} else {
dataFormSettingPlan(el, 0);
}
set((state: DashBoardType) => ({
...state,
PlanFclty: {
...state.PlanFclty,
planFcltyList: planFcltyList,
planYearList: planYearList,
},
}));
});
} catch (error) {
console.error('시설정보 계획정보 처리 중 오류가 발생했습니다:', error);
} finally {
// 성공/실패와 관계없이 로딩 오버레이를 해제한다.
set((state: DashBoardType) => ({
...state,
PlanFclty: {
...state.PlanFclty,
isLoadingPlanFclty: false,
},
}));
}
},
/** 시설정보 및 운영현황 - 운영실태 */
searchOperationStatus: async (isExcel: boolean, searchYear: string, fcltyCd: string) => {
const state = get();
let mainGraphData: ApiRes = { data: [], count: 0 };
// 이미 조회된 데이터가 있는지 확인 (연도와 시설코드가 같을 때만)
if (state.RainManage.mainGraphYear === searchYear && state.RainManage.mainGraphFcltyCd === fcltyCd && state.RainManage.mainGraphData) {
mainGraphData = state.RainManage.mainGraphData;
} else {
mainGraphData = await fetchMainGraph(searchYear, fcltyCd);
// 조회된 데이터 저장
set((state: DashBoardType) => ({
...state,
RainManage: {
...state.RainManage,
mainGraphData: mainGraphData,
mainGraphYear: searchYear,
mainGraphFcltyCd: fcltyCd,
}
}));
}
set((state: DashBoardType) => ({
...state,
OperationStatus: {
@@ -1471,356 +1471,386 @@ export const dashBoardReducer = (
isLoadingOperationStatus: true,
},
}));
try {
let mainGraphData: ApiRes = { data: [], count: 0 };
// const fcltCdList = [fcltyCd];
//const wtrUsgRes: any = await fetchWtrUsgYmList(searchYear, fcltCdList); // 수용가의 실제 물사용량
// 이미 조회된 데이터가 있는지 확인 (연도와 시설코드가 같을 때만)
if (state.RainManage.mainGraphYear === searchYear && state.RainManage.mainGraphFcltyCd === fcltyCd && state.RainManage.mainGraphData) {
mainGraphData = state.RainManage.mainGraphData;
} else {
mainGraphData = await fetchMainGraph(searchYear, fcltyCd);
// 조회된 데이터 저장
set((state: DashBoardType) => ({
...state,
RainManage: {
...state.RainManage,
mainGraphData: mainGraphData,
mainGraphYear: searchYear,
mainGraphFcltyCd: fcltyCd,
}
}));
}
const operList = {
inFlow: {
yearTot: 0, yearAvg: 0, yearMax: 0, yearMin: 9999999
, summerTot: 0, summerAvg: 0, summerRainy: 0, summerSunny: 0
, winterTot: 0, winterAvg: 0, winterSunny: 0, winterSunnyMax: 0, winterSunnyMin: 9999999
, groundTot: 0, groundSummer: 0, groundWinter: 0, rdii: 0, rdiiRainAmt: 0
},
inflAmt: {
yearTot: 0, yearAvg: 0, yearMax: 0, yearMin: 9999999, yearSunny: 0
, summerTot: 0, summerAvg: 0, summerRainy: 0, summerSunny: 0
, winterTot: 0, winterAvg: 0, winterSunny: 0, winterSunnyMax: 0, winterSunnyMin: 9999999
, groundTot: 0, groundSummer: 0, groundWinter: 0, rdii: 0, rdiiRainAmt: 0
},
sumFlow: {
yearTot: 0, yearAvg: 0, yearMax: 0, yearMin: 9999999
, summerTot: 0, summerAvg: 0, summerRainy: 0, summerSunny: 0
, winterTot: 0, winterAvg: 0, winterSunny: 0, winterSunnyMax: 0, winterSunnyMin: 9999999
, groundTot: 0, groundSummer: 0, groundWinter: 0, rdii: 0, rdiiRainAmt: 0
},
returnFlow: {
yearTot: 0, yearAvg: 0, yearMax: 0, yearMin: 9999999
, summerTot: 0, summerAvg: 0, summerRainy: 0, summerSunny: 0
, winterTot: 0, winterAvg: 0, winterSunny: 0, winterSunnyMax: 0, winterSunnyMin: 9999999
, groundTot: 0, groundSummer: 0, groundWinter: 0, rdii: 0, rdiiRainAmt: 0
},
efflFlow: {
yearTot: 0, yearAvg: 0, yearMax: 0, yearMin: 9999999
, summerTot: 0, summerAvg: 0, summerRainy: 0, summerSunny: 0
, winterTot: 0, winterAvg: 0, winterSunny: 0, winterSunnyMax: 0, winterSunnyMin: 9999999
, groundTot: 0, groundSummer: 0, groundWinter: 0, rdii: 0, rdiiRainAmt: 0
},
};
const clone = (arr: any[]) => arr?.map(v => ({ ...v })) ?? [];
// const fcltCdList = [fcltyCd];
//const wtrUsgRes: any = await fetchWtrUsgYmList(searchYear, fcltCdList); // 수용가의 실제 물사용량
let rdiPercent = 0;
let operationalStatusList = clone(operationalStatusListOrg);
if (operationalStatusList) {
// 유량 - 유입
if (operationalStatusList?.[0]) {
const operList = {
inFlow: {
yearTot: 0, yearAvg: 0, yearMax: 0, yearMin: 9999999
, summerTot: 0, summerAvg: 0, summerRainy: 0, summerSunny: 0
, winterTot: 0, winterAvg: 0, winterSunny: 0, winterSunnyMax: 0, winterSunnyMin: 9999999
, groundTot: 0, groundSummer: 0, groundWinter: 0, rdii: 0, rdiiRainAmt: 0
},
inflAmt: {
yearTot: 0, yearAvg: 0, yearMax: 0, yearMin: 9999999, yearSunny: 0
, summerTot: 0, summerAvg: 0, summerRainy: 0, summerSunny: 0
, winterTot: 0, winterAvg: 0, winterSunny: 0, winterSunnyMax: 0, winterSunnyMin: 9999999
, groundTot: 0, groundSummer: 0, groundWinter: 0, rdii: 0, rdiiRainAmt: 0
},
sumFlow: {
yearTot: 0, yearAvg: 0, yearMax: 0, yearMin: 9999999
, summerTot: 0, summerAvg: 0, summerRainy: 0, summerSunny: 0
, winterTot: 0, winterAvg: 0, winterSunny: 0, winterSunnyMax: 0, winterSunnyMin: 9999999
, groundTot: 0, groundSummer: 0, groundWinter: 0, rdii: 0, rdiiRainAmt: 0
},
returnFlow: {
yearTot: 0, yearAvg: 0, yearMax: 0, yearMin: 9999999
, summerTot: 0, summerAvg: 0, summerRainy: 0, summerSunny: 0
, winterTot: 0, winterAvg: 0, winterSunny: 0, winterSunnyMax: 0, winterSunnyMin: 9999999
, groundTot: 0, groundSummer: 0, groundWinter: 0, rdii: 0, rdiiRainAmt: 0
},
efflFlow: {
yearTot: 0, yearAvg: 0, yearMax: 0, yearMin: 9999999
, summerTot: 0, summerAvg: 0, summerRainy: 0, summerSunny: 0
, winterTot: 0, winterAvg: 0, winterSunny: 0, winterSunnyMax: 0, winterSunnyMin: 9999999
, groundTot: 0, groundSummer: 0, groundWinter: 0, rdii: 0, rdiiRainAmt: 0
},
};
const clone = (arr: any[]) => arr?.map(v => ({ ...v })) ?? [];
// 연계처리수
let yearDay = 0, summerDay = 0, winterDay = 0; // 연간 일수, 하절기 일수, 동절기 일수
let summerRainDay = 0, summerChungchunDay = 0, winterChungchuDay = 0; // 하절기 강우 일수, 하절기 청천 일수, 동절기 청천 일수
let rdiPercent = 0;
let operationalStatusList = clone(operationalStatusListOrg);
if (operationalStatusList) {
// 유량 - 유입
if (operationalStatusList?.[0]) {
// 연계처리수,지하수유입량
const bscFctCd = fcltyCd;
let res2: any = { data: [] };
// 연계처리수
let yearDay = 0, summerDay = 0, winterDay = 0; // 연간 일수, 하절기 일수, 동절기 일수
let summerRainDay = 0, summerChungchunDay = 0, winterChungchuDay = 0; // 하절기 강우 일수, 하절기 청천 일수, 동절기 청천 일수
// 이미 조회된 데이터가 있는지 확인 (연도와 시설코드가 같을 때만)
if (state.RainManage.flowRateYear === searchYear && state.RainManage.flowRateFcltyCd === fcltyCd && state.RainManage.flowRateData) {
res2 = state.RainManage.flowRateData;
} else {
res2 = await fetchFlowRateModalList(bscFctCd, searchYear); // /fclt/flow/ - 일별 유량 조회
// 조회된 데이터 저장
set((state: DashBoardType) => ({
...state,
RainManage: {
...state.RainManage,
flowRateData: res2,
flowRateYear: searchYear,
flowRateFcltyCd: fcltyCd,
}
}));
}
// 연계처리수,지하수유입량
const bscFctCd = fcltyCd;
let res2: any = { data: [] };
//const calData = CalcRainEffect(clone(res2.data), 'SUNNY');
//const calRainData = CalcRainEffect(clone(res2.data), 'RAIN');
let cntSunnyDay = 0; // 청천일 수
// let chungcunSumFlow = 0; // 연간 청천 순수하수
let rainEffectDay = 0;
yearDay = res2.data ? res2.data.length : 1;
res2.data.forEach((item: any) => { // --일별 유량 start
const month = item.msrDt.substring(4, 6); // 월 추출
const sumFlow = item.sumFlow && item.sumFlow !== 'x' ? Number(item.sumFlow.toString().trim()) : 0;
const inflAmnt = item.inflAmnt && item.inflAmnt !== 'x' ? Number(item.inflAmnt.toString().trim()) : 0;
const returnAmnt = item.returnAmnt && item.returnAmnt !== 'x' ? Number(item.returnAmnt.toString().trim()) : 0;
const efflAmnt = item.efflAmnt && item.efflAmnt !== 'x' ? Number(item.efflAmnt.toString().trim()) : 0;
if (item.infoRnDay == null) item.infoRnDay = 0;
if (item.infoRnDay >= 3) {
rainEffectDay = 2;
// 강우시
// 이미 조회된 데이터가 있는지 확인 (연도와 시설코드가 같을 때만)
if (state.RainManage.flowRateYear === searchYear && state.RainManage.flowRateFcltyCd === fcltyCd && state.RainManage.flowRateData) {
res2 = state.RainManage.flowRateData;
} else {
rainEffectDay--;
res2 = await fetchFlowRateModalList(bscFctCd, searchYear); // /fclt/flow/ - 일별 유량 조회
// 조회된 데이터 저장
set((state: DashBoardType) => ({
...state,
RainManage: {
...state.RainManage,
flowRateData: res2,
flowRateYear: searchYear,
flowRateFcltyCd: fcltyCd,
}
}));
}
if (rainEffectDay >= 0) {
// 강우영향일
if (month === '06' || month === '07' || month === '08') { // 하절기 강우영향일
summerRainDay += 1;
operList.inFlow.summerRainy += inflAmnt + sumFlow + returnAmnt;
operList.inflAmt.summerRainy += inflAmnt;
operList.sumFlow.summerRainy += sumFlow;
operList.returnFlow.summerRainy += returnAmnt;
operList.efflFlow.summerRainy += efflAmnt;
//const calData = CalcRainEffect(clone(res2.data), 'SUNNY');
//const calRainData = CalcRainEffect(clone(res2.data), 'RAIN');
let cntSunnyDay = 0; // 청천일 수
// let chungcunSumFlow = 0; // 연간 청천 순수하수
let rainEffectDay = 0;
yearDay = res2.data ? res2.data.length : 1;
res2.data.forEach((item: any) => { // --일별 유량 start
const month = item.msrDt.substring(4, 6); // 월 추출
const sumFlow = item.sumFlow && item.sumFlow !== 'x' ? Number(item.sumFlow.toString().trim()) : 0;
const inflAmnt = item.inflAmnt && item.inflAmnt !== 'x' ? Number(item.inflAmnt.toString().trim()) : 0;
const returnAmnt = item.returnAmnt && item.returnAmnt !== 'x' ? Number(item.returnAmnt.toString().trim()) : 0;
const efflAmnt = item.efflAmnt && item.efflAmnt !== 'x' ? Number(item.efflAmnt.toString().trim()) : 0;
if (item.infoRnDay == null) item.infoRnDay = 0;
if (item.infoRnDay >= 3) {
rainEffectDay = 2;
// 강우시
} else {
rainEffectDay--;
}
} else if (rainEffectDay < 0) {
cntSunnyDay += 1; // 청천일수
// 청천시
// chungcunSumFlow += inflAmnt; // 연간 청천 순수하수
operList.inflAmt.yearSunny += inflAmnt; // 연간 청천 순수하수
if (month === '06' || month === '07' || month === '08') { // 하절기 청천
summerChungchunDay += 1;
operList.inFlow.summerSunny += inflAmnt + sumFlow + returnAmnt;
operList.inflAmt.summerSunny += inflAmnt;
operList.sumFlow.summerSunny += sumFlow;
operList.returnFlow.summerSunny += returnAmnt;
operList.efflFlow.summerSunny += efflAmnt;
} else if (month === '01' || month === '02') { // 동절기 청천
winterChungchuDay += 1;
const inflowOne = inflAmnt + sumFlow + returnAmnt;
operList.inFlow.winterSunny += inflAmnt + sumFlow + returnAmnt;
operList.inflAmt.winterSunny += inflAmnt;
operList.sumFlow.winterSunny += sumFlow;
operList.returnFlow.winterSunny += returnAmnt;
operList.efflFlow.winterSunny += efflAmnt;
if (rainEffectDay >= 0) {
// 강우영향일
if (month === '06' || month === '07' || month === '08') { // 하절기 강우영향일
summerRainDay += 1;
operList.inFlow.summerRainy += inflAmnt + sumFlow + returnAmnt;
operList.inflAmt.summerRainy += inflAmnt;
operList.sumFlow.summerRainy += sumFlow;
operList.returnFlow.summerRainy += returnAmnt;
operList.efflFlow.summerRainy += efflAmnt;
}
} else if (rainEffectDay < 0) {
cntSunnyDay += 1; // 청천일수
// 청천시
// chungcunSumFlow += inflAmnt; // 연간 청천 순수하수
operList.inflAmt.yearSunny += inflAmnt; // 연간 청천 순수하수
if (operList.inFlow.winterSunnyMax < inflowOne) operList.inFlow.winterSunnyMax = inflowOne;
if (operList.inflAmt.winterSunnyMax < inflAmnt) operList.inflAmt.winterSunnyMax = inflAmnt;
if (operList.sumFlow.winterSunnyMax < sumFlow) operList.sumFlow.winterSunnyMax = sumFlow;
if (operList.returnFlow.winterSunnyMax < returnAmnt) operList.returnFlow.winterSunnyMax = returnAmnt;
if (operList.efflFlow.winterSunnyMax < efflAmnt) operList.efflFlow.winterSunnyMax = efflAmnt;
if (month === '06' || month === '07' || month === '08') { // 하절기 청천
summerChungchunDay += 1;
operList.inFlow.summerSunny += inflAmnt + sumFlow + returnAmnt;
operList.inflAmt.summerSunny += inflAmnt;
operList.sumFlow.summerSunny += sumFlow;
operList.returnFlow.summerSunny += returnAmnt;
operList.efflFlow.summerSunny += efflAmnt;
} else if (month === '01' || month === '02') { // 동절기 청천
winterChungchuDay += 1;
const inflowOne = inflAmnt + sumFlow + returnAmnt;
operList.inFlow.winterSunny += inflAmnt + sumFlow + returnAmnt;
operList.inflAmt.winterSunny += inflAmnt;
operList.sumFlow.winterSunny += sumFlow;
operList.returnFlow.winterSunny += returnAmnt;
operList.efflFlow.winterSunny += efflAmnt;
if (operList.inFlow.winterSunnyMin > inflowOne) operList.inFlow.winterSunnyMin = inflowOne;
if (operList.inflAmt.winterSunnyMin > inflAmnt) operList.inflAmt.winterSunnyMin = inflAmnt;
if (operList.sumFlow.winterSunnyMin > sumFlow) operList.sumFlow.winterSunnyMin = sumFlow;
if (operList.returnFlow.winterSunnyMin > returnAmnt) operList.returnFlow.winterSunnyMin = returnAmnt;
if (operList.efflFlow.winterSunnyMin > efflAmnt) operList.efflFlow.winterSunnyMin = efflAmnt;
}
}
if (operList.inFlow.winterSunnyMax < inflowOne) operList.inFlow.winterSunnyMax = inflowOne;
if (operList.inflAmt.winterSunnyMax < inflAmnt) operList.inflAmt.winterSunnyMax = inflAmnt;
if (operList.sumFlow.winterSunnyMax < sumFlow) operList.sumFlow.winterSunnyMax = sumFlow;
if (operList.returnFlow.winterSunnyMax < returnAmnt) operList.returnFlow.winterSunnyMax = returnAmnt;
if (operList.efflFlow.winterSunnyMax < efflAmnt) operList.efflFlow.winterSunnyMax = efflAmnt;
const inflowOne = inflAmnt + sumFlow + returnAmnt;
operList.inFlow.yearTot += inflAmnt + sumFlow + returnAmnt;
operList.inflAmt.yearTot += inflAmnt;
operList.sumFlow.yearTot += sumFlow;
operList.returnFlow.yearTot += returnAmnt;
operList.efflFlow.yearTot += efflAmnt;
if (operList.inFlow.yearMax < inflowOne) operList.inFlow.yearMax = inflowOne;
if (operList.inflAmt.yearMax < inflAmnt) operList.inflAmt.yearMax = inflAmnt;
if (operList.sumFlow.yearMax < sumFlow) operList.sumFlow.yearMax = sumFlow;
if (operList.returnFlow.yearMax < returnAmnt) operList.returnFlow.yearMax = returnAmnt;
if (operList.efflFlow.yearMax < efflAmnt) operList.efflFlow.yearMax = efflAmnt;
if (operList.inFlow.yearMin > inflowOne) operList.inFlow.yearMin = inflowOne;
if (operList.inflAmt.yearMin > inflAmnt) operList.inflAmt.yearMin = inflAmnt;
if (operList.sumFlow.yearMin > sumFlow) operList.sumFlow.yearMin = sumFlow;
if (operList.returnFlow.yearMin > returnAmnt) operList.returnFlow.yearMin = returnAmnt;
if (operList.efflFlow.yearMin > efflAmnt) operList.efflFlow.yearMin = efflAmnt;
if (month === '06' || month === '07' || month === '08') {
summerDay += 1;
operList.inFlow.summerTot += inflAmnt + sumFlow + returnAmnt;
operList.inflAmt.summerTot += inflAmnt;
operList.sumFlow.summerTot += sumFlow;
operList.returnFlow.summerTot += returnAmnt;
operList.efflFlow.summerTot += efflAmnt;
} else if (month === '01' || month === '02') {
winterDay += 1;
operList.inFlow.winterTot += inflAmnt + sumFlow + returnAmnt;
operList.inflAmt.winterTot += inflAmnt;
operList.sumFlow.winterTot += sumFlow;
operList.returnFlow.winterTot += returnAmnt;
operList.efflFlow.winterTot += efflAmnt;
}
}); // --일별 유량 end
// 연간 평균
operList.inFlow.yearAvg = (yearDay > 0) ? operList.inFlow.yearTot / yearDay : 0;
operList.inflAmt.yearAvg = (yearDay > 0) ? operList.inflAmt.yearTot / yearDay : 0;
operList.sumFlow.yearAvg = (yearDay > 0) ? operList.sumFlow.yearTot / yearDay : 0;
operList.returnFlow.yearAvg = (yearDay > 0) ? operList.returnFlow.yearTot / yearDay : 0;
operList.efflFlow.yearAvg = (yearDay > 0) ? operList.efflFlow.yearTot / yearDay : 0;
// 하절기 전기간 평균
operList.inFlow.summerAvg = (summerDay > 0) ? operList.inFlow.summerTot / summerDay : 0;
operList.inflAmt.summerAvg = (summerDay > 0) ? operList.inflAmt.summerTot / summerDay : 0;
operList.sumFlow.summerAvg = (summerDay > 0) ? operList.sumFlow.summerTot / summerDay : 0;
operList.returnFlow.summerAvg = (summerDay > 0) ? operList.returnFlow.summerTot / summerDay : 0;
operList.efflFlow.summerAvg = (summerDay > 0) ? operList.efflFlow.summerTot / summerDay : 0;
// 하절기 강우시 평균
operList.inFlow.summerRainy = (summerRainDay > 0) ? operList.inFlow.summerRainy / summerRainDay : 0;
operList.inflAmt.summerRainy = (summerRainDay > 0) ? operList.inflAmt.summerRainy / summerRainDay : 0;
operList.sumFlow.summerRainy = (summerRainDay > 0) ? operList.sumFlow.summerRainy / summerRainDay : 0;
operList.returnFlow.summerRainy = (summerRainDay > 0) ? operList.returnFlow.summerRainy / summerRainDay : 0;
operList.efflFlow.summerRainy = (summerRainDay > 0) ? operList.efflFlow.summerRainy / summerRainDay : 0;
// 하절기 청천시 평균
operList.inFlow.summerSunny = (summerChungchunDay > 0) ? operList.inFlow.summerSunny / summerChungchunDay : 0;
operList.inflAmt.summerSunny = (summerChungchunDay > 0) ? operList.inflAmt.summerSunny / summerChungchunDay : 0;
operList.sumFlow.summerSunny = (summerChungchunDay > 0) ? operList.sumFlow.summerSunny / summerChungchunDay : 0;
operList.returnFlow.summerSunny = (summerChungchunDay > 0) ? operList.returnFlow.summerSunny / summerChungchunDay : 0;
operList.efflFlow.summerSunny = (summerChungchunDay > 0) ? operList.efflFlow.summerSunny / summerChungchunDay : 0;
// 동절기 전기간 평균
operList.inFlow.winterAvg = (winterDay > 0) ? operList.inFlow.winterTot / winterDay : 0;
operList.inflAmt.winterAvg = (winterDay > 0) ? operList.inflAmt.winterTot / winterDay : 0;
operList.sumFlow.winterAvg = (winterDay > 0) ? operList.sumFlow.winterTot / winterDay : 0;
operList.returnFlow.winterAvg = (winterDay > 0) ? operList.returnFlow.winterTot / winterDay : 0;
operList.efflFlow.winterAvg = (winterDay > 0) ? operList.efflFlow.winterTot / winterDay : 0;
// 동절기 청천시 평균
operList.inFlow.winterSunny = (winterChungchuDay > 0) ? operList.inFlow.winterSunny / winterChungchuDay : 0;
operList.inflAmt.winterSunny = (winterChungchuDay > 0) ? operList.inflAmt.winterSunny / winterChungchuDay : 0;
operList.sumFlow.winterSunny = (winterChungchuDay > 0) ? operList.sumFlow.winterSunny / winterChungchuDay : 0;
operList.returnFlow.winterSunny = (winterChungchuDay > 0) ? operList.returnFlow.winterSunny / winterChungchuDay : 0;
operList.efflFlow.winterSunny = (winterChungchuDay > 0) ? operList.efflFlow.winterSunny / winterChungchuDay : 0;
// 연간 유입 평균 = 하수유입량(순수하수유입량) + 연계처리량 + 반류수유량(m³/일)
operationalStatusList[0].yearAvg = roundUp(operList.inFlow.yearAvg, 0); // 연간 유입 평균 = 하수유입량(순수하수유입량) + 연계처리량 + 반류수유량(m³/일)
operationalStatusList[0].yearMax = roundUp(operList.inFlow.yearMax, 0); // 연간 유입 최대
operationalStatusList[0].yearMin = roundUp(operList.inFlow.yearMin, 0); // 연간 유입 최소
operationalStatusList[0].summerAll = roundUp(operList.inFlow.summerAvg, 0); // 하절기 유입 전기간
operationalStatusList[0].summerThree = roundUp(operList.inFlow.summerRainy, 0); // 하절기 유입 강우시(강우영향일)
operationalStatusList[0].summerRain = roundUp(operList.inFlow.summerSunny, 0); // 하절기 유입 청천시
operationalStatusList[0].winterAll = roundUp(operList.inFlow.winterAvg, 0); // 동절기 유입 전기간
operationalStatusList[0].winterSunnyMin = roundUp(operList.inFlow.winterSunnyMin, 0); // 동절기 유입 최소
operationalStatusList[0].winterSunnyMax = roundUp(operList.inFlow.winterSunnyMax, 0); // 동절기 유입 최대
operationalStatusList[0].winterSunnyAvg = roundUp(operList.inFlow.winterAvg, 0); // 동절기 유입 평균
// 청천시 유입(순수하수) 평균
const usage = operList.inflAmt.yearSunny / cntSunnyDay; // 연간 청천 순수하수 평균
const summerUsage = operList.inflAmt.summerSunny; // 하절기 청천 순수하수 평균
const winterUsage = operList.inflAmt.winterSunny; // 동절기 청천 순수하수 평균
// 물사용량 = 유입평균 * 0.65
const wtrUsg = operList.inflAmt.yearAvg * 0.65; // 연간 물사용량 평균
const wtrUsgSummer = operList.inflAmt.summerAvg * 0.65; // 하절기 물사용량 평균
const wtrUsgWinter = operList.inflAmt.winterAvg * 0.65; // 동절기 물사용량 평균
// 지하수유입량
operationalStatusList[0].groundWaterAvg = Math.round((usage - (wtrUsg * OSU_PERCENT)) * 100) / 100;
operationalStatusList[0].groundWaterSummer = Math.round((summerUsage - (wtrUsgSummer * OSU_PERCENT)) * 100) / 100;
operationalStatusList[0].groundWaterWinter = Math.round((winterUsage - (wtrUsgWinter * OSU_PERCENT)) * 100) / 100;
// 오염물질
// RDII 추정 = 하절기(6~8월) 중 최저 유입 BOD일때 유입유량 x ((동절기 청천시 유입BOD - 하절기(6~8월) 중 최저 유입BOD) / (동절기 청천시 유입BOD))
// const resp = await fetchMainGraph(searchYear, fcltyCd);
const resp = mainGraphData;
if (resp && resp.data && resp.data.wqltObjs && resp.data.wqltObjs.length > 0) {
const wqltData = resp.data.wqltObjs;
const wqltDataTot = CalcRainEffect(clone(wqltData));
const wqltDataSunny = CalcRainEffect(clone(wqltData), 'SUNNY');
let minSummerBod = 99999999;
let minSummerBodInfl = 99999999;
let winterCnt = 0;
let winterBodSunny = 0;
let rdiRain = 0;
const summerMonth = ['06', '07', '08'];
const winterMonth = ['01', '02'];
wqltDataTot.filter(item => summerMonth.includes(item.msrDt.toString().replaceAll('-', '').substring(4, 6))).forEach(item2 => {
if (Number(item2.infoRnDay) >= 3) { // 3mm 이상 강우일
const inflBod = Number(item2.inflAssctBfrWqltBod); //유입연계전수질_BOD(mg/L)
const infl = Number(item2.inflAmnt); //실제유입량(반류수제거)(m³/일)
const rain = Number(item2.infoRnDay); //강우량
if (inflBod < minSummerBod) {
minSummerBodInfl = infl;
minSummerBod = inflBod;
rdiRain = rain; // 하절기 최소 bod일때의 일강수량
if (operList.inFlow.winterSunnyMin > inflowOne) operList.inFlow.winterSunnyMin = inflowOne;
if (operList.inflAmt.winterSunnyMin > inflAmnt) operList.inflAmt.winterSunnyMin = inflAmnt;
if (operList.sumFlow.winterSunnyMin > sumFlow) operList.sumFlow.winterSunnyMin = sumFlow;
if (operList.returnFlow.winterSunnyMin > returnAmnt) operList.returnFlow.winterSunnyMin = returnAmnt;
if (operList.efflFlow.winterSunnyMin > efflAmnt) operList.efflFlow.winterSunnyMin = efflAmnt;
}
}
});
wqltDataSunny.filter(item => winterMonth.includes(item.msrDt.toString().replaceAll('-', '').substring(4, 6))).forEach(item2 => {
winterBodSunny += Number(item2.inflAssctBfrWqltBod); // 동절기 청천시 유입BOD(mg/L)
winterCnt += 1;
});
const inflowOne = inflAmnt + sumFlow + returnAmnt;
operList.inFlow.yearTot += inflAmnt + sumFlow + returnAmnt;
operList.inflAmt.yearTot += inflAmnt;
operList.sumFlow.yearTot += sumFlow;
operList.returnFlow.yearTot += returnAmnt;
operList.efflFlow.yearTot += efflAmnt;
const roundMinSummerBodInfl = Number(roundNumber(minSummerBodInfl, 0).toString().replaceAll(',', ''));
const roundMinSummerBod = Number(roundNumber(minSummerBod, 1).toString().replaceAll(',', ''));
const roundWinterBodSunny = Number(roundNumber(winterBodSunny, 1).toString().replaceAll(',', ''));
if (operList.inFlow.yearMax < inflowOne) operList.inFlow.yearMax = inflowOne;
if (operList.inflAmt.yearMax < inflAmnt) operList.inflAmt.yearMax = inflAmnt;
if (operList.sumFlow.yearMax < sumFlow) operList.sumFlow.yearMax = sumFlow;
if (operList.returnFlow.yearMax < returnAmnt) operList.returnFlow.yearMax = returnAmnt;
if (operList.efflFlow.yearMax < efflAmnt) operList.efflFlow.yearMax = efflAmnt;
const winterBodAvg = Number(roundNumber((roundWinterBodSunny / winterCnt), 1).toString().replaceAll(',', ''));
// 하절기(6~8월) 중 최저 유입 BOD일때 유입유량 x ((동절기 청천시 유입BOD - 하절기(6~8월) 중 최저 유입BOD) / (동절기 청천시 유입BOD))
const winMinusSum = winterBodAvg - roundMinSummerBod;
if (operList.inFlow.yearMin > inflowOne) operList.inFlow.yearMin = inflowOne;
if (operList.inflAmt.yearMin > inflAmnt) operList.inflAmt.yearMin = inflAmnt;
if (operList.sumFlow.yearMin > sumFlow) operList.sumFlow.yearMin = sumFlow;
if (operList.returnFlow.yearMin > returnAmnt) operList.returnFlow.yearMin = returnAmnt;
if (operList.efflFlow.yearMin > efflAmnt) operList.efflFlow.yearMin = efflAmnt;
const rdiValue = winMinusSum === 0 ? 0 : roundMinSummerBodInfl * (winMinusSum / winterBodAvg);
if (month === '06' || month === '07' || month === '08') {
summerDay += 1;
operList.inFlow.summerTot += inflAmnt + sumFlow + returnAmnt;
operList.inflAmt.summerTot += inflAmnt;
operList.sumFlow.summerTot += sumFlow;
operList.returnFlow.summerTot += returnAmnt;
operList.efflFlow.summerTot += efflAmnt;
} else if (month === '01' || month === '02') {
winterDay += 1;
operList.inFlow.winterTot += inflAmnt + sumFlow + returnAmnt;
operList.inflAmt.winterTot += inflAmnt;
operList.sumFlow.winterTot += sumFlow;
operList.returnFlow.winterTot += returnAmnt;
operList.efflFlow.winterTot += efflAmnt;
}
}); // --일별 유량 end
rdiPercent = (rdiValue / minSummerBodInfl) * 100;
// 연간 평균
operList.inFlow.yearAvg = (yearDay > 0) ? operList.inFlow.yearTot / yearDay : 0;
operList.inflAmt.yearAvg = (yearDay > 0) ? operList.inflAmt.yearTot / yearDay : 0;
operList.sumFlow.yearAvg = (yearDay > 0) ? operList.sumFlow.yearTot / yearDay : 0;
operList.returnFlow.yearAvg = (yearDay > 0) ? operList.returnFlow.yearTot / yearDay : 0;
operList.efflFlow.yearAvg = (yearDay > 0) ? operList.efflFlow.yearTot / yearDay : 0;
// 하절기 전기간 평균
operList.inFlow.summerAvg = (summerDay > 0) ? operList.inFlow.summerTot / summerDay : 0;
operList.inflAmt.summerAvg = (summerDay > 0) ? operList.inflAmt.summerTot / summerDay : 0;
operList.sumFlow.summerAvg = (summerDay > 0) ? operList.sumFlow.summerTot / summerDay : 0;
operList.returnFlow.summerAvg = (summerDay > 0) ? operList.returnFlow.summerTot / summerDay : 0;
operList.efflFlow.summerAvg = (summerDay > 0) ? operList.efflFlow.summerTot / summerDay : 0;
// 하절기 강우시 평균
operList.inFlow.summerRainy = (summerRainDay > 0) ? operList.inFlow.summerRainy / summerRainDay : 0;
operList.inflAmt.summerRainy = (summerRainDay > 0) ? operList.inflAmt.summerRainy / summerRainDay : 0;
operList.sumFlow.summerRainy = (summerRainDay > 0) ? operList.sumFlow.summerRainy / summerRainDay : 0;
operList.returnFlow.summerRainy = (summerRainDay > 0) ? operList.returnFlow.summerRainy / summerRainDay : 0;
operList.efflFlow.summerRainy = (summerRainDay > 0) ? operList.efflFlow.summerRainy / summerRainDay : 0;
// 하절기 청천시 평균
operList.inFlow.summerSunny = (summerChungchunDay > 0) ? operList.inFlow.summerSunny / summerChungchunDay : 0;
operList.inflAmt.summerSunny = (summerChungchunDay > 0) ? operList.inflAmt.summerSunny / summerChungchunDay : 0;
operList.sumFlow.summerSunny = (summerChungchunDay > 0) ? operList.sumFlow.summerSunny / summerChungchunDay : 0;
operList.returnFlow.summerSunny = (summerChungchunDay > 0) ? operList.returnFlow.summerSunny / summerChungchunDay : 0;
operList.efflFlow.summerSunny = (summerChungchunDay > 0) ? operList.efflFlow.summerSunny / summerChungchunDay : 0;
// 동절기 전기간 평균
operList.inFlow.winterAvg = (winterDay > 0) ? operList.inFlow.winterTot / winterDay : 0;
operList.inflAmt.winterAvg = (winterDay > 0) ? operList.inflAmt.winterTot / winterDay : 0;
operList.sumFlow.winterAvg = (winterDay > 0) ? operList.sumFlow.winterTot / winterDay : 0;
operList.returnFlow.winterAvg = (winterDay > 0) ? operList.returnFlow.winterTot / winterDay : 0;
operList.efflFlow.winterAvg = (winterDay > 0) ? operList.efflFlow.winterTot / winterDay : 0;
// 동절기 청천시 평균
operList.inFlow.winterSunny = (winterChungchuDay > 0) ? operList.inFlow.winterSunny / winterChungchuDay : 0;
operList.inflAmt.winterSunny = (winterChungchuDay > 0) ? operList.inflAmt.winterSunny / winterChungchuDay : 0;
operList.sumFlow.winterSunny = (winterChungchuDay > 0) ? operList.sumFlow.winterSunny / winterChungchuDay : 0;
operList.returnFlow.winterSunny = (winterChungchuDay > 0) ? operList.returnFlow.winterSunny / winterChungchuDay : 0;
operList.efflFlow.winterSunny = (winterChungchuDay > 0) ? operList.efflFlow.winterSunny / winterChungchuDay : 0;
operationalStatusList[0].rdi = rdiValue; // RDII 추정
operationalStatusList[0].rdiRain = rdiRain; // RDII 추정시 일강수량(mm)
// 연간 유입 평균 = 하수유입량(순수하수유입량) + 연계처리량 + 반류수유량(m³/일)
operationalStatusList[0].yearAvg = roundUp(operList.inFlow.yearAvg, 0); // 연간 유입 평균 = 하수유입량(순수하수유입량) + 연계처리량 + 반류수유량(m³/일)
operationalStatusList[0].yearMax = roundUp(operList.inFlow.yearMax, 0); // 연간 유입 최대
operationalStatusList[0].yearMin = roundUp(operList.inFlow.yearMin, 0); // 연간 유입 최소
operationalStatusList[0].summerAll = roundUp(operList.inFlow.summerAvg, 0); // 하절기 유입 전기간
operationalStatusList[0].summerThree = roundUp(operList.inFlow.summerRainy, 0); // 하절기 유입 강우시(강우영향일)
operationalStatusList[0].summerRain = roundUp(operList.inFlow.summerSunny, 0); // 하절기 유입 청천시
operationalStatusList[0].winterAll = roundUp(operList.inFlow.winterAvg, 0); // 동절기 유입 전기간
operationalStatusList[0].winterSunnyMin = roundUp(operList.inFlow.winterSunnyMin, 0); // 동절기 유입 최소
operationalStatusList[0].winterSunnyMax = roundUp(operList.inFlow.winterSunnyMax, 0); // 동절기 유입 최대
operationalStatusList[0].winterSunnyAvg = roundUp(operList.inFlow.winterAvg, 0); // 동절기 유입 평균
// 청천시 유입(순수하수) 평균
const usage = operList.inflAmt.yearSunny / cntSunnyDay; // 연간 청천 순수하수 평균
const summerUsage = operList.inflAmt.summerSunny; // 하절기 청천 순수하수 평균
const winterUsage = operList.inflAmt.winterSunny; // 동절기 청천 순수하수 평균
// 물사용량 = 유입평균 * 0.65
const wtrUsg = operList.inflAmt.yearAvg * 0.65; // 연간 물사용량 평균
const wtrUsgSummer = operList.inflAmt.summerAvg * 0.65; // 하절기 물사용량 평균
const wtrUsgWinter = operList.inflAmt.winterAvg * 0.65; // 동절기 물사용량 평균
// 지하수유입량
operationalStatusList[0].groundWaterAvg = Math.round((usage - (wtrUsg * OSU_PERCENT)) * 100) / 100;
operationalStatusList[0].groundWaterSummer = Math.round((summerUsage - (wtrUsgSummer * OSU_PERCENT)) * 100) / 100;
operationalStatusList[0].groundWaterWinter = Math.round((winterUsage - (wtrUsgWinter * OSU_PERCENT)) * 100) / 100;
// 오염물질
// RDII 추정 = 하절기(6~8월) 중 최저 유입 BOD일때 유입유량 x ((동절기 청천시 유입BOD - 하절기(6~8월) 중 최저 유입BOD) / (동절기 청천시 유입BOD))
// const resp = await fetchMainGraph(searchYear, fcltyCd);
const resp = mainGraphData;
if (resp && resp.data && resp.data.wqltObjs && resp.data.wqltObjs.length > 0) {
const wqltData = resp.data.wqltObjs;
const wqltDataTot = CalcRainEffect(clone(wqltData));
const wqltDataSunny = CalcRainEffect(clone(wqltData), 'SUNNY');
let minSummerBod = 99999999;
let minSummerBodInfl = 99999999;
let winterCnt = 0;
let winterBodSunny = 0;
let rdiRain = 0;
const summerMonth = ['06', '07', '08'];
const winterMonth = ['01', '02'];
wqltDataTot.filter(item => summerMonth.includes(item.msrDt.toString().replaceAll('-', '').substring(4, 6))).forEach(item2 => {
if (Number(item2.infoRnDay) >= 3) { // 3mm 이상 강우일
const inflBod = Number(item2.inflAssctBfrWqltBod); //유입연계전수질_BOD(mg/L)
const infl = Number(item2.inflAmnt); //실제유입량(반류수제거)(m³/일)
const rain = Number(item2.infoRnDay); //강우량
if (inflBod < minSummerBod) {
minSummerBodInfl = infl;
minSummerBod = inflBod;
rdiRain = rain; // 하절기 최소 bod일때의 일강수량
}
}
});
wqltDataSunny.filter(item => winterMonth.includes(item.msrDt.toString().replaceAll('-', '').substring(4, 6))).forEach(item2 => {
winterBodSunny += Number(item2.inflAssctBfrWqltBod); // 동절기 청천시 유입BOD(mg/L)
winterCnt += 1;
});
const roundMinSummerBodInfl = Number(roundNumber(minSummerBodInfl, 0).toString().replaceAll(',', ''));
const roundMinSummerBod = Number(roundNumber(minSummerBod, 1).toString().replaceAll(',', ''));
const roundWinterBodSunny = Number(roundNumber(winterBodSunny, 1).toString().replaceAll(',', ''));
const winterBodAvg = Number(roundNumber((roundWinterBodSunny / winterCnt), 1).toString().replaceAll(',', ''));
// 하절기(6~8월) 중 최저 유입 BOD일때 유입유량 x ((동절기 청천시 유입BOD - 하절기(6~8월) 중 최저 유입BOD) / (동절기 청천시 유입BOD))
const winMinusSum = winterBodAvg - roundMinSummerBod;
const rdiValue = winMinusSum === 0 ? 0 : roundMinSummerBodInfl * (winMinusSum / winterBodAvg);
rdiPercent = (rdiValue / minSummerBodInfl) * 100;
operationalStatusList[0].rdi = rdiValue; // RDII 추정
operationalStatusList[0].rdiRain = rdiRain; // RDII 추정시 일강수량(mm)
}
}
if (operationalStatusList[0] && operationalStatusList[7]) {
// operationalStatusList[7].groundWaterAvg = operationalStatusList[0].groundWaterAvg === null ? '' : operList.inFlow.yearTot && data.yearData.AVG_INFL_AMNT === 0 ? '' : Math.round((Number(operationalStatusList[0].groundWaterAvg.toString().replaceAll(',', '')) / (data.yearData && data.yearData.AVG_INFL_AMNT ? Number(data.yearData.AVG_INFL_AMNT.toString().replaceAll(',', '')) : 0) * 100) * 10) / 10 + '%';
// operationalStatusList[7].groundWaterSummer = operationalStatusList[0].groundWaterSummer === null ? '' : data.summer && data.summer.AVG_INFL_AMNT === 0 ? '' : Math.round((Number(operationalStatusList[0].groundWaterSummer.toString().replaceAll(',', '')) / (data.summer && data.summer.AVG_INFL_AMNT ? Number(data.summer.AVG_INFL_AMNT.toString().replaceAll(',', '')) : 0) * 100) * 10) / 10 + '%';
// operationalStatusList[7].groundWaterWinter = operationalStatusList[0].groundWaterWinter === null ? '' : data.winter && data.winter.AVG_INFL_AMNT === 0 ? '' : Math.round((Number(operationalStatusList[0].groundWaterWinter.toString().replaceAll(',', '')) / (data.winter && data.winter.AVG_INFL_AMNT ? Number(data.winter.AVG_INFL_AMNT.toString().replaceAll(',', '')) : 0) * 100) * 10) / 10 + '%';
operationalStatusList[7].groundWaterAvg = operList.inflAmt.yearAvg === 0 ? '' : Math.round((Number(operationalStatusList[0].groundWaterAvg.toString().replaceAll(',', '')) / operList.inflAmt.yearAvg * 100) * 10) / 10 + '%';
operationalStatusList[7].groundWaterSummer = operList.inflAmt.summerAvg === 0 ? '' : Math.round((Number(operationalStatusList[0].groundWaterSummer.toString().replaceAll(',', '')) / operList.inflAmt.summerAvg * 100) * 10) / 10 + '%';
operationalStatusList[7].groundWaterWinter = operList.inflAmt.winterAvg === 0 ? '' : Math.round((Number(operationalStatusList[0].groundWaterWinter.toString().replaceAll(',', '')) / operList.inflAmt.winterAvg * 100) * 10) / 10 + '%';
operationalStatusList[7].rdi = roundNumber(rdiPercent, 1) + '%';
}
// 순수하수량(1), 연계처리수(2), 총인설비방류수(3), 방류수(4) 데이터 매핑
const flowMappings = [
{ index: 0, source: operList.inFlow },
{ index: 1, source: operList.inflAmt },
{ index: 2, source: operList.sumFlow },
{ index: 3, source: operList.returnFlow },
{ index: 4, source: operList.efflFlow },
];
flowMappings.forEach(({ index, source }) => {
const item = operationalStatusList[index];
if (item) {
item.yearAvg = source.yearAvg;
item.yearMax = source.yearMax;
item.yearMin = source.yearMin;
item.summerAll = source.summerAvg;
item.summerThree = source.summerRainy;
item.summerRain = source.summerSunny;
item.winterSunnyAvg = source.winterSunny;
item.winterSunnyMax = source.winterSunnyMax;
item.winterSunnyMin = source.winterSunnyMin;
item.winterAll = source.winterAvg;
dataFormSetting(item);
}
});
}
if (operationalStatusList[0] && operationalStatusList[7]) {
// operationalStatusList[7].groundWaterAvg = operationalStatusList[0].groundWaterAvg === null ? '' : operList.inFlow.yearTot && data.yearData.AVG_INFL_AMNT === 0 ? '' : Math.round((Number(operationalStatusList[0].groundWaterAvg.toString().replaceAll(',', '')) / (data.yearData && data.yearData.AVG_INFL_AMNT ? Number(data.yearData.AVG_INFL_AMNT.toString().replaceAll(',', '')) : 0) * 100) * 10) / 10 + '%';
// operationalStatusList[7].groundWaterSummer = operationalStatusList[0].groundWaterSummer === null ? '' : data.summer && data.summer.AVG_INFL_AMNT === 0 ? '' : Math.round((Number(operationalStatusList[0].groundWaterSummer.toString().replaceAll(',', '')) / (data.summer && data.summer.AVG_INFL_AMNT ? Number(data.summer.AVG_INFL_AMNT.toString().replaceAll(',', '')) : 0) * 100) * 10) / 10 + '%';
// operationalStatusList[7].groundWaterWinter = operationalStatusList[0].groundWaterWinter === null ? '' : data.winter && data.winter.AVG_INFL_AMNT === 0 ? '' : Math.round((Number(operationalStatusList[0].groundWaterWinter.toString().replaceAll(',', '')) / (data.winter && data.winter.AVG_INFL_AMNT ? Number(data.winter.AVG_INFL_AMNT.toString().replaceAll(',', '')) : 0) * 100) * 10) / 10 + '%';
operationalStatusList[7].groundWaterAvg = operList.inflAmt.yearAvg === 0 ? '' : Math.round((Number(operationalStatusList[0].groundWaterAvg.toString().replaceAll(',', '')) / operList.inflAmt.yearAvg * 100) * 10) / 10 + '%';
operationalStatusList[7].groundWaterSummer = operList.inflAmt.summerAvg === 0 ? '' : Math.round((Number(operationalStatusList[0].groundWaterSummer.toString().replaceAll(',', '')) / operList.inflAmt.summerAvg * 100) * 10) / 10 + '%';
operationalStatusList[7].groundWaterWinter = operList.inflAmt.winterAvg === 0 ? '' : Math.round((Number(operationalStatusList[0].groundWaterWinter.toString().replaceAll(',', '')) / operList.inflAmt.winterAvg * 100) * 10) / 10 + '%';
operationalStatusList[7].rdi = roundNumber(rdiPercent, 1) + '%';
const rtnData = await calcWaterQltyData(operationalStatusList, searchYear, fcltyCd, mainGraphData); // 수질 데이터 청천시, 강우시 재계산
let tpFctYn = 'N';
if (mainGraphData.data.wqltObjs && mainGraphData.data.wqltObjs.length > 0)
tpFctYn = mainGraphData.data.wqltObjs?.[0].tpFctYn;
// 총인설비가 없을 경우 제외
console.log('총인시설 여부 : ', tpFctYn);
// console.log('rtnData : ', rtnData);
if (tpFctYn !== 'Y') {
operationalStatusList = rtnData.slice(0, 11);
} else {
operationalStatusList = rtnData;
}
// 순수하수량(1), 연계처리수(2), 총인설비방류수(3), 방류수(4) 데이터 매핑
const flowMappings = [
{ index: 0, source: operList.inFlow },
{ index: 1, source: operList.inflAmt },
{ index: 2, source: operList.sumFlow },
{ index: 3, source: operList.returnFlow },
{ index: 4, source: operList.efflFlow },
];
flowMappings.forEach(({ index, source }) => {
const item = operationalStatusList[index];
if (item) {
item.yearAvg = source.yearAvg;
item.yearMax = source.yearMax;
item.yearMin = source.yearMin;
item.summerAll = source.summerAvg;
item.summerThree = source.summerRainy;
item.summerRain = source.summerSunny;
item.winterSunnyAvg = source.winterSunny;
item.winterSunnyMax = source.winterSunnyMax;
item.winterSunnyMin = source.winterSunnyMin;
item.winterAll = source.winterAvg;
dataFormSetting(item);
}
});
set((state: DashBoardType) => ({
...state,
OperationStatus: {
...state.OperationStatus,
operationalStatusList: operationalStatusList,
operationalStatusCount: 0,
},
}))
} catch (error) {
console.error('시설정보 운영실태 처리 중 오류가 발생했습니다:', error);
} finally {
// 성공/실패와 관계없이 로딩 오버레이를 해제한다.
set((state: DashBoardType) => ({
...state,
OperationStatus: {
...state.OperationStatus,
isLoadingOperationStatus: false,
},
}));
}
const rtnData = await calcWaterQltyData(operationalStatusList, searchYear, fcltyCd, mainGraphData); // 수질 데이터 청천시, 강우시 재계산
let tpFctYn = 'N';
if (mainGraphData.data.wqltObjs && mainGraphData.data.wqltObjs.length > 0)
tpFctYn = mainGraphData.data.wqltObjs?.[0].tpFctYn;
// 총인설비가 없을 경우 제외
console.log('총인시설 여부 : ', tpFctYn);
// console.log('rtnData : ', rtnData);
if (tpFctYn !== 'Y') {
operationalStatusList = rtnData.slice(0, 11);
} else {
operationalStatusList = rtnData;
}
set((state: DashBoardType) => ({
...state,
OperationStatus: {
...state.OperationStatus,
operationalStatusList: operationalStatusList,
operationalStatusCount: 0,
isLoadingOperationStatus: false,
},
}))
},
searchMainGraph: async (searchYear: string, fcltyCd: string) => {