ya_setting.cpp 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. #define D_GetValue(K,N,X,PS) \
  21. if (DBRes.GetField( N,strVal, Error ))\
  22. {K = atoi(strVal.c_str()) * X;}\
  23. D_GetValue(m_sys_setting.over_count_person,"over_count_person",1,"人员井下超员")
  24. D_GetValue(m_sys_setting.over_count_vehicle,"over_count_vehicle",1,"车辆井下超员")
  25. D_GetValue(m_sys_setting.over_time_person,"over_time_person",60,"人员井下超时")
  26. D_GetValue(m_sys_setting.over_time_vehicle,"over_time_vehicle",60,"车辆井下超时")
  27. D_GetValue(m_sys_setting.over_speed,"over_speed",1,"车辆超速限值")
  28. D_GetValue(m_sys_setting.att_starttime_offset_staff,"att_starttime_offset_staff",60,"考勤开始时间向前偏移分钟数")
  29. D_GetValue(m_sys_setting.att_endtime_offset_staff,"att_endtime_offset_staff",60,"车辆考勤开始时间向前偏移分钟数")
  30. D_GetValue(m_sys_setting.att_starttime_offset_vehicle,"att_starttime_offset_vehicle",60,"车辆考勤结束时间向后偏移分钟数")
  31. D_GetValue(m_sys_setting.att_endtime_offset_vehicle,"att_endtime_offset_vehicle",60,"车辆考勤结束时间向后偏移分钟数")
  32. D_GetValue(m_sys_setting.att_person_thre_hour,"att_person_thre_hour",60*60,"")
  33. D_GetValue(m_sys_setting.rear_end_d,"rear_end_distance",1,"")
  34. D_GetValue(m_sys_setting.rear_end_t,"rear_end_time",1,"")
  35. D_GetValue(m_sys_setting.geofault_warn_dis,"geofault_warn",1,"")
  36. #undef D_GetValue
  37. }
  38. }
  39. return true;
  40. }