Commit ab080c56 by 朱淼
parents fc39c393 78a56c2d
Showing with 320 additions and 41 deletions
...@@ -34,7 +34,7 @@ public class TenantIdUtil { ...@@ -34,7 +34,7 @@ public class TenantIdUtil {
public static String getTenantId() { public static String getTenantId() {
List<Supplier<String>> supplierList = Arrays.asList( List<Supplier<String>> supplierList = Arrays.asList(
TenantIdUtil::getFromThreadLocal, //TenantIdUtil::getFromThreadLocal,
TenantIdUtil::getFromHeader//, TenantIdUtil::getFromHeader//,
); );
......
...@@ -12,7 +12,9 @@ import com.makeit.module.iot.vo.IotPagerResult; ...@@ -12,7 +12,9 @@ import com.makeit.module.iot.vo.IotPagerResult;
import com.makeit.module.iot.vo.ResponseMessage; import com.makeit.module.iot.vo.ResponseMessage;
import com.makeit.module.iot.vo.breathe.DeviceInfoContentBreathe; import com.makeit.module.iot.vo.breathe.DeviceInfoContentBreathe;
import com.makeit.module.iot.vo.breathe.DeviceInfoContentSpace; import com.makeit.module.iot.vo.breathe.DeviceInfoContentSpace;
import com.makeit.utils.LongTimestampUtil;
import com.makeit.utils.data.convert.JsonUtil; import com.makeit.utils.data.convert.JsonUtil;
import com.makeit.utils.data.convert.StreamUtil;
import com.makeit.utils.old.StringUtils; import com.makeit.utils.old.StringUtils;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
...@@ -23,6 +25,7 @@ import java.time.Duration; ...@@ -23,6 +25,7 @@ import java.time.Duration;
import java.time.Instant; import java.time.Instant;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.ZoneId; import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.List; import java.util.List;
/** /**
...@@ -95,7 +98,7 @@ public class IotProductDeviceService extends IotCommonService { ...@@ -95,7 +98,7 @@ public class IotProductDeviceService extends IotCommonService {
DeviceInfoContentBreathe breathe = JsonUtil.toObj((String) deviceOperationLogEntity.getContent(), DeviceInfoContentBreathe.class); DeviceInfoContentBreathe breathe = JsonUtil.toObj((String) deviceOperationLogEntity.getContent(), DeviceInfoContentBreathe.class);
LocalDateTime time = LocalDateTime.ofInstant(Instant.ofEpochMilli(breathe.getTimestamp()), ZoneId.systemDefault()); LocalDateTime time = LongTimestampUtil.toLocalDateTime(breathe.getTimestamp());
if (ignoreDuration != null && Duration.between(time, LocalDateTime.now()).getSeconds() > ignoreDuration) { if (ignoreDuration != null && Duration.between(time, LocalDateTime.now()).getSeconds() > ignoreDuration) {
return null; return null;
} }
...@@ -112,7 +115,7 @@ public class IotProductDeviceService extends IotCommonService { ...@@ -112,7 +115,7 @@ public class IotProductDeviceService extends IotCommonService {
DeviceInfoContentSpace space = JsonUtil.toObj((String) deviceOperationLogEntity.getContent(), DeviceInfoContentSpace.class); DeviceInfoContentSpace space = JsonUtil.toObj((String) deviceOperationLogEntity.getContent(), DeviceInfoContentSpace.class);
LocalDateTime time = LocalDateTime.ofInstant(Instant.ofEpochMilli(space.getTimestamp()), ZoneId.systemDefault()); LocalDateTime time = LongTimestampUtil.toLocalDateTime(space.getTimestamp());
if (ignoreDuration != null && Duration.between(time, LocalDateTime.now()).getSeconds() > ignoreDuration) { if (ignoreDuration != null && Duration.between(time, LocalDateTime.now()).getSeconds() > ignoreDuration) {
return null; return null;
} }
...@@ -121,6 +124,26 @@ public class IotProductDeviceService extends IotCommonService { ...@@ -121,6 +124,26 @@ public class IotProductDeviceService extends IotCommonService {
} }
public List<DeviceInfoContentBreathe> getDeviceLogByTimeRangeBreathe(String deviceId, int pageSize, LocalDateTime startTime, LocalDateTime endTime) {
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
List<DeviceOperationLogEntity> deviceOperationLogEntityList = getDeviceLogByTimeRange(deviceId, "reportProperty", pageSize, dateTimeFormatter.format(startTime), dateTimeFormatter.format(endTime));
List<DeviceInfoContentBreathe> deviceInfoContentBreatheList = StreamUtil.map(deviceOperationLogEntityList, e -> JsonUtil.toObj((String) e.getContent(), DeviceInfoContentBreathe.class));
return deviceInfoContentBreatheList;
}
public List<DeviceInfoContentSpace> getDeviceLogByTimeRangeSpace(String deviceId, int pageSize, LocalDateTime startTime, LocalDateTime endTime) {
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
List<DeviceOperationLogEntity> deviceOperationLogEntityList = getDeviceLogByTimeRange(deviceId, "reportProperty", pageSize, dateTimeFormatter.format(startTime), dateTimeFormatter.format(endTime));
List<DeviceInfoContentSpace> deviceInfoContentSpaceList = StreamUtil.map(deviceOperationLogEntityList, e -> JsonUtil.toObj((String) e.getContent(), DeviceInfoContentSpace.class));
return deviceInfoContentSpaceList;
}
/** /**
* 根据类型查询设备日志 * 根据类型查询设备日志
...@@ -171,13 +194,24 @@ public class IotProductDeviceService extends IotCommonService { ...@@ -171,13 +194,24 @@ public class IotProductDeviceService extends IotCommonService {
} }
public List<DeviceOperationLogEntity> getDeviceLogByTimeRange(String deviceId, int pageSize,String startTime,String endTime) { public List<DeviceOperationLogEntity> getDeviceLogByTimeRange(String deviceId, String typeValue, int pageSize, String startTime, String endTime) {
IotQueryParam iotQueryParam = buildQueryParam(pageSize); IotQueryParam iotQueryParam = buildQueryParam(pageSize);
List<Term> terms = Lists.newArrayList(); List<Term> terms = Lists.newArrayList();
Term term = Term.builder()
.column("type")
.termType("btw")
.type(Term.Type.or)
.value(typeValue)
.terms(Lists.newArrayList())
.options(Lists.newArrayList())
.build();
terms.add(term);
Term term1 = Term.builder() Term term1 = Term.builder()
.column("timestamp") .column("timestamp")
.termType("gte") .termType("gte")
.type(Term.Type.or) .type(Term.Type.and)
.value(startTime) .value(startTime)
.terms(Lists.newArrayList()) .terms(Lists.newArrayList())
.options(Lists.newArrayList()) .options(Lists.newArrayList())
......
package com.makeit.utils;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
public class LongTimestampUtil {
public static LocalDateTime toLocalDateTime(Long timestamp) {
if (timestamp == null) {
return null;
}
LocalDateTime time = LocalDateTime.ofInstant(Instant.ofEpochMilli(timestamp), ZoneId.systemDefault());
return time;
}
}
...@@ -2,12 +2,15 @@ package com.makeit.module.controller.elder; ...@@ -2,12 +2,15 @@ package com.makeit.module.controller.elder;
import com.makeit.common.response.ApiResponseEntity; import com.makeit.common.response.ApiResponseEntity;
import com.makeit.common.response.ApiResponseUtils;
import com.makeit.dto.platform.elder.PlatElderIdDTO; import com.makeit.dto.platform.elder.PlatElderIdDTO;
import com.makeit.service.platform.elder.PlatElderDayReportDayService;
import com.makeit.vo.platform.elder.realtime.PlatElderCoordinateVO; import com.makeit.vo.platform.elder.realtime.PlatElderCoordinateVO;
import com.makeit.vo.platform.elder.realtime.PlatElderRealTimeHeartRespiratoryVO; import com.makeit.vo.platform.elder.realtime.PlatElderRealTimeHeartRespiratoryVO;
import com.makeit.vo.platform.elder.report.day.*; import com.makeit.vo.platform.elder.report.day.*;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; 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.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
...@@ -28,6 +31,9 @@ import java.util.List; ...@@ -28,6 +31,9 @@ import java.util.List;
@RequestMapping("/plat/elder/report/day") @RequestMapping("/plat/elder/report/day")
public class PlatElderReportDayController { public class PlatElderReportDayController {
@Autowired
private PlatElderDayReportDayService platElderDayReportDayService;
@ApiOperation("睡眠评价") @ApiOperation("睡眠评价")
@PostMapping("sleepEvaluation") @PostMapping("sleepEvaluation")
public ApiResponseEntity<PlatElderSleepEvaluationVO> sleepEvaluation(@RequestBody PlatElderIdDTO platElderIdDTO) { public ApiResponseEntity<PlatElderSleepEvaluationVO> sleepEvaluation(@RequestBody PlatElderIdDTO platElderIdDTO) {
...@@ -61,7 +67,7 @@ public class PlatElderReportDayController { ...@@ -61,7 +67,7 @@ public class PlatElderReportDayController {
@ApiOperation("心率呼吸率") @ApiOperation("心率呼吸率")
@PostMapping("heartRespiratory") @PostMapping("heartRespiratory")
public ApiResponseEntity<List<PlatElderRealTimeHeartRespiratoryVO>> heartRespiratory(@RequestBody PlatElderIdDTO platElderIdDTO) { public ApiResponseEntity<List<PlatElderRealTimeHeartRespiratoryVO>> heartRespiratory(@RequestBody PlatElderIdDTO platElderIdDTO) {
return null; return ApiResponseUtils.success(platElderDayReportDayService.heartRespiratory(platElderIdDTO));
} }
@ApiOperation("行为异常记录") @ApiOperation("行为异常记录")
...@@ -79,7 +85,7 @@ public class PlatElderReportDayController { ...@@ -79,7 +85,7 @@ public class PlatElderReportDayController {
@ApiOperation("坐标记录") @ApiOperation("坐标记录")
@PostMapping("coordinateList") @PostMapping("coordinateList")
public ApiResponseEntity<List<PlatElderCoordinateVO>> coordinateList(@RequestBody PlatElderIdDTO platElderIdDTO) { public ApiResponseEntity<List<PlatElderCoordinateVO>> coordinateList(@RequestBody PlatElderIdDTO platElderIdDTO) {
return null; return ApiResponseUtils.success(platElderDayReportDayService.coordinateList(platElderIdDTO));
} }
@ApiOperation("行为辐射") @ApiOperation("行为辐射")
......
...@@ -2,7 +2,7 @@ package com.makeit.module.controller.elder; ...@@ -2,7 +2,7 @@ package com.makeit.module.controller.elder;
import com.makeit.common.response.ApiResponseEntity; import com.makeit.common.response.ApiResponseEntity;
import com.makeit.dto.platform.elder.PlatElderIdDTO; import com.makeit.dto.platform.elder.PlatElderReportDTO;
import com.makeit.vo.platform.elder.report.day.PlatElderHeartRespiratoryEvaluationVO; import com.makeit.vo.platform.elder.report.day.PlatElderHeartRespiratoryEvaluationVO;
import com.makeit.vo.platform.elder.report.day.PlatElderReportMonthVO; import com.makeit.vo.platform.elder.report.day.PlatElderReportMonthVO;
import com.makeit.vo.platform.elder.report.day.PlatElderSleepEvaluationVO; import com.makeit.vo.platform.elder.report.day.PlatElderSleepEvaluationVO;
...@@ -29,26 +29,26 @@ public class PlatElderReportMonthController { ...@@ -29,26 +29,26 @@ public class PlatElderReportMonthController {
@ApiOperation("综合评价") @ApiOperation("综合评价")
@PostMapping("comprehensiveEvaluation") @PostMapping("comprehensiveEvaluation")
public ApiResponseEntity<PlatElderComprehensiveEvaluationVO> comprehensiveEvaluation(@RequestBody PlatElderIdDTO platElderIdDTO) { public ApiResponseEntity<PlatElderComprehensiveEvaluationVO> comprehensiveEvaluation(@RequestBody PlatElderReportDTO platElderIdDTO) {
return null; return null;
} }
@ApiOperation("睡眠评价") @ApiOperation("睡眠评价")
@PostMapping("sleepEvaluation") @PostMapping("sleepEvaluation")
public ApiResponseEntity<PlatElderSleepEvaluationVO> sleepEvaluation(@RequestBody PlatElderIdDTO platElderIdDTO) { public ApiResponseEntity<PlatElderSleepEvaluationVO> sleepEvaluation(@RequestBody PlatElderReportDTO platElderIdDTO) {
return null; return null;
} }
@ApiOperation("心率呼吸评价") @ApiOperation("心率呼吸评价")
@PostMapping("heartRespiratoryEvaluation") @PostMapping("heartRespiratoryEvaluation")
public ApiResponseEntity<PlatElderHeartRespiratoryEvaluationVO> heartRespiratoryEvaluation(@RequestBody PlatElderIdDTO platElderIdDTO) { public ApiResponseEntity<PlatElderHeartRespiratoryEvaluationVO> heartRespiratoryEvaluation(@RequestBody PlatElderReportDTO platElderIdDTO) {
return null; return null;
} }
@ApiOperation("月报表") @ApiOperation("月报表")
@PostMapping("reportMonth") @PostMapping("reportMonth")
public ApiResponseEntity<PlatElderReportMonthVO> reportMonth(@RequestBody PlatElderIdDTO platElderIdDTO) { public ApiResponseEntity<PlatElderReportMonthVO> reportMonth(@RequestBody PlatElderReportDTO platElderIdDTO) {
return null; return null;
} }
......
...@@ -2,14 +2,17 @@ package com.makeit.module.controller.elder; ...@@ -2,14 +2,17 @@ package com.makeit.module.controller.elder;
import com.makeit.common.response.ApiResponseEntity; import com.makeit.common.response.ApiResponseEntity;
import com.makeit.dto.platform.elder.PlatElderIdDTO; import com.makeit.common.response.ApiResponseUtils;
import com.makeit.dto.platform.elder.PlatElderReportDTO;
import com.makeit.service.platform.elder.PlatElderDayReportWeekService;
import com.makeit.vo.platform.elder.realtime.PlatElderCoordinateVO; 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.day.*;
import com.makeit.vo.platform.elder.report.week.PlatElderComprehensiveEvaluationVO;
import com.makeit.vo.platform.elder.report.week.PlatElderRealTimeHeartRespiratoryWeekVO; import com.makeit.vo.platform.elder.report.week.PlatElderRealTimeHeartRespiratoryWeekVO;
import com.makeit.vo.platform.elder.report.week.PlatElderSleepDiagramWeekVO; import com.makeit.vo.platform.elder.report.week.PlatElderSleepDiagramWeekVO;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; 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.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
...@@ -30,69 +33,72 @@ import java.util.List; ...@@ -30,69 +33,72 @@ import java.util.List;
@RequestMapping("/plat/elder/report/week") @RequestMapping("/plat/elder/report/week")
public class PlatElderReportWeekController { public class PlatElderReportWeekController {
@Autowired
private PlatElderDayReportWeekService platElderDayReportWeekService;
@ApiOperation("综合评价") @ApiOperation("综合评价")
@PostMapping("comprehensiveEvaluation") @PostMapping("comprehensiveEvaluation")
public ApiResponseEntity<PlatElderComprehensiveEvaluationVO> comprehensiveEvaluation(@RequestBody PlatElderIdDTO platElderIdDTO) { public ApiResponseEntity<PlatElderComprehensiveEvaluationVO> comprehensiveEvaluation(@RequestBody PlatElderReportDTO platElderIdDTO) {
return null; return null;
} }
@ApiOperation("睡眠评价") @ApiOperation("睡眠评价")
@PostMapping("sleepEvaluation") @PostMapping("sleepEvaluation")
public ApiResponseEntity<PlatElderSleepEvaluationVO> sleepEvaluation(@RequestBody PlatElderIdDTO platElderIdDTO) { public ApiResponseEntity<PlatElderSleepEvaluationVO> sleepEvaluation(@RequestBody PlatElderReportDTO platElderIdDTO) {
return null; return null;
} }
@ApiOperation("睡眠图表") @ApiOperation("睡眠图表")
@PostMapping("sleepDiagram") @PostMapping("sleepDiagram")
public ApiResponseEntity<List<PlatElderSleepDiagramWeekVO>> sleepDiagram(@RequestBody PlatElderIdDTO platElderIdDTO) { public ApiResponseEntity<List<PlatElderSleepDiagramWeekVO>> sleepDiagram(@RequestBody PlatElderReportDTO platElderIdDTO) {
return null; return null;
} }
@ApiOperation("心率呼吸评价") @ApiOperation("心率呼吸评价")
@PostMapping("heartRespiratoryEvaluation") @PostMapping("heartRespiratoryEvaluation")
public ApiResponseEntity<PlatElderHeartRespiratoryEvaluationVO> heartRespiratoryEvaluation(@RequestBody PlatElderIdDTO platElderIdDTO) { public ApiResponseEntity<PlatElderHeartRespiratoryEvaluationVO> heartRespiratoryEvaluation(@RequestBody PlatElderReportDTO platElderIdDTO) {
return null; return null;
} }
@ApiOperation("心率异常记录") @ApiOperation("心率异常记录")
@PostMapping("heartExceptionRecordList") @PostMapping("heartExceptionRecordList")
public ApiResponseEntity<List<PlatElderHeartRespiratoryEvaluationRecordVO>> heartExceptionRecordList(@RequestBody PlatElderIdDTO platElderIdDTO) { public ApiResponseEntity<List<PlatElderHeartRespiratoryEvaluationRecordVO>> heartExceptionRecordList(@RequestBody PlatElderReportDTO platElderIdDTO) {
return null; return null;
} }
@ApiOperation("呼吸率异常记录") @ApiOperation("呼吸率异常记录")
@PostMapping("respiratoryExceptionRecordList") @PostMapping("respiratoryExceptionRecordList")
public ApiResponseEntity<List<PlatElderHeartRespiratoryEvaluationRecordVO>> respiratoryExceptionRecordList(@RequestBody PlatElderIdDTO platElderIdDTO) { public ApiResponseEntity<List<PlatElderHeartRespiratoryEvaluationRecordVO>> respiratoryExceptionRecordList(@RequestBody PlatElderReportDTO platElderIdDTO) {
return null; return null;
} }
@ApiOperation("心率呼吸率") @ApiOperation("心率呼吸率")
@PostMapping("heartRespiratory") @PostMapping("heartRespiratory")
public ApiResponseEntity<PlatElderRealTimeHeartRespiratoryWeekVO> heartRespiratory(@RequestBody PlatElderIdDTO platElderIdDTO) { public ApiResponseEntity<PlatElderRealTimeHeartRespiratoryWeekVO> heartRespiratory(@RequestBody PlatElderReportDTO platElderIdDTO) {
return null; return null;
} }
@ApiOperation("行为异常记录") @ApiOperation("行为异常记录")
@PostMapping("behaviorExceptionRecordList") @PostMapping("behaviorExceptionRecordList")
public ApiResponseEntity<List<PlatElderBehaviorExceptionRecordVO>> behaviorExceptionRecordList(@RequestBody PlatElderIdDTO platElderIdDTO) { public ApiResponseEntity<List<PlatElderBehaviorExceptionRecordVO>> behaviorExceptionRecordList(@RequestBody PlatElderReportDTO platElderIdDTO) {
return null; return null;
} }
@ApiOperation("跌倒记录") @ApiOperation("跌倒记录")
@PostMapping("failRecordList") @PostMapping("failRecordList")
public ApiResponseEntity<List<String>> failRecordList(@RequestBody PlatElderIdDTO platElderIdDTO) { public ApiResponseEntity<List<String>> failRecordList(@RequestBody PlatElderReportDTO platElderIdDTO) {
return null; return null;
} }
@ApiOperation("坐标记录") @ApiOperation("坐标记录")
@PostMapping("coordinateList") @PostMapping("coordinateList")
public ApiResponseEntity<List<PlatElderCoordinateVO>> coordinateList(@RequestBody PlatElderIdDTO platElderIdDTO) { public ApiResponseEntity<List<PlatElderCoordinateVO>> coordinateList(@RequestBody PlatElderReportDTO platElderIdDTO) {
return null; return ApiResponseUtils.success(platElderDayReportWeekService.coordinateList(platElderIdDTO));
} }
@ApiOperation("行为辐射") @ApiOperation("行为辐射")
@PostMapping("behaviorDistribution") @PostMapping("behaviorDistribution")
public ApiResponseEntity<List<PlatElderBehaviorDistributionVO>> behaviorDistribution(@RequestBody PlatElderIdDTO platElderIdDTO) { public ApiResponseEntity<List<PlatElderBehaviorDistributionVO>> behaviorDistribution(@RequestBody PlatElderReportDTO platElderIdDTO) {
return null; return null;
} }
......
...@@ -15,10 +15,13 @@ import lombok.EqualsAndHashCode; ...@@ -15,10 +15,13 @@ import lombok.EqualsAndHashCode;
*/ */
@Data @Data
@ApiModel(value = "Elder对象", description = "长者基本信息") @ApiModel(value = "Elder对象", description = "长者基本信息")
public class PlatElderIdDTO{ public class PlatElderIdDTO {
@ApiModelProperty(value = "长者id") @ApiModelProperty(value = "长者id")
private String elderId; private String elderId;
@ApiModelProperty(value = "设备id")
private String deviceId;
} }
...@@ -74,6 +74,8 @@ public class PlatAlarmRecord extends BaseBusEntity { ...@@ -74,6 +74,8 @@ public class PlatAlarmRecord extends BaseBusEntity {
*/ */
private String elderIds; private String elderIds;
private String remark;
} }
......
...@@ -2,10 +2,9 @@ package com.makeit.service.platform.elder; ...@@ -2,10 +2,9 @@ package com.makeit.service.platform.elder;
import com.makeit.dto.platform.elder.PlatElderIdDTO; import com.makeit.dto.platform.elder.PlatElderIdDTO;
import com.makeit.vo.platform.elder.realtime.PlatElderCoordinateVO; 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.PlatElderRealTimeHeartRespiratoryVO;
import com.makeit.vo.platform.elder.realtime.PlatElderRealTimeNowVO;
import java.time.LocalDateTime;
import java.util.List; import java.util.List;
/** /**
...@@ -18,4 +17,10 @@ import java.util.List; ...@@ -18,4 +17,10 @@ import java.util.List;
*/ */
public interface PlatElderDayReportDayService { public interface PlatElderDayReportDayService {
List<PlatElderRealTimeHeartRespiratoryVO> heartRespiratory(PlatElderIdDTO platElderIdDTO);
List<PlatElderCoordinateVO> coordinateList(String elderId, String deviceId, LocalDateTime start, LocalDateTime end);
List<PlatElderCoordinateVO> coordinateList(PlatElderIdDTO platElderIdDTO);
} }
package com.makeit.service.platform.elder;
import com.makeit.dto.platform.elder.PlatElderIdDTO;
import com.makeit.dto.platform.elder.PlatElderReportDTO;
import com.makeit.vo.platform.elder.realtime.PlatElderCoordinateVO;
import com.makeit.vo.platform.elder.realtime.PlatElderRealTimeHeartRespiratoryVO;
import java.util.List;
/**
* <p>
* 长者健康状态 服务类
* </p>
*
* @author eugene young
* @since 2023-08-29
*/
public interface PlatElderDayReportWeekService {
List<PlatElderCoordinateVO> coordinateList(PlatElderReportDTO platElderIdDTO);
}
package com.makeit.service.platform.elder; package com.makeit.service.platform.elder;
import com.makeit.dto.platform.elder.PlatElderIdDTO; import com.makeit.dto.platform.elder.PlatElderIdDTO;
import com.makeit.entity.platform.device.PlatDevice;
import com.makeit.vo.platform.elder.realtime.PlatElderCoordinateVO; import com.makeit.vo.platform.elder.realtime.PlatElderCoordinateVO;
import com.makeit.vo.platform.elder.realtime.PlatElderRealTimeBodyVO; import com.makeit.vo.platform.elder.realtime.PlatElderRealTimeBodyVO;
import com.makeit.vo.platform.elder.realtime.PlatElderRealTimeHeartRespiratoryVO; import com.makeit.vo.platform.elder.realtime.PlatElderRealTimeHeartRespiratoryVO;
...@@ -18,6 +19,10 @@ import java.util.List; ...@@ -18,6 +19,10 @@ import java.util.List;
*/ */
public interface PlatElderRealTimeService { public interface PlatElderRealTimeService {
PlatDevice getBreathDevice(String elderId, String deviceId);
List<PlatDevice> getSpaceDevice(String elderId, String deviceId);
PlatElderRealTimeNowVO nowStatus(PlatElderIdDTO platElderIdDTO); PlatElderRealTimeNowVO nowStatus(PlatElderIdDTO platElderIdDTO);
PlatElderRealTimeHeartRespiratoryVO heartRespiratory(PlatElderIdDTO platElderIdDTO); PlatElderRealTimeHeartRespiratoryVO heartRespiratory(PlatElderIdDTO platElderIdDTO);
......
package com.makeit.service.platform.elder.impl; 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.device.PlatDeviceService;
import com.makeit.service.platform.elder.PlatElderDayReportDayService; import com.makeit.service.platform.elder.PlatElderDayReportDayService;
import com.makeit.service.platform.elder.PlatElderRealTimeService;
import com.makeit.service.platform.elder.PlatElderService;
import com.makeit.utils.LongTimestampUtil;
import com.makeit.utils.data.convert.StreamUtil;
import com.makeit.utils.data.validate.CollectionUtils;
import com.makeit.utils.old.StringUtils;
import com.makeit.utils.time.LocalDateTimeUtils;
import com.makeit.vo.platform.elder.realtime.PlatElderCoordinateVO;
import com.makeit.vo.platform.elder.realtime.PlatElderRealTimeHeartRespiratoryVO;
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.Arrays;
import java.util.List;
@Service
public class PlatElderDayReportDayServiceImpl implements PlatElderDayReportDayService { public class PlatElderDayReportDayServiceImpl implements PlatElderDayReportDayService {
@Autowired
private PlatElderService platElderService;
@Autowired
private PlatDeviceService platDeviceService;
@Autowired
private IotProductDeviceService iotProductDeviceService;
@Autowired
private PlatElderRealTimeService platElderRealTimeService;
@Override
public List<PlatElderRealTimeHeartRespiratoryVO> heartRespiratory(PlatElderIdDTO platElderIdDTO) {
PlatDevice platDevice = platElderRealTimeService.getBreathDevice(platElderIdDTO.getElderId(), platElderIdDTO.getDeviceId());
if (platDevice == null) {
return new ArrayList<>(10);
}
LocalDateTime now = LocalDateTime.now();
LocalDateTime start = LocalDateTimeUtils.getDayStart(now);
LocalDateTime end = LocalDateTimeUtils.getDayEnd(now);
List<DeviceInfoContentBreathe> breatheList = iotProductDeviceService.getDeviceLogByTimeRangeBreathe(platDevice.getOriDeviceId(), 2 * 24 * 3600, start, end);
List<PlatElderRealTimeHeartRespiratoryVO> voList = StreamUtil.map(breatheList, e -> {
PlatElderRealTimeHeartRespiratoryVO vo = new PlatElderRealTimeHeartRespiratoryVO();
vo.setTime(LongTimestampUtil.toLocalDateTime(e.getTimestamp()));
vo.setHeartRate(e.getProperties().getHr());
vo.setRespiratoryRate(e.getProperties().getBr());
return vo;
});
return voList;
}
@Override
public List<PlatElderCoordinateVO> coordinateList(String elderId, String deviceId, LocalDateTime start, LocalDateTime end) {
List<PlatDevice> platDeviceList = platElderRealTimeService.getSpaceDevice(elderId, deviceId);
if (CollectionUtils.isEmpty(platDeviceList)) {
return new ArrayList<>(10);
}
List<PlatElderCoordinateVO> voList = new ArrayList<>(10);
platDeviceList.forEach(e -> {
List<DeviceInfoContentSpace> spaceList = iotProductDeviceService.getDeviceLogByTimeRangeSpace(e.getOriDeviceId(), 2 * 24 * 3600, start, end);
voList.addAll(StreamUtil.map(spaceList, i -> {
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));
return vo;
})
);
});
return voList;
}
@Override
public List<PlatElderCoordinateVO> coordinateList(PlatElderIdDTO platElderIdDTO) {
LocalDateTime now = LocalDateTime.now();
LocalDateTime start = LocalDateTimeUtils.getDayStart(now);
LocalDateTime end = LocalDateTimeUtils.getDayEnd(now);
return coordinateList(platElderIdDTO.getElderId(), platElderIdDTO.getDeviceId(), start, end);
}
} }
package com.makeit.service.platform.elder.impl;
import com.makeit.dto.platform.elder.PlatElderReportDTO;
import com.makeit.module.iot.service.IotProductDeviceService;
import com.makeit.service.platform.elder.PlatElderDayReportDayService;
import com.makeit.service.platform.elder.PlatElderDayReportWeekService;
import com.makeit.service.platform.elder.PlatElderService;
import com.makeit.vo.platform.elder.realtime.PlatElderCoordinateVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class PlatElderDayReportWeekServiceImpl implements PlatElderDayReportWeekService {
@Autowired
private PlatElderDayReportDayService platElderDayReportDayService;
@Autowired
private PlatElderService platElderService;
@Autowired
private IotProductDeviceService iotProductDeviceService;
@Override
public List<PlatElderCoordinateVO> coordinateList(PlatElderReportDTO platElderIdDTO) {
return platElderDayReportDayService.coordinateList(platElderIdDTO.getElderId(), platElderIdDTO.getDeviceId(), platElderIdDTO.getStartTime(), platElderIdDTO.getEndTime());
}
}
...@@ -5,10 +5,12 @@ import com.makeit.entity.platform.device.PlatDevice; ...@@ -5,10 +5,12 @@ import com.makeit.entity.platform.device.PlatDevice;
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.breathe.DeviceInfoContentSpace; import com.makeit.module.iot.vo.breathe.DeviceInfoContentSpace;
import com.makeit.service.platform.device.PlatDeviceService;
import com.makeit.service.platform.elder.PlatElderRealTimeService; import com.makeit.service.platform.elder.PlatElderRealTimeService;
import com.makeit.service.platform.elder.PlatElderService; import com.makeit.service.platform.elder.PlatElderService;
import com.makeit.utils.data.convert.StreamUtil; import com.makeit.utils.data.convert.StreamUtil;
import com.makeit.utils.data.validate.CollectionUtils; import com.makeit.utils.data.validate.CollectionUtils;
import com.makeit.utils.old.StringUtils;
import com.makeit.vo.platform.elder.realtime.PlatElderCoordinateVO; import com.makeit.vo.platform.elder.realtime.PlatElderCoordinateVO;
import com.makeit.vo.platform.elder.realtime.PlatElderRealTimeBodyVO; import com.makeit.vo.platform.elder.realtime.PlatElderRealTimeBodyVO;
import com.makeit.vo.platform.elder.realtime.PlatElderRealTimeHeartRespiratoryVO; import com.makeit.vo.platform.elder.realtime.PlatElderRealTimeHeartRespiratoryVO;
...@@ -20,6 +22,7 @@ import java.math.BigDecimal; ...@@ -20,6 +22,7 @@ import java.math.BigDecimal;
import java.math.RoundingMode; import java.math.RoundingMode;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -40,11 +43,44 @@ public class PlatElderRealTimeServiceImpl implements PlatElderRealTimeService { ...@@ -40,11 +43,44 @@ public class PlatElderRealTimeServiceImpl implements PlatElderRealTimeService {
private PlatElderService platElderService; private PlatElderService platElderService;
@Autowired @Autowired
private PlatDeviceService platDeviceService;
@Autowired
private IotProductDeviceService iotProductDeviceService; private IotProductDeviceService iotProductDeviceService;
private DeviceInfoContentBreathe getNowDataBreathe(String elderId) { @Override
public PlatDevice getBreathDevice(String elderId, String deviceId) {
PlatDevice platDevice = null;
if (StringUtils.isNotBlank(elderId)) {
platDevice = platElderService.getBreathDevice(elderId);
}
if (StringUtils.isNotBlank(deviceId)) {
platDevice = platDeviceService.getById(deviceId);
}
return platDevice;
}
@Override
public List<PlatDevice> getSpaceDevice(String elderId, String deviceId) {
List<PlatDevice> deviceList = null;
if (StringUtils.isNotBlank(elderId)) {
deviceList = platElderService.getSpaceDevice(elderId);
}
if (StringUtils.isNotBlank(deviceId)) {
deviceList = Arrays.asList(platDeviceService.getById(deviceId));
}
return deviceList;
}
private DeviceInfoContentBreathe getNowDataBreathe(String elderId, String deviceId) {
PlatDevice platDevice = platElderService.getBreathDevice(elderId); PlatDevice platDevice = getBreathDevice(elderId, deviceId);
if (platDevice == null) { if (platDevice == null) {
return null; return null;
...@@ -56,11 +92,11 @@ public class PlatElderRealTimeServiceImpl implements PlatElderRealTimeService { ...@@ -56,11 +92,11 @@ public class PlatElderRealTimeServiceImpl implements PlatElderRealTimeService {
} }
private List<DeviceInfoContentSpace> getNowDataSpace(String elderId) { private List<DeviceInfoContentSpace> getNowDataSpace(String elderId, String deviceId) {
List<PlatDevice> deviceList = platElderService.getSpaceDevice(elderId); List<PlatDevice> deviceList = getSpaceDevice(elderId, deviceId);
if (CollectionUtils.isNotEmpty(deviceList)) { if (CollectionUtils.isEmpty(deviceList)) {
return null; return null;
} }
...@@ -71,7 +107,7 @@ public class PlatElderRealTimeServiceImpl implements PlatElderRealTimeService { ...@@ -71,7 +107,7 @@ public class PlatElderRealTimeServiceImpl implements PlatElderRealTimeService {
@Override @Override
public PlatElderRealTimeNowVO nowStatus(PlatElderIdDTO platElderIdDTO) { public PlatElderRealTimeNowVO nowStatus(PlatElderIdDTO platElderIdDTO) {
DeviceInfoContentBreathe deviceInfoContentBreathe = getNowDataBreathe(platElderIdDTO.getElderId()); DeviceInfoContentBreathe deviceInfoContentBreathe = getNowDataBreathe(platElderIdDTO.getElderId(), platElderIdDTO.getDeviceId());
PlatElderRealTimeNowVO platElderRealTimeNowVO = new PlatElderRealTimeNowVO(); PlatElderRealTimeNowVO platElderRealTimeNowVO = new PlatElderRealTimeNowVO();
...@@ -90,7 +126,7 @@ public class PlatElderRealTimeServiceImpl implements PlatElderRealTimeService { ...@@ -90,7 +126,7 @@ public class PlatElderRealTimeServiceImpl implements PlatElderRealTimeService {
@Override @Override
public PlatElderRealTimeHeartRespiratoryVO heartRespiratory(PlatElderIdDTO platElderIdDTO) { public PlatElderRealTimeHeartRespiratoryVO heartRespiratory(PlatElderIdDTO platElderIdDTO) {
DeviceInfoContentBreathe deviceInfoContentBreathe = getNowDataBreathe(platElderIdDTO.getElderId()); DeviceInfoContentBreathe deviceInfoContentBreathe = getNowDataBreathe(platElderIdDTO.getElderId(), platElderIdDTO.getDeviceId());
PlatElderRealTimeHeartRespiratoryVO platElderRealTimeHeartRespiratoryVO = new PlatElderRealTimeHeartRespiratoryVO(); PlatElderRealTimeHeartRespiratoryVO platElderRealTimeHeartRespiratoryVO = new PlatElderRealTimeHeartRespiratoryVO();
platElderRealTimeHeartRespiratoryVO.setTime(LocalDateTime.now()); platElderRealTimeHeartRespiratoryVO.setTime(LocalDateTime.now());
...@@ -107,7 +143,7 @@ public class PlatElderRealTimeServiceImpl implements PlatElderRealTimeService { ...@@ -107,7 +143,7 @@ public class PlatElderRealTimeServiceImpl implements PlatElderRealTimeService {
@Override @Override
public PlatElderRealTimeBodyVO body(PlatElderIdDTO platElderIdDTO) { public PlatElderRealTimeBodyVO body(PlatElderIdDTO platElderIdDTO) {
DeviceInfoContentBreathe deviceInfoContentBreathe = getNowDataBreathe(platElderIdDTO.getElderId()); DeviceInfoContentBreathe deviceInfoContentBreathe = getNowDataBreathe(platElderIdDTO.getElderId(), platElderIdDTO.getDeviceId());
PlatElderRealTimeBodyVO platElderRealTimeBodyVO = new PlatElderRealTimeBodyVO(); PlatElderRealTimeBodyVO platElderRealTimeBodyVO = new PlatElderRealTimeBodyVO();
platElderRealTimeBodyVO.setTime(LocalDateTime.now()); platElderRealTimeBodyVO.setTime(LocalDateTime.now());
...@@ -124,7 +160,7 @@ public class PlatElderRealTimeServiceImpl implements PlatElderRealTimeService { ...@@ -124,7 +160,7 @@ public class PlatElderRealTimeServiceImpl implements PlatElderRealTimeService {
@Override @Override
public List<PlatElderCoordinateVO> coordinate(PlatElderIdDTO platElderIdDTO) { public List<PlatElderCoordinateVO> coordinate(PlatElderIdDTO platElderIdDTO) {
List<DeviceInfoContentSpace> deviceInfoContentSpaceList = getNowDataSpace(platElderIdDTO.getElderId()); List<DeviceInfoContentSpace> deviceInfoContentSpaceList = getNowDataSpace(platElderIdDTO.getElderId(), platElderIdDTO.getDeviceId());
List<PlatElderCoordinateVO> voList = new ArrayList<>(10); List<PlatElderCoordinateVO> voList = new ArrayList<>(10);
......
...@@ -165,9 +165,13 @@ public class PlatBedServiceImpl extends ServiceImpl<PlatBedMapper, PlatBed> impl ...@@ -165,9 +165,13 @@ public class PlatBedServiceImpl extends ServiceImpl<PlatBedMapper, PlatBed> impl
LambdaQueryWrapper<PlatRoomBedDevice> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<PlatRoomBedDevice> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(PlatRoomBedDevice::getRoomId,dto.getRoomId()); queryWrapper.eq(PlatRoomBedDevice::getRoomId,dto.getRoomId());
queryWrapper.select(PlatRoomBedDevice::getBedId); queryWrapper.select(PlatRoomBedDevice::getBedId);
queryWrapper.isNotNull(PlatRoomBedDevice::getBedId);
List<PlatRoomBedDevice> listDevices = platRoomBedDeviceService.list(queryWrapper); List<PlatRoomBedDevice> listDevices = platRoomBedDeviceService.list(queryWrapper);
List<String> listBedIds = listDevices.stream().map(item->item.getBedId()).collect(Collectors.toList());
List<String> listBedIds = new ArrayList<>();
if(!listDevices.isEmpty()){
listBedIds = listDevices.stream().map(item->item.getBedId()).collect(Collectors.toList());
}
LambdaQueryWrapper<PlatBed> queryWrapper1 = new LambdaQueryWrapper<>(); LambdaQueryWrapper<PlatBed> queryWrapper1 = new LambdaQueryWrapper<>();
queryWrapper1.eq(StringUtil.isNotEmpty(dto.getRoomId()), PlatBed::getRoomId, dto.getRoomId()); queryWrapper1.eq(StringUtil.isNotEmpty(dto.getRoomId()), PlatBed::getRoomId, dto.getRoomId());
......
...@@ -64,7 +64,7 @@ public class IotTest { ...@@ -64,7 +64,7 @@ public class IotTest {
@Test @Test
void getDeviceLogByTimeRange() { void getDeviceLogByTimeRange() {
iotProductDeviceService.getDeviceLogByTimeRange("1701127702523473920",100,"2023-09-11 00:00:00","2023-09-11 23:59:00"); iotProductDeviceService.getDeviceLogByTimeRange("1701127702523473920", "reportProperty", 100, "2023-09-12 00:00:00", "2023-09-12 23:59:00");
} }
@Test @Test
...@@ -74,6 +74,6 @@ public class IotTest { ...@@ -74,6 +74,6 @@ public class IotTest {
@Test @Test
void updateIotOrgInfo() { void updateIotOrgInfo() {
iotOrgService.updateIotOrgInfo("1698964909267415040","lxl2234"); iotOrgService.updateIotOrgInfo("1698964909267415040", "lxl2234");
} }
} }
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