适用版本:v3.3.6+;
目前仅提供:保存草稿、启动、审批(同意、反对、驳回、驳回上一步、驳回发起人、弃权、终止、挂起、恢复、批量同意、批量反对、批量终止、批量挂起、批量恢复);

dependency

<dependency>
    <groupId>com.lc.ibps.provider.base</groupId>
    <artifactId>ibps-provider-bpmn-client</artifactId>
</dependency>

配置说明

添加了相关依赖后直接调用即可。

API说明

保存草稿、启动接口
接口:com.lc.ibps.bpmn.api.IBpmInstService
实现:com.lc.ibps.bpmn.provider.BpmInstProvider

    /**
     * 保存草稿
     * @param request  {"parameters":[{"key":"defId","value":"793176595517931520"},{"key":"data","value":"{\"id\":\"\",\"mingZi\":\"test\"}"}]}
     * defId 流程定义ID
     * data  业务数据
     */
    public APIResult<Void> saveDraft(APIRequest request) ;

    /**
     * 启动流程实例
     * @param request {"parameters":[{"key":"defId","value":"793176595517931520"},{"key":"data","value":"{\"id\":\"\",\"mingZi\":\"test\"}"}]}
     * defId 流程定义ID
     * data  业务数据
     */
    public APIResult<Void> start(APIRequest request) ;

任务审批(同意、反对、驳回、驳回上一步、驳回发起人、弃权、终止、挂起、恢复、批量同意、批量反对、批量终止、批量挂起、批量恢复)
接口:com.lc.ibps.bpmn.api.IBpmTaskService
实现:com.lc.ibps.bpmn.provider.BpmTaskProvider

    /**
     * 处理任务-同意
     * @param agreeVo  {"opinion":"审批","taskId":"793443915633000448","data":"{\"id\":\"793443627899551744\",\"mingZi\":\"test\"}"}
     * opinion 审批意见
     * taskId 任务ID
     * data 业务数据
     */
    public APIResult<Void> agree(BpmActionAgreeVo agreeVo);

    /**
     * 处理任务-同意(批量)
     * @param agreeBatchVo {"taskIds":"793499993234210816,793436381983539200","opinion":"审批"}
     * opinion 审批意见
     * taskIds 任务ID,多个任务用英文的逗号分开
     */
    public APIResult<Void> agreeBatch(BpmActionAgreeBatchVo agreeBatchVo);

    /**
     * 处理任务-保存
     * @param saveVo {"taskId":"793500286445420544","data":"{\"id\":\"793411676668952576\",\"mingZi\":\"test2\"}"}
     * taskId 任务ID
     * data 业务数据
     */
    public APIResult<Void> save(BpmActionSaveVo saveVo);

    /**
     * 处理任务-反对
     * @param opposeVo {"opinion":"审批","taskId":"793443915633000448","data":"{\"id\":\"793443627899551744\",\"mingZi\":\"test\"}"}
     * opinion 审批意见
     * taskId 任务ID
     * data 业务数据
     */
    public APIResult<Void> oppose(BpmActionOpposeVo opposeVo);

    /**
     * 处理任务-反对
     * @param opposeBatchVo {"taskIds":"793499993234210816,793436381983539200","opinion":"审批"}
     * opinion 审批意见
     * taskIds 任务ID,多个任务用英文的逗号分开
     */
    public APIResult<Void> opposeBatch(BpmActionOpposeBatchVo opposeBatchVo);

    /**
     * 处理任务-弃权
     * @param abandonVo {"opinion":"审批","taskId":"793443915633000448","data":"{\"id\":\"793443627899551744\",\"mingZi\":\"test\"}"}
     * opinion 审批意见
     * taskId 任务ID
     * data 业务数据
     */
    public APIResult<Void> abandon(BpmActionAbandonVo abandonVo);

    /**
     * 处理任务-驳回
     * @param rejectVo {"backHandMode":"direct","destination":"","opinion":"驳回","taskId":"793498752261292032","data":"{\"id\":\"793443627899551744\",\"mingZi\":\"test\"}"}
     * backHandMode 返回模式  direct:返回当前节点/normal:按流程图流转
     * destination 目标节点,指定节点驳回使用
     * opinion 审批意见
     * taskId 任务ID
     * data 业务数据
     */
    public APIResult<Void> reject(BpmActionRejectVo rejectVo);

    /**
     * 处理任务-驳回发起人
     * @param rejectStarterVo {"backHandMode":"direct""opinion":"驳回发起人","taskId":"793499790380892160","data":"{\"id\":\"793443627899551744\",\"mingZi\":\"test\"}"}
     * backHandMode 返回模式  direct:返回当前节点/normal:按流程图流转
     * opinion 审批意见
     * taskId 任务ID
     * data 业务数据
     */
    public APIResult<Void> rejectToStarter(BpmActionRejectStarterVo rejectStarterVo);

    /**
     * 处理任务-驳回上一步
     * @param rejectPreviousVo {"backHandMode":"direct","opinion":"驳回上一步","taskId":"793499693987397632","data":"{\"id\":\"793443627899551744\",\"mingZi\":\"test\"}"}
     * backHandMode 返回模式  direct:返回当前节点/normal:按流程图流转
     * opinion 审批意见
     * taskId 任务ID
     * data 业务数据
     */
    public APIResult<Void> rejectToPrevious(BpmActionRejectPreviousVo rejectPreviousVo);

    /**
     * 终止流程
     * @param taskIds 任务ID,多个任务用英文的逗号分开
     * @param messageType 通知类型,那么就是用传入的通知类型,如果没有则获取节点的通知类型
     * @param endReason 终止原因
     */
    public APIResult<Void> doEndProcess(String taskIds, String messageType, String endReason);

    /**
     * 流程实例-挂起
     * @param taskId 任务ID
     */
    public APIResult<Void> suspendProcess(String taskId);

    /**
     * 流程实例-恢复
     * @param taskId 任务ID
     */
    public APIResult<Void> recoverProcess(String taskId);

    /**
     * 流程实例-批量挂起
     * @param taskIds 任务ID,多个任务用英文的逗号分开
     */
    public APIResult<Void> batchSuspendProcess(String taskIds);

    /**
     * 流程实例-批量恢复
     * @param taskIds 任务ID,多个任务用英文的逗号分开
     */
    public APIResult<Void> batchRecoverProcess(String taskIds);

使用示例

package com.lc.ibps.skeleton.provider;

import javax.annotation.Resource;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.lc.ibps.bpmn.api.IBpmInstService;
import com.lc.ibps.bpmn.api.IBpmTaskService;
import com.lc.ibps.bpmn.vo.BpmActionAbandonVo;
import com.lc.ibps.bpmn.vo.BpmActionAgreeBatchVo;
import com.lc.ibps.bpmn.vo.BpmActionAgreeVo;
import com.lc.ibps.bpmn.vo.BpmActionOpposeBatchVo;
import com.lc.ibps.bpmn.vo.BpmActionOpposeVo;
import com.lc.ibps.bpmn.vo.BpmActionRejectStarterVo;
import com.lc.ibps.bpmn.vo.BpmActionRejectVo;
import com.lc.ibps.bpmn.vo.BpmActionSaveVo;
import com.lc.ibps.bpmn.vo.EndProcessVo;
import com.lc.ibps.cloud.entity.APIRequest;
import com.lc.ibps.cloud.entity.APIResult;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

@Api(tags = "流程动作类", value = "流程动作类")
@RestController
@RequestMapping(value = "/action")
public class BpmnActionProvider {

    @Resource
    public IBpmInstService inst;
    @Resource
    public IBpmTaskService task;

    //保存草稿
    @ApiOperation(value = "saveDraft", notes = "saveDraft")
    @RequestMapping(value = "/saveDraft",method = RequestMethod.GET)
    public String saveDraft() {
        APIRequest request = new APIRequest();
        request.addParameters("defId", "793176595517931520");
        request.addParameters("version", "0");
        request.addParameters("data","{\"id\":\"\",\"mingZi\":\"test\"}\"}");
        APIResult<Void> result = inst.start(request);
        return result.toJsonString();
    }

    //启动
    @ApiOperation(value = "start", notes = "start")
    @RequestMapping(value = "/start",method = RequestMethod.GET)
    public String start() {
        APIRequest request = new APIRequest();
//        request.addParameters("proInstId", "793433098430709760"); //如果是草稿启动,需要参数
        request.addParameters("defId", "793176595517931520");
        request.addParameters("version", "0");
        request.addParameters("data","{\"id\":\"\",\"mingZi\":\"test\"}\"}");
        APIResult<Void> result = inst.start(request);
        return result.toJsonString();
    }

    //保存
    @ApiOperation(value = "save", notes = "save")
    @RequestMapping(value = "/save",method = RequestMethod.GET)
    public String save() {
        BpmActionSaveVo vo = new BpmActionSaveVo();
        vo.setData("{\"id\":\"793411676668952576\",\"mingZi\":\"test2\"}");
        vo.setTaskId("793436381983539200");
        APIResult<Void> result = task.save(vo);
        return result.toJsonString();
    }

    //同意
    @ApiOperation(value = "agree", notes = "agree")
    @RequestMapping(value = "/agree",method = RequestMethod.GET)
    public String agree() {
        BpmActionAgreeVo agreeVo = new BpmActionAgreeVo();
        agreeVo.setOpinion("测试数据同意");
        agreeVo.setData("{\"id\":\"793411676668952576\",\"mingZi\":\"test\"}");
        agreeVo.setTaskId("793413686562652160");
        APIResult<Void> result = task.agree(agreeVo);
        return result.toJsonString();
    }

    //反对
    @ApiOperation(value = "oppose", notes = "oppose")
    @RequestMapping(value = "/oppose",method = RequestMethod.GET)
    public String oppose() {
        BpmActionOpposeVo vo = new BpmActionOpposeVo();
        vo.setOpinion("测试数据反对");
        vo.setData("{\"id\":\"793411676668952576\",\"mingZi\":\"test\"}");
        vo.setTaskId("793413686562652160");
        APIResult<Void> result = task.oppose(vo);
        return result.toJsonString();
    }

    //驳回发起人
    @ApiOperation(value = "rejectToStart", notes = "rejectToStart")
    @RequestMapping(value = "/rejectToStart",method = RequestMethod.GET)
    public String rejectToStart() {
        BpmActionRejectStarterVo vo = new BpmActionRejectStarterVo();
        vo.setBackHandMode("direct");// normal:流程图走、direct:回到本节点
        vo.setOpinion("驳回发起人-回到本节点");
        vo.setData("{\"id\":\"793411676668952576\",\"mingZi\":\"test\"}");
        vo.setTaskId("793413686562652160");
        APIResult<Void> result = task.rejectToStarter(vo);
        return result.toJsonString();
    }

    //驳回上一步
    @ApiOperation(value = "rejectToPrevious", notes = "rejectToPrevious")
    @RequestMapping(value = "/rejectToPrevious",method = RequestMethod.GET)
    public String rejectToPrevious() {
        BpmActionRejectStarterVo vo = new BpmActionRejectStarterVo();
        vo.setBackHandMode("normal");
        vo.setOpinion("驳回上一步");
        vo.setData("{\"id\":\"793411676668952576\",\"mingZi\":\"test\"}");
        vo.setTaskId("793413686562652160");
        APIResult<Void> result = task.rejectToStarter(vo);
        return result.toJsonString();
    }

    //驳回
    @ApiOperation(value = "reject", notes = "reject")
    @RequestMapping(value = "/reject",method = RequestMethod.GET)
    public String reject() {
        // ===========================>
        // 驳回-驳回上一步-回到本节点
//        BpmActionRejectVo vo = new BpmActionRejectVo();
//        vo.setBackHandMode("direct"); // normal:流程图走、direct:回到本节点
//        vo.setOpinion("驳回-驳回上一步-回到本节点");
//        vo.setData("{\"id\":\"793411676668952576\",\"mingZi\":\"test\"}");
//        vo.setTaskId("793413686562652160");
//        APIResult<Void> result = task.reject(vo);
        // ===========================>

        // ===========================>
        // 驳回-驳回指定节点-流程图
        BpmActionRejectVo vo = new BpmActionRejectVo();
        vo.setBackHandMode("normal"); // normal:流程图走、direct:回到本节点
        vo.setDestination("Activity_171feq7");
        vo.setOpinion("驳回-驳回指定节点-流程图");
        vo.setData("{\"id\":\"793411676668952576\",\"mingZi\":\"test\"}");
        vo.setTaskId("793413686562652160");
        APIResult<Void> result = task.reject(vo);
        // ===========================>

        return result.toJsonString();
    }

    //弃权
    @ApiOperation(value = "abandon", notes = "abandon")
    @RequestMapping(value = "/abandon",method = RequestMethod.GET)
    public String abandon() {
        BpmActionAbandonVo vo = new BpmActionAbandonVo();
        vo.setOpinion("弃权");
        vo.setData("{\"id\":\"793411676668952576\",\"mingZi\":\"test\"}");
        vo.setTaskId("793413686562652160");
        APIResult<Void> result = task.abandon(vo);
        return result.toJsonString();
    }

    //终止流程/批量终止流程
    @ApiOperation(value = "doEndProcess", notes = "doEndProcess")
    @RequestMapping(value = "/doEndProcess",method = RequestMethod.GET)
    public String doEndProcess() {
        EndProcessVo vo = new EndProcessVo();
        vo.setEndReason("终止流程");
        vo.setTaskIds("793413686562652160");
        APIResult<Void> result = task.doEndProcess(vo);
        return result.toJsonString();
    }

    //挂起任务
    @ApiOperation(value = "suspendProcess", notes = "suspendProcess")
    @RequestMapping(value = "/suspendProcess",method = RequestMethod.GET)
    public String suspendProcess() {
        APIResult<Void> result = task.suspendProcess("793436381983539200");
        return result.toJsonString();
    }

    //恢复任务
    @ApiOperation(value = "recoverProcess", notes = "recoverProcess")
    @RequestMapping(value = "/recoverProcess",method = RequestMethod.GET)
    public String recoverProcess() {
        APIResult<Void> result = task.recoverProcess("793436381983539200");
        return result.toJsonString();
    }

    //批量挂起任务
    @ApiOperation(value = "batchSuspendProcess", notes = "batchSuspendProcess")
    @RequestMapping(value = "/batchSuspendProcess",method = RequestMethod.GET)
    public String batchSuspendProcess() {
        APIResult<Void> result = task.batchSuspendProcess("791270975688671234,791274746321829888");
        return result.toJsonString();
    }

    //批量恢复任务
    @ApiOperation(value = "batchRecoverProcess", notes = "batchRecoverProcess")
    @RequestMapping(value = "/batchRecoverProcess",method = RequestMethod.GET)
    public String batchRecoverProcess() {
        APIResult<Void> result = task.batchRecoverProcess("791270975688671234,791274746321829888");
        return result.toJsonString();
    }

    //批量同意
    @ApiOperation(value = "batchAgree", notes = "batchAgree")
    @RequestMapping(value = "/batchAgree",method = RequestMethod.GET)
    public String batchAgree() {
        BpmActionAgreeBatchVo vo = new BpmActionAgreeBatchVo();
        vo.setOpinion("批量同意");
        vo.setTaskIds("793443638855073792,793443606215000064");
        APIResult<Void> result = task.agreeBatch(vo);
        return result.toJsonString();
    }

    //批量反对
    @ApiOperation(value = "batchOppose", notes = "batchOppose")
    @RequestMapping(value = "/batchOppose",method = RequestMethod.GET)
    public String batchOppose() {
        BpmActionOpposeBatchVo vo = new BpmActionOpposeBatchVo();
        vo.setOpinion("批量反对");
        vo.setTaskIds("793443638855073792,793443606215000064");
        APIResult<Void> result = task.opposeBatch(vo);
        return result.toJsonString();
    }

}
文档更新时间: 2021-03-08 10:25   作者:Eddy