From 3d4eeb82dd61f8951616dece2425e870116bc23d Mon Sep 17 00:00:00 2001 From: Pu Zhibing <393733352@qq.com> Date: 星期五, 04 四月 2025 15:56:37 +0800 Subject: [PATCH] 提交最终版本和配置线上环境 --- ruoyi-service/ruoyi-dataInterchange/src/main/java/com/ruoyi/dataInterchange/server/ExgMsgService.java | 49 ++++++++++++++++++++++++++++++++++++++++--------- 1 files changed, 40 insertions(+), 9 deletions(-) diff --git a/ruoyi-service/ruoyi-dataInterchange/src/main/java/com/ruoyi/dataInterchange/server/ExgMsgService.java b/ruoyi-service/ruoyi-dataInterchange/src/main/java/com/ruoyi/dataInterchange/server/ExgMsgService.java index 5fbf7fd..6ffff42 100644 --- a/ruoyi-service/ruoyi-dataInterchange/src/main/java/com/ruoyi/dataInterchange/server/ExgMsgService.java +++ b/ruoyi-service/ruoyi-dataInterchange/src/main/java/com/ruoyi/dataInterchange/server/ExgMsgService.java @@ -1,6 +1,7 @@ package com.ruoyi.dataInterchange.server; import com.alibaba.fastjson.JSON; +import com.ruoyi.dataInterchange.api.vo.GnssDataVo; import com.ruoyi.dataInterchange.dao.*; import com.ruoyi.dataInterchange.model.*; import com.ruoyi.dataInterchange.model.enu.DataType; @@ -12,6 +13,7 @@ import io.netty.channel.Channel; import io.netty.channel.ChannelHandlerContext; import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.BeanUtils; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Service; @@ -19,6 +21,7 @@ import java.time.LocalDateTime; import java.time.ZoneOffset; import java.util.Iterator; +import java.util.List; /** * @author zhibing.pu @@ -144,26 +147,37 @@ if (null == register) { upExgMsgRegisterDao.save(upExgMsgRegister); } - //上报驾驶员身份识别信息请求 - UPExgMsgReportDriverInfoAck byVehicleNo = upExgMsgReportDriverInfoAckDao.findByVehicleNo(upExgMsgRegister.getVehicleNo()); - if (null == byVehicleNo) { - down_exg_msg_report_driver_info(ctx, inferiorPlatformId, upExgMsgRegister.getVehicleNo(), upExgMsgRegister.getVehicleColor()); + } + + + /** + * 定时获取司机基础信息 + */ + public void taskReportDriverInfo() { + Iterator<UPExgMsgRegister> iterator = upExgMsgRegisterDao.findAll().iterator(); + while (iterator.hasNext()) { + UPExgMsgRegister register = iterator.next(); + + //上报驾驶员身份识别信息请求 + UPExgMsgReportDriverInfoAck byVehicleNo = upExgMsgReportDriverInfoAckDao.findByVehicleNo(register.getVehicleNo()); + if (null == byVehicleNo) { + down_exg_msg_report_driver_info(register.getInferiorPlatformId(), register.getVehicleNo(), register.getVehicleColor()); + } } + } /** * 上报驾驶员身份识别信息请求 - * - * @param ctx */ - public void down_exg_msg_report_driver_info(ChannelHandlerContext ctx, int inferiorPlatformId, String vehicleNo, int VehicleColor) { + public void down_exg_msg_report_driver_info(int inferiorPlatformId, String vehicleNo, int VehicleColor) { DOWNExgMsgReportDriverInfo downExgMsgReportDriverInfo = new DOWNExgMsgReportDriverInfo(); downExgMsgReportDriverInfo.setVehicleNo(vehicleNo); downExgMsgReportDriverInfo.setVehicleColor(VehicleColor); downExgMsgReportDriverInfo.setDataType(DataType.DOWN_EXG_MSG_REPORT_DRIVER_INFO.getCode()); downExgMsgReportDriverInfo.setDataLength(0); byte[] body = downExgMsgReportDriverInfo.encode(); - OuterPacket out = new OuterPacket(DataType.DOWN_EXG_MSG_REPORT_DRIVER_INFO.getCode(), body); + OuterPacket out = new OuterPacket(DataType.DOWN_EXG_MSG.getCode(), body); //获取从链路通道 Channel channel = ChannelMap.getClientChannel(inferiorPlatformId); if (null != channel && channel.isActive()) { @@ -183,6 +197,10 @@ upExgMsgRealLocation.setInferiorPlatformId(inferiorPlatformId); upExgMsgRealLocation.setCreateTime(LocalDateTime.now().toEpochSecond(ZoneOffset.ofHours(8))); upExgMsgRealLocationDao.save(upExgMsgRealLocation); + //修改车辆实时定位 + GnssDataVo vo = new GnssDataVo(); + BeanUtils.copyProperties(upExgMsgRealLocation.getGnssData(), vo); + redisTemplate.opsForValue().set("location:" + upExgMsgRealLocation.getVehicleNo(), vo); } @@ -215,7 +233,7 @@ downExgMsgTakeEwaybillReq.setDataLength(0); byte[] body = downExgMsgTakeEwaybillReq.encode(); - OuterPacket out = new OuterPacket(DataType.DOWN_EXG_MSG_TAKE_EWAYBILL_REQ.getCode(), body); + OuterPacket out = new OuterPacket(DataType.DOWN_EXG_MSG.getCode(), body); //获取从链路通道 Channel channel = ChannelMap.getClientChannel(inferiorPlatformId); if (null != channel && channel.isActive()) { @@ -237,6 +255,19 @@ upExgMsgHistoryLocation.setInferiorPlatformId(inferiorPlatformId); upExgMsgHistoryLocation.setCreateTime(LocalDateTime.now().toEpochSecond(ZoneOffset.ofHours(8))); upExgMsgHistoryLocationDao.save(upExgMsgHistoryLocation); + + //将数据存储实时定位数据表中 + List<GnssData> gnssData = upExgMsgHistoryLocation.getGnssData(); + for (GnssData gnssDatum : gnssData) { + UPExgMsgRealLocation upExgMsgRealLocation = new UPExgMsgRealLocation(); + upExgMsgRealLocation.setVehicleNo(upExgMsgHistoryLocation.getVehicleNo()); + upExgMsgRealLocation.setVehicleColor(upExgMsgHistoryLocation.getVehicleColor()); + upExgMsgRealLocation.setInferiorPlatformId(inferiorPlatformId); + upExgMsgRealLocation.setDataType(DataType.UP_EXG_MSG_REAL_LOCATION.getCode()); + upExgMsgRealLocation.setGnssData(gnssDatum); + upExgMsgRealLocation.setCreateTime(LocalDateTime.now().toEpochSecond(ZoneOffset.ofHours(8))); + upExgMsgRealLocationDao.save(upExgMsgRealLocation); + } } -- Gitblit v1.7.1