| | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.ruoyi.dataInterchange.model.UPDisconnectReq; |
| | | import com.ruoyi.dataInterchange.model.enu.DataType; |
| | | import com.ruoyi.dataInterchange.netty.client.ChannelMap; |
| | | import com.ruoyi.dataInterchange.util.jtt809.packet.common.OuterPacket; |
| | | import com.ruoyi.system.api.feignClient.EnterpriseClient; |
| | | import com.ruoyi.system.api.model.Enterprise; |
| | | import io.netty.buffer.ByteBuf; |
| | | import io.netty.buffer.Unpooled; |
| | | 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.Component; |
| | | |
| | | import javax.annotation.Resource; |
| | |
| | | @Resource |
| | | private EnterpriseClient enterpriseClient; |
| | | |
| | | @Resource |
| | | private RedisTemplate redisTemplate; |
| | | |
| | | |
| | | /** |
| | | * 主链路注销 |
| | | * |
| | | * @param ctx |
| | | * @param out |
| | | */ |
| | | public void disconnect(ChannelHandlerContext ctx, OuterPacket out){ |
| | | public void disconnect(ChannelHandlerContext ctx, OuterPacket out) { |
| | | ByteBuf byteBuf = Unpooled.wrappedBuffer(out.getBody()); |
| | | UPDisconnectReq disconnectReq = new UPDisconnectReq().decode(byteBuf); |
| | | Enterprise data = enterpriseClient.getEnterprise(disconnectReq.getUserId() + "").getData(); |
| | | if(null != data){ |
| | | if(!data.getPassword().equals(disconnectReq.getPassword())){ |
| | | if (null != data) { |
| | | if (!data.getPassword().equals(disconnectReq.getPassword())) { |
| | | ctx.close(); |
| | | return; |
| | | } |
| | | OuterPacket rep = new OuterPacket(DataType.UP_DISCONNECT_RSP.getCode(), null); |
| | | log.info("主链路注销应答({}):{}", DataType.UP_DISCONNECT_RSP.getCode(), JSON.toJSONString(rep)); |
| | | ctx.writeAndFlush(rep); |
| | | ctx.flush(); |
| | | redisTemplate.delete("login:" + out.getGnsscenterId()); |
| | | } |
| | | } |
| | | } |