From 68f63e520f1410b0c2bbdb28301cd0a8d3b409ab Mon Sep 17 00:00:00 2001 From: mmc <1556375442@qq.com> Date: Mon, 20 Jul 2026 15:27:27 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=B7=A5=E5=8D=95=E5=8A=A0?= =?UTF-8?q?=E4=B8=8A=E8=AE=A1=E5=88=92=E5=AE=8C=E6=88=90=E6=97=B6=E9=97=B4?= =?UTF-8?q?=20=E4=B8=BA=E4=BA=86=E5=B7=A5=E5=8D=95=E4=B8=AD=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1=E5=88=86=E5=B8=83=20=20=20=E8=BF=98=E6=9C=89=20?= =?UTF-8?q?=E5=A2=9E=E7=9B=8A=E7=B3=BB=E6=95=B0=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/device.ts | 10 ++ .../SystemSetting/DeviceManagement.tsx | 154 +++++++++++++++++- src/components/alerts/AlarmOverview.tsx | 103 +++++++++--- src/pages/WorkOrder.tsx | 2 +- 4 files changed, 241 insertions(+), 28 deletions(-) diff --git a/src/api/device.ts b/src/api/device.ts index bde7af3..c788140 100644 --- a/src/api/device.ts +++ b/src/api/device.ts @@ -427,6 +427,16 @@ export function addRoute(data) { return request(config); } +//配置设备参数 + +export function deviceCommmand(data) { + return request({ + url: '/netty/device/sendCommand', + method: 'post', + data + }) +} + diff --git a/src/components/SystemSetting/DeviceManagement.tsx b/src/components/SystemSetting/DeviceManagement.tsx index b65b18b..4cfbb1c 100644 --- a/src/components/SystemSetting/DeviceManagement.tsx +++ b/src/components/SystemSetting/DeviceManagement.tsx @@ -32,7 +32,7 @@ import { DisconnectOutlined, } from '@ant-design/icons'; import SerialNumGenerate from "./SerialNumGenerate" -import { getPlaneDeviceList, bindDrone, unbindDrone, bindSmartDevice, unbindSmartDevice, getAllDevice } from '@/api/device'; +import { getPlaneDeviceList, bindDrone, unbindDrone, bindSmartDevice, unbindSmartDevice, getAllDevice, deviceCommmand } from '@/api/device'; import { getOrgList } from '@/api/organization/index'; import { getSiteByOrgId, getStationList, deviceRunParamSelectByDeviceId, deviceRunParamSave, deviceRunParamDelete } from '@/api/stationManage/index'; import { getUser } from '@/api/user/index'; @@ -80,6 +80,11 @@ export default function DeviceManagementPage() { const [bindForm] = Form.useForm(); const [selectedDroneKeys, setSelectedDroneKeys] = useState([]); + // 批量增益参数弹窗 + const [batchParamModalVisible, setBatchParamModalVisible] = useState(false); + const [batchParamForm] = Form.useForm(); + + // 无人机分页 + 筛选 const [droneParams, setDroneParams] = useState({ pageNum: 1, @@ -121,6 +126,12 @@ export default function DeviceManagementPage() { const [paramData, setParamData] = useState(null); const [paramForm] = Form.useForm(); + + const [paramModalVisible1, setParamModalVisible1] = useState(false); + const [currentParamDevice1, setCurrentParamDevice1] = useState(null); + const [paramData1, setParamData1] = useState(null); + const [paramForm1] = Form.useForm(); + // 获取无人机列表(带分页 + 筛选) const fetchDroneList = async () => { setLoading(true); @@ -169,6 +180,10 @@ export default function DeviceManagementPage() { setParamModalVisible(true); await fetchParamData(record.serialNumber); }; + const openParamModal1 = async (record) => { + setCurrentParamDevice1(record); + setParamModalVisible1(true); + }; // 获取设备参数 const fetchParamData = async (deviceId) => { @@ -212,6 +227,61 @@ export default function DeviceManagementPage() { } }; + const saveParam1 = async (values) => { + console.log(values); + try { + const payload = { + params: { + left: Math.max(0.1, Math.min(1, values.left >= 10 ? values.left / 10 : values.left)), + right: Math.max(0.1, Math.min(1, values.right)) + }, + commandType: "WheelGainCoefficients", + deviceId: [currentParamDevice1.serialNumber], + + }; + console.log(values); + const res = await deviceCommmand(payload); + if (res.code === 200) { + utils.message.success('保存参数成功'); + setParamModalVisible1(false); + //await fetchParamData(currentParamDevice.serialNumber); + } else { + utils.message.error(res.msg || '保存参数失败'); + } + } catch (err) { + utils.message.error('操作异常'); + } + }; + + // 批量保存增益参数 + const saveBatchParam = async (values) => { + try { + // 选中的所有设备serialNumber数组 + const deviceIdList = [...selectedSmartKeys]; + const payload = { + params: { + left: Math.max(0.1, Math.min(1, values.left >= 10 ? values.left / 10 : values.left)), + right: Math.max(0.1, Math.min(1, values.right)) + }, + commandType: "WheelGainCoefficients", + deviceId: deviceIdList, // 批量传设备数组 + }; + const res = await deviceCommmand(payload); + if (res.code === 200) { + utils.message.success(`已批量为${deviceIdList.length}台设备更新增益参数`); + setBatchParamModalVisible(false); + batchParamForm.resetFields(); + setSelectedSmartKeys([]); // 清空选中 + } else { + utils.message.error(res.msg || '批量修改参数失败'); + } + } catch (err) { + utils.message.error('操作异常'); + console.error(err); + } + }; + + const fetchSmartList = async () => { setLoading(true); try { @@ -441,6 +511,8 @@ export default function DeviceManagementPage() { + + ), @@ -633,6 +705,14 @@ export default function DeviceManagementPage() { /> + @@ -746,6 +826,44 @@ export default function DeviceManagementPage() { + {/* 设备增益参数 */} + + { + setParamModalVisible1(false); + setCurrentParamDevice1(null); + setParamData1(null); + }} + footer={null} + width={500} + > + {/* 显示和编辑参数 */} +
+ + + +
+ +
+
+ + +
+ {/**/} + +
+
+ + + +
+
{/* 设备参数管理弹窗 */} + + {/* 批量修改增益参数弹窗 */} + { + setBatchParamModalVisible(false); + batchParamForm.resetFields(); + }} + footer={null} + width={500} + > +
+ + + + + + + + + + + + + + +
+
+ ) : activeTab === 'drone' ? ( <> diff --git a/src/components/alerts/AlarmOverview.tsx b/src/components/alerts/AlarmOverview.tsx index 62fd0ab..569fb06 100644 --- a/src/components/alerts/AlarmOverview.tsx +++ b/src/components/alerts/AlarmOverview.tsx @@ -48,7 +48,6 @@ const levelColorMap = { INFO: '#1890FF', // 信息 蓝 }; - // 快速根据 value 获取 label const getLevelLabel = (val) => { const item = errorLevelOptions.find(opt => opt.value === val); @@ -63,7 +62,6 @@ const getLevelLabel = (val) => { const AlarmLevelTag = ({ level, size = 'small' }) => { const color = levelColorMap[level] || '#86909C'; const text = getLevelLabel(level); - // 详情大标签 if (size === 'large') { return ( @@ -84,7 +82,6 @@ const AlarmLevelTag = ({ level, size = 'small' }) => { ); } - // 表格小标签 return ( { fetchList(); - }, [pageNum, stationId]); useEffect(() => { fetchTodayAndYesterdayStat(); @@ -371,7 +370,6 @@ export default function AlarmCenterPage() { })); }; - const pieData = [ { name: '错误', @@ -431,52 +429,60 @@ export default function AlarmCenterPage() { console.log('派发工单', currentAlarm); }; - - // 生成工单 - const handleaddOrder = async () => { + // ========== 修改:点击生成工单只打开弹窗,不直接请求接口 ========== + const handleaddOrder = () => { if (!currentAlarm) { messageApi.warning('无告警信息,无法生成工单'); return; } + // 预填充表单 + orderForm.setFieldsValue({ + orderTitle: currentAlarm.alarmTitle || '告警生成工单', + planStartTime: null + }); + setCreateOrderModalVisible(true); + }; + // ========== 新增:弹窗提交工单函数 ========== + const submitCreateOrder = async (values) => { try { - // 组装接口需要的所有参数(你给的格式) const params = { id: '', orderNo: '', - orderTitle: currentAlarm.alarmTitle || '告警生成工单', + orderTitle: values.orderTitle, sourceType: 7, // 来源 7=告警 orderType: 5, // 类型 5=运维 - priorityLevel: currentAlarm.alarmLevel === 1 ? 1 : 2, // 严重=高,其他=中 + priorityLevel: currentAlarm.alarmLevel === 'ERROR' ? 1 : 2, // 修复:等级是字符串,不是数字1 deviceId: currentAlarm.deviceId || '', deviceName: currentAlarm.deviceName || '', - deviceType: currentAlarm.deviceType, // 没有就传空 + deviceType: currentAlarm.deviceType, siteId: stationId, orgId: userInfo?.orgId || '', assigneeId: '', assigneeName: '', collaboratorIds: '', collaboratorNames: '', - planStartTime: '', + planStartTime: values.planStartTime ? dayjs(values.planStartTime).format('YYYY-MM-DD HH:mm:ss') : '', planEndTime: '', deadlineTime: '', actualStartTime: '', actualEndTime: '', orderStatus: 1, // 1-待处理 - alarmId: currentAlarm.id || '', // 关联告警ID - alarmNo: currentAlarm.alarmNo || '', // 关联告警编号 - taskDescription: currentAlarm.alarmContent || '', // 任务描述=告警内容 - aiSuggestion: currentAlarm.rootCause || '', // AI建议 + alarmId: currentAlarm.id || '', + alarmNo: currentAlarm.alarmNo || '', + taskDescription: values.taskDescription, + aiSuggestion: currentAlarm.rootCause || '', requiredEquipment: '', estimatedImpact: '', handleResult: '', handleRemark: '' }; - // 调用新增接口 const res = await addWorkOrder(params); if (res.code === 0 || res.code === 200) { messageApi.success('工单生成成功'); + setCreateOrderModalVisible(false); + orderForm.resetFields(); } else { messageApi.error(res.msg || '工单生成失败'); } @@ -485,6 +491,7 @@ export default function AlarmCenterPage() { console.error(error); } }; + return (
{contextHolder} @@ -516,10 +523,10 @@ export default function AlarmCenterPage() { }, { title: '严重告警', - value: todayData.levelStats?.[1] || 0, + value: todayData.levelStats?.["ERROR"] || 0, trend: (() => { const now = todayData.levelStats?.["ERROR"] ?? 0; - const last = yesterdayData.levelStats?.[1] ?? 0; + const last = yesterdayData.levelStats?.["ERROR"] ?? 0; if (last === 0) return '较昨日 无变化'; const rateNum = ((now - last) / last) * 100; const rateStr = rateNum.toFixed(1); @@ -781,7 +788,8 @@ export default function AlarmCenterPage() { innerRadius={45} outerRadius={80} backgroundColor="transparent" - /> + /> + @@ -820,7 +828,6 @@ export default function AlarmCenterPage() { {/* 告警详情抽屉 */} setDrawerVisible(false)} width={480} @@ -910,18 +917,15 @@ export default function AlarmCenterPage() { - {/* 底部按钮 */} - - - )} + {/* ====================== 修改告警弹窗 ====================== */} + {/* ========== 新增:生成工单弹窗 ========== */} + { + setCreateOrderModalVisible(false); + orderForm.resetFields(); + }} + width={500} + maskClosable={false} + footer={null} + > +
+ + + + + + + + + + + + + +
+
+
); } diff --git a/src/pages/WorkOrder.tsx b/src/pages/WorkOrder.tsx index 820da15..624469a 100644 --- a/src/pages/WorkOrder.tsx +++ b/src/pages/WorkOrder.tsx @@ -304,7 +304,7 @@ const WorkOrderPage = () => { const pieData = getOrderStatusPieData(); const alarmTrendData = [ - { date: '05-18', value: 5 }, + { date: '05-181', value: 5 }, { date: '05-19', value: 10 }, { date: '05-20', value: 7 }, { date: '05-21', value: 12 },