| | |
| | | public static void init(MysqlConnPool pool, boolean recreate) {
|
| | | createDB_battinf(pool); //创建db_battinf 数据库 不存在则创建db_battinf数据库
|
| | |
|
| | | createBattInf_Table(pool, recreate); //创建电池组信息配置表
|
| | | |
| | | createBattinfApply_table(pool, recreate); //创建机房安装审批表
|
| | |
|
| | | createBattinfEx_TABLE(pool, recreate); //创建基站信息
|
| | |
| | | sql.close_con();
|
| | | }
|
| | | }
|
| | | |
| | | /**
|
| | | * 创建 tb_batt_alm_param 表
|
| | | * @param pool
|
| | | * @param recreate
|
| | | */
|
| | | public static void createBattInf_Table(MysqlConnPool pool, boolean recreate) {
|
| | | String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.BattInf_Table;
|
| | | String sql_str02 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.BattInf_Table + " (" + |
| | | " `num` int(11) NOT NULL AUTO_INCREMENT," + |
| | | " `StationId` varchar(20) NOT NULL DEFAULT '0'," + |
| | | " `charge_curr_max` float DEFAULT '20'," + |
| | | " `StationId_ex` varchar(20) DEFAULT '0'," + |
| | | " `StationName` varchar(100) NOT NULL DEFAULT ' '," + |
| | | " `StationName1` varchar(100) NOT NULL DEFAULT ' '," + |
| | | " `StationName2` varchar(100) NOT NULL DEFAULT ' '," + |
| | | " `StationName3` varchar(100) NOT NULL DEFAULT ' '," + |
| | | " `StationName4` varchar(100) NOT NULL DEFAULT ' '," + |
| | | " `StationName5` varchar(100) NOT NULL DEFAULT ' '," + |
| | | " `StationName6` varchar(100) NOT NULL DEFAULT ' '," + |
| | | " `StationName7` varchar(100) NOT NULL DEFAULT ' '," + |
| | | " `StationName8` varchar(100) NOT NULL DEFAULT ' '," + |
| | | " `StationName9` varchar(100) NOT NULL DEFAULT ' '," + |
| | | " `StationIP` varchar(20) NOT NULL DEFAULT '0'," + |
| | | " `FBSDeviceId` bigint(11) NOT NULL DEFAULT '0'," + |
| | | " `FBSDeviceIp` varchar(50) NOT NULL DEFAULT '192.168.0.88'," + |
| | | " `FBSDeviceName` varchar(100) NOT NULL DEFAULT '0'," + |
| | | " `GroupIndexInFBSDevice` int(11) NOT NULL DEFAULT '0'," + |
| | | " `BattModel` varchar(100) NOT NULL DEFAULT ' '," + |
| | | " `BattGroupId` int(11) NOT NULL DEFAULT '0'," + |
| | | " `BattGroupNum` int(11) NOT NULL DEFAULT '0'," + |
| | | " `BattGroupName` varchar(100) NOT NULL DEFAULT ' '," + |
| | | " `BattGroupName1` varchar(100) NOT NULL DEFAULT ' '," + |
| | | " `BattGroupName2` varchar(100) NOT NULL DEFAULT ' '," + |
| | | " `BattGroupName3` varchar(100) NOT NULL DEFAULT ' '," + |
| | | " `BattGroupName4` varchar(100) NOT NULL DEFAULT ' '," + |
| | | " `BattGroupName5` varchar(100) NOT NULL DEFAULT ' '," + |
| | | " `BattGroupName6` varchar(100) NOT NULL DEFAULT ' '," + |
| | | " `FloatVolLevel` float NOT NULL DEFAULT '1.12'," + |
| | | " `OfflineVolLevel` float NOT NULL DEFAULT '1.06'," + |
| | | " `BattFloatCurrent` float NOT NULL DEFAULT '0'," + |
| | | " `DeviceId` varchar(20) NOT NULL DEFAULT '0'," + |
| | | " `DeviceName` varchar(100) NOT NULL DEFAULT '0'," + |
| | | " `MonCount` int(11) NOT NULL DEFAULT '0'," + |
| | | " `MonCapStd` float NOT NULL DEFAULT '0'," + |
| | | " `MonVolStd` float NOT NULL DEFAULT '0'," + |
| | | " `MonResStd` float NOT NULL DEFAULT '0'," + |
| | | " `MonSerStd` float NOT NULL DEFAULT '0'," + |
| | | " `MonTmpStd` float NOT NULL DEFAULT '0'," + |
| | | " `MonVolLowToAvg` float NOT NULL DEFAULT '0'," + |
| | | " `MonNum` int(11) NOT NULL DEFAULT '0'," + |
| | | " `BattProducer` varchar(45) NOT NULL DEFAULT '0'," + |
| | | " `BattProductDate` date NOT NULL DEFAULT '2006-07-06'," + |
| | | " `BattInUseDate` date NOT NULL DEFAULT '2006-07-06'," + |
| | | " `BattGuarantDayCount` int(11) NOT NULL DEFAULT '1095'," + |
| | | " `SignalId` varchar(20) NOT NULL DEFAULT '0'," + |
| | | " `CInterFaceId` int(11) NOT NULL DEFAULT '0'," + |
| | | " `SignalName` varchar(50) NOT NULL DEFAULT '0'," + |
| | | " `Load_curr` float NOT NULL DEFAULT '15'," + |
| | | " `disCurrMax` float NOT NULL DEFAULT '0'," + |
| | | " `FbsDeviceIp_YM` varchar(50) NOT NULL DEFAULT '255.255.255.0'," + |
| | | " `FbsDeviceIp_WG` varchar(50) NOT NULL DEFAULT '127.0.0.1'," + |
| | | " `station_phone` varchar(32) DEFAULT ''," + |
| | | " `station_install` tinyint(1) NOT NULL DEFAULT '0'," + |
| | | " `install_user` varchar(64) DEFAULT ''," + |
| | | " `Vol_grade` float DEFAULT '0'," + |
| | | " `Manufacturers` varchar(64) DEFAULT ''," + |
| | | " `Assetequipment` varchar(64) DEFAULT ''," + |
| | | " `Deviceclasspath` varchar(64) DEFAULT ''," + |
| | | " `DeviceOperationDepartment` varchar(64) DEFAULT ''," + |
| | | " `PropertyRightUnit` varchar(64) DEFAULT ''," + |
| | | " `PropertyAttribute` varchar(64) DEFAULT ''," + |
| | | " `FactoryNumber` varchar(64) DEFAULT ''," + |
| | | " `OperationTeam` varchar(64) DEFAULT ''," + |
| | | " `DeviceIdentityCode` varchar(64) DEFAULT ''," + |
| | | " `ProjectType` varchar(64) DEFAULT ''," + |
| | | " `BatteryApplicationType` varchar(64) DEFAULT ''," + |
| | | " `SingleRatedVoltage` float DEFAULT '0'," + |
| | | " `RemoteMonitor` varchar(64) DEFAULT ''," + |
| | | " `BatttIndependentPlaced` varchar(64) DEFAULT ''," + |
| | | " `JunChargeVoltageValue` float DEFAULT '0'," + |
| | | " `PublicKeyX` varchar(200) NOT NULL DEFAULT ''," + |
| | | " `PublicKeyY` varchar(200) NOT NULL DEFAULT ''," + |
| | | " `KeyID` varchar(200) NOT NULL DEFAULT ''," + |
| | | " `SerialNumber` varchar(200) NOT NULL DEFAULT ''," + |
| | | " PRIMARY KEY (`num`)," + |
| | | " UNIQUE KEY `index_battgroup_id` (`BattGroupId`) USING BTREE," + |
| | | " KEY `index_station_id` (`StationId`)," + |
| | | " KEY `index_station_name` (`StationName`)," + |
| | | " KEY `index_battgroup_name` (`BattGroupName`)" + |
| | | ") ENGINE=InnoDB AUTO_INCREMENT=3 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);
|
| | | //添加Load_curr
|
| | | res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
|
| | | + " WHERE table_schema='db_battinf'"
|
| | | + " AND table_name='tb_battinf'"
|
| | | + " AND column_name='Load_curr'");
|
| | | if(false == res.next()) {
|
| | | sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.BattInf_Table |
| | | + " ADD COLUMN `Load_curr` float NOT NULL DEFAULT '15';");
|
| | | }
|
| | | //添加disCurrMax
|
| | | res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
|
| | | + " WHERE table_schema='db_battinf'"
|
| | | + " AND table_name='tb_battinf'"
|
| | | + " AND column_name='disCurrMax'");
|
| | | if(false == res.next()) {
|
| | | sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.BattInf_Table |
| | | + " ADD COLUMN `disCurrMax` float NOT NULL DEFAULT '0';");
|
| | | }
|
| | | //添加FbsDeviceIp_YM
|
| | | res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
|
| | | + " WHERE table_schema='db_battinf'"
|
| | | + " AND table_name='tb_battinf'"
|
| | | + " AND column_name='FbsDeviceIp_YM'");
|
| | | if(false == res.next()) {
|
| | | sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.BattInf_Table |
| | | + " ADD COLUMN `FbsDeviceIp_YM` varchar(50) NOT NULL DEFAULT '255.255.255.0';");
|
| | | }
|
| | | //添加FbsDeviceIp_WG
|
| | | res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
|
| | | + " WHERE table_schema='db_battinf'"
|
| | | + " AND table_name='tb_battinf'"
|
| | | + " AND column_name='FbsDeviceIp_WG'");
|
| | | if(false == res.next()) {
|
| | | sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.BattInf_Table |
| | | + " ADD COLUMN `FbsDeviceIp_WG` varchar(50) NOT NULL DEFAULT '127.0.0.1';");
|
| | | }
|
| | | //添加station_phone
|
| | | res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
|
| | | + " WHERE table_schema='db_battinf'"
|
| | | + " AND table_name='tb_battinf'"
|
| | | + " AND column_name='station_phone'");
|
| | | if(false == res.next()) {
|
| | | sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.BattInf_Table |
| | | + " ADD COLUMN `station_phone` varchar(32) DEFAULT '';");
|
| | | }
|
| | | //添加station_install
|
| | | res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
|
| | | + " WHERE table_schema='db_battinf'"
|
| | | + " AND table_name='tb_battinf'"
|
| | | + " AND column_name='station_install'");
|
| | | if(false == res.next()) {
|
| | | sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.BattInf_Table |
| | | + " ADD COLUMN `station_install` tinyint(1) NOT NULL DEFAULT '0';");
|
| | | }
|
| | | //添加install_user
|
| | | res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
|
| | | + " WHERE table_schema='db_battinf'"
|
| | | + " AND table_name='tb_battinf'"
|
| | | + " AND column_name='install_user'");
|
| | | if(false == res.next()) {
|
| | | sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.BattInf_Table |
| | | + " ADD COLUMN `install_user` varchar(64) DEFAULT '';");
|
| | | }
|
| | | //添加Vol_grade
|
| | | res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
|
| | | + " WHERE table_schema='db_battinf'"
|
| | | + " AND table_name='tb_battinf'"
|
| | | + " AND column_name='Vol_grade'");
|
| | | if(false == res.next()) {
|
| | | sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.BattInf_Table |
| | | + " ADD COLUMN `Vol_grade` float DEFAULT '0';");
|
| | | }
|
| | | //添加Manufacturers
|
| | | res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
|
| | | + " WHERE table_schema='db_battinf'"
|
| | | + " AND table_name='tb_battinf'"
|
| | | + " AND column_name='Manufacturers'");
|
| | | if(false == res.next()) {
|
| | | sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.BattInf_Table |
| | | + " ADD COLUMN `Manufacturers` varchar(64) DEFAULT '';");
|
| | | }
|
| | | //添加Assetequipment
|
| | | res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
|
| | | + " WHERE table_schema='db_battinf'"
|
| | | + " AND table_name='tb_battinf'"
|
| | | + " AND column_name='Assetequipment'");
|
| | | if(false == res.next()) {
|
| | | sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.BattInf_Table |
| | | + " ADD COLUMN `Assetequipment` varchar(64) DEFAULT '';");
|
| | | }
|
| | | //添加Deviceclasspath
|
| | | res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
|
| | | + " WHERE table_schema='db_battinf'"
|
| | | + " AND table_name='tb_battinf'"
|
| | | + " AND column_name='Deviceclasspath'");
|
| | | if(false == res.next()) {
|
| | | sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.BattInf_Table |
| | | + " ADD COLUMN `Deviceclasspath` varchar(64) DEFAULT '';");
|
| | | }
|
| | | //添加DeviceOperationDepartment
|
| | | res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
|
| | | + " WHERE table_schema='db_battinf'"
|
| | | + " AND table_name='tb_battinf'"
|
| | | + " AND column_name='DeviceOperationDepartment'");
|
| | | if(false == res.next()) {
|
| | | sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.BattInf_Table |
| | | + " ADD COLUMN `DeviceOperationDepartment` varchar(64) DEFAULT '';");
|
| | | }
|
| | | //添加PropertyRightUnit
|
| | | res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
|
| | | + " WHERE table_schema='db_battinf'"
|
| | | + " AND table_name='tb_battinf'"
|
| | | + " AND column_name='PropertyRightUnit'");
|
| | | if(false == res.next()) {
|
| | | sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.BattInf_Table |
| | | + " ADD COLUMN `PropertyRightUnit` varchar(64) DEFAULT '';");
|
| | | }
|
| | | //添加PropertyAttribute
|
| | | res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
|
| | | + " WHERE table_schema='db_battinf'"
|
| | | + " AND table_name='tb_battinf'"
|
| | | + " AND column_name='PropertyAttribute'");
|
| | | if(false == res.next()) {
|
| | | sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.BattInf_Table |
| | | + " ADD COLUMN `PropertyAttribute` varchar(64) DEFAULT '';");
|
| | | }
|
| | | //添加FactoryNumber
|
| | | res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
|
| | | + " WHERE table_schema='db_battinf'"
|
| | | + " AND table_name='tb_battinf'"
|
| | | + " AND column_name='FactoryNumber'");
|
| | | if(false == res.next()) {
|
| | | sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.BattInf_Table |
| | | + " ADD COLUMN `FactoryNumber` varchar(64) DEFAULT '';");
|
| | | }
|
| | | //添加OperationTeam
|
| | | res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
|
| | | + " WHERE table_schema='db_battinf'"
|
| | | + " AND table_name='tb_battinf'"
|
| | | + " AND column_name='OperationTeam'");
|
| | | if(false == res.next()) {
|
| | | sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.BattInf_Table |
| | | + " ADD COLUMN `OperationTeam` varchar(64) DEFAULT '';");
|
| | | }
|
| | | //添加DeviceIdentityCode
|
| | | res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
|
| | | + " WHERE table_schema='db_battinf'"
|
| | | + " AND table_name='tb_battinf'"
|
| | | + " AND column_name='DeviceIdentityCode'");
|
| | | if(false == res.next()) {
|
| | | sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.BattInf_Table |
| | | + " ADD COLUMN `DeviceIdentityCode` varchar(64) DEFAULT '';");
|
| | | }
|
| | | //添加ProjectType
|
| | | res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
|
| | | + " WHERE table_schema='db_battinf'"
|
| | | + " AND table_name='tb_battinf'"
|
| | | + " AND column_name='ProjectType'");
|
| | | if(false == res.next()) {
|
| | | sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.BattInf_Table |
| | | + " ADD COLUMN `ProjectType` varchar(64) DEFAULT '';");
|
| | | }
|
| | | //添加BatteryApplicationType
|
| | | res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
|
| | | + " WHERE table_schema='db_battinf'"
|
| | | + " AND table_name='tb_battinf'"
|
| | | + " AND column_name='BatteryApplicationType'");
|
| | | if(false == res.next()) {
|
| | | sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.BattInf_Table |
| | | + " ADD COLUMN `BatteryApplicationType` varchar(64) DEFAULT '';");
|
| | | }
|
| | | //添加SingleRatedVoltage
|
| | | res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
|
| | | + " WHERE table_schema='db_battinf'"
|
| | | + " AND table_name='tb_battinf'"
|
| | | + " AND column_name='SingleRatedVoltage'");
|
| | | if(false == res.next()) {
|
| | | sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.BattInf_Table |
| | | + " ADD COLUMN `SingleRatedVoltage` float DEFAULT '0';");
|
| | | }
|
| | | //添加RemoteMonitor
|
| | | res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
|
| | | + " WHERE table_schema='db_battinf'"
|
| | | + " AND table_name='tb_battinf'"
|
| | | + " AND column_name='RemoteMonitor'");
|
| | | if(false == res.next()) {
|
| | | sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.BattInf_Table |
| | | + " ADD COLUMN `RemoteMonitor` varchar(64) DEFAULT '';");
|
| | | }
|
| | | //添加BatttIndependentPlaced
|
| | | res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
|
| | | + " WHERE table_schema='db_battinf'"
|
| | | + " AND table_name='tb_battinf'"
|
| | | + " AND column_name='BatttIndependentPlaced'");
|
| | | if(false == res.next()) {
|
| | | sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.BattInf_Table |
| | | + " ADD COLUMN `BatttIndependentPlaced` varchar(64) DEFAULT '';");
|
| | | }
|
| | | //添加JunChargeVoltageValue
|
| | | res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
|
| | | + " WHERE table_schema='db_battinf'"
|
| | | + " AND table_name='tb_battinf'"
|
| | | + " AND column_name='JunChargeVoltageValue'");
|
| | | if(false == res.next()) {
|
| | | sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.BattInf_Table |
| | | + " ADD COLUMN `JunChargeVoltageValue` float DEFAULT '0';");
|
| | | }
|
| | | //添加PublicKeyX
|
| | | res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
|
| | | + " WHERE table_schema='db_battinf'"
|
| | | + " AND table_name='tb_battinf'"
|
| | | + " AND column_name='PublicKeyX'");
|
| | | if(false == res.next()) {
|
| | | sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.BattInf_Table |
| | | + " ADD COLUMN `PublicKeyX` varchar(200) NOT NULL DEFAULT '';");
|
| | | }
|
| | | //添加PublicKeyY
|
| | | res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
|
| | | + " WHERE table_schema='db_battinf'"
|
| | | + " AND table_name='tb_battinf'"
|
| | | + " AND column_name='PublicKeyY'");
|
| | | if(false == res.next()) {
|
| | | sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.BattInf_Table |
| | | + " ADD COLUMN `PublicKeyY` varchar(200) NOT NULL DEFAULT '';");
|
| | | }
|
| | | //添加KeyID
|
| | | res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
|
| | | + " WHERE table_schema='db_battinf'"
|
| | | + " AND table_name='tb_battinf'"
|
| | | + " AND column_name='KeyID'");
|
| | | if(false == res.next()) {
|
| | | sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.BattInf_Table |
| | | + " ADD COLUMN `KeyID` varchar(200) NOT NULL DEFAULT '';");
|
| | | }
|
| | | //添加SerialNumber
|
| | | res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
|
| | | + " WHERE table_schema='db_battinf'"
|
| | | + " AND table_name='tb_battinf'"
|
| | | + " AND column_name='SerialNumber'");
|
| | | if(false == res.next()) {
|
| | | sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.BattInf_Table |
| | | + " ADD COLUMN `SerialNumber` varchar(200) NOT NULL DEFAULT '';");
|
| | | }
|
| | | } catch (SQLException e) {
|
| | | e.printStackTrace();
|
| | | } finally {
|
| | | sql.close_con();
|
| | | }
|
| | | }
|
| | | }
|