feat: ajouter les exports CSV individuels des equipements commandes pour le flocage (initiales et prenom/numero)
This commit is contained in:
@@ -42,6 +42,12 @@ public class Dotation {
|
||||
@Column(name = "date_commande")
|
||||
private java.time.LocalDateTime dateCommande;
|
||||
|
||||
@Column(name = "flocage_exporte", nullable = false)
|
||||
private Boolean flocageExporte = false;
|
||||
|
||||
@Column(name = "date_flocage")
|
||||
private java.time.LocalDateTime dateFlocage;
|
||||
|
||||
// Getters and Setters
|
||||
|
||||
public Long getId() { return id; }
|
||||
@@ -77,6 +83,13 @@ 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 java.time.LocalDateTime getDateFlocage() { return dateFlocage; }
|
||||
public void setDateFlocage(java.time.LocalDateTime dateFlocage) { this.dateFlocage = dateFlocage; }
|
||||
|
||||
|
||||
public static boolean isSizeMatch(String option, String adherentSize) {
|
||||
if (option == null || adherentSize == null) return false;
|
||||
String opt = option.trim();
|
||||
|
||||
@@ -12,4 +12,6 @@ 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);
|
||||
}
|
||||
|
||||
|
||||
@@ -116,6 +116,106 @@ public class DotationService {
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public String genererCsvFlocageInitiales(Saison saisonActive) {
|
||||
List<Dotation> dotations = dotationRepository.findByLicence_SaisonAndChoisiTrueAndCommandeeTrueAndFlocageExporteFalse(saisonActive);
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
String dateExportFormatted = now.format(DATE_FORMATTER);
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append('\ufeff'); // BOM UTF-8 for Excel
|
||||
sb.append("Saison;Catégorie;Nom;Prénom;Équipement;Référence;Taille;Initiales;Date Export Flocage\n");
|
||||
|
||||
for (Dotation d : dotations) {
|
||||
if (d.getEquipement() == null || !d.getEquipement().isHasFlocageInitiales()) {
|
||||
continue;
|
||||
}
|
||||
String initiales = d.getFlocage() != null ? d.getFlocage().trim() : "";
|
||||
if (initiales.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
String saison = d.getLicence().getSaison() != null ? d.getLicence().getSaison().getNom() : "";
|
||||
String categorie = d.getLicence().getCategorie() != null ? d.getLicence().getCategorie().getNom() : "";
|
||||
String nom = d.getLicence().getAdherent() != null ? d.getLicence().getAdherent().getNom() : "";
|
||||
String prenom = d.getLicence().getAdherent() != null ? d.getLicence().getAdherent().getPrenom() : "";
|
||||
String equipement = d.getEquipement().getNom();
|
||||
String reference = d.getEquipement().getReference() != null ? d.getEquipement().getReference() : "";
|
||||
String taille = d.getTaille() != null ? d.getTaille() : "";
|
||||
|
||||
sb.append(escapeCsv(saison)).append(";")
|
||||
.append(escapeCsv(categorie)).append(";")
|
||||
.append(escapeCsv(nom)).append(";")
|
||||
.append(escapeCsv(prenom)).append(";")
|
||||
.append(escapeCsv(equipement)).append(";")
|
||||
.append(escapeCsv(reference)).append(";")
|
||||
.append(escapeCsv(taille)).append(";")
|
||||
.append(escapeCsv(initiales)).append(";")
|
||||
.append(escapeCsv(dateExportFormatted)).append("\n");
|
||||
|
||||
d.setFlocageExporte(true);
|
||||
d.setDateFlocage(now);
|
||||
dotationRepository.save(d);
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public String genererCsvFlocagePrenomNumero(Saison saisonActive) {
|
||||
List<Dotation> dotations = dotationRepository.findByLicence_SaisonAndChoisiTrueAndCommandeeTrueAndFlocageExporteFalse(saisonActive);
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
String dateExportFormatted = now.format(DATE_FORMATTER);
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append('\ufeff'); // BOM UTF-8 for Excel
|
||||
sb.append("Saison;Catégorie;Nom;Prénom;Équipement;Référence;Taille;Prénom Floqué;Numéro;Date Export Flocage\n");
|
||||
|
||||
for (Dotation d : dotations) {
|
||||
if (d.getEquipement() == null) {
|
||||
continue;
|
||||
}
|
||||
boolean handlesPrenom = d.getEquipement().isHasFlocagePrenom();
|
||||
boolean handlesNumero = d.getEquipement().isHasFlocageNumero();
|
||||
|
||||
if (!handlesPrenom && !handlesNumero) {
|
||||
continue;
|
||||
}
|
||||
|
||||
String prenomFloque = d.getFlocage() != null ? d.getFlocage().trim() : "";
|
||||
String numero = d.getNumero() != null ? d.getNumero().trim() : "";
|
||||
|
||||
if (prenomFloque.isEmpty() && numero.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
String saison = d.getLicence().getSaison() != null ? d.getLicence().getSaison().getNom() : "";
|
||||
String categorie = d.getLicence().getCategorie() != null ? d.getLicence().getCategorie().getNom() : "";
|
||||
String nom = d.getLicence().getAdherent() != null ? d.getLicence().getAdherent().getNom() : "";
|
||||
String prenom = d.getLicence().getAdherent() != null ? d.getLicence().getAdherent().getPrenom() : "";
|
||||
String equipement = d.getEquipement().getNom();
|
||||
String reference = d.getEquipement().getReference() != null ? d.getEquipement().getReference() : "";
|
||||
String taille = d.getTaille() != null ? d.getTaille() : "";
|
||||
|
||||
sb.append(escapeCsv(saison)).append(";")
|
||||
.append(escapeCsv(categorie)).append(";")
|
||||
.append(escapeCsv(nom)).append(";")
|
||||
.append(escapeCsv(prenom)).append(";")
|
||||
.append(escapeCsv(equipement)).append(";")
|
||||
.append(escapeCsv(reference)).append(";")
|
||||
.append(escapeCsv(taille)).append(";")
|
||||
.append(escapeCsv(prenomFloque)).append(";")
|
||||
.append(escapeCsv(numero)).append(";")
|
||||
.append(escapeCsv(dateExportFormatted)).append("\n");
|
||||
|
||||
d.setFlocageExporte(true);
|
||||
d.setDateFlocage(now);
|
||||
dotationRepository.save(d);
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
private String escapeCsv(String value) {
|
||||
if (value == null) {
|
||||
return "";
|
||||
@@ -130,3 +230,4 @@ public class DotationService {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
ALTER TABLE dotation ADD COLUMN flocage_exporte BOOLEAN NOT NULL DEFAULT FALSE;
|
||||
ALTER TABLE dotation ADD COLUMN date_flocage TIMESTAMP NULL;
|
||||
Reference in New Issue
Block a user