Search in sources :

Example 26 with ManufOrder

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

the class ManufOrderController method print.

/**
 * Method that generate a Pdf file for an manufacturing order
 *
 * @param request
 * @param response
 * @return
 * @throws BirtException
 * @throws IOException
 */
public void print(ActionRequest request, ActionResponse response) {
    try {
        ManufOrder manufOrder = request.getContext().asType(ManufOrder.class);
        ManufOrderPrintService manufOrderPrintService = Beans.get(ManufOrderPrintService.class);
        @SuppressWarnings("unchecked") List<Integer> selectedManufOrderList = (List<Integer>) request.getContext().get("_ids");
        if (selectedManufOrderList != null) {
            String name = manufOrderPrintService.getManufOrdersFilename();
            String fileLink = manufOrderPrintService.printManufOrders(selectedManufOrderList.stream().map(Integer::longValue).collect(Collectors.toList()));
            LOG.debug("Printing {}", name);
            response.setView(ActionView.define(name).add("html", fileLink).map());
        } else if (manufOrder != null) {
            String name = manufOrderPrintService.getFileName(manufOrder);
            String fileLink = manufOrderPrintService.printManufOrder(manufOrder);
            LOG.debug("Printing {}", name);
            response.setView(ActionView.define(name).add("html", fileLink).map());
        } else {
            response.setFlash(I18n.get(IExceptionMessage.MANUF_ORDER_1));
        }
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : ManufOrderPrintService(com.axelor.apps.production.service.manuforder.ManufOrderPrintService) ArrayList(java.util.ArrayList) List(java.util.List) BirtException(org.eclipse.birt.core.exception.BirtException) AxelorException(com.axelor.exception.AxelorException) IOException(java.io.IOException) ManufOrder(com.axelor.apps.production.db.ManufOrder)

Example 27 with ManufOrder

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

the class ManufOrderController method resume.

public void resume(ActionRequest request, ActionResponse response) {
    try {
        Long manufOrderId = (Long) request.getContext().get("id");
        ManufOrder manufOrder = Beans.get(ManufOrderRepository.class).find(manufOrderId);
        Beans.get(ManufOrderWorkflowService.class).resume(manufOrder);
        response.setReload(true);
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : ManufOrderRepository(com.axelor.apps.production.db.repo.ManufOrderRepository) ManufOrderWorkflowService(com.axelor.apps.production.service.manuforder.ManufOrderWorkflowService) BirtException(org.eclipse.birt.core.exception.BirtException) AxelorException(com.axelor.exception.AxelorException) IOException(java.io.IOException) ManufOrder(com.axelor.apps.production.db.ManufOrder)

Example 28 with ManufOrder

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

the class ManufOrderController method updatePlannedDates.

public void updatePlannedDates(ActionRequest request, ActionResponse response) {
    try {
        ManufOrder manufOrderView = request.getContext().asType(ManufOrder.class);
        if (manufOrderView.getStatusSelect() == ManufOrderRepository.STATUS_PLANNED) {
            ManufOrder manufOrder = Beans.get(ManufOrderRepository.class).find(manufOrderView.getId());
            if (manufOrderView.getPlannedStartDateT() != null) {
                if (!manufOrderView.getPlannedStartDateT().isEqual(manufOrder.getPlannedStartDateT())) {
                    Beans.get(ManufOrderWorkflowService.class).updatePlannedDates(manufOrder, manufOrderView.getPlannedStartDateT());
                    response.setReload(true);
                }
            } else {
                response.setValue("plannedStartDateT", manufOrder.getPlannedStartDateT());
            }
        }
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : ManufOrderRepository(com.axelor.apps.production.db.repo.ManufOrderRepository) ManufOrderWorkflowService(com.axelor.apps.production.service.manuforder.ManufOrderWorkflowService) BirtException(org.eclipse.birt.core.exception.BirtException) AxelorException(com.axelor.exception.AxelorException) IOException(java.io.IOException) ManufOrder(com.axelor.apps.production.db.ManufOrder)

Example 29 with ManufOrder

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

the class ManufOrderController method plan.

public void plan(ActionRequest request, ActionResponse response) {
    try {
        Context context = request.getContext();
        List<ManufOrder> manufOrders = new ArrayList<>();
        if (context.get("id") != null) {
            Long manufOrderId = (Long) request.getContext().get("id");
            manufOrders.add(Beans.get(ManufOrderRepository.class).find(manufOrderId));
        } else if (context.get("_ids") != null) {
            manufOrders = Beans.get(ManufOrderRepository.class).all().filter("self.id in ?1 and self.statusSelect in (?2,?3)", context.get("_ids"), ManufOrderRepository.STATUS_DRAFT, ManufOrderRepository.STATUS_CANCELED).fetch();
        }
        for (ManufOrder manufOrder : manufOrders) {
            Beans.get(ManufOrderWorkflowService.class).plan(manufOrder);
            if (manufOrder.getProdProcess().getGeneratePurchaseOrderOnMoPlanning()) {
                Beans.get(ManufOrderWorkflowService.class).createPurchaseOrder(manufOrder);
            }
        }
        response.setReload(true);
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : Context(com.axelor.rpc.Context) ManufOrderRepository(com.axelor.apps.production.db.repo.ManufOrderRepository) ArrayList(java.util.ArrayList) ManufOrderWorkflowService(com.axelor.apps.production.service.manuforder.ManufOrderWorkflowService) BirtException(org.eclipse.birt.core.exception.BirtException) AxelorException(com.axelor.exception.AxelorException) IOException(java.io.IOException) ManufOrder(com.axelor.apps.production.db.ManufOrder)

Example 30 with ManufOrder

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

the class ManufOrderController method updatePlannedQty.

/**
 * Called from manuf order wizard view. Call {@link
 * ManufOrderService#updatePlannedQty(ManufOrder)}
 *
 * @param request
 * @param response
 */
public void updatePlannedQty(ActionRequest request, ActionResponse response) {
    try {
        ManufOrder manufOrder = request.getContext().asType(ManufOrder.class);
        manufOrder = Beans.get(ManufOrderRepository.class).find(manufOrder.getId());
        Beans.get(ManufOrderService.class).updatePlannedQty(manufOrder);
        response.setReload(true);
        response.setCanClose(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)

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