mirror of
https://gitee.com/hhyykk/ipms-sjy.git
synced 2025-07-14 19:15:06 +08:00
Merge remote-tracking branch 'origin/develop' into develop
This commit is contained in:
@ -11,7 +11,7 @@ import lombok.Getter;
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum BpmTaskStatustEnum {
|
||||
public enum BpmTaskStatusEnum {
|
||||
|
||||
RUNNING(1, "审批中"),
|
||||
APPROVE(2, "审批通过"),
|
@ -28,10 +28,6 @@
|
||||
</dependency>
|
||||
|
||||
<!-- 业务组件 -->
|
||||
<dependency>
|
||||
<groupId>cn.iocoder.boot</groupId>
|
||||
<artifactId>yudao-spring-boot-starter-biz-operatelog</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.iocoder.boot</groupId>
|
||||
<artifactId>yudao-spring-boot-starter-biz-data-permission</artifactId>
|
||||
@ -69,6 +65,7 @@
|
||||
<groupId>cn.iocoder.boot</groupId>
|
||||
<artifactId>yudao-spring-boot-starter-excel</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Flowable 工作流相关 -->
|
||||
<dependency>
|
||||
<groupId>org.flowable</groupId>
|
||||
|
@ -93,7 +93,7 @@ public class BpmTaskController {
|
||||
@GetMapping("manager-page")
|
||||
@Operation(summary = "获取全部任务的分页", description = "用于【流程任务】菜单")
|
||||
@PreAuthorize("@ss.hasPermission('bpm:task:mananger-query')")
|
||||
public CommonResult<PageResult<BpmTaskRespVO>> getDoneTaskPage(@Valid BpmTaskPageReqVO pageVO) {
|
||||
public CommonResult<PageResult<BpmTaskRespVO>> getTaskManagerPage(@Valid BpmTaskPageReqVO pageVO) {
|
||||
PageResult<HistoricTaskInstance> pageResult = taskService.getTaskPage(getLoginUserId(), pageVO);
|
||||
if (CollUtil.isEmpty(pageResult.getList())) {
|
||||
return success(PageResult.empty());
|
||||
|
@ -53,8 +53,10 @@ public interface BpmProcessInstanceConvert {
|
||||
// user
|
||||
if (userMap != null) {
|
||||
AdminUserRespDTO startUser = userMap.get(NumberUtils.parseLong(pageResult.getList().get(i).getStartUserId()));
|
||||
respVO.setStartUser(BeanUtils.toBean(startUser, BpmProcessInstanceRespVO.User.class));
|
||||
MapUtils.findAndThen(deptMap, startUser.getDeptId(), dept -> respVO.getStartUser().setDeptName(dept.getName()));
|
||||
if (startUser != null) {
|
||||
respVO.setStartUser(BeanUtils.toBean(startUser, BpmProcessInstanceRespVO.User.class));
|
||||
MapUtils.findAndThen(deptMap, startUser.getDeptId(), dept -> respVO.getStartUser().setDeptName(dept.getName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
return vpPageResult;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package cn.iocoder.yudao.module.bpm.dal.dataobject.oa;
|
||||
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
import cn.iocoder.yudao.module.bpm.enums.task.BpmTaskStatustEnum;
|
||||
import cn.iocoder.yudao.module.bpm.enums.task.BpmTaskStatusEnum;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.*;
|
||||
@ -57,7 +57,7 @@ public class BpmOALeaveDO extends BaseDO {
|
||||
/**
|
||||
* 审批结果
|
||||
*
|
||||
* 枚举 {@link BpmTaskStatustEnum}
|
||||
* 枚举 {@link BpmTaskStatusEnum}
|
||||
* 考虑到简单,所以直接复用了 BpmProcessInstanceStatusEnum 枚举,也可以自己定义一个枚举哈
|
||||
*/
|
||||
private Integer status;
|
||||
|
@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||
import cn.iocoder.yudao.framework.datapermission.core.annotation.DataPermission;
|
||||
import cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmTaskCandidateStrategyEnum;
|
||||
import cn.iocoder.yudao.module.bpm.framework.flowable.core.util.BpmnModelUtils;
|
||||
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
||||
@ -77,6 +78,7 @@ public class BpmTaskCandidateInvoker {
|
||||
* @param execution 执行任务
|
||||
* @return 用户编号集合
|
||||
*/
|
||||
@DataPermission(enable = false) // 忽略数据权限,避免因为过滤,导致找不到候选人
|
||||
public Set<Long> calculateUsers(DelegateExecution execution) {
|
||||
Integer strategy = BpmnModelUtils.parseCandidateStrategy(execution.getCurrentFlowElement());
|
||||
String param = BpmnModelUtils.parseCandidateParam(execution.getCurrentFlowElement());
|
||||
|
@ -34,6 +34,13 @@ public class BpmTaskAssignLeaderExpression {
|
||||
@Resource
|
||||
private BpmProcessInstanceService processInstanceService;
|
||||
|
||||
/**
|
||||
* 计算审批的候选人
|
||||
*
|
||||
* @param execution 流程执行实体
|
||||
* @param level 指定级别
|
||||
* @return 指定级别的领导
|
||||
*/
|
||||
public Set<Long> calculateUsers(DelegateExecution execution, int level) {
|
||||
Assert.isTrue(level > 0, "level 必须大于 0");
|
||||
// 获得发起人
|
||||
|
@ -4,6 +4,7 @@ import cn.iocoder.yudao.framework.common.util.collection.SetUtils;
|
||||
import cn.iocoder.yudao.framework.common.util.number.NumberUtils;
|
||||
import cn.iocoder.yudao.module.bpm.service.task.BpmProcessInstanceService;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.flowable.engine.impl.persistence.entity.ExecutionEntityImpl;
|
||||
import org.flowable.engine.runtime.ProcessInstance;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@ -20,7 +21,13 @@ public class BpmTaskAssignStartUserExpression {
|
||||
@Resource
|
||||
private BpmProcessInstanceService processInstanceService;
|
||||
|
||||
public Set<Long> calculateUsers(org.flowable.engine.impl.persistence.entity.ExecutionEntityImpl execution) {
|
||||
/**
|
||||
* 计算审批的候选人
|
||||
*
|
||||
* @param execution 流程执行实体
|
||||
* @return 发起人
|
||||
*/
|
||||
public Set<Long> calculateUsers(ExecutionEntityImpl execution) {
|
||||
ProcessInstance processInstance = processInstanceService.getProcessInstance(execution.getProcessInstanceId());
|
||||
Long startUserId = NumberUtils.parseLong(processInstance.getStartUserId());
|
||||
return SetUtils.asSet(startUserId);
|
||||
|
@ -20,7 +20,7 @@ import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 监听 {@link org.flowable.task.api.Task} 的开始与完成
|
||||
* 监听 {@link Task} 的开始与完成
|
||||
*
|
||||
* @author jason
|
||||
*/
|
||||
|
@ -3,14 +3,12 @@ package cn.iocoder.yudao.module.bpm.framework.flowable.core.listener.demo.task;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.flowable.engine.delegate.TaskListener;
|
||||
import org.flowable.task.service.delegate.DelegateTask;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 类型为 class 的 TaskListener 监听器示例
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Component
|
||||
@Slf4j
|
||||
public class DemoDelegateClassTaskListener implements TaskListener {
|
||||
|
||||
|
@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.bpm.framework.flowable.core.listener.demo.task;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.flowable.task.service.delegate.DelegateTask;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 类型为 expression 的 TaskListener 监听器示例
|
||||
@ -9,6 +10,7 @@ import org.flowable.task.service.delegate.DelegateTask;
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class DemoSpringExpressionTaskListener {
|
||||
|
||||
public void notify(DelegateTask delegateTask) {
|
||||
|
@ -1,10 +1,12 @@
|
||||
package cn.iocoder.yudao.module.bpm.framework.flowable.core.util;
|
||||
|
||||
import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder;
|
||||
import cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmConstants;
|
||||
import org.flowable.common.engine.api.delegate.Expression;
|
||||
import org.flowable.common.engine.api.variable.VariableContainer;
|
||||
import org.flowable.common.engine.impl.el.ExpressionManager;
|
||||
import org.flowable.common.engine.impl.identity.Authentication;
|
||||
import org.flowable.engine.ProcessEngineConfiguration;
|
||||
import org.flowable.engine.history.HistoricProcessInstance;
|
||||
import org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl;
|
||||
import org.flowable.engine.impl.util.CommandContextUtil;
|
||||
@ -32,6 +34,11 @@ public class FlowableUtils {
|
||||
Authentication.setAuthenticatedUserId(null);
|
||||
}
|
||||
|
||||
public static String getTenantId() {
|
||||
Long tenantId = TenantContextHolder.getTenantId();
|
||||
return tenantId != null ? String.valueOf(tenantId) : ProcessEngineConfiguration.NO_TENANT_ID;
|
||||
}
|
||||
|
||||
// ========== Execution 相关的工具方法 ==========
|
||||
|
||||
/**
|
||||
|
@ -6,7 +6,6 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
|
||||
import cn.iocoder.yudao.framework.common.util.object.PageUtils;
|
||||
import cn.iocoder.yudao.framework.common.util.validation.ValidationUtils;
|
||||
import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder;
|
||||
import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.BpmModelCreateReqVO;
|
||||
import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.BpmModelPageReqVO;
|
||||
import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.BpmModelUpdateReqVO;
|
||||
@ -15,6 +14,7 @@ import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmFormDO;
|
||||
import cn.iocoder.yudao.module.bpm.enums.definition.BpmModelFormTypeEnum;
|
||||
import cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.BpmTaskCandidateInvoker;
|
||||
import cn.iocoder.yudao.module.bpm.framework.flowable.core.util.BpmnModelUtils;
|
||||
import cn.iocoder.yudao.module.bpm.framework.flowable.core.util.FlowableUtils;
|
||||
import cn.iocoder.yudao.module.bpm.service.definition.dto.BpmModelMetaInfoRespDTO;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.validation.Valid;
|
||||
@ -79,7 +79,7 @@ public class BpmModelServiceImpl implements BpmModelService {
|
||||
return PageResult.empty(count);
|
||||
}
|
||||
List<Model> models = modelQuery
|
||||
.modelTenantId(TenantContextHolder.getTenantIdStr())
|
||||
.modelTenantId(FlowableUtils.getTenantId())
|
||||
.orderByCreateTime().desc()
|
||||
.listPage(PageUtils.getStart(pageVO), pageVO.getPageSize());
|
||||
return new PageResult<>(models, count);
|
||||
@ -100,7 +100,7 @@ public class BpmModelServiceImpl implements BpmModelService {
|
||||
// 创建流程定义
|
||||
Model model = repositoryService.newModel();
|
||||
BpmModelConvert.INSTANCE.copyToCreateModel(model, createReqVO);
|
||||
model.setTenantId(TenantContextHolder.getTenantIdStr());
|
||||
model.setTenantId(FlowableUtils.getTenantId());
|
||||
// 保存流程定义
|
||||
repositoryService.saveModel(model);
|
||||
// 保存 BPMN XML
|
||||
|
@ -5,12 +5,12 @@ import cn.hutool.core.util.StrUtil;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.framework.common.util.object.PageUtils;
|
||||
import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder;
|
||||
import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.process.BpmProcessDefinitionPageReqVO;
|
||||
import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmFormDO;
|
||||
import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmProcessDefinitionInfoDO;
|
||||
import cn.iocoder.yudao.module.bpm.dal.mysql.definition.BpmProcessDefinitionInfoMapper;
|
||||
import cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmnModelConstants;
|
||||
import cn.iocoder.yudao.module.bpm.framework.flowable.core.util.FlowableUtils;
|
||||
import cn.iocoder.yudao.module.bpm.service.definition.dto.BpmModelMetaInfoRespDTO;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@ -109,7 +109,7 @@ public class BpmProcessDefinitionServiceImpl implements BpmProcessDefinitionServ
|
||||
Deployment deploy = repositoryService.createDeployment()
|
||||
.key(model.getKey()).name(model.getName()).category(model.getCategory())
|
||||
.addBytes(model.getKey() + BpmnModelConstants.BPMN_FILE_SUFFIX, bpmnBytes)
|
||||
.tenantId(TenantContextHolder.getTenantIdStr())
|
||||
.tenantId(FlowableUtils.getTenantId())
|
||||
.disableSchemaValidation() // 禁用 XML Schema 验证,因为有自定义的属性
|
||||
.deploy();
|
||||
|
||||
@ -195,7 +195,7 @@ public class BpmProcessDefinitionServiceImpl implements BpmProcessDefinitionServ
|
||||
query.active();
|
||||
}
|
||||
// 执行查询
|
||||
query.processDefinitionTenantId(TenantContextHolder.getTenantIdStr());
|
||||
query.processDefinitionTenantId(FlowableUtils.getTenantId());
|
||||
return query.list();
|
||||
}
|
||||
|
||||
|
@ -9,7 +9,7 @@ import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.BpmOALeaveCreateReqVO;
|
||||
import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.BpmOALeavePageReqVO;
|
||||
import cn.iocoder.yudao.module.bpm.dal.dataobject.oa.BpmOALeaveDO;
|
||||
import cn.iocoder.yudao.module.bpm.dal.mysql.oa.BpmOALeaveMapper;
|
||||
import cn.iocoder.yudao.module.bpm.enums.task.BpmTaskStatustEnum;
|
||||
import cn.iocoder.yudao.module.bpm.enums.task.BpmTaskStatusEnum;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@ -48,7 +48,7 @@ public class BpmOALeaveServiceImpl implements BpmOALeaveService {
|
||||
// 插入 OA 请假单
|
||||
long day = LocalDateTimeUtil.between(createReqVO.getStartTime(), createReqVO.getEndTime()).toDays();
|
||||
BpmOALeaveDO leave = BeanUtils.toBean(createReqVO, BpmOALeaveDO.class)
|
||||
.setUserId(userId).setDay(day).setStatus(BpmTaskStatustEnum.RUNNING.getStatus());
|
||||
.setUserId(userId).setDay(day).setStatus(BpmTaskStatusEnum.RUNNING.getStatus());
|
||||
leaveMapper.insert(leave);
|
||||
|
||||
// 发起 BPM 流程
|
||||
|
File diff suppressed because one or more lines are too long
@ -17,7 +17,7 @@ import cn.iocoder.yudao.module.bpm.convert.task.BpmTaskConvert;
|
||||
import cn.iocoder.yudao.module.bpm.enums.task.BpmCommentTypeEnum;
|
||||
import cn.iocoder.yudao.module.bpm.enums.task.BpmDeleteReasonEnum;
|
||||
import cn.iocoder.yudao.module.bpm.enums.task.BpmTaskSignTypeEnum;
|
||||
import cn.iocoder.yudao.module.bpm.enums.task.BpmTaskStatustEnum;
|
||||
import cn.iocoder.yudao.module.bpm.enums.task.BpmTaskStatusEnum;
|
||||
import cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmConstants;
|
||||
import cn.iocoder.yudao.module.bpm.service.definition.BpmModelService;
|
||||
import cn.iocoder.yudao.module.bpm.service.message.BpmMessageService;
|
||||
@ -134,6 +134,7 @@ public class BpmTaskServiceImpl implements BpmTaskService {
|
||||
public PageResult<HistoricTaskInstance> getTaskPage(Long userId, BpmTaskPageReqVO pageVO) {
|
||||
HistoricTaskInstanceQuery taskQuery = historyService.createHistoricTaskInstanceQuery()
|
||||
.includeTaskLocalVariables()
|
||||
.taskTenantId(FlowableUtils.getTenantId())
|
||||
.orderByHistoricTaskInstanceEndTime().desc(); // 审批时间倒序
|
||||
if (StrUtil.isNotBlank(pageVO.getName())) {
|
||||
taskQuery.taskNameLike("%" + pageVO.getName() + "%");
|
||||
@ -203,7 +204,7 @@ public class BpmTaskServiceImpl implements BpmTaskService {
|
||||
|
||||
// 情况三:审批普通的任务。大多数情况下,都是这样
|
||||
// 3.1 更新 task 状态、原因
|
||||
updateTaskStatusAndReason(task.getId(), BpmTaskStatustEnum.APPROVE.getStatus(), reqVO.getReason());
|
||||
updateTaskStatusAndReason(task.getId(), BpmTaskStatusEnum.APPROVE.getStatus(), reqVO.getReason());
|
||||
// 3.2 添加评论
|
||||
taskService.addComment(task.getId(), task.getProcessInstanceId(), BpmCommentTypeEnum.APPROVE.getType(),
|
||||
BpmCommentTypeEnum.APPROVE.formatComment(reqVO.getReason()));
|
||||
@ -231,14 +232,14 @@ public class BpmTaskServiceImpl implements BpmTaskService {
|
||||
*/
|
||||
private void approveAfterSignTask(Task task, BpmTaskApproveReqVO reqVO) {
|
||||
// 更新父 task 状态 + 原因
|
||||
updateTaskStatusAndReason(task.getId(), BpmTaskStatustEnum.APPROVING.getStatus(), reqVO.getReason());
|
||||
updateTaskStatusAndReason(task.getId(), BpmTaskStatusEnum.APPROVING.getStatus(), reqVO.getReason());
|
||||
|
||||
// 2. 激活子任务
|
||||
List<Task> childrenTaskList = getTaskListByParentTaskId(task.getId());
|
||||
for (Task childrenTask : childrenTaskList) {
|
||||
taskService.resolveTask(childrenTask.getId());
|
||||
// 更新子 task 状态
|
||||
updateTaskStatus(childrenTask.getId(), BpmTaskStatustEnum.RUNNING.getStatus());
|
||||
updateTaskStatus(childrenTask.getId(), BpmTaskStatusEnum.RUNNING.getStatus());
|
||||
}
|
||||
}
|
||||
|
||||
@ -262,7 +263,7 @@ public class BpmTaskServiceImpl implements BpmTaskService {
|
||||
// 1.2 只处理加签的父任务
|
||||
Task parentTask = validateTaskExist(parentTaskId);
|
||||
String scopeType = parentTask.getScopeType();
|
||||
if (BpmTaskSignTypeEnum.of(scopeType) == null){
|
||||
if (BpmTaskSignTypeEnum.of(scopeType) == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -276,17 +277,17 @@ public class BpmTaskServiceImpl implements BpmTaskService {
|
||||
// 3.1.1 owner 重新赋值给父任务的 assignee,这样它就可以被审批
|
||||
taskService.resolveTask(parentTaskId);
|
||||
// 3.1.2 更新流程任务 status
|
||||
updateTaskStatus(parentTaskId, BpmTaskStatustEnum.RUNNING.getStatus());
|
||||
updateTaskStatus(parentTaskId, BpmTaskStatusEnum.RUNNING.getStatus());
|
||||
// 3.2 情况二:处理向【向后】加签
|
||||
} else if (BpmTaskSignTypeEnum.AFTER.getType().equals(scopeType)) {
|
||||
// 只有 parentTask 处于 APPROVING 的情况下,才可以继续 complete 完成
|
||||
// 否则,一个未审批的 parentTask 任务,在加签出来的任务都被减签的情况下,就直接完成审批,这样会存在问题
|
||||
Integer status = (Integer) parentTask.getTaskLocalVariables().get(BpmConstants.TASK_VARIABLE_STATUS);
|
||||
if (ObjectUtil.notEqual(status, BpmTaskStatustEnum.APPROVING.getStatus())) {
|
||||
if (ObjectUtil.notEqual(status, BpmTaskStatusEnum.APPROVING.getStatus())) {
|
||||
return;
|
||||
}
|
||||
// 3.2.2 完成自己(因为它已经没有子任务,所以也可以完成)
|
||||
updateTaskStatus(parentTaskId, BpmTaskStatustEnum.APPROVE.getStatus());
|
||||
updateTaskStatus(parentTaskId, BpmTaskStatusEnum.APPROVE.getStatus());
|
||||
taskService.complete(parentTaskId);
|
||||
}
|
||||
|
||||
@ -312,7 +313,7 @@ public class BpmTaskServiceImpl implements BpmTaskService {
|
||||
// 底层调用 TaskHelper.changeTaskAssignee(task, task.getOwner()):将 owner 设置为 assignee
|
||||
taskService.resolveTask(task.getId());
|
||||
// 2.2 更新 task 状态 + 原因
|
||||
updateTaskStatusAndReason(task.getId(), BpmTaskStatustEnum.RUNNING.getStatus(), reqVO.getReason());
|
||||
updateTaskStatusAndReason(task.getId(), BpmTaskStatusEnum.RUNNING.getStatus(), reqVO.getReason());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -327,7 +328,7 @@ public class BpmTaskServiceImpl implements BpmTaskService {
|
||||
}
|
||||
|
||||
// 2.1 更新流程实例为不通过
|
||||
updateTaskStatusAndReason(task.getId(), BpmTaskStatustEnum.REJECT.getStatus(), reqVO.getReason());
|
||||
updateTaskStatusAndReason(task.getId(), BpmTaskStatusEnum.REJECT.getStatus(), reqVO.getReason());
|
||||
// 2.2 添加评论
|
||||
taskService.addComment(task.getId(), task.getProcessInstanceId(), BpmCommentTypeEnum.REJECT.getType(),
|
||||
BpmCommentTypeEnum.REJECT.formatComment(reqVO.getReason()));
|
||||
@ -379,7 +380,7 @@ public class BpmTaskServiceImpl implements BpmTaskService {
|
||||
log.error("[updateTaskStatusWhenCreated][taskId({}) 已经有状态({})]", task.getId(), status);
|
||||
return;
|
||||
}
|
||||
updateTaskStatus(task.getId(), BpmTaskStatustEnum.RUNNING.getStatus());
|
||||
updateTaskStatus(task.getId(), BpmTaskStatusEnum.RUNNING.getStatus());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -393,11 +394,11 @@ public class BpmTaskServiceImpl implements BpmTaskService {
|
||||
|
||||
// 2. 更新 task 状态 + 原因
|
||||
Integer status = (Integer) task.getTaskLocalVariables().get(BpmConstants.TASK_VARIABLE_STATUS);
|
||||
if (BpmTaskStatustEnum.isEndStatus(status)) {
|
||||
if (BpmTaskStatusEnum.isEndStatus(status)) {
|
||||
log.error("[updateTaskStatusWhenCanceled][taskId({}) 处于结果({}),无需进行更新]", taskId, status);
|
||||
return;
|
||||
}
|
||||
updateTaskStatusAndReason(taskId, BpmTaskStatustEnum.CANCEL.getStatus(), BpmDeleteReasonEnum.CANCEL_BY_SYSTEM.getReason());
|
||||
updateTaskStatusAndReason(taskId, BpmTaskStatusEnum.CANCEL.getStatus(), BpmDeleteReasonEnum.CANCEL_BY_SYSTEM.getReason());
|
||||
// 补充说明:由于 Task 被删除成 HistoricTask 后,无法通过 taskService.addComment 添加理由,所以无法存储具体的取消理由
|
||||
}
|
||||
|
||||
@ -526,7 +527,7 @@ public class BpmTaskServiceImpl implements BpmTaskService {
|
||||
taskService.addComment(task.getId(), currentTask.getProcessInstanceId(), BpmCommentTypeEnum.RETURN.getType(),
|
||||
BpmCommentTypeEnum.RETURN.formatComment(reqVO.getReason()));
|
||||
// 2.2 更新 task 状态 + 原因
|
||||
updateTaskStatusAndReason(task.getId(), BpmTaskStatustEnum.RETURN.getStatus(), reqVO.getReason());
|
||||
updateTaskStatusAndReason(task.getId(), BpmTaskStatusEnum.RETURN.getStatus(), reqVO.getReason());
|
||||
});
|
||||
|
||||
// 3. 执行驳回
|
||||
@ -563,7 +564,7 @@ public class BpmTaskServiceImpl implements BpmTaskService {
|
||||
taskService.delegateTask(taskId, reqVO.getDelegateUserId().toString());
|
||||
// 3.3 更新 task 状态。
|
||||
// 为什么不更新原因?因为原因目前主要给审批通过、不通过时使用
|
||||
updateTaskStatus(taskId, BpmTaskStatustEnum.DELEGATE.getStatus());
|
||||
updateTaskStatus(taskId, BpmTaskStatusEnum.DELEGATE.getStatus());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -617,7 +618,7 @@ public class BpmTaskServiceImpl implements BpmTaskService {
|
||||
taskService.saveTask(taskEntity);
|
||||
// 2.6 更新 task 状态为 WAIT,只有在向前加签的时候
|
||||
if (reqVO.getType().equals(BpmTaskSignTypeEnum.BEFORE.getType())) {
|
||||
updateTaskStatus(taskEntity.getId(), BpmTaskStatustEnum.WAIT.getStatus());
|
||||
updateTaskStatus(taskEntity.getId(), BpmTaskStatusEnum.WAIT.getStatus());
|
||||
}
|
||||
|
||||
// 3. 创建加签任务
|
||||
@ -704,7 +705,7 @@ public class BpmTaskServiceImpl implements BpmTaskService {
|
||||
|
||||
// 3. 向后前签,设置子任务的状态为 WAIT,因为需要等父任务审批完
|
||||
if (BpmTaskSignTypeEnum.AFTER.getType().equals(parentTask.getScopeType())) {
|
||||
updateTaskStatus(task.getId(), BpmTaskStatustEnum.WAIT.getStatus());
|
||||
updateTaskStatus(task.getId(), BpmTaskStatusEnum.WAIT.getStatus());
|
||||
}
|
||||
}
|
||||
|
||||
@ -728,8 +729,8 @@ public class BpmTaskServiceImpl implements BpmTaskService {
|
||||
childTaskList.add(task);
|
||||
// 2.2 更新子任务为已取消
|
||||
String cancelReason = StrUtil.format("任务被取消,原因:由于[{}]操作[减签],", cancelUser.getNickname());
|
||||
childTaskList.forEach(childTask -> updateTaskStatusAndReason(childTask.getId(), BpmTaskStatustEnum.CANCEL.getStatus(), cancelReason));
|
||||
// 2.2 删除任务和所有子任务
|
||||
childTaskList.forEach(childTask -> updateTaskStatusAndReason(childTask.getId(), BpmTaskStatusEnum.CANCEL.getStatus(), cancelReason));
|
||||
// 2.3 删除任务和所有子任务
|
||||
taskService.deleteTasks(convertList(childTaskList, Task::getId));
|
||||
|
||||
// 3. 记录日志到父任务中。先记录日志是因为,通过 handleParentTask 方法之后,任务可能被完成了,并且不存在了,会报异常,所以先记录
|
||||
|
Reference in New Issue
Block a user