|
|
|
@ -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());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|