|
@ -29,6 +29,7 @@ import org.springframework.web.bind.annotation.RestController; |
|
|
import javax.xml.stream.XMLInputFactory; |
|
|
import javax.xml.stream.XMLInputFactory; |
|
|
import javax.xml.stream.XMLStreamReader; |
|
|
import javax.xml.stream.XMLStreamReader; |
|
|
import java.io.UnsupportedEncodingException; |
|
|
import java.io.UnsupportedEncodingException; |
|
|
|
|
|
import java.nio.charset.Charset; |
|
|
import java.util.*; |
|
|
import java.util.*; |
|
|
import java.util.stream.Collectors; |
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
@ -52,7 +53,7 @@ public class WorkFlowController { |
|
|
public void model() { |
|
|
public void model() { |
|
|
RepositoryService repositoryService = processEngine.getRepositoryService(); |
|
|
RepositoryService repositoryService = processEngine.getRepositoryService(); |
|
|
Model model = repositoryService.newModel(); |
|
|
Model model = repositoryService.newModel(); |
|
|
model.setName("请假工作流"); |
|
|
model.setName("请假工作流市场部"); |
|
|
model.setKey("holidayex"); |
|
|
model.setKey("holidayex"); |
|
|
repositoryService.saveModel(model); |
|
|
repositoryService.saveModel(model); |
|
|
System.out.println(model.getId()); |
|
|
System.out.println(model.getId()); |
|
@ -98,6 +99,7 @@ public class WorkFlowController { |
|
|
JsonNode modelNode = new ObjectMapper().readTree(bytes); |
|
|
JsonNode modelNode = new ObjectMapper().readTree(bytes); |
|
|
BpmnModel model = new BpmnJsonConverter().convertToBpmnModel(modelNode); |
|
|
BpmnModel model = new BpmnJsonConverter().convertToBpmnModel(modelNode); |
|
|
model.getProcesses().get(0).setName(modelData.getName()); |
|
|
model.getProcesses().get(0).setName(modelData.getName()); |
|
|
|
|
|
model.getProcesses().get(0).setId(modelData.getKey()); |
|
|
//校验有没有开始结束节点-
|
|
|
//校验有没有开始结束节点-
|
|
|
List<EndEvent> endEventList = model.getProcesses().get(0).findFlowElementsOfType(EndEvent.class); |
|
|
List<EndEvent> endEventList = model.getProcesses().get(0).findFlowElementsOfType(EndEvent.class); |
|
|
List<StartEvent> startEventList = model.getProcesses().get(0).findFlowElementsOfType(StartEvent.class); |
|
|
List<StartEvent> startEventList = model.getProcesses().get(0).findFlowElementsOfType(StartEvent.class); |
|
@ -106,19 +108,9 @@ public class WorkFlowController { |
|
|
for (ExclusiveGateway gateway : gateways) { |
|
|
for (ExclusiveGateway gateway : gateways) { |
|
|
System.out.println(gateway.getId()); |
|
|
System.out.println(gateway.getId()); |
|
|
Collection<FlowElement> flowElements = model.getProcesses().get(0).getFlowElements(); |
|
|
Collection<FlowElement> flowElements = model.getProcesses().get(0).getFlowElements(); |
|
|
List<SequenceFlow> collect = model.getProcesses().get(0).findFlowElementsOfType(SequenceFlow.class).stream().filter(x -> { |
|
|
List<SequenceFlow> collect = model.getProcesses().get(0).findFlowElementsOfType(SequenceFlow.class).stream().filter(x -> x.getSourceRef().equals(gateway.getId())).collect(Collectors.toList()); |
|
|
flowElements.remove(x); |
|
|
flowElements.removeAll(collect); |
|
|
return x.getSourceRef().equals(gateway.getId()); |
|
|
Collections.sort(collect, (x1, x2) -> x1.getConditionExpression() == null && x2.getConditionExpression() != null ? 1 : x1.getConditionExpression() != null && x2.getConditionExpression() == null ? -1 : 0); |
|
|
}).collect(Collectors.toList()); |
|
|
|
|
|
Collections.sort(collect, (x1, x2) -> { |
|
|
|
|
|
if (x1.getConditionExpression() == null && x2.getConditionExpression() != null) { |
|
|
|
|
|
return 1; |
|
|
|
|
|
} |
|
|
|
|
|
if (x1.getConditionExpression() != null && x2.getConditionExpression() == null) { |
|
|
|
|
|
return -1; |
|
|
|
|
|
} |
|
|
|
|
|
return 0; |
|
|
|
|
|
}); |
|
|
|
|
|
flowElements.addAll(collect); |
|
|
flowElements.addAll(collect); |
|
|
System.out.println(collect); |
|
|
System.out.println(collect); |
|
|
} |
|
|
} |
|
@ -133,13 +125,12 @@ public class WorkFlowController { |
|
|
byte[] bpmnByates = new BpmnXMLConverter().convertToXML(model); |
|
|
byte[] bpmnByates = new BpmnXMLConverter().convertToXML(model); |
|
|
//发布流程
|
|
|
//发布流程
|
|
|
String processName = modelData.getName() + ".bpmn20.xml"; |
|
|
String processName = modelData.getName() + ".bpmn20.xml"; |
|
|
String convertToXML = new String(bpmnByates); |
|
|
String convertToXML = new String(bpmnByates, "UTF-8"); |
|
|
System.out.println(convertToXML); |
|
|
System.out.println(convertToXML); |
|
|
DeploymentBuilder deployment = repositoryService.createDeployment(); |
|
|
DeploymentBuilder deployment = repositoryService.createDeployment(); |
|
|
deployment.name(modelData.getName()); |
|
|
deployment.name(modelData.getName()); |
|
|
deployment.addString(processName, convertToXML); |
|
|
deployment.addString(processName, convertToXML); |
|
|
// deployment.key(modelData.getKey());
|
|
|
deployment.key(modelData.getKey()); |
|
|
deployment.key("holidayex"); |
|
|
|
|
|
Deployment deploy = deployment.deploy(); |
|
|
Deployment deploy = deployment.deploy(); |
|
|
modelData.setDeploymentId(deploy.getId()); |
|
|
modelData.setDeploymentId(deploy.getId()); |
|
|
System.out.println(deploy.getId()); |
|
|
System.out.println(deploy.getId()); |
|
|