欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

SpringBoot實(shí)現(xiàn)阿里云快遞物流查詢的示例代碼

 更新時(shí)間:2021年10月29日 09:41:14   作者:鄭清  
本文將基于springboot實(shí)現(xiàn)快遞物流查詢,物流信息的獲取通過阿里云第三方實(shí)現(xiàn),具有一定的參考價(jià)值,感興趣的可以了解一下

一、前言

本文將基于springboot2.4.0實(shí)現(xiàn)快遞物流查詢,物流信息的獲取通過阿里云第三方實(shí)現(xiàn)

可參考: https://market.aliyun.com/products/57124001/cmapi022273.html?spm=5176.730005.productlist.d_cmapi022273.e8357d36FVX3Eu&innerSource=search#sku=yuncode1627300000

在這里插入圖片描述

快遞查詢API,快遞識(shí)別單號(hào),快遞接口可查詢上百家快遞公司及物流快遞信息包括:順豐、申通、圓通、韻達(dá)、中通、匯通、EMS、天天、國(guó)通、德邦、宅急送等幾百家快遞物流公司單號(hào)查詢接口。與官網(wǎng)實(shí)時(shí)同步更新,包含快遞送達(dá)時(shí)間。

二、快遞物流查詢

注:需要購買快遞物流查詢接口服務(wù)獲取AppCode

在這里插入圖片描述

工具類

其中http請(qǐng)求工具類自行查看demo源碼

@Slf4j
public class LogisticUtil {

    /**
     * 查詢物流信息
     *
     * @param params 提交參數(shù)
     * @return 物流信息
     * @author zhengqingya
     * @date 2021/10/23 10:48 下午
     */
    public static LogisticVO getLogisticInfo(LogisticDTO params) {
        String no = params.getNo();
        String type = params.getType();
        String appCode = params.getAppCode();

        // 請(qǐng)求地址
        String requestUrl = String.format("https://kdwlcxf.market.alicloudapi.com/kdwlcx?no=%s&type=%s",
                no, StringUtils.isBlank(type) ? "" : type);
        // 發(fā)起請(qǐng)求
        Map<String, String> headerMap = Maps.newHashMap();
        headerMap.put("Authorization", String.format("APPCODE %s", appCode));
        String resultJson = HttpUtil.getUrl(requestUrl, headerMap);
        LogisticApiResult logisticApiResult = JSON.parseObject(resultJson, LogisticApiResult.class);
        Assert.notNull(logisticApiResult, "參數(shù)異常");
        Assert.isTrue(logisticApiResult.getStatus() == 0, logisticApiResult.getMsg());
        return logisticApiResult.getResult();
    }
}

請(qǐng)求實(shí)體類

@Data
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
@ApiModel("物流-查詢參數(shù)")
public class LogisticDTO {

    @ApiModelProperty(value = "快遞單號(hào) 【順豐請(qǐng)輸入運(yùn)單號(hào) : 收件人或寄件人手機(jī)號(hào)后四位。例如:123456789:1234】", required = true, example = "780098068058")
    private String no;

    @ApiModelProperty(value = "快遞公司代碼: 可不填自動(dòng)識(shí)別,填了查詢更快【代碼見附表】", required = true, example = "zto")
    private String type;

    @ApiModelProperty(value = "appCode", required = true, example = "xxx")
    private String appCode;
}

響應(yīng)實(shí)體類

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@ApiModel("物流-api響應(yīng)結(jié)果")
public class LogisticApiResult {

    @ApiModelProperty("狀態(tài)碼")
    private Integer status;

    @ApiModelProperty("提示信息")
    private String msg;

    @ApiModelProperty("結(jié)果集")
    private LogisticVO result;

}
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@ApiModel("物流-響應(yīng)參數(shù)")
public class LogisticVO {

    @ApiModelProperty("運(yùn)單編號(hào)")
    private String number;

    @ApiModelProperty("快遞公司編碼[見附表]")
    private String type;

    @ApiModelProperty("投遞狀態(tài) 0快遞收件(攬件)1在途中 2正在派件 3已簽收 4派送失敗 5.疑難件 6.退件簽收")
    private String deliverystatus;

    @ApiModelProperty("是否本人簽收")
    private String issign;

    @ApiModelProperty("快遞公司名字")
    private String expName;

    @ApiModelProperty("快遞公司官網(wǎng)")
    private String expSite;

    @ApiModelProperty("快遞公司電話")
    private String expPhone;

    @ApiModelProperty("快遞員")
    private String courier;

    @ApiModelProperty("快遞員電話")
    private String courierPhone;

    @ApiModelProperty("最新軌跡的時(shí)間")
    private String updateTime;

    @ApiModelProperty("發(fā)貨到收貨耗時(shí)(截止最新軌跡)")
    private String takeTime;

    @ApiModelProperty("快遞公司logo")
    private String logo;

    @ApiModelProperty("事件軌跡集")
    private List<LogisticItem> list;

    @Data
    @Builder
    @NoArgsConstructor
    @AllArgsConstructor
    @ApiModel("事件軌跡集")
    public static class LogisticItem {
        @ApiModelProperty("時(shí)間點(diǎn)")
        private String time;

        @ApiModelProperty("事件詳情")
        private String status;
    }
}

三、測(cè)試api

@Slf4j
@RestController
@RequestMapping("/test")
@Api(tags = "測(cè)試api")
public class TestController {

    @ApiOperation("查詢物流信息")
    @GetMapping("getLogistic")
    public LogisticVO getLogistic(@ModelAttribute LogisticDTO params) {
        return LogisticUtil.getLogisticInfo(params);
    }

}

接口文檔 http://127.0.0.1/doc.html

在這里插入圖片描述

本文demo源碼

https://gitee.com/zhengqingya/java-workspace

到此這篇關(guān)于SpringBoot實(shí)現(xiàn)阿里云快遞物流查詢的示例代碼的文章就介紹到這了,更多相關(guān)SpringBoot 阿里云快遞物流查詢內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • java實(shí)現(xiàn)圖片分割指定大小

    java實(shí)現(xiàn)圖片分割指定大小

    這篇文章主要為大家詳細(xì)介紹了java實(shí)現(xiàn)圖片分割指定大小,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2021-09-09
  • Spring中@RabbitHandler和@RabbitListener的區(qū)別詳析

    Spring中@RabbitHandler和@RabbitListener的區(qū)別詳析

    @RabbitHandler是用于處理消息的方法注解,它與@RabbitListener注解一起使用,這篇文章主要給大家介紹了關(guān)于Spring中@RabbitHandler和@RabbitListener區(qū)別的相關(guān)資料,需要的朋友可以參考下
    2024-02-02
  • JAVA字符串格式化-String.format()的使用

    JAVA字符串格式化-String.format()的使用

    本篇文章主要介紹了JAVA字符串格式化-String.format()的使用,具有一定的參考價(jià)值,有需要的可以了解一下。
    2016-11-11
  • SpringBoot中使用@Value注解注入詳解

    SpringBoot中使用@Value注解注入詳解

    這篇文章主要介紹了SpringBoot中的@Value注入詳解,在SpringBoot中,@Value注解可以注入一些字段的普通屬性,并且會(huì)自動(dòng)進(jìn)行類型轉(zhuǎn)換,本文對(duì)這些類型進(jìn)行總結(jié),需要的朋友可以參考下
    2023-08-08
  • java_object的簡(jiǎn)單使用詳解

    java_object的簡(jiǎn)單使用詳解

    下面小編就為大家?guī)硪黄猨ava_object的簡(jiǎn)單使用詳解。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
    2016-06-06
  • Spring中@Configuration注解修改的類生成代理原因解析

    Spring中@Configuration注解修改的類生成代理原因解析

    大家好,本篇文章主要講的是Spring中@Configuration注解修改的類生成代理原因解析,感興趣的同學(xué)趕快來看一看吧,對(duì)你有幫助的話記得收藏一下
    2022-02-02
  • 自從在 IDEA 中用了熱部署神器 JRebel 之后,開發(fā)效率提升了 10(真棒)

    自從在 IDEA 中用了熱部署神器 JRebel 之后,開發(fā)效率提升了 10(真棒)

    在javaweb開發(fā)過程中,使用熱部署神器 JRebel可以使class類還是更新spring配置文件都能立馬見到效率,本文給大家介紹JRebel的兩種安裝方法,小編建議使用第二種方法,具體安裝步驟跟隨小編一起看看吧
    2021-06-06
  • 構(gòu)建Maven多模塊項(xiàng)目的方法

    構(gòu)建Maven多模塊項(xiàng)目的方法

    這篇文章主要介紹了構(gòu)建Maven多模塊項(xiàng)目的方法,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2021-08-08
  • Java Calendar類常用示例_動(dòng)力節(jié)點(diǎn)Java學(xué)院整理

    Java Calendar類常用示例_動(dòng)力節(jié)點(diǎn)Java學(xué)院整理

    從JDK1.1版本開始,在處理日期和時(shí)間時(shí),系統(tǒng)推薦使用Calendar類進(jìn)行實(shí)現(xiàn)。接下來通過實(shí)例代碼給大家詳細(xì)介紹Java Calendar類相關(guān)知識(shí),需要的朋友參考下吧
    2017-04-04
  • 使用Java自制一個(gè)一個(gè)Nacos

    使用Java自制一個(gè)一個(gè)Nacos

    Nacos是?Dynamic?Naming?and?Configuration?Service的首字母簡(jiǎn)稱,一個(gè)更易于構(gòu)建云原生應(yīng)用的動(dòng)態(tài)服務(wù)發(fā)現(xiàn)、配置管理和服務(wù)管理平臺(tái),本文將嘗試用Java實(shí)現(xiàn)一個(gè)Nacos,感興趣的可以了解下
    2024-01-01

最新評(píng)論