24282 2 vuotta sitten
vanhempi
commit
3402459bfc

+ 10 - 2
hx-iot/src/main/java/com/fjhx/iot/listener/DtaListener.java

@@ -74,7 +74,15 @@ public class DtaListener {
 
         MessageConsumer consumer = null;
         try {
-            AmqpClientOptions options = AmqpClientOptions.builder().host(tdaConfig.getEndPoint()).port(AmqpConstant.PORT).accessKey(tdaConfig.getAccessKey()).accessCode(tdaConfig.getAccessCode()).queuePrefetch(1000).build();
+
+            AmqpClientOptions options = AmqpClientOptions.builder()
+                    .host(tdaConfig.getEndPoint())
+                    .port(AmqpConstant.PORT)
+                    .accessKey(tdaConfig.getAccessKey())
+                    .accessCode(tdaConfig.getAccessCode())
+                    .queuePrefetch(1000)
+                    .build();
+
             AmqpClient amqpClient = new AmqpClient(options);
             amqpClient.initialize();
             consumer = amqpClient.newConsumer(AmqpConstant.DEFAULT_QUEUE);
@@ -193,7 +201,7 @@ public class DtaListener {
 
         switch (deviceType) {
             case "ebc":
-                doEbc(productId, deviceId, eventTime, properties.toJavaObject(EbcDto.class));
+                doEbc(productId, deviceId, eventTime, properties.getJSONObject("DeviceData").toJavaObject(EbcDto.class));
                 break;
             default:
                 log.error("未知 deviceType:{}", deviceType);

+ 8 - 2
hx-iot/src/main/java/com/fjhx/iot/service/tda/impl/TdaProductServiceImpl.java

@@ -64,8 +64,14 @@ public class TdaProductServiceImpl extends ServiceImpl<TdaProductMapper, TdaProd
         String appId = tdaApplication.getAppId();
 
         // 华为ioDta添加产品
-        String productId = IoTDAUtil.createProduct(tdaApplication.getTdaConfigId(), appId, tdaProductDto.getName(),
-                tdaProductDto.getDeviceType(), tdaProductDto.getManufacturerName(), tdaProductDto.getProtocolType());
+        String productId = IoTDAUtil.createProduct(
+                tdaApplication.getTdaConfigId(),
+                appId,
+                tdaProductDto.getName(),
+                tdaProductDto.getDeviceType(),
+                tdaProductDto.getManufacturerName(),
+                tdaProductDto.getProtocolType()
+        );
 
         tdaProductDto.setAppId(appId);
         tdaProductDto.setProductId(productId);

+ 1 - 1
hx-iot/src/main/java/com/fjhx/iot/utils/IoTDAUtil.java

@@ -76,7 +76,7 @@ public class IoTDAUtil {
 
         // 添加产品属性
         ServiceCapability serviceCapability = new ServiceCapability();
-        serviceCapability.setServiceId("Data");
+        serviceCapability.setServiceId("data");
         serviceCapability.setServiceType("data");
         serviceCapability.setProperties(Collections.singletonList(serviceProperty));