新火炬后端单体项目初始化代码
zhangherong
10 天以前 e6d788eef335aa02ac306e984c44affa68ab971c
src/main/java/org/jeecg/modules/sap/service/impl/ProductionOrderSyncImpl.java
@@ -1,7 +1,13 @@
package org.jeecg.modules.sap.service.impl;
import com.sap.conn.jco.*;
import com.alibaba.fastjson.JSONObject;
import com.sap.conn.jco.JCoDestination;
import com.sap.conn.jco.JCoFunction;
import com.sap.conn.jco.JCoRepository;
import com.sap.conn.jco.JCoTable;
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.dto.ProductionOrderDTO;
@@ -10,7 +16,9 @@
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * 生成订单同步服务
@@ -35,9 +43,10 @@
    @Override
    public void syncProductionOrder() {
    @ApiLog(apiName = "生产订单同步接口(ZPPF_033_1)", apiCategory = ApiLogCategoryEnum.SAP)
    public Map<String, Object> syncProductionOrder() throws Exception {
        Map<String, Object> resultMap = new HashMap<>();
        JCoDestination destination = connectionManager.getDestination();
        try {
            JCoRepository repository = destination.getRepository();
            JCoFunction function = repository.getFunction(FunctionConst.ZPPF_033_1);
            if (function == null) {
@@ -46,31 +55,44 @@
            // 设置输入参数
            //订单号查询条件
//            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);
            // 执行调用
            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();
@@ -108,8 +130,10 @@
                resultList.add(dto);
                log.info(dto.toString());
            }
        } catch (JCoException e) {
            log.error(e.getMessage(), e);
        }
        resultMap.put("zmess", zmess);
        resultMap.put("ztype", ztype);
        resultMap.put("importParameters", items);
        resultMap.put("result", resultList);
        return resultMap;
    }
}