瀏覽代碼

fix: 优化性能

liuc 4 月之前
父節點
當前提交
3351a01ac6

+ 24 - 2
bound-link-api/sa-flow-api/src/main/java/com/cloud/sa/api/AppEngineController.java

@@ -1,6 +1,7 @@
 package com.cloud.sa.api;
 
 import com.alibaba.fastjson.JSONObject;
+import com.cloud.sa.flow.commom.aspect.EventProgram;
 import com.cloud.sa.flow.commom.common.model.StCodeMsg;
 import com.cloud.sa.flow.commom.common.model.StResult;
 import com.cloud.sa.flow.commom.common.utils.StString;
@@ -14,6 +15,7 @@ import com.cloud.sa.flow.commom.service.StMenuService;
 import com.cloud.sa.flow.commom.service.flow.StTaskItemService;
 import com.cloud.sa.flow.commom.service.setting.StSettingService;
 import com.cloud.sa.flow.engine.service.StFlowService;
+import com.wx.blink.base.common.annoation.NoNeedLogin;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.HttpHeaders;
 import org.springframework.http.MediaType;
@@ -60,7 +62,7 @@ public class AppEngineController {
     @PostMapping("/instance/savesubmit")
     public StResult SaveSubmitInstance(@Validated @RequestBody FlowEnteredParam flowEnteredParam) {
         StTaskitem taskitem = null;
-        if (flowEnteredParam.getIsBatches() == false) {
+        if (flowEnteredParam.getIsBatches() == false && flowEnteredParam.getTableData() != null && flowEnteredParam.getTableData().length() > 0) {
             //如果不是批量的审批通过,则先走一下保存
             taskitem = flowService.Save(flowEnteredParam, false);
             flowEnteredParam.setTaskid(taskitem.getObjectid());
@@ -70,7 +72,27 @@ public class AppEngineController {
             flowEnteredParam.setErrorMessage(errorMessage);
             return StResult.success(flowEnteredParam);
         } catch (Exception e) {
-            settingService.FlowCommonExceptionRecord(e, taskitem.getObjectid(), "提交");
+            settingService.FlowCommonExceptionRecord(e, flowEnteredParam.getTaskid(), "提交");
+            return StResult.error(StCodeMsg.SERVER_EXCEPTION, e.getMessage());
+        }
+    }
+
+    @NoNeedLogin
+    @EventProgram
+    @PostMapping("/instance/autosubmit")
+    public StResult autoSubmitInstance(@Validated @RequestBody FlowEnteredParam flowEnteredParam) {
+        StTaskitem taskitem = null;
+        if (flowEnteredParam.getIsBatches() == false && flowEnteredParam.getTableData() != null && flowEnteredParam.getTableData().length() > 0) {
+            //如果不是批量的审批通过,则先走一下保存
+            taskitem = flowService.Save(flowEnteredParam, false);
+            flowEnteredParam.setTaskid(taskitem.getObjectid());
+        }
+        try {
+            String errorMessage = flowService.Submit(flowEnteredParam);
+            flowEnteredParam.setErrorMessage(errorMessage);
+            return StResult.success(flowEnteredParam);
+        } catch (Exception e) {
+            settingService.FlowCommonExceptionRecord(e, flowEnteredParam.getTaskid(), "提交");
             return StResult.error(StCodeMsg.SERVER_EXCEPTION, e.getMessage());
         }
     }

+ 31 - 2
bound-link-api/sa-flow-api/src/main/java/com/cloud/sa/service/FlowUniversalService.java

@@ -1,16 +1,21 @@
 package com.cloud.sa.service;
 
+import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.cloud.sa.flow.commom.domain.common.EngineParams;
 import com.cloud.sa.flow.commom.domain.entity.StInstance;
 import com.cloud.sa.flow.commom.domain.entity.StTaskitem;
 import com.cloud.sa.flow.commom.domain.virentity.ActivityNodeBase;
+import com.cloud.sa.flow.commom.domain.virentity.FlowEnteredParam;
 import com.cloud.sa.flow.commom.domain.virentity.ParamAdJustActivate;
-import com.cloud.sa.flow.engine.service.form.StFormService;
 import com.cloud.sa.flow.engine.service.StFlowService;
 import com.cloud.sa.flow.engine.service.StOperationService;
+import com.cloud.sa.flow.engine.service.form.StFormService;
+import com.cloud.sa.flow.engine.subs.StHttpRequest;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
+
 import java.util.List;
 
 /**
@@ -22,7 +27,8 @@ public class FlowUniversalService {
     private final StFlowService flowService;
     private final StOperationService stOperationService;
     private final StFormService formService;
-
+    @Value("${server.port}")
+    private String port;
     @Autowired
     public FlowUniversalService(StFlowService flowService, StOperationService stOperationService, StFormService formService) {
         this.flowService = flowService;
@@ -42,6 +48,29 @@ public class FlowUniversalService {
         return flowService.autoSave(flowCode, tableData, userCode);
     }
 
+    /**
+     * @param flowCode
+     * @param flowVersion
+     * @param bizObjectid
+     * @param taskId
+     * @return 提交错误信息
+     */
+    public void autoSubmit(String flowCode, Integer flowVersion, String bizObjectid, String taskId) throws Exception {
+        FlowEnteredParam flowEnteredParam = new FlowEnteredParam();
+        flowEnteredParam.setFlowCode(flowCode);
+        flowEnteredParam.setFlowVersion(flowVersion);
+        flowEnteredParam.setBizObjectid(bizObjectid);
+        flowEnteredParam.setTaskid(taskId);
+        Thread thread = new Thread(() -> {
+            try {
+                Thread.sleep(10000);
+                StHttpRequest.postHttpClient("http://localhost:" + port + "/bpm/core/instance/autosubmit", JSON.toJSONString(flowEnteredParam));
+            } catch (Exception e) {
+            }
+        });
+        thread.start();
+    }
+
     /**
      * 取消流程
      *

二進制
bound-link-api/sa-flow-api/src/main/resources/lib/sa-flow-engine-3.0.0.jar