| | |
| | | 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 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.util.*; |
| | | import java.util.function.Function; |
| | | import java.util.stream.Collectors; |
| | | import java.util.stream.Stream; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | |
| | | 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 (StringUtils.isNotBlank(pendingInventoryDto.getSearchAll())) { |
| | | String searchValue = pendingInventoryDto.getSearchAll(); |
| | | // 1. 先尝试作为日期查询 |
| | | try { |
| | | LocalDate RegistrationDate = LocalDate.parse(searchValue); |
| | | queryWrapper.eq(PendingInventory::getRegistrationDate, RegistrationDate); |
| | | } catch (DateTimeParseException e) { |
| | | // 2. 如果不是日期,则作为煤种名称查询 |
| | | if (pendingInventoryDto.getRegistrationDate() != null) { |
| | | queryWrapper.eq(PendingInventory::getRegistrationDate, pendingInventoryDto.getRegistrationDate()); |
| | | } |
| | | |
| | | // 按煤种名称查询 |
| | | if (StringUtils.isNotBlank(pendingInventoryDto.getCoal())) { |
| | | LambdaQueryWrapper<CoalInfo> coalQueryWrapper = new LambdaQueryWrapper<>(); |
| | | coalQueryWrapper.like(CoalInfo::getCoal, searchValue); |
| | | coalQueryWrapper.like(CoalInfo::getCoal, pendingInventoryDto.getCoal()); |
| | | List<CoalInfo> coalInfos = coalInfoMapper.selectList(coalQueryWrapper); |
| | | |
| | | if (!coalInfos.isEmpty()) { |
| | | // 提取所有匹配的煤种ID |
| | | List<Long> coalIds = coalInfos.stream() |
| | | .map(CoalInfo::getId) |
| | | .collect(Collectors.toList()); |
| | | // 使用in查询匹配任意一个煤种ID |
| | | queryWrapper.in(PendingInventory::getCoalId, coalIds); |
| | | } else { |
| | | // 3. 如果找不到煤种,可以返回空结果 |
| | | queryWrapper.eq(PendingInventory::getCoalId, "-1"); // 使用不可能存在的ID |
| | | } |
| | | // 如果没有匹配的煤种,直接返回空结果 |
| | | queryWrapper.eq(PendingInventory::getCoalId, -1L); // 使用不可能存在的ID |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | return i; |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | public int addPending(PendingInventoryDto pendingInventoryDto) { |
| | | return 1; |
| | | } |
| | | } |