一、前言
-
19世纪70年代,流程管理思想萌芽阶段。
怎样提高工作效率?
泰勒:标准化个人操作流程
亨利·福特:规定标准时间定额
标准化、精简化、通用化、专业化。
-
20世纪70年代,工作流技术起源于办公自动化领域的研究。由于当时计算机尚未普及,网络技术水平还很低以及理论基础匮乏,这项新技术并未取得成功,许多公司采用纸张表单,手工传递的方式,一级一级审批签字,工作效率非常低下。
-
20世纪90年代,信息技术驱动流程自动化阶段。信息技术开始引入管理领域,对传统的业务进行自动化改造。
产品:sabre订票系统,mrp(物料需求计划),mis(管理信息系统),cims(计算机集成制造系统)。
-
21世纪初,bpm管理与治理结合。
bpr/bpi:以信息技术为核心重新设计业务流程,失败率高达50%-70%;
bpm:以业务流程为主导的管理思想;
bpm治理思想:对bpm实施的成功率以及roi的高要求,强调bpm与企业战略相结合。
二、bpmn介绍
bpmn(business process modeling notation,业务流程建模符号)是一种用于描述业务流程的标准化建模语言。它通过图形符号及规则,帮助企业建模、分析和优化各种业务流程。bpmn有两个主要版本:bpmn 1.0和bpmn 2.0。bpmn 1.0规范由标准组织bpmi(后并入到omg)于2004年5月发布;bpmn 2.0标准由omg于2011年推出。
2.0相对于1.0规范了流程引擎的语义和格式,利用标准的图元描述真实的业务发生过程,保证相同的流程在不同的流程引擎中得到一致的执行结果。
bpmn的理论基础
-
流程建模:bpmn使用不同的图形符号来表示业务流程中的各项活动、任务、决策和事件等。这些符号包括任务、网关、事件等,每个符号都有特定的含义和用法。
-
流程分析:通过bpmn模型,企业可以分析业务流程的效率、资源利用率和风险等,以便进行优化和改进。
-
流程执行:bpmn不仅是一种建模语言,还可以将建模的业务流程实际执行起来,并进行监控和控制。
bpmn的优势
传统使用场景
-
采购流程:通过bpmn建模,企业可以规范采购流程,包括需求确认、供应商选择、合同签订、物品收货等环节,提高采购效率。
-
请假审批流程:bpmn模型可以帮助企业规范请假审批流程,包括员工请假申请、直属主管审批、人力资源部门审批等环节,减少误差和纠纷。
-
客户投诉处理流程:利用bpmn,企业可以清晰地展示客户投诉处理流程,包括客户投诉登记、处理人员分配、处理过程跟踪、客户反馈等环节,提高客户满意度。
三、实践举例:xx平台xxx商家合规治理任务优化项目(非真实场景)
背景目标
-
商家合规治理手段的单一性和对线下人工的过度依赖方面需要优化,通过整合商家合规治理策略,并实现这些策略的可在线化配置。这一举措将打破传统的手工操作模式,允许业务方直接在系统中配置和更新治理策略,减少人工干预,提高治理效率。同时,在线化配置也便于策略的快速部署和灵活调整,以应对不同业务场景下的合规要求。
-
各商家的合规治理进度和状态的透明度方面需要优化,为改变这一现状,我们需要搭建一套高效的工作流引擎。该引擎将支持商家合规治理流程的编排和自动化流转,从任务触发到完成审核、记录反馈等各个环节都将实现自动化处理。同时,内置的进度跟踪机制将确保业务团队能够实时查看各商家的治理进度,及时发现问题并采取相应措施。这将大大提高治理的透明度和可控性。
-
评估治理成果和手段的有效性分析方面需要优化,将合规治理成果的数据可视化,通过强大的数据分析与可视化系统,我们将关键指标(如治理效率、违规率、改进情况等)以图表、报告等形式直观展现。同时,通过持续的数据分析与改进循环,我们将逐步优化治理策略和方式,最终形成商家合规治理的闭环机制。
方案
业务流程
治理流程1
治理流程2
系统架构图
流程编排
工作流技术选型
smartengine详细介绍
e-r图
create table `se_deployment_instance` (
`id` bigint(20) unsigned not null auto_increment comment 'pk' ,
`gmt_create` datetime(6) not null comment 'create time' ,
`gmt_modified` datetime(6) not null comment 'modification time' ,
`process_definition_id` varchar(255) not null comment 'process definition id' ,
`process_definition_version` varchar(255) default null comment 'process definition version' ,
`process_definition_type` varchar(255) default null comment 'process definition type' ,
`process_definition_code` varchar(255) default null comment 'process definition code' ,
`process_definition_name` varchar(255) default null comment 'process definition name' ,
`process_definition_desc` varchar(255) default null comment 'process definition desc' ,
`process_definition_content` mediumtext not null comment 'process definition content' ,
`deployment_user_id` varchar(128) not null comment 'deployment user id' ,
`deployment_status` varchar(64) not null comment 'deployment status' ,
`logic_status` varchar(64) not null comment 'logic status' ,
primary key (`id`)
) comment='流程定义表' ;
create table `se_process_instance` (
`id` bigint(20) unsigned not null auto_increment comment 'pk' ,
`gmt_create` datetime(6) not null comment 'create time' ,
`gmt_modified` datetime(6) not null comment 'modification time' ,
`process_definition_id_and_version` varchar(128) not null comment 'process definition id and version' ,
`process_definition_type` varchar(255) default null comment 'process definition type' ,
`status` varchar(64) not null comment ' 1.running 2.completed 3.aborted',
`parent_process_instance_id` bigint(20) unsigned default null comment 'parent process instance id' ,
`parent_execution_instance_id` bigint(20) unsigned default null comment 'parent execution instance id' ,
`start_user_id` varchar(128) default null comment 'start user id' ,
`biz_unique_id` varchar(255) default null comment 'biz unique id' ,
`reason` varchar(255) default null comment 'reason' ,
`comment` varchar(255) default null comment 'comment' ,
`title` varchar(255) default null comment 'title' ,
`tag` varchar(255) default null comment 'tag' ,
primary key (`id`)
) comment='流程实例表' ;
create table `se_activity_instance` (
`id` bigint(20) unsigned not null auto_increment comment 'pk' ,
`gmt_create` datetime(6) not null comment 'create time' ,
`gmt_modified` datetime(6) not null comment 'modification time' ,
`process_instance_id` bigint(20) unsigned default null comment 'process instance id' ,
`process_definition_id_and_version` varchar(255) not null comment 'process definition id and version' ,
`process_definition_activity_id` varchar(64) not null comment 'process definition activity id' ,
primary key (`id`)
) comment='活动节点实例表' ;
create table `se_task_instance` (
`id` bigint(20) unsigned not null auto_increment comment 'pk' ,
`gmt_create` datetime(6) not null comment 'create time' ,
`gmt_modified` datetime(6) not null comment 'modification time' ,
`process_instance_id` bigint(20) unsigned not null comment 'process instance id' ,
`process_definition_id_and_version` varchar(128) default null comment 'process definition id and version' ,
`process_definition_type` varchar(255) default null comment 'process definition type' ,
`activity_instance_id` bigint(20) unsigned not null comment 'activity instance id' ,
`process_definition_activity_id` varchar(255) not null comment 'process definition activity id' ,
`execution_instance_id` bigint(20) unsigned not null comment 'execution instance id' ,
`claim_user_id` varchar(255) default null comment 'claim user id' ,
`title` varchar(255) default null comment 'title' ,
`priority` int(11) default 500 comment 'priority' ,
`tag` varchar(255) default null comment 'tag' ,
`claim_time` datetime(6) default null comment 'claim time' ,
`complete_time` datetime(6) default null comment 'complete time' ,
`status` varchar(255) not null comment 'status' ,
`comment` varchar(255) default null comment 'comment' ,
`extension` varchar(255) default null comment 'extension' ,
primary key (`id`)
) comment='人工任务节点实例表' ;
create table `se_task_assignee_instance` (
`id` bigint(20) unsigned not null auto_increment comment 'pk' ,
`gmt_create` datetime(6) not null comment 'create time' ,
`gmt_modified` datetime(6) not null comment 'modification time' ,
`process_instance_id` bigint(20) unsigned not null comment 'process instance id' ,
`task_instance_id` bigint(20) unsigned not null comment 'task instance id' ,
`assignee_id` varchar(255) not null comment 'assignee id' ,
`assignee_type` varchar(128) not null comment 'assignee type' ,
primary key (`id`)
) comment='人工任务节点代理人实例表' ;
create table `se_execution_instance` (
`id` bigint(20) unsigned not null auto_increment comment 'pk' ,
`gmt_create` datetime(6) not null comment 'create time' ,
`gmt_modified` datetime(6) not null comment 'modification time' ,
`process_instance_id` bigint(20) unsigned not null comment 'process instance id' ,
`process_definition_id_and_version` varchar(255) not null comment 'process definition id and version' ,
`process_definition_activity_id` varchar(255) not null comment 'process definition activity id' ,
`activity_instance_id` bigint(20) unsigned not null comment 'activity instance id' ,
`active` tinyint(4) not null comment '1:active 0:inactive',
primary key (`id`)
) comment='执行节点实例表-最细粒度的实例' ;
create table `se_variable_instance` (
`id` bigint(20) unsigned not null auto_increment comment 'pk' ,
`gmt_create` datetime(6) not null comment 'create time' ,
`gmt_modified` datetime(6) not null comment 'modification time' ,
`process_instance_id` bigint(20) unsigned not null comment 'process instance id' ,
`execution_instance_id` bigint(20) unsigned default null comment 'execution instance id' ,
`field_key` varchar(128) not null comment 'field key' ,
`field_type` varchar(128) not null comment 'field type' ,
`field_double_value` decimal(65,30) default null comment 'field double value' ,
`field_long_value` bigint(20) default null comment 'field long value' ,
`field_string_value` varchar(4000) default null comment 'field string value' ,
primary key (`id`)
) comment='执行节点变量量表' ;
代码实操
第一步,要选择正确的smartengine版本,将其添加到pom依赖中。 com.alibaba.smart.framework
smart-engine-extension-storage-custom
3.0.0
第二步,完成smartengine初始化。在初始化时,一般要加载流程定义到应用中。集群情况下,要注意流程定义的一致性(如果纯静态记载则无此类问题)。在初始化时,可以根据需要定义bean的加载优先级。
import com.alibaba.smart.framework.engine.smartengine;
import com.alibaba.smart.framework.engine.configuration.instanceaccessor;
import com.alibaba.smart.framework.engine.configuration.processengineconfiguration;
import com.alibaba.smart.framework.engine.configuration.impl.defaultprocessengineconfiguration;
import com.alibaba.smart.framework.engine.configuration.impl.defaultsmartengine;
import com.alibaba.smart.framework.engine.exception.engineexception;
import com.alibaba.smart.framework.engine.service.command.repositorycommandservice;
import com.alibaba.smart.framework.engine.util.ioutil;
import org.springframework.beans.beansexception;
import org.springframework.beans.factory.annotation.autowired;
import org.springframework.boot.autoconfigure.condition.conditionalonclass;
import org.springframework.boot.autoconfigure.condition.conditionalonmissingbean;
import org.springframework.context.applicationcontext;
import org.springframework.context.applicationcontextaware;
import org.springframework.context.annotation.bean;
import org.springframework.context.annotation.configuration;
import org.springframework.core.annotation.order;
import org.springframework.core.io.resource;
import org.springframework.core.io.support.pathmatchingresourcepatternresolver;
import java.io.inputstream;
import static org.springframework.core.ordered.lowest_precedence;
@order(lowest_precedence)
[@configuration](https://my.oschina.net/pointdance)
@conditionalonclass(smartengine.class)
public class smartengineautoconfiguration implements applicationcontextaware {
private applicationcontext applicationcontext;
[@bean](https://my.oschina.net/bean)
@conditionalonmissingbean
public smartengine constructsmartengine() {
processengineconfiguration processengineconfiguration = new defaultprocessengineconfiguration();
// 实现instanceaccessor接口
processengineconfiguration.setinstanceaccessor(new custominstanceaccessservice());
smartengine smartengine = new defaultsmartengine();
smartengine.init(processengineconfiguration);
// 加载流程定义
deployprocessdefinition(smartengine);
return smartengine;
}
@override
public void setapplicationcontext(applicationcontext applicationcontext) throws beansexception {
this.applicationcontext = applicationcontext;
}
private class custominstanceaccessservice implements instanceaccessor {
@override
public object access(string name) {
return applicationcontext.getbean(name);
}
}
private void deployprocessdefinition(smartengine smartengine) {
repositorycommandservice repositorycommandservice = smartengine
.getrepositorycommandservice();
pathmatchingresourcepatternresolver resolver = new pathmatchingresourcepatternresolver();
try {
resource[] resources = resolver.getresources("classpath*:/smart-engine/*.xml");
for (resource resource : resources) {
inputstream inputstream = resource.getinputstream();
repositorycommandservice.deploy(inputstream);
ioutil.closequietly(inputstream);
}
} catch (exception e) {
throw new engineexception(e);
}
}
}
bmpn2.0 xml举例
附言:排他网关的条件表达式是跟着线条绑定的,要自己确保条件的是和否加在一起的总概率是100%,如果不是100%,小概率执行节点会卡在排他网关走不下去。例如:线条"否"的条件表达式为:条件1为假且条件2为假,线条"是"的条件表达式为条件1为真且条件2为真,则其他条件会卡死在排他网关流程走不下去。
test1.bpmn
<?xml version="1.0" encoding="utf-8"?>
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/bpmn/20100524/model" xmlns:bpmndi="http://www.omg.org/spec/bpmn/20100524/di" xmlns:dc="http://www.omg.org/spec/dd/20100524/dc" xmlns:di="http://www.omg.org/spec/dd/20100524/di" xmlns:modeler="http://camunda.org/schema/modeler/1.0" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" id="definitions_1" targetnamespace="http://bpmn.io/schema/bpmn" exporter="camunda web modeler" exporterversion="b1a091a" modeler:executionplatform="camunda cloud" modeler:executionplatformversion="8.5.0" camunda:diagramrelationid="2a2c997b-ff2f-49b0-9ba8-3c4860d223e7">
<bpmn:process id="process_1qijgvk" name="test1" isexecutable="true">
<bpmn:startevent id="startevent_1">
<bpmn:outgoing>flow_0soou9n</bpmn:outgoing>
</bpmn:startevent>
<bpmn:sequenceflow id="flow_0soou9n" sourceref="startevent_1" targetref="activity_02gdgyk" />
<bpmn:endevent id="event_1i2y4ym">
<bpmn:incoming>flow_07mf0sc</bpmn:incoming>
<bpmn:incoming>flow_1nd3369</bpmn:incoming>
<bpmn:incoming>flow_160ji3a</bpmn:incoming>
</bpmn:endevent>
<bpmn:exclusivegateway id="gateway_1kykneu" name="检查是否5天内完成治理">
<bpmn:extensionelements />
<bpmn:incoming>flow_0exjsc9</bpmn:incoming>
<bpmn:outgoing>flow_0hj860q</bpmn:outgoing>
<bpmn:outgoing>flow_1oqjt08</bpmn:outgoing>
</bpmn:exclusivegateway>
<bpmn:sequenceflow id="flow_0hj860q" name="否" sourceref="gateway_1kykneu" targetref="activity_1ms8vu6" />
<bpmn:servicetask id="activity_02gdgyk" name="站内通知商户去治理">
<bpmn:extensionelements />
<bpmn:incoming>flow_0soou9n</bpmn:incoming>
<bpmn:outgoing>flow_0exjsc9</bpmn:outgoing>
</bpmn:servicetask>
<bpmn:sequenceflow id="flow_0exjsc9" sourceref="activity_02gdgyk" targetref="gateway_1kykneu" />
<bpmn:servicetask id="activity_1ms8vu6" name="发送sms通知商户">
<bpmn:incoming>flow_0hj860q</bpmn:incoming>
<bpmn:outgoing>flow_0bemgki</bpmn:outgoing>
</bpmn:servicetask>
<bpmn:sequenceflow id="flow_0bemgki" sourceref="activity_1ms8vu6" targetref="gateway_1dyp6hh" />
<bpmn:sequenceflow id="flow_1oqjt08" name="是" sourceref="gateway_1kykneu" targetref="activity_1c9i1el" />
<bpmn:exclusivegateway id="gateway_1dyp6hh" name="是否10天内完成治理">
<bpmn:incoming>flow_0bemgki</bpmn:incoming>
<bpmn:outgoing>flow_07xq405</bpmn:outgoing>
<bpmn:outgoing>flow_1w4qeti</bpmn:outgoing>
</bpmn:exclusivegateway>
<bpmn:sequenceflow id="flow_07xq405" name="是" sourceref="gateway_1dyp6hh" targetref="activity_0m5dsna" />
<bpmn:servicetask id="activity_1c9i1el" name="发放奖励给到商户">
<bpmn:incoming>flow_1oqjt08</bpmn:incoming>
<bpmn:outgoing>flow_1t7ectj</bpmn:outgoing>
</bpmn:servicetask>
<bpmn:sequenceflow id="flow_1t7ectj" sourceref="activity_1c9i1el" targetref="activity_1p6mkdy" />
<bpmn:task id="activity_0m5dsna" name="任务完成">
<bpmn:incoming>flow_07xq405</bpmn:incoming>
<bpmn:outgoing>flow_07mf0sc</bpmn:outgoing>
</bpmn:task>
<bpmn:sequenceflow id="flow_07mf0sc" sourceref="activity_0m5dsna" targetref="event_1i2y4ym" />
<bpmn:sequenceflow id="flow_1w4qeti" name="否" sourceref="gateway_1dyp6hh" targetref="activity_1gud1rw" />
<bpmn:task id="activity_1p6mkdy" name="任务完成">
<bpmn:incoming>flow_1t7ectj</bpmn:incoming>
<bpmn:outgoing>flow_1nd3369</bpmn:outgoing>
</bpmn:task>
<bpmn:sequenceflow id="flow_1nd3369" sourceref="activity_1p6mkdy" targetref="event_1i2y4ym" />
<bpmn:servicetask id="activity_1gud1rw" name="通知运营下线商户店铺">
<bpmn:incoming>flow_1w4qeti</bpmn:incoming>
<bpmn:outgoing>flow_0vr5zs3</bpmn:outgoing>
</bpmn:servicetask>
<bpmn:sequenceflow id="flow_0vr5zs3" sourceref="activity_1gud1rw" targetref="activity_1pfbnmo" />
<bpmn:task id="activity_1pfbnmo" name="任务结束">
<bpmn:incoming>flow_0vr5zs3</bpmn:incoming>
<bpmn:outgoing>flow_160ji3a</bpmn:outgoing>
</bpmn:task>
<bpmn:sequenceflow id="flow_160ji3a" sourceref="activity_1pfbnmo" targetref="event_1i2y4ym" />
</bpmn:process>
<bpmndi:bpmndiagram id="bpmndiagram_1">
<bpmndi:bpmnplane id="bpmnplane_1" bpmnelement="process_1qijgvk">
<bpmndi:bpmnshape id="_bpmnshape_startevent_2" bpmnelement="startevent_1">
<dc:bounds x="152" y="232" width="36" height="36" />
</bpmndi:bpmnshape>
<bpmndi:bpmnshape id="gateway_1kykneu_di" bpmnelement="gateway_1kykneu" ismarkervisible="true">
<dc:bounds x="465" y="225" width="50" height="50" />
<bpmndi:bpmnlabel>
<dc:bounds x="448" y="188" width="84" height="27" />
</bpmndi:bpmnlabel>
</bpmndi:bpmnshape>
<bpmndi:bpmnshape id="activity_02gdgyk_di" bpmnelement="activity_02gdgyk">
<dc:bounds x="270" y="210" width="100" height="80" />
<bpmndi:bpmnlabel />
</bpmndi:bpmnshape>
<bpmndi:bpmnshape id="activity_1ms8vu6_di" bpmnelement="activity_1ms8vu6">
<dc:bounds x="630" y="210" width="100" height="80" />
<bpmndi:bpmnlabel />
</bpmndi:bpmnshape>
<bpmndi:bpmnshape id="event_1i2y4ym_di" bpmnelement="event_1i2y4ym">
<dc:bounds x="1182" y="232" width="36" height="36" />
</bpmndi:bpmnshape>
<bpmndi:bpmnshape id="gateway_1dyp6hh_di" bpmnelement="gateway_1dyp6hh" ismarkervisible="true">
<dc:bounds x="825" y="225" width="50" height="50" />
<bpmndi:bpmnlabel>
<dc:bounds x="810" y="285" width="79" height="27" />
</bpmndi:bpmnlabel>
</bpmndi:bpmnshape>
<bpmndi:bpmnshape id="activity_1c9i1el_di" bpmnelement="activity_1c9i1el">
<dc:bounds x="630" y="320" width="100" height="80" />
<bpmndi:bpmnlabel />
</bpmndi:bpmnshape>
<bpmndi:bpmnshape id="activity_0m5dsna_di" bpmnelement="activity_0m5dsna">
<dc:bounds x="950" y="210" width="100" height="80" />
<bpmndi:bpmnlabel />
</bpmndi:bpmnshape>
<bpmndi:bpmnshape id="bpmnshape_0ab1d2g" bpmnelement="activity_1p6mkdy">
<dc:bounds x="840" y="320" width="100" height="80" />
<bpmndi:bpmnlabel />
</bpmndi:bpmnshape>
<bpmndi:bpmnshape id="activity_1gud1rw_di" bpmnelement="activity_1gud1rw">
<dc:bounds x="800" y="80" width="100" height="80" />
<bpmndi:bpmnlabel />
</bpmndi:bpmnshape>
<bpmndi:bpmnshape id="bpmnshape_02s3tua" bpmnelement="activity_1pfbnmo">
<dc:bounds x="950" y="80" width="100" height="80" />
<bpmndi:bpmnlabel />
</bpmndi:bpmnshape>
<bpmndi:bpmnedge id="flow_0soou9n_di" bpmnelement="flow_0soou9n">
<di:waypoint x="188" y="250" />
<di:waypoint x="270" y="250" />
</bpmndi:bpmnedge>
<bpmndi:bpmnedge id="flow_0exjsc9_di" bpmnelement="flow_0exjsc9">
<di:waypoint x="370" y="250" />
<di:waypoint x="465" y="250" />
</bpmndi:bpmnedge>
<bpmndi:bpmnedge id="flow_0hj860q_di" bpmnelement="flow_0hj860q">
<di:waypoint x="515" y="250" />
<di:waypoint x="630" y="250" />
<bpmndi:bpmnlabel>
<dc:bounds x="567" y="232" width="11" height="14" />
</bpmndi:bpmnlabel>
</bpmndi:bpmnedge>
<bpmndi:bpmnedge id="flow_1oqjt08_di" bpmnelement="flow_1oqjt08">
<di:waypoint x="490" y="275" />
<di:waypoint x="490" y="360" />
<di:waypoint x="630" y="360" />
<bpmndi:bpmnlabel>
<dc:bounds x="544" y="373" width="11" height="14" />
</bpmndi:bpmnlabel>
</bpmndi:bpmnedge>
<bpmndi:bpmnedge id="flow_0bemgki_di" bpmnelement="flow_0bemgki">
<di:waypoint x="730" y="250" />
<di:waypoint x="825" y="250" />
</bpmndi:bpmnedge>
<bpmndi:bpmnedge id="flow_1t7ectj_di" bpmnelement="flow_1t7ectj">
<di:waypoint x="730" y="360" />
<di:waypoint x="840" y="360" />
</bpmndi:bpmnedge>
<bpmndi:bpmnedge id="flow_07mf0sc_di" bpmnelement="flow_07mf0sc">
<di:waypoint x="1050" y="250" />
<di:waypoint x="1182" y="250" />
</bpmndi:bpmnedge>
<bpmndi:bpmnedge id="flow_07xq405_di" bpmnelement="flow_07xq405">
<di:waypoint x="875" y="250" />
<di:waypoint x="950" y="250" />
<bpmndi:bpmnlabel>
<dc:bounds x="899" y="232" width="11" height="14" />
</bpmndi:bpmnlabel>
</bpmndi:bpmnedge>
<bpmndi:bpmnedge id="flow_1w4qeti_di" bpmnelement="flow_1w4qeti">
<di:waypoint x="850" y="225" />
<di:waypoint x="850" y="160" />
<bpmndi:bpmnlabel>
<dc:bounds x="853" y="186" width="11" height="14" />
</bpmndi:bpmnlabel>
</bpmndi:bpmnedge>
<bpmndi:bpmnedge id="flow_1nd3369_di" bpmnelement="flow_1nd3369">
<di:waypoint x="940" y="360" />
<di:waypoint x="1120" y="360" />
<di:waypoint x="1120" y="250" />
<di:waypoint x="1182" y="250" />
</bpmndi:bpmnedge>
<bpmndi:bpmnedge id="flow_0vr5zs3_di" bpmnelement="flow_0vr5zs3">
<di:waypoint x="900" y="120" />
<di:waypoint x="950" y="120" />
</bpmndi:bpmnedge>
<bpmndi:bpmnedge id="flow_160ji3a_di" bpmnelement="flow_160ji3a">
<di:waypoint x="1050" y="120" />
<di:waypoint x="1120" y="120" />
<di:waypoint x="1120" y="250" />
<di:waypoint x="1182" y="250" />
</bpmndi:bpmnedge>
</bpmndi:bpmnplane>
</bpmndi:bpmndiagram>
</bpmn:definitions>
-
process,表示一个流程。
-
id="exclusivetest" version="1.0.0",分别表示流程定义的id和版本。这两个字段唯一区分一个流程定义。
-
startevent,表示流程开始节点。只允许有一个开始节点。
-
endevent,表示流程结束节点。可以有多个结束节点。
-
sequenceflow,表示环节流转关系。sourceref="thestart" targetref="submittask" 分别表示起始节点和目标节点。该节点有个子节点, approve == 'agree',这个片段很重要,用来描述流程流转的条件。approve == 'upgrade'使用的是mvel表达式语法。另外,还值得注意的是,在驱动流程运转时,需要传入正确的参数。比如说,在后面介绍的api中,通常会需要在map中传递业务请求参数。那么需要将map中的key和mvel的运算因子关联起来。以这个例子来说,request.put("approve", "agree");里面的approve和approve == 'agree'命名要一致。
-
exclusivegateway,表示互斥网关。该节点非常重要。用来区分流程节点的不同转向。互斥网关在引擎执行conditionexpression后,有且只能选择一条匹配的sequenceflow继续执行。
-
servicetask,服务任务,用来表示执行一个服务,所以他会有引擎默认的扩展:smart:class="com.alibaba.smart.framework.example.auditprocessservicetaskdelegation". client developer使用时,需要自定义对应的业务实现类。在该节点执行时,它会自动执行服务调用,执行smart:class 这个 delegation。该节点不暂停,会自动往下一个流转。
-
receivetask,接收任务。在引擎遇到此类型的节点时,引擎执行会自动暂停,等待外部调用signal方法。当调用signal方法时,会驱动流程当前节点离开。在离开该节点时,引擎会自动执行smart:class 这个delegation。在一般业务场景中,我们通常使用receivetask来表示等需要等待外部回调的节点。
-
usertask,表示用户任务节点,仅用于database模式。该节点需要人工参与处理,并且通常需要在待办列表中展示。在custom模式下,建议使用receivetask来代替。
-
parallelgateway,这个节点并未在上述流程定义中体现,这里详细说一下。parallelgateway 首先必须成对出现,分别承担fork和join职责。其次,在join时需要实现分布式锁接口:lockstrategy。第三,fork默认是顺序遍历多个sequeceflow,但是你如果需要使用并发fork功能的话,则需要实现该接口:executorservice。
重要领域对象
-
部署实例: deploymentinstance,描述这个流程定义是谁发布的,当前处于什么状态。
-
流程定义: processdefinition,描述一个流程有几个环节,之间的流转关系是什么样子的。
-
流程实例: processinstance,可以简单理解为我们常见的一个工单。
-
活动实例: activityinstance,主要是描述流程实例(工单)的流转轨迹。
-
执行实例: executioninstance,主要根据该实例的状态,来判断当前流程处在哪个节点上。
-
任务实例: taskinstance,用来表示人工任务处理的,可以理解为一个需要人工参与处理的环节。
-
任务处理:taskassigneeinstance,用来表示当前任务共有几个处理者。通常在代办列表中用到此实体。
-
变量实例:variableinstance,用来存储流程实例上下文。
四、总结与建议
优点
-
业务流程可视化与实际系统流程可视化高度一致,所见即所得。
-
调整效率高(业务平均每个月会升级一次治理流程),如果业务流程1.0要升级到1.1,只需要重新复制一份bpmn.xml流程模板重新编排为1.1,并下发流程实例即可,不影响原有的流程模板和流程实例执行(调整效率由原来的一周缩短到1小时)。
-
流程实例和流程节点实例可视,方便监控各个节点的执行和数据报表的产出。
缺点
-
异常处理的支持度不够友好(smartengine是异常丢弃),如果在某一个节点上执行失败(一般情况是业务接口执行失败导致),默认当前流程进度是卡在该节点的,需要设计张异常表,把当前流程实例,节点实例以及变量都保存下载,通过job重新拉起重试去驱动流程继续执行,并需要做好告警监控,以及任务实例和流程实例的核对。
-
高并发场景的支持度并不是太友好,要通过异步消息的方式来控制创建流程实例的速度,目前得到的创建流程实例的tps是100/s单台,只是相对于activiti来说并发支持度要高,超过这个上限的场景建议谨慎使用。
-
可扩展性不足,例如:processqueryservice只支持findbyid,findlist,count;executionqueryservice只支持findactiveexecutionlist,findall这些基本查询 ,复杂查询需要新写smartengine核心包,升级jar包版本后才可使用。
-
无历史记录表,每隔一段时间要清理表中流程实例已经完结的相关数据,否则历史数据堆积影响查询效率。
建议
如果业务流程的复杂度一般,且经常会调整,并发量并不高的情况下,建议使用;如果业务复杂度过高,或并发量tps超过单台100/s,不建议使用。
*文 / 冬冬
本文属得物技术原创,更多精彩文章请看:得物技术
未经得物技术许可严禁转载,否则依法追究法律责任!
发表评论