Commit 635e7a96 by 杨伟程

小时字段

parent 891fb6fe
...@@ -101,6 +101,9 @@ public class PlatElderDayReportDayServiceImpl implements PlatElderDayReportDaySe ...@@ -101,6 +101,9 @@ public class PlatElderDayReportDayServiceImpl implements PlatElderDayReportDaySe
platElderSleepEvaluationVO.setSleepDuration(Integer.valueOf(platElderSleepAnalysis.getSleepTime() + "")); platElderSleepEvaluationVO.setSleepDuration(Integer.valueOf(platElderSleepAnalysis.getSleepTime() + ""));
platElderSleepEvaluationVO.setRestDuration(Integer.valueOf(platElderSleepAnalysis.getRestTime() + "")); platElderSleepEvaluationVO.setRestDuration(Integer.valueOf(platElderSleepAnalysis.getRestTime() + ""));
platElderSleepEvaluationVO.setSleepDurationHour(new BigDecimal(platElderSleepEvaluationVO.getSleepDuration()).divide(new BigDecimal(60), 2, BigDecimal.ROUND_HALF_UP));
platElderSleepEvaluationVO.setRestDurationHour(new BigDecimal(platElderSleepEvaluationVO.getRestDuration()).divide(new BigDecimal(60), 2, BigDecimal.ROUND_HALF_UP));
return platElderSleepEvaluationVO; return platElderSleepEvaluationVO;
} }
......
...@@ -29,6 +29,7 @@ import com.makeit.vo.platform.elder.report.week.PlatElderSleepDiagramWeekVO; ...@@ -29,6 +29,7 @@ import com.makeit.vo.platform.elder.report.week.PlatElderSleepDiagramWeekVO;
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.math.BigDecimal;
import java.time.DayOfWeek; import java.time.DayOfWeek;
import java.time.Duration; import java.time.Duration;
import java.time.LocalDate; import java.time.LocalDate;
...@@ -262,20 +263,7 @@ public class PlatElderDayReportWeekServiceImpl implements PlatElderDayReportWeek ...@@ -262,20 +263,7 @@ public class PlatElderDayReportWeekServiceImpl implements PlatElderDayReportWeek
List<PlatSleepRangeVO> sleepRecord = list.stream().flatMap(i -> i.getSleepRecord().stream()).collect(Collectors.toList()); List<PlatSleepRangeVO> sleepRecord = list.stream().flatMap(i -> i.getSleepRecord().stream()).collect(Collectors.toList());
vo.setSleepDeepDuration(sleepRecord.stream().filter(i -> SleepTypeEnum.SLEEP_DEEP.getCode().equals(i.getSleepType())).map(i -> duration(timeFormatter, i.getStartTime(), i.getEndTime())).reduce(0L, Long::sum).intValue()); return getPlatElderSleepDiagramWeekContentVO(dateTimeFormatter, sleepAnalysisMap, timeFormatter, e, vo, sleepRecord);
vo.setSleepModerateDuration(sleepRecord.stream().filter(i -> SleepTypeEnum.SLEEP_MODERATE.getCode().equals(i.getSleepType())).map(i -> duration(timeFormatter, i.getStartTime(), i.getEndTime())).reduce(0L, Long::sum).intValue());
vo.setSleepLightnessDuration(sleepRecord.stream().filter(i -> SleepTypeEnum.SLEEP_LIGHTNESS.getCode().equals(i.getSleepType())).map(i -> duration(timeFormatter, i.getStartTime(), i.getEndTime())).reduce(0L, Long::sum).intValue());
vo.setSoberDuration(sleepRecord.stream().filter(i -> SleepTypeEnum.SOBER.getCode().equals(i.getSleepType())).map(i -> duration(timeFormatter, i.getStartTime(), i.getEndTime())).reduce(0L, Long::sum).intValue());
PlatElderSleepAnalysis platElderSleepAnalysis = sleepAnalysisMap.get(dateTimeFormatter.format(e));
if (platElderSleepAnalysis != null) {
vo.setTurnedCount(platElderSleepAnalysis.getTurnedCount());
vo.setBodyMoveCount(platElderSleepAnalysis.getActionCount());
vo.setScore(Integer.valueOf(platElderSleepAnalysis.getSleepScore() + ""));
}
return vo;
}); });
...@@ -287,20 +275,7 @@ public class PlatElderDayReportWeekServiceImpl implements PlatElderDayReportWeek ...@@ -287,20 +275,7 @@ public class PlatElderDayReportWeekServiceImpl implements PlatElderDayReportWeek
List<PlatSleepRangeVO> sleepRecord = list.stream().flatMap(i -> Optional.ofNullable(i.getSleepRecord()).orElse(new ArrayList<>(10)).stream()).collect(Collectors.toList()); List<PlatSleepRangeVO> sleepRecord = list.stream().flatMap(i -> Optional.ofNullable(i.getSleepRecord()).orElse(new ArrayList<>(10)).stream()).collect(Collectors.toList());
vo.setSleepDeepDuration(sleepRecord.stream().filter(i -> SleepTypeEnum.SLEEP_DEEP.getCode().equals(i.getSleepType())).map(i -> duration(timeFormatter, i.getStartTime(), i.getEndTime())).reduce(0L, Long::sum).intValue()); return getPlatElderSleepDiagramWeekContentVO(dateTimeFormatter, sleepAnalysisMap, timeFormatter, e, vo, sleepRecord);
vo.setSleepModerateDuration(sleepRecord.stream().filter(i -> SleepTypeEnum.SLEEP_MODERATE.getCode().equals(i.getSleepType())).map(i -> duration(timeFormatter, i.getStartTime(), i.getEndTime())).reduce(0L, Long::sum).intValue());
vo.setSleepLightnessDuration(sleepRecord.stream().filter(i -> SleepTypeEnum.SLEEP_LIGHTNESS.getCode().equals(i.getSleepType())).map(i -> duration(timeFormatter, i.getStartTime(), i.getEndTime())).reduce(0L, Long::sum).intValue());
vo.setSoberDuration(sleepRecord.stream().filter(i -> SleepTypeEnum.SOBER.getCode().equals(i.getSleepType())).map(i -> duration(timeFormatter, i.getStartTime(), i.getEndTime())).reduce(0L, Long::sum).intValue());
PlatElderSleepAnalysis platElderSleepAnalysis = sleepAnalysisMap.get(dateTimeFormatter.format(e));
if (platElderSleepAnalysis != null) {
vo.setTurnedCount(platElderSleepAnalysis.getTurnedCount());
vo.setBodyMoveCount(platElderSleepAnalysis.getActionCount());
vo.setScore(Integer.valueOf(platElderSleepAnalysis.getSleepScore() + ""));
}
return vo;
}); });
...@@ -311,6 +286,28 @@ public class PlatElderDayReportWeekServiceImpl implements PlatElderDayReportWeek ...@@ -311,6 +286,28 @@ public class PlatElderDayReportWeekServiceImpl implements PlatElderDayReportWeek
return vo; return vo;
} }
private PlatElderSleepDiagramWeekContentVO getPlatElderSleepDiagramWeekContentVO(DateTimeFormatter dateTimeFormatter, Map<String, PlatElderSleepAnalysis> sleepAnalysisMap, DateTimeFormatter timeFormatter, LocalDate e, PlatElderSleepDiagramWeekContentVO vo, List<PlatSleepRangeVO> sleepRecord) {
vo.setSleepDeepDuration(sleepRecord.stream().filter(i -> SleepTypeEnum.SLEEP_DEEP.getCode().equals(i.getSleepType())).map(i -> duration(timeFormatter, i.getStartTime(), i.getEndTime())).reduce(0L, Long::sum).intValue());
vo.setSleepModerateDuration(sleepRecord.stream().filter(i -> SleepTypeEnum.SLEEP_MODERATE.getCode().equals(i.getSleepType())).map(i -> duration(timeFormatter, i.getStartTime(), i.getEndTime())).reduce(0L, Long::sum).intValue());
vo.setSleepLightnessDuration(sleepRecord.stream().filter(i -> SleepTypeEnum.SLEEP_LIGHTNESS.getCode().equals(i.getSleepType())).map(i -> duration(timeFormatter, i.getStartTime(), i.getEndTime())).reduce(0L, Long::sum).intValue());
vo.setSoberDuration(sleepRecord.stream().filter(i -> SleepTypeEnum.SOBER.getCode().equals(i.getSleepType())).map(i -> duration(timeFormatter, i.getStartTime(), i.getEndTime())).reduce(0L, Long::sum).intValue());
vo.setSleepDeepDurationHour(new BigDecimal(vo.getSleepDeepDuration()).divide(new BigDecimal(60), 2, BigDecimal.ROUND_HALF_UP));
vo.setSleepModerateDurationHour(new BigDecimal(vo.getSleepModerateDuration()).divide(new BigDecimal(60), 2, BigDecimal.ROUND_HALF_UP));
vo.setSleepLightnessDurationHour(new BigDecimal(vo.getSleepLightnessDuration()).divide(new BigDecimal(60), 2, BigDecimal.ROUND_HALF_UP));
vo.setSoberDurationHour(new BigDecimal(vo.getSoberDuration()).divide(new BigDecimal(60), 2, BigDecimal.ROUND_HALF_UP));
PlatElderSleepAnalysis platElderSleepAnalysis = sleepAnalysisMap.get(dateTimeFormatter.format(e));
if (platElderSleepAnalysis != null) {
vo.setTurnedCount(platElderSleepAnalysis.getTurnedCount());
vo.setBodyMoveCount(platElderSleepAnalysis.getActionCount());
vo.setScore(Integer.valueOf(platElderSleepAnalysis.getSleepScore() + ""));
}
return vo;
}
@Override @Override
public PlatElderHeartRespiratoryEvaluationVO heartRespiratoryEvaluationInternal(PlatElderReportDTO platElderIdDTO, LocalDate weekStartDate, LocalDate weekEndDate) { public PlatElderHeartRespiratoryEvaluationVO heartRespiratoryEvaluationInternal(PlatElderReportDTO platElderIdDTO, LocalDate weekStartDate, LocalDate weekEndDate) {
......
...@@ -3,6 +3,8 @@ package com.makeit.vo.platform.elder.report.day; ...@@ -3,6 +3,8 @@ package com.makeit.vo.platform.elder.report.day;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import java.math.BigDecimal;
@Data @Data
public class PlatElderSleepEvaluationVO { public class PlatElderSleepEvaluationVO {
...@@ -22,4 +24,12 @@ public class PlatElderSleepEvaluationVO { ...@@ -22,4 +24,12 @@ public class PlatElderSleepEvaluationVO {
private Integer restDuration; private Integer restDuration;
@ApiModelProperty(value = "睡眠时长")
private BigDecimal sleepDurationHour;
@ApiModelProperty(value = "休息时长")
private BigDecimal restDurationHour;
} }
...@@ -3,6 +3,7 @@ package com.makeit.vo.platform.elder.report.week; ...@@ -3,6 +3,7 @@ package com.makeit.vo.platform.elder.report.week;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import java.math.BigDecimal;
import java.time.LocalDate; import java.time.LocalDate;
@Data @Data
...@@ -23,6 +24,7 @@ public class PlatElderSleepDiagramWeekContentVO { ...@@ -23,6 +24,7 @@ public class PlatElderSleepDiagramWeekContentVO {
@ApiModelProperty(value = "清醒时长") @ApiModelProperty(value = "清醒时长")
private Integer soberDuration; private Integer soberDuration;
@ApiModelProperty(value = "翻身次数") @ApiModelProperty(value = "翻身次数")
private Integer turnedCount; private Integer turnedCount;
...@@ -33,5 +35,17 @@ public class PlatElderSleepDiagramWeekContentVO { ...@@ -33,5 +35,17 @@ public class PlatElderSleepDiagramWeekContentVO {
private Integer score; private Integer score;
@ApiModelProperty(value = "深度睡眠时长")
private BigDecimal sleepDeepDurationHour;
@ApiModelProperty(value = "中度睡眠时长")
private BigDecimal sleepModerateDurationHour;
@ApiModelProperty(value = "浅度睡眠时长")
private BigDecimal sleepLightnessDurationHour;
@ApiModelProperty(value = "清醒时长")
private BigDecimal soberDurationHour;
} }
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