蓄电池监控管理平台数据库初始化程序
DELL
2025-03-22 7c594971d117f8ef5ca3977f1d087aa216e147df
BattMonitor_DB_Builder/src/com/database_util/DB_Ram_db.java
@@ -288,14 +288,156 @@
            ") ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='BTS6185相关设备告警阈值遥调表';" + 
            ";";
      Sql_Mysql sql = new Sql_Mysql(pool.getConn());
      ResultSet res = null;
      try {
         if(true == recreate) {         
            sql.sqlMysqlExecute(sql_str01);
         }
         sql.sqlMysqlExecute(sql_str02);
         sql.sqlMysqlExecute(sql_str02);
         //电池组号:battgroupnum
         res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
               + " WHERE table_schema='db_ram_db'"
               + " AND table_name='tb_dev_6185_almparam'"
               + " AND column_name='battgroupnum'");
         if(false == res.next()) {
            sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.Dev_6185_AlmpPram_Table
                        + " ADD COLUMN `battgroupnum` int(11) NOT NULL DEFAULT '1' COMMENT '组号[1-组1  2-组2]'");
         }
         res = null;
         //在线电压高阈值:onlinevol_high_val
         res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
               + " WHERE table_schema='db_ram_db'"
               + " AND table_name='tb_dev_6185_almparam'"
               + " AND column_name='onlinevol_high_val'");
         if(false == res.next()) {
            sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.Dev_6185_AlmpPram_Table
                        + " ADD COLUMN `onlinevol_high_val` float NOT NULL DEFAULT '0' COMMENT '在线电压高阈值'");
         }
         res = null;
         //在线电压低阈值:onlinevol_low_val
         res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
               + " WHERE table_schema='db_ram_db'"
               + " AND table_name='tb_dev_6185_almparam'"
               + " AND column_name='onlinevol_low_val'");
         if(false == res.next()) {
            sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.Dev_6185_AlmpPram_Table
                        + " ADD COLUMN `onlinevol_low_val` float NOT NULL DEFAULT '0' COMMENT '在线电压低阈值'");
         }
         res = null;
         //在线电压告警使能:onlinevol_en
         res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
               + " WHERE table_schema='db_ram_db'"
               + " AND table_name='tb_dev_6185_almparam'"
               + " AND column_name='onlinevol_en'");
         if(false == res.next()) {
            sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.Dev_6185_AlmpPram_Table
                        + " ADD COLUMN `onlinevol_en` tinyint(4) NOT NULL DEFAULT '0' COMMENT '在线电压告警使能[0-启用  1-不启用]'");
         }
         res = null;
         //组端电压告警使能:groupvol_en
         res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
               + " WHERE table_schema='db_ram_db'"
               + " AND table_name='tb_dev_6185_almparam'"
               + " AND column_name='groupvol_en'");
         if(false == res.next()) {
            sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.Dev_6185_AlmpPram_Table
                        + " ADD COLUMN `groupvol_en` tinyint(4) NOT NULL DEFAULT '0' COMMENT '组端电压告警使能[0-启用  1-不启用]'");
         }
         res = null;
         //单体电压告警使能:monvol_en
         res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
               + " WHERE table_schema='db_ram_db'"
               + " AND table_name='tb_dev_6185_almparam'"
               + " AND column_name='monvol_en'");
         if(false == res.next()) {
            sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.Dev_6185_AlmpPram_Table
                        + " ADD COLUMN `monvol_en` tinyint(4) NOT NULL DEFAULT '0' COMMENT '单体电压告警使能[0-启用  1-不启用]'");
         }
         res = null;
         //单体温度告警使能:montmp_en
         res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
               + " WHERE table_schema='db_ram_db'"
               + " AND table_name='tb_dev_6185_almparam'"
               + " AND column_name='montmp_en'");
         if(false == res.next()) {
            sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.Dev_6185_AlmpPram_Table
                        + " ADD COLUMN `montmp_en` tinyint(4) NOT NULL DEFAULT '0' COMMENT '单体温度告警使能[0-启用  1-不启用]'");
         }
         res = null;
         //单体内阻告警使能:monres_en
         res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
               + " WHERE table_schema='db_ram_db'"
               + " AND table_name='tb_dev_6185_almparam'"
               + " AND column_name='monres_en'");
         if(false == res.next()) {
            sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.Dev_6185_AlmpPram_Table
                        + " ADD COLUMN `monres_en` tinyint(4) NOT NULL DEFAULT '0' COMMENT '单体内阻告警使能[0-启用  1-不启用]'");
         }
         res = null;
         //单体容量告警使能:moncap_en
         res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
               + " WHERE table_schema='db_ram_db'"
               + " AND table_name='tb_dev_6185_almparam'"
               + " AND column_name='moncap_en'");
         if(false == res.next()) {
            sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.Dev_6185_AlmpPram_Table
                  + " ADD COLUMN `moncap_en` tinyint(4) NOT NULL DEFAULT '0' COMMENT '单体容量告警使能[0-启用  1-不启用]'");
         }
         res = null;
         //放电电流上限阈值:discurr_high_val
         res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
               + " WHERE table_schema='db_ram_db'"
               + " AND table_name='tb_dev_6185_almparam'"
               + " AND column_name='discurr_high_val'");
         if(false == res.next()) {
            sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.Dev_6185_AlmpPram_Table
                  + " ADD COLUMN `discurr_high_val` float NOT NULL DEFAULT '0' COMMENT '放电电流上限阈值'");
         }
         res = null;
         //放电电流告警使能:discurr_en
         res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
               + " WHERE table_schema='db_ram_db'"
               + " AND table_name='tb_dev_6185_almparam'"
               + " AND column_name='discurr_en'");
         if(false == res.next()) {
            sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.Dev_6185_AlmpPram_Table
                  + " ADD COLUMN `discurr_en` tinyint(4) NOT NULL DEFAULT '0' COMMENT '放电电流告警使能[0-启用  1-不启用]'");
         }
         res = null;
         //充电电流告警上限阈值:chrcurr_high_val
         res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
               + " WHERE table_schema='db_ram_db'"
               + " AND table_name='tb_dev_6185_almparam'"
               + " AND column_name='chrcurr_high_val'");
         if(false == res.next()) {
            sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.Dev_6185_AlmpPram_Table
                  + " ADD COLUMN `chrcurr_high_val` float NOT NULL DEFAULT '0' COMMENT '充电电流告警上限阈值'");
         }
         res = null;
         //充电电流告警使能:chrcurr_en
         res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
               + " WHERE table_schema='db_ram_db'"
               + " AND table_name='tb_dev_6185_almparam'"
               + " AND column_name='chrcurr_en'");
         if(false == res.next()) {
            sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.Dev_6185_AlmpPram_Table
                  + " ADD COLUMN `chrcurr_en` tinyint(4) NOT NULL DEFAULT '0' COMMENT '充电电流告警使能[0-启用  1-不启用]'");
         }
      } catch (SQLException e) {
         e.printStackTrace();
      } finally {
         if(null != res) {
            try {
               res.close();
            } catch (SQLException e) {
               e.printStackTrace();
            }
         }
         sql.close_con();
      }      
   }