use of com.qcadoo.mes.technologies.dto.OperationProductComponentWithQuantityContainer in project mes by qcadoo.
the class ProductQuantitiesServiceImplBPCOverrideUtil method getProductComponentWithQuantities.
private OperationProductComponentWithQuantityContainer getProductComponentWithQuantities(final Entity order) {
OperationProductComponentWithQuantityContainer productComponentWithQuantities = new OperationProductComponentWithQuantityContainer();
List<Entity> productionCountingQuantities = dataDefinitionService.get(BasicProductionCountingConstants.PLUGIN_IDENTIFIER, BasicProductionCountingConstants.MODEL_PRODUCTION_COUNTING_QUANTITY).find().add(SearchRestrictions.belongsTo(ProductionCountingQuantityFields.ORDER, order)).list().getEntities();
for (Entity productionCountingQuantity : productionCountingQuantities) {
Entity technologyOperationComponent = productionCountingQuantity.getBelongsToField(ProductionCountingQuantityFields.TECHNOLOGY_OPERATION_COMPONENT);
Entity product = productionCountingQuantity.getBelongsToField(ProductionCountingQuantityFields.PRODUCT);
String role = productionCountingQuantity.getStringField(ProductionCountingQuantityFields.ROLE);
BigDecimal plannedQuantity = productionCountingQuantity.getDecimalField(ProductionCountingQuantityFields.PLANNED_QUANTITY);
OperationProductComponentEntityType entityType = getEntityType(role);
ProductMaterialType productMaterialType = ProductMaterialType.parseString(productionCountingQuantity.getStringField(ProductionCountingQuantityFields.TYPE_OF_MATERIAL));
Entity productInputType = productionCountingQuantity.getBelongsToField(ProductionCountingQuantityFields.TECHNOLOGY_INPUT_PRODUCT_TYPE);
Entity attribute = productionCountingQuantity.getBelongsToField(ProductionCountingQuantityFields.ATTRIBUTE);
OperationProductComponentHolder operationProductComponentHolder = new OperationProductComponentHolder(product, technologyOperationComponent, productInputType, attribute, productionCountingQuantity, entityType, productMaterialType);
productComponentWithQuantities.put(operationProductComponentHolder, plannedQuantity);
}
return productComponentWithQuantities;
}
use of com.qcadoo.mes.technologies.dto.OperationProductComponentWithQuantityContainer in project mes by qcadoo.
the class ProductQuantitiesServiceImplBPCOverrideUtil method getProductComponentWithQuantitiesForOrders.
public OperationProductComponentWithQuantityContainer getProductComponentWithQuantitiesForOrders(final List<Entity> orders, final Map<Long, BigDecimal> operationRuns, final Set<OperationProductComponentHolder> nonComponents, final boolean onTheFly) {
Map<Long, OperationProductComponentWithQuantityContainer> productComponentWithQuantitiesForOrders = Maps.newHashMap();
for (Entity order : orders) {
BigDecimal plannedQuantity = order.getDecimalField(OrderFields.PLANNED_QUANTITY);
Entity technology = order.getBelongsToField(OrderFields.TECHNOLOGY);
Entity product = order.getBelongsToField(OrderFields.PRODUCT);
if (technology == null) {
throw new IllegalStateException("Order doesn't contain technology.");
}
String state = order.getStringField(OrderFields.STATE);
if (!onTheFly && (OrderStateStringValues.ACCEPTED.equals(state) || OrderStateStringValues.IN_PROGRESS.equals(state) || OrderStateStringValues.INTERRUPTED.equals(state))) {
productComponentWithQuantitiesForOrders.put(order.getId(), getProductComponentWithQuantities(order));
fillOperationRuns(operationRuns, order);
fillNonComponents(nonComponents, order);
} else {
productComponentWithQuantitiesForOrders.put(order.getId(), productQuantitiesServiceImpl.getProductComponentWithQuantitiesForTechnology(technology, product, plannedQuantity, operationRuns, nonComponents));
}
}
return productQuantitiesServiceImpl.groupOperationProductComponentWithQuantities(productComponentWithQuantitiesForOrders);
}
use of com.qcadoo.mes.technologies.dto.OperationProductComponentWithQuantityContainer in project mes by qcadoo.
the class ProductQuantitiesServiceImpl method getProductComponentQuantitiesWithoutNonComponents.
@Override
public OperationProductComponentWithQuantityContainer getProductComponentQuantitiesWithoutNonComponents(final List<Entity> orders, final boolean onTheFly) {
Map<Long, BigDecimal> operationRuns = Maps.newHashMap();
Set<OperationProductComponentHolder> nonComponents = Sets.newHashSet();
OperationProductComponentWithQuantityContainer productComponentWithQuantities = getProductComponentWithQuantitiesForOrders(orders, operationRuns, nonComponents, onTheFly);
return getProductComponentWithQuantitiesWithoutNonComponents(productComponentWithQuantities, nonComponents);
}
use of com.qcadoo.mes.technologies.dto.OperationProductComponentWithQuantityContainer in project mes by qcadoo.
the class ProductQuantitiesServiceImpl method getNeededProductQuantitiesByOPC.
@Override
public Map<OperationProductComponentHolder, BigDecimal> getNeededProductQuantitiesByOPC(final Entity technology, final Entity orderedProduct, final BigDecimal givenQuantity, final MrpAlgorithm mrpAlgorithm) {
Map<Long, BigDecimal> operationRuns = Maps.newHashMap();
Set<OperationProductComponentHolder> nonComponents = Sets.newHashSet();
OperationProductComponentWithQuantityContainer productComponentWithQuantities = getProductComponentWithQuantitiesForTechnology(technology, orderedProduct, givenQuantity, operationRuns, nonComponents);
OperationProductComponentWithQuantityContainer allWithSameEntityType = productComponentWithQuantities.getAllWithSameEntityType(TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT);
if (mrpAlgorithm.equals(MrpAlgorithm.ALL_PRODUCTS_IN)) {
return getOperationProductComponentWithQuantities(allWithSameEntityType, nonComponents, false, false);
} else if (mrpAlgorithm.equals(MrpAlgorithm.ONLY_COMPONENTS)) {
return getOperationProductComponentWithQuantities(allWithSameEntityType, nonComponents, true, false);
} else if (mrpAlgorithm.equals(MrpAlgorithm.COMPONENTS_AND_SUBCONTRACTORS_PRODUCTS)) {
return getOperationProductComponentWithQuantities(allWithSameEntityType, nonComponents, false, false);
} else {
return getOperationProductComponentWithQuantities(allWithSameEntityType, nonComponents, true, true);
}
}
use of com.qcadoo.mes.technologies.dto.OperationProductComponentWithQuantityContainer in project mes by qcadoo.
the class ProductQuantitiesServiceImpl method getNeededProductQuantities.
@Override
public Map<Long, BigDecimal> getNeededProductQuantities(final Entity technology, final BigDecimal givenQuantity, final MrpAlgorithm mrpAlgorithm) {
Map<Long, BigDecimal> operationRuns = Maps.newHashMap();
Set<OperationProductComponentHolder> nonComponents = Sets.newHashSet();
OperationProductComponentWithQuantityContainer productComponentWithQuantities = getProductComponentWithQuantitiesForTechnology(technology, null, givenQuantity, operationRuns, nonComponents);
return getProductWithQuantities(productComponentWithQuantities, nonComponents, mrpAlgorithm, TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT);
}
Aggregations