From 1feec308c1e576355e3a159138fce8982c8a121e Mon Sep 17 00:00:00 2001 From: leedj312 Date: Tue, 12 Aug 2025 11:03:41 +0900 Subject: [PATCH] =?UTF-8?q?=EC=A4=91=EC=88=98=EB=8F=84=20=EC=A7=80?= =?UTF-8?q?=EB=8F=84=EC=A0=90=EA=B2=80=20=EC=97=91=EC=85=80=20=EA=B2=80?= =?UTF-8?q?=EC=A6=9D=20=EB=A1=9C=EC=A7=81=20=EC=88=98=EC=A0=95=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../prfmncReg/chkgdnReg/rswrtChkgdn/excel.tsx | 46 +++++-------------- .../ui/modal/chkgd/chkgdExcel/chkgdExcel.tsx | 39 +++++++++------- 2 files changed, 34 insertions(+), 51 deletions(-) diff --git a/apps/wr/app/store/prfmncReg/chkgdnReg/rswrtChkgdn/excel.tsx b/apps/wr/app/store/prfmncReg/chkgdnReg/rswrtChkgdn/excel.tsx index 4cdef5b70..a3372639b 100644 --- a/apps/wr/app/store/prfmncReg/chkgdnReg/rswrtChkgdn/excel.tsx +++ b/apps/wr/app/store/prfmncReg/chkgdnReg/rswrtChkgdn/excel.tsx @@ -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)) { diff --git a/apps/wr/components/ui/modal/chkgd/chkgdExcel/chkgdExcel.tsx b/apps/wr/components/ui/modal/chkgd/chkgdExcel/chkgdExcel.tsx index 46e6c5d30..405061390 100644 --- a/apps/wr/components/ui/modal/chkgd/chkgdExcel/chkgdExcel.tsx +++ b/apps/wr/components/ui/modal/chkgd/chkgdExcel/chkgdExcel.tsx @@ -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); + } } }); }