Search in sources :

Example 11 with ProdProcessLine

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;
}
Also used : AxelorException(com.axelor.exception.AxelorException) WorkCenter(com.axelor.apps.production.db.WorkCenter) ProdProcessLine(com.axelor.apps.production.db.ProdProcessLine) BigDecimal(java.math.BigDecimal) Machine(com.axelor.apps.production.db.Machine)

Example 12 with ProdProcessLine

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()));
        }
    }
}
Also used : ManufOrderService(com.axelor.apps.production.service.manuforder.ManufOrderService) ProdProduct(com.axelor.apps.production.db.ProdProduct) ProdProcessLine(com.axelor.apps.production.db.ProdProcessLine) BigDecimal(java.math.BigDecimal)

Aggregations

ProdProcessLine (com.axelor.apps.production.db.ProdProcessLine)12 WorkCenter (com.axelor.apps.production.db.WorkCenter)4 BigDecimal (java.math.BigDecimal)4 AxelorException (com.axelor.exception.AxelorException)3 BillOfMaterial (com.axelor.apps.production.db.BillOfMaterial)2 Machine (com.axelor.apps.production.db.Machine)2 ProdProcess (com.axelor.apps.production.db.ProdProcess)2 ProdProduct (com.axelor.apps.production.db.ProdProduct)2 Product (com.axelor.apps.base.db.Product)1 ConfiguratorProdProcessLine (com.axelor.apps.production.db.ConfiguratorProdProcessLine)1 ManufOrder (com.axelor.apps.production.db.ManufOrder)1 WorkCenterGroup (com.axelor.apps.production.db.WorkCenterGroup)1 ProdProcessLineRepository (com.axelor.apps.production.db.repo.ProdProcessLineRepository)1 WorkCenterGroupRepository (com.axelor.apps.production.db.repo.WorkCenterGroupRepository)1 ProdProcessLineService (com.axelor.apps.production.service.ProdProcessLineService)1 StockConfigProductionService (com.axelor.apps.production.service.config.StockConfigProductionService)1 ManufOrderService (com.axelor.apps.production.service.manuforder.ManufOrderService)1 StockConfig (com.axelor.apps.stock.db.StockConfig)1 StockLocation (com.axelor.apps.stock.db.StockLocation)1 Transactional (com.google.inject.persist.Transactional)1