一款简易的Java工作流框架

一、工程简介 【一款简易的Java工作流框架】一款易于使用的工作流设计器,内置丰富的API保证工作流正常运行,数据库操作框架为mybatis-plus
一款简易的Java工作流框架
文章图片

二、安装 下载:https://gitee.com/gs_work/eas... 进入启动器目录

cd easy-process-boot-starter

通过Maven打包 安装到本地Maven仓库:
#jar包方式安装(安装安装记得用工程下的pom文件覆盖本地仓库的) mvn install:install-file -Dfile=jar包路径 -DgroupId=com.shallow.universe -DartifactId=process-spring-boot-starter -Dversion=1.0.0 -Dpackaging=jar

#在文件夹中安装 mvn clean install

导入启动器resource/mysql目录下的process.sql文件到自己的数据库 三、配置 创建SpringBoot工程引入依赖
com.shallow.universe easy-process-boot-starter 1.0.0

配置文件(application.yml)配置流程引擎参数(可选)
#后置处理器扫描路径,流程设计重置是否同步任务ID shallow: process: task-processor-packages: com.example.processor replace-task-if-reset: true

启动类开启流程设计(@EnableProcessDesign)
@SpringBootApplication @EnableProcessDesign @MapperScan(basePackages = {"com.example.mapper"}) public class Application {public static void main(String[] args) { SpringApplication.run(Application.class, args); } }

四、使用步骤 1. 访问http://host:port/shallow-ui/p... 2. 在流程设计模块设计流程并保存 3. 用@ProcessEntity注解标注要做流程的表名已经要开的流程名称,用@PrimaryKey注解标注出主键
@ProcessEntity(table = "leaves", process = "请假流程") @Data @Accessors(chain = true) public class Leaves {@PrimaryKey @TableId(value = "https://www.it610.com/article/sid", type = IdType.AUTO) private Long sid; @TableField(value = "https://www.it610.com/article/content") private String content; @TableField(value = "https://www.it610.com/article/days") private String days; }

4. 调用方法开启流程,gs为用户名,soft为部门(可选)
@SpringBootTest(classes = Application.class) public class ApplicationTests {@Autowired private ProcessEngine processEngine; @Autowired private LeavesService leavesService; @Test public void test02() { Leaves leaves = new Leaves().setContent("123").setDays("2"); leavesService.save(leaves); processEngine.taskServiceInstance().runTask(leaves, "gs", "soft"); }

5. 调用方法进行审批
@Test public void test04() { TaskStep taskStep = new TaskStep(); taskStep.setUser("guest").setRole("经理") .setTaskId(1L).setOpinion(ProcessConstant.APPROVE_ALLOW_STATUS) .setReason("同意").setStageId(1L); processEngine.taskStepServiceInstance().nextStep(taskStep); }

6.查询自己的审批单
@Test public void test03() { System.out.println(processEngine.taskServiceInstance().approveUser("admin").page(1, 5).getRecords()); System.out.println(processEngine.taskServiceInstance().approveRole("主管").executeQuery()); System.out.println(processEngine.taskServiceInstance().submitBy("gs").executeQuery()); }

    推荐阅读