activiti工作流项目中显示流程进度(流程图高亮显示)

更新时间:2023-05-21 11:37:37 阅读: 评论:0

activiti⼯作流项⽬中显⽰流程进度(流程图⾼亮显⽰)1.flowList.jsp页⾯使⽤img标签,processInstanceId为后台传来的值
<img src="testController.do?queryProPlan&ProcessInstanceId=${processInstanceId}"/>
2.后台代码(ProcessDiagramGenerator的获取根据activiti版本的不同有两种⽅式)
package st.controller;
import java.util.ArrayList;
import java.util.List;
import javax.rvlet.http.HttpServletRequest;
import javax.rvlet.http.HttpServletRespon;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
我们开学了手抄报import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.rvlet.ModelAndView;
import ller.BaController;
创业的类型import org.jeecgframework.web.system.rvice.SystemService;
import java.io.InputStream;
import org.del.BpmnModel;
import ine.HistoryService;
import ine.ProcessEngineConfiguration;
import ine.RepositoryService;
import ine.RuntimeService;
import ine.TaskService;
import ine.history.HistoricActivityInstance;
import ine.history.HistoricProcessInstance;
import ine.impl.cfg.ProcessEngineConfigurationImpl;
import t.Context;
import ine.ity.ProcessDefinitionEntity;
import ine.impl.pvm.PvmTransition;
import ine.impl.pvm.process.ActivityImpl;
import org.activiti.image.ProcessDiagramGenerator;
import org.activiti.image.impl.DefaultProcessDiagramGenerator;
import org.activiti.spring.ProcessEngineFactoryBean;
import java.io.IOException;
import st.rvice.TestServiceI;
/**
* @Title: Controller
* @Description: test
* @author onlineGenerator
* @date 2019-11-15 14:27:21
* @version V1.0
*
*/
@Controller
@RequestMapping("/testController")
public class CopyOfTestController1 extends BaController {
private static final Logger logger = LoggerFactory
.getLogger(CopyOfTestController1.class);
@Autowired
@Autowired
private TestServiceI testService;
@Autowired
private SystemService systemService;
@Autowired
RepositoryService repositoryService;
@Autowired
protected RuntimeService runtimeService;
@Autowired
ProcessEngineConfiguration processEngineConfiguration;
@Autowired
ProcessEngineFactoryBean processEngine;
@Autowired
HistoryService historyService;
@Autowired
TaskService taskService;
/**
古诗书法
* test列表页⾯跳转
*
* @return
*/
@RequestMapping(params = "list")
public ModelAndView list(HttpServletRequest request) {
return new ModelAndView("com/hdkj/test/testList");
}
/**
* 流程列表页⾯跳转
*
* @return
*/
@RequestMapping(params = "flowList")
public ModelAndView flowList(HttpServletRequest request) {
String id = Parameter("id");
String processInstanceId = stService
.getProcessInstanceIdById(id);
request.tAttribute("businesskey", id);
request.tAttribute("processInstanceId", processInstanceId);
return new ModelAndView("com/hdkj/test/flowList");
民族民主革命}
@RequestMapping(params = "queryProPlan")
public void queryProPlan(HttpServletRequest request,
HttpServletRespon respon) throws IOException {
String processInstanceId = Parameter("ProcessInstanceId");
// 获取历史流程实例
HistoricProcessInstance processInstance = historyService
.createHistoricProcessInstanceQuery()
.processInstanceId(processInstanceId).singleResult();
// 获取流程图
BpmnModel bpmnModel = BpmnModel(processInstance
.getProcessDefinitionId());
processEngineConfiguration = processEngine
.getProcessEngineConfiguration();
Context.tProcessEngineConfiguration((ProcessEngineConfigurationImpl) processEngineConfiguration);
//activiti-engine-5.15.jar版本获取diagramGenerator⽅式
ProcessDiagramGenerator diagramGenerator = new DefaultProcessDiagramGenerator();
//activiti-engine-5.22.0.jar版本获取diagramGenerator⽅式
//ProcessDiagramGenerator diagramGenerator = processEngineConfiguration
//  .getProcessDiagramGenerator();
ProcessDefinitionEntity definitionEntity = (ProcessDefinitionEntity) repositoryService
.ProcessDefinitionId());
/*第⼀种.⾼亮⽬前⾛过的节点*/
List<HistoricActivityInstance> highLightedActivitList =  ateHistoricActivityInstanceQuery().processInstanceId(processInstanceId).list();
List<HistoricActivityInstance> highLightedActivitList =  ateHistoricActivityInstanceQuery().processInstanceId(processInstanceId).list();
/*第⼆种,⾼亮最后⾛过的那个节点*/
/*List<HistoricActivityInstance> highLightedActivitList1 = historyService
.createHistoricActivityInstanceQuery()
.processInstanceId(processInstanceId).orderByHistoricActivityInstanceStartTime().desc().list();
List<HistoricActivityInstance> highLightedActivitList=new ArrayList<HistoricActivityInstance>();
highLightedActivitList.(0));
*/
// ⾼亮环节id集合
List<String> highLightedActivitis = new ArrayList<String>();
// ⾼亮线路id集合
List<String> highLightedFlows = getHighLightedFlows(definitionEntity,
highLightedActivitList);
for (HistoricActivityInstance tempActivity : highLightedActivitList) {
String activityId = ActivityId();
highLightedActivitis.add(activityId);
}
// 中⽂显⽰的是⼝⼝⼝,设置字体就好了
InputStream imageStream = ateDiagram(bpmnModel,
"png", highLightedActivitis, highLightedFlows, "宋体", "宋体",
null, null, 1.0);
// 单独返回流程图,不⾼亮显⽰
// InputStream imageStream =
// atePngDiagram(bpmnModel);
// 输出资源内容到相应对象
byte[] b = new byte[1024];
int len;
while ((len = ad(b, 0, 1024)) != -1) {
}
}
/
**
* 获取需要⾼亮的线
*
* @param processDefinitionEntity
* @param historicActivityInstances
* @return
*/
private List<String> getHighLightedFlows(
ProcessDefinitionEntity processDefinitionEntity,
List<HistoricActivityInstance> historicActivityInstances) {
List<String> highFlows = new ArrayList<String>();// ⽤以保存⾼亮的线flowId
for (int i = 0; i < historicActivityInstances.size() - 1; i++) {// 对历史流程节点进⾏遍历
ActivityImpl activityImpl = processDefinitionEntity
.(i)
.getActivityId());// 得到节点定义的详细信息
List<ActivityImpl> sameStartTimeNodes = new ArrayList<ActivityImpl>();// ⽤以保存后需开始时间相同的节点骨头粥的做法
ActivityImpl sameActivityImpl1 = processDefinitionEntity
.(i + 1)
.getActivityId());
// 将后⾯第⼀个节点放在时间相同节点的集合⾥
sameStartTimeNodes.add(sameActivityImpl1);
for (int j = i + 1; j < historicActivityInstances.size() - 1; j++) {
黄的成语
HistoricActivityInstance activityImpl1 = historicActivityInstances
.get(j);// 后续第⼀个节点
HistoricActivityInstance activityImpl2 = historicActivityInstances
两个月的宝宝吃手.get(j + 1);// 后续第⼆个节点
if (StartTime().equals(
// 如果第⼀个节点和第⼆个节点开始时间相同保存
ActivityImpl sameActivityImpl2 = processDefinitionEntity
.ActivityId());
sameStartTimeNodes.add(sameActivityImpl2);
} el {
// 有不相同跳出循环
break;
}
}
List<PvmTransition> pvmTransitions = activityImpl
.getOutgoingTransitions();// 取出节点的所有出去的线期货怎么买
for (PvmTransition pvmTransition : pvmTransitions) {
// 对所有的线进⾏遍历
ActivityImpl pvmActivityImpl = (ActivityImpl) pvmTransition
.getDestination();
/
/ 如果取出的线的⽬标节点存在时间相同的节点⾥,保存该线的id,进⾏⾼亮显⽰    if (ains(pvmActivityImpl)) {
highFlows.Id());
}
}
}
return highFlows;
}
}

本文发布于:2023-05-21 11:37:37,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/fan/82/719058.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:节点   获取   时间   流程   后台   集合
相关文章
留言与评论(共有 0 条评论)
   
验证码:
推荐文章
排行榜
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图