Activiti6 ---承認コンサルティングの実装のプロセス

記事ディレクトリ

1.推奨

承認とは、現在のノードが承認された後、承認のために追加の承認者を追加する必要があることを意味します。追加の承認ユーザーが承認された後、プロセスは次のノードに進みます。たとえば、通常の承認プロセスはA->B->Cであり、Bが署名アクションを実行するとA->B-->D-->Cプロセスはになり、ノードDが追加されます。

医学には、プラセボと呼ばれる万能薬があります。それは薬の効果はありません。単なるお菓子であるかもしれませんが、患者はそれを知りませんが、医師に対する患者の信頼、患者の自己提案、および特定の薬の有効性の期待のために役割を果たします。それは鎮痛、抗ディップまたは救済効果があります。なぜこれが言及されているのですか?承認計画はプラセボ計画であるため、ユーザーは承認履歴から承認を認識します。承認操作を実行すると、承認履歴に承認アクションが記録されますが、それはバックグラウンドで実行されます再割り当て操作は、現在のプロセスを別のユーザーに再割り当てして、署名の効果を達成するため、署名はコードの1行にすぎません。

taskService.setAssignee(task.getTaskId(), user);  

これには次の問題がある可能性があります。

新しいノードが生成されないため、フローチャートは推奨を反映できません

システムがactivitiを変換する準備ができている場合、標準のactivitiフローチャートはニーズを十分に満たしておらず、フローチャートを描画するための承認履歴を記録するための追加の計画が必要です。

2.相談

相談とは、現在のプロセスについて明確ではないことを意味します。プロセスを別の人に転送し、別の人にガイダンスを与える必要があります。他の人がプロセスを承認すると、プロセスはあなたに戻り、彼の承認コメントに基づいて承認します。 。簡単に言うと、通常の承認プロセスがA->B->Cで、Bが照会操作を実行すると、プロセスはになりA->B-->D-->B->Cます。照会と承認の違いは、照会は照会を開始したノードに戻り、承認は戻されないことです。

コンサルテーションは2つの再割り当てです。

  1. BはDに再割り当てされます
  2. DはBに再割り当てされます

コンサルテーションは、2つの再割り当て操作で実現できます。解決すべき問題は、これら2つの再割り当てをどのように調整するかです。

  1. Bが照会操作を実行すると、変数によって照会アクションがマークされ、変数に照会者Bの情報(主にアカウント番号)が格納されます

  2. Dが返信操作を実行すると(プロセスが問い合わせになった後、問い合わせられた人は返信する権利のみを持ちます)、変数からBのアカウントを取り出し、プロセスをBに再割り当てします

  3. Bは通常の承認操作を実行し、プロセスは通常どおり流れます。

3.テスト

設計フローチャート
ここに画像の説明を挿入
Bpmnファイル:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:activiti="http://activiti.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" xmlns:tns="http://www.activiti.org/test" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" expressionLanguage="http://www.w3.org/1999/XPath" id="m1597390628483" name="" targetNamespace="http://www.activiti.org/test" typeLanguage="http://www.w3.org/2001/XMLSchema">
  <process id="consultation" isClosed="false" isExecutable="true" processType="None">
    <startEvent id="_2" name="开始"/>
    <userTask activiti:assignee="A" activiti:exclusive="true" id="_3" name="A"/>
    <userTask activiti:assignee="B" activiti:exclusive="true" id="_4" name="B"/>
    <userTask activiti:assignee="C" activiti:exclusive="true" id="_5" name="C"/>
    <endEvent id="_6" name="结束"/>
    <sequenceFlow id="_7" sourceRef="_2" targetRef="_3"/>
    <sequenceFlow id="_8" sourceRef="_3" targetRef="_4"/>
    <sequenceFlow id="_9" sourceRef="_4" targetRef="_5"/>
    <sequenceFlow id="_10" sourceRef="_5" targetRef="_6"/>

  </process>
  <bpmndi:BPMNDiagram documentation="background=#000000;count=1;horizontalcount=1;orientation=0;width=842.4;height=1195.2;imageableWidth=832.4;imageableHeight=1185.2;imageableX=5.0;imageableY=5.0" id="Diagram-_1" name="New Diagram">
    <bpmndi:BPMNPlane bpmnElement="consultation">
      <bpmndi:BPMNShape bpmnElement="_2" id="Shape-_2">
        <omgdc:Bounds height="32.0" width="32.0" x="20.0" y="315.0"/>
        <bpmndi:BPMNLabel>
          <omgdc:Bounds height="32.0" width="32.0" x="0.0" y="0.0"/>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="_3" id="Shape-_3">
        <omgdc:Bounds height="55.0" width="85.0" x="140.0" y="305.0"/>
        <bpmndi:BPMNLabel>
          <omgdc:Bounds height="55.0" width="85.0" x="0.0" y="0.0"/>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="_4" id="Shape-_4">
        <omgdc:Bounds height="55.0" width="85.0" x="315.0" y="305.0"/>
        <bpmndi:BPMNLabel>
          <omgdc:Bounds height="55.0" width="85.0" x="0.0" y="0.0"/>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="_5" id="Shape-_5">
        <omgdc:Bounds height="55.0" width="85.0" x="500.0" y="305.0"/>
        <bpmndi:BPMNLabel>
          <omgdc:Bounds height="55.0" width="85.0" x="0.0" y="0.0"/>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="_6" id="Shape-_6">
        <omgdc:Bounds height="32.0" width="32.0" x="645.0" y="315.0"/>
        <bpmndi:BPMNLabel>
          <omgdc:Bounds height="32.0" width="32.0" x="0.0" y="0.0"/>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="_11" id="Shape-_11">
        <omgdc:Bounds height="55.0" width="85.0" x="315.0" y="140.0"/>
        <bpmndi:BPMNLabel>
          <omgdc:Bounds height="55.0" width="85.0" x="0.0" y="0.0"/>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge bpmnElement="_7" id="BPMNEdge__7" sourceElement="_2" targetElement="_3">
        <omgdi:waypoint x="52.0" y="331.0"/>
        <omgdi:waypoint x="140.0" y="332.5"/>
        <bpmndi:BPMNLabel>
          <omgdc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="_8" id="BPMNEdge__8" sourceElement="_3" targetElement="_4">
        <omgdi:waypoint x="225.0" y="332.5"/>
        <omgdi:waypoint x="315.0" y="332.5"/>
        <bpmndi:BPMNLabel>
          <omgdc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="_9" id="BPMNEdge__9" sourceElement="_4" targetElement="_5">
        <omgdi:waypoint x="400.0" y="332.5"/>
        <omgdi:waypoint x="500.0" y="332.5"/>
        <bpmndi:BPMNLabel>
          <omgdc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="_10" id="BPMNEdge__10" sourceElement="_5" targetElement="_6">
        <omgdi:waypoint x="585.0" y="332.5"/>
        <omgdi:waypoint x="645.0" y="331.0"/>
        <bpmndi:BPMNLabel>
          <omgdc:Bounds height="0.0" width="0.0" x="0.0" y="0.0"/>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</definitions>

テストカテゴリ:

package com.yb;

import org.activiti.engine.HistoryService;
import org.activiti.engine.RepositoryService;
import org.activiti.engine.RuntimeService;
import org.activiti.engine.TaskService;
import org.activiti.engine.repository.Deployment;
import org.activiti.engine.runtime.ProcessInstance;
import org.activiti.engine.task.Task;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * @author [email protected]
 * @version 1.0
 * @date 2020/8/5
 */
@RunWith(SpringRunner.class)
@SpringBootTest
public class ActivitiJpaTest09 {
    
    

    @Resource
    private RepositoryService repositoryService;
    @Resource
    private RuntimeService runtimeService;
    @Resource
    private TaskService taskService;
    @Resource
    private HistoryService historyService;

    @Resource
    private HttpServletRequest request;

    /**
     * 部署流程,测试征询
     */
    @Test
    public void repositoryDeploy(){
    
    
        Deployment deploy = repositoryService.createDeployment()
                .addClasspathResource("processes/activiti_Consultation.bpmn")
                .addClasspathResource("processes/activiti_Consultation.png")
                .name("测试征询-2")
                .deploy();
        System.out.println("部署ID:"+deploy.getId());
        System.out.println("部署名称"+deploy.getName());
    }

    /**
     * 发布流程
     */
    @Test
    public void runtimeRelease(){
    
    

        ProcessInstance pi = runtimeService.startProcessInstanceByKey("consultation");
        System.out.println("流程实例ID:"+pi.getId());
        System.out.println("流程定义ID:"+pi.getProcessDefinitionId());
    }

    /**
     * 查询及完成任务
     */
    @Test
    public void taskQueryComplete(){
    
    
        List<Task> list = taskService.createTaskQuery()
                .taskAssignee("A")
                .list();
        for (Task task : list) {
    
    
            System.out.println("--------------------------------------------");
            System.out.println("任务ID:" + task.getId());
            System.out.println("任务名称:" + task.getName());
            System.out.println("任务创建时间:" + task.getCreateTime());
            System.out.println("任务委派人:" + task.getAssignee());
            System.out.println("流程实例ID:" + task.getProcessInstanceId());
            System.out.println("--------------------------------------------");
            taskService.complete(task.getId());
        }
    }





    /**
     *征询
     */
    @Test
    public void taskQueryComplete2(){
    
    

        Task task = taskService.createTaskQuery()
                .taskAssignee("B")
                .singleResult();
        taskService.setAssignee(task.getId(),"D");

        //对被征询者做出记录
        taskService.setVariableLocal(task.getId(),"status","D");
        //对发出征询者做出记录
        taskService.setVariableLocal(task.getId(),"originUser","B");


    }

    /**
     * D执行回复操作
     */
    @Test
    public void reply(){
    
    

        String originUser = (String)
                taskService.getVariableLocal("5002", "originUser");
        System.out.println(originUser);

        taskService.setAssignee("5002",originUser);
        taskService.removeVariable("5002", "status");
        taskService.removeVariable("5002", "originUser");
    }
}

データベース:
基本的に、照会と応答を送信する単純なプロセス:照会と応答
ここに画像の説明を挿入
送信した承認者の情報をデータベースに保存します。
ここに画像の説明を挿入
説明:
テストが完了した後ケース4で機能を追加するために、現在の承認者は承認の方法がわからない場合に他のユーザーにコンサルトでき、他のユーザーは返信します。現在の承認者は返信の内容に基づいて次の承認を実行します。それは機能を求めて署名することです。フォローアップ更新事例4。

おすすめ

転載: blog.csdn.net/Lv_vI/article/details/108005678