mirror of
https://github.com/klmp200/PQT_Gestionnaire_vente_stock.git
synced 2024-11-25 10:34:15 +00:00
[SERVEUR] #12 : Ajout d'un catch+print des exceptions lors de la composition des listes de stats; Correction du bug d'ordre des produits populaires; Correction du bug de valeur brutes des commandes du staff
This commit is contained in:
parent
611eb86f07
commit
ed02c20be0
@ -98,6 +98,7 @@ public class SimpleMessageHandler implements IMessageHandler {
|
||||
}, AccountLevel.WAITER);
|
||||
manager.supportForConnectedAccounts(MessageType.QUERY_STAT, (message)->{
|
||||
Map<String, String> fields = new HashMap<>();
|
||||
try{
|
||||
fields.put(StatisticFields.TOTAL_SALE_WORTH.getStr(), Double.toString(statisticsService.getTotalSaleWorth()));
|
||||
fields.put(StatisticFields.TOTAL_SALE_AMOUNT.getStr(), Integer.toString(statisticsService.getTotalAmountSale()));
|
||||
fields.put(StatisticFields.TOTAL_MONEY_MADE.getStr(), Double.toString(statisticsService.getTotalMoneyMade()));
|
||||
@ -106,7 +107,9 @@ public class SimpleMessageHandler implements IMessageHandler {
|
||||
fields.put(StatisticFields.STAFF_SALE_AMOUNT.getStr(), Integer.toString(statisticsService.getStaffSaleAmount()));
|
||||
fields.put(StatisticFields.GUEST_SALE_WORTH.getStr(), Double.toString(statisticsService.getGuestSaleWorth()));
|
||||
fields.put(StatisticFields.GUEST_SALE_AMOUNT.getStr(), Integer.toString(statisticsService.getGuestSaleAmount()));
|
||||
|
||||
}catch(Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
return new Message(MessageType.MSG_STAT, serverStateService.getServer(), message.getEmitter(), message.getUser(), message, fields);
|
||||
}, AccountLevel.WAITER);
|
||||
|
||||
|
@ -50,7 +50,7 @@ public class StatisticsService {
|
||||
break;
|
||||
case OFFERED_STAFF_MEMBER:
|
||||
staffSaleAmount++;
|
||||
staffSaleWorth+=price;
|
||||
staffSaleWorth+=worth;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -71,7 +71,7 @@ public class StatisticsService {
|
||||
|
||||
public List<LightweightProduct> getTopPopularProducts(int amount) {
|
||||
return stockService.getProductList().stream()
|
||||
.sorted(Comparator.comparingInt(Product::getAmountSold))
|
||||
.sorted((prod1, prod2)->prod2.getAmountSold()-prod1.getAmountSold())
|
||||
.limit(amount)
|
||||
.map(LightweightProduct::new)
|
||||
.collect(Collectors.toList());
|
||||
|
Loading…
Reference in New Issue
Block a user