use of com.qcadoo.mes.technologies.dto.OperationProductComponentHolder 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.OperationProductComponentHolder in project mes by qcadoo.
the class ProductQuantitiesServiceImpl method addOPCQuantitiesToList.
public void addOPCQuantitiesToList(final Map.Entry<OperationProductComponentHolder, BigDecimal> productComponentWithQuantity, final Map<OperationProductComponentHolder, BigDecimal> productWithQuantities) {
OperationProductComponentHolder operationProductComponentHolder = productComponentWithQuantity.getKey();
BigDecimal quantity = productComponentWithQuantity.getValue();
productWithQuantities.put(operationProductComponentHolder, quantity);
}
use of com.qcadoo.mes.technologies.dto.OperationProductComponentHolder in project mes by qcadoo.
the class ProductQuantitiesServiceImpl method getProductWithoutSubcontractingProduct.
private Map<Long, BigDecimal> getProductWithoutSubcontractingProduct(final OperationProductComponentWithQuantityContainer productComponentWithQuantities, final Set<OperationProductComponentHolder> nonComponents, final boolean onlyComponents, final boolean onlyMaterials) {
Map<Long, BigDecimal> productWithQuantities = Maps.newHashMap();
for (Entry<OperationProductComponentHolder, BigDecimal> productComponentWithQuantity : productComponentWithQuantities.asMap().entrySet()) {
OperationProductComponentHolder operationProductComponentHolder = productComponentWithQuantity.getKey();
if (onlyComponents && nonComponents.contains(operationProductComponentHolder)) {
continue;
}
if (onlyMaterials) {
Entity product = operationProductComponentHolder.getProduct();
if (hasAcceptedMasterTechnology(product)) {
continue;
}
}
addProductQuantitiesToList(productComponentWithQuantity, productWithQuantities);
}
return productWithQuantities;
}
use of com.qcadoo.mes.technologies.dto.OperationProductComponentHolder 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.OperationProductComponentHolder in project mes by qcadoo.
the class ProductQuantitiesServiceImpl method traverseProductQuantitiesAndOperationRuns.
@Override
public void traverseProductQuantitiesAndOperationRuns(final Entity technology, final BigDecimal givenQuantity, final Entity operationComponent, final Entity previousOperationComponent, final OperationProductComponentWithQuantityContainer operationProductComponentWithQuantityContainer, final Set<OperationProductComponentHolder> nonComponents, final Map<Long, BigDecimal> operationRuns) {
if (Objects.isNull(previousOperationComponent)) {
Entity technologyProduct = technology.getBelongsToField(TechnologyFields.PRODUCT);
for (Entity operationProductOutComponent : operationComponent.getHasManyField(TechnologyOperationComponentFields.OPERATION_PRODUCT_OUT_COMPONENTS)) {
if (operationProductOutComponent.getBelongsToField(OperationProductOutComponentFields.PRODUCT).getId().equals(technologyProduct.getId())) {
BigDecimal outQuantity = operationProductComponentWithQuantityContainer.get(operationProductOutComponent);
multiplyProductQuantitiesAndAddOperationRuns(operationComponent, givenQuantity, outQuantity, operationProductComponentWithQuantityContainer, operationRuns);
break;
}
}
} else {
for (Entity operationProductInComponent : previousOperationComponent.getHasManyField(TechnologyOperationComponentFields.OPERATION_PRODUCT_IN_COMPONENTS)) {
boolean isntComponent = false;
for (Entity operationProductOutComponent : operationComponent.getHasManyField(TechnologyOperationComponentFields.OPERATION_PRODUCT_OUT_COMPONENTS)) {
if (!operationProductInComponent.getBooleanField(OperationProductInComponentFields.DIFFERENT_PRODUCTS_IN_DIFFERENT_SIZES) && !Objects.isNull(getOperationProductProduct(operationProductInComponent)) && operationProductOutComponent.getBelongsToField(OperationProductOutComponentFields.PRODUCT).getId().equals(operationProductInComponent.getBelongsToField(OperationProductInComponentFields.PRODUCT).getId())) {
isntComponent = true;
BigDecimal outQuantity = operationProductComponentWithQuantityContainer.get(operationProductOutComponent);
BigDecimal inQuantity = operationProductComponentWithQuantityContainer.get(operationProductInComponent);
multiplyProductQuantitiesAndAddOperationRuns(operationComponent, inQuantity, outQuantity, operationProductComponentWithQuantityContainer, operationRuns);
break;
}
}
if (isntComponent) {
nonComponents.add(new OperationProductComponentHolder(operationProductInComponent));
}
}
}
for (Entity child : operationComponent.getHasManyField(TechnologyOperationComponentFields.CHILDREN)) {
traverseProductQuantitiesAndOperationRuns(technology, givenQuantity, child, operationComponent, operationProductComponentWithQuantityContainer, nonComponents, operationRuns);
}
}
Aggregations