SAP领料过账和订单接收

highway
Yangwl 12 months ago
parent 8abc2cba6a
commit 31747dcf41

@ -1,5 +1,6 @@
package com.op.sap.controller; package com.op.sap.controller;
import com.alibaba.fastjson2.JSONObject;
import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder; import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder;
import com.op.common.core.domain.R; import com.op.common.core.domain.R;
import com.op.common.core.web.controller.BaseController; import com.op.common.core.web.controller.BaseController;
@ -377,12 +378,18 @@ public class SapController extends BaseController {
} }
/**
* 退 262
* 261
* @param sapMaterialPostingList
* @return
*/
@PostMapping("/sapMaterialPosting") @PostMapping("/sapMaterialPosting")
@Log(title = "订单物料领料过账、原材料补料、订单物料退料过账接口MB1A", businessType = BusinessType.SAP) @Log(title = "订单物料领料过账、原材料补料、订单物料退料过账接口MB1A", businessType = BusinessType.SAP)
public R sapMaterialPosting(@RequestBody SapMaterialPosting sapMaterialPosting){ public R sapMaterialPosting(@RequestBody List<SapMaterialPosting> sapMaterialPostingList){
return sapItemSyncService.sapMaterialPosting(sapMaterialPosting); return sapItemSyncService.sapMaterialPosting(sapMaterialPostingList);
} }
@ -396,6 +403,17 @@ public class SapController extends BaseController {
return sapOrderService.sapPurchaseOrderSync(sapPurchaseOrderQuery); return sapOrderService.sapPurchaseOrderSync(sapPurchaseOrderQuery);
} }
/**
* 101
*
* @param sapOrderReceiptQuery
* @return
*/
@PostMapping("/sapOrderReceipt")
@Log(title = "智慧工厂101类型订单收货", businessType = BusinessType.SAP)
public R sapOrderReceipt(@RequestBody SapOrderReceiptQuery sapOrderReceiptQuery){
return sapOrderService.sapOrderReceipt(sapOrderReceiptQuery);
}
} }

@ -3,14 +3,18 @@ package com.op.sap.domain.vo;
//智慧工厂-订单物料领料过账、原材料补料、订单物料退料过账MB1A //智慧工厂-订单物料领料过账、原材料补料、订单物料退料过账MB1A
/** /**
* AUFNR AUFNR CHAR 12 0
* BWART BWART CHAR 3 0
* PLANT PLANT CHAR 4 0
* LGORT GL_ACCOUNT CHAR 10 0
* MATNR COSTCENTER CHAR 10 0
* QUANTITY GR_RCPT CHAR 12 0 /
* MEINS LGORT CHAR 4 0
* BATCH MATNR CHAR 18 0
QUANTITY QUAN 13 3
MEINS UNIT 3 0
BATCH CHAR 10 0
*/ */
public class SapMaterialPosting { public class SapMaterialPosting {
@ -24,12 +28,39 @@ public class SapMaterialPosting {
private String aufnr; private String aufnr;
private String bwart; private String bwart;
private String plant; private String plant;
private String gl_account;
private String costcenter;
private String gr_rcpt;
private String lgort; private String lgort;
private String matnr; private String matnr;
private String quantity; private String quantity;
private String meins; private String meins;
private String batch; private String batch;
public String getGl_account() {
return gl_account;
}
public void setGl_account(String gl_account) {
this.gl_account = gl_account;
}
public String getCostcenter() {
return costcenter;
}
public void setCostcenter(String costcenter) {
this.costcenter = costcenter;
}
public String getGr_rcpt() {
return gr_rcpt;
}
public void setGr_rcpt(String gr_rcpt) {
this.gr_rcpt = gr_rcpt;
}
public String getAufnr() { public String getAufnr() {
return aufnr; return aufnr;
} }

@ -0,0 +1,81 @@
package com.op.sap.domain.vo;
/**
* AUFNR CHAR12
* LGORT CHAR4
* ERFMG QUAN-13-3
* CHARG CHAR10
* HSDAT DATS8
* ERFME UNIT
* auth YangWL
*/
public class SapOrderReceiptQuery {
private String aufnr;
private String lgort;
private String erfmg;
private String charg;
private String hsdat;
private String erfme;
public String getAufnr() {
return aufnr;
}
public void setAufnr(String aufnr) {
this.aufnr = aufnr;
}
public String getLgort() {
return lgort;
}
public void setLgort(String lgort) {
this.lgort = lgort;
}
public String getErfmg() {
return erfmg;
}
public void setErfmg(String erfmg) {
this.erfmg = erfmg;
}
public String getCharg() {
return charg;
}
public void setCharg(String charg) {
this.charg = charg;
}
public String getHsdat() {
return hsdat;
}
public void setHsdat(String hsdat) {
this.hsdat = hsdat;
}
public String getErfme() {
return erfme;
}
public void setErfme(String erfme) {
this.erfme = erfme;
}
@Override
public String toString() {
return "SapOrderReceiptQuery{" +
"aufnr='" + aufnr + '\'' +
", lgort='" + lgort + '\'' +
", erfmg='" + erfmg + '\'' +
", charg='" + charg + '\'' +
", hsdat='" + hsdat + '\'' +
", erfme='" + erfme + '\'' +
'}';
}
}

@ -21,11 +21,11 @@ public interface SapItemSyncService {
/** /**
* 退MB1A * 退MB1A
* @param sapMaterialPosting * @param sapMaterialPostingList
* @return * @return
*/ */
R sapMaterialPosting(SapMaterialPosting sapMaterialPosting); R sapMaterialPosting(List<SapMaterialPosting> sapMaterialPostingList);
R sapBackflushMP(List<SapBackflushMPQuery> sapBackflushMPQueryList); R sapBackflushMP(List<SapBackflushMPQuery> sapBackflushMPQueryList);
} }

@ -2,6 +2,7 @@ package com.op.sap.service;
import com.op.common.core.domain.R; import com.op.common.core.domain.R;
import com.op.sap.domain.vo.SapOrderReceiptQuery;
import com.op.sap.domain.vo.SapPurchaseOrderQuery; import com.op.sap.domain.vo.SapPurchaseOrderQuery;
import com.op.system.api.domain.sap.SapCloseOrderQuery; import com.op.system.api.domain.sap.SapCloseOrderQuery;
import com.op.system.api.domain.sap.SapCreateOrder; import com.op.system.api.domain.sap.SapCreateOrder;
@ -50,4 +51,6 @@ public interface SapOrderService {
R sapPurchaseOrderSync(SapPurchaseOrderQuery sapPurchaseOrderQuery); R sapPurchaseOrderSync(SapPurchaseOrderQuery sapPurchaseOrderQuery);
R shopUpdateSync(SapShopOrderQuery sapProOrder); R shopUpdateSync(SapShopOrderQuery sapProOrder);
R sapOrderReceipt(SapOrderReceiptQuery sapOrderReceiptQuery);
} }

@ -28,6 +28,7 @@ import org.springframework.stereotype.Service;
import javax.validation.Validator; import javax.validation.Validator;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -225,7 +226,7 @@ public class SapItemSyncImpl implements SapItemSyncService {
} }
@Override @Override
public R sapMaterialPosting(SapMaterialPosting sapMaterialPosting) { public R sapMaterialPosting(List<SapMaterialPosting> sapMaterialPostingList) {
try { try {
// 获取调用 RFC 函数对象 // 获取调用 RFC 函数对象
@ -233,90 +234,71 @@ public class SapItemSyncImpl implements SapItemSyncService {
// JCoDestination dest = SAPConnUtils.connect(); // JCoDestination dest = SAPConnUtils.connect();
JCoRepository repository = dest.getRepository(); JCoRepository repository = dest.getRepository();
JCoFunction func = repository.getFunction("ZPPR_MES_GOODSMVT_CREATE"); 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"); JCoTable L_ITEM = func.getTableParameterList().getTable("L_ITEM");
System.out.println(jCoTable);
JCoParameterList AUFNR = func.getImportParameterList(); for (SapMaterialPosting smp:sapMaterialPostingList){
System.out.println(AUFNR); 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());
//订单
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); func.execute(dest);
// 获取 内表 - ZMES_PRO
JCoTable maraTable = func.getTableParameterList().getTable("LT_RETURN"); JCoTable maraTable = func.getTableParameterList().getTable("LT_RETURN");
JCoRecordMetaData metaData = maraTable.getRecordMetaData(); JCoRecordMetaData metaData = maraTable.getRecordMetaData();
System.out.println("###" + metaData.toString()); System.out.println("###" + metaData.toString());
StringBuilder Msg = new StringBuilder();
for (int i = 0; i < maraTable.getNumRows(); i++) { for (int i = 0; i < maraTable.getNumRows(); i++) {
maraTable.setRow(i); maraTable.setRow(i);
String RETCODE = maraTable.getString("RETCODE"); String TYPE = maraTable.getString("TYPE");
System.out.println(RETCODE); 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");
// JCoRecordMetaData metaData = maraTable.getRecordMetaData(); String RETCODE= func.getExportParameterList().getString("RETCODE");
// System.out.println("###" + metaData.toString()); String MATERIALDOCUMENT= func.getExportParameterList().getString("MATERIALDOCUMENT");
String MATDOCUMENTYEAR= func.getExportParameterList().getString("MATDOCUMENTYEAR");
System.out.println("L_MSG"+L_MSG);
if (func == null) {
throw new RuntimeException("Function does not exist in SAP"); 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){ }catch (Exception e){
return R.fail(e.getMessage()); return R.fail(e.getMessage());
} }
@ -330,6 +312,7 @@ public class SapItemSyncImpl implements SapItemSyncService {
@Override @Override
public R sapBackflushMP(List<SapBackflushMPQuery> sapBackflushMPQueryList) { public R sapBackflushMP(List<SapBackflushMPQuery> sapBackflushMPQueryList) {
try { try {
JCoRepository repository = dest.getRepository(); JCoRepository repository = dest.getRepository();
JCoFunction func = repository.getFunction("ZPPR_MES_GOODSMVT_CREATE_B"); 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"); JCoTable L_ITEM = func.getTableParameterList().getTable("L_ITEM");
System.out.println(L_ITEM); // System.out.println(L_ITEM);
// //
// int successNum = 0; // int successNum = 0;
@ -375,23 +358,37 @@ public class SapItemSyncImpl implements SapItemSyncService {
JCoTable maraTable = func.getTableParameterList().getTable("LT_RETURN"); JCoTable maraTable = func.getTableParameterList().getTable("LT_RETURN");
JCoRecordMetaData metaData = maraTable.getRecordMetaData(); JCoRecordMetaData metaData = maraTable.getRecordMetaData();
System.out.println("###" + metaData.toString()); System.out.println("###" + metaData.toString());
StringBuilder Msg = new StringBuilder();
for (int i = 0; i < maraTable.getNumRows(); i++) { for (int i = 0; i < maraTable.getNumRows(); i++) {
maraTable.setRow(i); maraTable.setRow(i);
String TYPE = maraTable.getString("TYPE"); 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 L_MSG= func.getExportParameterList().getString("L_MSG");
String RETCODE= func.getExportParameterList().getString("RETCODE"); String RETCODE= func.getExportParameterList().getString("RETCODE");
String MATERIALDOCUMENT= func.getExportParameterList().getString("MATERIALDOCUMENT"); String MATERIALDOCUMENT= func.getExportParameterList().getString("MATERIALDOCUMENT");
String MATDOCUMENTYEAR= func.getExportParameterList().getString("MATDOCUMENTYEAR"); 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("MATERIALDOCUMENT"+MATERIALDOCUMENT);
System.out.println(L_MSG); // System.out.println("MATDOCUMENTYEAR"+MATDOCUMENTYEAR);
System.out.println(RETCODE); //
System.out.println(MATERIALDOCUMENT); // return R.ok();
System.out.println(MATDOCUMENTYEAR);
return R.ok();
}catch (Exception e){ }catch (Exception e){
return R.fail(e.getMessage()); return R.fail(e.getMessage());

@ -7,6 +7,8 @@ import com.op.common.core.utils.DateUtils;
import com.op.common.core.utils.StringUtils; import com.op.common.core.utils.StringUtils;
import com.op.common.core.utils.uuid.IdUtils; import com.op.common.core.utils.uuid.IdUtils;
import com.op.sap.domain.vo.SapBackflushMPQuery;
import com.op.sap.domain.vo.SapOrderReceiptQuery;
import com.op.sap.domain.vo.SapPurchaseOrderQuery; import com.op.sap.domain.vo.SapPurchaseOrderQuery;
import com.op.sap.service.SapOrderService; import com.op.sap.service.SapOrderService;
@ -59,6 +61,7 @@ public class SapOrderServiceImpl implements SapOrderService {
// 配置传入参数 // 配置传入参数
// S_WERKS(工厂) S_AUFNR订单号 S_MATNR物料号 S_ERDAT(创建日期) 例如20230923 // S_WERKS(工厂) S_AUFNR订单号 S_MATNR物料号 S_ERDAT(创建日期) 例如20230923
if (!StringUtils.isNull(sapShopOrderQuery.getWerk())){ if (!StringUtils.isNull(sapShopOrderQuery.getWerk())){
JCoTable S_WERKS = func.getTableParameterList().getTable("S_PWERK"); JCoTable S_WERKS = func.getTableParameterList().getTable("S_PWERK");
S_WERKS.appendRow(); S_WERKS.appendRow();
@ -183,13 +186,15 @@ public class SapOrderServiceImpl implements SapOrderService {
jCoParameterList.setValue("P_DATEE",sapCreateOrder.getDatee()); jCoParameterList.setValue("P_DATEE",sapCreateOrder.getDatee());
func.execute(dest);//执行调用函数 func.execute(dest);//执行调用函数
JCoParameterList J= func.getExportParameterList(); JCoParameterList J= func.getExportParameterList();
// System.out.println(J); System.out.println(func.getExportParameterList());
L_MSG= func.getExportParameterList().getString("L_MSG"); L_MSG= func.getExportParameterList().getString("L_MSG");
String LV_ORDER_NUMBER= func.getExportParameterList().getString("LV_ORDER_NUMBER"); // String RETCODE = func.getExportParameterList().getString("RETCODE");
//String LV_ORDER_NUMBER= func.getExportParameterList().getString("LV_ORDER_NUMBER");
// if (RETCODE.equals(Constants.FAIL)){
// return R.fail(LV_ORDER_NUM_List,L_MSG);
// }
JCoTable LT_ZGD=func.getTableParameterList().getTable("LT_ZGD"); JCoTable LT_ZGD=func.getTableParameterList().getTable("LT_ZGD");
// System.out.println(LT_ZGD);
//DynamicDataSourceContextHolder.push("ds_1000");//controller已经完成切换
for (int i = 0; i <LT_ZGD.getNumRows(); i++) { for (int i = 0; i <LT_ZGD.getNumRows(); i++) {
LT_ZGD.setRow(i); LT_ZGD.setRow(i);
Map map=new HashMap(); Map map=new HashMap();
@ -199,8 +204,10 @@ public class SapOrderServiceImpl implements SapOrderService {
map.put("AUFNR",AUFNR); map.put("AUFNR",AUFNR);
LV_ORDER_NUM_List.add(map); LV_ORDER_NUM_List.add(map);
} }
} }
log.info("订单创建结果----"+L_MSG+"|"+JSONObject.toJSONString(LV_ORDER_NUM_List)); log.info("订单创建结果----"+L_MSG+"|"+JSONObject.toJSONString(LV_ORDER_NUM_List));
return R.ok(LV_ORDER_NUM_List,L_MSG); return R.ok(LV_ORDER_NUM_List,L_MSG);
}else { }else {
log.error("接收的数据为空"); log.error("接收的数据为空");
@ -292,7 +299,7 @@ public class SapOrderServiceImpl implements SapOrderService {
* LT_GS * LT_GS
*/ */
JCoTable LT_GS_jCoTable = func.getTableParameterList().getTable("LT_GS"); JCoTable LT_GS_jCoTable = func.getTableParameterList().getTable("LT_GS");
System.out.println("LT_GS_jCoTable"+LT_GS_jCoTable); // System.out.println("LT_GS_jCoTable"+LT_GS_jCoTable);
LT_GS_jCoTable.appendRow(); LT_GS_jCoTable.appendRow();
LT_GS_jCoTable.setValue("CONF_ACTIVITY1", sapRFW.getLt_gs().getConf_activity1()); LT_GS_jCoTable.setValue("CONF_ACTIVITY1", sapRFW.getLt_gs().getConf_activity1());
LT_GS_jCoTable.setValue("CONF_ACTIVITY2", sapRFW.getLt_gs().getConf_activity2()); LT_GS_jCoTable.setValue("CONF_ACTIVITY2", sapRFW.getLt_gs().getConf_activity2());
@ -304,7 +311,7 @@ public class SapOrderServiceImpl implements SapOrderService {
* MES LT_HW * MES LT_HW
*/ */
JCoTable LT_HW_jCoTable = func.getTableParameterList().getTable("LT_HW"); JCoTable LT_HW_jCoTable = func.getTableParameterList().getTable("LT_HW");
System.out.println("LT_HW_jCoTable"+LT_HW_jCoTable); //System.out.println("LT_HW_jCoTable"+LT_HW_jCoTable);
for (SapRFW.lt_hw lt_hw:sapRFW.getLt_hwList()){ for (SapRFW.lt_hw lt_hw:sapRFW.getLt_hwList()){
LT_HW_jCoTable.appendRow(); LT_HW_jCoTable.appendRow();
LT_HW_jCoTable.setValue("MATERIAL", lt_hw.getMaterial()); LT_HW_jCoTable.setValue("MATERIAL", lt_hw.getMaterial());
@ -314,9 +321,10 @@ public class SapOrderServiceImpl implements SapOrderService {
func.execute(dest);//执行调用函数 func.execute(dest);//执行调用函数
JCoParameterList J= func.getExportParameterList(); JCoParameterList J= func.getExportParameterList();
System.out.println(J); //System.out.println(J);
String RETCODE= func.getExportParameterList().getString("RETCODE");
MESSAGE= func.getExportParameterList().getString("MESSAGE"); MESSAGE= func.getExportParameterList().getString("MESSAGE");
if (StringUtils.contains(MESSAGE,"错误")){ if (Constants.FAIL.equals(RETCODE)){
return R.fail("订单号:"+sapRFW.getAufnr()+"报工失败"+MESSAGE); return R.fail("订单号:"+sapRFW.getAufnr()+"报工失败"+MESSAGE);
} }
return R.ok("",MESSAGE); return R.ok("",MESSAGE);
@ -475,7 +483,80 @@ public class SapOrderServiceImpl implements SapOrderService {
} }
} }
@Override
public R sapOrderReceipt(SapOrderReceiptQuery sapOrderReceiptQuery) {
try {
log.info("智慧工厂101类型订单收货入参-------"+sapOrderReceiptQuery.toString());
JCoRepository repository = dest.getRepository();
JCoFunction func = repository.getFunction("ZMES_101_MIGO");
//System.out.println(jCoParameterList);
if (func == null) {
throw new RuntimeException("Function does not exist in SAP");
}
if (StringUtils.isEmpty(sapOrderReceiptQuery.getAufnr()))
{
return R.fail("订单号为空!");
}
if (StringUtils.isEmpty(sapOrderReceiptQuery.getLgort()))
{
return R.fail("库位为空!");
}
if (StringUtils.isEmpty(sapOrderReceiptQuery.getErfmg()))
{
return R.fail("数量为空!");
}
if (StringUtils.isEmpty(sapOrderReceiptQuery.getCharg()))
{
return R.fail("批号为空!");
}
if (StringUtils.isEmpty(sapOrderReceiptQuery.getHsdat()))
{
return R.fail("生产日期为空!");
}
// 配置传入参数
JCoTable L_ITEM = func.getTableParameterList().getTable("L_ITEM");
L_ITEM.appendRow();
// System.out.println(L_ITEM);
L_ITEM.setValue("AUFNR",sapOrderReceiptQuery.getAufnr());
L_ITEM.setValue("WERKS","1000");
L_ITEM.setValue("LGORT",sapOrderReceiptQuery.getLgort());
L_ITEM.setValue("QUANTITY",sapOrderReceiptQuery.getErfmg());
L_ITEM.setValue("BATCH",sapOrderReceiptQuery.getCharg());
L_ITEM.setValue("HSDAT",sapOrderReceiptQuery.getHsdat());
L_ITEM.setValue("ERFME",sapOrderReceiptQuery.getErfme());
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");
if ((Constants.FAIL).equals(Integer.parseInt(RETCODE))){
log.error("订单收货结果-----"+MESSAGE);
return R.fail(null,"订单号:"+sapOrderReceiptQuery.getAufnr()+MESSAGE);
}else {
log.info("订单收货结果-----"+MESSAGE);
return R.ok(MATERIALDOCUMENT,"订单号:"+sapOrderReceiptQuery.getAufnr()+MESSAGE);
}
}catch (Exception e){
log.error(e.getMessage());
return R.fail(e.getMessage());
}
}
// public static void main(String[] args) {
// List<SapBackflushMPQuery> sapBackflushMPQueryList=new ArrayList<>();
// SapBackflushMPQuery sapBackflushMPQuery=new SapBackflushMPQuery();
// sapBackflushMPQuery.setMatnr("000000020000000280");
// sapBackflushMPQuery.setPlant("1000");
// sapBackflushMPQuery.setLgort("0013");
// sapBackflushMPQuery.setQuantity("3600");
// sapBackflushMPQuery.setMeins("ST");
// sapBackflushMPQueryList.add(sapBackflushMPQuery);
// System.out.println(JSONObject.toJSONString(sapBackflushMPQueryList));
// }
} }

@ -13,6 +13,8 @@ import com.op.sap.service.SapRouterService;
import com.op.sap.util.SAPConnUtils; import com.op.sap.util.SAPConnUtils;
import com.op.system.api.domain.sap.*; import com.op.system.api.domain.sap.*;
import com.sap.conn.jco.*; import com.sap.conn.jco.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -27,6 +29,7 @@ import java.util.stream.Collectors;
@Component @Component
@Service @Service
public class SapRouterServiceImpl implements SapRouterService { public class SapRouterServiceImpl implements SapRouterService {
private static final Logger log = LoggerFactory.getLogger(SapOrderServiceImpl.class);
private static final String END_DATE="99991231"; private static final String END_DATE="99991231";
@Autowired @Autowired
private SapProProcessMapper sapProProcessMapper; private SapProProcessMapper sapProProcessMapper;
@ -70,6 +73,7 @@ public class SapRouterServiceImpl implements SapRouterService {
S_AEDAT S_AEDAT
*/ */
log.info("工艺路线同步入参-------"+sapRouterQuery.toString());
if (!StringUtils.isNull(sapRouterQuery.getMatnr())){ if (!StringUtils.isNull(sapRouterQuery.getMatnr())){
JCoTable S_MATNR = func.getTableParameterList().getTable("S_MATNR"); JCoTable S_MATNR = func.getTableParameterList().getTable("S_MATNR");
S_MATNR.appendRow(); S_MATNR.appendRow();
@ -118,7 +122,7 @@ public class SapRouterServiceImpl implements SapRouterService {
// 获取 内表 - ZMES_PRO // 获取 内表 - ZMES_PRO
JCoTable maraTable = func.getTableParameterList().getTable("LT_ROUTING"); JCoTable maraTable = func.getTableParameterList().getTable("LT_ROUTING");
JCoRecordMetaData metaData = maraTable.getRecordMetaData(); JCoRecordMetaData metaData = maraTable.getRecordMetaData();
System.out.println("###" + metaData.toString()); // System.out.println("###" + metaData.toString());
List<SapProRoute> sapProRouteList=new ArrayList<>(); List<SapProRoute> sapProRouteList=new ArrayList<>();
//DynamicDataSourceContextHolder.push("ds_1000");//controller已经完成切换 //DynamicDataSourceContextHolder.push("ds_1000");//controller已经完成切换
for (int i = 0; i <maraTable.getNumRows(); i++) { for (int i = 0; i <maraTable.getNumRows(); i++) {
@ -168,7 +172,7 @@ public class SapRouterServiceImpl implements SapRouterService {
String SPMUS = maraTable.getString("SPMUS"); String SPMUS = maraTable.getString("SPMUS");
String SPLIM = maraTable.getString("SPLIM"); String SPLIM = maraTable.getString("SPLIM");
String CKSELKZ = maraTable.getString("CKSELKZ"); String CKSELKZ = maraTable.getString("CKSELKZ");
System.out.println( log.info(
"工厂:" + WERKS+ "工厂:" + WERKS+
"任务清单类型:" + PLNTY+ "任务清单类型:" + PLNTY+
"任务清单组码:" + PLNNR+ "任务清单组码:" + PLNNR+
@ -354,14 +358,16 @@ public class SapRouterServiceImpl implements SapRouterService {
if (failureNum > 0) if (failureNum > 0)
{ {
failureMsg.insert(0, "很抱歉,同步失败!共 " + failureNum + " 工艺路线异常,错误如下:"); failureMsg.insert(0, "很抱歉,同步失败!共 " + failureNum + " 工艺路线异常");
log.error(failureMsg.toString());
throw new ServiceException(failureMsg.toString()); throw new ServiceException(failureMsg.toString());
} }
else else
{ {
successMsg.insert(0, "恭喜您,数据同步成功!共 " + successNum + " 条,数据如下:"); successMsg.insert(0, "恭喜您,数据同步成功!共 " + successNum + " 条");
} }
}catch (Exception e){ }catch (Exception e){
log.error(e.getMessage());
return R.fail(e.getMessage()); return R.fail(e.getMessage());
} }
return R.ok(successMsg); return R.ok(successMsg);

Loading…
Cancel
Save