Search in sources :

Example 21 with OperationProductComponentWithQuantityContainer

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

Example 22 with OperationProductComponentWithQuantityContainer

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

Example 23 with OperationProductComponentWithQuantityContainer

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

Example 24 with OperationProductComponentWithQuantityContainer

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

Example 25 with OperationProductComponentWithQuantityContainer

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

Aggregations

OperationProductComponentWithQuantityContainer (com.qcadoo.mes.technologies.dto.OperationProductComponentWithQuantityContainer)31 BigDecimal (java.math.BigDecimal)26 Entity (com.qcadoo.model.api.Entity)18 OperationProductComponentHolder (com.qcadoo.mes.technologies.dto.OperationProductComponentHolder)16 EntityTree (com.qcadoo.model.api.EntityTree)5 ProductQuantitiesHolder (com.qcadoo.mes.technologies.dto.ProductQuantitiesHolder)4 Lists (com.google.common.collect.Lists)3 Maps (com.google.common.collect.Maps)3 Sets (com.google.common.collect.Sets)3 DataDefinition (com.qcadoo.model.api.DataDefinition)3 Map (java.util.Map)3 Entry (java.util.Map.Entry)3 Test (org.junit.Test)3 Autowired (org.springframework.beans.factory.annotation.Autowired)3 Service (org.springframework.stereotype.Service)3 Transactional (org.springframework.transaction.annotation.Transactional)3 com.qcadoo.mes.basic.constants (com.qcadoo.mes.basic.constants)2 com.qcadoo.mes.technologies.constants (com.qcadoo.mes.technologies.constants)2 OperationProductComponentEntityType (com.qcadoo.mes.technologies.dto.OperationProductComponentEntityType)2 OperationProductComponentMessage (com.qcadoo.mes.technologies.dto.OperationProductComponentMessage)2