¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.jeecg.modules.sap.service.impl; |
| | | |
| | | import com.sap.conn.jco.*; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.jeecg.config.sap.SapRfcConnectionManager; |
| | | import org.jeecg.modules.sap.FunctionConst; |
| | | import org.jeecg.modules.sap.dto.ProductionOrderDTO; |
| | | import org.jeecg.modules.sap.service.ProductionOrderSync; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * çæè®¢å忥æå¡ |
| | | */ |
| | | @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 |
| | | public void syncProductionOrder() { |
| | | 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("è·å订åä¿¡æ¯å¤±è´¥ï¼ZTYPE={}, 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); |
| | | } |
| | | } |
| | | } |