欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

springboot2.5.2与 flowable6.6.0整合流程引擎应用分析

程序员文章站 2022-03-09 11:10:00
1.pom org.springframework.boot

1.pom

<parent>
        <groupid>org.springframework.boot</groupid>
        <artifactid>spring-boot-starter-parent</artifactid>
        <version>2.5.2</version>
        <relativepath /> <!-- lookup parent from repository -->
    </parent>


    <properties>
        <project.build.sourceencoding>utf-8</project.build.sourceencoding>
        <project.reporting.outputencoding>utf-8</project.reporting.outputencoding>
        <java.version>1.8</java.version>
        <flowable.version>6.6.0</flowable.version>
    </properties>

         <!--flowable工作流依赖-->
        <dependency>
            <groupid>org.flowable</groupid>
            <artifactid>flowable-spring-boot-starter</artifactid>
            <version>${flowable.version}</version>
        </dependency>
         <!-- https://mvnrepository.com/artifact/org.flowable/flowable-json-converter -->
        <dependency>
            <groupid>org.flowable</groupid>
            <artifactid>flowable-json-converter</artifactid>
            <version>${flowable.version}</version>
        </dependency>
        <!-- app 依赖 包含 rest,logic,conf -->
        <dependency>
            <groupid>org.flowable</groupid>
            <artifactid>flowable-ui-modeler-rest</artifactid>
            <version>${flowable.version}</version>
        </dependency>
        <dependency>
            <groupid>org.flowable</groupid>
            <artifactid>flowable-ui-modeler-logic</artifactid>
            <version>${flowable.version}</version>
            <exclusions>
                <exclusion>
                    <groupid>org.apache.logging.log4j</groupid>
                    <artifactid>log4j-slf4j-impl</artifactid>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupid>org.flowable</groupid>
            <artifactid>flowable-ui-modeler-conf</artifactid>
            <version>${flowable.version}</version>
        </dependency>

2.flowableconfig配置类

package org.fh.config;

import org.flowable.spring.springprocessengineconfiguration;
import org.flowable.spring.boot.engineconfigurationconfigurer;
import org.springframework.context.annotation.configuration;
import org.springframework.stereotype.controller;

/**
 * 说明:flowable配置
 * 作者:fh admin
 * from:fhadmin.cn
 */
@controller
@configuration
public class flowableconfig implements engineconfigurationconfigurer<springprocessengineconfiguration> {
    
    @override
    public void configure(springprocessengineconfiguration engineconfiguration) {
        engineconfiguration.setactivityfontname("宋体");
        engineconfiguration.setlabelfontname("宋体");
        engineconfiguration.setannotationfontname("宋体");
    }
    
}
3.重写 securityutils 重构流程编辑器获取用户信息

package org.flowable.ui.common.security;

import org.fh.util.jurisdiction;
import org.flowable.common.engine.api.flowableillegalstateexception;
import org.flowable.idm.api.user;
import org.flowable.ui.common.model.remoteuser;
import org.springframework.security.core.authentication;
import org.springframework.security.core.context.securitycontext;
import org.springframework.security.core.context.securitycontextholder;

import java.util.arraylist;
import java.util.list;

/**
 * 说明:重构流程编辑器获取用户信息
 * 作者:fh admin
 * from:fhadmin.cn
 */
public class securityutils {

    private static user assumeuser;
    
    private static securityscopeprovider securityscopeprovider = new flowablesecurityscopeprovider();

    private securityutils() {
    }

    /**
     * get the login of the current user.
     */
    public static string getcurrentuserid() {
        user user = getcurrentuserobject();
        if (user != null) {
            return user.getid();
        }
        return null;
    }

    /**
     * @return the {@link user} object associated with the current logged in user.
     */
    public static user getcurrentuserobject() {
        if (assumeuser != null) {
            return assumeuser;
        }

        remoteuser user = new remoteuser();
        user.setid(jurisdiction.getusername());
        user.setdisplayname(jurisdiction.getname());
        user.setfirstname(jurisdiction.getname());
        user.setlastname(jurisdiction.getname());
        user.setemail("admin@flowable.com");
        user.setpassword("123456");
        list<string> pris = new arraylist<>();
        pris.add(defaultprivileges.access_modeler);
        pris.add(defaultprivileges.access_idm);
        pris.add(defaultprivileges.access_admin);
        pris.add(defaultprivileges.access_task);
        pris.add(defaultprivileges.access_rest_api);
        user.setprivileges(pris);
        return user;
    }
    
    public static void setsecurityscopeprovider(securityscopeprovider securityscopeprovider) {
        securityutils.securityscopeprovider = securityscopeprovider;
    }

    public static securityscope getcurrentsecurityscope() {
        securitycontext securitycontext = securitycontextholder.getcontext();
        if (securitycontext != null && securitycontext.getauthentication() != null) {
            return getsecurityscope(securitycontext.getauthentication());
        }
        return null;
    }

    public static securityscope getsecurityscope(authentication authentication) {
        return securityscopeprovider.getsecurityscope(authentication);
    }

    public static securityscope getauthenticatedsecurityscope() {
        securityscope currentsecurityscope = getcurrentsecurityscope();
        if (currentsecurityscope != null) {
            return currentsecurityscope;
        }
        throw new flowableillegalstateexception("user is not authenticated");
    }

    public static void assumeuser(user user) {
        assumeuser = user;
    }

    public static void clearassumeuser() {
        assumeuser = null;
    }
}

工作流模块----------------www.fhadmin.cn---------------

1.模型管理:web在线流程设计器、导入导出xml、复制流程、部署流程

2.流程管理:导入导出流程资源文件、查看流程图、根据流程实例反射出流程模型、激活挂起

3.运行中流程:查看流程信息、当前任务节点、当前流程图、作废暂停流程、指派待办人、*跳转

4.历史的流程:查看流程信息、流程用时、流程状态、查看任务发起人信息

5.待办任务:查看本人个人任务以及本角色下的任务、办理、驳回、作废、指派一下代理人

6.已办任务:查看自己办理过的任务以及流程信息、流程图、流程状态(作废 驳回 正常完成)

办理任务时候可以选择用户进行抄送,就是给被抄送人发送站内信通知当前审批意见以及备注信息

注:当办理完当前任务时,下一任务待办人会即时通讯收到新任务消息提醒,当作废和完结任务时,任务发起人会收到站内信消息通知

到此这篇关于springboot2.5.2与 flowable6.6.0整合流程引擎应用分析的文章就介绍到这了,更多相关springboot整合 flowable内容请搜索以前的文章或继续浏览下面的相关文章希望大家以后多多支持!