中航光电的中间件仓库

Agent.h 5.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. /*************************************************************************
  2. 【文件名】 Agent.h
  3. 【功能模块和目的】 座席类头文件
  4. 【开发者及日期】 郑石诺 2015/01/19
  5. 【版本】 V1.0.0
  6. 【版权信息】 Copyright (C)2015 河南华谊网络科技有限公司
  7. 【更改记录】
  8. *************************************************************************/
  9. #pragma once
  10. #include <atomic>
  11. #include "TemplateTimer.h"
  12. //class CAgentProperty // ych 2018.5.4
  13. //{
  14. //public:
  15. // CTime m_FirstLogTimeToday;
  16. // // 业务属性
  17. // UINT m_TimePostProcessing; // 话后处理时长
  18. // UINT m_AnswerCount; // 应答次数
  19. // UINT m_ReposeCount; // 小休次数
  20. // UINT m_TimeFree; // 空闲时长
  21. // UINT m_TimeRepos; // 小休时长
  22. // UINT m_TimeTalk; // 通话时长
  23. //};
  24. /*************************************************************************
  25. 【类名】 CAgent
  26. 【功能】
  27. 【接口说明】 座席类
  28. 【开发者及日期】 郑石诺 2015/01/19
  29. 【版本】 V1.0.0
  30. 【版权信息】 Copyright (C)2015 河南华谊网络科技有限公司
  31. 【更改记录】
  32. *************************************************************************/
  33. class CAgent
  34. {
  35. public:
  36. CAgent(UINT a_AgentID, UINT a_ExtID, LPCTSTR a_GroupID, UINT a_AgentType, UINT a_PostProcessingTime);
  37. //CAgent(UINT a_AgentID, UINT a_ExtID, LPCTSTR a_GroupID, UINT a_AgentType, const CAgentProperty& AgentProperty); // ych 2018.5.4 2020-03-05 屏蔽
  38. ~CAgent(void);
  39. // 清理资源
  40. void release(UINT HostAgent);
  41. // 座席是否空闲
  42. bool isFree(void) const { return (m_State == AGENT_STATE_FREE && m_AssoExtState == INNER_STATE_FREE && !m_IsRepose); }
  43. bool isFreeForCall(void) const { return (m_State == AGENT_STATE_FREE && m_AssoExtState == INNER_STATE_FREE/* && !m_IsRepose*/); } // 安图拷贝
  44. // 属性操作
  45. BOOL setState(AGENT_STATE a_AgentState, bool IsForce = false); // 设置座席的逻辑状态
  46. /*2020-04-03 安图复制,解决置忙情况下外呼后状态为置忙 start*/
  47. BOOL setFreeForAgentCall(bool IsForce = false);
  48. BOOL setRequestedForAgentCall(bool IsForce = false);
  49. BOOL setBusyForAgentCall(bool IsForce = false);
  50. BOOL setProcessingForAgentCall(bool IsForce = false);
  51. /* end*/
  52. void onAssoExtStatusUpdated(INNER_STATE a_ExtState, PARAM Param = NULL); // 关联分机状态更新的处理函数
  53. const CString& ip(void) const { return m_AgentIp; } // 读取座席的主机IP
  54. UINT assoExten(void) const { return m_Exten; } // 读取关联的分机ID
  55. UINT id(void) const { return m_AgentID; } // 读取座席工号
  56. LPCTSTR group(void) const { return m_GroupID; } // 读取座席组号
  57. //UINT answerCount(void) const { return m_AnswerCount; } // 读取应答次数
  58. //UINT freeTime(void) const { return m_TimeFree; } // 读取空闲时长
  59. /********2019-12-19************/
  60. UINT answerCount(void) const { return m_AnswerCount + m_AnswerCountOld; } // 读取应答次数
  61. UINT freeTime(void) const { return m_TimeFree + m_TimeFreeOld; } // 读取空闲时长
  62. UINT type(void) const { return m_AgentType; } // 读取坐席类型
  63. AGENT_STATE state(void) const { return m_State; } // 得到座席实际状态
  64. BOOL isRepose(void) const { return m_IsRepose; } // 读取座席是否置忙
  65. const AgentGroupNoList& groupNoList(void) const { return m_GroupNoList; }
  66. AgentGroupNoList& groupNoList(void) { return m_GroupNoList; }
  67. BOOL lock(void);
  68. BOOL lockForCall(void); // 安图拷贝
  69. //void GetAgentProperty(CAgentProperty& AgentProperty); // ych 2018.5.4 2020-03-05 屏蔽
  70. bool queueJump();
  71. private:
  72. // 统计处理
  73. void __reportLogin(); // 签出统计通知
  74. void __reportLogout(const UINT HostAgent); // 签出统计通知
  75. void __onStatusUpdate(AGENT_STATE State, bool StartFlag);
  76. void __reportStatus(void); // 上报座席当前状态
  77. // 定时器处理
  78. void __onTimerPoll(void); // 轮询处理
  79. void __onTimerPostProcessing(void); // 话后处理时长处理
  80. void __onTimerLock(void); // 座席被锁定超时处理
  81. void __setTimer(UINT TimmerId, UINT Elapse);
  82. void __killTimer(UINT TimmerId);
  83. private:
  84. // 定时器常量
  85. static const UINT TIMER_POST_PROCESSING = 1001; // 话后处理定时器ID
  86. static const UINT TIMER_LOCK_PERIOD = 1005; // 锁定定时器ID
  87. // 座席网络属性
  88. CString m_AgentIp; // 座席网络IP
  89. int m_AgentPort; // 座席网络端口号
  90. // 座席基本属性
  91. UINT m_AgentID; // 座席工号
  92. UINT m_Exten; // 关联分机号
  93. CString m_GroupID; // 座席组号
  94. AGENT_TYPE m_AgentType; // 座席类型
  95. AGENT_STATE m_State; // 座席状态
  96. INNER_STATE m_AssoExtState; // 关联分机状态
  97. bool m_IsRepose; // 是否小休
  98. AgentGroupNoList m_GroupNoList; // 座席组号列表
  99. bool m_bFirstQueue; //2018.6.11 for loop
  100. // 业务属性
  101. UINT m_TypePostProcessing; // 话后处理类型 0:自动 1:手动
  102. UINT m_TimePostProcessing; // 话后处理时长
  103. UINT m_AnswerCount; // 应答次数
  104. UINT m_ReposeCount; // 小休次数
  105. //UINT m_TimeFree; // 空闲时长
  106. std::atomic<UINT> m_TimeFree; // 空闲时长 // 2020-03-05 防止 定时器,挂断后该值置0时 该变量被同时操作
  107. UINT m_TimeRepos; // 小休时长
  108. UINT m_TimeTalk; // 通话时长
  109. /************2019-12-19 历史记录**************************/
  110. UINT m_AnswerCountOld; // 应答次数
  111. UINT m_ReposeCountOld; // 小休次数 暂不需要使用
  112. UINT m_TimeFreeOld; // 空闲时长
  113. UINT m_TimeReposOld; // 小休时长 暂不需要使用
  114. UINT m_TimeTalkOld; // 通话时长 暂不需要使用
  115. /**************************************/
  116. CCriticalSection m_Cs4Lock; // 座席锁用于多组分配、被叫前锁定
  117. TTimer<CAgent> m_PollTimer; // 轮询定时器
  118. TTimer<CAgent> m_AgentTimer; // 座席定时器,用于锁定和话后处理
  119. };