123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131 |
- #include "sys_setting.h"
- #include "db/db_api/CDBSingletonDefine.h"
- #include "log.h"
- #include <config_file.h>
- extern config_file config;
- SSys_setting CYaSetting::m_sys_setting;
- service_position_ptr ios_service::m_ios_service;
- /*
- * 从数据库的dat_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;";
- sDBConnPool.Query(sql.c_str(),DBRes,Error);
- int nCount = DBRes.GetRecordCount( Error );
- if (nCount > 0)
- {
- while ( DBRes.GetNextRecod(Error) )
- {
- std::string strVal = "";
- std::string val="";
- DBRes.GetField("name",strVal, Error );
- #define D_GetValue(K,N,X,PS) \
- if(strVal==N)\
- {DBRes.GetField("value",val, Error);\
- log_info("init_setting:%s,%s",N,val.c_str());\
- K = atoi(val.c_str())*X;}\
- D_GetValue(m_sys_setting.over_count_person,"over_count_person",1,"人员井下超员")
- D_GetValue(m_sys_setting.over_count_vehicle,"over_count_vehicle",1,"车辆井下超员")
- D_GetValue(m_sys_setting.over_time_person,"over_time_person",60,"人员井下超时")
- D_GetValue(m_sys_setting.over_time_vehicle,"over_time_vehicle",60,"车辆井下超时")
- D_GetValue(m_sys_setting.over_speed,"over_speed",1,"车辆超速限值")
- D_GetValue(m_sys_setting.att_starttime_offset_staff,"att_starttime_offset_staff",60,"考勤开始时间向前偏移分钟数")
- D_GetValue(m_sys_setting.att_endtime_offset_staff,"att_endtime_offset_staff",60,"车辆考勤开始时间向前偏移分钟数")
- D_GetValue(m_sys_setting.att_starttime_offset_vehicle,"att_starttime_offset_vehicle",60,"车辆考勤结束时间向后偏移分钟数")
- D_GetValue(m_sys_setting.att_endtime_offset_vehicle,"att_endtime_offset_vehicle",60,"车辆考勤结束时间向后偏移分钟数")
- D_GetValue(m_sys_setting.att_person_thre_hour,"att_person_thre_hour",60*60,"")
- D_GetValue(m_sys_setting.rear_end_d,"rear_end_distance",1,"")
- D_GetValue(m_sys_setting.rear_end_t,"rear_end_time",1,"")
- D_GetValue(m_sys_setting.geofault_warn_dis,"geofault_warn",1,"")
- D_GetValue(m_sys_setting.light_group_count, "light_group_count", 1, "")
- D_GetValue(m_sys_setting.site_no_position_time, "site_no_position_time", 60, "基站长时间无定位阈值(分钟数)");
- #undef D_GetValue
- if(strVal == "anti_collision"){
- val = "";
- DBRes.GetField("value", val, Error);
- log_info("init_setting: anti_collision:%s", val.c_str());
- m_sys_setting.init_anti_coll_value(val);
- }
- }
- log_info("init_setting:rear_end_d:%f, rear_end_t:%ld, over_count_person:%u, over_count_vehicle:%u, over_time_person:%u, over_time_vehicle:%u, over_speed:%f, light_group_count:%d, site_no_position_time: %d",
- m_sys_setting.rear_end_d,
- m_sys_setting.rear_end_t,
- m_sys_setting.over_count_person,
- m_sys_setting.over_count_vehicle,
- m_sys_setting.over_time_person,
- m_sys_setting.over_time_vehicle,
- m_sys_setting.over_speed,
- m_sys_setting.light_group_count,
- m_sys_setting.site_no_position_time
- );
- }
- Init_map_setting();
- return true;
- }
- bool CYaSetting::Init_map_setting()
- {
- m_sys_setting.mp_sid_solution.clear();
- m_sys_setting.mp_sids_index.clear();
- std::string Error;
- YADB::CDBResultSet DBRes;
- std::string sql = "select site_list, solution from dat_map_zhurong;";
- sDBConnPool.Query(sql.c_str(), DBRes, Error);
- int nCount = DBRes.GetRecordCount(Error);
- if (nCount > 0)
- {
- while (DBRes.GetNextRecod(Error))
- {
- std::string strVal = "";
- std::string val = "";
- DBRes.GetField("site_list", strVal, Error);
- std::vector<std::string> vt_sid;
- boost::split(vt_sid, strVal, boost::is_any_of(","));
- int nSolution = 0;
- DBRes.GetField("solution", nSolution, Error);
- int nResultIndex = 1;
- for (auto iter0 = vt_sid.begin(); iter0 != vt_sid.end(); iter0++)
- {
- m_sys_setting.mp_sid_solution.insert(std::make_pair(atoi(iter0->c_str()), nSolution));
- for (auto iter1 = iter0 + 1; iter1 != vt_sid.end(); ++iter1)
- {
- for (auto iter2 = iter1 + 1; iter2 != vt_sid.end(); ++iter2, ++nResultIndex)
- {
- if (nSolution == 0)
- {
- m_sys_setting.mp_sids_index.insert(std::make_pair(*iter0 + ',' + *iter1 + ',' + *iter2, 0));
- }
- else
- {
- m_sys_setting.mp_sids_index.insert(std::make_pair(*iter0 + ',' + *iter1 + ',' + *iter2, nResultIndex));
- }
- }
- }
- }
- }
- }
- return true;
- }
- void ios_service::start_service_position(const int& port)
- {
- m_ios_service = service_position_ptr(new service_position_ptr::element_type());
- m_ios_service->set_port(port);
- m_ios_service->start();
- }
|