Quellcode durchsuchen

feat(warning): 新增发布页排序及参与人选择功能

- 预警搜索接口新增 releaseOrder 参数支持按状态优先级排序
- 实现草稿优先、已解除最后、按修改时间倒序的排序规则
- 新增预警参与人候选人实体及分页查询接口
- 新增部门树和用户列表接口供处置人、核查人选择使用
- 候选人查询支持按部门及关键字过滤
林仔 vor 5 Tagen
Ursprung
Commit
e5026de809

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

@@ -368,9 +368,10 @@ List<String> alarmIds = alarmIdsJson != null && !alarmIdsJson.isEmpty()
             @ApiParam("开始时间") @RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") LocalDateTime startTime,
             @ApiParam("结束时间") @RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") LocalDateTime endTime,
             @ApiParam("设备编码") @RequestParam(required = false) String deviceCode,
-            @ApiParam("设备名称") @RequestParam(required = false) String deviceName) {
+            @ApiParam("设备名称") @RequestParam(required = false) String deviceName,
+            @ApiParam("发布页排序:草稿优先,已解除最后,按修改时间倒序") @RequestParam(defaultValue = "false") boolean releaseOrder) {
         Page<?> page = new Page<>(pageNum, pageSize);
-        IPage<Map<String, Object>> result = earlyWarningService.searchWarnings(page, warningNo, warningType, warningLevel, status, publisher, ownershipUnit, startTime, endTime, excludePublisher, deviceCode, deviceName);
+        IPage<Map<String, Object>> result = earlyWarningService.searchWarnings(page, warningNo, warningType, warningLevel, status, publisher, ownershipUnit, startTime, endTime, excludePublisher, deviceCode, deviceName, releaseOrder);
         return AjaxResult.success(result);
     }
 

+ 34 - 0
pipe-network-service/zksy-admin/src/main/java/com/zksy/web/controller/warning/WarningParticipantController.java

@@ -0,0 +1,34 @@
+package com.zksy.web.controller.warning;
+
+import com.zksy.base.warning.service.WarningParticipantService;
+import com.zksy.common.core.domain.AjaxResult;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+/** 预警处置人、核查人选择,不要求用户管理权限。 */
+@RestController
+@RequestMapping("/warning/participants")
+@PreAuthorize("@ss.hasAnyPermi('warning:warning:add,warning:warning:edit,warning:warning:publish')")
+public class WarningParticipantController {
+    private final WarningParticipantService participants;
+
+    public WarningParticipantController(WarningParticipantService participants) {
+        this.participants = participants;
+    }
+
+    @GetMapping("/deptTree")
+    public AjaxResult departments() {
+        return AjaxResult.success(participants.departments());
+    }
+
+    @GetMapping("/users")
+    public AjaxResult users(@RequestParam(defaultValue = "1") int pageNum,
+                            @RequestParam(defaultValue = "10") int pageSize,
+                            @RequestParam(required = false) Long deptId,
+                            @RequestParam(required = false) String keyword) {
+        return AjaxResult.success(participants.users(pageNum, pageSize, deptId, keyword));
+    }
+}

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

@@ -0,0 +1,13 @@
+package com.zksy.base.warning.domain;
+
+import lombok.Data;
+
+/** 预警指派候选人,仅包含选择人员所需字段。 */
+@Data
+public class WarningParticipant {
+    private Long userId;
+    private String userName;
+    private String nickName;
+    private Long deptId;
+    private String deptName;
+}

+ 1 - 1
pipe-network-service/zksy-system/src/main/java/com/zksy/base/warning/mapper/EarlyWarningMapper.java

@@ -20,7 +20,7 @@ public interface EarlyWarningMapper extends BaseMapper<EarlyWarning> {
 
     IPage<Map<String, Object>> selectWarningList(Page<?> page, @Param("warningNo") String warningNo, @Param("warningType") String warningType, @Param("warningLevel") String warningLevel, @Param("status") String status);
 
-    IPage<Map<String, Object>> searchWarnings(Page<?> page, @Param("warningNo") String warningNo, @Param("warningType") String warningType, @Param("warningLevel") String warningLevel, @Param("status") String status, @Param("publisher") String publisher, @Param("ownershipUnit") String ownershipUnit, @Param("startTime") LocalDateTime startTime, @Param("endTime") LocalDateTime endTime, @Param("excludePublisher") String excludePublisher, @Param("deviceCode") String deviceCode, @Param("deviceName") String deviceName);
+    IPage<Map<String, Object>> searchWarnings(Page<?> page, @Param("warningNo") String warningNo, @Param("warningType") String warningType, @Param("warningLevel") String warningLevel, @Param("status") String status, @Param("publisher") String publisher, @Param("ownershipUnit") String ownershipUnit, @Param("startTime") LocalDateTime startTime, @Param("endTime") LocalDateTime endTime, @Param("excludePublisher") String excludePublisher, @Param("deviceCode") String deviceCode, @Param("deviceName") String deviceName, @Param("releaseOrder") boolean releaseOrder);
 
     IPage<Map<String, Object>> selectTodoList(Page<?> page, @Param("userId") String userId, @Param("todoType") String todoType, @Param("warningNo") String warningNo);
 

+ 13 - 0
pipe-network-service/zksy-system/src/main/java/com/zksy/base/warning/mapper/WarningParticipantMapper.java

@@ -0,0 +1,13 @@
+package com.zksy.base.warning.mapper;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.zksy.base.warning.domain.WarningParticipant;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+@Mapper
+public interface WarningParticipantMapper {
+    IPage<WarningParticipant> selectCandidates(Page<WarningParticipant> page,
+            @Param("deptId") Long deptId, @Param("keyword") String keyword);
+}

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

@@ -18,7 +18,7 @@ public interface EarlyWarningService extends IService<EarlyWarning> {
 
     IPage<Map<String, Object>> getWarningList(Page<?> page, String warningNo, String warningType, String warningLevel, String status);
 
-    IPage<Map<String, Object>> searchWarnings(Page<?> page, String warningNo, String warningType, String warningLevel, String status, String publisher, String ownershipUnit, LocalDateTime startTime, LocalDateTime endTime, String excludePublisher, String deviceCode, String deviceName);
+    IPage<Map<String, Object>> searchWarnings(Page<?> page, String warningNo, String warningType, String warningLevel, String status, String publisher, String ownershipUnit, LocalDateTime startTime, LocalDateTime endTime, String excludePublisher, String deviceCode, String deviceName, boolean releaseOrder);
 
     IPage<Map<String, Object>> getTodoList(Page<?> page, String userName, String todoType, String warningNo);
 

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

@@ -0,0 +1,46 @@
+package com.zksy.base.warning.service;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.zksy.base.warning.domain.WarningParticipant;
+import com.zksy.base.warning.mapper.WarningParticipantMapper;
+import com.zksy.common.core.domain.TreeSelect;
+import com.zksy.common.core.domain.entity.SysDept;
+import com.zksy.common.exception.ServiceException;
+import com.zksy.system.mapper.SysDeptMapper;
+import com.zksy.system.service.ISysDeptService;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/** 预警发布允许跨部门指派,业务候选查询不使用系统用户管理的数据范围。 */
+@Service
+public class WarningParticipantService {
+    private final SysDeptMapper deptMapper;
+    private final ISysDeptService deptService;
+    private final WarningParticipantMapper participantMapper;
+
+    public WarningParticipantService(SysDeptMapper deptMapper, ISysDeptService deptService,
+                                     WarningParticipantMapper participantMapper) {
+        this.deptMapper = deptMapper;
+        this.deptService = deptService;
+        this.participantMapper = participantMapper;
+    }
+
+    public List<TreeSelect> departments() {
+        SysDept query = new SysDept();
+        query.setStatus("0");
+        // 直接使用现有 Mapper 查询全部启用部门;只向客户端输出 id/label 树。
+        return deptService.buildDeptTreeSelect(deptMapper.selectDeptList(query));
+    }
+
+    public IPage<WarningParticipant> users(int pageNum, int pageSize, Long deptId, String keyword) {
+        if (deptId != null && deptId <= 0) throw new ServiceException("请选择有效部门");
+        if (keyword != null) {
+            keyword = keyword.trim();
+            if (keyword.length() > 100) throw new ServiceException("搜索关键字不能超过100个字符");
+        }
+        Page<WarningParticipant> page = new Page<>(Math.max(1, pageNum), Math.max(1, Math.min(100, pageSize)));
+        return participantMapper.selectCandidates(page, deptId, keyword);
+    }
+}

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

@@ -77,9 +77,9 @@ public class EarlyWarningServiceImpl extends ServiceImpl<EarlyWarningMapper, Ear
     }
 
     @Override
-    public IPage<Map<String, Object>> searchWarnings(Page<?> page, String warningNo, String warningType, String warningLevel, String status, String publisher, String ownershipUnit, LocalDateTime startTime, LocalDateTime endTime, String excludePublisher, String deviceCode, String deviceName) {
+    public IPage<Map<String, Object>> searchWarnings(Page<?> page, String warningNo, String warningType, String warningLevel, String status, String publisher, String ownershipUnit, LocalDateTime startTime, LocalDateTime endTime, String excludePublisher, String deviceCode, String deviceName, boolean releaseOrder) {
         reference.validateStatus(status);
-        return earlyWarningMapper.searchWarnings(page, warningNo, warningType, warningLevel, status, publisher, ownershipUnit, startTime, endTime, excludePublisher, deviceCode, deviceName);
+        return earlyWarningMapper.searchWarnings(page, warningNo, warningType, warningLevel, status, publisher, ownershipUnit, startTime, endTime, excludePublisher, deviceCode, deviceName, releaseOrder);
     }
 
     @Override

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

@@ -828,7 +828,21 @@
                 AND w.create_time &lt;= #{endTime}
             </if>
         </where>
-        ORDER BY w.create_time DESC
+        <choose>
+            <when test="releaseOrder">
+                ORDER BY CASE w.status
+                             WHEN 'DRAFT' THEN 0
+                             WHEN 'PENDING' THEN 1
+                             WHEN 'RECEIVED' THEN 2
+                             WHEN 'PROCESSING' THEN 3
+                             WHEN 'HANDLED' THEN 4
+                             WHEN 'CLOSED' THEN 5
+                             ELSE 6 END,
+                         COALESCE(w.update_time, w.create_time) DESC NULLS LAST,
+                         w.create_time DESC NULLS LAST, w.warning_id DESC
+            </when>
+            <otherwise>ORDER BY w.create_time DESC</otherwise>
+        </choose>
     </select>
 
     <select id="selectTodoList" resultType="java.util.Map">

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

@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.zksy.base.warning.mapper.WarningParticipantMapper">
+    <select id="selectCandidates" resultType="com.zksy.base.warning.domain.WarningParticipant">
+        SELECT u.user_id, u.user_name, u.nick_name, u.dept_id, d.dept_name
+        FROM app_user.sys_user u
+        JOIN app_user.sys_dept d ON d.dept_id = u.dept_id
+        WHERE u.status = '0' AND u.del_flag = '0'
+          AND d.status = '0' AND d.del_flag = '0'
+        <if test="deptId != null">
+          AND (d.dept_id = #{deptId}
+               OR POSITION(CONCAT(',', #{deptId}, ',') IN CONCAT(',', d.ancestors, ',')) &gt; 0)
+        </if>
+        <if test="keyword != null and keyword != ''">
+          AND (LOWER(u.user_name) LIKE CONCAT('%', LOWER(#{keyword}), '%')
+               OR LOWER(u.nick_name) LIKE CONCAT('%', LOWER(#{keyword}), '%'))
+        </if>
+        ORDER BY d.order_num, d.dept_id, u.user_name, u.user_id
+    </select>
+</mapper>