Переглянути джерело

更新! 取消GateWay信息

TRX 1 рік тому
батько
коміт
83d9bc19da
34 змінених файлів з 418 додано та 932 видалено
  1. 1 2
      OneCardIotClient/src/main/java/com/zhongshu/iot/client/model/artemis/OperationMessageModel.java
  2. 42 57
      OneCardIotServer/src/main/java/com/zhongshu/iot/server/core/controller/devices/GateWayController.java
  3. 0 38
      OneCardIotServer/src/main/java/com/zhongshu/iot/server/core/controller/free/GateWayFreeController.java
  4. 4 1
      OneCardIotServer/src/main/java/com/zhongshu/iot/server/core/dao/mqtt/DeviceInfoDao.java
  5. 2 3
      OneCardIotServer/src/main/java/com/zhongshu/iot/server/core/dao/mqtt/GateWay2DeviceDao.java
  6. 3 3
      OneCardIotServer/src/main/java/com/zhongshu/iot/server/core/dao/mqtt/GateWay2UserDao.java
  7. 0 21
      OneCardIotServer/src/main/java/com/zhongshu/iot/server/core/dao/mqtt/GateWayInfoDao.java
  8. 3 3
      OneCardIotServer/src/main/java/com/zhongshu/iot/server/core/dao/mqtt/GateWayMqttSecurityDao.java
  9. 0 15
      OneCardIotServer/src/main/java/com/zhongshu/iot/server/core/dao/mqtt/extend/GateWayInfoDaoExtend.java
  10. 0 72
      OneCardIotServer/src/main/java/com/zhongshu/iot/server/core/dao/mqtt/impl/GateWayInfoDaoImpl.java
  11. 2 2
      OneCardIotServer/src/main/java/com/zhongshu/iot/server/core/domain/docker/AkSkConfig.java
  12. 3 3
      OneCardIotServer/src/main/java/com/zhongshu/iot/server/core/domain/iot/mqtt/DeviceOnLineInfo.java
  13. 1 1
      OneCardIotServer/src/main/java/com/zhongshu/iot/server/core/domain/iot/mqtt/GateWay2Device.java
  14. 1 1
      OneCardIotServer/src/main/java/com/zhongshu/iot/server/core/domain/iot/mqtt/GateWay2User.java
  15. 0 67
      OneCardIotServer/src/main/java/com/zhongshu/iot/server/core/domain/iot/mqtt/GateWayInfo.java
  16. 1 1
      OneCardIotServer/src/main/java/com/zhongshu/iot/server/core/domain/iot/mqtt/GateWayMqttSecurity.java
  17. 1 1
      OneCardIotServer/src/main/java/com/zhongshu/iot/server/core/domain/iot/mqtt/OperationMessage.java
  18. 1 1
      OneCardIotServer/src/main/java/com/zhongshu/iot/server/core/service/artemis/OperationMessageService.java
  19. 13 1
      OneCardIotServer/src/main/java/com/zhongshu/iot/server/core/service/device/DeviceInfoService.java
  20. 22 140
      OneCardIotServer/src/main/java/com/zhongshu/iot/server/core/service/device/DevicePingInfoService.java
  21. 281 288
      OneCardIotServer/src/main/java/com/zhongshu/iot/server/core/service/device/GateWayInfoService.java
  22. 5 7
      OneCardIotServer/src/main/java/com/zhongshu/iot/server/core/service/device/GateWayUserInfoService.java
  23. 14 14
      OneCardIotServer/src/main/java/com/zhongshu/iot/server/core/service/device/JMXSyncService.java
  24. 1 31
      OneCardIotServer/src/main/java/com/zhongshu/iot/server/core/service/device/MqttInfoService.java
  25. 1 13
      OneCardIotServer/src/main/java/com/zhongshu/iot/server/core/service/fix/FixDataService.java
  26. 6 11
      OneCardIotServer/src/main/java/com/zhongshu/iot/server/core/service/iot/IotSendMessageService.java
  27. 1 1
      OneCardIotServer/src/main/java/com/zhongshu/iot/server/core/service/iot/IotServiceImpl.java
  28. 2 3
      OneCardIotServer/src/main/java/com/zhongshu/iot/server/core/service/iot/IotTemplateManagerService.java
  29. 0 27
      OneCardIotServer/src/main/java/com/zhongshu/iot/server/core/service/iot/IotThing2DeviceService.java
  30. 2 1
      OneCardIotServer/src/main/java/com/zhongshu/iot/server/core/service/iot/IotThingService.java
  31. 0 35
      OneCardIotServer/src/main/java/com/zhongshu/iot/server/core/service/iotPlatform/impl/RegisterGatewayTopic.java
  32. 2 61
      OneCardIotServer/src/main/java/com/zhongshu/iot/server/core/service/sync/DeviceSyncFullCardService.java
  33. 0 3
      OneCardIotServer/src/main/java/com/zhongshu/iot/server/core/timers/CheckDeviceStateWork.java
  34. 3 4
      OneCardIotServer/src/main/java/com/zhongshu/iot/server/core/util/JMXUtil.java

+ 1 - 2
OneCardIotClient/src/main/java/com/zhongshu/iot/client/model/artemis/OperationMessageModel.java

@@ -2,7 +2,6 @@ package com.zhongshu.iot.client.model.artemis;
 
 import com.zhongshu.iot.client.model.baseParam.SuperModel;
 import com.zhongshu.iot.client.model.mqtt.DeviceInfoModel;
-import com.zhongshu.iot.client.model.mqtt.GateWayInfoModel;
 import com.zhongshu.iot.client.type.OperationType;
 import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.Data;
@@ -53,7 +52,7 @@ public class OperationMessageModel extends SuperModel {
     private String deviceId;
 
     @Schema(description = "关于的网关信息")
-    private GateWayInfoModel gateWayInfo;
+    private DeviceInfoModel gateWayInfo;
 
     @Schema(description = "网关ID")
     private String gateWayId;

+ 42 - 57
OneCardIotServer/src/main/java/com/zhongshu/iot/server/core/controller/devices/GateWayController.java

@@ -1,25 +1,8 @@
 package com.zhongshu.iot.server.core.controller.devices;
 
-import com.github.microservice.auth.security.annotations.ResourceAuth;
-import com.github.microservice.auth.security.type.AuthType;
-import com.zhongshu.iot.client.model.mqtt.GateWayBindDeviceParam;
-import com.zhongshu.iot.client.model.mqtt.GateWayInfoAddParam;
-import com.zhongshu.iot.client.model.mqtt.GateWayInfoModel;
-import com.zhongshu.iot.client.model.mqtt.GateWayInfoSearchParam;
-import com.zhongshu.iot.server.core.service.device.GateWayInfoService;
-import com.github.microservice.net.ResultContent;
-import io.swagger.v3.oas.annotations.Operation;
-import io.swagger.v3.oas.annotations.Parameter;
 import io.swagger.v3.oas.annotations.tags.Tag;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.data.domain.Page;
-import org.springframework.data.domain.Pageable;
-import org.springframework.data.web.PageableDefault;
-import org.springframework.util.Assert;
 import org.springframework.validation.annotation.Validated;
-import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.RestController;
 
 /**
@@ -32,47 +15,49 @@ import org.springframework.web.bind.annotation.RestController;
 @RestController
 @Validated
 @Tag(name = "网关管理")
+@Deprecated
 public class GateWayController {
 
-    @Autowired
-    GateWayInfoService gateWayInfoService;
+//    @Autowired
+//    GateWayInfoService gateWayInfoService;
+//
+//    @ResourceAuth(value = "user", type = AuthType.User)
+//    @Operation(summary = "添加网关")
+//    @RequestMapping(value = "addDeviceInfo", method = {RequestMethod.POST})
+//    public ResultContent addDeviceInfo(@RequestBody GateWayInfoAddParam param) {
+//        Assert.hasText(param.getGateWayId(), "网关ID不能为空");
+//        Assert.hasText(param.getGateWayName(), "网关名称不能为空");
+//        return gateWayInfoService.addGateWayInfo(param);
+//    }
+//
+//    @ResourceAuth(value = "user", type = AuthType.User)
+//    @Operation(summary = "网关列表-分页查询")
+//    @RequestMapping(value = {"pageGateWay"}, method = {RequestMethod.POST})
+//    public ResultContent<Page<GateWayInfoModel>> pageGateWay(@Parameter(hidden = true) @PageableDefault(page = 0, size = 10) Pageable pageable, GateWayInfoSearchParam param) {
+//        return gateWayInfoService.pageGateWay(pageable, param);
+//    }
+//
+//    @ResourceAuth(value = "user", type = AuthType.User)
+//    @Operation(summary = "删除网关")
+//    @RequestMapping(value = "deleteGateWayInfo", method = {RequestMethod.GET})
+//    public ResultContent deleteGateWayInfo(String gateWayId) {
+//        return gateWayInfoService.deleteGateWayInfo(gateWayId);
+//    }
+//
+//    @ResourceAuth(value = "user", type = AuthType.User)
+//    @Operation(summary = "查询网关")
+//    @RequestMapping(value = "getGateWayById", method = {RequestMethod.GET})
+//    public ResultContent<GateWayInfoModel> getGateWayById(String deviceId) {
+//        return gateWayInfoService.getById(deviceId);
+//    }
+//
+//    @ResourceAuth(value = "user", type = AuthType.User)
+//    @Operation(summary = "网关绑定设备、连接账号")
+//    @RequestMapping(value = "gateWayBindDevice", method = {RequestMethod.POST})
+//    public ResultContent gateWayBindDevice(@RequestBody GateWayBindDeviceParam param) {
+//        Assert.hasText(param.getGateWayId(), "网关ID不能为空");
+//        Assert.hasText(param.getUserName(), "连接账号不能为空");
+//        return gateWayInfoService.gateWayBindDevice(param);
+//    }
 
-    @ResourceAuth(value = "user", type = AuthType.User)
-    @Operation(summary = "添加网关")
-    @RequestMapping(value = "addDeviceInfo", method = {RequestMethod.POST})
-    public ResultContent addDeviceInfo(@RequestBody GateWayInfoAddParam param) {
-        Assert.hasText(param.getGateWayId(), "网关ID不能为空");
-        Assert.hasText(param.getGateWayName(), "网关名称不能为空");
-        return gateWayInfoService.addGateWayInfo(param);
-    }
-
-    @ResourceAuth(value = "user", type = AuthType.User)
-    @Operation(summary = "网关列表-分页查询")
-    @RequestMapping(value = {"pageGateWay"}, method = {RequestMethod.POST})
-    public ResultContent<Page<GateWayInfoModel>> pageGateWay(@Parameter(hidden = true) @PageableDefault(page = 0, size = 10) Pageable pageable, GateWayInfoSearchParam param) {
-        return gateWayInfoService.pageGateWay(pageable, param);
-    }
-
-    @ResourceAuth(value = "user", type = AuthType.User)
-    @Operation(summary = "删除网关")
-    @RequestMapping(value = "deleteGateWayInfo", method = {RequestMethod.GET})
-    public ResultContent deleteGateWayInfo(String gateWayId) {
-        return gateWayInfoService.deleteGateWayInfo(gateWayId);
-    }
-
-    @ResourceAuth(value = "user", type = AuthType.User)
-    @Operation(summary = "查询网关")
-    @RequestMapping(value = "getGateWayById", method = {RequestMethod.GET})
-    public ResultContent<GateWayInfoModel> getGateWayById(String deviceId) {
-        return gateWayInfoService.getById(deviceId);
-    }
-
-    @ResourceAuth(value = "user", type = AuthType.User)
-    @Operation(summary = "网关绑定设备、连接账号")
-    @RequestMapping(value = "gateWayBindDevice", method = {RequestMethod.POST})
-    public ResultContent gateWayBindDevice(@RequestBody GateWayBindDeviceParam param) {
-        Assert.hasText(param.getGateWayId(), "网关ID不能为空");
-        Assert.hasText(param.getUserName(), "连接账号不能为空");
-        return gateWayInfoService.gateWayBindDevice(param);
-    }
 }

+ 0 - 38
OneCardIotServer/src/main/java/com/zhongshu/iot/server/core/controller/free/GateWayFreeController.java

@@ -1,18 +1,10 @@
 package com.zhongshu.iot.server.core.controller.free;
 
 import com.github.microservice.net.ResultContent;
-import com.zhongshu.iot.client.model.mqtt.GateWayBindDeviceParam;
-import com.zhongshu.iot.client.model.mqtt.GateWayInfoAddParam;
-import com.zhongshu.iot.client.model.mqtt.MqttInfoReturnModel;
-import com.zhongshu.iot.server.core.service.base.AkSignService;
-import com.zhongshu.iot.server.core.service.device.GateWayInfoService;
 import io.swagger.v3.oas.annotations.Operation;
 import io.swagger.v3.oas.annotations.tags.Tag;
 import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.util.Assert;
 import org.springframework.validation.annotation.Validated;
-import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.RestController;
@@ -30,36 +22,6 @@ import org.springframework.web.bind.annotation.RestController;
 @Slf4j
 public class GateWayFreeController {
 
-    @Autowired
-    GateWayInfoService gateWayInfoService;
-
-    @Autowired
-    private AkSignService akSignService;
-
-    @Operation(summary = "注册网关")
-    @RequestMapping(value = "registerGateWay", method = {RequestMethod.POST})
-    public ResultContent<MqttInfoReturnModel> registerGateWay(@RequestBody GateWayInfoAddParam param) {
-        Assert.hasText(param.getGateWayId(), "网关ID不能为空");
-        ResultContent resultContent = akSignService.verifyAk(param.getAk(), param.getTime(), param.getSign(), param.getGateWayId());
-        if (resultContent.isFailed()) {
-            return resultContent;
-        }
-        log.info("-----------------------注册网关---------------------- {}", param);
-        return gateWayInfoService.registerGateWay(param);
-    }
-
-    @Operation(summary = "网关绑定设备")
-    @RequestMapping(value = "gateWayBindDevice", method = {RequestMethod.POST})
-    public ResultContent gateWayBindDevice(@RequestBody GateWayBindDeviceParam param) {
-        Assert.hasText(param.getGateWayId(), "网关ID不能为空");
-        ResultContent resultContent = akSignService.verifyAk(param.getAk(), param.getTime(), param.getSign(), param.getGateWayId());
-        if (resultContent.isFailed()) {
-            return resultContent;
-        }
-        log.info("-------------------------网关绑定设备------------------------: {}", param);
-        return gateWayInfoService.gateWayBindDevice(param);
-    }
-
     @Operation(summary = "ServerTime")
     @RequestMapping(value = "ServerTime", method = {RequestMethod.GET})
     public ResultContent ServerTime() {

+ 4 - 1
OneCardIotServer/src/main/java/com/zhongshu/iot/server/core/dao/mqtt/DeviceInfoDao.java

@@ -1,5 +1,6 @@
 package com.zhongshu.iot.server.core.dao.mqtt;
 
+import com.github.microservice.types.deviceUse.DeviceCategory;
 import com.github.microservice.types.deviceUse.RegistType;
 import com.zhongshu.iot.server.core.dao.mqtt.extend.DeviceInfoDaoExtend;
 import com.zhongshu.iot.server.core.domain.iot.mqtt.DeviceInfo;
@@ -20,10 +21,12 @@ public interface DeviceInfoDao extends DeviceInfoDaoExtend, org.springframework.
 
     List<DeviceInfo> findByDeviceIdIn(List<String> deviceIds);
 
-    long countByMqttUserNameAndIsDelete(String mqttUserName, Boolean isDelete);
+    long countByMqttUserNameAndIsDeleteAndDeviceCategory(String mqttUserName, Boolean isDelete, DeviceCategory deviceCategory);
 
     List<DeviceInfo> findByRegistTypeIn(List<RegistType> registTypes);
 
     Long countByProductCode(String productCode);
 
+    List<DeviceInfo> findByDeviceCategory(DeviceCategory deviceCategory);
+
 }

+ 2 - 3
OneCardIotServer/src/main/java/com/zhongshu/iot/server/core/dao/mqtt/GateWay2DeviceDao.java

@@ -2,7 +2,6 @@ package com.zhongshu.iot.server.core.dao.mqtt;
 
 import com.zhongshu.iot.server.core.domain.iot.mqtt.DeviceInfo;
 import com.zhongshu.iot.server.core.domain.iot.mqtt.GateWay2Device;
-import com.zhongshu.iot.server.core.domain.iot.mqtt.GateWayInfo;
 
 import java.util.List;
 
@@ -12,12 +11,12 @@ import java.util.List;
  */
 public interface GateWay2DeviceDao extends org.springframework.data.mongodb.repository.MongoRepository<GateWay2Device, String> {
 
-    GateWay2Device findTopByGateWayInfoAndDeviceInfo(GateWayInfo gateWayInfo, DeviceInfo deviceInfo);
+    GateWay2Device findTopByGateWayInfoAndDeviceInfo(DeviceInfo gateWayInfo, DeviceInfo deviceInfo);
 
     // 根据设备查询绑定关系
     List<GateWay2Device> findByDeviceInfo(DeviceInfo deviceInfo);
 
-    List<GateWay2Device> findByGateWayInfo(GateWayInfo gateWayInfo);
+    List<GateWay2Device> findByGateWayInfo(DeviceInfo gateWayInfo);
 
     GateWay2Device findTopByDeviceInfoOrderByUpdateTimeDesc(DeviceInfo deviceInfo);
 }

+ 3 - 3
OneCardIotServer/src/main/java/com/zhongshu/iot/server/core/dao/mqtt/GateWay2UserDao.java

@@ -1,7 +1,7 @@
 package com.zhongshu.iot.server.core.dao.mqtt;
 
+import com.zhongshu.iot.server.core.domain.iot.mqtt.DeviceInfo;
 import com.zhongshu.iot.server.core.domain.iot.mqtt.GateWay2User;
-import com.zhongshu.iot.server.core.domain.iot.mqtt.GateWayInfo;
 import com.zhongshu.iot.server.core.domain.iot.mqtt.GateWayUserInfo;
 
 /**
@@ -12,7 +12,7 @@ public interface GateWay2UserDao extends org.springframework.data.mongodb.reposi
 
     GateWay2User findTopByGateWayUserInfo(GateWayUserInfo gateWayUserInfo);
 
-    GateWay2User findTopByGateWayInfo(GateWayInfo gateWayInfo);
+    GateWay2User findTopByGateWayInfo(DeviceInfo gateWayInfo);
 
-    GateWay2User findTopByGateWayInfoOrderByCreateTimeDesc(GateWayInfo gateWayInfo);
+    GateWay2User findTopByGateWayInfoOrderByCreateTimeDesc(DeviceInfo gateWayInfo);
 }

+ 0 - 21
OneCardIotServer/src/main/java/com/zhongshu/iot/server/core/dao/mqtt/GateWayInfoDao.java

@@ -1,21 +0,0 @@
-package com.zhongshu.iot.server.core.dao.mqtt;
-
-import com.zhongshu.iot.server.core.dao.mqtt.extend.GateWayInfoDaoExtend;
-import com.zhongshu.iot.server.core.domain.iot.mqtt.GateWayInfo;
-
-import java.util.List;
-
-/**
- * @author TRX
- * @date 2024/3/21
- */
-public interface GateWayInfoDao extends GateWayInfoDaoExtend, org.springframework.data.mongodb.repository.MongoRepository<GateWayInfo, String> {
-
-    GateWayInfo findTopById(String id);
-
-    GateWayInfo findTopByGateWayId(String gateWayId);
-
-    List<GateWayInfo> findByGateWayIdIn(List<String> gateWayIds);
-
-    long countByMqttUserNameAndIsDelete(String mqttUserName, Boolean isDelete);
-}

+ 3 - 3
OneCardIotServer/src/main/java/com/zhongshu/iot/server/core/dao/mqtt/GateWayMqttSecurityDao.java

@@ -1,6 +1,6 @@
 package com.zhongshu.iot.server.core.dao.mqtt;
 
-import com.zhongshu.iot.server.core.domain.iot.mqtt.GateWayInfo;
+import com.zhongshu.iot.server.core.domain.iot.mqtt.DeviceInfo;
 import com.zhongshu.iot.server.core.domain.iot.mqtt.GateWayMqttSecurity;
 import com.zhongshu.iot.server.core.domain.iot.mqtt.MqttInfo;
 
@@ -14,9 +14,9 @@ public interface GateWayMqttSecurityDao extends org.springframework.data.mongodb
 
     GateWayMqttSecurity findTopById(String id);
 
-    List<GateWayMqttSecurity> findByMqttInfoAndGateWayInfo(MqttInfo mqttInfo, GateWayInfo gateWayInfo);
+    List<GateWayMqttSecurity> findByMqttInfoAndGateWayInfo(MqttInfo mqttInfo, DeviceInfo gateWayInfo);
 
-    void deleteByMqttInfoAndGateWayInfo(MqttInfo mqttInfo, GateWayInfo gateWayInfo);
+    void deleteByMqttInfoAndGateWayInfo(MqttInfo mqttInfo, DeviceInfo gateWayInfo);
 
     void deleteByMqttInfoAndAddressMatch(MqttInfo mqttInfo, String addressMatch);
 

+ 0 - 15
OneCardIotServer/src/main/java/com/zhongshu/iot/server/core/dao/mqtt/extend/GateWayInfoDaoExtend.java

@@ -1,15 +0,0 @@
-package com.zhongshu.iot.server.core.dao.mqtt.extend;
-
-import com.zhongshu.iot.server.core.domain.iot.mqtt.GateWayInfo;
-import com.zhongshu.iot.client.model.mqtt.GateWayInfoSearchParam;
-import org.springframework.data.domain.Page;
-import org.springframework.data.domain.Pageable;
-
-/**
- * @Author TRX
- * @CreateDate: 2023/7/7
- * @Version: 1.0
- */
-public interface GateWayInfoDaoExtend {
-    Page<GateWayInfo> page(Pageable pageable, GateWayInfoSearchParam param);
-}

+ 0 - 72
OneCardIotServer/src/main/java/com/zhongshu/iot/server/core/dao/mqtt/impl/GateWayInfoDaoImpl.java

@@ -1,72 +0,0 @@
-package com.zhongshu.iot.server.core.dao.mqtt.impl;
-
-import com.zhongshu.iot.server.core.dao.base.BaseImpl;
-import com.zhongshu.iot.server.core.dao.mqtt.extend.GateWayInfoDaoExtend;
-import com.zhongshu.iot.server.core.domain.iot.mqtt.GateWayInfo;
-import com.github.microservice.components.data.mongo.mongo.helper.DBHelper;
-import com.zhongshu.iot.client.model.mqtt.GateWayInfoSearchParam;
-import org.apache.commons.lang3.StringUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.data.domain.Page;
-import org.springframework.data.domain.Pageable;
-import org.springframework.data.domain.Sort;
-import org.springframework.data.mongodb.core.MongoTemplate;
-import org.springframework.data.mongodb.core.query.Criteria;
-import org.springframework.data.mongodb.core.query.Query;
-import org.springframework.util.CollectionUtils;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.regex.Pattern;
-
-/**
- * @Author TRX
- * @CreateDate: 2023/4/12
- * @Version: 1.0
- */
-public class GateWayInfoDaoImpl extends BaseImpl implements GateWayInfoDaoExtend {
-
-    @Autowired
-    private MongoTemplate mongoTemplate;
-
-    @Autowired
-    private DBHelper dbHelper;
-
-    @Override
-    public Page<GateWayInfo> page(Pageable pageable, GateWayInfoSearchParam param) {
-        Criteria criteria = new Criteria();
-
-        if (StringUtils.isNotEmpty(param.getGateWayId())) {
-            criteria.and("gateWayId").is(param.getGateWayId());
-        }
-
-        if (StringUtils.isNotEmpty(param.getEpId())) {
-            criteria.and("epId").is(param.getEpId());
-        }
-
-        if (param.getOnLineState() != null) {
-            criteria.and("onLineState").is(param.getOnLineState());
-        }
-
-        // 模糊搜索
-        List<Criteria> criterias = new ArrayList<>();
-        if (StringUtils.isNotEmpty(param.getGateWayName())) {
-            Pattern pattern = Pattern.compile("^.*" + param.getGateWayName() + ".*$");
-            criterias.add(Criteria.where("gateWayName").is(pattern));
-        }
-        if (StringUtils.isNotEmpty(param.getName())) {
-            Pattern pattern = Pattern.compile("^.*" + param.getName() + ".*$");
-            criterias.add(Criteria.where("gateWayName").is(pattern));
-        }
-        if (!CollectionUtils.isEmpty(criterias)) {
-            criteria.andOperator(criterias.toArray(new Criteria[]{}));
-        }
-
-        criteria.and("isDelete").is(Boolean.FALSE);
-        Sort sort = buildSort(param);
-        Query query = Query.query(criteria);
-        query.with(sort);
-        return dbHelper.pages(query, pageable, GateWayInfo.class);
-    }
-
-}

+ 2 - 2
OneCardIotServer/src/main/java/com/zhongshu/iot/server/core/domain/docker/AkSkConfig.java

@@ -2,7 +2,7 @@ package com.zhongshu.iot.server.core.domain.docker;
 
 import com.zhongshu.iot.client.type.DataState;
 import com.zhongshu.iot.server.core.domain.base.SuperEntity;
-import com.zhongshu.iot.server.core.domain.iot.mqtt.GateWayInfo;
+import com.zhongshu.iot.server.core.domain.iot.mqtt.DeviceInfo;
 import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.AllArgsConstructor;
 import lombok.Data;
@@ -33,7 +33,7 @@ public class AkSkConfig extends SuperEntity {
 
     @Schema(description = "关联的网关信息")
     @DBRef(lazy = true)
-    private GateWayInfo gateWayInfo;
+    private DeviceInfo gateWayInfo;
 
     @Schema(description = "关联使用的数据ID")
     private String aboutDataId;

+ 3 - 3
OneCardIotServer/src/main/java/com/zhongshu/iot/server/core/domain/iot/mqtt/DeviceOnLineInfo.java

@@ -1,6 +1,6 @@
 package com.zhongshu.iot.server.core.domain.iot.mqtt;
 
-import com.github.microservice.types.deviceUse.OnLineDeviceType;
+import com.github.microservice.types.deviceUse.DeviceCategory;
 import com.zhongshu.iot.server.core.domain.base.SuperEntity;
 import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.AllArgsConstructor;
@@ -27,8 +27,8 @@ public class DeviceOnLineInfo extends SuperEntity {
     @Schema(description = "设备名称、网关名称")
     private String deviceName;
 
-    @Schema(description = "")
-    private OnLineDeviceType onLineDeviceType;
+    @Schema(description = "设备品类")
+    private DeviceCategory deviceCategory;
 
     @Schema(description = "最后在线时间")
     private String timeStr;

+ 1 - 1
OneCardIotServer/src/main/java/com/zhongshu/iot/server/core/domain/iot/mqtt/GateWay2Device.java

@@ -23,7 +23,7 @@ public class GateWay2Device extends SuperEntity {
 
     @DBRef(lazy = true)
     @Schema(description = "硬件设备网关信息")
-    private GateWayInfo gateWayInfo;
+    private DeviceInfo gateWayInfo;
 
     @Schema(description = "网关id")
     private String gateWayId;

+ 1 - 1
OneCardIotServer/src/main/java/com/zhongshu/iot/server/core/domain/iot/mqtt/GateWay2User.java

@@ -22,7 +22,7 @@ public class GateWay2User extends SuperEntity {
 
     @DBRef(lazy = true)
     @Schema(description = "硬件设备网关信息")
-    private GateWayInfo gateWayInfo;
+    private DeviceInfo gateWayInfo;
 
     @Schema(description = "网关ID")
     private String gateWayId;

+ 0 - 67
OneCardIotServer/src/main/java/com/zhongshu/iot/server/core/domain/iot/mqtt/GateWayInfo.java

@@ -1,67 +0,0 @@
-package com.zhongshu.iot.server.core.domain.iot.mqtt;
-
-import com.github.microservice.types.deviceUse.DeviceState;
-import com.github.microservice.types.deviceUse.OnLineState;
-import com.zhongshu.iot.server.core.domain.base.SuperEntity;
-import io.swagger.v3.oas.annotations.media.Schema;
-import lombok.AllArgsConstructor;
-import lombok.Data;
-import lombok.NoArgsConstructor;
-import org.springframework.data.mongodb.core.mapping.DBRef;
-import org.springframework.data.mongodb.core.mapping.Document;
-
-/**
- * 物联网 硬件设备  网关信息
- *
- * @author TRX
- * @date 2024/5/14
- */
-@Data
-@Document
-@NoArgsConstructor
-@AllArgsConstructor
-public class GateWayInfo extends SuperEntity {
-
-    @Schema(description = "设备code,产品code")
-    private String productCode;
-
-    @Schema(description = "mqtt账号名称")
-    private String mqttUserName;
-
-    @Schema(description = "网关ID")
-    private String gateWayId;
-
-    @Schema(description = "网关名称")
-    private String gateWayName;
-
-    @Schema(description = "网关状态")
-    private DeviceState state = DeviceState.Enable;
-
-    @Schema(description = "ip地址")
-    private String ip;
-
-    @Schema(description = "网关在线状态")
-    private OnLineState onLineState;
-
-    @Schema(description = "所属项目")
-    @DBRef(lazy = true)
-    private ProjectInfo projectInfo;
-
-    @Schema(description = "项目code")
-    private String projectInfoCode;
-
-    @Schema(description = "激活时间")
-    private Long activityTime;
-
-    @Schema(description = "最上线时间")
-    private Long lastOnlineTime;
-
-    @Schema(description = "最后下线时间")
-    private Long lastOfflineTime;
-
-    @Schema(description = "最大可连接失败数量")
-    private Long maxConnectDevices = 10L;
-
-    @Schema(description = "心跳间隔,单位:秒")
-    private Long hbInterval = 30l;
-}

+ 1 - 1
OneCardIotServer/src/main/java/com/zhongshu/iot/server/core/domain/iot/mqtt/GateWayMqttSecurity.java

@@ -27,7 +27,7 @@ public class GateWayMqttSecurity extends SuperEntity {
 
     @Schema(description = "网关信息信息")
     @DBRef(lazy = true)
-    private GateWayInfo gateWayInfo;
+    private DeviceInfo gateWayInfo;
 
     @Schema(description = "网关ID")
     private String gateWayId;

+ 1 - 1
OneCardIotServer/src/main/java/com/zhongshu/iot/server/core/domain/iot/mqtt/OperationMessage.java

@@ -71,7 +71,7 @@ public class OperationMessage extends SuperEntity {
     private String deviceId;
 
     @Schema(description = "关于的网关信息")
-    private GateWayInfo gateWayInfo;
+    private DeviceInfo gateWayInfo;
 
     @Schema(description = "网关ID")
     private String gateWayId;

+ 1 - 1
OneCardIotServer/src/main/java/com/zhongshu/iot/server/core/service/artemis/OperationMessageService.java

@@ -684,7 +684,7 @@ public class OperationMessageService {
         if (ObjectUtils.isNotEmpty(entity)) {
             BeanUtils.copyProperties(entity, model);
             model.setDeviceInfo(deviceInfoService.toModel(entity.getDeviceInfo()));
-            model.setGateWayInfo(gateWayInfoService.toModel(entity.getGateWayInfo()));
+            model.setGateWayInfo(deviceInfoService.toModel(entity.getGateWayInfo()));
         }
         return model;
     }

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

@@ -2,6 +2,7 @@ package com.zhongshu.iot.server.core.service.device;
 
 import com.github.microservice.net.ResultContent;
 import com.github.microservice.types.FunctionType;
+import com.github.microservice.types.deviceUse.DeviceCategory;
 import com.github.microservice.types.deviceUse.DeviceState;
 import com.github.microservice.types.deviceUse.OnLineState;
 import com.zhongshu.iot.client.model.iot.IotMainModel;
@@ -359,11 +360,22 @@ public class DeviceInfoService {
         return ResultContent.buildSuccess(model);
     }
 
+    //---------------------------网关数据 start-----------------
+
+    /**
+     * 得到所有的网关数据
+     *
+     * @return
+     */
+    public List<DeviceInfo> getAllGateWayDevices() {
+        return deviceInfoDao.findByDeviceCategory(DeviceCategory.GW);
+    }
+    //---------------------------网关数据 end-------------------
+
     public DeviceInfoModel toModel(DeviceInfo deviceInfo) {
         DeviceInfoModel deviceInfoModel = new DeviceInfoModel();
         if (ObjectUtils.isNotEmpty(deviceInfo)) {
             BeanUtils.copyProperties(deviceInfo, deviceInfoModel);
-//            deviceInfoModel.setIotTemplate(iotService.toModel(deviceInfo.getIotTemplate()));
             deviceInfoModel.setProjectInfo(projectInfoService.toModel(deviceInfo.getProjectInfo()));
         }
         return deviceInfoModel;

+ 22 - 140
OneCardIotServer/src/main/java/com/zhongshu/iot/server/core/service/device/DevicePingInfoService.java

@@ -5,16 +5,17 @@ import com.github.microservice.models.hxz.DevicePingInfoParam;
 import com.github.microservice.models.hxz.GateWayPingInfoParam;
 import com.github.microservice.models.hxz.PingResult;
 import com.github.microservice.net.ResultContent;
-import com.github.microservice.types.deviceUse.DeviceType;
 import com.github.microservice.types.deviceUse.OnLineDeviceType;
 import com.github.microservice.types.deviceUse.OnLineState;
 import com.zhongshu.iot.server.core.dao.mqtt.DeviceInfoDao;
 import com.zhongshu.iot.server.core.dao.mqtt.DeviceOnLineInfoDao;
 import com.zhongshu.iot.server.core.dao.mqtt.DevicePingInfoDao;
-import com.zhongshu.iot.server.core.dao.mqtt.GateWayInfoDao;
 import com.zhongshu.iot.server.core.dataConfig.CommonTTLTimeConfig;
 import com.zhongshu.iot.server.core.domain.iot.IotThing2Device;
-import com.zhongshu.iot.server.core.domain.iot.mqtt.*;
+import com.zhongshu.iot.server.core.domain.iot.mqtt.DeviceInfo;
+import com.zhongshu.iot.server.core.domain.iot.mqtt.DeviceOnLineInfo;
+import com.zhongshu.iot.server.core.domain.iot.mqtt.DevicePingInfo;
+import com.zhongshu.iot.server.core.domain.iot.mqtt.GateWay2Device;
 import com.zhongshu.iot.server.core.service.base.CommonService;
 import com.zhongshu.iot.server.core.service.base.RedisService;
 import com.zhongshu.iot.server.core.service.base.SuperService;
@@ -51,15 +52,19 @@ public class DevicePingInfoService extends SuperService {
     @Autowired
     private DeviceSyncFullCardService deviceSyncFullCardService;
 
-    @Autowired
-    private GateWayInfoDao gateWayInfoDao;
-
     @Autowired
     private DeviceOnLineInfoDao deviceOnLineInfoDao;
 
     @Autowired
     private RedisService redisService;
 
+    /**
+     * 设备ping
+     *
+     * @param dataId
+     * @param dataStr
+     * @return
+     */
     private ResultContent<Object> devicePing(String dataId, String dataStr) {
         DevicePingInfoParam param = JSONUtil.toBean(dataStr, DevicePingInfoParam.class);
         String deviceId = param.getDeviceId();
@@ -96,7 +101,7 @@ public class DevicePingInfoService extends SuperService {
             deviceSyncFullCardService.noticeSyncDeviceOnlineTimeChange(deviceId);
 
             // 设备在线状态
-            updateDeviceOnLine(deviceInfo.getDeviceId(), deviceInfo.getDeviceName(), OnLineDeviceType.Device);
+            updateDeviceOnLine(deviceInfo.getDeviceId(), deviceInfo.getDeviceName());
         } else {
             log.info("心跳设备未找到: {}", deviceId);
             return ResultContent.buildFail(String.format("设备不存在:%s", deviceId));
@@ -114,33 +119,6 @@ public class DevicePingInfoService extends SuperService {
                 pingResult.setFailed(resultContent.getMsg());
                 return ResultContent.buildSuccess(pingResult);
             }
-        } else if (StringUtils.isNotEmpty(param.getGateWayId())) {
-            log.info("ping 网关在线处理:{}", param.getGateWayId());
-            GateWayInfo gateWayInfo = gateWayInfoDao.findTopByGateWayId(param.getGateWayId());
-            if (ObjectUtils.isNotEmpty(gateWayInfo)) {
-                Map<String, Object> where = new HashMap<>();
-                where.put("gateWayId", gateWayInfo.getGateWayId());
-
-                Map<String, Object> standardData = new HashMap<>();
-                standardData.put("onLineState", OnLineState.OnLine);
-                standardData.put("lastOnlineTime", System.currentTimeMillis());
-                commonService.updateData(where, standardData, GateWayInfo.class.getSimpleName());
-
-                // ping记录
-                DevicePingInfo devicePingInfo = new DevicePingInfo();
-                devicePingInfo.setPingType(DeviceType.GateWay.name());
-                devicePingInfo.setGateWayId(param.getGateWayId());
-                devicePingInfo.setProjectInfoCode(gateWayInfo.getProjectInfoCode());
-                devicePingInfo.setTTL(new Date(System.currentTimeMillis() + CommonTTLTimeConfig.pingTTl));
-                devicePingInfo.setTimeStr(DateUtils.paresTime(System.currentTimeMillis(), DateUtils.FORMAT_LONG));
-                devicePingInfoDao.save(devicePingInfo);
-
-                // 网关在线状态
-                updateDeviceOnLine(gateWayInfo.getGateWayId(), gateWayInfo.getGateWayName(), OnLineDeviceType.GateWay);
-            } else {
-                pingResult.setFailed(String.format("网关不存在:%s", param.getGateWayId()));
-                return ResultContent.buildSuccess(pingResult);
-            }
         } else {
             pingResult.setFailed("ping设备不存在");
             return ResultContent.buildSuccess(pingResult);
@@ -150,7 +128,7 @@ public class DevicePingInfoService extends SuperService {
         return ResultContent.buildSuccess(pingResult);
     }
 
-    private void updateDeviceOnLine(String deviceId, String deviceName, OnLineDeviceType onLineDeviceType) {
+    private void updateDeviceOnLine(String deviceId, String deviceName) {
         DeviceOnLineInfo entity = deviceOnLineInfoDao.findTopByDeviceId(deviceId);
         if (ObjectUtils.isEmpty(entity)) {
             entity = new DeviceOnLineInfo();
@@ -161,21 +139,15 @@ public class DevicePingInfoService extends SuperService {
         entity.setDeviceName(deviceName);
         entity.setTTL(new Date(System.currentTimeMillis() + expireTime));
         entity.setTimeStr(DateUtils.paresTime(System.currentTimeMillis(), DateUtils.FORMAT_LONG));
-        entity.setOnLineDeviceType(onLineDeviceType);
+        entity.setDeviceCategory(entity.getDeviceCategory());
         deviceOnLineInfoDao.save(entity);
 
         long expirePeriod = CommonTTLTimeConfig.maxDeviceRedisOnLineTime;
-        if (onLineDeviceType == OnLineDeviceType.GateWay) {
-            GateWayInfo gateWayInfo = gateWayInfoDao.findTopByGateWayId(deviceId);
-            if (ObjectUtils.isNotEmpty(gateWayInfo) && gateWayInfo.getHbInterval() != null) {
-                expirePeriod = gateWayInfo.getHbInterval();
-            }
-        } else if (onLineDeviceType == OnLineDeviceType.Device) {
-            DeviceInfo deviceInfo = deviceInfoDao.findTopByDeviceId(deviceId);
-            if (ObjectUtils.isNotEmpty(deviceInfo) && deviceInfo.getHbInterval() != null) {
-                expirePeriod = deviceInfo.getHbInterval();
-            }
+        DeviceInfo deviceInfo = deviceInfoDao.findTopByDeviceId(deviceId);
+        if (ObjectUtils.isNotEmpty(deviceInfo) && deviceInfo.getHbInterval() != null) {
+            expirePeriod = deviceInfo.getHbInterval();
         }
+
         String expiredKey = String.format("%s%s", CommonTTLTimeConfig.OnLineExpiredKey, deviceId);
         redisService.setValueSECONDS(expiredKey, deviceName, expirePeriod);
     }
@@ -201,18 +173,10 @@ public class DevicePingInfoService extends SuperService {
 
         long expirePeriod = CommonTTLTimeConfig.maxDeviceRedisOnLineTime;
         if (ObjectUtils.isNotEmpty(entity)) {
-            if (entity.getOnLineDeviceType() == OnLineDeviceType.GateWay) {
-                GateWayInfo gateWayInfo = gateWayInfoDao.findTopByGateWayId(entity.getDeviceId());
-                gateWayCheckOnLineState(gateWayInfo);
-                if (ObjectUtils.isNotEmpty(gateWayInfo) && gateWayInfo.getHbInterval() != null) {
-                    expirePeriod = gateWayInfo.getHbInterval();
-                }
-            } else if (entity.getOnLineDeviceType() == OnLineDeviceType.Device) {
-                DeviceInfo deviceInfo = deviceInfoDao.findTopByDeviceId(entity.getDeviceId());
-                deviceCheckOnLineState(deviceInfo);
-                if (ObjectUtils.isNotEmpty(deviceInfo) && deviceInfo.getHbInterval() != null) {
-                    expirePeriod = deviceInfo.getHbInterval();
-                }
+            DeviceInfo deviceInfo = deviceInfoDao.findTopByDeviceId(entity.getDeviceId());
+            deviceCheckOnLineState(deviceInfo);
+            if (ObjectUtils.isNotEmpty(deviceInfo) && deviceInfo.getHbInterval() != null) {
+                expirePeriod = deviceInfo.getHbInterval();
             }
             String expiredKey = String.format("%s%s", CommonTTLTimeConfig.OnLineExpiredKey, entity.getDeviceId());
             redisService.setValueSECONDS(expiredKey, entity.getDeviceName(), expirePeriod);
@@ -299,86 +263,4 @@ public class DevicePingInfoService extends SuperService {
         deviceSyncFullCardService.noticeSyncDeviceOnlineStateChange(deviceId);
     }
 
-    /**
-     * 定期检查网关的状态
-     */
-    public void checkGateWayState() {
-        List<GateWayInfo> list = gateWayInfoDao.findAll();
-        if (ObjectUtils.isNotEmpty(list)) {
-            list.parallelStream().forEach(gateWayInfo -> {
-                gateWayCheckOnLineState(gateWayInfo);
-            });
-        }
-    }
-
-    private void gateWayCheckOnLineState(GateWayInfo gateWayInfo) {
-        if (ObjectUtils.isEmpty(gateWayInfo)) {
-            return;
-        }
-        long time = System.currentTimeMillis();
-        List<DevicePingInfo> _list = devicePingInfoDao.findTop5ByGateWayIdAndPingTypeOrderByCreateTimeDesc(gateWayInfo.getGateWayId(), DeviceType.GateWay.name());
-        // 默认离线
-        OnLineState onLineState = OnLineState.OffLine;
-        if (_list != null) {
-            long defaultTime = CommonTTLTimeConfig.maxUnPingOnLineTime;
-            if (gateWayInfo.getHbInterval() != null) {
-                defaultTime = gateWayInfo.getHbInterval() * 1000L * 1000;
-            }
-            Long firstTime = null;
-            long avgTime = 0;
-            if (_list.size() == 1) {
-                firstTime = _list.get(0).getCreateTime();
-                avgTime = defaultTime;
-            } else if (_list.size() > 2) {
-                firstTime = _list.get(0).getCreateTime();
-                Long lastTime = _list.get(_list.size() - 1).getCreateTime();
-                // 2 次心跳间隔时间
-                avgTime = ((firstTime - lastTime) / (_list.size() - 1)) * 2;
-                if (avgTime > defaultTime) {
-                    avgTime = defaultTime;
-                }
-            }
-            if (firstTime != null) {
-                // 根据ping数据判断是否在线
-                if ((time - firstTime) > avgTime) {
-                    onLineState = OnLineState.OffLine;
-                } else {
-                    onLineState = OnLineState.OnLine;
-                }
-            }
-        }
-
-        if (_list != null && _list.size() > 2) {
-            Long firstTime = _list.get(0).getCreateTime();
-            Long lastTime = _list.get(_list.size() - 1).getCreateTime();
-            // 2 次心跳间隔时间
-            long avgTime = ((firstTime - lastTime) / (_list.size() - 1)) * 2;
-            if (avgTime > CommonTTLTimeConfig.maxUnPingOnLineTime) {
-                avgTime = CommonTTLTimeConfig.maxUnPingOnLineTime;
-            }
-            // 根据ping数据判断是否在线
-            if ((time - firstTime) > avgTime) {
-                onLineState = OnLineState.OffLine;
-            }
-        }
-        if (ObjectUtils.isEmpty(_list)) {
-            onLineState = OnLineState.OffLine;
-        }
-
-        if (onLineState != gateWayInfo.getOnLineState()) {
-            log.info("网关在线状态改变:{} {}", gateWayInfo.getGateWayName(), onLineState);
-            updateGateWayOnLine(gateWayInfo.getId(), onLineState);
-        }
-    }
-
-    private void updateGateWayOnLine(String id, OnLineState onLineState) {
-        Map<String, Object> standardData = new HashMap<String, Object>();
-        standardData.put("id", id);
-        standardData.put("onLineState", onLineState);
-        if (onLineState == OnLineState.OffLine) {
-            standardData.put("lastOfflineTime", System.currentTimeMillis());
-        }
-        commonService.updateData(standardData, GateWayInfo.class.getSimpleName());
-    }
-
 }

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

@@ -1,22 +1,19 @@
 package com.zhongshu.iot.server.core.service.device;
 
 import cn.hutool.json.JSONUtil;
-import com.github.microservice.http.APIResponseModel;
 import com.github.microservice.models.common.CommonResult;
-import com.github.microservice.models.project.ProjectConfigQueryParam;
 import com.github.microservice.net.ResultContent;
 import com.github.microservice.types.deviceUse.DeviceCategory;
-import com.github.microservice.types.deviceUse.DeviceState;
 import com.github.microservice.types.deviceUse.OnLineState;
 import com.github.microservice.types.deviceUse.RegistType;
-import com.zhongshu.iot.client.model.mqtt.*;
+import com.zhongshu.iot.client.model.mqtt.DeviceInfoAddParam;
+import com.zhongshu.iot.client.model.mqtt.DeviceInfoRegistParam;
 import com.zhongshu.iot.client.type.IotDataType;
 import com.zhongshu.iot.server.core.dao.iot.IotTemplateDao;
 import com.zhongshu.iot.server.core.dao.mqtt.*;
 import com.zhongshu.iot.server.core.domain.iot.IotTemplate;
 import com.zhongshu.iot.server.core.domain.iot.mqtt.*;
 import com.zhongshu.iot.server.core.httpRequest.ApiRequestService;
-import com.zhongshu.iot.server.core.httpRequest.conf.FullCardAPIConfig;
 import com.zhongshu.iot.server.core.service.base.SuperService;
 import com.zhongshu.iot.server.core.service.iot.IotServiceImpl;
 import com.zhongshu.iot.server.core.service.iot.IotThingService;
@@ -25,7 +22,6 @@ import com.zhongshu.iot.server.core.util.DateUtils;
 import com.zhongshu.iot.server.core.util.JMXUtil;
 import com.zhongshu.iot.server.core.util.bean.BeanUtils;
 import com.zhongshu.iot.server.core.util.mqtt.MqttTopicUtils;
-import com.zhongshu.iot.server.core.util.page.PageEntityUtil;
 import lombok.Cleanup;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.activemq.artemis.api.core.management.ActiveMQServerControl;
@@ -33,8 +29,6 @@ import org.apache.activemq.artemis.api.core.management.ObjectNameBuilder;
 import org.apache.commons.lang3.ObjectUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.data.domain.Page;
-import org.springframework.data.domain.Pageable;
 import org.springframework.stereotype.Service;
 
 import javax.management.MBeanServerConnection;
@@ -53,14 +47,9 @@ import java.util.concurrent.CompletableFuture;
  */
 @Slf4j
 @Service
+@Deprecated
 public class GateWayInfoService extends SuperService {
 
-    @Autowired
-    private GateWayInfoDao gateWayInfoDao;
-
-    @Autowired
-    private GateWay2UserDao gateWay2UserDao;
-
     @Autowired
     private DeviceInfoService deviceInfoService;
 
@@ -102,119 +91,123 @@ public class GateWayInfoService extends SuperService {
 
     @Autowired
     private IotTemplateDao iotTemplateDao;
+
     @Autowired
     private IotThingService iotThingService;
 
-    /**
-     * 注册 网关
-     *
-     * @param dataStr
-     * @return
-     */
-    public ResultContent<Object> gateWayRegister(String dataId, String dataStr) {
-        log.info("gateWayRegister: {}", dataId);
-        CommonResult commonResult = new CommonResult();
-        OperationMessage operationMessage = operationMessageDao.findTopByDataId(dataId);
-        commonResult.setMessageId(dataId);
-        if (ObjectUtils.isEmpty(operationMessage)) {
-            commonResult.setFailed("数据不存在");
-            return ResultContent.buildSuccess(commonResult);
-        }
-        ResultContent<GateWayUserInfo> resultContent = gateWayUserInfoService.verifyMqttUser(operationMessage.getTopic());
-        if (resultContent.isFailed()) {
-            commonResult.setFailed(resultContent.getMsg());
-            return ResultContent.buildSuccess(commonResult);
-        }
-
-        GateWayInfoAddParam param = null;
-        try {
-            param = JSONUtil.toBean(dataStr, GateWayInfoAddParam.class);
-        } catch (Exception e) {
-            log.error(e.getMessage());
-            commonResult.setFailed(resultContent.getMsg());
-            return ResultContent.buildSuccess(commonResult);
-        }
-        GateWayUserInfo gateWayUserInfo = resultContent.getContent();
-        param.setMqttUserName(gateWayUserInfo.getUserName());
-
-        // 网关基本信息维护
-        ResultContent<GateWayInfo> content = addGateWayInfo(param);
-        if (content.isSuccess()) {
-        } else {
-            commonResult.setFailed(content.getMsg());
-            return ResultContent.buildSuccess(commonResult);
-        }
-        commonResult.setSuccess("注册成功");
-        return ResultContent.buildSuccess(commonResult);
-    }
-
-    /**
-     * 添加网关
-     *
-     * @param param
-     * @return
-     */
-    public ResultContent<GateWayInfo> addGateWayInfo(GateWayInfoAddParam param) {
-        if (StringUtils.isEmpty(param.getGateWayId())) {
-            return ResultContent.buildFail("gateWayId不能为空");
-        }
-        if (StringUtils.isEmpty(param.getGateWayName())) {
-            return ResultContent.buildFail("gateWayName不能为空");
-        }
-        if (StringUtils.isEmpty(param.getProjectInfoCode())) {
-            return ResultContent.buildFail("projectInfoCode不能为空");
-        }
-        if (param.getHbInterval() != null && param.getHbInterval() <= 0) {
-            return ResultContent.buildFail("hbInterval不符合规范");
-        }
-        ResultContent checkIdContent = JMXUtil.checkDeviceIdLength(param.getGateWayId(), "gateWayId");
-        if (checkIdContent.isFailed()) {
-            return ResultContent.buildFail(checkIdContent.getMsg());
-        }
-        ResultContent checkNameContent = JMXUtil.checkDeviceNameLength(param.getGateWayName(), "gateWayName");
-        if (checkNameContent.isFailed()) {
-            return ResultContent.buildFail(checkNameContent.getMsg());
-        }
-
-        ProjectInfo projectInfo = null;
-        if (StringUtils.isNotEmpty(param.getProjectInfoCode())) {
-            projectInfo = projectInfoDao.findTopByCode(param.getProjectInfoCode());
-        }
-        if (ObjectUtils.isEmpty(projectInfo)) {
-            return ResultContent.buildFail("projectInfoCode不存在");
-        }
-        GateWayUserInfo gateWayUserInfo = gateWayUserInfoDao.findTopByUserName(param.getMqttUserName());
-        if (StringUtils.isNotEmpty(gateWayUserInfo.getProjectCode()) && !gateWayUserInfo.getProjectCode().equals(param.getProjectInfoCode())) {
-            return ResultContent.buildFail("projectInfoCode不匹配");
-        }
-
-        GateWayInfo gateWayInfo = gateWayInfoDao.findTopByGateWayId(param.getGateWayId());
-        if (ObjectUtils.isEmpty(gateWayInfo)) {
-            gateWayInfo = new GateWayInfo();
-            gateWayInfo.setActivityTime(System.currentTimeMillis());
-            gateWayInfo.setState(DeviceState.Enable);
-        }
-
-        BeanUtils.copyProperties(param, gateWayInfo, "id");
-        gateWayInfo.setOnLineState(OnLineState.OnLine);
-        gateWayInfo.setLastOnlineTime(System.currentTimeMillis());
-        if (ObjectUtils.isNotEmpty(projectInfo)) {
-            gateWayInfo.setProjectInfo(projectInfo);
-        }
-
-        gateWayInfoDao.save(gateWayInfo);
-
-        log.info("网关注册成功");
-        // 通知同步 (网关信息)
-        deviceSyncFullCardService.noticeSyncGateWay(gateWayInfo);
-
-        // 更新连接账号关联的设备数量
-        gateWayUserInfoService.updateBindNumber(gateWayInfo.getMqttUserName());
-
-        // 同步权限
-        jmxSyncService.syncSecurityToMQTTService(gateWayInfo);
-        return ResultContent.buildSuccess(gateWayInfo);
-    }
+    @Autowired
+    private DeviceInfoDao deviceInfoDao;
+
+//    /**
+//     * 注册 网关
+//     *
+//     * @param dataStr
+//     * @return
+//     */
+//    public ResultContent<Object> gateWayRegister(String dataId, String dataStr) {
+//        log.info("gateWayRegister: {}", dataId);
+//        CommonResult commonResult = new CommonResult();
+//        OperationMessage operationMessage = operationMessageDao.findTopByDataId(dataId);
+//        commonResult.setMessageId(dataId);
+//        if (ObjectUtils.isEmpty(operationMessage)) {
+//            commonResult.setFailed("数据不存在");
+//            return ResultContent.buildSuccess(commonResult);
+//        }
+//        ResultContent<GateWayUserInfo> resultContent = gateWayUserInfoService.verifyMqttUser(operationMessage.getTopic());
+//        if (resultContent.isFailed()) {
+//            commonResult.setFailed(resultContent.getMsg());
+//            return ResultContent.buildSuccess(commonResult);
+//        }
+//
+//        GateWayInfoAddParam param = null;
+//        try {
+//            param = JSONUtil.toBean(dataStr, GateWayInfoAddParam.class);
+//        } catch (Exception e) {
+//            log.error(e.getMessage());
+//            commonResult.setFailed(resultContent.getMsg());
+//            return ResultContent.buildSuccess(commonResult);
+//        }
+//        GateWayUserInfo gateWayUserInfo = resultContent.getContent();
+//        param.setMqttUserName(gateWayUserInfo.getUserName());
+//
+//        // 网关基本信息维护
+//        ResultContent<GateWayInfo> content = addGateWayInfo(param);
+//        if (content.isSuccess()) {
+//        } else {
+//            commonResult.setFailed(content.getMsg());
+//            return ResultContent.buildSuccess(commonResult);
+//        }
+//        commonResult.setSuccess("注册成功");
+//        return ResultContent.buildSuccess(commonResult);
+//    }
+
+//    /**
+//     * 添加网关
+//     *
+//     * @param param
+//     * @return
+//     */
+//    public ResultContent<GateWayInfo> addGateWayInfo(GateWayInfoAddParam param) {
+//        if (StringUtils.isEmpty(param.getGateWayId())) {
+//            return ResultContent.buildFail("gateWayId不能为空");
+//        }
+//        if (StringUtils.isEmpty(param.getGateWayName())) {
+//            return ResultContent.buildFail("gateWayName不能为空");
+//        }
+//        if (StringUtils.isEmpty(param.getProjectInfoCode())) {
+//            return ResultContent.buildFail("projectInfoCode不能为空");
+//        }
+//        if (param.getHbInterval() != null && param.getHbInterval() <= 0) {
+//            return ResultContent.buildFail("hbInterval不符合规范");
+//        }
+//        ResultContent checkIdContent = JMXUtil.checkDeviceIdLength(param.getGateWayId(), "gateWayId");
+//        if (checkIdContent.isFailed()) {
+//            return ResultContent.buildFail(checkIdContent.getMsg());
+//        }
+//        ResultContent checkNameContent = JMXUtil.checkDeviceNameLength(param.getGateWayName(), "gateWayName");
+//        if (checkNameContent.isFailed()) {
+//            return ResultContent.buildFail(checkNameContent.getMsg());
+//        }
+//
+//        ProjectInfo projectInfo = null;
+//        if (StringUtils.isNotEmpty(param.getProjectInfoCode())) {
+//            projectInfo = projectInfoDao.findTopByCode(param.getProjectInfoCode());
+//        }
+//        if (ObjectUtils.isEmpty(projectInfo)) {
+//            return ResultContent.buildFail("projectInfoCode不存在");
+//        }
+//        GateWayUserInfo gateWayUserInfo = gateWayUserInfoDao.findTopByUserName(param.getMqttUserName());
+//        if (StringUtils.isNotEmpty(gateWayUserInfo.getProjectCode()) && !gateWayUserInfo.getProjectCode().equals(param.getProjectInfoCode())) {
+//            return ResultContent.buildFail("projectInfoCode不匹配");
+//        }
+//
+//        GateWayInfo gateWayInfo = gateWayInfoDao.findTopByGateWayId(param.getGateWayId());
+//        if (ObjectUtils.isEmpty(gateWayInfo)) {
+//            gateWayInfo = new GateWayInfo();
+//            gateWayInfo.setActivityTime(System.currentTimeMillis());
+//            gateWayInfo.setState(DeviceState.Enable);
+//        }
+//
+//        BeanUtils.copyProperties(param, gateWayInfo, "id");
+//        gateWayInfo.setOnLineState(OnLineState.OnLine);
+//        gateWayInfo.setLastOnlineTime(System.currentTimeMillis());
+//        if (ObjectUtils.isNotEmpty(projectInfo)) {
+//            gateWayInfo.setProjectInfo(projectInfo);
+//        }
+//
+//        gateWayInfoDao.save(gateWayInfo);
+//
+//        log.info("网关注册成功");
+//        // 通知同步 (网关信息)
+//        deviceSyncFullCardService.noticeSyncGateWay(gateWayInfo);
+//
+//        // 更新连接账号关联的设备数量
+//        gateWayUserInfoService.updateBindNumber(gateWayInfo.getMqttUserName());
+//
+//        // 同步权限
+//        jmxSyncService.syncSecurityToMQTTService(gateWayInfo);
+//        return ResultContent.buildSuccess(gateWayInfo);
+//    }
 
     /**
      * 注册设备
@@ -308,9 +301,9 @@ public class GateWayInfoService extends SuperService {
         }
 
         RegistType registType = RegistType.Gateway;
-        GateWayInfo gateWayInfo;
+        DeviceInfo gateWayInfo;
         if (StringUtils.isNotEmpty(param.getGateWayId())) {
-            gateWayInfo = gateWayInfoDao.findTopByGateWayId(param.getGateWayId());
+            gateWayInfo = deviceInfoDao.findTopByDeviceId(param.getGateWayId());
             if (ObjectUtils.isEmpty(gateWayInfo)) {
                 return ResultContent.buildFail("gateWayId数据不存在");
             }
@@ -366,7 +359,7 @@ public class GateWayInfoService extends SuperService {
      * @param gateWayInfo
      * @return
      */
-    public ResultContent deviceBindGateWay(DeviceInfo deviceInfo, GateWayInfo gateWayInfo) {
+    public ResultContent deviceBindGateWay(DeviceInfo deviceInfo, DeviceInfo gateWayInfo) {
         if (ObjectUtils.isEmpty(deviceInfo)) {
             return ResultContent.buildFail("设备信息为空");
         }
@@ -392,7 +385,7 @@ public class GateWayInfoService extends SuperService {
             } else {
             }
             gateWay2Device.setGateWayInfo(gateWayInfo);
-            gateWay2Device.setGateWayId(gateWayInfo != null ? gateWayInfo.getGateWayId() : "");
+            gateWay2Device.setGateWayId(gateWayInfo != null ? gateWayInfo.getDeviceId() : "");
             gateWay2Device.setDeviceInfo(deviceInfo);
             gateWay2Device.setDeviceId(deviceInfo.getDeviceId());
 
@@ -402,165 +395,165 @@ public class GateWayInfoService extends SuperService {
         return ResultContent.buildSuccess();
     }
 
-    /**
-     * 注册网关
-     *
-     * @param param
-     * @return
-     */
-    @Deprecated
-    public ResultContent<MqttInfoReturnModel> registerGateWay(GateWayInfoAddParam param) {
-        ProjectInfo projectInfo = projectInfoDao.findTopByCode(param.getProjectInfoCode());
-        if (ObjectUtils.isEmpty(projectInfo)) {
-            return ResultContent.buildFail(String.format("分组不存在:%s", param.getProjectInfoCode()));
-        }
-        // 添加网关信息
-        ResultContent<GateWayInfo> gateWayInfo = addGateWayInfo(param);
-
-        // 给网关分配个mqtt账号
-        MqttInfoReturnModel mqttInfoSimpleModel = mqttInfoService.getCommonMqttInfo(gateWayInfo.getContent());
-
-        // 通知下发项目配置信息
-        ProjectConfigQueryParam queryParam = new ProjectConfigQueryParam();
-        queryParam.setProjectInfoCode(param.getProjectInfoCode());
-        APIResponseModel api = apiRequestService.sendFullCardAPI(FullCardAPIConfig.iotQueryProjectConfig, queryParam);
-        if (api.isSuccess()) {
-            log.info("查询项目配置成功");
-        } else {
-            log.error("查询项目配置失败:{}", api.getMsg());
-        }
-        return ResultContent.buildSuccess(mqttInfoSimpleModel);
-    }
-
-    /**
-     * 网关绑定设备、连接账号
-     *
-     * @param param
-     * @return
-     */
-    public ResultContent gateWayBindDevice(GateWayBindDeviceParam param) {
-        // 网关信息
-        GateWayInfo gateWayInfo = gateWayInfoDao.findTopByGateWayId(param.getGateWayId());
-        if (ObjectUtils.isEmpty(gateWayInfo)) {
-            log.error("网关未注册");
-            return ResultContent.buildFail(String.format("网关未注册,清先注册网关:%s", param.getGateWayId()));
-        }
-
-        String projectInfoCode = param.getProjectInfoCode();
-        if (ObjectUtils.isEmpty(projectInfoCode)) {
-            projectInfoCode = gateWayInfo.getProjectInfoCode();
-        }
-
-        ProjectInfo projectInfo = projectInfoDao.findTopByCode(projectInfoCode);
-        if (ObjectUtils.isEmpty(projectInfo)) {
-            log.error("分组不存在");
-            return ResultContent.buildFail(String.format("分组不存在:%s", projectInfoCode));
-        }
-
-        List<DeviceInfoAddParam> devices = param.getDevices();
-        if (ObjectUtils.isNotEmpty(devices)) {
-            // 检查设备数据合法性
-            for (DeviceInfoAddParam device : devices) {
-                if (StringUtils.isEmpty(device.getDeviceId())) {
-                    return ResultContent.buildFail("deviceId不能为空");
-                }
-            }
-        }
-
-        GateWay2User gateWay2User = gateWay2UserDao.findTopByGateWayInfo(gateWayInfo);
-        if (ObjectUtils.isEmpty(gateWay2User)) {
-            return ResultContent.buildFail(String.format("网关为分配连接账户: %S", gateWay2User.getGateWayId()));
-        }
-
-        // 设备列表
-        List<DeviceInfo> deviceInfos = new ArrayList<>();
-        if (ObjectUtils.isNotEmpty(devices)) {
-            // 绑定网关和设备的关系
-            for (DeviceInfoAddParam device : devices) {
-                device.setProjectInfoCode(projectInfoCode);
-                // 保存设备信息
-                ResultContent<DeviceInfo> resultContent = deviceInfoService.addDeviceInfo(device);
-                DeviceInfo deviceInfo = resultContent.getContent();
-
-                // 设备可以绑定到多个网关,一个网关只能绑定设备一次
-                GateWay2Device gateWay2Device = gateWay2DeviceDao.findTopByGateWayInfoAndDeviceInfo(gateWayInfo, deviceInfo);
-                if (ObjectUtils.isEmpty(gateWay2Device)) {
-                    gateWay2Device = new GateWay2Device();
-                    gateWay2Device.setState(OnLineState.OffLine);
-                } else {
-                }
-                gateWay2Device.setGateWayInfo(gateWayInfo);
-                gateWay2Device.setDeviceInfo(deviceInfo);
-                gateWay2Device.setGateWayId(gateWayInfo.getGateWayId());
-                gateWay2Device.setDeviceId(deviceInfo.getDeviceId());
-
-                gateWay2Device.setBindTimeStr(DateUtils.paresTime(System.currentTimeMillis(), DateUtils.FORMAT_LONG));
-                gateWay2DeviceDao.save(gateWay2Device);
-                deviceInfos.add(deviceInfo);
-
-                iotService.updateAllDeviceIotMainGateWayInfo(deviceInfo);
-            }
-        }
-
-        // 更新网关的权限
-        jmxSyncService.syncSecurityToMQTTService(gateWayInfo);
-        log.info("设备注册成功:{}", deviceInfos.size());
-
-        // 同步设备
-        deviceSyncFullCardService.noticeSyncDevice(deviceInfos);
-        return ResultContent.buildSuccess();
-    }
-
-    /**
-     * 删除网关
-     *
-     * @param gateWayId
-     * @return
-     */
-    public ResultContent deleteGateWayInfo(String gateWayId) {
-        GateWayInfo gateWayInfo = gateWayInfoDao.findTopByGateWayId(gateWayId);
-        if (ObjectUtils.isEmpty(gateWayInfo)) {
-            return ResultContent.buildFail(String.format("网关ID不存在:%s", gateWayId));
-        }
-        gateWayInfoDao.delete(gateWayInfo);
-        return ResultContent.buildSuccess();
-    }
-
-    /**
-     * 网关列表
-     *
-     * @param pageable
-     * @param param
-     * @return
-     */
-    public ResultContent<Page<GateWayInfoModel>> pageGateWay(Pageable pageable, GateWayInfoSearchParam param) {
-        Page<GateWayInfo> page = gateWayInfoDao.page(pageable, param);
-        return ResultContent.buildSuccess(PageEntityUtil.toPageModel(page, this::toModel));
-    }
-
-    /**
-     * 查询网关详情
-     *
-     * @param gateWayId
-     * @return
-     */
-    public ResultContent<GateWayInfoModel> getById(String gateWayId) {
-        GateWayInfoModel model = null;
-        GateWayInfo deviceInfo = gateWayInfoDao.findTopByGateWayId(gateWayId);
-        if (ObjectUtils.isNotEmpty(deviceInfo)) {
-            model = toModel(deviceInfo);
-        }
-        return ResultContent.buildSuccess(model);
-    }
-
-    public GateWayInfoModel toModel(GateWayInfo entity) {
-        GateWayInfoModel model = new GateWayInfoModel();
-        if (ObjectUtils.isNotEmpty(entity)) {
-            BeanUtils.copyProperties(entity, model);
-            model.setProjectInfo(projectInfoService.toModel(entity.getProjectInfo()));
-        }
-        return model;
-    }
+//    /**
+//     * 注册网关
+//     *
+//     * @param param
+//     * @return
+//     */
+//    @Deprecated
+//    public ResultContent<MqttInfoReturnModel> registerGateWay(GateWayInfoAddParam param) {
+//        ProjectInfo projectInfo = projectInfoDao.findTopByCode(param.getProjectInfoCode());
+//        if (ObjectUtils.isEmpty(projectInfo)) {
+//            return ResultContent.buildFail(String.format("分组不存在:%s", param.getProjectInfoCode()));
+//        }
+//        // 添加网关信息
+//        ResultContent<GateWayInfo> gateWayInfo = addGateWayInfo(param);
+//
+//        // 给网关分配个mqtt账号
+//        MqttInfoReturnModel mqttInfoSimpleModel = mqttInfoService.getCommonMqttInfo(gateWayInfo.getContent());
+//
+//        // 通知下发项目配置信息
+//        ProjectConfigQueryParam queryParam = new ProjectConfigQueryParam();
+//        queryParam.setProjectInfoCode(param.getProjectInfoCode());
+//        APIResponseModel api = apiRequestService.sendFullCardAPI(FullCardAPIConfig.iotQueryProjectConfig, queryParam);
+//        if (api.isSuccess()) {
+//            log.info("查询项目配置成功");
+//        } else {
+//            log.error("查询项目配置失败:{}", api.getMsg());
+//        }
+//        return ResultContent.buildSuccess(mqttInfoSimpleModel);
+//    }
+
+//    /**
+//     * 网关绑定设备、连接账号
+//     *
+//     * @param param
+//     * @return
+//     */
+//    public ResultContent gateWayBindDevice(GateWayBindDeviceParam param) {
+//        // 网关信息
+//        GateWayInfo gateWayInfo = gateWayInfoDao.findTopByGateWayId(param.getGateWayId());
+//        if (ObjectUtils.isEmpty(gateWayInfo)) {
+//            log.error("网关未注册");
+//            return ResultContent.buildFail(String.format("网关未注册,清先注册网关:%s", param.getGateWayId()));
+//        }
+//
+//        String projectInfoCode = param.getProjectInfoCode();
+//        if (ObjectUtils.isEmpty(projectInfoCode)) {
+//            projectInfoCode = gateWayInfo.getProjectInfoCode();
+//        }
+//
+//        ProjectInfo projectInfo = projectInfoDao.findTopByCode(projectInfoCode);
+//        if (ObjectUtils.isEmpty(projectInfo)) {
+//            log.error("分组不存在");
+//            return ResultContent.buildFail(String.format("分组不存在:%s", projectInfoCode));
+//        }
+//
+//        List<DeviceInfoAddParam> devices = param.getDevices();
+//        if (ObjectUtils.isNotEmpty(devices)) {
+//            // 检查设备数据合法性
+//            for (DeviceInfoAddParam device : devices) {
+//                if (StringUtils.isEmpty(device.getDeviceId())) {
+//                    return ResultContent.buildFail("deviceId不能为空");
+//                }
+//            }
+//        }
+//
+//        GateWay2User gateWay2User = gateWay2UserDao.findTopByGateWayInfo(gateWayInfo);
+//        if (ObjectUtils.isEmpty(gateWay2User)) {
+//            return ResultContent.buildFail(String.format("网关为分配连接账户: %S", gateWay2User.getGateWayId()));
+//        }
+//
+//        // 设备列表
+//        List<DeviceInfo> deviceInfos = new ArrayList<>();
+//        if (ObjectUtils.isNotEmpty(devices)) {
+//            // 绑定网关和设备的关系
+//            for (DeviceInfoAddParam device : devices) {
+//                device.setProjectInfoCode(projectInfoCode);
+//                // 保存设备信息
+//                ResultContent<DeviceInfo> resultContent = deviceInfoService.addDeviceInfo(device);
+//                DeviceInfo deviceInfo = resultContent.getContent();
+//
+//                // 设备可以绑定到多个网关,一个网关只能绑定设备一次
+//                GateWay2Device gateWay2Device = gateWay2DeviceDao.findTopByGateWayInfoAndDeviceInfo(gateWayInfo, deviceInfo);
+//                if (ObjectUtils.isEmpty(gateWay2Device)) {
+//                    gateWay2Device = new GateWay2Device();
+//                    gateWay2Device.setState(OnLineState.OffLine);
+//                } else {
+//                }
+//                gateWay2Device.setGateWayInfo(gateWayInfo);
+//                gateWay2Device.setDeviceInfo(deviceInfo);
+//                gateWay2Device.setGateWayId(gateWayInfo.getGateWayId());
+//                gateWay2Device.setDeviceId(deviceInfo.getDeviceId());
+//
+//                gateWay2Device.setBindTimeStr(DateUtils.paresTime(System.currentTimeMillis(), DateUtils.FORMAT_LONG));
+//                gateWay2DeviceDao.save(gateWay2Device);
+//                deviceInfos.add(deviceInfo);
+//
+//                iotService.updateAllDeviceIotMainGateWayInfo(deviceInfo);
+//            }
+//        }
+//
+//        // 更新网关的权限
+//        jmxSyncService.syncSecurityToMQTTService(gateWayInfo);
+//        log.info("设备注册成功:{}", deviceInfos.size());
+//
+//        // 同步设备
+//        deviceSyncFullCardService.noticeSyncDevice(deviceInfos);
+//        return ResultContent.buildSuccess();
+//    }
+
+//    /**
+//     * 删除网关
+//     *
+//     * @param gateWayId
+//     * @return
+//     */
+//    public ResultContent deleteGateWayInfo(String gateWayId) {
+//        GateWayInfo gateWayInfo = gateWayInfoDao.findTopByGateWayId(gateWayId);
+//        if (ObjectUtils.isEmpty(gateWayInfo)) {
+//            return ResultContent.buildFail(String.format("网关ID不存在:%s", gateWayId));
+//        }
+//        gateWayInfoDao.delete(gateWayInfo);
+//        return ResultContent.buildSuccess();
+//    }
+
+//    /**
+//     * 网关列表
+//     *
+//     * @param pageable
+//     * @param param
+//     * @return
+//     */
+//    public ResultContent<Page<GateWayInfoModel>> pageGateWay(Pageable pageable, GateWayInfoSearchParam param) {
+//        Page<GateWayInfo> page = gateWayInfoDao.page(pageable, param);
+//        return ResultContent.buildSuccess(PageEntityUtil.toPageModel(page, this::toModel));
+//    }
+
+//    /**
+//     * 查询网关详情
+//     *
+//     * @param gateWayId
+//     * @return
+//     */
+//    public ResultContent<GateWayInfoModel> getById(String gateWayId) {
+//        GateWayInfoModel model = null;
+//        GateWayInfo deviceInfo = gateWayInfoDao.findTopByGateWayId(gateWayId);
+//        if (ObjectUtils.isNotEmpty(deviceInfo)) {
+//            model = toModel(deviceInfo);
+//        }
+//        return ResultContent.buildSuccess(model);
+//    }
+
+//    public GateWayInfoModel toModel(GateWayInfo entity) {
+//        GateWayInfoModel model = new GateWayInfoModel();
+//        if (ObjectUtils.isNotEmpty(entity)) {
+//            BeanUtils.copyProperties(entity, model);
+//            model.setProjectInfo(projectInfoService.toModel(entity.getProjectInfo()));
+//        }
+//        return model;
+//    }
 
     /**
      * 绑定角色网关的权限
@@ -637,7 +630,7 @@ public class GateWayInfoService extends SuperService {
      * @param deviceInfo
      * @return
      */
-    public GateWayInfo getDeviceGateWayInfo(DeviceInfo deviceInfo) {
+    public DeviceInfo getDeviceGateWayInfo(DeviceInfo deviceInfo) {
         if (ObjectUtils.isEmpty(deviceInfo)) {
             return null;
         }

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

@@ -1,6 +1,7 @@
 package com.zhongshu.iot.server.core.service.device;
 
 import com.github.microservice.net.ResultContent;
+import com.github.microservice.types.deviceUse.DeviceCategory;
 import com.zhongshu.card.client.model.base.IDParam;
 import com.zhongshu.iot.client.model.mqtt.*;
 import com.zhongshu.iot.client.type.type.LogsLevel;
@@ -53,9 +54,6 @@ public class GateWayUserInfoService extends SuperService {
     @Autowired
     private GateWay2DeviceDao gateWay2DeviceDao;
 
-    @Autowired
-    private GateWayInfoDao gateWayInfoDao;
-
     @Autowired
     private JMXSyncService jmxSyncService;
 
@@ -106,7 +104,7 @@ public class GateWayUserInfoService extends SuperService {
         return ResultContent.buildSuccess();
     }
 
-    public GateWayUserInfo gateWayBindMqttUser(GateWayInfo gateWayInfo) {
+    public GateWayUserInfo gateWayBindMqttUser(DeviceInfo gateWayInfo) {
         GateWayUserInfo gateWayUserInfo = null;
         if (ObjectUtils.isNotEmpty(gateWayInfo)) {
             GateWay2User gateWay2User = gateWay2UserDao.findTopByGateWayInfoOrderByCreateTimeDesc(gateWayInfo);
@@ -127,7 +125,7 @@ public class GateWayUserInfoService extends SuperService {
                     }
 
                     gateWay2User.setGateWayInfo(gateWayInfo);
-                    gateWay2User.setGateWayId(gateWayInfo.getGateWayId());
+                    gateWay2User.setGateWayId(gateWayInfo.getDeviceId());
                     gateWay2User.setGateWayUserInfo(gateWayUserInfo);
                     gateWay2User.setUserName(userName);
 
@@ -345,9 +343,9 @@ public class GateWayUserInfoService extends SuperService {
     public ResultContent updateBindNumber(GateWayUserInfo entity) {
         if (ObjectUtils.isNotEmpty(entity)) {
             // 网关数量
-            long gatewayNumber = gateWayInfoDao.countByMqttUserNameAndIsDelete(entity.getUserName(), Boolean.FALSE);
+            long gatewayNumber = deviceInfoDao.countByMqttUserNameAndIsDeleteAndDeviceCategory(entity.getUserName(), Boolean.FALSE, DeviceCategory.GW);
             // 设备数量
-            long deviceNumber = deviceInfoDao.countByMqttUserNameAndIsDelete(entity.getUserName(), Boolean.FALSE);
+            long deviceNumber = deviceInfoDao.countByMqttUserNameAndIsDeleteAndDeviceCategory(entity.getUserName(), Boolean.FALSE, DeviceCategory.DE);
 
             long bindNumber = gatewayNumber + deviceNumber;
             entity.setGatewayNumber(gatewayNumber);

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

@@ -1,8 +1,8 @@
 package com.zhongshu.iot.server.core.service.device;
 
+import com.github.microservice.net.ResultContent;
 import com.github.microservice.types.deviceUse.DeviceState;
 import com.github.microservice.types.deviceUse.RegistType;
-import com.github.microservice.net.ResultContent;
 import com.zhongshu.iot.server.core.dao.mqtt.*;
 import com.zhongshu.iot.server.core.dataConfig.MqttConfig;
 import com.zhongshu.iot.server.core.domain.iot.mqtt.*;
@@ -57,15 +57,15 @@ public class JMXSyncService {
     @Autowired
     private GateWay2DeviceDao gateWay2DeviceDao;
 
-    @Autowired
-    private GateWayInfoDao gateWayInfoDao;
-
     @Autowired
     private ApplicationContext applicationContext;
 
     @Autowired
     private DeviceInfoDao deviceInfoDao;
 
+    @Autowired
+    private DeviceInfoService deviceInfoService;
+
     /**
      * 把用户同步到MQTT服务中
      *
@@ -217,7 +217,7 @@ public class JMXSyncService {
      * @param gateWayInfo
      * @return
      */
-    public ResultContent syncSecurityToMQTTService(GateWayInfo gateWayInfo) {
+    public ResultContent syncSecurityToMQTTService(DeviceInfo gateWayInfo) {
         if (ObjectUtils.isNotEmpty(gateWayInfo)) {
             //todo同步权限
             List<MqttInfo> list = mqttInfoDao.findAll();
@@ -237,7 +237,7 @@ public class JMXSyncService {
      * @param gateWayInfo
      * @return
      */
-    public ResultContent syncSecurityGateToMQTTService(GateWayInfo gateWayInfo) {
+    public ResultContent syncSecurityGateToMQTTService(DeviceInfo gateWayInfo) {
         //todo同步权限
         List<MqttInfo> list = mqttInfoDao.findAll();
         log.info("syncSecurityGateToMQTTService {}", list.size());
@@ -249,7 +249,7 @@ public class JMXSyncService {
         return ResultContent.buildSuccess();
     }
 
-    public ResultContent syncSecurityToMQTTService(List<GateWayInfo> gateWayInfos) {
+    public ResultContent syncSecurityToMQTTService(List<DeviceInfo> gateWayInfos) {
         //todo同步权限
         List<MqttInfo> list = mqttInfoDao.findAll();
         log.info("syncSecurityToMQTTService {}", list.size());
@@ -268,7 +268,7 @@ public class JMXSyncService {
      * @param gateWayInfos
      * @return
      */
-    public void syncMqttSecuritySettings(MqttInfo mqttInfo, List<GateWayInfo> gateWayInfos) {
+    public void syncMqttSecuritySettings(MqttInfo mqttInfo, List<DeviceInfo> gateWayInfos) {
         if (ObjectUtils.isNotEmpty(mqttInfo) && ObjectUtils.isNotEmpty(gateWayInfos)) {
             try {
                 String urlStr = JMXUtil.buildServiceURL(mqttInfo);
@@ -280,7 +280,7 @@ public class JMXSyncService {
                 ObjectName addressObjectName = ObjectNameBuilder.create("org.apache.activemq.artemis", mqttInfo.getBrokerName()).getActiveMQServerObjectName();
                 ActiveMQServerControl addressControl = MBeanServerInvocationHandler.newProxyInstance(connection, addressObjectName, ActiveMQServerControl.class, false);
 
-                for (GateWayInfo gateWayInfo : gateWayInfos) {
+                for (DeviceInfo gateWayInfo : gateWayInfos) {
                     // 以前的权限
                     List<GateWayMqttSecurity> list = gateWayMqttSecurityDao.findByMqttInfoAndGateWayInfo(mqttInfo, gateWayInfo);
                     gateWayMqttSecurityDao.deleteByMqttInfoAndGateWayInfo(mqttInfo, gateWayInfo);
@@ -320,7 +320,7 @@ public class JMXSyncService {
                             gateWayMqttSecurity.setUserName(userName);
                             gateWayMqttSecurity.setRoleName(roleName);
                             gateWayMqttSecurity.setGateWayInfo(gateWayInfo);
-                            gateWayMqttSecurity.setGateWayId(gateWayInfo.getGateWayId());
+                            gateWayMqttSecurity.setGateWayId(gateWayInfo.getDeviceId());
                             gateWayMqttSecurity.setMqttInfo(mqttInfo);
                             gateWayMqttSecurity.setMqttName(mqttInfo.getName());
                             gateWayMqttSecurity.setAddressMatch(addressMatch);
@@ -355,7 +355,7 @@ public class JMXSyncService {
      * @param mqttInfo
      * @param gateWayInfos
      */
-    public void syncMqttSecurityGateSettings(MqttInfo mqttInfo, List<GateWayInfo> gateWayInfos) {
+    public void syncMqttSecurityGateSettings(MqttInfo mqttInfo, List<DeviceInfo> gateWayInfos) {
         if (ObjectUtils.isNotEmpty(mqttInfo) && ObjectUtils.isNotEmpty(gateWayInfos)) {
             try {
                 String urlStr = JMXUtil.buildServiceURL(mqttInfo);
@@ -368,7 +368,7 @@ public class JMXSyncService {
                 ActiveMQServerControl addressControl = MBeanServerInvocationHandler.newProxyInstance(connection, addressObjectName, ActiveMQServerControl.class, false);
 
                 final String _roleName = MqttConfig.adminRoleName;
-                for (GateWayInfo gateWayInfo : gateWayInfos) {
+                for (DeviceInfo gateWayInfo : gateWayInfos) {
                     // 查询网关关联的用户
                     GateWay2User gateWay2User = gateWay2UserDao.findTopByGateWayInfo(gateWayInfo);
                     if (ObjectUtils.isEmpty(gateWay2User)) {
@@ -398,7 +398,7 @@ public class JMXSyncService {
                             gateWayMqttSecurity.setUserName(userName);
                             gateWayMqttSecurity.setRoleName(roleName);
                             gateWayMqttSecurity.setGateWayInfo(gateWayInfo);
-                            gateWayMqttSecurity.setGateWayId(gateWayInfo.getGateWayId());
+                            gateWayMqttSecurity.setGateWayId(gateWayInfo.getDeviceId());
                             gateWayMqttSecurity.setMqttInfo(mqttInfo);
                             gateWayMqttSecurity.setMqttName(mqttInfo.getName());
                             gateWayMqttSecurity.setAddressMatch(addressMatch);
@@ -499,7 +499,7 @@ public class JMXSyncService {
      * @return
      */
     public ResultContent refreshAllGateWaySecurity() {
-        List<GateWayInfo> gateWayInfos = gateWayInfoDao.findAll();
+        List<DeviceInfo> gateWayInfos = deviceInfoService.getAllGateWayDevices();
         if (ObjectUtils.isNotEmpty(gateWayInfos)) {
             syncSecurityToMQTTService(gateWayInfos);
         }

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

@@ -1,16 +1,13 @@
 package com.zhongshu.iot.server.core.service.device;
 
-import com.github.microservice.types.common.CommonState;
 import com.github.microservice.net.ResultContent;
+import com.github.microservice.types.common.CommonState;
 import com.zhongshu.iot.client.model.mqtt.MqttInfoAddParam;
 import com.zhongshu.iot.client.model.mqtt.MqttInfoModel;
-import com.zhongshu.iot.client.model.mqtt.MqttInfoReturnModel;
 import com.zhongshu.iot.client.model.mqtt.MqttInfoSimpleModel;
 import com.zhongshu.iot.client.type.type.AddressType;
 import com.zhongshu.iot.server.core.dao.mqtt.Mqtt2UserDao;
 import com.zhongshu.iot.server.core.dao.mqtt.MqttInfoDao;
-import com.zhongshu.iot.server.core.domain.iot.mqtt.GateWayInfo;
-import com.zhongshu.iot.server.core.domain.iot.mqtt.GateWayUserInfo;
 import com.zhongshu.iot.server.core.domain.iot.mqtt.MqttInfo;
 import com.zhongshu.iot.server.core.util.bean.BeanUtils;
 import lombok.extern.slf4j.Slf4j;
@@ -65,33 +62,6 @@ public class MqttInfoService {
         mqttInfoDao.save(mqttInfo);
     }
 
-    /**
-     * 网关注册时,得到默认的mqtt连接
-     *
-     * @return
-     */
-    public MqttInfoReturnModel getCommonMqttInfo(GateWayInfo gatewayInfo) {
-        // 返回信息
-        MqttInfoReturnModel mqttInfoSimpleModel = new MqttInfoReturnModel();
-
-        // 查询一个通用的连接信息
-        MqttInfo mqttInfo = mqttInfoDao.findTopByAddress(AddressType.Common);
-
-        // 查询和绑定分配网关的mqtt账号
-        GateWayUserInfo gateWayUserInfo = gateWayUserInfoService.gateWayBindMqttUser(gatewayInfo);
-        if (ObjectUtils.isNotEmpty(mqttInfo)) {
-            mqttInfoSimpleModel.setBrokerAddress(String.format("%s:%s", mqttInfo.getBrokerHost(), mqttInfo.getBrokerPort()));
-//            mqttInfoSimpleModel.setBrokerUsername(gateWayUserInfo.getUserName());
-//            mqttInfoSimpleModel.setBrokerPassword(gateWayUserInfo.getPassWord());
-
-            mqttInfoSimpleModel.setBrokerUsername(mqttInfo.getUserName());
-            mqttInfoSimpleModel.setBrokerPassword(mqttInfo.getPassword());
-        }
-        // 只同步网关的 权限
-        jmxSyncService.syncSecurityGateToMQTTService(gatewayInfo);
-        return mqttInfoSimpleModel;
-    }
-
     /**
      * 添加/编辑MQTT地址
      *

+ 1 - 13
OneCardIotServer/src/main/java/com/zhongshu/iot/server/core/service/fix/FixDataService.java

@@ -1,11 +1,9 @@
 package com.zhongshu.iot.server.core.service.fix;
 
+import com.github.microservice.net.ResultContent;
 import com.zhongshu.iot.server.core.dao.mqtt.DeviceInfoDao;
-import com.zhongshu.iot.server.core.dao.mqtt.GateWayInfoDao;
 import com.zhongshu.iot.server.core.domain.iot.mqtt.DeviceInfo;
-import com.zhongshu.iot.server.core.domain.iot.mqtt.GateWayInfo;
 import com.zhongshu.iot.server.core.service.sync.DeviceSyncFullCardService;
-import com.github.microservice.net.ResultContent;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.ObjectUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -25,9 +23,6 @@ public class FixDataService {
     @Autowired
     DeviceInfoDao deviceInfoDao;
 
-    @Autowired
-    GateWayInfoDao gateWayInfoDao;
-
     @Autowired
     private DeviceSyncFullCardService deviceSyncFullCardService;
 
@@ -39,18 +34,11 @@ public class FixDataService {
     public ResultContent fixSyncDevice() {
         List<String> strs = new ArrayList<>();
 
-        List<GateWayInfo> gateWayInfos = gateWayInfoDao.findAll();
-        if (ObjectUtils.isNotEmpty(gateWayInfos)) {
-            deviceSyncFullCardService.noticeSyncGateWay(gateWayInfos);
-            strs.add(String.format("同步网关数量:%d", gateWayInfos.size()));
-        }
-
         List<DeviceInfo> deviceInfoList = deviceInfoDao.findAll();
         if (ObjectUtils.isNotEmpty(deviceInfoList)) {
             deviceSyncFullCardService.noticeSyncDevice(deviceInfoList);
             strs.add(String.format("同步设备数量:%d", deviceInfoList.size()));
         }
-
         return ResultContent.buildSuccess(strs);
     }
 

+ 6 - 11
OneCardIotServer/src/main/java/com/zhongshu/iot/server/core/service/iot/IotSendMessageService.java

@@ -11,10 +11,11 @@ import com.zhongshu.iot.client.model.iot.IotMainSearch;
 import com.zhongshu.iot.client.type.IotDataType;
 import com.zhongshu.iot.client.type.OperationType;
 import com.zhongshu.iot.server.core.dao.iot.IotMainDao;
-import com.zhongshu.iot.server.core.dao.mqtt.*;
+import com.zhongshu.iot.server.core.dao.mqtt.DeviceInfoDao;
+import com.zhongshu.iot.server.core.dao.mqtt.OperationMessageDao;
+import com.zhongshu.iot.server.core.dao.mqtt.OperationMessageResultDao;
 import com.zhongshu.iot.server.core.domain.iot.IotMain;
 import com.zhongshu.iot.server.core.domain.iot.mqtt.DeviceInfo;
-import com.zhongshu.iot.server.core.domain.iot.mqtt.GateWayInfo;
 import com.zhongshu.iot.server.core.domain.iot.mqtt.OperationMessage;
 import com.zhongshu.iot.server.core.domain.iot.mqtt.OperationMessageResult;
 import com.zhongshu.iot.server.core.service.base.SuperService;
@@ -59,16 +60,10 @@ public class IotSendMessageService extends SuperService {
     @Autowired
     private MQClient mqClient;
 
-    @Autowired
-    private GateWay2DeviceDao gateWay2DeviceDao;
-
     // 保存90天
     @Value("${artemisstore.time}")
     public Long ttlMill = 30 * 24L * 60 * 60 * 1000L;
 
-    @Autowired
-    private GateWayInfoDao gateWayInfoDao;
-
     public ResultContent sendIotMsgById(IotSendByIdParam param) {
         if (StringUtils.isEmpty(param.getId())) {
             return ResultContent.buildFail("id不能为空");
@@ -112,9 +107,9 @@ public class IotSendMessageService extends SuperService {
                 () -> new TreeSet<>(Comparator.comparing(IotMain::getRealIotTopic))), ArrayList::new));
 
         DeviceInfo deviceInfo = null;
-        GateWayInfo gateWayInfo = null;
+        DeviceInfo gateWayInfo = null;
         if (StringUtils.isNotEmpty(param.getGateWayId())) {
-            gateWayInfo = gateWayInfoDao.findTopByGateWayId(param.getGateWayId());
+            gateWayInfo = deviceInfoDao.findTopByDeviceId(param.getGateWayId());
         }
         if (StringUtils.isNotEmpty(param.getDeviceId())) {
             deviceInfo = deviceInfoDao.findTopByDeviceId(param.getDeviceId());
@@ -152,7 +147,7 @@ public class IotSendMessageService extends SuperService {
             entity.setEvent("");
             if (ObjectUtils.isNotEmpty(gateWayInfo)) {
                 entity.setGateWayInfo(gateWayInfo);
-                entity.setGateWayId(gateWayInfo.getGateWayId());
+                entity.setGateWayId(gateWayInfo.getDeviceId());
             }
             if (ObjectUtils.isNotEmpty(deviceInfo)) {
                 entity.setDeviceId(deviceInfo.getDeviceId());

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

@@ -527,7 +527,7 @@ public class IotServiceImpl extends SuperService {
             if (ObjectUtils.isNotEmpty(deviceInfo)) {
                 GateWay2Device gateWay2Device = gateWay2DeviceDao.findTopByDeviceInfoOrderByUpdateTimeDesc(deviceInfo);
                 if (ObjectUtils.isNotEmpty(gateWay2Device)) {
-                    String gateWayId = gateWay2Device.getGateWayInfo().getGateWayId();
+                    String gateWayId = gateWay2Device.getGateWayInfo().getDeviceId();
                     if (StringUtils.isNotEmpty(iotTopic)) {
                         realIotTopic = realIotTopic.replaceAll(Pattern.quote("${gateWayId}"), gateWayId);
                     }

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

@@ -13,7 +13,6 @@ import com.zhongshu.iot.server.core.domain.iot.IotMain;
 import com.zhongshu.iot.server.core.domain.iot.IotTemplate;
 import com.zhongshu.iot.server.core.domain.iot.IotThing;
 import com.zhongshu.iot.server.core.domain.iot.mqtt.DeviceInfo;
-import com.zhongshu.iot.server.core.domain.iot.mqtt.GateWayInfo;
 import com.zhongshu.iot.server.core.service.base.CommonService;
 import com.zhongshu.iot.server.core.service.base.SuperService;
 import com.zhongshu.iot.server.core.service.device.DeviceInfoService;
@@ -146,7 +145,7 @@ public class IotTemplateManagerService extends SuperService {
                 map.put(it.getIotMainTemplateId(), it.getId());
             });
         }
-        GateWayInfo gateWayInfo = gateWayInfoService.getDeviceGateWayInfo(deviceInfo);
+        DeviceInfo gateWayInfo = gateWayInfoService.getDeviceGateWayInfo(deviceInfo);
 
         if (list != null) {
             IotTemplate finalNewIotTemplate = newIotTemplate;
@@ -173,7 +172,7 @@ public class IotTemplateManagerService extends SuperService {
                 main.setProjectCode(projectInfoCode);
                 main.setAddTime(System.currentTimeMillis());
                 if (ObjectUtils.isNotEmpty(gateWayInfo)) {
-                    main.setGateWayId(gateWayInfo.getGateWayId());
+                    main.setGateWayId(gateWayInfo.getDeviceId());
                 }
                 iotService.initRealTopic(main);
                 saveList.add(main);

+ 0 - 27
OneCardIotServer/src/main/java/com/zhongshu/iot/server/core/service/iot/IotThing2DeviceService.java

@@ -11,7 +11,6 @@ import com.zhongshu.iot.server.core.dao.mqtt.DeviceInfoDao;
 import com.zhongshu.iot.server.core.domain.iot.IotThing;
 import com.zhongshu.iot.server.core.domain.iot.IotThing2Device;
 import com.zhongshu.iot.server.core.domain.iot.mqtt.DeviceInfo;
-import com.zhongshu.iot.server.core.domain.iot.mqtt.GateWayInfo;
 import com.zhongshu.iot.server.core.service.base.SuperService;
 import com.zhongshu.iot.server.core.service.device.DeviceInfoService;
 import com.zhongshu.iot.server.core.service.device.ProjectInfoService;
@@ -51,32 +50,6 @@ public class IotThing2DeviceService extends SuperService {
     @Autowired
     private IotThingService iotThingService;
 
-    /**
-     * 物模型绑定设备
-     *
-     * @param iotThing
-     * @param gateWayInfo
-     * @return
-     */
-    public ResultContent initAutoBindGateWay(IotThing iotThing, GateWayInfo gateWayInfo) {
-        if (ObjectUtils.isNotEmpty(iotThing) && ObjectUtils.isNotEmpty(gateWayInfo)) {
-            IotThing2Device entity = iotThing2DeviceDao.findTopByIotThingId(iotThing.getId());
-            if (ObjectUtils.isEmpty(entity)) {
-                entity = new IotThing2Device();
-            }
-            entity.setIotThing(iotThing);
-            entity.setIotThingId(iotThing.getId());
-            entity.setDeviceId(gateWayInfo.getGateWayId());
-            entity.setDeviceName(gateWayInfo.getGateWayName());
-            entity.setDeviceCategory(iotThing.getDeviceCategory());
-            entity.setProjectInfo(gateWayInfo.getProjectInfo());
-            entity.setProjectCode(gateWayInfo.getProjectInfoCode());
-            entity.setOnLineState(gateWayInfo.getOnLineState());
-            iotThing2DeviceDao.save(entity);
-        }
-        return ResultContent.buildSuccess();
-    }
-
     /**
      * 绑定物模型和设备
      *

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

@@ -100,6 +100,7 @@ public class IotThingService extends SuperService {
                 initEntity(iotThing);
             } else {
             }
+            // 物模型名称
             iotThing.setName(deviceInfo.getDeviceName());
             // 产品code
             iotThing.setProductCode(productCode);
@@ -177,7 +178,7 @@ public class IotThingService extends SuperService {
 
     /**
      * 物模型分页查询
-     * 
+     *
      * @param pageable
      * @param param
      * @return

+ 0 - 35
OneCardIotServer/src/main/java/com/zhongshu/iot/server/core/service/iotPlatform/impl/RegisterGatewayTopic.java

@@ -1,35 +0,0 @@
-package com.zhongshu.iot.server.core.service.iotPlatform.impl;
-
-
-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.device.GateWayInfoService;
-import com.zhongshu.iot.server.core.service.iotPlatform.PlatformTopic;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-/**
- * @author TRX
- * @date 2025/1/13
- */
-@Component
-@ExecuteAnnotationService
-@Slf4j
-public class RegisterGatewayTopic implements PlatformTopic {
-
-    @Autowired
-    private GateWayInfoService gateWayInfoService;
-
-    @Override
-    public String topic() {
-        return "/platform/%s/regist";
-    }
-
-    @ExecuteAnnotationServiceMethod(value = "registGateway", remark = "网关注册")
-    @Override
-    public ResultContent<Object> action(String dataId, String message) {
-        return gateWayInfoService.gateWayRegister(dataId, message);
-    }
-}

+ 2 - 61
OneCardIotServer/src/main/java/com/zhongshu/iot/server/core/service/sync/DeviceSyncFullCardService.java

@@ -3,23 +3,18 @@ package com.zhongshu.iot.server.core.service.sync;
 import com.github.microservice.http.APIResponseModel;
 import com.github.microservice.models.device.DeviceInfoSyncParam;
 import com.github.microservice.models.device.DeviceSyncListParam;
-import com.github.microservice.models.device.GateWaySyncParam;
 import com.github.microservice.models.hxz.DevicePingInfoParam;
 import com.github.microservice.net.ResultContent;
 import com.zhongshu.iot.server.core.dao.mqtt.DeviceInfoDao;
 import com.zhongshu.iot.server.core.dao.mqtt.GateWay2DeviceDao;
-import com.zhongshu.iot.server.core.dao.mqtt.GateWayInfoDao;
 import com.zhongshu.iot.server.core.domain.iot.mqtt.DeviceInfo;
 import com.zhongshu.iot.server.core.domain.iot.mqtt.GateWay2Device;
-import com.zhongshu.iot.server.core.domain.iot.mqtt.GateWayInfo;
 import com.zhongshu.iot.server.core.event.DeviceOnLineTimeChangeEvent;
 import com.zhongshu.iot.server.core.event.DeviceStateChangeEvent;
 import com.zhongshu.iot.server.core.event.DeviceSyncEvent;
-import com.zhongshu.iot.server.core.event.GateWaySyncEvent;
 import com.zhongshu.iot.server.core.httpRequest.ApiRequestService;
 import com.zhongshu.iot.server.core.httpRequest.conf.FullCardAPIConfig;
 import com.zhongshu.iot.server.core.service.base.SuperService;
-import com.zhongshu.iot.server.core.service.user.OperationLogsService;
 import com.zhongshu.iot.server.core.util.bean.BeanUtils;
 import lombok.SneakyThrows;
 import lombok.extern.slf4j.Slf4j;
@@ -47,12 +42,6 @@ public class DeviceSyncFullCardService extends SuperService {
     @Autowired
     DeviceInfoDao deviceInfoDao;
 
-    @Autowired
-    GateWayInfoDao gateWayInfoDao;
-
-    @Autowired
-    OperationLogsService operationLogsService;
-
     @Autowired
     ApiRequestService apiRequestService;
 
@@ -140,11 +129,11 @@ public class DeviceSyncFullCardService extends SuperService {
 
                 if (ObjectUtils.isNotEmpty(gateWay2Devices)) {
                     gateWayIds = gateWay2Devices.stream().map(it2 -> {
-                        return it2.getGateWayInfo().getGateWayId();
+                        return it2.getGateWayInfo().getDeviceId();
                     }).collect(Collectors.toList());
 
                     gateWayNames = gateWay2Devices.stream().map(it2 -> {
-                        return it2.getGateWayInfo().getGateWayName();
+                        return it2.getGateWayInfo().getDeviceName();
                     }).collect(Collectors.toList());
 
                 }
@@ -163,54 +152,6 @@ public class DeviceSyncFullCardService extends SuperService {
         log.info("同步设备情况:{} {}", api.isSuccess(), api.getMsg());
     }
 
-    /**
-     * 通知同步网关信息
-     *
-     * @param gateWayInfo
-     * @return
-     */
-    public ResultContent noticeSyncGateWay(GateWayInfo gateWayInfo) {
-        if (ObjectUtils.isNotEmpty(gateWayInfo)) {
-            GateWaySyncEvent event = new GateWaySyncEvent(this, List.of(gateWayInfo.getGateWayId()));
-            applicationContext.publishEvent(event);
-        }
-        return ResultContent.buildSuccess();
-    }
-
-    public ResultContent noticeSyncGateWay(List<GateWayInfo> gateWayInfos) {
-        if (ObjectUtils.isNotEmpty(gateWayInfos)) {
-            GateWaySyncEvent event = new GateWaySyncEvent(this, gateWayInfos.stream().map(it -> it.getGateWayId()).collect(Collectors.toList()));
-            applicationContext.publishEvent(event);
-        }
-        return ResultContent.buildSuccess();
-    }
-
-    /**
-     * 同步网关信息
-     *
-     * @param event
-     */
-    @EventListener(classes = GateWaySyncEvent.class)
-    @Async
-    @SneakyThrows
-    public void syncGateWayInfo(GateWaySyncEvent event) {
-        List<String> gatewayIds = event.getGateWayIds();
-        log.info("event syncGateWayInfo: {}", gatewayIds);
-        List<GateWayInfo> gateWayInfos = gateWayInfoDao.findByGateWayIdIn(gatewayIds);
-        if (ObjectUtils.isNotEmpty(gateWayInfos)) {
-            GateWaySyncParam syncParam = new GateWaySyncParam();
-            List<GateWaySyncParam.GateWaySyncInfo> list = gateWayInfos.stream().map(it -> {
-                GateWaySyncParam.GateWaySyncInfo syncInfo = new GateWaySyncParam.GateWaySyncInfo();
-                BeanUtils.copyProperties(it, syncInfo);
-                syncInfo.setState(it.getOnLineState());
-                return syncInfo;
-            }).collect(Collectors.toList());
-            syncParam.setList(list);
-            APIResponseModel api = apiRequestService.sendFullCardAPI(FullCardAPIConfig.syncGateWays, syncParam);
-            log.info("同步网关情况:{} {}", api.isSuccess(), api.getMsg());
-        }
-    }
-
     public ResultContent noticeSyncDeviceOnlineStateChange(String deviceId) {
         if (ObjectUtils.isNotEmpty(deviceId)) {
             DeviceStateChangeEvent event = new DeviceStateChangeEvent(this, deviceId);

+ 0 - 3
OneCardIotServer/src/main/java/com/zhongshu/iot/server/core/timers/CheckDeviceStateWork.java

@@ -25,8 +25,5 @@ public class CheckDeviceStateWork {
     public void checkDeviceState() {
         // 检测设备在线状态
         devicePingInfoService.checkDeviceState();
-
-        // 检测网关在线状态
-        devicePingInfoService.checkGateWayState();
     }
 }

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

@@ -6,7 +6,6 @@ import com.github.microservice.net.ResultContent;
 import com.zhongshu.iot.server.core.dataConfig.DeviceConfig;
 import com.zhongshu.iot.server.core.dataConfig.MqttConfig;
 import com.zhongshu.iot.server.core.domain.iot.mqtt.DeviceInfo;
-import com.zhongshu.iot.server.core.domain.iot.mqtt.GateWayInfo;
 import com.zhongshu.iot.server.core.domain.iot.mqtt.GateWayUserInfo;
 import com.zhongshu.iot.server.core.domain.iot.mqtt.MqttInfo;
 import lombok.extern.slf4j.Slf4j;
@@ -61,7 +60,7 @@ public class JMXUtil {
      * @param deviceInfoList
      * @return
      */
-    public static List<String> buildAddressMatch(GateWayInfo gateWayInfo, List<DeviceInfo> deviceInfoList) {
+    public static List<String> buildAddressMatch(DeviceInfo gateWayInfo, List<DeviceInfo> deviceInfoList) {
         List<String> list = new ArrayList<String>();
         list.add("$sys.mqtt.sessions");
         if (ObjectUtils.isNotEmpty(gateWayInfo)) {
@@ -93,10 +92,10 @@ public class JMXUtil {
         return list;
     }
 
-    public static List<String> buildGateWayAddressMatch(GateWayInfo gateWayInfo) {
+    public static List<String> buildGateWayAddressMatch(DeviceInfo gateWayInfo) {
         List<String> list = new ArrayList<String>();
         if (ObjectUtils.isNotEmpty(gateWayInfo)) {
-            list.add(String.format("/device/%s/#", gateWayInfo.getGateWayId()));
+            list.add(String.format("/device/%s/#", gateWayInfo.getDeviceId()));
         }
         return list;
     }