|
@@ -203,19 +203,16 @@ struct person:card_location_base, card_area
|
|
|
{
|
|
|
std::weak_ptr<monkey_person> m_monkeyPerson;
|
|
|
int m_workLine=0;
|
|
|
- person(std::string type,uint32_t cardid,uint16_t needdisplay,int16_t t,int32_t deptid,int32_t level_id,uint32_t cid,int wl)
|
|
|
+ time_t m_iris_recognition_timeval=0;
|
|
|
+ std::string m_stafferName,m_deptName;
|
|
|
+ person(std::string type,uint32_t cardid,uint16_t needdisplay,int16_t t,int32_t deptid,int32_t level_id,uint32_t cid,int wl,std::string sname,std::string dname)
|
|
|
:card_location_base(type,cardid,needdisplay,t,deptid,level_id,cid)
|
|
|
- ,m_workLine(wl)
|
|
|
+ ,m_workLine(wl),m_iris_recognition_timeval(0),m_stafferName(sname),m_deptName(dname)
|
|
|
{
|
|
|
m_message_handle.reset(new card_message_handle(this));
|
|
|
m_his_location_card.reset(new location_staff(m_id,m_type));
|
|
|
}
|
|
|
|
|
|
- void on_message(zloop<task*> * loop,const message_locinfo&loc,bool is_history)
|
|
|
- {
|
|
|
- m_message_handle->on_message(loop,loc,is_history);
|
|
|
- }
|
|
|
-
|
|
|
void clear()
|
|
|
{
|
|
|
//m_site_area.reset(new site_area_hover);
|
|
@@ -228,11 +225,35 @@ struct person:card_location_base, card_area
|
|
|
virtual void site_hover(int sid)
|
|
|
{
|
|
|
if(m_time<=0)
|
|
|
- {
|
|
|
return;
|
|
|
- }
|
|
|
- log_info("__thread_id site_hover:%d,%x [%x]",m_id,std::this_thread::get_id(),m_site_area.get());
|
|
|
m_site_area->on_point(m_id,sid,nullptr, m_type);
|
|
|
+ IKSDK_DB(sid);
|
|
|
+ }
|
|
|
+ //虹膜识别入库功能
|
|
|
+ void IKSDK_DB(int sid)
|
|
|
+ {
|
|
|
+ auto sit_ptr = sit_list::instance()->get(sid);
|
|
|
+ if(nullptr == sit_ptr)
|
|
|
+ return;
|
|
|
+ if(sit_ptr->m_reader_type_id == READER_TYPE_ID_UP)
|
|
|
+ {
|
|
|
+ time_t now = time(0);
|
|
|
+ if(now - m_iris_recognition_timeval > 5)
|
|
|
+ {
|
|
|
+ int f=0;
|
|
|
+ if(event_list::instance()->get_event_card(m_id, m_type, ET_CARD_LOW_POWER_SERIOUS))
|
|
|
+ f=1;
|
|
|
+ std::string card_id = tool_other::type_id_to_str(m_type,m_id);
|
|
|
+ std::string st = tool_time::to_str(now);
|
|
|
+ char nsql[256]={0};
|
|
|
+ const char*sql="REPLACE INTO his_att_interface (staff_id,card_id,reader_id,staff_name,dept_name,upt_time,low_power_warn) VALUES (%d,%s,%d,'%s','%s','%s',%d);";
|
|
|
+ snprintf(nsql,256,sql,m_cid,card_id.c_str(),sid,m_stafferName.c_str(),m_deptName.c_str(),st.c_str(),f);
|
|
|
+ tool_db::PushAsync(nsql);
|
|
|
+ log_info("%s",nsql);
|
|
|
+ logn_info(2,"%s",nsql);
|
|
|
+ m_iris_recognition_timeval = now;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
virtual std::shared_ptr<area_hover> get_area_hover()
|
|
@@ -340,9 +361,7 @@ struct car:card_location_base,card_area
|
|
|
virtual void site_hover(int sid)
|
|
|
{
|
|
|
if(m_time<=0)
|
|
|
- {
|
|
|
return;
|
|
|
- }
|
|
|
m_site_area->on_point(m_id,sid,0, m_type);
|
|
|
}
|
|
|
|
|
@@ -451,17 +470,14 @@ private:
|
|
|
|
|
|
loc_tool_main one_ct_message_handle::m_loc_tool;
|
|
|
|
|
|
-uint64_t card_list::getId(uint32_t cardid,uint64_t type)
|
|
|
-{
|
|
|
- return type<<32|cardid;
|
|
|
-}
|
|
|
-
|
|
|
void card_list::init_staffer(int64_t id64)
|
|
|
{
|
|
|
- std::string strategy = config.get("person.strategy","person1");
|
|
|
- std::string sql = "SELECT staff_id, s.card_id, c.card_type_id, s.dept_id, s.group_id, s.occupation_id, \
|
|
|
- ol.occupation_level_id,s.worktype_id,s.need_display,s.work_line\
|
|
|
+ std::string strategy = config.get("person.strategy","PS_1");
|
|
|
+ std::string sql = "SELECT s.staff_id, s.card_id, c.card_type_id, s.dept_id, s.group_id, s.occupation_id, \
|
|
|
+ ol.occupation_level_id,s.worktype_id,s.need_display,s.work_line,ds.name as staffer_name,dd.name as dept_name\
|
|
|
FROM dat_staff_extend s \
|
|
|
+ LEFT JOIN dat_staff ds ON ds.staff_id = s.staff_id \
|
|
|
+ LEFT JOIN dat_dept dd ON dd.dept_id = s.dept_id \
|
|
|
LEFT JOIN dat_card c ON s.card_id = c.card_id \
|
|
|
LEFT JOIN dat_occupation o ON s.occupation_id = o.occupation_id \
|
|
|
LEFT JOIN dat_occupation_level ol ON ol.occupation_level_id = o.occupation_level_id \
|
|
@@ -523,21 +539,26 @@ void card_list::init_staffer(int64_t id64)
|
|
|
|
|
|
int work_line = 0;
|
|
|
DBRes.GetField( "work_line",work_line, Error );
|
|
|
- //for now;
|
|
|
- //staff_id = vsid;
|
|
|
+
|
|
|
+ std::string staffer_name;
|
|
|
+ DBRes.GetField( "staffer_name",staffer_name, Error );
|
|
|
+
|
|
|
+ std::string dept_name;
|
|
|
+ DBRes.GetField( "dept_name",dept_name, Error );
|
|
|
+
|
|
|
|
|
|
if(-1 == id64)
|
|
|
{
|
|
|
std::shared_ptr<card_location_base> clb =
|
|
|
- std::make_shared<person>(strategy,vsid,need_display,card_type_id,dept_id,occupation_level_id,staff_id,work_line);
|
|
|
- uint64_t cardid = getId(vsid,card_type_id);
|
|
|
- log_info("cardId:%llu,id:%d dept_id:%d,need_display:%d,card:%s:work_line:%d,staff_id:%d,type:%d",
|
|
|
- cardid,vsid,dept_id,need_display,card_id.c_str(),work_line,staff_id,card_type_id);
|
|
|
+ std::make_shared<person>(strategy,vsid,need_display,card_type_id,dept_id,occupation_level_id,staff_id,work_line,staffer_name,dept_name);
|
|
|
+ uint64_t cardid = tool_other::type_id_to_u64(vsid,card_type_id);
|
|
|
+ log_info("cardId:%llu,id:%d dept_id:%d,need_display:%d,card:%s:work_line:%d,staff_id:%d,type:%d,staffer_name:%s,dept_name:%s",
|
|
|
+ cardid,vsid,dept_id,need_display,card_id.c_str(),work_line,staff_id,card_type_id,staffer_name.c_str(),dept_name.c_str());
|
|
|
map.insert({cardid,clb});
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- auto card_id64 = card_list::to_id64(card_type_id, tool_other::id64_to_id(card_id));
|
|
|
+ auto card_id64 = tool_other::type_id_to_u64(card_type_id, tool_other::id64_to_id(card_id));
|
|
|
auto card_ptr = card_list::instance()->get(card_id64);
|
|
|
if(card_ptr)
|
|
|
{
|
|
@@ -551,7 +572,7 @@ void card_list::init_staffer(int64_t id64)
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- auto clb = std::make_shared<person>(strategy,vsid,need_display,card_type_id,dept_id,occupation_level_id,staff_id,work_line);
|
|
|
+ auto clb = std::make_shared<person>(strategy,vsid,need_display,card_type_id,dept_id,occupation_level_id,staff_id,work_line,staffer_name,dept_name);
|
|
|
card_list::instance()->add(card_id64, clb);
|
|
|
}
|
|
|
|
|
@@ -571,7 +592,6 @@ void card_list::init_staffer(int64_t id64)
|
|
|
|
|
|
void card_list::init_vehicle(int64_t id64)
|
|
|
{
|
|
|
- std::string strategy = config.get("car.strategy","car1");
|
|
|
std::string sql = "SELECT ve.vehicle_id, ve.card_id, c.card_type_id, \
|
|
|
ve.dept_id, ve.group_id, v.vehicle_type_id, vt.vehicle_level_id, \
|
|
|
vt.is_railroad AS vt_is_railroad,ve.need_display ,ve.power_alarm,\
|
|
@@ -650,7 +670,15 @@ void card_list::init_vehicle(int64_t id64)
|
|
|
|
|
|
double over_speed= 0;
|
|
|
DBRes.GetField( "over_speed",over_speed, Error );
|
|
|
-
|
|
|
+ std::string strategy;
|
|
|
+ if(card_type_id == CT_VEHICLE)
|
|
|
+ {
|
|
|
+ strategy = config.get("car.strategy","CS_1");
|
|
|
+ }
|
|
|
+ else if(card_type_id == CT_COAL_CUTTER || CT_HEADING_MACHINE == card_type_id)
|
|
|
+ {
|
|
|
+ strategy = config.get("coal_wining.strategy","WS_1");
|
|
|
+ }
|
|
|
//for now
|
|
|
//vehicle_id = vsid;
|
|
|
|
|
@@ -658,14 +686,14 @@ void card_list::init_vehicle(int64_t id64)
|
|
|
{
|
|
|
auto clb = std::make_shared<car>(strategy,vsid,need_display,card_type_id,
|
|
|
dept_id,vehicle_category_id, vehicle_type_id,vehicle_level_id,vehicle_id);
|
|
|
- uint64_t cardid = getId(vsid,card_type_id);
|
|
|
+ uint64_t cardid = tool_other::type_id_to_u64(vsid,card_type_id);
|
|
|
log_info("cardId:%llu,id:%d dept_id:%d,need_display:%d-cardid:%s,categoryid:%d,vchile_id:%d,type:%d",
|
|
|
cardid,vsid,dept_id,need_display,card_id.c_str(),vehicle_category_id,vehicle_id,card_type_id);
|
|
|
map.insert({cardid,clb});
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- auto card_id64 = card_list::to_id64(card_type_id, tool_other::id64_to_id(card_id));
|
|
|
+ auto card_id64 = tool_other::type_id_to_u64(card_type_id, tool_other::id64_to_id(card_id));
|
|
|
auto card_ptr = card_list::instance()->get(card_id64);
|
|
|
if(card_ptr)
|
|
|
{
|
|
@@ -694,147 +722,9 @@ void card_list::init_vehicle(int64_t id64)
|
|
|
{
|
|
|
log_info( "init_vehicle. The record count=%d\n", nCount );
|
|
|
card_list::instance()->add(map);
|
|
|
- }
|
|
|
-}
|
|
|
-#if 0
|
|
|
-void card_list::init_vehicle()
|
|
|
-{
|
|
|
- std::unordered_map<uint64_t,std::shared_ptr<card_location_base>> map;
|
|
|
- std::string strategy = config.get("car.strategy","car1");
|
|
|
- const char *sql = "SELECT ve.vehicle_id, ve.card_id, c.card_type_id, \
|
|
|
- ve.dept_id, ve.group_id, v.vehicle_type_id, vt.vehicle_level_id, \
|
|
|
- vt.is_railroad AS vt_is_railroad,ve.need_display ,ve.power_alarm,\
|
|
|
- vt.vehicle_category_id,v.bigger_car_flag,vc.over_speed \
|
|
|
- FROM dat_vehicle_extend ve \
|
|
|
- LEFT JOIN dat_vehicle v ON ve.vehicle_id = v.vehicle_id \
|
|
|
- LEFT JOIN dat_card c ON ve.card_id = c.card_id \
|
|
|
- LEFT JOIN dat_dept d ON ve.dept_id = d.dept_id \
|
|
|
- LEFT JOIN dat_group g ON ve.group_id = g.group_id \
|
|
|
- LEFT JOIN dat_vehicle_type vt ON v.vehicle_type_id = vt.vehicle_type_id \
|
|
|
- LEFT JOIN dat_vehicle_category vc ON vc.vehicle_category_id = vt.vehicle_category_id \
|
|
|
- WHERE c.card_type_id = 2 AND c.state_id = 0;";
|
|
|
- std::string Error;
|
|
|
- YADB::CDBResultSet DBRes;
|
|
|
- sDBConnPool.Query(sql,DBRes,Error);
|
|
|
- int nCount = DBRes.GetRecordCount( Error );
|
|
|
- if (nCount > 0)
|
|
|
- {
|
|
|
log_info( "init_vehicle. The record count=%d\n", nCount );
|
|
|
-
|
|
|
- while ( DBRes.GetNextRecod(Error) )
|
|
|
- {
|
|
|
- unsigned int vehicle_id = 0;
|
|
|
- DBRes.GetField( "vehicle_id",vehicle_id, Error );
|
|
|
-
|
|
|
- std::string card_id;
|
|
|
- DBRes.GetField( "card_id",card_id, Error );
|
|
|
-
|
|
|
- uint32_t vsid = atoi(card_id.substr(3).c_str());
|
|
|
-
|
|
|
- unsigned int card_type_id = 0;
|
|
|
- DBRes.GetField( "card_type_id",card_type_id, Error );
|
|
|
-
|
|
|
- int dept_id = 0;
|
|
|
- DBRes.GetField( "dept_id",dept_id, Error );
|
|
|
-
|
|
|
- int group_id = 0;
|
|
|
- DBRes.GetField( "group_id",group_id, Error );
|
|
|
-
|
|
|
- int vehicle_type_id = 0;
|
|
|
- DBRes.GetField( "vehicle_type_id",vehicle_type_id, Error );
|
|
|
-
|
|
|
- int vehicle_level_id = 0;
|
|
|
- DBRes.GetField( "vehicle_level_id",vehicle_level_id, Error );
|
|
|
-
|
|
|
- int need_display = 0;
|
|
|
- DBRes.GetField( "need_display",need_display, Error );
|
|
|
-
|
|
|
- int power_alarm = 0;
|
|
|
- DBRes.GetField( "power_alarm",power_alarm, Error );
|
|
|
-
|
|
|
- int vehicle_category_id = 0;
|
|
|
- DBRes.GetField( "vehicle_category_id",vehicle_category_id, Error );
|
|
|
-
|
|
|
- int bigger_car_flag= 0;
|
|
|
- DBRes.GetField( "bigger_car_flag",bigger_car_flag, Error );
|
|
|
-
|
|
|
- double over_speed= 0;
|
|
|
- DBRes.GetField( "over_speed",over_speed, Error );
|
|
|
-
|
|
|
- //for now
|
|
|
- vehicle_id = vsid;
|
|
|
-
|
|
|
- std::shared_ptr<card_location_base> clb = std::make_shared<car>(strategy,vehicle_id,
|
|
|
- need_display,card_type_id,dept_id,vehicle_category_id, vehicle_type_id,vehicle_level_id);
|
|
|
- uint64_t cardid = getId(vehicle_id,2);
|
|
|
- log_info("cardId:%llu,vehicle_id:%d dept_id:%d,need_display:%d---cardid:%s,categoryid:%d",cardid,vehicle_id,dept_id,need_display,card_id.c_str(),vehicle_category_id);
|
|
|
- map.insert({cardid,clb});
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- card_list::instance()->add(map);
|
|
|
-}
|
|
|
-
|
|
|
-void card_list::init_staffer()
|
|
|
-{
|
|
|
- std::unordered_map<uint64_t,std::shared_ptr<card_location_base>> map;
|
|
|
- std::string strategy = config.get("person.strategy","person1");
|
|
|
- const char *sql = "SELECT staff_id, s.card_id, c.card_type_id, s.dept_id, s.group_id, s.occupation_id, \
|
|
|
- ol.occupation_level_id,s.worktype_id,s.need_display \
|
|
|
- FROM dat_staff_extend s \
|
|
|
- LEFT JOIN dat_card c ON s.card_id = c.card_id \
|
|
|
- LEFT JOIN dat_occupation o ON s.occupation_id = o.occupation_id \
|
|
|
- LEFT JOIN dat_occupation_level ol ON ol.occupation_level_id = o.occupation_level_id \
|
|
|
- WHERE c.card_type_id = 1 AND s.duty_id = 0 AND c.state_id = 0;";
|
|
|
- std::string Error;
|
|
|
- YADB::CDBResultSet DBRes;
|
|
|
- sDBConnPool.Query(sql,DBRes,Error);
|
|
|
- int nCount = DBRes.GetRecordCount( Error );
|
|
|
- if (nCount > 0)
|
|
|
- {
|
|
|
- log_info( "init_staffer. The record count=%d\n", nCount );
|
|
|
-
|
|
|
- while ( DBRes.GetNextRecod(Error) )
|
|
|
- {
|
|
|
- unsigned int staff_id = 0;
|
|
|
- DBRes.GetField( "staff_id",staff_id, Error );
|
|
|
-
|
|
|
- std::string card_id;
|
|
|
- DBRes.GetField( "card_id",card_id, Error );
|
|
|
-
|
|
|
- uint32_t vsid = atoi(card_id.substr(3).c_str());
|
|
|
-
|
|
|
- unsigned int card_type_id = 0;
|
|
|
- DBRes.GetField( "card_type_id",card_type_id, Error );
|
|
|
-
|
|
|
- int dept_id = 0;
|
|
|
- DBRes.GetField( "dept_id",dept_id, Error );
|
|
|
-
|
|
|
- int group_id = 0;
|
|
|
- DBRes.GetField( "group_id",group_id, Error );
|
|
|
-
|
|
|
- int occupation_id = 0;
|
|
|
- DBRes.GetField( "occupation_id",occupation_id, Error );
|
|
|
-
|
|
|
- int occupation_level_id = 0;
|
|
|
- DBRes.GetField( "occupation_level_id",occupation_level_id, Error );
|
|
|
-
|
|
|
- int need_display = 0;
|
|
|
- DBRes.GetField( "need_display",need_display, Error );
|
|
|
-
|
|
|
- //for now;
|
|
|
- staff_id = vsid;
|
|
|
-
|
|
|
- std::shared_ptr<card_location_base> clb = std::make_shared<person>(strategy,staff_id,need_display,card_type_id,dept_id,occupation_level_id);
|
|
|
- uint64_t cardid = getId(staff_id,1);
|
|
|
- log_info("cardId:%llu,staff_id:%d dept_id:%d,need_display:%d--c-ard:%s",cardid,staff_id,dept_id,need_display,card_id.c_str());
|
|
|
- map.insert({cardid,clb});
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- card_list::instance()->add(map);
|
|
|
+ }
|
|
|
}
|
|
|
-#endif
|
|
|
void card_list::init_card_from_db()
|
|
|
{
|
|
|
init_staffer(-1);
|
|
@@ -905,7 +795,7 @@ void card_list::load_his_card_postion_vehicle()
|
|
|
uint32_t id = tool_other::id64_to_id(card_id);
|
|
|
int type = tool_other::id64_to_type(card_id);
|
|
|
|
|
|
- auto temp_ptr = card_list::instance()->get(card_list::to_id64(type, id));
|
|
|
+ auto temp_ptr = card_list::instance()->get(tool_other::type_id_to_u64(type, id));
|
|
|
if(!temp_ptr || !temp_ptr->is_vehicle())
|
|
|
{
|
|
|
log_error("全局卡列表中找不到卡,卡id=%d,卡type=%d", id, type);
|
|
@@ -1027,7 +917,7 @@ void card_list::load_his_card_postion_staff()
|
|
|
uint32_t id = tool_other::id64_to_id(card_id);
|
|
|
int type = tool_other::id64_to_type(card_id);
|
|
|
|
|
|
- auto temp_ptr = card_list::instance()->get(card_list::to_id64(type, id));
|
|
|
+ auto temp_ptr = card_list::instance()->get(tool_other::type_id_to_u64(type, id));
|
|
|
if(!temp_ptr || !temp_ptr->is_person())
|
|
|
{
|
|
|
log_error("全局卡列表中找不到卡,卡id=%d,卡type=%d", id, type);
|
|
@@ -1115,8 +1005,8 @@ void card_list::load_his_card_postion_staff()
|
|
|
void card_list::on_message(zloop<task*> *loop,const message_locinfo&loc,bool is_history)
|
|
|
{
|
|
|
//std::shared_ptr<card_location_base>c=get(loc.m_card_id);
|
|
|
- uint64_t cardid = getId(loc.m_card_id,loc.m_card_type);
|
|
|
- const auto c=get(cardid);
|
|
|
+ uint64_t cardid = tool_other::type_id_to_u64(loc.m_card_id,loc.m_card_type);
|
|
|
+ const auto c=card_list::instance()->get(cardid);
|
|
|
if(c==nullptr)
|
|
|
{
|
|
|
log_warn("数据库中未定义该卡的信息,card_id=%d", loc.m_card_id);
|
|
@@ -1136,13 +1026,6 @@ struct local_visit:visitor<std::shared_ptr<card_location_base>>
|
|
|
}
|
|
|
};
|
|
|
|
|
|
-// TODO : 停止进程
|
|
|
-void card_list::onStopRun()
|
|
|
-{
|
|
|
- card_list::instance()->m_bflag = true;
|
|
|
- card_list::instance()->m_pThread->join();
|
|
|
-}
|
|
|
-
|
|
|
void card_list::onTimer()
|
|
|
{
|
|
|
local_visit lv;
|
|
@@ -1177,9 +1060,9 @@ void card_location_base::on_location(const std::vector<point>&vp,const std::vect
|
|
|
x = pt.x;
|
|
|
y = pt.y;
|
|
|
|
|
|
- //Msg m;
|
|
|
- //m.type=m_type;m.x=(int)x;m.y=(int)y;m.cmd=CMD_HANDLE;m.cardid=m_type<<32|m_id;
|
|
|
- //cardMgr::instance()->tryPut(m);
|
|
|
+ Msg m;
|
|
|
+ m.type=m_type;m.x=(int)x;m.y=(int)y;m.cmd=CMD_HANDLE;m.cardid=m_type<<32|m_id;
|
|
|
+ cardMgr::instance()->tryPut(m);
|
|
|
double acc = lm[0].m_acc;
|
|
|
log_info("useful:card_id:%d,ct:%d,timestamp:%llu, loc_point,x:%.2f,y:%.2f acc:%.2f",m_id,m_ct,m_time,pt.x,pt.y,acc);
|
|
|
do_business(pt,acc);
|