1. Set<TsUserOccTest> userOccTestExpSet = new TreeSet<>(Comparator.comparing(TsUserOccTest::getOccType)); userOccTestExpSet.addAll(list); list.clear(); list.addAll(userOccTestExpSet);
2.在list的add的时候直接去重(根据属性的唯一值确定)
List<Integer> presTypeRidList = new ArrayList<>(); TsSimpleCode codes = presSimpleCodeMap.get(codeFirstLeveNo); if (null != codes && null != codes.getRid() && !presTypeRidList.contains(codes.getRid())) { tempSortList.add(codes); presTypeRidList.add(codes.getRid()); }