use of com.qcadoo.mes.technologies.dto.OperationProductComponentHolder in project mes by qcadoo.
the class ProductQuantitiesServiceImpl method groupOperationProductComponentWithQuantities.
@Override
public OperationProductComponentWithQuantityContainer groupOperationProductComponentWithQuantities(final Map<Long, OperationProductComponentWithQuantityContainer> operationProductComponentWithQuantityContainerForOrders) {
OperationProductComponentWithQuantityContainer operationProductComponentWithQuantityContainer = new OperationProductComponentWithQuantityContainer();
for (Entry<Long, OperationProductComponentWithQuantityContainer> operationProductComponentWithQuantityContainerForOrder : operationProductComponentWithQuantityContainerForOrders.entrySet()) {
operationProductComponentWithQuantityContainer.getMessages().addAll(operationProductComponentWithQuantityContainerForOrder.getValue().getMessages());
for (Entry<OperationProductComponentHolder, BigDecimal> productComponentWithQuantity : operationProductComponentWithQuantityContainerForOrder.getValue().asMap().entrySet()) {
OperationProductComponentHolder operationProductComponentHolder = productComponentWithQuantity.getKey();
BigDecimal quantity = productComponentWithQuantity.getValue();
if (operationProductComponentWithQuantityContainer.containsKey(operationProductComponentHolder)) {
BigDecimal addedQuantity = operationProductComponentWithQuantityContainer.get(operationProductComponentHolder);
quantity = quantity.add(addedQuantity, numberService.getMathContext());
}
operationProductComponentWithQuantityContainer.put(operationProductComponentHolder, quantity);
}
}
return operationProductComponentWithQuantityContainer;
}
use of com.qcadoo.mes.technologies.dto.OperationProductComponentHolder in project mes by qcadoo.
the class ProductQuantitiesServiceImpl method getNeededProductQuantitiesForComponents.
private Map<Long, BigDecimal> getNeededProductQuantitiesForComponents(final List<Entity> components, final MrpAlgorithm mrpAlgorithm, final boolean onTheFly) {
Map<Long, BigDecimal> operationRuns = Maps.newHashMap();
Set<OperationProductComponentHolder> nonComponents = Sets.newHashSet();
OperationProductComponentWithQuantityContainer productComponentWithQuantities = getProductComponentWithQuantitiesForOrders(getOrdersFromComponents(components), operationRuns, nonComponents, onTheFly);
return getProductWithQuantities(productComponentWithQuantities, nonComponents, mrpAlgorithm, TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT);
}
use of com.qcadoo.mes.technologies.dto.OperationProductComponentHolder in project mes by qcadoo.
the class MrpAlgorithmStrategyTS method perform.
public Map<Long, BigDecimal> perform(final OperationProductComponentWithQuantityContainer productComponentWithQuantities, final Set<OperationProductComponentHolder> nonComponents, final MrpAlgorithm mrpAlgorithm, final String operationProductComponentModelName) {
OperationProductComponentWithQuantityContainer allWithSameEntityType = productComponentWithQuantities.getAllWithSameEntityType(operationProductComponentModelName);
Map<Long, BigDecimal> productWithQuantities = Maps.newHashMap();
for (Entry<OperationProductComponentHolder, BigDecimal> productComponentWithQuantity : allWithSameEntityType.asMap().entrySet()) {
OperationProductComponentHolder operationProductComponentHolder = productComponentWithQuantity.getKey();
if (nonComponents.contains(operationProductComponentHolder)) {
Entity product = operationProductComponentHolder.getProduct();
Entity technologyOperationComponent = operationProductComponentHolder.getTechnologyOperationComponent();
if (technologyOperationComponent != null) {
List<Entity> children = technologyOperationComponent.getHasManyField(CHILDREN).find().add(SearchRestrictions.eq(TechnologyOperationComponentFieldsTS.IS_SUBCONTRACTING, true)).list().getEntities();
boolean isSubcontracting = false;
for (Entity child : children) {
Entity operationProductOutComponent = child.getHasManyField(OPERATION_PRODUCT_OUT_COMPONENTS).find().add(SearchRestrictions.belongsTo(PRODUCT, product)).setMaxResults(1).uniqueResult();
if (operationProductOutComponent != null) {
isSubcontracting = true;
}
}
if (!isSubcontracting) {
continue;
}
}
}
productQuantitiesService.addProductQuantitiesToList(productComponentWithQuantity, productWithQuantities);
}
return productWithQuantities;
}
use of com.qcadoo.mes.technologies.dto.OperationProductComponentHolder in project mes by qcadoo.
the class ProductQuantitiesServiceImplTSOverrideUtil method getProductComponentWithQuantitiesWithoutNonComponents.
public OperationProductComponentWithQuantityContainer getProductComponentWithQuantitiesWithoutNonComponents(final OperationProductComponentWithQuantityContainer productComponentWithQuantities, final Set<OperationProductComponentHolder> nonComponents) {
for (OperationProductComponentHolder nonComponent : nonComponents) {
Entity product = nonComponent.getProduct();
Entity technologyOperationComponent = nonComponent.getTechnologyOperationComponent();
if (technologyOperationComponent != null) {
List<Entity> children = technologyOperationComponent.getHasManyField(TechnologyOperationComponentFields.CHILDREN).find().add(SearchRestrictions.eq(TechnologyOperationComponentFieldsTS.IS_SUBCONTRACTING, true)).list().getEntities();
boolean isSubcontracting = false;
for (Entity child : children) {
Entity operationProductOutComponent = child.getHasManyField(TechnologyOperationComponentFields.OPERATION_PRODUCT_OUT_COMPONENTS).find().add(SearchRestrictions.belongsTo(OperationProductOutComponentFields.PRODUCT, product)).setMaxResults(1).uniqueResult();
if (operationProductOutComponent != null) {
isSubcontracting = true;
}
}
if (!isSubcontracting) {
productComponentWithQuantities.remove(nonComponent);
}
}
}
return productComponentWithQuantities;
}
use of com.qcadoo.mes.technologies.dto.OperationProductComponentHolder in project mes by qcadoo.
the class ProductQuantitiesWithComponentsServiceImpl method getProductComponentQuantities.
@Override
public ProductQuantitiesHolder getProductComponentQuantities(final Entity technology, final BigDecimal givenQuantity) {
Map<Long, BigDecimal> operationRuns = Maps.newHashMap();
Set<OperationProductComponentHolder> nonComponents = Sets.newHashSet();
OperationProductComponentWithQuantityContainer productQuantities = getProductComponentWithQuantitiesForTechnology(technology, givenQuantity, operationRuns, nonComponents);
return new ProductQuantitiesHolder(productQuantities, operationRuns);
}
Aggregations