介绍

主功能流程上某个节点提交之后启动子功能流程。

需求描述

在主子功能中,如【采购申请】与【采购明细】,在采购申请流程在【组长】这个任务节点提交后启动【采购明细】子功能上绑定的流程,并且在【经理】这个多人节点提交的时候判断【采购明细】子功能的流程是否审批结束,审批结束就可以执行下一步,审批未结束就阻断不能提交。

实现步骤

1.创建【采购申请】与【采购明细】主子功能

2.创建采购申请与采购明细两个流程

3.设置【采购申请】流程中【经理】的任务节点可处理人来自表单字段【审批人ID】

4.在【采购明细】功能中通过人员选择设置审批人,方便发起子流程时指定人员

5.在【采购申请】这个流程中【组长】的任务节点,设置节点【提交之后】事件,执行策略是【自定义方法】,【业务Bean】是workFlowShengFeiService

6.在【采购申请】这个流程中【经理】的多人审批任务节点,设置【提交】按钮动作事件,判断子功能的流程是否审批结束

最终效果

  • 【采购申请】主功能流程在【组长】提交之后启动子功能流程之后,子功能审批状态与首页待办数据变化

  • 【采购申请】主功能流程目前在【经理】这个节点,提交前需要判断子功能的流程是否审批结束,如果没结束给出提示

相关代码

  • 后端workFlowShengFeiService
package com.je.business.wf;

import com.je.common.base.service.MetaService;
import com.je.common.base.util.SecurityUserHolder;
import com.je.workflow.model.*;
import com.je.workflow.rpc.dictionary.WorkFlowExecuteCustomMethodService;
import com.je.workflow.rpc.workflow.ProcessInfoRpcService;
import org.apache.servicecomb.provider.pojo.RpcSchema;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 在某个节点提交后事件中获取到子功能数据并进行启动
 */

@RpcSchema(schemaId = "workFlowShengFeiService")

2.2.3以后的版本用@Service注解
@Service(value = "workFlowShengFeiService")

public class MyWorkFlowShengFeiServiceImpl implements WorkFlowExecuteCustomMethodService {

    //注入ProcessInfoRpcService rpc接口
    @Autowired
    private ProcessInfoRpcService processInfoRpcService;
    @Autowired
    private MetaService metaService;

    @Override
    public void executeCustomMethod(EventSubmitDTO eventSubmitDTO) {
        //获取流程提交信息中的dyanbean
        Map<String, Object> map = eventSubmitDTO.getDynaBean();
        //根据主表的主键作为外键去查子表数据
        List<Map<String, Object>> cgmxlist = metaService.selectSql("SELECT * FROM SF_DEMO_CGMX WHERE SF_DEMO_CGSQ_ID={0}", map.get("SF_DEMO_CGSQ_ID").toString());
        if (cgmxlist != null && cgmxlist.size() > 0) {
            //子表是多条数据,进行循环
            for (Map<String, Object> cgxxmap : cgmxlist) {
                //1.获取表单流程按钮和表单控制信息
                //设置当前登录人账号
                String deptId = SecurityUserHolder.getCurrentAccount().getDeptId();
                String code = SecurityUserHolder.getCurrentAccountCode();
                String name = SecurityUserHolder.getCurrentAccountName();
                String realUserId = SecurityUserHolder.getCurrentAccountRealUserId();
                AccountVo account = new AccountVo.Builder().deptId(deptId).code(code).name(name).realUserId(realUserId).build();
                ButtonsVo buttonsVo = new ButtonsVo.Builder().prod("test").funcCode("SF_DEMO_CGMX").tableCode("SF_DEMO_CGMX")
                        .beanId(cgxxmap.get("SF_DEMO_CGMX_ID").toString()).account(account).build();
                List<Map<String, Object>> buttons = processInfoRpcService.getButtons(buttonsVo);
                //获取想要调用的流程的pdid
                ArrayList<Map<String, Object>> arrayList = (ArrayList) buttons.get(0).get("buttonList");
                String pdid = arrayList.get(0).get("pdid").toString();
                //2.获取提交的节点信息和人员信息
                SubmitOutGoingNodeVo submitOutGoingNodeVo = new SubmitOutGoingNodeVo.Builder().taskId("").pdid(pdid).prod("test").beanId(cgxxmap.get("SF_DEMO_CGMX_ID").toString()).tableCode("SF_DEMO_CGMX").account(account).build();
                List<ProcessNextNodeInfoVo> submitOutGoingNode = processInfoRpcService.getSubmitOutGoingNode(submitOutGoingNodeVo);
                //获取流转的目标节点ID  name 目标顺序流
                String target = submitOutGoingNode.get(0).getTarget();
                String nodeId = submitOutGoingNode.get(0).getNodeId();
                String nodeName = submitOutGoingNode.get(0).getNodeName();
                String assignee = cgxxmap.get("JE_RBAC_ACCOUNTDEPT_ID").toString();
                String assigneeName = cgxxmap.get("CGMX_USER_NAME").toString();
                //3.执行流程按钮操作
                Map<String, Object> operationCustomerParam = new HashMap<>();
                //设置节点,人员信息
                operationCustomerParam.put("assignee", "[{\"nodeId\":\"" + nodeId + "\",\"nodeName\":\"" + nodeName + "\",\"assignee\":\"" + assignee + "\",\"assigneeName\":\"" + assigneeName + "\"}]");
                //设置目标信息
                operationCustomerParam.put("target", target);
                operationCustomerParam.put("taskId", "");
                operationCustomerParam.put("piid", "");
                //具体操作类型
                operationCustomerParam.put("opinionType", "");
                //审批意见
                operationCustomerParam.put("comment", "同意");
                operationCustomerParam.put("sequentials", "");
                operationCustomerParam.put("isJump", "0");
                ButtonOperateVo buttonOperateVo = new ButtonOperateVo.Builder().account(account).operationId("processEmptySponsorOperation").prod("test").funcCode("SF_DEMO_CGMX").pdid(pdid).beanId(cgxxmap.get("SF_DEMO_CGMX_ID").toString()).tableCode("SF_DEMO_CGMX").funcId("").operationCustomerParam(operationCustomerParam).build();
                Map<String, Object> map1 = processInfoRpcService.operate(buttonOperateVo);
                System.out.println(map1.toString());
            }
        }
    }
}
  • 【采购申请】这个流程中【经理】的多人审批任务节点中提交按钮事件
const {$func} = EventOptions;
const ui = JE.useUi();
const {ajax,encode, decode} = JE.useUtils();
const utils = JE.useUtils(); // 工具库
let deferred = utils.createDeferred(); // Promise异步队列函数
//获取主功能的主键做为查询的子表的外键
let SF_DEMO_CGSQ_ID =  $func.getFuncForm().getValues().SF_DEMO_CGSQ_ID;
ajax({
      url:"/je/common/load",
      params:{
         tableCode:"SF_DEMO_CGMX",
         funcCode:"SF_DEMO_CGMX",
         j_query:'[{"type":"=","code":"SF_DEMO_CGSQ_ID","value":"'+SF_DEMO_CGSQ_ID+'","cn":"and"}]'
      },
      headers:{pd:"test"}
   }).then((resObj)=>{
      const {rows} = resObj.data;
      //如果子功能无数据继续执行下一步
      if(rows.length <= 0) {
         deferred.resolve();
      };
      //如果数据中有未结束的流程,isEnd返回ture ,阻断提交并且弹出提示信息
      const isEnd = rows.some(item => item.SY_AUDFLAG !='ENDED');
      isEnd && ui.Modal.alert('子功能流程没结束,不能提交!','error') && deferred.reject();
      //isEnd返回false,继续执行下一步
      !isEnd && deferred.resolve();
   });
return deferred.promise;
最后编辑: 于春辉  文档更新时间: 2024-11-08 17:00   作者:呼丽华