|
@@ -182,7 +182,6 @@ public class StockPreparationServiceImpl implements StockPreparationService {
|
|
|
|
|
|
Date stockPreparationTime = new Date();
|
|
|
List<Long> orderIdList = list.stream().map(StockPreparationVo::getOrderId).distinct().collect(Collectors.toList());
|
|
|
- List<Long> orderSkuIdList = list.stream().map(StockPreparationVo::getOrderSkuId).collect(Collectors.toList());
|
|
|
|
|
|
// 订单状态改为生产中
|
|
|
orderService.update(q -> q
|
|
@@ -193,12 +192,12 @@ public class StockPreparationServiceImpl implements StockPreparationService {
|
|
|
|
|
|
// 订单sku出库
|
|
|
orderSkuService.update(q -> q
|
|
|
- .in(BaseIdPo::getId, orderSkuIdList)
|
|
|
+ .in(OrderSku::getOrderId, orderIdList)
|
|
|
.set(OrderSku::getStockPreparationTime, stockPreparationTime)
|
|
|
.set(OrderSku::getStockPreparationStatus, StatusConstant.YES));
|
|
|
|
|
|
// 订单出库
|
|
|
- orderDelivery(orderIdList, list, dto);
|
|
|
+ orderDelivery(orderIdList, dto);
|
|
|
|
|
|
List<ProductionTask> productionTaskList = new ArrayList<>();
|
|
|
List<ProductionWorkOrder> productionWorkOrderList = new ArrayList<>();
|
|
@@ -264,39 +263,40 @@ public class StockPreparationServiceImpl implements StockPreparationService {
|
|
|
return Collections.emptyList();
|
|
|
}
|
|
|
|
|
|
- Map<Long, StockPreparationVo> stockPreparationVoMap =
|
|
|
- stockPreparationVoList.stream().collect(Collectors.toMap(StockPreparationVo::getOrderSkuId, Function.identity()));
|
|
|
-
|
|
|
- // 订单sku包材列表
|
|
|
- List<Long> orderSkuIdList = stockPreparationVoList.stream().map(StockPreparationVo::getOrderSkuId).collect(Collectors.toList());
|
|
|
- List<OrderSkuBom> orderSkuBomList = orderSkuBomService.list(q -> q.in(OrderSkuBom::getOrderSkuId, orderSkuIdList));
|
|
|
-
|
|
|
- // 合并列表
|
|
|
- List<OutBomVo> outBomVoList = stockPreparationVoList.stream().map(item -> {
|
|
|
- OutBomVo outBomVo = new OutBomVo();
|
|
|
- outBomVo.setBomSpecId(item.getBomSpecId());
|
|
|
- outBomVo.setOutQuantity(item.getQuantity());
|
|
|
- return outBomVo;
|
|
|
- }).collect(Collectors.toList());
|
|
|
-
|
|
|
- for (OrderSkuBom orderSkuBom : orderSkuBomList) {
|
|
|
- StockPreparationVo stockPreparationVo = stockPreparationVoMap.get(orderSkuBom.getOrderSkuId());
|
|
|
- OutBomVo outBomVo = new OutBomVo();
|
|
|
- outBomVo.setBomSpecId(orderSkuBom.getBomSpecId());
|
|
|
- outBomVo.setOutQuantity(orderSkuBom.getQuantity().multiply(stockPreparationVo.getQuantity()));
|
|
|
- outBomVoList.add(outBomVo);
|
|
|
- }
|
|
|
+ List<Long> orderIdList = stockPreparationVoList.stream().map(StockPreparationVo::getOrderId).distinct().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));
|
|
|
+ Map<Long, OrderSku> orderSkuMap = orderSkuList.stream().collect(Collectors.toMap(BaseIdPo::getId, Function.identity()));
|
|
|
+
|
|
|
+ Map<Long, OutBomVo> map = Stream.concat(
|
|
|
+ // 主材
|
|
|
+ orderSkuList.stream().map(item -> {
|
|
|
+ OutBomVo outBomVo = new OutBomVo();
|
|
|
+ outBomVo.setBomSpecId(item.getBomSpecId());
|
|
|
+ outBomVo.setOutQuantity(item.getQuantity());
|
|
|
+ return outBomVo;
|
|
|
+ }),
|
|
|
+
|
|
|
+ // 包材
|
|
|
+ orderSkuBomList.stream().map(item -> {
|
|
|
+ OrderSku orderSku = orderSkuMap.get(item.getOrderSkuId());
|
|
|
+ OutBomVo outBomVo = new OutBomVo();
|
|
|
+ outBomVo.setBomSpecId(item.getBomSpecId());
|
|
|
+ outBomVo.setOutQuantity(item.getQuantity().multiply(orderSku.getQuantity()));
|
|
|
+ return outBomVo;
|
|
|
+ })
|
|
|
+ )
|
|
|
+ .collect(Collectors.toMap(
|
|
|
+ OutBomVo::getBomSpecId,
|
|
|
+ Function.identity(),
|
|
|
+ (v1, v2) -> {
|
|
|
+ v1.setOutQuantity(v1.getOutQuantity().add(v2.getOutQuantity()));
|
|
|
+ return v1;
|
|
|
+ })
|
|
|
+ );
|
|
|
|
|
|
- // 合并数量
|
|
|
- Map<Long, OutBomVo> map = outBomVoList.stream().collect(Collectors.toMap(
|
|
|
- OutBomVo::getBomSpecId,
|
|
|
- Function.identity(),
|
|
|
- (v1, v2) -> {
|
|
|
- v1.setOutQuantity(v1.getOutQuantity().add(v2.getOutQuantity()));
|
|
|
- return v1;
|
|
|
- }
|
|
|
- ));
|
|
|
- outBomVoList = new ArrayList<>(map.values());
|
|
|
+ // 合并sku主材和包材
|
|
|
+ List<OutBomVo> outBomVoList = new ArrayList<>(map.values());
|
|
|
|
|
|
// 区分半成品仓和包材仓库
|
|
|
Map<Long, BomSpecBo> bomSpecBoMap = skuSpecService.getBomSpecBoByIdList(map.keySet());
|
|
@@ -460,51 +460,47 @@ public class StockPreparationServiceImpl implements StockPreparationService {
|
|
|
/**
|
|
|
* 订单出库
|
|
|
*/
|
|
|
- private void orderDelivery(List<Long> orderIdList, List<StockPreparationVo> stockPreparationVoList, StockPreparationDto dto) {
|
|
|
-
|
|
|
+ private void orderDelivery(List<Long> orderIdList, 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, StockPreparationVo> stockPreparationVoMap =
|
|
|
- stockPreparationVoList.stream().collect(Collectors.toMap(StockPreparationVo::getOrderSkuId, Function.identity()));
|
|
|
+ Map<Long, OrderSku> orderSkuMap = orderSkuList.stream().collect(Collectors.toMap(BaseIdPo::getId, Function.identity()));
|
|
|
+
|
|
|
+ Map<Long, InOutStorageBom> map = Stream.concat(
|
|
|
+ // 主材
|
|
|
+ orderSkuList.stream().map(item -> {
|
|
|
+ InOutStorageBom inOutStorageBom = new InOutStorageBom();
|
|
|
+ inOutStorageBom.setBomSpecId(item.getBomSpecId());
|
|
|
+ inOutStorageBom.setQuantity(item.getQuantity());
|
|
|
+ return inOutStorageBom;
|
|
|
+ }),
|
|
|
+
|
|
|
+ // 包材
|
|
|
+ orderSkuBomList.stream().map(item -> {
|
|
|
+ OrderSku orderSku = orderSkuMap.get(item.getOrderSkuId());
|
|
|
+ InOutStorageBom inOutStorageBom = new InOutStorageBom();
|
|
|
+ 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;
|
|
|
+ })
|
|
|
+ );
|
|
|
|
|
|
// 合并sku主材和包材
|
|
|
- List<InOutStorageBom> list = new ArrayList<>(
|
|
|
- Stream.concat(
|
|
|
- stockPreparationVoList.stream().map(item -> {
|
|
|
- InOutStorageBom inOutStorageBom = new InOutStorageBom();
|
|
|
- inOutStorageBom.setBomSpecId(item.getBomSpecId());
|
|
|
- inOutStorageBom.setQuantity(item.getQuantity());
|
|
|
- return inOutStorageBom;
|
|
|
- }),
|
|
|
- orderSkuBomList.stream().map(item -> {
|
|
|
- StockPreparationVo stockPreparationVo = stockPreparationVoMap.get(item.getOrderSkuId());
|
|
|
-
|
|
|
- InOutStorageBom inOutStorageBom = new InOutStorageBom();
|
|
|
- inOutStorageBom.setBomSpecId(item.getBomSpecId());
|
|
|
- inOutStorageBom.setQuantity(item.getQuantity().multiply(stockPreparationVo.getQuantity()));
|
|
|
- return inOutStorageBom;
|
|
|
- })
|
|
|
- )
|
|
|
- .collect(Collectors.toMap(
|
|
|
- InOutStorageBom::getBomSpecId,
|
|
|
- Function.identity(),
|
|
|
- (v1, v2) -> {
|
|
|
- v1.setQuantity(v1.getQuantity().add(v2.getQuantity()));
|
|
|
- return v1;
|
|
|
- })
|
|
|
- ).values());
|
|
|
-
|
|
|
- List<Long> bomSpecIdList = list.stream().map(InOutStorageBom::getBomSpecId).collect(Collectors.toList());
|
|
|
- Map<Long, BomSpecBo> bomSpecBo = skuSpecService.getBomSpecBoByIdList(bomSpecIdList);
|
|
|
+ List<InOutStorageBom> list = new ArrayList<>(map.values());
|
|
|
+
|
|
|
+ Map<Long, BomSpecBo> bomSpecBo = skuSpecService.getBomSpecBoByIdList(map.keySet());
|
|
|
|
|
|
// 主材从半成品仓出库
|
|
|
- List<InOutStorageBom> semiFinishedProductInOutStorageBomList = list.stream().filter(item -> {
|
|
|
- BomSpecBo tempBomSpecBo = bomSpecBo.get(item.getBomSpecId());
|
|
|
- if (tempBomSpecBo == null) {
|
|
|
- return false;
|
|
|
- }
|
|
|
- return ObjectUtil.equal(tempBomSpecBo.getClassifyParentId(), 1L);
|
|
|
- }).collect(Collectors.toList());
|
|
|
+ List<InOutStorageBom> semiFinishedProductInOutStorageBomList = list.stream()
|
|
|
+ .filter(item -> ObjectUtil.equal(bomSpecBo.get(item.getBomSpecId()).getClassifyParentId(), 1L))
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
|
|
InOutStorageDto semiFinishedProduct = new InOutStorageDto();
|
|
|
semiFinishedProduct.setType(InOutTypeEnum.OUT.getKey());
|
|
@@ -517,13 +513,9 @@ public class StockPreparationServiceImpl implements StockPreparationService {
|
|
|
inOutStorageService.add(semiFinishedProduct);
|
|
|
|
|
|
// 包材从包材仓出库
|
|
|
- List<InOutStorageBom> packagingMaterialInOutStorageBomList = list.stream().filter(item -> {
|
|
|
- BomSpecBo tempBomSpecBo = bomSpecBo.get(item.getBomSpecId());
|
|
|
- if (tempBomSpecBo == null) {
|
|
|
- return true;
|
|
|
- }
|
|
|
- return ObjectUtil.notEqual(tempBomSpecBo.getClassifyParentId(), 1L);
|
|
|
- }).collect(Collectors.toList());
|
|
|
+ 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());
|