From 671531a5f1d13bcd96a0928c1c190bff68bb4903 Mon Sep 17 00:00:00 2001 From: zhaoxianglong Date: Mon, 27 May 2024 18:13:11 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=AF=AB=E7=B1=B3=E6=B3=A2?= =?UTF-8?q?=E9=9B=B7=E8=BE=BE=E4=BA=8B=E4=BB=B6=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/zc/business/enums/IotProductEnum.java | 3 + .../device/handler/DeviceMessageHandler.java | 97 ++++++++++++++++++- 2 files changed, 97 insertions(+), 3 deletions(-) diff --git a/zc-business/src/main/java/com/zc/business/enums/IotProductEnum.java b/zc-business/src/main/java/com/zc/business/enums/IotProductEnum.java index 5e449a50..655c652c 100644 --- a/zc-business/src/main/java/com/zc/business/enums/IotProductEnum.java +++ b/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"), diff --git a/zc-business/src/main/java/com/zc/business/message/device/handler/DeviceMessageHandler.java b/zc-business/src/main/java/com/zc/business/message/device/handler/DeviceMessageHandler.java index 4452e5cf..56a827f5 100644 --- a/zc-business/src/main/java/com/zc/business/message/device/handler/DeviceMessageHandler.java +++ b/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 lambdaQueryWrapper = new LambdaQueryWrapper<>(); + lambdaQueryWrapper.eq(DcDevice::getIotDeviceId, deviceId); + List 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); }