fo: excel 조회 결과

This commit is contained in:
2026-01-30 10:39:41 +09:00
parent 1aaa8fcd6b
commit 39fb1d974a
10 changed files with 217 additions and 136 deletions
@@ -98,6 +98,7 @@ export default function FacilityPrecipitation() {
const [searchYear, setSearchYear] = useState<string>(defaultSearchYear);
// 엑셀다운로드 트리거
const [isExcelDownClick, setIsExcelDownClick] = useState<boolean>(false);
const excelWaitRef = useRef<boolean>(false);
/**
* 페이지 함수
*/
@@ -147,21 +148,28 @@ export default function FacilityPrecipitation() {
useEffect(() => {
if (!isExcelDownClick) return;
const timer = setTimeout(() => {
if (excelList && excelList.length > 0) {
downloadExcel({
data: excelList as unknown as JSON[],
fileName: '시설별 강수현황',
sheetNameArray: ['시설별 강수현황'],
headerRange: 'A1:N1'
});
} else {
alert("조회된 결과가 없습니다.");
}
setIsExcelDownClick(false);
}, 500);
return () => clearTimeout(timer);
}, [excelList]);
if (isLoading) {
excelWaitRef.current = true;
return;
}
if (!excelWaitRef.current) {
return;
}
if (excelList && excelList.length > 0) {
downloadExcel({
data: excelList as unknown as JSON[],
fileName: '시설별 강수현황',
sheetNameArray: ['시설별 강수현황'],
headerRange: 'A1:N1'
});
} else {
alert("조회된 결과가 없습니다.");
}
setIsExcelDownClick(false);
excelWaitRef.current = false;
}, [excelList, isExcelDownClick, isLoading]);
useEffect(() => {
if (facilityPrecipitation.length > 0) {
@@ -221,6 +229,7 @@ export default function FacilityPrecipitation() {
// return;
// }
// }
excelWaitRef.current = false;
searchFacilityPrecipitation(searchReturn, 1, 10000);
setIsExcelDownClick(true);
}, [searchFacilityPrecipitation]);
@@ -56,6 +56,7 @@ export default function ProcessFacilitySearch() {
const [initTrigger, setInitTrigger] = useState<boolean>(false);
// 엑셀다운로드 트리거
const [isExcelDownClick, setIsExcelDownClick] = useState<boolean>(false);
const excelWaitRef = useRef<boolean>(false);
// 그리드 관련
const [resetPage, setResetPage] = useState<boolean>(false);
const searchInputRef = useRef<HTMLDivElement & HTMLInputElement>(null);
@@ -155,26 +156,32 @@ export default function ProcessFacilitySearch() {
useEffect(() => {
if (!isExcelDownClick) return;
const timer = setTimeout(() => {
if (excelList && excelList.length > 0) {
downloadExcelFormat(
{
data: excelList as unknown as JSON[],
fileName: '시설별 수질현황',
sheetNameArray: ['시설별 수질현황'],
headerRange: 'A1:T1',
decimalArray1: [10, 11, 12, 15, 16, 17],
decimalArray3: [13, 14, 18, 19]
}
);
} else {
alert("조회된 결과가 없습니다.");
}
setIsExcelDownClick(false);
}, 500);
if (isLoading) {
excelWaitRef.current = true;
return;
}
return () => clearTimeout(timer);
}, [excelList, isExcelDownClick]);
if (!excelWaitRef.current) {
return;
}
if (excelList && excelList.length > 0) {
downloadExcelFormat(
{
data: excelList as unknown as JSON[],
fileName: '시설별 수질현황',
sheetNameArray: ['시설별 수질현황'],
headerRange: 'A1:T1',
decimalArray1: [10, 11, 12, 15, 16, 17],
decimalArray3: [13, 14, 18, 19]
}
);
} else {
alert("조회된 결과가 없습니다.");
}
setIsExcelDownClick(false);
excelWaitRef.current = false;
}, [excelList, isExcelDownClick, isLoading]);
const chkVal = useCallback((returntype: ReturnType) => {
// setWidthSize(returntype.partValue=='A' ?"w-[120%]":"w-[130%]")
@@ -200,8 +207,9 @@ export default function ProcessFacilitySearch() {
}
}
setIsExcelDownClick(true);
excelWaitRef.current = false;
searchFcltyQltyList(ref.current, 1, 10000);
setIsExcelDownClick(true);
}, [searchFcltyQltyList]);
const handlePageChange = useCallback((page: number) => {
@@ -73,6 +73,7 @@ export default function ProcessFacilitySearch() {
const [fcltyNm, setFcltyNm] = useState<string>("");
const [fcltyCd, setFcltyCd] = useState<string>("");
const [isExcelDownClick, setIsExcelDownClick] = useState<boolean>(false);
const excelWaitRef = useRef<boolean>(false);
const [initTrigger, setInitTrigger] = useState<boolean>(false);
const searchFlowRate = useCallback(({ partValue, regionValue, unitWaterShedValue, middleRegionValue, envPartValue, sidoValue, sigunValue }: ReturnType, pageNo: number, pageCnt:number=20) => {
@@ -154,16 +155,23 @@ export default function ProcessFacilitySearch() {
useEffect(() => {
if(!isExcelDownClick) return;
const timer = setTimeout(() => {
if (excelList && excelList.length > 0) {
downloadExcelFormat({ data: JSON.parse(JSON.stringify(excelList)), fileName: '시설별 유량현황', sheetNameArray: ['시설별 유량현황'], headerRange: 'A1:O1', decimalArray0: [9,10,11,12,13,14] });
} else {
alert('조회된 결과가 없습니다.');
}
setIsExcelDownClick(false);
}, 1000); // 약간의 지연을 두고 다운로드 실행
return () => clearTimeout(timer);
}, [excelList, isExcelDownClick]);
if (isLoading) {
excelWaitRef.current = true;
return;
}
if (!excelWaitRef.current) {
return;
}
if (excelList && excelList.length > 0) {
downloadExcelFormat({ data: JSON.parse(JSON.stringify(excelList)), fileName: '시설별 유량현황', sheetNameArray: ['시설별 유량현황'], headerRange: 'A1:O1', decimalArray0: [9,10,11,12,13,14] });
} else {
alert('조회된 결과가 없습니다.');
}
setIsExcelDownClick(false);
excelWaitRef.current = false;
}, [excelList, isExcelDownClick, isLoading]);
const ref = useRef<ReturnType>({
partValue: '',
@@ -201,6 +209,7 @@ export default function ProcessFacilitySearch() {
}
}
excelWaitRef.current = false;
searchFlowRate(ref.current, 1, 10000);
setIsExcelDownClick(true);
}, [searchFlowRate]);
@@ -95,6 +95,7 @@ export default function PlanSewage() {
const [initTrigger, setInitTrigger] = useState<boolean>(false);
// 엑셀다운로드 트리거
const [isExcelDownClick, setIsExcelDownClick] = useState<boolean>(false);
const excelWaitRef = useRef<boolean>(false);
/**
* 페이지 함수
@@ -122,22 +123,28 @@ export default function PlanSewage() {
useEffect(() => {
if (!isExcelDownClick) return;
const timer = setTimeout(() => {
if (excelList && excelList.length > 0) {
downloadExcel({
data: excelList as unknown as JSON[],
fileName: '계획하수량 산정지표 현황',
sheetNameArray: ['계획하수량 산정지표 현황'],
headerRange: 'A1:M1'
});
} else {
alert("조회된 결과가 없습니다.");
}
setIsExcelDownClick(false);
}, 500);
return () => clearTimeout(timer);
}, [excelList, isExcelDownClick]);
if (isLoading) {
excelWaitRef.current = true;
return;
}
if (!excelWaitRef.current) {
return;
}
if (excelList && excelList.length > 0) {
downloadExcel({
data: excelList as unknown as JSON[],
fileName: '계획하수량 산정지표 현황',
sheetNameArray: ['계획하수량 산정지표 현황'],
headerRange: 'A1:M1'
});
} else {
alert("조회된 결과가 없습니다.");
}
setIsExcelDownClick(false);
excelWaitRef.current = false;
}, [excelList, isExcelDownClick, isLoading]);
/**
* 콜백함수
@@ -208,6 +215,7 @@ export default function PlanSewage() {
}
}
excelWaitRef.current = false;
searchPlanSewage(searchReturn, 1, 10000);
setIsExcelDownClick(true);
}, [searchPlanSewage]);
@@ -72,6 +72,7 @@ export default function ProcessArea() {
const [searchYearValue, setSearchYearValue] = useState<string>(defaultSearchYear);
const [isExcelDownClick, setIsExcelDownClick] = useState<boolean>(false);
const excelWaitRef = useRef<boolean>(false);
const ref = useRef<ReturnType>({
partValue: '',
@@ -130,21 +131,28 @@ export default function ProcessArea() {
useEffect(() => {
if(!isExcelDownClick) return;
const timer = setTimeout(() => {
if (excelList && excelList.length > 0) {
downloadExcel({
data: excelList as unknown as JSON[],
fileName: '처리구역정보',
sheetNameArray: ['처리구역정보'],
headerRange: 'A1:W1'
});
} else {
alert('조회된 결과가 없습니다.');
}
setIsExcelDownClick(false);
}, 500); // 약간의 지연을 두고 다운로드 실행
return () => clearTimeout(timer);
}, [excelList, isExcelDownClick]);
if (isLoading) {
excelWaitRef.current = true;
return;
}
if (!excelWaitRef.current) {
return;
}
if (excelList && excelList.length > 0) {
downloadExcel({
data: excelList as unknown as JSON[],
fileName: '처리구역정보',
sheetNameArray: ['처리구역정보'],
headerRange: 'A1:W1'
});
} else {
alert('조회된 결과가 없습니다.');
}
setIsExcelDownClick(false);
excelWaitRef.current = false;
}, [excelList, isExcelDownClick, isLoading]);
const excelDownload = useCallback(() => {
// if (ref.current.partValue === 'A') { // 행정별
@@ -164,6 +172,7 @@ export default function ProcessArea() {
// }
// }
excelWaitRef.current = false;
searchProcessArea(ref.current, 1, 10000);
setIsExcelDownClick(true);
}, [searchProcessArea]);
@@ -90,6 +90,7 @@ export default function ProcessFacilitySearch() {
// const [widthSize, setWidthSize] = useState<string>("w-[120%]");
const [upHeadList, setUpheadList] = useState(upHeadList1);
const [isExcelDownClick, setIsExcelDownClick] = useState<boolean>(false);
const excelWaitRef = useRef<boolean>(false);
/**
* 모달 상태 변수
@@ -151,18 +152,25 @@ export default function ProcessFacilitySearch() {
}, [partValue, upHeadList1, upHeadList2, upHeadList3]);
useEffect(() => {
if(!isExcelDownClick) return;
if (!isExcelDownClick) return;
const timer = setTimeout(() => {
if (excelList && excelList.length > 0) {
downloadExcel({ data: excelList as unknown as JSON[], fileName: '처리시설 시설정보', sheetNameArray: ['처리시설 시설정보'], headerRange: 'A1:P1' });
} else {
alert('조회된 결과가 없습니다.');
}
setIsExcelDownClick(false);
}, 500); // 약간의 지연을 두고 다운로드 실행
return () => clearTimeout(timer);
}, [excelList, isExcelDownClick]);
if (isLoading) {
excelWaitRef.current = true;
return;
}
if (!excelWaitRef.current) {
return;
}
if (excelList && excelList.length > 0) {
downloadExcel({ data: excelList as unknown as JSON[], fileName: '처리시설 시설정보', sheetNameArray: ['처리시설 시설정보'], headerRange: 'A1:P1' });
} else {
alert('조회된 결과가 없습니다.');
}
setIsExcelDownClick(false);
excelWaitRef.current = false;
}, [excelList, isExcelDownClick, isLoading]);
const searchFcltyList = useCallback(({ partValue, regionValue, unitWaterShedValue, middleRegionValue, envPartValue, sidoValue, sigunValue }: ReturnType, pageNo: number, pageCnt:number=10) => {
let nameCd, partStr
@@ -262,6 +270,7 @@ export default function ProcessFacilitySearch() {
// }
// }
excelWaitRef.current = false;
searchFcltyList(ref.current, 1, 10000);
setIsExcelDownClick(true);
}, [searchFcltyList]);
@@ -326,4 +335,4 @@ export default function ProcessFacilitySearch() {
)}
</MainDiv>
);
}
}
+23 -15
View File
@@ -91,6 +91,7 @@ export default function Rdi() {
const [searchYear, setSearchYear] = useState<string>(defaultSearchYear);
// 엑셀 다운로드 트리거
const [isExcelDownClick, setIsExcelDownClick] = useState<boolean>(false);
const excelWaitRef = useRef<boolean>(false);
const [initTrigger, setInitTrigger] = useState<boolean>(false);
@@ -121,22 +122,28 @@ export default function Rdi() {
useEffect(() => {
if(!isExcelDownClick) return ;
const timer = setTimeout(() => {
if (excelList && excelList.length > 0) {
downloadExcel({
data: excelList as unknown as JSON[],
fileName: 'RDII추정',
sheetNameArray: ['RDII추정'],
headerRange: 'A1:R1'
});
} else {
alert("조회된 결과가 없습니다.");
}
setIsExcelDownClick(false);
}, 500); // 약간의 지연을 두고 다운로드 실행
if (isLoading) {
excelWaitRef.current = true;
return;
}
return () => clearTimeout(timer);
}, [excelList, isExcelDownClick]);
if (!excelWaitRef.current) {
return;
}
if (excelList && excelList.length > 0) {
downloadExcel({
data: excelList as unknown as JSON[],
fileName: 'RDII추정',
sheetNameArray: ['RDII추정'],
headerRange: 'A1:R1'
});
} else {
alert("조회된 결과가 없습니다.");
}
setIsExcelDownClick(false);
excelWaitRef.current = false;
}, [excelList, isExcelDownClick, isLoading]);
/**
* 콜백함수
@@ -206,6 +213,7 @@ export default function Rdi() {
// }
// }
excelWaitRef.current = false;
searchRdi(ref.current, 1, 5000);
setIsExcelDownClick(true);
}, [searchRdi]);
@@ -101,6 +101,7 @@ export default function PlanSewage() {
const [searchYear, setSearchYear] = useState<string>(defaultSearchYear);
// 엑셀다운로드 트리거
const [isExcelDownClick, setIsExcelDownClick] = useState<boolean>(false);
const excelWaitRef = useRef<boolean>(false);
/**
* 페이지 함수
@@ -151,22 +152,28 @@ export default function PlanSewage() {
useEffect(() => {
if(!isExcelDownClick) return ;
const timer = setTimeout(() => {
if (excelList && excelList.length > 0) {
downloadExcel({
data: excelList as unknown as JSON[],
fileName: '오수발생량 추정',
sheetNameArray: ['오수발생량 추정'],
headerRange: 'A1:O1'
});
} else {
alert("조회된 결과가 없습니다.");
}
setIsExcelDownClick(false);
}, 500); // 약간의 지연을 두고 다운로드 실행
if (isLoading) {
excelWaitRef.current = true;
return;
}
return () => clearTimeout(timer);
}, [excelList, isInit, isExcelDownClick]);
if (!excelWaitRef.current) {
return;
}
if (excelList && excelList.length > 0) {
downloadExcel({
data: excelList as unknown as JSON[],
fileName: '오수발생량 추정',
sheetNameArray: ['오수발생량 추정'],
headerRange: 'A1:O1'
});
} else {
alert("조회된 결과가 없습니다.");
}
setIsExcelDownClick(false);
excelWaitRef.current = false;
}, [excelList, isExcelDownClick, isLoading]);
/**
* 콜백함수
@@ -190,7 +197,8 @@ export default function PlanSewage() {
break;
}
if (partStr.length > 1 || fcltCpct !== '0' || operationValue!== '0' ||nameCd ||(fcltyName.trim() !== "" && fcltyName.trim() !== null)) {
searchSewageOccurList(pageNo, pageCnt, searchYear, partStr, nameCd || '0', fcltCpct, operationValue, fcltyName.trim() !== "" || fcltyName.trim() !== null ? fcltyName : undefined);
searchSewageOccurList(pageNo, pageCnt, searchYear, partStr, nameCd || '0', fcltCpct, operationValue
, fcltyName.trim() !== ""? fcltyName : undefined);
} else {
searchSewageOccurList(pageNo, pageCnt, searchYear);
}
@@ -220,6 +228,7 @@ export default function PlanSewage() {
return;
}
}
excelWaitRef.current = false;
searchFacilityPrecipitation(ref.current, 1, 5000);
setIsExcelDownClick(true);
}, [searchFacilityPrecipitation]);
@@ -106,6 +106,7 @@ export default function UnderWaterInput() {
const [searchYear, setSearchYear] = useState<string>(defaultSearchYear);
// 엑셀다운로드 트리거
const [isExcelDownClick, setIsExcelDownClick] = useState<boolean>(false);
const excelWaitRef = useRef<boolean>(false);
/**
* 페이지 함수
@@ -156,21 +157,28 @@ export default function UnderWaterInput() {
useEffect(() => {
if(!isExcelDownClick) return ;
const timer = setTimeout(() => {
if (excelList && excelList.length > 0) {
downloadExcel({
data: excelList as unknown as JSON[],
fileName: '지하수유입량 추정',
sheetNameArray: ['지하수유입량 추정'],
headerRange: 'A1:O1'
});
} else {
alert("조회된 결과가 없습니다.");
}
setIsExcelDownClick(false);
}, 1000); // 약간의 지연을 두고 다운로드 실행
return () => clearTimeout(timer);
}, [excelList, isExcelDownClick]);
if (isLoading) {
excelWaitRef.current = true;
return;
}
if (!excelWaitRef.current) {
return;
}
if (excelList && excelList.length > 0) {
downloadExcel({
data: excelList as unknown as JSON[],
fileName: '지하수유입량 추정',
sheetNameArray: ['지하수유입량 추정'],
headerRange: 'A1:O1'
});
} else {
alert("조회된 결과가 없습니다.");
}
setIsExcelDownClick(false);
excelWaitRef.current = false;
}, [excelList, isExcelDownClick, isLoading]);
/**
* 콜백함수
@@ -194,7 +202,8 @@ export default function UnderWaterInput() {
break;
}
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);
searchUnderWaterList(pageNo, pageCnt, searchYear, partStr, nameCd || '0', fcltCpct, operationValue
, fcltyName.trim() !== ""? fcltyName : undefined);
} else {
searchUnderWaterList(pageNo, pageCnt, searchYear);
}
@@ -224,6 +233,7 @@ export default function UnderWaterInput() {
return;
}
}
excelWaitRef.current = false;
searchFacilityPrecipitation(ref.current, 1, 5000);
setIsExcelDownClick(true);
}, [searchFacilityPrecipitation]);
+3 -1
View File
@@ -418,7 +418,9 @@ const gridListFcltyWaterQltyInfo: fcltyWaterQltyInfoProps[] = [
*/
export const fetchFacilityListInit = async (pageNo: number, pageSize: number, partValue?: string, nameCd?: string, fcltCpct?: string, oprtngSttsCd?: string, facilityPartValue?: string, facilityName?: string): Promise<{ data: facilityListProps[], count: number }> => {
try {
const tailStr = partValue ? '/' + (partValue === 'G' ? 'A' : partValue) + '/' + nameCd + '/' + fcltCpct + '/' + oprtngSttsCd + '/' + facilityPartValue + (facilityName && facilityName !== '' ? '/' + facilityName : '') : '';
const tailStr = partValue ? '/' + (partValue === 'G' ? 'A' : partValue) + '/' + nameCd + '/' + fcltCpct + '/' + oprtngSttsCd
+ (facilityPartValue && facilityPartValue !== ''? '/' + facilityPartValue : '')
+ (facilityName && facilityName !== ''? '/' + facilityName : '') : '';
const url = '/prcsFclt/info/' + pageNo + '/' + pageSize + tailStr;
const res = await getFetch('fo', url);
res.data.forEach((item: Record<string, unknown>) => {