001/*
002 *    Copyright 2024-2025, Warm-Flow (290631660@qq.com).
003 *
004 *    Licensed under the Apache License, Version 2.0 (the "License");
005 *    you may not use this file except in compliance with the License.
006 *    You may obtain a copy of the License at
007 *
008 *       https://www.apache.org/licenses/LICENSE-2.0
009 *
010 *    Unless required by applicable law or agreed to in writing, software
011 *    distributed under the License is distributed on an "AS IS" BASIS,
012 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 *    See the License for the specific language governing permissions and
014 *    limitations under the License.
015 */
016package org.dromara.warm.flow.core.service;
017
018import org.dromara.warm.flow.core.dto.FlowParams;
019import org.dromara.warm.flow.core.entity.Instance;
020import org.dromara.warm.flow.core.orm.service.IWarmService;
021
022import java.util.List;
023
024/**
025 * 流程实例Service接口
026 *
027 * @author warm
028 * @since 2023-03-29
029 */
030public interface InsService extends IWarmService<Instance> {
031
032    /**
033     * 传入业务id开启流程
034     *
035     * @param businessId: 业务id[必传]
036     * @param flowParams: 包含流程相关参数的对象
037     *                    - flowCode: 流程编码 [必传]
038     *                    - handler: 办理人唯一标识[建议传]
039     *                    - variable: 流程变量[按需传输]
040     *                    - flowStatus: 流程状态,自定义流程状态[按需传输]
041     *                    - ext: 扩展字段,预留给业务系统使用[按需传输]
042     * @return 流程实例
043     */
044    Instance start(String businessId, FlowParams flowParams);
045
046
047    /**
048     * 根据实例id,流程跳转,一般是开始节点后第一个节点,用来提交申请,此时不可有同时两个待办任务
049     *
050     * @param instanceId:流程实例id[必传]
051     * @param flowParams:包含流程相关参数的对象 - skipType:跳转类型(PASS审批通过 REJECT退回) [必传]
052     *                               - nodeCode: 办理人权限标识,比如用户,角色,部门等,未设置办理人或者ignore为true可不传 [按需传输]
053     *                               - permissionFlag: 办理人权限标识,比如用户,角色,部门等[只有未设置办理人时可不传]
054     *                               - message: 审批意见[按需传输]
055     *                               - handler: 办理人唯一标识[建议传]
056     *                               - variable: 流程变量[按需传输,跳转条件放入流程变量<互斥网关必传>]
057     *                               - flowStatus: 流程状态,自定义流程状态[按需传输]
058     *                               - ignore   转办忽略权限校验,默认不忽略(true:忽略,false:不忽略)[按需传输]
059     * @return 流程实例
060     */
061    Instance skipByInsId(Long instanceId, FlowParams flowParams);
062
063    /**
064     * 终止流程,提前结束流程,将所有待办任务转历史
065     *
066     * @param instanceId:流程实例id[必传]
067     * @param flowParams:包含流程相关参数的对象 - message: 审批意见  [按需传输]
068     *                               - handler: 办理人唯一标识[建议传]
069     *                               - flowStatus: 流程状态,自定义流程状态[按需传输]
070     *                               - ignore   转办忽略权限校验,默认不忽略(true:忽略,false:不忽略)[按需传输]
071     */
072    Instance termination(Long instanceId, FlowParams flowParams);
073
074    /**
075     * 根据实例ids,删除流程
076     *
077     * @param instanceIds: 流程实例集合[必传]
078     */
079    boolean remove(List<Long> instanceIds);
080
081    /**
082     * 激活实例
083     * @param id 流程实例id: [必传]
084     */
085    boolean active(Long id);
086
087    /**
088     * 挂起实例,流程实例挂起后,该流程实例无法继续流转
089     * @param id 流程实例id: [必传]
090     */
091    boolean unActive(Long id);
092}