use of com.qcadoo.view.api.components.CheckBoxComponent in project mes by qcadoo.
the class SupplyParametersHooksOS method updateOrdersIncludePeriodState.
public void updateOrdersIncludePeriodState(final ViewDefinitionState view) {
CheckBoxComponent includeRequirements = (CheckBoxComponent) view.getComponentByReference("includeRequirements");
FieldComponent ordersIncludePeriod = (FieldComponent) view.getComponentByReference("ordersIncludePeriod");
boolean shouldIncludeRequirements = includeRequirements.isChecked();
ordersIncludePeriod.setEnabled(shouldIncludeRequirements);
if (!shouldIncludeRequirements) {
ordersIncludePeriod.setFieldValue(null);
}
ordersIncludePeriod.requestComponentUpdateState();
CheckBoxComponent considerMinimumStockLevelWhenCreatingProductionOrders = (CheckBoxComponent) view.getComponentByReference(L_CONSIDER_MINIMUM_STOCK_LEVEL_WHEN_CREATING_PRODUCTION_ORDERS);
if (parameterService.getParameter().getBooleanField(L_REALIZATION_FROM_STOCK)) {
considerMinimumStockLevelWhenCreatingProductionOrders.setEnabled(true);
} else {
considerMinimumStockLevelWhenCreatingProductionOrders.setEnabled(false);
}
}
use of com.qcadoo.view.api.components.CheckBoxComponent in project mes by qcadoo.
the class OrderServiceImpl method changeFieldState.
// FIXME - this method doesn't have anything in common with production orders..
@Override
public void changeFieldState(final ViewDefinitionState view, final String booleanFieldComponentName, final String fieldComponentName) {
CheckBoxComponent booleanCheckBox = (CheckBoxComponent) view.getComponentByReference(booleanFieldComponentName);
FieldComponent fieldComponent = (FieldComponent) view.getComponentByReference(fieldComponentName);
if (booleanCheckBox.isChecked()) {
fieldComponent.setEnabled(true);
fieldComponent.requestComponentUpdateState();
} else {
fieldComponent.setEnabled(false);
fieldComponent.requestComponentUpdateState();
}
}
use of com.qcadoo.view.api.components.CheckBoxComponent in project mes by qcadoo.
the class OperationDurationDetailsInOrderListenersOFSPGOverrideAspect method aroundGenerateRealizationTime.
@Around("generateRealizationTimeE(viewDefinitionState, state, args)")
public void aroundGenerateRealizationTime(final ProceedingJoinPoint pjp, final ViewDefinitionState viewDefinitionState, final ComponentState state, final String[] args) throws Throwable {
CheckBoxComponent component = (CheckBoxComponent) viewDefinitionState.getComponentByReference("includeOrdersForComponent");
if (!component.isChecked()) {
pjp.proceed();
return;
}
FormComponent orderForm = (FormComponent) viewDefinitionState.getComponentByReference(QcadooViewConstants.L_FORM);
FieldComponent startTimeField = (FieldComponent) viewDefinitionState.getComponentByReference(L_START_TIME);
if (!StringUtils.hasText((String) startTimeField.getFieldValue())) {
startTimeField.addMessage(L_PRODUCTION_SCHEDULING_ERROR_FIELD_REQUIRED, ComponentState.MessageType.FAILURE);
return;
}
FieldComponent plannedQuantityField = (FieldComponent) viewDefinitionState.getComponentByReference(OrderFields.PLANNED_QUANTITY);
FieldComponent productionLineLookup = (FieldComponent) viewDefinitionState.getComponentByReference(OrderFields.PRODUCTION_LINE);
FieldComponent generatedEndDateField = (FieldComponent) viewDefinitionState.getComponentByReference(OrderFieldsPS.GENERATED_END_DATE);
FieldComponent calculatedFinishAllOrdersField = (FieldComponent) viewDefinitionState.getComponentByReference("calculatedFinishAllOrders");
FieldComponent calculatedStartAllOrdersField = (FieldComponent) viewDefinitionState.getComponentByReference("calculatedStartAllOrders");
FieldComponent includeTpzField = (FieldComponent) viewDefinitionState.getComponentByReference(OrderFieldsPS.INCLUDE_TPZ);
FieldComponent includeAdditionalTimeField = (FieldComponent) viewDefinitionState.getComponentByReference(OrderFieldsPS.INCLUDE_ADDITIONAL_TIME);
boolean isGenerated = false;
Entity productionLine = dataDefinitionService.get(ProductionLinesConstants.PLUGIN_IDENTIFIER, ProductionLinesConstants.MODEL_PRODUCTION_LINE).get((Long) productionLineLookup.getFieldValue());
Entity order = dataDefinitionService.get(OrdersConstants.PLUGIN_IDENTIFIER, OrdersConstants.MODEL_ORDER).get(orderForm.getEntity().getId());
// copy of technology from order
Entity technology = order.getBelongsToField(OrderFields.TECHNOLOGY);
Validate.notNull(technology, "technology is null");
BigDecimal quantity = orderRealizationTimeService.getBigDecimalFromField(plannedQuantityField.getFieldValue(), viewDefinitionState.getLocale());
// Included in work time
boolean includeTpz = "1".equals(includeTpzField.getFieldValue());
boolean includeAdditionalTime = "1".equals(includeAdditionalTimeField.getFieldValue());
final Map<Long, BigDecimal> operationRuns = Maps.newHashMap();
productQuantitiesService.getProductComponentQuantities(technology, quantity, operationRuns);
operationWorkTimeService.deleteOperCompTimeCalculations(order);
OperationWorkTime workTime = operationWorkTimeService.estimateTotalWorkTimeForOrder(order, operationRuns, includeTpz, includeAdditionalTime, true);
List<Entity> orders = getOrderAndSubOrders(order.getId());
Map<Integer, OrdersByLevel> ordersByLevel = productionSchedulingForComponentsService.mapToOrdersByLevel(orders);
List<Integer> keys = Lists.newArrayList(ordersByLevel.keySet());
keys.sort(Collections.reverseOrder());
Date orderStartDate = order.getDateField(OrderFields.START_DATE);
Date lastDateTo = orderStartDate;
for (Integer key : keys) {
OrdersByLevel ords = ordersByLevel.get(key);
Date currentDateTo = lastDateTo;
for (Entity o : ords.getOrders()) {
Entity t = o.getBelongsToField(OrderFields.TECHNOLOGY);
final Map<Long, BigDecimal> oR = Maps.newHashMap();
productQuantitiesService.getProductComponentQuantities(t, quantity, oR);
operationWorkTimeService.estimateTotalWorkTimeForOrder(o, oR, includeTpz, includeAdditionalTime, true);
int maxPathTime = orderRealizationTimeService.estimateMaxOperationTimeConsumptionForWorkstation(o, t.getTreeField(TechnologyFields.OPERATION_COMPONENTS).getRoot(), quantity, includeTpz, includeAdditionalTime, productionLine);
if (maxPathTime > OrderRealizationTimeService.MAX_REALIZATION_TIME) {
state.addMessage("orders.validate.global.error.RealizationTimeIsToLong", ComponentState.MessageType.FAILURE);
if (o.getId().equals(order.getId())) {
generatedEndDateField.setFieldValue(null);
}
} else {
o.setField(OrderFieldsPS.REALIZATION_TIME, maxPathTime);
Date startTime = o.getDateField(OrderFields.DATE_FROM);
if (Objects.isNull(startTime)) {
startTime = orderStartDate;
}
if (startTime == null) {
startTimeField.addMessage("orders.validate.global.error.dateFromIsNull", ComponentState.MessageType.FAILURE);
} else {
if (maxPathTime == 0) {
orderForm.addMessage("productionScheduling.timenorms.isZero", ComponentState.MessageType.FAILURE, false);
if (o.getId().equals(order.getId())) {
generatedEndDateField.setFieldValue(null);
}
} else {
lastDateTo = scheduleOperationsInOrder(o, currentDateTo);
isGenerated = true;
}
orderForm.addMessage("orders.dateFrom.info.dateFromSetToFirstPossible", ComponentState.MessageType.INFO, false);
}
o.getDataDefinition().save(o);
}
}
}
fillWorkTimeFields(viewDefinitionState, workTime);
generatedEndDateField.requestComponentUpdateState();
if (isGenerated) {
order = getActualOrderWithChanges(order);
Entity orderTimeCalculation = dataDefinitionService.get(TimeNormsConstants.PLUGIN_PRODUCTION_SCHEDULING_IDENTIFIER, TimeNormsConstants.MODEL_ORDER_TIME_CALCULATION).find().add(SearchRestrictions.belongsTo("order", order)).setMaxResults(1).uniqueResult();
Date startTimeOrders = findCalculatedStartAllOrders(order);
order.setField("calculatedStartAllOrders", orderRealizationTimeService.setDateToField(startTimeOrders));
calculatedStartAllOrdersField.setFieldValue(orderRealizationTimeService.setDateToField(startTimeOrders));
Date finishDate = orderTimeCalculation.getDateField(OrderTimeCalculationFields.EFFECTIVE_DATE_TO);
generatedEndDateField.setFieldValue(orderRealizationTimeService.setDateToField(finishDate));
calculatedFinishAllOrdersField.setFieldValue(orderRealizationTimeService.setDateToField(finishDate));
order.setField("calculatedFinishAllOrders", orderRealizationTimeService.setDateToField(finishDate));
order = order.getDataDefinition().save(order);
orderForm.setEntity(order);
orderForm.addMessage("productionScheduling.info.calculationGenerated", ComponentState.MessageType.SUCCESS);
state.performEvent(viewDefinitionState, "reset");
}
}
use of com.qcadoo.view.api.components.CheckBoxComponent in project mes by qcadoo.
the class CostCalculationDetailsHooksOFSPG method onBeforeRender.
public void onBeforeRender(final ViewDefinitionState view) {
FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
if (form.getEntityId() == null) {
CheckBoxComponent fieldComponent = (CheckBoxComponent) view.getComponentByReference("includeComponents");
boolean check = parameterService.getParameter().getBooleanField("includeComponents");
fieldComponent.setChecked(check);
fieldComponent.requestComponentUpdateState();
}
enableSaveNominalCostForComponentButton(view);
}
use of com.qcadoo.view.api.components.CheckBoxComponent in project mes by qcadoo.
the class ParametersHooksOFSPG method onChangeAutomaticallyGenerate.
public void onChangeAutomaticallyGenerate(final ViewDefinitionState view, final ComponentState componentState, final String[] args) {
CheckBoxComponent automaticallyGenerateOrdersForComponents = (CheckBoxComponent) view.getComponentByReference("automaticallyGenerateOrdersForComponents");
CheckBoxComponent ordersGeneratedByCoverage = (CheckBoxComponent) view.getComponentByReference("ordersGeneratedByCoverage");
if (!automaticallyGenerateOrdersForComponents.isChecked()) {
ordersGeneratedByCoverage.setChecked(false);
}
}
Aggregations