| | |
| | | import org.dromara.workflow.domain.WfCategory; |
| | | import org.dromara.workflow.domain.WfNodeConfig; |
| | | import org.dromara.workflow.domain.bo.ProcessDefinitionBo; |
| | | import org.dromara.workflow.domain.bo.WfDefinitionConfigBo; |
| | | import org.dromara.workflow.domain.vo.ProcessDefinitionVo; |
| | | import org.dromara.workflow.domain.vo.WfDefinitionConfigVo; |
| | | import org.dromara.workflow.service.IActProcessDefinitionService; |
| | |
| | | String processName = splitFilename[0]; |
| | | //流程key |
| | | String processKey = splitFilename[1]; |
| | | ProcessDefinition oldProcessDefinition = QueryUtils.definitionQuery().processDefinitionKey(processKey).latestVersion().singleResult(); |
| | | DeploymentBuilder builder = repositoryService.createDeployment(); |
| | | Deployment deployment = builder.addInputStream(filename, zipInputStream) |
| | | .tenantId(TenantHelper.getTenantId()) |
| | | .name(processName).key(processKey).category(categoryCode).deploy(); |
| | | ProcessDefinition definition = QueryUtils.definitionQuery().deploymentId(deployment.getId()).singleResult(); |
| | | repositoryService.setProcessDefinitionCategory(definition.getId(), categoryCode); |
| | | setForm(oldProcessDefinition, definition); |
| | | setWfNodeConfig(definition); |
| | | zipInputStream.closeEntry(); |
| | | } |
| | | } catch (IOException e) { |
| | |
| | | String processName = splitFilename[0]; |
| | | //流程key |
| | | String processKey = splitFilename[1]; |
| | | ProcessDefinition oldProcessDefinition = QueryUtils.definitionQuery().processDefinitionKey(processKey).latestVersion().singleResult(); |
| | | |
| | | DeploymentBuilder builder = repositoryService.createDeployment(); |
| | | Deployment deployment = builder.addInputStream(originalFilename, inputStream) |
| | |
| | | // 更新分类 |
| | | ProcessDefinition definition = QueryUtils.definitionQuery().deploymentId(deployment.getId()).singleResult(); |
| | | repositoryService.setProcessDefinitionCategory(definition.getId(), categoryCode); |
| | | setForm(oldProcessDefinition, definition); |
| | | setWfNodeConfig(definition); |
| | | |
| | | } else { |
| | | throw new ServiceException("文件类型上传错误!"); |
| | |
| | | /** |
| | | * 设置表单内容 |
| | | * |
| | | * @param oldProcessDefinition 部署前最新流程定义 |
| | | * @param definition 部署后最新流程定义 |
| | | * @param definition 部署后最新流程定义 |
| | | */ |
| | | private void setForm(ProcessDefinition oldProcessDefinition, ProcessDefinition definition) { |
| | | //更新流程定义表单 |
| | | if (oldProcessDefinition != null) { |
| | | WfDefinitionConfigVo definitionVo = iWfDefinitionConfigService.getByDefId(oldProcessDefinition.getId()); |
| | | if (definitionVo != null) { |
| | | WfDefinitionConfigBo wfFormDefinition = new WfDefinitionConfigBo(); |
| | | wfFormDefinition.setDefinitionId(definition.getId()); |
| | | wfFormDefinition.setProcessKey(definition.getKey()); |
| | | wfFormDefinition.setFormId(ObjectUtil.isNotNull(definitionVo.getFormId()) ? definitionVo.getFormId() : null); |
| | | wfFormDefinition.setRemark(definitionVo.getRemark()); |
| | | iWfDefinitionConfigService.saveOrUpdate(wfFormDefinition); |
| | | } |
| | | } |
| | | private void setWfNodeConfig(ProcessDefinition definition) { |
| | | //更新流程节点配置表单 |
| | | List<UserTask> userTasks = ModelUtils.getuserTaskFlowElements(definition.getId()); |
| | | List<UserTask> userTasks = ModelUtils.getUserTaskFlowElements(definition.getId()); |
| | | UserTask applyUserTask = ModelUtils.getApplyUserTask(definition.getId()); |
| | | List<WfNodeConfig> wfNodeConfigList = new ArrayList<>(); |
| | | for (UserTask userTask : userTasks) { |
| | | if (StringUtils.isNotBlank(userTask.getFormKey()) && userTask.getFormKey().contains(StrUtil.COLON)) { |
| | |
| | | String[] split = userTask.getFormKey().split(StrUtil.COLON); |
| | | wfNodeConfig.setFormType(split[0]); |
| | | wfNodeConfig.setFormId(Long.valueOf(split[1])); |
| | | wfNodeConfig.setApplyUserTask(applyUserTask.getId().equals(userTask.getId()) ? FlowConstant.TRUE : FlowConstant.FALSE); |
| | | wfNodeConfigList.add(wfNodeConfig); |
| | | } |
| | | } |