diff --git a/apps/wr/app/matMng/coMat/coMatRvw/page.tsx b/apps/wr/app/matMng/coMat/coMatRvw/page.tsx
index 446323b83..c1e601320 100644
--- a/apps/wr/app/matMng/coMat/coMatRvw/page.tsx
+++ b/apps/wr/app/matMng/coMat/coMatRvw/page.tsx
@@ -14,9 +14,6 @@ import {
tableData,
yearOptions,
} from "@/components/lib/func/commom";
-import { CmpttnModal } from "@/components/ui/modal/coMat/constCostFeeTable";
-import { CoMatModal } from "@/components/ui/modal/coMat/rateFeeModal";
-import type { objSearchType } from "@/components/ui/modal/fcltReg/bdstRegModal/bdstRegModal";
import {
ContentsDiv,
Form,
@@ -43,6 +40,7 @@ import moment from "moment";
import { usageProcData } from "@/app/store/matDmd/coMatRvw/headList";
import { zodResolver } from "@hookform/resolvers/zod";
import ConCostForm from "@/components/ui/form/coMat/conCostForm/conCostForm";
+import type { objSearchType } from "@/components/ui/modal/fcltReg/bdstRegModal/bdstRegModal";
export default function CoMatRvw() {
const { code, coRvw, coMatRvwInit, coMatRvwSearch, coMatRvwInqua } =
@@ -114,7 +112,7 @@ export default function CoMatRvw() {
}, [form.watch("useUsgCd")]);
useEffect(() => {
- if (coMatRvwRes) {
+ if (coMatRvwRes.length > 0) {
const data = coMatRvwRes?.map((item, index) => {
let flag = "";
flag = getdmdMatFlag(item?.demandMatching?.splyFcltFlg ??"");
diff --git a/apps/wr/app/matMng/coMat/ruseCaseMng/page.tsx b/apps/wr/app/matMng/coMat/ruseCaseMng/page.tsx
index 4950ab0da..e8146b37a 100644
--- a/apps/wr/app/matMng/coMat/ruseCaseMng/page.tsx
+++ b/apps/wr/app/matMng/coMat/ruseCaseMng/page.tsx
@@ -105,7 +105,7 @@ export default function RuseCaseMng() {
-
+
{
form.clearErrors;
if (item?.completeYn) {
- return item.dmdInfoSn;
+ return Number(item.dmdInfoSn);
}
})
.filter((item) => item !== undefined);
@@ -136,7 +135,7 @@ export default function RuseRvwHstry() {
-
+
>
)
}
diff --git a/apps/wr/app/store/common/code/index.ts b/apps/wr/app/store/common/code/index.ts
index 6caabcb5c..e7fca8180 100644
--- a/apps/wr/app/store/common/code/index.ts
+++ b/apps/wr/app/store/common/code/index.ts
@@ -31,18 +31,18 @@ const bdstUsgCd: SelectDataType[] = [
{ val: '16', text: "기타" },
];
//빗물 집수면 종류 용도
-const rainFcltCd = [
- { val: "1", text: "지붕" },
- { val: "2", text: "건물옥상" },
- { val: "3", text: "골프장 연못" },
- { val: "4", text: "운동장 바닥" },
- { val: "5", text: "운동장 지붕" },
- { val: "6", text: "주차장" },
- { val: "7", text: "태양광패널" },
- { val: "8", text: "연못" },
- { val: "9", text: "기타" },
- { val: "10", text: "확인불가" },
-];
+// const rainFcltCd = [
+// { val: "1", text: "지붕" },
+// { val: "2", text: "건물옥상" },
+// { val: "3", text: "골프장 연못" },
+// { val: "4", text: "운동장 바닥" },
+// { val: "5", text: "운동장 지붕" },
+// { val: "6", text: "주차장" },
+// { val: "7", text: "태양광패널" },
+// { val: "8", text: "연못" },
+// { val: "9", text: "기타" },
+// { val: "10", text: "확인불가" },
+// ];
// 중수도 필수 원수종류
const rswtBdstType: SelectDataType[] = [
{ text: "숙박업", val: "17" },
@@ -138,6 +138,19 @@ export const buildingType = {
HTB:"HTB"
}
+const rainFcltCd = [
+ { val: "지붕", text: "지붕" },
+ { val: "건물옥상", text: "건물옥상" },
+ { val: "골프장 연못", text: "골프장 연못" },
+ { val: "운동장 바닥", text: "운동장 바닥" },
+ { val: "운동장 지붕", text: "운동장 지붕" },
+ { val: "주차장", text: "주차장" },
+ { val: "태양광패널", text: "태양광패널" },
+ { val: "연못", text: "연못" },
+ { val: "기타", text: "기타" },
+ { val: "확인불가", text: "확인불가" },
+];
+
export type comCodeState = {
code: {
isInit: boolean;
@@ -168,10 +181,20 @@ export type comCodeType = comCodeState & comCodeActions;
export const getSggCd = async (set: any) => {
const sgg = await getFetch("common", "/addr/sgg");
- const sggCd = sgg.map((item: any) => ({
+ /* const sggCd = sgg.map((item: any) => ({
val: item.adstDstrCd,
text: item.gugun,
- }));
+ })); */
+
+ const sggCd = [
+ { text: "전체", val: '0' },
+ ...sgg
+ .map((item: any) => ({
+ text: item.gugun || '',
+ val: String(item.adstDstrCd) || ''
+ }))
+ ];
+
set((state: comCodeState) => ({
code: {
...state.code,
@@ -319,7 +342,7 @@ export const codeActionExport: (set: any) => comCodeActions = (set: any) => {
val: item.adstDstrCd,
text: item.gugun,
}));
-
+
const city = await getFetch("common", "/addr/city");
const cityCd = city.map((item: any) => ({
val: item.adstDstrCd,
diff --git a/apps/wr/app/store/common/type/header.tsx b/apps/wr/app/store/common/type/header.tsx
index 45ef9e291..f064b7580 100644
--- a/apps/wr/app/store/common/type/header.tsx
+++ b/apps/wr/app/store/common/type/header.tsx
@@ -22,5 +22,6 @@ export type TableUpperProps = {
selectData ?:string; // type 이 seelct 일경우 selectarray 정하기 위해
row?:number;
mergeCell?:boolean // 셀을 합칠경우
+ readonly?:boolean
};
diff --git a/apps/wr/app/store/matDmd/coMatRvw/headList.tsx b/apps/wr/app/store/matDmd/coMatRvw/headList.tsx
index b13796950..7b43e4b00 100644
--- a/apps/wr/app/store/matDmd/coMatRvw/headList.tsx
+++ b/apps/wr/app/store/matDmd/coMatRvw/headList.tsx
@@ -187,13 +187,13 @@ export const rateFeeHeadListExport: CommonTableProps[] = [
];
export const usageProcData = [
- { usage: "청소", process: "총인처리시설 + 염소소독" },
- { usage: "화장실용수", process: "총인처리시설 + 염소소독" },
- { usage: "세척", process: "총인처리시설 + UV소독" },
- { usage: "살수", process: "총인처리시설 + UV소독" },
- { usage: "조경", process: "총인처리시설 + UV소독" },
- { usage: "농업", process: "총인처리시설 + UV소독" },
- { usage: "하천", process: "총인처리시설 + UV소독" },
- { usage: "지하수", process: "전처리시설 + RO" },
- { usage: "공업", process: "전처리시설 + RO" },
+ { usage: "청소", process: "총인처리시설+염소소독" },
+ { usage: "화장실용수", process: "총인처리시설+염소소독" },
+ { usage: "세척", process: "총인처리시설+UV소독" },
+ { usage: "살수", process: "총인처리시설+UV소독" },
+ { usage: "조경", process: "총인처리시설+UV소독" },
+ { usage: "농업", process: "총인처리시설+UV소독" },
+ { usage: "하천", process: "총인처리시설+UV소독" },
+ { usage: "지하수", process: "전처리시설+RO" },
+ { usage: "공업", process: "전처리시설+RO" },
];
diff --git a/apps/wr/app/store/matDmd/coMatRvw/type.tsx b/apps/wr/app/store/matDmd/coMatRvw/type.tsx
index b4990c7eb..9f146c0fb 100644
--- a/apps/wr/app/store/matDmd/coMatRvw/type.tsx
+++ b/apps/wr/app/store/matDmd/coMatRvw/type.tsx
@@ -62,7 +62,7 @@ import { z } from "zod";
dmdInfoSn: z.number(),
usgPrcsProcs: z.string().nullish(),
cstrnCst: z.number(),
- fcltSbsdEpsTrf: z.number(),
+ fcltSbsdCstrnCst: z.number(),
prcsFcltCpctCstrnCst: z.number()
});
@@ -73,19 +73,19 @@ import { z } from "zod";
dmdInfoFk: z.string(),
dmndTmng: z.coerce.date(),
dmndQty: z.number(),
- wntUntprc: z.number(),
- grssClfg: z.number(),
- combResdch: z.number(),
- trbt: z.number(),
+ wntUntprc: z.number().nullish(),
+ grssClfg: z.number().nullish(),
+ combResdch: z.number().nullish(),
+ trbt: z.number().nullish(),
blgcOxygDmndQnt: z.number(),
- smll: z.number(),
- crmty: z.number(),
- tn: z.number(),
- tph: z.number(),
- ph: z.number(),
- clIonQnt: z.number(),
+ smll: z.number().nullish(),
+ crmty: z.number().nullish(),
+ tn: z.number().nullish(),
+ tph: z.number().nullish(),
+ ph: z.number().nullish(),
+ clIonQnt: z.number().nullish(),
cdtnv: z.number(),
- rmrk: z.string(),
+ rmrk: z.string().nullish(),
useUsgCd: z.string().nullish(),
mtchnCmptnYmd: z.string().nullish(),
rvwCmptnYmd: z.string().nullish(),
@@ -93,6 +93,8 @@ import { z } from "zod";
demandMatching: DemandMatchingSchema.nullish(),
demandCst: DemandCstSchema,
ruseUtztnFcltNm:z.string().nullish(),
+ totalConstCost:z.number().nullish(),
+
});
@@ -113,7 +115,7 @@ export type DedMatUpdateType =
dmdInfoSn: number;
usgPrcsProcs: string;
cstrnCst: number;
- fcltSbsdEpsTrf: number;
+ fcltSbsdCstrnCst: number;
prcsFcltCpctCstrnCst: number;
rgtr: string;
}
diff --git a/apps/wr/app/store/matDmd/ruseRvwHstry/index.tsx b/apps/wr/app/store/matDmd/ruseRvwHstry/index.tsx
index 698a49abb..3338bc467 100644
--- a/apps/wr/app/store/matDmd/ruseRvwHstry/index.tsx
+++ b/apps/wr/app/store/matDmd/ruseRvwHstry/index.tsx
@@ -8,6 +8,7 @@ import { ruseHstryHeadListExport } from "./headList";
import { fetchType, getFetch, postFectch, putFectch } from "@/components/lib/api";
import type { DmdCoReqType } from "../coMatRvw/type";
import toast from "react-hot-toast";
+import { TEST_UUID } from "../../ruseFcltMng/fcltReg/rainReg";
const ruseHistHeadList = ruseHstryHeadListExport;
@@ -29,6 +30,21 @@ export const ruseHstryStateExport: ruseHstryState = {
export type ruseHstryType = ruseHstryState & ruseHstryActions;
+//
+export const addRgtrAndMdfrToDemandObj = (data: DmdCoReqType) => {
+ // 최상위 demand 객체
+ // demandCo가 있을 경우
+ if (data.demandCo) {
+ data.demandCo.rgtr = TEST_UUID;
+ data.demandCo.mdfr = TEST_UUID;
+ }
+
+
+ return data;
+};
+
+
+
type ruseHstryActions = {
ruseRvwHistInit: (
pageNo: number,
@@ -54,7 +70,7 @@ type ruseHstryActions = {
endYear: string,
sggCd: string
) => void;
- ruseRvwComplete:( data: string[]) => void;
+ ruseRvwComplete:( data: Number[]) => void;
};
const irvwHistInit = async (
@@ -62,14 +78,13 @@ const irvwHistInit = async (
pageCnt: number,
startYear: string,
endYear: string,
- sggCd?: string
) => {
let url = `/reuseFc/request/infoList/matched/${pageNo}/${pageCnt}/${startYear}/${endYear}`;
- console.log("sggCd ", sggCd);
- if (sggCd) {
- url += `/${sggCd}`;
- }
+ // console.log("sggCd ", sggCd);
+ // if (sggCd) {
+ // url += `/${sggCd}`;
+ // }
const rvwHistRes = await getFetch(fetchType.WR, url);
@@ -92,7 +107,7 @@ export const ruseHstryActionsExport: (set: any) => ruseHstryActions = (
pageCnt,
startYear,
endYear,
- sggCd
+ // sggCd
);
return set((state: ruseHstryState) => ({
@@ -106,9 +121,11 @@ export const ruseHstryActionsExport: (set: any) => ruseHstryActions = (
},
ruseRvwCalUpdate: async (data: DmdCoReqType) => {
try {
+
+ const updatedData = addRgtrAndMdfrToDemandObj(data);
const update = await putFectch(
`/reuseFc/request/cst`,
- JSON.stringify(data)
+ updatedData
);
if (update.status === 200) {
toast.success("매칭 계산 저장이 완료입니다.");
@@ -117,7 +134,6 @@ export const ruseHstryActionsExport: (set: any) => ruseHstryActions = (
10,
new Date().getFullYear().toString(),
new Date().getFullYear().toString(),
- "0"
);
return set((state: ruseHstryState) => ({
...state,
@@ -193,11 +209,11 @@ export const ruseHstryActionsExport: (set: any) => ruseHstryActions = (
console.log(" error ", e);
}
},
- ruseRvwComplete: async (data: string[]) => {
+ ruseRvwComplete: async (data: Number[]) => {
try {
const complet = await postFectch(
`/reuseFc/request/completeCheck`,
- JSON.stringify(data),
+ data,
fetchType.WR
);
if (complet.status === 200) {
@@ -207,7 +223,6 @@ export const ruseHstryActionsExport: (set: any) => ruseHstryActions = (
10,
new Date().getFullYear().toString(),
new Date().getFullYear().toString(),
- "0"
);
}
} catch (e) {
diff --git a/apps/wr/app/store/prfmncReg/chkgdnReg/rainChkgdn/excel.tsx b/apps/wr/app/store/prfmncReg/chkgdnReg/rainChkgdn/excel.tsx
index ed23740d0..5754c02fc 100644
--- a/apps/wr/app/store/prfmncReg/chkgdnReg/rainChkgdn/excel.tsx
+++ b/apps/wr/app/store/prfmncReg/chkgdnReg/rainChkgdn/excel.tsx
@@ -32,106 +32,106 @@ export const buildingToExcelType = (
sggCdoe: SelectDataType[],
) => {
const excelData: string[][] = [];
- buildings.forEach((building) => {
- useTypes.forEach((useType) => {
- excelData.push([
- building.bdstInfoPk.toString(),
- sidoCode.find((sido) => sido.val === building.ctpvCd.toString())
- ?.text || "",
- sggCdoe.find((sido) => sido.val === building.sggCd.toString())
- ?.text || "",
- building.daddr,
- building.bdstNm,
- "",
- "",
- "",
- "",
- useType,
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- "",
- ]);
- });
+ buildings.forEach((building) => {
+ useTypes.forEach((useType) => {
+ excelData.push([
+ building.bdstInfoPk.toString(),
+ sidoCode.find((sido) => sido.val === building.ctpvCd.toString())
+ ?.text || "",
+ sggCdoe.find((sido) => sido.val === building.sggCd.toString())
+ ?.text || "",
+ building.daddr,
+ building.bdstNm,
+ "",
+ "",
+ "",
+ "",
+ useType,
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ ]);
});
- return excelData;
-
+ });
+ return excelData;
+
};
export const excelToRainChkData = (excelData: any, year: string) => {
const rainChkgdData: rainChkZodType[] = excelData.map((item: any) => {
if (item["점검일"] !== undefined) {
- const checkYmd = item["점검일"].replace(/\./g, "")
- let vltnDt = item["과태료 부과일(위반일)"]
- if (vltnDt !== undefined) {
- vltnDt = vltnDt .replace(/\./g, "")
- }
- const makeGuidDetail = Array.from({ length: 12 }, (_, i) => {
- let month = `${i + 1}`;
- const splyData = item[`보급_${month}월`];
- const ruseData = item[`빗물_${month}월`];
- if (month.length < 2) month = "0" + month;
- return {
- utztnUsgCd: item["이용용도"],
- ym: year + month,
- chckYmd: checkYmd,
- splyUswtrUtztnQnt: splyData !== undefined ? splyData : 0,
- ruseFcltUtztnQnt: ruseData !== undefined ? ruseData : 0,
- flg: "RNB",
- };
- });
-
- return {
-
- bdstRuseFcltFk: Number(item["NO"]),
- chckYmd: checkYmd,
- spwtPositn: item["유량측정방법"],
- rgtr: TEST_UUID,
- oilqMeasMthd: item["운영관리형태"],
- anlOperCst: Number(item["연간운영비(원/년)"]) ?? 0,
- operMngCd: item["유량측정방법"],
- guideDetails: makeGuidDetail,
- rainyDetails: [
- {
+ const checkYmd = item["점검일"].replace(/\./g, "")
+ let vltnDt = item["과태료 부과일(위반일)"]
+ if (vltnDt !== undefined) {
+ vltnDt = vltnDt ? vltnDt.replace(/\./g, "") : "";
+ }
+ const makeGuidDetail = Array.from({ length: 12 }, (_, i) => {
+ let month = `${i + 1}`;
+ const splyData = item[`보급_${month}월`];
+ const ruseData = item[`빗물_${month}월`];
+ if (month.length < 2) month = "0" + month;
+ return {
utztnUsgCd: item["이용용도"],
- ph: Number(item["PH"]) ?? 0,
- trbt: Number(item["탁도"]) ?? 0,
- grssClfg: Number(item["총대장균군수"]) ?? 0,
- etc: item["기타"] ?? "", // 필드 누락 방지
- vltnDt: vltnDt,
- vltnMttr: item["위반사항"],
- levyAmt: Number(item["과태료부과금액(천원)"]) ?? 0,
- rgtr: TEST_UUID,
- },
- ],
- };
- }
+ ym: year + month,
+ chckYmd: checkYmd,
+ splyUswtrUtztnQnt: Number(splyData ?? 0),
+ ruseFcltUtztnQnt: Number(ruseData ?? 0),
+ flg: "RNB",
+ };
+ });
+
+ return {
+
+ bdstRuseFcltFk: Number(item["NO"]),
+ chckYmd: checkYmd,
+ spwtPositn: item["유량측정방법"] ?? "",
+ rgtr: TEST_UUID,
+ oilqMeasMthd: item["운영관리형태"] ?? "",
+ anlOperCst: Number(item["연간운영비(원/년)"]) ?? 0,
+ operMngCd: item["유량측정방법"] ?? "",
+ guideDetails: makeGuidDetail,
+ rainyDetails: [
+ {
+ utztnUsgCd: item["이용용도"] ?? "",
+ ph: Number(item["PH"] ?? 0),
+ trbt: Number(item["탁도"] ?? 0),
+ grssClfg: Number(item["총대장균군수"] ?? 0),
+ etc: item["기타"] ?? "", // 필드 누락 방지
+ vltnDt: vltnDt ?? "",
+ vltnMttr: item["위반사항"] ?? "",
+ levyAmt: Number(item["과태료부과금액(천원)"] ?? 0),
+ rgtr: TEST_UUID,
+ },
+ ],
+ };
+ }
}).filter((el: any) => el !== undefined);
return rainChkgdData;
};
diff --git a/apps/wr/app/store/prfmncReg/chkgdnReg/rswrtChkgdn/index.tsx b/apps/wr/app/store/prfmncReg/chkgdnReg/rswrtChkgdn/index.tsx
index c6737b31e..eb0010047 100644
--- a/apps/wr/app/store/prfmncReg/chkgdnReg/rswrtChkgdn/index.tsx
+++ b/apps/wr/app/store/prfmncReg/chkgdnReg/rswrtChkgdn/index.tsx
@@ -1,10 +1,9 @@
import {
TEST_UUID,
- type TableUpperProps,
} from "@/app/store/ruseFcltMng/fcltReg/rainReg";
import type {
SelectDataType,
- sheetParameter,
+ SheetParameter,
} from "@common/business_components";
import {
deleteFectch,
@@ -25,6 +24,7 @@ import {
import { z } from "zod";
import { ToastFormUi } from "@/components/ui/toast/toastFromUi";
import { type chHeadType } from "../rainChkgdn/headList";
+import type { TableUpperProps } from "@/app/store/common/type/header";
const rswtChkHeadList = rswtChkHeadListExport;
const rswtDetailHeadList = rswtDetailHeadListExport;
@@ -37,7 +37,7 @@ export type rswtChkgdnState = {
rswtDetailHeadList: TableUpperProps[];
rswtHeadNm: chHeadType[];
- excelList: [typeof sheetParameter];
+ excelList: SheetParameter[];
rswtChkRes: rswtChkZodType[];
rswtChkPolGuide: rswtChkZodType[];
isInit: boolean;
@@ -55,6 +55,7 @@ type rswtChkgdnActions = {
rswtChkDelete: (chkgdnPks: number[]) => void;
rswtChkDetilsUpdate: (rswtChkDetails: rswtrChkDetailsZodType[]) => void;
rswtChkPolAndGuide: (chkGdnPk: number) => void;
+ rswtChkPolInit: () => void;
rwstPolAndGuideUpdate: (rswtChk: rswtChkZodType[]) => void;
rswtChkHeadChange: (rswtChkgdn: rswtChkgdnState, isEdit: boolean) => void;
};
@@ -69,7 +70,7 @@ export const rswtChkgdnStateExport: rswtChkgdnState = {
excelList: [{
data: [[]], headerNum: 0, headerRange: "A1:V3",
sheetName: "",
- startCol: 0
+ startCol: '1'
}],
rswtChkRes: [],
rswtChkPolGuide: [],
@@ -175,9 +176,6 @@ export const rswtChkgdnActionsExport: (set: any) => rswtChkgdnActions = (
try {
const chData = await makeMdfrChk(rswtChk);
- console.log("chData ", chData);
-
- console.log("rswtChk ", rswtChk);
const res = await putFectch("/reuseChk/reuseWater", chData);
if (res.ok) {
@@ -237,6 +235,17 @@ export const rswtChkgdnActionsExport: (set: any) => rswtChkgdnActions = (
}));
} catch (error) {}
},
+ rswtChkPolInit: () => {
+ try {
+ return set((state: rswtChkgdnState) => ({
+ ...state,
+ rswtChkgdn: {
+ ...state.rswtChkgdn,
+ rswtChkPolGuide: undefined,
+ },
+ }));
+ } catch (error) {}
+ },
rwstPolAndGuideUpdate: async (rswtChk: rswtChkZodType[]) => {
try {
const chData = await makeMdfrChk(rswtChk);
diff --git a/apps/wr/app/store/prfmncReg/pbnstPrfmncReg/index.tsx b/apps/wr/app/store/prfmncReg/pbnstPrfmncReg/index.tsx
index e72d6def6..87e827f60 100644
--- a/apps/wr/app/store/prfmncReg/pbnstPrfmncReg/index.tsx
+++ b/apps/wr/app/store/prfmncReg/pbnstPrfmncReg/index.tsx
@@ -4,6 +4,7 @@ import type { pubHasuType } from "../../ruseFcltMng/fcltReg/pbnstReg/type";
import type { FcPrfType, PrfType } from "./type";
import type { TableUpperProps } from "../../common/type/header";
import { ToastFormUi } from "@/components/ui/toast/toastFromUi";
+import toast from "react-hot-toast";
const pbnstPrfmncHeadList = pbnstPrfmncHeadListExport;
const monthHeadList = monthHeadListExport;
@@ -32,7 +33,7 @@ export type pbnstPrfmncType = pbnstPrfmncState & pbnstPrfmncActions;
type pbnstPrfmncActions = {
prfmncHasuInit: (page: string, sggOrCity: string) => void;
- prfmnRegData: (data:PrfType) =>void
+ prfmnRegData: (data: PrfType) => void;
};
const checkWrRegList = async () => {
@@ -46,21 +47,28 @@ const hasuListFetch = async (page: string, sggOrCity: string) => {
checkWrRegListRes?.fcltCds,
fetchType.COMMON
);
- const data = checkWrRegListRes.fcPrfList.map((item: FcPrfType) => {
- const findData = rainRes.data.find(
- (fclt: pubHasuType) =>
- fclt.bscFctCd === item.pbnstRuseFcltPk.substring(0, 11)
+
+
+ const findData = rainRes.data.map((item: pubHasuType) => {
+ const data = checkWrRegListRes?.fcPrfList.find(
+ (fclt: FcPrfType) =>
+ fclt.pbnstRuseFcltPk.substring(0, 11) === item?.bscFctCd
);
- return {
- sido: findData?.sido,
- gugun: findData?.gugun,
- bscFctNm: findData?.bscFctNm,
- ruseUtztnFcltNm: item.ruseUtztnFcltNm,
- pbnstRuseFcltPk: item.pbnstRuseFcltPk,
- prfList : item.prfList
- };
+ if(data !==undefined){
+ return( {
+
+ sido: item.sido,
+ gugun: item.gugun,
+ bscFctNm: item.bscFctNm,
+ bscFctCd: item.bscFctCd,
+ ruseUtztnFcltNm: data.ruseUtztnFcltNm,
+ pbnstRuseFcltPk: data.pbnstRuseFcltPk,
+ prfList: data.prfList,
+ });
+ }
});
- return data;
+
+ return findData;
};
export const pbnstPrfmncActionsExport: (set: any) => pbnstPrfmncActions = (
set: any
@@ -82,31 +90,21 @@ export const pbnstPrfmncActionsExport: (set: any) => pbnstPrfmncActions = (
console.log(errorHasu);
}
},
- prfmnRegData: async (data:PrfType,) => {
- try{
-
+ prfmnRegData: async (data: PrfType) => {
+ try {
const ressponse = await postFectch(
"/reuseFc/pubFcPrf",
data,
fetchType.WR
);
- console.log('ressponse ', ressponse)
-
- if(ressponse.status === 200){
- ToastFormUi({
- body: "하수재이용 시설 실적 등록이 완료되었습니다. ",
- title: "하수재이용 시설 실적 등록",
- });
-
- }
- }catch(e){
- console.log(e)
- ToastFormUi({
- body: "하수재이용 시설 실적 등록이 실패하였습니다. ",
- title: "하수재이용 시설 실적 등록",
- });
+ if (ressponse.status === 200) {
+ toast.success("하수재이용 시설 실적 등록이 완료되었습니다.");
+ }
+ } catch (e) {
+ console.log(e);
+ toast.error("하수재이용 시설 실적 등록이 실패하였습니다.");
}
},
};
diff --git a/apps/wr/app/store/prfmncReg/pbnstPrfmncReg/type.tsx b/apps/wr/app/store/prfmncReg/pbnstPrfmncReg/type.tsx
index 3bd741663..f6d5ff43f 100644
--- a/apps/wr/app/store/prfmncReg/pbnstPrfmncReg/type.tsx
+++ b/apps/wr/app/store/prfmncReg/pbnstPrfmncReg/type.tsx
@@ -164,6 +164,9 @@ export const initValInUsage = [
"11월": 0,
"12월": 0,
},
+];
+
+export const initValOutUsage = [
{
usage: "resn",
용수명: "세척살수용수",
@@ -198,9 +201,6 @@ export const initValInUsage = [
"11월": 0,
"12월": 0,
},
-];
-
-export const initValOutUsage = [
{
usage: "lndwtr",
용수명: "조경용수",
diff --git a/apps/wr/app/store/prfmncSttn/pbnstPrfmncSttn/excel.tsx b/apps/wr/app/store/prfmncSttn/pbnstPrfmncSttn/excel.tsx
new file mode 100644
index 000000000..113a35289
--- /dev/null
+++ b/apps/wr/app/store/prfmncSttn/pbnstPrfmncSttn/excel.tsx
@@ -0,0 +1,24 @@
+export const excelPrfmncSttnParsing = (
+ data: any[]
+): string[][] => {
+ const excelExportData: string[][] = [];
+ data.forEach((item) => {
+ excelExportData.push([
+ item.용수명,
+ item.total,
+ item["1월"],
+ item["2월"],
+ item["3월"],
+ item["4월"],
+ item["5월"],
+ item["6월"],
+ item["7월"],
+ item["8월"],
+ item["9월"],
+ item["10월"],
+ item["11월"],
+ item["12월"],
+ ]);
+ });
+ return excelExportData;
+};
\ No newline at end of file
diff --git a/apps/wr/app/store/prfmncSttn/pbnstPrfmncSttn/index.tsx b/apps/wr/app/store/prfmncSttn/pbnstPrfmncSttn/index.tsx
index e47301b48..b513085ae 100644
--- a/apps/wr/app/store/prfmncSttn/pbnstPrfmncSttn/index.tsx
+++ b/apps/wr/app/store/prfmncSttn/pbnstPrfmncSttn/index.tsx
@@ -75,7 +75,7 @@ export const pbnstPrfmncSttnActionsExport: (set: any) => pbnstPrfmncSttnActions
for (let i = startYear; i <= endYear; i++) {
const yearHead = JSON.parse(JSON.stringify(pbnstYearHeadListExport));
if (yearHead) {
- yearHead.forEach((item: { id?: number; }) => {
+ yearHead.forEach((item: { id?: string; }) => {
if (item.id) {
item.id = i + item.id;
@@ -86,12 +86,13 @@ export const pbnstPrfmncSttnActionsExport: (set: any) => pbnstPrfmncSttnActions
yearHead[0].title = i + "년도"
}
yearHeader = [...yearHeader, ...yearHead]
- selectList.push({text: i + "년도", val: String(i)} )
+ selectList.push({ text: i + "년도", val: String(i) })
}
set((state: pbnstPrfmncSttnState) => {
return {
...state,
pbnstPrfmncSttn: {
+ ...state.pbnstPrfmncSttn,
pbnstPrfHeadList: [...yearHeader],
selectYearList: selectList
},
@@ -106,7 +107,7 @@ export const pbnstPrfmncSttnActionsExport: (set: any) => pbnstPrfmncSttnActions
pbnstPrfmncSttn: {
...state.pbnstPrfmncSttn,
prfmncRes: prfmncRes,
- isInit: false,
+ isInit: true,
},
}));
} catch (e) {
@@ -115,8 +116,7 @@ export const pbnstPrfmncSttnActionsExport: (set: any) => pbnstPrfmncSttnActions
},
pbnstPrfmncSearch: async (returnType: ReturnType, swtrmtFcltNm: string, fromDate: string, toDate: string) => {
let searchUrl = "";
-
- if (returnType.sigunValue !== undefined) {
+ if (returnType.sigunValue !== "0") {
if (swtrmtFcltNm !== "") {
searchUrl = `/prcsFclt/info/1/20/${returnType.partValue}/${returnType.sigunValue}/0/1/SW${'/' + swtrmtFcltNm}`;
} else {
@@ -134,6 +134,7 @@ export const pbnstPrfmncSttnActionsExport: (set: any) => pbnstPrfmncSttnActions
fetchType.COMMON,
searchUrl
);
+
const bscFctCdList = pbnstRes.map((item: any) => {
return item.bscFctCd;
})
@@ -142,43 +143,66 @@ export const pbnstPrfmncSttnActionsExport: (set: any) => pbnstPrfmncSttnActions
bscFctCdList,
`wr`,
)
-
let inUsageSum = 0;
let outUsageSum = 0;
let usageSum = 0;
let year = "";
const yearsData = []
+
res.data.forEach((item) => {
+ if (item.prfList.length === 0) {
+ const year = ""; // 연도 정보가 없으면 빈 문자열, 필요시 item에서 추출
+ const yearVal = { year: year, pbnstRuseFcltPk: item.pbnstRuseFcltPk ?? "", ruseUtztnFcltNm : item.ruseUtztnFcltNm ?? "" };
+ yearVal[year + "inUsage"] = 0;
+ yearVal[year + "outUsage"] = 0;
+ yearVal[year + "total"] = 0;
+ yearsData.push(yearVal);
+ }
item.prfList.forEach((acc) => {
- year = acc.ym.substring(0, 4);
- inUsageSum = acc.wshwtr + acc.coolUswtr + acc.cleanUswtr + acc.drwtUswtr +
- acc.dltnUswtr + acc.ithlRswtr + acc.ithlEtcUswtr + acc.cleanToilUswtr + acc.resn;
- outUsageSum = acc.lndwtr + acc.hydUswtr + acc.ugwtChr + acc.farmUswtr + acc.rvrKeepUswtr + acc.indstUswtr;
- const yearData = yearsData.find(yearItem => yearItem.year === year && yearItem.pbnstRuseFcltPk == acc.pbnstRuseFcltPk)
+ year = acc.ym?.substring(0, 4) ?? "";
+ inUsageSum =
+ (acc.wshwtr ?? 0) +
+ (acc.coolUswtr ?? 0) +
+ (acc.cleanUswtr ?? 0) +
+ (acc.drwtUswtr ?? 0) +
+ (acc.dltnUswtr ?? 0) +
+ (acc.ithlRswtr ?? 0) +
+ (acc.ithlEtcUswtr ?? 0) +
+ (acc.cleanToilUswtr ?? 0) +
+ (acc.resn ?? 0);
+ outUsageSum =
+ (acc.lndwtr ?? 0) +
+ (acc.hydUswtr ?? 0) +
+ (acc.ugwtChr ?? 0) +
+ (acc.farmUswtr ?? 0) +
+ (acc.rvrKeepUswtr ?? 0) +
+ (acc.indstUswtr ?? 0);
+ const yearData = yearsData.find(
+ (yearItem) =>
+ yearItem.year === year &&
+ yearItem.pbnstRuseFcltPk == acc.pbnstRuseFcltPk
+ );
if (yearData) {
- yearData.inUsageSum += inUsageSum;
- yearData.outUsageSum += outUsageSum;
+ yearData[year + "inUsage"] += inUsageSum;
+ yearData[year + "outUsage"] += outUsageSum;
+ yearData[year + "total"] += (inUsageSum + outUsageSum);
} else {
- const yearVal = { year: year, pbnstRuseFcltPk: acc.pbnstRuseFcltFk }
- yearVal[year + 'inUsage'] = inUsageSum;
- yearVal[year + 'outUsage'] = outUsageSum;
- yearVal[year + 'total'] = inUsageSum + outUsageSum;
+ const yearVal = { year: year, pbnstRuseFcltPk: acc.pbnstRuseFcltFk, ruseUtztnFcltNm : item.ruseUtztnFcltNm ?? "" };
+ yearVal[year + "inUsage"] = inUsageSum;
+ yearVal[year + "outUsage"] = outUsageSum;
+ yearVal[year + "total"] = inUsageSum + outUsageSum;
yearsData.push(yearVal);
}
-
- })
- })
+ });
+ });
const resData: any[] = []
pbnstRes.forEach((acc) => {
let data = yearsData.find((item) => item.pbnstRuseFcltPk.substring(0, 11) === acc.bscFctCd)
if (data) {
- resData.push({ ...data, ...acc })
+ resData.push({ ...acc, ...data })
}
})
-
-
-
return set((state: pbnstPrfmncSttnState) => ({
...state,
pbnstPrfmncSttn: {
diff --git a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/index.tsx b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/index.tsx
index 9fde9c092..fb799c26c 100644
--- a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/index.tsx
+++ b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/index.tsx
@@ -24,6 +24,7 @@ import {
fcOrgwtsHeadListExport,
} from "./headList";
import type { TableUpperProps } from "@/app/store/common/type/header";
+import toast from "react-hot-toast";
const selectLabel: SelectDataType[] = [{ text: "test", val: "1" }];
const pubFacHeadList = pubFacHeadListExport;
@@ -62,9 +63,9 @@ type pubFacActions = {
appendRuseFclt(array: customPbnst[]): void;
fileDelete: (atflCd: string) => void;
fileDownLoad: (atflCd: string) => void;
- pbnstMngData: (data: customPbnst[]) => void;
- pbnstBizData(data: fcBizType): void;
- getBizCycle: (pbnstObj: customPbnst) => void;
+ //pbnstMngData: (data: customPbnst[]) => void;
+ //pbnstBizData(data: fcBizType): void;
+ // getBizCycle: (pbnstObj: customPbnst) => void;
getpbnstInsertIndex: (data: pbnstInsertIndex) => void;
pbnstRuseFcltUpdate: (ruseRes: customPbnst[]) => void;
pbnstRuseBizUpdate: (ruseRes: fcBizType[]) => void;
@@ -100,14 +101,20 @@ const checkWrRegList = async () => {
const hasuListFetch = async (page: string, sggOrCity: string, searchTxt?:string) => {
const checkWrRegListRes = await checkWrRegList();
-let url = `/prcsFclt/ruseInfo/${page ? page : 1}/10/A/${sggOrCity ? sggOrCity : "11"}/0/1/SW`;
+
+ console.log(' checkWrRegListRes ', checkWrRegListRes)
+let url = `/prcsFclt/ruseInfo/${page ? page : 1}/10/A/${sggOrCity? sggOrCity : "11"}/0/1/SW`;
+
+
+const data = checkWrRegListRes.filter((item:string) => item !== "")
+ console.log(' checkWrRegListRes ' )
if(searchTxt){
url= url +`/${searchTxt}`
}
const rainRes = await postFectch(
url,
- checkWrRegListRes,
+ data,
fetchType.COMMON
);
@@ -200,7 +207,6 @@ export const pubFacActionsExport: (set: any) => pubFacActions = (set: any) => {
pbnstRegClick: async (pubHasuRes: pubHasuType) => {
try {
const pbnstRes = await initFetch(pubHasuRes.bscFctCd);
- console.log('pbnstRes ' , pbnstRes)
return set((state: pubFacState) => ({
...state,
pbnst: {
@@ -234,14 +240,19 @@ export const pubFacActionsExport: (set: any) => pubFacActions = (set: any) => {
const response = await postFectch(
`/reuseFc/pubFc`,
- JSON.stringify( pbnstRes)
+ pbnstRes
);
+ if( response.status === 200) {
+ toast.success(`${pbnstRes.ruseUtztnFcltNm} 하수재이용 시설이 등록되었습니다.`);
+ }
+ const pbnstHasuRes = await hasuListFetch('1', '0');
+
return set((state: pubFacState) => ({
...state,
pbnst: {
...state.pbnst,
- pbnstRes: response.data,
+ pbnstRes: pbnstHasuRes,
isInit: false,
},
}));
@@ -334,41 +345,41 @@ export const pubFacActionsExport: (set: any) => pubFacActions = (set: any) => {
}
},
- pbnstMngData: (data: customPbnst[]) => {
- if (data.length > 0) {
- }
- return set((state: pubFacState) => {
- state.pbnst.pbnstMngRegData = data;
- state.pbnst.pbnstBizCycle =
- data.length <= 0
- ? [{ text: "없음", val: "1" }]
- : state.pbnst.pbnstBizCycle;
- return state;
- });
- },
+ // pbnstMngData: (data: customPbnst[]) => {
+ // if (data.length > 0) {
+ // }
+ // return set((state: pubFacState) => {
+ // state.pbnst.pbnstMngRegData = data;
+ // state.pbnst.pbnstBizCycle =
+ // data.length <= 0
+ // ? [{ text: "없음", val: "1" }]
+ // : state.pbnst.pbnstBizCycle;
+ // return state;
+ // });
+ // },
- pbnstBizData: (data: fcBizType) => {
- return set((state: pubFacState) => {
- if (state.pbnst.pbnstMngRegData) {
- const regData = state.pbnst.pbnstMngRegData.find(
- (item) => data.pbnstRuseFcltFk === item.pbnstRuseFcltPk
- );
- if (regData) {
- const bizIdx = regData.fcBizs.findIndex(
- (item) => item.pbnstRuseFcltBizPk == data.pbnstRuseFcltBizPk
- );
+ // pbnstBizData: (data: fcBizType) => {
+ // return set((state: pubFacState) => {
+ // if (state.pbnst.pbnstMngRegData) {
+ // const regData = state.pbnst.pbnstMngRegData.find(
+ // (item) => data.pbnstRuseFcltFk === item.pbnstRuseFcltPk
+ // );
+ // if (regData) {
+ // const bizIdx = regData.fcBizs.findIndex(
+ // (item) => item.pbnstRuseFcltBizPk == data.pbnstRuseFcltBizPk
+ // );
- if (bizIdx >= 0) {
- regData.fcBizs[bizIdx] = data;
- const pbnstData = state.pbnst.pbnstMngRegData
- state.pbnst.pbnstMngRegData= [...pbnstData]
+ // if (bizIdx >= 0) {
+ // regData.fcBizs[bizIdx] = data;
+ // const pbnstData = state.pbnst.pbnstMngRegData
+ // state.pbnst.pbnstMngRegData= [...pbnstData]
- }
- }
- }
- return state;
- });
- },
+ // }
+ // }
+ // }
+ // return state;
+ // });
+ // },
getpbnstInsertIndex: async (data: pbnstInsertIndex) => {
return set((state: pubFacState) => {
state.pbnst.pbnsUpdateIndex = data;
diff --git a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/type.tsx b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/type.tsx
index fb9515bcf..a34985810 100644
--- a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/type.tsx
+++ b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/type.tsx
@@ -57,7 +57,7 @@ export type PbnstDemandComType = {
dmdAplyPswd: string | '';
splyCpct: number | 0;
splyFmYn:string|'Y'
- dmdInfoFk:string|''
+// dmdInfoFk:string|''
}
const pubHasuZod = z.object({
@@ -129,14 +129,14 @@ const fcOrgwtSchema = z.object({
});
const dmdColist = z.object({
- dmdInfoFk: z.string().default(''),
+ dmdInfoPk: z.string().default(''),
dmdCoNm: z.string().default(''),
daddr: z.string(),
- useUsgCd: z.string().default(""),
+ useUsgCd: z.string().nullish(),
splyBgngDay: zDateDefaultNow,
splyEndDay: zDateDefaultNow,
splyCpct: zNumDefaultZero,
- splyFmYn: z.string().default('Y'),
+ splyFmYn: z.string().nullish(),
rgtr: z.string().nullish(),
mdfr: z.string().nullish(),
pbnstRuseFcltBizPk: zNumDefaultZero,
@@ -208,7 +208,7 @@ export const fcBizSchema = z.object({
ruseFcltCstClcln: zNumNullish,
fcOrgwts: z.array(fcOrgwtSchema).nullish(),
pplInstls: z.array(pplInstlSchema).nullish(),
- fcDemands: z.array(dmdColist).default([]).nullish(),
+ fcDemands: z.array(dmdColist).nullish(),
flg: z.string().nullish(),
regDt: z.string().nullish(),
rgtr: z.string().nullish(),
diff --git a/apps/wr/app/store/ruseFcltMng/fcltReg/rainReg/index.tsx b/apps/wr/app/store/ruseFcltMng/fcltReg/rainReg/index.tsx
index d398b7f6e..5b3ad6813 100644
--- a/apps/wr/app/store/ruseFcltMng/fcltReg/rainReg/index.tsx
+++ b/apps/wr/app/store/ruseFcltMng/fcltReg/rainReg/index.tsx
@@ -3,7 +3,76 @@ import { getFetch, postFectch, putFectch } from "@/components/lib/api";
import { z } from "zod";
import { makeMdfr, makeRstr } from "../bdstReg";
+const validationMessages = {
+ required: (field: string) => `${field}을(를) 입력해주세요.`,
+ requiredSelect: (field: string) => `${field}을(를) 선택해주세요.`,
+ yearFormat: '4자리 연도만 입력하세요',
+};
+
export const TEST_UUID= '2d4b151d-1828-41e0-91d9-4cd28ea1cc7e'
+
+const rainyObjSchema = z.object({
+ bdstReuseFcltFk: z.number().nullish(),
+ pntfColKnd: z.string().default(""),
+ pntfColArea: z.number().default(0),
+ dtfcltCpct: z.number().default(0),
+ filtrTrtmfctYn: z.string().default("Y").nullish(),
+ filtrTrtmfctCpct: z.number().nullish().default(0),
+ filtrTrtmfctPrs: z.string().default(""),
+ annRnwtQty: z.number().default(0),
+ oilqMeasMthd: z.string().default("").nullish(),
+ rgtr:z.string().nullish(),
+ mdfr:z.string().nullish(),
+}).refine((data) => data.pntfColKnd.length > 0, {
+ message: validationMessages.requiredSelect("종류"),
+ path: ["pntfColKnd"],
+}).refine((data) => data.pntfColArea > 0, {
+ message: validationMessages.required("면적(m³)"),
+ path: ["pntfColArea"],
+});
+
+const reuseBuildingSchema = z.object({
+ bdstRuseFcltPk: z.number().nullish(),
+ bdstInfoFk:z.number().nullish(),
+ instlCmptnDt: z.coerce.date().default(() => new Date()),
+ instlCst: z.number().nullish(),
+ operMngCd: z.string().optional().default(""),
+ anlOperCst: z.number().default(0),
+ instlCstSprtYn: z.string().default("Y"),
+ instlCstSprtAmt: z.number().nullish(),
+ grntchBdstCertYn: z.string().default("Y"),
+ grntchBdstCertYr: z.string().default("")
+ .refine((year)=> year.length===0 || /^\d{4}$/.test(year),{
+ message: validationMessages.yearFormat
+ }),
+ grntchBdstCertNo: z.string().default(""),
+ grntchBdstCertGrd: z.string().default(""),
+ crgRdctYn: z.string().default("N").nullish(), /// 안쓰는 값
+ crgRdctBss: z.string().default("").nullish(), /// 안쓰는 값
+ crgRdctAmt: z.number().default(0), // 안쓰는 값
+ ruseFcltFlg: z.string().default(""),
+ bdstUsgCd: z.number().default(0),
+ lawTrgtYn: z.string().default("Y"),
+ rgtr:z.string().nullish(),
+ mdfr:z.string().nullish(),
+ rainyObj: rainyObjSchema.default({})
+}).refine((data) => data.bdstUsgCd > 0, {
+ message: validationMessages.requiredSelect("건축물용도"),
+ path: ["bdstUsgCd"],
+});
+
+const chgBuildingSchema = z.object({
+ bdstInfoFk: z.number().nullish(),
+ archChgPrmsnDt: z.coerce.date({required_error: validationMessages.required("허가일")}),
+ archChgArea: z.string().default("-"),
+ bdstChgNm: z.string().default(""),
+ rgtr:z.string().nullish(),
+ mdfr:z.string().nullish(),
+}).refine(data => data.bdstChgNm.length > 0, {
+ message: validationMessages.requiredSelect("구분"),
+ path: ["bdstChgNm"]
+});
+
export const rainZod = z.object({
bdstInfoPk: z.number().optional(),
ctpvCd: z.number().default(0),
@@ -16,62 +85,9 @@ export const rainZod = z.object({
archChgArea: z.number().default(0),
rgtr:z.string().nullish(),
mdfr:z.string().nullish(),
- reuseBuilding: z.array(
- z.object({
- bdstRuseFcltPk: z.number().nullish(),
- bdstInfoFk:z.number().nullish(),
- instlCmptnDt: z.coerce.date().default(() => new Date()),
- instlCst: z.number().nullish(),
- operMngCd: z.string().optional().default(""),
- anlOperCst: z.number().default(0),
- instlCstSprtYn: z.string().default(""),
- instlCstSprtAmt: z.number().nullish(),
- grntchBdstCertYn: z.enum(["Y", "N"]).nullish(),
- grntchBdstCertYr: z.string().default("")
- .refine((year)=> year.length===0 || /^\d{4}$/.test(year),{
- message:'4자리 연도만 입력하세요'
- }),
- grntchBdstCertNo: z.string().default(""),
- grntchBdstCertGrd: z.string().default(""),
- crgRdctYn: z.string().default("N").nullish(), /// 안쓰는 값
- crgRdctBss: z.string().default("").nullish(), /// 안쓰는 값
- crgRdctAmt: z.number().default(0), // 안쓰는 값
- ruseFcltFlg: z.string().default(""),
- bdstUsgCd: z.number().default(0),
- lawTrgtYn: z.enum(["Y", "N"]),
- rgtr:z.string().nullish(),
- mdfr:z.string().nullish(),
-
- rainyObj: z.object({
- bdstReuseFcltFk: z.number().nullish(),
- pntfColKnd: z.string().default(""),
- pntfColArea: z.number().default(0),
- dtfcltCpct: z.number().default(0),
- filtrTrtmfctYn: z.enum(["Y", "N"]).nullish(),
- filtrTrtmfctCpct: z.number().nullish().default(0),
- filtrTrtmfctPrs: z.string().default(""),
- annRnwtQty: z.number().default(0),
- oilqMeasMthd: z.string().default("").nullish(),
- rgtr:z.string().nullish(),
- mdfr:z.string().nullish(),
-
-
- }).default({})
- })
- ).default([]),
-
- chgBuilding: z.array(
- z.object({
- bdstInfoFk: z.number().nullish(),
- archChgPrmsnDt: z.coerce.date(),
- archChgArea: z.string().default("-"),
- bdstChgNm: z.string().default(""),
- rgtr:z.string().nullish(),
- mdfr:z.string().nullish(),
-
- })
- ).default([])
-});
+ reuseBuilding: z.array(reuseBuildingSchema).default([]),
+ chgBuilding: z.array(chgBuildingSchema).default([])
+})
export type chgBuilding={
bdstInfoFk?: number|null,
@@ -254,6 +270,3 @@ export const rainFacActionsExport: (set: any) => rainFacSActions = (
}
}}
-
-
-
diff --git a/apps/wr/app/store/ruseFcltMng/fcltSttn/htdflSttn/excel.tsx b/apps/wr/app/store/ruseFcltMng/fcltSttn/htdflSttn/excel.tsx
index 671eacae8..591623911 100644
--- a/apps/wr/app/store/ruseFcltMng/fcltSttn/htdflSttn/excel.tsx
+++ b/apps/wr/app/store/ruseFcltMng/fcltSttn/htdflSttn/excel.tsx
@@ -1,30 +1,34 @@
+import type { SelectDataType } from "@common/business_components/ui";
import type { customHtdflBdst } from "../../fcltReg/htdflReg";
-export const excelHtdflSttnParsing = (data: customHtdflBdst[]): string[][] => {
+export const excelHtdflSttnParsing = (
+ data: customHtdflBdst[],
+ sidoCode: SelectDataType[],
+ sggCode: SelectDataType[]
+): string[][] => {
const excelExportData: string[][] = [];
data.forEach((item) => {
excelExportData.push([
- String(item.cityText??""),
- String(item.sggText??""),
+ sidoCode.find((sido) => sido.val === item.ctpvCd.toString())?.text ?? "",
+ sggCode.find((sgg) => sgg.val === item.sggCd.toString())?.text ?? "",
item.bdstNm ?? "",
item.daddr ?? "",
String(item.frstArchPrmsnDt ?? ""),
String(item.reuseBuilding?.[0]?.htdflObj.etgtType ?? ""),
String(item.reuseBuilding?.[0]?.htdflObj.fclCpct ?? ""), // fix: added missing parenthesis
- String(item.reuseBuilding?.[0]?.htdflObj.plwtYn ? "Y" :"N"), // fix: added missing parenthesis
+ String(item.reuseBuilding?.[0]?.htdflObj.plwtYn ? "Y" : "N"), // fix: added missing parenthesis
String(item.reuseBuilding?.[0]?.htdflObj.orgwtWtritSpt ?? ""), // fix: added missing parenthesis
String(item.reuseBuilding?.[0]?.htdflObj.wtritEntrcTp ?? ""), // fix: removed as it doesn't exist in the provided context
String(item.reuseBuilding?.[0]?.htdflObj.orgwtOcrnProcs ?? ""), // fix: removed as it doesn't exist in the provided context
- String( item.reuseBuilding?.[0]?.htdflObj?.amtgnr ?? ""), // fix: removed as it doesn't exist in the provided context
+ String(item.reuseBuilding?.[0]?.htdflObj?.amtgnr ?? ""), // fix: removed as it doesn't exist in the provided context
String(item.reuseBuilding?.[0]?.htdflObj?.prcsProcsYn ?? ""), // fix: removed as it doesn't exist in the provided context
- String( '컬럼확인'), // fix: removed as it doesn't exist in the provided context
String(item.reuseBuilding?.[0]?.htdflObj?.prcsFcltCpct ?? ""), // fix: removed as it doesn't exist in the provided context
String(item.reuseBuilding?.[0]?.htdflObj?.fmYn ?? ""), // fix: removed as it doesn't exist in the provided context
String(item.reuseBuilding?.[0]?.htdflObj?.utztnCpct ?? ""), // fix: removed as it doesn't exist in the provided context
String(item.reuseBuilding?.[0]?.htdflObj?.utztnUsg ?? ""), // fix: removed as it doesn't exist in the provided context
String(item.reuseBuilding?.[0]?.htdflObj?.emsnExitTp ?? ""), // fix: removed as it doesn't exist in the provided context
- ]);
- });
- return excelExportData;
+ ]);
+ });
+ return excelExportData;
};
diff --git a/apps/wr/app/store/ruseFcltMng/fcltSttn/htdflSttn/headList.tsx b/apps/wr/app/store/ruseFcltMng/fcltSttn/htdflSttn/headList.tsx
index 8de673f16..756c47b9b 100644
--- a/apps/wr/app/store/ruseFcltMng/fcltSttn/htdflSttn/headList.tsx
+++ b/apps/wr/app/store/ruseFcltMng/fcltSttn/htdflSttn/headList.tsx
@@ -70,13 +70,6 @@ export const htdflSttHeadListExport: z.infer
= [
title: "처리공정여부",
visible: true,
},
- {
- id: "prcsProcstest",
- title: "처리공정여부??",
- visible: true,
- },
-
-
{
id: "prcsFcltCpct",
title: "처리시설용량(m³)",
@@ -259,36 +252,15 @@ export const htdflSttNodeListExport: CommonTableProps[] = [
rowSpan: 2,
colSpan: 1,
},
- {
- id: "prcsProcs",
- title: "처리공정",
- upName: "htdflMngInfo",
- visible: true,
- row: 2,
- rowSpan: 1,
- colSpan: 2,
- },
{
id: "prcsProcsYn",
title: "처리공정여부",
upName: "prcsProcs",
visible: true,
- row: 3,
- rowSpan: 1,
+ row: 2,
+ rowSpan: 2,
colSpan: 1,
},
-
- {
- id: "prcsProcstest",
- title: "처리공정여부??",
- upName: "prcsProcs",
- visible: true,
- row: 3,
- rowSpan: 1,
- colSpan: 1,
- },
-
-
{
id: "prcsFcltCpct",
title: "처리시설용량(m³)",
diff --git a/apps/wr/app/store/ruseFcltMng/fcltSttn/pbnstSttn/headList.tsx b/apps/wr/app/store/ruseFcltMng/fcltSttn/pbnstSttn/headList.tsx
index 9fe7fddc9..7c2953932 100644
--- a/apps/wr/app/store/ruseFcltMng/fcltSttn/pbnstSttn/headList.tsx
+++ b/apps/wr/app/store/ruseFcltMng/fcltSttn/pbnstSttn/headList.tsx
@@ -31,8 +31,8 @@ export const pbnSttHeadListExport: z.infer = [
{ id: "bscFctNm", title: "시설명", visible: true },
{ id: "efflWqltStndrdNm", title: "지역구분", visible: true },
- { id: "fctCpc", title: "시설용량(톤/일)", visible: true },
{ id: "tel", title: "전화번호", visible: true },
+ { id: "fctCpc", title: "시설용량(톤/일)", visible: true },
{ id: "ruseUtztnFcltNm", title: "재이용시설명", visible: true },
{
@@ -132,7 +132,7 @@ export const pbnstSttNodeListExport: CommonTableProps[] = [
colSpan: 1,
},
{
- id: "phone",
+ id: "tel",
title: "전화번호",
visible: true,
row: 1,
@@ -140,7 +140,7 @@ export const pbnstSttNodeListExport: CommonTableProps[] = [
colSpan: 1,
},
{
- id: "fcltQuantity",
+ id: "fctCpc",
title: "시설용량(톤/일)",
visible: true,
row: 1,
@@ -325,7 +325,7 @@ export const ruseFcltNodeListExport: TableUpperProps[] = [
visible: true,
row: 1,
rowSpan: 1,
- colSpan: 10,
+ colSpan: 9,
},
{
id: "ruseFclt",
@@ -333,10 +333,10 @@ export const ruseFcltNodeListExport: TableUpperProps[] = [
visible: true,
row: 1,
rowSpan: 1,
- colSpan: 5,
+ colSpan: 3,
},
{
- id: "mainSply",
+ id: "mainSplyPumpCpct",
title: "메인공급펌프용량",
visible: true,
row: 1,
@@ -349,7 +349,7 @@ export const ruseFcltNodeListExport: TableUpperProps[] = [
visible: true,
row: 2,
rowSpan: 1,
- colSpan: 6,
+ colSpan: 5,
},
{
id: "instlAprvSncnDt",
@@ -424,14 +424,7 @@ export const ruseFcltNodeListExport: TableUpperProps[] = [
rowSpan: 1,
colSpan: 1,
},
- {
- id: "cusrAlotm2",
- title: "원인자부담금",
- visible: true,
- row: 3,
- rowSpan: 1,
- colSpan: 1,
- },
+
{ id: "etc", title: "기타", visible: true, row: 3, rowSpan: 1, colSpan: 1 },
{
id: "totalMoney",
@@ -498,11 +491,7 @@ export const ruseFcltHeadListExport: CommonTableProps[] = [
title: "민간투자비",
visible: true,
},
- {
- id: "cusrAlotm2",
- title: "원인자부담금",
- visible: true,
- },
+
{ id: "etc", title: "기타", visible: true },
{
id: "totalMoney",
@@ -545,7 +534,7 @@ export const ruseFcltHeadListExport: CommonTableProps[] = [
visible: true,
},
{
- id: "mainSply",
+ id: "mainSplyPumpCpct",
title: "메인공급펌프용량",
visible: true,
},
diff --git a/apps/wr/app/store/ruseFcltMng/fcltSttn/pbnstSttn/index.tsx b/apps/wr/app/store/ruseFcltMng/fcltSttn/pbnstSttn/index.tsx
index 6ce27db86..33bce5520 100644
--- a/apps/wr/app/store/ruseFcltMng/fcltSttn/pbnstSttn/index.tsx
+++ b/apps/wr/app/store/ruseFcltMng/fcltSttn/pbnstSttn/index.tsx
@@ -9,6 +9,7 @@ import { excelPbnstSttnParsing } from "./excel";
import type { FcPrfType } from "@/app/store/prfmncReg/pbnstPrfmncReg/type";
import type { ReturnType } from "@common/business_components/ui";
import type { WaterReuseFacility } from "./type";
+import moment from "moment";
const pbnstSttHeadList = pbnSttHeadListExport;
const pbnstSttNodeList = pbnstSttNodeListExport;
@@ -166,8 +167,8 @@ const hasuListFetch = async (
outUsage: usage.outUsage,
operMthd: item.operList[0]?.operMthd,
rprtvBzenty: item.operList[0]?.rprtvBzenty,
- bgngDt: item.operList[0]?.bgngDt.toLocaleDateString ?? "",
- endDt: item.operList[0]?.endDt.toLocaleDateString?? "",
+ bgngDt: moment(item.operList[0]?.bgngDt).format("YYYY-MM-DD") ?? "",
+ endDt: moment(item.operList[0]?.endDt).format("YYYY-MM-DD") ?? "",
searchNm: findData.bscFctNm,
searchPk: findData.bscFctCd,
prfList:item?.prfList??[]
diff --git a/apps/wr/app/store/ruseFcltMng/fcltSttn/rainSttn/excel.tsx b/apps/wr/app/store/ruseFcltMng/fcltSttn/rainSttn/excel.tsx
index 8ae786488..13530a81f 100644
--- a/apps/wr/app/store/ruseFcltMng/fcltSttn/rainSttn/excel.tsx
+++ b/apps/wr/app/store/ruseFcltMng/fcltSttn/rainSttn/excel.tsx
@@ -1,18 +1,23 @@
+import type { SelectDataType } from "@common/business_components/ui";
import type { customRainBdst } from "../../fcltReg/rainReg";
-export const excelRainSttnParsing = (data: customRainBdst[]): string[][] => {
+export const excelRainSttnParsing = (
+ data: customRainBdst[],
+ sidoCode: SelectDataType[],
+ sggCode: SelectDataType[]
+): string[][] => {
const excelExportData: string[][] = [];
data.forEach((item) => {
excelExportData.push([
- String(item.ctpvCd),
- String(item.sggCd),
+ sidoCode.find((sido) => sido.val === item.ctpvCd.toString())?.text ?? "",
+ sggCode.find((sgg) => sgg.val === item.sggCd.toString())?.text ?? "",
item.bdstNm ?? "",
item.daddr ?? "",
String(item.bdstInfoPk ?? ""),
String(item.frstArchPrmsnDt ?? ""),
String(item.archArea ?? ""),
- String(item.chgBuilding.length>0 ? "Y" :"N"),
+ String(item.chgBuilding.length > 0 ? "Y" : "N"),
String(item.reuseBuilding?.[0]?.lawTrgtYn ?? ""),
String(item.reuseBuilding?.[0]?.instlCmptnDt ?? ""),
String(item.reuseBuilding?.[0]?.instlCst ?? ""),
@@ -28,8 +33,8 @@ export const excelRainSttnParsing = (data: customRainBdst[]): string[][] => {
String(item.reuseBuilding?.[0]?.grntchBdstCertYr ?? ""),
String(item.reuseBuilding?.[0]?.grntchBdstCertNo ?? ""),
String(item.reuseBuilding?.[0]?.grntchBdstCertGrd ?? "")
- ]);
- });
- return excelExportData;
+ ]);
+ });
+ return excelExportData;
};
diff --git a/apps/wr/app/store/ruseFcltMng/fcltSttn/rainSttn/index.tsx b/apps/wr/app/store/ruseFcltMng/fcltSttn/rainSttn/index.tsx
index 853298d51..5aa54ee48 100644
--- a/apps/wr/app/store/ruseFcltMng/fcltSttn/rainSttn/index.tsx
+++ b/apps/wr/app/store/ruseFcltMng/fcltSttn/rainSttn/index.tsx
@@ -13,6 +13,7 @@ import {
} from "./headList";
import type { z } from "zod";
import type { CommonTableProps } from "@/app/store/common/type/header";
+import type { SelectDataType } from "@common/business_components/ui";
// 테이블 헤드 리스트
const rainSttHeadList = rainSttHeadListExport;
@@ -101,7 +102,7 @@ export type rainSttnState = {
};
type rainSttnActions = {
rainSttnInit:(con:string) => void
- rainSttnSearch: (page: number, total: string, con: string) => void;
+ rainSttnSearch: (page: number, total: string, con: string, sidoCode: SelectDataType[], sggCode: SelectDataType[]) => void;
rainChSttnHead: (
headList: z.infer,
) => void;
@@ -148,14 +149,16 @@ export const rainSttnActionsExport: (set: any) => rainSttnActions = (
console.log(e)
}
},
- rainSttnSearch: async (page: number, total: string, con: string) => {
+ rainSttnSearch: async (page: number, total: string, con: string,
+ sidoCode: SelectDataType[],
+ sggCode: SelectDataType[]) => {
try {
const rainSttnRes = await getFetch(
fetchType.WR,
`/reuseFc/rainyInfoList/${page}/${total}/${con}`
);
if (Number(total) > 9000) {
- const rainExcel = excelRainSttnParsing(rainSttnRes);
+ const rainExcel = excelRainSttnParsing(rainSttnRes, sidoCode, sggCode);
set((state: rainSttnState) => {
return {
...state,
diff --git a/apps/wr/app/store/ruseFcltMng/fcltSttn/rswtSttn/excel.tsx b/apps/wr/app/store/ruseFcltMng/fcltSttn/rswtSttn/excel.tsx
index 5c0ecf0b3..ac57a8016 100644
--- a/apps/wr/app/store/ruseFcltMng/fcltSttn/rswtSttn/excel.tsx
+++ b/apps/wr/app/store/ruseFcltMng/fcltSttn/rswtSttn/excel.tsx
@@ -1,19 +1,25 @@
+import type { SelectDataType } from "@common/business_components/ui";
import type { customRswtBdst } from "../../fcltReg/rswtReg";
+import { useWrStore } from "@/app/store";
-export const excelRSwtSttnParsing = (data: customRswtBdst[]): string[][] => {
+export const excelRSwtSttnParsing = (
+ data: customRswtBdst[],
+ sidoCode: SelectDataType[],
+ sggCode: SelectDataType[]
+): string[][] => {
const excelExportData: string[][] = [];
data.forEach((item) => {
excelExportData.push([
- String(item.ctpvCd),
- String(item.sggCd),
+ sidoCode.find((sido) => sido.val === item.ctpvCd.toString())?.text ?? "",
+ sggCode.find((sgg) => sgg.val === item.sggCd.toString())?.text ?? "",
item.bdstNm ?? "",
item.daddr ?? "",
String(item.bdstUsgText ?? ""),
String(item.frstArchPrmsnDt ?? ""),
String(item.archArea ?? ""),
String(item.reuseBuilding?.[0]?.rswtrObj.wtrUsqty ?? "0"), //물사용량
- String(item.chgBuilding.length>0 ? "Y" :"N"), //중축・개축・재축여부
+ String(item.chgBuilding.length > 0 ? "Y" : "N"), //중축・개축・재축여부
String(item.reuseBuilding?.[0]?.lawTrgtYn ?? ""), //법적의무대상여부
String(item.reuseBuilding?.[0]?.rswtrObj.oblgTrgtWtrUsqty ?? ""), //의무대상물사용량
String(item.reuseBuilding?.[0]?.instlCmptnDt ?? ""), //설치완료일시
@@ -28,7 +34,7 @@ export const excelRSwtSttnParsing = (data: customRswtBdst[]): string[][] => {
String(item.reuseBuilding?.[0]?.grntchBdstCertYr ?? ""),
String(item.reuseBuilding?.[0]?.grntchBdstCertNo ?? ""),
String(item.reuseBuilding?.[0]?.grntchBdstCertGrd ?? "")
- ]);
- });
- return excelExportData;
+ ]);
+ });
+ return excelExportData;
};
\ No newline at end of file
diff --git a/apps/wr/app/store/ruseFcltMng/fcltSttn/rswtSttn/index.tsx b/apps/wr/app/store/ruseFcltMng/fcltSttn/rswtSttn/index.tsx
index 775e22e0c..301cd965e 100644
--- a/apps/wr/app/store/ruseFcltMng/fcltSttn/rswtSttn/index.tsx
+++ b/apps/wr/app/store/ruseFcltMng/fcltSttn/rswtSttn/index.tsx
@@ -6,6 +6,7 @@ import { controlHeadView } from "../rainSttn";
import type { sttnHeadListType } from "../rainSttn/headList";
import { excelRSwtSttnParsing } from "./excel";
import { rswtSttHeadListExport, rswtSttNodeListExport } from "./headList";
+import type { SelectDataType } from "@common/business_components/ui";
@@ -26,11 +27,10 @@ export type rswtSttnState = {
};
};
-
-
type rswtSttnActions = {
rswtSttnInit: (con: string) => void;
- rswtSttnSearch: (page: number, total: string, con: string) => void;
+ rswtSttnSearch: (page: number, total: string, con: string, sidoCode: SelectDataType[],
+ sggCode: SelectDataType[]) => void;
rswtChSttnHead: (
headList: z.infer,
) => void;
@@ -38,8 +38,6 @@ type rswtSttnActions = {
export type rswtSttnType = rswtSttnState & rswtSttnActions;
-
-
export const rswtSttnStateExport: rswtSttnState = {
rswtSttn: {
rswtSttHeadList: rswtSttHeadList,
@@ -77,14 +75,16 @@ export const rswtSttnActionsExport: (set: any) => rswtSttnActions = (
console.log(e)
}
},
- rswtSttnSearch: async (page: number, total: string, con: string) => {
+ rswtSttnSearch: async (page: number, total: string, con: string,
+ sidoCode: SelectDataType[],
+ sggCode: SelectDataType[]) => {
try {
const rswtSttnRes = await getFetch(
fetchType.WR,
`/reuseFc/waterreuseFc/${page}/${total}/${con}`
);
if (Number(total) > 9000) {
- const rswtExcel = excelRSwtSttnParsing(rswtSttnRes);
+ const rswtExcel = excelRSwtSttnParsing(rswtSttnRes, sidoCode, sggCode);
set((state: rswtSttnState) => {
return {
...state,
diff --git a/apps/wr/components/lib/config/index.ts b/apps/wr/components/lib/config/index.ts
index d0e076d81..f85f7bad9 100644
--- a/apps/wr/components/lib/config/index.ts
+++ b/apps/wr/components/lib/config/index.ts
@@ -8,7 +8,7 @@ export const LOCAL_URL_WR = `http://localhost:${LOCAL_PORT}/api/v1`;
export const DEV_URL_WR = `http://con.mind-one.co.kr:${DEV_PORT}/api/v1`;
// export const DEV_URL_WR = `http://192.168.0.91:8880/api/v1`;
-// export const DEV_URL_FO = `http://192.168.0.91:8882/api/v1`;
+/// export const DEV_URL_FO = `http://192.168.0.91:8882/api/v1`;
export const DEV_URL_FO = `http://con.mind-one.co.kr:${DEV_PORT_NEW}/api/v1`;
diff --git a/apps/wr/components/lib/func/TableData.tsx b/apps/wr/components/lib/func/TableData.tsx
index c21a7e70a..dbb3aa7a6 100644
--- a/apps/wr/components/lib/func/TableData.tsx
+++ b/apps/wr/components/lib/func/TableData.tsx
@@ -152,7 +152,8 @@ export const chRowspanTable = (
onChange={(e) => {
handleChange(rowIndex, head.id, e.target.value);
}}
- value={value}
+ value={value ?? ""}
+ disabled={!selectedIds.includes(row.chkgdnPk)}
/>
) : (
(head.id === "totalSplyUswtrUtztnQnt" || head.id === "totalRuseFcltUtztnQnt" || head.id === "splyUswtrUtztnQnt" || head.id === "ruseFcltUtztnQnt") ? (
diff --git a/apps/wr/components/lib/func/calculateConstCost .tsx b/apps/wr/components/lib/func/calculateConstCost .tsx
new file mode 100644
index 000000000..5e9387385
--- /dev/null
+++ b/apps/wr/components/lib/func/calculateConstCost .tsx
@@ -0,0 +1,101 @@
+export const findBounds = (
+ data: any[],
+ fctCd: string,
+ dataCode: string,
+ qtyCode:string,
+ qty: number
+): { lower: any; upper: any } => {
+
+
+ const filtered = data.filter((item) => item[dataCode] === fctCd);
+
+ const lowers = filtered.filter((item) => Number(item[qtyCode]) <= qty);
+ const uppers = filtered.filter((item) => Number(item[qtyCode]) > qty);
+
+ const lower =
+ lowers.length > 0
+ ? lowers.reduce((acc, curr) =>
+ Number(curr[qtyCode]) > Number(acc[qtyCode]) ? curr : acc
+ )
+ : undefined;
+
+ const upper =
+ uppers.length > 0
+ ? uppers.reduce((acc, curr) =>
+ Number(curr[qtyCode]) < Number(acc[qtyCode]) ? curr : acc
+ )
+ : undefined;
+
+ // ✅ 바운더리 하나만 있을 경우 대체 처리
+ if (!lower && upper) return { lower: upper, upper };
+ if (!upper && lower) return { lower, upper: lower };
+
+ // ✅ 정상 보간 구간
+ if (lower && upper) return { lower, upper };
+
+ // ❌ 둘 다 없을 경우 (fctCd 필터 결과가 없음)
+ throw new Error(`No matching bounds found for fctCd: ${fctCd}, qty: ${qty}`);
+};
+
+
+// (기울기) a = (y2 - y1) / (x2 - x1)
+// (절편) b = y1 - a * x1
+// ↓
+// 결과값 y = a * x + b
+
+
+export const getInterpolation = (
+ Upper: { stdCost: number; fctCpc: number },
+ Lower: { stdCost: number; fctCpc: number },
+ qtyYear: number
+): number => {
+ const x1 = Number(Lower.fctCpc); // 최소 처리 용량
+ const y1 = Number(Lower.stdCost); // 최소 공사비/요율
+ const x2 = Number(Upper.fctCpc); // 최대 처리 용량
+ const y2 = Number(Upper.stdCost); // 최대 공사비/요율
+
+ if (qtyYear <= x1) return y1; // 최소 이하면 y1 반환
+ if (qtyYear >= x2) return y2; // 최대 이상이면 y2 반환
+
+ const slope = (y2 - y1) / (x2 - x1); // 기울기 a
+ const intercept = y1 - slope * x1; // 절편 b
+
+ return slope * qtyYear + intercept; // 보간 계산
+};
+
+export const transformAndInterpolate = (
+ rawData: any,
+ dmndQtyYear: number
+): any => {
+ const result: any = {};
+
+ for (const key in rawData) {
+ const item = rawData[key];
+
+ const range = {
+ Lower: {
+ fctCpc: item.lower?.stdCost,
+ stdCost: item.lower?.rt,
+ },
+ Upper: {
+ fctCpc: item.upper?.stdCost,
+ stdCost: item.upper?.rt,
+ },
+ };
+ result[key] = getInterpolation(range.Upper, range.Lower, dmndQtyYear);
+ }
+
+ return result;
+};
+
+export const getConstFctCode = (fctCd: string) => {
+ const fctMap: { [key: string]: string } = {
+ 총인처리시설: "001",
+ 염소소독: "002",
+ UV소독: "003",
+ 전처리시설: "004",
+ RO: "005",
+ };
+
+ return fctMap[fctCd];
+};
diff --git a/apps/wr/components/lib/func/commom.tsx b/apps/wr/components/lib/func/commom.tsx
index ba0f5c588..e5dfc8c0c 100644
--- a/apps/wr/components/lib/func/commom.tsx
+++ b/apps/wr/components/lib/func/commom.tsx
@@ -4,6 +4,7 @@ import {
type SelectDataType,
type ReturnType,
filePickedBlobArray,
+ type SheetParameter,
} from "@common/business_components/ui";
import type { RefObject } from "react";
@@ -81,7 +82,7 @@ export const excelDownload = (
export const excelArrayDownload = (
fileNm: string,
sampleFile: string,
- sheetArray: []
+ sheetArray:SheetParameter []
) => {
if (!sheetArray) return;
fetch(`/${sampleFile}`, {}).then(async (response) => {
@@ -110,7 +111,12 @@ export const formatCommaNumber = (
value: number | string | undefined | null
): string => {
if (value === undefined || value === null || value === "") return "";
- return Number(value).toLocaleString();
+ const num = Number(value);
+ // 숫자로 변환할 수 없는 값이 들어올 경우 빈 문자열을 반환하여 예상치 못한 "NaN" 출력을 방지합니다.
+ if (isNaN(num)) {
+ return "";
+ }
+ return num.toLocaleString();
};
export const getCityOrSgg = (ref: RefObject) => {
diff --git a/apps/wr/components/ui/form/coMat/conCostForm/conCostForm.tsx b/apps/wr/components/ui/form/coMat/conCostForm/conCostForm.tsx
index 21746c099..b22f9474e 100644
--- a/apps/wr/components/ui/form/coMat/conCostForm/conCostForm.tsx
+++ b/apps/wr/components/ui/form/coMat/conCostForm/conCostForm.tsx
@@ -6,6 +6,12 @@ import type {
} from "@/app/store/matDmd/coMatRvw/type";
import { TEST_UUID } from "@/app/store/ruseFcltMng/fcltReg/rainReg";
import { formH1Class } from "@/components/lib/class/comClass";
+import {
+ findBounds,
+ getConstFctCode,
+ getInterpolation,
+ transformAndInterpolate,
+} from "@/components/lib/func/calculateConstCost ";
import { ConstCostFeeTable } from "@/components/ui/modal/coMat/constCostFeeTable";
import { RateFeeTableModal } from "@/components/ui/modal/coMat/rateFeeModal";
import {
@@ -17,8 +23,10 @@ import {
} from "@common/business_components/ui";
import PopoverUi from "@common/business_components/ui/popover_ui";
import { Button, Input, Label } from "@common/components/ui";
-import { useEffect, useRef, useState } from "react";
+import type { read } from "fs";
+import { useCallback, useEffect, useRef, useState } from "react";
import { type UseFormReturn } from "react-hook-form";
+import toast from "react-hot-toast";
export default function ConCostForm({
form,
@@ -27,7 +35,14 @@ export default function ConCostForm({
form: UseFormReturn;
type: string;
}) {
- const { coMatRvwUpdate, ruseRvwCalUpdate,getRateFee ,getConstCostFee} = useWrStore((state) => state);
+ const {
+ constCostRes,
+ rateFeeRes,
+ coMatRvwUpdate,
+ ruseRvwCalUpdate,
+ getRateFee,
+ getConstCostFee,
+ } = useWrStore((state) => state);
const ref = useRef(false);
@@ -38,15 +53,7 @@ export default function ConCostForm({
getRateFee(String(currentYear));
ref.current = true;
}
- }, [ref, getConstCostFee ,getRateFee ]);
-
-
- const [isTrfMo, setIsTrfMo] = useState<{
- isModal: boolean;
- }>({ isModal: false });
- const [isCmpttnMo, setIsCmpttnMo] = useState<{
- isModal: boolean;
- }>({ isModal: false });
+ }, [ref, getConstCostFee, getRateFee]);
const zipDowonLoad = () => {
fetch(`/2024_constarctFeeProgram.zip`, {}).then(async (response) => {
@@ -59,25 +66,88 @@ export default function ConCostForm({
link.click();
});
};
+ const usgPrcsProcsWatch = form.watch("demandCst.usgPrcsProcs");
+ const dmndQtyWatch = form.watch("dmndQty");
+ const totalConstCost = form.watch("totalConstCost");
+ const cstrnCst = form.watch("demandCst.cstrnCst");
+ const calculateConstCost = useCallback(() => {
+ const usgPrcsProcs = usgPrcsProcsWatch;
+ const dmndQtyYear = dmndQtyWatch * 365;
+ if (usgPrcsProcs && usgPrcsProcs?.length > 0) {
+ const firstProc = getConstFctCode(usgPrcsProcs?.split("+")[0] || "") || "";
+ const secondProc = getConstFctCode(usgPrcsProcs?.split("+")[1] || "") || "";
+
+ const { lower: firstLower, upper: firstUpper } = findBounds(
+ constCostRes,
+ firstProc || "",
+ 'fctCd',
+ 'fctCpc',
+ Number(dmndQtyYear)
+ );
+ const { lower: secondLower, upper: secondUpper } = findBounds(
+ constCostRes,
+ secondProc || "",
+ 'fctCd',
+ 'fctCpc',
+ Number(dmndQtyYear)
+ );
+
+ const firstConstFee = getInterpolation(
+ firstUpper,
+ firstLower,
+ dmndQtyYear
+ );
+ const secondConstFee = getInterpolation(
+ secondUpper,
+ secondLower,
+ dmndQtyYear
+ );
+ const result = Math.round(firstConstFee + secondConstFee) / 100;
+
+ const groupCodes = ["BD", "CE", "SE", "WD"];
+ const groupedBounds: { [key: string]: { lower?: any; upper?: any } } = {};
+ for (const code of groupCodes) {
+
+ groupedBounds[code] = findBounds(rateFeeRes, code, 'incExpCd', 'stdCost',result);
+ }
+ const resultRate = transformAndInterpolate(groupedBounds, result);
+ const fcltSbsdCstrnCst = (result* (resultRate.BD + resultRate.CE + resultRate.SE + resultRate.WD) / 100);
+ const realResult = result + fcltSbsdCstrnCst;
+
+ form.setValue("demandCst.prcsFcltCpctCstrnCst", Math.round(result) );
+ form.setValue("demandCst.fcltSbsdCstrnCst", Math.round(fcltSbsdCstrnCst)) ;
+ form.setValue("totalConstCost", Math.round(realResult));
+ }
+ }, [constCostRes, rateFeeRes, usgPrcsProcsWatch, dmndQtyWatch]);
const onSubmit = (value: DmdCoReqType) => {
+
+ if( !form.getValues('demandCst.prcsFcltCpctCstrnCst') ){
+ toast.error('공사비 계산 진행 후 저장을 눌러주새요')
+ return
+ }
if (type === "mat") {
const data: DedMatUpdateType = {
dmdInfoSn: form.getValues("dmdInfoSn"),
usgPrcsProcs: form.getValues("demandCst.usgPrcsProcs"),
cstrnCst: form.getValues("demandCst.cstrnCst"),
- fcltSbsdEpsTrf: form.getValues("demandCst.fcltSbsdEpsTrf"),
+ fcltSbsdCstrnCst: form.getValues("demandCst.fcltSbsdCstrnCst"),
prcsFcltCpctCstrnCst: form.getValues("demandCst.prcsFcltCpctCstrnCst"),
rgtr: TEST_UUID,
};
- coMatRvwUpdate("11000SW001R1", form.getValues("dmdInfoFk"), data);
+ coMatRvwUpdate("11000SW001R1", form.getValues("dmdInfoFk"), data);
} else if (type === "hist") {
+
+ delete value.totalConstCost
+ delete value.ruseUtztnFcltNm
+
+
ruseRvwCalUpdate(value);
}
};
useEffect(() => {
- console.log(" form ", form.formState.errors);
+ console.log(" form ", form.formState.errors);
}, [form.formState]);
return (
@@ -90,12 +160,21 @@ export default function ConCostForm({
처리시설 표준공사비 산정
- {}}>
+
계산
-
+
저장
+
+
+ 다운로드
+
기본사항
@@ -111,7 +190,7 @@ export default function ConCostForm({
placeholder=""
type="text"
onChange={(e) => {
- field.onChange((e.target.value));
+ field.onChange(e.target.value);
}}
value={field.value ?? ""}
/>
@@ -194,9 +273,10 @@ export default function ConCostForm({
type="number"
step="0.001"
onChange={(e) => {
- field.onChange(Number(e.target.value));
+ //field.onChange(Number(e.target.value) * 365 );
}}
value={Number(field.value) * 365 || 0}
+ readOnly
/>
)}
@@ -207,14 +287,23 @@ export default function ConCostForm({
-
-
setIsCmpttnMo({ isModal: true })}
- className="bg-none"
- >
- 공사비 산정표 보기
-
+
+
+ >
+ }
+ childrenBody={
+ <>
+ {}}
+ >
+ >
+ }
+ bodyClassName={"w-[40vw] h-full"}
+ >
)}
@@ -236,17 +326,27 @@ export default function ConCostForm({
@@ -323,75 +430,37 @@ export default function ConCostForm({
/>
- (
-
- {
- field.onChange(Number(e.target.value));
- }}
- value={field.value ?? 0}
- />
-
- )}
- />
-
-
- (
-
- )}
- />
-
-
-
-
- 다운로드
-
-
+ (
+
+ {
+ field.onChange(Number(e.target.value));
+ }}
+ value={field.value ?? 0}
+ />
+
+ )}
+ />
+
+