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

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

View File

@ -46,10 +46,12 @@ public class IpcAlarmRulesServiceImpl implements IIpcAlarmRulesService
public void init(){
List<IpcEquipInfo> equips = ipcEquipInfoService.selectIpcEquipInfoList(null);
for (IpcEquipInfo equip : equips) {
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);