Commit 599e0fb6 by 杨伟程

老人报表更新

parent f9882e1e
...@@ -9,12 +9,7 @@ import com.makeit.global.aspect.tenant.TenantIdIgnore; ...@@ -9,12 +9,7 @@ import com.makeit.global.aspect.tenant.TenantIdIgnore;
import com.makeit.service.platform.elder.PlatElderDayReportDayService; import com.makeit.service.platform.elder.PlatElderDayReportDayService;
import com.makeit.vo.platform.elder.realtime.PlatElderCoordinateVO; import com.makeit.vo.platform.elder.realtime.PlatElderCoordinateVO;
import com.makeit.vo.platform.elder.realtime.PlatElderRealTimeHeartRespiratoryVO; import com.makeit.vo.platform.elder.realtime.PlatElderRealTimeHeartRespiratoryVO;
import com.makeit.vo.platform.elder.report.day.PlatElderBehaviorDistributionVO; import com.makeit.vo.platform.elder.report.day.*;
import com.makeit.vo.platform.elder.report.day.PlatElderBehaviorExceptionRecordVO;
import com.makeit.vo.platform.elder.report.day.PlatElderHeartRespiratoryEvaluationRecordVO;
import com.makeit.vo.platform.elder.report.day.PlatElderHeartRespiratoryEvaluationVO;
import com.makeit.vo.platform.elder.report.day.PlatElderSleepDiagramVO;
import com.makeit.vo.platform.elder.report.day.PlatElderSleepEvaluationVO;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -86,15 +81,15 @@ public class SaasDeviceReportDayController { ...@@ -86,15 +81,15 @@ public class SaasDeviceReportDayController {
@ApiOperation("行为异常记录") @ApiOperation("行为异常记录")
@PostMapping("behaviorExceptionRecordList") @PostMapping("behaviorExceptionRecordList")
@TenantIdIgnore @TenantIdIgnore
public ApiResponseEntity<List<PlatElderBehaviorExceptionRecordVO>> behaviorExceptionRecordList(@RequestBody PlatElderIdDTO platElderIdDTO) { public ApiResponseEntity<List<PlatElderBehaviorExceptionRecordVO>> behaviorExceptionRecordList(@RequestBody PlatElderReportDTO platElderIdDTO) {
return null; return ApiResponseUtils.success(platElderDayReportDayService.behaviorExceptionRecordList(platElderIdDTO));
} }
@ApiOperation("跌倒记录") @ApiOperation("跌倒记录")
@PostMapping("failRecordList") @PostMapping("failRecordList")
@TenantIdIgnore @TenantIdIgnore
public ApiResponseEntity<List<String>> failRecordList(@RequestBody PlatElderIdDTO platElderIdDTO) { public ApiResponseEntity<List<String>> failRecordList(@RequestBody PlatElderReportDTO platElderIdDTO) {
return null; return ApiResponseUtils.success(platElderDayReportDayService.failRecordList(platElderIdDTO));
} }
@ApiOperation("坐标记录") @ApiOperation("坐标记录")
...@@ -107,8 +102,8 @@ public class SaasDeviceReportDayController { ...@@ -107,8 +102,8 @@ public class SaasDeviceReportDayController {
@ApiOperation("行为辐射") @ApiOperation("行为辐射")
@PostMapping("behaviorDistribution") @PostMapping("behaviorDistribution")
@TenantIdIgnore @TenantIdIgnore
public ApiResponseEntity<List<PlatElderBehaviorDistributionVO>> behaviorDistribution(@RequestBody PlatElderIdDTO platElderIdDTO) { public ApiResponseEntity<List<PlatElderBehaviorDistributionVO>> behaviorDistribution(@RequestBody PlatElderReportDTO platElderIdDTO) {
return null; return ApiResponseUtils.success(platElderDayReportDayService.behaviorDistribution(platElderIdDTO));
} }
} }
......
package com.makeit.module.iot.enums;
import com.makeit.enums.BaseEnum;
import com.makeit.utils.sys.SysDictUtil;
public class DeviceInfoContentFallEnum {
public enum PersonStateEnum {
NOBODY(0, "无人"),//0
FALL(1, "跌倒");//3
private Integer value;
private String name;
PersonStateEnum(Integer value, String name) {
this.value = value;
this.name = name;
}
public Integer getValue() {
return value;
}
public String getName() {
return name;
}
}
}
...@@ -150,9 +150,9 @@ public class IotProductDeviceService extends IotCommonService { ...@@ -150,9 +150,9 @@ public class IotProductDeviceService extends IotCommonService {
List<DeviceOperationLogEntity> deviceOperationLogEntityList = getDeviceLogByTimeRange(deviceId, "event", pageSize, dateTimeFormatter.format(startTime), dateTimeFormatter.format(endTime)); List<DeviceOperationLogEntity> deviceOperationLogEntityList = getDeviceLogByTimeRange(deviceId, "event", pageSize, dateTimeFormatter.format(startTime), dateTimeFormatter.format(endTime));
List<DeviceInfoContentFall> deviceInfoContentSpaceList = StreamUtil.map(deviceOperationLogEntityList, e -> JsonUtil.toObj((String) e.getContent(), DeviceInfoContentFall.class)); List<DeviceInfoContentFall> deviceInfoContentFallList = StreamUtil.map(deviceOperationLogEntityList, e -> JsonUtil.toObj((String) e.getContent(), DeviceInfoContentFall.class));
return deviceInfoContentSpaceList; return deviceInfoContentFallList;
} }
......
package com.makeit.service.platform.elder; package com.makeit.service.platform.elder;
import com.makeit.common.response.ApiResponseEntity;
import com.makeit.dto.platform.elder.PlatElderReportDTO; import com.makeit.dto.platform.elder.PlatElderReportDTO;
import com.makeit.vo.platform.elder.realtime.PlatElderCoordinateVO; import com.makeit.vo.platform.elder.realtime.PlatElderCoordinateVO;
import com.makeit.vo.platform.elder.realtime.PlatElderRealTimeHeartRespiratoryVO; import com.makeit.vo.platform.elder.realtime.PlatElderRealTimeHeartRespiratoryVO;
import com.makeit.vo.platform.elder.report.day.*; import com.makeit.vo.platform.elder.report.day.*;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.List; import java.util.List;
...@@ -42,4 +38,6 @@ public interface PlatElderDayReportDayService { ...@@ -42,4 +38,6 @@ public interface PlatElderDayReportDayService {
List<PlatElderCoordinateVO> coordinateList(PlatElderReportDTO platElderIdDTO); List<PlatElderCoordinateVO> coordinateList(PlatElderReportDTO platElderIdDTO);
List<PlatElderBehaviorDistributionVO> behaviorDistribution(PlatElderReportDTO platElderIdDTO);
} }
package com.makeit.service.platform.elder; package com.makeit.service.platform.elder;
import com.makeit.dto.platform.elder.PlatElderIdDTO;
import com.makeit.dto.platform.elder.PlatElderReportDTO; import com.makeit.dto.platform.elder.PlatElderReportDTO;
import com.makeit.vo.platform.elder.realtime.PlatElderCoordinateVO; import com.makeit.vo.platform.elder.realtime.PlatElderCoordinateVO;
import com.makeit.vo.platform.elder.realtime.PlatElderRealTimeHeartRespiratoryVO; import com.makeit.vo.platform.elder.report.day.PlatElderSleepEvaluationVO;
import java.util.List; import java.util.List;
...@@ -17,6 +16,8 @@ import java.util.List; ...@@ -17,6 +16,8 @@ import java.util.List;
*/ */
public interface PlatElderDayReportWeekService { public interface PlatElderDayReportWeekService {
PlatElderSleepEvaluationVO sleepEvaluation(PlatElderReportDTO platElderIdDTO);
List<PlatElderCoordinateVO> coordinateList(PlatElderReportDTO platElderIdDTO); List<PlatElderCoordinateVO> coordinateList(PlatElderReportDTO platElderIdDTO);
} }
...@@ -23,6 +23,8 @@ public interface PlatElderRealTimeService { ...@@ -23,6 +23,8 @@ public interface PlatElderRealTimeService {
List<PlatDevice> getSpaceDevice(String elderId, String deviceId); List<PlatDevice> getSpaceDevice(String elderId, String deviceId);
List<PlatDevice> getFallDevice(String elderId, String deviceId);
PlatElderRealTimeNowVO nowStatus(PlatElderIdDTO platElderIdDTO); PlatElderRealTimeNowVO nowStatus(PlatElderIdDTO platElderIdDTO);
PlatElderRealTimeHeartRespiratoryVO heartRespiratory(PlatElderIdDTO platElderIdDTO); PlatElderRealTimeHeartRespiratoryVO heartRespiratory(PlatElderIdDTO platElderIdDTO);
......
...@@ -54,6 +54,8 @@ public interface PlatElderService extends IService<PlatElder> { ...@@ -54,6 +54,8 @@ public interface PlatElderService extends IService<PlatElder> {
List<PlatDevice> getSpaceDevice(String id); List<PlatDevice> getSpaceDevice(String id);
List<PlatDevice> getFallDevice(String id);
/*小程序*/ /*小程序*/
List<PlatElderWechatSimpleVO> listMy(); List<PlatElderWechatSimpleVO> listMy();
/*小程序*/ /*小程序*/
......
...@@ -3,15 +3,19 @@ package com.makeit.service.platform.elder.impl; ...@@ -3,15 +3,19 @@ package com.makeit.service.platform.elder.impl;
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.alarm.PlatAlarmRecord; import com.makeit.entity.platform.alarm.PlatAlarmRecord;
import com.makeit.entity.platform.alarm.PlatDayDurationRecord;
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.PlatElderBreatheAnalysis;
import com.makeit.entity.platform.elder.PlatElderSleep; import com.makeit.entity.platform.elder.PlatElderSleep;
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.module.iot.enums.DeviceInfoContentFallEnum;
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;
import com.makeit.module.iot.vo.fall.DeviceInfoContentFall;
import com.makeit.module.iot.vo.space.DeviceInfoContentSpace; import com.makeit.module.iot.vo.space.DeviceInfoContentSpace;
import com.makeit.service.platform.alarm.PlatAlarmRecordService; import com.makeit.service.platform.alarm.PlatAlarmRecordService;
import com.makeit.service.platform.alarm.PlatDayDurationRecordService;
import com.makeit.service.platform.device.PlatDeviceService; import com.makeit.service.platform.device.PlatDeviceService;
import com.makeit.service.platform.elder.*; import com.makeit.service.platform.elder.*;
import com.makeit.utils.LongTimestampUtil; import com.makeit.utils.LongTimestampUtil;
...@@ -29,20 +33,14 @@ import java.math.RoundingMode; ...@@ -29,20 +33,14 @@ import java.math.RoundingMode;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.ArrayList; import java.util.*;
import java.util.List; import java.util.stream.Collector;
import java.util.Optional; import java.util.stream.Collectors;
@Service @Service
public class PlatElderDayReportDayServiceImpl implements PlatElderDayReportDayService { public class PlatElderDayReportDayServiceImpl implements PlatElderDayReportDayService {
@Autowired @Autowired
private PlatElderService platElderService;
@Autowired
private PlatDeviceService platDeviceService;
@Autowired
private PlatElderSleepService platElderSleepService; private PlatElderSleepService platElderSleepService;
@Autowired @Autowired
...@@ -51,9 +49,13 @@ public class PlatElderDayReportDayServiceImpl implements PlatElderDayReportDaySe ...@@ -51,9 +49,13 @@ public class PlatElderDayReportDayServiceImpl implements PlatElderDayReportDaySe
@Autowired @Autowired
private PlatElderBreatheAnalysisService platElderBreatheAnalysisService; private PlatElderBreatheAnalysisService platElderBreatheAnalysisService;
@Autowired
private PlatAlarmRecordService platAlarmRecordService; private PlatAlarmRecordService platAlarmRecordService;
@Autowired @Autowired
private PlatDayDurationRecordService platDayDurationRecordService;
@Autowired
private IotProductDeviceService iotProductDeviceService; private IotProductDeviceService iotProductDeviceService;
@Autowired @Autowired
...@@ -252,9 +254,16 @@ public class PlatElderDayReportDayServiceImpl implements PlatElderDayReportDaySe ...@@ -252,9 +254,16 @@ public class PlatElderDayReportDayServiceImpl implements PlatElderDayReportDaySe
return new ArrayList<>(10); return new ArrayList<>(10);
} }
LocalDate now = Optional.ofNullable(platElderIdDTO.getNow()).orElse(LocalDate.now());
LocalDateTime start = dayStartNow(now);
LocalDateTime end = dayEndNow(now);
List<PlatAlarmRecord> recordList = platAlarmRecordService.list(new QueryWrapper<PlatAlarmRecord>().lambda() List<PlatAlarmRecord> recordList = platAlarmRecordService.list(new QueryWrapper<PlatAlarmRecord>().lambda()
.eq(PlatAlarmRecord::getAlarmType, PlatAlarmConfigEnum.AlarmTypeEnum.BEHAVIOR.getValue()) .eq(PlatAlarmRecord::getAlarmType, PlatAlarmConfigEnum.AlarmTypeEnum.BEHAVIOR.getValue())
.in(PlatAlarmRecord::getDeviceId, StreamUtil.mapId(platDeviceList, PlatDevice::getId)) .in(PlatAlarmRecord::getDeviceId, StreamUtil.mapId(platDeviceList, PlatDevice::getId))
.ge(PlatAlarmRecord::getAlarmDate, start)
.le(PlatAlarmRecord::getAlarmDate, end)
.orderByDesc(PlatAlarmRecord::getAlarmDate) .orderByDesc(PlatAlarmRecord::getAlarmDate)
); );
...@@ -276,7 +285,33 @@ public class PlatElderDayReportDayServiceImpl implements PlatElderDayReportDaySe ...@@ -276,7 +285,33 @@ public class PlatElderDayReportDayServiceImpl implements PlatElderDayReportDaySe
@Override @Override
public List<String> failRecordList(PlatElderReportDTO platElderIdDTO) { public List<String> failRecordList(PlatElderReportDTO platElderIdDTO) {
return null; List<PlatDevice> platDeviceList = platElderRealTimeService.getFallDevice(platElderIdDTO.getElderId(), platElderIdDTO.getDeviceId());
if (CollectionUtils.isEmpty(platDeviceList)) {
return new ArrayList<>(10);
}
LocalDate now = Optional.ofNullable(platElderIdDTO.getNow()).orElse(LocalDate.now());
LocalDateTime start = dayStartNow(now);
LocalDateTime end = dayEndNow(now);
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
List<String> voList = new ArrayList<>(10);
platDeviceList.forEach(e -> {
List<DeviceInfoContentFall> fallList = iotProductDeviceService.getDeviceLogByTimeRangeFall(e.getOriDeviceId(), 2 * 24 * 3600, start, end);
fallList = StreamUtil.filter(fallList, i -> DeviceInfoContentFallEnum.PersonStateEnum.FALL.getValue().equals(i.getProperties().getPersonState()));
voList.addAll(StreamUtil.map(fallList, i -> dateTimeFormatter.format(LongTimestampUtil.toLocalDateTime(i.getTimestamp()))));
});
voList.sort(String::compareTo);
return voList;
} }
@Override @Override
...@@ -318,4 +353,59 @@ public class PlatElderDayReportDayServiceImpl implements PlatElderDayReportDaySe ...@@ -318,4 +353,59 @@ public class PlatElderDayReportDayServiceImpl implements PlatElderDayReportDaySe
return coordinateList(platElderIdDTO.getElderId(), platElderIdDTO.getDeviceId(), start, end); return coordinateList(platElderIdDTO.getElderId(), platElderIdDTO.getDeviceId(), start, end);
} }
@Override
public List<PlatElderBehaviorDistributionVO> behaviorDistribution(PlatElderReportDTO platElderIdDTO) {
List<PlatDevice> platDeviceList = platElderRealTimeService.getSpaceDevice(platElderIdDTO.getElderId(), platElderIdDTO.getDeviceId());
if (CollectionUtils.isEmpty(platDeviceList)) {
return new ArrayList<>(10);
}
List<PlatElderBehaviorDistributionVO> voList = new ArrayList<>(10);
LocalDate now = Optional.ofNullable(platElderIdDTO.getNow()).orElse(LocalDate.now());
LocalDateTime start = dayStartNow(now);
LocalDateTime end = dayEndNow(now);
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyyMMdd");
List<PlatElderBehaviorDistributionVO> finalVoList = voList;
platDeviceList.forEach(e -> {
List<PlatDayDurationRecord> recordList = platDayDurationRecordService.list(new QueryWrapper<PlatDayDurationRecord>().lambda()
.eq(PlatDayDurationRecord::getDeviceId, e.getId())
.eq(PlatDayDurationRecord::getDay, dateTimeFormatter.format(now))
);
finalVoList.addAll(StreamUtil.map(recordList, i -> {
PlatElderBehaviorDistributionVO vo = new PlatElderBehaviorDistributionVO();
vo.setAreaName(i.getRegionName());
vo.setDuration(Integer.valueOf(i.getDuration() + ""));
return vo;
}));
});
Map<String, List<PlatElderBehaviorDistributionVO>> map = StreamUtil.groupBy(voList, PlatElderBehaviorDistributionVO::getAreaName);
List<PlatElderBehaviorDistributionVO> newVoList = new ArrayList<>(10);
map.forEach((k, v) -> {
PlatElderBehaviorDistributionVO vo = new PlatElderBehaviorDistributionVO();
vo.setAreaName(k);
vo.setDuration(StreamUtil.reduce(v, PlatElderBehaviorDistributionVO::getDuration, 0, Integer::sum));
newVoList.add(vo);
});
voList = newVoList;
voList.sort(Comparator.comparing(PlatElderBehaviorDistributionVO::getDuration));
return voList;
}
} }
package com.makeit.service.platform.elder.impl; package com.makeit.service.platform.elder.impl;
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.elder.PlatElderSleep;
import com.makeit.entity.platform.elder.PlatElderSleepAnalysis;
import com.makeit.module.iot.service.IotProductDeviceService; import com.makeit.module.iot.service.IotProductDeviceService;
import com.makeit.service.platform.elder.PlatElderDayReportDayService; import com.makeit.service.platform.elder.PlatElderDayReportDayService;
import com.makeit.service.platform.elder.PlatElderDayReportWeekService; import com.makeit.service.platform.elder.PlatElderDayReportWeekService;
import com.makeit.service.platform.elder.PlatElderService; import com.makeit.service.platform.elder.PlatElderService;
import com.makeit.service.platform.elder.PlatElderSleepAnalysisService;
import com.makeit.utils.data.convert.StreamUtil;
import com.makeit.utils.data.validate.CollectionUtils;
import com.makeit.utils.time.LocalDateTimeUtils;
import com.makeit.vo.platform.elder.realtime.PlatElderCoordinateVO; import com.makeit.vo.platform.elder.realtime.PlatElderCoordinateVO;
import com.makeit.vo.platform.elder.report.day.PlatElderSleepEvaluationVO;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.time.DayOfWeek;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.time.temporal.TemporalAdjusters;
import java.util.List; import java.util.List;
@Service @Service
...@@ -18,13 +31,119 @@ public class PlatElderDayReportWeekServiceImpl implements PlatElderDayReportWeek ...@@ -18,13 +31,119 @@ public class PlatElderDayReportWeekServiceImpl implements PlatElderDayReportWeek
private PlatElderDayReportDayService platElderDayReportDayService; private PlatElderDayReportDayService platElderDayReportDayService;
@Autowired @Autowired
private PlatElderSleepAnalysisService platElderSleepAnalysisService;
@Autowired
private PlatElderService platElderService; private PlatElderService platElderService;
@Autowired @Autowired
private IotProductDeviceService iotProductDeviceService; private IotProductDeviceService iotProductDeviceService;
private LocalDateTime weekStartDateTime(LocalDateTime defaultTime) {
return weekStartDateTime(LocalDate.now(), defaultTime);
}
private LocalDateTime weekStartDateTime(LocalDate now, LocalDateTime defaultTime) {
if (defaultTime != null) {
return defaultTime;
}
LocalDate monday = now.with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY));
LocalDateTime start = LocalDateTimeUtils.getDayStart(monday);
return start;
}
private LocalDateTime weekEndDateTime(LocalDateTime defaultTime) {
return weekStartDateTime(LocalDate.now(), defaultTime);
}
private LocalDateTime weekEndDateTime(LocalDate now, LocalDateTime defaultTime) {
if (defaultTime != null) {
return defaultTime;
}
LocalDate sunday = now.with(TemporalAdjusters.nextOrSame(DayOfWeek.SUNDAY));
LocalDateTime start = LocalDateTimeUtils.getDayStart(sunday);
return start;
}
private LocalDate weekStartDate(LocalDateTime defaultTime) {
return weekStartDate(LocalDate.now(), defaultTime);
}
private LocalDate weekStartDate(LocalDate now, LocalDateTime defaultTime) {
if (defaultTime != null) {
return defaultTime.toLocalDate();
}
LocalDate monday = now.with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY));
return monday;
}
private LocalDate weekEndDate(LocalDateTime defaultTime) {
return weekStartDate(LocalDate.now(), defaultTime);
}
private LocalDate weekEndDate(LocalDate now, LocalDateTime defaultTime) {
if (defaultTime != null) {
return defaultTime.toLocalDate();
}
LocalDate sunday = now.with(TemporalAdjusters.nextOrSame(DayOfWeek.SUNDAY));
return sunday;
}
@Override
public PlatElderSleepEvaluationVO sleepEvaluation(PlatElderReportDTO platElderIdDTO) {
LocalDate weekStartDate = weekStartDate(platElderIdDTO.getStartTime());
LocalDate weekEndDate = weekStartDate(platElderIdDTO.getEndTime());
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
List<PlatElderSleepAnalysis> sleepAnalysisList = platElderSleepAnalysisService.list(new QueryWrapper<PlatElderSleepAnalysis>().lambda()
.ge(PlatElderSleepAnalysis::getCurrentDate, dateTimeFormatter.format(weekStartDate))
.le(PlatElderSleepAnalysis::getCurrentDate, dateTimeFormatter.format(weekEndDate))
);
int score = 0;
int sleepDuration = 0;
int restDuration = 0;
if (CollectionUtils.isNotEmpty(sleepAnalysisList)) {
score = StreamUtil.reduce(sleepAnalysisList, e -> Integer.valueOf(e.getSleepScore() + ""), 0, Integer::sum) / sleepAnalysisList.size();
sleepDuration = StreamUtil.reduce(sleepAnalysisList, e -> Integer.valueOf(e.getSleepTime() + ""), 0, Integer::sum) / sleepAnalysisList.size();
restDuration = StreamUtil.reduce(sleepAnalysisList, e -> Integer.valueOf(e.getRestTime() + ""), 0, Integer::sum) / sleepAnalysisList.size();
}
PlatElderSleepEvaluationVO platElderSleepEvaluationVO = new PlatElderSleepEvaluationVO();
platElderSleepEvaluationVO.setScore(score);
platElderSleepEvaluationVO.setSleepDuration(sleepDuration);
platElderSleepEvaluationVO.setRestDuration(restDuration);
// platElderSleepEvaluationVO.setResult();
// platElderSleepEvaluationVO.setEvaluation();
return platElderSleepEvaluationVO;
}
@Override @Override
public List<PlatElderCoordinateVO> coordinateList(PlatElderReportDTO platElderIdDTO) { public List<PlatElderCoordinateVO> coordinateList(PlatElderReportDTO platElderIdDTO) {
return platElderDayReportDayService.coordinateList(platElderIdDTO.getElderId(), platElderIdDTO.getDeviceId(), platElderIdDTO.getStartTime(), platElderIdDTO.getEndTime()); return platElderDayReportDayService.coordinateList(platElderIdDTO.getElderId(), platElderIdDTO.getDeviceId(), weekStartDateTime(platElderIdDTO.getStartTime()), weekEndDateTime(platElderIdDTO.getEndTime()));
} }
} }
...@@ -78,6 +78,22 @@ public class PlatElderRealTimeServiceImpl implements PlatElderRealTimeService { ...@@ -78,6 +78,22 @@ public class PlatElderRealTimeServiceImpl implements PlatElderRealTimeService {
return deviceList; return deviceList;
} }
@Override
public List<PlatDevice> getFallDevice(String elderId, String deviceId) {
List<PlatDevice> deviceList = null;
if (StringUtils.isNotBlank(elderId)) {
deviceList = platElderService.getFallDevice(elderId);
}
if (StringUtils.isNotBlank(deviceId)) {
deviceList = Arrays.asList(platDeviceService.getById(deviceId));
}
return deviceList;
}
private DeviceInfoContentBreathe getNowDataBreathe(String elderId, String deviceId) { private DeviceInfoContentBreathe getNowDataBreathe(String elderId, String deviceId) {
PlatDevice platDevice = getBreathDevice(elderId, deviceId); PlatDevice platDevice = getBreathDevice(elderId, deviceId);
......
...@@ -739,6 +739,17 @@ public class PlatElderServiceImpl extends ServiceImpl<PlatElderMapper, PlatElder ...@@ -739,6 +739,17 @@ public class PlatElderServiceImpl extends ServiceImpl<PlatElderMapper, PlatElder
} }
@Override @Override
public List<PlatDevice> getFallDevice(String id) {
PlatElder platElder = getById(id);
if (StringUtils.isBlank(platElder.getBedId())) {
return null;
}
return platRoomBedDeviceService.getFallDevice(platElder.getBedId());
}
@Override
public List<PlatElderWechatSimpleVO> listMy() { public List<PlatElderWechatSimpleVO> listMy() {
PlatElderChildrenInfoWechatVO childrenInfo = platElderChildrenInfoService.view(); PlatElderChildrenInfoWechatVO childrenInfo = platElderChildrenInfoService.view();
......
...@@ -53,4 +53,6 @@ public interface PlatRoomBedDeviceService extends IService<PlatRoomBedDevice> { ...@@ -53,4 +53,6 @@ public interface PlatRoomBedDeviceService extends IService<PlatRoomBedDevice> {
PlatDevice getBreathDevice(String bedId); PlatDevice getBreathDevice(String bedId);
List<PlatDevice> getSpaceDevice(String bedId); List<PlatDevice> getSpaceDevice(String bedId);
List<PlatDevice> getFallDevice(String bedId);
} }
...@@ -109,34 +109,34 @@ public class PlatRoomBedDeviceServiceImpl extends ServiceImpl<PlatRoomBedDeviceM ...@@ -109,34 +109,34 @@ public class PlatRoomBedDeviceServiceImpl extends ServiceImpl<PlatRoomBedDeviceM
public List<PlatDeviceDTO> listBindDevice(PlatBedDeviceQueryDTO dto) { public List<PlatDeviceDTO> listBindDevice(PlatBedDeviceQueryDTO dto) {
LambdaQueryWrapper<PlatRoomBedDevice> queryWrapper1 = new LambdaQueryWrapper<>(); LambdaQueryWrapper<PlatRoomBedDevice> queryWrapper1 = new LambdaQueryWrapper<>();
queryWrapper1.eq(PlatRoomBedDevice::getRoomId,dto.getRoomId()); queryWrapper1.eq(PlatRoomBedDevice::getRoomId, dto.getRoomId());
queryWrapper1.eq(StringUtil.isNotEmpty(dto.getBedId()),PlatRoomBedDevice::getBedId,dto.getBedId()); queryWrapper1.eq(StringUtil.isNotEmpty(dto.getBedId()), PlatRoomBedDevice::getBedId, dto.getBedId());
List<PlatRoomBedDevice> list = list(queryWrapper1); List<PlatRoomBedDevice> list = list(queryWrapper1);
List<String> listEquipmentIds = list.stream().map(item->item.getDeviceId()).collect(Collectors.toList()); List<String> listEquipmentIds = list.stream().map(item -> item.getDeviceId()).collect(Collectors.toList());
List<String> listBedIds = list.stream().map(item->item.getBedId()).collect(Collectors.toList()); List<String> listBedIds = list.stream().map(item -> item.getBedId()).collect(Collectors.toList());
LambdaQueryWrapper<PlatBed> queryWrapper2 = new LambdaQueryWrapper<>(); LambdaQueryWrapper<PlatBed> queryWrapper2 = new LambdaQueryWrapper<>();
queryWrapper2.in(PlatBed::getId,listBedIds); queryWrapper2.in(PlatBed::getId, listBedIds);
List<PlatBed> listBeds = platBedService.list(queryWrapper2); List<PlatBed> listBeds = platBedService.list(queryWrapper2);
Map<String,String> map = listBeds.stream().collect(Collectors.toMap(PlatBed::getId,PlatBed::getName,(k1, k2)->k1)); Map<String, String> map = listBeds.stream().collect(Collectors.toMap(PlatBed::getId, PlatBed::getName, (k1, k2) -> k1));
Map<String,String> mapName = new HashMap<>(20); Map<String, String> mapName = new HashMap<>(20);
Map<String,String> mapBedId = new HashMap<>(20); Map<String, String> mapBedId = new HashMap<>(20);
list.forEach(item->{ list.forEach(item -> {
if(map.containsKey(item.getBedId())){ if (map.containsKey(item.getBedId())) {
mapName.put(item.getDeviceId(),map.get(item.getBedId())); mapName.put(item.getDeviceId(), map.get(item.getBedId()));
mapBedId.put(item.getDeviceId(),item.getBedId()); mapBedId.put(item.getDeviceId(), item.getBedId());
} }
}); });
List<PlatDeviceDTO> data = new ArrayList<>(); List<PlatDeviceDTO> data = new ArrayList<>();
if(!listEquipmentIds.isEmpty()){ if (!listEquipmentIds.isEmpty()) {
LambdaQueryWrapper<PlatDevice> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<PlatDevice> queryWrapper = new LambdaQueryWrapper<>();
//queryWrapper.eq(PlatDevice::getCategory, PlatDeviceEnum.CategoryEnum.HEART); //queryWrapper.eq(PlatDevice::getCategory, PlatDeviceEnum.CategoryEnum.HEART);
queryWrapper.in(PlatDevice::getId,listEquipmentIds); queryWrapper.in(PlatDevice::getId, listEquipmentIds);
List<PlatDevice> listDevices = platDeviceService.list(queryWrapper); List<PlatDevice> listDevices = platDeviceService.list(queryWrapper);
data = BeanDtoVoUtils.listVo(listDevices,PlatDeviceDTO.class); data = BeanDtoVoUtils.listVo(listDevices, PlatDeviceDTO.class);
data.forEach(item->{ data.forEach(item -> {
item.setBedName(mapName.get(item.getId())); item.setBedName(mapName.get(item.getId()));
item.setBedId(mapBedId.get(item.getId())); item.setBedId(mapBedId.get(item.getId()));
}); });
...@@ -182,9 +182,7 @@ public class PlatRoomBedDeviceServiceImpl extends ServiceImpl<PlatRoomBedDeviceM ...@@ -182,9 +182,7 @@ public class PlatRoomBedDeviceServiceImpl extends ServiceImpl<PlatRoomBedDeviceM
} }
@Override private List<PlatDevice> getDeviceInternal(String bedId, String category) {
public List<PlatDevice> getSpaceDevice(String bedId) {
PlatBed bed = platBedService.getById(bedId); PlatBed bed = platBedService.getById(bedId);
List<PlatRoomBedDevice> deviceList = list(new QueryWrapper<PlatRoomBedDevice>().lambda() List<PlatRoomBedDevice> deviceList = list(new QueryWrapper<PlatRoomBedDevice>().lambda()
...@@ -192,10 +190,17 @@ public class PlatRoomBedDeviceServiceImpl extends ServiceImpl<PlatRoomBedDeviceM ...@@ -192,10 +190,17 @@ public class PlatRoomBedDeviceServiceImpl extends ServiceImpl<PlatRoomBedDeviceM
return platDeviceService.list(new QueryWrapper<PlatDevice>().lambda() return platDeviceService.list(new QueryWrapper<PlatDevice>().lambda()
.in(PlatDevice::getId, StreamUtil.mapId(deviceList, PlatRoomBedDevice::getDeviceId)) .in(PlatDevice::getId, StreamUtil.mapId(deviceList, PlatRoomBedDevice::getDeviceId))
.eq(PlatDevice::getCategory, PlatDeviceEnum.CategoryEnum.SPACE.getValue()) .eq(PlatDevice::getCategory, category)
); );
} }
@Override
public List<PlatDevice> getSpaceDevice(String bedId) {
return getDeviceInternal(bedId, PlatDeviceEnum.CategoryEnum.SPACE.getValue());
}
@Override
public List<PlatDevice> getFallDevice(String bedId) {
return getDeviceInternal(bedId, PlatDeviceEnum.CategoryEnum.FALL.getValue());
}
} }
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