| | |
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 创建电池组更换记录表
|
| | | */
|
| | | 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';");
|
| | | }
|
| | | } catch (SQLException e) {
|
| | | e.printStackTrace();
|
| | | } finally {
|
| | | 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);
|
| | | MysqlConnPool pool = new MysqlConnPool("127.0.0.1", 3360, 10);
|
| | | DB_web_site website = new DB_web_site();
|
| | | website.createThread_utilTable(pool, false);
|
| | | website.createBattReplace_Table(pool, false);
|
| | | }
|
| | | }
|