Преглед на файлове

修改读取的结果

tags/v1.0.0^2
林万龙 преди 3 години
родител
ревизия
2641bebed8
променени са 4 файла, в които са добавени 13 реда и са изтрити 10 реда
  1. +2
    -2
      src/main/java/com/telpo/dipperposition/common/SocketClient.java
  2. +5
    -2
      src/main/java/com/telpo/dipperposition/handler/NettyServerHandler.java
  3. +1
    -1
      src/main/java/com/telpo/dipperposition/service/IDipperDataAsyncTaskService.java
  4. +5
    -5
      src/main/java/com/telpo/dipperposition/service/impl/DipperDataAsyncTaskServiceImpl.java

+ 2
- 2
src/main/java/com/telpo/dipperposition/common/SocketClient.java Целия файл

@@ -38,7 +38,7 @@ public class SocketClient {
}


public String sendCmd(String astCmd, String ackAckCheckRef) {
public byte[] sendCmd(String astCmd, String ackAckCheckRef) {
try {
OutputStream os=socket.getOutputStream();
PrintWriter pw=new PrintWriter(os);
@@ -80,7 +80,7 @@ public class SocketClient {
os.close();
//log.debug(ackResult);
log.debug("接收服务器的信息:"+in2b.toString());
return in2b.toString();
return in2b;
} catch (IOException e) {
log.error("Socket sendCmd Error:" + e.getMessage());
return null;


+ 5
- 2
src/main/java/com/telpo/dipperposition/handler/NettyServerHandler.java Целия файл

@@ -116,10 +116,12 @@ public class NettyServerHandler extends ChannelInboundHandlerAdapter {
// 返回时间指令
//if (Integer.parseInt(timeAsycServerPort) == channel.localAddress().getPort()) {
ByteBuf recvmg = (ByteBuf) msg;
ByteBuf buf = null;
String recvmgStr = recvmg.toString();
if (AST_TIME_CMD.equals(recvmg)) {
// 初始时间辅助输入;
channelAns = dipperTimeAsyncTaskService.pushAstTime();
buf = Unpooled.buffer(channelAns.getBytes().length);
}

// 发送SDBP-AST-POS获取辅助位置信息
@@ -131,12 +133,14 @@ public class NettyServerHandler extends ChannelInboundHandlerAdapter {
centerProvince,
ipPositionRequestPath,
ipPositionRequestKey);
buf = Unpooled.buffer(channelAns.getBytes().length);
}

// 从缓存获取SDBP-AST-EPH星历数
//if (Integer.parseInt(starsAsycServerPort) == channel.localAddress().getPort()) {
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进制返回数据。
// 通知客户端链消息发送成功
// String str = "服务端收到:" + LocalDateTime.now() + " " + msg + "\r\n";
ByteBuf buf = Unpooled.buffer(channelAns.getBytes().length);
buf.writeBytes(channelAns.getBytes("GBK"));
ctx.writeAndFlush(buf);
//ctx.write("你也好哦");


+ 1
- 1
src/main/java/com/telpo/dipperposition/service/IDipperDataAsyncTaskService.java Целия файл

@@ -23,6 +23,6 @@ public interface IDipperDataAsyncTaskService {
* 根据IP获取EPH
*
*/
String getAstEPH();
byte[] getAstEPH();

}

+ 5
- 5
src/main/java/com/telpo/dipperposition/service/impl/DipperDataAsyncTaskServiceImpl.java Целия файл

@@ -32,7 +32,7 @@ public class DipperDataAsyncTaskServiceImpl implements IDipperDataAsyncTaskServi
@Override
public void pullAstEPH() {
// (1) 发送bds获取星历数据
String dipperData = pullEPHFromDipper();
byte[] dipperData = pullEPHFromDipper();

// (2) 获取星历数据
if (dipperData == null) {
@@ -44,7 +44,7 @@ public class DipperDataAsyncTaskServiceImpl implements IDipperDataAsyncTaskServi
}


private String pullEPHFromDipper() {
private byte[] pullEPHFromDipper() {

// 创建Socket客户端实例;
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 ackAckCheckRef = "233E010102000421293C";
String sendResult = client.sendCmd(hexIn, ackAckCheckRef);
byte[] sendResult = client.sendCmd(hexIn, ackAckCheckRef);
client.closeConnection();

return sendResult;
@@ -62,7 +62,7 @@ public class DipperDataAsyncTaskServiceImpl implements IDipperDataAsyncTaskServi

@Override
@Async("asyncServiceExecutor")
public String getAstEPH(){
return (String)redisUtil.get(DIPPER_DATA_KEY);
public byte[] getAstEPH(){
return (byte[])redisUtil.get(DIPPER_DATA_KEY);
}
}

Loading…
Отказ
Запис