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.chart.FlowChart; 019import org.dromara.warm.flow.core.entity.Definition; 020import org.dromara.warm.flow.core.orm.service.IWarmService; 021import org.dom4j.Document; 022 023import java.io.IOException; 024import java.io.InputStream; 025import java.util.List; 026 027/** 028 * 流程定义Service接口 029 * 030 * @author warm 031 * @since 2023-03-29 032 */ 033public interface DefService extends IWarmService<Definition> { 034 035 /** 036 * 导入流程定义、流程节点和流程跳转数据 037 * 038 * @param is 流程定义xml的输入流 039 */ 040 Definition importXml(InputStream is) throws Exception; 041 042 /** 043 * 保存流程节点和流程跳转数据 044 * 045 * @param def 流程定义对象 046 */ 047 void saveXml(Definition def) throws Exception; 048 049 /** 050 * 保存流程节点和流程跳转数据 051 * @param id 流程定义id 052 * @param xmlString 流程定义xml字符串 053 */ 054 void saveXml(Long id, String xmlString) throws Exception; 055 056 /** 057 * 导出流程定义(流程定义、流程节点和流程跳转数据)xml的Document对象 058 * 059 * @param id 流程定义id 060 * @return Document 061 */ 062 Document exportXml(Long id); 063 064 /** 065 * 获取流程定义xml(流程定义、流程节点和流程跳转数据)的字符串 066 * 067 * @param id 流程定义id 068 * @return xmlString 069 */ 070 String xmlString(Long id); 071 072 List<Definition> queryByCodeList(List<String> flowCodeList); 073 074 void closeFlowByCodeList(List<String> flowCodeList); 075 076 /** 077 * 新增流程定义表数据,新增后需要通过saveXml接口保存流程节点和流程跳转数据 078 * 校验后新增 079 * @param definition 流程定义对象 080 * @return boolean 081 */ 082 boolean checkAndSave(Definition definition); 083 084 /** 085 * 删除流程定义相关数据 086 * 087 * @param ids 流程定义id列表 088 * @return boolean 089 */ 090 boolean removeDef(List<Long> ids); 091 092 /** 093 * 发布流程定义 094 * 095 * @param id 流程定义id 096 * @return boolean 097 */ 098 boolean publish(Long id); 099 100 /** 101 * 取消发布流程定义 102 * 103 * @param id 流程定义id 104 * @return boolean 105 */ 106 boolean unPublish(Long id); 107 108 /** 109 * 复制流程定义 110 * 111 * @param id 流程定义id 112 * @return boolean 113 */ 114 boolean copyDef(Long id); 115 116 /** 117 * 根据流程实例ID,获取流程图的图片流(渲染颜色) 118 * 119 * @param instanceId 流程实例id 120 * @return base64编码的图片流字符串 121 */ 122 String flowChart(Long instanceId) throws IOException; 123 124 /** 125 * 根据流程实例ID,获取流程图元数据 126 * 127 * @param instanceId 流程实例id 128 * @return List<FlowChart> 129 */ 130 List<FlowChart> flowChartData(Long instanceId) throws IOException; 131 132 /** 133 * 根据流程定义ID,获取流程图的图片流(不渲染颜色) 134 * @param definitionId 流程定义id 135 * @return base64编码的图片流字符串 136 */ 137 String flowChartNoColor(Long definitionId) throws IOException; 138 139 /** 140 * 根据流程定义ID,获取流程图元数据 141 * @param definitionId 流程定义id 142 * @return List<FlowChart> 143 */ 144 List<FlowChart> flowChartNoColorData(Long definitionId) throws IOException; 145 146 /** 147 * 激活流程 148 * @param id 流程定义id 149 */ 150 boolean active(Long id); 151 152 /** 153 * 挂起流程:流程定义挂起后,相关的流程实例都无法继续流转 154 * @param id 流程定义id 155 */ 156 boolean unActive(Long id); 157}