啊鑫
2025-02-11 af5aeb12ed2ef193ce66686cb5f3a21b4d981549
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package com.gs.xky;
 
import com.alibaba.fastjson.JSON;
import com.gs.xky.config.*;
import com.gs.xky.dto.XkyEntity;
import com.gs.xky.service.ApiService;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
 
import java.io.IOException;
 
@SpringBootTest
class XkyApplicationTests {
 
 
    @Autowired
    private ApiService apiService;
 
    @Test
    void contextLoads() throws IOException {
 
        long currentTimeMillis = System.currentTimeMillis();
 
        ApiCommonParam apiParam = new ApiCommonParam();
        apiParam.setAppKey(DataAcquisitionConfiguration.TEST_APP_KEY);//发携客云提供的appKey
        apiParam.setVersion("1.0");//接口版本
        apiParam.setOperateCompanyCode(DataAcquisitionConfiguration.TEST_COMPANY_CODE);//操作者所属公司编码
        apiParam.setOwnerCompanyCode(DataAcquisitionConfiguration.TEST_COMPANY_CODE);//数据所属公司编码,非集团公司默认赋值为操作公司
        apiParam.setTimestamps(currentTimeMillis / 1000);//当前时间对应的时间戳(秒数)
 
        String appSecret = DataAcquisitionConfiguration.TEST_APP_SECRET;//携客云提供的appSecret
 
        String sign = SignUtils.buildCurrentSign(JSON.toJSONString(apiParam), appSecret);
        apiParam.setSign(sign);
 
 
        // 计算五分钟前的时间戳
        long startDate = currentTimeMillis - (65 * 60 * 1000); // 5 分钟 = 5 * 60 * 1000 毫秒
 
        // 创建 BodyParam 对象并赋值
        BodyParam bodyParam = new BodyParam();
        bodyParam.setStartDate(startDate);
        bodyParam.setEndDate(currentTimeMillis);
        bodyParam.setErpCode("Z106");
        bodyParam.setStatus(new int[]{1});
        bodyParam.setLogisticsStatus(2);
 
        XkyCommonParam param = new XkyCommonParam();
        param.setCommonParam(apiParam);
        param.setBody(bodyParam);
 
 
        ApiResponse<XkyEntity> xkyEntityApiResponse = apiService.sendListRequest(param, XkyEntity.class, "https://openapi.xiekeyun.com/delivery/getNoList.json");
 
        System.out.println(JSON.toJSONString(xkyEntityApiResponse));
    }
 
}