新火炬后端单体项目初始化代码
zhangherong
7 天以前 1eefb88049771407e0d0f9c8711bd473e44a1ba6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
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;
    }
}