|
|
@@ -10,6 +10,8 @@ import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.scheduling.annotation.Async; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
import static java.lang.Thread.sleep; |
|
|
|
|
|
|
|
/** |
|
|
|
* @program: DipperDataAsyncTaskServiceImpl |
|
|
|
* @description: 获取星历数据。 |
|
|
@@ -31,13 +33,20 @@ public class DipperDataAsyncTaskServiceImpl implements IDipperDataAsyncTaskServi |
|
|
|
|
|
|
|
@Override |
|
|
|
@Async("asyncServiceExecutor") |
|
|
|
public void pullAstEPH() { |
|
|
|
public void pullAstEPH(int tryTimes) throws InterruptedException { |
|
|
|
if (tryTimes==0) { |
|
|
|
return; |
|
|
|
} else { |
|
|
|
tryTimes--; |
|
|
|
} |
|
|
|
// (1) 发送bds获取星历数据 |
|
|
|
byte[] dipperData = pullEPHFromDipper(); |
|
|
|
|
|
|
|
// (2) 获取星历数据 |
|
|
|
if (dipperData == null) { |
|
|
|
log.error("获取星历数据错误,取不到星历数据。"); |
|
|
|
sleep(10000); |
|
|
|
pullAstEPH(tryTimes); |
|
|
|
} else { |
|
|
|
// 保存到DB或者缓存 |
|
|
|
log.info("保存到DB或者缓存"); |
|
|
@@ -65,7 +74,7 @@ public class DipperDataAsyncTaskServiceImpl implements IDipperDataAsyncTaskServi |
|
|
|
String hexIn = astTimeCmd + checkSum.substring(0,2) + " " + checkSum.substring(2,4); |
|
|
|
|
|
|
|
byte[] sendResult = null; |
|
|
|
String ackAckCheckRef = "233E010102000421293C"; |
|
|
|
//String ackAckCheckRef = "233E010102000421293C"; |
|
|
|
sendResult = client.sendCmd(hexIn); |
|
|
|
client.closeConnection(); |
|
|
|
|
|
|
@@ -77,7 +86,11 @@ public class DipperDataAsyncTaskServiceImpl implements IDipperDataAsyncTaskServi |
|
|
|
// String dipperData = pullEPHFromDipper(); |
|
|
|
byte[] dipperData; |
|
|
|
if (!redisUtil.hasKey(DIPPER_DATA_KEY)) { |
|
|
|
this.pullAstEPH(); |
|
|
|
try { |
|
|
|
this.pullAstEPH(1); |
|
|
|
} catch (InterruptedException e) { |
|
|
|
log.error("获取星历数据发生异常:", e); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
dipperData = (byte[])redisUtil.get(DIPPER_DATA_KEY); |
|
|
|