diff --git a/apps/wr/app/matMng/coMng/coSttn/page.tsx b/apps/wr/app/matMng/coMng/coSttn/page.tsx index d9fb09031..781a02210 100644 --- a/apps/wr/app/matMng/coMng/coSttn/page.tsx +++ b/apps/wr/app/matMng/coMng/coSttn/page.tsx @@ -71,6 +71,7 @@ export default function CoSttn() { const getSgg = useCallback((val: string | number) => { setObjSearch((prev) => ({ ...prev, sgg: String(val) })); + setPageNation(1) }, []); useEffect(() => { @@ -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 ( <> @@ -166,7 +174,10 @@ export default function CoSttn() { label="시도" selectClass={""} selectArray={code.cityCd || []} - onSelectValue={getSelCity} + onSelectValue={(val)=>{ + getSelCity(val) + setPageNation(1) + } } value={objSearch.city} /> { - 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)); + + + } } > diff --git a/apps/wr/app/ruseFcltMng/fcltSttn/pbnstSttn/page.tsx b/apps/wr/app/ruseFcltMng/fcltSttn/pbnstSttn/page.tsx index baafd8053..338ac71f9 100644 --- a/apps/wr/app/ruseFcltMng/fcltSttn/pbnstSttn/page.tsx +++ b/apps/wr/app/ruseFcltMng/fcltSttn/pbnstSttn/page.tsx @@ -30,6 +30,7 @@ export default function PbnstSttn() { pbnSttnInit, getPbnStnDetail, pbnNmSearch, + getFlcts } = useWrStore((state) => state); const ref = useRef({} as ReturnType); @@ -77,13 +78,20 @@ export default function PbnstSttn() { }, [pbnstSttn.excelList]); useEffect(() => { if (!pbnstSttn.isInit) { - pbnSttnInit("1", "20", ref.current, searchYear); + getFlcts() + } }, [pbnstSttn.isInit, pbnSttnInit, ref.current]); useEffect(() => { + + console.log('pbnstSttn.pbnstSttnRes ' ,pbnstSttn.pbnstSttnRes ) setBdstTable(pbnstSttn.pbnstSttnRes); }, [pbnstSttn.pbnstSttnRes]); + useEffect(() =>{ + pbnSttnInit("1", "20", ref.current, searchYear, pbnstSttn.fclts); + },[pbnstSttn.fclts]) + // useEffect(() => { // pbnstSttnSearch("1", "20", ref.current, pbnRuseNm, searchYear); // }, [pageNation, ref.current, pbnRuseNm, searchYear, pbnstSttnSearch]); @@ -94,7 +102,7 @@ export default function PbnstSttn() { // }, [pbnRuseNm,pageNation]); useEffect(() => { - pbnstSttnSearch(false, String(pageNation), "20", returnType, pbnRuseNm, searchYear); + // pbnstSttnSearch(false, String(pageNation), "20", returnType, pbnRuseNm, searchYear); }, [pageNation]); useEffect(() => { diff --git a/apps/wr/app/ruseFcltMng/prfmncReg/pbnstPrfmncReg/page.tsx b/apps/wr/app/ruseFcltMng/prfmncReg/pbnstPrfmncReg/page.tsx index c54725ff2..20e3652dd 100644 --- a/apps/wr/app/ruseFcltMng/prfmncReg/pbnstPrfmncReg/page.tsx +++ b/apps/wr/app/ruseFcltMng/prfmncReg/pbnstPrfmncReg/page.tsx @@ -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) { diff --git a/apps/wr/app/store/prfmncReg/chkgdnReg/rainChkgdn/excel.tsx b/apps/wr/app/store/prfmncReg/chkgdnReg/rainChkgdn/excel.tsx index 53b43e0f3..408d746e3 100644 --- a/apps/wr/app/store/prfmncReg/chkgdnReg/rainChkgdn/excel.tsx +++ b/apps/wr/app/store/prfmncReg/chkgdnReg/rainChkgdn/excel.tsx @@ -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; }; diff --git a/apps/wr/app/store/prfmncReg/pbnstPrfmncReg/index.tsx b/apps/wr/app/store/prfmncReg/pbnstPrfmncReg/index.tsx index 387f56eb7..87007d5f6 100644 --- a/apps/wr/app/store/prfmncReg/pbnstPrfmncReg/index.tsx +++ b/apps/wr/app/store/prfmncReg/pbnstPrfmncReg/index.tsx @@ -68,7 +68,7 @@ const hasuListFetch = async (page: number, sggOrCity: string) => { prfList: data.prfList, }); } - }); + }).filter(Boolean); // undefined 값을 제거합니다. return findData; }; diff --git a/apps/wr/app/store/ruseFcltMng/fcltSttn/pbnstSttn/index.tsx b/apps/wr/app/store/ruseFcltMng/fcltSttn/pbnstSttn/index.tsx index 76a13943f..939d2c37a 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltSttn/pbnstSttn/index.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltSttn/pbnstSttn/index.tsx @@ -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"; @@ -28,6 +28,7 @@ export type pbnstSttnState = { ruseDmdHeadList: TableUpperProps[] ruseFcltHeadList: TableUpperProps[] excelList: []; + fclts:string[] isInit: boolean; }; }; @@ -40,13 +41,15 @@ type pbnstSttnActions = { total: string, reurnValue: ReturnType, searchNm: string | undefined, - year: string, + year: string ) => void; + getFlcts:()=>void; pbnSttnInit: ( page: string, total: string, reurnValue: ReturnType, - year: string + year: string, + flcts:string[] ) => void; getPbnStnDetail: (pbnstRuseFcltPk: string) => void; pbnNmSearch: ( @@ -74,6 +77,7 @@ export const pbnstSttnStateExport: pbnstSttnState = { pbnstDetail: {} as customPbnst, pbnstSearchData: [], excelList: [], + fclts:[], isInit: false, }, }; @@ -83,46 +87,49 @@ 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 === 'G2120'){ + url += `${page}/${total}/${reurnValue.envPartValue}/${reurnValue.sidoValue ? reurnValue.sidoValue : reurnValue.sigunValue}/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) ); @@ -182,6 +189,8 @@ const hasuListFetch = async ( }; } ); + + console.log('data ', data) return data; }; @@ -189,6 +198,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 ): Promise => { @@ -211,16 +229,20 @@ export const pbnstSttnActionsExport: (set: any) => pbnstSttnActions = ( year: string, ) => { try { - console.log("여기") + + let fclts = [] as any + set((state: pbnstSttnState) => { + fclts = state.pbnstSttn.fclts + }); 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); @@ -249,23 +271,24 @@ export const pbnstSttnActionsExport: (set: any) => pbnstSttnActions = ( 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: { diff --git a/apps/wr/components/ui/modal/chkgd/chkgdExcel/chkgdExcel.tsx b/apps/wr/components/ui/modal/chkgd/chkgdExcel/chkgdExcel.tsx index a7b66d811..6ebbe4c6c 100644 --- a/apps/wr/components/ui/modal/chkgd/chkgdExcel/chkgdExcel.tsx +++ b/apps/wr/components/ui/modal/chkgd/chkgdExcel/chkgdExcel.tsx @@ -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) {