liding
10 小时以前 cb966ac5c02835eab5a99b7b93a5a9a063cf3201
main-business/src/main/java/com/ruoyi/business/service/impl/PendingInventoryServiceImpl.java
@@ -20,8 +20,10 @@
import com.ruoyi.business.service.InputInventoryRecordService;
import com.ruoyi.business.service.InventorySummaryService;
import com.ruoyi.business.service.PendingInventoryService;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.exception.base.BaseException;
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;
@@ -52,6 +54,8 @@
    private final CoalFieldMapper coalFieldMapper;
    private final CoalInfoMapper coalInfoMapper;
    private final SysUserMapper sysUserMapper;
    private final InputInventoryRecordService inputInventoryRecordService;
@@ -91,6 +95,20 @@
            coalInfoMap = new HashMap<>();
        }
        // 5. 批量查询登记人id
        List<Long> registrantIds = pendingInventoryPage.getRecords().stream()
                .map(PendingInventory::getRegistrantId)
                .distinct()
                .toList();
        // 批量查询登记人
        Map<Long, SysUser> sysUserMap;
        if (!registrantIds.isEmpty()) {
            List<SysUser> sysUsers = sysUserMapper.selectList(registrantIds);
            sysUserMap = sysUsers.stream().collect(Collectors.toMap(SysUser::getUserId, Function.identity()));
        } else {
            sysUserMap = new HashMap<>();
        }
        // 批量查询正式库存信息
        Map<Long, Long> pendingToOfficialMap = getOfficialInventoryMap(pendingIds);
@@ -105,6 +123,12 @@
                dto.setCoal(coalInfo.getCoal());
            }
            // 设置登记人
            SysUser sysUser = sysUserMap.get(record.getRegistrantId());
            if (sysUser != null) {
                dto.setRegistrant(sysUser.getNickName());
            }
            // 从预加载的Map中获取officialId
            dto.setOfficialId(pendingToOfficialMap.getOrDefault(record.getId(), null));