Commit 35d8f542 by 汪志阳

fix:离床预警时间bug修复

parent 5d960feb
...@@ -91,7 +91,7 @@ public class OffBedAlarm implements IAlarm { ...@@ -91,7 +91,7 @@ public class OffBedAlarm implements IAlarm {
} }
String deviceId = platDevice.getId(); String deviceId = platDevice.getId();
List<LocalDateTime> timeRange = getOffTimeRange(ruleConfig); List<LocalDateTime> timeRange = getOffTimeRange(ruleConfig);
if (CollUtil.isEmpty(timeRange)) { if (CollUtil.isEmpty(timeRange) || timeRange.get(0) == null || timeRange.get(1) == null) {
log.error("离床告警配置时间段解析失败,config:{}", JSONUtil.toJsonStr(ruleConfig)); log.error("离床告警配置时间段解析失败,config:{}", JSONUtil.toJsonStr(ruleConfig));
return; return;
} }
...@@ -203,16 +203,27 @@ public class OffBedAlarm implements IAlarm { ...@@ -203,16 +203,27 @@ public class OffBedAlarm implements IAlarm {
} }
/**
* 22-4 :昨天22-今天4 22-20:昨天22-今天20 22-23:今天22-23
* @param ruleConfig
* @return
*/
private List<LocalDateTime> getOffTimeRange(PlatAlarmConfigOffBedDTOVO ruleConfig) { private List<LocalDateTime> getOffTimeRange(PlatAlarmConfigOffBedDTOVO ruleConfig) {
List<LocalDateTime> result = new ArrayList<>(); List<LocalDateTime> result = new ArrayList<>();
LocalTime offBedStart = ruleConfig.getOffBedStart();
LocalTime offBedEnd = ruleConfig.getOffBedEnd();
LocalDate localDate = LocalDate.now(); LocalDate localDate = LocalDate.now();
LocalDateTime startTime = LocalDateTime.of(localDate, ruleConfig.getOffBedStart()); LocalDateTime startTime = null;
LocalDateTime endTime; LocalDateTime endTime = null;
boolean isNextDay = ruleConfig.getOffBedStart().isAfter(ruleConfig.getOffBedEnd()); // 22-23:今天22-23
if (isNextDay) { if (offBedStart.isBefore(offBedEnd)) {
endTime = LocalDateTime.of(localDate.plusDays(1), ruleConfig.getOffBedEnd()); startTime = LocalDateTime.of(localDate, offBedStart);
} else { endTime = LocalDateTime.of(localDate, offBedEnd);
endTime = LocalDateTime.of(localDate, ruleConfig.getOffBedEnd()); }
// 22-4 :昨天22-今天4
if (offBedStart.isAfter(offBedEnd)) {
startTime = LocalDateTime.of(localDate.plusDays(-1), offBedStart);
endTime = LocalDateTime.of(localDate, offBedEnd);
} }
result.add(startTime); result.add(startTime);
result.add(endTime); result.add(endTime);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment