Эх сурвалжийг харах

管网子系统-报警相关功能开发

zengy 1 долоо хоног өмнө
parent
commit
8c04a5baad

+ 1 - 2
pipe-network-service/zksy-system/src/main/java/com/zksy/base/alarm/dto/AlarmReviewQuery.java

@@ -8,8 +8,7 @@ import java.time.LocalDateTime;
 
 @Data
 public class AlarmReviewQuery {
-    @NotNull(message = "设备大类不能为空")
-    @ApiModelProperty("equipment_type.id,设备大类根ID")
+    @ApiModelProperty("设备大类根ID,equipment_type.id;为空表示查询全部子系统")
     private Integer rootTypeId;
     @ApiModelProperty("报警编码,精确匹配;燃气菜单限定 WARN-GAS-CONCENTRATION")
     @Size(max = 100)

+ 2 - 2
pipe-network-service/zksy-system/src/main/java/com/zksy/base/alarm/service/AlarmOperationsService.java

@@ -132,7 +132,7 @@ public class AlarmOperationsService {
         return result;
     }
     public List<AlarmVO> map(AlarmQuery query) {
-        requireWaterSubsystem(query);
+        if (query.getRootTypeId() != null) requireWaterSubsystem(query);
         query.setAlarmStatus(AlarmRecordStatusEnum.UNHANDLED.getCode());
         validate(query);
         List<AlarmVO> result = mapper.selectMap(query, scope.resolveOperations(query));
@@ -141,7 +141,7 @@ public class AlarmOperationsService {
         return result;
     }
     public Map<String, Object> analysis(String id, AlarmQuery query, AlarmSeriesPeriod period) {
-        requireWaterSubsystem(query);
+        if (query.getRootTypeId() != null) requireWaterSubsystem(query);
         AlarmVO alarm = detail(id, query);
         AlarmMetricSource source = AlarmMetricSource.fromCode(alarm.getWarningCode());
         Map<String, Object> result = new LinkedHashMap<>();

+ 18 - 12
pipe-network-service/zksy-system/src/main/java/com/zksy/base/alarm/service/AlarmReviewScopeService.java

@@ -48,13 +48,14 @@ public class AlarmReviewScopeService {
     /** 读取与审核授权独立,列表菜单不能授予跨系统审核能力。 */
     public List<Integer> resolveOperations(AlarmReviewQuery query) {
         return resolve(query, new HashSet<>(Arrays.asList("subSystem/alarm/common/remind", "subSystem/alarm/common/list",
-                "subSystem/drainage/alarm/analysis", "subSystem/drainage/alarm/alarmGIS",
+                "subSystem/alarm/common/analysis", "subSystem/alarm/common/alarmGIS",
                 "subSystem/waterSupply/alarm/alarmGIS")));
     }
 
     private List<Integer> resolve(AlarmReviewQuery query, Set<String> components) {
-        EquipmentTypeEnum root = EquipmentTypeEnum.getById(query.getRootTypeId());
-        if (root == null || !root.isRoot()) throw new ServiceException("无效的设备大类");
+        Integer rootTypeId = query.getRootTypeId();
+        EquipmentTypeEnum root = rootTypeId == null ? null : EquipmentTypeEnum.getById(rootTypeId);
+        if (rootTypeId != null && (root == null || !root.isRoot())) throw new ServiceException("无效的设备大类");
         if (!SecurityUtils.isAdmin(SecurityUtils.getUserId())) {
             boolean allowed = menuService.selectMenuList(SecurityUtils.getUserId()).stream()
                     .anyMatch(menu -> matches(menu, query, components));
@@ -62,15 +63,20 @@ public class AlarmReviewScopeService {
         }
         List<EquipmentType> types = typeMapper.selectList(null);
         Set<Integer> ids = new LinkedHashSet<>();
-        if (types.stream().noneMatch(type -> root.getId().equals(type.getId()))) return new ArrayList<>();
-        ids.add(root.getId());
-        boolean changed;
-        do {
-            changed = false;
-            for (EquipmentType type : types) {
-                if (type.getId() != null && ids.contains(type.getParentId())) changed |= ids.add(type.getId());
-            }
-        } while (changed);
+        if (root != null) {
+            if (types.stream().noneMatch(type -> root.getId().equals(type.getId()))) return new ArrayList<>();
+            ids.add(root.getId());
+            boolean changed;
+            do {
+                changed = false;
+                for (EquipmentType type : types) {
+                    if (type.getId() != null && ids.contains(type.getParentId())) changed |= ids.add(type.getId());
+                }
+            } while (changed);
+        } else {
+            // rootTypeId 为空:返回全部设备类型,支持"按全部子系统"查询
+            types.stream().map(EquipmentType::getId).filter(Objects::nonNull).forEach(ids::add);
+        }
         return new ArrayList<>(ids);
     }