|
|
@@ -7,12 +7,10 @@ import com.etotem.cfc.entity.DanKnowledgeBase;
|
|
|
import com.etotem.cfc.entity.DanKnowledgeBaseDimension;
|
|
|
import com.etotem.cfc.entity.DanKnowledgeBaseTag;
|
|
|
import com.etotem.cfc.entity.DanKnowledgeTag;
|
|
|
-import com.etotem.cfc.entity.ProductDimensionConfig;
|
|
|
import com.etotem.cfc.mapper.DanKnowledgeBaseDimensionMapper;
|
|
|
import com.etotem.cfc.mapper.DanKnowledgeBaseMapper;
|
|
|
import com.etotem.cfc.mapper.DanKnowledgeBaseTagMapper;
|
|
|
import com.etotem.cfc.mapper.DanKnowledgeTagMapper;
|
|
|
-import com.etotem.cfc.mapper.ProductDimensionConfigMapper;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
@@ -46,7 +44,7 @@ public class DanKnowledgeBaseService extends ServiceImpl<DanKnowledgeBaseMapper,
|
|
|
private DanKnowledgeTagMapper danKnowledgeTagMapper;
|
|
|
|
|
|
@Resource
|
|
|
- private ProductDimensionConfigMapper productDimensionConfigMapper;
|
|
|
+ private DimensionRegistryService dimensionRegistryService;
|
|
|
|
|
|
@Resource
|
|
|
private LanggraphSyncService langgraphSyncService;
|
|
|
@@ -276,17 +274,7 @@ public class DanKnowledgeBaseService extends ServiceImpl<DanKnowledgeBaseMapper,
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- Map<Long, String> dimCodesById = new HashMap<>();
|
|
|
- if (!allDimIds.isEmpty()) {
|
|
|
- List<ProductDimensionConfig> configs = productDimensionConfigMapper.selectBatchIds(allDimIds);
|
|
|
- if (configs != null) {
|
|
|
- for (ProductDimensionConfig config : configs) {
|
|
|
- if (config.getId() != null && config.getDimensionCode() != null) {
|
|
|
- dimCodesById.put(config.getId(), config.getDimensionCode());
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ Map<Long, String> dimCodesById = dimensionRegistryService.getDimensionCodesByIds(allDimIds);
|
|
|
|
|
|
for (DanKnowledgeBase record : records) {
|
|
|
List<Long> tids = tagIdsByKnowledge.getOrDefault(record.getId(), Collections.emptyList());
|
|
|
@@ -322,15 +310,7 @@ public class DanKnowledgeBaseService extends ServiceImpl<DanKnowledgeBaseMapper,
|
|
|
}
|
|
|
List<Long> dimIds = knowledge.getDimensionIds();
|
|
|
if (dimIds != null && !dimIds.isEmpty()) {
|
|
|
- List<ProductDimensionConfig> configs = productDimensionConfigMapper.selectBatchIds(dimIds);
|
|
|
- Map<Long, String> codes = new HashMap<>();
|
|
|
- if (configs != null) {
|
|
|
- for (ProductDimensionConfig config : configs) {
|
|
|
- if (config.getId() != null && config.getDimensionCode() != null) {
|
|
|
- codes.put(config.getId(), config.getDimensionCode());
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ Map<Long, String> codes = dimensionRegistryService.getDimensionCodesByIds(dimIds);
|
|
|
knowledge.setDimensionCodes(dimIds.stream().map(codes::get)
|
|
|
.filter(Objects::nonNull).collect(Collectors.toList()));
|
|
|
} else {
|
|
|
@@ -390,21 +370,15 @@ public class DanKnowledgeBaseService extends ServiceImpl<DanKnowledgeBaseMapper,
|
|
|
.eq(DanKnowledgeBaseDimension::getKnowledgeId, knowledgeId));
|
|
|
if (dims == null || dims.isEmpty()) return new java.util.ArrayList<>();
|
|
|
List<Long> dimIds = dims.stream().map(DanKnowledgeBaseDimension::getDimensionId).collect(Collectors.toList());
|
|
|
- ProductDimensionConfig cfg = new ProductDimensionConfig();
|
|
|
- cfg.setId(dimIds.get(0));
|
|
|
- List<ProductDimensionConfig> configs = new java.util.ArrayList<>();
|
|
|
+ Map<Long, String> codeById = dimensionRegistryService.getDimensionCodesByIds(dimIds);
|
|
|
+ List<String> codes = new java.util.ArrayList<>();
|
|
|
for (Long dimId : dimIds) {
|
|
|
- ProductDimensionConfig c = new ProductDimensionConfig();
|
|
|
- c.setId(dimId);
|
|
|
- configs.add(c);
|
|
|
+ String code = codeById.get(dimId);
|
|
|
+ if (code != null) {
|
|
|
+ codes.add(code);
|
|
|
+ }
|
|
|
}
|
|
|
- return configs.stream()
|
|
|
- .map(c -> {
|
|
|
- ProductDimensionConfig full = productDimensionConfigMapper.selectById(c.getId());
|
|
|
- return full != null ? full.getDimensionCode() : null;
|
|
|
- })
|
|
|
- .filter(code -> code != null)
|
|
|
- .collect(Collectors.toList());
|
|
|
+ return codes;
|
|
|
}
|
|
|
|
|
|
// ==================== 标签/维度自动回填 ====================
|
|
|
@@ -525,9 +499,6 @@ public class DanKnowledgeBaseService extends ServiceImpl<DanKnowledgeBaseMapper,
|
|
|
}
|
|
|
|
|
|
private Long dimensionIdByCode(String code) {
|
|
|
- ProductDimensionConfig cfg = productDimensionConfigMapper.selectOne(
|
|
|
- new LambdaQueryWrapper<ProductDimensionConfig>()
|
|
|
- .eq(ProductDimensionConfig::getDimensionCode, code));
|
|
|
- return cfg != null ? cfg.getId() : null;
|
|
|
+ return dimensionRegistryService.getDimensionIdByCode(code);
|
|
|
}
|
|
|
}
|