@Override
public boolean buildDailyTask(String name, String domain, Date period) {
Date end = new Date(period.getTime() + TimeHelper.ONE_DAY);
StateReport report = m_reportService.queryStateReport(Constants.CAT, period, end);
RouterConfig routerConfig = new RouterConfig(Constants.CAT);
StateReportVisitor visitor = new StateReportVisitor();
visitor.visitStateReport(report);
Map<String, Long> numbers = visitor.getNumbers();
Comparator<Entry<String, Long>> compator = new Comparator<Map.Entry<String, Long>>() {
@Override
public int compare(Entry<String, Long> o1, Entry<String, Long> o2) {
return (int) (o2.getValue() - o1.getValue());
}
};
numbers = SortHelper.sortMap(numbers, compator);
Map<Server, Long> servers = findAvaliableServers();
processMainServer(servers, routerConfig, numbers);
processBackServer(servers, routerConfig, numbers);
routerConfig.setStartTime(end);
routerConfig.setEndTime(new Date(end.getTime() + TimeHelper.ONE_DAY));
DailyReport dailyReport = new DailyReport();
dailyReport.setContent("");
dailyReport.setCreationDate(new Date());