升龙物业 老版本 ocx IPO, 加密狗 转值班电话

QueueMgr.cpp 7.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  1. #include "StdAfx.h"
  2. #include "QueueMgr.h"
  3. #include "Queue.h"
  4. #include "AgentOffice.h"
  5. #include "IncomingCall.h"
  6. #include "Agent.h"
  7. CQueueMgr::CQueueMgr(void)
  8. {
  9. }
  10. CQueueMgr::~CQueueMgr(void)
  11. {
  12. __freeQueues();
  13. }
  14. /*****************************************************************
  15. **【函数名称】 __getQueue
  16. **【函数功能】 获取指定来电队列
  17. **【参数】
  18. **【返回值】
  19. ****************************************************************/
  20. CQueue* CQueueMgr::__getQueue( int QueueNo, bool NewWhenNull /*= false*/ )
  21. {
  22. for(int i = 0; i < m_QueueArray.GetCount(); ++i)
  23. {
  24. CQueue* pQueue = m_QueueArray[i];
  25. ASSERT(pQueue != NULL);
  26. if(pQueue->no() == QueueNo)
  27. return pQueue;
  28. }
  29. if(NewWhenNull)
  30. {
  31. CQueue* pQueue = new CQueue(QueueNo);
  32. m_QueueArray.Add(pQueue);
  33. return pQueue;
  34. }
  35. return NULL;
  36. }
  37. /*****************************************************************
  38. **【函数名称】 __freeQueues
  39. **【函数功能】 释放所有来电队列
  40. **【参数】
  41. **【返回值】
  42. ****************************************************************/
  43. void CQueueMgr::__freeQueues( void )
  44. {
  45. for(int i = 0; i < m_QueueArray.GetCount(); ++i)
  46. {
  47. CQueue* pQueue = m_QueueArray[i];
  48. ASSERT(pQueue != NULL);
  49. pQueue->clear();
  50. delete pQueue;
  51. }
  52. m_QueueArray.RemoveAll();
  53. }
  54. /*****************************************************************
  55. **【函数名称】 onQueueAsking
  56. **【函数功能】 IVR请求座席命令响应
  57. **【参数】 pCmd: PDU命令内容
  58. pAgentOffice: 关联的座席管理类
  59. **【返回值】
  60. ****************************************************************/
  61. void CQueueMgr::onQueueAsking( CPduEntity* pCmd )
  62. {
  63. UINT QueueNo = pCmd->GetDataUInt(4);
  64. CQueue* pQueue = __getQueue(QueueNo, true);
  65. ASSERT(pQueue != NULL);
  66. ILogger::getInstance().log(LOG_CLASS_BUSI, LOG_LEVEL_NORMAL, "{Queue}: 来电请求排队, Index = %d, CallID = %lu, Group = %lu, VipLevel = %d, CallerNum = %s",
  67. pCmd->GetDataInt(1),
  68. pCmd->GetDataULong(2),
  69. QueueNo,
  70. pCmd->GetDataInt(5),
  71. pCmd->GetDataString(6));
  72. pQueue->onQueueRequest(pCmd);
  73. }
  74. /*****************************************************************
  75. **【函数名称】 onQueueCancel
  76. **【函数功能】 IVR继续请求排队命令响应
  77. **【参数】 pCmd: PDU命令内容
  78. pAgentOffice: 关联的座席管理类
  79. **【返回值】
  80. ****************************************************************/
  81. void CQueueMgr::onQueueCancel( CPduEntity* pCmd )
  82. {
  83. ILogger::getInstance().log(LOG_CLASS_BUSI, LOG_LEVEL_NORMAL, "{Queue}: 来电取消排队, Index = %d, CallId = %lu",
  84. pCmd->GetDataInt(1),
  85. pCmd->GetDataULong(2));
  86. for(int i = 0; i < m_QueueArray.GetCount(); ++i)
  87. {
  88. if(m_QueueArray[i]->onQueueCancel(pCmd))
  89. return;
  90. }
  91. }
  92. /*****************************************************************
  93. **【函数名称】 onQueueContinue
  94. **【函数功能】 IVR继续请求排队命令响应
  95. **【参数】 pCmd: 命令内容
  96. pAgentOffice: 关联的座席管理类
  97. **【返回值】
  98. ****************************************************************/
  99. void CQueueMgr::onQueueContinue( CPduEntity* pCmd )
  100. {
  101. ILogger::getInstance().log(LOG_CLASS_BUSI, LOG_LEVEL_NORMAL, "{Queue}: 来电继续排队, Index = %d, CallId = %lu, CallerNum = %s",
  102. pCmd->GetDataInt(1),
  103. pCmd->GetDataULong(2),
  104. pCmd->GetDataString(4));
  105. for(int i = 0; i < m_QueueArray.GetCount(); ++i)
  106. {
  107. if(m_QueueArray[i]->onQueueContinue(pCmd))
  108. return;
  109. }
  110. }
  111. /*****************************************************************
  112. **【函数名称】 onQueuePause
  113. **【函数功能】 IVR暂停排队命令响应
  114. **【参数】 pCmd: PDU命令内容
  115. pAgentOffice: 关联的座席管理类
  116. **【返回值】
  117. ****************************************************************/
  118. void CQueueMgr::onQueuePause( CPduEntity* pCmd )
  119. {
  120. ILogger::getInstance().log(LOG_CLASS_BUSI, LOG_LEVEL_NORMAL, "{Queue}: 来电暂停排队, Index = %d", pCmd->GetDataInt(0));
  121. for(int i = 0; i < m_QueueArray.GetCount(); ++i)
  122. {
  123. if(m_QueueArray[i]->onQueuePause(pCmd))
  124. return;
  125. }
  126. }
  127. /*****************************************************************
  128. **【函数名称】 callCount
  129. **【函数功能】 读取等待排队的来电数量
  130. **【参数】
  131. **【返回值】
  132. ****************************************************************/
  133. UINT CQueueMgr::callCount( void )
  134. {
  135. UINT Count = 0;
  136. for(int i = 0; i < m_QueueArray.GetCount(); ++i)
  137. {
  138. Count += m_QueueArray[i]->callCount();
  139. }
  140. return Count;
  141. }
  142. /*****************************************************************
  143. **【函数名称】 callCount
  144. **【函数功能】 读取等待排队的来电数量
  145. **【参数】
  146. **【返回值】
  147. ****************************************************************/
  148. UINT CQueueMgr::callCount( UINT QueueNo )
  149. {
  150. CQueue* pQueue = __getQueue(QueueNo);
  151. if(pQueue != NULL)
  152. return pQueue->callCount();
  153. else
  154. return 0;
  155. }
  156. /*****************************************************************
  157. **【函数名称】 clear
  158. **【函数功能】 释放资源
  159. **【参数】
  160. **【返回值】
  161. ****************************************************************/
  162. void CQueueMgr::clear( void )
  163. {
  164. __freeQueues();
  165. }
  166. /*****************************************************************
  167. **【函数名称】 getCallInfo
  168. **【函数功能】 获取指定呼叫的相关信息用于UI展现
  169. **【参数】
  170. **【返回值】
  171. ****************************************************************/
  172. bool CQueueMgr::getCallInfo( Call2Show& Info )
  173. {
  174. for(int i = 0; i < m_QueueArray.GetCount(); ++i)
  175. {
  176. if(m_QueueArray[i]->getCallInfo(Info))
  177. return true;
  178. }
  179. return false;
  180. }
  181. /*****************************************************************
  182. **【函数名称】 addAgent
  183. **【函数功能】 添加座席
  184. **【参数】
  185. **【返回值】
  186. ****************************************************************/
  187. void CQueueMgr::addAgent( CAgent* pAgent )
  188. {
  189. ASSERT(pAgent != NULL);
  190. UINT GroupNo = 0;
  191. TCHAR AgentGroup[AGENT_GROUP_BUF_LEN] = { 0 };
  192. lstrcpy(AgentGroup, pAgent->group());
  193. AgentGroupNoList& GrouNoList = pAgent->groupNoList();
  194. TCHAR* lpNext = NULL;
  195. TCHAR* lpToken = strtok_s(AgentGroup, AGENT_GROUP_SPLIT_FLAG, &lpNext);
  196. while(lpToken != NULL)
  197. {
  198. sscanf_s(lpToken, "%u", &GroupNo);
  199. CQueue* pQueue = __getQueue(GroupNo, true);
  200. ASSERT(pQueue != NULL);
  201. GrouNoList.AddTail(GroupNo);
  202. pQueue->addAgent(pAgent);
  203. lpToken = strtok_s(NULL, AGENT_GROUP_SPLIT_FLAG, &lpNext);
  204. }
  205. }
  206. /*****************************************************************
  207. **【函数名称】 delAgent
  208. **【函数功能】 删除座席
  209. **【参数】
  210. **【返回值】
  211. ****************************************************************/
  212. void CQueueMgr::delAgent( CAgent* pAgent )
  213. {
  214. AgentGroupNoList& GrouNoList = pAgent->groupNoList();
  215. POSITION Pos = GrouNoList.GetHeadPosition();
  216. while(Pos != NULL)
  217. {
  218. UINT GroupNo = GrouNoList.GetNext(Pos);
  219. CQueue* pQueue = __getQueue(GroupNo);
  220. if(pQueue != NULL)
  221. pQueue->delAgent(pAgent);
  222. }
  223. }
  224. /*****************************************************************
  225. **【函数名称】 onAgentFree
  226. **【函数功能】 座席的处理函数
  227. **【参数】
  228. **【返回值】
  229. ****************************************************************/
  230. void CQueueMgr::onAgentFree( CAgent* pAgent )
  231. {
  232. CQueue* pQueueDst = NULL;
  233. UINT CallCountMax = 0;
  234. AgentGroupNoList& GrouNoList = pAgent->groupNoList();
  235. // 查找排队呼叫最多的队列
  236. POSITION Pos = GrouNoList.GetHeadPosition();
  237. while(Pos != NULL)
  238. {
  239. UINT GroupNo = GrouNoList.GetNext(Pos);
  240. CQueue* pQueue = __getQueue(GroupNo);
  241. ASSERT(pQueue != NULL);
  242. UINT CallCout = pQueue->callCount();
  243. if(CallCout > CallCountMax)
  244. {
  245. pQueueDst = pQueue;
  246. CallCountMax = CallCout;
  247. }
  248. }
  249. if(CallCountMax > 0)
  250. pQueueDst->distributeAgent();
  251. }