diff --git a/.gitignore b/.gitignore index d0bb49da9..6b685ea40 100644 --- a/.gitignore +++ b/.gitignore @@ -18,5 +18,5 @@ apps/wr/.next/**/* apps/fo/.next/**/* # env -.env* +#.env* .qodo diff --git a/apps/sn/.env.development b/apps/sn/.env.development new file mode 100644 index 000000000..fab02e36c --- /dev/null +++ b/apps/sn/.env.development @@ -0,0 +1,12 @@ +NEXT_PUBLIC_SITE_ID = SN +NEXT_PUBLIC_PORT = 11302 +NEXT_PUBLIC_PROXY_HOST = http://con.mind-one.co.kr:11302 +NEXT_PUBLIC_SERVER_API_URL = http://dev.onasys.co.kr:8000 +NEXT_PUBLIC_GEOSERVER_URL = http://rsone.iptime.org:10010/geoserver +NEXT_PUBLIC_LX_GEOSERVER_URL = http://con.mind-one.co.kr:11306/geoserver #TODO 운영에서 바꿔야 함 +NEXT_PUBLIC_CLAIM_NAME = Authorization +NEXT_PUBLIC_AUTH_USER_ID = token-id +NEXT_PUBLIC_ACCESS_TOKEN = access-token +NEXT_PUBLIC_REFRESH_TOKEN = refresh-token + +NEXT_PUBLIC_SEWERAGE_API_URL=http://con.mind-one.co.kr:11083/sewerage-service/api # 개발 서버 API diff --git a/apps/sn/.env.local b/apps/sn/.env.local new file mode 100644 index 000000000..2d8993cb5 --- /dev/null +++ b/apps/sn/.env.local @@ -0,0 +1,16 @@ +NEXT_PUBLIC_SITE_ID = SN +NEXT_PUBLIC_PORT = 3002 +NEXT_PUBLIC_PROXY_HOST = http://localhost:3002 +NEXT_PUBLIC_ADDR_URL = http://con.mind-one.co.kr:11082 +NEXT_PUBLIC_SERVER_API_URL = http://dev.onasys.co.kr:8000 +NEXT_PUBLIC_GEOSERVER_URL = http://rsone.iptime.org:10010/geoserver +NEXT_PUBLIC_LX_GEOSERVER_URL = http://con.mind-one.co.kr:11306/geoserver +NEXT_PUBLIC_RSONE_DC_URL = https://apigateway.rsonesoft.com #자료관 데이터 +NEXT_PUBLIC_CLAIM_NAME = Authorization +NEXT_PUBLIC_AUTH_USER_ID = token-id +NEXT_PUBLIC_ACCESS_TOKEN = access-token +NEXT_PUBLIC_REFRESH_TOKEN = refresh-token + +NEXT_PUBLIC_SEWERAGE_API_URL=http://con.mind-one.co.kr:11083/sewerage-service/api # 개발 서버 API +#NEXT_PUBLIC_SEWERAGE_API_URL=http://192.168.1.128:8883/sewerage-service/api # 최용성 부장님 API +#NEXT_PUBLIC_SEWERAGE_API_URL=http://192.168.1.222:8883/sewerage-service/api # 박이정 차장님 API diff --git a/apps/sn/.env.production b/apps/sn/.env.production new file mode 100644 index 000000000..0e7f34cb7 --- /dev/null +++ b/apps/sn/.env.production @@ -0,0 +1,14 @@ +NEXT_PUBLIC_SITE_ID = SN +NEXT_PUBLIC_PORT = 11302 +NEXT_PUBLIC_PROXY_HOST = http://con.mind-one.co.kr:11302 +NEXT_PUBLIC_ADDR_URL = http://con.mind-one.co.kr:11082 +NEXT_PUBLIC_SERVER_API_URL = http://dev.onasys.co.kr:8000 +NEXT_PUBLIC_GEOSERVER_URL = http://172.29.143.87:8080/geoserver +NEXT_PUBLIC_LX_GEOSERVER_URL = http://rsone.iptime.org:10010/geoserver_swl +NEXT_PUBLIC_RSONE_DC_URL = https://apigateway.rsonesoft.com #자료관 데이터 +NEXT_PUBLIC_CLAIM_NAME = Authorization +NEXT_PUBLIC_AUTH_USER_ID = token-id +NEXT_PUBLIC_ACCESS_TOKEN = access-token +NEXT_PUBLIC_REFRESH_TOKEN = refresh-token + +NEXT_PUBLIC_SEWERAGE_API_URL=http://con.mind-one.co.kr:11083/sewerage-service/api # 개발 서버 API diff --git a/apps/sn/app/(map-layout)/layout.tsx b/apps/sn/app/(map-layout)/layout.tsx new file mode 100644 index 000000000..e245cfdf1 --- /dev/null +++ b/apps/sn/app/(map-layout)/layout.tsx @@ -0,0 +1,34 @@ +"use client"; + +import { usePathname, useRouter } from "next/navigation"; +import { useQueryClient } from "@tanstack/react-query"; +import { BaseLayout } from "@common/components"; +import type { MenuItem } from "@/entities/menu"; +import { useMenuStore } from "@/shared/lib"; + +export default function MapLayout({ + children, +}: { + children: React.ReactNode; +}) { + const router = useRouter(); + const pathname = usePathname(); + const queryClient = useQueryClient(); + + const setCurrentMenuInfo = useMenuStore((state) => state.setCurrentMenuInfo); + + const handleMenuClick = (item: MenuItem) => { + setCurrentMenuInfo(item); + router.push(item.urlPath); + }; + + return ( + + {children} + + ); +} diff --git a/apps/sn/app/map/SearchModal.tsx b/apps/sn/app/(map-layout)/map/SearchModal.tsx similarity index 67% rename from apps/sn/app/map/SearchModal.tsx rename to apps/sn/app/(map-layout)/map/SearchModal.tsx index e1c2bd0de..74975331e 100644 --- a/apps/sn/app/map/SearchModal.tsx +++ b/apps/sn/app/(map-layout)/map/SearchModal.tsx @@ -1,15 +1,18 @@ import FeatureClickEventPopup from './featureClickEventPopup'; -import React, { useState } from 'react'; +import React, { useEffect, useState } from 'react'; import axios from 'axios'; -import { UiModal, UiTable } from '@common/business_components/ui'; +import { UiModal, UiTable, DatePickerRange } from '@common/business_components/ui'; import { Button, Input, Label } from '@common/components'; import { UiTable2 } from '@common/business_components/ui/table/index-2'; import { UITab2 } from '@common/business_components/ui/tab/index-2'; import { SelectBox2 } from '@common/business_components/ui/select/index-2'; import { YearRangeSelectBox } from '@/components/ui/YearRangeSelectBox'; import { SidoSigunguSelectBox } from '@/components/ui/SidoSigunguSelectBox'; -import { SwtrmtFcltCol, SwtrmtPrcsZoneCol } from './components/common/table'; +import { MsSwagePplCol2, SwtrmtFcltCol2, SwtrmtPrcsZoneCol2, MsSwageMhlCol2, ExclnSewagePumpCol2, stofcbrCol2 } from './components/common/table'; import LoadingOverlay from '@/components/ui/LoadingBar'; +//import { useDcTree, flattenFolders, useSggCd, useCityCd } from './components/searchModalReportApi'; +import { useDcTree,flattenFolders, useSggCd, useCityCd, addFileName, getFileDownload } from './components/searchModalReportApi'; +import { useCityCdStore, type SelectDataType } from './commonStore'; const API_URL = `${process.env.NEXT_PUBLIC_SEWERAGE_API_URL}`; @@ -24,10 +27,11 @@ const BASIC_TYPES = [ { val: "tb_ms_swage_ppl", text: "하수관로" }, { val: "tb_il_swage_prcs_fclt", text: "하수처리시설" }, { val: "tb_ms_swage_prcs_zone", text: "하수처리구역" }, - { val: "tb_ms_swage_mh", text: "하수맨홀" }, - { val: "tb_ms_swage_psmtn_1", text: "오수펌프" }, - { val: "tb_ms_swage_psmtn_2", text: "빗물펌프" }, - { val: "tb_ms_otfl", text: "우수토실" }, + { val: "tb_ms_swage_mhl", text: "하수맨홀" }, + { val: "tb_ms_swage_pmstn", text: "하수펌프장" }, + // { val: "tb_ms_swage_psmtn_1", text: "오수펌프" }, + // { val: "tb_ms_swage_psmtn_2", text: "빗물펌프" }, + { val: "tb_ms_stofcbr", text: "우수토실" }, ]; // 운영정보 '구분' 선택 목록 const WORK_TYPES = [ @@ -37,38 +41,7 @@ const WORK_TYPES = [ ]; const YEARS = Array.from({ length: 100 }, (_, i) => `${2025 - i}`); -// 테이블 헤더 리스트 -// 하수관로 -const swagePplTableHeadlist = [ - { id: 'pipeNumber', title: '관로번호' }, - { id: 'gisManageNumber', title: '관리번호(GIS)' }, - { id: 'managingInstitution', title: '관리기관' }, - { id: 'drawingNumber', title: '도엽번호' }, - { id: 'installationLocation', title: '설치위치' }, - { id: 'usage', title: '용도' }, - { id: 'pipeDiameter', title: '관경' }, - { id: 'pipeLength', title: '관로연장' }, - { id: 'pipeType', title: '관종' }, - { id: 'burialDepth', title: '매설심도' }, - { id: 'constructionYear', title: '개보수 년도' }, - { id: 'installationSubject', title: '설치 주체' }, - { id: 'area', title: '구역' }, - { id: 'division', title: '분구' }, - { id: 'alignmentType', title: '지선/간선 구분' }, - { id: 'flowType', title: '흐름 방식' }, - { id: 'boxCount', title: '박스 열수' }, - { id: 'height', title: '높이' }, - { id: 'width', title: '폭' }, - { id: 'startManholeNumber', title: '시점 맨홀번호' }, - { id: 'endManholeNumber', title: '종점 맨홀번호' }, - { id: 'startElevation', title: '시점관저고' }, - { id: 'endElevation', title: '종점관저고' }, -] -// 하수맨홀 (추후 작성 예정) -const swageMhTableHeadlist = [ - { id: "swtrmtFcltCd", title: "하수처리시설코드" }, -]; // 운영정보 const operationTableHeadlist = [ { id: "no", title: "NO" }, @@ -81,28 +54,15 @@ const operationTableHeadlist = [ // 하수도정비 기본계획 보고서 const reportTableHeadlist = [ { id: "no", title: "NO" }, - { id: "approvalYear", title: "승인년도" }, { id: "sido", title: "시도" }, { id: "sigungu", title: "시군구" }, - { id: "treatmentPlant", title: "하수처리장" }, - { id: "treatmentZone", title: "하수처리구역" }, - { id: "reportCount", title: "보고서(00건)" }, - { id: "planMapCount", title: "하수도대장 평면도(00건)" }, + { id: "approvalYear", title: "승인년도" }, + { id: "plantZoneGugun", title: "구분" }, + { id: "reportGubun", title: "보고서구분" }, + { id: "fileName", title: "파일명" }, { id: "regDate", title: "등록일자" }, ]; -const 처리구역List = [ - { val: "0", text: "선택" }, - { val: "a", text: "A" }, - { val: "b", text: "B" }, -]; - -interface SearchModalProps { - open: boolean; - onOpenChange: (open: boolean) => void; - onFeatureSelect: (row: any) => void; -} - // 날짜 조합 함수 const getDateString = ( year: string, @@ -117,6 +77,12 @@ const getDateString = ( return `${y}${m}${d}`; }; +interface SearchModalProps { + open: boolean; + onOpenChange: (open: boolean) => void; + onFeatureSelect: (row: any) => void; +} + const SearchModal: React.FC = ({ open, onOpenChange, @@ -129,9 +95,10 @@ const SearchModal: React.FC = ({ const [tableCount, setTableCount] = useState(0); const [curPage, setCurPage] = useState(1); const [basicType, setBasicType] = useState(BASIC_TYPES[0]?.val ?? ""); - const [시도, set시도] = useState(0); - const [시군구, set시군구] = useState(0); - const [처리구역, set처리구역] = useState(""); + const [ctpvCd, setCtpvCd] = useState('0'); + const [sigungu, setSigungu] = useState('0'); + //const [swageProcessingZone, set처리구역] = useState(""); + const [gubun, setGubun] = useState(""); // 하수정비기본계획 report // 날짜 상태 선언 const [시작1, set시작1] = useState(""); const [시작2, set시작2] = useState(""); @@ -145,34 +112,57 @@ const SearchModal: React.FC = ({ const [yearFilter, setYearFilter] = useState({ 시작: "", 종료: "", - 경과년도: "", + // 경과년도: "", }); const [가동개시_시작_월, set가동개시_시작_월] = useState(''); const [가동개시_종료_월, set가동개시_종료_월] = useState(''); const [가동개시_시작_일, set가동개시_시작_일] = useState(''); const [가동개시_종료_일, set가동개시_종료_일] = useState(''); + const [fromDate, setFromDate] = useState(() => { const date = new Date(); date.setDate(date.getDate() - 7); return date }) + const [toDate, setToDate] = useState(new Date()) + const [filteredSiguns, setFilteredSiguns] = useState([{ val: '0', text: '전체', sido: '0' }]); // 로딩바 const [isLoading, setIsLoading] = useState(false); - // 상세 정보 조회를 위한 상태 추가 - const [popupFeature, setPopupFeature] = useState(null); + const sidos = useCityCd(); + const siguns = useSggCd(); + const reportOriginData = useDcTree(""); //:Folder[] + // 오늘 날짜 구하기 const today = new Date(); const todayYear = today.getFullYear().toString(); const todayMonth = (today.getMonth() + 1).toString().padStart(2, "0"); const todayDate = today.getDate().toString().padStart(2, "0"); + const isDateInRanges = (date: Date) => { + const standYear = parseInt(fromDate.getFullYear().toString()); + const dateRanges = []; + dateRanges.push({ + start: new Date(standYear, 0, 1), + end: new Date(standYear, 11, 31) + }); + + return dateRanges.some(range => { + const start = new Date(range.start); + const end = new Date(range.end); + return date >= start && date <= end; + }); + }; + // UiTable2에 넘길 headlist를 BASIC_TYPES 값에 따라 분기 처리 - let dynamicHeadlist = SwtrmtPrcsZoneCol; // default 값 + let dynamicHeadlist = MsSwagePplCol2; // default 값 if (activeTab === 'operation') dynamicHeadlist = operationTableHeadlist; // 운영정보 else if (activeTab === 'report') dynamicHeadlist = reportTableHeadlist; // 하수도정비기본계획보고서 - else if (basicType === 'tb_ms_swage_ppl') dynamicHeadlist = swagePplTableHeadlist; // 하수관로 - else if (basicType === 'tb_il_swage_prcs_fclt') dynamicHeadlist = SwtrmtFcltCol; // 하수처리시설 - else if (basicType === 'tb_ms_swage_prcs_zone') dynamicHeadlist = SwtrmtPrcsZoneCol; // 하수처리구역 - else if (basicType === 'tb_ms_swage_mh') dynamicHeadlist = swageMhTableHeadlist; // 하수맨홀 + else if (basicType === 'tb_ms_swage_ppl') dynamicHeadlist = MsSwagePplCol2; // 하수관로 + else if (basicType === 'tb_il_swage_prcs_fclt') dynamicHeadlist = SwtrmtFcltCol2; // 하수처리시설 + else if (basicType === 'tb_ms_swage_prcs_zone') dynamicHeadlist = SwtrmtPrcsZoneCol2; // 하수처리구역 + else if (basicType === 'tb_ms_swage_mhl') dynamicHeadlist = MsSwageMhlCol2; // 하수맨홀 + else if (basicType === 'tb_ms_swage_pmstn') dynamicHeadlist = ExclnSewagePumpCol2; // 하수펌프장 + else if (basicType === 'tb_ms_stofcbr') dynamicHeadlist = stofcbrCol2; // 우수토실 + // 조회 버튼 클릭 시 1페이지로 이동하도록 수정 const handleSearch = () => { setCurPage(1); // 페이지를 1로 초기화 @@ -181,15 +171,36 @@ const SearchModal: React.FC = ({ }; // cellClick 함수 타입 지정 - const handleCellClick = (index?: number, headId?: string) => { + const handleCellClick = (index?: number) => { if (typeof index === "number") { onFeatureSelect(tableData[index % 10]); // 10은 page size 하드 코딩한 숫자 onOpenChange(false); // SearchModal 닫기 } }; + // 하수도정비기본계획.table cellClick + const handleReportCellClick = (index: number) => { + console.log(index); + const reportData = tableData[index]; + const fileName = reportData.fileName; + if (reportData.fileSn !== "") { + getFileDownload(reportData.fileSn, fileName); + } + }; - // 구분(basicType)이 바뀔 때마다 queryParams, filterParams 초기화 - React.useEffect(() => { + const handleCtpvCdChange = (val: string|number) => { // 하수도정비기본계획.시도 + const sidoOption = sidos.find((n) => n.val === val); + setCtpvCd(String(val)); + if (val !== '0') { + const filterSiguns = siguns.filter(item => item.sido === sidoOption?.text); + filterSiguns.unshift({ val: '0', text: '전체', sido: '0' }); + setFilteredSiguns(filterSiguns); + } + setSigungu("0"); + setGubun(""); + setYearFilter({시작: "",종료: "",}); + } + + useEffect(() => { // filterParams 초기화 // setFilterParams({}); set시작1(""); @@ -204,22 +215,21 @@ const SearchModal: React.FC = ({ set가동개시_종료_월(""); set가동개시_시작_일(""); set가동개시_종료_일(""); - set시도(0); - set시군구(0); - set처리구역(""); + setCtpvCd('0'); + setSigungu('0'); setYearFilter({ 시작: "", 종료: "", - 경과년도: "", + // 경과년도: "", }); setShowTable(false); setTableCount(0); setTableData([]); // queryParams는 fetchFilteredData 내에서 매번 새로 생성되므로 별도 상태 초기화는 필요 없음 - }, [activeTab, basicType]); + }, [activeTab, basicType, open]); // 페이지 변경 시마다 데이터 fetch - React.useEffect(() => { + useEffect(() => { // showTable이 true일 때만 fetch (최초 렌더 방지) if (showTable) { fetchFilteredData(); // 실제 API 사용 시 @@ -227,14 +237,95 @@ const SearchModal: React.FC = ({ } }, [curPage]); + + // 검색 API 호출 함수 + const fetchFilteredData = async () => { + setIsLoading(true); // 로딩 시작 + try { + const queryParams = new URLSearchParams({ + lyrTypeNm: basicType, + page: `${curPage - 1}`, + size: '10', + sort: 'string', + }); + + let cqlFilters: string[] = []; + if (activeTab === 'basic') { + if (basicType === 'tb_ms_swage_prcs_zone') cqlFilters = zoneCqlFilters(); // 하수처리구역 + else if (basicType === 'tb_il_swage_prcs_fclt') cqlFilters = facilityCqlFilters(); // 하수처리시설 + else if (basicType === 'tb_ms_swage_ppl') cqlFilters = pplCqlFilters(); // 하수관로 + else if (basicType === 'tb_ms_swage_mhl') cqlFilters = mhCqlFilters(); // 하수맨홀 + else if (basicType === 'tb_ms_swage_pmstn') cqlFilters = psmtnCqlFilters(); // 하수펌프장 + else if (basicType === 'tb_ms_stofcbr') cqlFilters = otflCqlFilters(); // 우수토실 + } else if (activeTab === 'operation') { + cqlFilters = zoneCqlFilters(); + } else { + cqlFilters = reportCqlFilters(); + } + + if (cqlFilters.length > 0) queryParams.append('cqlFiter', cqlFilters.join(' and ')); + + if (activeTab === 'report') { + //const reportOriginData = await getDcTree('경기도'); + const reportData = flattenFolders(reportOriginData); + let filterReportData = reportData; + if (ctpvCd !== "0") { // 시도검색 + const sidoOption = sidos.find((n) => n.val === ctpvCd); + filterReportData = filterReportData.filter(item => item.sido === sidoOption?.text); + } + if (sigungu !== "0") { // 시군구검색 + const sigunguOption = filteredSiguns.find((n) => n.val === sigungu); + filterReportData = filterReportData.filter(item => item.sigungu === sigunguOption?.text); + } + if (yearFilter.시작 != "" && yearFilter.종료 == "") //승인년도검색 + filterReportData = filterReportData.filter(item => (item.approvalYear)? item.approvalYear >= yearFilter.시작+"년" : null); + if (yearFilter.시작 == "" && yearFilter.종료 != "") + filterReportData = filterReportData.filter(item => (item.approvalYear)? item.approvalYear <= yearFilter.종료+"년" : null); + if (yearFilter.시작 != "" && yearFilter.종료 != "") { + filterReportData = filterReportData.filter(item => { + return (item.approvalYear)? item.approvalYear >= yearFilter.시작+"년" && item.approvalYear <= yearFilter.종료+"년": null; + }); + } + if (gubun !== "") { // 구분검색 + filterReportData = filterReportData.filter(item => (item.plantZoneGugun)? String(item.plantZoneGugun).includes(String(gubun)) : null); + } + console.log('report count:', filterReportData.length); + setTableCount(filterReportData.length || 0); + filterReportData = filterReportData.slice((curPage-1)*10, curPage*10); // paging + filterReportData = filterReportData?.map((item, index)=>({...item, no:(curPage-1)*10+index+1})); + //const fileList = await getDcFile("CLS20250530000041"); + addFileName(filterReportData).then(data => { + filterReportData = data; + setTableData(filterReportData || []); + }); + setTableData(filterReportData || []); + } else { + console.log('API URL:', `${API_URL}/v1/fclts?${queryParams.toString()}`); + const res = await axios.get(`${API_URL}/v1/fclts?${queryParams.toString()}`); + console.log('필터링된 API 결과(개수):', res.data.count); + console.log('필터링된 API 결과(데이터):', res.data.data); + setTableData(res.data.data || []); + setTableCount(res.data.count || []); + console.log('tableCount 상태 업데이트 후:', res.data.count); // tableCount 로그 추가 + } + + setShowTable(true); + } catch (err) { + console.error('API ERROR:', err); + setTableData([]); + } finally { + setIsLoading(false); // 로딩 종료 + } + }; + // 하수관로용 CQL 필터 생성 const pplCqlFilters = () => { const cqlFilters: string[] = []; // 추후 작성 예정 - if (변수1) cqlFilters.push(`용도코드='${변수1}'`); - if (변수2) cqlFilters.push(`재질코드='${변수2}'`); - if (변수3) cqlFilters.push(`행정읍면동코드='${변수3}'`); - if (변수4) cqlFilters.push(`경과년도='${변수4}'`); + if (변수1) cqlFilters.push(`usg_cd='${변수1}'`); + if (변수2) cqlFilters.push(`mqlt_cd='${변수2}'`); + if (변수3) cqlFilters.push(`pbadms_emd_cd='${변수3}'`); + // if (변수4) cqlFilters.push(`경과년도='${변수4}'`); // 설치년도 범위 const startDate = getDateString( yearFilter.시작, @@ -249,19 +340,20 @@ const SearchModal: React.FC = ({ `${todayYear}${todayMonth}${todayDate}`, ); cqlFilters.push( - `설치시작년도 >= '${startDate}' and 설치시작년도 <= '${endDate}'`, + `instl_ymd >= '${startDate}' and instl_ymd <= '${endDate}'`, ); // 관경(mm) 범위 - if (시작1 && 종료1) cqlFilters.push(`관경 BETWEEN ${시작1} AND ${종료1}`); - else if (시작1) cqlFilters.push(`관경 >= ${시작1}`); - else if (종료1) cqlFilters.push(`관경 <= ${종료1}`); + if (시작1 && 종료1) cqlFilters.push(`pdmt BETWEEN ${시작1} AND ${종료1}`); + else if (시작1) cqlFilters.push(`pdmt >= ${시작1}`); + else if (종료1) cqlFilters.push(`pdmt <= ${종료1}`); // 연장(m) 범위 - if (시작2 && 종료2) cqlFilters.push(`연장 BETWEEN ${시작2} AND ${종료2}`); - else if (시작2) cqlFilters.push(`연장 >= ${시작2}`); - else if (종료2) cqlFilters.push(`연장 <= ${종료2}`); + if (시작2 && 종료2) cqlFilters.push(`prlg BETWEEN ${시작2} AND ${종료2}`); + else if (시작2) cqlFilters.push(`prlg >= ${시작2}`); + else if (종료2) cqlFilters.push(`prlg <= ${종료2}`); return cqlFilters; }; + // 하수처리시설용 CQL 필터 생성 const facilityCqlFilters = () => { const cqlFilters: string[] = []; @@ -290,19 +382,21 @@ const SearchModal: React.FC = ({ if (변수1) cqlFilters.push(`swtrmt_fclt_nm ILIKE '%${변수1}%'`); return cqlFilters; }; + // 하수처리구역용 CQL 필터 생성 const zoneCqlFilters = () => { const cqlFilters: string[] = []; - if (시도) cqlFilters.push(`ctpv_cd='${시도}'`); - if (시군구) cqlFilters.push(`sgg_cd='${시군구}'`); + if (ctpvCd) cqlFilters.push(`ctpv_cd='${ctpvCd}'`); + if (sigungu) cqlFilters.push(`sgg_cd='${sigungu}'`); if (변수1) cqlFilters.push(`swtrmt_zone_nm ILIKE '%${변수1}%'`); if (변수2) cqlFilters.push(`swtrmt_fclt_nm ILIKE '%${변수2}%'`); return cqlFilters; }; + // 하수맨홀용 CQL 필터 생성 const mhCqlFilters = () => { const cqlFilters: string[] = []; - // 설치년도 범위 + // // 설치년도 범위 const startDate = getDateString( yearFilter.시작, 가동개시_시작_월, @@ -316,17 +410,18 @@ const SearchModal: React.FC = ({ `${todayYear}${todayMonth}${todayDate}`, ); cqlFilters.push( - `설치시작년도 >= '${startDate}' and 설치시작년도 <= '${endDate}'`, + `instl_ymd >= '${startDate}' and instl_ymd <= '${endDate}'`, ); - if (변수1) cqlFilters.push(`경과년도='${변수1}'`); - if (변수2) cqlFilters.push(`용도코드='${변수2}'`); + // if (변수1) cqlFilters.push(`경과년도='${변수1}'`); + if (변수2) cqlFilters.push(`usg_cd='${변수2}'`); // 구경(mm) 범위 - if (시작1 && 종료1) cqlFilters.push(`구경 BETWEEN ${시작1} AND ${종료1}`); - else if (시작1) cqlFilters.push(`구경 >= ${시작1}`); - else if (종료1) cqlFilters.push(`구경 <= ${종료1}`); + if (시작1 && 종료1) cqlFilters.push(`swage_mh_diam BETWEEN ${시작1} AND ${종료1}`); + else if (시작1) cqlFilters.push(`swage_mh_diam >= ${시작1}`); + else if (종료1) cqlFilters.push(`swage_mh_diam <= ${종료1}`); return cqlFilters; }; + // 하수펌프장용 CQL 필터 생성 const psmtnCqlFilters = () => { const cqlFilters: string[] = []; @@ -344,22 +439,23 @@ const SearchModal: React.FC = ({ `${todayYear}${todayMonth}${todayDate}`, ); cqlFilters.push( - `설치시작년도 >= '${startDate}' and 설치시작년도 <= '${endDate}'`, + `instl_ymd >= '${startDate}' and instl_ymd <= '${endDate}'`, ); - if (변수1) cqlFilters.push(`경과년도='${변수1}'`); + // if (변수1) cqlFilters.push(`경과년도='${변수1}'`); // 일일처리용량 범위 if (시작1 && 종료1) - cqlFilters.push(`일일처리용량 BETWEEN ${시작1} AND ${종료1}`); - else if (시작1) cqlFilters.push(`일일처리용량 >= ${시작1}`); - else if (종료1) cqlFilters.push(`일일처리용량 <= ${종료1}`); + cqlFilters.push(`daily_prcs_cpct BETWEEN ${시작1} AND ${종료1}`); + else if (시작1) cqlFilters.push(`daily_prcs_cpct >= ${시작1}`); + else if (종료1) cqlFilters.push(`daily_prcs_cpct <= ${종료1}`); // 우수양수능력 범위 if (시작2 && 종료2) - cqlFilters.push(`우수양수능력 BETWEEN ${시작2} AND ${종료2}`); - else if (시작2) cqlFilters.push(`우수양수능력 >= ${시작2}`); - else if (종료2) cqlFilters.push(`우수양수능력 <= ${종료2}`); + cqlFilters.push(`excln_wpmp_ablt BETWEEN ${시작2} AND ${종료2}`); + else if (시작2) cqlFilters.push(`excln_wpmp_ablt >= ${시작2}`); + else if (종료2) cqlFilters.push(`excln_wpmp_ablt <= ${종료2}`); return cqlFilters; }; + // 우수토실용 CQL 필터 생성 const otflCqlFilters = () => { const cqlFilters: string[] = []; @@ -377,18 +473,19 @@ const SearchModal: React.FC = ({ `${todayYear}${todayMonth}${todayDate}`, ); cqlFilters.push( - `설치시작년도 >= '${startDate}' and 설치시작년도 <= '${endDate}'`, + `instl_ymd >= '${startDate}' and instl_ymd <= '${endDate}'`, ); - if (변수1) cqlFilters.push(`경과년도='${변수1}'`); - if (변수2) cqlFilters.push(`하천명 ILIKE '%${변수1}%'`); + // if (변수1) cqlFilters.push(`경과년도='${변수1}'`); + // if (변수2) cqlFilters.push(`하천명 ILIKE '%${변수1}%'`); // 계획방류량 범위 - if (시작1 && 종료1) - cqlFilters.push(`계획방류량 BETWEEN ${시작1} AND ${종료1}`); - else if (시작1) cqlFilters.push(`계획방류량 >= ${시작1}`); - else if (종료1) cqlFilters.push(`계획방류량 <= ${종료1}`); + // if (시작1 && 종료1) + // cqlFilters.push(`계획방류량 BETWEEN ${시작1} AND ${종료1}`); + // else if (시작1) cqlFilters.push(`계획방류량 >= ${시작1}`); + // else if (종료1) cqlFilters.push(`계획방류량 <= ${종료1}`); return cqlFilters; }; + // 운영정보용 CQL 필터 생성 const operationCqlFilters = () => { const cqlFilters: string[] = []; @@ -410,73 +507,17 @@ const SearchModal: React.FC = ({ ); return cqlFilters; }; + // 하수도정비기본계획보고서용 CQL 필터 생성 const reportCqlFilters = () => { const cqlFilters: string[] = []; // 설치년도 범위 - if (시도) cqlFilters.push(`ctpv_cd='${시도}'`); - if (시군구) cqlFilters.push(`sgg_cd='${시군구}'`); - if (처리구역) cqlFilters.push(`처리구역='${처리구역}'`); - if (변수1) cqlFilters.push(`처리구역코드='${변수1}'`); - const startDate = getDateString( - yearFilter.시작, - 가동개시_시작_월, - 가동개시_시작_일, - "19000101", - ); - const endDate = getDateString( - yearFilter.종료, - 가동개시_종료_월, - 가동개시_종료_일, - `${todayYear}${todayMonth}${todayDate}`, - ); - cqlFilters.push( - `설치시작년도 >= '${startDate}' and 설치시작년도 <= '${endDate}'`, - ); + if (ctpvCd) cqlFilters.push(`ctpv_cd='${ctpvCd}'`); + if (sigungu) cqlFilters.push(`sgg_cd='${sigungu}'`); + return cqlFilters; }; - // 검색 API 호출 함수 - const fetchFilteredData = async () => { - setIsLoading(true); // 로딩 시작 - try { - const queryParams = new URLSearchParams({ - lyrTypeNm: basicType, - page: `${curPage - 1}`, - size: '10', - sort: 'string', - }); - - let cqlFilters: string[] = []; - if (activeTab === 'basic') { - if (basicType === 'tb_ms_swage_prcs_zone') cqlFilters = zoneCqlFilters(); - else if (basicType === 'tb_il_swage_prcs_fclt') cqlFilters = facilityCqlFilters(); - else if (basicType === 'tb_ms_swage_ppl') cqlFilters = pplCqlFilters(); - } else if (activeTab === 'operation') { - cqlFilters = zoneCqlFilters(); - } else { - cqlFilters = reportCqlFilters(); - } - - if (cqlFilters.length > 0) queryParams.append('cqlFiter', cqlFilters.join(' and ')); - - console.log('API URL:', `${API_URL}/v1/fclts?${queryParams.toString()}`); - const res = await axios.get(`${API_URL}/v1/fclts?${queryParams.toString()}`); - console.log('필터링된 API 결과(개수):', res.data.count); - console.log('필터링된 API 결과(데이터):', res.data.data); - - setTableData(res.data.data || []); - setTableCount(res.data.count || []); - console.log('tableCount 상태 업데이트 후:', res.data.count); // tableCount 로그 추가 - setShowTable(true); - } catch (err) { - console.error('API ERROR:', err); - setTableData([]); - } finally { - setIsLoading(false); // 로딩 종료 - } - }; - const renderBody = () => ( <> {/* 탭 영역 */} @@ -527,7 +568,7 @@ const SearchModal: React.FC = ({ /> {/* 경과년도 */} -
+ {/*
@@ -541,7 +582,7 @@ const SearchModal: React.FC = ({ setYearFilter({ ...yearFilter, 경과년도: val }); }} /> -
+
*/} {/* 용도코드 */}