From 652f5161a91475ae0c22a88eb06b36b240edb744 Mon Sep 17 00:00:00 2001 From: 疯狂的狮子Li <15040126243@163.com> Date: 星期三, 15 一月 2025 17:40:31 +0800 Subject: [PATCH] update 适配 新版本将xml转为json --- ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/service/impl/FlwDefinitionServiceImpl.java | 16 ++++------------ 1 files changed, 4 insertions(+), 12 deletions(-) diff --git a/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/service/impl/FlwDefinitionServiceImpl.java b/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/service/impl/FlwDefinitionServiceImpl.java index da547ef..a881ba6 100644 --- a/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/service/impl/FlwDefinitionServiceImpl.java +++ b/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/service/impl/FlwDefinitionServiceImpl.java @@ -11,7 +11,6 @@ import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.dromara.common.core.exception.ServiceException; -import org.dromara.common.core.utils.DateUtils; import org.dromara.common.core.utils.StreamUtils; import org.dromara.common.core.utils.StringUtils; import org.dromara.common.json.utils.JsonUtils; @@ -41,7 +40,6 @@ import org.springframework.web.multipart.MultipartFile; import java.io.IOException; -import java.io.InputStream; import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Arrays; @@ -147,18 +145,13 @@ @Override @Transactional(rollbackFor = Exception.class) public boolean importJson(MultipartFile file, String category) { - try (InputStream inputStream = file.getInputStream()) { - byte[] fileBytes = inputStream.readAllBytes(); - String fileContent = new String(fileBytes, StandardCharsets.UTF_8); - DefJson defJson = JsonUtils.parseObject(fileContent, DefJson.class); + try { + DefJson defJson = JsonUtils.parseObject(file.getBytes(), DefJson.class); defJson.setCategory(category); defService.importDef(defJson); } catch (IOException e) { log.error("璇诲彇鏂囦欢娴侀敊璇�: {}", e.getMessage(), e); throw new IllegalStateException("鏂囦欢璇诲彇澶辫触锛岃妫�鏌ユ枃浠跺唴瀹�", e); - } catch (Exception e) { - log.error("瀵煎叆娴佺▼瀹氫箟閿欒: {}", e.getMessage(), e); - throw new IllegalStateException("瀵煎叆娴佺▼瀹氫箟澶辫触", e); } return true; } @@ -173,12 +166,11 @@ @Override public void exportDef(Long id, HttpServletResponse response) throws IOException { byte[] data = defService.exportJson(id).getBytes(StandardCharsets.UTF_8); - String filename = "workflow_export_" + DateUtils.dateTimeNow() + ".json"; // 璁剧疆鍝嶅簲澶村拰鍐呭绫诲瀷 response.reset(); response.setCharacterEncoding(StandardCharsets.UTF_8.name()); - response.setContentType("application/json"); - response.setHeader("Content-Disposition", "attachment; filename=" + filename); + response.setContentType("application/text"); + response.setHeader("Content-Disposition", "attachment;"); response.addHeader("Content-Length", "" + data.length); IoUtil.write(response.getOutputStream(), false, data); } -- Gitblit v1.9.3