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