Commit 39dc5c78 by 罗志长

Merge branch 'dev'

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