Переглянути джерело

增加OkHttp配置文件读取

tags/v1.0.0^2
林万龙 4 роки тому
джерело
коміт
c54ba7bb57
4 змінених файлів з 23 додано та 28 видалено
  1. +13
    -0
      src/main/java/com/telpo/dipperposition/config/SchedulingExecutorConfig.java
  2. +1
    -6
      src/main/java/com/telpo/dipperposition/service/IDipperDataAsyncTaskService.java
  3. +8
    -12
      src/main/java/com/telpo/dipperposition/service/impl/DipperDataAsyncTaskServiceImpl.java
  4. +1
    -10
      src/main/java/com/telpo/dipperposition/task/ScheduleService.java

+ 13
- 0
src/main/java/com/telpo/dipperposition/config/SchedulingExecutorConfig.java Переглянути файл

@@ -1,5 +1,7 @@
package com.telpo.dipperposition.config;

import lombok.Getter;
import lombok.Setter;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@@ -13,6 +15,8 @@ import org.springframework.scheduling.config.ScheduledTaskRegistrar;
* @author: linwl
* @create: 2020-07-24 10:53
*/
@Getter
@Setter
@Configuration
public class SchedulingExecutorConfig implements SchedulingConfigurer {

@@ -22,6 +26,15 @@ public class SchedulingExecutorConfig implements SchedulingConfigurer {
@Value("${scheduler.pool.await-seconds}")
private int awaitSeconds;

@Value("${pos.ast.server}")
private String astServer;
@Value("${pos.ast.ephAstPort}")
private int ephAstPort;
@Value("${pos.ast.ephAstHexPort}")
private int ephAstHexPort;
@Value("${pos.ast.timeout}")
private int astTimeout;

@Override
public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
ThreadPoolTaskScheduler taskScheduler = taskScheduler();


+ 1
- 6
src/main/java/com/telpo/dipperposition/service/IDipperDataAsyncTaskService.java Переглянути файл

@@ -14,14 +14,9 @@ public interface IDipperDataAsyncTaskService {

/**
* 同步任务
* @param astServer
* @param ephAstHexPort
* @param astTimeout
*
*/
void pullAstEPH(String astServer,
int ephAstHexPort,
int astTimeout);
void pullAstEPH();


/**


+ 8
- 12
src/main/java/com/telpo/dipperposition/service/impl/DipperDataAsyncTaskServiceImpl.java Переглянути файл

@@ -3,6 +3,7 @@ package com.telpo.dipperposition.service.impl;
import com.telpo.dipperposition.common.HexConvert;
import com.telpo.dipperposition.common.RedisUtil;
import com.telpo.dipperposition.common.SocketClient;
import com.telpo.dipperposition.config.SchedulingExecutorConfig;
import com.telpo.dipperposition.service.IDipperDataAsyncTaskService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
@@ -19,21 +20,16 @@ import org.springframework.stereotype.Service;
@Slf4j
public class DipperDataAsyncTaskServiceImpl implements IDipperDataAsyncTaskService {

@Autowired
private RedisUtil redisUtil;

private static String DIPPER_DATA_KEY = "TaidouDipperData";
private String astServer;
private int ephAstHexPort;
private int astTimeout;

@Autowired
private RedisUtil redisUtil;
@Autowired
private SchedulingExecutorConfig schedulingExecutorConfig;

@Override
public void pullAstEPH(String astServer,
int ephAstHexPort,
int astTimeout) {
this.astServer = astServer;
this.ephAstHexPort = ephAstHexPort;
this.astTimeout = astTimeout;
public void pullAstEPH() {
// (1) 发送bds获取星历数据
String dipperData = pullEPHFromDipper();

@@ -50,7 +46,7 @@ public class DipperDataAsyncTaskServiceImpl implements IDipperDataAsyncTaskServi
private String pullEPHFromDipper() {

// 创建Socket客户端实例;
SocketClient client = new SocketClient(astServer, ephAstHexPort, astTimeout);
SocketClient client = new SocketClient(schedulingExecutorConfig.getAstServer(), schedulingExecutorConfig.getEphAstHexPort(),schedulingExecutorConfig.getAstTimeout());

// astTimeCmd 组装
String astTimeCmd = "all";


+ 1
- 10
src/main/java/com/telpo/dipperposition/task/ScheduleService.java Переглянути файл

@@ -18,15 +18,6 @@ import org.springframework.stereotype.Component;
@Slf4j
public class ScheduleService {

@Value("${pos.ast.server}")
String astServer;
@Value("${pos.ast.ephAstPort}")
int ephAstPort;
@Value("${pos.ast.ephAstHexPort}")
int ephAstHexPort;
@Value("${pos.ast.timeout}")
int astTimeout;

@Autowired
private IDipperDataAsyncTaskService dipperDataAsyncTaskService;

@@ -41,7 +32,7 @@ public class ScheduleService {
log.info("开始星历数据同步!");
// 获取推送失败的记录
try {
dipperDataAsyncTaskService.pullAstEPH(astServer,ephAstHexPort,astTimeout);
dipperDataAsyncTaskService.pullAstEPH();
} catch (Exception e) {
log.error("执行定时获取星历数据发生异常:", e);
}


Завантаження…
Відмінити
Зберегти