Compare commits

...

3 Commits

Author SHA1 Message Date
阿斌
1140fcedb9
Pre Merge pull request !36 from 阿斌/N/A 2026-05-20 03:21:34 +00:00
lin
e545b00a8f 部标-tcp空闲超时时间改为可配置 2026-05-20 11:20:56 +08:00
阿斌
da98101aac
update src/main/resources/civilCode.csv.
行政规划错误。江苏南通海门市,修改为海门区,浙江杭州删除下城区、江干区,新增钱塘区,临平区

Signed-off-by: 阿斌 <38912748@qq.com>
2024-12-15 08:58:42 +00:00
5 changed files with 18 additions and 7 deletions

View File

@ -3,6 +3,7 @@ package com.genersoft.iot.vmp.jt1078.codec.netty;
import com.genersoft.iot.vmp.jt1078.codec.decode.Jt808Decoder;
import com.genersoft.iot.vmp.jt1078.codec.encode.Jt808Encoder;
import com.genersoft.iot.vmp.jt1078.codec.encode.Jt808EncoderCmd;
import com.genersoft.iot.vmp.jt1078.config.JT1078Config;
import com.genersoft.iot.vmp.jt1078.proc.factory.CodecFactory;
import com.genersoft.iot.vmp.jt1078.service.Ijt1078Service;
import io.netty.bootstrap.ServerBootstrap;
@ -38,13 +39,15 @@ public class TcpServer {
private EventLoopGroup workerGroup = null;
private ApplicationEventPublisher applicationEventPublisher = null;
private Ijt1078Service service = null;
private final JT1078Config jt1078Config;
private final ByteBuf DECODER_JT808 = Unpooled.wrappedBuffer(new byte[]{0x7e});
public TcpServer(Integer port, ApplicationEventPublisher applicationEventPublisher, Ijt1078Service service) {
public TcpServer(Integer port, ApplicationEventPublisher applicationEventPublisher, Ijt1078Service service, JT1078Config jt1078Config) {
this.port = port;
this.applicationEventPublisher = applicationEventPublisher;
this.service = service;
this.jt1078Config = jt1078Config;
}
private void startTcpServer() {
@ -63,7 +66,7 @@ public class TcpServer {
@Override
public void initChannel(NioSocketChannel channel) {
channel.pipeline()
.addLast(new IdleStateHandler(10, 0, 0, TimeUnit.MINUTES))
.addLast(new IdleStateHandler(jt1078Config.getReaderIdleTime(), 0, 0, TimeUnit.MINUTES))
.addLast(new DelimiterBasedFrameDecoder(1024 * 2, DECODER_JT808))
.addLast(new Jt808Decoder(applicationEventPublisher, service))
.addLast(new Jt808Encoder())

View File

@ -26,8 +26,11 @@ public class JT1078AutoConfiguration {
@Autowired
private Ijt1078Service service;
@Autowired
private JT1078Config jt1078Config;
@Bean(initMethod = "start", destroyMethod = "stop")
public TcpServer jt1078Server(@Value("${jt1078.port}") Integer port) {
return new TcpServer(port, applicationEventPublisher, service);
return new TcpServer(port, applicationEventPublisher, service, jt1078Config);
}
}

View File

@ -17,4 +17,9 @@ public class JT1078Config {
private String password;
private Boolean record = false;
/**
* IdleStateHandler reader idle timeout, unit: minutes
*/
private Integer readerIdleTime = 15;
}

View File

@ -861,7 +861,7 @@
320623,如东县,3206
320681,启东市,3206
320682,如皋市,3206
320684,海门,3206
320684,海门,3206
320685,海安市,3206
3207,连云港市,32
320703,连云区,3207
@ -918,8 +918,6 @@
33,浙江省,
3301,杭州市,33
330102,上城区,3301
330103,下城区,3301
330104,江干区,3301
330105,拱墅区,3301
330106,西湖区,3301
330108,滨江区,3301
@ -927,6 +925,8 @@
330110,余杭区,3301
330111,富阳区,3301
330112,临安区,3301
330113,临平区,3301
330114,钱塘区,3301
330122,桐庐县,3301
330127,淳安县,3301
330182,建德市,3301

1 编号 名称 上级
861 320623 如东县 3206
862 320681 启东市 3206
863 320682 如皋市 3206
864 320684 海门市 海门区 3206
865 320685 海安市 3206
866 3207 连云港市 32
867 320703 连云区 3207
918 33 浙江省
919 3301 杭州市 33
920 330102 上城区 3301
330103 下城区 3301
330104 江干区 3301
921 330105 拱墅区 3301
922 330106 西湖区 3301
923 330108 滨江区 3301
925 330110 余杭区 3301
926 330111 富阳区 3301
927 330112 临安区 3301
928 330113 临平区 3301
929 330114 钱塘区 3301
930 330122 桐庐县 3301
931 330127 淳安县 3301
932 330182 建德市 3301

View File

@ -20,7 +20,7 @@ public class JT1078ServerTest {
public static void main(String[] args) {
System.out.println("Starting jt1078 server...");
TcpServer tcpServer = new TcpServer(21078, null, null);
TcpServer tcpServer = new TcpServer(21078, null, null, null);
tcpServer.start();
System.out.println("Start jt1078 server success!");