| | |
| | |
|
| | | createRamDB_CMCC_POWER_Data_Table(pool, recreate);
|
| | |
|
| | | createFBS9100_CollectionstateTable(pool, recreate);
|
| | |
|
| | | createFBS9100_InsulatstateTable(pool, recreate);
|
| | | |
| | | createFBS9100_ChargerstateTable(pool, recreate);
|
| | | }
|
| | |
|
| | |
|
| | |
| | | sql.close_con();
|
| | | }
|
| | | }
|
| | | |
| | | /**
|
| | | * 创建 tb_fbs9100_insulatstate 表
|
| | | * @param pool
|
| | | * @param recreate
|
| | | */
|
| | | public static void createFBS9100_InsulatstateTable(MysqlConnPool pool, boolean recreate) {
|
| | | String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.FBS9100_InsulatstateTable;
|
| | | String sql_str02 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.FBS9100_InsulatstateTable + " (" + |
| | | " `num` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键'," + |
| | | " `PowerDeviceId` int(11) NOT NULL DEFAULT '1' COMMENT '电源id'," + |
| | | " `BattGroupId` int(11) NOT NULL DEFAULT '0' COMMENT '电池组id'," + |
| | | " `record_time` datetime NOT NULL DEFAULT '2000-01-01 00:00:00' COMMENT '记录时间'," + |
| | | " `insulat_system_vol` float NOT NULL DEFAULT '0' COMMENT '绝缘监测模块系统电压'," + |
| | | " `insulat_ground_vol` float NOT NULL DEFAULT '0' COMMENT '绝缘监测模块正对地电压'," + |
| | | " `insulat_negative_vol` float NOT NULL DEFAULT '0' COMMENT '绝缘监测模块负对地电压'," + |
| | | " `insulat_ground_res` float NOT NULL DEFAULT '0' COMMENT '绝缘监测模块正对地电阻'," + |
| | | " `insulat_negative_res` float NOT NULL DEFAULT '0' COMMENT '绝缘监测模块负对地电阻'," + |
| | | " `insulat_batt_res` float NOT NULL DEFAULT '0' COMMENT '绝缘监测模块电池对地电阻'," + |
| | | " `insulat_fault_num` int(11) NOT NULL DEFAULT '0' COMMENT '绝缘监测模块故障电池节数'," + |
| | | " `insulat_ac_vol` float NOT NULL DEFAULT '0' COMMENT '绝缘监测模块交流电压'," + |
| | | " `insulat_system_state` int(11) NOT NULL DEFAULT '0' COMMENT '绝缘监测模块系统状态'," + |
| | | " `insulat_record_state` int(11) NOT NULL DEFAULT '0' COMMENT '绝缘监测模块瞬时记录状态'," + |
| | | " `insulat_state` int(11) NOT NULL DEFAULT '0' COMMENT '绝缘监测模块装置状态'," + |
| | | " `insulat_branch_num_1` int(11) NOT NULL DEFAULT '0' COMMENT '绝缘监测模块接地支路号(模块1)'," + |
| | | " `insulat_branch_res_is_1` float NOT NULL DEFAULT '0' COMMENT '绝缘监测模块支路正对地电阻(模块1)'," + |
| | | " `insulat_branch_res_ne_1` float NOT NULL DEFAULT '0' COMMENT '绝缘监测模块支路负对地电阻(模块1)'," + |
| | | " `insulat_branch_num_2` int(11) NOT NULL DEFAULT '0' COMMENT '绝缘监测模块接地支路号(模块2)'," + |
| | | " `insulat_branch_res_is_2` float NOT NULL DEFAULT '0' COMMENT '绝缘监测模块支路正对地电阻(模块2)'," + |
| | | " `insulat_branch_res_ne_2` float NOT NULL DEFAULT '0' COMMENT '绝缘监测模块支路负对地电阻(模块2)'," + |
| | | " `insulat_branch_num_3` int(11) NOT NULL DEFAULT '0' COMMENT '绝缘监测模块接地支路号(模块3)'," + |
| | | " `insulat_branch_res_is_3` float NOT NULL DEFAULT '0' COMMENT '绝缘监测模块支路正对地电阻(模块3)'," + |
| | | " `insulat_branch_res_ne_3` float NOT NULL DEFAULT '0' COMMENT '绝缘监测模块支路负对地电阻(模块3)'," + |
| | | " `insulat_branch_num_4` int(11) NOT NULL DEFAULT '0' COMMENT '绝缘监测模块接地支路号(模块4)'," + |
| | | " `insulat_branch_res_is_4` float NOT NULL DEFAULT '0' COMMENT '绝缘监测模块支路正对地电阻(模块4)'," + |
| | | " `insulat_branch_res_ne_4` float NOT NULL DEFAULT '0' COMMENT '绝缘监测模块支路负对地电阻(模块4)'," + |
| | | " `insulat_branch_num_5` int(11) NOT NULL DEFAULT '0' COMMENT '绝缘监测模块接地支路号(模块5)'," + |
| | | " `insulat_branch_res_is_5` float NOT NULL DEFAULT '0' COMMENT '绝缘监测模块支路正对地电阻(模块5)'," + |
| | | " `insulat_branch_res_ne_5` float NOT NULL DEFAULT '0' COMMENT '绝缘监测模块支路负对地电阻(模块5)'," + |
| | | " `insulat_branch_num_6` int(11) NOT NULL DEFAULT '0' COMMENT '绝缘监测模块接地支路号(模块6)'," + |
| | | " `insulat_branch_res_is_6` float NOT NULL DEFAULT '0' COMMENT '绝缘监测模块支路正对地电阻(模块6)'," + |
| | | " `insulat_branch_res_ne_6` float NOT NULL DEFAULT '0' COMMENT '绝缘监测模块支路负对地电阻(模块6)'," + |
| | | " `insulat_branch_num_7` int(11) NOT NULL DEFAULT '0' COMMENT '绝缘监测模块接地支路号(模块7)'," + |
| | | " `insulat_branch_res_is_7` float NOT NULL DEFAULT '0' COMMENT '绝缘监测模块支路正对地电阻(模块7)'," + |
| | | " `insulat_branch_res_ne_7` float NOT NULL DEFAULT '0' COMMENT '绝缘监测模块支路负对地电阻(模块7)'," + |
| | | " `insulat_branch_num_8` int(11) NOT NULL DEFAULT '0' COMMENT '绝缘监测模块接地支路号(模块8)'," + |
| | | " `insulat_branch_res_is_8` float NOT NULL DEFAULT '0' COMMENT '绝缘监测模块支路正对地电阻(模块8)'," + |
| | | " `insulat_branch_res_ne_8` float NOT NULL DEFAULT '0' COMMENT '绝缘监测模块支路负对地电阻(模块8)'," + |
| | | " `insulat_branch_num_9` int(11) NOT NULL DEFAULT '0' COMMENT '绝缘监测模块接地支路号(模块9)'," + |
| | | " `insulat_branch_res_is_9` float NOT NULL DEFAULT '0' COMMENT '绝缘监测模块支路正对地电阻(模块9)'," + |
| | | " `insulat_branch_res_ne_9` float NOT NULL DEFAULT '0' COMMENT '绝缘监测模块支路负对地电阻(模块9)'," + |
| | | " `insulat_branch_num_10` int(11) NOT NULL DEFAULT '0' COMMENT '绝缘监测模块接地支路号(模块10)'," + |
| | | " `insulat_branch_res_is_10` float NOT NULL DEFAULT '0' COMMENT '绝缘监测模块支路正对地电阻(模块10)'," + |
| | | " `insulat_branch_res_ne_10` float NOT NULL DEFAULT '0' COMMENT '绝缘监测模块支路负对地电阻(模块10)'," + |
| | | " `insulat_branch_num_11` int(11) NOT NULL DEFAULT '0' COMMENT '绝缘监测模块接地支路号(模块11)'," + |
| | | " `insulat_branch_res_is_11` float NOT NULL DEFAULT '0' COMMENT '绝缘监测模块支路正对地电阻(模块11)'," + |
| | | " `insulat_branch_res_ne_11` float NOT NULL DEFAULT '0' COMMENT '绝缘监测模块支路负对地电阻(模块11)'," + |
| | | " `insulat_branch_num_12` int(11) NOT NULL DEFAULT '0' COMMENT '绝缘监测模块接地支路号(模块12)'," + |
| | | " `insulat_branch_res_is_12` float NOT NULL DEFAULT '0' COMMENT '绝缘监测模块支路正对地电阻(模块12)'," + |
| | | " `insulat_branch_res_ne_12` float NOT NULL DEFAULT '0' COMMENT '绝缘监测模块支路负对地电阻(模块12)'," + |
| | | " `insulat_branch_num_13` int(11) NOT NULL DEFAULT '0' COMMENT '绝缘监测模块接地支路号(模块13)'," + |
| | | " `insulat_branch_res_is_13` float NOT NULL DEFAULT '0' COMMENT '绝缘监测模块支路正对地电阻(模块13)'," + |
| | | " `insulat_branch_res_ne_13` float NOT NULL DEFAULT '0' COMMENT '绝缘监测模块支路负对地电阻(模块13)'," + |
| | | " `insulat_branch_num_14` int(11) NOT NULL DEFAULT '0' COMMENT '绝缘监测模块接地支路号(模块14)'," + |
| | | " `insulat_branch_res_is_14` float NOT NULL DEFAULT '0' COMMENT '绝缘监测模块支路正对地电阻(模块14)'," + |
| | | " `insulat_branch_res_ne_14` float NOT NULL DEFAULT '0' COMMENT '绝缘监测模块支路负对地电阻(模块14)'," + |
| | | " `insulat_branch_num_15` int(11) NOT NULL DEFAULT '0' COMMENT '绝缘监测模块接地支路号(模块15)'," + |
| | | " `insulat_branch_res_is_15` float NOT NULL DEFAULT '0' COMMENT '绝缘监测模块支路正对地电阻(模块15)'," + |
| | | " `insulat_branch_res_ne_15` float NOT NULL DEFAULT '0' COMMENT '绝缘监测模块支路负对地电阻(模块15)'," + |
| | | " `insulat_branch_num_16` int(11) NOT NULL DEFAULT '0' COMMENT '绝缘监测模块接地支路号(模块12)'," + |
| | | " `insulat_branch_res_is_16` float NOT NULL DEFAULT '0' COMMENT '绝缘监测模块支路正对地电阻(模块12)'," + |
| | | " `insulat_branch_res_ne_16` float NOT NULL DEFAULT '0' COMMENT '绝缘监测模块支路负对地电阻(模块12)'," + |
| | | " `note` varchar(32) NOT NULL DEFAULT '' COMMENT '备用'," + |
| | | " PRIMARY KEY (`num`,`PowerDeviceId`)," + |
| | | " KEY `index_PowerDeviceId` (`PowerDeviceId`) USING BTREE," + |
| | | " KEY `index_battgroupid` (`BattGroupId`) USING BTREE" + |
| | | ") ENGINE=InnoDB AUTO_INCREMENT=4 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); |
| | | //移除之前的以电池组id设置的唯一索引
|
| | | res = sql.sqlMysqlQuery("show INDEX FROM "+Sql_Mysql.FBS9100_InsulatstateTable+" WHERE KEY_name = 'unique_battgroupid'");
|
| | | if(res.next()) {
|
| | | sql.sqlMysqlExecute("alter table "+Sql_Mysql.FBS9100_InsulatstateTable+" drop index unique_battgroupid;");
|
| | | }
|
| | | //添加字段PowerDeviceId
|
| | | res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
|
| | | + " WHERE table_schema='db_ram_db'"
|
| | | + " AND table_name='tb_fbs9100_insulatstate'"
|
| | | + " AND column_name='PowerDeviceId'");
|
| | | if(false == res.next()) {
|
| | | sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.FBS9100_InsulatstateTable |
| | | + " ADD COLUMN `PowerDeviceId` int(11) NOT NULL DEFAULT '1' COMMENT '电源id'");
|
| | | }
|
| | | } catch (SQLException e) {
|
| | | e.printStackTrace();
|
| | | } finally {
|
| | | if(null != res) {
|
| | | try {
|
| | | res.close();
|
| | | } catch (SQLException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | sql.close_con();
|
| | | }
|
| | | }
|
| | | |
| | | /**
|
| | | * 创建 tb_fbs9100_collectionstate 表
|
| | | * @param pool
|
| | | * @param recreate
|
| | | */
|
| | | public static void createFBS9100_CollectionstateTable(MysqlConnPool pool, boolean recreate) {
|
| | | String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.FBS9100_CollectionstateTable;
|
| | | String sql_str02 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.FBS9100_CollectionstateTable + " (" + |
| | | " `num` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键'," + |
| | | " `BattGroupId` int(11) NOT NULL DEFAULT '0' COMMENT '电池组ID'," + |
| | | " `record_time` datetime NOT NULL DEFAULT '2000-01-01 00:00:00' COMMENT '记录时间'," + |
| | | " `col_version` float NOT NULL DEFAULT '0' COMMENT '汇集器版本'," + |
| | | " `col_state` int(11) NOT NULL DEFAULT '0' COMMENT '汇集器状态'," + |
| | | " `col_vol` float NOT NULL DEFAULT '0' COMMENT '汇集器组电压'," + |
| | | " `col_curr` float NOT NULL DEFAULT '0' COMMENT '汇集器组电流'," + |
| | | " `col_batt_state` int(11) NOT NULL DEFAULT '0' COMMENT '汇集器电池状态'," + |
| | | " `col_curr_dir` float NOT NULL DEFAULT '0' COMMENT '汇集器电流方向'," + |
| | | " `col_mean_rip_curr` float NOT NULL DEFAULT '0' COMMENT '汇集器纹波电流均值'," + |
| | | " `col_peak_rip_curr` float NOT NULL DEFAULT '0' COMMENT '汇集器纹波电流峰值'," + |
| | | " `col_restest_count` int(11) NOT NULL DEFAULT '0' COMMENT '汇集器内阻测试次数'," + |
| | | " `col_restest_type` int(11) NOT NULL DEFAULT '0' COMMENT '汇集器内阻测试方法'," + |
| | | " `note` varchar(255) NOT NULL DEFAULT '' COMMENT '备用'," + |
| | | " PRIMARY KEY (`num`)," + |
| | | " UNIQUE KEY `unique_battgroupid` (`BattGroupId`) USING BTREE" + |
| | | ") ENGINE=InnoDB AUTO_INCREMENT=4 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_fbs9100_chargerstate 表
|
| | | * @param pool
|
| | | * @param recreate
|
| | | */
|
| | | public static void createFBS9100_ChargerstateTable(MysqlConnPool pool, boolean recreate) {
|
| | | String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.FBS9100_ChargerstateTable;
|
| | | String sql_str02 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.FBS9100_ChargerstateTable + " (" + |
| | | " `num` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键'," + |
| | | " `PowerDeviceId` int(11) NOT NULL DEFAULT '1' COMMENT '电源id'," + |
| | | " `BattGroupId` int(11) NOT NULL DEFAULT '0' COMMENT '电池组ID'," + |
| | | " `record_time` datetime NOT NULL DEFAULT '2000-01-01 00:00:00' COMMENT '记录时间'," + |
| | | " `char_output_vol` float NOT NULL DEFAULT '0' COMMENT '充电机输出电压'," + |
| | | " `char_output_curr` float NOT NULL DEFAULT '0' COMMENT '充电机输出电流'," + |
| | | " `char_peak_rip_vol` float NOT NULL DEFAULT '0' COMMENT '纹波峰值'," + |
| | | " `char_peak_rip_param` float NOT NULL DEFAULT '0' COMMENT '纹波峰值系数'," + |
| | | " `char_Uan` float NOT NULL DEFAULT '0' COMMENT 'Uan'," + |
| | | " `char_Ian` float NOT NULL DEFAULT '0' COMMENT 'Ian'," + |
| | | " `char_Ubn` float NOT NULL DEFAULT '0' COMMENT 'Ubn'," + |
| | | " `char_Ibn` float NOT NULL DEFAULT '0' COMMENT 'Ibn'," + |
| | | " `char_Ucn` float NOT NULL DEFAULT '0' COMMENT 'Ucn'," + |
| | | " `char_Icn` float NOT NULL DEFAULT '0' COMMENT 'Icn'," + |
| | | " `char_system_state` int(11) NOT NULL DEFAULT '0' COMMENT 'ϵͳ״̬'," + |
| | | " `note` varchar(255) NOT NULL DEFAULT '' COMMENT '备用'," + |
| | | " PRIMARY KEY (`num`)," + |
| | | " KEY `index_battgroupid` (`BattGroupId`) USING BTREE," + |
| | | " KEY `index_PowerDeviceId` (`PowerDeviceId`) USING BTREE" + |
| | | ") ENGINE=InnoDB AUTO_INCREMENT=4 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); |
| | | //移除之前的以电池组id设置的唯一索引
|
| | | res = sql.sqlMysqlQuery("show INDEX FROM "+Sql_Mysql.FBS9100_ChargerstateTable+" WHERE KEY_name = 'unique_battgroupid'");
|
| | | if(res.next()) {
|
| | | sql.sqlMysqlExecute("alter table "+Sql_Mysql.FBS9100_ChargerstateTable+" drop index unique_battgroupid;");
|
| | | }
|
| | | //添加字段PowerDeviceId
|
| | | res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
|
| | | + " WHERE table_schema='db_ram_db'"
|
| | | + " AND table_name='tb_fbs9100_chargerstate'"
|
| | | + " AND column_name='PowerDeviceId'");
|
| | | if(false == res.next()) {
|
| | | sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.FBS9100_ChargerstateTable |
| | | + " ADD COLUMN `PowerDeviceId` int(11) NOT NULL DEFAULT '1' COMMENT '电源id'");
|
| | | }
|
| | | } catch (SQLException e) {
|
| | | e.printStackTrace();
|
| | | } finally {
|
| | | if(null != res) {
|
| | | try {
|
| | | res.close();
|
| | | } catch (SQLException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | sql.close_con();
|
| | | }
|
| | | }
|
| | | }
|