From b554a106bc1b06e0320b642d16c31554ae558301 Mon Sep 17 00:00:00 2001 From: Pu Zhibing <393733352@qq.com> Date: 星期二, 03 六月 2025 17:28:11 +0800 Subject: [PATCH] 新增加川标报警处理结果 --- ruoyi-service/ruoyi-dataInterchange/src/main/java/com/ruoyi/dataInterchange/server/WarnMsgService.java | 114 +++++++++++++++++++++++++++++++++++++++++++-------------- 1 files changed, 86 insertions(+), 28 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..50040d3 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 @@ -4,6 +4,7 @@ import com.alibaba.fastjson2.JSONObject; import com.ruoyi.dataInterchange.dao.UPExgMsgRealLocationDao; import com.ruoyi.dataInterchange.dao.UPWarnMsgAdptInfoDao; +import com.ruoyi.dataInterchange.dao.UPWarnMsgOperationInfoDao; import com.ruoyi.dataInterchange.dao.UPWarnMsgUrgeTodoAckDao; import com.ruoyi.dataInterchange.model.*; import com.ruoyi.dataInterchange.model.enu.DataType; @@ -48,12 +49,18 @@ private UPWarnMsgAdptInfoDao upWarnMsgAdptInfoDao; @Resource + private UPWarnMsgOperationInfoDao upWarnMsgOperationInfoDao; + + @Resource private RedisTemplate redisTemplate; @Resource private UPExgMsgRealLocationDao upExgMsgRealLocationDao; //走川标的公司 private List<Integer> enterprise = Arrays.asList(17458936, 43984060, 13914394); + //固定报警类型 + private List<Integer> warnType = Arrays.asList(0x0201, 0x0202, 0x0301, 0x000B, 0x0012, 0x0203, 0x0208, 0x0002, 0x0211, 0x0212, 0x0214, 0x0213, 0x0215, 0x0217, 0x0307); + public void up_warn_msg(ChannelHandlerContext ctx, OuterPacket out) { if (!redisTemplate.hasKey("login:" + out.getGnsscenterId())) { @@ -71,6 +78,10 @@ case UP_WARN_MSG_ADPT_INFO: log.info("上报报警信息({}):{}", DataType.UP_WARN_MSG_ADPT_INFO.getCode(), out); up_warn_msg_adpt_info(ctx, out.getGnsscenterId(), warnMsg); + break; + case UP_WARN_MSG_OPERATION_INFO: + log.info("上报报警处理信息({}):{}", DataType.UP_WARN_MSG_OPERATION_INFO.getCode(), out); + up_warn_msg_operation_info(ctx, out.getGnsscenterId(), warnMsg); break; default: break; @@ -129,6 +140,9 @@ */ public void up_warn_msg_adpt_info(ChannelHandlerContext ctx, int inferiorPlatformId, WarnMsg warnMsg) { UPWarnMsgAdptInfo upWarnMsgAdptInfo = enterprise.contains(inferiorPlatformId) ? new UPWarnMsgAdptInfo().decode2(warnMsg) : new UPWarnMsgAdptInfo().decode1(warnMsg); + if(!warnType.contains(upWarnMsgAdptInfo.getWarnType())){ + return; + } upWarnMsgAdptInfo.setResult(0x00); upWarnMsgAdptInfo.setInferiorPlatformId(inferiorPlatformId); upWarnMsgAdptInfo.setCreateTime(LocalDateTime.now().toEpochSecond(ZoneOffset.ofHours(8))); @@ -140,9 +154,25 @@ upWarnMsgAdptInfo.setLongitude(gnssData.getLon()); upWarnMsgAdptInfo.setLatitude(gnssData.getLat()); } - }else if(2 != upWarnMsgAdptInfo.getLevel()){ - return; } + upWarnMsgAdptInfoDao.save(upWarnMsgAdptInfo); + } + + + /** + * 上报报警处理信息 + * @param ctx + * @param inferiorPlatformId + * @param warnMsg + */ + public void up_warn_msg_operation_info(ChannelHandlerContext ctx, int inferiorPlatformId, WarnMsg warnMsg) { + UPWarnMsgOperationInfo upWarnMsgOperationInfo = new UPWarnMsgOperationInfo().decode(warnMsg); + upWarnMsgOperationInfo.setInferiorPlatformId(inferiorPlatformId); + upWarnMsgOperationInfo.setCreateTime(LocalDateTime.now().toEpochSecond(ZoneOffset.ofHours(8))); + upWarnMsgOperationInfoDao.save(upWarnMsgOperationInfo); + //修改报警处理结果 + UPWarnMsgAdptInfo upWarnMsgAdptInfo = upWarnMsgAdptInfoDao.findByInfoIdIs(upWarnMsgOperationInfo.getInfoId()); + upWarnMsgAdptInfo.setResult(upWarnMsgOperationInfo.getResult()); upWarnMsgAdptInfoDao.save(upWarnMsgAdptInfo); } @@ -187,33 +217,61 @@ * 存储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); - UPWarnMsgAdptInfo upWarnMsgAdptInfo = upWarnMsgAdptInfoDao.findByInfoIdIs(data.getAlarmId()); - if(null == upWarnMsgAdptInfo){ - upWarnMsgAdptInfo = new UPWarnMsgAdptInfo(); - } - upWarnMsgAdptInfo.setVehicleNo(srcName); - upWarnMsgAdptInfo.setVehicleColor(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))); - upWarnMsgAdptInfo.setInfoId(data.getAlarmId()); - upWarnMsgAdptInfo.setLevel(getLevel(data.getLevel())); - 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.setStatus(data.getStatus()); - upWarnMsgAdptInfo.setDirection(data.getDirection() / 100); - upWarnMsgAdptInfo.setInfoContent(data.getAlarmInfo()); - upWarnMsgAdptInfoDao.save(upWarnMsgAdptInfo); - }); + if(null != events){ + events.forEach(event -> { + try { + //车牌号 + 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(null == data.getVehicleLicenseColor() ? 0 : data.getVehicleLicenseColor()); + upWarnMsgAdptInfo.setWarnSrc(data.getSourceType() + 1); + upWarnMsgAdptInfo.setWarnType(getAlarmType(data.getEventType())); + if(null != data.getAlarmTime()){ + upWarnMsgAdptInfo.setWarnTime(LocalDateTime.parse(data.getAlarmTime(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")).toEpochSecond(ZoneOffset.ofHours(8))); + } + upWarnMsgAdptInfo.setInfoId(data.getAlarmId()); + upWarnMsgAdptInfo.setLevel(getLevel(data.getLevel())); + if(null != data.getLatitude()){ + upWarnMsgAdptInfo.setLongitude(data.getLatitude().intValue() * 10); + } + if(null != data.getLongitude()){ + upWarnMsgAdptInfo.setLatitude(data.getLongitude().intValue()); + } + if(null != data.getHeight()){ + upWarnMsgAdptInfo.setAltitude(data.getHeight().intValue() / 10); + } + if(null != data.getSpeed()){ + upWarnMsgAdptInfo.setSpeed(data.getSpeed().intValue() / 100000); + } + if(null != data.getSpeed()){ + upWarnMsgAdptInfo.setVec2(data.getSpeed().intValue() / 100000); + } + upWarnMsgAdptInfo.setStatus(data.getStatus()); + if(null != data.getDirection()){ + upWarnMsgAdptInfo.setDirection(data.getDirection() / 100); + } + upWarnMsgAdptInfo.setInfoContent(data.getAlarmInfo()); + upWarnMsgAdptInfo.setInferiorPlatformId(25439966); + upWarnMsgAdptInfo.setCreateTime(LocalDateTime.now().toEpochSecond(ZoneOffset.ofHours(8))); + if(!warnType.contains(upWarnMsgAdptInfo.getWarnType())){ + return; + } + upWarnMsgAdptInfoDao.save(upWarnMsgAdptInfo); + }catch (Exception e){ + e.printStackTrace(); + } + }); + } } public int getAlarmType(long eventType){ -- Gitblit v1.7.1