generated from root/miduo_server
服务器列表添加跨服id修改功能
parent
b239eb0e11
commit
adad013eb6
|
@ -60,6 +60,10 @@ public class LoginController {
|
|||
* @param content
|
||||
*/
|
||||
public static void addQueue(String content) {
|
||||
// 只存储最新的十条数据
|
||||
if (queue.size() >= 10){
|
||||
queue.poll();
|
||||
}
|
||||
queue.offer(content);
|
||||
}
|
||||
|
||||
|
@ -137,6 +141,9 @@ public class LoginController {
|
|||
}
|
||||
}
|
||||
|
||||
// 服务器数据同步
|
||||
ServerInfoController.oneRunServerGroup();
|
||||
|
||||
// 登陆成功,并添加session
|
||||
if (verify) {
|
||||
session.setAttribute(WebSecurityConfig.SESSION_KEY, userName);
|
||||
|
|
|
@ -167,6 +167,14 @@ public class ServerInfoController {
|
|||
int payPort = ints.length>1?ints[1]:-1;
|
||||
vo.setPayPortState(payPort);
|
||||
}
|
||||
|
||||
// 当前的服务器跨服分组
|
||||
Integer value = RedisUtil.getInstence().getMapValue(RedisUserKey.SERVER_SPLIT_INFO, "", serverInfo.getServer_id(), Integer.class, -1);
|
||||
if (value == null){
|
||||
value = 0;
|
||||
}
|
||||
vo.setOldGroupId(value);
|
||||
|
||||
return vo;
|
||||
}
|
||||
|
||||
|
@ -489,4 +497,29 @@ public class ServerInfoController {
|
|||
}
|
||||
return list.contains(port);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取跨服服务器分组id
|
||||
* @param serverId
|
||||
* @return
|
||||
*/
|
||||
public static int getServerGroupId(String serverId){
|
||||
Integer groupId = RedisUtil.getInstence().getMapValue(RedisUserKey.CROSS_SERVER_GROUP, "", serverId, Integer.class, -1);
|
||||
if (groupId == null){
|
||||
groupId = 0;
|
||||
}
|
||||
return groupId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 只会执行一次,同步游戏服跨服分组到gm,之后会以gm的为准
|
||||
*/
|
||||
public static void oneRunServerGroup(){
|
||||
Map<String, Integer> map = RedisUtil.getInstence().getMap(RedisUserKey.CROSS_SERVER_GROUP + ":", Integer.class, -1);
|
||||
if (map == null || map.isEmpty()){
|
||||
Map<String, Integer> map1 = RedisUtil.getInstence().getMap(RedisUserKey.SERVER_SPLIT_INFO + ":", Integer.class, -1);
|
||||
RedisUtil.getInstence().putMap(RedisUserKey.CROSS_SERVER_GROUP,"",map1);
|
||||
LOGGER.info("同步跨服id完成");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,15 +30,17 @@ public class ServerInfoDaoImpl implements ServerInfoDao {
|
|||
@Override
|
||||
public List<ServerInfo> getAllServerInfo() throws Exception {
|
||||
MongoTemplate mongoTemplate = connect.getMongoTemplete(dbName);
|
||||
Query query = new Query();
|
||||
return mongoTemplate.find(query, ServerInfo.class);
|
||||
List<ServerInfo> serverInfos = mongoTemplate.find(new Query(), ServerInfo.class);
|
||||
Map<String, Integer> splitMap = RedisUtil.getInstence().getMap(RedisUserKey.CROSS_SERVER_GROUP, Integer.class, -1);
|
||||
for (ServerInfo info : serverInfos) {
|
||||
info.setCrossGroupId(splitMap.getOrDefault(info.getServer_id(),0));
|
||||
}
|
||||
return serverInfos;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, ServerInfo> getAllServerMap() throws Exception {
|
||||
MongoTemplate mongoTemplate = connect.getMongoTemplete(dbName);
|
||||
Query query = new Query();
|
||||
List<ServerInfo> serverInfos = mongoTemplate.find(query, ServerInfo.class);
|
||||
List<ServerInfo> serverInfos = getAllServerInfo();
|
||||
HashMap<String, ServerInfo> map = new HashMap<>();
|
||||
for (ServerInfo info : serverInfos) {
|
||||
map.put(info.getServer_id(),info);
|
||||
|
@ -56,9 +58,11 @@ public class ServerInfoDaoImpl implements ServerInfoDao {
|
|||
@Override
|
||||
public ServerInfo getServerinfo(String serverId) throws Exception {
|
||||
MongoTemplate mongoTemplate = connect.getMongoTemplete(dbName);
|
||||
Query query = new Query();
|
||||
query.addCriteria(Criteria.where("server_id").is(String.valueOf(serverId)));
|
||||
return mongoTemplate.findOne(query, ServerInfo.class);
|
||||
Query query = new Query(Criteria.where("server_id").is(String.valueOf(serverId)));
|
||||
ServerInfo serverInfo = mongoTemplate.findOne(query, ServerInfo.class);
|
||||
Map<String, Integer> splitMap = RedisUtil.getInstence().getMap(RedisUserKey.CROSS_SERVER_GROUP, Integer.class, -1);
|
||||
serverInfo.setCrossGroupId(splitMap.getOrDefault(serverId,0));
|
||||
return serverInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -81,15 +85,16 @@ public class ServerInfoDaoImpl implements ServerInfoDao {
|
|||
|
||||
@Override
|
||||
public void updateServerInfo(String server_id, int status,int isWhite,int is_new,String name,String register_state) throws Exception {
|
||||
Update update = new Update();
|
||||
update.set("name",name);
|
||||
update.set("status",String.valueOf(status));
|
||||
update.set("isWhite",String.valueOf(isWhite));
|
||||
update.set("is_new",String.valueOf(is_new));
|
||||
update.set("register_state",register_state);
|
||||
MongoTemplate mongoTemplate = connect.getMongoTemplete(dbName);
|
||||
Query query = new Query(Criteria.where("server_id").is(String.valueOf(server_id)));
|
||||
mongoTemplate.updateMulti(query, update, ServerInfo.class);
|
||||
// 不用这个方法了
|
||||
// Update update = new Update();
|
||||
// update.set("name",name);
|
||||
// update.set("status",String.valueOf(status));
|
||||
// update.set("isWhite",String.valueOf(isWhite));
|
||||
// update.set("is_new",String.valueOf(is_new));
|
||||
// update.set("register_state",register_state);
|
||||
// MongoTemplate mongoTemplate = connect.getMongoTemplete(dbName);
|
||||
// Query query = new Query(Criteria.where("server_id").is(String.valueOf(server_id)));
|
||||
// mongoTemplate.updateMulti(query, update, ServerInfo.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -116,23 +121,20 @@ public class ServerInfoDaoImpl implements ServerInfoDao {
|
|||
if (serverInfo.getCoreName() != null && !"".equals(serverInfo.getCoreName())){
|
||||
update.set("coreName",serverInfo.getCoreName());
|
||||
}
|
||||
|
||||
// 跨服分组修改
|
||||
RedisUtil.getInstence().putMapEntry(RedisUserKey.CROSS_SERVER_GROUP,"",serverInfo.getServer_id(),serverInfo.getCrossGroupId(),-1);
|
||||
|
||||
MongoTemplate mongoTemplate = connect.getMongoTemplete(dbName);
|
||||
Query query = new Query(Criteria.where("server_id").is(serverInfo.getServer_id()));
|
||||
mongoTemplate.updateMulti(query, update, ServerInfo.class);
|
||||
}
|
||||
|
||||
public void updateServerInfoNew(String server_id, String is_new) throws Exception {
|
||||
Update update = new Update();
|
||||
update.set("is_new",is_new);
|
||||
MongoTemplate mongoTemplate = connect.getMongoTemplete(dbName);
|
||||
Query query = new Query(Criteria.where("server_id").is(String.valueOf(server_id)));
|
||||
mongoTemplate.updateMulti(query, update, ServerInfo.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addServerInfo(ServerInfo serverInfo) throws Exception {
|
||||
MongoTemplate mongoTemplate = connect.getMongoTemplete(dbName);
|
||||
mongoTemplate.insert(serverInfo, "server_info"); //有则更新,没有则新增
|
||||
//有则更新,没有则新增
|
||||
mongoTemplate.insert(serverInfo, "server_info");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -77,6 +77,12 @@ public class ServerInfo implements Comparable,Cloneable {
|
|||
@Field(value = "open_time")
|
||||
private String open_time;
|
||||
|
||||
/**
|
||||
* 跨服分组id,存在redis里,不放mongo中
|
||||
*/
|
||||
@Transient
|
||||
private int crossGroupId;
|
||||
|
||||
/**
|
||||
* 不入库,批量添加服务器时使用
|
||||
*/
|
||||
|
@ -224,6 +230,14 @@ public class ServerInfo implements Comparable,Cloneable {
|
|||
this.count = count;
|
||||
}
|
||||
|
||||
public int getCrossGroupId() {
|
||||
return crossGroupId;
|
||||
}
|
||||
|
||||
public void setCrossGroupId(int crossGroupId) {
|
||||
this.crossGroupId = crossGroupId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ServerInfo{" +
|
||||
|
@ -240,6 +254,11 @@ public class ServerInfo implements Comparable,Cloneable {
|
|||
", register_state='" + register_state + '\'' +
|
||||
", coreName='" + coreName + '\'' +
|
||||
", isWhite='" + isWhite + '\'' +
|
||||
", server_version=" + server_version +
|
||||
", open_type='" + open_type + '\'' +
|
||||
", open_time='" + open_time + '\'' +
|
||||
", crossGroupId=" + crossGroupId +
|
||||
", count=" + count +
|
||||
'}';
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.jmfy.model.vo;
|
||||
|
||||
import com.jmfy.controller.ServerInfoController;
|
||||
import com.jmfy.model.ServerInfo;
|
||||
|
||||
public class ServerInfoVo extends ServerInfo {
|
||||
|
@ -41,6 +42,11 @@ public class ServerInfoVo extends ServerInfo {
|
|||
*/
|
||||
private int payPortState = -1;
|
||||
|
||||
/**
|
||||
* 实时的跨服分组id
|
||||
*/
|
||||
private int oldGroupId;
|
||||
|
||||
public ServerInfoVo(){
|
||||
|
||||
}
|
||||
|
@ -59,6 +65,15 @@ public class ServerInfoVo extends ServerInfo {
|
|||
this.setCoreName(serverInfo.getCoreName());
|
||||
this.setIsWhite(serverInfo.getIsWhite());
|
||||
this.setServer_version(serverInfo.getServer_version());
|
||||
this.setCrossGroupId(ServerInfoController.getServerGroupId(getServer_id()));
|
||||
}
|
||||
|
||||
public int getOldGroupId() {
|
||||
return oldGroupId;
|
||||
}
|
||||
|
||||
public void setOldGroupId(int oldGroupId) {
|
||||
this.oldGroupId = oldGroupId;
|
||||
}
|
||||
|
||||
public String getIpAndPort() {
|
||||
|
@ -133,6 +148,10 @@ public class ServerInfoVo extends ServerInfo {
|
|||
this.version = version;
|
||||
}
|
||||
|
||||
public String getGroupShow(){
|
||||
return getCrossGroupId()+"("+getOldGroupId()+")";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ServerInfoVo{" +
|
||||
|
|
|
@ -31,6 +31,10 @@ public class RedisUserKey {
|
|||
public final static String C_PAYORDER_MAP = "C_PAYORDER_MAP";
|
||||
|
||||
public static final String AUTO_START_SERVER_SETTING= "AUTO_START_SERVER_SETTING";
|
||||
|
||||
public static final String SERVER_SPLIT_INFO = "SERVER_SPLIT_INFO";//游戏服跨服分组,实时生效,gm不要修改这个key参数
|
||||
|
||||
public static final String CROSS_SERVER_GROUP = "CROSS_SERVER_GROUP";//gm跨服分组,每周一重新分组生效
|
||||
/**
|
||||
* 在线人数 updata/min
|
||||
*/
|
||||
|
@ -42,9 +46,9 @@ public class RedisUserKey {
|
|||
|
||||
public static String getKey(String type, String key, int serverId) {
|
||||
if (serverId!=0) {
|
||||
return serverId + Delimiter_colon + type + Delimiter_colon + String.valueOf(key);
|
||||
return serverId + Delimiter_colon + type + Delimiter_colon + key;
|
||||
}
|
||||
return type + Delimiter_colon + String.valueOf(key);
|
||||
return type + Delimiter_colon + key;
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -249,17 +249,14 @@ public class RedisUtil {
|
|||
* @param key
|
||||
* @param value
|
||||
*/
|
||||
public <T> void putMap(String type, String key, Map<String, T> value, int expireTime) {
|
||||
public <T> void putMap(String type, String key, Map<String, T> value) {
|
||||
try {
|
||||
Map<String, String> map = new HashMap<>();
|
||||
for (Map.Entry<String, T> entry : value.entrySet()) {
|
||||
String valueStr = gson.toJson(entry.getValue());
|
||||
map.put(entry.getKey(), valueStr);
|
||||
}
|
||||
redisObjectTemplate.opsForHash().putAll(type + key, map);
|
||||
// if (expireTime > 0) {
|
||||
// redisObjectTemplate.expire(getKey(type, key), expireTime, TimeUnit.SECONDS);
|
||||
// }
|
||||
redisObjectTemplate.opsForHash().putAll(type + RedisUserKey.Delimiter_colon + key, map);
|
||||
} catch (RedisConnectionFailureException e) {
|
||||
e.printStackTrace();
|
||||
LOGGER.error("------------------Redis 连接失败---------------msg={}", e);
|
||||
|
|
|
@ -70,6 +70,7 @@
|
|||
<th width="200">服务器名字</th>
|
||||
<th width="100">渠道</th>
|
||||
<th width="200">开服时间</th>
|
||||
<th width="100">跨服分组id(当前)</th>
|
||||
<th width="120">服务器状态</th>
|
||||
<th width="100">新服推荐</th>
|
||||
<th width="100">版本号</th>
|
||||
|
@ -87,6 +88,7 @@
|
|||
<td th:text="${obj.getName()}" style="text-align: center;"></td>
|
||||
<td th:text="${obj.getChannel()}" style="text-align: center;"></td>
|
||||
<td th:text="${obj.getOpenTime()}" style="text-align: center;"></td>
|
||||
<td th:text="${obj.getGroupShow()}" style="text-align: center;"></td>
|
||||
<th th:switch="${obj.getStatus()}" style="text-align: center;">
|
||||
<span th:case="-2" class="Hui-iconfont" style="color: #8b0000;">未运营 </span>
|
||||
<span th:case="0" class="label label-defaunt radius">已关闭</span>
|
||||
|
|
|
@ -128,6 +128,14 @@
|
|||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row cl">
|
||||
<label class="form-label col-xs-4 col-sm-2">
|
||||
<span class="c-red">*</span>
|
||||
跨服分组id:</label>
|
||||
<div class="formControls col-xs-8 col-sm-9">
|
||||
<input type="number" name="groupId" placeholder="<=0表示不进行分组" th:value="*{getCrossGroupId()}" class="input-text"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="row cl">
|
||||
|
@ -181,6 +189,7 @@
|
|||
var status = $("#status option:selected").val();
|
||||
var is_new = $("#is_new option:selected").val();
|
||||
var register_state = $("#register_state option:selected").val();
|
||||
var groupId = $("input[name='groupId']").val();
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
data:
|
||||
|
@ -192,7 +201,9 @@
|
|||
"name": name,
|
||||
"status": status,
|
||||
"is_new": is_new,
|
||||
"register_state": register_state
|
||||
"register_state": register_state,
|
||||
"crossGroupId": groupId
|
||||
|
||||
}),
|
||||
url: "/serverEdit",
|
||||
dataType: "json",
|
||||
|
|
|
@ -26,6 +26,14 @@
|
|||
<h1 class="f-20 text-success">太初行管理后台</h1>
|
||||
</div>
|
||||
<div style="margin-left: 20px;font-size: 18px">
|
||||
<div>
|
||||
<h2 style="color: red" class="f-18">更新日志[2022-2-18]</h2>
|
||||
<p class="f-14" style="line-height:32px;">
|
||||
1、服务器列表添加列:《跨服分组id》,可以在修改服务器窗口修改,该属性修改后gm后台展示立即生效,游戏内会在下周一零点生效.
|
||||
括号内为当前服务器的跨服分组id<br>
|
||||
2、页面红点提示修改为只支持最新的十条通知,旧的会被覆盖,请及时查看
|
||||
</p>
|
||||
</div>
|
||||
<div>
|
||||
<h2 style="color: red" class="f-18">更新日志[2022-1-17]</h2>
|
||||
<p class="f-14" style="line-height:32px;">
|
||||
|
|
Loading…
Reference in New Issue