Parcourir la source

加载采煤机 掘进机

daiyueteng il y a 6 ans
Parent
commit
dd076817a9
8 fichiers modifiés avec 89 ajouts et 62 suppressions
  1. 4 3
      CMakeLists.txt
  2. 40 30
      card.cpp
  3. 8 12
      card.h
  4. 2 1
      cardMgr.cpp
  5. 4 0
      common.h
  6. 10 0
      common_tool.h
  7. 15 12
      module_service/module_meta_date_changed.cpp
  8. 6 4
      module_service/module_meta_date_changed.h

+ 4 - 3
CMakeLists.txt

@@ -86,7 +86,7 @@ set(SRC_MODULE
 
 add_executable(${PROJECT_NAME} "main.cpp" ${SRC_YASL}  ${SRC_MODULE})
 
-target_link_libraries (${PROJECT_NAME}  zlog rt ev boost_chrono boost_system boost_thread mysqlclient)
+target_link_libraries (${PROJECT_NAME}  zlog rt ev boost_chrono boost_system boost_thread mysqlclient three_rates)
 
 #file(COPY data_reader_antenna.txt DESTINATION ${PROJECT_BINARY_DIR})
 #file(COPY path_tof.txt DESTINATION ${PROJECT_BINARY_DIR})
@@ -94,8 +94,9 @@ target_link_libraries (${PROJECT_NAME}  zlog rt ev boost_chrono boost_system boo
 #file(COPY /root/projection/out/bin/logger DESTINATION ${PROJECT_BINARY_DIR})
 #file(COPY /root/projection/out/etc DESTINATION ${PROJECT_SOURCE_DIR})
 #file(COPY /root/projection/out/log DESTINATION ${PROJECT_SOURCE_DIR})
-#file(COPY /root/projection/out/include/log.h DESTINATION ${PROJECT_SOURCE_DIR})
-#file(COPY /root/projection/out/include/config_file.h DESTINATION ${PROJECT_SOURCE_DIR})
+#file(COPY /root/projection/out/include/ DESTINATION ${PROJECT_SOURCE_DIR})
+
+
 
 
 

+ 40 - 30
card.cpp

@@ -23,7 +23,6 @@
 #include "visit.h"
 #include "his_location.h"
 #include "three_rates.h"
-
 extern config_file config;
 //一张卡一个ct的所有不同天线的信息
 struct one_ct_message_handle
@@ -123,6 +122,7 @@ struct one_ct_message_handle
 
     void calc_location()
 	{
+		log_info("calc_location:%d begin",m_card->m_id);
         auto v = m_msg_list;
 
 		std::vector<point> rc=std::move(m_loc_tool.calc_location(v));
@@ -130,6 +130,7 @@ struct one_ct_message_handle
 		if(!rc.empty()) m_card->on_location(std::move(rc),v);
 
 		reset();
+		log_info("calc_location:%d end",m_card->m_id);
 	}
 };
 struct card_message_handle
@@ -219,7 +220,7 @@ struct person:card_location_base, card_area
 
     void clear()
     {
-        m_site_area.reset(new site_area_hover);
+        //m_site_area.reset(new site_area_hover);
         m_area_tool.reset(new area_tool);
         m_mine_tool.reset(new mine_tool);
 
@@ -367,7 +368,7 @@ struct car:card_location_base,card_area
 		m_area_tool->on_point(m_id,pt,m_speed,m_type);
         m_site_area->on_point(m_id,0,this, m_type);
         m_mine_tool->on_point(m_id, m_type, m_vehicle_category_id);
-		handle_three_rates(pt);
+	handle_three_rates(pt);
 	}
 
     int get_vehicle_type_id()
@@ -456,7 +457,7 @@ uint64_t card_list::getId(uint32_t cardid,uint64_t type)
 	return type<<32|cardid;
 }
 
-void card_list::init_staffer(int32_t id)
+void card_list::init_staffer(int64_t id64)
 {
     std::string strategy = config.get("person.strategy","person1");
     std::string sql = "SELECT staff_id, s.card_id, c.card_type_id, s.dept_id, s.group_id, s.occupation_id, \
@@ -465,11 +466,10 @@ void card_list::init_staffer(int32_t id)
             LEFT JOIN dat_card c ON s.card_id = c.card_id \
             LEFT JOIN dat_occupation o ON s.occupation_id = o.occupation_id \
             LEFT JOIN dat_occupation_level ol ON ol.occupation_level_id = o.occupation_level_id \
-            WHERE c.card_type_id = 1 AND s.duty_id = 0 AND c.state_id = 0";
+            WHERE s.duty_id = 0 AND c.state_id = 0";
 
-    int type = CT_PERSON;
-    std::string card_id_str = card_list::to_id64_str(type, static_cast<uint32_t>(id));
-    if(-1 == id)
+    std::string card_id_str = tool_other::to13str(id64);
+    if(-1 == id64)
     {
         sql.append(";");
     }
@@ -527,18 +527,18 @@ void card_list::init_staffer(int32_t id)
         //for now;
         //staff_id = vsid;
 
-        if(-1 == id)
+        if(-1 == id64)
         {
             std::shared_ptr<card_location_base> clb =
                     std::make_shared<person>(strategy,vsid,need_display,card_type_id,dept_id,occupation_level_id,staff_id,work_line);
-            uint64_t cardid = getId(vsid,type);
+            uint64_t cardid = getId(vsid,card_type_id);
             log_info("cardId:%llu,id:%d dept_id:%d,need_display:%d,card:%s:work_line:%d,staff_id:%d,type:%d",
                      cardid,vsid,dept_id,need_display,card_id.c_str(),work_line,staff_id,card_type_id);
             map.insert({cardid,clb});
         }
         else
         {
-            auto card_id64 = card_list::to_id64(type, static_cast<uint32_t>(id));
+            auto card_id64 = card_list::to_id64(card_type_id, tool_other::id64_to_id(card_id));
             auto card_ptr = card_list::instance()->get(card_id64);
             if(card_ptr)
             {
@@ -556,21 +556,21 @@ void card_list::init_staffer(int32_t id)
                 card_list::instance()->add(card_id64, clb);
             }
 
-            log_info("基础数据 增加或修改人卡成功:卡id:%d,卡type:%d dept_id:%d,need_display:%d,occupation_level_id:%d",
-                     id,type,dept_id,need_display,occupation_level_id);
-            std_debug("基础数据 增加或修改人卡成功:卡id:%d,卡type:%d dept_id:%d,need_display:%d,occupation_level_id:%d",
-                     id,type,dept_id,need_display,occupation_level_id);
+            log_info("基础数据 增加或修改人卡成功:卡id:%ld, dept_id:%d,need_display:%d,occupation_level_id:%d",
+                     id64,dept_id,need_display,occupation_level_id);
+            std_debug("基础数据 增加或修改人卡成功:卡id:%ld, dept_id:%d,need_display:%d,occupation_level_id:%d",
+                     id64,dept_id,need_display,occupation_level_id);
         }
     }
 
-    if(-1 == id)
+    if(-1 == id64)
     {
         log_info( "init_staffer. The record count=%d\n", nCount );
         card_list::instance()->add(map);
     }
 }
 
-void card_list::init_vehicle(int32_t id)
+void card_list::init_vehicle(int64_t id64)
 {
     std::string strategy = config.get("car.strategy","car1");
     std::string sql = "SELECT ve.vehicle_id, ve.card_id, c.card_type_id, \
@@ -584,11 +584,10 @@ void card_list::init_vehicle(int32_t id)
                         LEFT JOIN dat_group g ON ve.group_id = g.group_id \
                         LEFT JOIN dat_vehicle_type vt ON v.vehicle_type_id = vt.vehicle_type_id \
                         LEFT JOIN dat_vehicle_category vc ON vc.vehicle_category_id = vt.vehicle_category_id \
-                        WHERE c.card_type_id = 2 AND c.state_id = 0";
+                        WHERE c.state_id = 0";
 
-    int type = CT_VEHICLE;
-    std::string card_id_str = card_list::to_id64_str(type, static_cast<uint32_t>(id));
-    if(-1 == id)
+    std::string card_id_str = tool_other::to13str(id64);
+    if(-1 == id64)
     {
         sql.append(";");
     }
@@ -656,18 +655,18 @@ void card_list::init_vehicle(int32_t id)
         //for now
         //vehicle_id = vsid;
 
-        if(-1 == id)
+        if(-1 == id64)
         {
             auto clb = std::make_shared<car>(strategy,vsid,need_display,card_type_id,
                                              dept_id,vehicle_category_id, vehicle_type_id,vehicle_level_id,vehicle_id);
-            uint64_t cardid = getId(vsid,type);
+            uint64_t cardid = getId(vsid,card_type_id);
             log_info("cardId:%llu,id:%d dept_id:%d,need_display:%d-cardid:%s,categoryid:%d,vchile_id:%d,type:%d",
                      cardid,vsid,dept_id,need_display,card_id.c_str(),vehicle_category_id,vehicle_id,card_type_id);
             map.insert({cardid,clb});
         }
         else
         {
-            auto card_id64 = card_list::to_id64(type, static_cast<uint32_t>(id));
+            auto card_id64 = card_list::to_id64(card_type_id, tool_other::id64_to_id(card_id));
             auto card_ptr = card_list::instance()->get(card_id64);
             if(card_ptr)
             {
@@ -685,14 +684,14 @@ void card_list::init_vehicle(int32_t id)
                 card_list::instance()->add(card_id64, clb);
             }
 
-            log_info("基础数据 增加或修改车卡成功:卡id:%d,卡type:%d dept_id:%d,need_display:%d,categoryid:%d",
-                     vsid,type,dept_id,need_display,vehicle_category_id);
-            std_debug("基础数据 增加或修改车卡成功:卡id:%d,卡type:%d dept_id:%d,need_display:%d,categoryid:%d",
-                     vsid,type,dept_id,need_display,vehicle_category_id);
+            log_info("基础数据 增加或修改车卡成功:卡id:%ld, dept_id:%d,need_display:%d,categoryid:%d",
+                     id64,dept_id,need_display,vehicle_category_id);
+            std_debug("基础数据 增加或修改车卡成功:卡id:%ld, dept_id:%d,need_display:%d,categoryid:%d",
+                     id64,dept_id,need_display,vehicle_category_id);
         }
     }
 
-    if(-1 == id)
+    if(-1 == id64)
     {
         log_info( "init_vehicle. The record count=%d\n", nCount );
         card_list::instance()->add(map);
@@ -1173,7 +1172,7 @@ void card_location_base::on_location(const std::vector<point>&vp,const std::vect
 
 		Msg m;
 		m.type=m_type;m.x=(int)x;m.y=(int)y;m.cmd=CMD_HANDLE;m.cardid=m_type<<32|m_id;
-		cardMgr::instance()->tryPut(m);
+		//cardMgr::instance()->tryPut(m);
 		double acc = lm[0].m_acc;
 		log_info("useful:card_id:%d,ct:%d,timestamp:%llu, loc_point,x:%.2f,y:%.2f acc:%.2f",m_id,m_ct,m_time,pt.x,pt.y,acc);
 		do_business(pt,acc);
@@ -1256,6 +1255,17 @@ void card_location_base::put_three_rates(card_pos & cp)
 	log_info("three_rates:type:%d,id:%d,cid:%d",cp.type,cp.id,cp.identifier_id);
 	three_rates::get_instance()->put(cp);
 }
+
+bool card_location_base::is_person() const
+{
+    return tool_other::is_person(m_type);
+}
+
+bool card_location_base::is_vehicle() const
+{
+    return tool_other::is_vehicle(m_type);
+}
+
 card_location_base::~card_location_base()
 {
 }

+ 8 - 12
card.h

@@ -83,24 +83,19 @@ struct card_location_base:card
 	void del_card_pos();
 	int get_stat();
 	void put_three_rates(card_pos &);
-    bool is_person() const
-    {
-        return CT_PERSON == m_type;
-    }
 
-    bool is_vehicle() const
-    {
-        return CT_VEHICLE == m_type;
-    }
+    bool is_person() const;
+    bool is_vehicle() const;
+
 	virtual ~card_location_base();
 };
 
 struct card_list:single_base<card_list,uint64_t,std::shared_ptr<card_location_base>>
 {
-    ///id=-1为初始化所有卡
-    void init_staffer(int32_t id);
-    ///id=-1为初始化所有卡
-    void init_vehicle(int32_t id);
+    ///id64=-1为初始化所有卡, id格式为:10000001016
+    void init_staffer(int64_t id64);
+    ///id64=-1为初始化所有卡, id格式为:10000001016
+    void init_vehicle(int64_t id64);
     //void init_staffer();
     //void init_vehicle();
     uint64_t getId(uint32_t cardid,uint64_t);
@@ -132,6 +127,7 @@ struct card_list:single_base<card_list,uint64_t,std::shared_ptr<card_location_ba
 
         return std::string(sql);
     }
+
     ~card_list(){m_bflag=true;}
 };
 

+ 2 - 1
cardMgr.cpp

@@ -1,6 +1,7 @@
 #include "cardMgr.h" 
 #include "bindmorecard.h"
 #include "common.h"
+#include"common_tool.h"
 
 cardMgr::cardMgr()
 :m_queue(2048)
@@ -46,7 +47,7 @@ void cardMgr::clear(uint64_t cardid)
 void cardMgr::handleMessage(const Msg &m)
 {
 	m_glist.update(m.x,m.y,m.cardid);
-	if(m.type==CT_VEHICLE) return;
+    if(tool_other::is_vehicle( m.type) ) return;
 	std::vector<uint64_t> rc=m_glist.find_near(m.cardid,1);
 	
 	log_info("LemonHash+..%d,size:%d,(%d,%d)",m.cardid,rc.size(),m.x,m.y);

+ 4 - 0
common.h

@@ -55,6 +55,10 @@ enum CARD_TYPE
 	CT_PERSON=1,
 	///卡类型 车卡
 	CT_VEHICLE=2,
+    ///    4 采煤机
+    CT_COAL_CUTTER=4,
+    ///    5  掘进机
+    CT_HEADING_MACHINE=5
 };
 
 enum AREA_TYPE

+ 10 - 0
common_tool.h

@@ -174,6 +174,16 @@ public:
         return std::stoi(to13str(str).substr(0, 3));
     }
 
+    static bool is_person(int32_t type)
+    {
+        return CT_PERSON == type;
+    }
+
+    static bool is_vehicle(int32_t type)
+    {
+        return CT_VEHICLE == type || CT_COAL_CUTTER == type || CT_HEADING_MACHINE == type;
+    }
+
 //    static uint32_t id64_to_id(uint64_t card_id)
 //    {
 //        return static_cast<uint32_t>(card_id);

+ 15 - 12
module_service/module_meta_date_changed.cpp

@@ -4,43 +4,46 @@
 #include"ant.h"
 
 
-void module_meta_date_changed::deal_call_edit_vehicle(int id, EDIT_TYPE_ID edit_type_id)
+void module_meta_date_changed::deal_call_edit_vehicle(int64_t id64, EDIT_TYPE_ID edit_type_id)
 {
     if(ET_INSERT == edit_type_id || ET_UPDATE == edit_type_id)
     {
-        card_list::instance()->init_vehicle(id);
+        card_list::instance()->init_vehicle(id64);
     }
     else if(ET_DELETE == edit_type_id)
     {
-        remove_card(static_cast<uint32_t>(id), CT_VEHICLE);
+        auto str = tool_other::to13str(id64);
+
+        remove_card(tool_other::id64_to_id(str), tool_other::id64_to_type(str));
     }
 }
 
-void module_meta_date_changed::deal_call_edit_staff(int id, EDIT_TYPE_ID edit_type_id)
+void module_meta_date_changed::deal_call_edit_staff(int64_t id64, EDIT_TYPE_ID edit_type_id)
 {
     if(ET_INSERT == edit_type_id || ET_UPDATE == edit_type_id)
     {
-        card_list::instance()->init_staffer(id);
+        card_list::instance()->init_staffer(id64);
     }
     else if(ET_DELETE == edit_type_id)
     {
-        remove_card(static_cast<uint32_t>(id), CT_PERSON);
+        auto str = tool_other::to13str(id64);
+
+        remove_card(tool_other::id64_to_id(str), tool_other::id64_to_type(str));
     }
 }
 
-void module_meta_date_changed::deal_call_edit_card(int id64, EDIT_TYPE_ID edit_type_id)
+void module_meta_date_changed::deal_call_edit_card(int64_t id64, EDIT_TYPE_ID edit_type_id)
 {
     std::string card_id64_str = tool_other::to13str(static_cast<uint64_t>(id64));
     int type = tool_other::id64_to_type(card_id64_str);
-    int id = static_cast<int32_t>(tool_other::id64_to_id(card_id64_str));
 
-    if(CT_PERSON==type)
+    if(tool_other::is_person(type))
     {
-        deal_call_edit_staff(id, edit_type_id);
+        deal_call_edit_staff(id64, edit_type_id);
     }
-    else if(CT_VEHICLE==type)
+    else if(tool_other::is_vehicle(type))
     {
-        deal_call_edit_vehicle(id, edit_type_id);
+        deal_call_edit_vehicle(id64, edit_type_id);
     }
     else
     {

+ 6 - 4
module_service/module_meta_date_changed.h

@@ -44,7 +44,7 @@ public:
 
         std_debug("基础数据 receive meta_data_changed: %s", name.c_str());
 
-        int id=-1;
+        int64_t id=-1;
         tool_map::try_get_value(id, JSON_KEY_ID, data);
 
         std::string op_type="";
@@ -148,12 +148,14 @@ public:
     }
 
 private:
-    void deal_call_edit_vehicle(int id, EDIT_TYPE_ID edit_type_id);
+    ///id64格式为:10000001016
+    void deal_call_edit_vehicle(int64_t id64, EDIT_TYPE_ID edit_type_id);
 
-    void deal_call_edit_staff(int id, EDIT_TYPE_ID edit_type_id);
+    ///id64格式为:10000001016
+    void deal_call_edit_staff(int64_t id64, EDIT_TYPE_ID edit_type_id);
 
     ///id64格式为10000006666
-    void deal_call_edit_card(int id64, EDIT_TYPE_ID edit_type_id);
+    void deal_call_edit_card(int64_t id64, EDIT_TYPE_ID edit_type_id);
 
     void deal_call_edit_reader(int id, EDIT_TYPE_ID edit_type_id);