Search in sources :

Example 1 with DashbordChantier

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));
}
Also used : Quantite(me.kadarh.mecaworks.domain.user.Quantite) ArrayList(java.util.ArrayList) LocalDate(java.time.LocalDate) Stock(me.kadarh.mecaworks.domain.others.Stock) DashbordChantier(me.kadarh.mecaworks.domain.user.DashbordChantier)

Aggregations

LocalDate (java.time.LocalDate)1 ArrayList (java.util.ArrayList)1 Stock (me.kadarh.mecaworks.domain.others.Stock)1 DashbordChantier (me.kadarh.mecaworks.domain.user.DashbordChantier)1 Quantite (me.kadarh.mecaworks.domain.user.Quantite)1