| Line 1... |
Line 1... |
| 1 |
package in.shop2020.hotspot.dashbaord.server;
|
1 |
package in.shop2020.hotspot.dashbaord.server;
|
| 2 |
|
2 |
|
| - |
|
3 |
import in.shop2020.hotspot.dashbaord.server.OrderPromisedShippingComparator;
|
| 3 |
import in.shop2020.hotspot.dashbaord.shared.actions.Order;
|
4 |
import in.shop2020.hotspot.dashbaord.shared.actions.Order;
|
| 4 |
import in.shop2020.hotspot.dashbaord.shared.actions.OrderType;
|
5 |
import in.shop2020.hotspot.dashbaord.shared.actions.OrderType;
|
| 5 |
import in.shop2020.hotspot.dashbaord.shared.actions.ReturnOrder;
|
6 |
import in.shop2020.hotspot.dashbaord.shared.actions.ReturnOrder;
|
| 6 |
import in.shop2020.model.v1.inventory.InventoryType;
|
7 |
import in.shop2020.model.v1.inventory.InventoryType;
|
| 7 |
import in.shop2020.model.v1.inventory.WarehouseType;
|
8 |
import in.shop2020.model.v1.inventory.WarehouseType;
|
| Line 25... |
Line 26... |
| 25 |
import java.text.DecimalFormat;
|
26 |
import java.text.DecimalFormat;
|
| 26 |
import java.text.NumberFormat;
|
27 |
import java.text.NumberFormat;
|
| 27 |
import java.text.SimpleDateFormat;
|
28 |
import java.text.SimpleDateFormat;
|
| 28 |
import java.util.ArrayList;
|
29 |
import java.util.ArrayList;
|
| 29 |
import java.util.Calendar;
|
30 |
import java.util.Calendar;
|
| - |
|
31 |
import java.util.Collections;
|
| 30 |
import java.util.Date;
|
32 |
import java.util.Date;
|
| 31 |
import java.util.GregorianCalendar;
|
33 |
import java.util.GregorianCalendar;
|
| 32 |
import java.util.HashMap;
|
34 |
import java.util.HashMap;
|
| 33 |
import java.util.List;
|
35 |
import java.util.List;
|
| 34 |
import java.util.Map;
|
36 |
import java.util.Map;
|
| - |
|
37 |
import java.util.Map.Entry;
|
| 35 |
|
38 |
|
| 36 |
import org.slf4j.Logger;
|
39 |
import org.slf4j.Logger;
|
| 37 |
import org.slf4j.LoggerFactory;
|
40 |
import org.slf4j.LoggerFactory;
|
| 38 |
|
41 |
|
| 39 |
/**
|
42 |
/**
|
| Line 44... |
Line 47... |
| 44 |
*
|
47 |
*
|
| 45 |
*/
|
48 |
*/
|
| 46 |
public class TransactionUtils {
|
49 |
public class TransactionUtils {
|
| 47 |
private static String courierDetailsPath = "/CourierDetailReports";
|
50 |
private static String courierDetailsPath = "/CourierDetailReports";
|
| 48 |
private static Logger logger = LoggerFactory.getLogger(TransactionUtils.class);
|
51 |
private static Logger logger = LoggerFactory.getLogger(TransactionUtils.class);
|
| - |
|
52 |
public static List<Long> virtualInvnetoryWarehouses;
|
| - |
|
53 |
|
| - |
|
54 |
static{
|
| - |
|
55 |
virtualInvnetoryWarehouses = new ArrayList<Long>();
|
| - |
|
56 |
try{
|
| - |
|
57 |
in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = new InventoryClient().getClient();
|
| - |
|
58 |
List<Warehouse> allWarehouses = inventoryClient.getWarehouses(null, null, 0, 0, 0);
|
| - |
|
59 |
for(Warehouse wh:allWarehouses){
|
| - |
|
60 |
if(wh.getWarehouseType()==WarehouseType.THIRD_PARTY){
|
| - |
|
61 |
virtualInvnetoryWarehouses.add(wh.getId());
|
| - |
|
62 |
}
|
| - |
|
63 |
}
|
| - |
|
64 |
}catch(Exception e){
|
| - |
|
65 |
e.printStackTrace();
|
| - |
|
66 |
}
|
| - |
|
67 |
|
| - |
|
68 |
}
|
| 49 |
|
69 |
|
| 50 |
/**
|
70 |
/**
|
| 51 |
* The human user is concerned only with a consolidated view of actionable
|
71 |
* The human user is concerned only with a consolidated view of actionable
|
| 52 |
* orders. Orders with different statuses in the database can be part of the
|
72 |
* orders. Orders with different statuses in the database can be part of the
|
| 53 |
* same consolidated view. This method uses a mapping of <i>type</i> to
|
73 |
* same consolidated view. This method uses a mapping of <i>type</i> to
|
| Line 71... |
Line 91... |
| 71 |
try{
|
91 |
try{
|
| 72 |
TransactionClient txnClient = new TransactionClient();
|
92 |
TransactionClient txnClient = new TransactionClient();
|
| 73 |
Client client = txnClient.getClient();
|
93 |
Client client = txnClient.getClient();
|
| 74 |
|
94 |
|
| 75 |
List<in.shop2020.model.v1.order.Order> t_orders = new ArrayList<in.shop2020.model.v1.order.Order>();
|
95 |
List<in.shop2020.model.v1.order.Order> t_orders = new ArrayList<in.shop2020.model.v1.order.Order>();
|
| - |
|
96 |
if(type==OrderType.NEW || type==OrderType.ALL_PENDING || type ==OrderType.LOW_INVENTORY || type == OrderType.PO_RAISED
|
| - |
|
97 |
|| type == OrderType.REVERSAL_INITIATED || type == OrderType.NOT_AVAILABLE){
|
| - |
|
98 |
t_orders.addAll(client.getOrdersInBatchAsPromisedShipping(statuses, offset, limit, warehouseId, source));
|
| - |
|
99 |
}else{
|
| 76 |
t_orders.addAll(client.getOrdersInBatch(statuses, offset, limit, warehouseId, source));
|
100 |
t_orders.addAll(client.getOrdersInBatch(statuses, offset, limit, warehouseId, source));
|
| - |
|
101 |
}
|
| 77 |
|
102 |
|
| 78 |
for (in.shop2020.model.v1.order.Order t_order: t_orders){
|
103 |
for (in.shop2020.model.v1.order.Order t_order: t_orders){
|
| 79 |
Order o = getOrderFromThriftOrder(t_order);
|
104 |
Order o = getOrderFromThriftOrder(t_order);
|
| 80 |
orders.add(o);
|
105 |
orders.add(o);
|
| 81 |
}
|
106 |
}
|
| - |
|
107 |
if(type==OrderType.NEW || type==OrderType.ALL_PENDING || type ==OrderType.LOW_INVENTORY || type == OrderType.PO_RAISED
|
| - |
|
108 |
|| type == OrderType.REVERSAL_INITIATED || type == OrderType.NOT_AVAILABLE){
|
| - |
|
109 |
Map<Long, List<Order>> transactionOrdersMap = new HashMap<Long, List<Order>>();
|
| - |
|
110 |
for(Order order : orders){
|
| - |
|
111 |
if(transactionOrdersMap.containsKey(order.getTransactionId())){
|
| - |
|
112 |
List<Order> txnOrders = transactionOrdersMap.get(order.getTransactionId());
|
| - |
|
113 |
txnOrders.add(order);
|
| - |
|
114 |
transactionOrdersMap.put(order.getTransactionId(), txnOrders);
|
| - |
|
115 |
}else{
|
| - |
|
116 |
List<Order> txnOrders = new ArrayList<Order>();
|
| - |
|
117 |
txnOrders.add(order);
|
| - |
|
118 |
transactionOrdersMap.put(order.getTransactionId(), txnOrders);
|
| - |
|
119 |
}
|
| - |
|
120 |
}
|
| - |
|
121 |
|
| - |
|
122 |
orders = new ArrayList<Order>();
|
| - |
|
123 |
for(Entry<Long, List<Order>> entry : transactionOrdersMap.entrySet()){
|
| - |
|
124 |
List<Order> txnOrders = entry.getValue();
|
| - |
|
125 |
Collections.sort(txnOrders,new OrderPromisedShippingComparator());
|
| - |
|
126 |
transactionOrdersMap.put(entry.getKey(), txnOrders);
|
| - |
|
127 |
}
|
| - |
|
128 |
|
| - |
|
129 |
for(Entry<Long, List<Order>> entry : transactionOrdersMap.entrySet()){
|
| - |
|
130 |
orders.addAll(entry.getValue());
|
| - |
|
131 |
}
|
| - |
|
132 |
}
|
| - |
|
133 |
|
| 82 |
}catch(Exception e){
|
134 |
}catch(Exception e){
|
| 83 |
e.printStackTrace();
|
135 |
e.printStackTrace();
|
| 84 |
}
|
136 |
}
|
| 85 |
return orders;
|
137 |
return orders;
|
| 86 |
}
|
138 |
}
|
| Line 211... |
Line 263... |
| 211 |
*/
|
263 |
*/
|
| 212 |
public static Order getOrderFromThriftOrder(in.shop2020.model.v1.order.Order t_order) {
|
264 |
public static Order getOrderFromThriftOrder(in.shop2020.model.v1.order.Order t_order) {
|
| 213 |
LineItem lineItem = t_order.getLineitems().get(0);
|
265 |
LineItem lineItem = t_order.getLineitems().get(0);
|
| 214 |
String pickFromWarehouse = null;
|
266 |
String pickFromWarehouse = null;
|
| 215 |
Item item = null;
|
267 |
Item item = null;
|
| - |
|
268 |
String warehouseType = "";
|
| 216 |
|
269 |
|
| 217 |
Map<Long, Map<String, String>> acceptTogetherOrdersMap = null;
|
270 |
Map<Long, Map<String, String>> acceptTogetherOrdersMap = null;
|
| 218 |
Map<Long, Map<String, String>> billTogetherOrdersMap = null;
|
271 |
Map<Long, Map<String, String>> billTogetherOrdersMap = null;
|
| 219 |
|
272 |
|
| 220 |
try {
|
273 |
try {
|
| Line 235... |
Line 288... |
| 235 |
orderValuesMap.put("Quantity", lineItem.getQuantity()+"");
|
288 |
orderValuesMap.put("Quantity", lineItem.getQuantity()+"");
|
| 236 |
if(!inventoryClient.isAlive()){
|
289 |
if(!inventoryClient.isAlive()){
|
| 237 |
inventoryClient = new InventoryClient().getClient();
|
290 |
inventoryClient = new InventoryClient().getClient();
|
| 238 |
}
|
291 |
}
|
| 239 |
Warehouse fulfillmentWarehouse = inventoryClient.getWarehouse(t_order.getFulfilmentWarehouseId());
|
292 |
Warehouse fulfillmentWarehouse = inventoryClient.getWarehouse(t_order.getFulfilmentWarehouseId());
|
| - |
|
293 |
warehouseType = fulfillmentWarehouse.getWarehouseType().toString();
|
| 240 |
orderValuesMap.put("WarehouseType", fulfillmentWarehouse.getWarehouseType().toString());
|
294 |
orderValuesMap.put("WarehouseType", fulfillmentWarehouse.getWarehouseType().toString());
|
| 241 |
SimpleDateFormat sdf = new SimpleDateFormat("EEE MMM dd HH:mm:ss yyyy");
|
295 |
SimpleDateFormat sdf = new SimpleDateFormat("EEE MMM dd HH:mm:ss yyyy");
|
| 242 |
orderValuesMap.put("Promised_Shipping", sdf.format(new Date(t_order.getPromised_shipping_time())));
|
296 |
orderValuesMap.put("Promised_Shipping", sdf.format(new Date(t_order.getPromised_shipping_time())));
|
| 243 |
NumberFormat formatter = new DecimalFormat("#0.000");
|
297 |
NumberFormat formatter = new DecimalFormat("#0.000");
|
| 244 |
orderValuesMap.put("Weight", formatter.format(t_order.getLineitems().get(0).getUnit_weight()));
|
298 |
orderValuesMap.put("Weight", formatter.format(t_order.getLineitems().get(0).getUnit_weight()));
|