|
|
|
@ -22,6 +22,7 @@ import org.slf4j.LoggerFactory;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
|
|
|
|
|
|
|
import javax.validation.Validator;
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
@ -225,77 +226,51 @@ public class SapItemSyncImpl implements SapItemSyncService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public R sapMaterialPosting(List<SapMaterialPosting> sapMaterialPostingList) {
|
|
|
|
|
public R sapMaterialPosting(SapMaterialPosting sapMaterialPosting) {
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
// 获取调用 RFC 函数对象
|
|
|
|
|
//获取连接
|
|
|
|
|
// JCoDestination dest = SAPConnUtils.connect();
|
|
|
|
|
JCoRepository repository = dest.getRepository();
|
|
|
|
|
JCoFunction func = repository.getFunction("ZPPR_MES_GOODSMVT_CREATE");
|
|
|
|
|
JCoFunction func=null;
|
|
|
|
|
if (Constants.LL.equals(sapMaterialPosting.getPostingType())){
|
|
|
|
|
func = repository.getFunction("ZMES_261_MB1A");
|
|
|
|
|
log.info("订单物料领料开始过账--------------------------");
|
|
|
|
|
}else if (Constants.TL.equals(sapMaterialPosting.getPostingType())){
|
|
|
|
|
func = repository.getFunction("ZMES_262_MB1A");
|
|
|
|
|
log.info("订单物料退料开始过账--------------------------");
|
|
|
|
|
}
|
|
|
|
|
if (func == null) {
|
|
|
|
|
throw new RuntimeException("Function does not exist in SAP");
|
|
|
|
|
}
|
|
|
|
|
log.info("订单物料开始过账----------------------------------------");
|
|
|
|
|
|
|
|
|
|
// 配置传入参数
|
|
|
|
|
JCoTable L_ITEM = func.getTableParameterList().getTable("L_ITEM");
|
|
|
|
|
|
|
|
|
|
for (SapMaterialPosting smp:sapMaterialPostingList){
|
|
|
|
|
for (Map<String, Object> stringObjectMap:sapMaterialPosting.getMapList()) {
|
|
|
|
|
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());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
|
L_ITEM.setValue("AUFNR", stringObjectMap.get("AUFNR"));
|
|
|
|
|
L_ITEM.setValue("PLANT", stringObjectMap.get("PLANT"));
|
|
|
|
|
L_ITEM.setValue("LGORT", stringObjectMap.get("LGORT"));
|
|
|
|
|
L_ITEM.setValue("MATNR", stringObjectMap.get("MATNR"));
|
|
|
|
|
L_ITEM.setValue("QUANTITY", stringObjectMap.get("QUANTITY"));
|
|
|
|
|
L_ITEM.setValue("MEINS", stringObjectMap.get("MEINS"));
|
|
|
|
|
}
|
|
|
|
|
String L_MSG= func.getExportParameterList().getString("L_MSG");
|
|
|
|
|
func.execute(dest);//执行调用函数
|
|
|
|
|
System.out.println(func.getExportParameterList());
|
|
|
|
|
String RETCODE= func.getExportParameterList().getString("RETCODE");
|
|
|
|
|
String MESSAGE= func.getExportParameterList().getString("L_MSG");
|
|
|
|
|
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());
|
|
|
|
|
if ((Constants.LOGIN_FAIL_STATUS).equals(RETCODE)){
|
|
|
|
|
log.error("订单收货结果-----"+MESSAGE);
|
|
|
|
|
return R.fail(MESSAGE);
|
|
|
|
|
}else {
|
|
|
|
|
Map map=new HashMap();
|
|
|
|
|
map.put("MATERIALDOCUMENT",MATERIALDOCUMENT);
|
|
|
|
|
map.put("MATDOCUMENTYEAR",MATDOCUMENTYEAR);
|
|
|
|
|
return R.ok(map,Msg.toString());
|
|
|
|
|
log.info("订单收货结果-----"+MESSAGE);
|
|
|
|
|
Map Resmap=new HashMap();
|
|
|
|
|
Resmap.put("MATERIALDOCUMENT",MATERIALDOCUMENT);
|
|
|
|
|
Resmap.put("MATDOCUMENTYEAR",MATDOCUMENTYEAR);
|
|
|
|
|
return R.ok(Resmap,MESSAGE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}catch (Exception e){
|
|
|
|
@ -303,6 +278,8 @@ public class SapItemSyncImpl implements SapItemSyncService {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 反冲物料领料过账
|
|
|
|
|
* @param sapBackflushMPQueryList
|
|
|
|
@ -332,17 +309,17 @@ public class SapItemSyncImpl implements SapItemSyncService {
|
|
|
|
|
L_ITEM.setValue("BATCH",sfp.getBatch());
|
|
|
|
|
L_ITEM.setValue("MOVE_BATCH",sfp.getMove_batch());
|
|
|
|
|
}
|
|
|
|
|
System.out.println(func.getTableParameterList().getTable("L_ITEM"));
|
|
|
|
|
func.execute(dest);
|
|
|
|
|
JCoTable maraTable = func.getTableParameterList().getTable("LT_RETURN");
|
|
|
|
|
JCoRecordMetaData metaData = maraTable.getRecordMetaData();
|
|
|
|
|
System.out.println("###" + metaData.toString());
|
|
|
|
|
System.out.println(func.getTableParameterList());
|
|
|
|
|
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("TYPE:"+TYPE);
|
|
|
|
|
System.out.println("MESSAGE:"+MESSAGE);
|
|
|
|
|
}
|
|
|
|
|
String L_MSG= func.getExportParameterList().getString("L_MSG");
|
|
|
|
@ -350,7 +327,6 @@ public class SapItemSyncImpl implements SapItemSyncService {
|
|
|
|
|
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);
|
|
|
|
@ -374,10 +350,7 @@ public class SapItemSyncImpl implements SapItemSyncService {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void main(String[] args) {
|
|
|
|
|
SapBackflushMPQuery sapBackflushMPQuery=new SapBackflushMPQuery();
|
|
|
|
|
System.out.println(sapBackflushMPQuery.toString());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public String importProducts(List<SapBaseProduct> sapBaseProductList){
|
|
|
|
|
if (StringUtils.isNull(sapBaseProductList) || sapBaseProductList.size() == 0)
|
|
|
|
|