Commit 6400bdf8 by 杨伟程

长者实时报告

parent 11d07b81
Showing with 637 additions and 64 deletions
......@@ -29,6 +29,9 @@ VALUES ('203', 'alarm.notifyWay', '告警配置通知对象', '2022-05-16 17:08:
INSERT INTO sys_dictionary_category (id, code, name, create_date, update_date, del_flag)
VALUES ('300', 'device.status', '设备状态', '2022-05-16 17:08:33', '2022-05-16 17:08:37', '0');
INSERT INTO sys_dictionary_category (id, code, name, create_date, update_date, del_flag)
VALUES ('1000', 'device.breathe.personState', '呼吸心率运动状态', '2022-05-16 17:08:33', '2022-05-16 17:08:37', '0');
INSERT INTO sys_dictionary (id, code, name, value, sort, description, category_id, create_date, update_date, del_flag)
VALUES ('1', 'common.status.yes', '是', '1', 1, '', '2', '2022-05-16 17:13:23', '2022-05-16 17:13:27', '0');
......@@ -109,6 +112,18 @@ VALUES ('300', 'device.status.online', '在线', '1', 1, '', '300', '2022-05-16
INSERT INTO sys_dictionary (id, code, name, value, sort, description, category_id, create_date, update_date, del_flag)
VALUES ('400', 'device.status.offline', '离线', '0', 0, '', '300', '2022-05-16 17:13:23', '2022-05-16 17:13:27', '0');
INSERT INTO sys_dictionary (id, code, name, value, sort, description, category_id, create_date, update_date, del_flag)
VALUES ('1000', 'device.breathe.personState.nobody', '无人', '0', 0, '', '1000', '2022-05-16 17:13:23', '2022-05-16 17:13:27', '0');
INSERT INTO sys_dictionary (id, code, name, value, sort, description, category_id, create_date, update_date, del_flag)
VALUES ('1001', 'device.breathe.personState.exercise', '运动', '1', 1, '', '1000', '2022-05-16 17:13:23', '2022-05-16 17:13:27', '0');
INSERT INTO sys_dictionary (id, code, name, value, sort, description, category_id, create_date, update_date, del_flag)
VALUES ('1002', 'device.breathe.personState.breathe', '呼吸', '2', 2, '', '1000', '2022-05-16 17:13:23', '2022-05-16 17:13:27', '0');
INSERT INTO sys_dictionary (id, code, name, value, sort, description, category_id, create_date, update_date, del_flag)
VALUES ('1003', 'device.breathe.personState.enter', '进入呼吸', '3', 3, '', '1000', '2022-05-16 17:13:23', '2022-05-16 17:13:27', '0');
INSERT INTO sys_config_category (id, tenant_id, code, name, create_date, update_date, del_flag, create_by, update_by, eng_name) VALUES ('1', '0', 'elder.certificateType', '长者证件类型', '2023-07-11 10:55:06', '2023-07-11 10:55:08', '0', null, null, null);
INSERT INTO sys_config_category (id, tenant_id, code, name, create_date, update_date, del_flag, create_by, update_by, eng_name) VALUES ('2', '0', 'elder.blood', '长者血型', '2023-07-11 10:55:06', '2023-07-11 10:55:08', '0', null, null, null);
......
package com.makeit.module.iot.enums;
import com.makeit.enums.BaseEnum;
import com.makeit.utils.sys.SysDictUtil;
public class DeviceInfoContentBreatheEnum {
public enum PersonStateEnum implements BaseEnum {
NOBODY("device.breathe.personState.nobody"),//0
EXERCISE("device.breathe.personState.exercise"),//1
BREATHE("device.breathe.personState.breathe"),//2
ENTER("device.breathe.personState.enter");//3
private String code;
PersonStateEnum(String code) {
this.code = code;
}
public String getValue() {
return SysDictUtil.getValue(code);
}
}
}
......@@ -10,6 +10,8 @@ import com.makeit.module.iot.vo.DeviceInstanceEntity;
import com.makeit.module.iot.vo.DeviceOperationLogEntity;
import com.makeit.module.iot.vo.IotPagerResult;
import com.makeit.module.iot.vo.ResponseMessage;
import com.makeit.module.iot.vo.breathe.DeviceInfoContentBreathe;
import com.makeit.module.iot.vo.breathe.DeviceInfoContentSpace;
import com.makeit.utils.data.convert.JsonUtil;
import com.makeit.utils.old.StringUtils;
import lombok.extern.slf4j.Slf4j;
......@@ -17,6 +19,10 @@ import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Component;
import java.io.IOException;
import java.time.Duration;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.List;
/**
......@@ -57,6 +63,7 @@ public class IotProductDeviceService extends IotCommonService {
/**
* 获取最新一条设备日志
*
* @param deviceId
* @return
*/
......@@ -68,19 +75,54 @@ public class IotProductDeviceService extends IotCommonService {
/**
* 获取最新的一条设备属性上报的数据
*
* @param deviceId
* @param typeValue 类型
*
* <p>
* 可以传 :reportProperty
* @return
*/
public DeviceOperationLogEntity getLastDeviceLogByType(String deviceId,String typeValue) {
public DeviceOperationLogEntity getLastDeviceLogByType(String deviceId, String typeValue) {
List<DeviceOperationLogEntity> deviceOperationLogEntities = getDeviceLog(deviceId, 1, typeValue);
return CollectionUtils.isNotEmpty(deviceOperationLogEntities) ? deviceOperationLogEntities.get(0) : null;
}
public DeviceInfoContentBreathe getLastDeviceLogBreathe(String deviceId, Integer ignoreDuration) {//秒
DeviceOperationLogEntity deviceOperationLogEntity = getLastDeviceLogByType(deviceId, "reportProperty");
if (deviceOperationLogEntity == null) {
return null;
}
DeviceInfoContentBreathe breathe = JsonUtil.toObj((String) deviceOperationLogEntity.getContent(), DeviceInfoContentBreathe.class);
LocalDateTime time = LocalDateTime.ofInstant(Instant.ofEpochMilli(breathe.getTimestamp()), ZoneId.systemDefault());
if (ignoreDuration != null && Duration.between(time, LocalDateTime.now()).getSeconds() > ignoreDuration) {
return null;
}
return breathe;
}
public DeviceInfoContentSpace getLastDeviceLogSpace(String deviceId, Integer ignoreDuration) {//秒
DeviceOperationLogEntity deviceOperationLogEntity = getLastDeviceLogByType(deviceId, "reportProperty");
if (deviceOperationLogEntity == null) {
return null;
}
DeviceInfoContentSpace space = JsonUtil.toObj((String) deviceOperationLogEntity.getContent(), DeviceInfoContentSpace.class);
LocalDateTime time = LocalDateTime.ofInstant(Instant.ofEpochMilli(space.getTimestamp()), ZoneId.systemDefault());
if (ignoreDuration != null && Duration.between(time, LocalDateTime.now()).getSeconds() > ignoreDuration) {
return null;
}
return space;
}
/**
*
* 根据类型查询设备日志
* text: "事件上报", value: "event"}
* {text: "读取属性", value: "readProperty"}
......@@ -124,8 +166,8 @@ public class IotProductDeviceService extends IotCommonService {
* @param typeValue
* @return
*/
public List<DeviceOperationLogEntity> getDeviceLogByType(String deviceId,String typeValue) {
return getDeviceLog(deviceId, 10,typeValue);
public List<DeviceOperationLogEntity> getDeviceLogByType(String deviceId, String typeValue) {
return getDeviceLog(deviceId, 10, typeValue);
}
/**
......@@ -170,7 +212,4 @@ public class IotProductDeviceService extends IotCommonService {
}
}
package com.makeit.module.iot.vo.breathe;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
@NoArgsConstructor
@Data
public class DeviceInfoContentBreathe {
@JsonProperty("headers")
private Headers headers;
@JsonProperty("messageType")
private String messageType;
@JsonProperty("deviceId")
private String deviceId;
@JsonProperty("properties")
private Properties properties;
@JsonProperty("timestamp")
private Long timestamp;
@NoArgsConstructor
@Data
public static class Headers {
@JsonProperty("bindings")
private List<Bindings> bindings;
@JsonProperty("deviceName")
private String deviceName;
@JsonProperty("productName")
private String productName;
@JsonProperty("productId")
private String productId;
@JsonProperty("_uid")
private String uid;
@JsonProperty("creatorId")
private String creatorId;
@JsonProperty("traceparent")
private String traceparent;
@NoArgsConstructor
@Data
public static class Bindings {
@JsonProperty("id")
private String id;
@JsonProperty("type")
private String type;
}
}
@NoArgsConstructor
@Data
public static class Properties {
@JsonProperty("br")
private Integer br;
@JsonProperty("distance")
private Integer distance;
@JsonProperty("bodymove")
private Integer bodymove;
@JsonProperty("personState")
private Integer personState;
@JsonProperty("person")
private Integer person;
@JsonProperty("hr")
private Integer hr;
@JsonProperty("point")
private List<Integer> point;
}
}
package com.makeit.module.iot.vo.breathe;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import lombok.NoArgsConstructor;
@NoArgsConstructor
@Data
public class DeviceInfoContentSpace {
@JsonProperty("headers")
private DeviceInfoContentBreathe.Headers headers;
@JsonProperty("messageType")
private String messageType;
@JsonProperty("deviceId")
private String deviceId;
@JsonProperty("properties")
private Properties properties;
@JsonProperty("timestamp")
private Long timestamp;
@NoArgsConstructor
@Data
public static class Properties {
@JsonProperty("mode")
private Integer mode;
@JsonProperty("distance")
private Integer distance;
@JsonProperty("personState")
private Integer personState;
@JsonProperty("angle")
private Integer angle;
@JsonProperty("mount")
private Integer mount;
}
}
package com.makeit.module.iot.vo.breathe;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import lombok.NoArgsConstructor;
@NoArgsConstructor
@Data
public class Test1 {
@JsonProperty("id")
private String id;
@JsonProperty("deviceId")
private String deviceId;
@JsonProperty("productId")
private Object productId;
@JsonProperty("type")
private String type;
@JsonProperty("createTime")
private Long createTime;
@JsonProperty("content")
private String content;
@JsonProperty("messageId")
private Object messageId;
@JsonProperty("orgId")
private Object orgId;
@JsonProperty("timestamp")
private Long timestamp;
}
//TODO ywc
//DeviceOperationLogEntity ==> DeviceInfo
\ No newline at end of file
......@@ -2,17 +2,23 @@ package com.makeit.module.controller.elder;
import com.makeit.common.response.ApiResponseEntity;
import com.makeit.common.response.ApiResponseUtils;
import com.makeit.dto.platform.elder.PlatElderIdDTO;
import com.makeit.service.platform.elder.PlatElderRealTimeService;
import com.makeit.vo.platform.elder.realtime.PlatElderCoordinateVO;
import com.makeit.vo.platform.elder.realtime.PlatElderRealTimeBodyVO;
import com.makeit.vo.platform.elder.realtime.PlatElderRealTimeHeartRespiratoryVO;
import com.makeit.vo.platform.elder.realtime.PlatElderRealTimeNowVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
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.RestController;
import java.util.List;
/**
* <p>
* 长者基本信息 前端控制器
......@@ -26,24 +32,34 @@ import org.springframework.web.bind.annotation.RestController;
@RequestMapping("/plat/elder/realTime")
public class PlatElderRealTimeController {
@Autowired
private PlatElderRealTimeService platElderRealTimeService;
@ApiOperation("现在状态")
@PostMapping("nowStatus")
public ApiResponseEntity<PlatElderRealTimeNowVO> nowStatus(@RequestBody PlatElderIdDTO platElderIdDTO) {
return null;
return ApiResponseUtils.success(platElderRealTimeService.nowStatus(platElderIdDTO));
}
@ApiOperation("心率呼吸率")
@PostMapping("heartRespiratory")
public ApiResponseEntity<PlatElderRealTimeHeartRespiratoryVO> heartRespiratory(@RequestBody PlatElderIdDTO platElderIdDTO) {
return null;
return ApiResponseUtils.success(platElderRealTimeService.heartRespiratory(platElderIdDTO));
}
@ApiOperation("体动")
@PostMapping("body")
public ApiResponseEntity<PlatElderRealTimeBodyVO> body(@RequestBody PlatElderIdDTO platElderIdDTO) {
return null;
return ApiResponseUtils.success(platElderRealTimeService.body(platElderIdDTO));
}
@ApiOperation("坐标")
@PostMapping("coordinate")
public ApiResponseEntity<List<PlatElderCoordinateVO>> coordinate(@RequestBody PlatElderIdDTO platElderIdDTO) {
return ApiResponseUtils.success(platElderRealTimeService.coordinate(platElderIdDTO));
}
//TODO ywc 少一个坐标
}
......
......@@ -3,6 +3,7 @@ package com.makeit.module.controller.elder;
import com.makeit.common.response.ApiResponseEntity;
import com.makeit.dto.platform.elder.PlatElderIdDTO;
import com.makeit.vo.platform.elder.realtime.PlatElderCoordinateVO;
import com.makeit.vo.platform.elder.realtime.PlatElderRealTimeHeartRespiratoryVO;
import com.makeit.vo.platform.elder.report.day.*;
import io.swagger.annotations.Api;
......
......@@ -3,7 +3,7 @@ package com.makeit.module.controller.elder;
import com.makeit.common.response.ApiResponseEntity;
import com.makeit.dto.platform.elder.PlatElderIdDTO;
import com.makeit.vo.platform.elder.realtime.PlatElderRealTimeHeartRespiratoryVO;
import com.makeit.vo.platform.elder.realtime.PlatElderCoordinateVO;
import com.makeit.vo.platform.elder.report.week.PlatElderComprehensiveEvaluationVO;
import com.makeit.vo.platform.elder.report.day.*;
import com.makeit.vo.platform.elder.report.week.PlatElderRealTimeHeartRespiratoryWeekVO;
......
......@@ -13,7 +13,7 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@Api(tags = "企微端-登录")
@Api(tags = "子女端小程序-登录")
@RestController
@RequestMapping("/children/login")
public class PlatElderChildrenInfoUserLoginWechatController {
......
package com.makeit.module.controller.wechat.elder;
import com.makeit.common.response.ApiResponseEntity;
import com.makeit.common.response.ApiResponseUtils;
import com.makeit.dto.platform.elder.PlatElderIdDTO;
import com.makeit.service.platform.elder.PlatElderRealTimeService;
import com.makeit.vo.platform.elder.realtime.PlatElderCoordinateVO;
import com.makeit.vo.platform.elder.realtime.PlatElderRealTimeBodyVO;
import com.makeit.vo.platform.elder.realtime.PlatElderRealTimeHeartRespiratoryVO;
import com.makeit.vo.platform.elder.realtime.PlatElderRealTimeNowVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
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.RestController;
import java.util.List;
/**
* <p>
* 长者基本信息 前端控制器
* </p>
*
* @author eugene young
* @since 2023-08-29
*/
@Api(tags = "长者实时监测-子女端小程序")
@RestController
@RequestMapping("/children/elder/realTime")
public class PlatElderRealTimeWechatController {
@Autowired
private PlatElderRealTimeService platElderRealTimeService;
@ApiOperation("现在状态")
@PostMapping("nowStatus")
public ApiResponseEntity<PlatElderRealTimeNowVO> nowStatus(@RequestBody PlatElderIdDTO platElderIdDTO) {
return ApiResponseUtils.success(platElderRealTimeService.nowStatus(platElderIdDTO));
}
@ApiOperation("心率呼吸率")
@PostMapping("heartRespiratory")
public ApiResponseEntity<PlatElderRealTimeHeartRespiratoryVO> heartRespiratory(@RequestBody PlatElderIdDTO platElderIdDTO) {
return ApiResponseUtils.success(platElderRealTimeService.heartRespiratory(platElderIdDTO));
}
@ApiOperation("体动")
@PostMapping("body")
public ApiResponseEntity<PlatElderRealTimeBodyVO> body(@RequestBody PlatElderIdDTO platElderIdDTO) {
return ApiResponseUtils.success(platElderRealTimeService.body(platElderIdDTO));
}
@ApiOperation("坐标")
@PostMapping("coordinate")
public ApiResponseEntity<List<PlatElderCoordinateVO>> coordinate(@RequestBody PlatElderIdDTO platElderIdDTO) {
return ApiResponseUtils.success(platElderRealTimeService.coordinate(platElderIdDTO));
}
//TODO ywc 少一个坐标
}
package com.makeit.service.platform.elder;
import com.makeit.dto.platform.elder.PlatElderIdDTO;
import com.makeit.vo.platform.elder.realtime.PlatElderCoordinateVO;
import com.makeit.vo.platform.elder.realtime.PlatElderRealTimeBodyVO;
import com.makeit.vo.platform.elder.realtime.PlatElderRealTimeHeartRespiratoryVO;
import com.makeit.vo.platform.elder.realtime.PlatElderRealTimeNowVO;
import java.util.List;
/**
* <p>
* 长者健康状态 服务类
* </p>
*
* @author eugene young
* @since 2023-08-29
*/
public interface PlatElderRealTimeService {
PlatElderRealTimeNowVO nowStatus(PlatElderIdDTO platElderIdDTO);
PlatElderRealTimeHeartRespiratoryVO heartRespiratory(PlatElderIdDTO platElderIdDTO);
PlatElderRealTimeBodyVO body(PlatElderIdDTO platElderIdDTO);
List<PlatElderCoordinateVO> coordinate(PlatElderIdDTO platElderIdDTO);
}
......@@ -7,6 +7,7 @@ import com.makeit.common.vo.ExcelImportVo;
import com.makeit.dto.platform.elder.*;
import com.makeit.dto.platform.elder.add.PlatElderAddDTO;
import com.makeit.dto.platform.elder.add.PlatElderDTOVO;
import com.makeit.entity.platform.device.PlatDevice;
import com.makeit.entity.platform.elder.PlatElder;
import com.makeit.vo.platform.elder.PlatElderListVO;
import com.makeit.vo.wechat.elder.PlatElderWechatSimpleVO;
......@@ -49,6 +50,10 @@ public interface PlatElderService extends IService<PlatElder> {
void delBatch(List<String> idList);
PlatDevice getBreathDevice(String id);
List<PlatDevice> getSpaceDevice(String id);
/*小程序*/
List<PlatElderWechatSimpleVO> listMy();
/*小程序*/
......
package com.makeit.service.platform.elder.impl;
import com.makeit.dto.platform.elder.PlatElderIdDTO;
import com.makeit.entity.platform.device.PlatDevice;
import com.makeit.module.iot.service.IotProductDeviceService;
import com.makeit.module.iot.vo.breathe.DeviceInfoContentBreathe;
import com.makeit.module.iot.vo.breathe.DeviceInfoContentSpace;
import com.makeit.service.platform.elder.PlatElderRealTimeService;
import com.makeit.service.platform.elder.PlatElderService;
import com.makeit.utils.data.convert.StreamUtil;
import com.makeit.utils.data.validate.CollectionUtils;
import com.makeit.vo.platform.elder.realtime.PlatElderCoordinateVO;
import com.makeit.vo.platform.elder.realtime.PlatElderRealTimeBodyVO;
import com.makeit.vo.platform.elder.realtime.PlatElderRealTimeHeartRespiratoryVO;
import com.makeit.vo.platform.elder.realtime.PlatElderRealTimeNowVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
/**
* <p>
* 长者健康状态 服务类
* </p>
*
* @author eugene young
* @since 2023-08-29
*/
@Service
public class PlatElderRealTimeServiceImpl implements PlatElderRealTimeService {
@Autowired
private PlatElderService platElderService;
@Autowired
private IotProductDeviceService iotProductDeviceService;
private DeviceInfoContentBreathe getNowDataBreathe(String elderId) {
PlatDevice platDevice = platElderService.getBreathDevice(elderId);
if (platDevice == null) {
return null;
}
DeviceInfoContentBreathe deviceInfoContentBreathe = iotProductDeviceService.getLastDeviceLogBreathe(platDevice.getOriDeviceId(), 10);
return deviceInfoContentBreathe;
}
private List<DeviceInfoContentSpace> getNowDataSpace(String elderId) {
List<PlatDevice> deviceList = platElderService.getSpaceDevice(elderId);
if (CollectionUtils.isNotEmpty(deviceList)) {
return null;
}
return deviceList.stream().map(e -> iotProductDeviceService.getLastDeviceLogSpace(e.getOriDeviceId(), 10)).filter(Objects::nonNull)
.collect(Collectors.toList());
}
@Override
public PlatElderRealTimeNowVO nowStatus(PlatElderIdDTO platElderIdDTO) {
DeviceInfoContentBreathe deviceInfoContentBreathe = getNowDataBreathe(platElderIdDTO.getElderId());
PlatElderRealTimeNowVO platElderRealTimeNowVO = new PlatElderRealTimeNowVO();
if (deviceInfoContentBreathe == null) {
return platElderRealTimeNowVO;
}
platElderRealTimeNowVO.setStatus(deviceInfoContentBreathe.getProperties().getPersonState() + "");
platElderRealTimeNowVO.setHeartRate(deviceInfoContentBreathe.getProperties().getHr());
platElderRealTimeNowVO.setRespiratoryRate(deviceInfoContentBreathe.getProperties().getBr());
platElderRealTimeNowVO.setBodyMove(deviceInfoContentBreathe.getProperties().getBodymove());
return platElderRealTimeNowVO;
}
@Override
public PlatElderRealTimeHeartRespiratoryVO heartRespiratory(PlatElderIdDTO platElderIdDTO) {
DeviceInfoContentBreathe deviceInfoContentBreathe = getNowDataBreathe(platElderIdDTO.getElderId());
PlatElderRealTimeHeartRespiratoryVO platElderRealTimeHeartRespiratoryVO = new PlatElderRealTimeHeartRespiratoryVO();
platElderRealTimeHeartRespiratoryVO.setTime(LocalDateTime.now());
if (deviceInfoContentBreathe == null) {
return platElderRealTimeHeartRespiratoryVO;
}
platElderRealTimeHeartRespiratoryVO.setHeartRate(deviceInfoContentBreathe.getProperties().getHr());
platElderRealTimeHeartRespiratoryVO.setRespiratoryRate(deviceInfoContentBreathe.getProperties().getBr());
return platElderRealTimeHeartRespiratoryVO;
}
@Override
public PlatElderRealTimeBodyVO body(PlatElderIdDTO platElderIdDTO) {
DeviceInfoContentBreathe deviceInfoContentBreathe = getNowDataBreathe(platElderIdDTO.getElderId());
PlatElderRealTimeBodyVO platElderRealTimeBodyVO = new PlatElderRealTimeBodyVO();
platElderRealTimeBodyVO.setTime(LocalDateTime.now());
if (deviceInfoContentBreathe == null) {
return platElderRealTimeBodyVO;
}
platElderRealTimeBodyVO.setBodyMovementIndex(deviceInfoContentBreathe.getProperties().getBodymove());
return platElderRealTimeBodyVO;
}
@Override
public List<PlatElderCoordinateVO> coordinate(PlatElderIdDTO platElderIdDTO) {
List<DeviceInfoContentSpace> deviceInfoContentSpaceList = getNowDataSpace(platElderIdDTO.getElderId());
List<PlatElderCoordinateVO> voList = new ArrayList<>(10);
if (CollectionUtils.isEmpty(deviceInfoContentSpaceList)) {
return voList;
}
voList = StreamUtil.map(deviceInfoContentSpaceList, e -> {
PlatElderCoordinateVO vo = new PlatElderCoordinateVO();
vo.setX(new BigDecimal(e.getProperties().getDistance()).multiply(new BigDecimal(Math.cos(e.getProperties().getAngle()) + "")).setScale(2, RoundingMode.HALF_UP));
vo.setY(new BigDecimal(e.getProperties().getDistance()).multiply(new BigDecimal(Math.sin(e.getProperties().getAngle()) + "")).setScale(2, RoundingMode.HALF_UP));
return vo;
});
return voList;
}
}
......@@ -16,6 +16,7 @@ import com.makeit.dto.platform.elder.PlatElderQueryDTO;
import com.makeit.dto.platform.elder.add.*;
import com.makeit.dto.platform.space.TreeDTOVO;
import com.makeit.entity.platform.auth.PlatOrg;
import com.makeit.entity.platform.device.PlatDevice;
import com.makeit.entity.platform.elder.PlatElder;
import com.makeit.entity.platform.elder.PlatElderHealthInfo;
import com.makeit.entity.platform.elder.PlatElderOtherInfo;
......@@ -32,6 +33,7 @@ import com.makeit.mapper.platform.elder.PlatElderMapper;
import com.makeit.service.platform.auth.PlatOrgService;
import com.makeit.service.platform.elder.*;
import com.makeit.service.platform.space.PlatBedService;
import com.makeit.service.platform.space.PlatRoomBedDeviceService;
import com.makeit.service.platform.space.PlatRoomService;
import com.makeit.service.platform.space.PlatSpaceService;
import com.makeit.utils.data.convert.BeanDtoVoUtils;
......@@ -96,6 +98,9 @@ public class PlatElderServiceImpl extends ServiceImpl<PlatElderMapper, PlatElder
@Autowired
private PlatBedService platBedService;
@Autowired
private PlatRoomBedDeviceService platRoomBedDeviceService;
private LambdaQueryWrapper<PlatElder> lambdaQueryWrapper(PlatElderQueryDTO dto) {
return new QueryWrapper<PlatElder>().lambda()
.like(StringUtils.isNotBlank(dto.getName()), PlatElder::getName, dto.getName())
......@@ -681,6 +686,29 @@ public class PlatElderServiceImpl extends ServiceImpl<PlatElderMapper, PlatElder
}
@Override
public PlatDevice getBreathDevice(String id) {
PlatElder platElder = getById(id);
if (StringUtils.isBlank(platElder.getBedId())) {
return null;
}
return platRoomBedDeviceService.getBreathDevice(platElder.getBedId());
}
@Override
public List<PlatDevice> getSpaceDevice(String id) {
PlatElder platElder = getById(id);
if (StringUtils.isBlank(platElder.getBedId())) {
return null;
}
return platRoomBedDeviceService.getSpaceDevice(platElder.getBedId());
}
@Override
public List<PlatElderWechatSimpleVO> listMy() {
PlatElderChildrenInfoWechatVO childrenInfo = platElderChildrenInfoService.view();
......
......@@ -8,6 +8,7 @@ import com.makeit.dto.platform.space.PlatBedDeviceQueryDTO;
import com.makeit.dto.platform.space.PlatRoomBindDeviceDTO;
import com.makeit.dto.platform.space.PlatSpaceDeviceQueryDTO;
import com.makeit.dto.platform.space.PlatUnbindingDeviceDTO;
import com.makeit.entity.platform.device.PlatDevice;
import com.makeit.entity.platform.space.PlatRoomBedDevice;
import java.util.List;
......@@ -21,12 +22,14 @@ public interface PlatRoomBedDeviceService extends IService<PlatRoomBedDevice> {
/**
* 绑定设备
*
* @param dto
*/
void bindingDevice(PlatRoomBindDeviceDTO dto);
/**
* 未绑定设备列表
*
* @param pageReqDTO
* @return
*/
......@@ -34,6 +37,7 @@ public interface PlatRoomBedDeviceService extends IService<PlatRoomBedDevice> {
/**
* 已绑定设备
*
* @param dto
* @return
*/
......@@ -41,7 +45,12 @@ public interface PlatRoomBedDeviceService extends IService<PlatRoomBedDevice> {
/**
* 解绑设备
*
* @param dto
*/
void unbindingDevice(PlatUnbindingDeviceDTO dto);
PlatDevice getBreathDevice(String bedId);
List<PlatDevice> getSpaceDevice(String bedId);
}
package com.makeit.service.platform.space.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.makeit.common.page.PageReqDTO;
......@@ -22,6 +23,7 @@ import com.makeit.service.platform.space.PlatRegionSettingService;
import com.makeit.service.platform.space.PlatRoomBedDeviceService;
import com.makeit.utils.data.convert.BeanDtoVoUtils;
import com.makeit.utils.data.convert.PageUtil;
import com.makeit.utils.data.convert.StreamUtil;
import jodd.util.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -56,7 +58,7 @@ public class PlatRoomBedDeviceServiceImpl extends ServiceImpl<PlatRoomBedDeviceM
List<String> listEquipmentIds = dto.getListDeviceId();
List<PlatRoomBedDevice> list = new ArrayList<>();
listEquipmentIds.forEach(item->{
listEquipmentIds.forEach(item -> {
PlatRoomBedDevice data = new PlatRoomBedDevice();
data.setDeviceId(item);
......@@ -64,11 +66,11 @@ public class PlatRoomBedDeviceServiceImpl extends ServiceImpl<PlatRoomBedDeviceM
data.setBedId(dto.getBedId());
list.add(data);
});
if(!list.isEmpty()){
if (!list.isEmpty()) {
saveBatch(list);
//区域设备
platRegionSettingService.add(dto.getRoomId(),dto.getListDeviceId());
platRegionSettingService.add(dto.getRoomId(), dto.getListDeviceId());
}
}
......@@ -79,20 +81,20 @@ public class PlatRoomBedDeviceServiceImpl extends ServiceImpl<PlatRoomBedDeviceM
LambdaQueryWrapper<PlatRoomBedDevice> queryWrapper1 = new LambdaQueryWrapper<>();
queryWrapper1.select(PlatRoomBedDevice::getDeviceId);
if(StringUtil.isNotEmpty(dto.getRoomId())){
queryWrapper1.ne(PlatRoomBedDevice::getRoomId,dto.getRoomId());
if (StringUtil.isNotEmpty(dto.getRoomId())) {
queryWrapper1.ne(PlatRoomBedDevice::getRoomId, dto.getRoomId());
}
if(CommonEnum.NO.getValue().equals(dto.getIsRoom())){
if (CommonEnum.NO.getValue().equals(dto.getIsRoom())) {
queryWrapper1.isNull(PlatRoomBedDevice::getBedId);
}
List<PlatRoomBedDevice> list = list(queryWrapper1);
List<String> listEquipmentIds = list.stream().map(item->item.getDeviceId()).collect(Collectors.toList());
List<String> listEquipmentIds = list.stream().map(item -> item.getDeviceId()).collect(Collectors.toList());
Page<PlatDevice> p = PageUtil.toMpPage(pageReqDTO);
LambdaQueryWrapper<PlatDevice> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.notIn(!listEquipmentIds.isEmpty(),PlatDevice::getId, listEquipmentIds);
queryWrapper.eq(StringUtil.isNotEmpty(dto.getCategory()), PlatDevice::getCategory,dto.getCategory());
queryWrapper.notIn(!listEquipmentIds.isEmpty(), PlatDevice::getId, listEquipmentIds);
queryWrapper.eq(StringUtil.isNotEmpty(dto.getCategory()), PlatDevice::getCategory, dto.getCategory());
queryWrapper.like(StringUtil.isNotEmpty(dto.getOriDeviceId()), PlatDevice::getOriDeviceId, dto.getOriDeviceId());
queryWrapper.like(StringUtil.isNotEmpty(dto.getName()), PlatDevice::getName, dto.getName());
queryWrapper.like(StringUtil.isNotEmpty(dto.getProductName()), PlatDevice::getProductName, dto.getProductName());
......@@ -107,32 +109,32 @@ public class PlatRoomBedDeviceServiceImpl extends ServiceImpl<PlatRoomBedDeviceM
public List<PlatDeviceDTO> listBindDevice(PlatBedDeviceQueryDTO dto) {
LambdaQueryWrapper<PlatRoomBedDevice> queryWrapper1 = new LambdaQueryWrapper<>();
queryWrapper1.eq(PlatRoomBedDevice::getRoomId,dto.getRoomId());
queryWrapper1.eq(StringUtil.isNotEmpty(dto.getBedId()),PlatRoomBedDevice::getBedId,dto.getBedId());
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> listEquipmentIds = list.stream().map(item -> item.getDeviceId()).collect(Collectors.toList());
List<String> listBedIds = list.stream().map(item->item.getBedId()).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);
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<>();
list.forEach(item->{
if(map.containsKey(item.getBedId())){
mapName.put(item.getDeviceId(),map.get(item.getBedId()));
Map<String, String> map = listBeds.stream().collect(Collectors.toMap(PlatBed::getId, PlatBed::getName, (k1, k2) -> k1));
Map<String, String> mapName = new HashMap<>();
list.forEach(item -> {
if (map.containsKey(item.getBedId())) {
mapName.put(item.getDeviceId(), map.get(item.getBedId()));
}
});
List<PlatDeviceDTO> data = new ArrayList<>();
if(!listEquipmentIds.isEmpty()){
if (!listEquipmentIds.isEmpty()) {
LambdaQueryWrapper<PlatDevice> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(PlatDevice::getCategory, PlatDeviceEnum.CategoryEnum.HEART);
queryWrapper.in(PlatDevice::getId,listEquipmentIds);
queryWrapper.in(PlatDevice::getId, listEquipmentIds);
List<PlatDevice> listDevices = platDeviceService.list(queryWrapper);
data = BeanDtoVoUtils.listVo(listDevices,PlatDeviceDTO.class);
data = BeanDtoVoUtils.listVo(listDevices, PlatDeviceDTO.class);
data.forEach(item->{
data.forEach(item -> {
item.setBedName(mapName.get(item.getId()));
});
}
......@@ -144,23 +146,53 @@ public class PlatRoomBedDeviceServiceImpl extends ServiceImpl<PlatRoomBedDeviceM
public void unbindingDevice(PlatUnbindingDeviceDTO dto) {
LambdaQueryWrapper<PlatRoomBedDevice> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(PlatRoomBedDevice::getDeviceId,dto.getEquipmentId());
queryWrapper.eq(PlatRoomBedDevice::getRoomId,dto.getRoomId());
queryWrapper.eq(StringUtil.isNotEmpty(dto.getBedId()),PlatRoomBedDevice::getBedId,dto.getBedId());
queryWrapper.eq(PlatRoomBedDevice::getDeviceId, dto.getEquipmentId());
queryWrapper.eq(PlatRoomBedDevice::getRoomId, dto.getRoomId());
queryWrapper.eq(StringUtil.isNotEmpty(dto.getBedId()), PlatRoomBedDevice::getBedId, dto.getBedId());
List<PlatRoomBedDevice> list = list(queryWrapper);
if(StringUtil.isNotEmpty(dto.getBedId())){
if (StringUtil.isNotEmpty(dto.getBedId())) {
list.forEach(item->{
list.forEach(item -> {
item.setBedId(null);
});
updateBatchById(list);
}else{
} else {
List<String> ids = list.stream().map(item->item.getId()).collect(Collectors.toList());
List<String> ids = list.stream().map(item -> item.getId()).collect(Collectors.toList());
removeByIds(ids);
platRegionSettingService.del(dto.getRoomId(),dto.getEquipmentId());
platRegionSettingService.del(dto.getRoomId(), dto.getEquipmentId());
}
}
@Override
public PlatDevice getBreathDevice(String bedId) {
PlatRoomBedDevice device = getOne(new QueryWrapper<PlatRoomBedDevice>().lambda()
.eq(PlatRoomBedDevice::getBedId, bedId));
if (device == null) {
return null;
}
return platDeviceService.getById(device.getDeviceId());
}
@Override
public List<PlatDevice> getSpaceDevice(String bedId) {
PlatBed bed = platBedService.getById(bedId);
List<PlatRoomBedDevice> deviceList = list(new QueryWrapper<PlatRoomBedDevice>().lambda()
.eq(PlatRoomBedDevice::getRoomId, bed.getRoomId()));
return platDeviceService.list(new QueryWrapper<PlatDevice>().lambda()
.in(PlatDevice::getId, StreamUtil.mapId(deviceList, PlatRoomBedDevice::getDeviceId))
.eq(PlatDevice::getCategory, PlatDeviceEnum.CategoryEnum.SPACE.getValue())
);
}
}
package com.makeit.vo.platform.elder.realtime;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
@Data
public class PlatElderCoordinateVO {
@ApiModelProperty("x")
private BigDecimal x;
@ApiModelProperty("y")
private BigDecimal y;
}
......@@ -4,7 +4,6 @@ import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
import java.time.LocalDateTime;
@Data
......@@ -15,6 +14,6 @@ public class PlatElderRealTimeBodyVO {
private LocalDateTime time;
@ApiModelProperty("体动指数")
private BigDecimal bodyMovementIndex;
private Integer bodyMovementIndex;
}
......@@ -3,8 +3,6 @@ package com.makeit.vo.platform.elder.realtime;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
@Data
public class PlatElderRealTimeNowVO {
......@@ -18,6 +16,6 @@ public class PlatElderRealTimeNowVO {
private Integer respiratoryRate;
@ApiModelProperty("体动")
private BigDecimal body;
private Integer bodyMove;
}
package com.makeit.vo.platform.elder.report.day;
import io.swagger.annotations.ApiModelProperty;
import java.math.BigDecimal;
public class PlatElderCoordinateVO {
@ApiModelProperty("经度")
private BigDecimal longitude;
@ApiModelProperty("纬度")
private BigDecimal latitude;
}
package com.makeit;
import com.makeit.module.iot.service.IotProductDeviceService;
import com.makeit.utils.data.convert.JsonUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;
@Component
public class IotRunner implements ApplicationRunner {
@Autowired
private IotProductDeviceService iotProductDeviceService;
private static final Logger logger = LoggerFactory.getLogger(IotRunner.class);
@Override
public void run(ApplicationArguments args) throws Exception {
logger.info("111111111111111111\n"+ JsonUtil.toJson(iotProductDeviceService.getLastDeviceLogByType("1701127702523473920","reportProperty")) + "");
}
}
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