diff --git a/src/main/java/com/telpo/dipperposition/handler/NettyServerHandler.java b/src/main/java/com/telpo/dipperposition/handler/NettyServerHandler.java index 519e1d1..3f60e52 100644 --- a/src/main/java/com/telpo/dipperposition/handler/NettyServerHandler.java +++ b/src/main/java/com/telpo/dipperposition/handler/NettyServerHandler.java @@ -22,6 +22,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; +import javax.annotation.PostConstruct; import java.io.InputStream; import java.time.LocalDateTime; @@ -42,6 +43,8 @@ public class NettyServerHandler extends ChannelInboundHandlerAdapter { private static String AST_POS_CMD_BYTE = "504f53"; private static String AST_EPH_CMD_BYTE = "455048"; + @Autowired + private PositionConfig positionConfig; @Autowired private IDipperAstTimeAsyncTaskService dipperTimeAsyncTaskService; @@ -51,10 +54,17 @@ public class NettyServerHandler extends ChannelInboundHandlerAdapter { @Autowired private IDipperDataAsyncTaskService dipperDataAsyncTaskService; - @Autowired - private NettyServerConfig nettyServerConfig; - @Autowired - private PositionConfig positionConfig; + private static NettyServerHandler nettyServerHandler; + + @PostConstruct + public void init() { + nettyServerHandler = this; + nettyServerHandler.positionConfig = this.positionConfig; + nettyServerHandler.dipperTimeAsyncTaskService = this.dipperTimeAsyncTaskService; + nettyServerHandler.dipperAstPosAsyncTaskService = this.dipperAstPosAsyncTaskService; + nettyServerHandler.dipperDataAsyncTaskService = this.dipperDataAsyncTaskService; + } + /** * 客户端连接会触发 */ @@ -124,7 +134,7 @@ public class NettyServerHandler extends ChannelInboundHandlerAdapter { // if (dipperTimeAsyncTaskService == null) { // dipperTimeAsyncTaskService = new DipperAstTimeAsyncTaskServiceImpl(); // } - channelAns = dipperTimeAsyncTaskService.pushAstTime(); + channelAns = nettyServerHandler.dipperTimeAsyncTaskService.pushAstTime(); } // 发送SDBP-AST-POS获取辅助位置信息 @@ -146,7 +156,7 @@ public class NettyServerHandler extends ChannelInboundHandlerAdapter { // if (dipperAstPosAsyncTaskService == null) { // dipperAstPosAsyncTaskService = new DipperAstPosAsyncTaskServiceImpl(); // } - channelAns = dipperAstPosAsyncTaskService.pushAstPos(ipAddress); + channelAns = nettyServerHandler.dipperAstPosAsyncTaskService.pushAstPos(ipAddress); // (ipAddress, // "/csv/provinceLonAlt.csv", // "湖北省", @@ -161,7 +171,7 @@ public class NettyServerHandler extends ChannelInboundHandlerAdapter { // if (dipperDataAsyncTaskService == null) { // dipperDataAsyncTaskService = new DipperDataAsyncTaskServiceImpl(); // } - channelAns = dipperDataAsyncTaskService.getAstEPH(); + channelAns = nettyServerHandler.dipperDataAsyncTaskService.getAstEPH(); } log.info(channelAns);