Browse Source

修复历史告警加载功能 && 修复人车卡 分站 区域删除后,删除告警相关功能

lixioayao 5 years ago
parent
commit
8b9bc5155f
4 changed files with 34 additions and 21 deletions
  1. 6 0
      ant.cpp
  2. 1 0
      ant.h
  3. 17 11
      event.cpp
  4. 10 10
      module_service/module_meta_date_changed.cpp

+ 6 - 0
ant.cpp

@@ -632,6 +632,12 @@ void site::create_area()
 {
     m_area=std::make_shared<area>(-m_id,0,0,m_scale,m_map_id,1<<7);
 }
+void site::clear_event()
+{
+    event_tool::instance()->handle_event(OT_DEVICE_READER,ET_READER_ERROR,id(),READER_TIMEOUT,0,false);
+    event_tool::instance()->handle_event(OT_DEVICE_READER,ET_READER_POWER_BY_BATTERY,id(),0,0,false);
+}
+
 /*
    处理分站供电状态,交流供电时,ac_down=false,直流供电时,ac_down=true
 

+ 1 - 0
ant.h

@@ -172,6 +172,7 @@ struct site:point,std::enable_shared_from_this<site>
     }
     void create_area();
     const std::shared_ptr<area> &get_area()const{return m_area;}
+    void clear_event();
     point get_dstp(const point pt) const
     {
         point tmp;

+ 17 - 11
event.cpp

@@ -265,7 +265,6 @@ void event_list::load_his_data_from_db(bool init /*=true*/)
             WHERE event_id IN (SELECT MAX(event_id) FROM his_event_data \
                                WHERE cur_time > (CASE obj_type_id \
                                                  WHEN 1 THEN DATE_SUB(NOW(),INTERVAL 2 DAY) \
-                                                 WHEN 2 THEN DATE_SUB(NOW(),INTERVAL 2 DAY)\
                                                  WHEN 4 THEN DATE_SUB(NOW(),INTERVAL 1 MONTH)\
                                                  WHEN 9 THEN DATE_SUB(NOW(),INTERVAL 2 DAY) \
                                                  WHEN 10 THEN DATE_SUB(NOW(),INTERVAL 2 DAY) \
@@ -273,7 +272,8 @@ void event_list::load_his_data_from_db(bool init /*=true*/)
                                AND cur_time < NOW()\
                                GROUP BY event_type_id, obj_id,dis_type) \
             AND  event_id NOT IN ( SELECT event_id FROM his_event_data WHERE  stat=100)\
-            AND event_type_id NOT IN (21,22,31,36);");
+            AND event_type_id NOT IN (21,22,31,36) and obj_type_id !=2;");
+
     if(!init)
         sql="SELECT event_id, id,stat,event_type_id,obj_type_id,obj_id,dis_type,map_id,area_id,limit_value,cur_value,x,y, cur_time FROM his_event_data WHERE cur_time > date_sub(NOW(),interval 20 second) and source=1 order by stat;";
     std::string Error;
@@ -371,17 +371,23 @@ void event_list::load_his_data_from_db(bool init /*=true*/)
                             auto mine_tool_ptr = c->get_mine_tool();
                             if(!mine_tool_ptr->m_is_attendance) break;
                         }
-                         c->set_event_flag(ev->m_ev_type);
+                        c->set_event_flag(ev->m_ev_type);
                     }while(0);
+                } else {
+                    log_warn("load_evnet_history:card_id:%s not exist...",obj_id.c_str());
+                    continue;
                 }
-            }
-            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;
-            if(ev->m_ev_type==ET_READER_ERROR)
-                if(auto r=sit_list::instance()->get(std::stoi(obj_id)))
-                    r->m_time=tool_time::to_ms(ev->m_cur_time)/1000;
-        
+            }else if(ev->m_obj_type==OT_DEVICE_READER){ 
+                auto sit_ptr=sit_list::instance()->get(std::stoi(obj_id));
+                if(!sit_ptr){
+                    log_warn("load_evnet_history:site_id:%s not exist...",obj_id.c_str());
+                    continue;
+                }
+                if(ev->m_ev_type==ET_READER_POWER_BY_BATTERY)
+                    sit_ptr->m_power_ac_down=true;
+                if(ev->m_ev_type==ET_READER_ERROR)
+                    sit_ptr->m_time=tool_time::to_ms(ev->m_cur_time)/1000;
+            } 
             if(!flag) 
                 map.insert(std::make_pair(id, ev));
             log_info("event_list %lld,%lld,%d,%d,%d,%s,%d,%d,%d,%.2f,%.2f,%.2f,%.2f,%s"

+ 10 - 10
module_service/module_meta_date_changed.cpp

@@ -209,14 +209,11 @@ void module_meta_date_changed::deal_call_edit_card(std::string & id64, EDIT_TYPE
 void module_meta_date_changed::deal_call_edit_area(const std::string& id,EDIT_TYPE_ID edit_type_id)
 {
     int cid = std::stoi(id);
-    if(ET_INSERT == edit_type_id || ET_UPDATE == edit_type_id)
-    {
+    if(ET_INSERT == edit_type_id || ET_UPDATE == edit_type_id){
         area_list::instance()->init_from_db(cid);
-    }
-    else if(ET_DELETE == edit_type_id)
+    }else if(ET_DELETE == edit_type_id)
     {
-        if(auto area_ptr = area_list::instance()->get(cid))
-        {
+        if(auto area_ptr = area_list::instance()->get(cid)){
             log_info("区域删除:areaid=%d", cid);
             area_ptr->clear();
             area_list::instance()->remove(cid);
@@ -228,11 +225,14 @@ void module_meta_date_changed::deal_call_edit_reader(const std::string &ids, EDI
 {
     if(ET_INSERT == edit_type_id || ET_UPDATE == edit_type_id){
         sit_list::instance()->init_site(ids);
-    }
-    else if(ET_DELETE == edit_type_id){
+    }else if(ET_DELETE == edit_type_id){
         int id =std::stoi(ids);
-        sit_list::instance()->remove(id);
-        card_path::init();
+        if(auto sit_ptr=sit_list::instance()->get(id)){
+            log_info("分站删除:sid=%d", id);
+            sit_ptr->clear_event();
+            sit_list::instance()->remove(id);
+            card_path::init();
+        }
     }
 }