初识activiti,整合了网页设计器,如图:
在某个用户任务上配置了监听:
保存文件后,model数据中是有taskListeners节点的:,
然后使用model部署流程,代码如下
@Override
@Transactional
/*
* 根据模型部署流程
* */
public Boolean deployProcessByModel(String modelId, String deptWithProcessKeyId, LoginInfo loginInfo) {
RepositoryService repositoryService = processEngineUtile.getProcessEngine().getRepositoryService();
// DeploymentBuilder deployment = repositoryService.createDeployment();
// BpmnModel bpmnModel = getBpmnModel();
// deployment.addBpmnModel("test", bpmnModel).deploy();
// 部署流程
DepartmentWithProcessEntity entity=departmentWithProcessRepository
.get(DepartmentWithProcessEntity.class, deptWithProcessKeyId);
String title=departmentWithProcessRepository.getProcessDeplyTitle(deptWithProcessKeyId);
String deploymentid="";
try {
Model modelData=repositoryService.getModel(modelId);
// ObjectNode modelNode = (ObjectNode) new ObjectMapper().readTree(repositoryService.getModelEditorSource(modelData.getId()));
byte[] bpmnBytes = null;
JsonNode editorNode = new ObjectMapper().readTree(repositoryService.getModelEditorSource(modelId));
BpmnJsonConverter jsonConverter = new BpmnJsonConverter();
BpmnModel model = jsonConverter.convertToBpmnModel(editorNode);
// filename = model.getMainProcess().getId() + ".bpmn20.xml";
// BpmnModel model = new BpmnJsonConverter().convertToBpmnModel(modelNode);
bpmnBytes = new BpmnXMLConverter().convertToXML(model);
String encoded = Base64.getEncoder().encodeToString(bpmnBytes);
byte[] decoded = Base64.getDecoder().decode(encoded);
String xml=new String(decoded);
String processName = modelData.getName() + ".bpmn20.xml";
ByteArrayInputStream in = new ByteArrayInputStream(bpmnBytes);
Deployment deployment = repositoryService.createDeployment().name(title)
.addInputStream(processName, in).deploy();
deploymentid = deployment.getId();
} catch (Exception e) {
System.out.println(e);
}
Assert.isTrue(!StringUtils.isEmpty(deploymentid), "流程部署出错");
ProcessDefinition processDefinition= repositoryService
.createProcessDefinitionQuery()
.deploymentId(deploymentid)
.singleResult();
//更新部门流程关系表
entity.setProcessDefinitionId(deploymentid);
departmentWithProcessRepository.update(entity);
//部署历史表
List<DeployHistoryEntity> deployHistoryEntities = deployHistoryRepository.getDeployHistoryByDeptWithProcessKeyId(deptWithProcessKeyId);
for (DeployHistoryEntity deployHistoryEntity : deployHistoryEntities) {
if (deployHistoryEntity.getModelKeyid().equals(modelId)) {
deployHistoryEntity.setDeploy(true);
}else {
deployHistoryEntity.setDeploy(false);
}
deployHistoryRepository.update(deployHistoryEntity);
}
return true;
}
editorNode变量值拷贝出来,还是可以看到taskListeners,转成bpmn后,复制出来监听部分的节点就没有了。,很迷惘,activiti版本号5.22。整合过这个设计器的没有看到谁有这个问题,但是又不知道自己错在哪里,目前只能定位到model转bpmn的时候监听丢失了。希望知道的哥哥姐姐解答一下疑惑,或远程帮助一下,不胜感激!!!