Browse Source

优化非机预警事件上报存储格式

develop
zhaoxianglong 10 months ago
parent
commit
2e35eafb10
  1. 27
      zc-business/src/main/java/com/zc/business/controller/NonAutomaticWarningController.java

27
zc-business/src/main/java/com/zc/business/controller/NonAutomaticWarningController.java

@ -7,7 +7,6 @@ import com.hikvision.artemis.sdk.ArtemisHttpUtil;
import com.hikvision.artemis.sdk.config.ArtemisConfig;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.uuid.IdUtils;
import com.zc.business.domain.DcWarning;
import com.zc.business.service.IDcWarningService;
import io.swagger.annotations.Api;
@ -102,12 +101,7 @@ public class NonAutomaticWarningController extends BaseController {
client.setCallback(new MqttCallback() {
public void connectionLost(Throwable cause) {
System.out.println("断开连接");
//try {
// eventSubscription();
//} catch (Exception e) {
// throw new RuntimeException(e);
//}
System.out.println("断开连接..........");
}
public void messageArrived(String topic, MqttMessage message) {
@ -122,16 +116,21 @@ public class NonAutomaticWarningController extends BaseController {
events.forEach(item -> {
JSONObject event = JSONObject.parseObject(String.valueOf(item));
JSONObject data = event.getJSONObject("data");
String crossingIndexCode = event.getString("crossingIndexCode");
Date happenTime = event.getDate("happenTime");
String srcName = event.getString("srcName").split("收费站")[1];
String illegalTrafficEvent = data.getString("illegalTrafficEvent");
String directionName = data.getString("directionName");
String crossingName = data.getString("crossingName");
String targetPicUrl = data.getString("targetPicUrl");
String targetPicUrl = "https://10.0.81.28"+data.getString("targetPicUrl");
String laneNo = data.getString("laneNo");
ArrayList<String> pictures = new ArrayList<>();
pictures.add(targetPicUrl);
JSONObject jsonObject = new JSONObject();
jsonObject.put("pictures",pictures);
DcWarning dcWarning = new DcWarning();
dcWarning.setOtherConfig(jsonObjString);
dcWarning.setOtherConfig(String.valueOf(jsonObject));
dcWarning.setLane(laneNo);
switch (illegalTrafficEvent) {
case "congestion"://拥堵
dcWarning.setWarningType(1);
@ -224,10 +223,10 @@ public class NonAutomaticWarningController extends BaseController {
//System.out.println("开始监听" + topicName.getString("6274883585"));
client.subscribe(topicName.getString("6274879489"), 1);
System.out.println("开始监听" + topicName.getString("6274879489"));
client.subscribe(topicName.getString("7768236033"), 1);
System.out.println("开始监听" + topicName.getString("7768236033"));
client.subscribe(topicName.getString("7835340801"), 1);
System.out.println("开始监听" + topicName.getString("7835340801"));
//client.subscribe(topicName.getString("7768236033"), 1);
//System.out.println("开始监听" + topicName.getString("7768236033"));
//client.subscribe(topicName.getString("7835340801"), 1);
//System.out.println("开始监听" + topicName.getString("7835340801"));
} catch (Exception e) {
e.printStackTrace();
}

Loading…
Cancel
Save