use of com.axelor.apps.production.db.ProdProcessLine in project axelor-open-suite by axelor.
the class OperationOrderWorkflowService method computeEntireCycleDuration.
public long computeEntireCycleDuration(OperationOrder operationOrder, BigDecimal qty) throws AxelorException {
ProdProcessLine prodProcessLine = operationOrder.getProdProcessLine();
WorkCenter workCenter = prodProcessLine.getWorkCenter();
long duration = 0;
if (prodProcessLine.getWorkCenter() == null) {
throw new AxelorException(TraceBackRepository.CATEGORY_INCONSISTENCY, I18n.get(IExceptionMessage.PROD_PROCESS_LINE_MISSING_WORK_CENTER), prodProcessLine.getProdProcess() != null ? prodProcessLine.getProdProcess().getCode() : "null", prodProcessLine.getName());
}
BigDecimal maxCapacityPerCycle = prodProcessLine.getMaxCapacityPerCycle();
BigDecimal nbCycles;
if (maxCapacityPerCycle.compareTo(BigDecimal.ZERO) == 0) {
nbCycles = qty;
} else {
nbCycles = qty.divide(maxCapacityPerCycle, 0, RoundingMode.UP);
}
int workCenterTypeSelect = workCenter.getWorkCenterTypeSelect();
if (workCenterTypeSelect == WorkCenterRepository.WORK_CENTER_TYPE_MACHINE || workCenterTypeSelect == WorkCenterRepository.WORK_CENTER_TYPE_BOTH) {
Machine machine = workCenter.getMachine();
if (machine == null) {
throw new AxelorException(workCenter, TraceBackRepository.CATEGORY_MISSING_FIELD, I18n.get(IExceptionMessage.WORKCENTER_NO_MACHINE), workCenter.getName());
}
duration += machine.getStartingDuration();
duration += machine.getEndingDuration();
duration += nbCycles.subtract(new BigDecimal(1)).multiply(new BigDecimal(machine.getSetupDuration())).longValue();
}
BigDecimal durationPerCycle = new BigDecimal(prodProcessLine.getDurationPerCycle());
duration += nbCycles.multiply(durationPerCycle).longValue();
return duration;
}
use of com.axelor.apps.production.db.ProdProcessLine in project axelor-open-suite by axelor.
the class OperationOrderServiceImpl method createToConsumeProdProductList.
@Override
public void createToConsumeProdProductList(OperationOrder operationOrder) {
BigDecimal manufOrderQty = operationOrder.getManufOrder().getQty();
BigDecimal bomQty = operationOrder.getManufOrder().getBillOfMaterial().getQty();
ProdProcessLine prodProcessLine = operationOrder.getProdProcessLine();
if (prodProcessLine.getToConsumeProdProductList() != null) {
for (ProdProduct prodProduct : prodProcessLine.getToConsumeProdProductList()) {
BigDecimal qty = Beans.get(ManufOrderService.class).computeToConsumeProdProductLineQuantity(bomQty, manufOrderQty, prodProduct.getQty());
operationOrder.addToConsumeProdProductListItem(new ProdProduct(prodProduct.getProduct(), qty, prodProduct.getUnit()));
}
}
}
Aggregations