TRX 1 год назад
Родитель
Сommit
0262032e6a

+ 1 - 1
OneCardIotClient/src/main/java/com/zhongshu/iot/client/model/iot/IotTemplateModel.java

@@ -36,7 +36,7 @@ public class IotTemplateModel extends SuperModel {
     @Schema(description = "关联code,产品code")
     private String productCode;
 
-    @Schema(description = "产品品类,直连设备、网关子设备、网关设备")
+    @Schema(description = "设备节点产品品类,直连设备、网关子设备、网关设备")
     private DeviceCategory deviceCategory;
 
     private String deviceCategoryStr;

+ 43 - 0
OneCardIotServer/src/main/java/com/zhongshu/iot/server/core/controller/common/CommonController.java

@@ -0,0 +1,43 @@
+package com.zhongshu.iot.server.core.controller.common;
+
+import com.github.microservice.auth.security.annotations.ResourceAuth;
+import com.github.microservice.auth.security.type.AuthType;
+import com.github.microservice.net.ResultContent;
+import com.zhongshu.iot.server.core.service.base.CommonService;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * 设备管理 服务
+ *
+ * @author TRX
+ * @date 2024/3/21
+ */
+@RequestMapping("/common")
+@RestController
+@Validated
+@Tag(name = "通用功能管理")
+public class CommonController {
+
+    @Autowired
+    private CommonService commonService;
+
+    @ResourceAuth(value = "user", type = AuthType.User)
+    @Operation(summary = "设备类型 选择项")
+    @RequestMapping(value = "getDeviceType", method = {RequestMethod.GET})
+    public ResultContent getDeviceType() {
+        return ResultContent.buildSuccess(commonService.getEnumListModel());
+    }
+
+    @ResourceAuth(value = "user", type = AuthType.User)
+    @Operation(summary = "设备节点 选择项")
+    @RequestMapping(value = "getDeviceCategory", method = {RequestMethod.GET})
+    public ResultContent getDeviceCategory() {
+        return ResultContent.buildSuccess(commonService.getDeviceCategory());
+    }
+}

+ 19 - 0
OneCardIotServer/src/main/java/com/zhongshu/iot/server/core/service/base/CommonService.java

@@ -1,5 +1,8 @@
 package com.zhongshu.iot.server.core.service.base;
 
+import com.github.microservice.models.common.EnumListModel;
+import com.github.microservice.types.deviceUse.DeviceCategory;
+import com.github.microservice.types.deviceUse.DeviceType;
 import com.mongodb.client.result.UpdateResult;
 import com.zhongshu.iot.server.core.util.CommonUtil;
 import lombok.extern.slf4j.Slf4j;
@@ -25,6 +28,22 @@ public class CommonService {
     @Autowired
     private MongoTemplate mongoTemplate;
 
+    public EnumListModel getEnumListModel() {
+        EnumListModel model = new EnumListModel();
+        for (DeviceType deviceType1 : DeviceType.values()) {
+            model.add(deviceType1.getRemark(), deviceType1.name());
+        }
+        return model;
+    }
+
+    public EnumListModel getDeviceCategory() {
+        EnumListModel model = new EnumListModel();
+        for (DeviceCategory deviceType1 : DeviceCategory.values()) {
+            model.add(deviceType1.getRemark(), deviceType1.name());
+        }
+        return model;
+    }
+
     /**
      * 编辑数据
      *

+ 2 - 2
OneCardIotServer/src/main/java/com/zhongshu/iot/server/core/service/iot/IotServiceImpl.java

@@ -480,7 +480,7 @@ public class IotServiceImpl extends SuperService {
             DeviceInfo deviceInfo = deviceInfoDao.findTopByDeviceId(deviceId);
             if (ObjectUtils.isNotEmpty(deviceInfo)) {
                 GateWay2Device gateWay2Device = gateWay2DeviceDao.findTopByDeviceInfoOrderByUpdateTimeDesc(deviceInfo);
-                if (ObjectUtils.isNotEmpty(gateWay2Device)) {
+                if (ObjectUtils.isNotEmpty(gateWay2Device) && gateWay2Device.getGateWayInfo() != null) {
                     String gateWayId = gateWay2Device.getGateWayInfo().getDeviceId();
                     realIotTopic = realIotTopic.replaceAll(Pattern.quote("${gateWayId}"), gateWayId);
                     replyRealIotTopic = replyRealIotTopic.replaceAll(Pattern.quote("${gateWayId}"), gateWayId);
@@ -492,7 +492,7 @@ public class IotServiceImpl extends SuperService {
                 realIotTopic = realIotTopic.replaceAll(Pattern.quote("${gateWayId}"), deviceInfo.getDeviceId());
                 replyRealIotTopic = replyRealIotTopic.replaceAll(Pattern.quote("${gateWayId}"), deviceInfo.getDeviceId());
             }
-            
+
             iotMain.setRealIotTopic(realIotTopic);
             iotMain.setReplyRealIotTopic(replyRealIotTopic);
         }

+ 4 - 27
OneCardIotServer/src/main/java/com/zhongshu/iot/server/core/util/JMXUtil.java

@@ -3,10 +3,10 @@ package com.zhongshu.iot.server.core.util;
 import cn.hutool.json.JSONArray;
 import cn.hutool.json.JSONObject;
 import com.github.microservice.net.ResultContent;
+import com.google.common.collect.Lists;
 import com.zhongshu.iot.server.core.dataConfig.DeviceConfig;
 import com.zhongshu.iot.server.core.dataConfig.MqttConfig;
 import com.zhongshu.iot.server.core.domain.iot.device.DeviceInfo;
-import com.zhongshu.iot.server.core.domain.iot.device.GateWayUserInfo;
 import com.zhongshu.iot.server.core.domain.iot.device.MqttInfo;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.ObjectUtils;
@@ -74,16 +74,6 @@ public class JMXUtil {
         return list;
     }
 
-    public static List<String> buildAddressMatch(List<DeviceInfo> deviceInfoList) {
-        List<String> list = new ArrayList<String>();
-        if (ObjectUtils.isNotEmpty(deviceInfoList)) {
-            deviceInfoList.stream().forEach(deviceInfo -> {
-                list.add(String.format("/device/%s/#", deviceInfo.getDeviceId()));
-            });
-        }
-        return list;
-    }
-
     public static List<String> buildDeviceAddressMatch(DeviceInfo deviceInfo) {
         List<String> list = new ArrayList<String>();
         if (ObjectUtils.isNotEmpty(deviceInfo)) {
@@ -93,23 +83,10 @@ public class JMXUtil {
     }
 
     public static List<String> buildGateWayAddressMatch(DeviceInfo gateWayInfo) {
-        List<String> list = new ArrayList<String>();
-        if (ObjectUtils.isNotEmpty(gateWayInfo)) {
-            list.add(String.format("/device/%s/#", gateWayInfo.getDeviceId()));
-        }
-        return list;
-    }
-
-    public static List<String> buildGateWayUserDefault(GateWayUserInfo gateWayUserInfo) {
-        List<String> list = new ArrayList<>();
-        if (ObjectUtils.isNotEmpty(gateWayUserInfo)) {
-            list.add(String.format("/platform/%s/register", gateWayUserInfo.getUserName()));
-            list.add(String.format("/platform/%s/ping", gateWayUserInfo.getUserName()));
-            list.add(String.format("/platform/%s/onLine", gateWayUserInfo.getUserName()));
-            list.add(String.format("/platform/%s/unLine", gateWayUserInfo.getUserName()));
-            list.add(String.format("/platform/%s/systemTime", gateWayUserInfo.getUserName()));
+        if (ObjectUtils.isEmpty(gateWayInfo)) {
+            return Lists.newArrayList();
         }
-        return list;
+        return List.of(String.format("/device/%s/#", gateWayInfo.getDeviceId()));
     }
 
     public static String buildSecurityRoleName(String roleName) {