/**
* 批量导出model的xml文件
* 打包下载
* modelIdS 模型ID串
* @throws IOException
* @throws JsonProcessingException
*/
public void batchExport(String modelIdS, HttpServletResponse response, HttpServletRequest request) {
String[] split = modelIdS.split(",");
// String v = "E://abc.bpmn20.xml";
FileChannel fc = null;
try {
List<String> strings = new ArrayList<>();
for (String id : split) {
response.setCharacterEncoding("UTF-8");
org.activiti.engine.repository.Model modelData = repositoryService.getModel(id);
BpmnJsonConverter jsonConverter = new BpmnJsonConverter();
JsonNode editorNode = new ObjectMapper().readTree(repositoryService.getModelEditorSource(modelData.getId()));
BpmnModel bpmnModel = jsonConverter.convertToBpmnModel(editorNode);
BpmnXMLConverter xmlConverter = new BpmnXMLConverter();
byte[] bpmnBytes = xmlConverter.convertToXML(bpmnModel);
String name = org.apache.commons.lang3.StringUtils.trim(bpmnModel.getMainProcess().getName());
String filename = name + ".bpmn20.xml";
//写文件 (writtenLocal + filename) 临时路径
ByteBuffer bb = ByteBuffer.wrap(bpmnBytes);
fc = new FileOutputStream(writtenLocal + filename).getChannel();
strings.add(writtenLocal + filename);
fc.write(bb);
activity 模型 xml 批量打包下载(导出),直接代码 ,先把单个文件保存在某个路径下 , 然后打包下载 , 最后删除 .整个思路 .
最新推荐文章于 2023-04-01 16:18:59 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)