Browse Source

督办状态及时恢复

baiwenju 2 years ago
parent
commit
209527dd31

+ 12 - 3
MidWare_WinStandard1.0-zmd/ACD/AcdCore.cpp

@@ -364,6 +364,12 @@ void CAcdCore::__onCmdAgentLogout( CPduEntity* a_pCmd )
364 364
 	// 显示日志
365 365
 	ILogger::getInstance().log(LOG_CLASS_SOCKET, LOG_LEVEL_NORMAL, _T("{Core}: AGENT -> ACD, CMD = [座席签出], Agent = %lu, Exten = %lu"), AgentId, ExtId);
366 366
 
367
+	//2023-10-08  判断分机是否是督办部门分机,是更新离线,成功,说明是督办
368
+	if (m_DepttelextOffice.UpdateDepttelext(ExtId, 8)) {
369
+		return;
370
+	}
371
+
372
+
367 373
 	// ych 2018.5.16
368 374
 	//  m_AgentOffice.setAgentState(AgentId, AGENT_STATE_LOGOUT);
369 375
 	if (m_AgentOffice.setAgentState(AgentId, AGENT_STATE_LOGOUT))
@@ -401,10 +407,13 @@ void CAcdCore::__onCmdAgentSetState( CPduEntity* a_pCmd )
401 407
 	// 得到座席信息
402 408
 	UINT AgentId = a_pCmd->GetDataUInt(2);
403 409
 	AGENT_STATE State = static_cast<AGENT_STATE>(a_pCmd->GetDataUInt(3));
404
-
410
+	UINT ExtID = a_pCmd->GetDataUInt(1);
405 411
 	// 显示日志
406
-	ILogger::getInstance().log(LOG_CLASS_SOCKET, LOG_LEVEL_NORMAL, _T("{Core}: AGENT -> ACD, CMD = [座席状态设置], Agent = %lu, State = %d"), AgentId, State);
407
-
412
+	ILogger::getInstance().log(LOG_CLASS_SOCKET, LOG_LEVEL_NORMAL, _T("{Core}: AGENT -> ACD, CMD = [座席状态设置], Agent = %lu,Exten = %lu State = %d"), AgentId, ExtID, State);
413
+	
414
+	if (State == 2 && m_DepttelextOffice.UpdateDepttelext(ExtID, 1)) {
415
+		return;
416
+	}
408 417
 	// 设置座席逻辑状态
409 418
 	if(m_AgentOffice.setAgentState(AgentId, State))
410 419
 		a_pCmd->SetDataBool(0, true);

+ 19 - 5
MidWare_WinStandard1.0-zmd/ACD/DepttelextOffice.cpp

@@ -49,29 +49,34 @@ bool CDepttelextOffice::InitDepttelext()
49 49
 
50 50
 	ILogger::getInstance().log(LOG_CLASS_BUSI, LOG_LEVEL_NORMAL, _T("{CDepttelextOffice}: 分机号码列表结束初始化"));
51 51
 	IOtlRecordset::DestroyInstance(record);		// 释放记录集
52
+
53
+	// 定时器初始化
54
+	//m_PollTimer.SetTimedEvent(this, &CDepttelextOffice::__onTimerPoll);
55
+	//m_PollTimer.Start(1000 * 60);   // 每分钟一次
56
+
52 57
 	return true;
53 58
 }
54 59
 
55
-void CDepttelextOffice::UpdateDepttelext(UINT extno, int state)
60
+bool CDepttelextOffice::UpdateDepttelext(UINT extno, int state)
56 61
 {
57 62
 	auto it = m_DeptTelextmap.find(extno);
58
-	if (it == m_DeptTelextmap.end()) return;
63
+	if (it == m_DeptTelextmap.end()) return false;
59 64
 	if (it->second) {
60
-		it->second->State = state;
65
+		it->second->UpdateState(state);
61 66
 	}
67
+	return true;
62 68
 }
63 69
 
64 70
 std::string CDepttelextOffice::GetAllDeptTelext()
65 71
 {
66 72
 	Json::Value root;
67
-	Json::Value body;
68 73
 	Json::FastWriter writer;
69
-
70 74
 	auto it = m_DeptTelextmap.begin();
71 75
 	DeptTelext *pDeptTelext = nullptr;
72 76
 	while (it != m_DeptTelextmap.end()){
73 77
 		pDeptTelext = it->second;
74 78
 		if (pDeptTelext) {
79
+			Json::Value body;
75 80
 			body["Name"] = pDeptTelext->Name.GetBuffer(0);
76 81
 			body["Telephone"] = pDeptTelext->Telephone.GetBuffer(0);
77 82
 			body["AgentExten"] = pDeptTelext->Extension.GetBuffer(0);
@@ -82,3 +87,12 @@ std::string CDepttelextOffice::GetAllDeptTelext()
82 87
 	}
83 88
 	return writer.write(root);
84 89
 }
90
+
91
+void CDepttelextOffice::__onTimerPoll(void)
92
+{
93
+	auto it = m_DeptTelextmap.begin();
94
+	DeptTelext *pDeptTelext = nullptr;
95
+	while (it != m_DeptTelextmap.end()) {
96
+		 it->second->UpdateTimeCount();
97
+	}
98
+}

+ 33 - 1
MidWare_WinStandard1.0-zmd/ACD/DepttelextOffice.h

@@ -2,6 +2,8 @@
2 2
 #include <map>
3 3
 #include <string>
4 4
 #include <iostream>
5
+#include <atomic>
6
+#include <TemplateTimer.h>
5 7
 
6 8
 class CDepttelextOffice
7 9
 {
@@ -10,10 +12,14 @@ public:
10 12
 	~CDepttelextOffice();
11 13
 
12 14
 	bool InitDepttelext();
13
-	void UpdateDepttelext(UINT extno, int state);
15
+	bool UpdateDepttelext(UINT extno, int state);
14 16
 	std::string GetAllDeptTelext();
15 17
 
16 18
 private:
19
+	// 定时器处理
20
+	void __onTimerPoll(void);			// 轮询处理
21
+
22
+private:
17 23
 	typedef struct tagtel_depttelext {
18 24
 		int Id;
19 25
 		CString Name;
@@ -21,11 +27,37 @@ private:
21 27
 		CString Extension;
22 28
 		CString AgentID;
23 29
 		int State;
30
+		std::atomic<std::int64_t> TimeCount;
31
+		
32
+		tagtel_depttelext() {
33
+			State = 8;
34
+			TimeCount.store(0);
35
+		}
36
+		void UpdateState(int state) {
37
+			this->State = state;
38
+			if (this->State == 1) { // 空闲开始计时时间
39
+				this->TimeCount.store(0);
40
+			}
41
+		}
42
+		void UpdateTimeCount() {
43
+			if (this->State == 1) { // 空闲就计时时间
44
+				auto tCount = this->TimeCount.load() + 1;
45
+				if (tCount > 19) { // 空闲时间超过,状态改为8-离线
46
+					this->State = 8;
47
+				}
48
+				else {
49
+					this->TimeCount.store(tCount);
50
+				}
51
+			}
52
+		}
24 53
 		void print() {
25 54
 			std::cout << Name << "-" << Telephone << "-" << Extension << "-" << AgentID << "-" << State << std::endl;
26 55
 		}
27 56
 	}DeptTelext;
28 57
 
29 58
 	std::map<UINT, DeptTelext*> m_DeptTelextmap;  // 2022-09-01
59
+
60
+	TTimer<CDepttelextOffice> m_PollTimer;  // 定时检测是否更改状态为签出
61
+
30 62
 };
31 63
 

+ 6 - 2
MidWare_WinStandard1.0-zmd/ACD/VideoOffice.cpp

@@ -60,16 +60,20 @@ bool CVideoOffice::findVideoExten(uint32_t & a_VideoExtId, std::string & a_Video
60 60
 
61 61
 bool CVideoOffice::recoverVideoExten(uint32_t a_VideoExtId, bool bIsRm)
62 62
 {
63
+	bool ret = false;
63 64
 	std::unique_lock<std::mutex> lock(mut);
64 65
 	auto it = m_VideoExtens.find(a_VideoExtId);
65 66
 	if (it != m_VideoExtens.end())
66 67
 	{
68
+		ret = true;
67 69
 		it->second->isUsed() = false;
68 70
 		if (!bIsRm)
69 71
 			ILogger::getInstance().log(LOG_CLASS_BUSI, LOG_LEVEL_NORMAL, _T("{CVideoOffice}: 释放视频分机号[%lu]状态[%s]"), a_VideoExtId, it->second->isUsed() ? "不可用" : "可用");
70 72
 		else
71 73
 			ILogger::getInstance().log(LOG_CLASS_BUSI, LOG_LEVEL_NORMAL, _T("{CVideoOffice}: 释放视频分机号[%lu]状态[%s],话机取消注册"), a_VideoExtId, it->second->isUsed() ? "不可用" : "可用");
72
-
74
+	}
75
+	else {
76
+		return ret;
73 77
 	}
74 78
 	
75 79
 	{
@@ -83,7 +87,7 @@ bool CVideoOffice::recoverVideoExten(uint32_t a_VideoExtId, bool bIsRm)
83 87
 		}
84 88
 		ILogger::getInstance().log(LOG_CLASS_BUSI, LOG_LEVEL_NORMAL, _T("{CVideoOffice}: 视频分机信息\n[%s]"),str.GetBuffer(0));
85 89
 	}
86
-	return true;
90
+	return ret;
87 91
 }
88 92
 
89 93
 void CVideoOffice::close()