list<Dto>根据某字段去重

List<CheckSchoolDto> list = eduSchoolSupplierService.findSchool(schoolDto);
        if(list != null && list.size() >0){
            list = mySortSchool(list);

        }




    private List<CheckSchoolDto> mySortSchool(List<CheckSchoolDto> list) {
        HashMap<String,CheckSchoolDto> tempMap = new HashMap<String,CheckSchoolDto>();
        for (CheckSchoolDto c : list) {
            String key = c.getSchoolId();
            if(tempMap.containsKey(key)){
                
            }else{
                tempMap.put(key, c);
            }
        }
        List<CheckSchoolDto> tempList = new ArrayList<CheckSchoolDto>();
        for(String key : tempMap.keySet()){
            tempList.add(tempMap.get(key));
        }
        return tempList;
    }

猜你喜欢

转载自blog.csdn.net/jam_yin/article/details/52958093