搭建流程控制基础
This commit is contained in:
@@ -82,6 +82,7 @@ public interface IWfProcessService {
|
||||
|
||||
/**
|
||||
* 启动流程实例
|
||||
*
|
||||
* @param procDefId 流程定义ID
|
||||
* @param variables 扩展参数
|
||||
*/
|
||||
@@ -113,4 +114,12 @@ public interface IWfProcessService {
|
||||
* @param taskId 任务ID
|
||||
*/
|
||||
WfDetailVo queryProcessDetail(String procInsId, String taskId);
|
||||
|
||||
|
||||
/**
|
||||
* 开始报销模型
|
||||
* @param variables
|
||||
* @return
|
||||
*/
|
||||
String startClaim(Map<String, Object> variables);
|
||||
}
|
||||
|
||||
@@ -607,7 +607,6 @@ public class WfProcessServiceImpl extends FlowServiceFactory implements IWfProce
|
||||
*
|
||||
* @param procDefId 流程定义Id
|
||||
* @param variables 流程变量
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@@ -615,7 +614,27 @@ public class WfProcessServiceImpl extends FlowServiceFactory implements IWfProce
|
||||
try {
|
||||
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery()
|
||||
.processDefinitionId(procDefId).singleResult();
|
||||
startProcess(processDefinition, variables);
|
||||
startProcess(processDefinition, variables);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new ServiceException("流程启动错误");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据流程定义ID启动流程实例
|
||||
*
|
||||
* @param variables 流程变量
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public String startClaim(Map<String, Object> variables) {
|
||||
try {
|
||||
|
||||
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery()
|
||||
.processDefinitionCategory("claim").singleResult();
|
||||
return startProcess(processDefinition, variables);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new ServiceException("流程启动错误");
|
||||
@@ -708,8 +727,10 @@ public class WfProcessServiceImpl extends FlowServiceFactory implements IWfProce
|
||||
|
||||
/**
|
||||
* 启动流程实例
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private void startProcess(ProcessDefinition procDef, Map<String, Object> variables) {
|
||||
private String startProcess(ProcessDefinition procDef, Map<String, Object> variables) {
|
||||
if (ObjectUtil.isNotNull(procDef) && procDef.isSuspended()) {
|
||||
throw new ServiceException("流程已被挂起,请先激活流程");
|
||||
}
|
||||
@@ -723,6 +744,7 @@ public class WfProcessServiceImpl extends FlowServiceFactory implements IWfProce
|
||||
ProcessInstance processInstance = runtimeService.startProcessInstanceById(procDef.getId(), variables);
|
||||
// 第一个用户任务为发起人,则自动完成任务
|
||||
wfTaskService.startFirstTask(processInstance, variables);
|
||||
return processInstance.getProcessInstanceId();
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user