做天津杰超项目中赛事活动作品审核中写的一段代码:

 //获取全部作品
ActivityProductionQueryCommond productionQueryCommond=new ActivityProductionQueryCommond();
productionQueryCommond.setSearchProductionWorksId(worksValidCommond.getProductionWorksId());
List<ActivityProductionValidCommond> productionValidCommonds=(List<ActivityProductionValidCommond>) this.activityProductionService
    .findAllList(productionQueryCommond);
//循环分组
Map<String, List<ActivityProductionValidCommond>> proHashMap=new HashMap<String, List<ActivityProductionValidCommond>>();
for (ActivityProductionValidCommond production : productionValidCommonds) {
if(proHashMap.containsKey(production.getProductionGroupId())) {
proHashMap.get(production.getProductionGroupId()).add(production);
}else {
List<ActivityProductionValidCommond> proList=new ArrayList<ActivityProductionValidCommond>();
proList.add(production);
proHashMap.put(production.getProductionGroupId(), proList);
}
}
List<String> keyList=new ArrayList<String>(proHashMap.keySet());
Collections.sort(keyList);//key排序 空在最上面
Map<String, List<ActivityProductionValidCommond>> proLinkedMap=new LinkedHashMap<String, List<ActivityProductionValidCommond>>();
//生成有序map
for (String key : keyList) {
if(PropertyUtil.objectNotEmpty(key)) {
ProductionGroupValidCommond group=this.productionGroupService.find(key);
key=group.getProductionGroupName();
}else {
key="未分组";
}
proLinkedMap.put(key, proHashMap.get(key));
}

写的不好。请大神们指正。我改。

04-22 20:05