Browse Source

修复限制人员入井逻辑,修改时

lixioayao 6 years ago
parent
commit
1f9b7a1e1b
3 changed files with 19 additions and 10 deletions
  1. 17 8
      forbid_staff_down_mine.cpp
  2. 1 1
      forbid_staff_down_mine.h
  3. 1 1
      module_service/module_meta_date_changed.cpp

+ 17 - 8
forbid_staff_down_mine.cpp

@@ -3,13 +3,13 @@
 #include "tool_time.h"
 #include "db_api/CDBSingletonDefine.h"
 
-void forbid_staff_down_mine::init_forbid_staff(int id /* = -1*/)
+void forbid_staff_down_mine::init_forbid_staff(int id /* = -1*/,int etype)
 {
-    std::string sql = "select id,staff_id,start_time,end_time,status,oper_time,lastupdate from rt_person_forbid_down_mine where status = 1 and end_time > now() ";
+    std::string sql = "select id,staff_id,start_time,end_time,status,oper_time,lastupdate from rt_person_forbid_down_mine where ";
     if (id != -1)
-        sql += " and id = " + std::to_string(id) + ";";
+        sql += " id = " + std::to_string(id) + ";";
     else
-        sql += ";";
+        sql += "status = 1 and end_time > now();";
     std::string Error;
     YADB::CDBResultSet DBRes;
     sDBConnPool.Query(sql.c_str(),DBRes,Error);
@@ -35,6 +35,8 @@ void forbid_staff_down_mine::init_forbid_staff(int id /* = -1*/)
         DBRes.GetField("oper_time", create_time, Error);
         std::string update_time;
         DBRes.GetField("lastupdate", update_time, Error);
+        time_t stime = tool_time::to_time(start_time);
+        time_t etime = tool_time::to_time(end_time);
         std::shared_ptr<SForbidStaffList> s = forbid_staff_down_mine::instance()->get(staff_id);
         //如果存在则查找更新。查找不到则插入
         if (s)
@@ -46,8 +48,8 @@ void forbid_staff_down_mine::init_forbid_staff(int id /* = -1*/)
                 if (info.db_id == key)
                 {
                     f=true;
-                    info.start_time = tool_time::to_time(start_time);
-                    info.end_time = tool_time::to_time(end_time);
+                    info.start_time =stime;
+                    info.end_time =etime;
                     info.state = state;
                     log_info("Check Forbid_staff_down_mine DBID:%d Staff:%d State:%d Time:%s -> %s . "
                                 ,key,staff_id,state,start_time.c_str(),end_time.c_str());
@@ -55,6 +57,13 @@ void forbid_staff_down_mine::init_forbid_staff(int id /* = -1*/)
                 }
             }
             if(f)continue;
+            //ET_UPDATE
+            if(id !=-1 && etype ==2)
+            {
+                time_t now= time(0);
+                if(state!=1 || now>etime)
+                    continue;
+            }
         }
         else
         {
@@ -65,8 +74,8 @@ void forbid_staff_down_mine::init_forbid_staff(int id /* = -1*/)
         SForbidStaffInfo info ;
         info.staff_id = staff_id;
         info.db_id = key;
-        info.start_time = tool_time::to_time(start_time);
-        info.end_time = tool_time::to_time(end_time);
+        info.start_time = stime;
+        info.end_time =etime;
         info.state = state;
 
         log_info("Init Forbid_staff_down_mine DBID:%d Staff:%d State:%d Time:%s -> %s . "

+ 1 - 1
forbid_staff_down_mine.h

@@ -39,7 +39,7 @@ struct forbid_staff_down_mine
 {
 public:
     // 根据数据库中的自增长id
-    void init_forbid_staff(int id = -1);
+    void init_forbid_staff(int id = -1,int etype=-1);
     // 根据数据库中的自增长id
     void del_forbid_data(int id,int staff_id);
 

+ 1 - 1
module_service/module_meta_date_changed.cpp

@@ -304,7 +304,7 @@ void module_meta_date_changed::deal_call_edit_forbid_person_down_mine(const std:
 
     if(ET_INSERT == edit_type_id || ET_UPDATE == edit_type_id)
     {
-        forbid_staff_down_mine::instance()->init_forbid_staff(db_id);
+        forbid_staff_down_mine::instance()->init_forbid_staff(db_id,edit_type_id);
     }
     else if(ET_DELETE == edit_type_id)
     {