From 4f57f75d6d4ef5281de4a0c2d054b2e8dba48a7e Mon Sep 17 00:00:00 2001 From: wangyuan Date: Tue, 10 Sep 2019 10:05:03 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=B5=9B=E5=AD=A3=E5=BC=80?= =?UTF-8?q?=E5=90=AF=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/ljsd/GameApplication.java | 44 ++++++++++--------- .../jieling/config/SGlobalSystemConfig.java | 18 +++++++- 2 files changed, 40 insertions(+), 22 deletions(-) diff --git a/serverlogic/src/main/java/com/ljsd/GameApplication.java b/serverlogic/src/main/java/com/ljsd/GameApplication.java index a55aa3ced..985390d82 100644 --- a/serverlogic/src/main/java/com/ljsd/GameApplication.java +++ b/serverlogic/src/main/java/com/ljsd/GameApplication.java @@ -86,7 +86,8 @@ public class GameApplication { //http线程池初始化 // HttpPool.init(); - + //todo 设置开服时间 + setRegisterTime(); STableManager.initialize("com.ljsd.jieling.config"); //mongo异步数据处理线程 MongoDataHandlerTask.init(configurableApplicationContext); @@ -104,25 +105,7 @@ public class GameApplication { final NettyServerAutoConfiguration netServerConfig = configurableApplicationContext.getBean(NettyServerAutoConfiguration.class); NettyProperties properties = netServerConfig.getNettyProperties(); - //todo 设置开服时间 - ServerConfig serverConfigTmp = MongoUtil.getInstence().getMyMongoTemplate().findById(1, ServerConfig.class); - if( null == serverConfigTmp ){ - serverConfigTmp = new ServerConfig(); - SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - long serverOenTime = TimeUtils.getAppointTime(0); - String format = simpleDateFormat.format(serverOenTime); - serverConfigTmp.setOpenTime(format); - serverConfigTmp.setCacheOpenTime(serverOenTime); - serverConfigTmp.setId(1); - serverConfigTmp.setWorldLevel(1); - MongoUtil.getInstence().getMyMongoTemplate().saveWithoutMongoRoot(serverConfigTmp); - }else{ - SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - String openTime = serverConfigTmp.getOpenTime(); - Date date = simpleDateFormat.parse(openTime); - serverConfigTmp.setCacheOpenTime(date.getTime()); - } - serverConfig = serverConfigTmp; + KeyGenUtils.setMachineNum(serverConfiguration.getServerProperties().getNum()); ActivityLogic.getInstance().checkActiviyStatus(); ThriftPoolUtils.getInstance().initContext(configurableApplicationContext); @@ -148,6 +131,27 @@ public class GameApplication { } } + private static void setRegisterTime() throws Exception { + ServerConfig serverConfigTmp = MongoUtil.getInstence().getMyMongoTemplate().findById(1, ServerConfig.class); + if( null == serverConfigTmp ){ + serverConfigTmp = new ServerConfig(); + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + long serverOenTime = TimeUtils.getAppointTime(0); + String format = simpleDateFormat.format(serverOenTime); + serverConfigTmp.setOpenTime(format); + serverConfigTmp.setCacheOpenTime(serverOenTime); + serverConfigTmp.setId(1); + serverConfigTmp.setWorldLevel(1); + MongoUtil.getInstence().getMyMongoTemplate().saveWithoutMongoRoot(serverConfigTmp); + }else{ + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + String openTime = serverConfigTmp.getOpenTime(); + Date date = simpleDateFormat.parse(openTime); + serverConfigTmp.setCacheOpenTime(date.getTime()); + } + serverConfig = serverConfigTmp; + } + private static void close() { start = false; diff --git a/serverlogic/src/main/java/com/ljsd/jieling/config/SGlobalSystemConfig.java b/serverlogic/src/main/java/com/ljsd/jieling/config/SGlobalSystemConfig.java index 720671bd2..ddd76da7d 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/config/SGlobalSystemConfig.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/config/SGlobalSystemConfig.java @@ -1,5 +1,6 @@ package com.ljsd.jieling.config; +import com.ljsd.GameApplication; import com.ljsd.jieling.core.FunctionIdEnum; import com.ljsd.jieling.logic.STableManager; import com.ljsd.jieling.logic.Table; @@ -37,6 +38,8 @@ public class SGlobalSystemConfig implements BaseConfig { private int isOpen; + private int type; + private static Map sGlobalSystemConfigMap; @@ -53,8 +56,15 @@ public class SGlobalSystemConfig implements BaseConfig { iterator.remove(); continue; } - sGlobalSystemConfig.setSeasonOpenLong(TimeUtils.parseTimeToMiles(sGlobalSystemConfig.getSeasonOpen(), TimeUtils.Stand_CeHua_Data_format)); - sGlobalSystemConfig.setSeasonEndLong(TimeUtils.parseTimeToMiles(sGlobalSystemConfig.getSeasonEnd(), TimeUtils.Stand_CeHua_Data_format)); + if(2 == sGlobalSystemConfig.getType()){ + long cacheOpenTime = GameApplication.serverConfig.getCacheOpenTime(); + sGlobalSystemConfig.setSeasonOpenLong(cacheOpenTime +Integer.parseInt(sGlobalSystemConfig.getSeasonOpen())); + sGlobalSystemConfig.setSeasonEndLong(cacheOpenTime +Integer.parseInt(sGlobalSystemConfig.getSeasonEnd())); + }else{ + sGlobalSystemConfig.setSeasonOpenLong(TimeUtils.parseTimeToMiles(sGlobalSystemConfig.getSeasonOpen(), TimeUtils.Stand_CeHua_Data_format)); + sGlobalSystemConfig.setSeasonEndLong(TimeUtils.parseTimeToMiles(sGlobalSystemConfig.getSeasonEnd(), TimeUtils.Stand_CeHua_Data_format)); + } + sGlobalSystemConfig.setSystemOpenLong(TimeUtils.parseTimeToMiles(sGlobalSystemConfig.getSystemOpen(), TimeUtils.Stand_CeHua_Data_format)); sGlobalSystemConfig.setSystemEndLong(TimeUtils.parseTimeToMiles(sGlobalSystemConfig.getSystemEnd(), TimeUtils.Stand_CeHua_Data_format)); } @@ -135,4 +145,8 @@ public class SGlobalSystemConfig implements BaseConfig { public int getIsOpen() { return isOpen; } + + public int getType() { + return type; + } } \ No newline at end of file