Search in sources :

Example 6 with ProdProcess

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

the class ProdProcessController method print.

public void print(ActionRequest request, ActionResponse response) {
    try {
        ProdProcess prodProcess = request.getContext().asType(ProdProcess.class);
        String fileLink = Beans.get(ProdProcessService.class).print(prodProcess);
        response.setView(ActionView.define(prodProcess.getName()).add("html", fileLink).map());
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : ProdProcessService(com.axelor.apps.production.service.ProdProcessService) ProdProcess(com.axelor.apps.production.db.ProdProcess) AxelorException(com.axelor.exception.AxelorException)

Example 7 with ProdProcess

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

the class ManufOrderServiceImpl method createManufOrder.

@Override
public ManufOrder createManufOrder(Product product, BigDecimal qty, int priority, boolean isToInvoice, Company company, BillOfMaterial billOfMaterial, LocalDateTime plannedStartDateT, LocalDateTime plannedEndDateT) throws AxelorException {
    logger.debug("Création d'un OF {}", priority);
    ProdProcess prodProcess = billOfMaterial.getProdProcess();
    ManufOrder manufOrder = new ManufOrder(qty, company, null, priority, this.isManagedConsumedProduct(billOfMaterial), billOfMaterial, product, prodProcess, plannedStartDateT, plannedEndDateT, ManufOrderRepository.STATUS_DRAFT, prodProcess.getOutsourcing());
    manufOrder = manufOrderRepo.save(manufOrder);
    if (appProductionService.getAppProduction().getManageWorkshop()) {
        manufOrder.setWorkshopStockLocation(billOfMaterial.getWorkshopStockLocation());
    }
    if (prodProcess != null && prodProcess.getProdProcessLineList() != null) {
        for (ProdProcessLine prodProcessLine : this._sortProdProcessLineByPriority(prodProcess.getProdProcessLineList())) {
            manufOrder.addOperationOrderListItem(operationOrderService.createOperationOrder(manufOrder, prodProcessLine));
        }
    }
    return manufOrder;
}
Also used : ProdProcess(com.axelor.apps.production.db.ProdProcess) ProdProcessLine(com.axelor.apps.production.db.ProdProcessLine) ManufOrder(com.axelor.apps.production.db.ManufOrder)

Example 8 with ProdProcess

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

the class ManufOrderServiceImpl method preFillOperations.

@Override
@Transactional(rollbackOn = { Exception.class })
public void preFillOperations(ManufOrder manufOrder) throws AxelorException {
    BillOfMaterial billOfMaterial = manufOrder.getBillOfMaterial();
    if (manufOrder.getProdProcess() == null) {
        manufOrder.setProdProcess(billOfMaterial.getProdProcess());
    }
    ProdProcess prodProcess = manufOrder.getProdProcess();
    if (manufOrder.getPlannedStartDateT() == null) {
        manufOrder.setPlannedStartDateT(appProductionService.getTodayDateTime().toLocalDateTime());
    }
    if (prodProcess != null && prodProcess.getProdProcessLineList() != null) {
        for (ProdProcessLine prodProcessLine : this._sortProdProcessLineByPriority(prodProcess.getProdProcessLineList())) {
            manufOrder.addOperationOrderListItem(operationOrderService.createOperationOrder(manufOrder, prodProcessLine));
        }
    }
    manufOrderRepo.save(manufOrder);
    manufOrder.setPlannedEndDateT(manufOrderWorkflowService.computePlannedEndDateT(manufOrder));
    manufOrderRepo.save(manufOrder);
}
Also used : BillOfMaterial(com.axelor.apps.production.db.BillOfMaterial) ProdProcess(com.axelor.apps.production.db.ProdProcess) ProdProcessLine(com.axelor.apps.production.db.ProdProcessLine) Transactional(com.google.inject.persist.Transactional)

Example 9 with ProdProcess

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

the class ConfiguratorProdProcessServiceImpl method createProdProcessHeader.

/**
 * Instantiate a new prod process and set the right attributes.
 */
protected ProdProcess createProdProcessHeader(ConfiguratorProdProcess confProdProcess, String code, StockLocation stockLocation, StockLocation producedProductStockLocation, StockLocation workshopStockLocation, Product product) {
    ProdProcess prodProcess = new ProdProcess();
    prodProcess.setName(confProdProcess.getName());
    prodProcess.setCompany(confProdProcess.getCompany());
    prodProcess.setStatusSelect(confProdProcess.getStatusSelect());
    prodProcess.setCode(code);
    prodProcess.setStockLocation(stockLocation);
    prodProcess.setProducedProductStockLocation(producedProductStockLocation);
    prodProcess.setWorkshopStockLocation(workshopStockLocation);
    prodProcess.setProduct(product);
    return prodProcessRepository.save(prodProcess);
}
Also used : ConfiguratorProdProcess(com.axelor.apps.production.db.ConfiguratorProdProcess) ProdProcess(com.axelor.apps.production.db.ProdProcess)

Example 10 with ProdProcess

use of com.axelor.apps.production.db.ProdProcess 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

ProdProcess (com.axelor.apps.production.db.ProdProcess)12 ProdProcessService (com.axelor.apps.production.service.ProdProcessService)3 Transactional (com.google.inject.persist.Transactional)3 BillOfMaterial (com.axelor.apps.production.db.BillOfMaterial)2 ConfiguratorProdProcess (com.axelor.apps.production.db.ConfiguratorProdProcess)2 ProdProcessLine (com.axelor.apps.production.db.ProdProcessLine)2 ProdProcessRepository (com.axelor.apps.production.db.repo.ProdProcessRepository)2 AxelorException (com.axelor.exception.AxelorException)2 Product (com.axelor.apps.base.db.Product)1 Unit (com.axelor.apps.base.db.Unit)1 ProductRepository (com.axelor.apps.base.db.repo.ProductRepository)1 ConfiguratorBOM (com.axelor.apps.production.db.ConfiguratorBOM)1 ConfiguratorProdProcessLine (com.axelor.apps.production.db.ConfiguratorProdProcessLine)1 ManufOrder (com.axelor.apps.production.db.ManufOrder)1 StockLocation (com.axelor.apps.stock.db.StockLocation)1 BigDecimal (java.math.BigDecimal)1