linux版本中间件

AgentDetail.cpp 3.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. #include "AgentDetail.h"
  2. #include <json/json.h>
  3. AgentDetailStatis::AgentDetailStatis()
  4. {
  5. m_AgentOnlineCount.store(0);
  6. m_AgentFreeCount.store(0);
  7. m_AgentSpeakCount.store(0);
  8. m_AgentReposeCount.store(0);
  9. m_TrunkCallInCount.store(0);
  10. }
  11. AgentDetailStatis::~AgentDetailStatis()
  12. {
  13. }
  14. AgentDetailStatis & AgentDetailStatis::operator=(const AgentDetailStatis & a)
  15. {
  16. // TODO: ÔÚ´Ë´¦²åÈë return Óï¾ä
  17. if (this == &a) {
  18. return *this;
  19. }
  20. this->m_AgentOnlineCount.store(a.m_AgentOnlineCount);
  21. this->m_AgentFreeCount.store(a.m_AgentFreeCount);
  22. this->m_AgentReposeCount.store(a.m_AgentReposeCount);
  23. this->m_AgentSpeakCount.store(a.m_AgentSpeakCount);
  24. this->m_TrunkCallInCount.store(a.m_TrunkCallInCount);
  25. return *this;
  26. }
  27. bool AgentDetailStatis::operator==(const AgentDetailStatis & a) const
  28. {
  29. if (this->m_AgentOnlineCount == a.m_AgentOnlineCount && this->m_AgentFreeCount == a.m_AgentFreeCount &&
  30. this->m_AgentReposeCount == a.m_AgentReposeCount && this->m_AgentSpeakCount == a.m_AgentSpeakCount &&
  31. this->m_TrunkCallInCount == a.m_TrunkCallInCount) {
  32. return true;
  33. }
  34. return false;
  35. }
  36. void AgentDetailStatis::setAgentOnlineCount(const std::int32_t & nCount)
  37. {
  38. m_AgentOnlineCount += nCount;
  39. if (m_AgentOnlineCount.load() < 0) {
  40. m_AgentOnlineCount.store(0);
  41. }
  42. }
  43. void AgentDetailStatis::setAgentFreeCount(const std::int32_t & nCount)
  44. {
  45. m_AgentFreeCount += nCount;
  46. if (m_AgentFreeCount.load() < 0) {
  47. m_AgentFreeCount.store(0);
  48. }
  49. }
  50. void AgentDetailStatis::setAgentSpeakCount(const std::int32_t & nCount)
  51. {
  52. m_AgentSpeakCount += nCount;
  53. if (m_AgentSpeakCount.load() < 0) {
  54. m_AgentSpeakCount.store(0);
  55. }
  56. }
  57. void AgentDetailStatis::setAgentReposeCount(const std::int32_t & nCount)
  58. {
  59. m_AgentReposeCount += nCount;
  60. if (m_AgentReposeCount.load() < 0) {
  61. m_AgentReposeCount.store(0);
  62. }
  63. }
  64. void AgentDetailStatis::setTrunkCallInCount(const std::int32_t & nCount)
  65. {
  66. m_TrunkCallInCount += nCount;
  67. if (m_TrunkCallInCount.load() < 0) {
  68. m_TrunkCallInCount.store(0);
  69. }
  70. }
  71. void AgentDetailStatis::resetAgent()
  72. {
  73. m_AgentOnlineCount.store(0);
  74. m_AgentFreeCount.store(0);
  75. m_AgentSpeakCount.store(0);
  76. m_AgentReposeCount.store(0);
  77. }
  78. void AgentDetailStatis::resetAgentOnlineCount()
  79. {
  80. m_AgentOnlineCount.store(0);
  81. }
  82. void AgentDetailStatis::resetAgentFreeCount()
  83. {
  84. m_AgentFreeCount.store(0);
  85. }
  86. void AgentDetailStatis::resetAgentSpeakCount()
  87. {
  88. m_AgentSpeakCount.store(0);
  89. }
  90. void AgentDetailStatis::resetAgentReposeCount()
  91. {
  92. m_AgentReposeCount.store(0);
  93. }
  94. void AgentDetailStatis::resetTrunkCallInCount()
  95. {
  96. m_TrunkCallInCount.store(0);
  97. }
  98. std::string AgentDetailStatis::to_string()
  99. {
  100. Json::Value root;
  101. Json::StreamWriterBuilder jsrocd;
  102. std::unique_ptr<Json::StreamWriter> write(jsrocd.newStreamWriter());
  103. Json::OStringStream os;
  104. root["Type"] = "GetAgentDetail";
  105. root["Result"] = true;
  106. root["AgentSpeakCount"] = this->m_AgentSpeakCount.load();
  107. root["AgentOnlineCount"] = this->m_AgentOnlineCount.load();
  108. root["AgentReposeCount"] = this->m_AgentReposeCount.load();
  109. root["AgentFreeCount"] = this->m_AgentFreeCount.load();
  110. root["TrunkCallInCount"] = this->m_TrunkCallInCount.load();
  111. write->write(root, &os);
  112. return os.str();
  113. }