时间设置修改
parent
5f4c02be98
commit
3d340f2511
|
|
@ -139,9 +139,9 @@ public class TimeUtils {
|
|||
|
||||
public static void main(String[] args) {
|
||||
|
||||
int lastHour = getOverTimeCount(1599602400000L,1600462810000L,5);
|
||||
long lastOrUnderHour = TimeUtils.getLastOrUnderHour(TimeUtils.now(), 1, 0, 0, true);
|
||||
lastOrUnderHour+=(2*TimeUtils.WEEK);
|
||||
|
||||
long lastOrUnderHour = getLastOrUnderHour(TimeUtils.now(), 1, 0, 0, true);
|
||||
System.out.println(lastOrUnderHour);
|
||||
}
|
||||
/**
|
||||
|
|
@ -1404,13 +1404,18 @@ public class TimeUtils {
|
|||
public static long getLastOrUnderHour(long time,int week,int hour,int minute,boolean lastOrUnder) {
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.setTimeInMillis(time);
|
||||
int offset = 0;
|
||||
if(cal.get(Calendar.DAY_OF_WEEK)==1){
|
||||
offset-=TimeUtils.WEEK;
|
||||
}
|
||||
cal.set(Calendar.DAY_OF_WEEK,week==7?0:week+1);
|
||||
time = cal.getTimeInMillis();
|
||||
long lastOrUnderHour = getLastOrUnderHour(time, hour, minute, true);
|
||||
|
||||
if(!lastOrUnder){
|
||||
lastOrUnderHour+=TimeUtils.WEEK;
|
||||
}
|
||||
return lastOrUnderHour;
|
||||
return lastOrUnderHour+offset;
|
||||
}
|
||||
/**
|
||||
*获取传入时间的上个几时几分或下个几时几分
|
||||
|
|
|
|||
|
|
@ -222,8 +222,12 @@ public class GlobleSystemLogic implements IEventHandler {
|
|||
if(!GameApplication.serverProperties.isArenaCross()){
|
||||
return;
|
||||
}
|
||||
SMServerArenaSetting setting = STableManager.getConfig(SMServerArenaSetting.class).get(1);
|
||||
RedisUtil redisUtil = RedisUtil.getInstence();
|
||||
Object matched = redisUtil.get(RedisKey.MATCHED_SPLIT_KEY);
|
||||
if(matched!=null){
|
||||
return;
|
||||
}
|
||||
SMServerArenaSetting setting = STableManager.getConfig(SMServerArenaSetting.class).get(1);
|
||||
//使用分布式锁,保证只有一个服来分组
|
||||
boolean lock = redisUtil.lock("SERVER_SPLIT_REDIS_LOCK", TimeUtils.ONE_MINUTE * 2);
|
||||
if(!lock){
|
||||
|
|
@ -232,10 +236,6 @@ public class GlobleSystemLogic implements IEventHandler {
|
|||
}
|
||||
//这里为所有服务器的世界等级
|
||||
Map<String,Integer> worldLevelMap = redisUtil.getMapValues(RedisKey.SERVER_WORLDLEVE_INFO,"",String.class,Integer.class);
|
||||
Object matched = redisUtil.get(RedisKey.MATCHED_SPLIT_KEY);
|
||||
if(matched!=null){
|
||||
return;
|
||||
}
|
||||
LOGGER.info("Global开始分组");
|
||||
long lastHour = TimeUtils.getLastOrUnderHour(TimeUtils.now(), 1, 0, 0, true);
|
||||
lastHour+=(2*TimeUtils.WEEK);
|
||||
|
|
@ -266,6 +266,8 @@ public class GlobleSystemLogic implements IEventHandler {
|
|||
//发分组邮件
|
||||
split.keySet().forEach(server->redisUtil.putMapEntry(RedisKey.SERVER_SPLIT_MAIL_INFO,"",server,0));
|
||||
}
|
||||
//释放分布式锁
|
||||
redisUtil.del("SERVER_SPLIT_REDIS_LOCK");
|
||||
LOGGER.info("Global分组结束");
|
||||
// splitInfo = RedisUtil.getInstence().getMapValues(RedisKey.SERVER_SPLIT_INFO,"",String.class,Integer.class);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -797,12 +797,17 @@ public class ArenaLogic {
|
|||
private void initRank(){
|
||||
int crossGroup = GlobleSystemLogic.getInstence().getCrossGroup();
|
||||
|
||||
if(crossGroup==-1){
|
||||
return;
|
||||
}
|
||||
|
||||
//分布式锁,保证一个组只有一个服进行初始化
|
||||
boolean lock = RedisUtil.getInstence().lock("WORLD_ARENA_INIT_RANK:" + crossGroup, TimeUtils.ONE_MINUTE * 5);
|
||||
if(!lock){
|
||||
return;
|
||||
}
|
||||
RedisUtil.getInstence().expire("WORLD_ARENA_INIT_RANK:" + crossGroup,TimeUtils.ONE_MINUTE * 5);
|
||||
|
||||
String key1 = RedisUtil.getInstence().getKey(RedisKey.CROSS_ARENA_ROBOT_INFO, String.valueOf(crossGroup));
|
||||
String key2 = RedisUtil.getInstence().getKey(RedisKey.CROSS_SERVICE_ARENA, String.valueOf(crossGroup));
|
||||
RedisUtil.getInstence().del(key1,key2);
|
||||
|
|
@ -830,7 +835,6 @@ public class ArenaLogic {
|
|||
|
||||
}
|
||||
RedisUtil.getInstence().putMapEntrys(RedisKey.CROSS_ARENA_ROBOT_INFO,String.valueOf(crossGroup),robotInfo);
|
||||
|
||||
}
|
||||
|
||||
//获取跨服信息
|
||||
|
|
|
|||
Loading…
Reference in New Issue