Browse Source

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

lixioayao 5 years ago
parent
commit
a14a724d14

+ 3 - 3
Makefile.am

@@ -22,13 +22,13 @@ SRC_MAIN= ant.cpp area.cpp base64.cpp bindmorecard.cpp mine_business.cpp card_ar
 		  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 bulletin_broad_show.cpp
+		  forbid_staff_down_mine.cpp bulletin_broad_show.cpp area_persons_thre_time.cpp
 
 AM_SOURCES=$(SRC_MONKEYCAR) $(SRC_MODULE_SERVICE) $(SRC_MAIN) $(SRC_MAIN_EVENT)
 
-AM_CPPFLAGS=-Wall -pthread -m64 -g  -std=c++11 -I${prefix}/include -I/usr/local/mysql/include -Iwebsocket -Iwebsocket/sio -I./db  -Imodule_service
+AM_CPPFLAGS=-Wall -pthread -m64 -g -std=c++11 -I${prefix}/include -I/usr/local/mysql/include -Iwebsocket -Iwebsocket/sio -I./db  -Imodule_service
 
-AM_LDFLAGS=-Wall -pthread -m64 -g  -std=c++11  -L${prefix}/lib  -L/usr/local/mysql/lib
+AM_LDFLAGS=-Wall -pthread -m64 -g -std=c++11  -L${prefix}/lib  -L/usr/local/mysql/lib
 
 yals_SOURCES=${AM_SOURCES} main.cpp
 yals_CPPFLAGS=${AM_CPPFLAGS}

+ 70 - 0
area.cpp

@@ -12,6 +12,7 @@
 #include "monkey_car/monkeycar_area.h"
 #include "landmark.h"
 #include "area_business.h"
+#include "area_persons_thre_time.h"
 
 #include <boost/algorithm/string/split.hpp>
 #include <boost/algorithm/string/classification.hpp>
@@ -84,7 +85,9 @@ area::area(int id,int limit_count_person, int limit_time_person,double scale,int
 	 ,m_frozen_count(0)
      ,m_is_work_area(0)
     {
+		m_default_limit_person_count = limit_count_person;
 		m_area_business_list=area_business::get_instance_list(m_biz_type,id);
+		m_persons_thre_time = std::make_shared<area_persons_thre_time>();
     }
 void area::clear()
 {
@@ -225,6 +228,19 @@ bool area::in_area(const std::shared_ptr<site>&s,const std::shared_ptr<card_loca
     }
 }
 
+//
+bool area::get_limit_person_count()
+{
+	int count = m_persons_thre_time->get_limit_person_count();
+	if (count != m_limit_person_count.load())
+	{
+		m_limit_person_count = count;
+		return true;
+	}
+	return false;
+}
+
+/////////////////// area_list //////////////////////////////////////////////////
 area_list::area_list()
 {
 }
@@ -567,6 +583,60 @@ std::vector<std::shared_ptr<area>> area_list::get_area(const std::shared_ptr<sit
 	//区域覆盖不完全地图,很多车辆人行驶在地图外,如何确认.
 	return std::move(ret);
 }
+// 区域时间段超员设置
+void area_list::init_area_persons_dynamic_thre_from_db(int area_id/* = -1*/)
+{
+	std::string sql = "SELECT area_id,adpt_id,start_time,end_time,thre_value from dat_area_persons_dynamic_thre ";
+	if (area_id > -1 )
+	{
+		sql.append(" where area_id=");
+		sql.append(std::to_string(area_id));
+	}
+	sql.append(" order by area_id asc,start_time asc ;");
+
+	std::string Error;
+	YADB::CDBResultSet DBRes;
+	sDBConnPool.Query(sql.c_str(),DBRes,Error);
+	int nCount = DBRes.GetRecordCount( Error );
+	if (nCount < 1)
+	{
+		return;
+	}
+	std::map<int, std::shared_ptr<area_persons_thre_time>> map_thre;
+	while ( DBRes.GetNextRecod(Error) )
+	{
+		SArea_Persons_Thre td;
+		DBRes.GetField("area_id", td.area_id, Error);
+		DBRes.GetField("adpt_id", td.db_id, Error);
+		DBRes.GetField("start_time", td.sz_start_time, Error);
+		DBRes.GetField("end_time", td.sz_end_time, Error);
+		DBRes.GetField("thre_value", td.thre_value, Error);
+		td.start_time = tool_time::time_to_day_seconds(td.sz_start_time);
+		td.end_time = tool_time::time_to_day_seconds(td.sz_end_time);
+		auto it = map_thre.find(td.area_id);
+		if (it == map_thre.end())
+		{
+			std::shared_ptr<area_persons_thre_time> p = std::make_shared<area_persons_thre_time>();
+			p->add_persons_thre(td);
+			map_thre[td.area_id] = p;
+		}
+		else
+		{
+			it->second->add_persons_thre(td);
+		}
+	}
+	for( auto &it : map_thre)
+	{
+		std::shared_ptr<area> a = area_list::instance()->get(it.first);
+		if (nullptr != a)
+		{
+			it.second->set_default_person_count_limit(a->m_default_limit_person_count);
+			a->m_persons_thre_time = it.second;
+		}
+	}
+	log_info("加载区域:%d 时间段人员超员设置sql: %s",area_id, sql.c_str());
+}
+/////////////////////////////////////////////////////////////////////
 area_hover::area_hover(const std::shared_ptr<area>&area,const point&pt)
 	:m_area(area)
 {

+ 14 - 2
area.h

@@ -18,6 +18,7 @@ struct area_business;
 struct business_data;
 struct card_location_base;
 struct site;
+struct area_persons_thre_time;
 
 /*
 	每个区域对应一个area对象。
@@ -103,9 +104,12 @@ public:
     int    m_biz_type=0;
     int    m_area_type=0;
 
-	//人卡超时及超员数量(阀值)
+	// 人卡超时及超员数量(阀值)
     int m_limit_person_min;
-    int m_limit_person_count;
+    // 区域表中人员超员的(阀值)
+    int m_default_limit_person_count;
+    // 当前人员超员的(阀值)
+    std::atomic<int> m_limit_person_count;
     //是否人卡超员已有告警
     bool m_event_person_count;
     bool m_event_person_show_count;
@@ -136,6 +140,12 @@ public:
     std::map<int,double> m_speed;
     std::vector<point> m_bound;
 	std::vector<area_business*> m_area_business_list;
+
+	//区域时间段超员限制
+    std::shared_ptr<area_persons_thre_time> m_persons_thre_time;
+
+    // 判断区域当前超员的阈值,是否变化 true:有变化
+    bool get_limit_person_count();
 };
 
 struct area_list:single_base<area_list,int,std::shared_ptr<area>>
@@ -148,6 +158,8 @@ struct area_list:single_base<area_list,int,std::shared_ptr<area>>
     ///id=-1为初始化所有
     void init_from_db(int id=-1);
     void init_monkeycar_area(int id=-1);
+    // 区域时间段超员设置
+    void init_area_persons_dynamic_thre_from_db(int area_id = -1);
 private:
 	std::shared_ptr<area>  create(int type,int id,int limit_count_person, int limit_time_person,double scale,int32_t mapid,int32_t b_type);
 };

+ 64 - 0
area_persons_thre_time.cpp

@@ -0,0 +1,64 @@
+//
+// Created by songchao.chen on 2019/7/4.
+//
+
+#include "area_persons_thre_time.h"
+#include "tool_time.h"
+
+area_persons_thre_time::area_persons_thre_time()
+{
+}
+
+void area_persons_thre_time::set_default_person_count_limit(int _limit)
+{
+    m_default_limit_person_limit = _limit;
+};
+
+void area_persons_thre_time::add_persons_thre(const SArea_Persons_Thre & thre)
+{
+    m_area_persons_thre[thre.db_id] = thre;
+}
+
+void area_persons_thre_time::del_persons_thre(int thre_db_id)
+{
+    m_area_persons_thre.erase(thre_db_id);
+}
+
+void area_persons_thre_time::clear_persons_thre()
+{
+    m_area_persons_thre.clear();
+}
+
+//记录数量
+int area_persons_thre_time::get_count() const
+{
+    return (int)m_area_persons_thre.size();
+}
+
+int area_persons_thre_time::get_limit_person_count(uint64_t cur_time)
+{
+    int cur_sec = tool_time::time_to_day_seconds(cur_time);
+
+    //std::string sz_cur_time = tool_time::to_str_time(cur_time);
+    for (auto it : m_area_persons_thre)
+    {
+        SArea_Persons_Thre &d = it.second;
+        /*if (sz_cur_time >= d.sz_start_time && sz_cur_time <= d.sz_end_time)
+        {
+            return d.thre_value;
+        }*/
+        if (cur_sec >= d.start_time && cur_sec <= d.end_time)
+        {
+            return d.thre_value;
+        }
+        if(d.start_time > d.end_time)  //隔天 (23:00:00 -- 02:00:00
+        {
+            if ((cur_sec >= d.start_time && cur_sec <= 3600 * 24)
+             || (cur_sec >= 0 && cur_sec <= d.end_time))
+            {
+                return d.thre_value;
+            }
+        }
+    }
+    return m_default_limit_person_limit;
+}

+ 55 - 0
area_persons_thre_time.h

@@ -0,0 +1,55 @@
+//
+// Created by songchao.chen on 2019/7/4.
+// 区域中设定时间段人员超时限制
+//
+
+#ifndef WORKSPACE_AREA_PERSONS_THRE_TIME_H
+#define WORKSPACE_AREA_PERSONS_THRE_TIME_H
+
+#include <string>
+#include <map>
+#include <atomic>
+
+struct SArea_Persons_Thre
+{
+    int db_id;
+    int area_id;
+    int thre_value;
+    std::string sz_start_time;
+    std::string sz_end_time;
+    int start_time;
+    int end_time;
+    SArea_Persons_Thre()
+    {
+        db_id = 0;
+        area_id = 0;
+        thre_value = 0;
+        start_time = 0;
+        end_time = 0;
+        sz_start_time = "";
+        sz_end_time = "";
+    }
+};
+
+typedef std::map<int,SArea_Persons_Thre> MAP_AREA_PERSONS_THRE;
+
+struct area_persons_thre_time
+{
+    area_persons_thre_time();
+    MAP_AREA_PERSONS_THRE m_area_persons_thre;
+    int m_default_limit_person_limit;
+
+    void add_persons_thre(const SArea_Persons_Thre & thre);
+    void del_persons_thre(int thre_db_id);
+    void clear_persons_thre();
+    //设置默认值
+    void set_default_person_count_limit(int _limit);
+
+    //记录数量
+    int get_count() const;
+    // 获取区域cur_time超员的阈值,区域可能有时间段限制
+    int get_limit_person_count(uint64_t cur_time = 0);
+};
+
+
+#endif //WORKSPACE_AREA_PERSONS_THRE_TIME_H

+ 2 - 0
main.cpp

@@ -77,6 +77,8 @@ struct Init_Setting
         sit_list::instance()->load_from_db();
         card_list::instance()->init_card_from_db();
         area_list::instance()->init_from_db();
+        area_list::instance()->init_area_persons_dynamic_thre_from_db();
+
         forbid_staff_down_mine::instance()->init_forbid_staff();
         //point pt(3348,100);
         //int id = area_list::instance()->get_area(pt)->id();

+ 103 - 64
module_service/area_business_count_checker.cpp

@@ -61,21 +61,8 @@ void area_business_count_checker::on_enter(const std::shared_ptr<area_hover>&a,
 		    a->m_area->m_person_count ++;
         if(c->m_display)
 		    a->m_area->m_person_show_count ++ ;
-        int pc=a->m_area->m_person_count.load();
-        int pc_=a->m_area->m_person_show_count.load();
-	    EVENT_TYPE ev = a->m_area->is_mine()?EVENT_TYPE::ET_OVER_COUNT_PERSON : EVENT_TYPE::ET_AREA_OVER_COUNT_PERSON ;
-        if(pc>limit_val){
-            lock();
-		    event_tool::instance()->handle_event(OT_AREA,ev,aid,limit_val,pc,a->m_area->m_event_person_count=true,DT_NORMAL);
-            unlock();
-		    log_info("person_count_enter:%d,v_count:%d limit:%d",aid,pc,limit_val);
-        }
-        if(pc_>limit_val){
-            lock();
-		    event_tool::instance()->handle_event(OT_AREA,ev,aid,limit_val,pc_,a->m_area->m_event_person_show_count=true,DT_SPECIAL);
-            unlock();
-		    log_info("person_count_enter_show:%d,v_count:%d limit:%d",aid,pc_,limit_val);
-        }
+
+        _add_person_count_event(a,limit_val,"person_count_enter");
 	}
 	else if (c->is_vehicle())
 	{
@@ -90,21 +77,8 @@ void area_business_count_checker::on_enter(const std::shared_ptr<area_hover>&a,
 		    a->m_area->m_vehicle_count ++ ;
         if(c->m_display)
 		    a->m_area->m_vehicle_show_count ++ ;
-        int vc=a->m_area->m_vehicle_count.load();
-        int vc_=a->m_area->m_vehicle_show_count.load();
-		EVENT_TYPE ev = a->m_area->is_mine()?EVENT_TYPE::ET_OVER_COUNT_VEHICLE : EVENT_TYPE::ET_AREA_OVER_COUNT_VEHICLE ;
-        if(vc>limit_val){
-            lock();
-		    event_tool::instance()->handle_event(OT_AREA,ev,aid,limit_val,vc,a->m_area->m_event_vehicle_count=true,DT_NORMAL);
-            unlock();
-		    log_info("vehicle_count_enter:%d,v_count:%d limit:%d",aid,vc,limit_val);
-        }
-        if(vc_>limit_val){
-            lock();
-		    event_tool::instance()->handle_event(OT_AREA,ev,aid,limit_val,vc_,a->m_area->m_event_vehicle_show_count=true,DT_SPECIAL);
-            unlock();
-		    log_info("vehicle_count_enter_show:%d,v_count:%d limit:%d",aid,vc_,limit_val);
-        }
+
+        _add_vehicle_count_event(a,limit_val);
 	}
     c->update_display();
 }
@@ -121,6 +95,13 @@ void area_business_count_checker::on_hover(const std::shared_ptr<area_hover>&a,
         c->update_display();
         ptr=nullptr;
     }
+
+    if (c->is_person() && a->m_area->get_limit_person_count())
+    {
+        int limit_val = a->m_area->m_limit_person_count;
+        _remove_person_count_event(a,limit_val,"area_business_count_checker::on_hover");
+        _add_person_count_event(a,limit_val,"area_business_count_checker::on_hover");
+    }
 }
 
 //减少计数
@@ -148,23 +129,7 @@ void area_business_count_checker::on_leave(const std::shared_ptr<area_hover>&a,
             if(flag)
 		        a->m_area->m_person_show_count -- ;
         }
-        int pc=a->m_area->m_person_count.load();
-        int pc_=a->m_area->m_person_show_count.load();
-        int limit_val=a->m_area->m_limit_person_count;
-        int aid=a->m_area->id();
-	    EVENT_TYPE ev = a->m_area->is_mine()?EVENT_TYPE::ET_OVER_COUNT_PERSON : EVENT_TYPE::ET_AREA_OVER_COUNT_PERSON ;
-		if(a->m_area->m_event_person_count&& pc <= limit_val){
-            lock();
-			event_tool::instance()->handle_event(OT_AREA,ev,aid,limit_val,pc,a->m_area->m_event_person_count=false,DT_NORMAL);
-            unlock();
-		    log_info("person_count_leave:%d,v_count:%d limit:%d",aid,pc,limit_val);
-        }
-		if(a->m_area->m_event_person_show_count&& pc_ <= limit_val){
-            lock();
-			event_tool::instance()->handle_event(OT_AREA,ev,aid,limit_val,pc_,a->m_area->m_event_person_show_count=false,DT_SPECIAL);
-            unlock();
-		    log_info("person_count_leave_show:%d,v_count:%d limit:%d",aid,pc,limit_val);
-        }
+        _remove_person_count_event(a , a->m_area->m_limit_person_count ,"person_count_leave");
 	}
 	else if (c->is_vehicle())
 	{
@@ -176,23 +141,97 @@ void area_business_count_checker::on_leave(const std::shared_ptr<area_hover>&a,
             if(flag)
 		        a->m_area->m_vehicle_show_count -- ;
         }
-        int pc=a->m_area->m_vehicle_count.load();
-        int pc_=a->m_area->m_vehicle_show_count.load();
-        int limit_val=a->m_area->m_limit_vehicle_count;
-        int aid=a->m_area->id();
-		EVENT_TYPE ev = a->m_area->is_mine()?EVENT_TYPE::ET_OVER_COUNT_VEHICLE : EVENT_TYPE::ET_AREA_OVER_COUNT_VEHICLE ;
-		if(a->m_area->m_event_vehicle_count&& pc <= limit_val){
-            lock();
-			event_tool::instance()->handle_event(OT_AREA,ev,aid,limit_val,pc,a->m_area->m_event_vehicle_count=false,DT_NORMAL);
-            unlock();
-		    log_info("vehicle_count_leave:%d,v_count:%d limit:%d",aid,pc,limit_val);
-        }
-		if(a->m_area->m_event_vehicle_show_count&& pc_ <= limit_val){
-            lock();
-			event_tool::instance()->handle_event(OT_AREA,ev,aid,limit_val,pc_,a->m_area->m_event_vehicle_show_count=false,DT_SPECIAL);
-            unlock();
-		    log_info("vehicle_count_leave_show:%d,v_count:%d limit:%d",aid,pc,limit_val);
-        }
+        _remove_vehicle_count_event(a,a->m_area->m_limit_vehicle_count);
 	}
 }
 
+//添加人员告警
+void area_business_count_checker::_add_person_count_event(const std::shared_ptr<area_hover>&a
+        ,int limit_val,const std::string &desc)
+{
+    int aid = a->m_area->id();
+    int pc = a->m_area->m_person_count.load();
+    int pc_ = a->m_area->m_person_show_count.load();
+    EVENT_TYPE ev = a->m_area->is_mine() ? EVENT_TYPE::ET_OVER_COUNT_PERSON : EVENT_TYPE::ET_AREA_OVER_COUNT_PERSON;
+    if(pc > limit_val )
+    {
+        lock();
+        event_tool::instance()->handle_event(OT_AREA,ev,aid,limit_val,pc,a->m_area->m_event_person_count=true,DT_NORMAL);
+        unlock();
+        log_info("%s:%d,v_count:%d limit:%d",desc.c_str(),aid,pc,limit_val);
+    }
+    if(pc_ > limit_val )
+    {
+        lock();
+        event_tool::instance()->handle_event(OT_AREA,ev,aid,limit_val,pc_,a->m_area->m_event_person_show_count=true,DT_SPECIAL);
+        unlock();
+        log_info("%s:%d,v_count:%d limit:%d",desc.c_str(),aid,pc_,limit_val);
+    }
+}
+//移除人员告警
+void area_business_count_checker::_remove_person_count_event(const std::shared_ptr<area_hover>&a
+        ,int limit_val,const std::string &desc)
+{
+    int aid = a->m_area->id();
+    int pc = a->m_area->m_person_count.load();
+    int pc_ = a->m_area->m_person_show_count.load();
+    EVENT_TYPE ev = a->m_area->is_mine() ? EVENT_TYPE::ET_OVER_COUNT_PERSON : EVENT_TYPE::ET_AREA_OVER_COUNT_PERSON;
+
+    if(pc <= limit_val && a->m_area->m_event_person_count)
+    {
+        lock();
+        event_tool::instance()->handle_event(OT_AREA,ev,aid,limit_val,pc,a->m_area->m_event_person_count=false,DT_NORMAL);
+        unlock();
+        log_info("%s :%d,v_count:%d limit:%d",desc.c_str(),aid,pc,limit_val);
+    }
+    if(pc_ <= limit_val && a->m_area->m_event_person_show_count)
+    {
+        lock();
+        event_tool::instance()->handle_event(OT_AREA,ev,aid,limit_val,pc_,a->m_area->m_event_person_show_count=false,DT_SPECIAL);
+        unlock();
+        log_info("%s :%d,v_count:%d limit:%d",desc.c_str(),aid,pc_,limit_val);
+    }
+}
+
+//添加车数量超出限制告警
+void area_business_count_checker::_add_vehicle_count_event(const std::shared_ptr<area_hover>&a
+        ,int limit_val,const std::string &desc)
+{
+    int aid = a->m_area->id();
+    int vc=a->m_area->m_vehicle_count.load();
+    int vc_=a->m_area->m_vehicle_show_count.load();
+    EVENT_TYPE ev = a->m_area->is_mine()?EVENT_TYPE::ET_OVER_COUNT_VEHICLE : EVENT_TYPE::ET_AREA_OVER_COUNT_VEHICLE ;
+    if(vc>limit_val){
+        lock();
+        event_tool::instance()->handle_event(OT_AREA,ev,aid,limit_val,vc,a->m_area->m_event_vehicle_count=true,DT_NORMAL);
+        unlock();
+        log_info("vehicle_count_enter:%d,v_count:%d limit:%d",aid,vc,limit_val);
+    }
+    if(vc_>limit_val){
+        lock();
+        event_tool::instance()->handle_event(OT_AREA,ev,aid,limit_val,vc_,a->m_area->m_event_vehicle_show_count=true,DT_SPECIAL);
+        unlock();
+        log_info("vehicle_count_enter_show:%d,v_count:%d limit:%d",aid,vc_,limit_val);
+    }
+}
+//移除车数量超出告警
+void area_business_count_checker::_remove_vehicle_count_event(const std::shared_ptr<area_hover>&a
+        ,int limit_val,const std::string &desc)
+{
+    int pc=a->m_area->m_vehicle_count.load();
+    int pc_=a->m_area->m_vehicle_show_count.load();
+    int aid=a->m_area->id();
+    EVENT_TYPE ev = a->m_area->is_mine()?EVENT_TYPE::ET_OVER_COUNT_VEHICLE : EVENT_TYPE::ET_AREA_OVER_COUNT_VEHICLE ;
+    if(a->m_area->m_event_vehicle_count&& pc <= limit_val){
+        lock();
+        event_tool::instance()->handle_event(OT_AREA,ev,aid,limit_val,pc,a->m_area->m_event_vehicle_count=false,DT_NORMAL);
+        unlock();
+        log_info("vehicle_count_leave:%d,v_count:%d limit:%d",aid,pc,limit_val);
+    }
+    if(a->m_area->m_event_vehicle_show_count&& pc_ <= limit_val){
+        lock();
+        event_tool::instance()->handle_event(OT_AREA,ev,aid,limit_val,pc_,a->m_area->m_event_vehicle_show_count=false,DT_SPECIAL);
+        unlock();
+        log_info("vehicle_count_leave_show:%d,v_count:%d limit:%d",aid,pc,limit_val);
+    }
+}

+ 11 - 0
module_service/area_business_count_checker.h

@@ -22,6 +22,17 @@ struct area_business_count_checker:area_business
 	void on_hover(const std::shared_ptr<area_hover>&a,const std::shared_ptr<card_location_base>&c,std::shared_ptr<business_data> ptr);
 	//减少计数
 	void on_leave(const std::shared_ptr<area_hover>&a,const std::shared_ptr<card_location_base>&c,std::shared_ptr<business_data> ptr);
+
+private:
+    //添加人数超出限制告警
+    void _add_person_count_event(const std::shared_ptr<area_hover>&a,int limit_val,const std::string &desc);
+    //移除人数超出限制告警
+    void _remove_person_count_event(const std::shared_ptr<area_hover>&a,int limit_val,const std::string &desc);
+    //添加车数量超出限制告警
+    void _add_vehicle_count_event(const std::shared_ptr<area_hover>&a,int limit_val,const std::string &desc = "");
+    //移除车数量超出告警
+    void _remove_vehicle_count_event(const std::shared_ptr<area_hover>&a,int limit_val,const std::string &desc = "");
+
 private:
 	std::atomic<int> m_mutex;
 	void lock()

+ 12 - 1
module_service/module_meta_date_changed.cpp

@@ -19,6 +19,7 @@
 #include <boost/algorithm/string/split.hpp>
 #include <boost/algorithm/string.hpp>
 #include <card_path.h>
+#include "ya_setting.h"
 ///基础数据
 void module_meta_date_changed::accept(sio::message::ptr const& data)
 {
@@ -96,6 +97,11 @@ void module_meta_date_changed::accept(sio::message::ptr const& data)
         else if (JSON_KEY_NAME_FORBID_PERSON_DOWN_MINE == name)
         {
             deal_call_edit_forbid_person_down_mine(szParam,edit_type_id);
+        }
+        else if (JSON_KEY_NAME_PERSONS_DYNAMIC_THRE == name)
+        {
+            int id = std::stoi(szParam);
+            deal_call_edit_persons_dynamic_thre(id,edit_type_id);
         }
 		else if (JSON_KEY_NAME_GEO_FAULT == name)//地址断层更新
 		{
@@ -319,6 +325,11 @@ void module_meta_date_changed::deal_call_edit_forbid_person_down_mine(const std:
     }
 }
 
+// 设置区域中时间段人员超员阈值等数据
+void module_meta_date_changed::deal_call_edit_persons_dynamic_thre(int area_id,EDIT_TYPE_ID edit_type_id)
+{
+    area_list::instance()->init_area_persons_dynamic_thre_from_db(area_id);
+}
 // 修改地标信息
 void module_meta_date_changed::deal_call_edit_landmark(const std::string & landmarkid, EDIT_TYPE_ID edit_type_id)
 {
@@ -336,7 +347,7 @@ void module_meta_date_changed::deal_call_edit_landmark(const std::string & landm
 
 void module_meta_date_changed::init_setting()
 {
-    //pRes = getMysqlRes("select setting_id, name, type, value from dat_setting;");
+    CYaSetting::Init_sys_setting();
 }
 
 void module_meta_date_changed::remove_card(uint32_t id, int32_t type) {

+ 3 - 0
module_service/module_meta_date_changed.h

@@ -68,6 +68,9 @@ private:
 	//地标
 	void deal_call_edit_landmark(const std::string & landmarkid, EDIT_TYPE_ID edit_type_id);
 
+    // 设置区域中时间段人员超员阈值等数据
+    void deal_call_edit_persons_dynamic_thre(int area_id,EDIT_TYPE_ID edit_type_id);
+
     ///待实现
     void init_setting();
 

+ 30 - 0
tool_time.h

@@ -129,6 +129,36 @@ public:
 
         return std::string(_time);
     }
+    //"%H:%M:%S"
+    static std::string to_str_time(const std::time_t &time)
+    {
+        char _time[25] = {0};
+        struct tm local_time;
+        localtime_r(&time, &local_time);
+        strftime(_time, 22, "%H:%M:%S", &local_time);
+
+        return std::string(_time);
+    }
+
+    static int time_to_day_seconds(uint64_t t)
+    {
+        std::time_t _time = t;
+        if (_time == 0)
+        {
+            _time = tool_time::now_to_seconds();
+        }
+        struct tm local_time;
+        localtime_r(&_time, &local_time);
+        return local_time.tm_hour * 3600 + local_time.tm_min * 60 + local_time.tm_sec;
+    }
+    //t 格式:05:02:02
+    static int time_to_day_seconds(const std::string &t)
+    {
+        int hour = 0,min = 0,sec = 0;
+        sscanf(t.c_str(), "%d:%d:%d", &hour,&min,&sec);
+        return hour * 3600 + min * 60 + sec;
+    }
+
     static int get_hour()
     {
         time_t tt = time(0);

+ 2 - 1
websocket/constdef.h

@@ -83,7 +83,8 @@
 
 //禁止指定人员下井
 #define JSON_KEY_NAME_FORBID_PERSON_DOWN_MINE "rt_person_forbid_down_mine"
-
+//设置区域中时间段人员超员阈值等数据
+#define JSON_KEY_NAME_PERSONS_DYNAMIC_THRE "area_persons_dynamic_thre"
 
 #define JSON_KEY_CALL_CARD_CALL_TYPE "call_type_id"
 #define JSON_KEY_CALL_CARD_CALL_TIME_OUT "call_time_out"