flowable 走过的流程图节点描红线-凯发app官方网站

凯发app官方网站-凯发k8官网下载客户端中心 | | 凯发app官方网站-凯发k8官网下载客户端中心
  • 博客访问: 553803
  • 博文数量: 298
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 3077
  • 用 户 组: 普通用户
  • 注册时间: 2019-06-17 10:57
文章分类

(298)

  • (298)
文章存档

(96)

(201)

(1)

我的朋友
相关博文
  • ·
  • ·
  • ·
  • ·
  • ·
  • ·
  • ·
  • ·
  • ·
  • ·

分类: java

2021-08-10 12:46:10

 在正常的flowable就是显示当前节点,路径需要我们自己获取,特别是来回的驳回会导致节点混乱,这里主要就是如何正确的显示流程图

效果:

已经结束的流程

  正在执行的流程

 代码:1、生成图片

点击(此处)折叠或打开

  1. // 源码 1b23.com
  2. public byte[] createimage2(string processinstanceid) {
  3.         //1.获取当前的流程实例
  4.         processinstance processinstance = runtimeservice.createprocessinstancequery().processinstanceid(processinstanceid).singleresult();
  5.         string processdefinitionid = null;
  6.         list<string> activeactivityids = null;
  7.         //2.获取所有的历史轨迹对象
  8.         list<historicactivityinstance> list = historyservice.createhistoricactivityinstancequery()
  9.                 .processinstanceid(processinstanceid).list();
  10.         map<string, historicactivityinstance> hisactivitymap = new hashmap<>();
  11.         list.foreach(historicactivityinstance -> {
  12.             if (!hisactivitymap.containskey(historicactivityinstance.getactivityid())) {
  13.                 hisactivitymap.put(historicactivityinstance.getactivityid(), historicactivityinstance);
  14.             }
  15.         });
  16.         //3. 获取流程定义id和高亮的节点id
  17.         if (processinstance != null) {
  18.             //3.1. 正在运行的流程实例
  19.             processdefinitionid = processinstance.getprocessdefinitionid();
  20.             activeactivityids = runtimeservice.getactiveactivityids(processinstanceid);
  21.         } else {
  22.             //3.2. 已经结束的流程实例
  23.             historicprocessinstance historicprocessinstance = historyservice.createhistoricprocessinstancequery().processinstanceid(processinstanceid).singleresult();
  24.             processdefinitionid = historicprocessinstance.getprocessdefinitionid();
  25.             activeactivityids = new arraylist<>();
  26.             list<endevent> endevents = bpmnmodelservice.findendflowelement(processdefinitionid);
  27.             list<string> finalactiveactivityids = activeactivityids;
  28.             endevents.foreach(endevent -> {
  29.                 if (hisactivitymap.containskey(endevent.getid())) {
  30.                     finalactiveactivityids.add(endevent.getid());
  31.                 }
  32.             });
  33.         }
  34.         //4. 获取流程定义的所有节点信息
  35.         list<flownode> flownodes = bpmnmodelservice.findflownodes(processdefinitionid);
  36.         map<string, flownode> activitymap = flownodes.stream().collect(collectors.tomap(flownode::getid, flownode -> flownode));
  37.         list<string> highlightedflows = new arraylist<>();
  38.         //5. 递归得到高亮线
  39.         activeactivityids.foreach(activeactivityid -> this.gethighlightedflows(activitymap, hisactivitymap, activeactivityid, highlightedflows, activeactivityid));
  40.         //6. 获取bpmnmodel对象
  41.         bpmnmodel bpmnmodel = bpmnmodelservice.getbpmnmodelbyprocessdefid(processdefinitionid);
  42.         //7. 生成图片流
  43.         inputstream inputstream = flowprocessdiagramgenerator.generatediagram(bpmnmodel, activeactivityids, highlightedflows);
  44.         //8. 转化成byte便于网络传输
  45.         byte[] datas = ioutil.readinputstream(inputstream, "image inputstream name");
  46.         return datas;
  47.     }
递归获取高

点击(此处)折叠或打开

  1. //from fhadmin.cn
  2. private void gethighlightedflows(map<string, flownode> flownodemap,
  3.             map<string, historicactivityinstance> hisactivitymap,
  4.             string activeactivityid,
  5.             list<string> highlightedflows,
  6.             string oldactivityid) {
  7.         flownode flownode = flownodemap.get(activeactivityid);
  8.         list<sequenceflow> incomingflows = flownode.getincomingflows();
  9.         for (sequenceflow sequenceflow : incomingflows) {
  10.             string sourcerefid = sequenceflow.getsourceref();
  11.             if (hisactivitymap.containskey(sourcerefid) && !oldactivityid.equals(sourcerefid)) {
  12.                 highlightedflows.add(sequenceflow.getid());
  13.                 this.gethighlightedflows(flownodemap, hisactivitymap, sourcerefid, highlightedflows, oldactivityid);
  14.             } else {
  15.  
  16.           if (hisactivitymap.containskey(sourcerefid)){
  17.               highlightedflows.add(sequenceflow.getid());
  18.           }
  19.           break;
  20. } } }


阅读(5453) | 评论(0) | 转发(0) |
0

上一篇:

下一篇:

给主人留下些什么吧!~~
")); function link(t){ var href= $(t).attr('href'); href ="?url=" encodeuricomponent(location.href); $(t).attr('href',href); //setcookie("returnouturl", location.href, 60, "/"); }
网站地图