Search in sources :

Example 6 with Quantite

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

the class DashbordServiceImpl method addThisMonthToDashbord.

private Dashbord addThisMonthToDashbord(Dashbord dashbord, int mois, int year) {
    log.info("calling method addThisMonthToDashbord() in DashbordServiceImpl -- ");
    log.info("--> Add data for this month ");
    if (mois == LocalDate.now().getMonthValue() && year == LocalDate.now().getYear())
        dashbord.setChantierBatch(userCalculService.getListChantierWithQuantities(mois, year));
    else
        dashbord.setChantierBatch(chantierBatchRepo.findAllByMoisAndAnnee(mois, year).isEmpty() ? new ArrayList<>() : chantierBatchRepo.findAllByMoisAndAnnee(mois, year));
    dashbord.getQuantites().add(new Quantite(mois + "/" + year, dashbord.getChantierBatch().stream().mapToLong(ChantierBatch::getQuantite).sum(), dashbord.getChantierBatch().stream().mapToLong(ChantierBatch::getQuantiteLocation).sum(), dashbord.getChantierBatch().stream().mapToLong(ChantierBatch::getChargeLocataire).sum(), dashbord.getChantierBatch().stream().mapToLong(ChantierBatch::getChargeLocataireExterne).sum(), 8.5f, dashbord.getChantierBatch().stream().mapToLong(ChantierBatch::getConsommationPrevue).sum(), dashbord.getChantierBatch().stream().mapToLong(ChantierBatch::getGazoilAchete).sum(), dashbord.getChantierBatch().stream().mapToLong(ChantierBatch::getGazoilFlotant).sum()));
    log.info("--> Object Dashbored filled  ");
    // Todo : dashbord.getQuantites().sort(Comparator.comparing(Quantite::getQuantity));
    return dashbord;
}
Also used : Quantite(me.kadarh.mecaworks.domain.user.Quantite)

Aggregations

Quantite (me.kadarh.mecaworks.domain.user.Quantite)6 LocalDate (java.time.LocalDate)5 Stock (me.kadarh.mecaworks.domain.others.Stock)4 ChantierBatch (me.kadarh.mecaworks.domain.user.ChantierBatch)4 Month (java.time.Month)3 ChronoUnit (java.time.temporal.ChronoUnit)3 java.util (java.util)3 Collectors (java.util.stream.Collectors)3 Slf4j (lombok.extern.slf4j.Slf4j)3 BonEngin (me.kadarh.mecaworks.domain.bons.BonEngin)3 BonFournisseur (me.kadarh.mecaworks.domain.bons.BonFournisseur)3 BonLivraison (me.kadarh.mecaworks.domain.bons.BonLivraison)3 Chantier (me.kadarh.mecaworks.domain.others.Chantier)3 Engin (me.kadarh.mecaworks.domain.others.Engin)3 BonEnginRepo (me.kadarh.mecaworks.repo.bons.BonEnginRepo)3 BonFournisseurRepo (me.kadarh.mecaworks.repo.bons.BonFournisseurRepo)3 BonLivraisonRepo (me.kadarh.mecaworks.repo.bons.BonLivraisonRepo)3 StockRepo (me.kadarh.mecaworks.repo.others.StockRepo)3 EnginService (me.kadarh.mecaworks.service.EnginService)3 OperationFailedException (me.kadarh.mecaworks.service.exceptions.OperationFailedException)3