From 917fc2502799b04e584e7e9a9c027667de063d1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B1=A4=E5=85=A8=E6=98=86?= Date: Wed, 3 Sep 2025 18:27:24 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E9=85=8D=E7=BD=AE=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=EF=BC=8Cbug=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nex-be/src/main/resources/application.yml | 8 +++--- .../controller/DeskImageController.java | 26 ++++++++++++++++--- 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/nex-be/src/main/resources/application.yml b/nex-be/src/main/resources/application.yml index 42aa3bf..86e4272 100644 --- a/nex-be/src/main/resources/application.yml +++ b/nex-be/src/main/resources/application.yml @@ -5,7 +5,7 @@ file: upload: temp-dir: /var/lib/vdi/tmp/chunked-uploads dir: /var/lib/vdi/test - bt-url: http://10.100.51.86:8114 + bt-url: http://10.100.51.179:8114 tool: dir: /vms/tool/iso spring: @@ -50,7 +50,7 @@ mybatis-plus: grpc: server: # 指定Grpc暴露的端口,后续客户端通过这个端口访问 - port: 51051 + port: 50051 # Feign 配置 feign: @@ -70,6 +70,6 @@ logging: com.unisinsight.project.feign.ExternalApiClient: debug external: api: - url: http://10.100.51.178:8000 + url: http://10.100.51.179:8000 torrent: - url: http://10.100.51.178:8114 \ No newline at end of file + url: http://10.100.51.179:8114 \ No newline at end of file diff --git a/torrent-be/src/main/java/com/unisinsight/torrent/controller/DeskImageController.java b/torrent-be/src/main/java/com/unisinsight/torrent/controller/DeskImageController.java index c24e4f6..2767b28 100644 --- a/torrent-be/src/main/java/com/unisinsight/torrent/controller/DeskImageController.java +++ b/torrent-be/src/main/java/com/unisinsight/torrent/controller/DeskImageController.java @@ -34,7 +34,8 @@ public class DeskImageController { public Double start(@RequestParam("name") String name) { System.out.println("查询进度"); Map resultMap = ImageVirtualUtils.progress(name); - // 使用log打印Map内容 + + // 使用log打印Map内容 if (resultMap != null) { log.info("进度信息详情:"); for (Map.Entry entry : resultMap.entrySet()) { @@ -44,9 +45,28 @@ public class DeskImageController { } else { log.warn("未获取到进度信息,resultMap为null"); } + if (resultMap != null && resultMap.get("progress") != null) { -// - return (Double) resultMap.get("progress"); + Object progressObj = resultMap.get("progress"); + + // 类型安全的转换 + if (progressObj instanceof Double) { + return (Double) progressObj; + } else if (progressObj instanceof Integer) { + return ((Integer) progressObj).doubleValue(); + } else if (progressObj instanceof Number) { + return ((Number) progressObj).doubleValue(); + } else if (progressObj instanceof String) { + try { + return Double.parseDouble((String) progressObj); + } catch (NumberFormatException e) { + log.warn("无法解析进度值: {}", progressObj); + return 0.0; + } + } else { + log.warn("未知的进度值类型: {}", progressObj.getClass().getSimpleName()); + return 0.0; + } } else { return 0.0; }