Browse Source

add serviço de supervisor pbx

websocket
lucascardo12 3 years ago
parent
commit
eb2497aea8
  1. 68
      service/ServiceSupervisorPBx.php
  2. 2
      service/ServiceTimeout.php
  3. 6
      tests/test_services.php

68
service/ServiceSupervisorPBx.php

@ -0,0 +1,68 @@
<?php
namespace service;
use app\Models\Atendimento;
use app\Models\Parametros;
use app\Models\Supervisor;
class ServiceSupervisorPBx implements IService
{
private $supervisor;
function run()
{
$this->supervisor = new Supervisor;
$agentes = $this->supervisor->listaAgentesDisponivel();
foreach ($agentes as $key => $agente) {
$agentPbx = $this->validaAgentCriado($agente->matricula);
if (!$agentPbx) {
$this->criaRegistroSupervisor($agente);
} else {
$this->atualizaTabelaSupervisor($agente, $agentPbx);
}
}
}
function atualizaTabelaSupervisor($agente, $agentePbx)
{
$this->supervisor->updateAgent2(
$agente->matricula,
$agente->ramal,
$agente->fila,
$agente->status,
$agente->motivo_pausa,
$agente->status != $agentePbx->status,
$this->retornaQuantidadeAtendimento($agente->matricula)
);
}
function criaRegistroSupervisor($agente)
{
$this->supervisor->addAgent2(
$agente->nome,
$agente->matricula,
$agente->ramal,
$agente->fila,
$agente->tempo_login,
$agente->status,
$agente->motivo_pausa,
$this->retornaQuantidadeAtendimento($agente->matricula)
);
}
function retornaQuantidadeAtendimento($matricula)
{
$atendimentoModel = new Atendimento();
$paratroModel = new Parametros();
$atendimentos = $atendimentoModel->getAtendimentoAbertoByAgente($matricula);
$parametros = $paratroModel->findProtocolByParams();
$count = count($atendimentos);
return "$count/{$parametros->prm_media_simultaneo}";
}
function validaAgentCriado($matricula)
{
return $this->supervisor->findAgentByMatriculaPbx($matricula);
}
}

2
service/ServiceTimeout.php

@ -51,7 +51,7 @@ class ServiceTimeout implements IService
}
private function timeoutCliente($uniqueid, $client)
{
echo "unique: $uniqueid - client: $client \n";
// echo "unique: $uniqueid - client: $client \n";
if ($this->message->timeoutTalk($uniqueid, $client) == 'FINISH') {
$this->positus->enviarMsg($client, $this->mensagem['TIMEOUT_CLIENT_INATIVIDADE']);
$this->command->finalizar($client);

6
tests/test_services.php

@ -1,6 +1,7 @@
<?php
use service\ServiceQueue;
use service\ServiceSupervisorPBx;
use service\ServiceTimeout;
require __DIR__ . '/../vendor/autoload.php';
@ -8,8 +9,13 @@ include __DIR__ . '/../includes/config.php';
$sevice_timeout = new ServiceTimeout();
$servce_queue = new ServiceQueue();
$servce_supervisor = new ServiceSupervisorPBx();
while (true) {
echo "executar servce_supervisor \n";
$servce_supervisor->run();
echo "executar sevice_timeout \n";
$sevice_timeout->run();
echo "executar servce_queue \n";
$servce_queue->run();
sleep(10);
}
Loading…
Cancel
Save