Commit 583b3590 by huangjy

Merge remote-tracking branch 'origin/dev' into dev

parents 1fe31ff4 eaff82de
......@@ -10,6 +10,7 @@ import com.makeit.common.response.ApiResponseUtils;
import com.makeit.dto.platform.alarm.PlatAlarmRecordQueryDTO;
import com.makeit.enums.CommonEnum;
import com.makeit.enums.report.PlatformTypeEnum;
import com.makeit.global.annotation.AuthIgnore;
import com.makeit.service.platform.alarm.PlatAlarmRecordService;
import com.makeit.utils.user.common.CommonUserUtil;
import com.makeit.vo.platform.alarm.PlatAlarmRecordVO;
......@@ -34,6 +35,7 @@ public class PlatAlarmRecordWechatController {
@ApiOperation("列表")
@PostMapping("page")
@AuthIgnore
public ApiResponseEntity<Map<String,Object>> page(@RequestBody PageReqDTO<PlatAlarmRecordQueryDTO> dto) {
//小程序告警记录只看到发给自己的告警
String userId = CommonUserUtil.getUserId();
......
......@@ -27,16 +27,16 @@ public class PlatAlarmConfigOffBedDTOVO {
@JsonFormat(pattern = "HH:mm:ss",timezone="GMT+8")
private LocalTime offBedStart;
@ApiModelProperty("离床时间类型 :1-当日,2-次日")
private String startTimeType;
// @ApiModelProperty("离床时间类型 :1-当日,2-次日")
// private String startTimeType;
@ApiModelProperty("离床结束时间")
@DateTimeFormat(pattern = "HH:mm:ss")
@JsonFormat(pattern = "HH:mm:ss",timezone="GMT+8")
private LocalTime offBedEnd;
@ApiModelProperty("离床时间类型 :1-当日,2-次日")
private String endTimeType;
// @ApiModelProperty("离床时间类型 :1-当日,2-次日")
// private String endTimeType;
@ApiModelProperty("离床持续时间")
private Integer duration;
......
......@@ -79,7 +79,8 @@ public class OffBedAlarm implements IAlarm {
log.error("离床告警配置解析失败,config:{}", JSONUtil.toJsonStr(config));
return;
}
if (!CURRENT_DAY.equals(ruleConfig.getStartTimeType())) {
if (ruleConfig.getOffBedStart() == null || ruleConfig.getOffBedEnd() == null) {
log.error("离床告警配置时间不能为空,config:{}", JSONUtil.toJsonStr(config));
return;
}
JSONObject properties = platAlarmCheckDTO.getProperties();
......@@ -94,11 +95,8 @@ public class OffBedAlarm implements IAlarm {
return;
}
LocalDateTime startTime = timeRange.get(0);
LocalDateTime endTime = CURRENT_DAY.equals(ruleConfig.getEndTimeType()) ? timeRange.get(1) : timeRange.get(1).plusDays(1);
if (startTime.isAfter(endTime)) {
log.error("离床告警配置开始时间大于结束时间,config:{}", JSONUtil.toJsonStr(ruleConfig));
return;
}
LocalDateTime endTime = timeRange.get(1);
log.info("离床预警时间范围,begin:{},end:{}", startTime, endTime);
Integer duration = ruleConfig.getDuration();
String personState = Convert.toStr(properties.get("person"));
boolean isOffBed = "0".equals(personState);
......@@ -157,46 +155,6 @@ public class OffBedAlarm implements IAlarm {
}
// if (isOffBed && isInRange) {
//
// // AlarmRedisDTO alarmRedisDTO = RedisUtil.get(RedisConst.ALARM_DEVICE_OFF_BED_ID + deviceId);
// if (alarmRedisDTO == null) {
// Date now = new Date();
// long endLong = now.getTime();
// alarmRedisDTO = new AlarmRedisDTO();
// alarmRedisDTO.setAlarm(CommonEnum.NO.getValue());
// alarmRedisDTO.setStart(now);
// alarmRedisDTO.setStartLong(endLong);
// RedisUtil.set(RedisConst.ALARM_DEVICE_OFF_BED_ID + deviceId, alarmRedisDTO);
// log.warn("离床设备存储redis,第一次上报时间:{},开始上报时间:{},是否上报:{}",
// getDateTime(alarmRedisDTO.getStartLong()), alarmRedisDTO.getStart(), alarmRedisDTO.getAlarm());
// return;
// }
// Date now = new Date();
// long endLong = now.getTime();
// Long startLong = alarmRedisDTO.getStartLong();
// long count = endLong - startLong;
// // 持续时间满足、且未预警过
// if (count / 1000 >= duration * 60 && StringUtils.equals(alarmRedisDTO.getAlarm(), CommonEnum.NO.getValue())) {
// log.warn("离床持续时间:{} 秒,当前时间:{},duration:{}", count / 1000, now, duration);
// // alarmRedisDTO.setStartLong(endLong);
// alarmRedisDTO.setStart(now);
// alarmRedisDTO.setAlarm(CommonEnum.YES.getValue());
// platAlarmCheckDTO.setAbnormalValue(String.valueOf(count));
// RedisUtil.set(RedisConst.ALARM_DEVICE_OFF_BED_ID + deviceId, alarmRedisDTO);
// log.warn("推送离床消息,第一次上报时间:{},开始上报时间:{},是否上报:{}",
// getDateTime(alarmRedisDTO.getStartLong()), alarmRedisDTO.getStart(), alarmRedisDTO.getAlarm());
// notice(platAlarmCheckDTO);
// }
// }
}
public static void main(String[] args) {
LocalDateTime startTime = LocalDateTime.of(2023, 12, 12, 23, 59);
long second = startTime.toInstant(ZoneOffset.of("+8")).toEpochMilli();
LocalDateTime firstOffBedTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(second), ZoneOffset.of("+8"));
System.out.println(second);
System.out.println(firstOffBedTime);
}
private void sendToRedis(AlarmRedisDTO alarmRedisDTO, String deviceId) {
......@@ -232,17 +190,13 @@ public class OffBedAlarm implements IAlarm {
private List<LocalDateTime> getOffTimeRange(PlatAlarmConfigOffBedDTOVO ruleConfig) {
List<LocalDateTime> result = new ArrayList<>();
LocalDate localDate = LocalDate.now();
LocalDateTime startTime;
LocalDateTime startTime = LocalDateTime.of(localDate, ruleConfig.getOffBedStart());
LocalDateTime endTime;
if (CURRENT_DAY.equals(ruleConfig.getStartTimeType())) {
startTime = LocalDateTime.of(localDate, ruleConfig.getOffBedStart());
boolean isNextDay = ruleConfig.getOffBedStart().isAfter(ruleConfig.getOffBedEnd());
if (isNextDay) {
endTime = LocalDateTime.of(localDate.plusDays(1), ruleConfig.getOffBedEnd());
} else {
startTime = LocalDateTime.of(localDate.plusDays(1), ruleConfig.getOffBedStart());
}
if (CURRENT_DAY.equals(ruleConfig.getEndTimeType())) {
endTime = LocalDateTime.of(localDate, ruleConfig.getOffBedEnd());
} else {
endTime = LocalDateTime.of(localDate.plusDays(1), ruleConfig.getOffBedEnd());
}
result.add(startTime);
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