|
@@ -4,6 +4,7 @@ import com.alibaba.druid.util.StringUtils;
|
|
|
import com.qhtx.eta.common.constant.ETAConstants;
|
|
|
import com.qhtx.eta.common.eunms.ErrorEnum;
|
|
|
import com.qhtx.eta.common.exception.ETAException;
|
|
|
+import com.qhtx.eta.domain.config.ETAConfigProperties;
|
|
|
import com.qhtx.eta.domain.convert.DWIndexDTOConverter;
|
|
|
import com.qhtx.eta.domain.convert.DWIndexDataDTOConverter;
|
|
|
import com.qhtx.eta.domain.convert.DWIndexFrameDTOConverter;
|
|
@@ -15,6 +16,7 @@ import com.qhtx.eta.domain.utils.RedisUtils;
|
|
|
import com.qhtx.eta.infra.datasource.DataSourceContextHolder;
|
|
|
import com.qhtx.eta.infra.entity.dw.TDampDwLinkDetail;
|
|
|
import com.qhtx.eta.infra.entity.dw.*;
|
|
|
+import com.qhtx.eta.infra.mapper.DWIndexFrameDao;
|
|
|
import com.qhtx.eta.infra.service.*;
|
|
|
import lombok.Data;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
@@ -29,6 +31,7 @@ import javax.annotation.Resource;
|
|
|
import java.util.*;
|
|
|
import java.util.concurrent.CompletableFuture;
|
|
|
import java.util.concurrent.ThreadPoolExecutor;
|
|
|
+import java.util.concurrent.TimeUnit;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
import com.qhtx.eta.common.eunms.DataSourceType;
|
|
@@ -37,6 +40,8 @@ import com.qhtx.eta.common.eunms.DataSourceType;
|
|
|
@Slf4j
|
|
|
public class DWIndexFrameServiceImpl implements DWIndexFrameService {
|
|
|
|
|
|
+ @Resource
|
|
|
+ private ETAConfigProperties etaConfigProperties;
|
|
|
@Resource
|
|
|
private RedisUtils redisUtils;
|
|
|
|
|
@@ -61,7 +66,8 @@ public class DWIndexFrameServiceImpl implements DWIndexFrameService {
|
|
|
@Resource
|
|
|
private TDampDwLinkDetailService tDampDwLinkDetailService;
|
|
|
|
|
|
-
|
|
|
+ @Resource
|
|
|
+ private DWIndexFrameDao dwIndexFrameDao;
|
|
|
@Resource
|
|
|
private TDampDwIndexService tDampDwIndexService;
|
|
|
@Resource(name = "IndexDataThreadPool")
|
|
@@ -75,20 +81,22 @@ public class DWIndexFrameServiceImpl implements DWIndexFrameService {
|
|
|
@Override
|
|
|
public String generateTableCode() throws ETAException {
|
|
|
if (!redisUtils.exist(ETAConstants.REDIS_INDEX_FRAME_TABLE_CODE_KEY)) {
|
|
|
- throw new ETAException(ErrorEnum.DW_INDEX_TABLE_CODE_GET_ERROR);
|
|
|
-// synchronized (this) {
|
|
|
-// if (!redisUtils.exist(ETAConstants.REDIS_INDEX_FRAME_TABLE_CODE_KEY)) {
|
|
|
-// long currentTableCode = 100;
|
|
|
-// redisUtils.setNx(ETAConstants.REDIS_INDEX_FRAME_TABLE_CODE_KEY, currentTableCode, -1L, TimeUnit.SECONDS);
|
|
|
-// }
|
|
|
-// }
|
|
|
+ // throw new ETAException(ErrorEnum.DW_INDEX_TABLE_CODE_GET_ERROR);
|
|
|
+ synchronized (this) {
|
|
|
+ if (!redisUtils.exist(ETAConstants.REDIS_INDEX_FRAME_TABLE_CODE_KEY)) {
|
|
|
+ String maxTableCode = dwIndexFrameDao.getMaxTableCode();
|
|
|
+ long maxData = maxTableCode == null ? 0L : Long.parseLong(maxTableCode.replaceAll(ETAConstants.INDEX_FRAME_TABLE_CODE_PREFIX, ""));
|
|
|
+ redisUtils.setNX(ETAConstants.REDIS_INDEX_FRAME_TABLE_CODE_KEY, maxData);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
return ETAConstants.INDEX_FRAME_TABLE_CODE_PREFIX + String.format("%07d", redisUtils.add(ETAConstants.REDIS_INDEX_FRAME_TABLE_CODE_KEY, 1L));
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void processing(List<DWIndexFrameDTO> processList) {
|
|
|
- DWIndexFrame hzIndexFrame = indexFrameService.getByCnName(ETAConstants.DW_INDEX_FRAME_PARENT_NAME);
|
|
|
+// DWIndexFrame hzIndexFrame = indexFrameService.getByCnName(ETAConstants.DW_INDEX_FRAME_PARENT_NAME);
|
|
|
+ DWIndexFrame hzIndexFrame = indexFrameService.getByCnName(etaConfigProperties.getEtaCategoryName());
|
|
|
if (hzIndexFrame == null) {
|
|
|
log.info("未找到根节点,不同步eta指标目录");
|
|
|
return;
|
|
@@ -248,9 +256,9 @@ public class DWIndexFrameServiceImpl implements DWIndexFrameService {
|
|
|
}
|
|
|
for (DWIndexFrameDTO dto : list) {
|
|
|
if (Objects.equals(dto.getParentId(), node.getClassifyId())) {
|
|
|
- String path = StringUtils.isEmpty(node.getPath().trim()) ? dto.getCnName() : node.getPath() + "|" + dto.getCnName();
|
|
|
+ String path = StringUtils.isEmpty(node.getPath().trim()) ? node.getName() + "|" + dto.getCnName() : node.getPath() + "|" + dto.getCnName();
|
|
|
String id = (dto.getId() == null || dto.getId().trim().isEmpty()) ? UUID.randomUUID().toString().replaceAll("-", "") : dto.getId();
|
|
|
- String idPath = StringUtils.isEmpty(node.getPath().trim()) ? id : node.getIdPath() + "|" + id;
|
|
|
+ String idPath = StringUtils.isEmpty(node.getPath().trim()) ? node.getId() + "|" + id : node.getIdPath() + "|" + id;
|
|
|
FrameNode temp = new FrameNode();
|
|
|
temp.setId(id);
|
|
|
temp.setClassifyId(dto.getClassifyId());
|