Search in sources :

Example 16 with AppProductionService

use of com.axelor.apps.production.service.app.AppProductionService in project axelor-open-suite by axelor.

the class OperationOrderServiceBusinessImpl method createOperationOrder.

@Override
@Transactional(rollbackOn = { Exception.class })
public OperationOrder createOperationOrder(ManufOrder manufOrder, ProdProcessLine prodProcessLine) throws AxelorException {
    AppProductionService appProductionService = Beans.get(AppProductionService.class);
    if (!appProductionService.isApp("production") || !appProductionService.getAppProduction().getManageBusinessProduction()) {
        return super.createOperationOrder(manufOrder, prodProcessLine);
    }
    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());
    }
    OperationOrder operationOrder = this.createOperationOrder(manufOrder, prodProcessLine.getPriority(), manufOrder.getIsToInvoice(), prodProcessLine.getWorkCenter(), prodProcessLine.getWorkCenter().getMachine(), prodProcessLine.getMachineTool(), prodProcessLine);
    return Beans.get(OperationOrderRepository.class).save(operationOrder);
}
Also used : AxelorException(com.axelor.exception.AxelorException) OperationOrderRepository(com.axelor.apps.production.db.repo.OperationOrderRepository) OperationOrder(com.axelor.apps.production.db.OperationOrder) AppProductionService(com.axelor.apps.production.service.app.AppProductionService) Transactional(com.google.inject.persist.Transactional)

Example 17 with AppProductionService

use of com.axelor.apps.production.service.app.AppProductionService in project axelor-open-suite by axelor.

the class ProductionConfigService method getManufOrderSequence.

/**
 * Find the configured sequence for a manufacturing order.
 *
 * <p>A company can have a different sequence per workshop. If no sequence is found per workshop,
 * then return {@link ProductionConfig#manufOrderSequence}.
 *
 * @param productionConfig the config corresponding to the company.
 * @param workshop the workshop of the manufacturing order.
 * @return the found sequence.
 * @throws AxelorException if no sequence is found for the given workshop, and if no default
 *     sequence is filled.
 */
public Sequence getManufOrderSequence(ProductionConfig productionConfig, StockLocation workshop) throws AxelorException {
    Sequence sequence = null;
    AppProductionService appProductionService = Beans.get(AppProductionService.class);
    if (appProductionService.isApp("production")) {
        if (productionConfig.getWorkshopSequenceConfigLineList() != null && appProductionService.getAppProduction().getManageWorkshop()) {
            sequence = productionConfig.getWorkshopSequenceConfigLineList().stream().filter(workshopSequenceConfigLine -> workshopSequenceConfigLine.getWorkshopStockLocation().equals(workshop)).map(WorkshopSequenceConfigLine::getSequence).findFirst().orElseGet(productionConfig::getManufOrderSequence);
        } else {
            sequence = productionConfig.getManufOrderSequence();
        }
    }
    if (sequence == null) {
        throw new AxelorException(productionConfig, TraceBackRepository.CATEGORY_CONFIGURATION_ERROR, I18n.get(IExceptionMessage.PRODUCTION_CONFIG_MISSING_MANUF_ORDER_SEQ), productionConfig.getCompany().getName());
    }
    return sequence;
}
Also used : AxelorException(com.axelor.exception.AxelorException) Sequence(com.axelor.apps.base.db.Sequence) AppProductionService(com.axelor.apps.production.service.app.AppProductionService)

Example 18 with AppProductionService

use of com.axelor.apps.production.service.app.AppProductionService in project axelor-open-suite by axelor.

the class PurchaseOrderServiceProductionImpl method setMergedPurchaseOrderForManufOrder.

@SuppressWarnings("unchecked")
private void setMergedPurchaseOrderForManufOrder(PurchaseOrder mergedPurchaseOrder, List<PurchaseOrder> purchaseOrderList) {
    AppProductionService appProductionService = Beans.get(AppProductionService.class);
    if (appProductionService.isApp("production") && appProductionService.getAppProduction().getManageOutsourcing()) {
        ManufOrderRepository manufOrderRepository = Beans.get(ManufOrderRepository.class);
        for (PurchaseOrder purchaseOrder : purchaseOrderList) {
            List<ManufOrder> manufOrderList = (List<ManufOrder>) manufOrderRepository.all().filter("self.purchaseOrder.id = ?1", purchaseOrder.getId());
            for (ManufOrder manufOrder : manufOrderList) {
                manufOrder.setPurchaseOrder(mergedPurchaseOrder);
                manufOrderRepository.save(manufOrder);
            }
        }
    }
}
Also used : ManufOrderRepository(com.axelor.apps.production.db.repo.ManufOrderRepository) PurchaseOrder(com.axelor.apps.purchase.db.PurchaseOrder) List(java.util.List) PriceList(com.axelor.apps.base.db.PriceList) AppProductionService(com.axelor.apps.production.service.app.AppProductionService) ManufOrder(com.axelor.apps.production.db.ManufOrder)

Aggregations

AppProductionService (com.axelor.apps.production.service.app.AppProductionService)18 Transactional (com.google.inject.persist.Transactional)6 ManufOrder (com.axelor.apps.production.db.ManufOrder)4 AxelorException (com.axelor.exception.AxelorException)3 ProductionOrder (com.axelor.apps.production.db.ProductionOrder)2 Project (com.axelor.apps.project.db.Project)2 BigDecimal (java.math.BigDecimal)2 PriceList (com.axelor.apps.base.db.PriceList)1 Product (com.axelor.apps.base.db.Product)1 Sequence (com.axelor.apps.base.db.Sequence)1 InvoicingProject (com.axelor.apps.businessproject.db.InvoicingProject)1 Employee (com.axelor.apps.hr.db.Employee)1 BillOfMaterial (com.axelor.apps.production.db.BillOfMaterial)1 OperationOrder (com.axelor.apps.production.db.OperationOrder)1 ProdHumanResource (com.axelor.apps.production.db.ProdHumanResource)1 ManufOrderRepository (com.axelor.apps.production.db.repo.ManufOrderRepository)1 OperationOrderRepository (com.axelor.apps.production.db.repo.OperationOrderRepository)1 ProjectRepository (com.axelor.apps.project.db.repo.ProjectRepository)1 PurchaseOrder (com.axelor.apps.purchase.db.PurchaseOrder)1 LocalDateTime (java.time.LocalDateTime)1