diff --git a/apps/sn/app/(map-layout)/map/searchModal/stofcbr.tsx b/apps/sn/app/(map-layout)/map/searchModal/stofcbr.tsx index 7571871d5..53d8866f7 100644 --- a/apps/sn/app/(map-layout)/map/searchModal/stofcbr.tsx +++ b/apps/sn/app/(map-layout)/map/searchModal/stofcbr.tsx @@ -7,6 +7,47 @@ import { CtpvSggPrcsFcltSelectBox } from '@/components/ui/ctpvSggPrcsFcltSelectB import useSearchModalStore from '../../../store/useSearchModalStore'; import { useSearchModal, type SearchModalProps } from './useSearchModal'; +interface stofcbrCqlFiltersParams { + ctpvCd: string; + sggCd: string; + yearFilter: { start: string; end: string }; + todayYear: string; + todayMonth: string; + todayDate: string; + getDateString: (year: string, month: string, day: string, defaultDate: string) => string; +} +export const stofcbrCqlFilters = (params: stofcbrCqlFiltersParams) => { + const { + ctpvCd, sggCd, + yearFilter, + todayYear, todayMonth, todayDate, + getDateString + } = params; + + const cqlFilters: string[] = []; + // 시도, 시군구 + if (ctpvCd !== '0' && sggCd !== '0') cqlFilters.push(`pbadms_emd_cd LIKE '${sggCd}%'`); + else if (ctpvCd !== '0') cqlFilters.push(`pbadms_emd_cd LIKE '${ctpvCd?.trim()}%'`); + // 설치년도 범위 + const startDate = getDateString( + yearFilter.start, + '', + '', + "19000101", + ); + const endDate = getDateString( + yearFilter.end, + '', + '', + `${todayYear}${todayMonth}${todayDate}`, + ); + cqlFilters.push( + `instl_ymd >= '${startDate}' and instl_ymd <= '${endDate}'`, + ); + + return cqlFilters; +}; + const Stofcbr: React.FC = (props) => { const { ctpvCd, setCtpvCd, diff --git a/apps/sn/app/(map-layout)/map/searchModal/swageMhl.tsx b/apps/sn/app/(map-layout)/map/searchModal/swageMhl.tsx index f16fae331..302105c63 100644 --- a/apps/sn/app/(map-layout)/map/searchModal/swageMhl.tsx +++ b/apps/sn/app/(map-layout)/map/searchModal/swageMhl.tsx @@ -9,6 +9,57 @@ import { CtpvSggPrcsFcltSelectBox } from '@/components/ui/ctpvSggPrcsFcltSelectB import useSearchModalStore from '../../../store/useSearchModalStore'; import { useSearchModal, type SearchModalProps } from './useSearchModal'; +interface swageMhlCqlFiltersParams { + ctpvCd: string; + sggCd: string; + yearFilter: { start: string; end: string }; + start1: string; + end1: string; + var1: string; + todayYear: string; + todayMonth: string; + todayDate: string; + getDateString: (year: string, month: string, day: string, defaultDate: string) => string; +} +export const swageMhlCqlFilters = (params: swageMhlCqlFiltersParams) => { + const { + ctpvCd, sggCd, + yearFilter, + start1, end1, + var1, + todayYear, todayMonth, todayDate, + getDateString + } = params; + + const cqlFilters: string[] = []; + // 시도, 시군구 + if (ctpvCd !== '0' && sggCd !== '0') cqlFilters.push(`pbadms_emd_cd LIKE '${sggCd}%'`); + else if (ctpvCd !== '0') cqlFilters.push(`pbadms_emd_cd LIKE '${ctpvCd?.trim()}%'`); + // // 설치년도 범위 + const startDate = getDateString( + yearFilter.start, + '', + '', + "19000101", + ); + const endDate = getDateString( + yearFilter.end, + '', + '', + `${todayYear}${todayMonth}${todayDate}`, + ); + cqlFilters.push( + `instl_ymd >= '${startDate}' and instl_ymd <= '${endDate}'`, + ); + if (var1) cqlFilters.push(`usg_cd='${var1}'`); + // 구경(mm) 범위 + if (start1 && end1) cqlFilters.push(`swage_mhL_diam_vl BETWEEN ${start1} AND ${end1}`); + else if (start1) cqlFilters.push(`swage_mhL_diam_vl >= ${start1}`); + else if (end1) cqlFilters.push(`swage_mhL_diam_vl <= ${end1}`); + + return cqlFilters; +}; + const SwageMhl: React.FC = (props) => { const { var1, setVar1, diff --git a/apps/sn/app/(map-layout)/map/searchModal/swagePmstn.tsx b/apps/sn/app/(map-layout)/map/searchModal/swagePmstn.tsx index 4ca1aec58..9286ccbdb 100644 --- a/apps/sn/app/(map-layout)/map/searchModal/swagePmstn.tsx +++ b/apps/sn/app/(map-layout)/map/searchModal/swagePmstn.tsx @@ -7,6 +7,61 @@ import { CtpvSggPrcsFcltSelectBox } from '@/components/ui/ctpvSggPrcsFcltSelectB import useSearchModalStore from '../../../store/useSearchModalStore'; import { useSearchModal, type SearchModalProps } from './useSearchModal'; +interface swagePmstnCqlFiltersParams { + ctpvCd: string; + sggCd: string; + yearFilter: { start: string; end: string }; + start1: string; + start2: string; + end1: string; + end2: string; + todayYear: string; + todayMonth: string; + todayDate: string; + getDateString: (year: string, month: string, day: string, defaultDate: string) => string; +} +export const swagePmstnCqlFilters = (params: swagePmstnCqlFiltersParams) => { + const { + ctpvCd, sggCd, + yearFilter, + start1, start2, end1, end2, + todayYear, todayMonth, todayDate, + getDateString + } = params; + + const cqlFilters: string[] = []; + // 시도, 시군구 + if (ctpvCd !== '0' && sggCd !== '0') cqlFilters.push(`pbadms_emd_cd LIKE '${sggCd}%'`); + else if (ctpvCd !== '0') cqlFilters.push(`pbadms_emd_cd LIKE '${ctpvCd?.trim()}%'`); + // 설치년도 범위 + const startDate = getDateString( + yearFilter.start, + '', + '', + "19000101", + ); + const endDate = getDateString( + yearFilter.end, + '', + '', + `${todayYear}${todayMonth}${todayDate}`, + ); + cqlFilters.push( + `instl_ymd >= '${startDate}' and instl_ymd <= '${endDate}'`, + ); + // 일일처리용량 범위 + if (start1 && end1) + cqlFilters.push(`daily_prcs_cpct BETWEEN ${start1} AND ${end1}`); + else if (start1) cqlFilters.push(`daily_prcs_cpct >= ${start1}`); + else if (end1) cqlFilters.push(`daily_prcs_cpct <= ${end1}`); + // 양수능력 범위 + if (start2 && end2) + cqlFilters.push(`excln_wpmp_ablt_vl BETWEEN ${start2} AND ${end2}`); + else if (start2) cqlFilters.push(`excln_wpmp_ablt_vl >= ${start2}`); + else if (end2) cqlFilters.push(`excln_wpmp_ablt_vl <= ${end2}`); + + return cqlFilters; +}; const SwagePmstn: React.FC = (props) => { const { diff --git a/apps/sn/app/(map-layout)/map/searchModal/swagePpl.tsx b/apps/sn/app/(map-layout)/map/searchModal/swagePpl.tsx index 71369fb13..71a0e9935 100644 --- a/apps/sn/app/(map-layout)/map/searchModal/swagePpl.tsx +++ b/apps/sn/app/(map-layout)/map/searchModal/swagePpl.tsx @@ -9,16 +9,32 @@ import { CtpvSggPrcsFcltSelectBox } from '@/components/ui/ctpvSggPrcsFcltSelectB import useSearchModalStore from '../../../store/useSearchModalStore'; import { useSearchModal, type SearchModalProps } from './useSearchModal'; + +interface swagePplCqlFiltersParams { + var1: string; + var2: string; + ctpvCd: string; + sggCd: string; + yearFilter: { start: string; end: string }; + start1: string; + start2: string; + end1: string; + end2: string; + todayYear: string; + todayMonth: string; + todayDate: string; + getDateString: (year: string, month: string, day: string, defaultDate: string) => string; +} // 하수관로용 CQL 필터 생성 -export const pplCqlFilters = () => { - const store = useSearchModalStore(); +export const swagePplCqlFilters = (params: swagePplCqlFiltersParams) => { const { - todayYear, todayMonth, todayDate, - ctpvCd, sggCd, - start1, start2, end1, end2, var1, var2, - yearFilter, getDateString - } = store; + ctpvCd, sggCd, + yearFilter, + start1, start2, end1, end2, + todayYear, todayMonth, todayDate, + getDateString + } = params; const cqlFilters: string[] = []; if (var1) cqlFilters.push(`usg_cd='${var1}'`); @@ -26,9 +42,21 @@ export const pplCqlFilters = () => { if (ctpvCd !== '0' && sggCd !== '0') cqlFilters.push(`pbadms_emd_cd LIKE '${sggCd}%'`); else if (ctpvCd !== '0') cqlFilters.push(`pbadms_emd_cd LIKE '${ctpvCd?.trim()}%'`); // 설치년도 범위 - const startDate = getDateString(yearFilter.start, '', '', "19000101"); - const endDate = getDateString(yearFilter.end, '', '', `${todayYear}${todayMonth}${todayDate}`); - cqlFilters.push(`instl_ymd >= '${startDate}' and instl_ymd <= '${endDate}'`); + const startDate = getDateString( + yearFilter.start, + '', + '', + "19000101", + ); + const endDate = getDateString( + yearFilter.end, + '', + '', + `${todayYear}${todayMonth}${todayDate}`, + ); + cqlFilters.push( + `instl_ymd >= '${startDate}' and instl_ymd <= '${endDate}'`, + ); // 관경(mm) 범위 if (start1 && end1) cqlFilters.push(`pdmt_vl BETWEEN ${start1} AND ${end1}`); else if (start1) cqlFilters.push(`pdmt_vl >= ${start1}`); @@ -50,6 +78,7 @@ const SwagePpl: React.FC = (props) => { } = useSearchModalStore(); const { handleSearch } = useSearchModal(props); + return (
diff --git a/apps/sn/app/(map-layout)/map/searchModal/swagePrcsFclt.tsx b/apps/sn/app/(map-layout)/map/searchModal/swagePrcsFclt.tsx index 934499a6c..dcc5546ad 100644 --- a/apps/sn/app/(map-layout)/map/searchModal/swagePrcsFclt.tsx +++ b/apps/sn/app/(map-layout)/map/searchModal/swagePrcsFclt.tsx @@ -8,6 +8,63 @@ import useSearchModalStore from '../../../store/useSearchModalStore'; import { useSearchModal, type SearchModalProps } from './useSearchModal'; +interface swagePrcsFcltCqlFiltersParams { + ctpvName: string; + sggName: string; + yearFilter: { start: string; end: string }; + start1: string; + end1: string; + todayYear: string; + todayMonth: string; + todayDate: string; + getDateString: (year: string, month: string, day: string, defaultDate: string) => string; +} +// 하수처리시설용 CQL 필터 생성 +export const swagePrcsFcltCqlFilters = (params: swagePrcsFcltCqlFiltersParams) => { + const { + ctpvName, sggName, + yearFilter, + start1, end1, + todayYear, todayMonth, todayDate, + getDateString + } = params; + + const cqlFilters: string[] = []; + // 가동개시일자 범위 + const startDate = getDateString( + yearFilter.start, + '', + '', + "19000101", + ); + const endDate = getDateString( + yearFilter.end, + '', + '', + `${todayYear}${todayMonth}${todayDate}`, + ); + cqlFilters.push( + `oprtng_strt_ymd >= '${startDate}' and oprtng_strt_ymd <= '${endDate}'`, + ); + // 시설용량 범위 + if (start1 && end1) + cqlFilters.push(`fclt_cpct BETWEEN ${start1} AND ${end1}`); + else if (start1) cqlFilters.push(`fclt_cpct >= ${start1}`); + else if (end1) cqlFilters.push(`fclt_cpct <= ${end1}`); + + // 시도 + if (ctpvName) cqlFilters.push(`ctpv_nm ILIKE '%${ctpvName}%'`); + if (sggName) cqlFilters.push(`sgg_nm ILIKE '%${sggName}%'`); + // // 처리구역 면적 + // if (start2 && end2) + // cqlFilters.push(`prcsZoneAreaSum BETWEEN ${start2} AND ${end2}`); + // else if (start2) cqlFilters.push(`prcsZoneAreaSum >= ${start2}`); + // else if (end2) cqlFilters.push(`prcsZoneAreaSum <= ${end2}`); + // // 하수처리시설명 + // if (var1) cqlFilters.push(`swtrmt_fclt_nm ILIKE '%${var1}%'`); + return cqlFilters; +}; + const SwagePrcsFclt: React.FC = (props) => { const { start1, setStart1, end1, setEnd1, diff --git a/apps/sn/app/(map-layout)/map/searchModal/swagePrcsZone.tsx b/apps/sn/app/(map-layout)/map/searchModal/swagePrcsZone.tsx index c7d3df3ce..84e30c5ee 100644 --- a/apps/sn/app/(map-layout)/map/searchModal/swagePrcsZone.tsx +++ b/apps/sn/app/(map-layout)/map/searchModal/swagePrcsZone.tsx @@ -7,6 +7,26 @@ import useSearchModalStore from '../../../store/useSearchModalStore'; import { useSearchModal, type SearchModalProps } from './useSearchModal'; +interface swagePrcsZoneCqlFiltersParams { + ctpvCd: string; + sggCd: string; + var1: string; + var2: string; +} +// 하수처리구역용 CQL 필터 생성 +export const swagePrcsZoneCqlFilters = (params: swagePrcsZoneCqlFiltersParams) => { + const { + ctpvCd, sggCd, + var1, var2 + } = params; + const cqlFilters: string[] = []; + if (ctpvCd !== '' && ctpvCd !== '0') cqlFilters.push(`ctpv_cd='${ctpvCd?.trim()}'`); + if (sggCd !== '' && sggCd !== '0') cqlFilters.push(`sgg_cd='${sggCd}'`); + if (var1) cqlFilters.push(`swtrmt_zone_nm ILIKE '%${var1}%'`); + if (var2) cqlFilters.push(`swtrmt_fclt_nm ILIKE '%${var2}%'`); + return cqlFilters; +}; + const swagePrcsZone: React.FC = (props) => { const { var1, setVar1, var2, setVar2, diff --git a/apps/sn/app/(map-layout)/map/searchModal/useSearchModal.tsx b/apps/sn/app/(map-layout)/map/searchModal/useSearchModal.tsx index e48455772..99a80fd8c 100644 --- a/apps/sn/app/(map-layout)/map/searchModal/useSearchModal.tsx +++ b/apps/sn/app/(map-layout)/map/searchModal/useSearchModal.tsx @@ -14,6 +14,12 @@ import GisApp from "@common/business_components/ui/map/lib/gis.core"; import { confirmToast } from '@/components/ui/toast' import { toast } from "react-hot-toast"; import useSearchModalStore from '../../../store/useSearchModalStore'; +import { swagePplCqlFilters } from './swagePpl'; +import { swagePrcsFcltCqlFilters } from './swagePrcsFclt'; +import { swagePrcsZoneCqlFilters } from './swagePrcsZone'; +import { swageMhlCqlFilters } from './swageMhl'; +import { swagePmstnCqlFilters } from './swagePmstn'; +import { stofcbrCqlFilters } from './stofcbr'; const API_URL = `${process.env.NEXT_PUBLIC_SEWERAGE_API_URL}`; export const OPERATION_TABLE_SIZE = 5; @@ -28,7 +34,7 @@ export function useSearchModal({ open, onOpenChange, onFeatureSelect }: SearchMo const { activeTab, basicType, workType, showTable, - tableData, detailTableData, + tableData, detailTableData, curPage, detailCurPage, detailBizId, ctpvCd, ctpvName, sggCd, sggName, @@ -91,12 +97,46 @@ export function useSearchModal({ open, onOpenChange, onFeatureSelect }: SearchMo sort: 'string', }); - 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(); // 우수토실 + if (basicType === 'tb_ms_swage_prcs_zone') cqlFilters = swagePrcsZoneCqlFilters({ + ctpvCd, sggCd, + var1, var2 + }); // 하수처리구역 + else if (basicType === 'tb_il_swage_prcs_fclt') cqlFilters = swagePrcsFcltCqlFilters({ + ctpvName, sggName, + yearFilter, + start1, end1, + todayYear, todayMonth, todayDate, + getDateString + }); // 하수처리시설 + else if (basicType === 'tb_ms_swage_ppl') cqlFilters = swagePplCqlFilters({ + var1, var2, + ctpvCd, sggCd, + yearFilter, + start1, start2, end1, end2, + todayYear, todayMonth, todayDate, + getDateString + }); // 하수관로 + else if (basicType === 'tb_ms_swage_mhl') cqlFilters = swageMhlCqlFilters({ + ctpvCd, sggCd, + yearFilter, + start1, end1, + var1, + todayYear, todayMonth, todayDate, + getDateString + }); // 하수맨홀 + else if (basicType === 'tb_ms_swage_pmstn') cqlFilters = swagePmstnCqlFilters({ + ctpvCd, sggCd, + yearFilter, + start1, start2, end1, end2, + todayYear, todayMonth, todayDate, + getDateString + }); // 하수펌프장 + else if (basicType === 'tb_ms_stofcbr') cqlFilters = stofcbrCqlFilters({ + ctpvCd, sggCd, + yearFilter, + todayYear, todayMonth, todayDate, + getDateString + }); // 우수토실 if (cqlFilters.length > 0) queryParams.append('cqlFiter', cqlFilters.join(' and ')); @@ -197,178 +237,6 @@ export function useSearchModal({ open, onOpenChange, onFeatureSelect }: SearchMo } }; - // 하수관로용 CQL 필터 생성 - const pplCqlFilters = () => { - const cqlFilters: string[] = []; - // 추후 작성 예정 - if (var1) cqlFilters.push(`usg_cd='${var1}'`); - if (var2) cqlFilters.push(`mqlt_cd='${var2}'`); - if (ctpvCd !== '0' && sggCd !== '0') cqlFilters.push(`pbadms_emd_cd LIKE '${sggCd}%'`); - else if (ctpvCd !== '0') cqlFilters.push(`pbadms_emd_cd LIKE '${ctpvCd?.trim()}%'`); - // 설치년도 범위 - const startDate = getDateString( - yearFilter.start, - '', - '', - "19000101", - ); - const endDate = getDateString( - yearFilter.end, - '', - '', - `${todayYear}${todayMonth}${todayDate}`, - ); - cqlFilters.push( - `instl_ymd >= '${startDate}' and instl_ymd <= '${endDate}'`, - ); - // 관경(mm) 범위 - if (start1 && end1) cqlFilters.push(`pdmt_vl BETWEEN ${start1} AND ${end1}`); - else if (start1) cqlFilters.push(`pdmt_vl >= ${start1}`); - else if (end1) cqlFilters.push(`pdmt_vl <= ${end1}`); - // 연장(m) 범위 - if (start2 && end2) cqlFilters.push(`prlg_vl BETWEEN ${start2} AND ${end2}`); - else if (start2) cqlFilters.push(`prlg_vl >= ${start2}`); - else if (end2) cqlFilters.push(`prlg_vl <= ${end2}`); - - return cqlFilters; - }; - // 하수처리시설용 CQL 필터 생성 - const facilityCqlFilters = () => { - const cqlFilters: string[] = []; - // 가동개시일자 범위 - const startDate = getDateString( - yearFilter.start, - '', - '', - "19000101", - ); - const endDate = getDateString( - yearFilter.end, - '', - '', - `${todayYear}${todayMonth}${todayDate}`, - ); - cqlFilters.push( - `oprtng_strt_ymd >= '${startDate}' and oprtng_strt_ymd <= '${endDate}'`, - ); - // 시설용량 범위 - if (start1 && end1) - cqlFilters.push(`fclt_cpct BETWEEN ${start1} AND ${end1}`); - else if (start1) cqlFilters.push(`fclt_cpct >= ${start1}`); - else if (end1) cqlFilters.push(`fclt_cpct <= ${end1}`); - - // 시도 - if (ctpvName) cqlFilters.push(`ctpv_nm ILIKE '%${ctpvName}%'`); - if (sggName) cqlFilters.push(`sgg_nm ILIKE '%${sggName}%'`); - // // 처리구역 면적 - // if (start2 && end2) - // cqlFilters.push(`prcsZoneAreaSum BETWEEN ${start2} AND ${end2}`); - // else if (start2) cqlFilters.push(`prcsZoneAreaSum >= ${start2}`); - // else if (end2) cqlFilters.push(`prcsZoneAreaSum <= ${end2}`); - // // 하수처리시설명 - // if (var1) cqlFilters.push(`swtrmt_fclt_nm ILIKE '%${var1}%'`); - return cqlFilters; - }; - // 하수처리구역용 CQL 필터 생성 - const zoneCqlFilters = () => { - const cqlFilters: string[] = []; - if (ctpvCd !== '' && ctpvCd !== '0') cqlFilters.push(`ctpv_cd='${ctpvCd?.trim()}'`); - if (sggCd !== '' && sggCd !== '0') cqlFilters.push(`sgg_cd='${sggCd}'`); - if (var1) cqlFilters.push(`swtrmt_zone_nm ILIKE '%${var1}%'`); - if (var2) cqlFilters.push(`swtrmt_fclt_nm ILIKE '%${var2}%'`); - return cqlFilters; - }; - // 하수맨홀용 CQL 필터 생성 - const mhCqlFilters = () => { - const cqlFilters: string[] = []; - // 시도, 시군구 - if (ctpvCd !== '0' && sggCd !== '0') cqlFilters.push(`pbadms_emd_cd LIKE '${sggCd}%'`); - else if (ctpvCd !== '0') cqlFilters.push(`pbadms_emd_cd LIKE '${ctpvCd?.trim()}%'`); - // // 설치년도 범위 - const startDate = getDateString( - yearFilter.start, - '', - '', - "19000101", - ); - const endDate = getDateString( - yearFilter.end, - '', - '', - `${todayYear}${todayMonth}${todayDate}`, - ); - cqlFilters.push( - `instl_ymd >= '${startDate}' and instl_ymd <= '${endDate}'`, - ); - if (var1) cqlFilters.push(`usg_cd='${var1}'`); - // 구경(mm) 범위 - if (start1 && end1) cqlFilters.push(`swage_mhL_diam_vl BETWEEN ${start1} AND ${end1}`); - else if (start1) cqlFilters.push(`swage_mhL_diam_vl >= ${start1}`); - else if (end1) cqlFilters.push(`swage_mhL_diam_vl <= ${end1}`); - - return cqlFilters; - }; - // 하수펌프장용 CQL 필터 생성 - const psmtnCqlFilters = () => { - const cqlFilters: string[] = []; - // 시도, 시군구 - if (ctpvCd !== '0' && sggCd !== '0') cqlFilters.push(`pbadms_emd_cd LIKE '${sggCd}%'`); - else if (ctpvCd !== '0') cqlFilters.push(`pbadms_emd_cd LIKE '${ctpvCd?.trim()}%'`); - // 설치년도 범위 - const startDate = getDateString( - yearFilter.start, - '', - '', - "19000101", - ); - const endDate = getDateString( - yearFilter.end, - '', - '', - `${todayYear}${todayMonth}${todayDate}`, - ); - cqlFilters.push( - `instl_ymd >= '${startDate}' and instl_ymd <= '${endDate}'`, - ); - // 일일처리용량 범위 - if (start1 && end1) - cqlFilters.push(`daily_prcs_cpct BETWEEN ${start1} AND ${end1}`); - else if (start1) cqlFilters.push(`daily_prcs_cpct >= ${start1}`); - else if (end1) cqlFilters.push(`daily_prcs_cpct <= ${end1}`); - // 양수능력 범위 - if (start2 && end2) - cqlFilters.push(`excln_wpmp_ablt_vl BETWEEN ${start2} AND ${end2}`); - else if (start2) cqlFilters.push(`excln_wpmp_ablt_vl >= ${start2}`); - else if (end2) cqlFilters.push(`excln_wpmp_ablt_vl <= ${end2}`); - - return cqlFilters; - }; - // 우수토실용 CQL 필터 생성 - const otflCqlFilters = () => { - const cqlFilters: string[] = []; - // 시도, 시군구 - if (ctpvCd !== '0' && sggCd !== '0') cqlFilters.push(`pbadms_emd_cd LIKE '${sggCd}%'`); - else if (ctpvCd !== '0') cqlFilters.push(`pbadms_emd_cd LIKE '${ctpvCd?.trim()}%'`); - // 설치년도 범위 - const startDate = getDateString( - yearFilter.start, - '', - '', - "19000101", - ); - const endDate = getDateString( - yearFilter.end, - '', - '', - `${todayYear}${todayMonth}${todayDate}`, - ); - cqlFilters.push( - `instl_ymd >= '${startDate}' and instl_ymd <= '${endDate}'`, - ); - - return cqlFilters; - }; - // 조회 버튼 클릭 시 1페이지로 이동 및 데이터 초기화 const handleSearch = () => { setCurPage(1); // 페이지를 1로 초기화 @@ -521,42 +389,76 @@ export function useSearchModal({ open, onOpenChange, onFeatureSelect }: SearchMo switch (basicType) { case 'tb_ms_swage_ppl': { // 하수관로 - cqlFilters = pplCqlFilters() + cqlFilters = swagePplCqlFilters({ + var1, var2, + ctpvCd, sggCd, + yearFilter, + start1, start2, end1, end2, + todayYear, todayMonth, todayDate, + getDateString + }) headerMapping = MsSwagePplExcelCol; headerRange = "A1:M1"; break; } case 'tb_il_swage_prcs_fclt': { // 하수처리시설 - cqlFilters = facilityCqlFilters(); + cqlFilters = swagePrcsFcltCqlFilters({ + ctpvName, sggName, + yearFilter, + start1, end1, + todayYear, todayMonth, todayDate, + getDateString + }); headerMapping = SwtrmtFcltExcelCol; headerRange = "A1:J1"; break; } case 'tb_ms_swage_prcs_zone': { // 하수처리구역 - cqlFilters = zoneCqlFilters(); + cqlFilters = swagePrcsZoneCqlFilters({ + ctpvCd, sggCd, + var1, var2 + }); headerMapping = SwtrmtPrcsZoneExcelCol; headerRange = "A1:D1"; break; } case 'tb_ms_swage_mhl': { // 하수맨홀 - cqlFilters = mhCqlFilters(); + cqlFilters = swageMhlCqlFilters({ + ctpvCd, sggCd, + yearFilter, + start1, end1, + var1, + todayYear, todayMonth, todayDate, + getDateString + }); headerMapping = MsSwageMhlExcelCol; headerRange = "A1:J1"; break; } case 'tb_ms_swage_pmstn': { // 하수펌프장 - cqlFilters = psmtnCqlFilters(); + cqlFilters = swagePmstnCqlFilters({ + ctpvCd, sggCd, + yearFilter, + start1, start2, end1, end2, + todayYear, todayMonth, todayDate, + getDateString + }); headerMapping = ExclnSewagePumpExcelCol; headerRange = "A1:J1"; break; } case 'tb_ms_stofcbr': { // 우수토실 - cqlFilters = otflCqlFilters(); + cqlFilters = stofcbrCqlFilters({ + ctpvCd, sggCd, + yearFilter, + todayYear, todayMonth, todayDate, + getDateString + }); headerMapping = stofcbrExcelCol; headerRange = "A1:H1"; break;