|
@ -4,6 +4,7 @@ import cn.hutool.core.date.DateUtil; |
|
|
import com.alibaba.fastjson.JSON; |
|
|
import com.alibaba.fastjson.JSON; |
|
|
import com.alibaba.fastjson.JSONArray; |
|
|
import com.alibaba.fastjson.JSONArray; |
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
import com.ruoyi.common.core.redis.RedisCache; |
|
|
import com.ruoyi.common.core.redis.RedisCache; |
|
|
import com.zc.business.constant.RedisKeyConstants; |
|
|
import com.zc.business.constant.RedisKeyConstants; |
|
|
import com.zc.business.domain.DcDevice; |
|
|
import com.zc.business.domain.DcDevice; |
|
@ -21,10 +22,9 @@ import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
import javax.annotation.Resource; |
|
|
import java.util.Date; |
|
|
import java.text.ParseException; |
|
|
import java.util.HashMap; |
|
|
import java.text.SimpleDateFormat; |
|
|
import java.util.List; |
|
|
import java.util.*; |
|
|
import java.util.Map; |
|
|
|
|
|
import java.util.stream.Collectors; |
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
@ -116,6 +116,11 @@ public class DeviceMessageHandler { |
|
|
if (IotProductEnum.WEATHER_DETECTOR.value().equals(productId)) { |
|
|
if (IotProductEnum.WEATHER_DETECTOR.value().equals(productId)) { |
|
|
weatherDetectorMessageHandle(data); |
|
|
weatherDetectorMessageHandle(data); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 护栏碰撞
|
|
|
|
|
|
if (IotProductEnum.GUARDRAIL_COLLISION.value().equals(productId)) { |
|
|
|
|
|
guardrailCollisionDeviceMessageHandle(data); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -248,6 +253,7 @@ public class DeviceMessageHandler { |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
//(有ID有框)
|
|
|
//(有ID有框)
|
|
|
private void extracted3(JSONObject data, DcWarning dcWarning) { |
|
|
private void extracted3(JSONObject data, DcWarning dcWarning) { |
|
|
//事件上报ID
|
|
|
//事件上报ID
|
|
@ -326,6 +332,7 @@ public class DeviceMessageHandler { |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 一站式情况调查站设备消息处理入口 |
|
|
* 一站式情况调查站设备消息处理入口 |
|
|
|
|
|
* |
|
|
* @param msg 设备消息 |
|
|
* @param msg 设备消息 |
|
|
*/ |
|
|
*/ |
|
|
private void oneStopDeviceMessageHandle(JSONObject 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 设备消息 |
|
|
* @param msg 设备消息 |
|
|
*/ |
|
|
*/ |
|
|
private void weatherDetectorMessageHandle(JSONObject msg) { |
|
|
private void weatherDetectorMessageHandle(JSONObject msg) { |
|
|