Jelajahi Sumber

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

zzj 6 tahun lalu
induk
melakukan
d787316e75

+ 1 - 1
Makefile.am

@@ -44,7 +44,7 @@ client_SOURCES=client.cpp message_file.cpp
 client_CPPFLAGS=${AM_CPPFLAGS}
 client_LDFLAGS=${AM_LDFLAGS}  -L. -lzlog
 
-test_SOURCES=test.cpp base64.cpp
+test_SOURCES=test.cpp base64.cpp point.cpp
 test_CPPFLAGS=${AM_CPPFLAGS}
 test_LDFLAGS=${AM_LDFLAGS}  -L. -lzlog -lrt
 

+ 7 - 3
ant.cpp

@@ -41,7 +41,7 @@ void ant::set_path(const std::vector<line_v>&v_line,std::vector<line_v>::const_i
 		m_path[1][i].swap_point();
 	}
 
-	for(auto&p:m_path)
+	for(const auto&p:m_path)
 	{
 		log_info("site-path: %s",p.to_str().c_str());
 	}
@@ -196,7 +196,7 @@ bool visit_site_status::visit(std::shared_ptr<site> s)
 {
 	time_t now=time(0);
 	int diff = now-s->m_time;
-	event_tool::instance()->handle_event(OT_DEVICE_READER,ET_READER_ERROR,s->m_id,READER_TIMEOUT,diff,[diff](){return diff>READER_TIMEOUT;});
+	event_tool::instance()->handle_event(OT_DEVICE_READER,ET_READER_ERROR,s->m_id,READER_TIMEOUT,diff,diff>READER_TIMEOUT);
 	return true;
 }
 
@@ -352,7 +352,7 @@ void sit_list::read_ant_path(int id)
 void sit_list::init_site(int id)
 {
      std::string sql = "SELECT reader_id, reader_type_id, dat_reader.map_id, \
-             area_id, device_type_id, dimension, dat_map.scale\
+             area_id, device_type_id, dimension, dat_map.scale,need_power_alarm\
              FROM dat_reader, dat_map where \
              dat_reader.map_id=dat_map.map_id and state=0";
 
@@ -412,9 +412,13 @@ void sit_list::init_site(int id)
          double scale= 0;
          DBRes.GetField( "scale",scale, Error );
 
+         int power_alarm  = 0;
+         DBRes.GetField( "need_power_alarm",power_alarm, Error );
+
          site_ptr->m_reader_type_id = reader_type_id;
          site_ptr->m_map_id = map_id;
          site_ptr->m_area_id = area_id;
+         site_ptr->m_power_check_enable=power_alarm;
 
          site_ptr->m_device_type_id = device_type_id;
 

+ 2 - 2
card_base.cpp

@@ -47,7 +47,7 @@ void card_location_base::on_location(const std::vector<point>&vp,const std::vect
 
 		double acc = lm[0].m_acc;
         m_acc = lm[0].m_acc;
-		log_info("useful:card_id:%d,ct:%d,timestamp:%llu, loc_point,x:%f,y:%f acc:%.2f",m_id,m_ct,m_time,x,y,acc);
+		log_info("useful:type:%d,card_id:%d,ct:%d,timestamp:%llu, loc_point,x:%f,y:%f acc:%.2f",m_type,m_id,m_ct,m_time,x,y,acc);
 		do_business(lm.front().m_sit, pt, acc);
 	}
 	else
@@ -60,7 +60,7 @@ void card_location_base::on_location(const std::vector<point>&vp,const std::vect
 			sid=site_ptr->m_id;
 		}
 		
-		log_warn("坐标不可用:site_id:%d,card_id:%d,ct:%d,x:%f,y:%f",sid,m_id,m_ct,pt.x,pt.y);
+		log_warn("坐标不可用:site_id:%d,type:%d,card_id:%d,ct:%d,x:%f,y:%f",sid,m_type,m_id,m_ct,pt.x,pt.y);
 	}
 }
 

+ 0 - 1
card_car.cpp

@@ -35,7 +35,6 @@ void car::set_area_info(int mapid,double scale,int areaid,uint64_t t,int type)
 void car::do_business(const std::shared_ptr<site>&site,const point &pt,double acc)
 {
 	m_acc=acc;
-    m_area_tool->set_site(site);
 	m_area_tool->on_point(shared_from_this(),pt);
 	m_timeval=m_time;
 	m_mine_tool->on_point(m_id, m_type, m_vehicle_category_id);

+ 1 - 2
card_person.cpp

@@ -90,7 +90,6 @@ std::shared_ptr<mine_tool> person::get_mine_tool()
 
 void person::do_business(const std::shared_ptr<site>&site,const point &pt,double acc)
 {
-    m_area_tool->set_site(site);
 	m_area_tool->on_point(shared_from_this(),pt);
 	m_timeval=m_time;
 	handle_three_rates(pt);
@@ -144,7 +143,7 @@ void person::on_timer()
 
 	if(m_upmine_flag.load())
 	{
-		m_upmine_flag.store(0);
+		m_upmine_flag=0;
 		m_area_tool->on_leave(shared_from_this());
 	}
 }

+ 17 - 8
forbid_staff_down_mine.cpp

@@ -3,13 +3,13 @@
 #include "tool_time.h"
 #include "db_api/CDBSingletonDefine.h"
 
-void forbid_staff_down_mine::init_forbid_staff(int id /* = -1*/)
+void forbid_staff_down_mine::init_forbid_staff(int id /* = -1*/,int etype)
 {
-    std::string sql = "select id,staff_id,start_time,end_time,status,oper_time,lastupdate from rt_person_forbid_down_mine where status = 1 and end_time > now() ";
+    std::string sql = "select id,staff_id,start_time,end_time,status,oper_time,lastupdate from rt_person_forbid_down_mine where ";
     if (id != -1)
-        sql += " and id = " + std::to_string(id) + ";";
+        sql += " id = " + std::to_string(id) + ";";
     else
-        sql += ";";
+        sql += "status = 1 and end_time > now();";
     std::string Error;
     YADB::CDBResultSet DBRes;
     sDBConnPool.Query(sql.c_str(),DBRes,Error);
@@ -35,6 +35,8 @@ void forbid_staff_down_mine::init_forbid_staff(int id /* = -1*/)
         DBRes.GetField("oper_time", create_time, Error);
         std::string update_time;
         DBRes.GetField("lastupdate", update_time, Error);
+        time_t stime = tool_time::to_time(start_time);
+        time_t etime = tool_time::to_time(end_time);
         std::shared_ptr<SForbidStaffList> s = forbid_staff_down_mine::instance()->get(staff_id);
         //如果存在则查找更新。查找不到则插入
         if (s)
@@ -46,8 +48,8 @@ void forbid_staff_down_mine::init_forbid_staff(int id /* = -1*/)
                 if (info.db_id == key)
                 {
                     f=true;
-                    info.start_time = tool_time::to_time(start_time);
-                    info.end_time = tool_time::to_time(end_time);
+                    info.start_time =stime;
+                    info.end_time =etime;
                     info.state = state;
                     log_info("Check Forbid_staff_down_mine DBID:%d Staff:%d State:%d Time:%s -> %s . "
                                 ,key,staff_id,state,start_time.c_str(),end_time.c_str());
@@ -55,6 +57,13 @@ void forbid_staff_down_mine::init_forbid_staff(int id /* = -1*/)
                 }
             }
             if(f)continue;
+            //ET_UPDATE
+            if(id !=-1 && etype ==2)
+            {
+                time_t now= time(0);
+                if(state!=1 || now>etime)
+                    continue;
+            }
         }
         else
         {
@@ -65,8 +74,8 @@ void forbid_staff_down_mine::init_forbid_staff(int id /* = -1*/)
         SForbidStaffInfo info ;
         info.staff_id = staff_id;
         info.db_id = key;
-        info.start_time = tool_time::to_time(start_time);
-        info.end_time = tool_time::to_time(end_time);
+        info.start_time = stime;
+        info.end_time =etime;
         info.state = state;
 
         log_info("Init Forbid_staff_down_mine DBID:%d Staff:%d State:%d Time:%s -> %s . "

+ 1 - 1
forbid_staff_down_mine.h

@@ -39,7 +39,7 @@ struct forbid_staff_down_mine
 {
 public:
     // 根据数据库中的自增长id
-    void init_forbid_staff(int id = -1);
+    void init_forbid_staff(int id = -1,int etype=-1);
     // 根据数据库中的自增长id
     void del_forbid_data(int id,int staff_id);
 

+ 14 - 4
module_service/area_business_count_checker.cpp

@@ -50,13 +50,18 @@ void area_business_count_checker::on_enter(const std::shared_ptr<area_hover>&a,
 		return ;
 	if (c->is_person())
 	{
+        int limit_val=a->m_area->m_limit_person_count;
+        int aid=a->m_area->id();
+        if(limit_val<=0)
+        {
+            log_warn("on_enter_area_id:%d,limit_person_count is 0.so should not run area_business_count_checker...",aid);
+            return;
+        }
 		a->m_area->m_person_count ++ ;
         if(c->m_display)
 		    a->m_area->m_person_show_count ++ ;
         int pc=a->m_area->m_person_count.load();
         int pc_=a->m_area->m_person_show_count.load();
-        int limit_val=a->m_area->m_limit_person_count;
-        int aid=a->m_area->id();
 	    EVENT_TYPE ev = a->m_area->is_mine()?EVENT_TYPE::ET_OVER_COUNT_PERSON : EVENT_TYPE::ET_AREA_OVER_COUNT_PERSON ;
         if(pc>limit_val){
             lock();
@@ -73,13 +78,18 @@ void area_business_count_checker::on_enter(const std::shared_ptr<area_hover>&a,
 	}
 	else if (c->is_vehicle())
 	{
+        int limit_val=a->m_area->m_limit_vehicle_count;
+        int aid=a->m_area->id();
+        if(limit_val<=0)
+        {
+            log_warn("on_enter_area_id:%d,limit_vehicle_count is 0.so should not run area_business_count_checker...",aid);
+            return;
+        }
 		a->m_area->m_vehicle_count ++ ;
         if(c->m_display)
 		    a->m_area->m_vehicle_show_count ++ ;
         int vc=a->m_area->m_vehicle_count.load();
         int vc_=a->m_area->m_vehicle_show_count.load();
-        int limit_val=a->m_area->m_limit_vehicle_count;
-        int aid=a->m_area->id();
 		EVENT_TYPE ev = a->m_area->is_mine()?EVENT_TYPE::ET_OVER_COUNT_VEHICLE : EVENT_TYPE::ET_AREA_OVER_COUNT_VEHICLE ;
         if(vc>limit_val){
             lock();

+ 1 - 3
module_service/area_business_person_attendance.cpp

@@ -110,9 +110,7 @@ void area_business_person_attendance::handle_up_mine(sio::message::ptr const& da
         if(card_ptr && STATUS_LOST == card_ptr->m_biz_stat)
         {
             log_info("handle_up_card:%s 手工升井,处理",s_card_id.c_str());
-
-			card_ptr->inc_upmine_flag();
-//            module_meta_date_changed::clear_card(card_ptr);
+            card_ptr->inc_upmine_flag();
         }
         else
             log_warn("handle_up_card:%s,手动升井的卡找不到,或者该卡不在盲区",s_card_id.c_str());

+ 1 - 1
module_service/module_meta_date_changed.cpp

@@ -297,7 +297,7 @@ void module_meta_date_changed::deal_call_edit_forbid_person_down_mine(const std:
 
     if(ET_INSERT == edit_type_id || ET_UPDATE == edit_type_id)
     {
-        forbid_staff_down_mine::instance()->init_forbid_staff(db_id);
+        forbid_staff_down_mine::instance()->init_forbid_staff(db_id,edit_type_id);
     }
     else if(ET_DELETE == edit_type_id)
     {

+ 3 - 0
websocket/wsClient.cpp

@@ -3,6 +3,7 @@
 #include <thread>
 #include <chrono>
 #include <boost/locale.hpp>
+#include"log.h"
 
 
 namespace YA
@@ -166,11 +167,13 @@ namespace YA
 
 	void wsClient::_on_close( sio::client::close_reason const & reason )
 	{
+        log_info("websocket %d close()",__ID);
 		_reset();
 	}
 
 	void wsClient::_on_reconnect( unsigned p1, unsigned p2 )
 	{
+        log_info("websocket %d reconnect()",__ID);
 		_reset();
 	}
 

+ 3 - 3
znet.cpp

@@ -55,7 +55,7 @@ public:
 
 	void boardcast(const std::vector<char>&msg)
 	{
-		for(auto&i:m_thread_clts)
+		for(const auto&i:m_thread_clts)
 		{
 			std::vector<char> tmp(msg);
 			i->send(std::move(tmp));
@@ -99,7 +99,7 @@ public:
 
 	void close_all()
 	{
-		for(auto&clt:m_thread_clts)
+		for(const auto&clt:m_thread_clts)
 		{
 			if(!clt)
 				continue;
@@ -110,7 +110,7 @@ public:
 
 	void on_async(const std::list<std::shared_ptr<client>>&notify_clts)
 	{
-		for(auto&clt:notify_clts)
+		for(const auto&clt:notify_clts)
 		{
 			((client_ex*)clt.get())->on_notify();
 		}