完成向上级联->保存时注册或注销
This commit is contained in:
parent
4ed02aa69b
commit
56bfa58efd
@ -75,10 +75,19 @@ public class PlatformController {
|
|||||||
}
|
}
|
||||||
// TODO 检查是否已经存在,且注册成功, 如果注册成功,需要先注销之前再,修改并注册
|
// TODO 检查是否已经存在,且注册成功, 如果注册成功,需要先注销之前再,修改并注册
|
||||||
|
|
||||||
|
ParentPlatform parentPlatformOld = storager.queryParentPlatById(parentPlatform.getDeviceGBId());
|
||||||
|
|
||||||
boolean updateResult = storager.updateParentPlatform(parentPlatform);
|
boolean updateResult = storager.updateParentPlatform(parentPlatform);
|
||||||
|
|
||||||
if (updateResult) {
|
if (updateResult) {
|
||||||
|
// 保存时启用就发送注册
|
||||||
|
if (parentPlatform.isEnable()) {
|
||||||
|
// 只要保存就发送注册
|
||||||
commanderForPlatform.register(parentPlatform);
|
commanderForPlatform.register(parentPlatform);
|
||||||
|
}else if (parentPlatformOld != null && parentPlatformOld.isEnable() && !parentPlatform.isEnable()){ // 关闭启用时注销
|
||||||
|
commanderForPlatform.unregister(parentPlatform, null, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return new ResponseEntity<>("success", HttpStatus.OK);
|
return new ResponseEntity<>("success", HttpStatus.OK);
|
||||||
}else {
|
}else {
|
||||||
@ -98,7 +107,7 @@ public class PlatformController {
|
|||||||
return new ResponseEntity<>("missing parameters", HttpStatus.BAD_REQUEST);
|
return new ResponseEntity<>("missing parameters", HttpStatus.BAD_REQUEST);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 发送离线消息,
|
// 发送离线消息,无论是否成功都删除缓存
|
||||||
commanderForPlatform.unregister(parentPlatform, (event -> {
|
commanderForPlatform.unregister(parentPlatform, (event -> {
|
||||||
// 清空redis缓存
|
// 清空redis缓存
|
||||||
redisCatchStorage.delPlatformCatchInfo(parentPlatform.getDeviceGBId());
|
redisCatchStorage.delPlatformCatchInfo(parentPlatform.getDeviceGBId());
|
||||||
|
Loading…
Reference in New Issue
Block a user