| | |
| | | package com.ruoyi.production.service.impl; |
| | | |
| | | import cn.hutool.core.bean.BeanUtil; |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.util.IdUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | |
| | | |
| | | return productionPrintOrderDto; |
| | | } |
| | | |
| | | @Override |
| | | public List<ProductionPrintOrder> getListByOrders(List<Long> orderIds) { |
| | | if(CollUtil.isEmpty(orderIds)){ |
| | | return new ArrayList<>(); |
| | | } |
| | | LambdaQueryWrapper<ProductionPrintOrder> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.in(ProductionPrintOrder::getProductOrderId, orderIds); |
| | | List<ProductionPrintOrder> productionPrintOrders = productionPrintOrderMapper.selectList(queryWrapper); |
| | | // 去除重复的orderIds的记录只保留id最大的一个 |
| | | return productionPrintOrders.stream().collect(Collectors.collectingAndThen( |
| | | Collectors.toMap( |
| | | ProductionPrintOrder::getProductOrderId, |
| | | productionPrintOrder -> productionPrintOrder, |
| | | (existing, replacement) -> existing.getId() > replacement.getId() ? existing : replacement |
| | | ), |
| | | map -> new ArrayList<>(map.values()) |
| | | )); |
| | | } |
| | | } |
| | | |
| | | |