吉安感知网项目-后端
linwei
2 days ago 51a551a7f8eae7654f973d45cd2fa2952774673d
drone-service/drone-gd/src/main/java/org/sxkj/gd/xingtu/JianXingtuApiService.java
@@ -1,5 +1,6 @@
package org.sxkj.gd.xingtu;
import com.alibaba.fastjson.JSON;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.redis.cache.BladeRedis;
@@ -110,7 +111,7 @@
    * @param param 请求参数
    * @return 接口响应
    */
   public R saveFlyTask(List<GdXingtuFlyTaskSaveDTO> param) {
   public R saveFlyTask(GdXingtuFlyTaskSaveDTO param) {
      String url = JianXingTuApiClient.getFlyTaskSaveUrl();
      return postWithAuthHeader(url, param);
   }
@@ -131,18 +132,28 @@
      try {
         HttpHeaders headers = new HttpHeaders();
         headers.set("authorization", token);
         log.info("请求外部接口: {} {}", url, body);
         log.info("请求外部接口: {} {}", url, JSON.toJSONString(body));
         HttpEntity<Object> entity = new HttpEntity<>(body, headers);
         ResponseEntity<R> response = restTemplate.exchange(url, HttpMethod.POST, entity, R.class);
         log.info("响应外部接口: {}", response);
         if (response.getStatusCode().is2xxSuccessful()) {
            R responseBody = response.getBody();
            if (responseBody != null) {
               // 检查接口内部返回的success状态
               if (!responseBody.isSuccess()) {
                  // 提取错误信息,优先使用msg字段
                  String errorMsg = responseBody.getMsg();
                  if (StringUtil.isBlank(errorMsg)) {
                     errorMsg = "接口调用失败";
                  }
                  log.warn("外部接口返回失败: {}", errorMsg);
                  return R.fail(errorMsg);
               }
               return responseBody;
            }
            return R.fail("接口返回为空");
         }
         return R.fail("请求外部接口失败");
         return R.fail("请求外部接口失败,HTTP状态码: " + response.getStatusCode());
      } catch (Exception e) {
         log.error("请求外部接口异常: ", e);
         return R.fail("请求外部接口异常: " + e.getMessage());