解决规则缓存重复存储报错问题

This commit is contained in:
zhangjunwen 2024-04-22 11:13:03 +08:00
parent 5baec55fe7
commit 47286e93c3

View File

@ -46,8 +46,10 @@ public class IpcAlarmRulesServiceImpl implements IIpcAlarmRulesService
public void init(){
List<IpcEquipInfo> equips = ipcEquipInfoService.selectIpcEquipInfoList(null);
for (IpcEquipInfo equip : equips) {
List<IpcAlarmRules> rulesByEquipId = selectIpcAlarmRulesByEquipId(equip.getId());
redisCache.setCacheList((CacheConstants.IPC_RULES_KEY+equip.getId()),rulesByEquipId);
if(!redisCache.hasKey((CacheConstants.IPC_RULES_KEY+equip.getId()))) {
List<IpcAlarmRules> rulesByEquipId = selectIpcAlarmRulesByEquipId(equip.getId());
redisCache.setCacheList((CacheConstants.IPC_RULES_KEY + equip.getId()), rulesByEquipId);
}
}
}
@ -169,6 +171,7 @@ public class IpcAlarmRulesServiceImpl implements IIpcAlarmRulesService
*/
@Override
public List<IpcAlarmRules> selectIpcAlarmRulesConfigListByCache(String equipId){
List<IpcAlarmRules> rules = redisCache.getCacheList(CacheConstants.IPC_RULES_KEY + equipId);
if (rules == null || rules.size() == 0){
List<IpcAlarmRules> rulesList = selectIpcAlarmRulesByEquipId(equipId);