加入在线判断逻辑
parent
afe20ec571
commit
e4b32a7b03
|
|
@ -4,6 +4,7 @@ import com.ljsd.jieling.core.GlobalsDef;
|
||||||
import com.ljsd.jieling.db.mongo.LjsdMongoTemplate;
|
import com.ljsd.jieling.db.mongo.LjsdMongoTemplate;
|
||||||
import com.ljsd.jieling.db.mongo.MongoUtil;
|
import com.ljsd.jieling.db.mongo.MongoUtil;
|
||||||
import com.ljsd.jieling.globals.Global;
|
import com.ljsd.jieling.globals.Global;
|
||||||
|
import com.ljsd.jieling.logic.OnlineUserManager;
|
||||||
import com.ljsd.jieling.logic.dao.GuilidManager;
|
import com.ljsd.jieling.logic.dao.GuilidManager;
|
||||||
import com.ljsd.jieling.logic.dao.UserManager;
|
import com.ljsd.jieling.logic.dao.UserManager;
|
||||||
import com.ljsd.jieling.logic.dao.root.GuildInfo;
|
import com.ljsd.jieling.logic.dao.root.GuildInfo;
|
||||||
|
|
@ -11,6 +12,7 @@ import com.ljsd.jieling.logic.dao.root.User;
|
||||||
import com.ljsd.jieling.logic.mail.MailLogic;
|
import com.ljsd.jieling.logic.mail.MailLogic;
|
||||||
import com.ljsd.jieling.logic.rank.RankEnum;
|
import com.ljsd.jieling.logic.rank.RankEnum;
|
||||||
import com.ljsd.jieling.logic.rank.RankLogic;
|
import com.ljsd.jieling.logic.rank.RankLogic;
|
||||||
|
import com.ljsd.jieling.network.session.ISession;
|
||||||
import config.SErrorCodeEerverConfig;
|
import config.SErrorCodeEerverConfig;
|
||||||
import util.TimeUtils;
|
import util.TimeUtils;
|
||||||
|
|
||||||
|
|
@ -29,14 +31,16 @@ public class GuildChangeTask implements GeneralTask{
|
||||||
|
|
||||||
private Set<Integer> releaseGuilds;
|
private Set<Integer> releaseGuilds;
|
||||||
|
|
||||||
public GuildChangeTask(Set<Integer> chairmanChangeGuilds, Set<Integer> releaseGuilds) {
|
private long time;
|
||||||
|
public GuildChangeTask(Set<Integer> chairmanChangeGuilds, Set<Integer> releaseGuilds,long time) {
|
||||||
this.chairmanChangeGuilds = chairmanChangeGuilds;
|
this.chairmanChangeGuilds = chairmanChangeGuilds;
|
||||||
this.releaseGuilds = releaseGuilds;
|
this.releaseGuilds = releaseGuilds;
|
||||||
|
this.time=time;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
long now = TimeUtils.now();
|
long now = time;
|
||||||
Map<Integer, GuildInfo> guildInfoMap = GuilidManager.guildInfoMap;
|
Map<Integer, GuildInfo> guildInfoMap = GuilidManager.guildInfoMap;
|
||||||
if(chairmanChangeGuilds!=null&&chairmanChangeGuilds.size()>0){
|
if(chairmanChangeGuilds!=null&&chairmanChangeGuilds.size()>0){
|
||||||
Iterator<Integer> iterator = chairmanChangeGuilds.iterator();
|
Iterator<Integer> iterator = chairmanChangeGuilds.iterator();
|
||||||
|
|
@ -128,11 +132,12 @@ public class GuildChangeTask implements GeneralTask{
|
||||||
}
|
}
|
||||||
|
|
||||||
private void getChangeUid(long now,Set<Integer> member,CompareValue value){
|
private void getChangeUid(long now,Set<Integer> member,CompareValue value){
|
||||||
|
Map<Integer, ISession> sessionMap = OnlineUserManager.sessionMap;
|
||||||
for(int oneAdmin:member){
|
for(int oneAdmin:member){
|
||||||
try {
|
try {
|
||||||
User user = UserManager.getUser(oneAdmin);
|
User user = UserManager.getUser(oneAdmin);
|
||||||
long offLineTime = user.getPlayerInfoManager().getOffLineTime();
|
long offLineTime = user.getPlayerInfoManager().getOffLineTime();
|
||||||
if(now-offLineTime> TimeUnit.DAYS.toMillis(7)){
|
if(!sessionMap.containsKey(oneAdmin)&&now-offLineTime> TimeUnit.DAYS.toMillis(7)){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(value.getUid()==0){
|
if(value.getUid()==0){
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,12 @@
|
||||||
package com.ljsd.jieling.thread.task;
|
package com.ljsd.jieling.thread.task;
|
||||||
|
|
||||||
import com.ljsd.jieling.core.GlobalsDef;
|
import com.ljsd.jieling.core.GlobalsDef;
|
||||||
|
import com.ljsd.jieling.logic.OnlineUserManager;
|
||||||
import com.ljsd.jieling.logic.dao.GuilidManager;
|
import com.ljsd.jieling.logic.dao.GuilidManager;
|
||||||
import com.ljsd.jieling.logic.dao.UserManager;
|
import com.ljsd.jieling.logic.dao.UserManager;
|
||||||
import com.ljsd.jieling.logic.dao.root.GuildInfo;
|
import com.ljsd.jieling.logic.dao.root.GuildInfo;
|
||||||
import com.ljsd.jieling.logic.dao.root.User;
|
import com.ljsd.jieling.logic.dao.root.User;
|
||||||
|
import com.ljsd.jieling.network.session.ISession;
|
||||||
import com.ljsd.jieling.thread.ThreadManager;
|
import com.ljsd.jieling.thread.ThreadManager;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
@ -29,6 +31,7 @@ public class GuildCheckOfflineTask implements GeneralTask {
|
||||||
Map<Integer, GuildInfo> guildInfoMap = GuilidManager.guildInfoMap;
|
Map<Integer, GuildInfo> guildInfoMap = GuilidManager.guildInfoMap;
|
||||||
Set<Integer> chairmanChangeGuilds = new HashSet<>();
|
Set<Integer> chairmanChangeGuilds = new HashSet<>();
|
||||||
Set<Integer> releaseGuilds = new HashSet<>();
|
Set<Integer> releaseGuilds = new HashSet<>();
|
||||||
|
Map<Integer, ISession> sessionMap = OnlineUserManager.sessionMap;
|
||||||
for(Map.Entry<Integer, GuildInfo> entry:guildInfoMap.entrySet()){
|
for(Map.Entry<Integer, GuildInfo> entry:guildInfoMap.entrySet()){
|
||||||
LOGGER.info("{}公会已开始离线检测",entry.getKey());
|
LOGGER.info("{}公会已开始离线检测",entry.getKey());
|
||||||
GuildInfo value = entry.getValue();
|
GuildInfo value = entry.getValue();
|
||||||
|
|
@ -45,7 +48,7 @@ public class GuildCheckOfflineTask implements GeneralTask {
|
||||||
LOGGER.error("{}公会会长数据为空id=>{}",entry.getKey(),chairmanId);
|
LOGGER.error("{}公会会长数据为空id=>{}",entry.getKey(),chairmanId);
|
||||||
}else{
|
}else{
|
||||||
long offLineTime = user.getPlayerInfoManager().getOffLineTime();
|
long offLineTime = user.getPlayerInfoManager().getOffLineTime();
|
||||||
if(now-offLineTime> TimeUnit.DAYS.toMillis(7)){
|
if(!sessionMap.containsKey(chairmanId)&&now-offLineTime> TimeUnit.DAYS.toMillis(7)){
|
||||||
LOGGER.error("{}公会会长{}需要替换",entry.getKey(),chairmanId);
|
LOGGER.error("{}公会会长{}需要替换",entry.getKey(),chairmanId);
|
||||||
chairmanChangeGuilds.add(entry.getKey());
|
chairmanChangeGuilds.add(entry.getKey());
|
||||||
if(now-offLineTime<TimeUnit.DAYS.toMillis(15)){
|
if(now-offLineTime<TimeUnit.DAYS.toMillis(15)){
|
||||||
|
|
@ -70,7 +73,7 @@ public class GuildCheckOfflineTask implements GeneralTask {
|
||||||
LOGGER.error("{}公会官员数据需要修理==>{}",entry.getKey(),uid);
|
LOGGER.error("{}公会官员数据需要修理==>{}",entry.getKey(),uid);
|
||||||
}else{
|
}else{
|
||||||
long offLineTime = user.getPlayerInfoManager().getOffLineTime();
|
long offLineTime = user.getPlayerInfoManager().getOffLineTime();
|
||||||
if(now-offLineTime<TimeUnit.DAYS.toMillis(15)){
|
if(sessionMap.containsKey(uid)||now-offLineTime<TimeUnit.DAYS.toMillis(15)){
|
||||||
isNeedRelease = false;
|
isNeedRelease = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -89,7 +92,7 @@ public class GuildCheckOfflineTask implements GeneralTask {
|
||||||
LOGGER.error("{}公会会员数据需要修理==>{}",entry.getKey(),uid);
|
LOGGER.error("{}公会会员数据需要修理==>{}",entry.getKey(),uid);
|
||||||
}else{
|
}else{
|
||||||
long offLineTime = user.getPlayerInfoManager().getOffLineTime();
|
long offLineTime = user.getPlayerInfoManager().getOffLineTime();
|
||||||
if(now-offLineTime<TimeUnit.DAYS.toMillis(15)){
|
if(sessionMap.containsKey(uid)||now-offLineTime<TimeUnit.DAYS.toMillis(15)){
|
||||||
isNeedRelease = false;
|
isNeedRelease = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -105,7 +108,7 @@ public class GuildCheckOfflineTask implements GeneralTask {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ThreadManager.commitGeneralTask(new GuildChangeTask(chairmanChangeGuilds,releaseGuilds));
|
ThreadManager.commitGeneralTask(new GuildChangeTask(chairmanChangeGuilds,releaseGuilds,now));
|
||||||
LOGGER.info("=-------公会检测结束-------");
|
LOGGER.info("=-------公会检测结束-------");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue