From 351bbd8738c89c0302465360c1ca0c92abd18eba Mon Sep 17 00:00:00 2001 From: DELL <1525436766@qq.com> Date: 星期五, 07 二月 2025 13:34:35 +0800 Subject: [PATCH] 新增统计月份,季度,年度统计开锁次数 --- ElectLock_Monitor/src/com/dev/lock/comm/Lock_Task_SQL.java | 124 +++++++++++++++++++++++++++++++++++++++- 1 files changed, 119 insertions(+), 5 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 f1a8a40..9ac63d4 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 @@ -10,6 +10,8 @@ import com.dev.lock.data.ElectLock_AuthIdcard; import com.dev.lock.data.ElectLock_ComBase; import com.dev.lock.data.ElectLock_Ctl_Log; +import com.dev.lock.data.ElectLock_Inf; +import com.dev.lock.data.ElectLock_Report; import com.dev.lock.data.ElectLock_State; import com.sql.MysqlConnPool; import com.sql.Sql_Mysql; @@ -81,13 +83,13 @@ * @param lock_id * @param state */ - public static void updateLock_Inf_Table(MysqlConnPool pool,int lock_id,ElectLock_State state) { + public static void updateLock_Inf_Table(MysqlConnPool pool,ElectLock_Inf inf,ElectLock_State state) { String sql_str = "UPDATE " + Sql_Mysql.Lock_Inf_Table + " Set lock_state = " + state.getLock_state() + " ,lock_online = " + state.getLock_online() + " ,lock_mac = '" + state.getLockMacAddr() + "'" + - " ,last_update_time = NOW() " + - " WHERE lock_id = " + lock_id; + " ,last_update_time = '" + Com.getDateTimeFormat(inf.getLast_update_time(), Com.DTF_YMDhms) + "'" + + " WHERE lock_id = " + inf.getLock_id(); Sql_Mysql sql = new Sql_Mysql(pool.getConn()); try { sql.sqlMysqlExecute(sql_str); @@ -263,11 +265,11 @@ Sql_Mysql sql = new Sql_Mysql(pool.getConn()); ResultSet res = null; try { - System.out.println("====="+sql_str); + //System.out.println("====="+sql_str); res = sql.sqlMysqlQuery(sql_str); if(res.next()) { uname = res.getString("uname"); - System.out.println("uname:" + uname); + //System.out.println("uname:" + uname); } } catch (SQLException e) { sql.logger.error(e.toString(),e); @@ -283,4 +285,116 @@ } return uname; } + + + public static void updateProcess_StartTime(MysqlConnPool pool, double mVersionnum) { + String sql_str = "UPDATE " + Sql_Mysql.Process_Survey_Table + + " Set Process_starttime = NOW() " + + " ,ProcessTime = NOW() " + + " ,ProcessVersion = 'V" + mVersionnum + "'"+ + " WHERE ProcessId = 11001"; + Sql_Mysql sql = new Sql_Mysql(pool.getConn()); + try { + sql.sqlMysqlExecute(sql_str); + } catch (SQLException e) { + sql.logger.error(e.toString(),e); + } finally { + sql.close_con(); + } + } + + public static void updateProcess_ProcessTime(MysqlConnPool pool) { + String sql_str = "UPDATE " + Sql_Mysql.Process_Survey_Table + + " Set ProcessTime = NOW() " + + " WHERE ProcessId = 11001"; + Sql_Mysql sql = new Sql_Mysql(pool.getConn()); + try { + sql.sqlMysqlExecute(sql_str); + } catch (SQLException e) { + sql.logger.error(e.toString(),e); + } finally { + sql.close_con(); + } + } + + public static void queryLock_Rt_TableByLockId(MysqlConnPool pool,int lock_id,ElectLock_State state) { + String sql_str = " SELECT * FROM " + Sql_Mysql.Lock_Rt_Table + " WHERE lock_id = " + lock_id; + Sql_Mysql sql = new Sql_Mysql(pool.getConn()); + ResultSet res = null; + try { + res = sql.sqlMysqlQuery(sql_str); + if(res.next()) { + state.setGprs_sn(res.getString("gprs_sn")); //'gprs妯″潡SN鐮�', + state.setClient_ip(res.getString("client_ip")); //'璁惧IP鍦板潃', + state.setAlready_id_count(res.getInt("already_id_count")); //'褰撳墠閿佸凡鎺堟潈鍗℃暟閲�', + state.setMax_id_count(res.getInt("max_id_count")); //'鎺堟潈鍗℃暟閲忓瓨鍌ㄤ笂闄�', + state.setLock_state(res.getInt("lock_state")); //'鐢靛瓙閿佺姸鎬乕0-鍏� 1-寮�]', + state.setLock_version(res.getString("lock_version")); //'杞欢鐗堟湰鍙�', + state.setUnlock_type(res.getInt("unlock_type")); //'涓婁竴娆″紑閿佹柟寮廩0-485寮�閿� 1-鍒峰崱寮�閿� 2-钃濈墮寮�閿� 3-DI寮�閿乚', + state.setUnlock_id(res.getInt("unlock_id")); //'涓婁竴娆″埛寮�寮�閿佸崱鍙穂浠呭埛寮�寮�閿佹椂鏈夋晥]', + state.setLock_addr(res.getInt("lock_addr")); //'璁惧鍦板潃', + state.setComm_count(res.getInt("comm_count")); //'閫氫俊璁℃暟', + state.setErr_tol_count(res.getInt("err_tol_count")); //'鎬婚敊璇鏁�', +// state.setErr_count(res.getInt("err_count")); //'杩炵画閿欒璁℃暟', + state.setOp_cmd(res.getInt("op_cmd")); //'鎺у埗鍛戒护', + state.setId_card_set(res.getInt("id_card_set")); //'鎺堟潈ID鍗″彿', + state.setLock_addr_set(res.getInt("lock_addr_set"));; //'璁剧疆璁惧鍦板潃[鎱庣敤]', + + } + } 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(); + } + + } + + public static void queryLock_Report_TableByLockId(MysqlConnPool pool,int lock_id,ElectLock_Report state,int now_year) { + String sql_str = " SELECT * FROM " + Sql_Mysql.Lock_Report_Table + " WHERE lock_id = " + lock_id + " AND record_year = " + now_year; + Sql_Mysql sql = new Sql_Mysql(pool.getConn()); + ResultSet res = null; + try { + res = sql.sqlMysqlQuery(sql_str); + if(res.next()) { + + state.record_year = res.getInt("record_year"); //缁熻骞翠唤', + state.month1 = res.getInt("month1"); //1鏈堝紑閿佹鏁�', + state.month2 = res.getInt("month2"); //2鏈堝紑閿佹鏁�', + state.month3 = res.getInt("month3"); //3鏈堝紑閿佹鏁�', + state.month4 = res.getInt("month4"); //4鏈堝紑閿佹鏁�', + state.month5 = res.getInt("month5"); //5鏈堝紑閿佹鏁�', + state.month6 = res.getInt("month6"); //6鏈堝紑閿佹鏁�', + state.month7 = res.getInt("month7"); //7鏈堝紑閿佹鏁�', + state.month8 = res.getInt("month8"); //8鏈堝紑閿佹鏁�', + state.month9 = res.getInt("month9"); //9鏈堝紑閿佹鏁�', + state.month10 = res.getInt("month10"); //10鏈堝紑閿佹鏁�', + state.month11 = res.getInt("month11"); //11鏈堝紑閿佹鏁�', + state.month12 = res.getInt("month12"); //12鏈堝紑閿佹鏁�', + state.quarter1 = res.getInt("quarter1"); //绗竴瀛e害寮�閿佹鏁�', + state.quarter2 = res.getInt("quarter2"); //绗簩瀛e害寮�閿佹鏁�', + state.quarter3 = res.getInt("quarter3"); //绗笁瀛e害寮�閿佹鏁�', + state.quarter4 = res.getInt("quarter4"); //绗洓瀛e害寮�閿佹鏁�', + state.year_count = res.getInt("year_count"); //鏈勾寮�閿佹鏁�', + } + } 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(); + } + + } } -- Gitblit v1.9.1