use of me.kadarh.mecaworks.domain.user.DashbordChantier in project mecaworks by KadarH.
the class DashbordChantierServiceImpl method getDashbordChantier.
@Override
public DashbordChantier getDashbordChantier(Long idc, int mois, int annee) {
Long stock_c;
Long ecartPlus;
Long ecartMoins;
LocalDate dateMaj;
Optional<Stock> stock = stockRepo.findLastStockReel(idc);
List<Quantite> quantites = new ArrayList<>();
LocalDate d = LocalDate.of(annee, mois, 1);
for (int i = 12, month, yeaar; i >= 0; i--) {
month = d.minusMonths(i).getMonthValue();
yeaar = d.minusMonths(i).getYear();
quantites.add(userCalculService.getMonthsWithQuantities(chantierService.get(idc), month, yeaar));
}
if (stock.isPresent()) {
ecartPlus = stock.get().getEcart_plus().longValue();
ecartMoins = stock.get().getEcart_moins().longValue();
dateMaj = stock.get().getDate();
} else {
ecartPlus = 0L;
ecartMoins = 0L;
dateMaj = LocalDate.now();
}
return new DashbordChantier(userCalculService.getListDaysQuantities(chantierService.get(idc), mois, annee), quantites, userCalculService.getListChantierStockDays(chantierService.get(idc), mois, annee), chantierService.get(idc).getStock().longValue(), ecartPlus, ecartMoins, dateMaj, chantierService.get(idc));
}
Aggregations