Lista de Solicitudes de empleado - Actualizar estado
All checks were successful
PR Builder / Build-PR (pull_request) Successful in 2m40s
All checks were successful
PR Builder / Build-PR (pull_request) Successful in 2m40s
This commit is contained in:
parent
6d60fd00cc
commit
ca5fb122fb
@ -4,7 +4,6 @@ import com.vaadin.flow.component.page.AppShellConfigurator;
|
|||||||
import com.vaadin.flow.theme.Theme;
|
import com.vaadin.flow.theme.Theme;
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The entry point of the Spring Boot application.
|
* The entry point of the Spring Boot application.
|
||||||
*
|
*
|
||||||
|
@ -3,7 +3,6 @@ package com.primefactorsolutions.service;
|
|||||||
import com.primefactorsolutions.model.*;
|
import com.primefactorsolutions.model.*;
|
||||||
import com.primefactorsolutions.repositories.TimeOffRequestRepository;
|
import com.primefactorsolutions.repositories.TimeOffRequestRepository;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import org.springframework.scheduling.annotation.Scheduled;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
@ -53,27 +52,22 @@ public class TimeOffRequestService {
|
|||||||
return timeOffRequestRepository.findByEmployeeIdAndCategory(employeeId, category);
|
return timeOffRequestRepository.findByEmployeeIdAndCategory(employeeId, category);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Scheduled(cron = "0 0 0 * * ?")
|
public void updateRequestStatuses() {
|
||||||
private void updateRequestStatuses() {
|
|
||||||
List<TimeOffRequest> requests = findAllTimeOffRequests();
|
List<TimeOffRequest> requests = findAllTimeOffRequests();
|
||||||
LocalDate now = LocalDate.now();
|
LocalDate now = LocalDate.now();
|
||||||
|
|
||||||
for (TimeOffRequest request : requests) {
|
for (TimeOffRequest request : requests) {
|
||||||
if (request.getState() != TimeOffRequestStatus.RECHAZADO) {
|
if (request.getState() == TimeOffRequestStatus.APROBADO) {
|
||||||
LocalDate expirationDate = request.getExpiration();
|
|
||||||
LocalDate startDate = request.getStartDate();
|
LocalDate startDate = request.getStartDate();
|
||||||
LocalDate endDate = request.getEndDate();
|
LocalDate endDate = request.getEndDate();
|
||||||
|
|
||||||
if (now.isAfter(expirationDate)) {
|
if (now.isAfter(endDate)) {
|
||||||
request.setState(TimeOffRequestStatus.VENCIDO);
|
|
||||||
} else if (now.isAfter(endDate) && now.isBefore(expirationDate)) {
|
|
||||||
request.setState(TimeOffRequestStatus.TOMADO);
|
request.setState(TimeOffRequestStatus.TOMADO);
|
||||||
} else if (now.isEqual(startDate) || now.isAfter(startDate) && now.isBefore(endDate)) {
|
} else if (now.isEqual(startDate) || now.isAfter(startDate) && now.isBefore(endDate)) {
|
||||||
request.setState(TimeOffRequestStatus.EN_USO);
|
request.setState(TimeOffRequestStatus.EN_USO);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
saveAll(requests);
|
saveAll(requests);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -52,6 +52,7 @@ public class RequestEmployeeView extends Div implements HasUrlParameter<String>
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void initializeView() {
|
private void initializeView() {
|
||||||
|
requestService.updateRequestStatuses();
|
||||||
setupFilters();
|
setupFilters();
|
||||||
setupGrid();
|
setupGrid();
|
||||||
add(requestGrid, createActionButtons(), createSummaryLayout());
|
add(requestGrid, createActionButtons(), createSummaryLayout());
|
||||||
|
@ -63,6 +63,7 @@ public class RequestRegisterView extends VerticalLayout {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void initializeView() {
|
private void initializeView() {
|
||||||
|
requestService.updateRequestStatuses();
|
||||||
configureFormFields();
|
configureFormFields();
|
||||||
configureButtons();
|
configureButtons();
|
||||||
configureBinder();
|
configureBinder();
|
||||||
|
@ -57,6 +57,7 @@ public class RequestsListView extends Main {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void initializeView() {
|
private void initializeView() {
|
||||||
|
requestService.updateRequestStatuses();
|
||||||
setupFilters();
|
setupFilters();
|
||||||
setupRequestGrid();
|
setupRequestGrid();
|
||||||
add(requestGrid);
|
add(requestGrid);
|
||||||
|
Loading…
Reference in New Issue
Block a user