Commit b1c74864 by 朱淼
parents f25daeef 7ff30f3f
package com.makeit.controller.sys;
import com.makeit.common.dto.BaseIdDTO;
import com.makeit.common.response.ApiResponseEntity;
import com.makeit.common.response.ApiResponseUtils;
import com.makeit.module.system.dto.SysFileDTOVO;
import com.makeit.module.system.entity.SysFile;
import com.makeit.module.system.service.SysFileService;
import com.makeit.utils.data.convert.BeanDtoVoUtils;
import com.makeit.utils.data.convert.StreamUtil;
import com.makeit.utils.storage.AccessoryRepository;
import com.makeit.utils.storage.DataWithMeta;
import com.makeit.utils.sys.FileUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.util.UriUtils;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.OutputStream;
import java.net.URLEncoder;
import java.util.Arrays;
import java.util.List;
@Api(tags = "saas-文件")
@RestController
@RequestMapping("/saas/sys/file")
public class SaasFileController {
@Autowired
public AccessoryRepository accessoryRepository;
@Autowired
private SysFileService sysFileService;
@ApiOperation("获取文件临时路径路径")
@PostMapping("getFileTmp")
public ApiResponseEntity<SysFileDTOVO> getFileTmp(@RequestBody BaseIdDTO baseIdDTO) {
SysFileDTOVO sysFileDTOVO = BeanDtoVoUtils.convert(sysFileService.getById(baseIdDTO.getId()), SysFileDTOVO.class);
sysFileDTOVO.setFullUrl(accessoryRepository.getTmpURL(sysFileDTOVO.getUrl()));
return ApiResponseUtils.success(sysFileDTOVO);
}
@ApiOperation("获取文件路径")
@PostMapping("getFile")
public ApiResponseEntity<List<SysFileDTOVO>> getFile(@RequestBody BaseIdDTO baseIdDTO) {
return ApiResponseUtils.success(FileUtil.convertMultiply(Arrays.asList(baseIdDTO.getId())).get(0));
}
@ApiOperation("获取文件路径集合")
@PostMapping("getFileList")
public ApiResponseEntity<List<List<SysFileDTOVO>>> getFile(@RequestBody List<String> list) {
return ApiResponseUtils.success(FileUtil.convertMultiply(list));
}
//这种方式可以 只是不能设置下载文件名
// @ApiOperation("下载文件")
// @PostMapping("downloadFile")
// public byte[] downloadFile(@RequestBody BaseIdDTO baseIdDTO) {
// return aliyunOSSRepository.getBytes(UriUtils.decode(StringUtils.substringAfter(sysFileService.getById(baseIdDTO.getId()).getUrl(), "oss/"), "UTF-8"));
// }
void downloadFile(HttpServletResponse response, String id) throws IOException {
SysFile sysFile = sysFileService.getById(id);
response.setCharacterEncoding("UTF-8");
response.setContentType("application/octet-stream");
// 设置文件头:最后一个参数是设置下载文件名
response.setHeader("Content-disposition", "attachment;filename=" + URLEncoder.encode(sysFile.getFileName(), "UTF-8"));
OutputStream outputStream = response.getOutputStream();
outputStream.write(accessoryRepository.getBytes(UriUtils.decode(StringUtils.substringAfter(sysFile.getUrl(), "oss/"), "UTF-8")));
}
//这样是可以
// private void previewFile(HttpServletResponse response, String id) throws IOException {
//
// SysFile sysFile = sysFileService.getById(id);
//
// response.setCharacterEncoding("UTF-8");
// response.setContentType("application/octet-stream");
// // 设置文件头:最后一个参数是设置下载文件名
// response.setHeader("Content-disposition", "inline;filename=" + URLEncoder.encode(sysFile.getFileName(), "UTF-8"));
//
// String suffix = sysFile.getUrl().substring(sysFile.getUrl().lastIndexOf("."));
//
// Map<String, String> map = new HashMap<>(16);
// map.put(".pdf", "application/pdf");
// map.put(".png", "image/png");
// map.put(".jpg", "image/jpg");
// map.put(".jpeg", "image/jpeg");
//
// String contentType = map.get(suffix);
// if (StringUtils.isNotBlank(contentType)) {
// response.setContentType(contentType);
// }
//
// OutputStream outputStream = response.getOutputStream();
// outputStream.write(aliyunOSSRepository.getBytes(UriUtils.decode(StringUtils.substringAfter(sysFile.getUrl(), "oss/"), "UTF-8")));
// outputStream.close();
// }
private void previewFile(HttpServletResponse response, String id) throws IOException {
SysFile sysFile = sysFileService.getById(id);
response.setCharacterEncoding("UTF-8");
// 设置文件头:最后一个参数是设置下载文件名
response.setHeader("Content-disposition", "inline;filename=" + URLEncoder.encode(sysFile.getFileName(), "UTF-8"));
DataWithMeta dataWithMeta = accessoryRepository.getDataWithMeta(UriUtils.decode(StringUtils.substringAfter(sysFile.getUrl(), "oss/"), "UTF-8"));
response.setContentType(dataWithMeta.getContentType());
OutputStream outputStream = response.getOutputStream();
outputStream.write(dataWithMeta.getBytes());
outputStream.close();
}
@ApiOperation("下载文件(json id)")
@RequestMapping(value = "downloadFile", method = {RequestMethod.GET, RequestMethod.POST})
public void downloadFile(HttpServletResponse response, @RequestBody BaseIdDTO baseIdDTO) throws IOException {
downloadFile(response, baseIdDTO.getId());
}
@ApiOperation("预览文件(json id)")
@RequestMapping(value = "previewFile", method = {RequestMethod.GET, RequestMethod.POST})
public void previewFile(HttpServletResponse response, @RequestBody BaseIdDTO baseIdDTO) throws IOException {
previewFile(response, baseIdDTO.getId());
}
@ApiOperation("下载文件")
@RequestMapping(value = "downloadFileParam", method = {RequestMethod.GET, RequestMethod.POST})
public void downloadFileParam(HttpServletResponse response, String id) throws IOException {
downloadFile(response, id);
}
@ApiOperation("预览文件")
@RequestMapping(value = "previewFileParam", method = {RequestMethod.GET, RequestMethod.POST})
public void previewFileParam(HttpServletResponse response, String id) throws IOException {
previewFile(response, id);
}
@ApiOperation("批量保存")
@PostMapping("addList")
public ApiResponseEntity<?> addList(@RequestBody List<SysFileDTOVO> list) {
List<SysFile> fileList = BeanDtoVoUtils.listVo(list, SysFile.class);
sysFileService.saveBatch(fileList);
return ApiResponseUtils.success(StreamUtil.map(fileList, SysFile::getId));
}
}
package com.makeit.controller.sys;
import com.makeit.common.response.ApiResponseEntity;
import com.makeit.common.response.ApiResponseUtils;
import com.makeit.module.system.dto.SysFileDTOVO;
import com.makeit.module.system.dto.UploadKeyDTO;
import com.makeit.module.system.entity.SysFile;
import com.makeit.module.system.service.SysFileService;
import com.makeit.utils.contract.word.WordConverterUtil;
import com.makeit.utils.data.convert.BeanDtoVoUtils;
import com.makeit.utils.data.convert.StreamUtil;
import com.makeit.utils.storage.HwObsRepository;
import com.makeit.utils.storage.PostSignature;
import com.makeit.utils.sys.FileUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StopWatch;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
/**
* @author liuhb
* @date 2021/12/14
*/
@Api(tags = "saas-文件")
@RestController
@RequestMapping("/saas/storage")
public class SaasUploadController extends BaseController {
@Autowired
private SysFileService sysFileService;
private static final Logger logger = LoggerFactory.getLogger(SaasUploadController.class);
// @ApiOperation(value = "获取key")
// @PostMapping("getKey")
// public String getKey(@ApiParam(value = "originalFilename") String originalFilename) {
// String fullPath = getFullPath(null, originalFilename);
// return getUri(accessoryRepository.getKey(fullPath));
// }
@ApiOperation(value = "获取key")
@PostMapping("getKey")
public SysFileDTOVO getKey(@RequestBody UploadKeyDTO dto) {
SysFileDTOVO sysFile = new SysFileDTOVO();
sysFile.setFileName(dto.getOriginalFilename());
String fullPath = getFullPath(null, dto.getOriginalFilename());
sysFile.setUrl(getUri(HwObsRepository.APIURI + accessoryRepository.getKey(fullPath)));
sysFile.setKey(accessoryRepository.getKey(fullPath));
return sysFile;
}
@ApiOperation(value = "获取签名")
@PostMapping("getSignature")
public PostSignature getPostSignature() {
return accessoryRepository.getPostSignature();
}
private String replaceSuffix(String name) {
int index = name.lastIndexOf(".");
return name.substring(0, index) + ".pdf";
}
private List<SysFile> uploadInternal(List<MultipartFile> files, String convertToPdf) {
StopWatch stopWatch = new StopWatch();
stopWatch.start();
List<SysFile> sysFileList = StreamUtil.map(files, e -> {
try {
SysFile sysFile = new SysFile();
sysFile.setFileName(e.getOriginalFilename());
String fullPath = getFullPath(null, e.getOriginalFilename());
sysFile.setUrl(getUri(storageRepository("1").save(e.getBytes(), fullPath)));
if ("1".equals(convertToPdf)) {
fullPath = getFullPath(null, replaceSuffix(e.getOriginalFilename()));
sysFile.setPdfUrl(getUri(storageRepository("1").save(WordConverterUtil.convert(e.getInputStream()), fullPath)));
}
sysFile.setMime(e.getContentType());
return sysFile;
} catch (IOException ex) {
throw new RuntimeException(ex);
}
});
sysFileService.saveBatch(sysFileList);
stopWatch.stop();
logger.info("文件上传耗时:{} ms", stopWatch.getLastTaskTimeMillis());
return sysFileList;
}
private List<SysFile> convertAndUploadInternal(List<MultipartFile> files) {
StopWatch stopWatch = new StopWatch();
stopWatch.start();
List<SysFile> sysFileList = StreamUtil.map(files, e -> {
try {
SysFile sysFile = new SysFile();
sysFile.setFileName(replaceSuffix(e.getOriginalFilename()));
String fullPath = getFullPath(null, replaceSuffix(e.getOriginalFilename()));
sysFile.setUrl(getUri(storageRepository("1").save(WordConverterUtil.convert(e.getInputStream()), fullPath)));
sysFile.setMime(e.getContentType());
return sysFile;
} catch (IOException ex) {
throw new RuntimeException(ex);
}
});
sysFileService.saveBatch(sysFileList);
stopWatch.stop();
logger.info("文件上传耗时:{} ms", stopWatch.getLastTaskTimeMillis());
return sysFileList;
}
@ApiOperation(value = "统一文件上传")
@PostMapping("uploadFile")
public ApiResponseEntity<List<String>> uploadFile(
@ApiParam(value = "convertToPdf") @RequestParam(defaultValue = "0") String convertToPdf,
@ApiParam(value = "files") List<MultipartFile> files) {
List<SysFile> sysFileList = uploadInternal(files, convertToPdf);
return ApiResponseUtils.success(StreamUtil.map(sysFileList, SysFile::getId));
}
@ApiOperation(value = "统一文件上传返回路径")
@PostMapping("uploadFileUrl")
public ApiResponseEntity<List<SysFileDTOVO>> uploadFileUrl(
@ApiParam(value = "convertToPdf") @RequestParam(defaultValue = "0") String convertToPdf,
@ApiParam(value = "files") List<MultipartFile> files) {
List<SysFile> sysFileList = uploadInternal(files, convertToPdf);
List<SysFileDTOVO> voList = BeanDtoVoUtils.listVo(sysFileList, SysFileDTOVO.class);
FileUtil.fillFullUrl(voList);
FileUtil.fillPdfFullUrl(voList);
return ApiResponseUtils.success(voList);
}
@ApiOperation(value = "统一转换为pdf后上传")
@PostMapping("convertAndUploadFile")
public ApiResponseEntity<List<String>> convertAndUploadFile(
@ApiParam(value = "files") List<MultipartFile> files) {
List<SysFile> sysFileList = convertAndUploadInternal(files);
return ApiResponseUtils.success(StreamUtil.map(sysFileList, SysFile::getId));
}
@ApiOperation(value = "统一转换为pdf后上传返回路径")
@PostMapping("convertAndUploadFileUrl")
public ApiResponseEntity<List<SysFileDTOVO>> convertAndUploadFileUrl(
@ApiParam(value = "files") List<MultipartFile> files) {
List<SysFile> sysFileList = convertAndUploadInternal(files);
List<SysFileDTOVO> voList = BeanDtoVoUtils.listVo(sysFileList, SysFileDTOVO.class);
FileUtil.fillFullUrl(voList);
//FileUtil.fillPdfFullUrl(voList);
return ApiResponseUtils.success(voList);
}
//下面两个的作用
//返回给前端的路径 要基于下面两个转发
@ApiOperation("获取oss文件")
@RequestMapping(value = "oss/**", method = RequestMethod.GET)
public void getOssFile(HttpServletRequest req, HttpServletResponse resp) throws Exception {
// String filepath = req.getRequestURI();
// filepath = UriUtils.decode(StringUtils.substringAfter(filepath, "oss"), "UTF-8");
// //.toString().split("\\?")[0];
// resp.sendRedirect(accessoryRepository.getPermanentURL(filepath));
resp.sendRedirect(accessoryRepository.getPermanentURL(req.getRequestURI()));
}
@ApiOperation("获取oss文件(临时路径)")
@RequestMapping(value = "tmp/oss/**", method = RequestMethod.GET)
public void getOssFileTmpPath(HttpServletRequest req, HttpServletResponse resp) throws Exception {
// String filepath = req.getRequestURI();
// filepath = UriUtils.decode(StringUtils.substringAfter(filepath, "tmp/oss"), "UTF-8");
// //.toString().split("\\?")[0];
// resp.sendRedirect(accessoryRepository.getTmpURL(filepath));
resp.sendRedirect(accessoryRepository.getTmpURL(req.getRequestURI()));
}
//private String name;
// private String nameOrigin;
// private String extName;
// private Long fileSize;
// private String storeType;//video audio img pdf等
// private String relativePath;
}
......@@ -28,6 +28,8 @@ public class PlatRoleDTOVO extends BaseOrgDTO implements Serializable {
@ApiModelProperty(value = "部门名称")
private String deptName;
private String orgPath;
@TableField(exist = false)
@ApiModelProperty(value = "角色名称集合")
private List<String> nameList;
......
......@@ -58,6 +58,11 @@ public class PlatAlarmRecordQueryDTO extends BaseTenantDTO {
//子女关联的老人id
private List<String> elderIdList;
/**
* 通知家属状态 0 未通知 1 已通知
*/
private String noticeStatus;
}
......@@ -6,10 +6,12 @@ import lombok.Data;
/**
* 租户端角色部门关联表
* 角色和所属部门 一对一
* @TableName plat_role_org
*/
@TableName(value ="plat_role_org")
@Data
@Deprecated
public class PlatRoleOrg extends BaseBusEntity {
/**
......
......@@ -120,6 +120,7 @@ public class PlatAlarmRecordServiceImpl extends ServiceImpl<PlatAlarmRecordMappe
String[] split = elderId.split(",");
PlatAlarmRecordQueryDTO data = dto.getData();
data.setElderIdList(Arrays.asList(split));
data.setNoticeStatus(CommonEnum.YES.getValue());
return page(dto);
}
......@@ -139,6 +140,7 @@ public class PlatAlarmRecordServiceImpl extends ServiceImpl<PlatAlarmRecordMappe
qw.or().apply("find_in_set('" + elderId + "',elder_ids)");
}
})
.eq(StringUtils.isNotBlank(param.getNoticeStatus()),PlatAlarmRecord::getNoticeStatus,param.getNoticeStatus())
.orderByDesc(BaseEntity::getCreateDate)
;
}
......@@ -304,6 +306,9 @@ public class PlatAlarmRecordServiceImpl extends ServiceImpl<PlatAlarmRecordMappe
*/
private void noticeByChannel(PlatAlarmConfig alarmConfig, PlatAlarmRecord alarmRecord, Set<String> phoneSet,Set<String> emailSet, List<SendTypeEnum> notifyChannelList) {
String notifyChannel = alarmConfig.getNotifyChannel();
if(StringUtils.isEmpty(notifyChannel)){
return;
}
String[] split = notifyChannel.split(",");
for (String sendType : split) {
SendTypeEnum sendTypeEnum = SendTypeEnum.getByValue(sendType);
......
......@@ -186,7 +186,10 @@ implements PlatRoleService {
PlatRoleDTOVO vo = BeanDtoVoUtils.convert(getById(id), PlatRoleDTOVO.class);
JoinUtil.join(Arrays.asList(vo), platOrgService, PlatRoleDTOVO::getOrgId, PlatOrg::getId, (r, e) -> r.setDeptName(e.getName()));
JoinUtil.join(Arrays.asList(vo), platOrgService, PlatRoleDTOVO::getOrgId, PlatOrg::getId, (r, e) ->{
r.setDeptName(e.getName());
r.setOrgPath(e.getPath()+","+e.getId());
} );
List<PlatMenuDTOVO> assignMenuDTO = getAssignMenuDTO(id);
List<PlatMenuDTOVO> tree = tree(assignMenuDTO);
......
......@@ -101,6 +101,9 @@ public class PlatElderDayReportDayServiceImpl implements PlatElderDayReportDaySe
platElderSleepEvaluationVO.setSleepDuration(Integer.valueOf(platElderSleepAnalysis.getSleepTime() + ""));
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;
}
......
......@@ -29,6 +29,7 @@ import com.makeit.vo.platform.elder.report.week.PlatElderSleepDiagramWeekVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.time.DayOfWeek;
import java.time.Duration;
import java.time.LocalDate;
......@@ -262,20 +263,7 @@ public class PlatElderDayReportWeekServiceImpl implements PlatElderDayReportWeek
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());
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;
return getPlatElderSleepDiagramWeekContentVO(dateTimeFormatter, sleepAnalysisMap, timeFormatter, e, vo, sleepRecord);
});
......@@ -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());
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());
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;
return getPlatElderSleepDiagramWeekContentVO(dateTimeFormatter, sleepAnalysisMap, timeFormatter, e, vo, sleepRecord);
});
......@@ -311,6 +286,28 @@ public class PlatElderDayReportWeekServiceImpl implements PlatElderDayReportWeek
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
public PlatElderHeartRespiratoryEvaluationVO heartRespiratoryEvaluationInternal(PlatElderReportDTO platElderIdDTO, LocalDate weekStartDate, LocalDate weekEndDate) {
......
......@@ -98,11 +98,20 @@ public class PlatRoomBedDeviceServiceImpl extends ServiceImpl<PlatRoomBedDeviceM
LambdaQueryWrapper<PlatRoomBedDevice> queryWrapper1 = new LambdaQueryWrapper<>();
queryWrapper1.select(PlatRoomBedDevice::getDeviceId);
List<PlatRoomBedDevice> list = list(queryWrapper1);
List<PlatRoomBedDevice> list1 = new ArrayList<>();
if (CommonEnum.NO.getValue().equals(dto.getIsRoom())) {
queryWrapper1.isNotNull(PlatRoomBedDevice::getBedId);
queryWrapper1.eq(PlatRoomBedDevice::getRoomId, dto.getRoomId());
list.forEach(item->{
if(!item.getRoomId().equals(dto.getRoomId())
|| (item.getRoomId().equals(dto.getRoomId()) && StringUtil.isEmpty(item.getBedId()))){
list1.add(item);
}
});
}
List<PlatRoomBedDevice> list = list(queryWrapper1);
List<String> listEquipmentIds = list.stream().map(item -> item.getDeviceId()).collect(Collectors.toList());
String orgId = "";
......
......@@ -3,6 +3,8 @@ package com.makeit.vo.platform.elder.report.day;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
@Data
public class PlatElderSleepEvaluationVO {
......@@ -22,4 +24,12 @@ public class PlatElderSleepEvaluationVO {
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;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
import java.time.LocalDate;
@Data
......@@ -23,6 +24,7 @@ public class PlatElderSleepDiagramWeekContentVO {
@ApiModelProperty(value = "清醒时长")
private Integer soberDuration;
@ApiModelProperty(value = "翻身次数")
private Integer turnedCount;
......@@ -33,5 +35,17 @@ public class PlatElderSleepDiagramWeekContentVO {
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