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.dto.OrderReportDTO;
|
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);
|
//获取返回结果
|
Object eReturn1 = function.getExportParameterList().getValue("E_RETURN");
|
OrderReportDTO reportDTO1 = null;
|
if (eReturn1 != null) {
|
JCoStructure eReturn = (JCoStructure) eReturn1;
|
//E Return
|
reportDTO1 = new OrderReportDTO();
|
reportDTO1.setTYPE(eReturn.getString("TYPE"));
|
reportDTO1.setID(eReturn.getString("ID"));
|
reportDTO1.setNUMBER(eReturn.getString("NUMBER"));
|
reportDTO1.setMESSAGE(eReturn.getString("MESSAGE"));
|
reportDTO1.setLOG_NO(eReturn.getString("LOG_NO"));
|
reportDTO1.setLOG_MSG_NO(eReturn.getString("LOG_MSG_NO"));
|
reportDTO1.setMESSAGE_V1(eReturn.getString("MESSAGE_V1"));
|
reportDTO1.setMESSAGE_V2(eReturn.getString("MESSAGE_V2"));
|
reportDTO1.setMESSAGE_V3(eReturn.getString("MESSAGE_V3"));
|
reportDTO1.setMESSAGE_V4(eReturn.getString("MESSAGE_V4"));
|
reportDTO1.setPARAMETER(eReturn.getString("PARAMETER"));
|
reportDTO1.setROW(eReturn.getString("ROW"));
|
reportDTO1.setFIELD(eReturn.getString("FIELD"));
|
reportDTO1.setSYSTEM(eReturn.getString("SYSTEM"));
|
reportDTO1.setFLG_LOCKED(eReturn.getString("FLG_LOCKED"));
|
reportDTO1.setCONF_NO(eReturn.getString("CONF_NO"));
|
reportDTO1.setCONF_CNT(eReturn.getString("CONF_CNT"));
|
}
|
JCoTable tReturn1 = function.getTableParameterList().getTable("T_RETURN");
|
OrderReportDTO reportDTO2 = null;
|
if (tReturn1.getNumRows() > 0) {
|
tReturn1.setRow(0);
|
reportDTO2 = new OrderReportDTO();
|
reportDTO2.setTYPE(tReturn1.getString("TYPE"));
|
reportDTO2.setID(tReturn1.getString("ID"));
|
reportDTO2.setNUMBER(tReturn1.getString("NUMBER"));
|
reportDTO2.setMESSAGE(tReturn1.getString("MESSAGE"));
|
reportDTO2.setLOG_NO(tReturn1.getString("LOG_NO"));
|
reportDTO2.setLOG_MSG_NO(tReturn1.getString("LOG_MSG_NO"));
|
reportDTO2.setMESSAGE_V1(tReturn1.getString("MESSAGE_V1"));
|
reportDTO2.setMESSAGE_V2(tReturn1.getString("MESSAGE_V2"));
|
reportDTO2.setMESSAGE_V3(tReturn1.getString("MESSAGE_V3"));
|
reportDTO2.setMESSAGE_V4(tReturn1.getString("MESSAGE_V4"));
|
reportDTO2.setPARAMETER(tReturn1.getString("PARAMETER"));
|
reportDTO2.setROW(tReturn1.getString("ROW"));
|
reportDTO2.setFIELD(tReturn1.getString("FIELD"));
|
reportDTO2.setSYSTEM(tReturn1.getString("SYSTEM"));
|
reportDTO2.setFLG_LOCKED(tReturn1.getString("FLG_LOCKED"));
|
reportDTO2.setCONF_NO(tReturn1.getString("CONF_NO"));
|
reportDTO2.setCONF_CNT(tReturn1.getString("CONF_CNT"));
|
}
|
|
String zmess = reportDTO1 == null ? (reportDTO2 == null ? "" : reportDTO2.getMESSAGE()) : reportDTO1.getMESSAGE();
|
String ztype = reportDTO1 == null ? (reportDTO2 == null ? "" : reportDTO2.getTYPE()) : reportDTO1.getTYPE(); //S 标识 成功
|
|
resultMap.put("zmess", zmess);
|
resultMap.put("ztype", ztype);
|
resultMap.put("importParameters", request);
|
resultMap.put("result", reportDTO1 == null ? reportDTO2 : reportDTO1);
|
return resultMap;
|
}
|
}
|