### Start a Workflow Instance Source: https://www.warm-flow.com/master/other/news/upgrade/5.html Initiates a new workflow instance. Requires a workflow definition ID and user context. ```java public void startFlow() { System.out.println("已开启的流程实例id:" + insService.start("1", getUser()).getId()); } ``` -------------------------------- ### Gateway Route Configuration Source: https://www.warm-flow.com/master/primary/designerIntroduced.html Configures a route for the RuoYi-Cloud gateway service. This example sets up a route for the 'ruoyi-flow' service, mapping paths starting with '/flow/**'. ```yaml spring: cloud: gateway: routes: # 流程服务 - id: ruoyi-flow uri: lb://ruoyi-flow predicates: - Path=/flow/** filters: - StripPrefix=1 ``` -------------------------------- ### Spring Security Configuration for Warm-Flow UI Source: https://www.warm-flow.com/master/other/news/upgrade/3.html Configure Spring Security to allow unauthenticated access to Warm-Flow UI paths. This example shows how to permit `/warm-flow-ui/**` while requiring authentication for other requests. ```java @Bean protected SecurityFilterChain filterChain(HttpSecurity httpSecurity) throws Exception { return httpSecurity ....... // 注解标记允许匿名访问的url .authorizeHttpRequests((requests) -> { // 后端请求,静态资源,可匿名访问 requests.antMatchers("/warm-flow-ui/**").permitAll() // 除上面外的所有请求全部需要鉴权认证 .anyRequest().authenticated(); }) ....... .build(); } ``` -------------------------------- ### Global Listener Implementation Source: https://www.warm-flow.com/master/advanced/listener.html Implements the GlobalListener interface to handle various workflow events globally across the system. This includes start, assignment, finish, and create events. ```java /** * 全局监听器: 整个系统只有一个,任务开始、分派、完成和创建时期执行 * * @author warm * @since 2024/11/17 */ @Component public class CustomGlobalListener implements GlobalListener { private static final Logger log = LoggerFactory.getLogger(CustomGlobalListener.class); /** * 开始监听器,任务开始办理时执行 * @param listenerVariable 监听器变量 */ public void start(ListenerVariable listenerVariable) { log.info("全局开始监听器开始执行......"); log.info("全局开始监听器执行结束......"); } /** * 分派监听器,动态修改代办任务信息 * @param listenerVariable 监听器变量 */ public void assignment(ListenerVariable listenerVariable) { log.info("全局分派监听器开始执行......"); log.info("全局分派监听器执行结束......"); } /** * 完成监听器,当前任务完成后执行 * @param listenerVariable 监听器变量 */ public void finish(ListenerVariable listenerVariable) { log.info("全局完成监听器开始执行......"); log.info("全局完成监听器执行结束......"); } /** * 创建监听器,任务创建时执行 * @param listenerVariable 监听器变量 */ public void create(ListenerVariable listenerVariable) { log.info("全局创建监听器开始执行......"); log.info("全局创建监听器执行结束......"); } } ``` -------------------------------- ### HandlerSelectService Interface Definition Source: https://www.warm-flow.com/master/other/news/upgrade/3.html Defines the interface for fetching assignee permission data for the workflow designer. It includes methods to get permission types and a list of assignees based on query parameters. ```java /** * 流程设计器-获取办理人权限设置列表接口 * * @author warm */ public interface HandlerSelectService { /** * 获取办理人权限设置列表tabs页签, 如:用户、角色和部门等 * @return tabs页签 */ List getHandlerType(); /** * 获取办理人权限设置列表结果,如:用户列表、角色列表、部门列表等 * @param query 查询参数 * @return 结果 */ List getHandlerSelect(HandlerQuery query); } ``` -------------------------------- ### HandlerSelectService Interface Definition Source: https://www.warm-flow.com/master/primary/designerIntroduced.html Defines the interface for retrieving assignee (handler) information for the process designer. It includes methods to get assignee types (tabs) and a list of assignees based on query parameters. ```java /** * 流程设计器-获取办理人权限设置接口 * * @author warm */ public interface HandlerSelectService { /** * 获取办理人权限设置列表tabs页签, 如:用户、角色和部门等 * @return tabs页签 */ List getHandlerType(); /** * 获取办理人权限设置列表结果,如:用户列表、角色列表、部门列表等 * @param query 查询参数 * @return 结果 */ List getHandlerSelect(HandlerQuery query); } ``` -------------------------------- ### Deploy Workflow from XML File Source: https://www.warm-flow.com/master/other/news/upgrade/5.html Deploys a workflow by reading its definition from an XML file. Ensure the file path is correct. ```java public void deployFlow() throws Exception { String path = "/Users/minliuhua/Desktop/mdata/file/IdeaProjects/min/hh-vue/hh-admin/src/main/resources/leaveFlow-serial.xml"; System.out.println("已部署流程的id:" + defService.importXml(new FileInputStream(path)).getId()); } ``` -------------------------------- ### 前后端不分离 - 后端接口 Source: https://www.warm-flow.com/master/primary/chart_manage.html 在前后端不分离的架构中,可以通过后端接口直接访问流程图页面。此示例展示了Spring Boot Controller的实现方式。 ```java @Controller @RequestMapping("/warm-flow") public class WarmFlowController { @GetMapping() public String index(String insId) { return redirect("/warm-flow-ui/index.html?id=" + insId + "&type=" + FlowChart); } } ``` -------------------------------- ### Transition Workflow Instance by Instance ID Source: https://www.warm-flow.com/master/other/news/upgrade/5.html Advances a workflow instance to the next step using its instance ID. Allows specifying skip type and permissions. ```java public void skipFlow() throws Exception { // 通过实例id流转 Instance instance = insService.skipByInsId(1219286332141080576L, getUser().skipType(SkipType.PASS.getKey()) .permissionFlag(Arrays.asList("role:1", "role:2"))); System.out.println("流转后流程实例:" + instance.toString()); } ``` -------------------------------- ### Listener List Service Implementation Source: https://www.warm-flow.com/master/advanced/listener.html Provides an implementation for the ListenerListService interface, returning a predefined list of listeners with their event type, class name, and description. ```java /** * 获取监听器列表 * * @author warm * @since 2026/3/20 */ @Service public class ListenerListServiceImpl implements ListenerListService { @Override public List listenerList() { List listenerList = new ArrayList<>(); listenerList.add(new ListenerVo("create", "com.ruoyi.system.listener.AutoApprovalListener", "超时自动审批监听器")); listenerList.add(new ListenerVo("finish", "com.ruoyi.system.listener.HttplListener", "远程请求监听器")); listenerList.add(new ListenerVo("finish", "com.ruoyi.system.listener.ScriptlListener", "脚本监听器")); listenerList.add(new ListenerVo("start", "com.ruoyi.system.listener.StartListener", "开始监听器")); listenerList.add(new ListenerVo("assignment", "com.ruoyi.system.listener.AssignmentListener", "分派监听器")); listenerList.add(new ListenerVo("finish", "com.ruoyi.system.listener.FinishListener", "完成监听器")); listenerList.add(new ListenerVo("creat", "com.ruoyi.system.listener.CreateListener", "创建监听器")); return listenerList; } } ``` -------------------------------- ### Warm Flow Tenant Configuration (YAML) Source: https://www.warm-flow.com/master/advanced/tenant.html Configure the Warm Flow workflow properties, including the path to the global tenant handler. This allows for centralized tenant management. ```yaml # warm-flow工作流配置 warm-flow: # 全局租户处理器(可通过配置文件注入,也可用@Bean/@Component方式 tenant_handler_path: org.dromara.warm.flow.core.test.handle.CustomTenantHandler ``` -------------------------------- ### 打开新标签页加载流程图 Source: https://www.warm-flow.com/master/primary/chart_manage.html 使用JavaScript和jQuery的$.modal.openTab方法在新标签页中打开流程图设计器。需要提供流程图的URL。 ```javascript function detail(dictId) { var url = prefix + '/detail/' + dictId; $.modal.openTab("字典数据", "/warm-flow-ui/index.html?id=1839683148936663047&type=FlowChart"); } ``` -------------------------------- ### YAML Configuration for Data Fillers Source: https://www.warm-flow.com/master/primary/datafillhandler.html Configure the data filler path in your application's YAML file to use a custom implementation. This allows Warm-Flow to use your custom logic instead of the default. ```yaml # warm-flow工作流配置 warm-flow: # 填充器,内部有默认实现,如果不满足实际业务,可通过此配置自定义实现 data-fill-handler-path: com.ruoyi.system.handle.CustomDataFillHandler ``` -------------------------------- ### Add Gitee Repository to pom.xml Source: https://www.warm-flow.com/master/other/news/news/2.html Configure your project's `pom.xml` to include the Gitee repository for dependency resolution. Ensure that your Maven `settings.xml` does not mirror all repositories if this configuration is not taking effect. ```xml Gitee-Warm-Flow https://gitee.com/min290/maven-repository/raw/main/releases ``` -------------------------------- ### Encourage GitHub Stars Source: https://www.warm-flow.com/master/other/news/news/n-9.html A call to action for developers to star the project on Gitee to support its continued development and longevity. ```markdown 希望一键三连,你的⭐️ Star ⭐️是我持续开发的动力,项目也活的更长~ ``` -------------------------------- ### Chart Info Configuration Source: https://www.warm-flow.com/master/primary/chart_manage.html Configuration object for setting text color and informational messages within a chart. Includes styling for prefixes, content, and rows of the info messages. ```javascript color: "#333" /* 深色文字 */ }, info: [ /* 提示信息列表 */ { prefix: "任务名称: ", /* 第一条提示信息前缀 */ prefixStyle: { fontWeight: "bold" }, /* 第一条提示信息前缀样式, 对应是span标签的样式 */ content: "组长审批", /* 第一条提示信息内容 */ contentStyle: { /* 第一条提示信息内容样式, 对应是span标签的样式 */ border: '1px solid #d1e9ff', backgroundColor: "#e8f4ff", padding: "4px 8px", borderRadius: "4px" }, rowStyle: { /* 第一条提示信息行样式, 对应是p标签的样式 */ fontWeight: "bold", margin: "0 0 6px 0", padding: "0 0 8px 0", borderBottom: "1px solid #ccc" } }, { prefix: "负责人: ", prefixStyle: { fontWeight: "bold" }, content: "李四", contentStyle: {}, rowStyle: {} } ] } ``` -------------------------------- ### Transition Workflow Instance to a Specific Node Source: https://www.warm-flow.com/master/other/news/upgrade/5.html Jumps a workflow instance to a designated node identified by its code. Requires instance ID, user context, and node code. ```java public void skipAnyNode() throws Exception { // 跳转到指定节点 Instance instance = insService.skip(1219286332145274880L, getUser().skipType(SkipType.PASS.getKey()) .permissionFlag(Arrays.asList("role:1", "role:2")).nodeCode("4")); System.out.println("流转后流程实例:" + instance.toString()); } ``` -------------------------------- ### Form Path Service Implementation Source: https://www.warm-flow.com/master/primary/designerIntroduced.html Provides an implementation for querying custom form paths, returning a list of Tree objects. Ensure the 'parentId' field is set for tree structure generation. ```java /** * 自定义表单路径服务 * * @author warm * @since 2025/10/22 */ @Service public class FormPathServiceImpl implements FormPathService { @Override public List queryFormPath() { List trees = new ArrayList<>(); trees.add(new Tree("1", "表单1", null, null)); trees.add(new Tree("1-1", "表单1-1", "1", null)); trees.add(new Tree("2", "表单2", null, null)); trees.add(new Tree("2-1", "表单2-1", "2", null)); trees.add(new Tree("3", "表单3", null, null)); return trees; } } ``` -------------------------------- ### Maven Profile for Gitee Repository Source: https://www.warm-flow.com/master/other/news/news/2.html This Maven profile configures the `maven-source-plugin` and `maven-javadoc-plugin` for packaging sources and Javadocs. It also defines `distributionManagement` settings to upload artifacts to a local Gitee repository path for snapshots and releases. ```xml gitee org.apache.maven.plugins maven-source-plugin 2.2.1 attach-sources jar-no-fork org.apache.maven.plugins maven-javadoc-plugin 2.10.4 -Xdoclint:none true UTF-8 UTF-8 UTF-8 attach-javadocs jar gitee-snapshots file:D:/IdeaProjects/min/warm-flow-repo/snapshots gitee-releases releases file:D:/IdeaProjects/min/warm-flow-repo/releases ``` -------------------------------- ### 前后端不分离 - 前端直接访问 Source: https://www.warm-flow.com/master/primary/chart_manage.html 在前后端不分离的场景下,前端可以直接通过URL访问流程图页面。URL格式为 `ip:port/warm-flow-ui/index.html?id=${insId}&type=FlowChart`。 ```html /warm-flow-ui/index.html?id=1839683148936663047&type=FlowChart ``` -------------------------------- ### Warm Flow Tenant Handler Bean Configuration (Java) Source: https://www.warm-flow.com/master/advanced/tenant.html Defines a Java Bean for the global tenant handler, allowing it to be managed by the Spring container. This is an alternative to YAML configuration. ```java @Configuration public class WarmFlowConfig { /** * 全局租户处理器(可通过配置文件注入,也可用@Bean/@Component方式 */ @Bean public TenantHandler tenantHandler() { return new CustomTenantHandler(); } } ``` -------------------------------- ### Ignore White Properties Configuration Source: https://www.warm-flow.com/master/primary/designerIntroduced.html Defines properties for whitelisting paths that the gateway should not validate. Use this to specify URLs that should be freely accessible. ```java /** * 放行白名单配置 * * @author RuoYi */ @Configuration @RefreshScope @ConfigurationProperties(prefix = "security.ignore") public class IgnoreWhiteProperties { /** * 放行白名单配置,网关不校验此处的白名单 */ private List whites = new ArrayList<>(); public List getWhites() { return whites; } public void setWhites(List whites) { this.whites = whites; } } ``` -------------------------------- ### Category Service Implementation Source: https://www.warm-flow.com/master/primary/designerIntroduced.html Provides an implementation for querying category data, returning a list of Tree objects. Ensure the 'parentId' field is set for tree structure generation. ```java /** * 分类服务 * * @author warm * @since 2025/6/24 */ @Service public class CategoryServiceImpl implements CategoryService { @Override public List queryCategory() { List trees = new ArrayList<>(); trees.add(new Tree("1", "分类1", null, null)); trees.add(new Tree("1-1", "分类1-1", "1", null)); trees.add(new Tree("2", "分类2", null, null)); trees.add(new Tree("2-1", "分类2-1", "2", null)); trees.add(new Tree("3", "分类3", null, null)); return trees; } } ``` -------------------------------- ### Custom Data Filler Implementation Source: https://www.warm-flow.com/master/primary/datafillhandler.html Implement the DataFillHandler interface to customize ID generation, insert, and update logic. This is useful when default rules do not meet business requirements. ```java public class CustomDataFillHandler implements DataFillHandler { @Override public void idFill(Object object) { RootEntity entity = (RootEntity) object; if (ObjectUtil.isNotNull(entity)) { if (Objects.isNull(entity.getId())) { entity.setId(IdUtils.nextId()); } } } @Override public void insertFill(Object object) { RootEntity entity = (RootEntity) object; if (ObjectUtil.isNotNull(entity)) { entity.setCreateTime(ObjectUtil.isNotNull(entity.getCreateTime()) ? entity.getCreateTime() : new Date()); entity.setUpdateTime(ObjectUtil.isNotNull(entity.getUpdateTime()) ? entity.getUpdateTime() : new Date()); PermissionHandler permissionHandler = FlowEngine.permissionHandler(); String handler = null; if (permissionHandler != null) { handler = permissionHandler.getHandler(); } entity.setCreateBy(StringUtils.isNotEmpty(handler) ? handler : entity.getCreateBy()); entity.setUpdateBy(StringUtils.isNotEmpty(handler) ? handler : entity.getUpdateBy()); } } @Override public void updateFill(Object object) { RootEntity entity = (RootEntity) object; if (ObjectUtil.isNotNull(entity)) { entity.setUpdateTime(ObjectUtil.isNotNull(entity.getUpdateTime()) ? entity.getUpdateTime() : new Date()); PermissionHandler permissionHandler = FlowEngine.permissionHandler(); String handler = null; if (permissionHandler != null) { handler = permissionHandler.getHandler(); } entity.setUpdateBy(StringUtils.isNotEmpty(handler) ? handler : entity.getUpdateBy()); } } } ``` -------------------------------- ### Custom Tenant Handler Implementation Source: https://www.warm-flow.com/master/advanced/tenant.html A custom implementation of the TenantHandler interface. This component provides the tenant ID, typically retrieved from a system utility. ```java /** * 全局租户处理器(可通过配置文件注入,也可用@Bean/@Component方式 * * @author warm */ @Component public class CustomTenantHandler implements TenantHandler { @Override public String getTenantId() { // 这里返回系统中的当前办理人的租户ID,一般会有工具类获取 return "000000"; } } ``` -------------------------------- ### Form Path Service Interface Source: https://www.warm-flow.com/master/primary/designerIntroduced.html Defines the interface for querying custom form paths. The implementation should return a List collection. ```java /** * 自定义表单路径接口 * * @author warm * @since 2025/10/22 */ public interface FormPathService { /** * 查询自定义表单路径 * * @return 自定义表单路径 */ List queryFormPath(); } ``` -------------------------------- ### Vue2 集成流程图查看器 Source: https://www.warm-flow.com/master/primary/chart_manage.html 在Vue2项目中使用iframe嵌入流程图查看器。需要传入流程实例ID,并配置后端API地址和用户Token。 ```vue