From f29c8786807015d78b9be8a33397f69478d92a76 Mon Sep 17 00:00:00 2001 From: liding <756868258@qq.com> Date: 星期六, 12 七月 2025 16:52:27 +0800 Subject: [PATCH] 1.设备优化 2.配煤计算器 --- main-business/src/main/java/com/ruoyi/business/service/impl/PendingInventoryServiceImpl.java | 71 +++++++++++++++++++++++++++++++++++ 1 files changed, 71 insertions(+), 0 deletions(-) diff --git a/main-business/src/main/java/com/ruoyi/business/service/impl/PendingInventoryServiceImpl.java b/main-business/src/main/java/com/ruoyi/business/service/impl/PendingInventoryServiceImpl.java index a38e13b..275e084 100644 --- a/main-business/src/main/java/com/ruoyi/business/service/impl/PendingInventoryServiceImpl.java +++ b/main-business/src/main/java/com/ruoyi/business/service/impl/PendingInventoryServiceImpl.java @@ -6,30 +6,44 @@ import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ruoyi.basic.dto.CoalFieldDto; import com.ruoyi.basic.entity.CoalField; import com.ruoyi.basic.entity.CoalInfo; import com.ruoyi.basic.entity.CoalValue; import com.ruoyi.basic.mapper.CoalFieldMapper; import com.ruoyi.basic.mapper.CoalInfoMapper; +import com.ruoyi.basic.mapper.CoalPlanMapper; import com.ruoyi.basic.mapper.CoalValueMapper; +import com.ruoyi.basic.service.CoalFieldService; +import com.ruoyi.basic.service.CoalPlanService; import com.ruoyi.business.dto.PendingInventoryDto; import com.ruoyi.business.entity.OfficialInventory; import com.ruoyi.business.entity.PendingInventory; +import com.ruoyi.business.entity.SalesRecord; +import com.ruoyi.business.mapper.InventorySummaryMapper; import com.ruoyi.business.mapper.OfficialInventoryMapper; import com.ruoyi.business.mapper.PendingInventoryMapper; +import com.ruoyi.business.mapper.SalesRecordMapper; 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.StringUtils; 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; +import org.springframework.transaction.interceptor.TransactionAspectSupport; import java.math.BigDecimal; +import java.time.LocalDate; +import java.time.format.DateTimeParseException; import java.util.*; import java.util.function.Function; import java.util.stream.Collectors; +import java.util.stream.Stream; /** * <p> @@ -53,14 +67,41 @@ private final CoalInfoMapper coalInfoMapper; + private final SysUserMapper sysUserMapper; + private final InputInventoryRecordService inputInventoryRecordService; private final InventorySummaryService inventorySummaryService; + + private final CoalFieldService coalFieldService; + + private final CoalPlanService coalPlanService; @Override public IPage<PendingInventoryDto> selectPendingInventoryList(Page page, PendingInventoryDto pendingInventoryDto) { // 1. 鏋勫缓涓绘煡璇� LambdaQueryWrapper<PendingInventory> queryWrapper = new LambdaQueryWrapper<>(); + if (pendingInventoryDto.getRegistrationDate() != null) { + queryWrapper.eq(PendingInventory::getRegistrationDate, pendingInventoryDto.getRegistrationDate()); + } + + // 鎸夌叅绉嶅悕绉版煡璇� + if (StringUtils.isNotBlank(pendingInventoryDto.getCoal())) { + LambdaQueryWrapper<CoalInfo> coalQueryWrapper = new LambdaQueryWrapper<>(); + coalQueryWrapper.like(CoalInfo::getCoal, pendingInventoryDto.getCoal()); + List<CoalInfo> coalInfos = coalInfoMapper.selectList(coalQueryWrapper); + + if (!coalInfos.isEmpty()) { + List<Long> coalIds = coalInfos.stream() + .map(CoalInfo::getId) + .collect(Collectors.toList()); + queryWrapper.in(PendingInventory::getCoalId, coalIds); + } else { + // 濡傛灉娌℃湁鍖归厤鐨勭叅绉嶏紝鐩存帴杩斿洖绌虹粨鏋� + queryWrapper.eq(PendingInventory::getCoalId, -1L); // 浣跨敤涓嶅彲鑳藉瓨鍦ㄧ殑ID + } + } + queryWrapper.orderByDesc(PendingInventory::getCreateTime); // 2. 鎵ц涓昏〃鍒嗛〉鏌ヨ @@ -91,6 +132,20 @@ coalInfoMap = new HashMap<>(); } + // 5. 鎵归噺鏌ヨ鐧昏浜篿d + 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<>(); + } + // 鎵归噺鏌ヨ姝e紡搴撳瓨淇℃伅 Map<Long, Long> pendingToOfficialMap = getOfficialInventoryMap(pendingIds); @@ -103,6 +158,12 @@ CoalInfo coalInfo = coalInfoMap.get(record.getCoalId()); if (coalInfo != null) { dto.setCoal(coalInfo.getCoal()); + } + + // 璁剧疆鐧昏浜� + SysUser sysUser = sysUserMap.get(record.getRegistrantId()); + if (sysUser != null) { + dto.setRegistrant(sysUser.getNickName()); } // 浠庨鍔犺浇鐨凪ap涓幏鍙杘fficialId @@ -209,6 +270,7 @@ BigDecimal left = pendingInventory.getInventoryQuantity().subtract(quantity); if (left.compareTo(BigDecimal.ZERO) > 0) { pendingInventory.setInventoryQuantity(left); + pendingInventory.setCoalPlanId(pendingInventoryDto.getCoalPlanId()); pendingInventoryMapper.updateById(pendingInventory); } else { pendingInventoryMapper.deleteById(pendingInventoryDto.getPId()); @@ -218,8 +280,11 @@ OfficialInventory officialInventory = new OfficialInventory(); BeanUtils.copyProperties(pendingInventory, officialInventory); officialInventory.setId(null); + officialInventory.setCoalPlanId(pendingInventoryDto.getCoalPlanId()); officialInventory.setPendingId(pendingInventoryDto.getPId()); officialInventory.setInventoryQuantity(quantity); + officialInventory.setRegistrantId(1L); + officialInventory.setSupplierId(pendingInventoryDto.getSupplierId()); officialInventoryMapper.insert(officialInventory); } else { OfficialInventory officialInventory = officialInventoryMapper.selectById(pendingInventoryDto.getOfficialId()); @@ -229,4 +294,10 @@ } return i; } + + @Override + @Transactional + public int addPending(PendingInventoryDto pendingInventoryDto) { + return 1; + } } -- Gitblit v1.9.3