|
|
@@ -186,82 +186,67 @@ void CFsProxy::onChanStateUpdate(long OpInstance, VirtualChan * pChan)
|
|
186
|
186
|
}
|
|
187
|
187
|
Format fmt("lineType = %s[%s],lineState = %s,chanState = %d");
|
|
188
|
188
|
fmt % lineType % chanNo % state % chanState;
|
|
189
|
|
- LOG_DEBUG_S(fmt.str())
|
|
|
189
|
+ LOG_DEBUG_S(fmt.str());
|
|
190
|
190
|
|
|
191
|
|
- if (devType == DEV_RES_TYPE_EXT) {
|
|
192
|
|
- map<std::string, Agent*>::iterator it;
|
|
193
|
|
-
|
|
194
|
|
- std::unique_lock<std::mutex>lock(m_AgentLock);
|
|
195
|
|
- it = m_MapAgent.find(chanNo);
|
|
196
|
|
-
|
|
197
|
|
- if (it != m_MapAgent.end())
|
|
198
|
|
- {
|
|
199
|
|
- if (it->second == nullptr)
|
|
200
|
|
- {
|
|
201
|
|
- LOG_DEBUG("查不到分机[%s]", chanNo.c_str());
|
|
202
|
|
- }
|
|
203
|
|
- else
|
|
204
|
|
- {
|
|
205
|
|
- LOG_DEBUG("查到分机[%s]", chanNo.c_str());
|
|
|
191
|
+ if (devType == DEV_RES_TYPE_EXT) {
|
|
|
192
|
+ map<std::string, Agent*>::iterator it;
|
|
|
193
|
+
|
|
|
194
|
+ std::unique_lock<std::mutex>lock(m_AgentLock);
|
|
|
195
|
+ it = m_MapAgent.find(chanNo);
|
|
|
196
|
+
|
|
|
197
|
+ if (it != m_MapAgent.end()) {
|
|
|
198
|
+ if (it->second == nullptr) {
|
|
|
199
|
+ LOG_WARN("查到分机[%s]对应坐席空", chanNo.c_str());
|
|
|
200
|
+ return;
|
|
|
201
|
+ }
|
|
|
202
|
+
|
|
|
203
|
+ if (chanState == CHAN_LOGIC_STATE_FREE) {
|
|
|
204
|
+ if (it->second->isRepose()) {
|
|
|
205
|
+ it->second->setState(AGENT_STATE_REPOSE);
|
|
|
206
|
+ state = it->second->state_s();
|
|
206
|
207
|
}
|
|
207
|
|
- if (chanState == CHAN_LOGIC_STATE_FREE && !it->second->isRepose()) {
|
|
|
208
|
+ else {
|
|
208
|
209
|
if (it->second->state() == AGENT_STATE_BUSY) {
|
|
209
|
210
|
__setStatePostProcessing(it->second->id()); // 在fs中设置坐席话后处理
|
|
210
|
211
|
it->second->setState(AGENT_STATE_POST_PROCESSING);
|
|
211
|
|
- state = "话后处理";
|
|
212
|
212
|
state = it->second->state_s();
|
|
213
|
213
|
}
|
|
214
|
214
|
else {
|
|
215
|
215
|
it->second->setState(AGENT_STATE_FREE);
|
|
216
|
216
|
}
|
|
217
|
217
|
}
|
|
218
|
|
- else if (chanState == CHAN_LOGIC_STATE_TALKING)
|
|
219
|
|
- it->second->setState(AGENT_STATE_BUSY);
|
|
220
|
|
- else if (chanState == CHAN_LOGIC_STATE_RING_BACK || chanState == CHAN_LOGIC_STATE_ALERTING)
|
|
221
|
|
- it->second->setState(AGENT_STATE_REQUESTED);
|
|
222
|
|
-
|
|
223
|
|
- if (it->second->isRepose() /*&& chanState == CHAN_LOGIC_STATE_FREE*/)
|
|
224
|
|
- {
|
|
225
|
|
- state = "小休";
|
|
226
|
|
- }
|
|
227
|
|
- /*else if (it->second->state() == AGENT_STATE_POST_PROCESSING)
|
|
228
|
|
- {
|
|
229
|
|
- state = it->second->state_s();
|
|
230
|
|
- __setStatePostProcessing(it->second->id());
|
|
231
|
|
- }*/
|
|
232
|
|
- if (!state.empty()) // 过滤掉保持状态
|
|
233
|
|
- {
|
|
234
|
|
- std::string data = creatJson("LineState", state);
|
|
235
|
|
- m_Server.sendMsg(it->second->hdl(), data);
|
|
236
|
|
-
|
|
237
|
|
- data = creatJson("Monitor", state, it->second->id(), chanNo);
|
|
238
|
|
- m_MonitAgents.loopAgent(m_Server, data); // 通知班长坐席监控
|
|
|
218
|
+ }
|
|
|
219
|
+ else if (chanState == CHAN_LOGIC_STATE_TALKING) {
|
|
|
220
|
+ it->second->setState(AGENT_STATE_BUSY);
|
|
|
221
|
+ }
|
|
|
222
|
+ else if (chanState == CHAN_LOGIC_STATE_RING_BACK || chanState == CHAN_LOGIC_STATE_ALERTING) {
|
|
|
223
|
+ if (AGENT_STATE_REQUESTED == it->second->state()) { // 当前状态已通知过,不在重复通知
|
|
|
224
|
+ return;
|
|
239
|
225
|
}
|
|
|
226
|
+ it->second->setState(AGENT_STATE_REQUESTED);
|
|
|
227
|
+ }
|
|
240
|
228
|
|
|
241
|
|
- __agentDetail(lock.release()); // 通知坐席详情变化
|
|
|
229
|
+ if (!state.empty()) { // 过滤掉保持状态
|
|
|
230
|
+ std::string data = creatJson("LineState", state);
|
|
|
231
|
+ m_Server.sendMsg(it->second->hdl(), data);
|
|
242
|
232
|
|
|
243
|
|
- // 坐席空闲且没有置忙 执行外呼 2022-06-28 不用自动外呼
|
|
244
|
|
- //if (it->second->state() == AGENT_STATE_FREE && !it->second->isRepose())
|
|
245
|
|
- //{
|
|
246
|
|
- // //LOG_DEBUG_S("进自动外呼等待");
|
|
247
|
|
- // m_AutoCall.waitTask(it->second->id());
|
|
248
|
|
- // //LOG_DEBUG_S("出自动外呼等待");
|
|
249
|
|
- //}
|
|
250
|
|
- }
|
|
251
|
|
- else
|
|
252
|
|
- {
|
|
253
|
|
- LOG_WARN("线路状态通知失败,找不到分机[%s]对应的坐席", chanNo.c_str());
|
|
|
233
|
+ data = creatJson("Monitor", state, it->second->id(), chanNo);
|
|
|
234
|
+ m_MonitAgents.loopAgent(m_Server, data); // 通知班长坐席监控
|
|
254
|
235
|
}
|
|
255
|
|
-
|
|
|
236
|
+ __agentDetail(lock.release()); // 通知坐席详情变化
|
|
256
|
237
|
}
|
|
257
|
|
- else if (devType == DEV_RES_TYPE_TRUNK) {
|
|
258
|
|
- if (CHAN_LOGIC_STATE_ALERTING == chanState) {
|
|
259
|
|
- __agentDetailTrunkChange(1); // 计算呼入数量
|
|
260
|
|
- }
|
|
261
|
|
- else if (CHAN_LOGIC_STATE_FREE == chanState) {
|
|
262
|
|
- __agentDetailTrunkChange(-1);
|
|
263
|
|
- }
|
|
|
238
|
+ else {
|
|
|
239
|
+ LOG_WARN("线路状态通知失败,找不到分机[%s]对应的坐席", chanNo.c_str());
|
|
|
240
|
+ }
|
|
|
241
|
+ }
|
|
|
242
|
+ else if (devType == DEV_RES_TYPE_TRUNK) {
|
|
|
243
|
+ if (CHAN_LOGIC_STATE_ALERTING == chanState) {
|
|
|
244
|
+ __agentDetailTrunkChange(1); // 计算呼入数量
|
|
264
|
245
|
}
|
|
|
246
|
+ else if (CHAN_LOGIC_STATE_FREE == chanState) {
|
|
|
247
|
+ __agentDetailTrunkChange(-1);
|
|
|
248
|
+ }
|
|
|
249
|
+ }
|
|
265
|
250
|
}
|
|
266
|
251
|
|
|
267
|
252
|
void CFsProxy::onChanPoor(Session * pSession, PCHAN_EVENT_NOTIFY pNotify)
|
|
|
@@ -270,6 +255,42 @@ void CFsProxy::onChanPoor(Session * pSession, PCHAN_EVENT_NOTIFY pNotify)
|
|
270
|
255
|
__kill(FS_LINK_JOBID_INVALID, pNotify->ChanId);
|
|
271
|
256
|
}
|
|
272
|
257
|
|
|
|
258
|
+void CFsProxy::onCallcenterQueue(const std::string & strQueueName, const std::string & strQueueCount)
|
|
|
259
|
+{
|
|
|
260
|
+ std::unique_lock<std::shared_mutex>lock(m_mutQueryCount);
|
|
|
261
|
+ m_QueryCount[strQueueName] = strQueueCount;
|
|
|
262
|
+ Json::Value root;
|
|
|
263
|
+ Json::StreamWriterBuilder jsrocd;
|
|
|
264
|
+ root["Type"] = "WaitCount";
|
|
|
265
|
+ root["Result"] = true;
|
|
|
266
|
+ std::int32_t nTotal = 0;
|
|
|
267
|
+
|
|
|
268
|
+ for (auto it = m_QueryCount.begin(); it != m_QueryCount.end(); ++it) {
|
|
|
269
|
+ root[it->first] = it->second;
|
|
|
270
|
+ try {
|
|
|
271
|
+ auto n = stoi(it->second);
|
|
|
272
|
+ nTotal += n;
|
|
|
273
|
+ }
|
|
|
274
|
+ catch (const std::exception& e) {
|
|
|
275
|
+ LOG_ERROR("坐席组[%s]数量[%s]转换失败:[%s]", it->first.c_str(), it->second.c_str(), e.what());
|
|
|
276
|
+ }
|
|
|
277
|
+ }
|
|
|
278
|
+
|
|
|
279
|
+ root["Total"] = nTotal;
|
|
|
280
|
+ auto strJson = Json::writeString(jsrocd, root);
|
|
|
281
|
+
|
|
|
282
|
+ // 发送给需要的坐席
|
|
|
283
|
+ for (auto it = m_subWaitCount.begin(); it != m_subWaitCount.end();) {
|
|
|
284
|
+ auto bOk = m_Server.sendMsg(*it, strJson);
|
|
|
285
|
+ if (bOk) {
|
|
|
286
|
+ ++it;
|
|
|
287
|
+ }
|
|
|
288
|
+ else {
|
|
|
289
|
+ it = m_subWaitCount.erase(it);
|
|
|
290
|
+ }
|
|
|
291
|
+ }
|
|
|
292
|
+}
|
|
|
293
|
+
|
|
273
|
294
|
void CFsProxy::onEslDisconnect(void)
|
|
274
|
295
|
{
|
|
275
|
296
|
// esl 断开重连
|
|
|
@@ -714,6 +735,31 @@ bool CFsProxy::transfer2Context(long JobId, std::string DestChanId, std::string
|
|
714
|
735
|
return m_Gateway.sendCmd(EslCmd);
|
|
715
|
736
|
}
|
|
716
|
737
|
|
|
|
738
|
+bool CFsProxy::setChannelVariable(long JobId, std::string DestChanId, std::string VarName, std::string Content)
|
|
|
739
|
+{
|
|
|
740
|
+ std::string EslCmd;
|
|
|
741
|
+ Format fmt("bgapi uuid_setvar %s %s %s\r\n%s: %ld");
|
|
|
742
|
+ fmt % DestChanId % VarName % Content % ESL_HEADER_JOB_UUID % JobId;
|
|
|
743
|
+ EslCmd = fmt.str();
|
|
|
744
|
+ bool ret = m_Gateway.sendCmd(EslCmd);
|
|
|
745
|
+ return ret;
|
|
|
746
|
+}
|
|
|
747
|
+
|
|
|
748
|
+bool CFsProxy::ExecteApp(std::string App, std::string Param, std::string ChanId)
|
|
|
749
|
+{
|
|
|
750
|
+ return m_Gateway.Execte(App.c_str(), Param.c_str(), ChanId.c_str());
|
|
|
751
|
+}
|
|
|
752
|
+
|
|
|
753
|
+bool CFsProxy::sendDtmf(long JobId, std::string DestChanId, std::string Content)
|
|
|
754
|
+{
|
|
|
755
|
+ std::string EslCmd;
|
|
|
756
|
+ Format fmt("bgapi uuid_send_dtmf %s %s\r\n%s: %ld");
|
|
|
757
|
+ fmt %DestChanId %Content %ESL_HEADER_JOB_UUID % JobId;
|
|
|
758
|
+ EslCmd = fmt.str();
|
|
|
759
|
+ bool ret = m_Gateway.sendCmd(EslCmd);
|
|
|
760
|
+ return ret;
|
|
|
761
|
+}
|
|
|
762
|
+
|
|
717
|
763
|
bool CFsProxy::getConferenceMemberId(std::string MeetingId, std::string ChanId, std::string & MemberId)
|
|
718
|
764
|
{
|
|
719
|
765
|
return m_Gateway.getConferenceMemberId(MeetingId, ChanId, MemberId);
|
|
|
@@ -782,6 +828,19 @@ std::string CFsProxy::creatJson(std::string type, bool result)
|
|
782
|
828
|
return os.str();
|
|
783
|
829
|
}
|
|
784
|
830
|
|
|
|
831
|
+std::string CFsProxy::creatJson(std::string type, bool result, std::string desc)
|
|
|
832
|
+{
|
|
|
833
|
+ Json::Value root;
|
|
|
834
|
+ Json::StreamWriterBuilder jsrocd;
|
|
|
835
|
+ std::unique_ptr<Json::StreamWriter> write(jsrocd.newStreamWriter());
|
|
|
836
|
+ Json::OStringStream os;
|
|
|
837
|
+ root["Type"] = type;
|
|
|
838
|
+ root["Result"] = result;
|
|
|
839
|
+ root["Desc"] = desc;
|
|
|
840
|
+ write->write(root, &os);
|
|
|
841
|
+ return os.str();
|
|
|
842
|
+}
|
|
|
843
|
+
|
|
785
|
844
|
std::string CFsProxy::creatJson(std::string type, std::string result, std::string agentId)
|
|
786
|
845
|
{
|
|
787
|
846
|
Format fmt("{ \"Type\":\"%s\",\"Result\":\"%s\",\"AgentID\":\"%s\" }");
|
|
|
@@ -1084,8 +1143,8 @@ bool CFsProxy::__login(std::string AgentID, std::string ExtenNo, std::list<std::
|
|
1084
|
1143
|
|
|
1085
|
1144
|
cmd = boost::str(Format("bgapi callcenter_config agent set max_no_answer %1% 0") % AgentID); // 0禁用
|
|
1086
|
1145
|
ret &= m_Gateway.sendCmd(cmd);
|
|
1087
|
|
- //cmd = boost::str(Format("bgapi callcenter_config agent set wrap_up_time %1% 20") % AgentID); // 话后处理时长
|
|
1088
|
|
- cmd = boost::str(Format("bgapi callcenter_config agent set wrap_up_time %1% %2%") % AgentID %CConfig::GetInstance()->postProcessTime());
|
|
|
1146
|
+ cmd = boost::str(Format("bgapi callcenter_config agent set wrap_up_time %1% 2") % AgentID); // 话后处理时长,2秒
|
|
|
1147
|
+ //cmd = boost::str(Format("bgapi callcenter_config agent set wrap_up_time %1% %2%") % AgentID %CConfig::GetInstance()->postProcessTime());
|
|
1089
|
1148
|
ret &= m_Gateway.sendCmd(cmd);
|
|
1090
|
1149
|
cmd = boost::str(Format("bgapi callcenter_config agent set reject_delay_time %1% 0") % AgentID);
|
|
1091
|
1150
|
ret &= m_Gateway.sendCmd(cmd);
|
|
|
@@ -1278,81 +1337,50 @@ void CFsProxy::__recvMsgFun(websocketpp::connection_hdl hdl, string msg)
|
|
1278
|
1337
|
return;
|
|
1279
|
1338
|
}
|
|
1280
|
1339
|
// 判断 坐席,分机是否已被签入
|
|
1281
|
|
- //{
|
|
1282
|
|
- std::unique_lock<std::mutex>lock(m_AgentLock);
|
|
|
1340
|
+ std::unique_lock<std::mutex>lock(m_AgentLock);
|
|
1283
|
1341
|
|
|
1284
|
|
- auto it = m_MapAgent.begin();
|
|
1285
|
|
- while (it != m_MapAgent.end()) {
|
|
1286
|
|
- if (it->second->id() == AgentID) {
|
|
1287
|
|
- Format fmt("坐席已被绑定,Agent = %s,Exten = %s");
|
|
1288
|
|
- fmt % AgentID % AgentExten;
|
|
1289
|
|
- LOG_INFO_S(fmt.str());
|
|
1290
|
|
- m_Server.sendMsg(hdl, creatJson(type, std::string("坐席已被绑定")));
|
|
1291
|
|
- return;
|
|
1292
|
|
- }
|
|
1293
|
|
- else if (it->first == AgentExten) {
|
|
1294
|
|
- Format fmt("分机已被绑定,Agent = %s,Exten = %s");
|
|
1295
|
|
- fmt % AgentID % AgentExten;
|
|
1296
|
|
- LOG_INFO_S(fmt.str());
|
|
1297
|
|
- m_Server.sendMsg(hdl, creatJson(type, std::string("分机已被绑定")));
|
|
1298
|
|
- return;
|
|
1299
|
|
- }
|
|
1300
|
|
- ++it;
|
|
|
1342
|
+ auto it = m_MapAgent.begin();
|
|
|
1343
|
+ while (it != m_MapAgent.end()) {
|
|
|
1344
|
+ if (it->second->id() == AgentID) {
|
|
|
1345
|
+ Format fmt("坐席已被绑定,Agent = %s,Exten = %s");
|
|
|
1346
|
+ fmt % AgentID % AgentExten;
|
|
|
1347
|
+ LOG_INFO_S(fmt.str());
|
|
|
1348
|
+ m_Server.sendMsg(hdl, creatJson(type, std::string("坐席已被绑定")));
|
|
|
1349
|
+ return;
|
|
1301
|
1350
|
}
|
|
1302
|
|
-
|
|
1303
|
|
- std::string AgentGroup = root["AgentGroup"].asString();
|
|
1304
|
|
- Agent *agent = new Agent(AgentID, AgentExten, AgentGroup);
|
|
1305
|
|
- agent->hdl() = hdl;
|
|
1306
|
|
- m_MapAgent[AgentExten] = agent; // 分机号作为key
|
|
1307
|
|
-
|
|
1308
|
|
- if (!__login(AgentID, AgentExten, agent->groups())){
|
|
1309
|
|
- m_MapAgent.erase(AgentExten);
|
|
1310
|
|
-
|
|
1311
|
|
- Format fmt("座席签入失败,Agent = %s,Exten = %d, %s");
|
|
1312
|
|
- fmt % AgentID % AgentExten % hdl.lock().get();
|
|
|
1351
|
+ else if (it->first == AgentExten) {
|
|
|
1352
|
+ Format fmt("分机已被绑定,Agent = %s,Exten = %s");
|
|
|
1353
|
+ fmt % AgentID % AgentExten;
|
|
1313
|
1354
|
LOG_INFO_S(fmt.str());
|
|
1314
|
|
- m_Server.sendMsg(hdl, creatJson(type, false));
|
|
|
1355
|
+ m_Server.sendMsg(hdl, creatJson(type, std::string("分机已被绑定")));
|
|
1315
|
1356
|
return;
|
|
1316
|
1357
|
}
|
|
1317
|
|
- Format fmt("座席签入成功,Agent = %s,Exten = %d,AgentGroup = %s %s");
|
|
1318
|
|
- fmt % AgentID % AgentExten % AgentGroup % hdl.lock().get();
|
|
1319
|
|
- LOG_INFO_S(fmt.str());
|
|
1320
|
|
- m_Server.sendMsg(hdl, creatJson(type, true));
|
|
1321
|
|
-
|
|
1322
|
|
- __agentDetail(lock.release()); // 通知坐席详情变化
|
|
1323
|
|
-
|
|
1324
|
|
- std::string data = creatJson("Monitor", "空闲", AgentID, AgentExten);
|
|
1325
|
|
- m_MonitAgents.loopAgent(m_Server, data); // 通知班长坐席监控
|
|
1326
|
|
- //}
|
|
1327
|
|
-
|
|
1328
|
|
- //std::string AgentGroup = root["AgentGroup"].asString();
|
|
1329
|
|
- //Agent *agent = new Agent(AgentID, AgentExten, AgentGroup);
|
|
1330
|
|
- //agent->hdl() = hdl;
|
|
1331
|
|
- //{
|
|
1332
|
|
- // std::unique_lock<std::mutex>lock(m_AgentLock);
|
|
1333
|
|
- // m_MapAgent[AgentExten] = agent; // 分机号作为key
|
|
1334
|
|
- //}
|
|
|
1358
|
+ ++it;
|
|
|
1359
|
+ }
|
|
1335
|
1360
|
|
|
1336
|
|
- //if (!__login(AgentID, AgentExten, agent->groups()))
|
|
1337
|
|
- //{
|
|
1338
|
|
- // m_MapAgent.erase(AgentExten);
|
|
|
1361
|
+ std::string AgentGroup = root["AgentGroup"].asString();
|
|
|
1362
|
+ Agent *agent = new Agent(AgentID, AgentExten, AgentGroup);
|
|
|
1363
|
+ agent->hdl() = hdl;
|
|
|
1364
|
+ m_MapAgent[AgentExten] = agent; // 分机号作为key
|
|
1339
|
1365
|
|
|
1340
|
|
- // Format fmt("座席签入失败,Agent = %s,Exten = %d, %s");
|
|
1341
|
|
- // fmt % AgentID % AgentExten % hdl.lock().get();
|
|
1342
|
|
- // LOG_INFO_S(fmt.str());
|
|
1343
|
|
- // m_Server.sendMsg(hdl, creatJson(type, false));
|
|
1344
|
|
- // return;
|
|
1345
|
|
- //}
|
|
|
1366
|
+ if (!__login(AgentID, AgentExten, agent->groups())) {
|
|
|
1367
|
+ m_MapAgent.erase(AgentExten);
|
|
1346
|
1368
|
|
|
1347
|
|
- //Format fmt("座席签入成功,Agent = %s,Exten = %d,AgentGroup = %s %s");
|
|
1348
|
|
- //fmt % AgentID % AgentExten % AgentGroup % hdl.lock().get();
|
|
1349
|
|
- //LOG_INFO_S(fmt.str());
|
|
1350
|
|
- //m_Server.sendMsg(hdl, creatJson(type, true));
|
|
|
1369
|
+ Format fmt("座席签入失败,Agent = %s,Exten = %d, %s");
|
|
|
1370
|
+ fmt % AgentID % AgentExten % hdl.lock().get();
|
|
|
1371
|
+ LOG_INFO_S(fmt.str());
|
|
|
1372
|
+ m_Server.sendMsg(hdl, creatJson(type, false));
|
|
|
1373
|
+ return;
|
|
|
1374
|
+ }
|
|
|
1375
|
+ Format fmt("座席签入成功,Agent = %s,Exten = %d,AgentGroup = %s %s");
|
|
|
1376
|
+ fmt % AgentID % AgentExten % AgentGroup % hdl.lock().get();
|
|
|
1377
|
+ LOG_INFO_S(fmt.str());
|
|
|
1378
|
+ m_Server.sendMsg(hdl, creatJson(type, true));
|
|
1351
|
1379
|
|
|
1352
|
|
- //std::string data = creatJson("Monitor", "空闲", AgentID, AgentExten);
|
|
1353
|
|
- //m_MonitAgents.loopAgent(m_Server, data); // 通知班长坐席监控
|
|
|
1380
|
+ __agentDetail(lock.release()); // 通知坐席详情变化
|
|
1354
|
1381
|
|
|
1355
|
|
- // __agentDetail(); // 通知坐席详情变化
|
|
|
1382
|
+ std::string data = creatJson("Monitor", "空闲", AgentID, AgentExten);
|
|
|
1383
|
+ m_MonitAgents.loopAgent(m_Server, data); // 通知班长坐席监控
|
|
1356
|
1384
|
|
|
1357
|
1385
|
}
|
|
1358
|
1386
|
else if ("Logout" == type) { // 签出
|
|
|
@@ -1368,19 +1396,19 @@ void CFsProxy::__recvMsgFun(websocketpp::connection_hdl hdl, string msg)
|
|
1368
|
1396
|
}
|
|
1369
|
1397
|
else if ("SayBusy" == type) { // 置忙
|
|
1370
|
1398
|
bool ret = __setState(AgentID, false);
|
|
1371
|
|
-
|
|
1372
|
|
- std::unique_lock<std::mutex>lock(m_AgentLock);
|
|
1373
|
|
- auto it = m_MapAgent.find(AgentExten);
|
|
1374
|
|
- if (it != m_MapAgent.end())
|
|
1375
|
|
- it->second->setState(AGENT_STATE_REPOSE);
|
|
1376
|
|
- __agentDetail(lock.release()); // 通知坐席详情变化
|
|
|
1399
|
+
|
|
|
1400
|
+ std::unique_lock<std::mutex>lock(m_AgentLock);
|
|
|
1401
|
+ auto it = m_MapAgent.find(AgentExten);
|
|
|
1402
|
+ if (it != m_MapAgent.end())
|
|
|
1403
|
+ it->second->setState(AGENT_STATE_REPOSE);
|
|
|
1404
|
+ __agentDetail(lock.release()); // 通知坐席详情变化
|
|
1377
|
1405
|
|
|
1378
|
1406
|
m_Server.sendMsg(hdl, creatJson(type, ret));
|
|
1379
|
1407
|
|
|
1380
|
1408
|
std::string data = creatJson("Monitor", "小休", AgentID, AgentExten);
|
|
1381
|
1409
|
m_MonitAgents.loopAgent(m_Server, data); // 通知班长坐席监控
|
|
1382
|
1410
|
|
|
1383
|
|
-
|
|
|
1411
|
+
|
|
1384
|
1412
|
}
|
|
1385
|
1413
|
else if ("SayFree" == type) { // 置闲
|
|
1386
|
1414
|
bool ret = __setState(AgentID, true);
|
|
|
@@ -1394,7 +1422,6 @@ void CFsProxy::__recvMsgFun(websocketpp::connection_hdl hdl, string msg)
|
|
1394
|
1422
|
std::string data = creatJson("Monitor", "空闲", AgentID, AgentExten);
|
|
1395
|
1423
|
m_MonitAgents.loopAgent(m_Server, data); // 通知班长坐席监控
|
|
1396
|
1424
|
|
|
1397
|
|
-
|
|
1398
|
1425
|
}
|
|
1399
|
1426
|
else if ("ForceAgentState" == type) { // 强制更改座席状态
|
|
1400
|
1427
|
|
|
|
@@ -1622,19 +1649,84 @@ void CFsProxy::__recvMsgFun(websocketpp::connection_hdl hdl, string msg)
|
|
1622
|
1649
|
else if ("TurnIvr" == type) { // 转满意度
|
|
1623
|
1650
|
COperationReactor::GetInstance()->procOperation(opInstance++, LINE_OP_TURNIVR, ExtenNo, nullptr);
|
|
1624
|
1651
|
}
|
|
|
1652
|
+ else if ("Heart" == type) { // 心跳
|
|
|
1653
|
+ m_Server.sendMsg(hdl, msg);
|
|
|
1654
|
+ }
|
|
1625
|
1655
|
else if ("AutoCall" == type) { // 自动外呼
|
|
1626
|
1656
|
//m_AutoCall.addTask(); // 从数据库刷新任务
|
|
1627
|
1657
|
m_Server.sendMsg(hdl, creatJson(type, true));
|
|
1628
|
1658
|
}
|
|
1629
|
|
- else if ("Heart" == type) { // 心跳
|
|
1630
|
|
- m_Server.sendMsg(hdl, msg);
|
|
1631
|
|
- }
|
|
1632
|
1659
|
else if ("GetAgentDetail" == type) {
|
|
1633
|
1660
|
auto data = m_AgentDetail.to_string();
|
|
1634
|
1661
|
m_Server.sendMsg(hdl, data);
|
|
1635
|
1662
|
|
|
1636
|
1663
|
m_mpAgentDetailHdl[conID] = hdl;
|
|
1637
|
1664
|
}
|
|
|
1665
|
+ else if ("WaitCount" == type) {
|
|
|
1666
|
+
|
|
|
1667
|
+ std::unique_lock<std::shared_mutex>lock(m_mutQueryCount);
|
|
|
1668
|
+ auto it = std::find_if(m_subWaitCount.begin(), m_subWaitCount.end(), [=](websocketpp::connection_hdl hdltmp) {return hdltmp.lock() == hdl.lock(); });
|
|
|
1669
|
+ if (it == m_subWaitCount.end()) { // 第一次发送则保存
|
|
|
1670
|
+ m_subWaitCount.emplace_back(hdl); // 保存订阅排队数量的坐席
|
|
|
1671
|
+ }
|
|
|
1672
|
+ Json::Value root;
|
|
|
1673
|
+ Json::StreamWriterBuilder jsrocd;
|
|
|
1674
|
+ root["Type"] = "WaitCount";
|
|
|
1675
|
+ root["Result"] = true;
|
|
|
1676
|
+ std::int32_t nTotal = 0;
|
|
|
1677
|
+
|
|
|
1678
|
+ for (auto it = m_QueryCount.begin(); it != m_QueryCount.end(); ++it) {
|
|
|
1679
|
+ root[it->first] = it->second;
|
|
|
1680
|
+ try {
|
|
|
1681
|
+ auto n = stoi(it->second);
|
|
|
1682
|
+ nTotal += n;
|
|
|
1683
|
+ }
|
|
|
1684
|
+ catch (const std::exception& e) {
|
|
|
1685
|
+ LOG_ERROR("坐席组[%s]数量[%s]转换失败:[%s]", it->first.c_str(), it->second.c_str(), e.what());
|
|
|
1686
|
+ }
|
|
|
1687
|
+ }
|
|
|
1688
|
+ lock.unlock();
|
|
|
1689
|
+ root["Total"] = nTotal;
|
|
|
1690
|
+ auto data = Json::writeString(jsrocd, root);
|
|
|
1691
|
+ m_Server.sendMsg(hdl, data);
|
|
|
1692
|
+ }
|
|
|
1693
|
+ else if ("SendDtmf" == type){
|
|
|
1694
|
+ std::string Dtmf = root["Dtmf"].asString();
|
|
|
1695
|
+ std::unique_lock<std::mutex>lock(m_AgentLock);
|
|
|
1696
|
+ auto it = m_MapAgent.find(AgentExten);
|
|
|
1697
|
+ if (it == m_MapAgent.end()) { // 坐席未签入
|
|
|
1698
|
+ lock.unlock();
|
|
|
1699
|
+ m_Server.sendMsg(hdl, creatJson(type, false,"坐席未签入"));
|
|
|
1700
|
+ return;
|
|
|
1701
|
+ }
|
|
|
1702
|
+ if (AGENT_STATE_BUSY != it->second->state()) {
|
|
|
1703
|
+ lock.unlock();
|
|
|
1704
|
+ m_Server.sendMsg(hdl, creatJson(type, false, "坐席未通话"));
|
|
|
1705
|
+ return;
|
|
|
1706
|
+ }
|
|
|
1707
|
+ auto pChanIter = m_MapChanExt.find(ExtenNo);
|
|
|
1708
|
+ if (pChanIter == m_MapChanExt.end()) {
|
|
|
1709
|
+ return;
|
|
|
1710
|
+ }
|
|
|
1711
|
+ auto pChan = pChanIter->second;
|
|
|
1712
|
+ auto pSession = __getSessionByChanId(pChan->chanId());
|
|
|
1713
|
+ auto pFinalChan = pSession->getAssoFinalChan();
|
|
|
1714
|
+ if (CHAN_LOGIC_STATE_TALKING != pFinalChan->state() || !pFinalChan->isInMeeting()) {
|
|
|
1715
|
+ m_Server.sendMsg(hdl, creatJson(type, false, "目标线路未通话或未在会议中"));
|
|
|
1716
|
+ return;
|
|
|
1717
|
+ }
|
|
|
1718
|
+ LineOpParam param;
|
|
|
1719
|
+ param.szParam1 = AgentExten;
|
|
|
1720
|
+ param.szParam2 = std::to_string(pFinalChan->no());
|
|
|
1721
|
+ param.szParam3 = pFinalChan->chanId();
|
|
|
1722
|
+ param.szDtmf = Dtmf; // 按键
|
|
|
1723
|
+ bool ret = COperationReactor::GetInstance()->procOperation(ExtenNo, LINE_OP_SEND_DTMF, pFinalChan->no(), ¶m);
|
|
|
1724
|
+ if (!ret)
|
|
|
1725
|
+ m_Server.sendMsg(hdl, creatJson(type, std::string("操作失败")));
|
|
|
1726
|
+ }
|
|
|
1727
|
+ else {
|
|
|
1728
|
+
|
|
|
1729
|
+ }
|
|
1638
|
1730
|
// try 结束
|
|
1639
|
1731
|
}
|
|
1640
|
1732
|
catch (const Json::LogicError& e)
|
|
|
@@ -1833,4 +1925,43 @@ void CFsProxy::__agentDetailTrunkChange(const std::int32_t& nCount)
|
|
1833
|
1925
|
}
|
|
1834
|
1926
|
}
|
|
1835
|
1927
|
|
|
|
1928
|
+std::string CFsProxy::__queryCount(const bool & bIsLock)
|
|
|
1929
|
+{
|
|
|
1930
|
+ Json::Value root;
|
|
|
1931
|
+ Json::StreamWriterBuilder jsrocd;
|
|
|
1932
|
+ root["Type"] = "WaitCount";
|
|
|
1933
|
+ root["Result"] = true;
|
|
|
1934
|
+ std::int32_t nTotal = 0;
|
|
|
1935
|
+ if (bIsLock) {
|
|
|
1936
|
+ std::shared_lock<std::shared_mutex>lock(m_mutQueryCount);
|
|
|
1937
|
+ for (auto it = m_QueryCount.begin(); it != m_QueryCount.end(); ++it) {
|
|
|
1938
|
+ root[it->first] = it->second;
|
|
|
1939
|
+ try {
|
|
|
1940
|
+ auto n = stoi(it->second);
|
|
|
1941
|
+ nTotal += n;
|
|
|
1942
|
+ }
|
|
|
1943
|
+ catch (const std::exception& e) {
|
|
|
1944
|
+ LOG_ERROR("坐席组[%s]数量[%s]转换失败:[%s]", it->first.c_str(), it->second.c_str(), e.what());
|
|
|
1945
|
+ }
|
|
|
1946
|
+ }
|
|
|
1947
|
+ lock.unlock();
|
|
|
1948
|
+ }
|
|
|
1949
|
+ else {
|
|
|
1950
|
+ for (auto it = m_QueryCount.begin(); it != m_QueryCount.end(); ++it) {
|
|
|
1951
|
+ root[it->first] = it->second;
|
|
|
1952
|
+ try {
|
|
|
1953
|
+ auto n = stoi(it->second);
|
|
|
1954
|
+ nTotal += n;
|
|
|
1955
|
+ }
|
|
|
1956
|
+ catch (const std::exception& e) {
|
|
|
1957
|
+ LOG_ERROR("坐席组[%s]数量[%s]转换失败:[%s]", it->first.c_str(), it->second.c_str(), e.what());
|
|
|
1958
|
+ }
|
|
|
1959
|
+ }
|
|
|
1960
|
+ }
|
|
|
1961
|
+ //m_WaitCounter
|
|
|
1962
|
+ root["Total"] = nTotal;
|
|
|
1963
|
+ auto strJson = Json::writeString(jsrocd, root);
|
|
|
1964
|
+ return strJson;
|
|
|
1965
|
+}
|
|
|
1966
|
+
|
|
1836
|
1967
|
CFsProxy CFsProxy::instance;
|