Kaynağa Gözat

fix: 产品id和productKey

jay 2 yıl önce
ebeveyn
işleme
880b454438
23 değiştirilmiş dosya ile 94 ekleme ve 57 silme
  1. 16 16
      data/init/product.json
  2. 16 16
      data/init/thingModel.json
  3. 1 1
      iot-common/iot-common-dao/iot-common-model/src/main/java/cc/iotkit/model/product/Product.java
  4. 1 1
      iot-common/iot-common-dao/iot-data-service/src/main/java/cc/iotkit/data/manager/IProductData.java
  5. 1 0
      iot-common/iot-common-dao/iot-data-service/src/main/java/cc/iotkit/data/manager/IThingModelData.java
  6. 7 0
      iot-common/iot-common-dao/iot-data-serviceImpl-cache/src/main/java/cc/iotkit/data/service/ProductDataCache.java
  7. 7 1
      iot-common/iot-common-dao/iot-data-serviceImpl-cache/src/main/java/cc/iotkit/data/service/ThingModelDataCache.java
  8. 1 0
      iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/dao/ProductRepository.java
  9. 3 0
      iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/dao/ThingModelRepository.java
  10. 1 1
      iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/DeviceInfoDataImpl.java
  11. 7 1
      iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/ProductDataImpl.java
  12. 9 0
      iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/ThingModelDataImpl.java
  13. 1 1
      iot-components/iot-component-server/src/main/java/cc/iotkit/comps/DeviceComponentManager.java
  14. 2 2
      iot-components/iot-component-server/src/main/java/cc/iotkit/comps/service/DeviceBehaviourService.java
  15. 1 1
      iot-components/iot-component-server/src/main/java/cc/iotkit/comps/service/DevicePropertyConsumer.java
  16. 2 2
      iot-module/iot-manager/src/main/java/cc/iotkit/manager/controller/SpaceDeviceController.java
  17. 1 1
      iot-module/iot-manager/src/main/java/cc/iotkit/manager/controller/StatsController.java
  18. 3 2
      iot-module/iot-manager/src/main/java/cc/iotkit/manager/dto/bo/product/ProductBo.java
  19. 5 1
      iot-module/iot-manager/src/main/java/cc/iotkit/manager/dto/vo/product/ProductVo.java
  20. 1 1
      iot-module/iot-manager/src/main/java/cc/iotkit/manager/service/SpaceDeviceService.java
  21. 1 1
      iot-module/iot-manager/src/main/java/cc/iotkit/manager/service/ThingModelService.java
  22. 1 1
      iot-module/iot-manager/src/main/java/cc/iotkit/manager/service/impl/DeviceServiceImpl.java
  23. 6 7
      iot-module/iot-manager/src/main/java/cc/iotkit/manager/service/impl/ProductServiceImpl.java

+ 16 - 16
data/init/product.json

@@ -1,6 +1,6 @@
 [
   {
-    "id": "xpsYHExTKPFaQMS7",
+    "productKey": "xpsYHExTKPFaQMS7",
     "name": "调光灯",
     "category": "light",
     "nodeType": 1,
@@ -8,7 +8,7 @@
     "createAt": 1650174777304
   },
   {
-    "id": "hdX3PCMcFrCYpesJ",
+    "productKey": "hdX3PCMcFrCYpesJ",
     "code": "hdX3PCMcFrCYpesJ",
     "name": "智能风扇",
     "category": "fan",
@@ -17,7 +17,7 @@
     "createAt": 1646571291131
   },
   {
-    "id": "hbtgIA0SuVw9lxjB",
+    "productKey": "hbtgIA0SuVw9lxjB",
     "name": "GW01网关",
     "category": "gateway",
     "nodeType": 0,
@@ -27,7 +27,7 @@
     "createAt": 1652238155938
   },
   {
-    "id": "eDhXKwEzwFybM5R7",
+    "productKey": "eDhXKwEzwFybM5R7",
     "name": "三路开关",
     "category": "switch",
     "nodeType": 1,
@@ -37,7 +37,7 @@
     "createAt": 1652238173536
   },
   {
-    "id": "cGCrkK7Ex4FESAwe",
+    "productKey": "cGCrkK7Ex4FESAwe",
     "name": "插座",
     "category": "SmartPlug",
     "nodeType": 1,
@@ -47,7 +47,7 @@
     "createAt": 1652238138626
   },
   {
-    "id": "Rf4QSjbm65X45753",
+    "productKey": "Rf4QSjbm65X45753",
     "name": "一路开关",
     "category": "switch",
     "nodeType": 1,
@@ -57,7 +57,7 @@
     "createAt": 1652238147123
   },
   {
-    "id": "PN3EDmkBZDD8whDd",
+    "productKey": "PN3EDmkBZDD8whDd",
     "name": "门磁",
     "category": "door",
     "nodeType": 1,
@@ -66,7 +66,7 @@
     "createAt": 1650190400357
   },
   {
-    "id": "N523nWsCiG3CAn6X",
+    "productKey": "N523nWsCiG3CAn6X",
     "name": "ZGW01",
     "category": "gateway",
     "nodeType": 0,
@@ -76,7 +76,7 @@
     "createAt": 1652237643216
   },
   {
-    "id": "Eit3kmGJtxSHfCKT",
+    "productKey": "Eit3kmGJtxSHfCKT",
     "name": "燃气表",
     "category": "meter",
     "nodeType": 2,
@@ -85,7 +85,7 @@
     "createAt": 1654237604221
   },
   {
-    "id": "DSGxxKk6E8mmDk6C",
+    "productKey": "DSGxxKk6E8mmDk6C",
     "name": "通断器",
     "category": "switch",
     "nodeType": 1,
@@ -95,7 +95,7 @@
     "createAt": 1652238202310
   },
   {
-    "id": "D8c5pXFmt2KJDxNm",
+    "productKey": "D8c5pXFmt2KJDxNm",
     "name": "四路场景面板",
     "category": "switch",
     "nodeType": 1,
@@ -103,7 +103,7 @@
     "createAt": 1650187781637
   },
   {
-    "id": "AWcJnf7ymGSkaz5M",
+    "productKey": "AWcJnf7ymGSkaz5M",
     "name": "smart pulg",
     "category": "SmartPlug",
     "nodeType": 1,
@@ -113,7 +113,7 @@
     "createAt": 1652279098100
   },
   {
-    "id": "6kYp6jszrDns2yh4",
+    "productKey": "6kYp6jszrDns2yh4",
     "name": "温湿度传感器",
     "category": "sensor",
     "nodeType": 1,
@@ -121,7 +121,7 @@
     "createAt": 1649653149339
   },
   {
-    "id": "bGdZt8ffBETtsirm",
+    "productKey": "bGdZt8ffBETtsirm",
     "name": "新风",
     "category": "FreshAir",
     "nodeType": 1,
@@ -129,7 +129,7 @@
     "createAt": 1649653149339
   },
   {
-    "id": "BRD3x4fkKxkaxXFt",
+    "productKey": "BRD3x4fkKxkaxXFt",
     "name": "智能电表采集器",
     "category": "gateway",
     "nodeType": 0,
@@ -137,7 +137,7 @@
     "createAt": 1649653149339
   },
   {
-    "id": "PwMfpXmp4ZWkGahn",
+    "productKey": "PwMfpXmp4ZWkGahn",
     "name": "智能电表",
     "category": "SmartMeter",
     "nodeType": 1,

+ 16 - 16
data/init/thingModel.json

@@ -1,6 +1,6 @@
 [
   {
-    "id": "xpsYHExTKPFaQMS7",
+    "id": "0",
     "productKey": "xpsYHExTKPFaQMS7",
     "model": {
       "properties": [
@@ -34,7 +34,7 @@
     }
   },
   {
-    "id": "hdX3PCMcFrCYpesJ",
+    "id": "1",
     "productKey": "hdX3PCMcFrCYpesJ",
     "model": {
       "properties": [
@@ -82,7 +82,7 @@
     }
   },
   {
-    "id": "hbtgIA0SuVw9lxjB",
+    "id": "2",
     "productKey": "hbtgIA0SuVw9lxjB",
     "model": {
       "properties": [],
@@ -178,7 +178,7 @@
     }
   },
   {
-    "id": "eDhXKwEzwFybM5R7",
+    "id": "3",
     "productKey": "eDhXKwEzwFybM5R7",
     "model": {
       "properties": [
@@ -274,7 +274,7 @@
     }
   },
   {
-    "id": "cGCrkK7Ex4FESAwe",
+    "id": "4",
     "productKey": "cGCrkK7Ex4FESAwe",
     "model": {
       "properties": [
@@ -344,7 +344,7 @@
     }
   },
   {
-    "id": "Rf4QSjbm65X45753",
+    "id": "5",
     "productKey": "Rf4QSjbm65X45753",
     "model": {
       "properties": [
@@ -436,7 +436,7 @@
     "_class": "cc.iotkit.model.ThingModel"
   },
   {
-    "id": "PN3EDmkBZDD8whDd",
+    "id": "6",
     "productKey": "PN3EDmkBZDD8whDd",
     "model": {
       "properties": [
@@ -496,7 +496,7 @@
     }
   },
   {
-    "id": "N523nWsCiG3CAn6X",
+    "id": "7",
     "productKey": "N523nWsCiG3CAn6X",
     "model": {
       "properties": [
@@ -658,7 +658,7 @@
     }
   },
   {
-    "id": "KdJYpTp5ywNhmrmC",
+    "id": "8",
     "productKey": "KdJYpTp5ywNhmrmC",
     "model": {
       "properties": [],
@@ -684,7 +684,7 @@
     }
   },
   {
-    "id": "Eit3kmGJtxSHfCKT",
+    "id": "9",
     "productKey": "Eit3kmGJtxSHfCKT",
     "model": {
       "properties": [
@@ -718,7 +718,7 @@
     }
   },
   {
-    "id": "D8c5pXFmt2KJDxNm",
+    "id": "10",
     "productKey": "D8c5pXFmt2KJDxNm",
     "model": {
       "properties": [
@@ -814,7 +814,7 @@
     }
   },
   {
-    "id": "AWcJnf7ymGSkaz5M",
+    "id": "11",
     "productKey": "AWcJnf7ymGSkaz5M",
     "model": {
       "properties": [
@@ -944,7 +944,7 @@
     }
   },
   {
-    "id": "6kYp6jszrDns2yh4",
+    "id": "12",
     "productKey": "6kYp6jszrDns2yh4",
     "model": {
       "properties": [
@@ -984,7 +984,7 @@
     }
   },
   {
-    "id": "bGdZt8ffBETtsirm",
+    "id": "13",
     "productKey": "bGdZt8ffBETtsirm",
     "model": {
       "properties": [
@@ -1047,7 +1047,7 @@
     }
   },
   {
-    "id": "BRD3x4fkKxkaxXFt",
+    "id": "14",
     "productKey": "BRD3x4fkKxkaxXFt",
     "model": {
       "properties": [],
@@ -1115,7 +1115,7 @@
     }
   },
   {
-    "id": "PwMfpXmp4ZWkGahn",
+    "id": "15",
     "productKey": "PwMfpXmp4ZWkGahn",
     "model": {
       "properties": [

+ 1 - 1
iot-common/iot-common-dao/iot-common-model/src/main/java/cc/iotkit/model/product/Product.java

@@ -24,7 +24,7 @@ public class Product extends TenantModel implements Id<Long>, Serializable {
 
     private Long id;
 
-    private String key;
+    private String productKey;
 
     private String name;
 

+ 1 - 1
iot-common/iot-common-dao/iot-data-service/src/main/java/cc/iotkit/data/manager/IProductData.java

@@ -25,5 +25,5 @@ public interface IProductData extends ICommonData<Product,Long> {
     List<Product> findByCategory(String category);
 
 
-
+    Product findByProductKey(String name);
 }

+ 1 - 0
iot-common/iot-common-dao/iot-data-service/src/main/java/cc/iotkit/data/manager/IThingModelData.java

@@ -5,4 +5,5 @@ import cc.iotkit.model.product.ThingModel;
 
 public interface IThingModelData extends ICommonData<ThingModel, Long> {
 
+    ThingModel findByProductKey(String productKey);
 }

+ 7 - 0
iot-common/iot-common-dao/iot-data-serviceImpl-cache/src/main/java/cc/iotkit/data/service/ProductDataCache.java

@@ -28,6 +28,12 @@ public class ProductDataCache implements IProductData {
         return productData.findByCategory(category);
     }
 
+    @Override
+    @Cacheable(value = Constants.CACHE_PRODUCT, key = "#root.method.name+#s", unless = "#result == null")
+    public Product findByProductKey(String productKey) {
+        return productData.findByProductKey(productKey);
+    }
+
 //    @Override
 //    public List<Product> findByUid(String uid) {
 //        return productData.findByUid(uid);
@@ -45,6 +51,7 @@ public class ProductDataCache implements IProductData {
 
     @Override
     @Cacheable(value = Constants.CACHE_PRODUCT, key = "#root.method.name+#s", unless = "#result == null")
+    @Deprecated
     public Product findById(Long s) {
         return productData.findById(s);
     }

+ 7 - 1
iot-common/iot-common-dao/iot-data-serviceImpl-cache/src/main/java/cc/iotkit/data/service/ThingModelDataCache.java

@@ -49,10 +49,11 @@ public class ThingModelDataCache implements IThingModelData {
     @Override
     public void deleteById(Long s) {
         thingModelData.deleteById(s);
+        thingModelCacheEvict.findById(s);
     }
 
     @Override
-    public void deleteByIds(Collection<Long> strings) {
+    public void deleteByIds(Collection<Long> ids) {
 
     }
 
@@ -81,4 +82,9 @@ public class ThingModelDataCache implements IThingModelData {
         return null;
     }
 
+    @Override
+    @Cacheable(value = Constants.CACHE_THING_MODEL, key = "#root.method.name+#s", unless = "#result == null")
+    public ThingModel findByProductKey(String productKey) {
+        return thingModelData.findByProductKey(productKey);
+    }
 }

+ 1 - 0
iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/dao/ProductRepository.java

@@ -26,4 +26,5 @@ public interface ProductRepository extends JpaRepository<TbProduct, Long> {
 
     long countByUid(String uid);
 
+    TbProduct findByProductKey(String productKey);
 }

+ 3 - 0
iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/dao/ThingModelRepository.java

@@ -12,6 +12,9 @@ package cc.iotkit.data.dao;
 import cc.iotkit.data.model.TbThingModel;
 import org.springframework.data.jpa.repository.JpaRepository;
 
+import java.util.Optional;
+
 public interface ThingModelRepository extends JpaRepository<TbThingModel, Long> {
 
+    Optional<TbThingModel> findByProductKey(String productKey);
 }

+ 1 - 1
iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/DeviceInfoDataImpl.java

@@ -363,7 +363,7 @@ public class DeviceInfoDataImpl implements IDeviceInfoData,IJPACommData<DeviceIn
                 args.toArray());
         for (DataItem item : rst) {
             //找到产品对应的品类取出品类名
-            Product product = productData.findById(item.getName());
+            Product product = productData.findByProductKey(item.getName());
             String cateId = product.getCategory();
             Category category = categoryData.findById(cateId);
             if (category == null) {

+ 7 - 1
iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/ProductDataImpl.java

@@ -43,6 +43,11 @@ public class ProductDataImpl implements IProductData, IJPACommData<Product, Long
         return MapstructUtils.convert(productRepository.findByCategory(category), Product.class);
     }
 
+    @Override
+    public Product findByProductKey(String productKey) {
+        return MapstructUtils.convert(productRepository.findByProductKey(productKey), Product.class);
+    }
+
     public List<Product> findByUid(String uid) {
         return MapstructUtils.convert(productRepository.findByUid(uid), Product.class);
     }
@@ -59,8 +64,9 @@ public class ProductDataImpl implements IProductData, IJPACommData<Product, Long
     }
 
     @Override
+    @Deprecated
     public Product findById(Long id) {
-        return MapstructUtils.convert(productRepository.findById(id).orElse(null), Product.class);
+        throw new IllegalStateException("Deprecated method");
     }
 
     @Override

+ 9 - 0
iot-common/iot-common-dao/iot-data-serviceImpl-rdb/src/main/java/cc/iotkit/data/service/ThingModelDataImpl.java

@@ -71,4 +71,13 @@ public class ThingModelDataImpl implements IThingModelData, IJPACommData<ThingMo
         thingModelRepository.deleteById(id);
     }
 
+    @Override
+    public ThingModel findByProductKey(String productKey) {
+        TbThingModel tbThingModel = thingModelRepository.findByProductKey(productKey).orElse(null);
+        ThingModel convert = MapstructUtils.convert(tbThingModel, ThingModel.class);
+        if (tbThingModel != null && convert != null) {
+            convert.setModel(JsonUtils.parseObject(tbThingModel.getModel(), ThingModel.Model.class));
+        }
+        return convert;
+    }
 }

+ 1 - 1
iot-components/iot-component-server/src/main/java/cc/iotkit/comps/DeviceComponentManager.java

@@ -205,7 +205,7 @@ public class DeviceComponentManager {
         }
 
         DeviceInfo deviceInfo = deviceInfoData.findByProductKeyAndDeviceName(service.getProductKey(), service.getDeviceName());
-        Product product = productData.findById(service.getProductKey());
+        Product product = productData.findByProductKey(service.getProductKey());
         String linkPk = service.getProductKey();
         String linkDn = service.getDeviceName();
 

+ 2 - 2
iot-components/iot-component-server/src/main/java/cc/iotkit/comps/service/DeviceBehaviourService.java

@@ -91,7 +91,7 @@ public class DeviceBehaviourService {
             }
         }
 
-        Product product = productData.findById(pk);
+        Product product = productData.findByProductKey(pk);
         if (product == null) {
             throw new BizException(ErrCode.PRODUCT_NOT_FOUND);
         }
@@ -203,7 +203,7 @@ public class DeviceBehaviourService {
         List<String> subDeviceIds = deviceInfoData.findSubDeviceIds(device.getDeviceId());
         for (String subDeviceId : subDeviceIds) {
             DeviceInfo subDevice = deviceInfoData.findByDeviceId(subDeviceId);
-            Product product = productData.findById(subDevice.getProductKey());
+            Product product = productData.findByProductKey(subDevice.getProductKey());
             Boolean transparent = product.getTransparent();
             //透传设备父设备上线,子设备也上线。非透传设备父设备离线,子设备才离线
             if (transparent != null && transparent || !online) {

+ 1 - 1
iot-components/iot-component-server/src/main/java/cc/iotkit/comps/service/DevicePropertyConsumer.java

@@ -66,7 +66,7 @@ public class DevicePropertyConsumer implements ConsumerHandler<ThingModelMessage
         }
 
         //物模型校验,过滤非物模型属性
-        ThingModel thingModel = thingModelData.findById(deviceInfo.getProductKey());
+        ThingModel thingModel = thingModelData.findByProductKey(deviceInfo.getProductKey());
         if (thingModel == null) {
             return;
         }

+ 2 - 2
iot-module/iot-manager/src/main/java/cc/iotkit/manager/controller/SpaceDeviceController.java

@@ -116,7 +116,7 @@ public class SpaceDeviceController {
     private SpaceDeviceVo parseSpaceDevice(SpaceDevice sd) {
         DeviceInfo device = deviceInfoData.findByDeviceId(sd.getDeviceId());
         Space space = spaceData.findById(sd.getSpaceId());
-        Product product = productData.findById(device.getProductKey());
+        Product product = productData.findByProductKey(device.getProductKey());
         Category category = categoryData.findById(product.getCategory());
         DeviceInfo.State state = device.getState();
 
@@ -194,7 +194,7 @@ public class SpaceDeviceController {
                 .productKey(device.getProductKey())
                 .build();
 
-        Product product = productData.findById(device.getProductKey());
+        Product product = productData.findByProductKey(device.getProductKey());
         Category category = categoryData.findById(product.getCategory());
         findDeviceVo.setProductName(product.getName());
         findDeviceVo.setProductImg(product.getImg());

+ 1 - 1
iot-module/iot-manager/src/main/java/cc/iotkit/manager/controller/StatsController.java

@@ -57,7 +57,7 @@ public class StatsController {
             mainStats.setDeviceStatsOfCategory(deviceInfoData.getDeviceStatsByCategory(""));
         } else {
             mainStats.setCategoryTotal(ICategoryData.count());
-            mainStats.setProductTotal(productData.countByUid(uid));
+//            mainStats.setProductTotal(productData.countByUid(uid));
             mainStats.setDeviceTotal(deviceInfoData.countByUid(uid));
 //            mainStats.setReportTotal(deviceReportRepository.countByUid(uid));
             //上报数据统计

+ 3 - 2
iot-module/iot-manager/src/main/java/cc/iotkit/manager/dto/bo/product/ProductBo.java

@@ -32,9 +32,10 @@ public class ProductBo extends BaseDto  {
 
 	private static final long serialVersionUID = -1L;
 
-
 	@ApiModelProperty(value="id")
-	private String id;
+	private Long id;
+	@ApiModelProperty(value="productKey")
+	private String productKey;
 
 	@ApiModelProperty(value="品类")
 	@Size(max = 255, message = "品类长度不正确")

+ 5 - 1
iot-module/iot-manager/src/main/java/cc/iotkit/manager/dto/vo/product/ProductVo.java

@@ -25,7 +25,11 @@ public class ProductVo implements Serializable  {
 
 	@ApiModelProperty(value="产品id")
     @ExcelProperty(value = "产品id")
-		private String id;
+		private Long id;
+
+	@ApiModelProperty(value="产品id")
+	@ExcelProperty(value = "产品id")
+	private String productKey;
 
 	@ApiModelProperty(value="品类")
     @ExcelProperty(value = "品类")

+ 1 - 1
iot-module/iot-manager/src/main/java/cc/iotkit/manager/service/SpaceDeviceService.java

@@ -49,7 +49,7 @@ public class SpaceDeviceService {
         List<SpaceDeviceVo> spaceDeviceVos = new ArrayList<>();
         spaceDevices.forEach(sd -> {
             DeviceInfo deviceInfo = deviceInfoData.findByDeviceId(sd.getDeviceId());
-            Product product = productData.findById(deviceInfo.getProductKey());
+            Product product = productData.findByProductKey(deviceInfo.getProductKey());
             spaceDeviceVos.add(SpaceDeviceVo.builder()
                     .uid(sd.getUid())
                     .deviceId(sd.getDeviceId())

+ 1 - 1
iot-module/iot-manager/src/main/java/cc/iotkit/manager/service/ThingModelService.java

@@ -26,7 +26,7 @@ public class ThingModelService {
     private IThingModelData thingModelData;
 
     public void parseParams(ThingService<Object> service) {
-        ThingModel thingModel = thingModelData.findById(service.getProductKey());
+        ThingModel thingModel = thingModelData.findByProductKey(service.getProductKey());
         ThingModel.Model model = thingModel.getModel();
 
         String type = service.getType();

+ 1 - 1
iot-module/iot-manager/src/main/java/cc/iotkit/manager/service/impl/DeviceServiceImpl.java

@@ -115,7 +115,7 @@ public class DeviceServiceImpl implements IDeviceService {
         String deviceName = deviceInfo.getDeviceName();
         String parentId = deviceInfo.getParentId();
 
-        Product product = productData.findById(productKey);
+        Product product = productData.findByProductKey(productKey);
         if (product == null) {
             throw new BizException(ErrCode.PRODUCT_NOT_FOUND);
         }

+ 6 - 7
iot-module/iot-manager/src/main/java/cc/iotkit/manager/service/impl/ProductServiceImpl.java

@@ -98,14 +98,13 @@ public class ProductServiceImpl implements IProductService {
 
     @Override
     public ProductVo getDetail(String productKey) {
-        return MapstructUtils.convert(productData.findById(productKey), ProductVo.class);
+        return MapstructUtils.convert(productData.findByProductKey(productKey), ProductVo.class);
     }
 
     @Override
     public ThingModelVo getThingModelByProductKey(String productKey) {
-//        ThingModel thingModel = thingModelData.findById(productKey);
-        // todo
-        ThingModel thingModel = thingModelData.findById(0L);
+
+        ThingModel thingModel = thingModelData.findByProductKey(productKey);
         return MapstructUtils.convert(thingModel, ThingModelVo.class);
     }
 
@@ -206,7 +205,7 @@ public class ProductServiceImpl implements IProductService {
         ProductModel productModel = productModelBo.to(ProductModel.class);
         String model = productModel.getModel();
         String productKey = productModel.getProductKey();
-        Product product = productData.findById(productKey);
+        Product product = productData.findByProductKey(productKey);
         if (product == null) {
             throw new BizException(ErrCode.PRODUCT_NOT_FOUND);
         }
@@ -222,13 +221,13 @@ public class ProductServiceImpl implements IProductService {
     }
 
     private Product getProduct(String productKey) {
-        return productData.findById(productKey);
+        return productData.findByProductKey(productKey);
     }
 
 
     /***********/
     private void checkProductOwner(String productKey) {
-//        dataOwnerService.checkOwner(productData.findById(productKey));
+//        dataOwnerService.checkOwner(productData.findByProductKey(productKey));
     }
 
 }