From 0abbcf35eaf96779789d39af203a6381eccef2b7 Mon Sep 17 00:00:00 2001
From: DELL <1525436766@qq.com>
Date: 星期二, 22 四月 2025 10:18:32 +0800
Subject: [PATCH] V1.114 edit by lijun 2025-04-22 	1.新增定时开启以及关闭蓝牙功能。 	2.添加读取锁具已授权ID卡信息功能。

---
 ElectLock_Monitor/src/com/dev/lock/comm/Lock_Task_SQL.java |  160 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 160 insertions(+), 0 deletions(-)

diff --git a/ElectLock_Monitor/src/com/dev/lock/comm/Lock_Task_SQL.java b/ElectLock_Monitor/src/com/dev/lock/comm/Lock_Task_SQL.java
index 3b033e1..ef45874 100644
--- a/ElectLock_Monitor/src/com/dev/lock/comm/Lock_Task_SQL.java
+++ b/ElectLock_Monitor/src/com/dev/lock/comm/Lock_Task_SQL.java
@@ -8,6 +8,7 @@
 
 import com.base.Com;
 import com.dev.lock.data.ElectLock_AuthIdcard;
+import com.dev.lock.data.ElectLock_Bl;
 import com.dev.lock.data.ElectLock_ComBase;
 import com.dev.lock.data.ElectLock_Ctl_Log;
 import com.dev.lock.data.ElectLock_Inf;
@@ -476,4 +477,163 @@
 			sql.close_con();
 		}
 	}
+	
+	/**
+	 * 	鎻掑叆榛樿鐨処D鍗′俊鎭�
+	 * @param pool
+	 * @param client_id
+	 */
+	public static void insertLock_IdCard_Table(MysqlConnPool pool, int lock_id) {
+		String sql_str_sel = " SELECT * FROM " + Sql_Mysql.Lock_IdCard_Table + " WHERE lock_id =  " + lock_id;
+		String sql_str_ins = " INSERT INTO " + Sql_Mysql.Lock_IdCard_Table + "(lock_id) VALUES(" + lock_id + ");";
+		Sql_Mysql sql = new Sql_Mysql(pool.getConn());
+		ResultSet res = null;
+		try {
+			res = sql.sqlMysqlQuery(sql_str_sel);
+			if(!res.next()) {
+				sql.sqlMysqlExecute(sql_str_ins);
+			}
+		} catch (SQLException e) {
+			sql.logger.error(e.toString(),e);
+		} finally {
+			if(null != res) {
+				try {
+					res.close();
+				} catch (SQLException e) {
+					sql.logger.error(e.toString(),e);
+				}
+			}
+			sql.close_con();
+		}
+	}
+	
+	/**
+	 * 	鎻掑叆榛樿鐨処D鍗′俊鎭�
+	 * @param pool
+	 * @param client_id
+	 */
+	public static void insertLock_Rt_Table(MysqlConnPool pool, int lock_id) {
+		String sql_str_sel = " SELECT * FROM " + Sql_Mysql.Lock_Rt_Table + " WHERE lock_id =  " + lock_id;
+		String sql_str_ins = " INSERT INTO " + Sql_Mysql.Lock_Rt_Table + "(lock_id) VALUES(" + lock_id + ");";
+		Sql_Mysql sql = new Sql_Mysql(pool.getConn());
+		ResultSet res = null;
+		try {
+			res = sql.sqlMysqlQuery(sql_str_sel);
+			if(!res.next()) {
+				sql.sqlMysqlExecute(sql_str_ins);
+			}
+		} catch (SQLException e) {
+			sql.logger.error(e.toString(),e);
+		} finally {
+			if(null != res) {
+				try {
+					res.close();
+				} catch (SQLException e) {
+					sql.logger.error(e.toString(),e);
+				}
+			}
+			sql.close_con();
+		}
+	}
+	
+	/**
+	 * 	鏇寸粏褰撳墠閿佸叿鐨処D鍗�
+	 * @param pool
+	 * @param client_id
+	 */
+	public static void updateLock_IdCard_Table(MysqlConnPool pool, ElectLock_State state) {
+		StringBuffer sql_str = new StringBuffer(" UPDATE " + Sql_Mysql.Lock_IdCard_Table + " SET ");
+		for(int k = 0;k<state.getId_cards().length;k++) {
+			if(k > 0) {
+				sql_str.append(",") ;
+			}
+			sql_str.append("card" + (k+1) + " = '" + state.getId_cards()[k] + "'") ;
+		}
+		sql_str.append(" WHERE lock_id =   " + state.getLock_id()) ;
+		Sql_Mysql sql = new Sql_Mysql(pool.getConn());
+		try {
+			sql.sqlMysqlExecute(sql_str.toString());
+		} catch (SQLException e) {
+			sql.logger.error(e.toString(),e);
+		} finally {
+			sql.close_con();
+		}
+	} 
+	
+	/**
+	 * 鏌ヨ褰撳墠闇�瑕佸紑鍚摑鐗欑殑璁″垝
+	 * @param pool
+	 * @param lock_id
+	 * @return
+	 */
+	public static ElectLock_Bl queryBluetoothOpenPlan(MysqlConnPool pool,int lock_id) {
+		ElectLock_Bl bl = null;
+		String sql_str_sel = "SELECT * FROM " + Sql_Mysql.Lock_BL_Table 
+							+ " WHERE NOW() BETWEEN start_time AND DATE_ADD(start_time,INTERVAL " + ElectLock_ComBase.Lock_BluetoothCheckTimeLong + " SECOND)"
+							+ " and type = 1 AND lock_id = " + lock_id;
+		Sql_Mysql sql = new Sql_Mysql(pool.getConn());
+		ResultSet res = null;
+		try {
+			res = sql.sqlMysqlQuery(sql_str_sel);
+			if(res.next()) {
+				bl = new ElectLock_Bl();
+				bl.setLock_id(lock_id);
+				bl.setCreate_time(res.getTimestamp("create_time"));
+				bl.setStart_time(res.getTime("start_time"));
+				bl.setStop_time(res.getTime("stop_time"));
+				bl.setType(res.getInt("type"));
+			}
+		} catch (SQLException e) {
+			sql.logger.error(e.toString(),e);
+		} finally {
+			if(null != res) {
+				try {
+					res.close();
+				} catch (SQLException e) {
+					sql.logger.error(e.toString(),e);
+				}
+			}
+			sql.close_con();
+		}
+		return bl;
+	}
+	
+	/**
+	 * 鏌ヨ褰撳墠闇�瑕佸紑鍚摑鐗欑殑璁″垝
+	 * @param pool
+	 * @param lock_id
+	 * @return
+	 */
+	public static ElectLock_Bl queryBluetoothClosePlan(MysqlConnPool pool,int lock_id) {
+		ElectLock_Bl bl = null;
+		String sql_str_sel = "SELECT * FROM " + Sql_Mysql.Lock_BL_Table 
+							+ " WHERE NOW() BETWEEN stop_time AND DATE_ADD(stop_time,INTERVAL " + ElectLock_ComBase.Lock_BluetoothCheckTimeLong + " SECOND)"
+							+ " and type = 1 AND lock_id = " + lock_id;
+		Sql_Mysql sql = new Sql_Mysql(pool.getConn());
+		ResultSet res = null;
+		try {
+			res = sql.sqlMysqlQuery(sql_str_sel);
+			if(res.next()) {
+				bl = new ElectLock_Bl();
+				bl.setLock_id(lock_id);
+				bl.setCreate_time(res.getTimestamp("create_time"));
+				bl.setStart_time(res.getTime("start_time"));
+				bl.setStop_time(res.getTime("stop_time"));
+				bl.setType(res.getInt("type"));
+			}
+		} catch (SQLException e) {
+			sql.logger.error(e.toString(),e);
+		} finally {
+			if(null != res) {
+				try {
+					res.close();
+				} catch (SQLException e) {
+					sql.logger.error(e.toString(),e);
+				}
+			}
+			sql.close_con();
+		}
+		return bl;
+	}
+	
 }

--
Gitblit v1.9.1