|
|
|
@ -12,6 +12,7 @@ import com.supervision.police.dto.EvidenceDirectoryDTO;
|
|
|
|
|
import com.supervision.police.mapper.*;
|
|
|
|
|
import io.swagger.v3.oas.annotations.media.Schema;
|
|
|
|
|
import lombok.Data;
|
|
|
|
|
import org.jetbrains.annotations.NotNull;
|
|
|
|
|
import org.springframework.ai.ollama.OllamaChatClient;
|
|
|
|
|
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
@ -221,10 +222,32 @@ public class CaseScoreDetailBuilder {
|
|
|
|
|
}).filter(result->StrUtil.isNotEmpty(result.getAtomicId())).filter(distinctPredicate(AtomicResult::getAtomicId)).count()
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
List<String> unusedCategoryIds = this.getUnusedCategoryIds();
|
|
|
|
|
caseScoreDetailDTO.setMissAtomicIndexCount((long) unusedCategoryIds.size());
|
|
|
|
|
caseScoreDetailDTO.setMissCategoryNameList(this.getUnusedCategoryNames(unusedCategoryIds));
|
|
|
|
|
caseScoreDetailDTO.setGuideDesc(this.buildGuideDesc(unusedCategoryIds, rootEvidenceCategory));
|
|
|
|
|
|
|
|
|
|
// 结构化推理分类id 只过滤不得分的指标
|
|
|
|
|
List<String> structureCategoryList = this.indexResultList.stream().filter(indexResult -> indexResult.getActualScore() == 0)
|
|
|
|
|
.flatMap(indexResult -> indexResult.getAtomicResults().stream())
|
|
|
|
|
.filter(atomicResult -> StrUtil.equals(IndexRuleConstants.OPERAND_TYPE_STRUCTURE, atomicResult.getIndexSource()))
|
|
|
|
|
.map(AtomicResult::getCategoryId)
|
|
|
|
|
.filter(id -> StrUtil.isNotEmpty(id) && !this.evidenceDirectoryDTO.categoryHasFile(id)).distinct().toList();
|
|
|
|
|
|
|
|
|
|
// 数据库查询分类id 只过滤不得分的指标
|
|
|
|
|
Set<String> filter = new HashSet<>();
|
|
|
|
|
List<AtomicResult> dbAtomicResultList = this.indexResultList.stream().filter(indexResult -> indexResult.getActualScore() == 0)
|
|
|
|
|
.flatMap(indexResult -> indexResult.getAtomicResults().stream())
|
|
|
|
|
.filter(r -> {
|
|
|
|
|
if (StrUtil.isEmpty(r.getCategoryId()) || !StrUtil.equals(IndexRuleConstants.OPERAND_TYPE_DB, r.getIndexSource())){
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
if (filter.contains(r.getCategoryId())){
|
|
|
|
|
return false;
|
|
|
|
|
}else {
|
|
|
|
|
filter.add(r.getCategoryId());
|
|
|
|
|
return !r.resultIsTrue() && StrUtil.isAllNotEmpty(r.getAtomicName(),r.getCategoryId());
|
|
|
|
|
}
|
|
|
|
|
}).filter(ar->StrUtil.isAllNotEmpty(ar.getAtomicName(),ar.getCategoryId())).toList();
|
|
|
|
|
|
|
|
|
|
String guideDesc = buildGuideDesc(structureCategoryList, dbAtomicResultList, rootEvidenceCategory);
|
|
|
|
|
caseScoreDetailDTO.setGuideDesc(guideDesc);
|
|
|
|
|
return caseScoreDetailDTO;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -286,29 +309,42 @@ public class CaseScoreDetailBuilder {
|
|
|
|
|
public List<String> getUnusedCategoryNames(List<String> unusedCategoryIds) {
|
|
|
|
|
return unusedCategoryIds.stream().map(id -> rootEvidenceCategory.findCategoryById(id)).map(EvidenceCategoryDTO::getCategoryName).toList();
|
|
|
|
|
}
|
|
|
|
|
public String buildGuideDesc(List<String> structureCategoryList,List<AtomicResult> dbAtomicResultList, EvidenceCategoryDTO rootCategory) {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 构建引导描述
|
|
|
|
|
* @param categoryIds 分类id
|
|
|
|
|
* @param rootCategory 根分类信息
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public String buildGuideDesc(List<String> categoryIds, EvidenceCategoryDTO rootCategory) {
|
|
|
|
|
|
|
|
|
|
if (CollUtil.isEmpty(categoryIds)) {
|
|
|
|
|
if (CollUtil.isEmpty(structureCategoryList) && CollUtil.isEmpty(dbAtomicResultList)) {
|
|
|
|
|
return "案件证据均已成功上传,系统已基于现有证据链进行分析和案件预测评分。如果对结果存在疑问或偏差,可核实证据信息是否完整和准确。如有需要,您可以补充更多相关证据以进一步支持案件分析。";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<List<String>> pathIds = categoryIds.stream().map(rootCategory::listCategoryIdPath).toList();
|
|
|
|
|
List<List<String>> structurePathIds = structureCategoryList.stream().map(rootCategory::listCategoryIdPath).collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
|
// 不考虑文件在二级目录的场景
|
|
|
|
|
List<List<String>> directCategoryList = dbAtomicResultList.stream().map(ra -> {
|
|
|
|
|
List<String> categoryIdPath = rootCategory.listCategoryIdPath(ra.getCategoryId());
|
|
|
|
|
if (CollUtil.isEmpty(categoryIdPath)) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
return List.of(CollUtil.getFirst(categoryIdPath), ra.getAtomicName());
|
|
|
|
|
}).toList();
|
|
|
|
|
|
|
|
|
|
structurePathIds.addAll(directCategoryList);
|
|
|
|
|
|
|
|
|
|
// 二级目录
|
|
|
|
|
Map<String, List<String>> categoryIdGroup = pathIds.stream().filter(list -> list.size() == 2)
|
|
|
|
|
Map<String, List<String>> categoryIdGroup = structurePathIds.stream().filter(list -> list.size() == 2)
|
|
|
|
|
.collect(Collectors.groupingBy(list -> list.get(0), Collectors.mapping(list -> list.get(1), Collectors.toList())));
|
|
|
|
|
|
|
|
|
|
// 只包含一级目录
|
|
|
|
|
List<String> categoryLevelOneIds = pathIds.stream().filter(list -> list.size() == 1)
|
|
|
|
|
List<String> categoryLevelOneIds = structurePathIds.stream().filter(list -> list.size() == 1)
|
|
|
|
|
.flatMap(Collection::stream).filter(id -> !categoryIdGroup.containsKey(id)).distinct().toList();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return builderGuideDesc(rootCategory, categoryIdGroup, categoryLevelOneIds);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@NotNull
|
|
|
|
|
private static String builderGuideDesc(EvidenceCategoryDTO rootCategory, Map<String, List<String>> categoryIdGroup,
|
|
|
|
|
List<String> categoryLevelOneIds) {
|
|
|
|
|
StringBuilder builder = new StringBuilder("为了提升司法定性的准确性,建议您补充以下相关证据:包括但不限于");
|
|
|
|
|
for (Map.Entry<String, List<String>> entry : categoryIdGroup.entrySet()) {
|
|
|
|
|
String oneLevel = entry.getKey();
|
|
|
|
@ -319,6 +355,8 @@ public class CaseScoreDetailBuilder {
|
|
|
|
|
EvidenceCategoryDTO secondLevelCategory = rootCategory.findCategoryById(secondCategoryId);
|
|
|
|
|
if (secondLevelCategory != null) {
|
|
|
|
|
builder.append(secondLevelCategory.getCategoryName()).append("、");
|
|
|
|
|
}else {
|
|
|
|
|
builder.append(secondCategoryId).append("、");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
builder.deleteCharAt(builder.length() - 1).append("),");
|
|
|
|
@ -336,6 +374,32 @@ public class CaseScoreDetailBuilder {
|
|
|
|
|
return builder.toString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 构建引导描述
|
|
|
|
|
* @param categoryIds 分类id
|
|
|
|
|
* @param rootCategory 根分类信息
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public String buildGuideDesc(List<String> categoryIds, EvidenceCategoryDTO rootCategory) {
|
|
|
|
|
|
|
|
|
|
if (CollUtil.isEmpty(categoryIds)) {
|
|
|
|
|
return "案件证据均已成功上传,系统已基于现有证据链进行分析和案件预测评分。如果对结果存在疑问或偏差,可核实证据信息是否完整和准确。如有需要,您可以补充更多相关证据以进一步支持案件分析。";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<List<String>> pathIds = categoryIds.stream().map(rootCategory::listCategoryIdPath).toList();
|
|
|
|
|
|
|
|
|
|
// 二级目录
|
|
|
|
|
Map<String, List<String>> categoryIdGroup = pathIds.stream().filter(list -> list.size() == 2)
|
|
|
|
|
.collect(Collectors.groupingBy(list -> list.get(0), Collectors.mapping(list -> list.get(1), Collectors.toList())));
|
|
|
|
|
|
|
|
|
|
// 只包含一级目录
|
|
|
|
|
List<String> categoryLevelOneIds = pathIds.stream().filter(list -> list.size() == 1)
|
|
|
|
|
.flatMap(Collection::stream).filter(id -> !categoryIdGroup.containsKey(id)).distinct().toList();
|
|
|
|
|
|
|
|
|
|
return builderGuideDesc(rootCategory, categoryIdGroup, categoryLevelOneIds);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取共性指标
|
|
|
|
|
* @return
|
|
|
|
|