From 974d15962ca6921cf3478f80be88920b239fa091 Mon Sep 17 00:00:00 2001 From: ljpark Date: Thu, 22 Jan 2026 11:26:43 +0900 Subject: [PATCH] =?UTF-8?q?fo:=20exceldownload=204=EB=B3=B8=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/fo/app/store/flowRate/index.tsx | 34 ++++++++++++--- apps/fo/app/store/rdi/index.tsx | 32 ++++++++++---- apps/fo/app/store/sewageOccur/index.tsx | 14 ++++--- apps/fo/app/store/underWaterInput/index.tsx | 46 ++++++++++++++++++--- 4 files changed, 104 insertions(+), 22 deletions(-) diff --git a/apps/fo/app/store/flowRate/index.tsx b/apps/fo/app/store/flowRate/index.tsx index 7bec0be97..02b55bd30 100644 --- a/apps/fo/app/store/flowRate/index.tsx +++ b/apps/fo/app/store/flowRate/index.tsx @@ -175,11 +175,11 @@ const fetchFlowRateList = async (pageNo: number, pageSize: number, searchYear: s const tailStr = partCd ? '/' + partCd + '/' + nameCd + '/' + fcltCpct + '/' + operationValue + (fcltyNm && fcltyNm !== '' ? '/' + fcltyNm : '') : ''; const url = '/fclt/flow/' + pageNo + '/' + pageSize + '/' + searchYear + tailStr; const res = await getFetch('fo', url); - return { data: res.data, count: res.count } + return { data: res.data, count: res.count, status: res.status} } catch (error) { console.error('시설정보 유량현황 데이터를 가져오는데 실패했습니다:', error); console.log(error); - return { data: [], count: 0 }; + return { data: [], count: 0, status: 300 }; } } @@ -279,8 +279,32 @@ export const flowRateSearchReducer: (set: (fn: (state: FlowRateSearchType) => Fl isLoading: true, }, })); - const res = await fetchFlowRateList(pageNo, pageSize, searchYear, partCd, nameCd, fcltCpct, operationValue, fcltyNm); - const data = res.data; + + // const res = await fetchFlowRateList(pageNo, pageSize, searchYear, partCd, nameCd, fcltCpct, operationValue, fcltyNm); + + //--------- + const flowRateList: any[] = []; + const results: any[] = []; + for (let idx = 0; idx < pageSize; idx += 100) { + const tmpPageNo = Math.floor(idx / 100) + 1; + const tmpPageSize = Math.min(100, pageSize - idx); + const result = await fetchFlowRateList( tmpPageNo, tmpPageSize, searchYear, partCd, nameCd, fcltCpct, operationValue, fcltyNm); + results.push(result); + + } + console.log(results); + // 결과를 합치기 + + for (const res of results) { + if (res?.status === 200 && Array.isArray(res?.data)) { + flowRateList.push(...res.data); + } + } + const recordCount = results[0]?.count || 0; + //------- + + // const data = res.data; + const data = flowRateList; const excelDownList: ExcelType[] = []; const rtnData = data.map((item: flowRateListProps) => { item.fctCpc = parseFloat(item.fctCpc.toString().replace(/,/g, '')); @@ -316,7 +340,7 @@ export const flowRateSearchReducer: (set: (fn: (state: FlowRateSearchType) => Fl FlowRateList: pageSize < 5000 ? { ...state.FlowRateList, flowRateList: rtnData, - flowRateCount: res.count, + flowRateCount: recordCount, isLoading: false, } : { ...state.FlowRateList, diff --git a/apps/fo/app/store/rdi/index.tsx b/apps/fo/app/store/rdi/index.tsx index 67c6efa1e..ff6a23053 100644 --- a/apps/fo/app/store/rdi/index.tsx +++ b/apps/fo/app/store/rdi/index.tsx @@ -322,15 +322,33 @@ export const rdiReducer:(set:SetStateFunction)=>RdiActions=(set: SetStateFunctio fcltCdList.push(item.bscFctCd); }); - const rdiiDetailListRes : any = await fetchFacilityRdiiDetailList(searchYear, fcltCdList); - console.log(rdiiDetailListRes); + // const rdiiDetailListRes : any = await fetchFacilityRdiiDetailList(searchYear, fcltCdList); + + //--------- + const rainDetailList: Record = {}; + const results: any[] = []; + for (let idx = 0; idx < fcltCdList.length; idx += 100) { + const slicedItems = fcltCdList.slice(idx, idx + 100); + const result = await fetchFacilityRdiiDetailList(searchYear, slicedItems); + results.push(result); + } + //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); + if (!rainDetailList[keyStr]) rainDetailList[keyStr] = []; + rainDetailList[keyStr].push(...(value as any[])); + } + } + } + //------- + // console.log(rdiiDetailListRes); for (const item of rtnData) { - //const fcltyCd = item.bscFctCd; - //const res: any = await fetchFacilityWaterQltyListHist(searchYear, fcltyCd); - //const rdiiDetailList = res.data.wqltObjs; - const rdiiDetailList = rdiiDetailListRes?.data[item.bscFctCd]; - //console.log(rdiiDetailListRes); + // const rdiiDetailList = rdiiDetailListRes?.data[item.bscFctCd]; + const rdiiDetailList = rainDetailList[item.bscFctCd]; let rtnWinterInflBod = 0; let rtnSummerBodInfl = 0; diff --git a/apps/fo/app/store/sewageOccur/index.tsx b/apps/fo/app/store/sewageOccur/index.tsx index a0ff0a3f3..fd219c0f1 100644 --- a/apps/fo/app/store/sewageOccur/index.tsx +++ b/apps/fo/app/store/sewageOccur/index.tsx @@ -4,7 +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"; +// import { fetchFacilityRainDetailList } from "../facilityPrecipitation"; export type { TableUpperProps }; /** @@ -329,8 +329,8 @@ export const sewageOccurReducer: (set: any) => SewageOccurActions = (set: any) = }); }); - const soccurDetailRes: any = await fetchSweageOccurListFlow(searchYear, fcltCdList); - const wtrUsgYmRes: any = await fetchWtrUsgYmList(searchYear, fcltCdList); + // const soccurDetailRes: any = await fetchSweageOccurListFlow(searchYear, fcltCdList); + // const wtrUsgYmRes: any = await fetchWtrUsgYmList(searchYear, fcltCdList); //--------- const rainDetailList: Record = {}; @@ -350,7 +350,9 @@ export const sewageOccurReducer: (set: any) => SewageOccurActions = (set: any) = 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[])]; + //rainDetailList[keyStr] = [...(rainDetailList[keyStr] || []), ...(value as any[])]; + if (!rainDetailList[keyStr]) rainDetailList[keyStr] = []; + rainDetailList[keyStr].push(...(value as any[])); } } } @@ -358,7 +360,9 @@ export const sewageOccurReducer: (set: any) => SewageOccurActions = (set: any) = 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[])]; + // wtrDetailList[keyStr] = [...(wtrDetailList[keyStr] || []), ...(value as any[])]; + if (!wtrDetailList[keyStr]) wtrDetailList[keyStr] = []; + wtrDetailList[keyStr].push(...(value as any[])); } } } diff --git a/apps/fo/app/store/underWaterInput/index.tsx b/apps/fo/app/store/underWaterInput/index.tsx index 0a0ce9537..d4d4c39e2 100644 --- a/apps/fo/app/store/underWaterInput/index.tsx +++ b/apps/fo/app/store/underWaterInput/index.tsx @@ -368,13 +368,49 @@ export const underWaterReducer: (set: (fn: (state: UnderWaterType) => UnderWater }); }); - const soccurDetailRes: any = await fetchDetailListFlow(searchYear, fcltCdList); - const wtrUsgYmRes: any = await fetchWtrUsgYmList(searchYear, fcltCdList); - + // const soccurDetailRes: any = await fetchDetailListFlow(searchYear, fcltCdList); + // const wtrUsgYmRes: any = await fetchWtrUsgYmList(searchYear, fcltCdList); + //--------- + 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 fetchDetailListFlow(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[])]; + if (!rainDetailList[keyStr]) rainDetailList[keyStr] = []; + rainDetailList[keyStr].push(...(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[])]; + if (!wtrDetailList[keyStr]) wtrDetailList[keyStr] = []; + wtrDetailList[keyStr].push(...(value as any[])); + } + } + } + //------- for (const item of underWaterPropsList) { - 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]; let chungcunSumFlow = 0; // 청천유입량 let sumChungcunDay = 0; // 청천일수