From 6733a32d4bcd7ad3ec3f109da0f3d2524766f7bb Mon Sep 17 00:00:00 2001 From: liding <756868258@qq.com> Date: 星期二, 15 七月 2025 15:54:33 +0800 Subject: [PATCH] 1.数据优化 2.配煤计算器入库优化 --- main-business/src/main/java/com/ruoyi/business/service/impl/OfficialInventoryServiceImpl.java | 36 ++++++++++++++++++++++++++++++------ 1 files changed, 30 insertions(+), 6 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 ab87226..eba9e50 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 @@ -19,9 +19,11 @@ import com.ruoyi.business.mapper.OfficialInventoryMapper; import com.ruoyi.business.service.OfficialInventoryService; import com.ruoyi.business.vo.OfficialInventoryVo; +import com.ruoyi.common.core.domain.entity.SysUser; import com.ruoyi.common.exception.base.BaseException; import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.common.utils.bean.BeanUtils; +import com.ruoyi.system.mapper.SysUserMapper; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -54,9 +56,11 @@ private final SupplyMapper supplyMapper; + private final SysUserMapper sysUserMapper; + @Override - public IPage<OfficialInventoryDto> selectOfficialInventoryList(Page page, OfficialInventoryDto officialInventoryDto) { + public IPage<OfficialInventoryDto> selectOfficialInventoryList(Page<OfficialInventory> page, OfficialInventoryDto officialInventoryDto) { // 鍏堟煡鍑哄師濮嬫暟鎹紙OfficialInventory锛� LambdaQueryWrapper<OfficialInventory> queryWrapper = new LambdaQueryWrapper<>(); @@ -73,6 +77,10 @@ .map(OfficialInventory::getSupplierId) .toList(); + List<Long> registrantIds = entityPage.getRecords().stream() + .map(OfficialInventory::getRegistrantId) + .toList(); + Map<Long, Supply> supplyMap; if (!supplierIds.isEmpty()) { List<Supply> infos = supplyMapper.selectList(new LambdaQueryWrapper<Supply>().in(Supply::getId, supplierIds)); @@ -81,19 +89,27 @@ supplyMap = new HashMap<>(); } + //鐧昏浜� + Map<Long, SysUser> userMap; + if (!registrantIds.isEmpty()) { + List<SysUser> sysUsers = sysUserMapper.selectList(registrantIds); + userMap = sysUsers.stream().collect(Collectors.toMap(SysUser::getUserId, Function.identity())); + }else { + userMap = new HashMap<>(); + } // 鏌ヨ鎵�鏈夊彲鐢ㄥ瓧娈碉紙CoalField锛� List<CoalField> coalFields = coalFieldMapper.selectList(null); List<String> allFieldNames = coalFields.stream() .map(CoalField::getFields) .distinct() - .collect(Collectors.toList()); + .toList(); //鏌ヨ鐓ょids List<Long> coalIds = entityPage.getRecords().stream() .map(OfficialInventory::getCoalId) .distinct() - .collect(Collectors.toList()); + .toList(); // 鎵归噺鏌ヨCoalInfo Map<Long, CoalInfo> coalInfoMap; @@ -113,6 +129,12 @@ Supply supply = supplyMap.get(entity.getSupplierId()); if (supply != null) { dto.setSupplierName(supply.getSupplierName()); + } + + // 鐧昏浜� + SysUser sysUser = userMap.get(entity.getRegistrantId()); + if (sysUser != null) { + dto.setRegistrant(sysUser.getNickName()); } List<CoalValue> coalValues; @@ -353,8 +375,10 @@ 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)); + Map<Long, List<CoalValue>> coalValuesMap = coalValueMapper.selectList( + new LambdaQueryWrapper<CoalValue>().in(CoalValue::getPlanId, planIds)) + .stream() + .collect(Collectors.groupingBy(CoalValue::getPlanId)); // 4. 缁勮DTO return officialInventories.stream() .map(inventory -> { @@ -367,7 +391,7 @@ dto.setSupplierCoal(supply.getSupplierName() + " - " + coalInfo.getCoal()); } // 璁剧疆鐓よ川鏁版嵁 - dto.setCoalValues(coalValues); + dto.setCoalValues(coalValuesMap.getOrDefault(inventory.getCoalPlanId(), Collections.emptyList())); return dto; }) .collect(Collectors.toList()); -- Gitblit v1.9.3