|
|
@ -74,6 +74,9 @@ public class ModelIndexServiceImpl extends ServiceImpl<ModelIndexMapper, ModelIn
|
|
|
|
@Value("${case.evidence.table}")
|
|
|
|
@Value("${case.evidence.table}")
|
|
|
|
private List<String> allowedTables;
|
|
|
|
private List<String> allowedTables;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Value("${case.atomic.query}")
|
|
|
|
|
|
|
|
private String queryTemplate;
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
@Transactional(transactionManager = "dataSourceTransactionManager", rollbackFor = Exception.class)
|
|
|
|
@Transactional(transactionManager = "dataSourceTransactionManager", rollbackFor = Exception.class)
|
|
|
|
public R<?> selectAll(ModelIndexReqVO modelIndex, Integer page, Integer size) {
|
|
|
|
public R<?> selectAll(ModelIndexReqVO modelIndex, Integer page, Integer size) {
|
|
|
@ -229,6 +232,12 @@ public class ModelIndexServiceImpl extends ServiceImpl<ModelIndexMapper, ModelIn
|
|
|
|
Assert.notNull(notePrompt, "提示词信息不存在");
|
|
|
|
Assert.notNull(notePrompt, "提示词信息不存在");
|
|
|
|
Assert.notEmpty(notePrompt.getEvidenceCategoryId(), "提示词分类为空");
|
|
|
|
Assert.notEmpty(notePrompt.getEvidenceCategoryId(), "提示词分类为空");
|
|
|
|
modelAtomicIndex.setCategoryId(notePrompt.getEvidenceCategoryId());
|
|
|
|
modelAtomicIndex.setCategoryId(notePrompt.getEvidenceCategoryId());
|
|
|
|
|
|
|
|
}else if (StringUtils.equals(IndexRuleConstants.OPERAND_TYPE_GRAPH, modelAtomicIndex.getIndexSource())) {
|
|
|
|
|
|
|
|
Assert.notEmpty(modelAtomicIndex.getPromptId(), "提示词id不能为空");
|
|
|
|
|
|
|
|
NotePrompt notePrompt = notePromptService.getBaseMapper().selectById(modelAtomicIndex.getPromptId());
|
|
|
|
|
|
|
|
Assert.notNull(notePrompt, "提示词信息不存在");
|
|
|
|
|
|
|
|
String query = promptGenerateGraphQuery(notePrompt, queryTemplate);
|
|
|
|
|
|
|
|
modelAtomicIndex.setQueryLang(query);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -246,6 +255,19 @@ public class ModelIndexServiceImpl extends ServiceImpl<ModelIndexMapper, ModelIn
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private String promptGenerateGraphQuery(NotePrompt prompt, String queryTemplate) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (null == prompt || !StrUtil.equals("2", prompt.getType())) {
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return StrUtil.format(queryTemplate,
|
|
|
|
|
|
|
|
new HashMap<String, Object>() {{
|
|
|
|
|
|
|
|
put("startEntityType", prompt.getStartEntityType());
|
|
|
|
|
|
|
|
put("relType", prompt.getRelType());
|
|
|
|
|
|
|
|
put("endEntityType", prompt.getEndEntityType());
|
|
|
|
|
|
|
|
}});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
@Transactional(transactionManager = "dataSourceTransactionManager", rollbackFor = Exception.class)
|
|
|
|
@Transactional(transactionManager = "dataSourceTransactionManager", rollbackFor = Exception.class)
|
|
|
|
public List<CaseAtomicIndexDTO> listCaseAtomicIndex(String caseId, String indexSource) {
|
|
|
|
public List<CaseAtomicIndexDTO> listCaseAtomicIndex(String caseId, String indexSource) {
|
|
|
@ -382,7 +404,7 @@ public class ModelIndexServiceImpl extends ServiceImpl<ModelIndexMapper, ModelIn
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
List<NotePrompt> notePrompts = notePromptService.listByIds(promptIds);
|
|
|
|
List<NotePrompt> notePrompts = notePromptService.listByIds(promptIds);
|
|
|
|
Map<String, String> dicMap = comDictionaryService.getDictionaryMapReverse("prompt_attribute_valuetype");
|
|
|
|
Map<String, String> dicMap = comDictionaryService.getDictionaryMap("prompt_attribute_valuetype");
|
|
|
|
|
|
|
|
|
|
|
|
for (Map.Entry<String, List<ValueCalculateScopeDTO>> entry : result.entrySet()) {
|
|
|
|
for (Map.Entry<String, List<ValueCalculateScopeDTO>> entry : result.entrySet()) {
|
|
|
|
List<ValueCalculateScopeDTO> scopeDTOList = makeScopes(entry.getKey(), atomicIndexList, notePrompts, dicMap);
|
|
|
|
List<ValueCalculateScopeDTO> scopeDTOList = makeScopes(entry.getKey(), atomicIndexList, notePrompts, dicMap);
|
|
|
@ -411,11 +433,11 @@ public class ModelIndexServiceImpl extends ServiceImpl<ModelIndexMapper, ModelIn
|
|
|
|
return extractAttributes.stream().map(extractAttribute -> {
|
|
|
|
return extractAttributes.stream().map(extractAttribute -> {
|
|
|
|
ValueCalculateScopeDTO valueCalculateScope = new ValueCalculateScopeDTO();
|
|
|
|
ValueCalculateScopeDTO valueCalculateScope = new ValueCalculateScopeDTO();
|
|
|
|
valueCalculateScope.setValue(extractAttribute.getAttrName());
|
|
|
|
valueCalculateScope.setValue(extractAttribute.getAttrName());
|
|
|
|
valueCalculateScope.setValueType(dicMap.get(extractAttribute.getAttrValueType()));
|
|
|
|
valueCalculateScope.setValueType(extractAttribute.getAttrValueType());
|
|
|
|
valueCalculateScope.setValueTypeDesc(extractAttribute.getAttrValueType());
|
|
|
|
valueCalculateScope.setValueTypeDesc(dicMap.get(extractAttribute.getAttrValueType()));
|
|
|
|
valueCalculateScope.setOperatorList(
|
|
|
|
valueCalculateScope.setOperatorList(
|
|
|
|
IndexRuleConstants.VALUE_TYPE_OPERATOR_MAPPING.get(valueCalculateScope.getValueType()));
|
|
|
|
IndexRuleConstants.VALUE_TYPE_OPERATOR_MAPPING.get(extractAttribute.getAttrValueType()));
|
|
|
|
Map<String, String> map = IndexRuleConstants.VALUE_TYPE_AGGREGATE_MAPPING.get(valueCalculateScope.getValueType());
|
|
|
|
Map<String, String> map = IndexRuleConstants.VALUE_TYPE_AGGREGATE_MAPPING.getOrDefault(valueCalculateScope.getValueType(),new HashMap<>());
|
|
|
|
valueCalculateScope.setAggregateList(map.entrySet().stream().map(entry -> new Pair<>(entry.getKey(), entry.getValue())).toList());
|
|
|
|
valueCalculateScope.setAggregateList(map.entrySet().stream().map(entry -> new Pair<>(entry.getKey(), entry.getValue())).toList());
|
|
|
|
return valueCalculateScope;
|
|
|
|
return valueCalculateScope;
|
|
|
|
}).toList();
|
|
|
|
}).toList();
|
|
|
|