| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131 |
- #include "AgentDetail.h"
- #include <json/json.h>
- AgentDetailStatis::AgentDetailStatis()
- {
- m_AgentOnlineCount.store(0);
- m_AgentFreeCount.store(0);
- m_AgentSpeakCount.store(0);
- m_AgentReposeCount.store(0);
- m_TrunkCallInCount.store(0);
- }
- AgentDetailStatis::~AgentDetailStatis()
- {
- }
- AgentDetailStatis & AgentDetailStatis::operator=(const AgentDetailStatis & a)
- {
- // TODO: ÔÚ´Ë´¦²åÈë return Óï¾ä
- if (this == &a) {
- return *this;
- }
- this->m_AgentOnlineCount.store(a.m_AgentOnlineCount);
- this->m_AgentFreeCount.store(a.m_AgentFreeCount);
- this->m_AgentReposeCount.store(a.m_AgentReposeCount);
- this->m_AgentSpeakCount.store(a.m_AgentSpeakCount);
- this->m_TrunkCallInCount.store(a.m_TrunkCallInCount);
- return *this;
- }
- bool AgentDetailStatis::operator==(const AgentDetailStatis & a) const
- {
- if (this->m_AgentOnlineCount == a.m_AgentOnlineCount && this->m_AgentFreeCount == a.m_AgentFreeCount &&
- this->m_AgentReposeCount == a.m_AgentReposeCount && this->m_AgentSpeakCount == a.m_AgentSpeakCount &&
- this->m_TrunkCallInCount == a.m_TrunkCallInCount) {
- return true;
- }
- return false;
- }
- void AgentDetailStatis::setAgentOnlineCount(const std::int32_t & nCount)
- {
- m_AgentOnlineCount += nCount;
- if (m_AgentOnlineCount.load() < 0) {
- m_AgentOnlineCount.store(0);
- }
- }
- void AgentDetailStatis::setAgentFreeCount(const std::int32_t & nCount)
- {
- m_AgentFreeCount += nCount;
- if (m_AgentFreeCount.load() < 0) {
- m_AgentFreeCount.store(0);
- }
- }
- void AgentDetailStatis::setAgentSpeakCount(const std::int32_t & nCount)
- {
- m_AgentSpeakCount += nCount;
- if (m_AgentSpeakCount.load() < 0) {
- m_AgentSpeakCount.store(0);
- }
- }
- void AgentDetailStatis::setAgentReposeCount(const std::int32_t & nCount)
- {
- m_AgentReposeCount += nCount;
- if (m_AgentReposeCount.load() < 0) {
- m_AgentReposeCount.store(0);
- }
- }
- void AgentDetailStatis::setTrunkCallInCount(const std::int32_t & nCount)
- {
- m_TrunkCallInCount += nCount;
- if (m_TrunkCallInCount.load() < 0) {
- m_TrunkCallInCount.store(0);
- }
- }
- void AgentDetailStatis::resetAgent()
- {
- m_AgentOnlineCount.store(0);
- m_AgentFreeCount.store(0);
- m_AgentSpeakCount.store(0);
- m_AgentReposeCount.store(0);
- }
- void AgentDetailStatis::resetAgentOnlineCount()
- {
- m_AgentOnlineCount.store(0);
- }
- void AgentDetailStatis::resetAgentFreeCount()
- {
- m_AgentFreeCount.store(0);
- }
- void AgentDetailStatis::resetAgentSpeakCount()
- {
- m_AgentSpeakCount.store(0);
- }
- void AgentDetailStatis::resetAgentReposeCount()
- {
- m_AgentReposeCount.store(0);
- }
- void AgentDetailStatis::resetTrunkCallInCount()
- {
- m_TrunkCallInCount.store(0);
- }
- std::string AgentDetailStatis::to_string()
- {
- Json::Value root;
- Json::StreamWriterBuilder jsrocd;
- std::unique_ptr<Json::StreamWriter> write(jsrocd.newStreamWriter());
- Json::OStringStream os;
- root["Type"] = "GetAgentDetail";
- root["Result"] = true;
- root["AgentSpeakCount"] = this->m_AgentSpeakCount.load();
- root["AgentOnlineCount"] = this->m_AgentOnlineCount.load();
- root["AgentReposeCount"] = this->m_AgentReposeCount.load();
- root["AgentFreeCount"] = this->m_AgentFreeCount.load();
- root["TrunkCallInCount"] = this->m_TrunkCallInCount.load();
- write->write(root, &os);
- return os.str();
- }
|