Idea integrates Activiti drag and drop to generate bpmn file process

Idea integrates Activiti. The drag-and-drop process of generating bpmn files is the first step in using workflow. Today we take a business scenario as an example, such as file archiving business: file query, creation of temporary directory, file decompression (if it is a compressed package, it needs to be decompressed) , file verification, file archiving, file warehousing, writing cache and logging at the same time;

1. Idea installation plug-in

2. Boot service generated file

Here activiti integrated boot service reference: previous article

 3. Right-click the file

Go to view edit page

 

 At this point, you can start dragging and dropping the flowchart.

4. Right click to start

 Parameters can be configured after creation

At this time, the bpmn file is changed at the same time, you can see

After that, various events and gateways are configured. 

5. Right-click to create a task

 configuration parameters

Notice:

1), Class is to specify a business class, such as:

com.nandao.bpm.CommonJavaDelegate

2), Expression parses a method using an expression, for example:

${testServer.doWork()}

3), Delegate Expression uses a delegate expression to specify an object, the first letter of this object must be changed to lowercase, otherwise an error will be reported:

4) Only one of the above three parameters can be configured, otherwise an error may be reported

Unknown property used in expression: ${XXX} 

6. Custom conditions

Judgment parameter isZip==false, decompression will not be performed, conditional judgment, if it is possible to judge isZip==true

In addition: the meaning of xsi:type is unknown, the value is tFormalExpression;

Generally, an exclusive gateway can be added in front, which is more secure, but there are points that need attention.

Note: The exclusive gateway will only select a branch that is true; if two branch conditions are true, the exclusive gateway will select a branch with a smaller id value to execute; if the conditions are not met, the process will end (yes Abnormal end).

7. Parallel Gateway

 Note: Parallel Gateway does not parse conditions. Even if a condition is defined in the sequence flow, it will be ignored.

In addition to the two gateways just mentioned, there are also containment gateways and event gateways. You can check them when you use them. The basic idea is the same.

8. Workflow ends

9. The final flow chart

It can also be downloaded and saved to a directory

 10. The content of the generated bpmn file

<?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>

This content can be briefly referred to. In addition, there is an idea integrated activiti drawing method, which is also very good to find on the Internet: two drawing methods

At this point, the entire process of npmn files has been generated. In the next article, we will demonstrate the entire process in practice, so stay tuned!

Guess you like

Origin blog.csdn.net/nandao158/article/details/129592748