|
|
@@ -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("你也好哦"); |
|
|
|