Merge branch 'iipbs/fo/dev' into iipbs/sn/dev

This commit is contained in:
2025-10-27 20:53:03 +09:00
8 changed files with 96 additions and 55 deletions
@@ -9,7 +9,7 @@ import CommaToNumber from "@/app/components/common/CommaToNumber";
import { roundNumber } from "@/app/components/common/DataForm";
import UnderComment from "@/app/components/common/UnderComment";
import { useFoStore } from "@/app/store";
import type { FacilityWaterQltyProps, modalExcelType } from "@/app/store/facilityWaterQlty";
import type { FacilityWaterQltyProps, modalChoinginExcelType, modalExcelType } from "@/app/store/facilityWaterQlty";
import { downloadExcelFormat, UITab, UiTable } from "@common/business_components/ui";
import { Button, TabsContent } from "@common/components/ui";
import { useCallback, useEffect, useRef, useState } from "react";
@@ -51,6 +51,8 @@ const tabList3 = [
];
export default function WaterQualityModal({fcltyName='', facilityCd='', searchYear=new Date().getFullYear().toString()} : ModalProps) {
const [tabName, setTabName] = useState<string>('tab_num1');
// 그리드 관련
const {FacilityWaterQltyModal,
searchFacilityWaterQltyListHist,
@@ -68,6 +70,7 @@ export default function WaterQualityModal({fcltyName='', facilityCd='', searchYe
} = FacilityWaterQltyModal;
const prevExcelListRef = useRef<modalExcelType[] | null>(null);
const prevChoinginExcelListRef = useRef<modalChoinginExcelType[] | null>(null);
// 필터링 된 후 최대, 최소, 평균 값 계산
const setFilterAfterData = (filteredData: FacilityWaterQltyProps[]) => {
@@ -351,43 +354,76 @@ export default function WaterQualityModal({fcltyName='', facilityCd='', searchYe
}, []);
const excelDownload = () => {
const excelDownList: modalExcelType[] = [];
if(copyYearList.length > 0){
copyYearList.forEach((item) => {
excelDownList.push({
날짜: item.msrDt,
"유입BOD(mg/L)": CommaToNumber(item.inflAssctBfrWqltBod),
"유입TOC(COD)(mg/L)": CommaToNumber(item.inflAssctBfrWqltToc),
"유입SS(mg/L)": CommaToNumber(item.inflAssctBfrWqltSs),
"유입TN(mg/L)": CommaToNumber(item.inflAssctBfrWqltTn),
"유입TP(mg/L)": CommaToNumber(item.inflAssctBfrWqltTp),
"유출BOD(mg/L)": CommaToNumber(item.efflWqltBod),
"유출TOC(COD)(mg/L)": CommaToNumber(item.efflWqltToc),
"유출SS(mg/L)": CommaToNumber(item.efflWqltSs),
"유출TN(mg/L)": CommaToNumber(item.efflWqltTn),
"유출TP(mg/L)": CommaToNumber(item.efflWqltTp),
"강우량(mm/일)": CommaToNumber(item.infoRnDay?item.infoRnDay.toString():"0.0"),
if(tabName === 'tab_num1'){
const excelDownList: modalExcelType[] = [];
if(copyYearList.length > 0){
copyYearList.forEach((item) => {
excelDownList.push({
날짜: item.msrDt,
"유입BOD(mg/L)": CommaToNumber(item.inflAssctBfrWqltBod),
"유입TOC(COD)(mg/L)": CommaToNumber(item.inflAssctBfrWqltToc),
"유입SS(mg/L)": CommaToNumber(item.inflAssctBfrWqltSs),
"유입TN(mg/L)": CommaToNumber(item.inflAssctBfrWqltTn),
"유입TP(mg/L)": CommaToNumber(item.inflAssctBfrWqltTp),
"유출BOD(mg/L)": CommaToNumber(item.efflWqltBod),
"유출TOC(COD)(mg/L)": CommaToNumber(item.efflWqltToc),
"유출SS(mg/L)": CommaToNumber(item.efflWqltSs),
"유출TN(mg/L)": CommaToNumber(item.efflWqltTn),
"유출TP(mg/L)": CommaToNumber(item.efflWqltTp),
"강우량(mm/일)": CommaToNumber(item.infoRnDay?item.infoRnDay.toString():"0.0"),
});
});
});
}
if (excelDownList && excelDownList.length > 0) {
downloadExcelFormat(
{ data: JSON.parse(JSON.stringify(excelDownList))
, fileName: searchYear+'년 '+fcltyName + ' 수질현황'
, sheetNameArray: [fcltyName + ' 수질현황']
, headerRange: 'A1:L1'
, decimalArray1: [1,2,3,6,7,8,11]
, decimalArray3: [4,5,9,10]
}
if (excelDownList && excelDownList.length > 0) {
downloadExcelFormat(
{ data: JSON.parse(JSON.stringify(excelDownList))
, fileName: searchYear+'년 '+fcltyName + ' 수질현황'
, sheetNameArray: [fcltyName + ' 수질현황']
, headerRange: 'A1:L1'
, decimalArray1: [1,2,3,6,7,8,11]
, decimalArray3: [4,5,9,10]
});
} else if (prevExcelListRef.current && prevExcelListRef.current.length > 0) {
alert('다운받을 데이터가 없습니다.');
}
prevExcelListRef.current = excelDownList;
}else{
const excelDownList: modalChoinginExcelType[] = [];
if(chongInWaterQltyYearList.length > 0){
chongInWaterQltyYearList.forEach((item) => {
excelDownList.push({
날짜: item.msrDt,
"유입BOD(mg/L)": CommaToNumber(item.tpInflWqltBod),
"유입TP(mg/L)": CommaToNumber(item.tpInflWqltTp),
"유출BOD(mg/L)": CommaToNumber(item.efflWqltBod),
"유출TP(mg/L)": CommaToNumber(item.efflWqltTn),
});
});
} else if (prevExcelListRef.current && prevExcelListRef.current.length > 0) {
alert('다운받을 데이터가 없습니다.');
}
if (excelDownList && excelDownList.length > 0) {
downloadExcelFormat(
{ data: JSON.parse(JSON.stringify(excelDownList))
, fileName: searchYear+'년 '+fcltyName + ' 총인설비수질현황'
, sheetNameArray: [fcltyName + ' 총인설비수질현황']
, headerRange: 'A1:E1'
, decimalArray1: [1,3]
, decimalArray3: [2,4]
});
} else if (prevChoinginExcelListRef.current && prevChoinginExcelListRef.current.length > 0) {
alert('다운받을 데이터가 없습니다.');
}
prevChoinginExcelListRef.current = excelDownList;
}
prevExcelListRef.current = excelDownList;
}
useEffect(() => {
setTabName("tab_num1");
}, []);
return (
<>
<UITab tabList={tabList1} defaultValue="tab_num1">
<UITab tabList={tabList1} defaultValue="tab_num1" onValueChange={(value) => setTabName(value)}>
<Button className={btnClass} style={{float: 'right'}} color="green" onClick={excelDownload}>
{"엑셀다운로드"}
</Button>
@@ -555,7 +591,7 @@ export default function WaterQualityModal({fcltyName='', facilityCd='', searchYe
</TabsContent>
{/* 총인설비 수질현황 */}
<TabsContent value="tab_num2">
<TabsContent value="tab_num2" >
<UITab tabList={tabList3} defaultValue="tab_term_year_chongin">
<TabsContent value="tab_term_year_chongin">
<FacilityTermModalHeader<FacilityWaterQltyProps>
+3 -3
View File
@@ -126,7 +126,7 @@ export default function Rdi() {
data: excelList as unknown as JSON[],
fileName: 'RDII추정',
sheetNameArray: ['RDII추정'],
headerRange: 'A1:O1'
headerRange: 'A1:R1'
});
}
}, [excelList, isInitExcelDownload]);
@@ -167,9 +167,9 @@ export default function Rdi() {
// 엑셀다운로드
const excelDownload = useCallback(() => {
searchRdi(ref.current, 1, rdiCount);
searchRdi(ref.current, 1, 5000);
setIsInitExcelDownload(true);
}, [searchRdi, rdiCount]);
}, [searchRdi]);
// 페이지 변경
const handlePageChange = useCallback((page: number) => {
@@ -196,9 +196,9 @@ export default function PlanSewage() {
// 엑셀다운로드
const excelDownload = useCallback(() => {
searchFacilityPrecipitation(ref.current, 1, sewageOccurCount);
searchFacilityPrecipitation(ref.current, 1, 5000);
setIsInitExcelDownload(true);
}, [searchFacilityPrecipitation, sewageOccurCount]);
}, [searchFacilityPrecipitation]);
// 페이지 변경
const handlePageChange = useCallback((page: number) => {
@@ -151,7 +151,7 @@ export default function UnderWaterInput() {
data: excelList as unknown as JSON[],
fileName: '지하수유입량 추정',
sheetNameArray: ['지하수유입량 추정'],
headerRange: 'A1:V1'
headerRange: 'A1:O1'
});
}
}, 1000); // 약간의 지연을 두고 다운로드 실행
@@ -181,7 +181,7 @@ export default function UnderWaterInput() {
}
if (partStr.length > 1 || fcltCpct !== '0' || operationValue!== '0' ||nameCd ||(fcltyName.trim() !== "" && fcltyName.trim() !== null)) {
searchUnderWaterList(pageNo, pageCnt, searchYear, partStr, nameCd || '0', fcltCpct, operationValue, fcltyName.trim() !== "" || fcltyName.trim() !== null ? fcltyName : undefined);
} else {
} else {
searchUnderWaterList(pageNo, pageCnt, searchYear);
}
}, [fcltCpct, operationValue, fcltyName, searchUnderWaterList, searchYear]);
@@ -194,9 +194,9 @@ export default function UnderWaterInput() {
// 엑셀다운로드
const excelDownload = useCallback(() => {
searchFacilityPrecipitation(ref.current, 1, underWaterCount);
searchFacilityPrecipitation(ref.current, 1, 5000);
setIsMount(true);
}, [searchFacilityPrecipitation, underWaterCount]);
}, [searchFacilityPrecipitation]);
// 페이지 변경
const handlePageChange = useCallback((page: number) => {
@@ -118,6 +118,14 @@ export type modalExcelType = {
"강우량(mm/일)": number | '';
}
export type modalChoinginExcelType = {
날짜: string;
"유입BOD(mg/L)": number | '';
"유입TP(mg/L)": number | '';
"유출BOD(mg/L)": number | '';
"유출TP(mg/L)": number | '';
}
/**====================================
* Store - data
====================================*/
+6 -7
View File
@@ -260,7 +260,6 @@ export type RdiStore = RdiType & RdiActions;
export const rdiReducer:(set:SetStateFunction)=>RdiActions=(set: SetStateFunction) => {
return {
resetExcelList: () => {
console.log('reset!!!!!');
set((state: RdiType) => ({
...state,
Rdi: {
@@ -280,7 +279,7 @@ export const rdiReducer:(set:SetStateFunction)=>RdiActions=(set: SetStateFunctio
}));
const res = await fetchRdiList(pageNo, pageSize, searchYear, partCd, nameCd, fcltCpct, operationValue, fcltyNm);
if(pageSize>=res.count){
if(pageSize>=5000){
set((state: RdiType) => ({
...state,
Rdi: {
@@ -414,11 +413,11 @@ export const rdiReducer:(set:SetStateFunction)=>RdiActions=(set: SetStateFunctio
item.summerMinBodValue = roundNumber(rtnSummerBod,1);
item.inflAmnt = roundNumber(rtnSummerBodInfl.toString(), 0);
item.winterAvgBodLowRainfall = roundNumber(rtnWinterInflBod, 1);
item.rdiiValue = roundNumber(rtnRdiValue, 0);
item.winterAvgBodLowRainfall = rtnWinterInflBod?roundNumber(rtnWinterInflBod, 1):0;
item.rdiiValue = rtnRdiValue?roundNumber(rtnRdiValue, 0):0;
item.infoRnDay = roundNumber(rtnRdiRain, 0);
item.chungchunFlow = roundNumber(chungchunFlow, 0);
item.rainCalInflAmnt = roundNumber(Number(item.chungchunFlow.toString().replaceAll(',','')) + Number(item.rdiiValue.toString().replaceAll(',','')), 0);
item.rainCalInflAmnt = roundNumber(Number(item.chungchunFlow.toString().replaceAll(',','')) + Number(item.rdiiValue.toString().replaceAll(',','')), 0) || 0;
item.properYn = Number(item.rainCalInflAmnt.toString().replaceAll(',','')) > Number(item.fctCpc.toString().replaceAll(',','')) ? '초과유입' : '적정';
}
@@ -427,7 +426,7 @@ export const rdiReducer:(set:SetStateFunction)=>RdiActions=(set: SetStateFunctio
dataFormSetting(item);
})
if(pageSize>=res.count){
if(pageSize>=5000){
rtnData.forEach((item: RdiProps) => {
excelDownList.push({
시설코드: item.bscFctCd,
@@ -453,7 +452,7 @@ export const rdiReducer:(set:SetStateFunction)=>RdiActions=(set: SetStateFunctio
}
set((state: RdiType) => ({
...state,
Rdi: pageSize<res.count?{
Rdi: pageSize<5000?{
...state.Rdi,
rdiList: rtnData,
rdiCount: res.count,
+3 -4
View File
@@ -231,12 +231,12 @@ export const sewageOccurReducer:(set:any)=>SewageOccurActions=(set: any) => {
return {
searchSewageOccurList: async (pageNo: number, pageSize: number, searchYear: string, part?: string, nameCd?: string, fcltCpct?: string, operationValue?: string, fcltyNm?: string) => {
const facilityInitData = await fetchFacilityListInit(pageNo, pageSize, part, nameCd, fcltCpct, operationValue, fcltyNm);
if(pageSize < facilityInitData.count){
if(pageSize < 5000){
set((state: SewageOccurType) => ({
...state,
SewageOccur: {
...state.SewageOccur,
sewageOccurList : facilityInitData.data,
sewageOccurList : [],
sewageOccurCount : facilityInitData.count,
excelList : [],
isLoading: true
@@ -254,7 +254,6 @@ export const sewageOccurReducer:(set:any)=>SewageOccurActions=(set: any) => {
}
const fcltylist = facilityInitData.data;
const fcltyCount = facilityInitData.count;
const calData = await processInBatches(fcltylist, 20, async (item: SewageOccurProps, index: number) => {
const bscFctCd = item.bscFctCd;
@@ -298,7 +297,7 @@ export const sewageOccurReducer:(set:any)=>SewageOccurActions=(set: any) => {
return {...item, index:index};
});
if(pageSize >= fcltyCount){
if(pageSize >= 5000){
const excelDownList: ExcelType[] = [];
calData.forEach((item: SewageOccurProps) => {
excelDownList.push({
+2 -3
View File
@@ -291,7 +291,7 @@ export const underWaterReducer:(set:(fn: (state: UnderWaterType) => UnderWaterTy
searchUnderWaterList: async (pageNo: number, pageSize: number, searchYear: string, part?: string, nameCd?: string, fcltCpct?: string, operationValue?: string, fcltyNm?: string) => {
const facilityInitData = await fetchFacilityListInit(pageNo, pageSize, part, nameCd, fcltCpct, operationValue, fcltyNm);
if(pageSize < facilityInitData.count){
if(pageSize < 5000){
set((state: UnderWaterType) => ({
...state,
UnderWater: {
@@ -313,7 +313,6 @@ export const underWaterReducer:(set:(fn: (state: UnderWaterType) => UnderWaterTy
}
const fcltylist = facilityInitData.data;
const fcltyCount = facilityInitData.count;
const calData = await processInBatches(fcltylist, 20, async (item: any, index: number) => {
const bscFctCd = item.bscFctCd;
@@ -369,7 +368,7 @@ export const underWaterReducer:(set:(fn: (state: UnderWaterType) => UnderWaterTy
return {...item, index:index};
});
if(pageSize>= fcltyCount){
if(pageSize>= 5000){
const excelDownList: ExcelType[] = [];
calData.forEach((item : any) => {
dataFormSetting(item)