增加SAP模块日志

highway
Yangwl 12 months ago
parent e24b2f8a6d
commit b20b6e63d9

@ -377,6 +377,8 @@ public class SapController extends BaseController {
}
@PostMapping("/sapMaterialPosting")
@Log(title = "订单物料领料过账、原材料补料、订单物料退料过账接口MB1A", businessType = BusinessType.SAP)
public R sapMaterialPosting(@RequestBody SapMaterialPosting sapMaterialPosting){

@ -8,11 +8,125 @@ public class SapPurchaseOrderQuery {
* S_MATNR
* S_PWERK
*/
/**
* EBELN
* EBELP
* MATNR
* MAKTX
* MENGE
* MEINS
* ZMENGE
* ZMEINS
* LIFNR
* WERKS
* LGORT
* EINDT
* ELIKZ
* BEIZHU
*/
private String ebeln;
private String ebelp;
private String matnr;
private String pwerk;
private String maktx;
private String menge;
private String meins;
private String zmenge;
private String zmeins;
private String lifnr;
private String werks;
private String lgort;
private String eindt;
private String elikz;
private String beizhu;
public String getMaktx() {
return maktx;
}
public void setMaktx(String maktx) {
this.maktx = maktx;
}
public String getMenge() {
return menge;
}
public void setMenge(String menge) {
this.menge = menge;
}
public String getMeins() {
return meins;
}
public void setMeins(String meins) {
this.meins = meins;
}
public String getZmenge() {
return zmenge;
}
public void setZmenge(String zmenge) {
this.zmenge = zmenge;
}
public String getZmeins() {
return zmeins;
}
public void setZmeins(String zmeins) {
this.zmeins = zmeins;
}
public String getLifnr() {
return lifnr;
}
public void setLifnr(String lifnr) {
this.lifnr = lifnr;
}
public String getWerks() {
return werks;
}
public void setWerks(String werks) {
this.werks = werks;
}
public String getLgort() {
return lgort;
}
public void setLgort(String lgort) {
this.lgort = lgort;
}
public String getEindt() {
return eindt;
}
public void setEindt(String eindt) {
this.eindt = eindt;
}
public String getElikz() {
return elikz;
}
public void setElikz(String elikz) {
this.elikz = elikz;
}
public String getBeizhu() {
return beizhu;
}
public void setBeizhu(String beizhu) {
this.beizhu = beizhu;
}
public String getEbeln() {
return ebeln;

@ -1,5 +1,6 @@
package com.op.sap.service.impl;
import com.alibaba.fastjson2.JSONObject;
import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder;
import com.op.common.core.constant.Constants;
import com.op.common.core.domain.R;
@ -54,6 +55,7 @@ public class SapItemSyncImpl implements SapItemSyncService {
// 获取调用 RFC 函数对象
//获取连接
// JCoDestination dest = SAPConnUtils.connect();
log.info("物料基础数据同步输入参数---------"+JSONObject.toJSONString(sapItemQuery));
JCoRepository repository = dest.getRepository();
JCoFunction func = repository.getFunction("ZMMR_MES_MAT_GET");
@ -104,7 +106,7 @@ public class SapItemSyncImpl implements SapItemSyncService {
// 获取 内表 - ZMES_PRO
JCoTable maraTable = func.getTableParameterList().getTable("LT_MARA");
JCoRecordMetaData metaData = maraTable.getRecordMetaData();
System.out.println("###" + metaData.toString());
// System.out.println("###" + metaData.toString());
// 加载数据源
DynamicDataSourceContextHolder.push("ds_1000");
List<SapBaseProduct> sapBaseProductList=new ArrayList<>();
@ -143,35 +145,64 @@ public class SapItemSyncImpl implements SapItemSyncService {
String MVGR5_NM = maraTable.getString("MVGR5_NM");
String LAEDA = maraTable.getString("LAEDA");
String ERSDA = maraTable.getString("LAEDA");
System.out.println(
log.info("物料基础数据同步数据输出----"+
"物料号:" + MATNR+
"物料描述(短文本):" + MAKTX+
"国际文件号(EAN/UPC)" + EAN11+
"物料类型:" + MTART+
"物料类型描述:" + MTBEZ+
"物料组:" + MATKL+
"物料组描述:" + WGBEZ+
"毛重:" + BRGEW+
"净重:" + NTGEW+
"体积:" + VOLUM+
"体积单位:" + VOLEH+
"基本计量单位:" + MEINS+
"帐面库存单位的可选计量单位 " + MEINH+
"基本计量单位转换分子:" + UMREZ+
"转换为基本计量单位的分母:" + UMREN+
"在客户级标记要删除的物料:" + LVORM+
"数量:" + MENGE+
"总货架寿命 " + MHDHB+
"产品组:" + SPART+
"产品组描述:" + SPART_NM+
"物料组1" + MVGR1+
"物料组1描述" + MVGR1_NM+
"物料组2" + MVGR2+
"物料组2描述" + MVGR2_NM+
" 物料组3" + MVGR3+
" 物料组描述 " + MVGR3_NM+
"创建日期:"+ERSDA+
"物料描述(短文本):" + MAKTX+
"国际文件号(EAN/UPC)" + EAN11+
"物料类型:" + MTART+
"物料类型描述:" + MTBEZ+
"物料组:" + MATKL+
"物料组描述:" + WGBEZ+
"毛重:" + BRGEW+
"净重:" + NTGEW+
"体积:" + VOLUM+
"体积单位:" + VOLEH+
"基本计量单位:" + MEINS+
"帐面库存单位的可选计量单位 " + MEINH+
"基本计量单位转换分子:" + UMREZ+
"转换为基本计量单位的分母:" + UMREN+
"在客户级标记要删除的物料:" + LVORM+
"数量:" + MENGE+
"总货架寿命 " + MHDHB+
"产品组:" + SPART+
"产品组描述:" + SPART_NM+
"物料组1" + MVGR1+
"物料组1描述" + MVGR1_NM+
"物料组2" + MVGR2+
"物料组2描述" + MVGR2_NM+
" 物料组3" + MVGR3+
" 物料组描述 " + MVGR3_NM+
"创建日期:"+ERSDA+
"上次更改日期:"+LAEDA);
// System.out.println(
// "物料号:" + MATNR+
// "物料描述(短文本):" + MAKTX+
// "国际文件号(EAN/UPC)" + EAN11+
// "物料类型:" + MTART+
// "物料类型描述:" + MTBEZ+
// "物料组:" + MATKL+
// "物料组描述:" + WGBEZ+
// "毛重:" + BRGEW+
// "净重:" + NTGEW+
// "体积:" + VOLUM+
// "体积单位:" + VOLEH+
// "基本计量单位:" + MEINS+
// "帐面库存单位的可选计量单位 " + MEINH+
// "基本计量单位转换分子:" + UMREZ+
// "转换为基本计量单位的分母:" + UMREN+
// "在客户级标记要删除的物料:" + LVORM+
// "数量:" + MENGE+
// "总货架寿命 " + MHDHB+
// "产品组:" + SPART+
// "产品组描述:" + SPART_NM+
// "物料组1" + MVGR1+
// "物料组1描述" + MVGR1_NM+
// "物料组2" + MVGR2+
// "物料组2描述" + MVGR2_NM+
// " 物料组3" + MVGR3+
// " 物料组描述 " + MVGR3_NM+
// "创建日期:"+ERSDA+
// "上次更改日期:"+LAEDA);
baseProduct.setProductCode(MATNR);
baseProduct.setProductDescZh(MAKTX);
baseProduct.setProductGroup(MATKL);
@ -314,7 +345,7 @@ public class SapItemSyncImpl implements SapItemSyncService {
// int failureNum = 0;
// StringBuilder successMsg = new StringBuilder();
// StringBuilder failureMsg = new StringBuilder();
// log.info("反冲物料开始过账----------------------------------------");
log.info("反冲物料开始过账----------------------------------------");
// for (int i = 0; i < sapBackflushMPQueryList.size(); i++) {
// L_ITEM.setRow(i);
@ -340,6 +371,26 @@ public class SapItemSyncImpl implements SapItemSyncService {
L_ITEM.setValue("MOVE_BATCH",sfp.getMove_batch());
}
func.execute(dest);
JCoTable maraTable = func.getTableParameterList().getTable("LT_RETURN");
JCoRecordMetaData metaData = maraTable.getRecordMetaData();
System.out.println("###" + metaData.toString());
for (int i = 0; i < maraTable.getNumRows(); i++) {
maraTable.setRow(i);
String TYPE = maraTable.getString("TYPE");
System.out.println(TYPE);
}
String L_MSG= func.getExportParameterList().getString("L_MSG");
String RETCODE= func.getExportParameterList().getString("RETCODE");
String MATERIALDOCUMENT= func.getExportParameterList().getString("MATERIALDOCUMENT");
String MATDOCUMENTYEAR= func.getExportParameterList().getString("MATDOCUMENTYEAR");
System.out.println(L_MSG);
System.out.println(RETCODE);
System.out.println(MATERIALDOCUMENT);
System.out.println(MATDOCUMENTYEAR);
return R.ok();
}catch (Exception e){

@ -8,6 +8,8 @@ import com.op.sap.service.SapMaterialPreparationService;
import com.op.sap.util.SAPConnUtils;
import com.op.system.api.domain.sap.SapMaterialPreparation;
import com.sap.conn.jco.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
@ -18,7 +20,7 @@ import java.util.List;
@Component
@Service
public class SapMaterialPreparationServiceImpl implements SapMaterialPreparationService {
private static final Logger log = LoggerFactory.getLogger(SapMaterialPreparationServiceImpl.class);
@Autowired
SapMaterialPreparationMapper sapMaterialPreparationMapper;
@ -33,6 +35,7 @@ public class SapMaterialPreparationServiceImpl implements SapMaterialPreparation
// 获取调用 RFC 函数对象
//获取连接
// JCoDestination dest = SAPConnUtils.connect();
log.info("备料单入参-----"+shopOrder);
JCoRepository repository = dest.getRepository();
JCoFunction func = repository.getFunction("ZPPR_MES_MATERIAL_PREPARATION");
if (func == null) {
@ -48,7 +51,7 @@ public class SapMaterialPreparationServiceImpl implements SapMaterialPreparation
// 获取 内表 - ZMES_PRO
JCoTable maraTable = func.getTableParameterList().getTable("LT_MAPRE");
JCoRecordMetaData metaData = maraTable.getRecordMetaData();
System.out.println("###" + metaData.toString());
//System.out.println("###" + metaData.toString());
List<SapMaterialPreparation> sapMaterialPreparationList =new ArrayList<>();
// 循环输出 Table 数据
@ -66,7 +69,7 @@ public class SapMaterialPreparationServiceImpl implements SapMaterialPreparation
String MEINS = maraTable.getString("MEINS");
String RGEKZ = maraTable.getString("RGEKZ");
String DBSKZ = maraTable.getString("DBSKZ");
System.out.println("订单号:" + AUFNR
log.info( "备料单输出------"+ "订单号:" + AUFNR
+ " - 预留/相关需求的项目编号:" + RSPOS +
" - 物料号:" + MATNR +
" - 物料描述(短文本):" + MAKTX +
@ -78,6 +81,18 @@ public class SapMaterialPreparationServiceImpl implements SapMaterialPreparation
" - 基本计量单位:" + MEINS +
" - 标识:反冲:" + RGEKZ +
" - 直接采购标识:" + DBSKZ );
// System.out.println("订单号:" + AUFNR
// + " - 预留/相关需求的项目编号:" + RSPOS +
// " - 物料号:" + MATNR +
// " - 物料描述(短文本):" + MAKTX +
// " - 工厂:" + WERKS +
// " - 库存地点:" + LGORT +
// " - 组件的需求日期 " + BDTER +
// " - 需求量:" + BDMNG +
// " - 欠料数量:" + ZQLSL +
// " - 基本计量单位:" + MEINS +
// " - 标识:反冲:" + RGEKZ +
// " - 直接采购标识:" + DBSKZ );
SapMaterialPreparation sapMaterialPreparation = new SapMaterialPreparation();
sapMaterialPreparation.setAUFNR(AUFNR);
sapMaterialPreparation.setBDMNG(BDMNG);
@ -93,8 +108,10 @@ public class SapMaterialPreparationServiceImpl implements SapMaterialPreparation
sapMaterialPreparation.setZQLSL(ZQLSL);
sapMaterialPreparationList.add(sapMaterialPreparation);
}
return R.ok(sapMaterialPreparationList);
String MSG= func.getExportParameterList().getString("MSG");
return R.ok(sapMaterialPreparationList,MSG);
} catch (Exception e) {
log.error("同步领料单报错-----"+e.getMessage());
return R.fail(e.getMessage());
}
}

@ -18,6 +18,8 @@ import com.op.system.api.domain.sap.SapShopOrderQuery;
import com.op.system.api.model.SapProOrder;
import com.sap.conn.jco.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
@ -31,7 +33,7 @@ import java.util.Map;
@Component
@Service
public class SapOrderServiceImpl implements SapOrderService {
private static final Logger log = LoggerFactory.getLogger(SapOrderServiceImpl.class);
private static final String END_DATE="99991231";
@Autowired
private JCoDestination dest;
@ -43,6 +45,7 @@ public class SapOrderServiceImpl implements SapOrderService {
// 获取调用 RFC 函数对象
//获取连接
//JCoDestination dest = SAPConnUtils.connect();
log.info("订单同步入参-----"+sapShopOrderQuery.toString());
JCoRepository repository = dest.getRepository();
JCoFunction func = repository.getFunction("ZPPR_MES_PRO_TO");
if (func == null) {
@ -51,8 +54,8 @@ public class SapOrderServiceImpl implements SapOrderService {
JCoParameterList jCoParameterList= func.getTableParameterList();
JCoParameterList js= func.getExportParameterList();
System.out.println(js);
System.out.println(jCoParameterList);
// System.out.println(js);
// System.out.println(jCoParameterList);
// 配置传入参数
// S_WERKS(工厂) S_AUFNR订单号 S_MATNR物料号 S_ERDAT(创建日期) 例如20230923
@ -95,7 +98,7 @@ public class SapOrderServiceImpl implements SapOrderService {
// 获取 内表 - ZMES_PRO
JCoTable maraTable = func.getTableParameterList().getTable("ZMES_PRO");
JCoRecordMetaData metaData = maraTable.getRecordMetaData();
System.out.println("###" + metaData.toString());
// System.out.println("###" + metaData.toString());
List<SapProOrder> proOrderList = new ArrayList<>();
// 循环输出 Table 数据
@ -115,9 +118,12 @@ public class SapOrderServiceImpl implements SapOrderService {
String ERNAM = maraTable.getString("ERNAM");
String ERDAT = maraTable.getString("ERDAT");
String STTXT = maraTable.getString("STTXT");
System.out.println("订单号:" + AUFNR + " - 订单类型:" + AUART + " - 上级订单编号:" + MAUFNR + " - 物料号:" + PLNBEZ + " - 物料描述(短文本):" + MAKTX
log.info("订单输出------"+"订单号:" + AUFNR + " - 订单类型:" + AUART + " - 上级订单编号:" + MAUFNR + " - 物料号:" + PLNBEZ + " - 物料描述(短文本):" + MAKTX
+ " - 订单的计划工厂:" + PWERK + " - 订单数量总计:" + GAMNG + " - 基本计量单位:" + GMEIN + " - 任务清单组码:" + PLNNR + " - 基本开始日期:" + GSTRP
+ " - 基本完成日期:" + GLTRP + " - 输入者:" + ERNAM + " - 创建日期:" + ERDAT + " - 系统状态:" + STTXT);
// System.out.println("订单号:" + AUFNR + " - 订单类型:" + AUART + " - 上级订单编号:" + MAUFNR + " - 物料号:" + PLNBEZ + " - 物料描述(短文本):" + MAKTX
// + " - 订单的计划工厂:" + PWERK + " - 订单数量总计:" + GAMNG + " - 基本计量单位:" + GMEIN + " - 任务清单组码:" + PLNNR + " - 基本开始日期:" + GSTRP
// + " - 基本完成日期:" + GLTRP + " - 输入者:" + ERNAM + " - 创建日期:" + ERDAT + " - 系统状态:" + STTXT);
SapProOrder proOrder = new SapProOrder();
proOrder.setId(IdUtils.fastSimpleUUID());
proOrder.setPlanFactoryCode(PWERK);
@ -145,7 +151,7 @@ public class SapOrderServiceImpl implements SapOrderService {
return R.ok(proOrderList);
} catch (Exception e) {
System.out.println(e.getMessage());
return R.fail(e.getMessage());
}
}
@ -156,6 +162,7 @@ public class SapOrderServiceImpl implements SapOrderService {
try {
//获取连接
// JCoDestination dest = SAPConnUtils.connect();
log.info("订单创建入参-----"+JSONObject.toJSONString(sapCreateOrderList));
JCoRepository repository = dest.getRepository();
JCoFunction func = repository.getFunction("ZPPR_MES_PRODORD_CREATE");
if (func == null) {
@ -176,12 +183,12 @@ public class SapOrderServiceImpl implements SapOrderService {
jCoParameterList.setValue("P_DATEE",sapCreateOrder.getDatee());
func.execute(dest);//执行调用函数
JCoParameterList J= func.getExportParameterList();
System.out.println(J);
// System.out.println(J);
L_MSG= func.getExportParameterList().getString("L_MSG");
String LV_ORDER_NUMBER= func.getExportParameterList().getString("LV_ORDER_NUMBER");
JCoTable LT_ZGD=func.getTableParameterList().getTable("LT_ZGD");
System.out.println(LT_ZGD);
// System.out.println(LT_ZGD);
//DynamicDataSourceContextHolder.push("ds_1000");//controller已经完成切换
for (int i = 0; i <LT_ZGD.getNumRows(); i++) {
LT_ZGD.setRow(i);
@ -193,11 +200,14 @@ public class SapOrderServiceImpl implements SapOrderService {
LV_ORDER_NUM_List.add(map);
}
}
log.info("订单创建结果----"+L_MSG+"|"+JSONObject.toJSONString(LV_ORDER_NUM_List));
return R.ok(LV_ORDER_NUM_List,L_MSG);
}else {
log.error("接收的数据为空");
return R.fail("接收的数据为空");
}
}catch (Exception e){
log.error(L_MSG+e.getMessage());
return R.fail(L_MSG);
}
@ -210,6 +220,7 @@ public class SapOrderServiceImpl implements SapOrderService {
try {
//获取连接
// JCoDestination dest = SAPConnUtils.connect();
log.info("订单关闭入参------"+sapCloseOrderQuery.toString());
JCoRepository repository = dest.getRepository();
JCoFunction func = repository.getFunction("ZPPR_MES_PRODORD_CLOSE");
if (func == null) {
@ -237,8 +248,10 @@ public class SapOrderServiceImpl implements SapOrderService {
func.execute(dest);//执行调用函数
String L_MSG2= func.getExportParameterList().getString("L_MSG");
Msg.append(sapCloseOrderQuery.getOrder()+L_MSG2);
log.info("订单关闭结果"+Msg.toString());
return R.ok(null,Msg.toString());
}catch (Exception e){
log.error("订单关闭失败"+e.getMessage());
return R.fail(e.getMessage());
}
}
@ -338,12 +351,12 @@ public class SapOrderServiceImpl implements SapOrderService {
S_EBELN.setValue(Constants.OPTION, "EQ");
S_EBELN.setValue(Constants.LOW, sapPurchaseOrderQuery.getEbeln());
}
if (!StringUtils.isNull(sapPurchaseOrderQuery.getEbeln())){
JCoTable S_EBELN = func.getTableParameterList().getTable("S_EBELP");
S_EBELN.appendRow();
S_EBELN.setValue(Constants.SIGN, "I");
S_EBELN.setValue(Constants.OPTION, "EQ");
S_EBELN.setValue(Constants.LOW, sapPurchaseOrderQuery.getEbeln());
if (!StringUtils.isNull(sapPurchaseOrderQuery.getEbelp())){
JCoTable S_EBELP = func.getTableParameterList().getTable("S_EBELP");
S_EBELP.appendRow();
S_EBELP.setValue(Constants.SIGN, "I");
S_EBELP.setValue(Constants.OPTION, "EQ");
S_EBELP.setValue(Constants.LOW, sapPurchaseOrderQuery.getEbelp());
}
if (!StringUtils.isNull(sapPurchaseOrderQuery.getMatnr())){
JCoTable S_MATNR = func.getTableParameterList().getTable("S_MATNR");
@ -365,7 +378,57 @@ public class SapOrderServiceImpl implements SapOrderService {
JCoTable maraTable = func.getTableParameterList().getTable("LT_PROCURE");
JCoRecordMetaData metaData = maraTable.getRecordMetaData();
System.out.println("###" + metaData.toString());
return R.ok();
List<SapPurchaseOrderQuery> sapPurchaseOrderQueryList=new ArrayList<>();
for (int i = 0; i < maraTable.getNumRows(); i++) {
maraTable.setRow(i);
SapPurchaseOrderQuery sapPCorder=new SapPurchaseOrderQuery();
String EBELN = maraTable.getString("EBELN");
String EBELP = maraTable.getString("EBELP");
String MATNR = maraTable.getString("MATNR");
String MAKTX = maraTable.getString("MAKTX");
String MENGE = maraTable.getString("MENGE");
String MEINS = maraTable.getString("MEINS");
String ZMENGE = maraTable.getString("ZMENGE");
String ZMEINS = maraTable.getString("ZMEINS");
String LIFNR = maraTable.getString("LIFNR");
String WERKS = maraTable.getString("WERKS");
String LGORT = maraTable.getString("LGORT");
String EINDT = maraTable.getString("EINDT");
String ELIKZ = maraTable.getString("ELIKZ");
String BEIZHU = maraTable.getString("BEIZHU");
System.out.println(
"采购凭证号"+EBELN+
"采购凭证的项目编号"+EBELP+
"物料号"+MATNR+
"物料描述(短文本)"+MAKTX+
"采购订单数量"+MENGE+
"采购订单的计量单位"+MEINS+
"交货数量"+ZMENGE+
"基本计量单位"+ZMEINS+
"供应商帐户号"+LIFNR+
"工厂"+WERKS+
"库存地点"+LGORT+
"项目交货日期"+EINDT+
"交货已完成标识"+ELIKZ+
"注释"+BEIZHU);
sapPCorder.setEbeln(EBELN);
sapPCorder.setEbelp(EBELP);
sapPCorder.setMatnr(MATNR);
sapPCorder.setMaktx(MAKTX);
sapPCorder.setMenge(MENGE);
sapPCorder.setMeins(MEINS);
sapPCorder.setZmenge(ZMENGE);
sapPCorder.setZmeins(ZMEINS);
sapPCorder.setLifnr(LIFNR);
sapPCorder.setWerks(WERKS);
sapPCorder.setLgort(LGORT);
sapPCorder.setEindt(EINDT);
sapPCorder.setElikz(ELIKZ);
sapPCorder.setBeizhu(BEIZHU);
sapPurchaseOrderQueryList.add(sapPCorder);
}
return R.ok(sapPurchaseOrderQueryList);
}catch (Exception e){
return R.fail(e.getMessage());
}
@ -375,6 +438,7 @@ public class SapOrderServiceImpl implements SapOrderService {
@Override
public R shopUpdateSync(SapShopOrderQuery sapProOrder) {
try {
log.info("订单修改入参-------"+sapProOrder.toString());
JCoRepository repository = dest.getRepository();
JCoFunction func = repository.getFunction("ZPPR_MES_PRODORD_CHANGE");
// 配置传入参数
@ -399,11 +463,14 @@ public class SapOrderServiceImpl implements SapOrderService {
String RETCODE= func.getExportParameterList().getString("RETCODE");
String MESSAGE= func.getExportParameterList().getString("MESSAGE");
if ((Constants.FAIL).equals(Integer.parseInt(RETCODE))){
log.error("订单修改结果-----"+MESSAGE);
return R.fail(null,"订单号:"+sapProOrder.getAufnr()+MESSAGE);
}else {
log.info("订单修改结果-----"+MESSAGE);
return R.ok(null,"订单号:"+sapProOrder.getAufnr()+MESSAGE);
}
}catch (Exception e){
log.error(e.getMessage());
return R.fail(e.getMessage());
}
}

Loading…
Cancel
Save