最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Flowable歷史查詢實例分析

 更新時間:2023年10月01日 09:39:05   作者:吳聲子夜歌  
這篇文章主要介紹了Flowable歷史查詢實例分析,歷史是記錄流程執(zhí)行過程中發(fā)生的事情,并將其永久存儲的組件,與運行時數(shù)據(jù)不同,歷史數(shù)據(jù)在流程實例完成以后仍保存在數(shù)據(jù)庫中,下面我們來深入了解

介紹

歷史是記錄流程執(zhí)行過程中發(fā)生的事情,并將其永久存儲的組件。與運行時數(shù)據(jù)不同,歷史數(shù)據(jù)在流程實例完成以后仍保存在數(shù)據(jù)庫中。

有6個歷史實體:

  • HistoricProcessInstance保存當(dāng)前及已結(jié)束流程實例的信息。
  • HistoricVariableInstance保存流程變量或任務(wù)變量的最新值。
  • HistoricActivityInstance保存活動(流程中的節(jié)點)的一次執(zhí)行的信息。
  • HistoricTaskInstance保存當(dāng)前與歷史(完成及刪除的)任務(wù)實例的信息。
  • HistoricIdentityLink保存任務(wù)及流程實例、當(dāng)前及歷史的身份關(guān)聯(lián)的信息。
  • HistoricDetail保存與歷史流程實例、活動實例或任務(wù)實例等有關(guān)的多種信息。

歷史與當(dāng)前進(jìn)行中的流程實例都在數(shù)據(jù)庫中保存歷史實體,因此可以選擇直接查詢歷史表,以減少對運行時流程實例數(shù)據(jù)的訪問,并提高運行時執(zhí)行的性能。

歷史流程實例查詢

獲取所有流程中,完成所花費時間(持續(xù)時間)排名前10的、流程定義為XXX的、已完成的HistoricProcessInstances(歷史流程實例)。

historyService.createHistoricProcessInstanceQuery()
  .finished()
  .processDefinitionId("XXX")
  .orderByProcessInstanceDuration().desc()
  .listPage(0, 10);
@Test
public void QueryHistoryProcess() {
	// 獲取流程引擎對象
    ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
    HistoryService historyService = processEngine.getHistoryService();
    HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery()
    		.processInstanceId("2c495021-55bf-11ed-a800-005056c00001")
            .orderByProcessInstanceStartTime().asc()
            .singleResult();
    System.out.println("流程實例ID:" + historicProcessInstance.getId());
    System.out.println("流程定義ID:" + historicProcessInstance.getProcessDefinitionId());
    System.out.println("流程開始時間:" + historicProcessInstance.getStartTime());
    System.out.println("流程結(jié)束時間:" + historicProcessInstance.getEndTime());
}

==>  Preparing: select distinct RES.* , DEF.KEY_ as PROC_DEF_KEY_, DEF.NAME_ as PROC_DEF_NAME_, DEF.VERSION_ as PROC_DEF_VERSION_, DEF.DEPLOYMENT_ID_ as DEPLOYMENT_ID_ from ACT_HI_PROCINST RES left outer join ACT_RE_PROCDEF DEF on RES.PROC_DEF_ID_ = DEF.ID_ WHERE RES.PROC_INST_ID_ = ? order by RES.START_TIME_ asc 
==> Parameters: 2c495021-55bf-11ed-a800-005056c00001(String)
<==      Total: 1

流程實例ID:2c495021-55bf-11ed-a800-005056c00001
流程定義ID:MyLeave:1:8c16935c-5544-11ed-b9df-005056c00001
流程開始時間:Thu Oct 27 14:18:28 CST 2022
流程結(jié)束時間:Thu Oct 27 16:40:51 CST 2022

歷史變量實例查詢

獲取已完成的、id為’XXX’的流程實例中,所有的HistoricVariableInstances(歷史變量實例),并以變量名排序。

historyService.createHistoricVariableInstanceQuery()
  .processInstanceId("XXX")
  .orderByVariableName.desc()
  .list();
@Test
public void QueryHistoryVariables() {
	// 獲取流程引擎對象
    ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
    HistoryService historyService = processEngine.getHistoryService();
    List<HistoricVariableInstance> list = historyService.createHistoricVariableInstanceQuery()
			.processInstanceId("2c495021-55bf-11ed-a800-005056c00001")
            .list();
	if (list != null && list.size() > 0) {
		for (HistoricVariableInstance hvi : list) {
			System.out.println("流程變量ID:" + hvi.getId());
            System.out.println("流程實例ID:" + hvi.getProcessInstanceId());
            System.out.println("變量名稱:" + hvi.getVariableName());
            System.out.println("變量的值:" + hvi.getValue());
            System.out.println("變量的創(chuàng)建時間:" + DateUtil.format(hvi.getCreateTime(), "yyyy-MM-dd HH:mm:ss"));
        	System.out.println("###############################################");
		}
	}
}

流程變量ID:2c499e42-55bf-11ed-a800-005056c00001
流程實例ID:2c495021-55bf-11ed-a800-005056c00001
變量名稱:nrOfHolidays
變量的值:3
變量的創(chuàng)建時間:2022-10-27 14:18:28
###############################################
流程變量ID:2c49ec63-55bf-11ed-a800-005056c00001
流程實例ID:2c495021-55bf-11ed-a800-005056c00001
變量名稱:description
變量的值:工作累了,想出去玩玩
變量的創(chuàng)建時間:2022-10-27 14:18:28
###############################################
流程變量ID:2c49ec64-55bf-11ed-a800-005056c00001
流程實例ID:2c495021-55bf-11ed-a800-005056c00001
變量名稱:employee
變量的值:小王
變量的創(chuàng)建時間:2022-10-27 14:18:28
###############################################
流程變量ID:45f4b054-55c7-11ed-80ee-005056c00001
流程實例ID:2c495021-55bf-11ed-a800-005056c00001
變量名稱:executeType
變量的值:YES
變量的創(chuàng)建時間:2022-10-27 15:16:27
###############################################

歷史活動實例查詢

獲取最新的、已完成的、流程定義的id為XXX的、服務(wù)任務(wù)類型的HistoricActivityInstance(歷史活動實例)。

historyService.createHistoricActivityInstanceQuery()
  .activityType("serviceTask")
  .processDefinitionId("XXX")
  .finished()
  .orderByHistoricActivityInstanceEndTime().desc()
  .listPage(0, 1);
@Test
public void QueryHistoryActivity() {
	// 獲取流程引擎對象
    ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
    HistoryService historyService = processEngine.getHistoryService();
    List<HistoricActivityInstance> list = historyService.createHistoricActivityInstanceQuery()
			.processInstanceId("2c495021-55bf-11ed-a800-005056c00001")
            .orderByHistoricActivityInstanceStartTime().asc()
            .list();
	if (list != null && list.size() > 0) {
		for (HistoricActivityInstance hai : list) {
			System.out.println("歷史活動ID:" + hai.getId());
            System.out.println("流程定義ID:" + hai.getProcessDefinitionId());
            System.out.println("流程開始時間:" + DateUtil.format(hai.getStartTime(), "yyyy-MM-dd HH:mm:ss"));
            System.out.println("流程結(jié)束時間:" + DateUtil.format(hai.getEndTime(), "yyyy-MM-dd HH:mm:ss"));
            System.out.println("流程的處理人是:" + hai.getAssignee());
            System.out.println("#####################");
		}
	}
}

==>  Preparing: select RES.* from ACT_HI_ACTINST RES WHERE RES.PROC_INST_ID_ = ? order by START_TIME_ asc 
==> Parameters: 2c495021-55bf-11ed-a800-005056c00001(String)
<==      Total: 11

歷史活動ID:2c4a1376-55bf-11ed-a800-005056c00001
流程定義ID:MyLeave:1:8c16935c-5544-11ed-b9df-005056c00001
流程開始時間:2022-10-27 14:18:28
流程結(jié)束時間:2022-10-27 14:18:28
流程的處理人是:null
#####################
歷史活動ID:2c4cd298-55bf-11ed-a800-005056c00001
流程定義ID:MyLeave:1:8c16935c-5544-11ed-b9df-005056c00001
流程開始時間:2022-10-27 14:18:28
流程結(jié)束時間:2022-10-27 15:16:27
流程的處理人是:張主管
#####################
歷史活動ID:4608ad88-55c7-11ed-80ee-005056c00001
流程定義ID:MyLeave:1:8c16935c-5544-11ed-b9df-005056c00001
流程開始時間:2022-10-27 15:16:28
流程結(jié)束時間:2022-10-27 16:40:51
流程的處理人是:李經(jīng)理
#####################

歷史詳情查詢

下面的的例子獲取id為123的流程中所有的變量更新記錄。這個查詢只會返回HistoricVariableUpdate(歷史變量更新)。請注意一個變量名可能會有多個HistoricVariableUpdate實體,這代表了流程中的每一次變量更新。可以使用orderByTime(按變量更新的時間)或orderByVariableRevision(按變量更新的版本號)對這些更新記錄進(jìn)行排序。

historyService.createHistoricDetailQuery()
  .variableUpdates()
  .processInstanceId("123")
  .orderByVariableName().asc()
  .list()

下面的例子獲取流程id為"123"的、啟動時提交或任何任務(wù)中提交的所有表單參數(shù)。這個查詢只會返回HistoricFormProperties(歷史表單參數(shù))。

historyService.createHistoricDetailQuery()
  .formProperties()
  .processInstanceId("123")
  .orderByVariableName().asc()
  .list()

最后一個例子獲取id為"123"的任務(wù)進(jìn)行的所有變量更新操作。將返回該任務(wù)設(shè)置的所有變量(任務(wù)局部變量)的HistoricVariableUpdates,而不會返回流程實例中設(shè)置的變量。

historyService.createHistoricDetailQuery()
  .variableUpdates()
  .taskId("123")
  .orderByVariableName().asc()
  .list()

歷史任務(wù)實例查詢

獲取所有任務(wù)中,完成所花費時間(持續(xù)時間)排名前10的、已完成的HistoricTaskInstance(歷史任務(wù)實例)。

historyService.createHistoricTaskInstanceQuery()
  .finished()
  .orderByHistoricTaskInstanceDuration().desc()
  .listPage(0, 10);

獲取刪除原因包含"invalid"的、最終指派給kermit用戶的HistoricTaskInstance。

historyService.createHistoricTaskInstanceQuery()
  .finished()
  .taskDeleteReasonLike("%invalid%")
  .taskAssignee("kermit")
  .listPage(0, 10);
@Test
public void QueryHistoryTask() {
	// 獲取流程引擎對象
    ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
    HistoryService historyService = processEngine.getHistoryService();
    List<HistoricTaskInstance> list = historyService.createHistoricTaskInstanceQuery()
			.processInstanceId("2c495021-55bf-11ed-a800-005056c00001")
            .orderByHistoricTaskInstanceStartTime().asc()
            .list()
    if (list != null && list.size() > 0) {
		for (HistoricTaskInstance hti : list) {
        	System.out.println("歷史任務(wù)ID:" + hti.getId());
            System.out.println("流程定義ID:" + hti.getProcessDefinitionId());
            System.out.println("流程執(zhí)行實例ID:" + hti.getExecutionId());
            System.out.println("流程結(jié)束時間:" + DateUtil.format(hti.getEndTime(), "yyyy-MM-dd HH:mm:ss"));
            System.out.println("流程的處理人是:" + hti.getAssignee());
            System.out.println("################################");
		}
	}
}

==>  Preparing: select distinct RES.* from ACT_HI_TASKINST RES WHERE RES.PROC_INST_ID_ = ? order by RES.START_TIME_ asc 
==> Parameters: 2c495021-55bf-11ed-a800-005056c00001(String)
<==      Total: 2

歷史任務(wù)ID:2c5277e9-55bf-11ed-a800-005056c00001
流程定義ID:MyLeave:1:8c16935c-5544-11ed-b9df-005056c00001
流程執(zhí)行實例ID:2c4a1375-55bf-11ed-a800-005056c00001
流程結(jié)束時間:2022-10-27 15:16:27
流程的處理人是:張主管
################################
歷史任務(wù)ID:4608d499-55c7-11ed-80ee-005056c00001
流程定義ID:MyLeave:1:8c16935c-5544-11ed-b9df-005056c00001
流程執(zhí)行實例ID:2c4a1375-55bf-11ed-a800-005056c00001
流程結(jié)束時間:2022-10-27 16:40:51
流程的處理人是:李經(jīng)理
################################

到此這篇關(guān)于Flowable歷史查詢實例分析的文章就介紹到這了,更多相關(guān)Flowable歷史查詢內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • Java如何定義Long類型

    Java如何定義Long類型

    這篇文章主要介紹了Java如何定義Long類型,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2022-07-07
  • 基于Java并發(fā)容器ConcurrentHashMap#put方法解析

    基于Java并發(fā)容器ConcurrentHashMap#put方法解析

    下面小編就為大家?guī)硪黄贘ava并發(fā)容器ConcurrentHashMap#put方法解析。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2017-06-06
  • 一文詳解Java中的監(jiān)聽器(Listener)

    一文詳解Java中的監(jiān)聽器(Listener)

    這篇文章主要介紹了Java中監(jiān)聽器(Listener)的相關(guān)資料,監(jiān)聽器模式是一種設(shè)計模式,用于處理異步事件和通知,文中通過代碼介紹的非常詳細(xì),需要的朋友可以參考下
    2025-03-03
  • 詳解Java 中的UnitTest 和 PowerMock

    詳解Java 中的UnitTest 和 PowerMock

    這篇文章主要介紹了Java中的 UnitTest 和 PowerMock,文中講解非常詳細(xì),對大家學(xué)習(xí)有很大的幫助,感興趣的朋友可以了解下
    2020-06-06
  • Java基于Tcp/ip連接的多人交互聊天室

    Java基于Tcp/ip連接的多人交互聊天室

    這篇文章主要為大家詳細(xì)介紹了Java基于Tcp/ip連接的多人交互聊天室,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2018-07-07
  • Mybatis-Plus使用@TableField實現(xiàn)自動填充日期的代碼示例

    Mybatis-Plus使用@TableField實現(xiàn)自動填充日期的代碼示例

    數(shù)據(jù)庫中經(jīng)常有create_time,update_time兩個字段,在代碼中設(shè)置時間有點太麻煩了?mybatis-plus可以幫我們自動填充,本文主要介紹了Mybatis-Plus使用@TableField實現(xiàn)自動填充日期的代碼示例,感興趣的可以了解一下
    2022-04-04
  • Java軟件編程培訓(xùn)機(jī)構(gòu)靠譜嗎

    Java軟件編程培訓(xùn)機(jī)構(gòu)靠譜嗎

    隨著網(wǎng)絡(luò)信息化的快速發(fā)展,Java培訓(xùn)受到越來越多人的青睞,目前Java工程師的薪資水平在不斷攀升,但是有好多企業(yè)還是招不到合適的人才,為什么呢
    2017-04-04
  • Spring超詳細(xì)講解注解開發(fā)

    Spring超詳細(xì)講解注解開發(fā)

    Spring是輕代碼而重配置的框架,配置比較繁重,影響開發(fā)效率,所以注解開發(fā)是一種趨勢。本文將通過示例為大家詳細(xì)講講Spring如何實現(xiàn)注解開發(fā),感興趣的可以學(xué)習(xí)一下
    2022-08-08
  • Java多線程中ThreadLocal解讀

    Java多線程中ThreadLocal解讀

    這篇文章主要介紹了Java多線程中ThreadLocal解讀,??多線程訪問同一個共享變量的時候容易出現(xiàn)并發(fā)問題,因此為了保證線程安全性,我們都會采用加鎖的方式,而ThreadLocal是除加鎖方式之外的另一種保證線程安全性的方法,需要的朋友可以參考下
    2023-09-09
  • spring mvc使用@InitBinder標(biāo)簽對表單數(shù)據(jù)綁定的方法

    spring mvc使用@InitBinder標(biāo)簽對表單數(shù)據(jù)綁定的方法

    這篇文章主要介紹了spring mvc使用@InitBinder標(biāo)簽對表單數(shù)據(jù)綁定的方法,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2018-03-03

最新評論

苏尼特右旗| 鸡泽县| 涞水县| 云浮市| 土默特右旗| 金阳县| 玉林市| 襄樊市| 美姑县| 乐陵市| 铜陵市| 石城县| 葫芦岛市| 盘山县| 岚皋县| 汉源县| 广饶县| 桐庐县| 秦安县| 名山县| 商洛市| 友谊县| 尚义县| 信阳市| 渝北区| 彰化县| 穆棱市| 十堰市| 龙州县| 河南省| 永胜县| 肥西县| 华容县| 八宿县| 勐海县| 雷山县| 疏附县| 南投市| 白水县| 南部县| 柳江县|