Procházet zdrojové kódy

[26110201] 事件查询优化: 确认告警逻辑修正为只要不是已处理(process_flag!=2)均置为已处理, 0行时提示所选告警均已处理未执行处理; 表格告警等级/告警类别改为从下拉options(alarmLevel/alarmCategory)构建label映射展示, 无匹配回退原始值; 导出Excel文件名时间改为查询的告警日期(如事件查询_20261103.xlsx, 未选日期时取当天)

taosj před 1 dnem
rodič
revize
ce2784eb82

+ 2 - 2
forecast-backend-server/src/main/java/com/ufo/project/alarm/controller/AlarmEventRecordController.java

@@ -57,7 +57,7 @@ public class AlarmEventRecordController extends BaseController
     }
 
     /**
-     * 确认告警(批量处理, 仅未处理数据可处理)
+     * 确认告警(批量处理, 非已处理数据均置为已处理)
      *
      * 参数: ids 告警主键集合
      */
@@ -75,7 +75,7 @@ public class AlarmEventRecordController extends BaseController
         int rows = alarmEventRecordService.processAlarmEventRecord(ids);
         if (rows == 0)
         {
-            return success("所选告警均非未处理状态, 未执行处理");
+            return success("所选告警均已处理, 未执行处理");
         }
         return success("已处理 " + rows + " 条告警");
     }

+ 1 - 1
forecast-backend-server/src/main/java/com/ufo/project/alarm/service/impl/AlarmEventRecordServiceImpl.java

@@ -103,7 +103,7 @@ public class AlarmEventRecordServiceImpl implements IAlarmEventRecordService
     }
 
     /**
-     * 批量处理报警信息(仅未处理数据可处理, 置为已处理)
+     * 批量处理报警信息(非已处理数据均置为已处理)
      *
      * @param ids 需要处理的报警信息主键集合
      * @return 结果

+ 1 - 1
forecast-backend-server/src/main/resources/mybatis/alarm/AlarmEventRecordMapper.xml

@@ -134,7 +134,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     <update id="processAlarmEventRecord">
         update alarm_event_record
         set process_flag = 2, update_time = #{updateTime}
-        where process_flag = 0 and id in
+        where process_flag != 2 and id in
         <foreach item="id" collection="ids" open="(" separator="," close=")">
             #{id}
         </foreach>

+ 15 - 5
forecast-backend-vue/src/views/ufo/electricity/statanalysis/eventQuery.vue

@@ -61,10 +61,10 @@
       >
         <template #bodyCell="{ column, record }">
           <template v-if="column.dataIndex === 'alarmLevel'">
-            {{ getDictLabel(record.alarmLevel, alarmLevel.value) }}
+            {{ levelLabel(record.alarmLevel) }}
           </template>
           <template v-else-if="column.dataIndex === 'alarmCategory'">
-            {{ getDictLabel(record.alarmCategory, alarmCategory.value) }}
+            {{ categoryLabel(record.alarmCategory) }}
           </template>
           <template v-else-if="column.dataIndex === 'processFlag'">
             <a-tag :color="processColorMap[record.processFlag] || 'default'">
@@ -83,7 +83,7 @@ import {message, Modal} from 'ant-design-vue';
 import dayjs from 'dayjs';
 import {saveAs} from 'file-saver';
 import {blobValidate} from '@/utils/bearjia';
-import {useDict, getDictLabel, getDictClass} from '@/composables/useDict';
+import {useDict} from '@/composables/useDict';
 import {listEventRecord, processEventRecord, exportEventRecord} from '@/api/alarm/eventRecord';
 
 const {alarm_category, alarm_level} = useDict('alarm_category', 'alarm_level');
@@ -97,6 +97,16 @@ const levelOptions = computed(() =>
   alarmLevel.value.map((o) => ({label: o.label, value: o.value}))
 );
 
+// 表格列展示: 从下拉options中取字典label, 无匹配时回退原始值
+const levelLabelMap = computed(() =>
+  Object.fromEntries(levelOptions.value.map((o) => [String(o.value), o.label]))
+);
+const categoryLabelMap = computed(() =>
+  Object.fromEntries(categoryOptions.value.map((o) => [String(o.value), o.label]))
+);
+const levelLabel = (val) => (val == null ? '' : levelLabelMap.value[String(val)] ?? val);
+const categoryLabel = (val) => (val == null ? '' : categoryLabelMap.value[String(val)] ?? val);
+
 const confirmedOptions = [
   {label: '已确认', value: true},
   {label: '未确认', value: false}
@@ -196,7 +206,7 @@ const handleProcess = () => {
   }
   Modal.confirm({
     title: '确认告警',
-    content: `确定将选中的 ${selectedRowKeys.value.length} 条告警标记为已处理吗?仅未处理的告警会被处理。`,
+    content: `确定将选中的 ${selectedRowKeys.value.length} 条告警标记为已处理吗?非已处理的告警将被置为已处理。`,
     okText: '确认',
     cancelText: '取消',
     onOk: async () => {
@@ -221,7 +231,7 @@ const handleExport = async () => {
     const res = await exportEventRecord(buildParams());
     const isFile = await blobValidate(res);
     if (isFile) {
-      const name = `事件查询_${dayjs().format('YYYYMMDDHHmmss')}.xlsx`;
+      const name = `事件查询_${dayjs(query.alarmDate || dayjs()).format('YYYYMMDD')}.xlsx`;
       saveAs(new Blob([res]), name);
       message.success('导出成功');
     } else {