From b50aa418312034cfebf121f416e197d68aa5d0de Mon Sep 17 00:00:00 2001 From: wuww <252740454@qq.com> Date: 星期五, 25 四月 2025 13:46:16 +0800 Subject: [PATCH] 修改测试方法 --- src/main/java/com/se/nsl/controller/TestController.java | 54 +++++++++++++++++++++++++++++++++++++++++++++--------- 1 files changed, 45 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/se/nsl/controller/TestController.java b/src/main/java/com/se/nsl/controller/TestController.java index 5d18af0..d19efa9 100644 --- a/src/main/java/com/se/nsl/controller/TestController.java +++ b/src/main/java/com/se/nsl/controller/TestController.java @@ -20,7 +20,10 @@ import javax.annotation.Resource; import java.io.File; +import java.io.IOException; +import java.nio.charset.StandardCharsets; import java.nio.file.Files; +import java.nio.file.Path; import java.nio.file.Paths; import java.nio.file.StandardCopyOption; import java.text.SimpleDateFormat; @@ -59,7 +62,7 @@ @ApiOperation(value = "褰撳墠鏃堕棿 *") @GetMapping("/getTime") public Object getTime() { - return System.currentTimeMillis(); + return (Object) System.currentTimeMillis(); } @ApiOperation(value = "testCallExe *") @@ -89,7 +92,7 @@ public R<Object> testResuslt(String path, String time) { try { DataPo data = new DataPo(); - data.setEpsg(4548); + data.setEpsg(Integer.valueOf(4548)); data.setInPath(path); data.setStartTime(StringHelper.YMDHMS_FORMAT.parse(time)); @@ -106,7 +109,7 @@ public R<Object> testSww2Tif() { try { DataPo data = new DataPo(); - data.setEpsg(4548); + data.setEpsg(Integer.valueOf(4548)); data.setInPath("20241010095328"); data.setStartTime(StringHelper.YMDHMS_FORMAT.parse("2024-09-30 00:00:00")); @@ -123,9 +126,9 @@ public R<Object> testRainfall() { try { DataPo data = new DataPo(); - data.setEpsg(4548); - data.setTotal(60.0); - data.setDuration(60); + data.setEpsg(Integer.valueOf(4548)); + data.setTotal(Double.valueOf(60.0)); + data.setDuration(Integer.valueOf(60)); data.setInPath("20241010095328"); data.setStartTime(StringHelper.YMDHMS_FORMAT.parse("2024-07-01 00:00:00")); @@ -166,7 +169,7 @@ public R<Object> testH5() { try { DataPo data = new DataPo(); - data.setEpsg(4548); + data.setEpsg(Integer.valueOf(4548)); data.setInPath("20241010095328"); data.setStartTime(StringHelper.YMDHMS_FORMAT.parse("2024-09-30 00:00:00")); @@ -232,8 +235,8 @@ continue; // g.GetGeometryType() == ogr.wkbPolygon || g.GetGeometryType() == ogr.wkbMultiPolygon if (!wkt.contains("MULTIPOLYGON")) wkt = wkt.replace("POLYGON (", "MULTIPOLYGON ((") + ")"; - list.add(new Region(f.GetFieldAsString("name"), type.shortValue(), wkt)); - if (path.contains("瀛欒儭娌�")) list.add(new Region(f.GetFieldAsString("name"), (short) 3, wkt)); + list.add(new Region(f.GetFieldAsString("name"), type, wkt)); // type.shortValue() + if (path.contains("瀛欒儭娌�")) list.add(new Region(f.GetFieldAsString("name"), 3, wkt)); } } ds.delete(); @@ -310,4 +313,37 @@ return fail(ex, null); } } + + @ApiOperation(value = "testPngList <") + @GetMapping("/testPngList") + @ApiImplicitParams({ + @ApiImplicitParam(name = "path", value = "璺緞", dataType = "String", paramType = "query", example = "D:\\other\\simu\\out\\chicago\\waters"), + @ApiImplicitParam(name = "size", value = "灏哄", dataType = "Integer", paramType = "query", example = "1024") + }) + public R<Object> testPngList(String path, Integer size) { + try { + if (null == size) size = (Integer) 1024; + List<String> list = new ArrayList<>(); + for (File file : new File(path).listFiles()) { + if (!file.exists() || file.isFile()) continue; + + File pngFile = new File(file.getPath() + File.separator + size + "_" + size + ".png"); + if (!pngFile.exists() || pngFile.isDirectory()) continue; + + list.add("file '" + pngFile.getPath().replace("\\", "/") + "'"); + System.out.println(list.get(list.size() - 1)); + } + + Path outPath = Paths.get(path + File.separator + "list.txt"); + try { + Files.write(outPath, list, StandardCharsets.UTF_8); + } catch (IOException e) { + e.printStackTrace(); + } + + return success("ok"); + } catch (Exception ex) { + return fail(ex, null); + } + } } -- Gitblit v1.9.3