Small changes according to comments on the pullrequest
This commit is contained in:
parent
e1df56147b
commit
d5540c1979
|
@ -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<WarehouseBookingPositionSlotEntry> inStock;
|
||||
private int amountInStock;
|
||||
private HashMap<ArticleIdentifier, Offer> cheapestOffer;
|
||||
private HashMap<ArticleIdentifier, ArticleOffer> articleOffers;
|
||||
|
||||
public ReorderAction(
|
||||
Article article, Integer[] orderedAmounts,
|
||||
Integer undeliveredReorders,
|
||||
List<WarehouseBookingPositionSlotEntry> inStock,
|
||||
int amountInStock,
|
||||
HashMap<ArticleIdentifier, Offer> cheapestOffer,
|
||||
HashMap<ArticleIdentifier, ArticleOffer> 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() {
|
||||
|
|
|
@ -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<WarehouseBookingPositionSlotEntry> 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) {
|
||||
|
|
|
@ -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) {
|
||||
|
|
Reference in New Issue