设备缓存删除修改

This commit is contained in:
谢洪龙 2017-08-01 13:46:38 +08:00
parent 541246a732
commit 77580eab64
3 changed files with 47 additions and 3 deletions

View File

@ -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);

View File

@ -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获取设备详情
*

View File

@ -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());
}
}