Search in sources :

Example 1 with ManufOrderService

use of com.axelor.apps.production.service.manuforder.ManufOrderService in project axelor-open-suite by axelor.

the class ManufOrderWorkFlowMaintenanceService method plan.

@Transactional(rollbackOn = { Exception.class })
@Override
public ManufOrder plan(ManufOrder manufOrder) throws AxelorException {
    if (manufOrder.getTypeSelect() != ManufOrderRepository.TYPE_MAINTENANCE) {
        return super.plan(manufOrder);
    }
    ManufOrderService manufOrderService = Beans.get(ManufOrderService.class);
    if (Beans.get(SequenceService.class).isEmptyOrDraftSequenceNumber(manufOrder.getManufOrderSeq())) {
        manufOrder.setManufOrderSeq(manufOrderService.getManufOrderSeq(manufOrder));
    }
    if (CollectionUtils.isEmpty(manufOrder.getOperationOrderList())) {
        manufOrderService.preFillOperations(manufOrder);
    }
    if (!manufOrder.getIsConsProOnOperation() && CollectionUtils.isEmpty(manufOrder.getToConsumeProdProductList())) {
        manufOrderService.createToConsumeProdProductList(manufOrder);
    }
    if (CollectionUtils.isEmpty(manufOrder.getToProduceProdProductList())) {
        manufOrderService.createToProduceProdProductList(manufOrder);
    }
    if (manufOrder.getPlannedStartDateT() == null) {
        manufOrder.setPlannedStartDateT(Beans.get(AppProductionService.class).getTodayDateTime().toLocalDateTime());
    }
    for (OperationOrder operationOrder : getSortedOperationOrderList(manufOrder)) {
        operationOrderWorkflowService.plan(operationOrder, null);
    }
    manufOrder.setPlannedEndDateT(this.computePlannedEndDateT(manufOrder));
    if (manufOrder.getBillOfMaterial() != null) {
        manufOrder.setUnit(manufOrder.getBillOfMaterial().getUnit());
    }
    manufOrder.setStatusSelect(ManufOrderRepository.STATUS_PLANNED);
    manufOrder.setCancelReason(null);
    manufOrder.setCancelReasonStr(null);
    return manufOrderRepo.save(manufOrder);
}
Also used : ManufOrderService(com.axelor.apps.production.service.manuforder.ManufOrderService) SequenceService(com.axelor.apps.base.service.administration.SequenceService) OperationOrder(com.axelor.apps.production.db.OperationOrder) AppProductionService(com.axelor.apps.production.service.app.AppProductionService) Transactional(com.google.inject.persist.Transactional)

Example 2 with ManufOrderService

use of com.axelor.apps.production.service.manuforder.ManufOrderService in project axelor-open-suite by axelor.

the class ManufOrderController method updateRealQty.

/**
 * Called from manuf order wizard view. Call {@link ManufOrderService#updateRealQty(ManufOrder,
 * BigDecimal)}
 *
 * @param request
 * @param response
 */
public void updateRealQty(ActionRequest request, ActionResponse response) {
    try {
        ManufOrder manufOrder = request.getContext().asType(ManufOrder.class);
        manufOrder = Beans.get(ManufOrderRepository.class).find(manufOrder.getId());
        BigDecimal qtyToUpdate = new BigDecimal(request.getContext().get("qtyToUpdate").toString());
        Beans.get(ManufOrderService.class).updateRealQty(manufOrder, qtyToUpdate);
        response.setReload(true);
        response.setCanClose(true);
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : ManufOrderService(com.axelor.apps.production.service.manuforder.ManufOrderService) BigDecimal(java.math.BigDecimal) BirtException(org.eclipse.birt.core.exception.BirtException) AxelorException(com.axelor.exception.AxelorException) IOException(java.io.IOException) ManufOrder(com.axelor.apps.production.db.ManufOrder)

Example 3 with ManufOrderService

use of com.axelor.apps.production.service.manuforder.ManufOrderService in project axelor-open-suite by axelor.

the class ManufOrderController method updateProducedStockMoveFromManufOrder.

/**
 * Called from manuf order form, on produced stock move line change. Call {@link
 * ManufOrderService#updateProducedStockMoveFromManufOrder(ManufOrder)}.
 *
 * @param request
 * @param response
 */
public void updateProducedStockMoveFromManufOrder(ActionRequest request, ActionResponse response) {
    try {
        ManufOrder manufOrder = request.getContext().asType(ManufOrder.class);
        manufOrder = Beans.get(ManufOrderRepository.class).find(manufOrder.getId());
        Beans.get(ManufOrderService.class).updateProducedStockMoveFromManufOrder(manufOrder);
        response.setReload(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)

Example 4 with ManufOrderService

use of com.axelor.apps.production.service.manuforder.ManufOrderService in project axelor-open-suite by axelor.

the class ManufOrderController method checkProducedStockMoveLineList.

/**
 * Called from manuf order form, on produced stock move line change. Call {@link
 * ManufOrderService#checkProducedStockMoveLineList(ManufOrder, ManufOrder)}.
 *
 * @param request
 * @param response
 */
public void checkProducedStockMoveLineList(ActionRequest request, ActionResponse response) {
    try {
        ManufOrder manufOrder = request.getContext().asType(ManufOrder.class);
        ManufOrder oldManufOrder = Beans.get(ManufOrderRepository.class).find(manufOrder.getId());
        Beans.get(ManufOrderService.class).checkProducedStockMoveLineList(manufOrder, oldManufOrder);
    } catch (Exception e) {
        TraceBackService.trace(response, e);
        response.setReload(true);
    }
}
Also used : ManufOrderService(com.axelor.apps.production.service.manuforder.ManufOrderService) ManufOrderRepository(com.axelor.apps.production.db.repo.ManufOrderRepository) BirtException(org.eclipse.birt.core.exception.BirtException) AxelorException(com.axelor.exception.AxelorException) IOException(java.io.IOException) ManufOrder(com.axelor.apps.production.db.ManufOrder)

Example 5 with ManufOrderService

use of com.axelor.apps.production.service.manuforder.ManufOrderService in project axelor-open-suite by axelor.

the class ManufOrderController method updateConsumedStockMoveFromManufOrder.

/**
 * Called from manuf order form, on consumed stock move line change. Call {@link
 * ManufOrderService#updateConsumedStockMoveFromManufOrder(ManufOrder)}.
 *
 * @param request
 * @param response
 */
public void updateConsumedStockMoveFromManufOrder(ActionRequest request, ActionResponse response) {
    try {
        ManufOrder manufOrder = request.getContext().asType(ManufOrder.class);
        manufOrder = Beans.get(ManufOrderRepository.class).find(manufOrder.getId());
        Beans.get(ManufOrderService.class).updateConsumedStockMoveFromManufOrder(manufOrder);
        response.setReload(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

ManufOrderService (com.axelor.apps.production.service.manuforder.ManufOrderService)8 ManufOrder (com.axelor.apps.production.db.ManufOrder)7 AxelorException (com.axelor.exception.AxelorException)7 IOException (java.io.IOException)7 BirtException (org.eclipse.birt.core.exception.BirtException)7 ManufOrderRepository (com.axelor.apps.production.db.repo.ManufOrderRepository)2 SequenceService (com.axelor.apps.base.service.administration.SequenceService)1 OperationOrder (com.axelor.apps.production.db.OperationOrder)1 AppProductionService (com.axelor.apps.production.service.app.AppProductionService)1 Transactional (com.google.inject.persist.Transactional)1 BigDecimal (java.math.BigDecimal)1