fix 获取连接
parent
c6b07df79b
commit
296db9bb3b
|
@ -16,6 +16,11 @@ import java.util.List;
|
|||
* Date 2024/5/28 21:49
|
||||
*/
|
||||
public interface ConnectService {
|
||||
/**
|
||||
* 获取连接
|
||||
* @param vehicleConnectionReq
|
||||
* @return
|
||||
*/
|
||||
Result<MqttServerModel> getConnect(VehicleConnectionReq vehicleConnectionReq);
|
||||
|
||||
void LoadCenterAdd(LoadEnterNumber loadEnterNumber);
|
||||
|
|
|
@ -47,7 +47,6 @@ public class ConnectServiceImpl implements ConnectService {
|
|||
} else {
|
||||
redisTemplate.opsForValue().set("subscript", String.valueOf(count + 1));
|
||||
}
|
||||
|
||||
String ip = redisTemplate.opsForList().index("ips", count);
|
||||
return Result.success(new MqttServerModel("tcp://" + ip + ":1883", "test1"));
|
||||
} finally {
|
||||
|
@ -63,38 +62,7 @@ public class ConnectServiceImpl implements ConnectService {
|
|||
lock.unlock(); // 释放锁
|
||||
}
|
||||
}
|
||||
// @Override
|
||||
// public Result<MqttServerModel> getConnect(VehicleConnectionReq vehicleConnectionReq) {
|
||||
// // 检查Redis中连接次数"count"是否存在
|
||||
// if (redisTemplate.hasKey("count")){
|
||||
// // 获取当前连接次数
|
||||
// Integer count = Integer.valueOf(redisTemplate.opsForValue().get("count"));
|
||||
// // 当连接次数达到100时,重置连接次数为0
|
||||
// if (count == 100){
|
||||
// redisTemplate.opsForValue().set("count", String.valueOf(0));
|
||||
// }else{
|
||||
// // 连接次数未达到100,递增连接次数
|
||||
// redisTemplate.opsForValue().set("count", String.valueOf(count+1));
|
||||
// }
|
||||
// // 根据当前连接次数,获取对应的IP地址
|
||||
// String ip = redisTemplate.opsForList().index("ipList", count);
|
||||
// long timestamp = System.currentTimeMillis();
|
||||
// this.insert(new VinIp(vehicleConnectionReq.getVehicleVin(), ip,timestamp));
|
||||
// // 创建并返回Mqtt服务器模型
|
||||
// MqttServerModel mqttServerModel = new MqttServerModel("tcp://" + ip + ":1883", "test1");
|
||||
// return Result.success(mqttServerModel);
|
||||
// }else{
|
||||
// // "count"不存在时,初始化连接次数为1
|
||||
// redisTemplate.opsForValue().set("count", String.valueOf(1));
|
||||
// // 获取列表中的第一个IP地址
|
||||
// String s = redisTemplate.opsForList().index("ipList", 0);
|
||||
// long timestamp = System.currentTimeMillis();
|
||||
// this.insert(new VinIp(vehicleConnectionReq.getVehicleVin(), s,timestamp));
|
||||
// // 创建并返回第一个IP地址对应的Mqtt服务器模型
|
||||
// MqttServerModel test1 = new MqttServerModel("tcp://" + s + ":1883", "test1");
|
||||
// return Result.success(test1);
|
||||
// }
|
||||
// }
|
||||
|
||||
}
|
||||
/**
|
||||
* 添加负载中心
|
||||
|
|
Loading…
Reference in New Issue