1. 修复bug

topo_dev
xueqingkun 9 months ago
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;
}
}

@ -58,9 +58,10 @@ public class CaseEvidenceController {
@Operation(summary = "分页查询案件证据信息列表") @Operation(summary = "分页查询案件证据信息列表")
@GetMapping("/pageListEvidence") @GetMapping("/pageListEvidence")
public R<IPage<CaseEvidenceDetailDTO>> pageListEvidence(@RequestParam @Parameter(name = "caseId",description = "案件id") String caseId, public R<IPage<CaseEvidenceDetailDTO>> pageListEvidence(@RequestParam @Parameter(name = "caseId",description = "案件id") String caseId,
@RequestParam @Parameter(name = "evidenceName",description = "证据名") String evidenceName,
@RequestParam(defaultValue = "1") @Parameter(name = "pageNum",description = "页码") Integer pageNum, @RequestParam(defaultValue = "1") @Parameter(name = "pageNum",description = "页码") Integer pageNum,
@RequestParam(defaultValue = "10") @Parameter(name = "pageSize",description = "每页数量") Integer pageSize) { @RequestParam(defaultValue = "10") @Parameter(name = "pageSize",description = "每页数量") Integer pageSize) {
IPage<CaseEvidenceDetailDTO> pageListEvidence = caseEvidenceService.pageListEvidence(caseId, pageNum, pageSize); IPage<CaseEvidenceDetailDTO> pageListEvidence = caseEvidenceService.pageListEvidence(caseId, evidenceName,pageNum, pageSize);
return R.ok(pageListEvidence); return R.ok(pageListEvidence);
} }
} }

@ -8,6 +8,7 @@ import com.supervision.police.dto.CaseAtomicResultWrapper;
import com.supervision.police.service.ModelIndexService; import com.supervision.police.service.ModelIndexService;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.Parameter;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -21,10 +22,10 @@ import java.util.List;
*/ */
@RestController @RestController
@RequestMapping("/modelIndex") @RequestMapping("/modelIndex")
@RequiredArgsConstructor
public class ModelIndexController { public class ModelIndexController {
@Autowired private final ModelIndexService modelIndexService;
private ModelIndexService modelIndexService;
/** /**
* *

@ -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;
}
/**
* listjson
* @param judgeLogicList
* @return
*/
public String judgeLogicToJson(List<JudgeLogic> judgeLogicList) {
return JSONUtil.toJsonStr(judgeLogicList);
}
}

@ -44,7 +44,7 @@ public interface CaseEvidenceService {
* @param pageSize * @param pageSize
* @return * @return
*/ */
IPage<CaseEvidenceDetailDTO> pageListEvidence(String caseId, Integer pageNum, Integer pageSize); IPage<CaseEvidenceDetailDTO> pageListEvidence(String caseId,String evidenceName, Integer pageNum, Integer pageSize);
/** /**
* *

@ -27,4 +27,13 @@ public interface ModelAtomicIndexService extends IService<ModelAtomicIndex> {
* @return * @return
*/ */
List<ModelAtomicIndex> listCaseAtomicIndex(List<String> indexIdList, String caseId, String indexSource); List<ModelAtomicIndex> listCaseAtomicIndex(List<String> indexIdList, String caseId, String indexSource);
/**
*
* @param caseType
* @param atomicIndexId id
*/
void whenDeleteAtomicIndex(String caseType,String atomicIndexId);
} }

@ -1,6 +1,7 @@
package com.supervision.police.service.impl; package com.supervision.police.service.impl;
import cn.hutool.core.lang.Assert; import cn.hutool.core.lang.Assert;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.plugins.pagination.PageDTO; import com.baomidou.mybatisplus.extension.plugins.pagination.PageDTO;
@ -113,10 +114,11 @@ public class CaseEvidenceServiceImpl implements CaseEvidenceService {
@Override @Override
@Transactional(transactionManager = "dataSourceTransactionManager",rollbackFor = Exception.class) @Transactional(transactionManager = "dataSourceTransactionManager",rollbackFor = Exception.class)
public IPage<CaseEvidenceDetailDTO> pageListEvidence(String caseId, Integer pageNum, Integer pageSize) { public IPage<CaseEvidenceDetailDTO> pageListEvidence(String caseId,String evidenceName, Integer pageNum, Integer pageSize) {
Assert.notEmpty(caseId,"案件id不能为空"); Assert.notEmpty(caseId,"案件id不能为空");
Page<CaseEvidence> caseEvidencePage = caseEvidenceDaoService.lambdaQuery().eq(CaseEvidence::getCaseId, caseId) Page<CaseEvidence> caseEvidencePage = caseEvidenceDaoService.lambdaQuery().eq(CaseEvidence::getCaseId, caseId)
.like(StrUtil.isNotEmpty(evidenceName), CaseEvidence::getEvidenceName,evidenceName)
.orderBy(true, false,CaseEvidence::getUpdateTime) .orderBy(true, false,CaseEvidence::getUpdateTime)
.page(new Page<>(pageNum, pageSize)); .page(new Page<>(pageNum, pageSize));

@ -1,13 +1,24 @@
package com.supervision.police.service.impl; package com.supervision.police.service.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.supervision.constant.DataStatus;
import com.supervision.police.domain.ModelAtomicIndex; import com.supervision.police.domain.ModelAtomicIndex;
import com.supervision.police.domain.ModelIndex;
import com.supervision.police.dto.JudgeLogic;
import com.supervision.police.dto.ModelIndexDTO;
import com.supervision.police.mapper.ModelAtomicIndexMapper; import com.supervision.police.mapper.ModelAtomicIndexMapper;
import com.supervision.police.service.ModelAtomicIndexService; import com.supervision.police.service.ModelAtomicIndexService;
import com.supervision.police.service.ModelIndexService;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List; import java.util.List;
@ -16,6 +27,9 @@ import java.util.List;
@RequiredArgsConstructor @RequiredArgsConstructor
public class ModelAtomicIndexServiceImpl extends ServiceImpl<ModelAtomicIndexMapper, ModelAtomicIndex> implements ModelAtomicIndexService { public class ModelAtomicIndexServiceImpl extends ServiceImpl<ModelAtomicIndexMapper, ModelAtomicIndex> implements ModelAtomicIndexService {
@Lazy
@Autowired
private ModelIndexService modelIndexService;
@Override @Override
public ModelAtomicIndexMapper getMapper() { public ModelAtomicIndexMapper getMapper() {
return super.getBaseMapper(); return super.getBaseMapper();
@ -40,4 +54,31 @@ public class ModelAtomicIndexServiceImpl extends ServiceImpl<ModelAtomicIndexMap
public List<ModelAtomicIndex> listCaseAtomicIndex(List<String> indexIdList, String caseType, String indexSource) { public List<ModelAtomicIndex> listCaseAtomicIndex(List<String> indexIdList, String caseType, String indexSource) {
return super.getBaseMapper().listCaseAtomicIndex(indexIdList, caseType, indexSource); return super.getBaseMapper().listCaseAtomicIndex(indexIdList, caseType, indexSource);
} }
@Override
@Transactional(transactionManager = "dataSourceTransactionManager",rollbackFor = Exception.class)
public void whenDeleteAtomicIndex(String caseType,String atomicIndexId) {
if (StrUtil.isEmpty(atomicIndexId)){
log.warn("whenDeleteAtomicIndex: atomicIndexId is null,停止后续操作..");
return;
}
// 清理指标中的关联数据
// 获取指标列表
List<ModelIndex> modelIndexList = modelIndexService.list(new LambdaQueryWrapper<ModelIndex>()
.eq(StrUtil.isNotEmpty(caseType),ModelIndex::getCaseType, caseType)
.eq(ModelIndex::getDataStatus, DataStatus.AVAILABLE.getCode()));
List<ModelIndexDTO> modelIndexDTOList = modelIndexList.stream().map(ModelIndexDTO::new)
.filter(modelIndexDTO -> modelIndexDTO.logicContainAtomicIndex(atomicIndexId)).toList();
if (CollUtil.isEmpty(modelIndexDTOList)){
return;
}
modelIndexDTOList.forEach(modelIndexDTO -> {
List<JudgeLogic> judgeLogicList = modelIndexDTO.judgeLogicExcludeAtomicIndex(atomicIndexId);
modelIndexDTO.setJudgeLogic(modelIndexDTO.judgeLogicToJson(judgeLogicList));
modelIndexService.lambdaUpdate().eq(ModelIndex::getId, modelIndexDTO.getId()).set(ModelIndex::getJudgeLogic, modelIndexDTO.getJudgeLogic()).update();
});
}
} }

@ -15,6 +15,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.supervision.common.domain.R; import com.supervision.common.domain.R;
import com.supervision.common.utils.IPages; import com.supervision.common.utils.IPages;
import com.supervision.common.utils.StringUtils; import com.supervision.common.utils.StringUtils;
import com.supervision.constant.DataStatus;
import com.supervision.police.domain.*; import com.supervision.police.domain.*;
import com.supervision.police.dto.AtomicData; import com.supervision.police.dto.AtomicData;
import com.supervision.police.dto.CaseAtomicIndexDTO; import com.supervision.police.dto.CaseAtomicIndexDTO;
@ -119,7 +120,7 @@ public class ModelIndexServiceImpl extends ServiceImpl<ModelIndexMapper, ModelIn
@Transactional(transactionManager = "dataSourceTransactionManager", rollbackFor = Exception.class) @Transactional(transactionManager = "dataSourceTransactionManager", rollbackFor = Exception.class)
public R<?> del(String id) { public R<?> del(String id) {
ModelIndex index = modelIndexMapper.selectById(id); ModelIndex index = modelIndexMapper.selectById(id);
index.setDataStatus(StringUtils.getUUID()); index.setDataStatus(DataStatus.NOT_AVAILABLE.getCode());
int i = modelIndexMapper.updateById(index); int i = modelIndexMapper.updateById(index);
if (i > 0) { if (i > 0) {
return R.okMsg("删除成功"); return R.okMsg("删除成功");
@ -154,7 +155,8 @@ public class ModelIndexServiceImpl extends ServiceImpl<ModelIndexMapper, ModelIn
Assert.isTrue(checkSql(modelAtomicIndex.getQueryLang()), "查询语句不合法"); Assert.isTrue(checkSql(modelAtomicIndex.getQueryLang()), "查询语句不合法");
} }
// 校验是否已经存在了相同名称的原子指标 // 校验是否已经存在了相同名称的原子指标
ModelAtomicIndex existIndex = modelAtomicIndexService.lambdaQuery().eq(ModelAtomicIndex::getName, modelAtomicIndex.getName()).last("limit 1").one(); ModelAtomicIndex existIndex = modelAtomicIndexService.lambdaQuery().eq(ModelAtomicIndex::getName, modelAtomicIndex.getName())
.eq(ModelAtomicIndex::getDataStatus, DataStatus.AVAILABLE.getCode()).last("limit 1").one();
if (ObjectUtil.isNotEmpty(existIndex) && !StringUtils.equals(modelAtomicIndex.getId(), existIndex.getId())){ if (ObjectUtil.isNotEmpty(existIndex) && !StringUtils.equals(modelAtomicIndex.getId(), existIndex.getId())){
throw new RuntimeException("已存在相同名称的原子指标"); throw new RuntimeException("已存在相同名称的原子指标");
} }
@ -174,9 +176,10 @@ public class ModelIndexServiceImpl extends ServiceImpl<ModelIndexMapper, ModelIn
@Transactional(transactionManager = "dataSourceTransactionManager", rollbackFor = Exception.class) @Transactional(transactionManager = "dataSourceTransactionManager", rollbackFor = Exception.class)
public R<?> delAtomic(String id) { public R<?> delAtomic(String id) {
ModelAtomicIndex index = modelAtomicIndexService.getMapper().selectById(id); ModelAtomicIndex index = modelAtomicIndexService.getMapper().selectById(id);
index.setDataStatus(StringUtils.getUUID()); index.setDataStatus(DataStatus.NOT_AVAILABLE.getCode());
int i = modelAtomicIndexService.getMapper().updateById(index); int i = modelAtomicIndexService.getMapper().updateById(index);
if (i > 0) { if (i > 0) {
modelAtomicIndexService.whenDeleteAtomicIndex(index.getCaseType(), id);
return R.okMsg("删除成功"); return R.okMsg("删除成功");
} else { } else {
return R.fail("删除失败"); return R.fail("删除失败");

Loading…
Cancel
Save