TRX 1 سال پیش
والد
کامیت
f10657d070

+ 20 - 2
OneCardIotServer/src/main/java/com/zhongshu/iot/server/core/service/mqtt/GateWayInfoService.java

@@ -1,10 +1,14 @@
 package com.zhongshu.iot.server.core.service.mqtt;
 
+import com.github.microservice.http.APIResponseModel;
+import com.github.microservice.models.project.ProjectConfigQueryParam;
 import com.github.microservice.models.type.OnLineState;
 import com.github.microservice.net.ResultContent;
 import com.zhongshu.iot.client.model.mqtt.*;
 import com.zhongshu.iot.server.core.dao.mqtt.*;
 import com.zhongshu.iot.server.core.domain.iot.mqtt.*;
+import com.zhongshu.iot.server.core.httpRequest.ApiRequestService;
+import com.zhongshu.iot.server.core.httpRequest.conf.FullCardAPIConfig;
 import com.zhongshu.iot.server.core.service.base.AkSignService;
 import com.zhongshu.iot.server.core.service.base.SuperService;
 import com.zhongshu.iot.server.core.service.iot.IotServiceImpl;
@@ -94,6 +98,9 @@ public class GateWayInfoService extends SuperService {
     @Autowired
     private AkSignService akSignService;
 
+    @Autowired
+    private ApiRequestService apiRequestService;
+
     /**
      * 添加网关
      *
@@ -117,9 +124,11 @@ public class GateWayInfoService extends SuperService {
             gateWayInfo.setProjectInfo(projectInfo);
         }
         log.info("网关注册成功");
-        // 通知同步
+        // 通知同步 (网关信息)
         deviceSyncFullCardService.noticeSyncGateWay(gateWayInfo);
-        akSignService.createAkSk();
+
+        //todo 创建token
+        // akSignService.createAkSk();
         return ResultContent.buildSuccess(gateWayInfo);
     }
 
@@ -140,6 +149,15 @@ public class GateWayInfoService extends SuperService {
         // 给网关分配个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);
     }