From 94509204d25f7c0ad213ae2322be2bd5bfd17424 Mon Sep 17 00:00:00 2001
From: liding <756868258@qq.com>
Date: 星期一, 14 七月 2025 16:30:28 +0800
Subject: [PATCH] 1.初始化配煤计算器数据 2。配煤到待入库

---
 main-business/src/main/java/com/ruoyi/business/service/impl/OfficialInventoryServiceImpl.java |   65 ++++++++++++++++++++++++++++++++
 1 files changed, 65 insertions(+), 0 deletions(-)

diff --git a/main-business/src/main/java/com/ruoyi/business/service/impl/OfficialInventoryServiceImpl.java b/main-business/src/main/java/com/ruoyi/business/service/impl/OfficialInventoryServiceImpl.java
index ceafff7..ab87226 100644
--- a/main-business/src/main/java/com/ruoyi/business/service/impl/OfficialInventoryServiceImpl.java
+++ b/main-business/src/main/java/com/ruoyi/business/service/impl/OfficialInventoryServiceImpl.java
@@ -26,7 +26,9 @@
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
+import java.math.BigDecimal;
 import java.util.*;
+import java.util.function.BiConsumer;
 import java.util.function.Function;
 import java.util.stream.Collectors;
 
@@ -330,4 +332,67 @@
         }
     }
 
+    @Override
+    public List<OfficialInventoryDto> coalBlendingList() {
+        // 1. 鏌ヨ鍩虹搴撳瓨鏁版嵁
+        List<OfficialInventory> officialInventories = officialInventoryMapper.selectList(null);
+        // 2. 鏀堕泦鎵�鏈夐渶瑕佹煡璇㈢殑ID
+        Set<Long> coalIds = new HashSet<>();
+        Set<Long> supplierIds = new HashSet<>();
+        Set<Long> planIds = new HashSet<>();
+
+        officialInventories.forEach(inventory -> {
+            coalIds.add(inventory.getCoalId());
+            supplierIds.add(inventory.getSupplierId());
+            planIds.add(inventory.getCoalPlanId());
+        });
+        // 3. 鎵归噺鏌ヨ鍏宠仈鏁版嵁
+        Map<Long, CoalInfo> coalInfoMap = coalInfoMapper.selectByIds(coalIds).stream()
+                .collect(Collectors.toMap(CoalInfo::getId, Function.identity()));
+
+        Map<Long, Supply> supplyMap = supplyMapper.selectByIds(supplierIds).stream()
+                .collect(Collectors.toMap(Supply::getId, Function.identity()));
+
+        List<CoalValue> coalValues = coalValueMapper.selectList(
+                new LambdaQueryWrapper<CoalValue>().in(CoalValue::getPlanId, planIds));
+        // 4. 缁勮DTO
+        return officialInventories.stream()
+                .map(inventory -> {
+                    OfficialInventoryDto dto = new OfficialInventoryDto();
+                    BeanUtils.copyProperties(inventory, dto);
+                    // 璁剧疆鐓ょ淇℃伅
+                    CoalInfo coalInfo = coalInfoMap.get(inventory.getCoalId());
+                    Supply supply = supplyMap.get(inventory.getSupplierId());
+                    if (coalInfo != null && supply != null) {
+                        dto.setSupplierCoal(supply.getSupplierName() + " - " + coalInfo.getCoal());
+                    }
+                    // 璁剧疆鐓よ川鏁版嵁
+                    dto.setCoalValues(coalValues);
+                    return dto;
+                })
+                .collect(Collectors.toList());
+    }
+
+    @Override
+    public Map<String, BigDecimal> selectOfficialAllInfo() {
+        // 1. 鏌ヨ official_inventory 琛ㄦ暟鎹�
+        List<OfficialInventory> officialInventories = officialInventoryMapper.selectList(null);
+
+        // 鐢ㄤ簬瀛樺偍鏈�缁堢粨鏋滐紝key 涓虹叅绉嶅悕绉帮紝value 涓哄簱瀛樻暟閲忔嫾鎺モ�滃惃鈥�
+        Map<String, BigDecimal> resultMap = new LinkedHashMap<>();
+
+        // 2. 閬嶅巻鏌ヨ缁撴灉锛屽叧鑱� coalInfo 鑾峰彇鐓ょ鍚嶇О骞剁粍瑁呮暟鎹�
+        for (OfficialInventory inventory : officialInventories) {
+            Long coalId = inventory.getCoalId();
+            // 鏍规嵁 coalId 鍒� coalInfoMapper 鏌ヨ鐓ょ鍚嶇О
+            CoalInfo coalInfo = coalInfoMapper.selectById(coalId);
+            if (coalInfo != null) {
+                String coalName = coalInfo.getCoal(); // 鍋囪 CoalInfo 鏈� getCoalName 鏂规硶鑾峰彇鐓ょ鍚嶇О
+                BigDecimal quantity = inventory.getInventoryQuantity();
+                resultMap.put(coalName, quantity);
+            }
+        }
+        return resultMap;
+    }
+
 }

--
Gitblit v1.9.3