Map分組排列

List<GgNoticeAllocate> ggNoticeAllocates = ggNoticeAllocateManager.findByProperty("noticeguid", getModel().getNoticeguid());
		Map<String, List<GgNoticeAllocate>> ggNoticeAllocateMap = new HashMap<String, List<GgNoticeAllocate>>();
		for (GgNoticeAllocate ggNoticeAllocate : ggNoticeAllocates) {
			String areaname = ggNoticeAllocate.getCityname();
			List<GgNoticeAllocate> ggNoticeAllocateList = null;
			if(ggNoticeAllocateMap.containsKey(areaname) && Validator.isNotNull(ggNoticeAllocateMap.get(areaname))) {
				ggNoticeAllocateList = ggNoticeAllocateMap.get(areaname);
				ggNoticeAllocateList.add(ggNoticeAllocate);
			} else {
				ggNoticeAllocateList = new ArrayList<GgNoticeAllocate>();
				ggNoticeAllocateList.add(ggNoticeAllocate);
				ggNoticeAllocateMap.put(areaname, ggNoticeAllocateList);
			}
		}

List<EventKeyword> eventKeywords = eventKeywordManager.getAll(criterions);	//取到所有需要短信報警的事件
				Map<String, List<EventKeyword>> eventKeywordMap = new HashMap<String, List<EventKeyword>>();
				for (EventKeyword eventKeyword : eventKeywords) {
					EventScore es = eventScoreManager.findByProperty("kwid", eventKeyword.getId()).get(0);
					if(es.getScoresum() < eventKeyword.getAlertscore()) {
						continue;
					}
					String[] userids = eventKeyword.getSmsuserids().split(",");
					List<EventKeyword> eventKeywordList = null;
					for (String userid : userids) {
						if(eventKeywordMap.containsKey(userid) && Validator.isNotNull(eventKeywordMap.get(userid))) {
							eventKeywordList = eventKeywordMap.get(userid);
							eventKeywordList.add(eventKeyword);
						} else {
							eventKeywordList = new ArrayList<EventKeyword>();
							eventKeywordList.add(eventKeyword);
							eventKeywordMap.put(userid, eventKeywordList);
						}
					}
				}


發佈了36 篇原創文章 · 獲贊 16 · 訪問量 76萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章