修改问题 #49

Merged
hnu202326010106 merged 1 commits from wanglei_branch into develop 1 month ago

@ -41,6 +41,9 @@ public class Device {
@Column(name = "create_time")
private LocalDateTime createTime = LocalDateTime.now();
public void setRemark(String remark) {
}
public enum DeviceType {
water_maker, water_supply
}

@ -51,8 +51,8 @@ public interface AlertRepository extends JpaRepository<Alert, Long> {
// 根据处理人查询告警
List<Alert> findByResolvedBy(String resolvedBy);
// 检查重复未处理告警
List<Alert> findByDeviceIdAndAlertTypeAndStatusAndTimestampAfter(
// 修复:将 AndStatus 改为 AndStatusIn支持List集合的IN查询
List<Alert> findByDeviceIdAndAlertTypeAndStatusInAndTimestampAfter(
String deviceId,
String alertType,
List<Alert.AlertStatus> activeStatus,

@ -21,4 +21,8 @@ public interface DeviceRepository extends JpaRepository<Device, String> {
// 按安装位置模糊查询设备
List<Device> findByInstallLocationContaining(String location);
List<Device> findByStatusAndAreaIdAndDeviceType(String status, String areaId, String deviceType);
Object countByStatusAndAreaIdAndDeviceType(String online, String areaId, String deviceType);
}

@ -32,6 +32,7 @@ import java.util.Optional;
public class AlertTriggerService {
// 异常阈值配置(可根据实际需求调整或移至配置文件)
private static final double WATER_MAKER_TDS_THRESHOLD = 100.0; // 制水机TDS值异常阈值
private static final double WATER_MAKER_PRESS_MIN = 0.2; // 最小水压
private static final int FILTER_LIFE_THRESHOLD = 20; // 滤芯寿命阈值(%)
@ -205,7 +206,7 @@ public class AlertTriggerService {
Alert.AlertStatus.pending,
Alert.AlertStatus.processing
);
return !alertRepository.findByDeviceIdAndAlertTypeAndStatusAndTimestampAfter(
return !alertRepository.findByDeviceIdAndAlertTypeAndStatusInAndTimestampAfter(
deviceId,
alertType,
activeStatus,

Loading…
Cancel
Save