diff --git a/apps/fo/app/store/sewageOccur/index.tsx b/apps/fo/app/store/sewageOccur/index.tsx index 1f4e8ce7e..a0ff0a3f3 100644 --- a/apps/fo/app/store/sewageOccur/index.tsx +++ b/apps/fo/app/store/sewageOccur/index.tsx @@ -4,6 +4,7 @@ import { roundNumber } from "@/app/components/common/DataForm"; import { OSU_PERCENT } from "../common"; import type { TableUpperProps } from "../dashboard"; import { fetchFacilityListInit } from "../processFacility"; +import { fetchFacilityRainDetailList } from "../facilityPrecipitation"; export type { TableUpperProps }; /** @@ -330,15 +331,46 @@ export const sewageOccurReducer: (set: any) => SewageOccurActions = (set: any) = const soccurDetailRes: any = await fetchSweageOccurListFlow(searchYear, fcltCdList); const wtrUsgYmRes: any = await fetchWtrUsgYmList(searchYear, fcltCdList); - // const wtrUsgMap : Record = {}; - // wtrUsgRes.data.forEach(fclt => { - // wtrUsgMap[fclt.bscFctCd] = fclt.wtrUsg; - // }); + + //--------- + const rainDetailList: Record = {}; + const wtrDetailList: Record = {}; + 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 fetchSweageOccurListFlow(searchYear, slicedItems); + const wtrResult = await fetchWtrUsgYmList(searchYear, slicedItems); + results.push(result); + 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[])]; + } + } + } + for (const res of wtrResults) { + if (res.status === 200 && res.data) { + for (const [key, value] of Object.entries(res.data)) { + const keyStr = String(key); + wtrDetailList[keyStr] = [...(wtrDetailList[keyStr] || []), ...(value as any[])]; + } + } + } + //------- + let maxEstimationSewage = 0, minEstimationSewage = 999999999; for (const item of sewageOccurPropsList) { - const detailList = soccurDetailRes?.data[item.bscFctCd]; - const wtrUsgYmList = wtrUsgYmRes?.data[item.bscFctCd]; + //const detailList = soccurDetailRes?.data[item.bscFctCd]; + // const wtrUsgYmList = wtrUsgYmRes?.data[item.bscFctCd]; + const detailList = rainDetailList[item.bscFctCd]; + const wtrUsgYmList = wtrDetailList[item.bscFctCd]; item.swageChangePercent = 90; let sumChungcunDay = 0; // 청천일수