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;
}
Aggregations