| | |
| | | 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); |