|
|
@@ -18,7 +18,9 @@ import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.HashSet;
|
|
|
import java.util.List;
|
|
|
+import java.util.Set;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@Tag(name = "管理后台 - SAP同步接口 物料主数据 领料单 SAP库存")
|
|
|
@@ -42,7 +44,7 @@ public class SapController {
|
|
|
|
|
|
// 设置输入参数
|
|
|
JCoParameterList input = function.getImportParameterList();
|
|
|
- input.setValue("IV_WERKS", "6000");
|
|
|
+ input.setValue("IV_WERKS", "5022");
|
|
|
|
|
|
// 执行 RFC 调用
|
|
|
function.execute(destination);
|
|
|
@@ -59,10 +61,12 @@ public class SapController {
|
|
|
|
|
|
if (etStockTable != null && etStockTable.getNumRows() > 0) {
|
|
|
BigDecimal jiage = BigDecimal.ZERO;
|
|
|
+ // 库存地点集合
|
|
|
+ Set<String> storageLocations = new HashSet<>();
|
|
|
for (int i = 0; i < etStockTable.getNumRows(); i++) {
|
|
|
etStockTable.setRow(i);
|
|
|
System.out.println(String.format("行号 %d: 工厂=%s, 物料编码=%s, 物料描述=%s, 库存数量 非限制=%s, 库存地点编码=%s, 批次=%s \n" +
|
|
|
- "特殊库存=%s, WBS 要素=%s, WBS 元素=%s, 基本单位=%s, 质量检验=%s, 已冻结=%s, 库存价格=%s",
|
|
|
+ "特殊库存=%s, 基本单位=%s, 质量检验=%s, 已冻结=%s, 库存价格=%s",
|
|
|
i,
|
|
|
etStockTable.getString("WERKS"), // 工厂
|
|
|
etStockTable.getString("MATNR"), // 物料编码
|
|
|
@@ -71,17 +75,23 @@ public class SapController {
|
|
|
etStockTable.getString("LGORT"), // 库存地点编码
|
|
|
etStockTable.getString("CHARG"), // 批次
|
|
|
etStockTable.getString("SOBKZ"), // 特殊库存
|
|
|
- etStockTable.getString("PSPNR"), // WBS 要素
|
|
|
- etStockTable.getString("POSID"), // WBS 元素
|
|
|
+ // etStockTable.getString("PSPNR"), // WBS 要素
|
|
|
+ // etStockTable.getString("POSID"), // WBS 元素
|
|
|
etStockTable.getString("MEINS"), // 基本单位
|
|
|
etStockTable.getString("INSME"), // 质量检验
|
|
|
etStockTable.getString("SPEME"), // 已冻结
|
|
|
etStockTable.getBigDecimal("JIAGE") // 库存价格
|
|
|
));
|
|
|
BigDecimal tempJiage = etStockTable.getBigDecimal("JIAGE");
|
|
|
+ String location = etStockTable.getString("LGORT");
|
|
|
+ storageLocations.add(location);
|
|
|
jiage = jiage.add(tempJiage);
|
|
|
}
|
|
|
System.out.println("总价格:" + jiage.toString());
|
|
|
+ // 1. 逗号拼接所有库存地点输出一行
|
|
|
+ String locationAll = storageLocations.stream()
|
|
|
+ .collect(Collectors.joining("、"));
|
|
|
+ System.out.println("【所有库存地点汇总】:" + locationAll);
|
|
|
}
|
|
|
return "Material Info: " + output.getString("ET_STOCK");
|
|
|
} catch (JCoException e) {
|