SAP的储位仓库信息接口

master
Yangwl 2 years ago
parent b3d73b8b4d
commit 801bf00af5

@ -74,4 +74,8 @@ public interface RemoteSapService {
/**订单物料领料过账、原材料补料、订单物料退料过账接口MB1A**/
public R sapMaterialPosting(@RequestBody List<SapMaterialPosting> sapMaterialPostingList);
/**智慧工厂储位信息*/
@PostMapping("/sap/sapLgortInfo")
public R sapLgortInfo(@RequestBody(required = false) Map<String, Object> map);
}

@ -89,6 +89,11 @@ public class RemoteSapFallbackFactory implements FallbackFactory<RemoteSapServic
return R.fail("订单物料领料过账、原材料补料、订单物料退料过账接口MB1A失败" + throwable.getMessage());
}
@Override
public R sapLgortInfo(Map<String, Object> map) {
return R.fail("储位仓库信息获取失败" + throwable.getMessage());
}
};
}
}

@ -53,6 +53,9 @@ public class SapController extends BaseController {
@Autowired
private SapBomMapper sapBomMapper;
@Autowired
private SapWmsService sapWmsService;
/**====================主数据相关===================================================================================*/
/**
*
@ -414,4 +417,32 @@ public class SapController extends BaseController {
return sapOrderService.sapOrderReceipt(sapOrderReceiptQuery);
}
/**================================WMS=============================*/
/**
*
* @param map
* @return
*/
@PostMapping("/sapLgortInfo")
@Log(title = "智慧工厂储位信息", businessType = BusinessType.SAP)
public R sapLgortInfo(@RequestBody(required = false) Map<String, Object> map){
return sapWmsService.sapLgortInfo(map);
}
/**
* 线
*ZMES_201_MB1A
* ZMES_961_MB1A
* ZMES_962_MB1A
* @param
* @return
*/
@PostMapping("/sapProductWarehousing")
@Log(title = "成品下线入库", businessType = BusinessType.SAP)
public R sapProductWarehousing(@RequestBody(required = false) List<Map<String, Object>> mapList){
return sapWmsService.sapProductWarehousing(mapList);
}
}

@ -54,4 +54,6 @@ public interface SapOrderService {
R shopUpdateSync(SapShopOrderQuery sapProOrder);
R sapOrderReceipt(SapOrderReceiptQuery sapOrderReceiptQuery);
}

@ -0,0 +1,13 @@
package com.op.sap.service;
import com.op.common.core.domain.R;
import java.util.List;
import java.util.Map;
public interface SapWmsService {
R sapLgortInfo(Map<String, Object> map);
R sapProductWarehousing(List<Map<String, Object>> mapList);
}

@ -0,0 +1,208 @@
package com.op.sap.service.impl;
import com.op.common.core.domain.R;
import com.op.common.core.utils.StringUtils;
import com.op.sap.service.SapWmsService;
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;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Component
@Service
public class SapWmsServicelmpl implements SapWmsService {
private static final Logger log = LoggerFactory.getLogger(SapWmsServicelmpl.class);
@Autowired
private JCoDestination dest;
@Override
public R sapLgortInfo(Map<String, Object> map) {
try {
JCoRepository repository = dest.getRepository();
JCoFunction func = repository.getFunction("ZMES_GET_LGORT");
if (func == null) {
throw new RuntimeException("Function does not exist in SAP");
}
log.info("获取储位信息入参-------"+map.toString());
if (!StringUtils.isNull(map.get("S_WERKS"))){
JCoTable S_MATNR = func.getTableParameterList().getTable("S_WERKS");
S_MATNR.appendRow();
S_MATNR.setValue("SIGN", "I");
S_MATNR.setValue("OPTION", "EQ");
S_MATNR.setValue("LOW", map.get("S_WERKS"));
}
func.execute(dest);//执行调用函数
// 获取 内表 - ZMES_PRO
JCoTable maraTable = func.getTableParameterList().getTable("LT_LGORT");
/**
* WERKS
* LGORT
* LGOBE
* ZTYPE
*/
List<Map> mapList=new ArrayList<>();
for (int i = 0; i <maraTable.getNumRows(); i++) {
maraTable.setRow(i);
String WERKS = maraTable.getString("WERKS");
String LGORT = maraTable.getString("LGORT");
String LGOBE = maraTable.getString("LGOBE");
String ZTYPE = maraTable.getString("ZTYPE");
log.info("工厂:" + WERKS+
"库存地点:" + LGORT+
"仓储地点的描述:" + LGOBE+
"已冻结标识:" + ZTYPE);
Map entyMap=new HashMap();
entyMap.put("WERKS",WERKS);
entyMap.put("LGORT",LGORT);
entyMap.put("LGOBE",LGOBE);
entyMap.put("ZTYPE",ZTYPE);
mapList.add(entyMap);
}
return R.ok(mapList);
}catch (Exception e){
log.error(e.getMessage());
return R.fail(e.getMessage());
}
}
@Override
public R sapProductWarehousing(List<Map<String, Object>> mapList) {
try {
JCoRepository repository = dest.getRepository();
JCoFunction func = repository.getFunction("ZMES_PRODUCT_MB1A");
if (func == null) {
throw new RuntimeException("Function does not exist in SAP");
}
log.info("成品移动ZMES_PRODUCT_MB1A-------"+mapList.toString());
/**
AUFNR
POSNR
BWART
PLANT
LGORT
KOSTL
MATNR
QUANTITY
MEINS
BATCH
HSDAT
VFDAT 寿
*/
JCoTable L_ITEM = func.getTableParameterList().getTable("L_ITEM");
System.out.println(L_ITEM);
System.out.println( L_ITEM.getNumRows());
for (int i=1;i<10;i++){
L_ITEM.appendRow();
L_ITEM.setValue("AUFNR", "01234567890"+String.valueOf(i));
L_ITEM.setValue("POSN", "012"+String.valueOf(i));
L_ITEM.setValue("POSN", "012"+String.valueOf(i));
L_ITEM.setValue("POSN", "012"+String.valueOf(i));
}
System.out.println(L_ITEM);
// if (!StringUtils.isNull(map.get("AUFNR"))){
// JCoTable S_MATNR = func.getTableParameterList().getTable("AUFNR");
// S_MATNR.appendRow();
// S_MATNR.setValue("SIGN", "I");
// S_MATNR.setValue("OPTION", "EQ");
// S_MATNR.setValue("LOW", map.get("AUFNR"));
// }
// if (!StringUtils.isNull(map.get("POSNR"))){
// JCoTable S_MATNR = func.getTableParameterList().getTable("POSNR");
// S_MATNR.appendRow();
// S_MATNR.setValue("SIGN", "I");
// S_MATNR.setValue("OPTION", "EQ");
// S_MATNR.setValue("LOW", map.get("POSNR"));
// }
// if (!StringUtils.isNull(map.get("BWART"))){
// JCoTable S_MATNR = func.getTableParameterList().getTable("BWART");
// S_MATNR.appendRow();
// S_MATNR.setValue("SIGN", "I");
// S_MATNR.setValue("OPTION", "EQ");
// S_MATNR.setValue("LOW", map.get("BWART"));
// }
// if (!StringUtils.isNull(map.get("PLANT"))){
// JCoTable S_MATNR = func.getTableParameterList().getTable("PLANT");
// S_MATNR.appendRow();
// S_MATNR.setValue("SIGN", "I");
// S_MATNR.setValue("OPTION", "EQ");
// S_MATNR.setValue("LOW", map.get("PLANT"));
// }
// if (!StringUtils.isNull(map.get("LGORT"))){
// JCoTable S_MATNR = func.getTableParameterList().getTable("LGORT");
// S_MATNR.appendRow();
// S_MATNR.setValue("SIGN", "I");
// S_MATNR.setValue("OPTION", "EQ");
// S_MATNR.setValue("LOW", map.get("LGORT"));
// }
// if (!StringUtils.isNull(map.get("KOSTL"))){
// JCoTable S_MATNR = func.getTableParameterList().getTable("KOSTL");
// S_MATNR.appendRow();
// S_MATNR.setValue("SIGN", "I");
// S_MATNR.setValue("OPTION", "EQ");
// S_MATNR.setValue("LOW", map.get("KOSTL"));
// }
// if (!StringUtils.isNull(map.get("MATNR"))){
// JCoTable S_MATNR = func.getTableParameterList().getTable("MATNR");
// S_MATNR.appendRow();
// S_MATNR.setValue("SIGN", "I");
// S_MATNR.setValue("OPTION", "EQ");
// S_MATNR.setValue("LOW", map.get("MATNR"));
// }
// if (!StringUtils.isNull(map.get("QUANTITY"))){
// JCoTable S_MATNR = func.getTableParameterList().getTable("QUANTITY");
// S_MATNR.appendRow();
// S_MATNR.setValue("SIGN", "I");
// S_MATNR.setValue("OPTION", "EQ");
// S_MATNR.setValue("LOW", map.get("QUANTITY"));
// }
// if (!StringUtils.isNull(map.get("MEINS"))){
// JCoTable S_MATNR = func.getTableParameterList().getTable("MEINS");
// S_MATNR.appendRow();
// S_MATNR.setValue("SIGN", "I");
// S_MATNR.setValue("OPTION", "EQ");
// S_MATNR.setValue("LOW", map.get("MEINS"));
// }
// if (!StringUtils.isNull(map.get("BATCH"))){
// JCoTable S_MATNR = func.getTableParameterList().getTable("BATCH");
// S_MATNR.appendRow();
// S_MATNR.setValue("SIGN", "I");
// S_MATNR.setValue("OPTION", "EQ");
// S_MATNR.setValue("LOW", map.get("BATCH"));
// }
// func.execute(dest);//执行调用函数
// // 获取 内表 - ZMES_PRO
// JCoTable maraTable = func.getTableParameterList().getTable("LT_LGORT");
//
// List<Map> mapList=new ArrayList<>();
// for (int i = 0; i <maraTable.getNumRows(); i++) {
// maraTable.setRow(i);
// String WERKS = maraTable.getString("WERKS");
// String LGORT = maraTable.getString("LGORT");
// String LGOBE = maraTable.getString("LGOBE");
// String ZTYPE = maraTable.getString("ZTYPE");
// log.info("工厂:" + WERKS+
// "库存地点:" + LGORT+
// "仓储地点的描述:" + LGOBE+
// "已冻结标识:" + ZTYPE);
// Map entyMap=new HashMap();
// entyMap.put("WERKS",WERKS);
// entyMap.put("LGORT",LGORT);
// entyMap.put("LGOBE",LGOBE);
// entyMap.put("ZTYPE",ZTYPE);
// mapList.add(entyMap);
// }
return R.ok();
}catch (Exception e){
log.error(e.getMessage());
return R.fail(e.getMessage());
}
}
}
Loading…
Cancel
Save