|
@@ -22,7 +22,7 @@
|
|
|
#include "module_service/module_mgr.h"
|
|
|
#include "visit.h"
|
|
|
#include "his_location.h"
|
|
|
-
|
|
|
+#include "three_rates.h"
|
|
|
extern config_file config;
|
|
|
//一张卡一个ct的所有不同天线的信息
|
|
|
struct one_ct_message_handle
|
|
@@ -122,6 +122,7 @@ struct one_ct_message_handle
|
|
|
|
|
|
void calc_location()
|
|
|
{
|
|
|
+ log_info("calc_location:%d begin",m_card->m_id);
|
|
|
auto v = m_msg_list;
|
|
|
|
|
|
std::vector<point> rc=std::move(m_loc_tool.calc_location(v));
|
|
@@ -129,6 +130,7 @@ struct one_ct_message_handle
|
|
|
if(!rc.empty()) m_card->on_location(std::move(rc),v);
|
|
|
|
|
|
reset();
|
|
|
+ log_info("calc_location:%d end",m_card->m_id);
|
|
|
}
|
|
|
};
|
|
|
struct card_message_handle
|
|
@@ -202,8 +204,10 @@ struct card_area
|
|
|
struct person:card_location_base, card_area
|
|
|
{
|
|
|
std::weak_ptr<monkey_person> m_monkeyPerson;
|
|
|
- person(std::string type,uint32_t cardid,uint16_t needdisplay,int16_t t,int32_t deptid,int32_t level_id)
|
|
|
- :card_location_base(type,cardid,needdisplay,t,deptid,level_id)
|
|
|
+ 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)
|
|
|
+ :card_location_base(type,cardid,needdisplay,t,deptid,level_id,cid)
|
|
|
+ ,m_workLine(wl)
|
|
|
{
|
|
|
m_message_handle.reset(new card_message_handle(this));
|
|
|
m_his_location_card.reset(new location_staff(m_id,m_type));
|
|
@@ -216,7 +220,7 @@ struct person:card_location_base, card_area
|
|
|
|
|
|
void clear()
|
|
|
{
|
|
|
- m_site_area.reset(new site_area_hover);
|
|
|
+ //m_site_area.reset(new site_area_hover);
|
|
|
m_area_tool.reset(new area_tool);
|
|
|
m_mine_tool.reset(new mine_tool);
|
|
|
|
|
@@ -247,10 +251,11 @@ struct person:card_location_base, card_area
|
|
|
return m_site_area;
|
|
|
}
|
|
|
|
|
|
- virtual void do_business(const point &pt)
|
|
|
+ virtual void do_business(const point &pt,double acc)
|
|
|
{
|
|
|
m_area_tool->on_point(m_id,pt,m_speed,m_type);
|
|
|
m_site_area->on_point(m_id,0,this, m_type);
|
|
|
+ handle_three_rates(pt);
|
|
|
}
|
|
|
void reset(std::shared_ptr<monkey_person> mp)
|
|
|
{
|
|
@@ -258,6 +263,17 @@ struct person:card_location_base, card_area
|
|
|
}
|
|
|
~person(){}
|
|
|
private:
|
|
|
+ void handle_three_rates(const point & pt)
|
|
|
+ {
|
|
|
+ card_pos cp;
|
|
|
+ cp.work_line=m_workLine;
|
|
|
+ cp.biz_stat = get_stat();
|
|
|
+ cp.x=pt.x;cp.y=pt.y;cp.z=pt.z;
|
|
|
+ const auto lm = m_area_tool->getLandmark();
|
|
|
+ cp.enter_time = std::get<0>(lm)*1000;
|
|
|
+ cp.area_id = std::get<3>(lm);
|
|
|
+ put_three_rates(cp);
|
|
|
+ }
|
|
|
void on_timer()
|
|
|
{
|
|
|
if(!m_mine_tool->is_attendance())
|
|
@@ -311,9 +327,10 @@ struct car:card_location_base,card_area
|
|
|
{
|
|
|
int m_vehicle_category_id=0;
|
|
|
int m_vehicle_type_id=0;
|
|
|
+ double m_acc =0;
|
|
|
car(std::string type,uint32_t cardid,uint16_t needdisplay,int16_t t,int32_t deptid,
|
|
|
- int32_t categoryid, int type_id,int32_t level_id)
|
|
|
- :card_location_base(type,cardid,needdisplay,t,deptid,level_id)
|
|
|
+ int32_t categoryid, int type_id,int32_t level_id,uint32_t cid)
|
|
|
+ :card_location_base(type,cardid,needdisplay,t,deptid,level_id,cid)
|
|
|
,m_vehicle_category_id(categoryid)
|
|
|
,m_vehicle_type_id(type_id)
|
|
|
{
|
|
@@ -345,12 +362,13 @@ struct car:card_location_base,card_area
|
|
|
return m_site_area;
|
|
|
}
|
|
|
|
|
|
- virtual void do_business(const point &pt)
|
|
|
+ virtual void do_business(const point &pt,double acc)
|
|
|
{
|
|
|
+ m_acc=acc;
|
|
|
m_area_tool->on_point(m_id,pt,m_speed,m_type);
|
|
|
m_site_area->on_point(m_id,0,this, m_type);
|
|
|
-
|
|
|
m_mine_tool->on_point(m_id, m_type, m_vehicle_category_id);
|
|
|
+ handle_three_rates(pt);
|
|
|
}
|
|
|
|
|
|
int get_vehicle_type_id()
|
|
@@ -360,6 +378,18 @@ struct car:card_location_base,card_area
|
|
|
|
|
|
~car(){}
|
|
|
private:
|
|
|
+ void handle_three_rates(const point &pt)
|
|
|
+ {
|
|
|
+ card_pos cp;
|
|
|
+ cp.biz_stat = get_stat();
|
|
|
+ cp.x=pt.x;cp.y=pt.y;cp.z=pt.z;
|
|
|
+ const auto lm = m_area_tool->getLandmark();
|
|
|
+ cp.enter_time = std::get<0>(lm)*1000;
|
|
|
+ cp.area_id = std::get<3>(lm);
|
|
|
+ cp.map_id = std::get<2>(lm);
|
|
|
+ cp.vibration=m_acc;
|
|
|
+ put_three_rates(cp);
|
|
|
+ }
|
|
|
void on_timer()
|
|
|
{
|
|
|
make_package();
|
|
@@ -427,20 +457,19 @@ uint64_t card_list::getId(uint32_t cardid,uint64_t type)
|
|
|
return type<<32|cardid;
|
|
|
}
|
|
|
|
|
|
-void card_list::init_staffer(int32_t id)
|
|
|
+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 \
|
|
|
+ ol.occupation_level_id,s.worktype_id,s.need_display,s.work_line\
|
|
|
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";
|
|
|
+ WHERE s.duty_id = 0 AND c.state_id = 0";
|
|
|
|
|
|
- int type = CT_PERSON;
|
|
|
- std::string card_id_str = card_list::to_id64_str(type, static_cast<uint32_t>(id));
|
|
|
- if(-1 == id)
|
|
|
+ std::string card_id_str = tool_other::to13str(id64);
|
|
|
+ if(-1 == id64)
|
|
|
{
|
|
|
sql.append(";");
|
|
|
}
|
|
@@ -492,22 +521,24 @@ void card_list::init_staffer(int32_t id)
|
|
|
|
|
|
int need_display = 0;
|
|
|
DBRes.GetField( "need_display",need_display, Error );
|
|
|
-
|
|
|
+
|
|
|
+ int work_line = 0;
|
|
|
+ DBRes.GetField( "work_line",work_line, Error );
|
|
|
//for now;
|
|
|
- staff_id = vsid;
|
|
|
+ //staff_id = vsid;
|
|
|
|
|
|
- if(-1 == id)
|
|
|
+ if(-1 == id64)
|
|
|
{
|
|
|
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,type);
|
|
|
- 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());
|
|
|
+ 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);
|
|
|
map.insert({cardid,clb});
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- auto card_id64 = card_list::to_id64(type, static_cast<uint32_t>(id));
|
|
|
+ auto card_id64 = card_list::to_id64(card_type_id, tool_other::id64_to_id(card_id));
|
|
|
auto card_ptr = card_list::instance()->get(card_id64);
|
|
|
if(card_ptr)
|
|
|
{
|
|
@@ -521,25 +552,25 @@ void card_list::init_staffer(int32_t id)
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- auto clb = std::make_shared<person>(strategy,staff_id,need_display,card_type_id,dept_id,occupation_level_id);
|
|
|
+ auto clb = std::make_shared<person>(strategy,vsid,need_display,card_type_id,dept_id,occupation_level_id,staff_id,work_line);
|
|
|
card_list::instance()->add(card_id64, clb);
|
|
|
}
|
|
|
|
|
|
- log_info("基础数据 增加或修改人卡成功:卡id:%d,卡type:%d dept_id:%d,need_display:%d,occupation_level_id:%d",
|
|
|
- id,type,dept_id,need_display,occupation_level_id);
|
|
|
- std_debug("基础数据 增加或修改人卡成功:卡id:%d,卡type:%d dept_id:%d,need_display:%d,occupation_level_id:%d",
|
|
|
- id,type,dept_id,need_display,occupation_level_id);
|
|
|
+ log_info("基础数据 增加或修改人卡成功:卡id:%ld, dept_id:%d,need_display:%d,occupation_level_id:%d",
|
|
|
+ id64,dept_id,need_display,occupation_level_id);
|
|
|
+ std_debug("基础数据 增加或修改人卡成功:卡id:%ld, dept_id:%d,need_display:%d,occupation_level_id:%d",
|
|
|
+ id64,dept_id,need_display,occupation_level_id);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if(-1 == id)
|
|
|
+ if(-1 == id64)
|
|
|
{
|
|
|
log_info( "init_staffer. The record count=%d\n", nCount );
|
|
|
card_list::instance()->add(map);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-void card_list::init_vehicle(int32_t id)
|
|
|
+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, \
|
|
@@ -553,11 +584,10 @@ void card_list::init_vehicle(int32_t 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";
|
|
|
+ WHERE c.state_id = 0";
|
|
|
|
|
|
- int type = CT_VEHICLE;
|
|
|
- std::string card_id_str = card_list::to_id64_str(type, static_cast<uint32_t>(id));
|
|
|
- if(-1 == id)
|
|
|
+ std::string card_id_str = tool_other::to13str(id64);
|
|
|
+ if(-1 == id64)
|
|
|
{
|
|
|
sql.append(";");
|
|
|
}
|
|
@@ -623,20 +653,20 @@ void card_list::init_vehicle(int32_t id)
|
|
|
DBRes.GetField( "over_speed",over_speed, Error );
|
|
|
|
|
|
//for now
|
|
|
- vehicle_id = vsid;
|
|
|
+ //vehicle_id = vsid;
|
|
|
|
|
|
- if(-1 == id)
|
|
|
+ if(-1 == id64)
|
|
|
{
|
|
|
- auto 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,type);
|
|
|
- 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);
|
|
|
+ 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);
|
|
|
+ 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(type, static_cast<uint32_t>(id));
|
|
|
+ auto card_id64 = card_list::to_id64(card_type_id, tool_other::id64_to_id(card_id));
|
|
|
auto card_ptr = card_list::instance()->get(card_id64);
|
|
|
if(card_ptr)
|
|
|
{
|
|
@@ -649,19 +679,19 @@ void card_list::init_vehicle(int32_t id)
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- auto clb = std::make_shared<car>(strategy,id,need_display,card_type_id,dept_id,
|
|
|
- vehicle_category_id, vehicle_type_id,vehicle_level_id);
|
|
|
+ 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);
|
|
|
card_list::instance()->add(card_id64, clb);
|
|
|
}
|
|
|
|
|
|
- log_info("基础数据 增加或修改车卡成功:卡id:%d,卡type:%d dept_id:%d,need_display:%d,categoryid:%d",
|
|
|
- id,type,dept_id,need_display,vehicle_category_id);
|
|
|
- std_debug("基础数据 增加或修改车卡成功:卡id:%d,卡type:%d dept_id:%d,need_display:%d,categoryid:%d",
|
|
|
- id,type,dept_id,need_display,vehicle_category_id);
|
|
|
+ log_info("基础数据 增加或修改车卡成功:卡id:%ld, dept_id:%d,need_display:%d,categoryid:%d",
|
|
|
+ id64,dept_id,need_display,vehicle_category_id);
|
|
|
+ std_debug("基础数据 增加或修改车卡成功:卡id:%ld, dept_id:%d,need_display:%d,categoryid:%d",
|
|
|
+ id64,dept_id,need_display,vehicle_category_id);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if(-1 == id)
|
|
|
+ if(-1 == id64)
|
|
|
{
|
|
|
log_info( "init_vehicle. The record count=%d\n", nCount );
|
|
|
card_list::instance()->add(map);
|
|
@@ -1116,8 +1146,8 @@ void card_list::onTimer()
|
|
|
}
|
|
|
}
|
|
|
//-----------------card_location_base..
|
|
|
-card_location_base::card_location_base(std::string type,uint32_t id,uint16_t dis,int16_t t,int32_t deptid,int32_t level_id)
|
|
|
- :card(id,dis,t,deptid,level_id)
|
|
|
+card_location_base::card_location_base(std::string type,uint32_t id,uint16_t dis,int16_t t,int32_t deptid,int32_t level_id,uint32_t cid)
|
|
|
+ :card(id,dis,t,deptid,level_id,cid)
|
|
|
{
|
|
|
select_tool_manage::instance()->create_tool(type,m_sel_tool,m_smo_tool);
|
|
|
}
|
|
@@ -1141,12 +1171,11 @@ void card_location_base::on_location(const std::vector<point>&vp,const std::vect
|
|
|
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);
|
|
|
-
|
|
|
- log_info("useful:card_id:%d,ct:%d,timestamp:%llu, loc_point,x:%.2f,y:%.2f ",m_id,m_ct,m_time,pt.x,pt.y);
|
|
|
- do_business(pt);
|
|
|
+ //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);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1219,6 +1248,24 @@ void card_location_base::clear()
|
|
|
//m_ct; //ct
|
|
|
m_time=0; //时间戳
|
|
|
}
|
|
|
+void card_location_base::put_three_rates(card_pos & cp)
|
|
|
+{
|
|
|
+ cp.rec_time=m_time;cp.type=m_type;cp.id=m_id;
|
|
|
+ cp.identifier_id=m_cid;cp.running_stat=m_stat;cp.final_v=m_speed;
|
|
|
+ log_info("three_rates:type:%d,id:%d,cid:%d",cp.type,cp.id,cp.identifier_id);
|
|
|
+ three_rates::get_instance()->put(cp);
|
|
|
+}
|
|
|
+
|
|
|
+bool card_location_base::is_person() const
|
|
|
+{
|
|
|
+ return tool_other::is_person(m_type);
|
|
|
+}
|
|
|
+
|
|
|
+bool card_location_base::is_vehicle() const
|
|
|
+{
|
|
|
+ return tool_other::is_vehicle(m_type);
|
|
|
+}
|
|
|
+
|
|
|
card_location_base::~card_location_base()
|
|
|
{
|
|
|
}
|