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