Browse Source

完善代码

yuansh 3 tháng trước cách đây
mục cha
commit
ad59c20b6f

+ 43 - 38
srm-module-code/src/main/java/org/jeecg/modules/storeCode/service/impl/StoreSaleOutServiceImpl.java

@@ -63,32 +63,35 @@ public class StoreSaleOutServiceImpl extends ServiceImpl<StoreSaleOutMapper, Sto
         if (storeSaleOutDetailsList != null && storeSaleOutDetailsList.size() > 0) {
             for (StoreSaleOutDetails entity : storeSaleOutDetailsList) {
 
-                BigDecimal stockOutQuantity = entity.getStockOutQuantity();
+                BigDecimal stockOutQuantity = entity.getStockOutQuantity()==null?BigDecimal.ZERO:entity.getStockOutQuantity();
 
-                if (stockOutQuantity == null) {
-                    continue;
-                }
                 String productId = entity.getProductId();
+                String setBatchId = entity.getBatchId();
                 // 项目、仓库、货位、产品编码
-
-                QueryWrapper<StoreOnhand> queryWrapper = new QueryWrapper<>();
-                queryWrapper.eq("project", project);
-                queryWrapper.eq("warehouse", warehouse);
-                queryWrapper.eq("goods_allocation", goodsAllocation);
-                queryWrapper.eq("product_id", productId);
-                queryWrapper.eq("del_flag", 0);
-
-                List<StoreOnhand> list = storeOnhandService.list(queryWrapper);
-
-                if (list.size() > 0) {
-
-                    BigDecimal quantity = list.get(0).getQuantity();
-                    if (quantity.compareTo(stockOutQuantity) >= 0) {
-                        entity.setInventorySelection(list.get(0).getBatchCode());
-                        entity.setBatchId(list.get(0).getId());
+                if(StringUtils.isNotBlank(warehouse) && StringUtils.isNotBlank(goodsAllocation)
+                        && StringUtils.isNotBlank(project) && StringUtils.isNotBlank(productId)
+                        && StringUtils.isBlank(setBatchId)){
+
+                    QueryWrapper<StoreOnhand> queryWrapper = new QueryWrapper<>();
+                    queryWrapper.eq("project", project);
+                    queryWrapper.eq("warehouse", warehouse);
+                    queryWrapper.eq("goods_allocation", goodsAllocation);
+                    queryWrapper.eq("product_id", productId);
+                    queryWrapper.eq("del_flag", 0);
+
+                    List<StoreOnhand> list = storeOnhandService.list(queryWrapper);
+
+                    if (list.size() > 0) {
+
+                        BigDecimal quantity = list.get(0).getQuantity();
+                        if (quantity.compareTo(stockOutQuantity) >= 0) {
+                            entity.setInventorySelection(list.get(0).getBatchCode());
+                            entity.setBatchId(list.get(0).getId());
+                        }
                     }
                 }
 
+
                 //外键设置
                 entity.setId(null);
                 entity.setHeadId(storeSaleOut.getId());
@@ -122,33 +125,35 @@ public class StoreSaleOutServiceImpl extends ServiceImpl<StoreSaleOutMapper, Sto
         if (storeSaleOutDetailsList != null && storeSaleOutDetailsList.size() > 0) {
             for (StoreSaleOutDetails entity : storeSaleOutDetailsList) {
 
-                BigDecimal stockOutQuantity = entity.getStockOutQuantity();
+                BigDecimal stockOutQuantity = entity.getStockOutQuantity()==null?BigDecimal.ZERO:entity.getStockOutQuantity();
 
-                if (stockOutQuantity == null) {
-                    continue;
-                }
                 String productId = entity.getProductId();
+                String setBatchId = entity.getBatchId();
                 // 项目、仓库、货位、产品编码
 
-                QueryWrapper<StoreOnhand> queryWrapper = new QueryWrapper<>();
-                queryWrapper.eq("project", project);
-                queryWrapper.eq("warehouse", warehouse);
-                queryWrapper.eq("goods_allocation", goodsAllocation);
-                queryWrapper.eq("product_id", productId);
-                queryWrapper.eq("del_flag", 0);
+                if(StringUtils.isNotBlank(warehouse) && StringUtils.isNotBlank(goodsAllocation)
+                        && StringUtils.isNotBlank(project) && StringUtils.isNotBlank(productId)
+                        && StringUtils.isBlank(setBatchId)){
 
-                List<StoreOnhand> list = storeOnhandService.list(queryWrapper);
+                    QueryWrapper<StoreOnhand> queryWrapper = new QueryWrapper<>();
+                    queryWrapper.eq("project", project);
+                    queryWrapper.eq("warehouse", warehouse);
+                    queryWrapper.eq("goods_allocation", goodsAllocation);
+                    queryWrapper.eq("product_id", productId);
+                    queryWrapper.eq("del_flag", 0);
 
-                if (list.size() > 0) {
+                    List<StoreOnhand> list = storeOnhandService.list(queryWrapper);
 
-                    BigDecimal quantity = list.get(0).getQuantity();
-                    if (quantity.compareTo(stockOutQuantity) >= 0) {
-                        entity.setInventorySelection(list.get(0).getBatchCode());
-                        entity.setBatchId(list.get(0).getId());
-                    }
-                }
+                    if (list.size() > 0) {
 
+                        BigDecimal quantity = list.get(0).getQuantity();
+                        if (quantity.compareTo(stockOutQuantity) >= 0) {
+                            entity.setInventorySelection(list.get(0).getBatchCode());
+                            entity.setBatchId(list.get(0).getId());
+                        }
+                    }
 
+                }
 
                 //外键设置
                 entity.setId(null);