|
@@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.pms.sap;
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
import cn.hutool.core.util.ObjUtil;
|
|
|
+import cn.iocoder.yudao.framework.tenant.core.util.TenantUtils;
|
|
|
import cn.iocoder.yudao.module.pms.sap.service.IotSapService;
|
|
|
import cn.iocoder.yudao.module.pms.sap.vo.IotSapMaterialVO;
|
|
|
import cn.iocoder.yudao.module.system.api.saporg.SapOrgApi;
|
|
@@ -88,11 +89,11 @@ public class SapController {
|
|
|
if (ObjUtil.isEmpty(function)) {
|
|
|
return "No SAP Function";
|
|
|
}
|
|
|
- // 设置输入参数
|
|
|
+ // 设置输入参数 暂时只同步2025年的数据
|
|
|
JCoParameterList input = function.getImportParameterList();
|
|
|
input.setValue("I_WERKS", "6011");
|
|
|
// 暂时只设置同步 2025年后的 领料单 2025年之前的领料单 手动入库
|
|
|
- input.setValue("I_DATUM_F", "20250101"); // 开始日期
|
|
|
+ // input.setValue("I_DATUM_F", "20250101"); // 开始日期
|
|
|
// input.setValue("I_DATUM_T", "20251231"); // 结束日期
|
|
|
|
|
|
// 执行 RFC 调用
|
|
@@ -110,21 +111,21 @@ public class SapController {
|
|
|
if (headTable != null && headTable.getNumRows() > 0) {
|
|
|
for (int i = 0; i < headTable.getNumRows(); i++) {
|
|
|
headTable.setRow(i);
|
|
|
- System.out.println(String.format("行号 %d: 工厂=%s, 名称 1=%s, 领料/退料编号=%s, ZLLLX=%s, " +
|
|
|
- "日期=%tT, 项目定义=%s, WBS 元素=%s, 描述=%s, 所属项目部=%s, 描述=%s, 成本中心=%s, 描述=%s\n",
|
|
|
+ System.out.println(String.format("行号 %d: 工厂=%s, 名称 1=%s, 领料/退料编号=%s, 领料/退料单名称=%s, " +
|
|
|
+ "日期=%tT, 项目定义=%s, WBS 元素=%s, 描述=%s, 所属项目部=%s, 所属项目部描述=%s, 成本中心=%s, 成本中心描述=%s\n",
|
|
|
i,
|
|
|
- headTable.getString("WERKS"),
|
|
|
- headTable.getString("TXTMD"),
|
|
|
- headTable.getString("ZLTNO"),
|
|
|
- headTable.getString("ZLLLX"),
|
|
|
- headTable.getString("DATUM"),
|
|
|
- headTable.getString("PSPID"),
|
|
|
- headTable.getString("POSID"),
|
|
|
- headTable.getString("POST1"),
|
|
|
- headTable.getString("ZSSXMB"),
|
|
|
- headTable.getString("LGOBE"),
|
|
|
- headTable.getString("KOSTL"),
|
|
|
- headTable.getString("LTEXT")
|
|
|
+ headTable.getString("WERKS"), // 工厂code
|
|
|
+ headTable.getString("TXTMD"), // 工厂名称
|
|
|
+ headTable.getString("ZLTNO"), // 领料/退料编号
|
|
|
+ headTable.getString("ZLLLX"), // 领料/退料单名称
|
|
|
+ headTable.getDate("DATUM"), // 日期
|
|
|
+ headTable.getString("PSPID"), // 项目定义
|
|
|
+ headTable.getString("POSID"), // WBS元素
|
|
|
+ headTable.getString("POST1"), // 描述 50032队/YB058-H02井
|
|
|
+ headTable.getString("ZSSXMB"), // 所属项目部
|
|
|
+ headTable.getString("LGOBE"), // 所属项目部描述
|
|
|
+ headTable.getString("KOSTL"), // 成本中心
|
|
|
+ headTable.getString("LTEXT") // 成本中心描述
|
|
|
));
|
|
|
}
|
|
|
}
|
|
@@ -133,23 +134,35 @@ public class SapController {
|
|
|
if (itemTable != null && itemTable.getNumRows() > 0) {
|
|
|
for (int i = 0; i < itemTable.getNumRows(); i++) {
|
|
|
itemTable.setRow(i);
|
|
|
- System.out.println(String.format("行号 %d: ZNUMC=%s, 物料=%s, 描述=%s, 数量=%f, " +
|
|
|
- "基本单位=%s, 特殊库存=%s, 移动原因=%s, 原因=%s, 库存地点=%s, 描述=%s, 库存仓位=%s, 批次=%s, 转入工厂=%s, BEIZHU=%s\n",
|
|
|
+ System.out.println(String.format("行号 %d: 工厂编号=%s, 领料/退料编号=%s, 物料编码=%s, 物料描述=%s, " +
|
|
|
+ "物料数量=%s, 基本单位=%s, 特殊库存=%s, 移动原因=%s, 原因=%s, 库存地点编码=%s, 库存地点描述=%s, 库存仓位=%s, 批次=%s, 转入工厂=%s\n" +
|
|
|
+ "备注=%s, 物料凭证编号=%s, 物料凭证年度=%s, 行项目号=%s, 本位币金额(单价)=%s, 货币码=%s, 交易后库存数量 - 以输入单位计=%s, 本位币库存总价值=%s, 价格控制标识=%s, 移动平均价或标准价=%s\n",
|
|
|
i,
|
|
|
- headTable.getString("ZNUMC"),
|
|
|
- headTable.getString("MATNR"),
|
|
|
- headTable.getString("MAKTX"),
|
|
|
- headTable.getString("MENGE"),
|
|
|
- headTable.getString("MEINS"),
|
|
|
- headTable.getString("SOBKZ"),
|
|
|
- headTable.getString("GRUND"),
|
|
|
- headTable.getString("GRTXT"),
|
|
|
- headTable.getString("LGORT"),
|
|
|
- headTable.getString("LGOBE"),
|
|
|
- headTable.getString("LGPBE"),
|
|
|
- headTable.getString("CHARG"),
|
|
|
- headTable.getString("WERKS_ZR"),
|
|
|
- headTable.getString("BEIZHU")
|
|
|
+ itemTable.getString("WERKS"), // 工厂编号
|
|
|
+ itemTable.getString("ZLTNO"), // 领料/退料编号
|
|
|
+ itemTable.getString("MATNR"), // 物料编码
|
|
|
+ itemTable.getString("MAKTX"), // 物料描述
|
|
|
+ itemTable.getBigDecimal("MENGE"), // 物料数量
|
|
|
+ itemTable.getString("MEINS"), // 基本单位
|
|
|
+ itemTable.getString("SOBKZ"), // 特殊库存
|
|
|
+ itemTable.getString("GRUND"), // 移动原因
|
|
|
+ itemTable.getString("GRTXT"), // 原因
|
|
|
+ itemTable.getString("LGORT"), // 库存地点编码
|
|
|
+ itemTable.getString("LGOBE"), // 库存地点描述
|
|
|
+ itemTable.getString("LGPBE"), // 库存仓位
|
|
|
+ itemTable.getString("CHARG"), // 批次
|
|
|
+ itemTable.getString("WERKS_ZR"), // 转入工厂
|
|
|
+ itemTable.getString("BEIZHU"), // 备注
|
|
|
+ // 无文档描述
|
|
|
+ itemTable.getString("MBLNR"), // 物料凭证编号
|
|
|
+ itemTable.getString("MJAHR"), // 物料凭证年度
|
|
|
+ itemTable.getString("ZEILE"), // 行项目号
|
|
|
+ itemTable.getBigDecimal("DMBTR"), // 本位币金额(单价)
|
|
|
+ itemTable.getString("WAERS"), // 货币码
|
|
|
+ itemTable.getBigDecimal("LBKUM"), // 交易后库存数量 - 以输入单位计
|
|
|
+ itemTable.getBigDecimal("SALK3"), // 本位币库存总价值
|
|
|
+ itemTable.getString("VPRSV"), // 价格控制标识
|
|
|
+ itemTable.getBigDecimal("VERPR") // 移动平均价或标准价
|
|
|
));
|
|
|
}
|
|
|
}
|
|
@@ -223,7 +236,7 @@ public class SapController {
|
|
|
//
|
|
|
try {
|
|
|
JCoDestination destination = sapConnector.getDestination();
|
|
|
- JCoFunction function = destination.getRepository().getFunction("BAPI_MATERIAL_GETLIST");
|
|
|
+ JCoFunction function = destination.getRepository().getFunction("ZPMS_001");
|
|
|
|
|
|
// 设置输入参数
|
|
|
/* JCoParameterList input = function.getImportParameterList();
|
|
@@ -232,7 +245,7 @@ public class SapController {
|
|
|
input.setValue("IV_MAKTX", ""); // 物料描述 */
|
|
|
|
|
|
// JCoTable materialRange = function.getTableParameterList().getTable("MATNR_RANGE");
|
|
|
- function.getImportParameterList().setValue("MATERIAL_TYPE", "ALL");
|
|
|
+ function.getImportParameterList().setValue("CODE", "LFA1");
|
|
|
// 执行 RFC 调用
|
|
|
function.execute(destination);
|
|
|
|
|
@@ -245,20 +258,24 @@ public class SapController {
|
|
|
} */
|
|
|
List<SapMaterial> materialList = new ArrayList<>();
|
|
|
// 处理返回的物料列表
|
|
|
- JCoTable materialTable = function.getTableParameterList().getTable("RETURN");
|
|
|
- for (int i = 0; i < materialTable.getNumRows(); i++) {
|
|
|
- materialTable.setRow(i);
|
|
|
+ JCoTable timportTable = function.getTableParameterList().getTable("TIMPORT");
|
|
|
+ JCoTable texportTable = function.getTableParameterList().getTable("TEXPORT");
|
|
|
+ for (int i = 0; i < texportTable.getNumRows(); i++) {
|
|
|
+ texportTable.setRow(i);
|
|
|
|
|
|
- SapMaterial material = new SapMaterial();
|
|
|
- material.setMaterialNumber(materialTable.getString("MATERIAL"));
|
|
|
+ // SapMaterial material = new SapMaterial();
|
|
|
+ /* material.setMaterialNumber(materialTable.getString("MATERIAL"));
|
|
|
material.setMaterialDescription(materialTable.getString("MATL_DESC"));
|
|
|
material.setMaterialType(materialTable.getString("MATL_TYPE"));
|
|
|
material.setPlant(materialTable.getString("PLANT"));
|
|
|
material.setBaseUnit(materialTable.getString("BASE_UOM"));
|
|
|
material.setIndustrySector(materialTable.getString("INDUSTRY"));
|
|
|
|
|
|
- materialList.add(material);
|
|
|
- System.out.println("物料编码:" + material.getMaterialNumber());
|
|
|
+ materialList.add(material); */
|
|
|
+ System.out.println("当前供应商KV_CODE:" + texportTable.getString("KV_CODE"));
|
|
|
+ System.out.println("当前供应商KV_NAME:" + texportTable.getString("KV_NAME"));
|
|
|
+ System.out.println("当前供应商KV_KEY:" + texportTable.getString("KV_KEY"));
|
|
|
+ System.out.println("当前供应商KV_VALUE:" + texportTable.getString("KV_VALUE"));
|
|
|
}
|
|
|
|
|
|
// 释放资源
|
|
@@ -277,7 +294,8 @@ public class SapController {
|
|
|
* 查询所有 SAP 工厂
|
|
|
*/
|
|
|
private List<String> factoryCodes(){
|
|
|
- List<SapOrgRespDTO> sapOrgs = sapOrgApi.getSapOrgByType(1);
|
|
|
+ List<SapOrgRespDTO> sapOrgs = TenantUtils.execute(1L, () -> sapOrgApi.getSapOrgByType(1));
|
|
|
+
|
|
|
if (CollUtil.isEmpty(sapOrgs)) {
|
|
|
return CollUtil.empty(String.class);
|
|
|
}
|