Search in sources :

Example 31 with OperationOrder

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

the class OperationOrderController method plan.

public void plan(ActionRequest request, ActionResponse response) {
    try {
        OperationOrder operationOrder = request.getContext().asType(OperationOrder.class);
        if (operationOrder.getManufOrder() != null && operationOrder.getManufOrder().getStatusSelect() < ManufOrderRepository.STATUS_PLANNED) {
            return;
        }
        Beans.get(OperationOrderWorkflowService.class).plan(Beans.get(OperationOrderRepository.class).find(operationOrder.getId()), null);
        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 32 with OperationOrder

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

the class OperationOrderController method pause.

public void pause(ActionRequest request, ActionResponse response) {
    try {
        OperationOrder operationOrder = request.getContext().asType(OperationOrder.class);
        operationOrder = Beans.get(OperationOrderRepository.class).find(operationOrder.getId());
        Beans.get(OperationOrderWorkflowService.class).pause(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 33 with OperationOrder

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

the class OperationOrderController method updateConsumedStockMoveFromOperationOrder.

/**
 * Called from operation order form, on consumed stock move line change.
 *
 * @param request
 * @param response
 */
public void updateConsumedStockMoveFromOperationOrder(ActionRequest request, ActionResponse response) {
    try {
        OperationOrder operationOrder = request.getContext().asType(OperationOrder.class);
        operationOrder = Beans.get(OperationOrderRepository.class).find(operationOrder.getId());
        Beans.get(OperationOrderService.class).updateConsumedStockMoveFromOperationOrder(operationOrder);
        response.setReload(true);
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : OperationOrderService(com.axelor.apps.production.service.operationorder.OperationOrderService) OperationOrder(com.axelor.apps.production.db.OperationOrder) BirtException(org.eclipse.birt.core.exception.BirtException) IOException(java.io.IOException)

Example 34 with OperationOrder

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

the class OperationOrderWorkflowService method manageDurationWithMachinePlanning.

@Transactional
public void manageDurationWithMachinePlanning(OperationOrder operationOrder, WeeklyPlanning weeklyPlanning, Long duration) throws AxelorException {
    LocalDateTime startDate = operationOrder.getPlannedStartDateT();
    LocalDateTime endDate = operationOrder.getPlannedEndDateT();
    DayPlanning dayPlanning = weeklyPlanningService.findDayPlanning(weeklyPlanning, startDate.toLocalDate());
    if (dayPlanning != null) {
        LocalTime firstPeriodFrom = dayPlanning.getMorningFrom();
        LocalTime firstPeriodTo = dayPlanning.getMorningTo();
        LocalTime secondPeriodFrom = dayPlanning.getAfternoonFrom();
        LocalTime secondPeriodTo = dayPlanning.getAfternoonTo();
        LocalTime startDateTime = startDate.toLocalTime();
        LocalTime endDateTime = endDate.toLocalTime();
        /*
       * If operation begins inside one period of the machine but finished after that period, then
       * we split the operation
       */
        if (firstPeriodTo != null && startDateTime.isBefore(firstPeriodTo) && endDateTime.isAfter(firstPeriodTo)) {
            LocalDateTime plannedEndDate = startDate.toLocalDate().atTime(firstPeriodTo);
            Long plannedDuration = DurationTool.getSecondsDuration(Duration.between(startDate, plannedEndDate));
            operationOrder.setPlannedDuration(plannedDuration);
            operationOrder.setPlannedEndDateT(plannedEndDate);
            operationOrderRepo.save(operationOrder);
            OperationOrder otherOperationOrder = JPA.copy(operationOrder, true);
            otherOperationOrder.setPlannedStartDateT(plannedEndDate);
            if (secondPeriodFrom != null) {
                otherOperationOrder.setPlannedStartDateT(startDate.toLocalDate().atTime(secondPeriodFrom));
            } else {
                this.searchForNextWorkingDay(otherOperationOrder, weeklyPlanning, plannedEndDate);
            }
            operationOrderRepo.save(otherOperationOrder);
            this.plan(otherOperationOrder, operationOrder.getPlannedDuration());
        }
    }
}
Also used : LocalDateTime(java.time.LocalDateTime) LocalTime(java.time.LocalTime) DayPlanning(com.axelor.apps.base.db.DayPlanning) OperationOrder(com.axelor.apps.production.db.OperationOrder) Transactional(com.google.inject.persist.Transactional)

Example 35 with OperationOrder

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

the class OperationOrderWorkflowService method resetPlannedDates.

/**
 * Reset the planned dates from the specified operation order list.
 *
 * @param operationOrderList
 * @return
 */
@Transactional
public List<OperationOrder> resetPlannedDates(List<OperationOrder> operationOrderList) {
    for (OperationOrder operationOrder : operationOrderList) {
        operationOrder.setPlannedStartDateT(null);
        operationOrder.setPlannedEndDateT(null);
        operationOrder.setPlannedDuration(null);
    }
    return operationOrderList;
}
Also used : OperationOrder(com.axelor.apps.production.db.OperationOrder) Transactional(com.google.inject.persist.Transactional)

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