|
|
|
@ -34,7 +34,7 @@ import java.util.Map;
|
|
|
|
|
@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;
|
|
|
|
|
|
|
|
|
@ -46,29 +46,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");
|
|
|
|
@ -76,14 +76,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");
|
|
|
|
@ -93,11 +93,14 @@ public class SapOrderServiceImpl implements SapOrderService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func.execute(dest);//执行调用函数
|
|
|
|
|
// 获取 内表 - 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 数据
|
|
|
|
@ -118,8 +121,7 @@ public class SapOrderServiceImpl implements SapOrderService {
|
|
|
|
|
String ERDAT = maraTable.getString("ERDAT");
|
|
|
|
|
String STTXT = maraTable.getString("STTXT");
|
|
|
|
|
String VERID = maraTable.getString("VERID");
|
|
|
|
|
|
|
|
|
|
log.info("订单输出------:" + "订单号:" + AUFNR + " - 订单类型:" + AUART + " - 生产版本:" + VERID + " - 上级订单编号:" + MAUFNR + " - 物料号:" + PLNBEZ + " - 物料描述(短文本):" + MAKTX
|
|
|
|
|
log.info("订单输出------:"+"订单号:" + AUFNR + " - 订单类型:" + AUART + "-生产版本:"+ VERID +" -上级订单编号:" + MAUFNR + " - 物料号:" + PLNBEZ + " - 物料描述(短文本):" + MAKTX
|
|
|
|
|
+ " - 订单的计划工厂:" + PWERK + " - 订单数量总计:" + GAMNG + " - 基本计量单位:" + GMEIN + " - 任务清单组码:" + PLNNR + " - 基本开始日期:" + GSTRP
|
|
|
|
|
+ " - 基本完成日期:" + GLTRP + " - 输入者:" + ERNAM + " - 创建日期:" + ERDAT + " - 系统状态:" + STTXT);
|
|
|
|
|
// System.out.println("订单号:" + AUFNR + " - 订单类型:" + AUART + " - 上级订单编号:" + MAUFNR + " - 物料号:" + PLNBEZ + " - 物料描述(短文本):" + MAKTX
|
|
|
|
@ -160,11 +162,11 @@ public class SapOrderServiceImpl implements SapOrderService {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public R<List<Map<String, 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) {
|
|
|
|
@ -174,39 +176,38 @@ public class SapOrderServiceImpl implements SapOrderService {
|
|
|
|
|
// 配置传入参数
|
|
|
|
|
JCoParameterList jCoParameterList = func.getImportParameterList();
|
|
|
|
|
|
|
|
|
|
if (sapCreateOrderList != null && sapCreateOrderList.size() > 0) {
|
|
|
|
|
List<Map<String, 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<Map<String,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());
|
|
|
|
|
func.execute(dest);//执行调用函数
|
|
|
|
|
JCoParameterList J = func.getExportParameterList();
|
|
|
|
|
JCoParameterList J= func.getExportParameterList();
|
|
|
|
|
System.out.println(func.getExportParameterList());
|
|
|
|
|
L_MSG = func.getExportParameterList().getString("L_MSG");
|
|
|
|
|
JCoTable LT_ZGD = func.getTableParameterList().getTable("LT_ZGD");
|
|
|
|
|
for (int i = 0; i < LT_ZGD.getNumRows(); i++) {
|
|
|
|
|
L_MSG= func.getExportParameterList().getString("L_MSG");
|
|
|
|
|
JCoTable LT_ZGD=func.getTableParameterList().getTable("LT_ZGD");
|
|
|
|
|
for (int i = 0; i <LT_ZGD.getNumRows(); i++) {
|
|
|
|
|
LT_ZGD.setRow(i);
|
|
|
|
|
Map map = new HashMap();
|
|
|
|
|
Map map=new HashMap();
|
|
|
|
|
String LEAD_AUFNR = LT_ZGD.getString("LEAD_AUFNR");
|
|
|
|
|
String AUFNR = LT_ZGD.getString("AUFNR");
|
|
|
|
|
map.put("LEAD_AUFNR", LEAD_AUFNR);
|
|
|
|
|
map.put("AUFNR", AUFNR);
|
|
|
|
|
map.put("LEAD_AUFNR",LEAD_AUFNR);
|
|
|
|
|
map.put("AUFNR",AUFNR);
|
|
|
|
|
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.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());
|
|
|
|
|
}catch (Exception e){
|
|
|
|
|
log.error(L_MSG+e.getMessage());
|
|
|
|
|
return R.fail(L_MSG);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -214,11 +215,12 @@ public class SapOrderServiceImpl implements SapOrderService {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public R sapCloseOrder(SapCloseOrderQuery sapCloseOrderQuery) {
|
|
|
|
|
|
|
|
|
|
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("ZPPR_MES_PRODORD_CLOSE");
|
|
|
|
|
if (func == null) {
|
|
|
|
@ -227,40 +229,41 @@ public class SapOrderServiceImpl implements SapOrderService {
|
|
|
|
|
|
|
|
|
|
// 配置传入参数
|
|
|
|
|
JCoParameterList jCoParameterList = func.getImportParameterList();
|
|
|
|
|
if (StringUtils.isEmpty(sapCloseOrderQuery.getLeadOrder())) {
|
|
|
|
|
if (StringUtils.isEmpty(sapCloseOrderQuery.getLeadOrder())){
|
|
|
|
|
return R.fail("母订单号为空");
|
|
|
|
|
}
|
|
|
|
|
if (StringUtils.isEmpty(sapCloseOrderQuery.getOrder())) {
|
|
|
|
|
if (StringUtils.isEmpty(sapCloseOrderQuery.getOrder())){
|
|
|
|
|
return R.fail("子订单号为空");
|
|
|
|
|
}
|
|
|
|
|
//关闭母订单
|
|
|
|
|
jCoParameterList.setValue("P_AUFNR", sapCloseOrderQuery.getLeadOrder());
|
|
|
|
|
func.execute(dest);//执行调用函数
|
|
|
|
|
jCoParameterList.setValue("P_AUFNR",sapCloseOrderQuery.getLeadOrder());
|
|
|
|
|
func.execute(dest);//执行调用函数
|
|
|
|
|
// JCoParameterList J= func.getExportParameterList();
|
|
|
|
|
// System.out.println(J);
|
|
|
|
|
String L_MSG1 = func.getExportParameterList().getString("L_MSG");
|
|
|
|
|
Msg.append(sapCloseOrderQuery.getLeadOrder() + L_MSG1 + ";");
|
|
|
|
|
//关闭子订单
|
|
|
|
|
jCoParameterList.setValue("P_AUFNR", sapCloseOrderQuery.getOrder());
|
|
|
|
|
String L_MSG1= func.getExportParameterList().getString("L_MSG");
|
|
|
|
|
Msg.append(sapCloseOrderQuery.getLeadOrder()+L_MSG1+";");
|
|
|
|
|
|
|
|
|
|
//关闭子订单
|
|
|
|
|
jCoParameterList.setValue("P_AUFNR",sapCloseOrderQuery.getOrder());
|
|
|
|
|
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());
|
|
|
|
|
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());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@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) {
|
|
|
|
@ -269,26 +272,27 @@ 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("报工数量为空");
|
|
|
|
|
}
|
|
|
|
|
//订单号
|
|
|
|
|
jCoParameterList.setValue("P_AUFNR", sapRFW.getAufnr());
|
|
|
|
|
jCoParameterList.setValue("P_AUFNR",sapRFW.getAufnr());
|
|
|
|
|
//报工数量
|
|
|
|
|
jCoParameterList.setValue("P_GAMNG", sapRFW.getGamng());
|
|
|
|
|
if (sapRFW.getLt_gs() == null) {
|
|
|
|
|
jCoParameterList.setValue("P_GAMNG",sapRFW.getGamng());
|
|
|
|
|
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);
|
|
|
|
|
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());
|
|
|
|
@ -300,21 +304,25 @@ public class SapOrderServiceImpl implements SapOrderService {
|
|
|
|
|
* MES生产订单报工货物移动修改 LT_HW
|
|
|
|
|
*/
|
|
|
|
|
JCoTable LT_HW_jCoTable = func.getTableParameterList().getTable("LT_HW");
|
|
|
|
|
for (SapRFW.lt_hw lt_hw : sapRFW.getLt_hwList()) {
|
|
|
|
|
//System.out.println("LT_HW_jCoTable"+LT_HW_jCoTable);
|
|
|
|
|
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());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func.execute(dest);//执行调用函数
|
|
|
|
|
String RETCODE = func.getExportParameterList().getString("RETCODE");
|
|
|
|
|
MESSAGE = func.getExportParameterList().getString("MESSAGE");
|
|
|
|
|
if (Constants.RFW_FAIL.equals(RETCODE)) {
|
|
|
|
|
log.error("订单号:" + sapRFW.getAufnr() + "报工失败" + MESSAGE);
|
|
|
|
|
return R.fail("订单号:" + sapRFW.getAufnr() + "报工失败" + MESSAGE);
|
|
|
|
|
}
|
|
|
|
|
log.error("订单号:" + sapRFW.getAufnr() + "报工成功" + MESSAGE);
|
|
|
|
|
return R.ok("", MESSAGE);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
JCoParameterList J= func.getExportParameterList();
|
|
|
|
|
System.out.println(func.getExportParameterList());
|
|
|
|
|
String RETCODE= func.getExportParameterList().getString("RETCODE");
|
|
|
|
|
MESSAGE= func.getExportParameterList().getString("MESSAGE");
|
|
|
|
|
if (Constants.FAIL.equals(RETCODE)){
|
|
|
|
|
return R.fail("订单号:"+sapRFW.getAufnr()+"报工失败"+MESSAGE);
|
|
|
|
|
}
|
|
|
|
|
return R.ok("",MESSAGE);
|
|
|
|
|
|
|
|
|
|
}catch (Exception e){
|
|
|
|
|
return R.fail(e.getMessage());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -327,7 +335,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");
|
|
|
|
@ -337,21 +345,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");
|
|
|
|
@ -359,7 +367,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");
|
|
|
|
@ -371,10 +379,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");
|
|
|
|
@ -390,20 +398,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);
|
|
|
|
@ -422,15 +430,16 @@ public class SapOrderServiceImpl implements SapOrderService {
|
|
|
|
|
sapPurchaseOrderQueryList.add(sapPCorder);
|
|
|
|
|
}
|
|
|
|
|
return R.ok(sapPurchaseOrderQueryList);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
}catch (Exception e){
|
|
|
|
|
return R.fail(e.getMessage());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@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");
|
|
|
|
|
// 配置传入参数
|
|
|
|
@ -439,27 +448,29 @@ 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());
|
|
|
|
|
}
|
|
|
|
@ -468,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);
|
|
|
|
@ -478,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());
|
|
|
|
|
}
|
|
|
|
@ -515,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 采购凭证的项目编号
|
|
|
|
@ -531,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"));
|
|
|
|
@ -555,28 +566,28 @@ 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());
|
|
|
|
|
}
|
|
|
|
|