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);
}
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);
}
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());
}
Aggregations