Browse Source

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

liulei 5 years ago
parent
commit
0aefb40878
1 changed files with 13 additions and 3 deletions
  1. 13 3
      module_service/area_business_card_enter_or_leave.cpp

+ 13 - 3
module_service/area_business_card_enter_or_leave.cpp

@@ -20,10 +20,20 @@ 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;
-    snprintf(sql,LENGTH_SQL,"INSERT INTO his_location_area (obj_id,card_type_id,ident,area_id,map_id,enter_time,start_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);
-
+                 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);
+    }
     db_tool::PushAsync(sql);
 }