dcb
2025-06-25 024c9f73fce8ab5f94c3af0c237bcf102a547766
将实时模拟的帧数调整为可配置参数
已重命名1个文件
已修改2个文件
32 ■■■■■ 文件已修改
src/main/java/com/se/nsl/config/RealTimeSimulationConfig.java 13 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/se/nsl/service/RealTimeSimulationService.java 16 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/application-dev.yml 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/se/nsl/config/RealTimeSimulationConfig.java
ÎļþÃû´Ó src/main/java/com/se/nsl/config/GaugeServer.java ÐÞ¸Ä
@@ -4,11 +4,12 @@
import org.springframework.context.annotation.Configuration;
@Configuration
@ConfigurationProperties(prefix = "gauge-server")
public class GaugeServer {
@ConfigurationProperties(prefix = "realtime-simulate-config")
public class RealTimeSimulationConfig {
    private String url;
    private String token;
    private int realTimeInterval;
    private int requestOffsetMinutes; //雨量计请求间隔的时间,为了便于获取一个范围内雨量数据
    private double offsetDays;
@@ -28,6 +29,14 @@
        this.token = token;
    }
    public int getRealTimeInterval() {
        return realTimeInterval;
    }
    public void setRealTimeInterval(int realTimeInterval) {
        this.realTimeInterval = realTimeInterval;
    }
    public int getRequestOffsetMinutes() {
        return requestOffsetMinutes;
    }
src/main/java/com/se/nsl/service/RealTimeSimulationService.java
@@ -3,7 +3,7 @@
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.se.nsl.config.GaugeServer;
import com.se.nsl.config.RealTimeSimulationConfig;
import com.se.nsl.config.PropertiesConfig;
import com.se.nsl.domain.dto.*;
import com.se.nsl.domain.po.RainGauge;
@@ -47,7 +47,7 @@
    private final ObjectMapper mapper = new ObjectMapper();
    @Resource
    private GaugeServer gaugeServer;
    private RealTimeSimulationConfig rtsConfig;
    private static final long MILLIS_OF_ONE_DAY = 86400000;
    public String realTimeSimulate(Simu simu) throws IOException {
@@ -71,7 +71,7 @@
    }
    private long getCurrentTime() {
        double offsetDays = gaugeServer.getOffsetDays();
        double offsetDays = rtsConfig.getOffsetDays();
        long millis = (long) (offsetDays * MILLIS_OF_ONE_DAY);
        return System.currentTimeMillis() - millis;
    }
@@ -186,7 +186,7 @@
            configVo.setStation(stationFile.getAbsolutePath());
        }
        int realTimeSimulateTime = 300; //模拟时间,默认为5min,即300s
        int realTimeInterval = 60; //每帧的间隔时间,默认为60s,60s生成一帧
        int realTimeInterval = rtsConfig.getRealTimeInterval(); //每帧的间隔时间
        List<String> rainGauge = new ArrayList<>();
        rainGauge.add(newDatFile.getAbsolutePath());//raingage file
        rainGauge.add("mm/min");
@@ -211,7 +211,7 @@
            configVo.setStation(stationFile.getAbsolutePath());
        }
        int realTimeSimulateTime = 300; //模拟时间,默认为5min,即300s
        int realTimeInterval = 60; //每帧的间隔时间,默认为60s,60s生成一帧
        int realTimeInterval = rtsConfig.getRealTimeInterval(); //每帧的间隔时间
        configVo.getRaingage().set(0, newDatFile.getAbsolutePath()); //raingage file
        ResultVo result = configVo.getResult();
        Integer lastFrames = result.getLastFrames();
@@ -259,7 +259,7 @@
        int hour = dateTime.getHour();
        int minute = dateTime.getMinute();
        String id = gauge.getId();
        long someMinutesAgo = currentTime - TimeUnit.MINUTES.toMillis(gaugeServer.getRequestOffsetMinutes());
        long someMinutesAgo = currentTime - TimeUnit.MINUTES.toMillis(rtsConfig.getRequestOffsetMinutes());
        String startTime = TimeFormatUtil.formatTime(someMinutesAgo, YYYY_MM_DD_HH_MM_SS);
        String endTime = TimeFormatUtil.formatTime(currentTime, YYYY_MM_DD_HH_MM_SS);
        double intensity = getIntensityByDeviceId(id, startTime, endTime); //保留指定位数小数
@@ -276,8 +276,8 @@
        filterObject.setDeviceCode(deviceId);
        filterObject.setSendTimeList(Arrays.asList(startTime, endTime));
        input.setFilterObject(filterObject);
        String url = gaugeServer.getUrl();
        String token = gaugeServer.getToken();
        String url = rtsConfig.getUrl();
        String token = rtsConfig.getToken();
        ResponseEntity<String> post = HttpRequestUtil.post(url, input, String.class, token);
        String body = post.getBody();
        JsonNode jsonNode = mapper.readTree(body);
src/main/resources/application-dev.yml
@@ -170,9 +170,10 @@
  tifPath: D:\other\simu\uwsolver\5ca43c87cd8e48c5a9c5399a5da46dbc\tongzhou_raster_4548_1m_clip_river_fill.tif
  #tif中的高程文件名要含有dem,土地利用要含有landuse,站点要含有station,不限制大小写,文字尽量用英文字母表达
  keyDitch: D:\other\simu\CudaUWSolver-2.2.1\KeyDitch
gauge-server:
realtime-simulate-config:
  url: http://192.168.56.106:9522/ylclyPacket/getData
  token: YjhhYjAwOWFhMjk1MTM1ZDA0NGU3ZWZlMDQzMzUzZDE1MGJmY2Q4ZWEyYjliNjQzZjcwMjhlNDY0ZjAxNWZjOTZmNzMwYmNmZDA2YmVmNTIzNjU0ZDgzODRjYTUxYTM1
  realTimeInterval: 5
  #请求雨量计数据时,时间范围相差多少分钟
  requestOffsetMinutes: 10
  #往前偏移多少天,为了方便实时模拟以前的降雨情况,设置为0表示,从当前时间开始计算