Browse Source

修改到docker外运行环境

tags/v1.0.0^2
林万龙 3 years ago
parent
commit
64460a0f20
2 changed files with 14 additions and 6 deletions
  1. +8
    -6
      src/main/java/com/telpo/dipperposition/handler/NettyServerHandler.java
  2. +6
    -0
      src/main/java/com/telpo/dipperposition/server/DipperPositionServer.java

+ 8
- 6
src/main/java/com/telpo/dipperposition/handler/NettyServerHandler.java View File

@@ -20,6 +20,7 @@ import io.netty.channel.ChannelInboundHandlerAdapter;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;


import java.io.InputStream; import java.io.InputStream;
import java.time.LocalDateTime; import java.time.LocalDateTime;
@@ -31,6 +32,7 @@ import java.time.LocalDateTime;
* @create: 2021-01-13 13:56 * @create: 2021-01-13 13:56
**/ **/
@Slf4j @Slf4j
@Component
public class NettyServerHandler extends ChannelInboundHandlerAdapter { public class NettyServerHandler extends ChannelInboundHandlerAdapter {


private static String AST_TIME_CMD = "TIME"; private static String AST_TIME_CMD = "TIME";
@@ -40,11 +42,11 @@ public class NettyServerHandler extends ChannelInboundHandlerAdapter {
private static String AST_POS_CMD_BYTE = "504f53"; private static String AST_POS_CMD_BYTE = "504f53";
private static String AST_EPH_CMD_BYTE = "455048"; private static String AST_EPH_CMD_BYTE = "455048";


private DipperAstTimeAsyncTaskController dipperTimeAsyncTaskController = new DipperAstTimeAsyncTaskController();
private IDipperAstTimeAsyncTaskService dipperTimeAsyncTaskService;


private DipperAstPosAsyncTaskController dipperAstPosAsyncTaskController = new DipperAstPosAsyncTaskController();
private IDipperAstPosAsyncTaskService dipperAstPosAsyncTaskService;


private DipperDataAsyncTaskController dipperDataAsyncTaskController = new DipperDataAsyncTaskController();
private IDipperDataAsyncTaskService dipperDataAsyncTaskService;


@Autowired @Autowired
private NettyServerConfig nettyServerConfig; private NettyServerConfig nettyServerConfig;
@@ -119,7 +121,7 @@ public class NettyServerHandler extends ChannelInboundHandlerAdapter {
// if (dipperTimeAsyncTaskService == null) { // if (dipperTimeAsyncTaskService == null) {
// dipperTimeAsyncTaskService = new DipperAstTimeAsyncTaskServiceImpl(); // dipperTimeAsyncTaskService = new DipperAstTimeAsyncTaskServiceImpl();
// } // }
channelAns = dipperTimeAsyncTaskController.pushAstTime();
channelAns = dipperTimeAsyncTaskService.pushAstTime();
} }


// 发送SDBP-AST-POS获取辅助位置信息 // 发送SDBP-AST-POS获取辅助位置信息
@@ -141,7 +143,7 @@ public class NettyServerHandler extends ChannelInboundHandlerAdapter {
// if (dipperAstPosAsyncTaskService == null) { // if (dipperAstPosAsyncTaskService == null) {
// dipperAstPosAsyncTaskService = new DipperAstPosAsyncTaskServiceImpl(); // dipperAstPosAsyncTaskService = new DipperAstPosAsyncTaskServiceImpl();
// } // }
channelAns = dipperAstPosAsyncTaskController.pushAstPos(ipAddress);
channelAns = dipperAstPosAsyncTaskService.pushAstPos(ipAddress);
// (ipAddress, // (ipAddress,
// "/csv/provinceLonAlt.csv", // "/csv/provinceLonAlt.csv",
// "湖北省", // "湖北省",
@@ -156,7 +158,7 @@ public class NettyServerHandler extends ChannelInboundHandlerAdapter {
// if (dipperDataAsyncTaskService == null) { // if (dipperDataAsyncTaskService == null) {
// dipperDataAsyncTaskService = new DipperDataAsyncTaskServiceImpl(); // dipperDataAsyncTaskService = new DipperDataAsyncTaskServiceImpl();
// } // }
// channelAns = dipperDataAsyncTaskController.getAstEPH();
channelAns = dipperDataAsyncTaskService.getAstEPH();
} }


log.info(channelAns); log.info(channelAns);


+ 6
- 0
src/main/java/com/telpo/dipperposition/server/DipperPositionServer.java View File

@@ -13,7 +13,9 @@ import io.netty.channel.EventLoopGroup;
import io.netty.channel.nio.NioEventLoopGroup; import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.nio.NioServerSocketChannel; import io.netty.channel.socket.nio.NioServerSocketChannel;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.env.ConfigurableEnvironment; import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.stereotype.Component;


import java.net.InetSocketAddress; import java.net.InetSocketAddress;


@@ -24,8 +26,11 @@ import java.net.InetSocketAddress;
* @create: 2021-01-13 14:01 * @create: 2021-01-13 14:01
*/ */
@Slf4j @Slf4j
@Component
public class DipperPositionServer { public class DipperPositionServer {


@Value("position-server.serverAddr")
private String myServerAddr;
private String serverAddr; private String serverAddr;
private Integer starsAsycPort; private Integer starsAsycPort;


@@ -62,6 +67,7 @@ public class DipperPositionServer {


ChannelFuture channelFuture3 = bootstrap.bind(socketAddress).sync(); ChannelFuture channelFuture3 = bootstrap.bind(socketAddress).sync();
log.info("星历服务器启动开始监听端口: {}", starsAsycPort); log.info("星历服务器启动开始监听端口: {}", starsAsycPort);
log.info("服务器: {}", myServerAddr);
channelFuture3.addListener(future -> { channelFuture3.addListener(future -> {
if (future.isSuccess()){ if (future.isSuccess()){
System.out.println("start success"); System.out.println("start success");


Loading…
Cancel
Save