feat:桌面镜像制作脚本,bug修改
parent
20c98d2d5c
commit
550fda7ce2
|
|
@ -1,6 +1,5 @@
|
||||||
package com.unisinsight.torrent.controller;
|
package com.unisinsight.torrent.controller;
|
||||||
|
|
||||||
import com.unisinsight.torrent.util.BtTorrentUtils;
|
|
||||||
import com.unisinsight.torrent.util.ImageVirtualUtils;
|
import com.unisinsight.torrent.util.ImageVirtualUtils;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
|
@ -35,12 +34,21 @@ public class DeskImageController {
|
||||||
public Double start(@RequestParam("name") String name) {
|
public Double start(@RequestParam("name") String name) {
|
||||||
System.out.println("查询进度");
|
System.out.println("查询进度");
|
||||||
Map<String, Object> resultMap = ImageVirtualUtils.progress(name);
|
Map<String, Object> resultMap = ImageVirtualUtils.progress(name);
|
||||||
if(resultMap.get("process")!=null && (Double)resultMap.get("process") == 100){
|
// 使用log打印Map内容
|
||||||
// String pid = (String) resultMap.get("pid");
|
if (resultMap != null) {
|
||||||
// ImageVirtualUtils.killProgress(pid);
|
log.info("进度信息详情:");
|
||||||
return 100.0;
|
for (Map.Entry<String, Object> entry : resultMap.entrySet()) {
|
||||||
|
log.info(" {} = {} ({})", entry.getKey(), entry.getValue(),
|
||||||
|
entry.getValue() != null ? entry.getValue().getClass().getSimpleName() : "null");
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return (Double) resultMap.get("process");
|
log.warn("未获取到进度信息,resultMap为null");
|
||||||
|
}
|
||||||
|
if (resultMap != null && resultMap.get("progress") != null) {
|
||||||
|
//
|
||||||
|
return (Double) resultMap.get("progress");
|
||||||
|
} else {
|
||||||
|
return 0.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package com.unisinsight.torrent.util;
|
package com.unisinsight.torrent.util;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
@ -13,10 +14,11 @@ import java.util.Map;
|
||||||
/**
|
/**
|
||||||
* 种子文件工具类
|
* 种子文件工具类
|
||||||
*/
|
*/
|
||||||
|
@Slf4j
|
||||||
public class ImageVirtualUtils {
|
public class ImageVirtualUtils {
|
||||||
|
|
||||||
private static final String BT_SCRIPT_PATH = "/deskTest/convert_image.sh";
|
private static final String BT_SCRIPT_PATH = "/deskTest/convert_image.sh";
|
||||||
private static final String JSON_PATH = "/deskTest/logs";
|
private static final String JSON_PATH = "/deskTest/logs/";
|
||||||
// private static final String JSON_PATH = "D:\\code\\";
|
// private static final String JSON_PATH = "D:\\code\\";
|
||||||
|
|
||||||
private static final Long WAIT_START_TIME = 8000L;
|
private static final Long WAIT_START_TIME = 8000L;
|
||||||
|
|
@ -106,7 +108,7 @@ public class ImageVirtualUtils {
|
||||||
|
|
||||||
// 读取文件内容
|
// 读取文件内容
|
||||||
String content = new String(Files.readAllBytes(Paths.get(JSON_PATH+name)));
|
String content = new String(Files.readAllBytes(Paths.get(JSON_PATH+name)));
|
||||||
|
log.info("JSON文件内容: {}", content);
|
||||||
// 使用Jackson将JSON转换为Map
|
// 使用Jackson将JSON转换为Map
|
||||||
ObjectMapper objectMapper = new ObjectMapper();
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
return objectMapper.readValue(content, Map.class);
|
return objectMapper.readValue(content, Map.class);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue