Last active
August 11, 2022 14:35
-
-
Save jjesusfilho/9078dc35e8bee4dd521d164afc86e0df to your computer and use it in GitHub Desktop.
Intimaçoes stj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(shiny) | |
orgaos <- c("Quinta Turma", "Sexta Turma", "CPPE", "Terceira Seção", | |
"CPRE", "CESP", "Corte Especial") | |
verificar <- readRDS("verificar.rds") | |
ui <- fluidPage( | |
titlePanel("Baixar intimações"), | |
sidebarLayout( | |
sidebarPanel( | |
dateInput(inputId = "data", | |
label = "Informe a data", | |
language = "pt-BR", | |
format = "dd/mm/yyyy"), | |
actionButton("buscar","Consulutar intimações") | |
), | |
mainPanel( | |
DT::DTOutput("tabela") | |
) | |
) | |
) | |
server <- function(input, output) { | |
conn <- DBI::dbConnect(RPostgres::Postgres(), | |
host="10.74.239.223", | |
dbname = "projetos", | |
user = Sys.getenv("DBUSER"), | |
password = Sys.getenv("DBPWD")) | |
#dbExecute(conn,"create schema intimacoes_stj") | |
DBI::dbExecute(conn,"set search_path = intimacoes_stj") | |
onStop(function() { | |
DBI::dbDisconnect(conn) | |
}) | |
base <- eventReactive(input$buscar, { | |
data1 <- input$data -10 | |
glue::glue_sql("select intimacoes.processo, | |
intimacoes.registro, | |
intimacoes.numero_unico, | |
lista_decisoes.sequencial, | |
intimacoes.orgao, | |
intimacoes.tipo_de_documento, | |
intimacoes.data_de_disponibilizacao, | |
intimacoes.prazo_para_ciencia, | |
intimacoes.segredo_de_justica, | |
detalhes.valor as ramo, | |
lista_decisoes.url, | |
lista_decisoes.texto as documento, | |
lista_decisoes.data as data_decisao, | |
decisoes.dispositivo, | |
decisoes.mp_papel, | |
decisoes.decisao | |
from intimacoes | |
left join lista_decisoes using (registro) | |
left join detalhes on lista_decisoes.registro = detalhes.registro | |
left join decisoes on lista_decisoes.registro = decisoes.registro | |
and lista_decisoes.sequencial = decisoes.sequencial | |
where detalhes.variavel = 'ramo_do_direito' | |
and data_de_disponibilizacao::date = {input$data} | |
and lista_decisoes.data >= {data1} | |
and lista_decisoes.data <= {input$data} | |
", .con = conn) | |
DBI::dbGetQuery(conn,q) |> | |
dplyr::filter(orgao %in% orgaos) |> | |
dplyr::mutate(militar = dplyr::case_when( | |
stringr::str_detect(numero_unico, "9\\.26\\.\\d{4}$") ~ TRUE, | |
TRUE ~ FALSE | |
)) |> | |
dplyr::mutate(competencia = dplyr::case_when( | |
numero_unico %in% unique(verificar$processo) ~ TRUE, | |
registro %in% unique(verificar$registro) ~ TRUE, | |
TRUE ~ FALSE | |
)) |> | |
dplyr::mutate(especial = dplyr::case_when( | |
militar ~ FALSE, | |
stringr::str_detect(orgao,"(CPRE|CESP|Corte Especial)") ~ TRUE, | |
TRUE ~ FALSE | |
)) | |
}) | |
observe( | |
output$tabela <- DT::renderDT(server = FALSE, | |
base(), | |
extensions = c('Buttons','Responsive'), | |
escape = FALSE, | |
options = list( | |
dom = 'Bfrtip', | |
buttons = | |
list(list( | |
extend = 'collection', | |
buttons = "excel", | |
text = 'Baixar', | |
exportOptions = list( | |
modifier = list(page = "all") | |
) | |
)) | |
) | |
) | |
) | |
} | |
shinyApp(ui = ui, server = server) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment