wr: 중수도 지도점검결과등록
This commit is contained in:
@@ -1,4 +1,7 @@
|
||||
"use client";
|
||||
/**
|
||||
* 재이용실적등록 > 하수재이용실적등록
|
||||
*/
|
||||
"use client";
|
||||
import { useWrStore } from "@/app/store";
|
||||
import { btnClass } from "@/app/store/common/code";
|
||||
import { excelToPbnPrfData } from "@/app/store/prfmncReg/pbnstPrfmncReg/excel";
|
||||
|
||||
@@ -148,6 +148,8 @@ export const excelToRswtGuideData = (
|
||||
.map((item: any) => {
|
||||
if (item["점검일"] !== undefined) {
|
||||
const checkYmd = normalizeExcelDateInput(item["점검일"]);
|
||||
const operMngCd = textToCode(item["운영관리형태"], "rainRswtMng") ?? item["운영관리형태"];
|
||||
const utztnUsgCd = textToCode(item["이용용도"], "dmdUszCd") ?? item["이용용도"];
|
||||
|
||||
const makeGuidDetail = Array.from({ length: 12 }, (_, i) => {
|
||||
let month = `${i + 1}`;
|
||||
@@ -155,20 +157,23 @@ export const excelToRswtGuideData = (
|
||||
const rswtData = parseRawValue(item[`중수_${month}월`]);
|
||||
if (month.length < 2) month = "0" + month;
|
||||
return {
|
||||
utztnUsgCd: utztnUsgCd,
|
||||
ym: year + month,
|
||||
chckYmd: checkYmd,
|
||||
splyUswtrUtztnQnt: splyData !== "" ? splyData : 0,
|
||||
ruseFcltUtztnQnt: rswtData !== "" ? rswtData : 0,
|
||||
flg: "RST",
|
||||
};
|
||||
});
|
||||
return {
|
||||
bdstRuseFcltSn: Number(item["NO"]),
|
||||
operMngCd: textToCode(item["운영관리형태"], "rainRswtMng") ??item["운영관리형태"],
|
||||
flg: "RST",
|
||||
operMngCd: operMngCd,
|
||||
anlOperCst: parseCommaRawValue(item["연간운영비(원/년)"]),
|
||||
prcsCpct: parseRawValue(item[`처리용량(m³)`]),
|
||||
spwtPositn: item["채수지점"],
|
||||
chckYmd: checkYmd,
|
||||
utztnUsgCd: textToCode(item["이용용도"], "dmdUszCd")??item["이용용도"],
|
||||
utztnUsgCd: utztnUsgCd,
|
||||
guideDetails: makeGuidDetail,
|
||||
rgtr: TEST_UUID,
|
||||
mdfr: TEST_UUID,
|
||||
@@ -191,6 +196,11 @@ export const excelToRswtPolution = (excelData: any) => {
|
||||
if (item["점검일"] !== undefined) {
|
||||
const checkYmd = normalizeExcelDateInput(item["점검일"]);
|
||||
const vltnDt = normalizeExcelDateInput(item["과태료 부과일(위반일)"]);
|
||||
const operMngCd =
|
||||
textToCode(item["운영관리형태"], "rainRswtMng") ??
|
||||
item["운영관리형태"];
|
||||
const utztnUsgCd =
|
||||
textToCode(item["이용용도"], "dmdUszCd") ?? item["이용용도"];
|
||||
|
||||
const makePoluttion = Array.from({ length: 4 }, (_, i) => {
|
||||
const quarter = `${i + 1}`;
|
||||
@@ -207,6 +217,7 @@ export const excelToRswtPolution = (excelData: any) => {
|
||||
const ph = String(item[`${quarter}분기_PH`]) ;
|
||||
const clIonQnt = parseRawValue(item[`${quarter}분기_염화물`]);
|
||||
return {
|
||||
utztnUsgCd: utztnUsgCd,
|
||||
node: quarter,
|
||||
chckYmd: checkYmd,
|
||||
grssClfgUswtr: grssClfgUswtr,
|
||||
@@ -226,9 +237,10 @@ export const excelToRswtPolution = (excelData: any) => {
|
||||
|
||||
return {
|
||||
bdstRuseFcltSn: Number(item["NO"]),
|
||||
flg: "RST",
|
||||
chckYmd: checkYmd,
|
||||
utztnUsgCd: textToCode(item["이용용도"], "dmdUszCd")??item["이용용도"],
|
||||
operMngCd: item["운영관리형태"],
|
||||
utztnUsgCd: utztnUsgCd,
|
||||
operMngCd: operMngCd,
|
||||
anlOperCst: parseCommaRawValue(item["연간운영비(원/년)"]),
|
||||
prcsCpct: parseRawValue(item["처리용량(m³)"]),
|
||||
spwtPositn: item["채수지점"],
|
||||
@@ -237,7 +249,7 @@ export const excelToRswtPolution = (excelData: any) => {
|
||||
mdfr: TEST_UUID,
|
||||
rswtrDetails: [
|
||||
{
|
||||
utztnUsgCd: textToCode(item["이용용도"], "dmdUszCd")??item["이용용도"],
|
||||
utztnUsgCd: utztnUsgCd,
|
||||
vltnDt: vltnDt,
|
||||
vltnMttr: item["위반사항"],
|
||||
levyAmt: Number(item["과태료 부과금액(천원)"]) ?? 0,
|
||||
@@ -257,6 +269,7 @@ export const rswtExcelDataCheck = (
|
||||
rswtChkgdData: rswtChkZodType[],
|
||||
issues: string[]
|
||||
) => {
|
||||
// const chkMngType = { "01": "위탁", "02": "자체" };
|
||||
|
||||
rswtChkgdData.forEach((rswt: any) => {
|
||||
const defaultMessage = `*중수도 수질 [NO: ${rswt.bdstRuseFcltSn}, 점검일: ${rswt.chckYmd}, 이용용도: ${codeToText(rswt.utztnUsgCd ,"dmdUszCd")??rswt.utztnUsgCd}] 항목에서 `;
|
||||
@@ -264,6 +277,17 @@ export const rswtExcelDataCheck = (
|
||||
if (rswt.chckYmd && isInvalidDate(rswt.chckYmd)) {
|
||||
issues.push(defaultMessage + `점검일: 날짜 형식 아님 (${rswt.chckYmd})`);
|
||||
}
|
||||
// if (rswt.operMngCd?.length > 1 && !chkMngType[rswt.operMngCd]) {
|
||||
// issues.push(
|
||||
// defaultMessage +
|
||||
// `운영관리형태: 위탁 혹은 자체만 허용 (${rswt.operMngCd})`
|
||||
// );
|
||||
// }
|
||||
// if (rswt.utztnUsgCd?.length > 2 && !codeToText(rswt.utztnUsgCd, "dmdUszCd")) {
|
||||
// issues.push(
|
||||
// defaultMessage + `이용용도: 허용되지 않은 값 (${rswt.utztnUsgCd})`
|
||||
// );
|
||||
// }
|
||||
if (rswt.anlOperCst.length > 2 && isInvalidNumber(rswt.anlOperCst)) {
|
||||
|
||||
issues.push(
|
||||
@@ -327,6 +351,11 @@ export const rswtExcelDataCheck = (
|
||||
defaultMessage + `${pol.node}분기_T-N: 숫자 형식 아님 (${pol.tn})`
|
||||
);
|
||||
}
|
||||
if (pol.ph?.length > 1 && isInvalidNumber(pol.ph)) {
|
||||
issues.push(
|
||||
defaultMessage + `${pol.node}분기_PH: 숫자 형식 아님 (${pol.ph})`
|
||||
);
|
||||
}
|
||||
|
||||
if (isInvalidNumber(pol.clIonQnt)) {
|
||||
issues.push(
|
||||
|
||||
@@ -98,6 +98,7 @@ export const rswtChkgdZod = z.object({
|
||||
rgtr: z.string().nullish(),
|
||||
mdfcnDt: z.string().nullish(),
|
||||
mdfr: z.string().nullish(),
|
||||
flg: z.string().nullable(),
|
||||
anlOperCst:z.number(),
|
||||
oilqMeasMthd: z.string().nullish(),
|
||||
utztnUsgCd: z.string(),
|
||||
|
||||
@@ -251,20 +251,20 @@ export const rswtChkgdnActionsExport: (set: any) => rswtChkgdnActions = (
|
||||
set((state: rswtChkgdnType) => (
|
||||
{ rswtChkgdn: { ...state.rswtChkgdn, isLoading: true } }));
|
||||
const res = await postFectch("/reuseChk/reuseWater", excelData);
|
||||
if (!res.ok) {
|
||||
return failMessage;
|
||||
if (res.status === 200) {
|
||||
const currentYear = new Date().getFullYear().toString();
|
||||
const rswtChkRes = await initFetch(1, rswtPageSize, currentYear, laeSeCd);
|
||||
set((state: rswtChkgdnState) => ({
|
||||
...state,
|
||||
rswtChkgdn: {
|
||||
...state.rswtChkgdn,
|
||||
rswtChkRes: rswtChkRes.data,
|
||||
rswtChkCount: rswtChkRes.count,
|
||||
},
|
||||
}));
|
||||
return successMessage;
|
||||
}
|
||||
const currentYear = new Date().getFullYear().toString();
|
||||
const rswtChkRes = await initFetch(1, rswtPageSize, currentYear, laeSeCd);
|
||||
set((state: rswtChkgdnState) => ({
|
||||
...state,
|
||||
rswtChkgdn: {
|
||||
...state.rswtChkgdn,
|
||||
rswtChkRes: rswtChkRes.data,
|
||||
rswtChkCount: rswtChkRes.count,
|
||||
},
|
||||
}));
|
||||
return successMessage;
|
||||
return failMessage;
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
return failMessage;
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
/**
|
||||
* 지도점검 결과등록 엑셀 업로드 모달
|
||||
*/
|
||||
import { useWrStore } from "@/app/store";
|
||||
import { type rainChkZodType } from "@/app/store/prfmncReg/chkgdnReg/rainChkgdn";
|
||||
import { excelToRainChkData } from "@/app/store/prfmncReg/chkgdnReg/rainChkgdn/excel";
|
||||
@@ -8,7 +11,6 @@ import {
|
||||
excelToRswtPolution,
|
||||
rswtExcelDataCheck,
|
||||
} from "@/app/store/prfmncReg/chkgdnReg/rswrtChkgdn/excel";
|
||||
import { showConfirmToast } from "@/components/lib/func/common";
|
||||
import { useAlertStore } from "@/src/shared/lib";
|
||||
import {
|
||||
filePicked,
|
||||
@@ -61,6 +63,8 @@ export default function ChkgdExcel({
|
||||
};
|
||||
const handleFileChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||
const selectedFile = e.target.files?.[0];
|
||||
setExcelData(undefined);
|
||||
setExcelRswtData(undefined);
|
||||
if (selectedFile) {
|
||||
setFile(selectedFile);
|
||||
}
|
||||
@@ -105,12 +109,15 @@ export default function ChkgdExcel({
|
||||
);
|
||||
if (excelData.message) {
|
||||
alert(excelData.message);
|
||||
setExcelData(undefined);
|
||||
}
|
||||
if (excelData.issues && excelData.issues.length > 0) {
|
||||
excelData.issues.some((err, index) => {
|
||||
showConfirmToast(err);
|
||||
// showConfirmToast(err);
|
||||
alert(err);
|
||||
return index === 4; // true 반환 시 반복 종료
|
||||
});
|
||||
setExcelData(undefined);
|
||||
clearFile();
|
||||
} else {
|
||||
setExcelData(excelData.rainChkgdData);
|
||||
@@ -123,6 +130,7 @@ export default function ChkgdExcel({
|
||||
setRswtChkLoading(true);
|
||||
filePickedArray(file, 0)
|
||||
.then((res) => {
|
||||
setExcelRswtData(undefined);
|
||||
if (res && res?.length > 1) {
|
||||
const guideData = excelToRswtGuideData(
|
||||
res[0],
|
||||
@@ -167,16 +175,24 @@ export default function ChkgdExcel({
|
||||
|
||||
if (issues && issues.length > 0) {
|
||||
issues.some((err, index) => {
|
||||
showConfirmToast(err);
|
||||
return index === 6; // true 반환 시 반복 종료
|
||||
// showConfirmToast(err);
|
||||
alert(err);
|
||||
return index === 4; // true 반환 시 반복 종료
|
||||
});
|
||||
console.log(issues.join("\n"));
|
||||
setExcelRswtData(undefined);
|
||||
clearFile();
|
||||
} else {
|
||||
setExcelRswtData(listTotalData);
|
||||
}
|
||||
} else {
|
||||
alert("중수도 엑셀은 2개 시트가 필요합니다. 양식을 확인해주세요.");
|
||||
setExcelRswtData(undefined);
|
||||
clearFile();
|
||||
}
|
||||
})
|
||||
.finally(() => setRswtChkLoading(false));
|
||||
console.log("업로드파일 점검 완료");
|
||||
}
|
||||
}
|
||||
}, [file]);
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
/**
|
||||
* 지도점검 상세조회/상세수정용 모달
|
||||
*/
|
||||
import { useWrStore } from "@/app/store";
|
||||
import type { TableUpperProps } from "@/app/store/common/type/header";
|
||||
import type { splRuseWaterType } from "@/app/store/prfmncReg/chkgdnReg/rainChkgdn/headList";
|
||||
|
||||
Reference in New Issue
Block a user