diff --git a/service/ServiceSupervisorPBx.php b/service/ServiceSupervisorPBx.php new file mode 100644 index 0000000..1e95cd9 --- /dev/null +++ b/service/ServiceSupervisorPBx.php @@ -0,0 +1,68 @@ +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); + } +} \ No newline at end of file diff --git a/service/ServiceTimeout.php b/service/ServiceTimeout.php index a039870..926a37e 100644 --- a/service/ServiceTimeout.php +++ b/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); diff --git a/tests/test_services.php b/tests/test_services.php index a8fe9dd..3f2df8f 100644 --- a/tests/test_services.php +++ b/tests/test_services.php @@ -1,6 +1,7 @@ run(); + echo "executar sevice_timeout \n"; $sevice_timeout->run(); + echo "executar servce_queue \n"; $servce_queue->run(); sleep(10); } \ No newline at end of file