提示词变更同时更新“笔录”表“提示词变更”字段状态

topo_dev
DESKTOP-DDTUS3E\yaxin 8 months ago
parent 3517d23a58
commit c9d6666c03

@ -1,18 +1,15 @@
package com.supervision.police.domain;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonSetter;
import com.fasterxml.jackson.annotation.Nulls;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
@ -28,17 +25,17 @@ public class NoteRecord implements Serializable {
@TableId
private String id;
/**
* id
*/
private String caseId;
/**
*
*/
private String recordName;
/**
* id
*/
@ -48,39 +45,39 @@ public class NoteRecord implements Serializable {
* id
*/
private String casePersonId;
/**
*
*/
private String name;
/**
*
*/
private String role;
/**
*
*/
private Integer confessionMaterial;
/**
*
*/
private String lawAsker;
/**
*
*/
// @JsonFormat(pattern="yyyy-MM-dd HH:mm",timezone = "GMT+8")
private String confessionStartTime;
/**
*
*/
// @JsonFormat(pattern="yyyy-MM-dd HH:mm",timezone = "GMT+8")
private String confessionEndTime;
/**
*
*/
@ -92,6 +89,11 @@ public class NoteRecord implements Serializable {
*/
private String dataStatus;
/**
*
*/
private Boolean isPromptUpdate;
@TableField(exist = false)
private List<NoteRecord> children = new ArrayList<>();
@ -104,7 +106,7 @@ public class NoteRecord implements Serializable {
*
*/
@TableField(fill = FieldFill.INSERT_UPDATE)
@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime createTime;
@ -118,7 +120,7 @@ public class NoteRecord implements Serializable {
*
*/
@TableField(fill = FieldFill.INSERT_UPDATE)
@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime updateTime;

@ -30,7 +30,6 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StopWatch;
import java.time.LocalDateTime;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
@ -63,6 +62,8 @@ public class ModelRecordTypeServiceImpl extends ServiceImpl<ModelRecordTypeMappe
private RecordSplitProcessService recordSplitProcessService;
@Autowired
private ModelRecordTypeService modelRecordTypeService;
@Autowired
private NoteRecordService noteRecordService;
@Override
@ -136,7 +137,7 @@ public class ModelRecordTypeServiceImpl extends ServiceImpl<ModelRecordTypeMappe
@Transactional(transactionManager = "dataSourceTransactionManager", rollbackFor = Exception.class)
public R<?> saveType(ModelRecordType type) {
String id = type.getId();
int i = 0;
int i;
if (StringUtils.isEmpty(id)) {
//新增
i = modelRecordTypeMapper.insert(type);
@ -157,7 +158,6 @@ public class ModelRecordTypeServiceImpl extends ServiceImpl<ModelRecordTypeMappe
if (CollUtil.isEmpty(typeList)) {
throw new RuntimeException("类型信息不能为空");
}
int i = 0;
boolean save;
if (StringUtils.isEmpty(prompt.getId())) {
// 新增的时候,校验是否已经存在相同的三元组关系,如果已经存在了相同的三元组关系,不允许添加
@ -222,7 +222,23 @@ public class ModelRecordTypeServiceImpl extends ServiceImpl<ModelRecordTypeMappe
}
}
if (save) {
// 获取所有的类型
List<ModelRecordType> modelRecordTypes = list();
// 根据提示词id获取类型和提示词的关系表
List<NotePromptTypeRel> relList = notePromptTypeRelService.list(new QueryWrapper<NotePromptTypeRel>().eq("prompt_id", prompt.getId()));
//根据typeId集合过滤出对应的modelRecordType的name
List<String> typeNames = modelRecordTypes.stream().filter(e -> relList.stream().map(NotePromptTypeRel::getTypeId).toList().contains(e.getId())).map(ModelRecordType::getRecordType).toList();
//根据typeNames模糊匹配查询note_record_split
List<NoteRecordSplit> noteRecordSplits = noteRecordSplitService.list().stream()
.filter(record -> record != null && record.getRecordType() != null && typeNames.stream().anyMatch(typeName -> Arrays.asList(record.getRecordType().split(",")).contains(typeName)))
.toList();
//过滤并去重涉及到的的note_record_id
Set<String> recordIds = noteRecordSplits.stream().map(NoteRecordSplit::getNoteRecordId).collect(Collectors.toSet());
//根据note_record_id更新note_record表的isPromptUpdate字段
log.info("开始更新笔录表提示词更新状态【is_prompt_update】涉及到的笔录有{}", recordIds);
boolean updated = noteRecordService.update(new UpdateWrapper<NoteRecord>().set("is_prompt_update", true).in("id", recordIds));
if (save && updated) {
return R.ok("保存成功");
} else {
return R.fail("保存失败");
@ -280,8 +296,8 @@ public class ModelRecordTypeServiceImpl extends ServiceImpl<ModelRecordTypeMappe
if (caseTaskRecord.getStatus() == 0 || caseTaskRecord.getStatus() == 3) {
// 重新提交
caseTaskRecordService.lambdaUpdate().set(CaseTaskRecord::getStatus, 1)
.set(CaseTaskRecord::getTaskCount,0)
.set(CaseTaskRecord::getFinishCount,0)
.set(CaseTaskRecord::getTaskCount, 0)
.set(CaseTaskRecord::getFinishCount, 0)
.eq(CaseTaskRecord::getId, caseTaskRecord.getId()).update();
List<ModelRecordType> allTypeList = modelRecordTypeService.lambdaQuery().list();
// 根据recordId查询所有的分割后的笔录
@ -408,12 +424,11 @@ public class ModelRecordTypeServiceImpl extends ServiceImpl<ModelRecordTypeMappe
@Override
public String addNeo4j(List<String> ids, String recordId) {
if (StrUtil.isBlank(recordId)){
if (StrUtil.isBlank(recordId)) {
throw new BusinessException("记录ID不能为空");
}
if (CollUtil.isNotEmpty(ids)) {
List<TripleInfo> tripleInfos = tripleInfoService.listByIds(ids);
int i = 0;
for (TripleInfo tripleInfo : tripleInfos) {
try {
//开始节点
@ -445,7 +460,6 @@ public class ModelRecordTypeServiceImpl extends ServiceImpl<ModelRecordTypeMappe
tripleInfo.setEndNodeGraphId(endNode.getId());
boolean updateResult = tripleInfoService.updateById(tripleInfo);
if (updateResult) {
i++;
}
} catch (Exception e) {
log.error(e.getMessage(), e);

@ -7,7 +7,6 @@ import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.supervision.chat.client.LangChainChatService;
import com.supervision.common.utils.IPages;
import com.supervision.common.utils.ListUtils;
import com.supervision.common.utils.StringUtils;
@ -32,7 +31,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.io.IOException;
import java.time.LocalDateTime;
import java.util.*;
import java.util.function.Function;
@ -388,7 +386,7 @@ public class NoteRecordSplitServiceImpl extends ServiceImpl<NoteRecordSplitMappe
@Override
@Transactional(transactionManager = "dataSourceTransactionManager", rollbackFor = Exception.class)
public String redoExtract(NoteRecordReqVO records) throws IOException {
public String redoExtract(NoteRecordReqVO records) {
// 删除旧数据
// 删除问答对数据
noteRecordSplitService.remove(new QueryWrapper<NoteRecordSplit>().eq("note_record_id", records.getId()));
@ -420,6 +418,8 @@ public class NoteRecordSplitServiceImpl extends ServiceImpl<NoteRecordSplitMappe
});
// 删除三元组数据
tripleInfoService.remove(new QueryWrapper<TripleInfo>().eq("record_id", records.getId()));
// 重置note_record表的isPromptUpdate字段为false
noteRecordService.lambdaUpdate().eq(NoteRecord::getId, records.getId()).set(NoteRecord::getIsPromptUpdate, false).update();
return uploadRecords(records);
}

Loading…
Cancel
Save