From 22a8875b365c568790f6115ceb6acf0f49bb8c47 Mon Sep 17 00:00:00 2001
From: 啊鑫 <t2856754968@163.com>
Date: 星期四, 10 四月 2025 15:43:29 +0800
Subject: [PATCH] 测试写入数据库

---
 src/test/java/com/gs/xiaomi/XiaomiApplicationTests.java |  144 +-----------------------------------------------
 1 files changed, 3 insertions(+), 141 deletions(-)

diff --git a/src/test/java/com/gs/xiaomi/XiaomiApplicationTests.java b/src/test/java/com/gs/xiaomi/XiaomiApplicationTests.java
index 4b5ac5c..cc8dbe1 100644
--- a/src/test/java/com/gs/xiaomi/XiaomiApplicationTests.java
+++ b/src/test/java/com/gs/xiaomi/XiaomiApplicationTests.java
@@ -1,156 +1,18 @@
 package com.gs.xiaomi;
 
-import com.alibaba.fastjson.JSON;
-import com.gs.xiaomi.config.DataAcquisitionConfiguration;
-import com.gs.xiaomi.dto.BizDocument;
-import com.gs.xiaomi.dto.BizDocumentResult;
-import com.gs.xiaomi.dto.ZfmWsApiRequest;
-import com.gs.xiaomi.service.SoapApiService;
-import com.gs.xiaomi.util.SoapXmlBuilder;
-import okhttp3.*;
+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;
-
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBException;
-import javax.xml.bind.Unmarshaller;
-import java.io.IOException;
-import java.io.StringReader;
 
 @SpringBootTest
 class XiaomiApplicationTests {
 
     @Autowired
-    private SoapApiService service;
+    private XM104Service xm104Service;
 
     @Test
     void contextLoads() throws Exception {
-        ZfmWsApiRequest req = new ZfmWsApiRequest();
-        req.setIvCode(DataAcquisitionConfiguration.IV_CODEXM104);
-        req.setIvEvent("");
-        req.setIvFlag("");
-        BizDocument doc = new BizDocument();
-        doc.setBizDate("2025-04-01");
-        doc.setLifnr(DataAcquisitionConfiguration.LIFNR);
-        req.setIvInfo(doc);
-        req.setIvPass(DataAcquisitionConfiguration.getIvPass(DataAcquisitionConfiguration.IV_CODEXM104));
-        req.setIvUser(DataAcquisitionConfiguration.IV_USER);
-        String soapXml = SoapXmlBuilder.build(req);
-        System.out.println(soapXml);
+        xm104Service.getDb();
     }
-
-    @Test
-    void testService() throws Exception {
-        ZfmWsApiRequest req = new ZfmWsApiRequest();
-        req.setIvCode(DataAcquisitionConfiguration.IV_CODEXM104);
-        req.setIvEvent("");
-        req.setIvFlag("");
-        BizDocument doc = new BizDocument();
-        doc.setBizDate("2025-04-01");
-        doc.setLifnr(DataAcquisitionConfiguration.LIFNR);
-        req.setIvInfo(doc);
-        req.setIvPass(DataAcquisitionConfiguration.getIvPass(DataAcquisitionConfiguration.IV_CODEXM104));
-        req.setIvUser(DataAcquisitionConfiguration.IV_USER);
-
-        BizDocumentResult bizDocumentResult = service.callAndParse(DataAcquisitionConfiguration.XM104_URL, req);
-
-        System.out.println(JSON.toJSONString(bizDocumentResult));
-    }
-
-    @Test
-    void sta() throws IOException, JAXBException {
-        OkHttpClient client = new OkHttpClient().newBuilder()
-                .build();
-        MediaType mediaType = MediaType.parse("application/xml");
-        RequestBody body = RequestBody.create(mediaType, "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:urn=\"urn:sap-com:document:sap:rfc:functions\">\r\n    <soapenv:Header/>\r\n    <soapenv:Body>\r\n        <urn:ZFM_WS_API>\r\n            <IV_CODE>VDATA.XM104</IV_CODE>\r\n            <IV_EVENT></IV_EVENT>\r\n            <IV_FLAG></IV_FLAG>\r\n            <IV_INFO><![CDATA[<?xml version=\"1.0\" encoding=\"utf-16\"?>\r\n<document>\r\n    <BIZ_DATE>2025-04-01</BIZ_DATE>\r\n    <I_LIFNR>177301</I_LIFNR>\r\n</document>]]></IV_INFO>\r\n            <IV_PASS>D25932DF5772D0A2DF9620A2A0AB121A</IV_PASS>\r\n            <IV_USER>V177301</IV_USER>\r\n        </urn:ZFM_WS_API>\r\n    </soapenv:Body>\r\n</soapenv:Envelope>");
-        Request request = new Request.Builder()
-                .url("https://mipoq.p.mi.com/XISOAPAdapter/MessageServlet?p=ic/9e8a118fb0b7379aa11c2a5c2860982a&senderParty=&senderService=ZJ_XIAOBU_QAS&receiverParty=&receiverService=&interface=SI_ZFM_WS_API_OUT&interfaceNamespace=http://xiaomi.com/srm/b2b")
-                .method("POST", body)
-//                .addHeader("User-Agent", "Apifox/1.0.0 (https://apifox.com)")
-                .addHeader("Content-Type", "application/xml")
-                .addHeader("Authorization", "Basic UkZDWkpYSUFPQlU6cHBCOVIhSGU=")
-                .addHeader("Accept", "*/*")
-//                .addHeader("Host", "mipoq.p.mi.com")
-                .addHeader("Connection", "keep-alive")
-//                .addHeader("Cookie", "saplb_*=(J2EE4281420)4281450; MYSAPSSO2=AjExMDAgABJwb3J0YWw6UkZDWkpYSUFPQlWIAAdkZWZhdWx0AQALUkZDWkpYSUFPQlUCAAMwMDADAANQT1EEAAwyMDI1MDQwOTAwMTcFAAQAAAAICgALUkZDWkpYSUFPQlX%2FAQUwggEBBgkqhkiG9w0BBwKggfMwgfACAQExCzAJBgUrDgMCGgUAMAsGCSqGSIb3DQEHATGB0DCBzQIBATAiMB0xDDAKBgNVBAMTA1BPUTENMAsGA1UECxMESjJFRQIBADAJBgUrDgMCGgUAoF0wGAYJKoZIhvcNAQkDMQsGCSqGSIb3DQEHATAcBgkqhkiG9w0BCQUxDxcNMjUwNDA5MDAxNzU2WjAjBgkqhkiG9w0BCQQxFgQUvvJ1HSnOLckboGYaMR9Wiaem6z4wCQYHKoZIzjgEAwQvMC0CFQDKLPrpUC19VM2gcslWaHAnh7dfxQIUNs2dTxwGcKdNU%2FdAQPs4f08yaw4%3D; JSESSIONID=_6bPldDq9mFJPXEd11bc-GvrWMAVlgFqVEEA_SAPF-GrpRbcuqxMK_gShBYGdmdp; JSESSIONMARKID=nUs7PQMlYui9UqFCm4Z-ZRqUiI8YQ_hLJPJWpUQQA")
-                .build();
-        Response response = client.newCall(request).execute();
-
-        if (response.isSuccessful() && response.body() != null) {
-            String bodyStr = response.body().string();
-
-            String evCode = extractEvCode(bodyStr);
-            if (!"Y".equalsIgnoreCase(evCode)) {
-                throw new RuntimeException("SOAP business failed, EV_CODE: " + evCode);
-            }
-
-            String decodedXml = decodeXmlEntities(bodyStr);
-
-            String innerXml = extractCdata(decodedXml);
-            if (innerXml == null) throw new RuntimeException("No CDATA <document> found in response");
-
-//            JAXBContext context = JAXBContext.newInstance(BizDocumentResult.class);
-//            Unmarshaller unmarshaller = context.createUnmarshaller();
-            //BizDocumentResult unmarshal = (BizDocumentResult) unmarshaller.unmarshal(new StringReader(decodedXml));
-            System.out.println(JSON.toJSONString(innerXml));
-        } else {
-            throw new RuntimeException("SOAP request failed: " + response.code() + " - " + response.message());
-        }
-    }
-
-
-    @Test
-    void contextLoads2() throws Exception {
-        String bodyStr = "<SOAP:Envelope xmlns:SOAP='http://schemas.xmlsoap.org/soap/envelope/'>" +
-                "  <SOAP:Header/>" +
-                "  <SOAP:Body xmlns:urn='urn:sap-com:document:sap:rfc:functions'>" +
-                "    <n0:ZFM_WS_APIResponse xmlns:n0='urn:sap-com:document:sap:rfc:functions' xmlns:prx='urn:sap.com:proxy:FRD:/1SAI/TAS82FD47019F21003C052D:752'>" +
-                "      <EV_CODE>Y</EV_CODE>" +
-                "      <EV_EVENT/>" +
-                "      <EV_FLAG/>" +
-                "      <EV_RESULT>&#60;?xml version=\"1.0\" encoding=\"utf-8\"?&#62;&#60;document&#62;&#60;et_headers type=\"h\"&#62;&#60;et_header idx=\"1\"&#62;&#60;zzasn&#62;9311031471&#60;/zzasn&#62;&#60;zzasn_type&#62;BL&#60;/zzasn_type&#62;&#60;imclr&#62;&#60;/imclr&#62;&#60;lifnr&#62;0000177301&#60;/lifnr&#62;&#60;vendor_name&#62;娴欐睙灏忔鍑鸿鏈夐檺鍏徃&#60;/vendor_name&#62;&#60;zzship_addr&#62;娴嬭瘯&#60;/zzship_addr&#62;&#60;zzship_name&#62;11&#60;/zzship_name&#62;&#60;zzship_phon&#62;1111&#60;/zzship_phon&#62;&#60;zzship_date&#62;2025-04-01&#60;/zzship_date&#62;&#60;zzwarehouse_id&#62;0000017560&#60;/zzwarehouse_id&#62;&#60;zzwarehouse&#62;涓皬浠�-鍖椾含涓績浠�&#60;/zzwarehouse&#62;&#60;zzreceive_addr&#62;鍖椾含甯傚ぇ鍏村尯缁忔祹寮�鍙戝尯绉戝垱鍗佽鍗佷簲鍙�(浜﹀簞灏忕背浜т笟鍥�)T1妤�1灞�&#60;/zzreceive_addr&#62;&#60;zzcarrier&#62;&#60;/zzcarrier&#62;&#60;zzdriver_name&#62;&#60;/zzdriver_name&#62;&#60;zzdriver_phon&#62;&#60;/zzdriver_phon&#62;&#60;zzarrive_time&#62;20250402&#60;/zzarrive_time&#62;&#60;zzarrive_time1&#62;00:00:00&#60;/zzarrive_time1&#62;&#60;zzcarrier_no&#62;&#60;/zzcarrier_no&#62;&#60;road_transport_no&#62;&#60;/road_transport_no&#62;&#60;zztrans_model&#62;&#60;/zztrans_model&#62;&#60;zzdriver_license&#62;&#60;/zzdriver_license&#62;&#60;zzlicense_numb&#62;&#60;/zzlicense_numb&#62;&#60;zzseal_no&#62;&#60;/zzseal_no&#62;&#60;zzcanceled&#62;&#60;/zzcanceled&#62;&#60;ship_email&#62;11@163.com&#60;/ship_email&#62;&#60;lifnr_dg&#62;&#60;/lifnr_dg&#62;&#60;short_name&#62;&#60;/short_name&#62;&#60;reserve_date&#62;&#60;/reserve_date&#62;&#60;reserve_time&#62;&#60;/reserve_time&#62;&#60;bukrs&#62;1110&#60;/bukrs&#62;&#60;asn_desc&#62;&#60;/asn_desc&#62;&#60;price_stat&#62;&#60;/price_stat&#62;&#60;final_contact&#62;&#60;/final_contact&#62;&#60;final_phone&#62;&#60;/final_phone&#62;&#60;final_addr&#62;&#60;/final_addr&#62;&#60;final_company&#62;&#60;/final_company&#62;&#60;status&#62;S002&#60;/status&#62;&#60;status_sn&#62;&#60;/status_sn&#62;&#60;purchase_mode&#62;&#60;/purchase_mode&#62;&#60;hub_lifnr&#62;&#60;/hub_lifnr&#62;&#60;items type=\"h\"&#62;&#60;item idx=\"1\"&#62;&#60;zzasn&#62;9311031471&#60;/zzasn&#62;&#60;zzitem_id&#62;0000000010&#60;/zzitem_id&#62;&#60;zzpo_no&#62;4500173648&#60;/zzpo_no&#62;&#60;zzpo_item_id&#62;0000000010&#60;/zzpo_item_id&#62;&#60;zzreqnr&#62;&#60;/zzreqnr&#62;&#60;zzreqln&#62;&#60;/zzreqln&#62;&#60;zzproduct_id&#62;950102000010&#60;/zzproduct_id&#62;&#60;zzvproduct_id&#62;&#60;/zzvproduct_id&#62;&#60;zzsku&#62;BHR4008CN&#60;/zzsku&#62;&#60;zzquantity&#62;5.000&#60;/zzquantity&#62;&#60;zzunit&#62;ST&#60;/zzunit&#62;&#60;brand&#62;&#60;/brand&#62;&#60;place&#62;&#60;/place&#62;&#60;brand_type&#62;&#60;/brand_type&#62;&#60;is_identification&#62;&#60;/is_identification&#62;&#60;zzopen_qty&#62;5.000&#60;/zzopen_qty&#62;&#60;changed_at&#62;20250401071304&#60;/changed_at&#62;&#60;created_at&#62;20250401071304&#60;/created_at&#62;&#60;app_models&#62;11-AD&#60;/app_models&#62;&#60;ext_doc_no&#62;8897300&#60;/ext_doc_no&#62;&#60;ext_doc_item&#62;2884654&#60;/ext_doc_item&#62;&#60;address_detail&#62;鍖椾含甯傚ぇ鍏村尯缁忔祹寮�鍙戝尯绉戝垱鍗佽鍗佷簲鍙�(浜﹀簞灏忕背浜т笟鍥�)T1妤�1灞�&#60;/address_detail&#62;&#60;batch_id&#62;&#60;/batch_id&#62;&#60;batch_row&#62;&#60;/batch_row&#62;&#60;xmsto_no&#62;&#60;/xmsto_no&#62;&#60;xmsto_item_no&#62;&#60;/xmsto_item_no&#62;&#60;modelnumber&#62;&#60;/modelnumber&#62;&#60;shipment_id&#62;&#60;/shipment_id&#62;&#60;shipmentid_num&#62;0&#60;/shipmentid_num&#62;&#60;maktx&#62;绫冲鏅鸿兘渚у惛娌圭儫鏈�&#60;/maktx&#62;&#60;bednr&#62;&#60;/bednr&#62;&#60;ware_type_from&#62;&#60;/ware_type_from&#62;&#60;ware_type_to&#62;&#60;/ware_type_to&#62;&#60;act_gr_qty&#62;0.000&#60;/act_gr_qty&#62;&#60;pn_matnr_l&#62;&#60;/pn_matnr_l&#62;&#60;pn_matnr_name&#62;&#60;/pn_matnr_name&#62;&#60;/item&#62;&#60;/items&#62;&#60;box_items type=\"h\"&#62;&#60;/box_items&#62;&#60;box_sums type=\"h\"&#62;&#60;/box_sums&#62;&#60;purchase_mode2&#62;&#60;/purchase_mode2&#62;&#60;receiver&#62;鏉ㄤ腹涓�,鍛ㄦ櫒鍏�&#60;/receiver&#62;&#60;receive_phone&#62;18811578183,13002157815&#60;/receive_phone&#62;&#60;receive_addr&#62;鍖椾含甯傚ぇ鍏村尯缁忔祹寮�鍙戝尯绉戝垱鍗佽鍗佷簲鍙�(浜﹀簞灏忕背浜т笟鍥�)T1妤�1灞�&#60;/receive_addr&#62;&#60;receive_warehouse_id&#62;0000017560&#60;/receive_warehouse_id&#62;&#60;receive_warehouse_short&#62;涓皬浠�-鍖椾含涓績浠�&#60;/receive_warehouse_short&#62;&#60;product_type&#62;GM&#60;/product_type&#62;&#60;ekorg&#62;2120&#60;/ekorg&#62;&#60;ekotx&#62;&#60;/ekotx&#62;&#60;stock_org_from&#62;&#60;/stock_org_from&#62;&#60;stock_org_from_desc&#62;&#60;/stock_org_from_desc&#62;&#60;stock_org_to&#62;MI_IOT&#60;/stock_org_to&#62;&#60;stock_org_to_desc&#62;鐢熸�侀摼搴撳瓨缁勭粐(IOT)&#60;/stock_org_to_desc&#62;&#60;migo_type&#62;&#60;/migo_type&#62;&#60;zrproject&#62;A1&#60;/zrproject&#62;&#60;logistics_no&#62;&#60;/logistics_no&#62;&#60;logistics_company&#62;&#60;/logistics_company&#62;&#60;last4_phone_number&#62;&#60;/last4_phone_number&#62;&#60;logistics_company_name&#62;&#60;/logistics_company_name&#62;&#60;business_model&#62;&#60;/business_model&#62;&#60;/et_header&#62;&#60;/et_headers&#62;&#60;ev_message&#62;&#60;/ev_message&#62;&#60;ev_msgty&#62;S&#60;/ev_msgty&#62;&#60;/document&#62;</EV_RESULT>" +
-                "    </n0:ZFM_WS_APIResponse>" +
-                "  </SOAP:Body>" +
-                "</SOAP:Envelope>";
-
-        String evCode = extractEvCode(bodyStr);
-        if (!"Y".equalsIgnoreCase(evCode)) {
-            throw new RuntimeException("SOAP business failed, EV_CODE: " + evCode);
-        }
-
-        String decodedXml = decodeXmlEntities(bodyStr);
-
-        String innerXml = extractCdata(decodedXml);
-        if (innerXml == null) throw new RuntimeException("No CDATA <document> found in response");
-
-
-        JAXBContext context = JAXBContext.newInstance(BizDocumentResult.class);
-        Unmarshaller unmarshaller = context.createUnmarshaller();
-        BizDocumentResult unmarshal = (BizDocumentResult) unmarshaller.unmarshal(new StringReader(innerXml));
-        System.out.println(JSON.toJSONString(unmarshal));
-    }
-
-    private String extractEvCode(String xml) {
-        int start = xml.indexOf("<EV_CODE>");
-        int end = xml.indexOf("</EV_CODE>", start);
-        if (start == -1 || end == -1) return null;
-        return xml.substring(start + 9, end).trim();
-    }
-
-    private String decodeXmlEntities(String xml) {
-        return xml.replace("&#60;", "<")
-                .replace("&#62;", ">")
-                .replace("&lt;", "<")
-                .replace("&gt;", ">")
-                .replace("&amp;", "&");
-    }
-
-    private String extractCdata(String xml) {
-        int cdataStart = xml.indexOf("<EV_RESULT>");
-        int cdataEnd = xml.indexOf("</EV_RESULT>", cdataStart);
-        if (cdataStart == -1 || cdataEnd == -1) return null;
-        return xml.substring(cdataStart + 11, cdataEnd).trim();
-    }
-
 }

--
Gitblit v1.9.3