一亭病、Camunda教程
請(qǐng)點(diǎn)擊此處强衡;
比上面還詳細(xì)的教程驰贷。
二、生成的數(shù)據(jù)表說明
1柜与、總介紹
(1) act_re_*: 're'表示流程資源存儲(chǔ)咏删,這個(gè)前綴的表包含了流程定義和流程靜態(tài)資源(圖片,規(guī)則等)拣凹,共5張表森爽。
(2) act_ru_*: 'ru'表示流程運(yùn)行時(shí)。 這些運(yùn)行時(shí)的表嚣镜,包含流程實(shí)例爬迟,任務(wù),變量菊匿,Job等運(yùn)行中的數(shù)據(jù)付呕。 Camunda只在流程實(shí)例執(zhí)行過程中保存這些數(shù)據(jù),在流程結(jié)束時(shí)就會(huì)刪除這些記錄跌捆, 這樣運(yùn)行時(shí)表的數(shù)據(jù)量最小徽职,可以最快運(yùn)行。共15張表疹蛉。
(3)act_id_*: 'id'表示組織用戶信息活箕,比如用戶,組等可款,共6張表育韩。
(4)act_hi_*: 'hi'表示流程歷史記錄。 這些表包含歷史數(shù)據(jù)闺鲸,比如歷史流程實(shí)例筋讨,變量,任務(wù)等摸恍,共18張表悉罕。
(5)act_ge_*: 'ge'表示流程通用數(shù)據(jù), 用于不同場(chǎng)景下立镶,共3張表壁袄。
2、每個(gè)表介紹
(1)流程資源存儲(chǔ)類
- act_re_case_def:CMMN案例管理模型定義表
- act_re_decision_def:DMN決策模型定義表
- act_re_decision_req_def :決策需求定義表
- act_re_deployment:流程部署表
- act_re_procdef:BPMN流程模型定義表
(2)流程運(yùn)行類
- act_ru_authorization:流程運(yùn)行時(shí)權(quán)限授予的表(是否使用與是否開啟"camunda.bpm.authorization.enabled" : "true" or "false"有關(guān))
- act_ru_batch:流程執(zhí)行批處理表
- act_ru_case_execution:CMMN案例運(yùn)行執(zhí)行表
- act_ru_case_sentry_part:CMMN案例運(yùn)行時(shí)哨兵部分表
- act_ru_event_subscr:流程事件訂閱表
- act_ru_execution:BPMN流程運(yùn)行時(shí)記錄表(運(yùn)行時(shí)流程執(zhí)行實(shí)例表媚媒,與流程實(shí)例并不一樣)
- act_ru_ext_task:流程任務(wù)消息執(zhí)行表(運(yùn)行時(shí)外部任務(wù)信息表)
- act_ru_filter:流程定義查詢配置表(運(yùn)行時(shí)過濾器表)
- act_ru_identitylink:運(yùn)行時(shí)流程人員表
- act_ru_incident:運(yùn)行時(shí)異常事件表(工作流引擎突發(fā)事件表)
- act_ru_job:流程運(yùn)行時(shí)作業(yè)表
- act_ru_jobdef :流程作業(yè)定義表
- act_ru_meter_log:流程運(yùn)行時(shí)度量日志表
- act_ru_task:流程運(yùn)行時(shí)任務(wù)表(最常用的表之一嗜逻,每一個(gè)流程實(shí)例開啟后,到達(dá)的每一個(gè)task都會(huì)生成在這里缭召,也就是任務(wù)實(shí)例)
- act_ru_variable:流程運(yùn)行時(shí)變量表(在開啟流程實(shí)例或者在流程推進(jìn)時(shí)傳入的參數(shù)栈顷,在流程未結(jié)束前逆日,都會(huì)存儲(chǔ)在這里,但是并不是每個(gè)節(jié)點(diǎn)的變量變化都在這里萄凤,比如一個(gè)布爾值的confirm如果多次傳入室抽,這里也只會(huì)存在一個(gè)confirm,但是在act_hi_detail表中會(huì)有每個(gè)節(jié)點(diǎn)中confirm變化的值)
(3)用戶信息類
- act_id_group:審批組信息表
- act_id_info:用戶擴(kuò)展信息表
- act_id_membership:用戶和審批組之間的關(guān)系的表
- act_id_tenant:租戶信息表
- act_id_tenant_member:用戶租戶關(guān)系表
- act_id_user:用戶信息表
(4)流程歷史記錄類
- act_hi_actinst:歷史的活動(dòng)實(shí)例表
- act_hi_attachment:歷史的流程附件表
- act_hi_batch:歷史的批處理記錄表
- act_hi_caseactinst:歷史的CMMN活動(dòng)實(shí)例表
- act_hi_caseinst:歷史的CMMN實(shí)例表
- act_hi_comment:歷史的流程審批意見表
- act_hi_dec_in:歷史的DMN變量輸入表
- act_hi_dec_out:歷史的DMN變量輸出表
- act_hi_decinst:歷史的DMN實(shí)例表靡努,包含有關(guān)決策的單個(gè)評(píng)估的信息坪圾,包括輸入和輸出值
- act_hi_detail:歷史的流程運(yùn)行時(shí)變量詳情記錄表
- act_hi_ext_task_log:歷史的流程任務(wù)消息執(zhí)行表
- act_hi_identitylink:歷史的流程運(yùn)行過程中用戶關(guān)系
- act_hi_incident:歷史的流程異常事件記錄表
- act_hi_job_log:歷史的流程作業(yè)記錄表
- act_hi_op_log:歷史的用戶操作記錄表,包含有關(guān)用戶執(zhí)行的操作的信息的日志條目惑朦,這用于記錄操作神年,如創(chuàng)建新任務(wù)、完成任務(wù)等
- act_hi_procinst:歷史的流程實(shí)例
- act_hi_taskinst:歷史的任務(wù)實(shí)例
- act_hi_varinst:歷史的流程變量記錄表
(5)流程通用數(shù)據(jù)類
- act_ge_bytearray:流程引擎二進(jìn)制數(shù)據(jù)表
- act_ge_property:流程引擎屬性配置表
- act_ge_schema_log:數(shù)據(jù)庫腳本執(zhí)行日志表
3行嗤、每個(gè)表中字段說明
(1)act_ge_bytearray(流程引擎二進(jìn)制數(shù)據(jù)表)
- id:主鍵
- rev_:版本
- name_:名稱
- deployment_id_:部署id
- bytes_:字節(jié)內(nèi)容
- generated_:是否系統(tǒng)生成(0用戶創(chuàng)建,null系統(tǒng)創(chuàng)建)
- tenant_id_:租戶id
- type_:類型
- create_time_:創(chuàng)建時(shí)間
- root_proc_inst_id_:流程實(shí)例根id
- removal_time_:刪除時(shí)間
(2)act_ge_property(流程引擎屬性配置表)
- name_:名稱
- value_:值
- rev_:版本
(3)act_ge_schema_log(數(shù)據(jù)庫腳本執(zhí)行日志表)
- id_:主鍵
- timestamp_:時(shí)間戳
- version_:版本
(4)act_hi_actinst(歷史的活動(dòng)實(shí)例表)
- id_:主鍵
- parent_act_inst_id_:父節(jié)點(diǎn)實(shí)例id
- proc_def_key_:流程定義key
- proc_def_id_:流程定義id
- root_proc_inst_id_:流程實(shí)例根id
- proc_inst_id_:流程實(shí)例id
- execution_id_:執(zhí)行實(shí)例id
- act_id_:節(jié)點(diǎn)id
- task_id_:任務(wù)id
- call_proc_inst_id_:調(diào)用外部的流程實(shí)例id
- call_case_inst_id_:調(diào)用外部的案例實(shí)例id
- act_name_:節(jié)點(diǎn)名稱
- acr_type_:節(jié)點(diǎn)類型
- assignee_:辦理人
- start_time_:開始時(shí)間
- end_time_:結(jié)束時(shí)間
- duration_:耗時(shí)
- act_inst_state_:活動(dòng)實(shí)例狀態(tài)
- sequence_counter_:序列計(jì)數(shù)器
- tenant_id_:租戶id
- removal_time_:刪除時(shí)間
(5)act_hi_comment(歷史流程審批意見表)
- id_:主鍵
- type_:類型
- time_:時(shí)間
- user_id_:處理人id
- task_id_:任務(wù)id
- root_proc_inst_id_:流程實(shí)例根id
- proc_inst_id_:流程實(shí)例id
- action_:行為類型
- messages_:基本內(nèi)容
- full_msg_:全部內(nèi)容
- tenant_id_:租戶id
- removal_time_:刪除時(shí)間
(6)act_hi_detail(歷史的流程運(yùn)行詳情表)
- id:主鍵
- type_:類型
- proc_def_key_:流程定義key
- proc_def_id_:流程定義id
- root_proc_inst_id_:流程實(shí)例根id
- proc_inst_id_:流程實(shí)例id
- execution_id_:流程執(zhí)行id
- case_def_key_:案例定義key
- case_def_id_:案例定義id
- case_inst_id_:案例實(shí)例id
- case_execution_id_:案例執(zhí)行id
- task_id_:任務(wù)id
- act_inst_id_:節(jié)點(diǎn)實(shí)例id
- var_inst_id_:流程變量記錄id
- name_:名稱
- var_type_:變量類型
- rev_:版本
- time_:時(shí)間戳
- bytearray_id_:二進(jìn)制數(shù)據(jù)對(duì)應(yīng)id
- double_:double類型值
- long_:long類型值
- text_:文本類型值
- text2_:文本類型值2
- sequence_counter_:序列計(jì)數(shù)器
- tenant_id_:租戶id
- operation_id_:操作id
- removal_time_:刪除時(shí)間
(7)act_hi_identitylink(歷史的流程運(yùn)行過程中用戶表)
- id_:主鍵
- timestamp_:時(shí)間戳
- type_:類型
- user_id_:用戶id
- group_id_:用戶組id
- task_id_:任務(wù)id
- root_proc_inst_id_:流程實(shí)例根id
- proc_def_id_:流程定義id
- operation_type_:操作類型
- assigner_id_:分配者id
- proc_def_key_:流程定義key
- tenant_id_:租戶id
- removal_time_:刪除時(shí)間
(8)act_hi_procinst(歷史的流程實(shí)例表)
- id_:主鍵
- proc_inst_id_:流程實(shí)例id
- business_key_:業(yè)務(wù)key
- proc_def_key_:流程定義key
- pro_def_id_:流程定義id
- start_time_:開始時(shí)間
- end_time_:結(jié)束時(shí)間
- removal_time_:刪除時(shí)間
- duration_:耗時(shí)
- start_user_id_:啟動(dòng)人id
- start_act_id_:啟動(dòng)節(jié)點(diǎn)id
- end_act_id_:結(jié)束節(jié)點(diǎn)
- super_process_instance_id_:父流程實(shí)例id
- root_proc_inst_id_:流程實(shí)例根id
- super_case_instance_id_:父案例實(shí)例id
- case_inst_id_:案例實(shí)例id
- delete_reason_:刪除原因
- tenant_id_:租戶id
- state_:狀態(tài)
(9)act_hi_taskinst(歷史的任務(wù)實(shí)例表)
- id_:主鍵
- task_def_key_:任務(wù)定義key
- proc_def_key_:流程定義key
- proc_def_id_:流程定義id
- root_proc_inst_id_:流程實(shí)例根id
- proc_inst_id_:流程實(shí)例id
- execution_id_:流程執(zhí)行id
- case_def_key_:案例定義key
- case_def_id_:案例定義id
- case_inst_id_:案例實(shí)例id
- case_execution_id_:案例執(zhí)行id
- act_inst_id_:節(jié)點(diǎn)實(shí)例id
- name_:名稱
- parent_task_id_:父任務(wù)id
- description_:描述
- owner_:委托人id
- assignee_:辦理人id
- start_time_:開始時(shí)間
- end_time_:結(jié)束時(shí)間
- duration_:耗時(shí)
- delete_reason_:刪除原因
- priority_:優(yōu)先級(jí)
- due_date_:超時(shí)時(shí)間
- follow_up_date_:跟蹤時(shí)間
- tenant_id_:租戶id
- removal_time_:刪除時(shí)間
(10)act_hi_varinst(歷史的流程變量表)
- id_:主鍵
- proc_def_key_:流程定義key
- proc_def_id_:流程定義id
- root_proc_inst_id_:流程實(shí)例根id
- proc_inst_id:流程實(shí)例id
- execution_id_:流程執(zhí)行id
- act_inst_id:節(jié)點(diǎn)實(shí)例id
- case_def_key_:案例定義key
- case_def_id_:案例定義id
- case_inst_id_:案例實(shí)例id
- case_execution_id_:案例執(zhí)行id
- task_id_:任務(wù)id
- name_:名稱
- var_type_:變量類型
- create_time_:創(chuàng)建時(shí)間
- rev_:版本
- bytearrary_id_:二進(jìn)制數(shù)據(jù)id
- double_:double類型值
- long_:long類型值
- text_:文本類型值
- text2_:文本類型值2
- tenant_id_:租戶id
- state_:狀態(tài)
- removal_time_:刪除時(shí)間
(11)act_id_user(用戶表)
- id_:主鍵
- rev_:版本
- first_:姓
- last_:名
- emall_:郵件
- pwd_:密碼
- salt_:鹽值
- lock_exp_time_:鎖定過期時(shí)間
- attempts_:嘗試次數(shù)
- picture_id_:圖片id
(12)act_id_group(群組表)
- id_:主鍵
- rev_:版本
- name_:組名稱
- type_:組類型(SYSTEM系統(tǒng)垛耳、WORKFLOW業(yè)務(wù))
(13)act_id_membership(用戶與群組關(guān)系表)
- user_id_:用戶id
- group_id_:組id
(14)act_re_deployment(流程部署表)
- id_:主鍵
- name_:流程名稱
- deploy_time_:部署時(shí)間
- source_:來源
- tenant_id_:租戶id
(15)act_re_procdef(流程定義表)
- id_:主鍵
- rev_:版本
- category_:流程定義的Namespace分類
- name_:流程定義名稱
- key_:流程定義key
- version_:流程定義版本號(hào)
- deployment_id_:部署id
- resource_name_:資源名稱
- dgrm_resource_name_:gram資源名稱
- has_start_form_key_:是否有啟動(dòng)表單
- suspension_state_:流程掛起
- tenant_id_:租戶id
- version_tag_:版本標(biāo)簽
- startable_:是否是可啟動(dòng)流程
(16)act_ru_event_subscr(流程事件訂閱表)
- id_:主鍵
- rev_:版本
- event_type_:事件類型
- event_name_:事件名稱
- execution_id_:執(zhí)行id
- pro_inst_id:流程實(shí)例id
- activity_id_:節(jié)點(diǎn)id
- configuration_:配置
- created_:創(chuàng)建時(shí)間
- tenant_id_:租戶id
(17)act_ru_execution(流程運(yùn)行時(shí)表)
- id_:主鍵
- rev_:版本
- root_proc_inst_id_:流程實(shí)例根id
- proc_inst_id_:流程實(shí)例id
- business_key_:業(yè)務(wù)key
- parent_id_:流程父實(shí)例id
- proc_def_id_:流程定義id
- super_exec_:父流程實(shí)例對(duì)應(yīng)的執(zhí)行
- super_case_exec_:父案例實(shí)例對(duì)應(yīng)的執(zhí)行
- case_inst_id_:案例實(shí)例id
- act_id_:節(jié)點(diǎn)id
- act_inst_id:節(jié)點(diǎn)實(shí)例id
- is_active_:是否激活
- is_concurrent_:是否并行
- is_scope_是否多實(shí)例范圍
- is_event_scope_:是否事件多實(shí)例范圍
- suspension_state_:掛起狀態(tài)
- cached_ent_state_:緩存狀態(tài)
- sequence_counter_:序列計(jì)數(shù)器
- tenant_id_:租戶id
(18)act_ru_identitylink(流程運(yùn)行時(shí)表)
- id_:主鍵
- rev_:版本
- group_id_:用戶組id
- type_:類型
- user_id_:用戶id
- task_id_:任務(wù)id
- proc_def_id_:流程定義id
- tenant_id_:租戶id
(19) act_ru_incident( 運(yùn)行時(shí)異常記錄表)
- id_:主鍵
- rev_:版本
- incident_timestamp_:事件時(shí)間戳
- incident_msg_:事件信息
- incident_type_:事件類型
- execution_id_:流程執(zhí)行id
- activity_id_:節(jié)點(diǎn)id
- proc_inst_id_:流程實(shí)例id
- proc_def_id_:流程定義id
- cause_incident_id_:事件原因id
- root_cause_incident_id_:事件原因根id
- configuration_:事件配置
- tenant_id_:租戶id
- job_def_id_:job定義id
(20)act_ru_job( 流程運(yùn)行時(shí)作業(yè)表)
- id_:主鍵
- rev_:版本
- type_:類型
- lock_exp_time_:鎖定過期時(shí)間
- lock_owner_:鎖定用戶
- exclusive_:獨(dú)占標(biāo)識(shí)
- execution_id_:執(zhí)行id
- process_instance_id_:流程實(shí)例id
- process_def_id_:流程定義id
- process_def_key_:流程定義key
- retries_:重試次數(shù)
- exception_stack_id_:異常堆棧id
- exception_msg_:異常信息
- duedate_:截止時(shí)間
- repeat_:重復(fù)
- handler_type_:處理類型
- handler_cfg_:處理配置
- deployment_id_:部署id
- suspension_state_:掛起狀態(tài)
- job_def_id_:作業(yè)定義id
- priority_:作業(yè)優(yōu)先級(jí)
- sequence_counter_:序列計(jì)數(shù)器
- tenant_id:租戶id
- create_time_:創(chuàng)建時(shí)間
(21)act_ru_jobdef( 流程作業(yè)定義表)
- job_type_:job類型
- job_configuration_:job配置
- suspension_state_:掛起狀態(tài)
- job_priority:優(yōu)先級(jí)
(22)act_ru_task( 流程運(yùn)行時(shí)任務(wù)表)
- execution_id_:流程執(zhí)行id
- proc_inst_id_:流程實(shí)例id
- proc_def_id_:流程定義id
- case_execution_id_:案例執(zhí)行id
- case_inst_id_:案例實(shí)例id
- case_def_id_:案例定義id
- parent_task_id_:父任務(wù)id
- description_:描述
- task_def_key_:任務(wù)定義key
- owner_:委托人
- assignee_:辦理人
- delegation:委托狀態(tài)
- priority_:優(yōu)先級(jí)
- due_date_:截止時(shí)間
- follow_up_date_:跟蹤時(shí)間
- suspension_state_:掛起狀態(tài)
(23)act_ru_variable( 流程運(yùn)行時(shí)變量表)
- execution_id_:流程執(zhí)行id
- proc_inst_id_:流程實(shí)例id
- case_exrcution_id_:案例執(zhí)行id
- case_inst_id_:案例實(shí)例id
- task_id_:任務(wù)id
- bytearray_id_:二進(jìn)制內(nèi)容id
- double_:double類型值
- long_:long類型值
- text_:文本
- text2:文本2
- var_scope_:變量范圍
- sequence_counter_:序列計(jì)數(shù)器
- is_concurrent_local_:是否并發(fā)
三栅屏、springboot集成camunda部署教程以及說明
1、創(chuàng)建springboot項(xiàng)目堂鲜,并且導(dǎo)入依賴
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.zjy.workflow</groupId>
<artifactId>camunda-springboot-testdemo</artifactId>
<version>1.0.0-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>2.7.9</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.camunda.bpm</groupId>
<artifactId>camunda-bom</artifactId>
<version>7.19.0</version>
<scope>import</scope>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<!-- 流程引擎 在Rest服務(wù)接口的依賴中有了-->
<!-- <dependency>-->
<!-- <groupId>org.camunda.bpm.springboot</groupId>-->
<!-- <artifactId>camunda-bpm-spring-boot-starter</artifactId>-->
<!-- <version>7.17.0</version>-->
<!-- </dependency>-->
<!-- Rest服務(wù)接口-->
<dependency>
<groupId>org.camunda.bpm.springboot</groupId>
<artifactId>camunda-bpm-spring-boot-starter-rest</artifactId>
</dependency>
<!-- web界面模塊栈雳,就是那個(gè)駕駛艙登錄界面,不需要可以不導(dǎo)入-->
<dependency>
<groupId>org.camunda.bpm.springboot</groupId>
<artifactId>camunda-bpm-spring-boot-starter-webapp</artifactId>
</dependency>
<dependency>
<groupId>org.camunda.bpm</groupId>
<artifactId>camunda-engine-plugin-spin</artifactId>
</dependency>
<dependency>
<groupId>org.camunda.spin</groupId>
<artifactId>camunda-spin-dataformat-all</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba.fastjson2</groupId>
<artifactId>fastjson2</artifactId>
<version>2.0.12</version>
</dependency>
<!--mysql-->
<!-- <dependency>-->
<!-- <groupId>mysql</groupId>-->
<!-- <artifactId>mysql-connector-java</artifactId>-->
<!-- <version>5.1.47</version>-->
<!-- </dependency>-->
<!--postgresql-->
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
<version>1.1.21</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j2</artifactId>
<version>2.6.1</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.7.9</version>
</plugin>
</plugins>
</build>
</project>
2缔莲、創(chuàng)建application.yml
server:
port: 8088
spring:
application:
name: camunda-springboot-testdemo
datasource:
# postgresql
url: jdbc:postgresql://192.168.126.130:5432/postgres?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&useSSL=false&useSSL=false
type: com.alibaba.druid.pool.DruidDataSource
username: postgres
password: root
driver-class-name: org.postgresql.Driver
sql:
init:
mode: always
# mysql
# url: jdbc:mysql://39.103.217.57:3306/camunda2?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false&useOldAliasMetadataBehavior=true
# driver-class-name: com.mysql.jdbc.Driver
# username: root
# password: root
camunda:
bpm:
admin-user:
id: demo
password: demo
auto-deployment-enabled: false # 關(guān)閉springboot繼承好的自動(dòng)部署功能
3哥纫、創(chuàng)建日志輸出log4j2.xml配置文件
<?xml version="1.0" encoding="UTF-8" ?>
<!--monitorInterval屬性值(秒數(shù))為一個(gè)非零值來讓Log4j每隔指定的秒數(shù)來重新讀取配置文件,可以用來動(dòng)態(tài)應(yīng)用Log4j配置-->
<Configuration status="debug" monitorInterval="30">
<!--用來自定義一些變量-->
<Properties>
<!--變量定義-->
<Property name="myPattern" value="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
<!-- <Property name="dir_url">d:/logs</Property>-->
</Properties>
<!--使用Appenders元素可以將日志事件數(shù)據(jù)寫到各種目標(biāo)位置-->
<Appenders>
<!-- 默認(rèn)打印到控制臺(tái) -->
<Console name="ConsoleAppend" target="SYSTEM_OUT">
<!-- 默認(rèn)打印格式 -->
<PatternLayout pattern="${myPattern}"/>
</Console>
<!-- 打印到日志文件上 -->
<!-- <File name="FileAppend" fileName="${dir_url}/fileLog.log" bufferedIO="true" immediateFlush="true">-->
<!-- <PatternLayout>-->
<!-- <pattern>${myPattern}</pattern>-->
<!-- </PatternLayout>-->
<!-- </File>-->
</Appenders>
<!--定義logger痴奏,只有定義了logger并引入的appender蛀骇,appender才會(huì)生效-->
<Loggers>
<!-- 默認(rèn)打印日志級(jí)別為 error -->
<Root level="INFO">
<AppenderRef ref="ConsoleAppend"/>
<AppenderRef ref="FileAppend"/>
</Root>
</Loggers>
</Configuration>
4、使用流程設(shè)計(jì)器读拆,設(shè)計(jì)一個(gè)bpmn流程擅憔,并保存到resources目錄下
(1)預(yù)約維修節(jié)點(diǎn)
(2)師傅上門維修節(jié)點(diǎn)
(3)公司電話回訪節(jié)點(diǎn)
(4)查看評(píng)分節(jié)點(diǎn)
5、創(chuàng)建service
(1)預(yù)約維修節(jié)點(diǎn)
package com.zjy.workflow.service;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.camunda.bpm.engine.delegate.JavaDelegate;
import org.springframework.stereotype.Service;
/**
* @創(chuàng)建人 zjy
* @文件名 ReserveRepairService
* @創(chuàng)建時(shí)間 2023/10/20
* @描述 預(yù)約維修
*/
@Service
public class ReserveRepairService implements JavaDelegate {
private final Logger logger = LogManager.getLogger(ReserveRepairService.class);
@Override
public void execute(DelegateExecution execution) throws Exception {
logger.info("進(jìn)入到預(yù)約家電維修環(huán)節(jié)~");
String currentActivityName = execution.getCurrentActivityName();
String currentActivityId = execution.getCurrentActivityId();
logger.info("當(dāng)前活動(dòng)名稱:" + currentActivityName + "\n當(dāng)前活動(dòng)id:" + currentActivityId);
}
}
(2)師傅上門維修節(jié)點(diǎn)
package com.zjy.workflow.service;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.camunda.bpm.engine.delegate.JavaDelegate;
import org.springframework.stereotype.Service;
/**
* @創(chuàng)建人 zjy
* @文件名 DoingRepairService
* @創(chuàng)建時(shí)間 2023/10/23
* @描述 師傅上門維修
*/
@Service("doRepair")
public class DoingRepairService implements JavaDelegate {
private final Logger logger = LogManager.getLogger(DoingRepairService.class);
@Override
public void execute(DelegateExecution execution) throws Exception {
logger.info("進(jìn)入到師傅上門維修環(huán)節(jié)~");
String currentActivityName = execution.getCurrentActivityName();
logger.info("當(dāng)前活動(dòng)名:" + currentActivityName);
execution.setVariable("repairName","小王");
}
}
(3)公司電話回訪和查看評(píng)分節(jié)點(diǎn)
package com.zjy.workflow.service;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.springframework.stereotype.Service;
/**
* @創(chuàng)建人 zjy
* @文件名 TelCallService
* @創(chuàng)建時(shí)間 2023/10/23
* @描述 公司電話回訪和查看評(píng)分
*/
@Service("telCall")
public class TelCallService {
private final Logger logger = LogManager.getLogger(TelCallService.class);
// 公司電話回訪
public int doCall(DelegateExecution execution) {
logger.info("公司電話回訪~");
Object repairName = execution.getVariable("repairName");
logger.info("您對(duì)" + repairName.toString() + "打了幾分檐晕?");
logger.info("您對(duì)" + String.valueOf(repairName) + "打了幾分暑诸?");
return 10;
}
// 查看評(píng)分
public void getScore(DelegateExecution execution) {
logger.info("查看評(píng)分~");
String s = String.valueOf(execution.getVariable("repairName"));
Object score = execution.getVariable("score");
logger.info("顧客對(duì)" + s + "的評(píng)分:" + (int)score);
}
}
6、創(chuàng)建controller
package com.zjy.workflow.controller;
import org.camunda.bpm.engine.RepositoryService;
import org.camunda.bpm.engine.RuntimeService;
import org.camunda.bpm.engine.repository.Deployment;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/flow")
public class FlowController {
@Autowired
private RepositoryService repositoryService;
@Autowired
private RuntimeService runtimeService;
// 說明:springboot項(xiàng)目在依賴camunda-bpm-spring-boot-starter中已經(jīng)實(shí)現(xiàn)了自動(dòng)部署的功能辟灰,
// 所以我們不用在執(zhí)行下面的controller方法去手動(dòng)部署流程了个榕,在啟動(dòng)項(xiàng)目的時(shí)候,springboot項(xiàng)目
// 會(huì)自動(dòng)幫我們部署好resources目錄下的所有流程
@GetMapping("/deploy")
public String deplopy(){
Deployment deploy = repositoryService.createDeployment()
.name("部署的第一個(gè)流程") // 定義部署文件的名稱
.addClasspathResource("LoanApproval.bpmn") // 綁定需要部署的流程文件
.deploy();// 部署流程
return deploy.getId() + ":" + deploy.getName();
}
@GetMapping("/startFlow/{processKey}")
public void startFlow(@PathVariable String processKey) {
runtimeService.startProcessInstanceByKey(processKey); // 這里的方法是ByKey芥喇!
}
}
7西采、啟動(dòng)項(xiàng)目測(cè)試。
8乃坤、部署說明
說明:有三種部署方式苛让。
(1)代碼方法(手動(dòng)部署)
@Autowired
private RepositoryService repositoryService;
@GetMapping("/deploy")
public String deplopy(){
Deployment deploy = repositoryService.createDeployment()
.name("部署的第一個(gè)流程") // 定義部署文件的名稱
.addClasspathResource("LoanApproval.bpmn") // 綁定需要部署的流程文件
.deploy();// 部署流程
return deploy.getId() + ":" + deploy.getName();
}
(2)通過依賴camunda-bpm-spring-boot-starter自動(dòng)部署
導(dǎo)入依賴
<dependency>
<groupId>org.camunda.bpm.springboot</groupId>
<artifactId>camunda-bpm-spring-boot-starter</artifactId>
<version>7.17.0</version>
</dependency>
啟動(dòng)項(xiàng)目沟蔑,就自動(dòng)將resources目錄下的所有流程部署好了。
可以通過修改配置來關(guān)閉自動(dòng)部署:
camunda:
bpm:
auto-deployment-enabled: false # 關(guān)閉自動(dòng)部署
(3)使用processes.xml配置文件實(shí)現(xiàn)自動(dòng)部署
在resources目錄下新建META-INF目錄狱杰,在META-INF目錄下新建processes.xml
<process-application
xmlns="http://www.camunda.org/schema/1.0/ProcessApplication"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<process-archive>
<process-engine>default</process-engine>
<!-- 默認(rèn)會(huì)掃描resource(及其子目錄下)的*.bpmn, *.cmmn, *.dmn文件 -->
<!-- 可通過<resource/>指定其他的需要一同部署的資源文件-->
<!-- 注:formKey中路徑需和resource路徑一致瘦材,如:camunda-forms:deployment:bpmn/payment_confirm.form -->
<!-- 注:通過Modeler作為附件一起部署,formKey格式為:camunda-forms:deployment:payment_confirm.form -->
<!--<resource>bpmn/PaymentInitForm.form</resource>
<resource>bpmn/PaymentConfirmForm.form</resource>-->
<properties>
<property name="isDeleteUponUndeploy">false</property>
<property name="isScanForProcessDefinitions">true</property>
</properties>
</process-archive>
</process-application>
然后在項(xiàng)目啟動(dòng)類上使用注解 @EnableProcessApplication仿畸,啟動(dòng)項(xiàng)目食棕,也可以把resources目錄下的所有流程成功部署。
注意:使用processes.xml配置文件實(shí)現(xiàn)自動(dòng)部署错沽,必須使用注解 @EnableProcessApplication 才能生效簿晓,不然不會(huì)自動(dòng)部署。
9千埃、節(jié)點(diǎn)參數(shù)介紹
(1)Service Task(自動(dòng)執(zhí)行節(jié)點(diǎn))
1)Implementation
a. Java Class
需要實(shí)現(xiàn)JavaDelegate接口蹋艺,并將實(shí)現(xiàn)了JavaDelegate接口的類的全路徑填寫到Java class一欄扣溺;
b. Delegate expression
需要實(shí)現(xiàn)JavaDelegate接口,然后將實(shí)現(xiàn)了JavaDelegate接口的類使用注解注入到容器中(可以起個(gè)別名),然后將類的名字開頭變小寫填入Delegate expression一欄(如果使用了別名舒萎,就填別名)当纱,它會(huì)自動(dòng)執(zhí)行execute的方法韭赘;
c. Expression
將類注入到容器中(可以起個(gè)別名)揍愁,類中方法的參數(shù)為DelegateExecution execution,然后在Expression一欄填入類名開頭變小寫.方法名(execution)冯挎,Result variable為方法的返回值變量名底哥;
a、b房官、c填入例子可以查看上面部署流程趾徽。
(2)并行
1)nrOfActiviteInstances:當(dāng)前活動(dòng)的實(shí)例數(shù)量,即還沒有完成的實(shí)例數(shù)量翰守;
2)loopCounter:循環(huán)計(jì)數(shù)器附较,辦理人在列表中的索引;
3)nrOfInstances:多實(shí)例任務(wù)中總共的實(shí)例數(shù)潦俺;
4)nrOfCompletedInstances:已經(jīng)完成的實(shí)例數(shù)量拒课。
可以通過設(shè)置Completion Condition 為${nrOfCompletedInstances == 2}表示任意兩個(gè)人完成審批。
10事示、流程執(zhí)行過程說明
每個(gè)節(jié)點(diǎn)執(zhí)行時(shí)早像,都會(huì)先執(zhí)行下一個(gè)節(jié)點(diǎn)的User assignment、Task listeners等肖爵,目的是將設(shè)置好的數(shù)據(jù)卢鹦,比如下一個(gè)節(jié)點(diǎn)審批人,審批策略等傳給前端。
四冀自、外部任務(wù)訂閱
1揉稚、項(xiàng)目git地址:https://gitee.com/zuo-junyuan/camunda.git
2、項(xiàng)目介紹
(1)bpmn是:RomeInvades.bpmn熬粗,在src/main/resources/bpmn/zjy/RomeInvades.bpmn搀玖;
(2)只實(shí)現(xiàn)三個(gè)業(yè)務(wù)節(jié)點(diǎn),最后那個(gè)用戶節(jié)點(diǎn)沒有去實(shí)現(xiàn)(主要針對(duì)的是業(yè)務(wù)節(jié)點(diǎn)的外部任務(wù)實(shí)現(xiàn))驻呐,第一個(gè)業(yè)務(wù)是Decide On Direction of Expansion灌诅,是使用nodejs實(shí)現(xiàn)的外部任務(wù);
(3)說明:啟動(dòng)項(xiàng)目含末,登錄駕駛艙查看猜拾,有這個(gè)工作流了,啟動(dòng)流程佣盒,如果沒有外部任務(wù)去獲取訂閱這個(gè)啟動(dòng)的流程挎袜,流程就會(huì)一直卡在第一個(gè)Decide On Direction of Expansion節(jié)點(diǎn)上,無法往下執(zhí)行肥惭,只有當(dāng)啟動(dòng)訂閱了這個(gè)主題的外部任務(wù)啟動(dòng)后宋雏,才會(huì)往下執(zhí)行。