ztcloud-dist 中 bpm 覆盖回来,包含 http://172.16.46.63:31560/index.php?m=task&f=view&taskID=735 和 http://172.16.46.63:31560/index.php?m=task&f=view&taskID=552 中的修复
This commit is contained in:
@@ -11,7 +11,9 @@
|
||||
<modules>
|
||||
<module>zt-module-bpm-api</module>
|
||||
<module>zt-module-bpm-server</module>
|
||||
<module>zt-module-bpm-server-app</module>
|
||||
</modules>
|
||||
<version>${revision}</version>
|
||||
<artifactId>zt-module-bpm</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
|
||||
@@ -3,10 +3,10 @@
|
||||
FROM 172.16.46.66:10043/base-service/eclipse-temurin:21-jre
|
||||
|
||||
## 创建目录,并使用它作为工作目录
|
||||
RUN mkdir -p /zt-module-bpm-server
|
||||
WORKDIR /zt-module-bpm-server
|
||||
RUN mkdir -p /zt-module-bpm-server-app
|
||||
WORKDIR /zt-module-bpm-server-app
|
||||
## 将后端项目的 Jar 文件,复制到镜像中
|
||||
COPY ./target/zt-module-bpm-server.jar app.jar
|
||||
COPY ./target/zt-module-bpm-server-app.jar app.jar
|
||||
|
||||
## 设置 TZ 时区
|
||||
## 设置 JAVA_OPTS 环境变量,可通过 docker run -e "JAVA_OPTS=" 进行覆盖
|
||||
49
zt-module-bpm/zt-module-bpm-server-app/pom.xml
Normal file
49
zt-module-bpm/zt-module-bpm-server-app/pom.xml
Normal file
@@ -0,0 +1,49 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.zt.plat</groupId>
|
||||
<artifactId>zt-module-bpm</artifactId>
|
||||
<version>${revision}</version>
|
||||
</parent>
|
||||
<artifactId>zt-module-bpm-server-app</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<name>${project.artifactId}</name>
|
||||
<description>
|
||||
bpm 模块启动器。
|
||||
</description>
|
||||
|
||||
<dependencies>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>com.zt.plat</groupId>
|
||||
<artifactId>zt-module-bpm-server</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<!-- 设置构建的 jar 包名 -->
|
||||
<finalName>${project.artifactId}</finalName>
|
||||
<plugins>
|
||||
<!-- 打包 -->
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<version>${spring.boot.version}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>repackage</goal> <!-- 将引入的 jar 打入其中 -->
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
@@ -76,5 +76,14 @@
|
||||
<logger name="com.zt.plat.module.bpm.dal" level="DEBUG" additivity="false">
|
||||
<appender-ref ref="STDOUT"/>
|
||||
</logger>
|
||||
<!-- <logger name="org.flowable" level="DEBUG" additivity="false">-->
|
||||
<!-- <appender-ref ref="STDOUT"/>-->
|
||||
<!-- </logger>-->
|
||||
<!-- <logger name="org.flowable.engine.impl.persistence.entity" level="DEBUG" additivity="false">-->
|
||||
<!-- <appender-ref ref="STDOUT"/>-->
|
||||
<!-- </logger>-->
|
||||
<!-- <logger name="org.flowable.task.service.impl.persistence.entity" level="DEBUG" additivity="false">-->
|
||||
<!-- <appender-ref ref="STDOUT"/>-->
|
||||
<!-- </logger>-->
|
||||
|
||||
</configuration>
|
||||
@@ -120,23 +120,4 @@
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<!-- 设置构建的 jar 包名 -->
|
||||
<finalName>${project.artifactId}</finalName>
|
||||
<plugins>
|
||||
<!-- 打包 -->
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<version>${spring.boot.version}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>repackage</goal> <!-- 将引入的 jar 打入其中 -->
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
|
||||
@@ -26,11 +26,17 @@ import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.annotation.security.PermitAll;
|
||||
import jakarta.validation.Valid;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.collections4.list.SetUniqueList;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.flowable.engine.RuntimeService;
|
||||
import org.flowable.engine.TaskService;
|
||||
import org.flowable.engine.history.HistoricProcessInstance;
|
||||
import org.flowable.engine.migration.ProcessInstanceMigrationBuilder;
|
||||
import org.flowable.engine.repository.ProcessDefinition;
|
||||
import org.flowable.engine.runtime.ActivityInstance;
|
||||
import org.flowable.task.api.Task;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
@@ -41,6 +47,7 @@ import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.zt.plat.framework.common.pojo.CommonResult.success;
|
||||
import static com.zt.plat.framework.common.util.collection.CollectionUtils.*;
|
||||
@@ -234,4 +241,39 @@ public class BpmProcessInstanceController {
|
||||
return success(processInstanceService.getProcessInstanceBpmnModelView(id));
|
||||
}
|
||||
|
||||
|
||||
@Resource
|
||||
private RuntimeService runtimeService;
|
||||
|
||||
@Resource
|
||||
private TaskService taskService2;
|
||||
|
||||
@GetMapping("/klwtest")
|
||||
@Operation(summary = "klw测试")
|
||||
@PermitAll
|
||||
public CommonResult<String> klwtest(@RequestParam String processInstanceId, @RequestParam String nodeId) {
|
||||
List<ActivityInstance> currentActivities = runtimeService
|
||||
.createActivityInstanceQuery()
|
||||
.processInstanceId(processInstanceId)
|
||||
.unfinished()
|
||||
.list();
|
||||
// taskService2.addComment(null, processInstanceId,
|
||||
// "测试 comment");
|
||||
if (CollectionUtils.isNotEmpty(currentActivities)) {
|
||||
runtimeService.createChangeActivityStateBuilder()
|
||||
.processInstanceId(processInstanceId)
|
||||
.moveActivityIdsToSingleActivityId(
|
||||
currentActivities.stream()
|
||||
.map(ActivityInstance::getActivityId)
|
||||
.collect(Collectors.toList()),
|
||||
nodeId
|
||||
)
|
||||
.changeState();
|
||||
}
|
||||
|
||||
|
||||
return success("klw测试");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ public class BpmTaskEventListener extends AbstractFlowableEngineEventListener {
|
||||
if (StrUtil.isEmpty(activity.getTaskId())) {
|
||||
return;
|
||||
}
|
||||
taskService.processTaskCanceled(activity.getTaskId());
|
||||
taskService.processTaskCanceled(activity.getTaskId(), null);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -235,7 +235,7 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService
|
||||
@Override
|
||||
public List<ActivityNode> getNextApprovalNodes(Long loginUserId, BpmApprovalDetailReqVO reqVO) {
|
||||
// 1.1 校验任务存在,且是当前用户的
|
||||
Task task = taskService.validateTask(loginUserId, reqVO.getTaskId());
|
||||
Task task = taskService.validateTask(loginUserId, reqVO.getTaskId(), false);
|
||||
// 1.2 校验流程实例存在
|
||||
ProcessInstance instance = getProcessInstance(task.getProcessInstanceId());
|
||||
if (instance == null) {
|
||||
|
||||
@@ -98,7 +98,7 @@ public interface BpmTaskService {
|
||||
* @param userId 用户 id
|
||||
* @param taskId task id
|
||||
*/
|
||||
Task validateTask(Long userId, String taskId);
|
||||
Task validateTask(Long userId, String taskId, boolean isCheckSuperAdmin);
|
||||
|
||||
/**
|
||||
* 获取任务
|
||||
@@ -269,7 +269,7 @@ public interface BpmTaskService {
|
||||
*
|
||||
* @param taskId 任务的编号
|
||||
*/
|
||||
void processTaskCanceled(String taskId);
|
||||
void processTaskCanceled(String taskId, String reason);
|
||||
|
||||
/**
|
||||
* 处理 Task 设置审批人事件,目前是发送审批消息
|
||||
|
||||
@@ -6,12 +6,14 @@ import cn.hutool.core.lang.Assert;
|
||||
import cn.hutool.core.util.*;
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.zt.plat.framework.common.pojo.CommonResult;
|
||||
import com.zt.plat.framework.common.pojo.PageResult;
|
||||
import com.zt.plat.framework.common.util.date.DateUtils;
|
||||
import com.zt.plat.framework.common.util.number.NumberUtils;
|
||||
import com.zt.plat.framework.common.util.object.ObjectUtils;
|
||||
import com.zt.plat.framework.common.util.object.PageUtils;
|
||||
import com.zt.plat.framework.datapermission.core.annotation.DataPermission;
|
||||
import com.zt.plat.framework.security.core.util.SecurityFrameworkUtils;
|
||||
import com.zt.plat.framework.web.core.util.WebFrameworkUtils;
|
||||
import com.zt.plat.module.bpm.controller.admin.definition.vo.model.BpmModelMetaInfoVO;
|
||||
import com.zt.plat.module.bpm.controller.admin.task.vo.task.*;
|
||||
@@ -35,11 +37,13 @@ import com.zt.plat.module.bpm.service.message.BpmMessageService;
|
||||
import com.zt.plat.module.bpm.service.message.dto.BpmMessageSendWhenTaskTimeoutReqDTO;
|
||||
import com.zt.plat.module.system.api.dept.DeptApi;
|
||||
import com.zt.plat.module.system.api.dept.dto.DeptRespDTO;
|
||||
import com.zt.plat.module.system.api.permission.PermissionApi;
|
||||
import com.zt.plat.module.system.api.user.AdminUserApi;
|
||||
import com.zt.plat.module.system.api.user.dto.AdminUserRespDTO;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.flowable.bpmn.model.*;
|
||||
import org.flowable.engine.HistoryService;
|
||||
import org.flowable.engine.ManagementService;
|
||||
@@ -107,6 +111,10 @@ public class BpmTaskServiceImpl implements BpmTaskService {
|
||||
|
||||
@Resource
|
||||
private AdminUserApi adminUserApi;
|
||||
|
||||
@Resource
|
||||
private PermissionApi permissionApi;
|
||||
|
||||
@Resource
|
||||
private DeptApi deptApi;
|
||||
|
||||
@@ -142,12 +150,17 @@ public class BpmTaskServiceImpl implements BpmTaskService {
|
||||
|
||||
@Override
|
||||
public BpmTaskRespVO getTodoTask(Long userId, String taskId, String processInstanceId) {
|
||||
boolean isSelfTask = true;
|
||||
// 1.1 获取指定的用户待办任务
|
||||
Task todoTask = getMyTodoTask(userId, taskId);
|
||||
// 1.2 获取不到,则获取该流程实例下,第一个用户的待办任务
|
||||
if (todoTask == null) {
|
||||
todoTask = getMyFirstTodoTask(userId, processInstanceId);
|
||||
}
|
||||
if (todoTask == null && isSuperAdmin(userId)) {
|
||||
isSelfTask = false;
|
||||
todoTask = getMyFirstTodoTaskForAdmin(processInstanceId);
|
||||
}
|
||||
if (todoTask == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -159,6 +172,19 @@ public class BpmTaskServiceImpl implements BpmTaskService {
|
||||
BpmnModel bpmnModel = bpmProcessDefinitionService.getProcessDefinitionBpmnModel(todoTask.getProcessDefinitionId());
|
||||
Map<Integer, BpmTaskRespVO.OperationButtonSetting> buttonsSetting = BpmnModelUtils.parseButtonsSetting(
|
||||
bpmnModel, todoTask.getTaskDefinitionKey());
|
||||
// 如果当前登录人是管理员,并且当前任务不属于管理员,则只显示退回,取消和转办按钮
|
||||
if (!isSelfTask && buttonsSetting != null) {
|
||||
Optional.ofNullable(buttonsSetting.get(1))
|
||||
.ifPresent(button -> button.setEnable(false));
|
||||
Optional.ofNullable(buttonsSetting.get(2))
|
||||
.ifPresent(button -> button.setEnable(false));
|
||||
Optional.ofNullable(buttonsSetting.get(4))
|
||||
.ifPresent(button -> button.setEnable(false));
|
||||
Optional.ofNullable(buttonsSetting.get(5))
|
||||
.ifPresent(button -> button.setEnable(false));
|
||||
Optional.ofNullable(buttonsSetting.get(7))
|
||||
.ifPresent(button -> button.setEnable(false));
|
||||
}
|
||||
Boolean signEnable = parseSignEnable(bpmnModel, todoTask.getTaskDefinitionKey());
|
||||
Boolean reasonRequire = parseReasonRequire(bpmnModel, todoTask.getTaskDefinitionKey());
|
||||
Integer nodeType = parseNodeType(BpmnModelUtils.getFlowElementById(bpmnModel, todoTask.getTaskDefinitionKey()));
|
||||
@@ -203,7 +229,7 @@ public class BpmTaskServiceImpl implements BpmTaskService {
|
||||
/**
|
||||
* 获得用户指定 processInstanceId 流程编号下的首个“待办”(未审批、且可审核)的任务
|
||||
*
|
||||
* @param userId 用户编号
|
||||
* @param userId 用户编号
|
||||
* @param processInstanceId 流程编号
|
||||
* @return 任务
|
||||
*/
|
||||
@@ -221,12 +247,47 @@ public class BpmTaskServiceImpl implements BpmTaskService {
|
||||
.list();
|
||||
|
||||
// 2. 查询我的首个任务
|
||||
SecurityFrameworkUtils.getLoginUser();
|
||||
return CollUtil.findOne(tasks, task -> {
|
||||
return isAssignUserTask(userId, task) // 当前用户为审批人
|
||||
|| isAddSignUserTask(userId, task); // 当前用户为加签人(为了减签)
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得指定 processInstanceId 流程编号下的首个“待办”(未审批、且可审核)的任务(超级管理员用)
|
||||
*
|
||||
* @param processInstanceId 流程编号
|
||||
* @return 任务
|
||||
*/
|
||||
private Task getMyFirstTodoTaskForAdmin(String processInstanceId) {
|
||||
if (processInstanceId == null) {
|
||||
return null;
|
||||
}
|
||||
// 1. 查询所有任务
|
||||
List<Task> tasks = taskService.createTaskQuery()
|
||||
.active()
|
||||
.processInstanceId(processInstanceId)
|
||||
.includeTaskLocalVariables()
|
||||
.includeProcessVariables()
|
||||
.orderByTaskCreateTime().asc() // 按创建时间升序
|
||||
.list();
|
||||
|
||||
// 2. 查询首个任务
|
||||
SecurityFrameworkUtils.getLoginUser();
|
||||
return CollUtil.findOne(tasks, task -> {
|
||||
return true; // 当前用户为超级管理员
|
||||
});
|
||||
}
|
||||
|
||||
private boolean isSuperAdmin(Long userId) {
|
||||
CommonResult<Boolean> result = permissionApi.isSuperAdmin(userId);
|
||||
if (result != null) {
|
||||
return result.getCheckedData();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<HistoricTaskInstance> getTaskDonePage(Long userId, BpmTaskPageReqVO pageVO) {
|
||||
HistoricTaskInstanceQuery taskQuery = historyService.createHistoricTaskInstanceQuery()
|
||||
@@ -301,10 +362,13 @@ public class BpmTaskServiceImpl implements BpmTaskService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Task validateTask(Long userId, String taskId) {
|
||||
public Task validateTask(Long userId, String taskId, boolean isCheckSuperAdmin) {
|
||||
Task task = validateTaskExist(taskId);
|
||||
// 为什么判断 assignee 非空的情况下?
|
||||
// 例如说:在审批人为空时,我们会有“自动审批通过”的策略,此时 userId 为 null,允许通过
|
||||
if (isCheckSuperAdmin && isSuperAdmin(userId)) {
|
||||
return task;
|
||||
}
|
||||
if (StrUtil.isNotBlank(task.getAssignee())
|
||||
&& ObjectUtil.notEqual(userId, NumberUtils.parseLong(task.getAssignee()))) {
|
||||
throw exception(TASK_OPERATE_FAIL_ASSIGN_NOT_SELF);
|
||||
@@ -528,7 +592,7 @@ public class BpmTaskServiceImpl implements BpmTaskService {
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void approveTask(Long userId, @Valid BpmTaskApproveReqVO reqVO) {
|
||||
// 1.1 校验任务存在
|
||||
Task task = validateTask(userId, reqVO.getId());
|
||||
Task task = validateTask(userId, reqVO.getId(), false);
|
||||
// 1.2 校验流程实例存在
|
||||
ProcessInstance instance = processInstanceService.getProcessInstance(task.getProcessInstanceId());
|
||||
if (instance == null) {
|
||||
@@ -601,15 +665,15 @@ public class BpmTaskServiceImpl implements BpmTaskService {
|
||||
|
||||
/**
|
||||
* 校验选择的下一个节点的审批人,是否合法
|
||||
*
|
||||
* <p>
|
||||
* 1. 是否有漏选:没有选择审批人
|
||||
* 2. 是否有多选:非下一个节点
|
||||
*
|
||||
* @param taskDefinitionKey 当前任务节点标识
|
||||
* @param variables 流程变量
|
||||
* @param bpmnModel 流程模型
|
||||
* @param nextAssignees 下一个节点审批人集合(参数)
|
||||
* @param processInstance 流程实例
|
||||
* @param variables 流程变量
|
||||
* @param bpmnModel 流程模型
|
||||
* @param nextAssignees 下一个节点审批人集合(参数)
|
||||
* @param processInstance 流程实例
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
private Map<String, Object> validateAndSetNextAssignees(String taskDefinitionKey, Map<String, Object> variables, BpmnModel bpmnModel,
|
||||
@@ -661,7 +725,7 @@ public class BpmTaskServiceImpl implements BpmTaskService {
|
||||
approveUserSelectAssignees = new HashMap<>();
|
||||
}
|
||||
approveUserSelectAssignees.put(nextFlowNode.getId(), assignees);
|
||||
Map<String,List<Long>> existingApproveUserSelectAssignees = (Map<String,List<Long>>) variables.get(
|
||||
Map<String, List<Long>> existingApproveUserSelectAssignees = (Map<String, List<Long>>) variables.get(
|
||||
BpmnVariableConstants.PROCESS_INSTANCE_VARIABLE_APPROVE_USER_SELECT_ASSIGNEES);
|
||||
if (CollUtil.isNotEmpty(existingApproveUserSelectAssignees)) {
|
||||
approveUserSelectAssignees.putAll(existingApproveUserSelectAssignees);
|
||||
@@ -771,7 +835,7 @@ public class BpmTaskServiceImpl implements BpmTaskService {
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void rejectTask(Long userId, @Valid BpmTaskRejectReqVO reqVO) {
|
||||
// 1.1 校验任务存在
|
||||
Task task = validateTask(userId, reqVO.getId());
|
||||
Task task = validateTask(userId, reqVO.getId(), false);
|
||||
// 1.2 校验流程实例存在
|
||||
ProcessInstance instance = processInstanceService.getProcessInstance(task.getProcessInstanceId());
|
||||
if (instance == null) {
|
||||
@@ -837,7 +901,7 @@ public class BpmTaskServiceImpl implements BpmTaskService {
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void returnTask(Long userId, BpmTaskReturnReqVO reqVO) {
|
||||
// 1.1 当前任务 task
|
||||
Task task = validateTask(userId, reqVO.getId());
|
||||
Task task = validateTask(userId, reqVO.getId(), true);
|
||||
if (task.isSuspended()) {
|
||||
throw exception(TASK_IS_PENDING);
|
||||
}
|
||||
@@ -895,6 +959,8 @@ public class BpmTaskServiceImpl implements BpmTaskService {
|
||||
|
||||
List<String> runExecutionIds = new ArrayList<>();
|
||||
// 2. 给当前要被退回的 task 数组,设置退回意见
|
||||
boolean isSuperAdmin = isSuperAdmin(userId);
|
||||
String reasonPrefix = isSuperAdmin ? "【管理员操作】" : "";
|
||||
taskList.forEach(task -> {
|
||||
// 需要排除掉,不需要设置退回意见的任务
|
||||
if (!returnTaskKeyList.contains(task.getTaskDefinitionKey())) {
|
||||
@@ -910,7 +976,7 @@ public class BpmTaskServiceImpl implements BpmTaskService {
|
||||
// 2.1.2 更新 task 状态 + 原因
|
||||
updateTaskStatusAndReason(task.getId(), BpmTaskStatusEnum.RETURN.getStatus(), reqVO.getReason());
|
||||
} else { // 情况二:别人的任务,进行 CANCEL 标记
|
||||
processTaskCanceled(task.getId());
|
||||
processTaskCanceled(task.getId(), reasonPrefix + reqVO.getReason());
|
||||
}
|
||||
});
|
||||
|
||||
@@ -931,7 +997,7 @@ public class BpmTaskServiceImpl implements BpmTaskService {
|
||||
public void delegateTask(Long userId, BpmTaskDelegateReqVO reqVO) {
|
||||
String taskId = reqVO.getId();
|
||||
// 1.1 校验任务
|
||||
Task task = validateTask(userId, reqVO.getId());
|
||||
Task task = validateTask(userId, reqVO.getId(), false);
|
||||
if (task.getAssignee().equals(reqVO.getDelegateUserId().toString())) { // 校验当前审批人和被委派人不是同一人
|
||||
throw exception(TASK_DELEGATE_FAIL_USER_REPEAT);
|
||||
}
|
||||
@@ -957,7 +1023,7 @@ public class BpmTaskServiceImpl implements BpmTaskService {
|
||||
public void transferTask(Long userId, BpmTaskTransferReqVO reqVO) {
|
||||
String taskId = reqVO.getId();
|
||||
// 1.1 校验任务
|
||||
Task task = validateTask(userId, reqVO.getId());
|
||||
Task task = validateTask(userId, reqVO.getId(), true);
|
||||
if (task.getAssignee().equals(reqVO.getAssigneeUserId().toString())) { // 校验当前审批人和被转派人不是同一人
|
||||
throw exception(TASK_TRANSFER_FAIL_USER_REPEAT);
|
||||
}
|
||||
@@ -994,7 +1060,7 @@ public class BpmTaskServiceImpl implements BpmTaskService {
|
||||
if (BpmTaskStatusEnum.isEndStatus(otherTaskStatus)) {
|
||||
return;
|
||||
}
|
||||
processTaskCanceled(task.getId());
|
||||
processTaskCanceled(task.getId(), null);
|
||||
});
|
||||
|
||||
// 2. 终止流程
|
||||
@@ -1066,7 +1132,7 @@ public class BpmTaskServiceImpl implements BpmTaskService {
|
||||
* @return 当前任务
|
||||
*/
|
||||
private TaskEntityImpl validateTaskCanCreateSign(Long userId, BpmTaskSignCreateReqVO reqVO) {
|
||||
TaskEntityImpl taskEntity = (TaskEntityImpl) validateTask(userId, reqVO.getId());
|
||||
TaskEntityImpl taskEntity = (TaskEntityImpl) validateTask(userId, reqVO.getId(), false);
|
||||
// 向前加签和向后加签不能同时存在
|
||||
if (taskEntity.getScopeType() != null
|
||||
&& ObjectUtil.notEqual(taskEntity.getScopeType(), reqVO.getType())) {
|
||||
@@ -1217,7 +1283,7 @@ public class BpmTaskServiceImpl implements BpmTaskService {
|
||||
}
|
||||
|
||||
// 2. 任务前置通知
|
||||
if (ObjUtil.isNotNull(processDefinitionInfo.getTaskBeforeTriggerSetting())){
|
||||
if (ObjUtil.isNotNull(processDefinitionInfo.getTaskBeforeTriggerSetting())) {
|
||||
BpmModelMetaInfoVO.HttpRequestSetting setting = processDefinitionInfo.getTaskBeforeTriggerSetting();
|
||||
BpmHttpRequestUtils.executeBpmHttpRequest(processInstance,
|
||||
setting.getUrl(), setting.getHeader(), setting.getBody(), true, setting.getResponse());
|
||||
@@ -1281,7 +1347,7 @@ public class BpmTaskServiceImpl implements BpmTaskService {
|
||||
* 2. 审批不通过:在 {@link #rejectTask(Long, BpmTaskRejectReqVO)} 不通过时,对于加签的任务,不会被 Flowable 删除,此时需要通过该方法更新状态为已取消
|
||||
*/
|
||||
@Override
|
||||
public void processTaskCanceled(String taskId) {
|
||||
public void processTaskCanceled(String taskId, String reason) {
|
||||
Task task = getTask(taskId);
|
||||
// 1. 可能只是活动,不是任务,所以查询不到
|
||||
if (task == null) {
|
||||
@@ -1295,7 +1361,7 @@ public class BpmTaskServiceImpl implements BpmTaskService {
|
||||
log.error("[updateTaskStatusWhenCanceled][taskId({}) 处于结果({}),无需进行更新]", taskId, status);
|
||||
return;
|
||||
}
|
||||
updateTaskStatusAndReason(taskId, BpmTaskStatusEnum.CANCEL.getStatus(), BpmReasonEnum.CANCEL_BY_SYSTEM.getReason());
|
||||
updateTaskStatusAndReason(taskId, BpmTaskStatusEnum.CANCEL.getStatus(), StringUtils.isNotBlank(reason) ? reason : BpmReasonEnum.CANCEL_BY_SYSTEM.getReason());
|
||||
// 补充说明:由于 Task 被删除成 HistoricTask 后,无法通过 taskService.addComment 添加理由,所以无法存储具体的取消理由
|
||||
}
|
||||
|
||||
@@ -1344,7 +1410,7 @@ public class BpmTaskServiceImpl implements BpmTaskService {
|
||||
.taskVariableValueEquals(BpmnVariableConstants.TASK_VARIABLE_STATUS, BpmTaskStatusEnum.APPROVE.getStatus())
|
||||
.finished();
|
||||
if (BpmAutoApproveTypeEnum.APPROVE_ALL.getType().equals(processDefinitionInfo.getAutoApprovalType())
|
||||
&& sameAssigneeQuery.count() > 0) {
|
||||
&& sameAssigneeQuery.count() > 0) {
|
||||
getSelf().approveTask(Long.valueOf(task.getAssignee()), new BpmTaskApproveReqVO().setId(task.getId())
|
||||
.setReason(BpmAutoApproveTypeEnum.APPROVE_ALL.getName()));
|
||||
return;
|
||||
@@ -1356,7 +1422,7 @@ public class BpmTaskServiceImpl implements BpmTaskService {
|
||||
return;
|
||||
}
|
||||
List<String> sourceTaskIds = convertList(BpmnModelUtils.getElementIncomingFlows( // 获取所有上一个节点
|
||||
BpmnModelUtils.getFlowElementById(bpmnModel, task.getTaskDefinitionKey())),
|
||||
BpmnModelUtils.getFlowElementById(bpmnModel, task.getTaskDefinitionKey())),
|
||||
SequenceFlow::getSourceRef);
|
||||
if (sameAssigneeQuery.taskDefinitionKeys(sourceTaskIds).count() > 0) {
|
||||
getSelf().approveTask(Long.valueOf(task.getAssignee()), new BpmTaskApproveReqVO().setId(task.getId())
|
||||
@@ -1451,7 +1517,7 @@ public class BpmTaskServiceImpl implements BpmTaskService {
|
||||
}
|
||||
|
||||
// 任务后置通知
|
||||
if (ObjUtil.isNotNull(processDefinitionInfo.getTaskAfterTriggerSetting())){
|
||||
if (ObjUtil.isNotNull(processDefinitionInfo.getTaskAfterTriggerSetting())) {
|
||||
BpmModelMetaInfoVO.HttpRequestSetting setting = processDefinitionInfo.getTaskAfterTriggerSetting();
|
||||
BpmHttpRequestUtils.executeBpmHttpRequest(processInstance,
|
||||
setting.getUrl(), setting.getHeader(), setting.getBody(), true, setting.getResponse());
|
||||
|
||||
Reference in New Issue
Block a user