@@ -38,7 +38,7 @@ public class SocketClient { | |||||
} | } | ||||
public String sendCmd(String astCmd, String ackAckCheckRef) { | |||||
public byte[] sendCmd(String astCmd, String ackAckCheckRef) { | |||||
try { | try { | ||||
OutputStream os=socket.getOutputStream(); | OutputStream os=socket.getOutputStream(); | ||||
PrintWriter pw=new PrintWriter(os); | PrintWriter pw=new PrintWriter(os); | ||||
@@ -80,7 +80,7 @@ public class SocketClient { | |||||
os.close(); | os.close(); | ||||
//log.debug(ackResult); | //log.debug(ackResult); | ||||
log.debug("接收服务器的信息:"+in2b.toString()); | log.debug("接收服务器的信息:"+in2b.toString()); | ||||
return in2b.toString(); | |||||
return in2b; | |||||
} catch (IOException e) { | } catch (IOException e) { | ||||
log.error("Socket sendCmd Error:" + e.getMessage()); | log.error("Socket sendCmd Error:" + e.getMessage()); | ||||
return null; | return null; | ||||
@@ -116,10 +116,12 @@ public class NettyServerHandler extends ChannelInboundHandlerAdapter { | |||||
// 返回时间指令 | // 返回时间指令 | ||||
//if (Integer.parseInt(timeAsycServerPort) == channel.localAddress().getPort()) { | //if (Integer.parseInt(timeAsycServerPort) == channel.localAddress().getPort()) { | ||||
ByteBuf recvmg = (ByteBuf) msg; | ByteBuf recvmg = (ByteBuf) msg; | ||||
ByteBuf buf = null; | |||||
String recvmgStr = recvmg.toString(); | String recvmgStr = recvmg.toString(); | ||||
if (AST_TIME_CMD.equals(recvmg)) { | if (AST_TIME_CMD.equals(recvmg)) { | ||||
// 初始时间辅助输入; | // 初始时间辅助输入; | ||||
channelAns = dipperTimeAsyncTaskService.pushAstTime(); | channelAns = dipperTimeAsyncTaskService.pushAstTime(); | ||||
buf = Unpooled.buffer(channelAns.getBytes().length); | |||||
} | } | ||||
// 发送SDBP-AST-POS获取辅助位置信息 | // 发送SDBP-AST-POS获取辅助位置信息 | ||||
@@ -131,12 +133,14 @@ public class NettyServerHandler extends ChannelInboundHandlerAdapter { | |||||
centerProvince, | centerProvince, | ||||
ipPositionRequestPath, | ipPositionRequestPath, | ||||
ipPositionRequestKey); | ipPositionRequestKey); | ||||
buf = Unpooled.buffer(channelAns.getBytes().length); | |||||
} | } | ||||
// 从缓存获取SDBP-AST-EPH星历数 | // 从缓存获取SDBP-AST-EPH星历数 | ||||
//if (Integer.parseInt(starsAsycServerPort) == channel.localAddress().getPort()) { | //if (Integer.parseInt(starsAsycServerPort) == channel.localAddress().getPort()) { | ||||
if (AST_POS_CMD.equals(recvmg)) { | if (AST_POS_CMD.equals(recvmg)) { | ||||
channelAns = dipperDataAsyncTaskService.getAstEPH(); | |||||
byte[] astEPHBytes = dipperDataAsyncTaskService.getAstEPH(); | |||||
buf = Unpooled.buffer(astEPHBytes.length); | |||||
} | } | ||||
@@ -144,7 +148,6 @@ public class NettyServerHandler extends ChannelInboundHandlerAdapter { | |||||
// 设备采用16进制获取数据,则代理服务器也是采用16进制返回数据。 | // 设备采用16进制获取数据,则代理服务器也是采用16进制返回数据。 | ||||
// 通知客户端链消息发送成功 | // 通知客户端链消息发送成功 | ||||
// String str = "服务端收到:" + LocalDateTime.now() + " " + msg + "\r\n"; | // String str = "服务端收到:" + LocalDateTime.now() + " " + msg + "\r\n"; | ||||
ByteBuf buf = Unpooled.buffer(channelAns.getBytes().length); | |||||
buf.writeBytes(channelAns.getBytes("GBK")); | buf.writeBytes(channelAns.getBytes("GBK")); | ||||
ctx.writeAndFlush(buf); | ctx.writeAndFlush(buf); | ||||
//ctx.write("你也好哦"); | //ctx.write("你也好哦"); | ||||
@@ -23,6 +23,6 @@ public interface IDipperDataAsyncTaskService { | |||||
* 根据IP获取EPH | * 根据IP获取EPH | ||||
* | * | ||||
*/ | */ | ||||
String getAstEPH(); | |||||
byte[] getAstEPH(); | |||||
} | } |
@@ -32,7 +32,7 @@ public class DipperDataAsyncTaskServiceImpl implements IDipperDataAsyncTaskServi | |||||
@Override | @Override | ||||
public void pullAstEPH() { | public void pullAstEPH() { | ||||
// (1) 发送bds获取星历数据 | // (1) 发送bds获取星历数据 | ||||
String dipperData = pullEPHFromDipper(); | |||||
byte[] dipperData = pullEPHFromDipper(); | |||||
// (2) 获取星历数据 | // (2) 获取星历数据 | ||||
if (dipperData == null) { | if (dipperData == null) { | ||||
@@ -44,7 +44,7 @@ public class DipperDataAsyncTaskServiceImpl implements IDipperDataAsyncTaskServi | |||||
} | } | ||||
private String pullEPHFromDipper() { | |||||
private byte[] pullEPHFromDipper() { | |||||
// 创建Socket客户端实例; | // 创建Socket客户端实例; | ||||
SocketClient client = new SocketClient(schedulingExecutorConfig.getAstServer(), schedulingExecutorConfig.getEphAstHexPort(),schedulingExecutorConfig.getAstTimeout()); | SocketClient client = new SocketClient(schedulingExecutorConfig.getAstServer(), schedulingExecutorConfig.getEphAstHexPort(),schedulingExecutorConfig.getAstTimeout()); | ||||
@@ -54,7 +54,7 @@ public class DipperDataAsyncTaskServiceImpl implements IDipperDataAsyncTaskServi | |||||
String hexIn = astTimeCmd + HexConvert.makeChecksum(astTimeCmd); | String hexIn = astTimeCmd + HexConvert.makeChecksum(astTimeCmd); | ||||
String ackAckCheckRef = "233E010102000421293C"; | String ackAckCheckRef = "233E010102000421293C"; | ||||
String sendResult = client.sendCmd(hexIn, ackAckCheckRef); | |||||
byte[] sendResult = client.sendCmd(hexIn, ackAckCheckRef); | |||||
client.closeConnection(); | client.closeConnection(); | ||||
return sendResult; | return sendResult; | ||||
@@ -62,7 +62,7 @@ public class DipperDataAsyncTaskServiceImpl implements IDipperDataAsyncTaskServi | |||||
@Override | @Override | ||||
@Async("asyncServiceExecutor") | @Async("asyncServiceExecutor") | ||||
public String getAstEPH(){ | |||||
return (String)redisUtil.get(DIPPER_DATA_KEY); | |||||
public byte[] getAstEPH(){ | |||||
return (byte[])redisUtil.get(DIPPER_DATA_KEY); | |||||
} | } | ||||
} | } |