Browse Source

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

zzj 6 years ago
parent
commit
2d6fd0f8f7
13 changed files with 50 additions and 32 deletions
  1. 0 1
      Makefile.am
  2. 1 1
      card.cpp
  3. 1 0
      card.h
  4. 1 1
      card_base.h
  5. 3 2
      card_car.cpp
  6. 1 1
      card_car.h
  7. 6 5
      card_person.cpp
  8. 1 0
      card_person.h
  9. 2 1
      db/db_tool.cpp
  10. 26 13
      mine_business.cpp
  11. 1 1
      mine_business.h
  12. 6 5
      net-service.cpp
  13. 1 1
      select_tool.h

+ 0 - 1
Makefile.am

@@ -1,7 +1,6 @@
 
 SUBDIRS=db websocket
 
-
 bin_PROGRAMS=yals 
 noinst_PROGRAMS=client async test 
 

+ 1 - 1
card.cpp

@@ -359,7 +359,7 @@ void card_list::on_message(zloop<task*> *loop,const message_locinfo&loc,bool is_
 
 bool card_list_visit::visit(std::shared_ptr<card_location_base> c)
 {
-	c->get_card();
+	c->get_card(_flag);
 	return true;	
 }
 

+ 1 - 0
card.h

@@ -9,6 +9,7 @@
 struct card_list_visit:visitor<std::shared_ptr<card_location_base>>
 {
 	bool visit(std::shared_ptr<card_location_base> c);
+    bool _flag{false};
 };
 
 struct card_list:single_base<card_list,uint64_t,std::shared_ptr<card_location_base>>

+ 1 - 1
card_base.h

@@ -84,7 +84,7 @@ struct card_location_base:card,std::enable_shared_from_this<card_location_base>
     virtual std::shared_ptr<area_tool> get_area_tool()=0;
     virtual int get_vehicle_category_id(){return -1;}
     virtual int get_workline(){return -1;}
-	virtual void get_card(){};
+	virtual void get_card(bool f)=0;
 	virtual void site_hover(int sid){}
 
     void on_message(zloop<task*> * loop,const message_locinfo&loc,bool is_history);

+ 3 - 2
card_car.cpp

@@ -121,9 +121,10 @@ void car::make_package()
 //		swsClientMgr.SendSpecialAreaProcess(cp);
 //	}
 }
-void car::get_card()
+void car::get_card(bool f)
 {
-	mine_business::inst()->put(shared_from_this());
+    if(f)
+	    mine_business::inst()->put(shared_from_this());
 }
 loc_point car::getSmoothPoint()
 {

+ 1 - 1
card_car.h

@@ -41,7 +41,7 @@ public:
     }
 
 	virtual void set_area_info(int mapid,double scale,int areaid,uint64_t t,int type);
-	virtual void get_card();
+	virtual void get_card(bool);
 private:
 	void handle_three_rates(const point &pt);
 	void on_timer();

+ 6 - 5
card_person.cpp

@@ -112,14 +112,9 @@ void person::handle_three_rates(const point & pt)
 
 void person::on_timer()
 {
-	//人员井下超时
-//    m_mine_tool->on_check_overtime(this->m_id,this->m_type);
-
     if(!m_mine_tool->m_is_attendance)
 		return;
 	YA::_CARD_POS_ cp;
-	if(m_display)
-	  mine_business::inst()->fetch_add();
 	uint64_t _time=0;
 	point pt = getSmoothPoint(_time);
     
@@ -166,4 +161,10 @@ point person::getSmoothPoint(uint64_t& t)
 	}
 	return pt;
 }
+void person::get_card(bool f)
+{
+    if(!m_mine_tool->m_is_attendance)
+		return;
+	mine_business::inst()->fetch_add(m_display);
+}
 

+ 1 - 0
card_person.h

@@ -23,6 +23,7 @@ struct person:card_location_base, card_area
     point getSmoothPoint(uint64_t& t);
 
     virtual void site_hover(int sid);
+	virtual void get_card(bool f);
     virtual std::shared_ptr<mine_tool> get_mine_tool();
     virtual void do_business(const std::shared_ptr<site>&site,const point &pt,double acc);
 	virtual void set_area_info(int mapid,double scale,int areaid,uint64_t t,int type);

+ 2 - 1
db/db_tool.cpp

@@ -8,11 +8,12 @@
 
 #include "tool_time.h"
 #include "db_tool.h"
-//#include "../common_tool.h"
+
 namespace db_tool
 {
     void PushAsync(const char* sql)
     {
+        logn_info(2,"sql:[%s]",sql);
         if(!sDBConnPool.PushAsync(sql))
         {
             log_error( "PushAsync记录到队列中失败\n");

+ 26 - 13
mine_business.cpp

@@ -130,15 +130,21 @@ struct card_sensor_mgr
 struct staffer_num_business
 {
 	void record_staffer_num();
-	void fetch_add(){m_staff_num++;}
+	void fetch_add(bool f)
+    {
+        if(f)
+            m_staff_num++;
+		m_staff_num_real++;
+        
+    }
 	staffer_num_business()
 	{
-		m_staff_num = 0;
+        reset();
 		m_record_staffer_timeval = 0;
 	}
 	private:
-	void reset(){m_staff_num=0;}
-	std::atomic<uint32_t> m_staff_num;
+	void reset(){m_staff_num=0;m_staff_num_real=0;}
+	std::atomic<uint32_t> m_staff_num,m_staff_num_real;
 	std::time_t m_record_staffer_timeval;
 };
 
@@ -243,9 +249,9 @@ void mine_business::run_business()
     handle_reverse_alarm();
     handle_rear_end();
 }
-void mine_business::fetch_add()
+void mine_business::fetch_add(bool f)
 {
-    m_staffer_num_ptr->fetch_add();
+    m_staffer_num_ptr->fetch_add(f);
 }
 void mine_business::record_staffer_num()
 {
@@ -287,31 +293,38 @@ void mine_business::clear_vehicle()
  *********************************/
 void staffer_num_business::record_staffer_num()
 {
-    static uint32_t min_num=0,max_num=0;
+    static uint32_t min_num=0,max_num=0,min_num_real=0,max_num_real=0;
     std::time_t t = time(NULL);
     char ti[64] = { 0 };
     strftime(ti,sizeof(ti),"%Y/%m/%d %H:%M:%S",localtime(&t));
     std::string sti(ti);
     int minute = atoi(sti.substr(sti.find_first_of(':')+1,2).c_str());
+    uint32_t a=m_staff_num.load();
+    uint32_t ar=m_staff_num_real.load();
     if(m_record_staffer_timeval==0)
     {
-        min_num=max_num=m_staff_num;
+        min_num=max_num=a;
+        min_num_real=max_num_real=ar;
         m_record_staffer_timeval = t;
     }
     if(t-m_record_staffer_timeval>=120 && minute%2 == 0)
     {
         std::stringstream ss;
-        ss<< "INSERT INTO his_staff_number(max_num,min_num,ave_num) VALUES("<<max_num<<','<<min_num<<','<<std::lround((max_num+min_num)/2)<<");";
-        logn_info(2,"staff_number:%s",ss.str().c_str());
+        ss<< "INSERT INTO his_staff_number(max_num,min_num,ave_num,max_num_real,min_num_real,ave_num_real) VALUES("
+            <<max_num<<','<<min_num<<','<<std::lround((max_num+min_num)/2)<<','
+            <<max_num_real<<','<<min_num_real<<','<<std::lround((max_num_real+min_num_real)/2)<<");";
         db_tool::PushAsync(ss.str().c_str());
 
-        min_num=max_num=m_staff_num;
+        min_num=max_num=a;
+        min_num_real=max_num_real=ar;
         m_record_staffer_timeval = t;
     }
     else
     {
-        if (min_num>m_staff_num)   min_num = m_staff_num;
-        if (max_num < m_staff_num) max_num = m_staff_num;
+        if (min_num>a)min_num = a;
+        if (max_num<a)max_num = a;
+        if (min_num_real>ar)min_num_real = ar;
+        if (max_num_real<ar)max_num_real = ar;
     }
     reset();
     return;

+ 1 - 1
mine_business.h

@@ -15,7 +15,7 @@ struct mine_business
 	static mine_business *inst();
 	void run_business();
 //人员数量曲线功能
-	void fetch_add();
+	void fetch_add(bool);
 //天线反向功能
 	void load();
 	void make_reverse_condition(uint64_t type,uint32_t id,int32_t antid,uint32_t ct,uint64_t tof,uint32_t sid);

+ 6 - 5
net-service.cpp

@@ -35,13 +35,14 @@ void net_service::on_timer()
 	visit_site_status vss;
 	sit_list::instance()->accept(vss);
 	int v = card_list::instance()->version();
+	card_list_visit clv;
 	if(v != version)
 	{
-		version=v;
-		mine_business::inst()->clear_vehicle();
-		card_list_visit clv;
-		card_list::instance()->accept(clv);
+        version=v;
+        clv._flag=true;
+        mine_business::inst()->clear_vehicle();
 	}
+	card_list::instance()->accept(clv);
 	mine_business::inst()->run_business();
 }
 
@@ -85,9 +86,9 @@ void net_service::on_message(std::shared_ptr<client> clt,const char*data,size_t
 
 						t->m_cmd_code=cmd;
 						t->m_hash_id=m.m_card_id;
-						m_loc_worker->request(t);
 						if(m.m_card_type==5)
 							mine_business::inst()->make_reverse_condition(m.m_card_type,m.m_card_id,m.m_ant_id,m.m_card_ct,m.m_tof,m.m_site_id);
+						m_loc_worker->request(t);
 					}
 				}
 				break;

+ 1 - 1
select_tool.h

@@ -758,7 +758,7 @@ struct smooth_tool
 	point smooth_last_true_position;
 
 	line smooth_line;
-	bool smooth_line_reset;	//if line reset
+	bool smooth_line_reset=false;	//if line reset
 
 	bool smooth_halt_condition;	//if halting
 	int smooth_halt_count;	//halting count