Commit 0ebd05c3 by huangjy

fix:长者月报问题

parent 8cdf2ef8
ALTER TABLE `plat_device_other` ALTER TABLE `plat_device_other`
...@@ -5,3 +5,13 @@ ADD COLUMN `secure_key` varchar(255) COMMENT '密钥key' AFTER `secure_id`; ...@@ -5,3 +5,13 @@ ADD COLUMN `secure_key` varchar(255) COMMENT '密钥key' AFTER `secure_id`;
ALTER TABLE `plat_alarm_record` ALTER TABLE `plat_alarm_record`
ADD COLUMN `misinformation_flag` char(1) DEFAULT 0 COMMENT '是否误报 1 误报 0 没有误报' AFTER `read_flag`; ADD COLUMN `misinformation_flag` char(1) DEFAULT 0 COMMENT '是否误报 1 误报 0 没有误报' AFTER `read_flag`;
ALTER TABLE `plat_elder_report_month`
MODIFY COLUMN `sleep_result` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci COMMENT '睡眠结果' AFTER `day`,
MODIFY COLUMN `heart_rate` int(11) COMMENT '心率' AFTER `sleep_result`,
MODIFY COLUMN `respiratory_rate` int(11) COMMENT '呼吸率' AFTER `heart_rate`,
MODIFY COLUMN `fail_count` int(11) COMMENT '跌倒次数' AFTER `respiratory_rate`,
MODIFY COLUMN `heart_exception_count` int(11) COMMENT '心率异常次数' AFTER `fail_count`,
MODIFY COLUMN `respiratory_exception_count` int(11) COMMENT '呼吸异常次数' AFTER `heart_exception_count`,
MODIFY COLUMN `behavior_exception_count` int(11) COMMENT '行为异常次数' AFTER `respiratory_exception_count`;
\ No newline at end of file
...@@ -7,6 +7,7 @@ import com.makeit.dto.wechat.device.PlatDeviceAttrWechatDTO; ...@@ -7,6 +7,7 @@ import com.makeit.dto.wechat.device.PlatDeviceAttrWechatDTO;
import com.makeit.global.annotation.AuthIgnore; import com.makeit.global.annotation.AuthIgnore;
import com.makeit.global.aspect.tenant.TenantIdIgnore; import com.makeit.global.aspect.tenant.TenantIdIgnore;
import com.makeit.service.platform.device.PlatDeviceService; import com.makeit.service.platform.device.PlatDeviceService;
import com.makeit.service.platform.elder.PlatElderReportMonthService;
import com.makeit.service.platform.elder.PlatElderSleepService; import com.makeit.service.platform.elder.PlatElderSleepService;
import com.makeit.task.IotSyncTask; import com.makeit.task.IotSyncTask;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
...@@ -36,6 +37,9 @@ public class PlatElderSleepController { ...@@ -36,6 +37,9 @@ public class PlatElderSleepController {
private PlatElderSleepService platElderSleepService; private PlatElderSleepService platElderSleepService;
@Autowired @Autowired
private PlatDeviceService platDeviceService; private PlatDeviceService platDeviceService;
@Autowired
private PlatElderReportMonthService platElderReportMonthService;
@ApiOperation("测试") @ApiOperation("测试")
@PostMapping("test") @PostMapping("test")
@AuthIgnore @AuthIgnore
...@@ -54,6 +58,13 @@ public class PlatElderSleepController { ...@@ -54,6 +58,13 @@ public class PlatElderSleepController {
return ApiResponseUtils.success(); return ApiResponseUtils.success();
} }
@ApiOperation("测试")
@PostMapping("test2")
@AuthIgnore
public ApiResponseEntity<Void> reportMonthJob() {
platElderReportMonthService.reportMonthJob();
return ApiResponseUtils.success();
}
@ApiOperation("编辑设备属性") @ApiOperation("编辑设备属性")
@PostMapping("editDeviceProperties") @PostMapping("editDeviceProperties")
......
...@@ -9,6 +9,7 @@ import com.makeit.entity.platform.elder.PlatElder; ...@@ -9,6 +9,7 @@ import com.makeit.entity.platform.elder.PlatElder;
import com.makeit.entity.platform.elder.PlatElderReportMonth; import com.makeit.entity.platform.elder.PlatElderReportMonth;
import com.makeit.entity.platform.elder.PlatElderSleepAnalysis; import com.makeit.entity.platform.elder.PlatElderSleepAnalysis;
import com.makeit.enums.platform.alarm.PlatAlarmConfigEnum; import com.makeit.enums.platform.alarm.PlatAlarmConfigEnum;
import com.makeit.global.aspect.tenant.TenantIdIgnore;
import com.makeit.mapper.platform.elder.PlatElderReportMonthMapper; import com.makeit.mapper.platform.elder.PlatElderReportMonthMapper;
import com.makeit.module.iot.service.IotProductDeviceService; import com.makeit.module.iot.service.IotProductDeviceService;
import com.makeit.module.iot.vo.breathe.DeviceInfoContentBreathe; import com.makeit.module.iot.vo.breathe.DeviceInfoContentBreathe;
...@@ -140,8 +141,9 @@ public class PlatElderReportMonthServiceImpl extends ServiceImpl<PlatElderReport ...@@ -140,8 +141,9 @@ public class PlatElderReportMonthServiceImpl extends ServiceImpl<PlatElderReport
} }
@Override @Override
@TenantIdIgnore
public void reportMonthJob() { public void reportMonthJob() {
LocalDate nowDate = LocalDate.now(); LocalDate nowDate = LocalDate.now().minusDays(6);
LocalDate yesDate = nowDate.minusDays(1); LocalDate yesDate = nowDate.minusDays(1);
LocalDateTime yesStart = LocalDateTimeUtils.getDayStart(yesDate); LocalDateTime yesStart = LocalDateTimeUtils.getDayStart(yesDate);
...@@ -151,7 +153,6 @@ public class PlatElderReportMonthServiceImpl extends ServiceImpl<PlatElderReport ...@@ -151,7 +153,6 @@ public class PlatElderReportMonthServiceImpl extends ServiceImpl<PlatElderReport
List<PlatElderReportMonth> reportMonthList = new ArrayList<>(10); List<PlatElderReportMonth> reportMonthList = new ArrayList<>(10);
platTenantService.executeTenantList(() -> {
List<PlatElder> elderList = platElderService.list(new QueryWrapper<PlatElder>().lambda() List<PlatElder> elderList = platElderService.list(new QueryWrapper<PlatElder>().lambda()
.isNotNull(PlatElder::getBedId)); .isNotNull(PlatElder::getBedId));
...@@ -167,9 +168,9 @@ public class PlatElderReportMonthServiceImpl extends ServiceImpl<PlatElderReport ...@@ -167,9 +168,9 @@ public class PlatElderReportMonthServiceImpl extends ServiceImpl<PlatElderReport
Map<String, List<PlatAlarmRecord>> recordMap = StreamUtil.groupBy(recordList, PlatAlarmRecord::getElderIds); Map<String, List<PlatAlarmRecord>> recordMap = StreamUtil.groupBy(recordList, PlatAlarmRecord::getElderIds);
elderList.forEach(e -> { for (PlatElder e : elderList) {
PlatElderReportMonth reportMonth = new PlatElderReportMonth(); PlatElderReportMonth reportMonth = new PlatElderReportMonth();
reportMonth.setElderId(e.getBedId()); reportMonth.setElderId(e.getId());
reportMonth.setDay(yesDate); reportMonth.setDay(yesDate);
MapUtil.setIfPresent(sleepAnalysisMap, e.getId(), sa -> { MapUtil.setIfPresent(sleepAnalysisMap, e.getId(), sa -> {
...@@ -177,6 +178,9 @@ public class PlatElderReportMonthServiceImpl extends ServiceImpl<PlatElderReport ...@@ -177,6 +178,9 @@ public class PlatElderReportMonthServiceImpl extends ServiceImpl<PlatElderReport
}); });
PlatDevice platDevice = platElderRealTimeService.getBreathDevice(e.getId(), null); PlatDevice platDevice = platElderRealTimeService.getBreathDevice(e.getId(), null);
if (platDevice == null) {
continue;
}
List<DeviceInfoContentBreathe> breatheList = iotProductDeviceService.getDeviceLogByTimeRangeBreathe(platDevice.getOriDeviceId(), 2 * 24 * 3600, yesStart, yesEnd); List<DeviceInfoContentBreathe> breatheList = iotProductDeviceService.getDeviceLogByTimeRangeBreathe(platDevice.getOriDeviceId(), 2 * 24 * 3600, yesStart, yesEnd);
...@@ -195,15 +199,10 @@ public class PlatElderReportMonthServiceImpl extends ServiceImpl<PlatElderReport ...@@ -195,15 +199,10 @@ public class PlatElderReportMonthServiceImpl extends ServiceImpl<PlatElderReport
reportMonth.setHeartExceptionCount((int) StreamUtil.count(rList, i -> PlatAlarmConfigEnum.AlarmTypeEnum.HEART.getValue().equals(i.getAlarmType()))); reportMonth.setHeartExceptionCount((int) StreamUtil.count(rList, i -> PlatAlarmConfigEnum.AlarmTypeEnum.HEART.getValue().equals(i.getAlarmType())));
reportMonth.setRespiratoryExceptionCount((int) StreamUtil.count(rList, i -> PlatAlarmConfigEnum.AlarmTypeEnum.BREATHE.getValue().equals(i.getAlarmType()))); reportMonth.setRespiratoryExceptionCount((int) StreamUtil.count(rList, i -> PlatAlarmConfigEnum.AlarmTypeEnum.BREATHE.getValue().equals(i.getAlarmType())));
reportMonth.setBehaviorExceptionCount((int) StreamUtil.count(rList, i -> PlatAlarmConfigEnum.AlarmTypeEnum.BEHAVIOR.getValue().equals(i.getAlarmType()))); reportMonth.setBehaviorExceptionCount((int) StreamUtil.count(rList, i -> PlatAlarmConfigEnum.AlarmTypeEnum.BEHAVIOR.getValue().equals(i.getAlarmType())));
reportMonth.setTenantId(e.getTenantId());
reportMonthList.add(reportMonth); reportMonthList.add(reportMonth);
}
});
saveBatch(reportMonthList); saveBatch(reportMonthList);
});
} }
} }
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