删除redis缓存修改
This commit is contained in:
parent
539ebf0be9
commit
ea697c781f
|
|
@ -270,10 +270,12 @@ public class DeviceHelper implements DeviceHelperI {
|
|||
/**
|
||||
* 根据设备ID获取设备统计信息
|
||||
*
|
||||
* @param macAddress
|
||||
* @param deviceId
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@Override
|
||||
public Tbl_Device_Statistics getDeviceStatisticsByMacAddress(String macAddress) throws Exception {
|
||||
Tbl_Device_Statistics device = null;
|
||||
String key = redisKeyHelperI.getTbl_Device_StatisticsRedisKeyByMacAddress(macAddress);
|
||||
|
|
@ -312,4 +314,26 @@ public class DeviceHelper implements DeviceHelperI {
|
|||
return device;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据摄像头ID从缓存中取得设备信息
|
||||
*
|
||||
* @param cameraId
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@Override
|
||||
public Tbl_Device getDeviceByCameraId(String cameraId) throws Exception {
|
||||
Tbl_Device device = null;
|
||||
String key = redisKeyHelperI.getTbl_CameraRedisKeyByCameraId(cameraId);
|
||||
String redisString = redisHelperI.getRedis(key);
|
||||
if (StringUtils.isNotBlank(redisString)) {
|
||||
device = (Tbl_Device) IfishUtil.JsonToBean(redisString, Tbl_Device.class);
|
||||
} else {
|
||||
device = tbl_Device_Mapper.getDeviceByCameraId(cameraId);
|
||||
if (device != null && device.getDeviceId() > 0) {
|
||||
redisHelperI.setRedis(key, IfishUtil.ObjectToJson(device));
|
||||
}
|
||||
}
|
||||
return device;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,6 +44,15 @@ public interface DeviceHelperI {
|
|||
*/
|
||||
public void updateWarnOnoff(String macAddress, String onOff);
|
||||
|
||||
/**
|
||||
* 根据设备Id获取设备详情
|
||||
*
|
||||
* @param deviceId
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
Tbl_Device getDeviceById(Integer deviceId) throws Exception;
|
||||
|
||||
/**
|
||||
* 根据mac地址查找设备
|
||||
*
|
||||
|
|
@ -53,6 +62,14 @@ public interface DeviceHelperI {
|
|||
*/
|
||||
public Tbl_Device getDeviceByMacAddress(String macAddress);
|
||||
|
||||
/**
|
||||
* 根据摄像头ID获取设备信息
|
||||
*
|
||||
* @param cameraId
|
||||
* @return
|
||||
*/
|
||||
Tbl_Device getDeviceByCameraId(String cameraId) throws Exception;
|
||||
|
||||
/**
|
||||
* 修改设备统计信息
|
||||
*
|
||||
|
|
@ -70,13 +87,13 @@ public interface DeviceHelperI {
|
|||
public List<Tbl_Device_User> getTbl_Device_UsersListByDeviceId(Integer deviceId);
|
||||
|
||||
/**
|
||||
* 根据设备Id获取设备详情
|
||||
* 根据设备ID获取设备统计信息
|
||||
*
|
||||
* @param deviceId
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
Tbl_Device getDeviceById(Integer deviceId) throws Exception;
|
||||
public Tbl_Device_Statistics getDeviceStatisticsByMacAddress(String macAddress) throws Exception;
|
||||
|
||||
/**
|
||||
* 根据设备ID获取设备统计信息
|
||||
|
|
|
|||
|
|
@ -26,9 +26,10 @@ public class RedisKeyHelper implements RedisKeyHelperI {
|
|||
|
||||
@Autowired
|
||||
private RedisHelperI redisHelperI;
|
||||
|
||||
@Autowired
|
||||
private DeviceHelperI deviceHelper;
|
||||
@Autowired
|
||||
private UserHelperI userHelperI;
|
||||
|
||||
/**
|
||||
* 根据phoneNumber获取Tbl_User用户信息的Redis缓存key键值
|
||||
|
|
@ -310,7 +311,6 @@ public class RedisKeyHelper implements RedisKeyHelperI {
|
|||
* @return
|
||||
*/
|
||||
@Override
|
||||
|
||||
public String getTbl_Live_Room_CountRedisKey() {
|
||||
return RedisKey.LIVEROOM_COUNT;
|
||||
}
|
||||
|
|
@ -377,8 +377,18 @@ public class RedisKeyHelper implements RedisKeyHelperI {
|
|||
*/
|
||||
@Override
|
||||
public void deleteRedisByTbl_Device(Tbl_Device device) {
|
||||
deleteTbl_DeviceInfo(device);
|
||||
|
||||
try {
|
||||
if (device.getDeviceId() != null && device.getDeviceId() != 0 && StringUtils.isBlank(device.getMacAddress())) {
|
||||
device = deviceHelper.getDeviceById(device.getDeviceId());
|
||||
}
|
||||
if (StringUtils.isNotBlank(device.getMacAddress()) && (device.getDeviceId() == null || device.getDeviceId() == 0)) {
|
||||
device = deviceHelper.getDeviceByMacAddress(device.getMacAddress());
|
||||
}
|
||||
if (StringUtils.isNotBlank(device.getCameraId()) && (device.getDeviceId() == null || device.getDeviceId() == 0)) {
|
||||
device = deviceHelper.getDeviceByCameraId(device.getCameraId());
|
||||
}
|
||||
deleteTbl_DeviceInfo(device);
|
||||
Tbl_Device_Statistics device_Statistics = deviceHelper.getDeviceStatisticsByDeviceId(device.getDeviceId());
|
||||
deleteTbl_Device_StatisticsInfo(device_Statistics);
|
||||
} catch (Exception e) {
|
||||
|
|
@ -405,8 +415,15 @@ public class RedisKeyHelper implements RedisKeyHelperI {
|
|||
*/
|
||||
@Override
|
||||
public void deleteRedisByTbl_Device_Statistics(Tbl_Device_Statistics device) {
|
||||
deleteTbl_Device_StatisticsInfo(device);
|
||||
|
||||
try {
|
||||
if (device.getDeviceId() != null && device.getDeviceId() != 0 && StringUtils.isBlank(device.getMacAddress())) {
|
||||
device = deviceHelper.getDeviceStatisticsByDeviceId(device.getDeviceId());
|
||||
}
|
||||
if (StringUtils.isNotBlank(device.getMacAddress()) && (device.getDeviceId() == null || device.getDeviceId() == 0)) {
|
||||
device = deviceHelper.getDeviceStatisticsByMacAddress(device.getMacAddress());
|
||||
}
|
||||
deleteTbl_Device_StatisticsInfo(device);
|
||||
Tbl_Device device1 = deviceHelper.getDeviceById(device.getDeviceId());
|
||||
deleteTbl_DeviceInfo(device1);
|
||||
} catch (Exception e) {
|
||||
|
|
@ -415,10 +432,10 @@ public class RedisKeyHelper implements RedisKeyHelperI {
|
|||
|
||||
public void deleteTbl_Device_StatisticsInfo(Tbl_Device_Statistics device) {
|
||||
if (device.getDeviceId() != null && device.getDeviceId() > 0) {
|
||||
redisHelperI.deleteRedis(getTbl_DeviceRedisKeyByDeviceId(device.getDeviceId()));
|
||||
redisHelperI.deleteRedis(getTbl_Device_StatisticsRedisKeyByDeviceId(device.getDeviceId()));
|
||||
}
|
||||
if (StringUtils.isNotBlank(device.getMacAddress())) {
|
||||
redisHelperI.deleteRedis(getTbl_DeviceRedisKeyByMacAddress(device.getMacAddress()));
|
||||
redisHelperI.deleteRedis(getTbl_Device_StatisticsRedisKeyByMacAddress(device.getMacAddress()));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -438,6 +455,7 @@ public class RedisKeyHelper implements RedisKeyHelperI {
|
|||
deleteTbl_Device_StatisticsInfo(device_Statistics);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void deleteTbl_Device_UserInfo(Tbl_Device_User tbl_Device_User) {
|
||||
|
|
@ -459,6 +477,12 @@ public class RedisKeyHelper implements RedisKeyHelperI {
|
|||
*/
|
||||
@Override
|
||||
public void deleteRedisByTbl_User(Tbl_User tbl_User) {
|
||||
try {
|
||||
if (tbl_User.getUserId() != null && tbl_User.getUserId() > 0) {
|
||||
tbl_User = userHelperI.findById(tbl_User.getUserId());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
if (tbl_User.getUserId() != null && tbl_User.getUserId() > 0) {
|
||||
redisHelperI.deleteRedis(getTbl_UserRedisKeyByUserId(tbl_User.getUserId()));
|
||||
}
|
||||
|
|
@ -483,11 +507,12 @@ public class RedisKeyHelper implements RedisKeyHelperI {
|
|||
*/
|
||||
@Override
|
||||
public void deleteRedisByTbl_Live_Room(Tbl_Live_Room live_Room) {
|
||||
|
||||
if (live_Room.getRoomId() != null && live_Room.getRoomId() > 0) {
|
||||
redisHelperI.deleteRedis(getTbl_Live_RoomRedisKeyByRoomId(live_Room.getRoomId()));
|
||||
}
|
||||
if (StringUtils.isNotBlank(live_Room.getCameraId())) {
|
||||
redisHelperI.deleteRedis(live_Room.getCameraId());
|
||||
redisHelperI.deleteRedis(getTbl_Live_RoomRedisKeyByCameraId(live_Room.getCameraId()));
|
||||
}
|
||||
if (live_Room.getUserId() != null && live_Room.getUserId() > 0) {
|
||||
redisHelperI.deleteRedis(getTbl_Live_RoomRedisKeyByUserId(live_Room.getUserId()));
|
||||
|
|
@ -590,4 +615,5 @@ public class RedisKeyHelper implements RedisKeyHelperI {
|
|||
public void deleteRedisByTbl_Push_ListToAllRedisList() {
|
||||
redisHelperI.delRedisByTagKey(RedisKey.PUSHLIST_SELECT);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue