Skip to content

Commit

Permalink
Merge pull request #45 from consiglionazionaledellericerche/44-cambio…
Browse files Browse the repository at this point in the history
…-namespace-per-invocazione-stored-procedure

Namespace PJ_TIMESHEET per stored procedure.
  • Loading branch information
criluc authored Apr 24, 2024
2 parents 2d3d693 + 616e942 commit 0eb65ea
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.NamedStoredProcedureQueries;
import jakarta.persistence.NamedStoredProcedureQuery;
import jakarta.persistence.Table;
import jakarta.validation.constraints.NotNull;
import lombok.AllArgsConstructor;
Expand All @@ -34,6 +36,16 @@
*
* @author Cristian Lucchesi
*/
@NamedStoredProcedureQueries({
@NamedStoredProcedureQuery(
name=PersonTimeDetail.LOAD_DETAILS_PROCEDURE_NAME,
procedureName="PJ_TIMESHEET.P_CARICA_MARCATURE"
),
@NamedStoredProcedureQuery(
name=PersonTimeDetail.LOAD_DETAILS_JOB_PROCEDURE_NAME,
procedureName="PJ_TIMESHEET.P_CARICA_MARCATURE_JOB"
)
})
@NoArgsConstructor
@AllArgsConstructor
@Builder
Expand All @@ -43,6 +55,8 @@
@Table(name = "IE_PJ_MARCATURE")
public class PersonTimeDetail {

public final static String LOAD_DETAILS_PROCEDURE_NAME = "loadDetails";
public final static String LOAD_DETAILS_JOB_PROCEDURE_NAME = "loadDetailsJob";
@Id
@Column(name = "ID_IE_PJ_MARCATURE")
private Long id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,20 +44,20 @@ public interface PersonTimeDetailRepo
@Query(value = "DELETE FROM PersonTimeDetail ptd")
void truncateTable();

@Procedure(procedureName = "IE_PJ.P_CARICA_MARCATURE")
@Procedure(name = PersonTimeDetail.LOAD_DETAILS_PROCEDURE_NAME)
void loadDetails();

@Procedure(procedureName = "IE_PJ.P_CARICA_MARCATURE_JOB")
@Procedure(name = PersonTimeDetail.LOAD_DETAILS_JOB_PROCEDURE_NAME)
void loadDetailsJob();

@Transactional
@Modifying
@Query(value = "call IE_PJ.P_CARICA_MARCATURE", nativeQuery = true)
@Query(value = "call PJ_TIMESHEET.P_CARICA_MARCATURE", nativeQuery = true)
void loadDetailsNative();

@Transactional
@Modifying
@Query(value = "call P_CARICA_MARCATURE_JOB", nativeQuery = true)
@Query(value = "call PJ_TIMESHEET.P_CARICA_MARCATURE_JOB", nativeQuery = true)
void loadDetailsJobNative();

@Query(value = "SELECT MAX(ptd.id) FROM PersonTimeDetail ptd")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.atomic.AtomicLong;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import com.google.common.base.Strings;
Expand Down Expand Up @@ -67,6 +67,8 @@ public class SyncService {

private final SemaphoreService semaphore;

@Value("${timesheet.number.length.max}")
private Integer numberMaxLenght;
/**
* Sincronizza il dato del tempo a lavoro di una persona in un giorno specifico.
*/
Expand Down Expand Up @@ -195,6 +197,12 @@ public List<PersonTimeDetail> syncPersonMonth(
log.info("Ignorata persona {} perché senza matricola", monthRecap.getPerson());
return details;
}
if (monthRecap.getPerson().getNumber().length() > Optional.ofNullable(numberMaxLenght).orElse(6)) {
log.info("Ignorata persona {} perché la matricola è più lunga di {} caratteri",
monthRecap.getPerson(), numberMaxLenght);
return details;
}

monthRecap.getPersonDays().forEach(personDay -> {
if (notBefore.isEmpty() || !personDay.getDate().isBefore(notBefore.get())) {
details.addAll(syncPersonDay(monthRecap.getPerson(), personDay, counter));
Expand All @@ -210,7 +218,7 @@ public List<PersonTimeDetail> syncPersonMonth(
public List<PersonTimeDetail> syncOfficeMonth(
long officeId, YearMonth yearMonth, Optional<LocalDate> notBefore,
AtomicLong counter) {
log.debug("Inizio sincronizzazione dell'ufficio id={} del {}, notBefore={}",
log.info("Inizio sincronizzazione dell'ufficio id={} del {}, notBefore={}",
officeId, yearMonth, notBefore);
long startTime = System.currentTimeMillis();
Timer.Sample timer = Timer.start(meterRegistry);
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ timesheet.all-day-presence-codes[0]=assign_all_day
timesheet.all-day-presence-codes[1]=complete_day_and_add_overtime
timesheet.delete-before-sync-all=true

timesheet.number.length.max=6

# Utilizzata per autenticare le chiamate REST a questo servizio
security.username=epas.timesheet
security.password=timesheet
Expand Down

0 comments on commit 0eb65ea

Please sign in to comment.