Search in sources :

Example 26 with OperationProductComponentHolder

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);
}
Also used : OperationProductComponentHolder(com.qcadoo.mes.technologies.dto.OperationProductComponentHolder) OperationProductComponentWithQuantityContainer(com.qcadoo.mes.technologies.dto.OperationProductComponentWithQuantityContainer) BigDecimal(java.math.BigDecimal)

Example 27 with OperationProductComponentHolder

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);
}
Also used : OperationProductComponentHolder(com.qcadoo.mes.technologies.dto.OperationProductComponentHolder) BigDecimal(java.math.BigDecimal)

Example 28 with OperationProductComponentHolder

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;
}
Also used : OperationProductComponentHolder(com.qcadoo.mes.technologies.dto.OperationProductComponentHolder) Entity(com.qcadoo.model.api.Entity) BigDecimal(java.math.BigDecimal)

Example 29 with OperationProductComponentHolder

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);
    }
}
Also used : OperationProductComponentHolder(com.qcadoo.mes.technologies.dto.OperationProductComponentHolder) OperationProductComponentWithQuantityContainer(com.qcadoo.mes.technologies.dto.OperationProductComponentWithQuantityContainer) BigDecimal(java.math.BigDecimal)

Example 30 with OperationProductComponentHolder

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);
    }
}
Also used : OperationProductComponentHolder(com.qcadoo.mes.technologies.dto.OperationProductComponentHolder) Entity(com.qcadoo.model.api.Entity) BigDecimal(java.math.BigDecimal)

Aggregations

OperationProductComponentHolder (com.qcadoo.mes.technologies.dto.OperationProductComponentHolder)35 BigDecimal (java.math.BigDecimal)31 Entity (com.qcadoo.model.api.Entity)23 OperationProductComponentWithQuantityContainer (com.qcadoo.mes.technologies.dto.OperationProductComponentWithQuantityContainer)14 Map (java.util.Map)11 DataDefinition (com.qcadoo.model.api.DataDefinition)4 List (java.util.List)4 Lists (com.google.common.collect.Lists)3 ProductQuantitiesService (com.qcadoo.mes.technologies.ProductQuantitiesService)3 HashMap (java.util.HashMap)3 LinkedHashMap (java.util.LinkedHashMap)3 Autowired (org.springframework.beans.factory.annotation.Autowired)3 Service (org.springframework.stereotype.Service)3 Lists.newArrayList (com.google.common.collect.Lists.newArrayList)2 Maps (com.google.common.collect.Maps)2 Sets (com.google.common.collect.Sets)2 ProductFields (com.qcadoo.mes.basic.constants.ProductFields)2 OperationProductInComponentFields (com.qcadoo.mes.technologies.constants.OperationProductInComponentFields)2 ProductBySizeGroupFields (com.qcadoo.mes.technologies.constants.ProductBySizeGroupFields)2 TechnologiesConstants (com.qcadoo.mes.technologies.constants.TechnologiesConstants)2