| | |
| | | HttpHeaders headers = new HttpHeaders(); |
| | | headers.setContentType(MediaType.APPLICATION_JSON); |
| | | HttpEntity<String> entity = new HttpEntity<>(reqBody, headers); |
| | | log.info("RCS站点轮询请求 POST /cv/station/getError url={} body={}", url, trimForLog(reqBody)); |
| | | ResponseEntity<String> resp = restTemplate.exchange( |
| | | url, HttpMethod.POST, entity, String.class); |
| | | String respBody = resp.getBody(); |
| | | log.info("RCS站点轮询响应 POST /cv/station/getError body={}", trimForLog(respBody)); |
| | | if (!shouldSkipInfoLogErrorPoll(respBody)) { |
| | | log.info("RCS站点轮询请求 POST /cv/station/getError url={} body={}", url, trimForLog(reqBody)); |
| | | log.info("RCS站点轮询响应 POST /cv/station/getError body={}", trimForLog(respBody)); |
| | | } |
| | | return respBody; |
| | | } |
| | | log.info("RCS站点轮询请求 GET /cv/station/getError url={}", url); |
| | | String raw = restTemplate.getForObject(url, String.class); |
| | | log.info("RCS站点轮询响应 GET /cv/station/getError body={}", trimForLog(raw)); |
| | | if (!shouldSkipInfoLogErrorPoll(raw)) { |
| | | log.info("RCS站点轮询请求 GET /cv/station/getError url={}", url); |
| | | log.info("RCS站点轮询响应 GET /cv/station/getError body={}", trimForLog(raw)); |
| | | } |
| | | return raw; |
| | | } |
| | | |
| | |
| | | HttpHeaders headers = new HttpHeaders(); |
| | | headers.setContentType(MediaType.APPLICATION_JSON); |
| | | HttpEntity<String> entity = new HttpEntity<>(reqBody, headers); |
| | | // log.info("RCS站点轮询请求 GET /cv/station/getTaskNo url={}", url); |
| | | log.info("RCS站点轮询请求 POST /cv/station/getTaskNo url={} body={}", url, trimForLog(reqBody)); |
| | | ResponseEntity<String> resp = restTemplate.exchange( |
| | | url, HttpMethod.POST, entity, String.class); |
| | | String respBody = resp.getBody(); |
| | | // log.info("RCS站点轮询响应 GET /cv/station/getTaskNo body={}", trimForLog(raw)); |
| | | log.info("RCS站点轮询响应 POST /cv/station/getTaskNo body={}", trimForLog(respBody)); |
| | | if (!shouldSkipInfoLogTaskNoPoll(respBody)) { |
| | | log.info("RCS站点轮询请求 POST /cv/station/getTaskNo url={} body={}", url, trimForLog(reqBody)); |
| | | log.info("RCS站点轮询响应 POST /cv/station/getTaskNo body={}", trimForLog(respBody)); |
| | | } |
| | | return respBody; |
| | | } |
| | | log.info("RCS站点轮询请求 GET /cv/station/getTaskNo url={}", url); |
| | | String raw = restTemplate.getForObject(url, String.class); |
| | | log.info("RCS站点轮询响应 GET /cv/station/getTaskNo body={}", trimForLog(raw)); |
| | | if (!shouldSkipInfoLogTaskNoPoll(raw)) { |
| | | log.info("RCS站点轮询请求 GET /cv/station/getTaskNo url={}", url); |
| | | log.info("RCS站点轮询响应 GET /cv/station/getTaskNo body={}", trimForLog(raw)); |
| | | } |
| | | return raw; |
| | | } |
| | | |
| | | /** code=200 且无异常明细(如 data:[])时不打 INFO,避免刷屏 */ |
| | | private boolean shouldSkipInfoLogErrorPoll(String respBody) { |
| | | if (!StringUtils.hasText(respBody)) { |
| | | return true; |
| | | } |
| | | try { |
| | | JsonNode root = objectMapper.readTree(respBody.trim()); |
| | | if (!httpSuccess(root)) { |
| | | return false; |
| | | } |
| | | JsonNode data = root.get("data"); |
| | | if (data == null || data.isNull()) { |
| | | return true; |
| | | } |
| | | return data.isArray() && data.size() == 0; |
| | | } catch (Exception e) { |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | /** code=200 且无任务号等非空业务数据时不打 INFO */ |
| | | private boolean shouldSkipInfoLogTaskNoPoll(String respBody) { |
| | | if (!StringUtils.hasText(respBody)) { |
| | | return true; |
| | | } |
| | | try { |
| | | JsonNode root = objectMapper.readTree(respBody.trim()); |
| | | if (!httpSuccess(root)) { |
| | | return false; |
| | | } |
| | | if (StringUtils.hasText(extractTaskNo(root))) { |
| | | return false; |
| | | } |
| | | JsonNode data = root.get("data"); |
| | | if (data != null && !data.isNull()) { |
| | | if (data.isArray()) { |
| | | return data.size() == 0; |
| | | } |
| | | return false; |
| | | } |
| | | return true; |
| | | } catch (Exception e) { |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | private ObjectNode createStationBody(String stationId) { |
| | | ObjectNode body = objectMapper.createObjectNode(); |
| | | if (StringUtils.hasText(stationId)) { |