@Override @Transactional public int estimateOperationTimeConsumption(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(null, operationComponent, includeTpz, includeAdditionalTime, operationRunsFromProductionQuantities, productionLine, false, productComponentQuantities); }
@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); }
@Override public Map<String, BigDecimal> estimateCostCalculationForHourly(final EntityTreeNode calculationOperationComponent, final BigDecimal productionCostMargin, final BigDecimal plannedQuantity, final OperationTimesContainer realizationTimes, final boolean hourlyCostFromOperation) { checkArgument(calculationOperationComponent != null, "given operationComponent is empty"); Map<String, BigDecimal> costs = Maps.newHashMapWithExpectedSize(L_COST_KEYS.size()); MathContext mathContext = numberService.getMathContext(); for (String costKey : L_COST_KEYS) { costs.put(costKey, BigDecimal.ZERO); } for (EntityTreeNode child : calculationOperationComponent.getChildren()) { Map<String, BigDecimal> unitCosts = estimateCostCalculationForHourly(child, productionCostMargin, plannedQuantity, realizationTimes, hourlyCostFromOperation); for (String costKey : L_COST_KEYS) { BigDecimal unitCost = costs.get(costKey).add(unitCosts.get(costKey), mathContext); costs.put(costKey, numberService.setScaleWithDefaultMathContext(unitCost)); } } OperationTimes operationTimes = realizationTimes.get(calculationOperationComponent.getBelongsToField( "technologyOperationComponent").getId()); Map<String, BigDecimal> costsForSingleOperation = estimateHourlyCostCalculationForSingleOperation(operationTimes, productionCostMargin, hourlyCostFromOperation); saveGeneratedValues(costsForSingleOperation, calculationOperationComponent, true, operationTimes.getTimes(), null); costs.put(L_MACHINE_HOURLY_COST, costs.get(L_MACHINE_HOURLY_COST).add(costsForSingleOperation.get(L_OPERATION_MACHINE_COST), mathContext)); costs.put(L_LABOR_HOURLY_COST, costs.get(L_LABOR_HOURLY_COST).add(costsForSingleOperation.get(L_OPERATION_LABOR_COST), mathContext)); return costs; }
private void createOrCopyCalculationOperationComponent(final EntityTreeNode operationComponent, final Entity calculationOperationComponent, final Entity costCalculation) { DataDefinition sourceDD = operationComponent.getDataDefinition(); for (String fieldName : Arrays.asList("priority", "nodeNumber", L_PRODUCTION_IN_ONE_CYCLE, "nextOperationAfterProducedQuantity", "operationOffSet", "effectiveOperationRealizationTime", "effectiveDateFrom", "effectiveDateTo", "pieceworkCost", "numberOfOperations")) { calculationOperationComponent.setField(fieldName, operationComponent.getField(fieldName)); } calculationOperationComponent.setField(L_OPERATION, operationComponent.getBelongsToField(L_OPERATION)); calculationOperationComponent.setField( "nextOperationAfterProducedType", operationComponent.getField("nextOperationAfterProducedType") == null ? "01all" : operationComponent .getField("nextOperationAfterProducedType")); if (!TechnologiesConstants.MODEL_TECHNOLOGY_OPERATION_COMPONENT.equals(sourceDD.getName())) { LOG.error("incorrect model!"); } calculationOperationComponent.setField(L_TECHNOLOGY_OPERATION_COMPONENT, operationComponent); calculationOperationComponent.setField(L_ENTITY_TYPE, L_OPERATION); List<Entity> newTechnologyInstanceOperationComponents = new ArrayList<>(); for (EntityTreeNode child : operationComponent.getChildren()) { newTechnologyInstanceOperationComponents.add(createCalculationOperationComponent(child, calculationOperationComponent, calculationOperationComponent.getDataDefinition(), costCalculation)); } calculationOperationComponent.setField("children", newTechnologyInstanceOperationComponents); }