Search in sources :

Example 31 with FieldComponent

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

the class TrackingOperationProductInComponentDetailsListeners method recalculateUsedQuantity.

public void recalculateUsedQuantity(final ViewDefinitionState view, final ComponentState wasteUsedQuantity, final String[] args) {
    Entity entity = getFormEntity(view);
    boolean wasteUsedOnly = entity.getBooleanField(TrackingOperationProductInComponentFields.WASTE_USED_ONLY);
    boolean sameUnits = view.getComponentByReference(L_USED_QUANTITY_UNIT).getFieldValue().equals(view.getComponentByReference(L_WASTE_UNIT).getFieldValue());
    if (!wasteUsedOnly && sameUnits) {
        BigDecimal wasteUsed = entity.getDecimalField(TrackingOperationProductInComponentFields.WASTE_USED_QUANTITY);
        if (wasteUsed != null && wasteUsed.compareTo(BigDecimal.ZERO) > 0) {
            Entity savedEntity = entity.getDataDefinition().get(entity.getId());
            BigDecimal savedUsedQuantity = savedEntity.getDecimalField(TrackingOperationProductInComponentFields.USED_QUANTITY);
            BigDecimal savedWasteUsed = convertNullToZero(savedEntity.getDecimalField(TrackingOperationProductInComponentFields.WASTE_USED_QUANTITY));
            if (savedUsedQuantity != null) {
                MathContext mc = numberService.getMathContext();
                BigDecimal newValue = savedUsedQuantity.add(savedWasteUsed, mc).subtract(wasteUsed, mc);
                if (newValue.compareTo(BigDecimal.ZERO) < 0) {
                    newValue = BigDecimal.ZERO;
                }
                FieldComponent usedQuantity = (FieldComponent) view.getComponentByReference(L_USED_QUANTITY);
                usedQuantity.setFieldValue(numberService.format(newValue));
                trackingOperationProductComponentDetailsListeners.calculateQuantityToGiven(view, usedQuantity, ArrayUtils.EMPTY_STRING_ARRAY);
            }
        }
    }
}
Also used : Entity(com.qcadoo.model.api.Entity) FieldComponent(com.qcadoo.view.api.components.FieldComponent) BigDecimal(java.math.BigDecimal) MathContext(java.math.MathContext)

Example 32 with FieldComponent

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

the class UseReplacementListeners method fillUnitField.

public void fillUnitField(final ViewDefinitionState view, final ComponentState state, final String[] args) {
    LookupComponent productLookup = (LookupComponent) view.getComponentByReference(PRODUCT);
    Entity product = productLookup.getEntity();
    String unit = "";
    if (product != null) {
        unit = product.getStringField(ProductFields.UNIT);
    }
    FieldComponent field = (FieldComponent) view.getComponentByReference("unit");
    field.setFieldValue(unit);
    field.requestComponentUpdateState();
}
Also used : Entity(com.qcadoo.model.api.Entity) LookupComponent(com.qcadoo.view.api.components.LookupComponent) FieldComponent(com.qcadoo.view.api.components.FieldComponent)

Example 33 with FieldComponent

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

the class PerformanceAnalysisListeners method calculateTotalTime.

public void calculateTotalTime(final ViewDefinitionState view, final ComponentState state, final String[] args) {
    FieldComponent totalTimeBasedOnNorms = (FieldComponent) view.getComponentByReference(PerformanceAnalysisDtoFields.TOTAL_TIME_BASED_ON_NORMS);
    FieldComponent totalLaborTime = (FieldComponent) view.getComponentByReference(PerformanceAnalysisDtoFields.TOTAL_LABOR_TIME);
    FieldComponent totalDeviationTime = (FieldComponent) view.getComponentByReference(PerformanceAnalysisDtoFields.TOTAL_DEVIATION_TIME);
    FieldComponent totalPerformance = (FieldComponent) view.getComponentByReference(PerformanceAnalysisDtoFields.TOTAL_PERFORMANCE);
    GridComponent grid = (GridComponent) view.getComponentByReference(QcadooViewConstants.L_GRID);
    String query = buildQuery();
    Map<String, String> filter = grid.getFilters();
    GridComponentMultiSearchFilter multiSearchFilter = grid.getMultiSearchFilter();
    String filterQ;
    try {
        filterQ = GridComponentFilterSQLUtils.addFilters(filter, grid.getColumns(), TABLE_PRODUCTIONCOUNTING_PERFORMANCEANALYSISDTO, dataDefinitionService.get(ProductionCountingConstants.PLUGIN_IDENTIFIER, PerformanceAnalysisDtoFields.MODEL_PERFORMANCE_ANALYSIS_DTO));
        filterQ += " AND ";
        filterQ += GridComponentFilterSQLUtils.addMultiSearchFilter(multiSearchFilter, grid.getColumns(), TABLE_PRODUCTIONCOUNTING_PERFORMANCEANALYSISDTO, dataDefinitionService.get(ProductionCountingConstants.PLUGIN_IDENTIFIER, PerformanceAnalysisDtoFields.MODEL_PERFORMANCE_ANALYSIS_DTO));
    } catch (Exception e) {
        filterQ = "";
    }
    if (StringUtils.isNoneBlank(filterQ)) {
        query = query + " WHERE " + filterQ;
    }
    Map<String, Object> values = jdbcTemplate.queryForMap(query, Collections.emptyMap());
    totalTimeBasedOnNorms.setFieldValue(values.get("totaltimebasedonnorms"));
    totalLaborTime.setFieldValue(values.get("totallabortime"));
    totalDeviationTime.setFieldValue(values.get("totaltimedeviation"));
    totalPerformance.setFieldValue(numberService.format(values.get("totalperformance")));
    totalTimeBasedOnNorms.requestComponentUpdateState();
    totalLaborTime.requestComponentUpdateState();
    totalDeviationTime.requestComponentUpdateState();
    totalPerformance.requestComponentUpdateState();
}
Also used : GridComponentMultiSearchFilter(com.qcadoo.view.api.components.grid.GridComponentMultiSearchFilter) FieldComponent(com.qcadoo.view.api.components.FieldComponent) GridComponent(com.qcadoo.view.api.components.GridComponent)

Example 34 with FieldComponent

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

the class ProdOutResourceAttrValDetailsListeners method onChangeAttribute.

public void onChangeAttribute(final ViewDefinitionState view, final ComponentState state, final String[] args) {
    LookupComponent attributeValueLookup = (LookupComponent) view.getComponentByReference(ResourceAttributeValueFields.ATTRIBUTE_VALUE);
    FieldComponent valueField = (FieldComponent) view.getComponentByReference(ResourceAttributeValueFields.VALUE);
    attributeValueLookup.setFieldValue(null);
    attributeValueLookup.requestComponentUpdateState();
    valueField.setFieldValue(null);
    valueField.requestComponentUpdateState();
}
Also used : LookupComponent(com.qcadoo.view.api.components.LookupComponent) FieldComponent(com.qcadoo.view.api.components.FieldComponent)

Example 35 with FieldComponent

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

the class ProductionCountingParametersListeners method onReleaseOfMaterialsChange.

public void onReleaseOfMaterialsChange(final ViewDefinitionState view, final ComponentState state, final String[] args) {
    CheckBoxComponent consumptionOfRawMaterialsBasedOnStandards = (CheckBoxComponent) view.getComponentByReference(ParameterFieldsPC.CONSUMPTION_OF_RAW_MATERIALS_BASED_ON_STANDARDS);
    FieldComponent releaseOfMaterials = (FieldComponent) view.getComponentByReference(ParameterFieldsPC.RELEASE_OF_MATERIALS);
    if (ReleaseOfMaterials.MANUALLY_TO_ORDER_OR_GROUP.getStringValue().equals(releaseOfMaterials.getFieldValue().toString())) {
        consumptionOfRawMaterialsBasedOnStandards.setChecked(false);
        consumptionOfRawMaterialsBasedOnStandards.setEnabled(false);
    } else {
        consumptionOfRawMaterialsBasedOnStandards.setEnabled(true);
    }
}
Also used : FieldComponent(com.qcadoo.view.api.components.FieldComponent) CheckBoxComponent(com.qcadoo.view.api.components.CheckBoxComponent)

Aggregations

FieldComponent (com.qcadoo.view.api.components.FieldComponent)443 Entity (com.qcadoo.model.api.Entity)201 FormComponent (com.qcadoo.view.api.components.FormComponent)183 LookupComponent (com.qcadoo.view.api.components.LookupComponent)107 BigDecimal (java.math.BigDecimal)47 CheckBoxComponent (com.qcadoo.view.api.components.CheckBoxComponent)31 GridComponent (com.qcadoo.view.api.components.GridComponent)31 Date (java.util.Date)30 Optional (com.google.common.base.Optional)18 AwesomeDynamicListComponent (com.qcadoo.view.api.components.AwesomeDynamicListComponent)14 ComponentState (com.qcadoo.view.api.ComponentState)13 FilterValueHolder (com.qcadoo.view.api.components.lookup.FilterValueHolder)13 WindowComponent (com.qcadoo.view.api.components.WindowComponent)12 RibbonActionItem (com.qcadoo.view.api.ribbon.RibbonActionItem)11 RibbonGroup (com.qcadoo.view.api.ribbon.RibbonGroup)9 PossibleUnitConversions (com.qcadoo.model.api.units.PossibleUnitConversions)7 SimpleDateFormat (java.text.SimpleDateFormat)7 ViewDefinitionState (com.qcadoo.view.api.ViewDefinitionState)6 QcadooViewConstants (com.qcadoo.view.constants.QcadooViewConstants)6 Collectors (java.util.stream.Collectors)6