优化服务器信息修改操作

master
duhui 2023-01-09 17:03:50 +08:00
parent 1767601f69
commit e5bb1bc1d9
6 changed files with 52 additions and 35 deletions

View File

@ -72,7 +72,7 @@ public class OrderInfoController {
List<Corder> orders = findOrders(parameterMap);
exportOrderExcel(name,orders);
} catch (Exception e) {
LoginController.addQueue("订单列表《"+name+"》导出报错2:"+e.getMessage());
LoginController.addQueue("订单列表《"+name+"》导出报错2");
e.printStackTrace();
}
}
@ -402,7 +402,7 @@ public class OrderInfoController {
workbook.write(fOut);
}
catch (Exception e) {
LoginController.addQueue("订单列表《"+name+"》导出报错:"+e.getMessage());
LoginController.addQueue("订单列表《"+name+"》导出报错:");
e.printStackTrace();
}
finally

View File

@ -1,11 +1,14 @@
package com.jmfy.controller;
import com.jmfy.dao.CUserDao;
import com.jmfy.dao.ServerInfoDao;
import com.jmfy.handler.GMHandler;
import com.jmfy.handler.RedisLogic;
import com.jmfy.model.AutoServerSetting;
import com.jmfy.model.CAdmin;
import com.jmfy.model.CServerOpenTime;
import com.jmfy.model.ServerInfo;
import com.jmfy.model.vo.IdentityEnum;
import com.jmfy.model.vo.PowersEnum;
import com.jmfy.model.vo.ServerInfoVo;
import com.jmfy.model.vo.ServerStatusEnum;
@ -23,7 +26,10 @@ import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
@ -40,6 +46,8 @@ public class ServerInfoController {
private CommonManager commonManager;
@Resource
private AutoServerManager autoServerManager;
@Resource
private CUserDao cUserDao;
private static int state = 0;
@ -228,34 +236,42 @@ public class ServerInfoController {
*/
@RequestMapping(value = "/serverEdit", method = {RequestMethod.POST, RequestMethod.GET})
public @ResponseBody
int serverEdit(@RequestBody ServerInfoVo vo) throws Exception {
int serverEdit(@RequestBody ServerInfoVo vo, HttpServletRequest request) throws Exception {
ServerInfo info = serverInfoDao.getServerInfo(vo.getServer_id());
// 服务器信息不存在
if (info == null){
return 0;
}
// 验证时间格式
// boolean format = DateUtil.verifyDateStrFormat(vo.getOpenTime());
// if (!format){
// return 0;
// }
boolean format = DateUtil.verifyDateStrFormat(vo.getOpenTime());
if (!format){
return 0;
}
// 未运营
int notState = ServerStatusEnum.NOT_OPERATE.getId();
// 正常状态转向未运营状态,验证权限
if (info.getStatusInt() != notState && vo.getStatusInt() == notState){
boolean verifyPower = commonManager.verifyPower(request, PowersEnum.SERVER_NOT_OPERATION);
String account = request.getSession().getAttribute("username")+"";
CAdmin admin = cUserDao.findAdmin(account);
if (!verifyPower || admin == null || admin.getIdentity() != IdentityEnum.SYSTEM_ADMIN.getId()){
return 2;
}
}
// 1. 修改服务器信息
serverInfoDao.updateServerInfo(vo);
// 未运营
int notState = ServerStatusEnum.NOT_OPERATE.getId();
// 2. 当前服务器状态是未运营状态时,会进行敏感数据修正
if (info.getStatusInt() == notState){
// 2.1 修改跨服信息
RedisLogic.updateGameGroupId(vo.getServer_id(),vo.getCrossGroupId());
// 2.2 修改开服时间
// serverInfoDao.updateOpenServerTime(vo.getServer_id(),vo.getOpenTime());
serverInfoDao.updateOpenServerTime(vo.getServer_id(),vo.getOpenTime());
// GMHandler.sendGm(info.getServer_id(),"reloadserverconfig");
autoServerManager.rebootServer(info.getServer_id());
}else {
RedisLogic.updateGmGroupId(vo.getServer_id(),vo.getCrossGroupId());
}
return 1;
}

View File

@ -28,6 +28,7 @@ public enum PowersEnum {
RESTART_SERVER_PERMISSIONS(209,"权限:重启服务器",200,0,""),
CLEANUP_SERVER_PERMISSIONS(210,"权限:清库",200,0,""),
SERVER_LIST_UPDATE(211,"批量修改服务器",200,1,"toUpdateServerList"),
SERVER_NOT_OPERATION(212,"权限:操作未运营状态服务器",200,0,""),
/**
* 300-399
*/

View File

@ -213,17 +213,10 @@ public class AutoServerManager {
Thread.sleep(DateUtil.ONE_SECOND * 10);
// 验证
boolean serverStatus = verifyServerStatus(serverInfo);
if (serverStatus){
//修改开服时间
// if (DateUtil.verifyDateStrFormat(vo.getOpenTime())){
// // 修改开服时间
//// serverInfoDao.updateOpenServerTime(vo.getServer_id(),vo.getOpenTime());
// }
// 重启服务器
rebootServer(serverInfo.getServer_id());
}else {
// 服务器状态校验失败后将状态改回未运营
if (!serverStatus){
// 校验失败后将状态改回未运营
serverInfoDao.updateServerInfo(vo.getServer_id(),ServerStatusEnum.NOT_OPERATE.getIdStr());
LoginController.addQueue("手动开服失败服务器id:" + vo.getServer_id());
}
} catch (Exception e) {
e.printStackTrace();

View File

@ -2,6 +2,8 @@ package com.jmfy.utils;
import config.SItemConfig;
import config.SRechargeCommodityConfig;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.*;
import java.lang.reflect.Field;
@ -9,6 +11,8 @@ import java.util.*;
public class FileCacheUtils {
private static final Logger LOGGER = LoggerFactory.getLogger(FileCacheUtils.class);
private static String path = "";
public static Map<Integer,String> itemNameMap;
@ -164,7 +168,7 @@ public class FileCacheUtils {
field.setAccessible(flag);
map.put(id, obj);
} catch (NoSuchFieldException e) {
e.printStackTrace();
LOGGER.error("初始化表异常表name{},异常:{}",clazz.getSimpleName(),e.getMessage());
}
}
}

View File

@ -89,7 +89,7 @@
<div class="formControls col-xs-8 col-sm-9">
<select th:name="status" class="input-text" id="status"><!--下拉列表-->
<div th:switch="*{getStatus()}">
<option th:if="*{getStatus().equals('-2')}" th:value="-2">未运营</option>
<option th:value="-2">未运营</option>
<option th:value="0">关闭</option>
<option th:value="1">维护</option>
<option th:value="2">流畅</option>
@ -134,15 +134,15 @@
<input type="number" name="groupId" placeholder="<=0表示不进行分组" th:value="*{getCrossGroupId()}" class="input-text"/>
</div>
</div>
<!-- <div class="row cl">-->
<!-- <label class="form-label col-xs-4 col-sm-2" title="未运营状态下修改立刻生效,其他状态修改不生效">-->
<!-- <span class="c-red">* 开服时间:</span>-->
<!-- </label>-->
<!-- <div class="formControls col-xs-8 col-sm-9">-->
<!-- <input th:if="*{getStatus().equals('-2')}" type="text" name="openTime" placeholder="格式必须为yyyy-MM-dd HH:mm:ss" th:value="*{getOpenTime()}" class="input-text" />-->
<!-- <input th:if="*{!getStatus().equals('-2')}" type="text" name="openTime" placeholder="格式必须为yyyy-MM-dd HH:mm:ss" th:value="*{getOpenTime()}" class="input-text" readonly style="background-color: #c3c3c3" />-->
<!-- </div>-->
<!-- </div>-->
<div class="row cl">
<label class="form-label col-xs-4 col-sm-2" title="未运营状态下修改立刻生效,其他状态修改不生效">
<span class="c-red">* 开服时间:</span>
</label>
<div class="formControls col-xs-8 col-sm-9">
<input th:if="*{getStatus().equals('-2')}" type="text" name="openTime" placeholder="格式必须为yyyy-MM-dd HH:mm:ss" th:value="*{getOpenTime()}" class="input-text" />
<input th:if="*{!getStatus().equals('-2')}" type="text" name="openTime" placeholder="格式必须为yyyy-MM-dd HH:mm:ss" th:value="*{getOpenTime()}" class="input-text" readonly style="background-color: #c3c3c3" />
</div>
</div>
</div>
<div class="row cl">
@ -200,7 +200,7 @@
var is_new = $("#is_new option:selected").val();
var register_state = $("#register_state option:selected").val();
var groupId = $("input[name='groupId']").val();
var openTime = "";
var openTime = $("input[name='openTime']").val();
$.ajax({
type: "POST",
data:
@ -225,7 +225,10 @@
window.location.href="/findServerInfo?quick=1";
}
if (data === 0) {
alert("修改失败,服务器参数有误,请检查后重新修改");
alert("修改失败,参数异常,请修改后重新提交!");
}
if (data === 2) {
alert("没有操作权限!");
}
if (data === 3) {
alert("服务器已开启自动开服,无法手动修改,修改请关闭自动开服功能!");