package org.lilie.services.eliot.notes.impression.synthese
+import org.lilie.services.eliot.absences.statistiques.mensuelle.ModeCalcul
+import org.lilie.services.eliot.absences.statistiques.mensuelle.StatsMensuellesParams
+import org.lilie.services.eliot.absences.statistiques.Type
import org.lilie.services.eliot.impression.donnees.synthese.SyntheseImpression
import org.lilie.services.eliot.notes.resultat.synthese.Synthese
import org.lilie.services.eliot.utils.NoteFormateur
import org.lilie.services.eliot.notes.PreferenceUtilisateurNotes
import org.lilie.services.eliot.notes.impression.NotesImpressionService
import org.lilie.services.eliot.scolarite.PeriodeService
+import org.lilie.services.eliot.parametrages.motifs.MotifService
+import org.lilie.services.eliot.applications.absences.PriseEnCompteMotif
+import org.lilie.services.eliot.absences.PreferencesEtablissementAbsences
+import org.lilie.services.eliot.scolarite.etablissement.PreferencesEtablissementAbsencesService
+import org.lilie.services.eliot.absences.statistiques.periode.StatsPeriodesService
+import org.lilie.services.eliot.absences.statistiques.periode.StatsPeriodes
+import org.lilie.services.eliot.absences.statistiques.periode.StatsPeriodesLigne
/**
* Ce service permet de convertir un objet Synthese en objet SyntheseImpression
class ImpressionSyntheseService {
private static final POSITION_MOYENNE = 9999
+ private static final POSITION_ABSENCES = 10000
+ private static final POSITION_RETARDS = 10001
+ private static final POSITION_DEPARTS_ANTICIPES = 10002
LocalPersonneService localPersonneService
PreferenceUtilisateurNotesService preferenceUtilisateurNotesService
NotesImpressionService notesImpressionService
PeriodeService periodeService
+ MotifService motifService
+ PreferencesEtablissementAbsencesService preferencesEtablissementAbsencesService
+ StatsPeriodesService statsPeriodesService
public SyntheseImpression construisTableauImpression(Synthese synthese,
- SecuriteSession securiteSession) {
+ SecuriteSession securiteSession,
+ OptionsImpressionParams optionsImpressionParams) {
SyntheseImpression tab = new SyntheseImpression(
classe: synthese?.classe?.code,
etablissement: synthese?.classe?.etablissement?.nomAffichage
)
- tab.data = construitTableau(synthese, securiteSession)
+ tab.data = construitTableau(synthese, securiteSession, optionsImpressionParams)
return tab
}
* @return
*/
private List<CelluleTableau> construitTableau(Synthese synthese,
- SecuriteSession securiteSession) {
+ SecuriteSession securiteSession,
+ OptionsImpressionParams optionsImpressionParams) {
NoteFormateur nf =
synthese.classe.etablissement.etablissementNotes.getNoteFormateur()
ServiceOrdre ordreService = new ServiceOrdre()
+ List<Integer> serviceNoteList = []
+ List<Integer> sousServiceNoteList = []
+ getServiceEtSousServiceNotes(nf, synthese, serviceNoteList, sousServiceNoteList)
+
+ Periode periodeDeSynthese = synthese.periode
+
synthese.syntheseEleves.each { SyntheseEleve syntheseEleve ->
PreferenceUtilisateurNotes pref =
long index = 1
- syntheseEleve.services.each { Service service ->
-
- index = ordreService.getPosition(service)
-
- ResultatEleveServicePeriode resultatEleve =
- syntheseEleve.resultatEleveServicePeriodes?.find {
- it.service.id == service.id
- }
+ if (optionsImpressionParams.moyennes && optionsImpressionParams.appreciations == false){
+ syntheseEleve.services.each { Service service ->
- String note = nf.format(resultatEleve?.getValeurAffichage())
+ index = ordreService.getPosition(service)
- // Le resultat de la classe pour le service
- ResultatClasseServicePeriode resultatClasse =
- synthese.syntheseClasse.resultatClasseServicePeriodes?.find {
- it.service.id == service.id
- }
+ ResultatEleveServicePeriode resultatEleve =
+ syntheseEleve.resultatEleveServicePeriodes?.find {
+ it.service.id == service.id
+ }
- List<Personne> enseignants =
- localPersonneService.findAllPersonneBySetAutorite(
- service.enseignements.collect {it.enseignant} as Set
- )
+ String note = nf.format(resultatEleve?.getValeurAffichage())
- String nomsEnseignants = libelleListeEnseignants(enseignants)
+ // Le resultat de la classe pour le service
+ ResultatClasseServicePeriode resultatClasse =
+ synthese.syntheseClasse.resultatClasseServicePeriodes?.find {
+ it.service.id == service.id
+ }
- Periode periodeDeSynthese = synthese.periode
+ List<Personne> enseignants =
+ localPersonneService.findAllPersonneBySetAutorite(
+ service.enseignements.collect {it.enseignant} as Set
+ )
- // rechercher des sous-services
- List<SousService> sousServices = service.getSousServices(
- periodeDeSynthese.typePeriode
- )
+ String nomsEnseignants = libelleListeEnseignants(enseignants)
- if (sousServices) {
- // on a des sous-services
- prepareSousServices(
- index,
- nf,
- service,
- nomsEnseignants,
- sousServices,
- tableau,
- syntheseEleve,
- resultatClasse,
- resultatEleve
- )
- }
- else {
-
- // pas de sous-service
- tableau << getCelluleTableau(
- syntheseEleve,
- synthese,
- service,
- nomsEnseignants,
- note,
- resultatClasse,
- index
+ // rechercher des sous-services
+ List<SousService> sousServices = service.getSousServices(
+ periodeDeSynthese.typePeriode
)
+ // si le service a des sous-service et que l'utilisateur veut les afficher ...
+ if (sousServices && optionsImpressionParams.sousMatieres) {
+ prepareSousServices(
+ index,
+ nf,
+ service,
+ nomsEnseignants,
+ sousServices,
+ tableau,
+ syntheseEleve,
+ resultatClasse,
+ resultatEleve,
+ optionsImpressionParams,
+ sousServiceNoteList
+ )
+ }
+ // sinon ...
+ else {
+ // pas de sous-service
+ if (serviceNoteList.contains(service.id)){
+ tableau << getCelluleTableau(
+ syntheseEleve,
+ synthese,
+ service,
+ nomsEnseignants,
+ note,
+ resultatClasse,
+ index
+ )
+ }
+ }
}
+ }
- if (pref?.moyennesPrecedentes == true &&
- periodeDeSynthese.typePeriode?.isNotation()){
- periodeDeSynthese.getPeriodesPrecedentes()?.each{ Periode periodePrecedente ->
- tableau << getCelluleI18nMoyennePrecedente(syntheseEleve, synthese, periodePrecedente)
- }
+ if (pref?.moyennesPrecedentes == true &&
+ periodeDeSynthese.typePeriode?.isNotation()){
+ periodeDeSynthese.getPeriodesPrecedentes()?.each{ Periode periodePrecedente ->
+ tableau << getCelluleI18nMoyennePrecedente(syntheseEleve, synthese, periodePrecedente)
}
+ }
- tableau << getCelluleI18n(syntheseEleve, synthese)
+ tableau << getCelluleI18n(syntheseEleve, synthese)
- Integer rangInteger = syntheseEleve.resultatElevePeriode?.rang
- String rang = rangInteger ? rangInteger.toString() : ""
- if (pref?.rangs == true){
- tableau << getCelluleI18nRang(synthese, syntheseEleve, rang)
- }
+ Integer rangInteger = syntheseEleve.resultatElevePeriode?.rang
+ String rang = rangInteger ? rangInteger.toString() : ""
+ if (pref?.rangs == true){
+ tableau << getCelluleI18nRang(synthese, syntheseEleve, rang)
}
}
+ if (optionsImpressionParams.vieScolaire == true) {
+ listeVieScolaire(synthese, tableau, securiteSession)
+ }
+
return tableau
}
List<CelluleTableau> tableau,
SyntheseEleve syntheseEleve,
ResultatClasseServicePeriode resultatClasseServicePeriode,
- ResultatEleveServicePeriode resultatEleveServicePeriode) {
+ ResultatEleveServicePeriode resultatEleveServicePeriode,
+ OptionsImpressionParams optionsImpressionParams,
+ List<Integer> sousServiceNoteList) {
String appreciation = syntheseEleve.appreciationElevePeriode?.appreciation
Integer indexSousMatiere = 1
sousServices.each {SousService sousService ->
+ if (sousServiceNoteList.contains(sousService.id)){
- ResultatEleveSousServicePeriode resSousService =
- resultatEleveServicePeriode?.resultatsEleveSousServicePeriode.find {
- it.sousService.id == sousService.id
- }
+ ResultatEleveSousServicePeriode resSousService =
+ resultatEleveServicePeriode?.resultatsEleveSousServicePeriode.find {
+ it.sousService.id == sousService.id
+ }
- ResultatClasseSousServicePeriode resClasseSousService =
- resultatClasseServicePeriode?.resultatsClasseSousServicePeriode.find {
- it.sousService.id == sousService.id
- }
+ ResultatClasseSousServicePeriode resClasseSousService =
+ resultatClasseServicePeriode?.resultatsClasseSousServicePeriode.find {
+ it.sousService.id == sousService.id
+ }
+
+
+ tableau << new CelluleI18n(
+ enteteLigne: syntheseEleve.eleve.nomAffichage(),
+ entete1: service.matiere.codeGestion,
+ entete2: enseignants,
+ entete3: indexSousMatiere + sousService.modaliteMatiere.libelle,
+ entete4: sousService.coeff,
+ finLigne: appreciation ? appreciation : "",
+ valeur: nf.format(resSousService?.getValeurAffichage()),
+ pied1: nf.format(resClasseSousService?.moyenne),
+ pied2: nf.format(resClasseSousService?.moyenneMin),
+ pied3: nf.format(resClasseSousService?.moyenneMax),
+ index: index
+ )
+ indexSousMatiere++
+
+ }
+ }
+
+ if (indexSousMatiere != 1){
+ ResultatEleveServicePeriode resService = syntheseEleve.
+ resultatEleveServicePeriodes?.find {it.service.id == service.id}
tableau << new CelluleTableau(
enteteLigne: syntheseEleve.eleve.nomAffichage(),
entete1: service.matiere.codeGestion,
entete2: enseignants,
- entete3: indexSousMatiere + sousService.modaliteMatiere.libelle,
- entete4: sousService.coeff,
+ entete3: "3Moy.",
finLigne: appreciation ? appreciation : "",
- valeur: nf.format(resSousService?.getValeurAffichage()),
- pied1: nf.format(resClasseSousService?.moyenne),
- pied2: nf.format(resClasseSousService?.moyenneMin),
- pied3: nf.format(resClasseSousService?.moyenneMax),
+ valeur: nf.format(resService?.getValeurAffichage()),
+ pied1: nf.format(resultatClasseServicePeriode?.moyenne),
+ pied2: nf.format(resultatClasseServicePeriode?.moyenneMin),
+ pied3: nf.format(resultatClasseServicePeriode?.moyenneMax),
index: index
)
- indexSousMatiere++
-
}
- ResultatEleveServicePeriode resService = syntheseEleve.
- resultatEleveServicePeriodes?.find {it.service.id == service.id}
-
- tableau << new CelluleTableau(
- enteteLigne: syntheseEleve.eleve.nomAffichage(),
- entete1: service.matiere.codeGestion,
- entete2: enseignants,
- entete3: "3Moy.",
- finLigne: appreciation ? appreciation : "",
- valeur: nf.format(resService?.getValeurAffichage()),
- pied1: nf.format(resultatClasseServicePeriode?.moyenne),
- pied2: nf.format(resultatClasseServicePeriode?.moyenneMin),
- pied3: nf.format(resultatClasseServicePeriode?.moyenneMax),
- index: index
- )
}
- /**
- * Retourne le libellé de la liste des enseignants
- *
- * @param enseignants
- * @return : le libellé est calculé de la manière suivante :
- * <nom avec initiale prenom>,...
- */
+/**
+ * Retourne le libellé de la liste des enseignants
+ *
+ * @param enseignants
+ * @return : le libellé est calculé de la manière suivante :
+ * <nom avec initiale prenom>,...
+ */
private String libelleListeEnseignants(List<Personne> enseignants) {
String nomsEnseignants = ""
enseignants.each {Personne enseignant ->
return nomsEnseignants
}
+ /*
+ * Détection des matières et sous-matières qui n'ont pas de notes
+ */
+ private void getServiceEtSousServiceNotes(NoteFormateur nf,
+ Synthese synthese,
+ List<Integer> serviceNoteList,
+ List<Integer> sousServiceNoteList){
+ synthese.syntheseEleves.each{ SyntheseEleve syntheseEleve ->
+
+ syntheseEleve.services.each { Service service ->
+
+ ResultatEleveServicePeriode resultatEleve =
+ syntheseEleve.resultatEleveServicePeriodes?.find {
+ it.service.id == service.id
+ }
+ String note = nf.format(resultatEleve?.getValeurAffichage())
+ Boolean hasServiceNote = note != null && !"".equalsIgnoreCase(note)
+
+ if (hasServiceNote){
+ if (!serviceNoteList.find{it == service.id}){
+ serviceNoteList.add(service.id)
+ }
+ }
+
+ Periode periodeDeSynthese = synthese.periode
+ List<SousService> sousServices = service.getSousServices(
+ periodeDeSynthese.typePeriode
+ )
+ sousServices?.each{ SousService sousService ->
+ ResultatEleveSousServicePeriode resSousService =
+ resultatEleve?.resultatsEleveSousServicePeriode.find {
+ it.sousService.id == sousService.id
+ }
+ String noteSousService = nf.format(resSousService?.getValeurAffichage())
+ Boolean hasSousServiceNote =
+ noteSousService != null && !"".equalsIgnoreCase(noteSousService)
+
+ if (hasSousServiceNote){
+ if (!sousServiceNoteList.find{it == sousService.id}){
+ sousServiceNoteList.add(sousService.id)
+ }
+ }
+ }
+
+ }
+
+ }
+ }
+
+ /**
+ * Calcule les informations de vie scolaire des élèves de la synthèse
+ * - le nombre d'absences
+ * - de retards
+ * - de départs anticipés
+ *
+ * @param synthese synthèse en cours d'impression
+ * @param tableau
+ * @param securiteSession
+ * @return informations concernant la vie scolaire
+ */
+ protected void listeVieScolaire(
+ Synthese synthese,
+ List<CelluleTableau> tableau,
+ SecuriteSession securiteSession) {
+
+ PreferencesEtablissementAbsences preferencesEtablissementAbsences =
+ preferencesEtablissementAbsencesService.
+ getPreferencesEtablissementForEtablissement(
+ securiteSession.etablissementCourant)
+
+ List<Long> motifIds = motifService.findAllMotifForPriseEnCompteMotif(
+ preferencesEtablissementAbsences,
+ PriseEnCompteMotif.STATS,
+ false
+ )*.id
+
+ StatsPeriodes statsPeriodesAbsences =
+ calculeAbsencesTotales(synthese, preferencesEtablissementAbsences, motifIds)
+
+ statsPeriodesAbsences.lignes.each { statsPeriodesLigne ->
+
+ if (statsPeriodesLigne.tableauStatsPeriodes.valeurs.size() == 0) {
+ tableau << new CelluleI18n(
+ enteteLigne: statsPeriodesLigne.personne.nomAffichage(),
+ entete1: 'eliot.notes.libelle.absences',
+ entete2: "",
+ entete3: "",
+ entete4: "",
+ finLigne: "",
+ index: POSITION_ABSENCES,
+ valeur: "",
+ pied1: "",
+ pied2: "",
+ pied3: ""
+ )
+ }
+ else {
+ statsPeriodesLigne.tableauStatsPeriodes.valeurs.each { statsPeriodesValeur ->
+ tableau << new CelluleI18n(
+ enteteLigne: statsPeriodesLigne.personne.nomAffichage(),
+ entete1: 'eliot.notes.libelle.absences',
+ entete2: "",
+ entete3: "",
+ entete4: "",
+ finLigne: "",
+ index: POSITION_ABSENCES,
+ valeur: statsPeriodesValeur.valeurBrute,
+ pied1: "",
+ pied2: "",
+ pied3: ""
+ )
+ }
+ }
+ }
+
+ StatsPeriodes statsPeriodesRetards =
+ calculeRetards(synthese, preferencesEtablissementAbsences, motifIds)
+
+ statsPeriodesRetards.lignes.each { statsPeriodesLigne ->
+ if (statsPeriodesLigne.tableauStatsPeriodes.valeurs.size() == 0) {
+ tableau << new CelluleI18n(
+ enteteLigne: statsPeriodesLigne.personne.nomAffichage(),
+ entete1: 'eliot.notes.libelle.retards',
+ entete2: "",
+ entete3: "",
+ entete4: "",
+ finLigne: "",
+ index: POSITION_RETARDS,
+ valeur: "",
+ pied1: "",
+ pied2: "",
+ pied3: ""
+ )
+ }
+ else {
+ statsPeriodesLigne.tableauStatsPeriodes.valeurs.each { statsPeriodesValeur ->
+ tableau << new CelluleI18n(
+ enteteLigne: statsPeriodesLigne.personne.nomAffichage(),
+ entete1: 'eliot.notes.libelle.retards',
+ entete2: "",
+ entete3: "",
+ entete4: "",
+ finLigne: "",
+ index: POSITION_RETARDS,
+ valeur: statsPeriodesValeur.valeurBrute,
+ pied1: "",
+ pied2: "",
+ pied3: ""
+ )
+ }
+ }
+ }
+
+ StatsPeriodes statsPeriodesDepartsAnticipes =
+ calculeDepartsAnticipes(synthese, preferencesEtablissementAbsences, motifIds)
+
+ statsPeriodesDepartsAnticipes.lignes.each { statsPeriodesLigne ->
+
+ if (statsPeriodesLigne.tableauStatsPeriodes.valeurs.size() == 0) {
+ tableau << new CelluleI18n(
+ enteteLigne: statsPeriodesLigne.personne.nomAffichage(),
+ entete1: 'eliot.notes.libelle.departsAnticipes',
+ entete2: "",
+ entete3: "",
+ entete4: "",
+ finLigne: "",
+ index: POSITION_DEPARTS_ANTICIPES,
+ valeur: "",
+ pied1: "",
+ pied2: "",
+ pied3: ""
+ )
+ }
+ else {
+ statsPeriodesLigne.tableauStatsPeriodes.valeurs.each { statsPeriodesValeur ->
+ tableau << new CelluleI18n(
+ enteteLigne: statsPeriodesLigne.personne.nomAffichage(),
+ entete1: 'eliot.notes.libelle.departsAnticipes',
+ entete2: "",
+ entete3: "",
+ entete4: "",
+ finLigne: "",
+ index: POSITION_DEPARTS_ANTICIPES,
+ valeur: statsPeriodesValeur.valeurBrute,
+ pied1: "",
+ pied2: "",
+ pied3: ""
+ )
+ }
+ }
+ }
+
+ }
+
+ /**
+ * Calcule les absences justifiées et non justifiées
+ * @param synthese
+ * @param preferencesEtablissementAbsences
+ * @param motifIds
+ * @return un StatsPeriodes
+ */
+ private StatsPeriodes calculeAbsencesTotales(
+ Synthese synthese,
+ PreferencesEtablissementAbsences preferencesEtablissementAbsences,
+ List<Long> motifIds) {
+
+ StatsMensuellesParams params =
+ creeBaseCriteresRecherche(synthese, preferencesEtablissementAbsences, motifIds)
+
+ params.absencesValables = true
+ params.absencesNonValables = true
+
+ return calculeStatistiquesAbsences(
+ synthese, preferencesEtablissementAbsences, params)
+ }
+
+ /**
+ * Calcule les retards
+ * @param synthese
+ * @param preferencesEtablissementAbsences
+ * @param motifIds
+ * @return un StatsPeriodes
+ */
+ StatsPeriodes calculeRetards(
+ Synthese synthese,
+ PreferencesEtablissementAbsences preferencesEtablissementAbsences,
+ List<Long> motifIds) {
+
+ StatsMensuellesParams params =
+ creeBaseCriteresRecherche(synthese, preferencesEtablissementAbsences, motifIds)
+
+ params.retards = true
+
+ return calculeStatistiquesAbsences(
+ synthese, preferencesEtablissementAbsences, params)
+ }
+
+ /**
+ * Calcule les départs anticipés
+ * @param synthese
+ * @param preferencesEtablissementAbsences
+ * @param motifIds
+ * @return un StatsPeriodes
+ */
+ StatsPeriodes calculeDepartsAnticipes(
+ Synthese synthese,
+ PreferencesEtablissementAbsences preferencesEtablissementAbsences,
+ List<Long> motifIds) {
+
+ StatsMensuellesParams params =
+ creeBaseCriteresRecherche(synthese, preferencesEtablissementAbsences, motifIds)
+
+ params.departsAnticipes = true
+
+ return calculeStatistiquesAbsences(
+ synthese, preferencesEtablissementAbsences, params)
+ }
+
+ /**
+ * Crée les critères de recherche de base
+ * @param synthese
+ * @param preferencesEtablissementAbsences
+ * @param motifIds
+ * @return un StatsMensuellesParams
+ */
+ protected StatsMensuellesParams creeBaseCriteresRecherche(
+ Synthese synthese,
+ PreferencesEtablissementAbsences preferencesEtablissementAbsences,
+ List<Long> motifIds) {
+
+ StatsMensuellesParams params = new StatsMensuellesParams(
+ modeCalcul: ModeCalcul.VOLUME,
+ type: Type.ABSENCES
+ )
+
+ params.dateDebut.setTime(synthese.periode.dateDebut)
+ params.dateFin.setTime(synthese.periode.dateFin)
+ params.eleveIds = synthese.syntheseEleves*.eleve.autorite.id
+ params.structIds = [synthese.classe.id]
+ params.motifIds = motifIds
+ params.etablissementId = preferencesEtablissementAbsences.etablissement.id
+
+ return params
+ }
+
+ /**
+ * Calcule les statistiques d'absences
+ * @param synthese
+ * @param preferencesEtablissementAbsences
+ * @param params
+ * @return StatsPeriodes
+ */
+ protected StatsPeriodes calculeStatistiquesAbsences(
+ Synthese synthese,
+ PreferencesEtablissementAbsences preferencesEtablissementAbsences,
+ StatsMensuellesParams params) {
+
+ StatsPeriodes statsPeriodes = new StatsPeriodes(
+ periodes: [synthese.periode]
+ )
+
+ statsPeriodes.lignes.addAll(
+ synthese.syntheseEleves.collect({
+ new StatsPeriodesLigne(it.eleve)
+ }))
+
+ return (StatsPeriodes) statsPeriodesService.calculeStatsPeriodesAbsences(
+ params,
+ statsPeriodes,
+ preferencesEtablissementAbsences
+ )
+ }
}