|
@@ -29,8 +29,8 @@
|
|
|
|
|
|
struct underground_area:area
|
|
|
{
|
|
|
- underground_area(int id,int limit_count_person, int limit_time_person,double scale,int32_t mapid,int32_t type)
|
|
|
- :area(id,limit_count_person,limit_time_person,scale,mapid,type)
|
|
|
+ underground_area(int id,int limit_count_person, int limit_time_person,double scale,int32_t mapid,int32_t biz_type)
|
|
|
+ :area(id,limit_count_person,limit_time_person,scale,mapid,biz_type)
|
|
|
{
|
|
|
}
|
|
|
virtual bool in_area(const std::shared_ptr<site>&s,const std::shared_ptr<card_location_base>&c, const point & p,int &sarid)
|
|
@@ -41,8 +41,8 @@ struct underground_area:area
|
|
|
|
|
|
struct special_area:area
|
|
|
{
|
|
|
- special_area(int id,int limit_count_person, int limit_time_person,double scale,int32_t mapid,int32_t type)
|
|
|
- :area(id,limit_count_person,limit_time_person,scale,mapid,type)
|
|
|
+ special_area(int id,int limit_count_person, int limit_time_person,double scale,int32_t mapid,int32_t biz_type)
|
|
|
+ :area(id,limit_count_person,limit_time_person,scale,mapid,biz_type)
|
|
|
{}
|
|
|
virtual bool in_area(const std::shared_ptr<site>&s,const std::shared_ptr<card_location_base>&c, const point & p,int &sarid)
|
|
|
{
|
|
@@ -66,9 +66,9 @@ struct special_area:area
|
|
|
|
|
|
};
|
|
|
|
|
|
-area::area(int id,int limit_count_person, int limit_time_person,double scale,int32_t mapid,int32_t type)
|
|
|
+area::area(int id,int limit_count_person, int limit_time_person,double scale,int32_t mapid,int32_t b_type)
|
|
|
:m_id(id)
|
|
|
- ,m_area_type(type)
|
|
|
+ ,m_biz_type(b_type)
|
|
|
,m_limit_person_min(limit_time_person)
|
|
|
,m_limit_person_count(limit_count_person)
|
|
|
,m_scale(scale)
|
|
@@ -78,7 +78,7 @@ area::area(int id,int limit_count_person, int limit_time_person,double scale,int
|
|
|
,m_person_show_count(0)
|
|
|
,m_vehicle_show_count(0)
|
|
|
{
|
|
|
- m_area_business_list=area_business::get_instance_list(m_area_type,id);
|
|
|
+ m_area_business_list=area_business::get_instance_list(m_biz_type,id);
|
|
|
m_event_person_count = false;
|
|
|
m_event_vehicle_count = false;
|
|
|
m_event_person_show_count = false;
|
|
@@ -106,9 +106,10 @@ void area::change_business(uint32_t new_bits)
|
|
|
{
|
|
|
worker*w=worker::instance();
|
|
|
|
|
|
- uint32_t del=((m_area_type^new_bits)|m_area_type)^m_area_type;
|
|
|
- uint32_t add=((m_area_type^new_bits)|new_bits)^new_bits;
|
|
|
- log_info("change_area_business:%d,b_type:%d,area_type:%d [del:%d, add:%d]",m_id,new_bits,m_area_type,del,add);
|
|
|
+ uint32_t del=((m_biz_type^new_bits)|m_biz_type)^m_biz_type;
|
|
|
+ uint32_t add=((m_biz_type^new_bits)|new_bits)^new_bits;
|
|
|
+ log_info("change_area_business:area_id:%d,b_type:%d,area_type:%d [del:%d, add:%d]",m_id,new_bits,m_biz_type,del,add);
|
|
|
+
|
|
|
if(del==0 && add==0)
|
|
|
return;
|
|
|
|
|
@@ -134,6 +135,8 @@ void area::change_business(uint32_t new_bits)
|
|
|
|
|
|
add_frozen_count(w->num_thread()+1);
|
|
|
|
|
|
+ this->m_biz_type=new_bits;
|
|
|
+
|
|
|
w->broadcast(t);
|
|
|
}
|
|
|
|
|
@@ -291,7 +294,7 @@ void area_list::init_monkeycar_area(int id)
|
|
|
da->m_default_speed = monkeycar_speed;
|
|
|
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);
|
|
|
- ap->update(over_count_person, over_time_person,scale,map_id,b_type, over_count_vehicle,over_time_vehicle);
|
|
|
+ ap->update(over_count_person, over_time_person,scale,map_id,over_count_vehicle,over_time_vehicle);
|
|
|
|
|
|
ap->m_bound=init_path(path,area_id);
|
|
|
for(const auto &p : ap->m_bound)
|
|
@@ -303,22 +306,31 @@ void area_list::init_monkeycar_area(int id)
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- //这里后续需要把猴车得信息传递过去
|
|
|
- std::shared_ptr<db_area> da = std::make_shared<db_area>();
|
|
|
- da->m_default_speed = monkeycar_speed;
|
|
|
- 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);
|
|
|
- if(auto area_=area_list::instance()->get(id))
|
|
|
- area_=ap;
|
|
|
- else
|
|
|
- area_list::instance()->add(area_id,ap);
|
|
|
|
|
|
- ap->m_bound=init_path(path,area_id);
|
|
|
- ap->update(over_count_person, over_time_person,scale,map_id,b_type, over_count_vehicle,over_time_vehicle);
|
|
|
- for(const auto &p : ap->m_bound)
|
|
|
- log_info("point:monkey:area_id:%d--x:%.2f,y:%.2f",area_id,p.x,p.y);
|
|
|
- for(const auto &p : da->m_point)
|
|
|
- log_info("point:monkey_coor:area_id:%d--x:%.2f,y:%.2f",area_id,p.x,p.y);
|
|
|
+ auto tmp_ptr = area_list::instance()->get(id);
|
|
|
+ bool newobj=false;
|
|
|
+
|
|
|
+ if(!tmp_ptr)
|
|
|
+ {
|
|
|
+ std::shared_ptr<db_area> da = std::make_shared<db_area>();
|
|
|
+ da->m_default_speed = monkeycar_speed;
|
|
|
+ da->m_point = init_path(monkeycar_coor,area_id);
|
|
|
+ tmp_ptr=std::make_shared<monkey_area>(da,area_id,over_count_person, over_time_person,scale,map_id,b_type);
|
|
|
+
|
|
|
+ newobj=true;
|
|
|
+ }
|
|
|
+
|
|
|
+ tmp_ptr->m_bound=init_path(path,area_id);
|
|
|
+ tmp_ptr->update(over_count_person, over_time_person,scale,map_id, over_count_vehicle,over_time_vehicle);
|
|
|
+
|
|
|
+ if(newobj)
|
|
|
+ {
|
|
|
+ area_list::instance()->add(id, tmp_ptr);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ tmp_ptr->change_business(b_type);
|
|
|
+ }
|
|
|
|
|
|
log_info("基础数据 monkeycar area增加或修改区域成功:区域id:%d,over_count_person:%d over_time_person:%d,\
|
|
|
scale:%.2f,map_id:%d,area_type_id:%d,over_count_vehicle:%d,over_time_vehicle:%d",
|
|
@@ -352,134 +364,137 @@ std::shared_ptr<area> area_list::create(int type,int id,int limit_count_person,
|
|
|
}
|
|
|
void area_list::init_from_db(int id/*=-1*/)
|
|
|
{
|
|
|
- std::string sql = "SELECT a.area_id, a.name, a.map_id, a.area_type_id, a.path,b.scale, \
|
|
|
- over_count_person, over_count_vehicle, over_time_person, over_time_vehicle, \
|
|
|
- over_speed_vehicle, is_attendance,business_type, a.is_work_area\
|
|
|
- FROM dat_area a,dat_map b\
|
|
|
- where a.map_id = b.map_id and area_id not in \
|
|
|
- (select monkeycar_base_info_id from dat_monkeycar_base_info)";
|
|
|
-
|
|
|
- if(-1 == id)
|
|
|
- {
|
|
|
- sql.append(";");
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- sql.append(" AND a.area_id=");
|
|
|
- sql.append(std::to_string(id));
|
|
|
- sql.append(";");
|
|
|
+ do{
|
|
|
+ std::string sql = "SELECT a.area_id, a.name, a.map_id, a.area_type_id, a.path,b.scale, \
|
|
|
+ over_count_person, over_count_vehicle, over_time_person, over_time_vehicle, \
|
|
|
+ over_speed_vehicle, is_attendance,business_type, a.is_work_area\
|
|
|
+ FROM dat_area a,dat_map b\
|
|
|
+ where a.map_id = b.map_id and area_id not in \
|
|
|
+ (select monkeycar_base_info_id from dat_monkeycar_base_info)";
|
|
|
+
|
|
|
+ if(-1 == id)
|
|
|
+ {
|
|
|
+ sql.append(";");
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ sql.append(" AND a.area_id=");
|
|
|
+ sql.append(std::to_string(id));
|
|
|
+ sql.append(";");
|
|
|
|
|
|
- log_info("基础数据 增加或修改区域 sql=%s", sql.c_str());
|
|
|
- }
|
|
|
+ log_info("基础数据 增加或修改区域 sql=%s", sql.c_str());
|
|
|
+ }
|
|
|
|
|
|
- std::string Error;
|
|
|
- YADB::CDBResultSet DBRes;
|
|
|
- sDBConnPool.Query(sql.c_str(),DBRes,Error);
|
|
|
- int nCount = DBRes.GetRecordCount( Error );
|
|
|
- if (nCount < 1)
|
|
|
- {
|
|
|
- log_error("基础数据 增加或修改失败,数据库中找不到: area_id=%d:%s", id,sql.c_str());
|
|
|
- return ;
|
|
|
- }
|
|
|
+ std::string Error;
|
|
|
+ YADB::CDBResultSet DBRes;
|
|
|
+ sDBConnPool.Query(sql.c_str(),DBRes,Error);
|
|
|
+ int nCount = DBRes.GetRecordCount( Error );
|
|
|
+ if (nCount < 1)
|
|
|
+ {
|
|
|
+ log_error("基础数据 增加或修改失败,数据库中找不到: area_id=%d:%s", id,sql.c_str());
|
|
|
+ break;
|
|
|
+ }
|
|
|
|
|
|
- std::unordered_map<int,std::shared_ptr<area>> map;
|
|
|
- while ( DBRes.GetNextRecod(Error) )
|
|
|
- {
|
|
|
- int area_id = 0;
|
|
|
- DBRes.GetField( "area_id",area_id, Error );
|
|
|
+ std::unordered_map<int,std::shared_ptr<area>> map;
|
|
|
+ while ( DBRes.GetNextRecod(Error) )
|
|
|
+ {
|
|
|
+ int area_id = 0;
|
|
|
+ DBRes.GetField( "area_id",area_id, Error );
|
|
|
|
|
|
- int map_id = 0;
|
|
|
- DBRes.GetField( "map_id",map_id, Error );
|
|
|
+ int map_id = 0;
|
|
|
+ DBRes.GetField( "map_id",map_id, Error );
|
|
|
|
|
|
- unsigned int area_type_id = 0;
|
|
|
- DBRes.GetField( "area_type_id",area_type_id, Error );
|
|
|
+ unsigned int area_type_id = 0;
|
|
|
+ DBRes.GetField( "area_type_id",area_type_id, Error );
|
|
|
|
|
|
- int over_count_person = 0;
|
|
|
- DBRes.GetField( "over_count_person",over_count_person, Error );
|
|
|
+ int over_count_person = 0;
|
|
|
+ DBRes.GetField( "over_count_person",over_count_person, Error );
|
|
|
|
|
|
- int over_count_vehicle = 0;
|
|
|
- DBRes.GetField( "over_count_vehicle",over_count_vehicle, Error );
|
|
|
+ int over_count_vehicle = 0;
|
|
|
+ DBRes.GetField( "over_count_vehicle",over_count_vehicle, Error );
|
|
|
|
|
|
- int over_time_person = 0;
|
|
|
- DBRes.GetField( "over_time_person",over_time_person, Error );
|
|
|
+ int over_time_person = 0;
|
|
|
+ DBRes.GetField( "over_time_person",over_time_person, Error );
|
|
|
|
|
|
- int over_time_vehicle = 0;
|
|
|
- DBRes.GetField( "over_time_vehicle",over_time_vehicle, Error );
|
|
|
+ int over_time_vehicle = 0;
|
|
|
+ DBRes.GetField( "over_time_vehicle",over_time_vehicle, Error );
|
|
|
|
|
|
- std::string over_speed_vehicle;
|
|
|
- DBRes.GetField( "over_speed_vehicle",over_speed_vehicle, Error );
|
|
|
+ std::string over_speed_vehicle;
|
|
|
+ DBRes.GetField( "over_speed_vehicle",over_speed_vehicle, Error );
|
|
|
|
|
|
- std::string path;
|
|
|
- DBRes.GetField( "path",path, Error );
|
|
|
+ std::string path;
|
|
|
+ DBRes.GetField( "path",path, Error );
|
|
|
|
|
|
- double scale = 0;
|
|
|
- DBRes.GetField( "scale",scale, Error );
|
|
|
+ double scale = 0;
|
|
|
+ DBRes.GetField( "scale",scale, Error );
|
|
|
|
|
|
- uint32_t b_type =0;
|
|
|
- DBRes.GetField( "business_type",b_type, Error );
|
|
|
+ uint32_t b_type =0;
|
|
|
+ DBRes.GetField( "business_type",b_type, Error );
|
|
|
|
|
|
- int is_work_area = 0;
|
|
|
- DBRes.GetField( "is_work_area",is_work_area, Error );
|
|
|
+ int is_work_area = 0;
|
|
|
+ DBRes.GetField( "is_work_area",is_work_area, Error );
|
|
|
|
|
|
- log_info("init_area : id:%d,path:%s..speed:%s",area_id, path.c_str(),over_speed_vehicle.c_str());
|
|
|
- std::map<int,double> map_;
|
|
|
- auto vp=init_path(over_speed_vehicle,area_id);
|
|
|
- for(const auto &v:vp)
|
|
|
- map_.insert({v.x,v.y});
|
|
|
- if(-1 == id)
|
|
|
- {
|
|
|
- std::shared_ptr<area> ap = create(area_type_id,area_id,over_count_person,over_time_person, scale,map_id,b_type);
|
|
|
- ap->m_limit_vehicle_min = over_time_vehicle;
|
|
|
- ap->m_limit_vehicle_count = over_count_vehicle;
|
|
|
- ap->m_speed=std::move(map_);
|
|
|
- ap->m_is_work_area = is_work_area;
|
|
|
+ log_info("init_area : id:%d,path:%s..speed:%s",area_id, path.c_str(),over_speed_vehicle.c_str());
|
|
|
+ std::map<int,double> map_;
|
|
|
+ auto vp=init_path(over_speed_vehicle,area_id);
|
|
|
+ for(const auto &v:vp)
|
|
|
+ map_.insert({v.x,v.y});
|
|
|
+ if(-1 == id)
|
|
|
+ {
|
|
|
+ std::shared_ptr<area> ap = create(area_type_id,area_id,over_count_person,over_time_person, scale,map_id,b_type);
|
|
|
+ ap->m_limit_vehicle_min = over_time_vehicle;
|
|
|
+ ap->m_limit_vehicle_count = over_count_vehicle;
|
|
|
+ ap->m_speed=std::move(map_);
|
|
|
+ ap->m_is_work_area = is_work_area;
|
|
|
+
|
|
|
+ ap->m_bound=init_path(path,area_id);
|
|
|
+ for(const auto &p : ap->m_bound)
|
|
|
+ log_info("point:area_id:%d--x:%.2f,y:%.2f",area_id,p.x,p.y);
|
|
|
+ map.insert({area_id,ap});
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ auto tmp_ptr = area_list::instance()->get(id);
|
|
|
+ bool newobj=false;
|
|
|
|
|
|
- ap->m_bound=init_path(path,area_id);
|
|
|
- for(const auto &p : ap->m_bound)
|
|
|
- log_info("point:area_id:%d--x:%.2f,y:%.2f",area_id,p.x,p.y);
|
|
|
- map.insert({area_id,ap});
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- auto tmp_ptr = area_list::instance()->get(id);
|
|
|
- bool newobj=false;
|
|
|
-
|
|
|
- if(!tmp_ptr)
|
|
|
- {
|
|
|
- tmp_ptr = create(area_type_id,area_id,over_count_person,over_time_person, scale,map_id,b_type);
|
|
|
- newobj=true;
|
|
|
- }
|
|
|
+ if(!tmp_ptr)
|
|
|
+ {
|
|
|
+ tmp_ptr = create(area_type_id,area_id,over_count_person,over_time_person, scale,map_id,b_type);
|
|
|
+ newobj=true;
|
|
|
+ }
|
|
|
|
|
|
- tmp_ptr->update(over_count_person, over_time_person,scale,map_id,b_type, over_count_vehicle,over_time_vehicle);
|
|
|
- tmp_ptr->m_speed=std::move(map_);
|
|
|
- tmp_ptr->m_bound=init_path(path,area_id);
|
|
|
- tmp_ptr->m_is_work_area = is_work_area;
|
|
|
+ tmp_ptr->update(over_count_person, over_time_person,scale,map_id, over_count_vehicle,over_time_vehicle);
|
|
|
+ tmp_ptr->m_speed=std::move(map_);
|
|
|
+ tmp_ptr->m_bound=init_path(path,area_id);
|
|
|
+ tmp_ptr->m_is_work_area = is_work_area;
|
|
|
|
|
|
- for(const auto &p : tmp_ptr->m_bound)
|
|
|
- log_info("point:area_id:%d--x:%.2f,y:%.2f",area_id,p.x,p.y);
|
|
|
+ for(const auto &p : tmp_ptr->m_bound)
|
|
|
+ log_info("point:area_id:%d--x:%.2f,y:%.2f",area_id,p.x,p.y);
|
|
|
|
|
|
- log_info("基础数据 增加或修改区域成功:区域id:%d,over_count_person:%d over_time_person:%d,scale:%.2f,map_id:%d\
|
|
|
- ,area_type_id:%d,over_count_vehicle:%d,over_time_vehicle:%d,b_type:%d",
|
|
|
- id,over_count_person, over_time_person,scale,map_id,area_type_id,
|
|
|
- over_count_vehicle,over_time_vehicle,b_type);
|
|
|
+ log_info("基础数据 增加或修改区域成功:区域id:%d,over_count_person:%d over_time_person:%d,scale:%.2f,map_id:%d\
|
|
|
+ ,area_type_id:%d,over_count_vehicle:%d,over_time_vehicle:%d",
|
|
|
+ id,over_count_person, over_time_person,scale,map_id,area_type_id,
|
|
|
+ over_count_vehicle,over_time_vehicle);
|
|
|
|
|
|
- if(newobj)
|
|
|
- {
|
|
|
- area_list::instance()->add(id, tmp_ptr);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- tmp_ptr->change_business(b_type);
|
|
|
+ if(newobj)
|
|
|
+ {
|
|
|
+ area_list::instance()->add(id, tmp_ptr);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ tmp_ptr->change_business(b_type);
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
- if(-1 == id)
|
|
|
- {
|
|
|
- log_info( "init_area. The record count=%d\n", nCount );
|
|
|
- area_list::instance()->add(map);
|
|
|
- }
|
|
|
- init_monkeycar_area(id);
|
|
|
+ if(-1 == id)
|
|
|
+ {
|
|
|
+ log_info( "init_area. The record count=%d\n", nCount );
|
|
|
+ area_list::instance()->add(map);
|
|
|
+ }
|
|
|
+ }while(0);
|
|
|
+
|
|
|
+ init_monkeycar_area(id);
|
|
|
}
|
|
|
|
|
|
std::vector<point> area_list::init_path(std::string &str_0,int area_id)
|