Browse Source

Merge branch 'master' of http://local.beijingyongan.com:3000/linux-dev/ya-serv

chensongchao 5 years ago
parent
commit
4f21613daf
4 changed files with 30 additions and 15 deletions
  1. 15 9
      area.cpp
  2. 3 2
      card.cpp
  3. 10 3
      card_base.cpp
  4. 2 1
      card_person.cpp

+ 15 - 9
area.cpp

@@ -193,7 +193,7 @@ void area::on_load_his(const std::shared_ptr<area_hover>&a,const std::shared_ptr
 
 void area::on_leave(const std::shared_ptr<area_hover>&a,const std::shared_ptr<card_location_base>&c)
 {
-	log_info("on_leave..%d  areaId:%d",c->m_id,m_id);
+	log_info("on_leave..card=%d  areaId=%d",c->m_id,m_id);
 	a->m_last_time=tool_time::now_to_ms();
 	a->m_last_point=*c;
  	for(const auto &i:m_area_business_list)
@@ -724,6 +724,7 @@ void area_tool::on_point(const std::shared_ptr<card_location_base>& c,const poin
 		}
 	}
 
+
 	while(c1!=ce)
 	{
 		if((*c1)->m_area->get_frozen_count()==0)
@@ -767,13 +768,16 @@ void area_tool::on_point(const std::shared_ptr<card_location_base>& c,const poin
                  strAreaInfo += tmpArea;
              }
          }
-         char sql[1024] = {0};
-         std::string _time=tool_time::to_str_ex(c->time_());
-         snprintf(sql, 1024, "REPLACE INTO rt_location (card_id, site_id,cur_time, x, y, z, state, area_info) VALUES (%s, %d,'%s',%lf, %lf, %lf, 0, '%s');",
-             tool_other::type_id_to_str(c->m_type, c->m_id).c_str(), m_site->id(),_time.c_str(), pt.x, pt.y, pt.z, strAreaInfo.c_str());
-         db_tool::PushAsync(sql);
-         log_info("insert rt_location: card=%d site_id=%d,point=%.2f-%.2f,area_info=%s"
-                 ,c->m_id,m_site->id(),pt.x,pt.y,strAreaInfo.c_str());
+		 if(!strAreaInfo.empty())
+		 {
+			 char sql[1024] = {0};
+			 std::string _time=tool_time::to_str_ex(c->time_());
+			 snprintf(sql, 1024, "REPLACE INTO rt_location (card_id, site_id,cur_time, x, y, z, state, area_info) VALUES (%s, %d,'%s',%lf, %lf, %lf, 0, '%s');",
+			 tool_other::type_id_to_str(c->m_type, c->m_id).c_str(), m_site->id(),_time.c_str(), pt.x, pt.y, pt.z, strAreaInfo.c_str());
+			 db_tool::PushAsync(sql);
+			 log_info("insert rt_location: card=%d site_id=%d,point=%.2f-%.2f,area_info=%s"
+			 ,c->m_id,m_site->id(),pt.x,pt.y,strAreaInfo.c_str());
+		 }
     }
 }
 
@@ -781,8 +785,10 @@ void area_tool::on_leave(const std::shared_ptr<card_location_base>& c)
 {
     for(const auto& t:m_hover_list)
     {
-        t->m_area->on_leave(t, c);
+		t->m_area->on_leave(t, c);
     }
+
+	m_hover_list.clear(); //手动升井、自动升井清除该卡区域列表
 }
 
 void area_tool::set_area_info(int mapid,double scale,int areaid,const point &pt,uint64_t t,int type)

+ 3 - 2
card.cpp

@@ -19,7 +19,6 @@
 #include "worker.h"
 #include "ya_setting.h"
 
-extern config_file config;
 int three_rates_flag=0;
 static void request(uint64_t id,uint32_t hash_id,uint16_t dis)
 {
@@ -253,9 +252,11 @@ void card_list::load_his_card_postion_staff()
             att.start_time, att.end_time \
             from rt_location l, rt_att_staff att, dat_card c, dat_staff_extend s \
             where l.card_id = c.card_id and l.card_id = att.card_id and l.card_id=s.card_id\
-            and c.state_id=0  ";
+            and c.state_id=0 and end_time is null ";
     sql += " and timestampdiff(hour ,att.start_time,now()) <= " + std::to_string(CYaSetting::g_load_person_his_data_interval) + ";";
 
+	log_info("load_his_card_postion_staff:%s\n",sql.c_str());
+
     std::string Error;
     YADB::CDBResultSet DBRes;
     sDBConnPool.Query(sql.c_str(),DBRes,Error);

+ 10 - 3
card_base.cpp

@@ -78,11 +78,18 @@ void card_location_base::do_status(int st)
 
     module_mgr::do_status((STATUS_CARD)st, m_id, m_type);
 }
+
 void card_location_base::make_his_location(uint64_t t,const point & pt,bool bclose /*= false*/)
 {
-     int sid=0,mapid=0;
-	if(auto site_ptr=get_area_tool()->m_site){sid=site_ptr->m_area_id;mapid=site_ptr->m_map_id;}
-    m_his_location_card->push(t,pt,sid,mapid,bclose);
+	int area_id=0,mapid=0,site_id=0;
+	if(auto site_ptr=get_area_tool()->m_site)
+	{
+		area_id=site_ptr->m_area_id;
+		mapid=site_ptr->m_map_id;
+		site_id=site_ptr->m_id;
+	}
+
+	m_his_location_card->push(t,pt,area_id,mapid,bclose);
 }
 
 void card_location_base::on_location(const std::vector<point>&vp,const std::vector<loc_message> &lm )

+ 2 - 1
card_person.cpp

@@ -182,9 +182,10 @@ void person::on_timer()
 		m_biz_stat=get_stat();
 	}
     print_card_detained();
+
 	if(m_upmine_flag.load())
 	{
-		log_info("card=%d cid=%d up_mine:upmine_flag=%d",m_id,m_cid, m_upmine_flag.load());
+		log_info("card=%d user-id=%d up_mine:upmine_flag=%d",m_id,m_cid, m_upmine_flag.load());
 		m_area_tool->on_leave(shared_from_this());
 		m_upmine_flag=0;
 	}