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(); } } }