瀏覽代碼

优化下发设备控制命令接口,增加未登录情况下用domain获取tenantid

james 6 月之前
父節點
當前提交
4e5182ac21

+ 6 - 2
data-gateway/data-gateway-eg-kat/src/main/resources/application.yml

@@ -39,9 +39,13 @@ mqtt:
   keep-alive-interval: 60
   password: public
   sub-topics: /502_KAT/+/control
-  url: tcp://172.16.120.165:1883
+  url: tcp://192.168.123.165:1883
   username: admin
+#  password: usky
+#  sub-topics: /502_KAT/+/control
+#  url: tcp://47.98.201.73:1883
+#  username: usky
 # 和嵌入式udp通信的发送端口和监听端口地址
 udp:
-  deviceIp: 172.16.120.172
+  deviceIp: 192.168.123.44
   sendingPort: 60000

+ 1 - 1
data-transfer/data-transfer-api/src/main/java/com/usky/transfer/RemoteTransferService.java

@@ -24,5 +24,5 @@ public interface RemoteTransferService {
      * 下发单个设备控制命令
      */
     @PostMapping("/deviceControl")
-    Map<String,Object> deviceControl(@RequestParam("productCode") String productCode, @RequestParam("deviceId") String deviceId, @RequestParam("commandStr") String commandStr);
+    Map<String,Object> deviceControl(@RequestParam("productCode") String productCode, @RequestParam("deviceId") String deviceId, @RequestParam("commandStr") String commandStr,@RequestParam(value = "tenantId") Integer tenantId);
 }

+ 1 - 1
data-transfer/data-transfer-api/src/main/java/com/usky/transfer/factory/RemoteTransferFallbackFactory.java

@@ -36,7 +36,7 @@ public class RemoteTransferFallbackFactory implements FallbackFactory<RemoteTran
                 throw new BusinessException(throwable.getMessage());
             }
             @Override
-            public Map<String,Object> deviceControl(String productCode, String deviceId, String commandStr) {
+            public Map<String,Object> deviceControl(String productCode, String deviceId, String commandStr,Integer tenantId) {
                 throw new BusinessException(throwable.getMessage());
             }
         };

+ 2 - 2
data-transfer/data-transfer-biz/src/main/java/com/usky/transfer/controller/api/DataTransferControllerApi.java

@@ -29,7 +29,7 @@ public class DataTransferControllerApi implements RemoteTransferService {
      * 下发单个设备控制命令
      */
     @Override
-    public Map<String,Object> deviceControl(String productCode, String deviceId, String commandStr){
-        return queryInfluxdbDataService.deviceControl(productCode, deviceId, commandStr);
+    public Map<String,Object> deviceControl(String productCode, String deviceId, String commandStr,Integer tenantId){
+        return queryInfluxdbDataService.deviceControl(productCode, deviceId, commandStr, tenantId);
     }
 }

+ 1 - 1
data-transfer/data-transfer-biz/src/main/java/com/usky/transfer/service/QueryInfluxdbDataService.java

@@ -18,6 +18,6 @@ public interface QueryInfluxdbDataService extends CrudService<QueryInfluxdbData>
 
     Map<String,Object> sendDeviceDataToMQ(DeviceDataWriteVO writeVO);
 
-    Map<String,Object> deviceControl(String productCode, String deviceId, String commandStr);
+    Map<String,Object> deviceControl(String productCode, String deviceId, String commandStr,Integer tenantId);
 
 }

+ 3 - 3
data-transfer/data-transfer-biz/src/main/java/com/usky/transfer/service/impl/QueryInfluxdbDataServiceImpl.java

@@ -54,21 +54,21 @@ public class QueryInfluxdbDataServiceImpl extends AbstractCrudService<QueryInflu
     private MqttOutConfig.MqttGateway mqttGateway;
 
     @Override
-    public Map<String,Object> deviceControl(String productCode, String deviceId, String commandStr){
+    public Map<String,Object> deviceControl(String productCode, String deviceId, String commandStr,Integer tenantId){
         Map<String,Object> rec_map = new HashMap<>();
 
+
         //存储下发设备控制命令到数据库表中
         DmpDeviceCommand command = new DmpDeviceCommand();
         command.setProductCode(productCode);
         command.setDeviceId(deviceId);
         command.setCommandContent(commandStr);
-        command.setCreatedBy(SecurityUtils.getUsername());
         command.setCreatedTime(LocalDateTime.now());
 //        if (Objects.nonNull(SecurityUtils.getLoginUser().getSysUser().getDeptId())){
 //            command.setDeptId(SecurityUtils.getLoginUser().getSysUser().getDeptId().intValue());
 //        }
 
-        command.setTenantId(SecurityUtils.getTenantId());
+        command.setTenantId(tenantId);
         dmpDeviceCommandService.save(command);
         int commandId = command.getId();
 

+ 0 - 1
data-transfer/data-transfer-biz/src/main/java/com/usky/transfer/service/mqtt/control/control.java

@@ -42,7 +42,6 @@ public class control implements MqttStrategy {
             command.setCommandStatus(1);
         }
 
-        command.setUpdatedBy(SecurityUtils.getUsername());
         command.setUpdatedTime(LocalDateTime.now());
 
         dmpDeviceCommandService.updateById(command);