Commit 551202ae by 汪志阳

fix:bug fix

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