중수도 지도점검 엑셀 검증 로직 수정 변경
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user