Browse Source

优化护栏碰撞和毫米波雷达事件上报内容

develop
zhaoxianglong 5 months ago
parent
commit
d2c92b30be
  1. 37
      zc-business/src/main/java/com/zc/business/message/device/handler/DeviceMessageHandler.java

37
zc-business/src/main/java/com/zc/business/message/device/handler/DeviceMessageHandler.java

@ -22,7 +22,6 @@ import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import javax.annotation.Resource;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
@ -134,6 +133,7 @@ public class DeviceMessageHandler {
if (IotProductEnum.GUARDRAIL_COLLISION.value().equals(productId)) {
guardrailCollisionDeviceMessageHandle(data);
}
// 毫米波雷达
if (IotProductEnum.MILLIMETER_WAVE_RADAR.value().equals(productId)) {
millimeterWaveRadarDeviceMessageHandle(data);
@ -151,7 +151,7 @@ public class DeviceMessageHandler {
if (Objects.equals(eventTopic, UniversalEnum.RADAR_TOPIC.getValue())) {
// 雷达目标检测事件
} else if (Objects.equals(eventTopic, UniversalEnum.TRAFFIC_ANALYSIS.getNumber())) {
} else if (Objects.equals(eventTopic, UniversalEnum.TRAFFIC_ANALYSIS.getValue())) {
// 交通事件
String deviceId = event.getString("deviceId");
@ -220,7 +220,7 @@ public class DeviceMessageHandler {
} else if (Objects.equals(eventTopic, UniversalEnum.TIME_RANGE.getValue())) {
// 交通统计
} else if (Objects.equals(eventTopic, UniversalEnum.REAL_TIME.getNumber())) {
} else if (Objects.equals(eventTopic, UniversalEnum.REAL_TIME.getValue())) {
// 交通状态数据
}
@ -491,6 +491,7 @@ public class DeviceMessageHandler {
String serviceIP = dataJsonObject.getString("serviceIP");//告警ip
String timeOfFireAlarming = dataJsonObject.getString("timeOfFireAlarming");//告警时间
JSONArray jsonArray = dataJsonObject.getJSONArray("data");
String deviceId = msg.getString("deviceId");
for (Object o : jsonArray) {
JSONObject jsonObject = JSONObject.parseObject(o.toString());
String nodeAddress = jsonObject.getString("nodeAddress");//节点地址
@ -500,9 +501,11 @@ public class DeviceMessageHandler {
DcWarning dcWarning = new DcWarning();
LambdaQueryWrapper<DcDevice> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(DcDevice::getIotDeviceId, nodeAddress);
lambdaQueryWrapper.eq(DcDevice::getIotDeviceId, deviceId);
List<DcDevice> dcDevices = dcDeviceService.list(lambdaQueryWrapper);
if (dcDevices.size() == UniversalEnum.ZERO.getNumber()) {
return;
}
String direction = UniversalEnum.EMPTY_STRING.getValue();
if (Objects.equals(location, UniversalEnum.ZERO.getValue())) {
dcWarning.setDirection(UniversalEnum.ONE.getValue());
@ -545,20 +548,14 @@ public class DeviceMessageHandler {
dcWarning.setWarningSubclass(UniversalEnum.FOUR_EIGHT.getValue());
}
SimpleDateFormat sdf = new SimpleDateFormat(UniversalEnum.PURE_CHINESE_CHARACTER_TIME_FORMATS.getValue());
try {
Date date = sdf.parse(timeOfFireAlarming);
dcWarning.setWarningTime(date);
} catch (ParseException e) {
e.printStackTrace();
}
dcWarning.setStakeMark(dcDevices.get(UniversalEnum.ZERO.getNumber()).getStakeMark());
dcWarning.setWarningType(UniversalEnum.NINE.getNumber());
dcWarning.setWarningSubclass(UniversalEnum.FOUR.getValue());
dcWarning.setWarningTime(new Date());
DcDevice dcDevice = dcDevices.get(UniversalEnum.ZERO.getNumber());
dcWarning.setStakeMark(dcDevice.getStakeMark());
dcWarning.setDirection(dcDevice.getDirection());
dcWarning.setWarningSource(UniversalEnum.FOUR.getNumber());
dcWarning.setWarningState(UniversalEnum.ONE.getNumber());
dcWarning.setCreateTime(new Date());
dcWarning.setDirection("护栏碰撞上报事件:区域号为" + areaCode + "在20" + timeOfFireAlarming + direction + UniversalEnum.TAKE_PLACE.getValue() + eventType + UniversalEnum.INCIDENT.getValue());
dcWarning.setRemark("护栏碰撞上报事件:区域号为" + areaCode + "在20" + timeOfFireAlarming + direction + UniversalEnum.TAKE_PLACE.getValue() + eventType + UniversalEnum.INCIDENT.getValue());
dcWarning.setWarningTitle("护栏碰撞在20" + timeOfFireAlarming + direction + UniversalEnum.TAKE_PLACE.getValue() + eventType + UniversalEnum.INCIDENT.getValue());
dcWarning.setOtherConfig(dataJsonObject.toJSONString());
dcWarningService.insertDcWarning(dcWarning);
@ -587,7 +584,7 @@ public class DeviceMessageHandler {
//设备名称
meteorologicalDetectorData.setDeviceName(deviceName+UniversalEnum.OPEN_PARENTHESIS.getValue()+stakeMark+UniversalEnum.CLOSING_PARENTHESIS.getValue());
meteorologicalDetectorData.setDeviceName(deviceName + UniversalEnum.OPEN_PARENTHESIS.getValue() + stakeMark + UniversalEnum.CLOSING_PARENTHESIS.getValue());
//位置
meteorologicalDetectorData.setStakeMark(stakeMark);
//方向
@ -618,7 +615,7 @@ public class DeviceMessageHandler {
DcWarning dcWarning = new DcWarning();
dcWarning.setWarningState(UniversalEnum.ONE.getNumber());
dcWarning.setRemark(new Date()+" "+content);
dcWarning.setRemark(new Date() + UniversalEnum.BLANK_SPACE.getValue() + content);
dcWarning.setWarningTime(new Date());
dcWarning.setWarningType(UniversalEnum.EIGHT_ONE.getNumber());
dcWarning.setWarningSubclass(UniversalEnum.EIGHT_ONE.getValue());
@ -665,7 +662,7 @@ public class DeviceMessageHandler {
String string = object.toString();
DcWarning dcWarning = new DcWarning();
dcWarning.setWarningState(UniversalEnum.ONE.getNumber());
dcWarning.setRemark(new Date()+" "+content);
dcWarning.setRemark(new Date() + UniversalEnum.BLANK_SPACE.getValue() + content);
dcWarning.setWarningTime(new Date());
dcWarning.setWarningType(UniversalEnum.EIGHT_FOUR.getNumber());
dcWarning.setWarningSubclass(UniversalEnum.EIGHT_FOUR.getValue());

Loading…
Cancel
Save