| | |
| | | package com.zy.acs.gateway.handler; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.zy.acs.common.constant.RedisConstant; |
| | | import com.zy.acs.common.domain.AgvProtocol; |
| | | import com.zy.acs.common.domain.mq.DeviceMessage; |
| | | import com.zy.acs.common.domain.protocol.*; |
| | | import com.zy.acs.common.utils.RedisSupport; |
| | | import com.zy.acs.gateway.AbstractInboundHandler; |
| | |
| | | ctx.writeAndFlush(pathAckPac); |
| | | |
| | | // 写入队列 |
| | | rabbitTemplate.convertAndSend(RabbitmqConstant.TOPIC_EXCHANGE, RabbitmqConstant.ROUTING_KEY_UP.replaceFirst(RabbitmqConstant.SPILT_REGEX, uniqueNo).replaceFirst(RabbitmqConstant.SPILT_REGEX, ProtocolType.PATH_ACK.name()), agv_01_up); |
| | | rabbitTemplate.convertAndSend(RabbitmqConstant.TOPIC_EXCHANGE, RabbitmqConstant.ROUTING_KEY_DOWN.replaceFirst(RabbitmqConstant.SPILT_REGEX, uniqueNo).replaceFirst(RabbitmqConstant.SPILT_REGEX, ProtocolType.PATH_ACK_RESPONSE.name()), agv_b1_down); |
| | | rabbitTemplate.convertAndSend(RabbitmqConstant.TOPIC_EXCHANGE, RabbitmqConstant.ROUTING_KEY_UP.replaceFirst(RabbitmqConstant.SPILT_REGEX, uniqueNo).replaceFirst(RabbitmqConstant.SPILT_REGEX, ProtocolType.PATH_ACK.name()), new DeviceMessage(pac.getSourceHexStr())); |
| | | rabbitTemplate.convertAndSend(RabbitmqConstant.TOPIC_EXCHANGE, RabbitmqConstant.ROUTING_KEY_DOWN.replaceFirst(RabbitmqConstant.SPILT_REGEX, uniqueNo).replaceFirst(RabbitmqConstant.SPILT_REGEX, ProtocolType.PATH_ACK_RESPONSE.name()), new DeviceMessage(pathAckPac.getSourceHexStr())); |
| | | |
| | | break label; |
| | | |
| | |
| | | AGV_06_UP agv_06_up = (AGV_06_UP) pac.getBody().getMessageBody(); |
| | | redis.push(RedisConstant.AGV_COMPLETE_FLAG, AgvProtocol.build(uniqueNo).setMessageBody(agv_06_up)); |
| | | // 写入队列 |
| | | rabbitTemplate.convertAndSend(RabbitmqConstant.TOPIC_EXCHANGE, RabbitmqConstant.ROUTING_KEY_UP.replaceFirst(RabbitmqConstant.SPILT_REGEX, uniqueNo).replaceFirst(RabbitmqConstant.SPILT_REGEX, ProtocolType.PICK_PLACE_REQUEST.name()), agv_06_up); |
| | | rabbitTemplate.convertAndSend(RabbitmqConstant.TOPIC_EXCHANGE, RabbitmqConstant.ROUTING_KEY_UP.replaceFirst(RabbitmqConstant.SPILT_REGEX, uniqueNo).replaceFirst(RabbitmqConstant.SPILT_REGEX, ProtocolType.PICK_PLACE_REQUEST.name()), new DeviceMessage(pac.getSourceHexStr())); |
| | | |
| | | break label; |
| | | |
| | |
| | | , pac.getHeader().getUniqueNo() + "_" + agv_02_up.getSerialNo() |
| | | , agv_02_up); |
| | | // 写入队列 |
| | | rabbitTemplate.convertAndSend(RabbitmqConstant.TOPIC_EXCHANGE, RabbitmqConstant.ROUTING_KEY_UP.replaceFirst(RabbitmqConstant.SPILT_REGEX, uniqueNo).replaceFirst(RabbitmqConstant.SPILT_REGEX, ProtocolType.COMMAND_ACK.name()), agv_02_up); |
| | | rabbitTemplate.convertAndSend(RabbitmqConstant.TOPIC_EXCHANGE, RabbitmqConstant.ROUTING_KEY_UP.replaceFirst(RabbitmqConstant.SPILT_REGEX, uniqueNo).replaceFirst(RabbitmqConstant.SPILT_REGEX, ProtocolType.COMMAND_ACK.name()), new DeviceMessage(pac.getSourceHexStr())); |
| | | |
| | | break label; |
| | | |
| | |
| | | redis.push(RedisConstant.AGV_COMPLETE_FLAG, AgvProtocol.build(uniqueNo).setMessageBody(agv_11_up)); |
| | | |
| | | // 写入队列 |
| | | rabbitTemplate.convertAndSend(RabbitmqConstant.TOPIC_EXCHANGE, RabbitmqConstant.ROUTING_KEY_UP.replaceFirst(RabbitmqConstant.SPILT_REGEX, uniqueNo).replaceFirst(RabbitmqConstant.SPILT_REGEX, ProtocolType.ACTION_COMPLETE.name()), agv_11_up); |
| | | rabbitTemplate.convertAndSend(RabbitmqConstant.TOPIC_EXCHANGE, RabbitmqConstant.ROUTING_KEY_UP.replaceFirst(RabbitmqConstant.SPILT_REGEX, uniqueNo).replaceFirst(RabbitmqConstant.SPILT_REGEX, ProtocolType.ACTION_COMPLETE.name()), new DeviceMessage(pac.getSourceHexStr())); |
| | | |
| | | // 动作完成应答 |
| | | if (null != ackType) { |
| | |
| | | |
| | | ctx.writeAndFlush(ackPac); |
| | | |
| | | rabbitTemplate.convertAndSend(RabbitmqConstant.TOPIC_EXCHANGE, RabbitmqConstant.ROUTING_KEY_DOWN.replaceFirst(RabbitmqConstant.SPILT_REGEX, uniqueNo).replaceFirst(RabbitmqConstant.SPILT_REGEX, ackType.name()), agv_a1_down); |
| | | rabbitTemplate.convertAndSend(RabbitmqConstant.TOPIC_EXCHANGE, RabbitmqConstant.ROUTING_KEY_DOWN.replaceFirst(RabbitmqConstant.SPILT_REGEX, uniqueNo).replaceFirst(RabbitmqConstant.SPILT_REGEX, ackType.name()), new DeviceMessage(ackPac.getSourceHexStr())); |
| | | } |
| | | |
| | | break label; |
| | |
| | | // |
| | | // }); |
| | | // 写入队列 |
| | | rabbitTemplate.convertAndSend(RabbitmqConstant.TOPIC_EXCHANGE, RabbitmqConstant.ROUTING_KEY_UP.replaceFirst(RabbitmqConstant.SPILT_REGEX, uniqueNo).replaceFirst(RabbitmqConstant.SPILT_REGEX, ProtocolType.DATA_CODE_REPORT.name()), agv_12_up); |
| | | rabbitTemplate.convertAndSend(RabbitmqConstant.TOPIC_EXCHANGE, RabbitmqConstant.ROUTING_KEY_UP.replaceFirst(RabbitmqConstant.SPILT_REGEX, uniqueNo).replaceFirst(RabbitmqConstant.SPILT_REGEX, ProtocolType.DATA_CODE_REPORT.name()), new DeviceMessage(pac.getSourceHexStr())); |
| | | |
| | | break label; |
| | | |
| | |
| | | // }); |
| | | |
| | | // 写入队列 |
| | | rabbitTemplate.convertAndSend(RabbitmqConstant.TOPIC_EXCHANGE, RabbitmqConstant.ROUTING_KEY_UP.replaceFirst(RabbitmqConstant.SPILT_REGEX, uniqueNo).replaceFirst(RabbitmqConstant.SPILT_REGEX, ProtocolType.DATA_WITHOUT_CODE_REPORT.name()), agv_13_up); |
| | | rabbitTemplate.convertAndSend(RabbitmqConstant.TOPIC_EXCHANGE, RabbitmqConstant.ROUTING_KEY_UP.replaceFirst(RabbitmqConstant.SPILT_REGEX, uniqueNo).replaceFirst(RabbitmqConstant.SPILT_REGEX, ProtocolType.DATA_WITHOUT_CODE_REPORT.name()), new DeviceMessage(pac.getSourceHexStr())); |
| | | |
| | | break label; |
| | | |
| | |
| | | // |
| | | // }); |
| | | // 写入队列 |
| | | rabbitTemplate.convertAndSend(RabbitmqConstant.TOPIC_EXCHANGE, RabbitmqConstant.ROUTING_KEY_UP.replaceFirst(RabbitmqConstant.SPILT_REGEX, uniqueNo).replaceFirst(RabbitmqConstant.SPILT_REGEX, ProtocolType.HEARTBEAT_REPORT.name()), agv_03_up); |
| | | rabbitTemplate.convertAndSend(RabbitmqConstant.TOPIC_EXCHANGE, RabbitmqConstant.ROUTING_KEY_UP.replaceFirst(RabbitmqConstant.SPILT_REGEX, uniqueNo).replaceFirst(RabbitmqConstant.SPILT_REGEX, ProtocolType.HEARTBEAT_REPORT.name()), new DeviceMessage(pac.getSourceHexStr())); |
| | | |
| | | break label; |
| | | |
| | |
| | | // }); |
| | | |
| | | // 写入队列 |
| | | rabbitTemplate.convertAndSend(RabbitmqConstant.TOPIC_EXCHANGE, RabbitmqConstant.ROUTING_KEY_UP.replaceFirst(RabbitmqConstant.SPILT_REGEX, uniqueNo).replaceFirst(RabbitmqConstant.SPILT_REGEX, ProtocolType.SILO_REPORT.name()), agv_70_up); |
| | | rabbitTemplate.convertAndSend(RabbitmqConstant.TOPIC_EXCHANGE, RabbitmqConstant.ROUTING_KEY_UP.replaceFirst(RabbitmqConstant.SPILT_REGEX, uniqueNo).replaceFirst(RabbitmqConstant.SPILT_REGEX, ProtocolType.SILO_REPORT.name()), new DeviceMessage(pac.getSourceHexStr())); |
| | | |
| | | break label; |
| | | |
| | |
| | | AGV_F0_UP agv_f0_up = (AGV_F0_UP) pac.getBody().getMessageBody(); |
| | | redis.push(RedisConstant.AGV_DATA_FLAG, AgvProtocol.build(uniqueNo).setMessageBody(agv_f0_up)); |
| | | // 写入队列 |
| | | rabbitTemplate.convertAndSend(RabbitmqConstant.TOPIC_EXCHANGE, RabbitmqConstant.ROUTING_KEY_UP.replaceFirst(RabbitmqConstant.SPILT_REGEX, uniqueNo).replaceFirst(RabbitmqConstant.SPILT_REGEX, ProtocolType.LOGIN_REPORT.name()), agv_f0_up); |
| | | rabbitTemplate.convertAndSend(RabbitmqConstant.TOPIC_EXCHANGE, RabbitmqConstant.ROUTING_KEY_UP.replaceFirst(RabbitmqConstant.SPILT_REGEX, uniqueNo).replaceFirst(RabbitmqConstant.SPILT_REGEX, ProtocolType.LOGIN_REPORT.name()), new DeviceMessage(pac.getSourceHexStr())); |
| | | |
| | | // 登录应答 |
| | | if (null != ackType) { |
| | | AgvPackage ackPac = AckMsgBuilder.ofSuccess(pac, ackType); |
| | | |
| | | ctx.writeAndFlush(ackPac); |
| | | rabbitTemplate.convertAndSend(RabbitmqConstant.TOPIC_EXCHANGE, RabbitmqConstant.ROUTING_KEY_DOWN.replaceFirst(RabbitmqConstant.SPILT_REGEX, uniqueNo).replaceFirst(RabbitmqConstant.SPILT_REGEX, ackType.name()), ackPac.getBody().getMessageBody()); |
| | | rabbitTemplate.convertAndSend(RabbitmqConstant.TOPIC_EXCHANGE, RabbitmqConstant.ROUTING_KEY_DOWN.replaceFirst(RabbitmqConstant.SPILT_REGEX, uniqueNo).replaceFirst(RabbitmqConstant.SPILT_REGEX, ackType.name()), new DeviceMessage(ackPac.getSourceHexStr())); |
| | | } |
| | | |
| | | // 30s redis |
| | |
| | | redis.push(RedisConstant.AGV_DATA_FLAG, AgvProtocol.build(uniqueNo).setMessageBody(agv_04_up)); |
| | | |
| | | // 写入队列 |
| | | rabbitTemplate.convertAndSend(RabbitmqConstant.TOPIC_EXCHANGE, RabbitmqConstant.ROUTING_KEY_UP.replaceFirst(RabbitmqConstant.SPILT_REGEX, uniqueNo).replaceFirst(RabbitmqConstant.SPILT_REGEX, ProtocolType.FAULT_REPORT.name()), agv_04_up); |
| | | rabbitTemplate.convertAndSend(RabbitmqConstant.TOPIC_EXCHANGE, RabbitmqConstant.ROUTING_KEY_UP.replaceFirst(RabbitmqConstant.SPILT_REGEX, uniqueNo).replaceFirst(RabbitmqConstant.SPILT_REGEX, ProtocolType.FAULT_REPORT.name()), new DeviceMessage(pac.getSourceHexStr())); |
| | | |
| | | break label; |
| | | |