Search in sources :

Example 26 with OperationOrder

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

the class OperationOrderController method print.

/**
 * Method that generate a Pdf file for an operation order
 *
 * @param request
 * @param response
 * @return
 * @throws BirtException
 * @throws IOException
 */
public void print(ActionRequest request, ActionResponse response) {
    OperationOrder operationOrder = request.getContext().asType(OperationOrder.class);
    String operationOrderIds = "";
    try {
        @SuppressWarnings("unchecked") List<Integer> lstSelectedOperationOrder = (List<Integer>) request.getContext().get("_ids");
        if (lstSelectedOperationOrder != null) {
            for (Integer it : lstSelectedOperationOrder) {
                operationOrderIds += it.toString() + ",";
            }
        }
        if (!operationOrderIds.equals("")) {
            operationOrderIds = operationOrderIds.substring(0, operationOrderIds.length() - 1);
            operationOrder = Beans.get(OperationOrderRepository.class).find(new Long(lstSelectedOperationOrder.get(0)));
        } else if (operationOrder.getId() != null) {
            operationOrderIds = operationOrder.getId().toString();
        }
        if (!operationOrderIds.equals("")) {
            String name = " ";
            if (operationOrder.getName() != null) {
                name += lstSelectedOperationOrder == null ? "Op " + operationOrder.getName() : "Ops";
            }
            String fileLink = ReportFactory.createReport(IReport.OPERATION_ORDER, name + "-${date}").addParam("Locale", ReportSettings.getPrintingLocale(null)).addParam("Timezone", getTimezone(operationOrder)).addParam("OperationOrderId", operationOrderIds).generate().getFileLink();
            LOG.debug("Printing " + name);
            response.setView(ActionView.define(name).add("html", fileLink).map());
        } else {
            response.setFlash(I18n.get(IExceptionMessage.OPERATION_ORDER_1));
        }
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : List(java.util.List) OperationOrder(com.axelor.apps.production.db.OperationOrder) BirtException(org.eclipse.birt.core.exception.BirtException) IOException(java.io.IOException)

Example 27 with OperationOrder

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

the class OperationOrderController method setRealDates.

public void setRealDates(ActionRequest request, ActionResponse response) {
    OperationOrder operationOrder = request.getContext().asType(OperationOrder.class);
    LocalDateTime realStartDateT = operationOrder.getRealStartDateT();
    LocalDateTime realEndDateT = operationOrder.getRealEndDateT();
    operationOrder = Beans.get(OperationOrderRepository.class).find(operationOrder.getId());
    Beans.get(OperationOrderWorkflowService.class).setRealDates(operationOrder, realStartDateT, realEndDateT);
}
Also used : LocalDateTime(java.time.LocalDateTime) OperationOrderWorkflowService(com.axelor.apps.production.service.operationorder.OperationOrderWorkflowService) OperationOrder(com.axelor.apps.production.db.OperationOrder)

Example 28 with OperationOrder

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

the class OperationOrderController method machineChange.

public void machineChange(ActionRequest request, ActionResponse response) {
    try {
        OperationOrder operationOrder = request.getContext().asType(OperationOrder.class);
        OperationOrderRepository operationOrderRepo = Beans.get(OperationOrderRepository.class);
        OperationOrderWorkflowService operationOrderWorkflowService = Beans.get(OperationOrderWorkflowService.class);
        operationOrder = operationOrderRepo.find(operationOrder.getId());
        if (operationOrder != null && operationOrder.getStatusSelect() == OperationOrderRepository.STATUS_PLANNED) {
            operationOrder = operationOrderWorkflowService.replan(operationOrder);
            List<OperationOrder> operationOrderList = operationOrderRepo.all().filter("self.manufOrder = ?1 AND self.priority >= ?2 AND self.statusSelect = 3 AND self.id != ?3", operationOrder.getManufOrder(), operationOrder.getPriority(), operationOrder.getId()).order("priority").order("plannedEndDateT").fetch();
            for (OperationOrder operationOrderIt : operationOrderList) {
                operationOrderWorkflowService.replan(operationOrderIt);
            }
            response.setReload(true);
        }
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : OperationOrderWorkflowService(com.axelor.apps.production.service.operationorder.OperationOrderWorkflowService) OperationOrderRepository(com.axelor.apps.production.db.repo.OperationOrderRepository) OperationOrder(com.axelor.apps.production.db.OperationOrder) BirtException(org.eclipse.birt.core.exception.BirtException) IOException(java.io.IOException)

Example 29 with OperationOrder

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

the class OperationOrderController method resume.

public void resume(ActionRequest request, ActionResponse response) {
    try {
        OperationOrder operationOrder = request.getContext().asType(OperationOrder.class);
        operationOrder = Beans.get(OperationOrderRepository.class).find(operationOrder.getId());
        Beans.get(ManufOrderWorkflowService.class).resume(operationOrder.getManufOrder());
        response.setReload(true);
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : ManufOrderWorkflowService(com.axelor.apps.production.service.manuforder.ManufOrderWorkflowService) OperationOrder(com.axelor.apps.production.db.OperationOrder) BirtException(org.eclipse.birt.core.exception.BirtException) IOException(java.io.IOException)

Example 30 with OperationOrder

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

the class OperationOrderController method partialFinish.

public void partialFinish(ActionRequest request, ActionResponse response) {
    try {
        OperationOrder operationOrder = request.getContext().asType(OperationOrder.class);
        operationOrder = Beans.get(OperationOrderRepository.class).find(operationOrder.getId());
        Beans.get(OperationOrderStockMoveService.class).partialFinish(operationOrder);
        response.setReload(true);
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : OperationOrder(com.axelor.apps.production.db.OperationOrder) OperationOrderStockMoveService(com.axelor.apps.production.service.operationorder.OperationOrderStockMoveService) BirtException(org.eclipse.birt.core.exception.BirtException) IOException(java.io.IOException)

Aggregations

OperationOrder (com.axelor.apps.production.db.OperationOrder)44 Transactional (com.google.inject.persist.Transactional)24 IOException (java.io.IOException)12 BirtException (org.eclipse.birt.core.exception.BirtException)11 OperationOrderWorkflowService (com.axelor.apps.production.service.operationorder.OperationOrderWorkflowService)10 AxelorException (com.axelor.exception.AxelorException)9 BigDecimal (java.math.BigDecimal)9 OperationOrderRepository (com.axelor.apps.production.db.repo.OperationOrderRepository)8 AppProductionService (com.axelor.apps.production.service.app.AppProductionService)7 LocalDateTime (java.time.LocalDateTime)7 ArrayList (java.util.ArrayList)6 ManufOrder (com.axelor.apps.production.db.ManufOrder)5 Company (com.axelor.apps.base.db.Company)4 ProdProduct (com.axelor.apps.production.db.ProdProduct)4 StockMove (com.axelor.apps.stock.db.StockMove)4 StockMoveLine (com.axelor.apps.stock.db.StockMoveLine)4 DayPlanning (com.axelor.apps.base.db.DayPlanning)3 ProdProcessLine (com.axelor.apps.production.db.ProdProcessLine)3 ManufOrderStockMoveService (com.axelor.apps.production.service.manuforder.ManufOrderStockMoveService)3 ProductionOrderService (com.axelor.apps.production.service.productionorder.ProductionOrderService)3