From a56e727cd6c0c70de8e539cd55dab6ce06b116a8 Mon Sep 17 00:00:00 2001
From: yiwenpeng <ywp303@163.com>
Date: Mon, 11 Sep 2023 17:05:17 +0800
Subject: [PATCH] fix:修复库存物料汇总页面,库存总数计算错误问题,计算时没加库区条件

---
 src/main/java/com/huaheng/mobile/invenory/MobileInventoryController.java                                         |  1 -
 src/main/java/com/huaheng/pc/inventory/InventoryMaterialSummary/service/InventoryMaterialSummaryServiceImpl.java | 31 ++++++++++++++-----------------
 2 files changed, 14 insertions(+), 18 deletions(-)

diff --git a/src/main/java/com/huaheng/mobile/invenory/MobileInventoryController.java b/src/main/java/com/huaheng/mobile/invenory/MobileInventoryController.java
index 7ff6678..0c9f22c 100644
--- a/src/main/java/com/huaheng/mobile/invenory/MobileInventoryController.java
+++ b/src/main/java/com/huaheng/mobile/invenory/MobileInventoryController.java
@@ -66,7 +66,6 @@ public class MobileInventoryController {
     private TransferTaskService transferTaskService;
     @Resource
     private WorkTaskService workTaskService;
-
     @Resource
     private LocationService locationService;
     @Resource
diff --git a/src/main/java/com/huaheng/pc/inventory/InventoryMaterialSummary/service/InventoryMaterialSummaryServiceImpl.java b/src/main/java/com/huaheng/pc/inventory/InventoryMaterialSummary/service/InventoryMaterialSummaryServiceImpl.java
index c46394c..49698f8 100644
--- a/src/main/java/com/huaheng/pc/inventory/InventoryMaterialSummary/service/InventoryMaterialSummaryServiceImpl.java
+++ b/src/main/java/com/huaheng/pc/inventory/InventoryMaterialSummary/service/InventoryMaterialSummaryServiceImpl.java
@@ -11,15 +11,15 @@ import java.util.stream.Collectors;
 
 
 @Service
-public class InventoryMaterialSummaryServiceImpl extends ServiceImpl<InventoryMaterialSummaryMapper, InventoryMaterialSummary>  implements InventoryMaterialSummaryService{
+public class InventoryMaterialSummaryServiceImpl extends ServiceImpl<InventoryMaterialSummaryMapper, InventoryMaterialSummary> implements InventoryMaterialSummaryService {
 
 
     /**
      * 根据物料码去重及累加数量
-     * */
+     */
     @Override
     public List<InventoryMaterialSummary> inventoryMaterialSummarySelect(List<InventoryMaterialSummary> inventoryMaterialSummaryList) {
-        if(inventoryMaterialSummaryList.size() < 1){
+        if (inventoryMaterialSummaryList.size() < 1) {
             return inventoryMaterialSummaryList;
         }
         /*以物料为条件把同物料数量全部相加,去重再展示*/
@@ -43,19 +43,17 @@ public class InventoryMaterialSummaryServiceImpl extends ServiceImpl<InventoryMa
      * 多条件去重
      * 合并数量
      * 多条件去重及累加数量,货主,物料码
-     * */
+     */
     @Override
-    public List<InventoryMaterialSummary> duplicateRemoval(List<InventoryMaterialSummary> inventoryMaterialSummaryList){
-        if(inventoryMaterialSummaryList.size() < 1){
+    public List<InventoryMaterialSummary> duplicateRemoval(List<InventoryMaterialSummary> inventoryMaterialSummaryList) {
+        if (inventoryMaterialSummaryList.size() < 1) {
             return inventoryMaterialSummaryList;
         }
         //先找货主和物料码相同的物料SKU相加得总数
-        for(InventoryMaterialSummary o:inventoryMaterialSummaryList){
+        for (InventoryMaterialSummary o : inventoryMaterialSummaryList) {
             BigDecimal numQty = BigDecimal.ZERO;
-            for (InventoryMaterialSummary t:inventoryMaterialSummaryList){
-                if(o.getCompanyCode().equals(t.getCompanyCode()) &&
-                        o.getMaterialCode().equals(t.getMaterialCode())){
-
+            for (InventoryMaterialSummary t : inventoryMaterialSummaryList) {
+                if (o.getCompanyCode().equals(t.getCompanyCode()) && o.getMaterialCode().equals(t.getMaterialCode()) && o.getZoneCode().equals(t.getZoneCode())) {
                     numQty = numQty.add(t.getQty());
                     o.setQty(numQty);
                 }
@@ -65,16 +63,15 @@ public class InventoryMaterialSummaryServiceImpl extends ServiceImpl<InventoryMa
         //多条件去重
         List<InventoryMaterialSummary> materialSummaryList = new ArrayList<>();
         inventoryMaterialSummaryList.stream().collect(Collectors.collectingAndThen(
-                Collectors.toCollection(() -> new TreeSet<>(
-                        Comparator.comparing(
-                                inventoryMaterialSummary ->
-                                        inventoryMaterialSummary.getCompanyCode() + ";" + inventoryMaterialSummary.getMaterialCode() + ";"  + inventoryMaterialSummary.getZoneCode()))),
-                ArrayList::new))
+                        Collectors.toCollection(() -> new TreeSet<>(
+                                Comparator.comparing(
+                                        inventoryMaterialSummary ->
+                                                inventoryMaterialSummary.getCompanyCode() + ";" + inventoryMaterialSummary.getMaterialCode() + ";" + inventoryMaterialSummary.getZoneCode()))),
+                        ArrayList::new))
                 .forEach(list -> materialSummaryList.add(list));
 
         return materialSummaryList;
     }
 
 
-
 }
--
libgit2 0.22.2