diff --git a/apps/fo/app/store/sewageOccur/index.tsx b/apps/fo/app/store/sewageOccur/index.tsx index dfd7e2bca..66cd1840e 100644 --- a/apps/fo/app/store/sewageOccur/index.tsx +++ b/apps/fo/app/store/sewageOccur/index.tsx @@ -48,6 +48,20 @@ export type WtrUsgYmProps = { levyYm: string, // 부과년월 wtrUsg: number, // 월별 물사용량(m³/월) } + +export type SewageOccurSummaryRow = { + bscFctCd?: string; + BSC_FCT_CD?: string; + waterUsage?: string | number; + estimationSewage?: string | number; + sewageInputYear?: string | number; + sewageInputChungchun?: string | number; +} + +export type SewageOccurSummaryResponse = { + status?: number; + data?: SewageOccurSummaryRow[]; +} // 검색단 const LabelArray: string[] = ['구분', '시도', '시군구', '용량별', '시설명', '조회기간', '시설상태', '권역', '단위유역', '중권역', '환경청별']; @@ -174,9 +188,10 @@ function getDaysInMonth(yyyymm) { // } // 시설들 유량 정보 조회 -export const fetchSweageOccurListFlow = async (searchYear: string | undefined, fcltCdList: string[]): Promise => { +export const fetchSweageOccurListFlow = async (searchYear: string | undefined, fcltCdList: string[]): Promise => { try { - const res = await postFetch('fo', '/fclt/flow/' + searchYear, fcltCdList); + // const res = await postFetch('fo', '/fclt/flow/' + searchYear, fcltCdList); + const res = await postFetch('fo', '/fclt/flow/sewageOccur/' + searchYear, fcltCdList); return res; } catch (error) { console.error('시설정보 오수발생량 상세 데이터를 가져오는데 실패했습니다:', error); @@ -317,7 +332,7 @@ export const sewageOccurReducer: (set: any) => SewageOccurActions = (set: any) = daddr: item.daddr, fctCpc: parseFloat(item.fctCpc.toString().replace(/,/g, '')), waterUsage: 0, - swageChangePercent: 0, + swageChangePercent: 90, estimationSewage: 0, sewageInputYear: 0, sewageInputChungchun: 0, @@ -328,34 +343,39 @@ export const sewageOccurReducer: (set: any) => SewageOccurActions = (set: any) = msrDt: '', }); }); - + const sewageOccurMap = new Map( + sewageOccurPropsList.map((item) => [item.bscFctCd, item]) + ); + console.log(sewageOccurMap); // const soccurDetailRes: any = await fetchSweageOccurListFlow(searchYear, fcltCdList); // const wtrUsgYmRes: any = await fetchWtrUsgYmList(searchYear, fcltCdList); //--------- - const rainDetailList: Record = {}; + // 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 slicedItems = fcltCdList.slice(idx, idx + 100); // 100건씩 가져오기 const result = await fetchSweageOccurListFlow(searchYear, slicedItems); const wtrResult = await fetchWtrUsgYmList(searchYear, slicedItems); - results.push(result); + + if (result?.status === 200 && Array.isArray(result.data)) { + result.data.forEach((row: any) => { + const bscFctCd = String(row.bscFctCd ?? ""); + const target = sewageOccurMap.get(bscFctCd); + + if (!target) return; + + target.waterUsage = Number(row.waterUsage ?? 0); + target.estimationSewage = Number(row.estimationSewage ?? 0); + target.sewageInputYear = Number(row.sewageInputYear ?? 0); + target.sewageInputChungchun = Number(row.sewageInputChungchun ?? 0); + }); + } + 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)) { @@ -368,34 +388,10 @@ export const sewageOccurReducer: (set: any) => SewageOccurActions = (set: any) = } //------- - let maxEstimationSewage = 0, minEstimationSewage = 999999999; + // let maxEstimationSewage = 0, minEstimationSewage = 999999999; for (const item of sewageOccurPropsList) { - - //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; // 청천일수 - let chungcunSumFlow = 0;// 청천시 하수유입량 - let totWaterUsage = 0; // 연간 하수유입량 - let rainEffectDay = 0; - detailList?.forEach(item2 => { - - if (item2.infoRnDay == null || item2.infoRnDay == 'x') item2.infoRnDay = 0; - if (item2.infoRnDay >= 3) { - rainEffectDay = 2; - } else { - rainEffectDay--; - } - if (rainEffectDay < 0) { //청천시 - chungcunSumFlow += item2.inflAmnt && item2.inflAmnt !== 'x' ? Number(item2.inflAmnt.toString().trim()) : 0;//Number(item2.inflAmnt); - sumChungcunDay += 1; - } - totWaterUsage += Number(item2.inflAmnt); - }); - let wtrUsgYearTotal = 0; // 연간 물사용량 let wtrUsgYearDays = 0; // 연간 물사용 일수 wtrUsgYmList?.forEach(item3 => { @@ -404,22 +400,9 @@ export const sewageOccurReducer: (set: any) => SewageOccurActions = (set: any) = wtrUsgYearDays += days; }); - // console.log("totWaterUsage:", totWaterUsage); - const count = detailList ? detailList.length : 0; - const avg = count == 0 ? 0 : totWaterUsage / count; // 연간 하수유입량(m³/일) - item.waterUsage = parseFloat((avg * 0.65).toFixed(2)); // 물사용량 = 연간 하수유입량(m³/일) * 65% : 실제 수용가의 물사용량 없는 경우 if (wtrUsgYearTotal > 0 && wtrUsgYearDays > 0) { item.waterUsage = wtrUsgYearDays > 0 ? wtrUsgYearTotal / wtrUsgYearDays : 0; // 일평균 물사용량: 실제 수용가의 물사용량 } - item.sewageInputYear = parseFloat(avg.toFixed(2)); // 연간 하수유입량(m³/일) - item.sewageInputChungchun = parseFloat((chungcunSumFlow === 0 ? 0 : (chungcunSumFlow / sumChungcunDay)).toFixed(2)); // 청천시 하수유입량 - item.estimationSewage = parseFloat((item.waterUsage * OSU_PERCENT).toFixed(2)); // 오수발생량 추정(m³/일) = 물사용량(m³/일) * 오수전환율 - if (item.estimationSewage > maxEstimationSewage) maxEstimationSewage = item.estimationSewage; - if (item.estimationSewage < minEstimationSewage) minEstimationSewage = item.estimationSewage; - // 반올림 처리 - ["fctCpc", "waterUsage", "swageChangePercent", "estimationSewage", "sewageInputYear", "sewageInputChungchun"].forEach( - (key) => (item[key] = roundNumber(item[key], 0)) - ); } if (pageSize >= 5000) { @@ -590,4 +573,4 @@ export const sewageOccurReducer: (set: any) => SewageOccurActions = (set: any) = })) }, } -} \ No newline at end of file +} diff --git a/apps/fo/next.config.ts b/apps/fo/next.config.ts index 6a892461e..01569bf17 100644 --- a/apps/fo/next.config.ts +++ b/apps/fo/next.config.ts @@ -1,6 +1,6 @@ import type { NextConfig } from "next"; -const domain = process.env.NEXT_PUBLIC_PROXY_HOST || "http://localhost:3000"; +// const domain = process.env.NEXT_PUBLIC_PROXY_HOST || "http://localhost:3000"; const subDomain = process.env.NEXT_PUBLIC_SUB_DOMAIN || "http://localhost:13000"; const nextConfig: NextConfig = { @@ -24,22 +24,22 @@ const nextConfig: NextConfig = { }, ], afterFiles: [ - { - source: "/sewerage-service/:path*", - destination: `${domain}/sewerage-service/:path*`, - }, - { - source: "/reuse-service/:path*", - destination: `${domain}/reuse-service/:path*`, - }, - { - source: "/operation-service/:path*", - destination: `${domain}/operation-service/:path*`, - }, - { - source: "/ngii-server/:path*", - destination: `${domain}/ngii-server/:path*`, - }, + // { + // source: "/sewerage-service/:path*", + // destination: `${domain}/sewerage-service/:path*`, + // }, + // { + // source: "/reuse-service/:path*", + // destination: `${domain}/reuse-service/:path*`, + // }, + // { + // source: "/operation-service/:path*", + // destination: `${domain}/operation-service/:path*`, + // }, + // { + // source: "/ngii-server/:path*", + // destination: `${domain}/ngii-server/:path*`, + // }, { source: "/cms/:path*", destination: `${subDomain}/cms/:path*`,