From 59b432c883011119649c283cc9d4c1d357599802 Mon Sep 17 00:00:00 2001
From: dcb <xgybdcb@163.com>
Date: 星期一, 30 六月 2025 15:13:56 +0800
Subject: [PATCH] 对于没有不能获取到数据的雨量计,使用其他雨量计数据填充

---
 src/main/java/com/se/nsl/service/ResolveService.java |  216 ++++++++++++++++++++++++++---------------------------
 1 files changed, 106 insertions(+), 110 deletions(-)

diff --git a/src/main/java/com/se/nsl/service/ResolveService.java b/src/main/java/com/se/nsl/service/ResolveService.java
index e041ab5..a78e688 100644
--- a/src/main/java/com/se/nsl/service/ResolveService.java
+++ b/src/main/java/com/se/nsl/service/ResolveService.java
@@ -11,8 +11,6 @@
 import com.se.nsl.domain.po.Simu;
 import com.se.nsl.domain.po.SimuData;
 import com.se.nsl.domain.vo.ConfigVo;
-import com.se.nsl.domain.vo.RealTimeInput;
-import com.se.nsl.domain.vo.ResultVo;
 import com.se.nsl.helper.ComHelper;
 import com.se.nsl.helper.GdalHelper;
 import com.se.nsl.helper.StringHelper;
@@ -37,7 +35,6 @@
 import javax.annotation.Resource;
 import java.io.BufferedReader;
 import java.io.File;
-import java.io.IOException;
 import java.io.InputStreamReader;
 import java.math.BigDecimal;
 import java.math.RoundingMode;
@@ -46,7 +43,6 @@
 import java.sql.Timestamp;
 import java.text.SimpleDateFormat;
 import java.time.Instant;
-import java.time.LocalDateTime;
 import java.time.temporal.ChronoUnit;
 import java.util.*;
 import java.util.concurrent.ExecutorService;
@@ -156,7 +152,7 @@
     /**
      * 鍒濆鍖栧弬鏁�
      */
-    public void initArgs(Simu simu, SimuData data) throws IOException {
+    public void initArgs(Simu simu, SimuData data) {
         String inPath = config.getInPath() + File.separator + data.getInPath();
         createDir(inPath);
         createDir(inPath + File.separator + "depth");
@@ -522,114 +518,114 @@
     }
 
     //瀹炴椂妯℃嫙
-    public String realTimeSimulate(RealTimeInput input) throws IOException {
-        long currentTime = System.currentTimeMillis();
-        //鏍规嵁鏈嶅姟鎵惧埌鎸囧畾鐨勬枃浠跺す
-        String serviceName = input.getServiceName();
-        File serviceNameDir = new File(config.getInPath(), serviceName);
-        //鐢熸垚涓�涓柊鐨勯洦閲忔枃浠�,闇�瑕佸師鍏堥洦閲忔枃浠剁殑涓�浜涗俊鎭紝鎵�浠ラ渶瑕佸厛璇诲彇鏃х殑
-        String[] values = readTheOldFirstLineRainfallValue(serviceNameDir);
-        File newDatFile = generateNewRainfallFile(input, values, serviceNameDir, currentTime);
+//    public String realTimeSimulate(RealTimeInput input) throws IOException {
+//        long currentTime = System.currentTimeMillis();
+//        //鏍规嵁鏈嶅姟鎵惧埌鎸囧畾鐨勬枃浠跺す
+//        String serviceName = input.getServiceName();
+//        File serviceNameDir = new File(config.getInPath(), serviceName);
+//        //鐢熸垚涓�涓柊鐨勯洦閲忔枃浠�,闇�瑕佸師鍏堥洦閲忔枃浠剁殑涓�浜涗俊鎭紝鎵�浠ラ渶瑕佸厛璇诲彇鏃х殑
+//        String[] values = readTheOldFirstLineRainfallValue(serviceNameDir);
+//        File newDatFile = generateNewRainfallFile(input, values, serviceNameDir, currentTime);
+//
+//        //鐢熸垚涓�涓柊鐨勭敓鎴恴arr鐨勯厤缃枃浠�
+//        File newConfigFile = generateNewZarrConfigFile(serviceNameDir, serviceName, currentTime, newDatFile);
+//        //鎵ц姹傝В鍣ㄨ繍绠�
+//        String cmd = String.format("%s \"%s\"", config.getUwSolverBat(), newConfigFile);
+//        callBat2(cmd);
+//
+//        //鐢熸垚涓�涓柊鐨剒arr杞瑃if鐨刯son鏂囦欢
+//        File newZarr2TifJson = generateNewZarr2TifJson(serviceNameDir, currentTime);
+//        //鎵цzarr杞瑃if
+//        String zarr2TifCmd = String.format("%s \"%s\"", config.getZarr2tifBat(), newZarr2TifJson);
+//        callBat2(zarr2TifCmd);
+//        //杩斿洖鏂扮殑layer.json鍚嶇О
+//        return generateLayerJsonAndPng(serviceName, serviceNameDir, currentTime);
+//
+//    }
 
-        //鐢熸垚涓�涓柊鐨勭敓鎴恴arr鐨勯厤缃枃浠�
-        File newConfigFile = generateNewZarrConfigFile(serviceNameDir, serviceName, currentTime, newDatFile);
-        //鎵ц姹傝В鍣ㄨ繍绠�
-        String cmd = String.format("%s \"%s\"", config.getUwSolverBat(), newConfigFile);
-        callBat2(cmd);
+//    private String generateLayerJsonAndPng(String serviceName, File serviceNameDir, long currentTime) throws IOException {
+//        ResultDto resultDto = new ResultDto();
+//        resultDto.setServiceName(serviceName);
+//        File temp = Paths.get(config.getOutPath(), serviceName, "temp").toFile();
+//        if (!temp.exists()) temp.mkdir();
+//        resultDto.setTemp(temp.getAbsolutePath());
+//        resultDto.setOutPath(Paths.get(config.getOutPath(), serviceName).toString());
+//        File dem = new File(serviceNameDir, "DEM.tif");
+//        resultDto.setTerrainFile(dem.getAbsolutePath());
+//        File newDepthDir = new File(serviceNameDir + File.separator + "depth_" + currentTime);
+//        resultDto.setWaterPath(newDepthDir.getAbsolutePath());
+//        LayerDto layerDto = new LayerDto(config.getVer(), 4548, config.getSizes());
+//        String newLayerJsonName = "layer_" + currentTime + ".json";
+//        layerDto.setName(newLayerJsonName);
+//        testService.processRealTime(resultDto, layerDto);
+//        return newLayerJsonName;
+//    }
 
-        //鐢熸垚涓�涓柊鐨剒arr杞瑃if鐨刯son鏂囦欢
-        File newZarr2TifJson = generateNewZarr2TifJson(serviceNameDir, currentTime);
-        //鎵цzarr杞瑃if
-        String zarr2TifCmd = String.format("%s \"%s\"", config.getZarr2tifBat(), newZarr2TifJson);
-        callBat2(zarr2TifCmd);
-        //杩斿洖鏂扮殑layer.json鍚嶇О
-        return generateLayerJsonAndPng(serviceName, serviceNameDir, currentTime);
+//    private File generateNewZarr2TifJson(File serviceNameDir, long currentTime) throws IOException {
+//        File srcZarr2TifJson = new File(serviceNameDir, "zarr2tif.json");
+//        Zarr2Tif zarr2Tif = mapper.readValue(srcZarr2TifJson, Zarr2Tif.class);
+//        //淇敼zarr2tif瀵硅薄涓殑瀛楁
+////        String stamp = TimeFormatUtil.formatTime(currentTime, "yyyy-MM-dd HH:mm:ss");
+////        zarr2Tif.setStart_timestamp(stamp);
+////        String newZarrPath = serviceNameDir + File.separator + "result_" + currentTime + ".zarr";
+//        String newZarrPath = serviceNameDir + File.separator + "result.zarr";
+//        zarr2Tif.setZarr_file(newZarrPath);
+//        zarr2Tif.setGeotiff_dir(serviceNameDir + File.separator + "depth_" + currentTime);
+//        File newZarr2TifJson = new File(serviceNameDir, "zarr2tif_" + currentTime + ".json");
+//        mapper.writeValue(newZarr2TifJson, zarr2Tif);
+//        return newZarr2TifJson;
+//    }
 
-    }
+//    private File generateNewZarrConfigFile(File serviceNameDir, String serviceName, long currentTime, File newDatFile) throws IOException {
+//        File configFile = new File(serviceNameDir, serviceName + ".json");
+//        ConfigVo configVo = mapper.readValue(configFile, ConfigVo.class);
+//        int simulateTime = 300; //妯℃嫙鏃堕棿锛岄粯璁や负5min锛屽嵆300s
+//        int intervalTime = 60; //姣忓抚鐨勯棿闅旀椂闂达紝榛樿涓�60s,60s鐢熸垚涓�甯�
+//        configVo.getRaingage().set(0, newDatFile.getAbsolutePath()); //raingage file
+//        ResultVo result = configVo.getResult();
+//        Integer oldDuration = configVo.getDuration();
+////        result.setSave_start(oldDuration); //璧峰鏃堕棿瑕佸湪涓婃鏃堕棿鐨勫熀纭�涓婂紑濮�
+//        configVo.setDuration(oldDuration + simulateTime); //鍥哄畾涓�5min
+//        result.setSave_interval(intervalTime);
+//        result.setSave_frames(result.getSave_frames() + (simulateTime / intervalTime)); //淇濈暀5甯э紝鍦ㄥ師鏉ョ殑鍩虹涓婂鍔�5甯�
+////        String newZarrPath = serviceNameDir + File.separator + "result_" + currentTime + ".zarr";
+//        String newZarrPath = serviceNameDir + File.separator + "result.zarr";
+//        result.setSave_name(newZarrPath);
+//        File newConfigFile = new File(serviceNameDir, currentTime + ".json");
+//        mapper.writeValue(newConfigFile, configVo);
+//        return newConfigFile;
+//    }
 
-    private String generateLayerJsonAndPng(String serviceName, File serviceNameDir, long currentTime) throws IOException {
-        ResultDto resultDto = new ResultDto();
-        resultDto.setServiceName(serviceName);
-        File temp = Paths.get(config.getOutPath(), serviceName, "temp").toFile();
-        if (!temp.exists()) temp.mkdir();
-        resultDto.setTemp(temp.getAbsolutePath());
-        resultDto.setOutPath(Paths.get(config.getOutPath(), serviceName).toString());
-        File dem = new File(serviceNameDir, "DEM.tif");
-        resultDto.setTerrainFile(dem.getAbsolutePath());
-        File newDepthDir = new File(serviceNameDir + File.separator + "depth_" + currentTime);
-        resultDto.setWaterPath(newDepthDir.getAbsolutePath());
-        LayerDto layerDto = new LayerDto(config.getVer(), 4548, config.getSizes());
-        String newLayerJsonName = "layer_" + currentTime + ".json";
-        layerDto.setName(newLayerJsonName);
-        testService.processRealTime(resultDto, layerDto);
-        return newLayerJsonName;
-    }
+//    private File generateNewRainfallFile(RealTimeInput input, String[] values, File serviceNameDir, long currentTime) throws IOException {
+//        String station = values[0];
+//        double lon = Double.parseDouble(values[1]);
+//        double lat = Double.parseDouble(values[2]);
+//        String title = config.getRainfallTitle();
+//        List<String> newLines = new ArrayList<>();
+//        newLines.add(title);
+//        List<RealTimeInput.RealTimeData> data = input.getData();
+//        for (RealTimeInput.RealTimeData rd : data) {
+//            LocalDateTime dateTime = rd.getDateTime();
+//            int year = dateTime.getYear();
+//            int month = dateTime.getMonthValue();
+//            int day = dateTime.getDayOfMonth();
+//            int hour = dateTime.getHour();
+//            int minute = dateTime.getMinute();
+//            double intensity = rd.getIntensity(); //淇濈暀鎸囧畾浣嶆暟灏忔暟
+//            String l = String.format("%s %s %s %s %s %s %s %s %s",
+//                    station, lon, lat, year, month, day, hour, minute, String.format("%.6f", intensity));
+//            newLines.add(l);
+//        }
+//        File newDatFile = new File(serviceNameDir, "rainfall_" + currentTime + ".dat");
+//        if (!newDatFile.exists()) newDatFile.createNewFile();
+//        Files.write(newDatFile.toPath(), newLines, StandardOpenOption.TRUNCATE_EXISTING);
+//        return newDatFile;
+//    }
 
-    private File generateNewZarr2TifJson(File serviceNameDir, long currentTime) throws IOException {
-        File srcZarr2TifJson = new File(serviceNameDir, "zarr2tif.json");
-        Zarr2Tif zarr2Tif = mapper.readValue(srcZarr2TifJson, Zarr2Tif.class);
-        //淇敼zarr2tif瀵硅薄涓殑瀛楁
-//        String stamp = TimeFormatUtil.formatTime(currentTime, "yyyy-MM-dd HH:mm:ss");
-//        zarr2Tif.setStart_timestamp(stamp);
-//        String newZarrPath = serviceNameDir + File.separator + "result_" + currentTime + ".zarr";
-        String newZarrPath = serviceNameDir + File.separator + "result.zarr";
-        zarr2Tif.setZarr_file(newZarrPath);
-        zarr2Tif.setGeotiff_dir(serviceNameDir + File.separator + "depth_" + currentTime);
-        File newZarr2TifJson = new File(serviceNameDir, "zarr2tif_" + currentTime + ".json");
-        mapper.writeValue(newZarr2TifJson, zarr2Tif);
-        return newZarr2TifJson;
-    }
-
-    private File generateNewZarrConfigFile(File serviceNameDir, String serviceName, long currentTime, File newDatFile) throws IOException {
-        File configFile = new File(serviceNameDir, serviceName + ".json");
-        ConfigVo configVo = mapper.readValue(configFile, ConfigVo.class);
-        int simulateTime = 300; //妯℃嫙鏃堕棿锛岄粯璁や负5min锛屽嵆300s
-        int intervalTime = 60; //姣忓抚鐨勯棿闅旀椂闂达紝榛樿涓�60s,60s鐢熸垚涓�甯�
-        configVo.getRaingage().set(0, newDatFile.getAbsolutePath()); //raingage file
-        ResultVo result = configVo.getResult();
-        Integer oldDuration = configVo.getDuration();
-//        result.setSave_start(oldDuration); //璧峰鏃堕棿瑕佸湪涓婃鏃堕棿鐨勫熀纭�涓婂紑濮�
-        configVo.setDuration(oldDuration + simulateTime); //鍥哄畾涓�5min
-        result.setSave_interval(intervalTime);
-        result.setSave_frames(result.getSave_frames() + (simulateTime / intervalTime)); //淇濈暀5甯э紝鍦ㄥ師鏉ョ殑鍩虹涓婂鍔�5甯�
-//        String newZarrPath = serviceNameDir + File.separator + "result_" + currentTime + ".zarr";
-        String newZarrPath = serviceNameDir + File.separator + "result.zarr";
-        result.setSave_name(newZarrPath);
-        File newConfigFile = new File(serviceNameDir, currentTime + ".json");
-        mapper.writeValue(newConfigFile, configVo);
-        return newConfigFile;
-    }
-
-    private File generateNewRainfallFile(RealTimeInput input, String[] values, File serviceNameDir, long currentTime) throws IOException {
-        String station = values[0];
-        double lon = Double.parseDouble(values[1]);
-        double lat = Double.parseDouble(values[2]);
-        String title = config.getRainfallTitle();
-        List<String> newLines = new ArrayList<>();
-        newLines.add(title);
-        List<RealTimeInput.RealTimeData> data = input.getData();
-        for (RealTimeInput.RealTimeData rd : data) {
-            LocalDateTime dateTime = rd.getDateTime();
-            int year = dateTime.getYear();
-            int month = dateTime.getMonthValue();
-            int day = dateTime.getDayOfMonth();
-            int hour = dateTime.getHour();
-            int minute = dateTime.getMinute();
-            double intensity = rd.getIntensity(); //淇濈暀鎸囧畾浣嶆暟灏忔暟
-            String l = String.format("%s %s %s %s %s %s %s %s %s",
-                    station, lon, lat, year, month, day, hour, minute, String.format("%.6f", intensity));
-            newLines.add(l);
-        }
-        File newDatFile = new File(serviceNameDir, "rainfall_" + currentTime + ".dat");
-        if (!newDatFile.exists()) newDatFile.createNewFile();
-        Files.write(newDatFile.toPath(), newLines, StandardOpenOption.TRUNCATE_EXISTING);
-        return newDatFile;
-    }
-
-    private static String[] readTheOldFirstLineRainfallValue(File serviceNameDir) throws IOException {
-        File srcRailfallFile = new File(serviceNameDir, "rainfall.dat");
-        List<String> lines = Files.readAllLines(srcRailfallFile.toPath());
-        String secondLine = lines.get(1);
-        return secondLine.split(" ");
-    }
+//    private static String[] readTheOldFirstLineRainfallValue(File serviceNameDir) throws IOException {
+//        File srcRailfallFile = new File(serviceNameDir, "rainfall.dat");
+//        List<String> lines = Files.readAllLines(srcRailfallFile.toPath());
+//        String secondLine = lines.get(1);
+//        return secondLine.split(" ");
+//    }
 }

--
Gitblit v1.9.3