V1.009 2023-08-21
1.电源告警新增告警配置读取,用以判别电源告警是否需要手动确认以及能否自动消失
| | |
| | | package com.main;
|
| | |
|
| | | import java.sql.SQLException;
|
| | | import java.util.HashMap;
|
| | | import java.util.Map;
|
| | |
|
| | | import org.apache.logging.log4j.LogManager;
|
| | | import org.apache.logging.log4j.Logger;
|
| | |
|
| | | import com.base.AppConfig;
|
| | | import com.power.mysql.Sql_Mysql;
|
| | | import com.power.alarm.AppAlm_Param;
|
| | | import com.power.alarm.PwrDeviceAlarm_Thread;
|
| | | import com.power.alarm.PwrDeviceAlarm_Thread_New;
|
| | | import com.power.alarm.PwrDeviceAlarm_Thread_SQL;
|
| | | import com.power.comm.Power_61850_Task_Thread;
|
| | | import com.power.data.PowerData_RT_Array;
|
| | | import com.power.data.PowerData_RT_SQL;
|
| | |
| | | public class main_PowerDev_IEC61850 {
|
| | |
|
| | | public final static boolean app_debug = false;
|
| | | public final static double m_VersionNum = 1.008;
|
| | | public final static double m_VersionNum = 1.009;
|
| | | public final static String m_Version = "Welcome To Use Monitor_PowerDev_IEC61850 V"
|
| | | + m_VersionNum + " RC_20201216";
|
| | |
|
| | |
| | | private static MysqlConnPool GB_MysqlConnPool;
|
| | | private static PowerData_RT_Array GB_DataArray;
|
| | | private static Power_61850_Task_Thread GB_task_61850;
|
| | | |
| | | private static Map<Integer,AppAlm_Param> appParam;
|
| | |
|
| | | /*********************************************************************************************/
|
| | | /*********************************************************************************************/
|
| | |
| | |
|
| | |
|
| | | public static void main(String[] args) {
|
| | | |
| | | appParam = new HashMap<Integer, AppAlm_Param>();
|
| | |
|
| | | String ver = m_Version;
|
| | |
|
| | |
| | |
|
| | | GB_task_61850.start();
|
| | |
|
| | | PwrDeviceAlarm_Thread_New alarmthread = new PwrDeviceAlarm_Thread_New(m_AppConfig,GB_MysqlConnPool,GB_DataArray);
|
| | | PwrDeviceAlarm_Thread_New alarmthread = new PwrDeviceAlarm_Thread_New(m_AppConfig,GB_MysqlConnPool,GB_DataArray,appParam);
|
| | |
|
| | | alarmthread.start();
|
| | |
|
| | |
| | | while(true)
|
| | | {
|
| | | try {
|
| | | //读取电源告警配置信息
|
| | | PwrDeviceAlarm_Thread_SQL.queryAppAlmParam(GB_MysqlConnPool, appParam);
|
| | |
|
| | | Thread.sleep(2000);
|
| | |
|
| | |
| | |
|
| | | PowerData_RT_SQL.updateThread_Time(GB_MysqlConnPool);
|
| | |
|
| | | |
| | | } catch (Exception e) {
|
| | | logger.error(e.toString(), e);
|
| | | }
|
New file |
| | |
| | | package com.power.alarm;
|
| | |
|
| | | /**
|
| | | * 平台告警允许自动消失配置信息表
|
| | | * @author LiJun
|
| | | *
|
| | | */
|
| | | public class AppAlm_Param {
|
| | | public static final int Alm_AutoClear_Oppose = 0; //不允许自动自动消失 |
| | | public static final int Alm_AutoClear_Allow = 1; //允许自动自动消失
|
| | | |
| | | |
| | | public int alm_id; //'告警id',
|
| | | public String alm_name; //'告警名称',
|
| | | public int alm_category; //'告警类别[1-电池告警;2-设备告警;3-电源告警]',
|
| | | public int alm_auto_clear_en; //'告警自动消失使能[平台告警是否允许消失使能]0-不允许 1-允许',
|
| | | |
| | | |
| | | |
| | | public int getAlm_id() {
|
| | | return alm_id;
|
| | | }
|
| | |
|
| | |
|
| | |
|
| | | public String getAlm_name() {
|
| | | return alm_name;
|
| | | }
|
| | |
|
| | |
|
| | |
|
| | | public int getAlm_category() {
|
| | | return alm_category;
|
| | | }
|
| | |
|
| | |
|
| | |
|
| | | public int getAlm_auto_clear_en() {
|
| | | return alm_auto_clear_en;
|
| | | }
|
| | |
|
| | |
|
| | |
|
| | | public void setAlm_id(int alm_id) {
|
| | | this.alm_id = alm_id;
|
| | | }
|
| | |
|
| | |
|
| | |
|
| | | public void setAlm_name(String alm_name) {
|
| | | this.alm_name = alm_name;
|
| | | }
|
| | |
|
| | |
|
| | |
|
| | | public void setAlm_category(int alm_category) {
|
| | | this.alm_category = alm_category;
|
| | | }
|
| | |
|
| | |
|
| | |
|
| | | public void setAlm_auto_clear_en(int alm_auto_clear_en) {
|
| | | this.alm_auto_clear_en = alm_auto_clear_en;
|
| | | }
|
| | |
|
| | |
|
| | |
|
| | | @Override
|
| | | public String toString() {
|
| | | return "AppAlm_Param [alm_id=" + alm_id + ", alm_name=" + alm_name + ", alm_category=" + alm_category
|
| | | + ", alm_auto_clear_en=" + alm_auto_clear_en + "]";
|
| | | }
|
| | | |
| | | |
| | | |
| | | }
|
| | |
| | | import java.util.ArrayList;
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | | import java.util.UUID;
|
| | |
|
| | | import org.apache.logging.log4j.LogManager;
|
| | |
| | | @SuppressWarnings("unused")
|
| | | private AppConfig m_AppCfg = null;
|
| | |
|
| | | private Map<Integer,AppAlm_Param> appParam;
|
| | | |
| | | private Logger logger = null;
|
| | |
|
| | | public PwrDeviceAlarm_Thread_New(AppConfig cfg, MysqlConnPool pool, PowerData_RT_Array data) {
|
| | | public PwrDeviceAlarm_Thread_New(AppConfig cfg, MysqlConnPool pool, PowerData_RT_Array data,Map<Integer,AppAlm_Param> appParam) {
|
| | | logger = LogManager.getLogger(this.getClass());
|
| | |
|
| | | this.appParam = appParam;
|
| | | m_Conn_Pool = pool;
|
| | | m_AL_Data = data;
|
| | | m_AppCfg = cfg;
|
| | |
| | | continue;
|
| | | }
|
| | |
|
| | | //查询
|
| | | //查询电源告警上一次实时告警
|
| | | PwrDeviceAlarm_Thread_SQL.queryLastPwrDeviceAlarm(m_AL_Data.getItem(n),m_Conn_Pool);
|
| | |
|
| | | }
|
| | |
| | | //查询电源实时告警表中的历史告警记录
|
| | | List<PwrDeviceAlarm_Data> al_histAlm = PwrDeviceAlarm_Thread_SQL.queryPwrDeviceHistoty(m_Conn_Pool);
|
| | | if(al_histAlm.size() > 0) {
|
| | | PwrDeviceAlarm_Thread_SQL.ChangeRT_AlarmToHistoryAlarm(m_Conn_Pool);
|
| | | for(int k = 0;k<al_histAlm.size();k++) {
|
| | | PwrDeviceAlarm_Data tmp_alm = al_histAlm.get(k);
|
| | | |
| | | AppAlm_Param param = appParam.get(tmp_alm.alm_type);
|
| | | |
| | | |
| | | if((null != param) &&
|
| | | ( param.alm_auto_clear_en == AppAlm_Param.Alm_AutoClear_Oppose)) {
|
| | | //将当前电源历史告警记录插入到电源告警确认表中
|
| | | PwrDeviceAlarm_Thread_SQL.ChangeRT_AlarmToAlarmVerify(m_Conn_Pool, tmp_alm); |
| | | }else {
|
| | | //将当前电源历史告警记录插入到电源历史告警表中
|
| | | PwrDeviceAlarm_Thread_SQL.ChangeRT_AlarmToHistoryAlarm(m_Conn_Pool,tmp_alm); |
| | | }
|
| | | |
| | | } |
| | | }
|
| | |
|
| | |
|
| | |
| | | import java.util.ArrayList;
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | |
|
| | | import com.base.Com;
|
| | | import com.power.data.PowerData_RT;
|
| | |
| | | public class PwrDeviceAlarm_Thread_SQL {
|
| | |
|
| | |
|
| | | public static void ChangeRT_AlarmToHistoryAlarm(MysqlConnPool pool){
|
| | | public static void ChangeRT_AlarmToHistoryAlarm(MysqlConnPool pool,PwrDeviceAlarm_Data alm){
|
| | |
|
| | | ArrayList<String> sql_strs = new ArrayList<String>();
|
| | | Sql_Mysql sql = new Sql_Mysql(pool.getConn());
|
| | |
| | | // + " WHERE PowerDeviceId=" + dev_id + " AND alm_type= "+ alm_type_id;
|
| | |
|
| | | //将当前设备实时告警表中的历史告警记录插入到设备历史告警表中
|
| | | String sql_str2 = " INSERT INTO " + Sql_Mysql.TB_PWRDEV_ALARM_HISTORY+"(record_id,PowerDeviceId,alm_type,alm_level,alm_start_time,alm_end_time,alm_value,alm_is_confirmed,alm_confirmed_time,alm_cleared_type,alm_trigger,alm_severity) (SELECT record_id,PowerDeviceId,alm_type,alm_level,alm_start_time,alm_end_time,alm_value,alm_is_confirmed,alm_confirmed_time,alm_cleared_type,alm_trigger,alm_severity from "+Sql_Mysql.TB_PWRDEV_ALARM+" WHERE alm_cleared_type = " + PwrDeviceAlarm_Data.ALM_CLEARED_TYPE_HIST + ")";
|
| | | String sql_str2 = " INSERT INTO " + Sql_Mysql.TB_PWRDEV_ALARM_HISTORY+"(record_id,PowerDeviceId,alm_type,alm_level,alm_start_time,alm_end_time,alm_value,alm_is_confirmed,alm_confirmed_time,alm_cleared_type,alm_trigger,alm_severity) (SELECT record_id,PowerDeviceId,alm_type,alm_level,alm_start_time,alm_end_time,alm_value,alm_is_confirmed,alm_confirmed_time,alm_cleared_type,alm_trigger,alm_severity from "+Sql_Mysql.TB_PWRDEV_ALARM+" WHERE PowerDeviceId = " + alm.pwrdev_id + " and alm_type = " + alm.alm_type + " and alm_cleared_type = " + PwrDeviceAlarm_Data.ALM_CLEARED_TYPE_HIST + ")";
|
| | |
|
| | | //将实时告警表中的非实时告警删除
|
| | | String sql_str3 = " DELETE FROM " + Sql_Mysql.TB_PWRDEV_ALARM +" WHERE alm_cleared_type = " + PwrDeviceAlarm_Data.ALM_CLEARED_TYPE_HIST;
|
| | | String sql_str3 = " DELETE FROM " + Sql_Mysql.TB_PWRDEV_ALARM +" WHERE PowerDeviceId = "+ alm.pwrdev_id + " and alm_type = " + alm.alm_type + " and alm_cleared_type = " + PwrDeviceAlarm_Data.ALM_CLEARED_TYPE_HIST + ")";
|
| | |
|
| | | //sql_strs.add(sql_str1);
|
| | | sql_strs.add(sql_str2);
|
| | | sql_strs.add(sql_str3);
|
| | | sql.makeManualCommit(sql_strs);
|
| | | |
| | | } catch (Exception e) {
|
| | | sql.logger.error(e.toString(), e);
|
| | | } finally {
|
| | | sql.close_con();
|
| | | }
|
| | | |
| | | }
|
| | | public static void ChangeRT_AlarmToAlarmVerify(MysqlConnPool pool,PwrDeviceAlarm_Data alm){
|
| | | |
| | | ArrayList<String> sql_strs = new ArrayList<String>();
|
| | | Sql_Mysql sql = new Sql_Mysql(pool.getConn());
|
| | | |
| | | |
| | | try {
|
| | | sql.sqlMysqlUseDB(Sql_Mysql.DB_PWRDEV_ALARM);
|
| | | |
| | | // //在实时告警表中的当前设备的告警记录改成历史告警记录,并且记录当前的时间
|
| | | // String sql_str1 = "UPDATE " + Sql_Mysql.TB_PWRDEV_ALARM
|
| | | // + " SET "
|
| | | // + " alm_end_time='" + Com.getDateTimeFormat(new Date(), Com.DTF_YMDhms) + "', "
|
| | | // + " alm_cleared_type=" + PwrDeviceAlarm_Data.ALM_CLEARED_TYPE_AUTO |
| | | // + " WHERE PowerDeviceId=" + dev_id + " AND alm_type= "+ alm_type_id;
|
| | | |
| | | //将当前设备实时告警表中的历史告警记录插入到设备历史告警表中
|
| | | String sql_str2 = " INSERT INTO " + Sql_Mysql.PWRDEV_ALARM_VERIFY_TABLE+"(record_id,PowerDeviceId,alm_type,alm_level,alm_start_time,alm_end_time,alm_value,alm_is_confirmed,alm_confirmed_time,alm_cleared_type,alm_trigger,alm_severity)(SELECT record_id,PowerDeviceId,alm_type,alm_level,alm_start_time,alm_end_time,alm_value,alm_is_confirmed,alm_confirmed_time,alm_cleared_type,alm_trigger,alm_severity from "+Sql_Mysql.TB_PWRDEV_ALARM+" WHERE PowerDeviceId = " + alm.pwrdev_id + " and alm_type = " + alm.alm_type + " and alm_cleared_type = " + PwrDeviceAlarm_Data.ALM_CLEARED_TYPE_HIST + ");";
|
| | | |
| | | //将实时告警表中的非实时告警删除
|
| | | String sql_str3 = " DELETE FROM " + Sql_Mysql.TB_PWRDEV_ALARM +" WHERE PowerDeviceId = "+ alm.pwrdev_id + " and alm_type = " + alm.alm_type + " and alm_cleared_type = " + PwrDeviceAlarm_Data.ALM_CLEARED_TYPE_HIST;
|
| | | |
| | | //System.out.println(sql_str2);
|
| | | //sql_strs.add(sql_str1);
|
| | | sql_strs.add(sql_str2);
|
| | | sql_strs.add(sql_str3);
|
| | |
| | | res = sql.sqlMysqlQuery(sql_str_sel);
|
| | | try {
|
| | | while(res.next()) {
|
| | | PwrDeviceAlarm_Data tmp_alm = new PwrDeviceAlarm_Data(res.getInt("alm_type")); |
| | | PwrDeviceAlarm_Data tmp_alm = new PwrDeviceAlarm_Data(res.getInt("alm_type")); |
| | | tmp_alm.pwrdev_id = res.getInt("PowerDeviceId");
|
| | | tmp_alm.RecId = res.getLong("record_id");
|
| | | tmp_alm.alm_cleared_type = res.getInt("alm_cleared_type"); //告警类型 0:实时告警 1:历史告警 2:取消告警
|
| | | tmp_alm.alm_vlaue = res.getFloat("alm_value"); //告警值
|
| | |
| | | }
|
| | |
|
| | |
|
| | |
|
| | | /**
|
| | | * 读取平台告警配置参数
|
| | | * @param pool
|
| | | * @param appParam
|
| | | */
|
| | | public static void queryAppAlmParam(MysqlConnPool pool,Map<Integer, AppAlm_Param> appParam) {
|
| | | String sql_str = " SELECT alm_id,alm_auto_clear_en,alm_auto_clear_en,alm_category,alm_name FROM db_param.tb_appalm_param ";
|
| | | Sql_Mysql sql = new Sql_Mysql(pool.getConn());
|
| | | ResultSet res = null;
|
| | | try {
|
| | | res = sql.sqlMysqlQuery(sql_str);
|
| | | while(res.next()) {
|
| | | int alm_id = res.getInt("alm_id");
|
| | | AppAlm_Param appAlm = appParam.get(alm_id);
|
| | | if(null != appAlm) {
|
| | | //更新当前配置参数
|
| | | |
| | | appAlm.setAlm_auto_clear_en(res.getInt("alm_auto_clear_en")); |
| | | }else {
|
| | | AppAlm_Param param = new AppAlm_Param();
|
| | | param.setAlm_id(res.getInt("alm_id"));
|
| | | param.setAlm_auto_clear_en(res.getInt("alm_auto_clear_en"));
|
| | | param.setAlm_name(res.getString("alm_name"));
|
| | | param.setAlm_category(res.getInt("alm_category"));
|
| | | |
| | | appParam.put(alm_id, param);
|
| | | } |
| | | } |
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | } finally{
|
| | | if(null != res) {
|
| | | try {
|
| | | res.close();
|
| | | } catch (SQLException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | sql.close_con();
|
| | | } |
| | | }
|
| | |
|
| | |
|
| | | }
|
| | |
| | | public final static String PWRAPP_SYS_TABLE = DB_PWRDEV_INF + ".`tb_pwrapp_sys`";
|
| | |
|
| | | public final static String PWRDEV_ALARM_TABLE = DB_PWRDEV_ALARM + ".`tb_pwrdev_alarm`";
|
| | | public final static String PWRDEV_ALARM_VERIFY_TABLE = DB_PWRDEV_ALARM + ".`tb_pwrdev_alarm_verify`";
|
| | | public final static String PWRDEV_ALARM_HISTORY_TABLE = DB_PWRDEV_ALARM + ".`tb_pwrdev_alarm_history`";
|
| | | public final static String PWRDEV_ALARM_PARAM_FORSX_TABLE = DB_PWRDEV_ALARM + ".`tb_pwrdev_alarm_param_forsx`"; //山西告警参数表
|
| | |
|
| | |
| | | 山西太原 电源通信程序
|
| | |
|
| | | V1.009 2023-08-21
|
| | | 1.电源告警新增告警配置读取,用以判别电源告警是否需要手动确认以及能否自动消失
|
| | |
|
| | | V1.008 2023-07-31
|
| | | 1.新增电源告警类型以及对应判断条件
|
| | | 交流停电告警 - 延迟60s触发
|