|
|
|
@ -1,8 +1,10 @@
|
|
|
|
|
package com.op.sap.service.impl;
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
|
|
|
import com.alibaba.nacos.shaded.org.checkerframework.checker.units.qual.C;
|
|
|
|
|
import com.op.common.core.constant.Constants;
|
|
|
|
|
import com.op.common.core.domain.R;
|
|
|
|
|
import com.op.common.core.exception.ServiceException;
|
|
|
|
|
import com.op.common.core.utils.DateUtils;
|
|
|
|
|
import com.op.common.core.utils.StringUtils;
|
|
|
|
|
import com.op.common.core.utils.uuid.IdUtils;
|
|
|
|
@ -33,7 +35,7 @@ import java.util.stream.Collectors;
|
|
|
|
|
@Service
|
|
|
|
|
public class SapOrderServiceImpl implements SapOrderService {
|
|
|
|
|
private static final Logger log = LoggerFactory.getLogger(SapOrderServiceImpl.class);
|
|
|
|
|
private static final String END_DATE="99991231";
|
|
|
|
|
private static final String END_DATE = "99991231";
|
|
|
|
|
@Autowired
|
|
|
|
|
private JCoDestination dest;
|
|
|
|
|
|
|
|
|
@ -45,29 +47,29 @@ public class SapOrderServiceImpl implements SapOrderService {
|
|
|
|
|
// 获取调用 RFC 函数对象
|
|
|
|
|
//获取连接
|
|
|
|
|
//JCoDestination dest = SAPConnUtils.connect();
|
|
|
|
|
log.info("订单同步入参-----"+sapShopOrderQuery.toString());
|
|
|
|
|
log.info("订单同步入参-----" + sapShopOrderQuery.toString());
|
|
|
|
|
JCoRepository repository = dest.getRepository();
|
|
|
|
|
JCoFunction func = repository.getFunction("ZPPR_MES_PRO_TO");
|
|
|
|
|
if (func == null) {
|
|
|
|
|
throw new RuntimeException("Function does not exist in SAP");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
JCoParameterList jCoParameterList= func.getTableParameterList();
|
|
|
|
|
JCoParameterList js= func.getExportParameterList();
|
|
|
|
|
JCoParameterList jCoParameterList = func.getTableParameterList();
|
|
|
|
|
JCoParameterList js = func.getExportParameterList();
|
|
|
|
|
// System.out.println(js);
|
|
|
|
|
// System.out.println(jCoParameterList);
|
|
|
|
|
// 配置传入参数
|
|
|
|
|
// 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");
|
|
|
|
|
S_WERKS.appendRow();
|
|
|
|
|
S_WERKS.setValue(Constants.SIGN, "I");
|
|
|
|
|
S_WERKS.setValue(Constants.OPTION, "EQ");
|
|
|
|
|
S_WERKS.setValue(Constants.LOW, sapShopOrderQuery.getWerk());
|
|
|
|
|
}
|
|
|
|
|
if (!StringUtils.isNull(sapShopOrderQuery.getAufnr())){
|
|
|
|
|
if (!StringUtils.isNull(sapShopOrderQuery.getAufnr())) {
|
|
|
|
|
JCoTable S_AUFNR = func.getTableParameterList().getTable("S_AUFNR");
|
|
|
|
|
S_AUFNR.appendRow();
|
|
|
|
|
S_AUFNR.setValue(Constants.SIGN, "I");
|
|
|
|
@ -75,14 +77,14 @@ public class SapOrderServiceImpl implements SapOrderService {
|
|
|
|
|
S_AUFNR.setValue(Constants.LOW, sapShopOrderQuery.getAufnr());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!StringUtils.isNull(sapShopOrderQuery.getMatnr())){
|
|
|
|
|
if (!StringUtils.isNull(sapShopOrderQuery.getMatnr())) {
|
|
|
|
|
JCoTable S_MATNR = func.getTableParameterList().getTable("S_MATNR");
|
|
|
|
|
S_MATNR.appendRow();
|
|
|
|
|
S_MATNR.setValue(Constants.SIGN, "I");
|
|
|
|
|
S_MATNR.setValue(Constants.OPTION, "EQ");
|
|
|
|
|
S_MATNR.setValue(Constants.LOW,sapShopOrderQuery.getMatnr());
|
|
|
|
|
S_MATNR.setValue(Constants.LOW, sapShopOrderQuery.getMatnr());
|
|
|
|
|
}
|
|
|
|
|
if (!StringUtils.isNull(sapShopOrderQuery.getErdat())){
|
|
|
|
|
if (!StringUtils.isNull(sapShopOrderQuery.getErdat())) {
|
|
|
|
|
JCoTable S_ERDAT = func.getTableParameterList().getTable("S_ERDAT");
|
|
|
|
|
S_ERDAT.appendRow();
|
|
|
|
|
S_ERDAT.setValue(Constants.SIGN, "I");
|
|
|
|
@ -92,9 +94,6 @@ public class SapOrderServiceImpl implements SapOrderService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func.execute(dest);//执行调用函数
|
|
|
|
|
// 获取 内表 - ZMES_PRO
|
|
|
|
|
JCoTable maraTable = func.getTableParameterList().getTable("ZMES_PRO");
|
|
|
|
@ -121,7 +120,7 @@ public class SapOrderServiceImpl implements SapOrderService {
|
|
|
|
|
String ERDAT = maraTable.getString("ERDAT");
|
|
|
|
|
String STTXT = maraTable.getString("STTXT");
|
|
|
|
|
String VERID = maraTable.getString("VERID");
|
|
|
|
|
log.info("订单输出------:"+"订单号:" + AUFNR +"工单层数:"+CEGCI+ " - 订单类型:" + AUART + "-生产版本:"+ VERID +" -上级订单编号:" + MAUFNR + " - 物料号:" + PLNBEZ + " - 物料描述(短文本):" + MAKTX
|
|
|
|
|
log.info("订单输出------:" + "订单号:" + AUFNR + "工单层数:" + CEGCI + " - 订单类型:" + AUART + "-生产版本:" + VERID + " -上级订单编号:" + MAUFNR + " - 物料号:" + PLNBEZ + " - 物料描述(短文本):" + MAKTX
|
|
|
|
|
+ " - 订单的计划工厂:" + PWERK + " - 订单数量总计:" + GAMNG + " - 基本计量单位:" + GMEIN + " - 任务清单组码:" + PLNNR + " - 基本开始日期:" + GSTRP
|
|
|
|
|
+ " - 基本完成日期:" + GLTRP + " - 输入者:" + ERNAM + " - 创建日期:" + ERDAT + " - 系统状态:" + STTXT);
|
|
|
|
|
// System.out.println("订单号:" + AUFNR + " - 订单类型:" + AUART + " - 上级订单编号:" + MAUFNR + " - 物料号:" + PLNBEZ + " - 物料描述(短文本):" + MAKTX
|
|
|
|
@ -163,11 +162,11 @@ public class SapOrderServiceImpl implements SapOrderService {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public R<List<String>> SapCreateOrder(List<SapCreateOrder> sapCreateOrderList) {
|
|
|
|
|
String L_MSG=null;
|
|
|
|
|
String L_MSG = null;
|
|
|
|
|
try {
|
|
|
|
|
//获取连接
|
|
|
|
|
// JCoDestination dest = SAPConnUtils.connect();
|
|
|
|
|
log.info("订单创建入参-----"+JSONObject.toJSONString(sapCreateOrderList));
|
|
|
|
|
// JCoDestination dest = SAPConnUtils.connect();
|
|
|
|
|
log.info("订单创建入参-----" + JSONObject.toJSONString(sapCreateOrderList));
|
|
|
|
|
JCoRepository repository = dest.getRepository();
|
|
|
|
|
JCoFunction func = repository.getFunction("ZPPR_MES_PRODORD_CREATE");
|
|
|
|
|
if (func == null) {
|
|
|
|
@ -177,23 +176,23 @@ public class SapOrderServiceImpl implements SapOrderService {
|
|
|
|
|
// 配置传入参数
|
|
|
|
|
JCoParameterList jCoParameterList = func.getImportParameterList();
|
|
|
|
|
|
|
|
|
|
if (sapCreateOrderList!=null && sapCreateOrderList.size()>0){
|
|
|
|
|
List<String> LV_ORDER_NUM_List=new ArrayList<>();
|
|
|
|
|
for (SapCreateOrder sapCreateOrder:sapCreateOrderList){
|
|
|
|
|
jCoParameterList.setValue("P_WERKS",sapCreateOrder.getWerks());
|
|
|
|
|
jCoParameterList.setValue("P_AUFPAR",sapCreateOrder.getAufpar());
|
|
|
|
|
jCoParameterList.setValue("P_MATNR",sapCreateOrder.getMatnr());
|
|
|
|
|
jCoParameterList.setValue("P_QUANTITY",sapCreateOrder.getQuantity());
|
|
|
|
|
jCoParameterList.setValue("P_DATES",sapCreateOrder.getDates());
|
|
|
|
|
jCoParameterList.setValue("P_DATEE",sapCreateOrder.getDatee());
|
|
|
|
|
jCoParameterList.setValue("P_VERID",sapCreateOrder.getVerid());
|
|
|
|
|
if (sapCreateOrderList != null && sapCreateOrderList.size() > 0) {
|
|
|
|
|
List<String> LV_ORDER_NUM_List = new ArrayList<>();
|
|
|
|
|
for (SapCreateOrder sapCreateOrder : sapCreateOrderList) {
|
|
|
|
|
jCoParameterList.setValue("P_WERKS", sapCreateOrder.getWerks());
|
|
|
|
|
jCoParameterList.setValue("P_AUFPAR", sapCreateOrder.getAufpar());
|
|
|
|
|
jCoParameterList.setValue("P_MATNR", sapCreateOrder.getMatnr());
|
|
|
|
|
jCoParameterList.setValue("P_QUANTITY", sapCreateOrder.getQuantity());
|
|
|
|
|
jCoParameterList.setValue("P_DATES", sapCreateOrder.getDates());
|
|
|
|
|
jCoParameterList.setValue("P_DATEE", sapCreateOrder.getDatee());
|
|
|
|
|
jCoParameterList.setValue("P_VERID", sapCreateOrder.getVerid());
|
|
|
|
|
func.execute(dest);//执行调用函数
|
|
|
|
|
JCoParameterList J= func.getExportParameterList();
|
|
|
|
|
L_MSG= func.getExportParameterList().getString("L_MSG");
|
|
|
|
|
JCoTable LT_ZGD=func.getTableParameterList().getTable("LT_ZGD");
|
|
|
|
|
String LV_ORDER_NUMBER=J.getString("LV_ORDER_NUMBER");
|
|
|
|
|
JCoParameterList J = func.getExportParameterList();
|
|
|
|
|
L_MSG = func.getExportParameterList().getString("L_MSG");
|
|
|
|
|
JCoTable LT_ZGD = func.getTableParameterList().getTable("LT_ZGD");
|
|
|
|
|
String LV_ORDER_NUMBER = J.getString("LV_ORDER_NUMBER");
|
|
|
|
|
LV_ORDER_NUM_List.add(LV_ORDER_NUMBER);
|
|
|
|
|
for (int i = 0; i <LT_ZGD.getNumRows(); i++) {
|
|
|
|
|
for (int i = 0; i < LT_ZGD.getNumRows(); i++) {
|
|
|
|
|
LT_ZGD.setRow(i);
|
|
|
|
|
String LEAD_AUFNR = LT_ZGD.getString("LEAD_AUFNR");
|
|
|
|
|
String AUFNR = LT_ZGD.getString("AUFNR");
|
|
|
|
@ -206,14 +205,14 @@ public class SapOrderServiceImpl implements SapOrderService {
|
|
|
|
|
.distinct()
|
|
|
|
|
.sorted((s1, s2) -> s2.compareTo(s1))
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
log.info("订单创建结果----"+L_MSG+"|"+JSONObject.toJSONString(uniqueAndSorted));
|
|
|
|
|
return R.ok(uniqueAndSorted,L_MSG);
|
|
|
|
|
}else {
|
|
|
|
|
log.info("订单创建结果----" + L_MSG + "|" + JSONObject.toJSONString(uniqueAndSorted));
|
|
|
|
|
return R.ok(uniqueAndSorted, L_MSG);
|
|
|
|
|
} else {
|
|
|
|
|
log.error("接收的数据为空");
|
|
|
|
|
return R.fail("接收的数据为空");
|
|
|
|
|
}
|
|
|
|
|
}catch (Exception e){
|
|
|
|
|
log.error(L_MSG+e.getMessage());
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
log.error(L_MSG + e.getMessage());
|
|
|
|
|
return R.fail(L_MSG);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -225,8 +224,8 @@ public class SapOrderServiceImpl implements SapOrderService {
|
|
|
|
|
StringBuilder Msg = new StringBuilder();
|
|
|
|
|
try {
|
|
|
|
|
//获取连接
|
|
|
|
|
// JCoDestination dest = SAPConnUtils.connect();
|
|
|
|
|
log.info("订单关闭入参------"+sapCloseOrderQuery.toString());
|
|
|
|
|
// JCoDestination dest = SAPConnUtils.connect();
|
|
|
|
|
log.info("订单关闭入参------" + sapCloseOrderQuery.toString());
|
|
|
|
|
JCoRepository repository = dest.getRepository();
|
|
|
|
|
JCoFunction func = repository.getFunction("ZMES_AUFNR_CLOSE");
|
|
|
|
|
if (func == null) {
|
|
|
|
@ -235,34 +234,34 @@ public class SapOrderServiceImpl implements SapOrderService {
|
|
|
|
|
|
|
|
|
|
// 配置传入参数
|
|
|
|
|
JCoParameterList jCoParameterList = func.getImportParameterList();
|
|
|
|
|
if (CollectionUtils.isEmpty(sapCloseOrderQuery.getOrderCodes())){
|
|
|
|
|
if (CollectionUtils.isEmpty(sapCloseOrderQuery.getOrderCodes())) {
|
|
|
|
|
return R.fail("订单集合为空");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//关闭订单
|
|
|
|
|
for(String orderCode:sapCloseOrderQuery.getOrderCodes()){
|
|
|
|
|
jCoParameterList.setValue("P_AUFNR",orderCode);
|
|
|
|
|
for (String orderCode : sapCloseOrderQuery.getOrderCodes()) {
|
|
|
|
|
jCoParameterList.setValue("P_AUFNR", orderCode);
|
|
|
|
|
func.execute(dest);//执行调用函数
|
|
|
|
|
String L_MSG1= func.getExportParameterList().getString("L_MSG");
|
|
|
|
|
Msg.append(orderCode+"-"+L_MSG1+";");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
log.info("订单关闭结果"+Msg.toString());
|
|
|
|
|
return R.ok(null,Msg.toString());
|
|
|
|
|
}catch (Exception e){
|
|
|
|
|
log.error("订单关闭失败"+e.getMessage());
|
|
|
|
|
String L_MSG1 = func.getExportParameterList().getString("L_MSG");
|
|
|
|
|
Msg.append(orderCode + "-" + L_MSG1 + ";");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
log.info("订单关闭结果" + Msg.toString());
|
|
|
|
|
return R.ok(null, Msg.toString());
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
log.error("订单关闭失败" + e.getMessage());
|
|
|
|
|
return R.fail(e.getMessage());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public R sapRFWOrder(SapRFW sapRFW) {
|
|
|
|
|
String json= JSONObject.toJSONString(sapRFW);
|
|
|
|
|
String json = JSONObject.toJSONString(sapRFW);
|
|
|
|
|
System.out.println(json);
|
|
|
|
|
String MESSAGE=null;
|
|
|
|
|
String MESSAGE = null;
|
|
|
|
|
try {
|
|
|
|
|
//获取连接
|
|
|
|
|
// JCoDestination dest = SAPConnUtils.connect();
|
|
|
|
|
// JCoDestination dest = SAPConnUtils.connect();
|
|
|
|
|
JCoRepository repository = dest.getRepository();
|
|
|
|
|
JCoFunction func = repository.getFunction("ZPPR_MES_PRODORDCONF_CREATE_TT");
|
|
|
|
|
if (func == null) {
|
|
|
|
@ -270,32 +269,32 @@ public class SapOrderServiceImpl implements SapOrderService {
|
|
|
|
|
}
|
|
|
|
|
// 配置传入参数
|
|
|
|
|
JCoParameterList jCoParameterList = func.getImportParameterList();
|
|
|
|
|
if (StringUtils.isEmpty(sapRFW.getAufnr())){
|
|
|
|
|
if (StringUtils.isEmpty(sapRFW.getAufnr())) {
|
|
|
|
|
return R.fail("订单号为空");
|
|
|
|
|
}
|
|
|
|
|
if (StringUtils.isEmpty(sapRFW.getGamng())){
|
|
|
|
|
if (StringUtils.isEmpty(sapRFW.getGamng())) {
|
|
|
|
|
return R.fail("报工数量为空");
|
|
|
|
|
}
|
|
|
|
|
if (StringUtils.isEmpty(sapRFW.getAnzma())){
|
|
|
|
|
if (StringUtils.isEmpty(sapRFW.getAnzma())) {
|
|
|
|
|
return R.fail("产线编号为空");
|
|
|
|
|
}
|
|
|
|
|
//订单号
|
|
|
|
|
jCoParameterList.setValue("P_AUFNR",sapRFW.getAufnr());
|
|
|
|
|
jCoParameterList.setValue("P_AUFNR", sapRFW.getAufnr());
|
|
|
|
|
//报工数量
|
|
|
|
|
jCoParameterList.setValue("P_GAMNG",sapRFW.getGamng());
|
|
|
|
|
jCoParameterList.setValue("P_GAMNG", sapRFW.getGamng());
|
|
|
|
|
//产线编号
|
|
|
|
|
jCoParameterList.setValue("P_ANZMA",sapRFW.getAnzma());
|
|
|
|
|
if (sapRFW.getLt_gs()==null){
|
|
|
|
|
jCoParameterList.setValue("P_ANZMA", sapRFW.getAnzma());
|
|
|
|
|
if (sapRFW.getLt_gs() == null) {
|
|
|
|
|
return R.fail("生产订单报工工时为空");
|
|
|
|
|
}
|
|
|
|
|
if (sapRFW.getLt_hwList()==null){
|
|
|
|
|
if (sapRFW.getLt_hwList() == null) {
|
|
|
|
|
return R.fail("生产订单报工货物移动为空");
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* 生产订单报工工时 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.setValue("CONF_ACTIVITY1", sapRFW.getLt_gs().getConf_activity1());
|
|
|
|
|
LT_GS_jCoTable.setValue("CONF_ACTIVITY2", sapRFW.getLt_gs().getConf_activity2());
|
|
|
|
@ -308,7 +307,7 @@ public class SapOrderServiceImpl implements SapOrderService {
|
|
|
|
|
*/
|
|
|
|
|
JCoTable LT_HW_jCoTable = func.getTableParameterList().getTable("LT_HW");
|
|
|
|
|
//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.setValue("MATERIAL", lt_hw.getMaterial());
|
|
|
|
|
LT_HW_jCoTable.setValue("ENTRY_QNT", lt_hw.getEntry_qnt());
|
|
|
|
@ -316,16 +315,16 @@ public class SapOrderServiceImpl implements SapOrderService {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func.execute(dest);//执行调用函数
|
|
|
|
|
JCoParameterList J= func.getExportParameterList();
|
|
|
|
|
JCoParameterList J = func.getExportParameterList();
|
|
|
|
|
System.out.println(func.getExportParameterList());
|
|
|
|
|
String RETCODE= func.getExportParameterList().getString("RETCODE");
|
|
|
|
|
MESSAGE= func.getExportParameterList().getString("MESSAGE");
|
|
|
|
|
if (Constants.FAIL.equals(Integer.parseInt(RETCODE))){
|
|
|
|
|
return R.fail("订单号:"+sapRFW.getAufnr()+"报工失败"+MESSAGE);
|
|
|
|
|
String RETCODE = func.getExportParameterList().getString("RETCODE");
|
|
|
|
|
MESSAGE = func.getExportParameterList().getString("MESSAGE");
|
|
|
|
|
if (Constants.FAIL.equals(Integer.parseInt(RETCODE))) {
|
|
|
|
|
return R.fail("订单号:" + sapRFW.getAufnr() + "报工失败" + MESSAGE);
|
|
|
|
|
}
|
|
|
|
|
return R.ok("",MESSAGE);
|
|
|
|
|
return R.ok("", MESSAGE);
|
|
|
|
|
|
|
|
|
|
}catch (Exception e){
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
return R.fail(e.getMessage());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -338,7 +337,7 @@ public class SapOrderServiceImpl implements SapOrderService {
|
|
|
|
|
//JCoDestination dest = SAPConnUtils.connect();
|
|
|
|
|
JCoRepository repository = dest.getRepository();
|
|
|
|
|
JCoFunction func = repository.getFunction("ZMES_GET_PROCURE");
|
|
|
|
|
JCoParameterList jCoParameterList= func.getTableParameterList();
|
|
|
|
|
JCoParameterList jCoParameterList = func.getTableParameterList();
|
|
|
|
|
System.out.println(jCoParameterList);
|
|
|
|
|
if (func == null) {
|
|
|
|
|
throw new RuntimeException("Function does not exist in SAP");
|
|
|
|
@ -348,21 +347,21 @@ public class SapOrderServiceImpl implements SapOrderService {
|
|
|
|
|
* S_MATNR 物料号
|
|
|
|
|
* S_PWERK 工厂
|
|
|
|
|
*/
|
|
|
|
|
if (!StringUtils.isNull(sapPurchaseOrderQuery.getEbeln())){
|
|
|
|
|
if (!StringUtils.isNull(sapPurchaseOrderQuery.getEbeln())) {
|
|
|
|
|
JCoTable S_EBELN = func.getTableParameterList().getTable("S_EBELN");
|
|
|
|
|
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())){
|
|
|
|
|
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())){
|
|
|
|
|
if (!StringUtils.isNull(sapPurchaseOrderQuery.getMatnr())) {
|
|
|
|
|
JCoTable S_MATNR = func.getTableParameterList().getTable("S_MATNR");
|
|
|
|
|
S_MATNR.appendRow();
|
|
|
|
|
S_MATNR.setValue(Constants.SIGN, "I");
|
|
|
|
@ -370,7 +369,7 @@ public class SapOrderServiceImpl implements SapOrderService {
|
|
|
|
|
S_MATNR.setValue(Constants.LOW, sapPurchaseOrderQuery.getMatnr());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!StringUtils.isNull(sapPurchaseOrderQuery.getPwerk())){
|
|
|
|
|
if (!StringUtils.isNull(sapPurchaseOrderQuery.getPwerk())) {
|
|
|
|
|
JCoTable S_PWERK = func.getTableParameterList().getTable("S_PWERK");
|
|
|
|
|
S_PWERK.appendRow();
|
|
|
|
|
S_PWERK.setValue(Constants.SIGN, "I");
|
|
|
|
@ -382,10 +381,10 @@ public class SapOrderServiceImpl implements SapOrderService {
|
|
|
|
|
JCoTable maraTable = func.getTableParameterList().getTable("LT_PROCURE");
|
|
|
|
|
JCoRecordMetaData metaData = maraTable.getRecordMetaData();
|
|
|
|
|
System.out.println("###" + metaData.toString());
|
|
|
|
|
List<SapPurchaseOrderQuery> sapPurchaseOrderQueryList=new ArrayList<>();
|
|
|
|
|
List<SapPurchaseOrderQuery> sapPurchaseOrderQueryList = new ArrayList<>();
|
|
|
|
|
for (int i = 0; i < maraTable.getNumRows(); i++) {
|
|
|
|
|
maraTable.setRow(i);
|
|
|
|
|
SapPurchaseOrderQuery sapPCorder=new SapPurchaseOrderQuery();
|
|
|
|
|
SapPurchaseOrderQuery sapPCorder = new SapPurchaseOrderQuery();
|
|
|
|
|
String EBELN = maraTable.getString("EBELN");
|
|
|
|
|
String EBELP = maraTable.getString("EBELP");
|
|
|
|
|
String MATNR = maraTable.getString("MATNR");
|
|
|
|
@ -401,20 +400,20 @@ public class SapOrderServiceImpl implements SapOrderService {
|
|
|
|
|
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);
|
|
|
|
|
"采购凭证号" + EBELN +
|
|
|
|
|
"采购凭证的项目编号" + EBELP +
|
|
|
|
|
"物料号" + MATNR +
|
|
|
|
|
"物料描述(短文本)" + MAKTX +
|
|
|
|
|
"采购订单数量" + MENGE +
|
|
|
|
|
"采购订单的计量单位" + MEINS +
|
|
|
|
|
"交货数量" + ZMENGE +
|
|
|
|
|
"基本计量单位" + ZMEINS +
|
|
|
|
|
"供应商帐户号" + LIFNR +
|
|
|
|
|
"工厂" + WERKS +
|
|
|
|
|
"库存地点" + LGORT +
|
|
|
|
|
"项目交货日期" + EINDT +
|
|
|
|
|
"交货已完成标识" + ELIKZ +
|
|
|
|
|
"注释" + BEIZHU);
|
|
|
|
|
|
|
|
|
|
sapPCorder.setEbeln(EBELN);
|
|
|
|
|
sapPCorder.setEbelp(EBELP);
|
|
|
|
@ -433,7 +432,7 @@ public class SapOrderServiceImpl implements SapOrderService {
|
|
|
|
|
sapPurchaseOrderQueryList.add(sapPCorder);
|
|
|
|
|
}
|
|
|
|
|
return R.ok(sapPurchaseOrderQueryList);
|
|
|
|
|
}catch (Exception e){
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
return R.fail(e.getMessage());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -442,7 +441,7 @@ public class SapOrderServiceImpl implements SapOrderService {
|
|
|
|
|
@Override
|
|
|
|
|
public R shopUpdateSync(SapShopOrderQuery sapProOrder) {
|
|
|
|
|
try {
|
|
|
|
|
log.info("订单修改入参-------"+sapProOrder.toString());
|
|
|
|
|
log.info("订单修改入参-------" + sapProOrder.toString());
|
|
|
|
|
JCoRepository repository = dest.getRepository();
|
|
|
|
|
JCoFunction func = repository.getFunction("ZPPR_MES_PRODORD_CHANGE");
|
|
|
|
|
// 配置传入参数
|
|
|
|
@ -451,29 +450,27 @@ public class SapOrderServiceImpl implements SapOrderService {
|
|
|
|
|
if (func == null) {
|
|
|
|
|
throw new RuntimeException("Function does not exist in SAP");
|
|
|
|
|
}
|
|
|
|
|
if (StringUtils.isEmpty(sapProOrder.getAufnr()))
|
|
|
|
|
{
|
|
|
|
|
if (StringUtils.isEmpty(sapProOrder.getAufnr())) {
|
|
|
|
|
return R.fail("订单号为空!");
|
|
|
|
|
}
|
|
|
|
|
if (StringUtils.isEmpty(sapProOrder.getQuantity()))
|
|
|
|
|
{
|
|
|
|
|
if (StringUtils.isEmpty(sapProOrder.getQuantity())) {
|
|
|
|
|
return R.fail("数量为空!");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
jCoParameterList.setValue("P_AUFNR",sapProOrder.getAufnr());
|
|
|
|
|
jCoParameterList.setValue("P_QUANTITY",sapProOrder.getQuantity());
|
|
|
|
|
jCoParameterList.setValue("P_AUFNR", sapProOrder.getAufnr());
|
|
|
|
|
jCoParameterList.setValue("P_QUANTITY", sapProOrder.getQuantity());
|
|
|
|
|
func.execute(dest);//执行调用函数
|
|
|
|
|
JCoParameterList J= func.getExportParameterList();
|
|
|
|
|
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){
|
|
|
|
|
JCoParameterList J = func.getExportParameterList();
|
|
|
|
|
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());
|
|
|
|
|
}
|
|
|
|
@ -482,7 +479,7 @@ public class SapOrderServiceImpl implements SapOrderService {
|
|
|
|
|
@Override
|
|
|
|
|
public R sapOrderReceipt(List<Map<String, Object>> mapList) {
|
|
|
|
|
try {
|
|
|
|
|
log.info("智慧工厂101类型订单收货入参-------"+mapList.toString());
|
|
|
|
|
log.info("智慧工厂101类型订单收货入参-------" + mapList.toString());
|
|
|
|
|
JCoRepository repository = dest.getRepository();
|
|
|
|
|
JCoFunction func = repository.getFunction("ZMES_101_MIGO");
|
|
|
|
|
//System.out.println(jCoParameterList);
|
|
|
|
@ -492,30 +489,30 @@ public class SapOrderServiceImpl implements SapOrderService {
|
|
|
|
|
// 配置传入参数
|
|
|
|
|
JCoTable L_ITEM = func.getTableParameterList().getTable("L_ITEM");
|
|
|
|
|
|
|
|
|
|
for (Map<String, Object> stringObjectMap:mapList){
|
|
|
|
|
for (Map<String, Object> stringObjectMap : mapList) {
|
|
|
|
|
L_ITEM.appendRow();
|
|
|
|
|
L_ITEM.setValue("AUFNR",stringObjectMap.get("AUFNR"));
|
|
|
|
|
L_ITEM.setValue("WERKS",stringObjectMap.get("WERKS"));
|
|
|
|
|
L_ITEM.setValue("LGORT",stringObjectMap.get("LGORT"));
|
|
|
|
|
L_ITEM.setValue("QUANTITY",stringObjectMap.get("QUANTITY"));
|
|
|
|
|
L_ITEM.setValue("BATCH",stringObjectMap.get("BATCH"));
|
|
|
|
|
L_ITEM.setValue("HSDAT",stringObjectMap.get("HSDAT"));
|
|
|
|
|
L_ITEM.setValue("ERFME",stringObjectMap.get("ERFME"));
|
|
|
|
|
L_ITEM.setValue("AUFNR", stringObjectMap.get("AUFNR"));
|
|
|
|
|
L_ITEM.setValue("WERKS", stringObjectMap.get("WERKS"));
|
|
|
|
|
L_ITEM.setValue("LGORT", stringObjectMap.get("LGORT"));
|
|
|
|
|
L_ITEM.setValue("QUANTITY", stringObjectMap.get("QUANTITY"));
|
|
|
|
|
L_ITEM.setValue("BATCH", stringObjectMap.get("BATCH"));
|
|
|
|
|
L_ITEM.setValue("HSDAT", stringObjectMap.get("HSDAT"));
|
|
|
|
|
L_ITEM.setValue("ERFME", stringObjectMap.get("ERFME"));
|
|
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
|
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(MESSAGE);
|
|
|
|
|
}else {
|
|
|
|
|
log.info("订单收货结果-----"+MESSAGE);
|
|
|
|
|
return R.ok(MATERIALDOCUMENT,MESSAGE);
|
|
|
|
|
} else {
|
|
|
|
|
log.info("订单收货结果-----" + MESSAGE);
|
|
|
|
|
return R.ok(MATERIALDOCUMENT, MESSAGE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}catch (Exception e){
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
log.error(e.getMessage());
|
|
|
|
|
return R.fail(e.getMessage());
|
|
|
|
|
}
|
|
|
|
@ -529,7 +526,7 @@ public class SapOrderServiceImpl implements SapOrderService {
|
|
|
|
|
if (func == null) {
|
|
|
|
|
throw new RuntimeException("Function does not exist in SAP");
|
|
|
|
|
}
|
|
|
|
|
log.info("采购订单收货过账ZMES_PROMIGO_CREATE-------"+mapList.toString());
|
|
|
|
|
log.info("采购订单收货过账ZMES_PROMIGO_CREATE-------" + mapList.toString());
|
|
|
|
|
/**
|
|
|
|
|
EBELN 采购凭证号
|
|
|
|
|
EBELP 采购凭证的项目编号
|
|
|
|
@ -545,7 +542,7 @@ public class SapOrderServiceImpl implements SapOrderService {
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
JCoTable L_ITEM = func.getTableParameterList().getTable("L_ITEM");
|
|
|
|
|
for (Map<String, Object> stringObjectMap:mapList){
|
|
|
|
|
for (Map<String, Object> stringObjectMap : mapList) {
|
|
|
|
|
L_ITEM.appendRow();
|
|
|
|
|
L_ITEM.setValue("EBELN", stringObjectMap.get("EBELN"));
|
|
|
|
|
L_ITEM.setValue("EBELP", stringObjectMap.get("EBELP"));
|
|
|
|
@ -569,33 +566,82 @@ public class SapOrderServiceImpl implements SapOrderService {
|
|
|
|
|
for (int i = 0; i < LT_RETURN.getNumRows(); i++) {
|
|
|
|
|
LT_RETURN.setRow(i);
|
|
|
|
|
String MESSAGE = LT_RETURN.getString("MESSAGE");
|
|
|
|
|
Msg.append(MESSAGE+"/");
|
|
|
|
|
Msg.append(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());
|
|
|
|
|
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());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}catch (Exception e){
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
log.error(e.getMessage());
|
|
|
|
|
return R.fail(e.getMessage());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public R shopOrderBomUpdate(List<Map<String, Object>> mapList) {
|
|
|
|
|
int successNum = 0;
|
|
|
|
|
int failureNum = 0;
|
|
|
|
|
StringBuilder successMsg = new StringBuilder();
|
|
|
|
|
StringBuilder failureMsg = new StringBuilder();
|
|
|
|
|
try {
|
|
|
|
|
JCoRepository repository = dest.getRepository();
|
|
|
|
|
JCoFunction func = repository.getFunction("ZMES_AUFNR_CHANGE");
|
|
|
|
|
if (func == null) {
|
|
|
|
|
throw new RuntimeException("Function does not exist in SAP");
|
|
|
|
|
}
|
|
|
|
|
log.info("生产订单组件修改-------" + mapList.toString());
|
|
|
|
|
|
|
|
|
|
JCoParameterList jCoParameterList = func.getImportParameterList();
|
|
|
|
|
|
|
|
|
|
for (Map m : mapList) {
|
|
|
|
|
jCoParameterList.setValue("P_AUFNR", m.get("P_AUFNR"));
|
|
|
|
|
jCoParameterList.setValue("P_MATNR", m.get("P_MATNR"));
|
|
|
|
|
jCoParameterList.setValue("P_GMEIN", m.get("P_GMEIN"));
|
|
|
|
|
jCoParameterList.setValue("P_WERKS", m.get("P_WERKS"));
|
|
|
|
|
jCoParameterList.setValue("P_LGORT", m.get("P_LGORT"));
|
|
|
|
|
func.execute(dest);//执行调用函数
|
|
|
|
|
//获取结果
|
|
|
|
|
String L_MSG = func.getExportParameterList().getString("MSG");
|
|
|
|
|
String RETCODE = func.getExportParameterList().getString("RETCODE");
|
|
|
|
|
|
|
|
|
|
if (Constants.SUCCESS.equals(Integer.parseInt(RETCODE))){
|
|
|
|
|
successNum++;
|
|
|
|
|
successMsg.append("<br/>" + successNum + "、物料:"+m.get("P_MATNR")+L_MSG);
|
|
|
|
|
}else {
|
|
|
|
|
failureNum++;
|
|
|
|
|
failureMsg.append("<br/>" + failureNum + "、物料 " +m.get("P_MATNR")+L_MSG);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
log.error(e.getMessage());
|
|
|
|
|
return R.fail(e.getMessage());
|
|
|
|
|
}
|
|
|
|
|
if (failureNum > 0) {
|
|
|
|
|
failureMsg.insert(0, "很抱歉,添加SAP组件失败!共 " + failureNum + " 条数据格式不正确,错误如下:");
|
|
|
|
|
throw new ServiceException(failureMsg.toString());
|
|
|
|
|
// return R.fail(failureMsg.toString());
|
|
|
|
|
} else {
|
|
|
|
|
successMsg.insert(0, "恭喜您,添加SAP组件成功!共 " + successNum + " 条,数据如下:");
|
|
|
|
|
}
|
|
|
|
|
return R.ok(successMsg);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|