做天津杰超项目中赛事活动作品审核中写的一段代码:
1 //获取全部作品 2 ActivityProductionQueryCommond productionQueryCommond=new ActivityProductionQueryCommond(); 3 productionQueryCommond.setSearchProductionWorksId(worksValidCommond.getProductionWorksId()); 4 ListproductionValidCommonds=(List ) this.activityProductionService .findAllList(productionQueryCommond); 5 //循环分组 6 Map > proHashMap=new HashMap >(); 7 for (ActivityProductionValidCommond production : productionValidCommonds) { 8 if(proHashMap.containsKey(production.getProductionGroupId())) { 9 proHashMap.get(production.getProductionGroupId()).add(production);10 }else {11 List proList=new ArrayList ();12 proList.add(production);13 proHashMap.put(production.getProductionGroupId(), proList);14 }15 }16 List keyList=new ArrayList (proHashMap.keySet());17 Collections.sort(keyList);//key排序 空在最上面18 Map > proLinkedMap=new LinkedHashMap >();19 //生成有序map20 for (String key : keyList) {21 if(PropertyUtil.objectNotEmpty(key)) {22 ProductionGroupValidCommond group=this.productionGroupService.find(key);23 key=group.getProductionGroupName();24 }else {25 key="未分组";26 }27 proLinkedMap.put(key, proHashMap.get(key));28 }
写的不好。请大神们指正。我改。