|
@@ -2,10 +2,12 @@ package com.qhtx.eta.domain.job;
|
|
|
|
|
|
import com.alibaba.nacos.api.utils.StringUtils;
|
|
|
import com.google.common.collect.Lists;
|
|
|
+import com.google.common.hash.Hashing;
|
|
|
import com.qhtx.eta.common.eunms.DataSourceType;
|
|
|
import com.qhtx.eta.common.eunms.ErrorEnum;
|
|
|
import com.qhtx.eta.common.exception.ETAException;
|
|
|
import com.qhtx.eta.common.utils.MD5Utils;
|
|
|
+import com.qhtx.eta.domain.config.RedisConfig;
|
|
|
import com.qhtx.eta.domain.config.ScheduleConfig;
|
|
|
import com.qhtx.eta.domain.config.ScheduleTaskConfig;
|
|
|
import com.qhtx.eta.domain.convert.ClassifyMappingDTOConverter;
|
|
@@ -26,6 +28,7 @@ import com.qhtx.eta.common.constant.ETAConstants;
|
|
|
import com.qhtx.eta.domain.service.impl.TDampLinkService;
|
|
|
import com.qhtx.eta.domain.task.FixedDelayTaskRegistrar;
|
|
|
import com.qhtx.eta.domain.task.SchedulingRunnable;
|
|
|
+import com.qhtx.eta.domain.utils.RedisUtils;
|
|
|
import com.qhtx.eta.infra.datasource.DataSourceContextHolder;
|
|
|
import com.qhtx.eta.infra.entity.dw.*;
|
|
|
import com.qhtx.eta.infra.enums.Frequency;
|
|
@@ -44,6 +47,7 @@ import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import java.math.BigDecimal;
|
|
|
+import java.nio.charset.StandardCharsets;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.time.DayOfWeek;
|
|
|
import java.time.LocalDate;
|
|
@@ -100,6 +104,8 @@ public class ETASyncJob implements CommandLineRunner {
|
|
|
@Resource
|
|
|
private RedissonClient redissonClient;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private RedisUtils redisUtils;
|
|
|
private static final Map<Integer, ETATaskEnum> taskMappingMap = new ConcurrentHashMap<>(16);
|
|
|
|
|
|
public ETATaskEnum getTaskType(int configId) {
|
|
@@ -233,7 +239,7 @@ public class ETASyncJob implements CommandLineRunner {
|
|
|
log.info("================================ 开始同步接口指标分类列表 ================================ ");
|
|
|
log.info("================================ 接口指标分类列表数量:{}条================================ ", classifyList.size());
|
|
|
try {
|
|
|
- // etaClassifyService.syncClassify(classifyList);
|
|
|
+ etaClassifyService.syncClassify(classifyList);
|
|
|
List<ClassifyMappingDTO> processingList = etaClassifyService.getProcessingList();
|
|
|
if (!CollectionUtils.isEmpty(processingList)) {
|
|
|
log.info("processingList size:{}", processingList.size());
|
|
@@ -335,9 +341,18 @@ public class ETASyncJob implements CommandLineRunner {
|
|
|
return dwIndexData;
|
|
|
}).collect(Collectors.toList());
|
|
|
if (CollectionUtils.isEmpty(dwLinkDetailList)) {
|
|
|
- log.warn("未找到对应指标数据:{},不同步指标", dwIndexWithLinkCodeDTO.getLinkCode());
|
|
|
continue;
|
|
|
}
|
|
|
+ if (!dwIndexWithLinkCodeDTO.getLinkCode().contains("ETA")) {
|
|
|
+ log.warn("当前对接码非ETA数据,不做处理{}", dwIndexWithLinkCodeDTO.getLinkCode());
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ int uniqueId = Integer.parseInt(dwIndexWithLinkCodeDTO.getLinkCode().substring(dwIndexWithLinkCodeDTO.getLinkCode().indexOf("ETA") + 3));
|
|
|
+ if (redisUtils.getBit(redisUtils.indexSyncKey(), uniqueId)) {
|
|
|
+ log.warn("对应指标数据:{},已同步,不在进行同步处理", dwIndexWithLinkCodeDTO.getLinkCode());
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ log.warn("对应指标数据:{},同步指标", dwIndexWithLinkCodeDTO.getLinkCode());
|
|
|
DataSourceContextHolder.setDataSourceType(DataSourceType.DW);
|
|
|
transactionTemplate.execute(new TransactionCallbackWithoutResult() {
|
|
|
@Override
|
|
@@ -347,13 +362,14 @@ public class ETASyncJob implements CommandLineRunner {
|
|
|
dwIndexFrameService.insertIndex(dwIndex);
|
|
|
//更新指标对接码
|
|
|
dwIndexFrameService.insertIndexLink(tDampDwIndexLink);
|
|
|
- dwIndexFrameService.batchInsertIndexData(dwLinkDetailList);
|
|
|
//添加指标数据
|
|
|
+ dwIndexFrameService.batchInsertIndexData(dwLinkDetailList);
|
|
|
}
|
|
|
});
|
|
|
+
|
|
|
+ redisUtils.setBit(redisUtils.indexSyncKey(), uniqueId, true);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
} catch (Exception e) {
|
|
|
log.error("同步指标数据数据失败", e);
|
|
|
}
|