|
@@ -18,6 +18,8 @@
|
|
|
#include "special_area.h"
|
|
|
#include "cardMgr.h"
|
|
|
#include "ant.h"
|
|
|
+#include "mine.h"
|
|
|
+#include "module_service/module_mgr.h"
|
|
|
|
|
|
extern config_file config;
|
|
|
//一张卡一个ct的所有不同天线的信息
|
|
@@ -158,15 +160,24 @@ struct card_message_handle
|
|
|
return;
|
|
|
}
|
|
|
//
|
|
|
- m_card->site_hover(loc.m_site_id);
|
|
|
+ m_card->site_hover(loc.m_site_id);
|
|
|
|
|
|
- if(loc.m_batty_status == 2)
|
|
|
+ if(loc.m_batty_status == 2)
|
|
|
{
|
|
|
- m_card->do_status(STA_TYPE::STATUS_LOW_POWER_);
|
|
|
+ m_card->do_status(STATUS_POWER_LOWER_SERIOUS);
|
|
|
}
|
|
|
- else if(loc.m_callinfo == 0x80)
|
|
|
+ else
|
|
|
{
|
|
|
- m_card->do_status(STA_TYPE::STATUS_HELP_);
|
|
|
+ m_card->do_status(STATUS_POWER_NOMARL);
|
|
|
+ }
|
|
|
+
|
|
|
+ if(loc.m_callinfo & 0x80)
|
|
|
+ {
|
|
|
+ m_card->do_status(STATUS_HELP);
|
|
|
+ }
|
|
|
+ if((loc.m_callinfo & 0x01) || (loc.m_callinfo & 0x02))
|
|
|
+ {
|
|
|
+ m_card->do_status(STATUS_CALL);
|
|
|
}
|
|
|
|
|
|
m_ct_list[loc.m_card_ct&(m_ct_list.size()-1)]->on_message(loop,loc);
|
|
@@ -178,18 +189,20 @@ struct card_area
|
|
|
card_area()
|
|
|
{
|
|
|
m_site_area.reset(new site_area_hover);
|
|
|
- m_area_tool.reset(new area_tool);
|
|
|
+ m_area_tool.reset(new area_tool);
|
|
|
+ m_mine_tool.reset(new mine_tool);
|
|
|
}
|
|
|
std::shared_ptr<site_area_hover> m_site_area=nullptr;
|
|
|
std::shared_ptr<area_tool> m_area_tool=nullptr;
|
|
|
+ std::shared_ptr<mine_tool> m_mine_tool=nullptr;
|
|
|
};
|
|
|
|
|
|
-struct person:card_location_base,private 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)
|
|
|
- :card_location_base(type,cardid,needdisplay,t,deptid)
|
|
|
+ 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)
|
|
|
{
|
|
|
m_message_handle = new card_message_handle(this);
|
|
|
}
|
|
@@ -198,29 +211,64 @@ struct person:card_location_base,private card_area
|
|
|
{
|
|
|
m_message_handle->on_message(loop,loc,is_history);
|
|
|
}
|
|
|
+
|
|
|
+ void clear()
|
|
|
+ {
|
|
|
+ //清除定时器
|
|
|
+ m_timer.stop();
|
|
|
+ m_loop = nullptr;
|
|
|
+
|
|
|
+ m_site_area.reset(new site_area_hover);
|
|
|
+ m_area_tool.reset(new area_tool);
|
|
|
+ m_mine_tool.reset(new mine_tool);
|
|
|
+
|
|
|
+ card_location_base::clear();
|
|
|
+ }
|
|
|
|
|
|
virtual void site_hover(int sid)
|
|
|
{
|
|
|
- m_site_area->on_point(m_id,sid,0);
|
|
|
+ if(m_time<=0)
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ m_site_area->on_point(m_id,sid,nullptr, m_type);
|
|
|
}
|
|
|
+
|
|
|
+ virtual std::shared_ptr<area_hover> get_area_hover()
|
|
|
+ {
|
|
|
+ return m_area_tool->m_area_hover;
|
|
|
+ }
|
|
|
+
|
|
|
+ virtual std::shared_ptr<mine_tool> get_mine_tool()
|
|
|
+ {
|
|
|
+ return m_mine_tool;
|
|
|
+ }
|
|
|
+
|
|
|
+ virtual std::shared_ptr<site_area_hover> get_site_area()
|
|
|
+ {
|
|
|
+ return m_site_area;
|
|
|
+ }
|
|
|
+
|
|
|
virtual void do_business(const point &pt)
|
|
|
{
|
|
|
//区域
|
|
|
m_area_tool->on_point(m_id,pt,m_speed,m_type);
|
|
|
//考勤
|
|
|
- m_site_area->on_point(m_id,0,this);
|
|
|
+ m_site_area->on_point(m_id,0,this, m_type);
|
|
|
//
|
|
|
}
|
|
|
//人卡升井后该线程要停掉
|
|
|
//手动升级需要补全区域得同时,需要进区域走区域业务
|
|
|
void set(ev::dynamic_loop * loop)
|
|
|
{
|
|
|
- log_info("cardid_id %d",m_id);
|
|
|
+ if(!m_mine_tool->is_attendance())
|
|
|
+ return;
|
|
|
+ log_info("person_is_on_att......%d",m_id);
|
|
|
m_loop = loop;
|
|
|
|
|
|
m_timer.set(*m_loop);
|
|
|
m_timer.set<person,&person::on_timer>(this);
|
|
|
- m_timer.start(1,1);
|
|
|
+ m_timer.start(10,1);
|
|
|
}
|
|
|
void reset(std::shared_ptr<monkey_person> mp)
|
|
|
{
|
|
@@ -234,7 +282,7 @@ private:
|
|
|
point pt = getSmoothPoint();
|
|
|
const auto lm = m_area_tool->getLandmark();
|
|
|
|
|
|
- cp.enter_area_time = std::get<0>(lm);
|
|
|
+ cp.enter_area_time = std::get<0>(lm)*1000;
|
|
|
cp.rec_time = std::get<1>(lm);
|
|
|
|
|
|
cp.map_id = std::get<2>(lm);
|
|
@@ -244,18 +292,13 @@ private:
|
|
|
cp.lm_direction = std::get<5>(lm);
|
|
|
cp.landmark_dis=std::get<6>(lm);
|
|
|
|
|
|
- cp.biz_stat = state();
|
|
|
+ cp.biz_stat = get_stat();
|
|
|
+ cp.down_time = m_mine_tool->get_down_time();
|
|
|
+ cp.work_time = m_mine_tool->get_work_time();
|
|
|
+ cp.is_on_duty= m_mine_tool->is_on_duty();
|
|
|
+
|
|
|
upt_card_pos(cp,pt);
|
|
|
}
|
|
|
- int state()
|
|
|
- {
|
|
|
- int status = get_stat();
|
|
|
- if(status == STATUS_NORMAL)
|
|
|
- {
|
|
|
- //超时
|
|
|
- }
|
|
|
- return status;
|
|
|
- }
|
|
|
point getSmoothPoint()
|
|
|
{
|
|
|
point pt;
|
|
@@ -276,25 +319,49 @@ private:
|
|
|
}
|
|
|
};
|
|
|
|
|
|
-struct car:card_location_base,private card_area
|
|
|
+struct car:card_location_base,card_area
|
|
|
{
|
|
|
int m_vehicle_category_id=0;
|
|
|
- car(std::string type,uint32_t cardid,uint16_t needdisplay,int16_t t,int32_t deptid,int32_t categoryid)
|
|
|
- :card_location_base(type,cardid,needdisplay,t,deptid)
|
|
|
+ int m_vehicle_type_id=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)
|
|
|
,m_vehicle_category_id(categoryid)
|
|
|
+ ,m_vehicle_type_id(type_id)
|
|
|
{
|
|
|
m_message_handle=new card_message_handle(this);
|
|
|
}
|
|
|
|
|
|
virtual void site_hover(int sid)
|
|
|
{
|
|
|
- m_site_area->on_point(m_id,sid,0);
|
|
|
+ if(m_time<=0)
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ m_site_area->on_point(m_id,sid,0, m_type);
|
|
|
}
|
|
|
|
|
|
+ virtual std::shared_ptr<area_hover> get_area_hover()
|
|
|
+ {
|
|
|
+ return m_area_tool->m_area_hover;
|
|
|
+ }
|
|
|
+
|
|
|
+ virtual std::shared_ptr<mine_tool> get_mine_tool()
|
|
|
+ {
|
|
|
+ return m_mine_tool;
|
|
|
+ }
|
|
|
+
|
|
|
+ virtual std::shared_ptr<site_area_hover> get_site_area()
|
|
|
+ {
|
|
|
+ return m_site_area;
|
|
|
+ }
|
|
|
+
|
|
|
virtual void do_business(const point &pt)
|
|
|
{
|
|
|
m_area_tool->on_point(m_id,pt,m_speed,m_type);
|
|
|
- m_site_area->on_point(m_id,0,this);
|
|
|
+ m_site_area->on_point(m_id,0,this, m_type);
|
|
|
+
|
|
|
+ m_mine_tool->on_point(m_id, m_type, m_vehicle_category_id);
|
|
|
}
|
|
|
|
|
|
void set(ev::dynamic_loop * loop)
|
|
@@ -306,6 +373,12 @@ struct car:card_location_base,private card_area
|
|
|
m_timer.set<car,&car::on_timer>(this);
|
|
|
m_timer.start(1,1);
|
|
|
}
|
|
|
+
|
|
|
+ int get_vehicle_type_id()
|
|
|
+ {
|
|
|
+ return m_vehicle_type_id;
|
|
|
+ }
|
|
|
+
|
|
|
~car(){}
|
|
|
private:
|
|
|
void on_timer()
|
|
@@ -316,12 +389,6 @@ private:
|
|
|
int statbiz(int32_t special_id)
|
|
|
{
|
|
|
int status = get_stat();
|
|
|
- if(status==STATUS_NORMAL)
|
|
|
- {
|
|
|
- //超速
|
|
|
- //超时
|
|
|
- //顺序不能变
|
|
|
- }
|
|
|
if(status == STATUS_LOST)
|
|
|
{
|
|
|
if(!m_area_tool->special_area())
|
|
@@ -350,11 +417,10 @@ private:
|
|
|
cp.landmark_dis=std::get<6>(lm);
|
|
|
int32_t biz_stat=statbiz(special_id);
|
|
|
cp.biz_stat=biz_stat;
|
|
|
- //cp.down_time
|
|
|
- //cp.work_time;
|
|
|
- //cp.level_id;
|
|
|
+ cp.down_time = m_mine_tool->get_down_time();
|
|
|
+ cp.work_time = m_mine_tool->get_work_time();
|
|
|
//for now
|
|
|
- cp.is_on_duty=1;
|
|
|
+ cp.is_on_duty=m_mine_tool->is_on_duty();
|
|
|
upt_card_pos(cp,pt);
|
|
|
|
|
|
if(biz_stat==STATUS_LOST && special_id != -1 && m_display==1)
|
|
@@ -383,7 +449,7 @@ uint64_t card_list::getId(uint32_t cardid,uint64_t type)
|
|
|
void card_list::init_vehicle()
|
|
|
{
|
|
|
std::unordered_map<uint64_t,std::shared_ptr<card_location_base>> map;
|
|
|
- std::string strategy = config.get("person.strategy","car1");
|
|
|
+ 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,\
|
|
@@ -447,7 +513,8 @@ void card_list::init_vehicle()
|
|
|
//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);
|
|
|
+ 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});
|
|
@@ -507,7 +574,7 @@ void card_list::init_staffer()
|
|
|
//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);
|
|
|
+ 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});
|
|
@@ -523,6 +590,276 @@ void card_list::init_card_from_db()
|
|
|
init_vehicle();
|
|
|
}
|
|
|
|
|
|
+void card_list::load_his_card_postion_from_db()
|
|
|
+{
|
|
|
+ load_his_card_postion_vehicle();
|
|
|
+ load_his_card_postion_staff();
|
|
|
+
|
|
|
+ for(auto&iter: m_map)
|
|
|
+ {
|
|
|
+ auto card_ptr = iter.second;
|
|
|
+ auto mine_tool_ptr = card_ptr->get_mine_tool();
|
|
|
+ if(mine_tool_ptr->is_attendance())
|
|
|
+ {
|
|
|
+ auto str = tool_time::to_str_ex( tool_time::to_ms(mine_tool_ptr->m_attendance_start_time));
|
|
|
+ std_debug("加载考勤,考勤开始时间: %s, 卡id=%d,卡type=%d", str.c_str(), card_ptr->m_id, card_ptr->m_type);
|
|
|
+ log_info("加载考勤,考勤开始时间: %s, 卡id=%d,卡type=%d", str.c_str(), card_ptr->m_id, card_ptr->m_type);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ auto area_map = area_list::instance()->m_map;
|
|
|
+ for(auto&iter: area_map)
|
|
|
+ {
|
|
|
+ auto area_ptr = iter.second;
|
|
|
+ if(area_ptr->m_person_count)
|
|
|
+ {
|
|
|
+ std_debug("加载区域人数: 区域id=%d,区域人数=%d",area_ptr->m_id, area_ptr->m_person_count.load());
|
|
|
+ log_info("加载区域人数: 区域id=%d,区域人数=%d",area_ptr->m_id, area_ptr->m_person_count.load());
|
|
|
+ }
|
|
|
+
|
|
|
+ if(area_ptr->m_vehicle_count)
|
|
|
+ {
|
|
|
+ std_debug("加载区域车数: 区域id=%d,区域车数=%d",area_ptr->m_id, area_ptr->m_vehicle_count.load());
|
|
|
+ log_info("加载区域车数: 区域id=%d,区域车数=%d",area_ptr->m_id, area_ptr->m_vehicle_count.load());
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+void card_list::load_his_card_postion_vehicle()
|
|
|
+{
|
|
|
+ const char *sql = "select l.card_id, l.cur_time, l.x, l.y, l.z, l.map_id, la.area_id, l.state, \
|
|
|
+ case when l.cur_time >= date_sub(now(), interval 2 minute) then l.speed else 0 end as speed, \
|
|
|
+ l.mileage, la.enter_time, att.start_time, \
|
|
|
+ att.end_time, \
|
|
|
+ l.landmark_id, l.direction_mapper_id, l.landmark_dist \
|
|
|
+ from rt_location l, rt_location_area la, rt_att_vehicle att, dat_card c, dat_vehicle_extend v \
|
|
|
+ where l.card_id = c.card_id and l.card_id = la.card_id and l.card_id = att.card_id and l.card_id=v.card_id \
|
|
|
+ and c.state_id=0;";
|
|
|
+ std::string Error;
|
|
|
+ YADB::CDBResultSet DBRes;
|
|
|
+ sDBConnPool.Query(sql,DBRes,Error);
|
|
|
+ if(!Error.empty())
|
|
|
+ log_error("load_his_card_postion_vehicle列表 Error,%s",Error.c_str());
|
|
|
+ uint64_t nCount = DBRes.GetRecordCount( Error );
|
|
|
+ if (nCount > 0)
|
|
|
+ {
|
|
|
+ log_info( "load_his_card_postion_vehicle. The record count=%ld\n", nCount );
|
|
|
+
|
|
|
+ while ( DBRes.GetNextRecod(Error) )
|
|
|
+ {
|
|
|
+ std::string card_id = "";
|
|
|
+ DBRes.GetField( "card_id",card_id, Error );
|
|
|
+
|
|
|
+ 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));
|
|
|
+ if(!temp_ptr || !temp_ptr->is_vehicle())
|
|
|
+ {
|
|
|
+ log_error("全局卡列表中找不到卡,卡id=%d,卡type=%d", id, type);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ auto card_ptr = static_cast<car*>(temp_ptr.get());
|
|
|
+
|
|
|
+ double x = 0;
|
|
|
+ DBRes.GetField( "x",x, Error );
|
|
|
+
|
|
|
+ double y = 0;
|
|
|
+ DBRes.GetField( "y",y, Error );
|
|
|
+
|
|
|
+ double z = 0;
|
|
|
+ DBRes.GetField( "z",z, Error );
|
|
|
+
|
|
|
+ int map_id = 0;
|
|
|
+ DBRes.GetField( "map_id",map_id, Error );
|
|
|
+
|
|
|
+ int area_id = 0;
|
|
|
+ DBRes.GetField( "area_id",area_id, Error );
|
|
|
+
|
|
|
+ int state = 0;
|
|
|
+ DBRes.GetField( "state",state, Error );
|
|
|
+
|
|
|
+ double speed = 0;
|
|
|
+ DBRes.GetField( "speed",speed, Error );
|
|
|
+
|
|
|
+ std::string enter_time = "";
|
|
|
+ DBRes.GetField( "enter_time",enter_time, Error );
|
|
|
+
|
|
|
+ std::string start_time = "";
|
|
|
+ DBRes.GetField( "start_time",start_time, Error );
|
|
|
+
|
|
|
+ std::string end_time = "";
|
|
|
+ DBRes.GetField( "end_time",end_time, Error );
|
|
|
+
|
|
|
+ int landmark_id = 0;
|
|
|
+ DBRes.GetField( "landmark_id",landmark_id, Error );
|
|
|
+
|
|
|
+ int direction_mapper_id = 0;
|
|
|
+ DBRes.GetField( "direction_mapper_id",direction_mapper_id, Error );
|
|
|
+
|
|
|
+ double landmark_dist = 0;
|
|
|
+ DBRes.GetField( "landmark_dist",landmark_dist, Error );
|
|
|
+
|
|
|
+ card_ptr->x = x;
|
|
|
+ card_ptr->y = y;
|
|
|
+ card_ptr->z = z;
|
|
|
+
|
|
|
+ auto area = area_list::instance()->get(area_id);
|
|
|
+ if(area == nullptr)
|
|
|
+ {
|
|
|
+ log_error("load_vehicle...area_list 找不到区域:区域id=%d", area_id);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ area->m_vehicle_count++;
|
|
|
+
|
|
|
+ point pt = *card_ptr;
|
|
|
+ card_ptr->m_area_tool->m_area_hover = std::make_shared<area_hover>( area, pt,speed);
|
|
|
+ auto area_hover_ptr = card_ptr->get_area_hover();
|
|
|
+
|
|
|
+ auto e_t = tool_time::to_time_ex(enter_time);
|
|
|
+ area_hover_ptr->m_enter_time = std::chrono::system_clock::to_time_t(e_t);
|
|
|
+
|
|
|
+ //int map_id = 0;
|
|
|
+ //int state = 0;
|
|
|
+ card_ptr->m_speed = speed;
|
|
|
+
|
|
|
+ if(end_time.empty())
|
|
|
+ {
|
|
|
+ auto mine_tool_ptr = card_ptr->get_mine_tool();
|
|
|
+ mine_tool_ptr->m_attendance_start_time = tool_time::to_time_ex(start_time);
|
|
|
+ mine_tool_ptr->m_stat_attendance = AS_ATTENDANCE;
|
|
|
+ }
|
|
|
+
|
|
|
+ area_hover_ptr->landmark_id = landmark_id;
|
|
|
+ area_hover_ptr->landmark_dir = direction_mapper_id;
|
|
|
+ area_hover_ptr->landmark_dis = landmark_dist;
|
|
|
+
|
|
|
+ card_ptr->m_time = tool_time::now_to_ms();
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+void card_list::load_his_card_postion_staff()
|
|
|
+{
|
|
|
+ const char *sql = "select l.card_id, l.cur_time, l.x, l.y, l.z, l.map_id, la.area_id, l.state, \
|
|
|
+ case when l.cur_time >= date_sub(now(), interval 2 minute) then l.speed else 0 end as speed, \
|
|
|
+ l.mileage, la.enter_time, att.start_time, \
|
|
|
+ att.end_time, \
|
|
|
+ l.landmark_id, l.direction_mapper_id, l.landmark_dist \
|
|
|
+ from rt_location l, rt_location_area la, rt_att_staff att, dat_card c, dat_staff_extend s \
|
|
|
+ where l.card_id = c.card_id and l.card_id = la.card_id and l.card_id = att.card_id and l.card_id=s.card_id\
|
|
|
+ and c.state_id=0;";
|
|
|
+ std::string Error;
|
|
|
+ YADB::CDBResultSet DBRes;
|
|
|
+ sDBConnPool.Query(sql,DBRes,Error);
|
|
|
+ if(!Error.empty())
|
|
|
+ log_error("load_his_card_postion_vehicle列表 Error,%s",Error.c_str());
|
|
|
+ uint64_t nCount = DBRes.GetRecordCount( Error );
|
|
|
+ if (nCount > 0)
|
|
|
+ {
|
|
|
+ log_info( "load_his_card_postion_vehicle. The record count=%ld\n", nCount );
|
|
|
+
|
|
|
+ while ( DBRes.GetNextRecod(Error) )
|
|
|
+ {
|
|
|
+ std::string end_time = "";
|
|
|
+ DBRes.GetField( "end_time",end_time, Error );
|
|
|
+ if(!end_time.empty()) // 已升井,不再读入
|
|
|
+ {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ std::string card_id = "";
|
|
|
+ DBRes.GetField( "card_id",card_id, Error );
|
|
|
+
|
|
|
+ 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));
|
|
|
+ if(!temp_ptr || !temp_ptr->is_person())
|
|
|
+ {
|
|
|
+ log_error("全局卡列表中找不到卡,卡id=%d,卡type=%d", id, type);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ auto card_ptr = static_cast<car*>(temp_ptr.get());
|
|
|
+
|
|
|
+ double x = 0;
|
|
|
+ DBRes.GetField( "x",x, Error );
|
|
|
+
|
|
|
+ double y = 0;
|
|
|
+ DBRes.GetField( "y",y, Error );
|
|
|
+
|
|
|
+ double z = 0;
|
|
|
+ DBRes.GetField( "z",z, Error );
|
|
|
+
|
|
|
+ int map_id = 0;
|
|
|
+ DBRes.GetField( "map_id",map_id, Error );
|
|
|
+
|
|
|
+ int area_id = 0;
|
|
|
+ DBRes.GetField( "area_id",area_id, Error );
|
|
|
+
|
|
|
+ int state = 0;
|
|
|
+ DBRes.GetField( "state",state, Error );
|
|
|
+
|
|
|
+ double speed = 0;
|
|
|
+ DBRes.GetField( "speed",speed, Error );
|
|
|
+
|
|
|
+ std::string enter_time = "";
|
|
|
+ DBRes.GetField( "enter_time",enter_time, Error );
|
|
|
+
|
|
|
+ std::string start_time = "";
|
|
|
+ DBRes.GetField( "start_time",start_time, Error );
|
|
|
+
|
|
|
+ int landmark_id = 0;
|
|
|
+ DBRes.GetField( "landmark_id",landmark_id, Error );
|
|
|
+
|
|
|
+ int direction_mapper_id = 0;
|
|
|
+ DBRes.GetField( "direction_mapper_id",direction_mapper_id, Error );
|
|
|
+
|
|
|
+ double landmark_dist = 0;
|
|
|
+ DBRes.GetField( "landmark_dist",landmark_dist, Error );
|
|
|
+
|
|
|
+ card_ptr->x = x;
|
|
|
+ card_ptr->y = y;
|
|
|
+ card_ptr->z = z;
|
|
|
+
|
|
|
+ auto area = area_list::instance()->get(area_id);
|
|
|
+ if(area == nullptr)
|
|
|
+ {
|
|
|
+ log_error("area_list 找不到区域:区域id=%d", area_id);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ area->m_person_count++;
|
|
|
+
|
|
|
+ point pt = *card_ptr;
|
|
|
+ card_ptr->m_area_tool->m_area_hover = std::make_shared<area_hover>(area,pt,speed);
|
|
|
+ auto area_hover_ptr = card_ptr->get_area_hover();
|
|
|
+
|
|
|
+ auto e_t = tool_time::to_time_ex(enter_time);
|
|
|
+ area_hover_ptr->m_enter_time = std::chrono::system_clock::to_time_t(e_t);
|
|
|
+ log_info("load_staff...%d,areaid:%d,mapid:%d",id,area->id(),area->mapid());
|
|
|
+
|
|
|
+ //int map_id = 0;
|
|
|
+ //int state = 0;
|
|
|
+ card_ptr->m_speed = speed;
|
|
|
+
|
|
|
+ if(end_time.empty())
|
|
|
+ {
|
|
|
+ auto mine_tool_ptr = card_ptr->get_mine_tool();
|
|
|
+ mine_tool_ptr->m_attendance_start_time = tool_time::to_time_ex(start_time);
|
|
|
+ mine_tool_ptr->m_stat_attendance = AS_ATTENDANCE;
|
|
|
+ }
|
|
|
+
|
|
|
+ area_hover_ptr->landmark_id = landmark_id;
|
|
|
+ area_hover_ptr->landmark_dir = direction_mapper_id;
|
|
|
+ area_hover_ptr->landmark_dis = landmark_dist;
|
|
|
+
|
|
|
+ card_ptr->m_time = tool_time::now_to_ms();
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
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);
|
|
@@ -539,11 +876,17 @@ void card_list::on_message(zloop<task*> *loop,const message_locinfo&loc,bool is_
|
|
|
c->on_message(loop,loc,is_history);
|
|
|
}
|
|
|
//-----------------card_location_base..
|
|
|
-card_location_base::card_location_base(std::string type,uint32_t id,uint16_t dis,int16_t t,int32_t deptid)
|
|
|
- :card(id,dis,t,deptid)
|
|
|
+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)
|
|
|
{
|
|
|
select_tool_manage::instance()->create_tool(type,m_sel_tool,m_smo_tool);
|
|
|
}
|
|
|
+
|
|
|
+void card_location_base::do_status(STATUS_CARD st)
|
|
|
+{
|
|
|
+ module_mgr::do_status(st, m_id, m_type);
|
|
|
+}
|
|
|
+
|
|
|
void card_location_base::on_location(const std::vector<point>&vp,const std::vector<loc_message> &lm )
|
|
|
{
|
|
|
//ct timestamp;
|
|
@@ -558,7 +901,8 @@ void card_location_base::on_location(const std::vector<point>&vp,const std::vect
|
|
|
y = pt.y;
|
|
|
|
|
|
Msg m;
|
|
|
- m.x=(int)x;m.y=(int)y;m.cmd=CMD_HANDLE;m.cardid=m_type<<32|m_id;
|
|
|
+
|
|
|
+ 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);
|
|
@@ -588,21 +932,54 @@ void card_location_base::upt_card_pos(YA::_CARD_POS_ &cp,const point &pt)
|
|
|
cp.dept_id = m_deptid;
|
|
|
cp.display=m_display;
|
|
|
cp.rec_time=m_time;
|
|
|
+ cp.level_id = m_level_id;
|
|
|
|
|
|
swsTimerThrd.upt_card_pos(cp);
|
|
|
}
|
|
|
+void card_location_base::del_card_pos()
|
|
|
+{
|
|
|
+ YA::_CARD_POS_ cp;
|
|
|
+ cp.ID = m_id;
|
|
|
+ cp.Type=m_type;
|
|
|
+ swsTimerThrd.del_card_pos(cp);
|
|
|
+}
|
|
|
int card_location_base::get_stat()
|
|
|
{
|
|
|
//盲区>呼救>呼叫>超时>超速>正常
|
|
|
- int status=STATUS_NORMAL;
|
|
|
- if(false)
|
|
|
- status = STATUS_CALL;
|
|
|
- if(false)
|
|
|
- status = STATUS_HELP;
|
|
|
-
|
|
|
- uint64_t now = time(0)*1000;
|
|
|
- status=(now-m_time>CARD_LOST_TIME_OUT)?STATUS_LOST:STATUS_NORMAL;
|
|
|
- return status;
|
|
|
+ uint64_t now = time(0)*1000;
|
|
|
+ if(now-m_time>CARD_LOST_TIME_OUT)
|
|
|
+ {
|
|
|
+ return STATUS_LOST;
|
|
|
+ }
|
|
|
+ else if(auto ev_ptr = event_list::instance()->get_event_card(m_id, m_type, ET_CARD_HELP))
|
|
|
+ {
|
|
|
+ return (ES_DEAL_HELP == ev_ptr->m_status) ? STATUS_HELP_DEALED : STATUS_HELP;
|
|
|
+ }
|
|
|
+ else if(CALL_NONE != get_mine_tool()->m_status_call)
|
|
|
+ {
|
|
|
+ return STATUS_CALL;
|
|
|
+ }
|
|
|
+ else if(event_list::instance()->get_event_card(m_id, m_type,
|
|
|
+ is_person()? ET_CARD_AREA_OVER_TIME_PERSON: ET_CARD_AREA_OVER_TIME_VEHICLE))
|
|
|
+ {
|
|
|
+ return STATUS_AREA_OVER_TIME;
|
|
|
+ }
|
|
|
+ else if(event_list::instance()->get_event_card(m_id, m_type, ET_CARD_OVER_SPEED))
|
|
|
+ {
|
|
|
+ return STATUS_OVER_SPEED;
|
|
|
+ }
|
|
|
+
|
|
|
+ return STATUS_NORMAL;
|
|
|
+}
|
|
|
+
|
|
|
+void card_location_base::clear()
|
|
|
+{
|
|
|
+// uint16_t m_display; //1显示0不显示,往前端推送
|
|
|
+ m_speed=0; //速度
|
|
|
+ m_is_attendance=0; //井上井下状态 0初始状态 1 井上 2 井下
|
|
|
+ m_stat=0; //运动静止状态
|
|
|
+ //m_ct; //ct
|
|
|
+ m_time=0; //时间戳
|
|
|
}
|
|
|
card_location_base::~card_location_base()
|
|
|
{
|