Browse Source

fix:修改校验流程数据接口和下发请求

xuezizhuo 1 năm trước cách đây
mục cha
commit
4bcb112c2e

+ 3 - 3
ruoyi-admin/src/main/resources/application.yml

@@ -155,11 +155,11 @@ parameter:
     # 用户下对应的所有角色key
     MAIN_ROLESKEY_IP: http://localhost:8080/system/user/roleKeyByUserId
     # CRM项目根据scriptKey获取节点脚本详情地址
-    GET_NODESCRIPT_IP: http://localhost:8080/system/script/selectSysBpmNodeScriptByScriptKey
+    GET_NODESCRIPT_IP: http://localhost:8080/system/script/selectSysBpmNodeScriptByScriptKey/{scriptKey}
     # crm项目查看角色下是否存在真实用户
-    QUERY_USER_EXISTS_BY_ROLEKEY_IP: http://localhost:8080/system/role/selectUserByRoleKey
+    QUERY_USER_EXISTS_BY_ROLEKEY_IP: http://localhost:8080/system/role/selectUserByRoleKey/{roleKeys}
     # crm项目查看一组用户是否存在真实用户
-    QUERY_USER_EXISTS_BY_USERIDS_IP: http://localhost:8080/system/user/selectUserByUserIds
+    QUERY_USER_EXISTS_BY_USERIDS_IP: http://localhost:8080/system/user/selectUserByUserIds/{userIds}
     # form项目共通修改接口
     FORM_COMMON_UPDATE_IP: http://localhost:8088/dragform/common/batchEdit
     #from项目共通获取详情接口

+ 48 - 6
ruoyi-common/src/main/java/com/ruoyi/common/utils/http/Sending.java

@@ -7,11 +7,14 @@ import com.ruoyi.common.utils.SecurityUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.*;
 import org.springframework.stereotype.Component;
+import org.springframework.util.LinkedMultiValueMap;
+import org.springframework.util.MultiValueMap;
 import org.springframework.web.client.RestTemplate;
 
 import java.lang.reflect.Field;
 import java.util.Collection;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 
 
@@ -126,22 +129,61 @@ public class Sending<T> {
     /**
      * 根据scriptKey获取节点脚本详情接口
      */
-    public ResponseEntity sendGetNodeScript(T param) {
-        return this.sendCommon(bpmProperties.getNodeScriptIp, "GET", param);
+    public ResponseEntity sendGetNodeScript(String scriptKey) {
+        // 得到当前用户的token  下发流程请求需要携带
+        String token = SecurityUtils.getLoginUser().getToken();
+        // 设置请求头
+        HttpHeaders headers = new HttpHeaders();
+        headers.set("Authorization", "XIAFA" + token);
+        HttpEntity request = new HttpEntity(headers);
+        ResponseEntity<AjaxResult> response = restTemplate.exchange(
+                bpmProperties.getNodeScriptIp,
+                HttpMethod.GET,
+                request,
+                AjaxResult.class,
+                scriptKey
+        );
+        return response;
     }
 
     /**
      * 查看角色下是否存在真实用户接口
      */
-    public ResponseEntity sendQueryUserExistsByRoleKey(T param) {
-        return this.sendCommon(bpmProperties.queryUserExistsByRoleKeyIp, "GET", param);
+    public ResponseEntity sendQueryUserExistsByRoleKey(String roleKeys) {
+        // 得到当前用户的token  下发流程请求需要携带
+        String token = SecurityUtils.getLoginUser().getToken();
+        // 设置请求头
+        HttpHeaders headers = new HttpHeaders();
+        headers.set("Authorization", "XIAFA" + token);
+        HttpEntity request = new HttpEntity(headers);
+        ResponseEntity<AjaxResult> response = restTemplate.exchange(
+                bpmProperties.queryUserExistsByRoleKeyIp,
+                HttpMethod.GET,
+                request,
+                AjaxResult.class,
+                roleKeys
+        );
+        return response;
     }
 
     /**
      * 查看一组用户下是否存在真实用户接口
      */
-    public ResponseEntity sendQueryUserExistsByUserIds(T param) {
-        return this.sendCommon(bpmProperties.queryUserExistsByUserIdsIp, "GET", param);
+    public ResponseEntity sendQueryUserExistsByUserIds(String userIds) {
+        // 得到当前用户的token  下发流程请求需要携带
+        String token = SecurityUtils.getLoginUser().getToken();
+        // 设置请求头
+        HttpHeaders headers = new HttpHeaders();
+        headers.set("Authorization", "XIAFA" + token);
+        HttpEntity request = new HttpEntity(headers);
+        ResponseEntity<AjaxResult> response = restTemplate.exchange(
+                bpmProperties.queryUserExistsByUserIdsIp,
+                HttpMethod.GET,
+                request,
+                AjaxResult.class,
+                userIds
+        );
+        return response;
     }
 
     /**

+ 1 - 1
ruoyi-process-execution/src/main/java/com/ruoyi/execution/produce/dispersed/controller/BpmExecuteNodeController.java

@@ -96,5 +96,5 @@ public class BpmExecuteNodeController extends BaseController {
     public AjaxResult remove(@PathVariable Long[] ids) {
         return toAjax(bpmExecuteNodeService.deleteBpmExecuteNodeByIds(ids));
     }
-    
+
 }

+ 1 - 1
ruoyi-process-execution/src/main/java/com/ruoyi/execution/produce/dispersed/service/impl/BpmExecuteNodeServiceImpl.java

@@ -120,7 +120,7 @@ public class BpmExecuteNodeServiceImpl implements IBpmExecuteNodeService {
     @Transactional
     public int triggerExceptionNode(TriggerExceptionVO vo) throws Exception {
         //新增节点标签ID
-        String newUserTaskTagId = "Activity_" + IdUtils.fastSimpleUUID().substring(0, 7);
+        String newUserTaskTagId = "Activity_" + IdUtils.fastUUID();
         //select bpm_execute_process
         BpmExecuteProcess bpmExecuteProcess = bpmExecuteProcessMapper.selectBpmExecuteProcessByTaskKey(vo.getTaskProcessKey());
         //sys_bpm_node_script info

+ 78 - 19
ruoyi-process-execution/src/main/java/com/ruoyi/execution/produce/dispersed/service/impl/utils/VerifyExecutionProcess.java

@@ -22,6 +22,7 @@ import java.util.Arrays;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.stream.Collectors;
 
 /**
  * @author hanzihang
@@ -50,7 +51,8 @@ public class VerifyExecutionProcess {
     private Sending sending;
 
     /*
-      判断是否有开始结束节点,有,循环判断每一个节点是否包含自动执行脚本,并且脚本是否存在,
+      判断开始节点结束节点是否存在、脚本是否存在
+      判断是否有其他节点,有,循环判断每一个节点是否包含自动执行脚本,并且脚本是否存在,
       节点是否绑定角色权限,真实角色下是否存在可处理用户,虚拟角色下用户是否都真实存在
       node_form_type类型为拖拽表单类型,查看该表单信息是否存在;为组合表单类型查看该表格组信息是否存在;
       为自定义表单类型时,判断节点脚本关联表查看script_node_name该字段是否存在及该字段是否有“-”,"-"前是否有内容。
@@ -64,38 +66,99 @@ public class VerifyExecutionProcess {
         int startNode = 0;
         int endNode = 0;
         for (BpmProcessConfiguration b : bpmProcessConfigurationList) {
+
+            if (b.getNodeType().equals("startEvent")) {
+                startNode++;
+                //校验正常节点存不存在
+                BpmNodeScriptRelevance bpmNodeScriptRelevance = new BpmNodeScriptRelevance();
+                bpmNodeScriptRelevance.setNodeKey(b.getNodeKey());
+                bpmNodeScriptRelevance.setScriptTriggerType(1L);
+                BpmNodeScriptRelevance bpmNodeScriptRelevance1 = bpmNodeScriptRelevanceService.selectBpmNodeScriptRelevanceInfo(bpmNodeScriptRelevance);
+                if(bpmNodeScriptRelevance1 != null){
+                    ResponseEntity<AjaxResult> responseEntity = sending.sendGetNodeScript(bpmNodeScriptRelevance1.getScriptKey());
+                    if(responseEntity.getStatusCodeValue() != 200L){
+                        return false;
+                    }
+                    AjaxResult ajaxResult = responseEntity.getBody();
+                    if(Long.valueOf(ajaxResult.get("code").toString()) != 200L){
+                        return false;
+                    }
+                    if (!ajaxResult.containsKey("data")){
+                        return false;
+                    }
+                    Map<String,Object> dataMap = (Map<String,Object>)ajaxResult.get("data");
+                    if(!runImplementationClass.isVerificationMethod(dataMap.get("scriptKey").toString())){
+                        return false;
+                    };
+                }else {
+                    return false;
+                }
+                continue;
+            }
+            if (b.getNodeType().equals("endEvent")) {
+                endNode++;
+                //校验正常节点存不存在
+                BpmNodeScriptRelevance bpmNodeScriptRelevance = new BpmNodeScriptRelevance();
+                bpmNodeScriptRelevance.setNodeKey(b.getNodeKey());
+                bpmNodeScriptRelevance.setScriptTriggerType(1L);
+                BpmNodeScriptRelevance bpmNodeScriptRelevance1 = bpmNodeScriptRelevanceService.selectBpmNodeScriptRelevanceInfo(bpmNodeScriptRelevance);
+                if(bpmNodeScriptRelevance1 != null){
+                    ResponseEntity<AjaxResult> responseEntity = sending.sendGetNodeScript(bpmNodeScriptRelevance1.getScriptKey());
+                    if(responseEntity.getStatusCodeValue() != 200L){
+                        return false;
+                    }
+                    AjaxResult ajaxResult = responseEntity.getBody();
+                    if(Long.valueOf(ajaxResult.get("code").toString()) != 200L){
+                        return false;
+                    }
+                    if (!ajaxResult.containsKey("data")){
+                        return false;
+                    }
+                    Map<String,Object> dataMap = (Map<String,Object>)ajaxResult.get("data");
+                    if(!runImplementationClass.isVerificationMethod(dataMap.get("scriptKey").toString())){
+                        return false;
+                    }
+
+                }else {
+                    return false;
+                }
+                continue;
+            }
+
             //判断节点前后是否执行自动脚本,并且脚本是否存在
             if (b.getNodeBefore().equals("true") || b.getNodeAfter().equals("true")) {
                 // 查询自动执行脚本
                 BpmNodeScriptRelevance bpmNodeScriptRelevance = bpmNodeScriptRelevanceService.selectAutoScriptByNodeKey(b.getNodeKey());
                  if (bpmNodeScriptRelevance != null) {
                      // 获取执行脚本名称,判断脚本是否存在
-                     Map<String,Object> paramMap = new HashMap<>();
-                     paramMap.put("scriptKey",bpmNodeScriptRelevance.getScriptKey());
-                     ResponseEntity responseEntity = sending.sendGetNodeScript(paramMap);
+                     ResponseEntity<AjaxResult> responseEntity = sending.sendGetNodeScript(bpmNodeScriptRelevance.getScriptKey());
                      if(responseEntity.getStatusCodeValue() != 200L){
                          return false;
                      }
-                     Map<String,Object> map = JSON.parseObject(responseEntity.getBody().toString());
-                    if(Long.valueOf(map.get("code").toString()) != 200L){
+                     AjaxResult ajaxResult = responseEntity.getBody();
+                    if(Long.valueOf(ajaxResult.get("code").toString()) != 200L){
+                        return false;
+                    }
+                    if (!ajaxResult.containsKey("data")){
+                        return false;
+                    }
+                     Map<String,Object> dataMap = (Map<String,Object>)ajaxResult.get("data");
+                    if(!runImplementationClass.isVerificationMethod(dataMap.get("scriptKey").toString())){
                         return false;
                     }
-                     Map<String,Object> dataMap = (Map<String,Object>)map.get("data");
-                     runImplementationClass.isVerificationMethod(dataMap.get("scriptFunctionName").toString());
                  }else {
                      return false;
                  }
             }else {
                 return false;
             }
+
             //判断节点是否绑定角色权限,真实角色下是否存在可处理用户,虚拟角色下用户是否都真实存在
             if (StringUtils.isNotEmpty(b.getNodeRolePermission())) {
                 BpmNodeHandleUser bpmNodeHandleUser = bpmNodeHandleUserService.selectBpmNodeHandleUserByVirtuallyRole(b.getNodeRolePermission());
                 // 真实角色不为空查询真实角色下是否存在可处理用户
                 if (StringUtils.isNotEmpty(bpmNodeHandleUser.getRealRole())) {
-                    Map<String,Object> paramMap = new HashMap<>();
-                    paramMap.put("userIds",Arrays.asList(bpmNodeHandleUser.getRealRole().split(",")));
-                    ResponseEntity responseEntity = sending.sendQueryUserExistsByRoleKey(paramMap);
+                    ResponseEntity responseEntity = sending.sendQueryUserExistsByRoleKey(bpmNodeHandleUser.getRealRole());
                     if (responseEntity.getStatusCodeValue() != 200){
                         return false;
                     }
@@ -109,17 +172,15 @@ public class VerifyExecutionProcess {
                 }
                 // 虚拟角色下用户是否都真实存在
                 if(StringUtils.isNotEmpty(bpmNodeHandleUser.getExecuteUserNo())){
-                    Map<String,Object> paramMap = new HashMap<>();
-                    paramMap.put("userIds",Arrays.asList(bpmNodeHandleUser.getExecuteUserNo().split(",")));
-                    ResponseEntity responseEntity = sending.sendQueryUserExistsByUserIds(paramMap);
+                    ResponseEntity<AjaxResult> responseEntity = sending.sendQueryUserExistsByUserIds(bpmNodeHandleUser.getExecuteUserNo());
                     if (responseEntity.getStatusCodeValue() != 200){
                         return false;
                     }
-                    Map<String,Object> map = JSON.parseObject(responseEntity.getBody().toString());
-                    if(Long.valueOf(map.get("code").toString()) != 200L){
+                    AjaxResult ajaxResult= responseEntity.getBody();
+                    if(Long.valueOf(ajaxResult.get("code").toString()) != 200L){
                         return false;
                     }
-                    if (Long.valueOf(map.get("data").toString()) <= 0L){
+                    if (Long.valueOf(ajaxResult.get("data").toString()) <= 0L){
                         return false;
                     }
                 }
@@ -166,8 +227,6 @@ public class VerifyExecutionProcess {
                     return false;
                 }
             }
-            if (b.getNodeType().equals("startEvent")) startNode++;
-            if (b.getNodeType().equals("endEvent")) endNode++;
         }
         if(startNode <= 0 || endNode <= 0){
             return false;

+ 8 - 0
ruoyi-system/src/main/java/com/ruoyi/system/mapper/BpmNodeScriptRelevanceMapper.java

@@ -79,4 +79,12 @@ public interface BpmNodeScriptRelevanceMapper
      * @return
      */
     int deleteBpmNodeScriptRelevanceByNodeKeys(List<String> nodeKeys);
+
+    /**
+     * 查询流程节点脚本关联详情
+     *
+     * @param bpmNodeScriptRelevance 流程节点脚本关联
+     * @return 流程节点脚本关联集合
+     */
+    BpmNodeScriptRelevance selectBpmNodeScriptRelevanceInfo(BpmNodeScriptRelevance bpmNodeScriptRelevance);
 }

+ 8 - 0
ruoyi-system/src/main/java/com/ruoyi/system/service/IBpmNodeScriptRelevanceService.java

@@ -72,4 +72,12 @@ public interface IBpmNodeScriptRelevanceService {
      * @return
      */
     int deleteBpmNodeScriptRelevanceByNodeKeys(List<String> nodeKeys);
+
+    /**
+     * 查询流程节点脚本关联详情
+     *
+     * @param bpmNodeScriptRelevance 流程节点脚本关联
+     * @return 流程节点脚本关联集合
+     */
+    BpmNodeScriptRelevance selectBpmNodeScriptRelevanceInfo(BpmNodeScriptRelevance bpmNodeScriptRelevance);
 }

+ 5 - 0
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/BpmNodeScriptRelevanceServiceImpl.java

@@ -107,4 +107,9 @@ public class BpmNodeScriptRelevanceServiceImpl implements IBpmNodeScriptRelevanc
     public int deleteBpmNodeScriptRelevanceByNodeKeys(List<String> nodeKeys) {
         return bpmNodeScriptRelevanceMapper.deleteBpmNodeScriptRelevanceByNodeKeys(nodeKeys);
     }
+
+    @Override
+    public BpmNodeScriptRelevance selectBpmNodeScriptRelevanceInfo(BpmNodeScriptRelevance bpmNodeScriptRelevance) {
+        return bpmNodeScriptRelevanceMapper.selectBpmNodeScriptRelevanceInfo(bpmNodeScriptRelevance);
+    }
 }

+ 13 - 0
ruoyi-system/src/main/resources/mapper/bpm/BpmNodeScriptRelevanceMapper.xml

@@ -104,4 +104,17 @@
         </foreach>
     </delete>
 
+    <select id="selectBpmNodeScriptRelevanceInfo" parameterType="com.ruoyi.system.entity.BpmNodeScriptRelevance"
+            resultMap="BpmNodeScriptRelevanceResult">
+        <include refid="selectBpmNodeScriptRelevanceVo"/>
+        <where>
+            <if test="nodeKey != null  and nodeKey != ''">and node_key = #{nodeKey}</if>
+            <if test="scriptKey != null  and scriptKey != ''">and script_key = #{scriptKey}</if>
+            <if test="scriptTriggerType != null ">and script_trigger_type = #{scriptTriggerType}</if>
+            <if test="formKey != null">and form_key = #{formKey},</if>
+            <if test="scriptNodeName != null">and script_node_name = #{scriptNodeName},</if>
+            <if test="scriptNodeFormType != null">and script_node_form_type = #{scriptNodeFormType},</if>
+        </where>
+    </select>
+
 </mapper>