Commit 34c46add by 杨伟程
parents 52c33f5e 46e3276e
......@@ -57,6 +57,13 @@ public class PlatRoomBedDeviceController {
return ApiResponseUtils.success(data);
}
@ApiOperation("已绑定设备分页")
@PostMapping("pageBindDevice")
public ApiResponseEntity<PageVO<PlatDeviceDTO>> pageBindDevice(@RequestBody PageReqDTO<PlatBedDeviceQueryDTO> page) {
PageVO<PlatDeviceDTO> data = platRoomBedDeviceService.pageBindDevice(page);
return ApiResponseUtils.success(data);
}
@ApiOperation("绑定设备")
@PostMapping("bindingDevice")
public ApiResponseEntity<?> bindingDevice(@RequestBody PlatRoomBindDeviceDTO dto) {
......
......@@ -5,6 +5,7 @@ import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @Author:lzy
* @Date:2023/9/18 11:38
......@@ -41,7 +42,7 @@ public class PlatSpaceImportDTO {
@ExcelProperty({BIG_TITLE, "床位数量"})
@ApiModelProperty(value = "床位数量")
private Integer bedNumber;
private String bedNumber;
......
......@@ -18,6 +18,7 @@ import com.makeit.service.platform.alarm.PlatDayDurationRecordService;
import com.makeit.utils.AlarmConfigCacheUtil;
import com.makeit.utils.AlarmRedisDTO;
import com.makeit.utils.DayDurationUtil;
import com.makeit.utils.data.convert.BeanDtoVoUtils;
import com.makeit.utils.data.convert.JsonUtil;
import com.makeit.utils.redis.RedisUtil;
import lombok.extern.slf4j.Slf4j;
......@@ -162,7 +163,9 @@ public class FallAlarm implements IAlarm {
return;
}
//保存每次进入空间时长
platDayDurationRecordService.saveDayDurationRecord(platAlarmCheckDTO, alarmRedisDTO);
PlatAlarmCheckDTO platAlarmCheckDTO_behavior = BeanDtoVoUtils.convert(platAlarmCheckDTO, PlatAlarmCheckDTO.class);
platAlarmCheckDTO_behavior.setPlatAlarmConfig(config);
platDayDurationRecordService.saveDayDurationRecord(platAlarmCheckDTO_behavior, alarmRedisDTO);
RedisUtil.delete(RedisConst.ALARM_DEVICE_BEHAVIOR_ID + deviceId);
}
}
......
......@@ -62,10 +62,10 @@ implements PlatDayDurationRecordService {
}
List<PlatElder> platElderList = platAlarmCheckDTO.getPlatElderList();
if(CollectionUtils.isNotEmpty(platElderList)){
platAlarmRecordService.getElderListByDeviceId(platAlarmCheckDTO);
platElderList = platAlarmCheckDTO.getPlatElderList();
}
// if(CollectionUtils.isNotEmpty(platElderList)){
// platAlarmRecordService.getElderListByDeviceId(platAlarmCheckDTO);
// platElderList = platAlarmCheckDTO.getPlatElderList();
// }
for (PlatElder platElder : platElderList) {
if(StringUtils.isBlank(platElder.getRegionName())){
continue;
......
......@@ -47,6 +47,8 @@ import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.function.Function;
......@@ -300,6 +302,12 @@ public class DataScreenServiceImpl implements DataScreenService {
@Override
public List<PlatMapStatisticsVO> mapStatistics(PlatDataScreenQueryDTO dto) {
if(dto.getStartTime() == null){
dto.setStartTime(LocalDateTime.of(LocalDateTime.now().toLocalDate(), LocalTime.MIN));
}
if(dto.getEndTime() == null){
dto.setEndTime(LocalDateTime.of(LocalDateTime.now().toLocalDate(), LocalTime.MAX));
}
List<PlatMapStatisticsVO> list = new ArrayList<>();
if(dto.getOrgIds().isEmpty()){
//获取该账号的权限组织
......@@ -542,7 +550,12 @@ public class DataScreenServiceImpl implements DataScreenService {
if (elderIds.size() > 0) {
if (platElderMap.get(elderIds.get(0)) != null) {
PlatAlarmRecordStatisticsVo statisticsVo = BeanDtoVoUtils.convert(record, PlatAlarmRecordStatisticsVo.class);
statisticsVo.setSpaceId(platElderMap.get(elderIds.get(0)).getSpaceId());
if(StringUtil.isNotEmpty(platElderMap.get(elderIds.get(0)).getSpacePath())){
String spacePath = platElderMap.get(elderIds.get(0)).getSpacePath();
String spaceId = Arrays.asList(spacePath.split(",")).get(0);
statisticsVo.setSpaceId(spaceId);
}
statisticsVos.add(statisticsVo);
}
}
......
......@@ -10,6 +10,7 @@ import com.makeit.enums.platform.elder.PlatElderRealtimeReportEnum;
import com.makeit.module.iot.enums.DeviceInfoContentBreatheEnum;
import com.makeit.module.iot.enums.DeviceInfoContentFallEnum;
import com.makeit.module.iot.enums.DeviceInfoContentSpaceEnum;
import com.makeit.module.iot.enums.DeviceState;
import com.makeit.module.iot.service.IotProductDeviceService;
import com.makeit.module.iot.vo.breathe.DeviceInfoContentBreathe;
import com.makeit.module.iot.vo.fall.DeviceInfoContentFall;
......@@ -131,6 +132,9 @@ public class PlatElderRealTimeServiceImpl implements PlatElderRealTimeService {
if (platDevice == null) {
return null;
}
if (!platDevice.getStatus().equals(DeviceState.online.getValue())) {
return null;
}
DeviceInfoContentBreathe deviceInfoContentBreathe = iotProductDeviceService.getLastDeviceLogBreathe(platDevice.getOriDeviceId(), 10);
......@@ -341,10 +345,19 @@ public class PlatElderRealTimeServiceImpl implements PlatElderRealTimeService {
platElderRealTimeHeartRespiratoryVO.setHeartRate(heartRate);
platElderRealTimeHeartRespiratoryVO.setRespiratoryRate(respiratoryRate);
} else {
int hrRange = RandomUtils.nextInt(1, 11) - 5;
int brRange = RandomUtils.nextInt(1, 7) - 3;
platElderRealTimeHeartRespiratoryVO.setHeartRate(heartRate + hrRange);
platElderRealTimeHeartRespiratoryVO.setRespiratoryRate(respiratoryRate + brRange);
if (heartRate == 0) {
platElderRealTimeHeartRespiratoryVO.setHeartRate(0);
} else {
int hrRange = RandomUtils.nextInt(1, 11) - 5;
platElderRealTimeHeartRespiratoryVO.setHeartRate(Math.max(heartRate + hrRange,0));
}
if (respiratoryRate == 0) {
platElderRealTimeHeartRespiratoryVO.setRespiratoryRate(0);
} else {
int brRange = RandomUtils.nextInt(1, 7) - 3;
platElderRealTimeHeartRespiratoryVO.setRespiratoryRate(Math.max(respiratoryRate + brRange,0));
}
}
redisTemplate.opsForList().leftPush(ELDER_BR_HR + platElderIdDTO.getElderId(),JSON.toJSONString(platElderRealTimeHeartRespiratoryVO));
}
......@@ -380,8 +393,13 @@ public class PlatElderRealTimeServiceImpl implements PlatElderRealTimeService {
if (i ==0) {
platElderRealTimeBodyVO.setBodyMovementIndex(body);
} else {
int hrRange = RandomUtils.nextInt(1, 11) - 5;
platElderRealTimeBodyVO.setBodyMovementIndex(Math.max(body + hrRange,0));
if (body == 0) {
platElderRealTimeBodyVO.setBodyMovementIndex(0);
} else {
int hrRange = RandomUtils.nextInt(1, 11) - 5;
platElderRealTimeBodyVO.setBodyMovementIndex(Math.max(body + hrRange,0));
}
}
redisTemplate.opsForList().leftPush(ELDER_MOVE + platElderIdDTO.getElderId(),JSON.toJSONString(platElderRealTimeBodyVO));
}
......@@ -433,49 +451,47 @@ public class PlatElderRealTimeServiceImpl implements PlatElderRealTimeService {
List<PlatDevice> deviceListFall = getFallDevice(platElderIdDTO.getElderId(), platElderIdDTO.getDeviceId());
if (CollectionUtils.isEmpty(deviceListSpace) && CollectionUtils.isNotEmpty(deviceListFall)) {
return voList;
}
deviceListSpace.forEach(e -> {
DeviceInfoContentSpace i = iotProductDeviceService.getLastDeviceLogSpace(e.getOriDeviceId(), 10);
if (i == null) {
return;
}
if (CollectionUtils.isNotEmpty(deviceListSpace)) {
deviceListSpace.forEach(e -> {
DeviceInfoContentSpace i = iotProductDeviceService.getLastDeviceLogSpace(e.getOriDeviceId(), 10);
if (i == null) {
return;
}
PlatElderCoordinateVO vo = new PlatElderCoordinateVO();
PlatElderCoordinateVO vo = new PlatElderCoordinateVO();
vo.setDeviceId(e.getId());
vo.setOriDeviceId(e.getOriDeviceId());
vo.setDeviceId(e.getId());
vo.setOriDeviceId(e.getOriDeviceId());
// vo.setX(new BigDecimal(i.getProperties().getDistance()).multiply(new BigDecimal(Math.cos(i.getProperties().getAngle()) + "")).setScale(2, RoundingMode.HALF_UP));
// vo.setY(new BigDecimal(i.getProperties().getDistance()).multiply(new BigDecimal(Math.sin(i.getProperties().getAngle()) + "")).setScale(2, RoundingMode.HALF_UP));
vo.setDistance(i.getProperties().getDistance());
vo.setAngle(i.getProperties().getAngle());
voList.add(vo);
});
vo.setDistance(i.getProperties().getDistance());
vo.setAngle(i.getProperties().getAngle());
deviceListFall.forEach(e -> {
DeviceInfoContentFall i = iotProductDeviceService.getLastDeviceLogFall(e.getOriDeviceId(), 10);
if (i == null) {
return;
}
voList.add(vo);
PlatElderCoordinateVO vo = new PlatElderCoordinateVO();
});
}
vo.setDeviceId(e.getId());
vo.setOriDeviceId(e.getOriDeviceId());
if (CollectionUtils.isNotEmpty(deviceListFall)) {
deviceListFall.forEach(e -> {
DeviceInfoContentFall i = iotProductDeviceService.getLastDeviceLogFall(e.getOriDeviceId(), 10);
if (i == null) {
return;
}
vo.setTrack(i.getProperties().getTrack());
PlatElderCoordinateVO vo = new PlatElderCoordinateVO();
voList.add(vo);
vo.setDeviceId(e.getId());
vo.setOriDeviceId(e.getOriDeviceId());
});
vo.setTrack(i.getProperties().getTrack());
voList.add(vo);
});
}
return voList;
}
......
......@@ -892,6 +892,9 @@ public class PlatElderServiceImpl extends ServiceImpl<PlatElderMapper, PlatElder
public List<PlatDevice> getSpaceDevice(String id) {
PlatElder platElder = getById(id);
if (platElder == null) {
return null;
}
if (StringUtils.isBlank(platElder.getBedId())) {
return null;
}
......
......@@ -55,4 +55,6 @@ public interface PlatRoomBedDeviceService extends IService<PlatRoomBedDevice> {
List<PlatDevice> getSpaceDevice(String bedId);
List<PlatDevice> getFallDevice(String bedId);
PageVO<PlatDeviceDTO> pageBindDevice(PageReqDTO<PlatBedDeviceQueryDTO> page);
}
......@@ -256,4 +256,46 @@ public class PlatRoomBedDeviceServiceImpl extends ServiceImpl<PlatRoomBedDeviceM
public List<PlatDevice> getFallDevice(String bedId) {
return getDeviceInternal(bedId, PlatDeviceEnum.CategoryEnum.FALL.getValue());
}
@Override
public PageVO<PlatDeviceDTO> pageBindDevice(PageReqDTO<PlatBedDeviceQueryDTO> pageReqDTO) {
PlatBedDeviceQueryDTO dto = pageReqDTO.getData();
Page<PlatDevice> p = PageUtil.toMpPage(pageReqDTO);
LambdaQueryWrapper<PlatRoomBedDevice> queryWrapper1 = new LambdaQueryWrapper<>();
queryWrapper1.eq(PlatRoomBedDevice::getRoomId, dto.getRoomId());
queryWrapper1.eq(StringUtil.isNotEmpty(dto.getBedId()), PlatRoomBedDevice::getBedId, dto.getBedId());
List<PlatRoomBedDevice> list = list(queryWrapper1);
List<String> listEquipmentIds = list.stream().map(item -> item.getDeviceId()).collect(Collectors.toList());
List<String> listBedIds = list.stream().map(item -> item.getBedId()).collect(Collectors.toList());
LambdaQueryWrapper<PlatBed> queryWrapper2 = new LambdaQueryWrapper<>();
queryWrapper2.in(PlatBed::getId, listBedIds);
List<PlatBed> listBeds = platBedService.list(queryWrapper2);
Map<String, String> map = listBeds.stream().collect(Collectors.toMap(PlatBed::getId, PlatBed::getName, (k1, k2) -> k1));
Map<String, String> mapName = new HashMap<>(20);
Map<String, String> mapBedId = new HashMap<>(20);
list.forEach(item -> {
if (map.containsKey(item.getBedId())) {
mapName.put(item.getDeviceId(), map.get(item.getBedId()));
mapBedId.put(item.getDeviceId(), item.getBedId());
}
});
if (!listEquipmentIds.isEmpty()) {
LambdaQueryWrapper<PlatDevice> queryWrapper = new LambdaQueryWrapper<>();
//queryWrapper.eq(PlatDevice::getCategory, PlatDeviceEnum.CategoryEnum.HEART);
queryWrapper.in(PlatDevice::getId, listEquipmentIds);
Page<PlatDevice> pages = platDeviceService.page(p, queryWrapper);
List<PlatDeviceDTO> data = BeanDtoVoUtils.listVo(pages.getRecords(), PlatDeviceDTO.class);
data.forEach(item -> {
item.setBedName(mapName.get(item.getId()));
item.setBedId(mapBedId.get(item.getId()));
});
return PageUtil.toPageVO(data, pages);
}else {
return new PageVO<>();
}
}
}
......@@ -39,6 +39,8 @@ import org.springframework.web.multipart.MultipartFile;
import java.util.*;
import java.util.function.BiConsumer;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
/**
......@@ -413,6 +415,7 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
Integer errorCount = 0;
Integer successCount = 0;
boolean errorFlag = false;
Pattern pattern = Pattern.compile("^\\d+$");
for (int i = 0; i < list.size(); i++) {
PlatSpaceImportDTO item = list.get(i);
......@@ -449,6 +452,17 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
}
listKey.add(key+"-"+item.getRoomName());
if(StringUtil.isNotEmpty(item.getBedNumber())){
Matcher matcher = pattern.matcher(item.getBedNumber());
// 进行匹配
if(!matcher.find()){
errorVoList.add(new ExcelErrorVo(i + 3, excelField.get(4), "床位数量格式错误"));
}
}
if (errorFlag) {
errorCount++;
} else {
......@@ -526,7 +540,7 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
String threeKey = secondId + "-" + item.getUnit();
if (!childrenIdMap.containsKey(threeKey)) {
PlatSpace platSpace = new PlatSpace();
platSpace.setName(item.getBuilding());
platSpace.setName(item.getUnit());
platSpace.setType(PlatSpaceEnum.TypeEnum.UNIT.getValue());
platSpace.setOrgId(orgId);
platSpace.setParentId(secondId);
......@@ -555,7 +569,7 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
String fourKey = threeId + "-" + item.getFloor();
if (!childrenIdMap.containsKey(fourKey)) {
PlatSpace platSpace = new PlatSpace();
platSpace.setName(item.getBuilding());
platSpace.setName(item.getFloor());
platSpace.setType(PlatSpaceEnum.TypeEnum.FLOOR.getValue());
platSpace.setOrgId(orgId);
platSpace.setParentId(threeId);
......@@ -572,8 +586,8 @@ public class PlatSpaceServiceImpl extends ServiceImpl<PlatSpaceMapper, PlatSpace
//房间
PlatRoomDTO platRoomDTO = new PlatRoomDTO();
platRoomDTO.setName(item.getRoomName());
if(item.getBedNumber()!=null){
platRoomDTO.setBedNumber(item.getBedNumber());
if(StringUtil.isNotEmpty(item.getBedNumber())){
platRoomDTO.setBedNumber(Integer.valueOf(item.getBedNumber()));
}else {
platRoomDTO.setBedNumber(0);
}
......
......@@ -561,7 +561,7 @@ public class WorkStationServiceImpl implements WorkStationService {
}
List<String> orgIds = orgs.stream().map(PlatOrg::getId).collect(Collectors.toList());
if(!dto.getOrgIds().isEmpty()){
if(dto.getOrgIds()!=null && !dto.getOrgIds().isEmpty()){
orgIds = dto.getOrgIds();
}
......
......@@ -14,6 +14,7 @@ import com.makeit.module.iot.vo.DeviceState;
import com.makeit.module.system.service.SysDictionaryCategoryService;
import com.makeit.module.system.vo.DictionaryVo;
import com.makeit.service.platform.device.PlatDeviceService;
import com.makeit.service.platform.elder.PlatElderDayReportDayService;
import com.makeit.service.platform.elder.PlatElderSleepService;
import com.makeit.service.saas.PlatTenantService;
import com.makeit.utils.DeviceCacheUtil;
......@@ -47,13 +48,15 @@ public class IotSyncTask {
private DeviceCacheUtil deviceCacheUtil;
@Autowired
private PlatElderSleepService platElderSleepService;
@Autowired
private PlatElderDayReportDayService platElderDayReportDayService;
/**
* 一小时同步一次
* 启用状态的租户才同步
* 新增和更新平台端设备表
*/
@Scheduled(cron = "0 0 */1 * * ?")
@Scheduled(cron = "0 0/10 * * * *")
public void syncEquipmentInfo() {
savePlatDevice();
}
......@@ -158,4 +161,13 @@ public class IotSyncTask {
log.info("定时分析长者睡眠质量结束");
}
/* @Scheduled(cron = "0 0 1 * * ?")
@TenantIdIgnore
public void elderCoordinateListAnalysisTask() {
log.info("开始定时分析24小时热力图");
platElderDayReportDayService.elderCoordinateListAnalysisTask();
log.info("定时分析长者24小时热力图");
}*/
}
......@@ -29,4 +29,7 @@ public class PlatBedVo extends BaseBusEntity {
@ApiModelProperty(value = "绑定设备")
private String deviceName;
@ApiModelProperty(value = "绑定设备id")
private String deviceId;
}
......@@ -117,7 +117,8 @@
pb.update_by as updateBy,
pb.update_date as updateDate,
pb.sort as sort,
d.name as deviceName
d.name as deviceName,
d.id as deviceId
from plat_bed pb
left join plat_room_bed_device prbd on prbd.bed_id = pb.id and prbd.del_flag = 0
left join plat_device d on d.id = prbd.device_id and d.del_flag = 0
......
......@@ -14,7 +14,7 @@
</foreach>
</if>
</where>
UNION
UNION ALL
SELECT pr.id,pr.`name`,pr.space_id as parentId,'2' as type FROM plat_room pr
LEFT JOIN plat_space p ON p.id = pr.space_id
<where>
......
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