map的使用
@Override
public List<Map<String, Object>> findSchedule(Date beginTime, Date endTime, Long userId) {
Map<String, Object> map = new HashMap<>();
Map<String, Object> param = new HashMap<>();
param.put("beginTime", beginTime);
param.put("endTime", endTime);
param.put("userId", userId);
List<CrmSchedule> schedules = crmScheduleRepo.find(param);
for (CrmSchedule schedule : schedules) {//日程的
map.put(DateUtil.format(DateUtil.shortDate(schedule.getDeadline()),
DateUtil.yyyyMMddHHmmss),1);
}
for (CrmSchedule schedule : schedules) {//未完成的跟踪记录
if(schedule.getTrackId()==null){
map.put(DateUtil.format(DateUtil.shortDate(schedule.getDeadline()),
DateUtil.yyyyMMddHHmmss),0);//当做所有是已经完成的
}
}
List<Map<String, Object>> rs = new ArrayList<>();
Set<String> keySet = map.keySet();
for (String key : keySet) {
Map<String, Object> info = new HashMap<>();
info.put("time", key);
info.put("state", map.get(key));
rs.add(info);
}
return rs;
}