| | |
| | | createWeb_siteDB(pool); //创建website 数据库
|
| | |
|
| | | createThread_utilTable(pool,recreate); //创建线程控制表
|
| | | |
| | | createPositiomapUsr_Table(pool,recreate); //创建首页上用户中心点设置表
|
| | | |
| | | createChartColor_Table(pool,recreate); //创建用户实时监测页面柱体颜色设置表
|
| | | |
| | | createUserChart_Table(pool,recreate); //创建班组管理表
|
| | | |
| | | createProcessSurvey_Table(pool,recreate); //创建线程监控表
|
| | | }
|
| | |
|
| | | //创建 web_site 数据库
|
| | | public static void createWeb_siteDB(MysqlConnPool pool) {
|
| | | Sql_Mysql sql = new Sql_Mysql(pool.getConn());
|
| | | try {
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 创建线程手动启动工具表
|
| | | */
|
| | | public static void createThread_utilTable(MysqlConnPool pool, boolean recreate) {
|
| | | String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.ThreadUtil_Table;
|
| | | String sql_str02 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.ThreadUtil_Table + " (" +
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 创建用户地图中心点位置表
|
| | | */
|
| | | public static void createPositiomapUsr_Table(MysqlConnPool pool, boolean recreate) {
|
| | | String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.PositiomapUsr_Table;
|
| | | String sql_str02 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.PositiomapUsr_Table + " (" + |
| | | " `num` int(11) NOT NULL AUTO_INCREMENT," + |
| | | " `map_longitude` float NOT NULL DEFAULT '116.405'," + |
| | | " `map_latitude` float NOT NULL DEFAULT '39.9149'," + |
| | | " `map_level` int(11) NOT NULL DEFAULT '10'," + |
| | | " `uid` int(11) NOT NULL DEFAULT '1002'," + |
| | | " `note` varchar(64) NOT NULL DEFAULT '保留'," + |
| | | " PRIMARY KEY (`num`)," + |
| | | " UNIQUE KEY `index_uid` (`uid`)" + |
| | | ") ENGINE=InnoDB AUTO_INCREMENT=62 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();
|
| | | }
|
| | | }
|
| | | |
| | | /**
|
| | | * 创建用户实时监测页面柱体颜色设置表
|
| | | */
|
| | | public static void createChartColor_Table(MysqlConnPool pool, boolean recreate) {
|
| | | String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.ChartColor_Table;
|
| | | String sql_str02 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.ChartColor_Table + " (" + |
| | | " `num` int(11) NOT NULL AUTO_INCREMENT," + |
| | | " `uid` int(11) NOT NULL DEFAULT '1001'," + |
| | | " `max_color` varchar(64) NOT NULL DEFAULT 'red'," + |
| | | " `min_color` varchar(64) NOT NULL DEFAULT 'green'," + |
| | | " `normal_color` varchar(64) NOT NULL DEFAULT '#5986BF'," + |
| | | " `change_color` varchar(64) NOT NULL DEFAULT '#BFA0D1'," + |
| | | " `warn_color` varchar(64) NOT NULL DEFAULT '#ffff00'," + |
| | | " `note` varchar(64) NOT NULL DEFAULT ''," + |
| | | " PRIMARY KEY (`num`)," + |
| | | " UNIQUE KEY `index_uid` (`uid`)" + |
| | | ") 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();
|
| | | }
|
| | | }
|
| | | /**
|
| | | * 创建班组管理表
|
| | | */
|
| | | public static void createUserChart_Table(MysqlConnPool pool, boolean recreate) {
|
| | | String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.UserChart_Table;
|
| | | String sql_str02 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.UserChart_Table + " (" + |
| | | " `num` int(11) NOT NULL AUTO_INCREMENT," + |
| | | " `chart_name` varchar(64) NOT NULL DEFAULT '铁塔'," + |
| | | " `chart_file` varchar(64) NOT NULL DEFAULT 'whyc'," + |
| | | " `chart_logo` blob," + //首页logo
|
| | | " `chart_normal` blob," + //正常logo
|
| | | " `chart_behind` blob," + //落后logo
|
| | | " `chart_warn` blob," + //告警logo
|
| | | " `chart_timeout` blob," + //延迟logo
|
| | | " `chart_online_charge` blob," + //在线充电
|
| | | " `chart_pre_charge` blob," + //预充电logo
|
| | | " `chart_dev_alarm` blob," + //设备告警
|
| | | " `chart_nuclear_cap` blob," + //核容放电 |
| | | " `Chart_poff` blob," + //停电logo
|
| | | " `Chart_install` blob," + //未安装logo
|
| | | " `Chart_xuhang` blob," + //续航不足logo
|
| | | " PRIMARY KEY (`num`)," +
|
| | | " UNIQUE KEY `unique_index_chart_file` (`chart_file`)" + //添加唯一索引 |
| | | ") 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); |
| | | //添加在线充电列
|
| | | res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
|
| | | + " WHERE table_schema='web_site'"
|
| | | + " AND table_name='tb_user_chart'"
|
| | | + " AND column_name='chart_online_charge'");
|
| | | if(false == res.next()) {
|
| | | sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.UserChart_Table |
| | | + " ADD COLUMN `chart_online_charge` blob");
|
| | | }
|
| | | //添加预充电列
|
| | | res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
|
| | | + " WHERE table_schema='web_site'"
|
| | | + " AND table_name='tb_user_chart'"
|
| | | + " AND column_name='chart_pre_charge'");
|
| | | if(false == res.next()) {
|
| | | sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.UserChart_Table |
| | | + " ADD COLUMN `chart_pre_charge` blob");
|
| | | }
|
| | | //添加设备告警列
|
| | | res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
|
| | | + " WHERE table_schema='web_site'"
|
| | | + " AND table_name='tb_user_chart'"
|
| | | + " AND column_name='chart_dev_alarm'");
|
| | | if(false == res.next()) {
|
| | | sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.UserChart_Table |
| | | + " ADD COLUMN `chart_dev_alarm` blob");
|
| | | }
|
| | | //添加核容放电列
|
| | | res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
|
| | | + " WHERE table_schema='web_site'"
|
| | | + " AND table_name='tb_user_chart'"
|
| | | + " AND column_name='chart_nuclear_cap'");
|
| | | if(false == res.next()) {
|
| | | sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.UserChart_Table |
| | | + " ADD COLUMN `chart_nuclear_cap` blob");
|
| | | }
|
| | | //添加停电列
|
| | | res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
|
| | | + " WHERE table_schema='web_site'"
|
| | | + " AND table_name='tb_user_chart'"
|
| | | + " AND column_name='Chart_poff'");
|
| | | if(false == res.next()) {
|
| | | sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.UserChart_Table |
| | | + " ADD COLUMN `Chart_poff` blob");
|
| | | }
|
| | | //添加未安装列
|
| | | res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
|
| | | + " WHERE table_schema='web_site'"
|
| | | + " AND table_name='tb_user_chart'"
|
| | | + " AND column_name='Chart_install'");
|
| | | if(false == res.next()) {
|
| | | sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.UserChart_Table |
| | | + " ADD COLUMN `Chart_install` blob");
|
| | | }
|
| | | //添加续航不足列
|
| | | res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
|
| | | + " WHERE table_schema='web_site'"
|
| | | + " AND table_name='tb_user_chart'"
|
| | | + " AND column_name='Chart_xuhang'");
|
| | | if(false == res.next()) {
|
| | | sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.UserChart_Table |
| | | + " ADD COLUMN `Chart_xuhang` blob");
|
| | | }
|
| | | } catch (SQLException e) {
|
| | | e.printStackTrace();
|
| | | } finally {
|
| | | sql.close_con();
|
| | | }
|
| | | }
|
| | | |
| | | /**
|
| | | * 创建线程监控表
|
| | | */
|
| | | public static void createProcessSurvey_Table(MysqlConnPool pool, boolean recreate) {
|
| | | String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.ProcessSurvey_Table;
|
| | | String sql_str02 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.ProcessSurvey_Table + " (" + |
| | | " `num` int(11) NOT NULL AUTO_INCREMENT," + |
| | | " `ProcessId` int(12) NOT NULL," + //进程id
|
| | | " `ProcessName` varchar(64) NOT NULL DEFAULT ' '," + //进程名称
|
| | | " `ProcessTime` datetime NOT NULL DEFAULT '1970-01-01 00:00:00'," + //进程运行更新时间
|
| | | " `Process_starttime` datetime NOT NULL DEFAULT '1970-01-01 00:00:00'," + //进程开始启动时间
|
| | | " `ServerName` varchar(64) NOT NULL DEFAULT ' '," + //服务名称
|
| | | " `ServerFlag` int(11) NOT NULL DEFAULT '1'," + //服务状态 0:停止 1:正在运行 2禁用
|
| | | " `ProcessVersion` varchar(64) DEFAULT ' '," + //进程版本
|
| | | " `note` varchar(64) NOT NULL DEFAULT ' '," + //备注
|
| | | " `OutTime` int(11) NOT NULL DEFAULT '60'," + //超时时长
|
| | | " PRIMARY KEY (`num`)," + |
| | | " UNIQUE KEY `ProcessId` (`ProcessId`)" + |
| | | ") ENGINE=InnoDB AUTO_INCREMENT=11 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 "+ Sql_Mysql.ProcessSurvey_Table + " WHERE ProcessId = 11001");
|
| | | if(false == res.next()) { |
| | | sql.sqlMysqlExecute("INSERT INTO " + Sql_Mysql.ProcessSurvey_Table + " VALUES ('1', '11001', 'BMS_FBSDEV', '1970-01-01 00:00:00', '1970-01-01 00:00:00', 'BMS_FBSDEV', '1', 'V1.585', '主程序线程', '300');");
|
| | | }
|
| | | //添加电池告警进程记录
|
| | | res = sql.sqlMysqlQuery("SELECT * FROM "+ Sql_Mysql.ProcessSurvey_Table + " WHERE ProcessId = 11002");
|
| | | if(false == res.next()) { |
| | | sql.sqlMysqlExecute("INSERT INTO " + Sql_Mysql.ProcessSurvey_Table + " VALUES ('2', '11002', 'BMS_FBSDEV_ALARM_BATT', '1970-01-01 00:00:00', '1970-01-01 00:00:00', 'BMS_FBSDEV_ALARM', '1', 'V1.109', '电池告警线程', '300');");
|
| | | }
|
| | | //添加设备告警进程记录
|
| | | res = sql.sqlMysqlQuery("SELECT * FROM "+ Sql_Mysql.ProcessSurvey_Table + " WHERE ProcessId = 11003");
|
| | | if(false == res.next()) { |
| | | sql.sqlMysqlExecute("INSERT INTO " + Sql_Mysql.ProcessSurvey_Table + " VALUES ('3', '11003', 'BMS_FBSDEV_ALARM_DEV', '1970-01-01 00:00:00', '1970-01-01 00:00:00', 'BMS_FBSDEV_ALARM', '1', 'V1.109', '设备告警线程', '300');");
|
| | | }
|
| | | //添加落后单体进程记录
|
| | | res = sql.sqlMysqlQuery("SELECT * FROM "+ Sql_Mysql.ProcessSurvey_Table + " WHERE ProcessId = 11004");
|
| | | if(false == res.next()) {
|
| | | sql.sqlMysqlExecute("INSERT INTO " + Sql_Mysql.ProcessSurvey_Table + " VALUES ('4', '11004', 'BMS_FBSDEV_BADBATT_MON', '1970-01-01 00:00:00', '1970-01-01 00:00:00', 'BMS_FBSDEV_BADBATT', '1', 'v2.303', '落后单体线程', '300');");
|
| | | }
|
| | | //添加容量告警进程记录
|
| | | res = sql.sqlMysqlQuery("SELECT * FROM "+ Sql_Mysql.ProcessSurvey_Table + " WHERE ProcessId = 11005");
|
| | | if(false == res.next()) { |
| | | sql.sqlMysqlExecute("INSERT INTO " + Sql_Mysql.ProcessSurvey_Table + " VALUES ('5', '11005', 'BMS_FBSDEV_BADBATT_CAP', '1970-01-01 00:00:00', '1970-01-01 00:00:00', 'BMS_FBSDEV_BADBATT', '1', 'v2.303', '容量告警线程', '300');");
|
| | | }
|
| | | //添加放电计划进程记录
|
| | | res = sql.sqlMysqlQuery("SELECT * FROM "+ Sql_Mysql.ProcessSurvey_Table + " WHERE ProcessId = 11006");
|
| | | if(false == res.next()) {
|
| | | sql.sqlMysqlExecute("INSERT INTO " + Sql_Mysql.ProcessSurvey_Table + " VALUES ('6', '11006', 'BMS_FBSDEV_PLAN', '1970-01-01 00:00:00', '1970-01-01 00:00:00', 'BMS_FBSDEV_PLAN', '2', ' ', '放电计划线程', '300');");
|
| | | }
|
| | | //添加机房停电进程记录
|
| | | res = sql.sqlMysqlQuery("SELECT * FROM "+ Sql_Mysql.ProcessSurvey_Table + " WHERE ProcessId = 11007");
|
| | | if(false == res.next()) {
|
| | | sql.sqlMysqlExecute("INSERT INTO " + Sql_Mysql.ProcessSurvey_Table + " VALUES ('7', '11007', 'BMS_FBSDEV_POWER_FAIL', '1970-01-01 00:00:00', '1970-01-01 00:00:00', 'BMS_FBSDEV_POWER_FAIL', '2', ' ', '机房停电线程', '300');");
|
| | | }
|
| | | //添加线程监控进程记录
|
| | | res = sql.sqlMysqlQuery("SELECT * FROM "+ Sql_Mysql.ProcessSurvey_Table + " WHERE ProcessId = 11008");
|
| | | if(false == res.next()) {
|
| | | sql.sqlMysqlExecute("INSERT INTO " + Sql_Mysql.ProcessSurvey_Table + " VALUES ('8', '11008', 'BMS_FBSDEV_LISTEN', '1970-01-01 00:00:00', '1970-01-01 00:00:00', 'BMS_FBSDEV_LISTEN', '1', 'V1.101', '线程监控线程', '300');");
|
| | | }
|
| | | //添加61850进程记录
|
| | | res = sql.sqlMysqlQuery("SELECT * FROM "+ Sql_Mysql.ProcessSurvey_Table + " WHERE ProcessId = 11009");
|
| | | if(false == res.next()) {
|
| | | sql.sqlMysqlExecute("INSERT INTO " + Sql_Mysql.ProcessSurvey_Table + " VALUES ('9', '11009', 'BMS_FBS61850_BATT', '1970-01-01 00:00:00', '1970-01-01 00:00:00', 'BMS_FBS61850_BATT', '2', 'V1.101', '61850通讯线程', '300');");
|
| | | }
|
| | | //添加9600进程记录
|
| | | res = sql.sqlMysqlQuery("SELECT * FROM "+ Sql_Mysql.ProcessSurvey_Table + " WHERE ProcessId = 11010");
|
| | | if(false == res.next()) {
|
| | | sql.sqlMysqlExecute("INSERT INTO " + Sql_Mysql.ProcessSurvey_Table + " VALUES ('10', '11010', 'BMS_FBS9600_DISPLAY', '1970-01-01 00:00:00', '1970-01-01 00:00:00', 'BMS_FBS9600_DISPLAY', '2', 'v1.101', '9600显示模块线程', '300');");
|
| | | }
|
| | | |
| | | } catch (SQLException e) {
|
| | | e.printStackTrace();
|
| | | } finally {
|
| | | sql.close_con();
|
| | | }
|
| | | }
|
| | | |
| | | public static void main(String[] args) {
|
| | | MysqlConnPool pool = new MysqlConnPool("123.207.82.239", 3360, 10);
|
| | | DB_web_site website = new DB_web_site();
|