Search in sources :

Example 16 with OperationOrder

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

the class OperationOrderController method checkConsumedStockMoveLineList.

/**
 * Called from operation order form, on consumed stock move line change. Call {@link
 * OperationOrderService#checkConsumedStockMoveLineList(OperationOrder, OperationOrder)}
 *
 * @param request
 * @param response
 */
public void checkConsumedStockMoveLineList(ActionRequest request, ActionResponse response) {
    try {
        OperationOrder operationOrder = request.getContext().asType(OperationOrder.class);
        OperationOrder oldOperationOrder = Beans.get(OperationOrderRepository.class).find(operationOrder.getId());
        Beans.get(OperationOrderService.class).checkConsumedStockMoveLineList(operationOrder, oldOperationOrder);
    } catch (Exception e) {
        TraceBackService.trace(response, e);
        response.setReload(true);
    }
}
Also used : OperationOrderService(com.axelor.apps.production.service.operationorder.OperationOrderService) 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 17 with OperationOrder

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

the class OperationOrderController method setPlannedDates.

public void setPlannedDates(ActionRequest request, ActionResponse response) {
    OperationOrder operationOrder = request.getContext().asType(OperationOrder.class);
    LocalDateTime plannedStartDateT = operationOrder.getPlannedStartDateT();
    LocalDateTime plannedEndDateT = operationOrder.getPlannedEndDateT();
    operationOrder = Beans.get(OperationOrderRepository.class).find(operationOrder.getId());
    Beans.get(OperationOrderWorkflowService.class).setPlannedDates(operationOrder, plannedStartDateT, plannedEndDateT);
}
Also used : LocalDateTime(java.time.LocalDateTime) OperationOrderWorkflowService(com.axelor.apps.production.service.operationorder.OperationOrderWorkflowService) OperationOrder(com.axelor.apps.production.db.OperationOrder)

Example 18 with OperationOrder

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

the class OperationOrderController method start.

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

Example 19 with OperationOrder

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

the class StockMoveLineController method setProductInfo.

/**
 * Called from stock move line form. Fill product info using the company either from the stock
 * move line, from the parent stock move or the parent manuf order.
 *
 * @param request
 * @param response
 */
public void setProductInfo(ActionRequest request, ActionResponse response) {
    StockMoveLine stockMoveLine;
    try {
        stockMoveLine = request.getContext().asType(StockMoveLine.class);
        Company company;
        StockMove stockMove = stockMoveLine.getStockMove();
        if (stockMove == null) {
            Context parentContext = request.getContext().getParent();
            if (parentContext.getContextClass().equals(StockMove.class)) {
                stockMove = parentContext.asType(StockMove.class);
                company = stockMove.getCompany();
            } else if (parentContext.getContextClass().equals(ManufOrder.class)) {
                ManufOrder manufOrder = parentContext.asType(ManufOrder.class);
                company = manufOrder.getCompany();
            } else if (parentContext.getContextClass().equals(OperationOrder.class)) {
                OperationOrder operationOrder = parentContext.asType(OperationOrder.class);
                if (operationOrder.getManufOrder() == null) {
                    return;
                }
                company = operationOrder.getManufOrder().getCompany();
            } else {
                throw new AxelorException(TraceBackRepository.CATEGORY_INCONSISTENCY, IExceptionMessage.STOCK_MOVE_LINE_UNKNOWN_PARENT_CONTEXT);
            }
        } else {
            company = stockMove.getCompany();
        }
        if (stockMoveLine.getProduct() == null) {
            stockMoveLine = new StockMoveLine();
            response.setValues(Mapper.toMap(stockMoveLine));
            return;
        }
        Beans.get(StockMoveLineService.class).setProductInfo(stockMove, stockMoveLine, company);
        response.setValues(stockMoveLine);
    } catch (Exception e) {
        stockMoveLine = new StockMoveLine();
        response.setValues(Mapper.toMap(stockMoveLine));
        TraceBackService.trace(response, e);
    }
}
Also used : Context(com.axelor.rpc.Context) StockMoveLineService(com.axelor.apps.stock.service.StockMoveLineService) AxelorException(com.axelor.exception.AxelorException) Company(com.axelor.apps.base.db.Company) StockMove(com.axelor.apps.stock.db.StockMove) StockMoveLine(com.axelor.apps.stock.db.StockMoveLine) OperationOrder(com.axelor.apps.production.db.OperationOrder) AxelorException(com.axelor.exception.AxelorException) ManufOrder(com.axelor.apps.production.db.ManufOrder)

Example 20 with OperationOrder

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

the class OperationOrderTimesheetServiceImpl method updateAllRealDuration.

@Override
public void updateAllRealDuration(List<TimesheetLine> timesheetLineList) {
    if (timesheetLineList == null) {
        return;
    }
    List<OperationOrder> operationOrderList = timesheetLineList.stream().map(TimesheetLine::getOperationOrder).filter(Objects::nonNull).distinct().collect(Collectors.toList());
    OperationOrderWorkflowService operationOrderWorkflowService = Beans.get(OperationOrderWorkflowService.class);
    operationOrderList.forEach(operationOrderWorkflowService::updateRealDuration);
}
Also used : Objects(java.util.Objects) OperationOrderWorkflowService(com.axelor.apps.production.service.operationorder.OperationOrderWorkflowService) OperationOrder(com.axelor.apps.production.db.OperationOrder)

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