|
|
@@ -20,9 +20,11 @@ public class TypeCacheService {
|
|
|
private RedisCacheManager redisCacheManager;
|
|
|
|
|
|
public void setCache(TosDevicetype tosDevicetype){
|
|
|
+ redisCacheManager.setCacheObject(RedisCacheKey.IOT_DEVICE_TYPE,tosDevicetype.getDevtypeBid(),tosDevicetype);
|
|
|
redisCacheManager.setCacheObject(RedisCacheKey.IOT_DEVICE_TYPE,tosDevicetype.getDevtypeCode(),tosDevicetype);
|
|
|
}
|
|
|
public void deleteCache(TosDevicetype tosDevicetype){
|
|
|
+ redisCacheManager.deleteObject(RedisCacheKey.IOT_DEVICE_TYPE,tosDevicetype.getDevtypeBid());
|
|
|
redisCacheManager.deleteObject(RedisCacheKey.IOT_DEVICE_TYPE,tosDevicetype.getDevtypeCode());
|
|
|
}
|
|
|
|
|
|
@@ -33,7 +35,14 @@ public class TypeCacheService {
|
|
|
}
|
|
|
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){
|
|
|
throw new IotBizException(IotErrorCode.INVALID_DEVICE_TYPE);
|
|
|
}
|
|
|
@@ -43,5 +52,16 @@ public class TypeCacheService {
|
|
|
}
|
|
|
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();
|
|
|
+ }
|
|
|
|
|
|
}
|