use of com.qcadoo.mes.productionPerShift.constants.ProgressType in project mes by qcadoo.
the class ProductionPerShiftDetailsHooks method onBeforeRender.
public void onBeforeRender(final ViewDefinitionState view) {
Entity order = getEntityFromLookup(view, ORDER_LOOKUP_REF).get();
OrderState orderState = OrderState.of(order);
ProgressType progressType = resolveProgressType(view);
AwesomeDynamicListComponent progressForDaysADL = (AwesomeDynamicListComponent) view.getComponentByReference(PROGRESS_ADL_REF);
if (!isViewAlreadyInitialized(view)) {
fillOrderDateComponents(view, order);
setupProgressTypeComboBox(view, orderState, progressType);
setProductAndFillProgressForDays(view, progressForDaysADL, orderState, progressType);
}
disableReasonOfCorrection(view, progressType, orderState);
disableComponents(progressForDaysADL, progressType, orderState);
changeButtonState(view, progressType, orderState);
updateAutoFillButtonState(view);
setupHasBeenCorrectedCheckbox(view);
checkOrderDates(view, order);
markViewAsInitialized(view);
deviationNotify(view);
}
use of com.qcadoo.mes.productionPerShift.constants.ProgressType in project mes by qcadoo.
the class ProductionPerShiftDetailsHooks method setProductAndFillProgressForDays.
public void setProductAndFillProgressForDays(final ViewDefinitionState view) {
Entity order = getEntityFromLookup(view, "order").get();
OrderState orderState = OrderState.of(order);
ProgressType progressType = resolveProgressType(view);
AwesomeDynamicListComponent progressForDaysADL = (AwesomeDynamicListComponent) view.getComponentByReference(PROGRESS_ADL_REF);
setProductAndFillProgressForDays(view, progressForDaysADL, orderState, progressType);
}
use of com.qcadoo.mes.productionPerShift.constants.ProgressType in project mes by qcadoo.
the class ProductionPerShiftDetailsHooks method deviationNotify.
private void deviationNotify(ViewDefinitionState view) {
FormComponent productionPerShiftForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
Entity pps = productionPerShiftForm.getPersistedEntityWithIncludedFormValues();
AwesomeDynamicListComponent progressForDaysADL = (AwesomeDynamicListComponent) view.getComponentByReference(PROGRESS_ADL_REF);
ProgressType progressType = resolveProgressType(view);
if (!progressForDaysADL.getEntities().isEmpty() && pps != null && (view.isViewAfterRedirect())) {
progressQuantitiesDeviationNotifier.compareAndNotify(view, pps, isCorrectedPlan(view));
}
}
use of com.qcadoo.mes.productionPerShift.constants.ProgressType in project mes by qcadoo.
the class ProgressPerShiftViewSaver method saveProgressesAndForm.
@Transactional
private boolean saveProgressesAndForm(final ViewDefinitionState view) {
AwesomeDynamicListComponent progressForDaysADL = (AwesomeDynamicListComponent) view.getComponentByReference(PROGRESS_ADL_REF);
FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
Entity pps = form.getEntity();
Long ppsId = pps.getId();
List<Entity> progressForDays = progressForDaysADL.getEntities();
ProgressType progressType = extractProgressType(view);
boolean hasCorrections = progressType == ProgressType.CORRECTED;
List<Entity> savedProgresses = validateAndSaveProgresses(progressForDays, pps, hasCorrections);
if (Iterables.all(savedProgresses, IS_VALID)) {
return tryUpdatePPS(view, pps, hasCorrections, savedProgresses);
} else {
progressForDaysADL.setFieldValue(savedProgresses);
showValidationErrors(view, FluentIterable.from(savedProgresses).transformAndConcat(new Function<Entity, Iterable<ErrorMessage>>() {
@Override
public Iterable<ErrorMessage> apply(final Entity input) {
return input.getGlobalErrors();
}
}));
rollbackCurrentTransaction();
return false;
}
}
use of com.qcadoo.mes.productionPerShift.constants.ProgressType 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