|
@@ -10,6 +10,7 @@ import com.ruoyi.common.utils.wrapper.IWrapper;
|
|
|
import com.sd.business.entity.bom.bo.BomSpecBo;
|
|
|
import com.sd.business.entity.bom.po.BomSpec;
|
|
|
import com.sd.business.entity.department.po.Department;
|
|
|
+import com.sd.business.entity.in.bo.InOutStorageBomBo;
|
|
|
import com.sd.business.entity.in.dto.InOutStorageDto;
|
|
|
import com.sd.business.entity.in.emums.InOutTypeEnum;
|
|
|
import com.sd.business.entity.in.emums.OutDetailTypeEnum;
|
|
@@ -197,7 +198,7 @@ public class StockPreparationServiceImpl implements StockPreparationService {
|
|
|
.set(OrderSku::getStockPreparationStatus, StatusConstant.YES));
|
|
|
|
|
|
// 订单出库
|
|
|
- orderDelivery(orderIdList, dto);
|
|
|
+ orderDelivery(list, dto);
|
|
|
|
|
|
List<ProductionTask> productionTaskList = new ArrayList<>();
|
|
|
List<ProductionWorkOrder> productionWorkOrderList = new ArrayList<>();
|
|
@@ -333,7 +334,7 @@ public class StockPreparationServiceImpl implements StockPreparationService {
|
|
|
if (semiFinishedProductBomSpecIdList.size() > 0) {
|
|
|
semiFinishedProductInventoryMap = inventoryService.mapKV(
|
|
|
Inventory::getBomSpecId,
|
|
|
- Inventory::getQuantity,
|
|
|
+ item -> item.getQuantity().add(item.getLockQuantity()),
|
|
|
q -> q.eq(Inventory::getWarehouseId, WarehouseConstant.SEMI_FINISHED_PRODUCT)
|
|
|
.eq(Inventory::getDepartmentId, outDepartmentId)
|
|
|
.in(Inventory::getBomSpecId, semiFinishedProductBomSpecIdList)
|
|
@@ -349,7 +350,7 @@ public class StockPreparationServiceImpl implements StockPreparationService {
|
|
|
if (packagingMaterialBomSpecIdList.size() > 0) {
|
|
|
packagingMaterialInventoryMap = inventoryService.mapKV(
|
|
|
Inventory::getBomSpecId,
|
|
|
- Inventory::getQuantity,
|
|
|
+ item -> item.getQuantity().add(item.getLockQuantity()),
|
|
|
q -> q.eq(Inventory::getWarehouseId, WarehouseConstant.PACKAGING_MATERIAL)
|
|
|
.eq(Inventory::getDepartmentId, outDepartmentId)
|
|
|
.in(Inventory::getBomSpecId, packagingMaterialBomSpecIdList)
|
|
@@ -459,25 +460,31 @@ public class StockPreparationServiceImpl implements StockPreparationService {
|
|
|
/**
|
|
|
* 订单出库
|
|
|
*/
|
|
|
- private void orderDelivery(List<Long> orderIdList, StockPreparationDto dto) {
|
|
|
+ private void orderDelivery(List<StockPreparationVo> stockPreparationVoList, StockPreparationDto dto) {
|
|
|
|
|
|
- List<OrderSku> orderSkuList = orderSkuService.list(q -> q.in(OrderSku::getOrderId, orderIdList));
|
|
|
- List<OrderSkuBom> orderSkuBomList = orderSkuBomService.list(q -> q.in(OrderSkuBom::getOrderId, orderIdList));
|
|
|
+ Map<Long, Integer> orderIdLockStorageMap = stockPreparationVoList.stream().collect(
|
|
|
+ Collectors.toMap(StockPreparationVo::getOrderId, StockPreparationVo::getLockStorage, (v1, v2) -> v1));
|
|
|
+
|
|
|
+ List<OrderSku> orderSkuList = orderSkuService.list(q -> q.in(OrderSku::getOrderId, orderIdLockStorageMap.keySet()));
|
|
|
+ List<OrderSkuBom> orderSkuBomList = orderSkuBomService.list(q -> q.in(OrderSkuBom::getOrderId, orderIdLockStorageMap.keySet()));
|
|
|
Map<Long, OrderSku> orderSkuMap = orderSkuList.stream().collect(Collectors.toMap(BaseIdPo::getId, Function.identity()));
|
|
|
|
|
|
- Map<Long, InOutStorageBom> map = Stream.concat(
|
|
|
+ Map<Long, InOutStorageBomBo> map = Stream.concat(
|
|
|
// 主材
|
|
|
orderSkuList.stream().map(item -> {
|
|
|
- InOutStorageBom inOutStorageBom = new InOutStorageBom();
|
|
|
+ Integer lockStorage = orderIdLockStorageMap.get(item.getOrderId());
|
|
|
+
|
|
|
+ InOutStorageBomBo inOutStorageBom = new InOutStorageBomBo();
|
|
|
inOutStorageBom.setBomSpecId(item.getBomSpecId());
|
|
|
inOutStorageBom.setQuantity(item.getQuantity());
|
|
|
+ inOutStorageBom.setLockStorage(lockStorage);
|
|
|
return inOutStorageBom;
|
|
|
}),
|
|
|
|
|
|
// 包材
|
|
|
orderSkuBomList.stream().map(item -> {
|
|
|
OrderSku orderSku = orderSkuMap.get(item.getOrderSkuId());
|
|
|
- InOutStorageBom inOutStorageBom = new InOutStorageBom();
|
|
|
+ InOutStorageBomBo inOutStorageBom = new InOutStorageBomBo();
|
|
|
inOutStorageBom.setBomSpecId(item.getBomSpecId());
|
|
|
inOutStorageBom.setQuantity(item.getQuantity().multiply(orderSku.getQuantity()));
|
|
|
return inOutStorageBom;
|
|
@@ -492,40 +499,61 @@ public class StockPreparationServiceImpl implements StockPreparationService {
|
|
|
})
|
|
|
);
|
|
|
|
|
|
+ Map<Long, BomSpecBo> bomSpecBo = skuSpecService.getBomSpecBoByIdList(map.keySet());
|
|
|
+
|
|
|
// 合并sku主材和包材
|
|
|
- List<InOutStorageBom> list = new ArrayList<>(map.values());
|
|
|
+ List<InOutStorageBomBo> list = new ArrayList<>(map.values());
|
|
|
|
|
|
- Map<Long, BomSpecBo> bomSpecBo = skuSpecService.getBomSpecBoByIdList(map.keySet());
|
|
|
+ // 主材从半成品仓出库(从冻结库存出库)
|
|
|
+ List<InOutStorageBom> lockSemiFinishedProductInOutStorageBomList = list.stream()
|
|
|
+ .filter(item -> ObjectUtil.equal(bomSpecBo.get(item.getBomSpecId()).getClassifyParentId(), 1L))
|
|
|
+ .filter(item -> ObjectUtil.equal(item.getLockStorage(), StatusConstant.YES))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ if (lockSemiFinishedProductInOutStorageBomList.size() > 0) {
|
|
|
+ InOutStorageDto lockSemiFinishedProduct = new InOutStorageDto();
|
|
|
+ lockSemiFinishedProduct.setType(InOutTypeEnum.OUT.getKey());
|
|
|
+ lockSemiFinishedProduct.setDetailType(OutDetailTypeEnum.PRODUCTION.getKey());
|
|
|
+ lockSemiFinishedProduct.setWarehouseId(WarehouseConstant.SEMI_FINISHED_PRODUCT);
|
|
|
+ lockSemiFinishedProduct.setDepartmentId(dto.getOutDepartmentId());
|
|
|
+ lockSemiFinishedProduct.setApplicant(dto.getApplicant());
|
|
|
+ lockSemiFinishedProduct.setRemark(dto.getRemark());
|
|
|
+ lockSemiFinishedProduct.setLockStorage(StatusConstant.YES);
|
|
|
+ lockSemiFinishedProduct.setInOutStorageBomList(lockSemiFinishedProductInOutStorageBomList);
|
|
|
+ inOutStorageService.add(lockSemiFinishedProduct);
|
|
|
+ }
|
|
|
|
|
|
- // 主材从半成品仓出库
|
|
|
+ // 主材从半成品仓出库(从非冻结库存出库)
|
|
|
List<InOutStorageBom> semiFinishedProductInOutStorageBomList = list.stream()
|
|
|
.filter(item -> ObjectUtil.equal(bomSpecBo.get(item.getBomSpecId()).getClassifyParentId(), 1L))
|
|
|
+ .filter(item -> ObjectUtil.notEqual(item.getLockStorage(), StatusConstant.YES))
|
|
|
.collect(Collectors.toList());
|
|
|
-
|
|
|
- InOutStorageDto semiFinishedProduct = new InOutStorageDto();
|
|
|
- semiFinishedProduct.setType(InOutTypeEnum.OUT.getKey());
|
|
|
- semiFinishedProduct.setDetailType(OutDetailTypeEnum.PRODUCTION.getKey());
|
|
|
- semiFinishedProduct.setWarehouseId(WarehouseConstant.SEMI_FINISHED_PRODUCT);
|
|
|
- semiFinishedProduct.setDepartmentId(dto.getOutDepartmentId());
|
|
|
- semiFinishedProduct.setApplicant(dto.getApplicant());
|
|
|
- semiFinishedProduct.setRemark(dto.getRemark());
|
|
|
- semiFinishedProduct.setInOutStorageBomList(semiFinishedProductInOutStorageBomList);
|
|
|
- inOutStorageService.add(semiFinishedProduct);
|
|
|
+ if (semiFinishedProductInOutStorageBomList.size() > 0) {
|
|
|
+ InOutStorageDto semiFinishedProduct = new InOutStorageDto();
|
|
|
+ semiFinishedProduct.setType(InOutTypeEnum.OUT.getKey());
|
|
|
+ semiFinishedProduct.setDetailType(OutDetailTypeEnum.PRODUCTION.getKey());
|
|
|
+ semiFinishedProduct.setWarehouseId(WarehouseConstant.SEMI_FINISHED_PRODUCT);
|
|
|
+ semiFinishedProduct.setDepartmentId(dto.getOutDepartmentId());
|
|
|
+ semiFinishedProduct.setApplicant(dto.getApplicant());
|
|
|
+ semiFinishedProduct.setRemark(dto.getRemark());
|
|
|
+ semiFinishedProduct.setInOutStorageBomList(semiFinishedProductInOutStorageBomList);
|
|
|
+ inOutStorageService.add(semiFinishedProduct);
|
|
|
+ }
|
|
|
|
|
|
// 包材从包材仓出库
|
|
|
List<InOutStorageBom> packagingMaterialInOutStorageBomList = list.stream()
|
|
|
.filter(item -> ObjectUtil.notEqual(bomSpecBo.get(item.getBomSpecId()).getClassifyParentId(), 1L))
|
|
|
.collect(Collectors.toList());
|
|
|
-
|
|
|
- InOutStorageDto packagingMaterial = new InOutStorageDto();
|
|
|
- packagingMaterial.setType(InOutTypeEnum.OUT.getKey());
|
|
|
- packagingMaterial.setDetailType(OutDetailTypeEnum.PRODUCTION.getKey());
|
|
|
- packagingMaterial.setWarehouseId(WarehouseConstant.PACKAGING_MATERIAL);
|
|
|
- packagingMaterial.setDepartmentId(dto.getOutDepartmentId());
|
|
|
- packagingMaterial.setApplicant(dto.getApplicant());
|
|
|
- packagingMaterial.setRemark(dto.getRemark());
|
|
|
- packagingMaterial.setInOutStorageBomList(packagingMaterialInOutStorageBomList);
|
|
|
- inOutStorageService.add(packagingMaterial);
|
|
|
+ if (packagingMaterialInOutStorageBomList.size() > 0) {
|
|
|
+ InOutStorageDto packagingMaterial = new InOutStorageDto();
|
|
|
+ packagingMaterial.setType(InOutTypeEnum.OUT.getKey());
|
|
|
+ packagingMaterial.setDetailType(OutDetailTypeEnum.PRODUCTION.getKey());
|
|
|
+ packagingMaterial.setWarehouseId(WarehouseConstant.PACKAGING_MATERIAL);
|
|
|
+ packagingMaterial.setDepartmentId(dto.getOutDepartmentId());
|
|
|
+ packagingMaterial.setApplicant(dto.getApplicant());
|
|
|
+ packagingMaterial.setRemark(dto.getRemark());
|
|
|
+ packagingMaterial.setInOutStorageBomList(packagingMaterialInOutStorageBomList);
|
|
|
+ inOutStorageService.add(packagingMaterial);
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|