From 9825ca9fb40954a2a4044b4c224486a2f813d243 Mon Sep 17 00:00:00 2001 From: zhangherong <571457620@qq.com> Date: 星期四, 31 七月 2025 17:58:34 +0800 Subject: [PATCH] art:订单BOM接口、订单工序接口调试 --- src/main/java/org/jeecg/modules/sap/controller/SAPTestController.java | 55 +++++- db/双林新火炬MES数据库设计.pdma.json | 4 src/main/java/org/jeecg/modules/sap/service/OrderProcessSync.java | 12 + src/main/java/org/jeecg/modules/sap/service/impl/SAPServiceImpl.java | 106 +++++----- src/main/java/org/jeecg/modules/sap/dto/OrderBomDTO.java | 19 ++ src/main/java/org/jeecg/modules/sap/dto/OrderProcessDTO.java | 20 ++ src/main/java/org/jeecg/modules/sap/service/impl/OrderBomSyncImpl.java | 91 ++++++++++ src/main/java/org/jeecg/modules/sap/service/OrderBomSync.java | 12 + src/main/java/org/jeecg/modules/sap/service/SAPService.java | 10 src/main/java/org/jeecg/modules/sap/service/impl/OrderProcessSyncImpl.java | 93 ++++++++++ src/main/java/org/jeecg/modules/sap/service/ProductionOrderSync.java | 2 src/main/java/org/jeecg/modules/sap/service/impl/ProductionOrderSyncImpl.java | 116 +++++++----- 12 files changed, 424 insertions(+), 116 deletions(-) diff --git "a/db/\345\217\214\346\236\227\346\226\260\347\201\253\347\202\254MES\346\225\260\346\215\256\345\272\223\350\256\276\350\256\241.pdma.json" "b/db/\345\217\214\346\236\227\346\226\260\347\201\253\347\202\254MES\346\225\260\346\215\256\345\272\223\350\256\276\350\256\241.pdma.json" index eef16dd..19f8250 100644 --- "a/db/\345\217\214\346\236\227\346\226\260\347\201\253\347\202\254MES\346\225\260\346\215\256\345\272\223\350\256\276\350\256\241.pdma.json" +++ "b/db/\345\217\214\346\236\227\346\226\260\347\201\253\347\202\254MES\346\225\260\346\215\256\345\272\223\350\256\276\350\256\241.pdma.json" @@ -4,7 +4,7 @@ "avatar": "", "version": "4.9.2", "createdTime": "2025-3-10 16:38:19", - "updatedTime": "2025-7-30 14:19:17", + "updatedTime": "2025-7-31 10:26:58", "dbConns": [], "profile": { "default": { @@ -11305,7 +11305,7 @@ { "defKey": "work_order_status", "defName": "宸ュ崟鐘舵��", - "comment": "鏂板缓銆佸彂甯冦�侀噸鍙戝竷", + "comment": "鏂板缓銆佸凡鍙戝竷銆侀噸鍙戝竷", "type": "", "len": "", "scale": "", diff --git a/src/main/java/org/jeecg/modules/sap/controller/SAPTestController.java b/src/main/java/org/jeecg/modules/sap/controller/SAPTestController.java index b1a4451..3dda5ce 100644 --- a/src/main/java/org/jeecg/modules/sap/controller/SAPTestController.java +++ b/src/main/java/org/jeecg/modules/sap/controller/SAPTestController.java @@ -4,8 +4,9 @@ import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; import org.jeecg.common.api.vo.Result; +import org.jeecg.modules.sap.service.OrderBomSync; +import org.jeecg.modules.sap.service.OrderProcessSync; import org.jeecg.modules.sap.service.ProductionOrderSync; -import org.jeecg.modules.sap.service.SAPService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; @@ -18,22 +19,56 @@ @RequestMapping("/sap/client") @Slf4j public class SAPTestController { - @Autowired - private SAPService sapService; + //鏂扮伀鐐伐鍘傜紪鐮� + private static final String factoryCode = "2301"; + //鏍囧噯鐢熶骇璁㈠崟 + private static final String orderTypeCode1 = "Z001"; + //杩斿伐璁㈠崟 鏆傛椂涓嶇敤 + private static final String orderTypeCode2 = "Z002"; + //鍏垎鍘傝皟搴﹀憳 + // private static final String productionManager = "012"; + private static final String productionManager = "010"; + //鐢熶骇璁㈠崟鐘舵�� CRTD 鏂板缓锛孯EL 涓嬭揪锛孴ECO 鍏抽棴 瀹為檯涓婏紝鍙湁REL鐘舵�佺殑宸ュ崟鎵嶅彲浠ヨ繘琛屾搷浣� + private static final String orderStatus = "REL"; + + private static final String createTime = "20250508"; + private static final String updateTime = "20250101"; +// @Autowired +// private SAPService sapService; @Autowired private ProductionOrderSync productionOrderSync; + @Autowired + private OrderBomSync orderBomSync; + @Autowired + private OrderProcessSync orderProcessSync; - @ApiOperation(value = "SAP闆嗘垚娴嬭瘯-娴嬭瘯鎺ュ彛", notes = "SAP闆嗘垚娴嬭瘯-娴嬭瘯鎺ュ彛") - @GetMapping("/test") - public Result<?> test() { - String test = sapService.test(); - return Result.ok(test); - } +// @ApiOperation(value = "SAP闆嗘垚娴嬭瘯-娴嬭瘯鎺ュ彛", notes = "SAP闆嗘垚娴嬭瘯-娴嬭瘯鎺ュ彛") +// @GetMapping("/test") +// public Result<?> test() { +// String test = sapService.test(); +// return Result.ok(test); +// } @ApiOperation(value = "SAP闆嗘垚娴嬭瘯-鐢熶骇璁㈠崟鍚屾鎺ュ彛", notes = "SAP闆嗘垚娴嬭瘯-鐢熶骇璁㈠崟鍚屾鎺ュ彛") @GetMapping("/syncProductionOrder") public Result<?> syncProductionOrder() throws Exception { - Map<String, Object> resultMap = productionOrderSync.syncProductionOrder(); + Map<String, Object> resultMap = productionOrderSync.syncProductionOrder(factoryCode, orderTypeCode1, productionManager, orderStatus, createTime, null); + return Result.ok(resultMap); + } + + @ApiOperation(value = "SAP闆嗘垚娴嬭瘯-璁㈠崟BOM鍚屾", notes = "SAP闆嗘垚娴嬭瘯-璁㈠崟BOM鍚屾") + @GetMapping("/syncOrderBom") + public Result<?> syncOrderBom() throws Exception { + String orderCode = "10706312,10706988,10708077,10708078,10708825,10711404,10711404,10711543"; + Map<String, Object> resultMap = orderBomSync.syncOrderBom(factoryCode, orderCode); + return Result.ok(resultMap); + } + + @ApiOperation(value = "SAP闆嗘垚娴嬭瘯-璁㈠崟宸ュ簭鍚屾", notes = "SAP闆嗘垚娴嬭瘯-璁㈠崟宸ュ簭鍚屾") + @GetMapping("/syncOrderProcess") + public Result<?> syncOrderProcess() throws Exception { + String orderCode = "10706312,10706988,10708077,10708078,10708825,10711404,10711404,10711543"; + Map<String, Object> resultMap = orderProcessSync.syncOrderProcess(factoryCode, orderCode); return Result.ok(resultMap); } } diff --git a/src/main/java/org/jeecg/modules/sap/dto/OrderBomDTO.java b/src/main/java/org/jeecg/modules/sap/dto/OrderBomDTO.java new file mode 100644 index 0000000..6622759 --- /dev/null +++ b/src/main/java/org/jeecg/modules/sap/dto/OrderBomDTO.java @@ -0,0 +1,19 @@ +package org.jeecg.modules.sap.dto; + +import lombok.Data; + +@Data +public class OrderBomDTO { + /** 璁㈠崟鍙� */ + private String AUFNR; + /** 鐗╂枡鍙� */ + private String MATNR; + /** 宸ュ巶缂栧彿 */ + private String WERKS; + /** 鐗╂枡鎻忚堪锛堢煭鏂囨湰锛� */ + private String MAKTX; + /** 闇�姹傞噺 */ + private String BDMNG; + /** MEINS */ + private String MEINS; +} diff --git a/src/main/java/org/jeecg/modules/sap/dto/OrderProcessDTO.java b/src/main/java/org/jeecg/modules/sap/dto/OrderProcessDTO.java new file mode 100644 index 0000000..a0b59a5 --- /dev/null +++ b/src/main/java/org/jeecg/modules/sap/dto/OrderProcessDTO.java @@ -0,0 +1,20 @@ +package org.jeecg.modules.sap.dto; + +import lombok.Data; + +@Data +public class OrderProcessDTO { + /** 璁㈠崟鍙� */ + private String AUFNR; + /** 鐗╂枡鍙� */ + private String MATNR; + /** 鎿嶄綔/娲诲姩缂栧彿 */ + private String VORNR; + /** 宸ュ簭鐭枃鏈� */ + private String LTXA1; + /** 宸ュ巶 */ + private String WERKS; + /** 鎺у埗鐮� */ + private String STEUS; + +} diff --git a/src/main/java/org/jeecg/modules/sap/service/OrderBomSync.java b/src/main/java/org/jeecg/modules/sap/service/OrderBomSync.java new file mode 100644 index 0000000..d2b7403 --- /dev/null +++ b/src/main/java/org/jeecg/modules/sap/service/OrderBomSync.java @@ -0,0 +1,12 @@ +package org.jeecg.modules.sap.service; + +import java.util.Map; + +public interface OrderBomSync { + /** + * 鍚屾璁㈠崟BOM鏁版嵁 + * @return + * @throws Exception + */ + Map<String, Object> syncOrderBom(String factoryCode, String orderCode) throws Exception; +} diff --git a/src/main/java/org/jeecg/modules/sap/service/OrderProcessSync.java b/src/main/java/org/jeecg/modules/sap/service/OrderProcessSync.java new file mode 100644 index 0000000..1741685 --- /dev/null +++ b/src/main/java/org/jeecg/modules/sap/service/OrderProcessSync.java @@ -0,0 +1,12 @@ +package org.jeecg.modules.sap.service; + +import java.util.Map; + +public interface OrderProcessSync { + /** + * 鍚屾璁㈠崟宸ュ簭鏁版嵁 + * @return + * @throws Exception + */ + Map<String, Object> syncOrderProcess(String factoryCode, String orderCode) throws Exception; +} diff --git a/src/main/java/org/jeecg/modules/sap/service/ProductionOrderSync.java b/src/main/java/org/jeecg/modules/sap/service/ProductionOrderSync.java index 7cb68da..0ba41c1 100644 --- a/src/main/java/org/jeecg/modules/sap/service/ProductionOrderSync.java +++ b/src/main/java/org/jeecg/modules/sap/service/ProductionOrderSync.java @@ -6,5 +6,5 @@ /** * 鍚屾鐢熸垚璁㈠崟 */ - Map<String, Object> syncProductionOrder() throws Exception; + Map<String, Object> syncProductionOrder(String factoryCode, String orderTypeCode, String productionManager, String orderStatus, String createTime, String updateTime) throws Exception; } diff --git a/src/main/java/org/jeecg/modules/sap/service/SAPService.java b/src/main/java/org/jeecg/modules/sap/service/SAPService.java index d8bd863..84b6899 100644 --- a/src/main/java/org/jeecg/modules/sap/service/SAPService.java +++ b/src/main/java/org/jeecg/modules/sap/service/SAPService.java @@ -1,5 +1,5 @@ -package org.jeecg.modules.sap.service; - -public interface SAPService { - String test(); -} +//package org.jeecg.modules.sap.service; +// +//public interface SAPService { +// String test(); +//} diff --git a/src/main/java/org/jeecg/modules/sap/service/impl/OrderBomSyncImpl.java b/src/main/java/org/jeecg/modules/sap/service/impl/OrderBomSyncImpl.java new file mode 100644 index 0000000..ce7531d --- /dev/null +++ b/src/main/java/org/jeecg/modules/sap/service/impl/OrderBomSyncImpl.java @@ -0,0 +1,91 @@ +package org.jeecg.modules.sap.service.impl; + +import com.alibaba.fastjson.JSONObject; +import com.sap.conn.jco.*; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +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.OrderBomDTO; +import org.jeecg.modules.sap.service.OrderBomSync; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@Service +@Slf4j +public class OrderBomSyncImpl implements OrderBomSync { + @Autowired + private SapRfcConnectionManager connectionManager; + + @Override + @ApiLog(apiName = "璁㈠崟BOM鍚屾(ZPPF_033_3)", apiCategory = ApiLogCategoryEnum.SAP) + public Map<String, Object> syncOrderBom(String factoryCode, String orderCode) throws Exception { + Map<String, Object> resultMap = new HashMap<>(); + JCoDestination destination = connectionManager.getDestination(); + JCoRepository repository = destination.getRepository(); + JCoFunction function = repository.getFunction(FunctionConst.ZPPF_033_3); + if (function == null) { + throw new RuntimeException("RFC 鍑芥暟 ZPPF_033_3 鏈壘鍒帮紒"); + } + // 璁剧疆杈撳叆鍙傛暟 + List<JSONObject> items = new ArrayList<>(); + if(StringUtils.isNotBlank(factoryCode)){ + //鏂扮伀鐐� + JCoParameterList importParameterList = function.getImportParameterList(); + importParameterList.setValue("WERKS", factoryCode); + //缁勮璇锋眰鍙傛暟 + JSONObject item = new JSONObject(); + item.put("WERKS", factoryCode); + items.add(item); + } + if(StringUtils.isNotBlank(orderCode)) { + //鏂扮伀鐐� + JCoTable AUFNRTable = function.getTableParameterList().getTable("ZTAB_AUFNR"); + String[] split = orderCode.split(","); + for(String code : split){ + AUFNRTable.appendRow(); + AUFNRTable.setValue("AUFNR", code); + } + //缁勮璇锋眰鍙傛暟 + JSONObject item = new JSONObject(); + item.put("AUFNR", orderCode); + items.add(item); + } + // 鎵ц璋冪敤 + 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<OrderBomDTO> resultList = new ArrayList<>(); + OrderBomDTO dto; + for (int i = 0; i < numRows; i++) { + outputTable.setRow(i); + dto = new OrderBomDTO(); + dto.setAUFNR(outputTable.getString("AUFNR")); + dto.setMATNR(outputTable.getString("MATNR")); + dto.setWERKS(outputTable.getString("WERKS")); + dto.setMAKTX(outputTable.getString("MAKTX")); + dto.setBDMNG(outputTable.getString("BDMNG")); + dto.setMEINS(outputTable.getString("MEINS")); + + //娣诲姞缁撴灉闆� + 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; + } +} diff --git a/src/main/java/org/jeecg/modules/sap/service/impl/OrderProcessSyncImpl.java b/src/main/java/org/jeecg/modules/sap/service/impl/OrderProcessSyncImpl.java new file mode 100644 index 0000000..2fdd666 --- /dev/null +++ b/src/main/java/org/jeecg/modules/sap/service/impl/OrderProcessSyncImpl.java @@ -0,0 +1,93 @@ +package org.jeecg.modules.sap.service.impl; + +import com.alibaba.fastjson.JSONObject; +import com.sap.conn.jco.*; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +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.OrderBomDTO; +import org.jeecg.modules.sap.dto.OrderProcessDTO; +import org.jeecg.modules.sap.service.OrderProcessSync; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.*; + +@Service +@Slf4j +public class OrderProcessSyncImpl implements OrderProcessSync { + @Autowired + private SapRfcConnectionManager connectionManager; + + @Override + @ApiLog(apiName = "浜у搧宸ヨ壓璺嚎鍚屾(ZPPF_033_2)", apiCategory = ApiLogCategoryEnum.SAP) + public Map<String, Object> syncOrderProcess(String factoryCode, String orderCode) throws Exception { + Map<String, Object> resultMap = new HashMap<>(); + JCoDestination destination = connectionManager.getDestination(); + JCoRepository repository = destination.getRepository(); + JCoFunction function = repository.getFunction(FunctionConst.ZPPF_033_2); + if (function == null) { + throw new RuntimeException("RFC 鍑芥暟 ZPPF_033_2 鏈壘鍒帮紒"); + } + // 璁剧疆杈撳叆鍙傛暟 + List<JSONObject> items = new ArrayList<>(); + if(StringUtils.isNotBlank(factoryCode)){ + //鏂扮伀鐐� + JCoTable WERKSTable = function.getTableParameterList().getTable("ZTAB_WERKS"); + String[] split = factoryCode.split(","); + for(String code : split){ + WERKSTable.appendRow(); + WERKSTable.setValue("WERKS", code); + } + //缁勮璇锋眰鍙傛暟 + JSONObject item = new JSONObject(); + item.put("WERKS", factoryCode); + items.add(item); + } + if(StringUtils.isNotBlank(orderCode)) { + //鏂扮伀鐐� + JCoTable AUFNRTable = function.getTableParameterList().getTable("ZTAB_AUFNR"); + String[] split = orderCode.split(","); + for(String code : split){ + AUFNRTable.appendRow(); + AUFNRTable.setValue("AUFNR", code); + } + //缁勮璇锋眰鍙傛暟 + JSONObject item = new JSONObject(); + item.put("AUFNR", orderCode); + items.add(item); + } + // 鎵ц璋冪敤 + 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<OrderProcessDTO> resultList = new ArrayList<>(); + OrderProcessDTO dto; + for (int i = 0; i < numRows; i++) { + outputTable.setRow(i); + dto = new OrderProcessDTO(); + dto.setAUFNR(outputTable.getString("AUFNR")); + dto.setMATNR(outputTable.getString("MATNR")); + dto.setWERKS(outputTable.getString("WERKS")); + dto.setVORNR(outputTable.getString("VORNR")); + dto.setLTXA1(outputTable.getString("LTXA1")); + dto.setSTEUS(outputTable.getString("STEUS")); + + //娣诲姞缁撴灉闆� + 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; + } +} 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 9cb836b..002bb07 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 @@ -6,6 +6,7 @@ import com.sap.conn.jco.JCoRepository; import com.sap.conn.jco.JCoTable; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; import org.jeecg.common.aspect.annotation.ApiLog; import org.jeecg.common.constant.ApiLogCategoryEnum; import org.jeecg.config.sap.SapRfcConnectionManager; @@ -26,25 +27,13 @@ @Service @Slf4j public class ProductionOrderSyncImpl implements ProductionOrderSync { - //鏂扮伀鐐伐鍘傜紪鐮� - private static final String factoryCode = "2301"; - //鏍囧噯鐢熶骇璁㈠崟 - private static final String orderTypeCode1 = "Z001"; - //杩斿伐璁㈠崟 鏆傛椂涓嶇敤 - private static final String orderTypeCode2 = "Z002"; - //鍏垎鍘傝皟搴﹀憳 -// private static final String productionManager = "012"; - private static final String productionManager = "010"; - //鐢熶骇璁㈠崟鐘舵�� CRTD 鏂板缓锛孯EL 涓嬭揪锛孴ECO 鍏抽棴 瀹為檯涓婏紝鍙湁REL鐘舵�佺殑宸ュ崟鎵嶅彲浠ヨ繘琛屾搷浣� - private static final String orderStatus = "REL"; @Autowired private SapRfcConnectionManager connectionManager; - @Override - @ApiLog(apiName = "鐢熶骇璁㈠崟鍚屾鎺ュ彛(ZPPF_033_1)", apiCategory = ApiLogCategoryEnum.SAP) - public Map<String, Object> syncProductionOrder() throws Exception { + @ApiLog(apiName = "鐢熶骇璁㈠崟鍚屾(ZPPF_033_1)", apiCategory = ApiLogCategoryEnum.SAP) + public Map<String, Object> syncProductionOrder(String factoryCode, String orderTypeCode, String productionManager, String orderStatus, String createTime, String updateTime) throws Exception { Map<String, Object> resultMap = new HashMap<>(); JCoDestination destination = connectionManager.getDestination(); JCoRepository repository = destination.getRepository(); @@ -57,37 +46,74 @@ // 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); + if(StringUtils.isNotBlank(orderTypeCode)){ + JCoTable AUARTTable = function.getTableParameterList().getTable("ZTAB_AUART"); + String[] split = orderTypeCode.split(","); + for(String code : split){ + AUARTTable.appendRow(); + AUARTTable.setValue("AUART", code); + } + //缁勮璇锋眰鍙傛暟 + JSONObject item = new JSONObject(); + item.put("AUART", orderTypeCode); + items.add(item); + } + if(StringUtils.isNotBlank(productionManager)){ + JCoTable FEVORTable = function.getTableParameterList().getTable("ZTAB_FEVOR"); + String[] split = productionManager.split(","); + for(String code : split){ + FEVORTable.appendRow(); + FEVORTable.setValue("FEVOR", code); + } + //缁勮璇锋眰鍙傛暟 + JSONObject item = new JSONObject(); + item.put("FEVOR", productionManager); + items.add(item); + } + if(StringUtils.isNotBlank(factoryCode)){ + //鏂扮伀鐐� + JCoTable WERKSTable = function.getTableParameterList().getTable("ZTAB_WERKS"); + String[] split = factoryCode.split(","); + for(String code : split){ + WERKSTable.appendRow(); + WERKSTable.setValue("WERKS", code); + } + //缁勮璇锋眰鍙傛暟 + JSONObject item = new JSONObject(); + item.put("WERKS", factoryCode); + items.add(item); + } + if(StringUtils.isNotBlank(orderStatus)) { + //鏂扮伀鐐� + JCoTable TXT04Table = function.getTableParameterList().getTable("ZTAB_TXT04"); + String[] split = orderStatus.split(","); + for(String code : split){ + TXT04Table.appendRow(); + TXT04Table.setValue("TXT04", code); + } + //缁勮璇锋眰鍙傛暟 + JSONObject item = new JSONObject(); + item.put("TXT04", orderStatus); + items.add(item); + } + if(StringUtils.isNotBlank(createTime)){ + JCoTable UDATETable = function.getTableParameterList().getTable("ZTAB_UDATE"); + UDATETable.appendRow(); + UDATETable.setValue("LOW", createTime); + //缁勮璇锋眰鍙傛暟 + JSONObject item = new JSONObject(); + item.put("ZTAB_UDATE_LOW", createTime); + items.add(item); + } + if(StringUtils.isNotBlank(updateTime)){ + JCoTable LAEDATable = function.getTableParameterList().getTable("ZTAB_LAEDA"); + LAEDATable.appendRow(); + LAEDATable.setValue("LOW", updateTime); + //缁勮璇锋眰鍙傛暟 + JSONObject item = new JSONObject(); + item.put("ZTAB_LAEDA_LOW", updateTime); + items.add(item); + } // 鎵ц璋冪敤 function.execute(destination); //鑾峰彇杩斿洖缁撴灉 diff --git a/src/main/java/org/jeecg/modules/sap/service/impl/SAPServiceImpl.java b/src/main/java/org/jeecg/modules/sap/service/impl/SAPServiceImpl.java index db1a753..0d14e0e 100644 --- a/src/main/java/org/jeecg/modules/sap/service/impl/SAPServiceImpl.java +++ b/src/main/java/org/jeecg/modules/sap/service/impl/SAPServiceImpl.java @@ -1,53 +1,53 @@ -package org.jeecg.modules.sap.service.impl; - -import com.sap.conn.jco.*; -import lombok.SneakyThrows; -import lombok.extern.slf4j.Slf4j; -import org.jeecg.config.sap.SapRfcConnectionManager; -import org.jeecg.modules.sap.service.SAPService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import java.util.Arrays; -import java.util.Collections; - -@Service -@Slf4j -public class SAPServiceImpl implements SAPService { - @Autowired - private SapRfcConnectionManager connectionManager; - - @Override - public String test() { - JCoDestination destination = connectionManager.getDestination(); - try { - JCoRepository repository = destination.getRepository(); - JCoFunction function = repository.getFunction("ZPPF_022"); - - if (function == null) { - throw new RuntimeException("RFC 鍑芥暟妯″潡 ZPPF_022 鏈壘鍒帮紒"); - } - - // 璁剧疆杈撳叆鍙傛暟 - JCoTable inputTable = function.getTableParameterList().getTable("ZTAB_WERKS"); - inputTable.appendRow(); - inputTable.setValue("WERKS", "2301"); //鍙傛暟鍚嶉渶涓� SAP 鍑芥暟瀹氫箟涓�鑷� - - // 鎵ц璋冪敤 - function.execute(destination); - - // 鑾峰彇杈撳嚭鍙傛暟 - JCoTable outputTable = function.getTableParameterList().getTable("ZTAB_AUFNR"); - int numRows = outputTable.getNumRows(); - for (int i = 0; i < numRows; i++) { - outputTable.setRow(i); - log.info("Row {} : {}", i, outputTable.getString("AUFNR")); - } - - return String.valueOf(numRows); - } catch (JCoException e) { - log.error(e.getMessage(), e); - } - return null; - } -} +//package org.jeecg.modules.sap.service.impl; +// +//import com.sap.conn.jco.*; +//import lombok.SneakyThrows; +//import lombok.extern.slf4j.Slf4j; +//import org.jeecg.config.sap.SapRfcConnectionManager; +//import org.jeecg.modules.sap.service.SAPService; +//import org.springframework.beans.factory.annotation.Autowired; +//import org.springframework.stereotype.Service; +// +//import java.util.Arrays; +//import java.util.Collections; +// +//@Service +//@Slf4j +//public class SAPServiceImpl implements SAPService { +// @Autowired +// private SapRfcConnectionManager connectionManager; +// +// @Override +// public String test() { +// JCoDestination destination = connectionManager.getDestination(); +// try { +// JCoRepository repository = destination.getRepository(); +// JCoFunction function = repository.getFunction("ZPPF_022"); +// +// if (function == null) { +// throw new RuntimeException("RFC 鍑芥暟妯″潡 ZPPF_022 鏈壘鍒帮紒"); +// } +// +// // 璁剧疆杈撳叆鍙傛暟 +// JCoTable inputTable = function.getTableParameterList().getTable("ZTAB_WERKS"); +// inputTable.appendRow(); +// inputTable.setValue("WERKS", "2301"); //鍙傛暟鍚嶉渶涓� SAP 鍑芥暟瀹氫箟涓�鑷� +// +// // 鎵ц璋冪敤 +// function.execute(destination); +// +// // 鑾峰彇杈撳嚭鍙傛暟 +// JCoTable outputTable = function.getTableParameterList().getTable("ZTAB_AUFNR"); +// int numRows = outputTable.getNumRows(); +// for (int i = 0; i < numRows; i++) { +// outputTable.setRow(i); +// log.info("Row {} : {}", i, outputTable.getString("AUFNR")); +// } +// +// return String.valueOf(numRows); +// } catch (JCoException e) { +// log.error(e.getMessage(), e); +// } +// return null; +// } +//} -- Gitblit v1.9.3