| | |
| | | package com.database_util;
|
| | |
|
| | | import java.sql.ResultSet;
|
| | | import java.sql.SQLException;
|
| | |
|
| | | import com.sql.MysqlConnPool;
|
| | | import com.sql.Sql_Mysql;
|
| | |
|
| | | public class DB_web_site {
|
| | | |
| | | |
| | | public static void init(MysqlConnPool pool, boolean recreate) {
|
| | | createWeb_siteDB(pool); //创建website 数据库
|
| | | |
| | | createThread_utilTable(pool,recreate); //创建线程控制表
|
| | | |
| | | createPositiomapUsr_Table(pool,recreate); //创建首页上用户中心点设置表
|
| | | |
| | | createChartColor_Table(pool,recreate); //创建用户实时监测页面柱体颜色设置表
|
| | | |
| | | createUserChart_Table(pool,recreate); //创建班组管理表
|
| | | |
| | | createProcessSurvey_Table(pool,recreate); //创建线程监控表
|
| | | |
| | | createEchartsUsr_Table(pool,recreate); //创建首页饼状图定制表
|
| | | |
| | | createDevstateUsr_Table(pool, recreate); //创建用户放电记录表
|
| | | |
| | | createCustomPage_Table(pool,recreate); //创建导航数据表
|
| | | |
| | | createAnnounce_Table(pool, recreate); //创建公告表
|
| | | |
| | | createBattAttention_Table(pool, recreate); //创建电池组单体关注表
|
| | | |
| | | createBattpowerOff_Table(pool,recreate); //创建机房停电表
|
| | | |
| | | createBadbattMon_Table(pool, recreate); //创建落后单体表
|
| | | |
| | | createBadbattMonFlag_Table(pool, recreate); //创建落后单体帮助控制表
|
| | | |
| | | createBattEndurance_Table(pool, recreate); //创建机房续航
|
| | | |
| | | createBattParamLow_Table(pool, recreate); //创建各种续航表
|
| | | |
| | | createBattDischargeParam_Table(pool, recreate); //创建放电计划参数表
|
| | | |
| | | createBattDischargePlan_Table(pool, recreate); //创建放电计划表
|
| | | |
| | | createAvoid_plan_Table_Table(pool, recreate); //创建放电计划规避时间表
|
| | | |
| | | createBattMapInformation_Table(pool, recreate); //创建基站定位表
|
| | | |
| | | createBattDischarge_Table(pool,recreate); //创建基站故障表
|
| | | |
| | | createBattReplace_Table(pool,recreate); //创建机房电池组更换记录表
|
| | | |
| | | createDev_Restart_PlanTable(pool,recreate); //创建设备重启计划表
|
| | | |
| | | createVip_User_Table(pool, recreate); //创建超级用户表以及添加vip用户
|
| | | |
| | | createLicense_Table(pool, recreate); //创建超级用户表以及添加vip用户
|
| | | |
| | | createDatabase_Backup_Table(pool, recreate); //创建数据库备份表
|
| | | }
|
| | | |
| | |
|
| | | /**
|
| | | * 创建 web_site 数据库
|
| | | * @param pool
|
| | | */
|
| | | public static void createWeb_siteDB(MysqlConnPool pool) {
|
| | | Sql_Mysql sql = new Sql_Mysql(pool.getConn());
|
| | | try {
|
| | | sql.sqlMysqlExecute("CREATE DATABASE IF NOT EXISTS " + Sql_Mysql.WEB_Site);
|
| | | } catch (SQLException e) {
|
| | | e.printStackTrace();
|
| | | } finally {
|
| | | sql.close_con();
|
| | | }
|
| | | }
|
| | | |
| | | /**
|
| | | * 创建线程手动启动工具表
|
| | | */
|
| | | 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 + " (" + |
| | | " `num` bigint(20) NOT NULL," + |
| | | " `thread_id` int(11) NOT NULL COMMENT '线程id'," + |
| | | " `thread_name` varchar(64) NOT NULL DEFAULT '线程名称'," + |
| | | " `thread_starttime` datetime NOT NULL DEFAULT '1970-01-01 00:00:00'," + |
| | | " `thread_en` int(11) NOT NULL DEFAULT '0' COMMENT '是否启动标识位 0:默认 1:需要启动 2:运行完成'," + |
| | | " `note` varchar(256) NOT NULL DEFAULT ''," +
|
| | | " UNIQUE KEY `unindex_thread_id` (`thread_id`)," + |
| | | " PRIMARY KEY (`num`)" + |
| | | ") ENGINE=InnoDB DEFAULT CHARSET=utf8;";
|
| | | Sql_Mysql sql = new Sql_Mysql(pool.getConn());
|
| | | ResultSet rs = null;
|
| | | try {
|
| | | if(true == recreate) { |
| | | sql.sqlMysqlExecute(sql_str01);
|
| | | }
|
| | | sql.sqlMysqlExecute(sql_str02);
|
| | | rs = sql.sqlMysqlQuery("SELECT * from web_site.tb_thread_util WHERE thread_id = 2019001");
|
| | | if(false == rs.next()) { |
| | | sql.sqlMysqlExecute("INSERT INTO " + Sql_Mysql.ThreadUtil_Table + " VALUES ('1', '2019001', '机房续航线程', '2019-01-08 10:44:28', '0', '')"); //添加机房续航线程的控制记录
|
| | | }
|
| | | rs = sql.sqlMysqlQuery("SELECT * from web_site.tb_thread_util WHERE thread_id = 2019002");
|
| | | if(false == rs.next()) { |
| | | sql.sqlMysqlExecute("INSERT INTO " + Sql_Mysql.ThreadUtil_Table + " VALUES ('2', '2019002', '落后单体线程', '2019-01-08 10:44:28', '0', '')"); //添加机房续航线程的控制记录
|
| | | }
|
| | | |
| | | } catch (SQLException e) {
|
| | | e.printStackTrace();
|
| | | } finally {
|
| | | sql.close_con();
|
| | | }
|
| | | }
|
| | | |
| | | /**
|
| | | * 创建用户地图中心点位置表
|
| | | */
|
| | | 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=1 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 + "(ProcessId,ProcessName,ProcessTime,Process_starttime,ServerName,ServerFlag,ProcessVersion,note,OutTime) VALUES ('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 + "(ProcessId,ProcessName,ProcessTime,Process_starttime,ServerName,ServerFlag,ProcessVersion,note,OutTime) VALUES ('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 + "(ProcessId,ProcessName,ProcessTime,Process_starttime,ServerName,ServerFlag,ProcessVersion,note,OutTime) VALUES ('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 + "(ProcessId,ProcessName,ProcessTime,Process_starttime,ServerName,ServerFlag,ProcessVersion,note,OutTime) VALUES ('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 + "(ProcessId,ProcessName,ProcessTime,Process_starttime,ServerName,ServerFlag,ProcessVersion,note,OutTime) VALUES ('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 + "(ProcessId,ProcessName,ProcessTime,Process_starttime,ServerName,ServerFlag,ProcessVersion,note,OutTime) VALUES ('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 + "(ProcessId,ProcessName,ProcessTime,Process_starttime,ServerName,ServerFlag,ProcessVersion,note,OutTime) VALUES ('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 + "(ProcessId,ProcessName,ProcessTime,Process_starttime,ServerName,ServerFlag,ProcessVersion,note,OutTime) VALUES ('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 + "(ProcessId,ProcessName,ProcessTime,Process_starttime,ServerName,ServerFlag,ProcessVersion,note,OutTime) VALUES ('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 + "(ProcessId,ProcessName,ProcessTime,Process_starttime,ServerName,ServerFlag,ProcessVersion,note,OutTime) VALUES ('11010', 'BMS_FBS9600_DISPLAY', '1970-01-01 00:00:00', '1970-01-01 00:00:00', 'BMS_FBS9600_DISPLAY', '2', 'v1.101', '9600显示模块线程', '300');");
|
| | | }
|
| | | //添加FBS汇集器通讯进程记录
|
| | | res = sql.sqlMysqlQuery("SELECT * FROM "+ Sql_Mysql.ProcessSurvey_Table + " WHERE ProcessId = 11011");
|
| | | if(false == res.next()) {
|
| | | sql.sqlMysqlExecute("INSERT INTO " + Sql_Mysql.ProcessSurvey_Table + "(ProcessId,ProcessName,ProcessTime,Process_starttime,ServerName,ServerFlag,ProcessVersion,note,OutTime) VALUES ('11011', 'BMS_FBS_CONCENTRATOR', '1970-01-01 00:00:00', '1970-01-01 00:00:00', 'BMS_FBS_CONCENTRATOR', '2', 'v1.101', 'FBS汇集器通讯线程', '300');");
|
| | | }
|
| | | //添加9度通讯线程
|
| | | res = sql.sqlMysqlQuery("SELECT * FROM "+ Sql_Mysql.ProcessSurvey_Table + " WHERE ProcessId = 11012");
|
| | | if(false == res.next()) {
|
| | | sql.sqlMysqlExecute(" INSERT INTO " + Sql_Mysql.ProcessSurvey_Table + "(ProcessId,ProcessName,ProcessTime,Process_starttime,ServerName,ServerFlag,ProcessVersion,note,OutTime) VALUES ('11012', 'BMS_LD9_MONITOR', '1970-01-01 00:00:00', '1970-01-01 00:00:00', 'BMS_LD9_MONITOR', '2', 'v1.101', '9度设备通讯线程', '300');");
|
| | | }
|
| | | |
| | | //添加6度通讯线程
|
| | | res = sql.sqlMysqlQuery("SELECT * FROM "+ Sql_Mysql.ProcessSurvey_Table + " WHERE ProcessId = 11013");
|
| | | if(false == res.next()) {
|
| | | sql.sqlMysqlExecute(" INSERT INTO " + Sql_Mysql.ProcessSurvey_Table + "(ProcessId,ProcessName,ProcessTime,Process_starttime,ServerName,ServerFlag,ProcessVersion,note,OutTime) VALUES ('11013', 'BMS_LD6_MONITOR', '1970-01-01 00:00:00', '1970-01-01 00:00:00', 'BMS_LD6_MONITOR', '2', 'v1.101', '6度设备通讯线程', '300');");
|
| | | }
|
| | | //添加BTS续航统计线程
|
| | | res = sql.sqlMysqlQuery("SELECT * FROM "+ Sql_Mysql.ProcessSurvey_Table + " WHERE ProcessId = 11014");
|
| | | if(false == res.next()) {
|
| | | sql.sqlMysqlExecute(" INSERT INTO " + Sql_Mysql.ProcessSurvey_Table + "(ProcessId,ProcessName,ProcessTime,Process_starttime,ServerName,ServerFlag,ProcessVersion,note,OutTime) VALUES ('11014', 'BMS_BTS_ENDURANCE', '1970-01-01 00:00:00', '1970-01-01 00:00:00', 'BMS_BTS_ENDURANCE', '2', 'v1.101', 'BTS续航统计线程', '300');");
|
| | | }
|
| | | //添加通信电源通讯
|
| | | res = sql.sqlMysqlQuery("SELECT * FROM "+ Sql_Mysql.ProcessSurvey_Table + " WHERE ProcessId = 11015");
|
| | | if(false == res.next()) {
|
| | | sql.sqlMysqlExecute(" INSERT INTO " + Sql_Mysql.ProcessSurvey_Table + "(ProcessId,ProcessName,ProcessTime,Process_starttime,ServerName,ServerFlag,ProcessVersion,note,OutTime) VALUES ('11015', 'BMS_COMM_POWER', '1970-01-01 00:00:00', '1970-01-01 00:00:00', 'BMS_COMM_POWER', '2', 'v1.101', '通信电源通讯线程', '300');");
|
| | | }
|
| | | //添加通信电源通讯
|
| | | res = sql.sqlMysqlQuery("SELECT * FROM "+ Sql_Mysql.ProcessSurvey_Table + " WHERE ProcessId = 11016");
|
| | | if(false == res.next()) {
|
| | | sql.sqlMysqlExecute(" INSERT INTO " + Sql_Mysql.ProcessSurvey_Table + "(ProcessId,ProcessName,ProcessTime,Process_starttime,ServerName,ServerFlag,ProcessVersion,note,OutTime) VALUES ('11016', 'BMS_POWER_MONITOR', '1970-01-01 00:00:00', '1970-01-01 00:00:00', 'BMS_POWER_MONITOR', '2', 'v1.100', '通信电源监控线程', '300');");
|
| | | }
|
| | | //蓄电池负载更新线程
|
| | | res = sql.sqlMysqlQuery("SELECT * FROM "+ Sql_Mysql.ProcessSurvey_Table + " WHERE ProcessId = 11017");
|
| | | if(false == res.next()) {
|
| | | sql.sqlMysqlExecute(" INSERT INTO " + Sql_Mysql.ProcessSurvey_Table + "(ProcessId,ProcessName,ProcessTime,Process_starttime,ServerName,ServerFlag,ProcessVersion,note,OutTime) VALUES ('11017', 'BMS_BATT_LOADUPDATE', '1970-01-01 00:00:00', '1970-01-01 00:00:00', 'BMS_BATT_LOADUPDATE', '1', 'v1.100', '蓄电池负载更新线程', '300');");
|
| | | }
|
| | | //充放电一体机通讯线程
|
| | | res = sql.sqlMysqlQuery("SELECT * FROM "+ Sql_Mysql.ProcessSurvey_Table + " WHERE ProcessId = 11018");
|
| | | if(false == res.next()) {
|
| | | sql.sqlMysqlExecute(" INSERT INTO " + Sql_Mysql.ProcessSurvey_Table + "(ProcessId,ProcessName,ProcessTime,Process_starttime,ServerName,ServerFlag,ProcessVersion,note,OutTime) VALUES ('11018', 'BMS_BATT_FGCD_A059', '1970-01-01 00:00:00', '1970-01-01 00:00:00', 'BMS_BATT_FGCD_A059', '1', 'v1.100', '充放电一体机通讯线程', '300');");
|
| | | }
|
| | | } catch (SQLException e) {
|
| | | e.printStackTrace();
|
| | | } finally {
|
| | | sql.close_con();
|
| | | }
|
| | | }
|
| | | |
| | | /**
|
| | | * 创建用户首页饼状图定制页面
|
| | | */
|
| | | public static void createEchartsUsr_Table(MysqlConnPool pool, boolean recreate) {
|
| | | String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.EchartsUsr_Table;
|
| | | String sql_str02 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.EchartsUsr_Table + " (" + |
| | | " `num` int(11) NOT NULL AUTO_INCREMENT," + |
| | | " `uid` int(11) NOT NULL DEFAULT '1002'," + |
| | | " `echarts1_enable` int(11) NOT NULL DEFAULT '1'," + |
| | | " `echarts2_enable` int(11) NOT NULL DEFAULT '1'," + |
| | | " `echarts3_enable` int(11) NOT NULL DEFAULT '1'," + |
| | | " `echarts4_enable` int(11) NOT NULL DEFAULT '1'," + |
| | | " `echarts5_enable` int(11) NOT NULL DEFAULT '0'," + |
| | | " `echarts6_enable` int(11) NOT NULL DEFAULT '0'," + |
| | | " `echarts7_enable` int(11) NOT NULL DEFAULT '0'," + |
| | | " `echarts8_enable` int(11) NOT NULL DEFAULT '0'," + |
| | | " `echarts9_enable` int(11) NOT NULL DEFAULT '0'," + |
| | | " `echarts10_enable` int(11) NOT NULL DEFAULT '0'," + |
| | | " `note` varchar(64) NOT NULL DEFAULT ''," + |
| | | " PRIMARY KEY (`num`)," + |
| | | " UNIQUE KEY `uid_index` (`uid`)" + |
| | | ") 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();
|
| | | }
|
| | | }
|
| | | |
| | | /**
|
| | | * 创建用户放电添加记录表
|
| | | */
|
| | | public static void createDevstateUsr_Table(MysqlConnPool pool, boolean recreate) {
|
| | | String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.DevstateUsr_Table;
|
| | | String sql_str02 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.DevstateUsr_Table + " (" + |
| | | " `num` int(11) NOT NULL AUTO_INCREMENT," + |
| | | " `uid` int(11) NOT NULL DEFAULT '1001'," + |
| | | " `dev_id` int(11) NOT NULL DEFAULT '910000001'," + |
| | | " `battgroupid` int(11) NOT NULL DEFAULT '1000001'," + |
| | | " `note` varchar(64) NOT NULL DEFAULT ' '," + |
| | | " `batt_index` int(11) NOT NULL DEFAULT '0'," + |
| | | " `stationname` varchar(64) NOT NULL DEFAULT ''," + |
| | | " `battgroupname` varchar(64) NOT NULL DEFAULT ''," + |
| | | " PRIMARY KEY (`num`)" + |
| | | ") 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); |
| | | |
| | | //清空添加过放电记录中的机房修改过机房名称的记录
|
| | | sql.sqlMysqlExecute(" DELETE FROM "+ Sql_Mysql.DevstateUsr_Table +" WHERE BattGroupId not in ( " + |
| | | " SELECT DISTINCT(BattGroupId) FROM " +Sql_Mysql.BattInf_Table +
|
| | | " ) ");
|
| | | |
| | | } catch (SQLException e) {
|
| | | e.printStackTrace();
|
| | | } finally {
|
| | | sql.close_con();
|
| | | }
|
| | | }
|
| | | /**
|
| | | * 创建导航数据表
|
| | | */
|
| | | public static void createCustomPage_Table(MysqlConnPool pool, boolean recreate) {
|
| | | String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.CustomPage_Table;
|
| | | String sql_str02 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.CustomPage_Table + " (" + |
| | | " `Num` int(11) NOT NULL AUTO_INCREMENT," + |
| | | " `Navigate` varchar(64) COLLATE utf8_unicode_ci DEFAULT NULL," + |
| | | " `Navigate_order` int(11) DEFAULT NULL," + |
| | | " `Submenu` varchar(64) COLLATE utf8_unicode_ci DEFAULT NULL," + |
| | | " `Subflag` int(11) DEFAULT NULL," + |
| | | " `Sublink` varchar(64) COLLATE utf8_unicode_ci DEFAULT NULL," + |
| | | " `SubEnable` int(11) DEFAULT NULL," + |
| | | " `SubName` varchar(64) COLLATE utf8_unicode_ci DEFAULT NULL," + |
| | | " `Subjudge` int(11) DEFAULT NULL," + |
| | | " `page_order` int(11) NOT NULL DEFAULT '0'," + |
| | | " PRIMARY KEY (`Num`)" + |
| | | ") ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;";
|
| | | 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_custompage'"
|
| | | + " AND column_name='page_order'");
|
| | | if(false == res.next()) {
|
| | | sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.CustomPage_Table |
| | | + " ADD COLUMN `page_order` int(11) NOT NULL DEFAULT '0';");
|
| | | }
|
| | | } catch (SQLException e) {
|
| | | e.printStackTrace();
|
| | | } finally {
|
| | | sql.close_con();
|
| | | }
|
| | | }
|
| | | /**
|
| | | * 创建公告表
|
| | | */
|
| | | public static void createAnnounce_Table(MysqlConnPool pool, boolean recreate) {
|
| | | String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.Announce_Table;
|
| | | String sql_str02 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.Announce_Table + " (" + |
| | | " `num` int(11) NOT NULL AUTO_INCREMENT," + |
| | | " `usr_id` int(11) DEFAULT NULL," + |
| | | " `announce_time` datetime DEFAULT NULL," + |
| | | " `message` varchar(1024) COLLATE utf8_unicode_ci DEFAULT NULL," + |
| | | " `note` varchar(16) COLLATE utf8_unicode_ci DEFAULT NULL," + |
| | | " PRIMARY KEY (`num`)" + |
| | | ") ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;";
|
| | | 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 createBattAttention_Table(MysqlConnPool pool, boolean recreate) {
|
| | | String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.BattAttention_Table;
|
| | | String sql_str02 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.BattAttention_Table + " (" + |
| | | " `num` int(11) NOT NULL AUTO_INCREMENT," + |
| | | " `BattGroupId` int(11) NOT NULL DEFAULT '0'," + |
| | | " `MonNum` int(11) NOT NULL DEFAULT '0'," + |
| | | " `note` varchar(64) NOT NULL DEFAULT ' '," + |
| | | " `Uid` int(11) NOT NULL DEFAULT '1001'," + |
| | | " PRIMARY KEY (`num`)" + |
| | | ") 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();
|
| | | }
|
| | | }
|
| | | /**
|
| | | * 创建机房停电表
|
| | | */
|
| | | public static void createBattpowerOff_Table(MysqlConnPool pool, boolean recreate) {
|
| | | String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.BattpowerOff_Table;
|
| | | String sql_str02 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.BattpowerOff_Table + " (" + |
| | | " `num` int(11) NOT NULL AUTO_INCREMENT," + |
| | | " `dev_id` int(11) NOT NULL," + |
| | | " `record_count` int(11) NOT NULL DEFAULT '0'," + |
| | | " `poweroff_starttime` timestamp NOT NULL DEFAULT '1982-01-01 00:00:00'," + |
| | | " `poweroff_stoptime` timestamp NOT NULL DEFAULT '1982-01-01 00:00:00'," + |
| | | " `power_state` int(11) NOT NULL DEFAULT '0'," + |
| | | " `timelong` int(11) NOT NULL DEFAULT '0'," + |
| | | " `note` varchar(64) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL DEFAULT ''," + |
| | | " PRIMARY KEY (`num`)," + |
| | | " KEY `index_dev_id` (`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();
|
| | | }
|
| | | }
|
| | | /**
|
| | | * 创落后单体表
|
| | | */
|
| | | public static void createBadbattMon_Table(MysqlConnPool pool, boolean recreate) {
|
| | | String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.BadbattMon_Table;
|
| | | String sql_str02 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.BadbattMon_Table + " (" + |
| | | " `num` int(11) NOT NULL AUTO_INCREMENT," + |
| | | " `battgroupid` int(11) NOT NULL DEFAULT '0'," + |
| | | " `mon_num` int(11) NOT NULL DEFAULT '0'," + |
| | | " `record_num` int(11) NOT NULL DEFAULT '0'," + |
| | | " `test_starttime` datetime NOT NULL DEFAULT '1982-01-01 00:00:00'," + |
| | | " `group_vol` float NOT NULL DEFAULT '0'," + |
| | | " `test_curr` float NOT NULL DEFAULT '0'," + |
| | | " `mon_vol` float NOT NULL DEFAULT '0'," + |
| | | " `real_cap` float NOT NULL DEFAULT '0'," + |
| | | " `stdcap` float NOT NULL DEFAULT '0'," + |
| | | " `note` varchar(64) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL DEFAULT ' '," + |
| | | " PRIMARY KEY (`num`)," + |
| | | " KEY `index_num` (`battgroupid`)" + |
| | | ") 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();
|
| | | }
|
| | | }
|
| | | /**
|
| | | * 创落后单体控制表
|
| | | */
|
| | | public static void createBadbattMonFlag_Table(MysqlConnPool pool, boolean recreate) {
|
| | | String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.BadbattMonFlag_Table;
|
| | | String sql_str02 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.BadbattMonFlag_Table + " (" + |
| | | " `num` int(11) NOT NULL AUTO_INCREMENT," + |
| | | " `count` int(11) NOT NULL DEFAULT '0'," + |
| | | " PRIMARY KEY (`num`)" + |
| | | ") ENGINE=InnoDB AUTO_INCREMENT=7 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 createBattEndurance_Table(MysqlConnPool pool, boolean recreate) {
|
| | | String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.BattEndurance_Table;
|
| | | String sql_str02 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.BattEndurance_Table + " (" + |
| | | " `num` int(11) NOT NULL AUTO_INCREMENT," + |
| | | " `deviceid` int(11) NOT NULL DEFAULT '0' COMMENT '设备id'," + |
| | | " `stationid` varchar(64) NOT NULL DEFAULT '0' COMMENT '机房id'," + |
| | | " `real_cap` float NOT NULL DEFAULT '0' COMMENT '实际容量'," + |
| | | " `moncapstd` float NOT NULL DEFAULT '0' COMMENT '标称容量'," + |
| | | " `real_curr` float NOT NULL DEFAULT '0' COMMENT '实际电流'," + |
| | | " `endurance_theory_timelong` float NOT NULL DEFAULT '0' COMMENT '理论续航时长(分钟)'," + |
| | | " `endurance_actual_timelong` float NOT NULL DEFAULT '0' COMMENT '平均实际续航时长(分钟)'," + |
| | | " `endurance_actual_timelong_min` float NOT NULL DEFAULT '0' COMMENT '最小实际续航时长(分钟)'," + |
| | | " `endurance_actual_timelong_max` float NOT NULL DEFAULT '0' COMMENT '最大实际续航时长(分钟)'," + |
| | | " `is_out_stand` tinyint(4) NOT NULL DEFAULT '0' COMMENT '是否掉站'," + |
| | | " `note` varchar(64) NOT NULL DEFAULT '' COMMENT '备注'," + |
| | | " `real_cap_group1` float NOT NULL DEFAULT '0' COMMENT '电池组1实际容量'," + |
| | | " `real_cap_group2` float NOT NULL DEFAULT '0' COMMENT '电池组2实际容量'," + |
| | | " `real_cap_group3` float NOT NULL DEFAULT '0' COMMENT '电池组3实际容量'," + |
| | | " `real_cap_group4` float NOT NULL DEFAULT '0' COMMENT '电池组4实际容量'," + |
| | | " PRIMARY KEY (`num`)," + |
| | | " UNIQUE KEY `unique_index_deviceid` (`deviceid`)," + |
| | | " KEY `index_stationid` (`stationid`)" + |
| | | ") 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); |
| | | |
| | | /************************** 添加最大续航时长列 **************************************/
|
| | | String sql_str1 = " SELECT * FROM information_schema.columns "
|
| | | + " WHERE table_schema= 'web_site' "
|
| | | + " AND table_name='tb_batt_endurance' "
|
| | | + " AND column_name='endurance_actual_timelong_max'";
|
| | | //System.out.println(sql_str3);
|
| | | ResultSet rs = sql.sqlMysqlQuery(sql_str1);
|
| | | if(false == rs.next()) {
|
| | | sql.sqlMysqlExecute(" ALTER TABLE " + Sql_Mysql.BattEndurance_Table
|
| | | + " ADD COLUMN `endurance_actual_timelong_max` int(11) NOT NULL DEFAULT '0' COMMENT '最大实际续航时长(分钟)' AFTER `endurance_actual_timelong`;");
|
| | | }
|
| | | |
| | | /************************** 添加最小续航时长列 **************************************/
|
| | | String sql_str2 = " SELECT * FROM information_schema.columns "
|
| | | + " WHERE table_schema= 'web_site' "
|
| | | + " AND table_name='tb_batt_endurance' "
|
| | | + " AND column_name='endurance_actual_timelong_min'";
|
| | | //System.out.println(sql_str3);
|
| | | rs = sql.sqlMysqlQuery(sql_str2);
|
| | | if(false == rs.next()) {
|
| | | sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.BattEndurance_Table |
| | | + " ADD COLUMN `endurance_actual_timelong_min` int(11) NOT NULL DEFAULT '0' COMMENT '最小实际续航时长(分钟)' AFTER `endurance_actual_timelong`;");
|
| | | }
|
| | | |
| | | /************************** 添加 电池组1实际容量 **************************************/
|
| | | String sql_str3 = " SELECT * FROM information_schema.columns "
|
| | | + " WHERE table_schema= 'web_site' "
|
| | | + " AND table_name='tb_batt_endurance' "
|
| | | + " AND column_name='real_cap_group1'";
|
| | | //System.out.println(sql_str3);
|
| | | rs = sql.sqlMysqlQuery(sql_str3);
|
| | | if(false == rs.next()) {
|
| | | sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.BattEndurance_Table |
| | | + " ADD COLUMN `real_cap_group1` float NOT NULL DEFAULT '0' COMMENT '电池组1实际容量';");
|
| | | }
|
| | | /************************** 添加 电池组2实际容量 **************************************/
|
| | | String sql_str4 = " SELECT * FROM information_schema.columns "
|
| | | + " WHERE table_schema= 'web_site' "
|
| | | + " AND table_name='tb_batt_endurance' "
|
| | | + " AND column_name='real_cap_group2'";
|
| | | //System.out.println(sql_str3);
|
| | | rs = sql.sqlMysqlQuery(sql_str4);
|
| | | if(false == rs.next()) {
|
| | | sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.BattEndurance_Table |
| | | + " ADD COLUMN `real_cap_group2` float NOT NULL DEFAULT '0' COMMENT '电池组2实际容量';");
|
| | | }
|
| | | /************************** 添加 电池组3实际容量 **************************************/
|
| | | String sql_str5 = " SELECT * FROM information_schema.columns "
|
| | | + " WHERE table_schema= 'web_site' "
|
| | | + " AND table_name='tb_batt_endurance' "
|
| | | + " AND column_name='real_cap_group3'";
|
| | | //System.out.println(sql_str3);
|
| | | rs = sql.sqlMysqlQuery(sql_str5);
|
| | | if(false == rs.next()) {
|
| | | sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.BattEndurance_Table |
| | | + " ADD COLUMN `real_cap_group3` float NOT NULL DEFAULT '0' COMMENT '电池组3实际容量';");
|
| | | }
|
| | | /************************** 添加 电池组4实际容量 **************************************/
|
| | | String sql_str6 = " SELECT * FROM information_schema.columns "
|
| | | + " WHERE table_schema= 'web_site' "
|
| | | + " AND table_name='tb_batt_endurance' "
|
| | | + " AND column_name='real_cap_group4'";
|
| | | //System.out.println(sql_str3);
|
| | | rs = sql.sqlMysqlQuery(sql_str6);
|
| | | if(false == rs.next()) {
|
| | | sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.BattEndurance_Table |
| | | + " ADD COLUMN `real_cap_group4` float NOT NULL DEFAULT '0' COMMENT '电池组4实际容量';");
|
| | | }
|
| | | /************************** 添加 电池组的标称容量 **************************************/
|
| | | String sql_str7 = " SELECT * FROM information_schema.columns "
|
| | | + " WHERE table_schema= 'web_site' "
|
| | | + " AND table_name='tb_batt_endurance' "
|
| | | + " AND column_name='batts_moncapstd'";
|
| | | //System.out.println(sql_str3);
|
| | | rs = sql.sqlMysqlQuery(sql_str7);
|
| | | if(false == rs.next()) {
|
| | | sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.BattEndurance_Table |
| | | + " ADD COLUMN `batts_moncapstd` varchar(64) NOT NULL DEFAULT '' COMMENT '电池组的标称容量';");
|
| | | }
|
| | | /************************** 添加 电池组的核容时间 **************************************/
|
| | | String sql_str8 = " SELECT * FROM information_schema.columns "
|
| | | + " WHERE table_schema= 'web_site' "
|
| | | + " AND table_name='tb_batt_endurance' "
|
| | | + " AND column_name='batts_teststarttime'";
|
| | | rs = sql.sqlMysqlQuery(sql_str8);
|
| | | if(false == rs.next()) {
|
| | | sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.BattEndurance_Table |
| | | + " ADD COLUMN `batts_teststarttime` varchar(250) NOT NULL DEFAULT '' COMMENT '电池组的核容时间';");
|
| | | }
|
| | | /************************** 添加 电池组的组数 **************************************/
|
| | | String sql_str9 = " SELECT * FROM information_schema.columns "
|
| | | + " WHERE table_schema= 'web_site' "
|
| | | + " AND table_name='tb_batt_endurance' "
|
| | | + " AND column_name='groupcount'";
|
| | | rs = sql.sqlMysqlQuery(sql_str9);
|
| | | if(false == rs.next()) {
|
| | | sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.BattEndurance_Table |
| | | + " ADD COLUMN `groupcount` int NOT NULL DEFAULT '0' COMMENT '电池组的组数';");
|
| | | }
|
| | | } catch (SQLException e) {
|
| | | e.printStackTrace();
|
| | | } finally {
|
| | | sql.close_con();
|
| | | }
|
| | | }
|
| | | |
| | | /**
|
| | | * 创建各种阀值参数表
|
| | | */
|
| | | public static void createBattParamLow_Table(MysqlConnPool pool, boolean recreate) {
|
| | | String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.BattParamLow_Table;
|
| | | String sql_str02 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.BattParamLow_Table + " (" + |
| | | " `num` int(11) NOT NULL AUTO_INCREMENT," + |
| | | " `low_type` int(11) DEFAULT NULL," + |
| | | " `Low_nametype` int(11) DEFAULT NULL," + |
| | | " `Low_value` float DEFAULT NULL," + |
| | | " `low_method` int(11) DEFAULT NULL," + |
| | | " PRIMARY KEY (`num`)" + |
| | | ") ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;"; |
| | | Sql_Mysql sql = new Sql_Mysql(pool.getConn());
|
| | | try {
|
| | | if(true == recreate) { |
| | | sql.sqlMysqlExecute(sql_str01);
|
| | | sql.sqlMysqlExecute(sql_str02);
|
| | | }else {
|
| | | sql.sqlMysqlUseDB(Sql_Mysql.WEB_Site);
|
| | | if(sql.sqlMysqlCheckIfTableExist("tb_batt_param_low")) { |
| | | sql.sqlMysqlExecute("DELETE FROM " + Sql_Mysql.BattParamLow_Table);
|
| | | }
|
| | | sql.sqlMysqlExecute(sql_str02);
|
| | | }
|
| | | sql.sqlMysqlExecute("INSERT INTO "+Sql_Mysql.BattParamLow_Table+" VALUES ('1', '1', '0', '0.8', '1');");
|
| | | sql.sqlMysqlExecute("INSERT INTO "+Sql_Mysql.BattParamLow_Table+" VALUES ('2', '1', '1', '0.9', '1');");
|
| | | sql.sqlMysqlExecute("INSERT INTO "+Sql_Mysql.BattParamLow_Table+" VALUES ('3', '2', '0', '0.01', '0');");
|
| | | sql.sqlMysqlExecute("INSERT INTO "+Sql_Mysql.BattParamLow_Table+" VALUES ('4', '2', '1', '0.1', '0');");
|
| | | sql.sqlMysqlExecute("INSERT INTO "+Sql_Mysql.BattParamLow_Table+" VALUES ('5', '2', '2', '0.4', '0');");
|
| | | sql.sqlMysqlExecute("INSERT INTO "+Sql_Mysql.BattParamLow_Table+" VALUES ('6', '2', '3', '0.5', '0');");
|
| | | sql.sqlMysqlExecute("INSERT INTO "+Sql_Mysql.BattParamLow_Table+" VALUES ('7', '3', '2', '0.94', '1');");
|
| | | sql.sqlMysqlExecute("INSERT INTO "+Sql_Mysql.BattParamLow_Table+" VALUES ('8', '3', '3', '0.01', '1');");
|
| | | } catch (SQLException e) {
|
| | | e.printStackTrace();
|
| | | } finally {
|
| | | sql.close_con();
|
| | | }
|
| | | }
|
| | | |
| | | /**
|
| | | * 创建放电计划参数表
|
| | | */
|
| | | public static void createBattDischargeParam_Table(MysqlConnPool pool, boolean recreate) {
|
| | | String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.BattDischargeParam_Table;
|
| | | String sql_str02 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.BattDischargeParam_Table + " (" + |
| | | " `num` int(11) NOT NULL AUTO_INCREMENT," + |
| | | " `preset_time` int(11) DEFAULT NULL," + |
| | | " `preset_cap` float NOT NULL DEFAULT '0'," + |
| | | " `preset_monvol` float NOT NULL DEFAULT '0'," + |
| | | " `preset_groupvol` float NOT NULL DEFAULT '0'," + |
| | | " `note` varchar(64) COLLATE utf8_unicode_ci NOT NULL DEFAULT ' '," + |
| | | " `param_name` varchar(64) COLLATE utf8_unicode_ci DEFAULT NULL," + |
| | | " `preset_mon` int(11) NOT NULL DEFAULT '0'," + |
| | | " `preset_curr` float NOT NULL DEFAULT '0'," + |
| | | " `chargecurrset` float NOT NULL DEFAULT '0'," + |
| | | " `dcvolhighlimit` float NOT NULL DEFAULT '0'," + |
| | | " PRIMARY KEY (`num`)," + |
| | | " KEY `index_num` (`num`)" + |
| | | ") ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;"; |
| | | Sql_Mysql sql = new Sql_Mysql(pool.getConn());
|
| | | try {
|
| | | if(true == recreate) { |
| | | //sql.sqlMysqlExecute(sql_str01);
|
| | | //sql.sqlMysqlExecute(sql_str02);
|
| | | }else {
|
| | | |
| | | }
|
| | | sql.sqlMysqlExecute(sql_str02); //创建放电计划参数表
|
| | | } catch (SQLException e) {
|
| | | e.printStackTrace();
|
| | | } finally {
|
| | | sql.close_con();
|
| | | }
|
| | | }
|
| | | |
| | | /**
|
| | | * 创建放电计划表
|
| | | */
|
| | | public static void createBattDischargePlan_Table(MysqlConnPool pool, boolean recreate) {
|
| | | String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.BattDischargePlan_Table;
|
| | | String sql_str02 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.BattDischargePlan_Table + " (" + |
| | | " `num` int(11) NOT NULL AUTO_INCREMENT," + |
| | | " `battgroupid` int(11) NOT NULL DEFAULT '0'," + |
| | | " `discharge_starttime` timestamp NOT NULL DEFAULT '1982-01-01 00:00:00'," + |
| | | " `discharge_stoptime` timestamp NOT NULL DEFAULT '1982-01-01 00:00:00'," + |
| | | " `discharge_state` int(11) NOT NULL DEFAULT '0'," + |
| | | " `discharge_reason` varchar(128) COLLATE utf8_unicode_ci NOT NULL DEFAULT ''," + |
| | | " `note` varchar(64) COLLATE utf8_unicode_ci NOT NULL DEFAULT ''," + |
| | | " `discharge_cleartype` int(11) NOT NULL DEFAULT '1'," + |
| | | " `BattIndexInFbs` int(11) NOT NULL DEFAULT '0'," + |
| | | " `preset_time` int(11) NOT NULL DEFAULT '0'," + |
| | | " `preset_cap` float NOT NULL DEFAULT '0'," + |
| | | " `preset_monvol` float NOT NULL DEFAULT '0'," + |
| | | " `preset_groupvol` float NOT NULL DEFAULT '0'," + |
| | | " `preset_mon` int(11) NOT NULL DEFAULT '0'," + |
| | | " `preset_curr` float NOT NULL DEFAULT '0'," + |
| | | " `dcvolhighlimit` float NOT NULL DEFAULT '0'," + |
| | | " `chargecurrset` float NOT NULL DEFAULT '0'," + |
| | | " PRIMARY KEY (`num`)," + |
| | | " KEY `index_num` (`num`)" + |
| | | ") ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;"; |
| | | Sql_Mysql sql = new Sql_Mysql(pool.getConn());
|
| | | try {
|
| | | if(true == recreate) { |
| | | //sql.sqlMysqlExecute(sql_str01);
|
| | | //sql.sqlMysqlExecute(sql_str02);
|
| | | }else {
|
| | | }
|
| | | sql.sqlMysqlExecute(sql_str02); //创建放电计划表
|
| | | |
| | | //添加放电计划周期列
|
| | | ResultSet res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
|
| | | + " WHERE table_schema='web_site'"
|
| | | + " AND table_name='tb_battdischarge_plan'"
|
| | | + " AND column_name='plan_circle'");
|
| | | if(false == res.next()) {
|
| | | sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.BattDischargePlan_Table |
| | | + " ADD COLUMN `plan_circle` int NOT NULL DEFAULT '0';");
|
| | | }
|
| | | |
| | | //添加放电放电次数列
|
| | | res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
|
| | | + " WHERE table_schema='web_site'"
|
| | | + " AND table_name='tb_battdischarge_plan'"
|
| | | + " AND column_name='plan_rate'");
|
| | | if(false == res.next()) {
|
| | | sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.BattDischargePlan_Table |
| | | + " ADD COLUMN `plan_rate` int NOT NULL DEFAULT '0';");
|
| | | }
|
| | | //添加已放电次数列
|
| | | res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
|
| | | + " WHERE table_schema='web_site'"
|
| | | + " AND table_name='tb_battdischarge_plan'"
|
| | | + " AND column_name='already_count'");
|
| | | if(false == res.next()) {
|
| | | sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.BattDischargePlan_Table |
| | | + " ADD COLUMN `already_count` int NOT NULL DEFAULT '0';");
|
| | | }
|
| | | } catch (SQLException e) {
|
| | | e.printStackTrace();
|
| | | } finally {
|
| | | sql.close_con();
|
| | | }
|
| | | }
|
| | | |
| | | /**
|
| | | * 创建放电计划规避时间表
|
| | | * @param pool
|
| | | * @param recreate
|
| | | */
|
| | | private static void createAvoid_plan_Table_Table(MysqlConnPool pool, boolean recreate) {
|
| | | String str_str = "CREATE TABLE IF NOT EXISTS "+Sql_Mysql.Avoid_plan_Table+" (" + |
| | | " `num` int(11) NOT NULL AUTO_INCREMENT," + |
| | | " `start_time` timestamp NOT NULL DEFAULT '2000-01-01 00:00:00'," + |
| | | " `start_month` int(11) NOT NULL DEFAULT '1'," + |
| | | " `start_day` int(11) NOT NULL DEFAULT '1'," + |
| | | " `stop_time` timestamp NOT NULL DEFAULT '2000-01-01 00:00:00'," + |
| | | " `stop_month` int(11) NOT NULL DEFAULT '1'," + |
| | | " `stop_day` int(11) NOT NULL DEFAULT '1'," + |
| | | " `note` varchar(64) NOT NULL DEFAULT ''," + |
| | | " PRIMARY KEY (`num`)" + |
| | | ") ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;";
|
| | | Sql_Mysql sql = new Sql_Mysql(pool.getConn());
|
| | | try {
|
| | | sql.sqlMysqlExecute(str_str);
|
| | | } catch (SQLException e) {
|
| | | e.printStackTrace();
|
| | | } finally {
|
| | | sql.close_con();
|
| | | }
|
| | | |
| | | }
|
| | | |
| | | |
| | | /**
|
| | | * 创建基站定位表
|
| | | */
|
| | | public static void createBattMapInformation_Table(MysqlConnPool pool, boolean recreate) {
|
| | | String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.BattMapInformation_Table;
|
| | | String sql_str02 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.BattMapInformation_Table + " (" + |
| | | " `num` int(11) NOT NULL AUTO_INCREMENT," + |
| | | " `stationId` varchar(128) NOT NULL," + |
| | | " `stationName` varchar(128) NOT NULL," + |
| | | " `stationName3` varchar(128) DEFAULT ''," + |
| | | " `address` varchar(128) NOT NULL," + |
| | | " `longitude` double(11,8) NOT NULL DEFAULT '0.00000000'," + |
| | | " `latitude` double(11,8) NOT NULL DEFAULT '0.00000000'," + |
| | | " `information` varchar(128) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL DEFAULT ''," + |
| | | " PRIMARY KEY (`num`)," + |
| | | " UNIQUE KEY `stationId_num` (`stationId`) USING BTREE," + |
| | | " KEY `index_num` (`num`)" + |
| | | ") ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;"; |
| | | Sql_Mysql sql = new Sql_Mysql(pool.getConn());
|
| | | ResultSet rs = null;
|
| | | try {
|
| | | if(true == recreate) { |
| | | //sql.sqlMysqlExecute(sql_str01);
|
| | | //sql.sqlMysqlExecute(sql_str02);
|
| | | }else {
|
| | | }
|
| | | sql.sqlMysqlExecute(sql_str02); //创建基站定位表
|
| | | /************************** 添加 stationName3 字段 **************************************/
|
| | | String sql_str03 = " SELECT * FROM information_schema.columns "
|
| | | + " WHERE table_schema= 'web_site' "
|
| | | + " AND table_name='tb_battmap_information' "
|
| | | + " AND column_name='stationName3'";
|
| | | rs = sql.sqlMysqlQuery(sql_str03);
|
| | | if(false == rs.next()) {
|
| | | sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.BattMapInformation_Table |
| | | + " ADD COLUMN `stationName3` varchar(128) NOT NULL DEFAULT '';");
|
| | | }
|
| | | } catch (SQLException e) {
|
| | | e.printStackTrace();
|
| | | } finally {
|
| | | sql.close_con();
|
| | | }
|
| | | }
|
| | | |
| | | /**
|
| | | * 创建故障基站表
|
| | | */
|
| | | public static void createBattDischarge_Table(MysqlConnPool pool, boolean recreate) {
|
| | | String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.BattDischarge_Table;
|
| | | String sql_str02 = "CREATE TABLE IF NOT EXISTS "+Sql_Mysql.BattDischarge_Table+" (" + |
| | | " `num` int(11) NOT NULL AUTO_INCREMENT," + |
| | | " `uid` int(11) NOT NULL DEFAULT '1002'," + |
| | | " `dev_id` int(11) NOT NULL DEFAULT '910000001'," + |
| | | " `record_time` datetime NOT NULL DEFAULT '2000-01-01 00:00:00'," + |
| | | " `note` varchar(64) NOT NULL DEFAULT ''," + |
| | | " PRIMARY KEY (`num`)," + |
| | | " UNIQUE KEY `unique_dev_id_index` (`dev_id`) USING BTREE" + |
| | | ") 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);
|
| | | }
|
| | | sql.sqlMysqlExecute(sql_str02); //创建基站故障表 |
| | | |
| | | } catch (SQLException e) {
|
| | | e.printStackTrace();
|
| | | } finally {
|
| | | sql.close_con();
|
| | | }
|
| | | }
|
| | | |
| | | /**
|
| | | * 创建数据库备份表 web_site.tb_database_backup
|
| | | */
|
| | | public static void createDatabase_Backup_Table(MysqlConnPool pool, boolean recreate) {
|
| | | String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.Database_Backup_Table;
|
| | | String sql_str02 = "CREATE TABLE IF NOT EXISTS "+Sql_Mysql.Database_Backup_Table+" (" + |
| | | " `num` int(11) NOT NULL AUTO_INCREMENT," + |
| | | " `database_name` varchar(64) NOT NULL," + |
| | | " `table_name` varchar(64) NOT NULL," + |
| | | " `backup_en` int(11) NOT NULL DEFAULT '0'," + |
| | | " `backup_flag` int(11) NOT NULL DEFAULT '0'," + |
| | | " `note` varchar(64) NOT NULL DEFAULT '保留'," + |
| | | " PRIMARY KEY (`num`)" + |
| | | ") ENGINE=InnoDB AUTO_INCREMENT=128 DEFAULT CHARSET=utf8;" + |
| | | ""; |
| | | Sql_Mysql sql = new Sql_Mysql(pool.getConn());
|
| | | try {
|
| | | if(true == recreate) { |
| | | //sql.sqlMysqlExecute(sql_str01);
|
| | | //sql.sqlMysqlExecute(sql_str02);
|
| | | }
|
| | | sql.sqlMysqlExecute(sql_str02); //创建基站故障表 |
| | | |
| | | } catch (SQLException e) {
|
| | | e.printStackTrace();
|
| | | } finally {
|
| | | sql.close_con();
|
| | | }
|
| | | }
|
| | | |
| | | /**
|
| | | * 创建电池组更换记录表
|
| | | */
|
| | | public static void createBattReplace_Table(MysqlConnPool pool, boolean recreate) {
|
| | | String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.BattReplace_Table;
|
| | | String sql_str02 = "CREATE TABLE IF NOT EXISTS "+Sql_Mysql.BattReplace_Table+" (" + |
| | | " num int(11) NOT NULL AUTO_INCREMENT," + |
| | | " stationid varchar(64) NOT NULL DEFAULT ''," + |
| | | " replaced_producer varchar(64) NOT NULL DEFAULT ''," + |
| | | " replaced_moncapstd int(11) NOT NULL DEFAULT '0'," + |
| | | " replaced_monvolstd float NOT NULL DEFAULT '0'," + |
| | | " replaced_moncount int(11) NOT NULL DEFAULT '0'," + |
| | | " replaced_time datetime NOT NULL DEFAULT '2018-01-01 00:00:00'," + |
| | | " replaced_uid int(11) NOT NULL DEFAULT '0'," + |
| | | " replaced_reason varchar(256) NOT NULL DEFAULT ''," + |
| | | " note varchar(64) NOT NULL DEFAULT ''," + |
| | | " replace_date date DEFAULT '2020-04-20'," + |
| | | " PRIMARY KEY (`num`)," + |
| | | " KEY `stationid_index` (`stationid`)" + |
| | | ") 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);
|
| | | }
|
| | | sql.sqlMysqlExecute(sql_str02); //创建电池组更换记录表 |
| | | /************************** 添加 replace_date 字段 **************************************/
|
| | | String sql_str03 = " SELECT * FROM information_schema.columns "
|
| | | + " WHERE table_schema= 'web_site' "
|
| | | + " AND table_name='tb_batt_replace' "
|
| | | + " AND column_name='replace_date'";
|
| | | ResultSet rs = sql.sqlMysqlQuery(sql_str03);
|
| | | if(false == rs.next()) {
|
| | | sql.sqlMysqlExecute(" ALTER TABLE " + Sql_Mysql.BattReplace_Table |
| | | + " ADD COLUMN replace_date date DEFAULT '2020-04-20';");
|
| | | }
|
| | | /************************** 添加 GroupIndexInFBSDevice 字段表明是那一组电池 **************************************/
|
| | | sql_str03 = " SELECT * FROM information_schema.columns "
|
| | | + " WHERE table_schema= 'web_site' "
|
| | | + " AND table_name='tb_batt_replace' "
|
| | | + " AND column_name='GroupIndexInFBSDevice'";
|
| | | rs = sql.sqlMysqlQuery(sql_str03);
|
| | | if(false == rs.next()) {
|
| | | sql.sqlMysqlExecute(" ALTER TABLE " + Sql_Mysql.BattReplace_Table |
| | | + " ADD COLUMN GroupIndexInFBSDevice int(11) NOT NULL DEFAULT '0';");
|
| | | }
|
| | | } catch (SQLException e) {
|
| | | e.printStackTrace();
|
| | | } finally {
|
| | | sql.close_con();
|
| | | }
|
| | | }
|
| | | |
| | | /**
|
| | | * 创建设备重启计划表
|
| | | * @param pool
|
| | | * @param recreate
|
| | | */
|
| | | public static void createDev_Restart_PlanTable(MysqlConnPool pool, boolean recreate) {
|
| | | String sql_str_del = " DROP TABLE IF EXISTS "+Sql_Mysql.Dev_Restart_Plan_Table;
|
| | | String sql_str = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.Dev_Restart_Plan_Table + " (" + |
| | | " num bigint(20) NOT NULL AUTO_INCREMENT," + |
| | | " dev_id int(11) NOT NULL DEFAULT '0' COMMENT '设备id'," + |
| | | " restart_starttime datetime NOT NULL DEFAULT '2000-01-01 00:00:00' COMMENT '重启开始时间'," + |
| | | " restart_cycle int(11) NOT NULL DEFAULT '1' COMMENT '重启周期'," + |
| | | " restart_en int(11) NOT NULL DEFAULT '0' COMMENT '重启使能 0:不启用 ;1:启用'," + |
| | | " note varchar(255) NOT NULL DEFAULT '' COMMENT '备用'," + |
| | | " PRIMARY KEY (`num`)," + |
| | | " UNIQUE KEY `index_dev_id` (`dev_id`) USING BTREE" + |
| | | ") ENGINE=InnoDB DEFAULT CHARSET=utf8;";
|
| | | Sql_Mysql sql = new Sql_Mysql(pool.getConn());
|
| | | ResultSet res = null;
|
| | | try {
|
| | | if(recreate) {
|
| | | sql.sqlMysqlExecute(sql_str_del);
|
| | | }
|
| | | sql.sqlMysqlExecute(sql_str);
|
| | | //添加上一次重启时间字段
|
| | | res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
|
| | | + " WHERE table_schema='web_site'"
|
| | | + " AND table_name='tb_dev_restart_plan'"
|
| | | + " AND column_name='last_restarttime'");
|
| | | if(false == res.next()) {
|
| | | sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.Dev_Restart_Plan_Table |
| | | + " ADD COLUMN last_restarttime datetime NOT NULL DEFAULT '2000-01-01 00:00:00' COMMENT '上一次重启时间';");
|
| | | }
|
| | | } catch (SQLException e) {
|
| | | e.printStackTrace();
|
| | | } finally {
|
| | | if(res != null) {
|
| | | try {
|
| | | res.close();
|
| | | } catch (SQLException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | sql.close_con();
|
| | | }
|
| | | }
|
| | | |
| | | /**
|
| | | * 创建新版本平台注册信息表
|
| | | * @param pool
|
| | | * @param recreate
|
| | | */
|
| | | public static void createLicense_Table(MysqlConnPool pool, boolean recreate) {
|
| | | String sql_str_del = " DROP TABLE IF EXISTS "+Sql_Mysql.License_Table;
|
| | | String sql_str = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.License_Table + " (" + |
| | | " `id` int(11) NOT NULL AUTO_INCREMENT," + |
| | | " `serialNumber` varchar(255) NOT NULL DEFAULT ''," + |
| | | " `duration` varchar(255) NOT NULL DEFAULT '0'," + |
| | | " `timeInUse` varchar(255) NOT NULL DEFAULT '0'," + |
| | | " PRIMARY KEY (`id`) USING BTREE" + |
| | | ") ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;";
|
| | | Sql_Mysql sql = new Sql_Mysql(pool.getConn());
|
| | | ResultSet res = null;
|
| | | try {
|
| | | if(recreate) {
|
| | | sql.sqlMysqlExecute(sql_str_del);
|
| | | }
|
| | | sql.sqlMysqlExecute(sql_str);
|
| | | //修改注册时长信息
|
| | | res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
|
| | | + " WHERE table_schema='web_site'"
|
| | | + " AND table_name='tb_license'"
|
| | | + " AND column_name='duration'"
|
| | | + " AND DATA_TYPE = 'varchar'");
|
| | | if(false == res.next()) {
|
| | | //System.out.println("###############");
|
| | | sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.License_Table |
| | | + " modify COLUMN `duration` varchar(255) NOT NULL DEFAULT '0';");
|
| | | }
|
| | | res =null;
|
| | | //修改已用时长字段
|
| | | res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
|
| | | + " WHERE table_schema='web_site'"
|
| | | + " AND table_name='tb_license'"
|
| | | + " AND column_name='timeInUse'"
|
| | | + " AND DATA_TYPE = 'varchar'");
|
| | | if(false == res.next()) {
|
| | | sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.License_Table |
| | | + " modify COLUMN `timeInUse` varchar(255) NOT NULL DEFAULT '0';");
|
| | | }
|
| | | } catch (SQLException e) {
|
| | | e.printStackTrace();
|
| | | } finally {
|
| | | if(res != null) {
|
| | | try {
|
| | | res.close();
|
| | | } catch (SQLException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | sql.close_con();
|
| | | }
|
| | | }
|
| | | |
| | | /**
|
| | | * 创建超级用户表
|
| | | * @param pool
|
| | | * @param recreate
|
| | | */
|
| | | public static void createVip_User_Table(MysqlConnPool pool, boolean recreate) {
|
| | | String sql_str_del = " DROP TABLE IF EXISTS "+Sql_Mysql.Vip_User_Table;
|
| | | String sql_str = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.Vip_User_Table + " (" + |
| | | " `num` int(11) NOT NULL AUTO_INCREMENT," + |
| | | " `vipname` varchar(64) COLLATE utf8_unicode_ci DEFAULT NULL," + |
| | | " `vipSnid` varchar(64) COLLATE utf8_unicode_ci DEFAULT NULL," + |
| | | " `vipPassword` varchar(64) COLLATE utf8_unicode_ci DEFAULT NULL," + |
| | | " PRIMARY KEY (`num`)" + |
| | | ") ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;";
|
| | | Sql_Mysql sql = new Sql_Mysql(pool.getConn());
|
| | | String sql_str_sel = "SELECT * FROM "+Sql_Mysql.Vip_User_Table+" WHERE vipname = 'vip';";
|
| | | ResultSet res = null;
|
| | | try {
|
| | | if(recreate) {
|
| | | sql.sqlMysqlExecute(sql_str_del);
|
| | | }
|
| | | sql.sqlMysqlExecute(sql_str);
|
| | | //添加上一次重启时间字段
|
| | | res = sql.sqlMysqlQuery(sql_str_sel);
|
| | | if(false == res.next()) {
|
| | | //不存在默认vip账号则
|
| | | sql.sqlMysqlExecute("INSERT INTO "+Sql_Mysql.Vip_User_Table+"(vipname,vipSnid,vipPassword) VALUES ('vip', 'vip', '232059cb5361a9336ccf1b8c2ba7657a');");
|
| | | }
|
| | | } catch (SQLException e) {
|
| | | e.printStackTrace();
|
| | | } finally {
|
| | | if(res != null) {
|
| | | try {
|
| | | res.close();
|
| | | } catch (SQLException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | sql.close_con();
|
| | | }
|
| | | }
|
| | | |
| | | |
| | | /**
|
| | | * 设置指定的线程重启[ 告警线程; ]
|
| | | */
|
| | | public static void setUpThreadRestart(MysqlConnPool conn_pool) {
|
| | | //重启告警线程
|
| | | String sql_str = "UPDATE " + Sql_Mysql.ProcessSurvey_Table
|
| | | + " SET ServerFlag = 0 "
|
| | | + " WHERE ProcessId = 11002 AND ServerFlag != 2";
|
| | | Sql_Mysql sql = new Sql_Mysql(conn_pool.getConn());
|
| | | try {
|
| | | sql.sqlMysqlExecute(sql_str);
|
| | | } 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();
|
| | | //website.createBattReplace_Table(pool, false);
|
| | | website.createAvoid_plan_Table_Table(pool, false);
|
| | | |
| | | }
|
| | | }
|
| | | package com.database_util; |
| | | |
| | | import java.sql.ResultSet; |
| | | import java.sql.SQLException; |
| | | |
| | | import com.sql.MysqlConnPool; |
| | | import com.sql.Sql_Mysql; |
| | | |
| | | public class DB_web_site { |
| | | |
| | | |
| | | public static void init(MysqlConnPool pool, boolean recreate) { |
| | | createWeb_siteDB(pool); //创建website 数据库 |
| | | |
| | | createThread_utilTable(pool,recreate); //创建线程控制表 |
| | | |
| | | createPositiomapUsr_Table(pool,recreate); //创建首页上用户中心点设置表 |
| | | |
| | | createChartColor_Table(pool,recreate); //创建用户实时监测页面柱体颜色设置表 |
| | | |
| | | createUserChart_Table(pool,recreate); //创建班组管理表 |
| | | |
| | | createProcessSurvey_Table(pool,recreate); //创建线程监控表 |
| | | |
| | | createEchartsUsr_Table(pool,recreate); //创建首页饼状图定制表 |
| | | |
| | | createDevstateUsr_Table(pool, recreate); //创建用户放电记录表 |
| | | |
| | | createCustomPage_Table(pool,recreate); //创建导航数据表 |
| | | |
| | | createAnnounce_Table(pool, recreate); //创建公告表 |
| | | |
| | | createBattAttention_Table(pool, recreate); //创建电池组单体关注表 |
| | | |
| | | createBattpowerOff_Table(pool,recreate); //创建机房停电表 |
| | | |
| | | createBadbattMon_Table(pool, recreate); //创建落后单体表 |
| | | |
| | | createBadbattMonFlag_Table(pool, recreate); //创建落后单体帮助控制表 |
| | | |
| | | createBattEndurance_Table(pool, recreate); //创建机房续航 |
| | | |
| | | createBattParamLow_Table(pool, recreate); //创建各种续航表 |
| | | |
| | | createBattDischargeParam_Table(pool, recreate); //创建放电计划参数表 |
| | | |
| | | createBattDischargePlan_Table(pool, recreate); //创建放电计划表 |
| | | |
| | | createAvoid_plan_Table_Table(pool, recreate); //创建放电计划规避时间表 |
| | | |
| | | createBattMapInformation_Table(pool, recreate); //创建基站定位表 |
| | | |
| | | createBattDischarge_Table(pool,recreate); //创建基站故障表 |
| | | |
| | | createBattReplace_Table(pool,recreate); //创建机房电池组更换记录表 |
| | | |
| | | createDev_Restart_PlanTable(pool,recreate); //创建设备重启计划表 |
| | | |
| | | createVip_User_Table(pool, recreate); //创建超级用户表以及添加vip用户 |
| | | |
| | | createLicense_Table(pool, recreate); //创建超级用户表以及添加vip用户 |
| | | |
| | | createDatabase_Backup_Table(pool, recreate); //创建数据库备份表 |
| | | |
| | | createTb_Eletmp_Table(pool, recreate); //创建模板表 |
| | | } |
| | | |
| | | |
| | | private static void createTb_Eletmp_Table(MysqlConnPool pool, boolean recreate) { |
| | | String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.Eletmp_Table; |
| | | String sql_str02 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.Eletmp_Table + " (" + |
| | | "`tmp_id` int(11) NOT NULL AUTO_INCREMENT," + |
| | | " `tmp_name` varchar(64) NOT NULL DEFAULT '模板1' COMMENT '模板名称'," + |
| | | " PRIMARY KEY (`tmp_id`)" + |
| | | ") ENGINE=InnoDB AUTO_INCREMENT=1011 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(); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 创建 web_site 数据库 |
| | | * @param pool |
| | | */ |
| | | public static void createWeb_siteDB(MysqlConnPool pool) { |
| | | Sql_Mysql sql = new Sql_Mysql(pool.getConn()); |
| | | try { |
| | | sql.sqlMysqlExecute("CREATE DATABASE IF NOT EXISTS " + Sql_Mysql.WEB_Site); |
| | | } catch (SQLException e) { |
| | | e.printStackTrace(); |
| | | } finally { |
| | | sql.close_con(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 创建线程手动启动工具表 |
| | | */ |
| | | 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 + " (" + |
| | | " `num` bigint(20) NOT NULL," + |
| | | " `thread_id` int(11) NOT NULL COMMENT '线程id'," + |
| | | " `thread_name` varchar(64) NOT NULL DEFAULT '线程名称'," + |
| | | " `thread_starttime` datetime NOT NULL DEFAULT '1970-01-01 00:00:00'," + |
| | | " `thread_en` int(11) NOT NULL DEFAULT '0' COMMENT '是否启动标识位 0:默认 1:需要启动 2:运行完成'," + |
| | | " `note` varchar(256) NOT NULL DEFAULT ''," + |
| | | " UNIQUE KEY `unindex_thread_id` (`thread_id`)," + |
| | | " PRIMARY KEY (`num`)" + |
| | | ") ENGINE=InnoDB DEFAULT CHARSET=utf8;"; |
| | | Sql_Mysql sql = new Sql_Mysql(pool.getConn()); |
| | | ResultSet rs = null; |
| | | try { |
| | | if(true == recreate) { |
| | | sql.sqlMysqlExecute(sql_str01); |
| | | } |
| | | sql.sqlMysqlExecute(sql_str02); |
| | | rs = sql.sqlMysqlQuery("SELECT * from web_site.tb_thread_util WHERE thread_id = 2019001"); |
| | | if(false == rs.next()) { |
| | | sql.sqlMysqlExecute("INSERT INTO " + Sql_Mysql.ThreadUtil_Table + " VALUES ('1', '2019001', '机房续航线程', '2019-01-08 10:44:28', '0', '')"); //添加机房续航线程的控制记录 |
| | | } |
| | | rs = sql.sqlMysqlQuery("SELECT * from web_site.tb_thread_util WHERE thread_id = 2019002"); |
| | | if(false == rs.next()) { |
| | | sql.sqlMysqlExecute("INSERT INTO " + Sql_Mysql.ThreadUtil_Table + " VALUES ('2', '2019002', '落后单体线程', '2019-01-08 10:44:28', '0', '')"); //添加机房续航线程的控制记录 |
| | | } |
| | | |
| | | } catch (SQLException e) { |
| | | e.printStackTrace(); |
| | | } finally { |
| | | sql.close_con(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 创建用户地图中心点位置表 |
| | | */ |
| | | 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=1 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 + "(ProcessId,ProcessName,ProcessTime,Process_starttime,ServerName,ServerFlag,ProcessVersion,note,OutTime) VALUES ('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 + "(ProcessId,ProcessName,ProcessTime,Process_starttime,ServerName,ServerFlag,ProcessVersion,note,OutTime) VALUES ('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 + "(ProcessId,ProcessName,ProcessTime,Process_starttime,ServerName,ServerFlag,ProcessVersion,note,OutTime) VALUES ('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 + "(ProcessId,ProcessName,ProcessTime,Process_starttime,ServerName,ServerFlag,ProcessVersion,note,OutTime) VALUES ('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 + "(ProcessId,ProcessName,ProcessTime,Process_starttime,ServerName,ServerFlag,ProcessVersion,note,OutTime) VALUES ('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 + "(ProcessId,ProcessName,ProcessTime,Process_starttime,ServerName,ServerFlag,ProcessVersion,note,OutTime) VALUES ('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 + "(ProcessId,ProcessName,ProcessTime,Process_starttime,ServerName,ServerFlag,ProcessVersion,note,OutTime) VALUES ('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 + "(ProcessId,ProcessName,ProcessTime,Process_starttime,ServerName,ServerFlag,ProcessVersion,note,OutTime) VALUES ('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 + "(ProcessId,ProcessName,ProcessTime,Process_starttime,ServerName,ServerFlag,ProcessVersion,note,OutTime) VALUES ('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 + "(ProcessId,ProcessName,ProcessTime,Process_starttime,ServerName,ServerFlag,ProcessVersion,note,OutTime) VALUES ('11010', 'BMS_FBS9600_DISPLAY', '1970-01-01 00:00:00', '1970-01-01 00:00:00', 'BMS_FBS9600_DISPLAY', '2', 'v1.101', '9600显示模块线程', '300');"); |
| | | } |
| | | //添加FBS汇集器通讯进程记录 |
| | | res = sql.sqlMysqlQuery("SELECT * FROM "+ Sql_Mysql.ProcessSurvey_Table + " WHERE ProcessId = 11011"); |
| | | if(false == res.next()) { |
| | | sql.sqlMysqlExecute("INSERT INTO " + Sql_Mysql.ProcessSurvey_Table + "(ProcessId,ProcessName,ProcessTime,Process_starttime,ServerName,ServerFlag,ProcessVersion,note,OutTime) VALUES ('11011', 'BMS_FBS_CONCENTRATOR', '1970-01-01 00:00:00', '1970-01-01 00:00:00', 'BMS_FBS_CONCENTRATOR', '2', 'v1.101', 'FBS汇集器通讯线程', '300');"); |
| | | } |
| | | //添加9度通讯线程 |
| | | res = sql.sqlMysqlQuery("SELECT * FROM "+ Sql_Mysql.ProcessSurvey_Table + " WHERE ProcessId = 11012"); |
| | | if(false == res.next()) { |
| | | sql.sqlMysqlExecute(" INSERT INTO " + Sql_Mysql.ProcessSurvey_Table + "(ProcessId,ProcessName,ProcessTime,Process_starttime,ServerName,ServerFlag,ProcessVersion,note,OutTime) VALUES ('11012', 'BMS_LD9_MONITOR', '1970-01-01 00:00:00', '1970-01-01 00:00:00', 'BMS_LD9_MONITOR', '2', 'v1.101', '9度设备通讯线程', '300');"); |
| | | } |
| | | |
| | | //添加6度通讯线程 |
| | | res = sql.sqlMysqlQuery("SELECT * FROM "+ Sql_Mysql.ProcessSurvey_Table + " WHERE ProcessId = 11013"); |
| | | if(false == res.next()) { |
| | | sql.sqlMysqlExecute(" INSERT INTO " + Sql_Mysql.ProcessSurvey_Table + "(ProcessId,ProcessName,ProcessTime,Process_starttime,ServerName,ServerFlag,ProcessVersion,note,OutTime) VALUES ('11013', 'BMS_LD6_MONITOR', '1970-01-01 00:00:00', '1970-01-01 00:00:00', 'BMS_LD6_MONITOR', '2', 'v1.101', '6度设备通讯线程', '300');"); |
| | | } |
| | | //添加BTS续航统计线程 |
| | | res = sql.sqlMysqlQuery("SELECT * FROM "+ Sql_Mysql.ProcessSurvey_Table + " WHERE ProcessId = 11014"); |
| | | if(false == res.next()) { |
| | | sql.sqlMysqlExecute(" INSERT INTO " + Sql_Mysql.ProcessSurvey_Table + "(ProcessId,ProcessName,ProcessTime,Process_starttime,ServerName,ServerFlag,ProcessVersion,note,OutTime) VALUES ('11014', 'BMS_BTS_ENDURANCE', '1970-01-01 00:00:00', '1970-01-01 00:00:00', 'BMS_BTS_ENDURANCE', '2', 'v1.101', 'BTS续航统计线程', '300');"); |
| | | } |
| | | //添加通信电源通讯 |
| | | res = sql.sqlMysqlQuery("SELECT * FROM "+ Sql_Mysql.ProcessSurvey_Table + " WHERE ProcessId = 11015"); |
| | | if(false == res.next()) { |
| | | sql.sqlMysqlExecute(" INSERT INTO " + Sql_Mysql.ProcessSurvey_Table + "(ProcessId,ProcessName,ProcessTime,Process_starttime,ServerName,ServerFlag,ProcessVersion,note,OutTime) VALUES ('11015', 'BMS_COMM_POWER', '1970-01-01 00:00:00', '1970-01-01 00:00:00', 'BMS_COMM_POWER', '2', 'v1.101', '通信电源通讯线程', '300');"); |
| | | } |
| | | //添加通信电源通讯 |
| | | res = sql.sqlMysqlQuery("SELECT * FROM "+ Sql_Mysql.ProcessSurvey_Table + " WHERE ProcessId = 11016"); |
| | | if(false == res.next()) { |
| | | sql.sqlMysqlExecute(" INSERT INTO " + Sql_Mysql.ProcessSurvey_Table + "(ProcessId,ProcessName,ProcessTime,Process_starttime,ServerName,ServerFlag,ProcessVersion,note,OutTime) VALUES ('11016', 'BMS_POWER_MONITOR', '1970-01-01 00:00:00', '1970-01-01 00:00:00', 'BMS_POWER_MONITOR', '2', 'v1.100', '通信电源监控线程', '300');"); |
| | | } |
| | | //蓄电池负载更新线程 |
| | | res = sql.sqlMysqlQuery("SELECT * FROM "+ Sql_Mysql.ProcessSurvey_Table + " WHERE ProcessId = 11017"); |
| | | if(false == res.next()) { |
| | | sql.sqlMysqlExecute(" INSERT INTO " + Sql_Mysql.ProcessSurvey_Table + "(ProcessId,ProcessName,ProcessTime,Process_starttime,ServerName,ServerFlag,ProcessVersion,note,OutTime) VALUES ('11017', 'BMS_BATT_LOADUPDATE', '1970-01-01 00:00:00', '1970-01-01 00:00:00', 'BMS_BATT_LOADUPDATE', '1', 'v1.100', '蓄电池负载更新线程', '300');"); |
| | | } |
| | | //充放电一体机通讯线程 |
| | | res = sql.sqlMysqlQuery("SELECT * FROM "+ Sql_Mysql.ProcessSurvey_Table + " WHERE ProcessId = 11018"); |
| | | if(false == res.next()) { |
| | | sql.sqlMysqlExecute(" INSERT INTO " + Sql_Mysql.ProcessSurvey_Table + "(ProcessId,ProcessName,ProcessTime,Process_starttime,ServerName,ServerFlag,ProcessVersion,note,OutTime) VALUES ('11018', 'BMS_BATT_FGCD_A059', '1970-01-01 00:00:00', '1970-01-01 00:00:00', 'BMS_BATT_FGCD_A059', '1', 'v1.100', '充放电一体机通讯线程', '300');"); |
| | | } |
| | | } catch (SQLException e) { |
| | | e.printStackTrace(); |
| | | } finally { |
| | | sql.close_con(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 创建用户首页饼状图定制页面 |
| | | */ |
| | | public static void createEchartsUsr_Table(MysqlConnPool pool, boolean recreate) { |
| | | String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.EchartsUsr_Table; |
| | | String sql_str02 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.EchartsUsr_Table + " (" + |
| | | " `num` int(11) NOT NULL AUTO_INCREMENT," + |
| | | " `uid` int(11) NOT NULL DEFAULT '1002'," + |
| | | " `echarts1_enable` int(11) NOT NULL DEFAULT '1'," + |
| | | " `echarts2_enable` int(11) NOT NULL DEFAULT '1'," + |
| | | " `echarts3_enable` int(11) NOT NULL DEFAULT '1'," + |
| | | " `echarts4_enable` int(11) NOT NULL DEFAULT '1'," + |
| | | " `echarts5_enable` int(11) NOT NULL DEFAULT '0'," + |
| | | " `echarts6_enable` int(11) NOT NULL DEFAULT '0'," + |
| | | " `echarts7_enable` int(11) NOT NULL DEFAULT '0'," + |
| | | " `echarts8_enable` int(11) NOT NULL DEFAULT '0'," + |
| | | " `echarts9_enable` int(11) NOT NULL DEFAULT '0'," + |
| | | " `echarts10_enable` int(11) NOT NULL DEFAULT '0'," + |
| | | " `note` varchar(64) NOT NULL DEFAULT ''," + |
| | | " PRIMARY KEY (`num`)," + |
| | | " UNIQUE KEY `uid_index` (`uid`)" + |
| | | ") 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(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 创建用户放电添加记录表 |
| | | */ |
| | | public static void createDevstateUsr_Table(MysqlConnPool pool, boolean recreate) { |
| | | String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.DevstateUsr_Table; |
| | | String sql_str02 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.DevstateUsr_Table + " (" + |
| | | " `num` int(11) NOT NULL AUTO_INCREMENT," + |
| | | " `uid` int(11) NOT NULL DEFAULT '1001'," + |
| | | " `dev_id` int(11) NOT NULL DEFAULT '910000001'," + |
| | | " `battgroupid` int(11) NOT NULL DEFAULT '1000001'," + |
| | | " `note` varchar(64) NOT NULL DEFAULT ' '," + |
| | | " `batt_index` int(11) NOT NULL DEFAULT '0'," + |
| | | " `stationname` varchar(64) NOT NULL DEFAULT ''," + |
| | | " `battgroupname` varchar(64) NOT NULL DEFAULT ''," + |
| | | " PRIMARY KEY (`num`)" + |
| | | ") 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); |
| | | |
| | | //清空添加过放电记录中的机房修改过机房名称的记录 |
| | | sql.sqlMysqlExecute(" DELETE FROM "+ Sql_Mysql.DevstateUsr_Table +" WHERE BattGroupId not in ( " + |
| | | " SELECT DISTINCT(BattGroupId) FROM " +Sql_Mysql.BattInf_Table + |
| | | " ) "); |
| | | |
| | | } catch (SQLException e) { |
| | | e.printStackTrace(); |
| | | } finally { |
| | | sql.close_con(); |
| | | } |
| | | } |
| | | /** |
| | | * 创建导航数据表 |
| | | */ |
| | | public static void createCustomPage_Table(MysqlConnPool pool, boolean recreate) { |
| | | String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.CustomPage_Table; |
| | | String sql_str02 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.CustomPage_Table + " (" + |
| | | " `Num` int(11) NOT NULL AUTO_INCREMENT," + |
| | | " `Navigate` varchar(64) COLLATE utf8_unicode_ci DEFAULT NULL," + |
| | | " `Navigate_order` int(11) DEFAULT NULL," + |
| | | " `Submenu` varchar(64) COLLATE utf8_unicode_ci DEFAULT NULL," + |
| | | " `Subflag` int(11) DEFAULT NULL," + |
| | | " `Sublink` varchar(64) COLLATE utf8_unicode_ci DEFAULT NULL," + |
| | | " `SubEnable` int(11) DEFAULT NULL," + |
| | | " `SubName` varchar(64) COLLATE utf8_unicode_ci DEFAULT NULL," + |
| | | " `Subjudge` int(11) DEFAULT NULL," + |
| | | " `page_order` int(11) NOT NULL DEFAULT '0'," + |
| | | " PRIMARY KEY (`Num`)" + |
| | | ") ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;"; |
| | | 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_custompage'" |
| | | + " AND column_name='page_order'"); |
| | | if(false == res.next()) { |
| | | sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.CustomPage_Table |
| | | + " ADD COLUMN `page_order` int(11) NOT NULL DEFAULT '0';"); |
| | | } |
| | | } catch (SQLException e) { |
| | | e.printStackTrace(); |
| | | } finally { |
| | | sql.close_con(); |
| | | } |
| | | } |
| | | /** |
| | | * 创建公告表 |
| | | */ |
| | | public static void createAnnounce_Table(MysqlConnPool pool, boolean recreate) { |
| | | String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.Announce_Table; |
| | | String sql_str02 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.Announce_Table + " (" + |
| | | " `num` int(11) NOT NULL AUTO_INCREMENT," + |
| | | " `usr_id` int(11) DEFAULT NULL," + |
| | | " `announce_time` datetime DEFAULT NULL," + |
| | | " `message` varchar(1024) COLLATE utf8_unicode_ci DEFAULT NULL," + |
| | | " `note` varchar(16) COLLATE utf8_unicode_ci DEFAULT NULL," + |
| | | " PRIMARY KEY (`num`)" + |
| | | ") ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;"; |
| | | 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 createBattAttention_Table(MysqlConnPool pool, boolean recreate) { |
| | | String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.BattAttention_Table; |
| | | String sql_str02 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.BattAttention_Table + " (" + |
| | | " `num` int(11) NOT NULL AUTO_INCREMENT," + |
| | | " `BattGroupId` int(11) NOT NULL DEFAULT '0'," + |
| | | " `MonNum` int(11) NOT NULL DEFAULT '0'," + |
| | | " `note` varchar(64) NOT NULL DEFAULT ' '," + |
| | | " `Uid` int(11) NOT NULL DEFAULT '1001'," + |
| | | " PRIMARY KEY (`num`)" + |
| | | ") 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(); |
| | | } |
| | | } |
| | | /** |
| | | * 创建机房停电表 |
| | | */ |
| | | public static void createBattpowerOff_Table(MysqlConnPool pool, boolean recreate) { |
| | | String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.BattpowerOff_Table; |
| | | String sql_str02 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.BattpowerOff_Table + " (" + |
| | | " `num` int(11) NOT NULL AUTO_INCREMENT," + |
| | | " `dev_id` int(11) NOT NULL," + |
| | | " `record_count` int(11) NOT NULL DEFAULT '0'," + |
| | | " `poweroff_starttime` timestamp NOT NULL DEFAULT '1982-01-01 00:00:00'," + |
| | | " `poweroff_stoptime` timestamp NOT NULL DEFAULT '1982-01-01 00:00:00'," + |
| | | " `power_state` int(11) NOT NULL DEFAULT '0'," + |
| | | " `timelong` int(11) NOT NULL DEFAULT '0'," + |
| | | " `note` varchar(64) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL DEFAULT ''," + |
| | | " PRIMARY KEY (`num`)," + |
| | | " KEY `index_dev_id` (`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(); |
| | | } |
| | | } |
| | | /** |
| | | * 创落后单体表 |
| | | */ |
| | | public static void createBadbattMon_Table(MysqlConnPool pool, boolean recreate) { |
| | | String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.BadbattMon_Table; |
| | | String sql_str02 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.BadbattMon_Table + " (" + |
| | | " `num` int(11) NOT NULL AUTO_INCREMENT," + |
| | | " `battgroupid` int(11) NOT NULL DEFAULT '0'," + |
| | | " `mon_num` int(11) NOT NULL DEFAULT '0'," + |
| | | " `record_num` int(11) NOT NULL DEFAULT '0'," + |
| | | " `test_starttime` datetime NOT NULL DEFAULT '1982-01-01 00:00:00'," + |
| | | " `group_vol` float NOT NULL DEFAULT '0'," + |
| | | " `test_curr` float NOT NULL DEFAULT '0'," + |
| | | " `mon_vol` float NOT NULL DEFAULT '0'," + |
| | | " `real_cap` float NOT NULL DEFAULT '0'," + |
| | | " `stdcap` float NOT NULL DEFAULT '0'," + |
| | | " `note` varchar(64) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL DEFAULT ' '," + |
| | | " PRIMARY KEY (`num`)," + |
| | | " KEY `index_num` (`battgroupid`)" + |
| | | ") 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(); |
| | | } |
| | | } |
| | | /** |
| | | * 创落后单体控制表 |
| | | */ |
| | | public static void createBadbattMonFlag_Table(MysqlConnPool pool, boolean recreate) { |
| | | String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.BadbattMonFlag_Table; |
| | | String sql_str02 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.BadbattMonFlag_Table + " (" + |
| | | " `num` int(11) NOT NULL AUTO_INCREMENT," + |
| | | " `count` int(11) NOT NULL DEFAULT '0'," + |
| | | " PRIMARY KEY (`num`)" + |
| | | ") ENGINE=InnoDB AUTO_INCREMENT=7 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 createBattEndurance_Table(MysqlConnPool pool, boolean recreate) { |
| | | String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.BattEndurance_Table; |
| | | String sql_str02 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.BattEndurance_Table + " (" + |
| | | " `num` int(11) NOT NULL AUTO_INCREMENT," + |
| | | " `deviceid` int(11) NOT NULL DEFAULT '0' COMMENT '设备id'," + |
| | | " `stationid` varchar(64) NOT NULL DEFAULT '0' COMMENT '机房id'," + |
| | | " `real_cap` float NOT NULL DEFAULT '0' COMMENT '实际容量'," + |
| | | " `moncapstd` float NOT NULL DEFAULT '0' COMMENT '标称容量'," + |
| | | " `real_curr` float NOT NULL DEFAULT '0' COMMENT '实际电流'," + |
| | | " `endurance_theory_timelong` float NOT NULL DEFAULT '0' COMMENT '理论续航时长(分钟)'," + |
| | | " `endurance_actual_timelong` float NOT NULL DEFAULT '0' COMMENT '平均实际续航时长(分钟)'," + |
| | | " `endurance_actual_timelong_min` float NOT NULL DEFAULT '0' COMMENT '最小实际续航时长(分钟)'," + |
| | | " `endurance_actual_timelong_max` float NOT NULL DEFAULT '0' COMMENT '最大实际续航时长(分钟)'," + |
| | | " `is_out_stand` tinyint(4) NOT NULL DEFAULT '0' COMMENT '是否掉站'," + |
| | | " `note` varchar(64) NOT NULL DEFAULT '' COMMENT '备注'," + |
| | | " `real_cap_group1` float NOT NULL DEFAULT '0' COMMENT '电池组1实际容量'," + |
| | | " `real_cap_group2` float NOT NULL DEFAULT '0' COMMENT '电池组2实际容量'," + |
| | | " `real_cap_group3` float NOT NULL DEFAULT '0' COMMENT '电池组3实际容量'," + |
| | | " `real_cap_group4` float NOT NULL DEFAULT '0' COMMENT '电池组4实际容量'," + |
| | | " PRIMARY KEY (`num`)," + |
| | | " UNIQUE KEY `unique_index_deviceid` (`deviceid`)," + |
| | | " KEY `index_stationid` (`stationid`)" + |
| | | ") 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); |
| | | |
| | | /************************** 添加最大续航时长列 **************************************/ |
| | | String sql_str1 = " SELECT * FROM information_schema.columns " |
| | | + " WHERE table_schema= 'web_site' " |
| | | + " AND table_name='tb_batt_endurance' " |
| | | + " AND column_name='endurance_actual_timelong_max'"; |
| | | //System.out.println(sql_str3); |
| | | ResultSet rs = sql.sqlMysqlQuery(sql_str1); |
| | | if(false == rs.next()) { |
| | | sql.sqlMysqlExecute(" ALTER TABLE " + Sql_Mysql.BattEndurance_Table |
| | | + " ADD COLUMN `endurance_actual_timelong_max` int(11) NOT NULL DEFAULT '0' COMMENT '最大实际续航时长(分钟)' AFTER `endurance_actual_timelong`;"); |
| | | } |
| | | |
| | | /************************** 添加最小续航时长列 **************************************/ |
| | | String sql_str2 = " SELECT * FROM information_schema.columns " |
| | | + " WHERE table_schema= 'web_site' " |
| | | + " AND table_name='tb_batt_endurance' " |
| | | + " AND column_name='endurance_actual_timelong_min'"; |
| | | //System.out.println(sql_str3); |
| | | rs = sql.sqlMysqlQuery(sql_str2); |
| | | if(false == rs.next()) { |
| | | sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.BattEndurance_Table |
| | | + " ADD COLUMN `endurance_actual_timelong_min` int(11) NOT NULL DEFAULT '0' COMMENT '最小实际续航时长(分钟)' AFTER `endurance_actual_timelong`;"); |
| | | } |
| | | |
| | | /************************** 添加 电池组1实际容量 **************************************/ |
| | | String sql_str3 = " SELECT * FROM information_schema.columns " |
| | | + " WHERE table_schema= 'web_site' " |
| | | + " AND table_name='tb_batt_endurance' " |
| | | + " AND column_name='real_cap_group1'"; |
| | | //System.out.println(sql_str3); |
| | | rs = sql.sqlMysqlQuery(sql_str3); |
| | | if(false == rs.next()) { |
| | | sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.BattEndurance_Table |
| | | + " ADD COLUMN `real_cap_group1` float NOT NULL DEFAULT '0' COMMENT '电池组1实际容量';"); |
| | | } |
| | | /************************** 添加 电池组2实际容量 **************************************/ |
| | | String sql_str4 = " SELECT * FROM information_schema.columns " |
| | | + " WHERE table_schema= 'web_site' " |
| | | + " AND table_name='tb_batt_endurance' " |
| | | + " AND column_name='real_cap_group2'"; |
| | | //System.out.println(sql_str3); |
| | | rs = sql.sqlMysqlQuery(sql_str4); |
| | | if(false == rs.next()) { |
| | | sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.BattEndurance_Table |
| | | + " ADD COLUMN `real_cap_group2` float NOT NULL DEFAULT '0' COMMENT '电池组2实际容量';"); |
| | | } |
| | | /************************** 添加 电池组3实际容量 **************************************/ |
| | | String sql_str5 = " SELECT * FROM information_schema.columns " |
| | | + " WHERE table_schema= 'web_site' " |
| | | + " AND table_name='tb_batt_endurance' " |
| | | + " AND column_name='real_cap_group3'"; |
| | | //System.out.println(sql_str3); |
| | | rs = sql.sqlMysqlQuery(sql_str5); |
| | | if(false == rs.next()) { |
| | | sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.BattEndurance_Table |
| | | + " ADD COLUMN `real_cap_group3` float NOT NULL DEFAULT '0' COMMENT '电池组3实际容量';"); |
| | | } |
| | | /************************** 添加 电池组4实际容量 **************************************/ |
| | | String sql_str6 = " SELECT * FROM information_schema.columns " |
| | | + " WHERE table_schema= 'web_site' " |
| | | + " AND table_name='tb_batt_endurance' " |
| | | + " AND column_name='real_cap_group4'"; |
| | | //System.out.println(sql_str3); |
| | | rs = sql.sqlMysqlQuery(sql_str6); |
| | | if(false == rs.next()) { |
| | | sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.BattEndurance_Table |
| | | + " ADD COLUMN `real_cap_group4` float NOT NULL DEFAULT '0' COMMENT '电池组4实际容量';"); |
| | | } |
| | | /************************** 添加 电池组的标称容量 **************************************/ |
| | | String sql_str7 = " SELECT * FROM information_schema.columns " |
| | | + " WHERE table_schema= 'web_site' " |
| | | + " AND table_name='tb_batt_endurance' " |
| | | + " AND column_name='batts_moncapstd'"; |
| | | //System.out.println(sql_str3); |
| | | rs = sql.sqlMysqlQuery(sql_str7); |
| | | if(false == rs.next()) { |
| | | sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.BattEndurance_Table |
| | | + " ADD COLUMN `batts_moncapstd` varchar(64) NOT NULL DEFAULT '' COMMENT '电池组的标称容量';"); |
| | | } |
| | | /************************** 添加 电池组的核容时间 **************************************/ |
| | | String sql_str8 = " SELECT * FROM information_schema.columns " |
| | | + " WHERE table_schema= 'web_site' " |
| | | + " AND table_name='tb_batt_endurance' " |
| | | + " AND column_name='batts_teststarttime'"; |
| | | rs = sql.sqlMysqlQuery(sql_str8); |
| | | if(false == rs.next()) { |
| | | sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.BattEndurance_Table |
| | | + " ADD COLUMN `batts_teststarttime` varchar(250) NOT NULL DEFAULT '' COMMENT '电池组的核容时间';"); |
| | | } |
| | | /************************** 添加 电池组的组数 **************************************/ |
| | | String sql_str9 = " SELECT * FROM information_schema.columns " |
| | | + " WHERE table_schema= 'web_site' " |
| | | + " AND table_name='tb_batt_endurance' " |
| | | + " AND column_name='groupcount'"; |
| | | rs = sql.sqlMysqlQuery(sql_str9); |
| | | if(false == rs.next()) { |
| | | sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.BattEndurance_Table |
| | | + " ADD COLUMN `groupcount` int NOT NULL DEFAULT '0' COMMENT '电池组的组数';"); |
| | | } |
| | | } catch (SQLException e) { |
| | | e.printStackTrace(); |
| | | } finally { |
| | | sql.close_con(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 创建各种阀值参数表 |
| | | */ |
| | | public static void createBattParamLow_Table(MysqlConnPool pool, boolean recreate) { |
| | | String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.BattParamLow_Table; |
| | | String sql_str02 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.BattParamLow_Table + " (" + |
| | | " `num` int(11) NOT NULL AUTO_INCREMENT," + |
| | | " `low_type` int(11) DEFAULT NULL," + |
| | | " `Low_nametype` int(11) DEFAULT NULL," + |
| | | " `Low_value` float DEFAULT NULL," + |
| | | " `low_method` int(11) DEFAULT NULL," + |
| | | " PRIMARY KEY (`num`)" + |
| | | ") ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;"; |
| | | Sql_Mysql sql = new Sql_Mysql(pool.getConn()); |
| | | try { |
| | | if(true == recreate) { |
| | | sql.sqlMysqlExecute(sql_str01); |
| | | sql.sqlMysqlExecute(sql_str02); |
| | | }else { |
| | | sql.sqlMysqlUseDB(Sql_Mysql.WEB_Site); |
| | | if(sql.sqlMysqlCheckIfTableExist("tb_batt_param_low")) { |
| | | sql.sqlMysqlExecute("DELETE FROM " + Sql_Mysql.BattParamLow_Table); |
| | | } |
| | | sql.sqlMysqlExecute(sql_str02); |
| | | } |
| | | sql.sqlMysqlExecute("INSERT INTO "+Sql_Mysql.BattParamLow_Table+" VALUES ('1', '1', '0', '0.8', '1');"); |
| | | sql.sqlMysqlExecute("INSERT INTO "+Sql_Mysql.BattParamLow_Table+" VALUES ('2', '1', '1', '0.9', '1');"); |
| | | sql.sqlMysqlExecute("INSERT INTO "+Sql_Mysql.BattParamLow_Table+" VALUES ('3', '2', '0', '0.01', '0');"); |
| | | sql.sqlMysqlExecute("INSERT INTO "+Sql_Mysql.BattParamLow_Table+" VALUES ('4', '2', '1', '0.1', '0');"); |
| | | sql.sqlMysqlExecute("INSERT INTO "+Sql_Mysql.BattParamLow_Table+" VALUES ('5', '2', '2', '0.4', '0');"); |
| | | sql.sqlMysqlExecute("INSERT INTO "+Sql_Mysql.BattParamLow_Table+" VALUES ('6', '2', '3', '0.5', '0');"); |
| | | sql.sqlMysqlExecute("INSERT INTO "+Sql_Mysql.BattParamLow_Table+" VALUES ('7', '3', '2', '0.94', '1');"); |
| | | sql.sqlMysqlExecute("INSERT INTO "+Sql_Mysql.BattParamLow_Table+" VALUES ('8', '3', '3', '0.01', '1');"); |
| | | } catch (SQLException e) { |
| | | e.printStackTrace(); |
| | | } finally { |
| | | sql.close_con(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 创建放电计划参数表 |
| | | */ |
| | | public static void createBattDischargeParam_Table(MysqlConnPool pool, boolean recreate) { |
| | | String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.BattDischargeParam_Table; |
| | | String sql_str02 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.BattDischargeParam_Table + " (" + |
| | | " `num` int(11) NOT NULL AUTO_INCREMENT," + |
| | | " `preset_time` int(11) DEFAULT NULL," + |
| | | " `preset_cap` float NOT NULL DEFAULT '0'," + |
| | | " `preset_monvol` float NOT NULL DEFAULT '0'," + |
| | | " `preset_groupvol` float NOT NULL DEFAULT '0'," + |
| | | " `note` varchar(64) COLLATE utf8_unicode_ci NOT NULL DEFAULT ' '," + |
| | | " `param_name` varchar(64) COLLATE utf8_unicode_ci DEFAULT NULL," + |
| | | " `preset_mon` int(11) NOT NULL DEFAULT '0'," + |
| | | " `preset_curr` float NOT NULL DEFAULT '0'," + |
| | | " `chargecurrset` float NOT NULL DEFAULT '0'," + |
| | | " `dcvolhighlimit` float NOT NULL DEFAULT '0'," + |
| | | " PRIMARY KEY (`num`)," + |
| | | " KEY `index_num` (`num`)" + |
| | | ") ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;"; |
| | | Sql_Mysql sql = new Sql_Mysql(pool.getConn()); |
| | | try { |
| | | if(true == recreate) { |
| | | //sql.sqlMysqlExecute(sql_str01); |
| | | //sql.sqlMysqlExecute(sql_str02); |
| | | }else { |
| | | |
| | | } |
| | | sql.sqlMysqlExecute(sql_str02); //创建放电计划参数表 |
| | | } catch (SQLException e) { |
| | | e.printStackTrace(); |
| | | } finally { |
| | | sql.close_con(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 创建放电计划表 |
| | | */ |
| | | public static void createBattDischargePlan_Table(MysqlConnPool pool, boolean recreate) { |
| | | String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.BattDischargePlan_Table; |
| | | String sql_str02 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.BattDischargePlan_Table + " (" + |
| | | " `num` int(11) NOT NULL AUTO_INCREMENT," + |
| | | " `battgroupid` int(11) NOT NULL DEFAULT '0'," + |
| | | " `discharge_starttime` timestamp NOT NULL DEFAULT '1982-01-01 00:00:00'," + |
| | | " `discharge_stoptime` timestamp NOT NULL DEFAULT '1982-01-01 00:00:00'," + |
| | | " `discharge_state` int(11) NOT NULL DEFAULT '0'," + |
| | | " `discharge_reason` varchar(128) COLLATE utf8_unicode_ci NOT NULL DEFAULT ''," + |
| | | " `note` varchar(64) COLLATE utf8_unicode_ci NOT NULL DEFAULT ''," + |
| | | " `discharge_cleartype` int(11) NOT NULL DEFAULT '1'," + |
| | | " `BattIndexInFbs` int(11) NOT NULL DEFAULT '0'," + |
| | | " `preset_time` int(11) NOT NULL DEFAULT '0'," + |
| | | " `preset_cap` float NOT NULL DEFAULT '0'," + |
| | | " `preset_monvol` float NOT NULL DEFAULT '0'," + |
| | | " `preset_groupvol` float NOT NULL DEFAULT '0'," + |
| | | " `preset_mon` int(11) NOT NULL DEFAULT '0'," + |
| | | " `preset_curr` float NOT NULL DEFAULT '0'," + |
| | | " `dcvolhighlimit` float NOT NULL DEFAULT '0'," + |
| | | " `chargecurrset` float NOT NULL DEFAULT '0'," + |
| | | " PRIMARY KEY (`num`)," + |
| | | " KEY `index_num` (`num`)" + |
| | | ") ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;"; |
| | | Sql_Mysql sql = new Sql_Mysql(pool.getConn()); |
| | | try { |
| | | if(true == recreate) { |
| | | //sql.sqlMysqlExecute(sql_str01); |
| | | //sql.sqlMysqlExecute(sql_str02); |
| | | }else { |
| | | } |
| | | sql.sqlMysqlExecute(sql_str02); //创建放电计划表 |
| | | |
| | | //添加放电计划周期列 |
| | | ResultSet res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns" |
| | | + " WHERE table_schema='web_site'" |
| | | + " AND table_name='tb_battdischarge_plan'" |
| | | + " AND column_name='plan_circle'"); |
| | | if(false == res.next()) { |
| | | sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.BattDischargePlan_Table |
| | | + " ADD COLUMN `plan_circle` int NOT NULL DEFAULT '0';"); |
| | | } |
| | | |
| | | //添加放电放电次数列 |
| | | res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns" |
| | | + " WHERE table_schema='web_site'" |
| | | + " AND table_name='tb_battdischarge_plan'" |
| | | + " AND column_name='plan_rate'"); |
| | | if(false == res.next()) { |
| | | sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.BattDischargePlan_Table |
| | | + " ADD COLUMN `plan_rate` int NOT NULL DEFAULT '0';"); |
| | | } |
| | | //添加已放电次数列 |
| | | res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns" |
| | | + " WHERE table_schema='web_site'" |
| | | + " AND table_name='tb_battdischarge_plan'" |
| | | + " AND column_name='already_count'"); |
| | | if(false == res.next()) { |
| | | sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.BattDischargePlan_Table |
| | | + " ADD COLUMN `already_count` int NOT NULL DEFAULT '0';"); |
| | | } |
| | | } catch (SQLException e) { |
| | | e.printStackTrace(); |
| | | } finally { |
| | | sql.close_con(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 创建放电计划规避时间表 |
| | | * @param pool |
| | | * @param recreate |
| | | */ |
| | | private static void createAvoid_plan_Table_Table(MysqlConnPool pool, boolean recreate) { |
| | | String str_str = "CREATE TABLE IF NOT EXISTS "+Sql_Mysql.Avoid_plan_Table+" (" + |
| | | " `num` int(11) NOT NULL AUTO_INCREMENT," + |
| | | " `start_time` timestamp NOT NULL DEFAULT '2000-01-01 00:00:00'," + |
| | | " `start_month` int(11) NOT NULL DEFAULT '1'," + |
| | | " `start_day` int(11) NOT NULL DEFAULT '1'," + |
| | | " `stop_time` timestamp NOT NULL DEFAULT '2000-01-01 00:00:00'," + |
| | | " `stop_month` int(11) NOT NULL DEFAULT '1'," + |
| | | " `stop_day` int(11) NOT NULL DEFAULT '1'," + |
| | | " `note` varchar(64) NOT NULL DEFAULT ''," + |
| | | " PRIMARY KEY (`num`)" + |
| | | ") ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;"; |
| | | Sql_Mysql sql = new Sql_Mysql(pool.getConn()); |
| | | try { |
| | | sql.sqlMysqlExecute(str_str); |
| | | } catch (SQLException e) { |
| | | e.printStackTrace(); |
| | | } finally { |
| | | sql.close_con(); |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 创建基站定位表 |
| | | */ |
| | | public static void createBattMapInformation_Table(MysqlConnPool pool, boolean recreate) { |
| | | String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.BattMapInformation_Table; |
| | | String sql_str02 = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.BattMapInformation_Table + " (" + |
| | | " `num` int(11) NOT NULL AUTO_INCREMENT," + |
| | | " `stationId` varchar(128) NOT NULL," + |
| | | " `stationName` varchar(128) NOT NULL," + |
| | | " `stationName3` varchar(128) DEFAULT ''," + |
| | | " `address` varchar(128) NOT NULL," + |
| | | " `longitude` double(11,8) NOT NULL DEFAULT '0.00000000'," + |
| | | " `latitude` double(11,8) NOT NULL DEFAULT '0.00000000'," + |
| | | " `information` varchar(128) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL DEFAULT ''," + |
| | | " PRIMARY KEY (`num`)," + |
| | | " UNIQUE KEY `stationId_num` (`stationId`) USING BTREE," + |
| | | " KEY `index_num` (`num`)" + |
| | | ") ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;"; |
| | | Sql_Mysql sql = new Sql_Mysql(pool.getConn()); |
| | | ResultSet rs = null; |
| | | try { |
| | | if(true == recreate) { |
| | | //sql.sqlMysqlExecute(sql_str01); |
| | | //sql.sqlMysqlExecute(sql_str02); |
| | | }else { |
| | | } |
| | | sql.sqlMysqlExecute(sql_str02); //创建基站定位表 |
| | | /************************** 添加 stationName3 字段 **************************************/ |
| | | String sql_str03 = " SELECT * FROM information_schema.columns " |
| | | + " WHERE table_schema= 'web_site' " |
| | | + " AND table_name='tb_battmap_information' " |
| | | + " AND column_name='stationName3'"; |
| | | rs = sql.sqlMysqlQuery(sql_str03); |
| | | if(false == rs.next()) { |
| | | sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.BattMapInformation_Table |
| | | + " ADD COLUMN `stationName3` varchar(128) NOT NULL DEFAULT '';"); |
| | | } |
| | | } catch (SQLException e) { |
| | | e.printStackTrace(); |
| | | } finally { |
| | | sql.close_con(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 创建故障基站表 |
| | | */ |
| | | public static void createBattDischarge_Table(MysqlConnPool pool, boolean recreate) { |
| | | String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.BattDischarge_Table; |
| | | String sql_str02 = "CREATE TABLE IF NOT EXISTS "+Sql_Mysql.BattDischarge_Table+" (" + |
| | | " `num` int(11) NOT NULL AUTO_INCREMENT," + |
| | | " `uid` int(11) NOT NULL DEFAULT '1002'," + |
| | | " `dev_id` int(11) NOT NULL DEFAULT '910000001'," + |
| | | " `record_time` datetime NOT NULL DEFAULT '2000-01-01 00:00:00'," + |
| | | " `note` varchar(64) NOT NULL DEFAULT ''," + |
| | | " PRIMARY KEY (`num`)," + |
| | | " UNIQUE KEY `unique_dev_id_index` (`dev_id`) USING BTREE" + |
| | | ") 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); |
| | | } |
| | | sql.sqlMysqlExecute(sql_str02); //创建基站故障表 |
| | | |
| | | } catch (SQLException e) { |
| | | e.printStackTrace(); |
| | | } finally { |
| | | sql.close_con(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 创建数据库备份表 web_site.tb_database_backup |
| | | */ |
| | | public static void createDatabase_Backup_Table(MysqlConnPool pool, boolean recreate) { |
| | | String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.Database_Backup_Table; |
| | | String sql_str02 = "CREATE TABLE IF NOT EXISTS "+Sql_Mysql.Database_Backup_Table+" (" + |
| | | " `num` int(11) NOT NULL AUTO_INCREMENT," + |
| | | " `database_name` varchar(64) NOT NULL," + |
| | | " `table_name` varchar(64) NOT NULL," + |
| | | " `backup_en` int(11) NOT NULL DEFAULT '0'," + |
| | | " `backup_flag` int(11) NOT NULL DEFAULT '0'," + |
| | | " `note` varchar(64) NOT NULL DEFAULT '保留'," + |
| | | " PRIMARY KEY (`num`)" + |
| | | ") ENGINE=InnoDB AUTO_INCREMENT=128 DEFAULT CHARSET=utf8;" + |
| | | ""; |
| | | Sql_Mysql sql = new Sql_Mysql(pool.getConn()); |
| | | try { |
| | | if(true == recreate) { |
| | | //sql.sqlMysqlExecute(sql_str01); |
| | | //sql.sqlMysqlExecute(sql_str02); |
| | | } |
| | | sql.sqlMysqlExecute(sql_str02); //创建基站故障表 |
| | | |
| | | } catch (SQLException e) { |
| | | e.printStackTrace(); |
| | | } finally { |
| | | sql.close_con(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 创建电池组更换记录表 |
| | | */ |
| | | public static void createBattReplace_Table(MysqlConnPool pool, boolean recreate) { |
| | | String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.BattReplace_Table; |
| | | String sql_str02 = "CREATE TABLE IF NOT EXISTS "+Sql_Mysql.BattReplace_Table+" (" + |
| | | " num int(11) NOT NULL AUTO_INCREMENT," + |
| | | " stationid varchar(64) NOT NULL DEFAULT ''," + |
| | | " replaced_producer varchar(64) NOT NULL DEFAULT ''," + |
| | | " replaced_moncapstd int(11) NOT NULL DEFAULT '0'," + |
| | | " replaced_monvolstd float NOT NULL DEFAULT '0'," + |
| | | " replaced_moncount int(11) NOT NULL DEFAULT '0'," + |
| | | " replaced_time datetime NOT NULL DEFAULT '2018-01-01 00:00:00'," + |
| | | " replaced_uid int(11) NOT NULL DEFAULT '0'," + |
| | | " replaced_reason varchar(256) NOT NULL DEFAULT ''," + |
| | | " note varchar(64) NOT NULL DEFAULT ''," + |
| | | " replace_date date DEFAULT '2020-04-20'," + |
| | | " PRIMARY KEY (`num`)," + |
| | | " KEY `stationid_index` (`stationid`)" + |
| | | ") 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); |
| | | } |
| | | sql.sqlMysqlExecute(sql_str02); //创建电池组更换记录表 |
| | | /************************** 添加 replace_date 字段 **************************************/ |
| | | String sql_str03 = " SELECT * FROM information_schema.columns " |
| | | + " WHERE table_schema= 'web_site' " |
| | | + " AND table_name='tb_batt_replace' " |
| | | + " AND column_name='replace_date'"; |
| | | ResultSet rs = sql.sqlMysqlQuery(sql_str03); |
| | | if(false == rs.next()) { |
| | | sql.sqlMysqlExecute(" ALTER TABLE " + Sql_Mysql.BattReplace_Table |
| | | + " ADD COLUMN replace_date date DEFAULT '2020-04-20';"); |
| | | } |
| | | /************************** 添加 GroupIndexInFBSDevice 字段表明是那一组电池 **************************************/ |
| | | sql_str03 = " SELECT * FROM information_schema.columns " |
| | | + " WHERE table_schema= 'web_site' " |
| | | + " AND table_name='tb_batt_replace' " |
| | | + " AND column_name='GroupIndexInFBSDevice'"; |
| | | rs = sql.sqlMysqlQuery(sql_str03); |
| | | if(false == rs.next()) { |
| | | sql.sqlMysqlExecute(" ALTER TABLE " + Sql_Mysql.BattReplace_Table |
| | | + " ADD COLUMN GroupIndexInFBSDevice int(11) NOT NULL DEFAULT '0';"); |
| | | } |
| | | } catch (SQLException e) { |
| | | e.printStackTrace(); |
| | | } finally { |
| | | sql.close_con(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 创建设备重启计划表 |
| | | * @param pool |
| | | * @param recreate |
| | | */ |
| | | public static void createDev_Restart_PlanTable(MysqlConnPool pool, boolean recreate) { |
| | | String sql_str_del = " DROP TABLE IF EXISTS "+Sql_Mysql.Dev_Restart_Plan_Table; |
| | | String sql_str = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.Dev_Restart_Plan_Table + " (" + |
| | | " num bigint(20) NOT NULL AUTO_INCREMENT," + |
| | | " dev_id int(11) NOT NULL DEFAULT '0' COMMENT '设备id'," + |
| | | " restart_starttime datetime NOT NULL DEFAULT '2000-01-01 00:00:00' COMMENT '重启开始时间'," + |
| | | " restart_cycle int(11) NOT NULL DEFAULT '1' COMMENT '重启周期'," + |
| | | " restart_en int(11) NOT NULL DEFAULT '0' COMMENT '重启使能 0:不启用 ;1:启用'," + |
| | | " note varchar(255) NOT NULL DEFAULT '' COMMENT '备用'," + |
| | | " PRIMARY KEY (`num`)," + |
| | | " UNIQUE KEY `index_dev_id` (`dev_id`) USING BTREE" + |
| | | ") ENGINE=InnoDB DEFAULT CHARSET=utf8;"; |
| | | Sql_Mysql sql = new Sql_Mysql(pool.getConn()); |
| | | ResultSet res = null; |
| | | try { |
| | | if(recreate) { |
| | | sql.sqlMysqlExecute(sql_str_del); |
| | | } |
| | | sql.sqlMysqlExecute(sql_str); |
| | | //添加上一次重启时间字段 |
| | | res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns" |
| | | + " WHERE table_schema='web_site'" |
| | | + " AND table_name='tb_dev_restart_plan'" |
| | | + " AND column_name='last_restarttime'"); |
| | | if(false == res.next()) { |
| | | sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.Dev_Restart_Plan_Table |
| | | + " ADD COLUMN last_restarttime datetime NOT NULL DEFAULT '2000-01-01 00:00:00' COMMENT '上一次重启时间';"); |
| | | } |
| | | } catch (SQLException e) { |
| | | e.printStackTrace(); |
| | | } finally { |
| | | if(res != null) { |
| | | try { |
| | | res.close(); |
| | | } catch (SQLException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | sql.close_con(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 创建新版本平台注册信息表 |
| | | * @param pool |
| | | * @param recreate |
| | | */ |
| | | public static void createLicense_Table(MysqlConnPool pool, boolean recreate) { |
| | | String sql_str_del = " DROP TABLE IF EXISTS "+Sql_Mysql.License_Table; |
| | | String sql_str = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.License_Table + " (" + |
| | | " `id` int(11) NOT NULL AUTO_INCREMENT," + |
| | | " `serialNumber` varchar(255) NOT NULL DEFAULT ''," + |
| | | " `duration` varchar(255) NOT NULL DEFAULT '0'," + |
| | | " `timeInUse` varchar(255) NOT NULL DEFAULT '0'," + |
| | | " PRIMARY KEY (`id`) USING BTREE" + |
| | | ") ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;"; |
| | | Sql_Mysql sql = new Sql_Mysql(pool.getConn()); |
| | | ResultSet res = null; |
| | | try { |
| | | if(recreate) { |
| | | sql.sqlMysqlExecute(sql_str_del); |
| | | } |
| | | sql.sqlMysqlExecute(sql_str); |
| | | //修改注册时长信息 |
| | | res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns" |
| | | + " WHERE table_schema='web_site'" |
| | | + " AND table_name='tb_license'" |
| | | + " AND column_name='duration'" |
| | | + " AND DATA_TYPE = 'varchar'"); |
| | | if(false == res.next()) { |
| | | //System.out.println("###############"); |
| | | sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.License_Table |
| | | + " modify COLUMN `duration` varchar(255) NOT NULL DEFAULT '0';"); |
| | | } |
| | | res =null; |
| | | //修改已用时长字段 |
| | | res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns" |
| | | + " WHERE table_schema='web_site'" |
| | | + " AND table_name='tb_license'" |
| | | + " AND column_name='timeInUse'" |
| | | + " AND DATA_TYPE = 'varchar'"); |
| | | if(false == res.next()) { |
| | | sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.License_Table |
| | | + " modify COLUMN `timeInUse` varchar(255) NOT NULL DEFAULT '0';"); |
| | | } |
| | | } catch (SQLException e) { |
| | | e.printStackTrace(); |
| | | } finally { |
| | | if(res != null) { |
| | | try { |
| | | res.close(); |
| | | } catch (SQLException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | sql.close_con(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 创建超级用户表 |
| | | * @param pool |
| | | * @param recreate |
| | | */ |
| | | public static void createVip_User_Table(MysqlConnPool pool, boolean recreate) { |
| | | String sql_str_del = " DROP TABLE IF EXISTS "+Sql_Mysql.Vip_User_Table; |
| | | String sql_str = "CREATE TABLE IF NOT EXISTS " + Sql_Mysql.Vip_User_Table + " (" + |
| | | " `num` int(11) NOT NULL AUTO_INCREMENT," + |
| | | " `vipname` varchar(64) COLLATE utf8_unicode_ci DEFAULT NULL," + |
| | | " `vipSnid` varchar(64) COLLATE utf8_unicode_ci DEFAULT NULL," + |
| | | " `vipPassword` varchar(64) COLLATE utf8_unicode_ci DEFAULT NULL," + |
| | | " PRIMARY KEY (`num`)" + |
| | | ") ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;"; |
| | | Sql_Mysql sql = new Sql_Mysql(pool.getConn()); |
| | | String sql_str_sel = "SELECT * FROM "+Sql_Mysql.Vip_User_Table+" WHERE vipname = 'vip';"; |
| | | ResultSet res = null; |
| | | try { |
| | | if(recreate) { |
| | | sql.sqlMysqlExecute(sql_str_del); |
| | | } |
| | | sql.sqlMysqlExecute(sql_str); |
| | | //添加上一次重启时间字段 |
| | | res = sql.sqlMysqlQuery(sql_str_sel); |
| | | if(false == res.next()) { |
| | | //不存在默认vip账号则 |
| | | sql.sqlMysqlExecute("INSERT INTO "+Sql_Mysql.Vip_User_Table+"(vipname,vipSnid,vipPassword) VALUES ('vip', 'vip', '232059cb5361a9336ccf1b8c2ba7657a');"); |
| | | } |
| | | } catch (SQLException e) { |
| | | e.printStackTrace(); |
| | | } finally { |
| | | if(res != null) { |
| | | try { |
| | | res.close(); |
| | | } catch (SQLException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | sql.close_con(); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 设置指定的线程重启[ 告警线程; ] |
| | | */ |
| | | public static void setUpThreadRestart(MysqlConnPool conn_pool) { |
| | | //重启告警线程 |
| | | String sql_str = "UPDATE " + Sql_Mysql.ProcessSurvey_Table |
| | | + " SET ServerFlag = 0 " |
| | | + " WHERE ProcessId = 11002 AND ServerFlag != 2"; |
| | | Sql_Mysql sql = new Sql_Mysql(conn_pool.getConn()); |
| | | try { |
| | | sql.sqlMysqlExecute(sql_str); |
| | | } 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(); |
| | | //website.createBattReplace_Table(pool, false); |
| | | website.createAvoid_plan_Table_Table(pool, false); |
| | | |
| | | } |
| | | } |