Compare commits

...

1 커밋

작성자 SHA1 메시지 날짜
Nan Kyung Lee
cebe5ce06b feat(korea): 작전가이드 + 보고서 + Google TTS — KoreaDashboard 통합
- OpsGuideModal: 3탭 (실시간탐지/대응절차/조치기준)
  - 해경 기지 선택 → 주변 의심선박 자동 탐지
  - 선박 클릭 → 업종별 대응 절차 자동 표시 (PT/GN/PS/FC/GEAR)
  - 중국어 경고문 16개 (클릭: 복사, 🔊: Google TTS 음성)
  - 임검침로 점선 시각화 (해경→선박)
  - 드래그 이동 + 크기 조절
- ReportModal: 현재 데이터 기반 자동 보고서 7섹션 + 인쇄/PDF
- KoreaDashboard에 작전가이드 버튼 + 모달 연결
- KoreaMap: externalFlyTo + opsRoute props 추가
- Google TTS: Vite 프록시 /api/gtts (client=webapp)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-24 16:31:55 +09:00
5개의 변경된 파일744개의 추가작업 그리고 1개의 파일을 삭제

파일 보기

@ -4,6 +4,9 @@ import { useTranslation } from 'react-i18next';
import { useLocalStorage, useLocalStorageSet } from '../../hooks/useLocalStorage'; import { useLocalStorage, useLocalStorageSet } from '../../hooks/useLocalStorage';
import { KoreaMap } from './KoreaMap'; import { KoreaMap } from './KoreaMap';
import { FieldAnalysisModal } from './FieldAnalysisModal'; import { FieldAnalysisModal } from './FieldAnalysisModal';
import { OpsGuideModal } from './OpsGuideModal';
import type { OpsRoute } from './OpsGuideModal';
import { ReportModal } from './ReportModal';
import { LayerPanel, type LayerTreeNode } from '../common/LayerPanel'; import { LayerPanel, type LayerTreeNode } from '../common/LayerPanel';
import { EventLog } from '../common/EventLog'; import { EventLog } from '../common/EventLog';
import { LiveControls } from '../common/LiveControls'; import { LiveControls } from '../common/LiveControls';
@ -79,6 +82,10 @@ export const KoreaDashboard = ({
onTimeZoneChange, onTimeZoneChange,
}: KoreaDashboardProps) => { }: KoreaDashboardProps) => {
const [showFieldAnalysis, setShowFieldAnalysis] = useState(false); const [showFieldAnalysis, setShowFieldAnalysis] = useState(false);
const [showOpsGuide, setShowOpsGuide] = useState(false);
const [showReport, setShowReport] = useState(false);
const [opsRoute, setOpsRoute] = useState<OpsRoute | null>(null);
const [flyToTarget, setFlyToTarget] = useState<{ lat: number; lng: number; zoom: number } | null>(null);
const { t } = useTranslation(); const { t } = useTranslation();
const { hiddenAcCategories, hiddenShipCategories, toggleAcCategory, toggleShipCategory } = const { hiddenAcCategories, hiddenShipCategories, toggleAcCategory, toggleShipCategory } =
@ -293,6 +300,10 @@ export const KoreaDashboard = ({
onClick={() => setShowFieldAnalysis(v => !v)} title="현장분석"> onClick={() => setShowFieldAnalysis(v => !v)} title="현장분석">
<span className="text-[11px]">📊</span> <span className="text-[11px]">📊</span>
</button> </button>
<button type="button" className={`mode-btn ${showOpsGuide ? 'active' : ''}`}
onClick={() => setShowOpsGuide(v => !v)} title="경비함정 작전 가이드">
<span className="text-[11px]"></span>
</button>
</div>, </div>,
headerSlot, headerSlot,
)} )}
@ -312,8 +323,20 @@ export const KoreaDashboard = ({
ships={koreaData.ships} ships={koreaData.ships}
vesselAnalysis={vesselAnalysis} vesselAnalysis={vesselAnalysis}
onClose={() => setShowFieldAnalysis(false)} onClose={() => setShowFieldAnalysis(false)}
onReport={() => setShowReport(true)}
/> />
)} )}
{showOpsGuide && (
<OpsGuideModal
ships={koreaData.ships}
onClose={() => { setShowOpsGuide(false); setOpsRoute(null); }}
onFlyTo={(lat, lng, zoom) => setFlyToTarget({ lat, lng, zoom })}
onRouteSelect={setOpsRoute}
/>
)}
{showReport && (
<ReportModal ships={koreaData.ships} onClose={() => setShowReport(false)} />
)}
<KoreaMap <KoreaMap
ships={koreaFiltersResult.filteredShips} ships={koreaFiltersResult.filteredShips}
allShips={koreaData.ships} allShips={koreaData.ships}
@ -332,6 +355,9 @@ export const KoreaDashboard = ({
groupPolygons={groupPolygons} groupPolygons={groupPolygons}
hiddenShipCategories={hiddenShipCategories} hiddenShipCategories={hiddenShipCategories}
hiddenNationalities={hiddenNationalities} hiddenNationalities={hiddenNationalities}
externalFlyTo={flyToTarget}
onExternalFlyToDone={() => setFlyToTarget(null)}
opsRoute={opsRoute}
/> />
<div className="map-overlay-left"> <div className="map-overlay-left">
<LayerPanel <LayerPanel

파일 보기

@ -69,6 +69,9 @@ interface Props {
groupPolygons?: UseGroupPolygonsResult; groupPolygons?: UseGroupPolygonsResult;
hiddenShipCategories?: Set<string>; hiddenShipCategories?: Set<string>;
hiddenNationalities?: Set<string>; hiddenNationalities?: Set<string>;
externalFlyTo?: { lat: number; lng: number; zoom: number } | null;
onExternalFlyToDone?: () => void;
opsRoute?: { from: { lat: number; lng: number; name: string }; to: { lat: number; lng: number; name: string }; distanceNM: number; riskLevel: string } | null;
} }
// MarineTraffic-style: satellite + dark ocean + nautical overlay // MarineTraffic-style: satellite + dark ocean + nautical overlay
@ -144,7 +147,7 @@ const FILTER_I18N_KEY: Record<string, string> = {
cnFishing: 'filters.cnFishingMonitor', cnFishing: 'filters.cnFishingMonitor',
}; };
export function KoreaMap({ ships, allShips, aircraft, satellites, layers, osintFeed, currentTime, koreaFilters, transshipSuspects, cableWatchSuspects, dokdoWatchSuspects, dokdoAlerts, vesselAnalysis, groupPolygons, hiddenShipCategories, hiddenNationalities }: Props) { export function KoreaMap({ ships, allShips, aircraft, satellites, layers, osintFeed, currentTime, koreaFilters, transshipSuspects, cableWatchSuspects, dokdoWatchSuspects, dokdoAlerts, vesselAnalysis, groupPolygons, hiddenShipCategories, hiddenNationalities, externalFlyTo, onExternalFlyToDone, opsRoute }: Props) {
const { t } = useTranslation(); const { t } = useTranslation();
const mapRef = useRef<MapRef>(null); const mapRef = useRef<MapRef>(null);
const [infra, setInfra] = useState<PowerFacility[]>([]); const [infra, setInfra] = useState<PowerFacility[]>([]);
@ -179,6 +182,13 @@ export function KoreaMap({ ships, allShips, aircraft, satellites, layers, osintF
} }
}, [flyToTarget]); }, [flyToTarget]);
useEffect(() => {
if (externalFlyTo && mapRef.current) {
mapRef.current.flyTo({ center: [externalFlyTo.lng, externalFlyTo.lat], zoom: externalFlyTo.zoom, duration: 1500 });
onExternalFlyToDone?.();
}
}, [externalFlyTo, onExternalFlyToDone]);
useEffect(() => { useEffect(() => {
if (!selectedAnalysisMmsi) setTrackCoords(null); if (!selectedAnalysisMmsi) setTrackCoords(null);
}, [selectedAnalysisMmsi]); }, [selectedAnalysisMmsi]);
@ -926,6 +936,36 @@ export function KoreaMap({ ships, allShips, aircraft, satellites, layers, osintF
onExpandedChange={setAnalysisPanelOpen} onExpandedChange={setAnalysisPanelOpen}
/> />
)} )}
{/* 작전가이드 임검침로 점선 */}
{opsRoute && (() => {
const riskColor = opsRoute.riskLevel === 'CRITICAL' ? '#ef4444' : opsRoute.riskLevel === 'HIGH' ? '#f59e0b' : '#3b82f6';
const routeGeoJson: GeoJSON.FeatureCollection = {
type: 'FeatureCollection',
features: [{ type: 'Feature', properties: {}, geometry: { type: 'LineString', coordinates: [[opsRoute.from.lng, opsRoute.from.lat], [opsRoute.to.lng, opsRoute.to.lat]] } }],
};
const midLng = (opsRoute.from.lng + opsRoute.to.lng) / 2;
const midLat = (opsRoute.from.lat + opsRoute.to.lat) / 2;
return (
<>
<Source id="ops-route-line" type="geojson" data={routeGeoJson}>
<Layer id="ops-route-dash" type="line" paint={{ 'line-color': riskColor, 'line-width': 2.5, 'line-dasharray': [4, 4], 'line-opacity': 0.8 }} />
</Source>
<Marker longitude={opsRoute.from.lng} latitude={opsRoute.from.lat} anchor="center">
<div style={{ fontSize: 18, filter: 'drop-shadow(0 0 4px rgba(0,0,0,0.8))' }}></div>
</Marker>
<Marker longitude={opsRoute.to.lng} latitude={opsRoute.to.lat} anchor="center">
<div style={{ width: 12, height: 12, borderRadius: '50%', background: riskColor, border: '2px solid #fff', boxShadow: `0 0 8px ${riskColor}` }} />
</Marker>
<Marker longitude={midLng} latitude={midLat} anchor="bottom">
<div style={{ background: 'rgba(0,0,0,0.8)', padding: '2px 6px', borderRadius: 3, border: `1px solid ${riskColor}`, fontSize: 9, color: '#fff', fontWeight: 700, whiteSpace: 'nowrap', textAlign: 'center' }}>
{opsRoute.distanceNM.toFixed(1)} NM
<div style={{ fontSize: 7, color: riskColor }}>{opsRoute.from.name} {opsRoute.to.name}</div>
</div>
</Marker>
</>
);
})()}
</Map> </Map>
); );
} }

파일 보기

@ -0,0 +1,409 @@
import { useState, useMemo, useRef, useCallback } from 'react';
import type { Ship } from '../../types';
import { COAST_GUARD_FACILITIES, CG_TYPE_LABEL } from '../../services/coastGuard';
import type { CoastGuardFacility } from '../../services/coastGuard';
import { getMarineTrafficCategory } from '../../utils/marineTraffic';
import { analyzeFishing, classifyFishingZone } from '../../utils/fishingAnalysis';
export interface OpsRoute {
from: { lat: number; lng: number; name: string };
to: { lat: number; lng: number; name: string; mmsi: string };
distanceNM: number;
riskLevel: 'CRITICAL' | 'HIGH' | 'MEDIUM';
}
interface Props {
ships: Ship[];
onClose: () => void;
onFlyTo?: (lat: number, lng: number, zoom: number) => void;
onRouteSelect?: (route: OpsRoute | null) => void;
}
interface SuspectVessel {
ship: Ship;
distance: number;
reasons: string[];
riskLevel: 'CRITICAL' | 'HIGH' | 'MEDIUM';
estimatedType: 'PT' | 'GN' | 'PS' | 'FC' | 'GEAR' | 'UNKNOWN';
}
function haversineNM(lat1: number, lng1: number, lat2: number, lng2: number): number {
const R = 3440.065;
const dLat = (lat2 - lat1) * Math.PI / 180;
const dLng = (lng2 - lng1) * Math.PI / 180;
const a = Math.sin(dLat / 2) ** 2 + Math.cos(lat1 * Math.PI / 180) * Math.cos(lat2 * Math.PI / 180) * Math.sin(dLng / 2) ** 2;
return 2 * R * Math.asin(Math.sqrt(a));
}
const RISK_COLOR = { CRITICAL: '#ef4444', HIGH: '#f59e0b', MEDIUM: '#3b82f6' };
const RISK_ICON = { CRITICAL: '🔴', HIGH: '🟡', MEDIUM: '🔵' };
type Tab = 'detect' | 'procedure' | 'alert';
// ── 중국어 경고문 ──
const CN_WARNINGS: Record<string, { zh: string; ko: string; usage: string }[]> = {
PT: [
{ zh: '请立即停船接受检查', ko: '즉시 정선하여 검사를 받으시오', usage: 'VHF Ch.16 + 확성기' },
{ zh: '请出示捕捞许可证', ko: '어업허가증을 제시하시오', usage: '승선 검사 시' },
{ zh: '请出示作业日志', ko: '조업일지를 제시하시오', usage: '어획량 확인' },
{ zh: '你的网目不符合规定', ko: '망목이 규정에 미달합니다', usage: '어구 검사 (54mm 미만)' },
],
GN: [
{ zh: '请打开AIS', ko: 'AIS를 켜시오', usage: '다크베셀 대응' },
{ zh: '请立即停船接受检查', ko: '즉시 정선하여 검사를 받으시오', usage: 'VHF + 확성기' },
{ zh: '你在非许可区域作业', ko: '비허가 구역에서 조업 중입니다', usage: '수역 이탈 시' },
{ zh: '请立即收回渔网', ko: '어망을 즉시 회수하시오', usage: '불법 자망 발견' },
],
PS: [
{ zh: '所有船只立即停止作业', ko: '모든 선박 즉시 조업 중단', usage: '선단 제압 시' },
{ zh: '请立即停船接受检查', ko: '즉시 정선하여 검사를 받으시오', usage: 'VHF + 확성기' },
{ zh: '关闭集鱼灯', ko: '집어등을 끄시오', usage: '조명선 대응' },
{ zh: '不要试图逃跑', ko: '도주를 시도하지 마시오', usage: '도주 시' },
],
FC: [
{ zh: '请立即停船接受检查', ko: '즉시 정선하여 검사를 받으시오', usage: 'VHF + 확성기' },
{ zh: '请出示货物清单', ko: '화물 목록을 제시하시오', usage: '환적 검사' },
{ zh: '禁止转运渔获物', ko: '어획물 환적을 금지합니다', usage: '환적 현장' },
],
GEAR: [
{ zh: '这些渔具属于非法设置', ko: '이 어구는 불법 설치되었습니다', usage: '어구 수거 시' },
],
UNKNOWN: [
{ zh: '请立即停船接受检查', ko: '즉시 정선하여 검사를 받으시오', usage: '기본 경고' },
{ zh: '请打开AIS', ko: 'AIS를 켜시오', usage: '다크베셀' },
],
};
function estimateVesselType(ship: Ship): 'PT' | 'GN' | 'PS' | 'FC' | 'GEAR' | 'UNKNOWN' {
const cat = getMarineTrafficCategory(ship.typecode, ship.category);
const isGear = /[_]\d+[_]|%$/.test(ship.name);
if (isGear) return 'GEAR';
if (cat === 'cargo' || (cat === 'unspecified' && (ship.length || 0) > 50)) return 'FC';
if (cat !== 'fishing' && ship.category !== 'fishing' && ship.typecode !== '30') return 'UNKNOWN';
const spd = ship.speed || 0;
if (spd >= 7) return 'PS';
if (spd < 1.5) return 'GN';
return 'PT';
}
export function OpsGuideModal({ ships, onClose, onFlyTo, onRouteSelect }: Props) {
const [selectedKCG, setSelectedKCG] = useState<CoastGuardFacility | null>(null);
const [searchRadius, setSearchRadius] = useState(30);
const [pos, setPos] = useState({ x: 60, y: 60 });
const [tab, setTab] = useState<Tab>('detect');
const [selectedSuspect, setSelectedSuspect] = useState<SuspectVessel | null>(null);
const [copiedIdx, setCopiedIdx] = useState<number | null>(null);
const dragRef = useRef<{ startX: number; startY: number; origX: number; origY: number } | null>(null);
const onDragStart = useCallback((e: React.MouseEvent) => {
e.preventDefault();
dragRef.current = { startX: e.clientX, startY: e.clientY, origX: pos.x, origY: pos.y };
const onMove = (ev: MouseEvent) => {
if (!dragRef.current) return;
setPos({ x: dragRef.current.origX + (ev.clientX - dragRef.current.startX), y: dragRef.current.origY + (ev.clientY - dragRef.current.startY) });
};
const onUp = () => { dragRef.current = null; window.removeEventListener('mousemove', onMove); window.removeEventListener('mouseup', onUp); };
window.addEventListener('mousemove', onMove);
window.addEventListener('mouseup', onUp);
}, [pos]);
const kcgBases = useMemo(() =>
COAST_GUARD_FACILITIES.filter(f => ['hq', 'regional', 'station', 'navy'].includes(f.type)).sort((a, b) => a.name.localeCompare(b.name)),
[]);
const suspects = useMemo<SuspectVessel[]>(() => {
if (!selectedKCG) return [];
const results: SuspectVessel[] = [];
for (const ship of ships) {
if (ship.flag !== 'CN') continue;
const dist = haversineNM(selectedKCG.lat, selectedKCG.lng, ship.lat, ship.lng);
if (dist > searchRadius) continue;
const cat = getMarineTrafficCategory(ship.typecode, ship.category);
const isFishing = cat === 'fishing' || ship.category === 'fishing' || ship.typecode === '30';
const isGear = /[_]\d+[_]|%$/.test(ship.name);
const zone = classifyFishingZone(ship.lat, ship.lng);
const reasons: string[] = [];
let riskLevel: 'CRITICAL' | 'HIGH' | 'MEDIUM' = 'MEDIUM';
if (isFishing && zone.zone === 'OUTSIDE') { reasons.push('비허가 수역 진입'); riskLevel = 'CRITICAL'; }
if (isFishing && zone.zone === 'ZONE_I' && ship.speed >= 2 && ship.speed <= 5) { reasons.push('수역I 저인망 의심'); riskLevel = 'HIGH'; }
if (isFishing && ship.speed === 0 && (!ship.heading || ship.heading === 0)) { reasons.push('다크베셀 의심'); if (riskLevel === 'MEDIUM') riskLevel = 'HIGH'; }
if (isFishing && ship.speed >= 2 && ship.speed <= 6) reasons.push(`조업 추정 (${ship.speed.toFixed(1)}kn)`);
if (isGear) { reasons.push('어구/어망 AIS'); if (riskLevel === 'MEDIUM') riskLevel = 'HIGH'; }
if (!isFishing && (cat === 'cargo' || cat === 'unspecified') && ship.speed < 3) reasons.push('운반선/환적 의심');
if (reasons.length > 0) results.push({ ship, distance: dist, reasons, riskLevel, estimatedType: estimateVesselType(ship) });
}
return results.sort((a, b) => ({ CRITICAL: 0, HIGH: 1, MEDIUM: 2 }[a.riskLevel] - { CRITICAL: 0, HIGH: 1, MEDIUM: 2 }[b.riskLevel]) || a.distance - b.distance);
}, [selectedKCG, ships, searchRadius]);
const criticalCount = suspects.filter(s => s.riskLevel === 'CRITICAL').length;
const highCount = suspects.filter(s => s.riskLevel === 'HIGH').length;
const [speakingIdx, setSpeakingIdx] = useState<number | null>(null);
const copyToClipboard = (text: string, idx: number) => {
navigator.clipboard.writeText(text).then(() => { setCopiedIdx(idx); setTimeout(() => setCopiedIdx(null), 1500); });
};
const audioRef = useRef<HTMLAudioElement | null>(null);
const speakChinese = useCallback((text: string, idx: number) => {
if (audioRef.current) { audioRef.current.pause(); audioRef.current = null; }
setSpeakingIdx(idx);
const encoded = encodeURIComponent(text);
const url = `/api/gtts?ie=UTF-8&q=${encoded}&tl=zh-CN&total=1&idx=0&textlen=${text.length}&client=webapp&prev=input&ttsspeed=0.24`;
const audio = new Audio(url);
audioRef.current = audio;
audio.onended = () => setSpeakingIdx(null);
audio.onerror = () => setSpeakingIdx(null);
audio.play().catch(() => setSpeakingIdx(null));
}, []);
const handleSuspectClick = (s: SuspectVessel) => {
setSelectedSuspect(s);
setTab('procedure');
onFlyTo?.(s.ship.lat, s.ship.lng, 10);
if (selectedKCG) {
onRouteSelect?.({ from: { lat: selectedKCG.lat, lng: selectedKCG.lng, name: selectedKCG.name }, to: { lat: s.ship.lat, lng: s.ship.lng, name: s.ship.name || s.ship.mmsi, mmsi: s.ship.mmsi }, distanceNM: s.distance, riskLevel: s.riskLevel });
}
};
const TYPE_LABEL: Record<string, string> = { PT: '저인망(PT)', GN: '유자망(GN)', PS: '위망(PS)', FC: '운반선(FC)', GEAR: '어구/어망', UNKNOWN: '미분류' };
return (
<div style={{ position: 'fixed', left: pos.x, top: pos.y, zIndex: 9999, width: 760, maxHeight: '85vh', overflow: 'hidden', background: '#0a0f1a', borderRadius: 8, border: '1px solid #1e293b', display: 'flex', flexDirection: 'column', boxShadow: '0 8px 32px rgba(0,0,0,0.6)', resize: 'both' }}>
{/* Header */}
<div onMouseDown={onDragStart} style={{ display: 'flex', alignItems: 'center', gap: 8, padding: '8px 16px', borderBottom: '1px solid #1e293b', background: 'rgba(30,58,95,0.5)', cursor: 'grab', userSelect: 'none', flexShrink: 0 }}>
<span style={{ fontSize: 10, color: '#475569', letterSpacing: 2 }}></span>
<span style={{ fontSize: 14 }}></span>
<span style={{ fontSize: 13, fontWeight: 700, color: '#e2e8f0' }}> </span>
<button onClick={onClose} style={{ marginLeft: 'auto', background: 'rgba(255,82,82,0.1)', border: '1px solid rgba(255,82,82,0.4)', color: '#ef4444', padding: '4px 12px', cursor: 'pointer', fontSize: 10, borderRadius: 2 }}></button>
</div>
{/* Tabs */}
<div style={{ display: 'flex', gap: 2, padding: '4px 16px', borderBottom: '1px solid #1e293b', flexShrink: 0 }}>
{([['detect', '🔍 실시간 탐지'], ['procedure', '📋 대응 절차'], ['alert', '🚨 조치 기준']] as [Tab, string][]).map(([k, l]) => (
<button key={k} onClick={() => setTab(k)} style={{
padding: '3px 10px', fontSize: 10, fontWeight: 700, borderRadius: 3, cursor: 'pointer',
background: tab === k ? 'rgba(59,130,246,0.2)' : 'transparent',
border: tab === k ? '1px solid rgba(59,130,246,0.4)' : '1px solid transparent',
color: tab === k ? '#60a5fa' : '#64748b',
}}>{l}</button>
))}
</div>
{/* Controls (detect tab) */}
{tab === 'detect' && (
<div style={{ display: 'flex', gap: 8, padding: '6px 16px', borderBottom: '1px solid #1e293b', flexShrink: 0, alignItems: 'center', flexWrap: 'wrap' }}>
<select value={selectedKCG?.id ?? ''} onChange={e => { const f = kcgBases.find(b => b.id === Number(e.target.value)); setSelectedKCG(f || null); }} style={{ background: '#1e293b', border: '1px solid #334155', borderRadius: 4, padding: '3px 8px', fontSize: 10, color: '#e2e8f0', minWidth: 160 }}>
<option value=""> </option>
{kcgBases.map(b => <option key={b.id} value={b.id}>[{CG_TYPE_LABEL[b.type]}] {b.name}</option>)}
</select>
<select value={searchRadius} onChange={e => setSearchRadius(Number(e.target.value))} style={{ background: '#1e293b', border: '1px solid #334155', borderRadius: 4, padding: '3px 8px', fontSize: 10, color: '#e2e8f0' }}>
{[10, 20, 30, 50, 100].map(n => <option key={n} value={n}>{n} NM</option>)}
</select>
{selectedKCG && <div style={{ marginLeft: 'auto', display: 'flex', gap: 6, fontSize: 9 }}>
<span style={{ color: '#ef4444', fontWeight: 700 }}>🔴 {criticalCount}</span>
<span style={{ color: '#f59e0b', fontWeight: 700 }}>🟡 {highCount}</span>
<span style={{ color: '#3b82f6', fontWeight: 700 }}>🔵 {suspects.length}</span>
</div>}
</div>
)}
{/* Content */}
<div style={{ flex: 1, overflow: 'auto', padding: '8px 16px', minHeight: 200 }}>
{/* ── TAB: 실시간 탐지 ── */}
{tab === 'detect' && (<>
{!selectedKCG ? (
<div style={{ textAlign: 'center', padding: '30px 0', color: '#64748b', fontSize: 11 }}> · </div>
) : suspects.length === 0 ? (
<div style={{ textAlign: 'center', padding: '30px 0', color: '#22c55e', fontSize: 11 }}> {selectedKCG.name} {searchRadius}NM </div>
) : (
<div style={{ display: 'flex', flexDirection: 'column', gap: 4 }}>
{suspects.map((s, i) => (
<div key={s.ship.mmsi} onClick={() => handleSuspectClick(s)} style={{
background: '#111827', borderRadius: 4, padding: '6px 10px', borderLeft: `3px solid ${RISK_COLOR[s.riskLevel]}`, cursor: 'pointer',
}}>
<div style={{ display: 'flex', alignItems: 'center', gap: 4, fontSize: 10 }}>
<span style={{ color: '#475569', minWidth: 18 }}>#{i + 1}</span>
<span>{RISK_ICON[s.riskLevel]}</span>
<span style={{ fontSize: 8, fontWeight: 700, padding: '0 4px', borderRadius: 2, background: RISK_COLOR[s.riskLevel] + '20', color: RISK_COLOR[s.riskLevel] }}>{s.riskLevel}</span>
<span style={{ fontWeight: 700, color: '#e2e8f0' }}>{s.ship.name || s.ship.mmsi}</span>
<span style={{ fontSize: 8, color: '#64748b' }}>[{TYPE_LABEL[s.estimatedType]}]</span>
<span style={{ marginLeft: 'auto', color: '#60a5fa', fontWeight: 700 }}>{s.distance.toFixed(1)} NM</span>
</div>
<div style={{ display: 'flex', gap: 3, marginTop: 2, flexWrap: 'wrap' }}>
{s.reasons.map((r, j) => <span key={j} style={{ fontSize: 7, padding: '0 4px', borderRadius: 2, background: 'rgba(255,255,255,0.05)', color: '#94a3b8' }}>{r}</span>)}
</div>
</div>
))}
</div>
)}
</>)}
{/* ── TAB: 대응 절차 ── */}
{tab === 'procedure' && (<>
{selectedSuspect ? (
<div style={{ fontSize: 10, color: '#e2e8f0', lineHeight: 1.7 }}>
{/* 선박 정보 */}
<div style={{ background: '#111827', borderRadius: 6, padding: '8px 12px', border: `1px solid ${RISK_COLOR[selectedSuspect.riskLevel]}30`, marginBottom: 8 }}>
<div style={{ display: 'flex', alignItems: 'center', gap: 6 }}>
<span>{RISK_ICON[selectedSuspect.riskLevel]}</span>
<span style={{ fontWeight: 700, fontSize: 12 }}>{selectedSuspect.ship.name || selectedSuspect.ship.mmsi}</span>
<span style={{ fontSize: 9, padding: '1px 6px', borderRadius: 3, background: RISK_COLOR[selectedSuspect.riskLevel] + '20', color: RISK_COLOR[selectedSuspect.riskLevel], fontWeight: 700 }}>{selectedSuspect.riskLevel}</span>
<span style={{ fontSize: 9, color: '#64748b' }}>: {TYPE_LABEL[selectedSuspect.estimatedType]}</span>
</div>
<div style={{ fontSize: 9, color: '#64748b', marginTop: 2 }}>MMSI: {selectedSuspect.ship.mmsi} | SOG: {selectedSuspect.ship.speed?.toFixed(1)}kn | {selectedSuspect.distance.toFixed(1)} NM</div>
</div>
{/* 업종별 대응 절차 */}
<ProcedureSteps type={selectedSuspect.estimatedType} />
{/* 중국어 경고문 */}
<div style={{ marginTop: 12, borderTop: '1px solid #1e293b', paddingTop: 8 }}>
<div style={{ fontSize: 11, fontWeight: 700, color: '#f59e0b', marginBottom: 6 }}>📢 (클릭: 복사 | 🔊: )</div>
{(CN_WARNINGS[selectedSuspect.estimatedType] || CN_WARNINGS.UNKNOWN).map((w, i) => (
<div key={i} style={{
background: copiedIdx === i ? 'rgba(34,197,94,0.15)' : speakingIdx === i ? 'rgba(251,191,36,0.1)' : '#111827',
border: copiedIdx === i ? '1px solid rgba(34,197,94,0.4)' : speakingIdx === i ? '1px solid rgba(251,191,36,0.4)' : '1px solid #1e293b',
borderRadius: 4, padding: '6px 10px', marginBottom: 4, transition: 'all 0.2s',
display: 'flex', alignItems: 'flex-start', gap: 8,
}}>
<div style={{ flex: 1, cursor: 'pointer' }} onClick={() => copyToClipboard(w.zh, i)}>
<div style={{ fontSize: 13, fontWeight: 700, color: '#fbbf24' }}>{w.zh}</div>
<div style={{ fontSize: 9, color: '#94a3b8' }}>{w.ko}</div>
<div style={{ fontSize: 8, color: '#475569' }}>
: {w.usage}
{copiedIdx === i && <span style={{ color: '#22c55e', fontWeight: 700, marginLeft: 4 }}> </span>}
</div>
</div>
<button
onClick={(e) => { e.stopPropagation(); speakChinese(w.zh, i); }}
style={{
background: speakingIdx === i ? 'rgba(251,191,36,0.3)' : 'rgba(251,191,36,0.1)',
border: '1px solid rgba(251,191,36,0.3)',
borderRadius: 4, padding: '4px 8px', cursor: 'pointer',
fontSize: 14, lineHeight: 1, flexShrink: 0,
animation: speakingIdx === i ? 'pulse 1s ease-in-out infinite' : 'none',
}}
title="중국어 음성 재생"
>
{speakingIdx === i ? '🔊' : '🔈'}
</button>
</div>
))}
</div>
</div>
) : (
<div style={{ textAlign: 'center', padding: '30px 0', color: '#64748b', fontSize: 11 }}>
<br/>
</div>
)}
</>)}
{/* ── TAB: 조치 기준 ── */}
{tab === 'alert' && (<AlertTable />)}
</div>
{/* Footer */}
<div style={{ padding: '4px 16px', borderTop: '1px solid #1e293b', fontSize: 8, color: '#475569', flexShrink: 0 }}>
GC-KCG-2026-001 | 906 | 수역: Point-in-Polygon |
</div>
</div>
);
}
// ── 업종별 대응 절차 컴포넌트 ──
const step: React.CSSProperties = { background: '#1e293b', borderRadius: 4, padding: '6px 10px', margin: '4px 0' };
const stepN: React.CSSProperties = { display: 'inline-block', background: '#3b82f6', color: '#fff', borderRadius: 3, padding: '0 5px', fontSize: 8, fontWeight: 700, marginRight: 4 };
const warn: React.CSSProperties = { background: 'rgba(239,68,68,0.1)', border: '1px solid rgba(239,68,68,0.3)', borderRadius: 4, padding: '4px 8px', margin: '4px 0', fontSize: 9, color: '#fca5a5' };
function ProcedureSteps({ type }: { type: string }) {
switch (type) {
case 'PT': return (<>
<div style={{ fontSize: 11, fontWeight: 700, color: '#60a5fa', marginBottom: 4 }}>🔴 2 (PT) </div>
<div style={warn}> () </div>
<div style={step}><span style={stepN}>1</span><b>/</b> AIS MMSI DB . · , </div>
<div style={step}><span style={stepN}>2</span><b>/</b> 45° . VHF Ch.16 3. </div>
<div style={step}><span style={stepN}>3</span><b> </b> (C21-xxxxx) ( 100/) (54mm)</div>
<div style={step}><span style={stepN}>4</span><b> </b> (4/16~10/15) | | </div>
<div style={step}><span style={stepN}>5</span><b>/</b> 위반: 목포··· . 경미: 경고 . </div>
</>);
case 'GN': return (<>
<div style={{ fontSize: 11, fontWeight: 700, color: '#60a5fa', marginBottom: 4 }}>🟡 (GN) </div>
<div style={warn}> ( )</div>
<div style={step}><span style={stepN}>1</span><b> </b> + SAR . 1NM </div>
<div style={step}><span style={stepN}>2</span><b> </b> 90° </div>
<div style={step}><span style={stepN}>3</span><b>AIS </b> "请打开AIS" . MMSI . </div>
<div style={step}><span style={stepN}>4</span><b> </b> (C25-xxxxx) (I발견) (28/) ·</div>
<div style={step}><span style={stepN}>5</span><b> </b> /. . GPS· </div>
</>);
case 'PS': return (<>
<div style={{ fontSize: 11, fontWeight: 700, color: '#60a5fa', marginBottom: 4 }}>🟣 (PS) </div>
<div style={warn}> , . </div>
<div style={step}><span style={stepN}>1</span><b> /</b> + . 3+ . </div>
<div style={step}><span style={stepN}>2</span><b> </b> EO/. MMSI . </div>
<div style={step}><span style={stepN}>3</span><b> </b> ·· . () </div>
<div style={step}><span style={stepN}>4</span><b> </b> 모선: C23-xxxxx, 1,500/. /조명선: 0톤 </div>
<div style={step}><span style={stepN}>5</span><b>/</b> · . VHF . · </div>
</>);
case 'FC': return (<>
<div style={{ fontSize: 11, fontWeight: 700, color: '#60a5fa', marginBottom: 4 }}>🟠 (FC) </div>
<div style={step}><span style={stepN}>1</span><b> </b> FC+ 0.5NM + 2kn + 30 HIGH. </div>
<div style={step}><span style={stepN}>2</span><b> </b> / . . MMSI·· </div>
<div style={step}><span style={stepN}>3</span><b> </b> 운반선: 화물··. 조업선: 허가량 </div>
<div style={step}><span style={stepN}>4</span><b>/</b> · . . . </div>
</>);
case 'GEAR': return (<>
<div style={{ fontSize: 11, fontWeight: 700, color: '#60a5fa', marginBottom: 4 }}>🪤 </div>
<div style={warn}> / . </div>
<div style={step}><span style={stepN}>1</span><b>/</b> GPS(WGS84), , , , (··)</div>
<div style={step}><span style={stepN}>2</span><b> </b> , · . . </div>
<div style={step}><span style={stepN}>3</span><b> </b> RIB/. . · </div>
<div style={step}><span style={stepN}>4</span><b> </b> . · . </div>
</>);
default: return (<div style={{ color: '#64748b', fontSize: 10 }}> . .</div>);
}
}
function AlertTable() {
const rows = [
{ type: '미등록 선박', criteria: 'MMSI 허가DB 미등록', action: '즉시 정선·나포', level: 'CRITICAL', note: '허가증 불소지 추가 확인' },
{ type: '휴어기 조업', criteria: 'C21·C22: 4/16~10/15\nC25: 6/2~8/31', action: '즉시 나포', level: 'CRITICAL', note: '날짜 자동 판별' },
{ type: '허가 수역 이탈', criteria: '비허가 수역 진입', action: '경고 후 나포', level: 'HIGH', note: 'PT: I·IV이탈 GN: I이탈' },
{ type: 'PT 부속선 분리', criteria: '본선 이격 3NM+', action: '양선 동시 나포', level: 'HIGH→CRIT', note: '311쌍 실시간 모니터링' },
{ type: '환적 현장 포착', criteria: 'FC+조업선 0.5NM+2kn+30분', action: '촬영 후 양선 나포', level: 'HIGH', note: '증거 촬영 최우선' },
{ type: '불법 어구 발견', criteria: '표지 없음/미허가', action: '즉시 수거·기록', level: '자체판단', note: 'GPS 등록, 반복 요주의' },
{ type: '할당량 초과', criteria: '80~100%+ 초과', action: '계량·초과 시 압수', level: 'CRITICAL', note: 'GN 28톤 현장 계량' },
{ type: '다크베셀', criteria: 'AIS 공백 6시간+', action: '접근·임검', level: 'HIGH', note: 'SAR 교차 확인' },
];
const lc = (l: string) => l.includes('CRIT') ? '#ef4444' : l === 'HIGH' ? '#f59e0b' : '#64748b';
return (
<div style={{ fontSize: 10, color: '#e2e8f0' }}>
<div style={{ fontSize: 12, fontWeight: 700, color: '#60a5fa', marginBottom: 6 }}>🚨 </div>
<table style={{ borderCollapse: 'collapse', width: '100%', fontSize: 9 }}>
<thead><tr style={{ background: '#1e293b' }}>
<th style={th}> </th><th style={th}> </th><th style={th}> </th><th style={th}></th><th style={th}></th>
</tr></thead>
<tbody>
{rows.map((r, i) => (
<tr key={i}><td style={td}>{r.type}</td><td style={{ ...td, whiteSpace: 'pre-line' }}>{r.criteria}</td><td style={td}>{r.action}</td>
<td style={{ ...td, color: lc(r.level), fontWeight: 700 }}>{r.level}</td><td style={{ ...td, color: '#64748b', fontSize: 8 }}>{r.note}</td></tr>
))}
</tbody>
</table>
<div style={{ marginTop: 12, fontSize: 11, fontWeight: 700, color: '#60a5fa' }}>📅 </div>
<table style={{ borderCollapse: 'collapse', width: '100%', fontSize: 9, marginTop: 4 }}>
<thead><tr style={{ background: '#1e293b' }}><th style={th}></th><th style={th}></th><th style={th}></th></tr></thead>
<tbody>
<tr><td style={{ ...td, fontWeight: 700 }}>7~8</td><td style={td}>PS 16 </td><td style={{ ...td, color: '#ef4444' }}>C21·C22·C25 </td></tr>
<tr><td style={{ ...td, fontWeight: 700 }}>5</td><td style={td}>GN만 </td><td style={td}>(C21·C22) </td></tr>
<tr><td style={{ ...td, fontWeight: 700 }}>4·10</td><td style={td}> </td><td style={td}>4/16, 10/16 </td></tr>
<tr><td style={{ ...td, fontWeight: 700 }}>1~3</td><td style={td}> </td><td style={td}>· </td></tr>
</tbody>
</table>
</div>
);
}
const th: React.CSSProperties = { border: '1px solid #1e293b', padding: '3px 6px', textAlign: 'left', color: '#e2e8f0', fontSize: 8, fontWeight: 700 };
const td: React.CSSProperties = { border: '1px solid #1e293b', padding: '2px 6px', fontSize: 9 };

파일 보기

@ -0,0 +1,258 @@
import { useMemo, useRef } from 'react';
import type { Ship } from '../../types';
import { getMarineTrafficCategory } from '../../utils/marineTraffic';
import { aggregateFishingStats, GEAR_LABELS, classifyFishingZone } from '../../utils/fishingAnalysis';
import type { FishingGearType } from '../../utils/fishingAnalysis';
interface Props {
ships: Ship[];
onClose: () => void;
}
function now() {
const d = new Date();
return `${d.getFullYear()}.${String(d.getMonth() + 1).padStart(2, '0')}.${String(d.getDate()).padStart(2, '0')} ${String(d.getHours()).padStart(2, '0')}:${String(d.getMinutes()).padStart(2, '0')}`;
}
export function ReportModal({ ships, onClose }: Props) {
const reportRef = useRef<HTMLDivElement>(null);
const timestamp = useMemo(() => now(), []);
// Ship statistics
const stats = useMemo(() => {
const kr = ships.filter(s => s.flag === 'KR');
const cn = ships.filter(s => s.flag === 'CN');
const cnFishing = cn.filter(s => {
const cat = getMarineTrafficCategory(s.typecode, s.category);
return cat === 'fishing' || s.category === 'fishing' || s.typecode === '30';
});
// CN fishing by speed
const cnAnchored = cnFishing.filter(s => s.speed < 1);
const cnLowSpeed = cnFishing.filter(s => s.speed >= 1 && s.speed < 3);
const cnOperating = cnFishing.filter(s => s.speed >= 2 && s.speed <= 6);
const cnSailing = cnFishing.filter(s => s.speed > 6);
// Gear analysis
const fishingStats = aggregateFishingStats(cn);
// Zone analysis
const zoneStats: Record<string, number> = { ZONE_I: 0, ZONE_II: 0, ZONE_III: 0, ZONE_IV: 0, OUTSIDE: 0 };
cnFishing.forEach(s => {
const z = classifyFishingZone(s.lat, s.lng);
zoneStats[z.zone] = (zoneStats[z.zone] || 0) + 1;
});
// Dark vessels (AIS gap)
const darkSuspect = cnFishing.filter(s => s.speed === 0 && (!s.heading || s.heading === 0));
// Ship types
const byType: Record<string, number> = {};
ships.forEach(s => {
const cat = getMarineTrafficCategory(s.typecode, s.category);
byType[cat] = (byType[cat] || 0) + 1;
});
// By nationality top 10
const byFlag: Record<string, number> = {};
ships.forEach(s => { byFlag[s.flag || 'unknown'] = (byFlag[s.flag || 'unknown'] || 0) + 1; });
const topFlags = Object.entries(byFlag).sort((a, b) => b[1] - a[1]).slice(0, 10);
return { total: ships.length, kr, cn, cnFishing, cnAnchored, cnLowSpeed, cnOperating, cnSailing, fishingStats, zoneStats, darkSuspect, byType, topFlags };
}, [ships]);
const handlePrint = () => {
const content = reportRef.current;
if (!content) return;
const win = window.open('', '_blank');
if (!win) return;
win.document.write(`
<html><head><title> - ${timestamp}</title>
<style>
body { font-family: 'Malgun Gothic', sans-serif; padding: 40px; color: #1a1a1a; line-height: 1.8; font-size: 12px; }
h1 { font-size: 20px; border-bottom: 2px solid #1e3a5f; padding-bottom: 8px; color: #1e3a5f; }
h2 { font-size: 15px; color: #1e3a5f; margin-top: 24px; border-left: 4px solid #1e3a5f; padding-left: 8px; }
h3 { font-size: 13px; color: #333; margin-top: 16px; }
table { border-collapse: collapse; width: 100%; margin: 8px 0; font-size: 11px; }
th, td { border: 1px solid #ccc; padding: 4px 8px; text-align: left; }
th { background: #1e3a5f; color: #fff; font-weight: 700; }
tr:nth-child(even) { background: #f5f7fa; }
.badge { display: inline-block; padding: 1px 6px; border-radius: 3px; font-size: 10px; font-weight: 700; }
.critical { background: #dc2626; color: #fff; }
.high { background: #f59e0b; color: #000; }
.medium { background: #3b82f6; color: #fff; }
.footer { margin-top: 30px; font-size: 9px; color: #888; border-top: 1px solid #ddd; padding-top: 8px; }
@media print { body { padding: 20px; } }
</style></head><body>${content.innerHTML}</body></html>
`);
win.document.close();
win.print();
};
const gearEntries = Object.entries(stats.fishingStats.byGear) as [FishingGearType, number][];
return (
<div style={{
position: 'fixed', inset: 0, zIndex: 9999,
background: 'rgba(0,0,0,0.7)', display: 'flex', alignItems: 'center', justifyContent: 'center',
}} onClick={onClose}>
<div
style={{
width: '90vw', maxWidth: 900, maxHeight: '90vh', overflow: 'auto',
background: '#0f172a', borderRadius: 8, border: '1px solid rgba(99,179,237,0.3)',
}}
onClick={e => e.stopPropagation()}
>
{/* Toolbar */}
<div style={{
display: 'flex', alignItems: 'center', gap: 8,
padding: '8px 16px', borderBottom: '1px solid rgba(255,255,255,0.1)',
background: 'rgba(30,58,95,0.5)',
}}>
<span style={{ fontSize: 14 }}>📋</span>
<span style={{ fontSize: 13, fontWeight: 700, color: '#e2e8f0' }}> </span>
<span style={{ fontSize: 9, color: '#64748b' }}>{timestamp} </span>
<div style={{ marginLeft: 'auto', display: 'flex', gap: 6 }}>
<button onClick={handlePrint} style={{
background: '#3b82f6', border: 'none', borderRadius: 4,
padding: '4px 12px', fontSize: 10, fontWeight: 700, color: '#fff', cursor: 'pointer',
}}>🖨 / PDF</button>
<button onClick={onClose} style={{
background: '#334155', border: 'none', borderRadius: 4,
padding: '4px 12px', fontSize: 10, fontWeight: 700, color: '#94a3b8', cursor: 'pointer',
}}> </button>
</div>
</div>
{/* Report Content */}
<div ref={reportRef} style={{ padding: '16px 24px', color: '#cbd5e1', fontSize: 11, lineHeight: 1.7 }}>
<h1 style={{ fontSize: 18, color: '#60a5fa', borderBottom: '2px solid #1e3a5f', paddingBottom: 6 }}>
</h1>
<div style={{ fontSize: 9, color: '#64748b', marginBottom: 12 }}>
문서번호: GC-KCG-RPT-AUTO | : {timestamp} | 작성: KCG AI |
</div>
{/* 1. 전체 현황 */}
<h2 style={{ fontSize: 14, color: '#60a5fa', borderLeft: '3px solid #3b82f6', paddingLeft: 8, marginTop: 16 }}>1. </h2>
<table style={{ borderCollapse: 'collapse', width: '100%', fontSize: 10 }}>
<thead><tr style={{ background: '#1e293b' }}>
<th style={thStyle}></th><th style={thStyle}></th><th style={thStyle}></th>
</tr></thead>
<tbody>
<tr><td style={tdStyle}> </td><td style={tdBold}>{stats.total.toLocaleString()}</td><td style={tdStyle}>100%</td></tr>
<tr><td style={tdStyle}>🇰🇷 </td><td style={tdBold}>{stats.kr.length.toLocaleString()}</td><td style={tdStyle}>{pct(stats.kr.length, stats.total)}</td></tr>
<tr><td style={tdStyle}>🇨🇳 </td><td style={tdBold}>{stats.cn.length.toLocaleString()}</td><td style={tdStyle}>{pct(stats.cn.length, stats.total)}</td></tr>
<tr style={{ background: '#1e293b' }}><td style={tdStyle}>🇨🇳 </td><td style={{ ...tdBold, color: '#f59e0b' }}>{stats.cnFishing.length.toLocaleString()}</td><td style={tdStyle}>{pct(stats.cnFishing.length, stats.total)}</td></tr>
</tbody>
</table>
{/* 2. 중국어선 상세 */}
<h2 style={h2Style}>2. </h2>
<table style={tableStyle}>
<thead><tr style={{ background: '#1e293b' }}>
<th style={thStyle}> </th><th style={thStyle}></th><th style={thStyle}></th><th style={thStyle}> </th>
</tr></thead>
<tbody>
<tr><td style={tdStyle}> (0~1kn)</td><td style={tdBold}>{stats.cnAnchored.length}</td><td style={tdStyle}>{pct(stats.cnAnchored.length, stats.cnFishing.length)}</td><td style={tdDim}>SOG {'<'} 1 knot</td></tr>
<tr><td style={tdStyle}>🔵 (1~3kn)</td><td style={tdBold}>{stats.cnLowSpeed.length}</td><td style={tdStyle}>{pct(stats.cnLowSpeed.length, stats.cnFishing.length)}</td><td style={tdDim}>· </td></tr>
<tr style={{ background: 'rgba(245,158,11,0.1)' }}><td style={tdStyle}>🟡 (2~6kn)</td><td style={{ ...tdBold, color: '#f59e0b' }}>{stats.cnOperating.length}</td><td style={tdStyle}>{pct(stats.cnOperating.length, stats.cnFishing.length)}</td><td style={tdDim}>/ </td></tr>
<tr><td style={tdStyle}>🟢 (6+kn)</td><td style={tdBold}>{stats.cnSailing.length}</td><td style={tdStyle}>{pct(stats.cnSailing.length, stats.cnFishing.length)}</td><td style={tdDim}>/</td></tr>
</tbody>
</table>
{/* 3. 어구별 분석 */}
<h2 style={h2Style}>3. / </h2>
<table style={tableStyle}>
<thead><tr style={{ background: '#1e293b' }}>
<th style={thStyle}> </th><th style={thStyle}> </th><th style={thStyle}></th><th style={thStyle}> </th>
</tr></thead>
<tbody>
{gearEntries.map(([gear, count]) => {
const meta = GEAR_LABELS[gear];
return (
<tr key={gear}>
<td style={tdStyle}><span style={{ color: meta?.color || '#888' }}>{meta?.icon || '🎣'}</span> {meta?.label || gear}</td>
<td style={tdBold}>{count}</td>
<td style={tdStyle}>{meta?.riskLevel === 'CRITICAL' ? '◉ CRITICAL' : meta?.riskLevel === 'HIGH' ? '⚠ HIGH' : '△ MED'}</td>
<td style={tdStyle}>{meta?.confidence || '-'}</td>
</tr>
);
})}
</tbody>
</table>
{/* 4. 수역별 분포 */}
<h2 style={h2Style}>4. </h2>
<table style={tableStyle}>
<thead><tr style={{ background: '#1e293b' }}>
<th style={thStyle}></th><th style={thStyle}> </th><th style={thStyle}> (3)</th><th style={thStyle}></th>
</tr></thead>
<tbody>
<tr><td style={tdStyle}> I ()</td><td style={tdBold}>{stats.zoneStats.ZONE_I}</td><td style={tdDim}>PS, FC만</td><td style={tdDim}>PT/OT/GN </td></tr>
<tr><td style={tdStyle}> II ()</td><td style={tdBold}>{stats.zoneStats.ZONE_II}</td><td style={tdDim}> </td><td style={tdDim}>-</td></tr>
<tr><td style={tdStyle}> III ()</td><td style={tdBold}>{stats.zoneStats.ZONE_III}</td><td style={tdDim}> </td><td style={tdDim}> </td></tr>
<tr><td style={tdStyle}> IV ()</td><td style={tdBold}>{stats.zoneStats.ZONE_IV}</td><td style={tdDim}>GN, PS, FC</td><td style={tdDim}>PT/OT </td></tr>
<tr style={{ background: 'rgba(239,68,68,0.1)' }}><td style={tdStyle}> </td><td style={{ ...tdBold, color: '#ef4444' }}>{stats.zoneStats.OUTSIDE}</td><td style={tdDim}>-</td><td style={{ ...tdDim, color: '#ef4444' }}> </td></tr>
</tbody>
</table>
{/* 5. 위험 분석 */}
<h2 style={h2Style}>5. </h2>
<table style={tableStyle}>
<thead><tr style={{ background: '#1e293b' }}>
<th style={thStyle}> </th><th style={thStyle}> </th><th style={thStyle}></th>
</tr></thead>
<tbody>
<tr><td style={tdStyle}> </td><td style={tdBold}>{stats.darkSuspect.length}</td><td style={tdStyle}><span style={{ ...badgeStyle, background: stats.darkSuspect.length > 10 ? '#dc2626' : '#f59e0b' }}>{stats.darkSuspect.length > 10 ? 'HIGH' : 'MEDIUM'}</span></td></tr>
<tr><td style={tdStyle}> </td><td style={tdBold}>{stats.zoneStats.OUTSIDE}</td><td style={tdStyle}><span style={{ ...badgeStyle, background: stats.zoneStats.OUTSIDE > 0 ? '#dc2626' : '#22c55e' }}>{stats.zoneStats.OUTSIDE > 0 ? 'CRITICAL' : 'NORMAL'}</span></td></tr>
<tr><td style={tdStyle}> </td><td style={tdBold}>{stats.cnOperating.length}</td><td style={tdStyle}><span style={{ ...badgeStyle, background: '#3b82f6' }}>MONITOR</span></td></tr>
</tbody>
</table>
{/* 6. 국적별 현황 */}
<h2 style={h2Style}>6. (TOP 10)</h2>
<table style={tableStyle}>
<thead><tr style={{ background: '#1e293b' }}>
<th style={thStyle}></th><th style={thStyle}></th><th style={thStyle}></th><th style={thStyle}></th>
</tr></thead>
<tbody>
{stats.topFlags.map(([flag, count], i) => (
<tr key={flag}><td style={tdStyle}>{i + 1}</td><td style={tdStyle}>{flag}</td><td style={tdBold}>{count.toLocaleString()}</td><td style={tdStyle}>{pct(count, stats.total)}</td></tr>
))}
</tbody>
</table>
{/* 7. 건의사항 */}
<h2 style={h2Style}>7. </h2>
<div style={{ fontSize: 10, color: '#94a3b8', paddingLeft: 12 }}>
<p>1. 3 , <strong style={{ color: '#f59e0b' }}> - </strong> </p>
<p>2. {stats.darkSuspect.length} <strong style={{ color: '#ef4444' }}>SAR </strong> </p>
<p>3. {stats.zoneStats.OUTSIDE} <strong style={{ color: '#ef4444' }}> </strong> </p>
<p>4. 4/16 <strong> </strong> </p>
<p>5. 16 <strong> </strong> </p>
</div>
{/* Footer */}
<div style={{ marginTop: 24, paddingTop: 8, borderTop: '1px solid rgba(255,255,255,0.1)', fontSize: 8, color: '#475569' }}>
KCG . | : {timestamp} | 데이터: 실시간 AIS | 분석: AI |
</div>
</div>
</div>
</div>
);
}
// Styles
const h2Style: React.CSSProperties = { fontSize: 13, color: '#60a5fa', borderLeft: '3px solid #3b82f6', paddingLeft: 8, marginTop: 20 };
const tableStyle: React.CSSProperties = { borderCollapse: 'collapse', width: '100%', fontSize: 10, marginTop: 6 };
const thStyle: React.CSSProperties = { border: '1px solid #334155', padding: '4px 8px', textAlign: 'left', color: '#e2e8f0', fontSize: 9, fontWeight: 700 };
const tdStyle: React.CSSProperties = { border: '1px solid #1e293b', padding: '3px 8px', fontSize: 10 };
const tdBold: React.CSSProperties = { ...tdStyle, fontWeight: 700, color: '#e2e8f0' };
const tdDim: React.CSSProperties = { ...tdStyle, color: '#64748b', fontSize: 9 };
const badgeStyle: React.CSSProperties = { display: 'inline-block', padding: '1px 6px', borderRadius: 3, fontSize: 9, fontWeight: 700, color: '#fff' };
function pct(n: number, total: number): string {
if (!total) return '-';
return `${((n / total) * 100).toFixed(1)}%`;
}

파일 보기

@ -115,6 +115,16 @@ export default defineConfig(({ mode }): UserConfig => ({
changeOrigin: true, changeOrigin: true,
rewrite: (path) => path.replace(/^\/ollama/, ''), rewrite: (path) => path.replace(/^\/ollama/, ''),
}, },
'/api/gtts': {
target: 'https://translate.google.com',
changeOrigin: true,
rewrite: (path) => path.replace(/^\/api\/gtts/, '/translate_tts'),
secure: true,
headers: {
'Referer': 'https://translate.google.com/',
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36',
},
},
}, },
}, },
})) }))