Browse Source

大家报价的优化

dongxin 1 year ago
parent
commit
33b9b423be

+ 1 - 1
tenant/insurance/quotation-chengtai/src/main/java/com/jzg/quotation/chengtai/api/entity/ChengTaiApiConfigureParameters.java

@@ -17,6 +17,6 @@ public class ChengTaiApiConfigureParameters implements ConfigureParameters {
      * 诚泰业务员
      */
     @JsonProperty("UserId")
-    private String UserId;
+    private String userId;
 
 }

+ 21 - 4
tenant/insurance/quotation-dajia/src/main/java/com/jzg/quotation/dajia/api/compoment/DaJiaApiRequestComponent.java

@@ -17,13 +17,16 @@ import lombok.extern.slf4j.Slf4j;
 import org.springframework.http.*;
 import org.springframework.stereotype.Component;
 import org.springframework.util.ObjectUtils;
+import org.springframework.web.client.RestTemplate;
+import reactor.core.publisher.Mono;
 
 @Slf4j
 @Component
 @RequiredArgsConstructor
 public class DaJiaApiRequestComponent {
 
-    private final RequestComponent requestComponent;
+
+    private final RestTemplate restTemplate;
 
     private final DaJiaApiProperties daJiaApiProperties;
 
@@ -40,12 +43,26 @@ public class DaJiaApiRequestComponent {
                     + InsuranceEnum.DJPC.getName()+"}\n---------> 请求参数:{"
                     +JSON.toJSONString(requestBody)+"}");
             String encrypt = AESEncrypt.encrypt(JSON.toJSONString(requestBody), daJiaApiProperties.getEncryptKey());
-            ResponseEntity<B> bResponseEntity = requestComponent.objectPost(url, encrypt, responseType, httpHeaders);
-            return bResponseEntity.getBody();
+            System.out.println(encrypt);
+            HttpEntity<String> httpEntity = new HttpEntity<>(encrypt, httpHeaders);
+            ResponseEntity<String> response = restTemplate.exchange(url, HttpMethod.POST,  httpEntity, String.class);
+            String body = response.getBody();
+            System.out.println("\n\n---------> 响应参数:{"+body+"}");
+            B res = JSON.parseObject(body).toJavaObject(responseType);
+            if(ObjectUtils.isEmpty(body)){
+                throw new SystemException("请求失败");
+            }
+            //统一处理错误
+            JSONObject resultObj = JSON.parseObject(body);
+            String code = resultObj.getString("code");
+            if(!"2000".equals(res.getStatus())) {
+                throw new SystemException(resultObj.getString("message"));
+            }
+            return res;
         }catch (Exception e){
+            System.out.println(e.getMessage());
             throw new SystemException(e.getMessage());
         }
-
     }
 
     public <T, B extends DaJiaBaseResponse> B requestRequestUrl(RequestUrl requestUrl, T requestBody, Class<B> responseType) {

+ 0 - 2
tenant/insurance/quotation-dajia/src/main/java/com/jzg/quotation/dajia/api/entity/DaJiaApiConfigureParameters.java

@@ -13,8 +13,6 @@ import java.io.Serial;
 @Data
 public class DaJiaApiConfigureParameters implements ConfigureParameters {
 
-    @Serial
-    private static final long serialVersionUID = 01212276026647077640261L;
 
     /**
      *