23 Commits

Author SHA1 Message Date
mmc
8f1b0d287b 增加机器数据报表 2026-09-23 10:52:18 +08:00
mmc
a9dce184ae 文档 2026-09-23 09:51:31 +08:00
mmc
2f61297bea shanchu 2026-09-03 13:39:42 +08:00
mmc
fd4e374add 优化细节 2026-09-03 13:38:44 +08:00
mmc
736645ac18 添加问号 优化错误 2026-09-02 15:38:05 +08:00
mmc
1d681316a7 地图飞过去 2026-09-02 15:13:22 +08:00
mmc
91fd8a3457 切换到在线资源 2026-09-02 15:07:08 +08:00
mmc
9bf683e9c9 场站映射 2026-09-02 10:45:43 +08:00
mmc
c2bf8adbec 修改 2026-09-02 09:34:59 +08:00
mmc
93d9bc648f 中文优化 2026-08-31 17:04:26 +08:00
mmc
ac60263a6c 修复 2026-08-31 14:56:09 +08:00
mmc
ce924ddf66 修复地图 2026-08-31 14:46:29 +08:00
mmc
f342bc7648 绑定 2026-08-31 14:38:52 +08:00
mmc
f318cba0b3 修复 控制台警告信息 图标大小在初始化 会警告 长宽-1 2026-08-31 14:23:47 +08:00
mmc
60583074bf 修复admin可以看到所有用户 2026-08-31 14:21:29 +08:00
mmc
2b887270b9 修复地图中 鼠标悬浮显示机器 优化显示登录用用户的角色 2026-08-31 14:21:29 +08:00
mmc
46c5236731 修复 地图 地址 2026-08-31 12:45:16 +08:00
mmc
2d30219a49 用户角色概览 2026-08-21 15:40:57 +08:00
mmc
54eebdfd15 基础设置中角色概览 2026-08-21 11:08:18 +08:00
mmc
4710b24ef3 电站地址接入 2026-08-21 09:45:02 +08:00
mmc
6b527bc316 中英文优化 2026-08-19 11:17:58 +08:00
mmc
98500d14ff 路由组件拆分 2026-08-19 11:15:44 +08:00
mmc
c611b2a2dc 登录默认选中 2026-08-19 11:15:10 +08:00
41 changed files with 1764 additions and 2312 deletions

View File

@@ -1,19 +0,0 @@
# 2026-09-04
### 任务1:补全 SOP v2.0 文档
- 源文件:D:\工作\绩效文档\202609\机器人智慧服务系统_SOP_v2.0_目录可点击.docx
- 输出:同上 _已完善.docx
- 工作内容:
- 为 19 章 + 5 附录共 24 个标题插入 Word 书签
- 将目录条目改造为内部超链接(HYPERLINK \\l 锚点)
- 用 matplotlib 生成 27 张界面示意图,替换所有【截图 X-Y】占位符
- 在登录、监控、设备控制、任务控制、AI 编排等关键位置补充 💡 使用提示
- 工具:python-docx + matplotlib + Pillow,隔离 venv:C:\Users\15563\.workbuddy\binaries\python\envs\sopenv
### 任务2:编写版本发布说明(V2.4.1 / V2.4.0 / V2.3.x)
- 输出:D:\工作\绩效文档\202609\机器人智慧服务系统_版本发布说明_V2.4.1.docx(42.9 KB)
- 工作内容:
- 基于 git log 三个分支(master / feat-suanfaceshi-0817 / feat-yanshi0821 / feat-lazyLoad-0602)梳理实际迭代历史
- 覆盖三个发布版本,含 1.1-1.6 / 2.1-2.6 / 3.1-3.5 完整结构
- 含 1 张能力对比表(4 列 14 行)
- 22 个 Word 书签便于跨文档引用

Binary file not shown.

19
env.js
View File

@@ -9,21 +9,15 @@ const currentEnv = import.meta.env?.MODE || process.env.NODE_ENV;
// 环境配置映射
const envConfig = {
[ENV.DEV]: {
//baseURL: 'http://1.95.137.212:8081',//http://192.168.2.56:8081
baseURL: 'http://1.95.137.212:59003',//http://192.168.2.56:8081
//baseURL: 'http://192.168.2.59:8081',//http://192.168.2.56:8081
////baseURL: 'http://1.95.137.212:59015',//http://192.168.2.56:8081
//WS_URL: 'ws://192.168.2.59:9002/ws/',
//mqtt_url: "ws://1.95.137.212:8083/mqtt",
//geoserver_url: "http://192.168.2.59:7000/geoserver"
//baseURL: 'http://1.95.137.212:8081',//http://192.168.2.56:8081
//baseURL: 'http://192.168.2.62:8081',//http://192.168.2.56:8081
WS_URL: 'ws://1.95.137.212:59005/ws/',
baseURL: 'http://1.95.137.212:8081',//http://192.168.2.56:8081
//baseURL: 'https://serviceri.satabot.com',
//WS_URL: 'ws://1.95.137.212:9002/ws/',
//WS_URL: 'ws://192.168.2.62:9002/ws/',
WS_URL: 'ws://1.95.137.212:9002/ws/',
mqtt_url: "ws://1.95.137.212:8083/mqtt",
geoserver_url: "http://1.95.137.212:7900/geoserver"
@@ -41,13 +35,10 @@ const envConfig = {
//mqtt_url: "ws://1.95.137.212:8083/mqtt",
//geoserver_url: "http://1.95.137.212:59018/geoserver"
baseURL: 'http://1.95.137.212:59003',//http://192.168.2.56:8081
WS_URL: 'ws://1.95.137.212:59005/ws/',
//baseURL: 'http://1.95.137.212:8081',//http://192.168.2.56:8081
baseURL: 'http://1.95.137.212:8081',//http://192.168.2.56:8081
//baseURL: 'https://serviceri.satabot.com',
//WS_URL: 'ws://1.95.137.212:9002/ws/',
WS_URL: 'ws://1.95.137.212:9002/ws/',
mqtt_url: "ws://1.95.137.212:8083/mqtt",
geoserver_url: "http://1.95.137.212:7900/geoserver"
},

View File

@@ -61,4 +61,3 @@ export default function App() {
</I18nextProvider>
);
}

View File

@@ -198,19 +198,6 @@ export function unbindSmartDevice(data) {
})
}
// 批量导入绑定智能装备(上传 Excel)
// 上传文件必须用 data(FormData)且带 multipart/form-data 头
export function importBindDevices(data) {
return request({
url: '/iot/deviceRunParam/importData',
method: 'post',
data,
headers: {
'Content-Type': 'multipart/form-data'
}
})
}
// 直播心跳
export function postLiveHeartbeat(data) {
@@ -468,15 +455,6 @@ export function hasPermission(params) {
})
}
///iot/workRecord/getTaskPath?taskId=74 get 获取算法回传的路径
export function getTaskPath(params) {
return request({
url: '/iot/workRecord/getTaskPath',
method: 'get',
params
})
}

9
src/api/machine.ts Normal file
View File

@@ -0,0 +1,9 @@
import request from './request';
export function getDeviceRunningHistoryStatistics(data) {
return request({
url: `/iot/device/runningHistoryStatistics`,
method: 'post',
data,
});
}

View File

@@ -1,232 +0,0 @@
import React, { useEffect, useRef, useState } from "react";
import AgoraRTC, { IAgoraRTCClient, IRemoteVideoTrack } from "agora-rtc-sdk-ng";
import { Badge, message } from "antd";
const APP_ID = "875f6494d87548e783fefbf33f598c97";
const TOKEN = "007eJxTYIjPuZr09PC0znd6+z0MMyL6ZHb68OetXW+kO1vHU2ZNtYECg4W5aZqZiaVJCpBhYpFqbmGclpqWlGZsnGZqaZFsaT6pZH5WQyAjA7e+LysjAwSC+JwMxmYlqcUlugZGDAwAbuYeJg==";
export default function AgrtcRoomRobot({ CHANNEL }) {
const [uid] = useState(() => Number(Math.floor(Math.random() * 100000)));
const [connected, setConnected] = useState(false);
const [joined, setJoined] = useState(false);
// 标记是否存在远端视频流
const [hasRemoteVideo, setHasRemoteVideo] = useState(false);
const remoteVideoRef = useRef<HTMLDivElement>(null);
const clientRef = useRef<IAgoraRTCClient | null>(null);
const remoteVideoTrackRef = useRef<IRemoteVideoTrack | null>(null);
const joiningRef = useRef(false);
const reconnectTimerRef = useRef<NodeJS.Timeout | null>(null);
useEffect(() => {
const client = AgoraRTC.createClient({
mode: "live",
codec: "h264",
});
clientRef.current = client;
client.setClientRole("audience");
let isUnmounted = false;
// 停止并清空远端视频
const clearRemoteVideo = () => {
if (remoteVideoTrackRef.current) {
try {
remoteVideoTrackRef.current.stop();
} catch (e) { /* */ }
remoteVideoTrackRef.current = null;
}
if (remoteVideoRef.current) {
remoteVideoRef.current.innerHTML = "";
}
setHasRemoteVideo(false);
};
// 重连逻辑
const doReconnect = async () => {
if (isUnmounted || joiningRef.current) return;
console.log("执行RTC重连");
clearRemoteVideo();
setJoined(false);
try {
joiningRef.current = true;
await client.join(APP_ID, CHANNEL, TOKEN, uid);
if (isUnmounted) return;
setJoined(true);
message.info("RTC重连成功");
// 重连成功后重新订阅已经在线的上位机
for (const remoteUser of client.remoteUsers) {
if (isUnmounted) break;
if (remoteUser.hasVideo) {
await client.subscribe(remoteUser, "video");
remoteVideoTrackRef.current = remoteUser.videoTrack;
remoteUser.videoTrack?.play(remoteVideoRef.current!);
setHasRemoteVideo(true);
}
}
} catch (err: any) {
if (err?.code !== "OPERATION_ABORTED") {
console.error("重连失败", err);
}
} finally {
joiningRef.current = false;
}
};
// 连接状态变化
const onConnStateChange = (curState: string, prevState: string) => {
if (isUnmounted) return;
console.log("连接状态变更", prevState, "→", curState);
setConnected(curState === "CONNECTED");
// 信令断开,延迟重连
if (curState === "DISCONNECTED") {
clearRemoteVideo();
if (reconnectTimerRef.current) clearTimeout(reconnectTimerRef.current);
reconnectTimerRef.current = setTimeout(() => {
doReconnect();
}, 2000);
}
};
// 远端用户发布流
const onUserPublished = async (user: any, mediaType: "video" | "audio") => {
if (isUnmounted) return;
console.log("user-published", user.uid, mediaType);
await client.subscribe(user, mediaType);
if (mediaType === "video" && remoteVideoRef.current) {
clearRemoteVideo();
remoteVideoTrackRef.current = user.videoTrack;
user.videoTrack?.play(remoteVideoRef.current);
setHasRemoteVideo(true);
}
};
// 远端停止发布流(上位机停止推流)
const onUserUnpublished = (user: any, mediaType: "video" | "audio") => {
if (isUnmounted) return;
console.log("user-unpublished", user.uid, mediaType);
if (mediaType === "video") {
clearRemoteVideo();
}
};
// 远端用户离开频道
const onUserLeft = (user: any) => {
if (isUnmounted) return;
console.log("user-left", user.uid);
clearRemoteVideo();
};
// 远端用户进入
const onUserJoined = (user: any) => {
if (!isUnmounted) console.log("远端用户进入频道:", user.uid);
};
// Token即将过期提醒(测试Token有效期有限)
const onTokenWillExpire = () => {
console.warn("token即将过期,请更新token");
message.warning("Token即将过期,视频可能很快断开");
// 正式环境:请求后端拿新token client.renewToken(newToken)
};
// 注册事件,保存回调引用用于off解绑
client.on("connection-state-change", onConnStateChange);
client.on("user-published", onUserPublished);
client.on("user-unpublished", onUserUnpublished);
client.on("user-left", onUserLeft);
client.on("user-joined", onUserJoined);
client.on("token-privilege-will-expire", onTokenWillExpire);
const init = async () => {
if (joiningRef.current) return;
joiningRef.current = true;
try {
await client.join(APP_ID, CHANNEL, TOKEN, uid);
if (isUnmounted) {
console.log("组件已卸载,丢弃join结果");
return;
}
console.log("加入频道成功");
setJoined(true);
message.success("RTC已加入频道");
// 上位机已经提前推流,手动订阅
for (const remoteUser of client.remoteUsers) {
if (isUnmounted) break;
console.log("发现已有远端用户:", remoteUser.uid);
if (remoteUser.hasVideo) {
await client.subscribe(remoteUser, "video");
remoteVideoTrackRef.current = remoteUser.videoTrack;
remoteUser.videoTrack?.play(remoteVideoRef.current!);
setHasRemoteVideo(true);
}
}
} catch (err: any) {
if (err?.code === "OPERATION_ABORTED") {
console.log("join操作被取消(StrictMode/组件卸载),忽略");
return;
}
console.error("加入频道失败:", err);
if (!isUnmounted) {
message.error("加入频道失败,请检查appid/token/channel");
}
} finally {
joiningRef.current = false;
}
};
init();
// 组件卸载清理
return () => {
isUnmounted = true;
if (reconnectTimerRef.current) clearTimeout(reconnectTimerRef.current);
clearRemoteVideo();
const c = clientRef.current;
if (!c) return;
c.off("connection-state-change", onConnStateChange);
c.off("user-published", onUserPublished);
c.off("user-unpublished", onUserUnpublished);
c.off("user-left", onUserLeft);
c.off("user-joined", onUserJoined);
c.off("token-privilege-will-expire", onTokenWillExpire);
c.leave();
clientRef.current = null;
};
}, [uid, CHANNEL]);
return (
<div style={{ width: "100%", height: "100%", display: "flex", flexDirection: "column", borderRadius: 8, overflow: "hidden", background: "#000" }}>
<div style={{ display: "flex", justifyContent: "end", alignItems: "center", gap: 12, padding: "4px 8px", background: "rgba(255,255,255,0.08)", flexShrink: 0 }}>
<Badge
color={connected ? "green" : "red"}
text={connected ? "RTC已连接" : "RTC未连接"}
styles={{ content: { color: '#888' } }}
/>
<Badge
color={joined ? "green" : "orange"}
text={joined ? "已加入频道" : "未加入频道"}
styles={{ content: { color: '#888' } }}
/>
<span style={{ fontSize: 11, color: "#888" }}>频道:{CHANNEL}</span>
</div>
<div style={{ flex: 1, width: "100%", minHeight: 0, position: "relative" }}>
{/* 无视频时显示加载占位 */}
{!hasRemoteVideo && (
<div style={{
position: "absolute",
inset: 0,
display: "flex",
alignItems: "center",
justifyContent: "center",
color: "#aaa",
fontSize: 14,
background: "#000"
}}>
视频加载中,等待远端推流...
</div>
)}
{/* Agora 视频容器,内部会被SDK填充video dom */}
<div ref={remoteVideoRef} style={{
position: "absolute",
inset: 0
}} />
</div>
</div >
);
}

View File

@@ -27,7 +27,7 @@ const CYAN_GLOW_COLOR = new window.Cesium.Color(
);
window.Cesium.Ion.defaultAccessToken = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJmNjk0NjI1MC0wZGYyLTQ1YzItYjJmZi0wY2M5ODEwODllYzIiLCJpZCI6Mzk3MTQxLCJpYXQiOjE3NzI1MjkwMjV9.U6qmakhDgXJVXwLFyWzSxAUOFZRrDkIsRUPP6CCdnKg";
const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine, finishPoint, drawRealTime, realtimePosition, realtimeType, pathPoints = [], devices = [], onCameraClick, focusLocation, points = [], markedPoints = [], onPathChange, from, onClearDraw, onMarkPoint, routeMode = '', polyPoints, mapLayer }, ref) => {
const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine, finishPoint, drawRealTime, realtimePosition, realtimeType, pathPoints = [], devices = [], onCameraClick, focusLocation, points = [], markedPoints = [], onPathChange, from, onClearDraw }, ref) => {
const containerRef = useRef(null);
const viewerRef = useRef(null);
const tooltipRef = useRef(null);
@@ -37,12 +37,8 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
const alarmMapRef = useRef(new Map());
const iotMapRef = useRef(new Map());
const planLineRef = useRef(null); // points 规划航线
const polygonRef = useRef(null); // coverage 区域多边形
const navLineRef = useRef(null); // 完成点实时轨迹
const markedPointsRef = useRef([]); // 标记点实体
const markedLineRef = useRef(null); // 标记点连线实体
const onMarkPointRef = useRef(onMarkPoint); // 总是指向最新的 onMarkPoint,避免闭包滞后
const onCameraClickRef = useRef(onCameraClick); // 同样处理,避免闭包滞后
const { t } = useTranslation();
@@ -58,21 +54,6 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
const isCameraFlyingRef = useRef(false);
const lastFlightPromiseRef = useRef(null);
// ==============================
// 飞行优先级调度:优先级高的可打断低的;同级不重复起飞
// realtime(100) > focus(90) > devices(80) > track(70) > layer(10)
// ==============================
const lastFlightPriorityRef = useRef(-1);
const FLIGHT_PRIORITY = { realtime: 100, focus: 90, devices: 80, track: 70, layer: 10 };
const flyToView = (viewer, priority, config) => {
if (!viewer) return;
if (priority <= lastFlightPriorityRef.current) return; // 同级或更低不重复/覆盖;更高优先级才打断
lastFlightPriorityRef.current = priority;
try { viewer.camera.cancelFlight(); } catch (e) { /* 忽略取消异常 */ }
viewer.camera.flyTo(config);
};
const resetFlightPriority = () => { lastFlightPriorityRef.current = -1; };
const [drawPoints, setDrawPoints] = useState([]);
const drawLineRef = useRef(null);
const pointEntitiesRef = useRef([]);
@@ -172,7 +153,6 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
}
});
}
console.log(newPoints, "newPoints")
onPathChange && onPathChange(newPoints);
};
@@ -280,7 +260,7 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
const p = validPoints[0];
viewer.scene.requestRender();
flyToView(viewer, FLIGHT_PRIORITY.track, {
viewer.camera.flyTo({
destination: Cesium.Cartesian3.fromDegrees(
p.lng,
p.lat,
@@ -302,7 +282,7 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
viewer.scene.requestRender();
flyToView(viewer, FLIGHT_PRIORITY.track, {
viewer.camera.flyTo({
destination: rectangle,
duration: 1.2
});
@@ -315,203 +295,26 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
};
const drawPolygon = (points) => {
const viewer = viewerRef.current;
if (!viewer) return;
const isRealtimeMode = !!(
realtimePosition?.lon &&
realtimePosition?.lat &&
!isNaN(Number(realtimePosition.lon)) &&
!isNaN(Number(realtimePosition.lat))
);
const Cesium = window.Cesium;
// 每次绘制区域前,先移除上一次绘制的地块
if (polygonRef.current) {
try {
viewer.entities.remove(polygonRef.current);
polygonRef.current = null;
} catch (e) { }
}
if (planLineRef.current) {
try {
viewer.entities.remove(planLineRef.current);
planLineRef.current = null;
} catch (e) { }
}
const validPoints = points?.filter(p => {
const lon = Number(p.lng);
const lat = Number(p.lat);
return (
!isNaN(lon) &&
!isNaN(lat) &&
Math.abs(lon) < 180 &&
Math.abs(lat) < 90 &&
lon !== 0 &&
lat !== 0
);
});
if (validPoints.length === 0) return;
const positions = validPoints.map(point =>
Cesium.Cartesian3.fromDegrees(
Number(point.lng),
Number(point.lat)
)
);
// coverage(区域覆盖)模式下以多边形 polygon 框绘制,否则为折线
const isCoverage = routeMode === 'coverage';
let trackLine;
if (isCoverage) {
trackLine = viewer.entities.add({
polygon: {
hierarchy: positions,
material: Cesium.Color.ORANGE.withAlpha(0.2),
outline: true,
outlineColor: Cesium.Color.ORANGE.withAlpha(0.8),
height: 0,
clampToGround: true,
disableDepthTestDistance: Number.POSITIVE_INFINITY,
},
});
} else {
trackLine = viewer.entities.add({
polyline: {
positions: positions,
width: 2,
material: Cesium.Color.ORANGE.withAlpha(0.8),
clampToGround: true,
disableDepthTestDistance: Number.POSITIVE_INFINITY,
},
});
}
polygonRef.current = trackLine;
// ======================
// 🚀 非实时模式 -> 自动飞到轨迹
// ======================
if (!isRealtimeMode) {
let minLon = 180, maxLon = -180;
let minLat = 90, maxLat = -90;
validPoints.forEach(p => {
minLon = Math.min(minLon, p.lng);
maxLon = Math.max(maxLon, p.lng);
minLat = Math.min(minLat, p.lat);
maxLat = Math.max(maxLat, p.lat);
});
if (getCameraMode() !== "track") return;
// 单个点
if (validPoints.length === 1) {
const p = validPoints[0];
viewer.scene.requestRender();
flyToView(viewer, FLIGHT_PRIORITY.track, {
destination: Cesium.Cartesian3.fromDegrees(
p.lng,
p.lat,
800
),
duration: 1.2
});
viewer.scene.requestRender();
} else {
const rectangle = Cesium.Rectangle.fromDegrees(
minLon,
minLat,
maxLon,
maxLat
);
viewer.scene.requestRender();
flyToView(viewer, FLIGHT_PRIORITY.track, {
destination: rectangle,
duration: 1.2
});
viewer.scene.requestRender();
}
}
};
useEffect(() => {
resetFlightPriority();
if (polyPoints && polyPoints.length > 0) {
drawPolygon(polyPoints)
} else {
// polyPoints 被清空时,移除已绘制的区域
const viewer = viewerRef.current;
if (viewer && polygonRef.current) {
try {
viewer.entities.remove(polygonRef.current);
polygonRef.current = null;
} catch (e) { }
}
}
}, [polyPoints])
useEffect(() => {
resetFlightPriority();
if (viewerRef.current) {
drawTrackLine(points);
}
}, [points]);
// 渲染标记点 + 连线(唯一系统,避免重复标记)
// 渲染绿色标记点
const drawMarkedPoints = (points) => {
const viewer = viewerRef.current;
if (!viewer) return;
// 先清空之前的标记点与连线
// 先清空之前的标记点
markedPointsRef.current.forEach(id => {
viewer.entities.removeById(id);
});
markedPointsRef.current = [];
if (markedLineRef.current) {
try {
viewer.entities.remove(markedLineRef.current);
} catch (e) { }
markedLineRef.current = null;
}
if (!points || points.length === 0) return;
// 先绘制连线:有 2 个及以上打点才连线
if (points.length >= 2) {
const linePositions = points.map(p =>
window.Cesium.Cartesian3.fromDegrees(Number(p.lon), Number(p.lat))
);
markedLineRef.current = viewer.entities.add({
polyline: {
positions: linePositions,
width: 4,
material: window.Cesium.Color.SKYBLUE,
clampToGround: true,
}
});
}
points.forEach((p, i) => {
const id = `marked-point-${i}`;
viewer.entities.add({
@@ -564,57 +367,11 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
tooltip.innerHTML = `
<div style="font-weight:600;margin-bottom:6px;">🤖 ${robot.deviceAlias || robot.serialNumber || robot.name}</div>
${deviceValuesHTML ? `<div style="margin-top:8px;"><strong>${t('devices.deviceData')}:</strong>${deviceValuesHTML}</div>` : ''}
<div>${t('systemSetting.longitude')}:${Number(robot?.locationMessage?.longitude || robot?.lastRunningStatus?.longitude).toFixed(6)}</div>
<div>${t('systemSetting.latitude')}:${Number(robot?.locationMessage?.latitude || robot?.lastRunningStatus?.latitude).toFixed(6)}</div>
<div>${t('systemSetting.longitude')}:${Number(robot.lastRunningStatus?.longitude).toFixed(6)}</div>
<div>${t('systemSetting.latitude')}:${Number(robot.lastRunningStatus?.latitude).toFixed(6)}</div>
`;
}
const getCursorLngLat = (viewer, screenPos) => {
const cartesian = viewer.camera.pickEllipsoid(screenPos, viewer.scene.globe.ellipsoid);
if (!window.Cesium.defined(cartesian)) return { lon: NaN, lat: NaN };
const cartographic = window.Cesium.Cartographic.fromCartesian(cartesian);
return {
lon: window.Cesium.Math.toDegrees(cartographic.longitude),
lat: window.Cesium.Math.toDegrees(cartographic.latitude),
};
};
function showCoordinateTooltip(tooltip, position, t, lon, lat, robot) {
tooltip.style.display = "block";
tooltip.style.left = position.x + 12 + "px";
tooltip.style.top = position.y + 12 + "px";
tooltip.style.whiteSpace = "nowrap";
const lonStr = Number.isFinite(lon) ? lon.toFixed(6) : "--";
const latStr = Number.isFinite(lat) ? lat.toFixed(6) : "--";
if (robot) {
const statusMap = {
1: { text: t('common.working'), color: "#10b981" },
2: { text: t('devices.idle'), color: "#f59e0b" },
3: { text: t('devices.offline'), color: "#f87171" }
};
const status = statusMap[robot.feStatus] || statusMap[1];
let deviceValuesHTML = '';
if (robot.devicevalue && robot.devicevalue.length > 0) {
deviceValuesHTML = robot.devicevalue.map((device) => `
<div style="margin-bottom:4px;"><strong>${device.name}:</strong> ${device.value}${device.unit}</div>
`).join('');
}
tooltip.innerHTML = `
<div style="font-weight:600;margin-bottom:6px;">🤖 ${robot.deviceAlias || robot.serialNumber || robot.name}</div>
${deviceValuesHTML ? `<div style="margin-top:8px;"><strong>${t('devices.deviceData')}:</strong>${deviceValuesHTML}</div>` : ''}
<div>${t('systemSetting.longitude')}:${lonStr}</div>
<div>${t('systemSetting.latitude')}:${latStr}</div>
`;
} else {
tooltip.innerHTML = `
<div style="font-weight:600;margin-bottom:4px;">📍 ${t('systemSetting.longitude')}:${lonStr}</div>
<div style="font-weight:600;">${t('systemSetting.latitude')}:${latStr}</div>
`;
}
}
function fetchPublishedLayers() {
const baseUrl = envConfig.geoserver_url;
//const baseUrl = 'https://gis.caasrobot.com/geoserver';
@@ -644,6 +401,7 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
}
}
}
console.log('已发布的图层:', publishedLayers);
displayPublishedLayers(publishedLayers, baseUrl);
})
.catch(error => console.error('获取图层失败:', error));
@@ -728,7 +486,7 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
!isNaN(Number(realtimePosition.lon)) &&
!isNaN(Number(realtimePosition.lat));
const hasTrack = (points && points.length > 0) || polyPoints?.length > 0;
const hasTrack = (points && points.length > 0);
if (hasRealtime) return "realtime";
if (hasTrack) return "track";
@@ -742,9 +500,9 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
//if (index == 2 && from == "other") {
// //flyToLayer(layerIdentifier, baseUrl, 100);
//}
//if (index == 0 && from == "other") {
// flyToLayer(layerIdentifier, baseUrl, 100);
//}
if (index == 1 && from == "other") {
flyToLayer(layerIdentifier, baseUrl, 100);
}
//getLayerBoundsAndFit(wmsUrl, layerName);
if (baseUrl.includes('/gwc/service/wms')) {
@@ -849,7 +607,7 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
}
}
function flyToLayer(layerIdentifier, baseUrl, flyHeight = 100) {
function flyToLayer(layerIdentifier, baseUrl, flyHeight = 1000) {
//console.log('开始获取图层范围', layerIdentifier);
const url = `${baseUrl}/wms?service=WMS&version=1.1.1&request=GetCapabilities`;
@@ -888,7 +646,7 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
const centerLon = (minx + maxx) / 2;
const centerLat = (miny + maxy) / 2;
flyToView(viewerRef.current, FLIGHT_PRIORITY.layer, {
viewerRef.current.camera.flyTo({
// 固定高度,第三个参数就是高度(单位米)
destination: window.Cesium.Cartesian3.fromDegrees(centerLon, centerLat, flyHeight),
orientation: {
@@ -1036,15 +794,6 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
};
}, []);
// 根据场站映射图层定位地图:切换场站时始终飞向该场站的图层
// 不再用可能滞后的 devices 判断(避免用上一场站的机器决策);
// 若场站有机器,由 devices 效果按更高优先级接管飞向机器
useEffect(() => {
if (!mapLayer || !viewerRef.current) return;
resetFlightPriority();
flyToLayer(mapLayer, envConfig.geoserver_url, 100);
}, [mapLayer]);
useEffect(() => {
// 如果有 realtimePosition,不显示 focusEntity
@@ -1099,7 +848,7 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
}
});
flyToView(viewer, FLIGHT_PRIORITY.focus, {
viewer.camera.flyTo({
destination: Cesium.Cartesian3.fromDegrees(Number(focusLocation.lon), Number(focusLocation.lat), focusLocation.height || 800),
orientation: {
heading: Cesium.Math.toRadians(0.0),
@@ -1126,7 +875,7 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
});
const rectangle = window.Cesium.Rectangle.fromDegrees(west, south, east, north);
flyToView(viewer, FLIGHT_PRIORITY.devices, { destination: rectangle, duration: 1.5 });
viewer.camera.flyTo({ destination: rectangle, duration: 1.5 });
}
function parseLngLat(lon, lat) {
@@ -1348,12 +1097,7 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
planLineRef.current = null;
}
if (polygonRef.current) {
viewer.entities.remove(polygonRef.current);
polygonRef.current = null;
}
viewer.scene.requestRender();
}
prevIfClearPlanLine.current = ifClearPlanLine;
@@ -1403,7 +1147,7 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
devices.forEach((device, index) => {
const raw = device?.locationMessage || device?.lastRunningStatus || {};
const raw = device?.lastRunningStatus || {};
const parsed = parseLngLat(raw.longitude, raw.latitude);
if (!parsed) return;
@@ -1575,7 +1319,7 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
const p = validPositions[0];
flyToView(viewer, FLIGHT_PRIORITY.devices, {
viewer.camera.flyTo({
destination: Cesium.Cartesian3.fromDegrees(
p.lon,
p.lat,
@@ -1593,7 +1337,7 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
maxLat
);
flyToView(viewer, FLIGHT_PRIORITY.devices, {
viewer.camera.flyTo({
destination: rectangle,
duration: 1.2
});
@@ -1652,10 +1396,6 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
};
}, [points]);
// 每次渲染都更新回调引用,确保单击处理器用最新版本(避免闭包滞后)
onMarkPointRef.current = onMarkPoint;
onCameraClickRef.current = onCameraClick;
useEffect(() => {
const viewer = viewerRef.current;
if (!viewer) return;
@@ -1664,12 +1404,9 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
handler.setInputAction((movement) => {
const picked = viewer.scene.pick(movement.endPosition);
const pickedRobot = (window.Cesium.defined(picked) && picked.id?.properties?.robot) ? picked.id.properties.robot.getValue() : null;
const { lon, lat } = getCursorLngLat(viewer, movement.endPosition);
if (window.Cesium.defined(lon) && Number.isFinite(lon)) {
showCoordinateTooltip(tooltipRef.current, movement.endPosition, t, lon, lat, pickedRobot);
} else if (pickedRobot) {
showCoordinateTooltip(tooltipRef.current, movement.endPosition, t, NaN, NaN, pickedRobot);
if (window.Cesium.defined(picked) && picked.id?.properties?.robot) {
const robot = picked.id.properties.robot.getValue();
showRobotTooltip(tooltipRef.current, robot, movement.endPosition, t);
} else {
tooltipRef.current.style.display = "none";
}
@@ -1679,20 +1416,22 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
const picked = viewer.scene.pick(movement.position);
if (window.Cesium.defined(picked) && picked.id?.properties?.robot) {
const robot = picked.id.properties.robot.getValue();
robot.feStatus == 1 && onCameraClickRef.current?.(robot);
robot.feStatus == 1 && onCameraClick?.(robot);
}
}, window.Cesium.ScreenSpaceEventType.LEFT_CLICK);
handler.setInputAction((movement) => {
if (from !== "deviceStatus")
return;
//if (from !== "device-control")
return;
const cartesian = viewer.camera.pickEllipsoid(movement.position, viewer.scene.globe.ellipsoid);
if (!cartesian) return;
const cartographic = window.Cesium.Cartographic.fromCartesian(cartesian);
const lon = window.Cesium.Math.toDegrees(cartographic.longitude);
const lat = window.Cesium.Math.toDegrees(cartographic.latitude);
const newPoint = { lon, lat };
onMarkPointRef.current?.({ lon, lat });
const newPoints = [...drawPoints, newPoint];
setDrawPoints(newPoints);
updateDrawPath(newPoints);
}, window.Cesium.ScreenSpaceEventType.LEFT_CLICK);
if (onClearDraw) {
@@ -1777,7 +1516,6 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
realtimeLastPointRef.current = null;
realtimeHiddenRef.current = false;
hasFlownRef.current = false;
resetFlightPriority();
// 恢复所有设备显示
entityMapRef.current.forEach(e => {
@@ -1825,7 +1563,7 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
// ====================================
// 无人机模式:保持原来的逻辑
// ====================================
if (isDroneMode || from == "deviceStatus" || from == "devicesTask") {
if (isDroneMode || from == "deviceStatus") {
// 轨迹点去抖动(防止重复点)
const last = realtimeLastPointRef.current;
let shouldAdd = true;
@@ -1938,7 +1676,7 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
hasFlownRef.current = true;
if (getCameraMode() !== "realtime") return;
flyToView(viewer, FLIGHT_PRIORITY.realtime, {
viewer.camera.flyTo({
destination: Cesium.Cartesian3.fromDegrees(lon, lat, 30),
orientation: {
heading: 0,
@@ -2078,7 +1816,7 @@ const CesiumMap = React.forwardRef(({ ifClear, ifClearPlanLine, ifClearNavLine,
hasFlownRef.current = true;
if (getCameraMode() !== "realtime") return;
flyToView(viewer, FLIGHT_PRIORITY.realtime, {
viewer.camera.flyTo({
destination: Cesium.Cartesian3.fromDegrees(
lon,

View File

@@ -1,4 +1,4 @@
import React, { useState } from 'react';
import React, { useState, useEffect } from 'react';
import {
Form,
Input,
@@ -58,12 +58,22 @@ import {
} from 'lucide-react';
import dayjs from 'dayjs';
import { useTranslation } from 'react-i18next';
import { getRoleList } from '@/api/role';
import { useSelector } from 'react-redux';
import { RootState } from '@/src/store';
import { getUser } from '@/api/user';
const { Text, Title } = Typography;
const BasicSettings = () => {
const { t } = useTranslation();
const [form] = Form.useForm();
const [roles, setRoles] = useState<any[]>([]);
const { userInfo } = useSelector((state: RootState) => state.user);
const { currentStation, stationId } = useSelector((state: RootState) => state.station);
const [userList, setUserList] = useState<any[]>([]);
// 响应式字体大小
const fontNormal = 'clamp(12px, 0.75vw, 13px)';
@@ -119,6 +129,7 @@ const BasicSettings = () => {
// 角色权限概览
const roleOverview = [
//平台管理员
{
title: t('roles.superAdmin'),
users: 2,
@@ -128,34 +139,68 @@ const BasicSettings = () => {
bg: '#e6f4ff',
icon: <ShieldCheck size={20} color="#1677ff" />
},
//普通用户
{
title: t('systemSetting.fixed2OM'),
users: 5,
perms: 18,
tags: [t('router.devices'), '工单管理'],
tags: ["处理工单", "处理任务"],
color: '#52c41a',
bg: '#f6ffed',
icon: <Wrench size={20} color="#52c41a" />
},
//机构管理员
{
title: t('systemSetting.fixed2Inspection2'),
users: 8,
perms: 12,
tags: ['巡检管理', '告警处理'],
tags: ['管理机构下所有场站', '告警处理'],
color: '#fa8c16',
bg: '#fff7e6',
icon: <Users size={20} color="#fa8c16" />
},
//场站管理员
{
title: t('systemSetting.s322'),
users: 3,
perms: 15,
tags: ['数据分析', '报表查看'],
tags: ['管理自己场站', '报表查看', '告警处理'],
color: '#722ed1',
bg: '#f9f0ff',
icon: <LineChart size={20} color="#722ed1" />
},
];
const matchRoleStyle = (roleName: string) => {
const found = roleOverview.find(item => item.title === roleName);
if (found) return found;
// 兜底默认样式
return {
color: '#8c8c8c',
bg: '#f5f5f5',
icon: null,
tags: []
};
};
const getUserData = () => {
const params = {
pageNum: 1,
pageSize: 9999,
orgId: userInfo?.roleKey == "manager" ? userInfo?.orgId : currentStation?.orgId,
...(userInfo?.roleKey == "manager"
? {}
: { siteId: stationId }
)
};
getUser(params).then(res => {
if (res.code === 200) {
setUserList(res.rows || []);
}
});
};
// 设备状态
const deviceStatuses = [
@@ -168,6 +213,21 @@ const BasicSettings = () => {
{ name: t('systemSetting.api'), count: t('roles.normal'), status: t('roles.normal') },
{ name: 'Modbus', count: t('roles.normal'), status: t('roles.normal') },
];
const getRoleData = () => {
const params = { pageNum: 1, pageSize: 9999 };
getRoleList(params).then(res => {
if (res.code === 200) {
let sortedRoles = (res.data || []).sort((a, b) => (a.roleSort || 999) - (b.roleSort || 999));
setRoles(sortedRoles);
}
});
};
useEffect(() => {
getRoleData();
getUserData();
}, [])
return (
<div className="normal-spacing" style={{ padding: '8px 0px', background: '#f5f7fa', minHeight: '100vh' }}>
@@ -180,11 +240,11 @@ const BasicSettings = () => {
<Row gutter={[8, 8]} style={{ marginBottom: 8 }}>
{topCards.map((item, idx) => (
<Col key={idx} style={{ minWidth: '168px', flex: '1 0 auto', maxWidth: "250px" }}>
<AntdCard variant="borderless" styles={{ body: { padding: '12px 16px' } }} style={{ borderRadius: 10, boxShadow: '0 2px 8px rgba(0,0,0,0.04)' }}>
<AntdCard bordered={false} bodyStyle={{ padding: '12px 16px' }} style={{ borderRadius: 10, boxShadow: '0 2px 8px rgba(0,0,0,0.04)' }}>
<div style={{ display: 'flex', alignItems: 'center', gap: 10 }}>
<div style={{ width: 40, height: 40, borderRadius: 10, background: item.bg, display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
{/*<div style={{ width: 40, height: 40, borderRadius: 10, background: item.bg, display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
{React.cloneElement(item.icon as React.ReactElement, { size: 20, style: item.icon.props.style ? { ...item.icon.props.style, fontSize: 20 } : { fontSize: 20 } })}
</div>
</div>*/}
<div style={{ flex: 1 }}>
<div style={{ color: '#8c8c8c', fontSize: fontSmall, marginBottom: 2 }}>{item.title}</div>
<div style={{ display: 'flex', alignItems: 'baseline', gap: 6 }}>
@@ -205,9 +265,9 @@ const BasicSettings = () => {
{/* 基础配置 */}
<AntdCard
title={<Space><SettingOutlined style={{ color: '#1677ff' }} /><b>{t('systemSetting.basicSettings')}</b></Space>}
variant="borderless"
bordered={false}
style={{ borderRadius: 10, marginBottom: 8, boxShadow: '0 2px 8px rgba(0,0,0,0.04)' }}
styles={{ body: { padding: '16px' } }}
bodyStyle={{ padding: '16px' }}
>
<Form form={form} layout="vertical">
<Row gutter={16}>
@@ -286,9 +346,9 @@ const BasicSettings = () => {
{/* 通知与告警策略 */}
<AntdCard
title={<Space><BellOutlined style={{ color: '#1677ff' }} /><b>{t('systemSetting.alert2')}</b></Space>}
variant="borderless"
bordered={false}
style={{ borderRadius: 10, marginBottom: 8, boxShadow: '0 2px 8px rgba(0,0,0,0.04)' }}
styles={{ body: { padding: '16px' } }}
bodyStyle={{ padding: '16px' }}
>
<Row gutter={[12, 12]} style={{ marginBottom: 8 }}>
{[
@@ -300,7 +360,7 @@ const BasicSettings = () => {
<Col xs={24} sm={12} lg={6} key={idx}>
<div style={{ display: 'flex', alignItems: 'center', padding: '10px 12px', background: '#f8fafc', borderRadius: 8, border: '1px solid #f1f5f9' }}>
<div style={{ width: 32, height: 32, borderRadius: '50%', background: '#fff', display: 'flex', alignItems: 'center', justifyContent: 'center', boxShadow: '0 1px 4px rgba(0,0,0,0.04)', marginRight: 10 }}>
{React.cloneElement(item.icon as React.ReactElement, { style: { color: item.color } })}
{/*{React.cloneElement(item.icon as React.ReactElement, { style: { color: item.color } })}*/}
</div>
<div style={{ flex: 1 }}>
<div style={{ fontSize: 10, color: '#8c8c8c' }}>{item.label}</div>
@@ -329,9 +389,9 @@ const BasicSettings = () => {
{/* 用户与权限预览 */}
<AntdCard
title={<Space><Users size={16} style={{ color: '#1677ff' }} /><b>{t('systemSetting.fixed2RolePermissionFixed2OverviewFixed2')}</b></Space>}
variant="borderless"
bordered={false}
style={{ borderRadius: 10, boxShadow: '0 2px 8px rgba(0,0,0,0.04)', marginBottom: 0 }}
styles={{ body: { padding: '12px' } }}
bodyStyle={{ padding: '12px' }}
>
<Table
size="small"
@@ -340,42 +400,39 @@ const BasicSettings = () => {
empty={false}
rowKey="name"
pagination={{ size: 'small', total: 4, pageSize: 4, showTotal: (total) => `共 ${total} 条` }}
columns={[
{ title: t('systemSetting.s36'), dataIndex: 'name', key: 'name', fixed: 'left', width: 80 },
{ title: t('systemSetting.s36'), dataIndex: 'userName', key: 'userName', fixed: 'left', },
{
title: t('users.role'),
dataIndex: 'role',
key: 'role',
width: 100,
render: (role) => {
const config: any = {
'超级管理员': { color: '#1677ff', bg: '#e6f4ff' },
'运维工程师': { color: '#52c41a', bg: '#f6ffed' },
'巡检主管': { color: '#fa8c16', bg: '#fff7e6' },
'数据分析师': { color: '#722ed1', bg: '#f9f0ff' },
};
const s = config[role] || { color: '#8c8c8c', bg: '#f5f5f5' };
return <Tag variant="borderless" style={{ color: s.color, background: s.bg, fontSize: 10, margin: 0 }}>{role}</Tag>;
render: (_val, record) => {
const roleList = record.roles || [];
return <>
{roleList.map((rItem: any) => {
//const conf = getRoleConfByKey(rItem.roleKey);
return <Tag key={rItem.roleId}>{rItem.roleKey == "manager" ? t('systemSetting.fixed2Inspection2') : rItem.roleKey == "siteManager" ? t('systemSetting.s322') : t('systemSetting.fixed2OM')}</Tag>
})}
</>
}
},
{ title: t('users.phone'), dataIndex: 'phone', key: 'phone', width: 110 },
{ title: t('users.phone'), dataIndex: 'phonenumber', key: 'phonenumber', },
{ title: t('users.email'), dataIndex: 'email', key: 'email', ellipsis: true },
{
title: t('roles.status'),
dataIndex: 'status',
key: 'status',
width: 70,
render: (status) => (
<Space size={4}>
<div style={{ width: 6, height: 6, borderRadius: '50%', background: status === t('devices.online') ? '#52c41a' : '#bfbfbf' }} />
<span style={{ fontSize: 10 }}>{status}</span>
<span style={{ fontSize: 10 }}>{status == 1 ? "在线" : "离线"}</span>
</Space>
)
},
{
title: t('roles.actions'), key: 'action', width: 60, render: () => <Button
title: t('roles.actions'), key: 'action', render: () => <Button
type="link"
size="small"
icon={<EyeOutlined />}
@@ -383,12 +440,7 @@ const BasicSettings = () => {
>{t('common.view')}</Button>, fixed: 'right'
},
]}
dataSource={[
{ name: '张运维', role: '超级管理员', phone: '138****0001', email: 'zhangyw@pvsmart.com', status: t('devices.online') },
{ name: '李工程师', role: '运维工程师', phone: '139****0002', email: 'li.gongcheng@pvsmart.com', status: t('devices.online') },
{ name: '王班长', role: '巡检主管', phone: '137****0003', email: 'wang.banzhang@pvsmart.com', status: t('devices.online') },
{ name: '赵分析师', role: '数据分析师', phone: '136****0004', email: 'zhao.fx@pvsmart.com', status: t('devices.online') },
]}
dataSource={userList}
/>
</AntdCard>
</Col>
@@ -398,30 +450,46 @@ const BasicSettings = () => {
{/* 角色权限概览 */}
<AntdCard
title={<Space><Users size={16} style={{ color: '#1677ff' }} /><b>{t('systemSetting.fixed2RolePermissionFixed2OverviewFixed2')}</b></Space>}
variant="borderless"
bordered={false}
style={{ borderRadius: 10, marginBottom: 8, boxShadow: '0 2px 8px rgba(0,0,0,0.04)' }}
styles={{ body: { padding: '10px' } }}
bodyStyle={{ padding: '10px' }}
>
<Row gutter={[8, 8]}>
{roleOverview.map((role, idx) => (
<Col xs={24} sm={12} key={idx}>
<div style={{ background: role.bg, borderRadius: 8, padding: 8, height: '100%' }}>
<div style={{ display: 'flex', justifyContent: 'space-between', marginBottom: 4 }}>
{React.cloneElement(role.icon as React.ReactElement, { size: 16 })}
<RightOutlined style={{ fontSize: 9, color: role.color }} />
{roles.map((role, idx) => {
const styleConf = matchRoleStyle(role.roleName);
return (
<Col xs={24} sm={12} key={idx}>
<div style={{ background: styleConf.bg, borderRadius: 8, padding: 8, height: '100%' }}>
<div style={{ display: 'flex', justifyContent: 'space-between', marginBottom: 4, alignItems: 'center' }}>
{styleConf.icon}
</div>
<div style={{ fontWeight: 600, fontSize: 11, color: styleConf.color, marginBottom: 2 }}>
{role.roleName}
</div>
<div style={{ fontSize: 9, color: '#8c8c8c', marginBottom: 6 }}>
用户 {role.users} | 菜单权限 {role.menuIds?.length ?? 0}
</div>
<div style={{ display: 'flex', gap: 4, flexWrap: 'wrap' }}>
{styleConf.tags.map((tag, tidx) => (
<span
key={tidx}
style={{
fontSize: 8,
padding: '0 4px',
background: '#fff',
color: styleConf.color,
borderRadius: 2,
border: `1px solid ${styleConf.color}20`
}}
>
{tag}
</span>
))}
</div>
</div>
<div style={{ fontWeight: 600, fontSize: 11, color: role.color, marginBottom: 2 }}>{role.title}</div>
<div style={{ fontSize: 9, color: '#8c8c8c', marginBottom: 6 }}>
用户 {role.users} | 权限 {role.perms}
</div>
<div style={{ display: 'flex', gap: 4, flexWrap: 'wrap' }}>
{role.tags.map((tag, tidx) => (
<span key={tidx} style={{ fontSize: 8, padding: '0 4px', background: '#fff', color: role.color, borderRadius: 2, border: `1px solid ${role.color}20` }}>{tag}</span>
))}
</div>
</div>
</Col>
))}
</Col>
);
})}
</Row>
</AntdCard>
@@ -429,9 +497,9 @@ const BasicSettings = () => {
<AntdCard
title={<Space><ApiOutlined style={{ color: '#1677ff' }} /><b>{t('systemSetting.fixed2DeviceAccessFixed2StatusFixed2')}</b></Space>}
extra={<Button type="link" size="small" style={{ fontSize: 11, padding: 0 }}>{t('common.detail')}<RightOutlined style={{ fontSize: 9 }} /></Button>}
variant="borderless"
bordered={false}
style={{ borderRadius: 10, marginBottom: 8, boxShadow: '0 2px 8px rgba(0,0,0,0.04)' }}
styles={{ body: { padding: '12px' } }}
bodyStyle={{ padding: '12px' }}
>
<div style={{ display: 'flex', gap: 12 }}>
<div style={{ flex: '0 0 90px' }}>
@@ -488,9 +556,9 @@ const BasicSettings = () => {
{/* 数据与安全 */}
<AntdCard
title={<Space><Shield size={16} style={{ color: '#1677ff' }} /><b>{t('systemSetting.dataSafety')}</b></Space>}
variant="borderless"
bordered={false}
style={{ borderRadius: 10, marginBottom: 8, boxShadow: '0 2px 8px rgba(0,0,0,0.04)' }}
styles={{ body: { padding: '12px' } }}
bodyStyle={{ padding: '12px' }}
>
<div style={{ display: 'grid', gridTemplateColumns: 'repeat(auto-fit, minmax(120px, 1fr))', gap: '10px 16px' }}>
{[
@@ -519,9 +587,9 @@ const BasicSettings = () => {
<AntdCard
title={<Space><Wrench size={16} style={{ color: '#1677ff' }} /><b>{t('systemSetting.systemMaintenance')}</b></Space>}
extra={<Button type="link" size="small" danger style={{ fontSize: 10, padding: 0 }}>{t('systemSetting.s192')}</Button>}
variant="borderless"
bordered={false}
style={{ borderRadius: 10, boxShadow: '0 2px 8px rgba(0,0,0,0.04)' }}
styles={{ body: { padding: '12px' } }}
bodyStyle={{ padding: '12px' }}
>
<Row gutter={[8, 8]}>
{[

View File

@@ -104,7 +104,7 @@ const LogManagement = () => {
<Text type="secondary" style={{ fontSize: 12 }}>{t('systemSetting.equipmentControlActionsSuperAdminViewFixed2')}</Text>
</div>
<AntdCard variant="borderless" style={{ borderRadius: 10, marginBottom: 8, boxShadow: '0 2px 8px rgba(0,0,0,0.04)' }} styles={{ body: { padding: 12 } }}>
<AntdCard bordered={false} style={{ borderRadius: 10, marginBottom: 8, boxShadow: '0 2px 8px rgba(0,0,0,0.04)' }} bodyStyle={{ padding: 12 }}>
<Row gutter={[8, 8]} align="middle">
<Col xs={24} sm={8} md={5}>
<Select
@@ -142,7 +142,7 @@ const LogManagement = () => {
</Row>
</AntdCard>
<AntdCard variant="borderless" style={{ borderRadius: 10, boxShadow: '0 2px 8px rgba(0,0,0,0.04)' }} styles={{ body: { padding: 4 } }}>
<AntdCard bordered={false} style={{ borderRadius: 10, boxShadow: '0 2px 8px rgba(0,0,0,0.04)' }} bodyStyle={{ padding: 4 }}>
<Table
size="small"
rowKey="id"

View File

@@ -102,7 +102,7 @@ const OnlineUserPage = () => {
{/* ====================== Tab 1:在线用户 ====================== */}
{activeTab === 'onlineUser' && (
<Card variant="borderless" style={{ borderRadius: 8 }}>
<Card bordered={false} style={{ borderRadius: 8 }}>
{/* 搜索栏 */}
<div style={{ display: 'flex', alignItems: 'center', gap: 16, marginBottom: 20 }}>
<div style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
@@ -140,14 +140,14 @@ const OnlineUserPage = () => {
showTotal: (total) => `${t('common.total')} ${total} ${t('common.items')}`,
showQuickJumper: true
}}
variant="borderless"
bordered={false}
/>
</Card>
)}
{/* ====================== Tab 2:其他页面(你可以随便改内容) ====================== */}
{activeTab === 'other' && (
<Card variant="borderless" style={{ borderRadius: 8, padding: '40px 0', textAlign: 'center' }}>
<Card bordered={false} style={{ borderRadius: 8, padding: '40px 0', textAlign: 'center' }}>
<h2>{t('systemSetting.fixed2OthersContentFixed2')}</h2>
<p>{t('systemSetting.statusCpuContentFixed2')}</p>
</Card>

View File

@@ -14,14 +14,12 @@ import {
App,
Card,
InputNumber,
Upload,
} from 'antd';
const { Text } = Typography;
import {
ReloadOutlined,
LinkOutlined,
DisconnectOutlined,
UploadOutlined,
EditOutlined,
} from '@ant-design/icons';
@@ -29,7 +27,6 @@ import {
getAllDevice,
bindSmartDevice,
unbindSmartDevice,
importBindDevices,
getDeviceAuth,
hasPermission,
} from '@/api/device';
@@ -264,28 +261,6 @@ export default function SmartDeviceManagement({
}, 0);
};
// 上传 Excel 批量导入绑定装备
const handleImportDevices = async (options: any) => {
const { file, onSuccess, onError } = options;
try {
const formData = new FormData();
formData.append('file', file);
const res = await importBindDevices(formData);
if (res.code == 200 && res.data == true) {
utils.message.success(res.msg || t('systemSetting.importSuccess'));
onSuccess?.(res);
fetchSmartList();
onAllDataNeedRefresh?.();
} else {
utils.message.error(res.msg || t('systemSetting.importFail'));
onError?.(new Error(res.msg || 'import failed'));
}
} catch (err) {
utils.message.error(t('systemSetting.importFail'));
onError?.(err);
}
};
const handleBindSmart = async (values) => {
try {
const payload = {
@@ -411,9 +386,6 @@ export default function SmartDeviceManagement({
/>
<Button icon={<ReloadOutlined />} onClick={() => setSmartParams({ pageNum: 1, pageSize: 10, serialNumber: '' })}>{t('common.reset')}</Button>
<Button type="primary" icon={<LinkOutlined />} onClick={openBindSmartModal}>{t('systemSetting.equipmentFixed22')}</Button>
<Upload customRequest={handleImportDevices} showUploadList={false} accept='.xlsx,.xls'>
<Button icon={<UploadOutlined />}>{t('common.import')}</Button>
</Upload>
<Button disabled={selectedSmartKeys.length === 0} onClick={() => handleUnbindSmart(selectedSmartKeys, 1)}>{t('systemSetting.batchUnbindUser')}</Button>
<Button disabled={selectedSmartKeys.length === 0} onClick={() => handleUnbindSmart(selectedSmartKeys, 2)}>{t('systemSetting.batchUnbindStation')}</Button>
<Button disabled={selectedSmartKeys.length === 0} onClick={() => handleUnbindSmart(selectedSmartKeys, 3)}>{t('systemSetting.batchUnbindOrg')}</Button>

View File

@@ -14,8 +14,7 @@ import {
import { getOrgList } from '../../api/organization';
import { fetchPublishedLayers } from '../../lib/geoServer';
import { useSelector } from 'react-redux';
import { useAppDispatch, RootState } from '../../store';
import { setCurrentStation as setStoreStation } from '../../store/stationSlice';
import { RootState } from '../../store';
import { useTranslation } from 'react-i18next';
const { Option } = Select;
@@ -36,8 +35,6 @@ export default function StationManage() {
// 获取当前登录用户信息
const { userInfo } = useSelector((state: RootState) => state.user);
const dispatch = useAppDispatch();
const { currentStation: storeStation } = useSelector((state: RootState) => state.station);
// 场站弹窗
const [modalVisible, setModalVisible] = useState(false);
@@ -194,10 +191,6 @@ export default function StationManage() {
if (res.code === 200) {
messageApi.success(editRecord ? t('common.editSuccess') : t('common.addSuccess'));
getStationData();
// 编辑的场站若正是当前选中场站,则同步更新到 store(尤其 siteMapName)
if (editRecord && storeStation && editRecord.id === storeStation.id) {
dispatch(setStoreStation({ ...storeStation, ...params }));
}
setModalVisible(false);
} else {
messageApi.error(res.msg || t('common.saveFail'));
@@ -271,7 +264,7 @@ export default function StationManage() {
{ title: t('systemSetting.siteName'), dataIndex: 'siteName' },
{
title: t('systemSetting.mappingLayer'),
dataIndex: 'siteMapName',
dataIndex: 'site_map_name',
render: (value) => value ? (
<Tag color="blue">{value}</Tag>
) : (
@@ -395,7 +388,7 @@ export default function StationManage() {
<Input placeholder={t('systemSetting.s14')} />
</Form.Item>
<Form.Item name="siteMapName" label={t('systemSetting.mappingLayer')}>
<Form.Item name="site_map_name" label={t('systemSetting.mappingLayer')}>
<Select
placeholder={t('systemSetting.mappingLayerPlaceholder')}
loading={layerLoading}

View File

@@ -185,7 +185,7 @@ const VideoManagement = () => {
</div>
<Card variant="borderless" style={{ borderRadius: 10, marginBottom: 8 }} styles={{ body: { padding: 12 } }}>
<Card bordered={false} style={{ borderRadius: 10, marginBottom: 8 }} bodyStyle={{ padding: 12 }}>
<Row gutter={[8, 8]} align="middle">
<Col xs={24} sm={10} md={7}>
<Text style={{ fontSize: 12, color: '#666' }}>{t('systemSetting.s0')}</Text>
@@ -225,7 +225,7 @@ const VideoManagement = () => {
</Row>
</Card>
<Card variant="borderless" style={{ borderRadius: 10 }} styles={{ body: { padding: 4 } }}>
<Card bordered={false} style={{ borderRadius: 10 }} bodyStyle={{ padding: 4 }}>
{loading ? (
<div style={{ textAlign: 'center', padding: 40 }}><Spin /></div>
) : !channel ? (

View File

@@ -61,50 +61,44 @@ class WebSocketManager {
// ==================== 连接管理 ====================
public connect(serialNumber: string, wsUrl: string): void {
console.log("创建开始");
// 清除重连计时器
console.log("创建开始");//ws://192.168.2.56:9002/ws/
// 清除之前的重连计时器
if (this.reconnectTimer) {
clearTimeout(this.reconnectTimer);
this.reconnectTimer = null;
}
if (serialNumber == null || serialNumber.trim() === "") {
console.log("serialNumber 是空/空白,停止执行");
return;
}
// 如果序列号相同且已连接,跳过
if (this.ws && this.currentSerialRef === serialNumber && this.status === 'connected') {
console.log('WebSocket already connected for this device');
return;
}
// ========== 重点修复:关闭旧连接,并且清空旧ws的事件监听,防止旧消息回调执行 ==========
if (this.ws) {
// 解绑所有事件,阻止旧ws继续触发onmessage/onclose
this.ws.onopen = null;
this.ws.onmessage = null;
this.ws.onerror = null;
this.ws.onclose = null;
// 如果序列号不同,先关闭旧连接
if (this.ws && this.currentSerialRef !== serialNumber) {
this.close();
this.ws = null;
}
this.currentSerialRef = serialNumber;
this.setStatus('connecting');
this.isManualCloseRef = false;
// 提前赋值,不要等到new WebSocket之后
this.wsSerialRef = serialNumber;
console.log('Connecting WebSocket for', serialNumber);
if (serialNumber == null || serialNumber.trim() === "") {
console.log("serialNumber 是空/空白,停止执行");
return;
}
this.ws = new WebSocket(wsUrl);
this.wsSerialRef = serialNumber;
this.ws.onopen = () => {
console.log('WebSocket Connected');
this.setStatus('connected');
const dataStr = localStorage.getItem('userInfo');
if (!dataStr) {
console.error('用户信息未找到,无法发送认证包');
@@ -115,21 +109,18 @@ class WebSocketManager {
console.log('WebSocket%', token);
console.log('WebSocket%', parse);
console.log("开始发送认证包");
console.log("开始发送认证包");//ws://192.168.2.56:9002/ws/
// 发送 AUTH 认证消息
this.send({
type: 'AUTH',
token: token,
userName: parse.username,
deviceId: serialNumber,
});
};
this.ws.onmessage = (event) => {
// 【防御二次校验】只有当前活跃serial才处理消息,旧连接残留消息直接丢弃
if (this.wsSerialRef !== this.currentSerialRef) {
console.log('丢弃过期ws消息');
return;
}
try {
const data = JSON.parse(event.data);
this.handleMessage(data);
@@ -146,7 +137,7 @@ class WebSocketManager {
const { code, reason, wasClean } = event;
console.log('[WebSocket closed]', 'code =', code, 'reason =', reason || '(no reason)', 'wasClean =', wasClean);
// 不是当前设备直接忽略
// 如果不是当前设备的 ws,忽略
if (this.wsSerialRef !== this.currentSerialRef) {
console.log('🟡 ignore old ws close');
return;
@@ -155,13 +146,15 @@ class WebSocketManager {
this.ws = null;
this.setStatus('disconnected');
// 主动关闭不重连
if (this.isManualCloseRef || !this.currentSerialRef) {
return;
}
// 5 秒后自动重连
this.reconnectTimer = setTimeout(() => {
if (this.currentSerialRef === this.wsSerialRef) {
this.connect(this.currentSerialRef!, wsUrl);
this.connect(this.currentSerialRef, wsUrl);
}
}, 5000);
};
@@ -171,17 +164,21 @@ class WebSocketManager {
public close(): void {
this.isManualCloseRef = true;
if (this.reconnectTimer) {
clearTimeout(this.reconnectTimer);
this.reconnectTimer = null;
}
if (this.ws) {
try {
this.ws.close(1000, 'manual close');
} catch (e) {
console.warn('ws close exception', e);
}
console.log('Closing WebSocket');
this.ws.close();
this.ws = null;
}
this.currentSerialRef = null;
this.wsSerialRef = null;
this.setStatus('disconnected');
}
// ==================== 消息发送 ====================

View File

@@ -618,8 +618,8 @@ export default function AlarmCenterPage() {
].map((item, idx) => (
<Col key={idx} style={{ minWidth: '200px', flex: '1 1 auto', maxWidth: "400px" }}>
<Card
variant="borderless"
styles={{ body: { padding: '16px 20px' } }}
bordered={false}
bodyStyle={{ padding: '16px 20px' }}
style={{ borderRadius: 8, height: 120 }}
>
<Row align="middle" gutter={16} style={{ height: '100%' }}>
@@ -658,7 +658,7 @@ export default function AlarmCenterPage() {
</Row>
<Row gutter={8} style={{ marginBottom: 8 }}>
<Col span={24}>
<Card variant="borderless" styles={{ body: { padding: '16px 24px' } }} style={{ borderRadius: 8 }}>
<Card bordered={false} bodyStyle={{ padding: '16px 24px' }} style={{ borderRadius: 8 }}>
<Row gutter={[8, 8]} align="middle">
<Col>
<div style={{ fontSize: 12, color: '#4E5969', marginBottom: 4 }}>{t('alerts.alertLevel')}</div>
@@ -747,7 +747,7 @@ export default function AlarmCenterPage() {
{/* 表格 */}
<Row gutter={16} style={{ marginBottom: 8 }}>
<Col flex="auto" style={{ minWidth: 0 }}>
<Card variant="borderless" styles={{ body: { padding: '16px 24px' } }} style={{ borderRadius: 8 }}>
<Card bordered={false} bodyStyle={{ padding: '16px 24px' }} style={{ borderRadius: 8 }}>
<Spin spinning={loading}>
<Table
rowKey="id"
@@ -774,7 +774,7 @@ export default function AlarmCenterPage() {
{/* 三个图表 */}
<Row gutter={16}>
<Col span={8}>
<Card variant="borderless" title={t('alerts.alertTrend')} style={{ borderRadius: 8 }}>
<Card bordered={false} title={t('alerts.alertTrend')} style={{ borderRadius: 8 }}>
<UniversalLineChart
data={getAlarmTrendData()}
xKey="date"
@@ -807,7 +807,7 @@ export default function AlarmCenterPage() {
</Card>
</Col>
<Col span={8}>
<Card variant="borderless" title={t('alerts.alertTypeProportion')} style={{ borderRadius: 8 }}>
<Card bordered={false} title={t('alerts.alertTypeProportion')} style={{ borderRadius: 8 }}>
<UniversalPieChart
data={pieData}
height={220}
@@ -818,7 +818,7 @@ export default function AlarmCenterPage() {
</Card>
</Col>
<Col span={8}>
<Card variant="borderless" title={t('alerts.alertStatusStatistics')} style={{ borderRadius: 8 }}>
<Card bordered={false} title={t('alerts.alertStatusStatistics')} style={{ borderRadius: 8 }}>
<UniversalBarChart
data={[
{

View File

@@ -99,7 +99,7 @@ const AlarmStatistics = () => {
return (
<div style={{ padding: 24, background: '#f5f7fa', minHeight: '100vh' }}>
<Card title={t('alerts.alertOverview')} variant="borderless" style={{ marginBottom: 24, borderRadius: 8 }}>
<Card title={t('alerts.alertOverview')} bordered={false} style={{ marginBottom: 24, borderRadius: 8 }}>
<Row gutter={16} align="middle">
<Col xs={24} sm={12} md={6}>
<Space size={16}>
@@ -153,13 +153,13 @@ const AlarmStatistics = () => {
<Row gutter={16}>
<Col xs={24} md={12}>
<Card variant="borderless" style={{ borderRadius: 8 }}>
<Card bordered={false} style={{ borderRadius: 8 }}>
<div ref={barChartRef} style={{ width: '100%', height: 360 }} />
</Card>
</Col>
<Col xs={24} md={12}>
<Card variant="borderless" style={{ borderRadius: 8 }}>
<Card bordered={false} style={{ borderRadius: 8 }}>
<div ref={pieChartRef} style={{ width: '100%', height: 360 }} />
</Card>
</Col>

View File

@@ -50,15 +50,8 @@ interface Robot {
lastRunningStatus?: {
latitude: string | number;
longitude: string | number;
battery: string | number;
battery: number;
};
locationMessage?: {
latitude: string | number;
longitude: string | number;
battery: string | number;
};
drone_callsign?: string;
serialNumber?: string;
}
@@ -466,17 +459,8 @@ const RobotControlCenter = ({ setView }) => {
}
const getControl = (serialnum) => {
setIsConnecting(true);
let userParse = null;
try {
const dataStr = localStorage.getItem("userInfo");
userParse = dataStr ? JSON.parse(dataStr) : null;
} catch (e) {
console.error("用户信息解析失败", e);
}
const token = userParse.token || Cookies.get("Admin-Token");
const data = { platform: "web", deviceId: serialnum, token: token };
const data = { platform: "web", deviceId: serialnum };
getJurisdiction(data).then(res => {
if (res?.data?.code === 200 && res?.data?.data?.remoteControl == true) {
console.log("获取远程遥控权限成功");
@@ -1047,8 +1031,8 @@ const RobotControlCenter = ({ setView }) => {
};
const mapFocus = selectedDevice ? {
lat: selectedDevice?.locationMessage?.latitude || selectedDevice?.lastRunningStatus?.latitude,
lon: selectedDevice?.locationMessage?.longitude || selectedDevice?.lastRunningStatus?.longitude,
lat: selectedDevice.lastRunningStatus.latitude,
lon: selectedDevice.lastRunningStatus.longitude,
height: 500
} : { lat: '31.030129089704428', lon: '120.76671769055027', height: 800 };
//手柄数据

View File

@@ -1,4 +1,4 @@
import React, { useState, useEffect, useRef, useMemo, useCallback } from 'react';
import React, { useState, useEffect, useRef, useMemo } from 'react';
import {
Layout, Card, Row, Col, Statistic, Tag, Button, Table,
Typography, Space, Progress, Badge, Timeline, message,
@@ -17,13 +17,15 @@ import {
} from '@ant-design/icons';
import { useNavigate } from 'react-router-dom';
// 组件内
import DroneLivePlayer from '../VolcRtcPlayer.jsx';
import DroneVideoPlayer from './DroneVideoPlayer';
import AgoraTextTest from '../AgoraRtc.tsx';
import { useWebRTCPlayer } from '../useWebRTCStream.tsx';
import VideoPlayer from '../VideoPlayer.tsx';
import AgrtcRoomRobot from '../AgrtcRoomRobot';
import CesiumMap from '../Map.jsx';
import DeviceParamModal from './DeviceParamModal';
import { getUAVState, getSiteDevice, getSiteUAVList, getsinglePlan, getRobotTaskList, getDeviceTotalData, updateDeviceAliasApi, hasPermission } from '@/api/device.ts';
@@ -289,7 +291,7 @@ export default function DeviceOverviewPage() {
}, [selectedDevice, uavState, persistentHostData, persistentDroneData?.wind_speed]);
// MQTT消息处理
const handleMqttMessage = useCallback((topic, message) => {
const handleMqttMessage = (topic, message) => {
try {
@@ -396,7 +398,7 @@ export default function DeviceOverviewPage() {
} catch (err) {
console.error('MQTT解析失败', err);
}
}, []);
};
// MQTT订阅
const mqttTopics = useMemo(() => {
@@ -415,13 +417,12 @@ export default function DeviceOverviewPage() {
url: envConfig.mqtt_url,
topic: mqttTopics,
onMessage: handleMqttMessage,
enabled: mqttTopics.length > 0,
});
// 机器人视频
// 机器人视频:只有 robotPlayActive = true 才真正拉流
const { video: robotVideo, error, ready } = useWebRTCPlayer(
(!isUAV && robotPlayActive && !selectedDevice?.hasHost) ? (selectedDevice?.serialNumber || '') : '',
(!isUAV && robotPlayActive) ? (selectedDevice?.serialNumber || '') : '',
(!isUAV && robotPlayActive)
? `webrtc://1.95.137.212/live/livestream/${selectedDevice?.serialNumber}`
: ''
@@ -585,8 +586,8 @@ export default function DeviceOverviewPage() {
{dynamicTopCards.map((card, idx) => (
<Col key={idx} style={{ minWidth: '200px', flex: '1 0 auto', maxWidth: "260px" }}>
<Card
variant="borderless"
styles={{ body: { padding: '20px 20px', display: 'flex', alignItems: 'flex-start', justifyContent: 'space-between' } }}
bordered={false}
bodyStyle={{ padding: '20px 20px', display: 'flex', alignItems: 'flex-start', justifyContent: 'space-between' }}
style={{ borderRadius: 8, boxShadow: '0 2px 8px rgba(0,0,0,0.06)', height: 101 }}
>
{/* 左侧文字区域 */}
@@ -626,7 +627,7 @@ export default function DeviceOverviewPage() {
<Row gutter={[8, 8]}>
<Col xs={24} lg={14}>
<Card title={<><EnvironmentOutlined />{t('devices.fixed2Equipment')}</>} extra={<Button type="text" icon={<SettingOutlined />} />} variant="borderless" style={{ borderRadius: 8, marginBottom: 8 }} styles={{ body: { padding: 0 } }}>
<Card title={<><EnvironmentOutlined />{t('devices.fixed2Equipment')}</>} extra={<Button type="text" icon={<SettingOutlined />} />} bordered={false} style={{ borderRadius: 8, marginBottom: 8 }} bodyStyle={{ padding: 0 }}>
<div style={{ width: '100%', height: 350, borderRadius: 8, position: 'relative', overflow: 'hidden' }}>
<div style={{ position: 'absolute', zIndex: 9999, top: 12, left: 12, background: 'rgba(255,255,255,0.95)', borderRadius: 6, padding: 8 }}>
<div style={{ fontSize: 11, fontWeight: 60, marginBottom: 4 }}>{t('devices.s22')}</div>
@@ -640,11 +641,11 @@ export default function DeviceOverviewPage() {
<div><span style={{ color: '#ff4d4f' }}>■</span>{t('devices.s9')}</div>
</div>
</div>
<CesiumMap devices={devicesAll} mapLayer={currentStation?.siteMapName} />
<CesiumMap devices={devicesAll} />
</div>
</Card>
<Card title={<><SettingOutlined />{t('devices.fixed2EquipmentListFixed2')}</>} variant="borderless" style={{ borderRadius: 8, marginBottom: 8 }}>
<Card title={<><SettingOutlined />{t('devices.fixed2EquipmentListFixed2')}</>} bordered={false} style={{ borderRadius: 8, marginBottom: 8 }}>
<Table rowKey={(record) => record.id || record.serialNumber || record.device_sn} size="small" pagination={false}
columns={[
{ title: t('devices.fixed2EquipmentFixed2NameFixed2'), dataIndex: 'name', width: 140 },
@@ -719,7 +720,7 @@ export default function DeviceOverviewPage() {
/>
</Card>
<Card title={<><SettingOutlined /> <span >{t('devices.fixed2ControlFixed2LogDesc6Alert')}</span></>} variant="borderless" style={{ borderRadius: 8 }} extra={<div style={{ display: 'flex', alignItems: 'center', gap: 8 }}><Button size="small" style={{ borderRadius: 4, border: '1px solid #d9d9d9' }}>{t('devices.fixed2AllLevels')}</Button></div>}>
<Card title={<><SettingOutlined /> <span >{t('devices.fixed2ControlFixed2LogDesc6Alert')}</span></>} bordered={false} style={{ borderRadius: 8 }} extra={<div style={{ display: 'flex', alignItems: 'center', gap: 8 }}><Button size="small" style={{ borderRadius: 4, border: '1px solid #d9d9d9' }}>{t('devices.fixed2AllLevels')}</Button></div>}>
<Table rowKey="time" size="small" pagination={false} dataSource={logs} scroll={{ x: 'max-content' }}
columns={[
{ title: t('common.time'), dataIndex: 'time', width: 90, render: t => <span style={{ fontSize: 13 }}>{t}</span> },
@@ -735,7 +736,7 @@ export default function DeviceOverviewPage() {
<Col xs={24} lg={10}>
<Card title={<><SettingOutlined style={{ marginRight: 6, }} />{t('devices.deviceControlPanel')}</>} variant="borderless" style={{ borderRadius: 8, marginBottom: 8 }} styles={{ body: { padding: 12, paddingBottom: 0 } }}>
<Card title={<><SettingOutlined style={{ marginRight: 6, }} />{t('devices.deviceControlPanel')}</>} bordered={false} style={{ borderRadius: 8, marginBottom: 8 }} bodyStyle={{ padding: 12, paddingBottom: 0 }}>
<Select
style={{ width: "80%", marginBottom: 8 }}
placeholder={t('workOrder.selectDeviceFixed2')}
@@ -749,8 +750,8 @@ export default function DeviceOverviewPage() {
String(option?.label || "").toLowerCase().includes(input.toLowerCase())
}
options={[
{ label: <span>{t('devices.robot')}</span>, options: devices.map(item => ({ value: item.device_sn || item.serialNumber, label: item.deviceAlias || item.deviceName || '未知设备' })) },
{ label: <span>{t('constants.uav')}</span>, options: planedevices.map(item => ({ value: item.device_sn, label: item.drone_callsign || item.callsign || '未知设备' })) },
{ label: <span>devices.robot</span>, options: devices.map(item => ({ value: item.device_sn || item.serialNumber, label: item.deviceAlias || item.deviceName || '未知设备' })) },
{ label: <span>constants.uav</span>, options: planedevices.map(item => ({ value: item.device_sn, label: item.drone_callsign || item.callsign || '未知设备' })) },
]}
/>
@@ -876,11 +877,7 @@ export default function DeviceOverviewPage() {
/>
) : (
robotPlayActive ? (
selectedDevice?.hasHost ? (
<div style={{ width: '100%', height: '100%', position: 'relative', overflow: 'hidden', background: '#000', borderRadius: 8 }}>
<AgrtcRoomRobot CHANNEL={selectedDevice?.serialNumber || ''} />
</div>
) : robotVideo ? (
robotVideo ? (
<VideoPlayer
deviceId={selectedDevice?.device_sn || selectedDevice?.serialNumber}
idx={mowerView === 'front' ? 1 : mowerView === 'back' ? 2 : mowerView === 'left' ? 3 : 4}
@@ -949,7 +946,7 @@ export default function DeviceOverviewPage() {
)}
</Card>
<Card title={<><ApiOutlined />{t('devices.fixed2AiActions')}</>} variant="borderless" style={{ borderRadius: 12, marginBottom: 8 }}>
<Card title={<><ApiOutlined />{t('devices.fixed2AiActions')}</>} bordered={false} style={{ borderRadius: 12, marginBottom: 8 }}>
<Row gutter={16} style={{ marginBottom: 8 }}>
<Col span={6}><div style={{ display: 'flex', alignItems: 'center', gap: 10, padding: '6px 12px 4px', borderRadius: 12, border: '1px solid #e8e8e8' }}><div style={{ width: 30, height: 30, borderRadius: '50%', background: 'rgba(255,77,79,0.15)', display: 'flex', alignItems: 'center', justifyContent: 'center', color: '#ff4d4f', fontSize: 20 }}><span role="img" aria-label="hotspot">🔥</span></div><div><div style={{ fontSize: 11, color: '#666' }}>{t('devices.hotspotSuspect')}</div><div style={{ fontSize: 22, fontWeight: 700, color: '#222' }}>2 <span style={{ fontSize: 12 }}>{t('devices.s32')}</span></div></div></div></Col>
<Col span={6}><div style={{ display: 'flex', alignItems: 'center', gap: 10, padding: '6px 12px 4px', borderRadius: 12, border: '1px solid #e8e8e8' }}><div style={{ width: 30, height: 30, borderRadius: '50%', background: 'rgba(82,196,26,0.15)', display: 'flex', alignItems: 'center', justifyContent: 'center', color: '#52c41a', fontSize: 16 }}><BranchesOutlined /></div><div><div style={{ fontSize: 11, color: '#666' }}>{t('devices.s33')}</div><div style={{ fontSize: 22, fontWeight: 700, color: '#222' }}>3 <span style={{ fontSize: 12 }}>{t('devices.s34')}</span></div></div></div></Col>
@@ -980,7 +977,7 @@ export default function DeviceOverviewPage() {
</Card>
{(selectedDevice?.productName?.includes(t('constants.uav')) || selectedDevice?.device_sn) && (
<Card title={t('devices.s60')} variant="borderless" style={{ borderRadius: 12, marginBottom: 8 }}>
<Card title={t('devices.s60')} bordered={false} style={{ borderRadius: 12, marginBottom: 8 }}>
<div style={{ display: "flex", justifyContent: "space-between", gap: 12, alignItems: "center" }}>
<div style={{ display: "flex", border: "1px solid #e8e8e8", borderRadius: 12, overflow: "hidden", flex: 1 }}>
<div style={{ flex: 1, textAlign: 'center', whiteSpace: "nowrap", padding: "12px 4px", borderRight: "1px solid #e8e8e8" }}><div style={{ fontSize: 11, color: '#666', fontWeight: 600 }}>{t('devices.s44')}</div><div style={{ fontSize: 14, fontWeight: 700, color: '#222', marginTop: 2 }}>{fix2(realtimeDevice?.wind_speed)} m/s</div></div>
@@ -1000,7 +997,7 @@ export default function DeviceOverviewPage() {
)}
{(!selectedDevice?.productName?.includes(t('constants.uav')) && !selectedDevice?.device_sn) && (
<Card title={<div style={{ display: 'flex', alignItems: 'center', gap: 8, fontSize: 14, fontWeight: 600 }}><RobotOutlined style={{ color: '#165DFF' }} />{t('devices.fixed2RobotStatusFixed2')}</div>} variant="borderless" style={{ borderRadius: 12, marginBottom: 8, boxShadow: '0 2px 8px rgba(0,0,0,0.06)', border: '1px solid #f0f0f0' }}>
<Card title={<div style={{ display: 'flex', alignItems: 'center', gap: 8, fontSize: 14, fontWeight: 600 }}><RobotOutlined style={{ color: '#165DFF' }} />{t('devices.fixed2RobotStatusFixed2')}</div>} bordered={false} style={{ borderRadius: 12, marginBottom: 8, boxShadow: '0 2px 8px rgba(0,0,0,0.06)', border: '1px solid #f0f0f0' }}>
<Row gutter={16} style={{ alignItems: 'center' }}>
<Col span={8}>
<div style={{ padding: '12px 16px', borderRadius: 10, background: '#F7F8FA', textAlign: 'center', border: '1px solid transparent', transition: 'all 0.2s' }}
@@ -1063,7 +1060,7 @@ export default function DeviceOverviewPage() {
</Card>
)}
<Card title={<><ClockCircleOutlined />{t('devices.fixed2TaskSuspended2Fixed2ExecutionTime')}</>} variant="borderless" style={{ borderRadius: 12 }} extra={<div style={{ fontSize: 12, color: '#666' }}></div>}>
<Card title={<><ClockCircleOutlined />{t('devices.fixed2TaskSuspended2Fixed2ExecutionTime')}</>} bordered={false} style={{ borderRadius: 12 }} extra={<div style={{ fontSize: 12, color: '#666' }}></div>}>
<Timeline mode="left">
{taskTimeline.map((item, idx) => (
<Timeline.Item key={idx} color={item.color} label={<div style={{ fontSize: 11, color: '#999' }}>{item.time}</div>}>

View File

@@ -174,14 +174,6 @@ const DeviceParamModal: React.FC<DeviceParamModalProps> = ({ open, device, onCan
{ key: 'rightBackwardGain', label: t('devices.paramRightBackwardGain'), type: 'InputNumber', editable: true, min: 0, max: 1, step: 0.01 },
{ key: 'runSpeed', label: t('devices.paramRunSpeed'), type: 'InputNumber', editable: true },
//hasHost: "hasHost",
//rtkMode: "rtkMode", cameraNum: "cameraNum", wheelType: "wheelType", engineType: "engineType", capabilityList: "capabilityList", powerType: "powerType",
{ key: 'hasHost', label: t('devices.hasHost'), type: 'Input', editable: false },
{ key: 'rtkMode', label: t('devices.rtkMode'), type: 'Input', editable: false },
{ key: 'cameraNum', label: t('devices.cameraNum'), type: 'Input', editable: false },
{ key: 'wheelType', label: t('devices.wheelType'), type: 'Input', editable: false },
{ key: 'engineType', label: t('devices.engineType'), type: 'Input', editable: false },
{ key: 'capabilityList', label: t('devices.capabilityList'), type: 'Input', editable: false },
{ key: 'chipUidSign', label: t('devices.paramChipUidSign'), type: 'InputNumber', editable: false },
{ key: 'chipUid', label: t('devices.paramChipUid'), type: 'Input', editable: false },
{ key: 'remoteConfig', label: t('devices.paramRemoteConfig'), type: 'InputNumber', editable: false },

View File

@@ -1,4 +1,4 @@
import React, {
import React, {
useState,
useEffect,
useMemo,
@@ -53,7 +53,6 @@ import { useSelector } from 'react-redux';
import { RootState } from '@/src/store/index.ts';
import { useWebRTCPlayer } from '../useWebRTCStream.tsx';
import VideoPlayer from '../VideoPlayer.tsx';
import AgrtcRoomRobot from '../AgrtcRoomRobot';
import DeviceController from './DeviceController';
import { DatePicker } from 'antd';
import dayjs from 'dayjs';
@@ -67,7 +66,6 @@ const { RangePicker } = DatePicker;
const { Text } = Typography;
export default function DeviceStatusPage() {
const { t } = useTranslation();
const { userInfo } = useSelector((state: RootState) => state.user);
@@ -80,7 +78,6 @@ export default function DeviceStatusPage() {
const [arrivedPoint, setArrivedPoint] = useState(null);//完成点
const [isLoopMode, setIsLoopMode] = useState(true);
const controllerRef = useRef<DeviceController | null>(null);
const isFirstConnect = useRef(true);
const [messageApi, contextHolder] = message.useMessage();
@@ -98,7 +95,6 @@ export default function DeviceStatusPage() {
const [connecting, setConnecting] = useState(false);
const [wsStatus, setWsStatus] = useState('disconnected');
const [wsDeviceInfo, setWsDeviceInfo] = useState({});
const [locationInfo, setLocationInfo] = useState({});
// 👇 加上这两个
@@ -125,8 +121,7 @@ export default function DeviceStatusPage() {
const [isSaveModalVisible, setIsSaveModalVisible] = useState(false); // 保存模态框可见性
const [plotName, setPlotName] = useState(''); // 地块名称
const [isSaving, setIsSaving] = useState(false); // 是否正在保存
const mapRef = useRef(null);
const clearDrawRef = useRef<(() => void) | null>(null); // 地图 ref
const mapRef = useRef(null); // 地图 ref
const location = useLocation();
const queryParams = new URLSearchParams(location.search);
@@ -249,7 +244,7 @@ export default function DeviceStatusPage() {
};
// 当MQTT数据更新时,更新持久化数据(只在有新数据时更新)
const handleMqttMessage = useCallback((topic, message) => {
const handleMqttMessage = (topic, message) => {
try {
const parsedMessage = JSON.parse(message);
@@ -357,7 +352,7 @@ export default function DeviceStatusPage() {
} catch (err) {
console.error('DeviceStatusPage MQTT 消息解析失败:', err);
}
}, []);
};
// 根据选中设备动态构建MQTT主题
const mqttTopics = useMemo(() => {
@@ -379,7 +374,6 @@ export default function DeviceStatusPage() {
url: envConfig.mqtt_url,
topic: mqttTopics,
onMessage: handleMqttMessage,
enabled: mqttTopics.length > 0,
});
// 合并无人机和机场数据
@@ -394,7 +388,7 @@ export default function DeviceStatusPage() {
const runningStatus = useMemo(() => {
// 判断对象是否为空
if ((!wsDeviceInfo || Object.keys(wsDeviceInfo).length === 0) && (!locationInfo || Object.keys(locationInfo).length === 0) && !isUAV) {
if ((!wsDeviceInfo || Object.keys(wsDeviceInfo).length === 0) && !isUAV) {
return {};
}
if (isUAV) {
@@ -408,14 +402,12 @@ export default function DeviceStatusPage() {
? base
: {
...base,
...device?.locationMessage,
...wsDeviceInfo,
...locationInfo
};
}, [device, wsDeviceInfo, isUAV, locationInfo]);
}, [device, wsDeviceInfo, isUAV]);
const { video: robotVideo, error, ready } = useWebRTCPlayer(
(!isUAV && isVideoPlaying && !device?.hasHost) ? (device?.serialNumber || '') : '',
(!isUAV && isVideoPlaying) ? (device?.serialNumber || '') : '',
(!isUAV && isVideoPlaying)
? `webrtc://1.95.137.212/live/livestream/${device?.serialNumber}`
: ''
@@ -426,20 +418,6 @@ export default function DeviceStatusPage() {
// `webrtc://1.95.137.212/live/livestream/${device?.serialNumber}`,
//);
const getVal = (val) => val === "no_rain" ? t('devices.rainNo') : (val || '-');
const fixStatusMap: Record<string, string> = {
'no_fix': t('devices.noFix'),
'single': t('devices.single'),
'dgnss': t('devices.dgnss'),
'ins': t('devices.ins'),
'rtk_fixed': t('devices.rtkFixed'),
'rtk_float': t('devices.rtkFloat'),
'single_no_heading': t('devices.singleNoHeading'),
'dgnss_no_heading': t('devices.dgnssNoHeading'),
'rtk_fixed_no_heading': t('devices.rtkFixedNoHeading'),
'rtk_float_no_heading': t('devices.rtkFloatNoHeading'),
}
const realtimePosition = React.useMemo(() => {
// 1. 无人机:优先用 MQTT 实时数据
@@ -475,7 +453,6 @@ export default function DeviceStatusPage() {
const controller = new DeviceController(userInfo, messageApi);
controller.onDeviceInfoUpdate = setWsDeviceInfo;
controller.onLocationInfoUpdate = setLocationInfo;
controller.onControlStatusChange = setIsControlled;
controller.onHasControlRightChange = setHasControlRight;
controller.onRequestControlStatusChange = setConnecting;
@@ -503,19 +480,13 @@ export default function DeviceStatusPage() {
useEffect(() => {
if (!device || !controllerRef.current || !device?.serialNumber || isUAV) {
//controllerRef.current?.destroy();
//setWsDeviceInfo({});
return;
}
setWsDeviceInfo({});
setLocationInfo({});
if (isFirstConnect.current) {
isFirstConnect.current = false;
controllerRef.current.connectDevice(device);
} else {
controllerRef.current.switchDevice(device);
}
controllerRef.current.connectDevice(device);
}, [device?.serialNumber]);
@@ -677,46 +648,111 @@ export default function DeviceStatusPage() {
messageApi.success(t('devices.pointMarked', { count: markedPoints.length + 1 }));
};
// Map click to add marked point
const handleMapMarkPoint = (point) => {
setMarkedPoints([...markedPoints, { lon: Number(point.lon), lat: Number(point.lat) }]);
messageApi.success(t('devices.pointMarked', { count: markedPoints.length + 1 }));
};
// 撤回上一个打点
const handleUndoMark = () => {
if (markedPoints.length === 0) {
message.info(t('devices.noPointsToUndo'));
return;
}
const newPoints = markedPoints.slice(0, -1);
setMarkedPoints(newPoints);
messageApi.success(t('devices.pointUndone', { count: newPoints.length }));
};
// 清空标记点
const handleClearPoints = () => {
setMarkedPoints([]);
setCompleteFlag(false);
setSavePath(null);
clearDrawRef.current?.();
};
const getPathPoints = (coords) => {
console.log("getPathPoints", coords)
//setPathPoints(coords);
if (!coords || coords.length === 0) return;
const newWps = coords.map((p, i) => ({
id: i + 1,
lon: p.lon.toFixed(6),
lat: p.lat.toFixed(6),
}));
console.log("newWps", newWps)
//setWaypoints(newWps);
};
// 完成功能 - 调用路径规划接口
const handleComplete = async () => {
//如果时弓子模式
if (isLoopMode) {
if (markedPoints.length < 3) {
messageApi.warning(t('devices.minThreePoints'));
return;
}
try {
// 准备路径规划请求参数
const positionPoints = [...markedPoints];
const requestParams = {
reference: {
lat: positionPoints[0].lat,
lon: positionPoints[0].lon,
},
heading: 0,
outer: {
position: positionPoints.map(point => ({
lat: point.lat,
lon: point.lon,
})),
sideWidth: 0.0,
},
holes: [],
workType: 0,
};
const response = await fetch('https://servicepathplan.satabot.com/api/path', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(requestParams),
});
const result = await response.json();
if (result) {
const path = result?.data?.path?.map(p => {
return {
lng: p.lon,
lat: p.lat
}
})
setPoints(path);
setSavePath({
path: path, // 存储返回的路径结果
outer: requestParams?.outer?.position?.map(p => {
return {
lng: p.lon,
lat: p.lat
}
}
),
planModel: 0,
});
setCompleteFlag(true);
messageApi.success(t('devices.pathPlanDone'));
}
} catch (error) {
console.error('路径规划失败:', error);
messageApi.error(t('devices.pathPlanFailRetry'));
}
} else {
const positionPoints = [...markedPoints].map(item => {
return {
lng: item.lon,
lat: item.lat
}
});
setPoints(positionPoints);
setSavePath({
path: positionPoints, // 存储返回的路径结果
outer: [],
planModel: 2,
});
setCompleteFlag(true);
}
};
// 打开保存模态框
const handleOpenSaveModal = () => {
if (!completeFlag) {
messageApi.warning(t('devices.completePathFirst'));
return;
}
setPlotName('');
setIsSaveModalVisible(true);
};
// 保存功能
const handleSave = async () => {
if (!plotName.trim()) {
messageApi.warning(t('devices.inputPlotName'));
@@ -725,15 +761,6 @@ export default function DeviceStatusPage() {
setIsSaving(true);
try {
// ✅重点:接收handleComplete返回的path数据,不再读组件savePath state
const pathResult = await handleComplete();
if (!pathResult) {
messageApi.warning(t('devices.saveFail'));
// 路径规划失败/校验不通过直接终止
return;
}
// 1. 获取地图截图
let screenshotDataUrl = null;
if (mapRef.current) {
@@ -749,20 +776,18 @@ export default function DeviceStatusPage() {
const file = dataUrlToFile(screenshotDataUrl, "screenshot.jpg");
console.log("blob", file)
if (file instanceof File) {
formData.append('file', file);
}
}
// 4. 添加 workRecord,直接使用函数返回的 pathResult,不读取state savePath
// 4. 添加 workRecord
const workRecord = {
workName: plotName,
siteId: stationId,
orgId: currentStation?.orgId,
jsonData: pathResult, // 直接用返回值,彻底规避state异步延迟
mode: isLoopMode ? "coverage" : "single_point",//"区域还是单点"
jsonData: savePath,
};
console.log("workRecord", workRecord)
formData.append(
"workRecord",
new Blob([JSON.stringify(workRecord)], {
@@ -770,6 +795,8 @@ export default function DeviceStatusPage() {
})
);
//formData.append('workRecord', JSON.stringify(workRecord));
// 5. 调用保存接口
const res = await addRoute(formData);
@@ -791,95 +818,6 @@ export default function DeviceStatusPage() {
}
};
/**
* 修改handleComplete:计算完成后 return路径对象;失败返回null
*/
const handleComplete = async () => {
//如果是闭环模式
if (isLoopMode) {
if (markedPoints.length < 3) {
messageApi.warning(t('devices.minThreePoints'));
return null; //校验失败返回null
}
try {
// 准备路径规划请求参数
let positionPoints = [...markedPoints];
// =========新增:保证闭环,第一个点和最后一个点一致=========
const firstPt = positionPoints[0];
const lastPt = positionPoints[positionPoints.length - 1];
// 判断经纬度是否相等,不相等就把首点追加到末尾
if (!(firstPt.lat === lastPt.lat && firstPt.lon === lastPt.lon)) {
positionPoints.push({ ...firstPt });
}
const requestParams = {
outer: {
position: positionPoints.map(point => ({
lat: point.lat,
lng: point.lon,
})),
},
};
const path = requestParams?.outer?.position
setPoints(path);
const resultObj = {
path: path,
outer: requestParams?.outer?.position?.map(p => {
return {
lng: p.lon,
lat: p.lat
}
}),
};
setSavePath(resultObj);
setCompleteFlag(true);
messageApi.success(t('devices.pathPlanDone'));
return resultObj; // ✅返回计算好的数据给上层调用
} catch (error) {
console.error('路径规划失败:', error);
messageApi.error(t('devices.pathPlanFailRetry'));
return null;
}
} else {
// 单点模式
const positionPoints = [...markedPoints].map(item => {
return {
lng: item.lon,
lat: item.lat
}
});
setPoints(positionPoints);
const resultObj = {
path: positionPoints,
outer: [],
};
setSavePath(resultObj);
setCompleteFlag(true);
return resultObj; // ✅返回
}
};
// 打开保存模态框
const handleOpenSaveModal = () => {
//if (!completeFlag) {
// messageApi.warning(t('devices.completePathFirst'));
// return;
//}
setPlotName('');
setIsSaveModalVisible(true);
};
const realtimeType = useMemo(() => {
return isUAV ? 'plane' : 'car';
}, [isUAV]);
@@ -938,31 +876,24 @@ export default function DeviceStatusPage() {
>
{t('devices.markPoint')}
</Button>
<Button
type="default"
onClick={handleUndoMark}
disabled={markedPoints?.length === 0}
>
{t('devices.undoMark')}
</Button>
<Button
type="default"
onClick={handleClearPoints}
>
{t('devices.clearMarks')}
</Button>
{/*<Button
<Button
type="primary"
ghost
onClick={handleComplete}
disabled={markedPoints?.length < 2}
>
{t('devices.complete')}
</Button>*/}
</Button>
<Button
type="primary"
onClick={handleOpenSaveModal}
//disabled={!completeFlag}
disabled={!completeFlag}
>
{t('common.save')}
</Button>
@@ -1033,9 +964,9 @@ export default function DeviceStatusPage() {
{t('devices.stationVideo')}
</>
}
variant="borderless"
bordered={false}
style={{ borderRadius: 12, marginBottom: 8 }}
styles={{ body: { padding: 12 } }}
bodyStyle={{ padding: 12 }}
>
<div style={{ borderRadius: 8, overflow: 'hidden', height: 300 }}>
<DroneVideoPlayer
@@ -1077,13 +1008,13 @@ export default function DeviceStatusPage() {
setClearPlanLine((v) => v + 1);
}}
>
{t('devices.clearPlanRoute')}
{t('devices.clearPlannedRoute')}
</Button>
</Space>
}
variant="borderless"
bordered={false}
style={{ borderRadius: 12 }}
styles={{ body: { padding: 12, height: 400 } }}
bodyStyle={{ padding: 12, height: 400 }}
>
<CesiumMap
ref={mapRef}
@@ -1092,13 +1023,11 @@ export default function DeviceStatusPage() {
markedPoints={markedPoints}
realtimePosition={realtimePosition}
realtimeType={realtimeType}
onPathChange={getPathPoints}
drawRealTime={true}
finishPoint={arrivedPoint}
ifClearNavLine={clearNavLine}
ifClearPlanLine={clearPlanLine}
from="deviceStatus" onMarkPoint={handleMapMarkPoint} onClearDraw={(fn) => { clearDrawRef.current = fn; }}
from="deviceStatus"
/>
</Card>
</Col>
@@ -1113,9 +1042,9 @@ export default function DeviceStatusPage() {
{t('devices.droneVideo')}
</>
}
variant="borderless"
bordered={false}
style={{ borderRadius: 12, marginBottom: 8 }}
styles={{ body: { padding: 12 } }}
bodyStyle={{ padding: 12 }}
>
<div style={{ borderRadius: 8, overflow: 'hidden', height: "100%" }}>
<DroneVideoPlayer
@@ -1142,9 +1071,9 @@ export default function DeviceStatusPage() {
{t('devices.realtimeVideoMonitor')}
</>
}
variant="borderless"
bordered={false}
style={{ borderRadius: 12, marginBottom: 8 }}
styles={{ body: { padding: 12, height: 'calc(100vh - 220px)', minHeight: 500 } }}
bodyStyle={{ padding: 12, height: 'calc(100vh - 220px)', minHeight: 500 }}
extra={
<Button
@@ -1222,41 +1151,25 @@ export default function DeviceStatusPage() {
{/* 视频层:停止时不渲染 / 未播放时为空,不影响状态面板 */}
{isVideoPlaying && (
{robotVideo && isVideoPlaying && (
mowerView === 'all' ? (
(
<div style={{ width: '100%', height: '100%' }}>
<MowerAllView
serialNumber={device?.serialNumber}
robotVideo={robotVideo}
error={error}
ready={ready}
/>
</div>
)
) : mowerView === 'front' ? (
<div style={{ position: 'relative', width: '100%', height: '100%' }}>
{device?.hasHost ? (
<AgrtcRoomRobot CHANNEL={device?.serialNumber || ''} />
) : (
<VideoPlayer
deviceId={device?.serialNumber}
idx={1}
className="w-full h-full object-contain"
video={robotVideo}
error={error}
ready={ready}
/>
)}
<div style={{ width: '100%', height: '100%' }}>
<MowerAllView
serialNumber={device?.serialNumber}
robotVideo={robotVideo}
error={error}
ready={ready}
/>
</div>
) : (
<div style={{ position: 'relative', width: '100%', height: '100%' }}>
<VideoPlayer
deviceId={device?.serialNumber}
idx={
mowerView === 'back' ? 2
: mowerView === 'left' ? 3
: 4
mowerView === 'front' ? 1
: mowerView === 'back' ? 2
: mowerView === 'left' ? 3
: 4
}
className="w-full h-full object-contain"
video={robotVideo}
@@ -1268,7 +1181,7 @@ export default function DeviceStatusPage() {
)}
{/* 视频未加载 / 停止播放的占位 */}
{!isVideoPlaying && (
{(!robotVideo || !isVideoPlaying) && (
<div style={{
width: '100%', height: '100%',
display: 'flex', alignItems: 'center', justifyContent: 'center',
@@ -1284,6 +1197,7 @@ export default function DeviceStatusPage() {
</div>
</div>
)}
{/* 单视频(非全景)模式状态叠加层:始终渲染,和视频层解耦 */}
{mowerView !== 'all' && (
<div style={{
@@ -1330,8 +1244,11 @@ export default function DeviceStatusPage() {
<span>{runningStatus?.headingStatus !== undefined ? `${runningStatus?.headingStatus == 1 ? t('devices.rtInitialized') : t('devices.uninitialized')}` : '-'}</span>
<span>{t('devices.rtPositioning')}</span>
<span>
{runningStatus?.fix_status ? fixStatusMap[runningStatus?.fix_status] : t('constants.locationUnknown')}
{runningStatus?.qual == 0 ? t('constants.locationInvalid') :
runningStatus?.qual == 1 ? t('devices.gpsSingle') :
runningStatus?.qual == 2 ? t('devices.dgpsDiff') :
runningStatus?.qual == 4 ? t('devices.rtkFixed2') :
runningStatus?.qual == 5 ? t('devices.rtkFloat') : t('constants.locationUnknown')}
</span>
<span>{t('devices.rtSatellites')}</span>
<span>{t('devices.satelliteCount', { count: runningStatus?.satelliteCnt || 0 })}</span>
@@ -1377,13 +1294,13 @@ export default function DeviceStatusPage() {
setClearPlanLine((v) => v + 1);
}}
>
{t('devices.clearPlanRoute')}
{t('devices.clearPlannedRoute')}
</Button>
</Space>
}
variant="borderless"
bordered={false}
style={{ borderRadius: 12, marginBottom: 8, flex: 1, minHeight: 280 }}
styles={{ body: { padding: 12, height: 'calc((100vh - 260px) / 2)', minHeight: 280 } }}
bodyStyle={{ padding: 12, height: 'calc((100vh - 260px) / 2)', minHeight: 280 }}
>
<CesiumMap
ref={mapRef}
@@ -1396,7 +1313,7 @@ export default function DeviceStatusPage() {
finishPoint={arrivedPoint}
ifClearNavLine={clearNavLine}
ifClearPlanLine={clearPlanLine}
from="deviceStatus" onMarkPoint={handleMapMarkPoint} onClearDraw={(fn) => { clearDrawRef.current = fn; }}
from="deviceStatus"
/>
</Card>
@@ -1408,12 +1325,10 @@ export default function DeviceStatusPage() {
{t('devices.remoteControl')}
</>
}
variant="borderless"
bordered={false}
style={{ borderRadius: 12, background: '#0f172a', flex: 1, minHeight: 280, }}
styles={{
header: { color: '#fff', },
body: { display: 'flex', justifyContent: 'center', alignItems: 'center', height: 'calc(100% - 57px)' },
}}
headStyle={{ color: '#fff' }}
bodyStyle={{ display: 'flex', justifyContent: 'center', alignItems: 'center', height: 'calc(100% - 57px)' }}
>
<XboxController
onGamepadUpdate={handleGamepadUpdate}

View File

@@ -1,12 +1,11 @@
import React, { useState, useEffect, useRef, useMemo } from 'react';
import React, { useState, useEffect, useRef, useMemo } from 'react';
import {
Row, Col, Card, Button, Space, Table, Tag, Typography, Progress, Badge,
Tabs, Input, Switch, Divider, Tooltip, Timeline, Select, message, DatePicker,
Modal, InputNumber,
TimePicker,
Popconfirm,
App,
Radio
App
} from 'antd';
import {
PlusOutlined, ImportOutlined, NodeIndexOutlined,
@@ -25,7 +24,7 @@ import {
import {
getRobotRouteList,
getSingleRouteList,
saveDeviceTask, getRobotTaskList,
getPlaneDeviceListAll, saveDeviceTask, getRobotTaskList,
deleteDeviceTask,
getSiteDevice,
excuetRoute,
@@ -36,7 +35,6 @@ import {
getSiteDeviceTaskHistory,
getRouteByTask,
deleteRoute,
getTaskPath,
} from '../../api/device';
import dayjs from 'dayjs';
import DraggableBox from '../Draggable';
@@ -66,8 +64,6 @@ export default function RobotTaskPage() {
const [taskList, setTaskList] = useState([]);
const [arrivedPoint, setArrivedPoint] = useState(null);//完成点
const { modal } = App.useApp();
const [polyPoints, setPolyPoints] = useState([]);
@@ -79,7 +75,6 @@ export default function RobotTaskPage() {
const [focusLocation, setFocusLocation] = useState(null);
const [points, setPoints] = useState([]);
const [routeMode, setRouteMode] = useState('');
const [clearNavLine, setClearNavLine] = useState(0);
const [clearPlanLine, setClearPlanLine] = useState(0);
@@ -121,8 +116,6 @@ export default function RobotTaskPage() {
robot: null,
dateRange: null,
});
// 取消任务模式 normal普通取消 force强制取消
const [cancelMode, setCancelMode] = useState<'normal' | 'force'>('normal');
@@ -144,26 +137,13 @@ export default function RobotTaskPage() {
});
const [messageApi, contextHolder] = message.useMessage();
const controllerRef = useRef<DeviceController | null>(null);
const isFirstConnect = useRef(true);
const fixStatusMap: Record<string, string> = {
'no_fix': t('devices.noFix'),
'single': t('devices.single'),
'dgnss': t('devices.dgnss'),
'ins': t('devices.ins'),
'rtk_fixed': t('devices.rtkFixed'),
'rtk_float': t('devices.rtkFloat'),
'single_no_heading': t('devices.singleNoHeading'),
'dgnss_no_heading': t('devices.dgnssNoHeading'),
'rtk_fixed_no_heading': t('devices.rtkFixedNoHeading'),
'rtk_float_no_heading': t('devices.rtkFloatNoHeading'),
}
const handleFinish = (data) => {
setExecute(false);
setShowVideo(false); // 任务完成关闭视频
utils.message.success(t('devices.fixed2TaskSuspended2Fixed2CompletedFixed2'));
//if (controllerRef.current) {
// controllerRef.current.destroy?.();
//}
setClearNavLine(clearNavLine + 1);
setSelectedRobotForExecute(null);
setSelectedRouteForExecute(null);
@@ -172,7 +152,6 @@ export default function RobotTaskPage() {
fetchTaskPoolList();
}
const handleFinishEdPoint = (point) => {
setArrivedPoint(point);
@@ -184,18 +163,15 @@ export default function RobotTaskPage() {
if (!taskId) return;
try {
const res = await getRouteByTask({ taskId });
if (res?.code === 200 && res?.data?.jsonData?.path) {
if (res?.code === 200 && res?.data) {
let pathPoints = [];
try {
const data = res.data;
pathPoints = data.jsonData.path || [];
setRouteMode(data?.mode || 'coverage'); // 设置路线模式
pathPoints = data || [];
} catch (err) {
console.error('解析任务路径数据失败:', err);
}
setPolyPoints(pathPoints);
setPoints(pathPoints);
}
} catch (err) {
console.error('获取任务路径失败:', err);
@@ -260,7 +236,7 @@ export default function RobotTaskPage() {
setExecute(true);
setExecutingRobot(targetDevice);
setClearNavLine(v => v + 1); // 清空地图轨迹
if (isFirstConnect.current) { isFirstConnect.current = false; controllerRef.current?.connectDevice(targetDevice); } else { controllerRef.current?.switchDevice(targetDevice); }
controllerRef.current?.connectDevice(targetDevice);
setShowVideo(true);
};
@@ -268,12 +244,9 @@ export default function RobotTaskPage() {
useEffect(() => {
const controller = new DeviceController(userInfo, messageApi);
controller.onLocationInfoUpdate = setRobotRealtimePosition;
controller.onDeviceInfoUpdate = setRobotRealtimePosition;
controller.onIsFinished = handleFinish;
controller.handleArrivedPoint = handleFinishEdPoint;
controller.onRoutePost = setPoints;
controller.init();
@@ -306,7 +279,6 @@ export default function RobotTaskPage() {
const runningTask = taskPoolList.find(item => ['EXECUTING', 'PAUSE'].includes(item.taskStaus));
if (!runningTask) return;
//fetchRouteDetail(runningTask?.id);
// 找到对应的设备
const targetDevice = devices.find(d => d.serialNumber === runningTask.deviceId);
@@ -324,7 +296,7 @@ export default function RobotTaskPage() {
setExecute(true);
setExecutingRobot(targetDevice);
setClearNavLine(v => v + 1); // 清空地图轨迹
if (isFirstConnect.current) { isFirstConnect.current = false; controllerRef.current?.connectDevice(targetDevice); } else { controllerRef.current?.switchDevice(targetDevice); }
controllerRef.current?.connectDevice(targetDevice);
setShowVideo(true);
}, [devices, taskPoolList, executingRobot, runningPoolTask]);
@@ -414,14 +386,57 @@ export default function RobotTaskPage() {
}
};
useEffect(() => {
//console.log('获取任务列表', selectedPathWork?.id);
if (!selectedRobotForExecute?.id || !execute) {
if (!selectedPathWork?.id) {
setPoints([]);
return;
}
// 调用接口获取路线详情
const fetchRouteDetail = async () => {
try {
const res = await getSingleRouteList({ id: selectedPathWork.id });
if (res?.code === 200 && res?.data) {
let pathPoints = [];
let outerPoints = [];
let method = '';//0弓子 2 回子
try {
// 尝试解析 JSON
if (res.data.jsonData) {
const data = typeof res.data.jsonData === 'string'
? JSON.parse(res.data.jsonData)
: res.data.jsonData;
pathPoints = data?.path || [];
outerPoints = data?.outer || [];
method = data?.planModel;
}, [selectedRobotForExecute?.id]);
}
} catch (err) {
console.error('解析路线数据失败:', err);
}
if (pathPoints.length === 0) {
utils.message.warning(t('devices.route2'));
}
//if (outerPoints.length === 0 && method == 2) {
// utils.message.warning(t('devices.route2'));
//}
//if (method == 0) {
setPoints(pathPoints);
//} else {
// setPoints(outerPoints);
//}
} else {
setPoints([]);
}
} catch (err) {
console.error('获取路线详情失败:', err);
setPoints([]);
}
};
fetchRouteDetail();
}, [selectedPathWork]);
// 监听任务池列表变化,自动加载第一个任务的路径
useEffect(() => {
@@ -430,79 +445,6 @@ export default function RobotTaskPage() {
}
}, [taskPoolList]);
const getRouteOut = async () => {
try {
const res = await getSingleRouteList({ id: selectedPathWork?.id });
// coverage(区域覆盖)绘制为多边形,其余为折线/单点
const mode = res?.data?.mode;
setRouteMode(mode);
if (res?.code === 200 && res?.data?.jsonData) {
let pathPoints = [];
try {
// 尝试解析 JSON
pathPoints = res?.data?.jsonData?.path || [];
} catch (err) {
console.error('解析路线数据失败:', err);
}
if (pathPoints.length === 0) {
utils.message.warning(t('devices.route2'));
}
setPolyPoints(pathPoints);
} else {
setPolyPoints([]);
setRouteMode('');
}
} catch (err) {
console.error('获取路线详情失败:', err);
setPolyPoints([]);
setRouteMode('');
}
}
useEffect(() => {
getRouteOut();
}, [selectedPathWork?.id])
// 调用接口获取路线详情
const fetchRouteDetail = async (id) => {
console.log(id, "获取正在执行任务的id")
try {
const params = {
taskId: id,
}
const res = await getTaskPath(params)
//const res = await getSingleRouteList({ id: selectedPathWork.id });
if (res?.code === 200 && res?.data) {
let pathPoints = [];
try {
// 尝试解析 JSON
pathPoints = res.data || [];
} catch (err) {
console.error('解析路线数据失败:', err);
}
if (pathPoints.length === 0) {
utils.message.warning(t('devices.route2'));
}
setPoints(pathPoints);
} else {
setPoints([]);
}
} catch (err) {
console.error('获取路线详情失败:', err);
setPoints([]);
}
};
@@ -510,8 +452,6 @@ export default function RobotTaskPage() {
if (!runningPoolTask?.id) return;
loadTaskPath(runningPoolTask.id);
fetchRouteDetail(runningPoolTask?.id);
// 只有当任务是执行状态,并且没有连接的设备时,才自动连接
if ((runningPoolTask.taskStaus == 'EXECUTING' || runningPoolTask.taskStaus == 'PAUSE') && !executingRobot) {
@@ -520,7 +460,7 @@ export default function RobotTaskPage() {
setExecute(true);
setExecutingRobot(targetDevice);
setClearNavLine(v => v + 1); // 清空地图轨迹
if (isFirstConnect.current) { isFirstConnect.current = false; controllerRef.current?.connectDevice(targetDevice); } else { controllerRef.current?.switchDevice(targetDevice); }
controllerRef.current?.connectDevice(targetDevice);
setShowVideo(true);
}
}
@@ -571,6 +511,30 @@ export default function RobotTaskPage() {
setExecuteModalVisible(true);
setSelectedRobotForExecute(null);
// 调用接口检查是否有路径点
const res = await getSingleRouteList({ id: route.id });
let hasPathPoints = false;
if (res?.code === 200 && res?.data) {
try {
if (res.data.jsonData) {
const data = typeof res.data.jsonData === 'string'
? JSON.parse(res.data.jsonData)
: res.data.jsonData;
hasPathPoints = data?.path && data.path.length > 0;
}
} catch (err) {
console.error('解析路线数据失败:', err);
}
}
//if (!hasPathPoints) {
// utils.message.warning(t('devices.routeExecuteFixed2'));
// return;
//}
} catch (err) {
console.error('检查路线失败:', err);
utils.message.error(t('devices.checkRouteFail'));
@@ -602,7 +566,7 @@ export default function RobotTaskPage() {
fetchTaskList();
fetchTaskPoolList();
fetchTaskHistoryList();
if (isFirstConnect.current) { isFirstConnect.current = false; controllerRef.current?.connectDevice(selectedRobotForExecute); } else { controllerRef.current?.switchDevice(selectedRobotForExecute); }
controllerRef.current?.connectDevice(selectedRobotForExecute);
setShowVideo(true); // 连接成功后自动打开视频
} else {
@@ -689,14 +653,13 @@ export default function RobotTaskPage() {
};
// 取消任务
const handleCancelTask = async (task, mode) => {
const handleCancelTask = async (task) => {
try {
const params = {
taskId: task.id,
//deviceId: task.deviceId,
siteId: stationId,
orgId: task.orgId,
forceCancel: mode === 'force' ? true : false,
};
const res = await cancelRoute(params);
if (res.code === 200 && res.data == true) {
@@ -710,8 +673,6 @@ export default function RobotTaskPage() {
setSelectedRobotForExecute(null);
setSelectedRouteForExecute(null);
} else {
utils.message.error(t('devices.taskCancelFail'));
}
@@ -871,17 +832,15 @@ export default function RobotTaskPage() {
dataIndex: 'taskStaus',
width: 100,
render: (status, record) => {
console.log('status', status, record);
const statusMap = {
'NEW': { color: 'default', text: t('devices.statusNew') },
'EXECUTING': { color: 'processing', text: t('workOrder.inProgress') },
'PAUSE': { color: 'warning', text: t('devices.statusPaused') },
'FINISH': { color: 'success', text: t('devices.statusFinished') },
'FAILED': { color: 'error', text: t('devices.statusFailed') },
"CANCELING": { color: 'warning', text: t('devices.statusCanceling') },
'FAILED': { color: 'error', text: t('devices.statusFailed') }
};
const item = statusMap[status] || { color: 'default', text: record.taskStausTranslate || t('constants.locationUnknown') };
return <Tag color={item.color}>{record.taskStausTranslate}</Tag>;
return <Tag color={item.color}>{item.text}</Tag>;
}
},
{
@@ -930,8 +889,7 @@ export default function RobotTaskPage() {
'EXECUTING': { color: 'processing', text: t('workOrder.inProgress') },
'PAUSE': { color: 'warning', text: t('devices.statusPaused') },
'FINISH': { color: 'success', text: t('devices.statusFinished') },
'FAILED': { color: 'error', text: t('devices.statusFailed') },
"CANCELING": { color: 'warning', text: t('devices.statusCanceling') },
'FAILED': { color: 'error', text: t('devices.statusFailed') }
};
const item = statusMap[status] || { color: 'default', text: t('constants.locationUnknown') };
return <Tag color={item.color}>{item.text}</Tag>;
@@ -951,46 +909,27 @@ export default function RobotTaskPage() {
<>
{/*{record.taskStaus === 'NEW' && (*/}
<Popconfirm
title={t('devices.confirmCancelTask')}
description={
<Radio.Group
value={cancelMode}
onChange={(e) => setCancelMode(e.target.value)}
style={{ marginTop: 8 }}
>
<Space direction="vertical">
<Radio value="normal">{t('devices.normalCancel')}</Radio>
<Radio value="force">{t('devices.forceCancel')}</Radio>
</Space>
</Radio.Group>
}
onConfirm={() => handleCancelTask(record, cancelMode)}
okText={t('common.ok')}
cancelText={t('common.cancel')}
>
<Button
type="text"
size="small"
danger
icon={<CloseOutlined />}
onClick={(e) => e.stopPropagation()}
>
{t('common.cancel')}
</Button>
</Popconfirm>
<Popconfirm
title={t('devices.confirmCancelTask')}
onConfirm={() => handleCancelTask(record)}
okText={t('common.ok')} cancelText={t('common.cancel')}
>
<Button type="text" size="small" danger icon={<CloseOutlined />} onClick={(e) => e.stopPropagation()}>
{t('common.cancel')}
</Button>
</Popconfirm>
{/*//)}*/}
{/*{record.taskStaus === 'EXECUTING' && (*/}
<Popconfirm
title={t('devices.confirmPauseTask')}
onConfirm={() => handlePauseTask(record)}
okText={t('common.ok')} cancelText={t('common.cancel')}
>
<Button type="text" size="small" style={{ color: '#FF9500' }} onClick={(e) => e.stopPropagation()}>
{t('video.pause')}
</Button>
</Popconfirm>
<Popconfirm
title={t('devices.confirmPauseTask')}
onConfirm={() => handlePauseTask(record)}
okText={t('common.ok')} cancelText={t('common.cancel')}
>
<Button type="text" size="small" style={{ color: '#FF9500' }} onClick={(e) => e.stopPropagation()}>
{t('video.pause')}
</Button>
</Popconfirm>
{/*)}/*/}
{record.taskStaus === 'PAUSE' && (
@@ -1104,14 +1043,12 @@ export default function RobotTaskPage() {
{topCards.map((item, index) => (
<Col xs={12} sm={8} md={4} key={index}>
<Card
variant="borderless"
styles={{
body: {
padding: '12px 14px',
height: '100%',
display: 'flex',
alignItems: 'center'
}
bordered={false}
bodyStyle={{
padding: '12px 14px',
height: '100%',
display: 'flex',
alignItems: 'center'
}}
style={{
...cardStyle,
@@ -1199,7 +1136,7 @@ export default function RobotTaskPage() {
extra={
<Space size={4} wrap> {/* Space开启自动换行,小屏按钮自动折行 */}
<Button size="small" icon={<DeleteOutlined />} type="primary" style={{ borderRadius: 4 }} onClick={() => setClearNavLine(v => v + 1)}>{t('devices.clearRealtimeTrack')}</Button>
<Button size="small" icon={<DeleteOutlined />} danger style={{ borderRadius: 4 }} onClick={() => { setPoints([]); setPolyPoints([]); setRouteMode(""); setClearPlanLine(v => v + 1); }}>{t('devices.clearPlanRoute')}</Button>
<Button size="small" icon={<DeleteOutlined />} danger style={{ borderRadius: 4 }} onClick={() => { setPoints([]); setClearPlanLine(v => v + 1); }}>{t('devices.clearPlanRoute')}</Button>
{/*<Button size="small" icon={<PlusOutlined />} style={{ borderRadius: 4 }}>{t('common.addNew')}</Button>
<Button size="small" icon={<ImportOutlined />} style={{ borderRadius: 4 }}>{t('common.import')}</Button>
<Button size="small" icon={<NodeIndexOutlined />} style={{ borderRadius: 4 }}>{t('devices.optimize')}</Button>
@@ -1207,8 +1144,8 @@ export default function RobotTaskPage() {
{/*<Button size="small" icon={<Maximize2 size={12} />} />*/}
</Space>
}
variant="borderless"
styles={{ body: { padding: 0, position: 'relative' } }}
bordered={false}
bodyStyle={{ padding: 0, position: 'relative' }}
style={{ ...cardStyle, marginBottom: 10 }}
>
<div style={{ width: '100%', height: 420, background: '#e8f3ff center/cover', position: 'relative' }}>
@@ -1217,15 +1154,12 @@ export default function RobotTaskPage() {
points={points}
focusLocation={focusLocation}
realtimePosition={realtimePosition}
polyPoints={polyPoints}
realtimeType="robot"
from="devicesTask"
from="device-control"
drawRealTime={execute}
finishPoint={arrivedPoint}
ifClearNavLine={clearNavLine}
ifClearPlanLine={clearPlanLine}
routeMode={routeMode}
mapLayer={currentStation?.siteMapName}
/>
{/* 机器人状态悬浮面板 - 绝对定位左上角 */}
@@ -1264,12 +1198,22 @@ export default function RobotTaskPage() {
)}
</span>
<span>
{t('devices.heading')}
{robotRealtimePosition?.headingStatus == '1' ? (
<span style={{ color: '#9eff9e' }}>{t('devices.initialized')}</span>
) : (
<span style={{ color: '#ff6f6f' }}>{t('devices.uninitialized')}</span>
)}
</span>
<span>
{t('devices.location')}
{robotRealtimePosition?.fix_status ? fixStatusMap[robotRealtimePosition?.fix_status] : t('constants.locationUnknown')}
{(() => {
const qual = robotRealtimePosition?.qual;
const info = getLocationQuality(qual);
return <span style={{ color: info.color }}>{info.text}</span>;
})()}
</span>
{/* 视频开关 */}
@@ -1292,8 +1236,8 @@ export default function RobotTaskPage() {
{/* 机器人任务模块,带Tab切换 */}
<Card
size="small"
variant="borderless"
styles={{ body: { padding: 0, display: 'flex', flexDirection: 'column', height: "calc(100%)", overflow: "auto" } }}
bordered={false}
bodyStyle={{ padding: 0, display: 'flex', flexDirection: 'column', height: "calc(100%)", overflow: "auto" }}
style={{ ...cardStyle, maxHeight: "300px", flex: 1, marginBottom: 0 }}
>
@@ -1520,7 +1464,73 @@ export default function RobotTaskPage() {
</div>
</Card>
</Col>
<Col xs={24} xl={10}>
<Col xs={24} xl={10} style={{ display: "flex", flexDirection: "column" }} >
<Card
title={<span style={{ fontSize: fontTitle, fontWeight: 700 }}>{t('devices.operationSuggestion')}</span>}
bordered={false}
bodyStyle={{ padding: '12px 16px' }}
style={{ ...cardStyle, marginBottom: 8 }}
>
<Timeline mode="left">
<Timeline.Item label="09:30" color="green">
<Text strong>{t('devices.timelineMow', { robot: 'RBT-01' })}</Text>
<div style={{ fontSize: 12, color: '#86909C' }}>{t('devices.timelineMowDetail')}</div>
</Timeline.Item>
<Timeline.Item label="11:00" color="blue">
<Text strong>{t('devices.timelineInspect', { robot: 'RBT-02' })}</Text>
<div style={{ fontSize: 12, color: '#86909C' }}>{t('devices.timelineInspectDetail')}</div>
</Timeline.Item>
<Timeline.Item label="14:00" color="gray">
<Text strong>{t('devices.timelineMaintenance')}</Text>
<div style={{ fontSize: 12, color: '#86909C' }}>{t('devices.timelineMaintenanceDetail')}</div>
</Timeline.Item>
</Timeline>
<Button type="primary" block style={{ marginTop: 16, borderRadius: 18 }}>{t('devices.autoGenerateTodayPlan')}</Button>
</Card>
<Card
title={<span style={{ fontSize: fontTitle, fontWeight: 700 }}>{t('devices.deviceEnvironment')}</span>}
bordered={false}
bodyStyle={{ padding: '16px' }}
style={{ ...cardStyle, flex: 1 }}
>
<Row gutter={[8, 8]}>
<Col span={12}>
<div style={{ background: '#F7F8FA', padding: 12, borderRadius: 10 }}>
<div style={{ fontSize: 12, color: '#86909C' }}>{t('devices.currentTemp')}</div>
<div style={{ fontSize: 18, fontWeight: 700 }}>24.5 ℃</div>
</div>
</Col>
<Col span={12}>
<div style={{ background: '#F7F8FA', padding: 12, borderRadius: 10 }}>
<div style={{ fontSize: 12, color: '#86909C' }}>{t('devices.humidity')}</div>
<div style={{ fontSize: 18, fontWeight: 700 }}>65 %</div>
</div>
</Col>
<Col span={12}>
<div style={{ background: '#F7F8FA', padding: 12, borderRadius: 10 }}>
<div style={{ fontSize: 12, color: '#86909C' }}>{t('devices.positionAccuracy')}</div>
<div style={{ fontSize: 18, fontWeight: 700, color: '#00B42A' }}>{t('devices.rtkFixed')}</div>
</div>
</Col>
<Col span={12}>
<div style={{ background: '#F7F8FA', padding: 12, borderRadius: 10 }}>
<div style={{ fontSize: 12, color: '#86909C' }}>{t('devices.networkLatency')}</div>
<div style={{ fontSize: 18, fontWeight: 700 }}>45 ms</div>
</div>
</Col>
</Row>
<div style={{ marginTop: 8, padding: 12, background: 'rgba(255, 125, 0, 0.1)', borderRadius: 8, display: 'flex', alignItems: 'center', gap: 8 }}>
<AlertCircle size={16} style={{ color: '#FF7D00' }} />
<span style={{ fontSize: 13, color: '#FF7D00' }}>{t('devices.waterRiskWarning')}</span>
</div>
</Card>
</Col>
</Row>
<Row gutter={16}>
<Col xs={24} xl={6}>
<Card
title={
<div className="flex justify-between items-center w-full">
@@ -1534,8 +1544,8 @@ export default function RobotTaskPage() {
/>
</div>
}
variant="borderless"
styles={{ body: { padding: '12px', height: 732, overflow: 'auto' } }}
bordered={false}
bodyStyle={{ padding: '12px', height: 400, overflow: 'auto' }}
style={cardStyle}
>
<div style={{ display: 'flex', flexDirection: 'column', gap: 12 }}>
@@ -1663,105 +1673,16 @@ export default function RobotTaskPage() {
</div>
</Card>
</Col>
</Row>
<Row gutter={16} >
<Col xs={24} xl={6} style={{ display: "flex", flexDirection: "column" }} >
<Card
title={<span style={{ fontSize: fontTitle, fontWeight: 700 }}>{t('devices.operationSuggestion')}</span>}
variant="borderless"
styles={{ body: { padding: '12px 16px' } }}
style={{ ...cardStyle, marginBottom: 8 }}
>
<Timeline
mode="left"
items={[
{
color: 'green',
label: '09:30',
children: (
<>
<Text strong>{t('devices.timelineMow', { robot: 'RBT-01' })}</Text>
<div style={{ fontSize: 12, color: '#86909C' }}>{t('devices.timelineMowDetail')}</div>
</>
)
},
{
color: 'blue',
label: '11:00',
children: (
<>
<Text strong>{t('devices.timelineInspect', { robot: 'RBT-02' })}</Text>
<div style={{ fontSize: 12, color: '#86909C' }}>{t('devices.timelineInspectDetail')}</div>
</>
)
},
{
color: 'gray',
label: '14:00',
children: (
<>
<Text strong>{t('devices.timelineMaintenance')}</Text>
<div style={{ fontSize: 12, color: '#86909C' }}>{t('devices.timelineMaintenanceDetail')}</div>
</>
)
}
]}
/>
<Button type="primary" block style={{ marginTop: 16, borderRadius: 18 }}>{t('devices.autoGenerateTodayPlan')}</Button>
</Card>
<Card
title={<span style={{ fontSize: fontTitle, fontWeight: 700 }}>{t('devices.deviceEnvironment')}</span>}
variant="borderless"
styles={{ body: { padding: '16px' } }}
style={{ ...cardStyle, flex: 1 }}
>
<Row gutter={[8, 8]}>
<Col span={12}>
<div style={{ background: '#F7F8FA', padding: 12, borderRadius: 10 }}>
<div style={{ fontSize: 12, color: '#86909C' }}>{t('devices.currentTemp')}</div>
<div style={{ fontSize: 18, fontWeight: 700 }}>24.5 ℃</div>
</div>
</Col>
<Col span={12}>
<div style={{ background: '#F7F8FA', padding: 12, borderRadius: 10 }}>
<div style={{ fontSize: 12, color: '#86909C' }}>{t('devices.humidity')}</div>
<div style={{ fontSize: 18, fontWeight: 700 }}>65 %</div>
</div>
</Col>
<Col span={12}>
<div style={{ background: '#F7F8FA', padding: 12, borderRadius: 10 }}>
<div style={{ fontSize: 12, color: '#86909C' }}>{t('devices.positionAccuracy')}</div>
<div style={{ fontSize: 18, fontWeight: 700, color: '#00B42A' }}>{t('devices.rtkFixed')}</div>
</div>
</Col>
<Col span={12}>
<div style={{ background: '#F7F8FA', padding: 12, borderRadius: 10 }}>
<div style={{ fontSize: 12, color: '#86909C' }}>{t('devices.networkLatency')}</div>
<div style={{ fontSize: 18, fontWeight: 700 }}>45 ms</div>
</div>
</Col>
</Row>
<div style={{ marginTop: 8, padding: 12, background: 'rgba(255, 125, 0, 0.1)', borderRadius: 8, display: 'flex', alignItems: 'center', gap: 8 }}>
<AlertCircle size={16} style={{ color: '#FF7D00' }} />
<span style={{ fontSize: 13, color: '#FF7D00' }}>{t('devices.waterRiskWarning')}</span>
</div>
</Card>
</Col>
<Col xs={24} xl={18} style={{ display: 'flex', flexDirection: 'column', }}>
<Col xs={24} xl={18}>
<Card
title={<span style={{ fontSize: fontTitle, fontWeight: 700 }}>{t('devices.taskBoard')}</span>}
variant="borderless"
styles={{ body: { padding: '12px', flex: 1 } }}
style={{ ...cardStyle, height: '100%', display: "flex", flexDirection: "column" }}
bordered={false}
bodyStyle={{ padding: '12px' }}
style={{ ...cardStyle, height: '100%' }}
>
<Row gutter={16} style={{ height: "100%" }} >
<Row gutter={16}>
<Col span={8}>
<div style={{ background: '#F7F8FA', padding: 12, borderRadius: 8, height: "100%" }}>
<div style={{ background: '#F7F8FA', padding: 12, borderRadius: 8, height: 400 }}>
<Title level={5} style={{ fontSize: 14, marginBottom: 12 }}><Badge color="#86909C" text={t('devices.pending')} /></Title>
{waitList.map((item, idx) => (
<Card key={idx} size="small" style={{ marginBottom: 8, borderRadius: 6 }}>
@@ -1772,7 +1693,7 @@ export default function RobotTaskPage() {
</div>
</Col>
<Col span={8}>
<div style={{ background: '#E8F3FF', padding: 12, borderRadius: 8, height: "100%" }}>
<div style={{ background: '#E8F3FF', padding: 12, borderRadius: 8, height: 400 }}>
<Title level={5} style={{ fontSize: 14, marginBottom: 12 }}><Badge color="#165DFF" text={t('devices.statInProgress')} /></Title>
{runList.map((item, idx) => (
<Card key={idx} size="small" style={{ marginBottom: 8, borderRadius: 6 }}>
@@ -1785,7 +1706,7 @@ export default function RobotTaskPage() {
</div>
</Col>
<Col span={8}>
<div style={{ background: '#F6FFED', padding: 12, borderRadius: 8, height: "100%" }}>
<div style={{ background: '#F6FFED', padding: 12, borderRadius: 8, height: 400 }}>
<Title level={5} style={{ fontSize: 14, marginBottom: 12 }}><Badge color="#52C41A" text={t('workOrder.completed')} /></Title>
{finishList.slice(0, 3).map((item, idx) => (
<Card key={idx} size="small" style={{ marginBottom: 8, borderRadius: 6 }}>
@@ -1853,7 +1774,7 @@ export default function RobotTaskPage() {
</div>
</Modal>
{showVideo && executingRobot && execute && taskPoolList.length > 0 && (
{showVideo && executingRobot && execute && (
<DraggableBox
defaultPosition={{ x: 50, y: 50 }}
title={t('devices.robotPanoramaVideo', { robot: executingRobot.deviceAlias || executingRobot.serialNumber })}
@@ -1894,7 +1815,6 @@ const NewTaskModal = ({ isOpen, onClose, robots, selectedPathWork, handlGetTaskL
if (selectedPathWork) {
setFormData(prev => ({ ...prev, path: selectedPathWork }));
}
}, [selectedPathWork]);
// ====================== 周/月选择 ======================

View File

@@ -1,4 +1,4 @@
import React, { useState, useEffect, useRef, useCallback } from 'react';
import React, { useState, useEffect, useRef } from 'react';
import {
Row, Col, Card, Button, Space, Table, Tag, Typography, Progress, Badge,
Tabs, Input, Switch, Divider, Tooltip, Timeline, Select, message, DatePicker,
@@ -39,8 +39,6 @@ export default function WayLinePage({ onRefresh }) {
const { t } = useTranslation();
const { userInfo } = useSelector((state: RootState) => state.user);
const { stationId } = useSelector((state: RootState) => state.station);
const { currentStation } = useSelector((state: RootState) => state.station);
const fontSmall = 'clamp(10px, 0.7vw, 11px)';
const fontNormal = 'clamp(12px, 0.75vw, 13px)';
@@ -95,7 +93,7 @@ export default function WayLinePage({ onRefresh }) {
// 当MQTT数据更新时,更新持久化数据(只在有新数据时更新)
const handleMqttMessage = useCallback((topic, message) => {
const handleMqttMessage = (topic, message) => {
try {
const parsedMessage = JSON.parse(message);
@@ -203,7 +201,7 @@ export default function WayLinePage({ onRefresh }) {
} catch (err) {
console.error('WayLinePage MQTT 消息解析失败:', err);
}
}, []);
};
// 根据选中设备动态构建MQTT主题
const mqttTopics = React.useMemo(() => {
@@ -225,7 +223,6 @@ export default function WayLinePage({ onRefresh }) {
url: envConfig.mqtt_url,
topic: mqttTopics,
onMessage: handleMqttMessage,
enabled: mqttTopics.length > 0,
});
// 优先使用持久化数据,保持显示稳定
@@ -834,7 +831,7 @@ export default function WayLinePage({ onRefresh }) {
<Row gutter={[16, 16]} style={{ marginBottom: 8 }}>
{topCards.map((item, index) => (
<Col xs={12} sm={8} md={4} key={index}>
<Card variant="borderless" styles={{ body: { padding: '12px 14px' } }} style={cardStyle}>
<Card bordered={false} bodyStyle={{ padding: '12px 14px' }} style={cardStyle}>
<div style={{ display: 'flex', alignItems: 'center', gap: 10 }}>
<div style={{ width: 36, height: 36, background: item.bg, borderRadius: 10, display: 'flex', justifyContent: 'center', alignItems: 'center', color: item.color }}>
{React.cloneElement(item.icon, { size: 18 })}
@@ -893,13 +890,12 @@ export default function WayLinePage({ onRefresh }) {
<Button size="small" icon={<Maximize2 size={12} />} />
</Space>
}
variant="borderless"
styles={{ body: { padding: 0, position: 'relative' } }}
bordered={false}
bodyStyle={{ padding: 0, position: 'relative' }}
style={{ ...cardStyle, marginBottom: 10 }}
>
<div style={{ width: '100%', height: 420, background: '#e8f3ff url(https://picsum.photos/seed/solar_map_v2/1600/1000) center/cover', position: 'relative' }}>
<CesiumMap realtimePosition={realtimePosition} drawRealTime={true} mapLayer={currentStation?.siteMapName}
<CesiumMap realtimePosition={realtimePosition} drawRealTime={true}
points={points} focusLocation={focusLocation} from="device-control" realtimeType='plane' ifClearNavLine={clearNavLine} ifClearPlanLine={clearPlanLine} />
<div style={{ position: 'absolute', top: 16, left: 16, background: 'rgba(255,255,255,0.92)', backdropFilter: 'blur(8px)', padding: '14px 16px', borderRadius: 10, width: 150, boxShadow: '0 4px 12px rgba(0,0,0,0.1)' }}>
<div style={{ fontSize: fontSmall, display: 'flex', flexDirection: 'column', gap: 10 }}>
@@ -961,8 +957,8 @@ export default function WayLinePage({ onRefresh }) {
/>
</Tooltip>
}
variant="borderless"
styles={{ body: { padding: 0, display: 'flex', flexDirection: 'column', height: "calc(100% - 40px)", overflow: "auto" } }}
bordered={false}
bodyStyle={{ padding: 0, display: 'flex', flexDirection: 'column', height: "calc(100% - 40px)", overflow: "auto" }}
style={{ ...cardStyle, maxHeight: "250px", flex: 1, marginBottom: 0 }}
>
<Table
@@ -986,8 +982,8 @@ export default function WayLinePage({ onRefresh }) {
<Col xs={24} xl={10} style={{ display: "flex", flexDirection: "column" }} >
<Card
title={<span style={{ fontSize: fontTitle, fontWeight: 700 }}>{t('devices.taskOrchestrationAI')}</span>}
variant="borderless"
styles={{ body: { padding: '12px 16px' } }}
bordered={false}
bodyStyle={{ padding: '12px 16px' }}
style={{ ...cardStyle, marginBottom: 8 }}
>
<Table
@@ -1029,8 +1025,8 @@ export default function WayLinePage({ onRefresh }) {
<Card
title={<span style={{ fontSize: fontTitle, fontWeight: 700 }}>{t('devices.waylineParamsTitle')}</span>}
extra={<Text type="secondary" style={{ fontSize: 12 }}>{t('devices.currentWayline')}{selectedTask?.name || '-'}</Text>}
variant="borderless"
styles={{ body: { padding: '16px' } }}
bordered={false}
bodyStyle={{ padding: '16px' }}
style={{ ...cardStyle, marginBottom: 8 }}
>
<div style={{ display: 'grid', gridTemplateColumns: 'repeat(4, 1fr)', gap: '8px', marginBottom: 8 }}>
@@ -1145,8 +1141,8 @@ export default function WayLinePage({ onRefresh }) {
<Card
title={<span style={{ fontSize: fontTitle, fontWeight: 700 }}>{t('devices.weatherWindowTitle')}</span>}
variant="borderless"
styles={{ body: { padding: '16px' } }}
bordered={false}
bodyStyle={{ padding: '16px' }}
style={{ ...cardStyle, flex: 1, }}
>
<div style={{ display: 'grid', gridTemplateColumns: 'repeat(5, 1fr)', gap: '8px', marginBottom: 16 }}>
@@ -1252,8 +1248,8 @@ export default function WayLinePage({ onRefresh }) {
/>
</div>
}
variant="borderless"
styles={{ body: { padding: '12px', display: 'flex', flexDirection: 'column', height: 480 } }}
bordered={false}
bodyStyle={{ padding: '12px', display: 'flex', flexDirection: 'column', height: 480 }}
style={{ ...cardStyle, height: '100%' }}
>
<Input
@@ -1317,8 +1313,8 @@ export default function WayLinePage({ onRefresh }) {
<Card
title={<span style={{ fontSize: fontTitle, fontWeight: 700 }}>{t('devices.ganttViewTitle')} <Text type="secondary" style={{ fontSize: 11, fontWeight: 400, marginLeft: 12 }}></Text></span>}
extra={<MoreOutlined style={{ cursor: 'pointer', fontSize: 18 }} />}
variant="borderless"
styles={{ body: { padding: 16 } }}
bordered={false}
bodyStyle={{ padding: 16 }}
style={{ ...cardStyle, height: '100%' }}
>
<div style={{ position: 'relative', border: '1px solid #F2F3F5', borderRadius: 8, padding: '16px 12px' }}>
@@ -1397,8 +1393,8 @@ export default function WayLinePage({ onRefresh }) {
</Space>
</div>
}
variant="borderless"
styles={{ body: { padding: 16 } }}
bordered={false}
bodyStyle={{ padding: 16 }}
style={{ ...cardStyle, height: '100%', maxHeight: 480, overflow: "auto" }}
>
<Row gutter={10}>

View File

@@ -116,7 +116,7 @@ const XboxController = ({ onGamepadUpdate, handleControlModal, isControlled, isC
return (
<div className="relative h-[252px] aspect-[4/3] flex items-center justify-center "
onClick={() => {
if (!isControlled) {
if (connected && !isControlled && hasControlRight) {
console.log("点击了无控制权限,发起权限请求");
// 示例:调用你代码中已有的权限请求弹窗逻辑
handleControlModal({ control: true, type: "switchPermission" });
@@ -125,7 +125,7 @@ const XboxController = ({ onGamepadUpdate, handleControlModal, isControlled, isC
{/* Gamepad Status Badge */}
<div
className={`absolute top-0 right-0 px-2 py-0.5 rounded text-[8px] font-bold tracking-widest border
${connected
${connected || !hasControlRight
? isConnecting
? 'bg-yellow-500/20 text-yellow-400 border-yellow-500/30'
: isControlled
@@ -137,6 +137,8 @@ const XboxController = ({ onGamepadUpdate, handleControlModal, isControlled, isC
>
{!connected ? (
t('devices.controllerNotConnected')
) : !hasControlRight ? (
t('devices.otherWebConnected')
) : isConnecting ? (
t('devices.control2')
) : isControlled ? (

View File

@@ -1,8 +1,8 @@
import throttle from 'lodash/throttle';
import { wsManager } from '../WebSocketManager.ts';
import {
getControlRight,
getJurisdiction,
releaseControl
} from '../../api/device.ts';
import envConfig from '../../../env';
@@ -17,7 +17,7 @@ export default class DeviceController {
envConfig.WS_URL || 'wss://ri.satabot.com/ws/';
this.connectedDeviceSn = null;
this.currentDevice = null;
this.currentDevice = null; // 保存当前设备
this.requestDeviceId = '';
@@ -27,27 +27,22 @@ export default class DeviceController {
this.wsStatus = 'disconnected';
this.wsDeviceInfo = {};
this.locationInfo = {};
this.controlTimeout = null;
this.keepAliveInterval = null;
this.keepAliveInterval = null; // 后台保活定时器
this.onDeviceInfoUpdate = null;
this.onLocationInfoUpdate = null;
this.onControlStatusChange = null;
this.onWsStatusChange = null;
this.onHasControlRightChange = null;
this.onRequestControlStatusChange = null;
this.onPermissionRequest = null;
this.onRoutePost = null;
this.onIsFinished = null;
this.handleArrivedPoint = null;
this.handleWsMessage = this.handleWsMessage.bind(this);
this.handleWsStatus = this.handleWsStatus.bind(this);
this.handleVisibilityChange = this.handleVisibilityChange.bind(this);
this.handleBeforeUnload = this.handleBeforeUnload.bind(this);
this.sendGamepad = throttle(
this.sendGamepad.bind(this),
@@ -60,38 +55,36 @@ export default class DeviceController {
this.unSubMessage = wsManager.onMessage(this.handleWsMessage);
this.unSubStatus = wsManager.onStatusChange(this.handleWsStatus);
// ========== 【集成】页面可见性监听 ==========
document.addEventListener('visibilitychange', this.handleVisibilityChange);
document.addEventListener('beforeunload', this.handleBeforeUnload);
}
levae() {
wsManager.close();
// ========== 【集成】后台保活定时 ==========
//this.startKeepAlive();
}
// ========== 【集成】页面切前台重连 ==========
handleVisibilityChange() {
// 切后台:关闭 WS
if (document.visibilityState === 'hidden') {
console.log('Page hidden, release control');
console.log('🔌 页面切后台,关闭 WebSocket');
//this.release();
wsManager.close();
this.connectedDeviceSn = null;
this.isControlled = false;
this.onControlStatusChange?.(false);
}
if (document.visibilityState === 'visible' && this.currentDevice) {
if (!this.currentDevice?.serialNumber) return;
console.log('Page visible, reconnect WebSocket');
console.log('✅ 页面切回前台,自动重连 WebSocket');
setTimeout(() => {
this.connectDevice(this.currentDevice);
}, 500);
}
}
handleBeforeUnload() {
console.log('Browser closing/refreshing, release control');
this.release();
}
// ========== 【集成】后台保活 ==========
startKeepAlive() {
this.keepAliveInterval = setInterval(() => {
if (
@@ -99,50 +92,47 @@ export default class DeviceController {
this.wsStatus !== 'connected' &&
this.currentDevice?.serialNumber
) {
console.log('Keep alive: reconnect WebSocket');
console.log('🔄 后台保活:尝试重连 WebSocket');
this.connectDevice(this.currentDevice);
}
}, 8000);
}
release() {
if (this.isControlled && this.connectedDeviceSn) {
const data = {
platform: "web",
type: 1
};
const url = `${envConfig.baseURL}/forward/device/releaseControl`;
async release() {
if (!this.connectedDeviceSn) return;
const data = {
platform: 'web',
type: 1,
deviceId: this.connectedDeviceSn,
token: this.userInfo.token,
};
const url = `${envConfig.baseURL}/forward/device/releaseControl`;
try {
await releaseControl(data);
const blob = new Blob([JSON.stringify(data)], { type: 'application/json' });
navigator.sendBeacon(url, blob);
console.log('releaseControl sent');
} catch (e) {
console.error('Failed to send releaseControl:', e);
try {
const blob = new Blob([JSON.stringify(data)], { type: 'application/json' });
navigator.sendBeacon(url, blob);
} catch (e) {
console.error('Failed to send releaseControl beacon:', e);
}
}
}
destroy() {
this.clearControlTimeout();
// 清理保活
if (this.keepAliveInterval) {
clearInterval(this.keepAliveInterval);
this.keepAliveInterval = null;
}
// 移除监听
document.removeEventListener('visibilitychange', this.handleVisibilityChange);
document.removeEventListener('beforeunload', this.handleBeforeUnload);
this.release();
this.levae();
this.unSubMessage?.();
this.unSubStatus?.();
//this.release();
//wsManager.close();
this.connectedDeviceSn = null;
}
handleWsStatus(status) {
@@ -158,6 +148,7 @@ export default class DeviceController {
async connectDevice(device) {
if (!device) return;
// 保存当前设备,用于保活/重连
this.currentDevice = device;
if (!device.serialNumber) return;
@@ -165,17 +156,31 @@ export default class DeviceController {
this.connectedDeviceSn = null;
this.wsDeviceInfo = {};
this.locationInfo = {};
this.isControlled = false;
this.onControlStatusChange?.(false);
wsManager.close();
try {
console.log('Connecting to', this.wsUrl);
const res = await getControlRight({
userName: this.userInfo.username,
sourceType: 1,
token: this.userInfo.token,
});
this.hasControlRight = res?.code === 200 && res.data == true;
this.onHasControlRightChange?.(this.hasControlRight);
wsManager.connect(sn, this.wsUrl);
this.connectedDeviceSn = sn;
if (!this.hasControlRight) {
this.messageApi.warning(i18n.t('devices.fixed2OthersControlFixed2'));
return;
}
await this.getControl(sn);
} catch (err) {
console.error(err);
@@ -183,42 +188,11 @@ export default class DeviceController {
}
}
async switchDevice(device) {
if (!device) return;
if (!device.serialNumber) return;
const newSn = device.serialNumber;
if (this.connectedDeviceSn === newSn && this.wsStatus === 'connected') {
console.log('switchDevice: same device, skip');
return;
}
console.log('Connecting to switchDevice: switching to', newSn);
this.currentDevice = device;
this.connectedDeviceSn = newSn;
this.wsDeviceInfo = {};
this.locationInfo = {};
this.isControlled = false;
this.onControlStatusChange?.(false);
wsManager.send({
type: 'AUTH',
token: this.userInfo.token,
userName: this.userInfo.username,
deviceId: newSn,
});
await this.getControl(newSn);
}
async getControl(serialnum) {
try {
const res = await getJurisdiction({
platform: 'web',
deviceId: serialnum,
token: this.userInfo.token,
});
this.isControlled = res?.code === 200 && res?.data?.remoteControl === true;
@@ -232,7 +206,10 @@ export default class DeviceController {
requestControl() {
if (this.isRequestControl) return;
if (!this.hasControlRight) {
this.messageApi.warning(i18n.t('devices.noneControl'));
return;
}
this.isRequestControl = true;
this.onRequestControlStatusChange?.(true);
@@ -275,7 +252,7 @@ export default class DeviceController {
}
handleWsMessage(msg) {
console.log('WS message:', msg);
console.log('📨 收到消息:', msg);
switch (msg.type) {
case 'deviceInfo': {
const data = {};
@@ -286,15 +263,6 @@ export default class DeviceController {
this.onDeviceInfoUpdate?.(data);
break;
}
case 'locationInfo': {
const data = {};
msg.data.forEach((item) => {
data[item.name] = item.value;
});
this.locationInfo = data;
this.onLocationInfoUpdate?.(data);
break;
}
case 'AUTH': {
if (msg.isAuth) {
@@ -309,7 +277,7 @@ export default class DeviceController {
this.isRequestControl = false;
this.onRequestControlStatusChange?.(false);
if (msg?.success === false || msg?.respond?.switchResult === false) {
if (msg.success === false || msg?.respond?.switchResult === false) {
this.isControlled = false;
this.onControlStatusChange?.(false);
this.messageApi.error({ key: 'control', content: msg.message || i18n.t('devices.controlFailed') });
@@ -323,16 +291,19 @@ export default class DeviceController {
case "device_task_change": {
if (msg.deviceId != this.connectedDeviceSn) return;
this.onIsFinished?.(true);
console.log('task change:', msg);
break;
console.log('🔌 控制结果任务变更,', msg);
}
//完成点
case "device_task_arrive_point": {
if (msg.deviceId != this.connectedDeviceSn) return;
this.handleArrivedPoint?.(msg.entity);
console.log('arrive point:', msg);
break;
console.log('🔌 到达完成点,', msg);
}
case 'switchPermission': {
const platform = (msg.platform || '').toLowerCase();
if (!platform || platform === 'null') return;
@@ -359,14 +330,6 @@ export default class DeviceController {
});
break;
case 'route_post':
console.log('route post:', msg);
if (msg.deviceId) {
this.onRoutePost?.(msg.data);
}
break;
default:
break;
}

View File

@@ -1,4 +1,4 @@
import React, { useEffect, useRef, useState } from 'react';
import React, { useEffect, useRef, useState } from 'react';
import {
LineChart,
Line,

View File

@@ -0,0 +1,388 @@
import React, { useEffect, useState, useMemo, useCallback } from 'react';
import {
Card, Row, Col, Select, DatePicker, Button, Space, Checkbox, Table, Tag,
Typography, message, Empty, Spin
} from 'antd';
import {
RobotOutlined, SearchOutlined, DownloadOutlined, LineChartOutlined
} from '@ant-design/icons';
import dayjs from 'dayjs';
import { useTranslation } from 'react-i18next';
import { useSelector } from 'react-redux';
import { RootState } from '../../store';
import { getSiteDevice } from '../../api/device';
import { getDeviceRunningHistoryStatistics } from '../../api/machine';
import { UniversalLineChart } from '../recharts';
import utils from '@/lib/utils';
const { RangePicker } = DatePicker;
const { Option } = Select;
const { Title } = Typography;
// 参数配置:i18n key + 后端字段 + 单位 + 颜色
const PARAM_CONFIG = [
{ key: 'voltage', labelKey: 'devices.rtVoltage', unit: 'V', color: '#1677ff' },
{ key: 'leftCurrent', labelKey: 'devices.rtLeftMotor', unit: 'A', color: '#52c41a' },
{ key: 'rightCurrent', labelKey: 'devices.rtRightMotor', unit: 'A', color: '#fa8c16' },
{ key: 'leftMeasureSpeed', labelKey: 'devices.rtLeftSpeed', unit: 'rpm', color: '#eb2f96' },
{ key: 'rightMeasureSpeed', labelKey: 'devices.rtRightSpeed', unit: 'rpm', color: '#722ed1' },
{ key: 'leftMotorTemp', labelKey: 'devices.rtLeftTemp', unit: '℃', color: '#13c2c2' },
{ key: 'rightMotorTemp', labelKey: 'devices.rtRightTemp', unit: '℃', color: '#f5222d' },
{ key: 'chipTemp', labelKey: 'devices.rtMainTemp', unit: '℃', color: '#2f54eb' },
];
// 默认选中全部参数
const DEFAULT_PARAM_KEYS = PARAM_CONFIG.map(p => p.key);
// 兼容多种时间字段
function getRowTime(row: any): string {
const t = row.createTime || row.ts || row.timestamp || row.time || row.recordTime || row.collectTime;
if (!t) return '';
return dayjs(typeof t === 'number' ? t : String(t)).format('YYYY-MM-DD HH:mm:ss');
}
// 兼容多种返回结构
function extractRows(res: any): any[] {
if (!res) return [];
if (Array.isArray(res)) return res;
if (Array.isArray(res.rows)) return res.rows;
if (Array.isArray(res.data)) return res.data;
if (res.data && Array.isArray(res.data.list)) return res.data.list;
if (res.data && Array.isArray(res.data.records)) return res.data.records;
return [];
}
export default function MachineDataReport() {
const { t } = useTranslation();
const { stationId, currentStation } = useSelector((state: RootState) => state.station);
const [deviceList, setDeviceList] = useState<any[]>([]);
const [deviceLoading, setDeviceLoading] = useState(false);
const [selectedDeviceSn, setSelectedDeviceSn] = useState<string | undefined>();
const [dateRange, setDateRange] = useState<[dayjs.Dayjs, dayjs.Dayjs]>([
dayjs().startOf('day'),
dayjs(),
]);
const [selectedParams, setSelectedParams] = useState<string[]>(DEFAULT_PARAM_KEYS);
const [loading, setLoading] = useState(false);
const [rawRows, setRawRows] = useState<any[]>([]);
// 获取机器人列表
const fetchDevices = useCallback(async () => {
if (!stationId) return;
setDeviceLoading(true);
try {
const res = await getSiteDevice({
siteId: stationId,
pageSize: 9999,
pageNum: 1,
orgId: currentStation?.orgId,
});
const rows = res?.code === 200 ? (res.rows || []) : [];
setDeviceList(rows);
if (rows.length > 0) {
setSelectedDeviceSn(rows[0].serialNumber);
} else {
setSelectedDeviceSn(undefined);
}
} catch (e) {
console.error('fetch devices failed', e);
} finally {
setDeviceLoading(false);
}
}, [stationId, currentStation, selectedDeviceSn]);
useEffect(() => {
fetchDevices();
}, [fetchDevices]);
// 查询报表数据
const handleQuery = useCallback(async () => {
if (!selectedDeviceSn) {
utils.message.warning(t('report.selectRobot'));
return;
}
if (selectedParams.length === 0) {
utils.message.warning(t('report.selectParameters'));
return;
}
setLoading(true);
try {
const params: any = {
deviceId: selectedDeviceSn,
startTime: dateRange[0].format('YYYY-MM-DD HH:mm:ss'),
endTime: dateRange[1].format('YYYY-MM-DD HH:mm:ss'),
};
const res = await getDeviceRunningHistoryStatistics(params);
const rows = extractRows(res);
setRawRows(rows);
if (rows.length === 0) {
utils.message.info(t('common.noData'));
}
} catch (e) {
console.error('fetch intraday data failed', e);
utils.message.error(t('common.noData'));
setRawRows([]);
} finally {
setLoading(false);
}
}, [selectedDeviceSn, dateRange, selectedParams, t]);
// 进入页面自动查询一次(如果有默认设备)
useEffect(() => {
if (selectedDeviceSn && dateRange) {
handleQuery();
}
}, [selectedDeviceSn]);
// 整理图表数据:每行 { time, [paramKey]: value }
const chartData = useMemo(() => {
return rawRows.map(row => {
const item: any = { time: getRowTime(row) };
selectedParams.forEach(k => {
const v = row[k];
item[k] = (typeof v === 'number') ? v : (v != null ? Number(v) : null);
});
return item;
}).sort((a, b) => (a.time < b.time ? -1 : a.time > b.time ? 1 : 0));
}, [rawRows, selectedParams]);
// 图表 series 配置
const chartSeries = useMemo(() => {
return PARAM_CONFIG
.filter(p => selectedParams.includes(p.key))
.map(p => ({
key: p.key,
name: `${t(p.labelKey)}(${p.unit})`,
color: p.color,
}));
}, [selectedParams, t]);
// 表格列
const tableColumns = useMemo(() => {
const cols: any[] = [
{
title: t('report.generateTime') || '时间',
dataIndex: '_time',
key: '_time',
width: 180,
fixed: 'left',
render: (v: string) => v || '-',
},
];
PARAM_CONFIG
.filter(p => selectedParams.includes(p.key))
.forEach(p => {
cols.push({
title: `${t(p.labelKey)}(${p.unit})`,
dataIndex: p.key,
key: p.key,
width: 140,
render: (v: any) => (v != null && !isNaN(Number(v))) ? Number(v).toFixed(2) : '-',
});
});
return cols;
}, [selectedParams, t]);
// 表格数据源
const tableData = useMemo(() => {
return rawRows.map((row, idx) => {
const item: any = {
key: idx,
_time: getRowTime(row),
};
PARAM_CONFIG.forEach(p => {
const v = row[p.key];
item[p.key] = (typeof v === 'number') ? v : (v != null ? Number(v) : null);
});
return item;
}).sort((a, b) => (a._time < b._time ? -1 : a._time > b._time ? 1 : 0));
}, [rawRows]);
// 导出 CSV
const handleExport = useCallback(() => {
if (tableData.length === 0) {
utils.message.warning(t('common.noData'));
return;
}
const headers = tableColumns.map((c: any) => c.title);
const keys = tableColumns.map((c: any) => c.dataIndex);
const lines = [headers.join(',')];
tableData.forEach(row => {
lines.push(keys.map(k => {
const v = row[k];
if (v == null) return '';
const s = typeof v === 'number' ? v.toFixed(2) : String(v);
return `"${s.replace(/"/g, '""')}"`;
}).join(','));
});
const csv = '\uFEFF' + lines.join('\r\n');
const blob = new Blob([csv], { type: 'text/csv;charset=utf-8;' });
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
const deviceName = deviceList.find(d => d.serialNumber === selectedDeviceSn)?.deviceAlias || selectedDeviceSn || 'machine';
a.href = url;
a.download = `machine_data_${deviceName}_${dayjs().format('YYYYMMDD_HHmmss')}.csv`;
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
URL.revokeObjectURL(url);
}, [tableData, tableColumns, deviceList, selectedDeviceSn, t]);
const cardStyle = {
borderRadius: 12,
border: '1px solid #f0f0f0',
boxShadow: '0 4px 12px rgba(0,0,0,0.05)',
};
return (
<div style={{ display: 'flex', flexDirection: 'column', gap: 8 }}>
{/* 筛选栏 */}
<Card bordered={false} style={cardStyle} bodyStyle={{ padding: '16px 20px' }}>
<div style={{ display: 'flex', alignItems: 'center', flexWrap: 'wrap', gap: 20 }}>
<div style={{ display: 'flex', alignItems: 'center' }}>
<span style={{ fontSize: 13, color: '#86909C', marginRight: 8, whiteSpace: 'nowrap' }}>
<RobotOutlined style={{ marginRight: 4 }} />{t('report.selectRobot')}:
</span>
<Select
showSearch
value={selectedDeviceSn}
onChange={setSelectedDeviceSn}
style={{ width: 420 }}
placeholder={t('common.pleaseSelect')}
loading={deviceLoading}
optionFilterProp="children"
filterOption={(input, option) =>
String(option?.children ?? '').toLowerCase().includes(input.toLowerCase())
}
>
{deviceList.map((d) => (
<Option key={d.serialNumber} value={d.serialNumber}>
{d.deviceAlias || d.deviceName || d.serialNumber}
</Option>
))}
</Select>
</div>
<div style={{ display: 'flex', alignItems: 'center' }}>
<span style={{ fontSize: 13, color: '#86909C', marginRight: 8, whiteSpace: 'nowrap' }}>
{t('common.timeRange')}:
</span>
<RangePicker
showTime
format="YYYY-MM-DD HH:mm:ss"
value={dateRange}
onChange={(v) => v && v[0] && v[1] && setDateRange([v[0], v[1]])}
style={{ width: 380 }}
/>
</div>
<div style={{ display: 'flex', alignItems: 'center' }}>
<span style={{ fontSize: 13, color: '#86909C', marginRight: 8, whiteSpace: 'nowrap' }}>
{t('report.selectParameters')}:
</span>
<Checkbox.Group
value={selectedParams}
onChange={(v) => setSelectedParams(v as string[])}
style={{ maxWidth: 700 }}
>
<Row gutter={[8, 4]}>
{PARAM_CONFIG.map(p => (
<Col key={p.key}>
<Checkbox value={p.key}>{t(p.labelKey)}</Checkbox>
</Col>
))}
</Row>
</Checkbox.Group>
</div>
<div style={{ marginLeft: 'auto' }}>
<Space size={8}>
<Button
type="primary"
icon={<SearchOutlined />}
onClick={handleQuery}
loading={loading}
style={{ borderRadius: 6, height: 32, padding: '0 16px' }}
>
{t('report.query')}
</Button>
<Button
icon={<DownloadOutlined />}
onClick={handleExport}
disabled={tableData.length === 0}
style={{ borderRadius: 6, height: 32, color: '#00B42A', borderColor: '#00B42A' }}
>
{t('report.exportTable')}
</Button>
</Space>
</div>
</div>
</Card>
{/* 统计曲线图 */}
<Card
bordered={false}
style={cardStyle}
bodyStyle={{ padding: '20px' }}
title={
<Space>
<LineChartOutlined style={{ color: '#165DFF' }} />
<span style={{ fontSize: 15, fontWeight: 700, color: '#1D2129' }}>
{t('report.aiAnalysisStatistics')}
</span>
</Space>
}
extra={
selectedParams.length > 0 && (
<span style={{ fontSize: 12, color: '#86909C' }}>
{t('common.total', { count: chartData.length })} {t('report.unitItem')}
</span>
)
}
>
<Spin spinning={loading}>
{chartData.length > 0 && chartSeries.length > 0 ? (
<UniversalLineChart
data={chartData}
xKey="time"
series={chartSeries}
height={420}
/>
) : (
<Empty
style={{ margin: '60px 0' }}
description={loading ? '' : t('common.noData')}
/>
)}
</Spin>
</Card>
{/* 数据表格 */}
<Card
bordered={false}
style={cardStyle}
bodyStyle={{ padding: 0 }}
title={
<span style={{ fontSize: 15, fontWeight: 700, color: '#1D2129' }}>
{t('report.machineRecords')}
</span>
}
>
<Table
rowKey="key"
columns={tableColumns}
dataSource={tableData}
size="small"
loading={loading}
scroll={{ x: 'max-content', y: 400 }}
pagination={{ pageSize: 20, showSizeChanger: true, showTotal: (total) => `${total}` }}
className="compact-table"
locale={{ emptyText: t('common.noData') }}
/>
</Card>
</div>
);
}

View File

@@ -1,188 +1,53 @@
import { useEffect, useRef, useCallback, useState } from 'react';
import { useEffect, useRef } from 'react';
import mqtt, { MqttClient } from 'mqtt';
/* ============================================================
* MQTT 连接池 —— 同一 URL 共享一个连接,避免重复建连
* ============================================================ */
const connectionPool = new Map<string, { client: MqttClient; refCount: number }>();
function getOrCreateClient(url: string, options?: mqtt.IClientOptions): MqttClient {
const entry = connectionPool.get(url);
if (entry) {
entry.refCount++;
return entry.client;
}
const client = mqtt.connect(url, {
reconnectPeriod: 3000,
clean: true,
...options,
});
connectionPool.set(url, { client, refCount: 1 });
// 连接断开后自动清理池条目
client.on('close', () => {
const cur = connectionPool.get(url);
if (cur && cur.client === client) {
connectionPool.delete(url);
}
});
return client;
}
function releaseClient(url: string): void {
const entry = connectionPool.get(url);
if (!entry) return;
entry.refCount--;
if (entry.refCount <= 0) {
entry.client.end(true);
connectionPool.delete(url);
}
}
/* ============================================================
* useMqtt Hook
* ============================================================ */
interface UseMqttOptions {
/** broker 地址,如 wss://xxx/mqtt */
interface Options {
url: string;
/** 要订阅的主题(字符串或数组),传空则不订阅 */
topic: string | string[];
/** 收到消息的回调 */
onMessage: (topic: string, message: string) => void;
/** 是否启用订阅,默认 true;设为 false 时不会建立连接 */
enabled?: boolean;
/** MQTT 连接额外配置(可选) */
connectOptions?: mqtt.IClientOptions;
}
interface UseMqttReturn {
/** 当前连接状态 */
connected: boolean;
/** 手动发布消息 */
publish: (topic: string, message: string) => void;
}
export function useMqtt({
url,
topic,
onMessage,
enabled = true,
connectOptions,
}: UseMqttOptions): UseMqttReturn {
export function useMqtt({ url, topic, onMessage }: Options) {
const clientRef = useRef<MqttClient | null>(null);
const onMessageRef = useRef(onMessage);
const [connected, setConnected] = useState(false);
// 始终保持 onMessage 回调为最新引用,避免闭包过期
useEffect(() => {
onMessageRef.current = onMessage;
}, [onMessage]);
// 将 topic 统一转为数组,方便做 diff
const topicList = (Array.isArray(topic) ? topic : [topic]).filter(Boolean);
const topicKey = topicList.join(',');
/* ---------- 核心:建连 / 订阅 / 清理 ---------- */
useEffect(() => {
if (!enabled || !url) return;
const client = getOrCreateClient(url, {
const client = mqtt.connect(url, {
reconnectPeriod: 3000,
username: 'maibu',
password: 'jsmbzn520',
...connectOptions,
clean: true,
});
clientRef.current = client;
/* --- 连接成功 → 订阅主题 --- */
const handleConnect = () => {
setConnected(true);
if (topicList.length > 0) {
client.subscribe(topicList, (err) => {
if (err) console.error('[useMqtt] subscribe failed:', err);
});
}
};
client.on('connect', () => {
console.log('MQTT connected');
client.subscribe(topic);
});
/* --- 收到消息 → 回调 --- */
const handleMessage = (t: string, payload: Buffer) => {
console.log(payload.toString(), "订阅无人机数据")
onMessageRef.current(t, payload.toString());
};
client.on('message', (t, payload) => {
onMessage(t, payload.toString());
});
/* --- 连接状态变化 --- */
const handleReconnect = () => setConnected(false);
const handleOffline = () => setConnected(false);
const handleError = (err: Error) => {
console.error('[useMqtt] error:', err);
};
client.on('error', err => {
console.error('MQTT error', err);
});
client.on('connect', handleConnect);
client.on('message', handleMessage);
client.on('reconnect', handleReconnect);
client.on('offline', handleOffline);
client.on('error', handleError);
// 如果连接已经建立,直接订阅
if (client.connected && topicList.length > 0) {
client.subscribe(topicList);
setConnected(true);
}
/* --- 清理:退出路由时取消订阅 & 释放连接 --- */
return () => {
// 取消当前 hook 订阅的主题
if (topicList.length > 0) {
client.unsubscribe(topicList);
}
// 移除本 hook 注册的事件监听
client.removeListener('connect', handleConnect);
client.removeListener('message', handleMessage);
client.removeListener('reconnect', handleReconnect);
client.removeListener('offline', handleOffline);
client.removeListener('error', handleError);
setConnected(false);
// 释放连接池引用(refCount=0 时自动断开)
releaseClient(url);
clientRef.current = null;
client.end(true);
};
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [enabled, url, topicKey]);
}, [url, JSON.stringify(topic)]);
/* ---------- 主题热更新:topic 变化时 diff 订阅 ---------- */
const prevTopicKeyRef = useRef(topicKey);
useEffect(() => {
const client = clientRef.current;
if (!client || !client.connected) return;
const prevKey = prevTopicKeyRef.current;
prevTopicKeyRef.current = topicKey;
if (prevKey === topicKey) return;
// 取消旧主题
const prevTopics = prevKey ? prevKey.split(',').filter(Boolean) : [];
if (prevTopics.length > 0) {
client.unsubscribe(prevTopics);
}
// 订阅新主题
if (topicList.length > 0) {
client.subscribe(topicList);
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [topicKey]);
/* ---------- 手动发布 ---------- */
const publish = useCallback((t: string, message: string) => {
const client = clientRef.current;
if (client && client.connected) {
client.publish(t, message);
} else {
console.warn('[useMqtt] publish skipped: not connected');
}
}, []);
return { connected, publish };
return clientRef;
}
/* 使用 */
// useMqtt({
// url: 'wss://broker.emqx.io:8084/mqtt',
// topic: 'robot/status',
// onMessage: (_, message) => {
// setMsg(message);
// },
// });

View File

@@ -154,11 +154,6 @@ h4, .ant-typography h4 { font-size: clamp(1rem, 1.5vw, 1.25rem) !important; }
background-color: #f0f7ff !important;
}
.recharts-responsive-container>div{
width: 100% !important;
height: 100% !important;
}

View File

@@ -241,7 +241,6 @@ const en = {
},
devices: {
deviceManagement: 'Device Management',
distributable: 'Distributable',
deviceOverview: 'Device Overview',
deviceStatus: 'Device Status',
waylineTask: 'Wayline Tasks',
@@ -609,9 +608,6 @@ const en = {
lostControlAction: 'Lost Control Action',
lostControlActionLabel: 'Lost Control Action Label',
markPoint: 'Mark Point',
undoMark: 'Undo Mark',
noPointsToUndo: 'No points to undo',
pointUndone: 'Undone, {{count}} points left',
markedPointsCount: 'Marked Points Count',
minBattery: 'Min Battery',
minBatteryLabel: 'Min Battery Label',
@@ -663,8 +659,6 @@ const en = {
optimize: 'Optimize',
optionalEmpty: 'Optional Empty',
otherWebControlling: 'Other Web Controlling',
platformRequestControl: "{{platform}} platformRequestControl",
outDock: 'Out Dock',
outdoor: 'Outdoor',
panorama: 'Panorama',
@@ -995,9 +989,6 @@ const en = {
working: 'Working',
workingCurrent: 'Working Current',
zoomLens: 'Zoom Lens',
controllerNotConnected: "controllerNotConnected",
otherWebConnected: "otherWebConnected",
clickToRequestControl: "clickToRequestControl",
fixed2TaskSuspended2: 'Fixed2 Task Suspended2 态势',
@@ -1032,18 +1023,11 @@ const en = {
fixed2Video: 'Fixed2 Video 已配',
batteryFixed2: '电池 Battery Fixed2',
noFix: 'noFix',
single: 'single',
dgnss: 'dgnss',
ins: 'ins',
singleNoHeading: 'singleNoHeading',
dgnssNoHeading: 'dgnssNoHeading',
rtkFixedNoHeading: 'rtkFixedNoHeading',
rtkFloatNoHeading: 'rtkFloatNoHeading',
s62: 'Signal/Satellite',
s72: 'Wind Speed',
distributable: 'Distributable',
UnitsRobot: '',
UnitsDrone: '',
executing: 'Executing',
@@ -1132,8 +1116,6 @@ const en = {
fixed2Inspection: 'Inspection Wayline',
locationFixed2: '🚗 Machine Location',
hasHost: "hasHost",
rtkMode: "rtkMode", cameraNum: "cameraNum", wheelType: "wheelType", engineType: "engineType", capabilityList: "capabilityList", powerType: "powerType",
dronePositionFixed2: '✈️ Drone Position',
@@ -1300,10 +1282,9 @@ const en = {
failedFixed22: '权限校验 Failed Fixed2',
noneControl: 'None Control jurisdiction',
noneControl: 'None Control 权限',
fixed2ControlFixed2: 'Fixed2 Control 请求 超时 Fixed2',
controlFailed: "controlFailed",
},
video: {
onlineVideo: 'Online Video',
@@ -2287,7 +2268,12 @@ const en = {
totalWorkOrders: 'Total Work Orders',
completionRate: 'Completion Rate',
averageEfficiency: 'Average Efficiency',
aiAnalysisReport: 'ai Analysis Report',
machineAnalysisReport: 'Machine Data Report',
selectRobot: 'Select Robot',
selectParameters: 'Select Parameters',
query: 'Query',
exportTable: 'Export Table',
machineRecords: 'Machine Records',
aiAnalysisStatistics: 'ai Analysis Statistics',
aiDiagnosisDaily: 'ai Diagnosis Daily',
alarmCount: 'Alarm Count',
@@ -3139,8 +3125,6 @@ const en = {
s92: 'nickname',
importSuccess: 'Import Success',
importFail: 'Import Failed',
successFixed22: 'Bind Success ',
device2: 'No valid Device was selected. Unbinding is not possible.',

View File

@@ -237,24 +237,13 @@ const zh = {
failedFixed2: '❌ 工单生成接口调用失败',
solarPanel: "组件阵列",
weatherStation: "气象站",
WeatherStation: "气象站",
environmentalSensor: "环境传感器",
distributable: "可调度",
},
devices: {
noFix: '无定位',
single: '单点定位',
dgnss: '差分定位',
ins: '惯导定位',
rtkFixed: 'RTK固定解',
rtkFloat: 'RTK浮点解',
singleNoHeading: '单点定位(无航向)',
dgnssNoHeading: '差分定位(无航向)',
rtkFixedNoHeading: 'RTK固定解(无航向)',
rtkFloatNoHeading: 'RTK浮点解(无航向)',
deviceManagement: '设备管理',
distributable: '可调度',
deviceOverview: '设备总览',
deviceStatus: '设备状态',
waylineTask: '航线任务',
@@ -355,7 +344,7 @@ const zh = {
good: '良好',
robotRouteMonitor: '机器人路径规划与监控',
clearRealtimeTrack: '清空实时轨迹',
clearPlanRoute: '清空规划区域',
clearPlanRoute: '清空规划航线',
controlMode: '控制模式:',
localMode: '本地',
remoteMode: '远程',
@@ -383,6 +372,7 @@ const zh = {
currentTemp: '当前温度',
humidity: '环境湿度',
positionAccuracy: '定位精度',
rtkFixed: 'RTK 固定',
networkLatency: '网络延迟',
waterRiskWarning: '注意:区域 B 存在积水风险,建议避开',
presetRoutes: '预设路线',
@@ -438,7 +428,7 @@ const zh = {
aiAnalysisTitle: 'AI分析标题',
aiOptimizeGain: 'AI优化增益',
aiOptimizePath: 'AI优化路径',
aiSuggestionColon: 'AI建议',
aiSuggestionColon: 'AI建议冒号',
airportCode: '机场码',
airportSn: '机场序列号',
airportSnLabel: '机场序列号标签',
@@ -465,7 +455,7 @@ const zh = {
blockUnit: '区块单位',
boardTaskFetchFail: '看板任务获取失败',
boundDrone: '边界无人机',
bowMode: '覆盖模式',
bowMode: '弓字模式',
canWorkNormally: '可工作正常',
cancelReturnHome: '取消返航首页',
chargePoint: '充电点',
@@ -487,7 +477,7 @@ const zh = {
communicationStatus: '通信状态',
complete: '完成',
completePathFirst: '完成路径先',
completedTimeColon: '已完成时间',
completedTimeColon: '已完成时间冒号',
completionRate: '完成率',
componentRiskZone: '组件风险区域',
confirmCreate: '确认创建',
@@ -497,6 +487,7 @@ const zh = {
connectionFailed: '连接失败',
controlLogTitle: '控制日志标题',
controlRequestContent: '控制请求内容',
controllerNotConnected: "控制器未连接",
countUnit: '数量单位',
coverClosed: '已关闭',
coverOpen: '打开',
@@ -525,10 +516,10 @@ const zh = {
deviceOnlineRate: '设备在线率',
deviceParamSetting: '设备参数设置',
deviceSn: '设备序列号',
deviceSnColon: '设备序列号',
deviceSnColon: '设备序列号冒号',
deviceSnLabel: '设备序列号标签',
deviceTaskList: '设备任务列表',
deviceTypeColon: '设备类型',
deviceTypeColon: '设备类型冒号',
dgpsDiff: 'DGPS差异',
dispatchableCount: '可派单数量',
droneAirport: '无人机机场',
@@ -547,14 +538,14 @@ const zh = {
endLabel: '结束标签',
envFlightConditions: '环境飞行条件',
envWindSpeed: '环境风速度',
equipmentColon: '设备',
equipmentColon: '设备冒号',
equipmentControl: '设备控制',
equipmentName: '设备名称',
equipmentOverview: '设备概览',
equipmentScheduleList: '设备计划列表',
equipmentSituationMap: '设备态势地图',
execTimePoint: '执行时间点',
executeDeviceColon: '执行设备',
executeDeviceColon: '执行设备冒号',
executeNow: '执行现在',
executeWayline: '执行航线',
executeWaylineTask: '执行航线任务',
@@ -568,12 +559,6 @@ const zh = {
fillRequiredFields: '填写必填字段',
firmwareVersion: '固件版本',
fixed: '固定',
controllerNotConnected: "控制器未连接",
otherWebConnected: "其他网页已连接",
clickToRequestControl: "点击请求控制",
controlling: "控制中",
fixed2: '',
fixedEnv: '固定环境',
flightAltitude: '飞行高度',
@@ -631,9 +616,6 @@ const zh = {
lostControlAction: '丢失控制操作',
lostControlActionLabel: '丢失控制操作标签',
markPoint: '打点',
undoMark: '撤回打点',
noPointsToUndo: '暂无打点可撤回',
pointUndone: '已撤回,剩余 {{count}} 个打点',
markedPointsCount: '已标记点数量',
minBattery: '最小电量',
minBatteryLabel: '最小电量标签',
@@ -685,59 +667,57 @@ const zh = {
optimize: '优化',
optionalEmpty: '可选空',
otherWebControlling: '其他网页控制中',
controlling: "控制中",
clickToRequestControl: "点击请求控制",
outDock: '舱外',
outdoor: '室外',
panorama: '全景',
paramArmChannel: '布防渠道',
paramBatteryType: '电量类型',
paramChassisChannel: '底盘渠道',
paramChipUid: '芯片UID',
paramChipUidSign: '芯片UID标识',
paramDelFlag: '删除标志',
paramDriveType: '驱动类型',
paramDualRtk: '双RTK',
paramFanChannel: '风扇渠道',
paramFanPolarity: '风扇极性',
paramFirmwareVersion: '固件版本',
paramForwardSpeedLimit: '前进速度限制',
paramFuelPumpChannel: '燃料泵渠道',
paramGearRatio: '档位比例',
paramKnifeChannel: '刀渠道',
paramKnifeMotorMode: '刀电机模式',
paramKnifePolarity: '刀极性',
paramKnifeWidth: '刀宽度',
paramLeftBackwardGain: '左后退增益',
paramLeftForwardGain: '左前进增益',
paramLeftMotorReverse: '左电机反向',
paramLiftChannel: '抬升渠道',
paramLiftProtectTime: '抬升保护时间',
paramRelayBoard: '中继看板',
paramRemoteConfig: '远程配置',
paramRemoteType: '远程类型',
paramRightBackwardGain: '右后退增益',
paramRightForwardGain: '右前进增益',
paramRightMotorReverse: '右电机反向',
paramRobotHeight: '机器人高度',
paramRobotLength: '机器人长度',
paramRobotWidth: '机器人宽度',
paramRunSpeed: '运行速度',
paramSaveException: '保存异常',
paramSaveFail: '保存失败',
paramSaveSuccess: '保存成功',
paramSwapChannel: '切换渠道',
paramThrottleChannel: '油门渠道',
paramThrottlePolarity: '油门极性',
paramTurnSpeedLimit: '转向速度限制',
paramTyreSize: '轮胎大小',
paramUse4G: '4G',
paramViewEditTitle: '参数查看编辑',
paramWalkMotorMode: '行走电机模式',
paramWifiName: 'WiFi名称',
paramWifiPassword: 'WiFi密码',
productModel: '产品型号',
hasHost: "是否有上位机",
rtkMode: "rtk模式", cameraNum: "摄像头数量", wheelType: "车轮类型", engineType: "发动机类型", capabilityList: "能力列表", powerType: "动力类型",
paramArmChannel: '参数布防渠道',
paramBatteryType: '参数电量类型',
paramChassisChannel: '参数底盘渠道',
paramChipUid: '参数芯片UID',
paramChipUidSign: '参数芯片UID标识',
paramDelFlag: '参数删除标志',
paramDriveType: '参数驱动类型',
paramDualRtk: '参数双RTK',
paramFanChannel: '参数风扇渠道',
paramFanPolarity: '参数风扇极性',
paramFirmwareVersion: '参数固件版本',
paramForwardSpeedLimit: '参数前进速度限制',
paramFuelPumpChannel: '参数燃料泵渠道',
paramGearRatio: '参数档位比例',
paramKnifeChannel: '参数刀渠道',
paramKnifeMotorMode: '参数刀电机模式',
paramKnifePolarity: '参数刀极性',
paramKnifeWidth: '参数刀宽度',
paramLeftBackwardGain: '参数左后退增益',
paramLeftForwardGain: '参数左前进增益',
paramLeftMotorReverse: '参数左电机反向',
paramLiftChannel: '参数抬升渠道',
paramLiftProtectTime: '参数抬升保护时间',
paramRelayBoard: '参数中继看板',
paramRemoteConfig: '参数远程配置',
paramRemoteType: '参数远程类型',
paramRightBackwardGain: '参数右后退增益',
paramRightForwardGain: '参数右前进增益',
paramRightMotorReverse: '参数右电机反向',
paramRobotHeight: '参数机器人高度',
paramRobotLength: '参数机器人长度',
paramRobotWidth: '参数机器人宽度',
paramRunSpeed: '参数运行速度',
paramSaveException: '参数保存异常',
paramSaveFail: '参数保存失败',
paramSaveSuccess: '参数保存成功',
paramSwapChannel: '参数切换渠道',
paramThrottleChannel: '参数油门渠道',
paramThrottlePolarity: '参数油门极性',
paramTurnSpeedLimit: '参数转向速度限制',
paramTyreSize: '参数轮胎大小',
paramUse4G: '参数4G',
paramViewEditTitle: '参数查看编辑标题',
paramWalkMotorMode: '参数行走电机模式',
paramWifiName: '参数WiFi名称',
paramWifiPassword: '参数WiFi密码',
pathPlanDone: '路径计划已完成',
pathPlanFailRetry: '路径计划失败重试',
pathPlanning: '路径规划',
@@ -755,8 +735,8 @@ const zh = {
positionInStation: '位置内电站',
precipStatus: '降水状态',
productType: '产品类型',
rainNo: '无',
rainYes: '降雨',
rainNo: '雨无',
rainYes: '雨是',
rainfall: '降雨',
realtimeMonitorList: '实时监控列表',
realtimePicture: '实时图片',
@@ -785,10 +765,10 @@ const zh = {
resumeTask: '恢复任务',
returnCommandSent: '返航指令已发送',
returnHomeAltitude: '返航首页高度',
returnHomeAltitudeColon: '返航首页高度',
returnHomeAltitudeLabel: '返航高度',
returnHomeAltitudeColon: '返航首页高度冒号',
returnHomeAltitudeLabel: '返航首页高度标签',
returnHomeMode: '返航首页模式',
returnHomeModeLabel: '返航模式',
returnHomeModeLabel: '返航首页模式标签',
rightView: '右视角',
rightWheelDrive: '右轮驱动',
robotExecutingCount: '机器人执行中数量',
@@ -804,28 +784,29 @@ const zh = {
routeLoadedWithName: '路线已加载带名称',
routeNoPathPoints: '路线编号路径点',
routeSavedLocal: '路线已保存本地',
rtBattery: '电量',
rtHeadingAngle: '航向角度',
rtHeadingStatus: '航向状态',
rtInitialized: '已初始化',
rtLeftMotor: '左电机',
rtLeftSpeed: '左速度',
rtLeftTemp: '左温度',
rtMainTemp: '主温度',
rtMode: '模式',
rtPitchAngle: '俯仰角度',
rtPositioning: '定位',
rtRightMotor: '右电机',
rtRightSpeed: '右速度',
rtRightTemp: '右温度',
rtSatellites: '卫星数量',
rtVoltage: '电压',
rtBattery: '实时电量',
rtHeadingAngle: '实时航向角度',
rtHeadingStatus: '实时航向状态',
rtInitialized: '实时已初始化',
rtLeftMotor: '实时左电机',
rtLeftSpeed: '实时左速度',
rtLeftTemp: '实时左温度',
rtMainTemp: '实时主温度',
rtMode: '实时模式',
rtPitchAngle: '实时俯仰角度',
rtPositioning: '实时定位',
rtRightMotor: '实时右电机',
rtRightSpeed: '实时右速度',
rtRightTemp: '实时右温度',
rtSatellites: '实时卫星',
rtVoltage: '实时电压',
rthMode: '返航模式',
rthOptimal: '返航最优',
rthPreset: '返航预设',
rtkCount: 'RTK数量',
rtkEnvLabel: 'RTK环境标签',
rtkFixed2: 'RTK固定',
rtkFixed2: 'RTK',
rtkFloat: 'RTK浮点',
rtkHighPrecision: 'RTK高精度',
rtkModeDesc: 'RTK模式描述',
rtkStatus: 'RTK状态',
@@ -838,36 +819,36 @@ const zh = {
searchWaylinePlaceholder: '搜索航线占位',
selectDevice: '选择设备',
selectDrone: '选择无人机',
selectExecuteDroneFirst: '执行无人机',
selectNoDrone: '无无人机',
selectStartTimePlaceholder: '开始时间',
selectExecuteDroneFirst: '选择执行无人机先',
selectNoDrone: '选择无无人机',
selectStartTimePlaceholder: '选择开始时间占位',
selectTaskFirst: '选择任务先',
selectTaskStartTime: '任务开始时间',
selectTaskStartTime: '选择任务开始时间',
selectWayline: '选择航线',
selectedWaylineColon: '已选航线',
selectedWaylineColon: '已选航线冒号',
signalSatellite: '信号卫星',
situationMap: '态势地图',
smartAssign: '智能分配',
standbyCount: '待机数量',
startBtn: '开始按钮',
startLabel: '开始标签',
startTimeColon: '开始时间',
startTimeColon: '开始时间冒号',
stationCameraNotFound: '电站摄像头未找到',
stationStatus: '电站状态',
stationTopology: '电站拓扑',
stationVideo: '电站视频',
statusExecFailed: '执行失败',
statusExecSuccess: '执行成功',
statusExecFailed: '状态执行失败',
statusExecSuccess: '状态执行成功',
statusPendingApproval: '状态待处理审批',
statusPreparing: '准备中',
statusRestored: '已恢复',
statusStartFailed: '开始失败',
statusSuggestExec: '建议执行',
statusTerminated: '已终止',
statusTimeout: '超时',
statusUpdateSuccess: '更新成功',
statusWaitExec: '等待执行',
statusWaitingStart: '等待中开始',
statusPreparing: '状态准备中',
statusRestored: '状态已恢复',
statusStartFailed: '状态开始失败',
statusSuggestExec: '状态建议执行',
statusTerminated: '状态已终止',
statusTimeout: '状态超时',
statusUpdateSuccess: '状态更新成功',
statusWaitExec: '状态等待执行',
statusWaitingStart: '状态等待中开始',
stopVideoBtn: '停止视频按钮',
suggestAction: '建议操作',
suggestTime: '建议时间',
@@ -1318,9 +1299,6 @@ const zh = {
cancel: "取消",
UnitsRobot: "台",
UnitsDrone: "架",
platformRequestControl: "{{platform}} 正在请求控制权限",
controlFailed: "controlFailed",
},
video: {
onlineVideo: '在线视频',
@@ -2318,7 +2296,13 @@ const zh = {
totalWorkOrders: '工单总数',
completionRate: '完成率',
averageEfficiency: '平均效率',
aiAnalysisReport: 'AI分析报表',
machineAnalysisReport: '机器数据报表',
selectRobot: '机器人',
selectParameters: '选择参数',
query: '查询',
exportTable: '导出表格',
machineRecords: '机器记录',
aiAnalysisStatistics: 'AI分析统计',
aiDiagnosisDaily: 'AI诊断每日',
alarmCount: '告警数量',
@@ -2661,7 +2645,7 @@ const zh = {
s28: '开启钉钉推送时必须填写加密密钥',
fixed2OM: '运维工程师',
fixed2OM: '普通用户',
fixed2Inspection: '巡检区',
@@ -3102,9 +3086,9 @@ const zh = {
s282: '最近更新',
fixed2Inspection2: '巡检主管',
fixed2Inspection2: '机构管理员',
s322: '数据分析师',
s322: '场站管理员',
fixed2Login2: '登录审计',
@@ -3176,8 +3160,6 @@ const zh = {
s92: '昵称',
importSuccess: '导入成功',
importFail: '导入失败',
successFixed22: '绑定成功',
device2: '未选择有效设备,无法解绑',
@@ -3365,17 +3347,17 @@ const zh = {
male: '男',
female: '女',
notSet: '未设置',
basicInfo: '基本信息',
basicInfo: '基础提示',
changePassword: '变更密码',
confirmPasswordPlaceholder: '确认密码',
confirmPasswordPlaceholder: '确认密码占位',
confirmPasswordRequired: '确认密码必填',
emailInvalid: '邮件无效',
emailPlaceholder: '邮件占位',
newPasswordPlaceholder: '新密码',
oldPasswordPlaceholder: '旧密码',
newPasswordPlaceholder: '新密码占位',
oldPasswordPlaceholder: '旧密码占位',
passwordLengthError: '密码长度错误',
phoneInvalid: '电话无效',
remarkPlaceholder: '备注',
remarkPlaceholder: '备注占位',
requestFailed: '请求失败',
},
users: {
@@ -3446,7 +3428,7 @@ const zh = {
roleNamePlaceholder: '角色名称占位',
rolePermission: '角色权限',
roleSortLabel: '角色排序标签',
superAdmin: '超级管理员',
superAdmin: '平台管理员',
},
constants: {
// 工单类型

View File

@@ -1,4 +1,4 @@
import React, { useState } from 'react';
import React, { useState } from 'react';
import {
Row, Col, Card, Button, Tag, Table, Typography, Space, Statistic, message, Divider, Tooltip, Avatar, Empty
} from 'antd';
@@ -210,8 +210,8 @@ export default function AIDiagnosisPage() {
].map((item, index) => (
<Col key={index} xs={24} sm={12} md={8} xl={4}>
<Card
variant="borderless"
styles={{ body: { padding: '20px 16px' } }}
bordered={false}
bodyStyle={{ padding: '20px 16px' }}
style={{ ...cardStyle, height: '100%' }}
>
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'flex-start' }}>
@@ -245,8 +245,8 @@ export default function AIDiagnosisPage() {
<Card
title={<span style={{ fontSize: 15, fontWeight: 700, color: '#1D2129' }}>{t('aiAnalysis.fixed2UavInspection')}<InfoCircleOutlined style={{ marginLeft: 6, color: '#86909C', fontSize: 13 }} /></span>}
extra={<Text type="secondary" style={{ fontSize: 12 }}>{t('aiAnalysis.fixed2Inspection202505200930')}<CalendarOutlined style={{ marginLeft: 4 }} /></Text>}
variant="borderless"
styles={{ body: { padding: '16px 20px' } }}
bordered={false}
bodyStyle={{ padding: '16px 20px' }}
style={{ ...cardStyle, height: '100%' }}
>
<Row gutter={[12, 12]}>
@@ -288,8 +288,8 @@ export default function AIDiagnosisPage() {
<span>{t('aiAnalysis.s9')}<b style={{ color: '#1D2129' }}>160</b></span>
<span>{t('aiAnalysis.fixed2Abnormal')}<b style={{ color: '#F53F3F' }}>8</b></span>
</Space>}
variant="borderless"
styles={{ body: { padding: '16px 20px' } }}
bordered={false}
bodyStyle={{ padding: '16px 20px' }}
style={{ ...cardStyle, height: '100%' }}
>
<Row gutter={[20, 20]}>
@@ -383,8 +383,8 @@ export default function AIDiagnosisPage() {
<Col xs={24} lg={7}>
<Card
title={<span style={{ fontSize: 15, fontWeight: 700, color: '#1D2129' }}>{t('aiAnalysis.s13')}<InfoCircleOutlined style={{ marginLeft: 6, color: '#86909C', fontSize: 13 }} /></span>}
variant="borderless"
styles={{ body: { padding: '16px 20px' } }}
bordered={false}
bodyStyle={{ padding: '16px 20px' }}
style={{ ...cardStyle, height: '100%' }}
>
<div style={{ fontSize: 12, color: '#86909C', marginBottom: 16, display: 'flex', justifyContent: 'space-between' }}>
@@ -432,8 +432,8 @@ export default function AIDiagnosisPage() {
<Col xs={24} lg={10}>
<Card
title={<span style={{ fontSize: 15, fontWeight: 700, color: '#1D2129' }}>{t('aiAnalysis.generation')}<InfoCircleOutlined style={{ marginLeft: 6, color: '#86909C', fontSize: 13 }} /></span>}
variant="borderless"
styles={{ body: { padding: '16px 20px' } }}
bordered={false}
bodyStyle={{ padding: '16px 20px' }}
style={{ ...cardStyle, height: '100%' }}
>
<div style={{ display: 'flex', gap: 20 }}>
@@ -487,8 +487,8 @@ export default function AIDiagnosisPage() {
<Col xs={24} lg={7}>
<Card
variant="borderless"
styles={{ body: { padding: 0 } }}
bordered={false}
bodyStyle={{ padding: 0 }}
style={{ ...cardStyle, height: '100%' }}
>
{/* AI诊断总结 */}
@@ -498,7 +498,6 @@ export default function AIDiagnosisPage() {
<span style={{ fontSize: 12, color: '#86909C' }}>{t('aiAnalysis.fixed2UpdatedAt202505200945')}</span>
</div>
<Table
rowKey="key"
columns={[
{ title: t('aiAnalysis.s36'), dataIndex: 'diagnosis', width: 78 },
{ title: t('roles.status'), dataIndex: 'status', render: renderStatusTag, },
@@ -515,6 +514,7 @@ export default function AIDiagnosisPage() {
]}
pagination={false}
size="small"
rowKey="key"
style={{ fontSize: 12 }}
/>
</div>
@@ -524,7 +524,6 @@ export default function AIDiagnosisPage() {
<div style={{ padding: '12px 14px' }}>
<div style={{ fontSize: 14, fontWeight: 700, color: '#1D2129', marginBottom: 10 }}>{t('aiAnalysis.fixed2Ai')}</div>
<Table
rowKey="key"
columns={[
{ title: t('aiAnalysis.s39'), dataIndex: 'measure', ellipsis: true },
{ title: t('workOrder.priority'), dataIndex: 'priority', render: renderPriorityTag, width: 58 },
@@ -554,6 +553,7 @@ export default function AIDiagnosisPage() {
]}
pagination={false}
size="small"
rowKey="key"
style={{ fontSize: 12 }}
/>
</div>
@@ -564,8 +564,8 @@ export default function AIDiagnosisPage() {
{/* 底部:数据来源 */}
<Card
title={<span style={{ fontSize: 15, fontWeight: 700, color: '#1D2129' }}>{t('aiAnalysis.sourceFixed2')}</span>}
variant="borderless"
styles={{ body: { padding: '16px 20px' } }}
bordered={false}
bodyStyle={{ padding: '16px 20px' }}
style={cardStyle}
>
<Row gutter={[16, 16]}>

View File

@@ -35,6 +35,7 @@ export default function AlarmCenterPage() {
<div style={{ display: 'flex', paddingBottom: "4px" }}>
<div style={{ padding: '8px 12px 0' }}>
<Typography.Title level={4} style={{ margin: 0, fontSize: 'clamp(14px, 1.2vw, 18px)' }}>{t('router.alerts')}</Typography.Title>
<Text type="secondary" style={{ fontSize: '12px' }}>{t('alerts.subtitle')}</Text>
</div>
<Header style={{ padding: 0, borderBottom: '1px solid #f0f0f0', position: 'sticky', top: 0, zIndex: 10, height: 40, lineHeight: '40px' }}>

View File

@@ -1,4 +1,4 @@
import React, { useState } from 'react';
import React, { useState } from 'react';
import {
Row, Col, Card, Button, Table, Tag, Typography, Space, Statistic, DatePicker,
Divider, Progress, Badge, Select, Tooltip, Avatar
@@ -226,8 +226,8 @@ export default function CleanOptimizationPage() {
].map((item, index) => (
<Col key={index} style={{ minWidth: '168px', flex: '1 0 auto', maxWidth: "250px" }}>
<Card
variant="borderless"
styles={{ body: { padding: '16px' } }}
bordered={false}
bodyStyle={{ padding: '16px' }}
style={{ borderRadius: 8, height: 120 }}
>
<div style={{ display: 'flex', justifyContent: 'space-between', height: '100%' }}>
@@ -298,7 +298,7 @@ export default function CleanOptimizationPage() {
<Row gutter={[8, 8]} style={{ display: 'flex', alignItems: 'stretch' }}>
{/* 左侧:分析图表 */}
<Col xs={24} xl={6} style={{ display: 'flex', flexDirection: 'column', gap: 8 }}>
<Card title={<span style={{ fontSize: 14, fontWeight: 700 }}>{t('clean.s6')}</span>} variant="borderless" style={cardStyle} styles={{ body: { padding: 16 } }}>
<Card title={<span style={{ fontSize: 14, fontWeight: 700 }}>{t('clean.s6')}</span>} bordered={false} style={cardStyle} bodyStyle={{ padding: 16 }}>
<div style={{ fontSize: 12, color: '#86909C', marginBottom: 16, display: 'flex', justifyContent: 'space-between' }}>
<span>{t('clean.s7')}</span>
<Space size={12}>
@@ -329,7 +329,7 @@ export default function CleanOptimizationPage() {
/>
</Card>
<Card title={<span style={{ fontSize: 14, fontWeight: 700 }}>{t('clean.fixed2Generation')}<Text type="secondary" style={{ fontWeight: 400, fontSize: 12 }}>{t('clean.near7Days')}</Text></span>} variant="borderless" style={cardStyle} styles={{ body: { padding: 16 } }}>
<Card title={<span style={{ fontSize: 14, fontWeight: 700 }}>{t('clean.fixed2Generation')}<Text type="secondary" style={{ fontWeight: 400, fontSize: 12 }}>{t('clean.near7Days')}</Text></span>} bordered={false} style={cardStyle} bodyStyle={{ padding: 16 }}>
<div style={{ position: 'relative', height: "100%" }}>
<UniversalPieChart
data={pieChartData}
@@ -346,7 +346,7 @@ export default function CleanOptimizationPage() {
</div>
</Card>
<Card title={<span style={{ fontSize: 14, fontWeight: 700 }}>{t('clean.fixed2Cleaning2')}<Text type="secondary" style={{ fontWeight: 400, fontSize: 12 }}>{t('clean.nearLast')}</Text></span>} variant="borderless" style={cardStyle} styles={{ body: { padding: 16 } }}>
<Card title={<span style={{ fontSize: 14, fontWeight: 700 }}>{t('clean.fixed2Cleaning2')}<Text type="secondary" style={{ fontWeight: 400, fontSize: 12 }}>{t('clean.nearLast')}</Text></span>} bordered={false} style={cardStyle} bodyStyle={{ padding: 16 }}>
<UniversalBarChart
data={compareChartData}
xKey="date"
@@ -367,7 +367,7 @@ export default function CleanOptimizationPage() {
/>
</Card>
<Card title={<span style={{ fontSize: 14, fontWeight: 700 }}>{t('clean.fixed2CleaningFixed2')}</span>} variant="borderless" style={cardStyle} styles={{ body: { padding: 16 } }}>
<Card title={<span style={{ fontSize: 14, fontWeight: 700 }}>{t('clean.fixed2CleaningFixed2')}</span>} bordered={false} style={cardStyle} bodyStyle={{ padding: 16 }}>
<Row gutter={[16, 16]}>
<Col span={12}>
<div style={{ fontSize: 11, color: '#86909C', marginBottom: 4 }}>{t('clean.generation')}</div>
@@ -398,9 +398,9 @@ export default function CleanOptimizationPage() {
<Col xs={24} xl={11} style={{ display: 'flex', flexDirection: 'column', gap: 8 }}>
<Card
title={<span style={{ fontSize: 15, fontWeight: 700 }}>{t('clean.recommendedCleanBlock')}</span>}
variant="borderless"
bordered={false}
style={{ ...cardStyle, }}
styles={{ body: { padding: 0, position: 'relative', overflow: 'hidden', minHeight: 500 } }}
bodyStyle={{ padding: 0, position: 'relative', overflow: 'hidden', minHeight: 500 }}
>
<div style={{ background: '#f8fafc', padding: '10px 20px', display: 'flex', justifyContent: 'space-between', borderBottom: '1px solid #f0f0f0', flexWrap: 'wrap', gap: 8 }}>
<Space size={16} wrap style={{ fontSize: 11 }}>
@@ -455,12 +455,11 @@ export default function CleanOptimizationPage() {
<Card
title={<span style={{ fontSize: 15, fontWeight: 700 }}>{t('clean.fixed2Cleaning2')}</span>}
extra={<Button type="link" size="small">{t('devices.viewMore')}<ChevronRight size={14} /></Button>}
variant="borderless"
bordered={false}
style={cardStyle}
styles={{ body: { padding: 0 } }}
bodyStyle={{ padding: 0 }}
>
<Table
rowKey="area"
columns={[
{ title: t('clean.s45'), dataIndex: 'area', key: 'area' },
{ title: t('workOrder.priority'), dataIndex: 'priority', key: 'priority', render: renderPriorityTag },
@@ -480,12 +479,11 @@ export default function CleanOptimizationPage() {
{/* 右侧:决策建议与参考 */}
<Col xs={24} xl={7} style={{ display: 'flex', flexDirection: 'column', gap: 8 }}>
<Card title={<span style={{ fontSize: 14, fontWeight: 700 }}>{t('clean.cleaning2')}</span>} variant="borderless" style={cardStyle} styles={{ body: { padding: 0 } }}>
<Card title={<span style={{ fontSize: 14, fontWeight: 700 }}>{t('clean.cleaning2')}</span>} bordered={false} style={cardStyle} bodyStyle={{ padding: 0 }}>
<div style={{ background: '#f8fafc', padding: '8px 16px', borderBottom: '1px solid #f0f0f0' }}>
<Text type="secondary" style={{ fontSize: 11 }}>{t('clean.algorithmModel')}</Text>
</div>
<Table
rowKey="id"
columns={[
{ title: t('clean.s48'), dataIndex: 'id', key: 'id', width: 85 },
{ title: t('workOrder.priority'), dataIndex: 'priority', key: 'priority', render: (p) => <span style={{ color: p === t('workOrder.high') ? '#F53F3F' : '#F7BA1E', fontWeight: 600 }}>{p}</span>, width: 65 },
@@ -500,7 +498,7 @@ export default function CleanOptimizationPage() {
/>
</Card>
<Card title={<span style={{ fontSize: 14, fontWeight: 700 }}>{t('clean.fixed2Cleaning2')}</span>} variant="borderless" style={cardStyle} styles={{ body: { padding: 16 } }}>
<Card title={<span style={{ fontSize: 14, fontWeight: 700 }}>{t('clean.fixed2Cleaning2')}</span>} bordered={false} style={cardStyle} bodyStyle={{ padding: 16 }}>
<Row gutter={12}>
<Col span={12}>
<div style={{ background: '#F9F0FF', borderRadius: 12, padding: 16, border: '1px solid #D3ADF7', height: '100%' }}>
@@ -531,7 +529,7 @@ export default function CleanOptimizationPage() {
</Row>
</Card>
<Card title={<span style={{ fontSize: 14, fontWeight: 700 }}>{t('clean.fixed2WeatherAdvice2')}<Text type="secondary" style={{ fontSize: 12, fontWeight: 400 }}>({t('clean.plan', { name: '01' })})</Text></span>} variant="borderless" style={cardStyle} styles={{ body: { padding: 16 } }}>
<Card title={<span style={{ fontSize: 14, fontWeight: 700 }}>{t('clean.fixed2WeatherAdvice2')}<Text type="secondary" style={{ fontSize: 12, fontWeight: 400 }}>({t('clean.plan', { name: '01' })})</Text></span>} bordered={false} style={cardStyle} bodyStyle={{ padding: 16 }}>
<Row gutter={12}>
<Col span={8}>
<div style={{ background: '#f8fafc', padding: '10px 4px', borderRadius: 8, textAlign: 'center', border: '1px solid #f0f0f0' }}>
@@ -563,7 +561,7 @@ export default function CleanOptimizationPage() {
</Row>
</Card>
<Card title={<span style={{ fontSize: 14, fontWeight: 700 }}>{t('clean.fixed2Cleaning')}</span>} variant="borderless" style={cardStyle} styles={{ body: { padding: 16 } }}>
<Card title={<span style={{ fontSize: 14, fontWeight: 700 }}>{t('clean.fixed2Cleaning')}</span>} bordered={false} style={cardStyle} bodyStyle={{ padding: 16 }}>
<Row gutter={[16, 16]}>
{[
{ icon: <Droplets size={18} color="#165DFF" />, bg: '#E8F3FF', label: t('clean.s52'), value: t('clean.tonUnit', { value: '18' }), sub: t('clean.waterSaveWithRobot', { value: '30%' }), subColor: '#00B42A' },

View File

@@ -1,4 +1,4 @@
import React, { useState, useEffect, useRef } from 'react';
import React, { useState, useEffect, useRef } from 'react';
import { Card, Row, Col, Statistic, Button, Space, Tag, Typography, Table, message } from 'antd';
import {
CloudOutlined, ThunderboltOutlined, BarChartOutlined,
@@ -7,7 +7,6 @@ import {
MoneyCollectOutlined,
DashboardOutlined,
FullscreenOutlined,
FullscreenExitOutlined,
RocketOutlined,
VideoCameraOutlined,
AppstoreOutlined,
@@ -22,57 +21,27 @@ import { getWeatherData, getWeatherType } from '../lib/utils';
import WeatherDisplay from '../components/Weather';
import bgMain from '../assets/images/bgmain.jpg';
import { UniversalBarChart, UniversalLineChart, UniversalPieChart } from '../components/recharts';
// 👇 在这里引入你的工单接口(改成你真实的接口地址)
import { addWorkOrder } from '../api/workOrder';
import { useSelector } from 'react-redux';
import { getAlarmList } from '../api/alarmApi';
import { RootState } from '../store';
import { useTranslation } from 'react-i18next';
const { Text } = Typography;
export default function StationDashboard() {
const { t } = useTranslation();
// 👇 消息提示(修复缺失)
const [messageApi, contextHolder] = message.useMessage();
// 👇 获取当前选中的电站(从redux拿,修复缺失)
const { currentStation } = useSelector((state) => state.station);
const { userInfo } = useSelector((state) => state.user);
const { stationId } = useSelector((state: RootState) => state.station);
const [alarmList, setAlarmList] = useState([]);
// ========== 发电趋势卡片全屏相关 ==========
const powerTrendCardRef = useRef<HTMLDivElement>(null);
const [isPowerCardFullscreen, setIsPowerCardFullscreen] = useState(false);
const togglePowerCardFullScreen = async () => {
const el = powerTrendCardRef.current;
if (!el) return;
try {
if (!document.fullscreenElement) {
await el.requestFullscreen();
} else {
await document.exitFullscreen();
}
} catch (err) {
console.error('全屏切换异常:', err);
}
};
const handleRefreshPowerTrend = () => {
console.log('刷新发电趋势数据');
// 这里可以写重新请求接口逻辑
};
useEffect(() => {
const onFullScreenChange = () => {
setIsPowerCardFullscreen(!!document.fullscreenElement);
};
document.addEventListener('fullscreenchange', onFullScreenChange);
return () => {
document.removeEventListener('fullscreenchange', onFullScreenChange);
};
}, []);
// =========================================
// 天气数据
const [weatherdata, setWeatherData] = useState({
@@ -89,6 +58,7 @@ export default function StationDashboard() {
report_time: "2026-03-27 12:35:08"
});
const weatherType = getWeatherType(weatherdata.weather);
// 请求天气
useEffect(() => {
const fetchWeather = async () => {
@@ -101,6 +71,7 @@ export default function StationDashboard() {
};
fetchWeather();
}, []);
// 模拟数据
const stationOverview = {
todayEnergy: 4752.0,
@@ -114,22 +85,27 @@ export default function StationDashboard() {
};
// 组件内部
const navigate = useNavigate();
const deviceStatus = [
{ name: t('home.combinerBox'), count: "2/2", status: "异常 1" },
{ name: t('home.inverter'), count: "3/3", status: "异常 1" },
{ name: "电表", count: "1/1", status: t('roles.normal') },
{ name: t('home.inspectionRobot'), count: "1/1", status: t('roles.normal') }
];
const patrolRecords = [
{ name: "升压站安防巡检任务", device: "UAV-01", status: "草稿", time: "04-29T...", person: "张运维" },
{ name: "B区清洗任务", device: "CLEAN-01", status: "待执行", time: "04-29T...", person: "张运维" },
{ name: "A区巡检任务", device: "ROBOT-01", status: "已派发", time: "04-29T...", person: "张运维" }
];
const aiAnalysis = [
{ type: "AI分析", content: t('home.fixed2AiInverterFixed2TemperatureAbnormalADevice'), desc: "发现2处组件存在异常热斑" },
{ type: t('constants.critical'), content: t('home.invA02MaintenanceInvA02Repair'), desc: "3个组串存在发电异常" },
{ type: t('constants.critical'), content: t('home.a05HotspotPvA05018PvA05020StatusAbnormal'), desc: "整体发电偏差-2.8%" }
];
// 图表数据
const powerTrendData = [
{ time: '00:00', actual: 1800, predict: 1600 },
@@ -144,6 +120,7 @@ export default function StationDashboard() {
{ time: '20:00', actual: 3000, predict: 2500 },
{ time: '24:00', actual: 1800, predict: 1600 },
];
const irradianceData = [
{ time: '00:00', irradiance: 40, temperature: 14 },
{ time: '04:00', irradiance: 30, temperature: 12 },
@@ -164,13 +141,16 @@ export default function StationDashboard() {
{ device: 'INV-04', efficiency: 96.5 },
{ device: 'INV-05', efficiency: 95.8 },
];
const taskProgressData = [
{ name: t('workOrder.completed'), value: 40, color: '#1890ff' },
{ name: '进行中', value: 35, color: '#52c41a' },
{ name: '待开始', value: 20, color: '#faad14' },
{ name: t('home.abnormal'), value: 5, color: '#ff4d4f' },
];
const cardStyle = { borderRadius: 12, border: '1px solid #f0f0f0', boxShadow: '0 2px 8px rgba(0,0,0,0.04)' };
// ==============================================
// 👇 【完整完善】生成清洗工单(核心修复)
// ==============================================
@@ -185,12 +165,12 @@ export default function StationDashboard() {
try {
// 严格按照你给的接口字段传参
const params = {
id: '', // 主键ID(新增为空)
orderNo: '', // 工单编号(后端生成)
id: '', // 主键ID(新增为空)
orderNo: '', // 工单编号(后端生成)
orderTitle: '光伏组件清洗工单', // 工单标题
sourceType: 3, // 来源 3=清洗
orderType: 3, // 类型 3=清洗
priorityLevel: 2, // 优先级 2=中
sourceType: 3, // 来源 3=清洗
orderType: 3, // 类型 3=清洗
priorityLevel: 2, // 优先级 2=中
deviceId: currentStation.id || '',
deviceName: currentStation.siteName || '电站',
deviceType: 1, // 设备类型:电站
@@ -206,7 +186,7 @@ export default function StationDashboard() {
deadlineTime: '',
actualStartTime: '',
actualEndTime: '',
orderStatus: 1, // 状态 1=待处理
orderStatus: 1, // 状态 1=待处理
alarmId: '',
alarmNo: '',
taskDescription: '根据电站清洁度建议进行组件清洗,提升发电效率',
@@ -216,7 +196,9 @@ export default function StationDashboard() {
handleResult: '',
handleRemark: ''
};
const res = await addWorkOrder(params);
if (res.code === 0 || res.code === 200) {
messageApi.success(t('home.cleaningOrderGeneratedSuccessfullyFixed2'));
} else {
@@ -238,19 +220,24 @@ export default function StationDashboard() {
if (res.code === 200) {
setAlarmList(res?.rows || []);
}
} catch (err) {
messageApi.error(t('common.loadFailed'));
} finally {
}
};
useEffect(() => {
fetchList()
}, [stationId])
return (
<div style={{ background: '#f8fafc', padding: '0px', minHeight: '100vh', width: '100%', boxSizing: 'border-box' }}>
{/* 👇 必须加这个,message才能正常显示 */}
{contextHolder}
{/* 顶部统计卡片 */}
<Row gutter={[8, 8]} style={{ margin: '0 4px 0px 4px' }}>
{[
@@ -267,7 +254,7 @@ export default function StationDashboard() {
maxWidth: '240px',
minWidth: '160px'
}}>
<Card variant="borderless" style={{ ...cardStyle, height: "100%" }} styles={{ body: { padding: '12px' } }}>
<Card bordered={false} style={{ ...cardStyle, height: "100%" }} bodyStyle={{ padding: '12px' }}>
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
<div>
<div style={{ color: '#000', fontSize: '13px', fontWeight: 600, marginBottom: 4 }}>{item.title}</div>
@@ -289,46 +276,28 @@ export default function StationDashboard() {
</Col>
))}
</Row>
{/* 主体布局 */}
<Row gutter={[8, 8]}>
{/* 左侧图表 */}
<Col xs={24} xl={6}>
<Space direction="vertical" size={8} style={{ width: '100%' }}>
{/* ========== 发电趋势卡片,增加ref与全屏逻辑 ========== */}
<div ref={powerTrendCardRef} style={{ alignItems: 'center', display: "flex", justifyContent: "center" }}>
<Card
title={<span style={{ fontWeight: 800 }}>{t('home.generationTrend')}</span>}
extra={
<Space>
<SyncOutlined onClick={handleRefreshPowerTrend} style={{ cursor: 'pointer' }} />
{isPowerCardFullscreen ? (
<FullscreenExitOutlined onClick={togglePowerCardFullScreen} style={{ cursor: 'pointer' }} />
) : (
<FullscreenOutlined onClick={togglePowerCardFullScreen} style={{ cursor: 'pointer' }} />
)}
</Space>
}
variant="borderless"
style={{ ...cardStyle, width: "100%" }}
styles={{ body: { padding: '8px' } }}
>
<div style={{ fontSize: 11, color: '#666', marginBottom: 8 }}>今日发电功率趋势 (kW)</div>
<UniversalLineChart
data={powerTrendData}
xKey="time"
height={isPowerCardFullscreen ? window.innerHeight : 200}
smooth
dot
backgroundColor="transparent"
series={[
{ key: 'actual', name: t('home.actual'), color: '#165DFF', strokeWidth: 3 },
{ key: 'predict', name: t('home.predict'), color: '#00B42A', strokeWidth: 2 },
]}
/>
</Card>
</div>
<Card title={<span style={{ fontWeight: 800 }}>{t('home.irradianceTempTrend')}</span>} variant="borderless" style={cardStyle} styles={{ body: { padding: '8px' } }}>
<Card title={<span style={{ fontWeight: 800 }}>{t('home.generationTrend')}</span>} extra={<Space><SyncOutlined /><FullscreenOutlined /></Space>} bordered={false} style={cardStyle} bodyStyle={{ padding: '8px' }}>
<div style={{ fontSize: 11, color: '#666', marginBottom: 8 }}>今日发电功率趋势 (kW)</div>
<UniversalLineChart
data={powerTrendData}
xKey="time"
height={200}
smooth
dot
backgroundColor="transparent"
series={[
{ key: 'actual', name: t('home.actual'), color: '#165DFF', strokeWidth: 3 },
{ key: 'predict', name: t('home.predict'), color: '#00B42A', strokeWidth: 2 },
]}
/>
</Card>
<Card title={<span style={{ fontWeight: 800 }}>{t('home.irradianceTempTrend')}</span>} bordered={false} style={cardStyle} bodyStyle={{ padding: '8px' }}>
<UniversalLineChart
data={irradianceData}
xKey="time"
@@ -342,7 +311,7 @@ export default function StationDashboard() {
]}
/>
</Card>
<Card title={<span style={{ fontWeight: 800 }}>{t('home.inverterEfficiency')}</span>} variant="borderless" style={cardStyle} styles={{ body: { padding: '12px' } }}>
<Card title={<span style={{ fontWeight: 800 }}>{t('home.inverterEfficiency')}</span>} bordered={false} style={cardStyle} bodyStyle={{ padding: '12px' }}>
<UniversalBarChart
data={invEfficiencyData}
xKey="device"
@@ -353,7 +322,7 @@ export default function StationDashboard() {
series={[{ key: 'efficiency', name: '效率', color: '#165DFF' }]}
/>
</Card>
<Card title={<span style={{ fontWeight: 800 }}>{t('home.maintenanceProgress')}</span>} extra={<Button type="link" size="small">{t('home.fixed2MoreGt')}</Button>} variant="borderless" style={cardStyle} styles={{ body: { padding: '12px' } }}>
<Card title={<span style={{ fontWeight: 800 }}>{t('home.maintenanceProgress')}</span>} extra={<Button type="link" size="small">{t('home.fixed2MoreGt')}</Button>} bordered={false} style={cardStyle} bodyStyle={{ padding: '12px' }}>
<div style={{ display: 'flex', alignItems: 'center' }}>
<UniversalPieChart
data={taskProgressData}
@@ -373,6 +342,7 @@ export default function StationDashboard() {
</Card>
</Space>
</Col>
{/* 中间 */}
<Col xs={24} xl={12}>
<Space direction="vertical" size={8} style={{ width: '100%' }}>
@@ -388,26 +358,28 @@ export default function StationDashboard() {
</div>
</div>
}
variant="borderless"
bordered={false}
style={cardStyle}
styles={{ body: { padding: 0, position: 'relative', overflow: 'hidden', height: 500 } }}
bodyStyle={{ padding: 0, position: 'relative', overflow: 'hidden', height: 500 }}
>
<div style={{ height: "100%", background: '#111827', borderRadius: 8, width: '100%', overflow: 'hidden', position: "relative" }}>
{/*<iframe
src="https://pvs.satabot.com/?platform=web"
style={{ width: '100%', height: '100%', border: 'none', borderRadius: '8px', position: "absolute" }}
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
allowFullScreen
title={t('home.s20')}
/>*/}
<CesiumMap from="other" mapLayer={currentStation?.siteMapName} />
src="https://pvs.satabot.com/?platform=web"
style={{ width: '100%', height: '100%', border: 'none', borderRadius: '8px', position: "absolute" }}
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
allowFullScreen
title={t('home.s20')}
/>*/}
<CesiumMap from="other" />
</div>
</Card>
<Row gutter={16}>
<Col span={12}>
<Card title={<span style={{ fontWeight: 800 }}>{t('home.recentInspection')}</span>} extra={<Button type="link" size="small">{t('home.fixed2MoreGt')}</Button>} variant="borderless" style={{ ...cardStyle, height: "100%" }} styles={{ body: { padding: '0 12px' } }}>
<Card title={<span style={{ fontWeight: 800 }}>{t('home.recentInspection')}</span>} extra={<Button type="link" size="small">{t('home.fixed2MoreGt')}</Button>} bordered={false} style={{ ...cardStyle, height: "100%" }} bodyStyle={{ padding: '0 12px' }}>
<Table
rowKey="name"
dataSource={patrolRecords}
pagination={false}
size="small"
@@ -421,7 +393,7 @@ export default function StationDashboard() {
</Card>
</Col>
<Col span={12}>
<Card title={<span style={{ fontWeight: 800 }}>{t('home.aiAnalysisSummary')}</span>} variant="borderless" style={{ ...cardStyle, height: "100%" }} styles={{ body: { padding: '12px' } }}>
<Card title={<span style={{ fontWeight: 800 }}>{t('home.aiAnalysisSummary')}</span>} bordered={false} style={{ ...cardStyle, height: "100%" }} bodyStyle={{ padding: '12px' }}>
<div style={{ display: 'flex', flexDirection: 'column', gap: 16 }}>
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between' }}>
<div style={{ display: 'flex', alignItems: 'center', gap: 12 }}>
@@ -465,10 +437,11 @@ export default function StationDashboard() {
</Row>
</Space>
</Col>
{/* 右侧 */}
<Col xs={24} xl={6}>
<Space direction="vertical" size={8} style={{ width: '100%' }}>
<Card title={<span style={{ fontWeight: 800 }}>{t('alerts.realtimeAlert')}</span>} extra={<Button type="link" size="small" onClick={() => navigate('/alerts/all')}>{t('home.fixed2MoreGt')}</Button>} variant="borderless" style={cardStyle} styles={{ body: { padding: '12px' } }}>
<Card title={<span style={{ fontWeight: 800 }}>{t('alerts.realtimeAlert')}</span>} extra={<Button type="link" size="small" onClick={() => navigate('/alerts/all')}>{t('home.fixed2MoreGt')}</Button>} bordered={false} style={cardStyle} bodyStyle={{ padding: '12px' }}>
<div style={{ display: 'flex', justifyContent: 'space-between', marginBottom: 12, padding: '0 4px 8px', borderBottom: '1px solid #f0f0f0', fontSize: 13, color: '#666' }}>
<span style={{ flex: 3 }}>{t('alerts.alarmContent')}</span>
<span style={{ flex: 1, textAlign: 'center' }}>{t('alerts.level')}</span>
@@ -492,13 +465,13 @@ export default function StationDashboard() {
})}
</Card>
<Card title={<span style={{ fontWeight: 800 }}>{t('home.deviceOnlineStatus')}</span>} extra={<Button type="link" size="small">{t('home.fixed2MoreGt')}</Button>} variant="borderless" style={cardStyle} styles={{ body: { padding: '12px' } }}>
<Card title={<span style={{ fontWeight: 800 }}>{t('home.deviceOnlineStatus')}</span>} extra={<Button type="link" size="small">{t('home.fixed2MoreGt')}</Button>} bordered={false} style={cardStyle} bodyStyle={{ padding: '12px' }}>
<Row gutter={[16, 16]}>
{[
{ name: t('home.solarPanel'), count: '320/320', icon: <AppstoreOutlined /> },
{ name: t('home.inverter'), count: '5/5', icon: <ThunderboltOutlined /> },
{ name: t('home.combinerBox'), count: '20/20', icon: <BranchesOutlined /> },
{ name: t('home.weatherStation'), count: '1/1', icon: <CloudOutlined /> },
{ name: t('home.WeatherStation'), count: '1/1', icon: <CloudOutlined /> },
{ name: t('devices.camera'), count: '12/12', icon: <VideoCameraOutlined /> },
{ name: t('home.environmentalSensor'), count: '8/8', icon: <ExperimentOutlined /> },
{ name: t('constants.uav'), count: '1/1', icon: <RocketOutlined /> },
@@ -517,7 +490,7 @@ export default function StationDashboard() {
</Row>
</Card>
<Card title={<span style={{ fontWeight: 800 }}>{t('home.weatherInfo')}</span>} extra={<Button type="link" size="small">{t('home.gt')}</Button>} variant="borderless" style={cardStyle} styles={{ body: { padding: '12px' } }}>
<Card title={<span style={{ fontWeight: 800 }}>{t('home.weatherInfo')}</span>} extra={<Button type="link" size="small">{t('home.gt')}</Button>} bordered={false} style={cardStyle} bodyStyle={{ padding: '12px' }}>
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'start', gap: 20 }}>
<div style={{ display: 'flex', alignItems: 'center', gap: 12 }}>
<WeatherDisplay type={weatherType} />
@@ -533,10 +506,11 @@ export default function StationDashboard() {
</div>
</div>
</Card>
{/* ====================================== */}
{/* 👇 清洗建议 + 生成工单按钮(已完善) */}
{/* ====================================== */}
<Card title={<span style={{ fontWeight: 800 }}>{t('clean.cleaningSuggestion')}</span>} extra={<Button type="link" size="small">{t('home.fixed2MoreGt')}</Button>} variant="borderless" style={cardStyle} styles={{ body: { padding: '12px' } }}>
<Card title={<span style={{ fontWeight: 800 }}>{t('clean.cleaningSuggestion')}</span>} extra={<Button type="link" size="small">{t('home.fixed2MoreGt')}</Button>} bordered={false} style={cardStyle} bodyStyle={{ padding: '12px' }}>
<div style={{ display: 'flex', alignItems: 'center', gap: 16, marginBottom: 16 }}>
<div style={{ width: 80, height: 80, position: 'relative' }}>
<UniversalPieChart

View File

@@ -146,7 +146,7 @@ const Profile: React.FC = () => {
{/* 左侧信息卡片 */}
<Col xs={24} sm={24} md={8} lg={7} xl={6}>
<Card
variant="borderless"
bordered={false}
style={{
borderRadius: 12,
boxShadow: '0 2px 12px rgba(0,0,0,0.06)',
@@ -220,7 +220,7 @@ const Profile: React.FC = () => {
{/* 右侧表单卡片 */}
<Col xs={24} sm={24} md={16} lg={17} xl={18}>
<Card
variant="borderless"
bordered={false}
style={{
borderRadius: 12,
boxShadow: '0 2px 12px rgba(0,0,0,0.06)',

View File

@@ -1,4 +1,4 @@
import React, { useState } from 'react';
import React, { useState } from 'react';
import {
Card, Row, Col, Table, Select, Input, Tag,
Typography, Button, Space, Avatar, Pagination
@@ -17,7 +17,6 @@ import bgMain from '../assets/images/bgmain.jpg';
import { UniversalBarChart, UniversalLineChart, UniversalPieChart } from '../components/recharts';
import CesiumMap from '../components/Map';
import { useTranslation } from 'react-i18next';
import { useSelector } from 'react-redux';
const { Option } = Select;
const { Search } = Input;
@@ -48,7 +47,6 @@ const heatmapColors = ['#52c41a', '#1890ff', '#faad14', '#1890ff', '#52c41a'];
const RealTimeMonitorPage = () => {
const { t } = useTranslation();
const { currentStation } = useSelector((state: any) => state.station);
const [filterStatus, setFilterStatus] = useState('all');
const [filterType, setFilterType] = useState(undefined);
const [searchName, setSearchName] = useState('');
@@ -123,9 +121,9 @@ const RealTimeMonitorPage = () => {
<span style={{ display: 'flex', alignItems: 'center' }}><span style={{ color: '#1890ff', marginLeft: 4 }}>{t('page.s2')}</span></span>
</div>
}
variant="borderless"
bordered={false}
style={{ ...cardStyle, borderRadius: 8 }}
styles={{ body: { padding: 0, position: 'relative', height: 400, overflow: 'hidden' } }}
bodyStyle={{ padding: 0, position: 'relative', height: 400, overflow: 'hidden' }}
>
<div style={{ height: "100%", background: '#111827', borderRadius: 8, width: '100%', overflow: 'hidden', position: "relative" }}>
{/*<iframe
@@ -143,7 +141,7 @@ const RealTimeMonitorPage = () => {
/>*/}
<CesiumMap from="other" mapLayer={currentStation?.siteMapName} />
<CesiumMap from="other" />
</div>
</Card>
@@ -151,7 +149,7 @@ const RealTimeMonitorPage = () => {
{/* 设备实时监控列表 */}
<Card
title={<span style={{ fontWeight: 800, fontSize: 13 }}>{t('page.fixed2DeviceFixed2RealtimeMonitorListFixed2')}</span>}
variant="borderless"
bordered={false}
style={{ ...cardStyle, borderRadius: 8 }}
extra={
<Space size={8}>
@@ -175,7 +173,7 @@ const RealTimeMonitorPage = () => {
/>
<div style={{ display: 'flex', justifyContent: 'space-between', marginTop: 12, alignItems: 'center' }}>
<span style={{ color: '#999', fontSize: 11 }}>{t('page.56')}</span>
<Pagination size="small" total={56} defaultCurrent={1} defaultPageSize={10} showSizeChanger />
<Pagination size="small" total={56} current={1} pageSize={10} showSizeChanger />
</div>
</Card>
</Space>
@@ -195,7 +193,7 @@ const RealTimeMonitorPage = () => {
{ title: t('home.ambientTemperature'), value: '28.0', unit: '℃', sub: '较昨日 +1.2 ℃', color: '#165DFF', icon: <CloudOutlined /> },
].map((item, idx) => (
<Col span={8} key={idx}>
<Card variant="borderless" style={{ ...cardStyle, height: '100%', borderRadius: 8 }} styles={{ body: { padding: '8px' } }}>
<Card bordered={false} style={{ ...cardStyle, height: '100%', borderRadius: 8 }} bodyStyle={{ padding: '8px' }}>
<div style={{ display: 'flex', alignItems: 'flex-start', gap: 6 }}>
<div style={{ color: item.color, fontSize: 18 }}>{item.icon}</div>
<div style={{ flex: 1, minWidth: 0 }}>
@@ -213,7 +211,7 @@ const RealTimeMonitorPage = () => {
</Row>
{/* 实时功率曲线 */}
<Card title={<span style={{ fontWeight: 800 }}>{t('page.powerCurveFixed2')}</span>} extra={<Select defaultValue="today" size="small"><Option value="today">{t('page.s11')}</Option></Select>} variant="borderless" style={cardStyle} styles={{ body: { padding: '12px' } }}>
<Card title={<span style={{ fontWeight: 800 }}>{t('page.powerCurveFixed2')}</span>} extra={<Select defaultValue="today" size="small"><Option value="today">{t('page.s11')}</Option></Select>} bordered={false} style={cardStyle} bodyStyle={{ padding: '12px' }}>
<UniversalLineChart
height={180}
data={powerTrendData}
@@ -234,7 +232,7 @@ const RealTimeMonitorPage = () => {
</Card>
{/* 逆变器功率对比 */}
<Card title={<span style={{ fontWeight: 800 }}>{t('page.inverterPowerCompare')}</span>} variant="borderless" style={cardStyle} styles={{ body: { padding: '12px' } }}>
<Card title={<span style={{ fontWeight: 800 }}>{t('page.inverterPowerCompare')}</span>} bordered={false} style={cardStyle} bodyStyle={{ padding: '12px' }}>
<UniversalBarChart
height={180}
data={inverterPowerData}
@@ -255,7 +253,7 @@ const RealTimeMonitorPage = () => {
{/* 热力图与在线率 */}
<Row gutter={8}>
<Col span={12}>
<Card title={<span style={{ fontWeight: 800 }}>{t('page.stringCurrentHeatmap')}</span>} extra={<Select defaultValue="a" size="small" style={{ width: 60 }}><Option value="a">{t('page.s12')}</Option></Select>} variant="borderless" style={cardStyle} styles={{ body: { padding: '12px' } }}>
<Card title={<span style={{ fontWeight: 800 }}>{t('page.stringCurrentHeatmap')}</span>} extra={<Select defaultValue="a" size="small" style={{ width: 60 }}><Option value="a">{t('page.s12')}</Option></Select>} bordered={false} style={cardStyle} bodyStyle={{ padding: '12px' }}>
<div style={{ display: 'flex', flexDirection: 'column', gap: 4 }}>
{['INV-01', 'INV-02', 'INV-03', 'INV-04', 'INV-05'].map((name, i) => (
<div key={i} style={{ display: 'flex', alignItems: 'center', gap: 4 }}>
@@ -294,7 +292,7 @@ const RealTimeMonitorPage = () => {
</Card>
</Col>
<Col span={12}>
<Card title={<span style={{ fontWeight: 800 }}>{t('devices.deviceOnlineRate')}</span>} variant="borderless" style={{ ...cardStyle, height: "100%" }} styles={{ body: { padding: '12px' } }}>
<Card title={<span style={{ fontWeight: 800 }}>{t('devices.deviceOnlineRate')}</span>} bordered={false} style={{ ...cardStyle, height: "100%" }} bodyStyle={{ padding: '12px' }}>
<div style={{ position: 'relative', height: 160 }}>
<UniversalPieChart
height={160}

View File

@@ -20,6 +20,7 @@ import dayjs from 'dayjs';
import { ChevronRight } from 'lucide-react';
import { UniversalBarChart, UniversalLineChart, UniversalPieChart } from '../components/recharts';
import { useTranslation } from 'react-i18next';
import MachineDataReport from '../components/reports/MachineDataReport';
const { TabPane } = Tabs;
const { RangePicker } = DatePicker;
@@ -207,405 +208,409 @@ export default function ReportCenterPage() {
<TabPane tab={t('report.generationReport')} key="power" />
<TabPane tab={t('report.operationReport')} key="operation" />
<TabPane tab={t('report.alertReport')} key="alarm" />
<TabPane tab={t('report.aiAnalysisReport')} key="ai" />
<TabPane tab={t('report.machineAnalysisReport')} key="ai" />
</Tabs>
</div>
<Row
gutter={[12, 12]}
style={{
marginBottom: 8,
flexWrap: 'wrap',
}}
>
{overviewCards.map((card, idx) => (
<Col key={idx} style={{ minWidth: '180px', flex: '1 0 auto', }}>
<Card
variant="borderless"
styles={{ body: { padding: '20px 20px', display: 'flex', alignItems: 'center', justifyContent: 'space-between' } }}
style={{ borderRadius: 8, boxShadow: '0 2px 8px rgba(0,0,0,0.06)' }}
>
{/* 左侧文字区域 */}
<div style={{ flex: 1, display: 'flex', flexDirection: 'column', alignItems: 'flex-start' }}>
<div style={{ fontSize: 14, color: '#86909C', marginBottom: 8, fontWeight: 500 }}>
{card.title}
</div>
<div style={{ fontSize: 28, fontWeight: 700, color: card.color, lineHeight: 1, marginBottom: 8 }}>
{card.value}
<span style={{ fontSize: 14, fontWeight: 500, marginLeft: 2, color: '#1D2129' }}>{card.unit}</span>
</div>
{/* 底部环比/备注 */}
<div style={{ fontSize: 12, color: '#86909C', fontWeight: 500 }}>
{card.trend}
</div>
</div>
{/* 右侧圆形图标区域 */}
<div
style={{
width: 48,
height: 48,
borderRadius: '50%',
backgroundColor: card.iconBg || '#f0f7ff',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
flexShrink: 0,
marginLeft: 8
}}
>
{card.icon}
</div>
</Card>
</Col>
))}
</Row>
{/* 筛选栏 */}
<div style={{ display: 'flex', alignItems: 'center', marginBottom: 8, gap: 20, flexWrap: 'wrap' }}>
<div style={{ display: 'flex', alignItems: 'center' }}>
<span className="filter-label">{t('report.reportCycle')}:</span>
<Select value={reportCycle} onChange={setReportCycle} style={{ width: 100 }} size="small">
<Option value="day">{t('report.daily')}</Option>
<Option value="week">{t('report.weekly')}</Option>
<Option value="month">{t('report.monthly')}</Option>
</Select>
</div>
<div style={{ display: 'flex', alignItems: 'center' }}>
<span className="filter-label">{t('report.reportType')}:</span>
<Select value={reportType} onChange={setReportType} style={{ width: 120 }} size="small">
<Option value="all">{t('common.all')}</Option>
<Option value="power">{t('report.generationReport')}</Option>
<Option value="operation">{t('report.operationReport')}</Option>
<Option value="alarm">{t('report.alertReport')}</Option>
<Option value="ai">{t('report.aiAnalysisReport')}</Option>
</Select>
</div>
<div style={{ display: 'flex', alignItems: 'center' }}>
<span className="filter-label">{t('report.dateRange')}:</span>
<RangePicker
value={dateRange}
onChange={setDateRange}
style={{ width: 260 }}
size="small"
/>
</div>
<div style={{ marginLeft: 'auto' }}>
<Space size={12}>
<Button type="primary" icon={<FileTextOutlined />} size="small" style={{ borderRadius: 6, height: 32, padding: '0 16px' }}>{t('report.generateReport')}</Button>
<Button icon={<FilePdfOutlined />} size="small" style={{ borderRadius: 6, height: 32, color: '#F53F3F', borderColor: '#F53F3F' }}>{t('report.exportPdf')}</Button>
<Button icon={<FileExcelOutlined />} size="small" style={{ borderRadius: 6, height: 32, color: '#00B42A', borderColor: '#00B42A' }}>{t('report.exportExcel')}</Button>
</Space>
</div>
</div>
<Row gutter={[8, 8]}>
{/* 左侧主内容区 */}
<Col xs={24} xl={16} >
{/* 月度综合经营分析 */}
<Card variant="borderless" style={cardStyle} styles={{ body: { padding: '20px' } }} title={<span style={{ fontSize: 15, fontWeight: 700, color: '#1D2129' }}>{t('report.monthlyOperationAnalysis')}</span>}>
<Row gutter={24}>
<Col span={17}>
<div style={{ fontSize: 11, color: '#86909C', marginBottom: 16, display: 'flex', justifyContent: 'flex-start', gap: 20 }}>
<Space size={4}><div style={{ width: 10, height: 3, background: '#00B42A' }}></div>{t('report.generation')} (MWh)</Space>
<Space size={4}><div style={{ width: 10, height: 1, borderTop: '1.5px dashed #165DFF' }}></div>{t('report.predictedGeneration')} (MWh)</Space>
<Space size={4}><div style={{ width: 10, height: 1, borderTop: '1.5px solid #FF7D00' }}></div>PR (%)</Space>
</div>
<UniversalLineChart
data={monthlyPowerData}
xKey="date"
height={260}
series={[
{
key: 'generation',
name: t('report.generation') + '(MWh)',
color: '#52c41a',
},
{
key: 'predicted',
name: t('report.predictedGeneration') + '(MWh)',
color: '#1890ff',
dashed: true,
},
{
key: 'pr',
name: 'PR(%)',
color: '#fa8c16',
strokeWidth: 2,
},
]}
/>
</Col>
<Col span={7}>
<div style={{ background: '#f8fafc', padding: '16px', borderRadius: 12, height: '100%' }}>
<div style={{ display: 'flex', flexDirection: 'column', gap: 12 }}>
{[
{ label: t('report.monthlyAccumulatedGeneration'), value: '138.6', unit: 'MWh' },
{ label: t('report.theoreticalGeneration'), value: '166.8', unit: 'MWh' },
{ label: t('report.prAverage'), value: '82.8', unit: '%' },
{ label: t('report.generationDeviation'), value: '-3.4', unit: '%', color: '#F53F3F' },
{ label: t('report.averageIrradiance'), value: '5.3', unit: t('report.unitIrradiancePerDay') },
].map((item, idx) => (
<div key={idx} style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
<span style={{ fontSize: 12, color: '#4E5969' }}>{item.label}</span>
<span style={{ fontSize: 14, fontWeight: 700, color: item.color || '#1D2129' }}>{item.value} <span style={{ fontSize: 10, fontWeight: 400, color: '#86909C' }}>{item.unit}</span></span>
</div>
))}
{activeTab === 'ai' ? (
<MachineDataReport />
) : (
<>
<Row
gutter={[12, 12]}
style={{
marginBottom: 8,
flexWrap: 'wrap',
}}
>
{overviewCards.map((card, idx) => (
<Col key={idx} style={{ minWidth: '180px', flex: '1 0 auto', }}>
<Card
bordered={false}
bodyStyle={{ padding: '20px 20px', display: 'flex', alignItems: 'center', justifyContent: 'space-between' }}
style={{ borderRadius: 8, boxShadow: '0 2px 8px rgba(0,0,0,0.06)' }}
>
{/* 左侧文字区域 */}
<div style={{ flex: 1, display: 'flex', flexDirection: 'column', alignItems: 'flex-start' }}>
<div style={{ fontSize: 14, color: '#86909C', marginBottom: 8, fontWeight: 500 }}>
{card.title}
</div>
<div style={{ fontSize: 28, fontWeight: 700, color: card.color, lineHeight: 1, marginBottom: 8 }}>
{card.value}
<span style={{ fontSize: 14, fontWeight: 500, marginLeft: 2, color: '#1D2129' }}>{card.unit}</span>
</div>
{/* 底部环比/备注 */}
<div style={{ fontSize: 12, color: '#86909C', fontWeight: 500 }}>
{card.trend}
</div>
</div>
</div>
{/* 右侧圆形图标区域 */}
<div
style={{
width: 48,
height: 48,
borderRadius: '50%',
backgroundColor: card.iconBg || '#f0f7ff',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
flexShrink: 0,
marginLeft: 8
}}
>
{card.icon}
</div>
</Card>
</Col>
</Row>
</Card>
))}
</Row>
{/* 第二排:三个图表 */}
<Row gutter={[8, 8]} style={{ marginTop: 8 }}>
<Col span={8}>
<Card
variant="borderless"
style={{ ...cardStyle, height: "100%" }}
styles={{ body: { padding: '16px' } }}
title={<span style={{ fontSize: 14, fontWeight: 700 }}>{t('report.generationMeteorology')}</span>}
>
<div style={{ fontSize: 10, color: '#86909C', marginBottom: 12 }}>
<Space size={8} wrap>
<Badge color="#165DFF" text={`${t('report.generation')} (MWh)`} style={{ fontSize: 10 }} />
<Badge color="#00B42A" text={`${t('home.irradiance')} (kWh/㎡)`} style={{ fontSize: 10 }} />
<Badge color="#FF7D00" text={`${t('home.temperature')} (℃)`} style={{ fontSize: 10 }} />
</Space>
</div>
<UniversalBarChart
data={powerMeteorologyData}
xKey="date"
height={200}
series={[
{ key: 'generation', name: t('report.generation'), color: '#1890ff' },
{ key: 'irradiance', name: t('home.irradiance'), color: '#52c41a' },
{ key: 'temp', name: t('home.temperature'), color: '#fa8c16' },
]}
/>
{/* 筛选栏 */}
<div style={{ display: 'flex', alignItems: 'center', marginBottom: 8, gap: 20, flexWrap: 'wrap' }}>
<div style={{ display: 'flex', alignItems: 'center' }}>
<span className="filter-label">{t('report.reportCycle')}:</span>
<Select value={reportCycle} onChange={setReportCycle} style={{ width: 100 }} size="small">
<Option value="day">{t('report.daily')}</Option>
<Option value="week">{t('report.weekly')}</Option>
<Option value="month">{t('report.monthly')}</Option>
</Select>
</div>
<div style={{ display: 'flex', alignItems: 'center' }}>
<span className="filter-label">{t('report.reportType')}:</span>
<Select value={reportType} onChange={setReportType} style={{ width: 120 }} size="small">
<Option value="all">{t('common.all')}</Option>
<Option value="power">{t('report.generationReport')}</Option>
<Option value="operation">{t('report.operationReport')}</Option>
<Option value="alarm">{t('report.alertReport')}</Option>
<Option value="ai">{t('report.machineAnalysisReport')}</Option>
</Select>
</div>
<div style={{ display: 'flex', alignItems: 'center' }}>
<span className="filter-label">{t('report.dateRange')}:</span>
<RangePicker
value={dateRange}
onChange={setDateRange}
style={{ width: 260 }}
size="small"
/>
</div>
<div style={{ marginLeft: 'auto' }}>
<Space size={12}>
<Button type="primary" icon={<FileTextOutlined />} size="small" style={{ borderRadius: 6, height: 32, padding: '0 16px' }}>{t('report.generateReport')}</Button>
<Button icon={<FilePdfOutlined />} size="small" style={{ borderRadius: 6, height: 32, color: '#F53F3F', borderColor: '#F53F3F' }}>{t('report.exportPdf')}</Button>
<Button icon={<FileExcelOutlined />} size="small" style={{ borderRadius: 6, height: 32, color: '#00B42A', borderColor: '#00B42A' }}>{t('report.exportExcel')}</Button>
</Space>
</div>
</div>
<Row gutter={[8, 8]}>
{/* 左侧主内容区 */}
<Col xs={24} xl={16} >
{/* 月度综合经营分析 */}
<Card bordered={false} style={cardStyle} bodyStyle={{ padding: '20px' }} title={<span style={{ fontSize: 15, fontWeight: 700, color: '#1D2129' }}>{t('report.monthlyOperationAnalysis')}</span>}>
<Row gutter={24}>
<Col span={17}>
<div style={{ fontSize: 11, color: '#86909C', marginBottom: 16, display: 'flex', justifyContent: 'flex-start', gap: 20 }}>
<Space size={4}><div style={{ width: 10, height: 3, background: '#00B42A' }}></div>{t('report.generation')} (MWh)</Space>
<Space size={4}><div style={{ width: 10, height: 1, borderTop: '1.5px dashed #165DFF' }}></div>{t('report.predictedGeneration')} (MWh)</Space>
<Space size={4}><div style={{ width: 10, height: 1, borderTop: '1.5px solid #FF7D00' }}></div>PR (%)</Space>
</div>
<UniversalLineChart
data={monthlyPowerData}
xKey="date"
height={260}
series={[
{
key: 'generation',
name: t('report.generation') + '(MWh)',
color: '#52c41a',
},
{
key: 'predicted',
name: t('report.predictedGeneration') + '(MWh)',
color: '#1890ff',
dashed: true,
},
{
key: 'pr',
name: 'PR(%)',
color: '#fa8c16',
strokeWidth: 2,
},
]}
/>
</Col>
<Col span={7}>
<div style={{ background: '#f8fafc', padding: '16px', borderRadius: 12, height: '100%' }}>
<div style={{ display: 'flex', flexDirection: 'column', gap: 12 }}>
{[
{ label: t('report.monthlyAccumulatedGeneration'), value: '138.6', unit: 'MWh' },
{ label: t('report.theoreticalGeneration'), value: '166.8', unit: 'MWh' },
{ label: t('report.prAverage'), value: '82.8', unit: '%' },
{ label: t('report.generationDeviation'), value: '-3.4', unit: '%', color: '#F53F3F' },
{ label: t('report.averageIrradiance'), value: '5.3', unit: t('report.unitIrradiancePerDay') },
].map((item, idx) => (
<div key={idx} style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
<span style={{ fontSize: 12, color: '#4E5969' }}>{item.label}</span>
<span style={{ fontSize: 14, fontWeight: 700, color: item.color || '#1D2129' }}>{item.value} <span style={{ fontSize: 10, fontWeight: 400, color: '#86909C' }}>{item.unit}</span></span>
</div>
))}
</div>
</div>
</Col>
</Row>
</Card>
</Col>
<Col span={8}>
<Card
variant="borderless"
style={{ ...cardStyle, height: "100%" }}
styles={{ body: { padding: '16px' } }}
title={<span style={{ fontSize: 14, fontWeight: 700 }}>{t('report.workOrderAlertClosure')}</span>}
>
<div style={{ fontSize: 10, color: '#86909C', marginBottom: 12 }}>
<Space size={8} wrap>
<Badge color="#165DFF" text={t('workOrder.newOrders')} style={{ fontSize: 10 }} />
<Badge color="#00B42A" text={t('workOrder.completeOrder')} style={{ fontSize: 10 }} />
<Badge color="#722ED1" text={`${t('report.closureRate')} (%)`} style={{ fontSize: 10 }} />
</Space>
</div>
<UniversalBarChart
data={orderAlarmData}
xKey="date"
height={200}
series={[
{ key: 'newOrder', name: t('workOrder.newOrders'), color: '#1890ff' },
{ key: 'completed', name: t('workOrder.completeOrder'), color: '#52c41a' },
{ key: 'alarmCount', name: t('report.alarmCount'), color: '#fa8c16' },
{ key: 'closedRate', name: t('report.closureRate'), color: '#722ed1' },
]}
/>
</Card>
</Col>
{/* 第二排:三个图表 */}
<Row gutter={[8, 8]} style={{ marginTop: 8 }}>
<Col span={8}>
<Card
bordered={false}
style={{ ...cardStyle, height: "100%" }}
bodyStyle={{ padding: '16px' }}
title={<span style={{ fontSize: 14, fontWeight: 700 }}>{t('report.generationMeteorology')}</span>}
>
<div style={{ fontSize: 10, color: '#86909C', marginBottom: 12 }}>
<Space size={8} wrap>
<Badge color="#165DFF" text={`${t('report.generation')} (MWh)`} style={{ fontSize: 10 }} />
<Badge color="#00B42A" text={`${t('home.irradiance')} (kWh/㎡)`} style={{ fontSize: 10 }} />
<Badge color="#FF7D00" text={`${t('home.temperature')} (℃)`} style={{ fontSize: 10 }} />
</Space>
</div>
<UniversalBarChart
data={powerMeteorologyData}
xKey="date"
height={200}
series={[
{ key: 'generation', name: t('report.generation'), color: '#1890ff' },
{ key: 'irradiance', name: t('home.irradiance'), color: '#52c41a' },
{ key: 'temp', name: t('home.temperature'), color: '#fa8c16' },
]}
/>
</Card>
</Col>
<Col span={8}>
<Card
variant="borderless"
style={{ ...cardStyle, height: "100%" }}
styles={{ body: { padding: '16px' } }}
title={<span style={{ fontSize: 14, fontWeight: 700 }}>{t('report.aiAnalysisStatistics')}</span>}
>
<div style={{ width: '100%', boxSizing: 'border-box' }}>
<UniversalPieChart
data={aiPieData}
width={220}
height={220}
innerRadius={40}
outerRadius={65}
style={{ padding: 0 }}
/>
<Col span={8}>
<Card
bordered={false}
style={{ ...cardStyle, height: "100%" }}
bodyStyle={{ padding: '16px' }}
title={<span style={{ fontSize: 14, fontWeight: 700 }}>{t('report.workOrderAlertClosure')}</span>}
>
<div style={{ fontSize: 10, color: '#86909C', marginBottom: 12 }}>
<Space size={8} wrap>
<Badge color="#165DFF" text={t('workOrder.newOrders')} style={{ fontSize: 10 }} />
<Badge color="#00B42A" text={t('workOrder.completeOrder')} style={{ fontSize: 10 }} />
<Badge color="#722ED1" text={`${t('report.closureRate')} (%)`} style={{ fontSize: 10 }} />
</Space>
</div>
<UniversalBarChart
data={orderAlarmData}
xKey="date"
height={200}
series={[
{ key: 'newOrder', name: t('workOrder.newOrders'), color: '#1890ff' },
{ key: 'completed', name: t('workOrder.completeOrder'), color: '#52c41a' },
{ key: 'alarmCount', name: t('report.alarmCount'), color: '#fa8c16' },
{ key: 'closedRate', name: t('report.closureRate'), color: '#722ed1' },
]}
/>
</Card>
</Col>
<div style={{
display: 'flex',
flexDirection: 'column',
gap: 10,
paddingLeft: 8,
width: '100%',
boxSizing: 'border-box'
}}>
{aiAnalysisData.map((item, idx) => (
<div key={idx} style={{
<Col span={8}>
<Card
bordered={false}
style={{ ...cardStyle, height: "100%" }}
bodyStyle={{ padding: '16px' }}
title={<span style={{ fontSize: 14, fontWeight: 700 }}>{t('report.aiAnalysisStatistics')}</span>}
>
<div style={{ width: '100%', boxSizing: 'border-box' }}>
<UniversalPieChart
data={aiPieData}
width={220}
height={220}
innerRadius={40}
outerRadius={65}
style={{ padding: 0 }}
/>
<div style={{
display: 'flex',
justifyContent: 'space-between',
alignItems: 'center',
flexDirection: 'column',
gap: 10,
paddingLeft: 8,
width: '100%',
flexWrap: 'wrap',
wordBreak: 'break-all',
whiteSpace: 'normal'
boxSizing: 'border-box'
}}>
<Space size={6} style={{
fontSize: 11,
color: '#4E5969',
flex: 1,
minWidth: '60%',
display: 'flex',
alignItems: 'center',
flexWrap: 'wrap'
}}>
<div style={{ width: 6, height: 6, borderRadius: '50%', background: item.color, flexShrink: 0 }}></div>
<span style={{ wordBreak: 'break-all', whiteSpace: 'normal' }}>{item.type}</span>
</Space>
<span style={{
fontSize: 12,
fontWeight: 700,
whiteSpace: 'nowrap',
flexShrink: 0
}}>
{item.value} <Text type="secondary" style={{ fontSize: 10, fontWeight: 400 }}>{t('report.unitItem')}</Text>
</span>
{aiAnalysisData.map((item, idx) => (
<div key={idx} style={{
display: 'flex',
justifyContent: 'space-between',
alignItems: 'center',
width: '100%',
flexWrap: 'wrap',
wordBreak: 'break-all',
whiteSpace: 'normal'
}}>
<Space size={6} style={{
fontSize: 11,
color: '#4E5969',
flex: 1,
minWidth: '60%',
display: 'flex',
alignItems: 'center',
flexWrap: 'wrap'
}}>
<div style={{ width: 6, height: 6, borderRadius: '50%', background: item.color, flexShrink: 0 }}></div>
<span style={{ wordBreak: 'break-all', whiteSpace: 'normal' }}>{item.type}</span>
</Space>
<span style={{
fontSize: 12,
fontWeight: 700,
whiteSpace: 'nowrap',
flexShrink: 0
}}>
{item.value} <Text type="secondary" style={{ fontSize: 10, fontWeight: 400 }}>{t('report.unitItem')}</Text>
</span>
</div>
))}
</div>
))}
</div>
</div>
</div>
</Card>
</Col>
</Row>
{/* 订阅与分发 */}
<Card bordered={false} style={{ ...cardStyle, marginTop: 8 }} bodyStyle={{ padding: '20px' }} title={<span style={{ fontSize: 15, fontWeight: 700, color: '#1D2129' }}>{t('report.subscriptionDispatch')}</span>}>
<Row gutter={[16, 16]} wrap>
<Col xs={24} sm={12} md={8}>
<div style={{ fontSize: 12, color: '#86909C', marginBottom: 12 }}>{t('report.subscribers', { count: 6 })}</div>
<div style={{ display: 'flex', alignItems: 'center', gap: 8, flexWrap: 'wrap' }}>
{[
{ name: '张运维', role: t('report.roleOmSupervisor'), img: 'https://img.icons8.com/fluency/48/user-male-circle.png' },
{ name: '李工程师', role: t('report.roleStationEngineer'), img: 'https://img.icons8.com/fluency/48/user-male-circle.png' },
{ name: '王运维', role: t('report.roleDeviceOm'), img: 'https://img.icons8.com/fluency/48/user-male-circle.png' },
{ name: '陈经理', role: t('report.roleOmManager'), img: 'https://img.icons8.com/fluency/48/user-male-circle.png' },
].map((p, idx) => (
<Tooltip title={`${p.name} - ${p.role}`} key={idx}>
<Avatar src={p.img} size={32} style={{ border: '2px solid #fff' }} />
</Tooltip>
))}
<Avatar size={32} style={{ background: '#F2F3F5', color: '#165DFF', fontSize: 12, fontWeight: 700, border: '2px solid #fff' }}>+2</Avatar>
</div>
</Col>
<Col xs={24} sm={12} md={8}>
<div style={{ fontSize: 12, color: '#86909C', marginBottom: 12 }}>{t('report.dispatchChannels')}</div>
<Space size={12} wrap>
<Button size="small" icon={<MailOutlined />} style={{ borderRadius: 6, background: '#E8F3FF', border: 'none', color: '#165DFF' }}>{t('report.email')} <CheckCircleFilled style={{ fontSize: 10, marginLeft: 4 }} /></Button>
<Button size="small" style={{ borderRadius: 6, background: '#E8F3FF', border: 'none', color: '#165DFF' }}>Telegram <CheckCircleFilled style={{ fontSize: 10, marginLeft: 4 }} /></Button>
<Button size="small" icon={<BellOutlined />} style={{ borderRadius: 6, background: '#E8F3FF', border: 'none', color: '#165DFF' }}>{t('report.systemNotification')} <CheckCircleFilled style={{ fontSize: 10, marginLeft: 4 }} /></Button>
</Space>
</Col>
<Col xs={24} sm={24} md={8}>
<div style={{ fontSize: 12, color: '#86909C', marginBottom: 12 }}>{t('report.sendPlan')}</div>
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', background: '#f8fafc', padding: '8px 12px', borderRadius: 8, gap: 8 }}>
<Space size={8} wrap>
<CalendarOutlined style={{ color: '#165DFF' }} />
<span style={{ fontSize: 13, fontWeight: 700 }}>{t('report.weeklyAutoSend')}</span>
</Space>
<Button type="link" size="small" icon={<EditOutlined />} style={{ fontSize: 12, whiteSpace: 'nowrap' }}>{t('roles.edit')}</Button>
</div>
</Col>
</Row>
</Card>
</Col>
{/* 右侧边栏 */}
<Col xs={24} xl={8}>
{/* 报表目录 / 快捷下载 */}
<Card bordered={false} style={cardStyle} bodyStyle={{ padding: 0 }} title={<span style={{ fontSize: 15, fontWeight: 700 }}>{t('report.reportDirectory')}</span>} extra={<Button type="link" size="small">{t('common.more')} <ChevronRight size={14} /></Button>}>
<Table
rowKey="name"
columns={[
{
title: t('report.reportName'), dataIndex: 'name',
render: (text) => <Space size={8}><FilePdfOutlined style={{ color: '#F53F3F' }} />{text}</Space>
},
{
title: t('roles.status'), dataIndex: 'status', width: 80,
render: (v) => <Tag color={v === t('report.generated') ? 'success' : 'warning'} style={{ borderRadius: 4, fontSize: 10, margin: 0 }}>{v}</Tag>
},
{
title: t('roles.actions'), width: 120,
render: () => (
<Space split={<Divider type="vertical" />}>
<Button type="link" size="small" icon={<EyeOutlined />} style={{ fontSize: 12, padding: 0 }}>{t('common.view')}</Button>
<Button type="link" size="small" icon={<DownloadOutlined />} style={{ fontSize: 12, padding: 0 }}>{t('common.download')}</Button>
</Space>
)
}
]}
dataSource={reportFileList}
pagination={false}
size="small"
className="compact-table"
/>
</Card>
{/* 模板中心 */}
<Card bordered={false} style={{ ...cardStyle, marginTop: 8 }} bodyStyle={{ padding: '16px' }} title={<span style={{ fontSize: 15, fontWeight: 700 }}>{t('report.templateCenter')}</span>} extra={<Button type="link" size="small">{t('common.more')} <ChevronRight size={14} /></Button>}>
<Row gutter={[12, 12]}>
{reportTemplates.map((tpl, idx) => (
<Col span={12} key={idx}>
<div style={{ background: '#f8fafc', padding: '12px', borderRadius: 10, height: '100%', border: '1px solid #f0f0f0' }}>
<div style={{ display: 'flex', alignItems: 'center', gap: 10, marginBottom: 8 }}>
<div style={{ width: 32, height: 32, borderRadius: 8, background: tpl.bg, color: tpl.color, display: 'flex', alignItems: 'center', justifyContent: 'center', fontSize: 16 }}>
{tpl.icon}
</div>
<div style={{ fontSize: 13, fontWeight: 700, color: '#1D2129' }}>{tpl.name}</div>
</div>
<div style={{ fontSize: 11, color: '#86909C', lineHeight: 1.4 }}>{tpl.desc}</div>
</div>
</Col>
))}
</Row>
</Card>
{/* 报表生成记录 */}
<Card bordered={false} style={{ ...cardStyle, marginTop: 8 }} bodyStyle={{ padding: 0 }} title={<span style={{ fontSize: 15, fontWeight: 700 }}>{t('report.generationRecords')}</span>} extra={<Button type="link" size="small">{t('common.more')} <ChevronRight size={14} /></Button>}>
<Table
rowKey="name"
columns={[
{ title: t('report.reportName'), dataIndex: 'name', width: 100, ellipsis: true },
{ title: t('report.generateTime'), dataIndex: 'time', width: 130 },
{ title: t('report.generator'), dataIndex: 'operator', width: 80 },
{ title: t('common.type'), dataIndex: 'type', width: 80 },
{
title: t('roles.status'), dataIndex: 'status', width: 70,
render: (v) => <Tag color={v === t('report.generated') ? 'success' : 'warning'} style={{ borderRadius: 4, fontSize: 10, margin: 0 }}>{v}</Tag>
},
{
title: t('roles.actions'), width: 90,
render: () => (
<Space size={8}>
<Button type="text" icon={<EyeOutlined />} size="small" />
<Button type="text" icon={<DownloadOutlined />} size="small" />
</Space>
)
}
]}
dataSource={generationRecord}
pagination={false}
size="small"
className="compact-table"
scroll={{ y: 240 }}
/>
</Card>
</Col>
</Row>
{/* 订阅与分发 */}
<Card variant="borderless" style={{ ...cardStyle, marginTop: 8 }} styles={{ body: { padding: '20px' } }} title={<span style={{ fontSize: 15, fontWeight: 700, color: '#1D2129' }}>{t('report.subscriptionDispatch')}</span>}>
<Row gutter={[16, 16]} wrap>
<Col xs={24} sm={12} md={8}>
<div style={{ fontSize: 12, color: '#86909C', marginBottom: 12 }}>{t('report.subscribers', { count: 6 })}</div>
<div style={{ display: 'flex', alignItems: 'center', gap: 8, flexWrap: 'wrap' }}>
{[
{ name: '张运维', role: t('report.roleOmSupervisor'), img: 'https://img.icons8.com/fluency/48/user-male-circle.png' },
{ name: '李工程师', role: t('report.roleStationEngineer'), img: 'https://img.icons8.com/fluency/48/user-male-circle.png' },
{ name: '王运维', role: t('report.roleDeviceOm'), img: 'https://img.icons8.com/fluency/48/user-male-circle.png' },
{ name: '陈经理', role: t('report.roleOmManager'), img: 'https://img.icons8.com/fluency/48/user-male-circle.png' },
].map((p, idx) => (
<Tooltip title={`${p.name} - ${p.role}`} key={idx}>
<Avatar src={p.img} size={32} style={{ border: '2px solid #fff' }} />
</Tooltip>
))}
<Avatar size={32} style={{ background: '#F2F3F5', color: '#165DFF', fontSize: 12, fontWeight: 700, border: '2px solid #fff' }}>+2</Avatar>
</div>
</Col>
<Col xs={24} sm={12} md={8}>
<div style={{ fontSize: 12, color: '#86909C', marginBottom: 12 }}>{t('report.dispatchChannels')}</div>
<Space size={12} wrap>
<Button size="small" icon={<MailOutlined />} style={{ borderRadius: 6, background: '#E8F3FF', border: 'none', color: '#165DFF' }}>{t('report.email')} <CheckCircleFilled style={{ fontSize: 10, marginLeft: 4 }} /></Button>
<Button size="small" style={{ borderRadius: 6, background: '#E8F3FF', border: 'none', color: '#165DFF' }}>Telegram <CheckCircleFilled style={{ fontSize: 10, marginLeft: 4 }} /></Button>
<Button size="small" icon={<BellOutlined />} style={{ borderRadius: 6, background: '#E8F3FF', border: 'none', color: '#165DFF' }}>{t('report.systemNotification')} <CheckCircleFilled style={{ fontSize: 10, marginLeft: 4 }} /></Button>
</Space>
</Col>
<Col xs={24} sm={24} md={8}>
<div style={{ fontSize: 12, color: '#86909C', marginBottom: 12 }}>{t('report.sendPlan')}</div>
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', background: '#f8fafc', padding: '8px 12px', borderRadius: 8, gap: 8 }}>
<Space size={8} wrap>
<CalendarOutlined style={{ color: '#165DFF' }} />
<span style={{ fontSize: 13, fontWeight: 700 }}>{t('report.weeklyAutoSend')}</span>
</Space>
<Button type="link" size="small" icon={<EditOutlined />} style={{ fontSize: 12, whiteSpace: 'nowrap' }}>{t('roles.edit')}</Button>
</div>
</Col>
</Row>
</Card>
</Col>
{/* 右侧边栏 */}
<Col xs={24} xl={8}>
{/* 报表目录 / 快捷下载 */}
<Card variant="borderless" style={cardStyle} styles={{ body: { padding: 0 } }} title={<span style={{ fontSize: 15, fontWeight: 700 }}>{t('report.reportDirectory')}</span>} extra={<Button type="link" size="small">{t('common.more')} <ChevronRight size={14} /></Button>}>
<Table
rowKey="name"
columns={[
{
title: t('report.reportName'), dataIndex: 'name',
render: (text) => <Space size={8}><FilePdfOutlined style={{ color: '#F53F3F' }} />{text}</Space>
},
{
title: t('roles.status'), dataIndex: 'status', width: 80,
render: (v) => <Tag color={v === t('report.generated') ? 'success' : 'warning'} style={{ borderRadius: 4, fontSize: 10, margin: 0 }}>{v}</Tag>
},
{
title: t('roles.actions'), width: 120,
render: () => (
<Space split={<Divider type="vertical" />}>
<Button type="link" size="small" icon={<EyeOutlined />} style={{ fontSize: 12, padding: 0 }}>{t('common.view')}</Button>
<Button type="link" size="small" icon={<DownloadOutlined />} style={{ fontSize: 12, padding: 0 }}>{t('common.download')}</Button>
</Space>
)
}
]}
dataSource={reportFileList}
pagination={false}
size="small"
className="compact-table"
/>
</Card>
{/* 模板中心 */}
<Card variant="borderless" style={{ ...cardStyle, marginTop: 8 }} styles={{ body: { padding: '16px' } }} title={<span style={{ fontSize: 15, fontWeight: 700 }}>{t('report.templateCenter')}</span>} extra={<Button type="link" size="small">{t('common.more')} <ChevronRight size={14} /></Button>}>
<Row gutter={[12, 12]}>
{reportTemplates.map((tpl, idx) => (
<Col span={12} key={idx}>
<div style={{ background: '#f8fafc', padding: '12px', borderRadius: 10, height: '100%', border: '1px solid #f0f0f0' }}>
<div style={{ display: 'flex', alignItems: 'center', gap: 10, marginBottom: 8 }}>
<div style={{ width: 32, height: 32, borderRadius: 8, background: tpl.bg, color: tpl.color, display: 'flex', alignItems: 'center', justifyContent: 'center', fontSize: 16 }}>
{tpl.icon}
</div>
<div style={{ fontSize: 13, fontWeight: 700, color: '#1D2129' }}>{tpl.name}</div>
</div>
<div style={{ fontSize: 11, color: '#86909C', lineHeight: 1.4 }}>{tpl.desc}</div>
</div>
</Col>
))}
</Row>
</Card>
{/* 报表生成记录 */}
<Card variant="borderless" style={{ ...cardStyle, marginTop: 8 }} styles={{ body: { padding: 0 } }} title={<span style={{ fontSize: 15, fontWeight: 700 }}>{t('report.generationRecords')}</span>} extra={<Button type="link" size="small">{t('common.more')} <ChevronRight size={14} /></Button>}>
<Table
rowKey="name"
columns={[
{ title: t('report.reportName'), dataIndex: 'name', width: 100, ellipsis: true },
{ title: t('report.generateTime'), dataIndex: 'time', width: 130 },
{ title: t('report.generator'), dataIndex: 'operator', width: 80 },
{ title: t('common.type'), dataIndex: 'type', width: 80 },
{
title: t('roles.status'), dataIndex: 'status', width: 70,
render: (v) => <Tag color={v === t('report.generated') ? 'success' : 'warning'} style={{ borderRadius: 4, fontSize: 10, margin: 0 }}>{v}</Tag>
},
{
title: t('roles.actions'), width: 90,
render: () => (
<Space size={8}>
<Button type="text" icon={<EyeOutlined />} size="small" />
<Button type="text" icon={<DownloadOutlined />} size="small" />
</Space>
)
}
]}
dataSource={generationRecord}
pagination={false}
size="small"
className="compact-table"
scroll={{ y: 240 }}
/>
</Card>
</Col>
</Row>
</>
)}
</div>
);
}

View File

@@ -1,4 +1,4 @@
import React, { useState } from 'react';
import React, { useState } from 'react';
import {
Card, Row, Col, Button, Space, Input, Select, Table, Tag, Typography, Dropdown, Menu,
Timeline, Badge, Divider, Tooltip
@@ -158,8 +158,8 @@ export default function VideoMonitorPage() {
].map((item, index) => (
<Col key={index} style={{ minWidth: '168px', flex: '1 0 auto', maxWidth: "250px" }}>
<Card
variant="borderless"
styles={{ body: { padding: '16px' } }}
bordered={false}
bodyStyle={{ padding: '16px' }}
style={{ borderRadius: 8, height: 120 }}
>
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', height: '100%' }}>
@@ -201,9 +201,9 @@ export default function VideoMonitorPage() {
<Button type="link" size="small" icon={<FullscreenOutlined />}>{t('video.fullScreen')}</Button>
</Space>
}
variant="borderless"
bordered={false}
style={cardStyle}
styles={{ body: { padding: 16 } }}
bodyStyle={{ padding: 16 }}
>
<Row gutter={[12, 12]}>
<Col span={14}>
@@ -221,7 +221,7 @@ export default function VideoMonitorPage() {
<ScissorOutlined style={{ color: '#fff', fontSize: 18, cursor: 'pointer' }} />
<CameraOutlined style={{ color: '#fff', fontSize: 18, cursor: 'pointer' }} />
<ExpandOutlined style={{ color: '#fff', fontSize: 18, cursor: 'pointer' }} />
<Select defaultValue={t('video.high')} size="small" style={{ width: 80 }} variant="borderless" className="video-select">
<Select defaultValue={t('video.high')} size="small" style={{ width: 80 }} bordered={false} className="video-select">
<Option value={t('video.super')}>{t('video.super')}</Option>
<Option value={t('video.high')}>{t('video.high')}</Option>
<Option value={t('video.standard')}>{t('video.standard')}</Option>
@@ -265,9 +265,9 @@ export default function VideoMonitorPage() {
<Card
title={<span style={{ fontSize: 16, fontWeight: 800, color: '#1D2129' }}>{t('video.fixed2AiVideoIntelligentAnalysisFixed2')}</span>}
extra={<Button type="link" size="small">{t('common.settings')}<ChevronRight size={14} /></Button>}
variant="borderless"
bordered={false}
style={{ ...cardStyle, height: '100%' }}
styles={{ body: { padding: '16px 20px' } }}
bodyStyle={{ padding: '16px 20px' }}
>
<div style={{ display: 'flex', flexDirection: 'column', gap: 16 }}>
{[
@@ -308,12 +308,11 @@ export default function VideoMonitorPage() {
</Select>
</Space>
}
variant="borderless"
bordered={false}
style={cardStyle}
styles={{ body: { padding: 0 } }}
bodyStyle={{ padding: 0 }}
>
<Table
rowKey="key"
columns={camColumns}
dataSource={camList}
pagination={false}
@@ -328,9 +327,9 @@ export default function VideoMonitorPage() {
<Card
title={<span style={{ fontSize: 15, fontWeight: 800, color: '#1D2129' }}>{t('video.eventTimeline')}</span>}
extra={<Select defaultValue={t('devices.allTypes')} size="small" style={{ width: 100 }}><Option value="全部类型">{t('devices.allTypes')}</Option></Select>}
variant="borderless"
bordered={false}
style={cardStyle}
styles={{ body: { padding: '16px 20px' } }}
bodyStyle={{ padding: '16px 20px' }}
>
<Timeline style={{ marginTop: 8 }}>
{[
@@ -358,9 +357,9 @@ export default function VideoMonitorPage() {
<Card
title={<span style={{ fontSize: 15, fontWeight: 800, color: '#1D2129' }}>{t('video.alert')}</span>}
extra={<Button type="link" size="small">{t('devices.viewMore')}<ChevronRight size={14} /></Button>}
variant="borderless"
bordered={false}
style={cardStyle}
styles={{ body: { padding: '16px 20px' } }}
bodyStyle={{ padding: '16px 20px' }}
>
<div style={{ display: 'flex', flexWrap: "wrap", gap: 12, paddingBottom: 8 }} >
{[

View File

@@ -915,7 +915,7 @@ const WorkOrderPage = () => {
<Row gutter={[8, 8]} style={{ marginBottom: 8 }}>
{stats.map((item, index) => (
<Col key={index} xs={24} sm={12} md={8} xl={4}>
<Card variant="borderless" styles={{ body: { padding: '20px 16px' } }} style={cardStyle}>
<Card bordered={false} bodyStyle={{ padding: '20px 16px' }} style={cardStyle}>
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
<div>
<div style={{ fontSize: 'clamp(12px, 0.8vw, 13px)', color: '#86909C', marginBottom: 2 }}>{item.title}</div>
@@ -940,7 +940,7 @@ const WorkOrderPage = () => {
</Row>
{/* 筛选栏 */}
<Card variant="borderless" styles={{ body: { padding: '8px 16px 0px 16px' } }} style={{ ...cardStyle, marginBottom: 8 }}>
<Card bordered={false} bodyStyle={{ padding: '8px 16px 0px 16px' }} style={{ ...cardStyle, marginBottom: 8 }}>
<Form form={queryForm} layout="inline" initialValues={{
orderStatus: 1
}}>
@@ -976,7 +976,7 @@ const WorkOrderPage = () => {
{/* 左侧:列表 + 底部图表 */}
<Col xs={24} xl={15}>
<Card
variant="borderless"
bordered={false}
title={
<Space size={8}>
<Text strong style={{ fontSize: 15, color: '#1D2129' }}>{t('workOrder.listFixed2')}</Text>
@@ -1002,7 +1002,7 @@ const WorkOrderPage = () => {
)}
</Space>
}
styles={{ body: { padding: 0 } }}
bodyStyle={{ padding: 0 }}
style={{ ...cardStyle, marginBottom: 8 }}
>
@@ -1037,7 +1037,7 @@ const WorkOrderPage = () => {
<Row gutter={[12, 12]}>
<Col xs={24} md={9}>
<Card variant="borderless" title={<Text strong style={{ fontSize: 14 }}>{t('workOrder.fixed2OrderStatus')}</Text>} style={{ ...cardStyle, height: 380 }}>
<Card bordered={false} title={<Text strong style={{ fontSize: 14 }}>{t('workOrder.fixed2OrderStatus')}</Text>} style={{ ...cardStyle, height: 380 }}>
<div style={{ height: 300, position: 'relative' }}>
<Pie
data={pieData}
@@ -1059,7 +1059,7 @@ const WorkOrderPage = () => {
</Col>
<Col xs={24} md={15}>
<Card
variant="borderless"
bordered={false}
title={<Text strong style={{ fontSize: 14 }}>{t('workOrder.fixed2TaskSuspended2')}</Text>}
extra={
<Button
@@ -1070,7 +1070,7 @@ const WorkOrderPage = () => {
</Button>
}
style={{ ...cardStyle, height: 380 }}
styles={{ body: { padding: '16px' } }}
bodyStyle={{ padding: '16px' }}
>
{/* 日期切换栏 */}
<div style={{ marginBottom: 16 }}>
@@ -1206,7 +1206,7 @@ const WorkOrderPage = () => {
{/* 右侧:详情 + AI + 告警 */}
<Col xs={24} xl={9}>
<Card variant="borderless" style={cardStyle} styles={{ body: { padding: '20px' } }}>
<Card bordered={false} style={cardStyle} bodyStyle={{ padding: '20px' }}>
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginBottom: 8 }}>
<Text strong style={{ fontSize: 16, color: '#1D2129' }}>{t('workOrder.detailFixed2')}</Text>
<Text type="secondary" style={{ fontSize: 12 }}>{t('workOrder.fixed2OrderNo')}<span style={{ color: '#4E5969', fontWeight: 600 }}>{currentDetail?.orderNo || '--'}</span></Text>
@@ -1464,8 +1464,8 @@ const WorkOrderPage = () => {
</Card>
<Card variant="borderless" title={<Text strong style={{ fontSize: 14, color: '#1D2129' }}>{t('workOrder.aiSuggestion')}</Text>}
style={{ ...cardStyle, marginTop: 8 }} styles={{ body: { padding: '16px' } }}>
<Card bordered={false} title={<Text strong style={{ fontSize: 14, color: '#1D2129' }}>{t('workOrder.aiSuggestion')}</Text>}
style={{ ...cardStyle, marginTop: 8 }} bodyStyle={{ padding: '16px' }}>
<Row gutter={12} style={{ marginBottom: 16 }}>
<Col span={8}>
<div style={{ background: '#F9F0FF', padding: '16px 8px', borderRadius: 12, textAlign: 'center', height: '100%', border: '1px solid #F3E8FF' }}>