添加服务器增加交叉id添加方式

master
duhui 2023-01-16 15:14:59 +08:00
parent 6807f62f3e
commit 2c90177b12
4 changed files with 54 additions and 16 deletions

View File

@ -445,19 +445,32 @@ public class ServerInfoController {
int port = Integer.parseInt(vo.getPort()); int port = Integer.parseInt(vo.getPort());
int coreNum = Integer.parseInt(vo.getCoreName()); int coreNum = Integer.parseInt(vo.getCoreName());
int crossGroupId = vo.getCrossGroupId(); int crossGroupId = vo.getCrossGroupId();
int cross = vo.getCross();
int crossValue = 0;
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
int i1 = serverId + i; int id = serverId + i;
if (serverMap.get(String.valueOf(i1)) != null){ if (serverMap.get(String.valueOf(id)) != null){
LOGGER.error("批量添加服务器出现重复id:{}",i1); LOGGER.error("批量添加服务器出现重复id:{}",id);
continue; continue;
} }
// 重新赋值 // 端口和core,不随id变化
vo.set_id(i1);
vo.setServer_id(String.valueOf(i1));
String name = named.replace("%d", String.valueOf(nameNum + i));
vo.setName(name);
vo.setPort(String.valueOf(port+i)); vo.setPort(String.valueOf(port+i));
vo.setCoreName("core"+(coreNum+i)); vo.setCoreName("core"+(coreNum+i));
// id和name随id变化
int i2 = i;
if (cross == 1){
id = serverId + crossValue;
i2 = crossValue;
}
vo.set_id(id);
vo.setServer_id(String.valueOf(id));
String name = named.replace("%d", String.valueOf(nameNum + i2));
vo.setName(name);
crossValue+=2;
serverInfoDao.addServerInfo(vo); serverInfoDao.addServerInfo(vo);
// 修改默认跨服id // 修改默认跨服id
RedisLogic.updateGameGroupId(vo.getServer_id(),crossGroupId); RedisLogic.updateGameGroupId(vo.getServer_id(),crossGroupId);

View File

@ -71,10 +71,18 @@ public class ServerInfoVo extends ServerInfo {
/** /**
* 使 * 使
*
*/ */
@Transient @Transient
private int count; private int count;
/**
* 使
*
*/
@Transient
private int cross;
public ServerInfoVo(){ public ServerInfoVo(){
} }
@ -192,6 +200,10 @@ public class ServerInfoVo extends ServerInfo {
this.count = count; this.count = count;
} }
public int getCross() {
return cross;
}
public String getGroupShow(){ public String getGroupShow(){
return getCrossGroupId()+"("+getOldGroupId()+")"; return getCrossGroupId()+"("+getOldGroupId()+")";
} }

View File

@ -42,6 +42,16 @@
</div> </div>
<div class="tabCon"> <div class="tabCon">
<div class="row cl">
<label class="form-label col-xs-4 col-sm-2" title="是否交叉配置服务器,默认取消" style="cursor:pointer">
<span class="c-red">* 是否交叉配置:</span>
</label>
<div class="formControls col-xs-8 col-sm-9">
<input type="radio" name="cross" value="0" checked/> 顺位
<input type="radio" name="cross" value="1" style="margin-left: 10px"/> 交叉
</div>
</div>
<div class="row cl"> <div class="row cl">
<label class="form-label col-xs-4 col-sm-2" title="批量添加填写第一个的服务器id" style="cursor:pointer"> <label class="form-label col-xs-4 col-sm-2" title="批量添加填写第一个的服务器id" style="cursor:pointer">
<span class="c-red">* serverId</span> <span class="c-red">* serverId</span>
@ -250,6 +260,8 @@
return false; return false;
} }
var cross = $('input[name=cross]:checked').val();
$.ajax({ $.ajax({
type: "POST", type: "POST",
data: data:
@ -271,7 +283,8 @@
"open_time":"0", "open_time":"0",
"open_type":"0", "open_type":"0",
"crossGroupId":crossId, "crossGroupId":crossId,
"count":count "count":count,
"cross":cross
}), }),
url: "/addServer", url: "/addServer",
dataType: "json", dataType: "json",

View File

@ -95,18 +95,18 @@
<!-- <span th:case="1" class="Hui-iconfont" style="color:green">开启</span>--> <!-- <span th:case="1" class="Hui-iconfont" style="color:green">开启</span>-->
<!-- </th>--> <!-- </th>-->
<td class="td-manage" style="text-align: center;"> <td class="td-manage" style="text-align: center;">
<a href="#" th:id="${obj.getServer_id()}" class="btn btn-primary radius" onclick="return editServer(this)"> <a href="#" th:id="${obj.getServer_id()}" class="btn btn-success radius" onclick="return editServer(this)">
修改 修改
</a> </a>
<button type="button" th:id="${obj.getServer_id()}" class="btn btn-warning radius" onclick="return deleteServer(this)"> <button type="button" th:id="${obj.getServer_id()}" th:attr="status=${obj.getStatusInt()}" onclick="return restartServer(this)" class="btn btn-secondary radius">
删除
</button>
<button type="button" th:id="${obj.getServer_id()}" th:attr="status=${obj.getStatusInt()}" onclick="return restartServer(this)" class="btn btn-warning radius">
重启 重启
</button> </button>
<button type="button" th:id="${obj.getServer_id()}" th:attr="status=${obj.getStatusInt()}" onclick="return cleanupServer(this)" class="btn btn-danger radius"> <button type="button" th:id="${obj.getServer_id()}" th:attr="status=${obj.getStatusInt()}" onclick="return cleanupServer(this)" class="btn btn-warning radius">
清库 清库
</button> </button>
<button type="button" th:id="${obj.getServer_id()}" class="btn btn-default radius" onclick="return deleteServer(this)">
删除
</button>
</td> </td>
</tr> </tr>
</tbody> </tbody>