Merge pull request 'Fix bad query for article slot sum' (#102) from feature/89_fix_lagerstand into master
This commit is contained in:
commit
ffea25c082
|
@ -173,8 +173,11 @@ class Reorder implements ICronjob {
|
|||
Integer undeliveredReorders = controller.supplierOrderRepository
|
||||
.countUndeliveredReorders(article.related.articleNumber);
|
||||
|
||||
int amountInStock = controller.warehouseBookingPositionSlotEntryRepository.getArticleStock(article.id)
|
||||
.orElse(0);
|
||||
int amountInStock = controller.warehouseBookingPositionSlotEntryRepository
|
||||
.getByArticle(article.id)
|
||||
.stream()
|
||||
.mapToInt(e -> e.newSumSlot)
|
||||
.sum();
|
||||
|
||||
ReorderAction action = new ReorderAction(article, orderedAmounts,
|
||||
undeliveredReorders,
|
||||
|
|
|
@ -53,7 +53,11 @@ public class InternArticleController {
|
|||
|
||||
for (Article article : articleRepository.findAll()) {
|
||||
UImodelArticles tmp = new UImodelArticles();
|
||||
tmp.addListedArticle(article, warehouseEntryRepository.getArticleStock(article.id).orElse(0));
|
||||
tmp.addListedArticle(article, warehouseEntryRepository
|
||||
.getByArticle(article.id)
|
||||
.stream()
|
||||
.mapToInt(e -> e.newSumSlot)
|
||||
.sum());
|
||||
totals.add(tmp);
|
||||
}
|
||||
|
||||
|
@ -63,10 +67,14 @@ public class InternArticleController {
|
|||
|
||||
@GetMapping("/{id}")
|
||||
public String internListedArticlesId(Model model, @PathVariable String id) {
|
||||
int articleid = Integer.parseInt(id);
|
||||
long articleId = Long.parseLong(id);
|
||||
UImodelArticle total = new UImodelArticle();
|
||||
total.addArticle(articleRepository.findArticleById(articleid),
|
||||
warehouseEntryRepository.getArticleStock(articleid).orElse(0));
|
||||
total.addArticle(
|
||||
articleRepository.findById(articleId).get(),
|
||||
warehouseEntryRepository.getByArticle(articleId)
|
||||
.stream()
|
||||
.mapToInt(e -> e.newSumSlot)
|
||||
.sum());
|
||||
|
||||
model.addAttribute("ArticleID", total);
|
||||
return "intern/listedArticles/id";
|
||||
|
|
|
@ -14,9 +14,6 @@ public interface WarehouseBookingPositionSlotEntryRepository extends JpaReposito
|
|||
@Query(value = "Select e.id, e.article_id, e.new_sum_slot, e.slot_id from warehouse_booking_position_entries as e, warehouse_slots as s where e.slot_id = s.id AND e.article_id = :article GROUP BY s.slot_num HAVING max(e.id)", nativeQuery = true)
|
||||
List<WarehouseBookingPositionSlotEntry> getByArticle(long article);
|
||||
|
||||
@Query(value = "SELECT SUM(w.new_sum_slot) FROM warehouse_booking_position_entries as w WHERE w.article_id = :articleid", nativeQuery = true)
|
||||
Optional<Integer> getArticleStock(long articleid);
|
||||
|
||||
@Query(value = "Select e.id, e.article_id, e.new_sum_slot, e.slot_id from warehouse_booking_position_entries as e, warehouse_slots as s where e.slot_id = s.id AND s.slot_num = :slotnum GROUP BY s.slot_num HAVING max(e.id)", nativeQuery = true)
|
||||
Optional<WarehouseBookingPositionSlotEntry> getBySlotNum(long slotnum);
|
||||
|
||||
|
|
Reference in New Issue