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.entity.Node;
019import org.dromara.warm.flow.core.orm.service.IWarmService;
020
021import java.io.Serializable;
022import java.util.Collection;
023import java.util.List;
024import java.util.Map;
025
026/**
027 * 流程节点Service接口
028 *
029 * @author warm
030 * @since 2023-03-29
031 */
032public interface NodeService extends IWarmService<Node> {
033
034    /**
035     * 根据流程编码获取流程节点集合
036     *
037     * @param flowCode 流程编码
038     * @return List<Node>
039     */
040    List<Node> getByFlowCode(String flowCode);
041
042    /**
043     * 根据流程编码获取开启的唯一流程的流程节点集合
044     *
045     * @param nodeCodes 流程节点code集合
046     * @return List<Node>
047     */
048    List<Node> getByNodeCodes(List<String> nodeCodes, Long definitionId);
049
050    /**
051     * 根据流程定义和当前节点code获取下一节点,如是网关跳过取下一节点,并行网关返回多个节点
052     * anyNodeCode不为空,则可跳转anyNodeCode节点
053     *
054     * @param definitionId  流程定义id
055     * @param nowNodeCode   当前节点code
056     * @param anyNodeCode   anyNodeCode不为空,则可跳转anyNodeCode节点(优先级最高)
057     * @param skipType      跳转类型(PASS审批通过 REJECT退回)
058     * @param variable      流程变量,下一个节点是网关需要判断跳转条件,并行网关返回多个节点
059     * @return List<Node>
060     * @author xiarg
061     * @since 2024/8/21 16:48
062     */
063    List<Node> getNextNodeList(Long definitionId, String nowNodeCode, String anyNodeCode, String skipType,
064                                     Map<String, Object> variable);
065
066    /**
067     * 根据流程定义和当前节点code获取下一节点(不考虑下个节点是网关的情况)
068     * anyNodeCode不为空,则可跳转anyNodeCode节点
069     *
070     * @param definitionId  流程定义id
071     * @param nowNodeCode   当前节点code
072     * @param anyNodeCode   anyNodeCode不为空,则可跳转anyNodeCode节点(优先级最高)
073     * @param skipType      跳转类型(PASS审批通过 REJECT退回)
074     * @return List<Node>
075     * @author xiarg
076     * @since 2024/8/21 16:48
077     */
078    Node getNextNode(Long definitionId, String nowNodeCode, String anyNodeCode, String skipType);
079
080    /**
081     * 批量删除流程节点
082     *
083     * @param defIds 需要删除的数据主键集合
084     * @return 结果
085     */
086    int deleteNodeByDefIds(Collection<? extends Serializable> defIds);
087
088    /**
089     * 校验是否网关节点,如果是重新获取新的后面的节点
090     *
091     * @param variable      流程变量
092     * @param nextNode      下一个节点
093     * @return List<Node>
094     * @author xiarg
095     * @since 2024/8/21 16:48
096     */
097    List<Node> getNextByCheckGateway(Map<String, Object> variable, Node nextNode);
098}