蓄电池监控管理平台数据库初始化程序
DELL
2020-04-13 a0c67802902622ce5fe13d800e74cf31b2ed7399
在用户表和电池信息表中添加uKey信息
1个文件已添加
8个文件已修改
191 ■■■■■ 已修改文件
BattMonitor_DB_Builder/bin/.gitignore 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
BattMonitor_DB_Builder/bin/com/battdata_rt/BattData_RT_RamDB_Thread_SQL.class 补丁 | 查看 | 原始文档 | blame | 历史
BattMonitor_DB_Builder/bin/com/dev/fbs9100/FBS9100S_DFU_SQL.class 补丁 | 查看 | 原始文档 | blame | 历史
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/com/version_inf/version_inf.txt 24 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
BattMonitor_DB_Builder/bin/main/main_BTS_DB_Builder.class 补丁 | 查看 | 原始文档 | blame | 历史
BattMonitor_DB_Builder/src/com/database_util/DB_db_user.java 122 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
BattMonitor_DB_Builder/src/com/sql/Sql_Mysql.java 44 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
BattMonitor_DB_Builder/bin/.gitignore
@@ -1,2 +1 @@
/com/
/main/
BattMonitor_DB_Builder/bin/com/battdata_rt/BattData_RT_RamDB_Thread_SQL.class
Binary files differ
BattMonitor_DB_Builder/bin/com/dev/fbs9100/FBS9100S_DFU_SQL.class
Binary files differ
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/com/version_inf/version_inf.txt
@@ -94,3 +94,27 @@
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字段用于判断
BattMonitor_DB_Builder/bin/main/main_BTS_DB_Builder.class
Binary files differ
BattMonitor_DB_Builder/src/com/database_util/DB_db_user.java
New file
@@ -0,0 +1,122 @@
package com.database_util;
import java.sql.ResultSet;
import java.sql.SQLException;
import com.sql.MysqlConnPool;
import com.sql.Sql_Mysql;
public class DB_db_user {
    public static void init(MysqlConnPool pool, boolean recreate) {
        createDB_UserDB(pool);                         //创建db_user数据库
        createTb_user_infTable(pool,  recreate);    //创建用户表
    }
    /**
     *     创建     db_user 数据库
     * @param pool
     */
    public static void createDB_UserDB(MysqlConnPool pool) {
        Sql_Mysql sql = new Sql_Mysql(pool.getConn());
        try {
            sql.sqlMysqlExecute("CREATE DATABASE IF NOT EXISTS " + Sql_Mysql.DB_USER);
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            sql.close_con();
        }
    }
    /**
     * 创建线程手动启动工具表
     */
    public static void createTb_user_infTable(MysqlConnPool pool, boolean recreate) {
        String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.TB_UserInf;
        String sql_str02 = "CREATE TABLE  IF NOT EXISTS " + Sql_Mysql.TB_UserInf + " (" +
                "  `uId` bigint(20) NOT NULL AUTO_INCREMENT," +
                "  `uSnId` varchar(50) NOT NULL DEFAULT '123456'," +
                "  `uName` varchar(50) NOT NULL DEFAULT ' '," +
                "  `uShenFenId` varchar(50) NOT NULL DEFAULT ' '," +
                "  `uEmployeeId` varchar(50) NOT NULL DEFAULT ' '," +
                "  `uTelephone` varchar(20) NOT NULL DEFAULT '0'," +
                "  `uMobilephone` varchar(20) NOT NULL DEFAULT '0'," +
                "  `uEmail` varchar(100) NOT NULL DEFAULT '0'," +
                "  `uAddr` varchar(200) NOT NULL DEFAULT ' '," +
                "  `uBirthDay` date NOT NULL DEFAULT '1980-01-01'," +
                "  `uAccessionDay` date NOT NULL DEFAULT '2001-01-01'," +
                "  `uSex` varchar(10) NOT NULL DEFAULT 'u'," +
                "  `uDepartment` varchar(50) NOT NULL DEFAULT ' '," +
                "  `uProTitle` varchar(50) NOT NULL DEFAULT ' '," +
                "  `uAuthority` varchar(50) NOT NULL DEFAULT ' '," +
                "  `uJobGroup` varchar(50) NOT NULL DEFAULT ' '," +
                "  `uDuties` varchar(50) NOT NULL DEFAULT ' '," +
                "  `uTasks` varchar(50) NOT NULL DEFAULT ' '," +
                "  `uBaojiUsr` tinyint(1) NOT NULL DEFAULT '1'," +
                "  `uNote` varchar(200) NOT NULL DEFAULT ' '," +
                "  `upassword` varchar(64) NOT NULL DEFAULT ''," +
                "  `uPubKeyX` varchar(200) NOT NULL DEFAULT ''," +
                "  `uPubKeyY` varchar(200) NOT NULL DEFAULT ''," +
                "  `uKey_ID` varchar(200) NOT NULL DEFAULT ''," +
                "  PRIMARY KEY (`uId`)," +
                "  UNIQUE KEY `user_id` (`uId`)" +
                ") ENGINE=InnoDB AUTO_INCREMENT=1 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);
            //添加加密告警upassword
            ResultSet res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
                    + " WHERE table_schema='db_battinf'"
                    + " AND table_name='tb_user_inf'"
                    + " AND column_name='upassword'");
            if(false == res.next()) {
                sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.DeverrorRecord_Table
                                + " ADD COLUMN `upassword` varchar(64) NOT NULL DEFAULT ''");
            }
            //添加公钥X
            res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
                    + " WHERE table_schema='db_battinf'"
                    + " AND table_name='tb_user_inf'"
                    + " AND column_name='uPubKeyX'");
            if(false == res.next()) {
                sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.DeverrorRecord_Table
                                + " ADD COLUMN `uPubKeyX` varchar(200) NOT NULL DEFAULT ''");
            }
            //添加公钥Y
            res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
                    + " WHERE table_schema='db_battinf'"
                    + " AND table_name='tb_user_inf'"
                    + " AND column_name='uPubKeyY'");
            if(false == res.next()) {
                sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.DeverrorRecord_Table
                                + " ADD COLUMN `uPubKeyY` varchar(200) NOT NULL DEFAULT ''");
            }
            //添加uKey_ID
            res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
                    + " WHERE table_schema='db_battinf'"
                    + " AND table_name='tb_user_inf'"
                    + " AND column_name='uKey_ID'");
            if(false == res.next()) {
                sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.DeverrorRecord_Table
                                + " ADD COLUMN `uKey_ID` varchar(200) NOT NULL DEFAULT ''");
            }
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            sql.close_con();
        }
    }
}
BattMonitor_DB_Builder/src/com/sql/Sql_Mysql.java
@@ -649,8 +649,8 @@
                                            + " ADD COLUMN `charge_curr_max` float DEFAULT '20'");
                        }
                //---------------------------------------------------------------------------------------------//
                        //为紫晶平台添加指定的列
                        boolean isZijing = false;
                        //为紫晶南网平台添加指定的列
                        boolean isZijing = true;
                        if(isZijing) {
                            //添加电压等级列
                            res = sqlMysqlQuery("SELECT * FROM information_schema.columns"
@@ -815,6 +815,46 @@
                                                + " 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 ''");
                            }
                        }