| | |
| | | import io.netty.channel.Channel; |
| | | import io.netty.channel.ChannelHandlerContext; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | |
| | | @Resource |
| | | private UPExgMsgTakeEwayBillAckDao upExgMsgTakeEwayBillAckDao; |
| | | |
| | | @Resource |
| | | private RedisTemplate redisTemplate; |
| | | |
| | | |
| | | public void up_exg_msg(ChannelHandlerContext ctx, OuterPacket out) { |
| | | if (!redisTemplate.hasKey("login:" + out.getGnsscenterId())) { |
| | | log.error("链路还未登录校验,拒绝连接"); |
| | | ctx.close(); |
| | | return; |
| | | } |
| | | UPExgMsg exgMsg = getExgMsg(out); |
| | | DataType dataType = DataType.getDataType(exgMsg.getDataType()); |
| | | log.info("主链路车辆动态信息交换子业务({}):{}", dataType.getCode(), out); |
| | | switch (dataType) { |
| | | case UP_EXG_MSG_REGISTER: |
| | | log.info("上传车辆注册信息({}):{}", DataType.UP_EXG_MSG_REGISTER.getCode(), out); |
| | |
| | | downExgMsgReportDriverInfo.setVehicleColor(VehicleColor); |
| | | downExgMsgReportDriverInfo.setDataType(DataType.DOWN_EXG_MSG_REPORT_DRIVER_INFO.getCode()); |
| | | downExgMsgReportDriverInfo.setDataLength(0); |
| | | log.info("上报驾驶员身份识别信息请求({}):{}", DataType.DOWN_EXG_MSG_REPORT_DRIVER_INFO.getCode(), JSON.toJSONString(downExgMsgReportDriverInfo)); |
| | | byte[] body = downExgMsgReportDriverInfo.encode(); |
| | | OuterPacket out = new OuterPacket(DataType.DOWN_EXG_MSG_REPORT_DRIVER_INFO.getCode(), body); |
| | | //获取从链路通道 |
| | | Channel channel = ChannelMap.getClientChannel(inferiorPlatformId); |
| | | if (null != channel && channel.isActive()) { |
| | | channel.writeAndFlush(out); |
| | | } else { |
| | | ctx.writeAndFlush(out); |
| | | log.info("上报驾驶员身份识别信息请求({}):{}", DataType.DOWN_EXG_MSG_REPORT_DRIVER_INFO.getCode(), JSON.toJSONString(downExgMsgReportDriverInfo)); |
| | | } |
| | | } |
| | | |
| | |
| | | * @param inferiorPlatformId |
| | | */ |
| | | public void down_exg_msg_take_ewaybill_req(int inferiorPlatformId, String vehicleNo, int VehicleColor) { |
| | | if (!redisTemplate.hasKey("login:" + inferiorPlatformId)) { |
| | | log.error("链路还未登录校验,拒绝连接"); |
| | | return; |
| | | } |
| | | DOWNExgMsgTakeEwaybillReq downExgMsgTakeEwaybillReq = new DOWNExgMsgTakeEwaybillReq(); |
| | | downExgMsgTakeEwaybillReq.setVehicleNo(vehicleNo); |
| | | downExgMsgTakeEwaybillReq.setVehicleColor(VehicleColor); |
| | | downExgMsgTakeEwaybillReq.setDataType(DataType.DOWN_EXG_MSG_REPORT_DRIVER_INFO.getCode()); |
| | | downExgMsgTakeEwaybillReq.setDataType(DataType.DOWN_EXG_MSG_TAKE_EWAYBILL_REQ.getCode()); |
| | | downExgMsgTakeEwaybillReq.setDataLength(0); |
| | | |
| | | log.info("上报车辆电子运单请求({}):{}", DataType.DOWN_EXG_MSG_TAKE_EWAYBILL_REQ.getCode(), JSON.toJSONString(downExgMsgTakeEwaybillReq)); |
| | | byte[] body = downExgMsgTakeEwaybillReq.encode(); |
| | | OuterPacket out = new OuterPacket(DataType.DOWN_EXG_MSG_TAKE_EWAYBILL_REQ.getCode(), body); |
| | | //获取从链路通道 |
| | | Channel channel = ChannelMap.getClientChannel(inferiorPlatformId); |
| | | if (null != channel && channel.isActive()) { |
| | | channel.writeAndFlush(out); |
| | | } else { |
| | | channel = ChannelMap.getServerChannel(inferiorPlatformId); |
| | | channel.writeAndFlush(out); |
| | | log.info("上报车辆电子运单请求({}):{}", DataType.DOWN_EXG_MSG_TAKE_EWAYBILL_REQ.getCode(), JSON.toJSONString(downExgMsgTakeEwaybillReq)); |
| | | } |
| | | } |
| | | |