|
|
|
@ -4,15 +4,13 @@ import cn.hutool.core.collection.CollUtil;
|
|
|
|
|
import cn.hutool.core.lang.Assert;
|
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
|
import cn.hutool.json.JSONObject;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
|
import com.supervision.common.constant.TaskRecordConstants;
|
|
|
|
|
import com.supervision.constant.DataStatus;
|
|
|
|
|
import com.supervision.police.domain.ModelCase;
|
|
|
|
|
import com.supervision.police.domain.NotePrompt;
|
|
|
|
|
import com.supervision.police.domain.NoteRecord;
|
|
|
|
|
import com.supervision.police.domain.TaskRecord;
|
|
|
|
|
import com.supervision.police.domain.*;
|
|
|
|
|
import com.supervision.police.dto.TaskInfoDTO;
|
|
|
|
|
import com.supervision.police.dto.taskRecord.TaskRecordVo;
|
|
|
|
|
import com.supervision.police.mapper.TaskRecordMapper;
|
|
|
|
@ -25,12 +23,15 @@ import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
|
import static com.supervision.common.constant.NotePromptConstants.TYPE_GRAPH_REASONING;
|
|
|
|
|
import static com.supervision.common.constant.NotePromptConstants.TYPE_STRUCTURAL_REASONING;
|
|
|
|
|
import static com.supervision.common.constant.TaskRecordConstants.*;
|
|
|
|
|
import static com.supervision.common.constant.XxlJobConstants.TASK_NAME_PROMPT_EXTRACT_TASK;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @author dxy
|
|
|
|
@ -52,40 +53,61 @@ public class TaskRecordServiceImpl extends ServiceImpl<TaskRecordMapper, TaskRec
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void executePromptExtractTask(TaskRecordVo taskRecordVo) {
|
|
|
|
|
//保存任务记录
|
|
|
|
|
TaskRecord taskRecord = new TaskRecord();
|
|
|
|
|
BeanUtils.copyProperties(taskRecordVo, taskRecord);
|
|
|
|
|
super.save(taskRecord);
|
|
|
|
|
NotePrompt prompt = notePromptService.getById(taskRecordVo.getPromptId());
|
|
|
|
|
switch (taskRecord.getType()) {
|
|
|
|
|
case TaskRecordConstants.TASK_TYPE_ALL_CASE:
|
|
|
|
|
if (TYPE_GRAPH_REASONING.equals(prompt.getType())) {
|
|
|
|
|
//笔录
|
|
|
|
|
List<ModelCase> modelCases = modelCaseService.lambdaQuery().eq(ModelCase::getDataStatus, DataStatus.AVAILABLE.getCode()).list();
|
|
|
|
|
for (ModelCase modelCase : modelCases) {
|
|
|
|
|
List<NoteRecord> noteRecords = noteRecordService.lambdaQuery().eq(NoteRecord::getCaseId, modelCase.getId()).list();
|
|
|
|
|
for (NoteRecord noteRecord : noteRecords) {
|
|
|
|
|
Map<String, String> params = new HashMap<>();
|
|
|
|
|
params.put("taskId", taskRecord.getId());
|
|
|
|
|
params.put("caseId", modelCase.getId());
|
|
|
|
|
params.put("executeId", noteRecord.getId());
|
|
|
|
|
params.put("promptId", taskRecordVo.getPromptId());
|
|
|
|
|
//map转String作为参数
|
|
|
|
|
xxlJobService.executeTaskByJobHandler("extractRecordByTask", new JSONObject(params).toString());
|
|
|
|
|
}
|
|
|
|
|
List<ModelCase> modelCases;
|
|
|
|
|
LambdaQueryWrapper<ModelCase> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
|
|
queryWrapper.eq(ModelCase::getDataStatus, DataStatus.AVAILABLE.getCode());
|
|
|
|
|
//根据任务类型查找案件
|
|
|
|
|
if (TASK_TYPE_SPECIFIED_CASE.equals(taskRecord.getType())) {
|
|
|
|
|
queryWrapper.in(ModelCase::getId, List.of(taskRecordVo.getCaseId().split(",")));
|
|
|
|
|
} else if (TASK_TYPE_SPECIFIED_RECORD.equals(taskRecord.getType()) || TASK_TYPE_SPECIFIED_EVIDENCE.equals(taskRecord.getType())) {
|
|
|
|
|
queryWrapper.eq(ModelCase::getId, taskRecord.getCaseId());
|
|
|
|
|
}
|
|
|
|
|
modelCases = modelCaseService.list(queryWrapper);
|
|
|
|
|
if (!CollUtil.isEmpty(modelCases)) {
|
|
|
|
|
for (ModelCase modelCase : modelCases) {
|
|
|
|
|
String caseId = modelCase.getId();
|
|
|
|
|
//查出当前案件相关笔录或证据
|
|
|
|
|
List<String> ids = new ArrayList<>();
|
|
|
|
|
//如果类型为指定笔录或证据,直接取传入的id
|
|
|
|
|
if (TASK_TYPE_SPECIFIED_RECORD.equals(taskRecord.getType())) {
|
|
|
|
|
ids = List.of(taskRecordVo.getRecordId().split(","));
|
|
|
|
|
} else if (TASK_TYPE_SPECIFIED_EVIDENCE.equals(taskRecord.getType())) {
|
|
|
|
|
ids = List.of(taskRecordVo.getEvidenceId().split(","));
|
|
|
|
|
} else {
|
|
|
|
|
//如果是案件维度,根据案件ID查找笔录或证据
|
|
|
|
|
if (TYPE_GRAPH_REASONING.equals(prompt.getType())) {
|
|
|
|
|
ids = noteRecordService.lambdaQuery().eq(NoteRecord::getCaseId, caseId).eq(NoteRecord::getDataStatus, DataStatus.AVAILABLE.getCode()).list().stream().map(NoteRecord::getId).toList();
|
|
|
|
|
} else if (TYPE_STRUCTURAL_REASONING.equals(prompt.getType())) {
|
|
|
|
|
ids = caseEvidenceService.lambdaQuery().eq(CaseEvidence::getCaseId, caseId).list().stream().map(CaseEvidence::getId).toList();
|
|
|
|
|
}
|
|
|
|
|
} else if (TYPE_STRUCTURAL_REASONING.equals(prompt.getType())) {
|
|
|
|
|
//证据
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case TaskRecordConstants.TASK_TYPE_SPECIFIED_CASE:
|
|
|
|
|
break;
|
|
|
|
|
case TaskRecordConstants.TASK_TYPE_SPECIFIED_RECORD:
|
|
|
|
|
break;
|
|
|
|
|
case TaskRecordConstants.TASK_TYPE_SPECIFIED_EVIDENCE:
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
if (!ids.isEmpty()) {
|
|
|
|
|
TaskCaseRecord taskCaseRecord = new TaskCaseRecord();
|
|
|
|
|
taskCaseRecord.setTaskRecordId(taskRecord.getId());
|
|
|
|
|
taskCaseRecord.setCaseId(caseId);
|
|
|
|
|
taskCaseRecord.setWaitingId(ids.stream().reduce((a, b) -> a + "," + b).orElse(""));
|
|
|
|
|
taskCaseRecord.setStatus(TaskRecordConstants.TASK_STATUS_WAITING);
|
|
|
|
|
taskCaseRecordService.save(taskCaseRecord);
|
|
|
|
|
for (String id : ids) {
|
|
|
|
|
Map<String, String> params = new HashMap<>();
|
|
|
|
|
params.put("taskId", taskRecord.getId());
|
|
|
|
|
params.put("caseId", caseId);
|
|
|
|
|
params.put("executeId", id);
|
|
|
|
|
params.put("promptId", taskRecordVo.getPromptId());
|
|
|
|
|
//map转String作为参数
|
|
|
|
|
xxlJobService.executeTaskByJobHandler(TASK_NAME_PROMPT_EXTRACT_TASK, new JSONObject(params).toString());
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
log.info("案件【{}】没有笔录", caseId);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
log.info("没有找到案件");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -114,8 +136,8 @@ public class TaskRecordServiceImpl extends ServiceImpl<TaskRecordMapper, TaskRec
|
|
|
|
|
Assert.notEmpty(taskIds, "取消任务失败,未找到任务信息");
|
|
|
|
|
|
|
|
|
|
List<TaskRecord> list = taskRecords.stream().filter(taskRecord -> !this.taskStatusCancelEnabled(taskRecord.getStatus())).toList();
|
|
|
|
|
if (CollUtil.isNotEmpty(list)){
|
|
|
|
|
log.info("cancelTask:取消任务失败,存在不可取消的任务:{}",list.stream().map(TaskRecord::getId).toList());
|
|
|
|
|
if (CollUtil.isNotEmpty(list)) {
|
|
|
|
|
log.info("cancelTask:取消任务失败,存在不可取消的任务:{}", list.stream().map(TaskRecord::getId).toList());
|
|
|
|
|
}
|
|
|
|
|
Assert.isTrue(CollUtil.isEmpty(list), "取消任务失败,存在不可取消的任务");
|
|
|
|
|
|
|
|
|
@ -133,8 +155,8 @@ public class TaskRecordServiceImpl extends ServiceImpl<TaskRecordMapper, TaskRec
|
|
|
|
|
Assert.notEmpty(taskIds, "删除任务失败,未找到任务信息");
|
|
|
|
|
|
|
|
|
|
List<TaskRecord> list = taskRecords.stream().filter(taskRecord -> !this.taskStatusDeleteEnabled(taskRecord.getStatus())).toList();
|
|
|
|
|
if (CollUtil.isNotEmpty(list)){
|
|
|
|
|
log.info("deleteTask:删除任务失败,存在不可删除的任务:{}",list.stream().map(TaskRecord::getId).toList());
|
|
|
|
|
if (CollUtil.isNotEmpty(list)) {
|
|
|
|
|
log.info("deleteTask:删除任务失败,存在不可删除的任务:{}", list.stream().map(TaskRecord::getId).toList());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Assert.isTrue(CollUtil.isEmpty(list), "删除任务失败,存在不可删除的任务");
|
|
|
|
|