Merge remote-tracking branch 'origin/master' into feature/REQ-3383

# Conflicts:
#	workflow-engine-core/src/main/java/cn/axzo/workflow/core/engine/cmd/CustomCompleteDummyTaskCmd.java
#	workflow-engine-core/src/main/java/cn/axzo/workflow/core/service/impl/BpmnProcessInstanceServiceImpl.java
#	workflow-engine-core/src/main/java/cn/axzo/workflow/core/service/impl/BpmnProcessTaskServiceImpl.java
This commit is contained in:
wangli 2024-12-09 09:52:11 +08:00
commit 5d376d2ac5
6 changed files with 39 additions and 8 deletions

View File

@ -5,7 +5,9 @@ import cn.axzo.workflow.common.model.request.bpmn.task.AttachmentDTO;
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;
@ -24,8 +26,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;
import static cn.axzo.workflow.core.engine.cmd.helper.CustomTaskHelper.batchAddAttachment;
@ -42,16 +47,18 @@ public class CustomCompleteDummyTaskCmd extends AbstractCommand<Void> implements
private final String operationDesc;
private final List<AttachmentDTO> attachmentList;
private final ExtAxHiTaskInstService extAxHiTaskInstService;
private final ExtAxProcessLogService extAxProcessLogService;
public CustomCompleteDummyTaskCmd(String processInstanceId, String taskId, String flowNodeName,
String operationDesc, List<AttachmentDTO> attachmentList,
ExtAxHiTaskInstService extAxHiTaskInstService) {
ExtAxHiTaskInstService extAxHiTaskInstService,
ExtAxProcessLogService extAxProcessLogService) {
this.processInstanceId = processInstanceId;
this.taskId = taskId;
this.flowNodeName = flowNodeName;
this.operationDesc = operationDesc;
this.attachmentList = attachmentList;
this.extAxHiTaskInstService = extAxHiTaskInstService;
this.extAxProcessLogService = extAxProcessLogService;
}
@Override
@ -90,6 +97,7 @@ public class CustomCompleteDummyTaskCmd extends AbstractCommand<Void> implements
TASK_ASSIGNEE_SKIP_FLAT, "系统");
batchAddAttachment(commandContext, task.getProcessInstanceId(), task, attachmentList, assignee);
task.setTransientVariable(TASK_COMPLETE_OPERATION_TYPE + taskId, APPROVED.getStatus());
taskService.complete(task.getId());
continueProcessingTask(commandContext);
@ -108,11 +116,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());
});
}
}

View File

@ -2,7 +2,12 @@ package cn.axzo.workflow.core.repository.mapper;
import cn.axzo.workflow.core.repository.entity.ExtAxProcessLog;
import org.apache.ibatis.annotations.Mapper;
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);
}

View File

@ -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);
}

View File

@ -146,6 +146,7 @@ import static cn.axzo.workflow.common.enums.BpmnFlowNodeMode.GENERAL;
import static cn.axzo.workflow.common.enums.BpmnFlowNodeMode.OR;
import static cn.axzo.workflow.common.enums.BpmnFlowNodeType.NODE_BUSINESS;
import static cn.axzo.workflow.common.enums.BpmnFlowNodeType.NODE_CARBON_COPY;
import static cn.axzo.workflow.common.enums.BpmnFlowNodeType.NODE_COMMENT;
import static cn.axzo.workflow.common.enums.BpmnFlowNodeType.NODE_ROBOT;
import static cn.axzo.workflow.common.enums.BpmnFlowNodeType.NODE_STARTER;
import static cn.axzo.workflow.common.enums.BpmnFlowNodeType.NODE_TASK;
@ -1039,7 +1040,7 @@ public class BpmnProcessInstanceServiceImpl implements BpmnProcessInstanceServic
.processInstanceId(dto.getProcessInstanceId())
.includeProcessVariables()
.singleResult();
logs.stream().reduce((f, s) -> Objects.equals(NODE_ROBOT.getType(), s.getActivityId()) ? f : s)
logs.stream().reduce((f, s) -> Objects.equals(s.getActivityId(), NODE_ROBOT.getType()) || Objects.equals(s.getActivityId(), NODE_COMMENT.getType()) ? f : s)
.ifPresent(e -> forecasting.addAll(
getProcessInstanceNodeForecastWithSpecifyTaskDefinitionKey(dto.getProcessInstanceId(), instance, e.getActivityId(), false, false))
);
@ -1307,6 +1308,7 @@ public class BpmnProcessInstanceServiceImpl implements BpmnProcessInstanceServic
Optional<BpmnTaskInstanceLogVO> processingTask = tasks.stream().filter(i -> Objects.equals(PROCESSING, i.getResult()))
.filter(i -> Objects.equals(i.getTaskDefinitionKey(), e.getActivityId())).findAny();
BpmnTaskDelegateAssigner assigner = BpmnTaskDelegateAssigner.toObjectCompatible(CollectionUtils.isEmpty(ListUtils.emptyIfNull(e.getAssigneeFull())) ? null : e.getAssigneeFull().get(0));
if (processingTask.isPresent()) {
// 多实例的情况需要合并节点
processingTask.ifPresent(i -> {
@ -1316,7 +1318,9 @@ public class BpmnProcessInstanceServiceImpl implements BpmnProcessInstanceServic
assigners.add(i.getAssigneeSnapshot());
}
}
assigners.add(BpmnTaskDelegateAssigner.toObjectCompatible(CollectionUtils.isEmpty(ListUtils.emptyIfNull(e.getAssigneeFull())) ? null : e.getAssigneeFull().get(0)));
if (Objects.nonNull(assigner)) {
assigners.add(assigner);
}
switch (i.getNodeMode()) {
case AND:
i.setOperationDesc(assigners.size() + "人会签,需要全部同意");
@ -1354,7 +1358,7 @@ public class BpmnProcessInstanceServiceImpl implements BpmnProcessInstanceServic
.fileList(getAttachmentByType(attachmentByTaskMap, e.getTaskId(), AttachmentTypeEnum.file))
.signatureUrl(getAttachmentByType(attachmentByTaskMap, e.getTaskId(), AttachmentTypeEnum.signature).stream().findFirst().orElse(new AttachmentDTO()).getUrl())
.assigneeSnapshot(Objects.equals(e.getNodeType(), BpmnFlowNodeType.NODE_CARBON_COPY.getType()) ? null :
BpmnTaskDelegateAssigner.toObjectCompatible(CollectionUtils.isEmpty(ListUtils.emptyIfNull(e.getAssigneeFull())) ? null : e.getAssigneeFull().get(0)))
assigner)
.forecastAssignees(Objects.equals(e.getNodeType(), BpmnFlowNodeType.NODE_CARBON_COPY.getType()) ? ListUtils.emptyIfNull(e.getAssigneeFull()) : Collections.emptyList())
.build());
}

View File

@ -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) {
@ -815,7 +818,8 @@ public class BpmnProcessTaskServiceImpl implements BpmnProcessTaskService {
Objects.isNull(dto.getRobotNode()) ? null : dto.getRobotNode().getFlowNodeName(),
Objects.isNull(dto.getRobotNode()) ? null : dto.getRobotNode().getOperationDesc(),
dto.getAttachmentList(),
extAxHiTaskInstService));
extAxHiTaskInstService,
extAxProcessLogService));
}
@Override

View File

@ -78,6 +78,11 @@ public class ExtAxProcessLogServiceImpl implements ExtAxProcessLogService {
return extAxProcessLogMapper.selectList(buildQueryWrapper(query));
}
@Override
public void restore(String processInstanceId, String taskId) {
extAxProcessLogMapper.restore(processInstanceId, taskId);
}
LambdaQueryWrapper<ExtAxProcessLog> buildQueryWrapper(ExtAxProcessLog log) {
return new LambdaQueryWrapper<ExtAxProcessLog>()
.eq(Objects.nonNull(log.getId()), ExtAxProcessLog::getId, log.getId())
@ -86,6 +91,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());
}
}