| | |
| | | |
| | | @PostConstruct |
| | | public void init() { |
| | | int timeoutSeconds = conveyorProperties.getTimeout() / 1000; |
| | | this.http = HttpGo.builder() |
| | | .connectTimeout(Duration.ofSeconds(8)) |
| | | .readTimeout(Duration.ofSeconds(15)) |
| | | .connectTimeout(Duration.ofSeconds(timeoutSeconds)) |
| | | .readTimeout(Duration.ofSeconds(timeoutSeconds)) |
| | | // .defaultHeader("User-Agent", "HttpGo/1.0") |
| | | // .trustAllSsl(true) // ONLY if you really need it (self-signed internal) |
| | | // .trustAllSsl(true) // ONLY if you really need it (self-signed internal) |
| | | .build(); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public boolean allowAgvWork(Sta sta, Task task, Segment seg, StaReserveType type) { |
| | | final String staNo = sta.getStaNo(); |
| | | |
| | | // url |
| | | String url = this.buildUrl("/station/query"); |
| | | String url = this.http.buildUrl(conveyorProperties.getHost(), conveyorProperties.getPort(), "/cv/station/query"); |
| | | // headers |
| | | Map<String, String> headers = new HashMap<>(); |
| | | // params |
| | |
| | | return true; |
| | | } |
| | | |
| | | private String buildUrl(String path) { |
| | | String host = conveyorProperties.getHost(); |
| | | Integer port = conveyorProperties.getPort(); |
| | | |
| | | String p = (path == null) ? "" : (path.startsWith("/") ? path : ("/" + path)); |
| | | return "http://" + host + ":" + port + p; |
| | | } |
| | | |
| | | private HttpResult<List<ConveyorStaDto>> postForResult(String url |
| | | , Map<String, String> headers, Map<String, Object> params) throws Exception { |
| | | private HttpResult<List<ConveyorStaDto>> postForResult(String url, Map<String, String> headers, Map<String, Object> params) throws Exception { |
| | | String json = JSON.toJSONString(params); |
| | | HttpGo.HttpResponse response = this.http.postJson(url, headers, json); |
| | | |