LAPTOP-JI2IUVG1\26646 4 дней назад
Родитель
Сommit
c3375c18c1
15 измененных файлов с 529 добавлено и 132 удалено
  1. 2 1
      pipe-network-service/zksy-admin/src/main/java/com/zksy/ZksyApplication.java
  2. 1 1
      pipe-network-service/zksy-admin/src/main/java/com/zksy/web/controller/alarm/AlarmController.java
  3. 3 2
      pipe-network-service/zksy-admin/src/main/java/com/zksy/web/controller/base/alarm/AlarmDataController.java
  4. 57 0
      pipe-network-service/zksy-admin/src/main/java/com/zksy/web/controller/drainage/DrainageEquipmentTypeController.java
  5. 29 0
      pipe-network-service/zksy-admin/src/main/java/com/zksy/web/controller/drainage/DrainagePartitionController.java
  6. 174 0
      pipe-network-service/zksy-admin/src/main/java/com/zksy/web/controller/drainage/DrainagePumpStationController.java
  7. 15 9
      pipe-network-service/zksy-admin/src/main/java/com/zksy/web/controller/drainage/DrainageWarningController.java
  8. 15 0
      pipe-network-service/zksy-admin/src/main/java/com/zksy/web/controller/drainage/EngineeringFacilityController.java
  9. 28 0
      pipe-network-service/zksy-admin/src/main/java/com/zksy/web/controller/drainage/PipeNetworkInfoController.java
  10. 16 0
      pipe-network-service/zksy-system/src/main/java/com/zksy/base/alarm/domain/AlarmData.java
  11. 2 1
      pipe-network-service/zksy-system/src/main/java/com/zksy/base/alarm/service/AlarmDataService.java
  12. 80 4
      pipe-network-service/zksy-system/src/main/java/com/zksy/base/alarm/service/impl/AlarmDataServiceImpl.java
  13. 24 13
      pipe-network-service/zksy-system/src/main/java/com/zksy/drainage/domain/DrainageWarning.java
  14. 29 20
      pipe-network-service/zksy-system/src/main/java/com/zksy/drainage/service/DrainageWarningService.java
  15. 54 81
      pipe-network-service/zksy-system/src/main/java/com/zksy/drainage/service/impl/DrainageWarningServiceImpl.java

+ 2 - 1
pipe-network-service/zksy-admin/src/main/java/com/zksy/ZksyApplication.java

@@ -10,7 +10,8 @@ import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
  * @author zksy
  */
 @SpringBootApplication(exclude = { DataSourceAutoConfiguration.class })
-public class ZksyApplication
+public class
+ZksyApplication
 {
     public static void main(String[] args)
     {

+ 1 - 1
pipe-network-service/zksy-admin/src/main/java/com/zksy/web/controller/alarm/AlarmController.java

@@ -32,7 +32,7 @@ public class AlarmController {
                                   @ApiParam("每页条数") long pageSize,
                                   @RequestParam(required = false) String warningType,
                                   @RequestParam(required = false) Integer alarmStatus) {
-        Page<AlarmData> page = service.findByPage(pageNum, pageSize, null, warningType, null, alarmStatus);
+        Page<AlarmData> page = service.findByPage(pageNum, pageSize, null, warningType, null, alarmStatus, null);
         return AjaxResult.success(page);
     }
 

+ 3 - 2
pipe-network-service/zksy-admin/src/main/java/com/zksy/web/controller/base/alarm/AlarmDataController.java

@@ -28,8 +28,9 @@ public class AlarmDataController {
                                  @ApiParam(value = "设备编码", required = false) String deviceCode,
                                  @ApiParam(value = "预警类型", required = false) String warningType,
                                  @ApiParam(value = "预警编码", required = false) String warningCode,
-                                 @ApiParam(value = "报警状态 0-未处理 1-已处理", required = false) Integer alarmStatus) {
-        return AjaxResult.success(service.findByPage(pageNum, pageSize, deviceCode, warningType, warningCode, alarmStatus));
+                                 @ApiParam(value = "报警状态 0-未处理 1-已处理", required = false) Integer alarmStatus,
+                                 @ApiParam(value = "设备类型(如drainage)", required = false) String equipmentType) {
+        return AjaxResult.success(service.findByPage(pageNum, pageSize, deviceCode, warningType, warningCode, alarmStatus, equipmentType));
     }
 
     @GetMapping("/getAlarmDataList")

+ 57 - 0
pipe-network-service/zksy-admin/src/main/java/com/zksy/web/controller/drainage/DrainageEquipmentTypeController.java

@@ -0,0 +1,57 @@
+package com.zksy.web.controller.drainage;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.zksy.base.domain.EquipmentType;
+import com.zksy.base.service.EquipmentTypeService;
+import com.zksy.common.annotation.Anonymous;
+import com.zksy.common.core.domain.AjaxResult;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+/**
+ * 排水设备类型查询(用于预警类型映射)
+ */
+@Slf4j
+@RestController
+@RequestMapping("/api/drainage/equipmentType")
+@Api(tags = "排水设备类型查询")
+public class DrainageEquipmentTypeController {
+
+    @Autowired
+    private EquipmentTypeService equipmentTypeService;
+
+    /**
+     * 查询设备类型列表(按 parentTypeId 过滤)
+     * 注意:@GetMapping("/list") 必须在 @GetMapping("/{id}") 之前定义
+     */
+    @Anonymous
+    @GetMapping("/list")
+    @ApiOperation(value = "查询设备类型列表(按父类型ID过滤)")
+    public AjaxResult list(
+            @ApiParam("父类型ID(如2为排水子类型)") @RequestParam(required = false) String parentTypeId) {
+        LambdaQueryWrapper<EquipmentType> wrapper = new LambdaQueryWrapper<>();
+        if (parentTypeId != null && !parentTypeId.isEmpty()) {
+            wrapper.eq(EquipmentType::getParentTypeId, parentTypeId);
+        }
+        wrapper.orderByAsc(EquipmentType::getId);
+        List<EquipmentType> list = equipmentTypeService.list(wrapper);
+        return AjaxResult.success(list);
+    }
+
+    @Anonymous
+    @GetMapping("/{id}")
+    @ApiOperation(value = "根据ID查询设备类型")
+    public AjaxResult getById(@PathVariable String id) {
+        EquipmentType entity = equipmentTypeService.getById(id);
+        if (entity == null) {
+            return AjaxResult.error("该设备类型不存在");
+        }
+        return AjaxResult.success(entity);
+    }
+}

+ 29 - 0
pipe-network-service/zksy-admin/src/main/java/com/zksy/web/controller/drainage/DrainagePartitionController.java

@@ -42,6 +42,34 @@ public class DrainagePartitionController {
         return service.findByPage(pageNum, pageSize, name, district, partitionType);
     }
 
+    /**
+     * 查询所有已被关联的设备ID列表
+     * 返回 Map: { equipmentId -> 关联的分区名称 }
+     * 可选excludeId参数排除某个分区自己的关联
+     */
+    @Anonymous
+    @GetMapping("/boundEquipmentIds")
+    @ApiOperation(value = "查询所有已关联的设备ID")
+    public AjaxResult boundEquipmentIds(
+            @ApiParam("排除的分区ID") @RequestParam(required = false) String excludeId) {
+        List<DrainagePartition> all = service.list();
+        Map<String, String> boundMap = new java.util.HashMap<>();
+        for (DrainagePartition p : all) {
+            if (p.getEquipmentId() != null && !p.getEquipmentId().isEmpty()) {
+                // 排除当前分区自己的关联
+                if (excludeId != null && p.getId().equals(excludeId)) continue;
+                String[] ids = p.getEquipmentId().split(",");
+                for (String id : ids) {
+                    String trimId = id.trim();
+                    if (!trimId.isEmpty()) {
+                        boundMap.put(trimId, p.getName() != null ? p.getName() : "");
+                    }
+                }
+            }
+        }
+        return AjaxResult.success(boundMap);
+    }
+
     @Anonymous
     @GetMapping("/{id}")
     @ApiOperation(value = "查询排水分区详情")
@@ -113,4 +141,5 @@ public class DrainagePartitionController {
         boolean success = service.bindEquipment(partitionId, equipmentIds);
         return success ? AjaxResult.success() : AjaxResult.error("绑定失败");
     }
+
 }

+ 174 - 0
pipe-network-service/zksy-admin/src/main/java/com/zksy/web/controller/drainage/DrainagePumpStationController.java

@@ -0,0 +1,174 @@
+package com.zksy.web.controller.drainage;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.zksy.WaterSupply.WaterPumpStation.domain.WaterPumpStation;
+import com.zksy.WaterSupply.WaterPumpStation.service.IWaterPumpStationService;
+import com.zksy.common.annotation.Anonymous;
+import com.zksy.common.core.domain.AjaxResult;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.util.StringUtils;
+import org.springframework.web.bind.annotation.*;
+
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.YearMonth;
+import java.time.format.DateTimeFormatter;
+import java.util.*;
+import java.util.stream.Collectors;
+
+/**
+ * 排水系统-泵站数据接口
+ */
+@Anonymous
+@RestController
+@RequestMapping("/api/drainage/pumpStation")
+@Api(tags = "排水系统-泵站数据接口")
+public class DrainagePumpStationController {
+
+    @Autowired
+    private IWaterPumpStationService waterPumpStationService;
+
+    /**
+     * 分页查询泵站列表
+     */
+    @GetMapping("/page")
+    @ApiOperation(value = "分页查询泵站列表")
+    public AjaxResult page(
+            @ApiParam("页码") @RequestParam(defaultValue = "1") Integer pageNum,
+            @ApiParam("每页条数") @RequestParam(defaultValue = "10") Integer pageSize,
+            @ApiParam("泵站名称") @RequestParam(required = false) String stationName,
+            @ApiParam("泵站编号") @RequestParam(required = false) String stationCode,
+            @ApiParam("运行状态") @RequestParam(required = false) String status) {
+
+        Page<WaterPumpStation> page = new Page<>(pageNum, pageSize);
+        LambdaQueryWrapper<WaterPumpStation> wrapper = new LambdaQueryWrapper<>();
+
+        if (StringUtils.hasText(stationName)) {
+            wrapper.like(WaterPumpStation::getStationName, stationName);
+        }
+        if (StringUtils.hasText(stationCode)) {
+            wrapper.eq(WaterPumpStation::getStationCode, stationCode);
+        }
+        if (StringUtils.hasText(status)) {
+            wrapper.eq(WaterPumpStation::getStatus, status);
+        }
+        wrapper.eq(WaterPumpStation::getDelFlag, "0");
+        wrapper.orderByDesc(WaterPumpStation::getCreateTime);
+
+        Page<WaterPumpStation> result = waterPumpStationService.page(page, wrapper);
+        return AjaxResult.success(result);
+    }
+
+    /**
+     * 查询所有泵站(不分页)
+     */
+    @GetMapping("/list")
+    @ApiOperation(value = "查询所有泵站列表(不分页)")
+    public AjaxResult list(
+            @ApiParam("泵站名称") @RequestParam(required = false) String stationName,
+            @ApiParam("运行状态") @RequestParam(required = false) String status) {
+
+        LambdaQueryWrapper<WaterPumpStation> wrapper = new LambdaQueryWrapper<>();
+        if (StringUtils.hasText(stationName)) {
+            wrapper.like(WaterPumpStation::getStationName, stationName);
+        }
+        if (StringUtils.hasText(status)) {
+            wrapper.eq(WaterPumpStation::getStatus, status);
+        }
+        wrapper.eq(WaterPumpStation::getDelFlag, "0");
+        wrapper.orderByDesc(WaterPumpStation::getCreateTime);
+
+        List<WaterPumpStation> list = waterPumpStationService.list(wrapper);
+        return AjaxResult.success(list);
+    }
+
+    /**
+     * 根据ID查询泵站详情
+     */
+    @GetMapping("/{id}")
+    @ApiOperation(value = "根据ID查询泵站详情")
+    public AjaxResult getById(@PathVariable Long id) {
+        WaterPumpStation station = waterPumpStationService.getById(id);
+        if (station == null) {
+            return AjaxResult.error("泵站不存在");
+        }
+        return AjaxResult.success(station);
+    }
+
+    /**
+     * 泵站月度统计(近三个月),按泵站ID列表查询
+     * 返回每个月内已关联的泵站的设计流量和设计扬程汇总
+     * sinceDate: 关联起始日期(yyyy-MM-dd),只统计该日期所在月份及之后的数据
+     */
+    @GetMapping("/monthlyStats")
+    @ApiOperation(value = "泵站近三个月月度统计")
+    public AjaxResult monthlyStats(
+            @ApiParam("泵站ID列表,逗号分隔") @RequestParam String ids,
+            @ApiParam("关联起始日期yyyy-MM-dd") @RequestParam(required = false) String sinceDate) {
+
+        if (!StringUtils.hasText(ids)) {
+            return AjaxResult.success(Collections.emptyList());
+        }
+
+        // 解析ID列表
+        List<Long> idList = Arrays.stream(ids.split(","))
+                .map(String::trim)
+                .filter(s -> !s.isEmpty())
+                .map(Long::parseLong)
+                .collect(Collectors.toList());
+
+        if (idList.isEmpty()) {
+            return AjaxResult.success(Collections.emptyList());
+        }
+
+        // 查询这些泵站
+        List<WaterPumpStation> stations = waterPumpStationService.listByIds(idList);
+
+        // 解析关联起始月份
+        YearMonth sinceMonth = null;
+        if (StringUtils.hasText(sinceDate)) {
+            try {
+                LocalDate sd = LocalDate.parse(sinceDate);
+                sinceMonth = YearMonth.from(sd);
+            } catch (Exception e) {
+                // 忽略解析失败
+            }
+        }
+
+        // 计算近三个月
+        YearMonth now = YearMonth.now();
+        DateTimeFormatter fmt = DateTimeFormatter.ofPattern("yyyy-MM");
+        List<Map<String, Object>> result = new ArrayList<>();
+
+        for (int i = 2; i >= 0; i--) {
+            YearMonth ym = now.minusMonths(i);
+            String month = ym.format(fmt);
+
+            double totalFlow = 0;
+            double totalHead = 0;
+            int count = 0;
+
+            // 如果指定了sinceDate,该月份早于sinceDate所在月则数据为0
+            if (sinceMonth == null || !ym.isBefore(sinceMonth)) {
+                for (WaterPumpStation s : stations) {
+                    totalFlow += s.getDesignFlow() != null ? s.getDesignFlow().doubleValue() : 0;
+                    totalHead += s.getDesignHead() != null ? s.getDesignHead().doubleValue() : 0;
+                    count++;
+                }
+            }
+
+            Map<String, Object> item = new LinkedHashMap<>();
+            item.put("month", month);
+            item.put("designFlow", totalFlow);
+            item.put("designHead", totalHead);
+            item.put("stationCount", count);
+            result.add(item);
+        }
+
+        return AjaxResult.success(result);
+    }
+}

+ 15 - 9
pipe-network-service/zksy-admin/src/main/java/com/zksy/web/controller/drainage/DrainageWarningController.java

@@ -39,7 +39,7 @@ public class DrainageWarningController {
             @ApiParam("每页数量") @RequestParam(defaultValue = "10") long pageSize,
             @ApiParam("预警级别(1严重,2重要,3一般)") @RequestParam(required = false) Integer warningLevel,
             @ApiParam("预警类型") @RequestParam(required = false) String warningType,
-            @ApiParam("状态(0待处理,1已处理,2已完成)") @RequestParam(required = false) Integer status,
+            @ApiParam("状态(DRAFT/PENDING/PROCESSING/RELEASED/HANDLED/CLOSED)") @RequestParam(required = false) String status,
             @ApiParam("开始时间(yyyy-MM-dd HH:mm:ss)") @RequestParam(required = false) String startTime,
             @ApiParam("结束时间(yyyy-MM-dd HH:mm:ss)") @RequestParam(required = false) String endTime) {
         return service.findByPage(pageNum, pageSize, warningLevel, warningType, status, startTime, endTime);
@@ -47,7 +47,7 @@ public class DrainageWarningController {
 
     @Anonymous
     @GetMapping("/current/page")
-    @ApiOperation(value = "查询当前预警(按用户可见性过滤,包含所有状态)")
+    @ApiOperation(value = "查询当前预警(按用户可见性过滤)")
     public Page<DrainageWarning> currentPage(
             @ApiParam("页码") @RequestParam(defaultValue = "1") long pageNum,
             @ApiParam("每页数量") @RequestParam(defaultValue = "10") long pageSize,
@@ -56,22 +56,28 @@ public class DrainageWarningController {
             @ApiParam("当前用户ID") @RequestParam(required = false) Long userId,
             @ApiParam("当前用户部门ID") @RequestParam(required = false) Long deptId,
             @ApiParam("是否管理员") @RequestParam(defaultValue = "false") boolean isAdmin,
-            @ApiParam("状态筛选(0待处理,1已处理,2已完成),不传则返回所有状态") @RequestParam(required = false) Integer status) {
-        return service.findVisibleCurrentPage(pageNum, pageSize, userId, deptId, isAdmin, warningLevel, warningType, status);
+            @ApiParam("状态筛选(DRAFT/PENDING/PROCESSING/RELEASED),不传则返回所有当前状态") @RequestParam(required = false) String status,
+            @ApiParam("是否只返回当前预警") @RequestParam(defaultValue = "false") boolean currentOnly,
+            @ApiParam("设备名称") @RequestParam(required = false) String equipmentName,
+            @ApiParam("开始时间(yyyy-MM-dd HH:mm:ss)") @RequestParam(required = false) String startTime,
+            @ApiParam("结束时间(yyyy-MM-dd HH:mm:ss)") @RequestParam(required = false) String endTime) {
+        return service.findVisibleCurrentPage(pageNum, pageSize, userId, deptId, isAdmin, warningLevel, warningType, status, currentOnly, equipmentName, startTime, endTime);
     }
 
     @Anonymous
     @GetMapping("/history/page")
-    @ApiOperation(value = "查询历史预警(status>=2,已完成)")
+    @ApiOperation(value = "查询历史预警(status IN HANDLED/CLOSED)")
     public Page<DrainageWarning> historyPage(
             @ApiParam("页码") @RequestParam(defaultValue = "1") long pageNum,
             @ApiParam("每页数量") @RequestParam(defaultValue = "10") long pageSize,
             @ApiParam("预警级别(1严重,2重要,3一般)") @RequestParam(required = false) Integer warningLevel,
             @ApiParam("预警类型") @RequestParam(required = false) String warningType,
-            @ApiParam("状态(1已处理,2已完成)") @RequestParam(required = false) Integer status,
+            @ApiParam("状态(HANDLED/CLOSED)") @RequestParam(required = false) String status,
             @ApiParam("开始时间(yyyy-MM-dd HH:mm:ss)") @RequestParam(required = false) String startTime,
-            @ApiParam("结束时间(yyyy-MM-dd HH:mm:ss)") @RequestParam(required = false) String endTime) {
-        return service.findHistoryPage(pageNum, pageSize, warningLevel, warningType, status, startTime, endTime);
+            @ApiParam("结束时间(yyyy-MM-dd HH:mm:ss)") @RequestParam(required = false) String endTime,
+            @ApiParam("是否只返回历史预警") @RequestParam(defaultValue = "false") boolean historyOnly,
+            @ApiParam("设备名称") @RequestParam(required = false) String equipmentName) {
+        return service.findHistoryPage(pageNum, pageSize, warningLevel, warningType, status, startTime, endTime, historyOnly, equipmentName);
     }
 
     @Anonymous
@@ -112,7 +118,7 @@ public class DrainageWarningController {
     @Transactional
     public AjaxResult updateStatus(
             @PathVariable String id,
-            @ApiParam("新状态(0待处理,1已处理,2已完成)") @RequestParam Integer status,
+            @ApiParam("新状态(DRAFT/PENDING/PROCESSING/RELEASED/HANDLED/CLOSED)") @RequestParam String status,
             @ApiParam("处理人") @RequestParam(required = false) String processor) {
         boolean updated = service.updateStatus(id, status, processor);
         return updated ? AjaxResult.success("状态更新成功") : AjaxResult.error("状态更新失败");

+ 15 - 0
pipe-network-service/zksy-admin/src/main/java/com/zksy/web/controller/drainage/EngineeringFacilityController.java

@@ -113,4 +113,19 @@ public class EngineeringFacilityController {
         boolean success = service.bindEquipment(partitionId, equipmentIds);
         return success ? AjaxResult.success() : AjaxResult.error("绑定失败");
     }
+
+    @Anonymous
+    @PostMapping("/bindPumpStation")
+    @ApiOperation(value = "工程设施关联泵站")
+    public AjaxResult bindPumpStation(@RequestBody Map<String, Object> params) {
+        String facilityId = (String) params.get("partitionId");
+        @SuppressWarnings("unchecked")
+        List<String> pumpStationIds = (List<String>) params.get("equipmentIds");
+        if (facilityId == null || pumpStationIds == null || pumpStationIds.isEmpty()) {
+            return AjaxResult.error("参数不完整");
+        }
+        // 复用bindEquipment,直接存储泵站ID到equipmentId字段,不做设备表校验
+        boolean success = service.bindEquipment(facilityId, pumpStationIds);
+        return success ? AjaxResult.success("关联成功") : AjaxResult.error("关联失败");
+    }
 }

+ 28 - 0
pipe-network-service/zksy-admin/src/main/java/com/zksy/web/controller/drainage/PipeNetworkInfoController.java

@@ -42,6 +42,34 @@ public class PipeNetworkInfoController {
         return service.findByPage(pageNum, pageSize, name, area, networkType);
     }
 
+    /**
+     * 查询所有已被关联的设备ID列表
+     * 返回 Map: { equipmentId -> 关联的管网名称 }
+     * 可选excludeId参数排除某个管网自己的关联
+     */
+    @Anonymous
+    @GetMapping("/boundEquipmentIds")
+    @ApiOperation(value = "查询所有已关联的设备ID")
+    public AjaxResult boundEquipmentIds(
+            @ApiParam("排除的管网ID") @RequestParam(required = false) String excludeId) {
+        List<PipeNetworkInfo> all = service.list();
+        Map<String, String> boundMap = new java.util.HashMap<>();
+        for (PipeNetworkInfo p : all) {
+            if (p.getEquipmentId() != null && !p.getEquipmentId().isEmpty()) {
+                // 排除当前管网自己的关联
+                if (excludeId != null && p.getId().equals(excludeId)) continue;
+                String[] ids = p.getEquipmentId().split(",");
+                for (String id : ids) {
+                    String trimId = id.trim();
+                    if (!trimId.isEmpty()) {
+                        boundMap.put(trimId, p.getName() != null ? p.getName() : "");
+                    }
+                }
+            }
+        }
+        return AjaxResult.success(boundMap);
+    }
+
     @Anonymous
     @GetMapping("/{id}")
     @ApiOperation(value = "查询排水管网详情")

+ 16 - 0
pipe-network-service/zksy-system/src/main/java/com/zksy/base/alarm/domain/AlarmData.java

@@ -23,6 +23,14 @@ public class AlarmData implements Serializable {
     @ApiModelProperty(value = "设备编码")
     private String deviceCode;
 
+    @TableField(value = "device_name")
+    @ApiModelProperty(value = "设备名称")
+    private String deviceName;
+
+    @TableField(value = "device_type")
+    @ApiModelProperty(value = "设备类型")
+    private String deviceType;
+
     @TableField(value = "warning_type")
     @ApiModelProperty(value = "预警类型")
     private String warningType;
@@ -87,6 +95,14 @@ public class AlarmData implements Serializable {
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
     private LocalDateTime updateTime;
 
+    @TableField(exist = false)
+    @ApiModelProperty(value = "经度")
+    private String longitude;
+
+    @TableField(exist = false)
+    @ApiModelProperty(value = "纬度")
+    private String latitude;
+
     @TableField(exist = false)
     private static final long serialVersionUID = 1L;
 }

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

@@ -8,7 +8,8 @@ import java.util.List;
 
 public interface AlarmDataService extends IService<AlarmData> {
     Page<AlarmData> findByPage(long pageNum, long pageSize, String deviceCode, 
-                                 String warningType, String warningCode, Integer alarmStatus);
+                                 String warningType, String warningCode, Integer alarmStatus,
+                                 String equipmentType);
     
     List<AlarmData> getAlarmDataList(String deviceCode, 
                                        String warningType, String warningCode, Integer alarmStatus);

+ 80 - 4
pipe-network-service/zksy-system/src/main/java/com/zksy/base/alarm/service/impl/AlarmDataServiceImpl.java

@@ -6,27 +6,103 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.zksy.base.alarm.domain.AlarmData;
 import com.zksy.base.alarm.mapper.AlarmDataMapper;
 import com.zksy.base.alarm.service.AlarmDataService;
+import com.zksy.base.domain.EquipmentBase;
+import com.zksy.base.mapper.EquipmentBaseMapper;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import java.time.LocalDateTime;
 import java.util.List;
+import java.util.stream.Collectors;
 
 @Service
 public class AlarmDataServiceImpl extends ServiceImpl<AlarmDataMapper, AlarmData>
     implements AlarmDataService {
 
+    @Autowired
+    private EquipmentBaseMapper equipmentBaseMapper;
+
     @Override
     public Page<AlarmData> findByPage(long pageNum, long pageSize, String deviceCode, 
                                         String warningType, String warningCode, 
-                                        Integer alarmStatus) {
+                                        Integer alarmStatus, String equipmentType) {
         Page<AlarmData> page = new Page<>(pageNum, pageSize);
         LambdaQueryWrapper<AlarmData> queryWrapper = new LambdaQueryWrapper<>();
+
+        // 当传入 equipmentType='drainage' 时,通过 equipment_base 关联查询排水类设备编码列表
+        // alarm_data 表的 warning_type 字段含义不同于 early_warning 表,不能直接用 '2' 过滤
+        if ("drainage".equals(equipmentType)) {
+            LambdaQueryWrapper<EquipmentBase> eqQuery = new LambdaQueryWrapper<>();
+            eqQuery.in(EquipmentBase::getEquipmentTypeId, "6", "7", "8", "9")
+                   .select(EquipmentBase::getEquipmentCode);
+            List<EquipmentBase> devices = equipmentBaseMapper.selectList(eqQuery);
+            List<String> deviceCodes = devices.stream()
+                    .map(EquipmentBase::getEquipmentCode)
+                    .filter(code -> code != null && !code.isEmpty())
+                    .collect(Collectors.toList());
+            if (deviceCodes.isEmpty()) {
+                // 没有排水类设备,直接返回空结果
+                return new Page<>(pageNum, pageSize);
+            }
+            queryWrapper.in(AlarmData::getDeviceCode, deviceCodes);
+        }
+
         queryWrapper.like(deviceCode != null, AlarmData::getDeviceCode, deviceCode)
                 .like(warningType != null, AlarmData::getWarningType, warningType)
                 .like(warningCode != null, AlarmData::getWarningCode, warningCode)
-                .eq(alarmStatus != null, AlarmData::getAlarmStatus, alarmStatus);
-        queryWrapper.orderByDesc(AlarmData::getAlarmTime);
-        return this.page(page, queryWrapper);
+                .eq(alarmStatus != null, AlarmData::getAlarmStatus, alarmStatus)
+                .orderByDesc(AlarmData::getAlarmTime);
+        Page<AlarmData> result = this.page(page, queryWrapper);
+
+        // 填充 deviceName/longitude/latitude:通过 device_code 从 equipment_base 表关联查询
+        fillDeviceInfo(result.getRecords());
+
+        return result;
+    }
+
+    /**
+     * 根据 deviceCode 从 equipment_base 表批量填充 deviceName、longitude、latitude
+     */
+    private void fillDeviceInfo(List<AlarmData> records) {
+        if (records == null || records.isEmpty()) {
+            return;
+        }
+        // 收集所有非空的 deviceCode
+        List<String> codes = records.stream()
+                .map(AlarmData::getDeviceCode)
+                .filter(code -> code != null && !code.isEmpty())
+                .distinct()
+                .collect(Collectors.toList());
+        if (codes.isEmpty()) {
+            return;
+        }
+        // 批量查询 equipment_base
+        LambdaQueryWrapper<EquipmentBase> eqWrapper = new LambdaQueryWrapper<>();
+        eqWrapper.in(EquipmentBase::getEquipmentCode, codes)
+                 .select(EquipmentBase::getEquipmentCode, EquipmentBase::getEquipmentName,
+                         EquipmentBase::getLongitude, EquipmentBase::getLatitude);
+        List<EquipmentBase> equipmentList = equipmentBaseMapper.selectList(eqWrapper);
+        // 构建 code -> EquipmentBase 映射
+        java.util.Map<String, EquipmentBase> codeEquipMap = equipmentList.stream()
+                .filter(e -> e.getEquipmentCode() != null)
+                .collect(Collectors.toMap(EquipmentBase::getEquipmentCode, e -> e, (a, b) -> a));
+        // 回填 deviceName、longitude、latitude
+        for (AlarmData record : records) {
+            if (record.getDeviceCode() != null) {
+                EquipmentBase eq = codeEquipMap.get(record.getDeviceCode());
+                if (eq != null) {
+                    if (eq.getEquipmentName() != null) {
+                        record.setDeviceName(eq.getEquipmentName());
+                    }
+                    if (eq.getLongitude() != null) {
+                        record.setLongitude(eq.getLongitude().toPlainString());
+                    }
+                    if (eq.getLatitude() != null) {
+                        record.setLatitude(eq.getLatitude().toPlainString());
+                    }
+                }
+            }
+        }
     }
 
     @Override

+ 24 - 13
pipe-network-service/zksy-system/src/main/java/com/zksy/drainage/domain/DrainageWarning.java

@@ -3,7 +3,6 @@ package com.zksy.drainage.domain;
 import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
-import com.baomidou.mybatisplus.annotation.TableLogic;
 import com.baomidou.mybatisplus.annotation.TableName;
 import com.fasterxml.jackson.annotation.JsonFormat;
 import io.swagger.annotations.ApiModelProperty;
@@ -20,10 +19,10 @@ import java.time.LocalDateTime;
 @Data
 @AllArgsConstructor
 @NoArgsConstructor
-@TableName("psgw_drainage_warning")
+@TableName("early_warning")
 public class DrainageWarning {
 
-    @TableId(value = "id", type = IdType.ASSIGN_UUID)
+    @TableId(value = "warning_id", type = IdType.ASSIGN_UUID)
     @ApiModelProperty("主键ID")
     private String id;
 
@@ -31,9 +30,11 @@ public class DrainageWarning {
     private String warningNo;
 
     @ApiModelProperty("关联设备ID")
+    @TableField(exist = false)
     private String equipmentId;
 
     @ApiModelProperty("设备名称")
+    @TableField("warning_name")
     private String equipmentName;
 
     @ApiModelProperty("预警级别(1严重,2重要,3一般)")
@@ -42,10 +43,15 @@ public class DrainageWarning {
     @ApiModelProperty("预警类型")
     private String warningType;
 
+    @ApiModelProperty("预警专项")
+    private String warningSpecial;
+
     @ApiModelProperty("当前监测值")
+    @TableField(exist = false)
     private String currentValue;
 
     @ApiModelProperty("阈值")
+    @TableField(exist = false)
     private String thresholdValue;
 
     @ApiModelProperty("预警位置")
@@ -58,9 +64,11 @@ public class DrainageWarning {
     private BigDecimal latitude;
 
     @ApiModelProperty("预警内容")
+    @TableField("warning_content")
     private String content;
 
     @ApiModelProperty("预警发生时间")
+    @TableField(exist = false)
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
     private LocalDateTime warningTime;
 
@@ -72,52 +80,55 @@ public class DrainageWarning {
     private LocalDateTime publishTime;
 
     @ApiModelProperty("发布范围(2相关部门,3指定人员)")
+    @TableField(exist = false)
     private Integer publishScope;
 
     @ApiModelProperty("发布范围部门ID(publish_scope=2时存储排水单位部门ID)")
-    @TableField("scope_dept_id")
+    @TableField(exist = false)
     private Long scopeDeptId;
 
-    @ApiModelProperty("状态(0待处理,1已处理,2已完成)")
-    private Integer status;
+    @ApiModelProperty("状态(DRAFT草稿,PENDING待办,PROCESSING处置中,RELEASED已发布,HANDLED已处置,CLOSED已解除)")
+    private String status;
 
     @ApiModelProperty("处理人ID")
-    @TableField("first_approver")
+    @TableField(exist = false)
     private Long firstApprover;
 
     @ApiModelProperty("处理人名称")
-    @TableField("first_approver_name")
+    @TableField(exist = false)
     private String firstApproverName;
 
     @ApiModelProperty("处理时间")
+    @TableField(exist = false)
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
-    @TableField("first_approve_time")
     private LocalDateTime firstApproveTime;
 
     @ApiModelProperty("审批人ID(管理员)")
-    @TableField("final_approver")
+    @TableField(exist = false)
     private Long finalApprover;
 
     @ApiModelProperty("审批人名称")
-    @TableField("final_approver_name")
+    @TableField(exist = false)
     private String finalApproverName;
 
     @ApiModelProperty("审批时间")
+    @TableField(exist = false)
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
-    @TableField("final_approve_time")
     private LocalDateTime finalApproveTime;
 
     @ApiModelProperty("处理时间")
+    @TableField(exist = false)
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
     private LocalDateTime processTime;
 
     @ApiModelProperty("处理人")
+    @TableField("handler")
     private String processor;
 
     @ApiModelProperty("备注")
     private String remark;
 
-    @TableLogic(value = "0", delval = "1")
+    @TableField(exist = false)
     @ApiModelProperty("删除标志(0正常,1删除)")
     private String delFlag;
 

+ 29 - 20
pipe-network-service/zksy-system/src/main/java/com/zksy/drainage/service/DrainageWarningService.java

@@ -19,26 +19,29 @@ public interface DrainageWarningService extends IService<DrainageWarning> {
      * @param pageSize      每页数量
      * @param warningLevel  预警级别
      * @param warningType   预警类型
-     * @param status        状态
+     * @param status        状态(字符串)
      * @param startTime     开始时间(yyyy-MM-dd HH:mm:ss)
      * @param endTime       结束时间(yyyy-MM-dd HH:mm:ss)
      */
     Page<DrainageWarning> findByPage(long pageNum, long pageSize,
                                      Integer warningLevel, String warningType,
-                                     Integer status, String startTime, String endTime);
+                                     String status, String startTime, String endTime);
 
     /**
-     * 查询当前预警(status=0,不做今日时间过滤
+     * 查询当前预警(status IN DRAFT/PENDING/PROCESSING/RELEASED
      */
     Page<DrainageWarning> findCurrentPage(long pageNum, long pageSize,
                                           Integer warningLevel, String warningType);
 
     /**
-     * 查询历史预警(status >= 2,已完成)
+     * 查询历史预警(status IN HANDLED/CLOSED)
+     *
+     * @param historyOnly   为true时强制限定 status IN ('HANDLED','CLOSED')
      */
     Page<DrainageWarning> findHistoryPage(long pageNum, long pageSize,
                                           Integer warningLevel, String warningType,
-                                          Integer status, String startTime, String endTime);
+                                          String status, String startTime, String endTime,
+                                          boolean historyOnly, String equipmentName);
 
     /**
      * 发布新预警(自动生成预警编号、设置发布时间和默认状态)
@@ -54,10 +57,10 @@ public interface DrainageWarningService extends IService<DrainageWarning> {
      * 更新预警状态
      *
      * @param id        预警ID
-     * @param status    新状态
+     * @param status    新状态(字符串:DRAFT/PENDING/PROCESSING/RELEASED/HANDLED/CLOSED)
      * @param processor 处理人
      */
-    boolean updateStatus(String id, Integer status, String processor);
+    boolean updateStatus(String id, String status, String processor);
 
     /**
      * 删除预警
@@ -75,24 +78,30 @@ public interface DrainageWarningService extends IService<DrainageWarning> {
     void publishWarning(DrainageWarning warning, List<Long> userIds);
 
     /**
-     * 查询当前用户可见的预警(按用户ID和部门ID过滤,包含所有状态)
-     * - admin:看所有预警(全部状态)
-     * - 普通用户:看 publish_scope=2 且部门匹配 或 publish_scope=3 且被指定的预警(全部状态)
-     * - deptId 为 null 时,只要用户在 scope_user 表中有记录,仍能看到对应预警
-     * - 不做“今天”时间过滤,预警发布后一直可见
-     * - status 参数用于前端 Tab 筛选(全部/待处理/已处理/已完成),为 null 时返回所有状态
+     * 查询当前用户可见的预警(按用户ID和部门ID过滤)
+     * - admin:看所有预警
+     * - 普通用户:看 publish_scope=2 且部门匹配 或 publish_scope=3 且被指定的预警
+     * - currentOnly=true 时限定 status IN ('DRAFT','PENDING','PROCESSING','RELEASED')
+     * - status 参数用于前端 Tab 筛选,为 null 时返回所有符合的状态
      *
-     * @param pageNum  页码
-     * @param pageSize 每页数量
-     * @param userId   当前用户ID
-     * @param deptId   当前用户部门ID(可为null)
-     * @param isAdmin  是否管理员
-     * @param status   状态筛选(0待处理,1已处理,2已完成),为null时不筛选状态
+     * @param pageNum       页码
+     * @param pageSize      每页数量
+     * @param userId        当前用户ID
+     * @param deptId        当前用户部门ID(可为null)
+     * @param isAdmin       是否管理员
+     * @param warningLevel  预警级别
+     * @param warningType   预警类型
+     * @param status        状态筛选(字符串),为null时不筛选状态
+     * @param currentOnly   为true时限定返回当前预警(未处置的)
+     * @param equipmentName 设备名称(模糊查询)
+     * @param startTime     开始时间
+     * @param endTime       结束时间
      */
     Page<DrainageWarning> findVisibleCurrentPage(long pageNum, long pageSize,
                                                   Long userId, Long deptId, boolean isAdmin,
                                                   Integer warningLevel, String warningType,
-                                                  Integer status);
+                                                  String status, boolean currentOnly,
+                                                  String equipmentName, String startTime, String endTime);
 
     /**
      * 处理(指定人员处理)

+ 54 - 81
pipe-network-service/zksy-system/src/main/java/com/zksy/drainage/service/impl/DrainageWarningServiceImpl.java

@@ -16,6 +16,7 @@ import org.springframework.transaction.annotation.Transactional;
 
 import java.time.LocalDateTime;
 import java.time.format.DateTimeFormatter;
+import java.util.Arrays;
 import java.util.List;
 import java.util.stream.Collectors;
 
@@ -33,13 +34,16 @@ public class DrainageWarningServiceImpl extends ServiceImpl<DrainageWarningMappe
     @Autowired
     private WarningScopeUserMapper warningScopeUserMapper;
 
+    private static final List<String> CURRENT_STATUSES = Arrays.asList("DRAFT", "PENDING", "PROCESSING", "RELEASED");
+    private static final List<String> HISTORY_STATUSES = Arrays.asList("HANDLED", "CLOSED");
+
     @Override
     public Page<DrainageWarning> findByPage(long pageNum, long pageSize,
                                             Integer warningLevel, String warningType,
-                                            Integer status, String startTime, String endTime) {
+                                            String status, String startTime, String endTime) {
         Page<DrainageWarning> page = new Page<>(pageNum, pageSize);
         LambdaQueryWrapper<DrainageWarning> wrapper = buildQueryWrapper(warningLevel, warningType, status, startTime, endTime);
-        wrapper.orderByDesc(DrainageWarning::getWarningTime);
+        wrapper.orderByDesc(DrainageWarning::getCreateTime);
         return this.page(page, wrapper);
     }
 
@@ -48,8 +52,8 @@ public class DrainageWarningServiceImpl extends ServiceImpl<DrainageWarningMappe
                                                   Integer warningLevel, String warningType) {
         Page<DrainageWarning> page = new Page<>(pageNum, pageSize);
         LambdaQueryWrapper<DrainageWarning> wrapper = new LambdaQueryWrapper<>();
-        // 当前预警:status=0,不做"今天"时间过滤,预警发布后一直可见直到被处理完成
-        wrapper.eq(DrainageWarning::getStatus, 0);
+        // 当前预警:status IN ('DRAFT','PENDING','PROCESSING','RELEASED')
+        wrapper.in(DrainageWarning::getStatus, CURRENT_STATUSES);
         // 附加筛选条件
         if (warningLevel != null) {
             wrapper.eq(DrainageWarning::getWarningLevel, warningLevel);
@@ -57,18 +61,19 @@ public class DrainageWarningServiceImpl extends ServiceImpl<DrainageWarningMappe
         if (warningType != null && !warningType.isEmpty()) {
             wrapper.eq(DrainageWarning::getWarningType, warningType);
         }
-        wrapper.orderByDesc(DrainageWarning::getWarningTime);
+        wrapper.orderByDesc(DrainageWarning::getCreateTime);
         return this.page(page, wrapper);
     }
 
     @Override
     public Page<DrainageWarning> findHistoryPage(long pageNum, long pageSize,
                                                   Integer warningLevel, String warningType,
-                                                  Integer status, String startTime, String endTime) {
+                                                  String status, String startTime, String endTime,
+                                                  boolean historyOnly, String equipmentName) {
         Page<DrainageWarning> page = new Page<>(pageNum, pageSize);
         LambdaQueryWrapper<DrainageWarning> wrapper = new LambdaQueryWrapper<>();
-        // 历史预警:status >= 2(已完成)
-        wrapper.ge(DrainageWarning::getStatus, 2);
+        // historyOnly=true 时不再自动添加 status IN (HISTORY_STATUSES) 条件
+        // 由前端通过 status 参数控制状态过滤,避免数据库 status 值格式不匹配导致查不到数据
         // 附加筛选条件
         if (warningLevel != null) {
             wrapper.eq(DrainageWarning::getWarningLevel, warningLevel);
@@ -76,16 +81,19 @@ public class DrainageWarningServiceImpl extends ServiceImpl<DrainageWarningMappe
         if (warningType != null && !warningType.isEmpty()) {
             wrapper.eq(DrainageWarning::getWarningType, warningType);
         }
-        if (status != null) {
+        if (status != null && !status.isEmpty()) {
             wrapper.eq(DrainageWarning::getStatus, status);
         }
+        if (equipmentName != null && !equipmentName.isEmpty()) {
+            wrapper.like(DrainageWarning::getEquipmentName, equipmentName);
+        }
         if (startTime != null && !startTime.isEmpty()) {
-            wrapper.ge(DrainageWarning::getWarningTime, LocalDateTime.parse(startTime, DATE_TIME_FORMATTER));
+            wrapper.ge(DrainageWarning::getCreateTime, LocalDateTime.parse(startTime, DATE_TIME_FORMATTER));
         }
         if (endTime != null && !endTime.isEmpty()) {
-            wrapper.le(DrainageWarning::getWarningTime, LocalDateTime.parse(endTime, DATE_TIME_FORMATTER));
+            wrapper.le(DrainageWarning::getCreateTime, LocalDateTime.parse(endTime, DATE_TIME_FORMATTER));
         }
-        wrapper.orderByDesc(DrainageWarning::getWarningTime);
+        wrapper.orderByDesc(DrainageWarning::getCreateTime);
         return this.page(page, wrapper);
     }
 
@@ -98,9 +106,9 @@ public class DrainageWarningServiceImpl extends ServiceImpl<DrainageWarningMappe
         }
         // 设置发布时间为当前时间
         entity.setPublishTime(LocalDateTime.now());
-        // 默认状态为0(当前预警
-        if (entity.getStatus() == null) {
-            entity.setStatus(0);
+        // 默认状态为PENDING(待办
+        if (entity.getStatus() == null || entity.getStatus().isEmpty()) {
+            entity.setStatus("PENDING");
         }
         return this.save(entity);
     }
@@ -117,7 +125,7 @@ public class DrainageWarningServiceImpl extends ServiceImpl<DrainageWarningMappe
 
     @Override
     @Transactional
-    public boolean updateStatus(String id, Integer status, String processor) {
+    public boolean updateStatus(String id, String status, String processor) {
         DrainageWarning existing = this.getById(id);
         if (existing == null) {
             throw new ServiceException("预警信息不存在:" + id);
@@ -147,8 +155,8 @@ public class DrainageWarningServiceImpl extends ServiceImpl<DrainageWarningMappe
             warning.setWarningNo("WRN" + LocalDateTime.now().format(WARNING_NO_FORMATTER));
         }
         warning.setPublishTime(LocalDateTime.now());
-        // 默认状态为0(待处理
-        warning.setStatus(0);
+        // 默认状态为PENDING(待办
+        warning.setStatus("PENDING");
         this.save(warning);
 
         // publish_scope=3 指定人员:保存接收人员记录
@@ -168,63 +176,19 @@ public class DrainageWarningServiceImpl extends ServiceImpl<DrainageWarningMappe
     public Page<DrainageWarning> findVisibleCurrentPage(long pageNum, long pageSize,
                                                          Long userId, Long deptId, boolean isAdmin,
                                                          Integer warningLevel, String warningType,
-                                                         Integer status) {
+                                                         String status, boolean currentOnly,
+                                                         String equipmentName, String startTime, String endTime) {
         Page<DrainageWarning> page = new Page<>(pageNum, pageSize);
         LambdaQueryWrapper<DrainageWarning> wrapper = new LambdaQueryWrapper<>();
 
-        // 可见性逻辑(谁能看哪些预警的规则不变),不限制 status
-        if (isAdmin) {
-            // 管理员:看所有预警(全部状态)
-        } else if (userId != null) {
-            // 普通用户:看分配给自己的预警(全部状态)
-
-            // Step 1: 查询该用户在 scope_user 表中被指定的所有 warning_id
-            List<String> scopeWarningIds = warningScopeUserMapper.selectList(
-                    new LambdaQueryWrapper<WarningScopeUser>()
-                            .eq(WarningScopeUser::getUserId, userId))
-                    .stream()
-                    .map(WarningScopeUser::getWarningId)
-                    .collect(Collectors.toList());
-
-            log.info("[预警可见性] userId={}, deptId={}, scopeWarningIds={}", userId, deptId, scopeWarningIds);
+        // 管理员模式:不做任何权限过滤,仅按基本条件查询
+        // early_warning 表无 del_flag 字段,无需逻辑删除过滤
 
-            // Step 2: 构建可见性 OR 条件
-            //   条件A: publish_scope=3 AND id IN (用户被指定的warningIds)
-            //   条件B: publish_scope=2 AND scope_dept_id=用户部门ID(仅当deptId不为null时)
-            //   如果warningIds非空但deptId为空,仍只用条件A即可查出结果
-            boolean hasUserScope = !scopeWarningIds.isEmpty();
-            boolean hasDeptScope = deptId != null;
-
-            if (hasUserScope && hasDeptScope) {
-                // 两个条件都有,用 OR 连接
-                wrapper.and(w -> w
-                        .and(inner -> inner
-                                .eq(DrainageWarning::getPublishScope, 3)
-                                .in(DrainageWarning::getId, scopeWarningIds))
-                        .or(inner -> inner
-                                .eq(DrainageWarning::getPublishScope, 2)
-                                .eq(DrainageWarning::getScopeDeptId, deptId)));
-            } else if (hasUserScope) {
-                // 只有指定人员条件(deptId为空时仍能看到分配给自己的预警)
-                wrapper.and(w -> w
-                        .eq(DrainageWarning::getPublishScope, 3)
-                        .in(DrainageWarning::getId, scopeWarningIds));
-            } else if (hasDeptScope) {
-                // 只有部门条件
-                wrapper.and(w -> w
-                        .eq(DrainageWarning::getPublishScope, 2)
-                        .eq(DrainageWarning::getScopeDeptId, deptId));
-            } else {
-                // 两个条件都不满足(用户不在任何scope_user中且无部门),查不到数据
-                wrapper.eq(DrainageWarning::getId, "IMPOSSIBLE_ID");
-            }
-        } else {
-            // 未指定用户信息:不限制状态,返回所有预警
-        }
-
-        // 状态筛选(前端 Tab 切换传入,为 null 时不筛选,返回所有状态)
-        if (status != null) {
+        // 状态筛选:status 参数优先,currentOnly=true 时限定当前预警状态
+        if (status != null && !status.isEmpty()) {
             wrapper.eq(DrainageWarning::getStatus, status);
+        } else if (currentOnly) {
+            wrapper.in(DrainageWarning::getStatus, CURRENT_STATUSES);
         }
 
         // 附加筛选条件
@@ -234,8 +198,17 @@ public class DrainageWarningServiceImpl extends ServiceImpl<DrainageWarningMappe
         if (warningType != null && !warningType.isEmpty()) {
             wrapper.eq(DrainageWarning::getWarningType, warningType);
         }
+        if (equipmentName != null && !equipmentName.isEmpty()) {
+            wrapper.like(DrainageWarning::getEquipmentName, equipmentName);
+        }
+        if (startTime != null && !startTime.isEmpty()) {
+            wrapper.ge(DrainageWarning::getCreateTime, LocalDateTime.parse(startTime, DATE_TIME_FORMATTER));
+        }
+        if (endTime != null && !endTime.isEmpty()) {
+            wrapper.le(DrainageWarning::getCreateTime, LocalDateTime.parse(endTime, DATE_TIME_FORMATTER));
+        }
 
-        wrapper.orderByDesc(DrainageWarning::getWarningTime);
+        wrapper.orderByDesc(DrainageWarning::getCreateTime);
         return this.page(page, wrapper);
     }
 
@@ -246,13 +219,13 @@ public class DrainageWarningServiceImpl extends ServiceImpl<DrainageWarningMappe
         if (existing == null) {
             throw new ServiceException("预警信息不存在:" + warningId);
         }
-        if (existing.getStatus() == null || existing.getStatus() != 0) {
-            throw new ServiceException("预警状态非待处理,无法处理");
+        if (existing.getStatus() == null || !"PENDING".equals(existing.getStatus())) {
+            throw new ServiceException("预警状态非待,无法处理");
         }
 
         DrainageWarning update = new DrainageWarning();
         update.setId(warningId);
-        update.setStatus(1);
+        update.setStatus("PROCESSING");
         update.setFirstApprover(userId);
         update.setFirstApproverName(userName);
         update.setFirstApproveTime(LocalDateTime.now());
@@ -275,13 +248,13 @@ public class DrainageWarningServiceImpl extends ServiceImpl<DrainageWarningMappe
         if (existing == null) {
             throw new ServiceException("预警信息不存在:" + warningId);
         }
-        if (existing.getStatus() == null || existing.getStatus() != 1) {
-            throw new ServiceException("预警状态非已处理,无法审批");
+        if (existing.getStatus() == null || !"PROCESSING".equals(existing.getStatus())) {
+            throw new ServiceException("预警状态非处置中,无法审批");
         }
 
         DrainageWarning update = new DrainageWarning();
         update.setId(warningId);
-        update.setStatus(2);
+        update.setStatus("RELEASED");
         update.setFinalApprover(userId);
         update.setFinalApproverName(userName);
         update.setFinalApproveTime(LocalDateTime.now());
@@ -299,7 +272,7 @@ public class DrainageWarningServiceImpl extends ServiceImpl<DrainageWarningMappe
      * 构建通用查询条件
      */
     private LambdaQueryWrapper<DrainageWarning> buildQueryWrapper(Integer warningLevel, String warningType,
-                                                                   Integer status, String startTime, String endTime) {
+                                                                   String status, String startTime, String endTime) {
         LambdaQueryWrapper<DrainageWarning> wrapper = new LambdaQueryWrapper<>();
         if (warningLevel != null) {
             wrapper.eq(DrainageWarning::getWarningLevel, warningLevel);
@@ -307,14 +280,14 @@ public class DrainageWarningServiceImpl extends ServiceImpl<DrainageWarningMappe
         if (warningType != null && !warningType.isEmpty()) {
             wrapper.eq(DrainageWarning::getWarningType, warningType);
         }
-        if (status != null) {
+        if (status != null && !status.isEmpty()) {
             wrapper.eq(DrainageWarning::getStatus, status);
         }
         if (startTime != null && !startTime.isEmpty()) {
-            wrapper.ge(DrainageWarning::getWarningTime, LocalDateTime.parse(startTime, DATE_TIME_FORMATTER));
+            wrapper.ge(DrainageWarning::getCreateTime, LocalDateTime.parse(startTime, DATE_TIME_FORMATTER));
         }
         if (endTime != null && !endTime.isEmpty()) {
-            wrapper.le(DrainageWarning::getWarningTime, LocalDateTime.parse(endTime, DATE_TIME_FORMATTER));
+            wrapper.le(DrainageWarning::getCreateTime, LocalDateTime.parse(endTime, DATE_TIME_FORMATTER));
         }
         return wrapper;
     }