Browse Source

新增毫米波雷达事件处理

develop
zhaoxianglong 6 months ago
parent
commit
671531a5f1
  1. 3
      zc-business/src/main/java/com/zc/business/enums/IotProductEnum.java
  2. 97
      zc-business/src/main/java/com/zc/business/message/device/handler/DeviceMessageHandler.java

3
zc-business/src/main/java/com/zc/business/enums/IotProductEnum.java

@ -16,6 +16,9 @@ public enum IotProductEnum {
// 护栏碰撞
GUARDRAIL_COLLISION("hlpz"),
// 毫米波雷达
MILLIMETER_WAVE_RADAR("hmbld"),
// 气象检测器
WEATHER_DETECTOR("zc-meteorological"),

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

@ -133,6 +133,97 @@ public class DeviceMessageHandler {
if (IotProductEnum.GUARDRAIL_COLLISION.value().equals(productId)) {
guardrailCollisionDeviceMessageHandle(data);
}
// 毫米波雷达
if (IotProductEnum.MILLIMETER_WAVE_RADAR.value().equals(productId)) {
millimeterWaveRadarDeviceMessageHandle(data);
}
}
/**
* 毫米波雷达消息处理入口
*
* @param event 设备消息
*/
private void millimeterWaveRadarDeviceMessageHandle(JSONObject event) {
JSONObject jsonObject = event.getJSONObject("data");
String eventTopic = event.getString("event");
if (Objects.equals(eventTopic, "RADAR_TOPIC")) {
// 雷达目标检测事件
} else if (Objects.equals(eventTopic, "trafficAnalysis")) {
// 交通事件
String deviceId = event.getString("deviceId");
LambdaQueryWrapper<DcDevice> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(DcDevice::getIotDeviceId, deviceId);
List<DcDevice> dcDevices = dcDeviceService.list(lambdaQueryWrapper);
if (dcDevices.size() == 0) {
return;
}
DcDevice dcDevice = dcDevices.get(0);
String direction = dcDevice.getDirection();
String stakeMark = dcDevice.getStakeMark();
Date happenTime = jsonObject.getDate("happenTime");
SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日 HH:mm:ss");
String formattedDate = sdf.format(happenTime);
String directio;
if (Objects.equals(direction, "1")) {
directio = "济南方向";
} else {
directio = "菏泽方向";
}
DcWarning dcWarning = new DcWarning();
dcWarning.setStakeMark(stakeMark);
dcWarning.setDirection(direction);
dcWarning.setCreateTime(new Date());
dcWarning.setWarningTime(happenTime);
dcWarning.setWarningSource(2);
dcWarning.setWarningState(1);
String illegalTrafficEvent = jsonObject.getString("illegalTrafficEvent");
String eventName = "";
if (Objects.equals(illegalTrafficEvent, "congestion")) {
dcWarning.setWarningType(1);
dcWarning.setWarningSubclass("1-1");
eventName = "拥堵";
} else if (Objects.equals(illegalTrafficEvent, "wrongDirection")) {
dcWarning.setWarningType(5);
dcWarning.setWarningSubclass("5-1");
eventName = "逆行";
} else if (Objects.equals(illegalTrafficEvent, "Speed")) {
dcWarning.setWarningType(5);
dcWarning.setWarningSubclass("5-4");
eventName = "超速";
} else if (Objects.equals(illegalTrafficEvent, "laneChange")) {
dcWarning.setWarningType(5);
dcWarning.setWarningSubclass("5-6");
eventName = "违规变道";
} else if (Objects.equals(illegalTrafficEvent, "illegalParking")) {
dcWarning.setWarningType(4);
dcWarning.setWarningSubclass("4-1");
eventName = "停车";
} else if (Objects.equals(illegalTrafficEvent, "lowSpeed")) {
dcWarning.setWarningType(5);
dcWarning.setWarningSubclass("5-5");
eventName = "机动车低速行驶";
} else if (Objects.equals(illegalTrafficEvent, "notKeepDistance")) {
dcWarning.setWarningType(5);
dcWarning.setWarningSubclass("5-7");
eventName = "未保持安全车距";
}
dcWarning.setWarningTitle(stakeMark + " " + directio+ " " + "发生" + eventName + "事件");
dcWarning.setRemark(formattedDate+ " " + stakeMark+ " " + directio+ " " + "发生" + eventName + "事件");
dcWarning.setOtherConfig(event.toJSONString());
dcWarningService.insertDcWarning(dcWarning);
} else if (Objects.equals(eventTopic, "timeRange")) {
// 交通统计
} else if (Objects.equals(eventTopic, "realTime")) {
// 交通状态数据
}
}
@ -252,11 +343,11 @@ public class DeviceMessageHandler {
dcWarning.setOtherConfig(otherConfig.toString());
//异常天气等级 过滤
if (data.getInteger("warningType") == VISIBILITY_LEVEL) {
int WarningLevel=data.getInteger("visibilityLevel");
if (WarningLevel !=0){
int WarningLevel = data.getInteger("visibilityLevel");
if (WarningLevel != 0) {
dcWarningService.insertDcWarning(dcWarning);
}
}else {
} else {
dcWarningService.insertDcWarning(dcWarning);
}

Loading…
Cancel
Save