refactor(reports): remove tarefas, periodo and total_horas native tags
This commit is contained in:
parent
02fa938d28
commit
a569f1d9b8
5 changed files with 12 additions and 41 deletions
|
|
@ -129,22 +129,11 @@ public class GenerateReportUseCase {
|
||||||
|
|
||||||
List<Task> taskList = new ArrayList<>(uniqueTasks.values());
|
List<Task> taskList = new ArrayList<>(uniqueTasks.values());
|
||||||
|
|
||||||
// 2. Calcular tempo total trabalhado no período
|
// 2. Montar variáveis globais
|
||||||
long totalSecondsInPeriod = 0;
|
|
||||||
for (Task t : taskList) {
|
|
||||||
totalSecondsInPeriod += calculateTaskSecondsInPeriod(t, user.getEmail(), startDt, endDt);
|
|
||||||
}
|
|
||||||
|
|
||||||
String formattedTotalTime = formatDuration(totalSecondsInPeriod);
|
|
||||||
|
|
||||||
// 3. Montar variáveis globais
|
|
||||||
Map<String, String> variables = new HashMap<>();
|
Map<String, String> variables = new HashMap<>();
|
||||||
String strStart = input.startDate().format(DATE_FORMATTER);
|
String strStart = input.startDate().format(DATE_FORMATTER);
|
||||||
String strEnd = input.endDate().format(DATE_FORMATTER);
|
String strEnd = input.endDate().format(DATE_FORMATTER);
|
||||||
|
|
||||||
String pattern = template.getDateFormatPattern();
|
|
||||||
String formattedPeriod = formatPeriodWithPattern(input.startDate(), input.endDate(), pattern);
|
|
||||||
|
|
||||||
String monthName = input.startDate().getMonth().getDisplayName(TextStyle.FULL, PT_BR);
|
String monthName = input.startDate().getMonth().getDisplayName(TextStyle.FULL, PT_BR);
|
||||||
String mesAno = capitalize(monthName) + "/" + input.startDate().getYear();
|
String mesAno = capitalize(monthName) + "/" + input.startDate().getYear();
|
||||||
|
|
||||||
|
|
@ -169,14 +158,10 @@ public class GenerateReportUseCase {
|
||||||
variables.put("nome_projeto", projectName);
|
variables.put("nome_projeto", projectName);
|
||||||
variables.put("organizacao", org.getName());
|
variables.put("organizacao", org.getName());
|
||||||
|
|
||||||
// Período
|
// Datas
|
||||||
variables.put("periodo", formattedPeriod);
|
|
||||||
variables.put("periodo_vigencia", formattedPeriod);
|
|
||||||
variables.put("data_inicio", strStart);
|
variables.put("data_inicio", strStart);
|
||||||
variables.put("data_fim", strEnd);
|
variables.put("data_fim", strEnd);
|
||||||
variables.put("mes_ano", mesAno);
|
variables.put("mes_ano", mesAno);
|
||||||
|
|
||||||
variables.put("total_horas", formattedTotalTime);
|
|
||||||
variables.put("data_emissao", LocalDate.now().format(DATE_FORMATTER));
|
variables.put("data_emissao", LocalDate.now().format(DATE_FORMATTER));
|
||||||
|
|
||||||
// Valores padrão das seções configuradas no modelo
|
// Valores padrão das seções configuradas no modelo
|
||||||
|
|
@ -214,10 +199,6 @@ public class GenerateReportUseCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
variables.put(sec.getSectionKey(), formattedVal);
|
variables.put(sec.getSectionKey(), formattedVal);
|
||||||
if ("periodo".equalsIgnoreCase(sec.getSectionKey()) || "periodo_vigencia".equalsIgnoreCase(sec.getSectionKey())) {
|
|
||||||
variables.put("periodo", formattedVal);
|
|
||||||
variables.put("periodo_vigencia", formattedVal);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -286,7 +267,6 @@ public class GenerateReportUseCase {
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
listSections.put("atividades", allItems);
|
listSections.put("atividades", allItems);
|
||||||
listSections.put("tarefas", allItems);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 5. Baixar o template do MinIO e gerar o documento preenchido
|
// 5. Baixar o template do MinIO e gerar o documento preenchido
|
||||||
|
|
@ -318,7 +298,7 @@ public class GenerateReportUseCase {
|
||||||
generated.setOrganization(org);
|
generated.setOrganization(org);
|
||||||
generated.setProject(project);
|
generated.setProject(project);
|
||||||
generated.setUser(user);
|
generated.setUser(user);
|
||||||
generated.setTitle(template.getName() + " (" + formattedPeriod + ")");
|
generated.setTitle(template.getName() + " (" + strStart + " a " + strEnd + ")");
|
||||||
generated.setStartDate(input.startDate());
|
generated.setStartDate(input.startDate());
|
||||||
generated.setEndDate(input.endDate());
|
generated.setEndDate(input.endDate());
|
||||||
generated.setFileUrl(fileUrl);
|
generated.setFileUrl(fileUrl);
|
||||||
|
|
|
||||||
|
|
@ -257,12 +257,10 @@ export const CreateTemplateModal: React.FC<CreateTemplateModalProps> = ({
|
||||||
<p className="font-bold text-brand">Tags Nativas Automáticas Disponíveis no Word:</p>
|
<p className="font-bold text-brand">Tags Nativas Automáticas Disponíveis no Word:</p>
|
||||||
<p className="text-muted">
|
<p className="text-muted">
|
||||||
Você pode utilizar diretamente as tags{' '}
|
Você pode utilizar diretamente as tags{' '}
|
||||||
<code className="text-brand font-bold bg-brand/10 px-1 py-0.5 rounded">{'{{atividades}}'}</code> (ou <code className="text-brand font-bold bg-brand/10 px-1 py-0.5 rounded">{'{{tarefas}}'}</code>, com todas as atividades realizadas no período),{' '}
|
<code className="text-brand font-bold bg-brand/10 px-1 py-0.5 rounded">{'{{atividades}}'}</code> (com todas as atividades realizadas no período),{' '}
|
||||||
<code className="text-brand font-bold bg-brand/10 px-1 py-0.5 rounded">{'{{nome}}'}</code> (usuário logado),{' '}
|
<code className="text-brand font-bold bg-brand/10 px-1 py-0.5 rounded">{'{{nome}}'}</code> (usuário logado),{' '}
|
||||||
<code className="text-brand font-bold bg-brand/10 px-1 py-0.5 rounded">{'{{periodo}}'}</code> (período de vigência),{' '}
|
<code className="text-brand font-bold bg-brand/10 px-1 py-0.5 rounded">{'{{data_inicio}}'}</code> e{' '}
|
||||||
<code className="text-brand font-bold bg-brand/10 px-1 py-0.5 rounded">{'{{data_inicio}}'}</code>,{' '}
|
<code className="text-brand font-bold bg-brand/10 px-1 py-0.5 rounded">{'{{data_fim}}'}</code> sem precisar cadastrar campos para elas.
|
||||||
<code className="text-brand font-bold bg-brand/10 px-1 py-0.5 rounded">{'{{data_fim}}'}</code> e{' '}
|
|
||||||
<code className="text-brand font-bold bg-brand/10 px-1 py-0.5 rounded">{'{{total_horas}}'}</code> sem precisar cadastrar campos para elas.
|
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -275,12 +275,10 @@ export const EditTemplateModal: React.FC<EditTemplateModalProps> = ({
|
||||||
<p className="font-bold text-brand">Tags Nativas Automáticas Disponíveis no Word:</p>
|
<p className="font-bold text-brand">Tags Nativas Automáticas Disponíveis no Word:</p>
|
||||||
<p className="text-muted">
|
<p className="text-muted">
|
||||||
Você pode utilizar diretamente as tags{' '}
|
Você pode utilizar diretamente as tags{' '}
|
||||||
<code className="text-brand font-bold bg-brand/10 px-1 py-0.5 rounded">{'{{atividades}}'}</code> (ou <code className="text-brand font-bold bg-brand/10 px-1 py-0.5 rounded">{'{{tarefas}}'}</code>, com todas as atividades realizadas no período),{' '}
|
<code className="text-brand font-bold bg-brand/10 px-1 py-0.5 rounded">{'{{atividades}}'}</code> (com todas as atividades realizadas no período),{' '}
|
||||||
<code className="text-brand font-bold bg-brand/10 px-1 py-0.5 rounded">{'{{nome}}'}</code> (usuário logado),{' '}
|
<code className="text-brand font-bold bg-brand/10 px-1 py-0.5 rounded">{'{{nome}}'}</code> (usuário logado),{' '}
|
||||||
<code className="text-brand font-bold bg-brand/10 px-1 py-0.5 rounded">{'{{periodo}}'}</code> (período de vigência),{' '}
|
<code className="text-brand font-bold bg-brand/10 px-1 py-0.5 rounded">{'{{data_inicio}}'}</code> e{' '}
|
||||||
<code className="text-brand font-bold bg-brand/10 px-1 py-0.5 rounded">{'{{data_inicio}}'}</code>,{' '}
|
<code className="text-brand font-bold bg-brand/10 px-1 py-0.5 rounded">{'{{data_fim}}'}</code> sem precisar cadastrar campos para elas.
|
||||||
<code className="text-brand font-bold bg-brand/10 px-1 py-0.5 rounded">{'{{data_fim}}'}</code> e{' '}
|
|
||||||
<code className="text-brand font-bold bg-brand/10 px-1 py-0.5 rounded">{'{{total_horas}}'}</code> sem precisar cadastrar campos para elas.
|
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -358,8 +358,7 @@ export const GenerateReportModal: React.FC<GenerateReportModalProps> = ({
|
||||||
<div className="text-[11px] text-muted flex items-center gap-1.5 pt-1">
|
<div className="text-[11px] text-muted flex items-center gap-1.5 pt-1">
|
||||||
<span className="w-1.5 h-1.5 rounded-full bg-accent animate-pulse" />
|
<span className="w-1.5 h-1.5 rounded-full bg-accent animate-pulse" />
|
||||||
<span>
|
<span>
|
||||||
Refletirá nas tags: <code className="text-brand font-semibold">{'{{periodo}}'}</code>,{' '}
|
Refletirá nas tags: <code className="text-brand font-semibold">{'{{data_inicio}}'}</code> e{' '}
|
||||||
<code className="text-brand font-semibold">{'{{data_inicio}}'}</code> e{' '}
|
|
||||||
<code className="text-brand font-semibold">{'{{data_fim}}'}</code>.
|
<code className="text-brand font-semibold">{'{{data_fim}}'}</code>.
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -482,9 +481,9 @@ export const GenerateReportModal: React.FC<GenerateReportModalProps> = ({
|
||||||
<div className="flex items-center justify-between">
|
<div className="flex items-center justify-between">
|
||||||
<span className="text-xs font-bold text-foreground flex items-center gap-1.5">
|
<span className="text-xs font-bold text-foreground flex items-center gap-1.5">
|
||||||
<CheckCircle2 className="w-4 h-4 text-emerald-500" />
|
<CheckCircle2 className="w-4 h-4 text-emerald-500" />
|
||||||
Atividades e Tarefas (Preenchimento Automático)
|
Atividades Realizadas (Preenchimento Automático)
|
||||||
</span>
|
</span>
|
||||||
<span className="text-[10px] text-muted font-mono font-semibold">{'{{atividades}}'} / {'{{tarefas}}'}</span>
|
<span className="text-[10px] text-muted font-mono font-semibold">{'{{atividades}}'}</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<p className="text-[11px] text-muted leading-relaxed">
|
<p className="text-[11px] text-muted leading-relaxed">
|
||||||
|
|
|
||||||
|
|
@ -98,16 +98,12 @@ export const ReportsPage: React.FC = () => {
|
||||||
|
|
||||||
const standardTags = [
|
const standardTags = [
|
||||||
{ tag: '{{atividades}}', desc: 'Lista de todas as atividades/tarefas trabalhadas ou concluídas no período' },
|
{ tag: '{{atividades}}', desc: 'Lista de todas as atividades/tarefas trabalhadas ou concluídas no período' },
|
||||||
{ tag: '{{tarefas}}', desc: 'Alias alternativo para a listagem geral de atividades no período' },
|
|
||||||
{ tag: '{{nome}}', desc: 'Nome do colaborador (pega automaticamente do usuário logado)' },
|
{ tag: '{{nome}}', desc: 'Nome do colaborador (pega automaticamente do usuário logado)' },
|
||||||
{ tag: '{{periodo}}', desc: 'Período formatado no padrão escolhido no modelo (ex.: 01/10/2026 até 31/10/2026)' },
|
|
||||||
{ tag: '{{data_inicio}}', desc: 'Data inicial do período escolhido (ex: 01/10/2026)' },
|
{ tag: '{{data_inicio}}', desc: 'Data inicial do período escolhido (ex: 01/10/2026)' },
|
||||||
{ tag: '{{data_fim}}', desc: 'Data final do período escolhido (ex: 31/10/2026)' },
|
{ tag: '{{data_fim}}', desc: 'Data final do período escolhido (ex: 31/10/2026)' },
|
||||||
{ tag: '{{periodo_vigencia}}', desc: 'Intervalo formatado no modelo (ex: 01/10/2026 até 31/10/2026)' },
|
|
||||||
{ tag: '{{mes_ano}}', desc: 'Mês e ano por extenso (ex: Outubro/2026)' },
|
{ tag: '{{mes_ano}}', desc: 'Mês e ano por extenso (ex: Outubro/2026)' },
|
||||||
{ tag: '{{email_usuario}}', desc: 'E-mail do usuário logado' },
|
{ tag: '{{email_usuario}}', desc: 'E-mail do usuário logado' },
|
||||||
{ tag: '{{organizacao}}', desc: 'Nome da organização / workspace ativo' },
|
{ tag: '{{organizacao}}', desc: 'Nome da organização / workspace ativo' },
|
||||||
{ tag: '{{total_horas}}', desc: 'Total de horas trabalhadas no período (ex: 142h 30m)' },
|
|
||||||
{ tag: '{{data_emissao}}', desc: 'Data de geração do relatório (ex: 31/10/2026)' },
|
{ tag: '{{data_emissao}}', desc: 'Data de geração do relatório (ex: 31/10/2026)' },
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue