Search in sources :

Example 6 with OperationProductComponentHolder

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

Example 7 with OperationProductComponentHolder

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

Example 8 with OperationProductComponentHolder

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

Example 9 with OperationProductComponentHolder

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

Example 10 with OperationProductComponentHolder

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