feat(REQ-3383) - 日志中存在机器人节点时,日志展示不完整
This commit is contained in:
parent
f717e3c09d
commit
aa5972e804
@ -4,7 +4,9 @@ import cn.axzo.workflow.common.enums.BpmnProcessInstanceResultEnum;
|
||||
import cn.axzo.workflow.common.model.request.bpmn.task.BpmnTaskDelegateAssigner;
|
||||
import cn.axzo.workflow.core.common.exception.WorkflowEngineException;
|
||||
import cn.axzo.workflow.core.engine.cmd.helper.CustomTaskHelper;
|
||||
import cn.axzo.workflow.core.repository.entity.ExtAxProcessLog;
|
||||
import cn.axzo.workflow.core.service.ExtAxHiTaskInstService;
|
||||
import cn.axzo.workflow.core.service.ExtAxProcessLogService;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import org.flowable.common.engine.impl.identity.Authentication;
|
||||
import org.flowable.common.engine.impl.interceptor.CommandContext;
|
||||
@ -23,8 +25,11 @@ import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
import static cn.axzo.workflow.common.constant.BpmnConstants.COMMENT_TYPE_OPERATION_DESC;
|
||||
import static cn.axzo.workflow.common.constant.BpmnConstants.HIDDEN_ASSIGNEE_ID;
|
||||
import static cn.axzo.workflow.common.constant.BpmnConstants.TASK_ASSIGNEE_SKIP_FLAT;
|
||||
import static cn.axzo.workflow.common.constant.BpmnConstants.TASK_COMPLETE_OPERATION_TYPE;
|
||||
import static cn.axzo.workflow.common.enums.BpmnFlowNodeType.NODE_ROBOT;
|
||||
import static cn.axzo.workflow.common.enums.BpmnProcessInstanceResultEnum.APPROVED;
|
||||
import static cn.axzo.workflow.core.common.code.BpmnTaskRespCode.DUMMY_TASK_NOT_EXISTS;
|
||||
|
||||
/**
|
||||
@ -39,14 +44,16 @@ public class CustomCompleteDummyTaskCmd extends AbstractCommand<Void> implements
|
||||
private final String flowNodeName;
|
||||
private final String operationDesc;
|
||||
private final ExtAxHiTaskInstService extAxHiTaskInstService;
|
||||
|
||||
private final ExtAxProcessLogService extAxProcessLogService;
|
||||
public CustomCompleteDummyTaskCmd(String processInstanceId, String taskId, String flowNodeName,
|
||||
String operationDesc, ExtAxHiTaskInstService extAxHiTaskInstService) {
|
||||
String operationDesc, ExtAxHiTaskInstService extAxHiTaskInstService,
|
||||
ExtAxProcessLogService extAxProcessLogService) {
|
||||
this.processInstanceId = processInstanceId;
|
||||
this.taskId = taskId;
|
||||
this.flowNodeName = flowNodeName;
|
||||
this.operationDesc = operationDesc;
|
||||
this.extAxHiTaskInstService = extAxHiTaskInstService;
|
||||
this.extAxProcessLogService = extAxProcessLogService;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -80,7 +87,7 @@ public class CustomCompleteDummyTaskCmd extends AbstractCommand<Void> implements
|
||||
CustomTaskHelper.addComment(commandContext, task, COMMENT_TYPE_OPERATION_DESC, operationDesc);
|
||||
Authentication.setAuthenticatedUserId(null);
|
||||
}
|
||||
|
||||
task.setTransientVariable(TASK_COMPLETE_OPERATION_TYPE + taskId, APPROVED.getStatus());
|
||||
taskService.complete(task.getId());
|
||||
|
||||
continueProcessingTask(commandContext);
|
||||
@ -100,11 +107,14 @@ public class CustomCompleteDummyTaskCmd extends AbstractCommand<Void> implements
|
||||
return;
|
||||
}
|
||||
taskList.stream().filter(i -> !Objects.equals(i.getTaskDefinitionKey(), NODE_ROBOT.getType()))
|
||||
.filter(i -> Objects.nonNull(i.getOwner()))
|
||||
.filter(i -> Objects.equals(i.getAssignee(), HIDDEN_ASSIGNEE_ID))
|
||||
.forEach(i -> {
|
||||
taskService.setAssignee(i.getId(), i.getOwner());
|
||||
taskService.setOwner(i.getId(), null);
|
||||
|
||||
extAxProcessLogService.restore(i.getProcessInstanceId(), i.getId());
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -117,13 +117,14 @@ public class CustomCreateDummyTaskCmd extends AbstractCommand<String> implements
|
||||
task.setTaskDefinitionKey(NODE_ROBOT.getType());
|
||||
task.setPriority(DEFAULT_PRIORITY);
|
||||
task.setCreateTime(new Date());
|
||||
// 创建临时节点
|
||||
taskService.saveTask(task);
|
||||
|
||||
Authentication.setAuthenticatedUserId("system");
|
||||
CustomTaskHelper.addComment(commandContext, task, COMMENT_TYPE_OPERATION_DESC, operationDesc);
|
||||
Authentication.setAuthenticatedUserId(null);
|
||||
|
||||
// 创建临时节点
|
||||
taskService.saveTask(task);
|
||||
|
||||
if (Objects.nonNull(operator)) {
|
||||
CommandContextUtil.getEntityCache().findInCache(HistoricTaskInstanceEntity.class).stream()
|
||||
.filter(i -> Objects.equals(i.getId(), task.getId())).findAny()
|
||||
|
||||
@ -89,7 +89,8 @@ public class TaskEntityEventHandle implements EntityEventHandle<TaskEntity> {
|
||||
log.setNodeType((getNodeType(flowElement).orElse(BpmnFlowNodeType.NODE_EMPTY)).getType());
|
||||
log.setNodeMode((isNodeStarter ? BpmnFlowNodeMode.GENERAL : getNodeMode(flowElement)).getType());
|
||||
log.setTaskId(taskEntity.getId());
|
||||
log.setOperationDesc(PENDING.getDesc());
|
||||
String operationDesc = taskEntity.getVariable(COMMENT_TYPE_OPERATION_DESC, String.class);
|
||||
log.setOperationDesc(StringUtils.hasText(operationDesc) ? operationDesc : PENDING.getDesc());
|
||||
log.setStartTime(taskEntity.getCreateTime());
|
||||
log.setStatus(PROCESSING.getStatus());
|
||||
|
||||
|
||||
@ -1,8 +1,17 @@
|
||||
package cn.axzo.workflow.core.repository.mapper;
|
||||
|
||||
import cn.axzo.workflow.core.repository.entity.ExtAxProcessLog;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
import org.apache.ibatis.annotations.Update;
|
||||
|
||||
@Mapper
|
||||
public interface ExtAxProcessLogMapper extends BaseMapperX<ExtAxProcessLog> {
|
||||
|
||||
// @Update("UPDATE ext_ax_process_log SET is_delete = 0, start_time = NOW() WHERE process_instance_id = #{processInstanceId} and task_id = #{taskId}")
|
||||
// void restore(String processInstanceId, String taskId);
|
||||
|
||||
@Select("SELECT * FROM ext_ax_process_log where process_instance_id = #{processInstanceId} and task_id = #{taskId}")
|
||||
ExtAxProcessLog selectProcessInstanceIdAndTaskId(String processInstanceId, String taskId);
|
||||
}
|
||||
|
||||
@ -53,4 +53,6 @@ public interface ExtAxProcessLogService {
|
||||
void updateAssignee(ExtAxProcessLog updateLog, BpmnTaskDelegateAssigner assignee, String operationDesc);
|
||||
|
||||
List<ExtAxProcessLog> genericQuery(ExtAxProcessLog query);
|
||||
|
||||
void restore(String processInstanceId, String taskId);
|
||||
}
|
||||
|
||||
@ -48,6 +48,7 @@ import cn.axzo.workflow.core.repository.entity.ExtAxHiTaskInst;
|
||||
import cn.axzo.workflow.core.service.BpmnProcessDefinitionService;
|
||||
import cn.axzo.workflow.core.service.BpmnProcessTaskService;
|
||||
import cn.axzo.workflow.core.service.ExtAxHiTaskInstService;
|
||||
import cn.axzo.workflow.core.service.ExtAxProcessLogService;
|
||||
import cn.axzo.workflow.core.service.converter.BpmnHistoricAttachmentConverter;
|
||||
import cn.axzo.workflow.core.service.converter.BpmnHistoricTaskInstanceConverter;
|
||||
import cn.axzo.workflow.core.service.converter.BpmnTaskConverter;
|
||||
@ -177,6 +178,8 @@ public class BpmnProcessTaskServiceImpl implements BpmnProcessTaskService {
|
||||
private BpmnProcessTaskService bpmnProcessTaskService;
|
||||
@Resource
|
||||
private BpmnProcessDefinitionService bpmnProcessModelService;
|
||||
@Resource
|
||||
private ExtAxProcessLogService extAxProcessLogService;
|
||||
|
||||
@Override
|
||||
public BpmPageResult<BpmnTaskTodoPageItemVO> getTodoTaskPage(BpmnTaskPageSearchDTO dto) {
|
||||
@ -814,7 +817,7 @@ public class BpmnProcessTaskServiceImpl implements BpmnProcessTaskService {
|
||||
commandExecutor.execute(new CustomCompleteDummyTaskCmd(dto.getProcessInstanceId(), dto.getTaskId(),
|
||||
Objects.isNull(dto.getRobotNode()) ? null : dto.getRobotNode().getFlowNodeName(),
|
||||
Objects.isNull(dto.getRobotNode()) ? null : dto.getRobotNode().getOperationDesc(),
|
||||
extAxHiTaskInstService));
|
||||
extAxHiTaskInstService, extAxProcessLogService));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -11,6 +11,7 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
@ -78,6 +79,16 @@ public class ExtAxProcessLogServiceImpl implements ExtAxProcessLogService {
|
||||
return extAxProcessLogMapper.selectList(buildQueryWrapper(query));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void restore(String processInstanceId, String taskId) {
|
||||
ExtAxProcessLog extAxProcessLog = extAxProcessLogMapper.selectProcessInstanceIdAndTaskId(processInstanceId, taskId);
|
||||
extAxProcessLog.setId(null);
|
||||
extAxProcessLog.setCreateAt(null);
|
||||
extAxProcessLog.setUpdateAt(null);
|
||||
extAxProcessLog.setIsDelete(0L);
|
||||
extAxProcessLogMapper.insert(extAxProcessLog);
|
||||
}
|
||||
|
||||
LambdaQueryWrapper<ExtAxProcessLog> buildQueryWrapper(ExtAxProcessLog log) {
|
||||
return new LambdaQueryWrapper<ExtAxProcessLog>()
|
||||
.eq(Objects.nonNull(log.getId()), ExtAxProcessLog::getId, log.getId())
|
||||
@ -86,6 +97,6 @@ public class ExtAxProcessLogServiceImpl implements ExtAxProcessLogService {
|
||||
.eq(StringUtils.hasText(log.getActivityName()), ExtAxProcessLog::getActivityName, log.getActivityName())
|
||||
.eq(StringUtils.hasText(log.getTaskId()), ExtAxProcessLog::getTaskId, log.getTaskId())
|
||||
.eq(StringUtils.hasText(log.getTenantId()), ExtAxProcessLog::getTenantId, log.getTenantId())
|
||||
.eq(ExtAxProcessLog::getIsDelete, 0);
|
||||
.eq(ExtAxProcessLog::getIsDelete, log.getIsDelete());
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user