ya_setting.cpp 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #include "ya_setting.h"
  2. #include "db_api/CDBSingletonDefine.h"
  3. SSys_setting CYaSetting::m_sys_setting;
  4. /*
  5. * 从数据库的dat_setting表初始化系统阈值,
  6. * 包括:井下人员阈值,井下车辆阈值,人员超时阈值,车辆超时阈值,车辆超速阈值
  7. */
  8. bool CYaSetting::Init_sys_setting()
  9. {
  10. std::string Error;
  11. YADB::CDBResultSet DBRes;
  12. std::string sql = "select setting_id, name, type, value from dat_setting;";
  13. sDBConnPool.Query(sql.c_str(),DBRes,Error);
  14. int nCount = DBRes.GetRecordCount( Error );
  15. if (nCount > 0)
  16. {
  17. while ( DBRes.GetNextRecod(Error) )
  18. {
  19. std::string strVal = "";
  20. std::string name = "";
  21. DBRes.GetField( "name",name, Error );
  22. #define D_GetValue(K,N,X,PS) \
  23. if(name == N){\
  24. DBRes.GetField( "value",strVal, Error );\
  25. K = atoi(strVal.c_str()) * X;\
  26. }\
  27. D_GetValue(m_sys_setting.over_count_person,"over_count_person",1,"人员井下超员")
  28. D_GetValue(m_sys_setting.over_count_vehicle,"over_count_vehicle",1,"车辆井下超员")
  29. D_GetValue(m_sys_setting.over_time_person,"over_time_person",60,"人员井下超时")
  30. D_GetValue(m_sys_setting.over_time_vehicle,"over_time_vehicle",60,"车辆井下超时")
  31. D_GetValue(m_sys_setting.over_speed,"over_speed",1,"车辆超速限值")
  32. D_GetValue(m_sys_setting.att_starttime_offset_staff,"att_starttime_offset_staff",60,"考勤开始时间向前偏移分钟数")
  33. D_GetValue(m_sys_setting.att_endtime_offset_staff,"att_endtime_offset_staff",60,"车辆考勤开始时间向前偏移分钟数")
  34. D_GetValue(m_sys_setting.att_starttime_offset_vehicle,"att_starttime_offset_vehicle",60,"车辆考勤结束时间向后偏移分钟数")
  35. D_GetValue(m_sys_setting.att_endtime_offset_vehicle,"att_endtime_offset_vehicle",60,"车辆考勤结束时间向后偏移分钟数")
  36. D_GetValue(m_sys_setting.att_person_thre_hour,"att_person_thre_hour",60*60,"")
  37. D_GetValue(m_sys_setting.rear_end_d,"rear_end_distance",1,"")
  38. D_GetValue(m_sys_setting.rear_end_t,"rear_end_time",1,"")
  39. D_GetValue(m_sys_setting.geofault_warn_dis,"geofault_warn",1,"")
  40. #undef D_GetValue
  41. }
  42. }
  43. return true;
  44. }