Search in sources :

Example 26 with OperationProductComponentWithQuantityContainer

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

the class ProductQuantitiesWithComponentsServiceImpl method getProductComponentWithQuantitiesForTechnology.

@Override
public OperationProductComponentWithQuantityContainer getProductComponentWithQuantitiesForTechnology(final Entity technology, final BigDecimal givenQuantity, final Map<Long, BigDecimal> operationRuns, final Set<OperationProductComponentHolder> nonComponents) {
    OperationProductComponentWithQuantityContainer operationProductComponentWithQuantityContainer = new OperationProductComponentWithQuantityContainer();
    EntityTree operationComponents = productStructureTreeService.getOperationComponentsFromTechnology(technology);
    technology.setField(TechnologyFields.OPERATION_COMPONENTS, EntityTreeUtilsService.getDetachedEntityTree(operationComponents));
    Entity root = technology.getTreeField(TechnologyFields.OPERATION_COMPONENTS).getRoot();
    Map<Long, Entity> entitiesById = new LinkedHashMap<>();
    for (Entity entity : operationComponents) {
        entitiesById.put(entity.getId(), entity);
    }
    if (root != null) {
        productQuantitiesService.preloadProductQuantitiesAndOperationRuns(operationComponents, operationProductComponentWithQuantityContainer, operationRuns);
        productQuantitiesService.traverseProductQuantitiesAndOperationRuns(technology, entitiesById, givenQuantity, root, null, operationProductComponentWithQuantityContainer, nonComponents, operationRuns);
    }
    return operationProductComponentWithQuantityContainer;
}
Also used : Entity(com.qcadoo.model.api.Entity) OperationProductComponentWithQuantityContainer(com.qcadoo.mes.technologies.dto.OperationProductComponentWithQuantityContainer) EntityTree(com.qcadoo.model.api.EntityTree) LinkedHashMap(java.util.LinkedHashMap)

Example 27 with OperationProductComponentWithQuantityContainer

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

the class WorkPlansColumnFiller method getValues.

@Override
public Map<Entity, Map<String, String>> getValues(final List<Entity> orders) {
    Map<Entity, Map<String, String>> values = new HashMap<>();
    for (Entity order : orders) {
        OperationProductComponentWithQuantityContainer productQuantities = productQuantitiesService.getProductComponentQuantities(order);
        Entity technology = order.getBelongsToField(OrderFields.TECHNOLOGY);
        fillProductNames(technology, values);
        fillPlannedQuantities(technology, productQuantities, values);
    }
    return values;
}
Also used : Entity(com.qcadoo.model.api.Entity) HashMap(java.util.HashMap) OperationProductComponentWithQuantityContainer(com.qcadoo.mes.technologies.dto.OperationProductComponentWithQuantityContainer) HashMap(java.util.HashMap) Map(java.util.Map)

Example 28 with OperationProductComponentWithQuantityContainer

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

the class MrpAlgorithmStrategyTSTest method init.

@Before
public void init() {
    algorithmStrategyTS = new MrpAlgorithmStrategyTS();
    MockitoAnnotations.initMocks(this);
    ReflectionTestUtils.setField(algorithmStrategyTS, "productQuantitiesService", productQuantitiesService);
    EntityList opComp1InComp = mockEntityListIterator(asList(productInComponent1, productInComponent3));
    EntityList opComp1OutComp = mockEntityListIterator(asList(productOutComponent2));
    EntityList opComp2InComp = mockEntityListIterator(asList(productInComponent2));
    EntityList opComp2OutComp = mockEntityListIterator(asList(productOutComponent4));
    when(operComp1.getHasManyField("operationProductInComponents")).thenReturn(opComp1InComp);
    when(operComp1.getHasManyField("operationProductOutComponents")).thenReturn(opComp1OutComp);
    when(operComp2.getHasManyField("operationProductInComponents")).thenReturn(opComp2InComp);
    when(operComp2.getHasManyField("operationProductOutComponents")).thenReturn(opComp2OutComp);
    when(productInComponent1.getField("quantity")).thenReturn(new BigDecimal(5));
    when(productInComponent3.getField("quantity")).thenReturn(BigDecimal.ONE);
    when(productOutComponent2.getField("quantity")).thenReturn(BigDecimal.ONE);
    when(productInComponent2.getField("quantity")).thenReturn(new BigDecimal(2));
    when(productOutComponent4.getField("quantity")).thenReturn(BigDecimal.ONE);
    productComponentQuantities = new OperationProductComponentWithQuantityContainer();
    nonComponents = Sets.newHashSet();
    productComponentQuantities.put(productInComponent1, new BigDecimal(5));
    productComponentQuantities.put(productInComponent3, BigDecimal.ONE);
    productComponentQuantities.put(productOutComponent2, BigDecimal.ONE);
    productComponentQuantities.put(productOutComponent4, BigDecimal.ONE);
    productComponentQuantities.put(productInComponent2, new BigDecimal(2));
    nonComponents.add(new OperationProductComponentHolder(productInComponent2));
    when(product1.getId()).thenReturn(1L);
    when(product2.getId()).thenReturn(2L);
    when(product3.getId()).thenReturn(3L);
    when(product4.getId()).thenReturn(4L);
    when(productInComponent1.getBelongsToField("product")).thenReturn(product1);
    when(productInComponent2.getBelongsToField("product")).thenReturn(product2);
    when(productInComponent3.getBelongsToField("product")).thenReturn(product3);
    when(productOutComponent2.getBelongsToField("product")).thenReturn(product2);
    when(productOutComponent4.getBelongsToField("product")).thenReturn(product4);
    when(productInComponent1.getBelongsToField("operationComponent")).thenReturn(operComp1);
    when(productInComponent3.getBelongsToField("operationComponent")).thenReturn(operComp1);
    when(productOutComponent2.getBelongsToField("operationComponent")).thenReturn(operComp1);
    when(productInComponent2.getBelongsToField("operationComponent")).thenReturn(operComp2);
    when(productOutComponent4.getBelongsToField("operationComponent")).thenReturn(operComp2);
    when(ddIn.getName()).thenReturn("productInComponent");
    when(ddOut.getName()).thenReturn("productOutComponent");
    when(productInComponent1.getDataDefinition()).thenReturn(ddIn);
    when(productInComponent2.getDataDefinition()).thenReturn(ddIn);
    when(productInComponent3.getDataDefinition()).thenReturn(ddIn);
    when(productOutComponent2.getDataDefinition()).thenReturn(ddOut);
    when(productOutComponent4.getDataDefinition()).thenReturn(ddOut);
    when(ddIn.getName()).thenReturn("operationProductInComponent");
    when(ddOut.getName()).thenReturn("operationProductOutComponent");
}
Also used : OperationProductComponentHolder(com.qcadoo.mes.technologies.dto.OperationProductComponentHolder) OperationProductComponentWithQuantityContainer(com.qcadoo.mes.technologies.dto.OperationProductComponentWithQuantityContainer) EntityList(com.qcadoo.model.api.EntityList) BigDecimal(java.math.BigDecimal) Before(org.junit.Before)

Example 29 with OperationProductComponentWithQuantityContainer

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

the class OrderRealizationTimeServiceImpl method getQuantityCyclesNeededToProducedNextOperationAfterProducedQuantity.

private BigDecimal getQuantityCyclesNeededToProducedNextOperationAfterProducedQuantity(final Entity operationComponent, final BigDecimal nextOperationAfterProducedQuantity) {
    MathContext mc = numberService.getMathContext();
    Entity technology = operationComponent.getBelongsToField(TECHNOLOGY);
    Map<Long, BigDecimal> operationRunsFromProductionQuantities = Maps.newHashMap();
    OperationProductComponentWithQuantityContainer productQuantities = productQuantitiesService.getProductComponentQuantities(technology, BigDecimal.ONE, operationRunsFromProductionQuantities);
    BigDecimal operationsRunsForOneMainProduct = operationRunsFromProductionQuantities.get(operationComponent.getId());
    BigDecimal quantityOutputProductProduced = productQuantities.get(getOutputProduct(operationComponent));
    BigDecimal cycles = operationsRunsForOneMainProduct.multiply(nextOperationAfterProducedQuantity, mc).divide(quantityOutputProductProduced, mc);
    return numberService.setScaleWithDefaultMathContext(cycles);
}
Also used : Entity(com.qcadoo.model.api.Entity) OperationProductComponentWithQuantityContainer(com.qcadoo.mes.technologies.dto.OperationProductComponentWithQuantityContainer) MathContext(java.math.MathContext) BigDecimal(java.math.BigDecimal)

Example 30 with OperationProductComponentWithQuantityContainer

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

the class OrderRealizationTimeServiceImpl method estimateMaxOperationTimeConsumptionForWorkstation.

@Override
@Transactional
public int estimateMaxOperationTimeConsumptionForWorkstation(final Entity order, final EntityTreeNode operationComponent, final BigDecimal plannedQuantity, final boolean includeTpz, final boolean includeAdditionalTime, final Entity productionLine) {
    Entity technology = operationComponent.getBelongsToField(TECHNOLOGY);
    Map<Long, BigDecimal> operationRunsFromProductionQuantities = Maps.newHashMap();
    OperationProductComponentWithQuantityContainer productComponentQuantities = productQuantitiesService.getProductComponentQuantities(technology, plannedQuantity, operationRunsFromProductionQuantities);
    return evaluateOperationTime(order, operationComponent, includeTpz, includeAdditionalTime, operationRunsFromProductionQuantities, productionLine, true, productComponentQuantities);
}
Also used : Entity(com.qcadoo.model.api.Entity) OperationProductComponentWithQuantityContainer(com.qcadoo.mes.technologies.dto.OperationProductComponentWithQuantityContainer) BigDecimal(java.math.BigDecimal) Transactional(org.springframework.transaction.annotation.Transactional)

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