1078-优化列表展示效果

This commit is contained in:
648540858
2024-03-14 18:04:28 +08:00
parent d4c531dc12
commit 23a72e94e6
21 changed files with 235 additions and 60 deletions

View File

@@ -50,9 +50,9 @@ public class Jt808Decoder extends ByteToMessageDecoder {
if (header.is2019Version()) {
header.setVersion(buf.readUnsignedByte());
String devId = ByteBufUtil.hexDump(buf.readSlice(10));
header.setDevId(devId.replaceFirst("^0*", ""));
header.setTerminalId(devId.replaceFirst("^0*", ""));
} else {
header.setDevId(ByteBufUtil.hexDump(buf.readSlice(6)).replaceFirst("^0*", ""));
header.setTerminalId(ByteBufUtil.hexDump(buf.readSlice(6)).replaceFirst("^0*", ""));
}
header.setSn(buf.readUnsignedShort());

View File

@@ -65,12 +65,12 @@ public class Jt808EncoderCmd extends MessageToByteEncoder<Cmd> {
byteBuf.writeByte(header.getVersion());
// 终端手机号
byteBuf.writeBytes(ByteBufUtil.decodeHexDump(Bin.strHexPaddingLeft(header.getDevId(), 20)));
byteBuf.writeBytes(ByteBufUtil.decodeHexDump(Bin.strHexPaddingLeft(header.getTerminalId(), 20)));
} else {
// 消息体属性
byteBuf.writeShort(encode.readableBytes());
byteBuf.writeBytes(ByteBufUtil.decodeHexDump(Bin.strHexPaddingLeft(header.getDevId(), 12)));
byteBuf.writeBytes(ByteBufUtil.decodeHexDump(Bin.strHexPaddingLeft(header.getTerminalId(), 12)));
}
// 消息体流水号

View File

@@ -10,6 +10,7 @@ import io.netty.handler.timeout.IdleState;
import io.netty.handler.timeout.IdleStateEvent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationEventPublisher;
/**
* @author QingtaiJiang
@@ -20,6 +21,13 @@ public class Jt808Handler extends ChannelInboundHandlerAdapter {
private final static Logger log = LoggerFactory.getLogger(Jt808Handler.class);
private ApplicationEventPublisher applicationEventPublisher = null;
public Jt808Handler(ApplicationEventPublisher applicationEventPublisher) {
this.applicationEventPublisher = applicationEventPublisher;
}
@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
if (msg instanceof Rs) {
@@ -42,6 +50,8 @@ public class Jt808Handler extends ChannelInboundHandlerAdapter {
Session session = ctx.channel().attr(Session.KEY).get();
log.info("< Tcp disconnect {}", session);
ctx.close();
applicationEventPublisher.publishEvent();
}
@Override

View File

@@ -69,7 +69,7 @@ public class TcpServer {
.addLast(new Jt808Decoder(applicationEventPublisher, service))
.addLast(new Jt808Encoder())
.addLast(new Jt808EncoderCmd())
.addLast(new Jt808Handler());
.addLast(new Jt808Handler(applicationEventPublisher));
}
});
ChannelFuture channelFuture = bootstrap.bind(port).sync();