Pārlūkot izejas kodu

Merge remote-tracking branch 'origin/master'

null 4 dienas atpakaļ
vecāks
revīzija
a07f2a13c5

+ 2 - 1
pipe-network-service/zksy-admin/src/main/java/com/zksy/web/controller/base/EquipmentBaseController.java

@@ -38,10 +38,11 @@ public class EquipmentBaseController {
                            @ApiParam("设备类型ID") @RequestParam(required = false) Integer equipmentTypeId,
                            @ApiParam("设备根类型ID(菜单 rootTypeId 数据范围过滤,空=全部)")
                            @RequestParam(required = false) Integer rootTypeId,
+                           @ApiParam("设备类型ID集合") @RequestParam(required = false) List<Integer> equipmentTypeIds,
                            @ApiParam("在线状态(0-离线,1-在线)") @RequestParam(required = false) Integer onlineStatus,
                            @ApiParam("报警状态(1-报警,仅勾选报警时传)") @RequestParam(required = false) Integer alarmStatus) throws Exception {
         return service.findByPage(pageNum, pageSize, equipmentCode, equipmentName, equipmentTypeId,
-                rootTypeId, onlineStatus, alarmStatus);
+                rootTypeId, equipmentTypeIds, onlineStatus, alarmStatus);
     }
 
 

+ 7 - 11
pipe-network-service/zksy-admin/src/main/java/com/zksy/web/controller/warning/EarlyWarningController.java

@@ -82,17 +82,6 @@ public class EarlyWarningController {
         return AjaxResult.success(result);
     }
 
-    @GetMapping("/detail/{warningId}")
-    @ApiOperation("预警详情")
-    @PreAuthorize("@ss.hasPermi('warning:warning:query')")
-    public AjaxResult getWarningDetail(@PathVariable String warningId) {
-        Map<String, Object> detail = earlyWarningService.getWarningDetail(warningId);
-        if (detail == null) {
-            return AjaxResult.error("预警信息不存在");
-        }
-        return AjaxResult.success(detail);
-    }
-
     @PostMapping("/save")
     @ApiOperation("保存预警信息")
     @Log(title = "保存预警信息", businessType = BusinessType.INSERT)
@@ -349,6 +338,13 @@ List<String> alarmIds = alarmIdsJson != null && !alarmIdsJson.isEmpty()
         return AjaxResult.success(result);
     }
 
+    @GetMapping("/config/equipment-type-ids")
+    @ApiOperation("获取预警类型可关联的设备类型")
+    @PreAuthorize("@ss.hasAnyPermi('warning:warning:add,warning:warning:edit,warning:warning:publish')")
+    public AjaxResult getEquipmentTypeIds(@RequestParam String warningType) {
+        return AjaxResult.success(reference.equipmentTypeIds(warningType));
+    }
+
     @GetMapping("/config/statuses")
     public AjaxResult statuses() { return AjaxResult.success(reference.statuses()); }
 

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

@@ -29,7 +29,8 @@ public interface EquipmentBaseService extends IService<EquipmentBase> {
     Page<EquipmentBaseVO> findByPage(long pageNum, long pageSize,
                                    String equipmentCode, String equipmentName,
                                    Integer equipmentTypeId, Integer rootTypeId,
-                Integer onlineStatus, Integer alarmStatus);
+                                   List<Integer> equipmentTypeIds,
+                                   Integer onlineStatus, Integer alarmStatus);
 
     /** 移动端日常设备查询:按当前用户公司范围过滤设备类型。 */
     Page<EquipmentBaseVO> findMobileByPage(long pageNum, long pageSize,

+ 7 - 0
pipe-network-service/zksy-system/src/main/java/com/zksy/base/service/impl/EquipmentBaseServiceImpl.java

@@ -92,6 +92,7 @@ public class EquipmentBaseServiceImpl extends ServiceImpl<EquipmentBaseMapper, E
     public Page<EquipmentBaseVO> findByPage(long pageNum, long pageSize,
                                           String equipmentCode, String equipmentName,
                                           Integer equipmentTypeId, Integer rootTypeId,
+                                          List<Integer> equipmentTypeIds,
                                           Integer onlineStatus, Integer alarmStatus) {
         Page<EquipmentBase> page = new Page<>(pageNum, pageSize);
         LambdaQueryWrapper<EquipmentBase> queryWrapper = new LambdaQueryWrapper<>();
@@ -104,6 +105,12 @@ public class EquipmentBaseServiceImpl extends ServiceImpl<EquipmentBaseMapper, E
         if (equipmentTypeId != null) {
             queryWrapper.eq(EquipmentBase::getEquipmentTypeId, equipmentTypeId);
         }
+        if (equipmentTypeIds != null) {
+            if (equipmentTypeIds.isEmpty()) {
+                return new Page<>(pageNum, pageSize, 0);
+            }
+            queryWrapper.in(EquipmentBase::getEquipmentTypeId, equipmentTypeIds);
+        }
         // 在线/报警条件位于 equipment_status,先取出命中的设备ID再回主表过滤
         if (onlineStatus != null || (alarmStatus != null && alarmStatus == 1)) {
             LambdaQueryWrapper<EquipmentStatus> statusWrapper = new LambdaQueryWrapper<>();

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

@@ -26,8 +26,6 @@ public interface EarlyWarningService extends IService<EarlyWarning> {
 
     boolean uploadReport(String warningId, List<MultipartFile> files);
 
-    Map<String, Object> getWarningDetail(String warningId);
-
     Map<String, Object> getWarningFullDetail(String warningId);
 
     boolean saveWarning(EarlyWarning warning, List<String> alarmIds, List<MultipartFile> files);

+ 27 - 0
pipe-network-service/zksy-system/src/main/java/com/zksy/base/warning/service/WarningReferenceService.java

@@ -2,6 +2,8 @@ package com.zksy.base.warning.service;
 
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.zksy.base.warning.domain.WarningType;
+import com.zksy.base.warning.domain.EquipmentWarningType;
+import com.zksy.base.warning.mapper.EquipmentWarningTypeMapper;
 import com.zksy.base.warning.mapper.WarningTypeMapper;
 import com.zksy.common.core.domain.entity.SysDictData;
 import com.zksy.common.exception.ServiceException;
@@ -14,6 +16,7 @@ import java.util.*;
 @Service
 public class WarningReferenceService {
     @Autowired private WarningTypeMapper typeMapper;
+    @Autowired private EquipmentWarningTypeMapper equipmentWarningTypeMapper;
     @Autowired private SysDictDataMapper dictMapper;
 
     public List<Map<String, Object>> types() {
@@ -31,6 +34,30 @@ public class WarningReferenceService {
 
     public List<SysDictData> statuses() { return dictMapper.selectDictDataByType("pre_alarm_status"); }
 
+    public List<Integer> equipmentTypeIds(String warningType) {
+        WarningType type = typeMapper.selectOne(new LambdaQueryWrapper<WarningType>()
+                .eq(WarningType::getWarningCode, warningType)
+                .last("LIMIT 1"));
+        if (type == null) {
+            throw new ServiceException("预警类型不存在");
+        }
+        List<Integer> result = new ArrayList<>();
+        for (EquipmentWarningType relation : equipmentWarningTypeMapper.selectList(
+                new LambdaQueryWrapper<EquipmentWarningType>()
+                        .eq(EquipmentWarningType::getWarningTypeId, type.getId()))) {
+            if (relation.getEquipmentTypeId() != null) {
+                result.add(relation.getEquipmentTypeId());
+            }
+        }
+        return result;
+    }
+
+    public void validateEquipmentType(String warningType, Integer equipmentTypeId) {
+        if (equipmentTypeId == null || !equipmentTypeIds(warningType).contains(equipmentTypeId)) {
+            throw new ServiceException("关联设备类型与预警类型不匹配,请重新选择");
+        }
+    }
+
     public void validateType(String type) {
         if (typeMapper.selectCount(new LambdaQueryWrapper<WarningType>().eq(WarningType::getWarningCode, type)) == 0)
             throw new ServiceException("请选择监测指标表中的预警类型");

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

@@ -103,18 +103,6 @@ public class EarlyWarningServiceImpl extends ServiceImpl<EarlyWarningMapper, Ear
         return result;
     }
 
-    @Override
-    public Map<String, Object> getWarningDetail(String warningId) {
-        Map<String, Object> detail = earlyWarningMapper.selectWarningDetail(warningId);
-        if (detail != null) {
-            addWorkflowActions(detail);
-            detail.put("attachmentList", getAttachmentList(warningId));
-            detail.put("disposalList", getDisposalList(warningId));
-            detail.put("alarmList", getLinkedAlarms(warningId));
-        }
-        return detail;
-    }
-
     @Override
     public Map<String, Object> getWarningFullDetail(String warningId) {
         Map<String, Object> result = new HashMap<>();
@@ -199,10 +187,9 @@ public class EarlyWarningServiceImpl extends ServiceImpl<EarlyWarningMapper, Ear
         reference.validateType(warning.getWarningType());
         bindRequiredDevice(warning);
         warning.setWarningId(null);
-        warning.setPublisher(null);
+        warning.setPublisher(currentUser());
         warning.setPublishTime(null);
         warning.setProcessInstanceId(null);
-        // 草稿可预选核查人;未选择时在发布时使用当前发布人。
         warning.setCreateBy(currentUser());
         warning.setUpdateBy(currentUser());
         warning.setWarningNo(generateWarningNo());
@@ -326,6 +313,7 @@ public class EarlyWarningServiceImpl extends ServiceImpl<EarlyWarningMapper, Ear
         if (equipment == null) {
             throw new ServiceException("关联设备不存在,请重新选择");
         }
+        reference.validateEquipmentType(warning.getWarningType(), equipment.getEquipmentTypeId());
         warning.setDeviceCode(equipment.getEquipmentCode());
         warning.setDeviceName(equipment.getEquipmentName());
         // 位置已从预警业务移除,兼容旧客户端时也不再写入。
@@ -416,7 +404,7 @@ public class EarlyWarningServiceImpl extends ServiceImpl<EarlyWarningMapper, Ear
 
         itemBinding.bind(warning);
         warning.setStatus(EarlyWarningStatusEnum.PENDING.getCode());
-        warning.setPublisher(currentUser());
+        warning.setPublisher(isBlank(warning.getCreateBy()) ? currentUser() : warning.getCreateBy());
         warning.setUpdateBy(currentUser());
         warning.setPublishTime(LocalDateTime.now());
         itemBinding.startPublished(warning, warning.getPublishTime());

+ 2 - 0
pipe-network-service/zksy-system/src/main/resources/mapper/warning/WarningDisposalMapper.xml

@@ -5,6 +5,7 @@
     <select id="selectDisposalList" resultType="java.util.Map">
         SELECT
             d.*,
+            COALESCE(NULLIF(TRIM(u.nick_name), ''), d.disposal_user) AS disposal_user_name,
             CASE d.disposal_type
                 WHEN 'RELEASE' THEN '发布预警'
                 WHEN 'RECEIVE' THEN '接收预警'
@@ -24,6 +25,7 @@
                 ELSE d.disposal_type
             END AS disposalTypeName
         FROM warning_disposal d
+        LEFT JOIN app_user.sys_user u ON u.user_name = d.disposal_user
         WHERE d.warning_id = #{warningId}
         ORDER BY d.create_time DESC
     </select>