1. 修复bug
parent
3e6fa2821c
commit
8a564a8b29
@ -0,0 +1,20 @@
|
||||
package com.supervision.constant;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
public enum DataStatus {
|
||||
|
||||
AVAILABLE("1","生效"),
|
||||
|
||||
NOT_AVAILABLE("2","失效");
|
||||
|
||||
private final String code;
|
||||
|
||||
private final String msg;
|
||||
|
||||
DataStatus(String code, String msg) {
|
||||
this.code = code;
|
||||
this.msg = msg;
|
||||
}
|
||||
}
|
@ -0,0 +1,151 @@
|
||||
package com.supervision.police.dto;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.supervision.common.utils.StringUtils;
|
||||
import com.supervision.police.domain.ModelIndex;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import javax.imageio.plugins.tiff.TIFFDirectory;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Data
|
||||
@Slf4j
|
||||
public class ModelIndexDTO {
|
||||
|
||||
@Schema(description = "指标id")
|
||||
private String id;
|
||||
|
||||
@Schema(description = "指标名称")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "指标简称")
|
||||
private String shortName;
|
||||
|
||||
@Schema(description = "指标说明")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "指标类别")
|
||||
private String indexType;
|
||||
|
||||
@Schema(description = "指标分数")
|
||||
private Integer indexScore;
|
||||
|
||||
@Schema(description = "案件类型")
|
||||
private String caseType;
|
||||
|
||||
@Schema(description = "判断逻辑字符串")
|
||||
private String judgeLogic;
|
||||
|
||||
@Schema(description = "判断逻辑list")
|
||||
private List<JudgeLogic> judgeLogicList;
|
||||
|
||||
public ModelIndexDTO() {
|
||||
}
|
||||
|
||||
public ModelIndexDTO(ModelIndex modelIndex) {
|
||||
if (Objects.isNull(modelIndex)){
|
||||
return;
|
||||
}
|
||||
this.id = modelIndex.getId();
|
||||
this.name = modelIndex.getName();
|
||||
this.shortName = modelIndex.getShortName();
|
||||
this.remark = modelIndex.getRemark();
|
||||
this.indexType = modelIndex.getIndexType();
|
||||
this.indexScore = modelIndex.getIndexScore();
|
||||
this.caseType = modelIndex.getCaseType();
|
||||
this.judgeLogic = modelIndex.getJudgeLogic();
|
||||
if (StrUtil.isNotEmpty(this.judgeLogic)){
|
||||
try {
|
||||
this.judgeLogicList = JSONUtil.toList(this.judgeLogic, JudgeLogic.class);
|
||||
} catch (Exception e) {
|
||||
log.error("ModelIndexDTO: 解析judgeLogic失败:id:{},judgeLogic:{}",this.id,this.judgeLogic,e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断逻辑是否包含原子指标
|
||||
* @param atomicIndexId 原子指标id
|
||||
* @return
|
||||
*/
|
||||
public boolean logicContainAtomicIndex(String atomicIndexId) {
|
||||
if (StrUtil.isEmpty(atomicIndexId)){
|
||||
return false;
|
||||
}
|
||||
if (CollUtil.isEmpty(this.judgeLogicList)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return this.judgeLogicList.stream().anyMatch(logic -> logicContainAtomicIndex(logic, atomicIndexId));
|
||||
}
|
||||
|
||||
private boolean logicContainAtomicIndex(JudgeLogic logic,String atomicIndexId) {
|
||||
|
||||
if (Objects.isNull(logic)){
|
||||
return false;
|
||||
}
|
||||
|
||||
List<AtomicData> atomicData = logic.getAtomicData();
|
||||
if (CollUtil.isEmpty(atomicData)){
|
||||
return false;
|
||||
}
|
||||
|
||||
for (AtomicData atomicDatum : atomicData) {
|
||||
if (atomicIndexId.equals(atomicDatum.getAtomicIndex())){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 清除指定原子指标
|
||||
* @param atomicIndexId 原子指标id
|
||||
* @return
|
||||
*/
|
||||
public List<JudgeLogic> judgeLogicExcludeAtomicIndex(String atomicIndexId) {
|
||||
if (StrUtil.isEmpty(atomicIndexId)){
|
||||
return this.judgeLogicList;
|
||||
}
|
||||
if (CollUtil.isEmpty(this.judgeLogicList)){
|
||||
return CollUtil.newArrayList();
|
||||
}
|
||||
|
||||
List<JudgeLogic> result = new ArrayList<>();
|
||||
for (JudgeLogic logic : this.judgeLogicList) {
|
||||
if (Objects.isNull(logic)){
|
||||
continue;
|
||||
}
|
||||
List<AtomicData> atomicDataList = new ArrayList<>();
|
||||
for (AtomicData atomicDatum : logic.getAtomicData()) {
|
||||
if (!atomicIndexId.equals(atomicDatum.getAtomicIndex())){
|
||||
atomicDataList.add(atomicDatum);
|
||||
}
|
||||
}
|
||||
JudgeLogic resultLogic = new JudgeLogic();
|
||||
resultLogic.setRowLogic(logic.getRowLogic());
|
||||
resultLogic.setGroupLogic(logic.getGroupLogic());
|
||||
resultLogic.setAtomicData(atomicDataList);
|
||||
result.add(resultLogic);
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 将判断逻辑list转换为json
|
||||
* @param judgeLogicList
|
||||
* @return
|
||||
*/
|
||||
public String judgeLogicToJson(List<JudgeLogic> judgeLogicList) {
|
||||
return JSONUtil.toJsonStr(judgeLogicList);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue