|
@@ -13,12 +13,10 @@ import com.qhtx.eta.domain.entity.DWIndexFrameDTO;
|
|
import com.qhtx.eta.domain.service.DWIndexFrameService;
|
|
import com.qhtx.eta.domain.service.DWIndexFrameService;
|
|
import com.qhtx.eta.domain.utils.RedisUtils;
|
|
import com.qhtx.eta.domain.utils.RedisUtils;
|
|
import com.qhtx.eta.infra.datasource.DataSourceContextHolder;
|
|
import com.qhtx.eta.infra.datasource.DataSourceContextHolder;
|
|
-import com.qhtx.eta.infra.entity.dw.DWIndex;
|
|
|
|
-import com.qhtx.eta.infra.entity.dw.DWIndexFrame;
|
|
|
|
-import com.qhtx.eta.infra.entity.dw.ETAClassifyIndexFrameMapping;
|
|
|
|
-import com.qhtx.eta.infra.entity.dw.TEtaIndexPushTask;
|
|
|
|
|
|
+import com.qhtx.eta.infra.entity.dw.*;
|
|
import com.qhtx.eta.infra.service.EtaApiClassifyService;
|
|
import com.qhtx.eta.infra.service.EtaApiClassifyService;
|
|
import com.qhtx.eta.infra.service.IndexFrameService;
|
|
import com.qhtx.eta.infra.service.IndexFrameService;
|
|
|
|
+import com.qhtx.eta.infra.service.TDampDwIndexDataService;
|
|
import com.qhtx.eta.infra.service.TEtaIndexPushTaskService;
|
|
import com.qhtx.eta.infra.service.TEtaIndexPushTaskService;
|
|
import lombok.Data;
|
|
import lombok.Data;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
@@ -35,6 +33,9 @@ import java.util.ArrayList;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.Objects;
|
|
import java.util.Objects;
|
|
import java.util.UUID;
|
|
import java.util.UUID;
|
|
|
|
+import java.util.concurrent.CompletableFuture;
|
|
|
|
+import java.util.concurrent.ThreadPoolExecutor;
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
import com.qhtx.eta.common.eunms.DataSourceType;
|
|
import com.qhtx.eta.common.eunms.DataSourceType;
|
|
|
|
|
|
@@ -57,6 +58,12 @@ public class DWIndexFrameServiceImpl implements DWIndexFrameService {
|
|
@Resource
|
|
@Resource
|
|
private TEtaIndexPushTaskService etaIndexPushTaskService;
|
|
private TEtaIndexPushTaskService etaIndexPushTaskService;
|
|
|
|
|
|
|
|
+ @Resource
|
|
|
|
+ private TDampDwIndexDataService tDampDwIndexDataService;
|
|
|
|
+
|
|
|
|
+ @Resource(name = "IndexDataThreadPool")
|
|
|
|
+ private ThreadPoolExecutor indexDataThreadPool;
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public void syncIndexFrame() {
|
|
public void syncIndexFrame() {
|
|
|
|
|
|
@@ -134,9 +141,39 @@ public class DWIndexFrameServiceImpl implements DWIndexFrameService {
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
public DWIndexDTO pushIndexToEta(String indexCode) {
|
|
public DWIndexDTO pushIndexToEta(String indexCode) {
|
|
DWIndex dwIndex = indexFrameService.getIndexByIndexCode(indexCode);
|
|
DWIndex dwIndex = indexFrameService.getIndexByIndexCode(indexCode);
|
|
- DWIndexDTO dwIndexDTO = DWIndexDTOConverter.INSTANCE.convertToDTO(dwIndex);
|
|
|
|
- TEtaIndexPushTask tEtaIndexPushTask = DWIndexDTOConverter.INSTANCE.convertToTEtaIndexPushTask(dwIndexDTO);
|
|
|
|
- etaIndexPushTaskService.insert(tEtaIndexPushTask);
|
|
|
|
|
|
+ int total = tDampDwIndexDataService.countByIndexCode(indexCode);
|
|
|
|
+ List<TDampDwIndexData> allResults = new ArrayList<>();
|
|
|
|
+ //分块取值
|
|
|
|
+ if (total > ETAConstants.ETA_PUSH_DATA_LIMIT) {
|
|
|
|
+ int chunk = (total + ETAConstants.ETA_PUSH_DATA_LIMIT - 1) / ETAConstants.ETA_PUSH_DATA_LIMIT;
|
|
|
|
+ List<CompletableFuture<List<TDampDwIndexData>>> futures = new ArrayList<>();
|
|
|
|
+ for (int i = 0; i < chunk; i++) {
|
|
|
|
+ int pars = i;
|
|
|
|
+ System.out.println(pars);
|
|
|
|
+ CompletableFuture<List<TDampDwIndexData>> future = CompletableFuture.supplyAsync(() -> {
|
|
|
|
+ try {
|
|
|
|
+ return tDampDwIndexDataService.queryAllByLimit(indexCode, pars * ETAConstants.ETA_PUSH_DATA_LIMIT, ETAConstants.ETA_PUSH_DATA_LIMIT);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ log.error("数据推送异常", e);
|
|
|
|
+ throw e;
|
|
|
|
+ }
|
|
|
|
+ }, indexDataThreadPool);
|
|
|
|
+ futures.add(future);
|
|
|
|
+ }
|
|
|
|
+ try {
|
|
|
|
+ // 等待所有任务完成并合并结果
|
|
|
|
+ allResults = futures.stream().map(CompletableFuture::join).flatMap(List::stream).collect(Collectors.toList());
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ log.error("数据推送异常", e);
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ return DWIndexDTOConverter.INSTANCE.convertToDTO(dwIndex);
|
|
|
|
+ }
|
|
|
|
+ System.out.println("allResults size:" + allResults.size());
|
|
|
|
+// List<TDampDwIndexData> dataList = tDampDwIndexDataService.queryAllByLimit(indexCode, 0, 500);
|
|
|
|
+// DWIndexDTO dwIndexDTO = DWIndexDTOConverter.INSTANCE.convertToDTO(dwIndex);
|
|
|
|
+// TEtaIndexPushTask tEtaIndexPushTask = DWIndexDTOConverter.INSTANCE.convertToTEtaIndexPushTask(dwIndexDTO);
|
|
|
|
+// etaIndexPushTaskService.insert(tEtaIndexPushTask);
|
|
return DWIndexDTOConverter.INSTANCE.convertToDTO(dwIndex);
|
|
return DWIndexDTOConverter.INSTANCE.convertToDTO(dwIndex);
|
|
}
|
|
}
|
|
|
|
|