|
@@ -318,15 +318,15 @@ public class StockPreparationServiceImpl implements StockPreparationService {
|
|
|
.set(OrderSku::getStockPreparationTime, stockPreparationTime)
|
|
|
.set(OrderSku::getStockPreparationStatus, StatusConstant.YES));
|
|
|
|
|
|
- // 成品库出库
|
|
|
+ // 订单出库
|
|
|
if (Objects.equals(dto.getOrderStockType(), 1)) {
|
|
|
+ // 成品库出库
|
|
|
orderFinishedDelivery(list, dto);
|
|
|
- return;
|
|
|
+ } else {
|
|
|
+ // 半成品出库
|
|
|
+ orderDelivery(list, dto);
|
|
|
}
|
|
|
|
|
|
- // 订单出库
|
|
|
- orderDelivery(list, dto);
|
|
|
-
|
|
|
List<ProductionWorkOrder> productionWorkOrderList = new ArrayList<>();
|
|
|
|
|
|
// 生产工单
|
|
@@ -380,99 +380,48 @@ public class StockPreparationServiceImpl implements StockPreparationService {
|
|
|
statementOfAccountService.add(statement);
|
|
|
}
|
|
|
|
|
|
- List<OrderSku> finishedSkuList = new ArrayList<>();
|
|
|
- for (Long orderId : orderIds) {
|
|
|
- finishedSkuList.addAll(orderSkuMap.getOrDefault(orderId, Collections.emptyList()));
|
|
|
- }
|
|
|
-
|
|
|
// 生产入库
|
|
|
- inventoryFinishedService.noSourceInWarehousing(finishedSkuList);
|
|
|
-
|
|
|
- // 无理由订单的快递包材退料
|
|
|
- List<OrderPackageBom> orderPackageBomList = orderPackageBomService.list(q -> q.in(OrderPackageBom::getOrderId, orderIds));
|
|
|
- Map<Long, InOutStorageBom> inStorageBomMap = orderPackageBomList.stream()
|
|
|
- .map(item -> {
|
|
|
- InOutStorageBom inStorageBom = new InOutStorageBom();
|
|
|
- inStorageBom.setBomSpecId(item.getBomSpecId());
|
|
|
- inStorageBom.setQuantity(item.getQuantity());
|
|
|
- return inStorageBom;
|
|
|
- }).collect(Collectors.toMap(
|
|
|
- InOutStorageBom::getBomSpecId,
|
|
|
- Function.identity(),
|
|
|
- (v1, v2) -> {
|
|
|
- v1.setQuantity(v1.getQuantity().add(v2.getQuantity()));
|
|
|
- return v1;
|
|
|
- }
|
|
|
- ));
|
|
|
- InOutStorageDto packageBomInStorageDto = new InOutStorageDto();
|
|
|
- packageBomInStorageDto.setType(InOutTypeEnum.IN.getKey());
|
|
|
- packageBomInStorageDto.setDetailType(InDetailTypeEnum.RETURN_GOODS.getKey());
|
|
|
- packageBomInStorageDto.setWarehouseId(WarehouseConstant.PACKAGING_MATERIAL);
|
|
|
- packageBomInStorageDto.setDepartmentId(DepartmentConstant.SD_SPORTS);
|
|
|
- packageBomInStorageDto.setApplicant(SecurityUtils.getLoginUser().getUser().getNickName());
|
|
|
- packageBomInStorageDto.setRemark("无理由订单快递包材退料入库");
|
|
|
- packageBomInStorageDto.setInOutStorageBomList(new ArrayList<>(inStorageBomMap.values()));
|
|
|
- inOutStorageService.add(packageBomInStorageDto);
|
|
|
+ inventoryFinishedService.productionWarehousing(orderIds);
|
|
|
}
|
|
|
|
|
|
- // 把生产工单发送到mq
|
|
|
- productionWorkOrderService.sendMq(productionWorkOrderList);
|
|
|
-
|
|
|
+ // 成品出库不需要生产裸垫
|
|
|
+ if (Objects.equals(dto.getOrderStockType(), 0)) {
|
|
|
+ // 把生产工单发送到mq
|
|
|
+ productionWorkOrderService.sendMq(productionWorkOrderList);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
private void orderFinishedDelivery(List<StockPreparationVo> list, StockPreparationDto dto) {
|
|
|
List<Long> orderIdList = list.stream().map(StockPreparationVo::getOrderId).distinct().collect(Collectors.toList());
|
|
|
|
|
|
- // 出库快递包装包材
|
|
|
- List<OrderPackageBom> orderPackageBomList = orderPackageBomService.list(q -> q.in(OrderPackageBom::getOrderId, orderIdList));
|
|
|
- if (!orderPackageBomList.isEmpty()) {
|
|
|
- // 快递包材
|
|
|
- List<InOutStorageBom> outStorageBomList = orderPackageBomList.stream()
|
|
|
- .map(item -> {
|
|
|
- InOutStorageBom inOutStorageBom = new InOutStorageBom();
|
|
|
- inOutStorageBom.setBomSpecId(item.getBomSpecId());
|
|
|
- inOutStorageBom.setQuantity(item.getQuantity());
|
|
|
- return inOutStorageBom;
|
|
|
- })
|
|
|
- .collect(Collectors.toList());
|
|
|
- productionOut(WarehouseConstant.PACKAGING_MATERIAL, dto, outStorageBomList, StatusConstant.NO);
|
|
|
+ // 查询出委外订单,委外订单不出库主材
|
|
|
+ List<OrderInfo> noReasonOrderList = orderService.list(q -> q
|
|
|
+ .in(BaseIdPo::getId, orderIdList)
|
|
|
+ .eq(OrderInfo::getClassify, OrderClassifyEnum.NO_REASON_ORDER.getKey())
|
|
|
+ .select(BaseIdPo::getId));
|
|
|
+ List<Long> noReasonOrderIds = noReasonOrderList.stream().map(BaseIdPo::getId).collect(Collectors.toList());
|
|
|
+
|
|
|
+ List<Long> orderPackageIds = new ArrayList<>(orderIdList);
|
|
|
+ orderPackageIds.removeAll(noReasonOrderIds);
|
|
|
+
|
|
|
+ if (!orderPackageIds.isEmpty()) {
|
|
|
+ // 出库快递包装包材
|
|
|
+ List<OrderPackageBom> orderPackageBomList = orderPackageBomService.list(q -> q.in(OrderPackageBom::getOrderId, orderPackageIds));
|
|
|
+ if (!orderPackageBomList.isEmpty()) {
|
|
|
+ // 快递包材
|
|
|
+ List<InOutStorageBom> outStorageBomList = orderPackageBomList.stream()
|
|
|
+ .map(item -> {
|
|
|
+ InOutStorageBom inOutStorageBom = new InOutStorageBom();
|
|
|
+ inOutStorageBom.setBomSpecId(item.getBomSpecId());
|
|
|
+ inOutStorageBom.setQuantity(item.getQuantity());
|
|
|
+ return inOutStorageBom;
|
|
|
+ })
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ productionOut(WarehouseConstant.PACKAGING_MATERIAL, dto, outStorageBomList, StatusConstant.NO);
|
|
|
+ }
|
|
|
}
|
|
|
// 成品出库
|
|
|
inventoryFinishedService.noSourceSaleOutOfWarehouse(orderIdList);
|
|
|
-
|
|
|
- // 生产工单
|
|
|
- List<ProductionWorkOrder> productionWorkOrderList = new ArrayList<>();
|
|
|
- Map<Long, List<StockPreparationVo>> map = list.stream().collect(Collectors.groupingBy(StockPreparationVo::getOrderId));
|
|
|
- List<OrderSku> orderSkuList = orderSkuService.list(q -> q.in(OrderSku::getOrderId, map.keySet()));
|
|
|
- // 筛选掉赠品sku
|
|
|
- List<Long> skuSpecIds = orderSkuList.stream().map(OrderSku::getSkuSpecId).collect(Collectors.toList());
|
|
|
- Set<Long> giftSkuSpecIds = skuSpecService.getGiftIdListByIdList(skuSpecIds);
|
|
|
-
|
|
|
- Map<Long, List<OrderSku>> orderSkuMap = orderSkuList.stream()
|
|
|
- .filter(item -> giftSkuSpecIds.isEmpty() || !giftSkuSpecIds.contains(item.getSkuSpecId()))
|
|
|
- .collect(Collectors.groupingBy(OrderSku::getOrderId));
|
|
|
-
|
|
|
- map.forEach((orderId, stockPreparationVoList) -> {
|
|
|
- StockPreparationVo stockPreparationVo = stockPreparationVoList.get(0);
|
|
|
- String orderCode = stockPreparationVo.getOrderCode();
|
|
|
- String orderWlnCode = stockPreparationVo.getOrderWlnCode();
|
|
|
- addWorkOrder(orderId, ObjectUtil.defaultIfNull(orderWlnCode, orderCode),
|
|
|
- orderSkuMap.getOrDefault(orderId, Collections.emptyList()), productionWorkOrderList);
|
|
|
- });
|
|
|
-
|
|
|
- skuSpecService.attributeAssign(productionWorkOrderList, ProductionWorkOrder::getSkuSpecId,
|
|
|
- (item, skuSpec) -> item.setMachinedPanel(skuSpec.getMachinedPanel()));
|
|
|
-
|
|
|
- // 直接完成生产任务
|
|
|
- productionWorkOrderList.forEach(item -> {
|
|
|
- item.setStatus(3);
|
|
|
- item.setCompleteTime(new Date());
|
|
|
- });
|
|
|
-
|
|
|
- orderService.update(q -> q
|
|
|
- .in(BaseIdPo::getId, orderIdList)
|
|
|
- .set(OrderInfo::getStatus, OrderStatusEnum.COMPLETION_PRODUCTION.getKey()));
|
|
|
- productionWorkOrderService.saveBatch(productionWorkOrderList);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -524,14 +473,32 @@ public class StockPreparationServiceImpl implements StockPreparationService {
|
|
|
|
|
|
List<Long> orderIdList = stockPreparationVoList.stream().map(StockPreparationVo::getOrderId).distinct().collect(Collectors.toList());
|
|
|
// 查询出委外订单,委外订单不出库主材
|
|
|
- List<Long> outsourceOrderIds = orderService.list(q -> q
|
|
|
- .in(BaseIdPo::getId, orderIdList)
|
|
|
- .eq(OrderInfo::getType, 2)
|
|
|
- .select(BaseIdPo::getId))
|
|
|
- .stream().map(BaseIdPo::getId).collect(Collectors.toList());
|
|
|
+ List<OrderInfo> specialOrderList = orderService.list(q -> q
|
|
|
+ .in(BaseIdPo::getId, orderIdList)
|
|
|
+ .and(e -> e.eq(OrderInfo::getType, 2).or().eq(OrderInfo::getClassify, OrderClassifyEnum.NO_REASON_ORDER.getKey()))
|
|
|
+ .select(BaseIdPo::getId, OrderInfo::getType));
|
|
|
+ // 委外订单id集合
|
|
|
+ List<Long> outsourceOrderIds = specialOrderList.stream()
|
|
|
+ .filter(item -> Objects.equals(item.getType(), 2))
|
|
|
+ .map(BaseIdPo::getId)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ // 无理由订单id集合
|
|
|
+ List<Long> noReasonOrderIds = specialOrderList.stream()
|
|
|
+ .filter(item -> !Objects.equals(item.getType(), 2))
|
|
|
+ .map(BaseIdPo::getId)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+
|
|
|
List<OrderSku> orderSkuList = orderSkuService.list(q -> q.in(OrderSku::getOrderId, orderIdList));
|
|
|
List<OrderSkuBom> orderSkuBomList = orderSkuBomService.list(q -> q.in(OrderSkuBom::getOrderId, orderIdList));
|
|
|
- List<OrderPackageBom> orderPackageBomList = orderPackageBomService.list(q -> q.in(OrderPackageBom::getOrderId, orderIdList));
|
|
|
+ // 无理由订单不出库快递包材
|
|
|
+ List<Long> orderPackageIds = new ArrayList<>(orderIdList);
|
|
|
+ orderPackageIds.removeAll(noReasonOrderIds);
|
|
|
+ List<OrderPackageBom> orderPackageBomList;
|
|
|
+ if (orderPackageIds.isEmpty()) {
|
|
|
+ orderPackageBomList = Collections.emptyList();
|
|
|
+ } else {
|
|
|
+ orderPackageBomList = orderPackageBomService.list(q -> q.in(OrderPackageBom::getOrderId, orderPackageIds));
|
|
|
+ }
|
|
|
Map<Long, OrderSku> orderSkuMap = orderSkuList.stream().collect(Collectors.toMap(BaseIdPo::getId, Function.identity()));
|
|
|
// 筛选掉赠品sku
|
|
|
List<Long> skuSpecIds = orderSkuList.stream().map(OrderSku::getSkuSpecId).collect(Collectors.toList());
|
|
@@ -713,7 +680,18 @@ public class StockPreparationServiceImpl implements StockPreparationService {
|
|
|
outSkuVo.setInventoryQuantity(inventoryMap.getOrDefault(skuSpecId, BigDecimal.ZERO));
|
|
|
}
|
|
|
|
|
|
- // 获取快递包装包材
|
|
|
+ // 获取快递包装包材,筛选委外订单不出库主材
|
|
|
+ List<OrderInfo> noReasonOrderList = orderService.list(q -> q
|
|
|
+ .in(BaseIdPo::getId, orderIdList)
|
|
|
+ .eq(OrderInfo::getClassify, OrderClassifyEnum.NO_REASON_ORDER.getKey())
|
|
|
+ .select(BaseIdPo::getId));
|
|
|
+ List<Long> noReasonOrderIds = noReasonOrderList.stream().map(BaseIdPo::getId).collect(Collectors.toList());
|
|
|
+ orderIdList.removeAll(noReasonOrderIds);
|
|
|
+
|
|
|
+ if (orderIdList.isEmpty()) {
|
|
|
+ return outBomVoList;
|
|
|
+ }
|
|
|
+
|
|
|
List<OrderPackageBom> orderPackageBomList = orderPackageBomService.list(q -> q.in(OrderPackageBom::getOrderId, orderIdList));
|
|
|
if (orderPackageBomList.isEmpty()) {
|
|
|
return outBomVoList;
|
|
@@ -835,17 +813,35 @@ public class StockPreparationServiceImpl implements StockPreparationService {
|
|
|
item -> ObjectUtil.defaultIfNull(item.getLockStorage(), StatusConstant.NO),
|
|
|
(v1, v2) -> v1)
|
|
|
);
|
|
|
+ Set<Long> orderIdList = orderIdLockStorageMap.keySet();
|
|
|
// 查询出委外订单,委外订单不出库主材
|
|
|
- List<Long> outsourceOrderIds = orderService.list(q -> q
|
|
|
- .in(BaseIdPo::getId, orderIdLockStorageMap.keySet())
|
|
|
- .eq(OrderInfo::getType, 2)
|
|
|
- .select(BaseIdPo::getId))
|
|
|
- .stream().map(BaseIdPo::getId).collect(Collectors.toList());
|
|
|
+ List<OrderInfo> specialOrderList = orderService.list(q -> q
|
|
|
+ .in(BaseIdPo::getId, orderIdList)
|
|
|
+ .and(e -> e.eq(OrderInfo::getType, 2).or().eq(OrderInfo::getClassify, OrderClassifyEnum.NO_REASON_ORDER.getKey()))
|
|
|
+ .select(BaseIdPo::getId, OrderInfo::getType));
|
|
|
+ // 委外订单id集合
|
|
|
+ List<Long> outsourceOrderIds = specialOrderList.stream()
|
|
|
+ .filter(item -> Objects.equals(item.getType(), 2))
|
|
|
+ .map(BaseIdPo::getId)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ // 无理由订单id集合
|
|
|
+ List<Long> noReasonOrderIds = specialOrderList.stream()
|
|
|
+ .filter(item -> !Objects.equals(item.getType(), 2))
|
|
|
+ .map(BaseIdPo::getId)
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
|
|
- List<OrderSku> orderSkuList = orderSkuService.list(q -> q.in(OrderSku::getOrderId, orderIdLockStorageMap.keySet()));
|
|
|
- List<OrderSkuBom> orderSkuBomList = orderSkuBomService.list(q -> q.in(OrderSkuBom::getOrderId, orderIdLockStorageMap.keySet()));
|
|
|
+ List<OrderSku> orderSkuList = orderSkuService.list(q -> q.in(OrderSku::getOrderId, orderIdList));
|
|
|
+ List<OrderSkuBom> orderSkuBomList = orderSkuBomService.list(q -> q.in(OrderSkuBom::getOrderId, orderIdList));
|
|
|
Map<Long, OrderSku> orderSkuMap = orderSkuList.stream().collect(Collectors.toMap(BaseIdPo::getId, Function.identity()));
|
|
|
- List<OrderPackageBom> orderPackageBomList = orderPackageBomService.list(q -> q.in(OrderPackageBom::getOrderId, orderIdLockStorageMap.keySet()));
|
|
|
+ // 无理由订单不出库快递包材
|
|
|
+ List<Long> orderPackageIds = new ArrayList<>(orderIdList);
|
|
|
+ orderPackageIds.removeAll(noReasonOrderIds);
|
|
|
+ List<OrderPackageBom> orderPackageBomList;
|
|
|
+ if (orderPackageIds.isEmpty()) {
|
|
|
+ orderPackageBomList = Collections.emptyList();
|
|
|
+ } else {
|
|
|
+ orderPackageBomList = orderPackageBomService.list(q -> q.in(OrderPackageBom::getOrderId, orderPackageIds));
|
|
|
+ }
|
|
|
// 筛选掉赠品sku
|
|
|
List<Long> skuSpecIds = orderSkuList.stream().map(OrderSku::getSkuSpecId).collect(Collectors.toList());
|
|
|
Set<Long> giftSkuSpecIds = skuSpecService.getGiftIdListByIdList(skuSpecIds);
|