Example #1
0
 /**
  * 该方法是usersToMapSortedConvertor(List<User> users,String client_id)方法的改良版,
  * 核心作用相同,除了有按行业排序,该方法多了一层按距离排序。现根据行业排序,然后根据距离排序
  *
  * @param users
  * @return notice:在推荐的同行中如果有人没有location记录,则为其设置一个默认坐标
  */
 public Map<String, Object> usersToMapSortedWithDistanceConvertor(List<User> users, User me) {
   List<Map<String, Object>> usersmsg = new ArrayList<Map<String, Object>>();
   for (User u : users) {
     Map<String, Object> msg = new HashMap<String, Object>();
     msg.put(
         "user",
         userMapBuilder(
             u,
             me.getClient_id(),
             conditionGenetator("hasFriend", "hasRoom", "hasDistance") /*true,true,true*/));
     usersmsg.add(msg);
   }
   // 排序操作,详细请看 SortUtil 类
   usersmsg = SortUtil.sortByLabelName(usersmsg, me.getLabelnames());
   if (locationService.findLocationByUser(me) != null)
     usersmsg = SortUtil.sortByDistance(usersmsg);
   return generateResult(usersmsg);
 }
Example #2
0
 /**
  * 该方法是usersToMapConvertor(List<User> users,String client_id)方法的改良版, 核心作用相同,该方法多了一层按标签排序
  *
  * @param users
  * @return 2015-12-18:暂时去掉标签排序
  */
 public Map<String, Object> usersToMapSortedConvertor(List<User> users, User me) {
   List<Map<String, Object>> usersmsg = new ArrayList<Map<String, Object>>();
   for (User u : users) {
     Map<String, Object> msg = new HashMap<String, Object>();
     msg.put(
         "user",
         userMapBuilder(
             u, me.getClient_id(), conditionGenetator("hasDistance") /*false,false,true*/));
     usersmsg.add(msg);
     // 比较当前用户哪些标签是根据使用者的标签被推出来的
   }
   // 排序操作,详细请看 SortUtil 类
   System.out.println("你的标签:" + me.getLabelnames());
   usersmsg = SortUtil.sortByLabelName(usersmsg, me.getLabelnames());
   return generateResult(usersmsg);
 }
Example #3
0
 /**
  * 和usersToMapConvertor方法功能一样,多一个按照距离排序的功能
  *
  * @param user
  * @param client_id
  * @return
  */
 public Map<String, Object> usersToMapSortByDistanceConvertor(List<User> users, String client_id) {
   List<Map<String, Object>> usersmsg = new ArrayList<Map<String, Object>>();
   for (User u : users) {
     Map<String, Object> msg = new HashMap<String, Object>();
     msg.put(
         "user",
         userMapBuilder(
             u,
             client_id,
             conditionGenetator("hasFriend", "hasRoom", "hasDistance") /*true,true,true */));
     usersmsg.add(msg);
   }
   // 根据距离排序
   usersmsg = SortUtil.sortByDistance(usersmsg);
   return generateResult(usersmsg);
 }