服务器列表bug

zhangshanxue 2020-08-29 10:30:00 +08:00
parent cd8ba3fe13
commit 31eedee47e
1 changed files with 39 additions and 22 deletions

View File

@ -15,6 +15,7 @@ import java.io.IOException;
import java.io.PrintWriter;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors;
public class GetServerListController extends HttpServlet {
private final static String _COLLECTION_NAME = "server_info";
@ -42,25 +43,27 @@ public class GetServerListController extends HttpServlet {
String openId = request.getParameter("openId");
String channel = request.getParameter("channel");
String sub_channel = request.getParameter("sub_channel");
String server_version = request.getParameter("server_version");
String plat = request.getParameter("plat");
if (StringUtils.checkIsEmpty(openId) || StringUtils.checkIsEmpty(channel) ||
StringUtils.checkIsEmpty(sub_channel) || StringUtils.checkIsEmpty(plat)) {
StringUtils.checkIsEmpty(sub_channel) || StringUtils.checkIsEmpty(plat) || StringUtils.checkIsEmpty(server_version)) {
response.sendError(400, "parm is wrong");
return;
}
DBObject req = new BasicDBObject();
req.put("channel", channel);
req.put("sub_channel", sub_channel);
req.put("plat", plat);
// DBObject req = new BasicDBObject();
// req.put("channel", channel);
// req.put("sub_channel", sub_channel);
// req.put("plat", plat);
// req.put("server_version", Integer.valueOf(server_version));
List<DBObject> serverList = new ArrayList<>();
long local = System.currentTimeMillis();
if ((local - lastRefreshTime) > 10 * 1000 || serverInfosCache.isEmpty()) {
// long local = System.currentTimeMillis();
// if ((local - lastRefreshTime) > 10 * 1000 || serverInfosCache.isEmpty()) {
serverInfosCache.clear();
lastRefreshTime = local;
// lastRefreshTime = local;
recommend = "";
whiteListCache = BaseGlobal.getInstance().mongoDBPool.findOne(_WHITE_LIST, openId);
List<DBObject> serverInfoList = BaseGlobal.getInstance().mongoDBPool.find(_COLLECTION_NAME, req);
List<DBObject> serverInfoList = BaseGlobal.getInstance().mongoDBPool.findAll(_COLLECTION_NAME);
SortedSet<String> newServerList = new TreeSet<>();
String maxNumServerId = "";
int maxNum = 0;
@ -125,9 +128,23 @@ public class GetServerListController extends HttpServlet {
}
} else {
serverList.addAll(serverInfosCache.values());
}
// } else {
// Set<DBObject> collect = serverInfosCache.values().stream().filter(dbObject -> {
//
// if(dbObject.containsField("channel")&&!dbObject.get("channel").equals(channel) ){
// return false;
// }
// if(dbObject.containsField("sub_channel")&&!dbObject.get("sub_channel").equals(sub_channel)){
// return false;
// } if( dbObject.containsField("plat")&&! dbObject.get("plat").equals(plat)){
// return false;
// } if( dbObject.containsField("server_version")&&!dbObject.get("server_version").equals(server_version)){
// return false;
// }
// return true;
// }).collect(Collectors.toSet());
// serverList.addAll(collect);
// }
//获取我的服务器列表
Map<String, UserRecentLoginInfo> userServerInfoMap = BaseGlobal.getInstance().redisApp.hgetAll(RedisKey.USER_SERVER_INFO, openId, UserRecentLoginInfo.class, -1, false);