Search in sources :

Example 16 with OperationProductComponentHolder

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

the class BasicProductionCountingServiceImpl method updateProductionCountingQuantities.

private void updateProductionCountingQuantities(final Entity order, final OperationProductComponentWithQuantityContainer productComponentQuantities, final Set<OperationProductComponentHolder> nonComponents) {
    for (Entry<OperationProductComponentHolder, BigDecimal> productComponentQuantity : productComponentQuantities.asMap().entrySet()) {
        OperationProductComponentHolder operationProductComponentHolder = productComponentQuantity.getKey();
        BigDecimal plannedQuantity = productComponentQuantity.getValue();
        Entity technologyOperationComponent = operationProductComponentHolder.getTechnologyOperationComponent();
        Entity product = operationProductComponentHolder.getProduct();
        String role = getRole(operationProductComponentHolder);
        boolean isNonComponent = nonComponents.contains(operationProductComponentHolder);
        updateProductionCountingQuantity(order, technologyOperationComponent, product, role, isNonComponent, plannedQuantity);
    }
    updateProductionCountingQuantity(order, getOrderTechnologyOperationComponent(order), order.getBelongsToField(OrderFields.PRODUCT), ProductionCountingQuantityRole.PRODUCED.getStringValue(), false, order.getDecimalField(OrderFields.PLANNED_QUANTITY));
}
Also used : OperationProductComponentHolder(com.qcadoo.mes.technologies.dto.OperationProductComponentHolder) Entity(com.qcadoo.model.api.Entity) BigDecimal(java.math.BigDecimal)

Example 17 with OperationProductComponentHolder

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

the class BasicProductionCountingServiceImpl method updateProductionCountingQuantitiesAndOperationRuns.

@Override
public void updateProductionCountingQuantitiesAndOperationRuns(final Entity order) {
    final Map<Long, BigDecimal> operationRuns = Maps.newHashMap();
    final Set<OperationProductComponentHolder> nonComponents = Sets.newHashSet();
    final OperationProductComponentWithQuantityContainer productComponentQuantities = productQuantitiesService.getProductComponentWithQuantities(Collections.singletonList(order), operationRuns, nonComponents);
    updateProductionCountingOperationRuns(order, operationRuns);
    updateProductionCountingQuantities(order, productComponentQuantities, nonComponents);
}
Also used : OperationProductComponentHolder(com.qcadoo.mes.technologies.dto.OperationProductComponentHolder) OperationProductComponentWithQuantityContainer(com.qcadoo.mes.technologies.dto.OperationProductComponentWithQuantityContainer) BigDecimal(java.math.BigDecimal)

Example 18 with OperationProductComponentHolder

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

the class BasicProductionCountingServiceImpl method prepareProductionCountingQuantities.

private List<Entity> prepareProductionCountingQuantities(final Entity order, final Set<OperationProductComponentHolder> nonComponents, final OperationProductComponentWithQuantityContainer productComponentQuantities) {
    final List<Entity> productionCountingQuantities = new ArrayList<>();
    for (Entry<OperationProductComponentHolder, BigDecimal> productComponentQuantity : productComponentQuantities.asMap().entrySet()) {
        OperationProductComponentHolder operationProductComponentHolder = productComponentQuantity.getKey();
        BigDecimal plannedQuantity = productComponentQuantity.getValue();
        Entity product = operationProductComponentHolder.getProduct();
        if (product == null) {
            continue;
        }
        Entity technologyOperationComponent = operationProductComponentHolder.getTechnologyOperationComponent();
        Entity operationProductComponent = operationProductComponentHolder.getOperationProductComponent();
        Entity technologyInputProductType = operationProductComponentHolder.getTechnologyInputProductType();
        Entity attribute = operationProductComponentHolder.getAttribute();
        String role = getRole(operationProductComponentHolder);
        boolean isNonComponent = nonComponents.contains(operationProductComponentHolder);
        Entity productionCountingQuantity = prepareProductionCountingQuantity(order, technologyOperationComponent, attribute, technologyInputProductType, operationProductComponent, product, role, isNonComponent, plannedQuantity);
        productionCountingQuantities.add(productionCountingQuantity);
    }
    if (PluginUtils.isEnabled("productFlowThruDivision")) {
        fillFlow(productionCountingQuantities, order);
    }
    return productionCountingQuantities;
}
Also used : OperationProductComponentHolder(com.qcadoo.mes.technologies.dto.OperationProductComponentHolder) Entity(com.qcadoo.model.api.Entity) ArrayList(java.util.ArrayList) BigDecimal(java.math.BigDecimal)

Example 19 with OperationProductComponentHolder

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

the class BasicProductionCountingServiceImpl method createProductionCounting.

@Override
public OperationProductComponentWithQuantityContainer createProductionCounting(final Entity order) {
    Map<Long, BigDecimal> operationRuns = Maps.newHashMap();
    Set<OperationProductComponentHolder> nonComponents = Sets.newHashSet();
    final OperationProductComponentWithQuantityContainer productComponentQuantities = productQuantitiesService.getProductComponentWithQuantities(Collections.singletonList(order), operationRuns, nonComponents);
    createProductionCountingOperationRuns(order, operationRuns);
    List<Entity> productionCountingQuantities = prepareProductionCountingQuantities(order, nonComponents, productComponentQuantities);
    List<Entity> basicProductionCounting = Lists.newArrayList();
    prepareBasicProductionCounting(order, productionCountingQuantities, basicProductionCounting);
    saveBasicProductionCounting(order, productionCountingQuantities, basicProductionCounting, order.getBelongsToField(OrderFields.PRODUCT));
    return productComponentQuantities;
}
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 20 with OperationProductComponentHolder

use of com.qcadoo.mes.technologies.dto.OperationProductComponentHolder 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)

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