| | |
| | | package main; |
| | | import java.sql.SQLException; |
| | | import java.util.Date; |
| | | |
| | | import com.base.Com; |
| | | import com.battdata_rt.BattData_RT_RamDB_Thread_SQL; |
| | | import com.config.AppConfig; |
| | | import com.dev.fbs9100.FBS9100S_DFU_SQL; |
| | | import com.dev.fbs9100.FBS9100_Task_Thread_SQL; |
| | | import com.sql.MysqlConnPool; |
| | | import com.sql.Sql_Mysql; |
| | | |
| | | public class main_BTS_DB_Builder { |
| | | /**************************************************************************/ |
| | | /**************************************************************************/ |
| | | public final static boolean app_debug = false; |
| | | public final static float m_VersionNum = (float) 1.001; |
| | | public final static String m_Version = "Welcome To Use BTS DB BUILDER V" + m_VersionNum + " RC_20180908"; |
| | | /**************************************************************************/ |
| | | /**************************************************************************/ |
| | | public static final int DEF_MysqlServerFBS_Port = 3360; |
| | | public static int MysqlServer_Port = DEF_MysqlServerFBS_Port; |
| | | |
| | | private static AppConfig m_AppConfig; |
| | | |
| | | private static MysqlConnPool GB_MysqlConnPool; |
| | | /*********************************************************************************************/ |
| | | /*********************************************************************************************/ |
| | | |
| | | public static void init(){ |
| | | /*//BasicConfigurator.configure();*/ |
| | | String ver = m_Version; |
| | | System.out.println("/****************************************************************"); |
| | | System.out.println("*****************************************************************"); |
| | | System.out.println("****************************************************************/"); |
| | | System.out.println(ver); |
| | | System.out.println("App Started At DateTime: " + Com.getDateTimeFormat(new Date(), Com.DTF_YMDhms)); |
| | | |
| | | m_AppConfig = new AppConfig(); |
| | | |
| | | System.out.println("正在连接数据库 DBserver IP:" + m_AppConfig.getMysqlServerIp() + ", port: " + MysqlServer_Port); |
| | | |
| | | GB_MysqlConnPool = new MysqlConnPool(m_AppConfig.getMysqlServerIp(), MysqlServer_Port, 5); |
| | | |
| | | Sql_Mysql sql_ck = new Sql_Mysql(GB_MysqlConnPool.getConn()); |
| | | if(null != sql_ck.mysql_con) { |
| | | System.out.println("成功连接数据库" |
| | | + " DBserver IP:" + m_AppConfig.getMysqlServerIp() |
| | | + ", port: " + MysqlServer_Port |
| | | + " @ " + Com.getDateTimeFormat(new Date(), Com.DTF_YMDhms)); |
| | | } |
| | | try { |
| | | sql_ck.checkAndCreateDB(); |
| | | } catch (SQLException e1) { |
| | | // TODO Auto-generated catch block |
| | | e1.printStackTrace(); |
| | | } finally { |
| | | sql_ck.close_con(); |
| | | } |
| | | /*********************************************************************************/ |
| | | boolean recreate_tb = m_AppConfig.getMysqlDB_RecreateEn(); |
| | | //创建tb_batt_rtstate表格并且将电池组id的值 |
| | | BattData_RT_RamDB_Thread_SQL.createBattState_RT_RamDB_Table(GB_MysqlConnPool, recreate_tb); |
| | | //创建tb_batt_rtdata表格并且将电池组id的值 |
| | | BattData_RT_RamDB_Thread_SQL.createBattData_RT_RamDB_Table(GB_MysqlConnPool, recreate_tb); |
| | | //创建tb_server_state表并且设置表中的值 |
| | | BattData_RT_RamDB_Thread_SQL.createServerState_RamDB_Table(GB_MysqlConnPool, recreate_tb); |
| | | /*********************************************************************************/ |
| | | System.out.println("Recreate RamDB Tables State Is '" + recreate_tb + "'"); |
| | | if(true == recreate_tb) { |
| | | //创建tb_fbs9100s_state表 |
| | | FBS9100_Task_Thread_SQL.createFBS9100StateTableOnRam(GB_MysqlConnPool); |
| | | //创建tb_fbs9100s_dcdc_data表 |
| | | FBS9100_Task_Thread_SQL.createFBS9100S_DCDC_DataTableOnRam(GB_MysqlConnPool); |
| | | //创建tb_fbs9100s_setparam表 |
| | | FBS9100_Task_Thread_SQL.createFBS9100SetTestParamTableOnRam(GB_MysqlConnPool); |
| | | //创建CmccPowerData表 |
| | | FBS9100_Task_Thread_SQL.createFBS9100CmccPowerDataOnRam(GB_MysqlConnPool); |
| | | //创建tb_fbs9100S_DFU_StateTable表并向表中添加数据 |
| | | FBS9100S_DFU_SQL.createFBS9100S_DFU_TableOnRam(GB_MysqlConnPool); |
| | | |
| | | //创建BTSStationState_Table表 |
| | | FBS9100_Task_Thread_SQL.createBTSStationState_TableOnRam(GB_MysqlConnPool); |
| | | } |
| | | |
| | | if(true == m_AppConfig.getMysqlDB_RecreateEn()) { |
| | | m_AppConfig.setMysqlDB_RecreateEn(false); |
| | | m_AppConfig.writeConfigToXml(); |
| | | } |
| | | |
| | | System.out.println("BTS DB BUILDER Work Done @ " + Com.getDateTimeFormat(new Date(), Com.DTF_YMDhms)); |
| | | |
| | | |
| | | //修改tb_app_sys表中的关键字,让主程序识别 |
| | | BattData_RT_RamDB_Thread_SQL.updateTb_App_Sys_AppServerTable(GB_MysqlConnPool); |
| | | try { |
| | | Thread.sleep(1000); |
| | | } catch (InterruptedException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | /* |
| | | while(true) { |
| | | try { |
| | | Thread.sleep(1000); |
| | | } catch (InterruptedException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | */ |
| | | } |
| | | |
| | | |
| | | public static void main(String[] args) { |
| | | init(); |
| | | } |
| | | } |
| | | package main;
|
| | | import java.sql.SQLException;
|
| | | import java.util.Date;
|
| | |
|
| | | import com.base.Com;
|
| | | import com.battdata_rt.BattData_RT_RamDB_Thread_SQL;
|
| | | import com.config.AppConfig;
|
| | | import com.dev.fbs9100.FBS9100S_DFU_SQL;
|
| | | import com.dev.fbs9100.FBS9100_Task_Thread_SQL;
|
| | | import com.sql.MysqlConnPool;
|
| | | import com.sql.Sql_Mysql;
|
| | |
|
| | | public class main_BTS_DB_Builder {
|
| | | /**************************************************************************/
|
| | | /**************************************************************************/
|
| | | public final static boolean app_debug = false;
|
| | | public final static float m_VersionNum = (float) 1.001;
|
| | | public final static String m_Version = "Welcome To Use BTS DB BUILDER V" + m_VersionNum + " RC_20180908";
|
| | | /**************************************************************************/
|
| | | /**************************************************************************/
|
| | | public static final int DEF_MysqlServerFBS_Port = 3360;
|
| | | public static int MysqlServer_Port = DEF_MysqlServerFBS_Port;
|
| | | |
| | | private static AppConfig m_AppConfig;
|
| | | |
| | | private static MysqlConnPool GB_MysqlConnPool;
|
| | | /*********************************************************************************************/
|
| | | /*********************************************************************************************/
|
| | | |
| | | public static void init(){
|
| | | /*//BasicConfigurator.configure();*/
|
| | | String ver = m_Version;
|
| | | System.out.println("/****************************************************************");
|
| | | System.out.println("*****************************************************************");
|
| | | System.out.println("****************************************************************/");
|
| | | System.out.println(ver);
|
| | | System.out.println("App Started At DateTime: " + Com.getDateTimeFormat(new Date(), Com.DTF_YMDhms));
|
| | | |
| | | m_AppConfig = new AppConfig();
|
| | | |
| | | System.out.println("正在连接数据库 DBserver IP:" + m_AppConfig.getMysqlServerIp() + ", port: " + MysqlServer_Port);
|
| | | |
| | | GB_MysqlConnPool = new MysqlConnPool(m_AppConfig.getMysqlServerIp(), MysqlServer_Port, 5);
|
| | | |
| | | Sql_Mysql sql_ck = new Sql_Mysql(GB_MysqlConnPool.getConn());
|
| | | if(null != sql_ck.mysql_con) {
|
| | | System.out.println("成功连接数据库" |
| | | + " DBserver IP:" + m_AppConfig.getMysqlServerIp() |
| | | + ", port: " + MysqlServer_Port |
| | | + " @ " + Com.getDateTimeFormat(new Date(), Com.DTF_YMDhms));
|
| | | }
|
| | | try {
|
| | | sql_ck.checkAndCreateDB();
|
| | | } catch (SQLException e1) {
|
| | | // TODO Auto-generated catch block
|
| | | e1.printStackTrace();
|
| | | } finally {
|
| | | sql_ck.close_con();
|
| | | }
|
| | | /*********************************************************************************/
|
| | | boolean recreate_tb = m_AppConfig.getMysqlDB_RecreateEn();
|
| | | //创建tb_batt_rtstate表格并且将电池组id的值
|
| | | BattData_RT_RamDB_Thread_SQL.createBattState_RT_RamDB_Table(GB_MysqlConnPool, recreate_tb);
|
| | | //创建tb_batt_rtdata表格并且将电池组id的值
|
| | | BattData_RT_RamDB_Thread_SQL.createBattData_RT_RamDB_Table(GB_MysqlConnPool, recreate_tb);
|
| | | //创建tb_server_state表并且设置表中的值
|
| | | BattData_RT_RamDB_Thread_SQL.createServerState_RamDB_Table(GB_MysqlConnPool, recreate_tb);
|
| | | /*********************************************************************************/
|
| | | System.out.println("Recreate RamDB Tables State Is '" + recreate_tb + "'");
|
| | | if(true == recreate_tb) {
|
| | | //创建tb_fbs9100s_state表
|
| | | FBS9100_Task_Thread_SQL.createFBS9100StateTableOnRam(GB_MysqlConnPool);
|
| | | //创建tb_fbs9100s_dcdc_data表
|
| | | FBS9100_Task_Thread_SQL.createFBS9100S_DCDC_DataTableOnRam(GB_MysqlConnPool);
|
| | | //创建tb_fbs9100s_setparam表
|
| | | FBS9100_Task_Thread_SQL.createFBS9100SetTestParamTableOnRam(GB_MysqlConnPool);
|
| | | //创建CmccPowerData表
|
| | | FBS9100_Task_Thread_SQL.createFBS9100CmccPowerDataOnRam(GB_MysqlConnPool);
|
| | | //创建tb_fbs9100S_DFU_StateTable表并向表中添加数据
|
| | | FBS9100S_DFU_SQL.createFBS9100S_DFU_TableOnRam(GB_MysqlConnPool);
|
| | | |
| | | //创建BTSStationState_Table表
|
| | | FBS9100_Task_Thread_SQL.createBTSStationState_TableOnRam(GB_MysqlConnPool);
|
| | | }
|
| | | |
| | | FBS9100_Task_Thread_SQL.insertBTSStationState_TableOnRam(GB_MysqlConnPool); //初始化录入机房状态
|
| | | |
| | | |
| | | if(true == m_AppConfig.getMysqlDB_RecreateEn()) {
|
| | | m_AppConfig.setMysqlDB_RecreateEn(false);
|
| | | m_AppConfig.writeConfigToXml();
|
| | | }
|
| | | |
| | | System.out.println("BTS DB BUILDER Work Done @ " + Com.getDateTimeFormat(new Date(), Com.DTF_YMDhms));
|
| | | |
| | | |
| | | //修改tb_app_sys表中的关键字,让主程序识别
|
| | | BattData_RT_RamDB_Thread_SQL.updateTb_App_Sys_AppServerTable(GB_MysqlConnPool);
|
| | | try {
|
| | | Thread.sleep(1000);
|
| | | } catch (InterruptedException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | |
| | | /*
|
| | | while(true) {
|
| | | try {
|
| | | Thread.sleep(1000);
|
| | | } catch (InterruptedException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | */
|
| | | }
|
| | | |
| | | |
| | | public static void main(String[] args) {
|
| | | init();
|
| | | }
|
| | | }
|