idea集成Activiti 拖拽生成bpmn文件过程

idea集成Activiti 拖拽生成bpmn文件过程是使用工作流的第一步,今天我们拿一个业务场景来举例,比如文件归档业务:文件查询、创建临时目录、文件解压(如果是压缩包才需要解压)、文件验证、文件归档、文件入库、同时写入缓存和记录日志;

1、idea安装插件

2、boot服务生成文件

此处activiti集成boot服务参考:上一篇

 3、点击文件右键鼠标

进入查看编辑页面

 

 此时就可以开始拖拽流程图了。

4、右键开始

 创建完成后可以配置参数

此时bpmn文件同时做出改变,可以看看

此后就配置各种事件和网关了。 

5、右键创建任务

 配置参数

注意:

1)、Class 是指定一个业务类,比如:

com.nandao.bpm.CommonJavaDelegate

2)、Expression 使用表达式解析一个方法,比如 :

${testServer.doWork()}

3)、Delegate  Expression 使用委托表达式指定一个对象,此对象首个字母必须改为小写,否则报错:

4)、以上三个参数只能配置一个,否则可能报错

Unknown property used in expression: ${XXX} 

6、自定义条件

判断参数  isZip==false,就不执行解压,条件判断,如果是可以这样判断  isZip==true

另外 :xsi:type 含义不知道,值为tFormalExpression;

一般前面可以添加一个排他网关,这样更安全,但是有需要注意的地方。

注意:排他网关只会选择一个为true的分支执行;如果有两个分支条件都为true,排他网关会选择id值较小的一条分支去执行;如果条件都不满足,流程就结束了(是异常结束) 。

7、并行网关

 注意:并行网关不会解析条件。 即使顺序流中定义了条件,也会被忽略。

除了刚才说的两种网关,还有包含网关、事件网关,用到时可以查一下,基本思路是一致的。

8、工作流结束

9、最终流程图

也可以下载,保存到某个目录

 10、生成的bpmn文件内容

<?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: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" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://www.activiti.org/processdef">
  <process id="nandaoTest" name="nandaoTest" isExecutable="true">
    <documentation>实战验证工作流</documentation>
    <startEvent id="sid-96e576ce-8cdb-4f6e-ab07-67e338eafb42" name="start">
      <documentation>开始执行</documentation>
    </startEvent>
    <serviceTask id="sid-a8c63ac0-8bd6-4abc-b067-b10e02533dca" name="文件查询" activiti:delegateExpression="${queryFileDelegate}" activiti:exclusive="false">
      <documentation>文件查询doc</documentation>
      <extensionElements>
        <activiti:field name="Field 1"/>
        <activiti:failedJobRetryTimeCycle/>
      </extensionElements>
    </serviceTask>
    <sequenceFlow id="sid-9dc7eea2-3c18-4250-9b23-8ced4e29d0bd" sourceRef="sid-96e576ce-8cdb-4f6e-ab07-67e338eafb42" targetRef="sid-a8c63ac0-8bd6-4abc-b067-b10e02533dca"/>
    <serviceTask id="sid-c1b2f9a7-4d92-4727-8f98-4f309e2a0a9b" name="创建临时目录" activiti:delegateExpression="${createPackageDelegate}">
      <documentation>创建临时目录2</documentation>
      <extensionElements>
        <activiti:failedJobRetryTimeCycle/>
      </extensionElements>
    </serviceTask>
    <serviceTask id="sid-b4267600-3bfd-4e50-8fac-74cec82981b3" name="文件解压" activiti:delegateExpression="${upFileDelegate}" activiti:exclusive="false">
      <documentation>文件解压</documentation>
      <extensionElements>
        <activiti:failedJobRetryTimeCycle/>
      </extensionElements>
    </serviceTask>
    <serviceTask id="sid-71a0ede9-1fba-4d43-8365-21f4cbd5b603" name="文件验证" activiti:delegateExpression="${checkFileDelegate}">
      <documentation>文件验证</documentation>
      <extensionElements>
        <activiti:field name="Field 1"/>
        <activiti:failedJobRetryTimeCycle/>
        <activiti:field name="Field 2"/>
      </extensionElements>
    </serviceTask>
    <serviceTask id="sid-68c5ce7e-df3e-4e6d-a19e-55fbdbb2d42e" name="文件归档" activiti:delegateExpression="${saveFileDelegate}" activiti:exclusive="false">
      <documentation>文件归档</documentation>
      <extensionElements>
        <activiti:failedJobRetryTimeCycle/>
      </extensionElements>
    </serviceTask>
    <serviceTask id="sid-00e7e2e3-ba4c-48c8-bfba-363ddff5fa5b" name="写缓存" activiti:delegateExpression="${saveCacheDelegate}" activiti:exclusive="false">
      <documentation>写缓存</documentation>
      <extensionElements>
        <activiti:failedJobRetryTimeCycle/>
      </extensionElements>
    </serviceTask>
    <serviceTask id="sid-88052a99-7a28-4c54-bf5f-3d2a648051b5" name="记日志" activiti:delegateExpression="${saveLogDelegate}" activiti:exclusive="false">
      <documentation>记日志</documentation>
      <extensionElements>
        <activiti:failedJobRetryTimeCycle/>
      </extensionElements>
    </serviceTask>
    <sequenceFlow id="sid-240c3a26-ffac-4b5f-a7bd-830decbcc61d" sourceRef="sid-a8c63ac0-8bd6-4abc-b067-b10e02533dca" targetRef="sid-c1b2f9a7-4d92-4727-8f98-4f309e2a0a9b"/>
    <sequenceFlow id="sid-1d0ccb71-0a35-48e6-b9f3-14b89130a384" sourceRef="sid-c1b2f9a7-4d92-4727-8f98-4f309e2a0a9b" targetRef="sid-71a0ede9-1fba-4d43-8365-21f4cbd5b603" name="非压缩包">
      <documentation>非压缩包</documentation>
      <conditionExpression xsi:type="tFormalExpression">${isZip==false}</conditionExpression>
      <!--   <conditionExpression xsi:type="tFormalExpression">${evection.num>=3}</conditionExpression>-->
    </sequenceFlow>
    <sequenceFlow id="sid-ab1ad905-e635-4627-9b6d-054ab15f44d2" sourceRef="sid-c1b2f9a7-4d92-4727-8f98-4f309e2a0a9b" targetRef="sid-b4267600-3bfd-4e50-8fac-74cec82981b3" name="是zip压缩包">
      <documentation>是zip压缩包</documentation>
      <conditionExpression xsi:type="tFormalExpression">${isZip==true}</conditionExpression>
      <!-- <conditionExpression xsi:type="tFormalExpression">
        <![CDATA[${evection.num<3}]]>
      </conditionExpression>-->
      <!--      <conditionExpression xsi:type="tFormalExpression">${evection.num <= 3}</conditionExpression>-->
    </sequenceFlow>
    <sequenceFlow id="sid-1ea62769-6f57-4a4d-a6c7-646dbb077533" sourceRef="sid-b4267600-3bfd-4e50-8fac-74cec82981b3" targetRef="sid-71a0ede9-1fba-4d43-8365-21f4cbd5b603"/>
    <sequenceFlow id="sid-e4f0fdb8-be80-491b-8af3-19654f7e76b0" sourceRef="sid-71a0ede9-1fba-4d43-8365-21f4cbd5b603" targetRef="sid-68c5ce7e-df3e-4e6d-a19e-55fbdbb2d42e"/>
    <parallelGateway id="sid-691a4d70-b56a-4345-ad4a-c932ae80f1c6" name="并行业务的网关">
      <documentation>同时执行写缓存和记日志</documentation>
    </parallelGateway>
    <sequenceFlow id="sid-1bdb89f6-9221-48dc-939d-eafae1ffe519" sourceRef="sid-68c5ce7e-df3e-4e6d-a19e-55fbdbb2d42e" targetRef="sid-691a4d70-b56a-4345-ad4a-c932ae80f1c6"/>
    <sequenceFlow id="sid-adf7b2a5-5487-478d-ab90-e9bdc667bc39" sourceRef="sid-691a4d70-b56a-4345-ad4a-c932ae80f1c6" targetRef="sid-00e7e2e3-ba4c-48c8-bfba-363ddff5fa5b">
      <conditionExpression xsi:type="tFormalExpression"/>
    </sequenceFlow>
    <sequenceFlow id="sid-d2429caf-8f13-4ed7-8eef-a14ea04090e5" sourceRef="sid-691a4d70-b56a-4345-ad4a-c932ae80f1c6" targetRef="sid-88052a99-7a28-4c54-bf5f-3d2a648051b5">
      <conditionExpression xsi:type="tFormalExpression"/>
    </sequenceFlow>
    <endEvent id="sid-6aff98c1-f522-419b-9027-fc63d6360836" name="end">
      <documentation>此业务工作流结束</documentation>
    </endEvent>
    <sequenceFlow id="sid-6ccc79b4-466e-4de4-bf9f-4b06c3d71b5a" sourceRef="sid-00e7e2e3-ba4c-48c8-bfba-363ddff5fa5b" targetRef="sid-6aff98c1-f522-419b-9027-fc63d6360836"/>
    <sequenceFlow id="sid-b1e44235-c115-4e95-98e1-4c06a72eea70" sourceRef="sid-88052a99-7a28-4c54-bf5f-3d2a648051b5" targetRef="sid-6aff98c1-f522-419b-9027-fc63d6360836"/>
  </process>
  <bpmndi:BPMNDiagram id="BPMNDiagram_nandaoTest">
    <bpmndi:BPMNPlane bpmnElement="nandaoTest" id="BPMNPlane_nandaoTest">
      <bpmndi:BPMNShape id="shape-05702fff-08fc-497c-9ff9-de99a46fe5e2" bpmnElement="sid-96e576ce-8cdb-4f6e-ab07-67e338eafb42">
        <omgdc:Bounds x="-679.0246" y="-194.61565" width="30.0" height="30.0"/>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="shape-be10642d-a2ed-4b0f-b8f8-6cc9089ff6d5" bpmnElement="sid-a8c63ac0-8bd6-4abc-b067-b10e02533dca">
        <omgdc:Bounds x="-622.5247" y="-196.70004" width="33.58441" height="34.16884"/>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge id="edge-9a12fe83-6aee-45c2-82ff-c106e6f7f16a" bpmnElement="sid-9dc7eea2-3c18-4250-9b23-8ced4e29d0bd">
        <omgdi:waypoint x="-649.0246" y="-179.61565"/>
        <omgdi:waypoint x="-622.5247" y="-179.61563"/>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNShape id="shape-a2494d87-8de3-4fb2-9825-2b73c7b5eed6" bpmnElement="sid-c1b2f9a7-4d92-4727-8f98-4f309e2a0a9b">
        <omgdc:Bounds x="-570.32983" y="-198.10263" width="42.487" height="33.987015"/>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="shape-2e1091d0-5ea4-4328-9da2-06e5d1ebda2d" bpmnElement="sid-b4267600-3bfd-4e50-8fac-74cec82981b3">
        <omgdc:Bounds x="-455.86563" y="-177.46625" width="37.779236" height="32.08441"/>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="shape-e61c62d9-1149-4795-b7f9-51f29c2c2112" bpmnElement="sid-71a0ede9-1fba-4d43-8365-21f4cbd5b603">
        <omgdc:Bounds x="-461.20007" y="-231.45" width="48.44806" height="32.69478"/>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="shape-723ad4a8-9167-422f-86d3-1d526cea2574" bpmnElement="sid-68c5ce7e-df3e-4e6d-a19e-55fbdbb2d42e">
        <omgdc:Bounds x="-401.2" y="-230.95001" width="37.889618" height="33.487015"/>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="shape-4c2cb6b2-8220-4831-8a48-f27263fee2c7" bpmnElement="sid-00e7e2e3-ba4c-48c8-bfba-363ddff5fa5b">
        <omgdc:Bounds x="-273.99228" y="-256.17145" width="32.487045" height="34.07144"/>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="shape-81d5998a-7ee2-4a7d-aacd-0706664831f2" bpmnElement="sid-88052a99-7a28-4c54-bf5f-3d2a648051b5">
        <omgdc:Bounds x="-275.1319" y="-194.90785" width="34.76622" height="33.571426"/>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge id="edge-2b0e75fb-f14e-491f-84d5-f407a7994110" bpmnElement="sid-240c3a26-ffac-4b5f-a7bd-830decbcc61d">
        <omgdi:waypoint x="-588.9403" y="-179.61563"/>
        <omgdi:waypoint x="-570.32983" y="-181.10912"/>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="edge-eb482a7a-e078-463f-aa47-87e1909d0ac8" bpmnElement="sid-1d0ccb71-0a35-48e6-b9f3-14b89130a384">
        <omgdi:waypoint x="-527.8427" y="-181.10913"/>
        <omgdi:waypoint x="-481.2" y="-198.45001"/>
        <omgdi:waypoint x="-481.2" y="-198.45001"/>
        <omgdi:waypoint x="-481.2" y="-198.45001"/>
        <omgdi:waypoint x="-481.2" y="-198.45001"/>
        <omgdi:waypoint x="-461.20007" y="-206.92892"/>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="edge-0195759a-28aa-4e77-b999-e7da8f331802" bpmnElement="sid-ab1ad905-e635-4627-9b6d-054ab15f44d2">
        <omgdi:waypoint x="-527.84283" y="-172.61237"/>
        <omgdi:waypoint x="-481.2" y="-169.70001"/>
        <omgdi:waypoint x="-481.2" y="-169.70001"/>
        <omgdi:waypoint x="-455.86563" y="-169.44514"/>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="edge-0bb17b68-12da-49b3-ad1f-e989f10e3ff8" bpmnElement="sid-1ea62769-6f57-4a4d-a6c7-646dbb077533">
        <omgdi:waypoint x="-436.976" y="-177.46625"/>
        <omgdi:waypoint x="-436.97607" y="-198.75522"/>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="edge-f21b1c9a-e575-4006-a0eb-c384669d341d" bpmnElement="sid-e4f0fdb8-be80-491b-8af3-19654f7e76b0">
        <omgdi:waypoint x="-412.752" y="-215.10262"/>
        <omgdi:waypoint x="-401.2" y="-214.20651"/>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNShape id="shape-7ac1a8df-5830-460b-8841-3e8e44a8d384" bpmnElement="sid-691a4d70-b56a-4345-ad4a-c932ae80f1c6">
        <omgdc:Bounds x="-346.69995" y="-235.70001" width="40.0" height="40.0"/>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge id="edge-11bbbbde-f0f2-4d0e-a958-a6afc36bff21" bpmnElement="sid-1bdb89f6-9221-48dc-939d-eafae1ffe519">
        <omgdi:waypoint x="-363.3104" y="-214.20651"/>
        <omgdi:waypoint x="-346.69995" y="-215.70001"/>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="edge-ac2baa2e-47c2-4e10-853a-c31f6a867628" bpmnElement="sid-adf7b2a5-5487-478d-ab90-e9bdc667bc39">
        <omgdi:waypoint x="-306.69995" y="-215.70001"/>
        <omgdi:waypoint x="-306.69992" y="-215.7"/>
        <omgdi:waypoint x="-273.99228" y="-230.61787"/>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="edge-b504282f-c20a-4eb6-b2c1-0ee2d1d73046" bpmnElement="sid-d2429caf-8f13-4ed7-8eef-a14ea04090e5">
        <omgdi:waypoint x="-306.69995" y="-215.70001"/>
        <omgdi:waypoint x="-275.1319" y="-186.515"/>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNShape id="shape-dbeb05c1-363b-4f21-8958-481be4c7c0a6" bpmnElement="sid-6aff98c1-f522-419b-9027-fc63d6360836">
        <omgdc:Bounds x="-231.19995" y="-223.20001" width="30.0" height="30.0"/>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge id="edge-d2765367-e450-4d4f-b727-d6d805552ff7" bpmnElement="sid-6ccc79b4-466e-4de4-bf9f-4b06c3d71b5a">
        <omgdi:waypoint x="-241.50523" y="-230.61787"/>
        <omgdi:waypoint x="-231.19995" y="-215.70001"/>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="edge-a1490219-5e58-4c48-8d69-d89b2509f6bb" bpmnElement="sid-b1e44235-c115-4e95-98e1-4c06a72eea70">
        <omgdi:waypoint x="-240.36568" y="-186.515"/>
        <omgdi:waypoint x="-231.19995" y="-200.70001"/>
      </bpmndi:BPMNEdge>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</definitions>

此内容可以简要参考一下 。另外还有一种idea集成activiti画图方式,网上找的也挺好的:两种画图方式

到此npmn文件整个流程生成完毕,下面篇我们实战演示整个流程,敬请期待!

  • 3
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

寅灯

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值