liurunyu
2024-12-05 267e622c876bea09b61af34fc93cd08b022aa423
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/rtuMw/Web2RtuMw.java
@@ -91,12 +91,18 @@
        String url = UriComponentsBuilder.fromUriString(toMwUrl)
                .build()
                .toUriString();
        HttpHeaders headers = new HttpHeaders();
        HttpEntity<?> httpEntity = new HttpEntity<>(headers);
        //UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(url)
        //        .queryParam("test", test);
        UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(url) ;
        ResponseEntity<BaseResponse> response = null;
        try {
            // 通过Post方式调用接口
            response = restTemplate.exchange(url, HttpMethod.GET, httpEntity, BaseResponse.class);
            // 通过Get方式调用接口
            response = restTemplate.exchange(builder.toUriString(),
                    HttpMethod.GET,
                    new HttpEntity<>(new HttpHeaders()),
                    BaseResponse.class);
        } catch (Exception e) {
            e.printStackTrace();
            return BaseResponseUtils.buildError("后端系统出错,中间件调用异常");