|
|
|
@ -1,12 +1,17 @@
|
|
|
|
|
package com.supervision.police.service.impl;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
|
|
import cn.hutool.core.util.ArrayUtil;
|
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
|
import com.supervision.common.constant.TaskRecordConstants;
|
|
|
|
|
import com.supervision.police.domain.TaskCaseRecord;
|
|
|
|
|
import com.supervision.police.service.TaskCaseRecordService;
|
|
|
|
|
import com.supervision.police.mapper.TaskCaseRecordMapper;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
import java.util.Arrays;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -14,6 +19,7 @@ import java.util.List;
|
|
|
|
|
* @description 针对表【task_case_record】的数据库操作Service实现
|
|
|
|
|
* @createDate 2024-12-25 09:57:08
|
|
|
|
|
*/
|
|
|
|
|
@Slf4j
|
|
|
|
|
@Service
|
|
|
|
|
public class TaskCaseRecordServiceImpl extends ServiceImpl<TaskCaseRecordMapper, TaskCaseRecord>
|
|
|
|
|
implements TaskCaseRecordService{
|
|
|
|
@ -21,6 +27,76 @@ public class TaskCaseRecordServiceImpl extends ServiceImpl<TaskCaseRecordMapper,
|
|
|
|
|
public List<TaskCaseRecord> queryProcessingTaskList() {
|
|
|
|
|
return super.lambdaQuery().eq(TaskCaseRecord::getStatus, TaskRecordConstants.TASK_STATUS_PROCESSING).list();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<TaskCaseRecord> queryByTaskId(String taskId) {
|
|
|
|
|
|
|
|
|
|
return super.lambdaQuery().eq(TaskCaseRecord::getTaskRecordId, taskId).list();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public String getActuallyStatus(TaskCaseRecord taskCaseRecord) {
|
|
|
|
|
String waitingId = taskCaseRecord.getWaitingId();
|
|
|
|
|
if (StrUtil.isNotEmpty(waitingId)) {
|
|
|
|
|
return TaskRecordConstants.TASK_STATUS_PROCESSING;
|
|
|
|
|
}
|
|
|
|
|
return TaskRecordConstants.TASK_STATUS_SUCCESS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public TaskCaseRecord updateStatus(String taskId, String executeId, boolean isSuccess) {
|
|
|
|
|
List<TaskCaseRecord> taskCaseRecords = this.queryByTaskId(taskId);
|
|
|
|
|
|
|
|
|
|
return updateStatus(taskId, executeId, isSuccess, taskCaseRecords);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public TaskCaseRecord updateStatus(String taskId, String executeId, boolean isSuccess, List<TaskCaseRecord> taskCaseRecords) {
|
|
|
|
|
// 理论上只能存在一个taskCase信息
|
|
|
|
|
List<TaskCaseRecord> taskCaseRecordList = taskCaseRecords.stream()
|
|
|
|
|
.filter(taskCaseRecord -> StrUtil.isNotEmpty(taskCaseRecord.getWaitingId()))
|
|
|
|
|
.filter(taskCaseRecord -> Arrays.asList(taskCaseRecord.getWaitingId().split(",")).contains(executeId))
|
|
|
|
|
.toList();
|
|
|
|
|
log.info("updateStatus:任务【{}】,当前执行ID【{}】,当前任务案件执行列表长度:{}", taskId, executeId, taskCaseRecordList.size());
|
|
|
|
|
TaskCaseRecord taskCaseRecord = CollUtil.getFirst(taskCaseRecordList);
|
|
|
|
|
|
|
|
|
|
taskCaseRecord.setWaitingId(removeSingle(taskCaseRecord.getWaitingId(), executeId));
|
|
|
|
|
if (isSuccess){
|
|
|
|
|
taskCaseRecord.setProcessedId(appendSingle(taskCaseRecord.getProcessedId(), executeId));
|
|
|
|
|
}else {
|
|
|
|
|
taskCaseRecord.setExceptionId(appendSingle(taskCaseRecord.getExceptionId(), executeId));
|
|
|
|
|
}
|
|
|
|
|
taskCaseRecord.setStatus(this.getActuallyStatus(taskCaseRecord));
|
|
|
|
|
// 更新任务案件执行记录
|
|
|
|
|
this.updateById(taskCaseRecord);
|
|
|
|
|
return taskCaseRecord;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Boolean updateStatus(String taskId, List<String> oldStatus, String nowStatus) {
|
|
|
|
|
return super.lambdaUpdate()
|
|
|
|
|
.eq(TaskCaseRecord::getTaskRecordId, taskId)
|
|
|
|
|
.in(CollUtil.isNotEmpty(oldStatus),TaskCaseRecord::getStatus, oldStatus)
|
|
|
|
|
.set(TaskCaseRecord::getStatus, nowStatus)
|
|
|
|
|
.update();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private String appendSingle(String longString, String single) {
|
|
|
|
|
if (StrUtil.isEmpty(longString)){
|
|
|
|
|
return single;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return String.join(",", longString, single);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private String removeSingle(String longString, String single) {
|
|
|
|
|
if (StrUtil.isEmpty(longString)){
|
|
|
|
|
return longString;
|
|
|
|
|
}
|
|
|
|
|
String[] split = longString.split(",");
|
|
|
|
|
split = ArrayUtil.remove(split, ArrayUtil.indexOf(split, single));
|
|
|
|
|
return ArrayUtil.join(split, ",");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|