Search in sources :

Example 1 with ProgressType

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);
}
Also used : Entity(com.qcadoo.model.api.Entity) ProgressType(com.qcadoo.mes.productionPerShift.constants.ProgressType) AwesomeDynamicListComponent(com.qcadoo.view.api.components.AwesomeDynamicListComponent) OrderState(com.qcadoo.mes.orders.states.constants.OrderState)

Example 2 with ProgressType

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);
}
Also used : Entity(com.qcadoo.model.api.Entity) ProgressType(com.qcadoo.mes.productionPerShift.constants.ProgressType) AwesomeDynamicListComponent(com.qcadoo.view.api.components.AwesomeDynamicListComponent) OrderState(com.qcadoo.mes.orders.states.constants.OrderState)

Example 3 with 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));
    }
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) Entity(com.qcadoo.model.api.Entity) ProgressType(com.qcadoo.mes.productionPerShift.constants.ProgressType) AwesomeDynamicListComponent(com.qcadoo.view.api.components.AwesomeDynamicListComponent)

Example 4 with ProgressType

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;
    }
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) Entity(com.qcadoo.model.api.Entity) Function(com.google.common.base.Function) ProgressType(com.qcadoo.mes.productionPerShift.constants.ProgressType) AwesomeDynamicListComponent(com.qcadoo.view.api.components.AwesomeDynamicListComponent) ErrorMessage(com.qcadoo.model.api.validators.ErrorMessage) Transactional(org.springframework.transaction.annotation.Transactional)

Example 5 with ProgressType

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;
        }
    }
}
Also used : Shift(com.qcadoo.mes.basic.shift.Shift) Entity(com.qcadoo.model.api.Entity) OrderRealizationDay(com.qcadoo.mes.productionPerShift.dates.OrderRealizationDay) Predicate(com.google.common.base.Predicate) OrderDates(com.qcadoo.mes.orders.dates.OrderDates) ProgressType(com.qcadoo.mes.productionPerShift.constants.ProgressType)

Aggregations

ProgressType (com.qcadoo.mes.productionPerShift.constants.ProgressType)5 Entity (com.qcadoo.model.api.Entity)5 AwesomeDynamicListComponent (com.qcadoo.view.api.components.AwesomeDynamicListComponent)4 OrderState (com.qcadoo.mes.orders.states.constants.OrderState)2 FormComponent (com.qcadoo.view.api.components.FormComponent)2 Function (com.google.common.base.Function)1 Predicate (com.google.common.base.Predicate)1 Shift (com.qcadoo.mes.basic.shift.Shift)1 OrderDates (com.qcadoo.mes.orders.dates.OrderDates)1 OrderRealizationDay (com.qcadoo.mes.productionPerShift.dates.OrderRealizationDay)1 ErrorMessage (com.qcadoo.model.api.validators.ErrorMessage)1 Transactional (org.springframework.transaction.annotation.Transactional)1