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