use of com.qcadoo.mes.productionPerShift.dates.OrderRealizationDay in project mes by qcadoo.
the class ProductionPerShiftListeners method updateProgressForDays.
public void updateProgressForDays(final ViewDefinitionState view, final ComponentState state, final String[] args) {
ProgressType progressType = detailsHooks.resolveProgressType(view);
Entity order = getEntityFromLookup(view, ORDER_LOOKUP_REF).get();
Optional<OrderDates> maybeOrderDates = resolveOrderDates(order);
if (!maybeOrderDates.isPresent()) {
return;
}
int lastDay = -1;
List<Shift> shifts = shiftsService.findAll(order.getBelongsToField(OrderFields.PRODUCTION_LINE));
LazyStream<OrderRealizationDay> realizationDaysStream = orderRealizationDaysResolver.asStreamFrom(progressType.extractStartDateTimeFrom(maybeOrderDates.get()), shifts);
AwesomeDynamicListComponent progressForDaysADL = (AwesomeDynamicListComponent) view.getComponentByReference(PROGRESS_ADL_REF);
for (FormComponent progressForDayForm : progressForDaysADL.getFormComponents()) {
FieldComponent dayField = progressForDayForm.findFieldComponentByName(DAY_NUMBER_INPUT_REF);
Integer dayNum = IntegerUtils.parse((String) dayField.getFieldValue());
if (dayNum == null) {
final int maxDayNum = lastDay;
if (realizationDaysStream != null) {
realizationDaysStream = realizationDaysStream.dropWhile(new Predicate<OrderRealizationDay>() {
@Override
public boolean apply(final OrderRealizationDay input) {
return input.getRealizationDayNumber() > maxDayNum;
}
});
OrderRealizationDay realizationDay = realizationDaysStream.head();
setUpProgressForDayRow(progressForDayForm, realizationDay);
lastDay = realizationDay.getRealizationDayNumber();
}
} else {
lastDay = dayNum;
}
}
}
Aggregations