|
@@ -1,6 +1,21 @@
|
|
|
package com.ruoyi.execution.produce.dispersed.service.impl.utils;
|
|
|
|
|
|
+import com.ruoyi.common.config.bpm.BpmProperties;
|
|
|
+import com.ruoyi.common.core.domain.AjaxResult;
|
|
|
+import com.ruoyi.common.utils.StringUtils;
|
|
|
+import com.ruoyi.execution.produce.RunImplementationClass;
|
|
|
+import com.ruoyi.system.entity.BpmNodeHandleUser;
|
|
|
+import com.ruoyi.system.entity.BpmNodeScriptRelevance;
|
|
|
+import com.ruoyi.system.entity.BpmProcessConfiguration;
|
|
|
+import com.ruoyi.system.service.IBpmNodeHandleUserService;
|
|
|
+import com.ruoyi.system.service.IBpmNodeScriptRelevanceService;
|
|
|
+import com.ruoyi.system.service.IBpmProcessConfigurationService;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
+import org.springframework.web.client.RestTemplate;
|
|
|
+
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
/**
|
|
|
* @author hanzihang
|
|
@@ -10,7 +25,78 @@ import org.springframework.stereotype.Component;
|
|
|
@Component
|
|
|
public class VerifyExecutionProcess {
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private IBpmProcessConfigurationService bpmProcessConfigurationService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IBpmNodeScriptRelevanceService bpmNodeScriptRelevanceService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IBpmNodeHandleUserService bpmNodeHandleUserService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private RunImplementationClass runImplementationClass;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private BpmProperties bpmProperties;
|
|
|
+
|
|
|
+ /*
|
|
|
+ 判断是否有开始结束节点,有,循环判断每一个节点是否包含自动执行脚本,并且脚本是否存在,
|
|
|
+ 节点是否绑定角色权限,真实角色下是否存在可处理用户,虚拟角色下用户是否都真实存在
|
|
|
+ */
|
|
|
public boolean VerifyProcessData(String processKey) {
|
|
|
+ RestTemplate restTemplate = new RestTemplate();
|
|
|
+ // 根据流程编号(node_process_key)查询流程配置表(bpm_process_configuration)得到该流程所有节点信息
|
|
|
+ BpmProcessConfiguration bpmProcessConfiguration = new BpmProcessConfiguration();
|
|
|
+ bpmProcessConfiguration.setNodeProcessKey(processKey);
|
|
|
+ List<BpmProcessConfiguration> bpmProcessConfigurationList = bpmProcessConfigurationService.selectBpmProcessConfigurationList(bpmProcessConfiguration);
|
|
|
+ // 定义变量开始节点(startNode),结束节点(endNode)
|
|
|
+ int startNode = 0;
|
|
|
+ int endNode = 0;
|
|
|
+ for (BpmProcessConfiguration b : bpmProcessConfigurationList) {
|
|
|
+ //判断节点前后是否执行自动脚本,并且脚本是否存在
|
|
|
+ if (b.getNodeBefore().equals("true") || b.getNodeAfter().equals("true")) {
|
|
|
+ // 查询自动执行脚本
|
|
|
+ BpmNodeScriptRelevance bpmNodeScriptRelevance = bpmNodeScriptRelevanceService.selectAutoScriptByNodeKey(b.getNodeKey());
|
|
|
+ if (bpmNodeScriptRelevance != null) {
|
|
|
+ // 获取执行脚本名称,判断脚本是否存在
|
|
|
+ AjaxResult ajaxResult = restTemplate.getForObject(bpmProperties.getNodeScriptIp + bpmNodeScriptRelevance.getScriptKey(), AjaxResult.class);
|
|
|
+ if(Long.valueOf(ajaxResult.get("code").toString()) != 200L){
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ Map<String,Object> map = (Map<String,Object>)ajaxResult.get("data");
|
|
|
+ runImplementationClass.isVerificationMethod(map.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())) {
|
|
|
+ AjaxResult ajaxResult = restTemplate.getForObject(bpmProperties.queryUserExistsByRoleKeyIp + bpmNodeHandleUser.getRealRole(),AjaxResult.class);
|
|
|
+ Long count = Long.valueOf(ajaxResult.get("data").toString());
|
|
|
+ if (count <= 0) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 虚拟角色下用户是否都真实存在
|
|
|
+ if(StringUtils.isNotEmpty(bpmNodeHandleUser.getExecuteUserNo())){
|
|
|
+ AjaxResult ajaxResult = restTemplate.getForObject(bpmProperties.queryUserExistsByUserIdsIp + bpmNodeHandleUser.getExecuteUserNo(),AjaxResult.class);
|
|
|
+ Long count = Long.valueOf(ajaxResult.get("data").toString());
|
|
|
+ if (count <= 0) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ if (b.getNodeType().equals("startEvent")) startNode++;
|
|
|
+ if (b.getNodeType().equals("endEvent")) endNode++;
|
|
|
+ }
|
|
|
return true;
|
|
|
}
|
|
|
|