Commit f551d371 by 朱淼

代码整理

parent ac8aec65
......@@ -160,4 +160,8 @@ public class StreamUtil {
return list.stream().filter(predicate).map(function).collect(Collectors.joining(","));
}
public static <T> String join(List<T> list, Predicate<T> predicate, Function<T, String> function, String split) {
return list.stream().filter(predicate).map(function).collect(Collectors.joining(split));
}
}
......@@ -8,6 +8,7 @@ import com.makeit.dto.platform.space.PlatRoomPanoramaDTO;
import com.makeit.entity.platform.elder.PlatElder;
import com.makeit.service.platform.space.PlatRoomDynamicService;
import com.makeit.vo.platform.space.PlatBedPanoramaVO;
import com.makeit.vo.platform.space.PlatDeviceElderVO;
import com.makeit.vo.platform.space.PlatRoomPanoramaVO;
import com.makeit.vo.platform.space.PlatSpaceAndRoomVO;
import io.swagger.annotations.Api;
......@@ -64,8 +65,8 @@ public class PlatRoomDynamicController {
@ApiOperation("房间详细-下拉长者")
@PostMapping("elderList")
public ApiResponseEntity<List<PlatElder>> elderList(@RequestBody PlatElderQueryDTO dto) {
List<PlatElder> data = platRoomDynamicService.elderList(dto);
public ApiResponseEntity<List<PlatDeviceElderVO>> elderList(@RequestBody PlatElderQueryDTO dto) {
List<PlatDeviceElderVO> data = platRoomDynamicService.elderList(dto);
return ApiResponseUtils.success(data);
}
......
......@@ -7,6 +7,7 @@ import com.makeit.entity.platform.auth.PlatOrg;
import com.makeit.entity.platform.auth.PlatUser;
import com.makeit.entity.platform.device.PlatDevice;
import com.makeit.entity.platform.elder.PlatElder;
import com.makeit.entity.platform.space.PlatBed;
import com.makeit.entity.platform.space.PlatSpace;
import com.makeit.enums.CommonEnum;
import com.makeit.enums.platform.alarm.PlatAlarmConfigEnum;
......@@ -25,12 +26,17 @@ import com.makeit.service.platform.space.PlatSpaceService;
import com.makeit.utils.area.AreaUtil;
import com.makeit.utils.area.ChinaAreaVO;
import com.makeit.utils.data.convert.BeanDtoVoUtils;
import com.makeit.utils.data.convert.StreamUtil;
import com.makeit.utils.sql.join.JoinUtil;
import com.makeit.vo.platform.dataScreen.*;
import com.makeit.vo.platform.elder.PlatElderListVO;
import jodd.util.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
......@@ -176,26 +182,46 @@ public class DataScreenServiceImpl implements DataScreenService {
.in(PlatAlarmRecord::getOrgId, dto.getOrgIds()));
List<PlatElder> platElders = platElderService.list();
Map<String,String> elderNameMap = platElders.stream().collect(Collectors.toMap(PlatElder::getId,PlatElder::getName));
Map<String, PlatElderListVO> elderBedPathMap = mapElderBedPath(platElders);
List<PlatAlarmStatisticsListVo> list = new ArrayList<>();
long total = 0;
long handledNumber = 0;
long unhandledNumber = 0;
DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
DateFormat dft = new SimpleDateFormat("HH:mm:ss");
for (PlatAlarmRecord record : alarmRecords){
if(StringUtil.isNotEmpty(record.getElderIds())){
List<String> elderIds = Arrays.asList(record.getElderIds().split(","));
PlatAlarmStatisticsListVo listVo = new PlatAlarmStatisticsListVo();
String elderName = "";
String pathName = "";
for (String elderId : elderIds){
if(elderNameMap.get(elderId)!=null){
elderName = "".equals(elderName) ? elderNameMap.get(elderId) : elderName + "," + elderNameMap.get(elderId);
}
if(PlatAlarmConfigEnum.AlarmTypeEnum.HEART.getValue().equals(record.getAlarmType()) ||
PlatAlarmConfigEnum.AlarmTypeEnum.BREATHE.getValue().equals(record.getAlarmType()) ){
if(elderBedPathMap.get(elderId)!= null){
pathName = elderBedPathMap.get(elderId).getSpacePathName();
}
}else {
if(elderBedPathMap.get(elderId)!= null){
pathName = "".equals(pathName) ? elderBedPathMap.get(elderId).getSpacePathName()
: pathName + "," + elderBedPathMap.get(elderId).getRoomName();
}
}
}
if(PlatAlarmConfigEnum.AlarmTypeEnum.HEART.getValue().equals(record.getAlarmType()) ||
PlatAlarmConfigEnum.AlarmTypeEnum.BREATHE.getValue().equals(record.getAlarmType()) ){
listVo.setStatus(record.getRemark());
}
listVo.setPath(pathName);
listVo.setElderName(elderName);
listVo.setType(record.getAlarmType());
listVo.setAlarmDate(df.format(record.getAlarmDate()));
listVo.setAlarmTime(dft.format(record.getAlarmDate()));
total ++;
if(PlatAlarmRecordEnum.AlarmRecordStatusEnum.HANDLED.getValue().equals(record.getStatus())){
handledNumber ++;
......@@ -213,6 +239,18 @@ public class DataScreenServiceImpl implements DataScreenService {
return vo;
}
private Map<String, PlatElderListVO> mapElderBedPath(List<PlatElder> platElders) {
List<PlatElderListVO> list = BeanDtoVoUtils.listVo(platElders, PlatElderListVO.class);
JoinUtil.joinSplit(list, platSpaceService, PlatElderListVO::getSpacePath, PlatSpace::getId, (e, l) -> {
e.setSpacePathName(StreamUtil.join(l, Objects::nonNull, PlatSpace::getName, "-"));
});
JoinUtil.join(list, platBedService, PlatElderListVO::getBedId, PlatBed::getId, (e, l) -> {
e.setBedName(l.getName());
});
Map<String, PlatElderListVO> map = list.stream().collect(Collectors.toMap(PlatElderListVO::getBedId, Function.identity()));
return map;
}
@Override
public PlatBaseInfoStatisticsVO baseInfoStatistics(PlatDataScreenQueryDTO dto) {
PlatBaseInfoStatisticsVO vo = new PlatBaseInfoStatisticsVO();
......
......@@ -5,6 +5,7 @@ import com.makeit.dto.platform.space.PlatBedPanoramaDTO;
import com.makeit.dto.platform.space.PlatRoomPanoramaDTO;
import com.makeit.entity.platform.elder.PlatElder;
import com.makeit.vo.platform.space.PlatBedPanoramaVO;
import com.makeit.vo.platform.space.PlatDeviceElderVO;
import com.makeit.vo.platform.space.PlatRoomPanoramaVO;
import com.makeit.vo.platform.space.PlatSpaceAndRoomVO;
......@@ -25,5 +26,5 @@ public interface PlatRoomDynamicService {
List<PlatSpaceAndRoomVO> bedPanoramaTree();
List<PlatElder> elderList(PlatElderQueryDTO dto);
List<PlatDeviceElderVO> elderList(PlatElderQueryDTO dto);
}
......@@ -7,26 +7,22 @@ import com.makeit.dto.platform.space.PlatRoomPanoramaDTO;
import com.makeit.entity.platform.elder.PlatElder;
import com.makeit.entity.platform.space.PlatBed;
import com.makeit.entity.platform.space.PlatRoom;
import com.makeit.entity.platform.space.PlatRoomBedDevice;
import com.makeit.entity.platform.space.PlatSpace;
import com.makeit.enums.platform.space.PlatBedPanoramaSpaceType;
import com.makeit.enums.platform.space.PlatRoomStatusEnum;
import com.makeit.service.platform.elder.PlatElderService;
import com.makeit.service.platform.space.PlatBedService;
import com.makeit.service.platform.space.PlatRoomDynamicService;
import com.makeit.service.platform.space.PlatRoomService;
import com.makeit.service.platform.space.PlatSpaceService;
import com.makeit.vo.platform.space.PlatBedPanoramaVO;
import com.makeit.vo.platform.space.PlatRoomPanoramaVO;
import com.makeit.vo.platform.space.PlatRoomVO;
import com.makeit.vo.platform.space.PlatSpaceAndRoomVO;
import com.makeit.service.platform.space.*;
import com.makeit.utils.data.convert.BeanDtoVoUtils;
import com.makeit.utils.data.convert.StreamUtil;
import com.makeit.utils.sql.join.JoinUtil;
import com.makeit.vo.platform.elder.PlatElderListVO;
import com.makeit.vo.platform.space.*;
import jodd.util.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
/**
......@@ -45,6 +41,8 @@ public class PlatRoomDynamicServiceImpl implements PlatRoomDynamicService {
private PlatBedService platBedService;
@Autowired
private PlatElderService platElderService;
@Autowired
private PlatRoomBedDeviceService platRoomBedDeviceService;
@Override
......@@ -107,19 +105,11 @@ public class PlatRoomDynamicServiceImpl implements PlatRoomDynamicService {
}else if(PlatBedPanoramaSpaceType.BedPanoramaSpaceType.ROOM.getValue().equals(dto.getType())){
list = platBedService.selectByRoomIdAndStatus(dto);
}
List<PlatSpace> spaces = platSpaceService.list();
Map<String,String> spaceNameMap = spaces.stream().collect(Collectors.toMap(PlatSpace::getId,PlatSpace::getName));
JoinUtil.joinSplit(list, platSpaceService, PlatBedPanoramaVO::getSpacePath, PlatSpace::getId, (e, l) -> {
e.setSpacePathName(StreamUtil.join(l, Objects::nonNull, PlatSpace::getName, "-"));
});
list.forEach(vo->{
String spacePathName = "";
if(StringUtil.isNotEmpty(vo.getSpacePath())){
List<String> spaceIds = Arrays.asList(vo.getSpacePath().split(","));
for(String spaceId : spaceIds){
if(spaceNameMap.get(spaceId)!=null && StringUtil.isNotEmpty(spaceNameMap.get(spaceId))){
spacePathName = "".equals(spacePathName) ? spaceNameMap.get(spaceId) : spacePathName + "-" + spaceNameMap.get(spaceId);
}
}
}
String spacePathName = vo.getSpacePathName();
if(StringUtil.isNotEmpty(vo.getRoomName())){
spacePathName = "".equals(spacePathName) ? vo.getRoomName() : spacePathName + "-" + vo.getRoomName();
}
......@@ -171,10 +161,23 @@ public class PlatRoomDynamicServiceImpl implements PlatRoomDynamicService {
}
@Override
public List<PlatElder> elderList(PlatElderQueryDTO dto) {
public List<PlatDeviceElderVO> elderList(PlatElderQueryDTO dto) {
List<PlatElder> list = platElderService.list(new QueryWrapper<PlatElder>().lambda()
.eq(PlatElder::getRoomId, dto.getRoomId()));
return list;
List<String> bedIds = list.stream().map(PlatElder::getBedId).collect(Collectors.toList());
List<PlatDeviceElderVO> voList = BeanDtoVoUtils.listVo(list, PlatDeviceElderVO.class);
if(bedIds.isEmpty()){
List<PlatRoomBedDevice> roomBedDevices = platRoomBedDeviceService.list(new QueryWrapper<PlatRoomBedDevice>()
.lambda()
.in(PlatRoomBedDevice::getBedId, bedIds));
Map<String, String> map = roomBedDevices.stream().collect(Collectors.toMap(PlatRoomBedDevice::getBedId, PlatRoomBedDevice::getDeviceId));
voList.forEach(t->{
if(map.containsKey(t.getBedId())){
t.setDeviceId(map.get(t.getBedId()));
}
});
}
return voList;
}
private PlatSpaceAndRoomVO child(PlatSpaceAndRoomVO vo,Map<String,List<PlatSpaceAndRoomVO>> map){
......
......@@ -20,7 +20,10 @@ import com.makeit.service.platform.space.PlatBedService;
import com.makeit.service.platform.space.PlatRoomService;
import com.makeit.service.platform.space.PlatSpaceService;
import com.makeit.service.platform.workstation.WorkStationService;
import com.makeit.utils.data.convert.StreamUtil;
import com.makeit.utils.sql.join.JoinUtil;
import com.makeit.vo.platform.elder.realtime.PlatElderRealTimeNowVO;
import com.makeit.vo.platform.space.PlatBedPanoramaVO;
import com.makeit.vo.platform.workstation.*;
import jodd.util.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -135,7 +138,6 @@ public class WorkStationServiceImpl implements WorkStationService {
//获取父级的所有子级空间
spaces = platSpaceService.listChild(dto.getSpaceIds());
}
Map<String, String> platSpaceMap = spaces.stream().collect(Collectors.toMap(PlatSpace::getId, PlatSpace::getName));
List<String> elderIdList = new ArrayList<>();
List<PlatAlarmRecord> alarmRecords = platAlarmRecordService.list(
......@@ -165,17 +167,14 @@ public class WorkStationServiceImpl implements WorkStationService {
List<WorkStationInstitutionBedVO> bedVos = platBedService.selectByRoomIds(roomIds);
Map<String, List<WorkStationInstitutionBedVO>> bedMap = bedVos.stream().collect(Collectors.groupingBy(WorkStationInstitutionBedVO::getRoomId));
JoinUtil.joinSplit(roomVOList, platSpaceService, WorkStationInstitutionRoomVO::getSpacePath, PlatSpace::getId, (e, l) -> {
e.setPathName(StreamUtil.join(l, Objects::nonNull, PlatSpace::getName, "-"));
});
for (WorkStationInstitutionRoomVO roomVo : roomVOList) {
WorkStationInstitutionRoomVO vo = new WorkStationInstitutionRoomVO();
String pathName = "";
for (String spaceId : Arrays.asList(roomVo.getSpacePath().split(","))) {
if (platSpaceMap.get(spaceId) != null) {
pathName = "".equals(pathName) ? platSpaceMap.get(spaceId) : pathName + "-" + platSpaceMap.get(spaceId);
}
}
pathName = pathName + "-" + roomVo.getRoomName();
vo.setRoomId(roomVo.getRoomId());
vo.setPathName(pathName);
vo.setPathName(vo.getPathName() + "-" + vo.getRoomName());
if (bedMap.get(roomVo.getRoomId()) != null) {
List<WorkStationInstitutionBedVO> roomBedVos = bedMap.get(roomVo.getRoomId());
//获取告警类型及老人状态
......@@ -308,7 +307,6 @@ public class WorkStationServiceImpl implements WorkStationService {
//获取父级的所有子级空间
spaces = platSpaceService.listChild(dto.getSpaceIds());
}
Map<String, String> platSpaceMap = spaces.stream().collect(Collectors.toMap(PlatSpace::getId, PlatSpace::getName));
List<String> elderIdList = new ArrayList<>();
List<PlatAlarmRecord> alarmRecords = platAlarmRecordService.list(
......@@ -333,15 +331,12 @@ public class WorkStationServiceImpl implements WorkStationService {
List<WorkStationHomeBedVO> list = platBedService.selectByCondition(dto);
JoinUtil.joinSplit(list, platSpaceService, WorkStationHomeBedVO::getSpacePath, PlatSpace::getId, (e, l) -> {
e.setPathName(StreamUtil.join(l, Objects::nonNull, PlatSpace::getName, "-"));
});
for(WorkStationHomeBedVO vo : list){
String pathName = "";
for (String spaceId : Arrays.asList(vo.getSpacePath().split(","))) {
if (platSpaceMap.get(spaceId) != null) {
pathName = "".equals(pathName) ? platSpaceMap.get(spaceId) : pathName + "-" + platSpaceMap.get(spaceId);
}
}
pathName = pathName + "-" + vo.getRoomName();
vo.setPathName(pathName);
vo.setPathName(vo.getPathName() + "-" + vo.getRoomName());
if (StringUtil.isNotEmpty(vo.getElderId()) ) {
if(elderAlarmTypeMap.containsKey(vo.getElderId())){
vo.setAlarmTypeMap(elderAlarmTypeMap.get(vo.getElderId()));
......
package com.makeit.vo.platform.space;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* Controller
*
* @author zm
* @version 2023/9/8
*/
@Data
@ApiModel("PlatDeviceElderVO参数")
public class PlatDeviceElderVO {
@ApiModelProperty("长者id")
private String id;
@ApiModelProperty("长者姓名")
private String name;
@ApiModelProperty("设备id")
private String deviceId;
@ApiModelProperty("床位id")
private String bedId;
}
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