Browse Source

新增护栏碰撞设备事件上报处理逻辑

develop
zhaoxianglong 8 months ago
parent
commit
199b85bb39
  1. 3
      zc-business/src/main/java/com/zc/business/enums/IotProductEnum.java
  2. 123
      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

@ -13,6 +13,9 @@ public enum IotProductEnum {
// 行车诱导
TRAFFIC_GUIDANCE("8866"),
// 护栏碰撞
GUARDRAIL_COLLISION("hlpz"),
// 气象检测器
WEATHER_DETECTOR("zc-meteorological"),

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

@ -4,6 +4,7 @@ import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.ruoyi.common.core.redis.RedisCache;
import com.zc.business.constant.RedisKeyConstants;
import com.zc.business.domain.DcDevice;
@ -21,10 +22,9 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
/**
@ -116,6 +116,11 @@ public class DeviceMessageHandler {
if (IotProductEnum.WEATHER_DETECTOR.value().equals(productId)) {
weatherDetectorMessageHandle(data);
}
// 护栏碰撞
if (IotProductEnum.GUARDRAIL_COLLISION.value().equals(productId)) {
guardrailCollisionDeviceMessageHandle(data);
}
}
@ -229,26 +234,27 @@ public class DeviceMessageHandler {
extracted1(data, dcWarning);
}
//抛洒物(有ID有框)
if (illegalTrafficEventSubType.equals("abandonedObjectEnd")){
if (illegalTrafficEventSubType.equals("abandonedObjectEnd")) {
extracted3(data, dcWarning);
}
//事故(有ID有框)
if(illegalTrafficEventSubType.equals("trafficAccidentEnd")){
if (illegalTrafficEventSubType.equals("trafficAccidentEnd")) {
extracted3(data, dcWarning);
}
//车辆抛锚有ID有框)
if(illegalTrafficEventSubType.equals("singleVehicleBreakdownEnd")){
if (illegalTrafficEventSubType.equals("singleVehicleBreakdownEnd")) {
extracted3(data, dcWarning);
}
//违停(有ID有框)
if(illegalTrafficEventSubType.equals("illegalParkingEnd")){
if (illegalTrafficEventSubType.equals("illegalParkingEnd")) {
extracted3(data, dcWarning);
}
}
//(有ID有框)
//(有ID有框)
private void extracted3(JSONObject data, DcWarning dcWarning) {
//事件上报ID
String targetId = data.getString("targetId");
@ -267,7 +273,7 @@ public class DeviceMessageHandler {
String targetIdEvent = (String) hashMap.get("targetId");
//事件位置
String coordinateEvent = (String) hashMap.get("coordinate");
if (coordinate.equals(coordinateEvent)&&targetId.equals(targetIdEvent)) {
if (coordinate.equals(coordinateEvent) && targetId.equals(targetIdEvent)) {
DcWarning dcWarning2 = new DcWarning();
dcWarning2.setId(id);
//自动确定状态
@ -326,6 +332,7 @@ public class DeviceMessageHandler {
/**
* 一站式情况调查站设备消息处理入口
*
* @param msg 设备消息
*/
private void oneStopDeviceMessageHandle(JSONObject msg) {
@ -333,8 +340,76 @@ public class DeviceMessageHandler {
}
/**
* 护栏碰撞设备消息处理入口
*
* @param msg 设备消息
*/
private void guardrailCollisionDeviceMessageHandle(JSONObject msg) {
JSONObject dataJsonObject = msg.getJSONObject("data");
String serviceIP = dataJsonObject.getString("serviceIP");//告警ip
String timeOfFireAlarming = dataJsonObject.getString("timeOfFireAlarming");//告警时间
JSONArray jsonArray = dataJsonObject.getJSONArray("data");
for (Object o : jsonArray) {
JSONObject jsonObject = JSONObject.parseObject(o.toString());
String nodeAddress = jsonObject.getString("nodeAddress");//节点地址
String alarmType = jsonObject.getString("alarmType");//告警类型
String location = jsonObject.getString("location");//告警位置
String areaCode = jsonObject.getString("areaCode");//区域号
DcWarning dcWarning = new DcWarning();
LambdaQueryWrapper<DcDevice> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(DcDevice::getIotDeviceId, nodeAddress);
List<DcDevice> dcDevices = dcDeviceService.list(lambdaQueryWrapper);
String direction = "";
if (Objects.equals(location, "0")) {
dcWarning.setDirection("1");
direction = "上行右侧";
} else if (Objects.equals(location, "1")) {
dcWarning.setDirection("1");
direction = "上行左侧";
} else if (Objects.equals(location, "10")) {
dcWarning.setDirection("0");
direction = "下行右侧";
} else if (Objects.equals(location, "11")) {
dcWarning.setDirection("0");
direction = "下行左侧";
}
String eventType = "";
if (Objects.equals(alarmType, "1")) {
eventType = "碰撞";
} else if (Objects.equals(alarmType, "2")) {
eventType = "只倾斜无碰撞";
} else if (Objects.equals(alarmType, "3")) {
eventType = "碰撞后倾斜";
} else if (Objects.equals(alarmType, "4")) {
eventType = "应急车道被占";
} else if (Objects.equals(alarmType, "5")) {
eventType = "车离开应急车道";
}
SimpleDateFormat sdf = new SimpleDateFormat("yy年MM月dd日HH时mm分");
try {
Date date = sdf.parse(timeOfFireAlarming);
dcWarning.setWarningTime(date);
} catch (ParseException e) {
e.printStackTrace();
}
dcWarning.setStakeMark(dcDevices.get(0).getStakeMark());
dcWarning.setWarningType(9);
dcWarning.setCreateTime(new Date());
dcWarning.setWarningTitle("护栏碰撞上报事件:区域号为" + areaCode + "在" + timeOfFireAlarming + direction + "发生" + eventType + "事件");
dcWarning.setOtherConfig(dataJsonObject.toJSONString());
dcWarningService.insertDcWarning(dcWarning);
}
}
/**
* 气象检测器消息处理入口
*
* @param msg 设备消息
*/
private void weatherDetectorMessageHandle(JSONObject msg) {
@ -350,20 +425,20 @@ public class DeviceMessageHandler {
mdDeviceData.setTimeStamp(new Date());
mdDeviceData.setCreatorUserId("自动存储");
Map<String,Object> expands = new HashMap<>();
expands.put("rainFall",meteorologicalDetectorData.getRainfall()); //雨量
expands.put("windSpeed",meteorologicalDetectorData.getWindSpeed()); //风速
expands.put("windDirection",meteorologicalDetectorData.getWindDirection()); //风向
expands.put("temperature",meteorologicalDetectorData.getTemperature()); //大气温度
expands.put("humidity",meteorologicalDetectorData.getHumidity()); //大气湿度
expands.put("airPressure",meteorologicalDetectorData.getAtmosphericPressure()); //数字气压
expands.put("wet",meteorologicalDetectorData.getWetSlipperyCoefficient()); //湿滑
expands.put("rainXingTai",meteorologicalDetectorData.getPrecipitationType()); //雨量降水形态
expands.put("visibility",meteorologicalDetectorData.getVisibility()); //能见度
expands.put("pathContactLu",meteorologicalDetectorData.getRoadSurfaceTemperature()); //路面温度
expands.put("pathContactBing",meteorologicalDetectorData.getFreezingPointTemperature()); //冰点温度
expands.put("pathContactYan",meteorologicalDetectorData.getSalinityValue()); //路面盐度
expands.put("pathContactZhuang",meteorologicalDetectorData.getRemoteRoadSurfaceStatus()); //路面状况
Map<String, Object> expands = new HashMap<>();
expands.put("rainFall", meteorologicalDetectorData.getRainfall()); //雨量
expands.put("windSpeed", meteorologicalDetectorData.getWindSpeed()); //风速
expands.put("windDirection", meteorologicalDetectorData.getWindDirection()); //风向
expands.put("temperature", meteorologicalDetectorData.getTemperature()); //大气温度
expands.put("humidity", meteorologicalDetectorData.getHumidity()); //大气湿度
expands.put("airPressure", meteorologicalDetectorData.getAtmosphericPressure()); //数字气压
expands.put("wet", meteorologicalDetectorData.getWetSlipperyCoefficient()); //湿滑
expands.put("rainXingTai", meteorologicalDetectorData.getPrecipitationType()); //雨量降水形态
expands.put("visibility", meteorologicalDetectorData.getVisibility()); //能见度
expands.put("pathContactLu", meteorologicalDetectorData.getRoadSurfaceTemperature()); //路面温度
expands.put("pathContactBing", meteorologicalDetectorData.getFreezingPointTemperature()); //冰点温度
expands.put("pathContactYan", meteorologicalDetectorData.getSalinityValue()); //路面盐度
expands.put("pathContactZhuang", meteorologicalDetectorData.getRemoteRoadSurfaceStatus()); //路面状况
mdDeviceData.setExpands(JSONObject.toJSONString(expands));

Loading…
Cancel
Save