Search in sources :

Example 1 with ConfiguratorProdProcessLine

use of com.axelor.apps.production.db.ConfiguratorProdProcessLine in project axelor-open-suite by axelor.

the class ConfiguratorProdProcessLineServiceImpl method generateProdProcessLine.

@Override
public ProdProcessLine generateProdProcessLine(ConfiguratorProdProcessLine confProdProcessLine, JsonContext attributes) throws AxelorException {
    if (confProdProcessLine == null) {
        return null;
    }
    ProdProcessLine prodProcessLine = new ProdProcessLine();
    BigDecimal minCapacityPerCycle;
    BigDecimal maxCapacityPerCycle;
    long durationPerCycle;
    if (confProdProcessLine.getDefMinCapacityFormula()) {
        minCapacityPerCycle = new BigDecimal(configuratorService.computeFormula(confProdProcessLine.getMinCapacityPerCycleFormula(), attributes).toString());
    } else {
        minCapacityPerCycle = confProdProcessLine.getMinCapacityPerCycle();
    }
    if (confProdProcessLine.getDefMaxCapacityFormula()) {
        maxCapacityPerCycle = new BigDecimal(configuratorService.computeFormula(confProdProcessLine.getMaxCapacityPerCycleFormula(), attributes).toString());
    } else {
        maxCapacityPerCycle = confProdProcessLine.getMaxCapacityPerCycle();
    }
    if (confProdProcessLine.getDefDurationFormula()) {
        durationPerCycle = Long.decode(configuratorService.computeFormula(confProdProcessLine.getDurationPerCycleFormula(), attributes).toString());
    } else {
        durationPerCycle = confProdProcessLine.getDurationPerCycle();
    }
    prodProcessLine.setName(confProdProcessLine.getName());
    prodProcessLine.setPriority(confProdProcessLine.getPriority());
    prodProcessLine.setWorkCenter(confProdProcessLine.getWorkCenter());
    prodProcessLine.setOutsourcing(confProdProcessLine.getOutsourcing());
    prodProcessLine.setStockLocation(confProdProcessLine.getStockLocation());
    prodProcessLine.setDescription(confProdProcessLine.getDescription());
    prodProcessLine.setMinCapacityPerCycle(minCapacityPerCycle);
    prodProcessLine.setMaxCapacityPerCycle(maxCapacityPerCycle);
    prodProcessLine.setDurationPerCycle(durationPerCycle);
    return prodProcessLine;
}
Also used : ProdProcessLine(com.axelor.apps.production.db.ProdProcessLine) ConfiguratorProdProcessLine(com.axelor.apps.production.db.ConfiguratorProdProcessLine) BigDecimal(java.math.BigDecimal)

Example 2 with ConfiguratorProdProcessLine

use of com.axelor.apps.production.db.ConfiguratorProdProcessLine in project axelor-open-suite by axelor.

the class ConfiguratorProdProcessServiceImpl method generateProdProcessService.

@Override
public ProdProcess generateProdProcessService(ConfiguratorProdProcess confProdProcess, JsonContext attributes, Product product) throws AxelorException {
    if (confProdProcess == null) {
        return null;
    }
    String code;
    StockLocation stockLocation;
    StockLocation producedProductStockLocation;
    StockLocation workshopStockLocation;
    if (confProdProcess.getDefCodeAsFormula()) {
        code = String.valueOf(configuratorService.computeFormula(confProdProcess.getCodeFormula(), attributes));
    } else {
        code = confProdProcess.getCode();
    }
    if (confProdProcess.getDefStockLocationAsFormula()) {
        stockLocation = (StockLocation) configuratorService.computeFormula(confProdProcess.getStockLocationFormula(), attributes);
    } else {
        stockLocation = confProdProcess.getStockLocation();
    }
    if (confProdProcess.getDefProducedProductStockLocationAsFormula()) {
        producedProductStockLocation = (StockLocation) configuratorService.computeFormula(confProdProcess.getProducedProductStockLocationFormula(), attributes);
    } else {
        producedProductStockLocation = confProdProcess.getProducedProductStockLocation();
    }
    if (confProdProcess.getDefWorkshopStockLocationAsFormula()) {
        workshopStockLocation = (StockLocation) configuratorService.computeFormula(confProdProcess.getWorkshopStockLocationFormula(), attributes);
    } else {
        workshopStockLocation = confProdProcess.getWorkshopStockLocation();
    }
    ProdProcess prodProcess = createProdProcessHeader(confProdProcess, code, stockLocation, producedProductStockLocation, workshopStockLocation, product);
    List<ConfiguratorProdProcessLine> confLines = confProdProcess.getConfiguratorProdProcessLineList();
    if (confLines != null) {
        for (ConfiguratorProdProcessLine confLine : confLines) {
            prodProcess.addProdProcessLineListItem(confProdProcessLineService.generateProdProcessLine(confLine, attributes));
        }
    }
    return prodProcess;
}
Also used : StockLocation(com.axelor.apps.stock.db.StockLocation) ConfiguratorProdProcess(com.axelor.apps.production.db.ConfiguratorProdProcess) ProdProcess(com.axelor.apps.production.db.ProdProcess) ConfiguratorProdProcessLine(com.axelor.apps.production.db.ConfiguratorProdProcessLine)

Aggregations

ConfiguratorProdProcessLine (com.axelor.apps.production.db.ConfiguratorProdProcessLine)2 ConfiguratorProdProcess (com.axelor.apps.production.db.ConfiguratorProdProcess)1 ProdProcess (com.axelor.apps.production.db.ProdProcess)1 ProdProcessLine (com.axelor.apps.production.db.ProdProcessLine)1 StockLocation (com.axelor.apps.stock.db.StockLocation)1 BigDecimal (java.math.BigDecimal)1