Search in sources :

Example 1 with OperationProductComponentEntityType

use of com.qcadoo.mes.technologies.dto.OperationProductComponentEntityType in project mes by qcadoo.

the class OperationProductsExtractor method getOperationProductComponents.

private List<Entity> getOperationProductComponents(final Entity order, final Entity technologyOperationComponent) {
    List<Entity> trackingOperationProductComponents = Lists.newArrayList();
    Map<OperationProductComponentEntityType, Set<Entity>> entityTypeWithAlreadyAddedProducts = Maps.newHashMap();
    String typeOfProductionRecording = order.getStringField(OrderFieldsPC.TYPE_OF_PRODUCTION_RECORDING);
    OperationProductComponentWithQuantityContainer productComponentQuantities = productQuantitiesService.getProductComponentQuantities(order);
    for (Entry<OperationProductComponentHolder, BigDecimal> productComponentQuantity : productComponentQuantities.asMap().entrySet()) {
        OperationProductComponentHolder operationProductComponentHolder = productComponentQuantity.getKey();
        if (forEach(typeOfProductionRecording)) {
            Entity operationComponent = operationProductComponentHolder.getTechnologyOperationComponent();
            if (technologyOperationComponent == null) {
                if (operationComponent != null) {
                    continue;
                }
            } else {
                if ((operationComponent == null) || !technologyOperationComponent.getId().equals(operationComponent.getId())) {
                    continue;
                }
            }
        } else if (cumulated(typeOfProductionRecording)) {
            OperationProductComponentEntityType entityType = operationProductComponentHolder.getEntityType();
            Entity product = operationProductComponentHolder.getProduct();
            if ((product != null) && (entityType != null)) {
                if (shouldSkipAddingProduct(operationProductComponentHolder, entityTypeWithAlreadyAddedProducts, typeOfProductionRecording)) {
                    if (entityTypeWithAlreadyAddedProducts.containsKey(entityType)) {
                        continue;
                    } else {
                        entityTypeWithAlreadyAddedProducts.put(entityType, Sets.newHashSet());
                        continue;
                    }
                } else {
                    if (entityTypeWithAlreadyAddedProducts.containsKey(entityType)) {
                        Set<Entity> alreadAddedProducts = entityTypeWithAlreadyAddedProducts.get(entityType);
                        alreadAddedProducts.add(product);
                        entityTypeWithAlreadyAddedProducts.put(entityType, alreadAddedProducts);
                    } else {
                        entityTypeWithAlreadyAddedProducts.put(entityType, Sets.newHashSet(product));
                    }
                }
            }
        }
        Entity trackingOperationProductComponent = trackingOperationComponentBuilder.fromOperationProductComponentHolder(operationProductComponentHolder);
        if (forEach(typeOfProductionRecording)) {
            Optional<Entity> mabyExist = trackingOperationProductComponents.stream().filter(toc -> toc.getBelongsToField(L_PRODUCT).getId().equals(trackingOperationProductComponent.getBelongsToField(L_PRODUCT).getId())).findAny();
            if (!mabyExist.isPresent()) {
                trackingOperationProductComponents.add(trackingOperationProductComponent);
            }
        } else {
            trackingOperationProductComponents.add(trackingOperationProductComponent);
        }
    }
    return trackingOperationProductComponents;
}
Also used : OperationProductComponentHolder(com.qcadoo.mes.technologies.dto.OperationProductComponentHolder) Function(com.google.common.base.Function) OperationProductComponentEntityType(com.qcadoo.mes.technologies.dto.OperationProductComponentEntityType) ProductionTrackingFields(com.qcadoo.mes.productionCounting.constants.ProductionTrackingFields) Set(java.util.Set) Autowired(org.springframework.beans.factory.annotation.Autowired) OrderFieldsPC(com.qcadoo.mes.productionCounting.constants.OrderFieldsPC) Multimap(com.google.common.collect.Multimap) TechnologyService(com.qcadoo.mes.technologies.TechnologyService) Maps(com.google.common.collect.Maps) OperationProductComponentHolder(com.qcadoo.mes.technologies.dto.OperationProductComponentHolder) Sets(com.google.common.collect.Sets) Multimaps(com.google.common.collect.Multimaps) OperationProductComponentWithQuantityContainer(com.qcadoo.mes.technologies.dto.OperationProductComponentWithQuantityContainer) BigDecimal(java.math.BigDecimal) Entity(com.qcadoo.model.api.Entity) List(java.util.List) Lists(com.google.common.collect.Lists) Service(org.springframework.stereotype.Service) Map(java.util.Map) Entry(java.util.Map.Entry) ProductionCountingConstants(com.qcadoo.mes.productionCounting.constants.ProductionCountingConstants) ProductQuantitiesService(com.qcadoo.mes.technologies.ProductQuantitiesService) Optional(java.util.Optional) TypeOfProductionRecording(com.qcadoo.mes.productionCounting.constants.TypeOfProductionRecording) Entity(com.qcadoo.model.api.Entity) Set(java.util.Set) OperationProductComponentWithQuantityContainer(com.qcadoo.mes.technologies.dto.OperationProductComponentWithQuantityContainer) OperationProductComponentEntityType(com.qcadoo.mes.technologies.dto.OperationProductComponentEntityType) BigDecimal(java.math.BigDecimal)

Example 2 with OperationProductComponentEntityType

use of com.qcadoo.mes.technologies.dto.OperationProductComponentEntityType in project mes by qcadoo.

the class ProductQuantitiesServiceImplBPCOverrideUtil method fillNonComponents.

private void fillNonComponents(final Set<OperationProductComponentHolder> nonComponents, final Entity order) {
    List<Entity> productionCountingQuantities = dataDefinitionService.get(BasicProductionCountingConstants.PLUGIN_IDENTIFIER, BasicProductionCountingConstants.MODEL_PRODUCTION_COUNTING_QUANTITY).find().add(SearchRestrictions.belongsTo(ProductionCountingQuantityFields.ORDER, order)).add(SearchRestrictions.eq(ProductionCountingQuantityFields.IS_NON_COMPONENT, true)).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);
        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);
        nonComponents.add(operationProductComponentHolder);
    }
}
Also used : OperationProductComponentHolder(com.qcadoo.mes.technologies.dto.OperationProductComponentHolder) Entity(com.qcadoo.model.api.Entity) ProductMaterialType(com.qcadoo.mes.technologies.dto.ProductMaterialType) OperationProductComponentEntityType(com.qcadoo.mes.technologies.dto.OperationProductComponentEntityType)

Example 3 with OperationProductComponentEntityType

use of com.qcadoo.mes.technologies.dto.OperationProductComponentEntityType 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 4 with OperationProductComponentEntityType

use of com.qcadoo.mes.technologies.dto.OperationProductComponentEntityType in project mes by qcadoo.

the class OperationProductsExtractor method shouldSkipAddingProduct.

private boolean shouldSkipAddingProduct(OperationProductComponentHolder operationProductComponentHolder, Map<OperationProductComponentEntityType, Set<Entity>> entityTypeWithAlreadyAddedProducts, String typeOfProductionRecording) {
    if (cumulated(typeOfProductionRecording) && operationProductComponentHolder.getProductMaterialType().getStringValue().equals(TechnologyService.L_02_INTERMEDIATE)) {
        return true;
    }
    OperationProductComponentEntityType entityType = operationProductComponentHolder.getEntityType();
    Entity product = operationProductComponentHolder.getProduct();
    return entityTypeWithAlreadyAddedProducts.containsKey(entityType) && entityTypeWithAlreadyAddedProducts.get(entityType).contains(product);
}
Also used : Entity(com.qcadoo.model.api.Entity) OperationProductComponentEntityType(com.qcadoo.mes.technologies.dto.OperationProductComponentEntityType)

Aggregations

OperationProductComponentEntityType (com.qcadoo.mes.technologies.dto.OperationProductComponentEntityType)4 Entity (com.qcadoo.model.api.Entity)4 OperationProductComponentHolder (com.qcadoo.mes.technologies.dto.OperationProductComponentHolder)3 OperationProductComponentWithQuantityContainer (com.qcadoo.mes.technologies.dto.OperationProductComponentWithQuantityContainer)2 ProductMaterialType (com.qcadoo.mes.technologies.dto.ProductMaterialType)2 BigDecimal (java.math.BigDecimal)2 Function (com.google.common.base.Function)1 Lists (com.google.common.collect.Lists)1 Maps (com.google.common.collect.Maps)1 Multimap (com.google.common.collect.Multimap)1 Multimaps (com.google.common.collect.Multimaps)1 Sets (com.google.common.collect.Sets)1 OrderFieldsPC (com.qcadoo.mes.productionCounting.constants.OrderFieldsPC)1 ProductionCountingConstants (com.qcadoo.mes.productionCounting.constants.ProductionCountingConstants)1 ProductionTrackingFields (com.qcadoo.mes.productionCounting.constants.ProductionTrackingFields)1 TypeOfProductionRecording (com.qcadoo.mes.productionCounting.constants.TypeOfProductionRecording)1 ProductQuantitiesService (com.qcadoo.mes.technologies.ProductQuantitiesService)1 TechnologyService (com.qcadoo.mes.technologies.TechnologyService)1 List (java.util.List)1 Map (java.util.Map)1