Commit 551202ae by 汪志阳

fix:bug fix

parent 7036d554
...@@ -31,6 +31,15 @@ public class SleepTimeAnalysisVO { ...@@ -31,6 +31,15 @@ public class SleepTimeAnalysisVO {
*/ */
private String type; private String type;
/**
* 体动次数
*/
private Integer actionCount;
/**
* 翻身次数
*/
private Integer turnedCount;
private List<SleepTimeAnalysisVO> deepList; private List<SleepTimeAnalysisVO> deepList;
private List<SleepTimeAnalysisVO> midList; private List<SleepTimeAnalysisVO> midList;
/** /**
......
...@@ -224,6 +224,9 @@ public class PlatElderSleepServiceImpl extends ServiceImpl<PlatElderSleepMapper, ...@@ -224,6 +224,9 @@ public class PlatElderSleepServiceImpl extends ServiceImpl<PlatElderSleepMapper,
int sleepMinute = 0; int sleepMinute = 0;
int riseActionDuration = Integer.parseInt(analysisModel.getRiseActionDuration()); int riseActionDuration = Integer.parseInt(analysisModel.getRiseActionDuration());
double riseLeaveThreshold = Double.parseDouble(analysisModel.getRiseLeaveThreshold()); double riseLeaveThreshold = Double.parseDouble(analysisModel.getRiseLeaveThreshold());
Integer totalActionCount = 0;
Integer totalTurnedCount = 0;
for (Map.Entry<String, AnalysisVO> entry : totalMap.entrySet()) { for (Map.Entry<String, AnalysisVO> entry : totalMap.entrySet()) {
AnalysisVO analysisVO = entry.getValue(); AnalysisVO analysisVO = entry.getValue();
// 非离床且体动值<20 // 非离床且体动值<20
...@@ -232,6 +235,8 @@ public class PlatElderSleepServiceImpl extends ServiceImpl<PlatElderSleepMapper, ...@@ -232,6 +235,8 @@ public class PlatElderSleepServiceImpl extends ServiceImpl<PlatElderSleepMapper,
startSleepTime = entry.getKey(); startSleepTime = entry.getKey();
} }
sleepMinute++; sleepMinute++;
totalActionCount += analysisVO.getActionCount();
totalTurnedCount += analysisVO.getTurnedCount();
continue; continue;
} }
if (StringUtils.isEmpty(startSleepTime) && sleepMinute == 0) { if (StringUtils.isEmpty(startSleepTime) && sleepMinute == 0) {
...@@ -242,6 +247,8 @@ public class PlatElderSleepServiceImpl extends ServiceImpl<PlatElderSleepMapper, ...@@ -242,6 +247,8 @@ public class PlatElderSleepServiceImpl extends ServiceImpl<PlatElderSleepMapper,
sleepTimeAnalysisVO.setStartTime(startSleepTime); sleepTimeAnalysisVO.setStartTime(startSleepTime);
sleepTimeAnalysisVO.setEndTime(entry.getKey()); sleepTimeAnalysisVO.setEndTime(entry.getKey());
sleepTimeAnalysisVO.setType(SleepTypeEnum.DAY_SLEEP.getCode()); sleepTimeAnalysisVO.setType(SleepTypeEnum.DAY_SLEEP.getCode());
sleepTimeAnalysisVO.setActionCount(totalActionCount);
sleepTimeAnalysisVO.setTurnedCount(totalTurnedCount);
isSleep = true; isSleep = true;
} }
getUpTime = sleepTimeAnalysisVO.getGetUpTime(); getUpTime = sleepTimeAnalysisVO.getGetUpTime();
...@@ -291,6 +298,8 @@ public class PlatElderSleepServiceImpl extends ServiceImpl<PlatElderSleepMapper, ...@@ -291,6 +298,8 @@ public class PlatElderSleepServiceImpl extends ServiceImpl<PlatElderSleepMapper,
if (!isSleep) { if (!isSleep) {
startSleepTime = null; startSleepTime = null;
sleepMinute = 0; sleepMinute = 0;
totalActionCount = 0;
totalTurnedCount = 0;
} }
if (isSleep && StrUtil.isNotBlank(getUpTime)) { if (isSleep && StrUtil.isNotBlank(getUpTime)) {
...@@ -303,6 +312,8 @@ public class PlatElderSleepServiceImpl extends ServiceImpl<PlatElderSleepMapper, ...@@ -303,6 +312,8 @@ public class PlatElderSleepServiceImpl extends ServiceImpl<PlatElderSleepMapper,
minuteActionCount = 0; minuteActionCount = 0;
getUpTime = null; getUpTime = null;
isSleep = false; isSleep = false;
totalActionCount = 0;
totalTurnedCount = 0;
} }
} }
TreeMap<String, TreeMap<String, AnalysisVO>> sleepTypeMap = new TreeMap<>(); TreeMap<String, TreeMap<String, AnalysisVO>> sleepTypeMap = new TreeMap<>();
...@@ -339,17 +350,17 @@ public class PlatElderSleepServiceImpl extends ServiceImpl<PlatElderSleepMapper, ...@@ -339,17 +350,17 @@ public class PlatElderSleepServiceImpl extends ServiceImpl<PlatElderSleepMapper,
* *
* @param totalMap * @param totalMap
*/ */
private void countTotal(TreeMap<String, AnalysisVO> totalMap, private void countTotal(TreeMap<String, TreeMap<String, AnalysisVO>> totalMap,
SleepCountDTO sleepCountDTO) { SleepCountDTO sleepCountDTO) {
Integer actionCount = 0; AtomicReference<Integer> actionCount = new AtomicReference<>(0);
Integer turnedCount = 0; AtomicReference<Integer> turnedCount = new AtomicReference<>(0);
for (Map.Entry<String, AnalysisVO> entry : totalMap.entrySet()) {
AnalysisVO analysisVO = entry.getValue(); totalMap.forEach((k, v) -> v.forEach((k2, v2) -> {
actionCount += analysisVO.getActionCount(); actionCount.updateAndGet(v1 -> v1 + v2.getActionCount());
turnedCount += analysisVO.getTurnedCount(); turnedCount.updateAndGet(v1 -> v1 + v2.getTurnedCount());
} }));
sleepCountDTO.setTotalActionCount(actionCount); sleepCountDTO.setTotalActionCount(actionCount.get());
sleepCountDTO.setTotalTurnedCount(turnedCount); sleepCountDTO.setTotalTurnedCount(turnedCount.get());
} }
/** /**
...@@ -843,7 +854,7 @@ public class PlatElderSleepServiceImpl extends ServiceImpl<PlatElderSleepMapper, ...@@ -843,7 +854,7 @@ public class PlatElderSleepServiceImpl extends ServiceImpl<PlatElderSleepMapper,
middleSleep(daySleepMap, analysisModel, sleepTimeAnalysisVOList); middleSleep(daySleepMap, analysisModel, sleepTimeAnalysisVOList);
// 清醒 // 清醒
sober(sleepTypeMap, sleepTimeAnalysisVOList); sober(sleepTypeMap, sleepTimeAnalysisVOList);
countTotal(totalMap, sleepCountDTO); countTotal(sleepTypeMap, sleepCountDTO);
//浅睡 //浅睡
SleepTimeDTO sleepTimeDTO = groupSleepData(sleepTimeAnalysisVOList); SleepTimeDTO sleepTimeDTO = groupSleepData(sleepTimeAnalysisVOList);
List<PlatElderSleep> platElderSleeps = saveElderSleep(sleepTimeDTO, elder.getId(), elder.getTenantId(), currentDate); List<PlatElderSleep> platElderSleeps = saveElderSleep(sleepTimeDTO, elder.getId(), elder.getTenantId(), currentDate);
......
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