diff --git a/prototype/src/main/java/org/hso/ecommerce/action/cronjob/ReorderAction.java b/prototype/src/main/java/org/hso/ecommerce/action/cronjob/ReorderAction.java index 2bad0e0..23599d8 100644 --- a/prototype/src/main/java/org/hso/ecommerce/action/cronjob/ReorderAction.java +++ b/prototype/src/main/java/org/hso/ecommerce/action/cronjob/ReorderAction.java @@ -2,7 +2,6 @@ package org.hso.ecommerce.action.cronjob; import java.sql.Timestamp; import java.util.HashMap; -import java.util.List; import org.hso.ecommerce.action.cronjob.ReadSupplierDataAction.ArticleIdentifier; import org.hso.ecommerce.action.cronjob.ReadSupplierDataAction.Offer; @@ -12,7 +11,6 @@ import org.hso.ecommerce.api.data.OrderConfirmation; import org.hso.ecommerce.entities.shop.Article; import org.hso.ecommerce.entities.supplier.ArticleOffer; import org.hso.ecommerce.entities.supplier.SupplierOrder; -import org.hso.ecommerce.entities.warehouse.WarehouseBookingPositionSlotEntry; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -22,21 +20,21 @@ public class ReorderAction { private Article article; private Integer[] orderedAmounts; private Integer undeliveredReorders; - private List inStock; + private int amountInStock; private HashMap cheapestOffer; private HashMap articleOffers; public ReorderAction( Article article, Integer[] orderedAmounts, Integer undeliveredReorders, - List inStock, + int amountInStock, HashMap cheapestOffer, HashMap articleOffers ) { this.article = article; this.orderedAmounts = orderedAmounts; this.undeliveredReorders = undeliveredReorders; - this.inStock = inStock; + this.amountInStock = amountInStock; this.cheapestOffer = cheapestOffer; this.articleOffers = articleOffers; } @@ -45,14 +43,6 @@ public class ReorderAction { return input == null ? 0 : input; } - private int getAmountInStock() { - int sum = 0; - for (WarehouseBookingPositionSlotEntry entry : inStock) { - sum += entry.newSumSlot; - } - return sum; - } - private int calculateAmountToReorder() { // Algorithm as described in the documentation int a = null_to_zero(orderedAmounts[0]); @@ -68,11 +58,9 @@ public class ReorderAction { } int i = null_to_zero(undeliveredReorders); - int l = getAmountInStock(); + int l = amountInStock; - int o = n - i - l; - - return o; + return n - i - l; } public SupplierOrder finish() { diff --git a/prototype/src/main/java/org/hso/ecommerce/controller/cronjob/CronjobController.java b/prototype/src/main/java/org/hso/ecommerce/controller/cronjob/CronjobController.java index 143f1cf..e2bad65 100644 --- a/prototype/src/main/java/org/hso/ecommerce/controller/cronjob/CronjobController.java +++ b/prototype/src/main/java/org/hso/ecommerce/controller/cronjob/CronjobController.java @@ -24,7 +24,6 @@ import org.hso.ecommerce.entities.shop.Article; import org.hso.ecommerce.entities.supplier.ArticleOffer; import org.hso.ecommerce.entities.supplier.Supplier; import org.hso.ecommerce.entities.supplier.SupplierOrder; -import org.hso.ecommerce.entities.warehouse.WarehouseBookingPositionSlotEntry; import org.hso.ecommerce.repos.booking.BookingAccountEntryRepository; import org.hso.ecommerce.repos.booking.BookingRepository; import org.hso.ecommerce.repos.cronjob.BackgroundJobRepository; @@ -68,8 +67,6 @@ interface ICronjob { @Component class Reorder implements ICronjob { - private static final Logger log = LoggerFactory.getLogger(Reorder.class); - @Override public Calendar nextExecution(Calendar reference) { if (reference.get(Calendar.HOUR_OF_DAY) >= 8) { @@ -162,12 +159,12 @@ class Reorder implements ICronjob { Integer undeliveredReorders = controller.supplierOrderRepository .countUndeliveredReorders(article.related.articleNumber); - List inStock = controller.warehouseBookingPositionSlotEntryRepository - .getByArticle(article.id); + int amountInStock = controller.warehouseBookingPositionSlotEntryRepository.getArticleStock(article.id) + .orElse(0); ReorderAction action = new ReorderAction(article, orderedAmounts, undeliveredReorders, - inStock, + amountInStock, supplierData.cheapestOffer, mappedOffers); SupplierOrder order = action.finish(); if (order != null) { diff --git a/supplier/src/main/java/org/hso/ecommerce/supplier/ConfigurationReader.java b/supplier/src/main/java/org/hso/ecommerce/supplier/ConfigurationReader.java index f4e4e20..79782d6 100644 --- a/supplier/src/main/java/org/hso/ecommerce/supplier/ConfigurationReader.java +++ b/supplier/src/main/java/org/hso/ecommerce/supplier/ConfigurationReader.java @@ -25,7 +25,7 @@ public class ConfigurationReader { try { String jsonData = Files.readString(path, StandardCharsets.UTF_8); ObjectMapper objectMapper = new ObjectMapper(); - Supplier sup = (Supplier)objectMapper.readValue(jsonData, Supplier.class); + Supplier sup = objectMapper.readValue(jsonData, Supplier.class); System.out.println("Loaded " + sup.id); return sup; } catch (IOException e) {