wr: 지도점검결과 중수도 수정

This commit is contained in:
2026-04-09 18:12:09 +09:00
parent c6838839e6
commit c5df40a9ef
6 changed files with 196 additions and 206 deletions
+106 -52
View File
@@ -40,7 +40,6 @@ const codeMApping = {
};
export const getCommonUpCd = async (set: any) => {
try {
let lwCdCode: Record<string, SelectDataType[]> = {};
const upCd = await getFetchWithCount(
fetchType.CS,
"/cms-service/api/v1/up-codes?keyword=&upCd=&cdSe=&useYn=Y&siteId=WR&page=0&size=100&sort=string"
@@ -50,24 +49,9 @@ export const getCommonUpCd = async (set: any) => {
.filter((item: any) => item.upCd.slice(0, 2) === "WR")
.map((cd: any) => cd.upCd);
await Promise.all(
upWrCode.map(async (cd) => {
const mapping = codeMApping[cd as keyof typeof codeMApping];
if (!mapping) return;
await fetchCommonCodesByKeys(upWrCode);
const lwCd = await getFetchWithCount(
fetchType.CS,
`/cms-service/api/v1/lwpo-cds/up-cd/${cd}`
);
const list = Array.isArray(lwCd) ? lwCd : (lwCd.content ?? []);
lwCds[mapping] = list.map((it: any) => ({
text: it.lwpoCdNm,
val: it.lwpoCd,
}));
})
);
lwCdCode = lwCds;
const lwCdCode = lwCds;
set((state: comCodeState) => ({
code: {
...state.code,
@@ -78,6 +62,8 @@ export const getCommonUpCd = async (set: any) => {
pplLenght: lwCdCode["pplLenght"] ?? [],
dmdUszCd: lwCdCode["dmdUszCd"] ?? [],
sewageOutFclttUse: lwCdCode["sewageOutFclttUse"] ?? [],
rainRswtMng: lwCdCode["rainRswtMng"] ?? [],
rainFcltFlowRate: lwCdCode["rainFcltFlowRate"] ?? [],
ruseMngMtd: lwCdCode["ruseMngMtd"] ?? [],
rusePrcsMthdCd: lwCdCode["rusePrcsMthdCd"] ?? [],
erctUswtrPrcsMeth: lwCdCode["erctUswtrPrcsMeth"] ?? [],
@@ -93,6 +79,30 @@ export const getCommonUpCd = async (set: any) => {
console.log("com code error ", e);
}
};
const fetchCommonCodesByKeys = async (keys: string[]) => {
const targets = [...new Set(keys)].filter(
(cd) => Boolean(codeMApping[cd as keyof typeof codeMApping])
);
await Promise.all(
targets.map(async (cd) => {
const mapping = codeMApping[cd as keyof typeof codeMApping];
if (!mapping) return;
const lwCd = await getFetchWithCount(
fetchType.CS,
`/cms-service/api/v1/lwpo-cds/up-cd/${cd}`
);
const list = Array.isArray(lwCd) ? lwCd : (lwCd.content ?? []);
lwCds[mapping] = list.map((it: any) => ({
text: it.lwpoCdNm,
val: it.lwpoCd,
}));
})
);
};
//물재이용 주소 코드: devU01TX0FVVEgyMDI1MDgyNTEwMzkwNDExNjEwNTM=
export const buildingType = {
RST: "RST",
@@ -219,41 +229,42 @@ export const getEnvPartCd = async (set: any) => {
export type comCodeState = {
code: {
isInit: boolean;
chBuCd: SelectDataType[];
rainFcltCd: SelectDataType[];
bdstUsgCd: SelectDataType[];
cityCd: SelectDataType[];
sggCd: SelectDataType[];
rvbsnCd: SelectDataType[];
mdmbsnCd: SelectDataType[];
lgbsnCd: SelectDataType[];
lclgvrnmntCd: EnvPartSelectDataType[];
orgwtKndCd: SelectDataType[];
yn: SelectDataType[];
pplQulity: SelectDataType[];
pplLenght: SelectDataType[];
dmdUszCd: SelectDataType[];
sewageOutFclttUse: SelectDataType[];
isInit: boolean; // 초기화 여부
chBuCd: SelectDataType[]; // 변경사업코드
rainFcltCd: SelectDataType[]; // 빗물시설코드
bdstUsgCd: SelectDataType[]; // 건물용도코드
cityCd: SelectDataType[]; // 시도코드
sggCd: SelectDataType[]; // 시군구코드
rvbsnCd: SelectDataType[]; // 대권역코드
mdmbsnCd: SelectDataType[]; // 중권역코드
lgbsnCd: SelectDataType[]; // 단위유역(대영역)코드
lclgvrnmntCd: EnvPartSelectDataType[]; // 지방환경청코드
orgwtKndCd: SelectDataType[]; // 원수종류코드
yn: SelectDataType[]; // 여부코드
pplQulity: SelectDataType[]; // 관저질
pplLenght: SelectDataType[]; // 관연장
dmdUszCd: SelectDataType[]; // 용도별코드
sewageOutFclttUse: SelectDataType[]; // 하수재이용 장외코드
rainRswtMng: SelectDataType[]; // 운영관리형태코드
rainFcltFlowRate: SelectDataType[]; // 유량측정방법코드
buildingType: {
RST: string;
RNB: string;
HTB: string;
};
ruseMngMtd: SelectDataType[];
ruseSeCd: SelectDataType[];
ruseBizMthdCd: SelectDataType[];
rusePrcsMthdCd: SelectDataType[];
erctUswtrPrcsMeth: SelectDataType[];
bdstFilterYn: SelectDataType[];
bdstIncenYn: SelectDataType[];
bdstGrntchClass: SelectDataType[];
// rswtPrscCdMthdCd: SelectDataType[];
htdPowerMthdCd: SelectDataType[];
htdUtztnUsgCd: SelectDataType[];
rswtBdstType: SelectDataType[];
bdstTotalUsgType: SelectDataType[];
userSiSggCd: string;
RST: string; // 중수도시설 구분
RNB: string; // 빗물이용시설 구분
HTB: string; // 온배수시설 구분
}; // 시설구분
ruseMngMtd: SelectDataType[]; // 재이용관리방식코드
ruseSeCd: SelectDataType[]; // 재이용구분코드
ruseBizMthdCd: SelectDataType[]; // 재이용사업방식코드
rusePrcsMthdCd: SelectDataType[]; // 재이용처리공법코드
erctUswtrPrcsMeth: SelectDataType[]; // 하수처리공법코드
bdstFilterYn: SelectDataType[]; // 여과시설여부코드
bdstIncenYn: SelectDataType[]; // 인센티브여부코드
bdstGrntchClass: SelectDataType[]; // 보조금지원대상분류코드
htdPowerMthdCd: SelectDataType[]; // 온배수발전방식코드
htdUtztnUsgCd: SelectDataType[]; // 온배수이용용도코드
rswtBdstType: SelectDataType[]; // 중수도건물유형코드
bdstTotalUsgType: SelectDataType[]; // 전체건물용도유형코드
userSiSggCd: string; // 사용자 시군구코드
};
};
@@ -277,6 +288,8 @@ export const comCodeStateExport: comCodeState = {
yn: yn,
dmdUszCd: lwCds["dmdUszCd"] ?? [],
sewageOutFclttUse: lwCds["sewageOutFclttUse"] ?? [],
rainRswtMng: lwCds["rainRswtMng"] ?? [],
rainFcltFlowRate: lwCds["rainFcltFlowRate"] ?? [],
buildingType: buildingType,
ruseMngMtd: lwCds["ruseMngMtd"] ?? [],
ruseSeCd: ruseSeCd,
@@ -298,10 +311,51 @@ export const comCodeStateExport: comCodeState = {
export type comCodeActions = {
returnCodeText: (val: string, codeName: string) => string;
returnTextCode: (text: string, codeName: string) => string;
getCommonCodesByKeys: (keys: string[]) => Promise<void>;
};
export const codeActionExport: (set: any, get:any) => comCodeActions = (set: any, get:any) => {
return {
getCommonCodesByKeys: async (keys: string[]) => {
try {
await fetchCommonCodesByKeys(keys);
const lwCdCode = lwCds;
set((state: comCodeState) => ({
code: {
...state.code,
rainFcltCd: lwCdCode["rainFcltCd"] ?? state.code.rainFcltCd,
bdstUsgCd: lwCdCode["bdstUsgCd"] ?? state.code.bdstUsgCd,
orgwtKndCd: lwCdCode["orgwtKndCd"] ?? state.code.orgwtKndCd,
pplQulity: lwCdCode["pplQulity"] ?? state.code.pplQulity,
pplLenght: lwCdCode["pplLenght"] ?? state.code.pplLenght,
dmdUszCd: lwCdCode["dmdUszCd"] ?? state.code.dmdUszCd,
sewageOutFclttUse:
lwCdCode["sewageOutFclttUse"] ?? state.code.sewageOutFclttUse,
rainRswtMng: lwCdCode["rainRswtMng"] ?? state.code.rainRswtMng,
rainFcltFlowRate:
lwCdCode["rainFcltFlowRate"] ?? state.code.rainFcltFlowRate,
ruseMngMtd: lwCdCode["ruseMngMtd"] ?? state.code.ruseMngMtd,
rusePrcsMthdCd:
lwCdCode["rusePrcsMthdCd"] ?? state.code.rusePrcsMthdCd,
erctUswtrPrcsMeth:
lwCdCode["erctUswtrPrcsMeth"] ?? state.code.erctUswtrPrcsMeth,
bdstGrntchClass:
lwCdCode["bdstGrntchClass"] ?? state.code.bdstGrntchClass,
htdPowerMthdCd:
lwCdCode["htdPowerMthdCd"] ?? state.code.htdPowerMthdCd,
htdUtztnUsgCd:
lwCdCode["htdUtztnUsgCd"] ?? state.code.htdUtztnUsgCd,
rswtBdstType: lwCdCode["rswtBdstType"] ?? state.code.rswtBdstType,
bdstTotalUsgType:
lwCdCode["bdstUsgCd"]?.concat(lwCdCode["rswtBdstType"] || []) ??
state.code.bdstTotalUsgType,
},
}));
} catch (e) {
console.log("selected common code error ", e);
}
},
returnCodeText: (val: string, codeName: string) => {
const codeList = get().code[codeName] || [];