| | |
| | | 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; |
| | |
| | | |
| | | 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 { |
| | |
| | | } |
| | | |
| | | private long getCurrentTime() { |
| | | double offsetDays = gaugeServer.getOffsetDays(); |
| | | double offsetDays = rtsConfig.getOffsetDays(); |
| | | long millis = (long) (offsetDays * MILLIS_OF_ONE_DAY); |
| | | return System.currentTimeMillis() - millis; |
| | | } |
| | |
| | | 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"); |
| | |
| | | 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(); |
| | |
| | | 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); //保留指定位数小数 |
| | |
| | | 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); |