1. 添加新功能

topo_dev
xueqingkun 10 months ago
parent b2a802d47b
commit b817b69c4d

@ -1,8 +1,10 @@
package com.supervision.police.controller; package com.supervision.police.controller;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Assert;
import com.supervision.common.domain.R; import com.supervision.common.domain.R;
import com.supervision.police.dto.CaseEvidenceDetailDTO; import com.supervision.police.dto.CaseEvidenceDetailDTO;
import com.supervision.police.dto.EvidenceIdWrapper;
import com.supervision.police.service.CaseEvidenceService; import com.supervision.police.service.CaseEvidenceService;
import com.supervision.police.dto.CaseEvidenceDTO; import com.supervision.police.dto.CaseEvidenceDTO;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
@ -41,8 +43,9 @@ public class CaseEvidenceController {
@Operation(summary = "删除案件证据信息") @Operation(summary = "删除案件证据信息")
@DeleteMapping("/deleteEvidence") @DeleteMapping("/deleteEvidence")
public R<Boolean> deleteEvidence(String evidenceId) { public R<Boolean> deleteEvidence(@RequestBody EvidenceIdWrapper evidenceIdWrapper) {
boolean success = caseEvidenceService.deleteEvidence(evidenceId); Assert.notEmpty(evidenceIdWrapper.getEvidenceId(), "证据id不能为空");
boolean success = caseEvidenceService.deleteEvidence(evidenceIdWrapper.getEvidenceId());
return R.ok(success); return R.ok(success);
} }
@ -55,9 +58,9 @@ 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(defaultValue = "1") @Parameter(name = "page",description = "页码") Integer page, @RequestParam(defaultValue = "1") @Parameter(name = "pageNum",description = "页码") Integer pageNum,
@RequestParam(defaultValue = "10") @Parameter(name = "size",description = "每页数量") Integer size) { @RequestParam(defaultValue = "10") @Parameter(name = "pageSize",description = "每页数量") Integer pageSize) {
IPage<CaseEvidenceDetailDTO> pageListEvidence = caseEvidenceService.pageListEvidence(caseId, page, size); IPage<CaseEvidenceDetailDTO> pageListEvidence = caseEvidenceService.pageListEvidence(caseId, pageNum, pageSize);
return R.ok(pageListEvidence); return R.ok(pageListEvidence);
} }
} }

@ -1,11 +1,11 @@
package com.supervision.police.controller; package com.supervision.police.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.supervision.common.domain.R; import com.supervision.common.domain.R;
import com.supervision.police.domain.ModelAtomicIndex; import com.supervision.police.domain.ModelAtomicIndex;
import com.supervision.police.domain.ModelIndex; import com.supervision.police.domain.ModelIndex;
import com.supervision.police.dto.CaseAtomicIndexDTO;
import com.supervision.police.service.ModelIndexService; import com.supervision.police.service.ModelIndexService;
import io.swagger.v3.oas.annotations.Parameter;
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.*;
@ -98,5 +98,19 @@ public class ModelIndexController {
return modelIndexService.delAtomic(id); return modelIndexService.delAtomic(id);
} }
/**
*
* @return
*/
@GetMapping("/listCaseAtomicIndex")
public R<List<CaseAtomicIndexDTO>> pageListCaseAtomicIndex(
@RequestParam @Parameter(name = "caseId",description = "案件id") String caseId,
@RequestParam(defaultValue = "1")
@Parameter(name = "indexSource",description = "指标来源 1:人工定义 2:数据库查询 3:图谱生成 4:大模型") String indexSource) {
List<CaseAtomicIndexDTO> list = modelIndexService.listCaseAtomicIndex(caseId, indexSource);
return R.ok(list);
}
} }

@ -1,25 +1,68 @@
package com.supervision.police.dto; package com.supervision.police.dto;
import com.supervision.police.domain.ModelAtomicIndex;
import com.supervision.police.domain.ModelAtomicResult;
import com.supervision.police.domain.ModelIndex;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
import java.util.Objects;
/** /**
* DTO * DTO
*/ */
@Data @Data
public class CaseAtomicIndexDTO { public class CaseAtomicIndexDTO {
@Schema(description = "原子评估结果id")
private String atomicResultId;
@Schema(description = "案件id") @Schema(description = "案件id")
private String caseId; private String caseId;
@Schema(description = "原子指标名称")
private String indexName;
@Schema(description = "原子指标id") @Schema(description = "原子指标id")
private String automicIndex; private String atomicIndexId;
@Schema(description = "原子指标名") @Schema(description = "原子指标名")
private String automicIndexName; private String automicIndexName;
@Schema(description = "指标id")
private String indexId;
@Schema(description = "指标名")
private String indexName;
@Schema(description = "案件类型")
private String caseType;
@Schema(description = "指标来源 1:人工定义 2:数据库查询 3:图谱生成 4:大模型")
private String indexSource;
@Schema(description = "评估结果")
private String atomicResult;
@Schema(description = "备注")
private String remark;
public CaseAtomicIndexDTO() {
}
public CaseAtomicIndexDTO(ModelAtomicIndex modelAtomicIndex, ModelIndex modelIndex, ModelAtomicResult modelAtomicResult) {
if (Objects.nonNull(modelAtomicIndex)){
this.atomicIndexId = modelAtomicIndex.getId();
this.automicIndexName = modelAtomicIndex.getName();
}
if (Objects.nonNull(modelIndex)){
this.caseType = modelIndex.getCaseType();
this.indexName = modelIndex.getName();
this.indexId = modelIndex.getId();
}
if (Objects.nonNull(modelAtomicResult)){
this.atomicResult = modelAtomicResult.getAtomicResult();
this.atomicResultId = modelAtomicResult.getId();
this.caseId = modelAtomicResult.getCaseId();
// todo: this.remark = modelAtomicResult.getRemark();
}
}
} }

@ -19,5 +19,8 @@ public interface ModelAtomicIndexMapper extends BaseMapper<ModelAtomicIndex> {
List<ModelAtomicIndex> selectByCaseType(@Param("caseType") String caseType); List<ModelAtomicIndex> selectByCaseType(@Param("caseType") String caseType);
List<ModelAtomicIndex> listCaseAtomicIndex(@Param("indexIdList") List<String> indexIdList,
@Param("caseType") String caseType,
@Param("indexSource") String indexSource);
} }

@ -0,0 +1,22 @@
package com.supervision.police.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.supervision.police.domain.ModelAtomicIndex;
import com.supervision.police.mapper.ModelAtomicIndexMapper;
import java.util.List;
public interface ModelAtomicIndexService {
ModelAtomicIndexMapper getMapper();
IPage<ModelAtomicIndex> selectAll(IPage<ModelAtomicIndex> iPage,ModelAtomicIndex index);
List<ModelAtomicIndex> selectByCaseType(String caseType);
List<ModelAtomicIndex> selectBatchIds(List<String> ids);
List<ModelAtomicIndex> listCaseAtomicIndex(List<String> indexIdList, String caseId, String indexSource);
}

@ -4,6 +4,9 @@ import com.baomidou.mybatisplus.extension.service.IService;
import com.supervision.common.domain.R; import com.supervision.common.domain.R;
import com.supervision.police.domain.ModelAtomicIndex; import com.supervision.police.domain.ModelAtomicIndex;
import com.supervision.police.domain.ModelIndex; import com.supervision.police.domain.ModelIndex;
import com.supervision.police.dto.CaseAtomicIndexDTO;
import java.util.List;
/** /**
* (ModelIndex) * (ModelIndex)
@ -25,5 +28,6 @@ public interface ModelIndexService extends IService<ModelIndex> {
R<?> delAtomic(String id); R<?> delAtomic(String id);
List<CaseAtomicIndexDTO> listCaseAtomicIndex(String caseId, String indexSource);
} }

@ -0,0 +1,43 @@
package com.supervision.police.service.impl;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.supervision.police.domain.ModelAtomicIndex;
import com.supervision.police.mapper.ModelAtomicIndexMapper;
import com.supervision.police.service.ModelAtomicIndexService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.util.List;
@Slf4j
@Service
@RequiredArgsConstructor
public class ModelAtomicIndexServiceImpl extends ServiceImpl<ModelAtomicIndexMapper, ModelAtomicIndex> implements ModelAtomicIndexService {
@Override
public ModelAtomicIndexMapper getMapper() {
return super.getBaseMapper();
}
@Override
public IPage<ModelAtomicIndex> selectAll(IPage<ModelAtomicIndex> iPage, ModelAtomicIndex index) {
return super.getBaseMapper().selectAll(iPage, index);
}
@Override
public List<ModelAtomicIndex> selectByCaseType(String caseType) {
return super.getBaseMapper().selectByCaseType(caseType);
}
@Override
public List<ModelAtomicIndex> selectBatchIds(List<String> ids) {
return super.getBaseMapper().selectBatchIds(ids);
}
@Override
public List<ModelAtomicIndex> listCaseAtomicIndex(List<String> indexIdList, String caseType, String indexSource) {
return super.getBaseMapper().listCaseAtomicIndex(indexIdList, caseType, indexSource);
}
}

@ -1,32 +1,36 @@
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 cn.hutool.json.JSONUtil; import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; 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.core.toolkit.Assert;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 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.police.domain.ComDictionary; import com.supervision.police.domain.*;
import com.supervision.police.domain.ModelAtomicIndex;
import com.supervision.police.dto.AtomicData; import com.supervision.police.dto.AtomicData;
import com.supervision.police.dto.CaseAtomicIndexDTO;
import com.supervision.police.dto.JudgeLogic; import com.supervision.police.dto.JudgeLogic;
import com.supervision.police.mapper.ModelAtomicIndexMapper; import com.supervision.police.mapper.ModelAtomicResultMapper;
import com.supervision.police.mapper.ModelIndexMapper; import com.supervision.police.mapper.ModelIndexMapper;
import com.supervision.police.domain.ModelIndex;
import com.supervision.police.service.ComDictionaryService; import com.supervision.police.service.ComDictionaryService;
import com.supervision.police.service.ModelAtomicIndexService;
import com.supervision.police.service.ModelCaseService;
import com.supervision.police.service.ModelIndexService; import com.supervision.police.service.ModelIndexService;
import com.supervision.springaidemo.dto.MetricResultDTO; import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired; import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.Map;
import java.util.regex.Matcher; import java.util.stream.Collectors;
import java.util.regex.Pattern;
/** /**
* (ModelIndex) * (ModelIndex)
@ -34,18 +38,20 @@ import java.util.regex.Pattern;
* @author qmy * @author qmy
* @since 2024-07-05 09:20:10 * @since 2024-07-05 09:20:10
*/ */
@Slf4j
@Service @Service
@RequiredArgsConstructor
public class ModelIndexServiceImpl extends ServiceImpl<ModelIndexMapper, ModelIndex> implements ModelIndexService { public class ModelIndexServiceImpl extends ServiceImpl<ModelIndexMapper, ModelIndex> implements ModelIndexService {
@Autowired private final ComDictionaryService comDictionaryService;
private ComDictionaryService comDictionaryService;
@Autowired private final ModelIndexMapper modelIndexMapper;
private ModelIndexMapper modelIndexMapper;
@Autowired private final ModelAtomicIndexService modelAtomicIndexService;
private ModelAtomicIndexMapper modelAtomicIndexMapper;
private final ModelCaseService modelCaseService;
private final ModelAtomicResultMapper modelAtomicResultMapper;
@Override @Override
public R<?> selectAll(ModelIndex modelIndex, Integer page, Integer size) { public R<?> selectAll(ModelIndex modelIndex, Integer page, Integer size) {
IPage<ModelIndex> iPage = new Page<>(page, size); IPage<ModelIndex> iPage = new Page<>(page, size);
@ -73,7 +79,7 @@ public class ModelIndexServiceImpl extends ServiceImpl<ModelIndexMapper, ModelIn
ids.add(atomic.getAtomicIndex()); ids.add(atomic.getAtomicIndex());
} }
} }
List<ModelAtomicIndex> atomicIndexList = modelAtomicIndexMapper.selectBatchIds(ids); List<ModelAtomicIndex> atomicIndexList = modelAtomicIndexService.selectBatchIds(ids);
index.setAtomicIndexList(atomicIndexList); index.setAtomicIndexList(atomicIndexList);
} }
index.setAtomicIndexNum(ids.size()); index.setAtomicIndexNum(ids.size());
@ -112,7 +118,7 @@ public class ModelIndexServiceImpl extends ServiceImpl<ModelIndexMapper, ModelIn
@Override @Override
public R<?> selectAllAtomic(ModelAtomicIndex modelAtomicIndex, Integer page, Integer size) { public R<?> selectAllAtomic(ModelAtomicIndex modelAtomicIndex, Integer page, Integer size) {
IPage<ModelAtomicIndex> iPage = new Page<>(page, size); IPage<ModelAtomicIndex> iPage = new Page<>(page, size);
iPage = modelAtomicIndexMapper.selectAll(iPage, modelAtomicIndex); iPage = modelAtomicIndexService.selectAll(iPage, modelAtomicIndex);
List<ModelAtomicIndex> records = iPage.getRecords(); List<ModelAtomicIndex> records = iPage.getRecords();
List<ComDictionary> dicts = comDictionaryService.list(); List<ComDictionary> dicts = comDictionaryService.list();
for (ModelAtomicIndex index : records) { for (ModelAtomicIndex index : records) {
@ -128,9 +134,9 @@ public class ModelIndexServiceImpl extends ServiceImpl<ModelIndexMapper, ModelIn
public R<?> addOrUpdAtomic(ModelAtomicIndex modelAtomicIndex) { public R<?> addOrUpdAtomic(ModelAtomicIndex modelAtomicIndex) {
int i = 0; int i = 0;
if (StringUtils.isEmpty(modelAtomicIndex.getId())) { if (StringUtils.isEmpty(modelAtomicIndex.getId())) {
i = modelAtomicIndexMapper.insert(modelAtomicIndex); i = modelAtomicIndexService.getMapper().insert(modelAtomicIndex);
} else { } else {
i = modelAtomicIndexMapper.updateById(modelAtomicIndex); i = modelAtomicIndexService.getMapper().updateById(modelAtomicIndex);
} }
if (i > 0) { if (i > 0) {
return R.okMsg("保存成功"); return R.okMsg("保存成功");
@ -141,14 +147,73 @@ public class ModelIndexServiceImpl extends ServiceImpl<ModelIndexMapper, ModelIn
@Override @Override
public R<?> delAtomic(String id) { public R<?> delAtomic(String id) {
ModelAtomicIndex index = modelAtomicIndexMapper.selectById(id); ModelAtomicIndex index = modelAtomicIndexService.getMapper().selectById(id);
index.setDataStatus(StringUtils.getUUID()); index.setDataStatus(StringUtils.getUUID());
int i = modelAtomicIndexMapper.updateById(index); int i = modelAtomicIndexService.getMapper().updateById(index);
if (i > 0) { if (i > 0) {
return R.okMsg("删除成功"); return R.okMsg("删除成功");
} else { } else {
return R.fail("删除失败"); return R.fail("删除失败");
} }
} }
@Override
public List<CaseAtomicIndexDTO> listCaseAtomicIndex(String caseId, String indexSource) {
Assert.notEmpty(caseId, "案件id不能为空");
ModelCase modelCase = modelCaseService.getById(caseId);
Assert.notNull(modelCase, "案件不存在");
String caseType = modelCase.getCaseType();
Assert.notEmpty(caseType, "案件类型不能为空");
// 获取案件类型对应的指标
List<ModelIndex> modelIndexList = modelIndexMapper.selectByCaseType(caseType);
if (CollUtil.isEmpty(modelIndexList)){
return new ArrayList<>(1);
}
// 从指标中计算出所有原子指标id
List<String> automicIndexIds = modelIndexList.stream().filter(modelIndex -> StrUtil.isNotEmpty(modelIndex.getJudgeLogic()))
.map(modelIndex -> pickAtomicIndexIds(modelIndex.getJudgeLogic()))
.flatMap(Collection::stream).distinct().toList();
if (CollUtil.isEmpty(automicIndexIds)){
return new ArrayList<>(1);
}
// 查询原子指标相关信息
List<ModelAtomicIndex> modelAtomicIndexList = modelAtomicIndexService.listCaseAtomicIndex(automicIndexIds, caseType, indexSource);
if (CollUtil.isEmpty(modelAtomicIndexList)){
return new ArrayList<>(1);
}
Map<String, ModelAtomicIndex> modelAtomicIndexMap = modelAtomicIndexList.stream().collect(Collectors.toMap(ModelAtomicIndex::getId, v -> v, (v1, v2) -> v1));
// 查询判定结果数据
List<ModelAtomicResult> modelAtomicResults = modelAtomicResultMapper.selectList(Wrappers.lambdaQuery(ModelAtomicResult.class).eq(ModelAtomicResult::getCaseId, caseId));
Map<String, ModelAtomicResult> modelAtomicResultMap = modelAtomicResults.stream()
.filter(modelAtomicResult -> StrUtil.isEmpty(modelAtomicResult.getAtomicId())).collect(Collectors.toMap(ModelAtomicResult::getAtomicId, v -> v, (v1, v2) -> v1));
// 以指标为基础数据,组装原子指标的值。然后把数据进行平铺
return modelIndexList.stream().flatMap(modelIndex -> {
String judgeLogic = modelIndex.getJudgeLogic();
List<String> indexIds = pickAtomicIndexIds(judgeLogic);
return indexIds.stream().map(id ->
new CaseAtomicIndexDTO(modelAtomicIndexMap.get(id), modelIndex, modelAtomicResultMap.get(id))).toList().stream();
}).toList();
}
private List<String> pickAtomicIndexIds(String judgeLogic) {
List<String> ids = new ArrayList<>();
List<JudgeLogic> logic = JSONUtil.toList(judgeLogic, JudgeLogic.class);
for (JudgeLogic judge : logic) {
List<AtomicData> atomicData = judge.getAtomicData();
for (AtomicData atomic : atomicData) {
if (!ids.contains(atomic.getAtomicIndex())){
ids.add(atomic.getAtomicIndex());
}
}
}
return ids;
}
} }

@ -1,6 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.supervision.police.mapper.ModelAtomicIndexMapper"> <mapper namespace="com.supervision.police.mapper.ModelAtomicIndexMapper">
<select id="selectAll" resultType="com.supervision.police.domain.ModelAtomicIndex"> <select id="selectAll" resultType="com.supervision.police.domain.ModelAtomicIndex">
select * from model_atomic_index mai select * from model_atomic_index mai
where data_status = '1' where data_status = '1'
@ -26,7 +28,27 @@
and DATE_FORMAT(update_time, '%Y-%m-%d') &lt;= DATE_FORMAT(#{index.updateEndTime}, '%Y-%m-%d') and DATE_FORMAT(update_time, '%Y-%m-%d') &lt;= DATE_FORMAT(#{index.updateEndTime}, '%Y-%m-%d')
</if> </if>
</select> </select>
<select id="selectByCaseType" resultType="com.supervision.police.domain.ModelAtomicIndex"> <select id="selectByCaseType" resultType="com.supervision.police.domain.ModelAtomicIndex">
select * from model_atomic_index where data_status = '1' and case_type = #{caseType} select * from model_atomic_index where data_status = '1' and case_type = #{caseType}
</select> </select>
<select id="listCaseAtomicIndex" resultType="com.supervision.police.domain.ModelAtomicIndex">
select *
from model_atomic_index
where data_status = '1'
<if test="indexIdList != null and indexIdList.size() > 0">
and id in
<foreach collection="indexIdList" item="indexId" open="(" separator="," close=")">
#{indexId}
</foreach>
</if>
<if test="caseType != null and caseType != ''">
and case_type = #{caseType}
</if>
<if test="indexSource != null and indexSource != ''">
and index_source = #{indexSource}
</if>
</select>
</mapper> </mapper>

@ -3,6 +3,13 @@
<mapper namespace="com.supervision.police.mapper.ModelAtomicResultMapper"> <mapper namespace="com.supervision.police.mapper.ModelAtomicResultMapper">
<select id="selectByCaseIdAndAtomicId" resultType="com.supervision.police.domain.ModelAtomicResult"> <select id="selectByCaseIdAndAtomicId" resultType="com.supervision.police.domain.ModelAtomicResult">
select * from model_atomic_result select * from model_atomic_result
where case_id = #{caseId} and atomic_id = #{atomicId} <where>
<if test="caseId != null and caseId != ''">
and case_id = #{caseId}
</if>
<if test="atomicId != null and atomicId != ''">
and atomic_id = #{atomicId}
</if>
</where>
</select> </select>
</mapper> </mapper>
Loading…
Cancel
Save