Переглянути джерело

fix: 流程优化

(cherry picked from commit de3d555aa33a3d20c5c12293c2624440d0e9bbf1)
liuc 6 місяців тому
батько
коміт
5b6e80fb64

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

@@ -1,5 +1,6 @@
 package com.cloud.sa.service;
 
+import cn.dev33.satoken.stp.StpUtil;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.cloud.sa.flow.commom.domain.common.EngineParams;
@@ -64,10 +65,11 @@ public class FlowUniversalService {
         flowEnteredParam.setFlowVersion(flowVersion);
         flowEnteredParam.setBizObjectid(bizObjectid);
         flowEnteredParam.setTaskid(taskId);
+        String token = StpUtil.getTokenValue();
         Thread thread = new Thread(() -> {
             try {
                 Thread.sleep(10000);
-                StHttpRequest.postHttpClient("http://localhost:" + port + "/bpm/core/instance/autosubmit", JSON.toJSONString(flowEnteredParam));
+                StHttpRequest.postHttpClient("http://localhost:" + port + "/bpm/core/instance/autosubmit", JSON.toJSONString(flowEnteredParam),token);
             } catch (Exception e) {
             }
         });

+ 5 - 4
bound-link-api/sa-flow-common/src/main/java/com/cloud/sa/flow/commom/common/Request/StHttpRequest.java

@@ -18,7 +18,7 @@ import java.io.IOException;
  * @date 2024/6/20 19:16
  */
 public class StHttpRequest {
-    public static String postHttpClient(String path, String json) throws Exception {
+    public static String postHttpClient(String path, String json,String token) throws Exception {
         CloseableHttpClient httpClient = HttpClients.createDefault();
         String uri = path;
         try {
@@ -28,7 +28,7 @@ public class StHttpRequest {
             entity.setContentType("application/json"); // 设置请求的内容类型
             httpPost.setEntity(entity);
             // 添加请求头
-            httpPost.addHeader("X-Access-Token", StpUtil.getTokenValue()); // 添加eventId请求头
+            httpPost.addHeader("X-Access-Token", token);
             // 执行请求并获取响应
             CloseableHttpResponse response = httpClient.execute(httpPost);
             try {
@@ -46,13 +46,14 @@ public class StHttpRequest {
         }
         return null;
     }
-    public static String getHttpClient(String path) throws Exception {
+
+    public static String getHttpClient(String path,String token) throws Exception {
         CloseableHttpClient httpClient = HttpClients.createDefault();
         String uri = path;
         try {
             HttpGet httpGet = new HttpGet(uri); // 替换为你的目标URL
             // 添加请求头
-            httpGet.addHeader("X-Access-Token", StpUtil.getTokenValue()); // 添加eventId请求头
+            httpGet.addHeader("X-Access-Token", token);
             // 执行请求并获取响应
             CloseableHttpResponse response = httpClient.execute(httpGet);
             try {

+ 6 - 6
bound-link-api/sa-flow-common/src/main/java/com/cloud/sa/flow/commom/common/system/StUserInfo.java

@@ -32,6 +32,9 @@ public class StUserInfo {
     }
 
     public static String getUserCode() {
+        if (StString.isNotEmpty(threadLocalValueUserCode.get())) {
+            return threadLocalValueUserCode.get();
+        }
         Object userDetails = getLoginUser();
         if (userDetails != null) {
             try {
@@ -46,13 +49,13 @@ public class StUserInfo {
                 throw new RuntimeException(e);
             }
         }
-        if (StString.isNotEmpty(threadLocalValueUserCode.get())) {
-            return threadLocalValueUserCode.get();
-        }
         return StGlobalConstant.ADMIN_USER_CODE;
     }
 
     public static String getUserName() {
+        if (StString.isNotEmpty(threadLocalValueUserName.get())) {
+            return threadLocalValueUserName.get();
+        }
         Object userDetails = getLoginUser();
         if (userDetails != null) {
             try {
@@ -67,9 +70,6 @@ public class StUserInfo {
                 throw new RuntimeException(e);
             }
         }
-        if (StString.isNotEmpty(threadLocalValueUserName.get())) {
-            return threadLocalValueUserName.get();
-        }
         return StGlobalConstant.ADMIN_USER_CODE;
     }
 

+ 1 - 0
bound-link-api/sa-flow-common/src/main/java/com/cloud/sa/flow/commom/domain/common/StGlobalConstant.java

@@ -57,6 +57,7 @@ public class StGlobalConstant {
      * 根据部门或者人的编码,找到岗位:$GetPostByCode([人/部门],'岗位名称')
      */
     public static final String GetPostByCode = "$GetPostByCode";
+    public static final String GetByMethod = "$GetByMethod";
 
 
     public static final String StThreadPoolTaskExecutor = "StThreadPoolTaskExecutor";

+ 4 - 3
bound-link-api/sa-flow-common/src/main/java/com/cloud/sa/flow/commom/service/setting/StSettingService.java

@@ -1,5 +1,6 @@
 package com.cloud.sa.flow.commom.service.setting;
 
+import cn.dev33.satoken.stp.StpUtil;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
@@ -131,9 +132,9 @@ public class StSettingService {
                         }
                     }
                 }
-                String httpClient = StHttpRequest.getHttpClient(url);
-                List<Map<String, String>> resultList= new ArrayList<>();
-                if(httpClient!=null  ){
+                String httpClient = StHttpRequest.getHttpClient(url, StpUtil.getTokenValue());
+                List<Map<String, String>> resultList = new ArrayList<>();
+                if (httpClient != null) {
                     JSONArray jsonArray = JSONArray.parseArray(httpClient);
                     resultList = jsonArray.stream()
                             .map(obj -> {