!168 update 优化流程办理监听,优化示例说明

Merge pull request !168 from May/new
2.X
疯狂的狮子Li 8 months ago committed by Gitee
commit cffe89ffab
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F

@ -18,9 +18,14 @@ public class ProcessTaskEvent implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** /**
* key(key_) * key
*/ */
private String keyNode; private String key;
/**
* key
*/
private String taskDefinitionKey;
/** /**
* id * id

@ -34,13 +34,15 @@ public class FlowProcessEventHandler {
/** /**
* *
* *
* @param keyNode key(key_) * @param key key
* @param taskId id * @param taskDefinitionKey key
* @param businessKey id * @param taskId id
* @param businessKey id
*/ */
public void processTaskHandler(String keyNode, String taskId, String businessKey) { public void processTaskHandler(String key, String taskDefinitionKey, String taskId, String businessKey) {
ProcessTaskEvent processTaskEvent = new ProcessTaskEvent(); ProcessTaskEvent processTaskEvent = new ProcessTaskEvent();
processTaskEvent.setKeyNode(keyNode); processTaskEvent.setKey(key);
processTaskEvent.setTaskDefinitionKey(taskDefinitionKey);
processTaskEvent.setTaskId(taskId); processTaskEvent.setTaskId(taskId);
processTaskEvent.setBusinessKey(businessKey); processTaskEvent.setBusinessKey(businessKey);
SpringUtils.context().publishEvent(processTaskEvent); SpringUtils.context().publishEvent(processTaskEvent);

@ -186,8 +186,8 @@ public class ActTaskServiceImpl implements IActTaskService {
} }
runtimeService.updateBusinessStatus(task.getProcessInstanceId(), BusinessStatusEnum.WAITING.getStatus()); runtimeService.updateBusinessStatus(task.getProcessInstanceId(), BusinessStatusEnum.WAITING.getStatus());
//办理监听 //办理监听
String keyNode = processInstance.getProcessDefinitionKey() + "_" + task.getTaskDefinitionKey(); flowProcessEventHandler.processTaskHandler(processInstance.getProcessDefinitionKey(), task.getTaskDefinitionKey(),
flowProcessEventHandler.processTaskHandler(keyNode, task.getId(), processInstance.getBusinessKey()); task.getId(), processInstance.getBusinessKey());
//办理意见 //办理意见
taskService.addComment(completeTaskBo.getTaskId(), task.getProcessInstanceId(), TaskStatusEnum.PASS.getStatus(), StringUtils.isBlank(completeTaskBo.getMessage()) ? "同意" : completeTaskBo.getMessage()); taskService.addComment(completeTaskBo.getTaskId(), task.getProcessInstanceId(), TaskStatusEnum.PASS.getStatus(), StringUtils.isBlank(completeTaskBo.getMessage()) ? "同意" : completeTaskBo.getMessage());
//办理任务 //办理任务

@ -136,10 +136,15 @@ public class TestLeaveServiceImpl implements ITestLeaveService {
/** /**
* *
* @EventListener(condition = "#processTaskEvent.key=='leave1'")
* key
* if ("xxx".equals(processTaskEvent.getTaskDefinitionKey())) {
* //执行业务逻辑
* }
* *
* @param processTaskEvent * @param processTaskEvent
*/ */
@EventListener(condition = "#processTaskEvent.keyNode=='leave1_Activity_14633hx'") @EventListener(condition = "#processTaskEvent.key=='leave1' && #processTaskEvent.taskDefinitionKey=='Activity_14633hx'")
public void processTaskHandler(ProcessTaskEvent processTaskEvent) { public void processTaskHandler(ProcessTaskEvent processTaskEvent) {
log.info("当前任务执行了{}", processTaskEvent.toString()); log.info("当前任务执行了{}", processTaskEvent.toString());
TestLeave testLeave = baseMapper.selectById(Long.valueOf(processTaskEvent.getBusinessKey())); TestLeave testLeave = baseMapper.selectById(Long.valueOf(processTaskEvent.getBusinessKey()));

Loading…
Cancel
Save