From f5051225ead19c6adead0d43cec1403103977864 Mon Sep 17 00:00:00 2001 From: kiminchan Date: Tue, 18 Aug 2026 17:28:48 +0900 Subject: [PATCH] =?UTF-8?q?=ED=86=B5=EC=88=98=EC=9C=84=ED=97=98=20?= =?UTF-8?q?=EA=B2=B0=EA=B3=BC=EC=A1=B0=ED=9A=8C=20=EB=B0=8F=20=EC=A7=80?= =?UTF-8?q?=EB=8F=84=20=EC=8B=9C=EA=B0=81=ED=99=94=20=ED=94=84=EB=A1=9C?= =?UTF-8?q?=ED=86=A0=ED=83=80=EC=9E=85=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../waterRisk/WaterRiskPopupPage.tsx | 201 +++-- .../components/waterRisk/waterRiskClient.ts | 12 +- .../components/waterRisk/waterRiskTypes.ts | 692 +----------------- apps/sn/app/(map-layout)/map/page.tsx | 425 ++++------- .../002-qa-SFR-011-007-통수위험분석-통합검증결과.md | 45 ++ .../001-fe-SFR-011-007-통수위험분석-통합구현기록.md | 41 ++ .../windowPopup/model/popupDefinitions.ts | 4 +- 7 files changed, 399 insertions(+), 1021 deletions(-) diff --git a/apps/sn/app/(map-layout)/map/components/waterRisk/WaterRiskPopupPage.tsx b/apps/sn/app/(map-layout)/map/components/waterRisk/WaterRiskPopupPage.tsx index 108a3a549..44daaa965 100644 --- a/apps/sn/app/(map-layout)/map/components/waterRisk/WaterRiskPopupPage.tsx +++ b/apps/sn/app/(map-layout)/map/components/waterRisk/WaterRiskPopupPage.tsx @@ -1,14 +1,14 @@ "use client"; import { useEffect, useMemo, useState } from "react"; -import UiPageNations from "@common/business_components/ui/table/uiPageNations"; - -import { Button } from "@common/components"; import { WINDOW_POPUP_MESSAGE_TYPE, type WindowPopupContentProps, } from "@/features/windowPopup/model/types"; +import UiPageNations from "@common/business_components/ui/table/uiPageNations"; +import { Button } from "@common/components"; + import { fetchWaterRiskAreas, fetchWaterRiskMapView, @@ -37,6 +37,7 @@ type ResultFilters = { const WATER_RISK_PAGE_SIZE = 10; const EMPTY_RESULT_PAGE: WaterRiskResultPage = { items: [], + analysisBaseAt: null, total: 0, page: 0, size: WATER_RISK_PAGE_SIZE, @@ -51,12 +52,26 @@ const formatLocalDate = (date: Date) => { return `${year}-${month}-${day}`; }; -/** 화면을 연 날짜를 현재 위험 기본 조회일로 사용한다. */ +/** 현재 로컬시각을 API가 조회할 정시 yyyy-MM-ddTHH:00:00으로 내림한다. */ +const formatCurrentAnalysisHour = (date: Date) => + `${formatLocalDate(date)}T${String(date.getHours()).padStart(2, "0")}:00:00`; + +/** API 분석기준시간을 화면의 yyyy.MM.dd HH:mm 형식으로 표시한다. */ +const formatAnalysisBaseAt = (value?: string | null) => { + if (!value || value === "-") return "-"; + const normalized = value.replace("T", " "); + const [date = "", time = ""] = normalized.split(" "); + return `${date.replaceAll("-", ".")} ${time.slice(0, 5)}`.trim(); +}; + +/** 개발 DB의 과거 시험자료와 운영 최신자료를 함께 찾도록 최근 1년을 기본 조회기간으로 사용한다. */ const buildDefaultResultFilters = (): ResultFilters => { - const today = formatLocalDate(new Date()); + const endDate = new Date(); + const startDate = new Date(endDate); + startDate.setDate(startDate.getDate() - 365); return { - startDate: today, - endDate: today, + startDate: formatLocalDate(startDate), + endDate: formatLocalDate(endDate), ctpvCd: "ALL", sggCd: "ALL", areaId: "ALL", @@ -95,6 +110,9 @@ export default function WaterRiskPopupPage(_props: WindowPopupContentProps) { const [selectedResultKey, setSelectedResultKey] = useState(""); const [resultCurrentPage, setResultCurrentPage] = useState(1); const [reloadVersion, setReloadVersion] = useState(0); + const [currentAnalysisBaseAt, setCurrentAnalysisBaseAt] = useState(() => + formatCurrentAnalysisHour(new Date()), + ); const [isLoading, setIsLoading] = useState(false); const [isMapLoading, setIsMapLoading] = useState(false); const [noticeMessage, setNoticeMessage] = useState(""); @@ -126,12 +144,13 @@ export default function WaterRiskPopupPage(_props: WindowPopupContentProps) { fetchWaterRiskResults({ startDate: appliedResultFilters.startDate, endDate: appliedResultFilters.endDate, + analysisBaseAt: resultMode === "current" ? currentAnalysisBaseAt : undefined, ctpvCd: - appliedResultFilters.ctpvCd === "ALL" + resultMode === "current" || appliedResultFilters.ctpvCd === "ALL" ? undefined : appliedResultFilters.ctpvCd, sggCd: - appliedResultFilters.sggCd === "ALL" + resultMode === "current" || appliedResultFilters.sggCd === "ALL" ? undefined : appliedResultFilters.sggCd, areaId: @@ -139,18 +158,17 @@ export default function WaterRiskPopupPage(_props: WindowPopupContentProps) { ? undefined : appliedResultFilters.areaId, riskStatus: - appliedResultFilters.riskStatus === "ALL" + resultMode === "current" || appliedResultFilters.riskStatus === "ALL" ? undefined : appliedResultFilters.riskStatus, + rainEventStatus: resultMode === "current" ? "IN_PROGRESS" : "ENDED", page: resultCurrentPage - 1, size: WATER_RISK_PAGE_SIZE, }) .then((page) => { if (!active) return; setResultPage(page); - if (page.items.length > 0) { - setSelectedResultKey((current) => current || buildResultRowKey(page.items[0]!)); - } + setSelectedResultKey(page.items[0] ? buildResultRowKey(page.items[0]) : ""); }) .catch((error) => { if (!active) return; @@ -167,7 +185,7 @@ export default function WaterRiskPopupPage(_props: WindowPopupContentProps) { return () => { active = false; }; - }, [appliedResultFilters, reloadVersion, resultCurrentPage]); + }, [appliedResultFilters, currentAnalysisBaseAt, reloadVersion, resultCurrentPage, resultMode]); useEffect(() => { const handleMessage = (event: MessageEvent) => { @@ -193,9 +211,30 @@ export default function WaterRiskPopupPage(_props: WindowPopupContentProps) { useEffect(() => { if (typeof window === "undefined" || !window.resizeTo) return; - window.resizeTo(1180, 720); + window.resizeTo(1360, 600); }, []); + /** 현재 탭의 표시·조회 기준시간을 매 정시에 새 현재시간으로 변경한다. */ + useEffect(() => { + if (resultMode !== "current" || typeof window === "undefined") return; + + let intervalId: number | undefined; + const applyCurrentHour = () => setCurrentAnalysisBaseAt(formatCurrentAnalysisHour(new Date())); + applyCurrentHour(); + const now = new Date(); + const nextRefreshAt = new Date(now); + nextRefreshAt.setHours(now.getHours() + 1, 0, 0, 0); + const timeoutId = window.setTimeout(() => { + applyCurrentHour(); + intervalId = window.setInterval(applyCurrentHour, 60 * 60 * 1000); + }, Math.max(0, nextRefreshAt.getTime() - now.getTime())); + + return () => { + window.clearTimeout(timeoutId); + if (intervalId != null) window.clearInterval(intervalId); + }; + }, [resultMode]); + const ctpvOptions = useMemo(() => { const unique = new Map(); areaOptions.forEach((option) => { @@ -234,7 +273,7 @@ export default function WaterRiskPopupPage(_props: WindowPopupContentProps) { [areaOptions, draftResultFilters.ctpvCd, draftResultFilters.sggCd], ); - const resultTableMinWidth = resultMode === "current" ? 1140 : 1060; + const resultTableMinWidth = 1240; /** 검증된 검색조건을 적용하고 첫 페이지를 새로 조회한다. */ const handleApplyResultFilters = () => { @@ -253,10 +292,12 @@ export default function WaterRiskPopupPage(_props: WindowPopupContentProps) { setNoticeMessage("통수위험 분석 결과를 조회했습니다."); }; - /** 현재 위험과 과거 이력 표시열만 전환하고 같은 API 검색조건은 유지한다. */ + /** 강우이벤트 상태에 따라 진행중 현재 위험과 종료된 과거 이력을 다시 조회한다. */ const handleChangeResultMode = (mode: WaterRiskResultMode) => { setResultMode(mode); setResultCurrentPage(1); + setResultPage(EMPTY_RESULT_PAGE); + setSelectedResultKey(""); setNoticeMessage(""); }; @@ -302,7 +343,7 @@ export default function WaterRiskPopupPage(_props: WindowPopupContentProps) { }`} onClick={() => handleChangeResultMode("current")} > - 현재 위험 + 현재 + {resultMode === "current" ? ( +
+ 분석기준시간 + + {formatAnalysisBaseAt(currentAnalysisBaseAt)} + +
+ ) : null}
-
-