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);
}
}
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);
}
}
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);
}
}
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());
}
}
}
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;
}
Aggregations