Search in sources :

Example 26 with GridComponent

use of com.qcadoo.view.api.components.GridComponent in project mes by qcadoo.

the class DivisionDetailsListenersPL method onRemoveSelectedEntity.

public void onRemoveSelectedEntity(final ViewDefinitionState view, final ComponentState state, final String[] args) {
    GridComponent workstationsGrid = (GridComponent) view.getComponentByReference("workstations");
    List<Entity> workstationsToDelete = workstationsGrid.getSelectedEntities();
    for (Entity workstation : workstationsToDelete) {
        workstation.setField(WorkstationFieldsPL.PRODUCTION_LINE, null);
        workstation.setField(WorkstationFields.DIVISION, null);
        workstation.getDataDefinition().save(workstation);
    }
}
Also used : Entity(com.qcadoo.model.api.Entity) GridComponent(com.qcadoo.view.api.components.GridComponent)

Example 27 with GridComponent

use of com.qcadoo.view.api.components.GridComponent in project mes by qcadoo.

the class OrderTimePredictionHooks method setCriteriaModifierParameters.

private void setCriteriaModifierParameters(ViewDefinitionState view) {
    LookupComponent techComponent = (LookupComponent) view.getComponentByReference("technology");
    Entity tech = techComponent.getEntity();
    GridComponent grid = (GridComponent) view.getComponentByReference("operCompTimeCalculationsGrid");
    FilterValueHolder holder = grid.getFilterValue();
    if (Objects.nonNull(tech)) {
        holder.put(OperCompTimeCalculationsCM.TECHNOLOGY_PARAMETER, tech.getId());
        grid.setFilterValue(holder);
    } else {
        if (holder.has(OperCompTimeCalculationsCM.TECHNOLOGY_PARAMETER)) {
            holder.remove(OperCompTimeCalculationsCM.TECHNOLOGY_PARAMETER);
            grid.setFilterValue(holder);
        }
    }
}
Also used : FilterValueHolder(com.qcadoo.view.api.components.lookup.FilterValueHolder) Entity(com.qcadoo.model.api.Entity) LookupComponent(com.qcadoo.view.api.components.LookupComponent) GridComponent(com.qcadoo.view.api.components.GridComponent)

Example 28 with GridComponent

use of com.qcadoo.view.api.components.GridComponent in project mes by qcadoo.

the class ProductionLineScheduleDetailsListenersPS method generatePlan.

@Transactional
public void generatePlan(final ViewDefinitionState view, final ComponentState state, final String[] args) {
    List<Entity> productionLines = dataDefinitionService.get(ProductionLinesConstants.PLUGIN_IDENTIFIER, ProductionLinesConstants.MODEL_PRODUCTION_LINE).find().add(SearchRestrictions.eq(ProductionLineFields.PRODUCTION, true)).list().getEntities();
    if (productionLines.isEmpty()) {
        view.addMessage("orders.error.productionLineScheduleNoProductionLines", ComponentState.MessageType.SUCCESS);
        return;
    }
    FormComponent formComponent = (FormComponent) state;
    GridComponent ordersGrid = (GridComponent) view.getComponentByReference(ProductionLineScheduleFields.ORDERS);
    Entity schedule = getOrders(ordersGrid.getEntities(), formComponent.getEntity());
    formComponent.setEntity(schedule);
    assignOrdersToProductionLines(schedule, productionLines);
    view.addMessage("orders.info.productionLineSchedulePositionsGenerated", ComponentState.MessageType.SUCCESS);
}
Also used : Entity(com.qcadoo.model.api.Entity) FormComponent(com.qcadoo.view.api.components.FormComponent) GridComponent(com.qcadoo.view.api.components.GridComponent) Transactional(org.springframework.transaction.annotation.Transactional)

Example 29 with GridComponent

use of com.qcadoo.view.api.components.GridComponent in project mes by qcadoo.

the class ScheduleDetailsListenersPS method getOperations.

@Transactional
public void getOperations(final ViewDefinitionState view, final ComponentState state, final String[] args) {
    GridComponent ordersGrid = (GridComponent) view.getComponentByReference(ScheduleFields.ORDERS);
    List<Entity> orders = ordersGrid.getEntities();
    FormComponent formComponent = (FormComponent) state;
    Entity schedule = formComponent.getEntity();
    boolean includeTpz = schedule.getBooleanField(ScheduleFields.INCLUDE_TPZ);
    DataDefinition schedulePositionDD = dataDefinitionService.get(OrdersConstants.PLUGIN_IDENTIFIER, OrdersConstants.MODEL_SCHEDULE_POSITION);
    List<Entity> positions = Lists.newArrayList();
    for (Entity order : orders) {
        Entity technology = order.getBelongsToField(OrderFields.TECHNOLOGY);
        if (technology == null) {
            continue;
        }
        final Map<Long, BigDecimal> operationRuns = Maps.newHashMap();
        OperationProductComponentWithQuantityContainer operationProductComponentWithQuantityContainer = productQuantitiesService.getProductComponentQuantities(technology, order.getDecimalField(OrderFields.PLANNED_QUANTITY), operationRuns);
        List<Entity> operationComponents = technology.getHasManyField(TechnologyFields.OPERATION_COMPONENTS);
        for (Entity operationComponent : operationComponents) {
            BigDecimal operationComponentRuns = BigDecimalUtils.convertNullToZero(operationRuns.get(operationComponent.getId()));
            BigDecimal staffFactor = getStaffFactor(operationComponent);
            OperationWorkTime operationWorkTime = operationWorkTimeService.estimateTechOperationWorkTime(operationComponent, operationComponentRuns, includeTpz, false, false, staffFactor);
            Entity schedulePosition = createSchedulePosition(schedule, schedulePositionDD, order, operationComponent, operationWorkTime, operationProductComponentWithQuantityContainer, operationComponentRuns);
            positions.add(schedulePosition);
        }
    }
    schedule.setField(ScheduleFields.POSITIONS, positions);
    schedule = schedule.getDataDefinition().save(schedule);
    formComponent.setEntity(schedule);
    view.addMessage("productionScheduling.info.schedulePositionsGenerated", ComponentState.MessageType.SUCCESS);
}
Also used : Entity(com.qcadoo.model.api.Entity) FormComponent(com.qcadoo.view.api.components.FormComponent) OperationProductComponentWithQuantityContainer(com.qcadoo.mes.technologies.dto.OperationProductComponentWithQuantityContainer) OperationWorkTime(com.qcadoo.mes.operationTimeCalculations.OperationWorkTime) GridComponent(com.qcadoo.view.api.components.GridComponent) DataDefinition(com.qcadoo.model.api.DataDefinition) BigDecimal(java.math.BigDecimal) Transactional(org.springframework.transaction.annotation.Transactional)

Example 30 with GridComponent

use of com.qcadoo.view.api.components.GridComponent in project mes by qcadoo.

the class NegotiationDetailsHooks method changeFieldsEnabled.

private void changeFieldsEnabled(final ViewDefinitionState view, final boolean enabledForm, final boolean enabledGrid) {
    FormComponent negotiationForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
    GridComponent negotiationProducts = (GridComponent) view.getComponentByReference(NEGOTIATION_PRODUCTS);
    negotiationForm.setFormEnabled(enabledForm);
    negotiationProducts.setEnabled(enabledGrid);
    negotiationProducts.setEditable(enabledGrid);
}
Also used : FormComponent(com.qcadoo.view.api.components.FormComponent) GridComponent(com.qcadoo.view.api.components.GridComponent)

Aggregations

GridComponent (com.qcadoo.view.api.components.GridComponent)260 Entity (com.qcadoo.model.api.Entity)131 FormComponent (com.qcadoo.view.api.components.FormComponent)85 FieldComponent (com.qcadoo.view.api.components.FieldComponent)33 WindowComponent (com.qcadoo.view.api.components.WindowComponent)30 RibbonActionItem (com.qcadoo.view.api.ribbon.RibbonActionItem)29 JSONObject (org.json.JSONObject)28 FilterValueHolder (com.qcadoo.view.api.components.lookup.FilterValueHolder)26 RibbonGroup (com.qcadoo.view.api.ribbon.RibbonGroup)24 ComponentState (com.qcadoo.view.api.ComponentState)23 DataDefinition (com.qcadoo.model.api.DataDefinition)22 ViewDefinitionState (com.qcadoo.view.api.ViewDefinitionState)22 QcadooViewConstants (com.qcadoo.view.constants.QcadooViewConstants)20 CheckBoxComponent (com.qcadoo.view.api.components.CheckBoxComponent)19 Autowired (org.springframework.beans.factory.annotation.Autowired)19 BigDecimal (java.math.BigDecimal)16 Service (org.springframework.stereotype.Service)16 LookupComponent (com.qcadoo.view.api.components.LookupComponent)15 Collectors (java.util.stream.Collectors)15 Lists (com.google.common.collect.Lists)12