diff --git a/src/main/java/com/ifish/helper/DeviceHelper.java b/src/main/java/com/ifish/helper/DeviceHelper.java index d4de920..bf601ed 100644 --- a/src/main/java/com/ifish/helper/DeviceHelper.java +++ b/src/main/java/com/ifish/helper/DeviceHelper.java @@ -181,6 +181,7 @@ public class DeviceHelper implements DeviceHelperI { * @return * @throws Exception */ + @Override public Tbl_Device_Statistics getDeviceStatisticsByDeviceId(Integer deviceId) throws Exception { Tbl_Device_Statistics device = null; String key = redisKeyHelperI.getTbl_Device_StatisticsRedisKeyByDeviceId(deviceId); diff --git a/src/main/java/com/ifish/helper/DeviceHelperI.java b/src/main/java/com/ifish/helper/DeviceHelperI.java index bc83b8d..081ce4e 100644 --- a/src/main/java/com/ifish/helper/DeviceHelperI.java +++ b/src/main/java/com/ifish/helper/DeviceHelperI.java @@ -6,6 +6,7 @@ package com.ifish.helper; import com.ifish.bean.Tbl_Device; +import com.ifish.bean.Tbl_Device_Statistics; import com.ifish.bean.Tbl_Device_User; import com.ifish.bean.Tbl_User; import java.util.List; @@ -32,6 +33,15 @@ public interface DeviceHelperI { */ Tbl_Device_User getDeviceUserByUserId_CameraId(Integer userId, String cameraId) throws Exception; + /** + * 根据设备ID获取设备统计信息 + * + * @param deviceId + * @return + * @throws Exception + */ + public Tbl_Device_Statistics getDeviceStatisticsByDeviceId(Integer deviceId) throws Exception; + /** * 根据设备Id获取设备详情 * diff --git a/src/main/java/com/ifish/helper/RedisKeyHelper.java b/src/main/java/com/ifish/helper/RedisKeyHelper.java index cd5d5b0..dee27cd 100644 --- a/src/main/java/com/ifish/helper/RedisKeyHelper.java +++ b/src/main/java/com/ifish/helper/RedisKeyHelper.java @@ -22,10 +22,13 @@ import org.springframework.stereotype.Component; */ @Component public class RedisKeyHelper implements RedisKeyHelperI { - + @Autowired private RedisHelperI redisHelperI; + @Autowired + private DeviceHelperI deviceHelper; + /** * 根据phoneNumber获取Tbl_User用户信息的Redis缓存key键值 * @@ -306,7 +309,7 @@ public class RedisKeyHelper implements RedisKeyHelperI { * @return */ @Override - + public String getTbl_Live_Room_CountRedisKey() { return RedisKey.LIVEROOM_COUNT; } @@ -373,6 +376,15 @@ public class RedisKeyHelper implements RedisKeyHelperI { */ @Override public void deleteRedisByTbl_Device(Tbl_Device device) { + deleteTbl_DeviceInfo(device); + try { + Tbl_Device_Statistics device_Statistics = deviceHelper.getDeviceStatisticsByDeviceId(device.getDeviceId()); + deleteRedisByTbl_Device_Statistics(device_Statistics); + } catch (Exception e) { + } + } + + public void deleteTbl_DeviceInfo(Tbl_Device device) { if (device.getDeviceId() != null && device.getDeviceId() > 0) { redisHelperI.deleteRedis(getTbl_DeviceRedisKeyByDeviceId(device.getDeviceId())); } @@ -392,12 +404,22 @@ public class RedisKeyHelper implements RedisKeyHelperI { */ @Override public void deleteRedisByTbl_Device_Statistics(Tbl_Device_Statistics device) { + deleteTbl_Device_StatisticsInfo(device); + try { + Tbl_Device device1 = deviceHelper.getDeviceById(device.getDeviceId()); + deleteRedisByTbl_Device(device1); + } catch (Exception e) { + } + } + + public void deleteTbl_Device_StatisticsInfo(Tbl_Device_Statistics device) { if (device.getDeviceId() != null && device.getDeviceId() > 0) { redisHelperI.deleteRedis(getTbl_DeviceRedisKeyByDeviceId(device.getDeviceId())); } if (StringUtils.isNotBlank(device.getMacAddress())) { redisHelperI.deleteRedis(getTbl_DeviceRedisKeyByMacAddress(device.getMacAddress())); } + } /** @@ -407,6 +429,17 @@ public class RedisKeyHelper implements RedisKeyHelperI { */ @Override public void deleteRedisByTbl_Device_User(Tbl_Device_User tbl_Device_User) { + deleteTbl_Device_UserInfo(tbl_Device_User); + try { + Tbl_Device device1 = deviceHelper.getDeviceById(tbl_Device_User.getDeviceId()); + deleteRedisByTbl_Device(device1); + Tbl_Device_Statistics device_Statistics = deviceHelper.getDeviceStatisticsByDeviceId(tbl_Device_User.getDeviceId()); + deleteRedisByTbl_Device_Statistics(device_Statistics); + } catch (Exception e) { + } + } + + public void deleteTbl_Device_UserInfo(Tbl_Device_User tbl_Device_User) { if (tbl_Device_User.getDeviceId() != null && tbl_Device_User.getUserId() != null && tbl_Device_User.getDeviceId() > 0 && tbl_Device_User.getUserId() > 0) { redisHelperI.deleteRedis(getTbl_Device_UserRedisKeyByDeviceIdAndUserId(tbl_Device_User.getUserId(), tbl_Device_User.getDeviceId())); } @@ -480,5 +513,5 @@ public class RedisKeyHelper implements RedisKeyHelperI { redisHelperI.delRedisByTagKey(RedisKey.LIVEMESSAGE_ROOMID + tbl_Live_Message.getRoomId()); redisHelperI.deleteRedis(RedisKey.LIVEMESSAGE_COUNT + tbl_Live_Message.getRoomId()); } - + }