From 2e2435258bcdc89220acab46125f9a82ff58fb24 Mon Sep 17 00:00:00 2001 From: whycrzg <ruanzhigang@whycst.com> Date: 星期二, 07 九月 2021 09:40:53 +0800 Subject: [PATCH] 修改`db_ram_db`.`tb_fbs9100_sysparam`表 JunHeng_Enabled字段类型为float --- BattMonitor_DB_Builder/src/com/database_util/DB_Ram_db.java | 4367 +++++++++++++++++++++++++++++----------------------------- 1 files changed, 2,185 insertions(+), 2,182 deletions(-) diff --git a/BattMonitor_DB_Builder/src/com/database_util/DB_Ram_db.java b/BattMonitor_DB_Builder/src/com/database_util/DB_Ram_db.java index 3a285bd..d44a724 100644 --- a/BattMonitor_DB_Builder/src/com/database_util/DB_Ram_db.java +++ b/BattMonitor_DB_Builder/src/com/database_util/DB_Ram_db.java @@ -1,2182 +1,2185 @@ -package com.database_util; - -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.Date; - -import com.base.Com; -import com.battdata_rt.BattData_RT_RamDB_Thread_SQL; -import com.sql.MysqlConnPool; -import com.sql.Sql_Mysql; - -public class DB_Ram_db { - - public static void init(MysqlConnPool pool, boolean recreate) { - createDb_Ram_Db(pool); - - createFBS9100s_fod_state(pool,recreate); //创建除硫状态表tb_fbs9100s_fod_state - - createFBS9100SetDLParam_Table(pool,recreate); //创建除硫参数表 - - createFBS9100_NiBian_State_Table(pool, recreate); //创建逆变信息表 - - - createSocketClientStateTable(pool, recreate); - - createServerState_Table(pool, recreate); - - createLd9_Updatestatue_Table(pool, recreate); - - createLd9_State_Table(pool, recreate); - - createLd9_Setparam_Table(pool, recreate); - - createLd9_Concentratestate_Table(pool, recreate); - - createLd9_Concentrateparam_Table(pool, recreate); - - createHardDevSmsState_Table(pool, recreate); - - createFBS9600State_Table(pool, recreate); - - createFBS9100S_DFUState_Table(pool, recreate); - - createFBS9100S_DcDcState_Table(pool, recreate); - - createFBS9100SysParam_Table(pool, recreate); - - createFBS9100State_Table(pool, recreate); - - createFBS9100SetParam_Table(pool, recreate); - - createFBS9100_offlineyhplan_Table(pool, recreate); - - createFBS9100BattParam_Table(pool, recreate); - - createBTSStationState_Table(pool, recreate); - - createBTSGPRSState_Table(pool, recreate); - - createBMP7100State_Table(pool, recreate); - - createBattRtState_Table(pool, recreate); - - createBattRtData_Table(pool, recreate); - - create61850_JHState_Table(pool, recreate); - - createRamDB_CMCC_POWER_Data_Table(pool, recreate); - - createFBS9100_CollectionstateTable(pool, recreate); - - createFBS9100_InsulatstateTable(pool, recreate); - - createFBS9100_ChargerstateTable(pool, recreate); - - createTb_Lithium_DataTable(pool, recreate); - - //南京送检特有 - createTb_Batt_RTAlarm_Table(pool, recreate); - //南京送检特有 - createTb_Batt_RSAlarm_Table(pool, recreate); - - //创建干节点状态表 - createFBS9100s_stemnode_state_Table(pool, recreate); - - //创建母联开关状态表 - createFBS9100s_buscouple_state_Table(pool, recreate); - - //创建FGCD充放电一体机下载控制表 - createFgcd_filedownload_Table(pool, recreate); - } - - - - - - /** - * 创建 web_site 数据库 - * @param pool - */ - public static void createDb_Ram_Db(MysqlConnPool pool) { - Sql_Mysql sql = new Sql_Mysql(pool.getConn()); - try { - sql.sqlMysqlExecute("CREATE DATABASE IF NOT EXISTS " + Sql_Mysql.DB_RamDB); - } catch (SQLException e) { - e.printStackTrace(); - } finally { - sql.close_con(); - } - } - - /** - * 创建除硫状态表 - * @param pool - * @param recreate - */ - public static void createFBS9100s_fod_state(MysqlConnPool pool, boolean recreate) { - String sql_str1 = " DROP TABLE IF EXISTS " + Sql_Mysql.FBS9100s_fod_state; - String sql_str2 = "CREATE TABLE IF NOT EXISTS "+ Sql_Mysql.FBS9100s_fod_state +" (" + - " num int(11) NOT NULL AUTO_INCREMENT," + - " dev_id int(11) NOT NULL DEFAULT '0' COMMENT '设备id'," + - " BattGroupId int(11) NOT NULL DEFAULT '0' COMMENT '电池组id'," + - " record_time datetime NOT NULL DEFAULT '1970-01-01 00:00:00' COMMENT '记录时间'," + - " RestTime_one int(11) NOT NULL DEFAULT '0' COMMENT '剩余天数(组1)'," + - " WorkState_one int(11) NOT NULL DEFAULT '0' COMMENT '工作模式(组1)'," + - " VGroupVol_one double NOT NULL DEFAULT '0' COMMENT '组端电压(组1)'," + - " VpeakVol_one double NOT NULL DEFAULT '0' COMMENT '峰值电压(组1)'," + - " RestTime_two int(11) NOT NULL DEFAULT '0' COMMENT '剩余天数(组2)'," + - " WorkState_two int(11) NOT NULL DEFAULT '0' COMMENT '工作模式(组2)'," + - " VGroupVol_two double NOT NULL DEFAULT '0' COMMENT '组端电压(组2)'," + - " VpeakVol_two double NOT NULL DEFAULT '0' COMMENT '峰值电压(组2)'," + - " RestTime_three int(11) NOT NULL DEFAULT '0' COMMENT '剩余天数(组3)'," + - " WorkState_three int(11) NOT NULL DEFAULT '0' COMMENT '工作模式(组3)'," + - " VGroupVol_three double NOT NULL DEFAULT '0' COMMENT '组端电压(组3)'," + - " VpeakVol_three double NOT NULL DEFAULT '0' COMMENT '峰值电压(组3)'," + - " RestTime_four int(11) NOT NULL DEFAULT '0' COMMENT '剩余天数(组4)'," + - " WorkState_four int(11) NOT NULL DEFAULT '0' COMMENT '工作模式(组4)'," + - " VGroupVol_four double NOT NULL DEFAULT '0' COMMENT '组端电压(组4)'," + - " VpeakVol_four double NOT NULL DEFAULT '0' COMMENT '峰值电压(组4)'," + - " RestTime_five int(11) NOT NULL DEFAULT '0' COMMENT '剩余时间(组5)'," + - " WorkState_five int(11) NOT NULL DEFAULT '0' COMMENT '除硫5状态(组5)'," + - " VGroupVol_five int(11) NOT NULL DEFAULT '0' COMMENT '组端电压(组5)'," + - " VpeakVol_five int(11) NOT NULL DEFAULT '0' COMMENT '峰值电压(组5)'," + - " PRIMARY KEY (num)," + - " UNIQUE KEY unique_battgroupid (BattGroupId) USING BTREE" + - ") ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;"; - Sql_Mysql sql = new Sql_Mysql(pool.getConn()); - ResultSet res = null; - try { - if(recreate) { - sql.sqlMysqlExecute(sql_str1); - } - sql.sqlMysqlExecute(sql_str2); - - //添加剩余时间(组1) - res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns" - + " WHERE table_schema='db_ram_db'" - + " AND table_name='tb_fbs9100s_fod_state'" - + " AND column_name='RestTime_one'"); - if(false == res.next()) { - sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.FBS9100s_fod_state - + " ADD COLUMN RestTime_one int(11) NOT NULL DEFAULT '0' COMMENT '剩余时间(组5)'"); - } - //添加除硫状态(组1) - res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns" - + " WHERE table_schema='db_ram_db'" - + " AND table_name='tb_fbs9100s_fod_state'" - + " AND column_name='WorkState_one'"); - if(false == res.next()) { - sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.FBS9100s_fod_state - + " ADD COLUMN WorkState_one int(11) NOT NULL DEFAULT '0' COMMENT '除硫5状态(组5)'"); - } - //添加组端电压(组1) - res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns" - + " WHERE table_schema='db_ram_db'" - + " AND table_name='tb_fbs9100s_fod_state'" - + " AND column_name='VGroupVol_one'"); - if(false == res.next()) { - sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.FBS9100s_fod_state - + " ADD COLUMN VGroupVol_one int(11) NOT NULL DEFAULT '0' COMMENT '组端电压(组5)'"); - } - //添加峰值电压(组1) - res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns" - + " WHERE table_schema='db_ram_db'" - + " AND table_name='tb_fbs9100s_fod_state'" - + " AND column_name='VpeakVol_one'"); - if(false == res.next()) { - sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.FBS9100s_fod_state - + " ADD COLUMN VpeakVol_one int(11) NOT NULL DEFAULT '0' COMMENT '峰值电压(组5)'"); - } - - //添加剩余时间(组2) - res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns" - + " WHERE table_schema='db_ram_db'" - + " AND table_name='tb_fbs9100s_fod_state'" - + " AND column_name='RestTime_two'"); - if(false == res.next()) { - sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.FBS9100s_fod_state - + " ADD COLUMN RestTime_two int(11) NOT NULL DEFAULT '0' COMMENT '剩余时间(组5)'"); - } - //添加除硫状态(组2) - res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns" - + " WHERE table_schema='db_ram_db'" - + " AND table_name='tb_fbs9100s_fod_state'" - + " AND column_name='WorkState_two'"); - if(false == res.next()) { - sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.FBS9100s_fod_state - + " ADD COLUMN WorkState_two int(11) NOT NULL DEFAULT '0' COMMENT '除硫5状态(组5)'"); - } - //添加组端电压(组2) - res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns" - + " WHERE table_schema='db_ram_db'" - + " AND table_name='tb_fbs9100s_fod_state'" - + " AND column_name='VGroupVol_two'"); - if(false == res.next()) { - sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.FBS9100s_fod_state - + " ADD COLUMN VGroupVol_two int(11) NOT NULL DEFAULT '0' COMMENT '组端电压(组5)'"); - } - //添加峰值电压(组2) - res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns" - + " WHERE table_schema='db_ram_db'" - + " AND table_name='tb_fbs9100s_fod_state'" - + " AND column_name='VpeakVol_two'"); - if(false == res.next()) { - sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.FBS9100s_fod_state - + " ADD COLUMN VpeakVol_two int(11) NOT NULL DEFAULT '0' COMMENT '峰值电压(组5)'"); - } - - //添加剩余时间(组3) - res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns" - + " WHERE table_schema='db_ram_db'" - + " AND table_name='tb_fbs9100s_fod_state'" - + " AND column_name='RestTime_three'"); - if(false == res.next()) { - sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.FBS9100s_fod_state - + " ADD COLUMN RestTime_three int(11) NOT NULL DEFAULT '0' COMMENT '剩余时间(组5)'"); - } - //添加除硫状态(组3) - res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns" - + " WHERE table_schema='db_ram_db'" - + " AND table_name='tb_fbs9100s_fod_state'" - + " AND column_name='WorkState_three'"); - if(false == res.next()) { - sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.FBS9100s_fod_state - + " ADD COLUMN WorkState_three int(11) NOT NULL DEFAULT '0' COMMENT '除硫5状态(组5)'"); - } - //添加组端电压(组3) - res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns" - + " WHERE table_schema='db_ram_db'" - + " AND table_name='tb_fbs9100s_fod_state'" - + " AND column_name='VGroupVol_three'"); - if(false == res.next()) { - sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.FBS9100s_fod_state - + " ADD COLUMN VGroupVol_three int(11) NOT NULL DEFAULT '0' COMMENT '组端电压(组5)'"); - } - //添加峰值电压(组3) - res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns" - + " WHERE table_schema='db_ram_db'" - + " AND table_name='tb_fbs9100s_fod_state'" - + " AND column_name='VpeakVol_three'"); - if(false == res.next()) { - sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.FBS9100s_fod_state - + " ADD COLUMN VpeakVol_three int(11) NOT NULL DEFAULT '0' COMMENT '峰值电压(组5)'"); - } - - //添加剩余时间(组4) - res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns" - + " WHERE table_schema='db_ram_db'" - + " AND table_name='tb_fbs9100s_fod_state'" - + " AND column_name='RestTime_four'"); - if(false == res.next()) { - sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.FBS9100s_fod_state - + " ADD COLUMN RestTime_four int(11) NOT NULL DEFAULT '0' COMMENT '剩余时间(组5)'"); - } - //添加除硫状态(组4) - res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns" - + " WHERE table_schema='db_ram_db'" - + " AND table_name='tb_fbs9100s_fod_state'" - + " AND column_name='WorkState_four'"); - if(false == res.next()) { - sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.FBS9100s_fod_state - + " ADD COLUMN WorkState_four int(11) NOT NULL DEFAULT '0' COMMENT '除硫5状态(组5)'"); - } - //添加组端电压(组4) - res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns" - + " WHERE table_schema='db_ram_db'" - + " AND table_name='tb_fbs9100s_fod_state'" - + " AND column_name='VGroupVol_four'"); - if(false == res.next()) { - sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.FBS9100s_fod_state - + " ADD COLUMN VGroupVol_four int(11) NOT NULL DEFAULT '0' COMMENT '组端电压(组5)'"); - } - //添加峰值电压(组4) - res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns" - + " WHERE table_schema='db_ram_db'" - + " AND table_name='tb_fbs9100s_fod_state'" - + " AND column_name='VpeakVol_four'"); - if(false == res.next()) { - sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.FBS9100s_fod_state - + " ADD COLUMN VpeakVol_four int(11) NOT NULL DEFAULT '0' COMMENT '峰值电压(组5)'"); - } - - //添加剩余时间(组5) - res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns" - + " WHERE table_schema='db_ram_db'" - + " AND table_name='tb_fbs9100s_fod_state'" - + " AND column_name='RestTime_five'"); - if(false == res.next()) { - sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.FBS9100s_fod_state - + " ADD COLUMN RestTime_five int(11) NOT NULL DEFAULT '0' COMMENT '剩余时间(组5)'"); - } - //添加除硫状态(组5) - res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns" - + " WHERE table_schema='db_ram_db'" - + " AND table_name='tb_fbs9100s_fod_state'" - + " AND column_name='WorkState_five'"); - if(false == res.next()) { - sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.FBS9100s_fod_state - + " ADD COLUMN WorkState_five int(11) NOT NULL DEFAULT '0' COMMENT '除硫5状态(组5)'"); - } - //添加组端电压(组5) - res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns" - + " WHERE table_schema='db_ram_db'" - + " AND table_name='tb_fbs9100s_fod_state'" - + " AND column_name='VGroupVol_five'"); - if(false == res.next()) { - sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.FBS9100s_fod_state - + " ADD COLUMN VGroupVol_five int(11) NOT NULL DEFAULT '0' COMMENT '组端电压(组5)'"); - } - //添加峰值电压(组5) - res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns" - + " WHERE table_schema='db_ram_db'" - + " AND table_name='tb_fbs9100s_fod_state'" - + " AND column_name='VpeakVol_five'"); - if(false == res.next()) { - sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.FBS9100s_fod_state - + " ADD COLUMN VpeakVol_five int(11) NOT NULL DEFAULT '0' COMMENT '峰值电压(组5)'"); - } - //添加电池组id字段 - res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns" - + " WHERE table_schema='db_ram_db'" - + " AND table_name='tb_fbs9100s_fod_state'" - + " AND column_name='BattGroupId'"); - if(false == res.next()) { - sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.FBS9100s_fod_state - + " ADD COLUMN BattGroupId int(11) NOT NULL DEFAULT '0' COMMENT '电池组id' AFTER dev_id"); - } - //移除之前的以设备id分组的设备id唯一索引 - res = sql.sqlMysqlQuery("show INDEX FROM "+Sql_Mysql.FBS9100s_fod_state+" WHERE KEY_name = 'unique_dev_id'"); - if(res.next()) { - sql.sqlMysqlExecute("alter table "+Sql_Mysql.FBS9100s_fod_state+" drop index unique_dev_id;"); - } - //添加电池组id为唯一索引 - res = sql.sqlMysqlQuery("show INDEX FROM "+Sql_Mysql.FBS9100s_fod_state+" WHERE KEY_name = 'unique_BattGroupId'"); - if(!res.next()) { - //添加唯一索引前先删除表中记录 - sql.sqlMysqlExecute("DELETE FROM "+Sql_Mysql.FBS9100s_fod_state+" WHERE num>0"); - sql.sqlMysqlExecute("alter table "+Sql_Mysql.FBS9100s_fod_state+" add UNIQUE unique_BattGroupId(BattGroupId);"); - } - //移除之前的以设备id分组的设备id唯一索引 - /*res = sql.sqlMysqlQuery("show INDEX FROM "+Sql_Mysql.FBS9100s_fod_state+" WHERE KEY_name = 'unique_BattGroupId'"); - if(res.next()) { - sql.sqlMysqlExecute("alter table "+Sql_Mysql.FBS9100s_fod_state+" drop index unique_BattGroupId;"); - } - //添加修复设备id为唯一索引 - res = sql.sqlMysqlQuery("show INDEX FROM "+Sql_Mysql.FBS9100s_fod_state+" WHERE KEY_name = 'unique_dev_id'"); - if(!res.next()) { - //添加唯一索引前先删除表中记录 - sql.sqlMysqlExecute("DELETE FROM "+Sql_Mysql.FBS9100s_fod_state+" WHERE num>0"); - sql.sqlMysqlExecute("alter table "+Sql_Mysql.FBS9100s_fod_state+" add UNIQUE unique_dev_id(dev_id);"); - }*/ - } catch (SQLException e) { - e.printStackTrace(); - } finally { - if(null != res) { - try { - res.close(); - } catch (SQLException e) { - e.printStackTrace(); - } - } - sql.close_con(); - } - } - - /** - * 创建除硫状态表 - * @param pool - * @param recreate - */ - public static void createFBS9100SetDLParam_Table(MysqlConnPool pool, boolean recreate) { - String sql_str1 = " DROP TABLE IF EXISTS " + Sql_Mysql.FBS9100SetDLParam_Table; - String sql_str2 = "CREATE TABLE IF NOT EXISTS "+ Sql_Mysql.FBS9100SetDLParam_Table +" (" + - " num int(11) NOT NULL AUTO_INCREMENT," + - " dev_id int(11) NOT NULL DEFAULT '0' COMMENT '设备id'," + - " op_cmd int(11) NOT NULL DEFAULT '0'," + - " test_cmd int(11) NOT NULL DEFAULT '0'," + - " GroupNum int(11) NOT NULL DEFAULT '0' COMMENT '模块编号'," + - " BattGroupNum int(11) NOT NULL DEFAULT '0' COMMENT '电池组号'," + - " STDCap_one int(11) NOT NULL DEFAULT '0' COMMENT '组1标称容量'," + - " FloatVol_one double NOT NULL DEFAULT '0' COMMENT '组1浮充电压'," + - " Strength_one double NOT NULL DEFAULT '0' COMMENT '组1除硫强度'," + - " YHStrength_one double NOT NULL DEFAULT '0' COMMENT '组1养护强度'," + - " TimeLong_one int(11) NOT NULL DEFAULT '0' COMMENT '组1除硫天数'," + - " STDCap_two int(11) NOT NULL DEFAULT '0' COMMENT '组2标称容量'," + - " FloatVol_two double NOT NULL DEFAULT '0' COMMENT '组2浮充电压'," + - " Strength_two double NOT NULL DEFAULT '0' COMMENT '组2除硫强度'," + - " YHStrength_two double NOT NULL DEFAULT '0' COMMENT '组2养护强度'," + - " TimeLong_two int(11) NOT NULL DEFAULT '0' COMMENT '组2除硫天数'," + - " STDCap_three int(11) NOT NULL DEFAULT '0' COMMENT '组3标称容量'," + - " FloatVol_three double NOT NULL DEFAULT '0' COMMENT '组3浮充电压'," + - " Strength_three double NOT NULL DEFAULT '0' COMMENT '组3除硫强度'," + - " YHStrength_three double NOT NULL DEFAULT '0' COMMENT '组3养护强度'," + - " TimeLong_three int(11) NOT NULL DEFAULT '0' COMMENT '组3除硫天数'," + - " STDCap_four int(11) NOT NULL DEFAULT '0' COMMENT '组4标称容量'," + - " FloatVol_four double NOT NULL DEFAULT '0' COMMENT '组4浮充电压'," + - " Strength_four double NOT NULL DEFAULT '0' COMMENT '组4除硫强度'," + - " YHStrength_four double NOT NULL DEFAULT '0' COMMENT '组4养护强度'," + - " TimeLong_four int(11) NOT NULL DEFAULT '0' COMMENT '组4除硫天数'," + - " PRIMARY KEY (num)," + - " UNIQUE KEY unique_dev_id (dev_id)" + - ") ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;"; - Sql_Mysql sql = new Sql_Mysql(pool.getConn()); - ResultSet res = null; - try { - if(recreate) { - sql.sqlMysqlExecute(sql_str1); - } - sql.sqlMysqlExecute(sql_str2); - //添加电池组编号字段 - res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns" - + " WHERE table_schema='db_ram_db'" - + " AND table_name='tb_fbs9100s_fod_param'" - + " AND column_name='BattGroupNum'"); - if(false == res.next()) { - sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.FBS9100SetDLParam_Table - + " ADD COLUMN BattGroupNum int(11) NOT NULL DEFAULT '0' COMMENT '电池组组号'"); - } - //添加标称容量(组5) - res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns" - + " WHERE table_schema='db_ram_db'" - + " AND table_name='tb_fbs9100s_fod_param'" - + " AND column_name='STDCap_five'"); - if(false == res.next()) { - sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.FBS9100SetDLParam_Table - + " ADD COLUMN STDCap_five int(11) NOT NULL DEFAULT '0' COMMENT '组5标称容量'"); - } - //添加浮充电压(组5) - res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns" - + " WHERE table_schema='db_ram_db'" - + " AND table_name='tb_fbs9100s_fod_param'" - + " AND column_name='FloatVol_five'"); - if(false == res.next()) { - sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.FBS9100SetDLParam_Table - + " ADD COLUMN FloatVol_five double NOT NULL DEFAULT '0' COMMENT '组5浮充电压'"); - } - //添加除硫强度(组5) - res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns" - + " WHERE table_schema='db_ram_db'" - + " AND table_name='tb_fbs9100s_fod_param'" - + " AND column_name='Strength_five'"); - if(false == res.next()) { - sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.FBS9100SetDLParam_Table - + " ADD COLUMN Strength_five double NOT NULL DEFAULT '0' COMMENT '组5除硫强度'"); - } - //添加养护强度(组5) - res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns" - + " WHERE table_schema='db_ram_db'" - + " AND table_name='tb_fbs9100s_fod_param'" - + " AND column_name='YHStrength_five'"); - if(false == res.next()) { - sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.FBS9100SetDLParam_Table - + " ADD COLUMN YHStrength_five double NOT NULL DEFAULT '0' COMMENT '组5养护强度'"); - } - //添加剩余时间(组5) - res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns" - + " WHERE table_schema='db_ram_db'" - + " AND table_name='tb_fbs9100s_fod_param'" - + " AND column_name='TimeLong_five'"); - if(false == res.next()) { - sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.FBS9100SetDLParam_Table - + " ADD COLUMN TimeLong_five int(11) NOT NULL DEFAULT '0' COMMENT '组5除硫天数'"); - } - } catch (SQLException e) { - e.printStackTrace(); - } finally { - if(null != res) { - try { - res.close(); - } catch (SQLException e) { - e.printStackTrace(); - } - } - sql.close_con(); - } - } - - /** - * 创建逆变信息表 - */ - public static void createFBS9100_NiBian_State_Table(MysqlConnPool pool, boolean recreate) { - String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.FBS9100_NiBian_State; - String sql_str02 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.FBS9100_NiBian_State + " (" + - " num bigint(20) NOT NULL AUTO_INCREMENT," + - " dev_id bigint(11) NOT NULL DEFAULT '0'," + - " nb_num bigint(11) NOT NULL DEFAULT '0'," + - " record_time datetime NOT NULL DEFAULT '2000-01-01 00:00:00'," + - " AC_ASimVol float NOT NULL DEFAULT '0'," + - " AC_ASimCur float NOT NULL DEFAULT '0'," + - " AC_BSimVol float NOT NULL DEFAULT '0'," + - " AC_BSimCur float NOT NULL DEFAULT '0'," + - " AC_CSimVol float NOT NULL DEFAULT '0'," + - " AC_CSimCur float NOT NULL DEFAULT '0'," + - " A_HZ float NOT NULL DEFAULT '0'," + - " B_HZ float NOT NULL DEFAULT '0'," + - " C_HZ float NOT NULL DEFAULT '0'," + - " Power_Pa float NOT NULL DEFAULT '0'," + - " Power_Pb float NOT NULL DEFAULT '0'," + - " Power_Pc float NOT NULL DEFAULT '0'," + - " Power_Sa float NOT NULL DEFAULT '0'," + - " Power_Sb float NOT NULL DEFAULT '0'," + - " Power_Sc float NOT NULL DEFAULT '0'," + - " Temp1 float NOT NULL DEFAULT '0'," + - " Temp2 float NOT NULL DEFAULT '0'," + - " RunState float NOT NULL DEFAULT '0'," + - " DcACState int(11) NOT NULL DEFAULT '0'," + - " InsulaTionRes1 int(11) NOT NULL DEFAULT '0'," + - " InsulaTionRes2 int(11) NOT NULL DEFAULT '0'," + - " DCInputVol float NOT NULL DEFAULT '0'," + - " DCInputCur float NOT NULL DEFAULT '0'," + - " SetRun_Stop int(11) NOT NULL DEFAULT '0'," + - " SetDischargeCur float NOT NULL DEFAULT '0'," + - " CommTxCnt int(11) NOT NULL DEFAULT '0'," + - " CommRxCnt int(11) NOT NULL DEFAULT '0'," + - " PRIMARY KEY (num)," + - " UNIQUE KEY nb_num_index (nb_num) USING HASH" + - ") ENGINE=InnoDB AUTO_INCREMENT=1 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_socketclient_state 表 - * @param pool - * @param recreate - */ - public static void createSocketClientStateTable(MysqlConnPool pool, boolean recreate) { - String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.SocketClientStateTable; - String sql_str02 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.SocketClientStateTable + " (" + - " num bigint(20) NOT NULL AUTO_INCREMENT," + - " uId int(11) NOT NULL DEFAULT '0'," + - " client_type int(11) NOT NULL DEFAULT '0'," + - " client_id bigint(20) NOT NULL DEFAULT '0'," + - " BattGroupId int(11) NOT NULL DEFAULT '0'," + - " client_is_connected tinyint(1) NOT NULL DEFAULT '0'," + - " client_ip varchar(64) NOT NULL DEFAULT ' '," + - " client_conn_time datetime NOT NULL DEFAULT '1980-01-01 00:00:00'," + - " client_disconn_time datetime NOT NULL DEFAULT '1980-01-01 00:00:00'," + - " PRIMARY KEY (num)," + - " KEY index_user_id (uId)," + - " KEY index_client_type (client_type)" + - ") ENGINE=InnoDB AUTO_INCREMENT=1 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_server_state 表 - * @param pool - * @param recreate - */ - public static void createServerState_Table(MysqlConnPool pool, boolean recreate) { - String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.ServerState_Table; - String sql_str02 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.ServerState_Table + " (" + - " num bigint(20) NOT NULL AUTO_INCREMENT," + - " server_version float NOT NULL DEFAULT '0'," + - " server_datetime datetime NOT NULL DEFAULT '1982-01-01 00:00:00'," + - " max_mem bigint(20) NOT NULL DEFAULT '0'," + - " total_mem bigint(20) NOT NULL DEFAULT '0'," + - " free_men bigint(20) NOT NULL DEFAULT '0'," + - " total_disc_space bigint(20) NOT NULL DEFAULT '0'," + - " free_disc_space bigint(20) NOT NULL DEFAULT '0'," + - " db_conn_max int(11) NOT NULL DEFAULT '0'," + - " db_conn_count int(11) NOT NULL DEFAULT '0'," + - " app_conn_max int(11) NOT NULL DEFAULT '0'," + - " app_busy_conn_cnt int(11) NOT NULL DEFAULT '0'," + - " app_idle_conn_cnt int(11) NOT NULL DEFAULT '0'," + - " server_cpu_rate float NOT NULL DEFAULT '0'," + - " server_network_rate float NOT NULL DEFAULT '0'," + - " PRIMARY KEY (num)" + - ") 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); - - //添加字段app_conn_max - res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns" - + " WHERE table_schema='db_ram_db'" - + " AND table_name='tb_server_state'" - + " AND column_name='app_conn_max'"); - if(false == res.next()) { - sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.ServerState_Table - + " ADD COLUMN app_conn_max int(11) NOT NULL DEFAULT '0';"); - } - - //添加字段app_busy_conn_cnt - res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns" - + " WHERE table_schema='db_ram_db'" - + " AND table_name='tb_server_state'" - + " AND column_name='app_busy_conn_cnt'"); - if(false == res.next()) { - sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.ServerState_Table - + " ADD COLUMN app_busy_conn_cnt int(11) NOT NULL DEFAULT '0';"); - } - - //添加字段app_idle_conn_cnt - res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns" - + " WHERE table_schema='db_ram_db'" - + " AND table_name='tb_server_state'" - + " AND column_name='app_idle_conn_cnt'"); - if(false == res.next()) { - sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.ServerState_Table - + " ADD COLUMN app_idle_conn_cnt int(11) NOT NULL DEFAULT '0';"); - } - - //添加字段server_cpu_rate - res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns" - + " WHERE table_schema='db_ram_db'" - + " AND table_name='tb_server_state'" - + " AND column_name='server_cpu_rate'"); - if(false == res.next()) { - sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.ServerState_Table - + " ADD COLUMN server_cpu_rate float NOT NULL DEFAULT '0';"); - } - - //添加字段 server_network_rate - res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns" - + " WHERE table_schema='db_ram_db'" - + " AND table_name='tb_server_state'" - + " AND column_name='server_network_rate'"); - if(false == res.next()) { - sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.ServerState_Table - + " ADD COLUMN server_network_rate float NOT NULL DEFAULT '0';"); - } - - } catch (SQLException e) { - e.printStackTrace(); - } finally { - if(null != res) { - try { - res.close(); - } catch (SQLException e) { - e.printStackTrace(); - } - } - sql.close_con(); - } - } - - /** - * 创建 tb_ld9_updatestatue 表 - * @param pool - * @param recreate - */ - public static void createLd9_Updatestatue_Table(MysqlConnPool pool, boolean recreate) { - String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.Ld9_Updatestatue_Table; - String sql_str02 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.Ld9_Updatestatue_Table + " (" + - " num bigint(20) NOT NULL AUTO_INCREMENT," + - " dev_id bigint(20) NOT NULL DEFAULT '0'," + - " update_file varchar(200) NOT NULL DEFAULT ''," + - " update_en tinyint(1) NOT NULL DEFAULT '0'," + - " send_upfile_ok tinyint(1) NOT NULL DEFAULT '0'," + - " stopreason int(11) NOT NULL DEFAULT '0'," + - " countpackage int(11) NOT NULL DEFAULT '0'," + - " nowpackagenum int(11) NOT NULL DEFAULT '0'," + - " updatetime datetime NOT NULL DEFAULT '1982-01-01 00:00:00'," + - " starttime datetime NOT NULL DEFAULT '1982-01-01 00:00:00'," + - " note varchar(200) NOT NULL DEFAULT ''," + - " PRIMARY KEY (num)," + - " UNIQUE KEY index_dev_id_uniq (dev_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_ld9_state 表 - * @param pool - * @param recreate - */ - public static void createLd9_State_Table(MysqlConnPool pool, boolean recreate) { - String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.Ld9_State_Table; - String sql_str02 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.Ld9_State_Table + " (" + - " num bigint(20) NOT NULL AUTO_INCREMENT," + - " dev_id int(11) NOT NULL DEFAULT '401900001'," + - " dev_ip varchar(20) NOT NULL DEFAULT '127.0.0.1'," + - " record_datetime datetime NOT NULL DEFAULT '1982-01-01 00:00:00'," + - " dev_version varchar(64) NOT NULL DEFAULT 'v1.01.01'," + - " sys_state int(11) NOT NULL DEFAULT '0'," + - " sys_online_vol float NOT NULL DEFAULT '0.01'," + - " sys_group_vol float NOT NULL DEFAULT '0.01'," + - " sys_now_battnum int(11) NOT NULL DEFAULT '1'," + - " sys_now_battstate int(11) NOT NULL DEFAULT '1'," + - " sys_now_battvol float NOT NULL DEFAULT '0.01'," + - " sys_now_battcurr float NOT NULL DEFAULT '0.01'," + - " sys_now_battcap float NOT NULL DEFAULT '0.01'," + - " sys_now_testtime datetime NOT NULL DEFAULT '1982-01-01 00:00:00'," + - " sys_next_battnum int(11) NOT NULL DEFAULT '1'," + - " sys_next_battstate int(11) NOT NULL DEFAULT '1'," + - " sys_next_battvol float NOT NULL DEFAULT '0.01'," + - " sys_next_battcurr float NOT NULL DEFAULT '0.01'," + - " sys_next_battcap float NOT NULL DEFAULT '0.01'," + - " sys_next_testtime datetime NOT NULL DEFAULT '1982-01-01 00:00:00'," + - " sys_tmp float NOT NULL DEFAULT '0.1'," + - " sys_stop_reason int(11) NOT NULL DEFAULT '1'," + - " dev_commcount int(11) NOT NULL DEFAULT '0'," + - " dev_errcommcount int(11) NOT NULL DEFAULT '0'," + - " timelong int(11) NOT NULL DEFAULT '0'," + - " monvol_hightalarm int(11) NOT NULL DEFAULT '0'," + - " monvol_loweralarm int(11) NOT NULL DEFAULT '0'," + - " moncap_alarm int(11) NOT NULL DEFAULT '0'," + - " montmp_alarm int(11) NOT NULL DEFAULT '0'," + - " monres_alarm int(11) NOT NULL DEFAULT '0'," + - " PRIMARY KEY (num)," + - " UNIQUE KEY index_dev_id (dev_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_ld9_setparam 表 - * @param pool - * @param recreate - */ - public static void createLd9_Setparam_Table(MysqlConnPool pool, boolean recreate) { - String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.Ld9_Setparam_Table; - String sql_str02 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.Ld9_Setparam_Table + " (" + - " num bigint(20) NOT NULL AUTO_INCREMENT," + - " dev_id int(11) NOT NULL DEFAULT '401900001'," + - " op_cmd int(11) NOT NULL DEFAULT '0'," + - " param_teststart_batt_num int(11) NOT NULL DEFAULT '0'," + - " param_cap int(11) NOT NULL DEFAULT '1'," + - " param_discharge_curr float NOT NULL DEFAULT '0.001'," + - " param_mon_curr_high float NOT NULL DEFAULT '0.001'," + - " param_charge_curr float NOT NULL DEFAULT '0.001'," + - " param_mon_curr_low float NOT NULL DEFAULT '0.001'," + - " param_online_vol float NOT NULL DEFAULT '0.01'," + - " param_charge_curr_low float NOT NULL DEFAULT '0.001'," + - " param_charge_cap_low float NOT NULL DEFAULT '0.1'," + - " param_online_vol_recover int(11) NOT NULL DEFAULT '0'," + - " param_module_address int(11) NOT NULL DEFAULT '1'," + - " param_junheng_model int(11) NOT NULL DEFAULT '0'," + - " param_cap_low float NOT NULL DEFAULT '0'," + - " param_datasource int(11) NOT NULL DEFAULT '0'," + - " param_res_args int(11) NOT NULL DEFAULT '0'," + - " param_tmp_high float NOT NULL DEFAULT '0'," + - " param_res_high float NOT NULL DEFAULT '0'," + - " PRIMARY KEY (num)," + - " UNIQUE KEY index_dev_id (dev_id)" + - ") ENGINE=InnoDB AUTO_INCREMENT=1 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_ld9_setparam 表 - * @param pool - * @param recreate - */ - public static void createLd9_Concentratestate_Table(MysqlConnPool pool, boolean recreate) { - String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.Ld9_Concentratestate_Table; - String sql_str02 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.Ld9_Concentratestate_Table + " (" + - " num int(11) NOT NULL AUTO_INCREMENT COMMENT '主键'," + - " dev_id int(11) NOT NULL DEFAULT '0' COMMENT '设备id'," + - " record_time datetime NOT NULL DEFAULT '2000-01-01 00:00:00' COMMENT '记录时间'," + - " systemVersion varchar(255) NOT NULL DEFAULT '' COMMENT '系统版本'," + - " systemState int(11) NOT NULL DEFAULT '0' COMMENT '系统状态'," + - " groupVol float NOT NULL DEFAULT '0' COMMENT '组端电压'," + - " groupCurr float NOT NULL DEFAULT '0' COMMENT '组端电流'," + - " battState int(11) NOT NULL DEFAULT '0' COMMENT '电池状态'," + - " currDirection int(11) NOT NULL DEFAULT '0' COMMENT '电流方向'," + - " rippleCurrAvg float NOT NULL DEFAULT '0' COMMENT '纹波电流均值'," + - " rippleCurrTop float NOT NULL DEFAULT '0' COMMENT '纹波电流峰值'," + - " resTestCount int(11) NOT NULL DEFAULT '0' COMMENT '内阻测试次数'," + - " resTestMethod int(11) NOT NULL DEFAULT '0' COMMENT '内阻测试方法'," + - " PRIMARY KEY (num)," + - " UNIQUE KEY unique_dev_id (dev_id)" + - ") ENGINE=InnoDB AUTO_INCREMENT=1 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_ld9_concentrateparam 表 - * @param pool - * @param recreate - */ - public static void createLd9_Concentrateparam_Table(MysqlConnPool pool, boolean recreate) { - String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.Ld9_Concentrateparam_Table; - String sql_str02 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.Ld9_Concentrateparam_Table + " (" + - " num int(11) NOT NULL AUTO_INCREMENT," + - " dev_id int(11) NOT NULL DEFAULT '0' COMMENT '设备id'," + - " op_cmd int(11) NOT NULL DEFAULT '0' COMMENT '命令控制字段'," + - " addr int(11) NOT NULL DEFAULT '0' COMMENT '汇集器地址(0-2555)'," + - " firthMonCount int(11) NOT NULL DEFAULT '0' COMMENT '第一路单体个数'," + - " secondMonCount int(11) NOT NULL DEFAULT '0' COMMENT '第二路单体个数'," + - " thirdMonCount int(11) NOT NULL DEFAULT '0' COMMENT '第三路单体个数'," + - " fourthMonCount int(11) NOT NULL DEFAULT '0' COMMENT '第四路单体个数'," + - " fifthMonCount int(11) NOT NULL DEFAULT '0' COMMENT '第五路单体个数'," + - " currRange int(11) NOT NULL DEFAULT '0' COMMENT '电流钳量程'," + - " floatCurrLimit float NOT NULL DEFAULT '0' COMMENT '浮充电流门限'," + - " rippleCurrLimit float NOT NULL DEFAULT '0' COMMENT '纹波电流阀值'," + - " autoTestCycle int(11) NOT NULL DEFAULT '1' COMMENT '自动测试周期'," + - " resTestType int(11) NOT NULL DEFAULT '0' COMMENT '内阻测试方法'," + - " dischargeType int(11) NOT NULL DEFAULT '0' COMMENT '放电模式'," + - " battCapStd int(11) NOT NULL DEFAULT '0' COMMENT '标称容量'," + - " backup1 int(11) NOT NULL DEFAULT '0' COMMENT '备用1'," + - " backup2 int(11) NOT NULL DEFAULT '0' COMMENT '备用2'," + - " backup3 int(11) NOT NULL DEFAULT '0' COMMENT '备用3'," + - " backup4 int(11) NOT NULL DEFAULT '0' COMMENT '备用4'," + - " PRIMARY KEY (num)," + - " UNIQUE KEY unique_dev_id (dev_id)" + - ") ENGINE=InnoDB AUTO_INCREMENT=1 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_hard_dev_sms_state 表 - * @param pool - * @param recreate - */ - public static void createHardDevSmsState_Table(MysqlConnPool pool, boolean recreate) { - String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.HardDevSmsState_Table; - String sql_str02 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.HardDevSmsState_Table + " (" + - " num bigint(20) NOT NULL AUTO_INCREMENT," + - " sms_dev_ip varchar(20) NOT NULL DEFAULT '192.168.1.60'," + - " sms_ack_type int(11) NOT NULL DEFAULT '0'," + - " sms_sincard_ok tinyint(1) NOT NULL DEFAULT '0'," + - " sms_mobile_net_ok tinyint(1) NOT NULL DEFAULT '0'," + - " sms_sinal_value int(11) NOT NULL DEFAULT '0'," + - " sms_is_busy tinyint(1) NOT NULL DEFAULT '0'," + - " sms_money_rest float NOT NULL DEFAULT '0'," + - " sms_com_count int(11) NOT NULL DEFAULT '0'," + - " sms_com_err_count int(11) NOT NULL DEFAULT '0'," + - " note varchar(100) NOT NULL DEFAULT ' '," + - " PRIMARY KEY (num)" + - ") ENGINE=MEMORY 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_fbs9600_state 表 - * @param pool - * @param recreate - */ - public static void createFBS9600State_Table(MysqlConnPool pool, boolean recreate) { - String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.FBS9600State_Table; - String sql_str02 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.FBS9600State_Table + " (" + - " num bigint(20) NOT NULL AUTO_INCREMENT," + - " dev_ip varchar(20) NOT NULL DEFAULT '127.0.0.0'," + - " dev_id bigint(20) NOT NULL DEFAULT '0'," + - " op_cmd int(11) NOT NULL DEFAULT '0'," + - " dev_workstate int(11) NOT NULL DEFAULT '0'," + - " dev_alarmstate int(11) NOT NULL DEFAULT '0'," + - " dev_commcount int(11) NOT NULL DEFAULT '0'," + - " dev_errcommcount int(11) NOT NULL DEFAULT '0'," + - " PRIMARY KEY (num)," + - " UNIQUE KEY index_dev_id_uniq (dev_id)" + - ") ENGINE=InnoDB AUTO_INCREMENT=1 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_fbs9100s_dfu_state 表 - * @param pool - * @param recreate - */ - public static void createFBS9100S_DFUState_Table(MysqlConnPool pool, boolean recreate) { - String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.FBS9100S_DFUState_Table; - String sql_str02 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.FBS9100S_DFUState_Table + " (" + - " num bigint(20) NOT NULL AUTO_INCREMENT," + - " dev_id bigint(20) NOT NULL DEFAULT '0'," + - " sysVersion_new int(11) NOT NULL DEFAULT '0'," + - " softVersion_new int(11) NOT NULL DEFAULT '0'," + - " sysVersion_dev int(11) NOT NULL DEFAULT '0'," + - " softVersion_dev int(11) NOT NULL DEFAULT '0'," + - " dfu_file varchar(200) NOT NULL DEFAULT ' '," + - " dfu_en tinyint(1) NOT NULL DEFAULT '0'," + - " dfu_wr_stat int(11) NOT NULL DEFAULT '0'," + - " dfu_data_blocknum int(11) NOT NULL DEFAULT '0'," + - " dfu_data_blocklen int(11) NOT NULL DEFAULT '256'," + - " dfu_password varchar(100) NOT NULL DEFAULT ' '," + - " dfu_file_len int(11) NOT NULL," + - " PRIMARY KEY (num)," + - " UNIQUE KEY index_dev_id_uniq (dev_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_fbs9100s_dcdc_state 表 - * @param pool - * @param recreate - */ - public static void createFBS9100S_DcDcState_Table(MysqlConnPool pool, boolean recreate) { - String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.FBS9100S_DcDcState_Table; - String sql_str02 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.FBS9100S_DcDcState_Table + " (" + - " num bigint(20) NOT NULL AUTO_INCREMENT," + - " dev_id bigint(20) NOT NULL DEFAULT '0'," + - " dcdc_num bigint(20) NOT NULL DEFAULT '0'," + - " dcdc_Vsys float NOT NULL DEFAULT '0'," + - " dcdc_Vout float NOT NULL DEFAULT '0'," + - " dcdc_Vbat float NOT NULL DEFAULT '0'," + - " dcdc_Iout float NOT NULL DEFAULT '0'," + - " dcdc_Ibuck float NOT NULL DEFAULT '0'," + - " dcdc_Tmp_Dis float NOT NULL DEFAULT '0'," + - " dcdc_Tmp_Chr float NOT NULL DEFAULT '0'," + - " dcdc_SMR_Alarm1 int(11) NOT NULL DEFAULT '0'," + - " dcdc_SMR_Alarm2 int(11) NOT NULL DEFAULT '0'," + - " dcdc_version int(11) NOT NULL DEFAULT '0'," + - " dcdc_ModeSetComm int(11) NOT NULL DEFAULT '0'," + - " dcdc_RunSetComm int(11) NOT NULL DEFAULT '0'," + - " dcdc_BuckISet float NOT NULL DEFAULT '0'," + - " dcdc_DisVolSet float NOT NULL DEFAULT '0'," + - " dcdc_DisCurrSet float NOT NULL DEFAULT '0'," + - " dcdc_CommTxCnt int(11) NOT NULL DEFAULT '0'," + - " dcdc_CommRxCnt int(11) NOT NULL DEFAULT '0'," + - " PRIMARY KEY (num)," + - " UNIQUE KEY index_dcdc_num_uniq (dcdc_num)" + - ") ENGINE=MEMORY 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_sysparam 表 - * @param pool - * @param recreate - */ - public static void createFBS9100SysParam_Table(MysqlConnPool pool, boolean recreate) { - String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.FBS9100SysParam_Table; - String sql_str02 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.FBS9100SysParam_Table + " (" + - " num bigint(20) NOT NULL AUTO_INCREMENT," + - " dev_ip varchar(20) NOT NULL DEFAULT '127.0.0.0'," + - " dev_id bigint(20) NOT NULL DEFAULT '0'," + - " op_cmd int(11) NOT NULL DEFAULT '0'," + - " IPADDR varchar(20) NOT NULL DEFAULT '127.0.0.0'," + - " SubIPADDR varchar(20) NOT NULL DEFAULT '127.0.0.0'," + - " NetGateADDR varchar(20) NOT NULL DEFAULT '127.0.0.0'," + - " GroupVolRange int(11) NOT NULL DEFAULT '0'," + - " GroupVolSorce int(11) NOT NULL DEFAULT '0'," + - " CurrentRange int(11) NOT NULL DEFAULT '0'," + - " CurrentTyte int(11) NOT NULL DEFAULT '0'," + - " MonomerOrder int(11) NOT NULL DEFAULT '0'," + - " BackLightTime int(11) NOT NULL DEFAULT '0'," + - " MACADDR varchar(30) NOT NULL DEFAULT '0.0.0.0.0.0'," + - " LoaderCount int(11) NOT NULL DEFAULT '0'," + - " DtCardCount int(11) NOT NULL DEFAULT '0'," + - " PowerBreakChargeCurr float NOT NULL DEFAULT '0'," + - " MajorBattGroupNum int(11) NOT NULL DEFAULT '0'," + - " POF_BG_Boost_Cnt int(11) NOT NULL DEFAULT '0'," + - " POF_BG_Boost_VolStop float NOT NULL DEFAULT '0'," + - " POF_BG_Boost_VolStart float NOT NULL DEFAULT '0'," + - - " `JunHeng_Enabled` int(11) NOT NULL DEFAULT '0' COMMENT '均衡功能启用状态(1:启用;0:禁用)'," + - " `JunHeng_StVol` float NOT NULL DEFAULT '0' COMMENT '均衡停止电压阀值'," + - " `JunHeng_StCurr` float NOT NULL DEFAULT '0' COMMENT '均衡停止电流阀值'," + - " PRIMARY KEY (num)," + - " UNIQUE KEY index_dev_id_uniq (dev_id)" + - ") ENGINE=InnoDB 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); - - //添加字段JunHeng_Enabled 均衡功能启用状态 - res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns" - + " WHERE table_schema='db_ram_db'" - + " AND table_name='tb_fbs9100_sysparam'" - + " AND column_name='JunHeng_Enabled'"); - if(false == res.next()) { - sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.FBS9100SysParam_Table - + " ADD COLUMN `JunHeng_Enabled` int(11) NOT NULL DEFAULT '0' COMMENT '均衡功能启用状态(1:启用;0:禁用)';"); - } - - //添加字段JunHeng_StVol 均衡停止电压阀值 - res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns" - + " WHERE table_schema='db_ram_db'" - + " AND table_name='tb_fbs9100_sysparam'" - + " AND column_name='JunHeng_StVol'"); - if(false == res.next()) { - sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.FBS9100SysParam_Table - + " ADD COLUMN `JunHeng_StVol` float NOT NULL DEFAULT '0' COMMENT '均衡停止电压阀值';"); - } - - //添加字段JunHeng_StCurr 均衡停止电流阀值 - res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns" - + " WHERE table_schema='db_ram_db'" - + " AND table_name='tb_fbs9100_sysparam'" - + " AND column_name='JunHeng_StCurr'"); - if(false == res.next()) { - sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.FBS9100SysParam_Table - + " ADD COLUMN `JunHeng_StCurr` float NOT NULL DEFAULT '0' COMMENT '均衡停止电流阀值';"); - } - } catch (SQLException e) { - e.printStackTrace(); - } finally { - if(null != res) { - try { - res.close(); - } catch (SQLException e) { - e.printStackTrace(); - } - } - sql.close_con(); - } - } - - /** - * 创建 tb_fbs9100_state 表 - * @param pool - * @param recreate - */ - public static void createFBS9100State_Table(MysqlConnPool pool, boolean recreate) { - String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.FBS9100State_Table; - String sql_str02 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.FBS9100State_Table + " (" + - " num bigint(20) NOT NULL AUTO_INCREMENT," + - " dev_ip varchar(20) NOT NULL DEFAULT '127.0.0.0'," + - " dev_version varchar(64) NOT NULL DEFAULT ''," + - " dev_id bigint(20) NOT NULL DEFAULT '0'," + - " op_cmd int(11) NOT NULL DEFAULT '0'," + - " record_datetime varchar(20) NOT NULL DEFAULT '2015-12-02 12:10:00'," + - " dev_datetime varchar(20) NOT NULL DEFAULT '2015-12-02 12:10:00'," + - " dev_testtype int(11) NOT NULL DEFAULT '0'," + - " dev_testgroupnum int(11) NOT NULL DEFAULT '0'," + - " dev_workstate int(11) NOT NULL DEFAULT '0'," + - " dev_alarmstate int(11) NOT NULL DEFAULT '0'," + - " dev_onlinevollow tinyint(1) NOT NULL DEFAULT '0'," + - " dev_eachgroup_battsum int(11) NOT NULL DEFAULT '0'," + - " dev_captest_onlinevol float NOT NULL DEFAULT '0'," + - " dev_captest_groupvol float NOT NULL DEFAULT '0'," + - " dev_captest_curr float NOT NULL DEFAULT '0'," + - " dev_captest_cap float NOT NULL DEFAULT '0'," + - " dev_captest_timelong int(11) NOT NULL DEFAULT '0'," + - " dev_restest_moncount int(11) NOT NULL DEFAULT '0'," + - " dev_restest_monindex int(11) NOT NULL DEFAULT '0'," + - " dev_commcount int(11) NOT NULL DEFAULT '0'," + - " dev_errcommcount int(11) NOT NULL DEFAULT '0'," + - " dev_rxnullerrcount int(11) NOT NULL DEFAULT '0'," + - " dev_temp float NOT NULL DEFAULT '0'," + - " dev_res_test_state int(11) NOT NULL DEFAULT '0'," + - " dev_restest_count int(11) NOT NULL DEFAULT '0'," + - " dev_last_captest_stop_type int(11) NOT NULL DEFAULT '0'," + - " dev_condvoldp float NOT NULL DEFAULT '0'," + - " dev_conresist float NOT NULL DEFAULT '0'," + - " dev_conresist1 float NOT NULL DEFAULT '0'," + - " dev_condcurr float NOT NULL DEFAULT '0'," + - " dev_61850alarms varchar(64) NOT NULL DEFAULT ''," + - " dev_batt_xuhang_tlong int(11) NOT NULL DEFAULT '0'," + - " dev_station_poff_tlong int(11) NOT NULL DEFAULT '0'," + - " dev_station_poff_cnt int(11) NOT NULL DEFAULT '0'," + - " dev_data_flowsum bigint(20) NOT NULL DEFAULT '0'," + - " batt_online_state int(11) NOT NULL DEFAULT '0'," + - " dev_concurr float NOT NULL DEFAULT '0'," + - " PRIMARY KEY (num)," + - " UNIQUE KEY index_dev_id_uniq (dev_id)" + - ") ENGINE=InnoDB AUTO_INCREMENT=1 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_setparam 表 - * @param pool - * @param recreate - */ - public static void createFBS9100SetParam_Table(MysqlConnPool pool, boolean recreate) { - String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.FBS9100SetParam_Table; - String sql_str02 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.FBS9100SetParam_Table + " (" + - " num bigint(20) NOT NULL AUTO_INCREMENT," + - " dev_ip varchar(20) NOT NULL DEFAULT '127.0.0.0'," + - " dev_id bigint(20) NOT NULL DEFAULT '0'," + - " op_cmd int(11) NOT NULL DEFAULT '0'," + - " TestCmd int(11) NOT NULL DEFAULT '0'," + - " HourRate int(11) NOT NULL DEFAULT '0'," + - " DisCurr float NOT NULL DEFAULT '0'," + - " DisCap float NOT NULL DEFAULT '0'," + - " DisTime int(11) NOT NULL DEFAULT '0'," + - " GroupVol_LOW float NOT NULL DEFAULT '0'," + - " MonomerVol_LOW float NOT NULL DEFAULT '0'," + - " MonomerLowCount int(11) NOT NULL DEFAULT '0'," + - " BattGroupNum int(11) NOT NULL DEFAULT '0'," + - " OnlineVolLowAction int(11) NOT NULL DEFAULT '0'," + - " DCVolHighLimit float NOT NULL DEFAULT '0'," + - " ChargeCurrSet float NOT NULL DEFAULT '0'," + - " MonomerTmp_High float NOT NULL DEFAULT '0'," + - " AutoTestStartVol float NOT NULL DEFAULT '0'," + - " OnLineVol_Low float NOT NULL DEFAULT '0'," + - " OffLineYH_Cycle int(11) NOT NULL DEFAULT '0'," + - " OffLineYHstarttime datetime NOT NULL DEFAULT '2000-01-01 00:00:00'," + - " OffLineYHTimes int(11) NOT NULL DEFAULT '1'," + - " OffLineYHOnceCycle int(11) NOT NULL DEFAULT '1'," + - " PRIMARY KEY (num)," + - " UNIQUE KEY index_dev_id_uniq (dev_id)" + - ") ENGINE=MEMORY 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_offlineyhplan 表 - * @param pool - * @param recreate - */ - public static void createFBS9100_offlineyhplan_Table(MysqlConnPool pool, boolean recreate) { - String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.FBS9100_offlineyhplan; - String sql_str02 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.FBS9100_offlineyhplan + " (" + - " num bigint(20) NOT NULL AUTO_INCREMENT," + - " dev_id int(11) NOT NULL DEFAULT '1'," + - " OffLineYH_Cycle int(11) NOT NULL DEFAULT '1'," + - " OffLineYHstarttime datetime NOT NULL DEFAULT '2000-01-01 00:00:00'," + - " OffLineYHTimes int(11) NOT NULL DEFAULT '0'," + - " OffLineYHOnceCycle int(11) NOT NULL DEFAULT '0'," + - " note varchar(255) NOT NULL DEFAULT ''," + - " PRIMARY KEY (num)" + - ") 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_fbs9100_battparam 表 - * @param pool - * @param recreate - */ - public static void createFBS9100BattParam_Table(MysqlConnPool pool, boolean recreate) { - String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.FBS9100BattParam_Table; - String sql_str02 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.FBS9100BattParam_Table + " (" + - " num bigint(20) NOT NULL AUTO_INCREMENT," + - " dev_ip varchar(20) NOT NULL DEFAULT '127.0.0.0'," + - " dev_id bigint(20) NOT NULL DEFAULT '0'," + - " op_cmd int(11) NOT NULL DEFAULT '0'," + - " STD_CAP int(11) NOT NULL DEFAULT '0'," + - " STD_RES int(11) NOT NULL DEFAULT '0'," + - " BattGroupCount int(11) NOT NULL DEFAULT '0'," + - " EachGroupBattCount int(11) NOT NULL DEFAULT '0'," + - " MonomerVol float NOT NULL DEFAULT '0'," + - " GroupVol float NOT NULL DEFAULT '0'," + - " BattTemp float NOT NULL DEFAULT '0'," + - " FloatChargeVol float NOT NULL DEFAULT '0'," + - " FloatChargeCurr float NOT NULL DEFAULT '0'," + - " OnlineVolLow float NOT NULL DEFAULT '0'," + - " GroupConnType int(11) NOT NULL DEFAULT '0'," + - " PRIMARY KEY (num)," + - " UNIQUE KEY index_dev_id_uniq (dev_id)" + - ") ENGINE=MEMORY 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_bts_station_state 表 - * @param pool - * @param recreate - */ - public static void createBTSStationState_Table(MysqlConnPool pool, boolean recreate) { - String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.BTSStationState_Table; - String sql_str02 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.BTSStationState_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_stat int(11) NOT NULL DEFAULT '0'," + - " station_poff_start_time varchar(20) NOT NULL DEFAULT '2015-12-02 12:10:00'," + - " station_fadian_start_time varchar(20) NOT NULL DEFAULT '2015-12-02 12:10:00'," + - " station_diaozhan_start_time varchar(20) NOT NULL DEFAULT '2015-12-02 12:10:00'," + - " station_temp float NOT NULL DEFAULT '0'," + - " station_damp float NOT NULL DEFAULT '0'," + - " station_dooropen_start_time varchar(20) NOT NULL DEFAULT '2015-12-02 12:10:00'," + - " station_xuhang_start_time varchar(20) NOT NULL DEFAULT '2015-12-02 12:10:00'," + - " station_xuhang_end_time varchar(20) NOT NULL DEFAULT '2015-12-02 12:10:00'," + - " PRIMARY KEY (num)," + - " UNIQUE KEY index_station_id_uniq (station_id)" + - ") 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_bts_gprs_state 表 - * @param pool - * @param recreate - */ - public static void createBTSGPRSState_Table(MysqlConnPool pool, boolean recreate) { - String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.BTSGPRSState_Table; - String sql_str02 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.BTSGPRSState_Table + " (" + - " `num` bigint(20) NOT NULL AUTO_INCREMENT," + - " `dev_id` bigint(20) NOT NULL DEFAULT '0'," + - " `op_cmd` int(11) NOT NULL DEFAULT '0'," + - " `AT_cmd` varchar(20) NOT NULL DEFAULT ''," + - " `ack_inf` varchar(50) NOT NULL DEFAULT ''," + - " `bts_task_inf` varchar(1024) NOT NULL DEFAULT ''," + - " PRIMARY KEY (`num`)," + - " UNIQUE KEY `index_dev_id_uniq` (`dev_id`)" + - ") ENGINE=InnoDB AUTO_INCREMENT=5 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_bpm7100_state 表 - * @param pool - * @param recreate - */ - public static void createBMP7100State_Table(MysqlConnPool pool, boolean recreate) { - String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.BMP7100State_Table; - String sql_str02 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.BMP7100State_Table + " (" + - " num bigint(20) NOT NULL AUTO_INCREMENT," + - " dev_ip varchar(20) NOT NULL DEFAULT '127.0.0.0'," + - " dev_id int(11) NOT NULL DEFAULT '0'," + - " op_cmd int(11) NOT NULL DEFAULT '0'," + - " dev_workstate int(11) NOT NULL DEFAULT '0'," + - " dev_worktime bigint(20) NOT NULL DEFAULT '0'," + - " dev_commcount int(11) NOT NULL DEFAULT '0'," + - " dev_errcommcount int(11) NOT NULL DEFAULT '0'," + - " PRIMARY KEY (num)" + - ") ENGINE=MEMORY 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_batt_rtstate 表 - * @param pool - * @param recreate - */ - public static void createBattRtState_Table(MysqlConnPool pool, boolean recreate) { - String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.BattRtState_Table; - String sql_str02 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.BattRtState_Table + " (" + - " num bigint(20) NOT NULL AUTO_INCREMENT," + - " BattGroupId int(11) NOT NULL DEFAULT '0'," + - " batt_count int(11) NOT NULL DEFAULT '0'," + - " rec_datetime datetime NOT NULL DEFAULT '1982-01-01 00:00:00'," + - " online_vol float NOT NULL DEFAULT '0'," + - " group_vol float NOT NULL DEFAULT '0'," + - " group_tmp float NOT NULL DEFAULT '0'," + - " group_curr float NOT NULL DEFAULT '0'," + - " batt_state int(11) NOT NULL DEFAULT '0'," + - " batt_test_type int(11) NOT NULL DEFAULT '0'," + - " batt_test_starttime datetime NOT NULL DEFAULT '1982-01-01 00:00:00'," + - " batt_test_recordtime datetime NOT NULL DEFAULT '1982-01-01 00:00:00'," + - " batt_test_tlong int(11) NOT NULL DEFAULT '0'," + - " batt_test_cap float NOT NULL DEFAULT '0'," + - " batt_real_cap float NOT NULL DEFAULT '0'," + - " batt_rest_cap float NOT NULL DEFAULT '0'," + - " batt_rest_power1_time int(11) NOT NULL DEFAULT '0'," + - " batt_rest_power2_time int(11) NOT NULL DEFAULT '0'," + - " test_loadertype int(11) NOT NULL DEFAULT '0'," + - " test_recordnum int(11) NOT NULL DEFAULT '0'," + - " PRIMARY KEY (num)," + - " KEY index_BattGroupId (BattGroupId)" + - ") ENGINE=InnoDB AUTO_INCREMENT=8 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_batt_rtdata 表 - * @param pool - * @param recreate - */ - public static void createBattRtData_Table(MysqlConnPool pool, boolean recreate) { - String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.BattRtData_Table; - String sql_str02 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.BattRtData_Table + " (" + - " num bigint(20) NOT NULL AUTO_INCREMENT," + - " BattGroupId int(11) NOT NULL DEFAULT '0'," + - " rec_datetime datetime NOT NULL DEFAULT '1982-01-01 00:00:00'," + - " mon_num int(11) NOT NULL DEFAULT '0'," + - " mon_vol float NOT NULL DEFAULT '0'," + - " mon_tmp float NOT NULL DEFAULT '0'," + - " mon_res float NOT NULL DEFAULT '0'," + - " mon_ser float NOT NULL DEFAULT '0'," + - " mon_conn_res float NOT NULL DEFAULT '0'," + - " mon_cap float NOT NULL DEFAULT '0'," + - " mon_JH_curr float NOT NULL DEFAULT '0'," + - " mon_LY_vol float NOT NULL DEFAULT '0'," + - " PRIMARY KEY (num)," + - " KEY index_BattGroupId (BattGroupId)" + - ") ENGINE=InnoDB AUTO_INCREMENT=347 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); - //添加字段mon_JH_curr - res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns" - + " WHERE table_schema='db_ram_db'" - + " AND table_name='tb_batt_rtdata'" - + " AND column_name='mon_JH_curr'"); - if(false == res.next()) { - sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.BattRtData_Table - + " ADD COLUMN mon_JH_curr float NOT NULL DEFAULT '0';"); - } - //添加字段mon_LY_vol - res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns" - + " WHERE table_schema='db_ram_db'" - + " AND table_name='tb_batt_rtdata'" - + " AND column_name='mon_LY_vol'"); - if(false == res.next()) { - sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.BattRtData_Table - + " ADD COLUMN mon_LY_vol float NOT NULL DEFAULT '0';"); - } - } catch (SQLException e) { - e.printStackTrace(); - } finally { - sql.close_con(); - } - } - /** - * 创建 tb_61850_jhstate 表 - * @param pool - * @param recreate - */ - public static void create61850_JHState_Table(MysqlConnPool pool, boolean recreate) { - String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.TB_61850_JHState_Table; - String sql_str02 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.TB_61850_JHState_Table + " (" + - " num bigint(20) NOT NULL AUTO_INCREMENT," + - " dev_id int(11) NOT NULL DEFAULT '0'," + - " dev_version varchar(255) NOT NULL DEFAULT ''," + - " input_vol_total double NOT NULL DEFAULT '0'," + - " output_vol_total double NOT NULL DEFAULT '0'," + - " input_curr_total double NOT NULL DEFAULT '0'," + - " output_curr_total double NOT NULL DEFAULT '0'," + - " output_vol_one double NOT NULL DEFAULT '0'," + - " output_vol_two double NOT NULL DEFAULT '0'," + - " output_vol_three double NOT NULL DEFAULT '0'," + - " output_vol_four double NOT NULL DEFAULT '0'," + - " output_vol_five double NOT NULL DEFAULT '0'," + - " output_vol_six double NOT NULL DEFAULT '0'," + - " output_vol_seven double NOT NULL DEFAULT '0'," + - " output_vol_eight double NOT NULL DEFAULT '0'," + - " output_vol_nine double NOT NULL DEFAULT '0'," + - " output_vol_ten double NOT NULL DEFAULT '0'," + - " dev_temp double NOT NULL DEFAULT '0'," + - " PRIMARY KEY (num)," + - " UNIQUE KEY index_dev_id_unique (dev_id) USING BTREE" + - ") ENGINE=InnoDB AUTO_INCREMENT=9046 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(); - } - } - /** - * 创建 cmcc_power_data 表 - * @param pool - * @param recreate - */ - public static void createRamDB_CMCC_POWER_Data_Table(MysqlConnPool pool, boolean recreate) { - String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.RamDB_CMCC_POWER_Data; - String sql_str02 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.RamDB_CMCC_POWER_Data + " (" + - " num bigint(20) NOT NULL AUTO_INCREMENT," + - " dev_id bigint(20) NOT NULL DEFAULT '0'," + - " vol1 float NOT NULL DEFAULT '0'," + - " vol2 float NOT NULL DEFAULT '0'," + - " vol3 float NOT NULL DEFAULT '0'," + - " vol4 float NOT NULL DEFAULT '0'," + - " vol5 float NOT NULL DEFAULT '0'," + - " curr1 float NOT NULL DEFAULT '0'," + - " curr2 float NOT NULL DEFAULT '0'," + - " curr3 float NOT NULL DEFAULT '0'," + - " curr4 float NOT NULL DEFAULT '0'," + - " curr5 float NOT NULL DEFAULT '0'," + - " PRIMARY KEY (num)," + - " UNIQUE KEY index_dev_id_uniq (dev_id)" + - ") ENGINE=InnoDB AUTO_INCREMENT=1 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_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 '记录时间'," + - " `dev_version` varchar(64) NOT NULL DEFAULT '' 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'"); - } - //添加字段dev_version - res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns" - + " WHERE table_schema='db_ram_db'" - + " AND table_name='tb_fbs9100_insulatstate'" - + " AND column_name='dev_version'"); - if(false == res.next()) { - sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.FBS9100_InsulatstateTable - + " ADD COLUMN `dev_version` varchar(64) NOT NULL DEFAULT '' COMMENT '协转版本号';"); - } - } 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_lithium_data 表 - * @param pool - * @param recreate - */ - public static void createTb_Lithium_DataTable(MysqlConnPool pool, boolean recreate) { - String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.Tb_Lithium_DataTable; - String sql_str02 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.Tb_Lithium_DataTable + " (" + - " `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 '记录时间'," + - " `envir_tmp` float NOT NULL DEFAULT '0' COMMENT '环境温度'," + - " `power_tmp` float NOT NULL DEFAULT '0' COMMENT '功率温度'," + - " `rest_cap` float NOT NULL DEFAULT '0' COMMENT '剩余容量'," + - " `remote_control_count` int(11) NOT NULL DEFAULT '0' COMMENT '自定义遥控数量'," + - " `batt_total_cap` float NOT NULL DEFAULT '0' COMMENT '电池总容量'," + - " `batt_cycles` int(11) NOT NULL DEFAULT '0' COMMENT '电池循环次数'," + - " `evir_tmp_alm_state` int(11) NOT NULL DEFAULT '0' COMMENT '环境温度告警状态'," + - " `power_tmp_alm_state` int(11) NOT NULL DEFAULT '0' COMMENT '功率温度告警状态'," + - " `discharge_curr_alm_state` int(11) NOT NULL DEFAULT '0' COMMENT '充放电电流告警状态'," + - " `batt_totalvol_alm_state` int(11) NOT NULL DEFAULT '0' COMMENT '电池总电压告警状态'," + - " `custom_alm_count` int(11) NOT NULL DEFAULT '0' COMMENT '自定义告警量数量'," + - " `junheng_event_code` int(11) NOT NULL DEFAULT '0' COMMENT '均衡事件代码'," + - " `vol_event_code` int(11) NOT NULL DEFAULT '0' COMMENT '电压事件代码'," + - " `tmp_event_code` int(11) NOT NULL DEFAULT '0' COMMENT '温度事件代码'," + - " `curr_event_code` int(11) NOT NULL DEFAULT '0' COMMENT '电流事件代码'," + - " `fet_state_code` int(11) NOT NULL DEFAULT '0' COMMENT 'FET状态代码'," + - " `junheng_state_code` int(11) NOT NULL DEFAULT '0' COMMENT '均衡状态代码'," + - " `sys_state_code` int(11) NOT NULL DEFAULT '0' COMMENT '系统状态代码'," + - " `note` varchar(255) NOT NULL DEFAULT '' COMMENT '备用'," + - " PRIMARY KEY (`num`)" + - ") 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(); - } - } - - /** - * 创建组端信息告警记录表 - * @param pool - * @param recreate - */ - 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," + - " `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 '组电压告警'," + - " `test_end_vol` float NOT NULL DEFAULT '0' COMMENT '测试终止电压'," + - " `test_end_cap` float NOT NULL DEFAULT '0' COMMENT '测试终止剩余容量'," + - " `test_timelong` int(11) NOT NULL DEFAULT '0' COMMENT '测试终止时间(秒)'," + - " PRIMARY KEY (`num`)," + - " KEY `index_BattGroupId` (`BattGroupId`) USING BTREE," + - " KEY `index_record_time` (`record_time`) USING BTREE" + - ") ENGINE=InnoDB DEFAULT CHARSET=utf8;"; - Sql_Mysql sql = new Sql_Mysql(pool.getConn()); - - try { - if(true == recreate) { - sql.sqlMysqlExecute(sql_str01); - } - //System.out.println(sql_str02); - sql.sqlMysqlExecute(sql_str02); - //添加未录入电池组的组端信息 - String sql_str03 = "INSERT INTO " + Sql_Mysql.Tb_Batt_RSAlarm_Table + " (BattGroupId)" + - " SELECT BattGroupId FROM " + Sql_Mysql.BattInf_Table + - " WHERE BattGroupId NOT IN (SELECT BattGroupId FROM " + Sql_Mysql.Tb_Batt_RSAlarm_Table + ")"; - //System.out.println(sql_str03); - sql.sqlMysqlExecute(sql_str03); - } catch (SQLException e) { - e.printStackTrace(); - } finally { - sql.close_con(); - } - } - - /** - * 创建单体信息告警记录表 - * @param pool - * @param recreate - */ - public static void createTb_Batt_RTAlarm_Table(MysqlConnPool pool, boolean recreate) { - String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.Tb_Batt_RTAlarm_Table; - String sql_str02 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.Tb_Batt_RTAlarm_Table + " (" + - " `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 '记录时间'," + - " `mon_num` int(11) NOT NULL DEFAULT '0' COMMENT '单体编号'," + - " `monvol_alm` tinyint(4) NOT NULL DEFAULT '0' COMMENT '单体电压告警'," + - " `montmp_alm` tinyint(4) NOT NULL DEFAULT '0' COMMENT '单体温度告警'," + - " `monres_alm` tinyint(4) NOT NULL DEFAULT '0' COMMENT '单体内阻告警'," + - " `monrestcap_alm` tinyint(4) NOT NULL DEFAULT '0' COMMENT '单体剩余容量告警'," + - " PRIMARY KEY (`num`)," + - " KEY `index_BattGroupId` (`BattGroupId`) USING BTREE," + - " KEY `index_record_time` (`record_time`) USING BTREE" + - ") 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); - - ResultSet res_t = sql.sqlMysqlQuery("SELECT BattGroupId,MonCount FROM " + Sql_Mysql.BattInf_Table); - while(res_t.next()) { - int bg_id = res_t.getInt("BattGroupId"); - int mon_cnt = res_t.getInt("MonCount"); - - if(mon_cnt > 0){ - - int max_monnum = BattData_RT_RamDB_Thread_SQL.seachBattRTAlarmMaxMonNum(pool,bg_id); //当前电池组在 tb_batt_rtdata 表中的最大单体个数 - if(mon_cnt > max_monnum){ - //需要从max_monnum开始添加单体记录 - String sql_str2 = "INSERT INTO " + Sql_Mysql.Tb_Batt_RTAlarm_Table + "(BattGroupId, mon_num)" + " VALUES "; - boolean isStart = true; - for(int mc = max_monnum; mc < mon_cnt; mc++) { - if(isStart) { - isStart = false; - }else{ - sql_str2 += ","; - } - sql_str2 += "(" + bg_id + "," + (mc+1) + ")"; - } - System.out.println("电池组"+bg_id+"从单体"+(max_monnum+1)+"开始在tb_batt_rtdata表中添加单体数据 at " + Com.getDateTimeFormat(new Date(), Com.DTF_YMDhms)); - sql.sqlMysqlExecute(sql_str2); - }else if(mon_cnt < max_monnum){ - //删除当前电池组中超过单体个数的数据 - String sql_str2 = " DELETE FROM " + Sql_Mysql.Tb_Batt_RTAlarm_Table + " WHERE BattGroupId = " +bg_id+ " AND mon_num > "+mon_cnt; - sql.sqlMysqlExecute(sql_str2); - System.out.println("电池组"+bg_id+"从单体"+(mon_cnt+1)+"开始删除tb_batt_rtdata单体数据 at "+Com.getDateTimeFormat(new Date(), Com.DTF_YMDhms)); - } - } - } - - } 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 '记录时间'," + - " `dev_version` varchar(64) NOT NULL DEFAULT '' 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';"); - } - //添加字段dev_version - res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns" - + " WHERE table_schema='db_ram_db'" - + " AND table_name='tb_fbs9100_chargerstate'" - + " AND column_name='dev_version'"); - if(false == res.next()) { - sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.FBS9100_ChargerstateTable - + " ADD COLUMN `dev_version` varchar(64) NOT NULL DEFAULT '' COMMENT '协转版本号';"); - } - } catch (SQLException e) { - e.printStackTrace(); - } finally { - if(null != res) { - try { - res.close(); - } catch (SQLException e) { - e.printStackTrace(); - } - } - sql.close_con(); - } - } - - /** - * 创建干接点状态表 - * @param pool - * @param recreate - */ - private static void createFBS9100s_stemnode_state_Table(MysqlConnPool pool, boolean recreate) { - String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.FBS9100s_stemnode_state_Table; - String sql_str02 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.FBS9100s_stemnode_state_Table + " (" + - " `num` bigint(20) NOT NULL AUTO_INCREMENT," + - " `dev_id` int(11) NOT NULL," + - " `record_time` datetime NOT NULL DEFAULT '2000-01-01 00:00:00' COMMENT '记录时间'," + - " `dryInputState` int(11) NOT NULL DEFAULT '0' COMMENT '干节点输入状态'," + - " `dryOutputState` int(11) NOT NULL DEFAULT '0' COMMENT '干节点输出状态'," + - " `volOutputState` int(11) NOT NULL DEFAULT '0' COMMENT '干节点电压输出状态'," + - " `sumOutputVolt` float NOT NULL DEFAULT '0' COMMENT '总输出电压'," + - " `sumOutputCur` float NOT NULL DEFAULT '0' COMMENT '总输出电流'," + - " `outputVolt1` float NOT NULL DEFAULT '0' COMMENT '输出电压1'," + - " `outputVolt2` float NOT NULL DEFAULT '0' COMMENT '输出电压2'," + - " `outputVolt3` float NOT NULL DEFAULT '0' COMMENT '输出电压3'," + - " `outputVolt4` float NOT NULL DEFAULT '0' COMMENT '输出电压4'," + - " PRIMARY KEY (`num`)," + - " UNIQUE KEY `index_dev_id` (`dev_id`) USING BTREE" + - ") 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(); - } - - } - - /** - * 创建母联状态表 - * @param pool - * @param recreate - */ - private static void createFBS9100s_buscouple_state_Table(MysqlConnPool pool, boolean recreate) { - String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.FBS9100s_buscouple_state_Table; - String sql_str02 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.FBS9100s_buscouple_state_Table + " (" + - " `num` bigint(20) NOT NULL AUTO_INCREMENT," + - " `dev_id` int(11) NOT NULL DEFAULT '912000001' COMMENT '设备id'," + - " `record_time` datetime NOT NULL DEFAULT '2000-01-01 00:00:00' COMMENT '记录时间'," + - " `fanglei_state` int(11) NOT NULL DEFAULT '0' COMMENT '防雷状态:0:未连接;1:正常工作;2需要更换防雷设备'," + - " `workstate` int(11) NOT NULL DEFAULT '0' COMMENT '工作状态'," + - " `rlayworkmode` int(11) NOT NULL DEFAULT '0' COMMENT '空开操作状态'," + - " `rlyAstate` int(11) NOT NULL DEFAULT '0' COMMENT '开关输入ON状态'," + - " `rlyBstate` int(11) NOT NULL DEFAULT '0' COMMENT '开关输入OFF状态'," + - " `stopreson` int(11) NOT NULL DEFAULT '0' COMMENT '停止原因'," + - " `volt_m1` float NOT NULL DEFAULT '0' COMMENT '电压1'," + - " `volt_m2` float NOT NULL DEFAULT '0' COMMENT '电压2'," + - " `iout` float NOT NULL DEFAULT '0' COMMENT '电流'," + - " `curdir` int(11) NOT NULL DEFAULT '0' COMMENT '电流方向'," + - " `commustate` int(11) NOT NULL DEFAULT '0' COMMENT '通信状态'," + - " PRIMARY KEY (`num`)," + - " UNIQUE KEY `index_dev_id` (`dev_id`) USING BTREE" + - ") ENGINE=InnoDB AUTO_INCREMENT=3 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(); - } - - } - - /** - * 创建充放电一体机下载控制表 - * @param pool - * @param recreate - */ - private static void createFgcd_filedownload_Table(MysqlConnPool pool, boolean recreate) { - String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.Fgcd_filedownload_Table; - String sql_str02 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.Fgcd_filedownload_Table + " (" + - " `num` bigint(20) NOT NULL AUTO_INCREMENT," + - " `dev_id` int(11) NOT NULL DEFAULT '0' COMMENT '设备id'," + - " `BattGroupId` int(11) NOT NULL DEFAULT '0' COMMENT '电池组ID'," + - " `op_cmd` int(11) NOT NULL DEFAULT '0' COMMENT '命令'," + - " `file_total` int(11) NOT NULL DEFAULT '0' COMMENT '总的文件数目'," + - " `file_count` int(11) NOT NULL DEFAULT '0' COMMENT '当前页数据文件数'," + - " `file_index` int(11) NOT NULL DEFAULT '0' COMMENT '需要下载文件索引'," + - " `file_name1` varchar(255) NOT NULL DEFAULT '' COMMENT '文件名1'," + - " `file_index1` int(11) NOT NULL DEFAULT '0' COMMENT '文件索引1'," + - " `test_timelong1` int(11) NOT NULL DEFAULT '0' COMMENT '测试时长1'," + - " `data_type1` int(11) NOT NULL DEFAULT '0' COMMENT '数据类型1'," + - " `test_curr1` float NOT NULL DEFAULT '0' COMMENT '测试电流1'," + - " `test_cap1` float NOT NULL DEFAULT '0' COMMENT '测试容量1'," + - " `cap_std1` int(11) NOT NULL DEFAULT '0' COMMENT '标称容量1'," + - " `mon_count1` int(11) NOT NULL DEFAULT '0' COMMENT '单体数量1'," + - " `mon_vol1` float NOT NULL DEFAULT '0' COMMENT '单体电压类型1'," + - " `stop_type1` int(11) NOT NULL DEFAULT '0' COMMENT '停止原因1'," + - " `download_flag1` int(11) NOT NULL DEFAULT '0' COMMENT '下载标识1'," + - " `download_state1` int(11) NOT NULL DEFAULT '0' COMMENT '下载状态1'," + - " `file_name2` varchar(255) NOT NULL DEFAULT '' COMMENT '文件名2'," + - " `file_index2` int(11) NOT NULL DEFAULT '0' COMMENT '文件索引2'," + - " `test_timelong2` int(11) NOT NULL DEFAULT '0' COMMENT '测试时长2'," + - " `data_type2` int(11) NOT NULL DEFAULT '0' COMMENT '数据类型2'," + - " `test_curr2` float NOT NULL DEFAULT '0' COMMENT '测试电流2'," + - " `test_cap2` float NOT NULL DEFAULT '0' COMMENT '测试容量2'," + - " `cap_std2` int(11) NOT NULL DEFAULT '0' COMMENT '标称容量2'," + - " `mon_count2` int(11) NOT NULL DEFAULT '0' COMMENT '单体数量2'," + - " `mon_vol2` float NOT NULL DEFAULT '0' COMMENT '单体电压类型2'," + - " `stop_type2` int(11) NOT NULL DEFAULT '0' COMMENT '停止原因2'," + - " `download_flag2` int(11) NOT NULL DEFAULT '0' COMMENT '下载标识2'," + - " `download_state2` int(11) NOT NULL DEFAULT '0' COMMENT '下载状态2'," + - " `file_name3` varchar(255) NOT NULL DEFAULT '' COMMENT '文件名3'," + - " `file_index3` int(11) NOT NULL DEFAULT '0' COMMENT '文件索引3'," + - " `test_timelong3` int(11) NOT NULL DEFAULT '0' COMMENT '测试时长3'," + - " `data_type3` int(11) NOT NULL DEFAULT '0' COMMENT '数据类型3'," + - " `test_curr3` float NOT NULL DEFAULT '0' COMMENT '测试电流3'," + - " `test_cap3` float NOT NULL DEFAULT '0' COMMENT '测试容量3'," + - " `cap_std3` int(11) NOT NULL DEFAULT '0' COMMENT '标称容量3'," + - " `mon_count3` int(11) NOT NULL DEFAULT '0' COMMENT '单体数量3'," + - " `mon_vol3` float NOT NULL DEFAULT '0' COMMENT '单体电压类型3'," + - " `stop_type3` int(11) NOT NULL DEFAULT '0' COMMENT '停止原因3'," + - " `download_flag3` int(11) NOT NULL DEFAULT '0' COMMENT '下载标识3'," + - " `download_state3` int(11) NOT NULL DEFAULT '0' COMMENT '下载状态3'," + - " `file_name4` varchar(255) NOT NULL DEFAULT '' COMMENT '文件名4'," + - " `file_index4` int(11) NOT NULL DEFAULT '0' COMMENT '文件索引4'," + - " `test_timelong4` int(11) NOT NULL DEFAULT '0' COMMENT '测试时长4'," + - " `data_type4` int(11) NOT NULL DEFAULT '0' COMMENT '数据类型4'," + - " `test_curr4` float NOT NULL DEFAULT '0' COMMENT '测试电流4'," + - " `test_cap4` float NOT NULL DEFAULT '0' COMMENT '测试容量4'," + - " `cap_std4` int(11) NOT NULL DEFAULT '0' COMMENT '标称容量4'," + - " `mon_count4` int(11) NOT NULL DEFAULT '0' COMMENT '单体数量4'," + - " `mon_vol4` float NOT NULL DEFAULT '0' COMMENT '单体电压类型4'," + - " `download_flag4` int(11) NOT NULL DEFAULT '0' COMMENT '下载标识4'," + - " `download_state4` int(11) NOT NULL DEFAULT '0' COMMENT '下载状态4'," + - " `stop_type4` int(11) NOT NULL DEFAULT '0' COMMENT '停止原因4'," + - " `file_name5` varchar(255) NOT NULL DEFAULT '' COMMENT '文件名5'," + - " `file_index5` int(11) NOT NULL DEFAULT '0' COMMENT '文件索引5'," + - " `test_timelong5` int(11) NOT NULL DEFAULT '0' COMMENT '测试时长5'," + - " `data_type5` int(11) NOT NULL DEFAULT '0' COMMENT '数据类型5'," + - " `test_curr5` float NOT NULL DEFAULT '0' COMMENT '测试电流5'," + - " `test_cap5` float NOT NULL DEFAULT '0' COMMENT '测试容量5'," + - " `cap_std5` int(11) NOT NULL DEFAULT '0' COMMENT '标称容量5'," + - " `mon_count5` int(11) NOT NULL DEFAULT '0' COMMENT '单体数量5'," + - " `mon_vol5` float NOT NULL DEFAULT '0' COMMENT '单体电压类型5'," + - " `stop_type5` int(11) NOT NULL DEFAULT '0' COMMENT '停止原因5'," + - " `download_flag5` int(11) NOT NULL DEFAULT '0' COMMENT '下载标识5'," + - " `download_state5` int(11) NOT NULL DEFAULT '0' COMMENT '下载状态5'," + - " `file_name6` varchar(255) NOT NULL DEFAULT '' COMMENT '文件名6'," + - " `file_index6` int(11) NOT NULL DEFAULT '0' COMMENT '文件索引6'," + - " `test_timelong6` int(11) NOT NULL DEFAULT '0' COMMENT '测试时长6'," + - " `data_type6` int(11) NOT NULL DEFAULT '0' COMMENT '数据类型6'," + - " `test_curr6` float NOT NULL DEFAULT '0' COMMENT '测试电流6'," + - " `test_cap6` float NOT NULL DEFAULT '0' COMMENT '测试容量6'," + - " `cap_std6` int(11) NOT NULL DEFAULT '0' COMMENT '标称容量6'," + - " `mon_count6` int(11) NOT NULL DEFAULT '0' COMMENT '单体数量6'," + - " `mon_vol6` float NOT NULL DEFAULT '0' COMMENT '单体电压类型6'," + - " `stop_type6` int(11) NOT NULL DEFAULT '0' COMMENT '停止原因6'," + - " `download_flag6` int(11) NOT NULL DEFAULT '0' COMMENT '下载标识6'," + - " `download_state6` int(11) NOT NULL DEFAULT '0' COMMENT '下载状态6'," + - " `file_name7` varchar(255) NOT NULL DEFAULT '' COMMENT '文件名7'," + - " `file_index7` int(11) NOT NULL DEFAULT '0' COMMENT '文件索引7'," + - " `test_timelong7` int(11) NOT NULL DEFAULT '0' COMMENT '测试时长7'," + - " `data_type7` int(11) NOT NULL DEFAULT '0' COMMENT '数据类型7'," + - " `test_curr7` float NOT NULL DEFAULT '0' COMMENT '测试电流7'," + - " `test_cap7` float NOT NULL DEFAULT '0' COMMENT '测试容量7'," + - " `cap_std7` int(11) NOT NULL DEFAULT '0' COMMENT '标称容量7'," + - " `mon_count7` int(11) NOT NULL DEFAULT '0' COMMENT '单体数量7'," + - " `mon_vol7` float NOT NULL DEFAULT '0' COMMENT '单体电压类型7'," + - " `stop_type7` int(11) NOT NULL DEFAULT '0' COMMENT '停止原因7'," + - " `download_flag7` int(11) NOT NULL DEFAULT '0' COMMENT '下载状态7'," + - " `download_state7` int(11) NOT NULL DEFAULT '0' COMMENT '下载状态7'," + - " `file_name8` varchar(255) NOT NULL DEFAULT '' COMMENT '文件名8'," + - " `file_index8` int(11) NOT NULL DEFAULT '0' COMMENT '文件索引8'," + - " `test_timelong8` int(11) NOT NULL DEFAULT '0' COMMENT '测试时长8'," + - " `data_type8` int(11) NOT NULL DEFAULT '0' COMMENT '数据类型8'," + - " `test_curr8` float NOT NULL DEFAULT '0' COMMENT '测试电流8'," + - " `test_cap8` float NOT NULL DEFAULT '0' COMMENT '测试容量8'," + - " `cap_std8` int(11) NOT NULL DEFAULT '0' COMMENT '标称容量8'," + - " `mon_count8` int(11) NOT NULL DEFAULT '0' COMMENT '单体数量8'," + - " `mon_vol8` float NOT NULL DEFAULT '0' COMMENT '单体电压类型8'," + - " `stop_type8` int(11) NOT NULL DEFAULT '0' COMMENT '停止原因8'," + - " `download_flag8` int(11) NOT NULL DEFAULT '0' COMMENT '下载标识8'," + - " `download_state8` int(11) NOT NULL DEFAULT '0' COMMENT '下载状态8'," + - " `stop_reason` int(11) NOT NULL DEFAULT '0' COMMENT '异常停止原因'," + - " `download_state` int(11) NOT NULL DEFAULT '0' COMMENT '下载状态[1:下载文件;2:生成文件;3:解析数据;4:导入完成]'," + - " `now_data_block` int(11) NOT NULL DEFAULT '0' COMMENT '当前下载进度'," + - " `total_data_block` int(11) NOT NULL DEFAULT '0' COMMENT '总的数据块数'," + - " PRIMARY KEY (`num`)," + - " UNIQUE KEY `index_dev_id` (`dev_id`) USING BTREE" + - ") 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(); - } - - } - -} +package com.database_util; + +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.Date; + +import com.base.Com; +import com.battdata_rt.BattData_RT_RamDB_Thread_SQL; +import com.sql.MysqlConnPool; +import com.sql.Sql_Mysql; + +public class DB_Ram_db { + + public static void init(MysqlConnPool pool, boolean recreate) { + createDb_Ram_Db(pool); + + createFBS9100s_fod_state(pool,recreate); //创建除硫状态表tb_fbs9100s_fod_state + + createFBS9100SetDLParam_Table(pool,recreate); //创建除硫参数表 + + createFBS9100_NiBian_State_Table(pool, recreate); //创建逆变信息表 + + + createSocketClientStateTable(pool, recreate); + + createServerState_Table(pool, recreate); + + createLd9_Updatestatue_Table(pool, recreate); + + createLd9_State_Table(pool, recreate); + + createLd9_Setparam_Table(pool, recreate); + + createLd9_Concentratestate_Table(pool, recreate); + + createLd9_Concentrateparam_Table(pool, recreate); + + createHardDevSmsState_Table(pool, recreate); + + createFBS9600State_Table(pool, recreate); + + createFBS9100S_DFUState_Table(pool, recreate); + + createFBS9100S_DcDcState_Table(pool, recreate); + + createFBS9100SysParam_Table(pool, recreate); + + createFBS9100State_Table(pool, recreate); + + createFBS9100SetParam_Table(pool, recreate); + + createFBS9100_offlineyhplan_Table(pool, recreate); + + createFBS9100BattParam_Table(pool, recreate); + + createBTSStationState_Table(pool, recreate); + + createBTSGPRSState_Table(pool, recreate); + + createBMP7100State_Table(pool, recreate); + + createBattRtState_Table(pool, recreate); + + createBattRtData_Table(pool, recreate); + + create61850_JHState_Table(pool, recreate); + + createRamDB_CMCC_POWER_Data_Table(pool, recreate); + + createFBS9100_CollectionstateTable(pool, recreate); + + createFBS9100_InsulatstateTable(pool, recreate); + + createFBS9100_ChargerstateTable(pool, recreate); + + createTb_Lithium_DataTable(pool, recreate); + + //南京送检特有 + createTb_Batt_RTAlarm_Table(pool, recreate); + //南京送检特有 + createTb_Batt_RSAlarm_Table(pool, recreate); + + //创建干节点状态表 + createFBS9100s_stemnode_state_Table(pool, recreate); + + //创建母联开关状态表 + createFBS9100s_buscouple_state_Table(pool, recreate); + + //创建FGCD充放电一体机下载控制表 + createFgcd_filedownload_Table(pool, recreate); + } + + + + + + /** + * 创建 web_site 数据库 + * @param pool + */ + public static void createDb_Ram_Db(MysqlConnPool pool) { + Sql_Mysql sql = new Sql_Mysql(pool.getConn()); + try { + sql.sqlMysqlExecute("CREATE DATABASE IF NOT EXISTS " + Sql_Mysql.DB_RamDB); + } catch (SQLException e) { + e.printStackTrace(); + } finally { + sql.close_con(); + } + } + + /** + * 创建除硫状态表 + * @param pool + * @param recreate + */ + public static void createFBS9100s_fod_state(MysqlConnPool pool, boolean recreate) { + String sql_str1 = " DROP TABLE IF EXISTS " + Sql_Mysql.FBS9100s_fod_state; + String sql_str2 = "CREATE TABLE IF NOT EXISTS "+ Sql_Mysql.FBS9100s_fod_state +" (" + + " num int(11) NOT NULL AUTO_INCREMENT," + + " dev_id int(11) NOT NULL DEFAULT '0' COMMENT '设备id'," + + " BattGroupId int(11) NOT NULL DEFAULT '0' COMMENT '电池组id'," + + " record_time datetime NOT NULL DEFAULT '1970-01-01 00:00:00' COMMENT '记录时间'," + + " RestTime_one int(11) NOT NULL DEFAULT '0' COMMENT '剩余天数(组1)'," + + " WorkState_one int(11) NOT NULL DEFAULT '0' COMMENT '工作模式(组1)'," + + " VGroupVol_one double NOT NULL DEFAULT '0' COMMENT '组端电压(组1)'," + + " VpeakVol_one double NOT NULL DEFAULT '0' COMMENT '峰值电压(组1)'," + + " RestTime_two int(11) NOT NULL DEFAULT '0' COMMENT '剩余天数(组2)'," + + " WorkState_two int(11) NOT NULL DEFAULT '0' COMMENT '工作模式(组2)'," + + " VGroupVol_two double NOT NULL DEFAULT '0' COMMENT '组端电压(组2)'," + + " VpeakVol_two double NOT NULL DEFAULT '0' COMMENT '峰值电压(组2)'," + + " RestTime_three int(11) NOT NULL DEFAULT '0' COMMENT '剩余天数(组3)'," + + " WorkState_three int(11) NOT NULL DEFAULT '0' COMMENT '工作模式(组3)'," + + " VGroupVol_three double NOT NULL DEFAULT '0' COMMENT '组端电压(组3)'," + + " VpeakVol_three double NOT NULL DEFAULT '0' COMMENT '峰值电压(组3)'," + + " RestTime_four int(11) NOT NULL DEFAULT '0' COMMENT '剩余天数(组4)'," + + " WorkState_four int(11) NOT NULL DEFAULT '0' COMMENT '工作模式(组4)'," + + " VGroupVol_four double NOT NULL DEFAULT '0' COMMENT '组端电压(组4)'," + + " VpeakVol_four double NOT NULL DEFAULT '0' COMMENT '峰值电压(组4)'," + + " RestTime_five int(11) NOT NULL DEFAULT '0' COMMENT '剩余时间(组5)'," + + " WorkState_five int(11) NOT NULL DEFAULT '0' COMMENT '除硫5状态(组5)'," + + " VGroupVol_five int(11) NOT NULL DEFAULT '0' COMMENT '组端电压(组5)'," + + " VpeakVol_five int(11) NOT NULL DEFAULT '0' COMMENT '峰值电压(组5)'," + + " PRIMARY KEY (num)," + + " UNIQUE KEY unique_battgroupid (BattGroupId) USING BTREE" + + ") ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;"; + Sql_Mysql sql = new Sql_Mysql(pool.getConn()); + ResultSet res = null; + try { + if(recreate) { + sql.sqlMysqlExecute(sql_str1); + } + sql.sqlMysqlExecute(sql_str2); + + //添加剩余时间(组1) + res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns" + + " WHERE table_schema='db_ram_db'" + + " AND table_name='tb_fbs9100s_fod_state'" + + " AND column_name='RestTime_one'"); + if(false == res.next()) { + sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.FBS9100s_fod_state + + " ADD COLUMN RestTime_one int(11) NOT NULL DEFAULT '0' COMMENT '剩余时间(组5)'"); + } + //添加除硫状态(组1) + res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns" + + " WHERE table_schema='db_ram_db'" + + " AND table_name='tb_fbs9100s_fod_state'" + + " AND column_name='WorkState_one'"); + if(false == res.next()) { + sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.FBS9100s_fod_state + + " ADD COLUMN WorkState_one int(11) NOT NULL DEFAULT '0' COMMENT '除硫5状态(组5)'"); + } + //添加组端电压(组1) + res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns" + + " WHERE table_schema='db_ram_db'" + + " AND table_name='tb_fbs9100s_fod_state'" + + " AND column_name='VGroupVol_one'"); + if(false == res.next()) { + sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.FBS9100s_fod_state + + " ADD COLUMN VGroupVol_one int(11) NOT NULL DEFAULT '0' COMMENT '组端电压(组5)'"); + } + //添加峰值电压(组1) + res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns" + + " WHERE table_schema='db_ram_db'" + + " AND table_name='tb_fbs9100s_fod_state'" + + " AND column_name='VpeakVol_one'"); + if(false == res.next()) { + sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.FBS9100s_fod_state + + " ADD COLUMN VpeakVol_one int(11) NOT NULL DEFAULT '0' COMMENT '峰值电压(组5)'"); + } + + //添加剩余时间(组2) + res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns" + + " WHERE table_schema='db_ram_db'" + + " AND table_name='tb_fbs9100s_fod_state'" + + " AND column_name='RestTime_two'"); + if(false == res.next()) { + sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.FBS9100s_fod_state + + " ADD COLUMN RestTime_two int(11) NOT NULL DEFAULT '0' COMMENT '剩余时间(组5)'"); + } + //添加除硫状态(组2) + res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns" + + " WHERE table_schema='db_ram_db'" + + " AND table_name='tb_fbs9100s_fod_state'" + + " AND column_name='WorkState_two'"); + if(false == res.next()) { + sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.FBS9100s_fod_state + + " ADD COLUMN WorkState_two int(11) NOT NULL DEFAULT '0' COMMENT '除硫5状态(组5)'"); + } + //添加组端电压(组2) + res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns" + + " WHERE table_schema='db_ram_db'" + + " AND table_name='tb_fbs9100s_fod_state'" + + " AND column_name='VGroupVol_two'"); + if(false == res.next()) { + sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.FBS9100s_fod_state + + " ADD COLUMN VGroupVol_two int(11) NOT NULL DEFAULT '0' COMMENT '组端电压(组5)'"); + } + //添加峰值电压(组2) + res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns" + + " WHERE table_schema='db_ram_db'" + + " AND table_name='tb_fbs9100s_fod_state'" + + " AND column_name='VpeakVol_two'"); + if(false == res.next()) { + sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.FBS9100s_fod_state + + " ADD COLUMN VpeakVol_two int(11) NOT NULL DEFAULT '0' COMMENT '峰值电压(组5)'"); + } + + //添加剩余时间(组3) + res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns" + + " WHERE table_schema='db_ram_db'" + + " AND table_name='tb_fbs9100s_fod_state'" + + " AND column_name='RestTime_three'"); + if(false == res.next()) { + sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.FBS9100s_fod_state + + " ADD COLUMN RestTime_three int(11) NOT NULL DEFAULT '0' COMMENT '剩余时间(组5)'"); + } + //添加除硫状态(组3) + res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns" + + " WHERE table_schema='db_ram_db'" + + " AND table_name='tb_fbs9100s_fod_state'" + + " AND column_name='WorkState_three'"); + if(false == res.next()) { + sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.FBS9100s_fod_state + + " ADD COLUMN WorkState_three int(11) NOT NULL DEFAULT '0' COMMENT '除硫5状态(组5)'"); + } + //添加组端电压(组3) + res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns" + + " WHERE table_schema='db_ram_db'" + + " AND table_name='tb_fbs9100s_fod_state'" + + " AND column_name='VGroupVol_three'"); + if(false == res.next()) { + sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.FBS9100s_fod_state + + " ADD COLUMN VGroupVol_three int(11) NOT NULL DEFAULT '0' COMMENT '组端电压(组5)'"); + } + //添加峰值电压(组3) + res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns" + + " WHERE table_schema='db_ram_db'" + + " AND table_name='tb_fbs9100s_fod_state'" + + " AND column_name='VpeakVol_three'"); + if(false == res.next()) { + sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.FBS9100s_fod_state + + " ADD COLUMN VpeakVol_three int(11) NOT NULL DEFAULT '0' COMMENT '峰值电压(组5)'"); + } + + //添加剩余时间(组4) + res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns" + + " WHERE table_schema='db_ram_db'" + + " AND table_name='tb_fbs9100s_fod_state'" + + " AND column_name='RestTime_four'"); + if(false == res.next()) { + sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.FBS9100s_fod_state + + " ADD COLUMN RestTime_four int(11) NOT NULL DEFAULT '0' COMMENT '剩余时间(组5)'"); + } + //添加除硫状态(组4) + res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns" + + " WHERE table_schema='db_ram_db'" + + " AND table_name='tb_fbs9100s_fod_state'" + + " AND column_name='WorkState_four'"); + if(false == res.next()) { + sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.FBS9100s_fod_state + + " ADD COLUMN WorkState_four int(11) NOT NULL DEFAULT '0' COMMENT '除硫5状态(组5)'"); + } + //添加组端电压(组4) + res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns" + + " WHERE table_schema='db_ram_db'" + + " AND table_name='tb_fbs9100s_fod_state'" + + " AND column_name='VGroupVol_four'"); + if(false == res.next()) { + sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.FBS9100s_fod_state + + " ADD COLUMN VGroupVol_four int(11) NOT NULL DEFAULT '0' COMMENT '组端电压(组5)'"); + } + //添加峰值电压(组4) + res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns" + + " WHERE table_schema='db_ram_db'" + + " AND table_name='tb_fbs9100s_fod_state'" + + " AND column_name='VpeakVol_four'"); + if(false == res.next()) { + sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.FBS9100s_fod_state + + " ADD COLUMN VpeakVol_four int(11) NOT NULL DEFAULT '0' COMMENT '峰值电压(组5)'"); + } + + //添加剩余时间(组5) + res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns" + + " WHERE table_schema='db_ram_db'" + + " AND table_name='tb_fbs9100s_fod_state'" + + " AND column_name='RestTime_five'"); + if(false == res.next()) { + sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.FBS9100s_fod_state + + " ADD COLUMN RestTime_five int(11) NOT NULL DEFAULT '0' COMMENT '剩余时间(组5)'"); + } + //添加除硫状态(组5) + res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns" + + " WHERE table_schema='db_ram_db'" + + " AND table_name='tb_fbs9100s_fod_state'" + + " AND column_name='WorkState_five'"); + if(false == res.next()) { + sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.FBS9100s_fod_state + + " ADD COLUMN WorkState_five int(11) NOT NULL DEFAULT '0' COMMENT '除硫5状态(组5)'"); + } + //添加组端电压(组5) + res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns" + + " WHERE table_schema='db_ram_db'" + + " AND table_name='tb_fbs9100s_fod_state'" + + " AND column_name='VGroupVol_five'"); + if(false == res.next()) { + sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.FBS9100s_fod_state + + " ADD COLUMN VGroupVol_five int(11) NOT NULL DEFAULT '0' COMMENT '组端电压(组5)'"); + } + //添加峰值电压(组5) + res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns" + + " WHERE table_schema='db_ram_db'" + + " AND table_name='tb_fbs9100s_fod_state'" + + " AND column_name='VpeakVol_five'"); + if(false == res.next()) { + sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.FBS9100s_fod_state + + " ADD COLUMN VpeakVol_five int(11) NOT NULL DEFAULT '0' COMMENT '峰值电压(组5)'"); + } + //添加电池组id字段 + res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns" + + " WHERE table_schema='db_ram_db'" + + " AND table_name='tb_fbs9100s_fod_state'" + + " AND column_name='BattGroupId'"); + if(false == res.next()) { + sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.FBS9100s_fod_state + + " ADD COLUMN BattGroupId int(11) NOT NULL DEFAULT '0' COMMENT '电池组id' AFTER dev_id"); + } + //移除之前的以设备id分组的设备id唯一索引 + res = sql.sqlMysqlQuery("show INDEX FROM "+Sql_Mysql.FBS9100s_fod_state+" WHERE KEY_name = 'unique_dev_id'"); + if(res.next()) { + sql.sqlMysqlExecute("alter table "+Sql_Mysql.FBS9100s_fod_state+" drop index unique_dev_id;"); + } + //添加电池组id为唯一索引 + res = sql.sqlMysqlQuery("show INDEX FROM "+Sql_Mysql.FBS9100s_fod_state+" WHERE KEY_name = 'unique_BattGroupId'"); + if(!res.next()) { + //添加唯一索引前先删除表中记录 + sql.sqlMysqlExecute("DELETE FROM "+Sql_Mysql.FBS9100s_fod_state+" WHERE num>0"); + sql.sqlMysqlExecute("alter table "+Sql_Mysql.FBS9100s_fod_state+" add UNIQUE unique_BattGroupId(BattGroupId);"); + } + //移除之前的以设备id分组的设备id唯一索引 + /*res = sql.sqlMysqlQuery("show INDEX FROM "+Sql_Mysql.FBS9100s_fod_state+" WHERE KEY_name = 'unique_BattGroupId'"); + if(res.next()) { + sql.sqlMysqlExecute("alter table "+Sql_Mysql.FBS9100s_fod_state+" drop index unique_BattGroupId;"); + } + //添加修复设备id为唯一索引 + res = sql.sqlMysqlQuery("show INDEX FROM "+Sql_Mysql.FBS9100s_fod_state+" WHERE KEY_name = 'unique_dev_id'"); + if(!res.next()) { + //添加唯一索引前先删除表中记录 + sql.sqlMysqlExecute("DELETE FROM "+Sql_Mysql.FBS9100s_fod_state+" WHERE num>0"); + sql.sqlMysqlExecute("alter table "+Sql_Mysql.FBS9100s_fod_state+" add UNIQUE unique_dev_id(dev_id);"); + }*/ + } catch (SQLException e) { + e.printStackTrace(); + } finally { + if(null != res) { + try { + res.close(); + } catch (SQLException e) { + e.printStackTrace(); + } + } + sql.close_con(); + } + } + + /** + * 创建除硫状态表 + * @param pool + * @param recreate + */ + public static void createFBS9100SetDLParam_Table(MysqlConnPool pool, boolean recreate) { + String sql_str1 = " DROP TABLE IF EXISTS " + Sql_Mysql.FBS9100SetDLParam_Table; + String sql_str2 = "CREATE TABLE IF NOT EXISTS "+ Sql_Mysql.FBS9100SetDLParam_Table +" (" + + " num int(11) NOT NULL AUTO_INCREMENT," + + " dev_id int(11) NOT NULL DEFAULT '0' COMMENT '设备id'," + + " op_cmd int(11) NOT NULL DEFAULT '0'," + + " test_cmd int(11) NOT NULL DEFAULT '0'," + + " GroupNum int(11) NOT NULL DEFAULT '0' COMMENT '模块编号'," + + " BattGroupNum int(11) NOT NULL DEFAULT '0' COMMENT '电池组号'," + + " STDCap_one int(11) NOT NULL DEFAULT '0' COMMENT '组1标称容量'," + + " FloatVol_one double NOT NULL DEFAULT '0' COMMENT '组1浮充电压'," + + " Strength_one double NOT NULL DEFAULT '0' COMMENT '组1除硫强度'," + + " YHStrength_one double NOT NULL DEFAULT '0' COMMENT '组1养护强度'," + + " TimeLong_one int(11) NOT NULL DEFAULT '0' COMMENT '组1除硫天数'," + + " STDCap_two int(11) NOT NULL DEFAULT '0' COMMENT '组2标称容量'," + + " FloatVol_two double NOT NULL DEFAULT '0' COMMENT '组2浮充电压'," + + " Strength_two double NOT NULL DEFAULT '0' COMMENT '组2除硫强度'," + + " YHStrength_two double NOT NULL DEFAULT '0' COMMENT '组2养护强度'," + + " TimeLong_two int(11) NOT NULL DEFAULT '0' COMMENT '组2除硫天数'," + + " STDCap_three int(11) NOT NULL DEFAULT '0' COMMENT '组3标称容量'," + + " FloatVol_three double NOT NULL DEFAULT '0' COMMENT '组3浮充电压'," + + " Strength_three double NOT NULL DEFAULT '0' COMMENT '组3除硫强度'," + + " YHStrength_three double NOT NULL DEFAULT '0' COMMENT '组3养护强度'," + + " TimeLong_three int(11) NOT NULL DEFAULT '0' COMMENT '组3除硫天数'," + + " STDCap_four int(11) NOT NULL DEFAULT '0' COMMENT '组4标称容量'," + + " FloatVol_four double NOT NULL DEFAULT '0' COMMENT '组4浮充电压'," + + " Strength_four double NOT NULL DEFAULT '0' COMMENT '组4除硫强度'," + + " YHStrength_four double NOT NULL DEFAULT '0' COMMENT '组4养护强度'," + + " TimeLong_four int(11) NOT NULL DEFAULT '0' COMMENT '组4除硫天数'," + + " PRIMARY KEY (num)," + + " UNIQUE KEY unique_dev_id (dev_id)" + + ") ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;"; + Sql_Mysql sql = new Sql_Mysql(pool.getConn()); + ResultSet res = null; + try { + if(recreate) { + sql.sqlMysqlExecute(sql_str1); + } + sql.sqlMysqlExecute(sql_str2); + //添加电池组编号字段 + res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns" + + " WHERE table_schema='db_ram_db'" + + " AND table_name='tb_fbs9100s_fod_param'" + + " AND column_name='BattGroupNum'"); + if(false == res.next()) { + sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.FBS9100SetDLParam_Table + + " ADD COLUMN BattGroupNum int(11) NOT NULL DEFAULT '0' COMMENT '电池组组号'"); + } + //添加标称容量(组5) + res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns" + + " WHERE table_schema='db_ram_db'" + + " AND table_name='tb_fbs9100s_fod_param'" + + " AND column_name='STDCap_five'"); + if(false == res.next()) { + sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.FBS9100SetDLParam_Table + + " ADD COLUMN STDCap_five int(11) NOT NULL DEFAULT '0' COMMENT '组5标称容量'"); + } + //添加浮充电压(组5) + res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns" + + " WHERE table_schema='db_ram_db'" + + " AND table_name='tb_fbs9100s_fod_param'" + + " AND column_name='FloatVol_five'"); + if(false == res.next()) { + sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.FBS9100SetDLParam_Table + + " ADD COLUMN FloatVol_five double NOT NULL DEFAULT '0' COMMENT '组5浮充电压'"); + } + //添加除硫强度(组5) + res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns" + + " WHERE table_schema='db_ram_db'" + + " AND table_name='tb_fbs9100s_fod_param'" + + " AND column_name='Strength_five'"); + if(false == res.next()) { + sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.FBS9100SetDLParam_Table + + " ADD COLUMN Strength_five double NOT NULL DEFAULT '0' COMMENT '组5除硫强度'"); + } + //添加养护强度(组5) + res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns" + + " WHERE table_schema='db_ram_db'" + + " AND table_name='tb_fbs9100s_fod_param'" + + " AND column_name='YHStrength_five'"); + if(false == res.next()) { + sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.FBS9100SetDLParam_Table + + " ADD COLUMN YHStrength_five double NOT NULL DEFAULT '0' COMMENT '组5养护强度'"); + } + //添加剩余时间(组5) + res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns" + + " WHERE table_schema='db_ram_db'" + + " AND table_name='tb_fbs9100s_fod_param'" + + " AND column_name='TimeLong_five'"); + if(false == res.next()) { + sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.FBS9100SetDLParam_Table + + " ADD COLUMN TimeLong_five int(11) NOT NULL DEFAULT '0' COMMENT '组5除硫天数'"); + } + } catch (SQLException e) { + e.printStackTrace(); + } finally { + if(null != res) { + try { + res.close(); + } catch (SQLException e) { + e.printStackTrace(); + } + } + sql.close_con(); + } + } + + /** + * 创建逆变信息表 + */ + public static void createFBS9100_NiBian_State_Table(MysqlConnPool pool, boolean recreate) { + String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.FBS9100_NiBian_State; + String sql_str02 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.FBS9100_NiBian_State + " (" + + " num bigint(20) NOT NULL AUTO_INCREMENT," + + " dev_id bigint(11) NOT NULL DEFAULT '0'," + + " nb_num bigint(11) NOT NULL DEFAULT '0'," + + " record_time datetime NOT NULL DEFAULT '2000-01-01 00:00:00'," + + " AC_ASimVol float NOT NULL DEFAULT '0'," + + " AC_ASimCur float NOT NULL DEFAULT '0'," + + " AC_BSimVol float NOT NULL DEFAULT '0'," + + " AC_BSimCur float NOT NULL DEFAULT '0'," + + " AC_CSimVol float NOT NULL DEFAULT '0'," + + " AC_CSimCur float NOT NULL DEFAULT '0'," + + " A_HZ float NOT NULL DEFAULT '0'," + + " B_HZ float NOT NULL DEFAULT '0'," + + " C_HZ float NOT NULL DEFAULT '0'," + + " Power_Pa float NOT NULL DEFAULT '0'," + + " Power_Pb float NOT NULL DEFAULT '0'," + + " Power_Pc float NOT NULL DEFAULT '0'," + + " Power_Sa float NOT NULL DEFAULT '0'," + + " Power_Sb float NOT NULL DEFAULT '0'," + + " Power_Sc float NOT NULL DEFAULT '0'," + + " Temp1 float NOT NULL DEFAULT '0'," + + " Temp2 float NOT NULL DEFAULT '0'," + + " RunState float NOT NULL DEFAULT '0'," + + " DcACState int(11) NOT NULL DEFAULT '0'," + + " InsulaTionRes1 int(11) NOT NULL DEFAULT '0'," + + " InsulaTionRes2 int(11) NOT NULL DEFAULT '0'," + + " DCInputVol float NOT NULL DEFAULT '0'," + + " DCInputCur float NOT NULL DEFAULT '0'," + + " SetRun_Stop int(11) NOT NULL DEFAULT '0'," + + " SetDischargeCur float NOT NULL DEFAULT '0'," + + " CommTxCnt int(11) NOT NULL DEFAULT '0'," + + " CommRxCnt int(11) NOT NULL DEFAULT '0'," + + " PRIMARY KEY (num)," + + " UNIQUE KEY nb_num_index (nb_num) USING HASH" + + ") ENGINE=InnoDB AUTO_INCREMENT=1 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_socketclient_state 表 + * @param pool + * @param recreate + */ + public static void createSocketClientStateTable(MysqlConnPool pool, boolean recreate) { + String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.SocketClientStateTable; + String sql_str02 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.SocketClientStateTable + " (" + + " num bigint(20) NOT NULL AUTO_INCREMENT," + + " uId int(11) NOT NULL DEFAULT '0'," + + " client_type int(11) NOT NULL DEFAULT '0'," + + " client_id bigint(20) NOT NULL DEFAULT '0'," + + " BattGroupId int(11) NOT NULL DEFAULT '0'," + + " client_is_connected tinyint(1) NOT NULL DEFAULT '0'," + + " client_ip varchar(64) NOT NULL DEFAULT ' '," + + " client_conn_time datetime NOT NULL DEFAULT '1980-01-01 00:00:00'," + + " client_disconn_time datetime NOT NULL DEFAULT '1980-01-01 00:00:00'," + + " PRIMARY KEY (num)," + + " KEY index_user_id (uId)," + + " KEY index_client_type (client_type)" + + ") ENGINE=InnoDB AUTO_INCREMENT=1 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_server_state 表 + * @param pool + * @param recreate + */ + public static void createServerState_Table(MysqlConnPool pool, boolean recreate) { + String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.ServerState_Table; + String sql_str02 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.ServerState_Table + " (" + + " num bigint(20) NOT NULL AUTO_INCREMENT," + + " server_version float NOT NULL DEFAULT '0'," + + " server_datetime datetime NOT NULL DEFAULT '1982-01-01 00:00:00'," + + " max_mem bigint(20) NOT NULL DEFAULT '0'," + + " total_mem bigint(20) NOT NULL DEFAULT '0'," + + " free_men bigint(20) NOT NULL DEFAULT '0'," + + " total_disc_space bigint(20) NOT NULL DEFAULT '0'," + + " free_disc_space bigint(20) NOT NULL DEFAULT '0'," + + " db_conn_max int(11) NOT NULL DEFAULT '0'," + + " db_conn_count int(11) NOT NULL DEFAULT '0'," + + " app_conn_max int(11) NOT NULL DEFAULT '0'," + + " app_busy_conn_cnt int(11) NOT NULL DEFAULT '0'," + + " app_idle_conn_cnt int(11) NOT NULL DEFAULT '0'," + + " server_cpu_rate float NOT NULL DEFAULT '0'," + + " server_network_rate float NOT NULL DEFAULT '0'," + + " PRIMARY KEY (num)" + + ") 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); + + //添加字段app_conn_max + res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns" + + " WHERE table_schema='db_ram_db'" + + " AND table_name='tb_server_state'" + + " AND column_name='app_conn_max'"); + if(false == res.next()) { + sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.ServerState_Table + + " ADD COLUMN app_conn_max int(11) NOT NULL DEFAULT '0';"); + } + + //添加字段app_busy_conn_cnt + res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns" + + " WHERE table_schema='db_ram_db'" + + " AND table_name='tb_server_state'" + + " AND column_name='app_busy_conn_cnt'"); + if(false == res.next()) { + sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.ServerState_Table + + " ADD COLUMN app_busy_conn_cnt int(11) NOT NULL DEFAULT '0';"); + } + + //添加字段app_idle_conn_cnt + res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns" + + " WHERE table_schema='db_ram_db'" + + " AND table_name='tb_server_state'" + + " AND column_name='app_idle_conn_cnt'"); + if(false == res.next()) { + sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.ServerState_Table + + " ADD COLUMN app_idle_conn_cnt int(11) NOT NULL DEFAULT '0';"); + } + + //添加字段server_cpu_rate + res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns" + + " WHERE table_schema='db_ram_db'" + + " AND table_name='tb_server_state'" + + " AND column_name='server_cpu_rate'"); + if(false == res.next()) { + sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.ServerState_Table + + " ADD COLUMN server_cpu_rate float NOT NULL DEFAULT '0';"); + } + + //添加字段 server_network_rate + res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns" + + " WHERE table_schema='db_ram_db'" + + " AND table_name='tb_server_state'" + + " AND column_name='server_network_rate'"); + if(false == res.next()) { + sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.ServerState_Table + + " ADD COLUMN server_network_rate float NOT NULL DEFAULT '0';"); + } + + } catch (SQLException e) { + e.printStackTrace(); + } finally { + if(null != res) { + try { + res.close(); + } catch (SQLException e) { + e.printStackTrace(); + } + } + sql.close_con(); + } + } + + /** + * 创建 tb_ld9_updatestatue 表 + * @param pool + * @param recreate + */ + public static void createLd9_Updatestatue_Table(MysqlConnPool pool, boolean recreate) { + String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.Ld9_Updatestatue_Table; + String sql_str02 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.Ld9_Updatestatue_Table + " (" + + " num bigint(20) NOT NULL AUTO_INCREMENT," + + " dev_id bigint(20) NOT NULL DEFAULT '0'," + + " update_file varchar(200) NOT NULL DEFAULT ''," + + " update_en tinyint(1) NOT NULL DEFAULT '0'," + + " send_upfile_ok tinyint(1) NOT NULL DEFAULT '0'," + + " stopreason int(11) NOT NULL DEFAULT '0'," + + " countpackage int(11) NOT NULL DEFAULT '0'," + + " nowpackagenum int(11) NOT NULL DEFAULT '0'," + + " updatetime datetime NOT NULL DEFAULT '1982-01-01 00:00:00'," + + " starttime datetime NOT NULL DEFAULT '1982-01-01 00:00:00'," + + " note varchar(200) NOT NULL DEFAULT ''," + + " PRIMARY KEY (num)," + + " UNIQUE KEY index_dev_id_uniq (dev_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_ld9_state 表 + * @param pool + * @param recreate + */ + public static void createLd9_State_Table(MysqlConnPool pool, boolean recreate) { + String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.Ld9_State_Table; + String sql_str02 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.Ld9_State_Table + " (" + + " num bigint(20) NOT NULL AUTO_INCREMENT," + + " dev_id int(11) NOT NULL DEFAULT '401900001'," + + " dev_ip varchar(20) NOT NULL DEFAULT '127.0.0.1'," + + " record_datetime datetime NOT NULL DEFAULT '1982-01-01 00:00:00'," + + " dev_version varchar(64) NOT NULL DEFAULT 'v1.01.01'," + + " sys_state int(11) NOT NULL DEFAULT '0'," + + " sys_online_vol float NOT NULL DEFAULT '0.01'," + + " sys_group_vol float NOT NULL DEFAULT '0.01'," + + " sys_now_battnum int(11) NOT NULL DEFAULT '1'," + + " sys_now_battstate int(11) NOT NULL DEFAULT '1'," + + " sys_now_battvol float NOT NULL DEFAULT '0.01'," + + " sys_now_battcurr float NOT NULL DEFAULT '0.01'," + + " sys_now_battcap float NOT NULL DEFAULT '0.01'," + + " sys_now_testtime datetime NOT NULL DEFAULT '1982-01-01 00:00:00'," + + " sys_next_battnum int(11) NOT NULL DEFAULT '1'," + + " sys_next_battstate int(11) NOT NULL DEFAULT '1'," + + " sys_next_battvol float NOT NULL DEFAULT '0.01'," + + " sys_next_battcurr float NOT NULL DEFAULT '0.01'," + + " sys_next_battcap float NOT NULL DEFAULT '0.01'," + + " sys_next_testtime datetime NOT NULL DEFAULT '1982-01-01 00:00:00'," + + " sys_tmp float NOT NULL DEFAULT '0.1'," + + " sys_stop_reason int(11) NOT NULL DEFAULT '1'," + + " dev_commcount int(11) NOT NULL DEFAULT '0'," + + " dev_errcommcount int(11) NOT NULL DEFAULT '0'," + + " timelong int(11) NOT NULL DEFAULT '0'," + + " monvol_hightalarm int(11) NOT NULL DEFAULT '0'," + + " monvol_loweralarm int(11) NOT NULL DEFAULT '0'," + + " moncap_alarm int(11) NOT NULL DEFAULT '0'," + + " montmp_alarm int(11) NOT NULL DEFAULT '0'," + + " monres_alarm int(11) NOT NULL DEFAULT '0'," + + " PRIMARY KEY (num)," + + " UNIQUE KEY index_dev_id (dev_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_ld9_setparam 表 + * @param pool + * @param recreate + */ + public static void createLd9_Setparam_Table(MysqlConnPool pool, boolean recreate) { + String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.Ld9_Setparam_Table; + String sql_str02 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.Ld9_Setparam_Table + " (" + + " num bigint(20) NOT NULL AUTO_INCREMENT," + + " dev_id int(11) NOT NULL DEFAULT '401900001'," + + " op_cmd int(11) NOT NULL DEFAULT '0'," + + " param_teststart_batt_num int(11) NOT NULL DEFAULT '0'," + + " param_cap int(11) NOT NULL DEFAULT '1'," + + " param_discharge_curr float NOT NULL DEFAULT '0.001'," + + " param_mon_curr_high float NOT NULL DEFAULT '0.001'," + + " param_charge_curr float NOT NULL DEFAULT '0.001'," + + " param_mon_curr_low float NOT NULL DEFAULT '0.001'," + + " param_online_vol float NOT NULL DEFAULT '0.01'," + + " param_charge_curr_low float NOT NULL DEFAULT '0.001'," + + " param_charge_cap_low float NOT NULL DEFAULT '0.1'," + + " param_online_vol_recover int(11) NOT NULL DEFAULT '0'," + + " param_module_address int(11) NOT NULL DEFAULT '1'," + + " param_junheng_model int(11) NOT NULL DEFAULT '0'," + + " param_cap_low float NOT NULL DEFAULT '0'," + + " param_datasource int(11) NOT NULL DEFAULT '0'," + + " param_res_args int(11) NOT NULL DEFAULT '0'," + + " param_tmp_high float NOT NULL DEFAULT '0'," + + " param_res_high float NOT NULL DEFAULT '0'," + + " PRIMARY KEY (num)," + + " UNIQUE KEY index_dev_id (dev_id)" + + ") ENGINE=InnoDB AUTO_INCREMENT=1 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_ld9_setparam 表 + * @param pool + * @param recreate + */ + public static void createLd9_Concentratestate_Table(MysqlConnPool pool, boolean recreate) { + String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.Ld9_Concentratestate_Table; + String sql_str02 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.Ld9_Concentratestate_Table + " (" + + " num int(11) NOT NULL AUTO_INCREMENT COMMENT '主键'," + + " dev_id int(11) NOT NULL DEFAULT '0' COMMENT '设备id'," + + " record_time datetime NOT NULL DEFAULT '2000-01-01 00:00:00' COMMENT '记录时间'," + + " systemVersion varchar(255) NOT NULL DEFAULT '' COMMENT '系统版本'," + + " systemState int(11) NOT NULL DEFAULT '0' COMMENT '系统状态'," + + " groupVol float NOT NULL DEFAULT '0' COMMENT '组端电压'," + + " groupCurr float NOT NULL DEFAULT '0' COMMENT '组端电流'," + + " battState int(11) NOT NULL DEFAULT '0' COMMENT '电池状态'," + + " currDirection int(11) NOT NULL DEFAULT '0' COMMENT '电流方向'," + + " rippleCurrAvg float NOT NULL DEFAULT '0' COMMENT '纹波电流均值'," + + " rippleCurrTop float NOT NULL DEFAULT '0' COMMENT '纹波电流峰值'," + + " resTestCount int(11) NOT NULL DEFAULT '0' COMMENT '内阻测试次数'," + + " resTestMethod int(11) NOT NULL DEFAULT '0' COMMENT '内阻测试方法'," + + " PRIMARY KEY (num)," + + " UNIQUE KEY unique_dev_id (dev_id)" + + ") ENGINE=InnoDB AUTO_INCREMENT=1 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_ld9_concentrateparam 表 + * @param pool + * @param recreate + */ + public static void createLd9_Concentrateparam_Table(MysqlConnPool pool, boolean recreate) { + String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.Ld9_Concentrateparam_Table; + String sql_str02 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.Ld9_Concentrateparam_Table + " (" + + " num int(11) NOT NULL AUTO_INCREMENT," + + " dev_id int(11) NOT NULL DEFAULT '0' COMMENT '设备id'," + + " op_cmd int(11) NOT NULL DEFAULT '0' COMMENT '命令控制字段'," + + " addr int(11) NOT NULL DEFAULT '0' COMMENT '汇集器地址(0-2555)'," + + " firthMonCount int(11) NOT NULL DEFAULT '0' COMMENT '第一路单体个数'," + + " secondMonCount int(11) NOT NULL DEFAULT '0' COMMENT '第二路单体个数'," + + " thirdMonCount int(11) NOT NULL DEFAULT '0' COMMENT '第三路单体个数'," + + " fourthMonCount int(11) NOT NULL DEFAULT '0' COMMENT '第四路单体个数'," + + " fifthMonCount int(11) NOT NULL DEFAULT '0' COMMENT '第五路单体个数'," + + " currRange int(11) NOT NULL DEFAULT '0' COMMENT '电流钳量程'," + + " floatCurrLimit float NOT NULL DEFAULT '0' COMMENT '浮充电流门限'," + + " rippleCurrLimit float NOT NULL DEFAULT '0' COMMENT '纹波电流阀值'," + + " autoTestCycle int(11) NOT NULL DEFAULT '1' COMMENT '自动测试周期'," + + " resTestType int(11) NOT NULL DEFAULT '0' COMMENT '内阻测试方法'," + + " dischargeType int(11) NOT NULL DEFAULT '0' COMMENT '放电模式'," + + " battCapStd int(11) NOT NULL DEFAULT '0' COMMENT '标称容量'," + + " backup1 int(11) NOT NULL DEFAULT '0' COMMENT '备用1'," + + " backup2 int(11) NOT NULL DEFAULT '0' COMMENT '备用2'," + + " backup3 int(11) NOT NULL DEFAULT '0' COMMENT '备用3'," + + " backup4 int(11) NOT NULL DEFAULT '0' COMMENT '备用4'," + + " PRIMARY KEY (num)," + + " UNIQUE KEY unique_dev_id (dev_id)" + + ") ENGINE=InnoDB AUTO_INCREMENT=1 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_hard_dev_sms_state 表 + * @param pool + * @param recreate + */ + public static void createHardDevSmsState_Table(MysqlConnPool pool, boolean recreate) { + String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.HardDevSmsState_Table; + String sql_str02 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.HardDevSmsState_Table + " (" + + " num bigint(20) NOT NULL AUTO_INCREMENT," + + " sms_dev_ip varchar(20) NOT NULL DEFAULT '192.168.1.60'," + + " sms_ack_type int(11) NOT NULL DEFAULT '0'," + + " sms_sincard_ok tinyint(1) NOT NULL DEFAULT '0'," + + " sms_mobile_net_ok tinyint(1) NOT NULL DEFAULT '0'," + + " sms_sinal_value int(11) NOT NULL DEFAULT '0'," + + " sms_is_busy tinyint(1) NOT NULL DEFAULT '0'," + + " sms_money_rest float NOT NULL DEFAULT '0'," + + " sms_com_count int(11) NOT NULL DEFAULT '0'," + + " sms_com_err_count int(11) NOT NULL DEFAULT '0'," + + " note varchar(100) NOT NULL DEFAULT ' '," + + " PRIMARY KEY (num)" + + ") ENGINE=MEMORY 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_fbs9600_state 表 + * @param pool + * @param recreate + */ + public static void createFBS9600State_Table(MysqlConnPool pool, boolean recreate) { + String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.FBS9600State_Table; + String sql_str02 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.FBS9600State_Table + " (" + + " num bigint(20) NOT NULL AUTO_INCREMENT," + + " dev_ip varchar(20) NOT NULL DEFAULT '127.0.0.0'," + + " dev_id bigint(20) NOT NULL DEFAULT '0'," + + " op_cmd int(11) NOT NULL DEFAULT '0'," + + " dev_workstate int(11) NOT NULL DEFAULT '0'," + + " dev_alarmstate int(11) NOT NULL DEFAULT '0'," + + " dev_commcount int(11) NOT NULL DEFAULT '0'," + + " dev_errcommcount int(11) NOT NULL DEFAULT '0'," + + " PRIMARY KEY (num)," + + " UNIQUE KEY index_dev_id_uniq (dev_id)" + + ") ENGINE=InnoDB AUTO_INCREMENT=1 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_fbs9100s_dfu_state 表 + * @param pool + * @param recreate + */ + public static void createFBS9100S_DFUState_Table(MysqlConnPool pool, boolean recreate) { + String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.FBS9100S_DFUState_Table; + String sql_str02 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.FBS9100S_DFUState_Table + " (" + + " num bigint(20) NOT NULL AUTO_INCREMENT," + + " dev_id bigint(20) NOT NULL DEFAULT '0'," + + " sysVersion_new int(11) NOT NULL DEFAULT '0'," + + " softVersion_new int(11) NOT NULL DEFAULT '0'," + + " sysVersion_dev int(11) NOT NULL DEFAULT '0'," + + " softVersion_dev int(11) NOT NULL DEFAULT '0'," + + " dfu_file varchar(200) NOT NULL DEFAULT ' '," + + " dfu_en tinyint(1) NOT NULL DEFAULT '0'," + + " dfu_wr_stat int(11) NOT NULL DEFAULT '0'," + + " dfu_data_blocknum int(11) NOT NULL DEFAULT '0'," + + " dfu_data_blocklen int(11) NOT NULL DEFAULT '256'," + + " dfu_password varchar(100) NOT NULL DEFAULT ' '," + + " dfu_file_len int(11) NOT NULL," + + " PRIMARY KEY (num)," + + " UNIQUE KEY index_dev_id_uniq (dev_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_fbs9100s_dcdc_state 表 + * @param pool + * @param recreate + */ + public static void createFBS9100S_DcDcState_Table(MysqlConnPool pool, boolean recreate) { + String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.FBS9100S_DcDcState_Table; + String sql_str02 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.FBS9100S_DcDcState_Table + " (" + + " num bigint(20) NOT NULL AUTO_INCREMENT," + + " dev_id bigint(20) NOT NULL DEFAULT '0'," + + " dcdc_num bigint(20) NOT NULL DEFAULT '0'," + + " dcdc_Vsys float NOT NULL DEFAULT '0'," + + " dcdc_Vout float NOT NULL DEFAULT '0'," + + " dcdc_Vbat float NOT NULL DEFAULT '0'," + + " dcdc_Iout float NOT NULL DEFAULT '0'," + + " dcdc_Ibuck float NOT NULL DEFAULT '0'," + + " dcdc_Tmp_Dis float NOT NULL DEFAULT '0'," + + " dcdc_Tmp_Chr float NOT NULL DEFAULT '0'," + + " dcdc_SMR_Alarm1 int(11) NOT NULL DEFAULT '0'," + + " dcdc_SMR_Alarm2 int(11) NOT NULL DEFAULT '0'," + + " dcdc_version int(11) NOT NULL DEFAULT '0'," + + " dcdc_ModeSetComm int(11) NOT NULL DEFAULT '0'," + + " dcdc_RunSetComm int(11) NOT NULL DEFAULT '0'," + + " dcdc_BuckISet float NOT NULL DEFAULT '0'," + + " dcdc_DisVolSet float NOT NULL DEFAULT '0'," + + " dcdc_DisCurrSet float NOT NULL DEFAULT '0'," + + " dcdc_CommTxCnt int(11) NOT NULL DEFAULT '0'," + + " dcdc_CommRxCnt int(11) NOT NULL DEFAULT '0'," + + " PRIMARY KEY (num)," + + " UNIQUE KEY index_dcdc_num_uniq (dcdc_num)" + + ") ENGINE=MEMORY 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_sysparam 表 + * @param pool + * @param recreate + */ + public static void createFBS9100SysParam_Table(MysqlConnPool pool, boolean recreate) { + String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.FBS9100SysParam_Table; + String sql_str02 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.FBS9100SysParam_Table + " (" + + " num bigint(20) NOT NULL AUTO_INCREMENT," + + " dev_ip varchar(20) NOT NULL DEFAULT '127.0.0.0'," + + " dev_id bigint(20) NOT NULL DEFAULT '0'," + + " op_cmd int(11) NOT NULL DEFAULT '0'," + + " IPADDR varchar(20) NOT NULL DEFAULT '127.0.0.0'," + + " SubIPADDR varchar(20) NOT NULL DEFAULT '127.0.0.0'," + + " NetGateADDR varchar(20) NOT NULL DEFAULT '127.0.0.0'," + + " GroupVolRange int(11) NOT NULL DEFAULT '0'," + + " GroupVolSorce int(11) NOT NULL DEFAULT '0'," + + " CurrentRange int(11) NOT NULL DEFAULT '0'," + + " CurrentTyte int(11) NOT NULL DEFAULT '0'," + + " MonomerOrder int(11) NOT NULL DEFAULT '0'," + + " BackLightTime int(11) NOT NULL DEFAULT '0'," + + " MACADDR varchar(30) NOT NULL DEFAULT '0.0.0.0.0.0'," + + " LoaderCount int(11) NOT NULL DEFAULT '0'," + + " DtCardCount int(11) NOT NULL DEFAULT '0'," + + " PowerBreakChargeCurr float NOT NULL DEFAULT '0'," + + " MajorBattGroupNum int(11) NOT NULL DEFAULT '0'," + + " POF_BG_Boost_Cnt int(11) NOT NULL DEFAULT '0'," + + " POF_BG_Boost_VolStop float NOT NULL DEFAULT '0'," + + " POF_BG_Boost_VolStart float NOT NULL DEFAULT '0'," + + + " `JunHeng_Enabled` float NOT NULL DEFAULT '0' COMMENT '均衡功能启用状态(1:启用;0:禁用)'," + + " `JunHeng_StVol` float NOT NULL DEFAULT '0' COMMENT '均衡停止电压阀值'," + + " `JunHeng_StCurr` float NOT NULL DEFAULT '0' COMMENT '均衡停止电流阀值'," + + " PRIMARY KEY (num)," + + " UNIQUE KEY index_dev_id_uniq (dev_id)" + + ") ENGINE=InnoDB 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); + + //添加字段JunHeng_Enabled 均衡功能启用状态 + res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns" + + " WHERE table_schema='db_ram_db'" + + " AND table_name='tb_fbs9100_sysparam'" + + " AND column_name='JunHeng_Enabled'"); + if(false == res.next()) { + sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.FBS9100SysParam_Table + + " ADD COLUMN `JunHeng_Enabled` float NOT NULL DEFAULT '0' COMMENT '均衡功能启用状态(1:启用;0:禁用)';"); + }else{ + sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.FBS9100SysParam_Table + + " CHANGE `JunHeng_Enabled` `JunHeng_Enabled` float NOT NULL DEFAULT '0' COMMENT '均衡功能启用状态(1:启用;0:禁用)';"); + } + + //添加字段JunHeng_StVol 均衡停止电压阀值 + res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns" + + " WHERE table_schema='db_ram_db'" + + " AND table_name='tb_fbs9100_sysparam'" + + " AND column_name='JunHeng_StVol'"); + if(false == res.next()) { + sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.FBS9100SysParam_Table + + " ADD COLUMN `JunHeng_StVol` float NOT NULL DEFAULT '0' COMMENT '均衡停止电压阀值';"); + } + + //添加字段JunHeng_StCurr 均衡停止电流阀值 + res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns" + + " WHERE table_schema='db_ram_db'" + + " AND table_name='tb_fbs9100_sysparam'" + + " AND column_name='JunHeng_StCurr'"); + if(false == res.next()) { + sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.FBS9100SysParam_Table + + " ADD COLUMN `JunHeng_StCurr` float NOT NULL DEFAULT '0' COMMENT '均衡停止电流阀值';"); + } + } catch (SQLException e) { + e.printStackTrace(); + } finally { + if(null != res) { + try { + res.close(); + } catch (SQLException e) { + e.printStackTrace(); + } + } + sql.close_con(); + } + } + + /** + * 创建 tb_fbs9100_state 表 + * @param pool + * @param recreate + */ + public static void createFBS9100State_Table(MysqlConnPool pool, boolean recreate) { + String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.FBS9100State_Table; + String sql_str02 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.FBS9100State_Table + " (" + + " num bigint(20) NOT NULL AUTO_INCREMENT," + + " dev_ip varchar(20) NOT NULL DEFAULT '127.0.0.0'," + + " dev_version varchar(64) NOT NULL DEFAULT ''," + + " dev_id bigint(20) NOT NULL DEFAULT '0'," + + " op_cmd int(11) NOT NULL DEFAULT '0'," + + " record_datetime varchar(20) NOT NULL DEFAULT '2015-12-02 12:10:00'," + + " dev_datetime varchar(20) NOT NULL DEFAULT '2015-12-02 12:10:00'," + + " dev_testtype int(11) NOT NULL DEFAULT '0'," + + " dev_testgroupnum int(11) NOT NULL DEFAULT '0'," + + " dev_workstate int(11) NOT NULL DEFAULT '0'," + + " dev_alarmstate int(11) NOT NULL DEFAULT '0'," + + " dev_onlinevollow tinyint(1) NOT NULL DEFAULT '0'," + + " dev_eachgroup_battsum int(11) NOT NULL DEFAULT '0'," + + " dev_captest_onlinevol float NOT NULL DEFAULT '0'," + + " dev_captest_groupvol float NOT NULL DEFAULT '0'," + + " dev_captest_curr float NOT NULL DEFAULT '0'," + + " dev_captest_cap float NOT NULL DEFAULT '0'," + + " dev_captest_timelong int(11) NOT NULL DEFAULT '0'," + + " dev_restest_moncount int(11) NOT NULL DEFAULT '0'," + + " dev_restest_monindex int(11) NOT NULL DEFAULT '0'," + + " dev_commcount int(11) NOT NULL DEFAULT '0'," + + " dev_errcommcount int(11) NOT NULL DEFAULT '0'," + + " dev_rxnullerrcount int(11) NOT NULL DEFAULT '0'," + + " dev_temp float NOT NULL DEFAULT '0'," + + " dev_res_test_state int(11) NOT NULL DEFAULT '0'," + + " dev_restest_count int(11) NOT NULL DEFAULT '0'," + + " dev_last_captest_stop_type int(11) NOT NULL DEFAULT '0'," + + " dev_condvoldp float NOT NULL DEFAULT '0'," + + " dev_conresist float NOT NULL DEFAULT '0'," + + " dev_conresist1 float NOT NULL DEFAULT '0'," + + " dev_condcurr float NOT NULL DEFAULT '0'," + + " dev_61850alarms varchar(64) NOT NULL DEFAULT ''," + + " dev_batt_xuhang_tlong int(11) NOT NULL DEFAULT '0'," + + " dev_station_poff_tlong int(11) NOT NULL DEFAULT '0'," + + " dev_station_poff_cnt int(11) NOT NULL DEFAULT '0'," + + " dev_data_flowsum bigint(20) NOT NULL DEFAULT '0'," + + " batt_online_state int(11) NOT NULL DEFAULT '0'," + + " dev_concurr float NOT NULL DEFAULT '0'," + + " PRIMARY KEY (num)," + + " UNIQUE KEY index_dev_id_uniq (dev_id)" + + ") ENGINE=InnoDB AUTO_INCREMENT=1 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_setparam 表 + * @param pool + * @param recreate + */ + public static void createFBS9100SetParam_Table(MysqlConnPool pool, boolean recreate) { + String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.FBS9100SetParam_Table; + String sql_str02 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.FBS9100SetParam_Table + " (" + + " num bigint(20) NOT NULL AUTO_INCREMENT," + + " dev_ip varchar(20) NOT NULL DEFAULT '127.0.0.0'," + + " dev_id bigint(20) NOT NULL DEFAULT '0'," + + " op_cmd int(11) NOT NULL DEFAULT '0'," + + " TestCmd int(11) NOT NULL DEFAULT '0'," + + " HourRate int(11) NOT NULL DEFAULT '0'," + + " DisCurr float NOT NULL DEFAULT '0'," + + " DisCap float NOT NULL DEFAULT '0'," + + " DisTime int(11) NOT NULL DEFAULT '0'," + + " GroupVol_LOW float NOT NULL DEFAULT '0'," + + " MonomerVol_LOW float NOT NULL DEFAULT '0'," + + " MonomerLowCount int(11) NOT NULL DEFAULT '0'," + + " BattGroupNum int(11) NOT NULL DEFAULT '0'," + + " OnlineVolLowAction int(11) NOT NULL DEFAULT '0'," + + " DCVolHighLimit float NOT NULL DEFAULT '0'," + + " ChargeCurrSet float NOT NULL DEFAULT '0'," + + " MonomerTmp_High float NOT NULL DEFAULT '0'," + + " AutoTestStartVol float NOT NULL DEFAULT '0'," + + " OnLineVol_Low float NOT NULL DEFAULT '0'," + + " OffLineYH_Cycle int(11) NOT NULL DEFAULT '0'," + + " OffLineYHstarttime datetime NOT NULL DEFAULT '2000-01-01 00:00:00'," + + " OffLineYHTimes int(11) NOT NULL DEFAULT '1'," + + " OffLineYHOnceCycle int(11) NOT NULL DEFAULT '1'," + + " PRIMARY KEY (num)," + + " UNIQUE KEY index_dev_id_uniq (dev_id)" + + ") ENGINE=MEMORY 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_offlineyhplan 表 + * @param pool + * @param recreate + */ + public static void createFBS9100_offlineyhplan_Table(MysqlConnPool pool, boolean recreate) { + String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.FBS9100_offlineyhplan; + String sql_str02 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.FBS9100_offlineyhplan + " (" + + " num bigint(20) NOT NULL AUTO_INCREMENT," + + " dev_id int(11) NOT NULL DEFAULT '1'," + + " OffLineYH_Cycle int(11) NOT NULL DEFAULT '1'," + + " OffLineYHstarttime datetime NOT NULL DEFAULT '2000-01-01 00:00:00'," + + " OffLineYHTimes int(11) NOT NULL DEFAULT '0'," + + " OffLineYHOnceCycle int(11) NOT NULL DEFAULT '0'," + + " note varchar(255) NOT NULL DEFAULT ''," + + " PRIMARY KEY (num)" + + ") 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_fbs9100_battparam 表 + * @param pool + * @param recreate + */ + public static void createFBS9100BattParam_Table(MysqlConnPool pool, boolean recreate) { + String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.FBS9100BattParam_Table; + String sql_str02 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.FBS9100BattParam_Table + " (" + + " num bigint(20) NOT NULL AUTO_INCREMENT," + + " dev_ip varchar(20) NOT NULL DEFAULT '127.0.0.0'," + + " dev_id bigint(20) NOT NULL DEFAULT '0'," + + " op_cmd int(11) NOT NULL DEFAULT '0'," + + " STD_CAP int(11) NOT NULL DEFAULT '0'," + + " STD_RES int(11) NOT NULL DEFAULT '0'," + + " BattGroupCount int(11) NOT NULL DEFAULT '0'," + + " EachGroupBattCount int(11) NOT NULL DEFAULT '0'," + + " MonomerVol float NOT NULL DEFAULT '0'," + + " GroupVol float NOT NULL DEFAULT '0'," + + " BattTemp float NOT NULL DEFAULT '0'," + + " FloatChargeVol float NOT NULL DEFAULT '0'," + + " FloatChargeCurr float NOT NULL DEFAULT '0'," + + " OnlineVolLow float NOT NULL DEFAULT '0'," + + " GroupConnType int(11) NOT NULL DEFAULT '0'," + + " PRIMARY KEY (num)," + + " UNIQUE KEY index_dev_id_uniq (dev_id)" + + ") ENGINE=MEMORY 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_bts_station_state 表 + * @param pool + * @param recreate + */ + public static void createBTSStationState_Table(MysqlConnPool pool, boolean recreate) { + String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.BTSStationState_Table; + String sql_str02 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.BTSStationState_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_stat int(11) NOT NULL DEFAULT '0'," + + " station_poff_start_time varchar(20) NOT NULL DEFAULT '2015-12-02 12:10:00'," + + " station_fadian_start_time varchar(20) NOT NULL DEFAULT '2015-12-02 12:10:00'," + + " station_diaozhan_start_time varchar(20) NOT NULL DEFAULT '2015-12-02 12:10:00'," + + " station_temp float NOT NULL DEFAULT '0'," + + " station_damp float NOT NULL DEFAULT '0'," + + " station_dooropen_start_time varchar(20) NOT NULL DEFAULT '2015-12-02 12:10:00'," + + " station_xuhang_start_time varchar(20) NOT NULL DEFAULT '2015-12-02 12:10:00'," + + " station_xuhang_end_time varchar(20) NOT NULL DEFAULT '2015-12-02 12:10:00'," + + " PRIMARY KEY (num)," + + " UNIQUE KEY index_station_id_uniq (station_id)" + + ") 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_bts_gprs_state 表 + * @param pool + * @param recreate + */ + public static void createBTSGPRSState_Table(MysqlConnPool pool, boolean recreate) { + String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.BTSGPRSState_Table; + String sql_str02 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.BTSGPRSState_Table + " (" + + " `num` bigint(20) NOT NULL AUTO_INCREMENT," + + " `dev_id` bigint(20) NOT NULL DEFAULT '0'," + + " `op_cmd` int(11) NOT NULL DEFAULT '0'," + + " `AT_cmd` varchar(20) NOT NULL DEFAULT ''," + + " `ack_inf` varchar(50) NOT NULL DEFAULT ''," + + " `bts_task_inf` varchar(1024) NOT NULL DEFAULT ''," + + " PRIMARY KEY (`num`)," + + " UNIQUE KEY `index_dev_id_uniq` (`dev_id`)" + + ") ENGINE=InnoDB AUTO_INCREMENT=5 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_bpm7100_state 表 + * @param pool + * @param recreate + */ + public static void createBMP7100State_Table(MysqlConnPool pool, boolean recreate) { + String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.BMP7100State_Table; + String sql_str02 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.BMP7100State_Table + " (" + + " num bigint(20) NOT NULL AUTO_INCREMENT," + + " dev_ip varchar(20) NOT NULL DEFAULT '127.0.0.0'," + + " dev_id int(11) NOT NULL DEFAULT '0'," + + " op_cmd int(11) NOT NULL DEFAULT '0'," + + " dev_workstate int(11) NOT NULL DEFAULT '0'," + + " dev_worktime bigint(20) NOT NULL DEFAULT '0'," + + " dev_commcount int(11) NOT NULL DEFAULT '0'," + + " dev_errcommcount int(11) NOT NULL DEFAULT '0'," + + " PRIMARY KEY (num)" + + ") ENGINE=MEMORY 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_batt_rtstate 表 + * @param pool + * @param recreate + */ + public static void createBattRtState_Table(MysqlConnPool pool, boolean recreate) { + String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.BattRtState_Table; + String sql_str02 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.BattRtState_Table + " (" + + " num bigint(20) NOT NULL AUTO_INCREMENT," + + " BattGroupId int(11) NOT NULL DEFAULT '0'," + + " batt_count int(11) NOT NULL DEFAULT '0'," + + " rec_datetime datetime NOT NULL DEFAULT '1982-01-01 00:00:00'," + + " online_vol float NOT NULL DEFAULT '0'," + + " group_vol float NOT NULL DEFAULT '0'," + + " group_tmp float NOT NULL DEFAULT '0'," + + " group_curr float NOT NULL DEFAULT '0'," + + " batt_state int(11) NOT NULL DEFAULT '0'," + + " batt_test_type int(11) NOT NULL DEFAULT '0'," + + " batt_test_starttime datetime NOT NULL DEFAULT '1982-01-01 00:00:00'," + + " batt_test_recordtime datetime NOT NULL DEFAULT '1982-01-01 00:00:00'," + + " batt_test_tlong int(11) NOT NULL DEFAULT '0'," + + " batt_test_cap float NOT NULL DEFAULT '0'," + + " batt_real_cap float NOT NULL DEFAULT '0'," + + " batt_rest_cap float NOT NULL DEFAULT '0'," + + " batt_rest_power1_time int(11) NOT NULL DEFAULT '0'," + + " batt_rest_power2_time int(11) NOT NULL DEFAULT '0'," + + " test_loadertype int(11) NOT NULL DEFAULT '0'," + + " test_recordnum int(11) NOT NULL DEFAULT '0'," + + " PRIMARY KEY (num)," + + " KEY index_BattGroupId (BattGroupId)" + + ") ENGINE=InnoDB AUTO_INCREMENT=8 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_batt_rtdata 表 + * @param pool + * @param recreate + */ + public static void createBattRtData_Table(MysqlConnPool pool, boolean recreate) { + String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.BattRtData_Table; + String sql_str02 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.BattRtData_Table + " (" + + " num bigint(20) NOT NULL AUTO_INCREMENT," + + " BattGroupId int(11) NOT NULL DEFAULT '0'," + + " rec_datetime datetime NOT NULL DEFAULT '1982-01-01 00:00:00'," + + " mon_num int(11) NOT NULL DEFAULT '0'," + + " mon_vol float NOT NULL DEFAULT '0'," + + " mon_tmp float NOT NULL DEFAULT '0'," + + " mon_res float NOT NULL DEFAULT '0'," + + " mon_ser float NOT NULL DEFAULT '0'," + + " mon_conn_res float NOT NULL DEFAULT '0'," + + " mon_cap float NOT NULL DEFAULT '0'," + + " mon_JH_curr float NOT NULL DEFAULT '0'," + + " mon_LY_vol float NOT NULL DEFAULT '0'," + + " PRIMARY KEY (num)," + + " KEY index_BattGroupId (BattGroupId)" + + ") ENGINE=InnoDB AUTO_INCREMENT=347 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); + //添加字段mon_JH_curr + res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns" + + " WHERE table_schema='db_ram_db'" + + " AND table_name='tb_batt_rtdata'" + + " AND column_name='mon_JH_curr'"); + if(false == res.next()) { + sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.BattRtData_Table + + " ADD COLUMN mon_JH_curr float NOT NULL DEFAULT '0';"); + } + //添加字段mon_LY_vol + res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns" + + " WHERE table_schema='db_ram_db'" + + " AND table_name='tb_batt_rtdata'" + + " AND column_name='mon_LY_vol'"); + if(false == res.next()) { + sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.BattRtData_Table + + " ADD COLUMN mon_LY_vol float NOT NULL DEFAULT '0';"); + } + } catch (SQLException e) { + e.printStackTrace(); + } finally { + sql.close_con(); + } + } + /** + * 创建 tb_61850_jhstate 表 + * @param pool + * @param recreate + */ + public static void create61850_JHState_Table(MysqlConnPool pool, boolean recreate) { + String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.TB_61850_JHState_Table; + String sql_str02 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.TB_61850_JHState_Table + " (" + + " num bigint(20) NOT NULL AUTO_INCREMENT," + + " dev_id int(11) NOT NULL DEFAULT '0'," + + " dev_version varchar(255) NOT NULL DEFAULT ''," + + " input_vol_total double NOT NULL DEFAULT '0'," + + " output_vol_total double NOT NULL DEFAULT '0'," + + " input_curr_total double NOT NULL DEFAULT '0'," + + " output_curr_total double NOT NULL DEFAULT '0'," + + " output_vol_one double NOT NULL DEFAULT '0'," + + " output_vol_two double NOT NULL DEFAULT '0'," + + " output_vol_three double NOT NULL DEFAULT '0'," + + " output_vol_four double NOT NULL DEFAULT '0'," + + " output_vol_five double NOT NULL DEFAULT '0'," + + " output_vol_six double NOT NULL DEFAULT '0'," + + " output_vol_seven double NOT NULL DEFAULT '0'," + + " output_vol_eight double NOT NULL DEFAULT '0'," + + " output_vol_nine double NOT NULL DEFAULT '0'," + + " output_vol_ten double NOT NULL DEFAULT '0'," + + " dev_temp double NOT NULL DEFAULT '0'," + + " PRIMARY KEY (num)," + + " UNIQUE KEY index_dev_id_unique (dev_id) USING BTREE" + + ") ENGINE=InnoDB AUTO_INCREMENT=9046 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(); + } + } + /** + * 创建 cmcc_power_data 表 + * @param pool + * @param recreate + */ + public static void createRamDB_CMCC_POWER_Data_Table(MysqlConnPool pool, boolean recreate) { + String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.RamDB_CMCC_POWER_Data; + String sql_str02 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.RamDB_CMCC_POWER_Data + " (" + + " num bigint(20) NOT NULL AUTO_INCREMENT," + + " dev_id bigint(20) NOT NULL DEFAULT '0'," + + " vol1 float NOT NULL DEFAULT '0'," + + " vol2 float NOT NULL DEFAULT '0'," + + " vol3 float NOT NULL DEFAULT '0'," + + " vol4 float NOT NULL DEFAULT '0'," + + " vol5 float NOT NULL DEFAULT '0'," + + " curr1 float NOT NULL DEFAULT '0'," + + " curr2 float NOT NULL DEFAULT '0'," + + " curr3 float NOT NULL DEFAULT '0'," + + " curr4 float NOT NULL DEFAULT '0'," + + " curr5 float NOT NULL DEFAULT '0'," + + " PRIMARY KEY (num)," + + " UNIQUE KEY index_dev_id_uniq (dev_id)" + + ") ENGINE=InnoDB AUTO_INCREMENT=1 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_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 '记录时间'," + + " `dev_version` varchar(64) NOT NULL DEFAULT '' 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'"); + } + //添加字段dev_version + res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns" + + " WHERE table_schema='db_ram_db'" + + " AND table_name='tb_fbs9100_insulatstate'" + + " AND column_name='dev_version'"); + if(false == res.next()) { + sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.FBS9100_InsulatstateTable + + " ADD COLUMN `dev_version` varchar(64) NOT NULL DEFAULT '' COMMENT '协转版本号';"); + } + } 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_lithium_data 表 + * @param pool + * @param recreate + */ + public static void createTb_Lithium_DataTable(MysqlConnPool pool, boolean recreate) { + String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.Tb_Lithium_DataTable; + String sql_str02 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.Tb_Lithium_DataTable + " (" + + " `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 '记录时间'," + + " `envir_tmp` float NOT NULL DEFAULT '0' COMMENT '环境温度'," + + " `power_tmp` float NOT NULL DEFAULT '0' COMMENT '功率温度'," + + " `rest_cap` float NOT NULL DEFAULT '0' COMMENT '剩余容量'," + + " `remote_control_count` int(11) NOT NULL DEFAULT '0' COMMENT '自定义遥控数量'," + + " `batt_total_cap` float NOT NULL DEFAULT '0' COMMENT '电池总容量'," + + " `batt_cycles` int(11) NOT NULL DEFAULT '0' COMMENT '电池循环次数'," + + " `evir_tmp_alm_state` int(11) NOT NULL DEFAULT '0' COMMENT '环境温度告警状态'," + + " `power_tmp_alm_state` int(11) NOT NULL DEFAULT '0' COMMENT '功率温度告警状态'," + + " `discharge_curr_alm_state` int(11) NOT NULL DEFAULT '0' COMMENT '充放电电流告警状态'," + + " `batt_totalvol_alm_state` int(11) NOT NULL DEFAULT '0' COMMENT '电池总电压告警状态'," + + " `custom_alm_count` int(11) NOT NULL DEFAULT '0' COMMENT '自定义告警量数量'," + + " `junheng_event_code` int(11) NOT NULL DEFAULT '0' COMMENT '均衡事件代码'," + + " `vol_event_code` int(11) NOT NULL DEFAULT '0' COMMENT '电压事件代码'," + + " `tmp_event_code` int(11) NOT NULL DEFAULT '0' COMMENT '温度事件代码'," + + " `curr_event_code` int(11) NOT NULL DEFAULT '0' COMMENT '电流事件代码'," + + " `fet_state_code` int(11) NOT NULL DEFAULT '0' COMMENT 'FET状态代码'," + + " `junheng_state_code` int(11) NOT NULL DEFAULT '0' COMMENT '均衡状态代码'," + + " `sys_state_code` int(11) NOT NULL DEFAULT '0' COMMENT '系统状态代码'," + + " `note` varchar(255) NOT NULL DEFAULT '' COMMENT '备用'," + + " PRIMARY KEY (`num`)" + + ") 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(); + } + } + + /** + * 创建组端信息告警记录表 + * @param pool + * @param recreate + */ + 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," + + " `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 '组电压告警'," + + " `test_end_vol` float NOT NULL DEFAULT '0' COMMENT '测试终止电压'," + + " `test_end_cap` float NOT NULL DEFAULT '0' COMMENT '测试终止剩余容量'," + + " `test_timelong` int(11) NOT NULL DEFAULT '0' COMMENT '测试终止时间(秒)'," + + " PRIMARY KEY (`num`)," + + " KEY `index_BattGroupId` (`BattGroupId`) USING BTREE," + + " KEY `index_record_time` (`record_time`) USING BTREE" + + ") ENGINE=InnoDB DEFAULT CHARSET=utf8;"; + Sql_Mysql sql = new Sql_Mysql(pool.getConn()); + + try { + if(true == recreate) { + sql.sqlMysqlExecute(sql_str01); + } + //System.out.println(sql_str02); + sql.sqlMysqlExecute(sql_str02); + //添加未录入电池组的组端信息 + String sql_str03 = "INSERT INTO " + Sql_Mysql.Tb_Batt_RSAlarm_Table + " (BattGroupId)" + + " SELECT BattGroupId FROM " + Sql_Mysql.BattInf_Table + + " WHERE BattGroupId NOT IN (SELECT BattGroupId FROM " + Sql_Mysql.Tb_Batt_RSAlarm_Table + ")"; + //System.out.println(sql_str03); + sql.sqlMysqlExecute(sql_str03); + } catch (SQLException e) { + e.printStackTrace(); + } finally { + sql.close_con(); + } + } + + /** + * 创建单体信息告警记录表 + * @param pool + * @param recreate + */ + public static void createTb_Batt_RTAlarm_Table(MysqlConnPool pool, boolean recreate) { + String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.Tb_Batt_RTAlarm_Table; + String sql_str02 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.Tb_Batt_RTAlarm_Table + " (" + + " `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 '记录时间'," + + " `mon_num` int(11) NOT NULL DEFAULT '0' COMMENT '单体编号'," + + " `monvol_alm` tinyint(4) NOT NULL DEFAULT '0' COMMENT '单体电压告警'," + + " `montmp_alm` tinyint(4) NOT NULL DEFAULT '0' COMMENT '单体温度告警'," + + " `monres_alm` tinyint(4) NOT NULL DEFAULT '0' COMMENT '单体内阻告警'," + + " `monrestcap_alm` tinyint(4) NOT NULL DEFAULT '0' COMMENT '单体剩余容量告警'," + + " PRIMARY KEY (`num`)," + + " KEY `index_BattGroupId` (`BattGroupId`) USING BTREE," + + " KEY `index_record_time` (`record_time`) USING BTREE" + + ") 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); + + ResultSet res_t = sql.sqlMysqlQuery("SELECT BattGroupId,MonCount FROM " + Sql_Mysql.BattInf_Table); + while(res_t.next()) { + int bg_id = res_t.getInt("BattGroupId"); + int mon_cnt = res_t.getInt("MonCount"); + + if(mon_cnt > 0){ + + int max_monnum = BattData_RT_RamDB_Thread_SQL.seachBattRTAlarmMaxMonNum(pool,bg_id); //当前电池组在 tb_batt_rtdata 表中的最大单体个数 + if(mon_cnt > max_monnum){ + //需要从max_monnum开始添加单体记录 + String sql_str2 = "INSERT INTO " + Sql_Mysql.Tb_Batt_RTAlarm_Table + "(BattGroupId, mon_num)" + " VALUES "; + boolean isStart = true; + for(int mc = max_monnum; mc < mon_cnt; mc++) { + if(isStart) { + isStart = false; + }else{ + sql_str2 += ","; + } + sql_str2 += "(" + bg_id + "," + (mc+1) + ")"; + } + System.out.println("电池组"+bg_id+"从单体"+(max_monnum+1)+"开始在tb_batt_rtdata表中添加单体数据 at " + Com.getDateTimeFormat(new Date(), Com.DTF_YMDhms)); + sql.sqlMysqlExecute(sql_str2); + }else if(mon_cnt < max_monnum){ + //删除当前电池组中超过单体个数的数据 + String sql_str2 = " DELETE FROM " + Sql_Mysql.Tb_Batt_RTAlarm_Table + " WHERE BattGroupId = " +bg_id+ " AND mon_num > "+mon_cnt; + sql.sqlMysqlExecute(sql_str2); + System.out.println("电池组"+bg_id+"从单体"+(mon_cnt+1)+"开始删除tb_batt_rtdata单体数据 at "+Com.getDateTimeFormat(new Date(), Com.DTF_YMDhms)); + } + } + } + + } 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 '记录时间'," + + " `dev_version` varchar(64) NOT NULL DEFAULT '' 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';"); + } + //添加字段dev_version + res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns" + + " WHERE table_schema='db_ram_db'" + + " AND table_name='tb_fbs9100_chargerstate'" + + " AND column_name='dev_version'"); + if(false == res.next()) { + sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.FBS9100_ChargerstateTable + + " ADD COLUMN `dev_version` varchar(64) NOT NULL DEFAULT '' COMMENT '协转版本号';"); + } + } catch (SQLException e) { + e.printStackTrace(); + } finally { + if(null != res) { + try { + res.close(); + } catch (SQLException e) { + e.printStackTrace(); + } + } + sql.close_con(); + } + } + + /** + * 创建干接点状态表 + * @param pool + * @param recreate + */ + private static void createFBS9100s_stemnode_state_Table(MysqlConnPool pool, boolean recreate) { + String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.FBS9100s_stemnode_state_Table; + String sql_str02 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.FBS9100s_stemnode_state_Table + " (" + + " `num` bigint(20) NOT NULL AUTO_INCREMENT," + + " `dev_id` int(11) NOT NULL," + + " `record_time` datetime NOT NULL DEFAULT '2000-01-01 00:00:00' COMMENT '记录时间'," + + " `dryInputState` int(11) NOT NULL DEFAULT '0' COMMENT '干节点输入状态'," + + " `dryOutputState` int(11) NOT NULL DEFAULT '0' COMMENT '干节点输出状态'," + + " `volOutputState` int(11) NOT NULL DEFAULT '0' COMMENT '干节点电压输出状态'," + + " `sumOutputVolt` float NOT NULL DEFAULT '0' COMMENT '总输出电压'," + + " `sumOutputCur` float NOT NULL DEFAULT '0' COMMENT '总输出电流'," + + " `outputVolt1` float NOT NULL DEFAULT '0' COMMENT '输出电压1'," + + " `outputVolt2` float NOT NULL DEFAULT '0' COMMENT '输出电压2'," + + " `outputVolt3` float NOT NULL DEFAULT '0' COMMENT '输出电压3'," + + " `outputVolt4` float NOT NULL DEFAULT '0' COMMENT '输出电压4'," + + " PRIMARY KEY (`num`)," + + " UNIQUE KEY `index_dev_id` (`dev_id`) USING BTREE" + + ") 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(); + } + + } + + /** + * 创建母联状态表 + * @param pool + * @param recreate + */ + private static void createFBS9100s_buscouple_state_Table(MysqlConnPool pool, boolean recreate) { + String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.FBS9100s_buscouple_state_Table; + String sql_str02 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.FBS9100s_buscouple_state_Table + " (" + + " `num` bigint(20) NOT NULL AUTO_INCREMENT," + + " `dev_id` int(11) NOT NULL DEFAULT '912000001' COMMENT '设备id'," + + " `record_time` datetime NOT NULL DEFAULT '2000-01-01 00:00:00' COMMENT '记录时间'," + + " `fanglei_state` int(11) NOT NULL DEFAULT '0' COMMENT '防雷状态:0:未连接;1:正常工作;2需要更换防雷设备'," + + " `workstate` int(11) NOT NULL DEFAULT '0' COMMENT '工作状态'," + + " `rlayworkmode` int(11) NOT NULL DEFAULT '0' COMMENT '空开操作状态'," + + " `rlyAstate` int(11) NOT NULL DEFAULT '0' COMMENT '开关输入ON状态'," + + " `rlyBstate` int(11) NOT NULL DEFAULT '0' COMMENT '开关输入OFF状态'," + + " `stopreson` int(11) NOT NULL DEFAULT '0' COMMENT '停止原因'," + + " `volt_m1` float NOT NULL DEFAULT '0' COMMENT '电压1'," + + " `volt_m2` float NOT NULL DEFAULT '0' COMMENT '电压2'," + + " `iout` float NOT NULL DEFAULT '0' COMMENT '电流'," + + " `curdir` int(11) NOT NULL DEFAULT '0' COMMENT '电流方向'," + + " `commustate` int(11) NOT NULL DEFAULT '0' COMMENT '通信状态'," + + " PRIMARY KEY (`num`)," + + " UNIQUE KEY `index_dev_id` (`dev_id`) USING BTREE" + + ") ENGINE=InnoDB AUTO_INCREMENT=3 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(); + } + + } + + /** + * 创建充放电一体机下载控制表 + * @param pool + * @param recreate + */ + private static void createFgcd_filedownload_Table(MysqlConnPool pool, boolean recreate) { + String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.Fgcd_filedownload_Table; + String sql_str02 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.Fgcd_filedownload_Table + " (" + + " `num` bigint(20) NOT NULL AUTO_INCREMENT," + + " `dev_id` int(11) NOT NULL DEFAULT '0' COMMENT '设备id'," + + " `BattGroupId` int(11) NOT NULL DEFAULT '0' COMMENT '电池组ID'," + + " `op_cmd` int(11) NOT NULL DEFAULT '0' COMMENT '命令'," + + " `file_total` int(11) NOT NULL DEFAULT '0' COMMENT '总的文件数目'," + + " `file_count` int(11) NOT NULL DEFAULT '0' COMMENT '当前页数据文件数'," + + " `file_index` int(11) NOT NULL DEFAULT '0' COMMENT '需要下载文件索引'," + + " `file_name1` varchar(255) NOT NULL DEFAULT '' COMMENT '文件名1'," + + " `file_index1` int(11) NOT NULL DEFAULT '0' COMMENT '文件索引1'," + + " `test_timelong1` int(11) NOT NULL DEFAULT '0' COMMENT '测试时长1'," + + " `data_type1` int(11) NOT NULL DEFAULT '0' COMMENT '数据类型1'," + + " `test_curr1` float NOT NULL DEFAULT '0' COMMENT '测试电流1'," + + " `test_cap1` float NOT NULL DEFAULT '0' COMMENT '测试容量1'," + + " `cap_std1` int(11) NOT NULL DEFAULT '0' COMMENT '标称容量1'," + + " `mon_count1` int(11) NOT NULL DEFAULT '0' COMMENT '单体数量1'," + + " `mon_vol1` float NOT NULL DEFAULT '0' COMMENT '单体电压类型1'," + + " `stop_type1` int(11) NOT NULL DEFAULT '0' COMMENT '停止原因1'," + + " `download_flag1` int(11) NOT NULL DEFAULT '0' COMMENT '下载标识1'," + + " `download_state1` int(11) NOT NULL DEFAULT '0' COMMENT '下载状态1'," + + " `file_name2` varchar(255) NOT NULL DEFAULT '' COMMENT '文件名2'," + + " `file_index2` int(11) NOT NULL DEFAULT '0' COMMENT '文件索引2'," + + " `test_timelong2` int(11) NOT NULL DEFAULT '0' COMMENT '测试时长2'," + + " `data_type2` int(11) NOT NULL DEFAULT '0' COMMENT '数据类型2'," + + " `test_curr2` float NOT NULL DEFAULT '0' COMMENT '测试电流2'," + + " `test_cap2` float NOT NULL DEFAULT '0' COMMENT '测试容量2'," + + " `cap_std2` int(11) NOT NULL DEFAULT '0' COMMENT '标称容量2'," + + " `mon_count2` int(11) NOT NULL DEFAULT '0' COMMENT '单体数量2'," + + " `mon_vol2` float NOT NULL DEFAULT '0' COMMENT '单体电压类型2'," + + " `stop_type2` int(11) NOT NULL DEFAULT '0' COMMENT '停止原因2'," + + " `download_flag2` int(11) NOT NULL DEFAULT '0' COMMENT '下载标识2'," + + " `download_state2` int(11) NOT NULL DEFAULT '0' COMMENT '下载状态2'," + + " `file_name3` varchar(255) NOT NULL DEFAULT '' COMMENT '文件名3'," + + " `file_index3` int(11) NOT NULL DEFAULT '0' COMMENT '文件索引3'," + + " `test_timelong3` int(11) NOT NULL DEFAULT '0' COMMENT '测试时长3'," + + " `data_type3` int(11) NOT NULL DEFAULT '0' COMMENT '数据类型3'," + + " `test_curr3` float NOT NULL DEFAULT '0' COMMENT '测试电流3'," + + " `test_cap3` float NOT NULL DEFAULT '0' COMMENT '测试容量3'," + + " `cap_std3` int(11) NOT NULL DEFAULT '0' COMMENT '标称容量3'," + + " `mon_count3` int(11) NOT NULL DEFAULT '0' COMMENT '单体数量3'," + + " `mon_vol3` float NOT NULL DEFAULT '0' COMMENT '单体电压类型3'," + + " `stop_type3` int(11) NOT NULL DEFAULT '0' COMMENT '停止原因3'," + + " `download_flag3` int(11) NOT NULL DEFAULT '0' COMMENT '下载标识3'," + + " `download_state3` int(11) NOT NULL DEFAULT '0' COMMENT '下载状态3'," + + " `file_name4` varchar(255) NOT NULL DEFAULT '' COMMENT '文件名4'," + + " `file_index4` int(11) NOT NULL DEFAULT '0' COMMENT '文件索引4'," + + " `test_timelong4` int(11) NOT NULL DEFAULT '0' COMMENT '测试时长4'," + + " `data_type4` int(11) NOT NULL DEFAULT '0' COMMENT '数据类型4'," + + " `test_curr4` float NOT NULL DEFAULT '0' COMMENT '测试电流4'," + + " `test_cap4` float NOT NULL DEFAULT '0' COMMENT '测试容量4'," + + " `cap_std4` int(11) NOT NULL DEFAULT '0' COMMENT '标称容量4'," + + " `mon_count4` int(11) NOT NULL DEFAULT '0' COMMENT '单体数量4'," + + " `mon_vol4` float NOT NULL DEFAULT '0' COMMENT '单体电压类型4'," + + " `download_flag4` int(11) NOT NULL DEFAULT '0' COMMENT '下载标识4'," + + " `download_state4` int(11) NOT NULL DEFAULT '0' COMMENT '下载状态4'," + + " `stop_type4` int(11) NOT NULL DEFAULT '0' COMMENT '停止原因4'," + + " `file_name5` varchar(255) NOT NULL DEFAULT '' COMMENT '文件名5'," + + " `file_index5` int(11) NOT NULL DEFAULT '0' COMMENT '文件索引5'," + + " `test_timelong5` int(11) NOT NULL DEFAULT '0' COMMENT '测试时长5'," + + " `data_type5` int(11) NOT NULL DEFAULT '0' COMMENT '数据类型5'," + + " `test_curr5` float NOT NULL DEFAULT '0' COMMENT '测试电流5'," + + " `test_cap5` float NOT NULL DEFAULT '0' COMMENT '测试容量5'," + + " `cap_std5` int(11) NOT NULL DEFAULT '0' COMMENT '标称容量5'," + + " `mon_count5` int(11) NOT NULL DEFAULT '0' COMMENT '单体数量5'," + + " `mon_vol5` float NOT NULL DEFAULT '0' COMMENT '单体电压类型5'," + + " `stop_type5` int(11) NOT NULL DEFAULT '0' COMMENT '停止原因5'," + + " `download_flag5` int(11) NOT NULL DEFAULT '0' COMMENT '下载标识5'," + + " `download_state5` int(11) NOT NULL DEFAULT '0' COMMENT '下载状态5'," + + " `file_name6` varchar(255) NOT NULL DEFAULT '' COMMENT '文件名6'," + + " `file_index6` int(11) NOT NULL DEFAULT '0' COMMENT '文件索引6'," + + " `test_timelong6` int(11) NOT NULL DEFAULT '0' COMMENT '测试时长6'," + + " `data_type6` int(11) NOT NULL DEFAULT '0' COMMENT '数据类型6'," + + " `test_curr6` float NOT NULL DEFAULT '0' COMMENT '测试电流6'," + + " `test_cap6` float NOT NULL DEFAULT '0' COMMENT '测试容量6'," + + " `cap_std6` int(11) NOT NULL DEFAULT '0' COMMENT '标称容量6'," + + " `mon_count6` int(11) NOT NULL DEFAULT '0' COMMENT '单体数量6'," + + " `mon_vol6` float NOT NULL DEFAULT '0' COMMENT '单体电压类型6'," + + " `stop_type6` int(11) NOT NULL DEFAULT '0' COMMENT '停止原因6'," + + " `download_flag6` int(11) NOT NULL DEFAULT '0' COMMENT '下载标识6'," + + " `download_state6` int(11) NOT NULL DEFAULT '0' COMMENT '下载状态6'," + + " `file_name7` varchar(255) NOT NULL DEFAULT '' COMMENT '文件名7'," + + " `file_index7` int(11) NOT NULL DEFAULT '0' COMMENT '文件索引7'," + + " `test_timelong7` int(11) NOT NULL DEFAULT '0' COMMENT '测试时长7'," + + " `data_type7` int(11) NOT NULL DEFAULT '0' COMMENT '数据类型7'," + + " `test_curr7` float NOT NULL DEFAULT '0' COMMENT '测试电流7'," + + " `test_cap7` float NOT NULL DEFAULT '0' COMMENT '测试容量7'," + + " `cap_std7` int(11) NOT NULL DEFAULT '0' COMMENT '标称容量7'," + + " `mon_count7` int(11) NOT NULL DEFAULT '0' COMMENT '单体数量7'," + + " `mon_vol7` float NOT NULL DEFAULT '0' COMMENT '单体电压类型7'," + + " `stop_type7` int(11) NOT NULL DEFAULT '0' COMMENT '停止原因7'," + + " `download_flag7` int(11) NOT NULL DEFAULT '0' COMMENT '下载状态7'," + + " `download_state7` int(11) NOT NULL DEFAULT '0' COMMENT '下载状态7'," + + " `file_name8` varchar(255) NOT NULL DEFAULT '' COMMENT '文件名8'," + + " `file_index8` int(11) NOT NULL DEFAULT '0' COMMENT '文件索引8'," + + " `test_timelong8` int(11) NOT NULL DEFAULT '0' COMMENT '测试时长8'," + + " `data_type8` int(11) NOT NULL DEFAULT '0' COMMENT '数据类型8'," + + " `test_curr8` float NOT NULL DEFAULT '0' COMMENT '测试电流8'," + + " `test_cap8` float NOT NULL DEFAULT '0' COMMENT '测试容量8'," + + " `cap_std8` int(11) NOT NULL DEFAULT '0' COMMENT '标称容量8'," + + " `mon_count8` int(11) NOT NULL DEFAULT '0' COMMENT '单体数量8'," + + " `mon_vol8` float NOT NULL DEFAULT '0' COMMENT '单体电压类型8'," + + " `stop_type8` int(11) NOT NULL DEFAULT '0' COMMENT '停止原因8'," + + " `download_flag8` int(11) NOT NULL DEFAULT '0' COMMENT '下载标识8'," + + " `download_state8` int(11) NOT NULL DEFAULT '0' COMMENT '下载状态8'," + + " `stop_reason` int(11) NOT NULL DEFAULT '0' COMMENT '异常停止原因'," + + " `download_state` int(11) NOT NULL DEFAULT '0' COMMENT '下载状态[1:下载文件;2:生成文件;3:解析数据;4:导入完成]'," + + " `now_data_block` int(11) NOT NULL DEFAULT '0' COMMENT '当前下载进度'," + + " `total_data_block` int(11) NOT NULL DEFAULT '0' COMMENT '总的数据块数'," + + " PRIMARY KEY (`num`)," + + " UNIQUE KEY `index_dev_id` (`dev_id`) USING BTREE" + + ") 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(); + } + + } + +} -- Gitblit v1.9.1