feat: adicionar gerenciamento de configuração para arquivos DMED
This commit is contained in:
Vendored
BIN
Binary file not shown.
Vendored
+4
@@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"ultimo_arquivo_txt": "P:\\ProEmp00\\LFSM2026\\Dmed2026\\LfsIssDmed073225.txt",
|
||||||
|
"ultimo_arquivo_xls": "Z:\\Fiscal\\FELIPE\\RELATORIO\\RELATORIO_PROSOFT_MOD_51.XLS"
|
||||||
|
}
|
||||||
+71
-18
@@ -3,6 +3,42 @@
|
|||||||
use eframe::egui;
|
use eframe::egui;
|
||||||
use dmed::{processar_arquivo, xls::processar_xls, Pessoa};
|
use dmed::{processar_arquivo, xls::processar_xls, Pessoa};
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
use std::path::PathBuf;
|
||||||
|
use std::fs;
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize, Default)]
|
||||||
|
struct Config {
|
||||||
|
ultimo_arquivo_txt: Option<String>,
|
||||||
|
ultimo_arquivo_xls: Option<String>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Config {
|
||||||
|
fn carregar() -> Self {
|
||||||
|
let config_path = Self::caminho_config();
|
||||||
|
if config_path.exists() {
|
||||||
|
if let Ok(conteudo) = fs::read_to_string(&config_path) {
|
||||||
|
if let Ok(config) = serde_json::from_str(&conteudo) {
|
||||||
|
return config;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Self::default()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn salvar(&self) {
|
||||||
|
if let Ok(json) = serde_json::to_string_pretty(self) {
|
||||||
|
let _ = fs::write(Self::caminho_config(), json);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn caminho_config() -> PathBuf {
|
||||||
|
let mut path = std::env::current_exe().unwrap_or_default();
|
||||||
|
path.pop();
|
||||||
|
path.push("dmed_config.json");
|
||||||
|
path
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn main() -> eframe::Result {
|
fn main() -> eframe::Result {
|
||||||
let options = eframe::NativeOptions {
|
let options = eframe::NativeOptions {
|
||||||
@@ -15,11 +51,13 @@ fn main() -> eframe::Result {
|
|||||||
eframe::run_native(
|
eframe::run_native(
|
||||||
"DMED Comparador",
|
"DMED Comparador",
|
||||||
options,
|
options,
|
||||||
Box::new(|_cc| Ok(Box::new(ComparadorApp::default()))),
|
Box::new(|_cc| {
|
||||||
|
let config = Config::carregar();
|
||||||
|
Ok(Box::new(ComparadorApp::from_config(config)))
|
||||||
|
}),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default)]
|
|
||||||
struct ComparadorApp {
|
struct ComparadorApp {
|
||||||
arquivo_txt: Option<String>,
|
arquivo_txt: Option<String>,
|
||||||
arquivo_xls: Option<String>,
|
arquivo_xls: Option<String>,
|
||||||
@@ -32,6 +70,30 @@ struct ComparadorApp {
|
|||||||
mostrar_confirmacao_saida: bool,
|
mostrar_confirmacao_saida: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl ComparadorApp {
|
||||||
|
fn from_config(config: Config) -> Self {
|
||||||
|
Self {
|
||||||
|
arquivo_txt: config.ultimo_arquivo_txt,
|
||||||
|
arquivo_xls: config.ultimo_arquivo_xls,
|
||||||
|
resultado: String::new(),
|
||||||
|
divergencias: Vec::new(),
|
||||||
|
cpfs_so_txt: Vec::new(),
|
||||||
|
cpfs_so_xls: Vec::new(),
|
||||||
|
erros_validacao: Vec::new(),
|
||||||
|
processando: false,
|
||||||
|
mostrar_confirmacao_saida: false,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn salvar_config(&self) {
|
||||||
|
let config = Config {
|
||||||
|
ultimo_arquivo_txt: self.arquivo_txt.clone(),
|
||||||
|
ultimo_arquivo_xls: self.arquivo_xls.clone(),
|
||||||
|
};
|
||||||
|
config.salvar();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
struct ErroValidacao {
|
struct ErroValidacao {
|
||||||
cpf: String,
|
cpf: String,
|
||||||
@@ -105,6 +167,7 @@ impl eframe::App for ComparadorApp {
|
|||||||
self.arquivo_txt = Some(path.display().to_string());
|
self.arquivo_txt = Some(path.display().to_string());
|
||||||
self.resultado.clear();
|
self.resultado.clear();
|
||||||
self.divergencias.clear();
|
self.divergencias.clear();
|
||||||
|
self.salvar_config();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if let Some(ref path) = self.arquivo_txt {
|
if let Some(ref path) = self.arquivo_txt {
|
||||||
@@ -124,6 +187,7 @@ impl eframe::App for ComparadorApp {
|
|||||||
self.arquivo_xls = Some(path.display().to_string());
|
self.arquivo_xls = Some(path.display().to_string());
|
||||||
self.resultado.clear();
|
self.resultado.clear();
|
||||||
self.divergencias.clear();
|
self.divergencias.clear();
|
||||||
|
self.salvar_config();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if let Some(ref path) = self.arquivo_xls {
|
if let Some(ref path) = self.arquivo_xls {
|
||||||
@@ -157,6 +221,10 @@ impl eframe::App for ComparadorApp {
|
|||||||
ui.separator();
|
ui.separator();
|
||||||
ui.add_space(10.0);
|
ui.add_space(10.0);
|
||||||
|
|
||||||
|
// Scroll global para todos os resultados
|
||||||
|
egui::ScrollArea::vertical()
|
||||||
|
.auto_shrink([false, false])
|
||||||
|
.show(ui, |ui| {
|
||||||
// Resultados
|
// Resultados
|
||||||
if !self.resultado.is_empty() {
|
if !self.resultado.is_empty() {
|
||||||
ui.label(&self.resultado);
|
ui.label(&self.resultado);
|
||||||
@@ -168,9 +236,6 @@ impl eframe::App for ComparadorApp {
|
|||||||
ui.heading(format!("📋 Divergências de valores: {}", self.divergencias.len()));
|
ui.heading(format!("📋 Divergências de valores: {}", self.divergencias.len()));
|
||||||
ui.add_space(5.0);
|
ui.add_space(5.0);
|
||||||
|
|
||||||
egui::ScrollArea::vertical()
|
|
||||||
.max_height(200.0)
|
|
||||||
.show(ui, |ui| {
|
|
||||||
egui::Grid::new("divergencias_grid")
|
egui::Grid::new("divergencias_grid")
|
||||||
.striped(true)
|
.striped(true)
|
||||||
.min_col_width(100.0)
|
.min_col_width(100.0)
|
||||||
@@ -201,7 +266,6 @@ impl eframe::App for ComparadorApp {
|
|||||||
ui.end_row();
|
ui.end_row();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
ui.add_space(10.0);
|
ui.add_space(10.0);
|
||||||
}
|
}
|
||||||
@@ -214,9 +278,6 @@ impl eframe::App for ComparadorApp {
|
|||||||
ui.label("Estes CPFs estão no DMED mas não aparecem no Prosoft");
|
ui.label("Estes CPFs estão no DMED mas não aparecem no Prosoft");
|
||||||
ui.add_space(5.0);
|
ui.add_space(5.0);
|
||||||
|
|
||||||
egui::ScrollArea::vertical()
|
|
||||||
.max_height(150.0)
|
|
||||||
.show(ui, |ui| {
|
|
||||||
egui::Grid::new("cpfs_txt_grid")
|
egui::Grid::new("cpfs_txt_grid")
|
||||||
.striped(true)
|
.striped(true)
|
||||||
.min_col_width(100.0)
|
.min_col_width(100.0)
|
||||||
@@ -233,7 +294,6 @@ impl eframe::App for ComparadorApp {
|
|||||||
ui.end_row();
|
ui.end_row();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
ui.add_space(10.0);
|
ui.add_space(10.0);
|
||||||
}
|
}
|
||||||
@@ -246,9 +306,6 @@ impl eframe::App for ComparadorApp {
|
|||||||
ui.label("Estes CPFs estão no Prosoft mas não aparecem no DMED");
|
ui.label("Estes CPFs estão no Prosoft mas não aparecem no DMED");
|
||||||
ui.add_space(5.0);
|
ui.add_space(5.0);
|
||||||
|
|
||||||
egui::ScrollArea::vertical()
|
|
||||||
.max_height(150.0)
|
|
||||||
.show(ui, |ui| {
|
|
||||||
egui::Grid::new("cpfs_xls_grid")
|
egui::Grid::new("cpfs_xls_grid")
|
||||||
.striped(true)
|
.striped(true)
|
||||||
.min_col_width(100.0)
|
.min_col_width(100.0)
|
||||||
@@ -263,7 +320,6 @@ impl eframe::App for ComparadorApp {
|
|||||||
ui.end_row();
|
ui.end_row();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
ui.add_space(10.0);
|
ui.add_space(10.0);
|
||||||
}
|
}
|
||||||
@@ -276,9 +332,6 @@ impl eframe::App for ComparadorApp {
|
|||||||
ui.label("Estes registros possuem problemas que precisam ser corrigidos");
|
ui.label("Estes registros possuem problemas que precisam ser corrigidos");
|
||||||
ui.add_space(5.0);
|
ui.add_space(5.0);
|
||||||
|
|
||||||
egui::ScrollArea::vertical()
|
|
||||||
.max_height(150.0)
|
|
||||||
.show(ui, |ui| {
|
|
||||||
egui::Grid::new("erros_validacao_grid")
|
egui::Grid::new("erros_validacao_grid")
|
||||||
.striped(true)
|
.striped(true)
|
||||||
.min_col_width(100.0)
|
.min_col_width(100.0)
|
||||||
@@ -297,7 +350,6 @@ impl eframe::App for ComparadorApp {
|
|||||||
ui.end_row();
|
ui.end_row();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
ui.add_space(10.0);
|
ui.add_space(10.0);
|
||||||
}
|
}
|
||||||
@@ -321,6 +373,7 @@ impl eframe::App for ComparadorApp {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}); // Fecha o ScrollArea
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user