Browse Source

出入库

24282 1 year ago
parent
commit
3c19429d3b

+ 6 - 8
sd-business/src/main/java/com/sd/business/service/inventory/impl/InventoryServiceImpl.java

@@ -73,9 +73,9 @@ public class InventoryServiceImpl extends ServiceImpl<InventoryMapper, Inventory
         wrapper.eq("i", Inventory::getDepartmentId, dto.getDepartmentId());
         wrapper.eq("i", InventoryBackup::getBackupDate, dto.getBackupDate());
 
-        Page<InventoryVo> page = this.baseMapper.getPage(dto.getPage(), wrapper, tableName);
-        return page;
+        return this.baseMapper.getPage(dto.getPage(), wrapper, tableName);
     }
+
     @Override
     public List<QuantityByWarehouseVo> getQuantityByWarehouse(QuantityByWarehouseDto dto) {
         return baseMapper.getQuantityByWarehouse(dto);
@@ -246,8 +246,9 @@ public class InventoryServiceImpl extends ServiceImpl<InventoryMapper, Inventory
         int j = 0;
 
         do {
+
             if (outStorageDetails.size() == j) {
-                throw new ServiceException("数据异常,无法计算库存单价!!");
+                throw new ServiceException("数据异常,无法计算库存单价");
             }
 
             // 获取这条记录剩余的数量
@@ -256,15 +257,12 @@ public class InventoryServiceImpl extends ServiceImpl<InventoryMapper, Inventory
             // 单条可出库数量
             BigDecimal tempQuantity = inOutStorageDetails.getQuantity();
 
-            if (tempQuantity.compareTo(quantity) > 0) {
+            if (tempQuantity.compareTo(quantity) >= 0) {
                 inOutStorageDetails.setQuantity(tempQuantity.subtract(quantity));
                 quantity = BigDecimal.ZERO;
-            } else if (tempQuantity.compareTo(quantity) < 0) {
-                inOutStorageDetails.setQuantity(BigDecimal.ZERO);
-                quantity = quantity.subtract(tempQuantity);
             } else {
                 inOutStorageDetails.setQuantity(BigDecimal.ZERO);
-                quantity = BigDecimal.ZERO;
+                quantity = quantity.subtract(tempQuantity);
             }
 
             j++;