1. 数据库分析证据结果功能初步提交
parent
697a8cca4c
commit
b8a0145097
@ -0,0 +1,41 @@
|
||||
package com.supervision.constants;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public enum ScoreEnum {
|
||||
EVIDENCE_FULL("证据充分", "司法机关对案件形成一致认定意见的概率比较大"),
|
||||
EVIDENCE_LACK("证据不足", "司法籍贯认定意见不一致的概率比较大"),
|
||||
EVIDENCE_NOT_FULL("证据不充分", "司法籍贯会作出绝对不起诉或存疑不起诉的决定");
|
||||
|
||||
private final String name;
|
||||
private final String desc;
|
||||
|
||||
ScoreEnum(String name, String desc) {
|
||||
this.name = name;
|
||||
this.desc = desc;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getDesc() {
|
||||
return desc;
|
||||
}
|
||||
|
||||
public static ScoreEnum getScoreEnum(Integer score) {
|
||||
if (Objects.isNull(score)){
|
||||
return null;
|
||||
}
|
||||
|
||||
if (score < 50){
|
||||
return EVIDENCE_NOT_FULL;
|
||||
}
|
||||
|
||||
if (score <= 70){
|
||||
return EVIDENCE_LACK;
|
||||
}
|
||||
|
||||
return EVIDENCE_FULL;
|
||||
}
|
||||
}
|
@ -0,0 +1,169 @@
|
||||
package com.supervision.police.dto.caseScore;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.supervision.constants.ScoreEnum;
|
||||
import com.supervision.police.domain.*;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import org.springframework.ai.ollama.OllamaChatClient;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 案件得分详情
|
||||
*/
|
||||
@Data
|
||||
public class CaseScoreDetailBuilder {
|
||||
|
||||
@Schema(description = "案件id")
|
||||
private String caseId;
|
||||
|
||||
@Schema(description = "案件名称")
|
||||
private String caseName;
|
||||
|
||||
@Schema(description = "当事人列表")
|
||||
private List<LawParty> lawPartyList;
|
||||
|
||||
@Schema(description = "指标结果")
|
||||
private List<IndexResult> indexResultList;
|
||||
|
||||
/**
|
||||
* Ollama 客户端
|
||||
*/
|
||||
private OllamaChatClient chatClient;
|
||||
|
||||
|
||||
/**
|
||||
* 共性指标分数
|
||||
* @return
|
||||
*/
|
||||
public Integer getCommonScore() {
|
||||
|
||||
return sumIndexGroupScore("1");
|
||||
}
|
||||
|
||||
/**
|
||||
* 入罪指标分数
|
||||
* @return
|
||||
*/
|
||||
public Integer getCrimeScore() {
|
||||
|
||||
return sumIndexGroupScore("2");
|
||||
}
|
||||
|
||||
/**
|
||||
* 出罪指标分数
|
||||
* @return
|
||||
*/
|
||||
public Integer getCrimeOutScore() {
|
||||
return sumIndexGroupScore("3");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取行为人
|
||||
*/
|
||||
public LawParty getLawActor() {
|
||||
if (CollUtil.isEmpty(this.lawPartyList)){
|
||||
return null;
|
||||
}
|
||||
return this.lawPartyList.stream()
|
||||
.filter(lawParty -> StrUtil.equals("1",lawParty.getUserType())).findFirst().orElse(null);
|
||||
}
|
||||
|
||||
public void setIndexResultList(List<ModelIndex> indexList, List<ModelIndexResult> indexResultList,
|
||||
List<ModelAtomicIndex> atomicIndexList, List<ModelAtomicResult> atomicResultList) {
|
||||
|
||||
if (CollUtil.isEmpty(indexList) || CollUtil.isEmpty(indexResultList)){
|
||||
this.indexResultList = new ArrayList<>();
|
||||
return;
|
||||
}
|
||||
|
||||
Map<String, ModelIndexResult> modelIndexResultMap = indexResultList.stream().collect(
|
||||
Collectors.toMap(ModelIndexResult::getIndexId, modelIndexResult -> modelIndexResult));
|
||||
|
||||
this.indexResultList = indexList.stream().map(indexInfo ->
|
||||
new IndexResult(indexInfo,modelIndexResultMap.get(indexInfo.getId()),atomicIndexList,atomicResultList)
|
||||
).toList();
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置行为人
|
||||
* @param casePersonList
|
||||
*/
|
||||
public void setLawActor(List<CasePerson> casePersonList) {
|
||||
if (CollUtil.isEmpty(casePersonList)){
|
||||
this.lawPartyList = new ArrayList<>();
|
||||
return;
|
||||
}
|
||||
this.lawPartyList = casePersonList.stream()
|
||||
.map(casePerson -> {
|
||||
LawParty lawParty = new LawParty();
|
||||
lawParty.setUserId(casePerson.getId());
|
||||
lawParty.setUserName(casePerson.getName());
|
||||
lawParty.setUserType(casePerson.getRoleCode());
|
||||
return lawParty;
|
||||
}).toList();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 构建CaseScoreDetailDTO
|
||||
*/
|
||||
public CaseScoreDetailDTO build(){
|
||||
|
||||
CaseScoreDetailDTO caseScoreDetailDTO = new CaseScoreDetailDTO();
|
||||
caseScoreDetailDTO.setCaseName(this.caseName);
|
||||
caseScoreDetailDTO.setCommonScore(this.getCommonScore());
|
||||
Integer crimeScore = this.getCrimeScore();
|
||||
Integer crimeOutScore = this.getCrimeOutScore();
|
||||
caseScoreDetailDTO.setCrimeScore(crimeScore < crimeOutScore? crimeOutScore:crimeScore);
|
||||
|
||||
int sumScore = caseScoreDetailDTO.getCommonScore() + caseScoreDetailDTO.getCrimeScore();
|
||||
ScoreEnum scoreEnum = ScoreEnum.getScoreEnum(sumScore);
|
||||
if (scoreEnum != null){
|
||||
caseScoreDetailDTO.setScoreDesc(scoreEnum.getDesc());
|
||||
caseScoreDetailDTO.setJudicialCharacterization(scoreEnum.getName());
|
||||
}
|
||||
|
||||
caseScoreDetailDTO.setCommonIndexCount(this.countIndexGroup("1",res->true).intValue());
|
||||
caseScoreDetailDTO.setCommonIndexHitCount(this.countIndexGroup("1",res->res.getActualScore() > 0).intValue());
|
||||
|
||||
if (crimeScore < crimeOutScore){
|
||||
caseScoreDetailDTO.setCrimeIndexCount(this.countIndexGroup("3",res->true).intValue());
|
||||
caseScoreDetailDTO.setCrimeIndexHitCount(this.countIndexGroup("3",res->res.getActualScore() > 0).intValue());
|
||||
}else {
|
||||
caseScoreDetailDTO.setCrimeIndexCount(this.countIndexGroup("2",res->true).intValue());
|
||||
caseScoreDetailDTO.setCrimeIndexHitCount(this.countIndexGroup("2",res->res.getActualScore() > 0).intValue());
|
||||
}
|
||||
return caseScoreDetailDTO;
|
||||
}
|
||||
|
||||
private Integer sumIndexGroupScore(String indexGroup) {
|
||||
if (CollUtil.isEmpty(this.indexResultList)){
|
||||
return 0;
|
||||
}
|
||||
|
||||
return this.indexResultList.stream()
|
||||
.filter(indexResult -> StrUtil.equals(indexGroup,indexResult.getIndexGroup()))
|
||||
.mapToInt(IndexResult::getIndexScore).sum();
|
||||
|
||||
}
|
||||
|
||||
private Long countIndexGroup(String indexGroup, Function<IndexResult, Boolean> function) {
|
||||
if (CollUtil.isEmpty(this.indexResultList)){
|
||||
return 0L;
|
||||
}
|
||||
|
||||
return this.indexResultList.stream()
|
||||
.filter(indexResult -> StrUtil.equals(indexGroup,indexResult.getIndexGroup())
|
||||
&& function.apply(indexResult)).count();
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
package com.supervision.police.dto.caseScore;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@Slf4j
|
||||
public class CaseScoreDetailDTO {
|
||||
|
||||
@Schema(description = "案件名称")
|
||||
private String caseName;
|
||||
|
||||
@Schema(description = "共性指标分数")
|
||||
private Integer commonScore;
|
||||
|
||||
@Schema(description = "入罪指标分数")
|
||||
private Integer crimeScore;
|
||||
|
||||
@Schema(description = "分数描述")
|
||||
private String scoreDesc;
|
||||
|
||||
@Schema(description = "司法定性")
|
||||
private String judicialCharacterization;
|
||||
|
||||
@Schema(description = "共性指标数量")
|
||||
private Integer commonIndexCount;
|
||||
|
||||
@Schema(description = "共性指标命中数量")
|
||||
private Integer commonIndexHitCount;
|
||||
|
||||
@Schema(description = "共性指标命描述")
|
||||
private List<String> commonIndexDescList;
|
||||
|
||||
@Schema(description = "入罪指标数量")
|
||||
private Integer crimeIndexCount;
|
||||
|
||||
@Schema(description = "入罪指标命中数量")
|
||||
private Integer crimeIndexHitCount;
|
||||
|
||||
@Schema(description = "入罪指标命描述")
|
||||
private List<String> crimeIndexDescList;
|
||||
|
||||
@Schema(description = "缺失的原子指标数量")
|
||||
private Integer missAtomicIndexCount;
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue