SendMawbBasf.java 3.21 KB
package com.erry.iclear.dateInterface;

import com.arronlong.httpclientutil.HttpClientUtil;
import com.arronlong.httpclientutil.builder.HCB;
import com.arronlong.httpclientutil.common.HttpConfig;
import com.arronlong.httpclientutil.common.HttpHeader;
import com.arronlong.httpclientutil.common.SSLs;
import com.erry.iclear.dateInterface.util.SHA256Util;
import org.apache.http.Header;

import java.util.Date;

/**
 *  C类申报数据落地接口
 *  fedex
 *  2022年4月14日17:55:55
 */
public class SendMawbBasf {
    public static String url = "https://40.73.78.157:8780";
    //C类申报数据落地接口
    public static String path = "/basf/sendMawbBasf";
    //时间戳
    public static String timeStamp = "1649839249891";
    //APPID
    public static String appId = "BASF";
    //APPKEY
    public static String appKey = "iClearExportC";
    //需要申请
    public static String security = "6db193cb4165a71b";

    public static void main(String[] args) throws Exception{
        sendMawbBasf();
    }

    /**
     * C类申报数据落地接口
     */
    public static void sendMawbBasf() throws Exception{
        //申报数据:consignmentCode 运单号需要修改
        String json ="{\"consignmentCode\":\"271002102051\",\"consignmentId\":164535620,\"consType\":\"C\",\"sender\":\"巴斯夫护理化学品(上海)有限公司\",\"shipperCustomsCode\":\"3119920047\",\"shipperSCC\":\"91310000607239894U\",\"operateUnitName\":\"巴斯夫护理化学品(上海)有限公司\",\"operateUnitCode\":\"3119920047\",\"operateSCC\":\"91310000607239894U\",\"consignmentList\":[{\"consignmentDetailId\":83010676,\"skuCode\":\"2917341090\",\"skuName\":\"邻苯二甲酸二丁酯\",\"model\":\"品名:邻苯二甲酸二丁酯 |品牌类型:0|出口享惠情况:0|成分含量:100%  邻苯二甲酸二丁酯|用途:化学分析用试剂,实验用途|GTIN:|CAS:|其他[非必报要素,请根据实际情况填报]:|\",\"knockdownNumber\":1,\"knockdownUnit\":\"035\",\"qtyLegalFirst\":1,\"unitLegalFirst\":\"035\",\"qtyLegalSecond\":\"1.0000\",\"unitLegalSecond\":\"\",\"declaredAmount\":10,\"currency\":\"USD\",\"declaredWeight\":1}]}";

        String token = SHA256Util.getSHA256String(SendMawbBasf.appId + SendMawbBasf.appKey + SendMawbBasf.security + SendMawbBasf.timeStamp);
        System.out.println(token);
        //消息头
        Header[] headers = HttpHeader.custom()
                .other("Content-Type", "application/json")
                .other("Appid", SendMawbBasf.appId)
                .other("appKey", SendMawbBasf.appKey)
                .other("TimeStamp", SendMawbBasf.timeStamp)
                .other("token", token)
                .build();
        //客户端配置
        HCB hcb = HCB.custom()
                .timeout(20000)
                .pool(100, 10)
                .sslpv(SSLs.SSLProtocolVersion.TLSv1_2)
                .ssl()
                .retry(3);
        //URL
        String url = SendMawbBasf.url + SendMawbBasf.path;
        //HTTP请求
        HttpConfig config = HttpConfig.custom()
                .headers(headers)
                .url(url)
                .encoding("utf-8")
                .client(hcb.build())
                .json(json);
        System.out.println(HttpClientUtil.post(config));
    }
}