Search in sources :

Example 1 with Dashbord

use of me.kadarh.mecaworks.domain.user.Dashbord in project mecaworks by KadarH.

the class DashbordServiceImpl method getDashbordFromBatch.

private Dashbord getDashbordFromBatch(int mois, int year) {
    log.info("calling method getDashbordFromBatch() in DashbordServiceImpl -- ");
    log.info("--> Add data for 12 last month [ one year ago ] ");
    List<Quantite> quantites = new ArrayList<>();
    List<ChantierBatch> chantierBatches;
    LocalDate d = LocalDate.of(year, mois, 1);
    for (int i = 12, month, yeaar; i >= 1; i--) {
        month = d.minusMonths(i).getMonthValue();
        yeaar = d.minusMonths(i).getYear();
        chantierBatches = chantierBatchRepo.findAllByMoisAndAnnee(month, yeaar);
        quantites.add(new Quantite(month + "/" + yeaar, chantierBatches.stream().mapToLong(ChantierBatch::getQuantite).sum(), chantierBatches.stream().mapToLong(ChantierBatch::getQuantiteLocation).sum(), chantierBatches.stream().mapToLong(ChantierBatch::getChargeLocataire).sum(), chantierBatches.stream().mapToLong(ChantierBatch::getChargeLocataireExterne).sum(), 8.5f, chantierBatches.stream().mapToLong(ChantierBatch::getConsommationPrevue).sum(), chantierBatches.stream().mapToLong(ChantierBatch::getGazoilAchete).sum(), chantierBatches.stream().mapToLong(ChantierBatch::getGazoilFlotant).sum()));
    }
    Dashbord dashbord = new Dashbord();
    dashbord.setQuantites(quantites);
    return dashbord;
}
Also used : Dashbord(me.kadarh.mecaworks.domain.user.Dashbord) ChantierBatch(me.kadarh.mecaworks.domain.user.ChantierBatch) Quantite(me.kadarh.mecaworks.domain.user.Quantite) ArrayList(java.util.ArrayList) LocalDate(java.time.LocalDate)

Aggregations

LocalDate (java.time.LocalDate)1 ArrayList (java.util.ArrayList)1 ChantierBatch (me.kadarh.mecaworks.domain.user.ChantierBatch)1 Dashbord (me.kadarh.mecaworks.domain.user.Dashbord)1 Quantite (me.kadarh.mecaworks.domain.user.Quantite)1