diff --git a/apps/fo/app/components/common/FacilityTermModalHeader.tsx b/apps/fo/app/components/common/FacilityTermModalHeader.tsx index 30c77405f..d856e233f 100644 --- a/apps/fo/app/components/common/FacilityTermModalHeader.tsx +++ b/apps/fo/app/components/common/FacilityTermModalHeader.tsx @@ -97,10 +97,7 @@ export default function FacilityTermModalHeader({ const startDateOnly = new Date(startDate.getFullYear(), startDate.getMonth(), startDate.getDate()); const endDateOnly = new Date(endDate.getFullYear(), endDate.getMonth(), endDate.getDate()); const rainEffectDay = (item as T & { rainEffectDay: number }).rainEffectDay; - if(flowPanel === '1') { - const infoRnDay = (item as T & { infoRnDay: number }).infoRnDay; - return (itemDateOnly >= startDateOnly && itemDateOnly <= endDateOnly) && infoRnDay>0 && infoRnDay < 3; - } else if(flowPanel === '2'){ + if(flowPanel === '2'){ const infoRnDay = (item as T & { infoRnDay: number }).infoRnDay; return (itemDateOnly >= startDateOnly && itemDateOnly <= endDateOnly) && infoRnDay >= 3 && infoRnDay < 10; } else if(flowPanel === '3'){ @@ -122,8 +119,7 @@ export default function FacilityTermModalHeader({ const infoRnDay = (item as T & { infoRnDay: number }).infoRnDay; return (itemDateOnly >= startDateOnly && itemDateOnly <= endDateOnly) && infoRnDay >= 60; } else { - const infoRnDay = (item as T & { infoRnDay: number }).infoRnDay; - return (itemDateOnly >= startDateOnly && itemDateOnly <= endDateOnly) && (infoRnDay>0 || rainEffectDay ===1); + return (itemDateOnly >= startDateOnly && itemDateOnly <= endDateOnly) && (rainEffectDay ===1); } }); } else if(tabName.includes("_chuncheon")) { @@ -132,8 +128,8 @@ export default function FacilityTermModalHeader({ const itemDateOnly = new Date(itemDate.getFullYear(), itemDate.getMonth(), itemDate.getDate()); const startDateOnly = new Date(startDate.getFullYear(), startDate.getMonth(), startDate.getDate()); const endDateOnly = new Date(endDate.getFullYear(), endDate.getMonth(), endDate.getDate()); - const infoRnDay = (item as T & { infoRnDay: number }).infoRnDay; - return (itemDateOnly >= startDateOnly && itemDateOnly <= endDateOnly) && infoRnDay==0; + const rainEffectDay = (item as T & { rainEffectDay: number }).rainEffectDay; + return (itemDateOnly >= startDateOnly && itemDateOnly <= endDateOnly) && rainEffectDay==0; }); } else { filteredData = searchList.filter((item) => { @@ -144,7 +140,6 @@ export default function FacilityTermModalHeader({ return itemDateOnly >= startDateOnly && itemDateOnly <= endDateOnly; }); } - setCopySearchList(filteredData); setStandSearchList(filteredData); }, [searchList, searchYear, tabName, flowPanel]); diff --git a/apps/fo/app/pages/flowRate/modal/page.tsx b/apps/fo/app/pages/flowRate/modal/page.tsx index 409dab7eb..bc121708c 100644 --- a/apps/fo/app/pages/flowRate/modal/page.tsx +++ b/apps/fo/app/pages/flowRate/modal/page.tsx @@ -52,7 +52,6 @@ export default function FlowRateModal(props: { fcltyName: string; facilityCd: st return Number(value.replace(/,/g, '')); }; - console.log('filteredData : ', filteredData); let maxtotInflAmnt = 0; let maxinflAmnt = 0; let maxsumFlow = 0; diff --git a/apps/fo/app/store/dashboard/index.tsx b/apps/fo/app/store/dashboard/index.tsx index 76f1bb046..89166281a 100644 --- a/apps/fo/app/store/dashboard/index.tsx +++ b/apps/fo/app/store/dashboard/index.tsx @@ -996,7 +996,7 @@ export const calRainEffectDayRainManage = (data: RainManageListProps[]) => { for(let idx = 0; idx < data.length; idx++) { const item = data[idx]; if(item){ - if(item.infoRnDay && Number(item.infoRnDay) > 3) { + if(item.infoRnDay && Number(item.infoRnDay) >= 3) { item.rainEffectDay = 1; } else { item.rainEffectDay = 0; @@ -1021,12 +1021,12 @@ export const calRainEffectDayRainManage = (data: RainManageListProps[]) => { for(let idx = 0; idx < data.length; idx++) { if(data[idx] && data[idx]?.rainEffectDay === 1) { if(idx > 1){ - if(data[idx-1]?.infoRnDay && Number(data[idx-1]?.infoRnDay) > 3) { + if(data[idx-1]?.infoRnDay && Number(data[idx-1]?.infoRnDay) >= 3) { data[idx]!.infoRnDay = data[idx-1]!.infoRnDay; } } if(idx > 2){ - if(data[idx-2]?.infoRnDay && Number(data[idx-2]?.infoRnDay) > 3) { + if(data[idx-2]?.infoRnDay && Number(data[idx-2]?.infoRnDay) >= 3) { data[idx]!.infoRnDay = data[idx-2]!.infoRnDay; } } diff --git a/apps/fo/app/store/flowRate/index.tsx b/apps/fo/app/store/flowRate/index.tsx index 0a36d972b..3456bb8cc 100644 --- a/apps/fo/app/store/flowRate/index.tsx +++ b/apps/fo/app/store/flowRate/index.tsx @@ -170,7 +170,6 @@ const fetchFlowRateList = async (pageNo: number, pageSize: number, searchYear: s try { const tailStr = partCd ? '/'+ partCd + '/' + nameCd + '/' + fcltCpct + '/' + operationValue + (fcltyNm && fcltyNm !== '' ? '/' + fcltyNm : '') : ''; const url = '/fclt/flow/' + pageNo + '/' + pageSize + '/' + searchYear + tailStr; const res = await getFetch('fo', url); - console.log(url); return { data: res.data, count: res.count } } catch (error) { console.error('시설정보 유량현황 데이터를 가져오는데 실패했습니다:', error); @@ -312,18 +311,11 @@ export const flowRateSearchReducer:(set:(fn: (state: FlowRateSearchType) => Flow searchFlowRateModalList: async (bscFctCd: string, searchYear: string) => { const res = await fetchFlowRateModalList(bscFctCd, searchYear); const data = res.data; - - data.forEach((item: FlowRateModalProps) => { - if(item.infoRnDay && item.infoRnDay.toString().trim() === 'x') { - item.infoRnDay = ''; - } - }); - // 강우영향일 계산 (강우량이 3 초과이면 무조건 강우영향일) for(let idx = 0; idx < data.length; idx++) { const item = data[idx]; if(item){ - if(item.infoRnDay && Number(item.infoRnDay) > 3) { + if(item.infoRnDay && Number(item.infoRnDay.toString().trim()) >= 3) { item.rainEffectDay = 1; } else { item.rainEffectDay = 0; @@ -335,11 +327,11 @@ export const flowRateSearchReducer:(set:(fn: (state: FlowRateSearchType) => Flow for(let idx = 0; idx < data.length; idx++) { if(data[idx]) { // 하루 전이 강우영향일(3 이상)인 경우 - if(idx > 0 && data[idx-1]?.infoRnDay && Number(data[idx-1]?.infoRnDay) >= 3) { + if(idx > 0 && data[idx-1]?.infoRnDay && Number(data[idx-1]?.infoRnDay.toString().trim()) >= 3) { data[idx]!.rainEffectDay = 1; } // 이틀 전이 강우영향일(3 이상)인 경우 - if(idx > 1 && data[idx-2]?.infoRnDay && Number(data[idx-2]?.infoRnDay) >= 3) { + if(idx > 1 && data[idx-2]?.infoRnDay && Number(data[idx-2]?.infoRnDay.toString().trim()) >= 3) { data[idx]!.rainEffectDay = 1; } } @@ -348,12 +340,12 @@ export const flowRateSearchReducer:(set:(fn: (state: FlowRateSearchType) => Flow for(let idx = 0; idx < data.length; idx++) { if(data[idx] && data[idx]?.rainEffectDay === 1) { if(idx > 1){ - if(data[idx-1]?.infoRnDay && Number(data[idx-1]?.infoRnDay) > 3) { + if(data[idx-1]?.infoRnDay && Number(data[idx-1]?.infoRnDay.toString().trim()) >= 3) { data[idx]!.infoRnDay = data[idx-1]!.infoRnDay; } } if(idx > 2){ - if(data[idx-2]?.infoRnDay && Number(data[idx-2]?.infoRnDay) > 3) { + if(data[idx-2]?.infoRnDay && Number(data[idx-2]?.infoRnDay.toString().trim()) >= 3) { data[idx]!.infoRnDay = data[idx-2]!.infoRnDay; } } diff --git a/apps/fo/app/store/planSewage/index.tsx b/apps/fo/app/store/planSewage/index.tsx index e9153305a..c5286db8d 100644 --- a/apps/fo/app/store/planSewage/index.tsx +++ b/apps/fo/app/store/planSewage/index.tsx @@ -1,6 +1,7 @@ import DataForm from "@/app/components/common/DataForm"; import type { TableUpperProps } from "../dashboard"; import { getFetch } from "@/app/components/api"; +import { calRainEffectDay, type ApiResponse, type FlowDataItem } from "../underWaterInput"; export type { TableUpperProps }; /**==================================== * Store - 타입 @@ -172,14 +173,34 @@ export const planSewageReducer:(set:(fn: (state: PlanSewageType) => PlanSewageTy searchPlanSewageList: async (pageNo: number, pageSize: number, searchYear: string, partCd?: string, nameCd?: string, fcltCpct?: string, operationValue?: string, fcltyNm?: string) => { const res = await fetchPlanSewageList(pageNo, pageSize, searchYear, partCd, nameCd, fcltCpct, operationValue, fcltyNm); const excelDownList: ExcelType[] = []; - console.log('res' , res.data); + const data = res.data + const processedData = await Promise.all(data.map(async (item:PlanSewageProps) => { + const res2 = await getFetch('fo', '/fclt/flow/' + item.bscFctCd + '/' + searchYear) as ApiResponse; + const calData = calRainEffectDay(res2.data, 'SUNNY'); + + let sumInflAmntSunny = 0; + let avgInflAmntSunny = 0; + calData.forEach((flowItem:FlowDataItem) => { + sumInflAmntSunny += Number(flowItem.inflAmnt); + }) + avgInflAmntSunny = sumInflAmntSunny / calData.length; + item.avgInflAmntSunny = avgInflAmntSunny; + if(item.bscFctCd === '11200PB001R'){ + console.log('avgInflAmntSunny : ',item.avgInflAmntSunny); + console.log('calData : ',calData); + } + return item; + })); + /** * 결과데이터 계산 * (1) 여유용량 = 시설용량 - 건기시 평균유량 * (2) 변동부하율 = 건기시 일최대 유량/일평균유량(기준 최근 3개년) * (3) 분류식화율 = 분류식지역 면적(㎢)/처리구역 면적합계(㎢) ×100 */ - const resultData = res.data.map((item:PlanSewageProps) => { + const resultData = processedData.map((item:PlanSewageProps) => { + console.log('item.fctCpc : ',item.fctCpc); + console.log('item.avgInflAmntSunny : ',item.avgInflAmntSunny); item.spareCapacity = Number(item.fctCpc) - Number(item.avgInflAmntSunny); item.variableLoadPercent = item.maxInflAmntSunny && item.maxInflAmntSunny!==0 ? Number(item.maxInflAmntSunny) / Number(item.avgInflAmntSunny) : 0; item.classifiedSewerPercent = item.sprtProcZoneAr && item.sprtProcZoneAr!==0 ? Number(item.sprtProcZoneAr) / Number(item.procZoneSm) * 100 : 0; diff --git a/apps/fo/app/store/sewageOccur/index.tsx b/apps/fo/app/store/sewageOccur/index.tsx index cdbc2ed4e..08b873cca 100644 --- a/apps/fo/app/store/sewageOccur/index.tsx +++ b/apps/fo/app/store/sewageOccur/index.tsx @@ -202,6 +202,7 @@ export type FlowDataItem = { infoRnDay: string | number; bscFctCd: string; msrDt: string; + rainEffectDay?: number; } export type FlowResponse = { @@ -221,14 +222,57 @@ export const sewageOccurReducer:(set:any)=>SewageOccurActions=(set: any) => { item.sggNm = item.lclgvrnmntNm.split(' ')[1]?.toString() || ''; item.fctCpc = parseFloat(item.fctCpc.toString().replace(/,/g, '')); item.swageChangePercent = 80; - const bscFctCd = item.bscFctCd; const res2 = await getFetch('fo', '/fclt/flow/' + bscFctCd + '/' + searchYear) as FlowResponse; - + let sumChungcunDay = 0; let chungcunSumFlow = 0; let totWaterUsage = 0; + + // 강우영향일 계산 (강우량이 3 초과이면 무조건 강우영향일) + for(let idx = 0; idx < res2.data.length; idx++) { + const item = res2.data[idx]; + if(item){ + if(item.infoRnDay && Number(item.infoRnDay.toString().trim()) >= 3) { + item.rainEffectDay = 1; + } else { + item.rainEffectDay = 0; + } + } + } + + // 이틀 전, 하루 전이 강우영향일(3 이상)인 경우 해당 날도 강우영향일로 설정 + for(let idx = 0; idx < data.length; idx++) { + if(data[idx]) { + // 하루 전이 강우영향일(3 이상)인 경우 + if(idx > 0 && data[idx-1]?.infoRnDay && Number(data[idx-1]?.infoRnDay.toString().trim()) >= 3) { + data[idx]!.rainEffectDay = 1; + } + // 이틀 전이 강우영향일(3 이상)인 경우 + if(idx > 1 && data[idx-2]?.infoRnDay && Number(data[idx-2]?.infoRnDay.toString().trim()) >= 3) { + data[idx]!.rainEffectDay = 1; + } + } + } + + for(let idx = 0; idx < data.length; idx++) { + if(data[idx] && data[idx]?.rainEffectDay === 1) { + if(idx > 1){ + if(data[idx-1]?.infoRnDay && Number(data[idx-1]?.infoRnDay.toString().trim()) >= 3) { + data[idx]!.infoRnDay = data[idx-1]!.infoRnDay; + } + } + if(idx > 2){ + if(data[idx-2]?.infoRnDay && Number(data[idx-2]?.infoRnDay.toString().trim()) >= 3) { + data[idx]!.infoRnDay = data[idx-2]!.infoRnDay; + } + } + } + } + + console.log('calData : ',res2.data); + res2.data.forEach((item: FlowDataItem) => { if(Number(item.infoRnDay) ===0){ chungcunSumFlow += Number(item.inflAmnt); diff --git a/apps/fo/app/store/underWaterInput/index.tsx b/apps/fo/app/store/underWaterInput/index.tsx index 060c641dc..2d0938a56 100644 --- a/apps/fo/app/store/underWaterInput/index.tsx +++ b/apps/fo/app/store/underWaterInput/index.tsx @@ -260,29 +260,44 @@ const dataFormSetting=(item : UnderWaterProps)=> { export type UnderWaterStore = UnderWaterType & UnderWaterActions; export const calRainEffectDay = (data: FlowDataItem[], weather: string) => { + // 강우영향일 계산 (강우량이 3 이상이면 무조건 강우영향일) for(let idx = 0; idx < data.length; idx++) { const item = data[idx]; - const rainDay = Number(item?.infoRnDay) >= 3 ? 1 : 0; - let rainEffectDay = 0; if(item){ - if(idx < data.length - 2) { - if(rainDay == 1) { - rainEffectDay = 1; - } else { - if(idx >= 2) { - if(Number(data[idx-1]?.infoRnDay) >= 3 || Number(data[idx-2]?.infoRnDay) >= 3) { - rainEffectDay = 1; - } - } - } - } else if(idx < data.length - 1) { - if(rainDay == 1 || Number(data[idx+1]?.infoRnDay) >= 3) { - rainEffectDay = 1; - } + if(item.infoRnDay && Number(item.infoRnDay.toString().trim()) >= 3) { + item.rainEffectDay = 1; } else { - rainEffectDay = rainDay; + item.rainEffectDay = 0; + } + } + } + + // 이틀 전, 하루 전이 강우영향일(3 이상)인 경우 해당 날도 강우영향일로 설정 + for(let idx = 0; idx < data.length; idx++) { + if(data[idx]) { + // 하루 전이 강우영향일(3 이상)인 경우 + if(idx > 0 && data[idx-1]?.infoRnDay && Number(data[idx-1]?.infoRnDay.toString().trim()) >= 3) { + data[idx]!.rainEffectDay = 1; + } + // 이틀 전이 강우영향일(3 이상)인 경우 + if(idx > 1 && data[idx-2]?.infoRnDay && Number(data[idx-2]?.infoRnDay.toString().trim()) >= 3) { + data[idx]!.rainEffectDay = 1; + } + } + } + + for(let idx = 0; idx < data.length; idx++) { + if(data[idx] && data[idx]?.rainEffectDay === 1) { + if(idx > 1){ + if(data[idx-1]?.infoRnDay && Number(data[idx-1]?.infoRnDay.toString().trim()) >= 3) { + data[idx]!.infoRnDay = data[idx-1]!.infoRnDay; + } + } + if(idx > 2){ + if(data[idx-2]?.infoRnDay && Number(data[idx-2]?.infoRnDay.toString().trim()) >= 3) { + data[idx]!.infoRnDay = data[idx-2]!.infoRnDay; + } } - item.rainEffectDay = rainEffectDay; } }