Просмотр исходного кода

early_warning,warning_archive去掉location

zengy 3 недель назад
Родитель
Сommit
627ad51468

+ 0 - 2
pipe-network-service/sql/early_warning_system.sql

@@ -12,7 +12,6 @@ CREATE TABLE `early_warning` (
   `warning_special` varchar(128) DEFAULT NULL COMMENT '预警专项',
   `device_code` varchar(128) DEFAULT NULL COMMENT '关联设备编码',
   `device_name` varchar(256) DEFAULT NULL COMMENT '关联设备名称',
-  `location` varchar(512) DEFAULT NULL COMMENT '预警位置',
   `ownership_unit` varchar(256) DEFAULT NULL COMMENT '权属单位',
   `publisher` varchar(128) DEFAULT NULL COMMENT '发布人',
   `publish_time` datetime DEFAULT NULL COMMENT '发布时间',
@@ -171,7 +170,6 @@ CREATE TABLE `warning_archive` (
   `warning_no` varchar(64) NOT NULL COMMENT '预警编号',
   `warning_type` varchar(64) NOT NULL COMMENT '预警类型',
   `warning_level` varchar(32) NOT NULL COMMENT '预警级别',
-  `location` varchar(512) DEFAULT NULL COMMENT '预警位置',
   `ownership_unit` varchar(256) DEFAULT NULL COMMENT '权属单位',
   `publisher` varchar(128) DEFAULT NULL COMMENT '发布人',
   `publish_time` datetime DEFAULT NULL COMMENT '发布时间',

+ 26 - 0
pipe-network-service/zksy-admin/src/test/java/com/zksy/web/controller/warning/WarningScopeMapperTest.java

@@ -1,5 +1,8 @@
 package com.zksy.web.controller.warning;
 
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.zksy.base.warning.domain.EarlyWarning;
+import com.zksy.base.warning.domain.WarningArchive;
 import com.zksy.base.warning.dto.WarningAccessScope;
 import org.apache.ibatis.builder.xml.XMLMapperBuilder;
 import org.apache.ibatis.io.Resources;
@@ -108,4 +111,27 @@ class WarningScopeMapperTest {
         String done = sql(statement("selectMyTasks", Set.of(2, 4), Map.of("q", Map.of("todoType", "DONE"))));
         assertTrue(done.contains("AND t.todo_id IS NOT NULL"));
     }
+
+    @Test void locationIsSourcedFromEquipmentBaseAndOldColumnIsNotReferenced() throws Exception {
+        for (String query : List.of("selectTodayWarningList", "selectWarningList", "searchWarnings",
+                "selectMyTasks", "selectProcessingWarnings", "selectCompletedWarnings",
+                "selectMobileWarnings", "selectTodoList", "selectWarningDetail", "selectWarningDetailByNo")) {
+            String text = sql(statement(query, Set.of(2), Collections.emptyMap()));
+            assertFalse(text.contains("w.location"), query + ": " + text);
+            assertTrue(text.contains("AS location"), query + ": " + text);
+            assertTrue(text.contains("e.equipment_location") || text.contains("eb.equipment_location"),
+                    query + ": " + text);
+        }
+        for (String query : List.of("selectWarningDetail", "selectWarningDetailByNo")) {
+            assertTrue(sql(statement(query, Set.of(2), Collections.emptyMap()))
+                    .contains("eb.equipment_location AS location"), query);
+        }
+    }
+
+    @Test void domainObjectsNoLongerMapLocationColumn() throws Exception {
+        TableField field = EarlyWarning.class.getDeclaredField("location").getAnnotation(TableField.class);
+        assertNotNull(field);
+        assertFalse(field.exist());
+        assertThrows(NoSuchFieldException.class, () -> WarningArchive.class.getDeclaredField("location"));
+    }
 }

+ 2 - 2
pipe-network-service/zksy-system/src/main/java/com/zksy/base/warning/domain/EarlyWarning.java

@@ -63,8 +63,8 @@ public class EarlyWarning implements Serializable {
     @ApiModelProperty("关联设备名称(展示用,来源 equipment_base.equipment_name)")
     private String deviceName;
 
-    @TableField("location")
-    @ApiModelProperty("预警位置")
+    @TableField(exist = false)
+    @ApiModelProperty("预警位置(展示用,来源 equipment_base.equipment_location)")
     private String location;
 
     @TableField("ownership_unit")

+ 0 - 3
pipe-network-service/zksy-system/src/main/java/com/zksy/base/warning/domain/WarningArchive.java

@@ -40,9 +40,6 @@ public class WarningArchive implements Serializable {
     @TableField("warning_level")
     @ApiModelProperty("预警级别")
     private String warningLevel;
-    @TableField("location")
-    @ApiModelProperty("预警位置")
-    private String location;
 
     @TableField("ownership_unit")
     @ApiModelProperty("权属单位")

+ 0 - 2
pipe-network-service/zksy-system/src/main/java/com/zksy/base/warning/service/impl/EarlyWarningServiceImpl.java

@@ -382,8 +382,6 @@ public class EarlyWarningServiceImpl extends ServiceImpl<EarlyWarningMapper, Ear
         warningAccess.requireDeviceVisible(equipment.getEquipmentCode());
         warning.setDeviceCode(equipment.getEquipmentCode());
         warning.setDeviceName(equipment.getEquipmentName());
-        // 位置已从预警业务移除,兼容旧客户端时也不再写入。
-        warning.setLocation(null);
     }
 
     @Override

+ 3 - 3
pipe-network-service/zksy-system/src/main/java/com/zksy/cockpit/event/BusinessCockpitEventAdapter.java

@@ -247,7 +247,7 @@ public class BusinessCockpitEventAdapter {
                 null,
                 trimToNull(warning.getDeviceCode()),
                 firstNonBlank(warning.getDeviceName(), deviceName(warning.getDeviceCode(), facts)),
-                firstNonBlank(warning.getLocation(), point == null ? null : point.location));
+                point == null ? null : point.location);
     }
 
     private CockpitEventAlarm toEventAlarm(AlarmFact item, Facts facts) {
@@ -334,7 +334,7 @@ public class BusinessCockpitEventAdapter {
                 firstNonBlank(warning.getDeviceName(), deviceName(warning.getDeviceCode(), facts)),
                 point == null ? null : point.code,
                 point == null ? null : point.name,
-                firstNonBlank(warning.getLocation(), point == null ? null : point.location),
+                point == null ? null : point.location,
                 typeCode(warning.getDeviceCode(), facts),
                 deviceLongitude(warning.getDeviceCode(), facts),
                 deviceLatitude(warning.getDeviceCode(), facts),
@@ -432,7 +432,7 @@ public class BusinessCockpitEventAdapter {
                     trimToNull(warning.getDeviceCode()),
                     trimToNull(warning.getStatus()),
                     firstNonBlank(warning.getDeviceName(), deviceName(warning.getDeviceCode(), facts)),
-                    firstNonBlank(warning.getLocation(), point == null ? null : point.location),
+                    point == null ? null : point.location,
                     offsetTime(warning.getUpdateTime()),
                     districtCode(warning.getDeviceCode(), facts)));
         }

+ 14 - 11
pipe-network-service/zksy-system/src/main/resources/mapper/warning/EarlyWarningMapper.xml

@@ -32,10 +32,13 @@
         <result column="remark" property="remark"/>
     </resultMap>
 
+    <!-- 预警位置不再落库:统一由设备台账位置回填,出参字段名 location 保持不变。 -->
+    <sql id="DeviceLocationColumn">(SELECT e.equipment_location FROM app_user.equipment_base e WHERE e.equipment_code = w.device_code ORDER BY e.equipment_id LIMIT 1) AS location</sql>
+
     <sql id="Base_Column_List">
         warning_id, warning_no, warning_type, warning_level, warning_special,
         disposal_deadline, stage_deadline, item_id, item_snapshot, device_code, (SELECT e.equipment_name FROM app_user.equipment_base e WHERE e.equipment_code = w.device_code ORDER BY e.equipment_id LIMIT 1) AS device_name,
-        location, ownership_unit, publisher, publish_time, handler, reviewer,
+        <include refid="DeviceLocationColumn"/>, ownership_unit, publisher, publish_time, handler, reviewer,
         status, warning_content, process_instance_id, create_by, create_time, update_by,
         update_time, remark
     </sql>
@@ -63,7 +66,7 @@
             (SELECT dict_label FROM app_user.sys_dict_data WHERE dict_type='pre_alarm_status' AND dict_value=w.status AND status='0' ORDER BY dict_sort LIMIT 1) AS status_name,
         w.warning_level,
         w.warning_special,
-        w.location,
+        <include refid="DeviceLocationColumn"/>,
 
         w.ownership_unit,
         w.publisher,
@@ -769,7 +772,7 @@
     </select>
 
     <select id="selectWarningList" resultType="java.util.Map">
-        SELECT w.*, (SELECT e.equipment_name FROM app_user.equipment_base e WHERE e.equipment_code = w.device_code ORDER BY e.equipment_id LIMIT 1) AS device_name, (SELECT wt.warning_name FROM app_user.warning_type wt WHERE wt.warning_code=w.warning_type ORDER BY wt.id LIMIT 1) AS warning_type_name,
+        SELECT w.*, <include refid="DeviceLocationColumn"/>, (SELECT e.equipment_name FROM app_user.equipment_base e WHERE e.equipment_code = w.device_code ORDER BY e.equipment_id LIMIT 1) AS device_name, (SELECT wt.warning_name FROM app_user.warning_type wt WHERE wt.warning_code=w.warning_type ORDER BY wt.id LIMIT 1) AS warning_type_name,
             (SELECT dict_label FROM app_user.sys_dict_data WHERE dict_type='alert_level' AND dict_value=w.warning_level AND status='0' ORDER BY dict_sort LIMIT 1) AS warning_level_name,
             (SELECT dict_label FROM app_user.sys_dict_data WHERE dict_type='pre_alarm_status' AND dict_value=w.status AND status='0' ORDER BY dict_sort LIMIT 1) AS status_name
         FROM early_warning w
@@ -790,7 +793,7 @@
     </select>
 
     <select id="searchWarnings" resultType="java.util.Map">
-        SELECT w.*, (SELECT e.equipment_name FROM app_user.equipment_base e WHERE e.equipment_code = w.device_code ORDER BY e.equipment_id LIMIT 1) AS device_name, (SELECT wt.warning_name FROM app_user.warning_type wt WHERE wt.warning_code=w.warning_type ORDER BY wt.id LIMIT 1) AS warning_type_name,
+        SELECT w.*, <include refid="DeviceLocationColumn"/>, (SELECT e.equipment_name FROM app_user.equipment_base e WHERE e.equipment_code = w.device_code ORDER BY e.equipment_id LIMIT 1) AS device_name, (SELECT wt.warning_name FROM app_user.warning_type wt WHERE wt.warning_code=w.warning_type ORDER BY wt.id LIMIT 1) AS warning_type_name,
             (SELECT dict_label FROM app_user.sys_dict_data WHERE dict_type='alert_level' AND dict_value=w.warning_level AND status='0' ORDER BY dict_sort LIMIT 1) AS warning_level_name,
             (SELECT dict_label FROM app_user.sys_dict_data WHERE dict_type='pre_alarm_status' AND dict_value=w.status AND status='0' ORDER BY dict_sort LIMIT 1) AS status_name
         FROM early_warning w
@@ -855,7 +858,7 @@
             w.warning_level,
             w.handler,
             w.publisher,
-            w.location,
+            <include refid="DeviceLocationColumn"/>,
             w.ownership_unit,
             w.publish_time
         FROM warning_todo t
@@ -872,7 +875,7 @@
 
     <!-- 身份由服务端登录上下文传入,禁止使用请求中的 userName。 -->
     <select id="selectMyTasks" resultType="java.util.Map">
-        SELECT w.*, (SELECT e.equipment_name FROM app_user.equipment_base e WHERE e.equipment_code = w.device_code ORDER BY e.equipment_id LIMIT 1) AS device_name, (SELECT wt.warning_name FROM app_user.warning_type wt WHERE wt.warning_code=w.warning_type ORDER BY wt.id LIMIT 1) AS warning_type_name,
+        SELECT w.*, <include refid="DeviceLocationColumn"/>, (SELECT e.equipment_name FROM app_user.equipment_base e WHERE e.equipment_code = w.device_code ORDER BY e.equipment_id LIMIT 1) AS device_name, (SELECT wt.warning_name FROM app_user.warning_type wt WHERE wt.warning_code=w.warning_type ORDER BY wt.id LIMIT 1) AS warning_type_name,
             (SELECT dict_label FROM app_user.sys_dict_data WHERE dict_type='alert_level' AND dict_value=w.warning_level AND status='0' ORDER BY dict_sort LIMIT 1) AS warning_level_name,
             (SELECT dict_label FROM app_user.sys_dict_data WHERE dict_type='pre_alarm_status' AND dict_value=w.status AND status='0' ORDER BY dict_sort LIMIT 1) AS status_name, t.todo_id,
             <choose>
@@ -922,7 +925,7 @@
     </select>
 
     <select id="selectProcessingWarnings" resultType="java.util.Map">
-        SELECT w.*, (SELECT e.equipment_name FROM app_user.equipment_base e WHERE e.equipment_code = w.device_code ORDER BY e.equipment_id LIMIT 1) AS device_name, (SELECT wt.warning_name FROM app_user.warning_type wt WHERE wt.warning_code=w.warning_type ORDER BY wt.id LIMIT 1) AS warning_type_name,
+        SELECT w.*, <include refid="DeviceLocationColumn"/>, (SELECT e.equipment_name FROM app_user.equipment_base e WHERE e.equipment_code = w.device_code ORDER BY e.equipment_id LIMIT 1) AS device_name, (SELECT wt.warning_name FROM app_user.warning_type wt WHERE wt.warning_code=w.warning_type ORDER BY wt.id LIMIT 1) AS warning_type_name,
             (SELECT dict_label FROM app_user.sys_dict_data WHERE dict_type='alert_level' AND dict_value=w.warning_level AND status='0' ORDER BY dict_sort LIMIT 1) AS warning_level_name,
             (SELECT dict_label FROM app_user.sys_dict_data WHERE dict_type='pre_alarm_status' AND dict_value=w.status AND status='0' ORDER BY dict_sort LIMIT 1) AS status_name
         FROM early_warning w
@@ -940,7 +943,7 @@
     </select>
 
     <select id="selectCompletedWarnings" resultType="java.util.Map">
-        SELECT w.*, (SELECT e.equipment_name FROM app_user.equipment_base e WHERE e.equipment_code = w.device_code ORDER BY e.equipment_id LIMIT 1) AS device_name, (SELECT wt.warning_name FROM app_user.warning_type wt WHERE wt.warning_code=w.warning_type ORDER BY wt.id LIMIT 1) AS warning_type_name,
+        SELECT w.*, <include refid="DeviceLocationColumn"/>, (SELECT e.equipment_name FROM app_user.equipment_base e WHERE e.equipment_code = w.device_code ORDER BY e.equipment_id LIMIT 1) AS device_name, (SELECT wt.warning_name FROM app_user.warning_type wt WHERE wt.warning_code=w.warning_type ORDER BY wt.id LIMIT 1) AS warning_type_name,
             (SELECT dict_label FROM app_user.sys_dict_data WHERE dict_type='alert_level' AND dict_value=w.warning_level AND status='0' ORDER BY dict_sort LIMIT 1) AS warning_level_name,
             (SELECT dict_label FROM app_user.sys_dict_data WHERE dict_type='pre_alarm_status' AND dict_value=w.status AND status='0' ORDER BY dict_sort LIMIT 1) AS status_name
         FROM early_warning w
@@ -1019,7 +1022,7 @@
             w.warning_content AS "warningContent",
             w.device_code AS "deviceCode",
             (SELECT e.equipment_name FROM app_user.equipment_base e WHERE e.equipment_code = w.device_code ORDER BY e.equipment_id LIMIT 1) AS "deviceName",
-            w.location,
+            <include refid="DeviceLocationColumn"/>,
             w.status,
             w.create_by AS "createBy",
             w.publisher,
@@ -1095,7 +1098,7 @@
             COALESCE(NULLIF(TRIM(ru.nick_name), ''), w.reviewer) AS reviewer_name,
             COALESCE(NULLIF(TRIM(pu.nick_name), ''), w.publisher) AS publisher_name,
             COALESCE(NULLIF(TRIM(cu.nick_name), ''), w.create_by) AS creator_name,
-            COALESCE(eb.equipment_location, w.location) AS location
+            eb.equipment_location AS location
         FROM early_warning w
         LEFT JOIN app_user.sys_user hu ON hu.user_name = w.handler
         LEFT JOIN app_user.sys_user ru ON ru.user_name = w.reviewer
@@ -1115,7 +1118,7 @@
             COALESCE(NULLIF(TRIM(ru.nick_name), ''), w.reviewer) AS reviewer_name,
             COALESCE(NULLIF(TRIM(pu.nick_name), ''), w.publisher) AS publisher_name,
             COALESCE(NULLIF(TRIM(cu.nick_name), ''), w.create_by) AS creator_name,
-            COALESCE(eb.equipment_location, w.location) AS location
+            eb.equipment_location AS location
         FROM early_warning w
         LEFT JOIN app_user.sys_user hu ON hu.user_name = w.handler
         LEFT JOIN app_user.sys_user ru ON ru.user_name = w.reviewer

+ 2 - 2
zk-api-service/src/main/java/com/zksy/api/domain/EarlyWarning.java

@@ -55,8 +55,8 @@ public class EarlyWarning implements Serializable {
     private String deviceName;
 
 
-    @TableField("location")
-    @ApiModelProperty("预警位置")
+    @TableField(exist = false)
+    @ApiModelProperty("预警位置(展示用,来源 equipment_base.equipment_location)")
     private String location;
 
     @TableField("ownership_unit")