|
@@ -7,6 +7,7 @@ import com.ruoyi.common.exception.ServiceException;
|
|
import com.sd.business.entity.bom.po.Bom;
|
|
import com.sd.business.entity.bom.po.Bom;
|
|
import com.sd.business.entity.bom.po.BomSpec;
|
|
import com.sd.business.entity.bom.po.BomSpec;
|
|
import com.sd.business.entity.department.po.Department;
|
|
import com.sd.business.entity.department.po.Department;
|
|
|
|
+import com.sd.business.entity.in.dto.InOutStorageDto;
|
|
import com.sd.business.entity.in.po.InOutStorageBom;
|
|
import com.sd.business.entity.in.po.InOutStorageBom;
|
|
import com.sd.business.entity.inventory.bo.InOutFun;
|
|
import com.sd.business.entity.inventory.bo.InOutFun;
|
|
import com.sd.business.entity.inventory.dto.InventorySelectDto;
|
|
import com.sd.business.entity.inventory.dto.InventorySelectDto;
|
|
@@ -133,55 +134,21 @@ public class InventoryServiceImpl extends ServiceImpl<InventoryMapper, Inventory
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public void purchaseInStorage(Long purchaseId, Long departmentId, Long warehouseId, List<InOutStorageBom> inOutStorageBomList) {
|
|
|
|
- List<Long> bomSpecIdList = inOutStorageBomList.stream().map(InOutStorageBom::getBomSpecId).collect(Collectors.toList());
|
|
|
|
- synchronized (this) {
|
|
|
|
-
|
|
|
|
- // 通过事业部id和出库id获取bom规格库存
|
|
|
|
- List<Inventory> inventoryList = getInventoryList(departmentId, warehouseId, bomSpecIdList);
|
|
|
|
-
|
|
|
|
- // 通过bom规格分组
|
|
|
|
- Map<Long, Inventory> map = inventoryList.stream().collect(Collectors.toMap(Inventory::getBomSpecId, Function.identity()));
|
|
|
|
-
|
|
|
|
- for (InOutStorageBom inOutStorageBom : inOutStorageBomList) {
|
|
|
|
-
|
|
|
|
- // 库存
|
|
|
|
- Inventory inventory = map.computeIfAbsent(inOutStorageBom.getBomSpecId(), item -> {
|
|
|
|
- Inventory tempInventory = new Inventory();
|
|
|
|
- tempInventory.setWarehouseId(warehouseId);
|
|
|
|
- tempInventory.setDepartmentId(departmentId);
|
|
|
|
- tempInventory.setBomSpecId(item);
|
|
|
|
- tempInventory.setQuantity(BigDecimal.ZERO);
|
|
|
|
- inventoryList.add(tempInventory);
|
|
|
|
- return tempInventory;
|
|
|
|
- });
|
|
|
|
-
|
|
|
|
- // 数量
|
|
|
|
- BigDecimal sumQuantity = inventory.getQuantity().add(inOutStorageBom.getQuantity());
|
|
|
|
- inventory.setQuantity(sumQuantity);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- saveOrUpdateBatch(inventoryList);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public void in(Long departmentId, Long warehouseId, List<? extends InOutFun> list) {
|
|
|
|
- if (list.isEmpty()) {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
|
|
+ public void in(InOutStorageDto dto) {
|
|
|
|
+ List<InOutStorageBom> list = dto.getInOutStorageBomList();
|
|
|
|
+ Long departmentId = dto.getDepartmentId();
|
|
|
|
+ Long warehouseId = dto.getWarehouseId();
|
|
|
|
|
|
List<Long> bomSpecIdList = list.stream().map(InOutFun::getBomSpecId).collect(Collectors.toList());
|
|
List<Long> bomSpecIdList = list.stream().map(InOutFun::getBomSpecId).collect(Collectors.toList());
|
|
|
|
|
|
synchronized (this) {
|
|
synchronized (this) {
|
|
-
|
|
|
|
// 通过事业部id和出库id获取bom规格库存
|
|
// 通过事业部id和出库id获取bom规格库存
|
|
List<Inventory> inventoryList = getInventoryList(departmentId, warehouseId, bomSpecIdList);
|
|
List<Inventory> inventoryList = getInventoryList(departmentId, warehouseId, bomSpecIdList);
|
|
|
|
|
|
// 通过bom规格分组
|
|
// 通过bom规格分组
|
|
Map<Long, Inventory> map = inventoryList.stream().collect(Collectors.toMap(Inventory::getBomSpecId, Function.identity()));
|
|
Map<Long, Inventory> map = inventoryList.stream().collect(Collectors.toMap(Inventory::getBomSpecId, Function.identity()));
|
|
- for (InOutFun inOutFun : list) {
|
|
|
|
|
|
|
|
|
|
+ for (InOutFun inOutFun : list) {
|
|
// 库存
|
|
// 库存
|
|
Inventory inventory = map.computeIfAbsent(inOutFun.getBomSpecId(), item -> {
|
|
Inventory inventory = map.computeIfAbsent(inOutFun.getBomSpecId(), item -> {
|
|
Inventory tempInventory = new Inventory();
|
|
Inventory tempInventory = new Inventory();
|
|
@@ -189,32 +156,34 @@ public class InventoryServiceImpl extends ServiceImpl<InventoryMapper, Inventory
|
|
tempInventory.setDepartmentId(departmentId);
|
|
tempInventory.setDepartmentId(departmentId);
|
|
tempInventory.setBomSpecId(item);
|
|
tempInventory.setBomSpecId(item);
|
|
tempInventory.setQuantity(BigDecimal.ZERO);
|
|
tempInventory.setQuantity(BigDecimal.ZERO);
|
|
- inventoryList.add(tempInventory);
|
|
|
|
return tempInventory;
|
|
return tempInventory;
|
|
});
|
|
});
|
|
inventory.setQuantity(inventory.getQuantity().add(inOutFun.getQuantity()));
|
|
inventory.setQuantity(inventory.getQuantity().add(inOutFun.getQuantity()));
|
|
}
|
|
}
|
|
|
|
|
|
- saveOrUpdateBatch(inventoryList);
|
|
|
|
|
|
+ saveOrUpdateBatch(map.values());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public void out(Long departmentId, Long warehouseId, List<? extends InOutFun> list, Integer lockStorage) {
|
|
|
|
|
|
+ public void out(InOutStorageDto dto) {
|
|
|
|
+ List<InOutStorageBom> list = dto.getInOutStorageBomList();
|
|
|
|
+ Long departmentId = dto.getDepartmentId();
|
|
|
|
+ Long warehouseId = dto.getWarehouseId();
|
|
|
|
+
|
|
List<Long> bomSpecIdList = list.stream().map(InOutFun::getBomSpecId).collect(Collectors.toList());
|
|
List<Long> bomSpecIdList = list.stream().map(InOutFun::getBomSpecId).collect(Collectors.toList());
|
|
|
|
|
|
synchronized (this) {
|
|
synchronized (this) {
|
|
|
|
|
|
// 通过事业部id和出库id获取bom规格库存
|
|
// 通过事业部id和出库id获取bom规格库存
|
|
List<Inventory> inventoryList = getInventoryList(departmentId, warehouseId, bomSpecIdList);
|
|
List<Inventory> inventoryList = getInventoryList(departmentId, warehouseId, bomSpecIdList);
|
|
- Map<Long, Inventory> inventoryMap = inventoryList.stream().collect(Collectors.toMap(Inventory::getBomSpecId, Function.identity()));
|
|
|
|
|
|
+ Map<Long, Inventory> map = inventoryList.stream().collect(Collectors.toMap(Inventory::getBomSpecId, Function.identity()));
|
|
|
|
|
|
for (InOutFun inOutFun : list) {
|
|
for (InOutFun inOutFun : list) {
|
|
|
|
|
|
BigDecimal quantity = inOutFun.getQuantity();
|
|
BigDecimal quantity = inOutFun.getQuantity();
|
|
Long bomSpecId = inOutFun.getBomSpecId();
|
|
Long bomSpecId = inOutFun.getBomSpecId();
|
|
- Inventory inventory = inventoryMap.get(bomSpecId);
|
|
|
|
-
|
|
|
|
|
|
+ Inventory inventory = map.get(bomSpecId);
|
|
|
|
|
|
if (inventory == null || inventory.getQuantity().compareTo(quantity) < 0) {
|
|
if (inventory == null || inventory.getQuantity().compareTo(quantity) < 0) {
|
|
BomSpec bomSpec = bomSpecService.getById(bomSpecId);
|
|
BomSpec bomSpec = bomSpecService.getById(bomSpecId);
|
|
@@ -225,7 +194,6 @@ public class InventoryServiceImpl extends ServiceImpl<InventoryMapper, Inventory
|
|
(inventory == null ? BigDecimal.ZERO : inventory.getQuantity()) + ",需要出库:" + quantity);
|
|
(inventory == null ? BigDecimal.ZERO : inventory.getQuantity()) + ",需要出库:" + quantity);
|
|
}
|
|
}
|
|
inventory.setQuantity(inventory.getQuantity().subtract(quantity));
|
|
inventory.setQuantity(inventory.getQuantity().subtract(quantity));
|
|
-
|
|
|
|
}
|
|
}
|
|
|
|
|
|
// 修改库存数量
|
|
// 修改库存数量
|