Commit afebfa3b133992beaa954dc131df29a05d34c9ab
1 parent
7af7bfa3
Exists in
master
and in
1 other branch
Correcoes para banco Oracle
Showing
1 changed file
with
24 additions
and
9 deletions
Show diff stats
rn/MdEstatisticasColetarRN.php
... | ... | @@ -415,20 +415,21 @@ class MdEstatisticasColetarRN extends InfraRN |
415 | 415 | |
416 | 416 | public function obterAcessosUsuarios($ultimadata = null) { |
417 | 417 | if ($ultimadata == null) { |
418 | - $ultimadata = '1900-01-01'; | |
418 | + $ultimadata = "1900-01-01"; | |
419 | 419 | } |
420 | 420 | $sgbd = $this->obterTipoSGBD(); |
421 | 421 | $query = ''; |
422 | 422 | if ($sgbd == 'MySql') { |
423 | - $query = "select count(*) as quantidade, date(dth_acesso) as data from infra_navegador where date(dth_acesso) > " . $ultimadata . " group by date(dth_acesso)"; | |
423 | + $query = "select count(*) as quantidade, date(dth_acesso) as data from infra_navegador where date(dth_acesso) > '%s' group by date(dth_acesso)"; | |
424 | 424 | } elseif ($sgbd == 'SqlServer') { |
425 | - $query = "select count(*) as quantidade, CONVERT(date, dth_acesso) as data from infra_navegador where dth_acesso >= " . $ultimadata . " group by CONVERT(date, dth_acesso)"; | |
425 | + $query = "select count(*) as quantidade, CONVERT(date, dth_acesso) as data from infra_navegador where dth_acesso >= '%s' group by CONVERT(date, dth_acesso)"; | |
426 | 426 | } elseif ($sgbd == 'Oracle') { |
427 | - $query = "select count(*) as quantidade, to_char(dth_acesso,'YYYY-MM-DD') AS data from infra_navegador where dth_acesso >= date " . $ultimadata . " group by to_char(dth_acesso,'YYYY-MM-DD')"; | |
427 | + $query = "select count(*) as quantidade, to_char(dth_acesso,'YYYY-MM-DD') AS data from infra_navegador where dth_acesso >= date '%s' group by to_char(dth_acesso,'YYYY-MM-DD')"; | |
428 | 428 | } |
429 | - | |
429 | + | |
430 | 430 | $rs = array(); |
431 | 431 | if ($query) { |
432 | + $query = sprintf($query, $ultimadata); | |
432 | 433 | $rs = BancoSEI::getInstance()->consultarSql($query); |
433 | 434 | } |
434 | 435 | InfraDebug::getInstance()->gravar('SEI27 - Quantidade de acessos por dia: ' . json_encode($rs), InfraLog::$INFORMACAO); |
... | ... | @@ -487,15 +488,29 @@ class MdEstatisticasColetarRN extends InfraRN |
487 | 488 | |
488 | 489 | public function obterQuantidadeRecursos($dataultimorecurso) { |
489 | 490 | if ($dataultimorecurso == null) { |
490 | - $dataultimorecurso = "'1900-01-01'"; | |
491 | + $dataultimorecurso = "1900-01-01"; | |
492 | + } | |
493 | + $current_month = date("Y-m-01"); | |
494 | + $sgbd = $this->obterTipoSGBD(); | |
495 | + if ($sgbd == 'Oracle') { | |
496 | + $query = "SELECT to_char(dth_acesso, 'YYYY') AS ano, to_char(dth_acesso, 'MM') AS mes, recurso, count(*) as quantidade FROM sei.infra_auditoria WHERE dth_acesso > date '%s' AND dth_acesso < date '%s' GROUP BY to_char(dth_acesso, 'YYYY'), to_char(dth_acesso, 'MM'), recurso"; | |
497 | + } else { | |
498 | + $query = "SELECT year(dth_acesso) as ano, month(dth_acesso) as mes, recurso, count(*) as quantidade FROM sei.infra_auditoria where date(dth_acesso) > '%s' and date(dth_acesso) < '%s' group by 1, 2, 3 order by 1, 2, 3"; | |
491 | 499 | } |
492 | - $current_month = date("'Y-m-01'"); | |
493 | - $query = "SELECT year(dth_acesso) as ano, month(dth_acesso) as mes, recurso, count(*) as quantidade FROM sei.infra_auditoria where date(dth_acesso) > " . $dataultimorecurso . " and date(dth_acesso) < ". $current_month . " group by 1, 2, 3 order by 1, 2, 3"; | |
500 | + $query = sprintf($query, $dataultimorecurso, $current_month); | |
501 | + | |
502 | + InfraDebug::getInstance()->gravar('Query: ' . $query, InfraLog::$INFORMACAO); | |
503 | + | |
494 | 504 | return BancoSEI::getInstance()->consultarSql($query); |
495 | 505 | } |
496 | 506 | |
497 | 507 | public function obterQuantidadeLogErro() { |
498 | - $query = "select year(dth_log) ano, month(dth_log) mes, week(dth_log) semana, count(*) as quantidade from sei.infra_log where sta_tipo = 'E' group by 1, 2, 3"; | |
508 | + $sgbd = $this->obterTipoSGBD(); | |
509 | + if ($sgbd == 'Oracle') { | |
510 | + $query = "select to_char(dth_log, 'YYYY') AS ano, to_char(dth_log, 'MM') AS mes, to_char(dth_log, 'WW') AS semana, count(*) as quantidade from sei.infra_log where sta_tipo = 'E' GROUP BY to_char(dth_log, 'YYYY'), to_char(dth_log, 'MM'), to_char(dth_log, 'WW')"; | |
511 | + } else { | |
512 | + $query = "select year(dth_log) ano, month(dth_log) mes, week(dth_log) + 1 semana, count(*) as quantidade from sei.infra_log where sta_tipo = 'E' group by 1, 2, 3"; | |
513 | + } | |
499 | 514 | return BancoSEI::getInstance()->consultarSql($query); |
500 | 515 | } |
501 | 516 | } | ... | ... |