Search in sources :

Example 6 with SequenceService

use of com.axelor.apps.base.service.administration.SequenceService in project axelor-open-suite by axelor.

the class DepositSlipAccountRepository method setDepositNumber.

private void setDepositNumber(DepositSlip entity) throws AxelorException {
    SequenceService sequenceService = Beans.get(SequenceService.class);
    String depositNumber = sequenceService.getSequenceNumber(SequenceRepository.DEPOSIT_SLIP, entity.getCompany());
    if (Strings.isNullOrEmpty(depositNumber)) {
        throw new AxelorException(Sequence.class, TraceBackRepository.CATEGORY_NO_VALUE, I18n.get(IExceptionMessage.DEPOSIT_SLIP_MISSING_SEQUENCE), entity.getCompany().getName());
    }
    entity.setDepositNumber(depositNumber);
}
Also used : AxelorException(com.axelor.exception.AxelorException) SequenceService(com.axelor.apps.base.service.administration.SequenceService)

Example 7 with SequenceService

use of com.axelor.apps.base.service.administration.SequenceService in project axelor-open-suite by axelor.

the class ReconcileSequenceService method getSequence.

protected String getSequence(Reconcile reconcile) throws AxelorException {
    SequenceService sequenceService = Beans.get(SequenceService.class);
    String seq = sequenceService.getSequenceNumber(SequenceRepository.RECONCILE, reconcile.getDebitMoveLine().getMove().getCompany());
    if (seq == null) {
        throw new AxelorException(TraceBackRepository.CATEGORY_CONFIGURATION_ERROR, I18n.get(IExceptionMessage.RECONCILE_6), I18n.get(com.axelor.apps.base.exceptions.IExceptionMessage.EXCEPTION), reconcile.getCompany().getName());
    }
    return seq;
}
Also used : AxelorException(com.axelor.exception.AxelorException) SequenceService(com.axelor.apps.base.service.administration.SequenceService)

Example 8 with SequenceService

use of com.axelor.apps.base.service.administration.SequenceService in project axelor-open-suite by axelor.

the class ManufOrderWorkflowService method plan.

@Transactional(rollbackOn = { AxelorException.class, Exception.class })
public List<ManufOrder> plan(List<ManufOrder> manufOrderList, boolean quickSolve) throws AxelorException {
    ManufOrderService manufOrderService = Beans.get(ManufOrderService.class);
    SequenceService sequenceService = Beans.get(SequenceService.class);
    for (ManufOrder manufOrder : manufOrderList) {
        if (manufOrder.getBillOfMaterial().getStatusSelect() != BillOfMaterialRepository.STATUS_APPLICABLE || manufOrder.getProdProcess().getStatusSelect() != ProdProcessRepository.STATUS_APPLICABLE) {
            throw new AxelorException(manufOrder, TraceBackRepository.CATEGORY_INCONSISTENCY, I18n.get(IExceptionMessage.CHECK_BOM_AND_PROD_PROCESS));
        }
        if (sequenceService.isEmptyOrDraftSequenceNumber(manufOrder.getManufOrderSeq())) {
            manufOrder.setManufOrderSeq(manufOrderService.getManufOrderSeq(manufOrder));
        }
        if (CollectionUtils.isEmpty(manufOrder.getOperationOrderList())) {
            manufOrderService.preFillOperations(manufOrder);
        } else {
            manufOrderService.updateOperationsName(manufOrder);
        }
        if (!manufOrder.getIsConsProOnOperation() && CollectionUtils.isEmpty(manufOrder.getToConsumeProdProductList())) {
            manufOrderService.createToConsumeProdProductList(manufOrder);
        }
        if (CollectionUtils.isEmpty(manufOrder.getToProduceProdProductList())) {
            manufOrderService.createToProduceProdProductList(manufOrder);
        }
        if (manufOrder.getPlannedStartDateT() == null && manufOrder.getPlannedEndDateT() == null) {
            manufOrder.setPlannedStartDateT(Beans.get(AppProductionService.class).getTodayDateTime().toLocalDateTime());
        } else if (manufOrder.getPlannedStartDateT() == null && manufOrder.getPlannedEndDateT() != null) {
            long duration = 0;
            for (OperationOrder order : manufOrder.getOperationOrderList()) {
                duration += operationOrderWorkflowService.computeEntireCycleDuration(order, // in seconds
                order.getManufOrder().getQty());
            }
            manufOrder.setPlannedStartDateT(manufOrder.getPlannedEndDateT().minusSeconds(duration));
        }
    }
    for (ManufOrder manufOrder : manufOrderList) {
        if (manufOrder.getOperationOrderList() != null) {
            for (OperationOrder operationOrder : getSortedOperationOrderList(manufOrder)) {
                operationOrderWorkflowService.plan(operationOrder, null);
            }
        }
    }
    for (ManufOrder manufOrder : manufOrderList) {
        if (manufOrder.getPlannedEndDateT() == null) {
            manufOrder.setPlannedEndDateT(this.computePlannedEndDateT(manufOrder));
        }
        if (manufOrder.getBillOfMaterial() != null) {
            manufOrder.setUnit(manufOrder.getBillOfMaterial().getUnit());
        }
        if (!manufOrder.getIsConsProOnOperation()) {
            manufOrderStockMoveService.createToConsumeStockMove(manufOrder);
        }
        manufOrderStockMoveService.createToProduceStockMove(manufOrder);
        manufOrder.setStatusSelect(ManufOrderRepository.STATUS_PLANNED);
        manufOrder.setCancelReason(null);
        manufOrder.setCancelReasonStr(null);
        manufOrderRepo.save(manufOrder);
        Beans.get(ProductionOrderService.class).updateStatus(manufOrder.getProductionOrderSet());
    }
    return manufOrderList;
}
Also used : AxelorException(com.axelor.exception.AxelorException) SequenceService(com.axelor.apps.base.service.administration.SequenceService) ProductionOrderService(com.axelor.apps.production.service.productionorder.ProductionOrderService) OperationOrder(com.axelor.apps.production.db.OperationOrder) ManufOrder(com.axelor.apps.production.db.ManufOrder) AppProductionService(com.axelor.apps.production.service.app.AppProductionService) Transactional(com.google.inject.persist.Transactional)

Aggregations

SequenceService (com.axelor.apps.base.service.administration.SequenceService)8 AxelorException (com.axelor.exception.AxelorException)7 Inventory (com.axelor.apps.stock.db.Inventory)2 Transactional (com.google.inject.persist.Transactional)2 PersistenceException (javax.persistence.PersistenceException)2 ManufOrder (com.axelor.apps.production.db.ManufOrder)1 OperationOrder (com.axelor.apps.production.db.OperationOrder)1 AppProductionService (com.axelor.apps.production.service.app.AppProductionService)1 ProductionOrderService (com.axelor.apps.production.service.productionorder.ProductionOrderService)1 StockLocation (com.axelor.apps.stock.db.StockLocation)1 StockMove (com.axelor.apps.stock.db.StockMove)1 IOException (java.io.IOException)1 NoResultException (javax.persistence.NoResultException)1 BirtException (org.eclipse.birt.core.exception.BirtException)1