啊鑫
2025-08-20 a92e3aeb50efc6ef252d0fbaa2d45b4b7a3f5c61
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
package com.gs.xiaomi;
 
import cn.hutool.crypto.digest.DigestUtil;
import com.gs.xiaomi.dto.BCS101Request;
import com.gs.xiaomi.service.BCS101ApiService;
import com.gs.xiaomi.service.XM104Service;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
 
@SpringBootTest
class XiaomiApplicationTests {
 
    @Autowired
    private XM104Service xm104Service;
 
    @Autowired
    private BCS101ApiService bcs101ApiService;
 
    @Test
    void contextLoads() throws Exception {
        xm104Service.getDb();
    }
 
    @Test
    void test() {
//        String str = ",,";
//        String[] parts = str.split(",");
//        for (String part : parts) {
//            System.out.println(part);
//        }
        System.out.println(DigestUtil.md5Hex("VDATA.XM104/177301/c5Kl}xN&i(").toUpperCase());
    }
 
    @Test
    void testBCS101ApiService() throws Exception {
        // 创建测试请求参数
        BCS101Request request = new BCS101Request();
        request.setSupplierId("100071");
        request.setDocNo("9311991542");
        request.setDocType("ASNGR");
        request.setPageNo(1);
        request.setPageSize(1000);
 
        //Error: ERROR_IN_MODULECHAIN;ERROR_IN_MODULECHAIN, Sender Channel 'CC_MI_OEM_HTTP_OUT' (ID: a58369adbaa03aafb76d2c02c2ae7cd7): Catching exception calling messaging system
        System.out.println("=== 测试BCS101 API服务(Basic Auth版本) ===");
        try {
            // 调用标准BCS101 API服务(只使用Basic Auth)
            String response = bcs101ApiService.getBCS101Data(request);
            System.out.println("BCS101 API Response: " + response);
        } catch (Exception e) {
            System.out.println("BCS101 API调用异常: " + e.getMessage());
            e.printStackTrace();
        }
 
        //Error: ERROR_IN_MODULECHAIN;ERROR_IN_MODULECHAIN, Sender Channel 'CC_MI_OEM_HTTP_OUT' (ID: a58369adbaa03aafb76d2c02c2ae7cd7): Catching exception calling messaging system
        System.out.println("\n=== 测试BCS101 API服务(带X5协议版本) ===");
        try {
            // 调用带X5协议的BCS101 API服务
            String responseWithX5 = bcs101ApiService.getBCS101DataWithX5(request, true);
            System.out.println("BCS101 API Response (X5): " + responseWithX5);
        } catch (Exception e) {
            System.out.println("BCS101 API X5调用异常: " + e.getMessage());
            e.printStackTrace();
        }
 
        System.out.println("\n=== 测试BCS101 API服务(调试版本) ===");
        try {
            // 调用调试版本API服务
            String debugResponse = bcs101ApiService.getBCS101DataDebug(request);
            System.out.println("BCS101 API Debug Response: " + debugResponse);
        } catch (Exception e) {
            System.out.println("BCS101 API 调试版本调用异常: " + e.getMessage());
            e.printStackTrace();
        }
 
        System.out.println("\n=== 测试BCS101 API服务(简化版本) ===");
        try {
            // 调用简化版本API服务
            String simpleResponse = bcs101ApiService.getBCS101DataSimple(request);
            System.out.println("BCS101 API Simple Response: " + simpleResponse);
        } catch (Exception e) {
            System.out.println("BCS101 API 简化版本调用异常: " + e.getMessage());
            e.printStackTrace();
        }
 
        System.out.println("\n=== 测试BCS101 API服务(X5协议标准版本) ===");
        try {
            // 调用X5协议标准版本
            String x5StandardResponse = bcs101ApiService.getBCS101DataX5Standard(request);
            System.out.println("BCS101 API X5Standard Response: " + x5StandardResponse);
        } catch (Exception e) {
            System.out.println("BCS101 API X5标准版本调用异常: " + e.getMessage());
            e.printStackTrace();
        }
 
        System.out.println("\n=== 测试BCS101 API服务(X5协议变体版本) ===");
        try {
            // 调用X5协议变体版本
            String x5VariantResponse = bcs101ApiService.getBCS101DataX5Variant(request);
            System.out.println("BCS101 API X5Variant Response: " + x5VariantResponse);
        } catch (Exception e) {
            System.out.println("BCS101 API X5变体版本调用异常: " + e.getMessage());
            e.printStackTrace();
        }
    }
}