|
|
|
@ -28,6 +28,7 @@ import org.springframework.stereotype.Service;
|
|
|
|
|
import javax.validation.Validator;
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
@ -225,7 +226,7 @@ public class SapItemSyncImpl implements SapItemSyncService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public R sapMaterialPosting(SapMaterialPosting sapMaterialPosting) {
|
|
|
|
|
public R sapMaterialPosting(List<SapMaterialPosting> sapMaterialPostingList) {
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
// 获取调用 RFC 函数对象
|
|
|
|
@ -233,90 +234,71 @@ public class SapItemSyncImpl implements SapItemSyncService {
|
|
|
|
|
// JCoDestination dest = SAPConnUtils.connect();
|
|
|
|
|
JCoRepository repository = dest.getRepository();
|
|
|
|
|
JCoFunction func = repository.getFunction("ZPPR_MES_GOODSMVT_CREATE");
|
|
|
|
|
if (func == null) {
|
|
|
|
|
throw new RuntimeException("Function does not exist in SAP");
|
|
|
|
|
}
|
|
|
|
|
log.info("订单物料开始过账----------------------------------------");
|
|
|
|
|
// 配置传入参数
|
|
|
|
|
JCoTable jCoTable = func.getTableParameterList().getTable("L_ITEM");
|
|
|
|
|
System.out.println(jCoTable);
|
|
|
|
|
JCoTable L_ITEM = func.getTableParameterList().getTable("L_ITEM");
|
|
|
|
|
|
|
|
|
|
for (SapMaterialPosting smp:sapMaterialPostingList){
|
|
|
|
|
L_ITEM.appendRow();
|
|
|
|
|
//订单号
|
|
|
|
|
L_ITEM.setValue("AUFNR",smp.getAufnr());
|
|
|
|
|
//移动类型
|
|
|
|
|
L_ITEM.setValue("BWART",smp.getBwart());
|
|
|
|
|
//工厂
|
|
|
|
|
L_ITEM.setValue("PLANT",smp.getPlant());
|
|
|
|
|
//总帐科目编号
|
|
|
|
|
L_ITEM.setValue("GL_ACCOUNT",smp.getGl_account());
|
|
|
|
|
//成本中心
|
|
|
|
|
L_ITEM.setValue("COSTCENTER",smp.getCostcenter());
|
|
|
|
|
//收货方/运达方
|
|
|
|
|
L_ITEM.setValue("GR_RCPT",smp.getGr_rcpt());
|
|
|
|
|
//库存地点
|
|
|
|
|
L_ITEM.setValue("LGORT",smp.getLgort());
|
|
|
|
|
//物料号
|
|
|
|
|
L_ITEM.setValue("MATNR",smp.getMatnr());
|
|
|
|
|
//数量
|
|
|
|
|
L_ITEM.setValue("QUANTITY",smp.getQuantity());
|
|
|
|
|
//基本计量单位
|
|
|
|
|
L_ITEM.setValue("MEINS",smp.getMeins());
|
|
|
|
|
//批号
|
|
|
|
|
L_ITEM.setValue("BATCH",smp.getBatch());
|
|
|
|
|
|
|
|
|
|
JCoParameterList AUFNR = func.getImportParameterList();
|
|
|
|
|
System.out.println(AUFNR);
|
|
|
|
|
|
|
|
|
|
//订单
|
|
|
|
|
if (!StringUtils.isNull(sapMaterialPosting.getAufnr())){
|
|
|
|
|
|
|
|
|
|
// AUFNR.appendRow();
|
|
|
|
|
// AUFNR.setValue(Constants.SIGN, "I");
|
|
|
|
|
// AUFNR.setValue(Constants.OPTION, "EQ");
|
|
|
|
|
// AUFNR.setValue(Constants.LOW, sapMaterialPosting.getAufnr());
|
|
|
|
|
}
|
|
|
|
|
// //移动类型
|
|
|
|
|
// if (!StringUtils.isNull(sapMaterialPosting.getBwart())){
|
|
|
|
|
// JCoTable S_MATNR = func.getTableParameterList().getTable("BWART");
|
|
|
|
|
// S_MATNR.appendRow();
|
|
|
|
|
// S_MATNR.setValue(Constants.SIGN, "I");
|
|
|
|
|
// S_MATNR.setValue(Constants.OPTION, "EQ");
|
|
|
|
|
// S_MATNR.setValue(Constants.LOW, sapMaterialPosting.getBwart());
|
|
|
|
|
// }
|
|
|
|
|
// //工厂
|
|
|
|
|
// if (!StringUtils.isNull(sapMaterialPosting.getPlant())){
|
|
|
|
|
// JCoTable S_MATNR = func.getTableParameterList().getTable("PLANT");
|
|
|
|
|
// S_MATNR.appendRow();
|
|
|
|
|
// S_MATNR.setValue(Constants.SIGN, "I");
|
|
|
|
|
// S_MATNR.setValue(Constants.OPTION, "EQ");
|
|
|
|
|
// S_MATNR.setValue(Constants.LOW, sapMaterialPosting.getPlant());
|
|
|
|
|
// }
|
|
|
|
|
// /**
|
|
|
|
|
// * 物料信息
|
|
|
|
|
// */
|
|
|
|
|
// if (!StringUtils.isNull(sapMaterialPosting.getMatnr())){
|
|
|
|
|
// JCoTable S_MATNR = func.getTableParameterList().getTable("MATNR");
|
|
|
|
|
// S_MATNR.appendRow();
|
|
|
|
|
// S_MATNR.setValue(Constants.SIGN, "I");
|
|
|
|
|
// S_MATNR.setValue(Constants.OPTION, "EQ");
|
|
|
|
|
// S_MATNR.setValue(Constants.LOW, sapMaterialPosting.getMatnr());
|
|
|
|
|
// }
|
|
|
|
|
// //数量
|
|
|
|
|
// if (!StringUtils.isNull(sapMaterialPosting.getQuantity())){
|
|
|
|
|
// JCoTable S_MATNR = func.getTableParameterList().getTable("QUANTITY");
|
|
|
|
|
// S_MATNR.appendRow();
|
|
|
|
|
// S_MATNR.setValue(Constants.SIGN, "I");
|
|
|
|
|
// S_MATNR.setValue(Constants.OPTION, "EQ");
|
|
|
|
|
// S_MATNR.setValue(Constants.LOW, sapMaterialPosting.getQuantity());
|
|
|
|
|
// }
|
|
|
|
|
// //单位
|
|
|
|
|
// if (!StringUtils.isNull(sapMaterialPosting.getMeins())){
|
|
|
|
|
// JCoTable S_MATNR = func.getTableParameterList().getTable("MEINS");
|
|
|
|
|
// S_MATNR.appendRow();
|
|
|
|
|
// S_MATNR.setValue(Constants.SIGN, "I");
|
|
|
|
|
// S_MATNR.setValue(Constants.OPTION, "EQ");
|
|
|
|
|
// S_MATNR.setValue(Constants.LOW, sapMaterialPosting.getMeins());
|
|
|
|
|
// }
|
|
|
|
|
// //批号
|
|
|
|
|
// JCoTable S_MATNR = func.getTableParameterList().getTable("BATCH");
|
|
|
|
|
// S_MATNR.appendRow();
|
|
|
|
|
// S_MATNR.setValue(Constants.SIGN, "I");
|
|
|
|
|
// S_MATNR.setValue(Constants.OPTION, "EQ");
|
|
|
|
|
// S_MATNR.setValue(Constants.LOW, sapMaterialPosting.getBatch());
|
|
|
|
|
|
|
|
|
|
// 获取调用 RFC 函数对象
|
|
|
|
|
func.execute(dest);
|
|
|
|
|
// 获取 内表 - ZMES_PRO
|
|
|
|
|
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 RETCODE = maraTable.getString("RETCODE");
|
|
|
|
|
System.out.println(RETCODE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// JCoRecordMetaData metaData = maraTable.getRecordMetaData();
|
|
|
|
|
// System.out.println("###" + metaData.toString());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (func == null) {
|
|
|
|
|
throw new RuntimeException("Function does not exist in SAP");
|
|
|
|
|
func.execute(dest);
|
|
|
|
|
JCoTable maraTable = func.getTableParameterList().getTable("LT_RETURN");
|
|
|
|
|
JCoRecordMetaData metaData = maraTable.getRecordMetaData();
|
|
|
|
|
System.out.println("###" + metaData.toString());
|
|
|
|
|
StringBuilder Msg = new StringBuilder();
|
|
|
|
|
for (int i = 0; i < maraTable.getNumRows(); i++) {
|
|
|
|
|
maraTable.setRow(i);
|
|
|
|
|
String TYPE = maraTable.getString("TYPE");
|
|
|
|
|
String MESSAGE = maraTable.getString("MESSAGE");
|
|
|
|
|
Msg.append(MESSAGE+"/");
|
|
|
|
|
System.out.println("TYPE:"+TYPE);
|
|
|
|
|
System.out.println("MESSAGE:"+MESSAGE);
|
|
|
|
|
}
|
|
|
|
|
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"+L_MSG);
|
|
|
|
|
|
|
|
|
|
System.out.println("返回值:0-没有错误,1-有错误:"+RETCODE);
|
|
|
|
|
System.out.println("物料凭证编号"+MATERIALDOCUMENT);
|
|
|
|
|
System.out.println("物料凭证年度"+MATDOCUMENTYEAR);
|
|
|
|
|
if (!("0").equals(RETCODE)){
|
|
|
|
|
return R.fail("",Msg.toString());
|
|
|
|
|
}else {
|
|
|
|
|
Map map=new HashMap();
|
|
|
|
|
map.put("MATERIALDOCUMENT",MATERIALDOCUMENT);
|
|
|
|
|
map.put("MATDOCUMENTYEAR",MATDOCUMENTYEAR);
|
|
|
|
|
return R.ok(map,Msg.toString());
|
|
|
|
|
}
|
|
|
|
|
return R.ok();
|
|
|
|
|
|
|
|
|
|
}catch (Exception e){
|
|
|
|
|
return R.fail(e.getMessage());
|
|
|
|
|
}
|
|
|
|
@ -330,6 +312,7 @@ public class SapItemSyncImpl implements SapItemSyncService {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public R sapBackflushMP(List<SapBackflushMPQuery> sapBackflushMPQueryList) {
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
JCoRepository repository = dest.getRepository();
|
|
|
|
|
JCoFunction func = repository.getFunction("ZPPR_MES_GOODSMVT_CREATE_B");
|
|
|
|
@ -338,7 +321,7 @@ public class SapItemSyncImpl implements SapItemSyncService {
|
|
|
|
|
}
|
|
|
|
|
JCoTable L_ITEM = func.getTableParameterList().getTable("L_ITEM");
|
|
|
|
|
|
|
|
|
|
System.out.println(L_ITEM);
|
|
|
|
|
// System.out.println(L_ITEM);
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// int successNum = 0;
|
|
|
|
@ -375,23 +358,37 @@ public class SapItemSyncImpl implements SapItemSyncService {
|
|
|
|
|
JCoTable maraTable = func.getTableParameterList().getTable("LT_RETURN");
|
|
|
|
|
JCoRecordMetaData metaData = maraTable.getRecordMetaData();
|
|
|
|
|
System.out.println("###" + metaData.toString());
|
|
|
|
|
StringBuilder Msg = new StringBuilder();
|
|
|
|
|
for (int i = 0; i < maraTable.getNumRows(); i++) {
|
|
|
|
|
maraTable.setRow(i);
|
|
|
|
|
String TYPE = maraTable.getString("TYPE");
|
|
|
|
|
System.out.println(TYPE);
|
|
|
|
|
String MESSAGE = maraTable.getString("MESSAGE");
|
|
|
|
|
Msg.append(MESSAGE+"/");
|
|
|
|
|
System.out.println("TYPE:"+TYPE);
|
|
|
|
|
System.out.println("MESSAGE:"+MESSAGE);
|
|
|
|
|
}
|
|
|
|
|
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"+L_MSG);
|
|
|
|
|
|
|
|
|
|
System.out.println("返回值:0-没有错误,1-有错误:"+RETCODE);
|
|
|
|
|
System.out.println("物料凭证编号"+MATERIALDOCUMENT);
|
|
|
|
|
System.out.println("物料凭证年度"+MATDOCUMENTYEAR);
|
|
|
|
|
if (!("0").equals(RETCODE)){
|
|
|
|
|
return R.fail("",Msg.toString());
|
|
|
|
|
}else {
|
|
|
|
|
Map map=new HashMap();
|
|
|
|
|
map.put("MATERIALDOCUMENT",MATERIALDOCUMENT);
|
|
|
|
|
map.put("MATDOCUMENTYEAR",MATDOCUMENTYEAR);
|
|
|
|
|
return R.ok(map,Msg.toString());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
System.out.println(L_MSG);
|
|
|
|
|
System.out.println(RETCODE);
|
|
|
|
|
System.out.println(MATERIALDOCUMENT);
|
|
|
|
|
System.out.println(MATDOCUMENTYEAR);
|
|
|
|
|
|
|
|
|
|
return R.ok();
|
|
|
|
|
// System.out.println("MATERIALDOCUMENT"+MATERIALDOCUMENT);
|
|
|
|
|
// System.out.println("MATDOCUMENTYEAR"+MATDOCUMENTYEAR);
|
|
|
|
|
//
|
|
|
|
|
// return R.ok();
|
|
|
|
|
|
|
|
|
|
}catch (Exception e){
|
|
|
|
|
return R.fail(e.getMessage());
|
|
|
|
|