Browse Source

修改到docker外运行环境

tags/v1.0.0^2
林万龙 3 years ago
parent
commit
20513c1de1
3 changed files with 16 additions and 29 deletions
  1. +6
    -6
      src/main/java/com/telpo/dipperposition/config/NettyServerConfig.java
  2. +6
    -6
      src/main/java/com/telpo/dipperposition/config/PositionConfig.java
  3. +4
    -17
      src/main/java/com/telpo/dipperposition/handler/NettyServerHandler.java

+ 6
- 6
src/main/java/com/telpo/dipperposition/config/NettyServerConfig.java View File

@@ -34,11 +34,11 @@ public class NettyServerConfig {
@NacosValue(value = "${position-server.starsAsycPort}")
private String starsAsycServerPort;

public static NettyServerConfig nettyServerConfig;
@PostConstruct
public void init() {
nettyServerConfig = this;
}
// public static NettyServerConfig nettyServerConfig;
//
// @PostConstruct
// public void init() {
// nettyServerConfig = this;
// }

}

+ 6
- 6
src/main/java/com/telpo/dipperposition/config/PositionConfig.java View File

@@ -40,10 +40,10 @@ public class PositionConfig {
int astTimeout;


public static PositionConfig positionConfig;
@PostConstruct
public void init() {
positionConfig = this;
}
// public static PositionConfig positionConfig;
//
// @PostConstruct
// public void init() {
// positionConfig = this;
// }
}

+ 4
- 17
src/main/java/com/telpo/dipperposition/handler/NettyServerHandler.java View File

@@ -1,17 +1,9 @@
package com.telpo.dipperposition.handler;

import com.telpo.dipperposition.config.NettyServerConfig;
import com.telpo.dipperposition.config.PositionConfig;
import com.telpo.dipperposition.controller.DipperAstPosAsyncTaskController;
import com.telpo.dipperposition.controller.DipperAstTimeAsyncTaskController;
import com.telpo.dipperposition.controller.DipperDataAsyncTaskController;
import com.telpo.dipperposition.enums.DipperReturnValue;
import com.telpo.dipperposition.service.IDipperAstPosAsyncTaskService;
import com.telpo.dipperposition.service.IDipperAstTimeAsyncTaskService;
import com.telpo.dipperposition.service.IDipperDataAsyncTaskService;
import com.telpo.dipperposition.service.impl.DipperAstPosAsyncTaskServiceImpl;
import com.telpo.dipperposition.service.impl.DipperAstTimeAsyncTaskServiceImpl;
import com.telpo.dipperposition.service.impl.DipperDataAsyncTaskServiceImpl;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import io.netty.channel.socket.SocketChannel;
@@ -19,12 +11,9 @@ import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
import lombok.extern.slf4j.Slf4j;
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;

/**
* @program: dipperposition
@@ -55,7 +44,7 @@ public class NettyServerHandler extends ChannelInboundHandlerAdapter {
private IDipperDataAsyncTaskService dipperDataAsyncTaskService;

private static NettyServerHandler nettyServerHandler;
public NettyServerHandler() {}
@PostConstruct
public void init() {
nettyServerHandler = this;
@@ -131,9 +120,6 @@ public class NettyServerHandler extends ChannelInboundHandlerAdapter {
//if (AST_TIME_CMD.equals(recvmg)) {
if (AST_TIME_CMD.equals(msg)) {
// 初始时间辅助输入;
// if (dipperTimeAsyncTaskService == null) {
// dipperTimeAsyncTaskService = new DipperAstTimeAsyncTaskServiceImpl();
// }
channelAns = nettyServerHandler.dipperTimeAsyncTaskService.pushAstTime();
}

@@ -175,11 +161,12 @@ public class NettyServerHandler extends ChannelInboundHandlerAdapter {
}

log.info(channelAns);
buf = Unpooled.buffer(channelAns.getBytes().length);
if (channelAns != null) {
buf = Unpooled.buffer(channelAns.getBytes().length);
}
// 最后把SDBP-AST-TIME、SDBP-AST-POS、SDBP-AST-EPH并包一起发给设备。
// 设备采用16进制获取数据,则代理服务器也是采用16进制返回数据。
// 通知客户端链消息发送成功
// String str = "服务端收到:" + LocalDateTime.now() + " " + msg + "\r\n";
buf.writeBytes(channelAns.getBytes("GBK"));
ctx.writeAndFlush(buf);
//ctx.write("你也好哦");


Loading…
Cancel
Save