蓄电池监控管理平台数据库初始化程序
Administrator
2021-07-02 a0fe090adf6622c72df70225881add061ab3a5d1
11修改
9个文件已修改
282 ■■■■■ 已修改文件
BattMonitor_DB_Builder/bin/com/version_inf/version_inf.txt 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
BattMonitor_DB_Builder/src/com/database_util/DB_App_Sys.java 36 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
BattMonitor_DB_Builder/src/com/database_util/DB_Pwrdev_Inf.java 173 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
BattMonitor_DB_Builder/src/com/database_util/DB_Ram_db.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
BattMonitor_DB_Builder/src/com/database_util/DB_db_user.java 36 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
BattMonitor_DB_Builder/src/com/database_util/DB_web_site.java 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
BattMonitor_DB_Builder/src/com/sql/Sql_Mysql.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
BattMonitor_DB_Builder/src/com/version_inf/version_inf.txt 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
BattMonitor_DB_Builder/src/main/main_BTS_DB_Builder.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
BattMonitor_DB_Builder/bin/com/version_inf/version_inf.txt
@@ -168,4 +168,14 @@
    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`'数据库表
    
BattMonitor_DB_Builder/src/com/database_util/DB_App_Sys.java
@@ -26,6 +26,8 @@
        
        createApp_Bts_Battgroup_Table(pool, recreate);
        
        createMenu_Table(pool, recreate);
    }
    
    /**
@@ -296,4 +298,38 @@
            sql.close_con();
        }
    }
    /**
     *     创建 tb_menu 表
     * @param pool
     * @param recreate
     */
    public static void createMenu_Table(MysqlConnPool pool, boolean recreate) {
        String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.Menu_Table;
        String sql_str02 = " CREATE TABLE IF NOT EXISTS " + Sql_Mysql.Menu_Table + " (" +
                "  `id` int(11) NOT NULL," +
                "  `label` varchar(50) DEFAULT NULL COMMENT '中文名称'," +
                "  `name` varchar(100) DEFAULT NULL COMMENT '名称'," +
                "  `src` varchar(100) DEFAULT NULL COMMENT '路径'," +
                "  `icon` varchar(100) DEFAULT NULL COMMENT '图标'," +
                "  `closable` tinyint(4) DEFAULT NULL COMMENT '是否可关闭'," +
                "  `enableduse` tinyint(4) DEFAULT NULL COMMENT '是否启用'," +
                "  `permitName` varchar(100) DEFAULT NULL COMMENT '权限'," +
                "  `level` tinyint(4) DEFAULT NULL COMMENT '菜单等级'," +
                "  `ord` tinyint(4) DEFAULT NULL COMMENT '排序'," +
                "  `menuId` int(11) DEFAULT NULL COMMENT '上级菜单id'," +
                "  PRIMARY KEY (`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();
        }
    }
}
BattMonitor_DB_Builder/src/com/database_util/DB_Pwrdev_Inf.java
@@ -14,6 +14,15 @@
        
        createPwrapp_Sys_Table(pool, recreate);
        
        createPwrapp_Stainf_Table(pool, recreate);
        createPwrapp_Dcinf_Table(pool, recreate);
        createPwrapp_Acinf_Table(pool, recreate);
        createPwrapp_Acdcinf_Table(pool, recreate);
        createDisplay_Config_Table(pool, recreate);
    }
    /**
@@ -61,20 +70,39 @@
                "  `PowerProducer` varchar(45) NOT NULL DEFAULT '0'," + 
                "  `PowerProductDate` date NOT NULL DEFAULT '2006-07-06'," + 
                "  `PowerInUseDate` date NOT NULL DEFAULT '2006-07-06'," + 
                "  `runCompany` varchar(45) NOT NULL DEFAULT ''," +
                "  PRIMARY KEY (`num`)," + 
                "  KEY `index_station_id` (`StationId`)," + 
                "  KEY `index_powerdev_id` (`PowerDeviceId`)," + 
                "  KEY `index_station_name` (`StationName`)" + 
                ") ENGINE=InnoDB AUTO_INCREMENT=141 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);
            sql.sqlMysqlExecute(sql_str02);
            //添加字段AppServer_Reinit_PowerData_Charger_EN
            res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
                    + " WHERE table_schema='db_pwrdev_inf'"
                    + " AND table_name='tb_pwrdev_inf'"
                    + " AND column_name='runCompany'");
            if(false == res.next()) {
                sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.Pwrdev_Inf_Table
                        + " ADD COLUMN `runCompany` varchar(45) NOT NULL DEFAULT '';");
            }
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            if(null != res) {
                try {
                    res.close();
                } catch (SQLException e) {
                    e.printStackTrace();
                }
            }
            sql.close_con();
        }
    }
@@ -130,5 +158,148 @@
        }
    }
    
    /**
     *     创建   tb_pwrapp_stainf 表
     * @param pool
     * @param recreate
     */
    public static void createPwrapp_Stainf_Table(MysqlConnPool pool, boolean recreate) {
        String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.Pwrapp_Stainf_Table;
        String sql_str02 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.Pwrapp_Stainf_Table + " (" +
                "  `num` bigint(20) NOT NULL AUTO_INCREMENT," +
                "  `PowerDeviceId` bigint(20) NOT NULL DEFAULT '0'," +
                "  `RunCompany` varchar(100) NOT NULL DEFAULT ' '," +
                "  `HistoryAlarmRelatRecord` varchar(100) NOT NULL DEFAULT ' '," +
                "  PRIMARY KEY (`num`)," +
                "  KEY `index_pwrdev_id` (`PowerDeviceId`)" +
                ") 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_pwrapp_dcinf 表
     * @param pool
     * @param recreate
     */
    public static void createPwrapp_Dcinf_Table(MysqlConnPool pool, boolean recreate) {
        String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.Pwrapp_Dcinf_Table;
        String sql_str02 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.Pwrapp_Dcinf_Table + " (" +
                "  `num` bigint(20) NOT NULL AUTO_INCREMENT," +
                "  `PowerDeviceId` bigint(20) NOT NULL DEFAULT '0'," +
                "  `InputSWCount` int(11) NOT NULL DEFAULT '0'," +
                "  `OutputSWCount` int(11) NOT NULL DEFAULT '0'," +
                "  `Cap` int(11) NOT NULL DEFAULT '0'," +
                "  `UsePurPose` varchar(100) NOT NULL DEFAULT ' '," +
                "  PRIMARY KEY (`num`)," +
                "  KEY `index_pwrdev_id` (`PowerDeviceId`)" +
                ") ENGINE=InnoDB AUTO_INCREMENT=2 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_pwrapp_acinf 表
     * @param pool
     * @param recreate
     */
    public static void createPwrapp_Acinf_Table(MysqlConnPool pool, boolean recreate) {
        String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.Pwrapp_Acinf_Table;
        String sql_str02 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.Pwrapp_Acinf_Table + " (" +
                "  `num` bigint(20) NOT NULL AUTO_INCREMENT," +
                "  `PowerDeviceId` bigint(20) NOT NULL DEFAULT '0'," +
                "  `InputSWCount` int(11) NOT NULL DEFAULT '0'," +
                "  `OutputSWCount` int(11) NOT NULL DEFAULT '0'," +
                "  `Cap` int(11) NOT NULL DEFAULT '0'," +
                "  `UsePurPose` varchar(100) NOT NULL DEFAULT ' '," +
                "  PRIMARY KEY (`num`)," +
                "  KEY `index_pwrdev_id` (`PowerDeviceId`)" +
                ") ENGINE=InnoDB AUTO_INCREMENT=2 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_pwrapp_acdcinf 表
     * @param pool
     * @param recreate
     */
    public static void createPwrapp_Acdcinf_Table(MysqlConnPool pool, boolean recreate) {
        String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.Pwrapp_Acdcinf_Table;
        String sql_str02 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.Pwrapp_Acdcinf_Table + " (" +
                "  `num` bigint(20) NOT NULL AUTO_INCREMENT," +
                "  `PowerDeviceId` bigint(20) NOT NULL DEFAULT '0'," +
                "  `ModuleInUseCount` int(11) NOT NULL DEFAULT '0'," +
                "  `ModuleCap` int(11) NOT NULL DEFAULT '0'," +
                "  `ModuleSlotCount` int(11) NOT NULL DEFAULT '0'," +
                "  PRIMARY KEY (`num`)," +
                "  KEY `index_pwrdev_id` (`PowerDeviceId`)" +
                ") ENGINE=InnoDB AUTO_INCREMENT=2 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_display_config 表
     * @param pool
     * @param recreate
     */
    public static void createDisplay_Config_Table(MysqlConnPool pool, boolean recreate) {
        String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.Display_Config_Table;
        String sql_str02 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.Display_Config_Table + " (" +
                "  `id` int(11) NOT NULL AUTO_INCREMENT," +
                "  `name` varchar(45) NOT NULL COMMENT '标识,名称'," +
                "  `type` int(11) NOT NULL COMMENT '图形类型'," +
                "  `user_id` int(11) NOT NULL," +
                "  PRIMARY KEY (`id`)" +
                ") ENGINE=InnoDB AUTO_INCREMENT=29 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();
        }
    }
    
}
BattMonitor_DB_Builder/src/com/database_util/DB_Ram_db.java
@@ -1668,7 +1668,7 @@
    public static void createTb_Batt_RSAlarm_Table(MysqlConnPool pool, boolean recreate) {
        String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.Tb_Batt_RSAlarm_Table;
        String sql_str02 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.Tb_Batt_RSAlarm_Table + " (" + 
                "  `num` bigint(20) NOT NULL AUTO_INCREMENT ," +
                "  `num` bigint(20) NOT NULL AUTO_INCREMENT," +
                "  `BattGroupId` int(11) NOT NULL DEFAULT '1000001' COMMENT '电池组ID'," + 
                "  `record_time` datetime NOT NULL DEFAULT '2000-01-01 00:00:00' COMMENT '记录时间'," + 
                "  `groupvol_alm` tinyint(4) NOT NULL DEFAULT '0' COMMENT '组电压告警'," + 
BattMonitor_DB_Builder/src/com/database_util/DB_db_user.java
@@ -57,7 +57,7 @@
        
        createUser_Limit_Table(pool, recreate);    
    
        createUser_Log_Table(pool, recreate);
    
    }
    
@@ -982,8 +982,8 @@
                int count = res.getInt("num_count");
                if(count<1) {
                    //默认没有添加用户信息时添加superuser
                    sql.sqlMysqlExecute("INSERT INTO "+Sql_Mysql.TB_UserInf+" VALUES ('1001', 'admin', 'admin', 'admin', 'employeeid', '12345678912', '12345678912', 'abcde@mail.com', '', '1980-01-01', '2015-12-09', '男', '广东省', 'protitle', 'authority', '默认班组', 'duties', 'tasks', '1', 'note', '21232f297a57a5a743894a0e4a801fc3', '', '', '48505834353130373639353153594E4F', '28', '');");
                    sql.sqlMysqlExecute("INSERT INTO "+Sql_Mysql.TB_UserInf+" VALUES ('1002', '1', 'superuser', '1234567', '100010000', '12345678', '15346259512', '123456789@qq.com', '', '1990-04-20', '2016-03-28', '男', '湖北省', '软件工程师', 'authority111', '默认班组', 'dutie', '完成软件的研发工作', '0', 'note', 'c4ca4238a0b923820dcc509a6f75849b', '', '', '14031C0F0136063E', '27', '');");
                    sql.sqlMysqlExecute("INSERT INTO "+Sql_Mysql.TB_UserInf+" VALUES ('1001', 'admin', 'admin', 'admin', 'employeeid', '12345678912', '12345678912', 'abcde@mail.com', '', '1980-01-01', '2015-12-09', '男', '广东省', 'protitle', 'authority', '默认班组', 'duties', 'tasks', '1', 'note', '21232f297a57a5a743894a0e4a801fc3', '', '', '48505834353130373639353153594E4F', '28', '','0');");
                    sql.sqlMysqlExecute("INSERT INTO "+Sql_Mysql.TB_UserInf+" VALUES ('1002', '1', 'superuser', '1234567', '100010000', '12345678', '15346259512', '123456789@qq.com', '', '1990-04-20', '2016-03-28', '男', '湖北省', '软件工程师', 'authority111', '默认班组', 'dutie', '完成软件的研发工作', '0', 'note', 'c4ca4238a0b923820dcc509a6f75849b', '', '', '14031C0F0136063E', '27', '','0');");
                }
            }
        } catch (SQLException e) {
@@ -992,4 +992,34 @@
            sql.close_con();
        }
    }
    /**
     * 创建用户操作日志表
     * @param pool
     * @param recreate
     */
    public static void createUser_Log_Table(MysqlConnPool pool, boolean recreate) {
        String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.User_Log_Table;
        String sql_str02 = "CREATE TABLE  IF NOT EXISTS " + Sql_Mysql.User_Log_Table + " (" +
                "  `num` bigint(20) NOT NULL AUTO_INCREMENT," +
                "  `uId` int(11) NOT NULL DEFAULT '0'," +
                "  `uOprateType` int(11) NOT NULL DEFAULT '0'," +
                "  `uOprateDay` datetime NOT NULL DEFAULT '1980-01-01 00:00:00'," +
                "  `uTerminalIp` varchar(20) NOT NULL DEFAULT ' '," +
                "  `uOprateMsg` varchar(250) NOT NULL DEFAULT ' '," +
                "  PRIMARY KEY (`num`)," +
                "  KEY `user_id` (`uId`)" +
                ") ENGINE=InnoDB AUTO_INCREMENT=7293 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();
        }
    }
}
BattMonitor_DB_Builder/src/com/database_util/DB_web_site.java
@@ -376,7 +376,11 @@
            if(false == res.next()) {
                sql.sqlMysqlExecute(" INSERT INTO " + Sql_Mysql.ProcessSurvey_Table + "(ProcessId,ProcessName,ProcessTime,Process_starttime,ServerName,ServerFlag,ProcessVersion,note,OutTime) VALUES ('11015', 'BMS_COMM_POWER',         '1970-01-01 00:00:00', '1970-01-01 00:00:00', 'BMS_COMM_POWER', '2', 'v1.101', '通信电源通讯线程', '300');");
            }
            //添加通信电源通讯
            res = sql.sqlMysqlQuery("SELECT * FROM "+ Sql_Mysql.ProcessSurvey_Table + " WHERE ProcessId = 11016");
            if(false == res.next()) {
                sql.sqlMysqlExecute(" INSERT INTO " + Sql_Mysql.ProcessSurvey_Table + "(ProcessId,ProcessName,ProcessTime,Process_starttime,ServerName,ServerFlag,ProcessVersion,note,OutTime) VALUES ('11016', 'BMS_POWER_MONITOR',     '1970-01-01 00:00:00', '1970-01-01 00:00:00', 'BMS_POWER_MONITOR', '2', 'v1.100', '通信电源监控线程', '300');");
            }
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
BattMonitor_DB_Builder/src/com/sql/Sql_Mysql.java
@@ -234,6 +234,7 @@
    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`";
@@ -255,6 +256,12 @@
    /***************************** 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`";
    
    
    //--------------------------------------------------------------------------------------------//
BattMonitor_DB_Builder/src/com/version_inf/version_inf.txt
@@ -168,4 +168,14 @@
    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`'数据库表
    
BattMonitor_DB_Builder/src/main/main_BTS_DB_Builder.java
@@ -26,7 +26,7 @@
    /**************************************************************************/
    /**************************************************************************/
    public final static boolean app_debug = false;
    public final static float m_VersionNum = (float) 1.55;
    public final static float m_VersionNum = (float) 1.59;
    public final static String m_Version = "Welcome To Use BTS DB BUILDER V" + m_VersionNum + " RC_20180908";
    /**************************************************************************/
    /**************************************************************************/