From 03146b1b9bf60974ea66f5a99eaa3f3dd9cb9247 Mon Sep 17 00:00:00 2001 From: Melina Gutierrez Date: Fri, 15 Nov 2024 12:26:47 -0400 Subject: [PATCH] =?UTF-8?q?A=C3=B1adir=20correcion=20de=20formato?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../model/HoursWorked.java | 4 ++-- .../repositories/EmployeeRepository.java | 2 +- .../service/EmployeeService.java | 2 +- .../service/HoursWorkedService.java | 6 +++--- .../service/ReportService.java | 3 ++- .../views/HoursWorkedListView.java | 20 +++++++++++-------- 6 files changed, 21 insertions(+), 16 deletions(-) diff --git a/src/main/java/com/primefactorsolutions/model/HoursWorked.java b/src/main/java/com/primefactorsolutions/model/HoursWorked.java index e5ef3f0..888b5fb 100644 --- a/src/main/java/com/primefactorsolutions/model/HoursWorked.java +++ b/src/main/java/com/primefactorsolutions/model/HoursWorked.java @@ -34,13 +34,13 @@ public class HoursWorked extends BaseEntity { private double horaspendientes; private double totalHours; - public static double calculateTotalHours(List activities) { + public static double calculateTotalHours(final List activities) { return activities.stream() .mapToDouble(activity -> activity.hours + activity.horasTareasEspecificas) .sum(); } - public static double calculatePendingHours(List activities) { + public static double calculatePendingHours(final List activities) { double totalHoursWorked = calculateTotalHours(activities); return Math.max(0, 40 - totalHoursWorked); } diff --git a/src/main/java/com/primefactorsolutions/repositories/EmployeeRepository.java b/src/main/java/com/primefactorsolutions/repositories/EmployeeRepository.java index 8c58a64..63e4a2a 100644 --- a/src/main/java/com/primefactorsolutions/repositories/EmployeeRepository.java +++ b/src/main/java/com/primefactorsolutions/repositories/EmployeeRepository.java @@ -11,7 +11,7 @@ public interface EmployeeRepository extends JpaRepository { Optional findByUsername(String username); Optional findByPersonalEmail(String personalEmail); - Optional findByTeamIdAndLeadManagerTrue(UUID teamId); + Optional findByTeamIdAndLeadManager(UUID teamId); List findByTeamName(String teamName); } \ No newline at end of file diff --git a/src/main/java/com/primefactorsolutions/service/EmployeeService.java b/src/main/java/com/primefactorsolutions/service/EmployeeService.java index dd3c179..9238fd0 100644 --- a/src/main/java/com/primefactorsolutions/service/EmployeeService.java +++ b/src/main/java/com/primefactorsolutions/service/EmployeeService.java @@ -50,7 +50,7 @@ public class EmployeeService { public String getTeamLeadName(final UUID teamId) { // Encuentra al empleado con el rol de lead_manager en el equipo especificado - Optional leadManager = employeeRepository.findByTeamIdAndLeadManagerTrue(teamId); + Optional leadManager = employeeRepository.findByTeamIdAndLeadManager(teamId); return leadManager.map(employee -> employee.getFirstName() + " " + employee.getLastName()) .orElse("No asignado"); diff --git a/src/main/java/com/primefactorsolutions/service/HoursWorkedService.java b/src/main/java/com/primefactorsolutions/service/HoursWorkedService.java index 80e4e88..36395bf 100644 --- a/src/main/java/com/primefactorsolutions/service/HoursWorkedService.java +++ b/src/main/java/com/primefactorsolutions/service/HoursWorkedService.java @@ -22,7 +22,7 @@ public class HoursWorkedService { return hoursWorkedRepository.findAll(); } - public double getTotalHoursWorkedByEmployeeForWeek(UUID employeeId, int weekNumber) { + public double getTotalHoursWorkedByEmployeeForWeek(final UUID employeeId, final int weekNumber) { List hoursWorkedList = hoursWorkedRepository.findByWeekNumber(weekNumber); return hoursWorkedList.stream() .filter(hw -> hw.getEmployee().getId().equals(employeeId)) @@ -44,12 +44,12 @@ public class HoursWorkedService { return hoursWorkedRepository.save(hoursWorked); } - public double getTotalHoursForEmployee(UUID employeeId, int weekNumber) { + public double getTotalHoursForEmployee(final UUID employeeId, final int weekNumber) { List activities = hoursWorkedRepository.findByEmployeeIdAndWeekNumber(employeeId, weekNumber); return HoursWorked.calculateTotalHours(activities); } - public double getPendingHoursForEmployee(UUID employeeId, int weekNumber) { + public double getPendingHoursForEmployee(final UUID employeeId, final int weekNumber) { List activities = hoursWorkedRepository.findByEmployeeIdAndWeekNumber(employeeId, weekNumber); return HoursWorked.calculatePendingHours(activities); } diff --git a/src/main/java/com/primefactorsolutions/service/ReportService.java b/src/main/java/com/primefactorsolutions/service/ReportService.java index a6de7e8..d7e2e3f 100644 --- a/src/main/java/com/primefactorsolutions/service/ReportService.java +++ b/src/main/java/com/primefactorsolutions/service/ReportService.java @@ -172,5 +172,6 @@ public class ReportService { cfg.setFallbackOnNullLoopVariable(false); cfg.setSQLDateAndTimeTimeZone(TimeZone.getDefault()); - return cfg;} + return cfg; + } } \ No newline at end of file diff --git a/src/main/java/com/primefactorsolutions/views/HoursWorkedListView.java b/src/main/java/com/primefactorsolutions/views/HoursWorkedListView.java index 7de2d98..4be4a2a 100644 --- a/src/main/java/com/primefactorsolutions/views/HoursWorkedListView.java +++ b/src/main/java/com/primefactorsolutions/views/HoursWorkedListView.java @@ -15,7 +15,6 @@ import com.vaadin.flow.router.PageTitle; import com.vaadin.flow.router.Route; import com.vaadin.flow.spring.annotation.SpringComponent; import jakarta.annotation.security.PermitAll; -import org.joda.time.Hours; import org.springframework.context.annotation.Scope; import org.vaadin.firitin.components.grid.PagingGrid; @@ -63,7 +62,8 @@ public class HoursWorkedListView extends Main { .mapToDouble(HoursWorked::getTotalHours) .sum(); - Notification.show("Total de horas trabajadas: " + totalHours, 3000, Notification.Position.BOTTOM_CENTER); + Notification.show("Total de horas trabajadas: " + totalHours, + 3000, Notification.Position.BOTTOM_CENTER); return hoursWorkedList; }); @@ -84,7 +84,8 @@ public class HoursWorkedListView extends Main { if (team != null && !"TODOS".equals(team.getName())) { filteredHoursWorked = filteredHoursWorked.stream() - .filter(hw -> hw.getEmployee().getTeam() != null && hw.getEmployee().getTeam().getId().equals(team.getId())) + .filter(hw -> hw.getEmployee().getTeam() != null + && hw.getEmployee().getTeam().getId().equals(team.getId())) .collect(Collectors.toList()); } @@ -94,7 +95,8 @@ public class HoursWorkedListView extends Main { int currentWeek = date.get(IsoFields.WEEK_OF_WEEK_BASED_YEAR); double totalWorkedInSameWeek = filteredHoursWorked.stream() - .filter(hw -> hw.getEmployee().getId().equals(employee.getId()) && + .filter(hw -> hw.getEmployee().getId().equals(employee.getId()) + && hw.getDate().get(IsoFields.WEEK_OF_WEEK_BASED_YEAR) == currentWeek) .mapToDouble(HoursWorked::getHours) .sum(); @@ -130,11 +132,13 @@ public class HoursWorkedListView extends Main { .setSortable(true); hoursWorkedGrid.addColumn(hw -> hw.getEmployee().getFirstName() + " " + hw.getEmployee().getLastName()) .setHeader("Empleado"); - hoursWorkedGrid.addColumn(hw -> hw.getEmployee().getTeam() != null ? hw.getEmployee().getTeam().getName() : "Sin asignar") + hoursWorkedGrid.addColumn(hw -> hw.getEmployee().getTeam() != null ? hw.getEmployee().getTeam() + .getName() : "Sin asignar") .setHeader("Equipo"); hoursWorkedGrid.addColumn(HoursWorked::getActividad).setHeader("Actividad"); - hoursWorkedGrid.addColumn(hw -> hw.getHours() ).setHeader("Total Horas").setSortable(true); - hoursWorkedGrid.addColumn(hw -> hw.getHoraspendientes() - calcularTotal(hw)).setHeader("Horas Pendientes").setSortable(true); + hoursWorkedGrid.addColumn(hw -> hw.getHours()).setHeader("Total Horas").setSortable(true); + hoursWorkedGrid.addColumn(hw -> hw.getHoraspendientes() - calcularTotal(hw)).setHeader("Horas Pendientes") + .setSortable(true); hoursWorkedGrid.setPaginationBarMode(PagingGrid.PaginationBarMode.BOTTOM); hoursWorkedGrid.setPageSize(5); @@ -146,7 +150,7 @@ public class HoursWorkedListView extends Main { }); } - private double calcularTotal(HoursWorked hoursWorked){ + private double calcularTotal(final HoursWorked hoursWorked) { List listHoursworkedemploye = hoursWorkedService.findListHoursWorkedEmployee( hoursWorked.getEmployee().getId(), hoursWorked.getWeekNumber()); return calculateTotalUtilized(listHoursworkedemploye);