|
@@ -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 . "
|