|  | @@ -26,7 +26,7 @@ import java.util.List;
 | 
	
		
			
				|  |  |  import java.util.Collection;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  /**
 | 
	
		
			
				|  |  | - * @Description: 销售出库(sale out)
 | 
	
		
			
				|  |  | + * @Description: 销售出库 (sale out)
 | 
	
		
			
				|  |  |   * @Author: jeecg-boot
 | 
	
		
			
				|  |  |   * @Date: 2024-12-11
 | 
	
		
			
				|  |  |   * @Version: V1.0
 | 
	
	
		
			
				|  | @@ -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);
 |