@Override public int evaluateOperationDurationOutOfCycles(final BigDecimal cycles, final Entity operationComponent, final Entity productionLine, final boolean maxForWorkstation, final boolean includeTpz, final boolean includeAdditionalTime) { boolean isTjDivisable = operationComponent.getBooleanField("isTjDivisible"); Integer workstationsCount = retrieveWorkstationTypesCount(operationComponent, productionLine); BigDecimal cyclesPerOperation = cycles; if (maxForWorkstation) { cyclesPerOperation = cycles.divide(BigDecimal.valueOf(workstationsCount), numberService.getMathContext()); if (!isTjDivisable) { cyclesPerOperation = cyclesPerOperation.setScale(0, RoundingMode.CEILING); } } int tj = getIntegerValue(operationComponent.getField("tj")); int operationTime = cyclesPerOperation.multiply(BigDecimal.valueOf(tj), numberService.getMathContext()).intValue(); if (includeTpz) { int tpz = getIntegerValue(operationComponent.getField("tpz")); operationTime += (maxForWorkstation ? tpz : (tpz * workstationsCount)); } if (includeAdditionalTime) { int additionalTime = getIntegerValue(operationComponent.getField("timeNextOperation")); operationTime += (maxForWorkstation ? additionalTime : (additionalTime * workstationsCount)); } return operationTime; }
private Integer retrieveWorkstationTypesCount(final Entity operationComponent, final Entity productionLine) { if (StringUtils.isEmpty(operationComponent.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY) .getStringField(TechnologyFields.TECHNOLOGY_TYPE))) { if (parameterService.getParameter().getBooleanField("workstationsQuantityFromProductionLine")) { return productionLinesService.getWorkstationTypesCount(operationComponent, productionLine); } else { return getIntegerValue(operationComponent .getIntegerField(TechnologyOperationComponentFields.QUANTITY_OF_WORKSTATIONS)); } } else { return getIntegerValue(operationComponent .getIntegerField(TechnologyOperationComponentFields.QUANTITY_OF_WORKSTATIONS)); } }