学习

算法红皮书 3.1.1-3.1.7

查找 #

  • 经典查找算法

  • 符号表这个词来描述抽象的表格,将信息(值)存储在其中,然后按照指定的来获取这些信息

  • 符号表也被称为字典

    • 在英语字典里,键就是单词,值就是单词对应的定义、发音和词源
    • 符号表有时又叫索引
    • 在一本书的索引中,键就是术语,而值就是书中该术语出现的所有页码
  • 下面学习三种经典的数据类型:二叉查找树、红黑树和散列表

符号表 #

  • 符号表最主要的目的是将联系起来

  • 用例能够将一个键值对插入符号表并希望在之后能够从符号表的所有键值对中按照键直接找到相对应的值

  • 符号表是一种存储键值对的数据结构,支持两种操作:插入(put),即将一组新的键值对存入表中;查找(get),即根据给定的键得到相应的值

  • 典型的符号表应用 ly-20241212142100034

API #

  • 符号表是一种典型的数据类型 :代表着一组定义清晰的值及相应的操作。使用应用程序编程接口(API)来精确地定义这些操作 一种简单的泛型符号表API ST(Symbol Table) ly-20241212142100261

  • 泛型 对于符号表,我们通过明确地指定查找时键和值的类型来区分它们的不同角色【key和value】

  • 重复的键

    • 这里假设每个键只对应着一个值(表中不允许重复值)
    • 当用例代码向表中存入的键值对和表中已有的键(及关联的值)冲突时,新的值会替代旧的值
    • 上述定义了关联数组的抽象形式,可以将符号表想象成数组,键即索引,值即数组中的值
    • 在一个关联数组中,键可以是任意类型,但我们仍然可以用它来快速访问数组的值
    • 非Java使用st[key]来替代st.get(key),用st[key]=val来替代st.put(key,val)
  • 键不能为空

  • 值不能为空(因为规定当键不存在时get()返回空) 当值为空表示删除

  • 删除操作

    • 延时删除,先将键对应的值置空,之后在某个时刻删除所有值为空的键

    • 即时删除,立即从表中删除指定的键 put实现的开头:

      if(val == null){
       delete(key);
       return;
      }
      
    • 便捷方法 ly-20241212142100362

    • 迭代 在API第一行加上implements Iterable<Key> ,所有实现都包含iterator()方法来实现hasNext()和next()方法的迭代器;这里采用另一种方式:定义keys返回一个Iterable<Key>对象以方便便利所有的键,且允许遍历一部分

    • 键的等价性 自定义的键需要重写equals()方法;且最好使用不可变数据类型作为键

有序符号表 #

  • 一种有序的泛型符号表的API ly-20241212142100464
  • 最大值和最小值、向下取整和向上取整、排名和选择
  • 对于0到size()-1的所有i都有i==rank(select(i)),且所有的键都满足key == select(rank(key))
  • 范围查找
  • 例外情况 当一个方法需要返回一个键但表中没有合适的键可以返回时,我们约定抛出一个异常
  • 有序符号表中冗余有序性方法的默认实现 ly-20241212142100610
  • 所有Comparable类型中compareTo()方法和equals()方法的一致性
  • ★★成本模型 在学习符号表的实现时,我们会统计比较的次数(等价性测试或是键的相互比较),在内循环**不进行比较(极少)**的情况下,我们会统计数组的访问次数

用例举例 #

如何使用

...

算法红皮书 2.5

  • 排序如此有用的原因是,在有序的数组中查找一个元素,要比在一个无序的数组中查找简单得多
  • 通用排序算法是最重要的
  • 算法思想虽然简单,但是适用领域广泛

将各种数据排序 #

  • Java的约定使得我们能够利用Java的回调机制将任意实现Comparable接口的数据类型排序

    • 我们的代码直接能够将String、Integer、Double 和一些其他例如File 和URL 类型的数组排序,因为它们都实现了Comparable 接口
  • 交易事务 商业数据的处理,设想一家互联网商业公司为每笔交易记录都保存了所有的相关信息

    public int compareTo(Transaction that)
    {
    	return this.when.compareTo(that.when);
    }
    
  • 指针排序 我们使用的方法在经典教材中被称为指针排序,因为我们只处理元素的引用而不移动数据本身

  • 不可变的键 用不可变的数据类型作为键,比如String、Integer、Double和File等

  • 廉价的交换

    • 使用引用的另一个好处是不必移动整个元素对于几乎任意大小的元素,使用引用使得在一般情况下交换的成本和比较的成本几乎相同(代价是需要额外的空间存储这些引用)

    • 研究将数字排序的算法性能的一种方法就是观察其所需的比较和交换总数,因为这里隐式地假设了比较和交换的成本是相同的

  • 多种排序方法

    • 根据情况将一组对象按照不同的方式排序。Java 的Comparator 接口允许我们在一个类之中实现多种排序方法
  • 多键数组

    • 一个元素的多种属性都可能被用作排序的键

      • 我们可以定义多种比较器,要将Transaction 对象的数组按照时间排序可以调用: Insertion.sort(a, new Transaction.WhenOrder()) 或者这样来按照金额排序: Insertion.sort(a, new Transaction.HowMuchOrder())
    • 使用Comparator的插入排序

      public static void sort(Object[] a, Comparator c)
      {
      	int N = a.length;
      	for (int i = 1; i < N; i++)
      	for (int j = i; j > 0 && less(Comparator, a[j], a[j-1]); j--)
      	exch(a, j, j-1);
      }
      private static Boolean less(Comparator c, Object v, Object w)
      {
      	return c.compare(v, w) < 0;
      }
      private static void exch(Object[] a, int i, int j)
      {
      	Object t = a[i];
      	a[i] = a[j];
      	a[j] = t;
      }
      
    • 使用比较器实现优先队列

      ...

算法红皮书 2.4

优先队列 #

  • 有些情况下,不需要要求处理的元素全部有序,只要求每次都处理键值最大的元素,然后再收集更多的元素,然后再处理键值最大的元素
  • 需要一种数据结构,支持操作:删除最大元素和插入元素,这种数据类型叫做优先队列
  • 优先队列的基本表现形式:其一或两种操作都能在线性时间内完成
  • 基于二叉堆数据结构的优先队列,用数组保存元素并按照一定条件排序,以实现高效的删除最大元素和插入元素

API #

  • 抽象数据类型,最重要的操作是删除最大元素和插入元素 delMax()和insert()

  • 用“最大元素”代替“最大键值”或是“键值最大的元素”

  • 泛型优先队列的API ly-20241212142058095

  • 优先队列的调用示例 从N各输入中找到最大的M各元素所需成本 ly-20241212142058324

    • 优先队列的用例 pq里面最多放5个,当大于5个的时候,就从中剔除1个

      public class TopM
      {
      	public static void main(String[] args)
      	{
      		// 打印输入流中最大的M行
      		int M = Integer.parseint(args[0]);
      		MinPQ<Transaction> pq = new MinPQ<Transaction>(M+1);
      		while (StdIn.hasNextLine())
      		{
      			// 为下一行输入创建一个元素并放入优先队列中
      			pq.insert(new Transaction(StdIn.readLine()));
      			if (pq.size() > M)
      			  pq.delMin();
      			// 如果优先队列中存在M+1个元素则删除其中最小的元素
      		}
      		// 最大的M个元素都在优先队列中
      		Stack<Transaction> stack = new Stack<Transaction>();
      		while (!pq.isEmpty()) stack.push(pq.delMin());
      		for (Transaction t : stack) StdOut.println(t);
      	}
      }
      
    • 应用 ly-20241212142058429

      ...

zsx_flowable_design01

  • 模型设计完后,下面三个表有变化

    ly-20241212142116933

    • act_cio_model ly-20241212142117063
    • act_cio_model_module_rel ly-20241212142117162
    • act_ge_bytearray ly-20241212142117254
  • 部署之后,四个表有变化 ly-20241212142117340

    • act_cio_deployment 多了39条记录 ly-20241212142117428

      ly-20241212142117516

    • act_ge_bytearray 多了两条记录 ly-20241212142117610

    • act_re_deployment 多了一条记录 ly-20241212142117704

    • act_re_procdef 多了一条记录 ly-20241212142117795

  • 流程开始运行

    • 下面只写上主要的几个表
    • 送审时这个结点只能选一个 ly-20241212142117883
    • 流程运行时变量表 ly-20241212142117970

linux_韩老师_28-39

文件目录 #

  • 用来定位绝对路径或相对路径 cd ~ 用来定位家目录 cd .. 返回上一级 cd - 返回上一次目录

  • mkdir 用于创建目录 mkdir -p hello/l1/l2 多级目录创建

  • recursion 递归 rm -rf 要删除的目录 #递归删除

  • 使用cp进行复制,加上 -r 进行递归复制

  • rm 删除某个文件(带提示)

    • rm -f 删除文件(不带提示)
    • rm -rf 强制删除递归文件(夹)
  • mv 用来重命名(移动到同一目录下)、(或者移动文件)

  • 注意,下面的命令,是将hello移动到hello2下,并改名为a(而不是hello2下的a目录) mv Hello.java hello2/a

    • mv Hello.java hello2/a/ 移动到hello2下的a目录下(最后有一个斜杠)
  • 移动目录

    • mv hello2 hello1/AB 或者 mv hello2/ hello1/AB

      或者 mv hello2/ hello1/AB/

      会把整个hello2文件夹(包括hello2)移动到AB下

    • 同样是上面的指令,如果AB不存在,那么就会将hello2移动到hello1下,并将hello2文件夹,改名为AB

  • cat 指令

    • cat -p /etc/profile 浏览并显示文件
    • 管道命令 cat -p /etc/profile | more 把前面的结果再交给more处理 (输入enter查看下一行,空格查看下一页)
  • less指令

    ...

linux_韩老师_21-33

用户管理 #

  • 使用ssh root@192.168.200.201进行服务器连接 ly-20241212142135612

  • xshell中 ctr+shift+r 用来重新连接

  • 用户解释图 ly-20241212142135812

  • 添加一个用户milan,会自动创建该用户的家目录milan

    • 当登录该用户时,会自动切换到家目录下 ly-20241212142135882
  • 指定家目录 ly-20241212142135954

  • 指定密码 ly-20241212142136024

  • 用milan登录,自动切换到/home/milan pwd:显示当前用户所在的目录

    ly-20241212142136094

  • 用户删除

    • 删除用户但保留家目录
      • 需要用超级管理员才能删除 ly-20241212142136163 使用su -u root切换到超级管理员
      • 先logout然后再删除 ly-20241212142136235
    • 删除用户及家目录 userdel -r milan
    • 建议保留家目录
  • 查询root用户信息

    • 使用id xx 查询 ly-20241212142136305
  • 切换用户 su - xx

    • 从权限高切换到权限低的用户不需要密码;反之需要 ly-20241212142136377
    • 使用logout(exit也行),从root用户回到jack
  • 查看当前用户 who am i ly-20241212142136445 即使切换了用户,返回的还是root(第一次登录时的用户) ly-20241212142136517

  • 用户组(角色)

    • 增加、删除组

      groupadd wudang
      groupdel wudang
      

      如果添加用户的时候没有指定组,那么会创建一个跟用户名一样的名字的组 ly-20241212142136586 id是1002,组为king

      ly-20241212142136655

    • 添加用户zwj,添加组wudang,并将zwj添加到wudang组里面

      groupadd wudang
      useradd -g wudang zwj
      

      ly-20241212142136719

      ...

官方的hello-world

简介 #

  • MyBatis-Plus (opens new window)(简称 MP)是一个 MyBatis (opens new window)的增强工具,在 MyBatis 的基础上只做增强不做改变,为简化开发、提高效率而生。

快速开始 #

  • 数据库的Schema脚本 resources/db/schema-mysql.sql

    DROP TABLE IF EXISTS user;
    
    CREATE TABLE user
    (
        id BIGINT(20) NOT NULL COMMENT '主键ID',
        name VARCHAR(30) NULL DEFAULT NULL COMMENT '姓名',
        age INT(11) NULL DEFAULT NULL COMMENT '年龄',
        email VARCHAR(50) NULL DEFAULT NULL COMMENT '邮箱',
        PRIMARY KEY (id)
    );
    
  • 数据库Data脚本 resources/db/data-mysql.sql

    DELETE FROM user;
    
    INSERT INTO user (id, name, age, email) VALUES
    (1, 'Jone', 18, 'test1@baomidou.com'),
    (2, 'Jack', 20, 'test2@baomidou.com'),
    (3, 'Tom', 28, 'test3@baomidou.com'),
    (4, 'Sandy', 21, 'test4@baomidou.com'),
    (5, 'Billie', 24, 'test5@baomidou.com');
    
  • 创建一个spring boot工程(使用maven)

    • 父工程

      <parent>
          <groupId>org.springframework.boot</groupId>
          <artifactId>spring-boot-starter-parent</artifactId>
          <version>2.7.0</version>
          <relativePath/>
      </parent>
      
    • springboot 相关仓库及mybatis-plus、mysql、Lombok相关仓库引入

      
          <dependencies>
              <dependency>
                  <groupId>org.springframework.boot</groupId>
                  <artifactId>spring-boot-starter</artifactId>
              </dependency>
              <dependency>
                  <groupId>org.springframework.boot</groupId>
                  <artifactId>spring-boot-starter-test</artifactId>
                  <scope>test</scope>
              </dependency>
              <dependency>
                  <groupId>com.baomidou</groupId>
                  <artifactId>mybatis-plus-boot-starter</artifactId>
                  <version>3.5.1</version>
              </dependency>
      
              <dependency>
                  <groupId>org.springframework.boot</groupId>
                  <artifactId>spring-boot-starter-web</artifactId>
              </dependency>
              <dependency>
                  <groupId>com.h2database</groupId>
                  <artifactId>h2</artifactId>
                  <scope>runtime</scope>
              </dependency>
              <!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
              <dependency>
                  <groupId>mysql</groupId>
                  <artifactId>mysql-connector-java</artifactId>
                  <version>8.0.29</version>
              </dependency>
              <!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
              <dependency>
                  <groupId>org.projectlombok</groupId>
                  <artifactId>lombok</artifactId>
                  <version>1.18.24</version>
                  <scope>provided</scope>
              </dependency>
      
          </dependencies>
      
    • 配置resources/application.yml文件

      ...

boge-03-其他

会签 #

  • 流程图绘制 ly-20241212142115466

    • 注意上面几个参数

      • 多实例类型用来判断串行并行
      • 基数(有几个用户处理)
      • 元素变量
      • 集合(集合变量)
      • 完成条件–这里填的是 ${nrOfCompletedInstances > 1 }
    • 在任务监听器 ly-20241212142115672

      package org.flowable.listener;
      
      import org.flowable.engine.ProcessEngine;
      import org.flowable.engine.ProcessEngines;
      import org.flowable.engine.TaskService;
      import org.flowable.engine.delegate.TaskListener;
      import org.flowable.task.api.Task;
      import org.flowable.task.service.delegate.DelegateTask;
      
      public class MultiInstanceTaskListener implements TaskListener {
      
          @Override
          public void notify(DelegateTask delegateTask) {
              System.out.println("处理aaaa");
              if(delegateTask.getEventName().equals("create")) {
                  System.out.println("任务id" + delegateTask.getId());
                  System.out.println("哪些人需要会签" + delegateTask.getVariable("persons"));
                  System.out.println("任务处理人" + delegateTask.getVariable("person"));
                  ProcessEngine engine = ProcessEngines.getDefaultProcessEngine();
                  TaskService taskService = engine.getTaskService();
                  Task task = taskService.createTaskQuery().taskId(delegateTask.getId()).singleResult();
                  task.setAssignee(delegateTask.getVariable("person").toString());
                  taskService.saveTask(task);
              }
          }
      }
      

boge-02-flowable进阶_6

任务回退-串行回退 #

  • 流程图绘制 ly-20241212142114607

  • xml

    <?xml version="1.0" encoding="UTF-8"?>
    <definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:flowable="http://flowable.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://www.flowable.org/processdef" exporter="Flowable Open Source Modeler" exporterVersion="6.7.2">
      <process id="reback-key" name="回退处理" isExecutable="true">
        <documentation>reback-desc</documentation>
        <startEvent id="startEvent1" flowable:formFieldValidation="true"></startEvent>
        <userTask id="sid-D380E41A-48EE-4C08-AD01-1D509C512543" name="用户1" flowable:assignee="user1" flowable:formFieldValidation="true">
          <extensionElements>
            <modeler:initiator-can-complete xmlns:modeler="http://flowable.org/modeler"><![CDATA[false]]></modeler:initiator-can-complete>
          </extensionElements>
        </userTask>
        <sequenceFlow id="sid-E2423FC5-F954-43D3-B57C-8460057CB7D6" sourceRef="startEvent1" targetRef="sid-D380E41A-48EE-4C08-AD01-1D509C512543"></sequenceFlow>
        <userTask id="sid-AF50E3D0-2014-4308-A717-D76586837D70" name="用户2" flowable:assignee="user2" flowable:formFieldValidation="true">
          <extensionElements>
            <modeler:initiator-can-complete xmlns:modeler="http://flowable.org/modeler"><![CDATA[false]]></modeler:initiator-can-complete>
          </extensionElements>
        </userTask>
        <sequenceFlow id="sid-7C8750DC-E1C1-4AB2-B18C-2C103B61A5E5" sourceRef="sid-D380E41A-48EE-4C08-AD01-1D509C512543" targetRef="sid-AF50E3D0-2014-4308-A717-D76586837D70"></sequenceFlow>
        <userTask id="sid-F4CE7565-5977-4B9C-A603-AB3B817B8C8C" name="用户3" flowable:assignee="user3" flowable:formFieldValidation="true">
          <extensionElements>
            <modeler:initiator-can-complete xmlns:modeler="http://flowable.org/modeler"><![CDATA[false]]></modeler:initiator-can-complete>
          </extensionElements>
        </userTask>
        <sequenceFlow id="sid-F91582FE-D110-48C9-9407-605E503E42B2" sourceRef="sid-AF50E3D0-2014-4308-A717-D76586837D70" targetRef="sid-F4CE7565-5977-4B9C-A603-AB3B817B8C8C"></sequenceFlow>
        <userTask id="sid-727C1235-F9C1-4CC5-BC6C-E56ABCA105B0" name="用户4" flowable:assignee="user4" flowable:formFieldValidation="true">
          <extensionElements>
            <modeler:initiator-can-complete xmlns:modeler="http://flowable.org/modeler"><![CDATA[false]]></modeler:initiator-can-complete>
          </extensionElements>
        </userTask>
        <sequenceFlow id="sid-6D998C20-2A97-44B5-92D0-118E5CB05795" sourceRef="sid-F4CE7565-5977-4B9C-A603-AB3B817B8C8C" targetRef="sid-727C1235-F9C1-4CC5-BC6C-E56ABCA105B0"></sequenceFlow>
        <endEvent id="sid-6E5F5037-1979-4150-8408-D0BFD0315BCA"></endEvent>
        <sequenceFlow id="sid-3ECF3E34-6C07-4AE6-997B-583BF8868AC8" sourceRef="sid-727C1235-F9C1-4CC5-BC6C-E56ABCA105B0" targetRef="sid-6E5F5037-1979-4150-8408-D0BFD0315BCA"></sequenceFlow>
      </process>
      <bpmndi:BPMNDiagram id="BPMNDiagram_reback-key">
        <bpmndi:BPMNPlane bpmnElement="reback-key" id="BPMNPlane_reback-key">
          <bpmndi:BPMNShape bpmnElement="startEvent1" id="BPMNShape_startEvent1">
            <omgdc:Bounds height="30.0" width="30.0" x="100.0" y="163.0"></omgdc:Bounds>
          </bpmndi:BPMNShape>
          <bpmndi:BPMNShape bpmnElement="sid-D380E41A-48EE-4C08-AD01-1D509C512543" id="BPMNShape_sid-D380E41A-48EE-4C08-AD01-1D509C512543">
            <omgdc:Bounds height="80.0" width="100.0" x="165.0" y="135.0"></omgdc:Bounds>
          </bpmndi:BPMNShape>
          <bpmndi:BPMNShape bpmnElement="sid-AF50E3D0-2014-4308-A717-D76586837D70" id="BPMNShape_sid-AF50E3D0-2014-4308-A717-D76586837D70">
            <omgdc:Bounds height="80.0" width="100.0" x="320.0" y="138.0"></omgdc:Bounds>
          </bpmndi:BPMNShape>
          <bpmndi:BPMNShape bpmnElement="sid-F4CE7565-5977-4B9C-A603-AB3B817B8C8C" id="BPMNShape_sid-F4CE7565-5977-4B9C-A603-AB3B817B8C8C">
            <omgdc:Bounds height="80.0" width="100.0" x="465.0" y="138.0"></omgdc:Bounds>
          </bpmndi:BPMNShape>
          <bpmndi:BPMNShape bpmnElement="sid-727C1235-F9C1-4CC5-BC6C-E56ABCA105B0" id="BPMNShape_sid-727C1235-F9C1-4CC5-BC6C-E56ABCA105B0">
            <omgdc:Bounds height="80.0" width="100.0" x="610.0" y="138.0"></omgdc:Bounds>
          </bpmndi:BPMNShape>
          <bpmndi:BPMNShape bpmnElement="sid-6E5F5037-1979-4150-8408-D0BFD0315BCA" id="BPMNShape_sid-6E5F5037-1979-4150-8408-D0BFD0315BCA">
            <omgdc:Bounds height="28.0" width="28.0" x="755.0" y="164.0"></omgdc:Bounds>
          </bpmndi:BPMNShape>
          <bpmndi:BPMNEdge bpmnElement="sid-6D998C20-2A97-44B5-92D0-118E5CB05795" id="BPMNEdge_sid-6D998C20-2A97-44B5-92D0-118E5CB05795" flowable:sourceDockerX="50.0" flowable:sourceDockerY="40.0" flowable:targetDockerX="50.0" flowable:targetDockerY="40.0">
            <omgdi:waypoint x="564.9499999999907" y="178.0"></omgdi:waypoint>
            <omgdi:waypoint x="609.9999999999807" y="178.0"></omgdi:waypoint>
          </bpmndi:BPMNEdge>
          <bpmndi:BPMNEdge bpmnElement="sid-7C8750DC-E1C1-4AB2-B18C-2C103B61A5E5" id="BPMNEdge_sid-7C8750DC-E1C1-4AB2-B18C-2C103B61A5E5" flowable:sourceDockerX="50.0" flowable:sourceDockerY="40.0" flowable:targetDockerX="50.0" flowable:targetDockerY="40.0">
            <omgdi:waypoint x="264.9499999999882" y="175.0"></omgdi:waypoint>
            <omgdi:waypoint x="292.5" y="175.0"></omgdi:waypoint>
            <omgdi:waypoint x="292.5" y="178.0"></omgdi:waypoint>
            <omgdi:waypoint x="319.9999999999603" y="178.0"></omgdi:waypoint>
          </bpmndi:BPMNEdge>
          <bpmndi:BPMNEdge bpmnElement="sid-3ECF3E34-6C07-4AE6-997B-583BF8868AC8" id="BPMNEdge_sid-3ECF3E34-6C07-4AE6-997B-583BF8868AC8" flowable:sourceDockerX="50.0" flowable:sourceDockerY="40.0" flowable:targetDockerX="14.0" flowable:targetDockerY="14.0">
            <omgdi:waypoint x="709.9499999999999" y="178.0"></omgdi:waypoint>
            <omgdi:waypoint x="755.0" y="178.0"></omgdi:waypoint>
          </bpmndi:BPMNEdge>
          <bpmndi:BPMNEdge bpmnElement="sid-E2423FC5-F954-43D3-B57C-8460057CB7D6" id="BPMNEdge_sid-E2423FC5-F954-43D3-B57C-8460057CB7D6" flowable:sourceDockerX="15.0" flowable:sourceDockerY="15.0" flowable:targetDockerX="50.0" flowable:targetDockerY="40.0">
            <omgdi:waypoint x="129.94340692927761" y="177.55019845363262"></omgdi:waypoint>
            <omgdi:waypoint x="164.99999999999906" y="176.4985"></omgdi:waypoint>
          </bpmndi:BPMNEdge>
          <bpmndi:BPMNEdge bpmnElement="sid-F91582FE-D110-48C9-9407-605E503E42B2" id="BPMNEdge_sid-F91582FE-D110-48C9-9407-605E503E42B2" flowable:sourceDockerX="50.0" flowable:sourceDockerY="40.0" flowable:targetDockerX="50.0" flowable:targetDockerY="40.0">
            <omgdi:waypoint x="419.94999999999067" y="178.0"></omgdi:waypoint>
            <omgdi:waypoint x="464.9999999999807" y="178.0"></omgdi:waypoint>
          </bpmndi:BPMNEdge>
        </bpmndi:BPMNPlane>
      </bpmndi:BPMNDiagram>
    </definitions>
    
  • 部署并运行

    ...

boge-02-flowable进阶_5

网关 #

ly-20241212142112823

排他网关 #

会按照所有出口顺序流定义的顺序对它们进行计算,选择第一个条件计算为true的顺序流(当没有设置条件时,认为顺序流为true)继续流程

ly-20241212142113034

  • 排他网关的绘制 ly-20241212142113127 xml文件

    <?xml version="1.0" encoding="UTF-8"?>
    <definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:flowable="http://flowable.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://www.flowable.org/processdef" exporter="Flowable Open Source Modeler" exporterVersion="6.7.2">
      <process id="holiday-exclusive" name="请假流程-排他网关" isExecutable="true">
        <startEvent id="startEvent1" flowable:formFieldValidation="true"></startEvent>
        <userTask id="sid-3D5ED4D4-97F5-4FFD-B160-F00566ECC55E" name="创建请假单" flowable:assignee="zhangsan" flowable:formFieldValidation="true">
          <extensionElements>
            <modeler:initiator-can-complete xmlns:modeler="http://flowable.org/modeler"><![CDATA[false]]></modeler:initiator-can-complete>
          </extensionElements>
        </userTask>
        <sequenceFlow id="sid-33A73370-751D-413F-9306-39DEAA674DB6" sourceRef="startEvent1" targetRef="sid-3D5ED4D4-97F5-4FFD-B160-F00566ECC55E"></sequenceFlow>
        <exclusiveGateway id="sid-5B2117E6-D341-49F2-85B2-336CA836C7D8"></exclusiveGateway>
        <sequenceFlow id="sid-D1B1F6E0-EA7F-4FF7-AD0C-5D43DBCEBFD2" sourceRef="sid-3D5ED4D4-97F5-4FFD-B160-F00566ECC55E" targetRef="sid-5B2117E6-D341-49F2-85B2-336CA836C7D8"></sequenceFlow>
        <userTask id="sid-08A6CB64-C9BB-4342-852D-444A75315BDE" name="总经理审批" flowable:assignee="wangwu" flowable:formFieldValidation="true">
          <extensionElements>
            <modeler:initiator-can-complete xmlns:modeler="http://flowable.org/modeler"><![CDATA[false]]></modeler:initiator-can-complete>
          </extensionElements>
        </userTask>
        <userTask id="sid-EA98D0C3-E41D-4DEB-8933-91A1B7301ABE" name="部门经理审批" flowable:assignee="lisi" flowable:formFieldValidation="true">
          <extensionElements>
            <modeler:initiator-can-complete xmlns:modeler="http://flowable.org/modeler"><![CDATA[false]]></modeler:initiator-can-complete>
          </extensionElements>
        </userTask>
        <userTask id="sid-24F73F7F-EB61-484F-A494-686E194D0118" name="人事审批" flowable:assignee="zhaoliu" flowable:formFieldValidation="true">
          <extensionElements>
            <modeler:initiator-can-complete xmlns:modeler="http://flowable.org/modeler"><![CDATA[false]]></modeler:initiator-can-complete>
          </extensionElements>
        </userTask>
        <sequenceFlow id="sid-8BA0B88C-BA4F-446D-B5E7-6BF0830B1DC8" sourceRef="sid-EA98D0C3-E41D-4DEB-8933-91A1B7301ABE" targetRef="sid-24F73F7F-EB61-484F-A494-686E194D0118"></sequenceFlow>
        <sequenceFlow id="sid-E748F81F-B0B2-4C34-B993-FBAA2BCD0995" sourceRef="sid-08A6CB64-C9BB-4342-852D-444A75315BDE" targetRef="sid-24F73F7F-EB61-484F-A494-686E194D0118"></sequenceFlow>
        <sequenceFlow id="sid-928C6C6F-57F1-40F2-BE0F-1A9FF3E6E9E4" sourceRef="sid-5B2117E6-D341-49F2-85B2-336CA836C7D8" targetRef="sid-08A6CB64-C9BB-4342-852D-444A75315BDE">
          <conditionExpression xsi:type="tFormalExpression"><![CDATA[${num>3}]]></conditionExpression>
        </sequenceFlow>
        <sequenceFlow id="sid-4DB25720-11C8-401E-BB4C-83BB25510B2E" sourceRef="sid-5B2117E6-D341-49F2-85B2-336CA836C7D8" targetRef="sid-EA98D0C3-E41D-4DEB-8933-91A1B7301ABE">
          <conditionExpression xsi:type="tFormalExpression"><![CDATA[${num<3}]]></conditionExpression>
        </sequenceFlow>
      </process>
      <bpmndi:BPMNDiagram id="BPMNDiagram_holiday-exclusive">
        <bpmndi:BPMNPlane bpmnElement="holiday-exclusive" id="BPMNPlane_holiday-exclusive">
          <bpmndi:BPMNShape bpmnElement="startEvent1" id="BPMNShape_startEvent1">
            <omgdc:Bounds height="30.0" width="30.0" x="30.0" y="163.0"></omgdc:Bounds>
          </bpmndi:BPMNShape>
          <bpmndi:BPMNShape bpmnElement="sid-3D5ED4D4-97F5-4FFD-B160-F00566ECC55E" id="BPMNShape_sid-3D5ED4D4-97F5-4FFD-B160-F00566ECC55E">
            <omgdc:Bounds height="80.0" width="100.0" x="150.0" y="135.0"></omgdc:Bounds>
          </bpmndi:BPMNShape>
          <bpmndi:BPMNShape bpmnElement="sid-5B2117E6-D341-49F2-85B2-336CA836C7D8" id="BPMNShape_sid-5B2117E6-D341-49F2-85B2-336CA836C7D8">
            <omgdc:Bounds height="40.0" width="40.0" x="315.0" y="155.0"></omgdc:Bounds>
          </bpmndi:BPMNShape>
          <bpmndi:BPMNShape bpmnElement="sid-08A6CB64-C9BB-4342-852D-444A75315BDE" id="BPMNShape_sid-08A6CB64-C9BB-4342-852D-444A75315BDE">
            <omgdc:Bounds height="80.0" width="100.0" x="420.0" y="225.0"></omgdc:Bounds>
          </bpmndi:BPMNShape>
          <bpmndi:BPMNShape bpmnElement="sid-EA98D0C3-E41D-4DEB-8933-91A1B7301ABE" id="BPMNShape_sid-EA98D0C3-E41D-4DEB-8933-91A1B7301ABE">
            <omgdc:Bounds height="80.0" width="100.0" x="405.0" y="30.0"></omgdc:Bounds>
          </bpmndi:BPMNShape>
          <bpmndi:BPMNShape bpmnElement="sid-24F73F7F-EB61-484F-A494-686E194D0118" id="BPMNShape_sid-24F73F7F-EB61-484F-A494-686E194D0118">
            <omgdc:Bounds height="80.0" width="100.0" x="630.0" y="225.0"></omgdc:Bounds>
          </bpmndi:BPMNShape>
          <bpmndi:BPMNEdge bpmnElement="sid-8BA0B88C-BA4F-446D-B5E7-6BF0830B1DC8" id="BPMNEdge_sid-8BA0B88C-BA4F-446D-B5E7-6BF0830B1DC8" flowable:sourceDockerX="50.0" flowable:sourceDockerY="40.0" flowable:targetDockerX="50.0" flowable:targetDockerY="40.0">
            <omgdi:waypoint x="504.95000000000005" y="70.0"></omgdi:waypoint>
            <omgdi:waypoint x="680.0" y="70.0"></omgdi:waypoint>
            <omgdi:waypoint x="680.0" y="225.0"></omgdi:waypoint>
          </bpmndi:BPMNEdge>
          <bpmndi:BPMNEdge bpmnElement="sid-4DB25720-11C8-401E-BB4C-83BB25510B2E" id="BPMNEdge_sid-4DB25720-11C8-401E-BB4C-83BB25510B2E" flowable:sourceDockerX="20.5" flowable:sourceDockerY="20.5" flowable:targetDockerX="50.0" flowable:targetDockerY="40.0">
            <omgdi:waypoint x="335.5" y="155.5"></omgdi:waypoint>
            <omgdi:waypoint x="335.5" y="70.0"></omgdi:waypoint>
            <omgdi:waypoint x="404.99999999996083" y="70.0"></omgdi:waypoint>
          </bpmndi:BPMNEdge>
          <bpmndi:BPMNEdge bpmnElement="sid-33A73370-751D-413F-9306-39DEAA674DB6" id="BPMNEdge_sid-33A73370-751D-413F-9306-39DEAA674DB6" flowable:sourceDockerX="15.0" flowable:sourceDockerY="15.0" flowable:targetDockerX="50.0" flowable:targetDockerY="40.0">
            <omgdi:waypoint x="59.94725673598754" y="177.70973069236373"></omgdi:waypoint>
            <omgdi:waypoint x="150.0" y="175.96677419354836"></omgdi:waypoint>
          </bpmndi:BPMNEdge>
          <bpmndi:BPMNEdge bpmnElement="sid-D1B1F6E0-EA7F-4FF7-AD0C-5D43DBCEBFD2" id="BPMNEdge_sid-D1B1F6E0-EA7F-4FF7-AD0C-5D43DBCEBFD2" flowable:sourceDockerX="50.0" flowable:sourceDockerY="40.0" flowable:targetDockerX="20.5" flowable:targetDockerY="20.5">
            <omgdi:waypoint x="249.95000000000002" y="175.18431734317343"></omgdi:waypoint>
            <omgdi:waypoint x="315.42592592592536" y="175.42592592592592"></omgdi:waypoint>
          </bpmndi:BPMNEdge>
          <bpmndi:BPMNEdge bpmnElement="sid-E748F81F-B0B2-4C34-B993-FBAA2BCD0995" id="BPMNEdge_sid-E748F81F-B0B2-4C34-B993-FBAA2BCD0995" flowable:sourceDockerX="50.0" flowable:sourceDockerY="40.0" flowable:targetDockerX="50.0" flowable:targetDockerY="40.0">
            <omgdi:waypoint x="519.95" y="265.0"></omgdi:waypoint>
            <omgdi:waypoint x="629.9999999998776" y="265.0"></omgdi:waypoint>
          </bpmndi:BPMNEdge>
          <bpmndi:BPMNEdge bpmnElement="sid-928C6C6F-57F1-40F2-BE0F-1A9FF3E6E9E4" id="BPMNEdge_sid-928C6C6F-57F1-40F2-BE0F-1A9FF3E6E9E4" flowable:sourceDockerX="20.5" flowable:sourceDockerY="20.5" flowable:targetDockerX="50.0" flowable:targetDockerY="40.0">
            <omgdi:waypoint x="335.5" y="194.43942522321433"></omgdi:waypoint>
            <omgdi:waypoint x="335.5" y="265.0"></omgdi:waypoint>
            <omgdi:waypoint x="420.0" y="265.0"></omgdi:waypoint>
          </bpmndi:BPMNEdge>
        </bpmndi:BPMNPlane>
      </bpmndi:BPMNDiagram>
    </definitions>
    
  • 部署

    ...