Browse Source

Foi acrescentado uma flag na tabela ast_bilhetes para previnir que chamadas sejam importadas antes de ser realizado a correcao do numero de destino

1.8-dev
douglas.strappasson 1 year ago
parent
commit
f1c2155feb
  1. 16
      asterisk/var_lib_asterisk/scripts/manutencaoDB/importaBilhetes.php
  2. 5
      projeto/base/sql/versao-1.8.1.sql

16
asterisk/var_lib_asterisk/scripts/manutencaoDB/importaBilhetes.php

@ -148,8 +148,9 @@ function ImportaAstEventosDacs($dbcon) {
function ImportaAstBilhetes($dbcon) {
global $numBilhetes;
$query = "drop table if exists tb_parametros;
create temporary table tb_parametros as
select (select min(id) mun_padrao from pbx_municipios where to_ascii(nome_localidade) = (select to_ascii(prm_mun_padrao) from pbx_parametros) and uf = (select prm_uf_padrao from pbx_parametros)) as mun_padrao, (select prm_ddd_padrao from pbx_parametros) as prm_ddd_padrao;
create temporary table tb_parametros as
select (select min(id) mun_padrao from pbx_municipios where to_ascii(nome_localidade) = (select to_ascii(prm_mun_padrao) from pbx_parametros)
and uf = (select prm_uf_padrao from pbx_parametros)) as mun_padrao, (select prm_ddd_padrao from pbx_parametros) as prm_ddd_padrao;
-- MELHOR DESEMPENHO EM PESQUISA DE MUNICIPIO PARA CELULAR
drop table if exists tb_municipios; create temporary table tb_municipios as select min(id) as id, codigo_ddd from pbx_municipios group by codigo_ddd;
@ -167,9 +168,7 @@ select (select min(id) mun_padrao from pbx_municipios where to_ascii(nome_local
when(34)then (select min(id) from tb_municipios where codigo_ddd = ast.prefixo)
else 0 end
end as id_municipio
from (
select *,
from ( select *,
case prf.tipo_chamada
when(21)then strtoint(((select prm_ddd_padrao::text from tb_parametros) || substring(prf.dst,1,4)))
when(22)then strtoint(substring(substring(prf.dst,'..........$'), 1,6))
@ -198,14 +197,13 @@ select (select min(id) mun_padrao from pbx_municipios where to_ascii(nome_local
end as tipo_chamada
from ast_bilhetes a
where not exists(select '' from pbx_bilhetes where id_bilhetes = a.id_bilhetes)
and a.corrige_numero_destino = TRUE
) as prf
) as ast;
create index \"tb_tipo_ligacaoIdBilhetes\" on tb_tipo_ligacao(id_bilhetes);
insert
into pbx_bilhetes(
insert into pbx_bilhetes(
id_bilhetes, calldate, clid, dst, dcontext, channel, dstchannel, lastapp, lastdata, duration, billsec, disposition, tipo_chamada, accountcode, uniqueid, userfield, data_bilhete, id_municipio, ramal_origem, fora_horario, flag_fila, src)
select a.id_bilhetes, calldate, clid, a.dst, dcontext, channel, dstchannel, lastapp, lastdata, duration, billsec, disposition, b.tipo_chamada, accountcode, a.uniqueid, userfield, calldate::date, b.id_municipio, ramal_origem, fora_horario, b.flag_fila, CASE WHEN(direcao = 'S')THEN coalesce(ramal_origem, src) ELSE src END AS src
from ast_bilhetes a, tb_tipo_ligacao b
@ -275,7 +273,7 @@ function CorrigeNumeroDestino($dbcon) {
) AS bilhetes_bilhetes GROUP BY uniqueid;
UPDATE ast_bilhetes
SET dst = ast_corrige_destino.dst, amaflags = 99
SET dst = ast_corrige_destino.dst, amaflags = 99, corrige_numero_destino = TRUE
FROM ast_corrige_destino
WHERE ast_bilhetes.uniqueid = ast_corrige_destino.uid
AND coalesce(ast_corrige_destino.dst, '') <> '';";

5
projeto/base/sql/versao-1.8.1.sql

@ -1,3 +1,8 @@
-- Correcao dados tipo preco
update pbx_tarifa_tipo_preco set ttp_descricao = 'Móvel Local' where ttp_id = 'vc3';
update pbx_tarifa_tipo_preco set ttp_descricao = 'Móvel Interurbano' where ttp_id = 'vc4';
-- acrescenta flag que identifica se o numero de destino foi corrigido no script importaBilhetes através da funcao CorrigeNumeroDestino
-- o objetivo é evitar que ligações sejam gravadas na tabela pbx_bilhetes com o numero de destino incorreto.
ALTER TABLE ast_bilhetes
ADD corrige_numero_destino BOOLEAN DEFAULT FALSE;
Loading…
Cancel
Save