Browse Source

-----------

zzj 5 years ago
parent
commit
9830ea71e5
3 changed files with 31 additions and 11 deletions
  1. 13 6
      area.cpp
  2. 9 2
      card.cpp
  3. 9 3
      card_base.cpp

+ 13 - 6
area.cpp

@@ -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,11 +768,15 @@ 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);
+
+		 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);
+		 }
     }
 }
 
@@ -779,8 +784,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)

+ 9 - 2
card.cpp

@@ -249,11 +249,18 @@ void card_list::load_his_card_postion_vehicle()
 
 void card_list::load_his_card_postion_staff()
 {
-    const char *sql = "select l.card_id,l.site_id, l.cur_time, l.x, l.y, l.z, l.area_info, l.state, \
+    const char *sql_fmt = "select l.card_id,l.site_id, l.cur_time, l.x, l.y, l.z, l.area_info, l.state, \
             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 and att.start_time > SUBTIME(now(),'%d:00:00');"; 
+	
+	char sql[1024];
+
+	sprintf(sql,sql_fmt,config.get("init_limit_hour",48));//缺省重启时不加载大于48小时以前的入井
+
+	log_info("load_his_card_postion_staff:%s\n",sql);
+
     std::string Error;
     YADB::CDBResultSet DBRes;
     sDBConnPool.Query(sql,DBRes,Error);

+ 9 - 3
card_base.cpp

@@ -78,11 +78,17 @@ 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 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);
 }
 
 void card_location_base::on_location(const std::vector<point>&vp,const std::vector<loc_message> &lm )