diff --git a/apps/fo/app/components/common/CalcRainEffect.tsx b/apps/fo/app/components/common/CalcRainEffect.tsx index bd6e39185..c35140d83 100644 --- a/apps/fo/app/components/common/CalcRainEffect.tsx +++ b/apps/fo/app/components/common/CalcRainEffect.tsx @@ -6,11 +6,10 @@ * 2.강우영향일이면서 3mm이하의 강우량일 경우에는 강우영향을 준 날의 강우량을 따름 * @param data * @param weather (default:ALL), SUNNY, ..etc - * @param chagePart (default:ALL), RAIN_DAY, RAIN_AMNT * @author jsyang */ -export default function CalcRainEffect(data : any, weather='ALL', changePart='ALL') { +export default function CalcRainEffect(data : any, weather='ALL') { console.log("%c Calculate RainEffect !" , "background:blue;color:white"); console.log("%c Data Length :"+data.length+" Weather : "+weather , "background:yellow;color:blue"); // 강우영향일 계산 (강우량이 3 초과이면 무조건 강우영향일) @@ -25,40 +24,38 @@ export default function CalcRainEffect(data : any, weather='ALL', changePart='AL if(item.infoRnDay == 'x'){ item.infoRnDay = '0.0'; + item.toBeInfoRnDay = '0.0'; }else{ item.infoRnDay = Number(item.infoRnDay).toFixed(1); + item.toBeInfoRnDay = Number(item.infoRnDay).toFixed(1); } } } - if(['ALL', 'RAIN_DAY'].includes(changePart)) { - // 이틀 전, 하루 전이 강우영향일(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) >= 3) { - data[idx]!.rainEffectDay = 1; - } - // 이틀 전이 강우영향일(3 이상)인 경우 - if(idx > 1 && data[idx-2]?.infoRnDay && Number(data[idx-2]?.infoRnDay) >= 3) { - data[idx]!.rainEffectDay = 1; - } + // 이틀 전, 하루 전이 강우영향일(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) >= 3) { + data[idx]!.rainEffectDay = 1; + } + // 이틀 전이 강우영향일(3 이상)인 경우 + if(idx > 1 && data[idx-2]?.infoRnDay && Number(data[idx-2]?.infoRnDay) >= 3) { + data[idx]!.rainEffectDay = 1; } } } - if(['ALL', 'RAIN_AMNT'].includes(changePart)){ - 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]?.infoRnDay) < 3 && Number(data[idx-1]?.infoRnDay.toString().trim()) >= 3) { - data[idx]!.infoRnDay = data[idx-1]!.infoRnDay; - } + 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]?.infoRnDay) < 3 && Number(data[idx-1]?.infoRnDay.toString().trim()) >= 3) { + data[idx]!.toBeInfoRnDay = data[idx-1]!.infoRnDay; } - if(idx > 2){ - if(data[idx-2]?.infoRnDay && Number(data[idx]?.infoRnDay) < 3 && Number(data[idx-2]?.infoRnDay.toString().trim()) >= 3) { - data[idx]!.infoRnDay = data[idx-2]!.infoRnDay; - } + } + if(idx > 2){ + if(data[idx-2]?.infoRnDay && Number(data[idx]?.infoRnDay) < 3 && Number(data[idx-2]?.infoRnDay.toString().trim()) >= 3) { + data[idx]!.toBeInfoRnDay = data[idx-2]!.infoRnDay; } } } diff --git a/apps/fo/app/components/common/FacilityTermModalHeader.tsx b/apps/fo/app/components/common/FacilityTermModalHeader.tsx index d856e233f..a11323528 100644 --- a/apps/fo/app/components/common/FacilityTermModalHeader.tsx +++ b/apps/fo/app/components/common/FacilityTermModalHeader.tsx @@ -98,25 +98,25 @@ export default function FacilityTermModalHeader({ const endDateOnly = new Date(endDate.getFullYear(), endDate.getMonth(), endDate.getDate()); const rainEffectDay = (item as T & { rainEffectDay: number }).rainEffectDay; if(flowPanel === '2'){ - const infoRnDay = (item as T & { infoRnDay: number }).infoRnDay; + const infoRnDay = (item as T & { toBeInfoRnDay: number }).toBeInfoRnDay; return (itemDateOnly >= startDateOnly && itemDateOnly <= endDateOnly) && infoRnDay >= 3 && infoRnDay < 10; } else if(flowPanel === '3'){ - const infoRnDay = (item as T & { infoRnDay: number }).infoRnDay; + const infoRnDay = (item as T & { toBeInfoRnDay: number }).toBeInfoRnDay; return (itemDateOnly >= startDateOnly && itemDateOnly <= endDateOnly) && infoRnDay >= 10 && infoRnDay < 20; } else if(flowPanel === '4'){ - const infoRnDay = (item as T & { infoRnDay: number }).infoRnDay; + const infoRnDay = (item as T & { toBeInfoRnDay: number }).toBeInfoRnDay; return (itemDateOnly >= startDateOnly && itemDateOnly <= endDateOnly) && infoRnDay >= 20 && infoRnDay < 30; } else if(flowPanel === '5'){ - const infoRnDay = (item as T & { infoRnDay: number }).infoRnDay; + const infoRnDay = (item as T & { toBeInfoRnDay: number }).toBeInfoRnDay; return (itemDateOnly >= startDateOnly && itemDateOnly <= endDateOnly) && infoRnDay >= 30 && infoRnDay < 40; } else if(flowPanel === '6'){ - const infoRnDay = (item as T & { infoRnDay: number }).infoRnDay; + const infoRnDay = (item as T & { toBeInfoRnDay: number }).toBeInfoRnDay; return (itemDateOnly >= startDateOnly && itemDateOnly <= endDateOnly) && infoRnDay >= 40 && infoRnDay < 50; } else if(flowPanel === '7'){ - const infoRnDay = (item as T & { infoRnDay: number }).infoRnDay; + const infoRnDay = (item as T & { toBeInfoRnDay: number }).toBeInfoRnDay; return (itemDateOnly >= startDateOnly && itemDateOnly <= endDateOnly) && infoRnDay >= 50 && infoRnDay < 60; } else if(flowPanel === '8'){ - const infoRnDay = (item as T & { infoRnDay: number }).infoRnDay; + const infoRnDay = (item as T & { toBeInfoRnDay: number }).toBeInfoRnDay; return (itemDateOnly >= startDateOnly && itemDateOnly <= endDateOnly) && infoRnDay >= 60; } else { return (itemDateOnly >= startDateOnly && itemDateOnly <= endDateOnly) && (rainEffectDay ===1); diff --git a/apps/fo/app/pages/(with-layout)/facilityPrecipitation/modal/page.tsx b/apps/fo/app/pages/(with-layout)/facilityPrecipitation/modal/page.tsx index e7659f672..0b4ef5830 100644 --- a/apps/fo/app/pages/(with-layout)/facilityPrecipitation/modal/page.tsx +++ b/apps/fo/app/pages/(with-layout)/facilityPrecipitation/modal/page.tsx @@ -122,7 +122,7 @@ export default function PrecipitationModal(props: PrecipitationModalProps) { const filteredList = props.detailList .map(i => ({ ...i })) // ← 얕은 복제 .filter((item) => props.facilityCd === item.bscFctCd); - const calcData = CalcRainEffect(filteredList, 'ALL', 'RAIN_DAY'); + const calcData = CalcRainEffect(filteredList); setFilteredDetailList(calcData); setCopyDetailList(calcData); diff --git a/apps/fo/app/pages/(with-layout)/planSewage/page.tsx b/apps/fo/app/pages/(with-layout)/planSewage/page.tsx index 634b0507d..00539da13 100644 --- a/apps/fo/app/pages/(with-layout)/planSewage/page.tsx +++ b/apps/fo/app/pages/(with-layout)/planSewage/page.tsx @@ -104,7 +104,7 @@ export default function PlanSewage() { initializeCommonData(); searchPlanSewageList(1, 10, selectSearchYear[0]?.val || "0", ref.current.partValue); } - }, [isInit, initializeCommonData, searchPlanSewageList]); + }, [isInit, initializeCommonData, searchPlanSewageList, selectSearchYear]); useEffect(() => { if (excelList && excelList.length > 0) { diff --git a/apps/fo/app/store/dashboard/index.tsx b/apps/fo/app/store/dashboard/index.tsx index 64cef9723..016084a00 100644 --- a/apps/fo/app/store/dashboard/index.tsx +++ b/apps/fo/app/store/dashboard/index.tsx @@ -745,8 +745,8 @@ const calcWaterQltyData = async (data: any[], searchYear : string|undefined, fcl if(res.data.wqltObjs.length> 0) { const clone = (arr: any[]) => arr?.map(v => ({ ...v })) ?? []; const qltyData = res.data.wqltObjs; - const qltyChungchunData = CalcRainEffect(clone(qltyData), 'SUNNY', 'RAIN_DAY'); - const qltyRainData = CalcRainEffect(clone(qltyData), 'RAIN', 'RAIN_DAY'); + const qltyChungchunData = CalcRainEffect(clone(qltyData), 'SUNNY'); + const qltyRainData = CalcRainEffect(clone(qltyData), 'RAIN'); // (0) 전체변수 let summerDay = 0; @@ -1507,7 +1507,7 @@ export const dashBoardReducer:(set:(fn: (state: DashBoardType) => DashBoardType) const clone = (arr: any[]) => arr?.map(v => ({ ...v })) ?? []; const calData = CalcRainEffect(clone(res2.data), 'SUNNY'); - const calRainDate = CalcRainEffect(clone(res2.data), 'RAIN', 'RAIN_DAY'); + const calRainDate = CalcRainEffect(clone(res2.data), 'RAIN'); // 지하수유입량 - 청천시 기준 let chungcunSumFlow = 0; @@ -1958,7 +1958,7 @@ export const dashBoardReducer:(set:(fn: (state: DashBoardType) => DashBoardType) // 청천시 중 강우영향일인 날짜는 이전의 강우량을 대입해 리스트 수정 - const rainEffectList = CalcRainEffect(res.data.wqltObjs); + const rainEffectList = CalcRainEffect(res.data.wqltObjs, 'RAIN_DAY'); // Process the data and create rain management list const totItemCnt = rainEffectList?rainEffectList.length : 1; diff --git a/apps/fo/app/store/flowRate/index.tsx b/apps/fo/app/store/flowRate/index.tsx index a6580500d..c73bcc0cd 100644 --- a/apps/fo/app/store/flowRate/index.tsx +++ b/apps/fo/app/store/flowRate/index.tsx @@ -320,7 +320,7 @@ export const flowRateSearchReducer:(set:(fn: (state: FlowRateSearchType) => Flow searchFlowRateModalList: async (bscFctCd: string, searchYear: string) => { const res = await fetchFlowRateModalList(bscFctCd, searchYear); const data = CalcRainEffect(res.data); - + console.log(data); const rtnData = data.map((item: FlowRateModalProps) => { item.totInflAmnt = Number(item.inflAmnt || 0) + Number(item.sumFlow || 0) + Number(item.returnAmnt || 0) dataFormSetting(item); diff --git a/apps/fo/app/store/planSewage/index.tsx b/apps/fo/app/store/planSewage/index.tsx index 25bbc9147..21a711e8b 100644 --- a/apps/fo/app/store/planSewage/index.tsx +++ b/apps/fo/app/store/planSewage/index.tsx @@ -183,7 +183,7 @@ export const planSewageReducer:(set:(fn: (state: PlanSewageType) => PlanSewageTy 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 = CalcRainEffect(res2.data, 'SUNNY', 'RAIN_DAY'); + const calData = CalcRainEffect(res2.data, 'SUNNY'); let sumInflAmntSunny = 0; let avgInflAmntSunny = 0;