蓄电池监控管理平台数据库初始化程序
whyclj
2019-01-08 ee24e022c8491d531785d3bfddedad4b39a6eac9
初始化web_site数据库中的表
1个文件已添加
6个文件已修改
82 ■■■■■ 已修改文件
BattMonitor_DB_Builder/bin/com/dev/fbs9100/FBS9100_Task_Thread_SQL.class 补丁 | 查看 | 原始文档 | blame | 历史
BattMonitor_DB_Builder/bin/com/sql/Sql_Mysql.class 补丁 | 查看 | 原始文档 | blame | 历史
BattMonitor_DB_Builder/bin/main/main_BTS_DB_Builder.class 补丁 | 查看 | 原始文档 | blame | 历史
BattMonitor_DB_Builder/src/com/database_util/DB_web_site.java 69 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
BattMonitor_DB_Builder/src/com/dev/fbs9100/FBS9100_Task_Thread_SQL.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
BattMonitor_DB_Builder/src/com/sql/Sql_Mysql.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
BattMonitor_DB_Builder/src/main/main_BTS_DB_Builder.java 5 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
BattMonitor_DB_Builder/bin/com/dev/fbs9100/FBS9100_Task_Thread_SQL.class
Binary files differ
BattMonitor_DB_Builder/bin/com/sql/Sql_Mysql.class
Binary files differ
BattMonitor_DB_Builder/bin/main/main_BTS_DB_Builder.class
Binary files differ
BattMonitor_DB_Builder/src/com/database_util/DB_web_site.java
New file
@@ -0,0 +1,69 @@
package com.database_util;
import java.sql.ResultSet;
import java.sql.SQLException;
import com.sql.MysqlConnPool;
import com.sql.Sql_Mysql;
public class DB_web_site {
    public static void init(MysqlConnPool pool, boolean recreate) {
        createWeb_siteDB(pool);                                        //创建website 数据库
        createThread_utilTable(pool,recreate);                        //创建线程控制表
    }
    public static void createWeb_siteDB(MysqlConnPool pool) {
        Sql_Mysql sql = new Sql_Mysql(pool.getConn());
        try {
            sql.sqlMysqlExecute("CREATE DATABASE IF NOT EXISTS " + Sql_Mysql.WEB_Site);
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            sql.close_con();
        }
    }
    public static void createThread_utilTable(MysqlConnPool pool, boolean recreate) {
        String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.ThreadUtil_Table;
        String sql_str02 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.ThreadUtil_Table + " (" +
                "  `num` bigint(20) NOT NULL," +
                "  `thread_id` int(11) NOT NULL COMMENT '线程id'," +
                "  `thread_name` varchar(64) NOT NULL DEFAULT '线程名称'," +
                "  `thread_starttime` datetime NOT NULL DEFAULT '1970-01-01 00:00:00'," +
                "  `thread_en` int(11) NOT NULL DEFAULT '0' COMMENT '是否启动标识位 0:默认   1:需要启动   2:运行完成'," +
                "  `note` varchar(256) NOT NULL DEFAULT ''," +
                "  UNIQUE KEY `unindex_thread_id` (`thread_id`)," +
                "  PRIMARY KEY (`num`)" +
                ") ENGINE=InnoDB DEFAULT CHARSET=utf8;";
        Sql_Mysql sql = new Sql_Mysql(pool.getConn());
        ResultSet rs = null;
        try {
            if(true == recreate) {
                sql.sqlMysqlExecute(sql_str01);
            }
            sql.sqlMysqlExecute(sql_str02);
            rs = sql.sqlMysqlQuery("SELECT * from web_site.tb_thread_util WHERE thread_id = 2019001");
            if(false == rs.next()) {
                sql.sqlMysqlExecute("INSERT INTO " + Sql_Mysql.ThreadUtil_Table + " VALUES ('1', '2019001', '机房续航线程', '2019-01-08 10:44:28', '0', '')");            //添加机房续航线程的控制记录
            }
            rs = sql.sqlMysqlQuery("SELECT * from web_site.tb_thread_util WHERE thread_id = 2019002");
            if(false == rs.next()) {
                sql.sqlMysqlExecute("INSERT INTO " + Sql_Mysql.ThreadUtil_Table + " VALUES ('2', '2019002', '落后单体线程', '2019-01-08 10:44:28', '0', '')");            //添加机房续航线程的控制记录
            }
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            sql.close_con();
        }
    }
    public static void main(String[] args) {
        MysqlConnPool pool = new MysqlConnPool("123.207.82.239", 3360, 10);
        DB_web_site website = new DB_web_site();
        website.createThread_utilTable(pool, false);
    }
}
BattMonitor_DB_Builder/src/com/dev/fbs9100/FBS9100_Task_Thread_SQL.java
@@ -208,7 +208,7 @@
     * 
     * @param gB_MysqlConnPool
     */
    public static void createBTSStationState_TableOnRam(MysqlConnPool con_pool) {
    public static void createBTSStationState_TableOnRam(MysqlConnPool con_pool,boolean recreate_tb) {
        String str1 = "DROP TABLE IF EXISTS " + Sql_Mysql.BTSStationState_Table;
        String str2 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.BTSStationState_Table
                + " ( `num` BIGINT NOT NULL AUTO_INCREMENT, "
@@ -233,7 +233,9 @@
                + " ENGINE=InnoDB DEFAULT CHARSET=utf8";
        Sql_Mysql sql = new Sql_Mysql(con_pool.getConn());
        try {
            sql.sqlMysqlExecute(str1);
            if(recreate_tb) {
                sql.sqlMysqlExecute(str1);
            }
            sql.sqlMysqlExecute(str2);
        } catch (SQLException e) {
            e.printStackTrace();
BattMonitor_DB_Builder/src/com/sql/Sql_Mysql.java
@@ -124,6 +124,8 @@
    
    
    public final static String BTSStationEvent_Table = DB_ALARM + ".`tb_bts_station_event`";                            //机房状态历史表
    public final static String ThreadUtil_Table = WEB_Site + ".`tb_thread_util`";
    //--------------------------------------------------------------------------------------------//
    //--------------------------------------------------------------------------------------------//
    public Connection mysql_con;
BattMonitor_DB_Builder/src/main/main_BTS_DB_Builder.java
@@ -5,6 +5,7 @@
import com.base.Com;
import com.battdata_rt.BattData_RT_RamDB_Thread_SQL;
import com.config.AppConfig;
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;
@@ -87,13 +88,15 @@
            FBS9100S_DFU_SQL.createFBS9100S_DFU_TableOnRam(GB_MysqlConnPool);
            
            //创建BTSStationState_Table表
            FBS9100_Task_Thread_SQL.createBTSStationState_TableOnRam(GB_MysqlConnPool);
        }
        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);                                //初始化录入机房状态
        
        DB_web_site.init(GB_MysqlConnPool, recreate_tb);                //初始化 web_site数据库中的表
        
        if(true == m_AppConfig.getMysqlDB_RecreateEn()) {
            m_AppConfig.setMysqlDB_RecreateEn(false);