Subversion Repositories SmartDukaan

Rev

Rev 19228 | Rev 19263 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 19228 Rev 19260
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.server.OrderPromisedShippingComparator;
4
import in.shop2020.hotspot.dashbaord.shared.actions.Order;
4
import in.shop2020.hotspot.dashbaord.shared.actions.Order;
5
import in.shop2020.hotspot.dashbaord.shared.actions.OrderAlert;
5
import in.shop2020.hotspot.dashbaord.shared.actions.OrderAlert;
-
 
6
import in.shop2020.hotspot.dashbaord.shared.actions.OrderCategory;
6
import in.shop2020.hotspot.dashbaord.shared.actions.OrderType;
7
import in.shop2020.hotspot.dashbaord.shared.actions.OrderType;
7
import in.shop2020.hotspot.dashbaord.shared.actions.ReturnOrder;
8
import in.shop2020.hotspot.dashbaord.shared.actions.ReturnOrder;
8
import in.shop2020.model.v1.inventory.InventoryService;
9
import in.shop2020.model.v1.inventory.InventoryService;
9
import in.shop2020.model.v1.inventory.InventoryType;
10
import in.shop2020.model.v1.inventory.InventoryType;
10
import in.shop2020.model.v1.inventory.WarehouseType;
11
import in.shop2020.model.v1.inventory.WarehouseType;
Line 60... Line 61...
60
	private static long GREEN_AND_IN_RED_OR_WHITE = 3L;
61
	private static long GREEN_AND_IN_RED_OR_WHITE = 3L;
61
	private static long ALL_RED = 4L;
62
	private static long ALL_RED = 4L;
62
	private static long ALL_PURPLE = 5L;
63
	private static long ALL_PURPLE = 5L;
63
	private static long PURPLE_AND_IN_RED_OR_WHITE = 6L;
64
	private static long PURPLE_AND_IN_RED_OR_WHITE = 6L;
64
	private static long ALL_OTHERS = 7L;
65
	private static long ALL_OTHERS = 7L;
-
 
66
	private static int categoryOrderCount = 0;
-
 
67
	
-
 
68
	
-
 
69
	private static Map<Long, OrderCategory> categoryStrMap = new HashMap<Long, OrderCategory>();
65
	
70
	
66
	private static enum ColorCode {
71
	private static enum ColorCode {
67
		GREEN,
72
		GREEN,
68
		PURPLE,
73
		PURPLE,
69
		RED,
74
		RED,
70
		OTHER
75
		OTHER
71
	}
76
	}
72
	
77
	
-
 
78
	static{
-
 
79
		categoryStrMap.put(ALL_GREEN, OrderCategory.READY);
-
 
80
		categoryStrMap.put(GREEN_AND_PURPULE, OrderCategory.READY);
-
 
81
		categoryStrMap.put(GREEN_AND_IN_RED_OR_WHITE, OrderCategory.REVIEW);
-
 
82
		categoryStrMap.put(ALL_RED, OrderCategory.REVIEW);
-
 
83
		categoryStrMap.put(ALL_PURPLE, OrderCategory.READY_LATER);
-
 
84
		categoryStrMap.put(PURPLE_AND_IN_RED_OR_WHITE, OrderCategory.REVIEW_LATER);
-
 
85
		categoryStrMap.put(ALL_OTHERS, OrderCategory.REVIEW_LATER);
-
 
86
	}
-
 
87
	
73
	
88
	
74
	/**
89
	/**
75
	 * The human user is concerned only with a consolidated view of actionable
90
	 * The human user is concerned only with a consolidated view of actionable
76
	 * orders. Orders with different statuses in the database can be part of the
91
	 * orders. Orders with different statuses in the database can be part of the
77
	 * same consolidated view. This method uses a mapping of <i>type</i> to
92
	 * same consolidated view. This method uses a mapping of <i>type</i> to
Line 86... Line 101...
86
	 * @param warehouseId
101
	 * @param warehouseId
87
	 *            The warehouse for which the orders should be queried.
102
	 *            The warehouse for which the orders should be queried.
88
	 * @return A list of orders of the given type to be fulfilled from the given
103
	 * @return A list of orders of the given type to be fulfilled from the given
89
	 *         warehouse
104
	 *         warehouse
90
	 */
105
	 */
91
	public static List<Order> getOrders(OrderType type, long offset, long limit, long warehouseId, long source){
106
	public static List<Order> getOrders(OrderType type, long offset, long limit, long warehouseId, long source, OrderCategory orderCategory){
92
		List<OrderStatus> statuses = getStatuses(type);
107
		List<OrderStatus> statuses = getStatuses(type);
93
		
108
		
94
		List<Order> orders = new ArrayList<Order>();
109
		List<Order> orders = new ArrayList<Order>();
95
		try{
110
		try{
96
			TransactionClient txnClient = new TransactionClient();
111
			TransactionClient txnClient = new TransactionClient();
Line 266... Line 281...
266
				
281
				
267
				List<Long> categoryList = new ArrayList<Long>(orderCategoryMap.keySet());
282
				List<Long> categoryList = new ArrayList<Long>(orderCategoryMap.keySet());
268
				Collections.sort(categoryList);
283
				Collections.sort(categoryList);
269
				
284
				
270
				orders = new ArrayList<Order>();
285
				orders = new ArrayList<Order>();
-
 
286
				if(orderCategory==OrderCategory.NONE){
271
				for(Long category:categoryList){
287
					for(Long category:categoryList){
272
					List<Long> transactions = orderCategoryMap.get(category);
288
						List<Long> transactions = orderCategoryMap.get(category);
273
					for(Long transactionId: transactions){
289
						for(Long transactionId: transactions){
274
						List<Order> txnOrders = transactionOrdersMap.get(transactionId);
290
							List<Order> txnOrders = transactionOrdersMap.get(transactionId);
-
 
291
							for(Order order: txnOrders){
-
 
292
								order.setCategory(categoryStrMap.get(category));
-
 
293
							}
275
						Collections.sort(txnOrders,new OrderPromisedShippingComparator());
294
							Collections.sort(txnOrders,new OrderPromisedShippingComparator());
276
						orders.addAll(txnOrders);
295
							orders.addAll(txnOrders);
-
 
296
						}
-
 
297
					}
-
 
298
				}else{
-
 
299
					for(Long category:categoryList){
-
 
300
						if(orderCategory==categoryStrMap.get(category)){
-
 
301
							List<Long> transactions = orderCategoryMap.get(category);
-
 
302
							for(Long transactionId: transactions){
-
 
303
								List<Order> txnOrders = transactionOrdersMap.get(transactionId);
-
 
304
								for(Order order: txnOrders){
-
 
305
									order.setCategory(categoryStrMap.get(category));
-
 
306
								}
-
 
307
								Collections.sort(txnOrders,new OrderPromisedShippingComparator());
-
 
308
								orders.addAll(txnOrders);
-
 
309
							}
-
 
310
						}else{
-
 
311
							continue;
-
 
312
						}
277
					}
313
					}
-
 
314
					categoryOrderCount = categoryOrderCount+orders.size();
278
				}
315
				}
-
 
316
				
279
			}
317
			}
280
			
318
			
281
		}catch(Exception e){
319
		}catch(Exception e){
282
			e.printStackTrace();
320
			e.printStackTrace();
283
		}
321
		}
Line 294... Line 332...
294
	 * @param warehouseId
332
	 * @param warehouseId
295
	 *            The warehouse for which the orders should be queried.
333
	 *            The warehouse for which the orders should be queried.
296
	 * @return The count of orders of the given type assigned to the given
334
	 * @return The count of orders of the given type assigned to the given
297
	 *         warehouse.
335
	 *         warehouse.
298
	 */
336
	 */
299
	public static int getOrderCount(OrderType type, long warehouseId, long source){
337
	public static int getOrderCount(OrderType type, long warehouseId, long source, OrderCategory orderCategory){
300
		List<OrderStatus> statuses = getStatuses(type);
338
		List<OrderStatus> statuses = getStatuses(type);
301
		
339
		
302
		int count = 0;
340
		int count = 0;
303
		try{
341
		try{
-
 
342
			if(type==OrderType.ALL_PENDING && orderCategory!=OrderCategory.NONE){
-
 
343
				return categoryOrderCount;
-
 
344
			}
-
 
345
			else{
304
			TransactionClient txnClient = new TransactionClient();
346
				TransactionClient txnClient = new TransactionClient();
305
			Client client = txnClient.getClient();
347
				Client client = txnClient.getClient();
306
			count += client.getOrderCount(statuses, warehouseId, source);
348
				count += client.getOrderCount(statuses, warehouseId, source);
-
 
349
			}
307
		}catch(Exception e){
350
		}catch(Exception e){
308
			e.printStackTrace();
351
			e.printStackTrace();
309
		}
352
		}
310
		return count;
353
		return count;
311
	}
354
	}