From e086fd1e97ef73f7004ce34dfdf6b36cc71d5919 Mon Sep 17 00:00:00 2001 From: lvxinran Date: Fri, 25 Dec 2020 10:19:50 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8D=81=E7=BB=9D=E9=98=B5=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/rpc/protocols/MessageTypeProto.java | 14 ++++++-- .../jieling/logic/family/DeathPathLogic.java | 33 ++++++++++--------- .../DeathPathWorldRewardRequestHandler.java | 22 ++++++++----- .../main/java/com/world/redis/RedisUtil.java | 6 ++-- 4 files changed, 48 insertions(+), 27 deletions(-) diff --git a/gamecommon/src/main/java/rpc/protocols/MessageTypeProto.java b/gamecommon/src/main/java/rpc/protocols/MessageTypeProto.java index f93997d12..75605a698 100644 --- a/gamecommon/src/main/java/rpc/protocols/MessageTypeProto.java +++ b/gamecommon/src/main/java/rpc/protocols/MessageTypeProto.java @@ -4173,6 +4173,10 @@ public final class MessageTypeProto { * GetDeathPathRewardRequest = 900014; */ GetDeathPathRewardRequest(675, 900014), + /** + * DeathPathWorldRewardRequest = 900015; + */ + DeathPathWorldRewardRequest(676, 900015), ; /** @@ -8335,6 +8339,10 @@ public final class MessageTypeProto { * GetDeathPathRewardRequest = 900014; */ public static final int GetDeathPathRewardRequest_VALUE = 900014; + /** + * DeathPathWorldRewardRequest = 900015; + */ + public static final int DeathPathWorldRewardRequest_VALUE = 900015; public final int getNumber() { return value; } @@ -9017,6 +9025,7 @@ public final class MessageTypeProto { case 900012: return AddDeathPathRankRequest; case 900013: return GetDeathPathFirstRequest; case 900014: return GetDeathPathRewardRequest; + case 900015: return DeathPathWorldRewardRequest; default: return null; } } @@ -9078,7 +9087,7 @@ public final class MessageTypeProto { static { java.lang.String[] descriptorData = { "\n\026MessageTypeProto.proto\022\rrpc.protocols*" + - "\341\254\001\n\013MessageType\022\027\n\022HEART_BEAT_REQUEST\020\350" + + "\204\255\001\n\013MessageType\022\027\n\022HEART_BEAT_REQUEST\020\350" + "\007\022\030\n\023HEART_BEAT_RESPONSE\020\351\007\022\036\n\031ACTIVITE_" + "WORKSHOP_REQUEST\020\224N\022\037\n\032ACTIVITE_WORKSHOP" + "_RESPONSE\020\225N\022\027\n\022ARENA_INFO_REQUEST\020\226N\022\030\n" + @@ -9630,7 +9639,8 @@ public final class MessageTypeProto { "\020\251\3676\022 \n\032GetGSUserArenaInfoResponse\020\252\3676\022\024" + "\n\016GetRankRequest\020\253\3676\022\035\n\027AddDeathPathRank" + "Request\020\254\3676\022\036\n\030GetDeathPathFirstRequest\020" + - "\255\3676\022\037\n\031GetDeathPathRewardRequest\020\256\3676B\002H\001" + "\255\3676\022\037\n\031GetDeathPathRewardRequest\020\256\3676\022!\n\033" + + "DeathPathWorldRewardRequest\020\257\3676B\002H\001" }; com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() { diff --git a/serverlogic/src/main/java/com/ljsd/jieling/logic/family/DeathPathLogic.java b/serverlogic/src/main/java/com/ljsd/jieling/logic/family/DeathPathLogic.java index 62a232bf9..b0f77cd45 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/logic/family/DeathPathLogic.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/logic/family/DeathPathLogic.java @@ -28,6 +28,7 @@ import com.ljsd.jieling.logic.rank.rankImpl.AbstractRank; import com.ljsd.jieling.network.server.GlobalidHelper; import com.ljsd.jieling.network.server.WorldHelper; import com.ljsd.jieling.network.session.ISession; +import org.springframework.data.redis.core.Cursor; import rpc.protocols.CommonProto; import rpc.protocols.Family; import rpc.protocols.MessageTypeProto; @@ -223,8 +224,8 @@ public class DeathPathLogic { tasks.clear(); taskExecutor = new DeathPathExecutor(tasks); taskExecutor.start(); - groupId = GlobalidHelper.getWorldInfo().getMyGroup(); } + groupId = GlobalidHelper.getWorldInfo().getMyGroup(); break; case 2: long appointTime = TimeUtils.getAppointTime(0, 0)+TimeUtils.DAY; @@ -263,12 +264,6 @@ public class DeathPathLogic { */ public void getStatus(ISession session, MessageTypeProto.MessageType messageType) throws Exception { int uid = session.getUid(); - String key = RedisKey.getKey(RedisKey.DEATH_PATH_CHALLENGE_COUNT, String.valueOf(uid), false); - AbstractRank personRank = RankContext.getRankEnum(RankEnum.DEATH_PATH_TOTAL_PERSON_RANK.getType()); - double scoreById = personRank.getScoreById(uid, ""); - if(RedisUtil.getInstence().get(key)!=null&&scoreById==-1){ - RedisUtil.getInstence().del(key); - } GuildMyInfo info = UserManager.getUser(uid).getGuildMyInfo(); int joinType =0; if(info.getJoinTime()overTime) { @@ -641,16 +636,24 @@ public class DeathPathLogic { } index++; } - redisUtil.del(removeGuildKey); - redisUtil.del(removePersonKey); - for(int i = 1; i <=10;i++){ - redisUtil.del(RedisKey.getKey(RankEnum.DEATH_PATH_EVERY_GUILD_RANK.getRedisKey(),String.valueOf(i),false)); - redisUtil.del(RedisKey.getKey(RankEnum.DEATH_PATH_EVERY_PERSON_RANK.getRedisKey(),String.valueOf(i),false)); - } - redisUtil.del(RedisKey.getKey(guildRank.getRedisKey(),"",false)); - redisUtil.del(RedisKey.getKey(personRank.getRedisKey(),"",false)); +// redisUtil.del(removeGuildKey); +// redisUtil.del(removePersonKey); +// for(int i = 1; i <=10;i++){ +// redisUtil.del(RedisKey.getKey(RankEnum.DEATH_PATH_EVERY_GUILD_RANK.getRedisKey(),String.valueOf(i),false)); +// redisUtil.del(RedisKey.getKey(RankEnum.DEATH_PATH_EVERY_PERSON_RANK.getRedisKey(),String.valueOf(i),false)); +// } +// redisUtil.del(RedisKey.getKey(guildRank.getRedisKey(),"",false)); +// redisUtil.del(RedisKey.getKey(personRank.getRedisKey(),"",false)); } + + Cursor cursor = RedisUtil.getInstence().scan(GameApplication.serverId+":DEATH_PATH*", -1); + while (cursor.hasNext()) { + //找到一次就添加一次 + String next = cursor.next(); + LOGGER.info("删除排行{}",next); + RedisUtil.getInstence().del(next); + } } public static int nextDiscrete(double[] probs) { diff --git a/worldserver/src/main/java/com/world/handler/DeathPathWorldRewardRequestHandler.java b/worldserver/src/main/java/com/world/handler/DeathPathWorldRewardRequestHandler.java index bd7dd7211..5a1e72ca2 100644 --- a/worldserver/src/main/java/com/world/handler/DeathPathWorldRewardRequestHandler.java +++ b/worldserver/src/main/java/com/world/handler/DeathPathWorldRewardRequestHandler.java @@ -8,6 +8,7 @@ import com.world.logic.rank.DeathPathCrossEveryGuildRank; import com.world.logic.rank.DeathPathCrossTotalGuildRank; import com.world.redis.RedisKey; import com.world.redis.RedisUtil; +import org.springframework.data.redis.core.Cursor; import org.springframework.data.redis.core.ZSetOperations; import rpc.net.RpcMessage; import rpc.net.gtGBaseHandler; @@ -25,14 +26,15 @@ public class DeathPathWorldRewardRequestHandler extends gtGBaseHandler groupIds = new HashSet<>(); @Override public WorldProto.DeathPathWorldRewardResponse processWithProto(RpcMessage rpcMessage, WorldProto.DeathPathWorldRewardRequest proto) throws Exception { + + WorldProto.DeathPathWorldRewardResponse.Builder builder = WorldProto.DeathPathWorldRewardResponse.newBuilder(); if(TimeUtils.getHourOfDay()!=0){ - return null; + return builder.build(); } groupIds.add(proto.getGroupId()); int serverId = rpcMessage.getServerId(); Set> values = RedisUtil.getInstence().getZsetreverseRangeWithScores(proto.getGroupId()+":" + RedisKey.DEATH_PATH_TOTAL_GUILD_RANK, "", 0, -1); - WorldProto.DeathPathWorldRewardResponse.Builder builder = WorldProto.DeathPathWorldRewardResponse.newBuilder(); int rank =0; for(ZSetOperations.TypedTuple value:values){ rank++; @@ -45,14 +47,18 @@ public class DeathPathWorldRewardRequestHandler extends gtGBaseHandler hmget = RedisUtil.getInstence().hmget(RedisKey.DEATH_PATH_EVERY_OVER_HASH); - groupIds.add(proto.getGroupId()); + if(proto.getGroupId()!=0) + groupIds.add(proto.getGroupId()); + if(hmget==null||hmget.size()<1){ groupIds.forEach(n->{ - RedisUtil.getInstence().del(n+":"+RedisKey.DEATH_PATH_EVERY_GUILD_RANK+"*"); - RedisUtil.getInstence().del(n+":"+RedisKey.DEATH_PATH_EVERY_PERSON_RANK+"*"); - RedisUtil.getInstence().del(n+":"+RedisKey.DEATH_PATH_TOTAL_GUILD_RANK+"*"); - RedisUtil.getInstence().del(n+":"+RedisKey.DEATH_PATH_TOTAL_PERSON_RANK+"*"); - + Cursor cursor = RedisUtil.getInstence().scan(n+":DEATH_PATH*", -1); + while (cursor.hasNext()) { + //找到一次就添加一次 + String next = cursor.next(); + LOGGER.info("删除排行{}",next); + RedisUtil.getInstence().del(next); + } }); } return builder.build(); diff --git a/worldserver/src/main/java/com/world/redis/RedisUtil.java b/worldserver/src/main/java/com/world/redis/RedisUtil.java index 41a8a6f6b..74fc3b403 100644 --- a/worldserver/src/main/java/com/world/redis/RedisUtil.java +++ b/worldserver/src/main/java/com/world/redis/RedisUtil.java @@ -748,10 +748,12 @@ public class RedisUtil { } public Cursor scan(String match, int count){ - ScanOptions scanOptions = ScanOptions.scanOptions().match(match).count(count).build(); + ScanOptions.ScanOptionsBuilder match1 = ScanOptions.scanOptions().match(match); + if(count!=-1) + match1.count(count); RedisSerializer redisSerializer = (RedisSerializer) redisTemplate.getKeySerializer(); return (Cursor) redisTemplate.executeWithStickyConnection((RedisCallback) redisConnection -> - new ConvertingCursor<>(redisConnection.scan(scanOptions), redisSerializer::deserialize)); + new ConvertingCursor<>(redisConnection.scan(match1.build()), redisSerializer::deserialize)); } private final static String UNLOCK_SCRIPT = "if redis.call('get', KEYS[1]) == ARGV[1] then return redis.call('del', KEYS[1]) else return 0 end";