mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-26 09:11:52 +08:00
修复 BPM Task 的 category 设置问题
This commit is contained in:
parent
9860a7d552
commit
abe161669c
@ -1,19 +1,26 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.bpm.framework.activiti;
|
||||
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.service.task.listener.BpmTackActivitiEventListener;
|
||||
import org.activiti.spring.SpringProcessEngineConfiguration;
|
||||
import org.activiti.spring.boot.ProcessEngineConfigurationConfigurer;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Collections;
|
||||
|
||||
/**
|
||||
* BPM 模块的 Activiti 配置类
|
||||
*/
|
||||
@Configuration
|
||||
public class BpmActivitiConfiguration implements ProcessEngineConfigurationConfigurer {
|
||||
|
||||
@Resource
|
||||
private BpmTackActivitiEventListener taskActivitiEventListener;
|
||||
|
||||
@Override
|
||||
public void configure(SpringProcessEngineConfiguration configuration) {
|
||||
// 注册监听器,例如说 ActivitiEventListener 的实现类
|
||||
// configuration.setEventListeners(Arrays.asList(processInstanceEventListener));
|
||||
// 注册监听器,例如说 BpmActivitiEventListener
|
||||
configuration.setEventListeners(Collections.singletonList(taskActivitiEventListener));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -64,6 +64,16 @@ public interface BpmProcessDefinitionService {
|
||||
*/
|
||||
ProcessDefinition getProcessDefinition(String id);
|
||||
|
||||
/**
|
||||
* 获得编号对应的 ProcessDefinition
|
||||
*
|
||||
* 相比 {@link #getProcessDefinition(String)} 方法,category 的取值是正确
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 流程定义
|
||||
*/
|
||||
ProcessDefinition getProcessDefinition2(String id);
|
||||
|
||||
/**
|
||||
* 获得 id 对应的 Deployment
|
||||
*
|
||||
|
@ -135,6 +135,11 @@ public class BpmProcessDefinitionServiceImpl implements BpmProcessDefinitionServ
|
||||
return repositoryService.getProcessDefinition(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProcessDefinition getProcessDefinition2(String id) {
|
||||
return repositoryService.createProcessDefinitionQuery().processDefinitionId(id).singleResult();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Deployment getDeployment(String id) {
|
||||
if (StrUtil.isEmpty(id)) {
|
||||
|
@ -1,15 +1,12 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.bpm.service.task.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.instance.BpmProcessInstanceCancelReqVO;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.instance.BpmProcessInstanceCreateReqVO;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.instance.BpmProcessInstanceMyPageReqVO;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.instance.BpmProcessInstancePageItemRespVO;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.convert.task.BpmProcessInstanceConvert;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.convert.task.BpmTaskConvert;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.task.BpmProcessInstanceExtDO;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.task.BpmTaskExtDO;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.dal.mysql.task.BpmProcessInstanceExtMapper;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.enums.task.BpmProcessInstanceDeleteReasonEnum;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.enums.task.BpmProcessInstanceResultEnum;
|
||||
@ -18,15 +15,11 @@ import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.BpmProcessDef
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.service.task.BpmProcessInstanceService;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.service.task.BpmTaskService;
|
||||
import cn.iocoder.yudao.adminserver.modules.system.service.user.SysUserService;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.user.SysUserDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.activiti.engine.HistoryService;
|
||||
import org.activiti.engine.RuntimeService;
|
||||
import org.activiti.engine.TaskService;
|
||||
import org.activiti.engine.history.HistoricProcessInstance;
|
||||
import org.activiti.engine.history.HistoricProcessInstanceQuery;
|
||||
import org.activiti.engine.repository.ProcessDefinition;
|
||||
import org.activiti.engine.runtime.ProcessInstance;
|
||||
import org.activiti.engine.task.Task;
|
||||
@ -37,7 +30,6 @@ import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.*;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import static cn.iocoder.yudao.adminserver.modules.bpm.enums.BpmErrorCodeConstants.*;
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
@ -93,9 +85,6 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService
|
||||
ProcessInstance instance = runtimeService.startProcessInstanceById(createReqVO.getProcessDefinitionId(), variables);
|
||||
// 设置流程名字
|
||||
runtimeService.setProcessInstanceName(instance.getId(), definition.getName());
|
||||
// 更新流程实例拓展表的 category TODO 芋艿:暂时没好的办法,task 的 category 不正确。另外,definition 返回的 category 也不太正确,后续在解决;
|
||||
processInstanceExtMapper.updateByProcessInstanceId(new BpmProcessInstanceExtDO()
|
||||
.setProcessInstanceId(instance.getId()).setCategory(definition.getCategory()));
|
||||
|
||||
// TODO 芋艿:临时使用, 保证分配
|
||||
List<Task> tasks = taskService.getTasksByProcessInstanceId(instance.getId());
|
||||
@ -194,7 +183,11 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService
|
||||
|
||||
@Override
|
||||
public void createProcessInstanceExt(org.activiti.api.process.model.ProcessInstance instance) {
|
||||
// 获得流程定义
|
||||
ProcessDefinition definition = processDefinitionService.getProcessDefinition2(instance.getProcessDefinitionId());
|
||||
// 插入 BpmProcessInstanceExtDO 对象
|
||||
BpmProcessInstanceExtDO instanceExtDO = BpmProcessInstanceConvert.INSTANCE.convert(instance)
|
||||
.setCategory(definition.getCategory())
|
||||
.setStatus(BpmProcessInstanceStatusEnum.RUNNING.getStatus())
|
||||
.setResult(BpmProcessInstanceResultEnum.PROCESS.getResult());
|
||||
processInstanceExtMapper.insert(instanceExtDO);
|
||||
|
@ -396,6 +396,7 @@ public class BpmTaskServiceImpl implements BpmTaskService {
|
||||
|
||||
@Override
|
||||
public void createTaskExt(org.activiti.api.task.model.Task task) {
|
||||
// 插入 BpmTaskExtDO 记录
|
||||
BpmTaskExtDO taskExtDO = BpmTaskConvert.INSTANCE.convert(task)
|
||||
.setResult(BpmProcessInstanceResultEnum.PROCESS.getResult());
|
||||
taskExtMapper.insert(taskExtDO);
|
||||
|
@ -0,0 +1,53 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.bpm.service.task.listener;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.BpmProcessDefinitionService;
|
||||
import org.activiti.api.process.runtime.events.listener.ProcessRuntimeEventListener;
|
||||
import org.activiti.api.task.runtime.events.listener.TaskEventListener;
|
||||
import org.activiti.engine.delegate.event.ActivitiEvent;
|
||||
import org.activiti.engine.delegate.event.ActivitiEventListener;
|
||||
import org.activiti.engine.delegate.event.ActivitiEventType;
|
||||
import org.activiti.engine.delegate.event.impl.ActivitiEntityEventImpl;
|
||||
import org.activiti.engine.impl.persistence.entity.TaskEntity;
|
||||
import org.activiti.engine.repository.ProcessDefinition;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* 监听 {@link TaskEntity} 相关的事件,设置相关属性。
|
||||
* 目的:解决 {@link TaskEventListener} 无法解决的场景
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Component
|
||||
public class BpmTackActivitiEventListener implements ActivitiEventListener {
|
||||
|
||||
@Resource
|
||||
@Lazy // 解决循环依赖
|
||||
private BpmProcessDefinitionService processDefinitionService;
|
||||
|
||||
@Override
|
||||
public void onEvent(ActivitiEvent event) {
|
||||
// Task 创建时,设置其分类,解决 TaskService 未提供 name 的设置方法
|
||||
if (ActivitiEventType.TASK_CREATED == event.getType()) {
|
||||
TaskEntity task = ((TaskEntity) ((ActivitiEntityEventImpl) event).getEntity());
|
||||
if (StrUtil.isNotEmpty(task.getCategory())) {
|
||||
return;
|
||||
}
|
||||
// 设置 name
|
||||
ProcessDefinition processDefinition = processDefinitionService.getProcessDefinition2(task.getProcessDefinitionId());
|
||||
if (processDefinition == null) {
|
||||
return;
|
||||
}
|
||||
task.setCategory(processDefinition.getCategory());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFailOnException() {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
@ -46,19 +46,4 @@ public class BpmTaskEventListener<T extends TaskRuntimeEvent<? extends Task>>
|
||||
taskService.updateTaskExt(event.getEntity());
|
||||
}
|
||||
|
||||
// // Task 创建时,插入拓展表
|
||||
// if (event.getType() == ActivitiEventType.TASK_CREATED) {
|
||||
// System.out.println(event);
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// if (event.getType() == ActivitiEventType.TASK_COMPLETED) {
|
||||
// System.out.println(event);
|
||||
// // 不处理;
|
||||
// } else if (event.getType() == ActivitiEventType.ENTITY_DELETED) {
|
||||
// // 假设是
|
||||
// System.out.println(event);
|
||||
// }
|
||||
// System.out.println(event);
|
||||
|
||||
}
|
||||
|
@ -175,17 +175,8 @@ export default {
|
||||
|
||||
.my-process-designer {
|
||||
height: calc(100vh - 84px);
|
||||
//height: 800px !important; // TODO 芋艿:bjs 容器的高度不对,临时改下
|
||||
//z-index: 0 !important;
|
||||
//pointer-events: none !important;
|
||||
}
|
||||
.process-panel__container { // TODO 芋艿:右边的位置不对,临时改下
|
||||
//margin-top: -800px !important;
|
||||
//float: right;
|
||||
//margin-left: 800px !important;
|
||||
//height: 800px;
|
||||
//z-index: 2147483647 !important;
|
||||
//cursor:pointer !important;
|
||||
.process-panel__container {
|
||||
position: absolute;
|
||||
right: 0;
|
||||
top: 55px;
|
||||
|
Loading…
Reference in New Issue
Block a user