Browse Source

修改到docker外运行环境

tags/v1.0.0^2
林万龙 3 years ago
parent
commit
2f9b51a26e
2 changed files with 9 additions and 38 deletions
  1. +8
    -10
      src/main/java/com/telpo/dipperposition/handler/NettyServerHandler.java
  2. +1
    -28
      src/main/java/com/telpo/dipperposition/service/impl/DipperAstTimeAsyncTaskServiceImpl.java

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

@@ -36,10 +36,8 @@ public class NettyServerHandler extends ChannelInboundHandlerAdapter {
private PositionConfig positionConfig;
@Autowired
private IDipperAstTimeAsyncTaskService dipperTimeAsyncTaskService;

@Autowired
private IDipperAstPosAsyncTaskService dipperAstPosAsyncTaskService;

@Autowired
private IDipperDataAsyncTaskService dipperDataAsyncTaskService;

@@ -110,6 +108,12 @@ public class NettyServerHandler extends ChannelInboundHandlerAdapter {
String ipAddress = channel.remoteAddress().toString();
//String message = " 接收到消息:{0}, 客户端IP:{1}";
log.info("接收到消息:" + msg + ",客户端IP:" + ipAddress);
if (positionConfig != null) {
log.info("config info is : " + positionConfig.getCenterProvinceFilePath() + positionConfig.getCenterProvince() + positionConfig.getIpPositionRequestPath() +
positionConfig.getIpPositionRequestKey());
} else {
log.info("positionConfig info is null!!!!!!!!!!!!!! ");
}

String channelAns = "";
// 返回时间指令
@@ -121,18 +125,12 @@ public class NettyServerHandler extends ChannelInboundHandlerAdapter {
if (AST_TIME_CMD.equals(msg)) {
// 初始时间辅助输入;
channelAns = nettyServerHandler.dipperTimeAsyncTaskService.pushAstTime();
log.info("返回时间:" + channelAns);
}

// 发送SDBP-AST-POS获取辅助位置信息
// if (Integer.parseInt(posAsycServerPort) == channel.localAddress().getPort()) {

//if (AST_POS_CMD.equals(recvmg)) {
if (positionConfig != null) {
log.info("config info is : " + positionConfig.getCenterProvinceFilePath() + positionConfig.getCenterProvince() + positionConfig.getIpPositionRequestPath() +
positionConfig.getIpPositionRequestKey());
} else {
log.info("positionConfig info is null!!!!!!!!!!!!!! ");
}
if (AST_POS_CMD.equals(msg)) {
// channelAns = dipperAstPosAsyncTaskService.pushAstPos(ipAddress,
// positionConfig.getCenterProvinceFilePath(),
@@ -163,11 +161,11 @@ public class NettyServerHandler extends ChannelInboundHandlerAdapter {
log.info(channelAns);
if (channelAns != null) {
buf = Unpooled.buffer(channelAns.getBytes().length);
buf.writeBytes(channelAns.getBytes("GBK"));
}
// 最后把SDBP-AST-TIME、SDBP-AST-POS、SDBP-AST-EPH并包一起发给设备。
// 设备采用16进制获取数据,则代理服务器也是采用16进制返回数据。
// 通知客户端链消息发送成功
buf.writeBytes(channelAns.getBytes("GBK"));
ctx.writeAndFlush(buf);
//ctx.write("你也好哦");
//ctx.flush();


+ 1
- 28
src/main/java/com/telpo/dipperposition/service/impl/DipperAstTimeAsyncTaskServiceImpl.java View File

@@ -21,35 +21,11 @@ import java.time.LocalDateTime;
@Service
@Slf4j
public class DipperAstTimeAsyncTaskServiceImpl implements IDipperAstTimeAsyncTaskService {
//
// private static IDipperAstTimeAsyncTaskService dipperAstTimeAsyncTaskService;
// /**
// * spring会自动从ioc容器当中根据IDipperAstTimeAsyncTaskService类型找到dipperAstTimeAsyncTaskService,当做参数传进来
// *
// */
// @Override
// public void setDipperAstTimeAsyncTaskService(IDipperAstTimeAsyncTaskService dipperAstTimeAsyncTaskService) {
// this.dipperAstTimeAsyncTaskService = dipperAstTimeAsyncTaskService;
// }

@Override
@Async("asyncServiceExecutor")
public String pushAstTime() {

// (1) 发送SDBP-AST-TIME
// String sendResult = pushTimeToDipper();
//if (sendResult == null) {
// log.error("取不到时间。");
// return null;
//}

// (2) 获取时间信息
return pushTimeToDipper();
//return sendResult;
}

private String pushTimeToDipper() {

// 创建Socket客户端实例;
// SocketClient client = new SocketClient(astServer, timeAstPort, astTimeout);

@@ -107,11 +83,8 @@ public class DipperAstTimeAsyncTaskServiceImpl implements IDipperAstTimeAsyncTas
astTimeCmd += "0000000000";
astTimeCmd += "00286BEE";

//String hexIn = HexConvert.convertStringToHex(astTimeCmd) + HexConvert.makeChecksum(astTimeCmd);
String hexIn = astTimeCmd + HexConvert.makeChecksum(astTimeCmd);
//String ackAckCheckRef = "233E0101020004020A1D";
//String sendResult = client.sendCmd(hexIn, ackAckCheckRef);
//client.closeConnection();
log.info("返回时间:" + hexIn);

return hexIn;
}


Loading…
Cancel
Save