添加机器人到redis
parent
a7241242f3
commit
f341e34989
|
|
@ -10,15 +10,17 @@ import java.util.concurrent.TimeUnit;
|
|||
import com.data.cache.AccountCache;
|
||||
import com.data.cache.GroupCache;
|
||||
import com.taurus.core.entity.ITArray;
|
||||
import com.taurus.core.entity.ITObject;
|
||||
import com.taurus.core.plugin.database.DataBase;
|
||||
import com.taurus.core.plugin.redis.Redis;
|
||||
import com.taurus.core.routes.Extension;
|
||||
import com.taurus.core.routes.Routes;
|
||||
|
||||
import com.taurus.permanent.TPServer;
|
||||
import hunan.DoTest;
|
||||
//import hunan.DoTest;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import redis.clients.jedis.Jedis;
|
||||
import taurus.client.NetManager;
|
||||
|
||||
|
||||
|
|
@ -75,7 +77,7 @@ public class MainServer extends Extension {
|
|||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
System.out.println("开始创建机器人连接...");
|
||||
System.out.println("开始创建机器人连接1111111");
|
||||
// QingChu qingChu = new QingChu();
|
||||
// qingChu.qingchu();
|
||||
|
||||
|
|
@ -114,19 +116,46 @@ public class MainServer extends Extension {
|
|||
* 把机器人加载到redis2
|
||||
*/
|
||||
private void loadGroupRobot(){
|
||||
|
||||
Jedis jedis2 = Redis.use("group1_db2").getJedis();
|
||||
try {
|
||||
String sql = String.format("SELECT id FROM `account` WHERE jiqiren=9998 and start = 0");
|
||||
String sql = String.format("SELECT id,acc,nick,portrait,password FROM `account` WHERE jiqiren=9998 and start = 0");
|
||||
ITArray robotIds = DataBase.use().executeQueryByTArray(sql);
|
||||
HashMap<String, String> robotMap = new HashMap<>();
|
||||
|
||||
//遍历机器人,
|
||||
for(int i = 0; i < robotIds.size(); ++i) {
|
||||
//把机器人按group 分类好 存放到redis2
|
||||
// //把机器人按group 分类好 存放到redis2
|
||||
|
||||
ITObject robot = robotIds.getTObject(i);
|
||||
Integer robotId = robot.getInt("id");
|
||||
String robotAcc = robot.getString("acc");
|
||||
String robotNick = robot.getString("nick");
|
||||
String robotPortrait = robot.getString("portrait");
|
||||
String robotPassword = robot.getString("password");
|
||||
|
||||
robotMap.put("acc", robotAcc);
|
||||
robotMap.put("nick", robotNick);
|
||||
robotMap.put("portrait", robotPortrait);
|
||||
robotMap.put("password", robotPassword);
|
||||
jedis2.hmset("{robot}:" + robotId , robotMap);
|
||||
|
||||
// String sqls = String.format("UPDATE `account` SET start = %d WHERE id = %d", 1, robotId);
|
||||
// DataBase.use().executeUpdate(sqls);
|
||||
}
|
||||
|
||||
} catch (SQLException e) {
|
||||
|
||||
Map<String,String> gRobotMap = new HashMap<>();
|
||||
gRobotMap.put("start", "0");
|
||||
gRobotMap.put("pid", "66");
|
||||
jedis2.hmset("{Grobot}:"+101666, gRobotMap);
|
||||
|
||||
|
||||
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}finally {
|
||||
jedis2.close();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue