From 3aa9f732b013c778a666b00e4936462372878a5c Mon Sep 17 00:00:00 2001 From: Pu Zhibing <393733352@qq.com> Date: 星期一, 26 五月 2025 14:07:42 +0800 Subject: [PATCH] 集成MQTT对接公交主防数据 --- ruoyi-service/ruoyi-dataInterchange/src/main/java/com/ruoyi/dataInterchange/server/WarnMsgService.java | 16 ++++++++++++---- 1 files changed, 12 insertions(+), 4 deletions(-) diff --git a/ruoyi-service/ruoyi-dataInterchange/src/main/java/com/ruoyi/dataInterchange/server/WarnMsgService.java b/ruoyi-service/ruoyi-dataInterchange/src/main/java/com/ruoyi/dataInterchange/server/WarnMsgService.java index 2932e7e..810ba80 100644 --- a/ruoyi-service/ruoyi-dataInterchange/src/main/java/com/ruoyi/dataInterchange/server/WarnMsgService.java +++ b/ruoyi-service/ruoyi-dataInterchange/src/main/java/com/ruoyi/dataInterchange/server/WarnMsgService.java @@ -187,18 +187,21 @@ * 存储mqtt协议报警信息 */ public void saveWarnMsgService(JSONObject jsonObject) { - SubscriptionEvent subscriptionEvent = jsonObject.getObject("", SubscriptionEvent.class); + SubscriptionEvent subscriptionEvent = jsonObject.getObject("params", SubscriptionEvent.class); List<Event> events = subscriptionEvent.getEvents(); events.forEach(event -> { //车牌号 String srcName = event.getSrcName(); Alarm data = JSONObject.parseObject(event.getData(), Alarm.class); + if(!StringUtils.hasLength(data.getAlarmId())){ + return; + } UPWarnMsgAdptInfo upWarnMsgAdptInfo = upWarnMsgAdptInfoDao.findByInfoIdIs(data.getAlarmId()); if(null == upWarnMsgAdptInfo){ upWarnMsgAdptInfo = new UPWarnMsgAdptInfo(); } upWarnMsgAdptInfo.setVehicleNo(srcName); - upWarnMsgAdptInfo.setVehicleColor(data.getVehicleLicenseColor()); + upWarnMsgAdptInfo.setVehicleColor(null == data.getVehicleLicenseColor() ? 0 : data.getVehicleLicenseColor()); upWarnMsgAdptInfo.setWarnSrc(data.getSourceType() + 1); upWarnMsgAdptInfo.setWarnType(getAlarmType(data.getEventType())); upWarnMsgAdptInfo.setWarnTime(LocalDateTime.parse(data.getAlarmTime(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")).toEpochSecond(ZoneOffset.ofHours(8))); @@ -207,11 +210,16 @@ upWarnMsgAdptInfo.setLongitude(data.getLongitude().intValue()); upWarnMsgAdptInfo.setLatitude(data.getLatitude().intValue()); upWarnMsgAdptInfo.setAltitude(data.getHeight().intValue() / 10); - upWarnMsgAdptInfo.setSpeed(data.getSpeed().intValue() / 10000); - upWarnMsgAdptInfo.setVec2(data.getSpeed().intValue()); + upWarnMsgAdptInfo.setSpeed(data.getSpeed().intValue() / 100000); + upWarnMsgAdptInfo.setVec2(data.getSpeed().intValue() / 100000); upWarnMsgAdptInfo.setStatus(data.getStatus()); upWarnMsgAdptInfo.setDirection(data.getDirection() / 100); upWarnMsgAdptInfo.setInfoContent(data.getAlarmInfo()); + upWarnMsgAdptInfo.setInferiorPlatformId(25439966); + upWarnMsgAdptInfo.setCreateTime(LocalDateTime.now().toEpochSecond(ZoneOffset.ofHours(8))); + if(2 == upWarnMsgAdptInfo.getLevel()){ + return; + } upWarnMsgAdptInfoDao.save(upWarnMsgAdptInfo); }); } -- Gitblit v1.7.1