Browse Source

使用vehicle_type_id 来确认采煤机和掘进机

lixioayao 5 years ago
parent
commit
cb81bf2eb4

+ 9 - 10
card.cpp

@@ -363,8 +363,8 @@ void card_list::load_his_card_postion_staff()
 void card_list::on_message(zloop<task*> *loop, message_locinfo&loc,bool is_history)
 {
 	uint64_t cardid = tool_other::type_id_to_u64(loc.m_card_type,loc.m_card_id);
-	const auto c=card_list::instance()->get(cardid);
-	if(c==nullptr)
+	const auto &c=card_list::instance()->get(cardid);
+	if(!c)
 	{
 		log_warn("数据库中未定义该卡的信息,card_id=%d, card_type=%d,cardid:%lld",loc.m_card_id,loc.m_card_type,cardid);
 		return;
@@ -376,21 +376,20 @@ void card_list::on_message(zloop<task*> *loop, message_locinfo&loc,bool is_histo
 			loc.m_acc,loc.m_rssi,loc.m_batty_status,loc.m_time_stamp);
     if(loc.m_card_type != CT_PERSON && CYaSetting::m_sys_setting.test_rav(loc.m_card_type,loc.m_card_id))
         loc.set_rav(0);
-
+    
 	c->on_message(loop,loc,is_history);
+
+	if(tool_other::is_driving(loc.m_card_type,c->get_vehicle_type_id()))
+        mine_business::inst()->make_reverse_condition(loc.m_card_type,loc.m_card_id,loc.m_ant_id,loc.m_card_ct,loc.m_tof,loc.m_site_id);
 }
 
 //获取卡数据  //标识id 人staff_id 车 vehicle_id
-std::shared_ptr<card_location_base> card_list::get_card_by_cid(int cid)
+const std::shared_ptr<card_location_base> card_list::get_card_by_cid(int cid)
 {
-    auto t_map = m_map;
-    for(std::pair<int,std::shared_ptr<card_location_base>> me:t_map)
-    {
+    auto t_map = card_list::instance()->m_map;
+    for(const std::pair<int,std::shared_ptr<card_location_base>> &me:t_map)
         if ((int)me.second->m_cid == cid)
-        {
             return me.second;
-        }
-    }
     return nullptr;
 }
 

+ 1 - 1
card.h

@@ -24,7 +24,7 @@ struct card_list:single_base<card_list,uint64_t,std::shared_ptr<card_location_ba
     void load_his_card_postion_from_db();
 
     //获取卡数据  //标识id 人staff_id 车 vehicle_id
-    std::shared_ptr<card_location_base> get_card_by_cid(int cid);
+    const std::shared_ptr<card_location_base> get_card_by_cid(int cid);
     ~card_list(){}
 };
 #endif

+ 0 - 5
card_person.cpp

@@ -141,11 +141,6 @@ void person::handle_three_rates(const point & pt)
 
 void person::on_timer()
 {
-    if(!m_1sto2s){
-        m_1sto2s=true;
-        return ;
-    }
-    m_1sto2s=false;
     if(!m_mine_tool->m_is_attendance)
 	{
 		if(m_upmine_flag.load())

+ 0 - 1
card_person.h

@@ -13,7 +13,6 @@ struct person:card_location_base, card_area
     static int m_limit_detained_time;
     static int m_auto_up_mine_time;
     static int m_person_cards_flag;
-    bool       m_1sto2s{true};
     std::weak_ptr<monkey_person> m_monkeyPerson;
     std::string m_stafferName,m_deptName;
     person(const std::string &type,uint32_t cardid,uint16_t needdisplay,int16_t t,int32_t deptid,int32_t level_id,uint32_t cid,int wl,const std::string &sname,const std::string &dname,int workrype_id);

+ 5 - 1
common.h

@@ -61,7 +61,11 @@ enum CARD_TYPE
     ///    5  掘进机
     CT_HEADING_MACHINE=5
 };
-
+enum VEHICLE_TYPE
+{
+    VT_COAL_CUTTER=25,
+    VT_HEADING_MACHINE=26
+};
 enum AREA_TYPE
 {
 	AREA_TYPE_UPMINE =0,

+ 6 - 10
common_tool.h

@@ -95,21 +95,17 @@ class tool_other
             return type_id_to_u64(card_id_to_type(cardid),card_id_to_id(cardid));
         }
 
-        ///采煤机
-        static bool is_coal(int32_t type)
+        static bool is_coal(int32_t type,int32_t vtype)
         {
-            return CT_COAL_CUTTER == type;
+            return CT_COAL_CUTTER == type || vtype==VT_COAL_CUTTER;
         }
-
-        /// 掘进机
-        static bool is_driving(int32_t type)
+        static bool is_driving(int32_t type,int32_t vtype)
         {
-            return CT_HEADING_MACHINE == type;
+            return CT_HEADING_MACHINE == type || vtype==VT_HEADING_MACHINE;
         }
-
-        static bool is_coal_or_driving(int32_t type)
+        static bool is_coal_or_driving(int32_t type,int32_t vtype)
         {
-            return CT_COAL_CUTTER == type || CT_HEADING_MACHINE == type;
+            return is_coal(type,vtype) || is_driving(type,vtype);
         }
 };
 

+ 3 - 3
db/db_card.cpp

@@ -99,7 +99,7 @@ namespace db_card
 			std::string strategy;
 			if(card_type_id ==CT_VEHICLE)
 				strategy = config.get("car.strategy","CS_1");
-			else if(card_type_id ==CT_COAL_CUTTER)
+			else if(vehicle_type_id==VT_COAL_CUTTER)
 				strategy = config.get("coalface.strategy","WS_1");
             else
 				strategy = config.get("person.strategy","PS_1");
@@ -107,8 +107,8 @@ namespace db_card
 			auto clb = card_location_base::make_car(strategy,vsid,need_display,card_type_id,
 					dept_id,vehicle_category_id, vehicle_type_id,vehicle_level_id,vehicle_id);
 			uint64_t cardid = tool_other::type_id_to_u64(card_type_id,vsid);
-			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);
+			log_info("cardId:%llu,id:%d dept_id:%d,need_display:%d-cardid:%s,categoryid:%d,vchile_id:%d,type:%d,vehicle_type_id:%d",
+					cardid,vsid,dept_id,need_display,card_id.c_str(),vehicle_category_id,vehicle_id,card_type_id,vehicle_type_id);
 			map.insert({cardid,clb});
 		}
 

+ 1 - 1
event.cpp

@@ -399,7 +399,7 @@ void event_list::_ev_to_node(std::shared_ptr<ya_event> ev_ptr,
 {
     rapidjson::Value ev(rapidjson::kObjectType);
 
-    ev.AddMember(JSON_KEY_EVENT_EVENT_ID,ev_ptr->m_ev_id, allocator);
+    ev.AddMember(JSON_KEY_EVENT_EVENT_ID,ev_ptr->m_id, allocator);
     ev.AddMember(JSON_KEY_EVENT_STATUS,ev_ptr->m_status, allocator);
 
     ev.AddMember(JSON_KEY_EVENT_TYPE_ID,ev_ptr->m_ev_type, allocator);

+ 7 - 4
message.cpp

@@ -2,6 +2,8 @@
 #include "zstream.h"
 #include "message.h"
 #include "log.h"
+#include "common_tool.h"
+#include "card.h"
 
 void message_locinfo::zero_this()
 {
@@ -50,7 +52,8 @@ void message_locinfo::load(zistream&is,bool tdoa)
 
 	//加速度
 	is>>b;
-	if(m_card_type == 1 || m_card_type==4 || m_card_type==5)
+    const auto &c=card_list::instance()->get(tool_other::type_id_to_u64(m_card_type,m_card_id));
+	if(m_card_type == 1 ||(c && tool_other::is_coal_or_driving(m_card_type,c->get_vehicle_type_id())))
 		m_acc=b;
 	else
 		m_acc=((b&0x80)?-1.:1.)*(b&0x7f)*0.01;
@@ -87,9 +90,8 @@ std::vector<task*> message_locinfo::load_753C(zistream&is)
 	m.zero_this();
 
 	uint8_t  b;
-	uint16_t card_id;
 	//卡类型、卡号、CT、电池状态
-	is>>b>>card_id>>m.m_card_ct;
+	is>>b>>m.m_card_id>>m.m_card_ct;
 	m.m_card_type=b&0xF;
 	m.m_batty_status=b>>4;
 
@@ -105,7 +107,8 @@ std::vector<task*> message_locinfo::load_753C(zistream&is)
 
 	//加速度
 	is>>b;
-	if(m.m_card_type==1 || m.m_card_type==4 || m.m_card_type==5)
+    auto c=card_list::instance()->get(tool_other::type_id_to_u64(m.m_card_type,m.m_card_id));
+	if(m.m_card_type == 1 ||(c && tool_other::is_coal_or_driving(m.m_card_type,c->get_vehicle_type_id())))
 		m.m_acc=b;
 	else
 		m.m_acc=((b&0x80)?-1.:1.)*(b&0x7f)*0.01;

+ 3 - 3
module_service/area_business_geofault.cpp

@@ -40,7 +40,7 @@ void area_business_geofault::on_load_his(const std::shared_ptr<area_hover>&area_
 void area_business_geofault::on_enter(const std::shared_ptr<area_hover>&area_hover_ptr,
                                       const std::shared_ptr<card_location_base>&card_ptr,std::shared_ptr<business_data>& ptr)
 {
-    if(!tool_other::is_coal_or_driving(card_ptr->m_type))
+    if(!tool_other::is_coal_or_driving(card_ptr->m_type,card_ptr->get_vehicle_type_id()))
     {
         return;
     }
@@ -65,7 +65,7 @@ void area_business_geofault::on_enter(const std::shared_ptr<area_hover>&area_hov
 void area_business_geofault::on_hover(const std::shared_ptr<area_hover>&area_hover_ptr,
                                       const std::shared_ptr<card_location_base>&card_ptr,std::shared_ptr<business_data> ptr)
 {
-    if(!tool_other::is_coal_or_driving(card_ptr->m_type))
+    if(!tool_other::is_coal_or_driving(card_ptr->m_type,card_ptr->get_vehicle_type_id()))
     {
         return;
     }
@@ -120,7 +120,7 @@ void area_business_geofault::on_hover(const std::shared_ptr<area_hover>&area_hov
 void area_business_geofault::on_leave(const std::shared_ptr<area_hover>&area_hover_ptr,
                                       const std::shared_ptr<card_location_base>&card_ptr,std::shared_ptr<business_data> ptr)
 {
-    if(!tool_other::is_coal_or_driving(card_ptr->m_type))
+    if(!tool_other::is_coal_or_driving(card_ptr->m_type,card_ptr->get_vehicle_type_id()))
     {
         return;
     }

+ 1 - 1
module_service/module_meta_date_changed.cpp

@@ -89,7 +89,7 @@ void module_meta_date_changed::accept(sio::message::ptr const& data)
             int id = std::stoi(szParam);
             deal_call_edit_light(id,edit_type_id);///待实现
         }
-        else if ("lights_group" == name)
+        else if ("lights_group"== name)
         {
             int id = std::stoi(szParam);
             deal_call_edit_lights_group(id,edit_type_id);///待实现

+ 1 - 5
net-service.cpp

@@ -65,7 +65,7 @@ void net_service::on_message(const std::shared_ptr<client> &clt,const char*data,
 					site_tm.tm_year+=2000-1900;
 					site_tm.tm_mon-=1;
 
-					auto site_ptr = sit_list::instance()->get(static_cast<int32_t>(site_id));
+					const auto &site_ptr = sit_list::instance()->get(static_cast<int32_t>(site_id));
 					if(!site_ptr)
 					{
 						logn_error(1,"在全局分站列表中找不到分站:%s,%d", clt->name().c_str(), site_id);
@@ -117,8 +117,6 @@ void net_service::on_message(const std::shared_ptr<client> &clt,const char*data,
 
 						t->m_cmd_code=cmd;
 						t->m_hash_id=m.m_card_id;
-						if(m.m_card_type==5)
-						    mine_business::inst()->make_reverse_condition(m.m_card_type,m.m_card_id,m.m_ant_id,m.m_card_ct,m.m_tof,m.m_site_id);
 						m_loc_worker->request(t);
 					}
 				}
@@ -197,8 +195,6 @@ void net_service::on_message(const std::shared_ptr<client> &clt,const char*data,
 
 							tk->m_hash_id=m.m_card_id;
 							tk->m_cmd_code=cmd;
-							if(m.m_card_type==5)
-								mine_business::inst()->make_reverse_condition(m.m_card_type,m.m_card_id,m.m_ant_id,m.m_card_ct,m.m_tof,m.m_site_id);
 
 							m_loc_worker->request(tk);
 						}

+ 3 - 1
websocket/jsonBuilder.cpp

@@ -411,6 +411,8 @@ namespace YA
 
 	std::string jsonBuilder::BuildCardPos( const std::map<uint64_t, _CARD_POS_>& CardPosList )
 	{
+        static bool p2s=false;
+        p2s=p2s?false:true;
 		rapidjson::StringBuffer sb;
 		rapidjson::Writer<rapidjson::StringBuffer> writer( sb );
 		rapidjson::Document doc;
@@ -438,7 +440,7 @@ namespace YA
 			//{
 			//	continue;
 			//}
-
+            if(p2s && mit_card->second.Type == 1)continue;
 			rapidjson::Value DetailItem;
 			if ( !__BuildDetail( mit_card->second, Allocator, DetailItem ) )
 			{