SendMawbTest.java 3.76 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;

/**
 *  D类申报的数据落地接口示例代码
 *  fedex
 *  2022年4月14日16:34:18
 */
public class SendMawbTest {
    public static String url = "https://40.73.78.157:8780";
    //D类申报的数据落地接口
    public static String sendMawb = "/customs/sendMawb";
    //时间戳
    public static String timeStamp = "1649839249891";
    //APPID
    public static String appId = "IDE";
    //APPKEY
    public static String appKey = "iClearExport";
    //需要申请
    public static String security = "b92131f03f19a348";

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

    /**
     * D类申报的数据落地接口
     */
    public static void sendMawb() throws Exception{
        //申报数据:billNo 提单号需要修改
        String masbJson ="{\"ieFlag\":\"E\",\"type\":\"EX\",\"agentCode\":\"1111980005\",\"agentName\":\"联邦快递(中国)有限公司\",\"billNo\":\"202204141\",\"contrNo\":\"3006622200\",\"customMaster\":\"0208\",\"cutMode\":\"601\",\"declTrnRel\":\"0\",\"distinatePort\":\"DEU000\",\"ediId\":\"001\",\"feeCurr\":\"EUR\",\"feeMark\":\"3\",\"feeRate\":110.9,\"grossWet\":4.6,\"iePort\":\"0101\",\"insurCurr\":\"EUR\",\"insurMark\":\"3\",\"insurRate\":0.74,\"netWt\":32,\"ownerCode\":\"3118962277\",\"ownerName\":\"测试核销单位\",\"packNo\":1,\"tradeCountry\":\"USA\",\"tradeMode\":\"110\",\"tradeCode\":\"32099616DM\",\"trafMode\":\"5\",\"tradeName\":\"测试发件人\",\"transMode\":\"1\",\"wrapType\":\"23\",\"tradeCodeScc\":\"A74125896321456987\",\"ownerCodeScc\":\"913100007421296207\",\"tradeAreaCode\":\"DEU\",\"entyPortCode\":\"310302\",\"goodsPlace\":\"\",\"declareName\":\"Jimmy shen\",\"overseasConsigneeEname\":\"PRYSMIAN KABEL UND SYSTEME GMBH\",\"mawbDetailList\":[{\"detailId\":\"204\",\"classMark\":\"\",\"codeTS\":\"8504409999\",\"declPrice\":3365,\"declTotal\":3365,\"dutyMode\":\"1\",\"exgNo\":\"\",\"exgVersion\":\"\",\"firstUnit\":\"007\",\"firstQty\":1,\"originCountry\":\"CHN\",\"secondUnit\":\"035\",\"secondQty\":1,\"tradeCurr\":\"EUR\",\"useTo\":\"03\",\"destinationCountry\":\"DEU\",\"ciqCode\":\"\",\"destCode\":\"110102\",\"districtCode\":\"44079\",\"gno\":1,\"gname\":\"变频调速装置\",\"gmodel\":\"4|0|控制电机用|240KW|西门子/SIEMENS|6RA8081-6GV62-0AA0|||\",\"gqty\":1,\"gunit\":\"007\"}]}";
        String token = SHA256Util.getSHA256String(SendMawbTest.appId + SendMawbTest.appKey + SendMawbTest.security + SendMawbTest.timeStamp);
        //消息头
        Header[] headers = HttpHeader.custom()
                .other("Content-Type", "application/json")
                .other("Appid", SendMawbTest.appId)
                .other("appKey", SendMawbTest.appKey)
                .other("TimeStamp", SendMawbTest.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 = SendMawbTest.url + SendMawbTest.sendMawb;
        //HTTP请求
        HttpConfig config = HttpConfig.custom()
                .headers(headers)
                .url(url)
                .encoding("utf-8")
                .client(hcb.build())
                .json(masbJson);
        System.out.println(HttpClientUtil.post(config));
    }
}