From e950cbbe9c2ec1f01e5e53fb6f95934c926ba585 Mon Sep 17 00:00:00 2001 From: yanyang Date: Mon, 5 Feb 2024 11:23:41 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=8D=E5=A4=8D=E4=B8=8A=E7=89=87=E5=9F=BA?= =?UTF-8?q?=E6=9D=BF=E5=8E=BB=E9=87=8D=E6=8E=92=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/WoPackagingBoxServiceBizImpl.java | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/ym-packing/src/main/java/com/cnbm/packing/service/impl/WoPackagingBoxServiceBizImpl.java b/ym-packing/src/main/java/com/cnbm/packing/service/impl/WoPackagingBoxServiceBizImpl.java index 052277b..9a245a1 100644 --- a/ym-packing/src/main/java/com/cnbm/packing/service/impl/WoPackagingBoxServiceBizImpl.java +++ b/ym-packing/src/main/java/com/cnbm/packing/service/impl/WoPackagingBoxServiceBizImpl.java @@ -142,13 +142,19 @@ public class WoPackagingBoxServiceBizImpl extends CrudServiceImpl wrapper = new QueryWrapper<>(); wrapper.eq(StringUtils.isNotBlank(entity.getBoxNo()), WoPackagingBoxSubstrate.PACKAGING_BOX_ID, entity.getBoxNo()); //重复上片基板去重 -// wrapper.select("DISTINCT WO_SUBSTRATE_ID").orderByDesc("CREATE_TIME"); // wrapper.orderByAsc(WoPackagingBoxSubstrate.SLOT); List woPackagingBoxSubstrateList = substrateMapper.selectList(wrapper); - List distinctList = woPackagingBoxSubstrateList.stream().collect( - Collectors.collectingAndThen( - Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(WoPackagingBoxSubstrate::getWoSubstrateId))), ArrayList::new) - ); + List distinctList = new ArrayList<>(); + Map> map = woPackagingBoxSubstrateList.stream().sorted(Comparator.comparing(WoPackagingBoxSubstrate::getCreateTime).reversed()) + .collect(Collectors.groupingBy(WoPackagingBoxSubstrate::getWoSubstrateId)); + for (Map.Entry> entry : map.entrySet()) { + //取list首并放入到新list中 + distinctList.add(entry.getValue().get(0)); + } +// List distinctList = woPackagingBoxSubstrateList.stream().collect( +// Collectors.collectingAndThen( +// Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(WoPackagingBoxSubstrate::getWoSubstrateId))), ArrayList::new) +// ); List sortedDistinctList = distinctList.stream().sorted(Comparator.comparing(WoPackagingBoxSubstrate::getSlot)).collect(Collectors.toList()); dto.setSubstrateList(sortedDistinctList); return dto; -- 2.24.3