feat: 可视化大屏展示
This commit is contained in:
@@ -0,0 +1,381 @@
|
||||
/**
|
||||
* 海事智慧监控服务平台 - 数据服务层
|
||||
* 提供船舶、港口、航线、气象等数据接口
|
||||
*/
|
||||
|
||||
import { request } from 'umi';
|
||||
|
||||
// 类型定义
|
||||
export interface ShipInfo {
|
||||
id: string;
|
||||
name: string;
|
||||
mmsi: string; // 海上移动业务标识
|
||||
imo?: string; // 国际海事组织编号
|
||||
callSign?: string; // 呼号
|
||||
type: 'cargo' | 'container' | 'tanker' | 'fishing' | 'passenger' | 'other';
|
||||
typeName: string;
|
||||
status: 'sailing' | 'anchored' | 'docked' | 'warning';
|
||||
position: {
|
||||
lat: number;
|
||||
lng: number;
|
||||
};
|
||||
speed: number; // 节
|
||||
course: number; // 航向
|
||||
destination?: string;
|
||||
eta?: string; // 预计到达时间
|
||||
lastUpdate: number;
|
||||
}
|
||||
|
||||
export interface MaritimeStats {
|
||||
totalShips: number;
|
||||
sailingShips: number;
|
||||
anchoredShips: number;
|
||||
dockedShips: number;
|
||||
warningShips: number;
|
||||
totalRoutes: number;
|
||||
activeRoutes: number;
|
||||
byType: Array<{ name: string; count: number }>;
|
||||
ports: PortInfo[];
|
||||
}
|
||||
|
||||
export interface PortInfo {
|
||||
id: string;
|
||||
name: string;
|
||||
code: string;
|
||||
ships: number;
|
||||
capacity: number;
|
||||
status: 'normal' | 'busy' | 'full';
|
||||
position: {
|
||||
lat: number;
|
||||
lng: number;
|
||||
};
|
||||
berthsTotal: number;
|
||||
berthsOccupied: number;
|
||||
}
|
||||
|
||||
export interface RouteInfo {
|
||||
id: string;
|
||||
name: string;
|
||||
startPort: string;
|
||||
endPort: string;
|
||||
distance: number; // 海里
|
||||
activeShips: number;
|
||||
status: 'active' | 'congested' | 'closed';
|
||||
waypoints: Array<{ lat: number; lng: number }>;
|
||||
}
|
||||
|
||||
export interface WeatherData {
|
||||
windSpeed: number; // m/s
|
||||
windDirection: string;
|
||||
windDegree: number;
|
||||
waveHeight: number; // 米
|
||||
wavePeriod: number; // 秒
|
||||
visibility: number; // 公里
|
||||
temperature: number; // 摄氏度
|
||||
humidity: number; // 百分比
|
||||
pressure: number; // 百帕
|
||||
seaTemp: number; // 海水温度
|
||||
tideHeight: number; // 潮高
|
||||
tideStatus: 'rising' | 'falling' | 'high' | 'low';
|
||||
forecast: string;
|
||||
warningLevel?: 'blue' | 'yellow' | 'orange' | 'red';
|
||||
warningMessage?: string;
|
||||
}
|
||||
|
||||
export interface MaritimeAlert {
|
||||
id: string;
|
||||
level: 'critical' | 'error' | 'warning' | 'info';
|
||||
type: 'signal' | 'route' | 'area' | 'weather' | 'collision' | 'speed' | 'other';
|
||||
typeName: string;
|
||||
shipId?: string;
|
||||
shipName?: string;
|
||||
message: string;
|
||||
description?: string;
|
||||
position?: { lat: number; lng: number };
|
||||
timestamp: number;
|
||||
acknowledged: boolean;
|
||||
acknowledgedBy?: string;
|
||||
acknowledgedAt?: number;
|
||||
}
|
||||
|
||||
export interface TrendItem {
|
||||
date: string;
|
||||
departures: number;
|
||||
arrivals: number;
|
||||
alerts: number;
|
||||
incidents?: number;
|
||||
}
|
||||
|
||||
export interface ShipMovementStats {
|
||||
period: 'day' | 'month' | 'year';
|
||||
date: string;
|
||||
arrivals: number;
|
||||
departures: number;
|
||||
throughput: number;
|
||||
averageStayHours: number;
|
||||
peakHour?: string;
|
||||
}
|
||||
|
||||
// API 接口封装
|
||||
|
||||
/**
|
||||
* 获取海事统计概览
|
||||
*/
|
||||
export async function getMaritimeStats(params?: {
|
||||
tenantId?: string;
|
||||
includeChildren?: boolean;
|
||||
}): Promise<MaritimeStats> {
|
||||
// 模拟数据,实际项目中替换为真实API调用
|
||||
// return request('/api-device/maritime/stats', { params });
|
||||
|
||||
return Promise.resolve({
|
||||
totalShips: 156,
|
||||
sailingShips: 78,
|
||||
anchoredShips: 32,
|
||||
dockedShips: 41,
|
||||
warningShips: 5,
|
||||
totalRoutes: 24,
|
||||
activeRoutes: 18,
|
||||
byType: [
|
||||
{ name: '货轮', count: 45 },
|
||||
{ name: '集装箱船', count: 38 },
|
||||
{ name: '油轮', count: 28 },
|
||||
{ name: '渔船', count: 25 },
|
||||
{ name: '客轮', count: 12 },
|
||||
{ name: '其他', count: 8 },
|
||||
],
|
||||
ports: [
|
||||
{ id: '1', name: '深圳港', code: 'SZPORT', ships: 28, capacity: 40, status: 'busy', position: { lat: 22.5, lng: 114.1 }, berthsTotal: 40, berthsOccupied: 32 },
|
||||
{ id: '2', name: '广州港', code: 'GZPORT', ships: 35, capacity: 50, status: 'normal', position: { lat: 23.1, lng: 113.3 }, berthsTotal: 50, berthsOccupied: 35 },
|
||||
{ id: '3', name: '香港港', code: 'HKPORT', ships: 22, capacity: 35, status: 'normal', position: { lat: 22.3, lng: 114.2 }, berthsTotal: 35, berthsOccupied: 22 },
|
||||
{ id: '4', name: '珠海港', code: 'ZHPORT', ships: 15, capacity: 20, status: 'busy', position: { lat: 22.3, lng: 113.6 }, berthsTotal: 20, berthsOccupied: 17 },
|
||||
],
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取船舶列表
|
||||
*/
|
||||
export async function getShipList(params?: {
|
||||
status?: string;
|
||||
type?: string;
|
||||
portId?: string;
|
||||
page?: number;
|
||||
pageSize?: number;
|
||||
}): Promise<{ list: ShipInfo[]; total: number }> {
|
||||
// return request('/api-device/maritime/ships', { params });
|
||||
|
||||
// 模拟数据
|
||||
const mockShips: ShipInfo[] = [];
|
||||
for (let i = 1; i <= 20; i++) {
|
||||
const types = ['cargo', 'container', 'tanker', 'fishing', 'passenger', 'other'] as const;
|
||||
const typeNames = ['货轮', '集装箱船', '油轮', '渔船', '客轮', '其他'];
|
||||
const statuses = ['sailing', 'anchored', 'docked'] as const;
|
||||
const typeIndex = i % 6;
|
||||
|
||||
mockShips.push({
|
||||
id: `ship-${i}`,
|
||||
name: `远洋${typeNames[typeIndex]}${i.toString().padStart(2, '0')}`,
|
||||
mmsi: `4123456${i.toString().padStart(2, '0')}`,
|
||||
type: types[typeIndex],
|
||||
typeName: typeNames[typeIndex],
|
||||
status: statuses[i % 3],
|
||||
position: {
|
||||
lat: 22.3 + Math.random() * 0.5,
|
||||
lng: 113.8 + Math.random() * 0.6,
|
||||
},
|
||||
speed: Math.floor(Math.random() * 15) + 5,
|
||||
course: Math.floor(Math.random() * 360),
|
||||
destination: ['深圳港', '广州港', '香港港'][i % 3],
|
||||
lastUpdate: Date.now() - Math.floor(Math.random() * 600000),
|
||||
});
|
||||
}
|
||||
|
||||
return Promise.resolve({ list: mockShips, total: 156 });
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取港口列表
|
||||
*/
|
||||
export async function getPortList(): Promise<PortInfo[]> {
|
||||
// return request('/api-device/maritime/ports');
|
||||
|
||||
return Promise.resolve([
|
||||
{ id: '1', name: '深圳港', code: 'SZPORT', ships: 28, capacity: 40, status: 'busy', position: { lat: 22.5, lng: 114.1 }, berthsTotal: 40, berthsOccupied: 32 },
|
||||
{ id: '2', name: '广州港', code: 'GZPORT', ships: 35, capacity: 50, status: 'normal', position: { lat: 23.1, lng: 113.3 }, berthsTotal: 50, berthsOccupied: 35 },
|
||||
{ id: '3', name: '香港港', code: 'HKPORT', ships: 22, capacity: 35, status: 'normal', position: { lat: 22.3, lng: 114.2 }, berthsTotal: 35, berthsOccupied: 22 },
|
||||
{ id: '4', name: '珠海港', code: 'ZHPORT', ships: 15, capacity: 20, status: 'busy', position: { lat: 22.3, lng: 113.6 }, berthsTotal: 20, berthsOccupied: 17 },
|
||||
{ id: '5', name: '中山港', code: 'ZSPORT', ships: 12, capacity: 18, status: 'normal', position: { lat: 22.5, lng: 113.4 }, berthsTotal: 18, berthsOccupied: 12 },
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取航线列表
|
||||
*/
|
||||
export async function getRouteList(): Promise<RouteInfo[]> {
|
||||
// return request('/api-device/maritime/routes');
|
||||
|
||||
return Promise.resolve([
|
||||
{ id: '1', name: '深圳-香港航线', startPort: '深圳港', endPort: '香港港', distance: 35, activeShips: 8, status: 'active', waypoints: [] },
|
||||
{ id: '2', name: '广州-深圳航线', startPort: '广州港', endPort: '深圳港', distance: 120, activeShips: 12, status: 'active', waypoints: [] },
|
||||
{ id: '3', name: '珠海-澳门航线', startPort: '珠海港', endPort: '澳门港', distance: 15, activeShips: 5, status: 'active', waypoints: [] },
|
||||
{ id: '4', name: '东南亚主航线', startPort: '深圳港', endPort: '新加坡', distance: 1580, activeShips: 15, status: 'active', waypoints: [] },
|
||||
{ id: '5', name: '东北亚航线', startPort: '广州港', endPort: '釜山港', distance: 1200, activeShips: 10, status: 'congested', waypoints: [] },
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取气象海况数据
|
||||
*/
|
||||
export async function getWeatherData(params?: {
|
||||
lat?: number;
|
||||
lng?: number;
|
||||
areaCode?: string;
|
||||
}): Promise<WeatherData> {
|
||||
// return request('/api-device/maritime/weather', { params });
|
||||
|
||||
return Promise.resolve({
|
||||
windSpeed: 18,
|
||||
windDirection: '东南风',
|
||||
windDegree: 135,
|
||||
waveHeight: 1.2,
|
||||
wavePeriod: 6,
|
||||
visibility: 12,
|
||||
temperature: 26,
|
||||
humidity: 78,
|
||||
pressure: 1013,
|
||||
seaTemp: 24,
|
||||
tideHeight: 2.3,
|
||||
tideStatus: 'rising',
|
||||
forecast: '多云转晴,风力3-4级',
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取海事告警列表
|
||||
*/
|
||||
export async function getMaritimeAlerts(params?: {
|
||||
level?: string;
|
||||
type?: string;
|
||||
acknowledged?: boolean;
|
||||
page?: number;
|
||||
pageSize?: number;
|
||||
}): Promise<{ list: MaritimeAlert[]; total: number }> {
|
||||
// return request('/api-device/maritime/alerts', { params });
|
||||
|
||||
const mockAlerts: MaritimeAlert[] = [
|
||||
{ id: '1', level: 'critical', type: 'signal', typeName: '信号异常', shipId: 's1', shipName: '远洋货轮01', message: 'AIS信号丢失超过30分钟', timestamp: Date.now() - 120000, acknowledged: false },
|
||||
{ id: '2', level: 'error', type: 'route', typeName: '航线偏离', shipId: 's2', shipName: '集装箱船12', message: '偏离预定航线3海里', timestamp: Date.now() - 300000, acknowledged: false },
|
||||
{ id: '3', level: 'warning', type: 'area', typeName: '区域告警', shipId: 's3', shipName: '油轮A7', message: '进入限制航行区域', timestamp: Date.now() - 600000, acknowledged: true },
|
||||
{ id: '4', level: 'warning', type: 'weather', typeName: '气象预警', message: '珠江口区域大雾预警', timestamp: Date.now() - 900000, acknowledged: false },
|
||||
{ id: '5', level: 'info', type: 'area', typeName: '区域提醒', shipId: 's5', shipName: '渔船F23', message: '即将进入港口管控区', timestamp: Date.now() - 1200000, acknowledged: true },
|
||||
];
|
||||
|
||||
return Promise.resolve({ list: mockAlerts, total: mockAlerts.length });
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取趋势数据
|
||||
*/
|
||||
export async function getTrendData(days: number = 7): Promise<TrendItem[]> {
|
||||
// return request('/api-device/maritime/trend', { params: { days } });
|
||||
|
||||
const data: TrendItem[] = [];
|
||||
const dayjs = require('dayjs');
|
||||
for (let i = days - 1; i >= 0; i--) {
|
||||
const date = dayjs().subtract(i, 'day').format('MM-DD');
|
||||
data.push({
|
||||
date,
|
||||
departures: Math.floor(Math.random() * 30) + 20,
|
||||
arrivals: Math.floor(Math.random() * 35) + 18,
|
||||
alerts: Math.floor(Math.random() * 10) + 2,
|
||||
incidents: Math.floor(Math.random() * 3),
|
||||
});
|
||||
}
|
||||
return Promise.resolve(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取船舶动态统计
|
||||
*/
|
||||
export async function getShipMovementStats(params: {
|
||||
period: 'day' | 'month' | 'year';
|
||||
date: string;
|
||||
}): Promise<ShipMovementStats> {
|
||||
// return request('/api-device/maritime/movement-stats', { params });
|
||||
|
||||
return Promise.resolve({
|
||||
period: params.period,
|
||||
date: params.date,
|
||||
arrivals: Math.floor(Math.random() * 50) + 30,
|
||||
departures: Math.floor(Math.random() * 45) + 28,
|
||||
throughput: Math.floor(Math.random() * 100) + 60,
|
||||
averageStayHours: Math.floor(Math.random() * 24) + 12,
|
||||
peakHour: '14:00-16:00',
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 确认告警
|
||||
*/
|
||||
export async function acknowledgeAlert(alertId: string): Promise<boolean> {
|
||||
// return request('/api-device/maritime/alerts/acknowledge', { method: 'POST', data: { alertId } });
|
||||
|
||||
return Promise.resolve(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取船舶详情
|
||||
*/
|
||||
export async function getShipDetail(shipId: string): Promise<ShipInfo | null> {
|
||||
// return request(`/api-device/maritime/ships/${shipId}`);
|
||||
|
||||
return Promise.resolve({
|
||||
id: shipId,
|
||||
name: '远洋货轮01',
|
||||
mmsi: '412345601',
|
||||
imo: '9123456',
|
||||
callSign: 'VRBC7',
|
||||
type: 'cargo',
|
||||
typeName: '货轮',
|
||||
status: 'sailing',
|
||||
position: { lat: 22.45, lng: 114.05 },
|
||||
speed: 12.5,
|
||||
course: 180,
|
||||
destination: '深圳港',
|
||||
eta: '2024-01-15 14:30',
|
||||
lastUpdate: Date.now() - 60000,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取年度统计数据
|
||||
*/
|
||||
export async function getAnnualStats(year?: number): Promise<Array<{ month: string; arrivals: number; departures: number }>> {
|
||||
// return request('/api-device/maritime/annual-stats', { params: { year } });
|
||||
|
||||
const data = [];
|
||||
for (let i = 1; i <= 12; i++) {
|
||||
data.push({
|
||||
month: `${i}月`,
|
||||
arrivals: Math.floor(Math.random() * 800) + 400,
|
||||
departures: Math.floor(Math.random() * 750) + 380,
|
||||
});
|
||||
}
|
||||
return Promise.resolve(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取航线分布统计
|
||||
*/
|
||||
export async function getRouteDistribution(): Promise<Array<{ type: string; value: number }>> {
|
||||
// return request('/api-device/maritime/route-distribution');
|
||||
|
||||
return Promise.resolve([
|
||||
{ type: '东南亚航线', value: 35 },
|
||||
{ type: '东北亚航线', value: 28 },
|
||||
{ type: '欧洲航线', value: 18 },
|
||||
{ type: '美洲航线', value: 12 },
|
||||
{ type: '内河航线', value: 7 },
|
||||
]);
|
||||
}
|
||||
Reference in New Issue
Block a user