12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- //
- // 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;
- }
|