Fix bad query for article slot sum #102
|
@ -173,8 +173,11 @@ class Reorder implements ICronjob {
|
||||||
Integer undeliveredReorders = controller.supplierOrderRepository
|
Integer undeliveredReorders = controller.supplierOrderRepository
|
||||||
.countUndeliveredReorders(article.related.articleNumber);
|
.countUndeliveredReorders(article.related.articleNumber);
|
||||||
|
|
||||||
int amountInStock = controller.warehouseBookingPositionSlotEntryRepository.getArticleStock(article.id)
|
int amountInStock = controller.warehouseBookingPositionSlotEntryRepository
|
||||||
.orElse(0);
|
.getByArticle(article.id)
|
||||||
|
.stream()
|
||||||
|
.mapToInt(e -> e.newSumSlot)
|
||||||
|
.sum();
|
||||||
|
|
||||||
ReorderAction action = new ReorderAction(article, orderedAmounts,
|
ReorderAction action = new ReorderAction(article, orderedAmounts,
|
||||||
undeliveredReorders,
|
undeliveredReorders,
|
||||||
|
|
|
@ -53,7 +53,11 @@ public class InternArticleController {
|
||||||
|
|
||||||
for (Article article : articleRepository.findAll()) {
|
for (Article article : articleRepository.findAll()) {
|
||||||
UImodelArticles tmp = new UImodelArticles();
|
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);
|
totals.add(tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,10 +67,14 @@ public class InternArticleController {
|
||||||
|
|
||||||
@GetMapping("/{id}")
|
@GetMapping("/{id}")
|
||||||
public String internListedArticlesId(Model model, @PathVariable String id) {
|
public String internListedArticlesId(Model model, @PathVariable String id) {
|
||||||
int articleid = Integer.parseInt(id);
|
long articleId = Long.parseLong(id);
|
||||||
UImodelArticle total = new UImodelArticle();
|
UImodelArticle total = new UImodelArticle();
|
||||||
total.addArticle(articleRepository.findArticleById(articleid),
|
total.addArticle(
|
||||||
warehouseEntryRepository.getArticleStock(articleid).orElse(0));
|
articleRepository.findById(articleId).get(),
|
||||||
|
warehouseEntryRepository.getByArticle(articleId)
|
||||||
|
.stream()
|
||||||
|
.mapToInt(e -> e.newSumSlot)
|
||||||
|
.sum());
|
||||||
|
|
||||||
model.addAttribute("ArticleID", total);
|
model.addAttribute("ArticleID", total);
|
||||||
return "intern/listedArticles/id";
|
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)
|
@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);
|
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)
|
@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);
|
Optional<WarehouseBookingPositionSlotEntry> getBySlotNum(long slotnum);
|
||||||
|
|
||||||
|
|
Reference in New Issue