refactor: separer les champs d export flocage en DB entre initiales et prenom/numero

This commit is contained in:
2026-08-09 00:51:09 +02:00
parent 6539e33f08
commit 03869841d5
5 changed files with 44 additions and 25 deletions
@@ -42,11 +42,17 @@ public class Dotation {
@Column(name = "date_commande")
private java.time.LocalDateTime dateCommande;
@Column(name = "flocage_exporte", nullable = false)
private Boolean flocageExporte = false;
@Column(name = "flocage_initiales_exporte", nullable = false)
private Boolean flocageInitialesExporte = false;
@Column(name = "date_flocage")
private java.time.LocalDateTime dateFlocage;
@Column(name = "date_flocage_initiales")
private java.time.LocalDateTime dateFlocageInitiales;
@Column(name = "flocage_prenom_numero_exporte", nullable = false)
private Boolean flocagePrenomNumeroExporte = false;
@Column(name = "date_flocage_prenom_numero")
private java.time.LocalDateTime dateFlocagePrenomNumero;
// Getters and Setters
@@ -83,11 +89,18 @@ public class Dotation {
public java.time.LocalDateTime getDateCommande() { return dateCommande; }
public void setDateCommande(java.time.LocalDateTime dateCommande) { this.dateCommande = dateCommande; }
public Boolean getFlocageExporte() { return flocageExporte; }
public void setFlocageExporte(Boolean flocageExporte) { this.flocageExporte = flocageExporte; }
public Boolean getFlocageInitialesExporte() { return flocageInitialesExporte; }
public void setFlocageInitialesExporte(Boolean flocageInitialesExporte) { this.flocageInitialesExporte = flocageInitialesExporte; }
public java.time.LocalDateTime getDateFlocageInitiales() { return dateFlocageInitiales; }
public void setDateFlocageInitiales(java.time.LocalDateTime dateFlocageInitiales) { this.dateFlocageInitiales = dateFlocageInitiales; }
public Boolean getFlocagePrenomNumeroExporte() { return flocagePrenomNumeroExporte; }
public void setFlocagePrenomNumeroExporte(Boolean flocagePrenomNumeroExporte) { this.flocagePrenomNumeroExporte = flocagePrenomNumeroExporte; }
public java.time.LocalDateTime getDateFlocagePrenomNumero() { return dateFlocagePrenomNumero; }
public void setDateFlocagePrenomNumero(java.time.LocalDateTime dateFlocagePrenomNumero) { this.dateFlocagePrenomNumero = dateFlocagePrenomNumero; }
public java.time.LocalDateTime getDateFlocage() { return dateFlocage; }
public void setDateFlocage(java.time.LocalDateTime dateFlocage) { this.dateFlocage = dateFlocage; }
public static boolean isSizeMatch(String option, String adherentSize) {
@@ -12,6 +12,8 @@ import com.astalange.core.entity.Saison;
public interface DotationRepository extends JpaRepository<Dotation, Long>, JpaSpecificationExecutor<Dotation> {
List<Dotation> findByLicence_SaisonAndChoisiTrueAndFourniFalse(Saison saison);
List<Dotation> findByLicence_SaisonAndChoisiTrueAndCommandeeFalse(Saison saison);
List<Dotation> findByLicence_SaisonAndChoisiTrueAndCommandeeTrueAndFlocageExporteFalse(Saison saison);
List<Dotation> findByLicence_SaisonAndChoisiTrueAndCommandeeTrueAndFlocageInitialesExporteFalse(Saison saison);
List<Dotation> findByLicence_SaisonAndChoisiTrueAndCommandeeTrueAndFlocagePrenomNumeroExporteFalse(Saison saison);
}
@@ -118,7 +118,7 @@ public class DotationService {
@Transactional
public String genererCsvFlocageInitiales(Saison saisonActive) {
List<Dotation> dotations = dotationRepository.findByLicence_SaisonAndChoisiTrueAndCommandeeTrueAndFlocageExporteFalse(saisonActive);
List<Dotation> dotations = dotationRepository.findByLicence_SaisonAndChoisiTrueAndCommandeeTrueAndFlocageInitialesExporteFalse(saisonActive);
LocalDateTime now = LocalDateTime.now();
String dateExportFormatted = now.format(DATE_FORMATTER);
@@ -153,8 +153,8 @@ public class DotationService {
.append(escapeCsv(initiales)).append(";")
.append(escapeCsv(dateExportFormatted)).append("\n");
d.setFlocageExporte(true);
d.setDateFlocage(now);
d.setFlocageInitialesExporte(true);
d.setDateFlocageInitiales(now);
dotationRepository.save(d);
}
@@ -163,7 +163,7 @@ public class DotationService {
@Transactional
public String genererCsvFlocagePrenomNumero(Saison saisonActive) {
List<Dotation> dotations = dotationRepository.findByLicence_SaisonAndChoisiTrueAndCommandeeTrueAndFlocageExporteFalse(saisonActive);
List<Dotation> dotations = dotationRepository.findByLicence_SaisonAndChoisiTrueAndCommandeeTrueAndFlocagePrenomNumeroExporteFalse(saisonActive);
LocalDateTime now = LocalDateTime.now();
String dateExportFormatted = now.format(DATE_FORMATTER);
@@ -208,14 +208,15 @@ public class DotationService {
.append(escapeCsv(numero)).append(";")
.append(escapeCsv(dateExportFormatted)).append("\n");
d.setFlocageExporte(true);
d.setDateFlocage(now);
d.setFlocagePrenomNumeroExporte(true);
d.setDateFlocagePrenomNumero(now);
dotationRepository.save(d);
}
return sb.toString();
}
private String escapeCsv(String value) {
if (value == null) {
return "";
@@ -1,2 +1,4 @@
ALTER TABLE dotation ADD COLUMN flocage_exporte BOOLEAN NOT NULL DEFAULT FALSE;
ALTER TABLE dotation ADD COLUMN date_flocage TIMESTAMP NULL;
ALTER TABLE dotation ADD COLUMN flocage_initiales_exporte BOOLEAN NOT NULL DEFAULT FALSE;
ALTER TABLE dotation ADD COLUMN date_flocage_initiales TIMESTAMP NULL;
ALTER TABLE dotation ADD COLUMN flocage_prenom_numero_exporte BOOLEAN NOT NULL DEFAULT FALSE;
ALTER TABLE dotation ADD COLUMN date_flocage_prenom_numero TIMESTAMP NULL;