| Line 1... |
Line 1... |
| 1 |
package in.shop2020.support.controllers;
|
1 |
package in.shop2020.support.controllers;
|
| 2 |
|
2 |
|
| 3 |
import java.util.List;
|
3 |
import java.util.List;
|
| 4 |
import java.util.ArrayList;
|
- |
|
| 5 |
import java.util.HashMap;
|
4 |
import java.util.HashMap;
|
| 6 |
import java.util.Map;
|
5 |
import java.util.Map;
|
| 7 |
|
6 |
|
| 8 |
import in.shop2020.model.v1.catalog.InventoryService.Client;
|
7 |
import in.shop2020.model.v1.catalog.InventoryService.Client;
|
| 9 |
import in.shop2020.model.v1.catalog.Warehouse;
|
8 |
import in.shop2020.model.v1.catalog.Warehouse;
|
| 10 |
import in.shop2020.support.models.InventoryUpdate;
|
9 |
import in.shop2020.support.models.InventoryUpdate;
|
| 11 |
import in.shop2020.support.models.Update;
|
10 |
import in.shop2020.support.models.Update;
|
| 12 |
import in.shop2020.thrift.clients.CatalogServiceClient;
|
11 |
import in.shop2020.thrift.clients.CatalogServiceClient;
|
| 13 |
|
12 |
|
| 14 |
import org.apache.commons.collections.map.HashedMap;
|
- |
|
| 15 |
import org.apache.struts2.rest.DefaultHttpHeaders;
|
13 |
import org.apache.struts2.rest.DefaultHttpHeaders;
|
| 16 |
import org.apache.struts2.rest.HttpHeaders;
|
14 |
import org.apache.struts2.rest.HttpHeaders;
|
| 17 |
import com.opensymphony.xwork2.ModelDriven;
|
15 |
import com.opensymphony.xwork2.ModelDriven;
|
| 18 |
|
16 |
|
| 19 |
public class UpdatesController implements ModelDriven<Object>{
|
17 |
public class UpdatesController implements ModelDriven<Object>{
|
| Line 65... |
Line 63... |
| 65 |
Long warehouseId = Long.parseLong(inventoryUpdate.getwarehouseId());
|
63 |
Long warehouseId = Long.parseLong(inventoryUpdate.getwarehouseId());
|
| 66 |
String timestamp = inventoryUpdate.getCurrentTimestamp();
|
64 |
String timestamp = inventoryUpdate.getCurrentTimestamp();
|
| 67 |
Map<String, Long> availability = new HashMap<String, Long>();
|
65 |
Map<String, Long> availability = new HashMap<String, Long>();
|
| 68 |
List<Update> updates = inventoryUpdate.getUpdates();
|
66 |
List<Update> updates = inventoryUpdate.getUpdates();
|
| 69 |
for(Update update: updates){
|
67 |
for(Update update: updates){
|
| - |
|
68 |
String group = update.getGroup().trim();
|
| 70 |
String brand = update.getBrand().trim();
|
69 |
String brand = update.getBrand().trim();
|
| 71 |
String model = update.getModel().trim();
|
70 |
String model = update.getModel().trim();
|
| 72 |
String color = update.getColor().trim();
|
71 |
String color = update.getColor().trim();
|
| 73 |
String key = brand + ";" + model + ";" + color;
|
72 |
String key = group + ";" + brand + ";" + model + ";" + color;
|
| 74 |
long quantity = (long) Double.parseDouble(update.getQuantity());
|
73 |
long quantity = (long) Double.parseDouble(update.getQuantity());
|
| 75 |
if(availability.containsKey(key)){
|
74 |
if(availability.containsKey(key)){
|
| 76 |
quantity = quantity + availability.get(key);
|
75 |
quantity = quantity + availability.get(key);
|
| 77 |
}
|
76 |
}
|
| 78 |
availability.put(key, quantity);
|
77 |
availability.put(key, quantity);
|