From b6899cd6d1bafb1c349f1fbd190e6632183719f5 Mon Sep 17 00:00:00 2001 From: 13693261870 <252740454@qq.com> Date: 星期五, 01 十一月 2024 20:44:00 +0800 Subject: [PATCH] 11 --- src/main/java/com/se/simu/service/ResultService.java | 52 ++++++++++++++++++++++++++++++---------------------- 1 files changed, 30 insertions(+), 22 deletions(-) diff --git a/src/main/java/com/se/simu/service/ResultService.java b/src/main/java/com/se/simu/service/ResultService.java index 302c970..b7bd2dd 100644 --- a/src/main/java/com/se/simu/service/ResultService.java +++ b/src/main/java/com/se/simu/service/ResultService.java @@ -8,6 +8,7 @@ import com.se.simu.domain.dto.LayerDto; import com.se.simu.domain.dto.ResultDto; import com.se.simu.domain.po.DataPo; +import com.se.simu.domain.vo.BuildingDepthVo; import com.se.simu.helper.GdalHelper; import lombok.extern.slf4j.Slf4j; import org.gdal.gdal.Band; @@ -44,6 +45,8 @@ PropertiesConfig config; public final static double MAX_X_OFFSET = 0; + + private final static SimpleDateFormat SDF = new SimpleDateFormat("yyyy-MM-dd HH:mm"); public void process(DataPo data) throws Exception { String basePath = config.getInPath() + File.separator + data.getInPath() + File.separator; @@ -528,14 +531,10 @@ layer.getTerrain().setEpsg(null); String json = JSON.toJSONString(layer); - //String json = JSONUtil.toJsonPrettyStr(layer); + // String json = JSONUtil.toJsonPrettyStr(layer); String filePath = dto.getOutPath() + File.separator + "layer.json"; - FileWriter fw = new FileWriter(filePath); - BufferedWriter bw = new BufferedWriter(fw); - bw.write(json); - bw.close(); - fw.close(); + writeJson(filePath, json); } /** @@ -545,28 +544,37 @@ String rainGageFilePath = config.getInPath() + File.separator + dto.getServiceName() + File.separator + "RainGage.dat"; String filePath = dto.getOutPath() + File.separator + "rainfall.json"; - String line; - Map<String, Double> rainFallJsons = new LinkedHashMap<>(); - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm"); + Map<String, Double> map = new LinkedHashMap<>(); + FileReader fr = new FileReader(rainGageFilePath); + BufferedReader br = new BufferedReader(fr); - BufferedReader br = new BufferedReader(new FileReader(rainGageFilePath)); - // 澶勭悊绗竴琛屾暟鎹� - if ((line = br.readLine()) != null) { - while ((line = br.readLine()) != null) { - // 澶勭悊姣忎竴琛屾暟鎹� - String[] rainFall = line.split(" "); + String line = br.readLine(); + while ((line = br.readLine()) != null) { + String[] rainFall = line.split(" "); + if (rainFall.length < 7) continue; - if (rainFall.length < 7) continue; - - String sdt = rainFall[1] + "-" + rainFall[2] + "-" + rainFall[3] + " " + rainFall[4] + ":" + rainFall[5]; - BigDecimal num = new BigDecimal(rainFall[6]); - rainFallJsons.put("" + sdf.parse(sdt).getTime(), num.setScale(2, RoundingMode.HALF_UP).doubleValue()); - } + String sdt = rainFall[1] + "-" + rainFall[2] + "-" + rainFall[3] + " " + rainFall[4] + ":" + rainFall[5]; + BigDecimal num = new BigDecimal(rainFall[6]); + map.put("" + SDF.parse(sdt).getTime(), num.setScale(2, RoundingMode.HALF_UP).doubleValue()); } + br.close(); + fr.close(); + String json = JSON.toJSONString(map); + writeJson(filePath, json); + } + + private void copeBuildingDepthJson(ResultDto dto, List<BuildingDepthVo> list) throws IOException { + String json = JSON.toJSONString(list); + String filePath = dto.getOutPath() + File.separator + "building.json"; + + writeJson(filePath, json); + } + + private void writeJson(String filePath, String json) throws IOException { FileWriter fw = new FileWriter(filePath); BufferedWriter bw = new BufferedWriter(fw); - bw.write(JSON.toJSONString(rainFallJsons)); + bw.write(json); bw.close(); fw.close(); } -- Gitblit v1.9.3