Commit 93872dd8 by 朱淼
parents 445e5be0 7c2fe347
Showing with 88 additions and 32 deletions
...@@ -12,7 +12,8 @@ import com.makeit.module.iot.vo.DeviceOperationLogEntity; ...@@ -12,7 +12,8 @@ import com.makeit.module.iot.vo.DeviceOperationLogEntity;
import com.makeit.module.iot.vo.IotPagerResult; 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.fall.DeviceInfoContentFall;
import com.makeit.module.iot.vo.space.DeviceInfoContentSpace;
import com.makeit.utils.LongTimestampUtil; 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.data.convert.StreamUtil;
...@@ -23,11 +24,10 @@ import org.springframework.stereotype.Component; ...@@ -23,11 +24,10 @@ import org.springframework.stereotype.Component;
import java.io.IOException; import java.io.IOException;
import java.time.Duration; import java.time.Duration;
import java.time.Instant;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
/** /**
* iot产品设备相关接口 * iot产品设备相关接口
...@@ -145,6 +145,16 @@ public class IotProductDeviceService extends IotCommonService { ...@@ -145,6 +145,16 @@ public class IotProductDeviceService extends IotCommonService {
return deviceInfoContentSpaceList; return deviceInfoContentSpaceList;
} }
public List<DeviceInfoContentFall> getDeviceLogByTimeRangeFall(String deviceId, int pageSize, LocalDateTime startTime, LocalDateTime endTime) {
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
List<DeviceOperationLogEntity> deviceOperationLogEntityList = getDeviceLogByTimeRange(deviceId, "event", pageSize, dateTimeFormatter.format(startTime), dateTimeFormatter.format(endTime));
List<DeviceInfoContentFall> deviceInfoContentSpaceList = StreamUtil.map(deviceOperationLogEntityList, e -> JsonUtil.toObj((String) e.getContent(), DeviceInfoContentFall.class));
return deviceInfoContentSpaceList;
}
/** /**
* 根据类型查询设备日志 * 根据类型查询设备日志
...@@ -195,7 +205,6 @@ public class IotProductDeviceService extends IotCommonService { ...@@ -195,7 +205,6 @@ public class IotProductDeviceService extends IotCommonService {
} }
/** /**
*
* @param deviceId * @param deviceId
* @param typeValue * @param typeValue
* @param pageSize * @param pageSize
...@@ -252,8 +261,9 @@ public class IotProductDeviceService extends IotCommonService { ...@@ -252,8 +261,9 @@ public class IotProductDeviceService extends IotCommonService {
if (responseMessage.getStatus() == 200) { if (responseMessage.getStatus() == 200) {
IotPagerResult pagerResult = JSON.parseObject(responseMessage.getResult().toString(), IotPagerResult.class); IotPagerResult pagerResult = JSON.parseObject(responseMessage.getResult().toString(), IotPagerResult.class);
List<DeviceOperationLogEntity> deviceOperationLogEntities = JSONArray.parseArray(pagerResult.getData().toString()).toJavaList(DeviceOperationLogEntity.class); List<DeviceOperationLogEntity> deviceOperationLogEntities = JSONArray.parseArray(pagerResult.getData().toString()).toJavaList(DeviceOperationLogEntity.class);
return deviceOperationLogEntities.stream().filter(deviceOperationLogEntity -> deviceOperationLogEntity.getType().contains("reportProperty"))
.collect(Collectors.toList());
//Map maps = (Map) JSON.parse(datum.getContent().toString()); //Map maps = (Map) JSON.parse(datum.getContent().toString());
return deviceOperationLogEntities;
} }
log.error("获取设备接口失败:{}", responseMessage.getMessage()); log.error("获取设备接口失败:{}", responseMessage.getMessage());
} catch (IOException e) { } catch (IOException e) {
......
package com.makeit.module.iot.vo.fall;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.makeit.module.iot.vo.breathe.DeviceInfoContentBreathe;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
@NoArgsConstructor
@Data
public class DeviceInfoContentFall {
@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("personState")
private Integer personState;
@JsonProperty("person")
private Integer person;
@JsonProperty("radarHitch")
private String radarHitch;
@JsonProperty("track")
private List<Integer> track;
@JsonProperty("mount")
private Integer mount;
}
}
package com.makeit.module.iot.vo.breathe; package com.makeit.module.iot.vo.space;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import com.makeit.module.iot.vo.breathe.DeviceInfoContentBreathe;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
......
...@@ -20,7 +20,7 @@ public class SaasElderReportConfigDTO { ...@@ -20,7 +20,7 @@ public class SaasElderReportConfigDTO {
private String id; private String id;
@ApiModelProperty(value = "评估内容 json字符串 {\"number:\"1\",condtion:\"\",\"score\":\"\",evaluate:\"\"\"}") @ApiModelProperty(value = "评估内容 json字符串 {\"number:\"1\",scoreRange:\"\",evaluate:\"\"\"}")
private String resultContent; private String resultContent;
......
...@@ -20,7 +20,7 @@ public class SaasSleepEvaluateReportDTO { ...@@ -20,7 +20,7 @@ public class SaasSleepEvaluateReportDTO {
private String id; private String id;
@ApiModelProperty(value = "评估结果 json字符串 {\"number:\"1\",socreRange:\"\",\"result\":\"\",evaluate:\"\"\"}") @ApiModelProperty(value = "评估结果 json字符串 {\"number:\"1\",scoreRange:\"~隔开\",\"result\":\"\",evaluate:\"\"\"}")
private String resultContent; private String resultContent;
......
...@@ -26,13 +26,13 @@ public class SaasSleepEvaluateStandardReportDTO { ...@@ -26,13 +26,13 @@ public class SaasSleepEvaluateStandardReportDTO {
@ApiModelProperty(value = "深度睡眠评估标准 json数组 [{hour:\"\",score:\"\"},{}]\"") @ApiModelProperty(value = "深度睡眠评估标准 json数组 [{hour:\"\",score:\"\"},{}]\"")
private String sleepDeepConfig; private String sleepDeepConfig;
@ApiModelProperty(value = "浅度睡眠评估标准 json字符串") @ApiModelProperty(value = "浅度睡眠评估标准 json数组")
private String sleepLightnessConfig; private String sleepLightnessConfig;
@ApiModelProperty(value = "清醒评估标准 json字符串") @ApiModelProperty(value = "清醒评估标准 json数组")
private String soberConfig; private String soberConfig;
@ApiModelProperty(value = "睡眠时长 json字符串") @ApiModelProperty(value = "睡眠时长 json数组")
private String sleepTime; private String sleepTime;
......
...@@ -30,7 +30,7 @@ public class PlatElderSleepAnalysis extends BaseBusEntity { ...@@ -30,7 +30,7 @@ public class PlatElderSleepAnalysis extends BaseBusEntity {
@ApiModelProperty(value = "睡眠结果") @ApiModelProperty(value = "睡眠结果")
private String sleepResult; private String sleepResult;
@ApiModelProperty(value = "睡眠时长") @ApiModelProperty(value = "睡眠时长 分钟")
private String sleepTime; private String sleepTime;
@ApiModelProperty(value = "休息时长") @ApiModelProperty(value = "休息时长")
......
...@@ -21,7 +21,7 @@ public class SaasDiseaseEvaluateReport extends BaseBusEntity { ...@@ -21,7 +21,7 @@ public class SaasDiseaseEvaluateReport extends BaseBusEntity {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "评估内容 json字符串 {\"number:\"1\",condtion:\"\",\"score\":\"\",evaluate:\"\"\"}") @ApiModelProperty(value = "评估内容 json字符串 {\"number:\"1\",condition:\"{}\",\"score\":\"\",evaluate:\"\"\"}")
private String resultContent; private String resultContent;
......
...@@ -21,7 +21,7 @@ public class SaasElderReportConfig extends BaseBusEntity { ...@@ -21,7 +21,7 @@ public class SaasElderReportConfig extends BaseBusEntity {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "评估内容 json字符串 {\"number:\"1\",condtion:\"\",\"score\":\"\",evaluate:\"\"\"}") @ApiModelProperty(value = "评估内容 json字符串 {\"number:\"1\",scoreRange:\"~隔开\",evaluate:\"\"\"}")
private String resultContent; private String resultContent;
......
...@@ -68,7 +68,7 @@ public class SaasSleepAnalysisModel extends BaseBusEntity { ...@@ -68,7 +68,7 @@ public class SaasSleepAnalysisModel extends BaseBusEntity {
@ApiModelProperty(value = "起床时间 每分钟大于30秒体动值") @ApiModelProperty(value = "起床时间 每分钟大于30秒体动值")
private String riseActionThreshold; private String riseActionThreshold;
@ApiModelProperty(value = "起床时间 每分钟大于30秒体动值 持续时间") @ApiModelProperty(value = "起床时间 每分钟大于30秒体动值 持续时间 min")
private String riseActionDuration; private String riseActionDuration;
@ApiModelProperty(value = "起床时间 多久(小时)内无再次入睡") @ApiModelProperty(value = "起床时间 多久(小时)内无再次入睡")
...@@ -80,13 +80,13 @@ public class SaasSleepAnalysisModel extends BaseBusEntity { ...@@ -80,13 +80,13 @@ public class SaasSleepAnalysisModel extends BaseBusEntity {
@ApiModelProperty(value = "入睡时间:体动值") @ApiModelProperty(value = "入睡时间:体动值")
private String sleepTimeActionThreshold; private String sleepTimeActionThreshold;
@ApiModelProperty(value = "入睡时间:体动值 持续时间") @ApiModelProperty(value = "入睡时间:体动值 持续时间 h")
private String sleepTimeActionDuration; private String sleepTimeActionDuration;
@ApiModelProperty(value = "每分钟体动值条件") @ApiModelProperty(value = "清醒每分钟体动值条件")
private String awakeComparison; private String awakeComparison;
@ApiModelProperty(value = "每分钟体动值") @ApiModelProperty(value = "清醒每分钟体动值")
private String awakeThreshold; private String awakeThreshold;
@ApiModelProperty(value = "深度睡眠和浅度睡眠条件") @ApiModelProperty(value = "深度睡眠和浅度睡眠条件")
......
...@@ -21,7 +21,7 @@ public class SaasSleepEvaluateReport extends BaseBusEntity { ...@@ -21,7 +21,7 @@ public class SaasSleepEvaluateReport extends BaseBusEntity {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "评估结果 json字符串 {\"number:\"1\",socreRange:\"\",\"result\":\"\",evaluate:\"\"\"}") @ApiModelProperty(value = "评估结果 json字符串 {\"number:\"1\",scoreRange:\"\",\"result\":\"\",evaluate:\"\"\"}")
private String resultContent; private String resultContent;
......
...@@ -10,7 +10,7 @@ import com.makeit.entity.platform.elder.PlatElderSleepAnalysis; ...@@ -10,7 +10,7 @@ import com.makeit.entity.platform.elder.PlatElderSleepAnalysis;
import com.makeit.enums.platform.alarm.PlatAlarmConfigEnum; import com.makeit.enums.platform.alarm.PlatAlarmConfigEnum;
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.space.DeviceInfoContentSpace;
import com.makeit.service.platform.alarm.PlatAlarmRecordService; import com.makeit.service.platform.alarm.PlatAlarmRecordService;
import com.makeit.service.platform.device.PlatDeviceService; import com.makeit.service.platform.device.PlatDeviceService;
import com.makeit.service.platform.elder.*; import com.makeit.service.platform.elder.*;
......
...@@ -4,7 +4,7 @@ import com.makeit.dto.platform.elder.PlatElderIdDTO; ...@@ -4,7 +4,7 @@ import com.makeit.dto.platform.elder.PlatElderIdDTO;
import com.makeit.entity.platform.device.PlatDevice; 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.space.DeviceInfoContentSpace;
import com.makeit.service.platform.device.PlatDeviceService; 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;
......
...@@ -86,17 +86,23 @@ implements SaasRoleService{ ...@@ -86,17 +86,23 @@ implements SaasRoleService{
} }
private void check(SaasRoleDTOVO dto) { private void check(SaasRoleDTOVO dto) {
SaasRole old = getOne(new QueryWrapper<SaasRole>().lambda() List<SaasRole> oldList = list(new QueryWrapper<SaasRole>().lambda()
.eq(SaasRole::getName, dto.getName())); .eq(SaasRole::getName, dto.getName()));
if (old != null && !old.getId().equals(dto.getId())) { for (SaasRole old : oldList) {
throw new BusinessException(CodeMessageEnum.SYSTEM_ERROR_NAME_DUPLICATE); if (old != null && !old.getId().equals(dto.getId())) {
throw new BusinessException(CodeMessageEnum.SYSTEM_ERROR_NAME_DUPLICATE);
}
}
oldList = list(new QueryWrapper<SaasRole>().lambda()
.eq(SaasRole::getCode, dto.getCode()));
for (SaasRole old : oldList) {
if (old != null && !old.getId().equals(dto.getId())) {
throw new BusinessException(CodeMessageEnum.SYSTEM_ERROR_CODE_DUPLICATE);
}
} }
// old = getOne(new QueryWrapper<SaasRole>().lambda()
// .eq(SaasRole::getName, dto.getName()));
// if (old != null && !old.getId().equals(dto.getId())) {
// throw new BusinessException(CodeMessageEnum.SYSTEM_ERROR_CODE_DUPLICATE);
// }
} }
@Transactional @Transactional
......
...@@ -186,7 +186,7 @@ implements SaasUserService{ ...@@ -186,7 +186,7 @@ implements SaasUserService{
private void setRoleList(SaasUserDTOVO dto) { private void setRoleList(SaasUserDTOVO dto) {
saasUserRoleService.remove(new QueryWrapper<SaasUserRole>().lambda() saasUserRoleService.remove(new QueryWrapper<SaasUserRole>().lambda()
.eq(SaasUserRole::getUserId, dto.getId())); .eq(SaasUserRole::getUserId, dto.getId()));
if (CollectionUtils.isNotEmpty(dto.getRoleList())) { if (CollectionUtils.isNotEmpty(dto.getRoleIdList())) {
List<SaasUserRole> userRoleList = StreamUtil.map(dto.getRoleIdList(), e -> { List<SaasUserRole> userRoleList = StreamUtil.map(dto.getRoleIdList(), e -> {
SaasUserRole saasUserRole = new SaasUserRole(); SaasUserRole saasUserRole = new SaasUserRole();
saasUserRole.setUserId(dto.getId()); saasUserRole.setUserId(dto.getId());
......
...@@ -82,7 +82,7 @@ mybatis-plus: ...@@ -82,7 +82,7 @@ mybatis-plus:
global-config: global-config:
db-config: db-config:
id-type: ASSIGN_ID id-type: ASSIGN_ID
update-strategy: not_empty update-strategy: not_null
insert-strategy: not_empty insert-strategy: not_empty
where-strategy: not_empty where-strategy: not_empty
......
...@@ -9,7 +9,7 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -9,7 +9,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest @SpringBootTest
public class IotTest { public class IotDeviceInfoContentFall {
@Autowired @Autowired
private IotTokenService tokenService; private IotTokenService tokenService;
......
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