|
|
|
|
@ -141,6 +141,48 @@ public class WxNursingLogServiceImpl implements IWxNursingLogService {
|
|
|
|
|
return nursingLog;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public WxNursingStatisticsRet fr200Statistics(Long nursingId) {
|
|
|
|
|
// 查询护理记录
|
|
|
|
|
WxNursingLog wxNursingLog = wxNursingLogMapper.selectWxNursingLogById(nursingId);
|
|
|
|
|
if (wxNursingLog == null) {
|
|
|
|
|
throw new ServiceException("参数有误");
|
|
|
|
|
}
|
|
|
|
|
// 查询模式信息
|
|
|
|
|
WxMode wxMode = wxModeMapper.selectWxModeById(wxNursingLog.getModeId());
|
|
|
|
|
// 获取模式分类
|
|
|
|
|
Long modeClass = wxMode.getModeClass();
|
|
|
|
|
// 获取用户ID
|
|
|
|
|
Long userId = wxNursingLog.getUserId();
|
|
|
|
|
// 构建查询条件
|
|
|
|
|
WxNursingLog queryNursingLog = new WxNursingLog();
|
|
|
|
|
LocalDateTime selectTime = LocalDateTime.ofInstant(wxNursingLog.getCreateTime().toInstant(), ZoneId.systemDefault());
|
|
|
|
|
queryNursingLog.getParams().put("beginTime", selectTime.with(TemporalAdjusters.firstDayOfMonth()).with(LocalTime.MIN));
|
|
|
|
|
queryNursingLog.getParams().put("endTime", selectTime.with(TemporalAdjusters.lastDayOfMonth()).with(LocalTime.MAX));
|
|
|
|
|
queryNursingLog.setUserId(userId);
|
|
|
|
|
List<WxNursingLog> wxNursingLogList = wxNursingLogMapper.fr200Statistics(queryNursingLog, modeClass);
|
|
|
|
|
|
|
|
|
|
// 结果封装
|
|
|
|
|
WxNursingStatisticsRet wxNursingStatisticsRet = new WxNursingStatisticsRet();
|
|
|
|
|
if (wxNursingLogList != null && wxNursingLogList.size() > 0) {
|
|
|
|
|
Map<LocalDate, Long> collect = wxNursingLogList.stream().collect(
|
|
|
|
|
Collectors.groupingBy(
|
|
|
|
|
log -> log.getCreateTime().toInstant()
|
|
|
|
|
.atZone(ZoneId.systemDefault()).toLocalDate(), Collectors.counting()
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
wxNursingStatisticsRet.setNursingNum(collect.size());
|
|
|
|
|
Integer totalNursingSecond = 0;
|
|
|
|
|
for (WxNursingLog nursingLog : wxNursingLogList) {
|
|
|
|
|
if (nursingLog.getNursingTime() != null) {
|
|
|
|
|
totalNursingSecond += nursingLog.getNursingTime().toSecondOfDay();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
wxNursingStatisticsRet.setNursingTime(DateUtils.formatHMS(totalNursingSecond));
|
|
|
|
|
}
|
|
|
|
|
return wxNursingStatisticsRet;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 新增用户护理日志
|
|
|
|
|
*/
|
|
|
|
|
|