1. 结构化数据存储改造

topo_dev
xueqingkun 5 months ago
parent 2bc8cf25a3
commit 70e7c4bf8d

@ -0,0 +1,136 @@
package com.supervision.police.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.time.LocalDateTime;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
/**
*
* @TableName attribute_mmht
*/
@TableName(value ="attribute_mmht")
@Data
public class AttributeMmht implements Serializable {
/**
*
*/
private String id;
/**
* id
*/
private String evidenceId;
/**
*
*/
@Schema(description = "甲方", type = "1")
private String partA;
/**
*
*/
@Schema(description = "乙方", type = "1")
private String partB;
/**
*
*/
@Schema(description = "丙方", type = "1")
private String partC;
/**
*
*/
@Schema(description = "资质要求", type = "1")
private String qualifications;
/**
*
*/
@Schema(description = "合同标的物", type = "1")
private String subjectMatter;
/**
*
*/
@Schema(description = "数量", type = "2")
private String number;
/**
*
*/
@Schema(description = "金额", type = "2")
private String amountMoney;
/**
*
*/
@Schema(description = "支付方式", type = "1")
private String paymentMethod;
/**
*
*/
@Schema(description = "支付时间", type = "3")
private String paymentTime;
/**
*
*/
@Schema(description = "履行期限", type = "3")
private String performancePeriod;
/**
*
*/
@Schema(description = "履行地点", type = "1")
private String placePerformance;
/**
*
*/
@Schema(description = "违约责任", type = "1")
private String liabilityBreach;
/**
*
*/
@Schema(description = "项目详细信息", type = "1")
private String projectDetails;
/**
*
*/
@Schema(description = "签订日期", type = "3")
private String signingDate;
/**
*
*/
private LocalDateTime createTime;
/**
*
*/
private String createUserId;
/**
*
*/
private LocalDateTime updateTime;
/**
*
*/
private String updateUserId;
@TableField(exist = false)
private static final long serialVersionUID = 1L;
}

@ -0,0 +1,88 @@
package com.supervision.police.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.time.LocalDateTime;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
/**
*
* @TableName attribute_yhls
*/
@TableName(value ="attribute_yhls")
@Data
public class AttributeYhls implements Serializable {
/**
*
*/
private String id;
/**
* id
*/
private String evidenceId;
/**
*
*/
@Schema(description = "账户信息", type = "1")
private String accountInformation;
/**
*
*/
@Schema(description = "对方账户信息", type = "1")
private String otherAccountInformation;
/**
*
*/
@Schema(description = "金额", type = "2")
private String amount;
/**
*
*/
@Schema(description = "交易时间", type = "3")
private String tradingTime;
/**
*
*/
@Schema(description = "收入支出标识", type = "1")
private String revenueExpenditureIdentification;
/**
*
*/
@Schema(description = "摘要", type = "1")
private String abstractInfo;
/**
*
*/
private LocalDateTime createTime;
/**
*
*/
private String createUserId;
/**
*
*/
private LocalDateTime updateTime;
/**
*
*/
private String updateUserId;
@TableField(exist = false)
private static final long serialVersionUID = 1L;
}

@ -0,0 +1,82 @@
package com.supervision.police.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.time.LocalDateTime;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
/**
*
* @TableName attribute_zfpz
*/
@TableName(value ="attribute_zfpz")
@Data
public class AttributeZfpz implements Serializable {
/**
*
*/
private String id;
/**
* id
*/
private String evidenceId;
/**
*
*/
@Schema(description = "付款方名称", type = "1")
private String payerName;
/**
*
*/
@Schema(description = "收款方名称", type = "1")
private String payeeName;
/**
*
*/
@Schema(description = "支付时间", type = "3")
private String paymentTime;
/**
*
*/
@Schema(description = "金额", type = "2")
private String amount;
/**
*
*/
@Schema(description = "说明", type = "1")
private String describeInfo;
/**
*
*/
private LocalDateTime createTime;
/**
*
*/
private String createUserId;
/**
*
*/
private LocalDateTime updateTime;
/**
*
*/
private String updateUserId;
@TableField(exist = false)
private static final long serialVersionUID = 1L;
}

@ -0,0 +1,18 @@
package com.supervision.police.mapper;
import com.supervision.police.domain.AttributeMmht;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* @author Administrator
* @description attribute_mmht()Mapper
* @createDate 2024-11-19 16:44:46
* @Entity com.supervision.police.domain.AttributeMmht
*/
public interface AttributeMmhtMapper extends BaseMapper<AttributeMmht> {
}

@ -0,0 +1,18 @@
package com.supervision.police.mapper;
import com.supervision.police.domain.AttributeYhls;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* @author Administrator
* @description attribute_yhls()Mapper
* @createDate 2024-11-20 14:40:46
* @Entity com.supervision.police.domain.AttributeYhls
*/
public interface AttributeYhlsMapper extends BaseMapper<AttributeYhls> {
}

@ -0,0 +1,18 @@
package com.supervision.police.mapper;
import com.supervision.police.domain.AttributeZfpz;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* @author Administrator
* @description attribute_zfpz()Mapper
* @createDate 2024-11-20 14:40:46
* @Entity com.supervision.police.domain.AttributeZfpz
*/
public interface AttributeZfpzMapper extends BaseMapper<AttributeZfpz> {
}

@ -0,0 +1,13 @@
package com.supervision.police.service;
import com.supervision.police.domain.AttributeMmht;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* @author Administrator
* @description attribute_mmht()Service
* @createDate 2024-11-19 16:44:46
*/
public interface AttributeMmhtService extends IService<AttributeMmht> {
}

@ -0,0 +1,13 @@
package com.supervision.police.service;
import com.supervision.police.domain.AttributeYhls;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* @author Administrator
* @description attribute_yhls()Service
* @createDate 2024-11-20 14:40:46
*/
public interface AttributeYhlsService extends IService<AttributeYhls> {
}

@ -0,0 +1,13 @@
package com.supervision.police.service;
import com.supervision.police.domain.AttributeZfpz;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* @author Administrator
* @description attribute_zfpz()Service
* @createDate 2024-11-20 14:40:46
*/
public interface AttributeZfpzService extends IService<AttributeZfpz> {
}

@ -0,0 +1,24 @@
package com.supervision.police.service;
import com.supervision.police.dto.NotePromptExtractAttributesDto;
import java.util.List;
import java.util.Map;
/**
*
*/
public interface CaseEvidencePropertyService {
List<NotePromptExtractAttributesDto> findExtractAttributes(String categoryId);
void saveEvidenceProperty(String evidenceId,String categoryId, List<NotePromptExtractAttributesDto> attributes);
void updateEvidenceProperty(String evidenceId,String categoryId, List<NotePromptExtractAttributesDto> attributes);
void deleteEvidenceProperty(String evidenceId,String categoryId);
Map<String,List<NotePromptExtractAttributesDto>> listEvidenceProperty(String categoryId,List<String> evidenceIdList);
}

@ -0,0 +1,22 @@
package com.supervision.police.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.supervision.police.domain.AttributeMmht;
import com.supervision.police.service.AttributeMmhtService;
import com.supervision.police.mapper.AttributeMmhtMapper;
import org.springframework.stereotype.Service;
/**
* @author Administrator
* @description attribute_mmht()Service
* @createDate 2024-11-19 16:44:46
*/
@Service
public class AttributeMmhtServiceImpl extends ServiceImpl<AttributeMmhtMapper, AttributeMmht>
implements AttributeMmhtService{
}

@ -0,0 +1,22 @@
package com.supervision.police.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.supervision.police.domain.AttributeYhls;
import com.supervision.police.service.AttributeYhlsService;
import com.supervision.police.mapper.AttributeYhlsMapper;
import org.springframework.stereotype.Service;
/**
* @author Administrator
* @description attribute_yhls()Service
* @createDate 2024-11-20 14:40:46
*/
@Service
public class AttributeYhlsServiceImpl extends ServiceImpl<AttributeYhlsMapper, AttributeYhls>
implements AttributeYhlsService{
}

@ -0,0 +1,22 @@
package com.supervision.police.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.supervision.police.domain.AttributeZfpz;
import com.supervision.police.service.AttributeZfpzService;
import com.supervision.police.mapper.AttributeZfpzMapper;
import org.springframework.stereotype.Service;
/**
* @author Administrator
* @description attribute_zfpz()Service
* @createDate 2024-11-20 14:40:46
*/
@Service
public class AttributeZfpzServiceImpl extends ServiceImpl<AttributeZfpzMapper, AttributeZfpz>
implements AttributeZfpzService{
}

@ -0,0 +1,269 @@
package com.supervision.police.service.impl;
import cn.hutool.core.bean.BeanDesc;
import cn.hutool.core.bean.PropDesc;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.lang.Assert;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.IService;
import com.supervision.police.dto.NotePromptExtractAttributesDto;
import com.supervision.police.service.CaseEvidencePropertyService;
import com.supervision.police.service.ComDictionaryService;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.annotation.PostConstruct;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Service;
import java.lang.reflect.Field;
import java.util.*;
import java.util.stream.Collectors;
@Slf4j
@Service
@SuppressWarnings("all")
@RequiredArgsConstructor
public class CaseEvidencePropertyServiceImpl implements CaseEvidencePropertyService {
private final ApplicationContext applicationContext;
private final ComDictionaryService comDictionaryService;
private final Map<String, IService<?>> evidencePropertyServiceMap = new HashMap<>();
private final Map<String, BeanDesc> beanDescMap = new HashMap<>();
@Override
public List<NotePromptExtractAttributesDto> findExtractAttributes(String categoryId) {
if (StrUtil.isEmpty(categoryId)){
return new ArrayList<>();
}
String beanName = getEntityNameIfExist(categoryId);
if (StrUtil.isEmpty(beanName)){
return new ArrayList<>();
}
BeanDesc beanDesc = beanDescMap.get(beanName);
Assert.notNull(beanDesc, "字典表evidence_property_bean中不存在"+beanName+"对应的属性");
return beanDesc.getProps().stream()
.filter(prop -> null != prop.getField().getAnnotation(Schema.class)).map(prop -> {
NotePromptExtractAttributesDto attributesDto = new NotePromptExtractAttributesDto();
Field field = prop.getField();
attributesDto.setAttrName(getFieldDesc(field));
attributesDto.setAttrValueType(getFieldType(field));
return attributesDto;
}).toList();
}
@Override
public void saveEvidenceProperty(String evidenceId, String categoryId,List<NotePromptExtractAttributesDto> attributes) {
if (CollUtil.isEmpty(attributes)){
log.warn("保存证据属性时属性为空不保存任何数据证据id:{}", evidenceId);
return;
}
if (StrUtil.isEmpty(evidenceId) || StrUtil.isEmpty(categoryId)){
return;
}
String entityName = getEntityName(categoryId);
IService iService = evidencePropertyServiceMap.get(entityName);
Assert.notNull(iService, "不存在"+entityName+"对应的bean");
JSONObject entityJson = mapToEntityJson(entityName,attributes);
entityJson.set("evidenceId", evidenceId);
if (entityJson.isEmpty()){
log.warn("保存证据属性时属性为空不保存任何数据证据id:{}", evidenceId);
return;
}
iService.save(JSONUtil.toBean(entityJson, iService.getEntityClass()));
}
@Override
public void updateEvidenceProperty(String evidenceId, String categoryId, List<NotePromptExtractAttributesDto> attributes) {
if (StrUtil.isEmpty(categoryId) || StrUtil.isEmpty(evidenceId) || CollUtil.isEmpty(attributes)){
return;
}
String entityName = getEntityNameIfExist(categoryId);
if (StrUtil.isEmpty(entityName)){
return;
}
IService iService = evidencePropertyServiceMap.get(entityName);
Assert.notNull(iService, "不存在"+entityName+"对应的bean");
JSONObject entityJson = mapToEntityJson(entityName, attributes);
if (entityJson.isEmpty()){
return;
}
iService.update(entityJson, new QueryWrapper<>().eq("evidence_id", evidenceId));
}
@Override
public void deleteEvidenceProperty(String evidenceId, String categoryId) {
if (StrUtil.isEmpty(evidenceId) || StrUtil.isEmpty(categoryId)){
return;
}
String entityName = getEntityNameIfExist(categoryId);
if (StrUtil.isEmpty(entityName)){
return;
}
IService iService = evidencePropertyServiceMap.get(entityName);
iService.remove(new QueryWrapper<>().eq("evidence_id", evidenceId));
}
@Override
public Map<String,List<NotePromptExtractAttributesDto>> listEvidenceProperty(String categoryId,List<String> evidenceIdList) {
Map<String,List<NotePromptExtractAttributesDto>> result = evidenceIdList.stream()
.distinct().collect(Collectors.toMap(String::valueOf, v -> new ArrayList<>()));
if (CollUtil.isEmpty(evidenceIdList) || StrUtil.isEmpty(categoryId)){
return result;
}
String entityName = getEntityNameIfExist(categoryId);
if (StrUtil.isEmpty(entityName)){
return result;
}
IService<?> iService = evidencePropertyServiceMap.get(entityName);
Assert.notNull(iService, "不存在"+entityName+"对应的bean");
// 从数据库查询证据数据
QueryWrapper queryWrapper = new QueryWrapper<>();
queryWrapper.in("evidence_id", evidenceIdList);
List<Map<String,Object>> properties = iService.getBaseMapper().selectMaps(queryWrapper);
if (CollUtil.isEmpty(properties)){
return result;
}
// 对查询出来的格式进行转换
for (Map<String, Object> property : properties) {
String evidenceId = (String) property.get("evidence_id");
if (StrUtil.isEmpty(evidenceId)){
continue;
}
result.put(evidenceId, mapToAttributes(entityName, property));
}
return result;
}
@PostConstruct
public void init(){
// 缓存证据属性bean
Map<String, String> evidencePropertyBean = comDictionaryService.getDictionaryMap("evidence_property_bean");
for (Map.Entry<String, String> entry : evidencePropertyBean.entrySet()) {
IService<?> bean = applicationContext.getBean(StrUtil.lowerFirst(entry.getValue())+"ServiceImpl", IService.class);
evidencePropertyServiceMap.put(entry.getValue(), bean);
Class<?> entityClass = bean.getEntityClass();
beanDescMap.put(entityClass.getSimpleName(),new BeanDesc(entityClass));
}
}
private JSONObject mapToEntityJson(String entityName, List<NotePromptExtractAttributesDto> attributes) {
BeanDesc beanDesc = beanDescMap.get(entityName);
Collection<PropDesc> props = beanDesc.getProps();
JSONObject json = new JSONObject();
for (NotePromptExtractAttributesDto attribute : attributes) {
String attrName = attribute.getAttrName();
String fieldName = getFieldName(props, attrName);
if (StrUtil.isNotEmpty(fieldName)){
json.set(fieldName, attribute.getAttrValue());
}
}
return json;
}
private String getFieldName(Collection<PropDesc> props,String fieldDesc) {
for (PropDesc prop : props) {
if (StrUtil.equals(getFieldDesc(prop.getField()), fieldDesc)){
return prop.getFieldName();
}
}
return null;
}
private String getEntityName(String categoryId){
Map<String, String> evidencePropertyBean = comDictionaryService.getDictionaryMap("evidence_property_bean");
Assert.notEmpty(evidencePropertyBean, "字典表evidence_property_bean为空");
String beanName = evidencePropertyBean.get(categoryId);
Assert.notEmpty(beanName, "字典表evidence_property_bean中不存在"+categoryId+"对应的bean");
return beanName;
}
private String getEntityNameIfExist(String categoryId){
Map<String, String> evidencePropertyBean = comDictionaryService.getDictionaryMap("evidence_property_bean");
if (CollUtil.isEmpty(evidencePropertyBean)){
return null;
}
return evidencePropertyBean.get(categoryId);
}
private List<NotePromptExtractAttributesDto> mapToAttributes(String entityName, Map<String,Object> property){
if (StrUtil.isEmpty(entityName)){
return new ArrayList<>();
}
BeanDesc beanDesc = beanDescMap.get(entityName);
return property.entrySet().stream().map(entry -> {
Field field = beanDesc.getField(StrUtil.toCamelCase(entry.getKey()));
NotePromptExtractAttributesDto attributesDto = new NotePromptExtractAttributesDto();
attributesDto.setAttrName(getFieldDesc(field));
attributesDto.setAttrValue(StrUtil.toString(entry.getValue()));
attributesDto.setAttrValueType(getFieldType(field));
return attributesDto;
}).filter(a->StrUtil.isNotEmpty(a.getAttrName())).toList();
}
private String getFieldDesc(Field field){
if (StrUtil.equalsAny(field.getName(),
"createTime","updateTime","createUserId",
"updateUserId","serialVersionUID")){
return null;
}
Schema schema = field.getAnnotation(Schema.class);
if (null == schema){
return null;
}
return schema.description();
}
/**
* 1:
* 2
* 3
*/
private String getFieldType(Field field) {
Schema schema = field.getAnnotation(Schema.class);
if (null != schema){
return schema.type();
}
return null;
}
}

@ -27,7 +27,6 @@ import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.aop.framework.AopContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
@ -57,9 +56,6 @@ public class CaseEvidenceServiceImpl extends ServiceImpl<CaseEvidenceMapper, Cas
private final ModelCaseService modelCaseService;
@Lazy
@Autowired
private OCREvidenceService ocrEvidenceService;
@Autowired
private LLMExtractService llmExtractService;
@Autowired
@ -71,6 +67,8 @@ public class CaseEvidenceServiceImpl extends ServiceImpl<CaseEvidenceMapper, Cas
private final XxlJobService xxlJobService;
private final CaseEvidencePropertyService caseEvidencePropertyService;
@Override
@Transactional(transactionManager = "dataSourceTransactionManager", rollbackFor = Exception.class)
public String saveEvidence(CaseEvidenceDTO caseEvidenceDTO) {
@ -81,6 +79,14 @@ public class CaseEvidenceServiceImpl extends ServiceImpl<CaseEvidenceMapper, Cas
CaseEvidence caseEvidence = caseEvidenceDTO.toCaseEvidence();
super.save(caseEvidence);
if (CollUtil.isNotEmpty(caseEvidence.getProperty())){
// 同时保存证据属性值
EvidenceDirectoryDTO rootDirectory = new EvidenceDirectoryDTO(evidenceDirectoryService.listDirectoryTree(caseEvidence.getCaseId()));
EvidenceDirectoryDTO directory = rootDirectory.findDirectory(caseEvidence.getDirectoryId());
caseEvidencePropertyService.saveEvidenceProperty(caseEvidence.getId(),directory.getCategoryId(),caseEvidence.getProperty());
}
//保存文件关联信息
caseEvidenceDTO.getFileIdList().forEach(fileId -> {
EvidenceFile evidenceFile = new EvidenceFile();
@ -112,6 +118,17 @@ public class CaseEvidenceServiceImpl extends ServiceImpl<CaseEvidenceMapper, Cas
CaseEvidence caseEvidence = caseEvidenceDTO.toCaseEvidence();
super.updateById(caseEvidence);
// 更新证据属性
EvidenceDirectoryDTO rootDirectory = new EvidenceDirectoryDTO(evidenceDirectoryService.listDirectoryTree(caseEvidence.getCaseId()));
EvidenceDirectoryDTO directory = rootDirectory.findDirectory(caseEvidence.getDirectoryId());
if (null != directory && StrUtil.isNotEmpty(directory.getCategoryId())){
if (CollUtil.isNotEmpty(caseEvidence.getProperty())){
caseEvidencePropertyService.updateEvidenceProperty(caseEvidence.getId(),directory.getCategoryId(),caseEvidence.getProperty());
}else {
caseEvidencePropertyService.deleteEvidenceProperty(caseEvidence.getId(),directory.getCategoryId());
}
}
// 更新文件关联信息
evidenceFileService.lambdaUpdate().eq(EvidenceFile::getEvidenceId, caseEvidence.getId()).remove();
caseEvidenceDTO.getFileIdList().forEach(fileId -> {
@ -148,6 +165,7 @@ public class CaseEvidenceServiceImpl extends ServiceImpl<CaseEvidenceMapper, Cas
if (remove) {
evidenceFileService.lambdaUpdate().eq(EvidenceFile::getEvidenceId, evidenceId).remove();
evidenceDirectoryService.removeDirectoryIf(directory.getId(), () -> directory.getLevel() == 3);
caseEvidencePropertyService.deleteEvidenceProperty(evidenceId, directory.getCategoryId());
caseStatusManageService.whenUpdateEvidence(caseEvidence.getCaseId());
}
} else {
@ -322,6 +340,9 @@ public class CaseEvidenceServiceImpl extends ServiceImpl<CaseEvidenceMapper, Cas
EvidenceDirectory directory = evidenceDirectoryService.getById(caseEvidence.getDirectoryId());
NotePrompt notePrompt = notePromptService.lambdaQuery().eq(NotePrompt::getEvidenceCategoryId, directory.getCategoryId()).one();
if (notePrompt != null) {
// 重新设置extractAttributes属性信息
List<NotePromptExtractAttributesDto> attributes = caseEvidencePropertyService.findExtractAttributes(directory.getCategoryId());
notePrompt.setExtractAttributes(attributes);
log.info("属性提取开始。");
long attrStart = System.currentTimeMillis();
llmExtractDto.setPrompt(notePrompt.getPrompt());
@ -335,6 +356,9 @@ public class CaseEvidenceServiceImpl extends ServiceImpl<CaseEvidenceMapper, Cas
}
}).toList();
caseEvidence.setProperty(extractAttributes);
// 同时设置案件属性值
caseEvidencePropertyService.deleteEvidenceProperty(evidenceId, directory.getCategoryId());
caseEvidencePropertyService.saveEvidenceProperty(evidenceId, directory.getCategoryId(), extractAttributes);
}
log.info("属性提取完成。更新证据处理状态为【属性提取完成】。属性:【{}】。耗时:【{}】", caseEvidence.getProperty(), System.currentTimeMillis() - attrStart);
caseEvidence.setProcessStatus(EvidenceConstants.PROCESS_STATUS_ATTR_EXTRACT_OK);
@ -784,6 +808,9 @@ public class CaseEvidenceServiceImpl extends ServiceImpl<CaseEvidenceMapper, Cas
return;
}
List<CaseEvidenceDetailDTO> caseEvidenceDetailDTOS = queryEvidenceList(caseId, null);
List<EvidenceDirectoryDTO> directoryDTOS = evidenceDirectoryService.listDirectoryTree(caseId);
EvidenceDirectoryDTO rootDirectory = new EvidenceDirectoryDTO(directoryDTOS);
Map<String, List<EvidenceVerifyDTO>> evidenceMap = evidenceVerifyDTOS.stream().collect(Collectors.groupingBy(EvidenceVerifyDTO::getEvidenceId));
for (Map.Entry<String, List<EvidenceVerifyDTO>> entry : evidenceMap.entrySet()) {
@ -799,6 +826,16 @@ public class CaseEvidenceServiceImpl extends ServiceImpl<CaseEvidenceMapper, Cas
.set(CaseEvidence::getEvidenceName, CollUtil.getFirst(value).getEvidenceName())
.update();
// 同时更新证据属性值
String categoryId = rootDirectory.findDirectory(CollUtil.getFirst(value).getDirectoryId()).getCategoryId();
Map<String, List<NotePromptExtractAttributesDto>> map = caseEvidencePropertyService.listEvidenceProperty(categoryId, Collections.singletonList(evidenceId));
if (CollUtil.isEmpty(map.get(categoryId))){
caseEvidencePropertyService.saveEvidenceProperty(evidenceId, categoryId,CollUtil.getFirst(value).getProperties());
}else {
caseEvidencePropertyService.updateEvidenceProperty(evidenceId, categoryId,CollUtil.getFirst(value).getProperties());
}
// 修改ocr内容
for (EvidenceVerifyDTO verifyDTO : value) {
if (StrUtil.isNotEmpty(verifyDTO.getOcrText())) {
@ -847,6 +884,7 @@ public class CaseEvidenceServiceImpl extends ServiceImpl<CaseEvidenceMapper, Cas
evidenceVerifyDTO.setFileId(fileDTO.getFileId());
evidenceVerifyDTO.setOcrText(fileDTO.getOcrText());
CaseEvidenceDTO evidenceInfo = fileDTO.getEvidenceInfo();
evidenceVerifyDTO.setDirectoryId(fileDTO.getDirectoryId());
if (null != evidenceInfo) {
evidenceVerifyDTO.setProperties(evidenceInfo.getProperty());
evidenceVerifyDTO.setTitle(evidenceInfo.getTitle());
@ -867,11 +905,11 @@ public class CaseEvidenceServiceImpl extends ServiceImpl<CaseEvidenceMapper, Cas
List<CaseEvidence> caseEvidenceList = this.lambdaQuery().eq(CaseEvidence::getCaseId, caseId).list();
EvidenceDirectoryDTO rootDirectory = new EvidenceDirectoryDTO(evidenceDirectoryDTOS);
// 强行翻译
rebuildEvidenceProperties(new EvidenceDirectoryDTO(evidenceDirectoryDTOS), caseEvidenceList);
rebuildEvidenceProperties(rootDirectory, caseEvidenceList);
EvidenceDirectoryDTO rootDirectory = new EvidenceDirectoryDTO(evidenceDirectoryDTOS);
List<CategoryPromptDTO> categoryPromptDTOS = evidenceDirectoryService.listCategoryPrompt(caseId);
Map<String, CaseEvidenceDTO> caseEvidenceMap = caseEvidenceList.stream().map(CaseEvidenceDTO::new).peek(e->e.setDirectoryNamePathValue(rootDirectory)).collect(Collectors.toMap(CaseEvidenceDTO::getId, Function.identity()));
Map<String, CategoryPromptDTO> categoryPromptMap = categoryPromptDTOS.stream().collect(Collectors.toMap(CategoryPromptDTO::getDirectoryId, k -> k, (v1, v2) -> v1));
@ -897,21 +935,22 @@ public class CaseEvidenceServiceImpl extends ServiceImpl<CaseEvidenceMapper, Cas
*/
private void rebuildEvidenceProperties(EvidenceDirectoryDTO rootDirectory, List<CaseEvidence> caseEvidenceList) {
List<String> categoryIds = caseEvidenceList.stream().map(e -> {
EvidenceDirectoryDTO directory = rootDirectory.findDirectory(e.getDirectoryId());
if (null == directory) {
return null;
}
return directory.getCategoryId();
}).filter(StrUtil::isNotEmpty).distinct().toList();
Map<String, String> directoryIdMapCategoryId = caseEvidenceList.stream()
.filter(e -> StrUtil.isNotEmpty(e.getDirectoryId()) && null != rootDirectory.findDirectory(e.getDirectoryId()))
.map(CaseEvidence::getDirectoryId).distinct().collect(
Collectors.toMap(directoryId -> directoryId,di-> rootDirectory.findDirectory(di).getCategoryId()));
List<NotePrompt> notePromptList = CollUtil.isEmpty(directoryIdMapCategoryId.values()) ? new ArrayList<>() : notePromptService.lambdaQuery().in(NotePrompt::getEvidenceCategoryId, categoryIds).list();
Map<String, List<NotePromptExtractAttributesDto>> categoryIdMapExtractAttributes = notePromptList.stream().collect(Collectors.toMap(NotePrompt::getEvidenceCategoryId, NotePrompt::getExtractAttributes, (v1, v2) -> v1));
Map<String, List<NotePromptExtractAttributesDto>> categoryIdMapExtractAttributes = new HashMap<>();
for (CaseEvidence caseEvidence : caseEvidenceList) {
EvidenceDirectoryDTO directory = rootDirectory.findDirectory(caseEvidence.getDirectoryId());
if (null == directory || StrUtil.isEmpty(directory.getCategoryId())){
continue;
}
String categoryId = directory.getCategoryId();
if (!categoryIdMapExtractAttributes.containsKey(categoryId)){
categoryIdMapExtractAttributes.put(categoryId, caseEvidencePropertyService.findExtractAttributes(categoryId));
}
}
for (CaseEvidence caseEvidence : caseEvidenceList) {

@ -449,6 +449,7 @@ public class ModelIndexServiceImpl extends ServiceImpl<ModelIndexMapper, ModelIn
}
graphDebugResVO.setRecordList(mapRecords(records));
// 尝试转换为图形数据
Pair<List<WebRelDTO>, List<Map<String, String>>> pair = this.neo4jService.mergeRecord(generateNodes(records), generateRelations(records));
graphDebugResVO.setGraphRelList(pair.getKey());
graphDebugResVO.setGraphNodeList(pair.getValue());
@ -462,7 +463,6 @@ public class ModelIndexServiceImpl extends ServiceImpl<ModelIndexMapper, ModelIn
}).collect(Collectors.toList());
graphDebugResVO.setGraphReCountList(collect);
// 尝试转换为图形数据
return graphDebugResVO;
}

@ -0,0 +1,39 @@
<?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">
<mapper namespace="com.supervision.police.mapper.AttributeMmhtMapper">
<resultMap id="BaseResultMap" type="com.supervision.police.domain.AttributeMmht">
<result property="id" column="id" jdbcType="VARCHAR"/>
<result property="evidenceId" column="evidence_id" jdbcType="VARCHAR"/>
<result property="partA" column="part_a" jdbcType="VARCHAR"/>
<result property="partB" column="part_b" jdbcType="VARCHAR"/>
<result property="partC" column="part_c" jdbcType="VARCHAR"/>
<result property="qualifications" column="qualifications" jdbcType="VARCHAR"/>
<result property="subjectMatter" column="subject_matter" jdbcType="VARCHAR"/>
<result property="number" column="number" jdbcType="VARCHAR"/>
<result property="amountMoney" column="amount_money" jdbcType="VARCHAR"/>
<result property="paymentMethod" column="payment_method" jdbcType="VARCHAR"/>
<result property="paymentTime" column="payment_time" jdbcType="VARCHAR"/>
<result property="performancePeriod" column="performance_period" jdbcType="VARCHAR"/>
<result property="placePerformance" column="place_performance" jdbcType="VARCHAR"/>
<result property="liabilityBreach" column="liability_breach" jdbcType="VARCHAR"/>
<result property="projectDetails" column="project_details" jdbcType="VARCHAR"/>
<result property="signingDate" column="signing_date" jdbcType="VARCHAR"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
<result property="createUserId" column="create_user_id" jdbcType="VARCHAR"/>
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
<result property="updateUserId" column="update_user_id" jdbcType="VARCHAR"/>
</resultMap>
<sql id="Base_Column_List">
id,evidence_id,part_a,
part_b,part_c,qualifications,
subject_matter,number,amount_money,
payment_method,payment_time,performance_period,
place_performance,liability_breach,project_details,
signing_date,create_time,create_user_id,
update_time,update_user_id
</sql>
</mapper>

@ -0,0 +1,28 @@
<?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">
<mapper namespace="com.supervision.police.mapper.AttributeYhlsMapper">
<resultMap id="BaseResultMap" type="com.supervision.police.domain.AttributeYhls">
<result property="id" column="id" jdbcType="VARCHAR"/>
<result property="evidenceId" column="evidence_id" jdbcType="VARCHAR"/>
<result property="accountInformation" column="account_information" jdbcType="VARCHAR"/>
<result property="otherAccountInformation" column="other_account_information" jdbcType="VARCHAR"/>
<result property="amount" column="amount" jdbcType="VARCHAR"/>
<result property="tradingTime" column="trading_time" jdbcType="VARCHAR"/>
<result property="revenueExpenditureIdentification" column="revenue_expenditure_identification" jdbcType="VARCHAR"/>
<result property="abstractInfo" column="abstract_info" jdbcType="VARCHAR"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
<result property="createUserId" column="create_user_id" jdbcType="VARCHAR"/>
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
<result property="updateUserId" column="update_user_id" jdbcType="VARCHAR"/>
</resultMap>
<sql id="Base_Column_List">
id,evidence_id,account_information,
other_account_information,amount,trading_time,
revenue_expenditure_identification,abstract_info,create_time,
create_user_id,update_time,update_user_id
</sql>
</mapper>

@ -0,0 +1,27 @@
<?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">
<mapper namespace="com.supervision.police.mapper.AttributeZfpzMapper">
<resultMap id="BaseResultMap" type="com.supervision.police.domain.AttributeZfpz">
<result property="id" column="id" jdbcType="VARCHAR"/>
<result property="evidenceId" column="evidence_id" jdbcType="VARCHAR"/>
<result property="payerName" column="payer_name" jdbcType="VARCHAR"/>
<result property="payeeName" column="payee_name" jdbcType="VARCHAR"/>
<result property="paymentTime" column="payment_time" jdbcType="VARCHAR"/>
<result property="amount" column="amount" jdbcType="VARCHAR"/>
<result property="describeInfo" column="describe_info" jdbcType="VARCHAR"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
<result property="createUserId" column="create_user_id" jdbcType="VARCHAR"/>
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
<result property="updateUserId" column="update_user_id" jdbcType="VARCHAR"/>
</resultMap>
<sql id="Base_Column_List">
id,evidence_id,payer_name,
payee_name,payment_time,amount,
describe_info,create_time,create_user_id,
update_time,update_user_id
</sql>
</mapper>

@ -16,6 +16,7 @@ import com.supervision.police.domain.ModelRecordType;
import com.supervision.police.domain.NotePrompt;
import com.supervision.police.domain.NoteRecordSplit;
import com.supervision.police.dto.EvidenceDirectoryDTO;
import com.supervision.police.dto.NotePromptExtractAttributesDto;
import com.supervision.police.dto.RetrieveReqDTO;
import com.supervision.police.dto.RetrieveResDTO;
import com.supervision.police.service.*;
@ -311,7 +312,6 @@ public class FuHsiApplicationTests {
public void initCaseDirectory() {
caseEvidenceService.initCaseEvidenceDirectory("1846389691251220482", "1");
System.out.println("222");
}
@Data
@ -331,4 +331,86 @@ public class FuHsiApplicationTests {
caseEvidenceService.refreshCaseEvidence();
System.out.println("执行完成");
}
@Autowired
private CaseEvidencePropertyService caseEvidencePropertyService;
@Test
public void findExtractAttributesTest(){
List<NotePromptExtractAttributesDto> extractAttributes = caseEvidencePropertyService.findExtractAttributes("7");
System.out.println(JSONUtil.toJsonStr(extractAttributes));
}
@Test
public void saveEvidencePropertyTest() {
List<NotePromptExtractAttributesDto> attributesDtoList = new ArrayList<>();
NotePromptExtractAttributesDto attributesDto = new NotePromptExtractAttributesDto();
attributesDto.setAttrName("甲方");
attributesDto.setAttrValue("甲方-value");
attributesDto.setAttrValueType("1");
attributesDtoList.add(attributesDto);
NotePromptExtractAttributesDto attributesDto2 = new NotePromptExtractAttributesDto();
attributesDto2.setAttrName("资质要求");
attributesDto2.setAttrValue("资质要求-value");
attributesDto2.setAttrValueType("1");
attributesDtoList.add(attributesDto2);
NotePromptExtractAttributesDto attributesDto3 = new NotePromptExtractAttributesDto();
attributesDto3.setAttrName("签订日期");
attributesDto3.setAttrValue("2024-10-15");
attributesDto3.setAttrValueType("3");
attributesDtoList.add(attributesDto3);
caseEvidencePropertyService.saveEvidenceProperty("1111","7", attributesDtoList);
}
@Test
public void updateEvidencePropertyTest() {
List<NotePromptExtractAttributesDto> attributesDtoList = new ArrayList<>();
NotePromptExtractAttributesDto attributesDto = new NotePromptExtractAttributesDto();
attributesDto.setAttrName("甲方");
attributesDto.setAttrValue("甲方-value-update");
attributesDto.setAttrValueType("1");
attributesDtoList.add(attributesDto);
NotePromptExtractAttributesDto attributesDto2 = new NotePromptExtractAttributesDto();
attributesDto2.setAttrName("资质要求");
attributesDto2.setAttrValue("资质要求-value-update");
attributesDto2.setAttrValueType("1");
attributesDtoList.add(attributesDto2);
NotePromptExtractAttributesDto attributesDto3 = new NotePromptExtractAttributesDto();
attributesDto3.setAttrName("签订日期");
attributesDto3.setAttrValue("2024-10-15");
attributesDto3.setAttrValueType("3");
attributesDtoList.add(attributesDto3);
caseEvidencePropertyService.updateEvidenceProperty("1111","7", attributesDtoList);
}
@Test
public void listEvidencePropertyTest() {
Map<String, List<NotePromptExtractAttributesDto>> evidenceProperty = caseEvidencePropertyService.listEvidenceProperty("7", List.of("1111"));
System.out.println(JSONUtil.toJsonStr(evidenceProperty));
}
@Test
public void deleteEvidencePropertyTest() {
caseEvidencePropertyService.deleteEvidenceProperty("1111", "7");
}
}

Loading…
Cancel
Save