| | |
| | | } |
| | | |
| | | 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) { |
| | | private HashMap<String, List<Map<String, BigDecimal>>> toBatchNoMaps( |
| | | HashMap<String, HashMap<String, BigDecimal>> stockBatchNoQtyMaps) { |
| | | 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()) { |
| | |
| | | } |
| | | batchNoMaps.put(entry.getKey(), batchList); |
| | | } |
| | | |
| | | record.setBatchNoMaps(batchNoMaps); |
| | | } |
| | | return batchNoMaps; |
| | | } |
| | | |
| | | private Long toLong(Object value) { |