Search in sources :

Example 1 with ProductQuantitiesHolder

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

the class ProductQuantitiesServiceImpl method getProductComponentQuantities.

@Override
public ProductQuantitiesHolder getProductComponentQuantities(final Entity technology, final BigDecimal givenQuantity) {
    Map<Long, BigDecimal> operationRuns = Maps.newHashMap();
    OperationProductComponentWithQuantityContainer productQuantities = getProductComponentQuantities(technology, givenQuantity, operationRuns);
    return new ProductQuantitiesHolder(productQuantities, operationRuns);
}
Also used : OperationProductComponentWithQuantityContainer(com.qcadoo.mes.technologies.dto.OperationProductComponentWithQuantityContainer) ProductQuantitiesHolder(com.qcadoo.mes.technologies.dto.ProductQuantitiesHolder) BigDecimal(java.math.BigDecimal)

Example 2 with ProductQuantitiesHolder

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

Example 3 with ProductQuantitiesHolder

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

the class OperationsCostCalculationServiceImpl method calculateOperationsCost.

@Override
public BigDecimal calculateOperationsCost(final Entity costCalculation, final Entity technology) {
    DataDefinition costCalculationDataDefinition = costCalculation.getDataDefinition();
    BigDecimal quantity = costCalculation.getDecimalField(CostCalculationFields.QUANTITY);
    ProductQuantitiesHolder productQuantitiesAndOperationRuns = getProductQuantitiesAndOperationRuns(technology, quantity, costCalculation);
    Entity copyCostCalculation = operationCostCalculationTreeBuilder.copyTechnologyTree(costCalculation, technology);
    Entity yetAnotherCostCalculation = costCalculationDataDefinition.save(copyCostCalculation);
    Entity newCostCalculation = costCalculationDataDefinition.get(yetAnotherCostCalculation.getId());
    EntityTree calculationOperationComponents = newCostCalculation.getTreeField(CostCalculationFields.CALCULATION_OPERATION_COMPONENTS);
    checkArgument(calculationOperationComponents != null, "given operation components is null");
    List<Entity> tocs = calculationOperationComponents.stream().map(e -> e.getBelongsToField(CalculationOperationComponentFields.TECHNOLOGY_OPERATION_COMPONENT)).collect(Collectors.toList());
    OperationTimesContainer operationTimes = operationWorkTimeService.estimateOperationsWorkTimes(tocs, productQuantitiesAndOperationRuns.getOperationRuns(), costCalculation.getBooleanField(CostCalculationFields.INCLUDE_TPZ), costCalculation.getBooleanField(CostCalculationFields.INCLUDE_ADDITIONAL_TIME), true);
    boolean hourlyCostFromOperation = !SourceOfOperationCosts.PARAMETERS.getStringValue().equals(costCalculation.getStringField(CostCalculationFields.SOURCE_OF_OPERATION_COSTS));
    Map<String, BigDecimal> resultsMap = estimateCostCalculationForHourly(calculationOperationComponents.getRoot(), operationTimes, hourlyCostFromOperation, costCalculation);
    costCalculation.setField(CostCalculationFields.CALCULATION_OPERATION_COMPONENTS, calculationOperationComponents);
    return BigDecimalUtils.convertNullToZero(numberService.setScaleWithDefaultMathContext(resultsMap.get(CalculationOperationComponentFields.MACHINE_HOURLY_COST))).add(BigDecimalUtils.convertNullToZero(numberService.setScaleWithDefaultMathContext(resultsMap.get(CalculationOperationComponentFields.LABOR_HOURLY_COST))), numberService.getMathContext());
}
Also used : OperationTimesContainer(com.qcadoo.mes.operationTimeCalculations.dto.OperationTimesContainer) TechnologyOperationComponentFieldsCNFO(com.qcadoo.mes.costNormsForOperation.constants.TechnologyOperationComponentFieldsCNFO) ProductQuantitiesHolder(com.qcadoo.mes.technologies.dto.ProductQuantitiesHolder) Autowired(org.springframework.beans.factory.annotation.Autowired) BigDecimalUtils(com.qcadoo.model.api.BigDecimalUtils) ProductQuantitiesWithComponentsService(com.qcadoo.mes.technologies.ProductQuantitiesWithComponentsService) BigDecimal(java.math.BigDecimal) CostCalculationFields(com.qcadoo.mes.costCalculation.constants.CostCalculationFields) Preconditions.checkArgument(com.google.common.base.Preconditions.checkArgument) PluginManager(com.qcadoo.plugin.api.PluginManager) Service(org.springframework.stereotype.Service) Map(java.util.Map) ProductQuantitiesService(com.qcadoo.mes.technologies.ProductQuantitiesService) MathContext(java.math.MathContext) Set(java.util.Set) CalculationOperationComponentFields(com.qcadoo.mes.costNormsForOperation.constants.CalculationOperationComponentFields) Collectors(java.util.stream.Collectors) Maps(com.google.common.collect.Maps) SourceOfOperationCosts(com.qcadoo.mes.costCalculation.constants.SourceOfOperationCosts) DataDefinition(com.qcadoo.model.api.DataDefinition) EntityTree(com.qcadoo.model.api.EntityTree) Sets(com.google.common.collect.Sets) OperationWorkTime(com.qcadoo.mes.operationTimeCalculations.OperationWorkTime) List(java.util.List) Entity(com.qcadoo.model.api.Entity) OperationTimes(com.qcadoo.mes.operationTimeCalculations.dto.OperationTimes) NumberService(com.qcadoo.model.api.NumberService) OperationWorkTimeService(com.qcadoo.mes.operationTimeCalculations.OperationWorkTimeService) OperationCostCalculationTreeBuilder(com.qcadoo.mes.operationCostCalculations.OperationCostCalculationTreeBuilder) EntityTreeNode(com.qcadoo.model.api.EntityTreeNode) Entity(com.qcadoo.model.api.Entity) ProductQuantitiesHolder(com.qcadoo.mes.technologies.dto.ProductQuantitiesHolder) OperationTimesContainer(com.qcadoo.mes.operationTimeCalculations.dto.OperationTimesContainer) DataDefinition(com.qcadoo.model.api.DataDefinition) EntityTree(com.qcadoo.model.api.EntityTree) BigDecimal(java.math.BigDecimal)

Aggregations

ProductQuantitiesHolder (com.qcadoo.mes.technologies.dto.ProductQuantitiesHolder)3 BigDecimal (java.math.BigDecimal)3 OperationProductComponentWithQuantityContainer (com.qcadoo.mes.technologies.dto.OperationProductComponentWithQuantityContainer)2 Preconditions.checkArgument (com.google.common.base.Preconditions.checkArgument)1 Maps (com.google.common.collect.Maps)1 Sets (com.google.common.collect.Sets)1 CostCalculationFields (com.qcadoo.mes.costCalculation.constants.CostCalculationFields)1 SourceOfOperationCosts (com.qcadoo.mes.costCalculation.constants.SourceOfOperationCosts)1 CalculationOperationComponentFields (com.qcadoo.mes.costNormsForOperation.constants.CalculationOperationComponentFields)1 TechnologyOperationComponentFieldsCNFO (com.qcadoo.mes.costNormsForOperation.constants.TechnologyOperationComponentFieldsCNFO)1 OperationCostCalculationTreeBuilder (com.qcadoo.mes.operationCostCalculations.OperationCostCalculationTreeBuilder)1 OperationWorkTime (com.qcadoo.mes.operationTimeCalculations.OperationWorkTime)1 OperationWorkTimeService (com.qcadoo.mes.operationTimeCalculations.OperationWorkTimeService)1 OperationTimes (com.qcadoo.mes.operationTimeCalculations.dto.OperationTimes)1 OperationTimesContainer (com.qcadoo.mes.operationTimeCalculations.dto.OperationTimesContainer)1 ProductQuantitiesService (com.qcadoo.mes.technologies.ProductQuantitiesService)1 ProductQuantitiesWithComponentsService (com.qcadoo.mes.technologies.ProductQuantitiesWithComponentsService)1 OperationProductComponentHolder (com.qcadoo.mes.technologies.dto.OperationProductComponentHolder)1 BigDecimalUtils (com.qcadoo.model.api.BigDecimalUtils)1 DataDefinition (com.qcadoo.model.api.DataDefinition)1