/** 供缓存使用 */ private void cacheCenterEverydayCameCustomers(String yearMonthString) { List<Fzx> centers = fzxDao.getAllValid(true); for (Fzx center : centers) { Map<String, Map<String, BaseVo>> result = new TreeMap<String, Map<String, BaseVo>>(); List<String> days = DateUtils.getMonthDays(DateUtils.parseDate("yyyyMM", yearMonthString)); for (String day : days) { result.put(day, new HashMap<String, BaseVo>()); result.get(day).put(TmkUtilsBaseVo.CENTER_EVERYDAY_CAME_CUSTOMERS, new BaseVo()); result.get(day).put(TmkUtilsBaseVo.CENTER_TOTAL, new BaseVo()); } Integer tmpTotal = 0; List<BaseVo> vs = tmkUtilsDao.getCenterComeInThisMonth(center.getFzxDto(), yearMonthString); Integer monthTarget = tmkUtilsDao.getThisCenterCameCustomerTargetInThisMonth( center.getFzxDto(), yearMonthString); BaseVo target = new BaseVo(); target.setSValue(monthTarget); for (BaseVo v : vs) { BaseVo todayTotal = new BaseVo(); if (result.containsKey(v.getSTime())) { todayTotal.setSValue(tmpTotal + v.getSValue()); result.get(v.getSTime()).put(TmkUtilsBaseVo.CENTER_EVERYDAY_CAME_CUSTOMERS, v); } else { todayTotal.setSValue(tmpTotal); } result.get(v.getSTime()).put(TmkUtilsBaseVo.CENTER_TOTAL, todayTotal); result.get(v.getSTime()).put(TmkUtilsBaseVo.CENTER_TARGET, target); tmpTotal = todayTotal.getSValue(); } Integer maxTotal = 0; for (Map.Entry<String, Map<String, BaseVo>> r : result.entrySet()) { if (r.getValue().get(TmkUtilsBaseVo.CENTER_TOTAL).getSValue() <= maxTotal) { r.getValue().get(TmkUtilsBaseVo.CENTER_TOTAL).setSValue(maxTotal); } else { maxTotal = r.getValue().get(TmkUtilsBaseVo.CENTER_TOTAL).getSValue(); } } putObjectInCache( tmkUtilsListCache, center.getId(), TmkUtilsBaseVo.CENTER_EVERYDAY_CAME_CUSTOMERS, result); } }
@SuppressWarnings("unchecked") public Map<String, Map<String, BaseVo>> getThisCenterEverydayCameCustomers(FzxDto fzx) { String yearMonthString = DateUtils.getCurYearMonthString(); Map<String, Map<String, BaseVo>> result = new TreeMap<String, Map<String, BaseVo>>(); List<String> days = DateUtils.getMonthDays(DateUtils.parseDate("yyyyMM", yearMonthString)); for (String day : days) { result.put(day, new HashMap<String, BaseVo>()); result.get(day).put(TmkUtilsBaseVo.CENTER_EVERYDAY_CAME_CUSTOMERS, new BaseVo()); result.get(day).put(TmkUtilsBaseVo.CENTER_TOTAL, new BaseVo()); } Integer tmpTotal = 0; List<BaseVo> vs = tmkUtilsDao.getCenterComeInThisMonth(fzx, yearMonthString); Integer monthTarget = tmkUtilsDao.getThisCenterCameCustomerTargetInThisMonth(fzx, yearMonthString); BaseVo target = new BaseVo(); target.setSValue(monthTarget); for (BaseVo v : vs) { BaseVo todayTotal = new BaseVo(); if (result.containsKey(v.getSTime())) { todayTotal.setSValue(tmpTotal + v.getSValue()); result.get(v.getSTime()).put(TmkUtilsBaseVo.CENTER_EVERYDAY_CAME_CUSTOMERS, v); } else { todayTotal.setSValue(tmpTotal); } result.get(v.getSTime()).put(TmkUtilsBaseVo.CENTER_TOTAL, todayTotal); result.get(v.getSTime()).put(TmkUtilsBaseVo.CENTER_TARGET, target); tmpTotal = todayTotal.getSValue(); } Integer maxTotal = 0; for (Map.Entry<String, Map<String, BaseVo>> r : result.entrySet()) { if (r.getValue().get(TmkUtilsBaseVo.CENTER_TOTAL).getSValue() <= maxTotal) { r.getValue().get(TmkUtilsBaseVo.CENTER_TOTAL).setSValue(maxTotal); } else { maxTotal = r.getValue().get(TmkUtilsBaseVo.CENTER_TOTAL).getSValue(); } } return result; // return (Map<String, Map<String, BaseVo>>) getObjectFromCache( // tmkUtilsListCache, fzx.getZdbm(), // TmkUtilsBaseVo.CENTER_EVERYDAY_CAME_CUSTOMERS); }