{"action":"opened","issue":{"url":"https://api.github.com/repos/culturagovbr/GOG/issues/24","labels_url":"https://api.github.com/repos/culturagovbr/GOG/issues/24/labels{/name}","comments_url":"https://api.github.com/repos/culturagovbr/GOG/issues/24/comments","events_url":"https://api.github.com/repos/culturagovbr/GOG/issues/24/events","html_url":"https://github.com/culturagovbr/GOG/issues/24","id":129234350,"number":24,"title":"Corrigir o SQL que recupera os últimos Tramites, para executar no Postgresql","user":{"login":"clelsonsalles","id":12459227,"avatar_url":"https://avatars.githubusercontent.com/u/12459227?v=3","gravatar_id":"","url":"https://api.github.com/users/clelsonsalles","html_url":"https://github.com/clelsonsalles","followers_url":"https://api.github.com/users/clelsonsalles/followers","following_url":"https://api.github.com/users/clelsonsalles/following{/other_user}","gists_url":"https://api.github.com/users/clelsonsalles/gists{/gist_id}","starred_url":"https://api.github.com/users/clelsonsalles/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/clelsonsalles/subscriptions","organizations_url":"https://api.github.com/users/clelsonsalles/orgs","repos_url":"https://api.github.com/users/clelsonsalles/repos","events_url":"https://api.github.com/users/clelsonsalles/events{/privacy}","received_events_url":"https://api.github.com/users/clelsonsalles/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-01-27T18:55:33Z","updated_at":"2016-01-27T18:55:33Z","closed_at":null,"body":"Adequar a implementação do SQL que seleciona os últimos trâmites para permitir a sua execução no Postgresql\r\nA partir da linha 751 do arquivo https://github.com/culturagovbr/GOG/blob/master/src/main/java/br/com/xti/ouvidoria/dao/ManifestacaoDTODAO.java\r\n\r\n```java\r\n        \t\tStringBuffer complementoSQLUltimoTramite = new StringBuffer();\r\n        \t\tcomplementoSQLUltimoTramite.append( \r\n        \t\t\t\t\"( SELECT distinct enc.idEncaminhamento \"\r\n        \t\t\t\t+ \" FROM TbEncaminhamento enc \"\r\n        \t\t\t\t+ \" INNER JOIN TbTramite tram on tram.idEncaminhamento = enc.idEncaminhamento \"\r\n        \t\t\t\t+ \" WHERE tram.idTramite in( \"\r\n        \t\t\t\t// Seleciona o último Trâmite\r\n        \t\t\t\t// TODO: deve tratar adequadamente para projetos com Postgresql\r\n        \t\t\t\t+ \"    SELECT TOP 1 ultimoTramite.idTramite \"\r\n        \t\t\t\t+ \"    FROM TbTramite ultimoTramite \"\r\n        \t\t\t\t+ \"    INNER JOIN TbUsuario usuarioReceptorUltimoTramite  ON usuarioReceptorUltimoTramite.idUsuario   = ultimoTramite.idUsuarioReceptor \"\r\n        \t\t\t\t+ \"    WHERE ultimoTramite.idEncaminhamento = enc.idEncaminhamento \"\r\n        \t\t\t\t// ... trâmite designado para um OPERADOR\r\n        \t\t\t\t+ \"        and usuarioReceptorUltimoTramite.tpFuncao   = '\" + FuncaoUsuarioEnum.OPERADOR.getId() + \"' \"\r\n        \t\t\t\t// ... trâmite que não retornou\r\n        \t\t\t\t+ \"        and ultimoTramite.stRetornada\t=   '\" + BooleanEnum.NAO.getId() + \"' \"\r\n        \t\t\t\t+ \"    ORDER BY ultimoTramite.idTramite DESC )\"\r\n        \t\t\t\t+ \" ) \" );  \r\n\r\n```"}}