Commit d7046ca6 by 杨伟程

坐标定位和轨迹更新

parent 30bb5321
...@@ -158,6 +158,24 @@ public class IotProductDeviceService extends IotCommonService { ...@@ -158,6 +158,24 @@ public class IotProductDeviceService extends IotCommonService {
} }
public DeviceInfoContentFall getLastDeviceLogFall(String deviceId, Integer ignoreDuration) {//秒
DeviceOperationLogEntity deviceOperationLogEntity = getLastDeviceLogByType(deviceId, REPORT_PROPERTY);
if (deviceOperationLogEntity == null) {
return null;
}
DeviceInfoContentFall fall = JsonUtil.toObj((String) deviceOperationLogEntity.getContent(), DeviceInfoContentFall.class);
LocalDateTime time = LongTimestampUtil.toLocalDateTime(fall.getTimestamp());
if (ignoreDuration != null && Duration.between(time, LocalDateTime.now()).getSeconds() > ignoreDuration) {
return null;
}
return fall;
}
public List<String> getLastDayHourRange(LocalDateTime startDateTime) { public List<String> getLastDayHourRange(LocalDateTime startDateTime) {
int count = 24; int count = 24;
List<String> list = Lists.newArrayList(); List<String> list = Lists.newArrayList();
......
...@@ -354,22 +354,25 @@ public class PlatElderDayReportDayServiceImpl implements PlatElderDayReportDaySe ...@@ -354,22 +354,25 @@ public class PlatElderDayReportDayServiceImpl implements PlatElderDayReportDaySe
@Override @Override
public List<PlatElderCoordinateVO> coordinateList(String elderId, String deviceId, LocalDateTime start, LocalDateTime end) { public List<PlatElderCoordinateVO> coordinateList(String elderId, String deviceId, LocalDateTime start, LocalDateTime end) {
List<PlatDevice> platDeviceList = platElderRealTimeService.getSpaceDevice(elderId, deviceId); List<PlatDevice> platDeviceListSpace = platElderRealTimeService.getSpaceDevice(elderId, deviceId);
if (CollectionUtils.isEmpty(platDeviceList)) { List<PlatDevice> platDeviceListFall = platElderRealTimeService.getFallDevice(elderId, deviceId);
if (CollectionUtils.isEmpty(platDeviceListSpace) && CollectionUtils.isEmpty(platDeviceListFall)) {
return new ArrayList<>(10); return new ArrayList<>(10);
} }
List<PlatElderCoordinateVO> voList = new ArrayList<>(10); List<PlatElderCoordinateVO> voList = new ArrayList<>(10);
platDeviceList.forEach(e -> { platDeviceListSpace.forEach(e -> {
List<DeviceInfoContentSpace> spaceList = iotProductDeviceService.getDeviceLogByTimeRangeSpace(e.getOriDeviceId(), 2 * 24 * 3600, start, end); List<DeviceInfoContentSpace> spaceList = iotProductDeviceService.getDeviceLogByTimeRangeSpace(e.getOriDeviceId(), 2 * 24 * 3600, start, end);
voList.addAll(StreamUtil.map(spaceList, i -> { voList.addAll(StreamUtil.map(spaceList, i -> {
PlatElderCoordinateVO vo = new PlatElderCoordinateVO(); PlatElderCoordinateVO vo = new PlatElderCoordinateVO();
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.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.setDistance(i.getProperties().getDistance());
vo.setAngle(i.getProperties().getAngle()); vo.setAngle(i.getProperties().getAngle());
...@@ -384,6 +387,25 @@ public class PlatElderDayReportDayServiceImpl implements PlatElderDayReportDaySe ...@@ -384,6 +387,25 @@ public class PlatElderDayReportDayServiceImpl implements PlatElderDayReportDaySe
}); });
platDeviceListFall.forEach(e -> {
List<DeviceInfoContentFall> fallList = iotProductDeviceService.getDeviceLogByTimeRangeFall(e.getOriDeviceId(), 2 * 24 * 3600, start, end);
voList.addAll(StreamUtil.map(fallList, i -> {
PlatElderCoordinateVO vo = new PlatElderCoordinateVO();
vo.setTrack(i.getProperties().getTrack());
vo.setDeviceId(e.getId());
vo.setOriDeviceId(e.getOriDeviceId());
return vo;
})
);
});
return voList; return voList;
} }
......
...@@ -9,9 +9,11 @@ import com.makeit.entity.saas.analysis.SaasSleepAnalysisModel; ...@@ -9,9 +9,11 @@ import com.makeit.entity.saas.analysis.SaasSleepAnalysisModel;
import com.makeit.entity.saas.analysis.SaasSleepEvaluateReport; import com.makeit.entity.saas.analysis.SaasSleepEvaluateReport;
import com.makeit.enums.platform.elder.PlatElderRealtimeReportEnum; import com.makeit.enums.platform.elder.PlatElderRealtimeReportEnum;
import com.makeit.module.iot.enums.DeviceInfoContentBreatheEnum; 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.DeviceInfoContentSpaceEnum;
import com.makeit.module.iot.service.IotProductDeviceService; import com.makeit.module.iot.service.IotProductDeviceService;
import com.makeit.module.iot.vo.breathe.DeviceInfoContentBreathe; import com.makeit.module.iot.vo.breathe.DeviceInfoContentBreathe;
import com.makeit.module.iot.vo.fall.DeviceInfoContentFall;
import com.makeit.module.iot.vo.space.DeviceInfoContentSpace; import com.makeit.module.iot.vo.space.DeviceInfoContentSpace;
import com.makeit.service.platform.device.PlatDeviceService; import com.makeit.service.platform.device.PlatDeviceService;
import com.makeit.service.platform.elder.PlatElderDayReportDayService; import com.makeit.service.platform.elder.PlatElderDayReportDayService;
...@@ -40,6 +42,7 @@ import java.util.List; ...@@ -40,6 +42,7 @@ import java.util.List;
import java.util.Objects; import java.util.Objects;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream;
/** /**
* <p> * <p>
...@@ -143,13 +146,46 @@ public class PlatElderRealTimeServiceImpl implements PlatElderRealTimeService { ...@@ -143,13 +146,46 @@ public class PlatElderRealTimeServiceImpl implements PlatElderRealTimeService {
} }
private List<DeviceInfoContentFall> getNowDataFall(String elderId, String deviceId) {
List<PlatDevice> deviceList = getFallDevice(elderId, deviceId);
if (CollectionUtils.isEmpty(deviceList)) {
return null;
}
return deviceList.stream().map(e -> iotProductDeviceService.getLastDeviceLogFall(e.getOriDeviceId(), 10)).filter(Objects::nonNull)
.collect(Collectors.toList());
}
private void nowStatusOut(PlatElderRealTimeNowVO platElderRealTimeNowVO, PlatElderIdDTO platElderIdDTO) { private void nowStatusOut(PlatElderRealTimeNowVO platElderRealTimeNowVO, PlatElderIdDTO platElderIdDTO) {
List<DeviceInfoContentSpace> deviceInfoContentSpaceList = getNowDataSpace(platElderIdDTO.getElderId(), platElderIdDTO.getDeviceId()); List<DeviceInfoContentSpace> deviceInfoContentSpaceList = getNowDataSpace(platElderIdDTO.getElderId(), platElderIdDTO.getDeviceId());
if (CollectionUtils.isEmpty(deviceInfoContentSpaceList)) {
List<DeviceInfoContentFall> deviceInfoContentFallList = getNowDataFall(platElderIdDTO.getElderId(), platElderIdDTO.getDeviceId());
if (CollectionUtils.isEmpty(deviceInfoContentSpaceList) && CollectionUtils.isEmpty(deviceInfoContentFallList)) {
return; return;
} }
if (StreamUtil.allMatch(deviceInfoContentSpaceList, e -> DeviceInfoContentSpaceEnum.PersonStateEnum.NOBODY.getValue().equals(e.getProperties().getPersonState()))) { // if (StreamUtil.allMatch(deviceInfoContentSpaceList, e -> DeviceInfoContentSpaceEnum.PersonStateEnum.NOBODY.getValue().equals(e.getProperties().getPersonState()))) {
// platElderRealTimeNowVO.setStatus(PlatElderRealtimeReportEnum.NowStatus.OUT.getValue());
// }
Boolean spaceFlag = null;
Boolean fallFlag = null;
if (CollectionUtils.isNotEmpty(deviceInfoContentSpaceList)) {
spaceFlag = StreamUtil.allMatch(deviceInfoContentSpaceList, e -> DeviceInfoContentSpaceEnum.PersonStateEnum.NOBODY.getValue().equals(e.getProperties().getPersonState()));
}
if (CollectionUtils.isNotEmpty(deviceInfoContentFallList)) {
fallFlag = StreamUtil.allMatch(deviceInfoContentFallList, e -> DeviceInfoContentFallEnum.PersonStateEnum.NOBODY.getValue().equals(e.getProperties().getPersonState()));
}
List<Boolean> flagList = Stream.of(spaceFlag, fallFlag).filter(Objects::nonNull).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(flagList) && StreamUtil.allMatch(flagList, Boolean.TRUE::equals)) {
platElderRealTimeNowVO.setStatus(PlatElderRealtimeReportEnum.NowStatus.OUT.getValue()); platElderRealTimeNowVO.setStatus(PlatElderRealtimeReportEnum.NowStatus.OUT.getValue());
} }
...@@ -161,7 +197,7 @@ public class PlatElderRealTimeServiceImpl implements PlatElderRealTimeService { ...@@ -161,7 +197,7 @@ public class PlatElderRealTimeServiceImpl implements PlatElderRealTimeService {
return; return;
} }
boolean flag = DeviceInfoContentBreatheEnum.PersonStateEnum.NOBODY.getValue().equals(nowDataBreathe.getProperties().getPersonState()+""); boolean flag = DeviceInfoContentBreatheEnum.PersonStateEnum.NOBODY.getValue().equals(nowDataBreathe.getProperties().getPersonState() + "");
if (!flag) { if (!flag) {
return; return;
...@@ -182,7 +218,7 @@ public class PlatElderRealTimeServiceImpl implements PlatElderRealTimeService { ...@@ -182,7 +218,7 @@ public class PlatElderRealTimeServiceImpl implements PlatElderRealTimeService {
return; return;
} }
boolean flag = DeviceInfoContentBreatheEnum.PersonStateEnum.NOBODY.getValue().equals(nowDataBreathe.getProperties().getPersonState()+""); boolean flag = DeviceInfoContentBreatheEnum.PersonStateEnum.NOBODY.getValue().equals(nowDataBreathe.getProperties().getPersonState() + "");
if (!flag) { if (!flag) {
return; return;
...@@ -203,7 +239,7 @@ public class PlatElderRealTimeServiceImpl implements PlatElderRealTimeService { ...@@ -203,7 +239,7 @@ public class PlatElderRealTimeServiceImpl implements PlatElderRealTimeService {
return; return;
} }
boolean flag = !DeviceInfoContentBreatheEnum.PersonStateEnum.NOBODY.getValue().equals(nowDataBreathe.getProperties().getPersonState()+""); boolean flag = !DeviceInfoContentBreatheEnum.PersonStateEnum.NOBODY.getValue().equals(nowDataBreathe.getProperties().getPersonState() + "");
if (!flag) { if (!flag) {
return; return;
} }
...@@ -241,7 +277,7 @@ public class PlatElderRealTimeServiceImpl implements PlatElderRealTimeService { ...@@ -241,7 +277,7 @@ public class PlatElderRealTimeServiceImpl implements PlatElderRealTimeService {
public PlatElderRealTimeNowVO nowStatus(PlatElderIdDTO platElderIdDTO) { public PlatElderRealTimeNowVO nowStatus(PlatElderIdDTO platElderIdDTO) {
Object result = RedisUtil.get(ELDER_STATUS + platElderIdDTO.getElderId()); Object result = RedisUtil.get(ELDER_STATUS + platElderIdDTO.getElderId());
if (result != null) { if (result != null) {
return JSON.parseObject(result.toString(),PlatElderRealTimeNowVO.class); return JSON.parseObject(result.toString(), PlatElderRealTimeNowVO.class);
} }
DeviceInfoContentBreathe deviceInfoContentBreathe = getNowDataBreathe(platElderIdDTO.getElderId(), platElderIdDTO.getDeviceId()); DeviceInfoContentBreathe deviceInfoContentBreathe = getNowDataBreathe(platElderIdDTO.getElderId(), platElderIdDTO.getDeviceId());
...@@ -274,7 +310,7 @@ public class PlatElderRealTimeServiceImpl implements PlatElderRealTimeService { ...@@ -274,7 +310,7 @@ public class PlatElderRealTimeServiceImpl implements PlatElderRealTimeService {
platElderRealTimeNowVO.setRespiratoryRate(deviceInfoContentBreathe.getProperties().getBr()); platElderRealTimeNowVO.setRespiratoryRate(deviceInfoContentBreathe.getProperties().getBr());
platElderRealTimeNowVO.setBodyMove(deviceInfoContentBreathe.getProperties().getBodymove()); platElderRealTimeNowVO.setBodyMove(deviceInfoContentBreathe.getProperties().getBodymove());
RedisUtil.set(ELDER_STATUS + platElderIdDTO.getElderId(), JSON.toJSONString(platElderRealTimeNowVO),15, TimeUnit.SECONDS); RedisUtil.set(ELDER_STATUS + platElderIdDTO.getElderId(), JSON.toJSONString(platElderRealTimeNowVO), 15, TimeUnit.SECONDS);
return platElderRealTimeNowVO; return platElderRealTimeNowVO;
} }
...@@ -313,29 +349,90 @@ public class PlatElderRealTimeServiceImpl implements PlatElderRealTimeService { ...@@ -313,29 +349,90 @@ public class PlatElderRealTimeServiceImpl implements PlatElderRealTimeService {
} }
// @Override
// public List<PlatElderCoordinateVO> coordinate(PlatElderIdDTO platElderIdDTO) {
// List<DeviceInfoContentSpace> deviceInfoContentSpaceList = getNowDataSpace(platElderIdDTO.getElderId(), platElderIdDTO.getDeviceId());
//
// List<PlatElderCoordinateVO> voList = new ArrayList<>(10);
//
// if (CollectionUtils.isEmpty(deviceInfoContentSpaceList)) {
// return voList;
// }
//
// voList = StreamUtil.map(deviceInfoContentSpaceList, e -> {
// PlatElderCoordinateVO vo = new PlatElderCoordinateVO();
//
//// vo.setDeviceId();
//// vo.setOriDeviceId();
//
// 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));
//
// vo.setDistance(e.getProperties().getDistance());
// vo.setAngle(e.getProperties().getAngle());
//
// return vo;
// });
//
// return voList;
// }
@Override @Override
public List<PlatElderCoordinateVO> coordinate(PlatElderIdDTO platElderIdDTO) { public List<PlatElderCoordinateVO> coordinate(PlatElderIdDTO platElderIdDTO) {
List<DeviceInfoContentSpace> deviceInfoContentSpaceList = getNowDataSpace(platElderIdDTO.getElderId(), platElderIdDTO.getDeviceId());
List<PlatElderCoordinateVO> voList = new ArrayList<>(10); List<PlatElderCoordinateVO> voList = new ArrayList<>(10);
if (CollectionUtils.isEmpty(deviceInfoContentSpaceList)) { List<PlatDevice> deviceListSpace = getSpaceDevice(platElderIdDTO.getElderId(), platElderIdDTO.getDeviceId());
List<PlatDevice> deviceListFall = getFallDevice(platElderIdDTO.getElderId(), platElderIdDTO.getDeviceId());
if (CollectionUtils.isEmpty(deviceListSpace) && CollectionUtils.isNotEmpty(deviceListFall)) {
return voList; return voList;
} }
voList = StreamUtil.map(deviceInfoContentSpaceList, e -> { deviceListSpace.forEach(e -> {
DeviceInfoContentSpace i = iotProductDeviceService.getLastDeviceLogSpace(e.getOriDeviceId(), 10);
if (i == null) {
return;
}
PlatElderCoordinateVO vo = new PlatElderCoordinateVO();
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);
});
deviceListFall.forEach(e -> {
DeviceInfoContentFall i = iotProductDeviceService.getLastDeviceLogFall(e.getOriDeviceId(), 10);
if (i == null) {
return;
}
PlatElderCoordinateVO vo = new PlatElderCoordinateVO(); 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.setDeviceId(e.getId());
vo.setY(new BigDecimal(e.getProperties().getDistance()).multiply(new BigDecimal(Math.sin(e.getProperties().getAngle()) + "")).setScale(2, RoundingMode.HALF_UP)); vo.setOriDeviceId(e.getOriDeviceId());
vo.setTrack(i.getProperties().getTrack());
vo.setDistance(e.getProperties().getDistance()); voList.add(vo);
vo.setAngle(e.getProperties().getAngle());
return vo;
}); });
return voList; return voList;
} }
} }
...@@ -4,6 +4,7 @@ import io.swagger.annotations.ApiModelProperty; ...@@ -4,6 +4,7 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.List;
@Data @Data
public class PlatElderCoordinateVO { public class PlatElderCoordinateVO {
...@@ -14,11 +15,11 @@ public class PlatElderCoordinateVO { ...@@ -14,11 +15,11 @@ public class PlatElderCoordinateVO {
@ApiModelProperty(value = "原始设备ID") @ApiModelProperty(value = "原始设备ID")
private String oriDeviceId; private String oriDeviceId;
@ApiModelProperty("x") // @ApiModelProperty("x")
private BigDecimal x; // private BigDecimal x;
//
@ApiModelProperty("y") // @ApiModelProperty("y")
private BigDecimal y; // private BigDecimal y;
@ApiModelProperty("人体目标距离雷达位置 范围:0-1000,单位cm") @ApiModelProperty("人体目标距离雷达位置 范围:0-1000,单位cm")
private Integer distance; private Integer distance;
...@@ -26,5 +27,8 @@ public class PlatElderCoordinateVO { ...@@ -26,5 +27,8 @@ public class PlatElderCoordinateVO {
@ApiModelProperty("人体目标偏离雷达法线角度范围:±60,单位°") @ApiModelProperty("人体目标偏离雷达法线角度范围:±60,单位°")
private Integer angle; private Integer angle;
@ApiModelProperty("跌倒设备轨迹")
private List<Integer> track;
} }
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