[serveur] Ajout d'un tableau de commande pour la cuisine

This commit is contained in:
2018-02-05 16:49:20 +01:00
parent f9fd2094c9
commit 0f35c8eff5
89860 changed files with 347134 additions and 49 deletions

View File

@@ -35,5 +35,22 @@ public enum MessageType {
ACK_PING,
QUERY_CONFIG_LIST,
MSG_CONFIG_LIST
MSG_CONFIG_LIST,
// no fields, permission at least Waiter
QUERY_SIMPLIFIED_PRODUCT_LIST,
ACK_SIMPLIFIED_PRODUCT_LIST,
// no fields, permission at least Waiter
QUERY_SERVING_LIST,
ACK_SERVING_LIST,
// fields (sale), permission at least Waiter
QUERY_SERVING_DONE,
ACK_SERVING_DONE,
// no fields, permission at least Waiter
QUERY_SERVING_VERSION,
ACK_SERVING_VERSION
}

View File

@@ -0,0 +1,31 @@
package com.pqt.core.entities.product;
/**
* Cette version de produit a pour but de communiquer avec une interface en javascript
* Le javascript ne supporte pas les long, ils sont donc remplacés ici par des String
* On se moque également ici de la catégorie puisque c'est destiné au panneau d'affichage en cuisine
*/
public class SimplifiedProduct {
private String id;
private String name;
public SimplifiedProduct() {}
public SimplifiedProduct(LightweightProduct product){
this.id = String.valueOf(product.getId());
this.name = product.getName();
}
public SimplifiedProduct(Product product){
this(new LightweightProduct(product));
}
public String getId() {
return id;
}
public String getName() {
return name;
}
}

View File

@@ -14,6 +14,7 @@ public class LightweightSale {
private int id;
private Map<Long, Integer> products;
private Map<Long, Boolean> serving;
private Client orderedWith;
private Account orderedBy;
private Account orderedFor;
@@ -29,9 +30,11 @@ public class LightweightSale {
this.orderedFor = sale.getOrderedFor();
this.type = sale.getType();
this.status = sale.getStatus();
serving = new HashMap<>();
products = new HashMap<>();
for(Product product : sale.getProducts().keySet()){
products.put(product.getId(), sale.getProducts().get(product));
serving.put(product.getId(), sale.getServing().get(product));
}
price = sale.getTotalPrice();
worth = sale.getTotalWorth();
@@ -109,6 +112,10 @@ public class LightweightSale {
this.worth = worth;
}
public Map<Long, Boolean> getServing() {
return serving;
}
@Override
public int hashCode() {
return Objects.hash(id, products, orderedBy, orderedFor, orderedWith, type);

View File

@@ -7,6 +7,7 @@ import com.pqt.core.entities.user_account.Account;
import java.io.Serializable;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
@@ -17,6 +18,7 @@ public class Sale implements ILoggable, Serializable{
private int id;
private Map<Product, Integer> products;
private Map<Product, Boolean> serving;
private Client orderedWith;
private Account orderedBy;
private Account orderedFor;
@@ -28,12 +30,23 @@ public class Sale implements ILoggable, Serializable{
public Sale(int id, Map<Product, Integer> products, Client orderedWith, Account orderedBy, Account orderedFor, SaleType type, SaleStatus status) {
this.id = id;
this.products = products;
this.orderedWith = orderedWith;
this.orderedBy = orderedBy;
this.orderedFor = orderedFor;
this.type = type;
this.status = status;
setProducts(products);
}
public Sale(int id, Map<Product, Integer> products, Client orderedWith, Account orderedBy, Account orderedFor, SaleType type, SaleStatus status, Map<Product, Boolean> serving) {
this.id = id;
this.orderedWith = orderedWith;
this.orderedBy = orderedBy;
this.orderedFor = orderedFor;
this.type = type;
this.status = status;
this.products = products;
this.serving = serving;
}
public int getId() {
@@ -49,7 +62,20 @@ public class Sale implements ILoggable, Serializable{
}
public void setProducts(Map<Product, Integer> products) {
serving = new HashMap<>();
this.products = products;
for (Product prod: this.products.keySet()){
serving.put(prod, false);
}
}
public boolean isAllServed(){
for (Product prod: serving.keySet()){
if (!serving.get(prod)){
return false;
}
}
return true;
}
public Client getOrderedWith() {
@@ -127,4 +153,8 @@ public class Sale implements ILoggable, Serializable{
}
return totalWorth;
}
public Map<Product, Boolean> getServing() {
return serving;
}
}

View File

@@ -0,0 +1,29 @@
package com.pqt.core.entities.sale;
import java.util.Map;
public class SaleEdit {
private int id;
private Map<Long, Boolean> products;
public SaleEdit(int id, Map<Long, Boolean> products) {
this.id = id;
this.products = products;
}
public int getId() {
return id;
}
@Override
public String toString() {
return "SaleEdit{" +
"id=" + id +
", products=" + products +
'}';
}
public Map<Long, Boolean> getProducts() {
return products;
}
}

View File

@@ -5,7 +5,7 @@ package com.pqt.core.entities.sale;
*/
public enum SaleStatus {
PENDING(0), REFUSED(1), ACCEPTED(2), ABORTED(3);
PENDING(0), REFUSED(1), ACCEPTED(2), ABORTED(3), SERVICE_PENDING(4);
private int id;