Browse Source

支持最后下井时间记录

zengminguo 2 years ago
parent
commit
b9e17ed17f
7 changed files with 44 additions and 3 deletions
  1. 16 3
      card_base.cpp
  2. 3 0
      card_base.h
  3. 1 0
      card_car.cpp
  4. 16 0
      his_location.cpp
  5. 1 0
      his_location.h
  6. 5 0
      websocket/jsonBuilder.cpp
  7. 2 0
      websocket/ws_common.h

+ 16 - 3
card_base.cpp

@@ -150,6 +150,11 @@ void card_location_base::make_his_location_cell_reader(uint64_t t, const loc_poi
 	m_his_location_card->insert_cell_reader(pt, t);
 }
 
+void card_location_base::make_his_vehicle_worktime(uint64_t t, uint32_t card_id)
+{
+	m_his_location_card->insert_vehicle_worktime(card_id, t);
+}
+
 float get_pdoa(const double poa[], const double& offset)
 {
 	if (poa == nullptr) {
@@ -505,9 +510,6 @@ void card_location_base::on_location(const std::vector<point>&vp, const std::vec
 			
 			pt.m_speed_change_rate = speed_diff;
 
-			
-
-			
 			log_info("[pdoa] card_location_base::on_location ,obj_id=%d, time=%s, reader_id=%d, ct=%d, poa1=%.4f, poa2=%.4f, poa3=%.4f, pdoa=%.4f, pdoa_offset=%.4f, speed=%f, avg_speed=%f, begin_pt.x=%f, begin_pt.y=%f, gesture=%d, dist_original=%f, dist=%f, angle=%f, acc=%.2f, rav=%d, cell_index=%d, cell_x=%f, cell_y=%f, site_cell_index=%d, cell_count=%d, moving_direct=%s, speed_diff=%f",
 				pt.m_cid,
 				tool_time::to_str_ex(lm[0].m_time_tmp).c_str(),
@@ -549,6 +551,16 @@ void card_location_base::on_location(const std::vector<point>&vp, const std::vec
 			//make_his_location_simplify(time(0) * 1000, pt);
 			make_his_location_cell_card(pt.m_time_tmp, pt);
 			make_his_location_cell_reader(pt.m_time_tmp, pt);
+			if (cell_index_current <= 30 && pt.m_direction == "-"&&m_rejudge_well_entry == true)
+			{
+				make_his_vehicle_worktime(pt.m_time_tmp, pt.m_cid);
+				m_rejudge_well_entry = false;
+			}
+			//已经入井了,可以重新记录入井时间
+			else if(cell_index_current > 30)
+			{
+				m_rejudge_well_entry = true;
+			}
 		}
 
 		//pt.m_speed *= 20;
@@ -766,6 +778,7 @@ void  card_location_base::clear()
     m_buff_size = 0;
     m_last_recv_time = 0;
     m_last_point = point(0,0);
+	m_cell_index = 0;
     m_last_site_id = 0;
     m_last_site_dir = -1;
     m_last_ct = 0;

+ 3 - 0
card_base.h

@@ -79,6 +79,7 @@ struct card:point
 	double	m_avg_speed_for_count = 0.0;
 	int			m_speed_count = 0;//累积速度数,最大10000
 	std::string	m_direction_last = "+";
+	bool	m_rejudge_well_entry = true; //重新判断入井
 	uint64_t m_time_tmp_last = 0;
 	int		 m_statusBeforeTurning = 0;
 	int		 m_biz_stat;
@@ -144,6 +145,7 @@ struct card_location_base:card,std::enable_shared_from_this<card_location_base>
     boost::circular_buffer<float> m_cb_tof;     // the list of tof that is pdoa history value
     boost::circular_buffer<point> m_cb_point;
     point m_last_point;
+	int m_cell_index;
 	int m_cur_site_counts = 0;				// 当前基站缓存数据总数
 	std::vector<float> m_vtp_dist;			// 相同分站存储距离数据
 	bool m_over_site = false;				// 过分站状态
@@ -181,6 +183,7 @@ struct card_location_base:card,std::enable_shared_from_this<card_location_base>
 	void make_his_location_simplify(uint64_t t, const loc_point & pt); //插入定位历史记录到数据库zengmg
 	void make_his_location_cell_card(uint64_t t, const loc_point & pt);
 	void make_his_location_cell_reader(uint64_t t, const loc_point & pt);
+	void make_his_vehicle_worktime(uint64_t t, uint32_t card_id);
 	void on_message(zloop<task*>* loop, message_locinfo&loc, bool is_history);
     void on_message(zloop<task*>* loop, message_tdoa_locinfo& loc, bool is_history);
     void on_message(zloop<task*>* loop, message_pdoa_locinfo& loc, bool is_history);

+ 1 - 0
card_car.cpp

@@ -403,6 +403,7 @@ void car::make_package()
     
     cp.down_time = m_last_point.x;
     cp.z         = m_last_point.y;
+	cp.cell_index = m_cell_index;
 	
     upt_card_pos(cp, pt);
 

+ 16 - 0
his_location.cpp

@@ -379,6 +379,22 @@ void location_card::insert_cell_reader(const loc_point &pt, uint64_t timestamp)
 	sDBConnPool.PushAsync(sql);
 }
 
+void location_card::insert_vehicle_worktime(uint32_t card_id, uint64_t timestamp)
+{
+	//按新表插入
+	char sql[1024] = { 0 };
+
+	std::string time = tool_time::to_str_ex(timestamp).c_str();
+
+	snprintf(sql, 1024, "replace into his_vehicle_worktime (card_id, work_Time) values(%d, '%s'); ",
+		card_id,
+		time.c_str());
+
+	log_info("[sql] %s", sql);
+
+	sDBConnPool.PushAsync(sql);
+}
+
 void location_card::update(const point &p,uint64_t timestamp,int flag/*=0*/,int dflag/*=0*/)
 {
     //std::string tabName=getTabName();

+ 1 - 0
his_location.h

@@ -63,6 +63,7 @@ struct location_card
 	void insert_simplify(const loc_point &pt, uint64_t timestamp);
 	void insert_cell_card(const loc_point &pt, uint64_t timestamp);
 	void insert_cell_reader(const loc_point &pt, uint64_t timestamp);
+	void insert_vehicle_worktime(uint32_t card_id, uint64_t timestamp);
 	void insert(uint64_t timestamp, const point & p, int32_t areaid, int32_t mapid, int32_t siteid, double scale);
 
 	void update(const point &p,uint64_t timestamp,int flag=0,int dflag=0);

+ 5 - 0
websocket/jsonBuilder.cpp

@@ -191,6 +191,11 @@ namespace sys
 		
 		DetailItem = Array_1;
 		Array.PushBack(DetailItem, Allocator );
+
+		//19 cell index
+		tmp_object.SetInt(CardPos.cell_index);
+		Array.PushBack(tmp_object, Allocator);
+
 		DetailItem = Array;
 		return true;
 	}

+ 2 - 0
websocket/ws_common.h

@@ -70,6 +70,7 @@ namespace sys
         double x;               //x坐标
         double y;               //y坐标
         double z;               //z坐标
+		int cell_index;
         double down_time;       //入井时间戳
         double enter_area_time; //进入区域时间戳
         double rec_time;        //最后接收时间戳
@@ -89,6 +90,7 @@ namespace sys
             x               = 0;
             y               = 0;
             z               = 0;
+			cell_index = 0;
             down_time       = 0;
             enter_area_time = 0;
             rec_time        = 0;