Commit 31b47eba authored by 雍欢's avatar 雍欢

流程模板文件改成支持bpmn格式

parent cf49bda4
......@@ -8,7 +8,6 @@ import com.huigou.explorer.domain.model.Model;
import com.huigou.explorer.repository.ModelRepository;
import com.huigou.uasp.bpm.managment.application.ProcDefinitionApplication;
import com.huigou.uasp.bpm.managment.domain.model.ProcDefinition;
import com.huigou.uasp.bpm.managment.repository.ProcDefinitionRespository;
import com.mxgraph.io.mxCodec;
import com.mxgraph.model.mxCell;
import com.mxgraph.model.mxGraphModel;
......@@ -35,8 +34,12 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert;
import org.w3c.dom.Document;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.StringReader;
import java.nio.charset.StandardCharsets;
import java.util.Collections;
......@@ -48,53 +51,30 @@ import java.util.Collections;
public class ModelApplicationImpl implements ModelApplication {
private final Logger LOG = LoggerFactory.getLogger(ModelApplicationImpl.class);
@Autowired
private ModelRepository modelRepository;
private ProcDefinitionRespository procDefinitionRespository;
private ProcDefinitionApplication procDefinitionApplication;
private WorkflowModeConverter workflowModeConverter;
private RepositoryService repositoryService;
private String mxGraphXmlTemplate;
private BpmnXMLConverter bpmnXMLConverter;
private TaskFormKeyGenerator taskFormKeyGenerator;
@Autowired
public void setModelRepository(ModelRepository modelRepository) {
this.modelRepository = modelRepository;
}
private ProcDefinitionApplication procDefinitionApplication;
@Autowired
public void setProcDefinitionRespository(ProcDefinitionRespository procDefinitionRespository) {
this.procDefinitionRespository = procDefinitionRespository;
}
private WorkflowModeConverter workflowModeConverter;
@Autowired
public void setProcDefinitionApplication(ProcDefinitionApplication procDefinitionApplication) {
this.procDefinitionApplication = procDefinitionApplication;
}
private RepositoryService repositoryService;
@Autowired
public void setWorkflowModeConverter(WorkflowModeConverter workflowModeConverter) {
this.workflowModeConverter = workflowModeConverter;
}
private BpmnXMLConverter bpmnXMLConverter;
@Autowired
public void setRepositoryService(RepositoryService repositoryService) {
this.repositoryService = repositoryService;
}
@Value("classpath:mxGraphXmlTemplate.xml")
public void setMxGraphXmlTemplate(Resource mxGraphXmlTemplate) throws IOException {
this.mxGraphXmlTemplate = String.join("\n", IOUtils.readLines(mxGraphXmlTemplate.getInputStream(), StandardCharsets.UTF_8.name()));
}
private TaskFormKeyGenerator taskFormKeyGenerator;
@Autowired
public void setBpmnXMLConverter(BpmnXMLConverter bpmnXMLConverter) {
this.bpmnXMLConverter = bpmnXMLConverter;
}
private String mxGraphXmlTemplate;
@Autowired
public void setTaskFormKeyGenerator(TaskFormKeyGenerator taskFormKeyGenerator) {
this.taskFormKeyGenerator = taskFormKeyGenerator;
@Value("classpath:bpmnModelTemplate.bpmn")
public void setBpmnModelTemplate(Resource bpmnModelTemplate) throws IOException, XMLStreamException {
if (bpmnModelTemplate != null) {
String bpmnModelXml = String.join("\n", IOUtils.readLines(bpmnModelTemplate.getInputStream(), StandardCharsets.UTF_8.name()));
XMLStreamReader xtr = XMLInputFactory.newInstance().createXMLStreamReader(new StringReader(bpmnModelXml));
BpmnModel bpmnModel = bpmnXMLConverter.convertToBpmnModel(xtr);
byte[] bs = workflowModeConverter.convertToXML(bpmnModel, StandardCharsets.UTF_8);
mxGraphXmlTemplate = new String(bs);
}
}
@Transactional(rollbackFor = RuntimeException.class)
......
<?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/leave">
<process id="key" name="流程名称" isExecutable="true">
<extensionElements>
<activiti:executionListener event="start" delegateExpression="#{leaveApplication}"></activiti:executionListener>
<activiti:executionListener event="end" delegateExpression="#{leaveApplication}"></activiti:executionListener>
</extensionElements>
<startEvent id="startevent1" name="开始"></startEvent>
<userTask id="Apply" name="填写申请" activiti:formKey="">
<extensionElements>
<activiti:taskListener event="all" delegateExpression="#{leaveApplication}"></activiti:taskListener>
<activiti:taskListener event="saveBizData" delegateExpression="#{leaveApplication}"></activiti:taskListener>
</extensionElements>
</userTask>
<sequenceFlow id="flow1" sourceRef="startevent1" targetRef="Apply"></sequenceFlow>
<userTask id="Approve" name="审批申请" activiti:assignee="${assignee}" activiti:formKey="">
<extensionElements>
<activiti:taskListener event="all" delegateExpression="#{leaveApplication}"></activiti:taskListener>
<activiti:taskListener event="saveBizData" delegateExpression="#{leaveApplication}"></activiti:taskListener>
</extensionElements>
<multiInstanceLoopCharacteristics isSequential="false" activiti:collection="handlerList" activiti:elementVariable="assignee">
<completionCondition>${chiefApprovePassed}</completionCondition>
</multiInstanceLoopCharacteristics>
</userTask>
<sequenceFlow id="flow2" sourceRef="Apply" targetRef="Approve"></sequenceFlow>
<exclusiveGateway id="ApprovePassed" name="审批通过"></exclusiveGateway>
<sequenceFlow id="flow3" sourceRef="Approve" targetRef="ApprovePassed"></sequenceFlow>
<endEvent id="endevent1" name="End"></endEvent>
<sequenceFlow id="flow4" name="审批未通过" sourceRef="ApprovePassed" targetRef="endevent1">
<conditionExpression xsi:type="tFormalExpression"><![CDATA[${!approvePassed}]]></conditionExpression>
</sequenceFlow>
<exclusiveGateway id="ApproveFinished" name="审批结束"></exclusiveGateway>
<sequenceFlow id="flow5" name="审批通过" sourceRef="ApprovePassed" targetRef="ApproveFinished">
<conditionExpression xsi:type="tFormalExpression"><![CDATA[${approvePassed}]]></conditionExpression>
</sequenceFlow>
<endEvent id="endevent2" name="End"></endEvent>
<sequenceFlow id="flow6" name="审批结束" sourceRef="ApproveFinished" targetRef="endevent2">
<conditionExpression xsi:type="tFormalExpression"><![CDATA[${approveFinished}]]></conditionExpression>
</sequenceFlow>
<sequenceFlow id="flow7" name="审批未结束" sourceRef="ApproveFinished" targetRef="Approve">
<conditionExpression xsi:type="tFormalExpression"><![CDATA[${!approveFinished}]]></conditionExpression>
</sequenceFlow>
</process>
<bpmndi:BPMNDiagram id="BPMNDiagram_leave">
<bpmndi:BPMNPlane bpmnElement="leave" id="BPMNPlane_leave">
<bpmndi:BPMNShape bpmnElement="startevent1" id="BPMNShape_startevent1">
<omgdc:Bounds height="35.0" width="35.0" x="272.0" y="30.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="Apply" id="BPMNShape_Apply">
<omgdc:Bounds height="55.0" width="105.0" x="237.0" y="130.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="Approve" id="BPMNShape_Approve">
<omgdc:Bounds height="55.0" width="105.0" x="237.0" y="251.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="ApprovePassed" id="BPMNShape_ApprovePassed">
<omgdc:Bounds height="40.0" width="40.0" x="269.0" y="370.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="endevent1" id="BPMNShape_endevent1">
<omgdc:Bounds height="35.0" width="35.0" x="110.0" y="373.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="ApproveFinished" id="BPMNShape_ApproveFinished">
<omgdc:Bounds height="40.0" width="40.0" x="269.0" y="460.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="endevent2" id="BPMNShape_endevent2">
<omgdc:Bounds height="35.0" width="35.0" x="272.0" y="550.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge bpmnElement="flow1" id="BPMNEdge_flow1">
<omgdi:waypoint x="289.0" y="65.0"></omgdi:waypoint>
<omgdi:waypoint x="289.0" y="130.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow2" id="BPMNEdge_flow2">
<omgdi:waypoint x="289.0" y="185.0"></omgdi:waypoint>
<omgdi:waypoint x="289.0" y="251.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow3" id="BPMNEdge_flow3">
<omgdi:waypoint x="289.0" y="306.0"></omgdi:waypoint>
<omgdi:waypoint x="289.0" y="370.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow4" id="BPMNEdge_flow4">
<omgdi:waypoint x="269.0" y="390.0"></omgdi:waypoint>
<omgdi:waypoint x="145.0" y="390.0"></omgdi:waypoint>
<bpmndi:BPMNLabel>
<omgdc:Bounds height="14.0" width="60.0" x="181.0" y="397.0"></omgdc:Bounds>
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow5" id="BPMNEdge_flow5">
<omgdi:waypoint x="289.0" y="410.0"></omgdi:waypoint>
<omgdi:waypoint x="289.0" y="460.0"></omgdi:waypoint>
<bpmndi:BPMNLabel>
<omgdc:Bounds height="14.0" width="48.0" x="306.0" y="419.0"></omgdc:Bounds>
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow6" id="BPMNEdge_flow6">
<omgdi:waypoint x="289.0" y="500.0"></omgdi:waypoint>
<omgdi:waypoint x="289.0" y="550.0"></omgdi:waypoint>
<bpmndi:BPMNLabel>
<omgdc:Bounds height="14.0" width="48.0" x="300.0" y="509.0"></omgdc:Bounds>
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow7" id="BPMNEdge_flow7">
<omgdi:waypoint x="309.0" y="480.0"></omgdi:waypoint>
<omgdi:waypoint x="448.0" y="479.0"></omgdi:waypoint>
<omgdi:waypoint x="448.0" y="377.0"></omgdi:waypoint>
<omgdi:waypoint x="448.0" y="277.0"></omgdi:waypoint>
<omgdi:waypoint x="342.0" y="278.0"></omgdi:waypoint>
<bpmndi:BPMNLabel>
<omgdc:Bounds height="14.0" width="60.0" x="459.0" y="374.0"></omgdc:Bounds>
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</definitions>
\ No newline at end of file
<mxGraphModel dx="1301" dy="845" grid="0" griSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="827" pageHeight="1169"><root><object code="" label="" id="0"><mxCell/></object><mxCell id="1" parent="0"/><object asynchronous="false" code="ApprovePassed" exclusive="true" label="审批通过" id="ApprovePassed"><mxCell style="shape=workflow.gateways.exclusive_gateway;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#585858;strokeWidth=2" parent="1" vertex="1"><mxGeometry x="331" y="350" width="40" height="40" as="geometry"/></mxCell></object><object asynchronous="false" code="Apply" exclusive="true" formKey="" label="填写申请" id="Apply"><mxCell style="html=1;whiteSpace=wrap;rounded=1;strokeColor=#bbbbbb;fillColor=#f9f9f9;shape=workflow.activities.user_task" parent="1" vertex="1"><mxGeometry x="292" y="140" width="118" height="78" as="geometry"/></mxCell></object><object asynchronous="false" code="ApproveFinished" exclusive="true" label="审批结束" id="ApproveFinished"><mxCell style="shape=workflow.gateways.exclusive_gateway;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#585858;strokeWidth=2" parent="1" vertex="1"><mxGeometry x="328.5" y="440" width="40" height="40" as="geometry"/></mxCell></object><object asynchronous="false" code="start" exclusive="true" label="开始" id="start"><mxCell style="shape=workflow.start_events.general_start;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#585858;strokeWidth=2" parent="1" vertex="1"><mxGeometry x="333.5" y="50" width="35" height="35" as="geometry"/></mxCell></object><object asynchronous="false" code="end" exclusive="true" label="结束" id="end"><mxCell style="shape=workflow.end_events.end_event;whiteSpace=wrap;html=1;fillColor=#ffffff;strokeColor=#585858;strokeWidth=2" parent="1" vertex="1"><mxGeometry x="331" y="549" width="35" height="35" as="geometry"/></mxCell></object><object asynchronous="false" code="Approve" exclusive="true" formKey="" label="审批申请" multiInstanceCardinality="" multiInstanceCollection="handlerList" multiInstanceCompletionCondition="${chiefApprovePassed}" multiInstanceElementVariable="assignee" multiInstanceType="Parallel" id="Approve"><mxCell style="html=1;whiteSpace=wrap;rounded=1;strokeColor=#bbbbbb;fillColor=#f9f9f9;shape=workflow.activities.user_task" parent="1" vertex="1"><mxGeometry x="292" y="240" width="118" height="77" as="geometry"/></mxCell></object><object code="flow9" conditionExpression="${!approvePassed}" label="审批未通过" skipExpression="" id="flow9"><mxCell style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1" parent="1" source="ApprovePassed" target="Apply" edge="1"><mxGeometry relative="1" as="geometry"><Array as="points"><mxPoint x="231" y="369"/><mxPoint x="231" y="167"/></Array></mxGeometry></mxCell></object><object code="flow6" conditionExpression="" label="" skipExpression="" id="flow6"><mxCell style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1" parent="1" source="Approve" target="ApprovePassed" edge="1"><mxGeometry relative="1" as="geometry"/></mxCell></object><object code="flow5" conditionExpression="${!approveFinished}" label="审批未结束" skipExpression="" id="flow5"><mxCell style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1" parent="1" source="ApproveFinished" target="Approve" edge="1"><mxGeometry relative="1" as="geometry"><Array as="points"><mxPoint x="519" y="459"/><mxPoint x="519" y="317"/><mxPoint x="519" y="267"/><mxPoint x="489" y="267"/></Array></mxGeometry></mxCell></object><object code="flow4" conditionExpression="${approveFinished}" label="审批结束" skipExpression="" id="flow4"><mxCell style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1" parent="1" source="ApproveFinished" target="end" edge="1"><mxGeometry relative="1" as="geometry"/></mxCell></object><object code="flow3" conditionExpression="${approvePassed}" label="审批通过" skipExpression="" id="flow3"><mxCell style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1" parent="1" source="ApprovePassed" target="ApproveFinished" edge="1"><mxGeometry relative="1" as="geometry"/></mxCell></object><object code="flow2" conditionExpression="" label="" skipExpression="" id="flow2"><mxCell style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1" parent="1" source="Apply" target="Approve" edge="1"><mxGeometry relative="1" as="geometry"/></mxCell></object><object code="flow1" conditionExpression="" label="" skipExpression="" id="flow1"><mxCell style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1" parent="1" source="start" target="Apply" edge="1"><mxGeometry relative="1" as="geometry"/></mxCell></object></root></mxGraphModel>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment