Merge commit 'e0e2530a56d6047365f0b99bff3110b39c5afe7f' into iipbs/wr/dev
iipbs_wr / build (push) Waiting to run

This commit is contained in:
leedj312
2025-07-09 00:58:57 +09:00
22 changed files with 502 additions and 322 deletions
+34 -18
View File
@@ -71,6 +71,7 @@ export default function CoSttn() {
const getSgg = useCallback((val: string | number) => {
setObjSearch((prev) => ({ ...prev, sgg: String(val) }));
setPageNation(1)
}, []);
useEffect(() => {
@@ -109,18 +110,18 @@ export default function CoSttn() {
}
}, [coSttnRes, code]);
useEffect(() => {
if (coSttn.excelList.length > 0) {
if (coSttn.excelList.length === 0) return;
excelDownload(
coSttn.excelList,
"수요처 관리",
"sample_coSttn.xlsx",
"A1:G1",
2
);
}
}, [coSttn.excelList]);
// useEffect(() => {
// if (coSttn.excelList.length > 0) {
// if (coSttn.excelList.length === 0) return;
// excelDownload(
// coSttn.excelList,
// "수요처 관리",
// "sample_coSttn.xlsx",
// "A1:H1",
// 2
// );
// }
// }, [coSttn.excelList]);
@@ -133,7 +134,7 @@ export default function CoSttn() {
excelData as [],
"수요처 관리",
"sample_coSttn.xlsx",
"A1:F1",
"A1:G1",
2
);
}
@@ -146,12 +147,19 @@ export default function CoSttn() {
if (con) {
if (seartchTxt && seartchTxt?.length > 0) {
coSttnTxtSearch("1", "13", String(con), seartchTxt ?? "");
coSttnTxtSearch(String(pageNation), "13", String(con), seartchTxt ?? "");
} else {
coSttnSearch("1", "13", String(con));
coSttnSearch(String(pageNation), "13", String(con));
}
}
};
useEffect(() =>{
},[pageNation])
return (
<>
<ContentsDiv>
@@ -166,7 +174,10 @@ export default function CoSttn() {
label="시도"
selectClass={""}
selectArray={code.cityCd || []}
onSelectValue={getSelCity}
onSelectValue={(val)=>{
getSelCity(val)
setPageNation(1)
} }
value={objSearch.city}
/>
<SelectBox
@@ -196,7 +207,6 @@ export default function CoSttn() {
size={"sm"}
className={btnClass}
onClick={() => {
setUpdateData(undefined);
setIsDmdModal({ ...isDmdModal, isMoal: true });
}}
@@ -243,7 +253,13 @@ export default function CoSttn() {
cellClick={(index: number | undefined, headId: string) => {
setUpdateData(coSttnRes[index as number]);
}}
onPageChange={setPageNation}
onPageChange={(page) =>{
const con = (objSearch.sgg && objSearch.sgg !== "0") ? objSearch.sgg : objSearch.city;
setPageNation(page)
coSttnSearch( String(page), "13", String(con));
} }
></UiTable>
</ListDiv>
</div>
@@ -38,7 +38,7 @@ export default function Home() {
chgBuilding: chgBuilding[];
}>({ isOpen: false, chgBuilding: [] });
const { htdflRes } = htdfl;
const { htdflRes ,htdflResCount} = htdfl;
useEffect(() => {
if (!htdfl.isInit) {
@@ -101,7 +101,7 @@ export default function Home() {
<SearchFormLeft>
<SearchInput
className="col-span-3 my-7 !text-3xl"
label="건물명"
label="시설명"
textValue={searchTxt || ""}
setText={(e) => {
setSearchTxt(e);
@@ -137,9 +137,9 @@ export default function Home() {
<UiTable
tableData={bdstTable || []}
headlist={htdfl.upHeadList}
pageSize={100}
total={10}
headName={"건축물 목록"}
pageSize={20}
total={htdflResCount}
headName={"시설물 목록"}
cellClick={(val, headId) => {
cellClick(val || undefined, headId);
}}
@@ -29,7 +29,7 @@ export default function Home() {
return state;
}
);
const { rainRes,rainResCount } = rain;
const { rainRes, rainResCount } = rain;
const [rainForm, setRainForm] = useState<customRainBdst>();
const [issNewReg, setIsNewReg] = useState<boolean>(false);
const [pageNation, setPageNation] = useState(1);
@@ -48,26 +48,27 @@ export default function Home() {
}, [rain.isInit, initRain]);
useEffect(() => {
if (code.sggCd.length > 0) {
if (code.sggCd.length > 0) {
if (rainRes && rainRes.length > 0) {
const rainData = tableData(rainRes, { code }).map(
(item: customRainBdst) => {
let archArea =
item?.archArea.split(".")[0] !== "-1"
? item?.archArea.split(".")[0]
: "확인불가";
return {
...item,
archArea: archArea,
if(rainRes&& rainRes.length>0){
bdstChgYn: item.chgBuilding.length > 0 ? "Y" : "N",
};
}
);
const rainData = tableData(rainRes, { code }).map(
(item: customRainBdst) => {
let archArea = item?.archArea.split('.')[0]!=='-1'?item?.archArea.split('.')[0]:'확인불가'
return {
...item,
archArea:archArea,
bdstChgYn: item.chgBuilding.length > 0 ? "Y" : "N",
};
}
);
setbdstTable(rainData);
}else{
setbdstTable([]);
}
setbdstTable(rainData);
} else {
setbdstTable([]);
}
}
}, [code, rainRes]);
const cellClick: (val: number | undefined, headId: string) => void = (
@@ -30,8 +30,10 @@ export default function PbnstSttn() {
pbnSttnInit,
getPbnStnDetail,
pbnNmSearch,
getFlcts
} = useWrStore((state) => state);
const { pbnstSttnRes, fclts,pbnstSttnResCount} =pbnstSttn
const ref = useRef<ReturnType>({} as ReturnType);
const [searchYear, setSearchYear] = useState<string>(
String(new Date().getFullYear())
@@ -48,21 +50,21 @@ export default function PbnstSttn() {
const [pbnRuseNm, setPbnRuseNm] = useState<string>("");
const excelClick = useCallback(() => {
pbnstSttnSearch(true, String(pageNation), "20", ref.current, "", searchYear);
}, [pbnstSttnSearch]);
pbnstSttnSearch(true, String(pageNation), "100000", ref.current, pbnRuseNm, searchYear,fclts );
}, [pbnstSttnSearch,fclts,pbnRuseNm]);
const cellCLick = useCallback(
(index: number | undefined) => {
if (
index !== undefined &&
pbnstSttn.pbnstSttnRes &&
pbnstSttn.pbnstSttnRes[index]
pbnstSttnRes &&
pbnstSttnRes[index]
) {
const pbnstRuseFcltPk = pbnstSttn.pbnstSttnRes[index].pbnstRuseFcltPk;
const pbnstRuseFcltPk = pbnstSttnRes[index].pbnstRuseFcltPk;
getPbnStnDetail(pbnstRuseFcltPk);
}
},
[getPbnStnDetail, pbnstSttn.pbnstSttnRes]
[getPbnStnDetail, pbnstSttnRes]
);
useEffect(() => {
@@ -71,31 +73,28 @@ export default function PbnstSttn() {
pbnstSttn.excelList,
"하수재이용시설 현황",
"sample_pbnstSttn.xlsx",
"A1:U2"
"A1:U2",
3
);
}
}, [pbnstSttn.excelList]);
useEffect(() => {
if (!pbnstSttn.isInit) {
pbnSttnInit("1", "20", ref.current, searchYear);
getFlcts()
}
}, [pbnstSttn.isInit, pbnSttnInit, ref.current]);
useEffect(() => {
setBdstTable(pbnstSttn.pbnstSttnRes);
}, [pbnstSttn.pbnstSttnRes]);
if(pbnstSttnRes && pbnstSttnRes.length>0) {
setBdstTable(pbnstSttnRes);
}else{
setBdstTable([]);
}
}, [pbnstSttnRes]);
// useEffect(() => {
// pbnstSttnSearch("1", "20", ref.current, pbnRuseNm, searchYear);
// }, [pageNation, ref.current, pbnRuseNm, searchYear, pbnstSttnSearch]);
// useEffect(() => {
// if (pbnRuseNm.length > 1)
// pbnNmSearch(String(pageNation), "23", ref.current, pbnRuseNm, searchYear);
// }, [pbnRuseNm,pageNation]);
useEffect(() => {
pbnstSttnSearch(false, String(pageNation), "20", returnType, pbnRuseNm, searchYear);
}, [pageNation]);
useEffect(() =>{
pbnSttnInit("1", "15", ref.current, searchYear, pbnstSttn.fclts);
},[fclts])
useEffect(() => {
if (pbnstSttn.pbnstDetail.pbnstRuseFcltPk)
@@ -157,12 +156,14 @@ export default function PbnstSttn() {
</div>
}
queryClick={function (returnType: ReturnType): void {
console.log("시군구코드", returnType)
setReturnType(returnType);
pbnstSttnSearch(false, "1", "20", returnType, pbnRuseNm, searchYear);
pbnstSttnSearch(false, "1", "15", returnType, pbnRuseNm, searchYear, fclts);
}}
excelClick={excelClick}
initClick={function (): void { }}
initClick={function (): void {
setPbnRuseNm('')
}}
btnClass={btnClass}
ref={ref}
isAdmin={false}
@@ -179,8 +180,8 @@ export default function PbnstSttn() {
<HeadMakeColSpan upHeadList={pbnstSttn.pbnstSttNodeList} />
}
headlist={pbnstSttn.pbnstSttHeadList}
pageSize={20}
total={100000}
pageSize={15}
total={pbnstSttnResCount}
cellClick={(index: number | undefined, headId: string) => {
cellCLick(index);
}}
@@ -188,10 +189,11 @@ export default function PbnstSttn() {
pbnstSttnSearch(
false,
String(page),
String(20),
String(15),
ref.current,
pbnRuseNm,
searchYear
searchYear,
fclts
);
}}
></UiTable>
@@ -37,7 +37,6 @@ import {
type PrfType,
} from "@/app/store/prfmncReg/pbnstPrfmncReg/type";
import { excelToPbnPrfData } from "@/app/store/prfmncReg/pbnstPrfmncReg/excel";
import data from "@common/components/ui/icon-finder/data";
export default function prfmncPrfmncReg() {
const { code, prfmnc, prfmncHasuInit, prfmnRegData } = useWrStore(
@@ -169,7 +168,12 @@ export default function prfmncPrfmncReg() {
}
}, [prfmnc.isInit, prfmncHasuInit]);
useEffect(() => {
setbdstTable(prfmncRes);
if(prfmncRes&&prfmncRes.length>0){
setbdstTable(prfmncRes);
}
// cellNum이 0일 경우(첫 번째 행)도 유효한 인덱스이므로 undefined 여부만 체크합니다.
if (cellNum !== undefined) {
+8
View File
@@ -3,6 +3,11 @@ import type { EnvPartSelectDataType, SelectDataType } from "@common/business_com
import { bdstFilterYn, bdstGrntchClass, bdstIncenYn, bdstUsgCd, chBuCd, dmdUszCd, erctUswtrPrcsMeth, htdPowerMthdCd, htdUtztnUsgCd, orgwtKndCd, pplLenght, pplQulity, rainFcltCd, rswtPrscCdMthdCd, ruseBizMthdCd, ruseMngMtd, rusePrcsMthdCd, ruseSeCd, yn } from "./basicCode";
export const btnClass = "p-4 m-2 text-white rounded-sm text-lg font-medium "
const laeSecd = '41'
const ogdpSeCd = '0'
export const buildingType = {
RST:"RST",
RNB:"RNB",
@@ -167,6 +172,8 @@ export type comCodeState = {
rswtPrscCdMthdCd:SelectDataType[];
htdPowerMthdCd:SelectDataType[]
htdUtztnUsgCd:SelectDataType[]
userSiSggCd : string;
};
};
@@ -203,6 +210,7 @@ export const comCodeStateExport: comCodeState = {
rswtPrscCdMthdCd:rswtPrscCdMthdCd,
htdPowerMthdCd:htdPowerMthdCd,
htdUtztnUsgCd:htdUtztnUsgCd,
userSiSggCd:laeSecd,
},
};
@@ -2,7 +2,6 @@ import moment from "moment";
export const excelCoSttnParsing = (data: any[]): string[][] => {
const excelExportData: string[][] = [];
data.forEach((item) => {
excelExportData.push([
String(item.cityText)??'',
@@ -87,9 +87,6 @@ export const buildingToExcelType = (
export const excelToRainChkData = (excelData: any, year: string) => {
const errors: string[] = [];
const rainChkgdData: rainChkZodType[] = excelData.map((item: any) => {
console.log('item ', item)
if (item["점검일"] !== undefined) {
const checkYmd = item["점검일"].replace(/\./g, "")
let vltnDt = item["과태료 부과일(위반일)"]
@@ -110,7 +107,6 @@ export const excelToRainChkData = (excelData: any, year: string) => {
flg: "RNB",
};
});
return {
bdstNm:item["시설명"] ?? "",
bdstRuseFcltFk: Number(item["NO"]),
@@ -138,64 +134,67 @@ export const excelToRainChkData = (excelData: any, year: string) => {
}
}).filter((el: any) => el !== undefined);
// ✨ 오류 검사 - 가공된 데이터 기준
const isInvalidNumber = (val: any) =>
val !== undefined && val !== null && val !== "" && isNaN(Number(val));
return rainChkgdData;
// // ✨ 오류 검사 - 가공된 데이터 기준
// const isInvalidNumber = (val: any) =>
// val !== undefined && val !== null && val !== "" && isNaN(Number(val));
const isInvalidDate = (val: any) =>
typeof val === "string" && !/^\d{4}\.\d{2}\.\d{2}$/.test(val.trim());
// const isInvalidDate = (val: any) =>
// typeof val === "string" && !/^\d{4}\.\d{2}\.\d{2}$/.test(val.trim());
const buildErrorMessage = (item: any, issues: string[]): string => {
const 시설명 = item.bdstNm ?? "";
const 점검일 = item.chckYmd ?? "";
const 이용용도 = item.utztnUsgCd ?? "";
return `시설명: ${시설명}, 점검일: ${점검일}, 이용용도: ${이용용도} (=> ${issues.join(", ")})`;
};
// const buildErrorMessage = (item: any, issues: string[]): string => {
// const 시설명 = item.bdstNm ?? "";
// const 점검일 = item.chckYmd ?? "";
// const 이용용도 = item.utztnUsgCd ?? "";
// return `시설명: ${시설명}, 점검일: ${점검일}, 이용용도: ${이용용도} (=> ${issues.join(", ")})`;
// };
if (rainChkgdData.length > 0) {
rainChkgdData.forEach((rain: any) => {
const item = rain.__origin; // 원본 item
const issues: string[] = [];
// if (rainChkgdData.length > 0) {
// rainChkgdData.forEach((rain: any) => {
// const item = rain.__origin; // 원본 item
// const issues: string[] = [];
if (rain.chckYmd && isInvalidDate(rain.chckYmd)) {
issues.push(`점검일: 날짜 형식 아님 (${rain.chckYmd})`);
}
// if (rain.chckYmd && isInvalidDate(rain.chckYmd)) {
// issues.push(`점검일: 날짜 형식 아님 (${rain.chckYmd})`);
// }
if (rain.vltnDt && isInvalidDate(rain.vltnDt)) {
issues.push(`과태료 부과일(위반일): 날짜 형식 아님 (${rain.vltnDt})`);
}
// if (rain.vltnDt && isInvalidDate(rain.vltnDt)) {
// issues.push(`과태료 부과일(위반일): 날짜 형식 아님 (${rain.vltnDt})`);
// }
// [
// "연간운영비(원/년)", "PH", "탁도", "총대장균군수", "과태료부과금액(천원)"
// ].forEach((key) => {
// if (isInvalidNumber(item[key])) {
// issues.push(`${key}: 숫자 형식 아님 (${item[key]})`);
// }
// }
// // [
// // "연간운영비(원/년)", "PH", "탁도", "총대장균군수", "과태료부과금액(천원)"
// // ].forEach((key) => {
// // if (isInvalidNumber(item[key])) {
// // issues.push(`${key}: 숫자 형식 아님 (${item[key]})`);
// // }
// // }
// );
// // );
for (let i = 1; i <= 12; i++) {
const month = `${i}월`;
if (isInvalidNumber(item[`대체_${month}`])) {
issues.push(`대체_${month}: 숫자 형식 아님 (${item[`대체_${month}`]})`);
}
if (isInvalidNumber(item[`빗물_${month}`])) {
issues.push(`빗물_${month}: 숫자 형식 아님 (${item[`빗물_${month}`]})`);
}
}
// for (let i = 1; i <= 12; i++) {
// const month = `${i}월`;
// if (isInvalidNumber(item[`대체_${month}`])) {
// issues.push(`대체_${month}: 숫자 형식 아님 (${item[`대체_${month}`]})`);
// }
// if (isInvalidNumber(item[`빗물_${month}`])) {
// issues.push(`빗물_${month}: 숫자 형식 아님 (${item[`빗물_${month}`]})`);
// }
// }
if (issues.length > 0) {
errors.push(buildErrorMessage(item, issues));
}
});
}
// if (issues.length > 0) {
// errors.push(buildErrorMessage(item, issues));
// }
// });
// }
if (errors.length > 0) {
return { rainChkgdData: [], errors };
}
// if (errors.length > 0) {
// return { rainChkgdData: [], errors };
// }
return { rainChkgdData, errors: [] };
// return { rainChkgdData, errors: [] };
return rainChkgdData;
};
@@ -68,7 +68,7 @@ const hasuListFetch = async (page: number, sggOrCity: string) => {
prfList: data.prfList,
});
}
});
}).filter(Boolean); // undefined 값을 제거합니다.
return findData;
};
@@ -177,7 +177,7 @@ export const htdflFacActionsExport: (set: any) => htdflFacSActions = (
if (res.status) {
toast.success("온배수 건축물 수정이 완료되었습니다.");
}
const htdflRes = await getFetch(
const htdflRes = await getFetchWithCount(
"wr",
`/drain/facilityList/1/10/${code}`
);
@@ -7,7 +7,7 @@ export const pubFacHeadListExport: TableUpperProps[] = [
{ id: "bscFctNm", title: "시설명" },
{ id: "addr", title: "위치" },
{ id: "efflWqltStndrdNm", title: "지역구분" },
{ id: "fctCpc", title: "시설용량" },
{ id: "fctCpc", title: "시설용량(m³/일)" },
{ id: "ruse", title: "재이용여부" },
{ id: "rswtrYn", title: "등록여부" },
];
@@ -28,8 +28,8 @@ const rainyObjSchema = z.object({
export const rainZod = z.object({
bdstInfoPk: z.number().optional(),
ctpvCd: z.number().default(0),
sggCd: z.number().default(0),
ctpvCd: z.number().optional(),
sggCd: z.number().optional(),
daddr: z.string().default(""),
bdstNm: z.string().default(""),
frstArchPrmsnDt: z.date().default(() => new Date()),
@@ -83,6 +83,7 @@ type rainFacSActions = {
rainSearch: (txt:string,pageNation:number,code:string|number) => void;
rainBdstReg: (data: customRainBdst, code:string|number) => void;
rainBdstUpdate: (data: customRainBdst, code:string|number) => void;
};
export type rainFacType = rainFacState & rainFacSActions;
@@ -11,7 +11,10 @@ export const baseReuseBuildingSchema = z.object({
bdstRuseFcltPk: z.number().nullish(),
bdstInfoFk: z.number().nullish(),
instlCmptnDt: z.coerce.date().default(() => new Date()),
instlCst: z.number().nullish(),
instlCst: z
.number()
.max(9_999_999, { message: "최대 9,999,999까지 입력 가능합니다." })
.nullish(),
operMngCd: z.string().optional().default(""),
anlOperCst: z.number().default(0),
instlCstSprtYn: z.string().default("Y"),
@@ -30,8 +30,8 @@ import toast from "react-hot-toast";
export const rswtZod = z.object({
bdstInfoPk: z.number().nullish(),
ctpvCd: z.number().default(0),
sggCd: z.number().default(0),
ctpvCd: z.number(),
sggCd: z.number(),
daddr: z.string().default(""),
bdstNm: z.string().default(""),
frstArchPrmsnDt: z.date().default(() => new Date()),
@@ -182,7 +182,7 @@ export const rswtFacActionsExport: (set: any) => rswtFacSActions = (
const chData = await makeRstr(data);
const res = await postFectch("/reuseFc/waterreuseFc", chData);
if (res.status===200) {
if(data.chgBuilding.length > 0){
if(data.chgBuilding ){
const chPK = res?.data?.bdstInfoPk
const makeCh= res.data.chgBuilding.map((item: chgBuilding) =>
@@ -13,15 +13,19 @@ export const excelPbnstSttnParsing = (data: any[]): string[][] => {
String(item.gugun ?? ""),
String(item.bscFctNm ?? ""),
String(item.efflWqltStndrdNm ?? ""),
String(item.fctCpc ?? ""),
String(item.tel ?? ""),
String(item.fctCpc ?? ""),
String(item.ruseUtztnFcltNm ?? ""),
String(item.fcltCpct ?? ""),
String(item.splyExtraCpct ?? ""),
String(item.ruseCpct ?? ""),
String(item.usageTotal ?? ""),
String(item.inUsage ?? ""),
String(item.outUsage ?? ""),
String(item.outUsage ?? ""),
String(item.operMthd ?? ""),
String(item.rprtvBzenty ?? ""),
String(item.bgngDt ?? ""),
String(item.endDt ?? ""),
])
})
return excelExportData;
@@ -1,5 +1,5 @@
import type { CommonTableProps, TableUpperProps } from "@/app/store/common/type/header";
import type { z } from "zod";
import { any, type z } from "zod";
import { pbnSttHeadListExport, pbnstSttNodeListExport, ruseDmdHeadListExport, ruseFcltHeadListExport, ruseFcltNodeListExport, ruseGuranteeHeadListExport, rusePplHeadListExport, ruseSplyHeadListExport } from "./headList";
import { fetchType, getFetch, postFectch } from "@/components/lib/api";
import { controlHeadView } from "../rainSttn";
@@ -27,7 +27,9 @@ export type pbnstSttnState = {
ruseGuranteeHeadList: TableUpperProps[]
ruseDmdHeadList: TableUpperProps[]
ruseFcltHeadList: TableUpperProps[]
pbnstSttnResCount:number;
excelList: [];
fclts:string[]
isInit: boolean;
};
};
@@ -41,12 +43,15 @@ type pbnstSttnActions = {
reurnValue: ReturnType,
searchNm: string | undefined,
year: string,
fclts:string[]
) => void;
getFlcts:()=>void;
pbnSttnInit: (
page: string,
total: string,
reurnValue: ReturnType,
year: string
year: string,
flcts:string[]
) => void;
getPbnStnDetail: (pbnstRuseFcltPk: string) => void;
pbnNmSearch: (
@@ -71,9 +76,11 @@ export const pbnstSttnStateExport: pbnstSttnState = {
ruseDmdHeadList: ruseDmdHeadListExport,
ruseFcltHeadList: ruseFcltHeadListExport,
pbnstSttnRes: [],
pbnstSttnResCount:1,
pbnstDetail: {} as customPbnst,
pbnstSearchData: [],
excelList: [],
fclts:[],
isInit: false,
},
};
@@ -83,105 +90,112 @@ const hasuListFetch = async (
total: string,
reurnValue: ReturnType,
searchNm: string | undefined,
year: string
year: string,
flcts:string[]
) => {
let url = `/prcsFclt/ruseInfo/`;
let url = "";
if (reurnValue.partValue === "A") {
url = `/prcsFclt/info/${page}/${total}/${reurnValue.partValue}/${
url+=`${page}/${total}/${reurnValue.partValue}/${
// reurnValue.sidoValue ? reurnValue.sidoValue : reurnValue.sigunValue
reurnValue.sigunValue !== '0' ? reurnValue.sigunValue : reurnValue.sidoValue
}/0/1/SW`
} else if (reurnValue.partValue === "R") {
url = `/prcsFclt/info/${page}/${total}/${reurnValue.partValue}/${reurnValue.regionValue
url += `${page}/${total}/${reurnValue.partValue}/${reurnValue.regionValue
? reurnValue.regionValue
: reurnValue.unitWaterShedValue
? reurnValue.unitWaterShedValue
: reurnValue.middleRegionValue
}/0/1/SW`
} else {
url = `/prcsFclt/info/${page}/${total}/${reurnValue.envPartValue}/${reurnValue.sidoValue ? reurnValue.sidoValue : reurnValue.sigunValue}/0/1/SW`
} else if( reurnValue.partValue === 'G'){
console.log('reurnValue.sigunValue ', reurnValue.sidoValue)
console.log('reurnValue.sigunValue ', reurnValue.sigunValue)
url += `${page}/${total}/${reurnValue.envPartValue}/${reurnValue.sigunValue !== '0' ? reurnValue.sigunValue : reurnValue.sidoValue}/0/1/SW`
}else{
url += `1/2/A/0/0/1/SW`
}
if (searchNm && searchNm?.length > 0) {
url += "/" + searchNm
}
console.log("주소", url)
const pbnList = await getFetch(fetchType.COMMON, url);
console.log("pbnList", pbnList)
const arrayList = pbnList.map((item: pubHasuType) => item.bscFctCd);
console.log("어레이리스트", arrayList)
const pbnList = await postFectch(url, flcts,fetchType.COMMON);
const getRuseList = await postFectch(
`/reuseFc/pubDetailList/${year}`,
arrayList,
flcts,
fetchType.WR
);
console.log("getRuseList", getRuseList)
const checkWrRegListRes = getRuseList.data;
const count = getRuseList.count;
const data: WaterReuseFacility[] = checkWrRegListRes.map(
(item: FcPrfType) => {
const findData = pbnList.find(
const findData = pbnList.data.find(
(fclt: pubHasuType) =>
fclt.bscFctCd === item.pbnstRuseFcltPk.substring(0, 11)
);
if(findData){
const usage = item.prfList.reduce(
(acc, cur) => {
acc.inUsage +=
cur.wshwtr +
cur.coolUswtr +
cur.cleanUswtr +
cur.drwtUswtr +
cur.dltnUswtr +
cur.ithlRswtr +
cur.ithlEtcUswtr +
cur.cleanToilUswtr +
cur.resn;
acc.outUsage +=
cur.lndwtr +
cur.hydUswtr +
cur.ugwtChr +
cur.farmUswtr +
cur.rvrKeepUswtr +
cur.indstUswtr;
acc.total = acc.inUsage + acc.outUsage;
const usage = item.prfList.reduce(
(acc, cur) => {
acc.inUsage +=
cur.wshwtr +
cur.coolUswtr +
cur.cleanUswtr +
cur.drwtUswtr +
cur.dltnUswtr +
cur.ithlRswtr +
cur.ithlEtcUswtr +
cur.cleanToilUswtr +
cur.resn;
acc.outUsage +=
cur.lndwtr +
cur.hydUswtr +
cur.ugwtChr +
cur.farmUswtr +
cur.rvrKeepUswtr +
cur.indstUswtr;
acc.total = acc.inUsage + acc.outUsage;
return acc;
},
{ total: 0, inUsage: 0, outUsage: 0 }
);
return {
rvbsn: findData?.rvbsn ||'-',
lgbsn: findData?.lgbsn||'-',
mdmbsn: findData?.mdmbsn||'-',
rgnNm: findData?.rgnNm||'-',
sido: findData?.sido||'-',
gugun: findData?.gugun||'-',
bscFctNm: findData?.bscFctNm||'-',
efflWqltStndrdNm: findData?.efflWqltStndrdNm||'-',
fctCpc: Number(findData?.fctCpc)||0,
tel: findData?.tel ?? "-",
ruseUtztnFcltNm: item?.ruseUtztnFcltNm||'-',
fcltCpct: item?.fcltCpct||'-',
splyExtraCpct: item?.splyExtraCpct||'-',
ruseCpct: item?.ruseCpct||'-',
pbnstRuseFcltPk: item.pbnstRuseFcltPk||'-',
usageTotal: usage?.total,
inUsage: usage?.inUsage,
outUsage: usage?.outUsage,
operMthd: item.operList[0]?.operMthd||'-',
rprtvBzenty: item.operList[0]?.rprtvBzenty,
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 ?? []
};
}
return acc;
},
{ total: 0, inUsage: 0, outUsage: 0 }
);
return {
rvbsn: findData?.rvbsn,
lgbsn: findData?.lgbsn,
mdmbsn: findData?.mdmbsn,
rgnNm: findData?.rgnNm,
sido: findData?.sido,
gugun: findData?.gugun,
bscFctNm: findData?.bscFctNm,
efflWqltStndrdNm: findData?.efflWqltStndrdNm,
fctCpc: findData.fctCpc,
tel: findData?.tel ?? "-",
ruseUtztnFcltNm: item.ruseUtztnFcltNm,
fcltCpct: item.fcltCpct,
splyExtraCpct: item.splyExtraCpct,
ruseCpct: item.ruseCpct,
pbnstRuseFcltPk: item.pbnstRuseFcltPk,
usageTotal: usage.total,
inUsage: usage.inUsage,
outUsage: usage.outUsage,
operMthd: item.operList[0]?.operMthd,
rprtvBzenty: item.operList[0]?.rprtvBzenty,
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 ?? []
};
}
);
).filter(Boolean);
return data;
};
@@ -189,6 +203,15 @@ export const pbnstSttnActionsExport: (set: any) => pbnstSttnActions = (
set: any
) => {
return {
getFlcts:async ()=>{
const fclts= await getFetch(fetchType.WR,'/reuseFc/pubFc')
return set((state: pbnstSttnState) => ({
pbnstSttn: {
...state.pbnstSttn,
fclts:fclts
},
}));
},
pbnstChSttnHead: async (
headList: z.infer<typeof sttnHeadListType>
): Promise<void> => {
@@ -209,22 +232,23 @@ export const pbnstSttnActionsExport: (set: any) => pbnstSttnActions = (
reurnValue: ReturnType,
searchNm: string | undefined,
year: string,
fclts:string[]
) => {
try {
console.log("여기")
const pbnstSttnRes = await hasuListFetch(
page,
total,
reurnValue,
searchNm,
year
year,
fclts,
);
console.log("pbnstSttnRes", pbnstSttnRes);
// if (Number(total) > 9000) {
if (isExcel) {
const pbnstExcel = excelPbnstSttnParsing(pbnstSttnRes);
set((state: pbnstSttnState) => {
return {
...state,
@@ -234,43 +258,48 @@ export const pbnstSttnActionsExport: (set: any) => pbnstSttnActions = (
},
};
});
} else
} else{
set((state: pbnstSttnState) => {
return {
...state,
pbnstSttn: {
...state.pbnstSttn,
pbnstSttnRes: pbnstSttnRes,
isInit: false,
pbnstSttnResCount:pbnstSttnRes.length
// isInit: false,
},
};
});
}
} catch (erTxt) {
console.log("error", erTxt);
}
},
pbnSttnInit: async (
pbnSttnInit: async(
page: string,
total: string,
reurnValue: ReturnType,
year: string
year: string,
fclts:string[]
) => {
try {
const pbnstSttnRes = await hasuListFetch(
page,
total,
reurnValue,
undefined,
year
);
page,
total,
reurnValue,
undefined,
year,
fclts
);
set((state: pbnstSttnState) => {
set( (state: pbnstSttnState) => {
return {
...state,
pbnstSttn: {
...state.pbnstSttn,
pbnstSttnRes: pbnstSttnRes,
pbnstSttnResCount:pbnstSttnRes.length,
isInit: false,
},
};
@@ -321,6 +350,7 @@ export const pbnstSttnActionsExport: (set: any) => pbnstSttnActions = (
pbnstSttn: {
...state.pbnstSttn,
pbnstSearchData: pbnstSttnRes,
pbnstSttnResCount:pbnstSttnRes.length,
},
};
});
@@ -24,6 +24,10 @@ export default function BdstReg({ form, type }: { form: any; type?: string }) {
return state;
});
const {userSiSggCd } =code
const [useCityCd, setUserCityCd] = useState<SelectDataType[]>([])
const [useSggCd, setUserSggCd] = useState<SelectDataType[]>([])
const { fields, append, remove } = useFieldArray({
name: "chgBuilding",
control: form?.control, // Provide a fallback to avoid errors
@@ -52,6 +56,33 @@ export default function BdstReg({ form, type }: { form: any; type?: string }) {
city: "",
});
useEffect(() =>{
if(userSiSggCd.length===2 && code.cityCd.length>0){
const city = code.cityCd.filter((item) => item.val === userSiSggCd)
const sgg = code.sggCd.filter((item) => item.val.slice(0,2) === userSiSggCd )
sgg.unshift({text:'전체' , val:'0'})
setUserCityCd(city) // Fix: Ensure city is of type SelectDataType[]
setUserSggCd(sgg)
if (city[0]?.val) {
// 여기 중요
queueMicrotask(() => {
form.setValue("ctpvCd", Number(city[0]?.val), { shouldDirty: true, shouldTouch: true, shouldValidate: true });
});
}
}else if(userSiSggCd.length===5 && code.cityCd.length>0 && code.sggCd.length>0) {
const city = code.cityCd.filter((item) => item.val === userSiSggCd.slice(0,2))
const sgg = code.sggCd.filter((item) => item.val === userSiSggCd)
setUserSggCd(sgg)
setUserCityCd(city)
form.setValue('ctpvCd',Number(city[0]?.val) )
form.setValue('sggCd',Number(sgg[0]?.val) )
}
},[form, userSiSggCd, code.cityCd, code.sggCd])
const getSelCity = (val: string) => {
const data = getCity(val, code.sggCd);
setSelectSgg(data);
@@ -87,6 +118,12 @@ export default function BdstReg({ form, type }: { form: any; type?: string }) {
);
};
useEffect(() =>{
console.log('form.formState ', form.watch())
},[form.formState])
return (
<>
<h1 className={formH1Class}> { type !== "HTB"?"건축물 기본 정보": '시설 기본 정보'}</h1>
@@ -101,12 +138,11 @@ export default function BdstReg({ form, type }: { form: any; type?: string }) {
className="col-span-3"
label={""}
selectClass={selectClass}
selectArray={code.cityCd}
selectArray={useCityCd}
onSelectValue={(val) => {
getSelCity(String(val));
field.onChange(Number(val));
}}
value={field.value}
value={typeof field.value !== "undefined" ? field.value : useCityCd[0]?.val}
/>
</FormUi>
)}
@@ -122,9 +158,8 @@ export default function BdstReg({ form, type }: { form: any; type?: string }) {
className="col-span-3"
label={""}
selectClass={`w-full min-h-[2.9rem] ${selectClass}`}
selectArray={selectSgg ? selectSgg : code.sggCd || []}
selectArray={useSggCd}
onSelectValue={(val) => {
getSgg(val);
field.onChange(Number(val));
}}
value={field.value}
@@ -61,7 +61,7 @@ export default function HtdflRegForm({
if (setIsModal) setIsModal(false);
} else {
htdflBdstUpdate(values, "41");
htdflBdstUpdate(values, "0");
}
};
@@ -39,7 +39,7 @@ export default function RainRegForm({
const defaultValues: z.infer<typeof rainZod> = rainZod.parse({});
const form = useForm<z.infer<typeof rainZod>>({
resolver: zodResolver(rainZod),
defaultValues: defaultValues,
// defaultValues: defaultValues,
});
const instlCst = form.watch(`reuseBuilding.0.instlCst`);
@@ -41,11 +41,11 @@ export default function RswtrRegForm({
(state) => state
);
const defaultValues: z.infer<typeof rswtZod> = rswtZod.parse({});
// const defaultValues: z.infer<typeof rswtZod> = rswtZod.parse({});
const form = useForm<z.infer<typeof rswtZod>>({
resolver: zodResolver(rswtZod),
defaultValues: defaultValues,
// defaultValues: defaultValues,
});
const [grntchBdstCertYn, instlCstSprtYn, filtrTrtmfctProcs] = form.watch([
@@ -71,22 +71,26 @@ export default function ChkgdExcel({ type,setIsRegExcel }: { type: string, setI
if (file)
if (type === "RNB") {
filePicked(file, 0).then((res) => {
if (res !== undefined){
// if (res !== undefined){
const excelData = excelToRainChkData(res, form.getValues("chckYr"))
if( excelData&&excelData.errors.length>0){
const excelData = excelToRainChkData(res, form.getValues("chckYr"))
if(res !== undefined)
setExcelData(excelData)
// if( excelData&&excelData.errors.length>0){
excelData.errors.forEach((err) =>{
toast.error(err)
})
}else{
// excelData.errors.forEach((err) =>{
// toast.error(err)
// })
// }else{
setExcelData(excelData.rainChkgdData)
}
}
// }
// }
});
})
} else if (type === "RST") {
filePickedArray(file, 0).then((res) => {
if (res && res?.length > 1) {
@@ -4,7 +4,12 @@ import {
selectClass,
type customRainBdst,
} from "@/app/store/ruseFcltMng/fcltReg/rainReg";
import { ScrollArea, SelectBox, UiTable, type SelectDataType } from "@common/business_components";
import {
ScrollArea,
SelectBox,
UiTable,
type SelectDataType,
} from "@common/business_components";
import { Button, Input, Label } from "@common/components";
import { useEffect, useState } from "react";
import { getCity, tableData } from "@/components/lib/func/commom";
@@ -15,83 +20,117 @@ import RswtrRegForm from "@/components/ui/form/fcltReg/rswtrReg/rswtrRegForm";
import HtdflRegForm from "@/components/ui/form/fcltReg/htdflReg/htdflRegForm";
export type objSearchType = {
sgg: string|number;
city: string|number;
};
sgg: string | number;
city: string | number;
};
//RNB(빗물), RST(중수도), HTB(온배수)
type MoType = 'RNB' | 'RST' | 'HTB'; // 여기에 'htdf' 추가
type MoType = "RNB" | "RST" | "HTB"; // 여기에 'htdf' 추가
type BdstTypeMap = {
type BdstTypeMap = {
RNB: customRainBdst;
RST: customRswtBdst;
HTB: customRswtBdst; // 해야해// 아직 아노딤
HTB: customRswtBdst; // 해야해// 아직 아노딤
};
interface BdstRegProps<T extends MoType> {
interface BdstRegProps<T extends MoType> {
moType: T;
isModal:boolean;
isModal: boolean;
siSggCode?: string;
setIsModal?: (open: boolean) => void;
}
export function BdstReg<T extends MoType>({ moType,setIsModal,isModal }: BdstRegProps<T>) {
const { rain, code, bdst,findBdst } = useWrStore((state) => {
export function BdstReg<T extends MoType>({
moType,
setIsModal,
siSggCode,
isModal,
}: BdstRegProps<T>) {
const { rain, code, bdst, findBdst } = useWrStore((state) => {
return state;
});
const { userSiSggCd } = code;
const [bdstTable, setbdstTable] = useState<BdstTypeMap[T][]>();
const [rainBdstForm, setRainBdstForm] = useState<BdstTypeMap[T]>({} as BdstTypeMap[T]);
const [searchTxt, setSearchTxt] = useState<string>()
const [selectSgg, setSelectSgg] = useState<SelectDataType[] | []>()
const [objSearch, setObjSearch] = useState<objSearchType>({sgg:"",city:""});
const [rainBdstForm, setRainBdstForm] = useState<BdstTypeMap[T]>(
{} as BdstTypeMap[T]
);
const [searchTxt, setSearchTxt] = useState<string>();
const [selectSgg, setSelectSgg] = useState<SelectDataType[] | []>();
const [objSearch, setObjSearch] = useState<objSearchType>({
sgg: "",
city: "",
});
const [useCityCd, setUserCityCd] = useState<SelectDataType[]>([]);
const [useSggCd, setUserSggCd] = useState<SelectDataType[]>([]);
const [dataCode, setDataCode] = useState<string>();
const getSelCity = (val: string | number) => {
const cityValue = String(val); // Ensure val is treated as a string
const data = getCity(cityValue, code.sggCd);
const searchBdst = (searchTxt: string | undefined) => {
let data = objSearch.city;
setSelectSgg(data);
// getSgg(data[0]?.val || "");
setObjSearch({ city: cityValue, sgg: '' });
if (objSearch.sgg !== "" && objSearch.sgg !== "0") {
data = objSearch.sgg;
}
//RNB(빗물), RST(중수도), HTB(온배수)
findBdst(String(data), searchTxt || "", moType);
};
const getSgg = (val: string | number) => {
setObjSearch({...objSearch,sgg: String(val)})
};
const searchBdst=(searchTxt: string | undefined)=>{
let data =objSearch.city;
if(objSearch.city==="" ){
data = String(code.cityCd[0]?.val)
}
if(objSearch.sgg !=="" ){
data = objSearch.sgg
}
//RNB(빗물), RST(중수도), HTB(온배수)
findBdst(String(data), searchTxt || "",moType )
}
useEffect(() => {
if (code.sggCd.length > 0) {
setbdstTable( tableData(bdst.bdstBase, { code }));
}
}, [ bdst]);
const bdstData = bdst.bdstBase.map((bdst) => {
let archArea =
bdst?.archArea.split(".")[0] !== "-1"
? bdst?.archArea.split(".")[0]
: "확인불가";
return {
...bdst,
archArea: archArea,
};
});
setbdstTable(tableData(bdstData, { code }));
}
}, [bdst]);
useEffect(() => {
if (userSiSggCd.length === 2 && code.cityCd.length > 0) {
const city = code.cityCd.filter((item) => item.val === userSiSggCd);
const sgg = code.sggCd.filter(
(item) => item.val.slice(0, 2) === userSiSggCd
);
sgg.unshift({ text: "전체", val: "0" });
setUserCityCd(city); // Fix: Ensure city is of type SelectDataType[]
setObjSearch({ ...objSearch, city: String(city[0]?.val) });
setUserSggCd(sgg);
} else if (
userSiSggCd.length === 5 &&
code.cityCd.length > 0 &&
code.sggCd.length > 0
) {
const city = code.cityCd.filter(
(item) => item.val === userSiSggCd.slice(0, 2)
);
setUserCityCd(city);
const sgg = code.sggCd.filter((item) => item.val === userSiSggCd);
setUserSggCd(sgg);
setObjSearch({ city: String(city[0]?.val), sgg: String(sgg[0]?.val) });
}
}, [userSiSggCd, code.cityCd, code.sggCd]);
const tableClick: (val: number | undefined , headId:string) => void = (val ,headId) => {
if(val!==undefined && bdst?.bdstBase.length>0){
const data:BdstTypeMap[T] =bdst?.bdstBase[val]
if (data) {
setRainBdstForm(data);
}
const tableClick: (val: number | undefined, headId: string) => void = (
val,
headId
) => {
if (val !== undefined && bdst?.bdstBase.length > 0) {
const data: BdstTypeMap[T] = bdst?.bdstBase[val];
if (data) {
setRainBdstForm(data);
}
}
}
};
useEffect(()=>{
setbdstTable([]) // 초기화 작업
},[])
useEffect(() => {
setbdstTable([]); // 초기화 작업
}, []);
return (
<>
<div className="grid grid-cols-12 gap-4 mt-4 items-center">
@@ -99,31 +138,50 @@ export function BdstReg<T extends MoType>({ moType,setIsModal,isModal }: BdstReg
className="col-span-3 h-full"
label={"시도"}
selectClass={selectClass}
selectArray={code.cityCd || []}
onSelectValue={getSelCity}
>
{""}
</SelectBox>
selectArray={useCityCd}
onSelectValue={(val) => {
setObjSearch({ ...objSearch, city: String(val) });
}}
value={objSearch.city || useCityCd[0]?.val}
></SelectBox>
<SelectBox
className="col-span-3 h-full"
label={"시군구"}
selectClass={selectClass}
selectArray={selectSgg || []}
onSelectValue={getSgg}
value={objSearch.sgg || ""}
selectArray={useSggCd || []}
onSelectValue={(val) => {
if (val) setObjSearch({ ...objSearch, sgg: String(val) });
}}
value={objSearch.sgg || useSggCd[0]?.val}
>
{" "}
</SelectBox>
<Label className="w-full text-xl text-gray-600 text-right">시설명</Label>
<Input className="w-full h-full !text-xl col-span-2 col-start-8" type="text" value={searchTxt || ''} onChange={(e) => setSearchTxt(e.target.value)}/>
<Button className="" size={"sm"} onClick={()=>{searchBdst(searchTxt)}}>조회</Button>
<Label className="w-full text-xl text-gray-600 text-right">
시설명
</Label>
<Input
className="w-full h-full !text-xl col-span-2 col-start-8"
type="text"
value={searchTxt || ""}
onChange={(e) => setSearchTxt(e.target.value)}
/>
<Button
className=""
size={"sm"}
onClick={() => {
searchBdst(searchTxt);
}}
>
조회
</Button>
</div>
<div className="border-t border-gray-300 my-4"></div>
<div className="h-auto">
<h1 className="text-2xl font-medium text-label pl-8">
건축물 목록
<span className="!text-2xl text-base text-blue-500">
(유의 사항: 신규등록하려는 건축물이 목록에 없을 경우 하단 건축물 정보에 추가하여 주시기 바랍니다.)
(유의 사항: 신규등록하려는 건축물이 목록에 없을 경우 하단 건축물
정보에 추가하여 주시기 바랍니다.)
</span>
</h1>
<ScrollArea className="h-[30vh]">
@@ -134,24 +192,40 @@ export function BdstReg<T extends MoType>({ moType,setIsModal,isModal }: BdstReg
pageSize={-10}
total={-1}
headName={undefined}
cellClick={(idx, headId) => (tableClick(idx, headId || ""))}
cellClick={(idx, headId) => tableClick(idx, headId || "")}
onPageChange={function (page: number): void {
throw new Error("Function not implemented.");
}}>
</UiTable>
}}
></UiTable>
</div>
</ScrollArea>
<div className="border-t border-gray-300 my-4"></div>
{/* <ScrollArea className="h-[40vh]"> */}
<div>
{ moType === 'RNB'?
<RainRegForm rainForm={rainBdstForm as customRainBdst} isModal={isModal} setIsModal={setIsModal} />
:moType==='RST'
? <RswtrRegForm rswtForm={rainBdstForm as customRswtBdst} isModal={isModal} setIsModal={(open) =>{setIsModal && setIsModal(open)}}></RswtrRegForm>
:<HtdflRegForm htdflForm={rainBdstForm as unknown as customHtdflBdst} isModal={true} setIsModal={(open) =>{setIsModal && setIsModal(open)}}></HtdflRegForm>
}
</div>
<div>
{moType === "RNB" ? (
<RainRegForm
rainForm={rainBdstForm as customRainBdst}
isModal={isModal}
setIsModal={setIsModal}
/>
) : moType === "RST" ? (
<RswtrRegForm
rswtForm={rainBdstForm as customRswtBdst}
isModal={isModal}
setIsModal={(open) => {
setIsModal && setIsModal(open);
}}
></RswtrRegForm>
) : (
<HtdflRegForm
htdflForm={rainBdstForm as unknown as customHtdflBdst}
isModal={true}
setIsModal={(open) => {
setIsModal && setIsModal(open);
}}
></HtdflRegForm>
)}
</div>
{/* </ScrollArea> */}
</div>
</>