修复路由器扫描问题
This commit is contained in:
parent
59477d518a
commit
e0751972a3
@ -31,22 +31,24 @@ public class MiRouter extends Model {
|
|||||||
@Override
|
@Override
|
||||||
public void onMessage(Long qq, MessageEvent event, boolean isGroup) {
|
public void onMessage(Long qq, MessageEvent event, boolean isGroup) {
|
||||||
super.onMessage(qq, event, isGroup);
|
super.onMessage(qq, event, isGroup);
|
||||||
if(msg.equals(QQFromCommands.ROUTER_ADD)){
|
if (msg.equals(QQFromCommands.ROUTER_ADD)) {
|
||||||
String url="http://192.168.31.88:8002/router/device/add.do?qq="+qq;
|
String url = "http://192.168.31.88:8002/router/device/add.do?qq=" + qq;
|
||||||
QQBotManager.getInstance().sendMessage(qq,"点击该链接完成设备添加:\n"+url);
|
QQBotManager.getInstance().sendMessage(qq, "点击该链接完成设备添加:\n" + url);
|
||||||
}else if(msg.equals(QQFromCommands.ROUTER_DEL)){
|
} else if (msg.equals(QQFromCommands.ROUTER_DEL)) {
|
||||||
String url="http://192.168.31.88:8002/router/device/del.do?qq="+qq;
|
String url = "http://192.168.31.88:8002/router/device/del.do?qq=" + qq;
|
||||||
QQBotManager.getInstance().sendMessage(qq,"点击该删除设备:\n"+url);
|
QQBotManager.getInstance().sendMessage(qq, "点击该删除设备:\n" + url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private static boolean isRunTime=false;
|
|
||||||
|
private static boolean isRunTime = false;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTime(String time) {
|
public void onTime(String time) {
|
||||||
super.onTime(time);
|
super.onTime(time);
|
||||||
if(isRunTime){
|
if (isRunTime) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
isRunTime=true;
|
isRunTime = true;
|
||||||
String url = XiaoMiRouter.getDeviceListUrl();
|
String url = XiaoMiRouter.getDeviceListUrl();
|
||||||
JSONObject json = JSONObject.parseObject(HttpTools.get(url));
|
JSONObject json = JSONObject.parseObject(HttpTools.get(url));
|
||||||
if (json.getInteger("code") == 0) {
|
if (json.getInteger("code") == 0) {
|
||||||
@ -68,6 +70,7 @@ public class MiRouter extends Model {
|
|||||||
builder.append(item.getString("oname"));
|
builder.append(item.getString("oname"));
|
||||||
builder.append(" 欢迎回家!").append("\n");
|
builder.append(" 欢迎回家!").append("\n");
|
||||||
builder.append("点击该链接开门:").append("\n");
|
builder.append("点击该链接开门:").append("\n");
|
||||||
|
builder.append("http://192.168.31.88:802/openDoor.html");
|
||||||
QQBotManager.getInstance().sendMessage(_device.getLong("qq"), builder.toString());
|
QQBotManager.getInstance().sendMessage(_device.getLong("qq"), builder.toString());
|
||||||
_device.put("online", true);
|
_device.put("online", true);
|
||||||
_device.put("name", item.getString("oname"));
|
_device.put("name", item.getString("oname"));
|
||||||
@ -82,7 +85,7 @@ public class MiRouter extends Model {
|
|||||||
devices = (JSONArray) devs.clone();
|
devices = (JSONArray) devs.clone();
|
||||||
for (Object device : devices) {
|
for (Object device : devices) {
|
||||||
JSONObject item = (JSONObject) device;
|
JSONObject item = (JSONObject) device;
|
||||||
if (!links.contains(item.getString("mac"))&&item.getLong("linkTime")!=0) {
|
if (!links.contains(item.getString("mac")) && item.getLong("linkTime") != 0) {
|
||||||
devs.remove(device);
|
devs.remove(device);
|
||||||
String builder = "你的设备:" +
|
String builder = "你的设备:" +
|
||||||
item.getString("name") +
|
item.getString("name") +
|
||||||
@ -90,13 +93,13 @@ public class MiRouter extends Model {
|
|||||||
"在线时长:" + getOnLineTime(item.getString("linkTime")) + "\n";
|
"在线时长:" + getOnLineTime(item.getString("linkTime")) + "\n";
|
||||||
QQBotManager.getInstance().sendMessage(item.getLong("qq"), builder);
|
QQBotManager.getInstance().sendMessage(item.getLong("qq"), builder);
|
||||||
item.put("online", false);
|
item.put("online", false);
|
||||||
item.put("linkTime",0);
|
item.put("linkTime", 0);
|
||||||
devs.add(item);
|
devs.add(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
RedisTools.set(redis_key, devs.toJSONString());
|
RedisTools.set(redis_key, devs.toJSONString());
|
||||||
isRunTime=false;
|
|
||||||
}
|
}
|
||||||
|
isRunTime = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getOnLineTime(String online) {
|
private String getOnLineTime(String online) {
|
||||||
|
Loading…
Reference in New Issue
Block a user