activiti 流程文件存哪里_【入门篇】Activiti流程资源文件下载保存到本地

需求

用户或者开发人员,有时候需要对绘制好的流程文件进行查看

参考数据库

0818b9ca8b590ca3270a3433284dd417.png

方案

根据流程标识,查找流程定义表,然后读取到跟这个流程有关的文件,然后保存到本地或者给出界面显示,目前只做保存到本地

代码

//流程定义资源文件查询

@Test

public void queryProcessDefinitionResource() throws IOException{

//得到repositoryService

RepositoryService repositoryService = processEngine.getRepositoryService();

//根据流程定义id查询部署id

String processDefinitionId = "purchasingflow:1:4";

ProcessDefinition processDefinition = repositoryService

.createProcessDefinitionQuery()

.processDefinitionId(processDefinitionId).singleResult();

//部署id

String deploymentId = processDefinition.getDeploymentId();

//bpmn文件

//bpmn资源文件名称

String resourceName_bpmn = processDefinition.getResourceName();

//bpmn资源文件输入流

InputStream inputStream_bpmn = repositoryService.getResourceAsStream(deploymentId, resourceName_bpmn);

//png文件

//png文件名称

String resourceName_png = processDefinition.getDiagramResourceName();

//png资源文件输入流

InputStream inputStream_png = repositoryService.getResourceAsStream(deploymentId, resourceName_png);

//构造输入流

File file_bpmn = new File("d:/" + resourceName_bpmn);

File file_png = new File("d:/" + resourceName_png);

FileOutputStream fileOutputStream_bpmn = new FileOutputStream(file_bpmn);

FileOutputStream fileOutputStream_png = new FileOutputStream(file_png);

//流复制

byte[] b = new byte[1024];

int len = -1;

while((len = inputStream_bpmn.read(b,0,1024)) != -1){

fileOutputStream_bpmn.write(b,0,len);

}

while((len = inputStream_png.read(b,0,1024)) != -1){

fileOutputStream_png.write(b,0,len);

}

//关闭流

inputStream_bpmn.close();

inputStream_png.close();

fileOutputStream_bpmn.close();

fileOutputStream_png.close();

}

效果图

0818b9ca8b590ca3270a3433284dd417.png

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值