From e6d788eef335aa02ac306e984c44affa68ab971c Mon Sep 17 00:00:00 2001
From: zhangherong <571457620@qq.com>
Date: 星期三, 30 七月 2025 20:45:03 +0800
Subject: [PATCH] art: 新增系统第三方集成调用日志表,切面服务实现

---
 src/main/java/org/jeecg/modules/sap/service/impl/ProductionOrderSyncImpl.java |  174 +++++++++++++++++++++++++++++++++-------------------------
 1 files changed, 99 insertions(+), 75 deletions(-)

diff --git a/src/main/java/org/jeecg/modules/sap/service/impl/ProductionOrderSyncImpl.java b/src/main/java/org/jeecg/modules/sap/service/impl/ProductionOrderSyncImpl.java
index ed2c10b..9cb836b 100644
--- a/src/main/java/org/jeecg/modules/sap/service/impl/ProductionOrderSyncImpl.java
+++ b/src/main/java/org/jeecg/modules/sap/service/impl/ProductionOrderSyncImpl.java
@@ -1,7 +1,13 @@
 package org.jeecg.modules.sap.service.impl;
 
-import com.sap.conn.jco.*;
+import com.alibaba.fastjson.JSONObject;
+import com.sap.conn.jco.JCoDestination;
+import com.sap.conn.jco.JCoFunction;
+import com.sap.conn.jco.JCoRepository;
+import com.sap.conn.jco.JCoTable;
 import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.aspect.annotation.ApiLog;
+import org.jeecg.common.constant.ApiLogCategoryEnum;
 import org.jeecg.config.sap.SapRfcConnectionManager;
 import org.jeecg.modules.sap.FunctionConst;
 import org.jeecg.modules.sap.dto.ProductionOrderDTO;
@@ -10,7 +16,9 @@
 import org.springframework.stereotype.Service;
 
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 /**
  * 鐢熸垚璁㈠崟鍚屾鏈嶅姟
@@ -35,81 +43,97 @@
 
 
     @Override
-    public void syncProductionOrder() {
+    @ApiLog(apiName = "鐢熶骇璁㈠崟鍚屾鎺ュ彛(ZPPF_033_1)", apiCategory = ApiLogCategoryEnum.SAP)
+    public Map<String, Object> syncProductionOrder() throws Exception {
+        Map<String, Object> resultMap = new HashMap<>();
         JCoDestination destination = connectionManager.getDestination();
-        try {
-            JCoRepository repository = destination.getRepository();
-            JCoFunction function = repository.getFunction(FunctionConst.ZPPF_033_1);
-            if (function == null) {
-                throw new RuntimeException("RFC 鍑芥暟 ZPPF_033_1 鏈壘鍒帮紒");
-            }
-            // 璁剧疆杈撳叆鍙傛暟
-            //璁㈠崟鍙锋煡璇㈡潯浠�
-//            JCoTable AUFNRTable = function.getTableParameterList().getTable("ZTAB_AUFNR");
-            //璁㈠崟绫诲瀷 鏍囧噯鐢熶骇璁㈠崟
-            JCoTable AUARTTable = function.getTableParameterList().getTable("ZTAB_AUART");
-            AUARTTable.appendRow();
-            AUARTTable.setValue("AUART", orderTypeCode1);
-            //鍏垎鍘傝皟搴�
-            JCoTable FEVORTable = function.getTableParameterList().getTable("ZTAB_FEVOR");
-            FEVORTable.appendRow();
-            FEVORTable.setValue("FEVOR", productionManager);
-            //鏂扮伀鐐�
-            JCoTable WERKSTable = function.getTableParameterList().getTable("ZTAB_WERKS");
-            WERKSTable.appendRow();
-            WERKSTable.setValue("WERKS", factoryCode);
-            //璁㈠崟鐘舵��
-            JCoTable TXT04Table = function.getTableParameterList().getTable("ZTAB_TXT04");
-            TXT04Table.appendRow();
-            TXT04Table.setValue("TXT04", orderStatus);
-            // 鎵ц璋冪敤
-            function.execute(destination);
-            //鑾峰彇杩斿洖缁撴灉
-            String zmess = function.getExportParameterList().getValue("ZMESS").toString();
-            String ztype = function.getExportParameterList().getValue("ZTYPE").toString();//S 鏍囪瘑 鎴愬姛
-            if(!"S".equals(ztype)){
-                log.error("鑾峰彇璁㈠崟淇℃伅澶辫触锛孼TYPE={}, ZMESS={}", ztype, zmess);
-                return;
-            }
-            // 鑾峰彇杈撳嚭鍙傛暟
-            JCoTable outputTable = function.getTableParameterList().getTable("ZTAB_OUT");
-            int numRows = outputTable.getNumRows();
-            List<ProductionOrderDTO> resultList = new ArrayList<>();
-            ProductionOrderDTO dto;
-            for (int i = 0; i < numRows; i++) {
-                outputTable.setRow(i);
-                dto = new ProductionOrderDTO();
-                dto.setKDPOS(outputTable.getString("KDPOS"));
-                dto.setCHARG(outputTable.getString("CHARG"));
-                dto.setMAKTX(outputTable.getString("MAKTX"));
-                dto.setMATNR(outputTable.getString("MATNR"));
-                dto.setKDAUF(outputTable.getString("KDAUF"));
-                dto.setAUFNR(outputTable.getString("AUFNR"));
-                dto.setDAUAT(outputTable.getString("DAUAT"));
-                dto.setGAMNG(outputTable.getString("GAMNG"));
-                dto.setGMEIN(outputTable.getString("GMEIN"));
-                dto.setAPRIO(outputTable.getString("APRIO"));
-                dto.setAUFPL(outputTable.getString("AUFPL"));
-                dto.setSTLNR(outputTable.getString("STLNR"));
-                dto.setDWERK(outputTable.getString("DWERK"));
-                dto.setNAME1(outputTable.getString("NAME1"));
-                dto.setFEVOR(outputTable.getString("FEVOR"));
-                dto.setTXT(outputTable.getString("TXT"));
-                dto.setUSNAM(outputTable.getString("USNAM"));
-                dto.setUDATE(outputTable.getString("UDATE"));
-                dto.setLAEDA(outputTable.getString("LAEDA"));
-                dto.setTIMES(outputTable.getString("TIMES"));
-                dto.setTXT04(outputTable.getString("TXT04"));
-                dto.setTXT30(outputTable.getString("TXT30"));
-                dto.setGSTRP(outputTable.getString("GSTRP"));
-                dto.setGLTRP(outputTable.getString("GLTRP"));
-
-                //娣诲姞缁撴灉闆�
-                resultList.add(dto);
-                log.info(dto.toString());
-            }
-        } catch (JCoException e) {
-            log.error(e.getMessage(), e);
+        JCoRepository repository = destination.getRepository();
+        JCoFunction function = repository.getFunction(FunctionConst.ZPPF_033_1);
+        if (function == null) {
+            throw new RuntimeException("RFC 鍑芥暟 ZPPF_033_1 鏈壘鍒帮紒");
         }
+        // 璁剧疆杈撳叆鍙傛暟
+        //璁㈠崟鍙锋煡璇㈡潯浠�
+//            JCoTable AUFNRTable = function.getTableParameterList().getTable("ZTAB_AUFNR");
+        List<JSONObject> items = new ArrayList<>();
+        //璁㈠崟绫诲瀷 鏍囧噯鐢熶骇璁㈠崟
+        JCoTable AUARTTable = function.getTableParameterList().getTable("ZTAB_AUART");
+        AUARTTable.appendRow();
+        AUARTTable.setValue("AUART", orderTypeCode1);
+        //缁勮璇锋眰鍙傛暟
+        JSONObject item1 = new JSONObject();
+        item1.put("AUART", orderTypeCode1);
+        items.add(item1);
+        //鍏垎鍘傝皟搴�
+        JCoTable FEVORTable = function.getTableParameterList().getTable("ZTAB_FEVOR");
+        FEVORTable.appendRow();
+        FEVORTable.setValue("FEVOR", productionManager);
+        //缁勮璇锋眰鍙傛暟
+        JSONObject item2 = new JSONObject();
+        item2.put("FEVOR", productionManager);
+        items.add(item2);
+        //鏂扮伀鐐�
+        JCoTable WERKSTable = function.getTableParameterList().getTable("ZTAB_WERKS");
+        WERKSTable.appendRow();
+        WERKSTable.setValue("WERKS", factoryCode);
+        //缁勮璇锋眰鍙傛暟
+        JSONObject item3 = new JSONObject();
+        item3.put("WERKS", factoryCode);
+        items.add(item3);
+        //璁㈠崟鐘舵��
+        JCoTable TXT04Table = function.getTableParameterList().getTable("ZTAB_TXT04");
+        TXT04Table.appendRow();
+        TXT04Table.setValue("TXT04", orderStatus);
+        //缁勮璇锋眰鍙傛暟
+        JSONObject item4 = new JSONObject();
+        item4.put("TXT04", orderStatus);
+        items.add(item4);
+        // 鎵ц璋冪敤
+        function.execute(destination);
+        //鑾峰彇杩斿洖缁撴灉
+        String zmess = function.getExportParameterList().getValue("ZMESS").toString();
+        String ztype = function.getExportParameterList().getValue("ZTYPE").toString();//S 鏍囪瘑 鎴愬姛
+        // 鑾峰彇杈撳嚭鍙傛暟
+        JCoTable outputTable = function.getTableParameterList().getTable("ZTAB_OUT");
+        int numRows = outputTable.getNumRows();
+        List<ProductionOrderDTO> resultList = new ArrayList<>();
+        ProductionOrderDTO dto;
+        for (int i = 0; i < numRows; i++) {
+            outputTable.setRow(i);
+            dto = new ProductionOrderDTO();
+            dto.setKDPOS(outputTable.getString("KDPOS"));
+            dto.setCHARG(outputTable.getString("CHARG"));
+            dto.setMAKTX(outputTable.getString("MAKTX"));
+            dto.setMATNR(outputTable.getString("MATNR"));
+            dto.setKDAUF(outputTable.getString("KDAUF"));
+            dto.setAUFNR(outputTable.getString("AUFNR"));
+            dto.setDAUAT(outputTable.getString("DAUAT"));
+            dto.setGAMNG(outputTable.getString("GAMNG"));
+            dto.setGMEIN(outputTable.getString("GMEIN"));
+            dto.setAPRIO(outputTable.getString("APRIO"));
+            dto.setAUFPL(outputTable.getString("AUFPL"));
+            dto.setSTLNR(outputTable.getString("STLNR"));
+            dto.setDWERK(outputTable.getString("DWERK"));
+            dto.setNAME1(outputTable.getString("NAME1"));
+            dto.setFEVOR(outputTable.getString("FEVOR"));
+            dto.setTXT(outputTable.getString("TXT"));
+            dto.setUSNAM(outputTable.getString("USNAM"));
+            dto.setUDATE(outputTable.getString("UDATE"));
+            dto.setLAEDA(outputTable.getString("LAEDA"));
+            dto.setTIMES(outputTable.getString("TIMES"));
+            dto.setTXT04(outputTable.getString("TXT04"));
+            dto.setTXT30(outputTable.getString("TXT30"));
+            dto.setGSTRP(outputTable.getString("GSTRP"));
+            dto.setGLTRP(outputTable.getString("GLTRP"));
+
+            //娣诲姞缁撴灉闆�
+            resultList.add(dto);
+            log.info(dto.toString());
+        }
+        resultMap.put("zmess", zmess);
+        resultMap.put("ztype", ztype);
+        resultMap.put("importParameters", items);
+        resultMap.put("result", resultList);
+        return resultMap;
     }
 }

--
Gitblit v1.9.3