중수도 지도점검 엑셀 검증 로직 수정 변경

This commit is contained in:
leedj312
2025-08-12 11:03:41 +09:00
parent 70dcc69f2d
commit 1feec308c1
2 changed files with 34 additions and 51 deletions
@@ -137,7 +137,6 @@ export const rswtMakeExcelSample = (
export const excelToRswtGuideData = (
excelData: any,
year: string,
issues: string[]
) => {
const rswtChkgdData: rswtChkZodType[] = excelData
.map((item: any) => {
@@ -174,23 +173,14 @@ export const excelToRswtGuideData = (
})
.filter((el: any) => el !== undefined);
if (rswtChkgdData.length > 0) {
console.log('rswtChkgdData ', rswtChkgdData)
rswtExcelDataCheck(rswtChkgdData, issues);
}
if (issues.length > 0) {
return { data: [], issues };
}
return { data: rswtChkgdData, issues: [] };
return rswtChkgdData
};
export const excelToRswtPolution = (excelData: any, issues: string[]) => {
export const excelToRswtPolution = (excelData: any) => {
const rswtChkgdData: rswtChkZodType[] = excelData
.map((item: any) => {
@@ -233,7 +223,6 @@ export const excelToRswtPolution = (excelData: any, issues: string[]) => {
};
});
console.log( 'item["연간운영비(원/년)"] ', item["연간운영비(원/년)"])
return {
bdstRuseFcltSn: Number(item["NO"]),
chckYmd: checkYmd,
@@ -259,18 +248,18 @@ export const excelToRswtPolution = (excelData: any, issues: string[]) => {
}
})
.filter((el: any) => el !== undefined);
if (rswtChkgdData.length > 0) {
rswtExcelDataCheck(rswtChkgdData, issues);
}
// if (rswtChkgdData.length > 0) {
// rswtExcelDataCheck(rswtChkgdData, issues);
// }
if (issues.length > 0) {
return { data: [], issues };
}
// if (issues.length > 0) {
// return { data: [], issues };
// }
return { data: rswtChkgdData, issues: [] };
return rswtChkgdData
};
const rswtExcelDataCheck = (
export const rswtExcelDataCheck = (
rswtChkgdData: rswtChkZodType[],
issues: string[]
) => {
@@ -283,7 +272,6 @@ const rswtExcelDataCheck = (
}
if (rswt.anlOperCst.length > 2 && isInvalidNumber(rswt.anlOperCst)) {
console.log('rswt.anlOperCst ', rswt.anlOperCst )
issues.push(
defaultMessage +
` 연간운영비(원/년): 숫자 형식 아님 (${rswt.anlOperCst})`
@@ -329,12 +317,6 @@ const rswtExcelDataCheck = (
defaultMessage + `${pol.node}분기_BOD: 숫자 형식 아님 (${pol.bod})`
);
}
if (isInvalidNumber(pol.smll)) {
issues.push(
defaultMessage +
`${pol.node}분기_냄새: 숫자 형식 아님 (${pol.smll})`
);
}
if (isInvalidNumber(pol.crmty)) {
issues.push(
defaultMessage +
@@ -351,20 +333,16 @@ const rswtExcelDataCheck = (
defaultMessage + `${pol.node}분기_T-N: 숫자 형식 아님 (${pol.tn})`
);
}
if (isInvalidNumber(pol.ph)) {
issues.push(
defaultMessage + `${pol.node}분기_PH: 숫자 형식 아님 (${pol.ph})`
);
if (isInvalidNumber(pol.clIonQnt)) {
issues.push(
defaultMessage +
`${pol.node}분기_PH: 숫자 형식 아님 (${pol.clIonQnt})`
`${pol.node}분기_염소이온량: 숫자 형식 아님 (${pol.clIonQnt})`
);
}
}
});
}
if (rswt?.rswtrDetails && rswt?.rswtrDetails.length > 0) {
rswt?.rswtrDetails.forEach((key) => {
if (key.levyAmt?.length > 1 && isInvalidNumber(key.levyAmt)) {
@@ -6,6 +6,7 @@ import type { rswtChkZodType } from "@/app/store/prfmncReg/chkgdnReg/rswrtChkgdn
import {
excelToRswtGuideData,
excelToRswtPolution,
rswtExcelDataCheck,
} from "@/app/store/prfmncReg/chkgdnReg/rswrtChkgdn/excel";
import { showConfirmToast } from "@/components/lib/func/commom";
import {
@@ -110,30 +111,23 @@ export default function ChkgdExcel({
});
} else if (type === "RST") {
filePickedArray(file, 0).then((res) => {
let issues: string[] = [];
if (res && res?.length > 1) {
const guideData = excelToRswtGuideData(
res[0],
form.getValues("chckYr"),
issues
);
const polutionData = excelToRswtPolution(res[1], issues);
const polutionData = excelToRswtPolution(res[1]);
issues = [...guideData.issues, ...polutionData.issues];
if (issues && issues.length > 0) {
issues.some((err, index) => {
showConfirmToast(err);
return index === 6; // true 반환 시 반복 종료
});
clearFile();
} else {
const keyGenerator = (item: rswtChkZodType) =>
`${item.bdstRuseFcltSn}|${item.chckYmd}|${item.utztnUsgCd}`;
const totalData: rswtChkZodType[] = guideData.data.map(
const totalData: rswtChkZodType[] = guideData.map(
(guide) => {
const fusion = polutionData.data.find(
const fusion = polutionData.find(
(polution) =>
guide.bdstRuseFcltSn === polution.bdstRuseFcltSn &&
guide.chckYmd === polution.chckYmd &&
@@ -153,8 +147,8 @@ export default function ChkgdExcel({
}
}
);
const guideKey = new Set(guideData.data.map(keyGenerator));
const onlypolution = polutionData.data.filter(
const guideKey = new Set(guideData.map(keyGenerator));
const onlypolution = polutionData.filter(
(item) => !guideKey.has(keyGenerator(item))
);
@@ -162,9 +156,20 @@ export default function ChkgdExcel({
...totalData,
...onlypolution,
];
const issues: string[] = [];
setExcelRswtData(listTotalData);
}
console.log('listTotalData ', listTotalData)
rswtExcelDataCheck(listTotalData,issues)
if (issues && issues.length > 0) {
issues.some((err, index) => {
showConfirmToast(err);
return index === 6; // true 반환 시 반복 종료
});
clearFile();
} else {
setExcelRswtData(listTotalData);
}
}
});
}