|
...
|
...
|
@@ -19,7 +19,7 @@ import java.util.List; |
|
|
|
* 告警工厂
|
|
|
|
*/
|
|
|
|
public abstract class UpAlarmFactory<T> {
|
|
|
|
private static final Logger logger = LoggerFactory.getLogger(UpAlarmFactory.class);
|
|
|
|
protected static final Logger logger = LoggerFactory.getLogger(UpAlarmFactory.class);
|
|
|
|
protected List<IotAlertLog> list = new ArrayList<>();
|
|
|
|
|
|
|
|
protected T beforeupAlarmDb;
|
|
...
|
...
|
@@ -46,6 +46,13 @@ public abstract class UpAlarmFactory<T> { |
|
|
|
return new IotTerminalAlarm(IotTerminal.instantiate(beforecolumns),IotTerminal.instantiate(aftercolumns));
|
|
|
|
case "mqtt_broker.iot_alert":
|
|
|
|
return new IotAlertAlarm(IotAlert.instantiate(beforecolumns),IotAlert.instantiate(aftercolumns));
|
|
|
|
|
|
|
|
case "mqtt_broker.iot_alert_notice_channel":
|
|
|
|
return new IotAlertNoticeChannelUpCach(IotAlertNoticeChannel.instantiate(beforecolumns),IotAlertNoticeChannel.instantiate(aftercolumns));
|
|
|
|
case "mqtt_broker.iot_alert_user_notice":
|
|
|
|
return new IotAlertUserNoticeUpCack(IotAlertUserNotice.instantiate(beforecolumns),IotAlertUserNotice.instantiate(aftercolumns));
|
|
|
|
case "mqtt_broker.user_openid":
|
|
|
|
return new UserOpenidUpCach(UserOpenid.instantiate(beforecolumns),UserOpenid.instantiate(aftercolumns));
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
...
|
...
|
@@ -75,6 +82,10 @@ public abstract class UpAlarmFactory<T> { |
|
|
|
|
|
|
|
protected void valueUp(String client_id,Integer product_id,String oldvalue,String newValue,Integer user_id,String device_name)
|
|
|
|
{
|
|
|
|
if ("864814074929612".equals(client_id))
|
|
|
|
{
|
|
|
|
System.out.println(client_id);
|
|
|
|
}
|
|
|
|
if(StringUtils.isNotEmpty(newValue))
|
|
|
|
{
|
|
|
|
JSONObject oldjson = null==oldvalue?new JSONObject():JSONObject.parseObject(oldvalue);
|
|
...
|
...
|
@@ -129,7 +140,7 @@ public abstract class UpAlarmFactory<T> { |
|
|
|
String alrmname = attributeTriggers.getValueMapName().get(newValue);
|
|
|
|
if(StringUtils.isNotEmpty(alrmname))
|
|
|
|
{
|
|
|
|
IotAlertLog iotAlertLog = new IotAlertLog(iotAlert.getAlertId(),alrmname,iotAlert.getAlertLevel().intValue(),2,client_id,System.currentTimeMillis(),1,iotAlert.getUser_id() ,device_name,null==iotAlert.getUser_id()?1:2);
|
|
|
|
IotAlertLog iotAlertLog = new IotAlertLog(iotAlert.getAlertId(),alrmname,iotAlert.getAlertLevel().intValue(),2,client_id,System.currentTimeMillis(),1,user_id ,device_name,null==iotAlert.getUser_id()?1:2);
|
|
|
|
list.add(iotAlertLog);
|
|
|
|
}
|
|
|
|
}
|
|
...
|
...
|
@@ -145,11 +156,11 @@ public abstract class UpAlarmFactory<T> { |
|
|
|
continue;
|
|
|
|
}
|
|
|
|
List<TriggerTriggers> attributeTriggersList = JSON.parseArray(iotAlert.getTriggers(),TriggerTriggers.class);
|
|
|
|
alarmTriggerTriggers(attributeTriggersList,newValue,iotAlert.getAlertId(),iotAlert.getAlertName(),iotAlert.getAlertLevel().intValue(),client_id,iotAlert.getUser_id(),device_name);
|
|
|
|
alarmTriggerTriggers(attributeTriggersList,newValue,iotAlert.getAlertId(),iotAlert.getAlertName(),iotAlert.getAlertLevel().intValue(),client_id,user_id,device_name,null==iotAlert.getUser_id()?1:2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void alarmTriggerTriggers( List<TriggerTriggers> attributeTriggersList,Object newValue,Long alert_id, String alert_name, Integer alert_level, String device_id,Integer userId,String device_name )
|
|
|
|
public void alarmTriggerTriggers( List<TriggerTriggers> attributeTriggersList,Object newValue,Long alert_id, String alert_name, Integer alert_level, String device_id,Integer userId,String device_name,Integer alert_config_type)
|
|
|
|
{
|
|
|
|
if(null != attributeTriggersList && attributeTriggersList.size() != 0)
|
|
|
|
{
|
|
...
|
...
|
@@ -188,7 +199,7 @@ public abstract class UpAlarmFactory<T> { |
|
|
|
|
|
|
|
if(jieguo)
|
|
|
|
{
|
|
|
|
IotAlertLog iotAlertLog = new IotAlertLog(alert_id,alert_name,alert_level,2,device_id,System.currentTimeMillis(),1,userId,device_name,null==userId?1:2);
|
|
|
|
IotAlertLog iotAlertLog = new IotAlertLog(alert_id,alert_name,alert_level,2,device_id,System.currentTimeMillis(),1,userId,device_name,alert_config_type);
|
|
|
|
list.add(iotAlertLog);
|
|
|
|
}
|
|
|
|
}
|
...
|
...
|
|