From f5d8f8fe233f6cace257ab04710449af11d6e478 Mon Sep 17 00:00:00 2001 From: mind-one005 Date: Sat, 28 Jun 2025 10:57:35 +0900 Subject: [PATCH] =?UTF-8?q?=EC=A4=91=EA=B0=84..?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../popupComponent/chart/aplcnYms.ts | 46 ++++++++++++++- .../popupComponent/chart/infilChart.tsx | 57 +++---------------- .../popupComponent/chart/inftwtAnls.ts | 0 3 files changed, 52 insertions(+), 51 deletions(-) create mode 100644 apps/sn/app/(map-layout)/map/components/popupComponent/chart/inftwtAnls.ts diff --git a/apps/sn/app/(map-layout)/map/components/popupComponent/chart/aplcnYms.ts b/apps/sn/app/(map-layout)/map/components/popupComponent/chart/aplcnYms.ts index 695c13560..174cd4d7c 100644 --- a/apps/sn/app/(map-layout)/map/components/popupComponent/chart/aplcnYms.ts +++ b/apps/sn/app/(map-layout)/map/components/popupComponent/chart/aplcnYms.ts @@ -1,7 +1,7 @@ import {useState, useEffect} from 'react'; const convertToTextValArray = (yyyymms: string[]): { text: string; val: string }[] => { - return yyyymms.map(dateStr => { + let yyyymms1 = yyyymms.map(dateStr => { const year = dateStr.slice(0, 4); const month = dateStr.slice(4, 6); return { @@ -9,6 +9,8 @@ const convertToTextValArray = (yyyymms: string[]): { text: string; val: string } val: dateStr }; }); + yyyymms1.unshift({ val: '0', text: '선택' }); + return yyyymms1; }; const selectAplcnYms = async() => { // 상수사용월 try { @@ -23,7 +25,6 @@ const selectAplcnYms = async() => { // 상수사용월 } if (result && result.length > 0) { - //setAplcnYms(convertToTextValArray(result)); console.log("selectAplcnYms", result); return convertToTextValArray(result); } @@ -31,6 +32,47 @@ const selectAplcnYms = async() => { // 상수사용월 console.error(error); } }; +type InftwtAnls = { + inftwtAnlsSn:number; + aplcnYm: string; + enoCd: string; + ctpvCd: string; + sggCd: string; + swageTmplntCd: string; + swageTmplntNm: string; + swtrmtZoneCd: string; + swtrmtZoneNm: string; + atflCd: string; + atflId: string; + atflInpNm: string; + atflHrPttnNm: string; + atflMpngNm: string; + atflOilqNm: string; + atflNm: string; + drtwSwtcRt:number; + anlsInfo: string; + scsYn: string; +}; +const selectInftwtAnls = async(aplcnYm:String) => { // 침입수분석 + try { + //const result = await getData('v1/inftwtAnlsRslt/aplcnYm'); + let result = null; + const res = await fetch('http://con.mind-one.co.kr:11083/sewerage-service/api/v1/inftwtAnls', { + method: "GET", + body: JSON.stringify({aplcnYm}), + }); + if (res.ok) { + result = await res.json(); + } + + if (result && result.numberOfElements > 0) { + console.log("selectInftwtAnls", result.content); + return result.content as InftwtAnls[]; + } + } catch (error) { + console.error(error); + } +}; export const useAplcnYms = () => { const [data, setData] = useState<{ text: string; val: string }[]>([]); diff --git a/apps/sn/app/(map-layout)/map/components/popupComponent/chart/infilChart.tsx b/apps/sn/app/(map-layout)/map/components/popupComponent/chart/infilChart.tsx index 7e6ba39b8..5d1d5bb42 100644 --- a/apps/sn/app/(map-layout)/map/components/popupComponent/chart/infilChart.tsx +++ b/apps/sn/app/(map-layout)/map/components/popupComponent/chart/infilChart.tsx @@ -18,8 +18,8 @@ const InfilChart = ({ btnTxt, isModalOpen, setIsModalOpen, closeModal }: ModalOp const buttonRef = React.useRef(null); // 버튼 참조 const [popupPosition, setPopupPosition] = useState<{ top: number; left: number }>({ top: 0, left: 0 }); // 팝업 위치 const [aplcnYm, setAplcnYm] = useState(""); - const [aplcnYms, setAplcnYms] = useState<{ text: string; val: string }[]>([]); - //const aplcnYms = useAplcnYms(); // 상수사용월 데이터 가져오기 + //const [aplcnYms, setAplcnYms] = useState<{ text: string; val: string }[]>([]); + const aplcnYms = useAplcnYms(); // 상수사용월 데이터 가져오기 const openPopup = () => { if (buttonRef.current) { const rect = buttonRef.current.getBoundingClientRect(); // 버튼 위치 계산 @@ -59,46 +59,6 @@ const InfilChart = ({ btnTxt, isModalOpen, setIsModalOpen, closeModal }: ModalOp return `${year}-${month}`; }; - const convertToTextValArray = (yyyymms: string[]): { text: string; val: string }[] => { - return yyyymms.map(dateStr => { - const year = dateStr.slice(0, 4); - const month = dateStr.slice(4, 6); - return { - text: `${year}-${month}`, - val: dateStr - }; - }); - }; - const selectAplcnYms = async() => { // 상수사용월 - try { - //const result = await getData('v1/inftwtAnlsRslt/aplcnYm'); - let result = null; - const res = await fetch('http://con.mind-one.co.kr:11083/sewerage-service/api/v1/inftwtAnlsRslt/aplcnYm', { - method: "GET", - body: null, - }); - if (res.ok) { - result = await res.json(); - } - - if (result && result.length > 0) { - //setAplcnYms(convertToTextValArray(result)); - console.log("selectAplcnYms", result); - return convertToTextValArray(result); - } - } catch (error) { - console.error(error); - } - } - useEffect(() => { - const fetchAplcnYms = async () => { - const aplcnYmsData = await selectAplcnYms(); - setAplcnYms(aplcnYmsData||[]); - console.log("aplcnYms: ", aplcnYms); - //setAplcnYm(getCurrentDate()); - }; - fetchAplcnYms(); - }, [aplcnYms]); return ( {/* 분석 입력현황 조회 */} @@ -135,13 +95,12 @@ const InfilChart = ({ btnTxt, isModalOpen, setIsModalOpen, closeModal }: ModalOp
- setAplcnYm(String(value))} - /> +
diff --git a/apps/sn/app/(map-layout)/map/components/popupComponent/chart/inftwtAnls.ts b/apps/sn/app/(map-layout)/map/components/popupComponent/chart/inftwtAnls.ts new file mode 100644 index 000000000..e69de29bb