增加SAP订单修改接口和@Bean依赖先后顺序

highway
Yangwl 10 months ago
parent da12afa045
commit 8e815945eb

@ -62,6 +62,17 @@ public class SapController extends BaseController {
return sapOrderService.shopOrderSync(sapProOrder); return sapOrderService.shopOrderSync(sapProOrder);
} }
/**
* SAP
*
*/
@PostMapping("/shopUpdateSync")
@Log(title = "修改SAP订单", businessType = BusinessType.SAP)
public R shopUpdateSync(@RequestBody SapShopOrderQuery sapProOrder){
return sapOrderService.shopUpdateSync(sapProOrder);
}
/** /**
* *
* @param * @param
@ -357,5 +368,16 @@ public class SapController extends BaseController {
} }
/**
*
*/
@PostMapping("/sapPurchaseOrderSync")
@Log(title = "获取采购订单", businessType = BusinessType.SAP)
public R sapPurchaseOrderSync(@RequestBody SapPurchaseOrderQuery sapPurchaseOrderQuery){
return sapOrderService.sapPurchaseOrderSync(sapPurchaseOrderQuery);
}
} }

@ -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.SapPurchaseOrderQuery;
import com.op.system.api.domain.sap.SapCreateOrder; import com.op.system.api.domain.sap.SapCreateOrder;
import com.op.system.api.domain.sap.SapRFW; import com.op.system.api.domain.sap.SapRFW;
import com.op.system.api.domain.sap.SapShopOrderQuery; import com.op.system.api.domain.sap.SapShopOrderQuery;
@ -44,4 +45,8 @@ public interface SapOrderService {
*/ */
R sapRFWOrder(SapRFW sapRFW); R sapRFWOrder(SapRFW sapRFW);
R sapPurchaseOrderSync(SapPurchaseOrderQuery sapPurchaseOrderQuery);
R shopUpdateSync(SapShopOrderQuery sapProOrder);
} }

@ -6,6 +6,7 @@ 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.SapPurchaseOrderQuery;
import com.op.sap.service.SapOrderService; import com.op.sap.service.SapOrderService;
import com.op.sap.util.SAPConnUtils; import com.op.sap.util.SAPConnUtils;
@ -296,6 +297,98 @@ public class SapOrderServiceImpl implements SapOrderService {
return R.fail(e.getMessage()); return R.fail(e.getMessage());
} }
} }
@Override
public R sapPurchaseOrderSync(SapPurchaseOrderQuery sapPurchaseOrderQuery) {
try {
// 获取调用 RFC 函数对象
//获取连接
//JCoDestination dest = SAPConnUtils.connect();
JCoRepository repository = dest.getRepository();
JCoFunction func = repository.getFunction("ZMES_GET_PROCURE");
JCoParameterList jCoParameterList= func.getTableParameterList();
System.out.println(jCoParameterList);
if (func == null) {
throw new RuntimeException("Function does not exist in SAP");
}
/** S_EBELN
* S_EBELP
* S_MATNR
* S_PWERK
*/
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.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.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, sapPurchaseOrderQuery.getMatnr());
}
if (!StringUtils.isNull(sapPurchaseOrderQuery.getPwerk())){
JCoTable S_PWERK = func.getTableParameterList().getTable("S_PWERK");
S_PWERK.appendRow();
S_PWERK.setValue(Constants.SIGN, "I");
S_PWERK.setValue(Constants.OPTION, "EQ");
S_PWERK.setValue(Constants.LOW, sapPurchaseOrderQuery.getPwerk());
}
func.execute(dest);//执行调用函数
// 获取 内表 - LT_PROCURE
JCoTable maraTable = func.getTableParameterList().getTable("LT_PROCURE");
JCoRecordMetaData metaData = maraTable.getRecordMetaData();
System.out.println("###" + metaData.toString());
return R.ok();
}catch (Exception e){
return R.fail(e.getMessage());
}
}
@Override
public R shopUpdateSync(SapShopOrderQuery sapProOrder) {
try {
JCoRepository repository = dest.getRepository();
JCoFunction func = repository.getFunction("ZPPR_MES_PRODORD_CHANGE");
// 配置传入参数
JCoParameterList jCoParameterList = func.getImportParameterList();
System.out.println(jCoParameterList);
if (func == null) {
throw new RuntimeException("Function does not exist in SAP");
}
if (StringUtils.isEmpty(sapProOrder.getAufnr()))
{
return R.fail("订单号为空!");
}
if (StringUtils.isEmpty(sapProOrder.getQuantity()))
{
return R.fail("数量为空!");
}
jCoParameterList.setValue("P_AUFNR",sapProOrder.getAufnr());
jCoParameterList.setValue("P_QUANTITY",sapProOrder.getQuantity());
func.execute(dest);//执行调用函数
JCoParameterList J= func.getExportParameterList();
System.out.println(J);
String MESSAGE= func.getExportParameterList().getString("MESSAGE");
System.out.println(MESSAGE);
return R.ok(MESSAGE);
}catch (Exception e){
return R.fail(e.getMessage());
}
}
} }

@ -7,6 +7,7 @@ import com.sap.conn.jco.JCoException;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.DependsOn;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@Component @Component
@ -16,6 +17,7 @@ public class SAPConnUtils {
private static final String ABAP_AS_POOLED = "ABAP_AS_WITH_POOL"; private static final String ABAP_AS_POOLED = "ABAP_AS_WITH_POOL";
@Bean @Bean
@DependsOn("CreateABAP")
public JCoDestination connect() { public JCoDestination connect() {
JCoDestination destination = null; JCoDestination destination = null;
try { try {

Loading…
Cancel
Save