瀏覽代碼

细化日志显示

zzj 6 年之前
父節點
當前提交
fd1e1313d1
共有 6 個文件被更改,包括 35 次插入24 次删除
  1. 14 10
      area.cpp
  2. 1 1
      area.h
  3. 17 10
      area_business.cpp
  4. 1 1
      area_business.h
  5. 1 1
      mine_business.cpp
  6. 1 1
      module_service/area_business_card_enter_or_leave.cpp

+ 14 - 10
area.cpp

@@ -74,7 +74,7 @@ area::area(int id,int limit_count_person, int limit_time_person,double scale,int
      ,m_person_count(0)
      ,m_person_count(0)
      ,m_vehicle_count(0)
      ,m_vehicle_count(0)
     {
     {
-		m_area_business_list=area_business::get_instance_list(m_area_type);
+		m_area_business_list=area_business::get_instance_list(m_area_type,id);
 		m_event_person_count = false;
 		m_event_person_count = false;
 		m_event_vehicle_count = false;
 		m_event_vehicle_count = false;
     }
     }
@@ -232,11 +232,11 @@ void area_list::init_monkeycar_area(int id)
         {
         {
             std::shared_ptr<db_area>  da = std::make_shared<db_area>();
             std::shared_ptr<db_area>  da = std::make_shared<db_area>();
             da->m_default_speed = monkeycar_speed;
             da->m_default_speed = monkeycar_speed;
-            da->m_point = init_path(monkeycar_coor);
+            da->m_point = init_path(monkeycar_coor,area_id);
             std::shared_ptr<area> ap = std::make_shared<monkey_area>(da,area_id,over_count_person, over_time_person,scale,map_id,b_type);
             std::shared_ptr<area> ap = std::make_shared<monkey_area>(da,area_id,over_count_person, over_time_person,scale,map_id,b_type);
             ap->update(over_count_person, over_time_person,scale,map_id,area_type_id, over_count_vehicle,over_time_vehicle);
             ap->update(over_count_person, over_time_person,scale,map_id,area_type_id, over_count_vehicle,over_time_vehicle);
 
 
-            ap->m_bound=init_path(path);
+            ap->m_bound=init_path(path,area_id);
             for(const auto &p : ap->m_bound)
             for(const auto &p : ap->m_bound)
               log_info("point:monkey:area_id:%d--x:%.2f,y:%.2f",area_id,p.x,p.y);
               log_info("point:monkey:area_id:%d--x:%.2f,y:%.2f",area_id,p.x,p.y);
             for(const auto &p : da->m_point)
             for(const auto &p : da->m_point)
@@ -249,14 +249,14 @@ void area_list::init_monkeycar_area(int id)
 			//这里后续需要把猴车得信息传递过去
 			//这里后续需要把猴车得信息传递过去
             std::shared_ptr<db_area>  da = std::make_shared<db_area>();
             std::shared_ptr<db_area>  da = std::make_shared<db_area>();
             da->m_default_speed = monkeycar_speed;
             da->m_default_speed = monkeycar_speed;
-            da->m_point = init_path(monkeycar_coor);
+            da->m_point = init_path(monkeycar_coor,area_id);
 			std::shared_ptr<area> ap = std::make_shared<monkey_area>(da,area_id,over_count_person, over_time_person,scale,map_id,b_type);
 			std::shared_ptr<area> ap = std::make_shared<monkey_area>(da,area_id,over_count_person, over_time_person,scale,map_id,b_type);
 			if(auto area_=area_list::instance()->get(id))
 			if(auto area_=area_list::instance()->get(id))
 				area_=ap;
 				area_=ap;
 			else
 			else
 				area_list::instance()->add(area_id,ap);
 				area_list::instance()->add(area_id,ap);
 
 
-            ap->m_bound=init_path(path);
+            ap->m_bound=init_path(path,area_id);
             ap->update(over_count_person, over_time_person,scale,map_id,area_type_id, over_count_vehicle,over_time_vehicle);
             ap->update(over_count_person, over_time_person,scale,map_id,area_type_id, over_count_vehicle,over_time_vehicle);
             for(const auto &p : ap->m_bound)
             for(const auto &p : ap->m_bound)
               log_info("point:monkey:area_id:%d--x:%.2f,y:%.2f",area_id,p.x,p.y);
               log_info("point:monkey:area_id:%d--x:%.2f,y:%.2f",area_id,p.x,p.y);
@@ -374,7 +374,7 @@ void area_list::init_from_db(int id/*=-1*/)
             ap->m_over_speed_vehicle = over_speed_vehicle;
             ap->m_over_speed_vehicle = over_speed_vehicle;
             ap->m_is_work_area = is_work_area;
             ap->m_is_work_area = is_work_area;
 
 
-            ap->m_bound=init_path(path);
+            ap->m_bound=init_path(path,area_id);
             for(const auto &p : ap->m_bound)
             for(const auto &p : ap->m_bound)
               log_info("point:area_id:%d--x:%.2f,y:%.2f",area_id,p.x,p.y);
               log_info("point:area_id:%d--x:%.2f,y:%.2f",area_id,p.x,p.y);
             map.insert({area_id,ap});
             map.insert({area_id,ap});
@@ -388,7 +388,7 @@ void area_list::init_from_db(int id/*=-1*/)
                 area_list::instance()->add(id, tmp_ptr);
                 area_list::instance()->add(id, tmp_ptr);
             }
             }
             tmp_ptr->update(over_count_person, over_time_person,scale,map_id,area_type_id, over_count_vehicle,over_time_vehicle);
             tmp_ptr->update(over_count_person, over_time_person,scale,map_id,area_type_id, over_count_vehicle,over_time_vehicle);
-            tmp_ptr->m_bound=init_path(path);
+            tmp_ptr->m_bound=init_path(path,area_id);
             tmp_ptr->m_over_speed_vehicle = over_speed_vehicle;
             tmp_ptr->m_over_speed_vehicle = over_speed_vehicle;
             tmp_ptr->m_is_work_area = is_work_area;
             tmp_ptr->m_is_work_area = is_work_area;
             for(const auto &p : tmp_ptr->m_bound)
             for(const auto &p : tmp_ptr->m_bound)
@@ -409,10 +409,12 @@ void area_list::init_from_db(int id/*=-1*/)
     init_monkeycar_area(id);
     init_monkeycar_area(id);
 }
 }
 
 
-std::vector<point> area_list::init_path(std::string &str)
+std::vector<point> area_list::init_path(std::string &str,int area_id)
 {
 {
 	if(str.empty())
 	if(str.empty())
-	  log_error("area path empty()...");
+	{
+	  log_error("area path is empty,area_id=%d.",area_id);
+	}
 	std::vector<point> vp;
 	std::vector<point> vp;
 	std::vector<std::string> vs;
 	std::vector<std::string> vs;
 	std::vector<std::string> vs1;
 	std::vector<std::string> vs1;
@@ -423,7 +425,9 @@ std::vector<point> area_list::init_path(std::string &str)
 		  continue;
 		  continue;
 		boost::split(vs1,s,boost::is_any_of(","));
 		boost::split(vs1,s,boost::is_any_of(","));
 		if(vs1.size()!=2)
 		if(vs1.size()!=2)
-		  log_error("area path data Error.pls check data table.");
+		{
+		  log_error("area path data Error.pls check data table,area_id=%d",area_id);
+		}
 		vp.emplace_back(atof(vs1[0].c_str()),atof(vs1[1].c_str()));
 		vp.emplace_back(atof(vs1[0].c_str()),atof(vs1[1].c_str()));
 	}
 	}
 	return std::move(vp);
 	return std::move(vp);

+ 1 - 1
area.h

@@ -114,7 +114,7 @@ struct area_list:single_base<area_list,int,std::shared_ptr<area>>
 
 
 	//根据分站、所在点找出所在区域列表
 	//根据分站、所在点找出所在区域列表
 	std::vector<std::shared_ptr<area>> get_area(const std::shared_ptr<site>& s,const std::shared_ptr<card_location_base> &c,const point&pt,int &);
 	std::vector<std::shared_ptr<area>> get_area(const std::shared_ptr<site>& s,const std::shared_ptr<card_location_base> &c,const point&pt,int &);
-    std::vector<point> init_path(std::string  &str);
+    std::vector<point> init_path(std::string  &str,int area_id);
     ///id=-1为初始化所有
     ///id=-1为初始化所有
     void init_from_db(int id=-1);
     void init_from_db(int id=-1);
     void init_monkeycar_area(int id=-1);
     void init_monkeycar_area(int id=-1);

+ 17 - 10
area_business.cpp

@@ -1,5 +1,6 @@
 
 
 #include <assert.h>
 #include <assert.h>
+#include "log.h"
 #include "area_business.h"
 #include "area_business.h"
 #include "area_business_car_attendance.h"
 #include "area_business_car_attendance.h"
 #include "area_business_card_enter_or_leave.h"
 #include "area_business_card_enter_or_leave.h"
@@ -29,7 +30,7 @@ struct area_business_factory
 		m_check_list[type].reset(ab);
 		m_check_list[type].reset(ab);
 	}
 	}
 
 
-	std::vector<area_business*> get_check_list(int business_type)
+	std::vector<area_business*> get_check_list(int business_type,int area_id)
 	{
 	{
 		std::vector<area_business*> check_list;
 		std::vector<area_business*> check_list;
 		for(int i=0;i<32;i++)
 		for(int i=0;i<32;i++)
@@ -38,13 +39,19 @@ struct area_business_factory
 				break;
 				break;
 
 
 			if((business_type&1)==0)
 			if((business_type&1)==0)
-            {
-                business_type >>= 1;
+			{
+				business_type >>= 1;
 				continue;
 				continue;
-            }
+			}
 
 
 			business_type >>= 1;
 			business_type >>= 1;
 
 
+			if(!m_check_list[i])
+			{
+				log_error("区域业务项目不存在:%d,area_id=%d",i,area_id);
+				continue;
+			}
+
 			check_list.push_back(m_check_list[i].get());
 			check_list.push_back(m_check_list[i].get());
 		}
 		}
 
 
@@ -56,7 +63,7 @@ struct area_business_factory
 		static area_business_factory _instance;
 		static area_business_factory _instance;
 		return _instance;
 		return _instance;
 	}
 	}
-private:
+	private:
 	std::vector<std::unique_ptr<area_business>> m_check_list;
 	std::vector<std::unique_ptr<area_business>> m_check_list;
 	area_business_factory()
 	area_business_factory()
 	{
 	{
@@ -70,15 +77,15 @@ private:
 		//regist(8,new area_business_monkey_area);
 		//regist(8,new area_business_monkey_area);
 		regist(9,new area_business_card_enter_or_leave);
 		regist(9,new area_business_card_enter_or_leave);
 
 
-        regist(10, new area_business_motionless_persion);
-        regist(11, new area_business_geofault);
-        regist(12, new area_business_work_rate);
+		regist(10, new area_business_motionless_persion);
+		regist(11, new area_business_geofault);
+		regist(12, new area_business_work_rate);
 	}
 	}
 
 
 };
 };
 
 
-std::vector<area_business*> area_business::get_instance_list(int business_type)
+std::vector<area_business*> area_business::get_instance_list(int business_type,int area_id)
 {
 {
-	return area_business_factory::instance().get_check_list(business_type);
+	return area_business_factory::instance().get_check_list(business_type,area_id);
 }
 }
 
 

+ 1 - 1
area_business.h

@@ -22,7 +22,7 @@ struct area_business
 
 
 	virtual ~area_business(){};
 	virtual ~area_business(){};
 
 
-	static std::vector<area_business*> get_instance_list(int business_type);
+	static std::vector<area_business*> get_instance_list(int business_type,int area_id);
 };
 };
 #endif
 #endif
 
 

+ 1 - 1
mine_business.cpp

@@ -394,7 +394,7 @@ void card_sensor_mgr::for_each()
         int nCount = DBRes.GetRecordCount( Error );
         int nCount = DBRes.GetRecordCount( Error );
         if (nCount < 1)
         if (nCount < 1)
         {
         {
-            log_error("load_sensor_data..failed[%s]", strsql);
+            log_warn("load_sensor_data..failed[%s]", strsql);
             continue;
             continue;
         }
         }
 
 

+ 1 - 1
module_service/area_business_card_enter_or_leave.cpp

@@ -23,7 +23,7 @@ void area_business_card_enter_or_leave::on_enter(const std::shared_ptr<area_hove
     const auto &p=a->m_enter_point;
     const auto &p=a->m_enter_point;
     snprintf(sql,LENGTH_SQL,"INSERT INTO his_location_area (obj_id,card_type_id,ident,area_id,map_id,enter_time,start_point) \
     snprintf(sql,LENGTH_SQL,"INSERT INTO his_location_area (obj_id,card_type_id,ident,area_id,map_id,enter_time,start_point) \
 	                         VALUES ('%d','%d','%d',%d,%d,'%s','%.2f,%.2f');",
 	                         VALUES ('%d','%d','%d',%d,%d,'%s','%.2f,%.2f');",
-				c->m_cid,c->m_type,c->m_id, a->id(),a->mapid(),start_time.c_str(),p.x,p.y);
+				c->m_cid,(int)c->m_type,c->m_id, a->id(),a->mapid(),start_time.c_str(),p.x,p.y);
 
 
     db_tool::PushAsync(sql);
     db_tool::PushAsync(sql);
 }
 }