package org.springblade.mdm.flow.excution; import org.flowable.common.engine.impl.identity.Authentication; import org.flowable.engine.IdentityService; import org.flowable.engine.runtime.ProcessInstance; import org.springblade.core.secure.utils.AuthUtil; import org.springblade.core.tool.api.R; import org.springblade.flow.core.feign.IFlowClient; import org.springblade.flow.core.pojo.entity.BladeFlow; import org.springblade.flow.core.utils.TaskUtil; import org.springblade.mdm.flow.vo.TaskAssignVO; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.flowable.engine.RuntimeService; import java.util.HashMap; import java.util.Map; @Service("startDispatcher") public class StartDispatcher { @Autowired private IFlowClient flowClient; @Autowired private RuntimeService runtimeService; @Autowired private AutoAssignUsersService autoAssignUsersService; @Autowired private IdentityService identityService; private static final String PROCESS_KEY = "dispatch"; public void start(TaskAssignVO startVO){ Map preAssignee = autoAssignUsersService.autoAssignUsers(startVO.getProducePlanId()); Map vars = new HashMap<>(preAssignee); String businessKey = "0";//业务表key identityService.setAuthenticatedUserId(String.valueOf(AuthUtil.getUserId()));//设置流程发起人 ProcessInstance pinst = runtimeService.startProcessInstanceByKey(PROCESS_KEY,businessKey,vars); //R flowR = flowClient.startProcessInstanceByKey(PROCESS_KEY,businessKey,vars); //R flowR = flowClient.startProcessInstanceById(PROCESS_KEY,businessKey,vars); int a=1; a =2; //log.info() } }