|
@@ -292,7 +292,7 @@ public class StockPreparationServiceImpl implements StockPreparationService {
|
|
|
IWrapper<StockPreparationVo> wrapper = getWrapper(dto);
|
|
|
List<StockPreparationVo> stockPreparationVoList = stockPreparationMapper.uncompletedList(wrapper);
|
|
|
|
|
|
- if (stockPreparationVoList.size() == 0) {
|
|
|
+ if (stockPreparationVoList.isEmpty()) {
|
|
|
return Collections.emptyList();
|
|
|
}
|
|
|
|
|
@@ -361,7 +361,7 @@ public class StockPreparationServiceImpl implements StockPreparationService {
|
|
|
.filter(item -> WarehouseConstant.SEMI_FINISHED_PRODUCT.equals(item.getWarehouseId()))
|
|
|
.map(OutBomVo::getBomSpecId)
|
|
|
.collect(Collectors.toList());
|
|
|
- if (semiFinishedProductBomSpecIdList.size() > 0) {
|
|
|
+ if (!semiFinishedProductBomSpecIdList.isEmpty()) {
|
|
|
List<Inventory> tempList = inventoryService.list(q -> q.eq(Inventory::getWarehouseId, WarehouseConstant.SEMI_FINISHED_PRODUCT)
|
|
|
.eq(Inventory::getDepartmentId, outDepartmentId)
|
|
|
.in(Inventory::getBomSpecId, semiFinishedProductBomSpecIdList));
|
|
@@ -376,7 +376,7 @@ public class StockPreparationServiceImpl implements StockPreparationService {
|
|
|
.filter(item -> WarehouseConstant.PACKAGING_MATERIAL.equals(item.getWarehouseId()))
|
|
|
.map(OutBomVo::getBomSpecId)
|
|
|
.collect(Collectors.toList());
|
|
|
- if (packagingMaterialBomSpecIdList.size() > 0) {
|
|
|
+ if (!packagingMaterialBomSpecIdList.isEmpty()) {
|
|
|
List<Inventory> tempList = inventoryService.list(q -> q
|
|
|
.eq(Inventory::getWarehouseId, WarehouseConstant.PACKAGING_MATERIAL)
|
|
|
.eq(Inventory::getDepartmentId, outDepartmentId)
|
|
@@ -497,92 +497,86 @@ public class StockPreparationServiceImpl implements StockPreparationService {
|
|
|
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, InOutStorageBomBo> map = Stream.concat(
|
|
|
- // 主材
|
|
|
- orderSkuList.stream().map(item -> {
|
|
|
- Integer lockStorage = orderIdLockStorageMap.get(item.getOrderId());
|
|
|
+ List<InOutStorageBomBo> inOutStorageBomBoList = Stream.concat(
|
|
|
|
|
|
- InOutStorageBomBo inOutStorageBom = new InOutStorageBomBo();
|
|
|
- inOutStorageBom.setBomSpecId(item.getBomSpecId());
|
|
|
- inOutStorageBom.setQuantity(item.getQuantity());
|
|
|
- inOutStorageBom.setLockStorage(lockStorage);
|
|
|
- return inOutStorageBom;
|
|
|
- }),
|
|
|
+ // 主材
|
|
|
+ orderSkuList.stream().map(item -> {
|
|
|
+ InOutStorageBomBo inOutStorageBom = new InOutStorageBomBo();
|
|
|
+ inOutStorageBom.setBomSpecId(item.getBomSpecId());
|
|
|
+ inOutStorageBom.setQuantity(item.getQuantity());
|
|
|
+ inOutStorageBom.setLockStorage(orderIdLockStorageMap.get(item.getOrderId()));
|
|
|
+ return inOutStorageBom;
|
|
|
+ }),
|
|
|
|
|
|
- // 包材
|
|
|
- orderSkuBomList.stream().map(item -> {
|
|
|
- OrderSku orderSku = orderSkuMap.get(item.getOrderSkuId());
|
|
|
- InOutStorageBomBo inOutStorageBom = new InOutStorageBomBo();
|
|
|
- inOutStorageBom.setBomSpecId(item.getBomSpecId());
|
|
|
- inOutStorageBom.setQuantity(item.getQuantity().multiply(orderSku.getQuantity()));
|
|
|
- return inOutStorageBom;
|
|
|
- })
|
|
|
- )
|
|
|
- .collect(Collectors.toMap(
|
|
|
- InOutStorageBom::getBomSpecId,
|
|
|
- Function.identity(),
|
|
|
- (v1, v2) -> {
|
|
|
- v1.setQuantity(v1.getQuantity().add(v2.getQuantity()));
|
|
|
- return v1;
|
|
|
- })
|
|
|
- );
|
|
|
+ // 包材
|
|
|
+ orderSkuBomList.stream().map(item -> {
|
|
|
+ InOutStorageBomBo inOutStorageBom = new InOutStorageBomBo();
|
|
|
+ inOutStorageBom.setBomSpecId(item.getBomSpecId());
|
|
|
+ inOutStorageBom.setQuantity(item.getQuantity().multiply(orderSkuMap.get(item.getOrderSkuId()).getQuantity()));
|
|
|
+ return inOutStorageBom;
|
|
|
+ })
|
|
|
|
|
|
- Map<Long, BomSpecBo> bomSpecBo = skuSpecService.getBomSpecBoByIdList(map.keySet());
|
|
|
+ ).collect(Collectors.toList());
|
|
|
|
|
|
- // 合并sku主材和包材
|
|
|
- List<InOutStorageBomBo> list = new ArrayList<>(map.values());
|
|
|
+ List<Long> bomSpecIdList = inOutStorageBomBoList.stream().map(InOutStorageBom::getBomSpecId).collect(Collectors.toList());
|
|
|
+ Map<Long, BomSpecBo> bomSpecBo = skuSpecService.getBomSpecBoByIdList(bomSpecIdList);
|
|
|
|
|
|
// 主材从半成品仓出库(从冻结库存出库)
|
|
|
- List<InOutStorageBom> lockSemiFinishedProductInOutStorageBomList = list.stream()
|
|
|
+ List<InOutStorageBom> lockSemiFinishedProductInOutStorageBomList = inOutStorageBomBoList.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);
|
|
|
+ if (!lockSemiFinishedProductInOutStorageBomList.isEmpty()) {
|
|
|
+ productionOut(WarehouseConstant.SEMI_FINISHED_PRODUCT, dto, lockSemiFinishedProductInOutStorageBomList, StatusConstant.YES);
|
|
|
}
|
|
|
|
|
|
// 主材从半成品仓出库(从非冻结库存出库)
|
|
|
- List<InOutStorageBom> semiFinishedProductInOutStorageBomList = list.stream()
|
|
|
+ List<InOutStorageBom> semiFinishedProductInOutStorageBomList = inOutStorageBomBoList.stream()
|
|
|
.filter(item -> ObjectUtil.equal(bomSpecBo.get(item.getBomSpecId()).getClassifyParentId(), 1L))
|
|
|
.filter(item -> ObjectUtil.notEqual(item.getLockStorage(), StatusConstant.YES))
|
|
|
.collect(Collectors.toList());
|
|
|
- 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);
|
|
|
+ if (!semiFinishedProductInOutStorageBomList.isEmpty()) {
|
|
|
+ productionOut(WarehouseConstant.SEMI_FINISHED_PRODUCT, dto, semiFinishedProductInOutStorageBomList, StatusConstant.NO);
|
|
|
}
|
|
|
|
|
|
// 包材从包材仓出库
|
|
|
- List<InOutStorageBom> packagingMaterialInOutStorageBomList = list.stream()
|
|
|
+ List<InOutStorageBom> packagingMaterialInOutStorageBomList = inOutStorageBomBoList.stream()
|
|
|
.filter(item -> ObjectUtil.notEqual(bomSpecBo.get(item.getBomSpecId()).getClassifyParentId(), 1L))
|
|
|
.collect(Collectors.toList());
|
|
|
- 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);
|
|
|
+ if (!packagingMaterialInOutStorageBomList.isEmpty()) {
|
|
|
+ productionOut(WarehouseConstant.PACKAGING_MATERIAL, dto, packagingMaterialInOutStorageBomList, StatusConstant.NO);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 生产出库
|
|
|
+ *
|
|
|
+ * @param warehouseId 出库id
|
|
|
+ * @param dto 入参
|
|
|
+ * @param inOutStorageBomList 出库bom规格明细
|
|
|
+ */
|
|
|
+ private void productionOut(Long warehouseId, StockPreparationDto dto, List<InOutStorageBom> inOutStorageBomList, Integer lockStorage) {
|
|
|
+
|
|
|
+ // 合并相同bom规格出库数量
|
|
|
+ List<InOutStorageBom> list = new ArrayList<>(inOutStorageBomList.stream().collect(Collectors.toMap(
|
|
|
+ InOutStorageBom::getBomSpecId,
|
|
|
+ Function.identity(),
|
|
|
+ (v1, v2) -> {
|
|
|
+ v1.setQuantity(v1.getQuantity().add(v2.getQuantity()));
|
|
|
+ return v1;
|
|
|
+ })).values());
|
|
|
+
|
|
|
+ InOutStorageDto inOutStorageDto = new InOutStorageDto();
|
|
|
+ inOutStorageDto.setType(InOutTypeEnum.OUT.getKey());
|
|
|
+ inOutStorageDto.setDetailType(OutDetailTypeEnum.PRODUCTION.getKey());
|
|
|
+ inOutStorageDto.setWarehouseId(warehouseId);
|
|
|
+ inOutStorageDto.setDepartmentId(dto.getOutDepartmentId());
|
|
|
+ inOutStorageDto.setApplicant(dto.getApplicant());
|
|
|
+ inOutStorageDto.setRemark(dto.getRemark());
|
|
|
+ inOutStorageDto.setInOutStorageBomList(list);
|
|
|
+ inOutStorageDto.setLockStorage(lockStorage);
|
|
|
+ inOutStorageService.add(inOutStorageDto);
|
|
|
+ }
|
|
|
+
|
|
|
}
|