|
|
|
@@ -21,6 +21,21 @@ export type SewageOccurDetailProps = {
|
|
|
|
|
sumWtrUsg: number, // 물사용량 합
|
|
|
|
|
avgWtrUsg: number, // 일평균 물사용량
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export type UnderWaterRow = {
|
|
|
|
|
bscFctCd: string;
|
|
|
|
|
inflYear: number; // 연간 하수유입량(m³/일)
|
|
|
|
|
inflSummer: number; // 하절기 하수유입량(m³/일)
|
|
|
|
|
inflWinter: number; // 동절기 하수유입량(m³/일)
|
|
|
|
|
inflSunny: number; // 청천시 연간 하수유입량(m³/일)
|
|
|
|
|
inflSunnySummer: number; // 청천시 하절기 하수유입량(m³/일)
|
|
|
|
|
inflSunnyWinter: number; // 청천시 동절기 하수유입량(m³/일)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export type UnderWaterResponse = {
|
|
|
|
|
status?: number;
|
|
|
|
|
data?: UnderWaterRow[];
|
|
|
|
|
}
|
|
|
|
|
/**====================================
|
|
|
|
|
* Store - 타입
|
|
|
|
|
====================================*/
|
|
|
|
@@ -217,12 +232,12 @@ const fetchUnderWaterList = async (pageNo: number, pageSize: number, searchYear:
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// 시설들 유량 정보 조회
|
|
|
|
|
export const fetchDetailListFlow = async (searchYear: string | undefined, fcltCdList: string[]): Promise<UnderWaterProps | null> => {
|
|
|
|
|
export const fetchDetailListFlow = async (searchYear: string | undefined, fcltCdList: string[]): Promise<UnderWaterResponse | null> => {
|
|
|
|
|
try {
|
|
|
|
|
const res = await postFetch('fo', '/fclt/flow/' + searchYear, fcltCdList);
|
|
|
|
|
const res = await postFetch('fo', '/fclt/flow/underWater/' + searchYear, fcltCdList);
|
|
|
|
|
return res;
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error('시설정보 오수발생량 상세 데이터를 가져오는데 실패했습니다:', error);
|
|
|
|
|
console.error('시설정보 지하수 유입량 데이터를 가져오는데 실패했습니다:', error);
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
@@ -373,35 +388,44 @@ export const underWaterReducer: (set: (fn: (state: UnderWaterType) => UnderWater
|
|
|
|
|
lgbsn: item.lgbsn,
|
|
|
|
|
mdmbsn: item.mdmbsn,
|
|
|
|
|
msrDt: '',
|
|
|
|
|
inflSummer: 0,
|
|
|
|
|
inflWinter: 0,
|
|
|
|
|
inflSunny: 0,
|
|
|
|
|
inflSunnySummer: 0,
|
|
|
|
|
inflSunnyWinter: 0,
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// const soccurDetailRes: any = await fetchDetailListFlow(searchYear, fcltCdList);
|
|
|
|
|
// const wtrUsgYmRes: any = await fetchWtrUsgYmList(searchYear, fcltCdList);
|
|
|
|
|
//---------
|
|
|
|
|
const rainDetailList: Record<string, any[]> = {};
|
|
|
|
|
const underWaterMap = new Map(
|
|
|
|
|
underWaterPropsList.map((item) => [item.bscFctCd, item])
|
|
|
|
|
);
|
|
|
|
|
// const rainDetailList: Record<string, any[]> = {};
|
|
|
|
|
const wtrDetailList: Record<string, any[]> = {};
|
|
|
|
|
const results: any[] = [];
|
|
|
|
|
const wtrResults: any[] = [];
|
|
|
|
|
for (let idx = 0; idx < fcltCdList.length; idx += 100) {
|
|
|
|
|
const slicedItems = fcltCdList.slice(idx, idx + 100);
|
|
|
|
|
const result = await fetchDetailListFlow(searchYear, slicedItems);
|
|
|
|
|
const wtrResult = await fetchWtrUsgYmList(searchYear, slicedItems);
|
|
|
|
|
results.push(result);
|
|
|
|
|
|
|
|
|
|
if (result?.status === 200 && Array.isArray(result.data)) {
|
|
|
|
|
result.data.forEach((row: any) => {
|
|
|
|
|
const bscFctCd = String(row.bscFctCd ?? "");
|
|
|
|
|
const target = underWaterMap.get(bscFctCd);
|
|
|
|
|
|
|
|
|
|
if (!target) return;
|
|
|
|
|
|
|
|
|
|
target.inflAmnt = Number(row.inflYear ?? 0); // 연평균 유입하수량(m³/일)
|
|
|
|
|
target.inflSummer = Number(row.inflSummer ?? 0); // 하절기 유입하수량(m³/일)
|
|
|
|
|
target.inflWinter = Number(row.inflWinter ?? 0); // 동절기 유입하수량(m³/일)
|
|
|
|
|
target.inflSunny = Number(row.inflSunny ?? 0); // 청천시 연간 유입하수량(m³/일)
|
|
|
|
|
target.inflSunnySummer = Number(row.inflSunnySummer ?? 0); // 청천시 하절기 유입하수량(m³/일)
|
|
|
|
|
target.inflSunnyWinter = Number(row.inflSunnyWinter ?? 0); // 청천시 동절기 유입하수량(m³/일)
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
wtrResults.push(wtrResult);
|
|
|
|
|
}
|
|
|
|
|
//console.log(results);
|
|
|
|
|
// 결과를 합치기
|
|
|
|
|
for (const res of results) {
|
|
|
|
|
if (res.status === 200 && res.data) {
|
|
|
|
|
for (const [key, value] of Object.entries(res.data)) {
|
|
|
|
|
const keyStr = String(key);
|
|
|
|
|
//rainDetailList[keyStr] = [...(rainDetailList[keyStr] || []), ...(value as any[])];
|
|
|
|
|
if (!rainDetailList[keyStr]) rainDetailList[keyStr] = [];
|
|
|
|
|
rainDetailList[keyStr].push(...(value as any[]));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// console.log(underWaterMap);
|
|
|
|
|
|
|
|
|
|
for (const res of wtrResults) {
|
|
|
|
|
if (res.status === 200 && res.data) {
|
|
|
|
|
for (const [key, value] of Object.entries(res.data)) {
|
|
|
|
@@ -414,65 +438,11 @@ export const underWaterReducer: (set: (fn: (state: UnderWaterType) => UnderWater
|
|
|
|
|
}
|
|
|
|
|
//-------
|
|
|
|
|
for (const item of underWaterPropsList) {
|
|
|
|
|
|
|
|
|
|
// const detailList = soccurDetailRes?.data[item.bscFctCd];
|
|
|
|
|
// const wtrUsgYmList = wtrUsgYmRes?.data[item.bscFctCd];
|
|
|
|
|
const detailList = rainDetailList[item.bscFctCd];
|
|
|
|
|
const wtrUsgYmList = wtrDetailList[item.bscFctCd];
|
|
|
|
|
|
|
|
|
|
let chungcunSumFlow = 0; // 청천유입량
|
|
|
|
|
let sumChungcunDay = 0; // 청천일수
|
|
|
|
|
let sumSummerChungcunDay = 0; // 하절기 청천일수
|
|
|
|
|
let sumSummerChungcunFlow = 0; // 하절기 청천유입량
|
|
|
|
|
let sumWinterChungcunDay = 0; // 동절기 청천일수
|
|
|
|
|
let sumWinterChungcunFlow = 0; // 동절기 청천유입량
|
|
|
|
|
let totWaterUsage = 0; // 연간 하수유입량
|
|
|
|
|
let totSummerUsage = 0; // 하절기 하수유입량
|
|
|
|
|
let totWinterUsage = 0; // 동절기 하수유입량
|
|
|
|
|
let totSummerDays = 0; // 하절기 일수
|
|
|
|
|
let totWinterDays = 0; // 동절기 일수
|
|
|
|
|
|
|
|
|
|
const summerMonth = ['06', '07', '08'];
|
|
|
|
|
const winterMonth = ['01', '02'];
|
|
|
|
|
|
|
|
|
|
let rainEffectDay = 0;
|
|
|
|
|
detailList?.forEach(item2 => {
|
|
|
|
|
|
|
|
|
|
if (item2.infoRnDay == null || item2.infoRnDay.trim() == 'x') item2.infoRnDay = 0;
|
|
|
|
|
if (Number(item2.infoRnDay) >= 3) {
|
|
|
|
|
rainEffectDay = 2;
|
|
|
|
|
} else {
|
|
|
|
|
rainEffectDay--;
|
|
|
|
|
}
|
|
|
|
|
if (rainEffectDay < 0) { //청천시
|
|
|
|
|
chungcunSumFlow += Number(item2.inflAmnt);
|
|
|
|
|
sumChungcunDay += 1;
|
|
|
|
|
|
|
|
|
|
if (item2.msrDt.substring(4, 6) === '06' || item2.msrDt.substring(4, 6) === '07' || item2.msrDt.substring(4, 6) === '08') {
|
|
|
|
|
// 하절기 6,7,8월
|
|
|
|
|
sumSummerChungcunDay += 1;
|
|
|
|
|
sumSummerChungcunFlow += Number(item2.inflAmnt); //item2.inflAmnt && item2.inflAmnt !== 'x' ? Number(item2.inflAmnt.toString().trim()) : 0;
|
|
|
|
|
} else if (item2.msrDt.substring(4, 6) === '01' || item2.msrDt.substring(4, 6) === '02') {
|
|
|
|
|
// 동절기 1,2월
|
|
|
|
|
sumWinterChungcunDay += 1;
|
|
|
|
|
sumWinterChungcunFlow += Number(item2.inflAmnt); //item2.inflAmnt && item2.inflAmnt !== 'x' ? Number(item2.inflAmnt.toString().trim()) : 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
totWaterUsage += Number(item2.inflAmnt);
|
|
|
|
|
if (item2.msrDt.substring(4, 6) === '06' || item2.msrDt.substring(4, 6) === '07' || item2.msrDt.substring(4, 6) === '08') {
|
|
|
|
|
// 하절기 6,7,8월
|
|
|
|
|
totSummerDays += 1;
|
|
|
|
|
totSummerUsage += Number(item2.inflAmnt); //item2.inflAmnt && item2.inflAmnt !== 'x' ? Number(item2.inflAmnt.toString().trim()) : 0;
|
|
|
|
|
} else if (item2.msrDt.substring(4, 6) === '01' || item2.msrDt.substring(4, 6) === '02') {
|
|
|
|
|
// 동절기 1,2월
|
|
|
|
|
totWinterDays += 1;
|
|
|
|
|
totWinterUsage += Number(item2.inflAmnt); //item2.inflAmnt && item2.inflAmnt !== 'x' ? Number(item2.inflAmnt.toString().trim()) : 0;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const count = detailList ? detailList.length : 0;
|
|
|
|
|
const avg = count == 0 ? 0 : totWaterUsage / count; // 연간 일평균 유입량
|
|
|
|
|
|
|
|
|
|
let wtrUsgYearTotal = 0; // 연간 물사용량
|
|
|
|
|
let summerWtrUsgTot = 0; // 하절기 물사용량
|
|
|
|
|
let winterWtrUsgTot = 0; // 동절기 물사용량
|
|
|
|
@@ -492,37 +462,26 @@ export const underWaterReducer: (set: (fn: (state: UnderWaterType) => UnderWater
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (wtrUsgYearTotal > 0) { // 물사용량이 있는 경우
|
|
|
|
|
const usage = chungcunSumFlow && chungcunSumFlow > 0 ? chungcunSumFlow / sumChungcunDay : 0; // 청천시 일평균 유입량
|
|
|
|
|
const summerUsage = sumSummerChungcunFlow ? sumSummerChungcunFlow / sumSummerChungcunDay : 0; // 하절기 청천시 일평균 유입량
|
|
|
|
|
const winterUsage = sumWinterChungcunFlow ? sumWinterChungcunFlow / sumWinterChungcunDay : 0; // 동절기 청천시 일평균 유입량
|
|
|
|
|
if (wtrUsgYearTotal > 0) { // 물사용량이 있는 경우
|
|
|
|
|
const wtrUsg = wtrUsgYearDays > 0 ? wtrUsgYearTotal / wtrUsgYearDays : 0; // 일평균 물사용량
|
|
|
|
|
const summerWtrUsg = summerWtrUsgTot ? summerWtrUsgTot / summerWtrUsgDays : 0; // 하절기 일평균 물사용량
|
|
|
|
|
const winterWtrUsg = winterWtrUsgTot ? winterWtrUsgTot / winterWtrUsgDays : 0; // 동절기 일평균 물사용량
|
|
|
|
|
|
|
|
|
|
item.inflAmnt = roundNumber(avg, 0);
|
|
|
|
|
item.underWaterInputYear = Math.round((usage - (wtrUsg * OSU_PERCENT)) * 1) / 1; // 연간지하수유입량(m³/일) = 청천시 실제유입량 - (물사용량 × 오수전환율)
|
|
|
|
|
item.underWaterInputSummer = Math.round((summerUsage - (summerWtrUsg * OSU_PERCENT)) * 1) / 1; // 하절기지하수유입량(m³/일)
|
|
|
|
|
item.underWaterInputWinter = Math.round((winterUsage - (winterWtrUsg * OSU_PERCENT)) * 1) / 1; // 동절기지하수유입량(m³/일)
|
|
|
|
|
item.properYn = Math.round((Number(usage - (wtrUsg * OSU_PERCENT)) / Number(item.inflAmnt)) * 100 * 1) / 1 > 20 ? '초과유입' : '적정'; // 적정여부
|
|
|
|
|
item.inflAmnt = Math.round(item.inflAmnt);
|
|
|
|
|
item.underWaterInputYear = Math.round((item.inflSunny - (wtrUsg * OSU_PERCENT)) ) ; // 연간지하수유입량(m³/일) = 청천시 실제유입량 - (물사용량 × 오수전환율)
|
|
|
|
|
item.underWaterInputSummer = Math.round((item.inflSunnySummer - (summerWtrUsg * OSU_PERCENT)) ) ; // 하절기지하수유입량(m³/일)
|
|
|
|
|
item.underWaterInputWinter = Math.round((item.inflSunnyWinter - (winterWtrUsg * OSU_PERCENT))) ; // 동절기지하수유입량(m³/일)
|
|
|
|
|
item.properYn = Math.round( (item.inflSunny - (wtrUsg * OSU_PERCENT)) / Number(item.inflAmnt) * 100 ) > 20 ? '초과유입' : '적정'; // 적정여부
|
|
|
|
|
} else { // 물사용량이 없는 경우, 일평균 유입량으로 물사용량 추정(물사용량 = 유입량*0.65)
|
|
|
|
|
const usage = chungcunSumFlow && chungcunSumFlow > 0 ? chungcunSumFlow / sumChungcunDay : 0; // 청천시 일평균 유입량
|
|
|
|
|
const summerUsage = sumSummerChungcunFlow ? sumSummerChungcunFlow / sumSummerChungcunDay : 0; // 하절기 청천시 일평균 유입량
|
|
|
|
|
const winterUsage = sumWinterChungcunFlow ? sumWinterChungcunFlow / sumWinterChungcunDay : 0; // 동절기 청천시 일평균 유입량
|
|
|
|
|
const wtrUsg = avg * 0.65; // 일평균 물사용량
|
|
|
|
|
const summerWtrUsg = totSummerDays > 0 ? (totSummerUsage / totSummerDays) * 0.65 : 0; // 하절기 일평균 물사용량
|
|
|
|
|
const winterWtrUsg = totWinterDays > 0 ? (totWinterUsage / totWinterDays) * 0.65 : 0; // 동절기 일평균 물사용량
|
|
|
|
|
const wtrUsg = item.inflAmnt * 0.65; // 일평균 물사용량
|
|
|
|
|
const summerWtrUsg = item.inflSummer * 0.65; // 하절기 일평균 물사용량
|
|
|
|
|
const winterWtrUsg = item.inflWinter * 0.65; // 동절기 일평균 물사용량
|
|
|
|
|
|
|
|
|
|
item.inflAmnt = roundNumber(avg, 0);
|
|
|
|
|
//item.underWaterInputYear = Math.round((usage-(usage*0.65*OSU_PERCENT)) * 1) / 1; // 연간지하수유입량(m³/일)
|
|
|
|
|
item.underWaterInputYear = Math.round((usage - (wtrUsg * OSU_PERCENT)) * 1) / 1; // 연간지하수유입량(m³/일) = 청천시 실제유입량 - (물사용량 × 오수전환율)
|
|
|
|
|
item.underWaterInputSummer = Math.round((summerUsage - (summerWtrUsg * OSU_PERCENT)) * 1) / 1; // 하절기지하수유입량(m³/일) = 청천시 실제유입량 - (물사용량 × 오수전환율)
|
|
|
|
|
item.underWaterInputWinter = Math.round((winterUsage - (winterWtrUsg * OSU_PERCENT)) * 1) / 1; // 동절기지하수유입량(m³/일) = 청천시 실제유입량 - (물사용량 × 오수전환율)
|
|
|
|
|
item.properYn = Math.round((Number(usage - (wtrUsg * OSU_PERCENT)) / Number(item.inflAmnt)) * 100 * 1) / 1 > 20 ? '초과유입' : '적정'; // 적정여부
|
|
|
|
|
// 반올림 처리
|
|
|
|
|
// ["fctCpc", "inflAmnt", "underWaterInputYear", "underWaterInputSummer", "underWaterInputWinter"].forEach(
|
|
|
|
|
// (key) => (item[key] = roundNumber(item[key], 0))
|
|
|
|
|
// );
|
|
|
|
|
item.inflAmnt = Math.round(item.inflAmnt);
|
|
|
|
|
item.underWaterInputYear = Math.round((item.inflSunny - (wtrUsg * OSU_PERCENT)) ) ; // 연간지하수유입량(m³/일) = 청천시 실제유입량 - (물사용량 × 오수전환율)
|
|
|
|
|
item.underWaterInputSummer = Math.round((item.inflSunnySummer - (summerWtrUsg * OSU_PERCENT)) ) ; // 하절기지하수유입량(m³/일) = 청천시 실제유입량 - (물사용량 × 오수전환율)
|
|
|
|
|
item.underWaterInputWinter = Math.round((item.inflSunnyWinter - (winterWtrUsg * OSU_PERCENT)) ) ; // 동절기지하수유입량(m³/일) = 청천시 실제유입량 - (물사용량 × 오수전환율)
|
|
|
|
|
item.properYn = Math.round( (item.inflSunny - (wtrUsg * OSU_PERCENT)) / Number(item.inflAmnt) * 100 ) > 20 ? '초과유입' : '적정'; // 적정여부
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|