Browse Source

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

chensongchao 6 years ago
parent
commit
c074100e4c

+ 36 - 8
card_base.cpp

@@ -12,10 +12,12 @@
 #include "websocket/wsTimerThread.h"
 #include "three_rates.h"
 #include "his_location.h"
-#include"event.h"
-#include"module_service/module_call.h"
-#include"mine.h"
-#include"common_tool.h"
+#include "event.h"
+#include "module_service/module_call.h"
+#include "mine.h"
+#include "common_tool.h"
+#include "ant.h"
+#include "area.h"
 
 extern config_file config;
 
@@ -53,15 +55,41 @@ void card_location_base::on_message(zloop<task*> * loop,const message_locinfo&lo
 {
 	m_ct = loc.m_card_ct;
 	m_time = loc.m_time_stamp;
-	m_message_handle->on_message(loop,loc,is_history);
+	auto site_ptr = sit_list::instance()->get(loc.m_site_id);
+
+	if(!site_ptr)
+	{
+		return;
+	}
+
+	if(site_ptr->is_up_site())
+	{
+		auto area_tool=get_area_tool();
+		area_tool->set(site_ptr);
+		area_tool->on_point(shared_from_this(),point(1,1));
+	}
+	else
+	{
+		m_message_handle->on_message(loop,loc,is_history);
+	}
 }
 
 //前端推送位置函数.
-void card_location_base::upt_card_pos(YA::_CARD_POS_&cp, const point &pt)
+void card_location_base::upt_card_pos(YA::_CARD_POS_&cp, point &pt)
 {
 //	YA::_CARD_POS_ cp;
-	cp.x = tool_other::round(pt.x,3);
-	cp.y = tool_other::round(pt.y,3);
+    point _p;
+    if(pt.empty())
+    {
+        _p=*this;
+        pt=_p;
+    }
+    else
+	{
+       	 _p=pt;
+	}
+	cp.x = tool_other::round(_p.x,3);
+	cp.y = tool_other::round(_p.y,3);
 	//cp.z = pt.z;
 
 	cp.Type=m_type;

+ 1 - 1
card_base.h

@@ -96,7 +96,7 @@ struct card_location_base:card,std::enable_shared_from_this<card_location_base>
     void on_message(zloop<task*> * loop,const message_locinfo&loc,bool is_history);
     void on_location(const std::vector<point>&vp,const std::vector<loc_message> &lm );
     void do_status(int st);
-	void upt_card_pos(YA::_CARD_POS_&cp, const point &pt);
+	void upt_card_pos(YA::_CARD_POS_&cp, point &pt);
 	void del_card_pos();
 	int	 get_stat();
 	void put_three_rates(card_pos &);

+ 1 - 9
card_person.cpp

@@ -114,15 +114,7 @@ void person::on_timer()
 	  mine_business::inst()->fetch_add();
 	uint64_t _time=0;
 	point pt = getSmoothPoint(_time);
-//	const auto lm = m_area_tool->getLandmark();
-//	cp.enter_area_time = std::get<0>(lm)*1000;
-//	cp.rec_time = std::get<1>(lm);
-//	int32_t map_id = std::get<2>(lm);
-//	int32_t area_id = std::get<3>(lm);
-//	cp.map_id=map_id;cp.area_id=area_id;
-//	cp.landmark_id = std::get<4>(lm);
-//	cp.lm_direction = std::get<5>(lm);
-//	cp.landmark_dis=std::get<6>(lm);
+    
 	cp.area_info=m_area_tool->m_area_info;	
 	cp.map_id =m_area_tool->m_mapid;
 

+ 20 - 3
crc.cpp

@@ -35,20 +35,18 @@ static unsigned short ccitt_table[256] = {
 0xEF1F, 0xFF3E, 0xCF5D, 0xDF7C, 0xAF9B, 0xBFBA, 0x8FD9, 0x9FF8,
 0x6E17, 0x7E36, 0x4E55, 0x5E74, 0x2E93, 0x3EB2, 0x0ED1, 0x1EF0
 };
-
 unsigned short do_crc(unsigned char *q, int len)
 {
 	unsigned short crc = 0;
 
 	while (len-- > 0)
-		crc = ccitt_table[(crc >> 8 ^ *q++) & 0xff] ^ (crc << 8);
+		crc = ccitt_table[((crc >> 8) ^ *q++) & 0xff] ^ (crc << 8);
 
 	return crc;
 }
 
 
 /*
-
 ----------------------------------------------
 --功能: 字节查表法求CRC
 ---------------------------------------------
@@ -67,4 +65,23 @@ uint16_t do_crc(unsigned char *ptr,int len) // 字节查表法求CRC
 	}
 	return(crc);
 }
+
+
+	uint16_t do_crc(uint8_t* pbtData, int nLength)
+	{
+		//查表(crc_Table)法求CRC
+		uint8_t tda;
+		uint16_t crc = 0;
+		int i = 0;
+		while (i < nLength)
+		{
+			tda = (uint8_t)(crc / 256); // 以8 位二进制数暂存CRC 的高8 位
+			crc <<= 8;				// 左移8 位
+			crc ^= ccitt_table[tda^pbtData[i++]]; // 高字节和当前数据XOR 再查表
+		}
+
+		return(crc);
+	}
 */
+
+

+ 1 - 0
module_service/area_business_card_enter_or_leave.cpp

@@ -42,5 +42,6 @@ void area_business_card_enter_or_leave::on_leave(const std::shared_ptr<area_hove
     const auto &ep=a->m_last_point;
     snprintf(sql,LENGTH_SQL,"UPDATE his_location_area SET leave_time='%s',end_point='%.2f,%.2f' WHERE card_id = '%s' AND area_id=%d AND enter_time='%s';",
                 end_time.c_str(),ep.x,ep.y,card_id.c_str(),a->id(),start_time.c_str());
+    log_info("card_enter_leave:%s",sql);
     db_tool::PushAsync(sql);
 }

+ 6 - 0
module_service/area_business_person_attendance.cpp

@@ -9,6 +9,7 @@
 #include"mine.h"
 #include"websocket/constdef.h"
 #include "websocket/wsClientMgr.h"
+#include "websocket/wsTimerThread.h"
 #include"tool_time.h"
 #include "module_meta_date_changed.h"
 //记录进入时间等信息,结束考勤,根据离开的时间和距离,判断是否记录一条新的考勤记录
@@ -52,6 +53,11 @@ void area_business_person_attendance::on_leave(const std::shared_ptr<area_hover>
     //作为一条结束考勤记录保存到数据库
     db_tool::save_attendance(card_ptr, area_hover_ptr);
 
+	YA::_CARD_POS_ cp;
+	cp.Type=card_ptr->m_type;
+	cp.ID = card_ptr->m_id;
+	swsTimerThrd.del_card_pos(cp);
+    
     rapidjson::Document doc(rapidjson::kObjectType);
     rapidjson::Value datas(rapidjson::kArrayType);
     rapidjson::Document::AllocatorType& allocator=doc.GetAllocator();

+ 4 - 0
module_service/area_business_post_area.cpp

@@ -7,6 +7,10 @@
 	确定推送人员信息时的区域,每一个明确需要推送的区域,都要推送
 */
 //将推送区域信息加入人员数据
+void area_business_post_area::on_load_his(const std::shared_ptr<area_hover>&a,const std::shared_ptr<card_location_base>&c,std::shared_ptr<business_data>&ptr)
+{
+    on_enter(a,c,ptr);
+}
 void area_business_post_area::on_enter(const std::shared_ptr<area_hover>&a,
 						const std::shared_ptr<card_location_base>&c,std::shared_ptr<business_data>&ptr)
 {

+ 1 - 0
module_service/area_business_post_area.h

@@ -12,6 +12,7 @@ struct area_business_post_area:area_business
 	{
 		return 1;
 	}
+	virtual void on_load_his(const std::shared_ptr<area_hover>&a,const std::shared_ptr<card_location_base>&c,std::shared_ptr<business_data>&ptr);
 	//将推送区域信息加入人员数据
 	void on_enter(const std::shared_ptr<area_hover>&a,const std::shared_ptr<card_location_base>&c,std::shared_ptr<business_data>&ptr);
 	void on_hover(const std::shared_ptr<area_hover>&a,const std::shared_ptr<card_location_base>&c,std::shared_ptr<business_data> ptr);

+ 3 - 0
monkey_car/monkey_fit.h

@@ -44,6 +44,9 @@ struct monkey_fit
 			s-=it->second; ++it;
 		}
 
+		if(p.empty())
+			return 0;
+
 		std::sort(p.begin(),p.end(),[](const std::tuple<T,T,int>&l,const std::tuple<T,T,int>&r){
 			return 1.*std::get<2>(l) > 1.*std::get<2>(r);
 		});

+ 6 - 6
websocket/jsonBuilder.cpp

@@ -71,8 +71,8 @@ namespace YA
               //0 区域编号
               //1 地标编号
               //2 地标方向
-			//3 距离地标的距离
-			//4 进入区域时间戳
+	      //3 距离地标的距离
+	      //4 进入区域时间戳
 		]
 #endif
 	bool jsonBuilder::__BuildDetail( const _CARD_POS_ & CardPos, rapidjson::Document::AllocatorType& Allocator, rapidjson::Value & DetailItem )
@@ -97,12 +97,12 @@ namespace YA
 		Array.PushBack( tmp_object, Allocator );
 
 		//4 进入区域时间戳
-		tmp_object.SetDouble( CardPos.enter_area_time );
-		Array.PushBack( tmp_object, Allocator );
+		//tmp_object.SetDouble( CardPos.enter_area_time );
+		//Array.PushBack( tmp_object, Allocator );
 
 		//5 最后接收时间戳
-		//tmp_object.SetDouble( CardPos.rec_time );
-		//Array.PushBack( tmp_object, Allocator );
+		tmp_object.SetDouble( CardPos.rec_time );
+		Array.PushBack( tmp_object, Allocator );
 
 		//6 工作时长
 		tmp_object.SetDouble( CardPos.work_time );

BIN
websocket/libwebsocket.a


+ 4 - 4
znet.cpp

@@ -437,16 +437,16 @@ struct sock_client:fd_io,client_ex
 		}
 	}
 
-	bool check_crc(const char*b,size_t mlen)
+	bool check_crc(void *b0,size_t mlen)
 	{
+		uint8_t*b=(uint8_t*)b0;
 		uint16_t crc=b[mlen-2];
 		crc<<=8;
 		crc|=b[mlen-1];
 
-		if(do_crc((unsigned char*)b+2,mlen-4)==crc)
-			return true;
+		uint16_t ccrc=do_crc((unsigned char*)b+2,mlen-4);
 
-		return false;
+		return ccrc==crc;
 	}
 
 	void on_message(const char*m,int mlen)