| | |
| | | " UNIQUE KEY index_electric2KW_id (electric2KW_id) USING BTREE" + |
| | | ") ENGINE=InnoDB DEFAULT CHARSET=utf8; "; |
| | | Sql_Mysql sql = new Sql_Mysql(pool.getConn()); |
| | | ResultSet res = null; |
| | | try { |
| | | //添加记录时间列,方便绘制实时曲线 |
| | | res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns" |
| | | + " WHERE table_schema='db_electric2mwsystem'" |
| | | + " AND table_name='tb_electric2MW_state'" |
| | | + " AND column_name='record_time'"); |
| | | if(false == res.next()) { |
| | | sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.Tb_electric2MW_state |
| | | + " ADD COLUMN `record_time` datetime NOT NULL DEFAULT '2000-01-01 00:00:00' after 'electric2KW_id';"); |
| | | } |
| | | |
| | | sql.sqlMysqlExecute(sql_str); |
| | | } catch (SQLException e) { |
| | | e.printStackTrace(); |
| | | } finally { |
| | | if(res != null) { |
| | | try { |
| | | res.close(); |
| | | } catch (SQLException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | sql.close_con(); |
| | | } |
| | | } |
| | |
| | | public static void update_Electric_State_2KW(MysqlConnPool conn_pool, Electric_State_2kw state) { |
| | | String sql_str = " UPDATE "+Sql_Mysql.Tb_electric2MW_state + |
| | | " Set brachdcvol= " + state.brachdcvol + |
| | | ",brachdccurr=" + state.brachdccurr + |
| | | ",record_time='" + Com.getDateTimeFormat(new Date(), Com.DTF_YMDhms) + |
| | | "',brachdccurr=" + state.brachdccurr + |
| | | ",alldcvol=" + state.alldcvol + |
| | | ",alldccurr=" + state.alldccurr + |
| | | ",stopchargevol_one=" + state.stopchargevol_one + |