diff --git a/wm-production/pom.xml b/wm-production/pom.xml index 93e9e58c..ec363cc0 100644 --- a/wm-production/pom.xml +++ b/wm-production/pom.xml @@ -13,9 +13,8 @@ cn.dev33sa-token-spring-boot3-starter org.postgresqlpostgresql - io.springfox - springfox-boot-starter - 3.0.0 + com.github.xiaoymin + knife4j-openapi3-jakarta-spring-boot-starter \ No newline at end of file diff --git a/wm-production/sql/init_data.sql b/wm-production/sql/init_data.sql new file mode 100644 index 00000000..f341a83b --- /dev/null +++ b/wm-production/sql/init_data.sql @@ -0,0 +1,83 @@ +-- 阈值表 +CREATE TABLE IF NOT EXISTS threshold ( + id BIGSERIAL PRIMARY KEY, + device_id VARCHAR(100) NOT NULL, + device_type VARCHAR(50), + region VARCHAR(50), + parameter VARCHAR(100) NOT NULL, + min_value DOUBLE PRECISION, + max_value DOUBLE PRECISION, + warning_min DOUBLE PRECISION, + warning_max DOUBLE PRECISION, + unit VARCHAR(20), + description TEXT, + status INTEGER DEFAULT 1 COMMENT '1-启用,0-禁用', + create_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + update_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP +); + +-- 信息发布表 +CREATE TABLE IF NOT EXISTS notification ( + id BIGSERIAL PRIMARY KEY, + title VARCHAR(200) NOT NULL, + content TEXT NOT NULL, + type VARCHAR(20) NOT NULL COMMENT 'forecast-预报,warning-预警,info-通知', + region VARCHAR(50), + priority VARCHAR(20) DEFAULT 'medium' COMMENT 'high-高,medium-中,low-低', + status INTEGER DEFAULT 1 COMMENT '1-草稿,2-已发布,3-已归档', + publisher VARCHAR(100), + publish_time TIMESTAMP, + create_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + update_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP +); + +-- 设备表 +CREATE TABLE IF NOT EXISTS equipment ( + id BIGSERIAL PRIMARY KEY, + device_name VARCHAR(100) NOT NULL, + device_type VARCHAR(50), + model VARCHAR(100), + serial_number VARCHAR(100), + region VARCHAR(50), + location TEXT, + status VARCHAR(20) DEFAULT 'offline' COMMENT 'online-在线,offline-离线,maintenance-维护中,fault-故障', + manufacturer VARCHAR(100), + installation_date DATE, + last_maintenance_date DATE, + next_maintenance_date DATE, + latitude DOUBLE PRECISION, + longitude DOUBLE PRECISION, + create_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + update_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP +); + +-- 创建索引 +CREATE INDEX IF NOT EXISTS idx_threshold_device_id ON threshold(device_id); +CREATE INDEX IF NOT EXISTS idx_threshold_region ON threshold(region); +CREATE INDEX IF NOT EXISTS idx_threshold_parameter ON threshold(parameter); +CREATE INDEX IF NOT EXISTS idx_notification_region ON notification(region); +CREATE INDEX IF NOT EXISTS idx_notification_type ON notification(type); +CREATE INDEX IF NOT EXISTS idx_notification_status ON notification(status); +CREATE INDEX IF NOT EXISTS idx_equipment_device_name ON equipment(device_name); +CREATE INDEX IF NOT EXISTS idx_equipment_device_type ON equipment(device_type); +CREATE INDEX IF NOT EXISTS idx_equipment_region ON equipment(region); +CREATE INDEX IF NOT EXISTS idx_equipment_status ON equipment(status); + +-- 插入示例数据 +-- 阈值示例 +INSERT INTO threshold (device_id, device_type, region, parameter, min_value, max_value, warning_min, warning_max, unit, description, status) VALUES +('DEV001', 'pressure_sensor', '精河县', 'water_pressure', 0.2, 0.8, 0.15, 0.85, 'MPa', '供水压力阈值', 1), +('DEV002', 'flow_meter', '精河县', 'water_flow', 10, 100, 8, 110, 'm³/h', '水流流量阈值', 1), +('DEV003', 'quality_sensor', '精河县', 'water_quality', 0, 1, 0.1, 0.9, 'pH', '水质pH值阈值', 1); + +-- 设备示例 +INSERT INTO equipment (device_name, device_type, model, serial_number, region, location, status, manufacturer, installation_date) VALUES +('压力传感器001', 'pressure_sensor', 'PS-3000', 'SN0012023001', '精河县', '供水站A区', 'online', '华为', '2023-01-15'), +('流量计001', 'flow_meter', 'FM-5000', 'SN0012023002', '精河县', '供水站B区', 'online', '西门子', '2023-02-20'), +('水质检测仪001', 'quality_sensor', 'QS-2000', 'SN0012023003', '精河县', '供水站C区', 'online', '霍尼韦尔', '2023-03-10'); + +-- 信息发布示例 +INSERT INTO notification (title, content, type, region, priority, status, publisher, publish_time) VALUES +('停水通知', '因设备维护,预计明天9:00-12:00精河县部分区域将暂停供水', 'warning', '精河县', 'high', 2, 'system_admin', '2026-06-14T08:00:00'), +('水质提升通知', '本季度已完成水质净化设备升级,水质显著提升', 'info', '精河县', 'medium', 2, 'water_quality_team', '2026-06-01T10:00:00'), +('雨季供水保障通知', '近期降雨较多,各水厂已加强巡检,确保供水稳定', 'forecast', '精河县', 'low', 2, 'emergency_team', '2026-05-20T14:00:00'); \ No newline at end of file diff --git a/wm-production/wm-production/src/main/java/com/water/production/controller/EquipmentController.java b/wm-production/wm-production/src/main/java/com/water/production/controller/EquipmentController.java new file mode 100644 index 00000000..6a2e0041 --- /dev/null +++ b/wm-production/wm-production/src/main/java/com/water/production/controller/EquipmentController.java @@ -0,0 +1,83 @@ +package com.water.production.controller; + +import com.water.production.entity.Equipment; +import com.water.production.service.EquipmentService; +import com.water.production.vo.EquipmentQueryVO; +import com.water.production.Result; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; +import java.util.List; + +@RestController +@RequestMapping("/api/equipment") +@Tag(name = "设备管理", description = "设备列表查询接口") +public class EquipmentController { + + @Autowired + private EquipmentService equipmentService; + + @PostMapping("/save") + @Operation(summary = "保存设备信息") + public Result saveEquipment(@RequestBody Equipment equipment) { + boolean success = equipmentService.saveEquipment(equipment); + return success ? Result.success(true) : Result.error("保存失败"); + } + + @PutMapping("/update") + @Operation(summary = "更新设备信息") + public Result updateEquipment(@RequestBody Equipment equipment) { + boolean success = equipmentService.updateEquipment(equipment); + return success ? Result.success(true) : Result.error("更新失败"); + } + + @DeleteMapping("/delete/{id}") + @Operation(summary = "删除设备信息") + public Result deleteEquipment(@PathVariable Long id) { + boolean success = equipmentService.deleteEquipment(id); + return success ? Result.success(true) : Result.error("删除失败"); + } + + @GetMapping("/list") + @Operation(summary = "获取所有设备列表") + public Result> list() { + List equipmentList = equipmentService.list(); + return Result.success(equipmentList); + } + + @PostMapping("/query") + @Operation(summary = "查询设备列表") + public Result> query(@RequestBody EquipmentQueryVO queryVO) { + List equipmentList = equipmentService.queryEquipment(queryVO); + return Result.success(equipmentList); + } + + @GetMapping("/name/{deviceName}") + @Operation(summary = "根据设备名称查询(模糊匹配)") + public Result> getByName(@PathVariable String deviceName) { + List equipmentList = equipmentService.getEquipmentByName(deviceName); + return Result.success(equipmentList); + } + + @GetMapping("/type/{deviceType}") + @Operation(summary = "根据设备类型查询") + public Result> getByType(@PathVariable String deviceType) { + List equipmentList = equipmentService.getEquipmentByType(deviceType); + return Result.success(equipmentList); + } + + @GetMapping("/region/{region}") + @Operation(summary = "根据区域查询") + public Result> getByRegion(@PathVariable String region) { + List equipmentList = equipmentService.getEquipmentByRegion(region); + return Result.success(equipmentList); + } + + @GetMapping("/status/{status}") + @Operation(summary = "根据状态查询") + public Result> getByStatus(@PathVariable String status) { + List equipmentList = equipmentService.getEquipmentByStatus(status); + return Result.success(equipmentList); + } +} \ No newline at end of file diff --git a/wm-production/wm-production/src/main/java/com/water/production/controller/NotificationController.java b/wm-production/wm-production/src/main/java/com/water/production/controller/NotificationController.java new file mode 100644 index 00000000..5260be5d --- /dev/null +++ b/wm-production/wm-production/src/main/java/com/water/production/controller/NotificationController.java @@ -0,0 +1,91 @@ +package com.water.production.controller; + +import com.water.production.entity.Notification; +import com.water.production.service.NotificationService; +import com.water.production.vo.NotificationQueryVO; +import com.water.production.Result; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; +import java.util.List; + +@RestController +@RequestMapping("/api/notification") +@Tag(name = "信息发布", description = "预报/预警信息发布接口") +public class NotificationController { + + @Autowired + private NotificationService notificationService; + + @PostMapping("/save") + @Operation(summary = "保存草稿") + public Result saveNotification(@RequestBody Notification notification) { + notification.setStatus(1); // draft + boolean success = notificationService.save(notification); + return success ? Result.success(true) : Result.error("保存失败"); + } + + @PutMapping("/update") + @Operation(summary = "更新信息") + public Result updateNotification(@RequestBody Notification notification) { + boolean success = notificationService.updateById(notification); + return success ? Result.success(true) : Result.error("更新失败"); + } + + @PutMapping("/publish/{id}") + @Operation(summary = "发布信息") + public Result publishNotification(@PathVariable Long id, @RequestParam String publisher) { + boolean success = notificationService.publishNotification(id, publisher); + return success ? Result.success(true) : Result.error("发布失败"); + } + + @PutMapping("/archive/{id}") + @Operation(summary = "归档信息") + public Result archiveNotification(@PathVariable Long id) { + boolean success = notificationService.archiveNotification(id); + return success ? Result.success(true) : Result.error("归档失败"); + } + + @DeleteMapping("/delete/{id}") + @Operation(summary = = "删除信息") + public Result deleteNotification(@PathVariable Long id) { + boolean success = notificationService.removeById(id); + return success ? Result.success(true) : Result.error("删除失败"); + } + + @GetMapping("/list") + @Operation(summary = "获取所有信息列表") + public Result> list() { + List notifications = notificationService.list(); + return Result.success(notifications); + } + + @PostMapping("/query") + @Operation(summary = "查询信息列表") + public Result> query(@RequestBody NotificationQueryVO queryVO) { + List notifications = notificationService.queryNotifications(queryVO); + return Result.success(notifications); + } + + @GetMapping("/region/{region}") + @Operation(summary = "根据区域获取信息") + public Result> getByRegion(@PathVariable String region) { + List notifications = notificationService.getNotificationsByRegion(region); + return Result.success(notifications); + } + + @GetMapping("/type/{type}") + @Operation(summary = = "根据类型获取信息") + public Result> getByType(@PathVariable String type) { + List notifications = notificationService.getNotificationsByType(type); + return Result.success(notifications); + } + + @GetMapping("/active") + @Operation(summary = "获取已发布信息") + public Result> getActiveNotifications() { + List notifications = notificationService.getActiveNotifications(); + return Result.success(notifications); + } +} \ No newline at end of file diff --git a/wm-production/wm-production/src/main/java/com/water/production/controller/ThresholdController.java b/wm-production/wm-production/src/main/java/com/water/production/controller/ThresholdController.java new file mode 100644 index 00000000..a5ebbbc6 --- /dev/null +++ b/wm-production/wm-production/src/main/java/com/water/production/controller/ThresholdController.java @@ -0,0 +1,77 @@ +package com.water.production.controller; + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.water.production.entity.Threshold; +import com.water.production.service.ThresholdService; +import com.water.production.vo.ThresholdQueryVO; +import com.water.production.Result; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; +import java.util.List; + +@RestController +@RequestMapping("/api/threshold") +@Tag(name = "阈值管理", description = "报警阈值编辑接口") +public class ThresholdController { + + @Autowired + private ThresholdService thresholdService; + + @PostMapping("/save") + @Operation(summary = "保存阈值配置") + public Result saveThreshold(@RequestBody Threshold threshold) { + boolean success = thresholdService.saveThreshold(threshold); + return success ? Result.success(true) : Result.error("保存失败"); + } + + @PutMapping("/update") + @Operation(summary = "更新阈值配置") + public Result updateThreshold(@RequestBody Threshold threshold) { + boolean success = thresholdService.updateThreshold(threshold); + return success ? Result.success(true) : Result.error("更新失败"); + } + + @DeleteMapping("/delete/{id}") + @Operation(summary = "删除阈值配置") + public Result deleteThreshold(@PathVariable Long id) { + boolean success = thresholdService.deleteThreshold(id); + return success ? Result.success(true) : Result.error("删除失败"); + } + + @GetMapping("/list") + @Operation(summary = "获取阈值配置列表") + public Result> list() { + List thresholds = thresholdService.list(); + return Result.success(thresholds); + } + + @PostMapping("/query") + @Operation(summary = "查询阈值配置") + public Result> query(@RequestBody ThresholdQueryVO queryVO) { + List thresholds = thresholdService.queryThresholds(queryVO); + return Result.success(thresholds); + } + + @GetMapping("/device/{deviceId}") + @Operation(summary = "根据设备ID获取阈值") + public Result> getByDeviceId(@PathVariable String deviceId) { + List thresholds = thresholdService.getThresholdsByDevice(deviceId); + return Result.success(thresholds); + } + + @GetMapping("/region/{region}") + @Operation(summary = "根据区域获取阈值") + public Result> getByRegion(@PathVariable String region) { + List thresholds = thresholdService.getThresholdsByRegion(region); + return Result.success(thresholds); + } + + @GetMapping("/parameter/{parameter}") + @Operation(summary = "根据参数获取阈值") + public Result> getByParameter(@PathVariable String parameter) { + List thresholds = thresholdService.getThresholdsByParameter(parameter); + return Result.success(thresholds); + } +} \ No newline at end of file diff --git a/wm-production/wm-production/src/main/java/com/water/production/entity/Equipment.java b/wm-production/wm-production/src/main/java/com/water/production/entity/Equipment.java new file mode 100644 index 00000000..9ebe3d9c --- /dev/null +++ b/wm-production/wm-production/src/main/java/com/water/production/entity/Equipment.java @@ -0,0 +1,29 @@ +package com.water.production.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; +import java.time.LocalDateTime; + +@Data +@TableName("equipment") +public class Equipment { + @TableId(type = IdType.AUTO) + private Long id; + private String deviceName; + private String deviceType; + private String model; + private String serialNumber; + private String region; + private String location; + private String status; // online, offline, maintenance, fault + private String manufacturer; + private String installationDate; + private String lastMaintenanceDate; + private String nextMaintenanceDate; + private Double latitude; + private Double longitude; + private LocalDateTime createTime; + private LocalDateTime updateTime; +} \ No newline at end of file diff --git a/wm-production/wm-production/src/main/java/com/water/production/entity/Notification.java b/wm-production/wm-production/src/main/java/com/water/production/entity/Notification.java new file mode 100644 index 00000000..28e2702e --- /dev/null +++ b/wm-production/wm-production/src/main/java/com/water/production/entity/Notification.java @@ -0,0 +1,24 @@ +package com.water.production.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; +import java.time.LocalDateTime; + +@Data +@TableName("notification") +public class Notification { + @TableId(type = IdType.AUTO) + private Long id; + private String title; + private String content; + private String type; // forecast, warning, info + private String region; + private String priority; // high, medium, low + private Integer status; // draft, published, archived + private String publisher; + private LocalDateTime publishTime; + private LocalDateTime createTime; + private LocalDateTime updateTime; +} \ No newline at end of file diff --git a/wm-production/wm-production/src/main/java/com/water/production/entity/Threshold.java b/wm-production/wm-production/src/main/java/com/water/production/entity/Threshold.java new file mode 100644 index 00000000..9a62e4ec --- /dev/null +++ b/wm-production/wm-production/src/main/java/com/water/production/entity/Threshold.java @@ -0,0 +1,27 @@ +package com.water.production.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; +import java.time.LocalDateTime; + +@Data +@TableName("threshold") +public class Threshold { + @TableId(type = IdType.AUTO) + private Long id; + private String deviceId; + private String deviceType; + private String region; + private String parameter; + private Double minValue; + private Double maxValue; + private Double warningMin; + private Double warningMax; + private String unit; + private String description; + private Integer status; + private LocalDateTime createTime; + private LocalDateTime updateTime; +} \ No newline at end of file diff --git a/wm-production/wm-production/src/main/java/com/water/production/mapper/EquipmentMapper.java b/wm-production/wm-production/src/main/java/com/water/production/mapper/EquipmentMapper.java new file mode 100644 index 00000000..90b8cb9a --- /dev/null +++ b/wm-production/wm-production/src/main/java/com/water/production/mapper/EquipmentMapper.java @@ -0,0 +1,9 @@ +package com.water.production.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.water.production.entity.Equipment; +import org.apache.ibatis.annotations.Mapper; + +@Mapper +public interface EquipmentMapper extends BaseMapper { +} \ No newline at end of file diff --git a/wm-production/wm-production/src/main/java/com/water/production/mapper/NotificationMapper.java b/wm-production/wm-production/src/main/java/com/water/production/mapper/NotificationMapper.java new file mode 100644 index 00000000..5d51fe54 --- /dev/null +++ b/wm-production/wm-production/src/main/java/com/water/production/mapper/NotificationMapper.java @@ -0,0 +1,9 @@ +package com.water.production.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.water.production.entity.Notification; +import org.apache.ibatis.annotations.Mapper; + +@Mapper +public interface NotificationMapper extends BaseMapper { +} \ No newline at end of file diff --git a/wm-production/wm-production/src/main/java/com/water/production/mapper/ThresholdMapper.java b/wm-production/wm-production/src/main/java/com/water/production/mapper/ThresholdMapper.java new file mode 100644 index 00000000..c4aa895a --- /dev/null +++ b/wm-production/wm-production/src/main/java/com/water/production/mapper/ThresholdMapper.java @@ -0,0 +1,9 @@ +package com.water.production.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.water.production.entity.Threshold; +import org.apache.ibatis.annotations.Mapper; + +@Mapper +public interface ThresholdMapper extends BaseMapper { +} \ No newline at end of file diff --git a/wm-production/wm-production/src/main/java/com/water/production/service/EquipmentService.java b/wm-production/wm-production/src/main/java/com/water/production/service/EquipmentService.java new file mode 100644 index 00000000..eb523922 --- /dev/null +++ b/wm-production/wm-production/src/main/java/com/water/production/service/EquipmentService.java @@ -0,0 +1,17 @@ +package com.water.production.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.water.production.entity.Equipment; +import com.water.production.vo.EquipmentQueryVO; +import java.util.List; + +public interface EquipmentService extends IService { + List getEquipmentByName(String deviceName); + List getEquipmentByType(String deviceType); + List getEquipmentByRegion(String region); + List getEquipmentByStatus(String status); + boolean saveEquipment(Equipment equipment); + boolean updateEquipment(Equipment equipment); + boolean deleteEquipment(Long id); + List queryEquipment(EquipmentQueryVO queryVO); +} \ No newline at end of file diff --git a/wm-production/wm-production/src/main/java/com/water/production/service/NotificationService.java b/wm-production/wm-production/src/main/java/com/water/production/service/NotificationService.java new file mode 100644 index 00000000..cc4e5292 --- /dev/null +++ b/wm-production/wm-production/src/main/java/com/water/production/service/NotificationService.java @@ -0,0 +1,15 @@ +package com.water.production.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.water.production.entity.Notification; +import com.water.production.vo.NotificationQueryVO; +import java.util.List; + +public interface NotificationService extends IService { + List getNotificationsByRegion(String region); + List getNotificationsByType(String type); + List getActiveNotifications(); + boolean publishNotification(Long id, String publisher); + boolean archiveNotification(Long id); + List queryNotifications(NotificationQueryVO queryVO); +} \ No newline at end of file diff --git a/wm-production/wm-production/src/main/java/com/water/production/service/ThresholdService.java b/wm-production/wm-production/src/main/java/com/water/production/service/ThresholdService.java new file mode 100644 index 00000000..fa559291 --- /dev/null +++ b/wm-production/wm-production/src/main/java/com/water/production/service/ThresholdService.java @@ -0,0 +1,16 @@ +package com.water.production.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.water.production.entity.Threshold; +import com.water.production.vo.ThresholdQueryVO; +import java.util.List; + +public interface ThresholdService extends IService { + List getThresholdsByDevice(String deviceId); + List getThresholdsByRegion(String region); + List getThresholdsByParameter(String parameter); + boolean saveThreshold(Threshold threshold); + boolean updateThreshold(Threshold threshold); + boolean deleteThreshold(Long id); + List queryThresholds(ThresholdQueryVO queryVO); +} \ No newline at end of file diff --git a/wm-production/wm-production/src/main/java/com/water/production/service/impl/EquipmentServiceImpl.java b/wm-production/wm-production/src/main/java/com/water/production/service/impl/EquipmentServiceImpl.java new file mode 100644 index 00000000..37f4b47e --- /dev/null +++ b/wm-production/wm-production/src/main/java/com/water/production/service/impl/EquipmentServiceImpl.java @@ -0,0 +1,84 @@ +package com.water.production.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.water.production.entity.Equipment; +import com.water.production.mapper.EquipmentMapper; +import com.water.production.service.EquipmentService; +import com.water.production.vo.EquipmentQueryVO; +import org.springframework.stereotype.Service; +import java.util.List; + +@Service +public class EquipmentServiceImpl extends ServiceImpl implements EquipmentService { + + @Override + public List getEquipmentByName(String deviceName) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.like(Equipment::getDeviceName, deviceName); + return list(queryWrapper); + } + + @Override + public List getEquipmentByType(String deviceType) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(Equipment::getDeviceType, deviceType); + return list(queryWrapper); + } + + @Override + public List getEquipmentByRegion(String region) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(Equipment::getRegion, region); + return list(queryWrapper); + } + + @Override + public List getEquipmentByStatus(String status) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(Equipment::getStatus, status); + return list(queryWrapper); + } + + @Override + public boolean saveEquipment(Equipment equipment) { + equipment.setCreateTime(java.time.LocalDateTime.now()); + equipment.setUpdateTime(java.time.LocalDateTime.now()); + return save(equipment); + } + + @Override + public boolean updateEquipment(Equipment equipment) { + equipment.setUpdateTime(java.time.LocalDateTime.now()); + return updateById(equipment); + } + + @Override + public boolean deleteEquipment(Long id) { + return removeById(id); + } + + @Override + public List queryEquipment(EquipmentQueryVO queryVO) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + + if (queryVO.getDeviceName() != null && !queryVO.getDeviceName().isEmpty()) { + queryWrapper.like(Equipment::getDeviceName, queryVO.getDeviceName()); + } + if (queryVO.getDeviceType() != null && !queryVO.getDeviceType().isEmpty()) { + queryWrapper.eq(Equipment::getDeviceType, queryVO.getDeviceType()); + } + if (queryVO.getRegion() != null && !queryVO.getRegion().isEmpty()) { + queryWrapper.eq(Equipment::getRegion, queryVO.getRegion()); + } + if (queryVO.getStatus() != null && !queryVO.getStatus().isEmpty()) { + queryWrapper.eq(Equipment::getStatus, queryVO.getStatus()); + } + if (queryVO.getManufacturer() != null && !queryVO.getManufacturer().isEmpty()) { + queryWrapper.eq(Equipment::getManufacturer, queryVO.getManufacturer()); + } + + queryWrapper.orderByDesc(Equipment::getCreateTime); + return list(queryWrapper); + } +} \ No newline at end of file diff --git a/wm-production/wm-production/src/main/java/com/water/production/service/impl/NotificationServiceImpl.java b/wm-production/wm-production/src/main/java/com/water/production/service/impl/NotificationServiceImpl.java new file mode 100644 index 00000000..0890addd --- /dev/null +++ b/wm-production/wm-production/src/main/java/com/water/production/service/impl/NotificationServiceImpl.java @@ -0,0 +1,83 @@ +package com.water.production.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.water.production.entity.Notification; +import com.water.production.mapper.NotificationMapper; +import com.water.production.service.NotificationService; +import com.water.production.vo.NotificationQueryVO; +import org.springframework.stereotype.Service; +import java.util.List; + +@Service +public class NotificationServiceImpl extends ServiceImpl implements NotificationService { + + @Override + public List getNotificationsByRegion(String region) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(Notification::getRegion, region) + .orderByDesc(Notification::getPublishTime); + return list(queryWrapper); + } + + @Override + public List getNotificationsByType(String type) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(Notification::getType, type) + .orderByDesc(Notification::getPublishTime); + return list(queryWrapper); + } + + @Override + public List getActiveNotifications() { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(Notification::getStatus, 2) // published + .orderByDesc(Notification::getPublishTime); + return list(queryWrapper); + } + + @Override + public boolean publishNotification(Long id, String publisher) { + Notification notification = getById(id); + if (notification != null) { + notification.setStatus(2); // published + notification.setPublisher(publisher); + notification.setPublishTime(java.time.LocalDateTime.now()); + notification.setUpdateTime(java.time.LocalDateTime.now()); + return updateById(notification); + } + return false; + } + + @Override + public boolean archiveNotification(Long id) { + Notification notification = getById(id); + if (notification != null) { + notification.setStatus(3); // archived + notification.setUpdateTime(java.time.LocalDateTime.now()); + return updateById(notification); + } + return false; + } + + @Override + public List queryNotifications(NotificationQueryVO queryVO) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + + if (queryVO.getRegion() != null && !queryVO.getRegion().isEmpty()) { + queryWrapper.eq(Notification::getRegion, queryVO.getRegion()); + } + if (queryVO.getType() != null && !queryVO.getType().isEmpty()) { + queryWrapper.eq(Notification::getType, queryVO.getType()); + } + if (queryVO.getStatus() != null) { + queryWrapper.eq(Notification::getStatus, queryVO.getStatus()); + } + if (queryVO.getPriority() != null && !queryVO.getPriority().isEmpty()) { + queryWrapper.eq(Notification::getPriority, queryVO.getPriority()); + } + + queryWrapper.orderByDesc(Notification::getCreateTime); + return list(queryWrapper); + } +} \ No newline at end of file diff --git a/wm-production/wm-production/src/main/java/com/water/production/service/impl/ThresholdServiceImpl.java b/wm-production/wm-production/src/main/java/com/water/production/service/impl/ThresholdServiceImpl.java new file mode 100644 index 00000000..8c43a9f7 --- /dev/null +++ b/wm-production/wm-production/src/main/java/com/water/production/service/impl/ThresholdServiceImpl.java @@ -0,0 +1,73 @@ +package com.water.production.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.water.production.entity.Threshold; +import com.water.production.mapper.ThresholdMapper; +import com.water.production.service.ThresholdService; +import com.water.production.vo.ThresholdQueryVO; +import org.springframework.stereotype.Service; +import java.util.List; + +@Service +public class ThresholdServiceImpl extends ServiceImpl implements ThresholdService { + + @Override + public List getThresholdsByDevice(String deviceId) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(Threshold::getDeviceId, deviceId); + return list(queryWrapper); + } + + @Override + public List getThresholdsByRegion(String region) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(Threshold::getRegion, region); + return list(queryWrapper); + } + + @Override + public List getThresholdsByParameter(String parameter) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(Threshold::getParameter, parameter); + return list(queryWrapper); + } + + @Override + public boolean saveThreshold(Threshold threshold) { + threshold.setCreateTime(java.time.LocalDateTime.now()); + threshold.setUpdateTime(java.time.LocalDateTime.now()); + return save(threshold); + } + + @Override + public boolean updateThreshold(Threshold threshold) { + threshold.setUpdateTime(java.time.LocalDateTime.now()); + return updateById(threshold); + } + + @Override + public boolean deleteThreshold(Long id) { + return removeById(id); + } + + @Override + public List queryThresholds(ThresholdQueryVO queryVO) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + + if (queryVO.getDeviceId() != null && !queryVO.getDeviceId().isEmpty()) { + queryWrapper.eq(Threshold::getDeviceId, queryVO.getDeviceId()); + } + if (queryVO.getRegion() != null && !queryVO.getRegion().isEmpty()) { + queryWrapper.eq(Threshold::getRegion, queryVO.getRegion()); + } + if (queryVO.getParameter() != null && !queryVO.getParameter().isEmpty()) { + queryWrapper.eq(Threshold::getParameter, queryVO.getParameter()); + } + if (queryVO.getStatus() != null) { + queryWrapper.eq(Threshold::getStatus, queryVO.getStatus()); + } + + return list(queryWrapper); + } +} \ No newline at end of file diff --git a/wm-production/wm-production/src/main/java/com/water/production/vo/EquipmentQueryVO.java b/wm-production/wm-production/src/main/java/com/water/production/vo/EquipmentQueryVO.java new file mode 100644 index 00000000..4f9bc280 --- /dev/null +++ b/wm-production/wm-production/src/main/java/com/water/production/vo/EquipmentQueryVO.java @@ -0,0 +1,23 @@ +package com.water.production.vo; + +import lombok.Data; +import io.swagger.v3.oas.annotations.media.Schema; + +@Data +@Schema(description = "设备查询参数") +public class EquipmentQueryVO { + @Schema(description = "设备名称(模糊查询)") + private String deviceName; + + @Schema(description = "设备类型") + private String deviceType; + + @Schema(description = "区域") + private String region; + + @Schema(description = = "状态:online-在线,offline-离线,maintenance-维护中,fault-故障") + private String status; + + @Schema(description = "制造商") + private String manufacturer; +} \ No newline at end of file diff --git a/wm-production/wm-production/src/main/java/com/water/production/vo/NotificationQueryVO.java b/wm-production/wm-production/src/main/java/com/water/production/vo/NotificationQueryVO.java new file mode 100644 index 00000000..b3bb8f01 --- /dev/null +++ b/wm-production/wm-production/src/main/java/com/water/production/vo/NotificationQueryVO.java @@ -0,0 +1,20 @@ +package com.water.production.vo; + +import lombok.Data; +import io.swagger.v3.oas.annotations.media.Schema; + +@Data +@Schema(description = "信息发布查询参数") +public class NotificationQueryVO { + @Schema(description = "区域") + private String region; + + @Schema(description = "类型:forecast-预报,warning-预警,info-通知") + private String type; + + @Schema(description = "状态:1-草稿,2-已发布,3-已归档") + private Integer status; + + @Schema(description = "优先级:high-高,medium-中,low-低") + private String priority; +} \ No newline at end of file diff --git a/wm-production/wm-production/src/main/java/com/water/production/vo/ThresholdQueryVO.java b/wm-production/wm-production/src/main/java/com/water/production/vo/ThresholdQueryVO.java new file mode 100644 index 00000000..46d44bb7 --- /dev/null +++ b/wm-production/wm-production/src/main/java/com/water/production/vo/ThresholdQueryVO.java @@ -0,0 +1,20 @@ +package com.water.production.vo; + +import lombok.Data; +import io.swagger.v3.oas.annotations.media.Schema; + +@Data +@Schema(description = "阈值查询参数") +public class ThresholdQueryVO { + @Schema(description = "设备ID") + private String deviceId; + + @Schema(description = "区域") + private String region; + + @Schema(description = "参数名称") + private String parameter; + + @Schema(description = "状态:1-启用,0-禁用") + private Integer status; +} \ No newline at end of file