Commit 9e4daec81a410e9b834ad959be8f9bbe52c9c1e3

Authored by daniel@ruoso.com
1 parent 2e565aac
Exists in master

Implementa o encaminhamento para categoria

git-svn-id: http://svn.softwarepublico.gov.br/svn/sistemadeatendimento/sistema/trunk@20 63db2ce5-8a6c-0410-abb9-a418dd412890
Fila-Servico/lib/Fila/Servico/Controller/WS/Gestao/Atendente.pm
... ... @@ -740,14 +740,11 @@ sub encaminhar_atendimento :WSDLPort('GestaoAtendente') :DBICTransaction('DB') :
740 740 my ($self, $c, $query) = @_;
741 741  
742 742 my $now = $c->stash->{now};
743   -
  743 +
744 744 my $guiche_origem = $c->model('DB::Guiche')->find
745 745 ( id_guiche => $c->stash->{guiche}->id_guiche );
746   -
747   - my $outro_guiche = $c->model('DB::Guiche')->find
748   - ( $query->{guiche} );
749 746  
750   - my $motivo = $query->{guiche}{pausa_motivo};
  747 + my $motivo = $query->{encaminhamento}{informacoes};
751 748 unless ($motivo) {
752 749 die $c->stash->{soap}->fault
753 750 ({ code => 'Server',
... ... @@ -755,13 +752,6 @@ sub encaminhar_atendimento :WSDLPort('GestaoAtendente') :DBICTransaction('DB') :
755 752 detail => 'E necessário um motivo para o encaminhamento.' });
756 753 }
757 754  
758   - unless ($outro_guiche) {
759   - die $c->stash->{soap}->fault
760   - ({ code => 'Server',
761   - reason => 'Guiche Invalido',
762   - detail => 'Nao conseguiu encontrar guiche.' });
763   - }
764   -
765 755 my $atendimento = $c->stash->{guiche}->atendimento_atual->first;
766 756  
767 757 unless ($atendimento) {
... ... @@ -796,13 +786,35 @@ sub encaminhar_atendimento :WSDLPort('GestaoAtendente') :DBICTransaction('DB') :
796 786 vt_fim => 'Infinity',
797 787 id_estado => $estado_encaminhado->id_estado });
798 788  
799   - $outro_guiche->encaminhamentos->create
800   - ({ vt_ini => $now,
801   - vt_fim => 'Infinity',
802   - id_atendimento => $atendimento->id_atendimento,
803   - id_guiche_origem => $guiche_origem->id_guiche,
804   - informacoes => $motivo
805   - });
  789 + if ($query->{encaminhamento}{id_guiche}) {
  790 + my $outro_guiche = $c->model('DB::Guiche')
  791 + ->find({ id_guiche => $query->{encaminhamento}{id_guiche} })
  792 + or die $c->stash->{soap}->fault
  793 + ({ code => 'Server',
  794 + reason => 'Nao encontrou guiche',
  795 + detail => 'O guiche informado não existe.' });
  796 +
  797 + $outro_guiche->encaminhamentos->create
  798 + ({ vt_ini => $now,
  799 + vt_fim => 'Infinity',
  800 + id_atendimento => $atendimento->id_atendimento,
  801 + id_guiche_origem => $guiche_origem->id_guiche,
  802 + informacoes => $motivo });
  803 + } elsif ($query->{encaminhamento}{id_categoria}) {
  804 + $c->stash->{local}->encaminhamentos_categoria->create
  805 + ({ id_categoria => $query->{encaminhamento}{id_categoria},
  806 + vt_ini => $now,
  807 + vt_fim => 'Infinity',
  808 + id_atendimento => $atendimento->id_atendimento,
  809 + id_guiche_origem => $guiche_origem->id_guiche,
  810 + informacoes => $motivo });
  811 +
  812 + } else {
  813 + die $c->stash->{soap}->fault
  814 + ({ code => 'Client',
  815 + reason => 'Faltou parâmetros',
  816 + detail => 'É preciso indicar ou um guiche ou uma categoria' });
  817 + }
806 818  
807 819 $c->stash->{guiche}->estado_atual->first->update
808 820 ({ vt_fim => $now });
... ...
Fila-Servico/lib/Fila/Servico/Controller/WS/Gestao/Guiche.pm
... ... @@ -99,6 +99,29 @@ sub listar_guiches :WSDLPort('GestaoGuiche') :DBICTransaction('DB') :MI {
99 99 ({ lista_guiches => { guiche => $lista_guiches } });
100 100 }
101 101  
  102 +sub listar_categorias :WSDLPort('GestaoGuiche') :DBICTransaction('DB') :MI {
  103 + my ($self, $c, $query) = @_;
  104 + my $now = $c->stash->{now};
  105 +
  106 + my $categorias = $c->stash->{local}->configuracoes_categoria->search
  107 + ({ 'me.vt_ini' => { '<=', $now },
  108 + 'me.vt_fim' => { '>', $now }},
  109 + { prefetch => 'categoria',
  110 + order_by => 'codigo' });
  111 +
  112 + my $lista_categorias = [];
  113 +
  114 + while (my $categoria = $categorias->next) {
  115 + my $ca = $categoria->categoria;
  116 + push @$lista_categorias,
  117 + {( map { $_ => $ca->$_() }
  118 + qw/id_categoria codigo nome/ )};
  119 + }
  120 +
  121 + $c->stash->{soap}->compile_return
  122 + ({ lista_categorias => { categoria => $lista_categorias } });
  123 +}
  124 +
102 125 sub abrir_guiche :WSDLPort('GestaoGuiche') :DBICTransaction('DB') :MI {
103 126 my ($self, $c, $query) = @_;
104 127  
... ...
Fila-Servico/lib/Fila/Servico/Controller/WS/Gestao/Local.pm
... ... @@ -22,6 +22,7 @@ use Net::XMPP2::Util &#39;bare_jid&#39;;
22 22 use DateTime;
23 23 use DateTime::Format::Pg;
24 24 use DateTime::Format::XSD;
  25 +use List::Util qw(reduce);
25 26 use Carp qw(croak);
26 27 use base
27 28 'Fila::Servico::Controller',
... ... @@ -240,7 +241,7 @@ sub status_local :WSDLPort(&#39;GestaoLocal&#39;) :DBICTransaction(&#39;DB&#39;) :MI {
240 241  
241 242 my $estado_local_aberto = $c->model('DB::TipoEstadoLocal')->find
242 243 ({ nome => 'aberto' });
243   -
  244 +
244 245 unless ($estado_local_aberto) {
245 246 die $c->stash->{soap}->fault
246 247 ({code => 'Server',
... ... @@ -257,7 +258,7 @@ sub status_local :WSDLPort(&#39;GestaoLocal&#39;) :DBICTransaction(&#39;DB&#39;) :MI {
257 258 print STDERR "O hash é ", Data::Dumper::Dumper( \$gerente ), "\n";
258 259  
259 260 # agora tah faltando 'mandar 'o $gerente para ser mostrado no template
260   -
  261 +
261 262 # obter o tempo maximo em espera por categoria,
262 263 # o agregado pode ser obtido sem outra consulta.
263 264 my $lista = $c->stash->{local}->configuracoes_categoria_atual->search
... ... @@ -416,49 +417,42 @@ sub status_local :WSDLPort(&#39;GestaoLocal&#39;) :DBICTransaction(&#39;DB&#39;) :MI {
416 417  
417 418 my $estado_local = $c->stash->{local}->estado_atual->search
418 419 ({ },
419   - {
420   - prefetch => 'estado' })->first;
  420 + { prefetch => 'estado' })->first;
421 421  
422 422 #encaminhamentos
423 423  
424 424 #pegar ultimo vt_ini do ultimo estadoaberto do local.
425 425 my $ultimo_aberto = $c->stash->{local}->estados->search
426   - ({
427   - 'estado.nome' => $estado_local_aberto->nome }, {
428   - join => 'estado',
429   - order_by => 'vt_ini DESC'
430   - })->first;
  426 + ({ 'estado.nome' => $estado_local_aberto->nome },
  427 + { join => 'estado',
  428 + order_by => 'vt_ini DESC' })->first;
431 429  
432 430 my $total_enc=0;
433 431 my $total_enc_abertos=0;
434 432  
435 433 if ($ultimo_aberto) {
436 434  
437   - my $enc = $c->model('DB::GuicheEncaminhamento')->find(
438   - {
439   - 'me.vt_ini' => { '>=', $ultimo_aberto->get_column('vt_ini') }
440   - },
441   - {
442   - select => [ { count => 'me.id_atendimento' } ],
443   - as => [ 'encaminhamentos' ]
444   - }
445   - );
446   -
447   - $total_enc = $enc->get_column('encaminhamentos');
448   -
449   - #encaminhamentos ainda sem atendimento
450   - $enc = $c->model('DB::GuicheEncaminhamento')->find(
451   - {
452   - 'me.vt_ini' => { '>=', $ultimo_aberto->get_column('vt_ini') },
453   - 'me.vt_fim' => 'Infinity'
454   - },
455   - {
456   - select => [ { count => 'me.id_atendimento' } ],
457   - as => [ 'encaminhamentos' ]
458   - }
459   - );
460   -
461   - $total_enc_abertos = $enc->get_column('encaminhamentos');
  435 + my @e_g = $c->model('DB::GuicheEncaminhamento')->search
  436 + ({ 'me.vt_ini' => { '>=', $ultimo_aberto->get_column('vt_ini') }},
  437 + { select => [ { count => 'me.id_atendimento' },
  438 + \"CASE WHEN vt_fim > NOW() THEN 1 ELSE 0 END" ],
  439 + as => [ 'encaminhamentos',
  440 + 'esperando' ],
  441 + group_by => \"CASE WHEN vt_fim > NOW() THEN 1 ELSE 0 END" })->all;
  442 +
  443 + my @e_c = $c->model('DB::CategoriaEncaminhamento')->search
  444 + ({ 'me.vt_ini' => { '>=', $ultimo_aberto->get_column('vt_ini') }},
  445 + { select => [ { count => 'me.id_atendimento' },
  446 + \"CASE WHEN vt_fim > NOW() THEN 1 ELSE 0 END" ],
  447 + as => [ 'encaminhamentos',
  448 + 'esperando' ],
  449 + group_by => \"CASE WHEN vt_fim > NOW() THEN 1 ELSE 0 END" })->all;
  450 +
  451 + my @tot = (@e_g, @e_c);
  452 + my @esp = grep { $_->get_column('esperando') } @tot;
  453 +
  454 + $total_enc = reduce { $a + $b->get_column('encaminhamentos') } 0, @tot;
  455 + $total_enc_abertos = reduce { $a + $b->get_column('encaminhamentos') } 0, @esp;
462 456 }
463 457  
464 458 return $c->stash->{soap}->compile_return
... ... @@ -801,28 +795,44 @@ sub escalonar_senha :WSDLPort(&#39;GestaoLocal&#39;) :DBICTransaction(&#39;DB&#39;) :MI {
801 795 # de categorias.
802 796 my @ids = map { $_->id_categoria } $guiche->categorias_atuais;
803 797 my %restringir;
  798 + my %restringir_c;
804 799 if (@ids) {
805 800 %restringir = ( 'categoria_atual.id_categoria' => { 'IN' => \@ids });
  801 + %restringir_c = ( 'id_categoria' => { 'IN' => \@ids });
806 802 }
807 803  
808   - # descobrir os atendimentos em espera. O escalonamento vai ter o
809   - # conceito de proporção entre o tempo de espera dependendo da
810   - # prioridade da categoria. A prioridade vai representar um
811   - # multiplicador para o tempo de espera, o que significa que, se
812   - # uma categoria tem prioridade 1, o tempo de espera vai ter a
813   - # proporção de 1 para 1. Uma categoria com prioridade 2 significa
814   - # que o tempo de espera vai significar o dobro. Ou seja, se uma
815   - # pessoa está esperando 10 minutos em uma categoria de prioridade
816   - # 2 vai representar para o sistema como se ela já estivesse
817   - # esperando a 20 minutos.
818   - $atendimento = $c->stash->{local}->atendimentos_atuais->find
819   - ({ 'estado.nome' => 'espera',
820   - 'configuracoes_atuais.id_local' => $c->stash->{local}->id_local,
821   - %restringir },
822   - { 'join' =>
823   - [{ 'estado_atual' => 'estado' },
824   - { 'categoria_atual' => { 'categoria' => 'configuracoes_atuais' }}],
825   - 'order_by' => '((now() - estado_atual.vt_ini) * configuracoes_atuais.prioridade) DESC'});
  804 + # agora também precisamos descobrir se existe algum
  805 + # encaminhamento esperando para alguma das categorias que
  806 + # esse guichê atende.
  807 + my $enc = $c->stash->{local}->encaminhamentos_categoria->search
  808 + ({ vt_ini => { '<=' => $now },
  809 + vt_fim => { '>' => $now },
  810 + %restringir_c },
  811 + { order_by => 'vt_ini' })->next;
  812 +
  813 + if ($enc) {
  814 + $atendimento = $enc->atendimento;
  815 + $enc->update({ vt_fim => $now });
  816 + } else {
  817 + # descobrir os atendimentos em espera. O escalonamento vai ter o
  818 + # conceito de proporção entre o tempo de espera dependendo da
  819 + # prioridade da categoria. A prioridade vai representar um
  820 + # multiplicador para o tempo de espera, o que significa que, se
  821 + # uma categoria tem prioridade 1, o tempo de espera vai ter a
  822 + # proporção de 1 para 1. Uma categoria com prioridade 2 significa
  823 + # que o tempo de espera vai significar o dobro. Ou seja, se uma
  824 + # pessoa está esperando 10 minutos em uma categoria de prioridade
  825 + # 2 vai representar para o sistema como se ela já estivesse
  826 + # esperando a 20 minutos.
  827 + $atendimento = $c->stash->{local}->atendimentos_atuais->find
  828 + ({ 'estado.nome' => 'espera',
  829 + 'configuracoes_atuais.id_local' => $c->stash->{local}->id_local,
  830 + %restringir },
  831 + { 'join' =>
  832 + [{ 'estado_atual' => 'estado' },
  833 + { 'categoria_atual' => { 'categoria' => 'configuracoes_atuais' }}],
  834 + 'order_by' => '((now() - estado_atual.vt_ini) * configuracoes_atuais.prioridade) DESC'});
  835 + }
826 836 }
827 837  
828 838 if ($atendimento) {
... ... @@ -1130,40 +1140,70 @@ sub listar_encaminhamentos: WSDLPort(&#39;GestaoLocal&#39;) :DBICTransaction(&#39;DB&#39;): MI {
1130 1140 if ($ultimo_aberto) {
1131 1141 my $vt_ini = $ultimo_aberto->get_column('vt_ini');
1132 1142  
1133   - my $enc =
  1143 + my $enc_guiches =
1134 1144 $c->model('DB::GuicheEncaminhamento')->search
1135 1145 ({ 'me.vt_ini' => { '>=', $vt_ini } },
1136 1146 { join => [ 'guiche' , 'guiche_origem' ],
1137   - select => [
1138   - 'me.vt_ini',
1139   - 'guiche.identificador',
1140   - 'guiche_origem.identificador',
1141   - 'me.id_atendimento',
1142   - 'me.informacoes',
1143   - 'me.vt_fim'
1144   - ],
1145   - as => [
1146   - 'vt_ini' ,
1147   - 'id_guiche',
1148   - 'id_guiche_origem',
1149   - 'id_atendimento',
1150   - 'informacoes',
1151   - 'vt_fim'
1152   - ],
1153   - order_by => [ 'me.vt_ini DESC' ]});
1154   -
1155   - while (my $encaminhamento = $enc->next) {
1156   - push @$ret,
1157   - {
1158   - ( map { $_ => $encaminhamento->get_column($_) }
1159   - qw( id_guiche id_guiche_origem id_atendimento informacoes )
1160   - ),
1161   - ( map { ($encaminhamento->$_ && $encaminhamento->$_->is_infinite) ?
1162   - () : ($_ => DateTime::Format::XSD->format_datetime($encaminhamento->$_->set_time_zone('local'))) }
1163   - qw/ vt_ini vt_fim /
1164   - ),
1165   - }
  1147 + select => [ 'me.vt_ini',
  1148 + 'guiche.identificador',
  1149 + 'guiche_origem.identificador',
  1150 + 'me.id_atendimento',
  1151 + 'me.informacoes',
  1152 + 'me.vt_fim' ],
  1153 + as => [ 'vt_ini' ,
  1154 + 'id_guiche',
  1155 + 'id_guiche_origem',
  1156 + 'id_atendimento',
  1157 + 'informacoes',
  1158 + 'vt_fim' ],
  1159 + order_by => 'me.vt_ini DESC'});
  1160 +
  1161 + my $enc_categorias =
  1162 + $c->model('DB::CategoriaEncaminhamento')->search
  1163 + ({ 'me.vt_ini' => { '>=', $vt_ini } },
  1164 + { join => [ 'categoria' , 'guiche_origem' ],
  1165 + select => [ 'me.vt_ini',
  1166 + 'categoria.codigo',
  1167 + 'guiche_origem.identificador',
  1168 + 'me.id_atendimento',
  1169 + 'me.informacoes',
  1170 + 'me.vt_fim' ],
  1171 + as => [ 'vt_ini' ,
  1172 + 'id_categoria',
  1173 + 'id_guiche_origem',
  1174 + 'id_atendimento',
  1175 + 'informacoes',
  1176 + 'vt_fim' ],
  1177 + order_by => 'me.vt_ini DESC'});
  1178 +
  1179 + my $eg = $enc_guiches->next;
  1180 + my $ec = $enc_categorias->next;
  1181 +
  1182 + while ($eg || $ec) {
  1183 + my $encaminhamento;
  1184 + my %add;
  1185 + if (($eg && $ec) && ($eg->vt_ini > $ec->vt_ini) ||
  1186 + ($eg && !$ec)) {
  1187 + $encaminhamento = $eg;
  1188 + $eg = $enc_guiches->next;
  1189 + $add{id_guiche} = $encaminhamento->get_column('id_guiche');
  1190 + } else {
  1191 + $encaminhamento = $ec;
  1192 + $ec = $enc_categorias->next;
  1193 + $add{id_categoria} = $encaminhamento->get_column('id_categoria');
1166 1194 }
  1195 +
  1196 + push @$ret,
  1197 + {( map { $_ => $encaminhamento->get_column($_) }
  1198 + qw( id_guiche_origem id_atendimento informacoes ) ),
  1199 + ( map { ($encaminhamento->$_ && $encaminhamento->$_->is_infinite) ?
  1200 + () : ($_ => DateTime::Format::XSD->format_datetime($encaminhamento->$_->set_time_zone('local'))) }
  1201 + qw/ vt_ini vt_fim /),
  1202 + %add
  1203 + };
  1204 + }
  1205 +
  1206 +
1167 1207 }
1168 1208 return $c->stash->{soap}->compile_return
1169 1209 ({ lista_encaminhamentos => { encaminhamento => $ret } });
... ...
Fila-Servico/lib/Fila/Servico/DB/Local.pm
... ... @@ -89,6 +89,10 @@ __PACKAGE__-&gt;has_many(&#39;configuracoes_categoria&#39;, &#39;Fila::Servico::DB::Configuraca
89 89 { 'foreign.id_local' => 'self.id_local' },
90 90 { join_type => 'left' });
91 91  
  92 +__PACKAGE__->has_many('encaminhamentos_categoria', 'Fila::Servico::DB::CategoriaEncaminhamento',
  93 + { 'foreign.id_local' => 'self.id_local' },
  94 + { join_type => 'left' });
  95 +
92 96 __PACKAGE__->has_many('configuracoes_limite', 'Fila::Servico::DB::ConfiguracaoLimite',
93 97 { 'foreign.id_local' => 'self.id_local' },
94 98 { join_type => 'left' });
... ...
Fila-Servico/schemas/FilaServico.wsdl
... ... @@ -55,9 +55,6 @@
55 55 <wsdl:part name="lista_funcionarios" element="filatp:lista_funcionarios" />
56 56 </wsdl:message>
57 57  
58   - <wsdl:message name="solicitacao_encaminhamento">
59   - <wsdl:part name="encaminhamento" element="filatp:encaminhamento" />
60   - </wsdl:message>
61 58 <wsdl:message name="resposta_lista_encaminhamentos">
62 59 <wsdl:part name="lista_encaminhamentos" element="filatp:lista_encaminhamentos" />
63 60 </wsdl:message>
... ... @@ -113,7 +110,7 @@
113 110 <wsdl:input message="filasv:solicitacao_guiche" />
114 111 </wsdl:operation>
115 112 <wsdl:operation name="listar_encaminhamentos">
116   - <wsdl:input message="filasv:solicitacao_encaminhamento" />
  113 + <wsdl:input message="filasv:solicitacao_guiche" />
117 114 <wsdl:output message="filasv:resposta_lista_encaminhamentos" />
118 115 </wsdl:operation>
119 116 <wsdl:operation name="associar_gerente">
... ... @@ -212,10 +209,15 @@
212 209 <wsdl:message name="solicitacao_guiche">
213 210 <wsdl:part name="guiche" element="filatp:guiche" />
214 211 </wsdl:message>
  212 + <wsdl:message name="solicitacao_encaminhamento">
  213 + <wsdl:part name="encaminhamento" element="filatp:encaminhamento" />
  214 + </wsdl:message>
215 215 <wsdl:message name="resposta_guiche">
216 216 <wsdl:part name="guiche" element="filatp:guiche" />
217 217 </wsdl:message>
218   -
  218 + <wsdl:message name="resposta_lista_categorias">
  219 + <wsdl:part name="lista_categorias" element="filatp:lista_categorias" />
  220 + </wsdl:message>
219 221  
220 222 <wsdl:portType name="GestaoGuiche">
221 223 <wsdl:operation name="dados_local">
... ... @@ -226,6 +228,10 @@
226 228 <wsdl:input message="filasv:solicitacao_local" />
227 229 <wsdl:output message="filasv:resposta_lista_guiches" />
228 230 </wsdl:operation>
  231 + <wsdl:operation name="listar_categorias">
  232 + <wsdl:input message="filasv:solicitacao_local" />
  233 + <wsdl:output message="filasv:resposta_lista_categorias" />
  234 + </wsdl:operation>
229 235 <wsdl:operation name="abrir_guiche">
230 236 <wsdl:input message="filasv:solicitacao_guiche" />
231 237 </wsdl:operation>
... ... @@ -243,6 +249,11 @@
243 249 <wsdl:input><soap:body namespace="urn:oktiva:fila:servico" use="literal"/></wsdl:input>
244 250 <wsdl:output><soap:body namespace="urn:oktiva:fila:servico" use="literal"/></wsdl:output>
245 251 </wsdl:operation>
  252 + <wsdl:operation name="listar_categorias">
  253 + <soap:operation style="rpc" />
  254 + <wsdl:input><soap:body namespace="urn:oktiva:fila:servico" use="literal"/></wsdl:input>
  255 + <wsdl:output><soap:body namespace="urn:oktiva:fila:servico" use="literal"/></wsdl:output>
  256 + </wsdl:operation>
246 257 <wsdl:operation name="abrir_guiche">
247 258 <soap:operation style="rpc" />
248 259 <wsdl:input><soap:body namespace="urn:oktiva:fila:servico" use="literal"/></wsdl:input>
... ... @@ -255,9 +266,6 @@
255 266 <wsdl:message name="resposta_atendimento">
256 267 <wsdl:part name="atendimento" element="filatp:atendimento" />
257 268 </wsdl:message>
258   - <wsdl:message name="resposta_lista_categorias">
259   - <wsdl:part name="lista_categorias" element="filatp:lista_categorias" />
260   - </wsdl:message>
261 269 <wsdl:message name="resposta_lista_atendimentos">
262 270 <wsdl:part name="lista_atendimentos" element="filatp:lista_atendimentos" />
263 271 </wsdl:message>
... ... @@ -342,7 +350,7 @@
342 350 <wsdl:input message="filasv:solicitacao_guiche" />
343 351 </wsdl:operation>
344 352 <wsdl:operation name="encaminhar_atendimento">
345   - <wsdl:input message="filasv:solicitacao_guiche" />
  353 + <wsdl:input message="filasv:solicitacao_encaminhamento" />
346 354 </wsdl:operation>
347 355 <wsdl:operation name="setar_motivo_pausa">
348 356 <wsdl:input message="filasv:solicitacao_guiche" />
... ...
Fila-Servico/schemas/FilaWeb.wsdl
... ... @@ -192,6 +192,9 @@
192 192 <wsdl:operation name="encaminhar_atendimento">
193 193 <wsdl:input message="filasv:callback_request" />
194 194 </wsdl:operation>
  195 + <wsdl:operation name="encaminhar_atendimento_categoria">
  196 + <wsdl:input message="filasv:callback_request" />
  197 + </wsdl:operation>
195 198 <wsdl:operation name="listar_no_show">
196 199 <wsdl:input message="filasv:callback_request" />
197 200 </wsdl:operation>
... ... @@ -267,6 +270,10 @@
267 270 <soap:operation style="rpc" />
268 271 <wsdl:input><soap:body namespace="urn:oktiva:fila:web:servico" use="literal"/></wsdl:input>
269 272 </wsdl:operation>
  273 + <wsdl:operation name="encaminhar_atendimento_categoria">
  274 + <soap:operation style="rpc" />
  275 + <wsdl:input><soap:body namespace="urn:oktiva:fila:web:servico" use="literal"/></wsdl:input>
  276 + </wsdl:operation>
270 277 <wsdl:operation name="disponivel">
271 278 <soap:operation style="rpc" />
272 279 <wsdl:input><soap:body namespace="urn:oktiva:fila:web:servico" use="literal"/></wsdl:input>
... ...
Fila-Servico/schemas/fila-servico.xsd
... ... @@ -145,6 +145,7 @@
145 145 </xsd:sequence>
146 146 </xsd:complexType>
147 147  
  148 +
148 149 <xsd:complexType name="TipoDadosAtendimento">
149 150 <xsd:sequence>
150 151 <xsd:element name="id_atendimento" minOccurs="0" type="xsd:integer" />
... ... @@ -233,6 +234,7 @@
233 234 <xsd:sequence>
234 235 <xsd:element name="id_atendimento" minOccurs="0" type="xsd:integer" />
235 236 <xsd:element name="id_guiche" minOccurs="0" type="xsd:string" />
  237 + <xsd:element name="id_categoria" minOccurs="0" type="xsd:string" />
236 238 <xsd:element name="id_guiche_origem" minOccurs="0" type="xsd:string" />
237 239 <xsd:element name="vt_ini" minOccurs="0" type="xsd:dateTime" />
238 240 <xsd:element name="vt_fim" minOccurs="0" type="xsd:dateTime" />
... ... @@ -250,6 +252,7 @@
250 252 <xsd:element name="guiche" type="fila:TipoDadosGuiche" />
251 253 <xsd:element name="lista_guiches" type="fila:TipoDadosListaGuiches" />
252 254 <xsd:element name="atendimento" type="fila:TipoDadosAtendimento" />
  255 + <xsd:element name="encaminhamento" type="fila:TipoDadosEncaminhamento" />
253 256 <xsd:element name="categoria" type="fila:TipoDadosCategoria" />
254 257 <xsd:element name="lista_categorias" type="fila:TipoDadosListaCategorias" />
255 258 <xsd:element name="funcionario" type="fila:TipoDadosFuncionario" />
... ... @@ -257,7 +260,6 @@
257 260 <xsd:element name="lista_atendimentos" type="fila:TipoDadosListaAtendimentos" />
258 261 <xsd:element name="servico" type="fila:TipoDadosServico" />
259 262 <xsd:element name="lista_servicos" type="fila:TipoDadosListaServicos" />
260   - <xsd:element name="encaminhamento" type="fila:TipoDadosEncaminhamento" />
261 263 <xsd:element name="lista_encaminhamentos" type="fila:TipoDadosListaEncaminhamentos" />
262 264 <xsd:element name="lista_funcionarios" type="fila:TipoDadosListaFuncionarios" />
263 265  
... ...
Fila-Web/lib/Fila/Web/Controller/CB/Atendente.pm
... ... @@ -79,6 +79,22 @@ sub encaminhar_atendimento : Local {
79 79 value => $id_guiche } ]}});
80 80 }
81 81  
  82 +sub encaminhar_atendimento_categoria : Local {
  83 + my ($self, $c) = @_;
  84 +
  85 + my $id_categoria = $c->req->param('id_categoria');
  86 + my $motivo = $c->req->param('motivoEnc');
  87 +
  88 + $c->model('SOAP')->transport
  89 + ->addrs([$c->session->{user_jid}.'/cb/atendente']);
  90 +
  91 + my $req = $c->model('SOAP::Atendente')->encaminhar_atendimento_categoria
  92 + ({ callback_request =>
  93 + { param =>
  94 + [ { name => $motivo,
  95 + value => $id_categoria } ]}});
  96 +}
  97 +
82 98 sub devolver_senha : Local {
83 99 my ($self, $c) = @_;
84 100  
... ...
Fila-Web/lib/Fila/WebApp/Controller/CB/Atendente.pm
... ... @@ -67,11 +67,21 @@ sub listar_guiches_encaminhar : WSDLPort(&#39;FilaWebAtendenteCallback&#39;) {
67 67 return $c->forward('/render/error_message');
68 68 }
69 69  
  70 + $c->model('SOAP')->transport->addrs(['motor@gestao.fila.vhost/ws/gestao/guiche']);
  71 + my $lista_categorias = $c->model('SOAP::Gestao::Guiche')
  72 + ->listar_categorias({ local => {} });
  73 +
  74 + if ($lista_categorias->{Fault}) {
  75 + $c->stash->{error_message} = $lista_guiches->{Fault}{faultstring};
  76 + return $c->forward('/render/error_message');
  77 + }
  78 +
70 79 $c->model('SOAP')->transport->addrs(['motor@gestao.fila.vhost/ws/gestao/atendente']);
71 80 $c->stash->{status_guiche} = $c->model('SOAP::Gestao::Atendente')
72 81 ->status_guiche({ guiche => {} });
73 82  
74 83 $c->stash->{lista_guiches_encaminhar} = $lista_guiches;
  84 + $c->stash->{lista_categorias_encaminhar} = $lista_categorias;
75 85  
76 86 $c->stash->{template} = 'cb/atendente/refresh.tt';
77 87 $c->forward($c->view());
... ... @@ -83,10 +93,21 @@ sub encaminhar_atendimento : WSDLPort(&#39;FilaWebAtendenteCallback&#39;) {
83 93  
84 94 my $id_guiche = $query->{callback_request}{param}[0]{value};
85 95 my $motivo = $query->{callback_request}{param}[0]{name};
86   -
  96 +
  97 + $c->model('SOAP')->transport->addrs(['motor@gestao.fila.vhost/ws/gestao/atendente']);
  98 + my $encaminhar_atendimento = $c->model('SOAP::Gestao::Atendente')
  99 + ->encaminhar_atendimento({ encaminhamento => { id_guiche => $id_guiche, informacoes => $motivo } });
  100 +}
  101 +
  102 +sub encaminhar_atendimento_categoria : WSDLPort('FilaWebAtendenteCallback') {
  103 + my ($self, $c,$query) = @_;
  104 +
  105 + my $id_categoria = $query->{callback_request}{param}[0]{value};
  106 + my $motivo = $query->{callback_request}{param}[0]{name};
  107 +
87 108 $c->model('SOAP')->transport->addrs(['motor@gestao.fila.vhost/ws/gestao/atendente']);
88 109 my $encaminhar_atendimento = $c->model('SOAP::Gestao::Atendente')
89   - ->encaminhar_atendimento({ guiche => { id_guiche => $id_guiche, pausa_motivo => $motivo } });
  110 + ->encaminhar_atendimento({ encaminhamento => { id_categoria => $id_categoria, informacoes => $motivo } });
90 111 }
91 112  
92 113 sub atender_no_show : WSDLPort('FilaWebAtendenteCallback') {
... ...
Fila-Web/root/render/atendente.tt
... ... @@ -154,6 +154,15 @@
154 154 });
155 155 return false;
156 156 }
  157 + function encaminhar_atendimento_categoria() {
  158 + var url = '/cb/atendente/encaminhar_atendimento_categoria';
  159 + var params = $('encaminhar_categoria').serialize(true);
  160 + new Ajax.Request(url, {
  161 + method: 'post',
  162 + parameters: params
  163 + });
  164 + return false;
  165 + }
157 166 function setar_info_interno() {
158 167 var url = '/cb/atendente/setar_info_interno';
159 168 var params = $('interno').serialize(true);
... ...
Fila-Web/root/render/mesas.tt
... ... @@ -28,7 +28,7 @@
28 28 <h3 class='titulos'>Encaminhados</h3>
29 29 <TABLE id='TabEncaminhamentos' cellspacing='0' cellpadding='5' border='1'>
30 30 <TR class='titulosTabela'>
31   - <TD>Horário:</TD><TD>Atendido:</TD><TD>Mesa de Origem:</TD><TD>Mesa de Destino:</TD><TD>Nº do Atendimento</TD><TD>Motivo:</TD>
  31 + <TD>Horário:</TD><TD>Atendido:</TD><TD>Mesa de Origem:</TD><TD>Mesa de Destino:</TD><TD>Categoria de Destino:</TD><TD>Nº do Atendimento</TD><TD>Motivo:</TD>
32 32 </TR>
33 33 [% FOREACH encaminhamento IN lista_encaminhamentos.lista_encaminhamentos.encaminhamento %]
34 34 <TR>
... ... @@ -36,6 +36,7 @@
36 36 <TD>[% dtf.f(encaminhamento.vt_fim) %]</TD>
37 37 <TD>[% encaminhamento.id_guiche_origem %]</TD>
38 38 <TD>[% encaminhamento.id_guiche %]</TD>
  39 + <TD>[% encaminhamento.id_categoria %]</TD>
39 40 <TD>[% encaminhamento.id_atendimento %]</TD>
40 41 <TD>[% encaminhamento.informacoes %]</TD>
41 42 </TR>
... ...
Fila-Web/root/render/status_atendente.tt
... ... @@ -125,6 +125,21 @@
125 125 </DIV>
126 126 [% END %]
127 127  
  128 + [% IF lista_categorias_encaminhar %]
  129 + <H3 class="titulos">Encaminhar para outra categoria</h3>
  130 + <DIV ID="lista_categorias_encaminhar" class="encaminhar">
  131 + <form name="encaminhar_categoria" id="encaminhar_categoria" onsubmit="return encaminhar_atendimento_categoria()">
  132 + Categorias: <select name="id_categoria" id="id_categoria_destino" size="1" style="width: 300px">
  133 + [% FOREACH categoria IN lista_categorias_encaminhar.lista_categorias.categoria %]
  134 + <option value="[% categoria.id_categoria %]">[% categoria.codigo %] - [% categoria.nome %]</option>
  135 + [% END %]
  136 + </select><br /><br />
  137 + Motivo: <input type="text" name="motivoEnc" id="motivoEncCat" style="width: 300px" maxlength="100"><br /><br />
  138 + <button value="Encaminhar" id="BtEncCat" type="submit">Encaminhar</button>
  139 + </form>
  140 + </DIV>
  141 + [% END %]
  142 +
128 143 [% IF status_guiche.guiche.estado == 'interno' %]
129 144 <h3 id="TitServicos" class="titulos">Serviço em andamento:</h3><br>
130 145 <DIV ID="servicos">
... ...