| | |
| | | "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": { |
| | |
| | | { |
| | | "defKey": "work_order_status", |
| | | "defName": "å·¥åç¶æ", |
| | | "comment": "æ°å»ºãåå¸ãéåå¸", |
| | | "comment": "æ°å»ºãå·²åå¸ãéåå¸", |
| | | "type": "", |
| | | "len": "", |
| | | "scale": "", |
| | |
| | | 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; |
| | |
| | | @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 æ°å»ºï¼REL ä¸è¾¾ï¼TECO å
³é å®é
ä¸ï¼åªæ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); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | 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; |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | 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; |
| | | |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | 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; |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | 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; |
| | | } |
| | |
| | | /** |
| | | * 忥çæè®¢å |
| | | */ |
| | | Map<String, Object> syncProductionOrder() throws Exception; |
| | | Map<String, Object> syncProductionOrder(String factoryCode, String orderTypeCode, String productionManager, String orderStatus, String createTime, String updateTime) throws Exception; |
| | | } |
| | |
| | | package org.jeecg.modules.sap.service; |
| | | |
| | | public interface SAPService { |
| | | String test(); |
| | | } |
| | | //package org.jeecg.modules.sap.service; |
| | | // |
| | | //public interface SAPService { |
| | | // String test(); |
| | | //} |
¶Ô±ÈÐÂÎļþ |
| | |
| | | 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; |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | 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; |
| | | } |
| | | } |
| | |
| | | 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; |
| | |
| | | @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 æ°å»ºï¼REL ä¸è¾¾ï¼TECO å
³é å®é
ä¸ï¼åªæ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(); |
| | |
| | | // 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); |
| | | //è·åè¿åç»æ |
| | |
| | | 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; |
| | | // } |
| | | //} |