/** 取得首页Body信息 */ public String getAllHotNewApp( String myTrack, List<Map<String, String>> appfavorite, List<Map<String, String>> userOrders, long userId) { Map<String, Object> rtn = new HashMap<String, Object>(); // rtn.putAll(getAllHotNewApp()); Map<String, Object> allHotNewApp = getAllHotNewApp(); rtn.putAll(allHotNewApp); if (userId > 0) { List<Map<String, String>> appList = getAllApps(); rtn.put("myTrack", getMyTrack(myTrack.split(","), appList)); } if (userId > 0) { calculationPicHref(appfavorite, "appPic"); rtn.put("appfavorite", appfavorite); } if (userId > 0) { List<Map<String, String>> appList = getAllApps(); List<Map<String, String>> orderApps = getUserOrders(appList, userOrders); if (orderApps != null && orderApps.size() > 7) { orderApps = orderApps.subList(0, 7); } rtn.put("userOrderApps", orderApps); } rtn.put("rtnCode", "1"); String rtnJson = JsonUtil.convertObject2Json(rtn); return rtnJson; }
/** 取得所有应用 */ public String getAllApp() { List<Map<String, String>> appList = getAllApps(); List<Map<String, String>> hotkeywords = getHotKeywords(appList); if (hotkeywords.size() > 5) { hotkeywords = hotkeywords.subList(0, 5); } Map<String, Object> rtnmap = new HashMap<String, Object>(); rtnmap.put("rtnCode", "1"); rtnmap.put("hotkeywords", hotkeywords); rtnmap.put("rows", appList); String rtnJson = JsonUtil.convertObject2Json(rtnmap); return rtnJson; }
/** 取得首页头部 */ @SuppressWarnings("unchecked") public synchronized String getHomeTops(String baseDir, List<Map<String, String>> userOrders) { String rtnJson = ""; rtnJson = SpringContextHelper.instance.getOscache().get(HOME_TOP_CACHE); if (!StringUtil.isEmpty(rtnJson)) { return rtnJson; } // 取得首页广告数据 String adverstr = getHomeAdvertising(); // 取得首页二级菜单 String secmenustr = getHomeSecMenu(); // 取得已经上线的单独应用 String singlestr = getSingleApp(); // 取得已经上线的组合应用 String mutistr = getMutiApp(); // 取得快报 String expressstr = getHomeExpress(); Map<String, Object> secmenuMp = JsonUtil.convertJson2Object(secmenustr, Map.class); List<Map<String, String>> secmenuLs = (List<Map<String, String>>) secmenuMp.get("rows"); Map<String, Object> singleMp = JsonUtil.convertJson2Object(singlestr, Map.class); List<Map<String, String>> singleLs = (List<Map<String, String>>) singleMp.get("rows"); Map<String, Object> mutiMp = JsonUtil.convertJson2Object(mutistr, Map.class); List<Map<String, String>> mutiLs = (List<Map<String, String>>) mutiMp.get("rows"); // 保存所有应用信息 List<Map<String, String>> appList = new ArrayList<Map<String, String>>(); if (singleLs != null) appList.addAll(singleLs); if (mutiLs != null) appList.addAll(mutiLs); Map<String, Object> adverMp = JsonUtil.convertJson2Object(adverstr, Map.class); List<Map<String, String>> adverLs = (List<Map<String, String>>) adverMp.get("rows"); calculateAdverLs(adverLs, appList); cacheAllApps(baseDir, singleLs, mutiLs, adverLs); if (appList.size() > 0) SpringContextHelper.instance.getOscache().put(HOME_APPS_CACHE, appList); // 保存所有应用信息.结束 Map<String, Object> expressMp = JsonUtil.convertJson2Object(expressstr, Map.class); List<Map<String, String>> expressLs = (List<Map<String, String>>) expressMp.get("rows"); // calculateAdverLs(adverLs,appList); // //从cms下载所有图片在本地 // List<String> picUrls = calculatePics(adverLs,appList); // downLoadPic.downloadPicFromCms(baseDir, picUrls); // List<Map<String,Map<String,String>>> picUrls = calculatePics1(adverLs,appList); // downLoadPic.downloadPicFromCms(baseDir, picUrls,this); Map<String, List<Map<String, String>>> secmenus = splitSecmenus(secmenuLs); Map<String, List<Map<String, Object>>> menus = calculatMenus(secmenus, singleLs, mutiLs, userOrders); if (expressLs != null && expressLs.size() > 5) { expressLs = expressLs.subList(0, 5); } List<Map<String, String>> teacherSubMenu = getsubMenu(appList, 1); List<Map<String, String>> studentSubMenu = getsubMenu(appList, 2); List<Map<String, String>> activitSubMenu = getsubMenu(appList, 3); Map<String, List<Map<String, String>>> subMenuMp = new HashMap<String, List<Map<String, String>>>(); subMenuMp.put("teacher", teacherSubMenu); subMenuMp.put("father", studentSubMenu); subMenuMp.put("actived", activitSubMenu); Map<String, Object> homeTops = new HashMap<String, Object>(); homeTops.put("secmenus", menus); homeTops.put("subMenu", subMenuMp); homeTops.put("adverpics", adverLs); homeTops.put("expresses", expressLs); homeTops.put("rtnCode", "1"); rtnJson = JsonUtil.convertObject2Json(homeTops); if (null == userOrders || userOrders.size() == 0) { if (!StringUtil.isEmpty(rtnJson)) SpringContextHelper.instance.getOscache().put(HOME_TOP_CACHE, rtnJson); } return rtnJson; }