Browse Source

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

lixioayao 5 years ago
parent
commit
7677d70d1c

+ 18 - 5
area.cpp

@@ -84,11 +84,24 @@ area::area(int id,int limit_count_person, int limit_time_person,double scale,int
      ,m_vehicle_show_count(0)
 	 ,m_frozen_count(0)
      ,m_is_work_area(0)
-    {
-		m_default_limit_person_count = limit_count_person;
-		m_area_business_list=area_business::get_instance_list(m_biz_type,id);
-		m_persons_thre_time = std::make_shared<area_persons_thre_time>();
-    }
+{
+    m_default_limit_person_count = limit_count_person;
+    m_area_business_list=area_business::get_instance_list(m_biz_type,id);
+    m_persons_thre_time = std::make_shared<area_persons_thre_time>();
+    m_persons_thre_time->set_default_person_count_limit(limit_count_person);
+}
+
+void  area::update(int limit_count_person, int limit_time_person,double scale,int32_t mapid, int limit_count_vehicle, int limit_time_vehicle)
+{
+    m_limit_person_min=limit_time_person;
+    m_default_limit_person_count=limit_count_person;
+    m_persons_thre_time->set_default_person_count_limit(limit_count_person);
+    m_scale=scale;
+    m_mapid=mapid;
+    m_limit_vehicle_count=limit_count_vehicle;
+    m_limit_vehicle_min=limit_time_vehicle;
+}
+
 void area::clear()
 {
     EVENT_TYPE ev = is_mine()?EVENT_TYPE::ET_OVER_COUNT_PERSON : EVENT_TYPE::ET_AREA_OVER_COUNT_PERSON ;

+ 8 - 10
area.h

@@ -46,22 +46,20 @@ struct area
     {
         return m_scale;
     }
-        bool is_mine()//是矿井区域
+    bool is_mine()//是矿井区域
     {
         return 0 == m_id;
     }
+    //分站创建的区域 --- 分站创建的区域id = 0-分站id
+    bool is_reader_area()
+    {
+        return m_id < 0;
+    }
+
     virtual ~area()
     {}
     double get_speed(int vehicle_category_id) {return m_speed[vehicle_category_id];}
-    void  update(int limit_count_person, int limit_time_person,double scale,int32_t mapid, int limit_count_vehicle, int limit_time_vehicle)
-    {
-        m_limit_person_min=limit_time_person;
-        m_limit_person_count=limit_count_person;
-        m_scale=scale;
-        m_mapid=mapid;
-        m_limit_vehicle_count=limit_count_vehicle;
-        m_limit_vehicle_min=limit_time_vehicle;
-    }
+    void  update(int limit_count_person, int limit_time_person,double scale,int32_t mapid, int limit_count_vehicle, int limit_time_vehicle);
 public:
 
 	void set_business_list(std::vector<area_business*>&&business_list)

+ 7 - 5
card_person.cpp

@@ -67,7 +67,6 @@ void person::clear()
     	m.cmd=CMD_CLEAR;m.cardid=m_type<<32|m_id;
     	cardMgr::instance()->tryPut(m);
     }
-
 }
 
 void person::set_area_info(int mapid,double scale,int areaid,uint64_t t,int type)
@@ -95,9 +94,12 @@ void person::IKSDK_DB(int sid)
 		}
 		std::string card_id = tool_other::type_id_to_str(m_type,m_id);
 		std::string st	    = tool_time::to_str(now);
+
 		char nsql[256]={0};
-		const char*sql="REPLACE INTO his_att_interface (staff_id,card_id,reader_id,staff_name,dept_name,upt_time,low_power_warn) VALUES (%d,%s,%d,'%s','%s','%s',%d);";
-		snprintf(nsql,256,sql,m_cid,card_id.c_str(),sid,m_stafferName.c_str(),m_deptName.c_str(),st.c_str(),f);
+		const char*sql="REPLACE INTO his_att_interface (staff_id,card_id,reader_id,staff_name,dept_id,dept_name,upt_time,low_power_warn)"
+				 " VALUES (%d,%s,%d,'%s',%d,'%s','%s',%d);";
+		snprintf(nsql,256,sql,m_cid,card_id.c_str(),sid,m_stafferName.c_str(),m_deptid,m_deptName.c_str(),st.c_str(),f);
+
 		db_tool::PushAsync(nsql);
 		m_iris_recognition_timeval = now;
 	}
@@ -151,6 +153,7 @@ void person::on_timer()
 
 		return;
 	}
+
 	YA::_CARD_POS_ cp;
 	uint64_t _time=0;
 	point pt = getSmoothPoint(_time);
@@ -176,7 +179,7 @@ void person::on_timer()
     print_card_detained();
 	if(m_upmine_flag.load())
 	{
-		log_info("up_mine:upmine_flag=%d",m_upmine_flag.load());
+		log_info("card=%d cid=%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;
 	}
@@ -239,4 +242,3 @@ void person::get_card(bool f)
 		return ;
 	mine_business::inst()->fetch_add(m_display);
 }
-

+ 1 - 1
forbid_staff_down_mine.cpp

@@ -16,7 +16,7 @@ void forbid_staff_down_mine::init_forbid_staff(int id /* = -1*/,int etype)
     int nCount = DBRes.GetRecordCount( Error );
     if (nCount < 1)
     {
-        log_info("增加或修改失败,数据库中没有记录: sql=%s", sql.c_str());
+        //log_info("增加或修改失败,数据库中没有记录: sql=%s", sql.c_str());
         return ;
     }
     while ( DBRes.GetNextRecod(Error) )

+ 28 - 17
module_service/area_business_card_enter_or_leave.cpp

@@ -6,6 +6,17 @@
 #include"db/db_tool.h"
 #include"log.h"
 
+const char * get_area_table_name(const std::shared_ptr<area_hover>&a)
+{
+    static const char * g_sz_area_name = "his_location_area";
+    // 分站定位数据保存(进入分站,离开分站保存记录)
+    static const char * g_sz_reader_area_name = "his_location_reader";
+    if (a->m_area->is_reader_area())
+    {
+        return  g_sz_reader_area_name;
+    }
+    return g_sz_area_name;
+}
 
 void area_business_card_enter_or_leave::on_load_his(const std::shared_ptr<area_hover>&area_hover_ptr,
                                             const std::shared_ptr<card_location_base>&card_ptr,std::shared_ptr<business_data>&ptr)
@@ -20,27 +31,29 @@ void area_business_card_enter_or_leave::on_enter(const std::shared_ptr<area_hove
     char sql[LENGTH_SQL]{0};
     std::string start_time = tool_time::to_str(a->m_enter_time/1000);
     const auto &p=a->m_enter_point;
-    // 根据区域无法区分是否井上分站[分站创建的区域没有代入区域类型-导致都是井上区域] 只能通过分站区分
+
+    // 根据区域无法区分是否井上区域[分站创建的区域没有代入区域类型-导致都是井上区域] 只能通过分站区分
     if (nullptr == c->get_area_tool()->m_site || !c->get_area_tool()->m_site->is_up_site())
     {
-        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','%lu','%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);
+        snprintf(sql, LENGTH_SQL, "INSERT INTO %s (obj_id,card_type_id,ident,area_id,map_id,enter_time,start_point) \
+	                         VALUES ('%d','%lu','%d',%d,%d,'%s','%.2f,%.2f');",get_area_table_name(a)
+	                         ,c->m_cid, c->m_type, c->m_id, a->id(), a->mapid(), start_time.c_str(), p.x, p.y);
     }
     else
     {
         // 井上分站时,插入时把离开时间也写入 防止员工出井后最后一个区域没有leave_time
-        snprintf(sql, LENGTH_SQL, "INSERT INTO his_location_area (obj_id,card_type_id,ident,area_id,map_id,enter_time,leave_time,start_point) \
-	                         VALUES ('%d','%lu','%d',%d,%d,'%s','%s','%.2f,%.2f');",
-                 c->m_cid, c->m_type, c->m_id, a->id(), a->mapid(), start_time.c_str(),start_time.c_str(), p.x, p.y);
+        snprintf(sql, LENGTH_SQL, "INSERT INTO %s (obj_id,card_type_id,ident,area_id,map_id,enter_time,leave_time,start_point) \
+	                         VALUES ('%d','%lu','%d',%d,%d,'%s','%s','%.2f,%.2f');",get_area_table_name(a)
+	                         ,c->m_cid, c->m_type, c->m_id, a->id(), a->mapid(), start_time.c_str(),start_time.c_str(), p.x, p.y);
     }
     db_tool::PushAsync(sql);
+   // std_info("card:%d Enter Area:%d ",c->m_cid,a->id());
 }
 
 void area_business_card_enter_or_leave::on_hover(const std::shared_ptr<area_hover>&a,
                                                  const std::shared_ptr<card_location_base>&c,std::shared_ptr<business_data> ptr)
 {
-    // 根据区域无法区分是否井上分站[分站创建的区域没有代入区域类型-导致都是井上区域] 只能通过分站区分
+    // 根据区域无法区分是否井上区域[分站创建的区域没有代入区域类型-导致都是井上区域] 只能通过分站区分
     if (nullptr != c->get_area_tool()->m_site && c->get_area_tool()->m_site->is_up_site())
     {
         // 井上分站时,员工在行走过程中更新时间
@@ -48,10 +61,9 @@ void area_business_card_enter_or_leave::on_hover(const std::shared_ptr<area_hove
         std::string start_time = tool_time::to_str(a->m_enter_time/1000);
         std::string end_time = tool_time::to_str(tool_time::now_to_seconds());
         const auto &ep=a->m_last_point;
-        snprintf(sql,LENGTH_SQL,"UPDATE his_location_area SET leave_time='%s',end_point='%.2f,%.2f' \
-	                         WHERE  enter_time='%s' AND obj_id=%d AND area_id=%d;",
-                 end_time.c_str(),ep.x,ep.y,
-                 start_time.c_str(),c->m_cid,a->id());
+        snprintf(sql,LENGTH_SQL,"UPDATE %s SET leave_time='%s',end_point='%.2f,%.2f'"
+                                " WHERE  enter_time='%s' AND obj_id=%d AND area_id=%d;"
+                                ,get_area_table_name(a),end_time.c_str(),ep.x,ep.y,start_time.c_str(),c->m_cid,a->id());
 
         db_tool::PushAsync(sql);
     }
@@ -65,13 +77,12 @@ void area_business_card_enter_or_leave::on_leave(const std::shared_ptr<area_hove
     std::string end_time = tool_time::to_str(a->m_last_time/1000);
 //    std::string card_id = tool_other::type_id_to_str(c->m_type,c->m_id);
     const auto &ep=a->m_last_point;
-    snprintf(sql,LENGTH_SQL,"UPDATE his_location_area SET leave_time='%s',end_point='%.2f,%.2f' \
-	                         WHERE  enter_time='%s' AND obj_id=%d AND area_id=%d;",
-                end_time.c_str(),ep.x,ep.y,
-				start_time.c_str(),c->m_cid,a->id());
+    snprintf(sql,LENGTH_SQL,"UPDATE %s SET leave_time='%s',end_point='%.2f,%.2f' \
+	                         WHERE  enter_time='%s' AND obj_id=%d AND area_id=%d;"
+	                         ,get_area_table_name(a),end_time.c_str(),ep.x,ep.y,start_time.c_str(),c->m_cid,a->id());
 
     log_info("card_enter_leave:%s",sql);
-
+    //std_info("card:%d leave Area:%d ",c->m_cid,a->id());
     db_tool::PushAsync(sql);
 }
 

+ 3 - 1
module_service/module_meta_date_changed.cpp

@@ -112,7 +112,9 @@ void module_meta_date_changed::accept(sio::message::ptr const& data)
 			deal_call_edit_landmark(szParam, edit_type_id);
 		}
 		else if (JSON_KEY_NAME_COALFACE==name|| JSON_KEY_NAME_COALFACE_VEHICLE == name || 
-			JSON_KEY_NAME_DRIVING_FACE == name || JSON_KEY_NAME_DRIVINGFACE_VEHICLE == name )
+			JSON_KEY_NAME_DRIVING_FACE == name || JSON_KEY_NAME_DRIVINGFACE_VEHICLE == name
+			|| JSON_KEY_NAME_DRIVINGFACE_REF_POINT == name
+			|| JSON_KEY_NAME_DRIVINGFACE_WARNING_POINT == name)
 		{			
 			three_rates::get_instance()->update_db_data(name, szParam, edit_type_id);
 		}

+ 2 - 0
websocket/constdef.h

@@ -80,6 +80,8 @@
 #define JSON_KEY_NAME_COALFACE_VEHICLE "coalface_vehicle"
 #define JSON_KEY_NAME_DRIVING_FACE "drivingface"
 #define JSON_KEY_NAME_DRIVINGFACE_VEHICLE "drivingface_vehicle"
+//掘进面基准点
+#define JSON_KEY_NAME_DRIVINGFACE_REF_POINT "drivingface_ref_point"
 
 //禁止指定人员下井
 #define JSON_KEY_NAME_FORBID_PERSON_DOWN_MINE "rt_person_forbid_down_mine"