Commit 4a178b15885ae60dfed3f6a4687abc04603a12db
1 parent
9e1e847e
Exists in
master
and in
1 other branch
Indicador 27 - Filtro por data, obtendo a ultima data enviada de acessos dos usuarios
Showing
2 changed files
with
40 additions
and
15 deletions
Show diff stats
rn/MdEstatisticasColetarRN.php
... | ... | @@ -445,15 +445,18 @@ class MdEstatisticasColetarRN extends InfraRN { |
445 | 445 | return $lista; |
446 | 446 | } |
447 | 447 | |
448 | - private function obterAcessosUsuarios(){ | |
448 | + public function obterAcessosUsuarios($ultimadata=null){ | |
449 | + if ($ultimadata == null) { | |
450 | + $ultimadata = '1900-01-01'; | |
451 | + } | |
449 | 452 | $sgbd = $this->obterTipoSGBD(); |
450 | 453 | $query = ''; |
451 | 454 | if ($sgbd == 'MySql') { |
452 | - $query = "select count(*) as quantidade, date(dth_acesso) as data from infra_navegador group by date(dth_acesso)"; | |
455 | + $query = "select count(*) as quantidade, date(dth_acesso) as data from infra_navegador where dth_acesso >= '" . $ultimadata . "' group by date(dth_acesso)"; | |
453 | 456 | } elseif ($sgbd == 'SqlServer') { |
454 | - $query = "select count(*) as quantidade, CONVERT(date, dth_acesso) as data from infra_navegador group by CONVERT(date, dth_acesso)"; | |
457 | + $query = "select count(*) as quantidade, CONVERT(date, dth_acesso) as data from infra_navegador where dth_acesso >= '" . $ultimadata . "' group by CONVERT(date, dth_acesso)"; | |
455 | 458 | } elseif ($sgbd == 'Oracle') { |
456 | - $query = "select count(*) as quantidade, to_char(dth_acesso,'YYYY-MM-DD') AS data from infra_navegador group by to_char(dth_acesso,'YYYY-MM-DD')"; | |
459 | + $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')"; | |
457 | 460 | } |
458 | 461 | |
459 | 462 | $rs = array(); | ... | ... |
rn/MdEstatisticasEnviarRN.php
... | ... | @@ -21,19 +21,16 @@ class MdEstatisticasEnviarRN extends InfraRN { |
21 | 21 | |
22 | 22 | $objConfiguracaoSEI = ConfiguracaoSEI::getInstance(); |
23 | 23 | $url = $objConfiguracaoSEI->getValor('MdEstatisticas','url', false, 'http://estatisticas.planejamento.gov.br'); |
24 | + $orgaoSigla = $objConfiguracaoSEI->getValor('MdEstatisticas','sigla', false, ''); | |
24 | 25 | |
25 | - InfraDebug::getInstance()->gravar('URL: ' . $url, InfraLog::$INFORMACAO); | |
26 | + $output = $this->doPost($url, $json); | |
27 | + $id = $output['id']; | |
28 | + InfraDebug::getInstance()->gravar('Output: ' . json_encode($output), InfraLog::$INFORMACAO); | |
29 | + InfraDebug::getInstance()->gravar('iD: ' . $id, InfraLog::$INFORMACAO); | |
26 | 30 | |
27 | - $ch = curl_init(); | |
28 | - curl_setopt($ch, CURLOPT_URL, $url); | |
29 | - curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | |
30 | - curl_setopt($ch, CURLOPT_POST, true); | |
31 | - curl_setopt($ch, CURLOPT_POSTFIELDS, $json); | |
32 | - curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json')); | |
33 | - $output = curl_exec($ch); | |
34 | - | |
35 | - InfraDebug::getInstance()->gravar('Output: ' . $output, InfraLog::$INFORMACAO); | |
36 | - curl_close($ch); | |
31 | + $data = $this->doGet($url . '/ultimoacesso?sigla=' . $orgaoSigla); | |
32 | + $data = date($data); | |
33 | + InfraDebug::getInstance()->gravar('Data: ' . $data, InfraLog::$INFORMACAO); | |
37 | 34 | |
38 | 35 | return true; |
39 | 36 | |
... | ... | @@ -45,5 +42,30 @@ class MdEstatisticasEnviarRN extends InfraRN { |
45 | 42 | } |
46 | 43 | } |
47 | 44 | |
45 | + private function doPost($url, $json) { | |
46 | + $ch = curl_init(); | |
47 | + curl_setopt($ch, CURLOPT_URL, $url); | |
48 | + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | |
49 | + curl_setopt($ch, CURLOPT_POST, true); | |
50 | + curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json')); | |
51 | + curl_setopt($ch, CURLOPT_POSTFIELDS, $json); | |
52 | + $output = curl_exec($ch); | |
53 | + curl_close($ch); | |
54 | + return json_decode($output, true); | |
55 | + } | |
56 | + | |
57 | + private function doGet($url, $isjson=false) { | |
58 | + $ch = curl_init(); | |
59 | + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | |
60 | + curl_setopt($ch, CURLOPT_URL, $url); | |
61 | + $output = curl_exec($ch); | |
62 | + curl_close($ch); | |
63 | + | |
64 | + if ($isjson) { | |
65 | + return json_decode($output, true); | |
66 | + } | |
67 | + return $output; | |
68 | + } | |
69 | + | |
48 | 70 | } |
49 | 71 | ?> | ... | ... |