Explorar el Código

feat: [Issue#72] 实现阈值管理、信息发布、设备管理功能

- 阈值管理:支持报警阈值配置(最小值、最大值、警告值)
- 信息发布:支持预报/预警信息发布和管理
- 设备管理:支持按名称、类型、时间、位置查询设备
- 新增3个实体类:Threshold、Notification、Equipment
- 新增6个Service及其实现类
- 新增3个Controller及对应的VO类
- 新增数据库表结构和示例数据
bot_dev1 hace 5 días
padre
commit
1d550c1bfb
Se han modificado 20 ficheros con 794 adiciones y 3 borrados
  1. 2
    3
      wm-production/pom.xml
  2. 83
    0
      wm-production/sql/init_data.sql
  3. 83
    0
      wm-production/wm-production/src/main/java/com/water/production/controller/EquipmentController.java
  4. 91
    0
      wm-production/wm-production/src/main/java/com/water/production/controller/NotificationController.java
  5. 77
    0
      wm-production/wm-production/src/main/java/com/water/production/controller/ThresholdController.java
  6. 29
    0
      wm-production/wm-production/src/main/java/com/water/production/entity/Equipment.java
  7. 24
    0
      wm-production/wm-production/src/main/java/com/water/production/entity/Notification.java
  8. 27
    0
      wm-production/wm-production/src/main/java/com/water/production/entity/Threshold.java
  9. 9
    0
      wm-production/wm-production/src/main/java/com/water/production/mapper/EquipmentMapper.java
  10. 9
    0
      wm-production/wm-production/src/main/java/com/water/production/mapper/NotificationMapper.java
  11. 9
    0
      wm-production/wm-production/src/main/java/com/water/production/mapper/ThresholdMapper.java
  12. 17
    0
      wm-production/wm-production/src/main/java/com/water/production/service/EquipmentService.java
  13. 15
    0
      wm-production/wm-production/src/main/java/com/water/production/service/NotificationService.java
  14. 16
    0
      wm-production/wm-production/src/main/java/com/water/production/service/ThresholdService.java
  15. 84
    0
      wm-production/wm-production/src/main/java/com/water/production/service/impl/EquipmentServiceImpl.java
  16. 83
    0
      wm-production/wm-production/src/main/java/com/water/production/service/impl/NotificationServiceImpl.java
  17. 73
    0
      wm-production/wm-production/src/main/java/com/water/production/service/impl/ThresholdServiceImpl.java
  18. 23
    0
      wm-production/wm-production/src/main/java/com/water/production/vo/EquipmentQueryVO.java
  19. 20
    0
      wm-production/wm-production/src/main/java/com/water/production/vo/NotificationQueryVO.java
  20. 20
    0
      wm-production/wm-production/src/main/java/com/water/production/vo/ThresholdQueryVO.java

+ 2
- 3
wm-production/pom.xml Ver fichero

@@ -13,9 +13,8 @@
13 13
         <dependency><groupId>cn.dev33</groupId><artifactId>sa-token-spring-boot3-starter</artifactId></dependency>
14 14
         <dependency><groupId>org.postgresql</groupId><artifactId>postgresql</artifactId></dependency>
15 15
     <dependency>
16
-        <groupId>io.springfox</groupId>
17
-        <artifactId>springfox-boot-starter</artifactId>
18
-        <version>3.0.0</version>
16
+        <groupId>com.github.xiaoymin</groupId>
17
+        <artifactId>knife4j-openapi3-jakarta-spring-boot-starter</artifactId>
19 18
     </dependency>
20 19
     </dependencies>
21 20
 </project>

+ 83
- 0
wm-production/sql/init_data.sql Ver fichero

@@ -0,0 +1,83 @@
1
+-- 阈值表
2
+CREATE TABLE IF NOT EXISTS threshold (
3
+    id BIGSERIAL PRIMARY KEY,
4
+    device_id VARCHAR(100) NOT NULL,
5
+    device_type VARCHAR(50),
6
+    region VARCHAR(50),
7
+    parameter VARCHAR(100) NOT NULL,
8
+    min_value DOUBLE PRECISION,
9
+    max_value DOUBLE PRECISION,
10
+    warning_min DOUBLE PRECISION,
11
+    warning_max DOUBLE PRECISION,
12
+    unit VARCHAR(20),
13
+    description TEXT,
14
+    status INTEGER DEFAULT 1 COMMENT '1-启用,0-禁用',
15
+    create_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
16
+    update_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP
17
+);
18
+
19
+-- 信息发布表
20
+CREATE TABLE IF NOT EXISTS notification (
21
+    id BIGSERIAL PRIMARY KEY,
22
+    title VARCHAR(200) NOT NULL,
23
+    content TEXT NOT NULL,
24
+    type VARCHAR(20) NOT NULL COMMENT 'forecast-预报,warning-预警,info-通知',
25
+    region VARCHAR(50),
26
+    priority VARCHAR(20) DEFAULT 'medium' COMMENT 'high-高,medium-中,low-低',
27
+    status INTEGER DEFAULT 1 COMMENT '1-草稿,2-已发布,3-已归档',
28
+    publisher VARCHAR(100),
29
+    publish_time TIMESTAMP,
30
+    create_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
31
+    update_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP
32
+);
33
+
34
+-- 设备表
35
+CREATE TABLE IF NOT EXISTS equipment (
36
+    id BIGSERIAL PRIMARY KEY,
37
+    device_name VARCHAR(100) NOT NULL,
38
+    device_type VARCHAR(50),
39
+    model VARCHAR(100),
40
+    serial_number VARCHAR(100),
41
+    region VARCHAR(50),
42
+    location TEXT,
43
+    status VARCHAR(20) DEFAULT 'offline' COMMENT 'online-在线,offline-离线,maintenance-维护中,fault-故障',
44
+    manufacturer VARCHAR(100),
45
+    installation_date DATE,
46
+    last_maintenance_date DATE,
47
+    next_maintenance_date DATE,
48
+    latitude DOUBLE PRECISION,
49
+    longitude DOUBLE PRECISION,
50
+    create_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
51
+    update_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP
52
+);
53
+
54
+-- 创建索引
55
+CREATE INDEX IF NOT EXISTS idx_threshold_device_id ON threshold(device_id);
56
+CREATE INDEX IF NOT EXISTS idx_threshold_region ON threshold(region);
57
+CREATE INDEX IF NOT EXISTS idx_threshold_parameter ON threshold(parameter);
58
+CREATE INDEX IF NOT EXISTS idx_notification_region ON notification(region);
59
+CREATE INDEX IF NOT EXISTS idx_notification_type ON notification(type);
60
+CREATE INDEX IF NOT EXISTS idx_notification_status ON notification(status);
61
+CREATE INDEX IF NOT EXISTS idx_equipment_device_name ON equipment(device_name);
62
+CREATE INDEX IF NOT EXISTS idx_equipment_device_type ON equipment(device_type);
63
+CREATE INDEX IF NOT EXISTS idx_equipment_region ON equipment(region);
64
+CREATE INDEX IF NOT EXISTS idx_equipment_status ON equipment(status);
65
+
66
+-- 插入示例数据
67
+-- 阈值示例
68
+INSERT INTO threshold (device_id, device_type, region, parameter, min_value, max_value, warning_min, warning_max, unit, description, status) VALUES
69
+('DEV001', 'pressure_sensor', '精河县', 'water_pressure', 0.2, 0.8, 0.15, 0.85, 'MPa', '供水压力阈值', 1),
70
+('DEV002', 'flow_meter', '精河县', 'water_flow', 10, 100, 8, 110, 'm³/h', '水流流量阈值', 1),
71
+('DEV003', 'quality_sensor', '精河县', 'water_quality', 0, 1, 0.1, 0.9, 'pH', '水质pH值阈值', 1);
72
+
73
+-- 设备示例
74
+INSERT INTO equipment (device_name, device_type, model, serial_number, region, location, status, manufacturer, installation_date) VALUES
75
+('压力传感器001', 'pressure_sensor', 'PS-3000', 'SN0012023001', '精河县', '供水站A区', 'online', '华为', '2023-01-15'),
76
+('流量计001', 'flow_meter', 'FM-5000', 'SN0012023002', '精河县', '供水站B区', 'online', '西门子', '2023-02-20'),
77
+('水质检测仪001', 'quality_sensor', 'QS-2000', 'SN0012023003', '精河县', '供水站C区', 'online', '霍尼韦尔', '2023-03-10');
78
+
79
+-- 信息发布示例
80
+INSERT INTO notification (title, content, type, region, priority, status, publisher, publish_time) VALUES
81
+('停水通知', '因设备维护,预计明天9:00-12:00精河县部分区域将暂停供水', 'warning', '精河县', 'high', 2, 'system_admin', '2026-06-14T08:00:00'),
82
+('水质提升通知', '本季度已完成水质净化设备升级,水质显著提升', 'info', '精河县', 'medium', 2, 'water_quality_team', '2026-06-01T10:00:00'),
83
+('雨季供水保障通知', '近期降雨较多,各水厂已加强巡检,确保供水稳定', 'forecast', '精河县', 'low', 2, 'emergency_team', '2026-05-20T14:00:00');

+ 83
- 0
wm-production/wm-production/src/main/java/com/water/production/controller/EquipmentController.java Ver fichero

@@ -0,0 +1,83 @@
1
+package com.water.production.controller;
2
+
3
+import com.water.production.entity.Equipment;
4
+import com.water.production.service.EquipmentService;
5
+import com.water.production.vo.EquipmentQueryVO;
6
+import com.water.production.Result;
7
+import io.swagger.v3.oas.annotations.Operation;
8
+import io.swagger.v3.oas.annotations.tags.Tag;
9
+import org.springframework.beans.factory.annotation.Autowired;
10
+import org.springframework.web.bind.annotation.*;
11
+import java.util.List;
12
+
13
+@RestController
14
+@RequestMapping("/api/equipment")
15
+@Tag(name = "设备管理", description = "设备列表查询接口")
16
+public class EquipmentController {
17
+
18
+    @Autowired
19
+    private EquipmentService equipmentService;
20
+
21
+    @PostMapping("/save")
22
+    @Operation(summary = "保存设备信息")
23
+    public Result<Boolean> saveEquipment(@RequestBody Equipment equipment) {
24
+        boolean success = equipmentService.saveEquipment(equipment);
25
+        return success ? Result.success(true) : Result.error("保存失败");
26
+    }
27
+
28
+    @PutMapping("/update")
29
+    @Operation(summary = "更新设备信息")
30
+    public Result<Boolean> updateEquipment(@RequestBody Equipment equipment) {
31
+        boolean success = equipmentService.updateEquipment(equipment);
32
+        return success ? Result.success(true) : Result.error("更新失败");
33
+    }
34
+
35
+    @DeleteMapping("/delete/{id}")
36
+    @Operation(summary = "删除设备信息")
37
+    public Result<Boolean> deleteEquipment(@PathVariable Long id) {
38
+        boolean success = equipmentService.deleteEquipment(id);
39
+        return success ? Result.success(true) : Result.error("删除失败");
40
+    }
41
+
42
+    @GetMapping("/list")
43
+    @Operation(summary = "获取所有设备列表")
44
+    public Result<List<Equipment>> list() {
45
+        List<Equipment> equipmentList = equipmentService.list();
46
+        return Result.success(equipmentList);
47
+    }
48
+
49
+    @PostMapping("/query")
50
+    @Operation(summary = "查询设备列表")
51
+    public Result<List<Equipment>> query(@RequestBody EquipmentQueryVO queryVO) {
52
+        List<Equipment> equipmentList = equipmentService.queryEquipment(queryVO);
53
+        return Result.success(equipmentList);
54
+    }
55
+
56
+    @GetMapping("/name/{deviceName}")
57
+    @Operation(summary = "根据设备名称查询(模糊匹配)")
58
+    public Result<List<Equipment>> getByName(@PathVariable String deviceName) {
59
+        List<Equipment> equipmentList = equipmentService.getEquipmentByName(deviceName);
60
+        return Result.success(equipmentList);
61
+    }
62
+
63
+    @GetMapping("/type/{deviceType}")
64
+    @Operation(summary = "根据设备类型查询")
65
+    public Result<List<Equipment>> getByType(@PathVariable String deviceType) {
66
+        List<Equipment> equipmentList = equipmentService.getEquipmentByType(deviceType);
67
+        return Result.success(equipmentList);
68
+    }
69
+
70
+    @GetMapping("/region/{region}")
71
+    @Operation(summary = "根据区域查询")
72
+    public Result<List<Equipment>> getByRegion(@PathVariable String region) {
73
+        List<Equipment> equipmentList = equipmentService.getEquipmentByRegion(region);
74
+        return Result.success(equipmentList);
75
+    }
76
+
77
+    @GetMapping("/status/{status}")
78
+    @Operation(summary = "根据状态查询")
79
+    public Result<List<Equipment>> getByStatus(@PathVariable String status) {
80
+        List<Equipment> equipmentList = equipmentService.getEquipmentByStatus(status);
81
+        return Result.success(equipmentList);
82
+    }
83
+}

+ 91
- 0
wm-production/wm-production/src/main/java/com/water/production/controller/NotificationController.java Ver fichero

@@ -0,0 +1,91 @@
1
+package com.water.production.controller;
2
+
3
+import com.water.production.entity.Notification;
4
+import com.water.production.service.NotificationService;
5
+import com.water.production.vo.NotificationQueryVO;
6
+import com.water.production.Result;
7
+import io.swagger.v3.oas.annotations.Operation;
8
+import io.swagger.v3.oas.annotations.tags.Tag;
9
+import org.springframework.beans.factory.annotation.Autowired;
10
+import org.springframework.web.bind.annotation.*;
11
+import java.util.List;
12
+
13
+@RestController
14
+@RequestMapping("/api/notification")
15
+@Tag(name = "信息发布", description = "预报/预警信息发布接口")
16
+public class NotificationController {
17
+
18
+    @Autowired
19
+    private NotificationService notificationService;
20
+
21
+    @PostMapping("/save")
22
+    @Operation(summary = "保存草稿")
23
+    public Result<Boolean> saveNotification(@RequestBody Notification notification) {
24
+        notification.setStatus(1); // draft
25
+        boolean success = notificationService.save(notification);
26
+        return success ? Result.success(true) : Result.error("保存失败");
27
+    }
28
+
29
+    @PutMapping("/update")
30
+    @Operation(summary = "更新信息")
31
+    public Result<Boolean> updateNotification(@RequestBody Notification notification) {
32
+        boolean success = notificationService.updateById(notification);
33
+        return success ? Result.success(true) : Result.error("更新失败");
34
+    }
35
+
36
+    @PutMapping("/publish/{id}")
37
+    @Operation(summary = "发布信息")
38
+    public Result<Boolean> publishNotification(@PathVariable Long id, @RequestParam String publisher) {
39
+        boolean success = notificationService.publishNotification(id, publisher);
40
+        return success ? Result.success(true) : Result.error("发布失败");
41
+    }
42
+
43
+    @PutMapping("/archive/{id}")
44
+    @Operation(summary = "归档信息")
45
+    public Result<Boolean> archiveNotification(@PathVariable Long id) {
46
+        boolean success = notificationService.archiveNotification(id);
47
+        return success ? Result.success(true) : Result.error("归档失败");
48
+    }
49
+
50
+    @DeleteMapping("/delete/{id}")
51
+    @Operation(summary = = "删除信息")
52
+    public Result<Boolean> deleteNotification(@PathVariable Long id) {
53
+        boolean success = notificationService.removeById(id);
54
+        return success ? Result.success(true) : Result.error("删除失败");
55
+    }
56
+
57
+    @GetMapping("/list")
58
+    @Operation(summary = "获取所有信息列表")
59
+    public Result<List<Notification>> list() {
60
+        List<Notification> notifications = notificationService.list();
61
+        return Result.success(notifications);
62
+    }
63
+
64
+    @PostMapping("/query")
65
+    @Operation(summary = "查询信息列表")
66
+    public Result<List<Notification>> query(@RequestBody NotificationQueryVO queryVO) {
67
+        List<Notification> notifications = notificationService.queryNotifications(queryVO);
68
+        return Result.success(notifications);
69
+    }
70
+
71
+    @GetMapping("/region/{region}")
72
+    @Operation(summary = "根据区域获取信息")
73
+    public Result<List<Notification>> getByRegion(@PathVariable String region) {
74
+        List<Notification> notifications = notificationService.getNotificationsByRegion(region);
75
+        return Result.success(notifications);
76
+    }
77
+
78
+    @GetMapping("/type/{type}")
79
+    @Operation(summary = = "根据类型获取信息")
80
+    public Result<List<Notification>> getByType(@PathVariable String type) {
81
+        List<Notification> notifications = notificationService.getNotificationsByType(type);
82
+        return Result.success(notifications);
83
+    }
84
+
85
+    @GetMapping("/active")
86
+    @Operation(summary = "获取已发布信息")
87
+    public Result<List<Notification>> getActiveNotifications() {
88
+        List<Notification> notifications = notificationService.getActiveNotifications();
89
+        return Result.success(notifications);
90
+    }
91
+}

+ 77
- 0
wm-production/wm-production/src/main/java/com/water/production/controller/ThresholdController.java Ver fichero

@@ -0,0 +1,77 @@
1
+package com.water.production.controller;
2
+
3
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
4
+import com.water.production.entity.Threshold;
5
+import com.water.production.service.ThresholdService;
6
+import com.water.production.vo.ThresholdQueryVO;
7
+import com.water.production.Result;
8
+import io.swagger.v3.oas.annotations.Operation;
9
+import io.swagger.v3.oas.annotations.tags.Tag;
10
+import org.springframework.beans.factory.annotation.Autowired;
11
+import org.springframework.web.bind.annotation.*;
12
+import java.util.List;
13
+
14
+@RestController
15
+@RequestMapping("/api/threshold")
16
+@Tag(name = "阈值管理", description = "报警阈值编辑接口")
17
+public class ThresholdController {
18
+
19
+    @Autowired
20
+    private ThresholdService thresholdService;
21
+
22
+    @PostMapping("/save")
23
+    @Operation(summary = "保存阈值配置")
24
+    public Result<Boolean> saveThreshold(@RequestBody Threshold threshold) {
25
+        boolean success = thresholdService.saveThreshold(threshold);
26
+        return success ? Result.success(true) : Result.error("保存失败");
27
+    }
28
+
29
+    @PutMapping("/update")
30
+    @Operation(summary = "更新阈值配置")
31
+    public Result<Boolean> updateThreshold(@RequestBody Threshold threshold) {
32
+        boolean success = thresholdService.updateThreshold(threshold);
33
+        return success ? Result.success(true) : Result.error("更新失败");
34
+    }
35
+
36
+    @DeleteMapping("/delete/{id}")
37
+    @Operation(summary = "删除阈值配置")
38
+    public Result<Boolean> deleteThreshold(@PathVariable Long id) {
39
+        boolean success = thresholdService.deleteThreshold(id);
40
+        return success ? Result.success(true) : Result.error("删除失败");
41
+    }
42
+
43
+    @GetMapping("/list")
44
+    @Operation(summary = "获取阈值配置列表")
45
+    public Result<List<Threshold>> list() {
46
+        List<Threshold> thresholds = thresholdService.list();
47
+        return Result.success(thresholds);
48
+    }
49
+
50
+    @PostMapping("/query")
51
+    @Operation(summary = "查询阈值配置")
52
+    public Result<List<Threshold>> query(@RequestBody ThresholdQueryVO queryVO) {
53
+        List<Threshold> thresholds = thresholdService.queryThresholds(queryVO);
54
+        return Result.success(thresholds);
55
+    }
56
+
57
+    @GetMapping("/device/{deviceId}")
58
+    @Operation(summary = "根据设备ID获取阈值")
59
+    public Result<List<Threshold>> getByDeviceId(@PathVariable String deviceId) {
60
+        List<Threshold> thresholds = thresholdService.getThresholdsByDevice(deviceId);
61
+        return Result.success(thresholds);
62
+    }
63
+
64
+    @GetMapping("/region/{region}")
65
+    @Operation(summary = "根据区域获取阈值")
66
+    public Result<List<Threshold>> getByRegion(@PathVariable String region) {
67
+        List<Threshold> thresholds = thresholdService.getThresholdsByRegion(region);
68
+        return Result.success(thresholds);
69
+    }
70
+
71
+    @GetMapping("/parameter/{parameter}")
72
+    @Operation(summary = "根据参数获取阈值")
73
+    public Result<List<Threshold>> getByParameter(@PathVariable String parameter) {
74
+        List<Threshold> thresholds = thresholdService.getThresholdsByParameter(parameter);
75
+        return Result.success(thresholds);
76
+    }
77
+}

+ 29
- 0
wm-production/wm-production/src/main/java/com/water/production/entity/Equipment.java Ver fichero

@@ -0,0 +1,29 @@
1
+package com.water.production.entity;
2
+
3
+import com.baomidou.mybatisplus.annotation.IdType;
4
+import com.baomidou.mybatisplus.annotation.TableId;
5
+import com.baomidou.mybatisplus.annotation.TableName;
6
+import lombok.Data;
7
+import java.time.LocalDateTime;
8
+
9
+@Data
10
+@TableName("equipment")
11
+public class Equipment {
12
+    @TableId(type = IdType.AUTO)
13
+    private Long id;
14
+    private String deviceName;
15
+    private String deviceType;
16
+    private String model;
17
+    private String serialNumber;
18
+    private String region;
19
+    private String location;
20
+    private String status; // online, offline, maintenance, fault
21
+    private String manufacturer;
22
+    private String installationDate;
23
+    private String lastMaintenanceDate;
24
+    private String nextMaintenanceDate;
25
+    private Double latitude;
26
+    private Double longitude;
27
+    private LocalDateTime createTime;
28
+    private LocalDateTime updateTime;
29
+}

+ 24
- 0
wm-production/wm-production/src/main/java/com/water/production/entity/Notification.java Ver fichero

@@ -0,0 +1,24 @@
1
+package com.water.production.entity;
2
+
3
+import com.baomidou.mybatisplus.annotation.IdType;
4
+import com.baomidou.mybatisplus.annotation.TableId;
5
+import com.baomidou.mybatisplus.annotation.TableName;
6
+import lombok.Data;
7
+import java.time.LocalDateTime;
8
+
9
+@Data
10
+@TableName("notification")
11
+public class Notification {
12
+    @TableId(type = IdType.AUTO)
13
+    private Long id;
14
+    private String title;
15
+    private String content;
16
+    private String type; // forecast, warning, info
17
+    private String region;
18
+    private String priority; // high, medium, low
19
+    private Integer status; // draft, published, archived
20
+    private String publisher;
21
+    private LocalDateTime publishTime;
22
+    private LocalDateTime createTime;
23
+    private LocalDateTime updateTime;
24
+}

+ 27
- 0
wm-production/wm-production/src/main/java/com/water/production/entity/Threshold.java Ver fichero

@@ -0,0 +1,27 @@
1
+package com.water.production.entity;
2
+
3
+import com.baomidou.mybatisplus.annotation.IdType;
4
+import com.baomidou.mybatisplus.annotation.TableId;
5
+import com.baomidou.mybatisplus.annotation.TableName;
6
+import lombok.Data;
7
+import java.time.LocalDateTime;
8
+
9
+@Data
10
+@TableName("threshold")
11
+public class Threshold {
12
+    @TableId(type = IdType.AUTO)
13
+    private Long id;
14
+    private String deviceId;
15
+    private String deviceType;
16
+    private String region;
17
+    private String parameter;
18
+    private Double minValue;
19
+    private Double maxValue;
20
+    private Double warningMin;
21
+    private Double warningMax;
22
+    private String unit;
23
+    private String description;
24
+    private Integer status;
25
+    private LocalDateTime createTime;
26
+    private LocalDateTime updateTime;
27
+}

+ 9
- 0
wm-production/wm-production/src/main/java/com/water/production/mapper/EquipmentMapper.java Ver fichero

@@ -0,0 +1,9 @@
1
+package com.water.production.mapper;
2
+
3
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
4
+import com.water.production.entity.Equipment;
5
+import org.apache.ibatis.annotations.Mapper;
6
+
7
+@Mapper
8
+public interface EquipmentMapper extends BaseMapper<Equipment> {
9
+}

+ 9
- 0
wm-production/wm-production/src/main/java/com/water/production/mapper/NotificationMapper.java Ver fichero

@@ -0,0 +1,9 @@
1
+package com.water.production.mapper;
2
+
3
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
4
+import com.water.production.entity.Notification;
5
+import org.apache.ibatis.annotations.Mapper;
6
+
7
+@Mapper
8
+public interface NotificationMapper extends BaseMapper<Notification> {
9
+}

+ 9
- 0
wm-production/wm-production/src/main/java/com/water/production/mapper/ThresholdMapper.java Ver fichero

@@ -0,0 +1,9 @@
1
+package com.water.production.mapper;
2
+
3
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
4
+import com.water.production.entity.Threshold;
5
+import org.apache.ibatis.annotations.Mapper;
6
+
7
+@Mapper
8
+public interface ThresholdMapper extends BaseMapper<Threshold> {
9
+}

+ 17
- 0
wm-production/wm-production/src/main/java/com/water/production/service/EquipmentService.java Ver fichero

@@ -0,0 +1,17 @@
1
+package com.water.production.service;
2
+
3
+import com.baomidou.mybatisplus.extension.service.IService;
4
+import com.water.production.entity.Equipment;
5
+import com.water.production.vo.EquipmentQueryVO;
6
+import java.util.List;
7
+
8
+public interface EquipmentService extends IService<Equipment> {
9
+    List<Equipment> getEquipmentByName(String deviceName);
10
+    List<Equipment> getEquipmentByType(String deviceType);
11
+    List<Equipment> getEquipmentByRegion(String region);
12
+    List<Equipment> getEquipmentByStatus(String status);
13
+    boolean saveEquipment(Equipment equipment);
14
+    boolean updateEquipment(Equipment equipment);
15
+    boolean deleteEquipment(Long id);
16
+    List<Equipment> queryEquipment(EquipmentQueryVO queryVO);
17
+}

+ 15
- 0
wm-production/wm-production/src/main/java/com/water/production/service/NotificationService.java Ver fichero

@@ -0,0 +1,15 @@
1
+package com.water.production.service;
2
+
3
+import com.baomidou.mybatisplus.extension.service.IService;
4
+import com.water.production.entity.Notification;
5
+import com.water.production.vo.NotificationQueryVO;
6
+import java.util.List;
7
+
8
+public interface NotificationService extends IService<Notification> {
9
+    List<Notification> getNotificationsByRegion(String region);
10
+    List<Notification> getNotificationsByType(String type);
11
+    List<Notification> getActiveNotifications();
12
+    boolean publishNotification(Long id, String publisher);
13
+    boolean archiveNotification(Long id);
14
+    List<Notification> queryNotifications(NotificationQueryVO queryVO);
15
+}

+ 16
- 0
wm-production/wm-production/src/main/java/com/water/production/service/ThresholdService.java Ver fichero

@@ -0,0 +1,16 @@
1
+package com.water.production.service;
2
+
3
+import com.baomidou.mybatisplus.extension.service.IService;
4
+import com.water.production.entity.Threshold;
5
+import com.water.production.vo.ThresholdQueryVO;
6
+import java.util.List;
7
+
8
+public interface ThresholdService extends IService<Threshold> {
9
+    List<Threshold> getThresholdsByDevice(String deviceId);
10
+    List<Threshold> getThresholdsByRegion(String region);
11
+    List<Threshold> getThresholdsByParameter(String parameter);
12
+    boolean saveThreshold(Threshold threshold);
13
+    boolean updateThreshold(Threshold threshold);
14
+    boolean deleteThreshold(Long id);
15
+    List<Threshold> queryThresholds(ThresholdQueryVO queryVO);
16
+}

+ 84
- 0
wm-production/wm-production/src/main/java/com/water/production/service/impl/EquipmentServiceImpl.java Ver fichero

@@ -0,0 +1,84 @@
1
+package com.water.production.service.impl;
2
+
3
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
4
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
5
+import com.water.production.entity.Equipment;
6
+import com.water.production.mapper.EquipmentMapper;
7
+import com.water.production.service.EquipmentService;
8
+import com.water.production.vo.EquipmentQueryVO;
9
+import org.springframework.stereotype.Service;
10
+import java.util.List;
11
+
12
+@Service
13
+public class EquipmentServiceImpl extends ServiceImpl<EquipmentMapper, Equipment> implements EquipmentService {
14
+
15
+    @Override
16
+    public List<Equipment> getEquipmentByName(String deviceName) {
17
+        LambdaQueryWrapper<Equipment> queryWrapper = new LambdaQueryWrapper<>();
18
+        queryWrapper.like(Equipment::getDeviceName, deviceName);
19
+        return list(queryWrapper);
20
+    }
21
+
22
+    @Override
23
+    public List<Equipment> getEquipmentByType(String deviceType) {
24
+        LambdaQueryWrapper<Equipment> queryWrapper = new LambdaQueryWrapper<>();
25
+        queryWrapper.eq(Equipment::getDeviceType, deviceType);
26
+        return list(queryWrapper);
27
+    }
28
+
29
+    @Override
30
+    public List<Equipment> getEquipmentByRegion(String region) {
31
+        LambdaQueryWrapper<Equipment> queryWrapper = new LambdaQueryWrapper<>();
32
+        queryWrapper.eq(Equipment::getRegion, region);
33
+        return list(queryWrapper);
34
+    }
35
+
36
+    @Override
37
+    public List<Equipment> getEquipmentByStatus(String status) {
38
+        LambdaQueryWrapper<Equipment> queryWrapper = new LambdaQueryWrapper<>();
39
+        queryWrapper.eq(Equipment::getStatus, status);
40
+        return list(queryWrapper);
41
+    }
42
+
43
+    @Override
44
+    public boolean saveEquipment(Equipment equipment) {
45
+        equipment.setCreateTime(java.time.LocalDateTime.now());
46
+        equipment.setUpdateTime(java.time.LocalDateTime.now());
47
+        return save(equipment);
48
+    }
49
+
50
+    @Override
51
+    public boolean updateEquipment(Equipment equipment) {
52
+        equipment.setUpdateTime(java.time.LocalDateTime.now());
53
+        return updateById(equipment);
54
+    }
55
+
56
+    @Override
57
+    public boolean deleteEquipment(Long id) {
58
+        return removeById(id);
59
+    }
60
+
61
+    @Override
62
+    public List<Equipment> queryEquipment(EquipmentQueryVO queryVO) {
63
+        LambdaQueryWrapper<Equipment> queryWrapper = new LambdaQueryWrapper<>();
64
+        
65
+        if (queryVO.getDeviceName() != null && !queryVO.getDeviceName().isEmpty()) {
66
+            queryWrapper.like(Equipment::getDeviceName, queryVO.getDeviceName());
67
+        }
68
+        if (queryVO.getDeviceType() != null && !queryVO.getDeviceType().isEmpty()) {
69
+            queryWrapper.eq(Equipment::getDeviceType, queryVO.getDeviceType());
70
+        }
71
+        if (queryVO.getRegion() != null && !queryVO.getRegion().isEmpty()) {
72
+            queryWrapper.eq(Equipment::getRegion, queryVO.getRegion());
73
+        }
74
+        if (queryVO.getStatus() != null && !queryVO.getStatus().isEmpty()) {
75
+            queryWrapper.eq(Equipment::getStatus, queryVO.getStatus());
76
+        }
77
+        if (queryVO.getManufacturer() != null && !queryVO.getManufacturer().isEmpty()) {
78
+            queryWrapper.eq(Equipment::getManufacturer, queryVO.getManufacturer());
79
+        }
80
+        
81
+        queryWrapper.orderByDesc(Equipment::getCreateTime);
82
+        return list(queryWrapper);
83
+    }
84
+}

+ 83
- 0
wm-production/wm-production/src/main/java/com/water/production/service/impl/NotificationServiceImpl.java Ver fichero

@@ -0,0 +1,83 @@
1
+package com.water.production.service.impl;
2
+
3
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
4
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
5
+import com.water.production.entity.Notification;
6
+import com.water.production.mapper.NotificationMapper;
7
+import com.water.production.service.NotificationService;
8
+import com.water.production.vo.NotificationQueryVO;
9
+import org.springframework.stereotype.Service;
10
+import java.util.List;
11
+
12
+@Service
13
+public class NotificationServiceImpl extends ServiceImpl<NotificationMapper, Notification> implements NotificationService {
14
+
15
+    @Override
16
+    public List<Notification> getNotificationsByRegion(String region) {
17
+        LambdaQueryWrapper<Notification> queryWrapper = new LambdaQueryWrapper<>();
18
+        queryWrapper.eq(Notification::getRegion, region)
19
+                   .orderByDesc(Notification::getPublishTime);
20
+        return list(queryWrapper);
21
+    }
22
+
23
+    @Override
24
+    public List<Notification> getNotificationsByType(String type) {
25
+        LambdaQueryWrapper<Notification> queryWrapper = new LambdaQueryWrapper<>();
26
+        queryWrapper.eq(Notification::getType, type)
27
+                   .orderByDesc(Notification::getPublishTime);
28
+        return list(queryWrapper);
29
+    }
30
+
31
+    @Override
32
+    public List<Notification> getActiveNotifications() {
33
+        LambdaQueryWrapper<Notification> queryWrapper = new LambdaQueryWrapper<>();
34
+        queryWrapper.eq(Notification::getStatus, 2) // published
35
+                   .orderByDesc(Notification::getPublishTime);
36
+        return list(queryWrapper);
37
+    }
38
+
39
+    @Override
40
+    public boolean publishNotification(Long id, String publisher) {
41
+        Notification notification = getById(id);
42
+        if (notification != null) {
43
+            notification.setStatus(2); // published
44
+            notification.setPublisher(publisher);
45
+            notification.setPublishTime(java.time.LocalDateTime.now());
46
+            notification.setUpdateTime(java.time.LocalDateTime.now());
47
+            return updateById(notification);
48
+        }
49
+        return false;
50
+    }
51
+
52
+    @Override
53
+    public boolean archiveNotification(Long id) {
54
+        Notification notification = getById(id);
55
+        if (notification != null) {
56
+            notification.setStatus(3); // archived
57
+            notification.setUpdateTime(java.time.LocalDateTime.now());
58
+            return updateById(notification);
59
+        }
60
+        return false;
61
+    }
62
+
63
+    @Override
64
+    public List<Notification> queryNotifications(NotificationQueryVO queryVO) {
65
+        LambdaQueryWrapper<Notification> queryWrapper = new LambdaQueryWrapper<>();
66
+        
67
+        if (queryVO.getRegion() != null && !queryVO.getRegion().isEmpty()) {
68
+            queryWrapper.eq(Notification::getRegion, queryVO.getRegion());
69
+        }
70
+        if (queryVO.getType() != null && !queryVO.getType().isEmpty()) {
71
+            queryWrapper.eq(Notification::getType, queryVO.getType());
72
+        }
73
+        if (queryVO.getStatus() != null) {
74
+            queryWrapper.eq(Notification::getStatus, queryVO.getStatus());
75
+        }
76
+        if (queryVO.getPriority() != null && !queryVO.getPriority().isEmpty()) {
77
+            queryWrapper.eq(Notification::getPriority, queryVO.getPriority());
78
+        }
79
+        
80
+        queryWrapper.orderByDesc(Notification::getCreateTime);
81
+        return list(queryWrapper);
82
+    }
83
+}

+ 73
- 0
wm-production/wm-production/src/main/java/com/water/production/service/impl/ThresholdServiceImpl.java Ver fichero

@@ -0,0 +1,73 @@
1
+package com.water.production.service.impl;
2
+
3
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
4
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
5
+import com.water.production.entity.Threshold;
6
+import com.water.production.mapper.ThresholdMapper;
7
+import com.water.production.service.ThresholdService;
8
+import com.water.production.vo.ThresholdQueryVO;
9
+import org.springframework.stereotype.Service;
10
+import java.util.List;
11
+
12
+@Service
13
+public class ThresholdServiceImpl extends ServiceImpl<ThresholdMapper, Threshold> implements ThresholdService {
14
+
15
+    @Override
16
+    public List<Threshold> getThresholdsByDevice(String deviceId) {
17
+        LambdaQueryWrapper<Threshold> queryWrapper = new LambdaQueryWrapper<>();
18
+        queryWrapper.eq(Threshold::getDeviceId, deviceId);
19
+        return list(queryWrapper);
20
+    }
21
+
22
+    @Override
23
+    public List<Threshold> getThresholdsByRegion(String region) {
24
+        LambdaQueryWrapper<Threshold> queryWrapper = new LambdaQueryWrapper<>();
25
+        queryWrapper.eq(Threshold::getRegion, region);
26
+        return list(queryWrapper);
27
+    }
28
+
29
+    @Override
30
+    public List<Threshold> getThresholdsByParameter(String parameter) {
31
+        LambdaQueryWrapper<Threshold> queryWrapper = new LambdaQueryWrapper<>();
32
+        queryWrapper.eq(Threshold::getParameter, parameter);
33
+        return list(queryWrapper);
34
+    }
35
+
36
+    @Override
37
+    public boolean saveThreshold(Threshold threshold) {
38
+        threshold.setCreateTime(java.time.LocalDateTime.now());
39
+        threshold.setUpdateTime(java.time.LocalDateTime.now());
40
+        return save(threshold);
41
+    }
42
+
43
+    @Override
44
+    public boolean updateThreshold(Threshold threshold) {
45
+        threshold.setUpdateTime(java.time.LocalDateTime.now());
46
+        return updateById(threshold);
47
+    }
48
+
49
+    @Override
50
+    public boolean deleteThreshold(Long id) {
51
+        return removeById(id);
52
+    }
53
+
54
+    @Override
55
+    public List<Threshold> queryThresholds(ThresholdQueryVO queryVO) {
56
+        LambdaQueryWrapper<Threshold> queryWrapper = new LambdaQueryWrapper<>();
57
+        
58
+        if (queryVO.getDeviceId() != null && !queryVO.getDeviceId().isEmpty()) {
59
+            queryWrapper.eq(Threshold::getDeviceId, queryVO.getDeviceId());
60
+        }
61
+        if (queryVO.getRegion() != null && !queryVO.getRegion().isEmpty()) {
62
+            queryWrapper.eq(Threshold::getRegion, queryVO.getRegion());
63
+        }
64
+        if (queryVO.getParameter() != null && !queryVO.getParameter().isEmpty()) {
65
+            queryWrapper.eq(Threshold::getParameter, queryVO.getParameter());
66
+        }
67
+        if (queryVO.getStatus() != null) {
68
+            queryWrapper.eq(Threshold::getStatus, queryVO.getStatus());
69
+        }
70
+        
71
+        return list(queryWrapper);
72
+    }
73
+}

+ 23
- 0
wm-production/wm-production/src/main/java/com/water/production/vo/EquipmentQueryVO.java Ver fichero

@@ -0,0 +1,23 @@
1
+package com.water.production.vo;
2
+
3
+import lombok.Data;
4
+import io.swagger.v3.oas.annotations.media.Schema;
5
+
6
+@Data
7
+@Schema(description = "设备查询参数")
8
+public class EquipmentQueryVO {
9
+    @Schema(description = "设备名称(模糊查询)")
10
+    private String deviceName;
11
+    
12
+    @Schema(description = "设备类型")
13
+    private String deviceType;
14
+    
15
+    @Schema(description = "区域")
16
+    private String region;
17
+    
18
+    @Schema(description = = "状态:online-在线,offline-离线,maintenance-维护中,fault-故障")
19
+    private String status;
20
+    
21
+    @Schema(description = "制造商")
22
+    private String manufacturer;
23
+}

+ 20
- 0
wm-production/wm-production/src/main/java/com/water/production/vo/NotificationQueryVO.java Ver fichero

@@ -0,0 +1,20 @@
1
+package com.water.production.vo;
2
+
3
+import lombok.Data;
4
+import io.swagger.v3.oas.annotations.media.Schema;
5
+
6
+@Data
7
+@Schema(description = "信息发布查询参数")
8
+public class NotificationQueryVO {
9
+    @Schema(description = "区域")
10
+    private String region;
11
+    
12
+    @Schema(description = "类型:forecast-预报,warning-预警,info-通知")
13
+    private String type;
14
+    
15
+    @Schema(description = "状态:1-草稿,2-已发布,3-已归档")
16
+    private Integer status;
17
+    
18
+    @Schema(description = "优先级:high-高,medium-中,low-低")
19
+    private String priority;
20
+}

+ 20
- 0
wm-production/wm-production/src/main/java/com/water/production/vo/ThresholdQueryVO.java Ver fichero

@@ -0,0 +1,20 @@
1
+package com.water.production.vo;
2
+
3
+import lombok.Data;
4
+import io.swagger.v3.oas.annotations.media.Schema;
5
+
6
+@Data
7
+@Schema(description = "阈值查询参数")
8
+public class ThresholdQueryVO {
9
+    @Schema(description = "设备ID")
10
+    private String deviceId;
11
+    
12
+    @Schema(description = "区域")
13
+    private String region;
14
+    
15
+    @Schema(description = "参数名称")
16
+    private String parameter;
17
+    
18
+    @Schema(description = "状态:1-启用,0-禁用")
19
+    private Integer status;
20
+}