use of com.axelor.apps.base.service.administration.AbstractBatch.FETCH_LIMIT in project axelor-open-suite by axelor.
the class AccountingCutOffServiceImpl method getStockMoveLines.
public List<Long> getStockMoveLines(Batch batch) {
int offset = 0;
Boolean includeNotStockManagedProduct = batch.getSupplychainBatch().getIncludeNotStockManagedProduct();
List<StockMoveLine> stockMoveLineList;
List<Long> stockMoveLineIdList = new ArrayList<>();
Query<StockMove> stockMoveQuery = stockMoverepository.all().filter(":batch MEMBER OF self.batchSet").bind("batch", batch);
List<Long> stockMoveIdList = stockMoveQuery.select("id").fetch(0, 0).stream().map(m -> (Long) m.get("id")).collect(Collectors.toList());
if (stockMoveIdList.isEmpty()) {
stockMoveLineIdList.add(0L);
} else {
Query<StockMoveLine> stockMoveLineQuery = stockMoveLineRepository.all().filter("self.stockMove.id IN :stockMoveIdList").bind("stockMoveIdList", stockMoveIdList).order("id");
while (!(stockMoveLineList = stockMoveLineQuery.fetch(FETCH_LIMIT, offset)).isEmpty()) {
offset += stockMoveLineList.size();
for (StockMoveLine stockMoveLine : stockMoveLineList) {
Product product = stockMoveLine.getProduct();
if (!checkStockMoveLine(stockMoveLine, product, includeNotStockManagedProduct)) {
stockMoveLineIdList.add(stockMoveLine.getId());
}
}
JPA.clear();
}
}
return stockMoveLineIdList;
}
Aggregations