¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.jeecg.modules.flowable.service.impl; |
| | | |
| | | import cn.hutool.core.bean.BeanUtil; |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.collection.CollectionUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import org.apache.commons.io.IOUtils; |
| | | import org.flowable.bpmn.model.BpmnModel; |
| | | import org.flowable.bpmn.model.UserTask; |
| | | import org.flowable.engine.ProcessEngineConfiguration; |
| | | import org.flowable.engine.history.HistoricActivityInstance; |
| | | import org.flowable.engine.repository.Deployment; |
| | | import org.flowable.engine.repository.ProcessDefinition; |
| | | import org.flowable.engine.repository.ProcessDefinitionQuery; |
| | | import org.flowable.engine.runtime.ProcessInstance; |
| | | import org.flowable.image.ProcessDiagramGenerator; |
| | | import org.flowable.image.impl.DefaultProcessDiagramGenerator; |
| | | import org.flowable.task.api.Task; |
| | | import org.jeecg.common.api.vo.Result; |
| | | import org.jeecg.common.util.SpringContextUtils; |
| | | import org.jeecg.modules.flowable.apithird.business.entity.FlowMyBusiness; |
| | | import org.jeecg.modules.flowable.apithird.business.service.impl.FlowMyBusinessServiceImpl; |
| | | import org.jeecg.modules.flowable.apithird.common.constant.ProcessConstants; |
| | | import org.jeecg.modules.flowable.apithird.common.enums.FlowComment; |
| | | import org.jeecg.modules.flowable.apithird.entity.SysUser; |
| | | import org.jeecg.modules.flowable.apithird.service.FlowCallBackServiceI; |
| | | import org.jeecg.modules.flowable.apithird.service.IFlowThirdService; |
| | | import org.jeecg.modules.flowable.domain.dto.FlowNextDto; |
| | | import org.jeecg.modules.flowable.domain.dto.FlowProcDefDto; |
| | | import org.jeecg.modules.flowable.factory.FlowServiceFactory; |
| | | import org.jeecg.modules.flowable.service.IFlowDefinitionService; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.io.IOException; |
| | | import java.io.InputStream; |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * æµç¨å®ä¹ |
| | | */ |
| | | @Service |
| | | public class FlowDefinitionServiceImpl extends FlowServiceFactory implements IFlowDefinitionService { |
| | | @Autowired |
| | | IFlowThirdService iFlowThirdService; |
| | | @Autowired |
| | | FlowMyBusinessServiceImpl flowMyBusinessService; |
| | | @Autowired |
| | | FlowTaskServiceImpl flowTaskService; |
| | | |
| | | private static final String BPMN_FILE_SUFFIX = ".bpmn"; |
| | | |
| | | @Override |
| | | public boolean exist(String processDefinitionKey) { |
| | | ProcessDefinitionQuery processDefinitionQuery |
| | | = repositoryService.createProcessDefinitionQuery().processDefinitionKey(processDefinitionKey); |
| | | long count = processDefinitionQuery.count(); |
| | | return count > 0; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * æµç¨å®ä¹å表 |
| | | * |
| | | * @param pageNum å½å页ç |
| | | * @param pageSize æ¯é¡µæ¡æ° |
| | | * @param flowProcDefDto |
| | | * @return æµç¨å®ä¹å页åè¡¨æ°æ® |
| | | */ |
| | | @Override |
| | | public Page<FlowProcDefDto> list(Integer pageNum, Integer pageSize, FlowProcDefDto flowProcDefDto) { |
| | | Page<FlowProcDefDto> page = new Page<>(); |
| | | // æµç¨å®ä¹åè¡¨æ°æ®æ¥è¯¢ |
| | | ProcessDefinitionQuery processDefinitionQuery = repositoryService.createProcessDefinitionQuery(); |
| | | processDefinitionQuery |
| | | //.processDefinitionId("cs:5:15e953ed-4d09-11ec-85b8-e884a5deddfc") |
| | | .orderByProcessDefinitionKey().asc().orderByProcessDefinitionVersion().desc(); |
| | | /*=====åæ°=====*/ |
| | | if (StrUtil.isNotBlank(flowProcDefDto.getName())) { |
| | | processDefinitionQuery.processDefinitionNameLike("%" + flowProcDefDto.getName() + "%"); |
| | | } |
| | | if (StrUtil.isNotBlank(flowProcDefDto.getCategory())) { |
| | | processDefinitionQuery.processDefinitionCategory(flowProcDefDto.getCategory()); |
| | | } |
| | | if (flowProcDefDto.getSuspensionState() == 1) { |
| | | processDefinitionQuery.active(); |
| | | } |
| | | if (StrUtil.isNotBlank(flowProcDefDto.getKey())) { |
| | | processDefinitionQuery.processDefinitionKey(flowProcDefDto.getKey()); |
| | | } |
| | | if (flowProcDefDto.getIsLastVersion() == 1) { |
| | | processDefinitionQuery.latestVersion(); |
| | | } |
| | | /*============*/ |
| | | page.setTotal(processDefinitionQuery.count()); |
| | | List<ProcessDefinition> processDefinitionList = processDefinitionQuery.listPage((pageNum - 1) * pageSize, pageSize); |
| | | |
| | | List<FlowProcDefDto> dataList = new ArrayList<>(); |
| | | for (ProcessDefinition processDefinition : processDefinitionList) { |
| | | String deploymentId = processDefinition.getDeploymentId(); |
| | | Deployment deployment = repositoryService.createDeploymentQuery().deploymentId(deploymentId).singleResult(); |
| | | FlowProcDefDto reProcDef = new FlowProcDefDto(); |
| | | BeanUtils.copyProperties(processDefinition, reProcDef); |
| | | // æµç¨å®ä¹æ¶é´ |
| | | reProcDef.setDeploymentTime(deployment.getDeploymentTime()); |
| | | dataList.add(reProcDef); |
| | | } |
| | | page.setRecords(dataList); |
| | | return page; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 导å
¥æµç¨æä»¶ |
| | | * |
| | | * @param name |
| | | * @param category |
| | | * @param in |
| | | */ |
| | | @Override |
| | | public void importFile(String name, String category, InputStream in) { |
| | | Deployment deploy = repositoryService.createDeployment().addInputStream(name + BPMN_FILE_SUFFIX, in).name(name).category(category).deploy(); |
| | | ProcessDefinition definition = repositoryService.createProcessDefinitionQuery().deploymentId(deploy.getId()).singleResult(); |
| | | repositoryService.setProcessDefinitionCategory(definition.getId(), category); |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 读åxml |
| | | * |
| | | * @param deployId |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Result readXml(String deployId) throws IOException { |
| | | ProcessDefinition definition = repositoryService.createProcessDefinitionQuery().deploymentId(deployId).singleResult(); |
| | | InputStream inputStream = repositoryService.getResourceAsStream(definition.getDeploymentId(), definition.getResourceName()); |
| | | String result = IOUtils.toString(inputStream, StandardCharsets.UTF_8); |
| | | return Result.OK("", result); |
| | | } |
| | | |
| | | @Override |
| | | public Result readXmlByDataId(String dataId) throws IOException { |
| | | LambdaQueryWrapper<FlowMyBusiness> flowMyBusinessLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | flowMyBusinessLambdaQueryWrapper.eq(FlowMyBusiness::getDataId, dataId) |
| | | ; |
| | | //妿ä¿åæ°æ®åæªè°ç¨å¿
è°çFlowCommonService.initActBusinessæ¹æ³ï¼å°±ä¼æé®é¢ |
| | | FlowMyBusiness business = flowMyBusinessService.getOne(flowMyBusinessLambdaQueryWrapper); |
| | | ProcessDefinition definition = repositoryService.createProcessDefinitionQuery().processDefinitionId(business.getProcessDefinitionId()).singleResult(); |
| | | InputStream inputStream = repositoryService.getResourceAsStream(definition.getDeploymentId(), definition.getResourceName()); |
| | | String result = IOUtils.toString(inputStream, StandardCharsets.UTF_8); |
| | | return Result.OK("", result); |
| | | } |
| | | |
| | | /** |
| | | * 读åxml æ ¹æ®ä¸å¡Id |
| | | * |
| | | * @param dataId |
| | | * @return |
| | | */ |
| | | @Override |
| | | public InputStream readImageByDataId(String dataId) { |
| | | FlowMyBusiness business = flowMyBusinessService.getByDataId(dataId); |
| | | |
| | | String processId = business.getProcessInstanceId(); |
| | | ProcessInstance pi = runtimeService.createProcessInstanceQuery().processInstanceId(processId).singleResult(); |
| | | //æµç¨èµ°å®ç æ¾ç¤ºå
¨å¾ |
| | | if (pi == null) { |
| | | ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionId(business.getProcessDefinitionId()).singleResult(); |
| | | return this.readImage(processDefinition.getDeploymentId()); |
| | | } |
| | | |
| | | List<HistoricActivityInstance> historyProcess = historyService.createHistoricActivityInstanceQuery() |
| | | .processInstanceId(processId).list(); |
| | | List<String> activityIds = new ArrayList<>(); |
| | | List<String> flows = new ArrayList<>(); |
| | | //è·åæµç¨å¾ |
| | | BpmnModel bpmnModel = repositoryService.getBpmnModel(pi.getProcessDefinitionId()); |
| | | for (HistoricActivityInstance hi : historyProcess) { |
| | | String activityType = hi.getActivityType(); |
| | | if (activityType.equals("sequenceFlow") || activityType.equals("exclusiveGateway")) { |
| | | flows.add(hi.getActivityId()); |
| | | } else if (activityType.equals("userTask") || activityType.equals("startEvent")) { |
| | | activityIds.add(hi.getActivityId()); |
| | | } |
| | | } |
| | | List<Task> tasks = taskService.createTaskQuery().processInstanceId(processId).list(); |
| | | for (Task task : tasks) { |
| | | activityIds.add(task.getTaskDefinitionKey()); |
| | | } |
| | | ProcessEngineConfiguration engConf = processEngine.getProcessEngineConfiguration(); |
| | | //å®ä¹æµç¨ç»å¸çæå¨ |
| | | ProcessDiagramGenerator processDiagramGenerator = engConf.getProcessDiagramGenerator(); |
| | | InputStream in = processDiagramGenerator.generateDiagram(bpmnModel, "png", activityIds, flows, engConf.getActivityFontName(), engConf.getLabelFontName(), engConf.getAnnotationFontName(), engConf.getClassLoader(), 1.0, true); |
| | | return in; |
| | | } |
| | | |
| | | /** |
| | | * 读åxml |
| | | * |
| | | * @param deployId |
| | | * @return |
| | | */ |
| | | @Override |
| | | public InputStream readImage(String deployId) { |
| | | ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().deploymentId(deployId).singleResult(); |
| | | //è·å¾å¾çæµ |
| | | DefaultProcessDiagramGenerator diagramGenerator = new DefaultProcessDiagramGenerator(); |
| | | BpmnModel bpmnModel = repositoryService.getBpmnModel(processDefinition.getId()); |
| | | //è¾åºä¸ºå¾ç |
| | | return diagramGenerator.generateDiagram( |
| | | bpmnModel, |
| | | "png", |
| | | Collections.emptyList(), |
| | | Collections.emptyList(), |
| | | "å®ä½", |
| | | "å®ä½", |
| | | "å®ä½", |
| | | null, |
| | | 1.0, |
| | | false); |
| | | |
| | | } |
| | | |
| | | /** |
| | | * æ ¹æ®æµç¨å®ä¹IDå¯å¨æµç¨å®ä¾ |
| | | * |
| | | * @param procDefKey æµç¨å®ä¹Id |
| | | * @param variables æµç¨åé |
| | | * @return |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = {Exception.class}) |
| | | public Result<?> startProcessInstanceByKey(String procDefKey, Map<String, Object> variables) { |
| | | ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery() |
| | | .processDefinitionKey(procDefKey) |
| | | .latestVersion().singleResult(); |
| | | Result result = startProcessInstanceById(processDefinition.getId(), variables); |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * æ ¹æ®æµç¨å®ä¹IDå¯å¨æµç¨å®ä¾ |
| | | * |
| | | * @param procDefId æµç¨å®ä¹Id |
| | | * @param variables æµç¨åé |
| | | * @return |
| | | */ |
| | | @Override |
| | | @Transactional |
| | | public Result<?> startProcessInstanceById(String procDefId, Map<String, Object> variables) { |
| | | ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery() |
| | | .processDefinitionId(procDefId) |
| | | .singleResult(); |
| | | if (Objects.nonNull(processDefinition) && processDefinition.isSuspended()) { |
| | | return Result.error("æµç¨å·²è¢«æèµ·,请å
æ¿æ´»æµç¨"); |
| | | } |
| | | // variables.put("skip", true); |
| | | // variables.put(ProcessConstants.FLOWABLE_SKIP_EXPRESSION_ENABLED, true); |
| | | // 设置æµç¨å起人Idå°æµç¨ä¸ |
| | | SysUser sysUser = iFlowThirdService.getLoginUser(); |
| | | identityService.setAuthenticatedUserId(sysUser.getUsername()); |
| | | variables.put(ProcessConstants.PROCESS_INITIATOR, sysUser.getUsername()); |
| | | ProcessInstance processInstance = runtimeService.startProcessInstanceById(procDefId, variables); |
| | | // ç»ç¬¬ä¸æ¥ç³è¯·äººèç¹è®¾ç½®ä»»å¡æ§è¡äººåæè§ |
| | | Task task = taskService.createTaskQuery().processInstanceId(processInstance.getProcessInstanceId()).active().singleResult(); |
| | | if (Objects.nonNull(task)) { |
| | | taskService.addComment(task.getId(), processInstance.getProcessInstanceId(), FlowComment.NORMAL.getType(), variables.get("organization").toString()); |
| | | taskService.setAssignee(task.getId(), sysUser.getUsername()); |
| | | task.setDescription(variables.get("organization").toString()); |
| | | //taskService.complete(task.getId(), variables); |
| | | } |
| | | //设置ææç³è¯·äºº |
| | | |
| | | /*======================todo å¯å¨ä¹å åè°ä»¥åå
³é®æ°æ®ä¿å======================*/ |
| | | //ä¸å¡æ°æ®id |
| | | String dataId = variables.get("dataId").toString(); |
| | | //妿ä¿åæ°æ®åæªè°ç¨å¿
è°çFlowCommonService.initActBusinessæ¹æ³ï¼å°±ä¼æé®é¢ |
| | | FlowMyBusiness business = flowMyBusinessService.getByDataId(dataId); |
| | | //è®¾ç½®æ°æ® |
| | | List<FlowNextDto> nextFlowNodeList = flowTaskService.getNextFlowNode(task.getId(), variables); |
| | | taskService.complete(task.getId(), variables); |
| | | //ä¸ä¸ä¸ªå®ä¾èç¹ å¤å®ä¾ä¼æ¯ä¸ä¸ªlist,éæåä¸ä¸ªå³å¯ æ°ç»ä¸å®ä¹Keyæ¯ä¸è´ç |
| | | //Task task2 = taskService.createTaskQuery().processInstanceId(processInstance.getProcessInstanceId()).active().singleResult(); |
| | | List<Task> task2List = taskService.createTaskQuery().processInstanceId(processInstance.getProcessInstanceId()).active().list(); |
| | | String doneUsers = business.getDoneUsers(); |
| | | // å¤çè¿æµç¨ç人 |
| | | JSONArray doneUserList = new JSONArray(); |
| | | if (StrUtil.isNotBlank(doneUsers)) { |
| | | doneUserList = JSON.parseArray(doneUsers); |
| | | } |
| | | if (!doneUserList.contains(sysUser.getUsername())) { |
| | | doneUserList.add(sysUser.getUsername()); |
| | | } |
| | | |
| | | if (CollectionUtil.isEmpty(nextFlowNodeList)) { |
| | | // **没æä¸ä¸ä¸ªèç¹ï¼æµç¨å·²ç»ç»æäº |
| | | business.setProcessDefinitionId(procDefId) |
| | | .setProcessInstanceId(processInstance.getProcessInstanceId()) |
| | | // .setActStatus(ActStatus.pass) |
| | | .setProposer(sysUser.getUsername()) |
| | | .setDoneUsers(doneUserList.toJSONString()) |
| | | ; |
| | | flowMyBusinessService.updateById(business); |
| | | } else if (nextFlowNodeList.size() == 1) { |
| | | //ä¸ä¸ªèç¹åªæä¸ä¸ª |
| | | FlowNextDto nextFlowNode = nextFlowNodeList.get(0); |
| | | UserTask nextTask = nextFlowNode.getUserTask(); |
| | | Task task2 = null; |
| | | Optional<Task> first = task2List.stream().filter(t -> t.getTaskDefinitionKey().equals(nextTask.getId())).findFirst(); |
| | | if (first.isPresent()) { |
| | | task2 = first.get(); |
| | | } |
| | | if (task2 != null) { |
| | | //è½å¤å¤çä¸ä¸ªèç¹çåé人 |
| | | List<SysUser> nextFlowNodeUserList = nextFlowNode.getUserList(); |
| | | |
| | | List<String> collect_username = nextFlowNodeUserList.stream().map(SysUser::getUsername).collect(Collectors.toList()); |
| | | //spring容å¨ç±»å |
| | | String serviceImplName = business.getServiceImplName(); |
| | | FlowCallBackServiceI flowCallBackService = (FlowCallBackServiceI) SpringContextUtils.getBean(serviceImplName); |
| | | List<String> beforeParamsCandidateUsernames = flowCallBackService.flowCandidateUsernamesOfTask(task2.getTaskDefinitionId(), variables); |
| | | business.setProcessDefinitionId(procDefId) |
| | | .setProcessInstanceId(processInstance.getProcessInstanceId()) |
| | | //// .setActStatus(ActStatus.start) |
| | | .setProposer(sysUser.getUsername()) |
| | | .setTaskId(task2.getId()) |
| | | .setTaskName(nextTask.getName()) |
| | | .setTaskNameId(nextTask.getId()) |
| | | .setPriority(nextTask.getPriority()) |
| | | .setDoneUsers(doneUserList.toJSONString()); |
| | | if (CollUtil.isNotEmpty(beforeParamsCandidateUsernames)) { |
| | | // å é¤åéå |
| | | for (String oldUser : collect_username) { |
| | | taskService.deleteCandidateUser(task2.getId(), oldUser); |
| | | } |
| | | // ä¸å¡å±ææå®åé人ï¼è¦ç |
| | | for (String newUser : beforeParamsCandidateUsernames) { |
| | | taskService.addCandidateUser(task2.getId(), newUser); |
| | | } |
| | | business.setTodoUsers(JSON.toJSONString(beforeParamsCandidateUsernames)); |
| | | } else { |
| | | // ä¸å¡å±æ²¡ææå®åé人ï¼ç´æ¥è¦ç |
| | | business.setTodoUsers(JSON.toJSONString(collect_username)); |
| | | } |
| | | flowMyBusinessService.updateById(business); |
| | | } |
| | | } else { |
| | | for (FlowNextDto nextFlowNode : nextFlowNodeList) { |
| | | //**æä¸ä¸ä¸ªèç¹ |
| | | UserTask nextTask = nextFlowNode.getUserTask(); |
| | | Task task2 = null; |
| | | Optional<Task> first = task2List.stream().filter(t -> t.getTaskDefinitionKey().equals(nextTask.getId())).findFirst(); |
| | | if (first.isPresent()) { |
| | | task2 = first.get(); |
| | | } |
| | | if (task2 != null) { |
| | | //æ°çä¸å¡æµç¨èç¹ |
| | | FlowMyBusiness newBusiness = BeanUtil.copyProperties(business, FlowMyBusiness.class, "id"); |
| | | //è½å¤å¤çä¸ä¸ªèç¹çåé人 |
| | | List<SysUser> nextFlowNodeUserList = nextFlowNode.getUserList(); |
| | | |
| | | List<String> collect_username = nextFlowNodeUserList.stream().map(SysUser::getUsername).collect(Collectors.toList()); |
| | | //spring容å¨ç±»å |
| | | String serviceImplName = newBusiness.getServiceImplName(); |
| | | FlowCallBackServiceI flowCallBackService = (FlowCallBackServiceI) SpringContextUtils.getBean(serviceImplName); |
| | | List<String> beforeParamsCandidateUsernames = flowCallBackService.flowCandidateUsernamesOfTask(task2.getTaskDefinitionId(), variables); |
| | | newBusiness.setProcessDefinitionId(procDefId) |
| | | .setProcessInstanceId(processInstance.getProcessInstanceId()) |
| | | //// .setActStatus(ActStatus.start) |
| | | .setProposer(sysUser.getUsername()) |
| | | .setTaskId(task2.getId()) |
| | | .setTaskName(nextTask.getName()) |
| | | .setTaskNameId(nextTask.getId()) |
| | | .setPriority(nextTask.getPriority()) |
| | | .setDoneUsers(doneUserList.toJSONString()); |
| | | if (CollUtil.isNotEmpty(beforeParamsCandidateUsernames)) { |
| | | // å é¤åéå |
| | | for (Task task2One : task2List) { |
| | | for (String oldUser : beforeParamsCandidateUsernames) { |
| | | taskService.deleteCandidateUser(task2One.getId(), oldUser); |
| | | } |
| | | } |
| | | // ä¸å¡å±ææå®åé人ï¼è¦ç |
| | | for (Task task2One : task2List) { |
| | | for (String newUser : beforeParamsCandidateUsernames) { |
| | | taskService.addCandidateUser(task2One.getId(), newUser); |
| | | } |
| | | } |
| | | newBusiness.setTodoUsers(JSON.toJSONString(beforeParamsCandidateUsernames)); |
| | | } else { |
| | | // ä¸å¡å±æ²¡ææå®åé人ï¼ç´æ¥è¦ç |
| | | newBusiness.setTodoUsers(JSON.toJSONString(collect_username)); |
| | | // å é¤åéå |
| | | for (Task task2One : task2List) { |
| | | for (String oldUser : collect_username) { |
| | | taskService.deleteCandidateUser(task2One.getId(), oldUser); |
| | | } |
| | | } |
| | | // ä¸å¡å±ææå®åé人ï¼è¦ç |
| | | for (Task task2One : task2List) { |
| | | for (String newUser : collect_username) { |
| | | taskService.addCandidateUser(task2One.getId(), newUser); |
| | | } |
| | | } |
| | | } |
| | | flowMyBusinessService.save(newBusiness); |
| | | } |
| | | } |
| | | //å é¤åæçä¸å¡æ°æ® |
| | | flowMyBusinessService.removeById(business.getId()); |
| | | } |
| | | //spring容å¨ç±»å |
| | | String serviceImplName = business.getServiceImplName(); |
| | | FlowCallBackServiceI flowCallBackService = (FlowCallBackServiceI) SpringContextUtils.getBean(serviceImplName); |
| | | // æµç¨å¤çå®åï¼è¿è¡åè°ä¸å¡å± |
| | | business.setValues(variables); |
| | | if (flowCallBackService != null) { |
| | | flowCallBackService.afterFlowHandle(business); |
| | | } |
| | | return Result.OK("æµç¨å¯å¨æå"); |
| | | } |
| | | |
| | | @Override |
| | | public Result startProcessInstanceByDataId(String dataId, Map<String, Object> variables) { |
| | | LambdaQueryWrapper<FlowMyBusiness> flowMyBusinessLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | flowMyBusinessLambdaQueryWrapper.eq(FlowMyBusiness::getDataId, dataId) |
| | | ; |
| | | FlowMyBusiness business = flowMyBusinessService.getOne(flowMyBusinessLambdaQueryWrapper); |
| | | if (business == null) { |
| | | return Result.error("æªæ¾å°dataIdï¼" + dataId); |
| | | } |
| | | if (StrUtil.isNotBlank(business.getProcessDefinitionId())) { |
| | | return this.startProcessInstanceById(business.getProcessDefinitionId(), variables); |
| | | } |
| | | return this.startProcessInstanceByKey(business.getProcessDefinitionKey(), variables); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * æ¿æ´»ææèµ·æµç¨å®ä¹ |
| | | * |
| | | * @param state ç¶æ æ¿æ´»1 æèµ·2 |
| | | * @param deployId æµç¨é¨ç½²ID |
| | | */ |
| | | @Override |
| | | public void updateState(Integer state, String deployId) { |
| | | ProcessDefinition procDef = repositoryService.createProcessDefinitionQuery().deploymentId(deployId).singleResult(); |
| | | // æ¿æ´» |
| | | if (state == 1) { |
| | | repositoryService.activateProcessDefinitionById(procDef.getId(), true, null); |
| | | } |
| | | // æèµ· |
| | | if (state == 2) { |
| | | repositoryService.suspendProcessDefinitionById(procDef.getId(), true, null); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * å 餿µç¨å®ä¹ |
| | | * |
| | | * @param deployId æµç¨é¨ç½²ID act_ge_bytearray è¡¨ä¸ deployment_idå¼ |
| | | */ |
| | | @Override |
| | | public void delete(String deployId) { |
| | | // true å
许级èå é¤ ,ä¸è®¾ç½®ä¼å¯¼è´æ°æ®åºå¤é®å
³èå¼å¸¸ |
| | | repositoryService.deleteDeployment(deployId, true); |
| | | } |
| | | |
| | | |
| | | } |