|
@@ -6,17 +6,14 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.ruoyi.common.exception.ServiceException;
|
|
|
import com.sd.business.entity.bom.po.Bom;
|
|
|
import com.sd.business.entity.bom.po.BomSpec;
|
|
|
-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.inventory.bo.InOutFun;
|
|
|
import com.sd.business.entity.inventory.dto.InventorySelectDto;
|
|
|
-import com.sd.business.entity.inventory.dto.QuantityByDepartmentDto;
|
|
|
import com.sd.business.entity.inventory.dto.QuantityByWarehouseDto;
|
|
|
import com.sd.business.entity.inventory.dto.QuantityDto;
|
|
|
import com.sd.business.entity.inventory.po.Inventory;
|
|
|
import com.sd.business.entity.inventory.vo.InventoryVo;
|
|
|
-import com.sd.business.entity.inventory.vo.QuantityByDepartmentVo;
|
|
|
import com.sd.business.entity.inventory.vo.QuantityByWarehouseVo;
|
|
|
import com.sd.business.entity.warehouse.po.Warehouse;
|
|
|
import com.sd.business.mapper.inventory.InventoryMapper;
|
|
@@ -61,15 +58,12 @@ public class InventoryServiceImpl extends ServiceImpl<InventoryMapper, Inventory
|
|
|
.selectAs(Warehouse::getName, InventoryVo::getWarehouseName)
|
|
|
.selectAs(BomSpec::getCode, InventoryVo::getBomSpecCode)
|
|
|
.selectAs(BomSpec::getName, InventoryVo::getBomSpecName)
|
|
|
- .selectAs(Department::getName, InventoryVo::getDepartmentName)
|
|
|
|
|
|
.from(Inventory.class)
|
|
|
.leftJoin(BomSpec.class, Inventory::getBomSpecId)
|
|
|
.leftJoin(Bom.class, BomSpec::getBomId)
|
|
|
.leftJoin(Warehouse.class, Inventory::getWarehouseId)
|
|
|
- .leftJoin(Department.class, Inventory::getDepartmentId)
|
|
|
|
|
|
- .eq(Inventory::getDepartmentId, dto.getDepartmentId())
|
|
|
.eq(Inventory::getWarehouseId, dto.getWarehouseId())
|
|
|
.in(Inventory::getWarehouseId, dto.getWarehouseIdList())
|
|
|
.like(BomSpec::getName, dto.getBomSpecName())
|
|
@@ -95,7 +89,6 @@ public class InventoryServiceImpl extends ServiceImpl<InventoryMapper, Inventory
|
|
|
public Map<Long, BigDecimal> getQuantity(QuantityDto dto) {
|
|
|
return mapKV(Inventory::getBomSpecId, Inventory::getQuantity, q -> q
|
|
|
.eq(Inventory::getWarehouseId, dto.getWarehouseId())
|
|
|
- .eq(Inventory::getDepartmentId, dto.getDepartmentId())
|
|
|
.in(Inventory::getBomSpecId, dto.getBomSpecIdList()));
|
|
|
}
|
|
|
|
|
@@ -110,40 +103,21 @@ public class InventoryServiceImpl extends ServiceImpl<InventoryMapper, Inventory
|
|
|
.from(Inventory.class)
|
|
|
.innerJoin(Warehouse.class, Warehouse::getId, Inventory::getId)
|
|
|
|
|
|
- .eq(Inventory::getDepartmentId, dto.getDepartmentId())
|
|
|
.groupBy(Warehouse::getId)
|
|
|
.orderByAsc(Warehouse::getId)
|
|
|
.list();
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<QuantityByDepartmentVo> getQuantityByDepartment(QuantityByDepartmentDto dto) {
|
|
|
-
|
|
|
- return Sql.create(QuantityByDepartmentVo.class)
|
|
|
- .sum(Inventory::getQuantity, QuantityByDepartmentVo::getInventoryQuantity)
|
|
|
- .selectAs(Department::getId, QuantityByDepartmentVo::getDepartmentId)
|
|
|
- .selectAs(Department::getName, QuantityByDepartmentVo::getDepartmentName)
|
|
|
-
|
|
|
- .from(Inventory.class)
|
|
|
- .innerJoin(Department.class, Department::getId, Inventory::getDepartmentId)
|
|
|
-
|
|
|
- .eq(Inventory::getWarehouseId, dto.getWarehouseId())
|
|
|
- .groupBy(Department::getId)
|
|
|
- .orderByAsc(Department::getId)
|
|
|
- .list();
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
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());
|
|
|
|
|
|
synchronized (this) {
|
|
|
// 通过事业部id和出库id获取bom规格库存
|
|
|
- List<Inventory> inventoryList = getInventoryList(departmentId, warehouseId, bomSpecIdList);
|
|
|
+ List<Inventory> inventoryList = getInventoryList(warehouseId, bomSpecIdList);
|
|
|
|
|
|
// 通过bom规格分组
|
|
|
Map<Long, Inventory> map = inventoryList.stream().collect(Collectors.toMap(Inventory::getBomSpecId, Function.identity()));
|
|
@@ -153,7 +127,6 @@ public class InventoryServiceImpl extends ServiceImpl<InventoryMapper, Inventory
|
|
|
Inventory inventory = map.computeIfAbsent(inOutFun.getBomSpecId(), item -> {
|
|
|
Inventory tempInventory = new Inventory();
|
|
|
tempInventory.setWarehouseId(warehouseId);
|
|
|
- tempInventory.setDepartmentId(departmentId);
|
|
|
tempInventory.setBomSpecId(item);
|
|
|
tempInventory.setQuantity(BigDecimal.ZERO);
|
|
|
return tempInventory;
|
|
@@ -168,7 +141,6 @@ public class InventoryServiceImpl extends ServiceImpl<InventoryMapper, Inventory
|
|
|
@Override
|
|
|
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());
|
|
@@ -176,7 +148,7 @@ public class InventoryServiceImpl extends ServiceImpl<InventoryMapper, Inventory
|
|
|
synchronized (this) {
|
|
|
|
|
|
// 通过事业部id和出库id获取bom规格库存
|
|
|
- List<Inventory> inventoryList = getInventoryList(departmentId, warehouseId, bomSpecIdList);
|
|
|
+ List<Inventory> inventoryList = getInventoryList(warehouseId, bomSpecIdList);
|
|
|
Map<Long, Inventory> map = inventoryList.stream().collect(Collectors.toMap(Inventory::getBomSpecId, Function.identity()));
|
|
|
|
|
|
for (InOutFun inOutFun : list) {
|
|
@@ -202,11 +174,10 @@ public class InventoryServiceImpl extends ServiceImpl<InventoryMapper, Inventory
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 通过事业部id和出库id获取bom规格库存
|
|
|
+ * 通过仓库id获取bom规格库存
|
|
|
*/
|
|
|
- private List<Inventory> getInventoryList(Long departmentId, Long warehouseId, List<Long> bomSpecIdList) {
|
|
|
+ private List<Inventory> getInventoryList(Long warehouseId, List<Long> bomSpecIdList) {
|
|
|
return list(q -> q
|
|
|
- .eq(Inventory::getDepartmentId, departmentId)
|
|
|
.eq(Inventory::getWarehouseId, warehouseId)
|
|
|
.in(Inventory::getBomSpecId, bomSpecIdList)
|
|
|
);
|