public void viewImage() throws Exception {
// 创建仓库服务对对象
RepositoryService repositoryService = processEngine.getRepositoryService();
// 从仓库中找需要展示的文件
String deploymentId = "701";
List<String> names = repositoryService.getDeploymentResourceNames(deploymentId);
String imageName = null;
for (String name : names) {
if(name.indexOf(".png")>=0){
imageName = name;
}
}
if(imageName!=null){
// System.out.println(imageName);
File f = new File("e:/"+ imageName);
// 通过部署ID和文件名称得到文件的输入流
InputStream in = repositoryService.getResourceAsStream(deploymentId, imageName);
FileUtils.copyInputStreamToFile(in, f);
}
public String viewImage(){
InputStream in = repositoryService.getResourceAsStream.getImageStream(deploymentId,imageName);//此处方法实际项目应该放在service里面
HttpServletResponse resp = ServletActionContext.getResponse();
try {
OutputStream out = resp.getOutputStream();
// 把图片的输入流程写入resp的输出流中
byte[] b = new byte[1024];
for (int len = -1; (len= in.read(b))!=-1; ) {
out.write(b, 0, len);
}
// 关闭流
out.close();
in.close();
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
public String viewCurrentImage(){
ProcessDefinition pd = service.getProcessDefinitionByTaskId(taskId);
// 1. 获取流程部署ID
putContext("deploymentId", pd.getDeploymentId());
// 2. 获取流程图片的名称
putContext("imageName", pd.getDiagramResourceName());
// 3.获取当前活动的坐标
Map<String,Object> currentActivityCoordinates =service.getCurrentActivityCoordinates(taskId);
putContext("acs", currentActivityCoordinates);
return "image";
}
public ProcessDefinition getProcessDefinitionByTaskId(String taskId) {
// 1. 得到task
Task task = taskService.createTaskQuery().taskId(taskId).singleResult();
// 2. 通过task对象的pdid获取流程定义对象
ProcessDefinition pd = repositoryService.getProcessDefinition(task.getProcessDefinitionId());
return pd;
}
public Map<String, Object> getCurrentActivityCoordinates(String taskId) {
Map<String, Object> coordinates = new HashMap<String, Object>();
// 1. 获取到当前活动的ID
Task task = taskService.createTaskQuery().taskId(taskId).singleResult();
ProcessInstance pi = runtimeService.createProcessInstanceQuery().processInstanceId(task.getProcessInstanceId()).singleResult();
String currentActivitiId = pi.getActivityId();
// 2. 获取到流程定义
ProcessDefinitionEntity pd = (ProcessDefinitionEntity) repositoryService.getProcessDefinition(task.getProcessDefinitionId());
// 3. 使用流程定义通过currentActivitiId得到活动对象
ActivityImpl activity = pd.findActivity(currentActivitiId);
// 4. 获取活动的坐标
coordinates.put("x", activity.getX());
coordinates.put("y", activity.getY());
coordinates.put("width", activity.getWidth());
coordinates.put("height", activity.getHeight());
return coordinates;
}
<body> <!-- 1.获取到规则流程图 这里是用的strust2的标签得到上面上面放入值栈的值--> <img style="position: absolute;top: 0px;left: 0px;" src="viewImage?deploymentId=<s:property value='#deploymentId'/>&imageName=<s:property value='#imageName'/>"> <!-- 2.根据当前活动的坐标,动态绘制DIV --> <div style="position: absolute;border:1px solid red;top:<s:property value='#acs.y'/>px;left: <s:property value='#acs.x'/>px;width: <s:property value='#acs.width'/>px;height:<s:property value='#acs.height'/>px; "></div> </body>
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有