From b5ad057f0697e1bdbb88d26cd5ac72f5f55f7995 Mon Sep 17 00:00:00 2001
From: gssong <1742057357@qq.com>
Date: 星期一, 25 三月 2024 23:31:59 +0800
Subject: [PATCH] update 调整办理校验

---
 ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/service/impl/ActModelServiceImpl.java |   63 ++++++++++++++++++++-----------
 1 files changed, 41 insertions(+), 22 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 4d23bf0..62a4a09 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
@@ -15,12 +15,16 @@
 import org.apache.commons.io.IOUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.dromara.common.core.exception.ServiceException;
+import org.dromara.common.mybatis.core.page.PageQuery;
 import org.dromara.common.mybatis.core.page.TableDataInfo;
 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;
@@ -51,6 +55,7 @@
 public class ActModelServiceImpl implements IActModelService {
 
     private final RepositoryService repositoryService;
+    private final IWfFormDefinitionService iWfFormDefinitionService;
 
     /**
      * 鍒嗛〉鏌ヨ妯″瀷
@@ -59,7 +64,7 @@
      * @return 杩斿洖鍒嗛〉鍒楄〃
      */
     @Override
-    public TableDataInfo<Model> page(ModelBo modelBo) {
+    public TableDataInfo<Model> page(ModelBo modelBo, PageQuery pageQuery) {
         ModelQuery query = QueryUtils.modelQuery();
         if (StringUtils.isNotEmpty(modelBo.getName())) {
             query.modelNameLike("%" + modelBo.getName() + "%");
@@ -74,7 +79,7 @@
         // 鍒涘缓鏃堕棿闄嶅簭鎺掑垪
         query.orderByCreateTime().desc();
         // 鍒嗛〉鏌ヨ
-        List<Model> modelList = query.listPage(modelBo.getPageNum(), modelBo.getPageSize());
+        List<Model> modelList = query.listPage(pageQuery.getFirstNum(), pageQuery.getPageSize());
         // 鎬昏褰曟暟
         long total = query.count();
         return new TableDataInfo<>(modelList, total);
@@ -248,6 +253,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鏂规硶杩涜閮ㄧ讲娴佺▼瀹氫箟
@@ -270,6 +276,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();
@@ -280,35 +297,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