Commit c32dd433 by 杨伟程

老人报表更新

parent 98095577
...@@ -48,4 +48,6 @@ public interface PlatElderDayReportWeekService { ...@@ -48,4 +48,6 @@ public interface PlatElderDayReportWeekService {
List<PlatElderBehaviorDistributionVO> behaviorDistribution(PlatElderReportDTO platElderIdDTO); List<PlatElderBehaviorDistributionVO> behaviorDistribution(PlatElderReportDTO platElderIdDTO);
void heartRespiratoryJob();
} }
...@@ -4,14 +4,14 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; ...@@ -4,14 +4,14 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.makeit.dto.platform.elder.PlatElderReportDTO; import com.makeit.dto.platform.elder.PlatElderReportDTO;
import com.makeit.entity.platform.device.PlatDevice; import com.makeit.entity.platform.device.PlatDevice;
import com.makeit.entity.platform.elder.PlatElderBreatheAnalysis; import com.makeit.entity.platform.elder.*;
import com.makeit.entity.platform.elder.PlatElderBreatheDayStat;
import com.makeit.entity.platform.elder.PlatElderSleep;
import com.makeit.entity.platform.elder.PlatElderSleepAnalysis;
import com.makeit.enums.platform.alarm.PlatAlarmConfigEnum; import com.makeit.enums.platform.alarm.PlatAlarmConfigEnum;
import com.makeit.enums.report.SleepTypeEnum; import com.makeit.enums.report.SleepTypeEnum;
import com.makeit.module.iot.service.IotProductDeviceService;
import com.makeit.module.iot.vo.analysis.EvaluateReportVO; import com.makeit.module.iot.vo.analysis.EvaluateReportVO;
import com.makeit.module.iot.vo.breathe.DeviceInfoContentBreathe;
import com.makeit.service.platform.elder.*; import com.makeit.service.platform.elder.*;
import com.makeit.service.saas.PlatTenantService;
import com.makeit.service.saas.SaasDiseaseReportService; import com.makeit.service.saas.SaasDiseaseReportService;
import com.makeit.service.saas.SaasElderReportConfigService; import com.makeit.service.saas.SaasElderReportConfigService;
import com.makeit.service.saas.SaasSleepEvaluateReportService; import com.makeit.service.saas.SaasSleepEvaluateReportService;
...@@ -45,6 +45,12 @@ import java.util.stream.Collectors; ...@@ -45,6 +45,12 @@ import java.util.stream.Collectors;
public class PlatElderDayReportWeekServiceImpl implements PlatElderDayReportWeekService { public class PlatElderDayReportWeekServiceImpl implements PlatElderDayReportWeekService {
@Autowired @Autowired
private PlatElderService platElderService;
@Autowired
private PlatTenantService platTenantService;
@Autowired
private PlatElderRealTimeService platElderRealTimeService; private PlatElderRealTimeService platElderRealTimeService;
@Autowired @Autowired
...@@ -71,6 +77,9 @@ public class PlatElderDayReportWeekServiceImpl implements PlatElderDayReportWeek ...@@ -71,6 +77,9 @@ public class PlatElderDayReportWeekServiceImpl implements PlatElderDayReportWeek
@Autowired @Autowired
private PlatElderBreatheDayStatService platElderBreatheDayStatService; private PlatElderBreatheDayStatService platElderBreatheDayStatService;
@Autowired
private IotProductDeviceService iotProductDeviceService;
private LocalDateTime weekStartDateTime(LocalDateTime defaultTime) { private LocalDateTime weekStartDateTime(LocalDateTime defaultTime) {
return weekStartDateTime(LocalDate.now().minusDays(1), defaultTime); return weekStartDateTime(LocalDate.now().minusDays(1), defaultTime);
} }
...@@ -423,7 +432,51 @@ public class PlatElderDayReportWeekServiceImpl implements PlatElderDayReportWeek ...@@ -423,7 +432,51 @@ public class PlatElderDayReportWeekServiceImpl implements PlatElderDayReportWeek
List<LocalDate> dateList = LocalDateTimeUtils.getDateSeries(weekStartDate, weekEndDate); List<LocalDate> dateList = LocalDateTimeUtils.getDateSeries(weekStartDate, weekEndDate);
return platElderDayReportDayService.behaviorDistributionInternal(platElderIdDTO, dateList); return platElderDayReportDayService.behaviorDistributionInternal(platElderIdDTO, dateList);
}
@Override
public void heartRespiratoryJob() {
LocalDate nowDate = LocalDate.now();
LocalDate yesDate = nowDate.minusDays(1);
LocalDateTime yesStart = LocalDateTimeUtils.getDayStart(yesDate);
LocalDateTime yesEnd = LocalDateTimeUtils.getDayEnd(yesDate);
List<PlatElderBreatheDayStat> breatheDayStatList = new ArrayList<>(10);
platTenantService.executeTenantList(() -> {
List<PlatElder> elderList = platElderService.list(new QueryWrapper<PlatElder>().lambda()
.isNotNull(PlatElder::getBedId));
elderList.forEach(e -> {
PlatDevice platDevice = platElderRealTimeService.getBreathDevice(e.getId(), null);
PlatElderBreatheDayStat platElderBreatheDayStat = new PlatElderBreatheDayStat();
platElderBreatheDayStat.setElderId(e.getId());
platElderBreatheDayStat.setDeviceId(platDevice.getId());
platElderBreatheDayStat.setOriDeviceId(platDevice.getOriDeviceId());
platElderBreatheDayStat.setDay(yesDate);
List<DeviceInfoContentBreathe> breatheList = iotProductDeviceService.getDeviceLogByTimeRangeBreathe(platDevice.getOriDeviceId(), 2 * 24 * 3600, yesStart, yesEnd);
platElderBreatheDayStat.setHeartRateMax(breatheList.stream().map(i -> i.getProperties().getHr()).max(Integer::compareTo).orElse(null));
platElderBreatheDayStat.setHeartRateMin(breatheList.stream().map(i -> i.getProperties().getHr()).min(Integer::compareTo).orElse(null));
platElderBreatheDayStat.setHeartRateAvg((int) (StreamUtil.reduce(breatheList, i -> (long) i.getProperties().getHr(), 0L, Long::sum) / breatheList.size()));
platElderBreatheDayStat.setRespiratoryRateMax(breatheList.stream().map(i -> i.getProperties().getBr()).max(Integer::compareTo).orElse(null));
platElderBreatheDayStat.setRespiratoryRateMin(breatheList.stream().map(i -> i.getProperties().getBr()).min(Integer::compareTo).orElse(null));
platElderBreatheDayStat.setRespiratoryRateAvg((int) (StreamUtil.reduce(breatheList, i -> (long) i.getProperties().getBr(), 0L, Long::sum) / breatheList.size()));
breatheDayStatList.add(platElderBreatheDayStat);
});
platElderBreatheDayStatService.saveBatch(breatheDayStatList);
});
} }
} }
package com.makeit.task;
import com.makeit.service.platform.elder.PlatElderDayReportWeekService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
@Component
public class HeartRespiratoryTask {
@Autowired
private PlatElderDayReportWeekService platElderDayReportWeekService;
@Scheduled(cron = "0 0 2 * * ? ")
public void job(){
platElderDayReportWeekService.heartRespiratoryJob();
}
}
...@@ -6,7 +6,7 @@ import org.springframework.scheduling.annotation.Scheduled; ...@@ -6,7 +6,7 @@ import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@Component @Component
public class ReportMonthJob { public class ReportMonthTask {
@Autowired @Autowired
private PlatElderReportMonthService platElderReportMonthService; private PlatElderReportMonthService platElderReportMonthService;
......
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