package com.database_util;
|
|
import java.sql.SQLException;
|
import java.util.Date;
|
|
import com.base.Com;
|
import com.sql.MysqlConnPool;
|
import com.sql.Sql_Mysql;
|
|
public class DB_Batt_Testdata {
|
|
public static void init(MysqlConnPool pool, boolean recreate) {
|
System.out.println(" db_batt_testdata init start at " + Com.getDateTimeFormat(new Date(), Com.DTF_YMDhms));
|
|
createDB_BATT_TESTDATA(pool);
|
|
createBattTestDataInf_Table(pool, recreate);
|
|
createBattResDataInf_Table(pool, recreate);
|
|
System.out.println(" db_batt_testdata init end at " + Com.getDateTimeFormat(new Date(), Com.DTF_YMDhms));
|
}
|
|
/**
|
* ´´½¨ db_batt_testdata Êý¾Ý¿â
|
* @param pool
|
*/
|
public static void createDB_BATT_TESTDATA(MysqlConnPool pool) {
|
Sql_Mysql sql = new Sql_Mysql(pool.getConn());
|
try {
|
sql.sqlMysqlExecute("CREATE DATABASE IF NOT EXISTS " + Sql_Mysql.DB_BATT_TESTDATA);
|
} catch (SQLException e) {
|
e.printStackTrace();
|
} finally {
|
sql.close_con();
|
}
|
}
|
|
/**
|
* ´´½¨ tb_batttestdata_inf ±í
|
* @param pool
|
* @param recreate
|
*/
|
public static void createBattTestDataInf_Table(MysqlConnPool pool, boolean recreate) {
|
String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.BattTestDataInf_Table;
|
String sql_str02 = " CREATE TABLE IF NOT EXISTS " + Sql_Mysql.BattTestDataInf_Table + " (" +
|
" num bigint(20) NOT NULL AUTO_INCREMENT," +
|
" BattGroupId int(11) NOT NULL DEFAULT '0'," +
|
" test_record_count int(11) NOT NULL DEFAULT '0'," +
|
" test_record_count_ex int(11) NOT NULL DEFAULT '0'," +
|
" test_type int(11) NOT NULL DEFAULT '0'," +
|
" record_time_interval int(11) NOT NULL DEFAULT '0'," +
|
" data_new tinyint(1) NOT NULL DEFAULT '0'," +
|
" data_available tinyint(1) NOT NULL DEFAULT '0'," +
|
" record_num int(11) NOT NULL DEFAULT '0'," +
|
" test_starttime datetime NOT NULL DEFAULT '1982-01-01 00:00:00'," +
|
" test_starttime_ex datetime NOT NULL DEFAULT '1982-01-01 00:00:00'," +
|
" test_starttype int(11) NOT NULL DEFAULT '0'," +
|
" record_time datetime NOT NULL DEFAULT '1982-01-01 00:00:00'," +
|
" test_timelong int(11) NOT NULL DEFAULT '0'," +
|
" test_stoptype int(11) NOT NULL DEFAULT '0'," +
|
" group_vol float NOT NULL DEFAULT '0'," +
|
" test_curr float NOT NULL DEFAULT '0'," +
|
" test_cap float NOT NULL DEFAULT '0'," +
|
" max_monnum int(11) NOT NULL DEFAULT '0'," +
|
" max_monvol float NOT NULL DEFAULT '0'," +
|
" min_monnum int(11) NOT NULL DEFAULT '0'," +
|
" min_monvol float NOT NULL DEFAULT '0'," +
|
" mon_num int(11) NOT NULL DEFAULT '0'," +
|
" mon_vol float NOT NULL DEFAULT '0'," +
|
" upload_usr_id int(11) NOT NULL DEFAULT '0'," +
|
" upload_data_ext int(11) NOT NULL DEFAULT '0'," +
|
" upload_client_type int(11) NOT NULL DEFAULT '0'," +
|
" PRIMARY KEY (num)," +
|
" KEY index_battgroup_id (BattGroupId)," +
|
" KEY index_test_record_count (test_record_count)," +
|
" KEY index_test_starttime (test_starttime)" +
|
") ENGINE=InnoDB AUTO_INCREMENT=9 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_battresdata_inf ±í
|
* @param pool
|
* @param recreate
|
*/
|
public static void createBattResDataInf_Table(MysqlConnPool pool, boolean recreate) {
|
String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.BattResDataInf_Table;
|
String sql_str02 = " CREATE TABLE IF NOT EXISTS " + Sql_Mysql.BattResDataInf_Table + " (" +
|
" num bigint(20) NOT NULL AUTO_INCREMENT," +
|
" BattGroupId int(11) NOT NULL DEFAULT '0'," +
|
" test_record_count int(11) NOT NULL DEFAULT '0'," +
|
" test_record_count_ex int(11) NOT NULL DEFAULT '0'," +
|
" test_type int(11) NOT NULL DEFAULT '0'," +
|
" data_new tinyint(1) NOT NULL DEFAULT '0'," +
|
" data_available tinyint(1) NOT NULL DEFAULT '0'," +
|
" test_starttime datetime NOT NULL DEFAULT '1982-01-01 00:00:00'," +
|
" test_starttime_ex datetime NOT NULL DEFAULT '1982-01-01 00:00:00'," +
|
" test_devtype int(11) NOT NULL DEFAULT '0'," +
|
" record_time datetime NOT NULL DEFAULT '1982-01-01 00:00:00'," +
|
" group_vol float NOT NULL DEFAULT '0'," +
|
" test_curr float NOT NULL DEFAULT '0'," +
|
" upload_usr_id int(11) NOT NULL DEFAULT '0'," +
|
" upload_client_type int(11) NOT NULL DEFAULT '0'," +
|
" PRIMARY KEY (num)," +
|
" KEY index_battgroup_id (BattGroupId)," +
|
" KEY index_test_record_count (test_record_count)," +
|
" KEY index_test_starttime (test_starttime)" +
|
") ENGINE=InnoDB AUTO_INCREMENT=39 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();
|
}
|
}
|
}
|