重复上片基板去重排序

This commit is contained in:
闫阳 2024-02-05 11:23:41 +08:00
parent 095bdc1e23
commit e950cbbe9c

View File

@ -142,13 +142,19 @@ public class WoPackagingBoxServiceBizImpl extends CrudServiceImpl<WoPackagingBox
QueryWrapper<WoPackagingBoxSubstrate> wrapper = new QueryWrapper<>(); QueryWrapper<WoPackagingBoxSubstrate> wrapper = new QueryWrapper<>();
wrapper.eq(StringUtils.isNotBlank(entity.getBoxNo()), WoPackagingBoxSubstrate.PACKAGING_BOX_ID, entity.getBoxNo()); 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); // wrapper.orderByAsc(WoPackagingBoxSubstrate.SLOT);
List<WoPackagingBoxSubstrate> woPackagingBoxSubstrateList = substrateMapper.selectList(wrapper); List<WoPackagingBoxSubstrate> woPackagingBoxSubstrateList = substrateMapper.selectList(wrapper);
List<WoPackagingBoxSubstrate> distinctList = woPackagingBoxSubstrateList.stream().collect( List<WoPackagingBoxSubstrate> distinctList = new ArrayList<>();
Collectors.collectingAndThen( Map<String, List<WoPackagingBoxSubstrate>> map = woPackagingBoxSubstrateList.stream().sorted(Comparator.comparing(WoPackagingBoxSubstrate::getCreateTime).reversed())
Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(WoPackagingBoxSubstrate::getWoSubstrateId))), ArrayList::new) .collect(Collectors.groupingBy(WoPackagingBoxSubstrate::getWoSubstrateId));
); for (Map.Entry<String, List<WoPackagingBoxSubstrate>> entry : map.entrySet()) {
//取list首并放入到新list中
distinctList.add(entry.getValue().get(0));
}
// List<WoPackagingBoxSubstrate> distinctList = woPackagingBoxSubstrateList.stream().collect(
// Collectors.collectingAndThen(
// Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(WoPackagingBoxSubstrate::getWoSubstrateId))), ArrayList::new)
// );
List<WoPackagingBoxSubstrate> sortedDistinctList = distinctList.stream().sorted(Comparator.comparing(WoPackagingBoxSubstrate::getSlot)).collect(Collectors.toList()); List<WoPackagingBoxSubstrate> sortedDistinctList = distinctList.stream().sorted(Comparator.comparing(WoPackagingBoxSubstrate::getSlot)).collect(Collectors.toList());
dto.setSubstrateList(sortedDistinctList); dto.setSubstrateList(sortedDistinctList);
return dto; return dto;