Browse Source

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

liulei 5 years ago
parent
commit
b2a64cba9a

+ 5 - 5
Makefile.am

@@ -18,11 +18,11 @@ SRC_MODULE_SERVICE= module_service/area_business_car_attendance.cpp module_servi
 
 
 SRC_MAIN= ant.cpp area.cpp base64.cpp bindmorecard.cpp mine_business.cpp card_area.cpp card_base.cpp card_car.cpp his_location.cpp\
-    	  card.cpp card_message_handle.cpp cardMgr.cpp card_path.cpp card_person.cpp crc.cpp geo_hash.cpp \
-		  landmark.cpp line_fit.cpp loc_point.cpp loc_tool.cpp message.cpp message_file.cpp mine.cpp \
-		  net-service.cpp point.cpp select_tool.cpp  special_area.cpp tdoa_sync.cpp visit.cpp \
+    	  card.cpp  cardMgr.cpp card_path.cpp card_person.cpp crc.cpp geo_hash.cpp \
+		  landmark.cpp line_fit.cpp  message.cpp message_file.cpp mine.cpp \
+		  net-service.cpp point.cpp  special_area.cpp tdoa_sync.cpp visit.cpp \
 		  web-client.cpp worker.cpp event.cpp znet.cpp ya_setting.cpp area_business.cpp\
-		  forbid_staff_down_mine.cpp
+		  forbid_staff_down_mine.cpp bulletin_broad_show.cpp
 
 AM_SOURCES=$(SRC_MONKEYCAR) $(SRC_MODULE_SERVICE) $(SRC_MAIN) $(SRC_MAIN_EVENT)
 
@@ -34,7 +34,7 @@ yals_SOURCES=${AM_SOURCES} main.cpp
 yals_CPPFLAGS=${AM_CPPFLAGS}
 yals_LDFLAGS=${AM_LDFLAGS}  -lev -lzlog -lrt -lboost_chrono -lboost_system -lboost_thread -lmysqlclient -lthree_rates
 
-yals_LDADD=db/libyadb.a websocket/libwebsocket.a
+yals_LDADD=db/libyadb.a websocket/libwebsocket.a ${prefix}/lib/libpoint_algorithm.a
 
 async_SOURCES=async.cpp
 async_CPPFLAGS=${AM_CPPFLAGS}

+ 1 - 1
ant.cpp

@@ -452,7 +452,7 @@ void sit_list::read_ant_path(int id)
 
 	card_path::init();
 
-	test_find_path(card_path::inst(),point(4727.00,418.07),point(4724.73,598.32));
+	test_find_path(card_path::inst(),point(4784.50,-25.49),point(4784.50,-28.78));
 	test_find_path(card_path::inst(),point(4727,-8.06),point(2200,-75));
 	test_find_path(card_path::inst(),point(4727,-8.06),point(2600,-100));
 	test_find_path(card_path::inst(),point(2768.50,-75.00),point(2768.50,-161.58));

+ 3 - 0
area.cpp

@@ -545,7 +545,10 @@ std::vector<std::shared_ptr<area>> area_list::get_area(const std::shared_ptr<sit
 	std::vector<std::shared_ptr<area>> ret;
 
 	if(tool_other::is_person(c->type_())&&s&&s->is_up_site())
+	{
+		ret.push_back(s->get_area());//地面分站的区域
 	    return std::move(ret);
+	}
 
 	auto&map = area_list::instance()->m_map;
 

+ 101 - 0
bulletin_broad_show.cpp

@@ -0,0 +1,101 @@
+//
+// Created by songchao.chen on 2019/6/26.
+//
+
+#include <config_file.h>
+#include <boost/algorithm/string/split.hpp>
+#include <boost/algorithm/string.hpp>
+#include <fstream>
+#include <unistd.h>
+#include <ctime>
+#include "bulletin_broad_show.h"
+#include "mine_business.h"
+#include <sys/stat.h>
+#include "log.h"
+
+bulletin_broad_show::bulletin_broad_show()
+{
+
+}
+bulletin_broad_show* bulletin_broad_show::inst()
+{
+    static bulletin_broad_show mb;
+    return &mb;
+}
+
+void bulletin_broad_show::OnInit(config_file * config)
+{
+    if (config == nullptr)
+    {
+        return;
+    }
+    //公告牌显示设置
+    m_bulletin_board_time = config->get("bulletinboard.showtime",1*60);
+    std::string tmpSz = config->get("bulletinboard.show_filepath","../log/bulletin");
+    set_bulletin_board_path(tmpSz);
+    m_bulletin_board_file_name = config->get("bulletinboard.show_filename","bulletin.txt");
+}
+
+void bulletin_broad_show::CreateDirectoryEx(const std::string & sPathName )
+{
+    std::vector<std::string> vecSegTag;
+    boost::split(vecSegTag, sPathName, boost::is_any_of("/"));
+    if (vecSegTag.size() == 1)  //数据发生错误
+    {
+        return;
+    }
+    std::string curPath = "";
+    for  (int i = 0 ; i < (int)vecSegTag.size() ; i++)
+    {
+        curPath += vecSegTag[i];
+        if(vecSegTag[i].length() > 1 && vecSegTag[i][0] != '.' )
+        {
+            int a = access(curPath.c_str(), F_OK);
+            if(a == -1)
+            {
+                mkdir(curPath.c_str(),0755);
+            }
+        }
+        curPath += "/";
+    }
+}
+
+void bulletin_broad_show::run_bulletin_board()
+{
+    time_t t = std::time(nullptr);
+    if (t - m_lastshow_bulletin_time > m_bulletin_board_time )
+    {
+        //把当前文件写到文件中
+        m_lastshow_bulletin_time = t;
+        uint32_t num = mine_business::inst()->get_mine_display_staff_num();
+        std::string path = m_bulletin_board_path;
+        static bool g_bCreatePath = false;
+        if (!g_bCreatePath)
+        {
+            CreateDirectoryEx(path); //创建目录
+            g_bCreatePath = true;
+        }
+        path += "/" + m_bulletin_board_file_name;
+        std::ofstream  f1(path.c_str());//打开文件用于写,若文件不存在就创建它
+        if(!f1.is_open()) {
+            return;//打开文件失败则结束运行
+        }
+        std::string szText = "井下当前总人数: " + std::to_string(num) + "人";
+        f1 << szText << std::endl;
+        f1.close(); //关闭文件
+        log_info("show_bulletin_board : %s" ,szText.c_str());
+    }
+}
+
+void bulletin_broad_show::set_bulletin_board_path(std::string & path)
+{
+    if (path.empty()) return;
+    for(unsigned i = path.length() - 1 ; i > 0 ;i--)
+    {
+        if ( path[i] == '/')
+            path.pop_back();
+        else
+          break;
+    }
+    m_bulletin_board_path = path;
+}

+ 39 - 0
bulletin_broad_show.h

@@ -0,0 +1,39 @@
+//
+// Created by songchao.chen on 2019/6/26.
+// 公告牌显示
+//
+
+#ifndef WORKSPACE_BULLETIN_BROAD_SHOW_H
+#define WORKSPACE_BULLETIN_BROAD_SHOW_H
+
+#include <string>
+
+struct config_file;
+struct bulletin_broad_show
+{
+private:
+    bulletin_broad_show();
+public:
+    bulletin_broad_show(const bulletin_broad_show&)=delete;
+    bulletin_broad_show & operator=(const bulletin_broad_show&)=delete;
+    static bulletin_broad_show *inst();
+
+    void OnInit(config_file * config);
+    //公告牌显示
+    void run_bulletin_board();
+private:
+    void CreateDirectoryEx(const std::string & sPathName );
+    void set_bulletin_board_path(std::string & path);
+
+    //公告牌显示--当前井下人数: 100 人
+    uint32_t m_lastshow_bulletin_time = 0;
+    //公告牌显示-时间间隔
+    uint32_t m_bulletin_board_time = 0 ;
+    // 公告牌显示内容文件的目录
+    std::string m_bulletin_board_path = "";
+    // 公告牌显示内容文件名
+    std::string m_bulletin_board_file_name = "";
+};
+
+
+#endif //WORKSPACE_BULLETIN_BROAD_SHOW_H

+ 7 - 10
card.cpp

@@ -17,6 +17,7 @@
 #include "card.h"
 #include "mine_business.h"
 #include "worker.h"
+#include "ya_setting.h"
 
 extern config_file config;
 int three_rates_flag=0;
@@ -59,13 +60,9 @@ void card_list::init_staffer(const std::string & lszId64)
             person* tmp_ptr= static_cast<person*>(card_ptr.get());
             person* db_person_ptr= static_cast<person*>(db_person.get());
 
-            tmp_ptr->m_cid = db_person_ptr->m_cid;
-            tmp_ptr->m_type = db_person_ptr->m_type;
-            tmp_ptr->m_deptid = db_person_ptr->m_deptid;
+            card_ptr->set_base_data(db_person_ptr->m_cid,db_person_ptr->m_type,db_person_ptr->m_deptid,db_person_ptr->m_level_id);
             //group_id
             //occ_id
-            tmp_ptr->m_level_id = db_person_ptr->m_level_id;
-    //        tmp_ptr->m_display = db_person_ptr->m_display;
             tmp_ptr->m_workLine = db_person_ptr->m_workLine;
             tmp_ptr->m_stafferName = db_person_ptr->m_stafferName;
             tmp_ptr->m_deptName = db_person_ptr->m_deptName;
@@ -104,17 +101,15 @@ void card_list::init_vehicle(const std::string & lszId64)
 	}
 	else
 	{
-		car* db_car= static_cast<car*>(map.begin()->second.get());
         uint64_t id64 = map.begin()->first;
 		auto card_ptr = card_list::instance()->get(id64);
+		car* db_car= static_cast<car*>(map.begin()->second.get());
 		if(card_ptr)
 		{
 			car* tmp_ptr= static_cast<car*>(card_ptr.get());
-			//tmp_ptr->m_display = static_cast<uint16_t>(db_car->m_display);
-			tmp_ptr->m_deptid = db_car->m_deptid;
+            card_ptr->set_base_data(db_car->m_cid,db_car->m_type,db_car->m_deptid,db_car->m_level_id);
 			tmp_ptr->m_vehicle_category_id = db_car->m_vehicle_category_id;
 			tmp_ptr->m_vehicle_type_id = db_car->m_vehicle_type_id;
-			tmp_ptr->m_level_id = db_car->m_level_id;
             if(db_car->m_display!=tmp_ptr->m_display){
                 request(id64,tmp_ptr->m_id,db_car->m_display);
             }
@@ -365,7 +360,7 @@ void card_list::load_his_card_postion_staff()
     }
 }
 
-void card_list::on_message(zloop<task*> *loop,const message_locinfo&loc,bool is_history)
+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);
@@ -379,6 +374,8 @@ void card_list::on_message(zloop<task*> *loop,const message_locinfo&loc,bool is_
 			loc.m_site_id,loc.m_ant_id,loc.m_card_type,loc.m_card_id,loc.m_card_ct,loc.m_tof,dist_tof,
 			(loc.m_card_type==1?loc.m_callinfo:loc.m_rav),
 			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);
 }

+ 1 - 1
card.h

@@ -16,7 +16,7 @@ struct card_list:single_base<card_list,uint64_t,std::shared_ptr<card_location_ba
     ///lszId64=为初始化所有卡, lszId64格式为:0010000001016
     void init_staffer(const std::string & lszId64);
     void init_vehicle(const std::string & lszId64);
-    void on_message(zloop<task*> *loop,const message_locinfo&loc,bool is_history);
+    void on_message(zloop<task*> *loop,message_locinfo&loc,bool is_history);
     void init_card_from_db();
 
     void load_his_card_postion_vehicle();

+ 6 - 1
card_base.cpp

@@ -18,7 +18,8 @@
 #include "common_tool.h"
 #include "ant.h"
 #include "area.h"
-
+#include "loc_point.h"
+#include "loc_message.h"
 extern config_file config;
 card_location_base::card_location_base(const std::string&type,uint32_t id,uint16_t dis,int16_t t,int32_t deptid,int32_t level_id,uint32_t cid)
 	:card(id,dis,t,deptid,level_id,cid)
@@ -277,6 +278,10 @@ bool card_location_base::is_vehicle() const
     return tool_other::is_vehicle(m_type);
 }
 
+void card_location_base::set_base_data(uint32_t cid,uint16_t type,uint32_t deptid,int32_t level_id) {
+    m_cid=cid;m_type=type;m_deptid=deptid;m_level_id=level_id;
+    m_his_location_card->set_cid(cid);
+}
 card_location_base::~card_location_base()
 {
 }

+ 4 - 5
card_base.h

@@ -79,15 +79,13 @@ struct card_location_base:card,std::enable_shared_from_this<card_location_base>
 	time_t m_help_last_time=0;
 	int    m_help_bit=0;
 
-	void inc_upmine_flag(int flag)
-	{
-		m_upmine_flag=flag;
-	}
-    int upmine_flag(){return m_upmine_flag.load();}
 
     card_location_base()=default;
     card_location_base(const std::string&type,uint32_t id,uint16_t dis,int16_t t,int32_t,int32_t,uint32_t );
 
+	void inc_upmine_flag(int flag){m_upmine_flag=flag;}
+    int upmine_flag(){return m_upmine_flag.load();}
+
 	virtual void do_business(const std::shared_ptr<site>&site,const point &pt,double acc)=0;
 	virtual void on_timer()=0;
     virtual std::shared_ptr<mine_tool> get_mine_tool()=0;
@@ -115,6 +113,7 @@ struct card_location_base:card,std::enable_shared_from_this<card_location_base>
 
     bool is_person() const;
     bool is_vehicle() const;
+    void set_base_data(uint32_t cid,uint16_t type,uint32_t deptid,int32_t level_id);
 	virtual ~card_location_base();
 
     static std::shared_ptr<card_location_base> make_person(const std::string&type,uint32_t cardid,uint16_t needdisplay,int16_t t,

+ 2 - 0
card_car.cpp

@@ -11,6 +11,8 @@
 #include "common_tool.h"
 #include "tool_time.h"
 #include "mine_business.h"
+#include "loc_point.h"
+
 car::car(const std::string&type,uint32_t cardid,uint16_t needdisplay,int16_t t,int32_t deptid,
 		int32_t categoryid, int type_id,int32_t level_id,uint32_t cid)
 	:card_location_base(type,cardid,needdisplay,t,deptid,level_id,cid)

+ 1 - 3
card_car.h

@@ -5,8 +5,6 @@
 #include <memory>
 
 #include "point.h"
-#include "loc_point.h"
-
 #include "card_base.h"
 #include "card_area.h"
 
@@ -14,6 +12,7 @@ struct area_hover;
 struct mine_tool;
 struct site;
 struct site_area_hover;
+struct loc_point;
 
 struct car:card_location_base,card_area
 {
@@ -45,7 +44,6 @@ public:
 private:
 	void handle_three_rates(const point &pt);
 	void on_timer();
-	//int statbiz(int32_t special_id);
 	void make_package();
 	loc_point getSmoothPoint();
 };

+ 0 - 181
card_message_handle.cpp

@@ -1,181 +0,0 @@
-#include <vector>
-
-#include <ev++.h>
-
-#include "card_base.h"
-#include "loc_tool.h"
-#include "message.h"
-#include "zloop.h"
-
-#include "card_message_handle.h"
-
-//一张卡一个ct的所有不同天线的信息
-struct one_ct_message_handle
-{
-	static loc_tool_main m_loc_tool;
-	ev::timer m_min_timer,m_max_timer;
-	//loc_message.
-	std::vector<loc_message> m_msg_list;
-	card_location_base*m_card;
-	const algo_config*m_ac=nullptr;
-	int  m_ct;
-	bool m_min_timeout=false;
-	ev::dynamic_loop * m_loop = nullptr;
-	one_ct_message_handle(card_location_base*card)
-	{
-		m_card=card;
-		m_ct=-1;
-	}
-
-	void reset()
-	{
-		m_ct=-1;
-		m_min_timeout=false;
-		m_msg_list.clear();
-	}
-
-	void on_min_timer()
-	{
-		m_min_timer.stop();
-
-		if((int)m_msg_list.size()>=m_ac->best_msg_cnt)
-		{
-			m_max_timer.stop();
-			calc_location();
-			return;
-		}
-		m_min_timeout=true;
-	}
-
-	void on_max_timer()
-	{
-		m_max_timer.stop();
-		calc_location();
-	}
-
-	void set(ev::dynamic_loop * loop)
-	{
-		m_loop = loop;
-
-		m_min_timer.set(*m_loop);
-		m_min_timer.set<one_ct_message_handle,&one_ct_message_handle::on_min_timer>(this);
-		m_max_timer.set(*m_loop);
-		m_max_timer.set<one_ct_message_handle,&one_ct_message_handle::on_max_timer>(this);
-	}
-
-	void on_message(ev::dynamic_loop *loop,const message_locinfo&loc)
-	{
-		if(m_loop == nullptr && loop!=nullptr)
-			set(loop);
-		else if(loop == nullptr)
-			return;
-		if(!m_msg_list.empty()&& m_ct!=loc.m_card_ct)
-		{
-			m_msg_list.clear();
-		}
-		auto sitPtr = sit_list::instance()->get(loc.m_site_id);
-		if(sitPtr==nullptr)
-		{
-			log_warn("分站信息缺失,SitId:%d",loc.m_site_id);
-			return;
-		}
-		auto s=sit_list::instance()->get(loc.m_site_id);
-		if(m_msg_list.empty())
-		{
-			m_ct=loc.m_card_ct;
-			m_ac=&s->config();
-			m_min_timeout=false;
-			//这里构造loc_message 保存数据
-			m_msg_list.push_back(loc_message(s,loc.m_tof,loc.m_time_stamp,loc.m_card_id,
-						loc.m_card_ct,loc.m_card_type,loc.m_ant_id,loc.m_rav,loc.m_acc,
-						loc.m_sync_ct,loc.m_rssi,loc.m_batty_status));
-
-			//启动本CT的最小、最大两个定时器
-			m_min_timer.start(m_ac->min_wait_time);
-			m_max_timer.start(m_ac->max_wait_time);
-			return;
-		}
-
-		m_msg_list.push_back(loc_message(s,loc.m_tof,loc.m_time_stamp,loc.m_card_id,
-					loc.m_card_ct,loc.m_card_type,loc.m_ant_id,loc.m_rav,loc.m_acc,
-					loc.m_sync_ct,loc.m_rssi,loc.m_batty_status));
-
-		if(m_min_timeout && (int)m_msg_list.size()>=m_ac->best_msg_cnt)
-		{
-			calc_location();
-			m_max_timer.stop();
-		}
-	}
-
-	void calc_location()
-	{
-		auto v = m_msg_list;
-		if(v.empty())
-		{
-			return;
-		}
-
-		log_info("calc_location_begin:card_id=%d,ct=%d,m_ct=%d",m_card->m_id,v[0].m_card_ct,m_ct);
-
-		std::vector<point> rc=std::move(m_loc_tool.calc_location(v));
-		log_info("calc_location:%d size:%d",m_card->m_id,rc.size());
-#if 0
-        for(const auto &_p:rc)
-		    log_info("calc_location:%d (%.2f,%.2f)",m_card->m_id,_p.x,_p.y);
-#endif
-
-		if(!rc.empty()) m_card->on_location(std::move(rc),v);
-
-		reset();
-		log_info("calc_location_end:card_id=%d",m_card->m_id);
-	}
-};
-
-loc_tool_main one_ct_message_handle::m_loc_tool;
-
-card_message_handle::card_message_handle(card_location_base*card)
-{
-	m_card=card;
-
-	for(size_t i=0;i<m_ct_list.size();i++)
-	{
-		m_ct_list[i]=new one_ct_message_handle(card);
-	}
-}
-
-card_message_handle::~card_message_handle()
-{
-	for(auto&it:m_ct_list)
-	{
-		delete it;
-	}
-}
-
-void card_message_handle::on_message(zloop<task*> * loop,const message_locinfo&loc,bool is_history)
-{
-	if(is_history)
-	{
-		log_warn("%s","当前代码没有处理历史消息记录。");
-		return;
-	}
-	int c_status = STATUS_POWER_NOMARL;
-	if(loc.m_batty_status == 2)
-	{
-		c_status ^= STATUS_POWER_NOMARL;
-		c_status  = STATUS_POWER_LOWER_SERIOUS;
-	}
-
-	if(loc.m_callinfo & 0x80)
-	{
-		c_status  |= STATUS_HELP;
-	}
-
-	if((loc.m_callinfo & 0x01) || (loc.m_callinfo & 0x02))
-	{
-		c_status  |= STATUS_CALL;
-	}
-
-	m_card->do_status(c_status);
-	m_ct_list[loc.m_card_ct&(m_ct_list.size()-1)]->on_message(loop,loc);
-}
-

+ 0 - 33
card_message_handle.h

@@ -1,33 +0,0 @@
-
-#ifndef _card_message_handle_h_
-#define _card_message_handle_h_
-
-//一张卡一个ct的所有不同天线的信息
-
-#include <thread>
-
-struct card_location_base;
-struct one_ct_message_handle;
-struct message_locinfo;
-struct task;
-template<typename NT> struct zloop;
-
-struct card_message_handle
-{
-	card_location_base*m_card;
-	std::array<one_ct_message_handle*,16> m_ct_list;
-
-	card_message_handle(card_location_base*card);
-	~card_message_handle();
-
-#ifndef _RELEASE_
-	bool m_first_call=true;
-	std::thread::id m_first_call_thread;
-#endif 
-	
-	void on_message(zloop<task*> * loop,const message_locinfo&loc,bool is_history);
-};
-
-#endif
-
-

+ 4 - 4
card_person.cpp

@@ -13,8 +13,8 @@
 #include "websocket/ws_common.h"
 #include "event.h"
 #include "mine_business.h"
-#include"common_tool.h"
-#include"db/db_tool.h"
+#include "common_tool.h"
+#include "db/db_tool.h"
 #include "forbid_staff_down_mine.h"
 #include <config_file.h>
 #include "cardMgr.h"
@@ -240,8 +240,8 @@ point person::getSmoothPoint(uint64_t& t)
 }
 void person::get_card(bool f)
 {
-    if(!m_mine_tool->m_is_attendance)
-		return;
+	if (!m_mine_tool->m_is_attendance)
+		return ;
 	mine_business::inst()->fetch_add(m_display);
 }
 

+ 2 - 2
common.h

@@ -66,13 +66,13 @@ enum AREA_TYPE
 {
 	AREA_TYPE_UPMINE =0,
 	AREA_TYPE_NORMAL=1,
-	AREA_TYPE_IMPORT=2,
 	AREA_TYPE_FORBIDDEN = 3,	// 禁止区域
 	AREA_TYPE_DOWNMINE=4,
 	AREA_TYPE_MONKEY=5,
     AREA_TYPE_ATTENDANCE=6,
 	AREA_TYPE_NO_COVER = 1000,	// 非覆盖区域,车辆信号消失后,定位到附近非覆盖区域内
-	AREA_TYPE_SPECIAL = 1001	// 特殊区域,只给你前端用来标识是否显示图标,胶轮车硐室
+	AREA_TYPE_SPECIAL = 1001,	// 特殊区域,只给你前端用来标识是否显示图标,胶轮车硐室
+    AREA_TYPE_WORKING=2000
 };
 
 enum EVENT_STATUS

+ 2 - 6
db/db_card.cpp

@@ -198,12 +198,8 @@ namespace db_card
             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,staffer_name,dept_name,worktype_id);
             uint64_t cardid = tool_other::type_id_to_u64(card_type_id,vsid);
-            if ("" != lszId64)
-            {
-				log_info("Check Card.cardId:%llu,id:%d dept_id:%d,need_display:%d,card:%s:work_line:%d,staff_id:%d,type:%d,staffer_name:%s,dept_name:%s",
-						cardid, vsid, dept_id, need_display, card_id.c_str(), work_line, staff_id, card_type_id,
-						staffer_name.c_str(), dept_name.c_str());
-			}
+			log_info("Init_card.cardId:%llu,id:%d dept_id:%d,need_display:%d,card:%s:work_line:%d,staff_id:%d,type:%d,staffer_name:%s,dept_name:%s",
+					cardid, vsid, dept_id, need_display, card_id.c_str(), work_line, staff_id, card_type_id,staffer_name.c_str(), dept_name.c_str());
             map.insert({cardid,clb});
 		}
 		return map;

+ 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 - 1
forbid_staff_down_mine.cpp

@@ -16,7 +16,7 @@ void forbid_staff_down_mine::init_forbid_staff(int id /* = -1*/,int etype)
     int nCount = DBRes.GetRecordCount( Error );
     if (nCount < 1)
     {
-        log_error("增加或修改失败,数据库中找不到: sql=%s", sql.c_str());
+        log_info("增加或修改失败,数据库中没有记录: sql=%s", sql.c_str());
         return ;
     }
     while ( DBRes.GetNextRecod(Error) )

+ 2 - 2
his_location.cpp

@@ -10,8 +10,8 @@ uint32_t  location_card::m_difftime=0;
 int  location_card::m_distance=-1;
 
 location_card::location_card(uint32_t id,uint64_t type,uint32_t objid)
-:m_cardid(id)
-,m_type(type)
+    :m_cardid(id)
+    ,m_type(type)
     ,m_objid(objid)
 {
     init();

+ 1 - 0
his_location.h

@@ -23,6 +23,7 @@ struct location_card
     bool 		m_isInsert ;	//是否
     static uint32_t  m_difftime;//进入盲区得时长限制 时长 
     static int  m_distance;//进入盲区后,第一个点与之前得距离  像素距离
+    void set_cid(uint32_t cid){m_objid=cid;}
 	struct mini_data
 	{
 		mini_data(const point &p,uint64_t t)

+ 0 - 119
loc_point.cpp

@@ -1,119 +0,0 @@
-
-#include <memory.h>
-#include "loc_point.h"
-#include "ant.h"
-#include "log.h"
-#include "loc_message.h"
-
-loc_point::loc_point()
-    :m_time(0)
-    ,m_ct(-1)
-	,m_cid(-1)
-    ,m_type(-1)
-    ,m_sid(-1)
-    ,m_acc(0)
-    ,m_rav(0)
-    ,m_cred_level(0)
-    ,m_dist(0)
-    ,m_speed(0)
-    ,m_stat(0)
-    ,m_useless(false)
-    ,m_dist1(0)
-    ,m_dist2(0)
-    ,m_smooth_x(0)
-    ,m_smooth_y(0)
-{
-    memset(&m_tof,0,sizeof(m_tof));
-    memset(&m_rsp,0,sizeof(m_rsp));
-}
-
-loc_point& loc_point::reset()
-{
-    memset(this,0,sizeof(*this));
-    return *this;
-}
-
-inline const char* now(char*date_str,uint64_t time)
-{
-    time_t ntime=time/1000;
-    struct tm buff;
-    const struct tm*t=localtime_r(&ntime, &buff);
-
-    sprintf(date_str,"%d-%02d-%02d %02d:%02d:%02d.%03d" ,
-            t->tm_year+1900,t->tm_mon+1,t->tm_mday,
-            t->tm_hour,t->tm_min,t->tm_sec,(int)(time%1000));
-
-    return date_str;
-}
-
-void loc_point::debug_out(const char *str)const
-{
-    char time_buff[128];
-#if 1
-    logn_info(3,"t=%s,sit=%d,card=%d,ct=%d,cred=%d,type=%d,"
-            "tof1=%d,tof2=%d,pt=(%.2lf,"
-            "%.2lf),rsp=%d,acc=%.2f,dist=%.2lf,dist1=%.2lf,dist2=%.2lf,rav=%.2f,speed:%.4lf\n",
-            now(time_buff,m_time), m_sid, 
-			m_cid,
-			m_ct, m_cred_level,m_type+0,
-            m_tof[0], m_tof[1],  x,
-            y ,(m_rsp[0]+m_rsp[1])/2,m_acc,
-            m_dist1,m_dist,m_dist2, m_rav,m_speed
-          );
-#else
-    printf("[%s]t=%s,sit=%d,ct=%d,cred=%d,"
-            "tof1=%d,tof2=%d,pt=(%.2lf,"
-            "%.2lf),rsp=,acc=%.2f,dist=%.2lf,dist1=%.2lf,dist2=%.2lf,rav=%.2f,speed=%.2f\n",
-            str,now(time_buff,m_time), m_sid, m_ct, m_cred_level,
-            m_tof[0], m_tof[1],  m_smooth_x,
-            m_smooth_y ,m_acc,
-            m_dist1,m_dist,m_dist2, m_rav, m_speed
-          );
-#endif
-}
-int loc_point::inc_cl(int cred_level)
-{
-    return m_cred_level+=cred_level;
-}
-
-int loc_point::set_cl(int cred_level)
-{
-    return m_cred_level=cred_level;
-}
-
-int loc_point::cl()const
-{
-    return m_cred_level;
-}
-
-void loc_point::set_source(const loc_message&li,const loc_message&li2)
-{
-    m_sid = li.m_sit->m_id;
-	m_cid = li.m_card_id;
-    m_type=li.m_card_type;
-    m_time=std::min(li.m_loc_time,li2.m_loc_time);
-    m_ct=li.m_card_ct;
-    m_acc=li.m_acc *10;// 1270.;
-    m_rav=li.m_rav;
-    m_tof[li.m_ant_id]=li.m_num_ticks;
-    m_tof[li2.m_ant_id]=li2.m_num_ticks;
-    m_rsp[li.m_ant_id]=li.m_rssi;
-    m_rsp[li2.m_ant_id]=li2.m_rssi;
-    m_step=0;
-}
-
-void loc_point::set_source(const loc_message&li)
-{
-    m_sid = li.m_sit->m_id;
-	m_cid = li.m_card_id;
-    m_type=li.m_card_type;
-    m_time=li.m_loc_time;
-    m_ct=li.m_card_ct;
-    m_acc=li.m_acc *10;// 1270.;
-    m_rav=li.m_rav;
-    m_tof[li.m_ant_id]=li.m_num_ticks;
-    m_tof[li.m_ant_id?0:1]=0;
-    m_rsp[li.m_ant_id]=li.m_rssi;
-    m_rsp[li.m_ant_id?0:1]=0;
-    m_step=0;
-}

+ 0 - 96
loc_point.h

@@ -1,96 +0,0 @@
-#ifndef _LOC_POINT_HPP_
-#define _LOC_POINT_HPP_
-
-#include "point.h"
-#include "line_fit.h"
-
-struct loc_message;
-
-struct loc_point:point
-{
-	int64_t m_time;
-	int     m_ct;
-	uint32_t m_cid;
-    uint8_t  m_type;
-    int     m_sid;
-	float	m_acc;
-	float	m_rav;
-	int	    m_cred_level;
-	int		m_tof[2];
-    int16_t	m_rsp[2];
-	int	    m_step;
-	double  m_area;
-	point   m_sol[2];
-	double  m_dist;
-	double 	m_speed;
-	int 	m_stat;
-    bool    m_useless;
-
-	double m_dist1;	//smooth phase 1
-	double m_dist2;	//smooth phase 3
-	double m_smooth_x;
-	double m_smooth_y;
-
-	fit_result m_k;
-
-	fit_result&set_k(const fit_result&k)
-	{
-		return m_k=k;
-	}
-
-	loc_point();
-	const point& operator[](int i)const
-	{
-		return m_sol[i];
-	}
-
-	point& operator[](int i)
-	{
-		return m_sol[i];
-	}
-
-	double loc_dist(const point&pt)const
-	{
-		return m_sol[0].dist_direct(pt);
-	}
-
-	double loc_dist(const loc_point&lp)const
-	{
-		return m_sol[0].dist_direct(lp.m_sol[0]);
-	}
-
-	bool is_same_site(const loc_point&o)const
-	{
-		return m_sid==o.m_sid;
-	}
-
-	double time_off(const loc_point&o)const
-	{
-		return (o.m_time-m_time)/1000.;
-	}
-
-	double ct_off(const loc_point&o)const
-	{
-		return o.m_ct-m_ct;
-	}
-
-	void  debug_out(const char * str="")const ;
-
-	void set_sol(int i,const point&p) ;
-	bool b_50m()const
-	{
-		static int tof_50m=50/(15.65*2.996*1e-4);
-		return m_tof[0]==0?m_tof[1]>tof_50m:m_tof[0]>tof_50m;
-	}
-
-	loc_point& reset() ;
-
-	int inc_cl(int cred_level) ;
-	int set_cl(int cred_level) ;
-	int cl()const ;
-
-	void set_source(const loc_message&li,const loc_message&li2) ;
-	void set_source(const loc_message&li) ;
-};
-#endif
-

+ 0 - 307
loc_tool.cpp

@@ -1,307 +0,0 @@
-
-#include <vector>
-
-#include <log.h>
-#include <ant.h>
-#include <loc_tool.h>
-#include <message.h>
-
-std::vector<point> loc_tool_tdoa_3_base::calc_location(std::vector<loc_message>&locm)
-{
-	return std::vector<point>();
-}
-int loc_tool_tdoa_3_base::index() 
-{
-	return 5;
-}
-
-std::vector<point> loc_tool_tdoa_2_base::calc_location(std::vector<loc_message>&locm)
-{
-	return std::vector<point>();
-}
-int loc_tool_tdoa_2_base::index() 
-{
-	return 3;
-}
-
-std::vector<point> loc_tool_tdoa_1_base::calc_location(std::vector<loc_message>&locm)
-{
-	return std::vector<point>();
-}
-int loc_tool_tdoa_1_base::index() 
-{
-	return 1;
-}
-
-std::vector<point> loc_tool_tof_3_base::calc_location(std::vector<loc_message>&locm)
-{
-	return std::vector<point>();
-}
-int loc_tool_tof_3_base::index() 
-{
-	return 4;
-}
-
-std::vector<point> loc_tool_tof_2_base::calc_location(std::vector<loc_message>&locm)
-{
-	return std::vector<point>();
-}
-int loc_tool_tof_2_base::index() 
-{
-	return 2;
-}
-
-
-std::vector<point> loc_tool_tof_1_base::calc_location(std::vector<loc_message>&locm)
-{
-    int32_t last_ct = -1;
-    std::vector<point> vec;
-    std::vector<loc_message> lm;
-    for(auto rit = locm.rbegin();rit != locm.rend();rit++)
-    {
-//        site s = rit->m_sit;
-
-        if(rit->m_sit->is_path_empty() || rit->m_num_ticks == 0)
-          continue;
-        if(last_ct == -1)
-          last_ct = rit->m_card_ct;
-        else if(last_ct != rit->m_card_ct)
-          continue;
-		double dist_tof=rit->m_num_ticks*15.65*2.996*1e-4/rit->m_sit->m_scale;
-        auto v = rit->m_sit->solving(rit->m_ant_id,dist_tof);
-        lm.insert(lm.begin(),*rit);
-        vec.insert(std::end(vec),std::begin(v),std::end(v));
-    }
-    locm.swap(lm);
-	return std::move(vec);
-}
-int loc_tool_tof_1_base::index() 
-{
-	return 0;
-}
-
-loc_tool_main::loc_tool_main()
-{
-	set_tool(new loc_tool_tof_1_base());
-	set_tool(new loc_tool_tof_2_base());
-	set_tool(new loc_tool_tof_3_base());
-	set_tool(new loc_tool_tdoa_1_base());
-	set_tool(new loc_tool_tdoa_2_base());
-	set_tool(new loc_tool_tdoa_3_base());
-}
-
-loc_tool_main::~loc_tool_main()
-{
-	for(auto&tool:g_tool)
-		delete tool;
-}
-
-void loc_tool_main::set_tool(loc_tool*tool)
-{
-	int index=tool->index();
-	if(g_tool[index])
-	{
-		delete g_tool[index];
-		g_tool[index]=0;
-	}
-	g_tool[index]=tool;
-}
-
-std::vector<point> loc_tool_main::calc_location(std::vector<loc_message>&locm)
-{
-	if(locm.empty()) return {};
-	int tool_index=locm[0].tool_index(),i=1,len=locm.size();
-	for(;i<len;i++)
-	{
-		if(tool_index!=locm[i].tool_index())
-			break;
-	}
-
-	if(i==len)
-	{
-		return std::move(g_tool[tool_index]->calc_location(locm));
-	}
-
-	//包含至少两种定位方式的基站,目前只考虑两种
-	std::vector<loc_message> locm1,locm2;
-	locm1.assign(locm.begin(),locm.begin()+i);
-
-	for(;i<len;i++)
-	{
-		if(tool_index!=locm[i].tool_index())
-			locm2.push_back(locm[i]);
-		else
-			locm1.push_back(locm[i]);
-	}
-    bool flag = false;
-    if(locm2[0].tool_index() > tool_index)
-        flag = true;
-    std::vector<point> rc;
-    if(flag && (locm2[0].m_sit->config().best_msg_cnt<=(int)locm2.size()))
-    {
-		int index=locm2[0].tool_index();
-		rc = std::move(g_tool[index]->calc_location(locm2));
-        locm.swap(locm2);
-    }
-    else if(locm1[0].m_sit->config().best_msg_cnt<=(int)locm1.size())
-	{
-	    rc = std::move(g_tool[tool_index]->calc_location(locm1));
-        locm.swap(locm1);
-	}
-    return std::move(rc);
-}
-
-loc_tool* loc_tool_main::g_tool[6]={0,0,0,0,0,0};
-
-/*
-std::vector<point> loc_tool_tdoa_3_base::calc_location(const std::vector<loc_message>&locm)
-{
-	return std::vector<point>();
-}
-int loc_tool_tdoa_3_base::index() 
-{
-	return 5;
-}
-
-std::vector<point> loc_tool_tdoa_2_base::calc_location(const std::vector<loc_message>&locm)
-{
-	return std::vector<point>();
-}
-int loc_tool_tdoa_2_base::index() 
-{
-	return 3;
-}
-
-std::vector<point> loc_tool_tdoa_1_base::calc_location(const std::vector<loc_message>&locm)
-{
-	return std::vector<point>();
-}
-int loc_tool_tdoa_1_base::index() 
-{
-	return 1;
-}
-
-std::vector<point> loc_tool_tof_3_base::calc_location(const std::vector<loc_message>&locm)
-{
-	return std::vector<point>();
-}
-int loc_tool_tof_3_base::index() 
-{
-	return 4;
-}
-
-std::vector<point> loc_tool_tof_2_base::calc_location(const std::vector<loc_message>&locm)
-{
-	return std::vector<point>();
-}
-int loc_tool_tof_2_base::index() 
-{
-	return 2;
-}
-
-void loc_tool_tof_1_base::on_loc_message(ant*,const message_locinfo&m)
-{
-	log_info("tof1-message:site=%d,ant=%d,card=%d,ct=%d,tof=%lld,rav=%02X,acc=%02X,rssi=%d",
-			m.m_site_id,m.m_ant_id,m.m_card_id,m.m_card_ct,m.m_tof,m.m_rav,m.m_acc,m.m_rssi);
-}
-
-std::vector<point> loc_tool_tof_1_base::calc_location(const std::vector<loc_message>&locm)
-{
-	return std::vector<point>();
-}
-int loc_tool_tof_1_base::index() 
-{
-	return 0;
-}
-
-loc_tool_main::loc_tool_main()
-{
-	set_tool(new loc_tool_tof_1_base());
-	set_tool(new loc_tool_tof_2_base());
-	set_tool(new loc_tool_tof_3_base());
-	set_tool(new loc_tool_tdoa_1_base());
-	set_tool(new loc_tool_tdoa_2_base());
-	set_tool(new loc_tool_tdoa_3_base());
-}
-
-loc_tool_main::~loc_tool_main()
-{
-	for(auto&tool:g_tool)
-		delete tool;
-}
-
-loc_tool* loc_tool_main::get_tool(int index)
-{
-	if((uint32_t)index >= sizeof(g_tool)/sizeof(loc_tool*))
-		return nullptr;
-	
-	return g_tool[index];
-}
-
-void loc_tool_main::set_tool(loc_tool*tool)
-{
-	int index=tool->index();
-	if(g_tool[index])
-	{
-		delete g_tool[index];
-		g_tool[index]=0;
-	}
-	g_tool[index]=tool;
-}
-
-void loc_tool_main::on_loc_message(ant*a, const message_locinfo&m)
-{
-	loc_tool*lt=get_tool(a->index());
-	if(lt==nullptr)
-	{
-		log_warn("无法找到对应的loctool-message:site=%d,ant=%d,card=%d,ct=%d,tof=%lld,rav=%02X,acc=%02X,rssi=%d",
-				m.m_site_id,m.m_ant_id,m.m_card_id,m.m_card_ct,m.m_tof,m.m_rav,m.m_acc,m.m_rssi);
-		return;
-	}
-
-	lt->on_loc_message(a, m);
-}
-
-std::vector<point> loc_tool_main::calc_location(const std::vector<loc_message>&locm)
-{
-	if(locm.empty()) return {};
-	int tool_index=locm[0].tool_index(),i=1,len=locm.size();
-	for(;i<len;i++)
-	{
-		if(tool_index!=locm[i].tool_index())
-			break;
-	}
-
-	if(i==len)
-	{
-		return std::move(g_tool[tool_index]->calc_location(locm));
-	}
-
-	//包含至少两种定位方式的基站,目前只考虑两种
-	std::vector<loc_message> locm1,locm2;
-	locm1.assign(locm.begin(),locm.begin()+i);
-
-	for(;i<len;i++)
-	{
-		if(tool_index!=locm[i].tool_index())
-			locm2.push_back(locm[i]);
-		else
-			locm1.push_back(locm[i]);
-	}
-
-	std::vector<point> rc;
-	if(locm1[0].m_ant->config().best_msg_cnt<=(int)locm1.size())
-	{
-		rc=std::move(g_tool[tool_index]->calc_location(locm1));
-	}
-
-	if(locm2[0].m_ant->config().best_msg_cnt<=(int)locm2.size())
-	{
-		int index=locm2[0].tool_index();
-		auto v=std::move(g_tool[index]->calc_location(locm2));
-		rc.insert(rc.begin(),v.begin(),v.end());
-	}
-
-	return std::move(rc);
-}
-*/

+ 0 - 126
loc_tool.h

@@ -1,126 +0,0 @@
-#ifndef __loc_tool_hpp__
-#define __loc_tool_hpp__
-#include "loc_message.h"
-struct ant;
-struct message_locinfo;
-/*
-struct loc_tool
-{
-	//将基础信息送入工具类,目前考虑各种算法输出不同的实时日志
-	virtual void on_loc_message(ant*a, const message_locinfo&m){};
-	virtual std::vector<point> calc_location(const std::vector<loc_message>&locm)=0;
-	virtual int index()
-	{
-		return -1;
-	}
-	virtual ~loc_tool(){}
-};
-
-struct loc_tool_tdoa_3_base:loc_tool
-{
-	virtual std::vector<point> calc_location(const std::vector<loc_message>&locm);
-	virtual int index();
-};
-
-struct loc_tool_tdoa_2_base:loc_tool
-{
-	virtual std::vector<point> calc_location(const std::vector<loc_message>&locm);
-	virtual int index();
-};
-
-struct loc_tool_tdoa_1_base:loc_tool
-{
-	virtual std::vector<point> calc_location(const std::vector<loc_message>&locm);
-	virtual int index();
-};
-
-struct loc_tool_tof_3_base:loc_tool
-{
-	virtual std::vector<point> calc_location(const std::vector<loc_message>&locm);
-	virtual int index();
-};
-
-struct loc_tool_tof_2_base:loc_tool
-{
-	virtual std::vector<point> calc_location(const std::vector<loc_message>&locm);
-	virtual int index();
-};
-
-struct loc_tool_tof_1_base:loc_tool
-{
-	virtual std::vector<point> calc_location(const std::vector<loc_message>&locm);
-	virtual void on_loc_message(ant*a, const message_locinfo&m);
-	virtual int index();
-};
-
-struct loc_tool_main:loc_tool
-{
-	loc_tool* g_tool[6];
-
-	loc_tool_main();
-	~loc_tool_main();
-	void set_tool(loc_tool*tool);
-	loc_tool* get_tool(int index);
-
-	void on_loc_message(ant*a, const message_locinfo&m);
-	std::vector<point> calc_location(const std::vector<loc_message>&locm);
-};
-*/
-struct loc_tool
-{
-	virtual std::vector<point> calc_location(std::vector<loc_message>&locm)=0;
-	virtual int index()
-	{
-		return -1;
-	}
-	virtual ~loc_tool(){}
-};
-
-struct loc_tool_tdoa_3_base:loc_tool
-{
-	virtual std::vector<point> calc_location(std::vector<loc_message>&locm);
-	virtual int index();
-};
-
-struct loc_tool_tdoa_2_base:loc_tool
-{
-	virtual std::vector<point> calc_location(std::vector<loc_message>&locm);
-	virtual int index();
-};
-
-struct loc_tool_tdoa_1_base:loc_tool
-{
-	virtual std::vector<point> calc_location(std::vector<loc_message>&locm);
-	virtual int index();
-};
-
-struct loc_tool_tof_3_base:loc_tool
-{
-	virtual std::vector<point> calc_location(std::vector<loc_message>&locm);
-	virtual int index();
-};
-
-struct loc_tool_tof_2_base:loc_tool
-{
-	virtual std::vector<point> calc_location(std::vector<loc_message>&locm);
-	virtual int index();
-};
-
-struct loc_tool_tof_1_base:loc_tool
-{
-	virtual std::vector<point> calc_location(std::vector<loc_message>&locm);
-	virtual int index();
-};
-
-struct loc_tool_main:loc_tool
-{
-	static loc_tool* g_tool[6];
-	loc_tool_main();
-	~loc_tool_main();
-	static void set_tool(loc_tool*tool);
-	std::vector<point> calc_location( std::vector<loc_message>&locm);
-};
-
-
-#endif
-

+ 5 - 1
main.cpp

@@ -18,10 +18,10 @@
 #include <config_file.h>
 #include "three_rates.h"
 #include "mine_business.h"
-#include "main_test.h"
 #include "ya_setting.h"
 #include "websocket/web_connect.h"
 #include "forbid_staff_down_mine.h"
+#include "bulletin_broad_show.h"
 
 config_file config;
 void handlereader(uint32_t readerid,bool duration,uint32_t t)
@@ -72,6 +72,8 @@ struct Init_Setting
             log_warn("连接webServer[%s] 失败!",url.c_str());
         }
 		CYaSetting::Init_sys_setting();
+        bulletin_broad_show::inst()->OnInit(&config);
+
         sit_list::instance()->load_from_db();
         card_list::instance()->init_card_from_db();
         area_list::instance()->init_from_db();
@@ -182,6 +184,7 @@ int main(int argc ,char * argv[])
     log_init("../etc/log.ini");
     if(config.open("../etc/config.ini"))
         return -1;
+
     Init_Setting is;
     is.init();
 
@@ -194,6 +197,7 @@ int main(int argc ,char * argv[])
 
     log_info("service_handle::instance(&mh)->run(%d)",port);
     std_info("service_handle::instance(&mh)->run(%d)",port);
+
     service_handle::instance(&mh)->run(port);
     
     sDBConnPool.Close();

+ 0 - 86
main_test.h

@@ -1,86 +0,0 @@
-#pragma once 
-
-#include "db_api/CDBSingletonDefine.h"
-#include"module_service/module_mgr.h"
-
-void test_find_path(const point&p1,const point&p2)
-{
-	printf("\nfind-path:  from=(%.3lf,%.3lf),to=(%.3lf,%.3lf)\n",p1.x,p1.y,p2.x,p2.y);
-	std::vector<point> rc=card_path::inst().find_path(p1,p2);
-	for(uint32_t i=0;i<rc.size();i++)
-		printf("x=%.3lf,y=%.3lf\n",rc[i].x,rc[i].y);
-}
-
-struct test_Sa{
-    static void test_savedata2db(void * p)
-    {
-        while(true)
-        {
-            std::string sql = "CALL add_att_staff(0010000002323, 2323, '2018-12-14 14:00:14', '2018-12-14 14:00:14', 0, 0, 0.000);";
-            sDBConnPool.PushAsync(sql.c_str());
-            //boost::this_thread::sleep( boost::posix_time::microseconds( 10000 ) );
-            usleep(1000*1000);
-        }
-    }
-
-    static void test_query(void *p)
-    {
-        std::string sql = "SELECT ve.vehicle_id, ve.card_id, c.card_type_id, \
-                            ve.dept_id, ve.group_id, v.vehicle_type_id, vt.vehicle_level_id, \
-                            vt.is_railroad AS vt_is_railroad,ve.need_display ,ve.power_alarm,\
-                            vt.vehicle_category_id,v.bigger_car_flag,vc.over_speed \
-                            FROM dat_vehicle_extend ve \
-                            LEFT JOIN dat_vehicle v ON ve.vehicle_id = v.vehicle_id \
-                            LEFT JOIN dat_card c ON ve.card_id = c.card_id \
-                            LEFT JOIN dat_dept d ON ve.dept_id = d.dept_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.state_id = 0";
-
-        std::string Error;
-        YADB::CDBResultSet DBRes;
-        while(true)
-        {
-            if (!sDBConnPool.Query(sql.c_str(),DBRes,Error))
-            {
-                printf(" Error = %s \n",Error.c_str());
-            }
-            usleep(10);
-        }
-    }
-
-    static void Test_JsonDataSend(void * p)
-    {
-        std::string text = "";
-        FILE * pfile = fopen("message_error.json","r");
-        if ( NULL != pfile)
-        {
-            
-            char p[10240] = {0};
-            while(!feof(pfile))
-            {
-                memset(p,0,sizeof(p));
-                fread(p,1,sizeof(p) - 1,pfile);
-                text += std::string(p);
-            }
-            fclose(pfile); 
-        }
-        int count = 0;
-        while(true)
-        {
-            swsClientMgr.send(JSON_CMD_VALUE_PUSH,text);
-            usleep(1000*1000*2);
-            printf("WSClient Send DataLen=%d count=%d \n",(int)text.length(),count++);
-        }
-    }
-};
-
-
-void test_createthread()
-{
-    for (int i = 1 ; i < 1 ; i++)
-    {
-        new  std::thread( std::bind( &test_Sa::Test_JsonDataSend, &i ) );
-    }
-}

+ 1 - 1
message.h

@@ -37,7 +37,7 @@ struct message_locinfo:task
 
 	void zero_this();
     void load(zistream&is,bool tdoa);
-
+    void set_rav(uint8_t rav){m_rav=rav;}
     static std::vector<task*> load_753C(zistream&is);
 	static message_locinfo*clone();
 

+ 18 - 7
mine_business.cpp

@@ -137,21 +137,26 @@ struct card_sensor_mgr
 struct staffer_num_business
 {
 	void record_staffer_num();
-	void fetch_add(bool f)
+
+	void fetch_add(bool bDisplay)
     {
-        if(f)
+        if(bDisplay) 
             m_staff_num++;
 		m_staff_num_real++;
-        
     }
 	staffer_num_business()
 	{
         reset();
 		m_record_staffer_timeval = 0;
 	}
-	private:
+    uint32_t get_staff_num() const { return m_staff_num.load();}
+private:
 	void reset(){m_staff_num=0;m_staff_num_real=0;}
-	std::atomic<uint32_t> m_staff_num,m_staff_num_real;
+	// 井下考勤并且要显示的人数
+	std::atomic<uint32_t> m_staff_num{0};
+	// 井下总人数
+    std::atomic<uint32_t> m_staff_num_real{0};
+    // 通知web最后时间
 	std::time_t m_record_staffer_timeval;
 };
 
@@ -259,10 +264,11 @@ void mine_business::run_business()
     handle_reverse_alarm();
     handle_rear_end();
 }
-void mine_business::fetch_add(bool f)
+void mine_business::fetch_add(bool bDisplay)
 {
-    m_staffer_num_ptr->fetch_add(f);
+    m_staffer_num_ptr->fetch_add(bDisplay);
 }
+
 void mine_business::record_staffer_num()
 {
     m_staffer_num_ptr->record_staffer_num();
@@ -297,6 +303,11 @@ void mine_business::clear_vehicle()
 {
     m_rear_ended_ptr->clear();
 }
+
+uint32_t mine_business::get_mine_display_staff_num()
+{
+    return m_staffer_num_ptr->get_staff_num();
+}
 ///////staffer_num_business
 /**********************************
 //每两分钟把人员数量入库。

+ 5 - 3
mine_business.h

@@ -14,15 +14,17 @@ struct mine_business
 	mine_business & operator=(const mine_business&)=delete;
 	static mine_business *inst();
 	void run_business();
-//人员数量曲线功
+	//人员数量曲线功
 	void fetch_add(bool);
-//天线反向功能
+	//天线反向功能
 	void load();
 	void make_reverse_condition(uint64_t type,uint32_t id,int32_t antid,uint32_t ct,uint64_t tof,uint32_t sid);
-//车辆防追尾告警
+	//车辆防追尾告警
 	void put(const std::shared_ptr<card_location_base>&);
 	void make_arg(uint64_t cid,const point &p,uint64_t t);
 	void clear_vehicle();
+
+	uint32_t get_mine_display_staff_num();
 private:
 	mine_business();
 	void handle_reverse_alarm();

+ 1 - 0
module_service/area_business_post_area.cpp

@@ -14,6 +14,7 @@ void area_business_post_area::on_load_his(const std::shared_ptr<area_hover>&a,co
 void area_business_post_area::on_enter(const std::shared_ptr<area_hover>&a,
 						const std::shared_ptr<card_location_base>&c,std::shared_ptr<business_data>&ptr)
 {
+    log_info("pos_area:cardid:%d,area_id:%d",c->m_id,a->id());
 	c->set_area_info(a->mapid(),a->scale(),a->id(),a->m_enter_time,0);
 }
 

+ 6 - 6
module_service/module_call.cpp

@@ -45,7 +45,7 @@ void module_call::to_node_element(rapidjson::Value& out_elemet,
     tool_json::push_back(out_elemet, card_ptr->to_id64_str(), allocator);
 
     out_elemet.PushBack(card_ptr->stationid, allocator);
-    out_elemet.PushBack(card_ptr->call_time_interval, allocator);
+    out_elemet.PushBack(tool_time::to_ms(card_ptr->call_time), allocator);
 
     out_elemet.PushBack(card_ptr->call_type_id, allocator);
     out_elemet.PushBack(card_ptr->call_state, allocator);
@@ -91,8 +91,8 @@ void module_call::send_to_sites(call_site_map& site_map)
         std::vector<char> arr;
 
         int16_t cmd = 0x77ab;
-        arr.push_back(cmd>>8);
-        arr.push_back(cmd);
+        arr.push_back(cmd>>8 & 0xff);
+        arr.push_back(cmd & 0xff);
         //分站地址 4字节,支持大小分站呼叫协议;added by zhuyf 2018/06/04
         //大小分站的全员呼叫,分站id要求4字节全为FF
         uint32_t anchor_id = (iter_site->second->is_call_all()? 0xffffffff : static_cast<uint32_t>(iter_site->first));
@@ -131,10 +131,10 @@ void module_call::send_to_sites(call_site_map& site_map)
         int16_t len=arr.size()+2;
         int16_t crc=do_crc_1(arr,0);
 
-        auto it= arr.begin();arr.insert(it,len);
-        it= arr.begin();arr.insert(it,len>>8);
+        auto it= arr.begin();arr.insert(it,len&0xff);
+        it= arr.begin();arr.insert(it,len>>8&0xff);
 
-        arr.push_back(crc>>8);arr.push_back(crc);
+        arr.push_back(crc>>8&0xff);arr.push_back(crc&0xff);
         std::vector<char> arr2 = arr;
         sit_ptr->m_clt->send(std::move(arr));
 

+ 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

+ 49 - 51
module_service/module_meta_date_changed.cpp

@@ -17,7 +17,7 @@
 #include <boost/tokenizer.hpp>
 #include <boost/algorithm/string/split.hpp>
 #include <boost/algorithm/string.hpp>
-
+#include <card_path.h>
 ///基础数据
 void module_meta_date_changed::accept(sio::message::ptr const& data)
 {
@@ -78,7 +78,7 @@ void module_meta_date_changed::accept(sio::message::ptr const& data)
             int id = std::stoi(szParam);
             deal_call_edit_path(id, edit_type_id);
         }
-        else if(JSON_KEY_NAME_MAP == name)
+        else if(JSON_KEY_NAME_MAP == name || JSON_KEY_NAME_MAP_GIS == name)
         {
             int id = std::stoi(szParam);
             deal_call_edit_map(id, edit_type_id);
@@ -220,6 +220,7 @@ void module_meta_date_changed::deal_call_edit_reader(int id, EDIT_TYPE_ID edit_t
     else if(ET_DELETE == edit_type_id)
     {
         sit_list::instance()->remove(id);
+        card_path::init();
     }
 }
 
@@ -229,27 +230,24 @@ void module_meta_date_changed::deal_call_edit_antenna(int id,EDIT_TYPE_ID edit_t
     {
         sit_list::instance()->read_sit_list(id);
     }
-    else if(ET_DELETE == edit_type_id)
-    {
-        delete_antenna(id);
-    }
+    //else if(ET_DELETE == edit_type_id)
+    //{
+        //delete_antenna(id);
+   // }
 }
 
 void module_meta_date_changed::deal_call_edit_path(int id, EDIT_TYPE_ID edit_type_id)
 {
-    if(ET_INSERT == edit_type_id)
-    {
-        log_error("path不支持增加操作");
-        std_debug("path不支持增加操作");
-    }
-    else if(ET_UPDATE == edit_type_id)
-    {
-        sit_list::instance()->read_ant_path(id);
-    }
-    else if(ET_DELETE == edit_type_id)
-    {
+   // if(ET_INSERT == edit_type_id)
+   // {
+   //     log_error("path不支持增加操作");
+   //     std_debug("path不支持增加操作");
+   // }
+   // else if(ET_UPDATE == edit_type_id)
+   // {
+   // }
+    if(sit_list::instance()->get(id))
         sit_list::instance()->read_ant_path(id);
-    }
 }
 
 void module_meta_date_changed::deal_call_edit_map(int id, EDIT_TYPE_ID edit_type_id)
@@ -406,39 +404,39 @@ bool module_meta_date_changed::try_get_edit_type_id(const std::string& op_type,
 //    }
 //}
 
-void module_meta_date_changed::delete_antenna(int id)
-{
-    int sitid=-8;
-    auto map = sit_list::instance()->m_map;
-    for(auto&it:map)
-    {
-        auto sit_ptr = it.second;
-        if(sit_ptr->m_ant[0].m_id == id)
-        {
-            sitid=sit_ptr->m_id;
-            sit_ptr->delete_antenna(0);
-            break;
-        }
-        if(sit_ptr->m_ant[1].m_id == id)
-        {
-            sitid=sit_ptr->m_id;
-            sit_ptr->delete_antenna(1);
-            break;
-        }
-    }
-
-    if(sitid==-8)
-    {
-        std_debug("天线已经删除了,在分站列表中找不到该天线:天线id=%d", id);
-        log_info("天线已经删除了,在分站列表中找不到该天线:天线id=%d", id);
-    }
-    else
-    {
-        std_debug("删除天线成功:天线id=%d,分站id=%d", id, sitid);
-        log_info("删除天线成功:天线id=%d,分站id=%d", id, sitid);
-    }
-}
-
+//void module_meta_date_changed::delete_antenna(int id)
+//{
+//    int sitid=-8;
+//    auto map = sit_list::instance()->m_map;
+//    for(auto&it:map)
+//    {
+//        auto sit_ptr = it.second;
+//        if(sit_ptr->m_ant[0].m_id == id)
+//        {
+//            sitid=sit_ptr->m_id;
+//            sit_ptr->delete_antenna(0);
+//            break;
+//        }
+//        if(sit_ptr->m_ant[1].m_id == id)
+//        {
+//            sitid=sit_ptr->m_id;
+//            sit_ptr->delete_antenna(1);
+//            break;
+//        }
+//    }
+//
+//    if(sitid==-8)
+//    {
+//        std_debug("天线已经删除了,在分站列表中找不到该天线:天线id=%d", id);
+//        log_info("天线已经删除了,在分站列表中找不到该天线:天线id=%d", id);
+//    }
+//    else
+//    {
+//        std_debug("删除天线成功:天线id=%d,分站id=%d", id, sitid);
+//        log_info("删除天线成功:天线id=%d,分站id=%d", id, sitid);
+//    }
+//}
+//
 bool module_meta_date_changed::is_cur_map(int id)
 {
     return cur_map_id()==id;

+ 1 - 1
module_service/module_meta_date_changed.h

@@ -82,7 +82,7 @@ private:
 
     bool try_get_edit_type_id(const std::string& op_type, EDIT_TYPE_ID& out_edit_type_id);
 
-    void delete_antenna(int id);
+    //void delete_antenna(int id);
 
     bool is_cur_map(int id);
 

+ 0 - 484
select_tool.cpp

@@ -1,484 +0,0 @@
-#include "select_tool.h"
-#include "ant.h"
-#include "card_path.h"
-#include "log.h"
-void select_point_object::att_initiate()
-{
-	m_fitk.add_tool(30,5,5);
-	m_fitk.add_tool(30,5,6);
-	m_fitk.add_tool(30,10,10);
-	m_fitk.add_tool(30,10,15);
-
-	m_fitk.add_tool(20,5,6);
-	m_fitk.add_tool(30,4,6);
-	m_fitk.add_tool(40,4,6);
-
-
-	m_fita.add_tool(15,5,5);
-	m_begin=m_last=0;
-
-}
-loc_point select_point_object::select_solution_impl(const std::vector<point> vp,const std::vector<loc_message>&lm)
-{
-    bool flag=false;
-    loc_point lp;
-    if(vp.size()==4)
-    {
-        m_d.grow().reset().set_source(lm[0],lm[1]);
-        flag = true;
-    }
-    if(vp.size()==2 && lm[0].m_card_ct - last_ct() == 1) 
-    {
-        m_d.grow().reset().set_source(lm[0]);
-        flag = true;
-    }
-    if(flag)
-    {
-        if(!select_solution(vp,lm[0].m_sit.get(),lp))
-        {
-            m_cur_fit.reset();
-            return lp;
-        }
-    }
-    m_ct = lm[0].m_card_ct;
-    return lp;
-}
-
-int select_point_object::find_last(int start)
-{
-	for(int i=start,len=m_d.size();i<len;i++)
-	{
-		if(m_d(i).cl()>0)
-			return i;
-	}
-
-	return -1;
-}
-
-int select_point_object::find_first(int start)
-{
-	for(int i=start,len=m_d.size();i<len;i++)
-	{
-		if(m_d[i].cl()>0)
-			return i;
-	}
-
-	return -1;
-}
-bool select_point_object::filter_by_fit(loc_point & c,const std::vector<point> & vp,const double scale)
-{
-    fit_result * fit = get_best_fit();
-	if(fit==nullptr || m_begin==nullptr || fit->ke>2)
-		return false;
-    loc_point &f = *m_begin;
-	std::array<solpoint,4> v;
-    int cnt = vp.size();
-	for(int i=0;i<cnt;i++)
-	{
-		v[i].set_sol(vp[i],fabs(fit->testk(c.m_time/1000.,f.dist_direct(vp[i]))));
-	}
-    std::sort(&v[0],&v[0]+cnt);
-    double a = getA(fit,scale,v[1].score()-v[0].score());  
-    if(a<0)
-      return false;
-	if(!filter_by_acc(c,v,a))
-	{
-		c.set_cl(0);
-		return true; //false?
-	}
-    reset_fit(vp[0].dist(v[0])); 
-    c[0]=v[0];
-    c[1]=v[1];
-    return true;
-
-}
-bool select_point_object::filter_by_acc(loc_point&c,std::array<solpoint,4>&v,double a)
-{
-	if(!m_last->is_same_site(c))
-		return true;
-
-	double td=m_last->time_off(c);
-
-	if(v[0].score()>a*td*td)
-		return false;
-
-	return true;
-}
-
-
-void select_point_object::select_one_ant(loc_point &c,const std::vector<point> & vp)
-{
-	int last=find_last(1);
-	if(last>0)
-	{
-		loc_point&p=m_d(last);
-
-		int cnt=vp.size();
-		std::array<solpoint,4> res;
-
-		//find the shortest dis
-		for(int i=0;i<cnt;i++) 
-			res[i].set_sol(vp[i],vp[i].dist(p[0]));
-
-		std::sort(&res[0],&res[0]+cnt);
-
-		c[1].set(res[1]);
-		c[0].set(res[0]);
-		c.inc_cl(5);
-    }
-}
- 
-point select_point_object::select_solution0(std::vector<point> &tvp,const double scale)
-{
-   //log_info("lemon test 2 :cardid:%d sit:%f sitid:%d",m_d(0).m_cid,scale,m_d(0).m_sid);
-    loc_point&c=m_d(0);
-	if(m_d.size()==1)
-	{
-		//first point ,only accpet two ants good data.
-		if(c.cl()>0 && tvp.size()<4)
-		{
-			c[1]=tvp[1];
-			return c[0]=tvp[0];
-		}
-
-		m_d.skip(1);
-		return point(0,0);
-	}
-    select_solution1(c,tvp,scale);
-    return c[0];
-}
-bool select_point_object::select_solution(const std::vector<point> &vp,const site*sit,loc_point &p)
-{
-   //log_info("lemon test 1 :cardid:%d sit:%d sitid:%d",m_d(0).m_cid,sit->m_id,m_d(0).m_sid);
-   remove_history(); 
-   std::vector<point> tvp(vp.begin(),vp.end());
-   if(vp.size()==4)
-   {
-       int c=0;
-       std::array<solpoint,4> res;
-       for(int i=0;i<2;i++)
-	   {
-            int x = i+2;
-			double d=vp[i].dist(vp[x]);
-			if(d<sit->ant_dist()*3)
-			{
-				res[c++].set_sol(vp[i].middle(vp[x]),d);
-			}
-			else
-			{
-				res[c++].set_sol(vp[i]);
-				res[c++].set_sol(vp[x]);
-			}
-		}
-
-		std::sort(&res[0],&res[0]+c);
-
-        tvp.clear();
-		for(int i=0;i<c;i++)
-          tvp.push_back(res[i]);
-
-		m_d(0).inc_cl(10);
-    }
-    point pt = select_solution0(tvp,sit->m_scale);
-	if(pt.empty() || m_d.empty())
-		return false;
-	m_d(0).set(pt);
-    if(!m_d(0).empty())
-		m_d(0).m_dist=sit->dist_direct(pt);
-	else
-	{
-		m_d(0).set_cl(0);
-		if(m_last) m_d(0).m_dist=0.01*m_last->m_dist>0?1:-1;
-	}
-
-	m_d(0).m_dist1=sit->dist_direct(pt);
-    //
-	//std_info("revise_by_history:::%llu",m_d(0).m_time);
-    bool fg=revise_by_history(pt,sit,m_d(0).m_time);
-	if(!fg)
-	{
-		log_warn("out of site path:t=%ld,sit=%d,card_id=%d,ct=%d,tof1=%d,tof2=%d,pt=(%f,%f)\n", m_d(0).m_time, m_d(0).m_sid,m_d(0).m_cid,m_d(0).m_ct, m_d(0).m_tof[0], m_d(0).m_tof[1], pt.x, pt.y);
-	
-	}
-
-    if(!card_path::inst().is_at_path(pt))
-	{
-		m_d(0).set_cl(0);
-
-		log_warn("out of path:t=%ld,sit=%d,card_id=%d,ct=%d,tof1=%d,tof2=%d,pt=(%f,%f)\n", m_d(0).m_time, m_d(0).m_sid,m_d(0).m_cid,m_d(0).m_ct, m_d(0).m_tof[0], m_d(0).m_tof[1], pt.x, pt.y);
-		return false;
-	}
-
-
-	m_last=&m_d(0);
-
-	if(m_line.empty() && m_d.size()>=2 && !make_line())
-		return false;
-    if(!m_line.contain(m_d(0),0.01) || (m_begin && !m_line.contain(m_begin->m_sol[0], 0.01)))
-    {
-		m_fitk.reset_data();
-		m_fita.reset_data();
-		m_begin=m_last=nullptr;
-
-		int i0=find_last(1);
-		if(i0==-1)
-			return false;
-
-		std::vector<point> path=card_path::inst().find_path(m_d(i0),m_d(0));
-
-		m_d.skip(m_d.size()-i0);
-
-		if(path.empty())
-		{
-			m_line.clear();
-			return false;
-		}
-
-		m_line.set(path.back(),m_d(0));
-	} 
-    if(!m_begin)
-	{
-		int idx=find_first(0);
-		if(idx>=0) m_begin=&m_d[idx];
-	}
-
-	if(!m_last)
-	{
-		int idx=find_last(0);
-		if(idx>=0) m_last=&m_d(idx);
-	}
-
-	if(m_begin && m_d(0).cl())
-	{
-		//implemented by li
-		int lastID1=find_last(1);
-		int lastID2=-1;
-		if(lastID1!=-1)
-			lastID2=find_last(lastID1+1);
-		if(lastID2!=-1)
-		{
-			double t0=m_last->m_time/1000., t1=m_d(lastID1).m_time/1000., t2=m_d(lastID2).m_time/1000.;
-			double d0=m_begin->loc_dist(*m_last), d1=m_begin->loc_dist(m_d(lastID1)), d2=m_begin->loc_dist(m_d(lastID2));
-			double k1=(d1-d0)/(t1-t0), k2=(d2-d1)/(t2-t1);
-			if(t0-t1<5 && t1-t2<5 && fabs(k2-k1)<0.5)
-			{
-				double tbegin = t0-3;
-				while(tbegin<t1+0.5)
-					tbegin=tbegin+1;
-				double tk=(d0-d1)/(t0-t1), tb=d1-tk*t1;		//d1+(d0-d1)/(t0-t1)*(t-t1)
-				for(double ti=tbegin;ti<t0;ti=ti+1)
-				{
-					//std_info("add ..seelct");
-					m_fitk.add(ti, tk*ti+tb);
-				}
-			}
-		}
-		m_fitk.add(m_last->m_time/1000.,m_begin->loc_dist(*m_last));
-
-		if(m_d.size()>1)
-		{
-			int pre=find_last(1);
-			if(pre>0) 
-			{
-				m_fita.add(m_d(0).m_time/1000.,m_begin->loc_dist(m_d(0))-m_begin->loc_dist(m_d(pre)));
-			}
-		}
-	}
-
-   p.set(pt);
-   save_k();
-   p.m_useless=fg;
-
-   return true;
-
-}
-
-bool select_point_object::make_line()
-{
-	int i0=-1,i1=-1;
-
-	if(-1==(i0=find_last(0)))
-		return false;
-
-	if(-1==(i1=find_last(i0+1)))
-		return false;
-
-	m_line.set(m_d(i0),m_d(i1));
-
-	return true;
-}
-
-void select_point_object::remove_history()
-{
-	loc_point&b=m_d(0);
-
-	if(m_d.size()>120 || (m_d.size()>2 && m_d(1).time_off(b)>max_histime))
-	{
-		m_d.skip_if([&b,this](loc_point&p){ return p.time_off(b)>max_histime;});
-		m_fitk.reset_data();
-		m_fita.reset_data();
-		m_cur_fit.reset();
-		m_begin=m_last=nullptr;
-		int idx=find_first(0);
-		if(idx<0) 
-			return;
-		m_begin=&m_d[idx];
-		idx=find_last(1);
-		m_last=&m_d(idx);
-
-		double dist=0,dist2=0;
-		for(int len=std::min(15,m_d.size()-1),i=len;i>0;i--)
-		{
-			if(!m_d(i).cl())
-				continue;
-			int lastID1=find_last(i+1);
-			int lastID2=-1;
-			if(lastID1!=-1)
-				lastID2=find_last(lastID1+1);
-			if(lastID2!=-1)
-			{
-				double t0=m_d(i).m_time/1000., t1=m_d(lastID1).m_time/1000., t2=m_d(lastID2).m_time/1000.;
-				double d0=m_begin->loc_dist(m_d(i)[0]), d1=m_begin->loc_dist(m_d(lastID1)[0]), 
-														d2=m_begin->loc_dist(m_d(lastID2)[0]);
-				double k1=(d1-d0)/(t1-t0), k2=(d2-d1)/(t2-t1);
-				if(t0-t1<5 && t1-t2<5 && fabs(k2-k1)<0.5)
-				{
-					double tbegin = t0-3;
-					while(tbegin<t1+0.5)
-						tbegin=tbegin+1;
-					double tk=(d0-d1)/(t0-t1), tb=d1-tk*t1;		//d1+(d0-d1)/(t0-t1)*(t-t1)
-					for(double ti=tbegin;ti<t0;ti=ti+1)
-					{
-						//std_info("add remove..");
-						m_fitk.add(ti, tk*ti+tb);
-					}
-				}
-			}
-
-			dist=m_begin->loc_dist(m_d(i)[0]);
-						//std_info("add remove..");
-			m_fitk.add(m_d(i).m_time/1000.,dist);
-
-			if(i==len)
-				continue;
-
-			m_fita.add(m_d(i).m_time/1000.,dist-dist2);
-			dist2=dist;
-		}
-		save_k();
-	}
-
-}
-void select_point_object::save_k()
-{
-	const fit_result*fk=best_fit_raw(0,4);
-	if(!fk)
-	{
-		m_cur_fit.reset();
-		return;
-	}
-	m_cur_fit=*fk;
-
-	fit_result&r=m_cur_fit;
-	card_fit*fa=&m_fita[0];
-	if(fa->is_valid() && fa->ke<0.1 && fk->k*fa->k<0)
-	{
-		double dk=fa->k*fa->num_point;
-		r.ka=fa->k;
-		if((fk->k+dk)*fk->k<0)
-			r.k=0;
-		else
-			r.k+=dk;
-
-		double y=fk->k*m_fitk(0).x+fk->kb;
-		r.kb=y-m_fitk(0).x*r.k;
-	}
-
-
-}
-fit_result* select_point_object::best_fit_raw(int num_point,int start,int last)
-{
-	card_fit*fit=nullptr;
-
-	start=std::max(start,0);
-	last  =std::min(last,m_fitk.tool_size());
-	if(last==-1)
-		last=m_fitk.tool_size();
-	//std_info("best_fit_raw :%d:%d",start,last);
-	for(int i=start;i<last;i++)
-	{
-		if(!m_fitk[i].is_valid())
-			continue;
-
-		if(m_fitk[i].num_point<num_point)
-			continue;
-
-		if(fit==nullptr)
-		{
-			fit=&m_fitk[i];
-			continue;
-		}
-
-		if(fit->ke>m_fitk[i].ke)
-		{
-			fit=&m_fitk[i];
-		}
-	}
-
-	return fit;
-}
-
-select_tool::~select_tool()
-{
-	if(m_spo !=nullptr)
-	  delete m_spo;
-}
-
-loc_point select_tool_person_1::select_solution(const std::vector<point> vp,const std::vector<loc_message>&lm)
-{
-    loc_point lp;
-    //select point.
-    if(lm[0].tool_index() == 0)  
-    {
-		if(m_spo==nullptr)
-			m_spo = new person_point_filter(this); 
-        lp=m_spo->select_solution_impl(vp,lm);
-    }
-    else if (lm[0].tool_index() == 2)
-    {
-        //for now..
-        //m_spo = new person_point_filter(); 
-        lp=m_spo->select_solution_impl(vp,lm);
-    }
-    else
-    {}
-    return lp;
-}
-
-loc_point select_tool_car_1::select_solution(const std::vector<point> vp,const std::vector<loc_message>&lm)
-{
-    loc_point lp;
-    //select point.
-    if(lm[0].tool_index() == 0)  
-    {
-		if(m_spo==nullptr)
-			m_spo = new car_point_filter(this); 
-        lp=m_spo->select_solution_impl(vp,lm);
-    }
-    else if (lm[0].tool_index() == 2)
-    {
-        //for now..
-        //m_spo = new car_point_filter(); 
-        lp=m_spo->select_solution_impl(vp,lm);
-    }
-    else
-    {}
-    return lp;
-}
-
-
-select_tool_manage * select_tool_manage::instance()
-{
-    static select_tool_manage stm;
-    return &stm;
-}

File diff suppressed because it is too large
+ 0 - 1205
select_tool.h


+ 1 - 0
websocket/constdef.h

@@ -51,6 +51,7 @@
 #define JSON_KEY_OP_TYPE_DELETE "DELETE"
 
 #define JSON_KEY_NAME "name"
+#define JSON_KEY_NAME_MAP_GIS "map_gis"
 #define JSON_KEY_NAME_MAP "map"
 #define JSON_KEY_NAME_AREA "area"
 #define JSON_KEY_NAME_PATH "reader_path_tof_n"

+ 2 - 0
worker.cpp

@@ -17,6 +17,7 @@
 #include "area.h"
 #include "clock.h"
 #include "mine_business.h"
+#include "bulletin_broad_show.h"
 
 loop_thread::loop_thread ()
 {
@@ -104,6 +105,7 @@ struct timer_worker_thread: loop_thread
 			mine_business::inst()->clear_vehicle();
 		}
 		card_list::instance()->accept(clv);
+		bulletin_broad_show::inst()->run_bulletin_board();
 		mine_business::inst()->run_business();
 
 		log_info("timer_worker_thread use time:%ldus", clock.count_us());

+ 6 - 0
ya_setting.cpp

@@ -2,6 +2,8 @@
 #include "db/db_api/CDBSingletonDefine.h"
 #include "log.h"
 
+#include <config_file.h>
+extern config_file config;
 SSys_setting CYaSetting::m_sys_setting;
 /*
 * 从数据库的dat_setting表初始化系统阈值,
@@ -9,6 +11,10 @@ SSys_setting CYaSetting::m_sys_setting;
 */
 bool CYaSetting::Init_sys_setting()
 {
+    {
+        m_sys_setting.rav_disable=config.get("service.rav_disable","");
+        log_info("rav_disable:%s",m_sys_setting.rav_disable.c_str());
+    }
 	std::string Error;
 	YADB::CDBResultSet DBRes;
 	std::string sql = "select setting_id, name, type, value from dat_setting;";

+ 10 - 1
ya_setting.h

@@ -3,7 +3,7 @@
 
 #include <time.h>
 #include <map>
-
+#include "common_tool.h"
 // 系统设置,,读取DB.dat_setting
 struct  SSys_setting // system_limit_setting
 {
@@ -23,10 +23,19 @@ struct  SSys_setting // system_limit_setting
 	double rear_end_d;
 	time_t rear_end_t;
 	double geofault_warn_dis;
+    std::string rav_disable;
     SSys_setting()
     {
         init();
     }
+    bool test_rav(uint8_t type,uint32_t id)
+    {
+        bool f = false;
+        std::string cardid=tool_other::type_id_to_str(type,id);
+       if(rav_disable.find(cardid) != std::string::npos) 
+         f=true;
+       return f;
+    }
     void init()
     {
         over_count_person = 1000;