diff --git a/apps/fo/app/store/facilityWaterQlty/index.tsx b/apps/fo/app/store/facilityWaterQlty/index.tsx index db60c5b2d..4a08b429a 100644 --- a/apps/fo/app/store/facilityWaterQlty/index.tsx +++ b/apps/fo/app/store/facilityWaterQlty/index.tsx @@ -282,15 +282,19 @@ const upHeadListModalChongIn: TableUpperProps[] = [ ====================================*/ // 메인페이지 // 시설정보 수질 리스트 데이터 호출 -const fetchFacilityWaterQltyList = async (pageNo: number, pageSize: number, searchYear: string, partCd?: string | undefined, nameCd?: string | undefined, fcltCpct?: string | undefined, operationValue?: string | undefined, fcltyNm?: string | undefined): Promise<{ data: FacilityWaterQltyProps[], count: number }> => { +const fetchFacilityWaterQltyList = async ( + pageNo: number, pageSize: number, searchYear: string, partCd?: string | undefined + , nameCd?: string | undefined, fcltCpct?: string | undefined + , operationValue?: string | undefined, fcltyNm?: string | undefined +): Promise<{ data: FacilityWaterQltyProps[], count: number, status: number }> => { try { const tailStr = partCd ? '/' + partCd + '/' + nameCd + '/' + fcltCpct + '/' + operationValue + (fcltyNm && fcltyNm !== '' ? '/' + fcltyNm : '') : ''; const url = '/fclt/qlty/' + 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); - return { data: [], count: 0 }; + return { data: [], count: 0, status: 300 }; } } @@ -457,8 +461,27 @@ export const facilityWaterQltyReducer = (set: SetFunc): FacilityWaterQltyActions isLoading: true, }, })); - const res = await fetchFacilityWaterQltyList(pageNo, pageSize, searchYear, part, nameCd, fcltCpct, operationValue, fcltyNm); - const rtnData = res.data.map(item => { + + // const res = await fetchFacilityWaterQltyList(pageNo, pageSize, searchYear, part, nameCd, fcltCpct, operationValue, fcltyNm); + //--------- + const waterQltyList: any[] = []; + let recordCount = 0; + 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 fetchFacilityWaterQltyList(tmpPageNo, tmpPageSize, searchYear, part, nameCd, fcltCpct, operationValue, fcltyNm); + if (result?.status === 200 && Array.isArray(result?.data)) { + waterQltyList.push(...result.data); + } + recordCount = result?.count || 0; + if (result?.count < tmpPageNo * tmpPageSize) { + break; // 더 이상 데이터가 없으면 중지 + } + } + //------- + + // const rtnData = res.data.map(item => { + const rtnData = waterQltyList.map(item => { dataFormSetting(item) if (item.inflAssctBfrWqltTn) { item.inflAssctBfrWqltTn = Number(Math.round(Number(item.inflAssctBfrWqltTn) * 1000) / 1000).toFixed(3); @@ -500,7 +523,8 @@ export const facilityWaterQltyReducer = (set: SetFunc): FacilityWaterQltyActions }); const excelDownList: ExcelType[] = []; if (pageSize > 5000) { - res.data.forEach(item => { + // res.data.forEach(item => { + waterQltyList.forEach(item => { dataFormSetting(item) item.fctCpc = parseFloat(item.fctCpc.toString().replace(/,/g, '')); item.sidoNm = item.lclgvrnmntNm.split(' ')[0]?.toString() || ''; @@ -531,7 +555,8 @@ export const facilityWaterQltyReducer = (set: SetFunc): FacilityWaterQltyActions }); }); } else { - res.data.forEach((item: FacilityWaterQltyProps) => { + // res.data.forEach((item: FacilityWaterQltyProps) => { + waterQltyList.forEach((item: FacilityWaterQltyProps) => { dataFormSetting(item) item.fctCpc = parseFloat(item.fctCpc.toString().replace(/,/g, '')); item.sidoNm = item.lclgvrnmntNm.split(' ')[0]?.toString() || ''; @@ -545,7 +570,7 @@ export const facilityWaterQltyReducer = (set: SetFunc): FacilityWaterQltyActions FacilityWaterQltyMain: pageSize < 5000 ? { ...state.FacilityWaterQltyMain, facilityWaterQltyList: rtnData, - facilityWaterQltyCount: res.count, + facilityWaterQltyCount: recordCount, isLoading: false, } : { ...state.FacilityWaterQltyMain, diff --git a/apps/fo/app/store/flowRate/index.tsx b/apps/fo/app/store/flowRate/index.tsx index 02b55bd30..232755c1d 100644 --- a/apps/fo/app/store/flowRate/index.tsx +++ b/apps/fo/app/store/flowRate/index.tsx @@ -290,7 +290,9 @@ export const flowRateSearchReducer: (set: (fn: (state: FlowRateSearchType) => Fl const tmpPageSize = Math.min(100, pageSize - idx); const result = await fetchFlowRateList( tmpPageNo, tmpPageSize, searchYear, partCd, nameCd, fcltCpct, operationValue, fcltyNm); results.push(result); - + if (result?.count < tmpPageNo * tmpPageSize) { + break; // 더 이상 데이터가 없으면 중지 + } } console.log(results); // 결과를 합치기 diff --git a/apps/fo/app/store/planSewage/index.tsx b/apps/fo/app/store/planSewage/index.tsx index 2fd9b531c..b11130a16 100644 --- a/apps/fo/app/store/planSewage/index.tsx +++ b/apps/fo/app/store/planSewage/index.tsx @@ -4,6 +4,7 @@ import { getFetch, postFetch } from "@/app/components/api"; import { type ApiResponse } from "../underWaterInput"; // import CalcRainEffect from "@/app/components/common/CalcRainEffect"; import { roundUp } from "../common"; +import { fetchSweageOccurListFlow, fetchWtrUsgYmList } from "../sewageOccur"; export type { TableUpperProps }; /** * 처리시설 연간 운영현황 > 계획하수량 산정지표 현황 @@ -101,14 +102,15 @@ const planSewageList: PlanSewageProps[] = [ * @param oprtngSttsCd : 운영 상태 코드 * @param facilityName : 시설명 */ -const fetchPlanSewageList = async (pageNo: number, pageSize: number, searchYear: string, partCd?: string, nameCd?: string, fcltCpct?: string, operationValue?: string, fcltyNm?: string) => { +const fetchPlanSewageList = async (pageNo: number, pageSize: number, searchYear: string, partCd?: string, nameCd?: string + , fcltCpct?: string, operationValue?: string, fcltyNm?: string) => { const tailStr = partCd ? '/' + partCd + '/' + (nameCd || '0') + '/' + (fcltCpct || '0') + '/' + (operationValue || '0') + '/0' + (fcltyNm && fcltyNm !== '' ? '/' + fcltyNm : '') : ''; const url = '/prcsFclt/info/plan/' + pageNo + '/' + pageSize + '/' + searchYear + tailStr; const res = await getFetch('fo', url); return { data: res.data, count: res.count } } -// 분류식화율 구하기 위한 api 호출 +// 분류식화율 구하기 위한 api 호출 : 분류식화율 = 분류식지역 면적(㎢) / 처리​구역 면적합계(㎢) × 100 const fetchPlanZoneList = async (searchYear: string, fcltCdList: string[]) => { try { const res = await postFetch('fo', '/prcsFclt/info/planZone/' + searchYear, fcltCdList); @@ -251,19 +253,50 @@ export const planSewageReducer: (set: (fn: (state: PlanSewageType) => PlanSewage const excelDownList: ExcelType[] = []; // const data = res.data - const planZoneRes: any = await fetchPlanZoneList(searchYear, fcltCdList); - const planZoneList = planZoneRes?.data; + // 분류식화율 구하기 위한 api 호출 : 분류식화율 = 분류식지역 면적(㎢) / 처리​구역 면적합계(㎢) × 100 + // const planZoneRes: any = await fetchPlanZoneList(searchYear, fcltCdList); + // const detailRes: any = await fetchFlow(searchYear, fcltCdList); + //--------- + const planZoneList: any[] = []; + const flowDetailList: Record = {}; + // const results: any[] = []; + const flowDetailResults: any[] = []; + for (let idx = 0; idx < fcltCdList.length; idx += 100) { + const slicedItems = fcltCdList.slice(idx, idx + 100); + const result = await fetchPlanZoneList(searchYear, slicedItems); // 분류식화율 구하기 위한 api 호출 : 분류식화율 = 분류식지역 면적(㎢) / 처리​구역 면적합계(㎢) × 100 + const flowResult = await fetchFlow(searchYear, slicedItems); + if (result?.status === 200 && Array.isArray(result?.data)) { + planZoneList.push(...result.data); + } + flowDetailResults.push(flowResult); + } + //console.log(results); + // 결과를 합치기 + for (const res of flowDetailResults) { + if (res.status === 200 && res.data) { + for (const [key, value] of Object.entries(res.data)) { + const keyStr = String(key); + if (!flowDetailList[keyStr]) flowDetailList[keyStr] = []; + flowDetailList[keyStr].push(...(value as any[])); + } + } + } + //------- + + + // const planZoneList = planZoneRes?.data; planZoneList?.forEach(item => { const planSewageItem = planSewageList.find(item2 => item2.bscFctCd == item.bscFctCd); if (planSewageItem) { - planSewageItem.sprtProcZoneAr = item.sprtProcZoneAr; - planSewageItem.procZoneSm = item.procZoneSm; + planSewageItem.sprtProcZoneAr = item.sprtProcZoneAr; // 처리구역면적_분류식 + planSewageItem.procZoneSm = item.procZoneSm; //처리구역면적합계 } }); - const detailRes: any = await fetchFlow(searchYear, fcltCdList); + //const detailRes: any = await fetchFlow(searchYear, fcltCdList); for (const item of planSewageList) { - const detailList = detailRes?.data[item.bscFctCd]; + // const detailList = detailRes?.data[item.bscFctCd]; + const detailList = flowDetailList[item.bscFctCd]; let avgInflAmnt = 0; let sumInflAmntSunny = 0;