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);
}
}
}
}
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();
}
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();
}
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();
}
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);
}
}
Aggregations