小优化
parent
7dbbb96c79
commit
b0595988ad
|
|
@ -335,7 +335,7 @@ public class RedisKey {
|
|||
|
||||
public static final String SERVER_SPLIT_INFO = "SERVER_SPLIT_INFO";// 游戏服跨服分组id缓存
|
||||
|
||||
public static final String SERVER_STATE = "SERVER_STATE";// 服务器状态缓存
|
||||
public static final String SERVER_INFO = "SERVER_INFO";// 服务器信息缓存
|
||||
|
||||
public static final String CROSS_SERVER_GROUP = "CROSS_SERVER_GROUP";// gm跨服分组id缓存
|
||||
|
||||
|
|
|
|||
|
|
@ -1384,6 +1384,17 @@ public class RedisUtil {
|
|||
return result;
|
||||
}
|
||||
|
||||
public <K,T> Map<K,T> getMapValues(String key,Class<K> keyClazz,Class<T> valueClazz){
|
||||
Map<K,T> result = new HashMap<>();
|
||||
Map<Object, Object> entries = redisTemplate.opsForHash().entries(key);
|
||||
for(Map.Entry<Object,Object> item : entries.entrySet()){
|
||||
Object key1 = item.getKey();
|
||||
Object value = item.getValue();
|
||||
result.put(gson.fromJson(gson.toJson(key1),keyClazz),gson.fromJson(value.toString(),valueClazz));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public boolean existsKey(String type,String key){
|
||||
String rkey = getKey(type, key);
|
||||
return redisTemplate.hasKey(rkey);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,155 @@
|
|||
package com.ljsd.jieling.jbean;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Administrator
|
||||
* @date 2015/8/13
|
||||
*/
|
||||
|
||||
public class ServerInfo{
|
||||
private int _id;
|
||||
private String name;
|
||||
private String ip;
|
||||
private String port;
|
||||
private String server_id;
|
||||
private String channel;
|
||||
private String sub_channel;
|
||||
|
||||
/**
|
||||
* -1 服务器准备中
|
||||
* -2 未运营
|
||||
* 0 已关闭
|
||||
* 1 维护
|
||||
* 2 流畅
|
||||
* 3 拥挤
|
||||
* 4 爆满
|
||||
*/
|
||||
private String status;
|
||||
private String plat;
|
||||
private String is_new;
|
||||
private String register_state;
|
||||
private String coreName;
|
||||
private String isWhite;
|
||||
private int server_version;
|
||||
|
||||
public ServerInfo(int _id, String name) {
|
||||
this._id = _id;
|
||||
this.server_id = String.valueOf(_id);
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public ServerInfo() {
|
||||
}
|
||||
|
||||
public int get_id() {
|
||||
return _id;
|
||||
}
|
||||
|
||||
public void set_id(int _id) {
|
||||
this._id = _id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getIp() {
|
||||
return ip;
|
||||
}
|
||||
|
||||
public void setIp(String ip) {
|
||||
this.ip = ip;
|
||||
}
|
||||
|
||||
public String getPort() {
|
||||
return port;
|
||||
}
|
||||
|
||||
public void setPort(String port) {
|
||||
this.port = port;
|
||||
}
|
||||
|
||||
public String getServer_id() {
|
||||
return server_id;
|
||||
}
|
||||
|
||||
public void setServer_id(String server_id) {
|
||||
this.server_id = server_id;
|
||||
}
|
||||
|
||||
public String getChannel() {
|
||||
return channel;
|
||||
}
|
||||
|
||||
public void setChannel(String channel) {
|
||||
this.channel = channel;
|
||||
}
|
||||
|
||||
public String getSub_channel() {
|
||||
return sub_channel;
|
||||
}
|
||||
|
||||
public void setSub_channel(String sub_channel) {
|
||||
this.sub_channel = sub_channel;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public int getStatusInt() {
|
||||
return Integer.parseInt(status);
|
||||
}
|
||||
|
||||
public void setStatus(String status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getPlat() {
|
||||
return plat;
|
||||
}
|
||||
|
||||
public void setPlat(String plat) {
|
||||
this.plat = plat;
|
||||
}
|
||||
|
||||
public String getIs_new() {
|
||||
return is_new==null?"0":is_new;
|
||||
}
|
||||
|
||||
public void setIs_new(String is_new) {
|
||||
this.is_new = is_new;
|
||||
}
|
||||
|
||||
public String getRegister_state() { return register_state==null?"1":register_state; }
|
||||
|
||||
public void setRegister_state(String register_state) { this.register_state = register_state; }
|
||||
|
||||
public String getCoreName() {
|
||||
return coreName;
|
||||
}
|
||||
|
||||
public void setCoreName(String coreName) {
|
||||
this.coreName = coreName;
|
||||
}
|
||||
|
||||
public String getIsWhite() {
|
||||
return isWhite;
|
||||
}
|
||||
|
||||
public void setIsWhite(String isWhite) {
|
||||
this.isWhite = isWhite;
|
||||
}
|
||||
|
||||
public int getServer_version() {
|
||||
return server_version;
|
||||
}
|
||||
|
||||
public void setServer_version(int server_version) {
|
||||
this.server_version = server_version;
|
||||
}
|
||||
}
|
||||
|
|
@ -6,6 +6,7 @@ import com.ljsd.jieling.db.redis.RedisKey;
|
|||
import com.ljsd.jieling.db.redis.RedisUtil;
|
||||
import com.ljsd.jieling.exception.ErrorCode;
|
||||
import com.ljsd.jieling.exception.ErrorCodeException;
|
||||
import com.ljsd.jieling.jbean.ServerInfo;
|
||||
import com.ljsd.jieling.logic.activity.ActivityLogic;
|
||||
import com.ljsd.jieling.logic.activity.ActivityType;
|
||||
import com.ljsd.jieling.logic.activity.IEventHandler;
|
||||
|
|
@ -339,16 +340,16 @@ public class GlobleSystemLogic implements IEventHandler {
|
|||
// 跨服分组id
|
||||
Map<String, Integer> values = RedisUtil.getInstence().getMapValues(RedisKey.SERVER_SPLIT_INFO, "", String.class, Integer.class);
|
||||
// 服务器状态
|
||||
Map<String, String> serverStates = RedisUtil.getInstence().getMapValues(RedisKey.SERVER_STATE, "", String.class, String.class);
|
||||
|
||||
Map<Integer, ServerInfo> serverInfos = RedisUtil.getInstence().getMapValues(RedisKey.SERVER_INFO, Integer.class, ServerInfo.class);
|
||||
ArrayList<String> list = new ArrayList<>();
|
||||
for (Map.Entry<String, Integer> entry : values.entrySet()) {
|
||||
// 获取服务器状态
|
||||
String serverStatesOrDefault = serverStates.getOrDefault(entry.getValue(), "1");
|
||||
ServerInfo info = serverInfos.get(entry.getValue());
|
||||
// "-2"表示未运营,此类服务器不参与分组
|
||||
if (entry.getValue() == group && !"-2".equals(serverStatesOrDefault)){
|
||||
list.add(entry.getKey());
|
||||
if (info == null || "-2".equals(info.getStatus()) || entry.getValue() != group){
|
||||
continue;
|
||||
}
|
||||
list.add(entry.getKey());
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -179,7 +179,6 @@ class SheJiActivity extends AbstractActivity {
|
|||
if (integerListMap == null) {
|
||||
return;
|
||||
}
|
||||
SGodSacrificeSetting sGodSacrificeSetting = STableManager.getConfig(SGodSacrificeSetting.class).get(1);
|
||||
InnerResult rewardMap = getRewardMap(1);
|
||||
Map<Integer, Integer> rank2miss = rewardMap.getRank2miss();
|
||||
int maxRank = rewardMap.getMaxRamk();
|
||||
|
|
@ -190,7 +189,6 @@ class SheJiActivity extends AbstractActivity {
|
|||
int rank = 1;
|
||||
int nowTime = (int) (TimeUtils.now() / 1000);
|
||||
//特殊分值 2500
|
||||
//int specailScore = SSpecialConfig.getIntegerValue(SSpecialConfig.ADVENTURE_RANKINGSHOWNUM);
|
||||
for (ZSetOperations.TypedTuple<String> item : rankInfo) {
|
||||
|
||||
String value = item.getValue();
|
||||
|
|
|
|||
Loading…
Reference in New Issue