From ed43774129f2278aa6248242c6ff145bde1a625d Mon Sep 17 00:00:00 2001 From: gssong <1742057357@qq.com> Date: 星期三, 27 三月 2024 22:23:02 +0800 Subject: [PATCH] add 添加任务过期自动审批 --- ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/service/impl/ActModelServiceImpl.java | 63 +++++++++++++++++++++---------- 1 files changed, 42 insertions(+), 21 deletions(-) diff --git a/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/service/impl/ActModelServiceImpl.java b/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/service/impl/ActModelServiceImpl.java index 93934c9..e070dfd 100644 --- a/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/service/impl/ActModelServiceImpl.java +++ b/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/service/impl/ActModelServiceImpl.java @@ -20,8 +20,11 @@ import org.dromara.common.tenant.helper.TenantHelper; import org.dromara.workflow.common.constant.FlowConstant; import org.dromara.workflow.domain.bo.ModelBo; +import org.dromara.workflow.domain.bo.WfFormDefinitionBo; import org.dromara.workflow.domain.vo.ModelVo; +import org.dromara.workflow.domain.vo.WfFormDefinitionVo; import org.dromara.workflow.service.IActModelService; +import org.dromara.workflow.service.IWfFormDefinitionService; import org.dromara.workflow.utils.ModelUtils; import org.dromara.workflow.utils.QueryUtils; import org.flowable.bpmn.model.BpmnModel; @@ -52,6 +55,7 @@ public class ActModelServiceImpl implements IActModelService { private final RepositoryService repositoryService; + private final IWfFormDefinitionService iWfFormDefinitionService; /** * 鍒嗛〉鏌ヨ妯″瀷 @@ -78,7 +82,10 @@ List<Model> modelList = query.listPage(pageQuery.getFirstNum(), pageQuery.getPageSize()); // 鎬昏褰曟暟 long total = query.count(); - return new TableDataInfo<>(modelList, total); + TableDataInfo<Model> build = TableDataInfo.build(); + build.setRows(modelList); + build.setTotal(total); + return build; } /** @@ -249,6 +256,7 @@ } // 鏌ヨ妯″瀷鐨勫熀鏈俊鎭� Model model = repositoryService.getModel(id); + ProcessDefinition processDefinition = QueryUtils.definitionQuery().processDefinitionKey(model.getKey()).latestVersion().singleResult(); // xml璧勬簮鐨勫悕绉� 锛屽搴攁ct_ge_bytearray琛ㄤ腑鐨刵ame_瀛楁 String processName = model.getName() + ".bpmn20.xml"; // 璋冪敤閮ㄧ讲鐩稿叧鐨刟pi鏂规硶杩涜閮ㄧ讲娴佺▼瀹氫箟 @@ -271,6 +279,17 @@ // 鏇存柊鍒嗙被 ProcessDefinition definition = QueryUtils.definitionQuery().deploymentId(deployment.getId()).singleResult(); repositoryService.setProcessDefinitionCategory(definition.getId(), model.getCategory()); + if (processDefinition != null) { + WfFormDefinitionVo definitionVo = iWfFormDefinitionService.getByDefId(processDefinition.getId()); + if (definitionVo != null) { + WfFormDefinitionBo wfFormDefinition = new WfFormDefinitionBo(); + wfFormDefinition.setDefinitionId(definition.getId()); + wfFormDefinition.setProcessKey(definition.getKey()); + wfFormDefinition.setPath(definitionVo.getPath()); + wfFormDefinition.setRemark(definitionVo.getRemark()); + iWfFormDefinitionService.saveOrUpdate(wfFormDefinition); + } + } return true; } catch (Exception e) { e.printStackTrace(); @@ -281,35 +300,37 @@ /** * 瀵煎嚭妯″瀷zip鍘嬬缉鍖� * - * @param modelId 妯″瀷id + * @param modelIds 妯″瀷id * @param response 鐩稿簲 */ @Override - public void exportZip(String modelId, HttpServletResponse response) { + public void exportZip(List<String> modelIds, HttpServletResponse response) { ZipOutputStream zos = null; try { zos = ZipUtil.getZipOutputStream(response.getOutputStream(), StandardCharsets.UTF_8); // 鍘嬬缉鍖呮枃浠跺悕 String zipName = "妯″瀷涓嶅瓨鍦�"; // 鏌ヨ妯″瀷鍩烘湰淇℃伅 - Model model = repositoryService.getModel(modelId); - byte[] xmlBytes = repositoryService.getModelEditorSource(modelId); - if (ObjectUtil.isNotNull(model)) { - if (JSONUtil.isTypeJSON(IOUtils.toString(xmlBytes, StandardCharsets.UTF_8.toString())) && ArrayUtil.isEmpty(ModelUtils.bpmnJsonToXmlBytes(xmlBytes))) { - zipName = "妯″瀷涓嶈兘涓虹┖锛岃鑷冲皯璁捐涓�鏉′富绾挎祦绋嬶紒"; - zos.putNextEntry(new ZipEntry(zipName + ".txt")); - zos.write(zipName.getBytes(StandardCharsets.UTF_8)); - } else if (ArrayUtil.isEmpty(xmlBytes)) { - zipName = "妯″瀷鏁版嵁涓虹┖锛岃鍏堣璁℃祦绋嬪畾涔夋ā鍨嬶紝鍐嶈繘琛岄儴缃诧紒"; - zos.putNextEntry(new ZipEntry(zipName + ".txt")); - zos.write(zipName.getBytes(StandardCharsets.UTF_8)); - } else { - String fileName = model.getName() + "-" + model.getKey(); - // 鍘嬬缉鍖呮枃浠跺悕 - zipName = fileName + ".zip"; - // 灏唜ml娣诲姞鍒板帇缂╁寘涓�(鎸囧畾xml鏂囦欢鍚嶏細璇峰亣娴佺▼.bpmn20.xml - zos.putNextEntry(new ZipEntry(fileName + ".bpmn20.xml")); - zos.write(xmlBytes); + for (String modelId : modelIds) { + Model model = repositoryService.getModel(modelId); + byte[] xmlBytes = repositoryService.getModelEditorSource(modelId); + if (ObjectUtil.isNotNull(model)) { + if (JSONUtil.isTypeJSON(IOUtils.toString(xmlBytes, StandardCharsets.UTF_8.toString())) && ArrayUtil.isEmpty(ModelUtils.bpmnJsonToXmlBytes(xmlBytes))) { + zipName = "妯″瀷涓嶈兘涓虹┖锛岃鑷冲皯璁捐涓�鏉′富绾挎祦绋嬶紒"; + zos.putNextEntry(new ZipEntry(zipName + ".txt")); + zos.write(zipName.getBytes(StandardCharsets.UTF_8)); + } else if (ArrayUtil.isEmpty(xmlBytes)) { + zipName = "妯″瀷鏁版嵁涓虹┖锛岃鍏堣璁℃祦绋嬪畾涔夋ā鍨嬶紝鍐嶈繘琛岄儴缃诧紒"; + zos.putNextEntry(new ZipEntry(zipName + ".txt")); + zos.write(zipName.getBytes(StandardCharsets.UTF_8)); + } else { + String fileName = model.getName() + "-" + model.getKey(); + // 鍘嬬缉鍖呮枃浠跺悕 + zipName = fileName + ".zip"; + // 灏唜ml娣诲姞鍒板帇缂╁寘涓�(鎸囧畾xml鏂囦欢鍚嶏細璇峰亣娴佺▼.bpmn20.xml + zos.putNextEntry(new ZipEntry(fileName + ".bpmn20.xml")); + zos.write(xmlBytes); + } } } response.setHeader("Content-Disposition", -- Gitblit v1.9.3