lucascardo12
3 years ago
3 changed files with 75 additions and 1 deletions
@ -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); |
||||
} |
||||
} |
Loading…
Reference in new issue