mirror of
https://github.com/dromara/RuoYi-Vue-Plus.git
synced 2025-09-29 22:56:40 +08:00
update 调整流程定义图片预览
This commit is contained in:
parent
73cf4e2a19
commit
313841839b
@ -1,6 +1,5 @@
|
||||
package org.dromara.workflow.controller;
|
||||
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@ -56,11 +55,10 @@ public class ActProcessDefinitionController extends BaseController {
|
||||
* 查看流程定义图片
|
||||
*
|
||||
* @param processDefinitionId 流程定义id
|
||||
* @param response 响应
|
||||
*/
|
||||
@GetMapping("/processDefinitionImage/{processDefinitionId}")
|
||||
public void processDefinitionImage(@PathVariable String processDefinitionId, HttpServletResponse response) {
|
||||
iActProcessDefinitionService.processDefinitionImage(processDefinitionId, response);
|
||||
public R<String> processDefinitionImage(@PathVariable String processDefinitionId) {
|
||||
return R.ok("操作成功", iActProcessDefinitionService.processDefinitionImage(processDefinitionId));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,6 +1,5 @@
|
||||
package org.dromara.workflow.service;
|
||||
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.workflow.domain.bo.ProcessDefinitionBo;
|
||||
import org.dromara.workflow.domain.vo.ProcessDefinitionVo;
|
||||
@ -34,9 +33,9 @@ public interface IActProcessDefinitionService {
|
||||
* 查看流程定义图片
|
||||
*
|
||||
* @param processDefinitionId 流程定义id
|
||||
* @param response 响应
|
||||
* @return 结果
|
||||
*/
|
||||
void processDefinitionImage(String processDefinitionId, HttpServletResponse response);
|
||||
String processDefinitionImage(String processDefinitionId);
|
||||
|
||||
/**
|
||||
* 查看流程定义xml文件
|
||||
|
@ -1,15 +1,15 @@
|
||||
package org.dromara.workflow.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.codec.Base64;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.io.IoUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import jakarta.servlet.ServletOutputStream;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.SneakyThrows;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.dromara.common.core.exception.ServiceException;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
@ -134,38 +134,12 @@ public class ActProcessDefinitionServiceImpl implements IActProcessDefinitionSer
|
||||
* 查看流程定义图片
|
||||
*
|
||||
* @param processDefinitionId 流程定义id
|
||||
* @param response 响应
|
||||
*/
|
||||
@SneakyThrows
|
||||
@Override
|
||||
public void processDefinitionImage(String processDefinitionId, HttpServletResponse response) {
|
||||
InputStream inputStream = null;
|
||||
try {
|
||||
// 设置页面不缓存
|
||||
response.setHeader("Pragma", "no-cache");
|
||||
response.addHeader("Cache-Control", "must-revalidate");
|
||||
response.addHeader("Cache-Control", "no-cache");
|
||||
response.addHeader("Cache-Control", "no-store");
|
||||
response.setDateHeader("Expires", 0);
|
||||
inputStream = repositoryService.getProcessDiagram(processDefinitionId);
|
||||
// 响应相关图片
|
||||
response.setContentType("image/png");
|
||||
|
||||
byte[] bytes = IOUtils.toByteArray(inputStream);
|
||||
ServletOutputStream outputStream = response.getOutputStream();
|
||||
outputStream.write(bytes);
|
||||
outputStream.flush();
|
||||
outputStream.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (inputStream != null) {
|
||||
try {
|
||||
inputStream.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
public String processDefinitionImage(String processDefinitionId) {
|
||||
InputStream inputStream = repositoryService.getProcessDiagram(processDefinitionId);
|
||||
return Base64.encode(IOUtils.toByteArray(inputStream));
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user