新增工单加上计划完成时间 为了工单中任务分布 还有 增益系数完成
This commit is contained in:
@@ -427,6 +427,16 @@ export function addRoute(data) {
|
||||
return request(config);
|
||||
}
|
||||
|
||||
//配置设备参数
|
||||
|
||||
export function deviceCommmand(data) {
|
||||
return request({
|
||||
url: '/netty/device/sendCommand',
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -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() {
|
||||
<Button size="small" icon={<DisconnectOutlined />} onClick={() => handleUnbindSmart([record.serialNumber], 3)}>组织</Button>
|
||||
</Tooltip>
|
||||
<Button size="small" icon={<EditOutlined />} onClick={() => openParamModal(record)}>参数</Button>
|
||||
<Button size="small" icon={<EditOutlined />} onClick={() => openParamModal1(record)}>增益参数</Button>
|
||||
|
||||
|
||||
</Space>
|
||||
),
|
||||
@@ -633,6 +705,14 @@ export default function DeviceManagementPage() {
|
||||
/>
|
||||
<Button icon={<ReloadOutlined />} onClick={() => setSmartParams({ pageNum: 1, pageSize: 10, serialNumber: '' })}>重置</Button>
|
||||
<Button type="primary" icon={<LinkOutlined />} onClick={openBindSmartModal}>绑定装备</Button>
|
||||
<Button
|
||||
type="primary"
|
||||
danger
|
||||
disabled={selectedSmartKeys.length === 0}
|
||||
onClick={() => setBatchParamModalVisible(true)}
|
||||
>
|
||||
批量修改增益参数
|
||||
</Button>
|
||||
<Button disabled={selectedSmartKeys.length === 0} onClick={() => handleUnbindSmart(selectedSmartKeys, 1)}>批量解绑(用户)</Button>
|
||||
<Button disabled={selectedSmartKeys.length === 0} onClick={() => handleUnbindSmart(selectedSmartKeys, 2)}>批量解绑(场站)</Button>
|
||||
<Button disabled={selectedSmartKeys.length === 0} onClick={() => handleUnbindSmart(selectedSmartKeys, 3)}>批量解绑(组织)</Button>
|
||||
@@ -746,6 +826,44 @@ export default function DeviceManagementPage() {
|
||||
</Form.Item>
|
||||
</Form>
|
||||
</Modal>
|
||||
{/* 设备增益参数 */}
|
||||
|
||||
<Modal
|
||||
title={`增益参数管理 - ${currentParamDevice1?.deviceAlias || currentParamDevice1?.serialNumber}`}
|
||||
open={paramModalVisible1}
|
||||
onCancel={() => {
|
||||
setParamModalVisible1(false);
|
||||
setCurrentParamDevice1(null);
|
||||
setParamData1(null);
|
||||
}}
|
||||
footer={null}
|
||||
width={500}
|
||||
>
|
||||
{/* 显示和编辑参数 */}
|
||||
<Form
|
||||
form={paramForm1}
|
||||
layout="vertical"
|
||||
onFinish={saveParam1}
|
||||
>
|
||||
|
||||
|
||||
<Form.Item label="左轮增益系数" name="left" rules={[{ required: true, message: '请设置左轮增益系数' }]}>
|
||||
<div style={{ display: 'flex', gap: 12, alignItems: 'center' }}>
|
||||
<InputNumber min={0.1} max={1} step={0.01} style={{ width: 100 }} placeholder="0.1~1" />
|
||||
</div>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item label="右轮增益系数" name="right" rules={[{ required: true, message: '请设置右轮增益系数' }]}>
|
||||
<div style={{ display: 'flex', gap: 12, alignItems: 'center' }}>
|
||||
{/*<Slider min={0} max={1} step={0.01} style={{ flex: 1 }} />*/}
|
||||
<InputNumber min={0.1} max={1} step={0.01} style={{ width: 100 }} placeholder="0.1~1" />
|
||||
</div>
|
||||
</Form.Item>
|
||||
<Form.Item>
|
||||
<Button type="primary" htmlType="submit">保存参数</Button>
|
||||
</Form.Item>
|
||||
</Form>
|
||||
</Modal>
|
||||
|
||||
{/* 设备参数管理弹窗 */}
|
||||
<Modal
|
||||
@@ -786,6 +904,40 @@ export default function DeviceManagementPage() {
|
||||
</Form.Item>
|
||||
</Form>
|
||||
</Modal>
|
||||
|
||||
{/* 批量修改增益参数弹窗 */}
|
||||
<Modal
|
||||
title={`批量修改增益参数(已选${selectedSmartKeys.length}台设备)`}
|
||||
open={batchParamModalVisible}
|
||||
onCancel={() => {
|
||||
setBatchParamModalVisible(false);
|
||||
batchParamForm.resetFields();
|
||||
}}
|
||||
footer={null}
|
||||
width={500}
|
||||
>
|
||||
<Form
|
||||
form={batchParamForm}
|
||||
layout="vertical"
|
||||
onFinish={saveBatchParam}
|
||||
>
|
||||
<Form.Item label="左轮增益系数" name="left" rules={[{ required: true, message: '请设置左轮增益系数' }]}>
|
||||
<InputNumber min={0.1} max={1} step={0.01} style={{ width: '100%' }} placeholder="范围0.1 ~ 1" />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item label="右轮增益系数" name="right" rules={[{ required: true, message: '请设置右轮增益系数' }]}>
|
||||
<InputNumber min={0.1} max={1} step={0.01} style={{ width: '100%' }} placeholder="范围0.1 ~ 1" />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item>
|
||||
<Space>
|
||||
<Button onClick={() => setBatchParamModalVisible(false)}>取消</Button>
|
||||
<Button type="primary" htmlType="submit">确认批量保存</Button>
|
||||
</Space>
|
||||
</Form.Item>
|
||||
</Form>
|
||||
</Modal>
|
||||
|
||||
</>
|
||||
) : activeTab === 'drone' ? (
|
||||
<>
|
||||
|
||||
@@ -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' }) => {
|
||||
</Tag>
|
||||
);
|
||||
}
|
||||
|
||||
// 表格小标签
|
||||
return (
|
||||
<Tag
|
||||
@@ -124,6 +121,9 @@ export default function AlarmCenterPage() {
|
||||
const [editModalVisible, setEditModalVisible] = useState(false);
|
||||
const [editForm] = Form.useForm();
|
||||
|
||||
// ========== 新增:工单弹窗状态 & 表单 ==========
|
||||
const [createOrderModalVisible, setCreateOrderModalVisible] = useState(false);
|
||||
const [orderForm] = Form.useForm();
|
||||
|
||||
// 查询条件
|
||||
const [queryParams, setQueryParams] = useState({
|
||||
@@ -254,7 +254,6 @@ export default function AlarmCenterPage() {
|
||||
useEffect(() => {
|
||||
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 (
|
||||
<div style={{ background: '#f5f7fa', minHeight: '100vh', padding: '0' }}>
|
||||
{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"
|
||||
/> </Card>
|
||||
/>
|
||||
</Card>
|
||||
</Col>
|
||||
<Col span={8}>
|
||||
<Card bordered={false} title="告警状态统计" style={{ borderRadius: 8 }}>
|
||||
@@ -820,7 +828,6 @@ export default function AlarmCenterPage() {
|
||||
{/* 告警详情抽屉 */}
|
||||
<Drawer
|
||||
title="告警详情"
|
||||
//open={true}
|
||||
open={drawerVisible}
|
||||
onClose={() => setDrawerVisible(false)}
|
||||
width={480}
|
||||
@@ -910,18 +917,15 @@ export default function AlarmCenterPage() {
|
||||
</Form.Item>
|
||||
</Card>
|
||||
|
||||
|
||||
{/* 底部按钮 */}
|
||||
<Button type="primary" block htmlType="submit">确认处理</Button>
|
||||
|
||||
|
||||
|
||||
|
||||
</>
|
||||
</Form>
|
||||
)}
|
||||
</Spin>
|
||||
</Drawer>
|
||||
|
||||
{/* ====================== 修改告警弹窗 ====================== */}
|
||||
<Modal
|
||||
title="修改告警"
|
||||
@@ -989,6 +993,53 @@ export default function AlarmCenterPage() {
|
||||
</Form>
|
||||
</Modal>
|
||||
|
||||
{/* ========== 新增:生成工单弹窗 ========== */}
|
||||
<Modal
|
||||
title="新建工单"
|
||||
open={createOrderModalVisible}
|
||||
onCancel={() => {
|
||||
setCreateOrderModalVisible(false);
|
||||
orderForm.resetFields();
|
||||
}}
|
||||
width={500}
|
||||
maskClosable={false}
|
||||
footer={null}
|
||||
>
|
||||
<Form
|
||||
form={orderForm}
|
||||
layout="vertical"
|
||||
onFinish={submitCreateOrder}
|
||||
>
|
||||
<Form.Item
|
||||
label="工单标题"
|
||||
name="orderTitle"
|
||||
rules={[{ required: true, message: '请输入工单标题' }]}
|
||||
>
|
||||
<Input placeholder="请输入工单标题" />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
label="计划开始时间"
|
||||
name="planStartTime"
|
||||
rules={[{ required: true, message: '请选择计划开始时间' }]}
|
||||
>
|
||||
<DatePicker
|
||||
showTime
|
||||
style={{ width: '100%' }}
|
||||
placeholder="请选择计划开始时间"
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
|
||||
<Form.Item style={{ textAlign: 'right', marginBottom: 0 }}>
|
||||
<Button onClick={() => setCreateOrderModalVisible(false)}>取消</Button>
|
||||
<Button type="primary" htmlType="submit" style={{ marginLeft: 8 }}>
|
||||
确认生成工单
|
||||
</Button>
|
||||
</Form.Item>
|
||||
</Form>
|
||||
</Modal>
|
||||
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -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 },
|
||||
|
||||
Reference in New Issue
Block a user