From 065c2d959a8e686ab03fee0454fbffa68a4d1411 Mon Sep 17 00:00:00 2001
From: Pu Zhibing <393733352@qq.com>
Date: 星期四, 05 六月 2025 16:11:19 +0800
Subject: [PATCH] 修改bug
---
ruoyi-service/ruoyi-dataInterchange/src/main/java/com/ruoyi/dataInterchange/server/WarnMsgService.java | 188 ++++++++++++++++++++++++++++++++++++++---------
1 files changed, 152 insertions(+), 36 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 50040d3..0197955 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
@@ -1,17 +1,16 @@
package com.ruoyi.dataInterchange.server;
import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson2.JSONArray;
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.dao.*;
import com.ruoyi.dataInterchange.model.*;
import com.ruoyi.dataInterchange.model.enu.DataType;
import com.ruoyi.dataInterchange.netty.client.ChannelMap;
+import com.ruoyi.dataInterchange.util.haikang.Artemis;
import com.ruoyi.dataInterchange.util.haikang.model.Alarm;
-import com.ruoyi.dataInterchange.util.haikang.model.AlarmPic;
import com.ruoyi.dataInterchange.util.haikang.model.Event;
+import com.ruoyi.dataInterchange.util.haikang.model.FindPicturesByAlarmIdRequest;
import com.ruoyi.dataInterchange.util.haikang.model.SubscriptionEvent;
import com.ruoyi.dataInterchange.util.jtt809.common.Jtt809Util;
import com.ruoyi.dataInterchange.util.jtt809.packet.common.OuterPacket;
@@ -30,6 +29,7 @@
import java.time.format.DateTimeFormatter;
import java.util.Arrays;
import java.util.List;
+import java.util.StringJoiner;
/**
* @author zhibing.pu
@@ -50,6 +50,9 @@
@Resource
private UPWarnMsgOperationInfoDao upWarnMsgOperationInfoDao;
+
+ @Resource
+ private UpWarnMsgFileListAckDao upWarnMsgFileListAckDao;
@Resource
private RedisTemplate redisTemplate;
@@ -82,6 +85,10 @@
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;
+ case UP_WARN_MSG_FILELIST_ACK:
+ log.info("报警附件目录请求应答({}):{}", DataType.UP_WARN_MSG_FILELIST_ACK.getCode(), out);
+ up_warn_msg_filelist_ack(ctx, out.getGnsscenterId(), warnMsg);
break;
default:
break;
@@ -156,6 +163,24 @@
}
}
upWarnMsgAdptInfoDao.save(upWarnMsgAdptInfo);
+
+ //请求报警附件(川标协议)
+ if(enterprise.contains(inferiorPlatformId)){
+ DOWNWarnMsgFileListReq downWarnMsgFileListReq = new DOWNWarnMsgFileListReq();
+ downWarnMsgFileListReq.setVehicleNo(upWarnMsgAdptInfo.getVehicleNo());
+ downWarnMsgFileListReq.setVehicleColor(upWarnMsgAdptInfo.getVehicleColor());
+ downWarnMsgFileListReq.setDataType(DataType.DOWN_WARN_MSG_FILELIST_REQ.getCode());
+ downWarnMsgFileListReq.setDataLength(32);
+ downWarnMsgFileListReq.setInfoId(upWarnMsgAdptInfo.getInfoId());
+ byte[] body = downWarnMsgFileListReq.encode();
+ OuterPacket out = new OuterPacket(DataType.DOWN_WARN_MSG.getCode(), inferiorPlatformId, body);
+ //获取从链路通道
+ Channel channel = ChannelMap.getClientChannel(inferiorPlatformId);
+ if (null != channel && channel.isActive()) {
+ channel.writeAndFlush(out);
+ log.info("报警附件目录请求({}):{}", DataType.DOWN_WARN_MSG_FILELIST_REQ.getCode(), JSON.toJSONString(downWarnMsgFileListReq));
+ }
+ }
}
@@ -172,17 +197,96 @@
upWarnMsgOperationInfoDao.save(upWarnMsgOperationInfo);
//修改报警处理结果
UPWarnMsgAdptInfo upWarnMsgAdptInfo = upWarnMsgAdptInfoDao.findByInfoIdIs(upWarnMsgOperationInfo.getInfoId());
- upWarnMsgAdptInfo.setResult(upWarnMsgOperationInfo.getResult());
- upWarnMsgAdptInfoDao.save(upWarnMsgAdptInfo);
+ if(null != upWarnMsgAdptInfo){
+ upWarnMsgAdptInfo.setResult(upWarnMsgOperationInfo.getResult());
+ upWarnMsgAdptInfoDao.save(upWarnMsgAdptInfo);
+ }
}
/**
- * 定时任务督办报警请求
+ * 报警附件目录请求应答
+ * @param ctx
+ * @param inferiorPlatformId
+ * @param warnMsg
+ */
+ public void up_warn_msg_filelist_ack(ChannelHandlerContext ctx, int inferiorPlatformId, WarnMsg warnMsg){
+ UpWarnMsgFileListAck upWarnMsgFileListAck = new UpWarnMsgFileListAck().decode(warnMsg).decode(warnMsg);
+ upWarnMsgFileListAck.setInferiorPlatformId(inferiorPlatformId);
+ upWarnMsgFileListAck.setCreateTime(LocalDateTime.now().toEpochSecond(ZoneOffset.ofHours(8)));
+ upWarnMsgFileListAckDao.save(upWarnMsgFileListAck);
+ //修改报警附件数据
+ UPWarnMsgAdptInfo upWarnMsgAdptInfo = upWarnMsgAdptInfoDao.findByInfoIdIs(upWarnMsgFileListAck.getInfoId());
+ if(upWarnMsgFileListAck.getFileList().size() > 0){
+ StringJoiner joiner = new StringJoiner(",");
+ upWarnMsgFileListAck.getFileList().forEach(file->{
+ if(file.getFileType() == 0x00){
+ joiner.add(file.getFileUrl());
+ }
+ });
+ upWarnMsgAdptInfo.setPicUrl(joiner.toString());
+ }else{
+ upWarnMsgAdptInfo.setPicUrl("*");
+ }
+ upWarnMsgAdptInfoDao.save(upWarnMsgAdptInfo);
+ }
+
+
+
+ /**
+ * 定时任务督办报警请求和附件请求
*/
public void taskUrgeTodo() {
List<UPWarnMsgAdptInfo> list = upWarnMsgAdptInfoDao.findByResultIsAndLevelNotNullAndPushTimeBefore(0x00, LocalDateTime.now().toEpochSecond(ZoneOffset.ofHours(8)));
for (UPWarnMsgAdptInfo upWarnMsgAdptInfo : list) {
+ Integer inferiorPlatformId = upWarnMsgAdptInfo.getInferiorPlatformId();
+ //海康威视直接走接口
+ if(25439966 == inferiorPlatformId){
+ try {
+ if(!StringUtils.hasLength(upWarnMsgAdptInfo.getPicUrl())){
+ FindPicturesByAlarmIdRequest findPicturesByAlarmIdRequest = new FindPicturesByAlarmIdRequest();
+ findPicturesByAlarmIdRequest.setAlarmId(upWarnMsgAdptInfo.getInfoId());
+ long warnTime = upWarnMsgAdptInfo.getWarnTime();
+ String format = LocalDateTime.ofEpochSecond(warnTime, 0, ZoneOffset.ofHours(8)).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS"));
+ format = format.replace(" ", "T") + "+08:00";
+ findPicturesByAlarmIdRequest.setAlarmTime(format);
+ String pictures = Artemis.findPicturesByAlarmId(findPicturesByAlarmIdRequest);
+ JSONObject jsonObject = JSONObject.parseObject(pictures);
+ Integer code = jsonObject.getInteger("code");
+ if(0 == code){
+ JSONArray data = jsonObject.getJSONArray("data");
+ StringJoiner joiner = new StringJoiner(",");
+ for (int i = 0; i < data.size(); i++) {
+ JSONObject jsonObject1 = data.getJSONObject(0);
+ String url = jsonObject1.getString("url");
+ joiner.add(url);
+ }
+ upWarnMsgAdptInfo.setPicUrl(joiner.length() > 0 ? joiner.toString() : "*");
+ upWarnMsgAdptInfoDao.save(upWarnMsgAdptInfo);
+ }
+ }
+ }catch (Exception e){
+ e.printStackTrace();
+ }
+ }
+ //请求报警附件(川标协议)
+ if(enterprise.contains(inferiorPlatformId) && !StringUtils.hasLength(upWarnMsgAdptInfo.getPicUrl())){
+ DOWNWarnMsgFileListReq downWarnMsgFileListReq = new DOWNWarnMsgFileListReq();
+ downWarnMsgFileListReq.setVehicleNo(upWarnMsgAdptInfo.getVehicleNo());
+ downWarnMsgFileListReq.setVehicleColor(upWarnMsgAdptInfo.getVehicleColor());
+ downWarnMsgFileListReq.setDataType(DataType.DOWN_WARN_MSG_FILELIST_REQ.getCode());
+ downWarnMsgFileListReq.setDataLength(32);
+ downWarnMsgFileListReq.setInfoId(upWarnMsgAdptInfo.getInfoId());
+ byte[] body = downWarnMsgFileListReq.encode();
+ OuterPacket out = new OuterPacket(DataType.DOWN_WARN_MSG.getCode(), inferiorPlatformId, body);
+ //获取从链路通道
+ Channel channel = ChannelMap.getClientChannel(inferiorPlatformId);
+ if (null != channel && channel.isActive()) {
+ channel.writeAndFlush(out);
+ log.info("报警附件目录请求({}):{}", DataType.DOWN_WARN_MSG_FILELIST_REQ.getCode(), JSON.toJSONString(downWarnMsgFileListReq));
+ }
+ }
+
down_warn_msg_urge_todo_req(upWarnMsgAdptInfo);
}
}
@@ -241,11 +345,19 @@
}
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.getLatitude()){
+// upWarnMsgAdptInfo.setLongitude(data.getLatitude().intValue() * 10);
+// }
+// if(null != data.getLongitude()){
+// upWarnMsgAdptInfo.setLatitude(data.getLongitude().intValue());
+// }
+ //调用获取实时定位数据
+ UPExgMsgRealLocation upExgMsgRealLocation = upExgMsgRealLocationDao.findByVehicleNoOrderByCreateTimeDesc(upWarnMsgAdptInfo.getVehicleNo());
+ if (null != upExgMsgRealLocation) {
+ GnssData gnssData = upExgMsgRealLocation.getGnssData();
+ upWarnMsgAdptInfo.setSpeed(gnssData.getVec1());
+ upWarnMsgAdptInfo.setLongitude(gnssData.getLon());
+ upWarnMsgAdptInfo.setLatitude(gnssData.getLat());
}
if(null != data.getHeight()){
upWarnMsgAdptInfo.setAltitude(data.getHeight().intValue() / 10);
@@ -266,7 +378,34 @@
if(!warnType.contains(upWarnMsgAdptInfo.getWarnType())){
return;
}
+ upWarnMsgAdptInfo.setResult(0x00);
+
+ //获取报警抓拍图片
+ if(data.getPicNum() > 0){
+ FindPicturesByAlarmIdRequest findPicturesByAlarmIdRequest = new FindPicturesByAlarmIdRequest();
+ findPicturesByAlarmIdRequest.setAlarmId(data.getAlarmId());
+ long warnTime = upWarnMsgAdptInfo.getWarnTime();
+ String format = LocalDateTime.ofEpochSecond(warnTime, 0, ZoneOffset.ofHours(8)).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS"));
+ format = format.replace(" ", "T") + "+08:00";
+ findPicturesByAlarmIdRequest.setAlarmTime(format);
+ String pictures = Artemis.findPicturesByAlarmId(findPicturesByAlarmIdRequest);
+ JSONObject jsonObject1 = JSONObject.parseObject(pictures);
+ Integer code = jsonObject1.getInteger("code");
+ if(0 == code){
+ JSONArray data1 = jsonObject1.getJSONArray("data");
+ StringJoiner joiner = new StringJoiner(",");
+ for (int i = 0; i < data1.size(); i++) {
+ JSONObject jsonObject2 = data1.getJSONObject(0);
+ String url = jsonObject2.getString("url");
+ joiner.add(url);
+ }
+ upWarnMsgAdptInfo.setPicUrl(joiner.toString());
+ }
+ }else{
+ upWarnMsgAdptInfo.setPicUrl("*");
+ }
upWarnMsgAdptInfoDao.save(upWarnMsgAdptInfo);
+
}catch (Exception e){
e.printStackTrace();
}
@@ -439,29 +578,6 @@
return 0;
}
}
-
- /**
- * 存储mqtt协议报警图片信息
- */
- public void saveWarnMsgPicService(JSONObject jsonObject) {
- SubscriptionEvent subscriptionEvent = jsonObject.getObject("", SubscriptionEvent.class);
- List<Event> events = subscriptionEvent.getEvents();
- events.forEach(event -> {
- AlarmPic data = JSONObject.parseObject(event.getData(), AlarmPic.class);
- if(StringUtils.hasLength(data.getAlarmId())){
- UPWarnMsgAdptInfo upWarnMsgAdptInfo = upWarnMsgAdptInfoDao.findByInfoIdIs(data.getAlarmId());
- if(null != upWarnMsgAdptInfo){
- upWarnMsgAdptInfo.setPicUrl(data.getUrl());
- upWarnMsgAdptInfoDao.save(upWarnMsgAdptInfo);
- }else{
- upWarnMsgAdptInfo = new UPWarnMsgAdptInfo();
- upWarnMsgAdptInfo.setInfoId(data.getAlarmId());
- upWarnMsgAdptInfoDao.save(upWarnMsgAdptInfo);
- }
- }
- });
- }
-
}
--
Gitblit v1.7.1