generated from root/miduo_server
自动开服细节修改
parent
587bfb3885
commit
f87c54842f
|
@ -317,6 +317,7 @@ public @ResponseBody String banFunction(HttpServletRequest request) throws Excep
|
|||
BufferedReader in = new BufferedReader(new FileReader(filePath+"rechargeImport.txt"));
|
||||
BufferedWriter out = new BufferedWriter(new FileWriter(filePath+"recharge.json"));
|
||||
String str;
|
||||
out.write("返利json生成开始===============================");
|
||||
while ((str = in.readLine()) != null) {
|
||||
String[] s = str.split("\t");
|
||||
if(s[0].charAt(s[0].length()-1)==' '){
|
||||
|
@ -327,6 +328,7 @@ public @ResponseBody String banFunction(HttpServletRequest request) throws Excep
|
|||
System.out.println(s[0]+"||"+s[1]);
|
||||
out.write(json+"\n");
|
||||
}
|
||||
out.write("返利json生成完成===============================");
|
||||
in.close();
|
||||
out.close();
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import com.jmfy.model.CServerOpenTime;
|
|||
import com.jmfy.model.ServerInfo;
|
||||
import com.jmfy.model.vo.PowersEnum;
|
||||
import com.jmfy.model.vo.ServerInfoVo;
|
||||
import com.jmfy.model.vo.ServerStatusEnum;
|
||||
import com.jmfy.redisProperties.RedisUserKey;
|
||||
import com.jmfy.utils.*;
|
||||
import org.slf4j.Logger;
|
||||
|
@ -68,14 +69,11 @@ public class ServerInfoController {
|
|||
serverInfoVo.setIp_port(serverInfo.getIP()+":"+serverInfo.getPort());
|
||||
|
||||
String openT = "手动开服";
|
||||
if(serverInfo.getOpen_type()!=null&&serverInfo.getOpen_type().equals(Constants.SERVEROPEN_TIME)){
|
||||
openT = RedisUtil.getInstence().getObject(serverInfo.getServer_id() + RedisUserKey.Delimiter_colon + RedisUserKey.AUTOOPENTIME, "", String.class, -1);
|
||||
}else if(serverInfo.getOpen_type()!=null&&serverInfo.getOpen_type().equals(Constants.SERVEROPEN_NUM)) {
|
||||
openT = "按量开服";
|
||||
}
|
||||
if(null!=openT) {
|
||||
serverInfoVo.setOpen_type(openT);
|
||||
AutoServerSetting setting = RedisUtil.getInstence().getMapValue(RedisUserKey.AUTO_START_SERVER_SETTING, "1", "1", AutoServerSetting.class, -1);
|
||||
if (setting != null && "1".equals(setting.getState())){
|
||||
openT = "1".equals(setting.getChoose())?"按量开服":"自动开服";
|
||||
}
|
||||
serverInfoVo.setOpen_type(openT);
|
||||
serverInfoVos.add(serverInfoVo);
|
||||
}
|
||||
map.addAttribute("serverInfos", serverInfoVos);
|
||||
|
@ -92,20 +90,10 @@ public class ServerInfoController {
|
|||
@RequestMapping(value = "/toServerInfoEdit", method = {RequestMethod.POST, RequestMethod.GET})
|
||||
public String toServerInfoEdit(ModelMap map, int id) throws Exception {
|
||||
ServerInfo serverInfo = serverInfoDao.getServerinfo(String.valueOf(id));
|
||||
|
||||
if(serverInfo.getOpen_type()!=null&&serverInfo.getOpen_type().equals(Constants.SERVEROPEN_TIME)&&serverInfo.getStatus().equals(Constants.SERVERSTATE_UNSTART)){
|
||||
String openT = RedisUtil.getInstence().getObject(serverInfo.getServer_id() + RedisUserKey.Delimiter_colon + RedisUserKey.AUTOOPENTIME, "", String.class, -1);
|
||||
if(null!= openT){
|
||||
serverInfo.setOpen_time("(等待启动)"+openT);
|
||||
}
|
||||
}else {
|
||||
CServerOpenTime cServerOpenTime = serverInfoDao.getOpenServerTime(serverInfo.getServer_id());
|
||||
if (null != cServerOpenTime) {
|
||||
serverInfo.setOpen_time(cServerOpenTime.getOpenTime());
|
||||
}
|
||||
CServerOpenTime cServerOpenTime = serverInfoDao.getOpenServerTime(serverInfo.getServer_id());
|
||||
if (null != cServerOpenTime) {
|
||||
serverInfo.setOpen_time(cServerOpenTime.getOpenTime());
|
||||
}
|
||||
serverInfo.setRegister_state(serverInfo.getRegister_state());
|
||||
System.out.println(serverInfo);
|
||||
map.addAttribute("serverInfo", serverInfo);
|
||||
return "serverInfoEdit";
|
||||
}
|
||||
|
@ -119,16 +107,19 @@ public class ServerInfoController {
|
|||
@RequestMapping(value = "/serverEdit", method = {RequestMethod.POST, RequestMethod.GET})
|
||||
public @ResponseBody
|
||||
int toServerInfoEdit(HttpServletRequest request) throws Exception {
|
||||
boolean open = AutoServerManager.getInstance().isOpen();
|
||||
if (open){
|
||||
return 3;
|
||||
}
|
||||
// 服务器id
|
||||
String server_id = request.getParameter("server_id");
|
||||
// 名字
|
||||
String name = request.getParameter("name");
|
||||
// 服务器状态
|
||||
int status = Integer.parseInt(request.getParameter("status"));
|
||||
if (status == ServerStatusEnum.NOT_OPERATE.getId()){
|
||||
// 未运营状态需要验证自动开服状态
|
||||
boolean open = AutoServerManager.getInstance().isOpen();
|
||||
if (open){
|
||||
return 3;
|
||||
}
|
||||
}
|
||||
// 新服
|
||||
int isnew = Integer.parseInt(request.getParameter("is_new"));
|
||||
// 注册状态
|
||||
|
@ -136,7 +127,7 @@ public class ServerInfoController {
|
|||
|
||||
ServerInfo info = serverInfoDao.getServerinfo(server_id);
|
||||
// 未运营状态的服务器需要进行清库处理
|
||||
if (info != null && "-2".equals(info.getStatus())){
|
||||
if (info != null && Integer.parseInt(info.getStatus()) == ServerStatusEnum.NOT_OPERATE.getId()){
|
||||
ThreadPoolManager.getInstance().execute(() -> AutoServerManager.getInstance().delUser(info));
|
||||
}
|
||||
// 修改服务器状态
|
||||
|
@ -152,10 +143,6 @@ public class ServerInfoController {
|
|||
*/
|
||||
@RequestMapping(value = "/serverListEdit", method = {RequestMethod.POST, RequestMethod.GET})
|
||||
public @ResponseBody int toServerListEdit(HttpServletRequest request) throws Exception {
|
||||
boolean open = AutoServerManager.getInstance().isOpen();
|
||||
if (open){
|
||||
return 3;
|
||||
}
|
||||
int status = Integer.parseInt(request.getParameter("status"));
|
||||
String serverId = request.getParameter("serverId");
|
||||
// 校验服务器状态
|
||||
|
|
|
@ -43,7 +43,6 @@ public class ServerInfo implements Comparable {
|
|||
* 2 流畅
|
||||
* 3 拥挤
|
||||
* 4 爆满
|
||||
* 5 自动
|
||||
*/
|
||||
@Field(value = "state")
|
||||
private String status;
|
||||
|
|
|
@ -60,7 +60,7 @@ public class AutoServerManager {
|
|||
long now = DateUtil.now();
|
||||
// 获取全部服务器列表,排除非未运营和准备中的服务器,正序排列
|
||||
List<ServerInfo> allServerInfo = serverInfoDao.getAllServerInfo();
|
||||
Stream<ServerInfo> sorted = allServerInfo.stream().filter(v -> Integer.parseInt(v.getStatus()) >= 0).sorted();
|
||||
Stream<ServerInfo> sorted = allServerInfo.stream().filter(v -> Integer.parseInt(v.getStatus()) != -2).sorted();
|
||||
Optional<ServerInfo> first = sorted.findFirst();
|
||||
if (!first.isPresent()){
|
||||
LOGGER.error("自动开服,服务器列表获取为空");
|
||||
|
|
Loading…
Reference in New Issue