Pārlūkot izejas kodu

小图分页公共查询

zhangchenm 1 dienu atpakaļ
vecāks
revīzija
1d40942d56

+ 10 - 0
trade-service/src/main/java/com/trade/service/thirdparty/xiaotu/configuration/XiaotuConfiguration.java

@@ -22,6 +22,8 @@ public class XiaotuConfiguration {
     private String tsslcxUrl;
     // 海关税则查询接口
     private String hgszcxUrl;
+    // 报关单查询接口
+    private String customsDeclarationUrl;
 
     public String getGatewayAppKey() {
         return gatewayAppKey;
@@ -94,4 +96,12 @@ public class XiaotuConfiguration {
     public void setHgszcxUrl(String hgszcxUrl) {
         this.hgszcxUrl = hgszcxUrl;
     }
+
+    public String getCustomsDeclarationUrl() {
+        return customsDeclarationUrl;
+    }
+
+    public void setCustomsDeclarationUrl(String customsDeclarationUrl) {
+        this.customsDeclarationUrl = customsDeclarationUrl;
+    }
 }

+ 11 - 0
trade-service/src/main/java/com/trade/service/thirdparty/xiaotu/dto/CommonQueryRequest.java

@@ -0,0 +1,11 @@
+package com.trade.service.thirdparty.xiaotu.dto;
+
+import lombok.Data;
+
+@Data
+public class CommonQueryRequest {
+
+    private int page; // 当前页数
+    private int pageSize; // 每页条数 最大值 2000
+    private String url;
+}

+ 16 - 0
trade-service/src/main/java/com/trade/service/thirdparty/xiaotu/dto/CommonQueryResponse.java

@@ -0,0 +1,16 @@
+package com.trade.service.thirdparty.xiaotu.dto;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import java.util.List;
+
+@Getter
+@Setter
+public class CommonQueryResponse<T extends CommonResultRows> {
+
+    private int page;
+    private int pageSize;
+    private int rowCount;
+    private List<T> rows;
+}

+ 4 - 0
trade-service/src/main/java/com/trade/service/thirdparty/xiaotu/dto/CommonResultRows.java

@@ -0,0 +1,4 @@
+package com.trade.service.thirdparty.xiaotu.dto;
+
+public class CommonResultRows {
+}

+ 35 - 0
trade-service/src/main/java/com/trade/service/thirdparty/xiaotu/dto/CustomsDeclarationRequest.java

@@ -0,0 +1,35 @@
+package com.trade.service.thirdparty.xiaotu.dto;
+
+import cn.hutool.core.collection.CollectionUtil;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.util.List;
+
+/**
+ * 报关单信息查询请求参数
+ */
+@EqualsAndHashCode(callSuper = false)
+@Data
+public class CustomsDeclarationRequest extends CommonQueryRequest {
+
+    private String ckrqQ; // 出口日期起 yyyy-MM-dd
+    private String ckrqZ; // 出口日期止 yyyy-MM-dd
+    private String sbrqQ; // 出口申报日期起 yyyy-MM-dd
+    private String sbrqZ; // 出口申报日期止 yyyy-MM-dd
+    private String rkrqQ; // 入库日期起 yyyy-MM-dd
+    private String rkrqZ; // 入库日期止 yyyy-MM-dd
+    private String bgdjgzt; // 报关单结关状态 YJG:已结关 WJG:未结关 不传:全部
+    private List<String> ckbgdhs; // 报关单号集合 数组
+    private List<String> ckhths; // 合同号集合
+    private List<String> tydhs; // 提运单号集合
+    private List<String> jzxhs; // 集装箱号集合
+
+
+    /*public void check() {
+        if ((ckrqQ == null && ckrqZ == null) || (sbrqQ == null && sbrqZ == null) || (rkrqQ == null && rkrqZ == null)
+                || CollectionUtil.isEmpty(ckbgdhs)) {
+            throw new IllegalArgumentException("出口日期、申报日期、入库日期、21位报关单号条件至少要传入一个");
+        }
+    }*/
+}

+ 33 - 0
trade-service/src/main/java/com/trade/service/thirdparty/xiaotu/dto/CustomsDeclarationResponse.java

@@ -0,0 +1,33 @@
+package com.trade.service.thirdparty.xiaotu.dto;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import java.math.BigDecimal;
+
+/**
+ * 报关单信息查询响应对象
+ */
+@Getter
+@Setter
+public class CustomsDeclarationResponse extends CommonResultRows {
+
+    private String xh4; // 项号
+    private String ckbgdh; // 出口报关单号
+    private String hgqyDm; // 海关企业代码
+    private String ckrq1; // 出口日期
+    private String sbhggqkaDm; // 申报海关关区(口岸)代码
+    private String sbhggqkajc; // 申报海关关区(口岸)简称
+    private BigDecimal yfje; // 运费金额
+    private String yfhghbzmDm; // 运费海关货币字母代码
+    private BigDecimal bfje; // 保费金额
+    private String bfhghbzmDm; // 保费海关货币字母代码
+    private BigDecimal zfje1; // 杂费金额
+    private String zfhghbzmDm; // 杂费海关货币字母代码
+    private Integer js1; // 件数
+    private Integer mz2;// 毛重(千克)
+    private Integer jz;// 净重(千克)
+    private String hgckhwbgdsbrq;// 海关出口货物报关单申报日期
+    private String sbdwmc;// 申报单位名称
+    private String jzxh;// 集装箱号
+}

+ 31 - 3
trade-service/src/main/java/com/trade/service/thirdparty/xiaotu/service/XiaotuRequestService.java

@@ -2,6 +2,8 @@ package com.trade.service.thirdparty.xiaotu.service;
 
 import com.trade.service.thirdparty.xiaotu.dto.*;
 
+import java.util.List;
+
 public interface XiaotuRequestService {
 
     /**
@@ -14,7 +16,7 @@ public interface XiaotuRequestService {
 
     /**
      * 用户信息修改
-     * 
+     *
      * @param request
      * @return
      */
@@ -30,7 +32,7 @@ public interface XiaotuRequestService {
 
     /**
      * 退税税率查询接口
-     * 
+     *
      * @param commodityRequest
      * @param businessCommonRequest
      * @return CommodityResponse
@@ -40,11 +42,37 @@ public interface XiaotuRequestService {
 
     /**
      * 海关税则查询接口
-     * 
+     *
      * @param spid 商品id
      * @param businessCommonRequest
      * @return CommodityCustomsTariffRespose
      */
     CommodityCustomsTariffRespose commodityCustomsTariffInquiry(String spid,
             BusinessCommonRequest businessCommonRequest);
+
+    /**
+     * 小图通用查询接口 - 带分页
+     *
+     * @param request 请求参数
+     * @param <T> 返回类型
+     * @return CommonQueryResponse<T>
+     */
+    <T extends CommonResultRows> CommonQueryResponse<T> queryCommonResponse(CommonQueryRequest request);
+
+    /**
+     * 小图通用查询接口 - 仅返回rows
+     *
+     * @param request 请求参数
+     * @param <T> 返回类型
+     * @return List<T>
+     */
+    <T extends CommonResultRows> List<T> queryCommonResponseRows(CommonQueryRequest request);
+
+    /**
+     * 报关单查询接口
+     * 
+     * @param request 报关单查询请求参数
+     * @return List<CustomsDeclarationResponse> 报关单查询结果
+     */
+    List<CustomsDeclarationResponse> customsDeclarationInquiry(CustomsDeclarationRequest request);
 }

+ 40 - 0
trade-service/src/main/java/com/trade/service/thirdparty/xiaotu/service/impl/XiaotuRequestServiceImpl.java

@@ -3,6 +3,7 @@ package com.trade.service.thirdparty.xiaotu.service.impl;
 import cn.hutool.core.util.StrUtil;
 import com.alibaba.fastjson2.JSON;
 import com.alibaba.fastjson2.JSONObject;
+import com.alibaba.fastjson2.TypeReference;
 import com.trade.common.constant.CacheConstants;
 import com.trade.common.redis.RedisCache;
 import com.trade.common.utils.http.HttpClientUtils;
@@ -17,6 +18,7 @@ import org.slf4j.LoggerFactory;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
+import java.util.List;
 import java.util.concurrent.TimeUnit;
 
 @Service
@@ -139,4 +141,42 @@ public class XiaotuRequestServiceImpl implements XiaotuRequestService {
         }
         return commonResponse.getBody();
     }
+
+    /**
+     * 小图通用查询接口 - 带分页
+     *
+     * @param request 请求参数
+     * @param <T> 返回类型
+     * @return List<T>
+     */
+    public <T extends CommonResultRows> CommonQueryResponse<T> queryCommonResponse(CommonQueryRequest request) {
+        String resp = HttpClientUtils
+                .post(HttpConfig.custom().headers(getCommonHeader().contentType(CONTENT_TYPE_JSON).build())
+                        .json(JSON.toJSONString(request)).url(request.getUrl()));
+        CommonResponse<?> commonResponse = JSON.parseObject(resp, CommonResponse.class);
+        logger.info("查询小图数据,req={},resp={}", request, resp);
+        if (commonResponse == null || !commonResponse.isSuccess()) {
+            throw new RuntimeException("查询小图数据失败");
+        }
+        return JSON.parseObject((String) commonResponse.getBody(), new TypeReference<CommonQueryResponse<T>>() {
+        });
+    }
+
+    /**
+     * 小图通用查询接口 - 仅返回rows
+     * 
+     * @param request 请求参数
+     * @param <T> 返回类型
+     * @return List<T>
+     */
+    public <T extends CommonResultRows> List<T> queryCommonResponseRows(CommonQueryRequest request) {
+        CommonQueryResponse<T> commonQueryResponse = queryCommonResponse(request);
+        return commonQueryResponse.getRows();
+    }
+
+    @Override
+    public List<CustomsDeclarationResponse> customsDeclarationInquiry(CustomsDeclarationRequest request) {
+        request.setUrl(xiaotuConfiguration.getCustomsDeclarationUrl());
+        return queryCommonResponseRows(request);
+    }
 }