Example #1
0
  public String convert(List<Map<String, String>> datas, String uid) {
    Action cmsaction = ControlFactory.getControl().getAction(CMSACTION);
    if (cmsaction != null) {
      Output cmsoutput = cmsaction.getOutput(uid);
      List<Parameter> parameters = cmsoutput.getParameters();
      String convertor = cmsoutput.getConvertor();
      String method = cmsoutput.getMethod();
      if (StringUtil.isEmpty(convertor)) {
        convertor = "com.ai.eduportal.convertor.CmsResultConvert";
      }
      if (StringUtil.isEmpty(method)) {
        log.error("{} convert to json has't config the convert method.", null, uid);

        return null;
      }

      Class<?>[] paramcls = new Class<?>[] {List.class, List.class};
      Object[] paramvals = new Object[] {datas, parameters};

      return ClassUtil.invokMethod(String.class, convertor, method, paramcls, paramvals);
    } else {
      log.error("{} convert to json has't get the action:{}", null, uid, CMSACTION);
    }
    return null;
  }
Example #2
0
 private void calculateAdverMp(Map<String, String> adverMp, List<Map<String, String>> appList) {
   String appId = adverMp.get("appID");
   String isMutiApp = getPropVal(appId, appList, "isMutiApp");
   String nodeUid = getPropVal(appId, appList, "nodeUid");
   String apphref = getPropVal(appId, appList, "apphref");
   adverMp.put("isMutiApp", StringUtil.trim(isMutiApp));
   adverMp.put("nodeUid", StringUtil.trim(nodeUid));
   adverMp.put("apphref", StringUtil.trim(apphref));
 }
Example #3
0
 private String getPropVal(String advAppId, List<Map<String, String>> appList, String propName) {
   if (appList != null) {
     for (Map<String, String> appMp : appList) {
       String appId = appMp.get("appID");
       if (StringUtil.trim(appId).equals(StringUtil.trim(advAppId))) {
         return appMp.get(propName);
       }
     }
   }
   return null;
 }
Example #4
0
  private List<Map<String, String>> calculatHotNewApps(String key) {
    List<Map<String, String>> appList = getAllApps();

    List<Map<String, String>> hotnewApps = new ArrayList<Map<String, String>>();
    if (appList != null) {
      for (Map<String, String> app : appList) {
        String hotNew = app.get(key);
        if (!StringUtil.isEmpty(hotNew) && StringUtil.str2Int(hotNew) == 1) {
          hotnewApps.add(app);
        }
      }
    }
    return hotnewApps;
  }
Example #5
0
 private int getProdMonth(String offerCode, Map<String, String> map) {
   String threeOfferCode = StringUtil.trim(map.get("threeOfferCode"));
   String sixOfferCode = StringUtil.trim(map.get("sixOfferCode"));
   String twelveOfferCode = StringUtil.trim(map.get("twelveOfferCode"));
   offerCode = StringUtil.trim(offerCode);
   if (threeOfferCode.equals(offerCode)) {
     return 3;
   } else if (sixOfferCode.equals(offerCode)) {
     return 6;
   } else if (twelveOfferCode.equals(offerCode)) {
     return 12;
   } else {
     return 0;
   }
 }
Example #6
0
 private boolean isStudent(String domain) {
   if (!StringUtil.isEmpty(domain)
       && (domain.indexOf("1") > -1 && domain.indexOf("3") > -1)) { // 家长和学生
     return true;
   }
   return false;
 }
Example #7
0
 private List<Map<String, String>> getMenuApps(
     String menuId, List<Map<String, String>> apps, int type) {
   List<Map<String, String>> menuapps = new ArrayList<Map<String, String>>();
   for (Map<String, String> app : apps) {
     if (StringUtil.trim(menuId).equals(StringUtil.trim(app.get("secMenu")))) { // 判断是否是指定二级菜单下
       if (type == 1 && isTeacher(StringUtil.trim(app.get("domain")))) {
         menuapps.add(app);
       } else if (type == 2 && isStudent(StringUtil.trim(app.get("domain")))) {
         menuapps.add(app);
       } else if (type == 3 && isActived(StringUtil.trim(app.get("isActive")))) {
         menuapps.add(app);
       }
     }
   }
   return menuapps;
 }
Example #8
0
 public boolean checkServiceUrl(String url) {
   RemoteHttpCallerI caller = new RemoteHttpCaller(httpClient, url);
   String respStr = caller.getResponse1("");
   if (!StringUtil.isEmpty(respStr)) {
     return true;
   }
   return false;
 }
Example #9
0
 private List<Map<String, String>> getsubMenu(List<Map<String, String>> appList, int type) {
   List<Map<String, String>> rtnls = new ArrayList<Map<String, String>>();
   for (Map<String, String> app : appList) {
     String commonUse = StringUtil.trim(app.get("commonUse"));
     if (commonUse.indexOf(String.valueOf(type)) > -1) rtnls.add(app);
   }
   return rtnls;
 }
Example #10
0
  private void calculationPicHref(Map<String, String> data, String picName) {
    String preHref = data.get(picName);
    if (!StringUtil.isEmpty(preHref)) {
      String picType = data.get(picName + PICTYPESUB);
      if (!StringUtil.isEmpty(picType)) {
        if (preHref.startsWith(".//")) {
          preHref = preHref.substring(3);
        } else if (preHref.startsWith("./")) {
          preHref = preHref.substring(2);
        } else if (preHref.startsWith("/")) {
          preHref = preHref.substring(1);
        }

        data.put(picName, preHref + "/" + picName + picType);
      }
    }
  }
Example #11
0
 private List<Map<String, String>> getHotKeywords(List<Map<String, String>> appList) {
   List<Map<String, String>> keywords = new ArrayList<Map<String, String>>();
   if (appList != null) {
     for (Map<String, String> appMap : appList) {
       int isKeywords = StringUtil.str2Int(appMap.get("isKeywords"), 2);
       if (isKeywords == 1) {
         keywords.add(appMap);
       }
     }
   }
   return keywords;
 }
Example #12
0
  protected List<String> calculatePics(List<Map<String, String>> picList) {
    List<String> picurls = new ArrayList<String>();
    if (picList != null && picList.size() > 0) {
      for (Map<String, String> picMp : picList) {
        String appPic = picMp.get("appPic");
        String appMxPic = picMp.get("appMxPic");
        String appDescPic = picMp.get("appDescPic");
        String adverPic = picMp.get("adverPic");
        String priceTable = picMp.get("priceTable");
        String appdown = picMp.get("appdown");
        //				System.out.println("calculatePics:"+appdown);
        if (!StringUtil.isEmpty(adverPic)) {
          picurls.add(adverPic);
        }
        if (!StringUtil.isEmpty(appPic)) {
          picurls.add(appPic);
        }
        if (!StringUtil.isEmpty(appMxPic)) {
          picurls.add(appMxPic);
        }
        if (!StringUtil.isEmpty(appDescPic)) {
          picurls.add(appDescPic);
        }
        if (!StringUtil.isEmpty(priceTable)) {
          picurls.add(priceTable);
        }
        if (!StringUtil.isEmpty(appdown)) {
          picurls.add(appdown);
        }
      }
    }

    return picurls;
  }
Example #13
0
  /** 取得应用详细信息 */
  @SuppressWarnings("unchecked")
  public Map<String, Object> getAppDetailMp(String nodeUid) {
    String appDetail = getAppDetail(nodeUid);

    Map<String, Object> appDetailMp = JsonUtil.convertJson2Object(appDetail, Map.class);
    List<Map<String, String>> appDetailLs = (List<Map<String, String>>) appDetailMp.get("rows");

    Map<String, Object> rtnMap = new HashMap<String, Object>();
    if (appDetailLs != null && appDetailLs.size() > 0) {
      Map<String, String> appinfos = appDetailLs.get(0);

      // 应用本身相关信息
      rtnMap.putAll(appinfos);

      // 联系方式
      String contactNodeId = appinfos.get("contact");
      String contactJson = getNodeByID(contactNodeId, "contact");
      Map<String, Object> contactMp = JsonUtil.convertJson2Object(contactJson, Map.class);
      List<Map<String, String>> contactLs = (List<Map<String, String>>) contactMp.get("rows");
      if (contactLs != null && contactLs.size() > 0) {
        rtnMap.put("contact", contactLs.get(0));
      }

      // 推荐组合
      List<Map<String, String>> cpackages = new ArrayList<Map<String, String>>();
      String recmdpckgNodeId = appinfos.get("recmdpckg");
      if (!StringUtil.isEmpty(recmdpckgNodeId)) {
        String[] appIds = recmdpckgNodeId.split(",");
        for (int i = 0; i < appIds.length; i++) {
          String recmdpckgJson = getNodeByID(appIds[i], "recmdpckg");
          Map<String, Object> recmdpckgMp = JsonUtil.convertJson2Object(recmdpckgJson, Map.class);
          List<Map<String, String>> recmdpckgLs =
              (List<Map<String, String>>) recmdpckgMp.get("rows");
          calculationPicHref(recmdpckgLs, "appPic");
          if (recmdpckgLs != null && recmdpckgLs.size() > 0) {
            cpackages.add(recmdpckgLs.get(0));
          }
        }
      }
      rtnMap.put("cpackage", cpackages);
    }

    return rtnMap;
  }
Example #14
0
 private boolean isActived(String isActive) {
   if (!StringUtil.isEmpty(isActive) && StringUtil.str2Int(isActive) == 1) { // 参加活动
     return true;
   }
   return false;
 }
Example #15
0
 private boolean isTeacher(String domain) {
   if (!StringUtil.isEmpty(domain) && domain.indexOf("2") > -1) { // 老师
     return true;
   }
   return false;
 }
Example #16
0
  /** 取得首页头部 */
  @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;
  }