新火炬后端单体项目初始化代码
cuilei
2 天以前 c71714508fbe3ace3543423c7700d7bbcca90056
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
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().getValue("ZTYPE").toString();
        String zmess = function.getExportParameterList().getValue("ZMESS").toString();
 
        resultMap.put("zmess", zmess);
        resultMap.put("ztype", ztype);
        resultMap.put("importParameters", orderCode);
        resultMap.put("result", null);
        return resultMap;
    }
}