Search in sources :

Example 11 with ManufOrder

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

the class ManufOrderController method checkProducedStockMoveLineList.

/**
 * Called from manuf order form, on produced stock move line change. Call {@link
 * ManufOrderService#checkProducedStockMoveLineList(ManufOrder, ManufOrder)}.
 *
 * @param request
 * @param response
 */
public void checkProducedStockMoveLineList(ActionRequest request, ActionResponse response) {
    try {
        ManufOrder manufOrder = request.getContext().asType(ManufOrder.class);
        ManufOrder oldManufOrder = Beans.get(ManufOrderRepository.class).find(manufOrder.getId());
        Beans.get(ManufOrderService.class).checkProducedStockMoveLineList(manufOrder, oldManufOrder);
    } catch (Exception e) {
        TraceBackService.trace(response, e);
        response.setReload(true);
    }
}
Also used : ManufOrderService(com.axelor.apps.production.service.manuforder.ManufOrderService) ManufOrderRepository(com.axelor.apps.production.db.repo.ManufOrderRepository) BirtException(org.eclipse.birt.core.exception.BirtException) AxelorException(com.axelor.exception.AxelorException) IOException(java.io.IOException) ManufOrder(com.axelor.apps.production.db.ManufOrder)

Example 12 with ManufOrder

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

the class ManufOrderController method updateConsumedStockMoveFromManufOrder.

/**
 * Called from manuf order form, on consumed stock move line change. Call {@link
 * ManufOrderService#updateConsumedStockMoveFromManufOrder(ManufOrder)}.
 *
 * @param request
 * @param response
 */
public void updateConsumedStockMoveFromManufOrder(ActionRequest request, ActionResponse response) {
    try {
        ManufOrder manufOrder = request.getContext().asType(ManufOrder.class);
        manufOrder = Beans.get(ManufOrderRepository.class).find(manufOrder.getId());
        Beans.get(ManufOrderService.class).updateConsumedStockMoveFromManufOrder(manufOrder);
        response.setReload(true);
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : ManufOrderService(com.axelor.apps.production.service.manuforder.ManufOrderService) BirtException(org.eclipse.birt.core.exception.BirtException) AxelorException(com.axelor.exception.AxelorException) IOException(java.io.IOException) ManufOrder(com.axelor.apps.production.db.ManufOrder)

Example 13 with ManufOrder

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

the class ManufOrderController method printProdProcess.

public void printProdProcess(ActionRequest request, ActionResponse response) {
    try {
        ManufOrder manufOrder = request.getContext().asType(ManufOrder.class);
        String prodProcessId = manufOrder.getProdProcess().getId().toString();
        String prodProcessLable = manufOrder.getProdProcess().getName();
        String fileLink = ReportFactory.createReport(IReport.PROD_PROCESS, prodProcessLable + "-${date}").addParam("Locale", ReportSettings.getPrintingLocale(null)).addParam("Timezone", manufOrder.getCompany() != null ? manufOrder.getCompany().getTimezone() : null).addParam("ProdProcessId", prodProcessId).generate().getFileLink();
        response.setView(ActionView.define(prodProcessLable).add("html", fileLink).map());
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : BirtException(org.eclipse.birt.core.exception.BirtException) AxelorException(com.axelor.exception.AxelorException) IOException(java.io.IOException) ManufOrder(com.axelor.apps.production.db.ManufOrder)

Example 14 with ManufOrder

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

the class ProductionOrderServiceImpl method updateProductionOrderStatus.

protected ProductionOrder updateProductionOrderStatus(ProductionOrder productionOrder) {
    if (productionOrder.getStatusSelect() == null) {
        return productionOrder;
    }
    int statusSelect = productionOrder.getStatusSelect();
    if (productionOrder.getManufOrderSet().stream().allMatch(manufOrder -> manufOrder.getStatusSelect() == ManufOrderRepository.STATUS_DRAFT)) {
        statusSelect = ProductionOrderRepository.STATUS_DRAFT;
        productionOrder.setStatusSelect(statusSelect);
        return productionOrderRepo.save(productionOrder);
    }
    boolean oneStarted = false;
    boolean onePlanned = false;
    boolean allCancel = true;
    boolean allCompleted = true;
    for (ManufOrder manufOrder : productionOrder.getManufOrderSet()) {
        switch(manufOrder.getStatusSelect()) {
            case (ManufOrderRepository.STATUS_PLANNED):
                onePlanned = true;
                allCancel = false;
                allCompleted = false;
                break;
            case (ManufOrderRepository.STATUS_IN_PROGRESS):
            case (ManufOrderRepository.STATUS_STANDBY):
                oneStarted = true;
                allCancel = false;
                allCompleted = false;
                break;
            case (ManufOrderRepository.STATUS_FINISHED):
                allCancel = false;
                break;
            case (ManufOrderRepository.STATUS_CANCELED):
                break;
            default:
                allCompleted = false;
                break;
        }
    }
    if (allCancel) {
        statusSelect = ProductionOrderRepository.STATUS_CANCELED;
    } else if (allCompleted) {
        statusSelect = ProductionOrderRepository.STATUS_COMPLETED;
    } else if (oneStarted) {
        statusSelect = ProductionOrderRepository.STATUS_STARTED;
    } else if (onePlanned && (productionOrder.getStatusSelect() == ProductionOrderRepository.STATUS_DRAFT || productionOrder.getStatusSelect() == ProductionOrderRepository.STATUS_CANCELED || productionOrder.getStatusSelect() == ProductionOrderRepository.STATUS_COMPLETED)) {
        statusSelect = ProductionOrderRepository.STATUS_PLANNED;
    }
    productionOrder.setStatusSelect(statusSelect);
    return productionOrderRepo.save(productionOrder);
}
Also used : ManufOrder(com.axelor.apps.production.db.ManufOrder)

Example 15 with ManufOrder

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

the class ProductionOrderServiceImpl method addManufOrder.

@Override
@Transactional(rollbackOn = { Exception.class })
public ProductionOrder addManufOrder(ProductionOrder productionOrder, Product product, BillOfMaterial billOfMaterial, BigDecimal qtyRequested, LocalDateTime startDate, LocalDateTime endDate, SaleOrder saleOrder, int originType) throws AxelorException {
    ManufOrder manufOrder = manufOrderService.generateManufOrder(product, qtyRequested, ManufOrderService.DEFAULT_PRIORITY, ManufOrderService.IS_TO_INVOICE, billOfMaterial, startDate, endDate, originType);
    if (manufOrder != null) {
        if (saleOrder != null) {
            manufOrder.addSaleOrderSetItem(saleOrder);
            manufOrder.setClientPartner(saleOrder.getClientPartner());
            manufOrder.setMoCommentFromSaleOrder(saleOrder.getProductionNote());
        }
        productionOrder.addManufOrderSetItem(manufOrder);
        manufOrder.addProductionOrderSetItem(productionOrder);
    }
    productionOrder = updateProductionOrderStatus(productionOrder);
    return productionOrderRepo.save(productionOrder);
}
Also used : ManufOrder(com.axelor.apps.production.db.ManufOrder) Transactional(com.google.inject.persist.Transactional)

Aggregations

ManufOrder (com.axelor.apps.production.db.ManufOrder)44 AxelorException (com.axelor.exception.AxelorException)30 IOException (java.io.IOException)22 BirtException (org.eclipse.birt.core.exception.BirtException)22 ManufOrderRepository (com.axelor.apps.production.db.repo.ManufOrderRepository)17 ManufOrderService (com.axelor.apps.production.service.manuforder.ManufOrderService)12 BigDecimal (java.math.BigDecimal)12 ArrayList (java.util.ArrayList)12 AppProductionService (com.axelor.apps.production.service.app.AppProductionService)11 List (java.util.List)11 ProdProduct (com.axelor.apps.production.db.ProdProduct)10 ManufOrderWorkflowService (com.axelor.apps.production.service.manuforder.ManufOrderWorkflowService)10 Transactional (com.google.inject.persist.Transactional)10 Beans (com.axelor.inject.Beans)9 Company (com.axelor.apps.base.db.Company)8 Product (com.axelor.apps.base.db.Product)8 ProductRepository (com.axelor.apps.base.db.repo.ProductRepository)8 AppBaseService (com.axelor.apps.base.service.app.AppBaseService)8 IExceptionMessage (com.axelor.apps.production.exceptions.IExceptionMessage)8 I18n (com.axelor.i18n.I18n)8