Search in sources :

Example 1 with Shift

use of com.qcadoo.mes.basic.shift.Shift in project mes by qcadoo.

the class PPSReportXlsHelper method getDateToInMills.

private long getDateToInMills(final Entity goodFoodReport, final List<Entity> shifts) {
    DateTime dateTo = new DateTime(goodFoodReport.getDateField(PPSReportFields.DATE_TO));
    Shift shiftEnd = new Shift(shifts.get(shifts.size() - 1), dateTo, false);
    List<TimeRange> rangesEnd = shiftEnd.findWorkTimeAt(dateTo.toLocalDate());
    LocalTime endTime = rangesEnd.get(0).getTo();
    dateTo = dateTo.plusDays(ONE);
    dateTo = dateTo.withHourOfDay(endTime.getHourOfDay());
    dateTo = dateTo.withMinuteOfHour(endTime.getMinuteOfHour());
    Entity shiftEntity = shiftsService.getShiftFromDateWithTime(dateTo.toDate());
    if (Objects.nonNull(shiftEntity)) {
        Optional<DateTime> mayBeShiftEndDate = getShiftEndDate(new DateTime(dateTo), shiftEntity);
        if (mayBeShiftEndDate.isPresent()) {
            dateTo = mayBeShiftEndDate.get();
        }
    }
    return dateTo.getMillis();
}
Also used : Shift(com.qcadoo.mes.basic.shift.Shift) TimeRange(com.qcadoo.commons.dateTime.TimeRange) Entity(com.qcadoo.model.api.Entity) LocalTime(org.joda.time.LocalTime) DateTime(org.joda.time.DateTime)

Example 2 with Shift

use of com.qcadoo.mes.basic.shift.Shift in project mes by qcadoo.

the class PPSReportXlsHelper method getShiftEndDate.

private Optional<DateTime> getShiftEndDate(final DateTime day, final Entity shiftEntity) {
    Shift shift = new Shift(shiftEntity);
    com.google.common.base.Optional<DateRange> mayBeWorkTimeAt = shift.findWorkTimeAt(day.toDate());
    if (mayBeWorkTimeAt.isPresent()) {
        DateRange range = mayBeWorkTimeAt.get();
        return Optional.of(new DateTime(range.getTo()));
    }
    return Optional.empty();
}
Also used : Shift(com.qcadoo.mes.basic.shift.Shift) DateRange(com.qcadoo.commons.dateTime.DateRange) DateTime(org.joda.time.DateTime)

Example 3 with Shift

use of com.qcadoo.mes.basic.shift.Shift in project mes by qcadoo.

the class NonWorkingShiftsNotifier method showNotification.

private void showNotification(final FormComponent form, final String translationKey, final ShiftAndDate shiftAndDate) {
    Shift shift = shiftAndDate.shift;
    String workDate = DateUtils.toDateString(shiftAndDate.date.toDate());
    String shiftName = shift.getEntity().getStringField(ShiftFields.NAME);
    form.addMessage(translationKey, MessageType.INFO, shiftName, workDate);
}
Also used : Shift(com.qcadoo.mes.basic.shift.Shift)

Example 4 with Shift

use of com.qcadoo.mes.basic.shift.Shift in project mes by qcadoo.

the class OrderRealizationDaysResolverTest method shouldResolveRealizationDay5.

@Test
public final void shouldResolveRealizationDay5() {
    // given
    DateTime startDate = new DateTime(2014, 8, 14, 12, 0, 0);
    List<Shift> shifts = ImmutableList.of(shift1, shift2, shift3);
    // when
    // - 3rd order realization day is Saturday,
    // - shift working at given time will work at this date,
    OrderRealizationDay realizationDay = orderRealizationDaysResolver.find(startDate, 3, false, shifts);
    // then
    assertRealizationDayState(realizationDay, 5, startDate.toLocalDate().plusDays(4), shifts);
}
Also used : Shift(com.qcadoo.mes.basic.shift.Shift) DateTime(org.joda.time.DateTime) Test(org.junit.Test)

Example 5 with Shift

use of com.qcadoo.mes.basic.shift.Shift in project mes by qcadoo.

the class OrderRealizationDaysResolverTest method shouldResolveRealizationDay2.

@Test
public final void shouldResolveRealizationDay2() {
    // given
    DateTime startDate = new DateTime(2014, 8, 14, 3, 0, 0);
    List<Shift> shifts = ImmutableList.of(shift1, shift2, shift3);
    // when
    // - 1st order realization day is Thursday,
    // - it's a first day of order realization,
    // - shift starting order starts day before,
    // - 'day before' mentioned above is work day
    OrderRealizationDay realizationDay = orderRealizationDaysResolver.find(startDate, 1, true, shifts);
    // then
    assertRealizationDayState(realizationDay, 0, startDate.toLocalDate().minusDays(1), ImmutableList.of(shift1));
}
Also used : Shift(com.qcadoo.mes.basic.shift.Shift) DateTime(org.joda.time.DateTime) Test(org.junit.Test)

Aggregations

Shift (com.qcadoo.mes.basic.shift.Shift)37 DateTime (org.joda.time.DateTime)30 Entity (com.qcadoo.model.api.Entity)12 Test (org.junit.Test)11 TimeRange (com.qcadoo.commons.dateTime.TimeRange)9 DateTimeRange (com.qcadoo.mes.basic.util.DateTimeRange)8 Date (java.util.Date)7 LocalTime (org.joda.time.LocalTime)7 LocalDate (org.joda.time.LocalDate)6 BigDecimal (java.math.BigDecimal)3 DailyProgressContainer (com.qcadoo.mes.productionPerShift.domain.DailyProgressContainer)2 ErrorMessage (com.qcadoo.model.api.validators.ErrorMessage)2 Calendar (java.util.Calendar)2 HSSFCell (org.apache.poi.hssf.usermodel.HSSFCell)2 Function (com.google.common.base.Function)1 Optional (com.google.common.base.Optional)1 Predicate (com.google.common.base.Predicate)1 FluentIterable (com.google.common.collect.FluentIterable)1 Lists (com.google.common.collect.Lists)1 DateRange (com.qcadoo.commons.dateTime.DateRange)1