|
@@ -1,13 +1,18 @@
|
|
package com.qhtx.eta.domain.job;
|
|
package com.qhtx.eta.domain.job;
|
|
|
|
|
|
-import com.qhtx.eta.common.utils.AssertUtils;
|
|
|
|
|
|
+import com.qhtx.eta.common.eunms.DataSourceType;
|
|
import com.qhtx.eta.domain.config.ScheduleConfig;
|
|
import com.qhtx.eta.domain.config.ScheduleConfig;
|
|
import com.qhtx.eta.domain.config.ScheduleTaskConfig;
|
|
import com.qhtx.eta.domain.config.ScheduleTaskConfig;
|
|
|
|
+import com.qhtx.eta.domain.convert.ClassifyMappingDTOConverter;
|
|
|
|
+import com.qhtx.eta.domain.entity.ClassifyMappingDTO;
|
|
import com.qhtx.eta.domain.entity.QuotaDataUpdateBO;
|
|
import com.qhtx.eta.domain.entity.QuotaDataUpdateBO;
|
|
import com.qhtx.eta.domain.entity.QuotaInfoDTO;
|
|
import com.qhtx.eta.domain.entity.QuotaInfoDTO;
|
|
import com.qhtx.eta.domain.enums.ETADataStatus;
|
|
import com.qhtx.eta.domain.enums.ETADataStatus;
|
|
import com.qhtx.eta.domain.enums.ETAInterfaceEnum;
|
|
import com.qhtx.eta.domain.enums.ETAInterfaceEnum;
|
|
|
|
+import com.qhtx.eta.domain.enums.ETATaskEnum;
|
|
import com.qhtx.eta.domain.enums.ExcludedQuotaSource;
|
|
import com.qhtx.eta.domain.enums.ExcludedQuotaSource;
|
|
|
|
+import com.qhtx.eta.domain.service.DWIndexFrameService;
|
|
|
|
+import com.qhtx.eta.domain.service.ETAClassifyService;
|
|
import com.qhtx.eta.domain.service.ETAQuotaService;
|
|
import com.qhtx.eta.domain.service.ETAQuotaService;
|
|
import com.qhtx.eta.domain.api.ApiServiceHolder;
|
|
import com.qhtx.eta.domain.api.ApiServiceHolder;
|
|
import com.qhtx.eta.domain.api.http.request.ETADataHttpRequest;
|
|
import com.qhtx.eta.domain.api.http.request.ETADataHttpRequest;
|
|
@@ -15,26 +20,26 @@ import com.qhtx.eta.common.constant.ETAConstants;
|
|
import com.qhtx.eta.domain.entity.QuotaDataDTO;
|
|
import com.qhtx.eta.domain.entity.QuotaDataDTO;
|
|
import com.qhtx.eta.domain.task.FixedDelayTaskRegistrar;
|
|
import com.qhtx.eta.domain.task.FixedDelayTaskRegistrar;
|
|
import com.qhtx.eta.domain.task.SchedulingRunnable;
|
|
import com.qhtx.eta.domain.task.SchedulingRunnable;
|
|
-import com.qhtx.eta.infra.entity.EtaApiQuotaData;
|
|
|
|
|
|
+import com.qhtx.eta.infra.annotation.UseDataSource;
|
|
import com.qhtx.eta.infra.enums.Frequency;
|
|
import com.qhtx.eta.infra.enums.Frequency;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.boot.CommandLineRunner;
|
|
import org.springframework.boot.CommandLineRunner;
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.util.CollectionUtils;
|
|
import org.springframework.util.CollectionUtils;
|
|
-import org.springframework.util.StringUtils;
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
-import java.text.SimpleDateFormat;
|
|
|
|
import java.time.LocalDate;
|
|
import java.time.LocalDate;
|
|
import java.time.format.DateTimeFormatter;
|
|
import java.time.format.DateTimeFormatter;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
|
+import java.util.concurrent.ConcurrentHashMap;
|
|
import java.util.concurrent.ThreadPoolExecutor;
|
|
import java.util.concurrent.ThreadPoolExecutor;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
+
|
|
@Component
|
|
@Component
|
|
@Slf4j
|
|
@Slf4j
|
|
-public class ETADataSyncJob implements CommandLineRunner {
|
|
|
|
|
|
+public class ETASyncJob implements CommandLineRunner {
|
|
|
|
|
|
@Value("${eta.http.interval}")
|
|
@Value("${eta.http.interval}")
|
|
private int interval;
|
|
private int interval;
|
|
@@ -46,16 +51,33 @@ public class ETADataSyncJob implements CommandLineRunner {
|
|
|
|
|
|
@Resource
|
|
@Resource
|
|
private ETAQuotaService etaQuotaService;
|
|
private ETAQuotaService etaQuotaService;
|
|
|
|
+ @Resource
|
|
|
|
+ private ETAClassifyService etaClassifyService;
|
|
|
|
|
|
@Resource(name = "ETADataThreadPool")
|
|
@Resource(name = "ETADataThreadPool")
|
|
private ThreadPoolExecutor etaDataThreadPool;
|
|
private ThreadPoolExecutor etaDataThreadPool;
|
|
-
|
|
|
|
|
|
+ @Resource(name = "IndexFrameThreadPool")
|
|
|
|
+ private ThreadPoolExecutor indexFrameThreadPool;
|
|
@Resource
|
|
@Resource
|
|
private FixedDelayTaskRegistrar fixedDelayTaskRegistrar;
|
|
private FixedDelayTaskRegistrar fixedDelayTaskRegistrar;
|
|
|
|
|
|
@Resource
|
|
@Resource
|
|
private ScheduleTaskConfig scheduleTaskConfig;
|
|
private ScheduleTaskConfig scheduleTaskConfig;
|
|
|
|
|
|
|
|
+
|
|
|
|
+ @Resource
|
|
|
|
+ private DWIndexFrameService dwIndexFrameService;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+// @Resource(name = "ETAIndexFrameThreadPool")
|
|
|
|
+// private ThreadPoolExecutor etaIndexFrameThreadPool;
|
|
|
|
+
|
|
|
|
+ private static final Map<Integer, ETATaskEnum> taskMappingMap = new ConcurrentHashMap<>(16);
|
|
|
|
+
|
|
|
|
+ public ETATaskEnum getTaskType(int configId) {
|
|
|
|
+ return taskMappingMap.get(configId);
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 同步指标信息
|
|
* 同步指标信息
|
|
*/
|
|
*/
|
|
@@ -72,6 +94,33 @@ public class ETADataSyncJob implements CommandLineRunner {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public void syncETAClassifyList() {
|
|
|
|
+ List<?> respList = apiServiceHolder.runApi(ETAInterfaceEnum.GET_CLASSIFY_LIST);
|
|
|
|
+ if (respList != null) {
|
|
|
|
+ List<ClassifyMappingDTO> classifyList = respList.stream().filter(item -> item instanceof ClassifyMappingDTO).map(item -> (ClassifyMappingDTO) item).collect(Collectors.toList());
|
|
|
|
+ log.info("================================ 开始同步接口指标分类列表 ================================ ");
|
|
|
|
+ log.info("================================ 接口指标分类列表数量:{}条================================ ", classifyList.size());
|
|
|
|
+ try {
|
|
|
|
+ etaClassifyService.syncClassify(classifyList);
|
|
|
|
+ // 获取信号量
|
|
|
|
+ List<ClassifyMappingDTO> processingList = etaClassifyService.getProcessingList();
|
|
|
|
+ if (!CollectionUtils.isEmpty(processingList)) {
|
|
|
|
+ log.info("processingList size:{}", processingList.size());
|
|
|
|
+ dwIndexFrameService.processing(ClassifyMappingDTOConverter.INSTANCE.convertDTOToDWIndexFrameList(processingList));
|
|
|
|
+ }
|
|
|
|
+ //开始获取新增和需要更新的框架数据
|
|
|
|
+
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ log.warn("同步eta指标分类失败:{}", e.getMessage());
|
|
|
|
+ }
|
|
|
|
+ log.info("================================ 同步接口指标分类列表完成 ================================ ");
|
|
|
|
+ } else {
|
|
|
|
+ log.warn("调用接口结束,无数据同步");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 同步指标数据
|
|
* 同步指标数据
|
|
*/
|
|
*/
|
|
@@ -181,18 +230,22 @@ public class ETADataSyncJob implements CommandLineRunner {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- //加载系统中的定时任务,目前只有2个就冗余写一下,后续有新任务再抽代码改造
|
|
|
|
@Override
|
|
@Override
|
|
public void run(String... args) {
|
|
public void run(String... args) {
|
|
- ScheduleConfig dataConfig = scheduleTaskConfig.getData();
|
|
|
|
- ScheduleConfig infoConfig = scheduleTaskConfig.getInfo();
|
|
|
|
- if (dataConfig.getEnabled()) {
|
|
|
|
- //同步指标数据任务
|
|
|
|
- fixedDelayTaskRegistrar.addFixedDelayTask(new SchedulingRunnable(this.getClass().getName(), "syncETAData", this), dataConfig.getInterval(), dataConfig.getInitialDelay());
|
|
|
|
- }
|
|
|
|
- if (infoConfig.getEnabled()) {
|
|
|
|
- //同步主表基本信息任务
|
|
|
|
- fixedDelayTaskRegistrar.addFixedDelayTask(new SchedulingRunnable(this.getClass().getName(), "syncETAInfo", this), infoConfig.getInterval(), infoConfig.getInitialDelay());
|
|
|
|
|
|
+ List<ScheduleConfig> list = scheduleTaskConfig.getList();
|
|
|
|
+ if (!CollectionUtils.isEmpty(list)) {
|
|
|
|
+ for (int index = 0; index < list.size(); index++) {
|
|
|
|
+ ScheduleConfig config = list.get(index);
|
|
|
|
+ ETATaskEnum etaTaskEnum = ETATaskEnum.ofName(config.getName());
|
|
|
|
+ if (etaTaskEnum != null) {
|
|
|
|
+ taskMappingMap.put(index, etaTaskEnum);
|
|
|
|
+ if (config.getEnabled()) {
|
|
|
|
+ //同步指标数据任务
|
|
|
|
+ fixedDelayTaskRegistrar.addFixedDelayTask(new SchedulingRunnable(this.getClass().getName(), etaTaskEnum.getMethod(), this), config.getInterval(), config.getInitialDelay());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
}
|
|
}
|