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

优化感知信息实时展示查下

zengy 1 неделя назад
Родитель
Сommit
1000f01720

+ 6 - 16
pipe-network-service/zksy-system/src/main/java/com/zksy/base/perception/service/impl/PerceptionServiceImpl.java

@@ -98,31 +98,21 @@ public class PerceptionServiceImpl implements PerceptionService {
         for (EquipmentBaseVO vo : basePage.getRecords()) {
             EquipmentRealtimeVO rv = new EquipmentRealtimeVO();
             BeanUtils.copyProperties(vo, rv);
-            rv.setLastCommTime(queryLastCommTime(vo.getEquipmentId()));
             records.add(rv);
         }
         result.setRecords(records);
         return result;
     }
 
-    private LocalDateTime queryLastCommTime(String equipmentId) {
-        EquipmentBase base = equipmentBaseMapper.selectById(equipmentId);
-        if (base == null) {
-            return null;
-        }
-        String table = resolveTable(base.getEquipmentTypeId());
-        if (table == null) {
+    private LocalDateTime queryLastCommTime(EquipmentBase base, String table) {
+        if (base == null || table == null) {
             return null;
         }
         return perceptionMapper.selectLastCommTime(table, TABLE_ID_COLUMN.get(table), base.getEquipmentCode());
     }
 
-    /** 由 equipment_type_id -> equipment_type.orig_coll_table 解析出原始采集表;不在白名单返回 null。 */
-    private String resolveTable(Integer equipmentTypeId) {
-        if (equipmentTypeId == null) {
-            return null;
-        }
-        EquipmentType type = equipmentTypeMapper.selectById(equipmentTypeId);
+    /** 由已加载的 equipment_type -> orig_coll_table 解析原始采集表;不在白名单返回 null。 */
+    private String resolveTable(EquipmentType type) {
         if (type == null || type.getOrigCollTable() == null) {
             return null;
         }
@@ -150,14 +140,14 @@ public class PerceptionServiceImpl implements PerceptionService {
             vo.setOnlineStatus(status.getOnlineStatus());
         }
         profile.setBase(vo);
-        profile.setLastCommTime(queryLastCommTime(equipmentId));
 
         EquipmentType type = equipmentTypeMapper.selectById(base.getEquipmentTypeId());
         if (type != null) {
             profile.setOrigCollTable(type.getOrigCollTable());
             vo.setEquipmentTypeName(type.getTypeName());
         }
-        String table = resolveTable(base.getEquipmentTypeId());
+        String table = resolveTable(type);
+        profile.setLastCommTime(queryLastCommTime(base, table));
         List<Map<String, Object>> rawRecords;
         if (table != null) {
             profile.setIdColumn(TABLE_ID_COLUMN.get(table));