buhuazhen
7 天以前 9f052ad68599a13c63b07dc225464cdc11f28e48
src/main/java/com/ruoyi/production/service/impl/ProductionOrderServiceImpl.java
@@ -1066,8 +1066,19 @@
        }
        // 过滤出非根节点(实际领料项)
        // 排除投入品与产出品相同且比例为1的情况(自身加工,不需要领料)
        List<ProductionBomStructureVo> childStructureList = bomStructureList.stream()
                .filter(s -> s != null && s.getParentId() != null && s.getParentId() != 0)
                .filter(s -> {
                    ProductionBomStructureVo parent = structureByIdMap.get(s.getParentId());
                    if (parent == null) {
                        return true;
                    }
                    // 投入品与产出品相同且比例为1时,不需要领料
                    boolean sameProduct = Objects.equals(s.getProductModelId(), parent.getProductModelId());
                    boolean unitRatio = BigDecimal.ONE.compareTo(defaultDecimal(s.getUnitQuantity())) == 0;
                    return !(sameProduct && unitRatio);
                })
                .collect(Collectors.toList());
        // 遍历处理数据并组装结果
@@ -1095,34 +1106,29 @@
            }
        }
        Map<String, ProductionOrderPickVo> mergedPickMap = new LinkedHashMap<>();
        List<ProductionOrderPickVo> pickList = new ArrayList<>();
        for (ProductionBomStructureVo structure : childStructureList) {
            if (structure == null || structure.getProductModelId() == null) {
                continue;
            }
            Long productModelId = structure.getProductModelId();
            String mergeKey = String.valueOf(structure.getTechnologyOperationId()) + "#" + productModelId;
            ProductionOrderPickVo vo = mergedPickMap.get(mergeKey);
            if (vo == null) {
                vo = new ProductionOrderPickVo();
                vo.setProductModelId(productModelId);
                vo.setOperationName(structure.getOperationName());
                vo.setTechnologyOperationId(structure.getTechnologyOperationId());
                vo.setProductName(structure.getProductName());
                vo.setModel(structure.getModel());
                vo.setDemandedQuantity(BigDecimal.ZERO);
                vo.setUnit(structure.getUnit());
                List<String> batchNoList = stockBatchNoMap.get(productModelId) == null
                        ? Collections.emptyList()
                        : new ArrayList<>(stockBatchNoMap.get(productModelId));
                vo.setBatchNoList(batchNoList);
                vo.setStockQuantity(stockQuantityMap.getOrDefault(productModelId, BigDecimal.ZERO));
                vo.setBom(true);
                mergedPickMap.put(mergeKey, vo);
            }
            vo.setDemandedQuantity(defaultDecimal(vo.getDemandedQuantity()).add(defaultDecimal(structure.getDemandedQuantity())));
            ProductionOrderPickVo vo = new ProductionOrderPickVo();
            vo.setProductModelId(productModelId);
            vo.setOperationName(structure.getOperationName());
            vo.setTechnologyOperationId(structure.getTechnologyOperationId());
            vo.setProductName(structure.getProductName());
            vo.setModel(structure.getModel());
            vo.setDemandedQuantity(defaultDecimal(structure.getDemandedQuantity()));
            vo.setUnit(structure.getUnit());
            List<String> batchNoList = stockBatchNoMap.get(productModelId) == null
                    ? Collections.emptyList()
                    : new ArrayList<>(stockBatchNoMap.get(productModelId));
            vo.setBatchNoList(batchNoList);
            vo.setStockQuantity(stockQuantityMap.getOrDefault(productModelId, BigDecimal.ZERO));
            vo.setBom(true);
            pickList.add(vo);
        }
        return new ArrayList<>(mergedPickMap.values());
        return pickList;
    }
    @Override