| | |
| | | } |
| | | // 浪潮用于区分成品和物料 |
| | | if (productDto.getProductType() != null && !productDto.getProductType().isEmpty()) { |
| | | if (productDto.getProductType().equals("成品")){ |
| | | if (productDto.getProductType().equals("成品")) { |
| | | queryWrapper.eq(Product::getProductName, productDto.getProductType()); |
| | | }else queryWrapper.ne(Product::getProductName, "成品"); |
| | | } else queryWrapper.ne(Product::getProductName, "成品"); |
| | | } |
| | | |
| | | // 查询根节点列表 |
| | |
| | | } |
| | | |
| | | List<Map<String, Object>> batchRows = productModelMapper.selectBatchNoQtyByProductModelIds(productModelIds); |
| | | List<Map<String, Object>> unqualifiedBatchRows = |
| | | productModelMapper.selectUnqualifiedBatchNoQtyByProductModelIds(productModelIds); |
| | | batchRows.addAll(unqualifiedBatchRows); |
| | | Map<Long, HashMap<String, HashMap<String, BigDecimal>>> batchNoQtyMapsByProductModelId = |
| | | buildBatchNoQtyMaps(batchRows); |
| | | for (ProductModelVo record : records) { |
| | | record.setBatchNoMaps(toBatchNoMaps( |
| | | batchNoQtyMapsByProductModelId.getOrDefault(record.getId(), new HashMap<>()))); |
| | | } |
| | | } |
| | | |
| | | private Map<Long, HashMap<String, HashMap<String, BigDecimal>>> buildBatchNoQtyMaps( |
| | | List<Map<String, Object>> batchRows) { |
| | | Map<Long, HashMap<String, HashMap<String, BigDecimal>>> batchNoQtyMapsByProductModelId = new HashMap<>(); |
| | | for (Map<String, Object> batchRow : batchRows) { |
| | | Long productModelId = toLong(batchRow.get("productModelId")); |
| | |
| | | .computeIfAbsent(String.valueOf(warehouseId), key -> new HashMap<>()) |
| | | .merge(batchNo, toBigDecimal(batchRow.get("qty")), BigDecimal::add); |
| | | } |
| | | return batchNoQtyMapsByProductModelId; |
| | | } |
| | | |
| | | for (ProductModelVo record : records) { |
| | | HashMap<String, List<Map<String, BigDecimal>>> batchNoMaps = new HashMap<>(); |
| | | HashMap<String, HashMap<String, BigDecimal>> stockBatchNoQtyMaps = |
| | | batchNoQtyMapsByProductModelId.getOrDefault(record.getId(), new HashMap<>()); |
| | | |
| | | for (Map.Entry<String, HashMap<String, BigDecimal>> entry : stockBatchNoQtyMaps.entrySet()) { |
| | | List<Map<String, BigDecimal>> batchList = new ArrayList<>(); |
| | | for (Map.Entry<String, BigDecimal> batchEntry : entry.getValue().entrySet()) { |
| | | Map<String, BigDecimal> batchItem = new HashMap<>(); |
| | | batchItem.put(batchEntry.getKey(), batchEntry.getValue()); |
| | | batchList.add(batchItem); |
| | | } |
| | | batchNoMaps.put(entry.getKey(), batchList); |
| | | private HashMap<String, List<Map<String, BigDecimal>>> toBatchNoMaps( |
| | | HashMap<String, HashMap<String, BigDecimal>> stockBatchNoQtyMaps) { |
| | | HashMap<String, List<Map<String, BigDecimal>>> batchNoMaps = new HashMap<>(); |
| | | for (Map.Entry<String, HashMap<String, BigDecimal>> entry : stockBatchNoQtyMaps.entrySet()) { |
| | | List<Map<String, BigDecimal>> batchList = new ArrayList<>(); |
| | | for (Map.Entry<String, BigDecimal> batchEntry : entry.getValue().entrySet()) { |
| | | Map<String, BigDecimal> batchItem = new HashMap<>(); |
| | | batchItem.put(batchEntry.getKey(), batchEntry.getValue()); |
| | | batchList.add(batchItem); |
| | | } |
| | | |
| | | record.setBatchNoMaps(batchNoMaps); |
| | | batchNoMaps.put(entry.getKey(), batchList); |
| | | } |
| | | return batchNoMaps; |
| | | } |
| | | |
| | | private Long toLong(Object value) { |