diff --git a/src/main/java/com/telpo/dipperposition/co/PositionConfigInfo.java b/src/main/java/com/telpo/dipperposition/co/PositionConfigInfo.java index f4f3de0..47c2d16 100644 --- a/src/main/java/com/telpo/dipperposition/co/PositionConfigInfo.java +++ b/src/main/java/com/telpo/dipperposition/co/PositionConfigInfo.java @@ -6,6 +6,7 @@ import lombok.ToString; import okhttp3.*; import okhttp3.internal.ws.RealWebSocket; import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Component; @@ -20,14 +21,15 @@ import javax.net.SocketFactory; @Getter @Setter @Component +@ConfigurationProperties(prefix = "position-server") public class PositionConfigInfo { private String serverAddr; - private String timeAsycServerPort; + private String timeAsycPort; - private String posAsycServerPort; + private String posAsycPort; - private String starsAsycServerPort; + private String starsAsycPort; } diff --git a/src/main/java/com/telpo/dipperposition/config/PositionConfig.java b/src/main/java/com/telpo/dipperposition/config/PositionConfig.java index aae0be6..6e7d36e 100644 --- a/src/main/java/com/telpo/dipperposition/config/PositionConfig.java +++ b/src/main/java/com/telpo/dipperposition/config/PositionConfig.java @@ -30,32 +30,32 @@ public class PositionConfig { //@Value(value = "${spring.application.name}") //private String name; - @Value(value = "${position.server.serverAddr}") - private String serverAddr; - - @Value(value = "${position.server.timeAsycPort}") - private String timeAsycServerPort; - - @Value(value = "${position.server.posAsycPort}") - private String posAsycServerPort; - - @Value(value = "${position.server.starsAsycPort}") - private String starsAsycServerPort; +// @Value(value = "${position.server.serverAddr}") +// private String serverAddr; +// +// @Value(value = "${position.server.timeAsycPort}") +// private String timeAsycServerPort; +// +// @Value(value = "${position.server.posAsycPort}") +// private String posAsycServerPort; +// +// @Value(value = "${position.server.starsAsycPort}") +// private String starsAsycServerPort; PositionConfig() { //hello = configurableApplicationContext.getEnvironment().getProperty("position.hello"); //name = configurableApplicationContext.getEnvironment().getProperty("spring.application.name"); } - - @Bean (name = "positionConfigInfo") - public PositionConfigInfo positionConfigInfo(){ - PositionConfigInfo configInfo = new PositionConfigInfo(); - configInfo.setServerAddr(this.serverAddr); - configInfo.setTimeAsycServerPort(this.timeAsycServerPort); - configInfo.setPosAsycServerPort(this.posAsycServerPort); - configInfo.setStarsAsycServerPort(this.starsAsycServerPort); - System.out.print(configInfo.toString()); - return configInfo; - } +// +// @Bean (name = "positionConfigInfo") +// public PositionConfigInfo positionConfigInfo(){ +// PositionConfigInfo configInfo = new PositionConfigInfo(); +// configInfo.setServerAddr(this.serverAddr); +// configInfo.setTimeAsycServerPort(this.timeAsycServerPort); +// configInfo.setPosAsycServerPort(this.posAsycServerPort); +// configInfo.setStarsAsycServerPort(this.starsAsycServerPort); +// System.out.print(configInfo.toString()); +// return configInfo; +// } } diff --git a/src/main/java/com/telpo/dipperposition/server/DipperPositionServer.java b/src/main/java/com/telpo/dipperposition/server/DipperPositionServer.java index c9c0fe6..6df87f5 100644 --- a/src/main/java/com/telpo/dipperposition/server/DipperPositionServer.java +++ b/src/main/java/com/telpo/dipperposition/server/DipperPositionServer.java @@ -1,5 +1,9 @@ package com.telpo.dipperposition.server; +import com.alibaba.nacos.api.NacosFactory; +import com.alibaba.nacos.api.PropertyKeyConst; +import com.alibaba.nacos.api.config.ConfigService; +import com.alibaba.nacos.api.exception.NacosException; import com.telpo.dipperposition.co.PositionConfigInfo; import com.telpo.dipperposition.config.AsyncExecutorConfig; import com.telpo.dipperposition.config.PositionConfig; @@ -14,8 +18,11 @@ import io.netty.channel.socket.nio.NioServerSocketChannel; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; +import org.springframework.beans.factory.config.YamlMapFactoryBean; +import java.io.InputStream; import java.net.InetSocketAddress; +import java.util.Properties; /** @@ -27,13 +34,16 @@ import java.net.InetSocketAddress; @Slf4j public class DipperPositionServer { + @Autowired PositionConfigInfo positionConfigInfo; private String serverAddr="172.16.192.26"; private String timeAsycServerPort="9011"; private String posAsycServerPort="9013"; private String starsAsycServerPort="9012"; - @Autowired - AsyncExecutorConfig positionConfig; + public DipperPositionServer() throws NacosException { + String serverAddr = positionConfigInfo.getServerAddr(); + log.info("Config serverAddr is " + serverAddr); + } /* * 时间同步进程线程 */ diff --git a/src/main/java/com/telpo/dipperposition/service/impl/DipperDataAsyncTaskServiceImpl.java b/src/main/java/com/telpo/dipperposition/service/impl/DipperDataAsyncTaskServiceImpl.java index 8eb9e01..aec944e 100644 --- a/src/main/java/com/telpo/dipperposition/service/impl/DipperDataAsyncTaskServiceImpl.java +++ b/src/main/java/com/telpo/dipperposition/service/impl/DipperDataAsyncTaskServiceImpl.java @@ -22,6 +22,7 @@ public class DipperDataAsyncTaskServiceImpl implements IDipperDataAsyncTaskServi private static String DIPPER_DATA_KEY = "TaidouDipperData"; + private static String DIPPER_ALL_DATA_REQ = "616C6C"; @Autowired private RedisUtil redisUtil; @@ -49,8 +50,8 @@ public class DipperDataAsyncTaskServiceImpl implements IDipperDataAsyncTaskServi SocketClient client = new SocketClient(schedulingExecutorConfig.getAstServer(), schedulingExecutorConfig.getEphAstHexPort(),schedulingExecutorConfig.getAstTimeout()); // astTimeCmd 组装 - String astTimeCmd = "all"; - String hexIn = HexConvert.convertStringToHex(astTimeCmd) + HexConvert.makeChecksum(astTimeCmd); + String astTimeCmd = DIPPER_ALL_DATA_REQ; + String hexIn = astTimeCmd + HexConvert.makeChecksum(astTimeCmd); String ackAckCheckRef = "233E010102000421293C"; String sendResult = client.sendCmd(hexIn, ackAckCheckRef);