art: SAP 生产订单报工、投料、关闭接口初始代码
| | |
| | | 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.request.OrderLoadRequest; |
| | | import org.jeecg.modules.sap.request.OrderReportRequest; |
| | | import org.jeecg.modules.sap.service.*; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.Map; |
| | | |
| | | @Api(tags = "SAPéææµè¯") |
| | |
| | | private OrderBomSync orderBomSync; |
| | | @Autowired |
| | | private OrderProcessSync orderProcessSync; |
| | | @Autowired |
| | | private OrderReportService orderReportService; |
| | | @Autowired |
| | | private OrderLoadService orderLoadService; |
| | | @Autowired |
| | | private OrderCloseService orderCloseService; |
| | | |
| | | // @ApiOperation(value = "SAPéææµè¯-æµè¯æ¥å£", notes = "SAPéææµè¯-æµè¯æ¥å£") |
| | | // @GetMapping("/test") |
| | |
| | | Map<String, Object> resultMap = orderProcessSync.syncOrderProcess(factoryCode, orderCode); |
| | | return Result.ok(resultMap); |
| | | } |
| | | |
| | | @ApiOperation(value = "SAPéææµè¯-å·¥åºæ¥å·¥", notes = "SAPéææµè¯-å·¥åºæ¥å·¥") |
| | | @GetMapping("/productionOrderReport") |
| | | public Result<?> productionOrderReport() throws Exception { |
| | | OrderReportRequest request = new OrderReportRequest(); |
| | | request.setFactoryCode(factoryCode); |
| | | request.setOrderCode("10711404"); |
| | | request.setWarehouseCode("7014"); //2# çº¿è¾¹åº |
| | | request.setProcessCode("0040"); |
| | | request.setQualifiedQuantity(new BigDecimal("180")); |
| | | request.setScrapQuantity(new BigDecimal("0")); |
| | | request.setKeyProcess("202505080102"); |
| | | Map<String, Object> resultMap = orderReportService.productionOrderReport(request); |
| | | return Result.ok(resultMap); |
| | | } |
| | | |
| | | @ApiOperation(value = "SAPéææµè¯-çäº§è®¢åææ", notes = "SAPéææµè¯-çäº§è®¢åææ") |
| | | @GetMapping("/productionOrderLoad") |
| | | public Result<?> productionOrderLoad() throws Exception { |
| | | OrderLoadRequest request = new OrderLoadRequest(); |
| | | request.setFactoryCode(factoryCode); |
| | | request.setOrderCode("10711404"); |
| | | request.setWarehouseCode("7014"); //2# çº¿è¾¹åº |
| | | request.setMaterialNumber("320013727"); |
| | | request.setQuantity(new BigDecimal("180")); |
| | | request.setBatchNumber("202505080102"); |
| | | Map<String, Object> resultMap = orderLoadService.productionOrderLoad(request); |
| | | return Result.ok(resultMap); |
| | | } |
| | | |
| | | @ApiOperation(value = "SAPéææµè¯-ç产订åå
³é", notes = "SAPéææµè¯-ç产订åå
³é") |
| | | @GetMapping("/productionOrderClose") |
| | | public Result<?> productionOrderClose() throws Exception { |
| | | String orderCode = "10711404"; |
| | | Map<String, Object> resultMap = orderCloseService.productionOrderClose(orderCode); |
| | | return Result.ok(resultMap); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.jeecg.modules.sap.dto; |
| | | |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * ææè¿åç»æ |
| | | */ |
| | | @Data |
| | | public class OrderLoadDTO { |
| | | /** æ¶æ¯ç±»å: S æå,E é误,W è¦å,I ä¿¡æ¯,A 䏿 */ |
| | | private String TYPE; |
| | | /** æ¶æ¯ç±» */ |
| | | private String ID; |
| | | /** æ¶æ¯ç¼å· */ |
| | | private String NUMBER; |
| | | /** æ¶æ¯ææ¬ */ |
| | | private String MESSAGE; |
| | | /** åºç¨ç¨åºæ¥å¿: æ¥å¿å· */ |
| | | private String LOG_NO; |
| | | /** åºç¨æ¥å¿ï¼å
é¨é®ä»¶åºåå· */ |
| | | private String LOG_MSG_NO; |
| | | /** æ¶æ¯åé */ |
| | | private String MESSAGE_V1; |
| | | /** æ¶æ¯åé */ |
| | | private String MESSAGE_V2; |
| | | /** æ¶æ¯åé */ |
| | | private String MESSAGE_V3; |
| | | /** æ¶æ¯åé */ |
| | | private String MESSAGE_V4; |
| | | /** åæ°åç§° */ |
| | | private String PARAMETER; |
| | | /** åæ°ä¸çè¡ */ |
| | | private String ROW; |
| | | /** åæ°ä¸çåæ®µ */ |
| | | private String FIELD; |
| | | /** å¼åæ¶æ¯çé»è¾ç³»ç» */ |
| | | private String SYSTEM; |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.jeecg.modules.sap.dto; |
| | | |
| | | import lombok.Data; |
| | | |
| | | @Data |
| | | public class OrderReportDTO { |
| | | /** æ¶æ¯ç±»å: S æå,E é误,W è¦å,I ä¿¡æ¯,A 䏿 */ |
| | | private String TYPE; |
| | | /** æ¶æ¯ç±» */ |
| | | private String ID; |
| | | /** æ¶æ¯ç¼å· */ |
| | | private String NUMBER; |
| | | /** æ¶æ¯ææ¬ */ |
| | | private String MESSAGE; |
| | | /** åºç¨ç¨åºæ¥å¿: æ¥å¿å· */ |
| | | private String LOG_NO; |
| | | /** åºç¨æ¥å¿ï¼å
é¨é®ä»¶åºåå· */ |
| | | private String LOG_MSG_NO; |
| | | /** æ¶æ¯åé */ |
| | | private String MESSAGE_V1; |
| | | /** æ¶æ¯åé */ |
| | | private String MESSAGE_V2; |
| | | /** æ¶æ¯åé */ |
| | | private String MESSAGE_V3; |
| | | /** æ¶æ¯åé */ |
| | | private String MESSAGE_V4; |
| | | /** åæ°åç§° */ |
| | | private String PARAMETER; |
| | | /** åæ°ä¸çè¡ */ |
| | | private String ROW; |
| | | /** åæ°ä¸çåæ®µ */ |
| | | private String FIELD; |
| | | /** å¼åæ¶æ¯çé»è¾ç³»ç» */ |
| | | private String SYSTEM; |
| | | /** æ è¯ç¬¦: æ¡ç®å»ç» */ |
| | | private String FLG_LOCKED; |
| | | /** æä½å®æç确认ç¼å· */ |
| | | private String CONF_NO; |
| | | /** 确认计æ°å¨ */ |
| | | private String CONF_CNT; |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.jeecg.modules.sap.request; |
| | | |
| | | import lombok.Data; |
| | | |
| | | import java.math.BigDecimal; |
| | | |
| | | /** |
| | | * ææè¯·æ±åæ° |
| | | */ |
| | | @Data |
| | | public class OrderLoadRequest { |
| | | /** MATNR ç©æå· */ |
| | | private String materialNumber; |
| | | /** WERKS ç©æå· */ |
| | | private String factoryCode; |
| | | /** LGORT åºåå°ç¹ 线边ä»ç¼å· */ |
| | | private String warehouseCode; |
| | | /** CHARG æ¹å·*/ |
| | | private String batchNumber; |
| | | /** BWART ç§»å¨ç±»å(åºå管ç)*/ |
| | | private String moveType; |
| | | /** MENGE æ°é*/ |
| | | private BigDecimal quantity; |
| | | /** MEINS åºæ¬è®¡éåä½*/ |
| | | private String productionUnit; |
| | | /** AUFNR 订åå·*/ |
| | | private String orderCode; |
| | | /** SGTXT é¡¹ç®ææ¬ */ |
| | | private String itemContent; |
| | | /** SOBKZ ç¹æ®åºåæ è¯ */ |
| | | private String specialStockFlag ; |
| | | /** LIFNR ä¾åºåæåºæäººçå¸å·(ä¾åºå代ç )*/ |
| | | private String supplierCode; |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.jeecg.modules.sap.request; |
| | | |
| | | import lombok.Data; |
| | | |
| | | import java.math.BigDecimal; |
| | | |
| | | /** |
| | | * ç产订åå·¥åºæ¥å·¥ãå
¥åºãä¸åæ ¼å |
| | | * 请æ±ç±» |
| | | */ |
| | | @Data |
| | | public class OrderReportRequest { |
| | | /** I_WERKS å·¥å */ |
| | | private String factoryCode; |
| | | /** I_AUFNR 订åå· */ |
| | | private String orderCode; |
| | | /** I_VORNR å·¥åºç¼å· */ |
| | | private String processCode; |
| | | /** I_LMNGA åæ ¼æ°é */ |
| | | private BigDecimal qualifiedQuantity; |
| | | /** I_LGORT åºåå°ç¹ 线边ä»ç¼å· */ |
| | | private String warehouseCode; |
| | | /** I_CHARG æ¹å· äº§åæ¹æ¬¡å·ï¼SAP8ä½ï¼25070301ï¼ */ |
| | | private String batchNumber; |
| | | /** I_SGTXT é¡¹ç®ææ¬ */ |
| | | private String itemContent; |
| | | /** I_EQUNR 设å¤ç¼å·/èµæºç¼å· */ |
| | | private String equipmentCode; |
| | | /** I_EXTID MESç产åäºç»´ç å·ï¼éå¿
è¾ */ |
| | | private String qrCode; |
| | | /** I_NC_QTY æ¥åºæ°é */ |
| | | private BigDecimal scrapQuantity; |
| | | /** I_LOTNR å
³é®å·¥åº/å
³é®ç»ä»¶æ¹æ¬¡ */ |
| | | private String keyProcess; |
| | | /** I_MODUL æ¨¡ç©´æ° */ |
| | | private String cavityNumber; |
| | | /** I_SCRAP æ¥åºä¸å¡æ è¯ */ |
| | | private String scrapFlag; |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.jeecg.modules.sap.service; |
| | | |
| | | import java.util.Map; |
| | | |
| | | public interface OrderCloseService { |
| | | /** |
| | | * ç产订åå
³é |
| | | * @param orderCode |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | Map<String, Object> productionOrderClose(String orderCode) throws Exception; |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.jeecg.modules.sap.service; |
| | | |
| | | import org.jeecg.modules.sap.request.OrderLoadRequest; |
| | | |
| | | import java.util.Map; |
| | | |
| | | public interface OrderLoadService { |
| | | /** |
| | | * çäº§è®¢åææ |
| | | * @param request |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | Map<String, Object> productionOrderLoad(OrderLoadRequest request) throws Exception; |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.jeecg.modules.sap.service; |
| | | |
| | | import org.jeecg.modules.sap.request.OrderReportRequest; |
| | | |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * ç产订åå·¥åºæ¥å·¥ãå
¥åºãä¸åæ ¼å |
| | | */ |
| | | public interface OrderReportService { |
| | | /** |
| | | * å·¥åºæ¥å·¥ãç产订åå
¥åºãä¸åæ ¼åå¤ç |
| | | * @param request |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | Map<String, Object> productionOrderReport(OrderReportRequest request) throws Exception; |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.jeecg.modules.sap.service.impl; |
| | | |
| | | import com.sap.conn.jco.JCoDestination; |
| | | import com.sap.conn.jco.JCoFunction; |
| | | import com.sap.conn.jco.JCoParameterList; |
| | | import com.sap.conn.jco.JCoRepository; |
| | | 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.service.OrderCloseService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | | @Service |
| | | @Slf4j |
| | | public class OrderCloseServiceImpl implements OrderCloseService { |
| | | @Autowired |
| | | private SapRfcConnectionManager connectionManager; |
| | | |
| | | @Override |
| | | @ApiLog(apiName = "ç产订åå
³é(ZPPF_019)", apiCategory = ApiLogCategoryEnum.SAP) |
| | | public Map<String, Object> productionOrderClose(String orderCode) throws Exception { |
| | | Map<String, Object> resultMap = new HashMap<>(); |
| | | JCoDestination destination = connectionManager.getDestination(); |
| | | JCoRepository repository = destination.getRepository(); |
| | | JCoFunction function = repository.getFunction(FunctionConst.ZPPF_019); |
| | | if (function == null) { |
| | | throw new RuntimeException("RFC 彿° ZPPF_019 æªæ¾å°ï¼"); |
| | | } |
| | | //设置请æ±åæ° |
| | | JCoParameterList importParameterList = function.getImportParameterList(); |
| | | importParameterList.setValue("AUFNR", orderCode); |
| | | // æ§è¡è°ç¨ |
| | | function.execute(destination); |
| | | //è·åè¿åç»æ |
| | | String ztype = function.getExportParameterList().getTable("ZTYPE").toString(); |
| | | String zmess = function.getExportParameterList().getTable("ZMESS").toString(); |
| | | |
| | | resultMap.put("zmess", zmess); |
| | | resultMap.put("ztype", ztype); |
| | | resultMap.put("importParameters", orderCode); |
| | | resultMap.put("result", null); |
| | | return resultMap; |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.jeecg.modules.sap.service.impl; |
| | | |
| | | import com.sap.conn.jco.*; |
| | | 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.request.OrderLoadRequest; |
| | | import org.jeecg.modules.sap.service.OrderLoadService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | | @Service |
| | | @Slf4j |
| | | public class OrderLoadServiceImpl implements OrderLoadService { |
| | | @Autowired |
| | | private SapRfcConnectionManager connectionManager; |
| | | |
| | | @Override |
| | | @ApiLog(apiName = "çäº§è®¢åææ(ZMES_GOODSMVT_CREATE_2301)", apiCategory = ApiLogCategoryEnum.SAP) |
| | | public Map<String, Object> productionOrderLoad(OrderLoadRequest request) throws Exception { |
| | | Map<String, Object> resultMap = new HashMap<>(); |
| | | JCoDestination destination = connectionManager.getDestination(); |
| | | JCoRepository repository = destination.getRepository(); |
| | | JCoFunction function = repository.getFunction(FunctionConst.ZMES_GOODSMVT_CREATE_2301); |
| | | if (function == null) { |
| | | throw new RuntimeException("RFC 彿° ZMES_GOODSMVT_CREATE_2301 æªæ¾å°ï¼"); |
| | | } |
| | | //设置请æ±åæ° |
| | | JCoParameterList importParameterList = function.getImportParameterList(); |
| | | importParameterList.setValue("I_WERKS", request.getFactoryCode()); |
| | | importParameterList.setValue("I_AUFNR", request.getOrderCode()); |
| | | importParameterList.setValue("I_SGTXT", request.getItemContent()); |
| | | JCoTable table = function.getTableParameterList().getTable("T_ITEM"); |
| | | table.appendRow(); |
| | | table.setValue("MATNR", request.getMaterialNumber()); |
| | | table.setValue("WERKS", request.getFactoryCode()); |
| | | table.setValue("LGORT", request.getWarehouseCode()); |
| | | table.setValue("CHARG", request.getBatchNumber()); |
| | | table.setValue("BWART", request.getMoveType()); |
| | | table.setValue("MENGE", request.getQuantity()); |
| | | table.setValue("MEINS", request.getProductionUnit()); |
| | | table.setValue("AUFNR", request.getOrderCode()); |
| | | table.setValue("SGTXT", request.getItemContent()); |
| | | table.setValue("SOBKZ", request.getSpecialStockFlag()); |
| | | table.setValue("LIFNR", request.getSupplierCode()); |
| | | |
| | | // æ§è¡è°ç¨ |
| | | function.execute(destination); |
| | | //è·åè¿åç»æ |
| | | JCoTable eReturn = function.getExportParameterList().getTable("E_RETURN"); |
| | | JCoTable tReturn1 = function.getTableParameterList().getTable("T_RETURN"); |
| | | String zmess = ""; |
| | | String ztype = "";//S æ è¯ æå |
| | | |
| | | resultMap.put("zmess", zmess); |
| | | resultMap.put("ztype", ztype); |
| | | resultMap.put("importParameters", request); |
| | | resultMap.put("result", null); |
| | | return resultMap; |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.jeecg.modules.sap.service.impl; |
| | | |
| | | import com.sap.conn.jco.*; |
| | | 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.request.OrderReportRequest; |
| | | import org.jeecg.modules.sap.service.OrderReportService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | | @Service |
| | | @Slf4j |
| | | public class OrderReportServiceImpl implements OrderReportService { |
| | | @Autowired |
| | | private SapRfcConnectionManager connectionManager; |
| | | |
| | | @Override |
| | | @ApiLog(apiName = "å·¥åºæ¥å·¥ãç产订åå
¥åºãä¸åæ ¼åå¤ç(ZMES_PRODORDCONF_CREATE_TT2301)", apiCategory = ApiLogCategoryEnum.SAP) |
| | | public Map<String, Object> productionOrderReport(OrderReportRequest request) throws Exception { |
| | | Map<String, Object> resultMap = new HashMap<>(); |
| | | JCoDestination destination = connectionManager.getDestination(); |
| | | JCoRepository repository = destination.getRepository(); |
| | | JCoFunction function = repository.getFunction(FunctionConst.ZMES_PRODORDCONF_CREATE_TT2301); |
| | | if (function == null) { |
| | | throw new RuntimeException("RFC 彿° ZMES_PRODORDCONF_CREATE_TT2301 æªæ¾å°ï¼"); |
| | | } |
| | | //设置请æ±åæ° |
| | | JCoParameterList importParameterList = function.getImportParameterList(); |
| | | importParameterList.setValue("I_WERKS", request.getFactoryCode()); |
| | | importParameterList.setValue("I_AUFNR", request.getOrderCode()); |
| | | importParameterList.setValue("I_VORNR", request.getProcessCode()); |
| | | importParameterList.setValue("I_LMNGA", request.getQualifiedQuantity()); |
| | | importParameterList.setValue("I_LGORT", request.getWarehouseCode()); |
| | | importParameterList.setValue("I_CHARG", request.getBatchNumber()); |
| | | importParameterList.setValue("I_SGTXT", request.getItemContent()); |
| | | importParameterList.setValue("I_EQUNR", request.getEquipmentCode()); |
| | | importParameterList.setValue("I_EXTID", request.getQrCode()); |
| | | importParameterList.setValue("I_NC_QTY", request.getScrapQuantity()); |
| | | importParameterList.setValue("I_LOTNR", request.getKeyProcess()); |
| | | importParameterList.setValue("I_MODUL", request.getCavityNumber()); |
| | | importParameterList.setValue("I_SCRAP", request.getScrapFlag()); |
| | | // æ§è¡è°ç¨ |
| | | function.execute(destination); |
| | | //è·åè¿åç»æ |
| | | JCoTable eReturn = function.getExportParameterList().getTable("E_RETURN"); |
| | | JCoTable tReturn1 = function.getTableParameterList().getTable("T_RETURN"); |
| | | String zmess = ""; |
| | | String ztype = "";//S æ è¯ æå |
| | | |
| | | resultMap.put("zmess", zmess); |
| | | resultMap.put("ztype", ztype); |
| | | resultMap.put("importParameters", request); |
| | | resultMap.put("result", null); |
| | | return resultMap; |
| | | } |
| | | } |