ProcessEngine processEngine =ProcessEngineManagement.getDefaultProcessEngine();
RuntimeService runtimeService = processEngine.getRuntimeService();
// runtimeService.getCommandExecutor().setConnection(dbgr.getConnection());
TaskService taskService = processEngine.getTaskService();
if(this.taskId!=null&&!this.taskId.equals("")){
//TaskInstance taskInstance=commandContext.getTaskManager().findTaskById(this.taskId);
ExpandTaskCommand expandTaskCommand=new ExpandTaskCommand();
expandTaskCommand.setCommandType("submit");
expandTaskCommand.setTaskComment(this.taskComment);
expandTaskCommand.setTaskId(this.taskId);
expandTaskCommand.setUserCommandId(this.userCommandId);
expandTaskCommand.setTransientVariables(transientVariables);
expandTaskCommand.setBusinessKey(businessKey);
expandTaskCommand.setInitiator(initiator);
if(this.agent!=null&&!this.agent.equals("")){
expandTaskCommand.setAgent(this.agent);
}
taskService.expandTaskComplete(expandTaskCommand, null);
return null;
}else{
StartProcessInstanceCommand startProcessInstanceCommand = new StartProcessInstanceCommand();
startProcessInstanceCommand.setProcessDefinitionKey(processDefinitionKey);
startProcessInstanceCommand.setBusinessKey(businessKey);
startProcessInstanceCommand.setStartAuthor(initiator);
startProcessInstanceCommand.setTransientVariables(transientVariables);
// startProcessInstanceCommand.setVariables(Variables);
ProcessInstance processInstanceQueryTo = runtimeService
.noneStartProcessInstance(startProcessInstanceCommand);
// 任务第一步提交完还需找到一个待办事宜再执行掉才算真正完成
String processInstanceId = processInstanceQueryTo.getId();