From eb580beee080cef4e9c410150b29d26b1dcb5af8 Mon Sep 17 00:00:00 2001 From: aikai Date: Mon, 13 Jan 2025 14:54:35 +0800 Subject: [PATCH] =?UTF-8?q?=E5=89=8D=E7=AB=AFpng=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E4=B8=8B=E8=BD=BD=E6=94=B9base64=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/enums/ErrorCodeConstants.java | 1 + .../positionmap/PositionMapController.java | 7 ++-- .../positionmap/PositionMapService.java | 3 +- .../positionmap/PositionMapServiceImpl.java | 37 ++++++++++++------- 4 files changed, 30 insertions(+), 18 deletions(-) diff --git a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/ErrorCodeConstants.java b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/ErrorCodeConstants.java index 37e0b1e62..048cc162e 100644 --- a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/ErrorCodeConstants.java +++ b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/ErrorCodeConstants.java @@ -201,4 +201,5 @@ public interface ErrorCodeConstants { ErrorCode AGV_FILE_UPLOAD_CONTENT_IS_EMPTY = new ErrorCode(1_002_038_002, "AGV文件上传内容为空"); ErrorCode PLEASE_UPLOAD_PNG_AND_YAML_FILES = new ErrorCode(1_002_038_003, "请上传png和yaml两个文件并且文件内容不为空"); ErrorCode AGV_MAP_NOT_FOUND = new ErrorCode(1_002_038_004, "找不到AGV地图信息"); + ErrorCode AGV_IMAGE_CONVERSION_TO_BASE64_FAILED = new ErrorCode(1_002_038_005, "AGV图片转base64失败"); } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/positionmap/PositionMapController.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/positionmap/PositionMapController.java index 82f1d6276..36a2ebd0f 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/positionmap/PositionMapController.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/positionmap/PositionMapController.java @@ -81,11 +81,12 @@ public class PositionMapController { return CommonResult.success(true); } - @GetMapping("/downloadPng") + @GetMapping("/downloadPngBase64") @Operation(summary = "下载png文件") @PermitAll - public void downloadPng(@RequestParam Integer floor, @RequestParam String area, HttpServletResponse response) throws IOException { - positionMapService.downloadPng(floor, area, response); + public CommonResult downloadPngBase64(@RequestParam Integer floor, @RequestParam String area) { + String base64 = positionMapService.downloadPngBase64(floor, area); + return CommonResult.success(base64); } @GetMapping("/download") diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/positionmap/PositionMapService.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/positionmap/PositionMapService.java index afd58867d..3ff293a71 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/positionmap/PositionMapService.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/positionmap/PositionMapService.java @@ -85,7 +85,6 @@ public interface PositionMapService extends IService { * * @param floor * @param area - * @param response */ - void downloadPng(Integer floor, String area, HttpServletResponse response) throws IOException; + String downloadPngBase64(Integer floor, String area); } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/positionmap/PositionMapServiceImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/positionmap/PositionMapServiceImpl.java index 8913fd8ce..8cc507334 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/positionmap/PositionMapServiceImpl.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/positionmap/PositionMapServiceImpl.java @@ -13,6 +13,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import org.apache.commons.io.IOUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; +import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpStatus; import org.springframework.stereotype.Service; @@ -28,6 +29,7 @@ import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.util.*; +import java.util.concurrent.TimeUnit; import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; @@ -47,6 +49,8 @@ public class PositionMapServiceImpl extends ServiceImpl