#46 Perfil de Empleado - Registro Semanal

This commit is contained in:
Melina Gutierrez 2024-10-22 15:04:40 -04:00
parent e3d672c00b
commit 4ad745145f
5 changed files with 60 additions and 1 deletions

View File

@ -72,6 +72,12 @@
<scope>runtime</scope> <scope>runtime</scope>
</dependency> </dependency>
<dependency>
<groupId>org.apache.pdfbox</groupId>
<artifactId>pdfbox</artifactId>
<version>2.0.29</version>
</dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId> <artifactId>spring-boot-starter-data-jpa</artifactId>

View File

@ -0,0 +1,10 @@
package com.primefactorsolutions.repositories;
import com.primefactorsolutions.model.HoursWorked;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
@Repository
public interface HoursWorkedRepository extends JpaRepository<HoursWorked, Long> {
// Puedes definir consultas personalizadas aquí si es necesario.
}

View File

@ -0,0 +1,35 @@
package com.primefactorsolutions.service;
import com.primefactorsolutions.model.HoursWorked;
import com.primefactorsolutions.repositories.HoursWorkedRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class HoursWorkedService {
private final HoursWorkedRepository hoursWorkedRepository;
@Autowired
public HoursWorkedService(HoursWorkedRepository hoursWorkedRepository) {
this.hoursWorkedRepository = hoursWorkedRepository;
}
public List<HoursWorked> findAll() {
return hoursWorkedRepository.findAll();
}
public HoursWorked saveHoursWorked(HoursWorked hoursWorked) {
return hoursWorkedRepository.save(hoursWorked);
}
public HoursWorked save(HoursWorked hoursWorked) {
return hoursWorkedRepository.save(hoursWorked);
}
public void deleteHoursWorked(Long id) {
hoursWorkedRepository.deleteById(id);
}
}

View File

@ -3,6 +3,7 @@ import com.primefactorsolutions.model.Actividad;
import com.primefactorsolutions.model.Employee; import com.primefactorsolutions.model.Employee;
import com.primefactorsolutions.model.HoursWorked; import com.primefactorsolutions.model.HoursWorked;
import com.primefactorsolutions.service.EmployeeService; import com.primefactorsolutions.service.EmployeeService;
import com.primefactorsolutions.service.HoursWorkedService;
import com.vaadin.flow.component.datepicker.DatePicker; import com.vaadin.flow.component.datepicker.DatePicker;
import com.vaadin.flow.component.grid.Grid; import com.vaadin.flow.component.grid.Grid;
import com.vaadin.flow.component.notification.Notification; import com.vaadin.flow.component.notification.Notification;
@ -48,8 +49,10 @@ public class HoursWorkedView extends VerticalLayout {
private final Label horasPendientesLabel = new Label(); private final Label horasPendientesLabel = new Label();
@Autowired @Autowired
public HoursWorkedView(final EmployeeService employeeService) { private final HoursWorkedService hoursWorkedService;
public HoursWorkedView(final EmployeeService employeeService, final HoursWorkedService hoursWorkedService) {
this.employeeService = employeeService; this.employeeService = employeeService;
this.hoursWorkedService = hoursWorkedService;
configurarVista(); configurarVista();
cargarDatos(); cargarDatos();
} }
@ -218,6 +221,9 @@ public class HoursWorkedView extends VerticalLayout {
HoursWorked hoursWorked = new HoursWorked(); HoursWorked hoursWorked = new HoursWorked();
hoursWorked.setEmployee(employeeComboBox.getValue()); hoursWorked.setEmployee(employeeComboBox.getValue());
hoursWorked.setWeekNumber(weekNumber); hoursWorked.setWeekNumber(weekNumber);
hoursWorked.setTotalHours((actividades.stream()
.mapToDouble(this::calcularTotalPorDia).sum()));
hoursWorkedService.save(hoursWorked);
Notification.show("Actividades guardadas correctamente."); Notification.show("Actividades guardadas correctamente.");
} }

View File

@ -148,6 +148,8 @@ public class MainLayout extends AppLayout {
LineAwesomeIcon.HOURGLASS_START_SOLID.create()); LineAwesomeIcon.HOURGLASS_START_SOLID.create());
timesheet.addItem(new SideNavItem("Hours Worked", HoursWorkedView.class, timesheet.addItem(new SideNavItem("Hours Worked", HoursWorkedView.class,
LineAwesomeIcon.ID_CARD_SOLID.create())); LineAwesomeIcon.ID_CARD_SOLID.create()));
// timesheet.addItem(new SideNavItem("Reporte", ReportHoursWorkedView.class,
// LineAwesomeIcon.CAR_ALT_SOLID.create()));
SideNavItem profile = new SideNavItem("My Profile", ProfileView.class, SideNavItem profile = new SideNavItem("My Profile", ProfileView.class,
LineAwesomeIcon.USER_EDIT_SOLID.create()); LineAwesomeIcon.USER_EDIT_SOLID.create());