Commit 39dc5c78 by 罗志长

Merge branch 'dev'

parents bacc1801 70833ecf
...@@ -39,7 +39,7 @@ public class IotCommonService { ...@@ -39,7 +39,7 @@ public class IotCommonService {
public HttpRequest buildRequest(String url,String body) { public HttpRequest buildRequest(String url,String body) {
log.info("接口:{},请求参数:{}",url,body); // log.info("接口:{},请求参数:{}",url,body);
HttpRequest request = new SimpleHttpRequest(url, httpClient); HttpRequest request = new SimpleHttpRequest(url, httpClient);
request.headers(headerUtils.createHeadersOfJsonString(body)); request.headers(headerUtils.createHeadersOfJsonString(body));
request.requestBody(body); request.requestBody(body);
...@@ -72,7 +72,9 @@ public class IotCommonService { ...@@ -72,7 +72,9 @@ public class IotCommonService {
private static ResponseMessage getResponseMessage(String url, Response response) throws IOException { private static ResponseMessage getResponseMessage(String url, Response response) throws IOException {
Object result = JSON.parse(response.asBytes()); Object result = JSON.parse(response.asBytes());
ResponseMessage responseMessage = JSON.parseObject(result.toString(), ResponseMessage.class); ResponseMessage responseMessage = JSON.parseObject(result.toString(), ResponseMessage.class);
log.info("接口:{},返回信息:{}", url,JSON.toJSONString(responseMessage)); if (responseMessage.getStatus() != 200) {
log.info("接口:{},返回信息:{}", url,JSON.toJSONString(responseMessage));
}
return responseMessage; return responseMessage;
} }
......
...@@ -261,16 +261,18 @@ public class IotProductDeviceService extends IotCommonService { ...@@ -261,16 +261,18 @@ public class IotProductDeviceService extends IotCommonService {
continue; continue;
} }
// 0和255直接跳过 // 0和255直接跳过
if (breatheProperties.getHr() == 255 || breatheProperties.getHr() == 0 ) { Integer propertiesHr = breatheProperties.getHr() != null ? breatheProperties.getHr() : 0;
if (propertiesHr == 255 || propertiesHr == 0 ) {
noPersonCount++; noPersonCount++;
continue; continue;
} }
if (breatheProperties.getBr() == 255 || breatheProperties.getBr() == 0) { Integer propertiesBr = breatheProperties.getBr() != null ? breatheProperties.getBr() : 0;
if (propertiesBr == 255 || propertiesBr == 0) {
noPersonCount++; noPersonCount++;
continue; continue;
} }
hr += breatheProperties.getHr(); hr += propertiesHr;
br += breatheProperties.getBr(); br += propertiesBr;
bodymove += breatheProperties.getBodymove(); bodymove += breatheProperties.getBodymove();
} }
temp = new DeviceInfoContentBreathe(); temp = new DeviceInfoContentBreathe();
......
...@@ -37,11 +37,9 @@ public class HeaderUtils { ...@@ -37,11 +37,9 @@ public class HeaderUtils {
.map(e -> e.getKey().concat("=").concat(String.valueOf(e.getValue()))) .map(e -> e.getKey().concat("=").concat(String.valueOf(e.getValue())))
.collect(Collectors.joining("&")); .collect(Collectors.joining("&"));
System.out.println(paramString);
//param+X-Timestamp+SecureKey通过MD5加密 //param+X-Timestamp+SecureKey通过MD5加密
MessageDigest digest = DigestUtils.getMd5Digest(); MessageDigest digest = DigestUtils.getMd5Digest();
System.out.println(paramString + xTimestamp + secureKey);
digest.update(paramString.getBytes()); digest.update(paramString.getBytes());
digest.update(xTimestamp.getBytes()); digest.update(xTimestamp.getBytes());
digest.update(secureKey.getBytes()); digest.update(secureKey.getBytes());
...@@ -60,7 +58,6 @@ public class HeaderUtils { ...@@ -60,7 +58,6 @@ public class HeaderUtils {
//密钥 //密钥
//param+X-Timestamp+SecureKey通过MD5加密 //param+X-Timestamp+SecureKey通过MD5加密
MessageDigest digest = DigestUtils.getMd5Digest(); MessageDigest digest = DigestUtils.getMd5Digest();
System.out.println(jsonString + xTimestamp + secureKey);
digest.update(jsonString.getBytes()); digest.update(jsonString.getBytes());
digest.update(xTimestamp.getBytes()); digest.update(xTimestamp.getBytes());
digest.update(secureKey.getBytes()); digest.update(secureKey.getBytes());
...@@ -70,7 +67,7 @@ public class HeaderUtils { ...@@ -70,7 +67,7 @@ public class HeaderUtils {
headers.put("X-Client-Id", clientId); headers.put("X-Client-Id", clientId);
headers.put("X-Timestamp", xTimestamp); headers.put("X-Timestamp", xTimestamp);
log.info("请求头信息:{}",Hex.encodeHexString(digest.digest()) +"|"+clientId+"|"+ xTimestamp); // log.info("请求头信息:{}",Hex.encodeHexString(digest.digest()) +"|"+clientId+"|"+ xTimestamp);
return headers; return headers;
} }
......
package com.makeit.module.iot.vo; package com.makeit.module.iot.vo;
import com.google.common.collect.Lists;
import lombok.Data; import lombok.Data;
import java.util.List; import java.util.List;
...@@ -13,7 +14,7 @@ public class HeaderInfo { ...@@ -13,7 +14,7 @@ public class HeaderInfo {
private String _uid; private String _uid;
private String creatorId; private String creatorId;
private String traceparent; private String traceparent;
private List<Bind> bindings; private List<Bind> bindings = Lists.newArrayList();
@Data @Data
......
package com.makeit.dto.platform.elder.es; package com.makeit.dto.platform.elder.es;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import java.time.LocalDateTime; import java.time.LocalDateTime;
...@@ -21,7 +20,6 @@ public class PlatElderCoordinateDTO { ...@@ -21,7 +20,6 @@ public class PlatElderCoordinateDTO {
*/ */
private String tenantId; private String tenantId;
/** /**
* 创建时间 * 创建时间
*/ */
...@@ -33,6 +31,21 @@ public class PlatElderCoordinateDTO { ...@@ -33,6 +31,21 @@ public class PlatElderCoordinateDTO {
private Integer type; private Integer type;
/** /**
* 人体目标距离雷达位置
*/
private Integer distance;
/**
* 人体目标偏离雷达法线角度范围:±60,单位°
*/
private Integer angle;
/**
* 安装方式
*/
private Integer mount;
/**
* 空间人感:0表示无人,1表示活动, 2表示微动 ,3表示静止 ,跌倒设备:0无人,1跌倒 * 空间人感:0表示无人,1表示活动, 2表示微动 ,3表示静止 ,跌倒设备:0无人,1跌倒
*/ */
private Integer personState; private Integer personState;
......
...@@ -10,6 +10,7 @@ import com.makeit.entity.platform.device.PlatDevice; ...@@ -10,6 +10,7 @@ import com.makeit.entity.platform.device.PlatDevice;
import com.makeit.entity.platform.elder.PlatElder; import com.makeit.entity.platform.elder.PlatElder;
import com.makeit.enums.CommonEnum; import com.makeit.enums.CommonEnum;
import com.makeit.enums.platform.alarm.PlatAlarmConfigEnum; import com.makeit.enums.platform.alarm.PlatAlarmConfigEnum;
import com.makeit.enums.platform.device.PlatDeviceEnum;
import com.makeit.enums.redis.RedisConst; import com.makeit.enums.redis.RedisConst;
import com.makeit.service.platform.alarm.PlatAlarmRecordService; import com.makeit.service.platform.alarm.PlatAlarmRecordService;
import com.makeit.utils.AlarmConfigCacheUtil; import com.makeit.utils.AlarmConfigCacheUtil;
...@@ -50,6 +51,9 @@ public class OffBedAlarm implements IAlarm { ...@@ -50,6 +51,9 @@ public class OffBedAlarm implements IAlarm {
@Override @Override
public void checkConfig(PlatAlarmCheckDTO platAlarmCheckDTO) { public void checkConfig(PlatAlarmCheckDTO platAlarmCheckDTO) {
PlatDevice platDevice = platAlarmCheckDTO.getPlatDevice(); PlatDevice platDevice = platAlarmCheckDTO.getPlatDevice();
if (!PlatDeviceEnum.CategoryEnum.HEART.getValue().equals(platDevice.getCategory())) {
return;
}
platAlarmRecordService.getElderListByDeviceId(platAlarmCheckDTO); platAlarmRecordService.getElderListByDeviceId(platAlarmCheckDTO);
//log.info("执行离床checkConfig方法:"); //log.info("执行离床checkConfig方法:");
List<PlatElder> platElderList = platAlarmCheckDTO.getPlatElderList(); List<PlatElder> platElderList = platAlarmCheckDTO.getPlatElderList();
......
...@@ -452,6 +452,9 @@ public class DataScreenServiceImpl implements DataScreenService { ...@@ -452,6 +452,9 @@ public class DataScreenServiceImpl implements DataScreenService {
.isNotNull(PlatAlarmRecord::getElderIds) .isNotNull(PlatAlarmRecord::getElderIds)
.orderByDesc(PlatAlarmRecord::getAlarmDate)); .orderByDesc(PlatAlarmRecord::getAlarmDate));
List<PlatAlarmRecord> alarmRecords = pages.getRecords(); List<PlatAlarmRecord> alarmRecords = pages.getRecords();
List<String> deviceIds = StreamUtil.map(alarmRecords, PlatAlarmRecord::getDeviceId);
List<PlatDevice> platDevices = platDeviceService.list(new QueryWrapper<PlatDevice>().lambda().in(PlatDevice::getId, deviceIds));
Map<String, String> deviceMap = StreamUtil.toMap(platDevices, PlatDevice::getId, PlatDevice::getCategory);
List<PlatElder> platElders = platElderService.list(new QueryWrapper<PlatElder>().lambda() List<PlatElder> platElders = platElderService.list(new QueryWrapper<PlatElder>().lambda()
.in(PlatElder::getOrgId, dto.getOrgIds())); .in(PlatElder::getOrgId, dto.getOrgIds()));
Map<String,String> elderNameMap = platElders.stream().collect(Collectors.toMap(PlatElder::getId,PlatElder::getName)); Map<String,String> elderNameMap = platElders.stream().collect(Collectors.toMap(PlatElder::getId,PlatElder::getName));
...@@ -494,6 +497,7 @@ public class DataScreenServiceImpl implements DataScreenService { ...@@ -494,6 +497,7 @@ public class DataScreenServiceImpl implements DataScreenService {
listVo.setAlarmDate(record.getAlarmDate().format(df)); listVo.setAlarmDate(record.getAlarmDate().format(df));
listVo.setAlarmTime(record.getAlarmDate().format(dft)); listVo.setAlarmTime(record.getAlarmDate().format(dft));
listVo.setAlarmRecordId(record.getId()); listVo.setAlarmRecordId(record.getId());
listVo.setDeviceCategory(deviceMap.get(record.getDeviceId()));
list.add(listVo); list.add(listVo);
} }
......
...@@ -469,44 +469,54 @@ public class PlatElderDayReportDayServiceImpl implements PlatElderDayReportDaySe ...@@ -469,44 +469,54 @@ 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) {
// 主要为了获取track,空间设备没有该字段,所以去除 List<PlatDevice> platDeviceListSpace = platElderRealTimeService.getSpaceDevice(elderId, deviceId);
// List<PlatDevice> platDeviceListSpace = platElderRealTimeService.getSpaceDevice(elderId, deviceId);
List<PlatDevice> platDeviceListFall = platElderRealTimeService.getFallDevice(elderId, deviceId); List<PlatDevice> platDeviceListFall = platElderRealTimeService.getFallDevice(elderId, deviceId);
if (CollectionUtils.isEmpty(platDeviceListFall)) { if (CollectionUtils.isEmpty(platDeviceListSpace) && CollectionUtils.isEmpty(platDeviceListFall)) {
return new ArrayList<>(10); return new ArrayList<>();
} }
List<PlatElderCoordinateVO> voList = new ArrayList<>(10); List<PlatElderCoordinateVO> voList = new ArrayList<>(10);
// platDeviceListSpace.forEach(e -> { platDeviceListSpace.forEach(e -> {
// List<DeviceInfoContentSpace> spaceList = iotProductDeviceService.getDeviceLogByTimeRangeSpace(e.getOriDeviceId(), 24 * 3600, start, end); List<DeviceInfoContentSpace> spaceList = iotProductDeviceService.getDeviceLogByTimeRangeSpace(e.getOriDeviceId(), 24 * 3600, start, end);
// voList.addAll(StreamUtil.map(spaceList, i -> { Map<String, Boolean> existMap = new HashMap<>();
// for (DeviceInfoContentSpace deviceInfoContentSpace : spaceList) {
// PlatElderCoordinateVO vo = new PlatElderCoordinateVO(); DeviceInfoContentSpace.Properties properties = deviceInfoContentSpace.getProperties();
// vo.setTimestamp(i.getTimestamp()); // 侧装 0 轨迹模式1 才有距离和角度
// vo.setDistance(i.getProperties().getDistance()); if (properties == null || properties.getMount() == null || properties.getMode() == null) {
// vo.setAngle(i.getProperties().getAngle()); continue;
// vo.setType(1); }
// vo.setPersonState(i.getProperties().getPersonState()); if (!(properties.getMount() == 0 && properties.getMode() == 1)) {
// vo.setMount(i.getProperties().getMount()); continue;
// vo.setDeviceId(e.getId()); }
// vo.setOriDeviceId(e.getOriDeviceId()); if (properties.getAngle() == null || properties.getDistance() == null) {
// continue;
// return vo; }
// String key = deviceInfoContentSpace.getDeviceId() + "_" + properties.getDistance() + "_" + properties.getAngle();
// }) if (!existMap.containsKey(key)) {
// ); existMap.put(key, true);
// PlatElderCoordinateVO vo = new PlatElderCoordinateVO();
// }); vo.setTimestamp(deviceInfoContentSpace.getTimestamp());
vo.setAngle(properties.getAngle());
vo.setDistance(properties.getDistance());
vo.setDeviceId(e.getId());
vo.setType(2);
vo.setPersonState(properties.getPersonState());
vo.setMount(properties.getMount());
vo.setOriDeviceId(e.getOriDeviceId());
voList.add(vo);
}
}
});
platDeviceListFall.forEach(e -> { platDeviceListFall.forEach(e -> {
List<DeviceInfoContentFall> fallList = iotProductDeviceService.getDeviceLogByTimeRangeFall(e.getOriDeviceId(), 2 * 24 * 3600, start, end); List<DeviceInfoContentFall> fallList = iotProductDeviceService.getDeviceLogByTimeRangeFall(e.getOriDeviceId(), 2 * 24 * 3600, start, end);
Map<String, Boolean> existMap = new HashMap<>(); Map<String, Boolean> existMap = new HashMap<>();
for (DeviceInfoContentFall deviceInfoContentFall : fallList) { for (DeviceInfoContentFall deviceInfoContentFall : fallList) {
DeviceInfoContentFall.Properties properties = deviceInfoContentFall.getProperties(); DeviceInfoContentFall.Properties properties = deviceInfoContentFall.getProperties();
if (properties == null || CollectionUtils.isEmpty(properties.getTrack())) { if (properties == null || (CollectionUtils.isEmpty(properties.getTrack()))) {
continue; continue;
} }
String key = deviceInfoContentFall.getDeviceId() + "_" + JSONObject.toJSONString(properties.getTrack()); String key = deviceInfoContentFall.getDeviceId() + "_" + JSONObject.toJSONString(properties.getTrack());
......
...@@ -30,4 +30,6 @@ public class PlatAlarmStatisticsListVo { ...@@ -30,4 +30,6 @@ public class PlatAlarmStatisticsListVo {
private String path; private String path;
@ApiModelProperty(value = "告警id") @ApiModelProperty(value = "告警id")
private String alarmRecordId; private String alarmRecordId;
@ApiModelProperty(value = "设备类型 0-呼吸心率雷达 1-空间人体雷达 2-跌倒检测雷达")
private String deviceCategory;
} }
...@@ -42,7 +42,7 @@ public class MqttPushClient { ...@@ -42,7 +42,7 @@ public class MqttPushClient {
try { try {
client = new MqttClient(host, clientId, new MemoryPersistence()); client = new MqttClient(host, clientId, new MemoryPersistence());
MqttConnectOptions options = new MqttConnectOptions(); MqttConnectOptions options = new MqttConnectOptions();
options.setCleanSession(false); options.setCleanSession(true);
options.setUserName(username); options.setUserName(username);
options.setPassword(password.toCharArray()); options.setPassword(password.toCharArray());
options.setConnectionTimeout(timeout); options.setConnectionTimeout(timeout);
......
...@@ -13,6 +13,7 @@ import com.makeit.entity.platform.device.PlatDevice; ...@@ -13,6 +13,7 @@ import com.makeit.entity.platform.device.PlatDevice;
import com.makeit.entity.saas.PlatTenant; import com.makeit.entity.saas.PlatTenant;
import com.makeit.entity.saas.analysis.SaasSleepAnalysisModel; import com.makeit.entity.saas.analysis.SaasSleepAnalysisModel;
import com.makeit.enums.platform.alarm.PlatAlarmConfigEnum; import com.makeit.enums.platform.alarm.PlatAlarmConfigEnum;
import com.makeit.enums.platform.device.PlatDeviceEnum;
import com.makeit.enums.redis.RedisConst; import com.makeit.enums.redis.RedisConst;
import com.makeit.external.strategy.OpenApiBaseStrategy; import com.makeit.external.strategy.OpenApiBaseStrategy;
import com.makeit.external.strategy.OpenApiBaseStrategyFactory; import com.makeit.external.strategy.OpenApiBaseStrategyFactory;
...@@ -74,7 +75,8 @@ public class PushCallback implements MqttCallbackExtended { ...@@ -74,7 +75,8 @@ public class PushCallback implements MqttCallbackExtended {
@Autowired @Autowired
private MqttConfig mqttConfig; private MqttConfig mqttConfig;
private static MqttClient client; @Autowired
private MqttPushClient mqttPushClient;
@Autowired @Autowired
private AlarmConfigCacheUtil alarmConfigCacheUtil; private AlarmConfigCacheUtil alarmConfigCacheUtil;
...@@ -98,38 +100,26 @@ public class PushCallback implements MqttCallbackExtended { ...@@ -98,38 +100,26 @@ public class PushCallback implements MqttCallbackExtended {
@Override @Override
public void connectionLost(Throwable cause) { public void connectionLost(Throwable cause) {
logger.info("连接断开,可以重连"); logger.info("连接断开,可以重连", cause);
int times = 1;
while (client == null || !client.isConnected()) {
logger.info("重新连接, 第" + (times++) + "次");
MqttPushClient mqttPushClient = mqttConfig.getMqttPushClient();
if (mqttPushClient != null && mqttPushClient.getMqttClient() != null && mqttPushClient.getMqttClient().isConnected()) {
logger.info("重连成功");
break;
}
logger.info("重连失败");
// 每隔10秒重试一次
try {
TimeUnit.SECONDS.sleep(10);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
} }
@Override @Override
public void messageArrived(String topic, MqttMessage message) throws Exception { public void messageArrived(String topic, MqttMessage message) {
// 收到消息并设置返回字符串格式 try {
String payload = new String(message.getPayload(), "UTF-8"); // 收到消息并设置返回字符串格式
String payload = new String(message.getPayload(), "UTF-8");
//logger.info("接收消息内容:payload格式:{}", payload); //logger.info("接收消息内容:payload格式:{}", payload);
// 解析数据 // 解析数据
DeviceInfo device = JSON.parseObject(payload, DeviceInfo.class); DeviceInfo device = JSON.parseObject(payload, DeviceInfo.class);
syncProperties(device); syncProperties(device);
checkAlarm(device); checkAlarm(device);
} catch (Exception e) {
logger.error("消息接收处理异常", e);
}
} }
@Override @Override
...@@ -138,8 +128,11 @@ public class PushCallback implements MqttCallbackExtended { ...@@ -138,8 +128,11 @@ public class PushCallback implements MqttCallbackExtended {
} }
@Override @Override
public void connectComplete(boolean b, String s) { public void connectComplete(boolean reconnect, String serverURI) {
logger.info("连接成功,连接方式:{}", b ? "重连" : "直连"); logger.info("连接成功,连接方式:{}", reconnect ? "重连" : "直连");
if (reconnect) {
mqttPushClient.subscribe(mqttConfig.getDefaultTopic(), 0);
}
} }
/** /**
...@@ -277,7 +270,9 @@ public class PushCallback implements MqttCallbackExtended { ...@@ -277,7 +270,9 @@ public class PushCallback implements MqttCallbackExtended {
* @param messageType * @param messageType
*/ */
private void handleOffBed(PlatDevice platDevice, JSONObject properties, String messageType) { private void handleOffBed(PlatDevice platDevice, JSONObject properties, String messageType) {
if (!PlatDeviceEnum.CategoryEnum.HEART.getValue().equals(platDevice.getCategory())) {
return;
}
List<PlatDevice> platDeviceList = deviceCacheUtil.getByDeviceId(platDevice.getOriDeviceId()); List<PlatDevice> platDeviceList = deviceCacheUtil.getByDeviceId(platDevice.getOriDeviceId());
if (CollUtil.isEmpty(platDeviceList)) { if (CollUtil.isEmpty(platDeviceList)) {
return; return;
......
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