Просмотр исходного кода

新增根据类型标识查询实现类方法

liuyaowen 1 год назад
Родитель
Сommit
f7c28677b3
1 измененных файлов с 21 добавлено и 1 удалено
  1. 21 1
      src/main/java/com/yunfeiyun/agmp/iot/common/service/TypeCacheService.java

+ 21 - 1
src/main/java/com/yunfeiyun/agmp/iot/common/service/TypeCacheService.java

@@ -20,9 +20,11 @@ public class TypeCacheService {
     private RedisCacheManager redisCacheManager;
     private RedisCacheManager redisCacheManager;
 
 
     public void setCache(TosDevicetype tosDevicetype){
     public void setCache(TosDevicetype tosDevicetype){
+        redisCacheManager.setCacheObject(RedisCacheKey.IOT_DEVICE_TYPE,tosDevicetype.getDevtypeBid(),tosDevicetype);
         redisCacheManager.setCacheObject(RedisCacheKey.IOT_DEVICE_TYPE,tosDevicetype.getDevtypeCode(),tosDevicetype);
         redisCacheManager.setCacheObject(RedisCacheKey.IOT_DEVICE_TYPE,tosDevicetype.getDevtypeCode(),tosDevicetype);
     }
     }
     public void deleteCache(TosDevicetype tosDevicetype){
     public void deleteCache(TosDevicetype tosDevicetype){
+        redisCacheManager.deleteObject(RedisCacheKey.IOT_DEVICE_TYPE,tosDevicetype.getDevtypeBid());
         redisCacheManager.deleteObject(RedisCacheKey.IOT_DEVICE_TYPE,tosDevicetype.getDevtypeCode());
         redisCacheManager.deleteObject(RedisCacheKey.IOT_DEVICE_TYPE,tosDevicetype.getDevtypeCode());
     }
     }
 
 
@@ -33,7 +35,14 @@ public class TypeCacheService {
         }
         }
         return JSONObject.parseObject(JSONObject.toJSONString(tosDevicetype), TosDevicetype.class);
         return JSONObject.parseObject(JSONObject.toJSONString(tosDevicetype), TosDevicetype.class);
     }
     }
-    public String getServiceName(String devtypeCode){
+    public TosDevicetype getCacheObjectByDevTypeBid(String devtypeBid){
+        Object tosDevicetype = redisCacheManager.getCacheObject(RedisCacheKey.IOT_DEVICE_TYPE,devtypeBid);
+        if(null == tosDevicetype){
+            throw new IotBizException(IotErrorCode.CACHE_NOT_FOUNT);
+        }
+        return JSONObject.parseObject(JSONObject.toJSONString(tosDevicetype), TosDevicetype.class);
+    }
+    public String getServiceNameByDevTypeCode(String devtypeCode){
         if(null == devtypeCode){
         if(null == devtypeCode){
             throw new IotBizException(IotErrorCode.INVALID_DEVICE_TYPE);
             throw new IotBizException(IotErrorCode.INVALID_DEVICE_TYPE);
         }
         }
@@ -43,5 +52,16 @@ public class TypeCacheService {
         }
         }
         return iotDeviceDictEnum.getServiceName();
         return iotDeviceDictEnum.getServiceName();
     }
     }
+    public String getServiceNameByDevTypeBid(String devtypeBid){
+        TosDevicetype tosDevicetype = this.getCacheObjectByDevTypeBid(devtypeBid);
+        if(null == tosDevicetype){
+            throw new IotBizException(IotErrorCode.INVALID_DEVICE_TYPE);
+        }
+        IotDeviceDictEnum iotDeviceDictEnum = IotDeviceDictEnum.findEnumByCode(tosDevicetype.getDevtypeCode());
+        if(null == iotDeviceDictEnum){
+            throw new IotBizException(IotErrorCode.INVALID_DEVICE_TYPE);
+        }
+        return iotDeviceDictEnum.getServiceName();
+    }
 
 
 }
 }