提交 f832715e 编写于 作者: zhouweidong's avatar zhouweidong

同步动态版工作流能力:

1、支持流程启动表单、流程辅助功能表单配置。
2、支持工作流超时配置。
3、支持流程版本启用配置。
4、优化计算待办任务处理页逻辑。
5、支持流程跳转、流程重启、流程撤回。
上级 77a4786c
...@@ -5,19 +5,18 @@ import cn.ibizlab.core.workflow.extensions.domain.FlowUser; ...@@ -5,19 +5,18 @@ import cn.ibizlab.core.workflow.extensions.domain.FlowUser;
import cn.ibizlab.core.workflow.extensions.service.WFCoreService; import cn.ibizlab.core.workflow.extensions.service.WFCoreService;
import cn.ibizlab.core.workflow.extensions.service.WFModelService; import cn.ibizlab.core.workflow.extensions.service.WFModelService;
import cn.ibizlab.util.errors.BadRequestAlertException; import cn.ibizlab.util.errors.BadRequestAlertException;
import cn.ibizlab.util.security.AuthenticationUser;
import cn.ibizlab.util.service.RemoteService; import cn.ibizlab.util.service.RemoteService;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.flowable.bpmn.model.FormProperty; import org.flowable.bpmn.model.FormProperty;
import org.flowable.bpmn.model.UserTask; import org.flowable.bpmn.model.UserTask;
import org.flowable.common.engine.api.delegate.event.AbstractFlowableEventListener; import org.flowable.common.engine.api.delegate.event.*;
import org.flowable.common.engine.api.delegate.event.FlowableEngineEventType;
import org.flowable.common.engine.api.delegate.event.FlowableEvent;
import org.flowable.common.engine.api.delegate.event.FlowableEventType;
import org.flowable.common.engine.impl.event.FlowableEntityEventImpl; import org.flowable.common.engine.impl.event.FlowableEntityEventImpl;
import org.flowable.engine.TaskService; import org.flowable.engine.TaskService;
import org.flowable.engine.delegate.DelegateExecution; import org.flowable.engine.delegate.DelegateExecution;
import org.flowable.engine.delegate.event.FlowableProcessEngineEvent;
import org.flowable.engine.delegate.event.impl.FlowableActivityEventImpl; import org.flowable.engine.delegate.event.impl.FlowableActivityEventImpl;
import org.flowable.engine.delegate.event.impl.FlowableEntityWithVariablesEventImpl; import org.flowable.engine.delegate.event.impl.FlowableEntityWithVariablesEventImpl;
import org.flowable.engine.delegate.event.impl.FlowableMultiInstanceActivityEventImpl; import org.flowable.engine.delegate.event.impl.FlowableMultiInstanceActivityEventImpl;
...@@ -25,9 +24,11 @@ import org.flowable.engine.delegate.event.impl.FlowableProcessStartedEventImpl; ...@@ -25,9 +24,11 @@ import org.flowable.engine.delegate.event.impl.FlowableProcessStartedEventImpl;
import org.flowable.engine.impl.persistence.entity.ExecutionEntityImpl; import org.flowable.engine.impl.persistence.entity.ExecutionEntityImpl;
import org.flowable.identitylink.api.IdentityLinkType; import org.flowable.identitylink.api.IdentityLinkType;
import org.flowable.identitylink.service.impl.persistence.entity.IdentityLinkEntity; import org.flowable.identitylink.service.impl.persistence.entity.IdentityLinkEntity;
import org.flowable.job.service.impl.persistence.entity.JobEntity;
import org.flowable.task.api.Task; import org.flowable.task.api.Task;
import org.flowable.task.service.impl.persistence.entity.TaskEntity; import org.flowable.task.service.impl.persistence.entity.TaskEntity;
import org.flowable.task.service.impl.persistence.entity.TaskEntityImpl; import org.flowable.task.service.impl.persistence.entity.TaskEntityImpl;
import org.flowable.ui.common.service.exception.BadRequestException;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy; import org.springframework.context.annotation.Lazy;
import org.springframework.context.expression.MapAccessor; import org.springframework.context.expression.MapAccessor;
...@@ -46,7 +47,6 @@ import java.util.*; ...@@ -46,7 +47,6 @@ import java.util.*;
@Component @Component
public class ProcessInstanceListener extends AbstractFlowableEventListener { public class ProcessInstanceListener extends AbstractFlowableEventListener {
@Autowired @Autowired
@Lazy @Lazy
private WFModelService wfModelService; private WFModelService wfModelService;
...@@ -138,7 +138,7 @@ public class ProcessInstanceListener extends AbstractFlowableEventListener { ...@@ -138,7 +138,7 @@ public class ProcessInstanceListener extends AbstractFlowableEventListener {
} }
} }
} }
else if (evt instanceof org.flowable.engine.delegate.event.impl.FlowableMultiInstanceActivityEventImpl){ else if (evt instanceof FlowableMultiInstanceActivityEventImpl){
try { try {
FlowableMultiInstanceActivityEventImpl event = (FlowableMultiInstanceActivityEventImpl) evt; FlowableMultiInstanceActivityEventImpl event = (FlowableMultiInstanceActivityEventImpl) evt;
// 多实例(会签) // 多实例(会签)
...@@ -319,7 +319,6 @@ public class ProcessInstanceListener extends AbstractFlowableEventListener { ...@@ -319,7 +319,6 @@ public class ProcessInstanceListener extends AbstractFlowableEventListener {
String token=curUser.getToken(); String token=curUser.getToken();
remoteService.getClient(cloudServiceid).put(entity + "/" + businessKey, token,callbackArg); remoteService.getClient(cloudServiceid).put(entity + "/" + businessKey, token,callbackArg);
} }
System.out.println("流程结束");
} }
} }
...@@ -395,6 +394,52 @@ public class ProcessInstanceListener extends AbstractFlowableEventListener { ...@@ -395,6 +394,52 @@ public class ProcessInstanceListener extends AbstractFlowableEventListener {
} }
} }
} }
//超时处理
else if (evt instanceof FlowableEngineEntityEvent && FlowableEngineEventType.TIMER_FIRED == evt.getType()) {
FlowableEngineEntityEvent event = (FlowableEngineEntityEvent) evt;
if(event.getEntity() == null || !(event.getEntity() instanceof JobEntity)){
throw new BadRequestException("执行工作流超时发生错误,超时作业参数格式不正确");
}
JobEntity jobEntity = (JobEntity) event.getEntity();
String strTenantId = jobEntity.getTenantId();
if(StringUtils.isEmpty(strTenantId)){
throw new BadRequestException(String.format("执行超时作业[%s]发生异常,超时作业未配置租户标识",jobEntity.getId()));
}
DelegateExecution delegateExecution = getDelegateExecution(event, false);
Object systemId = delegateExecution.getVariable("system");
if(ObjectUtils.isEmpty(systemId)){
throw new BadRequestException("执行超时作业[%s]发生异常,未能从流程实例变量中获取系统标识",jobEntity.getId());
}
//构造超时用户身份
AuthenticationUser user = AuthenticationUser.setAuthenticationUser("SYSTEM","内置用户");
user.setSrfsystemid(systemId.toString());
user.setSrfdcid(strTenantId);
}
}
/**
* 获取流程执行器
* @param evt
* @param bTryMode
* @return
*/
protected DelegateExecution getDelegateExecution(FlowableEvent evt, boolean bTryMode) {
DelegateExecution delegateExecution = null;
if (evt instanceof FlowableProcessEngineEvent) {
delegateExecution = ((FlowableProcessEngineEvent) evt).getExecution();
if (delegateExecution != null) {
return delegateExecution;
}
}
if(bTryMode) {
return null;
}
throw new BadRequestException(String.format("上下文执行对象无效"));
} }
@Override @Override
...@@ -402,5 +447,4 @@ public class ProcessInstanceListener extends AbstractFlowableEventListener { ...@@ -402,5 +447,4 @@ public class ProcessInstanceListener extends AbstractFlowableEventListener {
return true; return true;
} }
} }
\ No newline at end of file
...@@ -297,7 +297,7 @@ public class WFCoreResource ...@@ -297,7 +297,7 @@ public class WFCoreResource
if(StringUtils.isEmpty(path)) if(StringUtils.isEmpty(path))
throw new BadRequestAlertException("未找到待办任务处理页","",""); throw new BadRequestAlertException("未找到待办任务处理页","","");
return ResponseEntity.status(HttpStatus.MOVED_PERMANENTLY).header(HttpHeaders.LOCATION, path).build(); return ResponseEntity.status(HttpStatus.OK).body(path);
} }
@RequestMapping(method = RequestMethod.POST, value = "/deploybpmn") @RequestMapping(method = RequestMethod.POST, value = "/deploybpmn")
...@@ -305,6 +305,27 @@ public class WFCoreResource ...@@ -305,6 +305,27 @@ public class WFCoreResource
return ResponseEntity.status(HttpStatus.OK).body(wfCoreService.wfdeploybpmns(bpmnfiles)); return ResponseEntity.status(HttpStatus.OK).body(wfCoreService.wfdeploybpmns(bpmnfiles));
} }
@ApiOperation(value = "withDraw", tags = {"withDraw" }, notes = "根据实例将流程撤回前一步")
@RequestMapping(method = RequestMethod.POST, value = "/{system}-app-{appname}/{entity}/{businessKey}/tasks/{taskId}/withdraw")
public ResponseEntity<Boolean> withDraw(@PathVariable("taskId") String taskId ,@RequestBody WFTaskWay taskWay){
return ResponseEntity.ok(wfCoreService.withDraw(taskId , taskWay));
}
@ApiOperation(value = "dataAccessMode", tags = {"流程跳转" }, notes = "流程跳转")
@RequestMapping(method = RequestMethod.POST, value = "/{system}-{entity}/{businessKey}/process-instances/{processInstanceId}/jump")
public ResponseEntity<Boolean> jump(@PathVariable("processInstanceId") String processInstanceId, @RequestBody WFProcessInstance instance) {
instance.setId(processInstanceId);
return ResponseEntity.status(HttpStatus.OK).body(wfCoreService.jump(instance));
}
@ApiOperation(value = "restartwf", tags = {"重启流程" }, notes = "重启流程")
@RequestMapping(method = RequestMethod.POST, value = "/{system}-{entity}/{businessKey}/process-instances/{processInstanceId}/restart")
public ResponseEntity<Boolean> restart(@PathVariable("system") String system, @PathVariable("entity") String entity, @PathVariable("businessKey") String businessKey,
@PathVariable("processInstanceId") String processInstanceId, @RequestBody WFProcessInstance instance) {
instance.setId(processInstanceId);
return ResponseEntity.status(HttpStatus.OK).body(wfCoreService.restart(system,entity,businessKey,instance));
}
@ApiOperation(value = "前加签任务", tags = {"工作流前加签任务" } ,notes = "前加签任务") @ApiOperation(value = "前加签任务", tags = {"工作流前加签任务" } ,notes = "前加签任务")
@RequestMapping(method = RequestMethod.POST, value = "/{system}-app-{appname}/{entity}/{businessKey}/tasks/{taskId}/beforesign") @RequestMapping(method = RequestMethod.POST, value = "/{system}-app-{appname}/{entity}/{businessKey}/tasks/{taskId}/beforesign")
public ResponseEntity<Boolean> beforeSign(@PathVariable("system") String system,@PathVariable("appname") String appname, public ResponseEntity<Boolean> beforeSign(@PathVariable("system") String system,@PathVariable("appname") String appname,
...@@ -314,15 +335,22 @@ public class WFCoreResource ...@@ -314,15 +335,22 @@ public class WFCoreResource
return ResponseEntity.status(HttpStatus.OK).body(wfCoreService.beforeSign(system,appname,entity,businessKey,taskId,taskWay)); return ResponseEntity.status(HttpStatus.OK).body(wfCoreService.beforeSign(system,appname,entity,businessKey,taskId,taskWay));
} }
@ApiOperation(value = "后加签任务", tags = {"工作流后加签任务" }, notes = "前加签任务") @ApiOperation(value = "转办任务", tags = {"工作流转办任务" }, notes = "转办任务")
@RequestMapping(method = RequestMethod.POST, value = "/{system}-app-{appname}/{entity}/{businessKey}/tasks/{taskId}/transfer") @RequestMapping(method = RequestMethod.POST, value = "/{system}-app-{appname}/{entity}/{businessKey}/tasks/{taskId}/transfer")
public ResponseEntity<Boolean> afterSign(@PathVariable("system") String system,@PathVariable("appname") String appname, public ResponseEntity<Boolean> reassign(@PathVariable("system") String system,@PathVariable("appname") String appname,
@PathVariable("entity") String entity, @PathVariable("entity") String entity,
@PathVariable("businessKey") String businessKey,@PathVariable("taskId") String taskId, @PathVariable("businessKey") String businessKey,@PathVariable("taskId") String taskId,
@RequestBody WFTaskWay taskWay) { @RequestBody WFTaskWay taskWay) {
return ResponseEntity.status(HttpStatus.OK).body(wfCoreService.afterSign(system,appname,entity,businessKey,taskId,taskWay)); return ResponseEntity.status(HttpStatus.OK).body(wfCoreService.reassign(system,appname,entity,businessKey,taskId,taskWay));
} }
@ApiOperation(value = "将文件抄送给选定人员", tags = {"将文件抄送给选定人员" } ,notes = "将文件抄送给选定人员")
@RequestMapping(method = RequestMethod.POST, value = "/{system}-app-{appname}/{entity}/{businessKey}/tasks/{taskId}/sendcopy")
public ResponseEntity<Boolean> sendCopy(@PathVariable("taskId") String taskId,@RequestBody WFTaskWay taskWay) {
return ResponseEntity.status(HttpStatus.OK).body(wfCoreService.sendCopy(taskId,taskWay));
}
/** /**
* 将流程表单设置到响应头中 * 将流程表单设置到响应头中
*/ */
......
...@@ -6,13 +6,17 @@ package cn.ibizlab.util.enums; ...@@ -6,13 +6,17 @@ package cn.ibizlab.util.enums;
public enum ProcFunction { public enum ProcFunction {
SENDBACK("sendback","退回"), SENDBACK("sendback","退回"),
WITHDRAW("withdraw","撤回"),
SUPPLYINFO("supplyinfo","补充信息"), SUPPLYINFO("supplyinfo","补充信息"),
ADDSTEPBEFORE("addstepbefore","前加签"), ADDSTEPBEFORE("addstepbefore","前加签"),
ADDSTEPAFTER("addstepafter","后加签"), ADDSTEPAFTER("addstepafter","后加签"),
TAKEADVICE("takeadvice","征求意见"), TAKEADVICE("takeadvice","征求意见"),
SENDCOPY("sendcopy","抄送"), SENDCOPY("sendcopy","抄送"),
TRANSFER("transfer","转办"), REASSIGN("reassign","转办"),
FINISH("finish","完成"); FINISH("finish","完成"),
JUMP("jump","跳转"),
TIMEOUT("timeout","超时"),
RESTART("restart","重启流程");
ProcFunction(String value, String text) { ProcFunction(String value, String text) {
this.value = value; this.value = value;
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册