|
@@ -7,9 +7,12 @@
|
|
|
#include "tool_time.h"
|
|
|
#include "db_api/CDBSingletonDefine.h"
|
|
|
|
|
|
+std::string forbid_staff_down_mine::m_updateTime = "";
|
|
|
+
|
|
|
void forbid_staff_down_mine::init_forbid_staff(int id /* = -1*/)
|
|
|
{
|
|
|
- std::string sql = "select id,staff_id,start_time,end_time,status,oper_time,lastupdate from rt_person_forbid_down_mine where status = 1";
|
|
|
+ std::string sql = "select id,staff_id,start_time,end_time,status,oper_time,lastupdate from rt_person_forbid_down_mine ";
|
|
|
+ sql += " where status = 1 and end_time > now() ";
|
|
|
if (id != -1)
|
|
|
{
|
|
|
sql += " and id = " + std::to_string(id) + ";";
|
|
@@ -28,11 +31,11 @@ void forbid_staff_down_mine::init_forbid_staff(int id /* = -1*/)
|
|
|
log_error("增加或修改失败,数据库中找不到: sql", sql.c_str());
|
|
|
return ;
|
|
|
}
|
|
|
- update_forbid_data(DBRes);
|
|
|
+ forbid_staff_down_mine::instance()->update_forbid_data(DBRes,true);
|
|
|
}
|
|
|
|
|
|
//更新数据
|
|
|
-void forbid_staff_down_mine::update_forbid_data(YADB::CDBResultSet & DBRes)
|
|
|
+void forbid_staff_down_mine::update_forbid_data(YADB::CDBResultSet & DBRes,bool bInsert)
|
|
|
{
|
|
|
std::string Error;
|
|
|
while ( DBRes.GetNextRecod(Error) )
|
|
@@ -51,20 +54,25 @@ void forbid_staff_down_mine::update_forbid_data(YADB::CDBResultSet & DBRes)
|
|
|
DBRes.GetField("oper_time", create_time, Error);
|
|
|
std::string update_time;
|
|
|
DBRes.GetField("lastupdate", update_time, Error);
|
|
|
- updatetime(create_time);
|
|
|
- updatetime(update_time);
|
|
|
+ forbid_staff_down_mine::updatetime(create_time);
|
|
|
+ forbid_staff_down_mine::updatetime(update_time);
|
|
|
|
|
|
std::shared_ptr<SForbidStaffList> s = forbid_staff_down_mine::instance()->get(staff_id);
|
|
|
if (s != nullptr)
|
|
|
{
|
|
|
- for (SForbidStaffInfo &info : s->forbidList)
|
|
|
+ if(!bInsert)
|
|
|
{
|
|
|
- if (info.db_id == key) //已有记录,修改完成
|
|
|
+ for (SForbidStaffInfo &info : s->forbidList)
|
|
|
{
|
|
|
- info.start_time = tool_time::to_time(start_time);
|
|
|
- info.end_time = tool_time::to_time(end_time);
|
|
|
- info.state = state;
|
|
|
- continue;
|
|
|
+ if (info.db_id == key) //已有记录,修改完成
|
|
|
+ {
|
|
|
+ info.start_time = tool_time::to_time(start_time);
|
|
|
+ info.end_time = tool_time::to_time(end_time);
|
|
|
+ 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());
|
|
|
+ continue;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -80,6 +88,9 @@ void forbid_staff_down_mine::update_forbid_data(YADB::CDBResultSet & DBRes)
|
|
|
info.start_time = tool_time::to_time(start_time);
|
|
|
info.end_time = tool_time::to_time(end_time);
|
|
|
info.state = state;
|
|
|
+
|
|
|
+ log_info("Init 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());
|
|
|
s->forbidList.push_back(info);
|
|
|
}
|
|
|
}
|
|
@@ -98,7 +109,7 @@ void forbid_staff_down_mine::on_load_data()
|
|
|
return ;
|
|
|
}
|
|
|
|
|
|
- update_forbid_data(DBRes);
|
|
|
+ forbid_staff_down_mine::instance()->update_forbid_data(DBRes,false);
|
|
|
}
|
|
|
|
|
|
void forbid_staff_down_mine::del_forbid_staff(int staff_id)
|
|
@@ -150,8 +161,7 @@ void forbid_staff_down_mine::updatetime(const std::string & t)
|
|
|
{
|
|
|
if (t.length() > 0 && t > m_updateTime)
|
|
|
{
|
|
|
+ log_info("forbid_staff_down_mine::updatetime :LastTime: %s -> t:%s ",t.c_str(),m_updateTime.c_str());
|
|
|
m_updateTime = t;
|
|
|
-
|
|
|
- std_info("forbid_staff_down_mine(%x)::updatetime : t:%s updateTime: %s",this,t.c_str(),m_updateTime.c_str());
|
|
|
}
|
|
|
}
|