蓄电池监控管理平台数据库初始化程序
db_user库新建表tb_user_work、tb_work_alarm,db_alarm数据库中新建表`tb_alarm_message`
5个文件已修改
4258 ■■■■ 已修改文件
BattMonitor_DB_Builder/src/com/database_util/DB_Alarm.java 607 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
BattMonitor_DB_Builder/src/com/database_util/DB_db_user.java 72 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
BattMonitor_DB_Builder/src/com/sql/Sql_Mysql.java 2721 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
BattMonitor_DB_Builder/src/com/version_inf/version_inf.txt 448 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
BattMonitor_DB_Builder/src/main/main_BTS_DB_Builder.java 410 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
BattMonitor_DB_Builder/src/com/database_util/DB_Alarm.java
@@ -1,283 +1,324 @@
package com.database_util;
import java.sql.ResultSet;
import java.sql.SQLException;
import com.sql.MysqlConnPool;
import com.sql.Sql_Mysql;
public class DB_Alarm {
    public static void init(MysqlConnPool pool, boolean recreate) {
        createDB_ALARM(pool);
        createBattalarm_Data_History_Table(pool, recreate);
        createBattalarm_Data_Table(pool, recreate);
        createBts_Station_Event_Table(pool, recreate);
        createDevalarm_Data__History_Table(pool, recreate);
        createDevalarm_Data_Table(pool, recreate);
    }
    /**
     *     创建     db_alarm 数据库
     * @param pool
     */
    public static void createDB_ALARM(MysqlConnPool pool) {
        Sql_Mysql sql = new Sql_Mysql(pool.getConn());
        try {
            sql.sqlMysqlExecute("CREATE DATABASE IF NOT EXISTS " + Sql_Mysql.DB_ALARM);
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            sql.close_con();
        }
    }
    /**
     *     创建tb_devalarm_data_history表
     */
    public static void createDevalarm_Data__History_Table(MysqlConnPool pool, boolean recreate) {
        String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.Devalarm_Data__History_Table;
        String sql_str02 = " CREATE TABLE IF NOT EXISTS " + Sql_Mysql.Devalarm_Data__History_Table + " (" +
                "  num bigint(20) NOT NULL AUTO_INCREMENT," +
                "  record_id bigint(20) NOT NULL DEFAULT '0'," +
                "  dev_id int(11) NOT NULL DEFAULT '0'," +
                "  dev_ip varchar(24) NOT NULL DEFAULT '127.0.0.1'," +
                "  alm_type int(11) NOT NULL DEFAULT '0'," +
                "  alm_level int(11) NOT NULL DEFAULT '0'," +
                "  alm_start_time datetime NOT NULL DEFAULT '1982-01-01 00:00:00'," +
                "  alm_end_time datetime NOT NULL DEFAULT '1982-01-01 00:00:00'," +
                "  alm_value float NOT NULL DEFAULT '0'," +
                "  alm_is_confirmed tinyint(1) NOT NULL DEFAULT '0'," +
                "  alm_confirmed_time datetime NOT NULL DEFAULT '1982-01-01 00:00:00'," +
                "  alm_cleared_type int(11) NOT NULL DEFAULT '0'," +
                "  usr_Id int(11) NOT NULL DEFAULT '0'," +
                "  PRIMARY KEY (num)," +
                "  KEY index_record_id (record_id)," +
                "  KEY index_dev_id (dev_id)," +
                "  KEY index_alm_type (alm_type)," +
                "  KEY index_alm_start_time (alm_start_time)," +
                "  KEY index_alm_cleared_type (alm_cleared_type)" +
                ") ENGINE=InnoDB AUTO_INCREMENT=12 DEFAULT CHARSET=utf8;";
        Sql_Mysql sql = new Sql_Mysql(pool.getConn());
        try {
            if(true == recreate) {
                sql.sqlMysqlExecute(sql_str01);
            }
            sql.sqlMysqlExecute(sql_str02);
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            sql.close_con();
        }
    }
    /**
     *     创建tb_devalarm_data表
     * @param pool
     * @param recreate
     */
    public static void createDevalarm_Data_Table(MysqlConnPool pool, boolean recreate) {
        String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.Devalarm_Data_Table;
        String sql_str02 = " CREATE TABLE IF NOT EXISTS " + Sql_Mysql.Devalarm_Data_Table + " (" +
                "  num bigint(20) NOT NULL AUTO_INCREMENT," +
                "  record_id bigint(20) NOT NULL DEFAULT '0'," +
                "  dev_id int(11) NOT NULL DEFAULT '0'," +
                "  dev_ip varchar(24) NOT NULL DEFAULT '127.0.0.1'," +
                "  alm_type int(11) NOT NULL DEFAULT '0'," +
                "  alm_level int(11) NOT NULL DEFAULT '0'," +
                "  alm_start_time datetime NOT NULL DEFAULT '1982-01-01 00:00:00'," +
                "  alm_end_time datetime NOT NULL DEFAULT '1982-01-01 00:00:00'," +
                "  alm_value float NOT NULL DEFAULT '0'," +
                "  alm_is_confirmed tinyint(1) NOT NULL DEFAULT '0'," +
                "  alm_confirmed_time datetime NOT NULL DEFAULT '1982-01-01 00:00:00'," +
                "  alm_cleared_type int(11) NOT NULL DEFAULT '0'," +
                "  usr_Id int(11) NOT NULL DEFAULT '0'," +
                "  PRIMARY KEY (num)," +
                "  KEY index_record_id (record_id)," +
                "  KEY index_dev_id (dev_id)," +
                "  KEY index_alm_type (alm_type)," +
                "  KEY index_alm_start_time (alm_start_time)," +
                "  KEY index_alm_cleared_type (alm_cleared_type)" +
                ") ENGINE=InnoDB AUTO_INCREMENT=18 DEFAULT CHARSET=utf8;";
        Sql_Mysql sql = new Sql_Mysql(pool.getConn());
        ResultSet res = null;
        try {
            if(true == recreate) {
                sql.sqlMysqlExecute(sql_str01);
            }
            sql.sqlMysqlExecute(sql_str02);
            //添加指定的work_flag列(派单管理)
            res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
                    + " WHERE table_schema='db_alarm'"
                    + " AND table_name='tb_devalarm_data'"
                    + " AND column_name='work_flag'");
            if(false == res.next()) {
                sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.Devalarm_Data_Table
                                + " ADD COLUMN `work_flag` tinyint NOT NULL DEFAULT 0;");
            }
            //添加指定的msg_flag列(派单管理)
            res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
                    + " WHERE table_schema='db_alarm'"
                    + " AND table_name='tb_devalarm_data'"
                    + " AND column_name='msg_flag'");
            if(false == res.next()) {
                sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.Devalarm_Data_Table
                                + " ADD COLUMN `msg_flag` tinyint NOT NULL DEFAULT 0;");
            }
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            sql.close_con();
        }
    }
    /**
     *     创建tb_bts_station_event表
     * @param pool
     * @param recreate
     */
    public static void createBts_Station_Event_Table(MysqlConnPool pool, boolean recreate) {
        String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.Bts_Station_Event_Table;
        String sql_str02 = " CREATE TABLE IF NOT EXISTS " + Sql_Mysql.Bts_Station_Event_Table + " (" +
                "  num bigint(20) NOT NULL AUTO_INCREMENT," +
                "  station_id bigint(20) NOT NULL DEFAULT '0'," +
                "  dev_id bigint(20) NOT NULL DEFAULT '0'," +
                "  record_datetime varchar(20) NOT NULL DEFAULT '2015-12-02 12:10:00'," +
                "  station_event_type int(11) NOT NULL DEFAULT '0'," +
                "  station_event_trig int(11) NOT NULL DEFAULT '0'," +
                "  PRIMARY KEY (num)," +
                "  KEY index_dev_id (dev_id)," +
                "  KEY index_station_id (station_id)" +
                ") ENGINE=InnoDB DEFAULT CHARSET=utf8;";
        Sql_Mysql sql = new Sql_Mysql(pool.getConn());
        try {
            if(true == recreate) {
                sql.sqlMysqlExecute(sql_str01);
            }
            sql.sqlMysqlExecute(sql_str02);
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            sql.close_con();
        }
    }
    /**
     *     创建tb_battalarm_data_history表
     * @param pool
     * @param recreate
     */
    public static void createBattalarm_Data_History_Table(MysqlConnPool pool, boolean recreate) {
        String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.Battalarm_Data_History_Table;
        String sql_str02 = " CREATE TABLE IF NOT EXISTS " + Sql_Mysql.Battalarm_Data_History_Table + " (" +
                "  num bigint(20) NOT NULL AUTO_INCREMENT," +
                "  BattGroupId int(11) NOT NULL DEFAULT '0'," +
                "  MonNum int(11) NOT NULL DEFAULT '0'," +
                "  Record_Id bigint(20) NOT NULL DEFAULT '0'," +
                "  alm_id int(11) NOT NULL DEFAULT '0'," +
                "  alm_signal_id int(11) NOT NULL DEFAULT '0'," +
                "  alm_level int(11) NOT NULL DEFAULT '0'," +
                "  alm_start_time datetime NOT NULL DEFAULT '1982-01-01 00:00:00'," +
                "  alm_end_time datetime NOT NULL DEFAULT '1982-01-01 00:00:00'," +
                "  alm_value float NOT NULL DEFAULT '0'," +
                "  alm_is_confirmed tinyint(1) NOT NULL DEFAULT '0'," +
                "  alm_confirmed_time datetime NOT NULL DEFAULT '1982-01-01 00:00:00'," +
                "  alm_cleared_type int(11) NOT NULL DEFAULT '0'," +
                "  usr_Id int(11) NOT NULL DEFAULT '0'," +
                "  PRIMARY KEY (num)," +
                "  KEY index_battgroup_id (BattGroupId)," +
                "  KEY index_Record_Id (Record_Id)," +
                "  KEY index_alm_id (alm_id)," +
                "  KEY index_alm_start_time (alm_start_time)," +
                "  KEY index_alm_cleared_type (alm_cleared_type)," +
                "  KEY index_alm_signal_id (alm_signal_id)," +
                "  KEY index_alm_level (alm_level)" +
                ") ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8;";
        Sql_Mysql sql = new Sql_Mysql(pool.getConn());
        try {
            if(true == recreate) {
                sql.sqlMysqlExecute(sql_str01);
            }
            sql.sqlMysqlExecute(sql_str02);
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            sql.close_con();
        }
    }
    /**
     *     创建tb_battalarm_data表
     * @param pool
     * @param recreate
     */
    public static void createBattalarm_Data_Table(MysqlConnPool pool, boolean recreate) {
        String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.Battalarm_Data_Table;
        String sql_str02 = " CREATE TABLE IF NOT EXISTS " + Sql_Mysql.Battalarm_Data_Table + " (" +
                "  num bigint(20) NOT NULL AUTO_INCREMENT," +
                "  BattGroupId int(11) NOT NULL DEFAULT '0'," +
                "  MonNum int(11) NOT NULL DEFAULT '0'," +
                "  Record_Id bigint(20) NOT NULL DEFAULT '0'," +
                "  alm_id int(11) NOT NULL DEFAULT '0'," +
                "  alm_signal_id int(11) NOT NULL DEFAULT '0'," +
                "  alm_level int(11) NOT NULL DEFAULT '0'," +
                "  alm_start_time datetime NOT NULL DEFAULT '1982-01-01 00:00:00'," +
                "  alm_end_time datetime NOT NULL DEFAULT '1982-01-01 00:00:00'," +
                "  alm_value float NOT NULL DEFAULT '0'," +
                "  alm_is_confirmed tinyint(1) NOT NULL DEFAULT '0'," +
                "  alm_confirmed_time datetime NOT NULL DEFAULT '1982-01-01 00:00:00'," +
                "  alm_cleared_type int(11) NOT NULL DEFAULT '0'," +
                "  usr_Id int(11) NOT NULL DEFAULT '0'," +
                "  PRIMARY KEY (num)," +
                "  KEY index_battgroup_id (BattGroupId)," +
                "  KEY index_Record_Id (Record_Id)," +
                "  KEY index_alm_id (alm_id)," +
                "  KEY index_alm_start_time (alm_start_time)," +
                "  KEY index_alm_cleared_type (alm_cleared_type)," +
                "  KEY index_alm_signal_id (alm_signal_id)," +
                "  KEY index_alm_level (alm_level)" +
                ") ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;";
        Sql_Mysql sql = new Sql_Mysql(pool.getConn());
        ResultSet res = null;
        try {
            if(true == recreate) {
                sql.sqlMysqlExecute(sql_str01);
            }
            sql.sqlMysqlExecute(sql_str02);
            //添加指定的work_flag列(派单管理)
            res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
                    + " WHERE table_schema='db_alarm'"
                    + " AND table_name='tb_battalarm_data'"
                    + " AND column_name='work_flag'");
            if(false == res.next()) {
                sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.Battalarm_Data_Table
                                + " ADD COLUMN `work_flag` tinyint NOT NULL DEFAULT 0;");
            }
            //添加指定的msg_flag列(派单管理)
            res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
                    + " WHERE table_schema='db_alarm'"
                    + " AND table_name='tb_battalarm_data'"
                    + " AND column_name='msg_flag'");
            if(false == res.next()) {
                sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.Battalarm_Data_Table
                                + " ADD COLUMN `msg_flag` tinyint NOT NULL DEFAULT 0;");
            }
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            sql.close_con();
        }
    }
}
package com.database_util;
import java.sql.ResultSet;
import java.sql.SQLException;
import com.sql.MysqlConnPool;
import com.sql.Sql_Mysql;
public class DB_Alarm {
    public static void init(MysqlConnPool pool, boolean recreate) {
        createDB_ALARM(pool);
        createBattalarm_Data_History_Table(pool, recreate);
        createBattalarm_Data_Table(pool, recreate);
        createBts_Station_Event_Table(pool, recreate);
        createDevalarm_Data__History_Table(pool, recreate);
        createDevalarm_Data_Table(pool, recreate);
        createTb_Alarm_Message(pool, recreate);
    }
    /**
     *     创建     db_alarm 数据库
     * @param pool
     */
    public static void createDB_ALARM(MysqlConnPool pool) {
        Sql_Mysql sql = new Sql_Mysql(pool.getConn());
        try {
            sql.sqlMysqlExecute("CREATE DATABASE IF NOT EXISTS " + Sql_Mysql.DB_ALARM);
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            sql.close_con();
        }
    }
    /**
     *     创建tb_devalarm_data_history表
     */
    public static void createDevalarm_Data__History_Table(MysqlConnPool pool, boolean recreate) {
        String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.Devalarm_Data__History_Table;
        String sql_str02 = " CREATE TABLE IF NOT EXISTS " + Sql_Mysql.Devalarm_Data__History_Table + " (" +
                "  num bigint(20) NOT NULL AUTO_INCREMENT," +
                "  record_id bigint(20) NOT NULL DEFAULT '0'," +
                "  dev_id int(11) NOT NULL DEFAULT '0'," +
                "  dev_ip varchar(24) NOT NULL DEFAULT '127.0.0.1'," +
                "  alm_type int(11) NOT NULL DEFAULT '0'," +
                "  alm_level int(11) NOT NULL DEFAULT '0'," +
                "  alm_start_time datetime NOT NULL DEFAULT '1982-01-01 00:00:00'," +
                "  alm_end_time datetime NOT NULL DEFAULT '1982-01-01 00:00:00'," +
                "  alm_value float NOT NULL DEFAULT '0'," +
                "  alm_is_confirmed tinyint(1) NOT NULL DEFAULT '0'," +
                "  alm_confirmed_time datetime NOT NULL DEFAULT '1982-01-01 00:00:00'," +
                "  alm_cleared_type int(11) NOT NULL DEFAULT '0'," +
                "  usr_Id int(11) NOT NULL DEFAULT '0'," +
                "  PRIMARY KEY (num)," +
                "  KEY index_record_id (record_id)," +
                "  KEY index_dev_id (dev_id)," +
                "  KEY index_alm_type (alm_type)," +
                "  KEY index_alm_start_time (alm_start_time)," +
                "  KEY index_alm_cleared_type (alm_cleared_type)" +
                ") ENGINE=InnoDB AUTO_INCREMENT=12 DEFAULT CHARSET=utf8;";
        Sql_Mysql sql = new Sql_Mysql(pool.getConn());
        try {
            if(true == recreate) {
                sql.sqlMysqlExecute(sql_str01);
            }
            sql.sqlMysqlExecute(sql_str02);
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            sql.close_con();
        }
    }
    /**
     *     创建tb_devalarm_data表
     * @param pool
     * @param recreate
     */
    public static void createDevalarm_Data_Table(MysqlConnPool pool, boolean recreate) {
        String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.Devalarm_Data_Table;
        String sql_str02 = " CREATE TABLE IF NOT EXISTS " + Sql_Mysql.Devalarm_Data_Table + " (" +
                "  num bigint(20) NOT NULL AUTO_INCREMENT," +
                "  record_id bigint(20) NOT NULL DEFAULT '0'," +
                "  dev_id int(11) NOT NULL DEFAULT '0'," +
                "  dev_ip varchar(24) NOT NULL DEFAULT '127.0.0.1'," +
                "  alm_type int(11) NOT NULL DEFAULT '0'," +
                "  alm_level int(11) NOT NULL DEFAULT '0'," +
                "  alm_start_time datetime NOT NULL DEFAULT '1982-01-01 00:00:00'," +
                "  alm_end_time datetime NOT NULL DEFAULT '1982-01-01 00:00:00'," +
                "  alm_value float NOT NULL DEFAULT '0'," +
                "  alm_is_confirmed tinyint(1) NOT NULL DEFAULT '0'," +
                "  alm_confirmed_time datetime NOT NULL DEFAULT '1982-01-01 00:00:00'," +
                "  alm_cleared_type int(11) NOT NULL DEFAULT '0'," +
                "  usr_Id int(11) NOT NULL DEFAULT '0'," +
                "  PRIMARY KEY (num)," +
                "  KEY index_record_id (record_id)," +
                "  KEY index_dev_id (dev_id)," +
                "  KEY index_alm_type (alm_type)," +
                "  KEY index_alm_start_time (alm_start_time)," +
                "  KEY index_alm_cleared_type (alm_cleared_type)" +
                ") ENGINE=InnoDB AUTO_INCREMENT=18 DEFAULT CHARSET=utf8;";
        Sql_Mysql sql = new Sql_Mysql(pool.getConn());
        ResultSet res = null;
        try {
            if(true == recreate) {
                sql.sqlMysqlExecute(sql_str01);
            }
            sql.sqlMysqlExecute(sql_str02);
            //添加指定的work_flag列(派单管理)
            res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
                    + " WHERE table_schema='db_alarm'"
                    + " AND table_name='tb_devalarm_data'"
                    + " AND column_name='work_flag'");
            if(false == res.next()) {
                sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.Devalarm_Data_Table
                                + " ADD COLUMN `work_flag` tinyint NOT NULL DEFAULT 0;");
            }
            //添加指定的msg_flag列(派单管理)
            res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
                    + " WHERE table_schema='db_alarm'"
                    + " AND table_name='tb_devalarm_data'"
                    + " AND column_name='msg_flag'");
            if(false == res.next()) {
                sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.Devalarm_Data_Table
                                + " ADD COLUMN `msg_flag` tinyint NOT NULL DEFAULT 0;");
            }
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            sql.close_con();
        }
    }
    /**
     *     创建tb_bts_station_event表
     * @param pool
     * @param recreate
     */
    public static void createBts_Station_Event_Table(MysqlConnPool pool, boolean recreate) {
        String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.Bts_Station_Event_Table;
        String sql_str02 = " CREATE TABLE IF NOT EXISTS " + Sql_Mysql.Bts_Station_Event_Table + " (" +
                "  num bigint(20) NOT NULL AUTO_INCREMENT," +
                "  station_id bigint(20) NOT NULL DEFAULT '0'," +
                "  dev_id bigint(20) NOT NULL DEFAULT '0'," +
                "  record_datetime varchar(20) NOT NULL DEFAULT '2015-12-02 12:10:00'," +
                "  station_event_type int(11) NOT NULL DEFAULT '0'," +
                "  station_event_trig int(11) NOT NULL DEFAULT '0'," +
                "  PRIMARY KEY (num)," +
                "  KEY index_dev_id (dev_id)," +
                "  KEY index_station_id (station_id)" +
                ") ENGINE=InnoDB DEFAULT CHARSET=utf8;";
        Sql_Mysql sql = new Sql_Mysql(pool.getConn());
        try {
            if(true == recreate) {
                sql.sqlMysqlExecute(sql_str01);
            }
            sql.sqlMysqlExecute(sql_str02);
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            sql.close_con();
        }
    }
    /**
     *     创建tb_battalarm_data_history表
     * @param pool
     * @param recreate
     */
    public static void createBattalarm_Data_History_Table(MysqlConnPool pool, boolean recreate) {
        String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.Battalarm_Data_History_Table;
        String sql_str02 = " CREATE TABLE IF NOT EXISTS " + Sql_Mysql.Battalarm_Data_History_Table + " (" +
                "  num bigint(20) NOT NULL AUTO_INCREMENT," +
                "  BattGroupId int(11) NOT NULL DEFAULT '0'," +
                "  MonNum int(11) NOT NULL DEFAULT '0'," +
                "  Record_Id bigint(20) NOT NULL DEFAULT '0'," +
                "  alm_id int(11) NOT NULL DEFAULT '0'," +
                "  alm_signal_id int(11) NOT NULL DEFAULT '0'," +
                "  alm_level int(11) NOT NULL DEFAULT '0'," +
                "  alm_start_time datetime NOT NULL DEFAULT '1982-01-01 00:00:00'," +
                "  alm_end_time datetime NOT NULL DEFAULT '1982-01-01 00:00:00'," +
                "  alm_value float NOT NULL DEFAULT '0'," +
                "  alm_is_confirmed tinyint(1) NOT NULL DEFAULT '0'," +
                "  alm_confirmed_time datetime NOT NULL DEFAULT '1982-01-01 00:00:00'," +
                "  alm_cleared_type int(11) NOT NULL DEFAULT '0'," +
                "  usr_Id int(11) NOT NULL DEFAULT '0'," +
                "  PRIMARY KEY (num)," +
                "  KEY index_battgroup_id (BattGroupId)," +
                "  KEY index_Record_Id (Record_Id)," +
                "  KEY index_alm_id (alm_id)," +
                "  KEY index_alm_start_time (alm_start_time)," +
                "  KEY index_alm_cleared_type (alm_cleared_type)," +
                "  KEY index_alm_signal_id (alm_signal_id)," +
                "  KEY index_alm_level (alm_level)" +
                ") ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8;";
        Sql_Mysql sql = new Sql_Mysql(pool.getConn());
        try {
            if(true == recreate) {
                sql.sqlMysqlExecute(sql_str01);
            }
            sql.sqlMysqlExecute(sql_str02);
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            sql.close_con();
        }
    }
    /**
     *     创建tb_battalarm_data表
     * @param pool
     * @param recreate
     */
    public static void createBattalarm_Data_Table(MysqlConnPool pool, boolean recreate) {
        String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.Battalarm_Data_Table;
        String sql_str02 = " CREATE TABLE IF NOT EXISTS " + Sql_Mysql.Battalarm_Data_Table + " (" +
                "  num bigint(20) NOT NULL AUTO_INCREMENT," +
                "  BattGroupId int(11) NOT NULL DEFAULT '0'," +
                "  MonNum int(11) NOT NULL DEFAULT '0'," +
                "  Record_Id bigint(20) NOT NULL DEFAULT '0'," +
                "  alm_id int(11) NOT NULL DEFAULT '0'," +
                "  alm_signal_id int(11) NOT NULL DEFAULT '0'," +
                "  alm_level int(11) NOT NULL DEFAULT '0'," +
                "  alm_start_time datetime NOT NULL DEFAULT '1982-01-01 00:00:00'," +
                "  alm_end_time datetime NOT NULL DEFAULT '1982-01-01 00:00:00'," +
                "  alm_value float NOT NULL DEFAULT '0'," +
                "  alm_is_confirmed tinyint(1) NOT NULL DEFAULT '0'," +
                "  alm_confirmed_time datetime NOT NULL DEFAULT '1982-01-01 00:00:00'," +
                "  alm_cleared_type int(11) NOT NULL DEFAULT '0'," +
                "  usr_Id int(11) NOT NULL DEFAULT '0'," +
                "  PRIMARY KEY (num)," +
                "  KEY index_battgroup_id (BattGroupId)," +
                "  KEY index_Record_Id (Record_Id)," +
                "  KEY index_alm_id (alm_id)," +
                "  KEY index_alm_start_time (alm_start_time)," +
                "  KEY index_alm_cleared_type (alm_cleared_type)," +
                "  KEY index_alm_signal_id (alm_signal_id)," +
                "  KEY index_alm_level (alm_level)" +
                ") ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;";
        Sql_Mysql sql = new Sql_Mysql(pool.getConn());
        ResultSet res = null;
        try {
            if(true == recreate) {
                sql.sqlMysqlExecute(sql_str01);
            }
            sql.sqlMysqlExecute(sql_str02);
            //添加指定的work_flag列(派单管理)
            res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
                    + " WHERE table_schema='db_alarm'"
                    + " AND table_name='tb_battalarm_data'"
                    + " AND column_name='work_flag'");
            if(false == res.next()) {
                sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.Battalarm_Data_Table
                                + " ADD COLUMN `work_flag` tinyint NOT NULL DEFAULT 0;");
            }
            //添加指定的msg_flag列(派单管理)
            res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
                    + " WHERE table_schema='db_alarm'"
                    + " AND table_name='tb_battalarm_data'"
                    + " AND column_name='msg_flag'");
            if(false == res.next()) {
                sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.Battalarm_Data_Table
                                + " ADD COLUMN `msg_flag` tinyint NOT NULL DEFAULT 0;");
            }
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            sql.close_con();
        }
    }
    /**
     *
     * @Title: createTb_Alarm_Message
     * @Description: 告警短信
     * @param pool
     * @param recreate
     * @author author
     * @date 2021年9月6日
     */
    public static void createTb_Alarm_Message(MysqlConnPool pool, boolean recreate) {
        String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.Tb_Alarm_Message;
        String sql_str02 = "CREATE TABLE  IF NOT EXISTS " + Sql_Mysql.Tb_Alarm_Message + " (" +
                "`id` bigint(19) NOT NULL AUTO_INCREMENT,\n" +
                "  `phone` varchar(15) DEFAULT NULL COMMENT '短信发送至手机号',\n" +
                "  `full_device_name` varchar(255) DEFAULT NULL COMMENT '设备全名',\n" +
                "  `alarm_time_category` varchar(255) DEFAULT NULL COMMENT '告警时间段',\n" +
                "  `alarm_message` varchar(255) DEFAULT NULL COMMENT '告警信息',\n" +
                "  `alarm_ids` varchar(255) DEFAULT NULL COMMENT '短信对应的告警id',\n" +
                "  `create_time` datetime DEFAULT NULL,\n" +
                "  `update_time` datetime DEFAULT NULL COMMENT '记录更新时间',\n" +
                "  `status` tinyint(1) DEFAULT NULL COMMENT '发送状态,0-未发送,1-发送完成,2-发送失败',\n" +
                "  PRIMARY KEY (`id`)" +
                ") ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COMMENT='告警短信';";
        Sql_Mysql sql = new Sql_Mysql(pool.getConn());
        try {
            if(true == recreate) {
                sql.sqlMysqlExecute(sql_str01);
            }
            sql.sqlMysqlExecute(sql_str02);
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            sql.close_con();
        }
    }
}
BattMonitor_DB_Builder/src/com/database_util/DB_db_user.java
@@ -58,7 +58,11 @@
        createUser_Limit_Table(pool, recreate);    
    
        createUser_Log_Table(pool, recreate);
        createTb_User_Work(pool, recreate);
        createTb_Work_Alarm(pool, recreate);
    }
    
    /**
@@ -1032,4 +1036,70 @@
            sql.close_con();
        }
    }
    public static void createTb_User_Work(MysqlConnPool pool, boolean recreate) {
        String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.Tb_User_Work;
        String sql_str02 = "CREATE TABLE  IF NOT EXISTS " + Sql_Mysql.Tb_User_Work + " (" +
                "  `id` int(11) NOT NULL AUTO_INCREMENT,\n" +
                "  `workId` int(11) NULL DEFAULT NULL,\n" +
                "  `userId` int(11) NULL DEFAULT NULL COMMENT '维护员id',\n" +
                "  `imageBefore` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '处理前照片',\n" +
                "  `imageAfter` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '处理后照片',\n" +
                "  `workWay` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '处理办法',\n" +
                "  `description` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '告警描述',\n" +
                "  `workSuggest` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '建议',\n" +
                "  `managerId` int(11) NULL DEFAULT NULL COMMENT '管理员审核',\n" +
                "  `note` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '审核意见',\n" +
                "  `createTime` datetime NULL DEFAULT NULL COMMENT '创建时间-接单时间',\n" +
                "  `endTime` datetime NULL DEFAULT NULL COMMENT '结束时间',\n" +
                "  `checkStatus` tinyint(4) NULL DEFAULT NULL COMMENT '审核状态',\n" +
                "  `checkedTime` datetime NULL DEFAULT NULL COMMENT '审核时间',\n" +
                "  PRIMARY KEY (`id`) USING BTREE" +
                ") ENGINE=InnoDB AUTO_INCREMENT=21 DEFAULT CHARSET=utf8 ROW_FORMAT = Dynamic;";
        Sql_Mysql sql = new Sql_Mysql(pool.getConn());
        try {
            if(true == recreate) {
                sql.sqlMysqlExecute(sql_str01);
            }
            sql.sqlMysqlExecute(sql_str02);
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            sql.close_con();
        }
    }
    public static void createTb_Work_Alarm(MysqlConnPool pool, boolean recreate) {
        String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.Tb_Work_Alarm;
        String sql_str02 = "CREATE TABLE  IF NOT EXISTS " + Sql_Mysql.Tb_Work_Alarm + " (" +
                "  `id` int(11) NOT NULL AUTO_INCREMENT,\n" +
                "  `alarmRecId` int(11) NULL DEFAULT NULL COMMENT 'tb_battalarm_data的num',\n" +
                "  `alarmRecordId` bigint(20) NULL DEFAULT NULL COMMENT 'battalarm和devalarm的record_id',\n" +
                "  `stationId` int(11) NULL DEFAULT NULL COMMENT '站点机房id',\n" +
                "  `battGroupId` int(11) NULL DEFAULT NULL COMMENT 'tb_battalarm_data的BattGroupId',\n" +
                "  `deviceId` int(11) NULL DEFAULT NULL,\n" +
                "  `managerId` int(11) NULL DEFAULT NULL COMMENT '管理员id',\n" +
                "  `userId` int(11) NULL DEFAULT NULL COMMENT '维护员id',\n" +
                "  `status` tinyint(4) NULL DEFAULT NULL COMMENT '״̬',\n" +
                "  `dispatchTime` datetime NULL DEFAULT NULL COMMENT '派单时间',\n" +
                "  `alarmLevel` tinyint(4) NULL DEFAULT NULL COMMENT '告警等级',\n" +
                "  `alarmName` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '告警名称',\n" +
                "  `alarmTime` datetime NULL DEFAULT NULL,\n" +
                "  `createTime` datetime NULL DEFAULT NULL,\n" +
                "  PRIMARY KEY (`id`) USING BTREE,\n" +
                "  INDEX `idx_device_id`(`deviceId`) USING BTREE" +
                ") ENGINE=InnoDB AUTO_INCREMENT=1447 DEFAULT CHARSET=utf8 ROW_FORMAT = Dynamic;";
        Sql_Mysql sql = new Sql_Mysql(pool.getConn());
        try {
            if(true == recreate) {
                sql.sqlMysqlExecute(sql_str01);
            }
            sql.sqlMysqlExecute(sql_str02);
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            sql.close_con();
        }
    }
}
BattMonitor_DB_Builder/src/com/sql/Sql_Mysql.java
@@ -1,1359 +1,1362 @@
package com.sql;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import com.base.Com;
/**
 *     创建数据库以及表格
 * @author 军
 *
 */
public class Sql_Mysql
{
    //--------------------------------------------------------------------------------------------//
    final public static String DB_AppSys = "`db_app_sys`";
    final public static String DB_BATT_INF = "`db_battinf`";
    final public static String DB_BATT_TESTDATA = "`db_batt_testdata`";
    final public static String DB_PARAM = "`db_param`";
    final public static String DB_ALARM = "`db_alarm`";
    final public static String DB_USER = "`db_user`";
    final public static String DB_RamDB = "`db_ram_db`";
    final public static String DB_RamDB_BATT_RT = "`db_ram_batt_rt`";
    final public static String WEB_Site = "`web_site`";
    final public static String DB_BATT_HISTORY = "`db_batt_history`";
    final public static String DB_LD9_TESTDATA = "`db_ld9_testdata`";
    final public static String DB_PWRDEV_ALARM = "`db_pwrdev_alarm`";
    final public static String DB_PWRDEV_DATA_RT = "`db_pwrdev_data_rt`";
    final public static String DB_PWRDEV_INF = "`db_pwrdev_inf`";
    final public static String DB_FBO_TESTDATA = "`db_fbo_testdata`";
    //--------------------------------------------------------------------------------------------//
    public final static String TB_HardDevSmsState = "tb_hard_dev_sms_state";
    //--------------------------------------------------------------------------------------------//
    public final static String TB_AppSys = "tb_app_sys";
    public final static String TB_ServerState = "tb_server_state";
    public final static String TB_BattTestDataInf = "tb_batttestdata_inf";
    public final static String TB_BattRtData = "tb_batt_rtdata";
    public final static String TB_BattRtState = "tb_batt_rtstate";
    public final static String TB_UserInf = "tb_user_inf";
    public final static String TB_UserLog = "tb_user_log";
    public final static String TB_UserBattGroup_BaoJiGroup = "tb_user_battgroup_baojigroup";
    public final static String TB_UserBattGroup_BaoJiGroup_BattGroup = "tb_user_battgroup_baojigroup_battgroup";
    public final static String TB_UserBattGroup_BaoJiGroup_Usr = "tb_user_battgroup_baojigroup_usr";
    public final static String TB_UserTaskTemplate = "tb_user_task_batt_template";
    public final static String TB_UserTask = "tb_user_task";
    public final static String TB_UserPaiXiu = "tb_user_paixiu";
    public final static String TB_UserListForTask = "tb_user_task_user_list";
    public final static String TB_UserTaskParam = "tb_user_task_param";
    public final static String TB_UserBattCkeckTask = "tb_user_task_batt_check";
    public final static String TB_UserBattTestTask = "tb_user_task_batt_test";
    public final static String TB_UserBattTaskChange = "tb_user_task_change";
    public final static String TB_UserSms = "tb_user_sms";
    public final static String TB_UserSmsFormat = "tb_user_sms_format";
    public final static String TB_UserPermitGroup = "tb_user_permitgroup";
    public final static String TB_UserPermitGroupData = "tb_user_permitgroup_data";
    public final static String TB_UserJieJiaRi = "tb_user_jiejiari";
    //--------------------------------------------------------------------------------------------//
    //--------------------------------------------------------------------------------------------//
    public final static String CInterfaceState_Table = DB_RamDB + ".`tb_cinterface_state`";
    public final static String FBS9600SetParam_Table = DB_RamDB + ".`tb_fbs9600_setparam`";
    //public final static String FBS9600Param_Table = DB_RamDB + ".`tb_fbs9600_param`";
    //--------------------------------------------------------------------------------------------//
    //--------------------------------------------------------------------------------------------//
    public final static String AppSys_Table = DB_AppSys + ".`tb_app_sys`";
    public final static String FBSDevStateChangeInf_Table = DB_AppSys + ".`tb_fbsdev_statechange_inf`";
    public final static String BattInf_Table = DB_BATT_INF + ".`tb_battinf`";
    public final static String BattCurrInf_Table = DB_BATT_INF + ".`tb_battcurr_inf`";
    public final static String BattMainInf_Table = DB_BATT_INF + ".`tb_batt_maint_inf`";
    public final static String BattMainProcess_Table = DB_BATT_INF + ".`tb_batt_maint_process`";
    public final static String BattTestDataInf_Table = DB_BATT_TESTDATA + ".`tb_batttestdata_inf`";
    public final static String BattResDataInf_Table = DB_BATT_TESTDATA + ".`tb_battresdata_inf`";
    public final static String BattResData_Table = DB_BATT_TESTDATA + ".`tb_BattResData`";
    public final static String UserInfTable = DB_USER + ".`tb_user_inf`";
    public final static String UserLogTable = DB_USER + ".`tb_user_log`";
    public final static String UserBattGroup_BaoJiGroup_Table = DB_USER + ".`tb_user_battgroup_baojigroup`";
    public final static String UserBattGroup_BaoJiGroup_BattGroupTable = DB_USER + ".`tb_user_battgroup_baojigroup_battgroup`";
    public final static String UserBattGroup_BaoJiGroup_UsrTable = DB_USER + ".`tb_user_battgroup_baojigroup_usr`";
    public final static String UserTaskTemplateTable = DB_USER + ".`tb_user_task_batt_template`";
    public final static String UserTaskTable = DB_USER + ".`tb_user_task`";
    public final static String UserPaiXiuTable = DB_USER + ".`tb_user_paixiu`";
    public final static String UserListForTaskTable = DB_USER + ".`tb_user_task_user_list`";
    public final static String UserTaskParamTable = DB_USER + ".`tb_user_task_param`";
    public final static String UserBattCheckTaskTable = DB_USER + ".`tb_user_task_batt_check`";
    public final static String UserBattTestTaskTable = DB_USER + ".`tb_user_task_batt_test`";
    public final static String UserBattTaskChangeTable = DB_USER + ".`tb_user_task_change`";
    public final static String UsrBattMaintCheck_Table = DB_USER + ".`tb_user_battmaint_check`";
    public final static String UsrBattMaintCheckProcess_Table = DB_USER + ".`tb_user_battmaint_check_process`";
    public final static String UserSmsTable = DB_USER + ".`tb_user_sms`";
    public final static String UserSmsFormatTable = DB_USER + ".`tb_user_sms_format`";
    public final static String UserPermitGroupTable = DB_USER + ".`tb_user_permitgroup`";
    public final static String UserPermitGroupDataTable = DB_USER + ".`tb_user_permitgroup_data`";
    public final static String UserJieJiaRiTable = DB_USER + ".`tb_user_jiejiari`";
    public final static String BTSStationEvent_Table = DB_ALARM + ".`tb_bts_station_event`";                            //机房状态历史表
    /**************************** db_ram_db数据库 ***************************************************/
    public final static String SocketClientStateTable = DB_RamDB + ".`tb_socketclient_state`";
    public final static String ServerState_Table = DB_RamDB + ".`tb_server_state`";
    public final static String Ld9_Updatestatue_Table = DB_RamDB + ".`tb_ld9_updatestatue`";
    public final static String Ld9_State_Table = DB_RamDB + ".`tb_ld9_state`";
    public final static String Ld9_Setparam_Table = DB_RamDB + ".`tb_ld9_setparam`";
    public final static String Ld9_Concentratestate_Table = DB_RamDB + ".`tb_ld9_concentratestate`";
    public final static String Ld9_Concentrateparam_Table = DB_RamDB + ".`tb_ld9_concentrateparam`";
    public final static String HardDevSmsState_Table = DB_RamDB + ".`tb_hard_dev_sms_state`";
    public final static String FBS9600State_Table = DB_RamDB + ".`tb_fbs9600_state`";
    public final static String FBS9100_NiBian_State = DB_RamDB + ".tb_fbs9100s_nibian_state";                        //61850离线养护计划参数表
    public final static String FBS9100s_fod_state = DB_RamDB + ".tb_fbs9100s_fod_state";                            //61850除硫状态表
    public final static String FBS9100SetDLParam_Table = DB_RamDB + ".`tb_fbs9100s_fod_param`";                        //61850除硫参数表
    public final static String FBS9100S_DFUState_Table = DB_RamDB + ".`tb_fbs9100s_DFU_state`";
    public final static String FBS9100S_DcDcState_Table = DB_RamDB + ".`tb_fbs9100s_dcdc_state`";
    public final static String FBS9100SysParam_Table = DB_RamDB + ".`tb_fbs9100_sysparam`";                            //系统参数表
    public final static String FBS9100State_Table = DB_RamDB + ".`tb_fbs9100_state`";
    public final static String FBS9100SetParam_Table = DB_RamDB + ".`tb_fbs9100_setparam`";
    public final static String FBS9100_offlineyhplan = DB_RamDB + ".tb_fbs9100_offlineyhplan";                        //61850离线养护计划参数表
    public final static String FBS9100BattParam_Table = DB_RamDB + ".`tb_fbs9100_battparam`";                        //电池组参数表
    public final static String BTSStationState_Table = DB_RamDB + ".`tb_bts_station_state`";                        //机房状态表
    public final static String BTSGPRSState_Table = DB_RamDB + ".`tb_bts_gprs_state`";                                //gprs 信息表
    public final static String BMP7100State_Table = DB_RamDB + ".`tb_bpm7100_state`";
    public final static String BattRtState_Table = DB_RamDB + ".`tb_batt_rtstate`";
    public final static String BattRtData_Table = DB_RamDB + ".`tb_batt_rtdata`";
    public final static String TB_61850_JHState_Table = DB_RamDB +".tb_61850_jhstate";                                //61850均衡61850供电模块信息
    public final static String RamDB_CMCC_POWER_Data = DB_RamDB + ".`cmcc_power_data`";
    public final static String FBS9100_InsulatstateTable = DB_RamDB + ".`tb_fbs9100_insulatstate`";                    //绝缘装置
    public final static String FBS9100_CollectionstateTable = DB_RamDB + ".`tb_fbs9100_collectionstate`";            //汇集装置
    public final static String FBS9100_ChargerstateTable = DB_RamDB + ".`tb_fbs9100_chargerstate`";                    //充电机
    public final static String Tb_Lithium_DataTable = DB_RamDB + ".`tb_lithium_data`";                                //锂电池数据表
    public final static String Tb_Batt_RSAlarm_Table = DB_RamDB + ".`tb_batt_rsalarm`";                                //锂电池数据表
    public final static String Tb_Batt_RTAlarm_Table = DB_RamDB + ".`tb_batt_rtalarm`";                                //锂电池数据表
    public final static String FBS9100s_stemnode_state_Table = DB_RamDB + ".`tb_fbs9100s_stemnode_state`";            //干节点状态表
    public final static String FBS9100s_buscouple_state_Table = DB_RamDB + ".`tb_fbs9100s_buscouple_state`";        //母联开关状态表
    public final static String Fgcd_filedownload_Table = DB_RamDB + ".`tb_fgcd_filedownload`";                        //FGCD充放电一体机控制
    /**************************** db_user数据库 ***************************************************/
    public final static String User_Permitgroup_Table = DB_USER + ".`tb_user_permitgroup`";                                //权限表
    public final static String User_Permitgroup_Data_Table = DB_USER + ".`tb_user_permitgroup_data`";                    //用户权限表
    public final static String User_Task_User_List_Table = DB_USER + ".`tb_user_task_user_list`";                        //
    public final static String User_Task_Template_Table = DB_USER + ".`tb_user_task_template`";                            //
    public final static String User_Task_Param_Table = DB_USER + ".`tb_user_task_param`";                            //
    public final static String User_Task_Change_Table = DB_USER + ".`tb_user_task_change`";                            //
    public final static String User_Task_Batt_Test_Table = DB_USER + ".`tb_user_task_batt_test`";                            //
    public final static String User_Task_Batt_Template_Table = DB_USER + ".`tb_user_task_batt_template`";                            //
    public final static String User_Task_Batt_Check_Table = DB_USER + ".`tb_user_task_batt_check`";                            //
    public final static String User_Task_Table = DB_USER + ".`tb_user_task`";                            //
    public final static String User_Sms_Format_Table = DB_USER + ".`tb_user_sms_format`";                            //
    public final static String User_Sms_Table = DB_USER + ".`tb_user_sms`";                            //
    public final static String User_Paixiu_Table = DB_USER + ".`tb_user_paixiu`";                            //
    public final static String User_Log_Table = DB_USER + ".`tb_user_log`";                            //
    public final static String User_Jiejiari_Table = DB_USER + ".`tb_user_jiejiari`";                            //
    public final static String User_Face_Table = DB_USER + ".`tb_user_face`";                            //
    public final static String User_Battmaint_Check_Process_Table = DB_USER + ".`tb_user_battmaint_check_process`";                            //
    public final static String User_Battmaint_Check_Table = DB_USER + ".`tb_user_battmaint_check`";                            //
    public final static String User_Battgroup_Baojigroup_Usr_Table = DB_USER + ".`tb_user_battgroup_baojigroup_usr`";                            //
    public final static String User_Battgroup_Baojigroup_Battgroup_Table = DB_USER + ".`tb_user_battgroup_baojigroup_battgroup`";                            //
    public final static String User_Battgroup_Baojigroup_Table = DB_USER + ".`tb_user_battgroup_baojigroup`";                            //
    public final static String User_Limit_Table = DB_USER + ".`tb_user_limit`";                            //
    /**************************** web_site数据库 ***************************************************/
    public final static String ThreadUtil_Table = WEB_Site + ".`tb_thread_util`";                        //线程帮助表
    public final static String PositiomapUsr_Table = WEB_Site + ".`tb_positiomap_usr`";                    //首页地图中心点定位表
    public final static String ChartColor_Table = WEB_Site + ".`tb_chart_color`";                        //用户实时监测页面指定柱状的颜色设置表
    public final static String UserChart_Table = WEB_Site + ".`tb_user_chart`";                            //班组管理表
    public final static String ProcessSurvey_Table = WEB_Site + ".`tb_process_survey`";                    //线程监控表
    public final static String EchartsUsr_Table = WEB_Site + ".`tb_echarts_usr`";                        //用户首页定制表
    public final static String DevstateUsr_Table = WEB_Site + ".`tb_devstate_usr`";                        //用户放电添加记录表
    public final static String CustomPage_Table = WEB_Site + ".`tb_custompage`";                        //导航数据表
    public final static String Announce_Table = WEB_Site + ".`tb_announce`";                            //公告表
    public final static String BattAttention_Table = WEB_Site + ".`tb_batt_attention`";                    //创建电池组单体关注表
    public final static String BattpowerOff_Table = WEB_Site + ".`tb_battpower_off`";                    //机房停电表
    public final static String BadbattMon_Table = WEB_Site + ".`tb_badbatt_mon`";                        //落后单体表
    public final static String BadbattMonFlag_Table = WEB_Site + ".`tb_badbatt_mon_flag`";                //落后单体控制表
    public final static String BattEndurance_Table = WEB_Site + ".`tb_batt_endurance`";                    //机房续航表
    public final static String BattParamLow_Table = WEB_Site + ".`tb_batt_param_low`";                    //电池参数表
    public final static String BattDischargeParam_Table = WEB_Site + ".`tb_battdischarge_param`";        //放电计划参数表
    public final static String BattDischargePlan_Table = WEB_Site + ".`tb_battdischarge_plan`";            //放电计划表
    public final static String Avoid_plan_Table = WEB_Site + ".`tb_avoid_plan`";                        //放电计划规避时间表
    public final static String BattMapInformation_Table = WEB_Site + ".`tb_battmap_information`";        //基站定位表
    public final static String BattDischarge_Table = WEB_Site + ".`tb_batt_discharge`";                    //基站故障表
    public final static String BattReplace_Table = WEB_Site + ".`tb_batt_replace`";                        //电池更换记录表
    public final static String Dev_Restart_Plan_Table = WEB_Site +".`tb_dev_restart_plan`";                //设备定期重启计划表
    public final static String Vip_User_Table = WEB_Site +".`tb_vip_user`";                                //超级用户表
    public final static String License_Table = WEB_Site +".`tb_license`";                                //超级用户表
    public final static String Database_Backup_Table = WEB_Site +".`tb_database_backup`";                                //超级用户表
    /***************************** db_battinf数据库  ***************************************/
    public final static String DeverrorRecord_Table = DB_BATT_INF + ".`tb_deverror_record`";                        //机房问题记录表
    public final static String BattinfApply_TABLE = DB_BATT_INF + ".`tb_battinf_apply`";                            //机房安装审批表
    public final static String BattinfEx_TABLE = DB_BATT_INF + ".`tb_battinf_ex`";                                    //基站信息表
    public final static String BattinfRebuild_TABLE = DB_BATT_INF + ".`tb_battinf_rebuild`";                        //机房配组表
    public final static String BattmonTestcap_TABLE = DB_BATT_INF + ".`tb_battmon_testcap`";                        //机房标准测试曲线记录表
    public final static String Battcurr_Inf_TABLE = DB_BATT_INF + ".`tb_battcurr_inf`";
    public final static String Batt_Maint_Process_TABLE = DB_BATT_INF + ".`tb_batt_maint_process`";
    public final static String Batt_Maint_Inf_TABLE = DB_BATT_INF + ".`tb_batt_maint_inf`";
    public final static String Batt_Alm_Param_TABLE = DB_BATT_INF + ".`tb_batt_alm_param`";
    /***************************** db_alarm数据库  ***************************************/
    public final static String Devalarm_Data_Table = DB_ALARM + ".`tb_devalarm_data`";
    public final static String Devalarm_Data__History_Table = DB_ALARM + ".`tb_devalarm_data_history`";
    public final static String Bts_Station_Event_Table = DB_ALARM + ".`tb_bts_station_event`";
    public final static String Battalarm_Data_Table = DB_ALARM + ".`tb_battalarm_data`";
    public final static String Battalarm_Data_History_Table = DB_ALARM + ".`tb_battalarm_data_history`";
    /***************************** db_app_sys 数据库  ***************************************/
    public final static String Page_Param_Table = DB_AppSys + ".`tb_page_param`";
    public final static String Fbsdev_Statechange_Inf_Table = DB_AppSys + ".`tb_fbsdev_statechange_inf`";
    public final static String Dashboard_Module_Chart_Table = DB_AppSys + ".`tb_dashboard_module_chart`";
    public final static String Dashboard_Module_Table = DB_AppSys + ".`tb_dashboard_module`";
    public final static String Dashboard_Chart_Type_Table = DB_AppSys + ".`tb_dashboard_chart_type`";
    public final static String App_Sys_Table = DB_AppSys + ".`tb_app_sys`";
    public final static String App_Bts_Comm_Task_Table = DB_AppSys + ".`tb_app_bts_comm_task`";
    public final static String App_Bts_Battgroup_Table = DB_AppSys + ".`tb_app_bts_battgroup`";
    public final static String Menu_Table = DB_AppSys + ".`tb_menu`";
    /***************************** db_ld9_testdata 数据库  ***************************************/
    public final static String Ld9testdata_Inf_Table = DB_LD9_TESTDATA + ".`tb_ld9testdata_inf`";
    /***************************** db_param 数据库  ***************************************/
    public final static String Dev_Param_Table = DB_PARAM + ".`tb_dev_param`";
    public final static String App_Param_Table = DB_PARAM + ".`tb_app_param`";
    public final static String Alarm_Param_Table = DB_PARAM + ".`tb_alarm_param`";
    /***************************** db_pwrdev_alarm 数据库  ************************************/
    public final static String Pwrdev_Alarm_Table = DB_PWRDEV_ALARM + ".`tb_pwrdev_alarm`";
    public final static String Pwrdev_Alarm_History_Table = DB_PWRDEV_ALARM + ".`tb_pwrdev_alarm_history`";
    /***************************** db_pwrdev_data_rt 数据库  ************************************/
    public final static String Pwrdev_Acdcdata_Table = DB_PWRDEV_DATA_RT + ".`tb_pwrdev_acdcdata`";
    public final static String Pwrdev_Dcdata_Table = DB_PWRDEV_DATA_RT + ".`tb_pwrdev_dcdata`";
    public final static String Pwrdev_Acdata_Table = DB_PWRDEV_DATA_RT + ".`tb_pwrdev_acdata`";
     /***************************** db_pwrdev_inf 数据库  ************************************/
    public final static String Pwrdev_Inf_Table = DB_PWRDEV_INF + ".`tb_pwrdev_inf`";
    public final static String Pwrapp_Sys_Table = DB_PWRDEV_INF + ".`tb_pwrapp_sys`";
    public final static String Display_Config_Table = DB_PWRDEV_INF + ".`tb_display_config`";
    public final static String Pwrapp_Stainf_Table = DB_PWRDEV_INF + ".`tb_pwrapp_stainf`";
    public final static String Pwrapp_Dcinf_Table = DB_PWRDEV_INF + ".`tb_pwrapp_dcinf`";
    public final static String Pwrapp_Acinf_Table = DB_PWRDEV_INF + ".`tb_pwrapp_acinf`";
    public final static String Pwrapp_Acdcinf_Table = DB_PWRDEV_INF + ".`tb_pwrapp_acdcinf`";
    /***************************** db_fbo_testdata 数据库  ************************************/
    public final static String Fbotestdata_Inf_Table = DB_FBO_TESTDATA + ".`tb_fbotestdata_inf`";
    //--------------------------------------------------------------------------------------------//
    //--------------------------------------------------------------------------------------------//
    public Connection mysql_con;
    public Sql_Mysql(Connection conn)
    {
        mysql_con = conn;
    }
    /*
    public static Connection getConnection() throws SQLException, java.lang.ClassNotFoundException{
        String url = "jdbc:mysql://192.168.48.128:3306/studentinfo";
        Class.forName("com.mysql.jdbc.Driver");
        String userName = "root";
        String password = "lmx8688139";
        Connection con = DriverManager.getConnection(url,userName,password);
        return con;
    }
    */
    public void close_con()
    {
        try {
            mysql_con.close();
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
    public void checkAndCreateDB() throws SQLException
    {
        sqlMysqlExecute("CREATE DATABASE IF NOT EXISTS " + DB_AppSys);
        sqlMysqlExecute("CREATE DATABASE IF NOT EXISTS " + DB_BATT_INF);
        sqlMysqlExecute("CREATE DATABASE IF NOT EXISTS " + DB_BATT_TESTDATA);
        sqlMysqlExecute("CREATE DATABASE IF NOT EXISTS " + DB_PARAM);
        sqlMysqlExecute("CREATE DATABASE IF NOT EXISTS " + DB_ALARM);
        sqlMysqlExecute("CREATE DATABASE IF NOT EXISTS " + DB_USER);
        sqlMysqlExecute("CREATE DATABASE IF NOT EXISTS " + DB_RamDB);
        //sqlMysqlExecute("DROP DATABASE IF EXISTS " + DB_RamDB_BATT_RT);
        //sqlMysqlExecute("CREATE DATABASE IF NOT EXISTS " + DB_RamDB_BATT_RT);
        sqlMysqlExecute("CREATE DATABASE IF NOT EXISTS " + WEB_Site);
        String table_0 = "CREATE TABLE IF NOT EXISTS " + AppSys_Table
                        + " ( `num` INT NOT NULL AUTO_INCREMENT,"
                        + "`SqlDB_Version` FLOAT NOT NULL DEFAULT '1.0',"
                        + "`SqlDB_BackUpTime` DATETIME NOT NULL DEFAULT '2000-1-1 00:00:00',"
                        + "`SqlDB_BackUpManual_EN` BOOLEAN NOT NULL DEFAULT false, "
                        + "`AppServer_Reinit_BattGroupData_EN` BOOLEAN NOT NULL DEFAULT false, "
                        + "`AppServer_Reinit_BattGroupData_LD9_EN` BOOLEAN NOT NULL DEFAULT false, "            //用于9度程序重新加载设备
                        + "`AppServer_Reinit_Config_EN` BOOLEAN NOT NULL DEFAULT false, "
                        + "`AppServer_Version` FLOAT NOT NULL DEFAULT '1.0',"
                        + "`AppClient_Version` FLOAT NOT NULL DEFAULT '1.0',"
                        + "`AppName` VARCHAR(50) NOT NULL DEFAULT '0',"
                        + " PRIMARY KEY (`num`)) "
                        + " ENGINE=InnoDB DEFAULT CHARSET=utf8;";
        String table_1 = "CREATE TABLE IF NOT EXISTS " + BattInf_Table
                        + " ( `num` INT NOT NULL AUTO_INCREMENT,"
                        + "`StationId` VARCHAR(20) NOT NULL DEFAULT '0',"
                        + "`StationName` VARCHAR(100) NOT NULL DEFAULT ' ',"
                        + "`StationName1` VARCHAR(100) NOT NULL DEFAULT ' ',"
                        + "`StationName2` VARCHAR(100) NOT NULL DEFAULT ' ',"
                        + "`StationName3` VARCHAR(100) NOT NULL DEFAULT ' ',"
                        + "`StationName4` VARCHAR(100) NOT NULL DEFAULT ' ',"
                        + "`StationName5` VARCHAR(100) NOT NULL DEFAULT ' ',"
                        + "`StationName6` VARCHAR(100) NOT NULL DEFAULT ' ',"
                        + "`StationName7` VARCHAR(100) NOT NULL DEFAULT ' ',"
                        + "`StationName8` VARCHAR(100) NOT NULL DEFAULT ' ',"
                        + "`StationName9` VARCHAR(100) NOT NULL DEFAULT ' ',"
                        + "`StationIP` VARCHAR(20) NOT NULL DEFAULT '0',"
                        + "`FBSDeviceId` BIGINT NOT NULL DEFAULT '0',"
                        + "`FBSDeviceIp` VARCHAR(50) NOT NULL DEFAULT '192.168.0.88',"
                        + "`FBSDeviceName` VARCHAR(100) NOT NULL DEFAULT '0',"
                        + "`GroupIndexInFBSDevice` INT NOT NULL DEFAULT '0',"
                        + "`BattModel` VARCHAR(100) NOT NULL DEFAULT ' ',"
                        + "`BattGroupId` INT NOT NULL DEFAULT '0',"
                        + "`BattGroupNum` INT NOT NULL DEFAULT '0',"
                        + "`BattGroupName` VARCHAR(100) NOT NULL DEFAULT ' ',"
                        + "`BattGroupName1` VARCHAR(100) NOT NULL DEFAULT ' ',"
                        + "`BattGroupName2` VARCHAR(100) NOT NULL DEFAULT ' ',"
                        + "`BattGroupName3` VARCHAR(100) NOT NULL DEFAULT ' ',"
                        + "`BattGroupName4` VARCHAR(100) NOT NULL DEFAULT ' ',"
                        + "`BattGroupName5` VARCHAR(100) NOT NULL DEFAULT ' ',"
                        + "`BattGroupName6` VARCHAR(100) NOT NULL DEFAULT ' ',"
                        + "`FloatVolLevel` FLOAT NOT NULL DEFAULT '1.12',"
                        + "`OfflineVolLevel` FLOAT NOT NULL DEFAULT '1.06',"
                        + "`BattFloatCurrent` FLOAT NOT NULL DEFAULT '0',"
                        + "`DeviceId` VARCHAR(20) NOT NULL DEFAULT '0',"
                        + "`DeviceName` VARCHAR(100) NOT NULL DEFAULT '0',"
                        + "`MonCount` INT NOT NULL DEFAULT '0',"
                        + "`MonCapStd` FLOAT NOT NULL DEFAULT '0',"
                        + "`MonVolStd` FLOAT NOT NULL DEFAULT '0',"
                        + "`MonResStd` FLOAT NOT NULL DEFAULT '0',"
                        + "`MonSerStd` FLOAT NOT NULL DEFAULT '0',"
                        + "`MonTmpStd` FLOAT NOT NULL DEFAULT '0',"
                        + "`MonVolLowToAvg` FLOAT NOT NULL DEFAULT '0',"
                        + "`MonNum` INT NOT NULL DEFAULT '0',"
                        + "`BattProducer` VARCHAR(45) NOT NULL DEFAULT '0',"
                        + "`BattProductDate` DATE NOT NULL DEFAULT '2006-07-06',"
                        + "`BattInUseDate` DATE NOT NULL DEFAULT '2006-07-06',"
                        + "`BattGuarantDayCount` INT NOT NULL DEFAULT '1095',"
                        + "`SignalId` VARCHAR(20) NOT NULL DEFAULT '0',"
                        + "`CInterFaceId` INT NOT NULL DEFAULT '0',"
                        + "`SignalName` VARCHAR(50) NOT NULL DEFAULT '0',"
                        + "INDEX index_station_id (`StationId`), "
                        + "INDEX index_battgroup_id (`BattGroupId`), "
                        + "INDEX index_station_name (`StationName`), "
                        + "INDEX index_battgroup_name (`BattGroupName`), "
                        + "PRIMARY KEY (`num`)) "
                        + "ENGINE=InnoDB DEFAULT CHARSET=utf8;";
        String table_2 = "CREATE TABLE IF NOT EXISTS " + BattCurrInf_Table
                        + " ( `num` INT NOT NULL AUTO_INCREMENT,"
                        + "`StationId` VARCHAR(20) NOT NULL DEFAULT '0',"
                        + "`BattGroupId` VARCHAR(20) NOT NULL DEFAULT '0',"
                        + "`BattGroupName` VARCHAR(100) NOT NULL DEFAULT '0',"
                        + "`CurrDeviceId` VARCHAR(20) NOT NULL DEFAULT '0',"
                        + "`CurrDeviceName` VARCHAR(100) NOT NULL DEFAULT '0',"
                        + "`CurrValueId` VARCHAR(20) NOT NULL DEFAULT '0',"
                        + "`CurrValueName` VARCHAR(100) NOT NULL DEFAULT '0',"
                        + "PRIMARY KEY (`num`)) "
                        + "ENGINE=InnoDB DEFAULT CHARSET=utf8;";
        String table_3 = "CREATE TABLE IF NOT EXISTS " + BattMainInf_Table
                        + " ( `num` BIGINT NOT NULL AUTO_INCREMENT, "
                        + "`BattGroupId` INT NOT NULL DEFAULT 0, "
                        + "`usr_id` INT NOT NULL DEFAULT 0, "
                        + "`fault_type_id` INT NOT NULL DEFAULT 0, "
                        + "`fault_type` VARCHAR(50) NOT NULL DEFAULT ' ', "
                        + "`fault_level` INT NOT NULL DEFAULT 0, "
                        + "`fault_caption` VARCHAR(200) NOT NULL DEFAULT ' ', "
                        + "`fault_time` DATETIME NOT NULL DEFAULT '2005-1-1 00:00:00', "
                        + "`record_uid` INT NOT NULL DEFAULT 0, "
                        + "`record_time` DATETIME NOT NULL DEFAULT '2005-1-1 00:00:00', "
                        + "`maint_time_limit` DATETIME NOT NULL DEFAULT '2005-1-1 00:00:00', "
                        + "`maint_type_id` INT NOT NULL DEFAULT 0, "
                        + "`maint_type` VARCHAR(50) NOT NULL DEFAULT ' ', "
                        + "`maint_result` VARCHAR(100) NOT NULL DEFAULT ' ', "
                        + "`maint_done` BOOLEAN NOT NULL DEFAULT false, "
                        + "`maint_done_time` DATETIME DEFAULT '2005-1-1 00:00:00', "
                        + "`maint_close` BOOLEAN NOT NULL DEFAULT false, "
                        + "`master_id` INT NOT NULL DEFAULT 0, "
                        + "`master_audit` INT NOT NULL DEFAULT 0, "                //领导审核
                        + "`appoint_uid` INT NOT NULL DEFAULT 0, "                 //指派给谁
                        + "`copy_uids` VARCHAR(200) NOT NULL DEFAULT ' ', "        //抄送给谁
                        + "`master_check` VARCHAR(100) NOT NULL DEFAULT ' ', "
                        + "`remark` VARCHAR(200) NOT NULL DEFAULT ' ', "
                        + "INDEX index_battgroup_id (`BattGroupId`), "
                        + "INDEX index_user_id (`usr_id`), "
                        + "INDEX index_fault_type_id (`fault_type_id`), "
                        + "INDEX index_maint_type_id (`maint_type_id`), "
                        + "PRIMARY KEY (`num`)) "
                        + "ENGINE=InnoDB DEFAULT CHARSET=utf8;";
        String table_3_1 = "CREATE TABLE IF NOT EXISTS " + BattMainProcess_Table
                        + " ( `num` BIGINT NOT NULL AUTO_INCREMENT, "
                        + "`batt_maint_rec_id` BIGINT NOT NULL DEFAULT 0, "
                        + "`usr_id` INT NOT NULL DEFAULT 0, "
                        + "`work_caption` VARCHAR(200) NOT NULL DEFAULT ' ', "
                        + "`work_caption_time` DATETIME DEFAULT '2005-1-1 00:00:00', "
                        + "INDEX index_batt_maint_rec_id (`batt_maint_rec_id`), "
                        + " PRIMARY KEY (`num`)) "
                        + "ENGINE=InnoDB DEFAULT CHARSET=utf8;";
        String table_3_2 = "CREATE TABLE IF NOT EXISTS " + UsrBattMaintCheck_Table
                        + " ( `num` BIGINT NOT NULL AUTO_INCREMENT, "
                        + "`StationId` INT NOT NULL DEFAULT 0, "
                        + "`usr_id` INT NOT NULL DEFAULT 0, "
                        + "`master_id` INT NOT NULL DEFAULT 0, "
                        + "`appoint_uid` INT NOT NULL DEFAULT 0, "                 //指派给谁
                        + "`copy_uids` VARCHAR(200) NOT NULL DEFAULT ' ', "        //抄送给谁
                        + "`task_type_id` INT NOT NULL DEFAULT 0, "
                        + "`task_level` INT NOT NULL DEFAULT 0, "
                        + "`task_caption` VARCHAR(200) NOT NULL DEFAULT ' ', "
                        + "`task_time_start` DATETIME NOT NULL DEFAULT '2005-1-1 00:00:00', "
                        + "`task_time_end` DATETIME NOT NULL DEFAULT '2005-1-1 00:00:00', "
                        + "`task_process` VARCHAR(200) NOT NULL DEFAULT ' ', "
                        + "`task_done` BOOLEAN NOT NULL DEFAULT false, "
                        + "`task_done_time` DATETIME DEFAULT '2005-1-1 00:00:00', "
                        + "`origin_usr_work_mark` INT NOT NULL DEFAULT 0, "
                        + "`task_done_confirm` BOOLEAN NOT NULL DEFAULT false, "
                        + "`master_audit` INT NOT NULL DEFAULT 0, "                //领导审核
                        + "`remark` VARCHAR(200) NOT NULL DEFAULT ' ', "
                        + "INDEX index_station_id (`StationId`), "
                        + "INDEX index_user_id (`usr_id`), "
                        + "INDEX index_task_type_id (`task_type_id`), "
                        + "PRIMARY KEY (`num`)) "
                        + "ENGINE=InnoDB DEFAULT CHARSET=utf8;";
        String table_3_2_1 = "CREATE TABLE IF NOT EXISTS " + UsrBattMaintCheckProcess_Table
                        + " ( `num` BIGINT NOT NULL AUTO_INCREMENT, "
                        + "`task_rec_id` BIGINT NOT NULL DEFAULT 0, "
                        + "`usr_id` INT NOT NULL DEFAULT 0, "
                        + "`work_caption` VARCHAR(200) NOT NULL DEFAULT ' ', "
                        + "`work_caption_time` DATETIME DEFAULT '2005-1-1 00:00:00', "
                        + "INDEX index_task_rec_id (`task_rec_id`), "
                        + " PRIMARY KEY (`num`)) "
                        + "ENGINE=InnoDB DEFAULT CHARSET=utf8;";
        String table_4 = "CREATE TABLE IF NOT EXISTS " + BattTestDataInf_Table
                        + " ( `num` BIGINT NOT NULL AUTO_INCREMENT, "
                        + "`BattGroupId` INT NOT NULL DEFAULT 0, "
                        + "`test_record_count` INT NOT NULL DEFAULT 0, "
                        + "`test_record_count_ex` INT NOT NULL DEFAULT 0, "
                        + "`test_type` INT NOT NULL DEFAULT 0, "
                        + "`record_time_interval` INT NOT NULL DEFAULT 0, "
                        + "`data_new` BOOLEAN NOT NULL DEFAULT false, "
                        + "`data_available` BOOLEAN NOT NULL DEFAULT false, "
                        + "`record_num` INT NOT NULL DEFAULT 0, "
                        + "`test_starttime` DATETIME NOT NULL DEFAULT '1982-01-01 00:00:00', "
                        + "`test_starttime_ex` DATETIME NOT NULL DEFAULT '1982-01-01 00:00:00', "
                        + "`test_starttype` INT NOT NULL DEFAULT 0, "
                        + "`record_time` DATETIME NOT NULL DEFAULT '1982-01-01 00:00:00', "
                        + "`test_timelong` INT NOT NULL DEFAULT 0, "
                        + "`test_stoptype` INT NOT NULL DEFAULT 0, "
                        + "`group_vol` FLOAT NOT NULL DEFAULT 0, "
                        + "`test_curr` FLOAT NOT NULL DEFAULT 0, "
                        + "`test_cap` FLOAT NOT NULL DEFAULT 0, "
                        + "`max_monnum` INT NOT NULL DEFAULT 0, "
                        + "`max_monvol` FLOAT NOT NULL DEFAULT 0, "
                        + "`min_monnum` INT NOT NULL DEFAULT 0, "
                        + "`min_monvol` FLOAT NOT NULL DEFAULT 0, "
                        + "`mon_num` INT NOT NULL DEFAULT 0, "
                        + "`mon_vol` FLOAT NOT NULL DEFAULT 0, "
                        + "`upload_usr_id` INT NOT NULL DEFAULT 0, "
                        + "`upload_data_ext` INT NOT NULL DEFAULT 0, "
                        + "`upload_client_type` INT NOT NULL DEFAULT 0, "
                        + "INDEX index_battgroup_id (`BattGroupId`), "
                        + "INDEX index_test_record_count (`test_record_count`), "
                        + "INDEX index_test_type (`test_type`), "
                        + "INDEX index_test_starttime (`test_starttime`), "
                        + "PRIMARY KEY (`num`)) "
                        + "ENGINE=InnoDB DEFAULT CHARSET=utf8;";
        String table_5 = "CREATE TABLE IF NOT EXISTS " + BattResDataInf_Table
                        + " ( `num` BIGINT NOT NULL AUTO_INCREMENT, "
                        + "`BattGroupId` INT NOT NULL DEFAULT 0, "
                        + "`test_record_count` INT NOT NULL DEFAULT 0, "
                        + "`test_record_count_ex` INT NOT NULL DEFAULT 0, "
                        + "`test_type` INT NOT NULL DEFAULT 0, "
                        + "`data_new` BOOLEAN NOT NULL DEFAULT false, "
                        + "`data_available` BOOLEAN NOT NULL DEFAULT false, "
                        + "`test_starttime` DATETIME NOT NULL DEFAULT '1982-01-01 00:00:00', "
                        + "`test_starttime_ex` DATETIME NOT NULL DEFAULT '1982-01-01 00:00:00', "
                        + "`test_devtype` INT NOT NULL DEFAULT 0, "
                        + "`record_time` DATETIME NOT NULL DEFAULT '1982-01-01 00:00:00', "
                        + "`group_vol` FLOAT NOT NULL DEFAULT 0, "
                        + "`test_curr` FLOAT NOT NULL DEFAULT 0, "
                        + "`upload_usr_id` INT NOT NULL DEFAULT 0, "
                        + "`upload_client_type` INT NOT NULL DEFAULT 0, "
                        + "INDEX index_battgroup_id (`BattGroupId`), "
                        + "INDEX index_test_record_count (`test_record_count`), "
                        + "INDEX index_test_starttime (`test_starttime`), "
                        + "PRIMARY KEY (`num`)) "
                        + "ENGINE=InnoDB DEFAULT CHARSET=utf8;";
        String table_6 = "DROP TABLE IF EXISTS " + SocketClientStateTable + "; ";
        String table_7 = "CREATE TABLE IF NOT EXISTS " + SocketClientStateTable
                        + "(`num` BIGINT NOT NULL AUTO_INCREMENT, "
                        + "`uId` INT NOT NULL DEFAULT 0, "
                        + "`client_type` INT NOT NULL DEFAULT 0, "
                        + "`client_id` BIGINT NOT NULL DEFAULT 0, "
                        + "`BattGroupId` INT NOT NULL DEFAULT 0, "
                        + "`client_is_connected` BOOLEAN NOT NULL DEFAULT false, "
                        + "`client_ip` VARCHAR(64) NOT NULL DEFAULT ' ', "
                        + "`client_conn_time` DATETIME NOT NULL DEFAULT '1980-01-01', "
                        + "`client_disconn_time` DATETIME NOT NULL DEFAULT '1980-01-01', "
                        + "INDEX index_user_id (`uId`), "
                        + "INDEX index_client_type (`client_type`), "
                        + "PRIMARY KEY (`num`)) "
                        + "ENGINE=MEMORY DEFAULT CHARSET=utf8;";
        String table_8 = "CREATE TABLE IF NOT EXISTS " + FBSDevStateChangeInf_Table
                        + "(`num` BIGINT NOT NULL AUTO_INCREMENT, "
                        + "`dev_id` INT NOT NULL DEFAULT 0, "
                        + "`rec_time` DATETIME NOT NULL DEFAULT '1980-01-01', "
                        + "`last_stat` INT NOT NULL DEFAULT 0, "
                        + "`now_stat` INT NOT NULL DEFAULT 0, "
                        + "`state_change_reason` INT NOT NULL DEFAULT 0, "
                        + "`dev_alarm` INT NOT NULL DEFAULT 0, "
                        + "INDEX index_dev_id (`dev_id`), "
                        + "PRIMARY KEY (`num`)) "
                        + "ENGINE=InnoDB DEFAULT CHARSET=utf8;";
        String table_9 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.BTSStationEvent_Table
                        + " ( `num` BIGINT NOT NULL AUTO_INCREMENT, "
                        + "`station_id` BIGINT NOT NULL DEFAULT 0, "
                        + "`dev_id` BIGINT NOT NULL DEFAULT 0, "
                        + "`record_datetime` varchar(20) NOT NULL DEFAULT '2015-12-02 12:10:00', "
                        + "`station_event_type` INT NOT NULL DEFAULT 0, "
                        + "`station_event_trig` INT NOT NULL DEFAULT 0, "
                        + " INDEX index_dev_id (`dev_id`), "
                        + " INDEX index_station_id (`station_id`), "
                        + " PRIMARY KEY (`num`) ) "
                        + " ENGINE=InnoDB DEFAULT CHARSET=utf8";
        //-------------------------------------------------------------------------------------//
        //-------------------------------------------------------------------------------------//
        sqlMysqlUseDB(Sql_Mysql.DB_AppSys);
        if(false == sqlMysqlCheckIfTableExist(TB_AppSys))
        {
            sqlMysqlExecute(table_0);
            sqlMysqlExecute("INSERT INTO " + Sql_Mysql.AppSys_Table
                                + " (AppName) VALUES ('蓄电池组综合管理系统')");
        }
        //-------------------------------------------------------------------------------------//
        {
            ResultSet rest = sqlMysqlQuery("SELECT AppServer_Version FROM " + Sql_Mysql.AppSys_Table);
            if(rest.next()) {
                float ser_version = rest.getFloat(1);
                if(ser_version < 1.387) {
                    sqlMysqlExecute("UPDATE " + Sql_Mysql.AppSys_Table + " SET AppServer_Version=1.388");
                    sqlMysqlExecute("USE db_batt_testdata");
                    sqlMysqlExecute("UPDATE tb_batttestdata_inf SET "
                                    + " test_starttime=date_sub(test_starttime, interval 1 month) "
                                    + " WHERE upload_usr_id>0");
                }
            }
        }
        //---------------------------------------------------------------------------------------------//
            ResultSet res0 = sqlMysqlQuery("SELECT * FROM information_schema.columns"
                                    + " WHERE table_schema='db_app_sys'"
                                    + " AND table_name='tb_app_sys'"
                                    + " AND column_name='SqlDB_BackUpTime'");
            if(false == res0.next()) {
                sqlMysqlExecute("ALTER TABLE " + AppSys_Table
                                + " ADD COLUMN `SqlDB_BackUpTime` DATETIME NOT NULL DEFAULT '2000-1-1 00:00:00'"
                                + " AFTER `SqlDB_Version`,"
                                + " ADD COLUMN `SqlDB_BackUpManual_EN` BOOLEAN NOT NULL DEFAULT false"
                                + " AFTER `SqlDB_BackUpTime`");
            }
            res0 = sqlMysqlQuery("SELECT * FROM information_schema.columns"
                                + " WHERE table_schema='db_app_sys'"
                                + " AND table_name='tb_app_sys'"
                                + " AND column_name='SqlDB_BackUpManual_EN'");
            if(false == res0.next()) {
                sqlMysqlExecute("ALTER TABLE " + AppSys_Table
                                + " ADD COLUMN `SqlDB_BackUpManual_EN` BOOLEAN NOT NULL DEFAULT false"
                                + " AFTER `SqlDB_BackUpTime`");
            }
            /**************************** db_app_sys 表中添加 AppServer_Reinit_BattGroupData_EN列(重新载入电池组信息) *******************************************/
            res0 = sqlMysqlQuery("SELECT * FROM information_schema.columns"
                    + " WHERE table_schema='db_app_sys'"
                    + " AND table_name='tb_app_sys'"
                    + " AND column_name='AppServer_Reinit_BattGroupData_EN'");
            if(false == res0.next()) {
            sqlMysqlExecute("ALTER TABLE " + AppSys_Table
                            + " ADD COLUMN `AppServer_Reinit_BattGroupData_EN` BOOLEAN NOT NULL DEFAULT false"
                            + " AFTER `SqlDB_BackUpManual_EN`");
            }
            /**************************** db_app_sys 表中添加 AppServer_Reinit_BattGroupData_EN 列(用于主程序动态调整运行参数) *******************************************/
            res0 = sqlMysqlQuery("SELECT * FROM information_schema.columns"
                    + " WHERE table_schema='db_app_sys'"
                    + " AND table_name='tb_app_sys'"
                    + " AND column_name='AppServer_Reinit_Config_EN'");
            if(false == res0.next()) {
            sqlMysqlExecute("ALTER TABLE " + AppSys_Table
                            + " ADD COLUMN `AppServer_Reinit_Config_EN` BOOLEAN NOT NULL DEFAULT false"
                            + " AFTER `AppServer_Reinit_BattGroupData_EN`");
            }
            /**************************** db_app_sys 表中添加 AppServer_Reinit_BattGroupData_LD9_EN 列(用于LD9主程序动态加载设备参数) *******************************************/
            res0 = sqlMysqlQuery("SELECT * FROM information_schema.columns"
                    + " WHERE table_schema='db_app_sys'"
                    + " AND table_name='tb_app_sys'"
                    + " AND column_name='AppServer_Reinit_BattGroupData_LD9_EN'");
            if(false == res0.next()) {
            sqlMysqlExecute("ALTER TABLE " + AppSys_Table
                            + " ADD COLUMN `AppServer_Reinit_BattGroupData_LD9_EN` BOOLEAN NOT NULL DEFAULT false"
                            + " AFTER `AppServer_Reinit_BattGroupData_EN`");
            }
        //---------------------------------------------------------------------------------------------//
        sqlMysqlExecute(table_1);
        sqlMysqlExecute(table_2);
        sqlMysqlExecute(table_3);
        sqlMysqlExecute(table_3_1);
        sqlMysqlExecute(table_3_2);
        sqlMysqlExecute(table_3_2_1);
        sqlMysqlExecute(table_4);
        sqlMysqlExecute(table_5);
        sqlMysqlExecute(table_6);
        sqlMysqlExecute(table_7);
        sqlMysqlExecute(table_8);
        sqlMysqlExecute(table_9);
        //---------------------------------------------------------------------------------------------//
        ResultSet res = sqlMysqlQuery("show index from " + BattInf_Table + " where column_name='BattGroupId'");
        if(false == res.next())
        {
            sqlMysqlExecute("ALTER TABLE " + BattInf_Table + " ADD INDEX `index_station_id` (`StationId` ASC);");
            sqlMysqlExecute("ALTER TABLE " + BattInf_Table + " ADD INDEX `index_battgroup_id` (`BattGroupId` ASC);");
            sqlMysqlExecute("ALTER TABLE " + BattInf_Table + " ADD INDEX `index_station_name` (`StationName` ASC);");
            sqlMysqlExecute("ALTER TABLE " + BattInf_Table + " ADD INDEX `index_battgroup_name` (`BattGroupName` ASC);");
        }
        //---------------------------------------------------------------------------------------------//
                //-------------------------------- 2017-06-06 by mxpopstar ------------------------------------//
                        res = sqlMysqlQuery("SELECT * FROM information_schema.columns"
                                                + " WHERE table_schema='db_battinf'"
                                                + " AND table_name='tb_battinf'"
                                                + " AND column_name='BattGuarantDayCount'");
                        if(false == res.next()) {
                            sqlMysqlExecute("ALTER TABLE " + BattInf_Table
                                            + " ADD COLUMN `BattGuarantDayCount` INT NOT NULL DEFAULT 1095 AFTER `BattInUseDate`");
                        }
                //---------------------------------------------------------------------------------------------//
                //-------------------------------- 2018-10-12 by lijun   (  binf表中添加   Load_curr->负载电流        disCurrMax -> 最大核容电流   )------------------------------------//
                        res = sqlMysqlQuery("SELECT * FROM information_schema.columns"
                                                + " WHERE table_schema='db_battinf'"
                                                + " AND table_name='tb_battinf'"
                                                + " AND column_name='Load_curr'");
                        if(false == res.next()) {
                            sqlMysqlExecute("ALTER TABLE " + BattInf_Table
                                            + " ADD COLUMN `Load_curr` float NOT NULL DEFAULT 15");
                        }
                        res = sqlMysqlQuery("SELECT * FROM information_schema.columns"
                                + " WHERE table_schema='db_battinf'"
                                + " AND table_name='tb_battinf'"
                                + " AND column_name='disCurrMax'");
                        if(false == res.next()) {
                            sqlMysqlExecute("ALTER TABLE " + BattInf_Table
                                            + " ADD COLUMN `disCurrMax` float NOT NULL DEFAULT 0");
                        }
                //-------------------------------- 2018-10-16 by lijun   (  binf表中添加   station_phone->基站手机号 )------------------------------------//
                        res = sqlMysqlQuery("SELECT * FROM information_schema.columns"
                                + " WHERE table_schema='db_battinf'"
                                + " AND table_name='tb_battinf'"
                                + " AND column_name='station_phone'");
                        if(false == res.next()) {
                            sqlMysqlExecute("ALTER TABLE " + BattInf_Table
                                            + " ADD COLUMN `station_phone` varchar(32) DEFAULT ''");
                        }
                //---------------------------------------------------------------------------------------------//
                //-------------------------------- 2018-10-16 by lijun   (  binf表中添加   station_install->标识机房是否已经安装 )------------------------------------//
                        res = sqlMysqlQuery("SELECT * FROM information_schema.columns"
                                + " WHERE table_schema='db_battinf'"
                                + " AND table_name='tb_battinf'"
                                + " AND column_name='station_install'");
                        if(false == res.next()) {
                            sqlMysqlExecute("ALTER TABLE " + BattInf_Table
                                            + " ADD COLUMN `station_install` BOOLEAN NOT NULL DEFAULT false");
                        }
                //---------------------------------------------------------------------------------------------//
                //-------------------------------- 2018-11-29 by lijun   (  binf表中添加   StationId_ex->基站站址编号   install_user-->安装人)------------------------------------//
                        res = sqlMysqlQuery("SELECT * FROM information_schema.columns"
                                + " WHERE table_schema='db_battinf'"
                                + " AND table_name='tb_battinf'"
                                + " AND column_name='StationId_ex'");
                        if(false == res.next()) {
                            sqlMysqlExecute("ALTER TABLE " + BattInf_Table
                                            + " ADD COLUMN `StationId_ex` varchar(20) DEFAULT '' AFTER StationId");
                        }
                        res = sqlMysqlQuery("SELECT * FROM information_schema.columns"
                                + " WHERE table_schema='db_battinf'"
                                + " AND table_name='tb_battinf'"
                                + " AND column_name='install_user'");
                        if(false == res.next()) {
                            sqlMysqlExecute("ALTER TABLE " + BattInf_Table
                                    + " ADD COLUMN `install_user` varchar(64) DEFAULT ''");
                        }
                //---------------------------------------------------------------------------------------------//
                //-------------------------------- 2018-12-12 by lijun   (  binf表中添加  charge_curr_max  最大充电电流)------------------------------------//
                        res = sqlMysqlQuery("SELECT * FROM information_schema.columns"
                                + " WHERE table_schema='db_battinf'"
                                + " AND table_name='tb_battinf'"
                                + " AND column_name='charge_curr_max'");
                        if(false == res.next()) {
                            sqlMysqlExecute("ALTER TABLE " + BattInf_Table
                                            + " ADD COLUMN `charge_curr_max` float DEFAULT '20'");
                        }
                 //---------------------------------------------------------------------------------------------//
                        //为紫晶南网平台添加指定的列
                        boolean isZijing = true;
                        if(isZijing) {
                            //添加电压等级列
                            res = sqlMysqlQuery("SELECT * FROM information_schema.columns"
                                    + " WHERE table_schema='db_battinf'"
                                    + " AND table_name='tb_battinf'"
                                    + " AND column_name='Vol_grade'");
                            if(false == res.next()) {
                                sqlMysqlExecute("ALTER TABLE " + BattInf_Table
                                                + " ADD COLUMN `Vol_grade` float DEFAULT '0'");
                            }
                            //生产厂家
                            res = sqlMysqlQuery("SELECT * FROM information_schema.columns"
                                    + " WHERE table_schema='db_battinf'"
                                    + " AND table_name='tb_battinf'"
                                    + " AND column_name='Manufacturers'");
                            if(false == res.next()) {
                                sqlMysqlExecute("ALTER TABLE " + BattInf_Table
                                                + " ADD COLUMN `Manufacturers` varchar(64) DEFAULT ''");
                            }
                            //是否资产级设备
                            res = sqlMysqlQuery("SELECT * FROM information_schema.columns"
                                    + " WHERE table_schema='db_battinf'"
                                    + " AND table_name='tb_battinf'"
                                    + " AND column_name='Assetequipment'");
                            if(false == res.next()) {
                                sqlMysqlExecute("ALTER TABLE " + BattInf_Table
                                                + " ADD COLUMN `Assetequipment` varchar(64) DEFAULT ''");
                            }
                            //设备分类全路径
                            res = sqlMysqlQuery("SELECT * FROM information_schema.columns"
                                    + " WHERE table_schema='db_battinf'"
                                    + " AND table_name='tb_battinf'"
                                    + " AND column_name='Deviceclasspath'");
                            if(false == res.next()) {
                                sqlMysqlExecute("ALTER TABLE " + BattInf_Table
                                                + " ADD COLUMN `Deviceclasspath` varchar(64) DEFAULT ''");
                            }
                            //设备运维部门
                            res = sqlMysqlQuery("SELECT * FROM information_schema.columns"
                                    + " WHERE table_schema='db_battinf'"
                                    + " AND table_name='tb_battinf'"
                                    + " AND column_name='Deviceoperationdepartment'");
                            if(false == res.next()) {
                                sqlMysqlExecute("ALTER TABLE " + BattInf_Table
                                                + " ADD COLUMN `DeviceOperationDepartment` varchar(64) DEFAULT ''");
                            }
                            //产权单位
                            res = sqlMysqlQuery("SELECT * FROM information_schema.columns"
                                    + " WHERE table_schema='db_battinf'"
                                    + " AND table_name='tb_battinf'"
                                    + " AND column_name='PropertyRightUnit'");
                            if(false == res.next()) {
                                sqlMysqlExecute("ALTER TABLE " + BattInf_Table
                                                + " ADD COLUMN `PropertyRightUnit` varchar(64) DEFAULT ''");
                            }
                            //产权属性
                            res = sqlMysqlQuery("SELECT * FROM information_schema.columns"
                                    + " WHERE table_schema='db_battinf'"
                                    + " AND table_name='tb_battinf'"
                                    + " AND column_name='PropertyAttribute'");
                            if(false == res.next()) {
                                sqlMysqlExecute("ALTER TABLE " + BattInf_Table
                                                + " ADD COLUMN `PropertyAttribute` varchar(64) DEFAULT ''");
                            }
                            //出厂编号
                            res = sqlMysqlQuery("SELECT * FROM information_schema.columns"
                                    + " WHERE table_schema='db_battinf'"
                                    + " AND table_name='tb_battinf'"
                                    + " AND column_name='FactoryNumber'");
                            if(false == res.next()) {
                                sqlMysqlExecute("ALTER TABLE " + BattInf_Table
                                                + " ADD COLUMN `FactoryNumber` varchar(64) DEFAULT ''");
                            }
                            //运维班组
                            res = sqlMysqlQuery("SELECT * FROM information_schema.columns"
                                    + " WHERE table_schema='db_battinf'"
                                    + " AND table_name='tb_battinf'"
                                    + " AND column_name='OperationTeam'");
                            if(false == res.next()) {
                                sqlMysqlExecute("ALTER TABLE " + BattInf_Table
                                                + " ADD COLUMN `OperationTeam` varchar(64) DEFAULT ''");
                            }
                            //设备身份编码
                            res = sqlMysqlQuery("SELECT * FROM information_schema.columns"
                                    + " WHERE table_schema='db_battinf'"
                                    + " AND table_name='tb_battinf'"
                                    + " AND column_name='DeviceIdentityCode'");
                            if(false == res.next()) {
                                sqlMysqlExecute("ALTER TABLE " + BattInf_Table
                                                + " ADD COLUMN `DeviceIdentityCode` varchar(64) DEFAULT ''");
                            }
                            //项目类型
                            res = sqlMysqlQuery("SELECT * FROM information_schema.columns"
                                    + " WHERE table_schema='db_battinf'"
                                    + " AND table_name='tb_battinf'"
                                    + " AND column_name='ProjectType'");
                            if(false == res.next()) {
                                sqlMysqlExecute("ALTER TABLE " + BattInf_Table
                                                + " ADD COLUMN `ProjectType` varchar(64) DEFAULT ''");
                            }
                            //蓄电池应用类型
                            res = sqlMysqlQuery("SELECT * FROM information_schema.columns"
                                    + " WHERE table_schema='db_battinf'"
                                    + " AND table_name='tb_battinf'"
                                    + " AND column_name='BatteryApplicationType'");
                            if(false == res.next()) {
                                sqlMysqlExecute("ALTER TABLE " + BattInf_Table
                                                + " ADD COLUMN `BatteryApplicationType` varchar(64) DEFAULT ''");
                            }
                            //单电池额定电压
                            res = sqlMysqlQuery("SELECT * FROM information_schema.columns"
                                    + " WHERE table_schema='db_battinf'"
                                    + " AND table_name='tb_battinf'"
                                    + " AND column_name='SingleRatedVoltage'");
                            if(false == res.next()) {
                                sqlMysqlExecute("ALTER TABLE " + BattInf_Table
                                                + " ADD COLUMN `SingleRatedVoltage` float DEFAULT '0'");
                            }
                            //是否实现远程监控
                            res = sqlMysqlQuery("SELECT * FROM information_schema.columns"
                                    + " WHERE table_schema='db_battinf'"
                                    + " AND table_name='tb_battinf'"
                                    + " AND column_name='RemoteMonitor'");
                            if(false == res.next()) {
                                sqlMysqlExecute("ALTER TABLE " + BattInf_Table
                                                + " ADD COLUMN `RemoteMonitor` varchar(64) DEFAULT ''");
                            }
                            //是否独立蓄电池室放置
                            res = sqlMysqlQuery("SELECT * FROM information_schema.columns"
                                    + " WHERE table_schema='db_battinf'"
                                    + " AND table_name='tb_battinf'"
                                    + " AND column_name='BatttIndependentPlaced'");
                            if(false == res.next()) {
                                sqlMysqlExecute("ALTER TABLE " + BattInf_Table
                                                + " ADD COLUMN `BatttIndependentPlaced` varchar(64) DEFAULT ''");
                            }
                            //均充电压设定值
                            res = sqlMysqlQuery("SELECT * FROM information_schema.columns"
                                    + " WHERE table_schema='db_battinf'"
                                    + " AND table_name='tb_battinf'"
                                    + " AND column_name='JunChargeVoltageValue'");
                            if(false == res.next()) {
                                sqlMysqlExecute("ALTER TABLE " + BattInf_Table
                                                + " ADD COLUMN `JunChargeVoltageValue` float DEFAULT '0'");
                            }
                            //公钥X
                            res = sqlMysqlQuery("SELECT * FROM information_schema.columns"
                                    + " WHERE table_schema='db_battinf'"
                                    + " AND table_name='tb_battinf'"
                                    + " AND column_name='PublicKeyX'");
                            if(false == res.next()) {
                                sqlMysqlExecute("ALTER TABLE " + BattInf_Table
                                                + " ADD COLUMN `PublicKeyX` varchar(200) NOT NULL DEFAULT ''");
                            }
                            //公钥Y
                            res = sqlMysqlQuery("SELECT * FROM information_schema.columns"
                                    + " WHERE table_schema='db_battinf'"
                                    + " AND table_name='tb_battinf'"
                                    + " AND column_name='PublicKeyY'");
                            if(false == res.next()) {
                                sqlMysqlExecute("ALTER TABLE " + BattInf_Table
                                                + " ADD COLUMN `PublicKeyY` varchar(200) NOT NULL DEFAULT ''");
                            }
                            //KeyID
                            res = sqlMysqlQuery("SELECT * FROM information_schema.columns"
                                    + " WHERE table_schema='db_battinf'"
                                    + " AND table_name='tb_battinf'"
                                    + " AND column_name='KeyID'");
                            if(false == res.next()) {
                                sqlMysqlExecute("ALTER TABLE " + BattInf_Table
                                                + " ADD COLUMN `KeyID` varchar(200) NOT NULL DEFAULT ''");
                            }
                            //唯一索引
                            res = sqlMysqlQuery("SELECT * FROM information_schema.columns"
                                    + " WHERE table_schema='db_battinf'"
                                    + " AND table_name='tb_battinf'"
                                    + " AND column_name='SerialNumber'");
                            if(false == res.next()) {
                                sqlMysqlExecute("ALTER TABLE " + BattInf_Table
                                                + " ADD COLUMN `SerialNumber` varchar(200) NOT NULL DEFAULT ''");
                            }
                        }
        //---------------------------------------------------------------------------------------------//
        res = sqlMysqlQuery("SELECT * FROM information_schema.columns"
                                + " WHERE table_schema='db_battinf'"
                                + " AND table_name='tb_batt_maint_inf'"
                                + " AND column_name='master_audit'");
        if(false == res.next()) {
            sqlMysqlExecute("ALTER TABLE " + BattMainInf_Table
                            + " ADD COLUMN `fault_type_id` INT NOT NULL DEFAULT 0 AFTER `usr_id`,"
                            + " ADD COLUMN `maint_type_id` INT NOT NULL DEFAULT 0 AFTER `maint_time_limit`,"
                            + " ADD COLUMN `master_audit` INT NOT NULL DEFAULT 0 AFTER `master_id`,"
                            + " ADD COLUMN `maint_close` BOOLEAN NOT NULL DEFAULT FALSE AFTER `maint_done_time`,"
                            + " ADD COLUMN `appoint_uid` INT NOT NULL DEFAULT 0 AFTER `master_audit`,"
                            + " ADD COLUMN `copy_uids` VARCHAR(200) NOT NULL DEFAULT ' ' AFTER `master_audit`");
        }
        //---------------------------------------------------------------------------------------------//
        //---------------------------------------------------------------------------------------------//
        res = sqlMysqlQuery("show index from " + BattTestDataInf_Table + " where column_name='test_starttime'");
        if(false == res.next())
        {
            sqlMysqlExecute("ALTER TABLE " + BattTestDataInf_Table + " ADD INDEX `index_test_record_count` (`test_record_count` ASC);");
            sqlMysqlExecute("ALTER TABLE " + BattTestDataInf_Table + " ADD INDEX `index_test_type` (`test_type` ASC);");
            sqlMysqlExecute("ALTER TABLE " + BattTestDataInf_Table + " ADD INDEX `index_test_starttime` (`test_starttime` ASC);");
        }
        //---------------------------------------------------------------------------------------------//
        //---------------------------------------------------------------------------------------------//
        res = sqlMysqlQuery("show index from " + BattResDataInf_Table + " where column_name='test_starttime'");
        if(false == res.next())
        {
            sqlMysqlExecute("ALTER TABLE " + BattResDataInf_Table + " ADD INDEX `index_test_record_count` (`test_record_count` ASC);");
            sqlMysqlExecute("ALTER TABLE " + BattResDataInf_Table + " ADD INDEX `index_test_type` (`test_type` ASC);");
            sqlMysqlExecute("ALTER TABLE " + BattResDataInf_Table + " ADD INDEX `index_test_starttime` (`test_starttime` ASC);");
        }
        //---------------------------------------------------------------------------------------------//
        res = sqlMysqlQuery("SELECT * FROM information_schema.columns"
                                        + " WHERE table_schema='db_batt_testdata'"
                                        + " AND table_name='tb_batttestdata_inf'"
                                        + " AND column_name='test_record_count_ex'");
        if(false == res.next())
        {
            sqlMysqlExecute("ALTER TABLE " + BattTestDataInf_Table
                            + " ADD COLUMN `test_record_count_ex` INT NOT NULL DEFAULT 0 AFTER `test_record_count`,"
                            + " ADD COLUMN `test_starttime_ex` DATETIME NOT NULL DEFAULT '1920-01-01 00:00:00' AFTER `test_starttime`,"
                            + " ADD COLUMN `upload_usr_id` INT NOT NULL DEFAULT 0 AFTER `mon_vol`");
        }
        //---------------------------------------------------------------------------------------------//
        //---------------------------------------------------------------------------------------------//
        res = sqlMysqlQuery("SELECT * FROM information_schema.columns"
                                                + " WHERE table_schema='db_batt_testdata'"
                                                + " AND table_name='tb_batttestdata_inf'"
                                                + " AND column_name='upload_data_ext'");
        if(false == res.next())
        {
            sqlMysqlExecute("ALTER TABLE " + BattTestDataInf_Table
                            + " ADD COLUMN `upload_data_ext` INT NOT NULL DEFAULT 0 AFTER `upload_usr_id`,"
                            + " ADD COLUMN `upload_client_type` INT NOT NULL DEFAULT 0 AFTER `upload_data_ext`");
            sqlMysqlExecute("ALTER TABLE " + BattResDataInf_Table
                            + " ADD COLUMN `upload_client_type` INT NOT NULL DEFAULT 0 AFTER `upload_usr_id`");
        }
        //---------------------------------------------------------------------------------------------//
        //----------------------------将num自增字段改为bigint类型---------------------------------------//
        res = sqlMysqlQuery("SELECT DATA_TYPE FROM information_schema.columns"
                                        + " WHERE table_schema='db_batt_testdata'"
                                        + " AND table_name='tb_batttestdata_inf'"
                                        + " AND column_name='num'");
        if(true == res.next()) {
            if(false == "bigint".equals(res.getString("DATA_TYPE").toLowerCase())) {
                sqlMysqlExecute("ALTER TABLE " + BattTestDataInf_Table + " MODIFY COLUMN num BIGINT NOT NULL AUTO_INCREMENT;");
                sqlMysqlExecute("ALTER TABLE " + BattResDataInf_Table + " MODIFY COLUMN num BIGINT NOT NULL AUTO_INCREMENT;");
            }
        }
        //---------------------------------------------------------------------------------------------//
        //-----------------------------  tb_fbsdev_statechange_inf 表中新增2个字段  ----------------------------------------------------------------//
        res = sqlMysqlQuery("SELECT DATA_TYPE FROM information_schema.columns"
                + " WHERE table_schema='db_app_sys'"
                + " AND table_name='tb_fbsdev_statechange_inf'"
                + " AND column_name='eve_type'");
        if(false == res.next()) {
            sqlMysqlExecute("ALTER TABLE " + FBSDevStateChangeInf_Table
                    + " ADD COLUMN `eve_type` int DEFAULT 0;");
        }
        res = sqlMysqlQuery("SELECT DATA_TYPE FROM information_schema.columns"
                + " WHERE table_schema='db_app_sys'"
                + " AND table_name='tb_fbsdev_statechange_inf'"
                + " AND column_name='module_num'");
        if(false == res.next()) {
            sqlMysqlExecute("ALTER TABLE " + FBSDevStateChangeInf_Table
                    + " ADD COLUMN `module_num` int DEFAULT 0;");
        }
    }
    //使用db数据库
    public void sqlMysqlUseDB(String db) throws SQLException
    {
        sqlMysqlExecute("use " + db);
    }
    //获取电池组机房的个数
    public int getBattStationCount()
    {
        int st_count = 0;
        try {
            sqlMysqlUseDB(Sql_Mysql.DB_BATT_INF);
            String sql_str = "SELECT DISTINCT StationId FROM " + BattInf_Table;
            ResultSet res = sqlMysqlQuery(sql_str);
            while(res.next())
            {
                st_count++;
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return st_count;
    }
    /**
     * 检查tb表是否存在
     * @param tb
     * @return
     * @throws SQLException
     */
    public boolean sqlMysqlCheckIfTableExist(String tb) throws SQLException
    {
        String sql_str = "SHOW TABLES LIKE '" + tb + "'";
        ResultSet res = sqlMysqlQuery(sql_str);
        boolean exist = false;
        while(res.next())
        {
            exist = true;
            break;
        }
        return exist;
    }
    //执行sql语句
    public void sqlMysqlExecute(String sql_str) throws SQLException
    {
        Statement sql = mysql_con.createStatement();
        sql.setQueryTimeout(30);
        sql.execute(sql_str);
    }
    //在事物中执行多条sql语句
    public boolean makeManualCommit(ArrayList<String> al_sql_strs)
    {
        boolean exe_res = true;
        try {
            mysql_con.setAutoCommit(false);
            for(int n=0; n<al_sql_strs.size(); n++) {
                sqlMysqlExecute(al_sql_strs.get(n));
            }
            if(true == exe_res) {
                mysql_con.commit();
            }
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            exe_res = false;
        } finally {
            try {
                if(false == exe_res) {
                    mysql_con.rollback();
                }
                mysql_con.setAutoCommit(true);
            } catch (SQLException e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
            }
        }
        return exe_res;
    }
    //根据sql语句执行sql查询语句
    public ResultSet sqlMysqlQuery(String sql_str)
    {
        ResultSet res = null;
        try
        {
            Statement sql = mysql_con.createStatement();
            sql.setQueryTimeout(30);
            String query = sql_str;
            res =  sql.executeQuery(query);
        }
        catch(SQLException ex)
        {
            System.err.println("SQLException:" + ex.getMessage());
        }
        return res;
    }
    //根据sql语句执行sql更新语句
    public void sqlMysqlUpdate(String sql_str)
    {
        try
        {
            Statement sql = mysql_con.createStatement();
            sql.setQueryTimeout(30);
            String query = sql_str;
            sql.execute(query);
        }
        catch(SQLException ex)
        {
            System.out.println("SQLException:" + ex.getMessage());
        }
    }
    //根据电池组id 获取机房名称
    public String getStationName(int bg_id)
    {
        String stname = " ";
        String sql_str = "SELECT DISTINCT StationName FROM "
                            + Sql_Mysql.BattInf_Table + " WHERE BattGroupId=" + bg_id;
        ResultSet res = sqlMysqlQuery(sql_str);
        try {
            if(res.next())
            {
                stname = res.getString("StationName");
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return stname;
    }
    //根据电池组id 获取电池组名称
    public String getBattGroupName(int bg_id)
    {
        String bgname = " ";
        String sql_str = "SELECT DISTINCT BattGroupName FROM "
                            + Sql_Mysql.BattInf_Table + " WHERE BattGroupId=" + bg_id;
        ResultSet res = sqlMysqlQuery(sql_str);
        try {
            if(res.next())
            {
                bgname = res.getString("BattGroupName");
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return bgname;
    }
    //根据用户的id获取用户的名称
    public String getUsrName(int uid)
    {
        String usrname = " ";
        String sql_str = "SELECT uName FROM " + Sql_Mysql.UserInfTable + " WHERE uId=" + uid;
        ResultSet res = sqlMysqlQuery(sql_str);
        try {
            if(res.next())
            {
                usrname = res.getString("uName");
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return usrname;
    }
    //根据format_type 获取format_str 的样式
    public String getTaskSmsFormatStr(String format_type)
    {
        String str = "";
        String sql_str = "SELECT DISTINCT "
                        + Sql_Mysql.UserSmsFormatTable + ".format_str"
                        + " FROM " + Sql_Mysql.UserSmsFormatTable
                        + " WHERE "
                        + Sql_Mysql.UserSmsFormatTable + ".format_type='" + format_type + "'";
        ResultSet sql_res = sqlMysqlQuery(sql_str);
        try {
            if(sql_res.next())
            {
                str = sql_res.getString("format_str");
            }
        } catch (SQLException e1) {
            // TODO Auto-generated catch block
            //e1.printStackTrace();
        }
        return str;
    }
    //根据作业id获取作业的名称
    public String getUsrTaskName(int taskid)
    {
        String taskname = " ";
        String sql_str = "SELECT task_name FROM " + Sql_Mysql.UserTaskTable + " WHERE task_id=" + taskid;
        ResultSet res = sqlMysqlQuery(sql_str);
        try {
            if(res.next()) {
                taskname = res.getString("task_name");
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return taskname;
    }
    //根据作业id获取用户作业的创建时间
    public String getUsrTaskCreateTime(int taskid)
    {
        String taskcreatetime = " ";
        String sql_str = "SELECT task_create_date FROM " + Sql_Mysql.UserTaskTable + " WHERE task_id=" + taskid;
        ResultSet res = sqlMysqlQuery(sql_str);
        try {
            if(res.next())
            {
                taskcreatetime = Com.getDateTimeFormat(res.getTimestamp("task_create_date"), Com.DTF_YMDhms);
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return taskcreatetime;
    }
    //获取新创建的记录的testrecordcount的值
    public int getBattTestRecordCountNew(int bg_id, String table)
    {
        int count = 0;
        boolean res_exe = true;
        String sql_str0 = "SELECT test_record_count_ex FROM " + table
                            + " WHERE BattGroupId=" + bg_id  + " FOR UPDATE";
        String sql_str1 = "UPDATE " + table + " SET test_record_count_ex=test_record_count+1"
                            + " WHERE BattGroupId=" + bg_id;
        String sql_str2 = "SELECT MAX(test_record_count_ex) FROM " + table
                            + " WHERE BattGroupId=" + bg_id;
        String sql_str3 = "INSERT INTO " + table + " (BattGroupId,test_record_count, test_record_count_ex) "
                            + " VALUES (" + bg_id + "," + 1 + "," + 1 + ")";
        try {
            mysql_con.setAutoCommit(false);
            ResultSet res = sqlMysqlQuery(sql_str0);
            if(res.next()) {
                sqlMysqlExecute(sql_str1);
                res = sqlMysqlQuery(sql_str2);
                if(res.next()) {
                    count = res.getInt(1);
                }
            } else {
                count = 1;
                sqlMysqlExecute(sql_str3);
            }
            mysql_con.commit();
        } catch (SQLException e) {
            e.printStackTrace();
            res_exe = false;
        } finally {
            if(false == res_exe) {
                try {
                    mysql_con.rollback();
                    mysql_con.setAutoCommit(true);
                } catch (SQLException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
        }
        return count;
    }
}
package com.sql;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import com.base.Com;
/**
 *     创建数据库以及表格
 * @author 军
 *
 */
public class Sql_Mysql
{
    //--------------------------------------------------------------------------------------------//
    final public static String DB_AppSys = "`db_app_sys`";
    final public static String DB_BATT_INF = "`db_battinf`";
    final public static String DB_BATT_TESTDATA = "`db_batt_testdata`";
    final public static String DB_PARAM = "`db_param`";
    final public static String DB_ALARM = "`db_alarm`";
    final public static String DB_USER = "`db_user`";
    final public static String DB_RamDB = "`db_ram_db`";
    final public static String DB_RamDB_BATT_RT = "`db_ram_batt_rt`";
    final public static String WEB_Site = "`web_site`";
    final public static String DB_BATT_HISTORY = "`db_batt_history`";
    final public static String DB_LD9_TESTDATA = "`db_ld9_testdata`";
    final public static String DB_PWRDEV_ALARM = "`db_pwrdev_alarm`";
    final public static String DB_PWRDEV_DATA_RT = "`db_pwrdev_data_rt`";
    final public static String DB_PWRDEV_INF = "`db_pwrdev_inf`";
    final public static String DB_FBO_TESTDATA = "`db_fbo_testdata`";
    //--------------------------------------------------------------------------------------------//
    public final static String TB_HardDevSmsState = "tb_hard_dev_sms_state";
    //--------------------------------------------------------------------------------------------//
    public final static String TB_AppSys = "tb_app_sys";
    public final static String TB_ServerState = "tb_server_state";
    public final static String TB_BattTestDataInf = "tb_batttestdata_inf";
    public final static String TB_BattRtData = "tb_batt_rtdata";
    public final static String TB_BattRtState = "tb_batt_rtstate";
    public final static String TB_UserInf = "tb_user_inf";
    public final static String TB_UserLog = "tb_user_log";
    public final static String TB_UserBattGroup_BaoJiGroup = "tb_user_battgroup_baojigroup";
    public final static String TB_UserBattGroup_BaoJiGroup_BattGroup = "tb_user_battgroup_baojigroup_battgroup";
    public final static String TB_UserBattGroup_BaoJiGroup_Usr = "tb_user_battgroup_baojigroup_usr";
    public final static String TB_UserTaskTemplate = "tb_user_task_batt_template";
    public final static String TB_UserTask = "tb_user_task";
    public final static String TB_UserPaiXiu = "tb_user_paixiu";
    public final static String TB_UserListForTask = "tb_user_task_user_list";
    public final static String TB_UserTaskParam = "tb_user_task_param";
    public final static String TB_UserBattCkeckTask = "tb_user_task_batt_check";
    public final static String TB_UserBattTestTask = "tb_user_task_batt_test";
    public final static String TB_UserBattTaskChange = "tb_user_task_change";
    public final static String TB_UserSms = "tb_user_sms";
    public final static String TB_UserSmsFormat = "tb_user_sms_format";
    public final static String TB_UserPermitGroup = "tb_user_permitgroup";
    public final static String TB_UserPermitGroupData = "tb_user_permitgroup_data";
    public final static String TB_UserJieJiaRi = "tb_user_jiejiari";
    //--------------------------------------------------------------------------------------------//
    //--------------------------------------------------------------------------------------------//
    public final static String CInterfaceState_Table = DB_RamDB + ".`tb_cinterface_state`";
    public final static String FBS9600SetParam_Table = DB_RamDB + ".`tb_fbs9600_setparam`";
    //public final static String FBS9600Param_Table = DB_RamDB + ".`tb_fbs9600_param`";
    //--------------------------------------------------------------------------------------------//
    //--------------------------------------------------------------------------------------------//
    public final static String AppSys_Table = DB_AppSys + ".`tb_app_sys`";
    public final static String FBSDevStateChangeInf_Table = DB_AppSys + ".`tb_fbsdev_statechange_inf`";
    public final static String BattInf_Table = DB_BATT_INF + ".`tb_battinf`";
    public final static String BattCurrInf_Table = DB_BATT_INF + ".`tb_battcurr_inf`";
    public final static String BattMainInf_Table = DB_BATT_INF + ".`tb_batt_maint_inf`";
    public final static String BattMainProcess_Table = DB_BATT_INF + ".`tb_batt_maint_process`";
    public final static String BattTestDataInf_Table = DB_BATT_TESTDATA + ".`tb_batttestdata_inf`";
    public final static String BattResDataInf_Table = DB_BATT_TESTDATA + ".`tb_battresdata_inf`";
    public final static String BattResData_Table = DB_BATT_TESTDATA + ".`tb_BattResData`";
    public final static String UserInfTable = DB_USER + ".`tb_user_inf`";
    public final static String UserLogTable = DB_USER + ".`tb_user_log`";
    public final static String UserBattGroup_BaoJiGroup_Table = DB_USER + ".`tb_user_battgroup_baojigroup`";
    public final static String UserBattGroup_BaoJiGroup_BattGroupTable = DB_USER + ".`tb_user_battgroup_baojigroup_battgroup`";
    public final static String UserBattGroup_BaoJiGroup_UsrTable = DB_USER + ".`tb_user_battgroup_baojigroup_usr`";
    public final static String UserTaskTemplateTable = DB_USER + ".`tb_user_task_batt_template`";
    public final static String UserTaskTable = DB_USER + ".`tb_user_task`";
    public final static String UserPaiXiuTable = DB_USER + ".`tb_user_paixiu`";
    public final static String UserListForTaskTable = DB_USER + ".`tb_user_task_user_list`";
    public final static String UserTaskParamTable = DB_USER + ".`tb_user_task_param`";
    public final static String UserBattCheckTaskTable = DB_USER + ".`tb_user_task_batt_check`";
    public final static String UserBattTestTaskTable = DB_USER + ".`tb_user_task_batt_test`";
    public final static String UserBattTaskChangeTable = DB_USER + ".`tb_user_task_change`";
    public final static String UsrBattMaintCheck_Table = DB_USER + ".`tb_user_battmaint_check`";
    public final static String UsrBattMaintCheckProcess_Table = DB_USER + ".`tb_user_battmaint_check_process`";
    public final static String UserSmsTable = DB_USER + ".`tb_user_sms`";
    public final static String UserSmsFormatTable = DB_USER + ".`tb_user_sms_format`";
    public final static String UserPermitGroupTable = DB_USER + ".`tb_user_permitgroup`";
    public final static String UserPermitGroupDataTable = DB_USER + ".`tb_user_permitgroup_data`";
    public final static String UserJieJiaRiTable = DB_USER + ".`tb_user_jiejiari`";
    public final static String BTSStationEvent_Table = DB_ALARM + ".`tb_bts_station_event`";                            //机房状态历史表
    /**************************** db_ram_db数据库 ***************************************************/
    public final static String SocketClientStateTable = DB_RamDB + ".`tb_socketclient_state`";
    public final static String ServerState_Table = DB_RamDB + ".`tb_server_state`";
    public final static String Ld9_Updatestatue_Table = DB_RamDB + ".`tb_ld9_updatestatue`";
    public final static String Ld9_State_Table = DB_RamDB + ".`tb_ld9_state`";
    public final static String Ld9_Setparam_Table = DB_RamDB + ".`tb_ld9_setparam`";
    public final static String Ld9_Concentratestate_Table = DB_RamDB + ".`tb_ld9_concentratestate`";
    public final static String Ld9_Concentrateparam_Table = DB_RamDB + ".`tb_ld9_concentrateparam`";
    public final static String HardDevSmsState_Table = DB_RamDB + ".`tb_hard_dev_sms_state`";
    public final static String FBS9600State_Table = DB_RamDB + ".`tb_fbs9600_state`";
    public final static String FBS9100_NiBian_State = DB_RamDB + ".tb_fbs9100s_nibian_state";                        //61850离线养护计划参数表
    public final static String FBS9100s_fod_state = DB_RamDB + ".tb_fbs9100s_fod_state";                            //61850除硫状态表
    public final static String FBS9100SetDLParam_Table = DB_RamDB + ".`tb_fbs9100s_fod_param`";                        //61850除硫参数表
    public final static String FBS9100S_DFUState_Table = DB_RamDB + ".`tb_fbs9100s_DFU_state`";
    public final static String FBS9100S_DcDcState_Table = DB_RamDB + ".`tb_fbs9100s_dcdc_state`";
    public final static String FBS9100SysParam_Table = DB_RamDB + ".`tb_fbs9100_sysparam`";                            //系统参数表
    public final static String FBS9100State_Table = DB_RamDB + ".`tb_fbs9100_state`";
    public final static String FBS9100SetParam_Table = DB_RamDB + ".`tb_fbs9100_setparam`";
    public final static String FBS9100_offlineyhplan = DB_RamDB + ".tb_fbs9100_offlineyhplan";                        //61850离线养护计划参数表
    public final static String FBS9100BattParam_Table = DB_RamDB + ".`tb_fbs9100_battparam`";                        //电池组参数表
    public final static String BTSStationState_Table = DB_RamDB + ".`tb_bts_station_state`";                        //机房状态表
    public final static String BTSGPRSState_Table = DB_RamDB + ".`tb_bts_gprs_state`";                                //gprs 信息表
    public final static String BMP7100State_Table = DB_RamDB + ".`tb_bpm7100_state`";
    public final static String BattRtState_Table = DB_RamDB + ".`tb_batt_rtstate`";
    public final static String BattRtData_Table = DB_RamDB + ".`tb_batt_rtdata`";
    public final static String TB_61850_JHState_Table = DB_RamDB +".tb_61850_jhstate";                                //61850均衡61850供电模块信息
    public final static String RamDB_CMCC_POWER_Data = DB_RamDB + ".`cmcc_power_data`";
    public final static String FBS9100_InsulatstateTable = DB_RamDB + ".`tb_fbs9100_insulatstate`";                    //绝缘装置
    public final static String FBS9100_CollectionstateTable = DB_RamDB + ".`tb_fbs9100_collectionstate`";            //汇集装置
    public final static String FBS9100_ChargerstateTable = DB_RamDB + ".`tb_fbs9100_chargerstate`";                    //充电机
    public final static String Tb_Lithium_DataTable = DB_RamDB + ".`tb_lithium_data`";                                //锂电池数据表
    public final static String Tb_Batt_RSAlarm_Table = DB_RamDB + ".`tb_batt_rsalarm`";                                //锂电池数据表
    public final static String Tb_Batt_RTAlarm_Table = DB_RamDB + ".`tb_batt_rtalarm`";                                //锂电池数据表
    public final static String FBS9100s_stemnode_state_Table = DB_RamDB + ".`tb_fbs9100s_stemnode_state`";            //干节点状态表
    public final static String FBS9100s_buscouple_state_Table = DB_RamDB + ".`tb_fbs9100s_buscouple_state`";        //母联开关状态表
    public final static String Fgcd_filedownload_Table = DB_RamDB + ".`tb_fgcd_filedownload`";                        //FGCD充放电一体机控制
    /**************************** db_user数据库 ***************************************************/
    public final static String User_Permitgroup_Table = DB_USER + ".`tb_user_permitgroup`";                                //权限表
    public final static String User_Permitgroup_Data_Table = DB_USER + ".`tb_user_permitgroup_data`";                    //用户权限表
    public final static String User_Task_User_List_Table = DB_USER + ".`tb_user_task_user_list`";                        //
    public final static String User_Task_Template_Table = DB_USER + ".`tb_user_task_template`";                            //
    public final static String User_Task_Param_Table = DB_USER + ".`tb_user_task_param`";                            //
    public final static String User_Task_Change_Table = DB_USER + ".`tb_user_task_change`";                            //
    public final static String User_Task_Batt_Test_Table = DB_USER + ".`tb_user_task_batt_test`";                            //
    public final static String User_Task_Batt_Template_Table = DB_USER + ".`tb_user_task_batt_template`";                            //
    public final static String User_Task_Batt_Check_Table = DB_USER + ".`tb_user_task_batt_check`";                            //
    public final static String User_Task_Table = DB_USER + ".`tb_user_task`";                            //
    public final static String User_Sms_Format_Table = DB_USER + ".`tb_user_sms_format`";                            //
    public final static String User_Sms_Table = DB_USER + ".`tb_user_sms`";                            //
    public final static String User_Paixiu_Table = DB_USER + ".`tb_user_paixiu`";                            //
    public final static String User_Log_Table = DB_USER + ".`tb_user_log`";                            //
    public final static String User_Jiejiari_Table = DB_USER + ".`tb_user_jiejiari`";                            //
    public final static String User_Face_Table = DB_USER + ".`tb_user_face`";                            //
    public final static String User_Battmaint_Check_Process_Table = DB_USER + ".`tb_user_battmaint_check_process`";                            //
    public final static String User_Battmaint_Check_Table = DB_USER + ".`tb_user_battmaint_check`";                            //
    public final static String User_Battgroup_Baojigroup_Usr_Table = DB_USER + ".`tb_user_battgroup_baojigroup_usr`";                            //
    public final static String User_Battgroup_Baojigroup_Battgroup_Table = DB_USER + ".`tb_user_battgroup_baojigroup_battgroup`";                            //
    public final static String User_Battgroup_Baojigroup_Table = DB_USER + ".`tb_user_battgroup_baojigroup`";                            //
    public final static String User_Limit_Table = DB_USER + ".`tb_user_limit`";                            //
    public static final String Tb_User_Work = DB_USER + ".`tb_user_work`";
    public static final String Tb_Work_Alarm = DB_USER + ".`tb_work_alarm`";
    /**************************** web_site数据库 ***************************************************/
    public final static String ThreadUtil_Table = WEB_Site + ".`tb_thread_util`";                        //线程帮助表
    public final static String PositiomapUsr_Table = WEB_Site + ".`tb_positiomap_usr`";                    //首页地图中心点定位表
    public final static String ChartColor_Table = WEB_Site + ".`tb_chart_color`";                        //用户实时监测页面指定柱状的颜色设置表
    public final static String UserChart_Table = WEB_Site + ".`tb_user_chart`";                            //班组管理表
    public final static String ProcessSurvey_Table = WEB_Site + ".`tb_process_survey`";                    //线程监控表
    public final static String EchartsUsr_Table = WEB_Site + ".`tb_echarts_usr`";                        //用户首页定制表
    public final static String DevstateUsr_Table = WEB_Site + ".`tb_devstate_usr`";                        //用户放电添加记录表
    public final static String CustomPage_Table = WEB_Site + ".`tb_custompage`";                        //导航数据表
    public final static String Announce_Table = WEB_Site + ".`tb_announce`";                            //公告表
    public final static String BattAttention_Table = WEB_Site + ".`tb_batt_attention`";                    //创建电池组单体关注表
    public final static String BattpowerOff_Table = WEB_Site + ".`tb_battpower_off`";                    //机房停电表
    public final static String BadbattMon_Table = WEB_Site + ".`tb_badbatt_mon`";                        //落后单体表
    public final static String BadbattMonFlag_Table = WEB_Site + ".`tb_badbatt_mon_flag`";                //落后单体控制表
    public final static String BattEndurance_Table = WEB_Site + ".`tb_batt_endurance`";                    //机房续航表
    public final static String BattParamLow_Table = WEB_Site + ".`tb_batt_param_low`";                    //电池参数表
    public final static String BattDischargeParam_Table = WEB_Site + ".`tb_battdischarge_param`";        //放电计划参数表
    public final static String BattDischargePlan_Table = WEB_Site + ".`tb_battdischarge_plan`";            //放电计划表
    public final static String Avoid_plan_Table = WEB_Site + ".`tb_avoid_plan`";                        //放电计划规避时间表
    public final static String BattMapInformation_Table = WEB_Site + ".`tb_battmap_information`";        //基站定位表
    public final static String BattDischarge_Table = WEB_Site + ".`tb_batt_discharge`";                    //基站故障表
    public final static String BattReplace_Table = WEB_Site + ".`tb_batt_replace`";                        //电池更换记录表
    public final static String Dev_Restart_Plan_Table = WEB_Site +".`tb_dev_restart_plan`";                //设备定期重启计划表
    public final static String Vip_User_Table = WEB_Site +".`tb_vip_user`";                                //超级用户表
    public final static String License_Table = WEB_Site +".`tb_license`";                                //超级用户表
    public final static String Database_Backup_Table = WEB_Site +".`tb_database_backup`";                                //超级用户表
    /***************************** db_battinf数据库  ***************************************/
    public final static String DeverrorRecord_Table = DB_BATT_INF + ".`tb_deverror_record`";                        //机房问题记录表
    public final static String BattinfApply_TABLE = DB_BATT_INF + ".`tb_battinf_apply`";                            //机房安装审批表
    public final static String BattinfEx_TABLE = DB_BATT_INF + ".`tb_battinf_ex`";                                    //基站信息表
    public final static String BattinfRebuild_TABLE = DB_BATT_INF + ".`tb_battinf_rebuild`";                        //机房配组表
    public final static String BattmonTestcap_TABLE = DB_BATT_INF + ".`tb_battmon_testcap`";                        //机房标准测试曲线记录表
    public final static String Battcurr_Inf_TABLE = DB_BATT_INF + ".`tb_battcurr_inf`";
    public final static String Batt_Maint_Process_TABLE = DB_BATT_INF + ".`tb_batt_maint_process`";
    public final static String Batt_Maint_Inf_TABLE = DB_BATT_INF + ".`tb_batt_maint_inf`";
    public final static String Batt_Alm_Param_TABLE = DB_BATT_INF + ".`tb_batt_alm_param`";
    /***************************** db_alarm数据库  ***************************************/
    public final static String Devalarm_Data_Table = DB_ALARM + ".`tb_devalarm_data`";
    public final static String Devalarm_Data__History_Table = DB_ALARM + ".`tb_devalarm_data_history`";
    public final static String Bts_Station_Event_Table = DB_ALARM + ".`tb_bts_station_event`";
    public final static String Battalarm_Data_Table = DB_ALARM + ".`tb_battalarm_data`";
    public final static String Battalarm_Data_History_Table = DB_ALARM + ".`tb_battalarm_data_history`";
    public final static String Tb_Alarm_Message = DB_ALARM + ".`tb_alarm_message`";
    /***************************** db_app_sys 数据库  ***************************************/
    public final static String Page_Param_Table = DB_AppSys + ".`tb_page_param`";
    public final static String Fbsdev_Statechange_Inf_Table = DB_AppSys + ".`tb_fbsdev_statechange_inf`";
    public final static String Dashboard_Module_Chart_Table = DB_AppSys + ".`tb_dashboard_module_chart`";
    public final static String Dashboard_Module_Table = DB_AppSys + ".`tb_dashboard_module`";
    public final static String Dashboard_Chart_Type_Table = DB_AppSys + ".`tb_dashboard_chart_type`";
    public final static String App_Sys_Table = DB_AppSys + ".`tb_app_sys`";
    public final static String App_Bts_Comm_Task_Table = DB_AppSys + ".`tb_app_bts_comm_task`";
    public final static String App_Bts_Battgroup_Table = DB_AppSys + ".`tb_app_bts_battgroup`";
    public final static String Menu_Table = DB_AppSys + ".`tb_menu`";
    /***************************** db_ld9_testdata 数据库  ***************************************/
    public final static String Ld9testdata_Inf_Table = DB_LD9_TESTDATA + ".`tb_ld9testdata_inf`";
    /***************************** db_param 数据库  ***************************************/
    public final static String Dev_Param_Table = DB_PARAM + ".`tb_dev_param`";
    public final static String App_Param_Table = DB_PARAM + ".`tb_app_param`";
    public final static String Alarm_Param_Table = DB_PARAM + ".`tb_alarm_param`";
    /***************************** db_pwrdev_alarm 数据库  ************************************/
    public final static String Pwrdev_Alarm_Table = DB_PWRDEV_ALARM + ".`tb_pwrdev_alarm`";
    public final static String Pwrdev_Alarm_History_Table = DB_PWRDEV_ALARM + ".`tb_pwrdev_alarm_history`";
    /***************************** db_pwrdev_data_rt 数据库  ************************************/
    public final static String Pwrdev_Acdcdata_Table = DB_PWRDEV_DATA_RT + ".`tb_pwrdev_acdcdata`";
    public final static String Pwrdev_Dcdata_Table = DB_PWRDEV_DATA_RT + ".`tb_pwrdev_dcdata`";
    public final static String Pwrdev_Acdata_Table = DB_PWRDEV_DATA_RT + ".`tb_pwrdev_acdata`";
     /***************************** db_pwrdev_inf 数据库  ************************************/
    public final static String Pwrdev_Inf_Table = DB_PWRDEV_INF + ".`tb_pwrdev_inf`";
    public final static String Pwrapp_Sys_Table = DB_PWRDEV_INF + ".`tb_pwrapp_sys`";
    public final static String Display_Config_Table = DB_PWRDEV_INF + ".`tb_display_config`";
    public final static String Pwrapp_Stainf_Table = DB_PWRDEV_INF + ".`tb_pwrapp_stainf`";
    public final static String Pwrapp_Dcinf_Table = DB_PWRDEV_INF + ".`tb_pwrapp_dcinf`";
    public final static String Pwrapp_Acinf_Table = DB_PWRDEV_INF + ".`tb_pwrapp_acinf`";
    public final static String Pwrapp_Acdcinf_Table = DB_PWRDEV_INF + ".`tb_pwrapp_acdcinf`";
    /***************************** db_fbo_testdata 数据库  ************************************/
    public final static String Fbotestdata_Inf_Table = DB_FBO_TESTDATA + ".`tb_fbotestdata_inf`";
    //--------------------------------------------------------------------------------------------//
    //--------------------------------------------------------------------------------------------//
    public Connection mysql_con;
    public Sql_Mysql(Connection conn)
    {
        mysql_con = conn;
    }
    /*
    public static Connection getConnection() throws SQLException, java.lang.ClassNotFoundException{
        String url = "jdbc:mysql://192.168.48.128:3306/studentinfo";
        Class.forName("com.mysql.jdbc.Driver");
        String userName = "root";
        String password = "lmx8688139";
        Connection con = DriverManager.getConnection(url,userName,password);
        return con;
    }
    */
    public void close_con()
    {
        try {
            mysql_con.close();
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
    public void checkAndCreateDB() throws SQLException
    {
        sqlMysqlExecute("CREATE DATABASE IF NOT EXISTS " + DB_AppSys);
        sqlMysqlExecute("CREATE DATABASE IF NOT EXISTS " + DB_BATT_INF);
        sqlMysqlExecute("CREATE DATABASE IF NOT EXISTS " + DB_BATT_TESTDATA);
        sqlMysqlExecute("CREATE DATABASE IF NOT EXISTS " + DB_PARAM);
        sqlMysqlExecute("CREATE DATABASE IF NOT EXISTS " + DB_ALARM);
        sqlMysqlExecute("CREATE DATABASE IF NOT EXISTS " + DB_USER);
        sqlMysqlExecute("CREATE DATABASE IF NOT EXISTS " + DB_RamDB);
        //sqlMysqlExecute("DROP DATABASE IF EXISTS " + DB_RamDB_BATT_RT);
        //sqlMysqlExecute("CREATE DATABASE IF NOT EXISTS " + DB_RamDB_BATT_RT);
        sqlMysqlExecute("CREATE DATABASE IF NOT EXISTS " + WEB_Site);
        String table_0 = "CREATE TABLE IF NOT EXISTS " + AppSys_Table
                        + " ( `num` INT NOT NULL AUTO_INCREMENT,"
                        + "`SqlDB_Version` FLOAT NOT NULL DEFAULT '1.0',"
                        + "`SqlDB_BackUpTime` DATETIME NOT NULL DEFAULT '2000-1-1 00:00:00',"
                        + "`SqlDB_BackUpManual_EN` BOOLEAN NOT NULL DEFAULT false, "
                        + "`AppServer_Reinit_BattGroupData_EN` BOOLEAN NOT NULL DEFAULT false, "
                        + "`AppServer_Reinit_BattGroupData_LD9_EN` BOOLEAN NOT NULL DEFAULT false, "            //用于9度程序重新加载设备
                        + "`AppServer_Reinit_Config_EN` BOOLEAN NOT NULL DEFAULT false, "
                        + "`AppServer_Version` FLOAT NOT NULL DEFAULT '1.0',"
                        + "`AppClient_Version` FLOAT NOT NULL DEFAULT '1.0',"
                        + "`AppName` VARCHAR(50) NOT NULL DEFAULT '0',"
                        + " PRIMARY KEY (`num`)) "
                        + " ENGINE=InnoDB DEFAULT CHARSET=utf8;";
        String table_1 = "CREATE TABLE IF NOT EXISTS " + BattInf_Table
                        + " ( `num` INT NOT NULL AUTO_INCREMENT,"
                        + "`StationId` VARCHAR(20) NOT NULL DEFAULT '0',"
                        + "`StationName` VARCHAR(100) NOT NULL DEFAULT ' ',"
                        + "`StationName1` VARCHAR(100) NOT NULL DEFAULT ' ',"
                        + "`StationName2` VARCHAR(100) NOT NULL DEFAULT ' ',"
                        + "`StationName3` VARCHAR(100) NOT NULL DEFAULT ' ',"
                        + "`StationName4` VARCHAR(100) NOT NULL DEFAULT ' ',"
                        + "`StationName5` VARCHAR(100) NOT NULL DEFAULT ' ',"
                        + "`StationName6` VARCHAR(100) NOT NULL DEFAULT ' ',"
                        + "`StationName7` VARCHAR(100) NOT NULL DEFAULT ' ',"
                        + "`StationName8` VARCHAR(100) NOT NULL DEFAULT ' ',"
                        + "`StationName9` VARCHAR(100) NOT NULL DEFAULT ' ',"
                        + "`StationIP` VARCHAR(20) NOT NULL DEFAULT '0',"
                        + "`FBSDeviceId` BIGINT NOT NULL DEFAULT '0',"
                        + "`FBSDeviceIp` VARCHAR(50) NOT NULL DEFAULT '192.168.0.88',"
                        + "`FBSDeviceName` VARCHAR(100) NOT NULL DEFAULT '0',"
                        + "`GroupIndexInFBSDevice` INT NOT NULL DEFAULT '0',"
                        + "`BattModel` VARCHAR(100) NOT NULL DEFAULT ' ',"
                        + "`BattGroupId` INT NOT NULL DEFAULT '0',"
                        + "`BattGroupNum` INT NOT NULL DEFAULT '0',"
                        + "`BattGroupName` VARCHAR(100) NOT NULL DEFAULT ' ',"
                        + "`BattGroupName1` VARCHAR(100) NOT NULL DEFAULT ' ',"
                        + "`BattGroupName2` VARCHAR(100) NOT NULL DEFAULT ' ',"
                        + "`BattGroupName3` VARCHAR(100) NOT NULL DEFAULT ' ',"
                        + "`BattGroupName4` VARCHAR(100) NOT NULL DEFAULT ' ',"
                        + "`BattGroupName5` VARCHAR(100) NOT NULL DEFAULT ' ',"
                        + "`BattGroupName6` VARCHAR(100) NOT NULL DEFAULT ' ',"
                        + "`FloatVolLevel` FLOAT NOT NULL DEFAULT '1.12',"
                        + "`OfflineVolLevel` FLOAT NOT NULL DEFAULT '1.06',"
                        + "`BattFloatCurrent` FLOAT NOT NULL DEFAULT '0',"
                        + "`DeviceId` VARCHAR(20) NOT NULL DEFAULT '0',"
                        + "`DeviceName` VARCHAR(100) NOT NULL DEFAULT '0',"
                        + "`MonCount` INT NOT NULL DEFAULT '0',"
                        + "`MonCapStd` FLOAT NOT NULL DEFAULT '0',"
                        + "`MonVolStd` FLOAT NOT NULL DEFAULT '0',"
                        + "`MonResStd` FLOAT NOT NULL DEFAULT '0',"
                        + "`MonSerStd` FLOAT NOT NULL DEFAULT '0',"
                        + "`MonTmpStd` FLOAT NOT NULL DEFAULT '0',"
                        + "`MonVolLowToAvg` FLOAT NOT NULL DEFAULT '0',"
                        + "`MonNum` INT NOT NULL DEFAULT '0',"
                        + "`BattProducer` VARCHAR(45) NOT NULL DEFAULT '0',"
                        + "`BattProductDate` DATE NOT NULL DEFAULT '2006-07-06',"
                        + "`BattInUseDate` DATE NOT NULL DEFAULT '2006-07-06',"
                        + "`BattGuarantDayCount` INT NOT NULL DEFAULT '1095',"
                        + "`SignalId` VARCHAR(20) NOT NULL DEFAULT '0',"
                        + "`CInterFaceId` INT NOT NULL DEFAULT '0',"
                        + "`SignalName` VARCHAR(50) NOT NULL DEFAULT '0',"
                        + "INDEX index_station_id (`StationId`), "
                        + "INDEX index_battgroup_id (`BattGroupId`), "
                        + "INDEX index_station_name (`StationName`), "
                        + "INDEX index_battgroup_name (`BattGroupName`), "
                        + "PRIMARY KEY (`num`)) "
                        + "ENGINE=InnoDB DEFAULT CHARSET=utf8;";
        String table_2 = "CREATE TABLE IF NOT EXISTS " + BattCurrInf_Table
                        + " ( `num` INT NOT NULL AUTO_INCREMENT,"
                        + "`StationId` VARCHAR(20) NOT NULL DEFAULT '0',"
                        + "`BattGroupId` VARCHAR(20) NOT NULL DEFAULT '0',"
                        + "`BattGroupName` VARCHAR(100) NOT NULL DEFAULT '0',"
                        + "`CurrDeviceId` VARCHAR(20) NOT NULL DEFAULT '0',"
                        + "`CurrDeviceName` VARCHAR(100) NOT NULL DEFAULT '0',"
                        + "`CurrValueId` VARCHAR(20) NOT NULL DEFAULT '0',"
                        + "`CurrValueName` VARCHAR(100) NOT NULL DEFAULT '0',"
                        + "PRIMARY KEY (`num`)) "
                        + "ENGINE=InnoDB DEFAULT CHARSET=utf8;";
        String table_3 = "CREATE TABLE IF NOT EXISTS " + BattMainInf_Table
                        + " ( `num` BIGINT NOT NULL AUTO_INCREMENT, "
                        + "`BattGroupId` INT NOT NULL DEFAULT 0, "
                        + "`usr_id` INT NOT NULL DEFAULT 0, "
                        + "`fault_type_id` INT NOT NULL DEFAULT 0, "
                        + "`fault_type` VARCHAR(50) NOT NULL DEFAULT ' ', "
                        + "`fault_level` INT NOT NULL DEFAULT 0, "
                        + "`fault_caption` VARCHAR(200) NOT NULL DEFAULT ' ', "
                        + "`fault_time` DATETIME NOT NULL DEFAULT '2005-1-1 00:00:00', "
                        + "`record_uid` INT NOT NULL DEFAULT 0, "
                        + "`record_time` DATETIME NOT NULL DEFAULT '2005-1-1 00:00:00', "
                        + "`maint_time_limit` DATETIME NOT NULL DEFAULT '2005-1-1 00:00:00', "
                        + "`maint_type_id` INT NOT NULL DEFAULT 0, "
                        + "`maint_type` VARCHAR(50) NOT NULL DEFAULT ' ', "
                        + "`maint_result` VARCHAR(100) NOT NULL DEFAULT ' ', "
                        + "`maint_done` BOOLEAN NOT NULL DEFAULT false, "
                        + "`maint_done_time` DATETIME DEFAULT '2005-1-1 00:00:00', "
                        + "`maint_close` BOOLEAN NOT NULL DEFAULT false, "
                        + "`master_id` INT NOT NULL DEFAULT 0, "
                        + "`master_audit` INT NOT NULL DEFAULT 0, "                //领导审核
                        + "`appoint_uid` INT NOT NULL DEFAULT 0, "                 //指派给谁
                        + "`copy_uids` VARCHAR(200) NOT NULL DEFAULT ' ', "        //抄送给谁
                        + "`master_check` VARCHAR(100) NOT NULL DEFAULT ' ', "
                        + "`remark` VARCHAR(200) NOT NULL DEFAULT ' ', "
                        + "INDEX index_battgroup_id (`BattGroupId`), "
                        + "INDEX index_user_id (`usr_id`), "
                        + "INDEX index_fault_type_id (`fault_type_id`), "
                        + "INDEX index_maint_type_id (`maint_type_id`), "
                        + "PRIMARY KEY (`num`)) "
                        + "ENGINE=InnoDB DEFAULT CHARSET=utf8;";
        String table_3_1 = "CREATE TABLE IF NOT EXISTS " + BattMainProcess_Table
                        + " ( `num` BIGINT NOT NULL AUTO_INCREMENT, "
                        + "`batt_maint_rec_id` BIGINT NOT NULL DEFAULT 0, "
                        + "`usr_id` INT NOT NULL DEFAULT 0, "
                        + "`work_caption` VARCHAR(200) NOT NULL DEFAULT ' ', "
                        + "`work_caption_time` DATETIME DEFAULT '2005-1-1 00:00:00', "
                        + "INDEX index_batt_maint_rec_id (`batt_maint_rec_id`), "
                        + " PRIMARY KEY (`num`)) "
                        + "ENGINE=InnoDB DEFAULT CHARSET=utf8;";
        String table_3_2 = "CREATE TABLE IF NOT EXISTS " + UsrBattMaintCheck_Table
                        + " ( `num` BIGINT NOT NULL AUTO_INCREMENT, "
                        + "`StationId` INT NOT NULL DEFAULT 0, "
                        + "`usr_id` INT NOT NULL DEFAULT 0, "
                        + "`master_id` INT NOT NULL DEFAULT 0, "
                        + "`appoint_uid` INT NOT NULL DEFAULT 0, "                 //指派给谁
                        + "`copy_uids` VARCHAR(200) NOT NULL DEFAULT ' ', "        //抄送给谁
                        + "`task_type_id` INT NOT NULL DEFAULT 0, "
                        + "`task_level` INT NOT NULL DEFAULT 0, "
                        + "`task_caption` VARCHAR(200) NOT NULL DEFAULT ' ', "
                        + "`task_time_start` DATETIME NOT NULL DEFAULT '2005-1-1 00:00:00', "
                        + "`task_time_end` DATETIME NOT NULL DEFAULT '2005-1-1 00:00:00', "
                        + "`task_process` VARCHAR(200) NOT NULL DEFAULT ' ', "
                        + "`task_done` BOOLEAN NOT NULL DEFAULT false, "
                        + "`task_done_time` DATETIME DEFAULT '2005-1-1 00:00:00', "
                        + "`origin_usr_work_mark` INT NOT NULL DEFAULT 0, "
                        + "`task_done_confirm` BOOLEAN NOT NULL DEFAULT false, "
                        + "`master_audit` INT NOT NULL DEFAULT 0, "                //领导审核
                        + "`remark` VARCHAR(200) NOT NULL DEFAULT ' ', "
                        + "INDEX index_station_id (`StationId`), "
                        + "INDEX index_user_id (`usr_id`), "
                        + "INDEX index_task_type_id (`task_type_id`), "
                        + "PRIMARY KEY (`num`)) "
                        + "ENGINE=InnoDB DEFAULT CHARSET=utf8;";
        String table_3_2_1 = "CREATE TABLE IF NOT EXISTS " + UsrBattMaintCheckProcess_Table
                        + " ( `num` BIGINT NOT NULL AUTO_INCREMENT, "
                        + "`task_rec_id` BIGINT NOT NULL DEFAULT 0, "
                        + "`usr_id` INT NOT NULL DEFAULT 0, "
                        + "`work_caption` VARCHAR(200) NOT NULL DEFAULT ' ', "
                        + "`work_caption_time` DATETIME DEFAULT '2005-1-1 00:00:00', "
                        + "INDEX index_task_rec_id (`task_rec_id`), "
                        + " PRIMARY KEY (`num`)) "
                        + "ENGINE=InnoDB DEFAULT CHARSET=utf8;";
        String table_4 = "CREATE TABLE IF NOT EXISTS " + BattTestDataInf_Table
                        + " ( `num` BIGINT NOT NULL AUTO_INCREMENT, "
                        + "`BattGroupId` INT NOT NULL DEFAULT 0, "
                        + "`test_record_count` INT NOT NULL DEFAULT 0, "
                        + "`test_record_count_ex` INT NOT NULL DEFAULT 0, "
                        + "`test_type` INT NOT NULL DEFAULT 0, "
                        + "`record_time_interval` INT NOT NULL DEFAULT 0, "
                        + "`data_new` BOOLEAN NOT NULL DEFAULT false, "
                        + "`data_available` BOOLEAN NOT NULL DEFAULT false, "
                        + "`record_num` INT NOT NULL DEFAULT 0, "
                        + "`test_starttime` DATETIME NOT NULL DEFAULT '1982-01-01 00:00:00', "
                        + "`test_starttime_ex` DATETIME NOT NULL DEFAULT '1982-01-01 00:00:00', "
                        + "`test_starttype` INT NOT NULL DEFAULT 0, "
                        + "`record_time` DATETIME NOT NULL DEFAULT '1982-01-01 00:00:00', "
                        + "`test_timelong` INT NOT NULL DEFAULT 0, "
                        + "`test_stoptype` INT NOT NULL DEFAULT 0, "
                        + "`group_vol` FLOAT NOT NULL DEFAULT 0, "
                        + "`test_curr` FLOAT NOT NULL DEFAULT 0, "
                        + "`test_cap` FLOAT NOT NULL DEFAULT 0, "
                        + "`max_monnum` INT NOT NULL DEFAULT 0, "
                        + "`max_monvol` FLOAT NOT NULL DEFAULT 0, "
                        + "`min_monnum` INT NOT NULL DEFAULT 0, "
                        + "`min_monvol` FLOAT NOT NULL DEFAULT 0, "
                        + "`mon_num` INT NOT NULL DEFAULT 0, "
                        + "`mon_vol` FLOAT NOT NULL DEFAULT 0, "
                        + "`upload_usr_id` INT NOT NULL DEFAULT 0, "
                        + "`upload_data_ext` INT NOT NULL DEFAULT 0, "
                        + "`upload_client_type` INT NOT NULL DEFAULT 0, "
                        + "INDEX index_battgroup_id (`BattGroupId`), "
                        + "INDEX index_test_record_count (`test_record_count`), "
                        + "INDEX index_test_type (`test_type`), "
                        + "INDEX index_test_starttime (`test_starttime`), "
                        + "PRIMARY KEY (`num`)) "
                        + "ENGINE=InnoDB DEFAULT CHARSET=utf8;";
        String table_5 = "CREATE TABLE IF NOT EXISTS " + BattResDataInf_Table
                        + " ( `num` BIGINT NOT NULL AUTO_INCREMENT, "
                        + "`BattGroupId` INT NOT NULL DEFAULT 0, "
                        + "`test_record_count` INT NOT NULL DEFAULT 0, "
                        + "`test_record_count_ex` INT NOT NULL DEFAULT 0, "
                        + "`test_type` INT NOT NULL DEFAULT 0, "
                        + "`data_new` BOOLEAN NOT NULL DEFAULT false, "
                        + "`data_available` BOOLEAN NOT NULL DEFAULT false, "
                        + "`test_starttime` DATETIME NOT NULL DEFAULT '1982-01-01 00:00:00', "
                        + "`test_starttime_ex` DATETIME NOT NULL DEFAULT '1982-01-01 00:00:00', "
                        + "`test_devtype` INT NOT NULL DEFAULT 0, "
                        + "`record_time` DATETIME NOT NULL DEFAULT '1982-01-01 00:00:00', "
                        + "`group_vol` FLOAT NOT NULL DEFAULT 0, "
                        + "`test_curr` FLOAT NOT NULL DEFAULT 0, "
                        + "`upload_usr_id` INT NOT NULL DEFAULT 0, "
                        + "`upload_client_type` INT NOT NULL DEFAULT 0, "
                        + "INDEX index_battgroup_id (`BattGroupId`), "
                        + "INDEX index_test_record_count (`test_record_count`), "
                        + "INDEX index_test_starttime (`test_starttime`), "
                        + "PRIMARY KEY (`num`)) "
                        + "ENGINE=InnoDB DEFAULT CHARSET=utf8;";
        String table_6 = "DROP TABLE IF EXISTS " + SocketClientStateTable + "; ";
        String table_7 = "CREATE TABLE IF NOT EXISTS " + SocketClientStateTable
                        + "(`num` BIGINT NOT NULL AUTO_INCREMENT, "
                        + "`uId` INT NOT NULL DEFAULT 0, "
                        + "`client_type` INT NOT NULL DEFAULT 0, "
                        + "`client_id` BIGINT NOT NULL DEFAULT 0, "
                        + "`BattGroupId` INT NOT NULL DEFAULT 0, "
                        + "`client_is_connected` BOOLEAN NOT NULL DEFAULT false, "
                        + "`client_ip` VARCHAR(64) NOT NULL DEFAULT ' ', "
                        + "`client_conn_time` DATETIME NOT NULL DEFAULT '1980-01-01', "
                        + "`client_disconn_time` DATETIME NOT NULL DEFAULT '1980-01-01', "
                        + "INDEX index_user_id (`uId`), "
                        + "INDEX index_client_type (`client_type`), "
                        + "PRIMARY KEY (`num`)) "
                        + "ENGINE=MEMORY DEFAULT CHARSET=utf8;";
        String table_8 = "CREATE TABLE IF NOT EXISTS " + FBSDevStateChangeInf_Table
                        + "(`num` BIGINT NOT NULL AUTO_INCREMENT, "
                        + "`dev_id` INT NOT NULL DEFAULT 0, "
                        + "`rec_time` DATETIME NOT NULL DEFAULT '1980-01-01', "
                        + "`last_stat` INT NOT NULL DEFAULT 0, "
                        + "`now_stat` INT NOT NULL DEFAULT 0, "
                        + "`state_change_reason` INT NOT NULL DEFAULT 0, "
                        + "`dev_alarm` INT NOT NULL DEFAULT 0, "
                        + "INDEX index_dev_id (`dev_id`), "
                        + "PRIMARY KEY (`num`)) "
                        + "ENGINE=InnoDB DEFAULT CHARSET=utf8;";
        String table_9 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.BTSStationEvent_Table
                        + " ( `num` BIGINT NOT NULL AUTO_INCREMENT, "
                        + "`station_id` BIGINT NOT NULL DEFAULT 0, "
                        + "`dev_id` BIGINT NOT NULL DEFAULT 0, "
                        + "`record_datetime` varchar(20) NOT NULL DEFAULT '2015-12-02 12:10:00', "
                        + "`station_event_type` INT NOT NULL DEFAULT 0, "
                        + "`station_event_trig` INT NOT NULL DEFAULT 0, "
                        + " INDEX index_dev_id (`dev_id`), "
                        + " INDEX index_station_id (`station_id`), "
                        + " PRIMARY KEY (`num`) ) "
                        + " ENGINE=InnoDB DEFAULT CHARSET=utf8";
        //-------------------------------------------------------------------------------------//
        //-------------------------------------------------------------------------------------//
        sqlMysqlUseDB(Sql_Mysql.DB_AppSys);
        if(false == sqlMysqlCheckIfTableExist(TB_AppSys))
        {
            sqlMysqlExecute(table_0);
            sqlMysqlExecute("INSERT INTO " + Sql_Mysql.AppSys_Table
                                + " (AppName) VALUES ('蓄电池组综合管理系统')");
        }
        //-------------------------------------------------------------------------------------//
        {
            ResultSet rest = sqlMysqlQuery("SELECT AppServer_Version FROM " + Sql_Mysql.AppSys_Table);
            if(rest.next()) {
                float ser_version = rest.getFloat(1);
                if(ser_version < 1.387) {
                    sqlMysqlExecute("UPDATE " + Sql_Mysql.AppSys_Table + " SET AppServer_Version=1.388");
                    sqlMysqlExecute("USE db_batt_testdata");
                    sqlMysqlExecute("UPDATE tb_batttestdata_inf SET "
                                    + " test_starttime=date_sub(test_starttime, interval 1 month) "
                                    + " WHERE upload_usr_id>0");
                }
            }
        }
        //---------------------------------------------------------------------------------------------//
            ResultSet res0 = sqlMysqlQuery("SELECT * FROM information_schema.columns"
                                    + " WHERE table_schema='db_app_sys'"
                                    + " AND table_name='tb_app_sys'"
                                    + " AND column_name='SqlDB_BackUpTime'");
            if(false == res0.next()) {
                sqlMysqlExecute("ALTER TABLE " + AppSys_Table
                                + " ADD COLUMN `SqlDB_BackUpTime` DATETIME NOT NULL DEFAULT '2000-1-1 00:00:00'"
                                + " AFTER `SqlDB_Version`,"
                                + " ADD COLUMN `SqlDB_BackUpManual_EN` BOOLEAN NOT NULL DEFAULT false"
                                + " AFTER `SqlDB_BackUpTime`");
            }
            res0 = sqlMysqlQuery("SELECT * FROM information_schema.columns"
                                + " WHERE table_schema='db_app_sys'"
                                + " AND table_name='tb_app_sys'"
                                + " AND column_name='SqlDB_BackUpManual_EN'");
            if(false == res0.next()) {
                sqlMysqlExecute("ALTER TABLE " + AppSys_Table
                                + " ADD COLUMN `SqlDB_BackUpManual_EN` BOOLEAN NOT NULL DEFAULT false"
                                + " AFTER `SqlDB_BackUpTime`");
            }
            /**************************** db_app_sys 表中添加 AppServer_Reinit_BattGroupData_EN列(重新载入电池组信息) *******************************************/
            res0 = sqlMysqlQuery("SELECT * FROM information_schema.columns"
                    + " WHERE table_schema='db_app_sys'"
                    + " AND table_name='tb_app_sys'"
                    + " AND column_name='AppServer_Reinit_BattGroupData_EN'");
            if(false == res0.next()) {
            sqlMysqlExecute("ALTER TABLE " + AppSys_Table
                            + " ADD COLUMN `AppServer_Reinit_BattGroupData_EN` BOOLEAN NOT NULL DEFAULT false"
                            + " AFTER `SqlDB_BackUpManual_EN`");
            }
            /**************************** db_app_sys 表中添加 AppServer_Reinit_BattGroupData_EN 列(用于主程序动态调整运行参数) *******************************************/
            res0 = sqlMysqlQuery("SELECT * FROM information_schema.columns"
                    + " WHERE table_schema='db_app_sys'"
                    + " AND table_name='tb_app_sys'"
                    + " AND column_name='AppServer_Reinit_Config_EN'");
            if(false == res0.next()) {
            sqlMysqlExecute("ALTER TABLE " + AppSys_Table
                            + " ADD COLUMN `AppServer_Reinit_Config_EN` BOOLEAN NOT NULL DEFAULT false"
                            + " AFTER `AppServer_Reinit_BattGroupData_EN`");
            }
            /**************************** db_app_sys 表中添加 AppServer_Reinit_BattGroupData_LD9_EN 列(用于LD9主程序动态加载设备参数) *******************************************/
            res0 = sqlMysqlQuery("SELECT * FROM information_schema.columns"
                    + " WHERE table_schema='db_app_sys'"
                    + " AND table_name='tb_app_sys'"
                    + " AND column_name='AppServer_Reinit_BattGroupData_LD9_EN'");
            if(false == res0.next()) {
            sqlMysqlExecute("ALTER TABLE " + AppSys_Table
                            + " ADD COLUMN `AppServer_Reinit_BattGroupData_LD9_EN` BOOLEAN NOT NULL DEFAULT false"
                            + " AFTER `AppServer_Reinit_BattGroupData_EN`");
            }
        //---------------------------------------------------------------------------------------------//
        sqlMysqlExecute(table_1);
        sqlMysqlExecute(table_2);
        sqlMysqlExecute(table_3);
        sqlMysqlExecute(table_3_1);
        sqlMysqlExecute(table_3_2);
        sqlMysqlExecute(table_3_2_1);
        sqlMysqlExecute(table_4);
        sqlMysqlExecute(table_5);
        sqlMysqlExecute(table_6);
        sqlMysqlExecute(table_7);
        sqlMysqlExecute(table_8);
        sqlMysqlExecute(table_9);
        //---------------------------------------------------------------------------------------------//
        ResultSet res = sqlMysqlQuery("show index from " + BattInf_Table + " where column_name='BattGroupId'");
        if(false == res.next())
        {
            sqlMysqlExecute("ALTER TABLE " + BattInf_Table + " ADD INDEX `index_station_id` (`StationId` ASC);");
            sqlMysqlExecute("ALTER TABLE " + BattInf_Table + " ADD INDEX `index_battgroup_id` (`BattGroupId` ASC);");
            sqlMysqlExecute("ALTER TABLE " + BattInf_Table + " ADD INDEX `index_station_name` (`StationName` ASC);");
            sqlMysqlExecute("ALTER TABLE " + BattInf_Table + " ADD INDEX `index_battgroup_name` (`BattGroupName` ASC);");
        }
        //---------------------------------------------------------------------------------------------//
                //-------------------------------- 2017-06-06 by mxpopstar ------------------------------------//
                        res = sqlMysqlQuery("SELECT * FROM information_schema.columns"
                                                + " WHERE table_schema='db_battinf'"
                                                + " AND table_name='tb_battinf'"
                                                + " AND column_name='BattGuarantDayCount'");
                        if(false == res.next()) {
                            sqlMysqlExecute("ALTER TABLE " + BattInf_Table
                                            + " ADD COLUMN `BattGuarantDayCount` INT NOT NULL DEFAULT 1095 AFTER `BattInUseDate`");
                        }
                //---------------------------------------------------------------------------------------------//
                //-------------------------------- 2018-10-12 by lijun   (  binf表中添加   Load_curr->负载电流        disCurrMax -> 最大核容电流   )------------------------------------//
                        res = sqlMysqlQuery("SELECT * FROM information_schema.columns"
                                                + " WHERE table_schema='db_battinf'"
                                                + " AND table_name='tb_battinf'"
                                                + " AND column_name='Load_curr'");
                        if(false == res.next()) {
                            sqlMysqlExecute("ALTER TABLE " + BattInf_Table
                                            + " ADD COLUMN `Load_curr` float NOT NULL DEFAULT 15");
                        }
                        res = sqlMysqlQuery("SELECT * FROM information_schema.columns"
                                + " WHERE table_schema='db_battinf'"
                                + " AND table_name='tb_battinf'"
                                + " AND column_name='disCurrMax'");
                        if(false == res.next()) {
                            sqlMysqlExecute("ALTER TABLE " + BattInf_Table
                                            + " ADD COLUMN `disCurrMax` float NOT NULL DEFAULT 0");
                        }
                //-------------------------------- 2018-10-16 by lijun   (  binf表中添加   station_phone->基站手机号 )------------------------------------//
                        res = sqlMysqlQuery("SELECT * FROM information_schema.columns"
                                + " WHERE table_schema='db_battinf'"
                                + " AND table_name='tb_battinf'"
                                + " AND column_name='station_phone'");
                        if(false == res.next()) {
                            sqlMysqlExecute("ALTER TABLE " + BattInf_Table
                                            + " ADD COLUMN `station_phone` varchar(32) DEFAULT ''");
                        }
                //---------------------------------------------------------------------------------------------//
                //-------------------------------- 2018-10-16 by lijun   (  binf表中添加   station_install->标识机房是否已经安装 )------------------------------------//
                        res = sqlMysqlQuery("SELECT * FROM information_schema.columns"
                                + " WHERE table_schema='db_battinf'"
                                + " AND table_name='tb_battinf'"
                                + " AND column_name='station_install'");
                        if(false == res.next()) {
                            sqlMysqlExecute("ALTER TABLE " + BattInf_Table
                                            + " ADD COLUMN `station_install` BOOLEAN NOT NULL DEFAULT false");
                        }
                //---------------------------------------------------------------------------------------------//
                //-------------------------------- 2018-11-29 by lijun   (  binf表中添加   StationId_ex->基站站址编号   install_user-->安装人)------------------------------------//
                        res = sqlMysqlQuery("SELECT * FROM information_schema.columns"
                                + " WHERE table_schema='db_battinf'"
                                + " AND table_name='tb_battinf'"
                                + " AND column_name='StationId_ex'");
                        if(false == res.next()) {
                            sqlMysqlExecute("ALTER TABLE " + BattInf_Table
                                            + " ADD COLUMN `StationId_ex` varchar(20) DEFAULT '' AFTER StationId");
                        }
                        res = sqlMysqlQuery("SELECT * FROM information_schema.columns"
                                + " WHERE table_schema='db_battinf'"
                                + " AND table_name='tb_battinf'"
                                + " AND column_name='install_user'");
                        if(false == res.next()) {
                            sqlMysqlExecute("ALTER TABLE " + BattInf_Table
                                    + " ADD COLUMN `install_user` varchar(64) DEFAULT ''");
                        }
                //---------------------------------------------------------------------------------------------//
                //-------------------------------- 2018-12-12 by lijun   (  binf表中添加  charge_curr_max  最大充电电流)------------------------------------//
                        res = sqlMysqlQuery("SELECT * FROM information_schema.columns"
                                + " WHERE table_schema='db_battinf'"
                                + " AND table_name='tb_battinf'"
                                + " AND column_name='charge_curr_max'");
                        if(false == res.next()) {
                            sqlMysqlExecute("ALTER TABLE " + BattInf_Table
                                            + " ADD COLUMN `charge_curr_max` float DEFAULT '20'");
                        }
                 //---------------------------------------------------------------------------------------------//
                        //为紫晶南网平台添加指定的列
                        boolean isZijing = true;
                        if(isZijing) {
                            //添加电压等级列
                            res = sqlMysqlQuery("SELECT * FROM information_schema.columns"
                                    + " WHERE table_schema='db_battinf'"
                                    + " AND table_name='tb_battinf'"
                                    + " AND column_name='Vol_grade'");
                            if(false == res.next()) {
                                sqlMysqlExecute("ALTER TABLE " + BattInf_Table
                                                + " ADD COLUMN `Vol_grade` float DEFAULT '0'");
                            }
                            //生产厂家
                            res = sqlMysqlQuery("SELECT * FROM information_schema.columns"
                                    + " WHERE table_schema='db_battinf'"
                                    + " AND table_name='tb_battinf'"
                                    + " AND column_name='Manufacturers'");
                            if(false == res.next()) {
                                sqlMysqlExecute("ALTER TABLE " + BattInf_Table
                                                + " ADD COLUMN `Manufacturers` varchar(64) DEFAULT ''");
                            }
                            //是否资产级设备
                            res = sqlMysqlQuery("SELECT * FROM information_schema.columns"
                                    + " WHERE table_schema='db_battinf'"
                                    + " AND table_name='tb_battinf'"
                                    + " AND column_name='Assetequipment'");
                            if(false == res.next()) {
                                sqlMysqlExecute("ALTER TABLE " + BattInf_Table
                                                + " ADD COLUMN `Assetequipment` varchar(64) DEFAULT ''");
                            }
                            //设备分类全路径
                            res = sqlMysqlQuery("SELECT * FROM information_schema.columns"
                                    + " WHERE table_schema='db_battinf'"
                                    + " AND table_name='tb_battinf'"
                                    + " AND column_name='Deviceclasspath'");
                            if(false == res.next()) {
                                sqlMysqlExecute("ALTER TABLE " + BattInf_Table
                                                + " ADD COLUMN `Deviceclasspath` varchar(64) DEFAULT ''");
                            }
                            //设备运维部门
                            res = sqlMysqlQuery("SELECT * FROM information_schema.columns"
                                    + " WHERE table_schema='db_battinf'"
                                    + " AND table_name='tb_battinf'"
                                    + " AND column_name='Deviceoperationdepartment'");
                            if(false == res.next()) {
                                sqlMysqlExecute("ALTER TABLE " + BattInf_Table
                                                + " ADD COLUMN `DeviceOperationDepartment` varchar(64) DEFAULT ''");
                            }
                            //产权单位
                            res = sqlMysqlQuery("SELECT * FROM information_schema.columns"
                                    + " WHERE table_schema='db_battinf'"
                                    + " AND table_name='tb_battinf'"
                                    + " AND column_name='PropertyRightUnit'");
                            if(false == res.next()) {
                                sqlMysqlExecute("ALTER TABLE " + BattInf_Table
                                                + " ADD COLUMN `PropertyRightUnit` varchar(64) DEFAULT ''");
                            }
                            //产权属性
                            res = sqlMysqlQuery("SELECT * FROM information_schema.columns"
                                    + " WHERE table_schema='db_battinf'"
                                    + " AND table_name='tb_battinf'"
                                    + " AND column_name='PropertyAttribute'");
                            if(false == res.next()) {
                                sqlMysqlExecute("ALTER TABLE " + BattInf_Table
                                                + " ADD COLUMN `PropertyAttribute` varchar(64) DEFAULT ''");
                            }
                            //出厂编号
                            res = sqlMysqlQuery("SELECT * FROM information_schema.columns"
                                    + " WHERE table_schema='db_battinf'"
                                    + " AND table_name='tb_battinf'"
                                    + " AND column_name='FactoryNumber'");
                            if(false == res.next()) {
                                sqlMysqlExecute("ALTER TABLE " + BattInf_Table
                                                + " ADD COLUMN `FactoryNumber` varchar(64) DEFAULT ''");
                            }
                            //运维班组
                            res = sqlMysqlQuery("SELECT * FROM information_schema.columns"
                                    + " WHERE table_schema='db_battinf'"
                                    + " AND table_name='tb_battinf'"
                                    + " AND column_name='OperationTeam'");
                            if(false == res.next()) {
                                sqlMysqlExecute("ALTER TABLE " + BattInf_Table
                                                + " ADD COLUMN `OperationTeam` varchar(64) DEFAULT ''");
                            }
                            //设备身份编码
                            res = sqlMysqlQuery("SELECT * FROM information_schema.columns"
                                    + " WHERE table_schema='db_battinf'"
                                    + " AND table_name='tb_battinf'"
                                    + " AND column_name='DeviceIdentityCode'");
                            if(false == res.next()) {
                                sqlMysqlExecute("ALTER TABLE " + BattInf_Table
                                                + " ADD COLUMN `DeviceIdentityCode` varchar(64) DEFAULT ''");
                            }
                            //项目类型
                            res = sqlMysqlQuery("SELECT * FROM information_schema.columns"
                                    + " WHERE table_schema='db_battinf'"
                                    + " AND table_name='tb_battinf'"
                                    + " AND column_name='ProjectType'");
                            if(false == res.next()) {
                                sqlMysqlExecute("ALTER TABLE " + BattInf_Table
                                                + " ADD COLUMN `ProjectType` varchar(64) DEFAULT ''");
                            }
                            //蓄电池应用类型
                            res = sqlMysqlQuery("SELECT * FROM information_schema.columns"
                                    + " WHERE table_schema='db_battinf'"
                                    + " AND table_name='tb_battinf'"
                                    + " AND column_name='BatteryApplicationType'");
                            if(false == res.next()) {
                                sqlMysqlExecute("ALTER TABLE " + BattInf_Table
                                                + " ADD COLUMN `BatteryApplicationType` varchar(64) DEFAULT ''");
                            }
                            //单电池额定电压
                            res = sqlMysqlQuery("SELECT * FROM information_schema.columns"
                                    + " WHERE table_schema='db_battinf'"
                                    + " AND table_name='tb_battinf'"
                                    + " AND column_name='SingleRatedVoltage'");
                            if(false == res.next()) {
                                sqlMysqlExecute("ALTER TABLE " + BattInf_Table
                                                + " ADD COLUMN `SingleRatedVoltage` float DEFAULT '0'");
                            }
                            //是否实现远程监控
                            res = sqlMysqlQuery("SELECT * FROM information_schema.columns"
                                    + " WHERE table_schema='db_battinf'"
                                    + " AND table_name='tb_battinf'"
                                    + " AND column_name='RemoteMonitor'");
                            if(false == res.next()) {
                                sqlMysqlExecute("ALTER TABLE " + BattInf_Table
                                                + " ADD COLUMN `RemoteMonitor` varchar(64) DEFAULT ''");
                            }
                            //是否独立蓄电池室放置
                            res = sqlMysqlQuery("SELECT * FROM information_schema.columns"
                                    + " WHERE table_schema='db_battinf'"
                                    + " AND table_name='tb_battinf'"
                                    + " AND column_name='BatttIndependentPlaced'");
                            if(false == res.next()) {
                                sqlMysqlExecute("ALTER TABLE " + BattInf_Table
                                                + " ADD COLUMN `BatttIndependentPlaced` varchar(64) DEFAULT ''");
                            }
                            //均充电压设定值
                            res = sqlMysqlQuery("SELECT * FROM information_schema.columns"
                                    + " WHERE table_schema='db_battinf'"
                                    + " AND table_name='tb_battinf'"
                                    + " AND column_name='JunChargeVoltageValue'");
                            if(false == res.next()) {
                                sqlMysqlExecute("ALTER TABLE " + BattInf_Table
                                                + " ADD COLUMN `JunChargeVoltageValue` float DEFAULT '0'");
                            }
                            //公钥X
                            res = sqlMysqlQuery("SELECT * FROM information_schema.columns"
                                    + " WHERE table_schema='db_battinf'"
                                    + " AND table_name='tb_battinf'"
                                    + " AND column_name='PublicKeyX'");
                            if(false == res.next()) {
                                sqlMysqlExecute("ALTER TABLE " + BattInf_Table
                                                + " ADD COLUMN `PublicKeyX` varchar(200) NOT NULL DEFAULT ''");
                            }
                            //公钥Y
                            res = sqlMysqlQuery("SELECT * FROM information_schema.columns"
                                    + " WHERE table_schema='db_battinf'"
                                    + " AND table_name='tb_battinf'"
                                    + " AND column_name='PublicKeyY'");
                            if(false == res.next()) {
                                sqlMysqlExecute("ALTER TABLE " + BattInf_Table
                                                + " ADD COLUMN `PublicKeyY` varchar(200) NOT NULL DEFAULT ''");
                            }
                            //KeyID
                            res = sqlMysqlQuery("SELECT * FROM information_schema.columns"
                                    + " WHERE table_schema='db_battinf'"
                                    + " AND table_name='tb_battinf'"
                                    + " AND column_name='KeyID'");
                            if(false == res.next()) {
                                sqlMysqlExecute("ALTER TABLE " + BattInf_Table
                                                + " ADD COLUMN `KeyID` varchar(200) NOT NULL DEFAULT ''");
                            }
                            //唯一索引
                            res = sqlMysqlQuery("SELECT * FROM information_schema.columns"
                                    + " WHERE table_schema='db_battinf'"
                                    + " AND table_name='tb_battinf'"
                                    + " AND column_name='SerialNumber'");
                            if(false == res.next()) {
                                sqlMysqlExecute("ALTER TABLE " + BattInf_Table
                                                + " ADD COLUMN `SerialNumber` varchar(200) NOT NULL DEFAULT ''");
                            }
                        }
        //---------------------------------------------------------------------------------------------//
        res = sqlMysqlQuery("SELECT * FROM information_schema.columns"
                                + " WHERE table_schema='db_battinf'"
                                + " AND table_name='tb_batt_maint_inf'"
                                + " AND column_name='master_audit'");
        if(false == res.next()) {
            sqlMysqlExecute("ALTER TABLE " + BattMainInf_Table
                            + " ADD COLUMN `fault_type_id` INT NOT NULL DEFAULT 0 AFTER `usr_id`,"
                            + " ADD COLUMN `maint_type_id` INT NOT NULL DEFAULT 0 AFTER `maint_time_limit`,"
                            + " ADD COLUMN `master_audit` INT NOT NULL DEFAULT 0 AFTER `master_id`,"
                            + " ADD COLUMN `maint_close` BOOLEAN NOT NULL DEFAULT FALSE AFTER `maint_done_time`,"
                            + " ADD COLUMN `appoint_uid` INT NOT NULL DEFAULT 0 AFTER `master_audit`,"
                            + " ADD COLUMN `copy_uids` VARCHAR(200) NOT NULL DEFAULT ' ' AFTER `master_audit`");
        }
        //---------------------------------------------------------------------------------------------//
        //---------------------------------------------------------------------------------------------//
        res = sqlMysqlQuery("show index from " + BattTestDataInf_Table + " where column_name='test_starttime'");
        if(false == res.next())
        {
            sqlMysqlExecute("ALTER TABLE " + BattTestDataInf_Table + " ADD INDEX `index_test_record_count` (`test_record_count` ASC);");
            sqlMysqlExecute("ALTER TABLE " + BattTestDataInf_Table + " ADD INDEX `index_test_type` (`test_type` ASC);");
            sqlMysqlExecute("ALTER TABLE " + BattTestDataInf_Table + " ADD INDEX `index_test_starttime` (`test_starttime` ASC);");
        }
        //---------------------------------------------------------------------------------------------//
        //---------------------------------------------------------------------------------------------//
        res = sqlMysqlQuery("show index from " + BattResDataInf_Table + " where column_name='test_starttime'");
        if(false == res.next())
        {
            sqlMysqlExecute("ALTER TABLE " + BattResDataInf_Table + " ADD INDEX `index_test_record_count` (`test_record_count` ASC);");
            sqlMysqlExecute("ALTER TABLE " + BattResDataInf_Table + " ADD INDEX `index_test_type` (`test_type` ASC);");
            sqlMysqlExecute("ALTER TABLE " + BattResDataInf_Table + " ADD INDEX `index_test_starttime` (`test_starttime` ASC);");
        }
        //---------------------------------------------------------------------------------------------//
        res = sqlMysqlQuery("SELECT * FROM information_schema.columns"
                                        + " WHERE table_schema='db_batt_testdata'"
                                        + " AND table_name='tb_batttestdata_inf'"
                                        + " AND column_name='test_record_count_ex'");
        if(false == res.next())
        {
            sqlMysqlExecute("ALTER TABLE " + BattTestDataInf_Table
                            + " ADD COLUMN `test_record_count_ex` INT NOT NULL DEFAULT 0 AFTER `test_record_count`,"
                            + " ADD COLUMN `test_starttime_ex` DATETIME NOT NULL DEFAULT '1920-01-01 00:00:00' AFTER `test_starttime`,"
                            + " ADD COLUMN `upload_usr_id` INT NOT NULL DEFAULT 0 AFTER `mon_vol`");
        }
        //---------------------------------------------------------------------------------------------//
        //---------------------------------------------------------------------------------------------//
        res = sqlMysqlQuery("SELECT * FROM information_schema.columns"
                                                + " WHERE table_schema='db_batt_testdata'"
                                                + " AND table_name='tb_batttestdata_inf'"
                                                + " AND column_name='upload_data_ext'");
        if(false == res.next())
        {
            sqlMysqlExecute("ALTER TABLE " + BattTestDataInf_Table
                            + " ADD COLUMN `upload_data_ext` INT NOT NULL DEFAULT 0 AFTER `upload_usr_id`,"
                            + " ADD COLUMN `upload_client_type` INT NOT NULL DEFAULT 0 AFTER `upload_data_ext`");
            sqlMysqlExecute("ALTER TABLE " + BattResDataInf_Table
                            + " ADD COLUMN `upload_client_type` INT NOT NULL DEFAULT 0 AFTER `upload_usr_id`");
        }
        //---------------------------------------------------------------------------------------------//
        //----------------------------将num自增字段改为bigint类型---------------------------------------//
        res = sqlMysqlQuery("SELECT DATA_TYPE FROM information_schema.columns"
                                        + " WHERE table_schema='db_batt_testdata'"
                                        + " AND table_name='tb_batttestdata_inf'"
                                        + " AND column_name='num'");
        if(true == res.next()) {
            if(false == "bigint".equals(res.getString("DATA_TYPE").toLowerCase())) {
                sqlMysqlExecute("ALTER TABLE " + BattTestDataInf_Table + " MODIFY COLUMN num BIGINT NOT NULL AUTO_INCREMENT;");
                sqlMysqlExecute("ALTER TABLE " + BattResDataInf_Table + " MODIFY COLUMN num BIGINT NOT NULL AUTO_INCREMENT;");
            }
        }
        //---------------------------------------------------------------------------------------------//
        //-----------------------------  tb_fbsdev_statechange_inf 表中新增2个字段  ----------------------------------------------------------------//
        res = sqlMysqlQuery("SELECT DATA_TYPE FROM information_schema.columns"
                + " WHERE table_schema='db_app_sys'"
                + " AND table_name='tb_fbsdev_statechange_inf'"
                + " AND column_name='eve_type'");
        if(false == res.next()) {
            sqlMysqlExecute("ALTER TABLE " + FBSDevStateChangeInf_Table
                    + " ADD COLUMN `eve_type` int DEFAULT 0;");
        }
        res = sqlMysqlQuery("SELECT DATA_TYPE FROM information_schema.columns"
                + " WHERE table_schema='db_app_sys'"
                + " AND table_name='tb_fbsdev_statechange_inf'"
                + " AND column_name='module_num'");
        if(false == res.next()) {
            sqlMysqlExecute("ALTER TABLE " + FBSDevStateChangeInf_Table
                    + " ADD COLUMN `module_num` int DEFAULT 0;");
        }
    }
    //使用db数据库
    public void sqlMysqlUseDB(String db) throws SQLException
    {
        sqlMysqlExecute("use " + db);
    }
    //获取电池组机房的个数
    public int getBattStationCount()
    {
        int st_count = 0;
        try {
            sqlMysqlUseDB(Sql_Mysql.DB_BATT_INF);
            String sql_str = "SELECT DISTINCT StationId FROM " + BattInf_Table;
            ResultSet res = sqlMysqlQuery(sql_str);
            while(res.next())
            {
                st_count++;
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return st_count;
    }
    /**
     * 检查tb表是否存在
     * @param tb
     * @return
     * @throws SQLException
     */
    public boolean sqlMysqlCheckIfTableExist(String tb) throws SQLException
    {
        String sql_str = "SHOW TABLES LIKE '" + tb + "'";
        ResultSet res = sqlMysqlQuery(sql_str);
        boolean exist = false;
        while(res.next())
        {
            exist = true;
            break;
        }
        return exist;
    }
    //执行sql语句
    public void sqlMysqlExecute(String sql_str) throws SQLException
    {
        Statement sql = mysql_con.createStatement();
        sql.setQueryTimeout(30);
        sql.execute(sql_str);
    }
    //在事物中执行多条sql语句
    public boolean makeManualCommit(ArrayList<String> al_sql_strs)
    {
        boolean exe_res = true;
        try {
            mysql_con.setAutoCommit(false);
            for(int n=0; n<al_sql_strs.size(); n++) {
                sqlMysqlExecute(al_sql_strs.get(n));
            }
            if(true == exe_res) {
                mysql_con.commit();
            }
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            exe_res = false;
        } finally {
            try {
                if(false == exe_res) {
                    mysql_con.rollback();
                }
                mysql_con.setAutoCommit(true);
            } catch (SQLException e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
            }
        }
        return exe_res;
    }
    //根据sql语句执行sql查询语句
    public ResultSet sqlMysqlQuery(String sql_str)
    {
        ResultSet res = null;
        try
        {
            Statement sql = mysql_con.createStatement();
            sql.setQueryTimeout(30);
            String query = sql_str;
            res =  sql.executeQuery(query);
        }
        catch(SQLException ex)
        {
            System.err.println("SQLException:" + ex.getMessage());
        }
        return res;
    }
    //根据sql语句执行sql更新语句
    public void sqlMysqlUpdate(String sql_str)
    {
        try
        {
            Statement sql = mysql_con.createStatement();
            sql.setQueryTimeout(30);
            String query = sql_str;
            sql.execute(query);
        }
        catch(SQLException ex)
        {
            System.out.println("SQLException:" + ex.getMessage());
        }
    }
    //根据电池组id 获取机房名称
    public String getStationName(int bg_id)
    {
        String stname = " ";
        String sql_str = "SELECT DISTINCT StationName FROM "
                            + Sql_Mysql.BattInf_Table + " WHERE BattGroupId=" + bg_id;
        ResultSet res = sqlMysqlQuery(sql_str);
        try {
            if(res.next())
            {
                stname = res.getString("StationName");
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return stname;
    }
    //根据电池组id 获取电池组名称
    public String getBattGroupName(int bg_id)
    {
        String bgname = " ";
        String sql_str = "SELECT DISTINCT BattGroupName FROM "
                            + Sql_Mysql.BattInf_Table + " WHERE BattGroupId=" + bg_id;
        ResultSet res = sqlMysqlQuery(sql_str);
        try {
            if(res.next())
            {
                bgname = res.getString("BattGroupName");
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return bgname;
    }
    //根据用户的id获取用户的名称
    public String getUsrName(int uid)
    {
        String usrname = " ";
        String sql_str = "SELECT uName FROM " + Sql_Mysql.UserInfTable + " WHERE uId=" + uid;
        ResultSet res = sqlMysqlQuery(sql_str);
        try {
            if(res.next())
            {
                usrname = res.getString("uName");
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return usrname;
    }
    //根据format_type 获取format_str 的样式
    public String getTaskSmsFormatStr(String format_type)
    {
        String str = "";
        String sql_str = "SELECT DISTINCT "
                        + Sql_Mysql.UserSmsFormatTable + ".format_str"
                        + " FROM " + Sql_Mysql.UserSmsFormatTable
                        + " WHERE "
                        + Sql_Mysql.UserSmsFormatTable + ".format_type='" + format_type + "'";
        ResultSet sql_res = sqlMysqlQuery(sql_str);
        try {
            if(sql_res.next())
            {
                str = sql_res.getString("format_str");
            }
        } catch (SQLException e1) {
            // TODO Auto-generated catch block
            //e1.printStackTrace();
        }
        return str;
    }
    //根据作业id获取作业的名称
    public String getUsrTaskName(int taskid)
    {
        String taskname = " ";
        String sql_str = "SELECT task_name FROM " + Sql_Mysql.UserTaskTable + " WHERE task_id=" + taskid;
        ResultSet res = sqlMysqlQuery(sql_str);
        try {
            if(res.next()) {
                taskname = res.getString("task_name");
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return taskname;
    }
    //根据作业id获取用户作业的创建时间
    public String getUsrTaskCreateTime(int taskid)
    {
        String taskcreatetime = " ";
        String sql_str = "SELECT task_create_date FROM " + Sql_Mysql.UserTaskTable + " WHERE task_id=" + taskid;
        ResultSet res = sqlMysqlQuery(sql_str);
        try {
            if(res.next())
            {
                taskcreatetime = Com.getDateTimeFormat(res.getTimestamp("task_create_date"), Com.DTF_YMDhms);
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return taskcreatetime;
    }
    //获取新创建的记录的testrecordcount的值
    public int getBattTestRecordCountNew(int bg_id, String table)
    {
        int count = 0;
        boolean res_exe = true;
        String sql_str0 = "SELECT test_record_count_ex FROM " + table
                            + " WHERE BattGroupId=" + bg_id  + " FOR UPDATE";
        String sql_str1 = "UPDATE " + table + " SET test_record_count_ex=test_record_count+1"
                            + " WHERE BattGroupId=" + bg_id;
        String sql_str2 = "SELECT MAX(test_record_count_ex) FROM " + table
                            + " WHERE BattGroupId=" + bg_id;
        String sql_str3 = "INSERT INTO " + table + " (BattGroupId,test_record_count, test_record_count_ex) "
                            + " VALUES (" + bg_id + "," + 1 + "," + 1 + ")";
        try {
            mysql_con.setAutoCommit(false);
            ResultSet res = sqlMysqlQuery(sql_str0);
            if(res.next()) {
                sqlMysqlExecute(sql_str1);
                res = sqlMysqlQuery(sql_str2);
                if(res.next()) {
                    count = res.getInt(1);
                }
            } else {
                count = 1;
                sqlMysqlExecute(sql_str3);
            }
            mysql_con.commit();
        } catch (SQLException e) {
            e.printStackTrace();
            res_exe = false;
        } finally {
            if(false == res_exe) {
                try {
                    mysql_con.rollback();
                    mysql_con.setAutoCommit(true);
                } catch (SQLException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
        }
        return count;
    }
}
BattMonitor_DB_Builder/src/com/version_inf/version_inf.txt
@@ -1,221 +1,227 @@
V1.389 edit at date 2017-1-3
    1:解决FBS系列实时数据库不更新数据的问题,BattData_RT_Array类中
    rtdata.al_MonVol_RtOld.add(data)修正为rtdata.al_MonVol_RtOld.add(data.clone())。2017-1-3
    (影响范围:FBS系列版本)
V1.388 edit at date 2016-12-27
    1:BattData_RT_Array类中的initBattDataRT_Inf_FromSQL()中增加rtdata.al_MonVol.size()不大于rtdata.MonCount的限制。2016-12-27
    (影响范围:CMCC版本)
V1.387 edit at date 2016-11-02
    1: 将tb_app_sys表中的AppServer_Version的版本最低设定为V1.388,以便V1.087以上的客户端识别服务器端的版本,并作出提示。
    2: 将tb_batttestdata_inf表中的添加upload_data_ext(区分.FBO或.IDC数据)与upload_client_type(
    区分上传的客户端:BS_CLI,CS_CLI,CS_SVR)字段。2016-11-02
    3: 将tb_battresdata_inf表中的添加upload_client_type(区分上传的客户端:BS_CLI,CS_CLI,CS_SVR)字段。2016-11-02
V1.386 edit at date 2016-10-26
    1: 修复通过手机上传.FBO数据时, 放电开始日期时间月份错误的问题,解析的月份比实际的多一个月。(影响范围:全系列版本)- 2016-10-26
V1.385 edit at date 2016-10-15
    1:FBS9600/9600S支持TCP-ModBus协议,此时服务器电池组配置信息中的FBS9600/9600S的设备ID必须设置为9610xxxx。
    ,虽然使用TCP-ModBus协议,但数据包中末尾仍然携带ModBus的CRC16校验。(影响范围:FBS9600/9600S系列) - 2016-10-15
    2:修复读取FBS9100单体内阻数据时倍率错误的问题,由之前的0.001改为0.01。(影响范围:FBS9600/9600S系列) - 2016-10-18
    3:修复FBR-5000CT的数据和密特电导仪数据的手机APP上传时服务器端对数据的校对审核问题,由未审核改为审核。
V1.384 edit at date 2016-10-14
    1:支持内阻计FBR-5000CT的数据和密特电导仪数据的手机APP上传。(影响范围:FBS9600) - 2016-10-14
V1.383 edit at date 2016-10-10
    1:该版本以上的FBS系列的在线监测数据保存的最小间隔恢复为10分钟。(影响范围:FBS9600) - 2016-10-10
V1.382 edit at date 2016-10-10
    1:对于FBO版本,实时电池数据只建表,不跟新数据,避免服务器空跑浪费电能。(影响范围:FBO系列) - 2016-10-10
    2:修复电池组信息为空时,实时内存表数据插入语句错误的问题,此时不进行内存表建表与数据插入操作。(影响范围:全系列) - 2016-10-10
    3: 该版本的FBS系列的在线监测数据保存的最小间隔为1分钟,为特殊测试版本。(影响范围:FBS9600) - 2016-10-10
V1.380 edit at date 2016-08-23
    1:修复FBS9600通信故障告警延时时间为10秒钟,通信出错重试次数为10次。(影响范围:FBS9600) - 2016-08-23
V1.379 edit at date 2016-08-02
    1:变更虚拟假负载支持判断”拉闸放电“与”非拉闸放电“的区分,需配套V1.076以上的客户端。(影响范围:全系列版本) - 2016-08-01
    2:修复FBS9600通信包里CRC16高低字节顺序的问题,此前由于用以太网通信而未使用CRC16校验。(影响范围:FBS9600) - 2016-08-01
V1.378 edit at date 2016-07-13
    1:添加作业变更管理数据库表。(影响范围:BMP7100) - 2016-06-23
V1.377 edit at date 2016-06-23
    1:修复bpm7100模块通信故障的设备告警工作不正常的问题。(影响范围:BMP7100) - 2016-06-23
V1.376 edit at date 2016-05-19
    1:支持bpm7100模块通信故障数据自动清零,配置文件中"bpm7100_commerr_dataclear_en"选项决定是否启用该功能。(影响范围:BMP7100) - 2016-06-16
    2:将告警的阀值比较由绝对值改为正常值。(影响范围:全系列版本 - 2016-06-16)
V1.375 edit at date 2016-05-19
    1:服务器状态表中增加数据库连接数量查询
    2:数据库增加自动全备份功能,备份时间间隔在配置文件中设置,最新备份时间在db_app_sys.tb_app_sys中查询。(影响范围:全系列版本)
V1.374 edit at date 2016-05-19
    1:服务器状态表中增加服务器端所在盘符的硬盘存储容量查询和数据库连接数量查询
V1.373 edit at date 2016-05-19
    1: 电池测试数据增加组端温度,没有改变数据表结构,只是增加一笔数据插入,mon_num=100010,mon_vol=组端温度。(影响范围:BMP7100) - 2016-05-19
    2:服务器端实时数据库表数据中,增加组端温度。(影响范围:全系列版本) - 2016-05-19。
V1.372 edit at date 2016-05-17
    1: 增加FBS9600和BPM7100 socket通信出错多次重试功能,以增加通信可靠性。(影响范围:FBS9600和BMP7100) - 2016-05-17。
V1.371 edit at date 2016-05-10
    1: 修改BMP7100的数据监测记录逻辑,取消电压变化阀值保存功能。(影响范围:BMP7100) - 2016-05-10。
V1.37 edit at date 2016-04-24
    1: “BattDataTestPro_Thread”使用Timer Task定时执行相关任务(影响范围:全系列版本)。
    2: 电池实时状态和数据使用数据库内存表(影响范围:全系列版本)。
    3: 增加设备通信故障告警(影响范围:全系列版本,FBO版本除外)- 2016-04-26。
    4:电池告警数据表与设备告警数据表的自增字段num类型改为BIGINT类型,避免该字段因到达最大值而造成insert操作出错。
V1.36 edit at date 2016-04-23
    1: class "BattStatData" add a member "recordNum_BPM7100" witch type is int,
    "recordNum_BPM7100" is used by function "check_If_Bpm7100_DataNeedStore()" in class "BattData_RT"
    and is used by function "bpm7100_init(byte batt_state)" int class "BattStatData",
    "recordNum_BPM7100" is used to determine if data_record_count is upto "mTestDataRecordCountMax"
    and then pause inser data to mysql db.(影响范围:Bpm7100版本)
V1.36 edit at date 2016-04-18
    1: class "BattData_RT" add a function "check_If_Bpm7100_DataNeedStore()" for BPM_7100 monitor only,
        It's called in class thread function "run()" in class "BattDataTestPro_Thread".
    2: class "BattStatData" add a boolean type member "bpm7100_runState", It's used to determine wether
        the BPM_7100 system is in "monitor" state witch will work data process and save data into mysql db,
        like dischage and charge test.(影响范围:Bpm7100版本)
V1.36 edit at date 2016-04-16
    1: 数据表TB_BattInf增加了机房名称、电池组名、机房ID、电池组ID索引,测试数据增加了电池组ID、测试日期索引
    (影响范围:全系列版本)。
V1.37 edit at date 2019-01-08
    1.在web_site数据库下新建线程帮助表用于手动启动某些线程
V1.38 edit at date 2019-01-08
    1.修复了无论是否重建表都需要重建  db_ram_db.tb_server_state 表,  ---》修复前期数据库表格式bug    MEMORY  ->   InnoDB
V1.39 edit at date 2019-07-15
    1.在web_site数据库中添加了tb_batt_discharge表用于存放机房放电黑名单表
V1.40 edit at date 2019-07-30
    1.在db_app_sys.tb_app_sys表中添加AppServer_Reinit_BattGroupData_LD9_EN字段用于9度设备重载设备数据
V1.41 edit at date 2019-08-13
    1.在运行程序时检测机房状态表中的机房id和设备id的对应关系并且进行修复
V1.42 edit at date 2019-08-30
    1.在’db_ram_db‘数据库中创建‘tb_61850_jhstate’表,用于存储61850均衡供电参数信息
V1.43 edit at date 2019-09-24
    1.在'db_ram_db'数据库中的表'tb_fbs9100_setparam'表中添加61850中的在线压低和离线续航周期值
    2.在'db_battinf'数据库中的表'tb_battinf'中添加紫晶那边的电池组信息列
V1.44 edit at date 2019-12-01
    1.在'web_site'数据库中的表'tb_battmap_information'表中添加stationName3字段用于判断
V1.45 edit at date 2019-12-01
    1.程序运行结束后重启告警线程(修改线程监控中的运行状态)
    2.用户表中添加三个字段用于UKEY判断
    3.电池组信息中也添加了4个UKEY字段用户UKEY校验
    4.机房电池组更换记录查询中添加GroupIndexInFBSDevice字段用于标识更换的哪一组电池
V1.46 edit at date 2020-06-10
    1.修复因db_ram_db.tb_fbs9100_state表中dev_version字段过短bug
V1.47 edit at date 2020-06-10
    1.修复因电池组id不存在在电池放电测试中记录用户添加过放电的记录机房不存在,无法删除bug
V1.48 edit at date 2020-06-10
    1.在db_ram_db.tb_fbs9100_state表中添加"dev_conresist1"字段用于显示组2接触器导通阻抗
V1.49 edit at date 2020-08-01
    1.在web_site数据库中新建tb_dev_restart_plan表用于设备重启计划操作
    2.在线程监控管理表中添加6度通讯线程的服务信息
V1.50 edit at date 2020-10-16
    1.在db_ram_db.tb_batt_rtdata表中添加'mon_LY_vol'字段用于表示单体漏液电压信息。
    2.在db_ram_db.tb_fbs9100s_fod_param表中添加第5个模块的除硫参数字段信息
    3.在db_ram_db.tb_fbs9100s_fod_state表中添加'BattGroupId'字段并设置成唯一索引
V1.51 edit at date 2020-10-18
    1.在db_ram_db库中添加逆变信息表'tb_fbs9100s_nibian_state'的创建
V1.52 edit at date 2021-01-13
    1.添加电源信息库的创建语句
    2.添加绝缘装置,充电机的创建语句
V1.53 edit at date 2021-03-08
    1.在线程监控管理表中默认添加通信电源通讯程序线程记录
V1.54 edit at date 2021-04-22
    1.添加用户表的建表语句以及单表中无数据时添加默认账号([admin:admin][superuser:1])
    2.添加权限表的建表语句,默认添加超级管理员权限组普通权限组
    3.添加用户权限组的建表语句,默认给初始用户添加权限
    4.添加平台注册信息表以及对应字段格式修改字段
    5.添加用户数据库中的表的建表语句
    6.添加电池组信息配置表中的扩展字段的添加
    [针对linux系统安装平台时重要的表未创建添加]
V1.55 edit at date 2021-05-07
    1.'db_pwrdev_data_rt`.`tb_pwrdev_acdcdata' 表中新增温湿度传感器相关字段
    2.新增`db_ram_db`.`tb_lithium_data`表用于更新锂电池实时数据
V1.56 edit at date 2021-06-08
    1.新增用户登陆限制表'db_user.tb_user_limit'
    2.用户表新增'login_type'[登陆状态]字段
    3.新增南京送检蓄电池告警表'db_ram_db.tb_batt_rtalarm'和'db_ram_db.tb_batt_rsalarm'表的建表语句
V1.57 edit at date 2021-06-21
    1.新增通讯电源对应的数据表:'tb_pwrapp_stainf','tb_pwrapp_dcinf','tb_pwrapp_acinf','tb_pwrapp_acdcinf','tb_display_config'表
    2.tb_pwrdev_inf表新增'runCompany'字段
    2.'web_site.tb_process_survey'新增南网通信电源监控线程'BMS_POWER_MONITOR'数据
V1.58 edit at date 2021-06-24
    1.新增"`db_app_sys`.`tb_menu`"表创建,用户fg平台导航配置
V1.59 edit at date 2021-07-02
    1.新建'db_user.`tb_user_log`'数据库表
V1.60 edit at date 2021-07-08
    1.新建'db_ram_db.`tb_fbs9100s_buscouple_state`'-->'母联开关状态表'数据库表
    1.新建'db_ram_db.`tb_fbs9100s_stemnode_state`'-->'干接点状态表'数据库表
V1.61 edit at date 2021-07-12
    1.线程监控表新增线程记录"ProcessId:11017",'BMS_BATT_LOADUPDATE','蓄电池负载更新线程'---默认启动
V1.62 edit at date 2021-07-20
    1.表'db_ram_db.tb_fbs9100_setparam'新增FGCD_A059设备相关的参数列字段
    2.修复'db_ram_db.tb_bts_gprs_state'表中初始化字段错误bug
V1.63 edit at date 2021-07-27
    1.表'db_ram_db.tb_fbs9100_setparam'新增一体机恒流参数字段
V1.64 edit at date 2021-08-09
    1.表'db_ram_db.tb_fbs9100_setparam'修改一体机参数充电过温'CharHighTmp' int --->float
V1.65 edit at date 2021-08-10
    1.新增默认线程监控中新增"充放电一体机通讯线程"  ------------->服务名称:"BMS_BATT_FGCD_A059"     线程ID:"11018"
V1.66 edit at date 2021-08-10
    1.修改充放电一体机温度阀值默认值为45
    2.db_app_sys.tb_app_sys新增列'AppServer_Reinit_BattGroupData_A059_EN'用于通讯程序新增机房时数据动态录入
V1.67 edit at date 2021-08-17
    1.db_battinf.tb_battinf表新增视频链接地址字段'video_url'
    2.db_battinf.tb_battinf表新增逆变充放电状态'charge_type'和母联状态'buscouple_state'
    3.新增数据库db_fbo_testdata,用于存放从充放电一体机导入的历史数据文件
    4.在数据库'db_fbo_testdata'中新增表'tb_fbotestdata_inf'用于存放历史数据导入记录
    5.新增'db_ram_db.tb_fgcd_filedownload'表用于充放电一体机历史数据远程导入
V1.68 edit at date 2021-08-24
    1.db_battinf.tb_battinf表新增'uRole'字段'告警角色:0-管理员、1-维护组长、2-维护组员'
V1.69 edit at date 2021-08-30
    1.db_ram_db.tb_fbs9100_sysparam 新增'JunHeng_Enabled'-均衡启用状态,'JunHeng_StVol'-均衡停止电压阀值,'JunHeng_StCurr'-均衡停止电流阀值
V1.70 edit at date 2021-8-31
    1:解决APP和平台界面告警派单功能,db_alarm数据库中`tb_battalarm_data`,`tb_devalarm_data`
    数据库中均添加两个字段work_flag,msg_flag(‘tinyint’)
V1.389 edit at date 2017-1-3
    1:解决FBS系列实时数据库不更新数据的问题,BattData_RT_Array类中
    rtdata.al_MonVol_RtOld.add(data)修正为rtdata.al_MonVol_RtOld.add(data.clone())。2017-1-3
    (影响范围:FBS系列版本)
V1.388 edit at date 2016-12-27
    1:BattData_RT_Array类中的initBattDataRT_Inf_FromSQL()中增加rtdata.al_MonVol.size()不大于rtdata.MonCount的限制。2016-12-27
    (影响范围:CMCC版本)
V1.387 edit at date 2016-11-02
    1: 将tb_app_sys表中的AppServer_Version的版本最低设定为V1.388,以便V1.087以上的客户端识别服务器端的版本,并作出提示。
    2: 将tb_batttestdata_inf表中的添加upload_data_ext(区分.FBO或.IDC数据)与upload_client_type(
    区分上传的客户端:BS_CLI,CS_CLI,CS_SVR)字段。2016-11-02
    3: 将tb_battresdata_inf表中的添加upload_client_type(区分上传的客户端:BS_CLI,CS_CLI,CS_SVR)字段。2016-11-02
V1.386 edit at date 2016-10-26
    1: 修复通过手机上传.FBO数据时, 放电开始日期时间月份错误的问题,解析的月份比实际的多一个月。(影响范围:全系列版本)- 2016-10-26
V1.385 edit at date 2016-10-15
    1:FBS9600/9600S支持TCP-ModBus协议,此时服务器电池组配置信息中的FBS9600/9600S的设备ID必须设置为9610xxxx。
    ,虽然使用TCP-ModBus协议,但数据包中末尾仍然携带ModBus的CRC16校验。(影响范围:FBS9600/9600S系列) - 2016-10-15
    2:修复读取FBS9100单体内阻数据时倍率错误的问题,由之前的0.001改为0.01。(影响范围:FBS9600/9600S系列) - 2016-10-18
    3:修复FBR-5000CT的数据和密特电导仪数据的手机APP上传时服务器端对数据的校对审核问题,由未审核改为审核。
V1.384 edit at date 2016-10-14
    1:支持内阻计FBR-5000CT的数据和密特电导仪数据的手机APP上传。(影响范围:FBS9600) - 2016-10-14
V1.383 edit at date 2016-10-10
    1:该版本以上的FBS系列的在线监测数据保存的最小间隔恢复为10分钟。(影响范围:FBS9600) - 2016-10-10
V1.382 edit at date 2016-10-10
    1:对于FBO版本,实时电池数据只建表,不跟新数据,避免服务器空跑浪费电能。(影响范围:FBO系列) - 2016-10-10
    2:修复电池组信息为空时,实时内存表数据插入语句错误的问题,此时不进行内存表建表与数据插入操作。(影响范围:全系列) - 2016-10-10
    3: 该版本的FBS系列的在线监测数据保存的最小间隔为1分钟,为特殊测试版本。(影响范围:FBS9600) - 2016-10-10
V1.380 edit at date 2016-08-23
    1:修复FBS9600通信故障告警延时时间为10秒钟,通信出错重试次数为10次。(影响范围:FBS9600) - 2016-08-23
V1.379 edit at date 2016-08-02
    1:变更虚拟假负载支持判断”拉闸放电“与”非拉闸放电“的区分,需配套V1.076以上的客户端。(影响范围:全系列版本) - 2016-08-01
    2:修复FBS9600通信包里CRC16高低字节顺序的问题,此前由于用以太网通信而未使用CRC16校验。(影响范围:FBS9600) - 2016-08-01
V1.378 edit at date 2016-07-13
    1:添加作业变更管理数据库表。(影响范围:BMP7100) - 2016-06-23
V1.377 edit at date 2016-06-23
    1:修复bpm7100模块通信故障的设备告警工作不正常的问题。(影响范围:BMP7100) - 2016-06-23
V1.376 edit at date 2016-05-19
    1:支持bpm7100模块通信故障数据自动清零,配置文件中"bpm7100_commerr_dataclear_en"选项决定是否启用该功能。(影响范围:BMP7100) - 2016-06-16
    2:将告警的阀值比较由绝对值改为正常值。(影响范围:全系列版本 - 2016-06-16)
V1.375 edit at date 2016-05-19
    1:服务器状态表中增加数据库连接数量查询
    2:数据库增加自动全备份功能,备份时间间隔在配置文件中设置,最新备份时间在db_app_sys.tb_app_sys中查询。(影响范围:全系列版本)
V1.374 edit at date 2016-05-19
    1:服务器状态表中增加服务器端所在盘符的硬盘存储容量查询和数据库连接数量查询
V1.373 edit at date 2016-05-19
    1: 电池测试数据增加组端温度,没有改变数据表结构,只是增加一笔数据插入,mon_num=100010,mon_vol=组端温度。(影响范围:BMP7100) - 2016-05-19
    2:服务器端实时数据库表数据中,增加组端温度。(影响范围:全系列版本) - 2016-05-19。
V1.372 edit at date 2016-05-17
    1: 增加FBS9600和BPM7100 socket通信出错多次重试功能,以增加通信可靠性。(影响范围:FBS9600和BMP7100) - 2016-05-17。
V1.371 edit at date 2016-05-10
    1: 修改BMP7100的数据监测记录逻辑,取消电压变化阀值保存功能。(影响范围:BMP7100) - 2016-05-10。
V1.37 edit at date 2016-04-24
    1: “BattDataTestPro_Thread”使用Timer Task定时执行相关任务(影响范围:全系列版本)。
    2: 电池实时状态和数据使用数据库内存表(影响范围:全系列版本)。
    3: 增加设备通信故障告警(影响范围:全系列版本,FBO版本除外)- 2016-04-26。
    4:电池告警数据表与设备告警数据表的自增字段num类型改为BIGINT类型,避免该字段因到达最大值而造成insert操作出错。
V1.36 edit at date 2016-04-23
    1: class "BattStatData" add a member "recordNum_BPM7100" witch type is int,
    "recordNum_BPM7100" is used by function "check_If_Bpm7100_DataNeedStore()" in class "BattData_RT"
    and is used by function "bpm7100_init(byte batt_state)" int class "BattStatData",
    "recordNum_BPM7100" is used to determine if data_record_count is upto "mTestDataRecordCountMax"
    and then pause inser data to mysql db.(影响范围:Bpm7100版本)
V1.36 edit at date 2016-04-18
    1: class "BattData_RT" add a function "check_If_Bpm7100_DataNeedStore()" for BPM_7100 monitor only,
        It's called in class thread function "run()" in class "BattDataTestPro_Thread".
    2: class "BattStatData" add a boolean type member "bpm7100_runState", It's used to determine wether
        the BPM_7100 system is in "monitor" state witch will work data process and save data into mysql db,
        like dischage and charge test.(影响范围:Bpm7100版本)
V1.36 edit at date 2016-04-16
    1: 数据表TB_BattInf增加了机房名称、电池组名、机房ID、电池组ID索引,测试数据增加了电池组ID、测试日期索引
    (影响范围:全系列版本)。
V1.37 edit at date 2019-01-08
    1.在web_site数据库下新建线程帮助表用于手动启动某些线程
V1.38 edit at date 2019-01-08
    1.修复了无论是否重建表都需要重建  db_ram_db.tb_server_state 表,  ---》修复前期数据库表格式bug    MEMORY  ->   InnoDB
V1.39 edit at date 2019-07-15
    1.在web_site数据库中添加了tb_batt_discharge表用于存放机房放电黑名单表
V1.40 edit at date 2019-07-30
    1.在db_app_sys.tb_app_sys表中添加AppServer_Reinit_BattGroupData_LD9_EN字段用于9度设备重载设备数据
V1.41 edit at date 2019-08-13
    1.在运行程序时检测机房状态表中的机房id和设备id的对应关系并且进行修复
V1.42 edit at date 2019-08-30
    1.在’db_ram_db‘数据库中创建‘tb_61850_jhstate’表,用于存储61850均衡供电参数信息
V1.43 edit at date 2019-09-24
    1.在'db_ram_db'数据库中的表'tb_fbs9100_setparam'表中添加61850中的在线压低和离线续航周期值
    2.在'db_battinf'数据库中的表'tb_battinf'中添加紫晶那边的电池组信息列
V1.44 edit at date 2019-12-01
    1.在'web_site'数据库中的表'tb_battmap_information'表中添加stationName3字段用于判断
V1.45 edit at date 2019-12-01
    1.程序运行结束后重启告警线程(修改线程监控中的运行状态)
    2.用户表中添加三个字段用于UKEY判断
    3.电池组信息中也添加了4个UKEY字段用户UKEY校验
    4.机房电池组更换记录查询中添加GroupIndexInFBSDevice字段用于标识更换的哪一组电池
V1.46 edit at date 2020-06-10
    1.修复因db_ram_db.tb_fbs9100_state表中dev_version字段过短bug
V1.47 edit at date 2020-06-10
    1.修复因电池组id不存在在电池放电测试中记录用户添加过放电的记录机房不存在,无法删除bug
V1.48 edit at date 2020-06-10
    1.在db_ram_db.tb_fbs9100_state表中添加"dev_conresist1"字段用于显示组2接触器导通阻抗
V1.49 edit at date 2020-08-01
    1.在web_site数据库中新建tb_dev_restart_plan表用于设备重启计划操作
    2.在线程监控管理表中添加6度通讯线程的服务信息
V1.50 edit at date 2020-10-16
    1.在db_ram_db.tb_batt_rtdata表中添加'mon_LY_vol'字段用于表示单体漏液电压信息。
    2.在db_ram_db.tb_fbs9100s_fod_param表中添加第5个模块的除硫参数字段信息
    3.在db_ram_db.tb_fbs9100s_fod_state表中添加'BattGroupId'字段并设置成唯一索引
V1.51 edit at date 2020-10-18
    1.在db_ram_db库中添加逆变信息表'tb_fbs9100s_nibian_state'的创建
V1.52 edit at date 2021-01-13
    1.添加电源信息库的创建语句
    2.添加绝缘装置,充电机的创建语句
V1.53 edit at date 2021-03-08
    1.在线程监控管理表中默认添加通信电源通讯程序线程记录
V1.54 edit at date 2021-04-22
    1.添加用户表的建表语句以及单表中无数据时添加默认账号([admin:admin][superuser:1])
    2.添加权限表的建表语句,默认添加超级管理员权限组普通权限组
    3.添加用户权限组的建表语句,默认给初始用户添加权限
    4.添加平台注册信息表以及对应字段格式修改字段
    5.添加用户数据库中的表的建表语句
    6.添加电池组信息配置表中的扩展字段的添加
    [针对linux系统安装平台时重要的表未创建添加]
V1.55 edit at date 2021-05-07
    1.'db_pwrdev_data_rt`.`tb_pwrdev_acdcdata' 表中新增温湿度传感器相关字段
    2.新增`db_ram_db`.`tb_lithium_data`表用于更新锂电池实时数据
V1.56 edit at date 2021-06-08
    1.新增用户登陆限制表'db_user.tb_user_limit'
    2.用户表新增'login_type'[登陆状态]字段
    3.新增南京送检蓄电池告警表'db_ram_db.tb_batt_rtalarm'和'db_ram_db.tb_batt_rsalarm'表的建表语句
V1.57 edit at date 2021-06-21
    1.新增通讯电源对应的数据表:'tb_pwrapp_stainf','tb_pwrapp_dcinf','tb_pwrapp_acinf','tb_pwrapp_acdcinf','tb_display_config'表
    2.tb_pwrdev_inf表新增'runCompany'字段
    2.'web_site.tb_process_survey'新增南网通信电源监控线程'BMS_POWER_MONITOR'数据
V1.58 edit at date 2021-06-24
    1.新增"`db_app_sys`.`tb_menu`"表创建,用户fg平台导航配置
V1.59 edit at date 2021-07-02
    1.新建'db_user.`tb_user_log`'数据库表
V1.60 edit at date 2021-07-08
    1.新建'db_ram_db.`tb_fbs9100s_buscouple_state`'-->'母联开关状态表'数据库表
    1.新建'db_ram_db.`tb_fbs9100s_stemnode_state`'-->'干接点状态表'数据库表
V1.61 edit at date 2021-07-12
    1.线程监控表新增线程记录"ProcessId:11017",'BMS_BATT_LOADUPDATE','蓄电池负载更新线程'---默认启动
V1.62 edit at date 2021-07-20
    1.表'db_ram_db.tb_fbs9100_setparam'新增FGCD_A059设备相关的参数列字段
    2.修复'db_ram_db.tb_bts_gprs_state'表中初始化字段错误bug
V1.63 edit at date 2021-07-27
    1.表'db_ram_db.tb_fbs9100_setparam'新增一体机恒流参数字段
V1.64 edit at date 2021-08-09
    1.表'db_ram_db.tb_fbs9100_setparam'修改一体机参数充电过温'CharHighTmp' int --->float
V1.65 edit at date 2021-08-10
    1.新增默认线程监控中新增"充放电一体机通讯线程"  ------------->服务名称:"BMS_BATT_FGCD_A059"     线程ID:"11018"
V1.66 edit at date 2021-08-10
    1.修改充放电一体机温度阀值默认值为45
    2.db_app_sys.tb_app_sys新增列'AppServer_Reinit_BattGroupData_A059_EN'用于通讯程序新增机房时数据动态录入
V1.67 edit at date 2021-08-17
    1.db_battinf.tb_battinf表新增视频链接地址字段'video_url'
    2.db_battinf.tb_battinf表新增逆变充放电状态'charge_type'和母联状态'buscouple_state'
    3.新增数据库db_fbo_testdata,用于存放从充放电一体机导入的历史数据文件
    4.在数据库'db_fbo_testdata'中新增表'tb_fbotestdata_inf'用于存放历史数据导入记录
    5.新增'db_ram_db.tb_fgcd_filedownload'表用于充放电一体机历史数据远程导入
V1.68 edit at date 2021-08-24
    1.db_battinf.tb_battinf表新增'uRole'字段'告警角色:0-管理员、1-维护组长、2-维护组员'
V1.69 edit at date 2021-08-30
    1.db_ram_db.tb_fbs9100_sysparam 新增'JunHeng_Enabled'-均衡启用状态,'JunHeng_StVol'-均衡停止电压阀值,'JunHeng_StCurr'-均衡停止电流阀值
V1.70 edit at date 2021-8-31
    1:解决APP和平台界面告警派单功能,db_alarm数据库中`tb_battalarm_data`,`tb_devalarm_data`
    数据库中均添加两个字段work_flag,msg_flag(‘tinyint’)
V1.71 edit at date 2021-9-6
    1:db_user库新建表tb_user_work、tb_work_alarm,db_alarm数据库中新建表`tb_alarm_message`
BattMonitor_DB_Builder/src/main/main_BTS_DB_Builder.java
@@ -1,205 +1,205 @@
package main;
import java.sql.SQLException;
import java.util.Date;
import com.base.Com;
import com.battdata_rt.BattData_RT_RamDB_Thread_SQL;
import com.config.AppConfig;
import com.database_util.DB_Alarm;
import com.database_util.DB_App_Sys;
import com.database_util.DB_Batt_History;
import com.database_util.DB_Fbo_testdata;
import com.database_util.DB_Ld9_Testdata;
import com.database_util.DB_Param;
import com.database_util.DB_Pwrdev_Alarm;
import com.database_util.DB_Pwrdev_Data_Rt;
import com.database_util.DB_Pwrdev_Inf;
import com.database_util.DB_Ram_db;
import com.database_util.DB_battinf;
import com.database_util.DB_db_user;
import com.database_util.DB_web_site;
import com.dev.fbs9100.FBS9100S_DFU_SQL;
import com.dev.fbs9100.FBS9100_Task_Thread_SQL;
import com.sql.MysqlConnPool;
import com.sql.Sql_Mysql;
public class main_BTS_DB_Builder {
    /**************************************************************************/
    /**************************************************************************/
    public final static boolean app_debug = false;
    public final static float m_VersionNum = (float) 1.69;
    public final static String m_Version = "Welcome To Use BTS DB BUILDER V" + m_VersionNum + " RC_20180908";
    /**************************************************************************/
    /**************************************************************************/
    public static final int DEF_MysqlServerFBS_Port = 3360;
    public static int MysqlServer_Port = DEF_MysqlServerFBS_Port;
    private static AppConfig m_AppConfig;
    private static MysqlConnPool GB_MysqlConnPool;
    /*********************************************************************************************/
    /*********************************************************************************************/
    public static void init(){
        /*//BasicConfigurator.configure();*/
        String ver = m_Version;
        System.out.println("/****************************************************************");
        System.out.println("*****************************************************************");
        System.out.println("****************************************************************/");
        System.out.println(ver);
        System.out.println("App Started At DateTime: " + Com.getDateTimeFormat(new Date(), Com.DTF_YMDhms));
        m_AppConfig = new AppConfig();
        System.out.println("正在连接数据库 DBserver IP:" + m_AppConfig.getMysqlServerIp() + ", port: " + MysqlServer_Port);
        GB_MysqlConnPool = new MysqlConnPool(m_AppConfig.getMysqlServerIp(), MysqlServer_Port, 5);
        Sql_Mysql sql_ck = new Sql_Mysql(GB_MysqlConnPool.getConn());
        if(null != sql_ck.mysql_con) {
            System.out.println("成功连接数据库"
                                + " DBserver IP:" + m_AppConfig.getMysqlServerIp()
                                + ", port: " + MysqlServer_Port
                                + " @ " + Com.getDateTimeFormat(new Date(), Com.DTF_YMDhms));
        }
        try {
            sql_ck.checkAndCreateDB();
        } catch (SQLException e1) {
            e1.printStackTrace();
        } finally {
            sql_ck.close_con();
        }
        /*********************************************************************************/
        boolean recreate_tb = m_AppConfig.getMysqlDB_RecreateEn();
        //初始话db_ram_db数据库
        DB_Ram_db.init(GB_MysqlConnPool, recreate_tb);
        //创建tb_batt_rtstate表格并且将电池组id的值
        BattData_RT_RamDB_Thread_SQL.createBattState_RT_RamDB_Table(GB_MysqlConnPool, recreate_tb);
        //创建tb_batt_rtdata表格并且将电池组id的值
        BattData_RT_RamDB_Thread_SQL.createBattData_RT_RamDB_Table(GB_MysqlConnPool, recreate_tb);
        //创建tb_server_state表并且设置表中的值
        BattData_RT_RamDB_Thread_SQL.createServerState_RamDB_Table(GB_MysqlConnPool, recreate_tb);
        //创建tb_bts_gprs_state表
        BattData_RT_RamDB_Thread_SQL.createBTSGPRSState_Table(GB_MysqlConnPool, recreate_tb);
        //创建tb_fbs9100_battparam表
        BattData_RT_RamDB_Thread_SQL.createBattParam_Table(GB_MysqlConnPool, recreate_tb);
        /*********************************************************************************/
        System.out.println("Recreate RamDB Tables State Is '" + recreate_tb + "'");
        if(true == recreate_tb) {
            //创建tb_fbs9100s_dcdc_data表
            FBS9100_Task_Thread_SQL.createFBS9100S_DCDC_DataTableOnRam(GB_MysqlConnPool);
            //创建CmccPowerData表
            FBS9100_Task_Thread_SQL.createFBS9100CmccPowerDataOnRam(GB_MysqlConnPool);
        }
        //创建tb_fbs9100S_DFU_StateTable表并向表中添加数据[修复数据库中缺失字段bug]
        FBS9100S_DFU_SQL.createFBS9100S_DFU_TableOnRam(GB_MysqlConnPool,recreate_tb);
        //创建tb_fbs9100s_setparam表
        FBS9100_Task_Thread_SQL.createFBS9100SetTestParamTableOnRam(GB_MysqlConnPool,recreate_tb);
        //创建tb_fbs9100s_state表
        FBS9100_Task_Thread_SQL.createFBS9100StateTableOnRam(GB_MysqlConnPool,recreate_tb);
        //创建BTSStationState_Table表
        FBS9100_Task_Thread_SQL.createBTSStationState_TableOnRam(GB_MysqlConnPool,recreate_tb);
        //创建设备状态表
        FBS9100_Task_Thread_SQL.createFBS9100SysParam_TableOnRam(GB_MysqlConnPool,recreate_tb);
        //初始化录入机房状态
        FBS9100_Task_Thread_SQL.insertBTSStationState_TableOnRam(GB_MysqlConnPool);
        //重新纠正机房状态表中的机房id和设备id之间的对应关系
        FBS9100_Task_Thread_SQL.checkBTSStationState_TableOnRam(GB_MysqlConnPool);
        //创建61850均衡模块信息表
        FBS9100_Task_Thread_SQL.createTB_61850_JHState_TableOnRam(GB_MysqlConnPool,recreate_tb);
        //创建61850离线养护计划参数表
        FBS9100_Task_Thread_SQL.createFBS9100_offlineyhplanOnRam(GB_MysqlConnPool, recreate_tb);
        //初始化数据库  db_battinf
        DB_battinf.init(GB_MysqlConnPool, recreate_tb);
        //初始化数据库 web_site
        DB_web_site.init(GB_MysqlConnPool, recreate_tb);
        //初始化数据库 db_user
        DB_db_user.init(GB_MysqlConnPool, recreate_tb);
        //初始化告警数据库 db_alarm
        DB_Alarm.init(GB_MysqlConnPool, recreate_tb);
        //初始化软件配置信息表 db_app_sys
        DB_App_Sys.init(GB_MysqlConnPool, recreate_tb);
        //初始化电池组历史实时记录库 db_batt_history
        DB_Batt_History.init(GB_MysqlConnPool, recreate_tb);
        //初始化9度历史数据数据库  db_ld9_testdata
        DB_Ld9_Testdata.init(GB_MysqlConnPool, recreate_tb);
        //初始化参数数据库 db_param
        DB_Param.init(GB_MysqlConnPool, recreate_tb);
        DB_Pwrdev_Alarm.init(GB_MysqlConnPool, recreate_tb);
        DB_Pwrdev_Data_Rt.init(GB_MysqlConnPool, recreate_tb);
        DB_Pwrdev_Inf.init(GB_MysqlConnPool, recreate_tb);
        //初始化FBO历史文件数据表
        DB_Fbo_testdata.init(GB_MysqlConnPool, recreate_tb);
        //设置重启告警线程
        DB_web_site.setUpThreadRestart(GB_MysqlConnPool);
        if(true == m_AppConfig.getMysqlDB_RecreateEn()) {
            m_AppConfig.setMysqlDB_RecreateEn(false);
            m_AppConfig.writeConfigToXml();
        }
        //修改tb_app_sys表中的关键字,让主程序识别
        for(int i=0;i<5;i++) {
            if(BattData_RT_RamDB_Thread_SQL.updateTb_App_Sys_AppServerTable(GB_MysqlConnPool)) {
                break;
            }
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("BTS DB BUILDER Work Done @ " + Com.getDateTimeFormat(new Date(), Com.DTF_YMDhms));
        /*
        while(true) {
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
        */
    }
    public static void main(String[] args) {
        init();
    }
}
package main;
import java.sql.SQLException;
import java.util.Date;
import com.base.Com;
import com.battdata_rt.BattData_RT_RamDB_Thread_SQL;
import com.config.AppConfig;
import com.database_util.DB_Alarm;
import com.database_util.DB_App_Sys;
import com.database_util.DB_Batt_History;
import com.database_util.DB_Fbo_testdata;
import com.database_util.DB_Ld9_Testdata;
import com.database_util.DB_Param;
import com.database_util.DB_Pwrdev_Alarm;
import com.database_util.DB_Pwrdev_Data_Rt;
import com.database_util.DB_Pwrdev_Inf;
import com.database_util.DB_Ram_db;
import com.database_util.DB_battinf;
import com.database_util.DB_db_user;
import com.database_util.DB_web_site;
import com.dev.fbs9100.FBS9100S_DFU_SQL;
import com.dev.fbs9100.FBS9100_Task_Thread_SQL;
import com.sql.MysqlConnPool;
import com.sql.Sql_Mysql;
public class main_BTS_DB_Builder {
    /**************************************************************************/
    /**************************************************************************/
    public final static boolean app_debug = false;
    public final static float m_VersionNum = (float) 1.71;
    public final static String m_Version = "Welcome To Use BTS DB BUILDER V" + m_VersionNum + " RC_20180908";
    /**************************************************************************/
    /**************************************************************************/
    public static final int DEF_MysqlServerFBS_Port = 3360;
    public static int MysqlServer_Port = DEF_MysqlServerFBS_Port;
    private static AppConfig m_AppConfig;
    private static MysqlConnPool GB_MysqlConnPool;
    /*********************************************************************************************/
    /*********************************************************************************************/
    public static void init(){
        /*//BasicConfigurator.configure();*/
        String ver = m_Version;
        System.out.println("/****************************************************************");
        System.out.println("*****************************************************************");
        System.out.println("****************************************************************/");
        System.out.println(ver);
        System.out.println("App Started At DateTime: " + Com.getDateTimeFormat(new Date(), Com.DTF_YMDhms));
        m_AppConfig = new AppConfig();
        System.out.println("正在连接数据库 DBserver IP:" + m_AppConfig.getMysqlServerIp() + ", port: " + MysqlServer_Port);
        GB_MysqlConnPool = new MysqlConnPool(m_AppConfig.getMysqlServerIp(), MysqlServer_Port, 5);
        Sql_Mysql sql_ck = new Sql_Mysql(GB_MysqlConnPool.getConn());
        if(null != sql_ck.mysql_con) {
            System.out.println("成功连接数据库"
                                + " DBserver IP:" + m_AppConfig.getMysqlServerIp()
                                + ", port: " + MysqlServer_Port
                                + " @ " + Com.getDateTimeFormat(new Date(), Com.DTF_YMDhms));
        }
        try {
            sql_ck.checkAndCreateDB();
        } catch (SQLException e1) {
            e1.printStackTrace();
        } finally {
            sql_ck.close_con();
        }
        /*********************************************************************************/
        boolean recreate_tb = m_AppConfig.getMysqlDB_RecreateEn();
        //初始话db_ram_db数据库
        DB_Ram_db.init(GB_MysqlConnPool, recreate_tb);
        //创建tb_batt_rtstate表格并且将电池组id的值
        BattData_RT_RamDB_Thread_SQL.createBattState_RT_RamDB_Table(GB_MysqlConnPool, recreate_tb);
        //创建tb_batt_rtdata表格并且将电池组id的值
        BattData_RT_RamDB_Thread_SQL.createBattData_RT_RamDB_Table(GB_MysqlConnPool, recreate_tb);
        //创建tb_server_state表并且设置表中的值
        BattData_RT_RamDB_Thread_SQL.createServerState_RamDB_Table(GB_MysqlConnPool, recreate_tb);
        //创建tb_bts_gprs_state表
        BattData_RT_RamDB_Thread_SQL.createBTSGPRSState_Table(GB_MysqlConnPool, recreate_tb);
        //创建tb_fbs9100_battparam表
        BattData_RT_RamDB_Thread_SQL.createBattParam_Table(GB_MysqlConnPool, recreate_tb);
        /*********************************************************************************/
        System.out.println("Recreate RamDB Tables State Is '" + recreate_tb + "'");
        if(true == recreate_tb) {
            //创建tb_fbs9100s_dcdc_data表
            FBS9100_Task_Thread_SQL.createFBS9100S_DCDC_DataTableOnRam(GB_MysqlConnPool);
            //创建CmccPowerData表
            FBS9100_Task_Thread_SQL.createFBS9100CmccPowerDataOnRam(GB_MysqlConnPool);
        }
        //创建tb_fbs9100S_DFU_StateTable表并向表中添加数据[修复数据库中缺失字段bug]
        FBS9100S_DFU_SQL.createFBS9100S_DFU_TableOnRam(GB_MysqlConnPool,recreate_tb);
        //创建tb_fbs9100s_setparam表
        FBS9100_Task_Thread_SQL.createFBS9100SetTestParamTableOnRam(GB_MysqlConnPool,recreate_tb);
        //创建tb_fbs9100s_state表
        FBS9100_Task_Thread_SQL.createFBS9100StateTableOnRam(GB_MysqlConnPool,recreate_tb);
        //创建BTSStationState_Table表
        FBS9100_Task_Thread_SQL.createBTSStationState_TableOnRam(GB_MysqlConnPool,recreate_tb);
        //创建设备状态表
        FBS9100_Task_Thread_SQL.createFBS9100SysParam_TableOnRam(GB_MysqlConnPool,recreate_tb);
        //初始化录入机房状态
        FBS9100_Task_Thread_SQL.insertBTSStationState_TableOnRam(GB_MysqlConnPool);
        //重新纠正机房状态表中的机房id和设备id之间的对应关系
        FBS9100_Task_Thread_SQL.checkBTSStationState_TableOnRam(GB_MysqlConnPool);
        //创建61850均衡模块信息表
        FBS9100_Task_Thread_SQL.createTB_61850_JHState_TableOnRam(GB_MysqlConnPool,recreate_tb);
        //创建61850离线养护计划参数表
        FBS9100_Task_Thread_SQL.createFBS9100_offlineyhplanOnRam(GB_MysqlConnPool, recreate_tb);
        //初始化数据库  db_battinf
        DB_battinf.init(GB_MysqlConnPool, recreate_tb);
        //初始化数据库 web_site
        DB_web_site.init(GB_MysqlConnPool, recreate_tb);
        //初始化数据库 db_user
        DB_db_user.init(GB_MysqlConnPool, recreate_tb);
        //初始化告警数据库 db_alarm
        DB_Alarm.init(GB_MysqlConnPool, recreate_tb);
        //初始化软件配置信息表 db_app_sys
        DB_App_Sys.init(GB_MysqlConnPool, recreate_tb);
        //初始化电池组历史实时记录库 db_batt_history
        DB_Batt_History.init(GB_MysqlConnPool, recreate_tb);
        //初始化9度历史数据数据库  db_ld9_testdata
        DB_Ld9_Testdata.init(GB_MysqlConnPool, recreate_tb);
        //初始化参数数据库 db_param
        DB_Param.init(GB_MysqlConnPool, recreate_tb);
        DB_Pwrdev_Alarm.init(GB_MysqlConnPool, recreate_tb);
        DB_Pwrdev_Data_Rt.init(GB_MysqlConnPool, recreate_tb);
        DB_Pwrdev_Inf.init(GB_MysqlConnPool, recreate_tb);
        //初始化FBO历史文件数据表
        DB_Fbo_testdata.init(GB_MysqlConnPool, recreate_tb);
        //设置重启告警线程
        DB_web_site.setUpThreadRestart(GB_MysqlConnPool);
        if(true == m_AppConfig.getMysqlDB_RecreateEn()) {
            m_AppConfig.setMysqlDB_RecreateEn(false);
            m_AppConfig.writeConfigToXml();
        }
        //修改tb_app_sys表中的关键字,让主程序识别
        for(int i=0;i<5;i++) {
            if(BattData_RT_RamDB_Thread_SQL.updateTb_App_Sys_AppServerTable(GB_MysqlConnPool)) {
                break;
            }
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("BTS DB BUILDER Work Done @ " + Com.getDateTimeFormat(new Date(), Com.DTF_YMDhms));
        /*
        while(true) {
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
        */
    }
    public static void main(String[] args) {
        init();
    }
}