Showing
2 changed files
with
23 additions
and
8 deletions
... | ... | @@ -133,7 +133,9 @@ class ReactState { |
133 | 133 | } |
134 | 134 | } else if (currentAlarms.containsKey(deviceId) && this.alarmAction != null) { |
135 | 135 | //清除设备告警 |
136 | - clearAlarm(ctx, msg, deviceId); | |
136 | + for (AlarmConditionFilterKey entityKey : triggerState.getEntityKeys()) { | |
137 | + clearAlarm(ctx, msg, deviceId, entityKey.getKey()); | |
138 | + } | |
137 | 139 | } |
138 | 140 | } |
139 | 141 | } |
... | ... | @@ -192,15 +194,28 @@ class ReactState { |
192 | 194 | |
193 | 195 | } |
194 | 196 | |
195 | - protected TriggerState getOrCreateClearState(String deviceId) { | |
197 | + protected TriggerState getOrCreateClearState(String deviceId,String key) { | |
198 | + String cacheKey = deviceId+key; | |
196 | 199 | if (triggerState.containsKey(deviceId)) { |
197 | - return triggerState.get(deviceId); | |
200 | + return triggerState.get(cacheKey); | |
198 | 201 | } |
199 | 202 | if (alarmAction.getDeviceId().contains(deviceId)) { |
203 | + TriggerState state = null; | |
200 | 204 | ActionAlarmDTO alarm = JacksonUtil.convertValue(alarmAction.getDoContext(), ActionAlarmDTO.class); |
201 | 205 | if (alarm != null && alarm.getClearRule() != null) { |
202 | - TriggerState state = createTriggerState(deviceId, alarm.getClearRule().getTriggerCondition()); | |
203 | - triggerState.put(deviceId, state); | |
206 | + for(TriggerDTO rule:alarm.getClearRule()){ | |
207 | + for (AlarmConditionFilter filter : rule.getTriggerCondition().getCondition().getCondition()) { | |
208 | + String tempKey =filter.getKey().getKey(); | |
209 | + if(key.equals(tempKey)){ | |
210 | + state = createTriggerState(deviceId, rule.getTriggerCondition()); | |
211 | + triggerState.put(cacheKey, state); | |
212 | + break; | |
213 | + } | |
214 | + } | |
215 | + if(state != null){ | |
216 | + break; | |
217 | + } | |
218 | + } | |
204 | 219 | return state; |
205 | 220 | } |
206 | 221 | } |
... | ... | @@ -320,8 +335,8 @@ class ReactState { |
320 | 335 | noticeService.alert(action.getAlarmProfileId(), formData); |
321 | 336 | } |
322 | 337 | |
323 | - private void clearAlarm(TbContext ctx, TbMsg msg, String deviceId) throws ExecutionException, InterruptedException { | |
324 | - TriggerState clearState = getOrCreateClearState(deviceId); | |
338 | + private void clearAlarm(TbContext ctx, TbMsg msg, String deviceId,String key) throws ExecutionException, InterruptedException { | |
339 | + TriggerState clearState = getOrCreateClearState(deviceId,key); | |
325 | 340 | if (clearState.process(ctx, msg)) { |
326 | 341 | ctx.getAlarmService().clearAlarmForResult(ctx.getTenantId(), currentAlarms.get(deviceId).getId(), null, System.currentTimeMillis()); |
327 | 342 | ytDeviceService.freshAlarmStatus(new DeviceId(UUID.fromString(deviceId)), 0); | ... | ... |