| | |
| | | package com.database_util;
|
| | |
|
| | | import java.sql.ResultSet;
|
| | | import java.sql.SQLException;
|
| | |
|
| | | import com.sql.MysqlConnPool;
|
| | | import com.sql.Sql_Mysql;
|
| | |
|
| | | public class DB_App_Sys {
|
| | |
|
| | | public static void init(MysqlConnPool pool, boolean recreate) {
|
| | | createDB_AppSys(pool);
|
| | | |
| | | createPage_Param_Table(pool, recreate);
|
| | | |
| | | createFbsdev_Statechange_Inf_Table(pool, recreate);
|
| | | |
| | | createDashboard_Module_Chart_Table(pool, recreate);
|
| | | |
| | | createDashboard_Module_Table(pool, recreate);
|
| | | |
| | | createDashboard_Chart_Type_Table(pool, recreate);
|
| | | |
| | | createApp_Sys_Table(pool, recreate);
|
| | | |
| | | createApp_Bts_Comm_Task_Table(pool, recreate);
|
| | | |
| | | createApp_Bts_Battgroup_Table(pool, recreate);
|
| | | |
| | | createMenu_Table(pool, recreate);
|
| | | |
| | | }
|
| | | |
| | | /**
|
| | | * 创建 db_app_sys 数据库
|
| | | * @param pool
|
| | | */
|
| | | public static void createDB_AppSys(MysqlConnPool pool) {
|
| | | Sql_Mysql sql = new Sql_Mysql(pool.getConn());
|
| | | try {
|
| | | sql.sqlMysqlExecute("CREATE DATABASE IF NOT EXISTS " + Sql_Mysql.DB_AppSys);
|
| | | } catch (SQLException e) {
|
| | | e.printStackTrace();
|
| | | } finally {
|
| | | sql.close_con();
|
| | | }
|
| | | }
|
| | | |
| | | /**
|
| | | * 创建 tb_page_param 表
|
| | | * @param pool
|
| | | * @param recreate
|
| | | */
|
| | | public static void createPage_Param_Table(MysqlConnPool pool, boolean recreate) {
|
| | | String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.Page_Param_Table;
|
| | | String sql_str02 = " CREATE TABLE IF NOT EXISTS " + Sql_Mysql.Page_Param_Table + " (" + |
| | | " id int(11) NOT NULL AUTO_INCREMENT," + |
| | | " param varchar(30) DEFAULT NULL COMMENT '具体参数'," + |
| | | " status int(1) DEFAULT NULL COMMENT '参数是否页面显示'," + |
| | | " categoryId int(1) DEFAULT NULL COMMENT '参数分类,类目1,类目2'," + |
| | | " PRIMARY KEY (id) USING BTREE" + |
| | | ") ENGINE=InnoDB AUTO_INCREMENT=21 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_fbsdev_statechange_inf 表
|
| | | * @param pool
|
| | | * @param recreate
|
| | | */
|
| | | public static void createFbsdev_Statechange_Inf_Table(MysqlConnPool pool, boolean recreate) {
|
| | | String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.Fbsdev_Statechange_Inf_Table;
|
| | | String sql_str02 = " CREATE TABLE IF NOT EXISTS " + Sql_Mysql.Fbsdev_Statechange_Inf_Table + " (" + |
| | | " num bigint(20) NOT NULL AUTO_INCREMENT," + |
| | | " dev_id int(11) NOT NULL DEFAULT '0'," + |
| | | " rec_time datetime NOT NULL DEFAULT '1980-01-01 00:00:00'," + |
| | | " last_stat int(11) NOT NULL DEFAULT '0'," + |
| | | " now_stat int(11) NOT NULL DEFAULT '0'," + |
| | | " state_change_reason int(11) NOT NULL DEFAULT '0'," + |
| | | " dev_alarm int(11) NOT NULL DEFAULT '0'," + |
| | | " eve_type int(11) NOT NULL DEFAULT '0'," + |
| | | " module_num int(11) NOT NULL DEFAULT '0'," + |
| | | " PRIMARY KEY (num)," + |
| | | " 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_dashboard_module_chart 表
|
| | | * @param pool
|
| | | * @param recreate
|
| | | */
|
| | | public static void createDashboard_Module_Chart_Table(MysqlConnPool pool, boolean recreate) {
|
| | | String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.Dashboard_Module_Chart_Table;
|
| | | String sql_str02 = " CREATE TABLE IF NOT EXISTS " + Sql_Mysql.Dashboard_Module_Chart_Table + " (" + |
| | | " id int(11) NOT NULL AUTO_INCREMENT," + |
| | | " module_id int(11) NOT NULL DEFAULT '0' COMMENT '模块id'," + |
| | | " title varchar(255) NOT NULL DEFAULT ''," + |
| | | " label varchar(20) NOT NULL DEFAULT ''," + |
| | | " type_id int(11) NOT NULL DEFAULT '1' COMMENT '图标类型:1.横向柱状图;2.竖向柱状图;3.折线图;4.饼图'," + |
| | | " page_id int(11) NOT NULL DEFAULT '1' COMMENT '页面id'," + |
| | | " PRIMARY KEY (id) USING BTREE" + |
| | | ") ENGINE=InnoDB AUTO_INCREMENT=24 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_dashboard_module 表
|
| | | * @param pool
|
| | | * @param recreate
|
| | | */
|
| | | public static void createDashboard_Module_Table(MysqlConnPool pool, boolean recreate) {
|
| | | String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.Dashboard_Module_Table;
|
| | | String sql_str02 = " CREATE TABLE IF NOT EXISTS " + Sql_Mysql.Dashboard_Module_Table + " (" + |
| | | " id int(11) NOT NULL AUTO_INCREMENT," + |
| | | " x int(11) DEFAULT NULL DEFAULT '1' COMMENT 'x坐标'," + |
| | | " y int(11) DEFAULT NULL DEFAULT '0' COMMENT 'y坐标'," + |
| | | " w int(11) DEFAULT NULL DEFAULT '0' COMMENT '宽度'," + |
| | | " h int(11) DEFAULT NULL DEFAULT '0' COMMENT '高度'," + |
| | | " module_id int(11) DEFAULT '0' COMMENT '模块Id'," + |
| | | " title varchar(255) DEFAULT '' COMMENT '模块标题'," + |
| | | " label varchar(255) DEFAULT '' COMMENT '英文'," + |
| | | " type varchar(20) DEFAULT '' COMMENT '图标类型:1.横向柱状图;2.竖向柱状图;3.折线图;4.饼图'," + |
| | | " page_id int(11) DEFAULT '0' COMMENT '页面Id'," + |
| | | " user_id int(11) DEFAULT '0' COMMENT '所属用户'," + |
| | | " PRIMARY KEY (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();
|
| | | }
|
| | | }
|
| | | |
| | | /**
|
| | | * 创建 tb_dashboard_chart_type 表
|
| | | * @param pool
|
| | | * @param recreate
|
| | | */
|
| | | public static void createDashboard_Chart_Type_Table(MysqlConnPool pool, boolean recreate) {
|
| | | String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.Dashboard_Chart_Type_Table;
|
| | | String sql_str02 = " CREATE TABLE IF NOT EXISTS " + Sql_Mysql.Dashboard_Chart_Type_Table + " (" + |
| | | " id int(11) NOT NULL AUTO_INCREMENT," + |
| | | " type_id int(11) DEFAULT '1'," + |
| | | " type_name varchar(20) DEFAULT ''," + |
| | | " PRIMARY KEY (id) USING BTREE" + |
| | | ") ENGINE=InnoDB AUTO_INCREMENT=6 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_app_sys 表
|
| | | * @param pool
|
| | | * @param recreate
|
| | | */
|
| | | public static void createApp_Sys_Table(MysqlConnPool pool, boolean recreate) {
|
| | | String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.App_Sys_Table;
|
| | | String sql_str02 = " CREATE TABLE IF NOT EXISTS " + Sql_Mysql.App_Sys_Table + " (" + |
| | | " num int(11) NOT NULL AUTO_INCREMENT," + |
| | | " SqlDB_Version float NOT NULL DEFAULT '1'," + |
| | | " SqlDB_BackUpTime datetime NOT NULL DEFAULT '2000-01-01 00:00:00'," + |
| | | " SqlDB_BackUpManual_EN tinyint(1) NOT NULL DEFAULT '0'," + |
| | | " AppServer_Reinit_BattGroupData_EN tinyint(1) NOT NULL DEFAULT '0'," + |
| | | " AppServer_Reinit_BattGroupData_LD9_EN tinyint(1) NOT NULL DEFAULT '0'," + |
| | | " AppServer_Reinit_BattGroupData_A059_EN tinyint(1) NOT NULL DEFAULT '0'," + |
| | | " AppServer_Reinit_Config_EN tinyint(1) NOT NULL DEFAULT '0'," + |
| | | " AppServer_Version float NOT NULL DEFAULT '1'," + |
| | | " AppClient_Version float NOT NULL DEFAULT '1'," + |
| | | " AppName varchar(50) NOT NULL DEFAULT '0'," + |
| | | " PRIMARY KEY (num)" + |
| | | ") ENGINE=InnoDB AUTO_INCREMENT=2 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); |
| | | //添加充放电一体机蓄电池组录入状态
|
| | | res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
|
| | | + " WHERE table_schema='db_app_sys'"
|
| | | + " AND table_name='tb_app_sys'"
|
| | | + " AND column_name='AppServer_Reinit_BattGroupData_A059_EN'");
|
| | | if(false == res.next()) {
|
| | | sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.App_Sys_Table |
| | | + " ADD COLUMN AppServer_Reinit_BattGroupData_A059_EN tinyint(1) NOT NULL DEFAULT '0';");
|
| | | }
|
| | | |
| | | } catch (SQLException e) {
|
| | | e.printStackTrace();
|
| | | } finally {
|
| | | sql.close_con();
|
| | | }
|
| | | }
|
| | | |
| | | /**
|
| | | * 创建 tb_app_bts_comm_task 表
|
| | | * @param pool
|
| | | * @param recreate
|
| | | */
|
| | | public static void createApp_Bts_Comm_Task_Table(MysqlConnPool pool, boolean recreate) {
|
| | | String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.App_Bts_Comm_Task_Table;
|
| | | String sql_str02 = " CREATE TABLE IF NOT EXISTS " + Sql_Mysql.App_Bts_Comm_Task_Table + " (" + |
| | | " num bigint(20) NOT NULL AUTO_INCREMENT," + |
| | | " thread_id bigint(20) NOT NULL DEFAULT '0'," + |
| | | " dev_id bigint(20) NOT NULL DEFAULT '0'," + |
| | | " dev_mcu_uid varchar(48) NOT NULL DEFAULT 'null'," + |
| | | " battgroup_cnt int(11) NOT NULL DEFAULT '0'," + |
| | | " battgroup_id1 int(11) NOT NULL DEFAULT '0'," + |
| | | " battgroup_index1 int(11) NOT NULL DEFAULT '0'," + |
| | | " battgroup_id2 int(11) NOT NULL DEFAULT '0'," + |
| | | " battgroup_index2 int(11) NOT NULL DEFAULT '0'," + |
| | | " battgroup_id3 int(11) NOT NULL DEFAULT '0'," + |
| | | " battgroup_index3 int(11) NOT NULL DEFAULT '0'," + |
| | | " battgroup_id4 int(11) NOT NULL DEFAULT '0'," + |
| | | " battgroup_index4 int(11) NOT NULL DEFAULT '0'," + |
| | | " connet_time varchar(20) NOT NULL DEFAULT '1980-01-01 01:01:00'," + |
| | | " dev_comm_runtime varchar(20) NOT NULL DEFAULT '1980-01-01 01:01:00'," + |
| | | " break_type int(11) NOT NULL DEFAULT '0'," + |
| | | " PRIMARY KEY (num)," + |
| | | " 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_app_bts_battgroup 表
|
| | | * @param pool
|
| | | * @param recreate
|
| | | */
|
| | | public static void createApp_Bts_Battgroup_Table(MysqlConnPool pool, boolean recreate) {
|
| | | String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.App_Bts_Battgroup_Table;
|
| | | String sql_str02 = " CREATE TABLE IF NOT EXISTS " + Sql_Mysql.App_Bts_Battgroup_Table + " (" + |
| | | " num bigint(20) NOT NULL AUTO_INCREMENT," + |
| | | " dev_id bigint(20) NOT NULL DEFAULT '0'," + |
| | | " battgroup_id int(11) NOT NULL DEFAULT '0'," + |
| | | " battgroup_index int(11) NOT NULL DEFAULT '-1'," + |
| | | " battgroup_mon_cnt int(11) NOT NULL DEFAULT '0'," + |
| | | " battgroup_float_vol float NOT NULL DEFAULT '0'," + |
| | | " battgroup_float_curr float NOT NULL DEFAULT '0'," + |
| | | " battgroup_register_code varchar(48) NOT NULL DEFAULT 'null'," + |
| | | " PRIMARY KEY (num)" + |
| | | ") 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();
|
| | | }
|
| | | }
|
| | | |
| | | /**
|
| | | * 创建 tb_menu 表
|
| | | * @param pool
|
| | | * @param recreate
|
| | | */
|
| | | public static void createMenu_Table(MysqlConnPool pool, boolean recreate) {
|
| | | String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.Menu_Table;
|
| | | String sql_str02 = " CREATE TABLE IF NOT EXISTS " + Sql_Mysql.Menu_Table + " (" + |
| | | " `id` int(11) NOT NULL," + |
| | | " `label` varchar(50) DEFAULT NULL COMMENT '中文名称'," + |
| | | " `name` varchar(100) DEFAULT NULL COMMENT '名称'," + |
| | | " `src` varchar(100) DEFAULT NULL COMMENT '路径'," + |
| | | " `icon` varchar(100) DEFAULT NULL COMMENT '图标'," + |
| | | " `closable` tinyint(4) DEFAULT NULL COMMENT '是否可关闭'," + |
| | | " `enableduse` tinyint(4) DEFAULT NULL COMMENT '是否启用'," + |
| | | " `permitName` varchar(100) DEFAULT NULL COMMENT '权限'," + |
| | | " `level` tinyint(4) DEFAULT NULL COMMENT '菜单等级'," + |
| | | " `ord` tinyint(4) DEFAULT NULL COMMENT '排序'," + |
| | | " `menuId` int(11) DEFAULT NULL COMMENT '上级菜单id'," + |
| | | " PRIMARY KEY (`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();
|
| | | }
|
| | | }
|
| | | }
|
| | | package com.database_util; |
| | | |
| | | import java.sql.ResultSet; |
| | | import java.sql.SQLException; |
| | | |
| | | import com.sql.MysqlConnPool; |
| | | import com.sql.Sql_Mysql; |
| | | |
| | | public class DB_App_Sys { |
| | | |
| | | public static void init(MysqlConnPool pool, boolean recreate) { |
| | | createDB_AppSys(pool); |
| | | |
| | | createPage_Param_Table(pool, recreate); |
| | | |
| | | createFbsdev_Statechange_Inf_Table(pool, recreate); |
| | | |
| | | createDashboard_Module_Chart_Table(pool, recreate); |
| | | |
| | | createDashboard_Module_Table(pool, recreate); |
| | | |
| | | createDashboard_Chart_Type_Table(pool, recreate); |
| | | |
| | | createApp_Sys_Table(pool, recreate); |
| | | |
| | | createApp_Bts_Comm_Task_Table(pool, recreate); |
| | | |
| | | createApp_Bts_Battgroup_Table(pool, recreate); |
| | | |
| | | createMenu_Table(pool, recreate); |
| | | |
| | | //3.5大屏 |
| | | createTb_application_Table(pool, recreate); |
| | | createTb_application_config_Table(pool, recreate); |
| | | createTb_dashboard_chart_type_Table(pool, recreate); |
| | | createTb_dashboard_module_Table(pool, recreate); |
| | | createTb_dashboard_module_chart_Table(pool, recreate); |
| | | |
| | | } |
| | | |
| | | private static void createTb_dashboard_module_chart_Table(MysqlConnPool pool, boolean recreate) { |
| | | String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.Tb_dashboard_module_chart_Table; |
| | | String sql_str02 = " CREATE TABLE IF NOT EXISTS " + Sql_Mysql.Tb_dashboard_module_chart_Table + " (" + |
| | | " id int(11) NOT NULL AUTO_INCREMENT," + |
| | | " param varchar(30) DEFAULT NULL COMMENT '具体参数'," + |
| | | " status int(1) DEFAULT NULL COMMENT '参数是否页面显示'," + |
| | | " categoryId int(1) DEFAULT NULL COMMENT '参数分类,类目1,类目2'," + |
| | | " PRIMARY KEY (id) USING BTREE" + |
| | | ") ENGINE=InnoDB AUTO_INCREMENT=21 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(); |
| | | } |
| | | } |
| | | |
| | | private static void createTb_dashboard_module_Table(MysqlConnPool pool, boolean recreate) { |
| | | String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.Tb_dashboard_module_Table; |
| | | String sql_str02 = " CREATE TABLE IF NOT EXISTS " + Sql_Mysql.Tb_dashboard_module_Table + " (" + |
| | | "`id` int(11) NOT NULL AUTO_INCREMENT," + |
| | | " `x` int(11) DEFAULT NULL COMMENT 'x坐标'," + |
| | | " `y` int(11) DEFAULT NULL COMMENT 'y坐标'," + |
| | | " `w` int(11) DEFAULT NULL COMMENT '宽度'," + |
| | | " `h` int(11) DEFAULT NULL COMMENT '高度'," + |
| | | " `module_id` int(11) DEFAULT NULL COMMENT '模块Id'," + |
| | | " `title` varchar(255) DEFAULT NULL COMMENT '模块标题'," + |
| | | " `label` varchar(255) DEFAULT NULL COMMENT '英文'," + |
| | | " `type` varchar(20) DEFAULT NULL COMMENT '图标类型:1.横向柱状图;2.竖向柱状图;3.折线图;4.饼图'," + |
| | | " `page_id` int(11) DEFAULT NULL COMMENT '页面Id'," + |
| | | " `user_id` int(11) DEFAULT NULL COMMENT '所属用户'," + |
| | | " PRIMARY KEY (`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(); |
| | | } |
| | | } |
| | | |
| | | private static void createTb_dashboard_chart_type_Table(MysqlConnPool pool, boolean recreate) { |
| | | String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.Tb_dashboard_chart_type_Table; |
| | | String sql_str02 = " CREATE TABLE IF NOT EXISTS " + Sql_Mysql.Tb_dashboard_chart_type_Table + " (" + |
| | | "`id` int(11) NOT NULL AUTO_INCREMENT," + |
| | | " `type_id` int(11) DEFAULT NULL," + |
| | | " `type_name` varchar(20) DEFAULT NULL," + |
| | | " PRIMARY KEY (`id`) USING BTREE" + |
| | | ") 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(); |
| | | } |
| | | } |
| | | |
| | | private static void createTb_application_config_Table(MysqlConnPool pool, boolean recreate) { |
| | | String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.Tb_application_config_Table; |
| | | String sql_str02 = " CREATE TABLE IF NOT EXISTS " + Sql_Mysql.Tb_application_config_Table + " (" + |
| | | "`num` int(11) NOT NULL AUTO_INCREMENT," + |
| | | " `id` int(11) NOT NULL COMMENT '配置模块对应id'," + |
| | | " `app_id` int(11) DEFAULT NULL COMMENT '所属应用id'," + |
| | | " `name` varchar(255) DEFAULT NULL COMMENT '应用中的模块配置名称'," + |
| | | " `w` double DEFAULT NULL COMMENT '宽度'," + |
| | | " `h` double DEFAULT NULL COMMENT '高度'," + |
| | | " `x` double DEFAULT NULL COMMENT 'X轴坐标'," + |
| | | " `y` double DEFAULT NULL COMMENT 'Y轴坐标'," + |
| | | " `type` varchar(255) DEFAULT NULL COMMENT '图标类型'," + |
| | | " PRIMARY KEY (`num`) USING BTREE" + |
| | | ") ENGINE=InnoDB AUTO_INCREMENT=404 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;"; |
| | | 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(); |
| | | } |
| | | } |
| | | |
| | | private static void createTb_application_Table(MysqlConnPool pool, boolean recreate) { |
| | | String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.Tb_application_Table; |
| | | String sql_str02 = " CREATE TABLE IF NOT EXISTS " + Sql_Mysql.Tb_application_Table + " (" + |
| | | "`id` int(11) NOT NULL AUTO_INCREMENT," + |
| | | " `name` varchar(255) DEFAULT NULL," + |
| | | " `screenshot` varchar(255) DEFAULT NULL COMMENT '缩略图'," + |
| | | " `bg_pic` varchar(255) DEFAULT NULL COMMENT '背景图片'," + |
| | | " `head_pic` varchar(255) DEFAULT NULL COMMENT '头部图片'," + |
| | | " `user_id` int(11) DEFAULT NULL COMMENT '应用所属的用户'," + |
| | | " `active_status` tinyint(1) DEFAULT NULL," + |
| | | " PRIMARY KEY (`id`) USING BTREE" + |
| | | ") ENGINE=InnoDB AUTO_INCREMENT=66 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;"; |
| | | 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(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 创建 db_app_sys 数据库 |
| | | * @param pool |
| | | */ |
| | | public static void createDB_AppSys(MysqlConnPool pool) { |
| | | Sql_Mysql sql = new Sql_Mysql(pool.getConn()); |
| | | try { |
| | | sql.sqlMysqlExecute("CREATE DATABASE IF NOT EXISTS " + Sql_Mysql.DB_AppSys); |
| | | } catch (SQLException e) { |
| | | e.printStackTrace(); |
| | | } finally { |
| | | sql.close_con(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 创建 tb_page_param 表 |
| | | * @param pool |
| | | * @param recreate |
| | | */ |
| | | public static void createPage_Param_Table(MysqlConnPool pool, boolean recreate) { |
| | | String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.Page_Param_Table; |
| | | String sql_str02 = " CREATE TABLE IF NOT EXISTS " + Sql_Mysql.Page_Param_Table + " (" + |
| | | " id int(11) NOT NULL AUTO_INCREMENT," + |
| | | " param varchar(30) DEFAULT NULL COMMENT '具体参数'," + |
| | | " status int(1) DEFAULT NULL COMMENT '参数是否页面显示'," + |
| | | " categoryId int(1) DEFAULT NULL COMMENT '参数分类,类目1,类目2'," + |
| | | " PRIMARY KEY (id) USING BTREE" + |
| | | ") ENGINE=InnoDB AUTO_INCREMENT=21 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_fbsdev_statechange_inf 表 |
| | | * @param pool |
| | | * @param recreate |
| | | */ |
| | | public static void createFbsdev_Statechange_Inf_Table(MysqlConnPool pool, boolean recreate) { |
| | | String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.Fbsdev_Statechange_Inf_Table; |
| | | String sql_str02 = " CREATE TABLE IF NOT EXISTS " + Sql_Mysql.Fbsdev_Statechange_Inf_Table + " (" + |
| | | " num bigint(20) NOT NULL AUTO_INCREMENT," + |
| | | " dev_id int(11) NOT NULL DEFAULT '0'," + |
| | | " rec_time datetime NOT NULL DEFAULT '1980-01-01 00:00:00'," + |
| | | " last_stat int(11) NOT NULL DEFAULT '0'," + |
| | | " now_stat int(11) NOT NULL DEFAULT '0'," + |
| | | " state_change_reason int(11) NOT NULL DEFAULT '0'," + |
| | | " dev_alarm int(11) NOT NULL DEFAULT '0'," + |
| | | " eve_type int(11) NOT NULL DEFAULT '0'," + |
| | | " module_num int(11) NOT NULL DEFAULT '0'," + |
| | | " PRIMARY KEY (num)," + |
| | | " 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_dashboard_module_chart 表 |
| | | * @param pool |
| | | * @param recreate |
| | | */ |
| | | public static void createDashboard_Module_Chart_Table(MysqlConnPool pool, boolean recreate) { |
| | | String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.Dashboard_Module_Chart_Table; |
| | | String sql_str02 = " CREATE TABLE IF NOT EXISTS " + Sql_Mysql.Dashboard_Module_Chart_Table + " (" + |
| | | " id int(11) NOT NULL AUTO_INCREMENT," + |
| | | " module_id int(11) NOT NULL DEFAULT '0' COMMENT '模块id'," + |
| | | " title varchar(255) NOT NULL DEFAULT ''," + |
| | | " label varchar(20) NOT NULL DEFAULT ''," + |
| | | " type_id int(11) NOT NULL DEFAULT '1' COMMENT '图标类型:1.横向柱状图;2.竖向柱状图;3.折线图;4.饼图'," + |
| | | " page_id int(11) NOT NULL DEFAULT '1' COMMENT '页面id'," + |
| | | " PRIMARY KEY (id) USING BTREE" + |
| | | ") ENGINE=InnoDB AUTO_INCREMENT=24 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_dashboard_module 表 |
| | | * @param pool |
| | | * @param recreate |
| | | */ |
| | | public static void createDashboard_Module_Table(MysqlConnPool pool, boolean recreate) { |
| | | String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.Dashboard_Module_Table; |
| | | String sql_str02 = " CREATE TABLE IF NOT EXISTS " + Sql_Mysql.Dashboard_Module_Table + " (" + |
| | | " id int(11) NOT NULL AUTO_INCREMENT," + |
| | | " x int(11) DEFAULT NULL DEFAULT '1' COMMENT 'x坐标'," + |
| | | " y int(11) DEFAULT NULL DEFAULT '0' COMMENT 'y坐标'," + |
| | | " w int(11) DEFAULT NULL DEFAULT '0' COMMENT '宽度'," + |
| | | " h int(11) DEFAULT NULL DEFAULT '0' COMMENT '高度'," + |
| | | " module_id int(11) DEFAULT '0' COMMENT '模块Id'," + |
| | | " title varchar(255) DEFAULT '' COMMENT '模块标题'," + |
| | | " label varchar(255) DEFAULT '' COMMENT '英文'," + |
| | | " type varchar(20) DEFAULT '' COMMENT '图标类型:1.横向柱状图;2.竖向柱状图;3.折线图;4.饼图'," + |
| | | " page_id int(11) DEFAULT '0' COMMENT '页面Id'," + |
| | | " user_id int(11) DEFAULT '0' COMMENT '所属用户'," + |
| | | " PRIMARY KEY (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(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 创建 tb_dashboard_chart_type 表 |
| | | * @param pool |
| | | * @param recreate |
| | | */ |
| | | public static void createDashboard_Chart_Type_Table(MysqlConnPool pool, boolean recreate) { |
| | | String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.Dashboard_Chart_Type_Table; |
| | | String sql_str02 = " CREATE TABLE IF NOT EXISTS " + Sql_Mysql.Dashboard_Chart_Type_Table + " (" + |
| | | " id int(11) NOT NULL AUTO_INCREMENT," + |
| | | " type_id int(11) DEFAULT '1'," + |
| | | " type_name varchar(20) DEFAULT ''," + |
| | | " PRIMARY KEY (id) USING BTREE" + |
| | | ") ENGINE=InnoDB AUTO_INCREMENT=6 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_app_sys 表 |
| | | * @param pool |
| | | * @param recreate |
| | | */ |
| | | public static void createApp_Sys_Table(MysqlConnPool pool, boolean recreate) { |
| | | String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.App_Sys_Table; |
| | | String sql_str02 = " CREATE TABLE IF NOT EXISTS " + Sql_Mysql.App_Sys_Table + " (" + |
| | | " num int(11) NOT NULL AUTO_INCREMENT," + |
| | | " SqlDB_Version float NOT NULL DEFAULT '1'," + |
| | | " SqlDB_BackUpTime datetime NOT NULL DEFAULT '2000-01-01 00:00:00'," + |
| | | " SqlDB_BackUpManual_EN tinyint(1) NOT NULL DEFAULT '0'," + |
| | | " AppServer_Reinit_BattGroupData_EN tinyint(1) NOT NULL DEFAULT '0'," + |
| | | " AppServer_Reinit_BattGroupData_LD9_EN tinyint(1) NOT NULL DEFAULT '0'," + |
| | | " AppServer_Reinit_BattGroupData_A059_EN tinyint(1) NOT NULL DEFAULT '0'," + |
| | | " AppServer_Reinit_Config_EN tinyint(1) NOT NULL DEFAULT '0'," + |
| | | " AppServer_Version float NOT NULL DEFAULT '1'," + |
| | | " AppClient_Version float NOT NULL DEFAULT '1'," + |
| | | " AppName varchar(50) NOT NULL DEFAULT '0'," + |
| | | " PRIMARY KEY (num)" + |
| | | ") ENGINE=InnoDB AUTO_INCREMENT=2 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); |
| | | //添加充放电一体机蓄电池组录入状态 |
| | | res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns" |
| | | + " WHERE table_schema='db_app_sys'" |
| | | + " AND table_name='tb_app_sys'" |
| | | + " AND column_name='AppServer_Reinit_BattGroupData_A059_EN'"); |
| | | if(false == res.next()) { |
| | | sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.App_Sys_Table |
| | | + " ADD COLUMN AppServer_Reinit_BattGroupData_A059_EN tinyint(1) NOT NULL DEFAULT '0';"); |
| | | } |
| | | |
| | | } catch (SQLException e) { |
| | | e.printStackTrace(); |
| | | } finally { |
| | | sql.close_con(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 创建 tb_app_bts_comm_task 表 |
| | | * @param pool |
| | | * @param recreate |
| | | */ |
| | | public static void createApp_Bts_Comm_Task_Table(MysqlConnPool pool, boolean recreate) { |
| | | String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.App_Bts_Comm_Task_Table; |
| | | String sql_str02 = " CREATE TABLE IF NOT EXISTS " + Sql_Mysql.App_Bts_Comm_Task_Table + " (" + |
| | | " num bigint(20) NOT NULL AUTO_INCREMENT," + |
| | | " thread_id bigint(20) NOT NULL DEFAULT '0'," + |
| | | " dev_id bigint(20) NOT NULL DEFAULT '0'," + |
| | | " dev_mcu_uid varchar(48) NOT NULL DEFAULT 'null'," + |
| | | " battgroup_cnt int(11) NOT NULL DEFAULT '0'," + |
| | | " battgroup_id1 int(11) NOT NULL DEFAULT '0'," + |
| | | " battgroup_index1 int(11) NOT NULL DEFAULT '0'," + |
| | | " battgroup_id2 int(11) NOT NULL DEFAULT '0'," + |
| | | " battgroup_index2 int(11) NOT NULL DEFAULT '0'," + |
| | | " battgroup_id3 int(11) NOT NULL DEFAULT '0'," + |
| | | " battgroup_index3 int(11) NOT NULL DEFAULT '0'," + |
| | | " battgroup_id4 int(11) NOT NULL DEFAULT '0'," + |
| | | " battgroup_index4 int(11) NOT NULL DEFAULT '0'," + |
| | | " connet_time varchar(20) NOT NULL DEFAULT '1980-01-01 01:01:00'," + |
| | | " dev_comm_runtime varchar(20) NOT NULL DEFAULT '1980-01-01 01:01:00'," + |
| | | " break_type int(11) NOT NULL DEFAULT '0'," + |
| | | " PRIMARY KEY (num)," + |
| | | " 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_app_bts_battgroup 表 |
| | | * @param pool |
| | | * @param recreate |
| | | */ |
| | | public static void createApp_Bts_Battgroup_Table(MysqlConnPool pool, boolean recreate) { |
| | | String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.App_Bts_Battgroup_Table; |
| | | String sql_str02 = " CREATE TABLE IF NOT EXISTS " + Sql_Mysql.App_Bts_Battgroup_Table + " (" + |
| | | " num bigint(20) NOT NULL AUTO_INCREMENT," + |
| | | " dev_id bigint(20) NOT NULL DEFAULT '0'," + |
| | | " battgroup_id int(11) NOT NULL DEFAULT '0'," + |
| | | " battgroup_index int(11) NOT NULL DEFAULT '-1'," + |
| | | " battgroup_mon_cnt int(11) NOT NULL DEFAULT '0'," + |
| | | " battgroup_float_vol float NOT NULL DEFAULT '0'," + |
| | | " battgroup_float_curr float NOT NULL DEFAULT '0'," + |
| | | " battgroup_register_code varchar(48) NOT NULL DEFAULT 'null'," + |
| | | " PRIMARY KEY (num)" + |
| | | ") 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(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 创建 tb_menu 表 |
| | | * @param pool |
| | | * @param recreate |
| | | */ |
| | | public static void createMenu_Table(MysqlConnPool pool, boolean recreate) { |
| | | String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.Menu_Table; |
| | | String sql_str02 = " CREATE TABLE IF NOT EXISTS " + Sql_Mysql.Menu_Table + " (" + |
| | | " `id` int(11) NOT NULL," + |
| | | " `label` varchar(50) DEFAULT NULL COMMENT '中文名称'," + |
| | | " `name` varchar(100) DEFAULT NULL COMMENT '名称'," + |
| | | " `src` varchar(100) DEFAULT NULL COMMENT '路径'," + |
| | | " `icon` varchar(100) DEFAULT NULL COMMENT '图标'," + |
| | | " `closable` tinyint(4) DEFAULT NULL COMMENT '是否可关闭'," + |
| | | " `enableduse` tinyint(4) DEFAULT NULL COMMENT '是否启用'," + |
| | | " `permitName` varchar(100) DEFAULT NULL COMMENT '权限'," + |
| | | " `level` tinyint(4) DEFAULT NULL COMMENT '菜单等级'," + |
| | | " `ord` tinyint(4) DEFAULT NULL COMMENT '排序'," + |
| | | " `menuId` int(11) DEFAULT NULL COMMENT '上级菜单id'," + |
| | | " PRIMARY KEY (`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(); |
| | | } |
| | | } |
| | | } |