|
|
@@ -133,10 +133,21 @@ public class JMXSyncService {
|
|
|
String userName = gateWayUserInfo.getUserName();
|
|
|
this.applicationContext.getBeansOfType(PlatformTopic.class).values().forEach((it) -> {
|
|
|
String topic = String.format(it.topic(), userName);
|
|
|
- security.add(topic);
|
|
|
- security.add(String.format("%s/#", topic));
|
|
|
+ if (StringUtils.isNotEmpty(topic)) {
|
|
|
+ security.add(topic);
|
|
|
+ if (!topic.endsWith("#")) {
|
|
|
+ security.add(String.format("%s/#", topic));
|
|
|
+ }
|
|
|
+ }
|
|
|
});
|
|
|
|
|
|
+ mqtt2User.setGateWayUserInfo(gateWayUserInfo);
|
|
|
+ mqtt2User.setUserName(gateWayUserInfo.getUserName());
|
|
|
+
|
|
|
+ mqtt2User.setMqttInfo(mqttInfo);
|
|
|
+ mqtt2User.setMqttInfoName(mqttInfo.getName());
|
|
|
+ mqtt2User.setPlatformSecurity(security);
|
|
|
+
|
|
|
if (ObjectUtils.isNotEmpty(security)) {
|
|
|
List<String> securites = security.stream().distinct().collect(Collectors.toList());
|
|
|
String roleName = gateWayUserInfo.getRoleName();
|
|
|
@@ -146,18 +157,12 @@ public class JMXSyncService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- mqtt2User.setGateWayUserInfo(gateWayUserInfo);
|
|
|
- mqtt2User.setUserName(gateWayUserInfo.getUserName());
|
|
|
-
|
|
|
- mqtt2User.setMqttInfo(mqttInfo);
|
|
|
- mqtt2User.setMqttInfoName(mqttInfo.getName());
|
|
|
-
|
|
|
mqtt2User.setIsSync(Boolean.TRUE);
|
|
|
mqtt2User.setSyncTime(System.currentTimeMillis());
|
|
|
mqtt2User.setSyncTimeStr(DateUtils.paresTime(System.currentTimeMillis(), DateUtils.FORMAT_LONG));
|
|
|
mqtt2User.setMsg("同步成功");
|
|
|
} catch (Exception e) {
|
|
|
- log.error("syncMqttUsers: {}", e.getMessage());
|
|
|
+ log.error("syncMqttUsers: {} {}", e.getMessage());
|
|
|
mqtt2User.setIsSync(Boolean.FALSE);
|
|
|
mqtt2User.setMsg(String.format("同步失败:%s", e.getMessage()));
|
|
|
}
|
|
|
@@ -262,7 +267,7 @@ public class JMXSyncService {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 同步网关可监听的权限
|
|
|
+ * 同步网关可监听的权限 (网管绑定的用户,对应的设备权限)
|
|
|
*
|
|
|
* @param mqttInfo
|
|
|
* @param gateWayInfos
|
|
|
@@ -282,7 +287,6 @@ public class JMXSyncService {
|
|
|
|
|
|
for (DeviceInfo gateWayInfo : gateWayInfos) {
|
|
|
// 以前的权限
|
|
|
- List<GateWayMqttSecurity> list = gateWayMqttSecurityDao.findByMqttInfoAndGateWayInfo(mqttInfo, gateWayInfo);
|
|
|
gateWayMqttSecurityDao.deleteByMqttInfoAndGateWayInfo(mqttInfo, gateWayInfo);
|
|
|
|
|
|
String userName = gateWayInfo.getMqttUserName();
|