添加SAP接口ZWM3A21【获取物料的属性信息(仓库、库位、批次管理、序号管理,是否质检)】

添加 SAP接口 ZWM00_MB113(厂内调库过账的接口)
This commit is contained in:
zhangke 2025-08-16 18:37:25 +08:00
parent 7c2734ff19
commit ea1ba6bd5b
11 changed files with 231 additions and 2 deletions

View File

@ -109,11 +109,9 @@ public class NormalPGIControllerService {
List<WmsSrmOrderItem> orderItemList = wmsSrmOrderItemService.lambdaQuery()
.eq(WmsSrmOrderItem::getOrderId, order.getId())
.list();
if (CollectionUtil.isEmpty(orderItemList)) {
return pdaOrderVO;
}
// if (CollectionUtil.isNotEmpty(orderItemList)) {
List<PDAOrderItemVO> orderItemVOList = new ArrayList<>();
// 遍历订单行项目填充详细信息并从 SAP 获取补充数据
for (WmsSrmOrderItem item : orderItemList) {

View File

@ -1016,6 +1016,106 @@ public class SapService {
return result;
}
/**
* 厂内调库过账接口
* <p>
* 该方法用于调用 SAP RFC 函数 ZWM00_MB113完成厂内调库的过账操作
* </p>
*
* @param query 查询参数对象包含过账所需的输入信息和物料明细列表
* @return 返回包含物料凭证号MBLNR和年度MJAHR的结果对象
*/
// 厂内调库过账接口
public ZWM00MB113DTO zwm3a11(ZWM00MB113QO query) {
// 校验查询参数及物料明细是否为空
VUtil.trueThrowBusinessError(Objects.isNull(query)).throwMessage("查询内容不可以为空");
VUtil.trueThrowBusinessError(CollectionUtil.isEmpty(query.getT_list1())).throwMessage("物料明细不能为空");
// 构造函数调用所需的输入参数
Map<String, Object> parameters = new HashMap<>();
parameters.put("I_RSNUM", query.getIRsnum());
parameters.put("I_UMLGO", query.getIUmlgo());
parameters.put("I_USNAM", UserUtil.getUserName());
// 将构造好的表数据放入输入参数中
Map<String, List<Map<String, Object>>> tables = new HashMap<>();
if (CollectionUtil.isNotEmpty(query.getT_list1())) {
tables.put("T_LIST1", JCoUtil.toMapList(query.getT_list1()));
}
if (CollectionUtil.isNotEmpty(query.getT_list2())) {
tables.put("T_LIST2", JCoUtil.toMapList(query.getT_list2()));
}
// 调用 SAP RFC 函数 ZWM00_MB112
JCoFunction function = exec("ZWM00_MB113", parameters, tables);
// 处理返回表 T_RETURN判断执行是否成功
JCoTable returnTable = function.getTableParameterList().getTable("T_RETURN");
VUtil.trueThrowBusinessError(returnTable.getNumRows() <= 0).throwMessage("获取Type信息有误");
returnTable.setRow(0);
VUtil.trueThrowBusinessError(!StrUtil.equals(returnTable.getString("TYPE"), "S"))
.throwMessage(returnTable.getString("MESSAGE"));
log.info("SAP返回: {}", returnTable);
// 获取导出参数构造返回结果对象
JCoParameterList exportParam = function.getExportParameterList();
VUtil.trueThrowBusinessError(Objects.isNull(exportParam)).throwMessage("无法获取到有效的物料凭证信息");
ZWM00MB113DTO result = new ZWM00MB113DTO()
.setEMjahr(exportParam.getString("E_MJAHR"))
.setEMblnr(exportParam.getString("E_MBLNR"));
log.info("SAP返回物料凭证信息: MBLNR={}, MJAHR={}", result.getEMblnr(), result.getEMjahr());
return result;
}
/**
* 获取物料的属性信息仓库库位批次管理序号管理是否质检
*
* @param query 查询条件封装对象包含工厂仓库物料等信息
* @return 物料属性信息列表每个元素为 {@link ZWM3A21ResultDTO} 类型
*/
public List<ZWM3A21ResultDTO> zwm3a21(ZWM3A21QueryDTO query) {
// 校验查询参数及物料明细是否为空
VUtil.trueThrowBusinessError(Objects.isNull(query)).throwMessage("查询内容不可以为空");
VUtil.trueThrowBusinessError(CollectionUtil.isEmpty(query.getIt_matnr())).throwMessage("物料明细不能为空");
// 构造函数调用所需的输入参数
Map<String, Object> parameters = new HashMap<>();
parameters.put("I_WERKS", query.getI_werks());
// 将构造好的表数据放入输入参数中
Map<String, List<Map<String, Object>>> tables = new HashMap<>();
if (CollectionUtil.isNotEmpty(query.getIt_lgort())) {
tables.put("IT_LGORT", JCoUtil.toMapList(query.getIt_lgort()));
}
if (CollectionUtil.isNotEmpty(query.getIt_matnr())) {
tables.put("IT_MATNR", JCoUtil.toMapList(query.getIt_matnr()));
}
// 调用 SAP RFC 函数 ZWM3A21
JCoFunction function = exec("ZWM3A21", parameters, tables);
// 获取并校验导出参数判断调用是否成功
JCoParameterList exportParam = function.getExportParameterList();
VUtil.trueThrowBusinessError(Objects.isNull(exportParam)).throwMessage("无法获取到有效的物料信息");
VUtil.trueThrowBusinessError(!StrUtil.equals(exportParam.getString("TYPE"), "S"))
.throwMessage(exportParam.getString("MESSAGE"));
// 处理返回表数据转换为结果对象列表
JCoTable returnTable = function.getTableParameterList().getTable("T_OUT");
VUtil.trueThrowBusinessError(returnTable.getNumRows() <= 0).throwMessage("获取物料信息有误");
log.info("SAP返回: {}", returnTable);
if(returnTable.getNumRows() > 0)
{
return JCoUtil.toBeanList(returnTable, ZWM3A21ResultDTO.class);
}
else
{
return Collections.emptyList();
}
}
private JCoTable execReturnTable(String functionName, Map<String, Object> parameters) {
return execReturnTable(functionName, parameters, null, "T_OUT");
}

View File

@ -153,6 +153,13 @@ public class SapMetaPrintTest {
printMeta("ZWM00_MB116");
}
@Test
public void ZWM3A21() throws JCoException {
printMeta("ZWM3A21");
}
public void printMeta(String functionName) throws JCoException {
functionName = functionName.toUpperCase();
JCoFunction function = repository.getFunction(functionName);

View File

@ -0,0 +1,13 @@
package com.nflg.wms.common.pojo.dto;
import lombok.Data;
import lombok.experimental.Accessors;
@Data
@Accessors(chain = true)
public class ZWM00MB113DTO {
// 物料凭证年度
private String eMjahr;
// 物料凭证编号
private String eMblnr;
}

View File

@ -0,0 +1,11 @@
package com.nflg.wms.common.pojo.dto;
import lombok.Data;
import lombok.experimental.Accessors;
@Data
@Accessors(chain = true)
public class ZWM3A21LgortItemDTO {
//库存地点
private String lgort;
}

View File

@ -0,0 +1,11 @@
package com.nflg.wms.common.pojo.dto;
import lombok.Data;
import lombok.experimental.Accessors;
@Data
@Accessors(chain = true)
public class ZWM3A21MatnrItemDTO {
//物料号
private String matnr;
}

View File

@ -0,0 +1,17 @@
package com.nflg.wms.common.pojo.dto;
import lombok.Data;
import java.util.List;
@Data
public class ZWM3A21QueryDTO{
//工厂
private String i_werks;
// 库存地点
private List<ZWM3A21LgortItemDTO> it_lgort;
//物料号
private List<ZWM3A21MatnrItemDTO>it_matnr;
}

View File

@ -0,0 +1,23 @@
package com.nflg.wms.common.pojo.dto;
import lombok.Data;
import lombok.experimental.Accessors;
@Data
@Accessors(chain = true)
public class ZWM3A21ResultDTO {
//工厂
private String werks;
//物料描述短文本
private String maktx;
//序列号参数文件
private String sernp;
//物料编号
private String matnr;
//库存仓位
private String lgpbe;
//批次管理需求的标识
private String xchpf;
//kzkri
private String kzkri;
}

View File

@ -0,0 +1,19 @@
package com.nflg.wms.common.pojo.qo;
import lombok.Data;
@Data
public class ZWM00MB113LIST1QO {
//工厂
private String werks;
//库存地点
private String lgort;
//以输入单位计的数量
private String erfmg;
//物料号
private String matnr;
//基本计量单位
private String meins;
//预留/相关需求的项目编号
private String rspos;
}

View File

@ -0,0 +1,13 @@
package com.nflg.wms.common.pojo.qo;
import lombok.Data;
@Data
public class ZWM00MB113LIST2QO {
//序列号
private String sernr;
//标志X表示合格品空表示不合格品
private String flag;
//预留/相关需求的项目编号
private String rspos;
}

View File

@ -0,0 +1,17 @@
package com.nflg.wms.common.pojo.qo;
import lombok.Data;
import java.util.List;
@Data
public class ZWM00MB113QO {
//预留/相关需求的编号
private String iRsnum;
//收货/发货库存地点
private String iUmlgo;
//创建311物料凭证接口输入结构
private List<ZWM00MB113LIST1QO> t_list1;
//创建311物料凭证接口序列号结构
private List<ZWM00MB113LIST2QO> t_list2;
}