From 8983244985c5509c6342afb3dbee53a4de5f7e55 Mon Sep 17 00:00:00 2001
From: Administrator <1525436766@qq.com>
Date: 星期四, 27 十月 2022 10:18:32 +0800
Subject: [PATCH] V1.44 edit at date 2022-10-27 	1.新增电操开关表'db_ram_db.tb_dev_60870_inverter_info'和'db_ram_db.tb_dev_60870_inverter_state'

---
 BattMonitor_DB_Builder/src/com/dev/fbs9100/FBS9100_Task_Thread_SQL.java |  128 ++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 128 insertions(+), 0 deletions(-)

diff --git a/BattMonitor_DB_Builder/src/com/dev/fbs9100/FBS9100_Task_Thread_SQL.java b/BattMonitor_DB_Builder/src/com/dev/fbs9100/FBS9100_Task_Thread_SQL.java
index d06e345..40c16c3 100644
--- a/BattMonitor_DB_Builder/src/com/dev/fbs9100/FBS9100_Task_Thread_SQL.java
+++ b/BattMonitor_DB_Builder/src/com/dev/fbs9100/FBS9100_Task_Thread_SQL.java
@@ -1202,6 +1202,134 @@
 		}		
 	}
 	
+	public static void insertDatatb_user_log(MysqlConnPool pool,String sql_str) {
+//		String sql_str = "INSERT INTO" + 
+//						" db_user.tb_user_log(uid,uOprateMsg,operation_detail)" + 
+//							" VALUES(1001,'测试数据','测试插入数据'); ";
+		Sql_Mysql sql = new Sql_Mysql(pool.getConn());
+		try {
+			//System.err.println(sql_str);
+			sql.sqlMysqlExecute(sql_str);
+		} catch (SQLException e) {
+			e.printStackTrace();
+		} finally{
+			sql.close_con();
+		}
+		
+	}
+	public static void insertDatatb_user_limit(MysqlConnPool pool,String sql_str) {
+		//String sql_str = "INSERT INTO db_user.tb_user_limit(userId,limitDuration,loginTime) VALUES(11,2502,NOW()); ";
+		Sql_Mysql sql = new Sql_Mysql(pool.getConn());
+		try {
+			sql.sqlMysqlExecute(sql_str);
+		} catch (SQLException e) {
+			e.printStackTrace();
+		} finally{
+			sql.close_con();
+		}
+		
+	}
+	
+	
+	/**
+	 * 创建用户操作日志表
+	 * @param pool
+	 * @param recreate
+	 */
+	public static void createUser_Log_Table(MysqlConnPool pool, boolean recreate) {
+		String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.User_Log_Table;
+		String sql_str02 = "CREATE TABLE  IF NOT EXISTS " + Sql_Mysql.User_Log_Table + " (" + 
+				"  `num` bigint(20) NOT NULL AUTO_INCREMENT," + 
+				"  `uId` int(11) NOT NULL DEFAULT '0'," + 
+				"  `uOprateType` int(11) NOT NULL DEFAULT '0'," + 
+				"  `uOprateDay` datetime NOT NULL DEFAULT '1980-01-01 00:00:00'," + 
+				"  `uTerminalIp` varchar(20) NOT NULL DEFAULT ' '," + 
+				"  `uOprateMsg` varchar(250) NOT NULL DEFAULT ' '," + 
+				"  PRIMARY KEY (`num`)," + 
+				"  KEY `user_id` (`uId`)" + 
+				") ENGINE=InnoDB AUTO_INCREMENT=7293 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);
+			
+			//添加operation_detail
+			res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
+					+ " WHERE table_schema='db_user'"
+					+ " AND table_name='tb_user_log'"
+					+ " AND column_name='operation_detail'");
+			if(false == res.next()) {
+				sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.User_Log_Table 
+								+ " ADD COLUMN `operation_detail` text COMMENT '操作的具体数据';");
+			}else{
+				//修改当前字段的类型
+				sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.User_Log_Table 
+						+ " CHANGE `operation_detail` `operation_detail` text COMMENT '操作的具体数据';");
+			}
+			
+			//修改uOprateMsg格式为text
+			res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
+					+ " WHERE table_schema='db_user'"
+					+ " AND table_name='tb_user_log'"
+					+ " AND column_name='uOprateMsg'");
+			if(res.next()) {
+				//修改当前字段的类型为text
+				sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.User_Log_Table 
+						+ " CHANGE `uOprateMsg` `uOprateMsg` text;");
+			}
+			
+			
+			//添加read_flag
+			res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
+					+ " WHERE table_schema='db_user'"
+					+ " AND table_name='tb_user_log'"
+					+ " AND column_name='read_flag'");
+			if(false == res.next()) {
+				sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.User_Log_Table 
+								+ " ADD COLUMN `read_flag` tinyint(1) DEFAULT '1' COMMENT '是否已阅读,此功能针对异常信息'");
+			}
+		} catch (SQLException e) {
+			e.printStackTrace();
+		} finally {
+			if(res != null) {
+				try {
+					res.close();
+				} catch (SQLException e) {
+					e.printStackTrace();
+				}
+			}
+			sql.close_con();
+		}
+	}
+	
+	/**
+	 * 
+	 */
+	public static void createUser_Limit_Table(MysqlConnPool pool, boolean recreate) {
+		String sql_str01 = " DROP TABLE IF EXISTS "+Sql_Mysql.User_Limit_Table;
+		String sql_str02 = "CREATE TABLE  IF NOT EXISTS " + Sql_Mysql.User_Limit_Table + " (" + 
+				"  `id` int(11) NOT NULL AUTO_INCREMENT," + 
+				"  `userId` int(11) DEFAULT NULL," + 
+				"  `limitDuration` int(3) DEFAULT NULL COMMENT '限制时间,单位:秒'," + 
+				"  `loginTime` datetime DEFAULT NULL COMMENT '登录时间'," + 
+				"  PRIMARY KEY (`id`)" + 
+				") ENGINE=InnoDB AUTO_INCREMENT=36 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 main(String[] args) {
 		MysqlConnPool pool = new MysqlConnPool("127.0.0.1", 3360, 100);
 		FBS9100_Task_Thread_SQL thread = new FBS9100_Task_Thread_SQL();

--
Gitblit v1.9.1