TRX před 1 rokem
rodič
revize
ee7979f3ed

+ 2 - 1
OneCardIotServer/src/main/java/com/zhongshu/iot/server/core/dataConfig/MqttConfig.java

@@ -13,6 +13,7 @@ public class MqttConfig {
 
     // 本地处理的事件名称
     public static final List<String> localHandelEvent = List.of("ping", "ServerTime",
-            "registGateway", "registDevice");
+            "registGateway", "registDevice", "systemTime",
+            "online", "offline");
 
 }

+ 0 - 1
OneCardIotServer/src/main/java/com/zhongshu/iot/server/core/service/device/GateWayInfoService.java

@@ -9,7 +9,6 @@ import com.github.microservice.models.type.OnLineState;
 import com.github.microservice.models.type.RegistType;
 import com.github.microservice.net.ResultContent;
 import com.zhongshu.iot.client.model.mqtt.*;
-import com.zhongshu.iot.client.type.type.LogsLevel;
 import com.zhongshu.iot.server.core.dao.mqtt.*;
 import com.zhongshu.iot.server.core.domain.iot.mqtt.*;
 import com.zhongshu.iot.server.core.httpRequest.ApiRequestService;

+ 6 - 0
OneCardIotServer/src/main/java/com/zhongshu/iot/server/core/service/device/GateWayUserInfoService.java

@@ -245,6 +245,9 @@ public class GateWayUserInfoService {
         }
         entity.setPassWord(CommonUtil.generateRandomString(16));
         gateWayUserInfoDao.save(entity);
+
+        // 同步用户
+        jmxSyncService.syncUserToMQTTService(entity);
         return ResultContent.buildSuccess();
     }
 
@@ -349,6 +352,9 @@ public class GateWayUserInfoService {
         if (ObjectUtils.isEmpty(entity)) {
             return ResultContent.buildFail(String.format("%s 账号不存在", param.getUserName()));
         }
+        if (entity.getIsShow() == null || !entity.getIsShow()) {
+            return ResultContent.buildFail("不能删除");
+        }
         gateWayUserInfoDao.delete(entity);
 
         // 删除服务文件上的用户

+ 3 - 1
OneCardIotServer/src/main/java/com/zhongshu/iot/server/core/service/device/JMXSyncService.java

@@ -126,7 +126,9 @@ public class JMXSyncService {
                         addressControl.addUser(gateWayUserInfo.getUserName(), gateWayUserInfo.getPassWord(), gateWayUserInfo.getRoleName(), false);
                         String userName = gateWayUserInfo.getUserName();
                         this.applicationContext.getBeansOfType(PlatformTopic.class).values().forEach((it) -> {
-                            security.add(String.format(it.topic(), userName));
+                            String topic = String.format(it.topic(), userName);
+                            security.add(topic);
+                            security.add(String.format("%s/#", topic));
                         });
                         if (ObjectUtils.isNotEmpty(security)) {
                             List<String> securites = security.stream().distinct().collect(Collectors.toList());

+ 11 - 6
OneCardIotServer/src/main/java/com/zhongshu/iot/server/core/service/device/ServerTimeService.java → OneCardIotServer/src/main/java/com/zhongshu/iot/server/core/service/iotPlatform/impl/ServerTimeService.java

@@ -1,10 +1,10 @@
-package com.zhongshu.iot.server.core.service.device;
+package com.zhongshu.iot.server.core.service.iotPlatform.impl;
 
 import com.github.microservice.models.hxz.ServerTimeResult;
+import com.github.microservice.net.ResultContent;
 import com.zhongshu.iot.server.core.domain.ExecuteAnnotationService;
 import com.zhongshu.iot.server.core.domain.ExecuteAnnotationServiceMethod;
-import com.zhongshu.iot.server.core.service.base.SuperService;
-import com.github.microservice.net.ResultContent;
+import com.zhongshu.iot.server.core.service.iotPlatform.PlatformTopic;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Service;
 
@@ -21,16 +21,21 @@ import java.util.Map;
 @Slf4j
 @Service
 @ExecuteAnnotationService
-public class ServerTimeService extends SuperService {
+public class ServerTimeService implements PlatformTopic {
+
+    @Override
+    public String topic() {
+        return "/platform/%s/serverTime";
+    }
 
     /**
      * 云版消费机的使用 (获取系统时间)
      *
-     * @param str
+     * @param
      * @return
      */
     @ExecuteAnnotationServiceMethod(value = "ServerTime", remark = "服务器时间")
-    public ResultContent ServerTime(String str) {
+    public ResultContent action(String dataId, String message) {
         var nowTime = new Date(System.currentTimeMillis());
         ServerTimeResult result = new ServerTimeResult();
         LocalDate date = LocalDate.now();

+ 11 - 4
OneCardIotServer/src/main/java/com/zhongshu/iot/server/core/service/iotPlatform/impl/SystemTimeTopic.java

@@ -1,18 +1,21 @@
 package com.zhongshu.iot.server.core.service.iotPlatform.impl;
 
+import com.github.microservice.models.hxz.SystemTimeResult;
 import com.github.microservice.net.ResultContent;
 import com.zhongshu.iot.server.core.domain.ExecuteAnnotationService;
+import com.zhongshu.iot.server.core.domain.ExecuteAnnotationServiceMethod;
 import com.zhongshu.iot.server.core.service.iotPlatform.PlatformTopic;
+import com.zhongshu.iot.server.core.util.DateUtils;
 import lombok.extern.slf4j.Slf4j;
-import org.springframework.stereotype.Component;
+import org.springframework.stereotype.Service;
 
 /**
  * @author TRX
  * @date 2025/1/13
  */
-@Component
-@ExecuteAnnotationService
 @Slf4j
+@Service
+@ExecuteAnnotationService
 public class SystemTimeTopic implements PlatformTopic {
 
     @Override
@@ -20,9 +23,13 @@ public class SystemTimeTopic implements PlatformTopic {
         return "/platform/%s/systemTime";
     }
 
+    @ExecuteAnnotationServiceMethod(value = "systemTime", remark = "服务器时间")
     @Override
     public ResultContent<Object> action(String topic, String message) {
-        return ResultContent.buildSuccess();
+        SystemTimeResult result = new SystemTimeResult();
+        result.setSuccess();
+        result.setTime(DateUtils.paresTime(System.currentTimeMillis(), DateUtils.FORMAT_LONG));
+        return ResultContent.buildSuccess(result);
     }
 
 }