| | |
| | | import java.awt.*; |
| | | import java.awt.image.BufferedImage; |
| | | import java.io.*; |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | import java.util.List; |
| | | |
| | |
| | | copeWater(dto, layer); |
| | | copeFlow(dto, layer); |
| | | copeLayerJson(dto, layer); |
| | | copeRainFallJson(dto, layer); |
| | | } finally { |
| | | File dir = new File(dto.getTemp()); |
| | | if (dir.exists()) { |
| | |
| | | bw.close(); |
| | | fw.close(); |
| | | } |
| | | |
| | | /** |
| | | * 处理降水曲线文件曲线图 |
| | | */ |
| | | public void copeRainFallJson(ResultDto dto, LayerDto layer) throws IOException, ParseException { |
| | | String rainGageFilePath = config.getInPath() + File.separator + dto.getServiceName() + File.separator + "RainGage.dat"; |
| | | String filePath = dto.getOutPath() + File.separator + "rainfall.json"; |
| | | |
| | | String line; |
| | | Map<Long,Double> rainFallJsons = new LinkedHashMap<>(); |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm"); |
| | | |
| | | BufferedReader br = new BufferedReader(new FileReader(rainGageFilePath)); |
| | | //处理第一行数据 |
| | | if ((line = br.readLine()) != null) { |
| | | while ((line = br.readLine()) != null) { |
| | | // 处理每一行数据 |
| | | String[] rainFall = line.split(" "); |
| | | |
| | | 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()/1000,num.setScale(2, RoundingMode.HALF_UP).doubleValue()); |
| | | } |
| | | } |
| | | |
| | | FileWriter fw = new FileWriter(filePath); |
| | | BufferedWriter bw = new BufferedWriter(fw); |
| | | bw.write(JSON.toJSONString(rainFallJsons)); |
| | | bw.close(); |
| | | fw.close(); |
| | | } |
| | | } |