Browse Source

修复呼救逻辑bug

lixioayao 5 years ago
parent
commit
40c47bdf9d
3 changed files with 15 additions and 13 deletions
  1. 13 7
      event.cpp
  2. 1 1
      event.h
  3. 1 5
      module_service/module_call_help.cpp

+ 13 - 7
event.cpp

@@ -11,7 +11,7 @@
 #include"tool_time.h"
 #include"ant.h"
 #include"db/db_tool.h"
-
+#include "mine.h"
 
 uint64_t ya_event::get_list_id()
 {
@@ -235,7 +235,7 @@ std::shared_ptr<ya_event> event_list::get_event_card(uint32_t card_id, int card_
     return base::get(to_list_id(ev_type, OT_CARD, id64,edt));
 }
 
-void event_list::save_event(std::shared_ptr<ya_event> ev_ptr)
+void event_list::save_event(const std::shared_ptr<ya_event> &ev_ptr)
 {
     char sql[LENGTH_SQL] = {0};
     std::string _time = tool_time::to_str_ex(ev_ptr->m_cur_time);
@@ -342,12 +342,18 @@ void event_list::load_his_data_from_db()
             //这里当是卡告警的时候,对m_event数据进行赋值
             //方便清理
             //备注防追尾告警和一人多卡告警可能不适用,后续整理
-            if(ev->m_obj_type==OT_CARD)
-            {
+            if(ev->m_obj_type==OT_CARD){
                 uint64_t c_id= tool_other::card_id_to_u64(ev->m_obj_id);
-                if(auto c=card_list::instance()->get(c_id))
-                    c->set_event_flag(ev->m_ev_type);
-            } 
+                if(auto c=card_list::instance()->get(c_id)){
+                    do{
+                        if(c->m_type==CT_PERSON){
+                            auto mine_tool_ptr = c->get_mine_tool();
+                            if(!mine_tool_ptr->m_is_attendance) break;
+                        }
+                         c->set_event_flag(ev->m_ev_type);
+                    }while(0);
+                }
+            }
             if(ev->m_ev_type==ET_READER_POWER_BY_BATTERY)
                 if(auto r=sit_list::instance()->get(std::stoi(obj_id)))
                     r->m_power_ac_down=true;

+ 1 - 1
event.h

@@ -115,7 +115,7 @@ public:
         return base::get(to_list_id(ev_type,OT_DEVICE_READER, static_cast<uint64_t>(reader_id),edt));
     }
 
-    static void save_event(std::shared_ptr<ya_event> event_ptr);
+    static void save_event(const std::shared_ptr<ya_event> &event_ptr);
 
     void load_his_data_from_db();
 

+ 1 - 5
module_service/module_call_help.cpp

@@ -18,6 +18,7 @@ void module_call_help::rev_from_card_help(std::shared_ptr<card_location_base> ca
 {
     uint64_t id = tool_other::type_id_to_u64(card_ptr->m_type, card_ptr->m_id);
     event_tool::instance()->handle_event(OT_CARD, ET_CARD_HELP, id, 0, 0, true);
+    if(card_ptr)card_ptr->set_event_flag(ET_CARD_HELP);
 }
 
 /**
@@ -47,11 +48,6 @@ void module_call_help::accept_web_deal_help(sio::message::ptr const& data)
         if(ev_ptr && ES_DEAL_HELP != ev_ptr->m_status)
         {
             ev_ptr->m_status = ES_DEAL_HELP;
-
-            event_list::save_event(ev_ptr);
-
-            //删除
-            //event_list::instance()->remove(ev_ptr->get_list_id(), ev_ptr);
         }
     }
     else