基于若依的ruoyi-nbcio流程管理系统自定义业务流程出现多个时相应的流程选择问题(二)

简介: 基于若依的ruoyi-nbcio流程管理系统自定义业务流程出现多个时相应的流程选择问题(二)

更多ruoyi-nbcio功能请看演示系统

gitee源代码地址

前后端代码: https://gitee.com/nbacheng/ruoyi-nbcio

演示地址:RuoYi-Nbcio后台管理系统

更多nbcio-boot功能请看演示系统

gitee源代码地址

后端代码: https://gitee.com/nbacheng/nbcio-boot

前端代码:https://gitee.com/nbacheng/nbcio-vue.git

在线演示(包括H5) : http://218.75.87.38:9888

接上一节

5、选择相应的流程后进行处理

selectProcess(row) {
        this.selectFlowId = row.id;
        this.flowOpen = false;
        var params = Object.assign({
          dataId: this.dataId
        }, this.variables);
        startByDataId(this.dataId, this.selectFlowId, this.serviceName, params)
          .then(res => {
            //console.log("startByDataId res",res);
            if (res.code == 200 ) {
              this.$message.success(res.msg);
              this.$emit('success');
            } else {
              this.$message.error(res.msg);
            }
          })
          .finally(() => (this.submitLoading = false));
      },

6、相应的后端启动流程也要做调整

/**
   * 根据流程dataId,serviceName启动流程实例,主要是自定义业务表单发起流程使用
   *  add by nbacheng
   * @param dataId,serviceName
   *           
   * @param variables
   *            流程变量
   * @return
   */
  @Override
  @Transactional(rollbackFor = Exception.class)
  public R<Void> startProcessByDataId(String dataId, String selectFlowId, String serviceName, Map<String, Object> variables) {
        //提交审批的时候进行流程实例关联初始化
      
        if (StringUtils.isEmpty(selectFlowId)){
             return R.fail("未找到关联流程selectFlowId:"+selectFlowId);
        }
        WfCustomFormVo wfCustomFormvo = wfCustomFormService.queryById(Long.valueOf(selectFlowId));
        if(ObjectUtil.isEmpty(wfCustomFormvo)){
          return R.fail("未找到wfCustomFormvo:"+selectFlowId);
        }
        //优先考虑自定义业务表是否关联流程,再看通用的表单流程关联表
        ProcessDefinition processDefinition;
        String deployId = wfCustomFormvo.getDeployId(); //临时先用一个,实际要返回list前端进行选择
        if(StringUtils.isEmpty(deployId)) {
          WfDeployForm sysDeployForm  = deployFormMapper.selectSysDeployFormByFormId("key_"+String.valueOf(wfCustomFormvo.getId()));
            if(sysDeployForm ==null){           
               return R.fail("自定义表单也没关联流程定义表,流程没定义关联自定义表单"+wfCustomFormvo.getId());
            }
            processDefinition = repositoryService.createProcessDefinitionQuery()
            .parentDeploymentId(sysDeployForm.getDeployId()).latestVersion().singleResult();
        }
        else {
          processDefinition = repositoryService.createProcessDefinitionQuery()
                .parentDeploymentId(deployId).latestVersion().singleResult();
        }
        try {
          LambdaQueryWrapper<WfMyBusiness> wfMyBusinessLambdaQueryWrapper = new LambdaQueryWrapper<>();
          wfMyBusinessLambdaQueryWrapper.eq(WfMyBusiness::getDataId, dataId);
          WfMyBusiness business = wfMyBusinessService.getOne(wfMyBusinessLambdaQueryWrapper);
          if (business==null || (business != null && business.getActStatus().equals(ActStatus.stop)) 
                         || (business != null && business.getActStatus().equals(ActStatus.recall))){
            if(processDefinition==null) {
              return R.fail("自定义表单也没关联流程定义表,流程没定义关联自定义表单"+wfCustomFormvo.getId());
            }
            boolean binit = wfCommonService.initActBusiness(wfCustomFormvo.getBusinessName(), dataId, serviceName, 
            processDefinition.getKey(), processDefinition.getId(), wfCustomFormvo.getRouteName());
            if(!binit) {
              return R.fail("自定义表单也没关联流程定义表,流程没定义关联自定义表单"+wfCustomFormvo.getId());
            }
            WfMyBusiness businessnew = wfMyBusinessService.getOne(wfMyBusinessLambdaQueryWrapper);
             //流程实例关联初始化结束
              if (StrUtil.isNotBlank(businessnew.getProcessDefinitionId())){
                return this.startProcessByDefId(businessnew.getProcessDefinitionId(),variables);
              }
              return this.startProcessByDefKey(businessnew.getProcessDefinitionKey(),variables);
          }
          else {
             return R.fail("已经存在这个dataid实例,不要重复申请:"+dataId);
          }
        } catch (Exception e) {
              e.printStackTrace();
              throw new RuntimeException();
      } 
  }

7、效果图

选择流程

这样选择不同的流程,实际走的也不一样了


相关文章
|
9月前
|
JSON API 数据格式
基于若依的ruoyi-nbcio流程管理系统增加仿钉钉流程设计(一)
基于若依的ruoyi-nbcio流程管理系统增加仿钉钉流程设计(一)
101 1
|
9月前
基于若依的ruoyi-nbcio流程管理系统增加仿钉钉流程设计(六)
基于若依的ruoyi-nbcio流程管理系统增加仿钉钉流程设计(六)
105 0
|
9月前
|
移动开发 前端开发
基于若依的ruoyi-nbcio流程管理系统自定义业务流程出现多个时相应的流程选择问题(一)
基于若依的ruoyi-nbcio流程管理系统自定义业务流程出现多个时相应的流程选择问题(一)
72 1
|
9月前
|
移动开发 前端开发
基于若依的ruoyi-nbcio流程管理系统自定义业务回写状态的一种新方法(二)
基于若依的ruoyi-nbcio流程管理系统自定义业务回写状态的一种新方法(二)
101 2
|
9月前
|
移动开发 前端开发
基于若依的ruoyi-nbcio流程管理系统中自定义业务流程发布动态更新业务流程关联信息
基于若依的ruoyi-nbcio流程管理系统中自定义业务流程发布动态更新业务流程关联信息
139 2
|
9月前
|
移动开发 前端开发
基于若依的ruoyi-nbcio流程管理系统自定义业务回写状态的一种新方法(一)
基于若依的ruoyi-nbcio流程管理系统自定义业务回写状态的一种新方法(一)
106 1
|
9月前
|
前端开发 数据库
基于若依的ruoyi-nbcio流程管理系统增加流程节点配置(二)
基于若依的ruoyi-nbcio流程管理系统增加流程节点配置(二)
158 1
|
9月前
|
移动开发 前端开发
基于若依的ruoyi-nbcio流程管理系统自定义业务实现一种简单的动态任务标题(续)
基于若依的ruoyi-nbcio流程管理系统自定义业务实现一种简单的动态任务标题(续)
63 1
|
9月前
|
移动开发 前端开发
基于若依的ruoyi-nbcio流程管理系统自定义业务实现一种简单的动态任务标题需求
基于若依的ruoyi-nbcio流程管理系统自定义业务实现一种简单的动态任务标题需求
115 1
|
9月前
|
移动开发 前端开发
基于若依的ruoyi-nbcio流程管理系统一种简单的动态表单模拟测试实现(三)
基于若依的ruoyi-nbcio流程管理系统一种简单的动态表单模拟测试实现(三)
93 2