| 493 |
rajveer |
1 |
package in.shop2020.hotspot.dashbaord.server;
|
|
|
2 |
|
| 19015 |
manish.sha |
3 |
import in.shop2020.hotspot.dashbaord.server.OrderPromisedShippingComparator;
|
| 493 |
rajveer |
4 |
import in.shop2020.hotspot.dashbaord.shared.actions.Order;
|
| 19032 |
manish.sha |
5 |
import in.shop2020.hotspot.dashbaord.shared.actions.OrderAlert;
|
| 19260 |
manish.sha |
6 |
import in.shop2020.hotspot.dashbaord.shared.actions.OrderCategory;
|
| 493 |
rajveer |
7 |
import in.shop2020.hotspot.dashbaord.shared.actions.OrderType;
|
| 2697 |
chandransh |
8 |
import in.shop2020.hotspot.dashbaord.shared.actions.ReturnOrder;
|
| 19227 |
manish.sha |
9 |
import in.shop2020.model.v1.inventory.InventoryService;
|
| 5945 |
mandeep.dh |
10 |
import in.shop2020.model.v1.inventory.InventoryType;
|
| 18100 |
manish.sha |
11 |
import in.shop2020.model.v1.inventory.WarehouseType;
|
| 5110 |
mandeep.dh |
12 |
import in.shop2020.model.v1.catalog.Item;
|
|
|
13 |
import in.shop2020.model.v1.catalog.ItemType;
|
| 5945 |
mandeep.dh |
14 |
import in.shop2020.model.v1.inventory.Warehouse;
|
| 914 |
chandransh |
15 |
import in.shop2020.model.v1.order.LineItem;
|
| 7422 |
rajveer |
16 |
import in.shop2020.model.v1.order.OrderSource;
|
| 493 |
rajveer |
17 |
import in.shop2020.model.v1.order.OrderStatus;
|
|
|
18 |
import in.shop2020.model.v1.order.TransactionService.Client;
|
| 19050 |
manish.sha |
19 |
import in.shop2020.hotspot.dashbaord.server.EhcacheWrapper;
|
| 5110 |
mandeep.dh |
20 |
import in.shop2020.thrift.clients.CatalogClient;
|
| 5948 |
mandeep.dh |
21 |
import in.shop2020.thrift.clients.InventoryClient;
|
| 3132 |
rajveer |
22 |
import in.shop2020.thrift.clients.TransactionClient;
|
| 13146 |
manish.sha |
23 |
import in.shop2020.thrift.clients.LogisticsClient;
|
| 493 |
rajveer |
24 |
|
| 4411 |
rajveer |
25 |
import java.io.ByteArrayOutputStream;
|
|
|
26 |
import java.io.File;
|
|
|
27 |
import java.io.FileNotFoundException;
|
|
|
28 |
import java.io.FileOutputStream;
|
|
|
29 |
import java.io.IOException;
|
| 18938 |
manish.sha |
30 |
import java.text.DecimalFormat;
|
|
|
31 |
import java.text.NumberFormat;
|
| 19054 |
manish.sha |
32 |
import java.text.SimpleDateFormat;
|
| 493 |
rajveer |
33 |
import java.util.ArrayList;
|
| 4411 |
rajveer |
34 |
import java.util.Calendar;
|
| 19004 |
manish.sha |
35 |
import java.util.Collections;
|
| 493 |
rajveer |
36 |
import java.util.Date;
|
| 4411 |
rajveer |
37 |
import java.util.GregorianCalendar;
|
|
|
38 |
import java.util.HashMap;
|
| 493 |
rajveer |
39 |
import java.util.List;
|
| 4411 |
rajveer |
40 |
import java.util.Map;
|
| 19004 |
manish.sha |
41 |
import java.util.Map.Entry;
|
| 19110 |
manish.sha |
42 |
import java.util.Set;
|
| 493 |
rajveer |
43 |
|
| 19050 |
manish.sha |
44 |
import net.sf.ehcache.CacheManager;
|
|
|
45 |
|
| 4411 |
rajveer |
46 |
import org.slf4j.Logger;
|
|
|
47 |
import org.slf4j.LoggerFactory;
|
|
|
48 |
|
| 2449 |
chandransh |
49 |
/**
|
|
|
50 |
* This class is a facade to the Transaction service and should be used to
|
| 4133 |
chandransh |
51 |
* access all order specific data which requires some kind of transformation.
|
| 2449 |
chandransh |
52 |
*
|
|
|
53 |
* @author Chandranshu
|
|
|
54 |
*
|
|
|
55 |
*/
|
| 493 |
rajveer |
56 |
public class TransactionUtils {
|
| 4411 |
rajveer |
57 |
private static String courierDetailsPath = "/CourierDetailReports";
|
|
|
58 |
private static Logger logger = LoggerFactory.getLogger(TransactionUtils.class);
|
| 19196 |
manish.sha |
59 |
private static long ALL_GREEN = 1L;
|
|
|
60 |
private static long GREEN_AND_PURPULE = 2L;
|
|
|
61 |
private static long GREEN_AND_IN_RED_OR_WHITE = 3L;
|
|
|
62 |
private static long ALL_RED = 4L;
|
|
|
63 |
private static long ALL_PURPLE = 5L;
|
|
|
64 |
private static long PURPLE_AND_IN_RED_OR_WHITE = 6L;
|
|
|
65 |
private static long ALL_OTHERS = 7L;
|
| 20776 |
amit.gupta |
66 |
private static int categoryOrderCount = 0;
|
|
|
67 |
private static SimpleDateFormat sdf = new SimpleDateFormat("EEE MMM dd HH:mm:ss yyyy");
|
|
|
68 |
private static SimpleDateFormat newSdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
69 |
private static NumberFormat formatter = new DecimalFormat("#0.000");
|
|
|
70 |
private static NumberFormat rformatter = new DecimalFormat("#0.00");
|
| 4411 |
rajveer |
71 |
|
| 20776 |
amit.gupta |
72 |
private static Map<Long, in.shop2020.logistics.Provider> getProvidersMap() {
|
|
|
73 |
if(providersMap==null){
|
|
|
74 |
try {
|
|
|
75 |
in.shop2020.logistics.LogisticsService.Client logisticsClient = new LogisticsClient().getClient();
|
|
|
76 |
List<in.shop2020.logistics.Provider> providers = logisticsClient.getAllProviders();
|
|
|
77 |
providersMap = new HashMap<Long, in.shop2020.logistics.Provider>();
|
|
|
78 |
|
|
|
79 |
for(in.shop2020.logistics.Provider provider : providers){
|
|
|
80 |
providersMap.put(provider.getId(), provider);
|
|
|
81 |
}
|
|
|
82 |
}catch (Exception e) {
|
|
|
83 |
e.printStackTrace();
|
|
|
84 |
}
|
|
|
85 |
}
|
|
|
86 |
return providersMap;
|
|
|
87 |
}
|
| 19260 |
manish.sha |
88 |
|
| 20776 |
amit.gupta |
89 |
private static Map<Long, in.shop2020.logistics.Provider> providersMap = null;
|
|
|
90 |
|
|
|
91 |
|
| 19260 |
manish.sha |
92 |
private static Map<Long, OrderCategory> categoryStrMap = new HashMap<Long, OrderCategory>();
|
|
|
93 |
|
| 19196 |
manish.sha |
94 |
private static enum ColorCode {
|
|
|
95 |
GREEN,
|
|
|
96 |
PURPLE,
|
|
|
97 |
RED,
|
|
|
98 |
OTHER
|
|
|
99 |
}
|
|
|
100 |
|
| 19260 |
manish.sha |
101 |
static{
|
|
|
102 |
categoryStrMap.put(ALL_GREEN, OrderCategory.READY);
|
|
|
103 |
categoryStrMap.put(GREEN_AND_PURPULE, OrderCategory.READY);
|
|
|
104 |
categoryStrMap.put(GREEN_AND_IN_RED_OR_WHITE, OrderCategory.REVIEW);
|
|
|
105 |
categoryStrMap.put(ALL_RED, OrderCategory.REVIEW);
|
|
|
106 |
categoryStrMap.put(ALL_PURPLE, OrderCategory.READY_LATER);
|
|
|
107 |
categoryStrMap.put(PURPLE_AND_IN_RED_OR_WHITE, OrderCategory.REVIEW_LATER);
|
|
|
108 |
categoryStrMap.put(ALL_OTHERS, OrderCategory.REVIEW_LATER);
|
|
|
109 |
}
|
| 19196 |
manish.sha |
110 |
|
| 19260 |
manish.sha |
111 |
|
| 2449 |
chandransh |
112 |
/**
|
|
|
113 |
* The human user is concerned only with a consolidated view of actionable
|
|
|
114 |
* orders. Orders with different statuses in the database can be part of the
|
|
|
115 |
* same consolidated view. This method uses a mapping of <i>type</i> to
|
|
|
116 |
* <i>status</i> to get all such orders and return them as order beans.
|
|
|
117 |
*
|
|
|
118 |
* @param type
|
|
|
119 |
* The type of orders to return.
|
| 4133 |
chandransh |
120 |
* @param offset
|
|
|
121 |
* Offset to start from
|
|
|
122 |
* @param limit
|
|
|
123 |
* No. of orders to return
|
| 2449 |
chandransh |
124 |
* @param warehouseId
|
| 20776 |
amit.gupta |
125 |
* The billing warehouse for which the orders should be queried.
|
| 2449 |
chandransh |
126 |
* @return A list of orders of the given type to be fulfilled from the given
|
|
|
127 |
* warehouse
|
|
|
128 |
*/
|
| 19260 |
manish.sha |
129 |
public static List<Order> getOrders(OrderType type, long offset, long limit, long warehouseId, long source, OrderCategory orderCategory){
|
| 2449 |
chandransh |
130 |
List<OrderStatus> statuses = getStatuses(type);
|
| 493 |
rajveer |
131 |
|
|
|
132 |
List<Order> orders = new ArrayList<Order>();
|
|
|
133 |
try{
|
| 4133 |
chandransh |
134 |
TransactionClient txnClient = new TransactionClient();
|
|
|
135 |
Client client = txnClient.getClient();
|
| 493 |
rajveer |
136 |
|
|
|
137 |
List<in.shop2020.model.v1.order.Order> t_orders = new ArrayList<in.shop2020.model.v1.order.Order>();
|
| 19004 |
manish.sha |
138 |
if(type==OrderType.NEW || type==OrderType.ALL_PENDING || type ==OrderType.LOW_INVENTORY || type == OrderType.PO_RAISED
|
|
|
139 |
|| type == OrderType.REVERSAL_INITIATED || type == OrderType.NOT_AVAILABLE){
|
| 19228 |
manish.sha |
140 |
t_orders.addAll(client.getOrdersInBatchAsPromisedShipping(statuses, 0, 0, warehouseId, source));
|
| 19004 |
manish.sha |
141 |
}else{
|
| 19268 |
manish.sha |
142 |
if(orderCategory!=OrderCategory.NONE){
|
|
|
143 |
statuses = getStatuses(OrderType.ALL_PENDING);
|
|
|
144 |
t_orders.addAll(client.getOrdersInBatchAsPromisedShipping(statuses, 0, 0, warehouseId, source));
|
|
|
145 |
}else{
|
|
|
146 |
t_orders.addAll(client.getOrdersInBatch(statuses, offset, limit, warehouseId, source));
|
|
|
147 |
}
|
| 19004 |
manish.sha |
148 |
}
|
| 493 |
rajveer |
149 |
|
| 20776 |
amit.gupta |
150 |
orders = getOrdersFromThirftOrders(t_orders, warehouseId);
|
| 19224 |
manish.sha |
151 |
/*for (in.shop2020.model.v1.order.Order t_order: t_orders){
|
| 671 |
chandransh |
152 |
Order o = getOrderFromThriftOrder(t_order);
|
| 493 |
rajveer |
153 |
orders.add(o);
|
| 19224 |
manish.sha |
154 |
}*/
|
| 19004 |
manish.sha |
155 |
if(type==OrderType.NEW || type==OrderType.ALL_PENDING || type ==OrderType.LOW_INVENTORY || type == OrderType.PO_RAISED
|
| 19268 |
manish.sha |
156 |
|| type == OrderType.REVERSAL_INITIATED || type == OrderType.NOT_AVAILABLE || type == OrderType.NOT_APPLICABLE){
|
| 19004 |
manish.sha |
157 |
Map<Long, List<Order>> transactionOrdersMap = new HashMap<Long, List<Order>>();
|
| 19196 |
manish.sha |
158 |
Map<Long, Map<String, Long>> transactionsColorMap = new HashMap<Long, Map<String, Long>>();
|
| 19004 |
manish.sha |
159 |
for(Order order : orders){
|
|
|
160 |
if(transactionOrdersMap.containsKey(order.getTransactionId())){
|
|
|
161 |
List<Order> txnOrders = transactionOrdersMap.get(order.getTransactionId());
|
|
|
162 |
txnOrders.add(order);
|
|
|
163 |
transactionOrdersMap.put(order.getTransactionId(), txnOrders);
|
|
|
164 |
}else{
|
|
|
165 |
List<Order> txnOrders = new ArrayList<Order>();
|
|
|
166 |
txnOrders.add(order);
|
|
|
167 |
transactionOrdersMap.put(order.getTransactionId(), txnOrders);
|
|
|
168 |
}
|
| 19196 |
manish.sha |
169 |
|
|
|
170 |
if(transactionsColorMap.containsKey(order.getTransactionId())){
|
|
|
171 |
Map<String, Long> colorMap = transactionsColorMap.get(order.getTransactionId());
|
|
|
172 |
//SHIPPING_TIME_EXCEEDED, DELIVERY_TIME_EXCEEDED, ORDER_NOT_CONNECTED_FOR_TOO_LONG, ORDER_NOT_CONNECTED
|
|
|
173 |
if(order.getAlert()==OrderAlert.TODAY_SHIPPING_IN_STOCK){
|
|
|
174 |
if(colorMap.containsKey(ColorCode.GREEN.toString())){
|
|
|
175 |
colorMap.put(ColorCode.GREEN.toString(),colorMap.get(ColorCode.GREEN.toString())+1);
|
|
|
176 |
}else{
|
|
|
177 |
colorMap.put(ColorCode.GREEN.toString(),1L);
|
|
|
178 |
}
|
|
|
179 |
}else if(order.getAlert()==OrderAlert.TODAY_SHIPPING_NOT_IN_STOCK){
|
|
|
180 |
if(colorMap.containsKey(ColorCode.RED.toString())){
|
|
|
181 |
colorMap.put(ColorCode.RED.toString(),colorMap.get(ColorCode.RED.toString())+1);
|
|
|
182 |
}else{
|
|
|
183 |
colorMap.put(ColorCode.RED.toString(),1L);
|
|
|
184 |
}
|
|
|
185 |
}else if(order.getAlert()==OrderAlert.LATER_SHIPPING_IN_STOCK){
|
|
|
186 |
if(colorMap.containsKey(ColorCode.PURPLE.toString())){
|
|
|
187 |
colorMap.put(ColorCode.PURPLE.toString(),colorMap.get(ColorCode.PURPLE.toString())+1);
|
|
|
188 |
}else{
|
|
|
189 |
colorMap.put(ColorCode.PURPLE.toString(),1L);
|
|
|
190 |
}
|
|
|
191 |
}else{
|
|
|
192 |
if(colorMap.containsKey(ColorCode.OTHER.toString())){
|
|
|
193 |
colorMap.put(ColorCode.OTHER.toString(),colorMap.get(ColorCode.OTHER.toString())+1);
|
|
|
194 |
}else{
|
|
|
195 |
colorMap.put(ColorCode.OTHER.toString(),1L);
|
|
|
196 |
}
|
|
|
197 |
}
|
|
|
198 |
transactionsColorMap.put(order.getTransactionId(), colorMap);
|
|
|
199 |
}else{
|
|
|
200 |
Map<String, Long> colorMap = new HashMap<String, Long>();
|
|
|
201 |
if(order.getAlert()==OrderAlert.TODAY_SHIPPING_IN_STOCK){
|
|
|
202 |
colorMap.put(ColorCode.GREEN.toString(),1L);
|
|
|
203 |
}else if(order.getAlert()==OrderAlert.TODAY_SHIPPING_NOT_IN_STOCK){
|
|
|
204 |
colorMap.put(ColorCode.RED.toString(),1L);
|
|
|
205 |
}else if(order.getAlert()==OrderAlert.LATER_SHIPPING_IN_STOCK){
|
|
|
206 |
colorMap.put(ColorCode.PURPLE.toString(),1L);
|
|
|
207 |
}else{
|
|
|
208 |
colorMap.put(ColorCode.OTHER.toString(),1L);
|
|
|
209 |
}
|
|
|
210 |
transactionsColorMap.put(order.getTransactionId(), colorMap);
|
|
|
211 |
}
|
|
|
212 |
|
| 19004 |
manish.sha |
213 |
}
|
| 19196 |
manish.sha |
214 |
|
|
|
215 |
Map<Long, List<Long>> orderCategoryMap = new HashMap<Long, List<Long>>();
|
|
|
216 |
|
|
|
217 |
for(Entry<Long, Map<String, Long>> colorMapEntry : transactionsColorMap.entrySet()){
|
|
|
218 |
Map<String, Long> colorMap = colorMapEntry.getValue();
|
|
|
219 |
List<String> colorSet = new ArrayList<String>(colorMap.keySet());
|
|
|
220 |
long colorMapSize = colorSet.size();
|
|
|
221 |
if(colorMapSize==1){
|
|
|
222 |
if(ColorCode.GREEN.toString().equalsIgnoreCase(colorSet.get(0))){
|
|
|
223 |
if(orderCategoryMap.containsKey(ALL_GREEN)){
|
|
|
224 |
List<Long> transactions = orderCategoryMap.get(ALL_GREEN);
|
|
|
225 |
transactions.add(colorMapEntry.getKey());
|
|
|
226 |
orderCategoryMap.put(ALL_GREEN, transactions);
|
|
|
227 |
}else{
|
|
|
228 |
List<Long> transactions = new ArrayList<Long>();
|
|
|
229 |
transactions.add(colorMapEntry.getKey());
|
|
|
230 |
orderCategoryMap.put(ALL_GREEN, transactions);
|
|
|
231 |
}
|
|
|
232 |
}else if(ColorCode.RED.toString().equalsIgnoreCase(colorSet.get(0))){
|
|
|
233 |
if(orderCategoryMap.containsKey(ALL_RED)){
|
|
|
234 |
List<Long> transactions = orderCategoryMap.get(ALL_RED);
|
|
|
235 |
transactions.add(colorMapEntry.getKey());
|
|
|
236 |
orderCategoryMap.put(ALL_RED, transactions);
|
|
|
237 |
}else{
|
|
|
238 |
List<Long> transactions = new ArrayList<Long>();
|
|
|
239 |
transactions.add(colorMapEntry.getKey());
|
|
|
240 |
orderCategoryMap.put(ALL_RED, transactions);
|
|
|
241 |
}
|
|
|
242 |
}else if(ColorCode.PURPLE.toString().equalsIgnoreCase(colorSet.get(0))){
|
|
|
243 |
if(orderCategoryMap.containsKey(ALL_PURPLE)){
|
|
|
244 |
List<Long> transactions = orderCategoryMap.get(ALL_PURPLE);
|
|
|
245 |
transactions.add(colorMapEntry.getKey());
|
|
|
246 |
orderCategoryMap.put(ALL_PURPLE, transactions);
|
|
|
247 |
}else{
|
|
|
248 |
List<Long> transactions = new ArrayList<Long>();
|
|
|
249 |
transactions.add(colorMapEntry.getKey());
|
|
|
250 |
orderCategoryMap.put(ALL_PURPLE, transactions);
|
|
|
251 |
}
|
|
|
252 |
}else{
|
|
|
253 |
if(orderCategoryMap.containsKey(ALL_OTHERS)){
|
|
|
254 |
List<Long> transactions = orderCategoryMap.get(ALL_OTHERS);
|
|
|
255 |
transactions.add(colorMapEntry.getKey());
|
|
|
256 |
orderCategoryMap.put(ALL_OTHERS, transactions);
|
|
|
257 |
}else{
|
|
|
258 |
List<Long> transactions = new ArrayList<Long>();
|
|
|
259 |
transactions.add(colorMapEntry.getKey());
|
|
|
260 |
orderCategoryMap.put(ALL_OTHERS, transactions);
|
|
|
261 |
}
|
|
|
262 |
}
|
| 19279 |
manish.sha |
263 |
}else if(colorMapSize==2){
|
| 19196 |
manish.sha |
264 |
if(colorSet.contains(ColorCode.GREEN.toString())){
|
|
|
265 |
if(colorSet.contains(ColorCode.PURPLE.toString())){
|
|
|
266 |
if(orderCategoryMap.containsKey(GREEN_AND_PURPULE)){
|
|
|
267 |
List<Long> transactions = orderCategoryMap.get(GREEN_AND_PURPULE);
|
|
|
268 |
transactions.add(colorMapEntry.getKey());
|
|
|
269 |
orderCategoryMap.put(GREEN_AND_PURPULE, transactions);
|
|
|
270 |
}else{
|
|
|
271 |
List<Long> transactions = new ArrayList<Long>();
|
|
|
272 |
transactions.add(colorMapEntry.getKey());
|
|
|
273 |
orderCategoryMap.put(GREEN_AND_PURPULE, transactions);
|
|
|
274 |
}
|
|
|
275 |
}else{
|
|
|
276 |
if(orderCategoryMap.containsKey(GREEN_AND_IN_RED_OR_WHITE)){
|
|
|
277 |
List<Long> transactions = orderCategoryMap.get(GREEN_AND_IN_RED_OR_WHITE);
|
|
|
278 |
transactions.add(colorMapEntry.getKey());
|
|
|
279 |
orderCategoryMap.put(GREEN_AND_IN_RED_OR_WHITE, transactions);
|
|
|
280 |
}else{
|
|
|
281 |
List<Long> transactions = new ArrayList<Long>();
|
|
|
282 |
transactions.add(colorMapEntry.getKey());
|
|
|
283 |
orderCategoryMap.put(GREEN_AND_IN_RED_OR_WHITE, transactions);
|
|
|
284 |
}
|
|
|
285 |
}
|
|
|
286 |
}else if(colorSet.contains(ColorCode.PURPLE.toString())){
|
|
|
287 |
if(orderCategoryMap.containsKey(PURPLE_AND_IN_RED_OR_WHITE)){
|
|
|
288 |
List<Long> transactions = orderCategoryMap.get(PURPLE_AND_IN_RED_OR_WHITE);
|
|
|
289 |
transactions.add(colorMapEntry.getKey());
|
|
|
290 |
orderCategoryMap.put(PURPLE_AND_IN_RED_OR_WHITE, transactions);
|
|
|
291 |
}else{
|
|
|
292 |
List<Long> transactions = new ArrayList<Long>();
|
|
|
293 |
transactions.add(colorMapEntry.getKey());
|
|
|
294 |
orderCategoryMap.put(PURPLE_AND_IN_RED_OR_WHITE, transactions);
|
|
|
295 |
}
|
|
|
296 |
}else{
|
|
|
297 |
if(orderCategoryMap.containsKey(ALL_OTHERS)){
|
|
|
298 |
List<Long> transactions = orderCategoryMap.get(ALL_OTHERS);
|
|
|
299 |
transactions.add(colorMapEntry.getKey());
|
|
|
300 |
orderCategoryMap.put(ALL_OTHERS, transactions);
|
|
|
301 |
}else{
|
|
|
302 |
List<Long> transactions = new ArrayList<Long>();
|
|
|
303 |
transactions.add(colorMapEntry.getKey());
|
|
|
304 |
orderCategoryMap.put(ALL_OTHERS, transactions);
|
|
|
305 |
}
|
|
|
306 |
}
|
| 19279 |
manish.sha |
307 |
}else{
|
|
|
308 |
if(colorSet.contains(ColorCode.GREEN.toString())){
|
|
|
309 |
if(colorSet.contains(ColorCode.RED.toString()) || colorSet.contains(ColorCode.OTHER.toString())){
|
|
|
310 |
if(orderCategoryMap.containsKey(GREEN_AND_IN_RED_OR_WHITE)){
|
|
|
311 |
List<Long> transactions = orderCategoryMap.get(GREEN_AND_IN_RED_OR_WHITE);
|
|
|
312 |
transactions.add(colorMapEntry.getKey());
|
|
|
313 |
orderCategoryMap.put(GREEN_AND_IN_RED_OR_WHITE, transactions);
|
|
|
314 |
}else{
|
|
|
315 |
List<Long> transactions = new ArrayList<Long>();
|
|
|
316 |
transactions.add(colorMapEntry.getKey());
|
|
|
317 |
orderCategoryMap.put(GREEN_AND_IN_RED_OR_WHITE, transactions);
|
|
|
318 |
}
|
|
|
319 |
}else{
|
|
|
320 |
if(orderCategoryMap.containsKey(GREEN_AND_PURPULE)){
|
|
|
321 |
List<Long> transactions = orderCategoryMap.get(GREEN_AND_PURPULE);
|
|
|
322 |
transactions.add(colorMapEntry.getKey());
|
|
|
323 |
orderCategoryMap.put(GREEN_AND_PURPULE, transactions);
|
|
|
324 |
}else{
|
|
|
325 |
List<Long> transactions = new ArrayList<Long>();
|
|
|
326 |
transactions.add(colorMapEntry.getKey());
|
|
|
327 |
orderCategoryMap.put(GREEN_AND_PURPULE, transactions);
|
|
|
328 |
}
|
|
|
329 |
}
|
|
|
330 |
}else if(colorSet.contains(ColorCode.PURPLE.toString())){
|
|
|
331 |
if(orderCategoryMap.containsKey(PURPLE_AND_IN_RED_OR_WHITE)){
|
|
|
332 |
List<Long> transactions = orderCategoryMap.get(PURPLE_AND_IN_RED_OR_WHITE);
|
|
|
333 |
transactions.add(colorMapEntry.getKey());
|
|
|
334 |
orderCategoryMap.put(PURPLE_AND_IN_RED_OR_WHITE, transactions);
|
|
|
335 |
}else{
|
|
|
336 |
List<Long> transactions = new ArrayList<Long>();
|
|
|
337 |
transactions.add(colorMapEntry.getKey());
|
|
|
338 |
orderCategoryMap.put(PURPLE_AND_IN_RED_OR_WHITE, transactions);
|
|
|
339 |
}
|
|
|
340 |
}else{
|
|
|
341 |
if(orderCategoryMap.containsKey(ALL_OTHERS)){
|
|
|
342 |
List<Long> transactions = orderCategoryMap.get(ALL_OTHERS);
|
|
|
343 |
transactions.add(colorMapEntry.getKey());
|
|
|
344 |
orderCategoryMap.put(ALL_OTHERS, transactions);
|
|
|
345 |
}else{
|
|
|
346 |
List<Long> transactions = new ArrayList<Long>();
|
|
|
347 |
transactions.add(colorMapEntry.getKey());
|
|
|
348 |
orderCategoryMap.put(ALL_OTHERS, transactions);
|
|
|
349 |
}
|
|
|
350 |
}
|
| 19196 |
manish.sha |
351 |
}
|
| 19004 |
manish.sha |
352 |
}
|
| 19110 |
manish.sha |
353 |
|
| 19196 |
manish.sha |
354 |
List<Long> categoryList = new ArrayList<Long>(orderCategoryMap.keySet());
|
|
|
355 |
Collections.sort(categoryList);
|
| 19110 |
manish.sha |
356 |
|
| 19196 |
manish.sha |
357 |
orders = new ArrayList<Order>();
|
| 19260 |
manish.sha |
358 |
if(orderCategory==OrderCategory.NONE){
|
|
|
359 |
for(Long category:categoryList){
|
|
|
360 |
List<Long> transactions = orderCategoryMap.get(category);
|
|
|
361 |
for(Long transactionId: transactions){
|
|
|
362 |
List<Order> txnOrders = transactionOrdersMap.get(transactionId);
|
|
|
363 |
for(Order order: txnOrders){
|
|
|
364 |
order.setCategory(categoryStrMap.get(category));
|
|
|
365 |
}
|
|
|
366 |
Collections.sort(txnOrders,new OrderPromisedShippingComparator());
|
|
|
367 |
orders.addAll(txnOrders);
|
|
|
368 |
}
|
| 19196 |
manish.sha |
369 |
}
|
| 19260 |
manish.sha |
370 |
}else{
|
|
|
371 |
for(Long category:categoryList){
|
|
|
372 |
if(orderCategory==categoryStrMap.get(category)){
|
|
|
373 |
List<Long> transactions = orderCategoryMap.get(category);
|
|
|
374 |
for(Long transactionId: transactions){
|
|
|
375 |
List<Order> txnOrders = transactionOrdersMap.get(transactionId);
|
|
|
376 |
for(Order order: txnOrders){
|
|
|
377 |
order.setCategory(categoryStrMap.get(category));
|
|
|
378 |
}
|
|
|
379 |
Collections.sort(txnOrders,new OrderPromisedShippingComparator());
|
|
|
380 |
orders.addAll(txnOrders);
|
|
|
381 |
}
|
|
|
382 |
}else{
|
|
|
383 |
continue;
|
|
|
384 |
}
|
|
|
385 |
}
|
| 19263 |
manish.sha |
386 |
categoryOrderCount = 0;
|
| 19260 |
manish.sha |
387 |
categoryOrderCount = categoryOrderCount+orders.size();
|
| 19004 |
manish.sha |
388 |
}
|
| 19260 |
manish.sha |
389 |
|
| 19004 |
manish.sha |
390 |
}
|
|
|
391 |
|
| 493 |
rajveer |
392 |
}catch(Exception e){
|
| 2449 |
chandransh |
393 |
e.printStackTrace();
|
| 493 |
rajveer |
394 |
}
|
|
|
395 |
return orders;
|
|
|
396 |
}
|
|
|
397 |
|
| 2449 |
chandransh |
398 |
/**
|
| 4133 |
chandransh |
399 |
* Wrapper around the method of same name in the transaction service. This
|
|
|
400 |
* method uses a mapping of <i>type</i> to <i>status</i> to get the count of
|
|
|
401 |
* all orders with a given status.
|
|
|
402 |
*
|
|
|
403 |
* @param type
|
|
|
404 |
* The type of orders to return.
|
|
|
405 |
* @param warehouseId
|
|
|
406 |
* The warehouse for which the orders should be queried.
|
|
|
407 |
* @return The count of orders of the given type assigned to the given
|
|
|
408 |
* warehouse.
|
|
|
409 |
*/
|
| 19260 |
manish.sha |
410 |
public static int getOrderCount(OrderType type, long warehouseId, long source, OrderCategory orderCategory){
|
| 4133 |
chandransh |
411 |
List<OrderStatus> statuses = getStatuses(type);
|
|
|
412 |
|
|
|
413 |
int count = 0;
|
|
|
414 |
try{
|
| 19268 |
manish.sha |
415 |
if(type==OrderType.NOT_APPLICABLE && orderCategory!=OrderCategory.NONE){
|
| 19263 |
manish.sha |
416 |
int orderCount = categoryOrderCount;
|
|
|
417 |
categoryOrderCount = 0;
|
|
|
418 |
return orderCount;
|
| 19260 |
manish.sha |
419 |
}
|
|
|
420 |
else{
|
|
|
421 |
TransactionClient txnClient = new TransactionClient();
|
|
|
422 |
Client client = txnClient.getClient();
|
|
|
423 |
count += client.getOrderCount(statuses, warehouseId, source);
|
|
|
424 |
}
|
| 4133 |
chandransh |
425 |
}catch(Exception e){
|
|
|
426 |
e.printStackTrace();
|
|
|
427 |
}
|
|
|
428 |
return count;
|
|
|
429 |
}
|
|
|
430 |
|
|
|
431 |
/**
|
| 2449 |
chandransh |
432 |
* Calls the same method of the transaction service and returns the status
|
|
|
433 |
* returned. Catches all exceptions that are raised and returns false in
|
|
|
434 |
* that case.
|
|
|
435 |
*
|
|
|
436 |
* @param warehouseId
|
|
|
437 |
* The warehouse for which the orders should be marked as
|
|
|
438 |
* manifested.
|
|
|
439 |
* @param providerId
|
|
|
440 |
* The provider for which the orders should be marked as
|
|
|
441 |
* manifested.
|
| 3065 |
chandransh |
442 |
* @param cod
|
|
|
443 |
* Whether cod orders have to be marked as manifested
|
| 2449 |
chandransh |
444 |
* @return True if everything goes fine, false otherwise.
|
|
|
445 |
*/
|
| 5769 |
rajveer |
446 |
public static Map<Long, Long> getBilledOrders(long warehouseId, String providerId, boolean cod){
|
|
|
447 |
Map<Long, Long> orders = new HashMap<Long, Long>();
|
| 760 |
chandransh |
448 |
try {
|
|
|
449 |
long provider_id = Long.parseLong(providerId);
|
| 3132 |
rajveer |
450 |
TransactionClient client = new TransactionClient();
|
| 760 |
chandransh |
451 |
Client c = client.getClient();
|
| 20956 |
kshitij.so |
452 |
|
|
|
453 |
List<in.shop2020.model.v1.order.Order> torders = c.getBilledOrdersForManifestGen(warehouseId, Long.valueOf(provider_id), cod);
|
| 4790 |
rajveer |
454 |
for(in.shop2020.model.v1.order.Order torder: torders){
|
| 20956 |
kshitij.so |
455 |
orders.put(torder.getId(), torder.getPickupStoreId());
|
| 4411 |
rajveer |
456 |
}
|
| 20956 |
kshitij.so |
457 |
|
| 760 |
chandransh |
458 |
}catch(Exception e){
|
|
|
459 |
e.printStackTrace();
|
|
|
460 |
}
|
| 4790 |
rajveer |
461 |
return orders;
|
| 760 |
chandransh |
462 |
}
|
| 20956 |
kshitij.so |
463 |
|
| 4790 |
rajveer |
464 |
public static boolean generateCourierDetailsFile(List<Long> orderIds, long providerId, long warehouseId, boolean isCod){
|
| 4411 |
rajveer |
465 |
Calendar date = new GregorianCalendar();
|
|
|
466 |
int year = date.get(Calendar.YEAR);
|
|
|
467 |
int month = date.get(Calendar.MONTH) +1;
|
|
|
468 |
int day = date.get(Calendar.DAY_OF_MONTH);
|
|
|
469 |
|
|
|
470 |
String fileNameSuffix = "-" + warehouseId + "-"+ providerId + "-" + year + "-" + month + "-" + day;
|
|
|
471 |
if(isCod){
|
|
|
472 |
fileNameSuffix = "cod" + fileNameSuffix ;
|
|
|
473 |
}
|
|
|
474 |
else{
|
|
|
475 |
fileNameSuffix = "prepaid" + fileNameSuffix;
|
|
|
476 |
}
|
|
|
477 |
|
|
|
478 |
try {
|
| 4790 |
rajveer |
479 |
String fileName = courierDetailsPath + "/courier-details-" + fileNameSuffix + "-temp.xls";
|
| 4415 |
rajveer |
480 |
FileOutputStream f = new FileOutputStream(fileName);
|
| 4411 |
rajveer |
481 |
CourierDetailsGenerator courierDetailsGenerator = new CourierDetailsGenerator();
|
| 4790 |
rajveer |
482 |
ByteArrayOutputStream baosXLS = courierDetailsGenerator.generateCourierDetails(orderIds, warehouseId, providerId, isCod);
|
| 4411 |
rajveer |
483 |
baosXLS.writeTo(f);
|
|
|
484 |
f.close();
|
|
|
485 |
} catch (FileNotFoundException e) {
|
|
|
486 |
logger.error("Unable to create the courier details file", e);
|
|
|
487 |
} catch (IOException e) {
|
|
|
488 |
logger.error("Unable to create the courier details file", e);
|
|
|
489 |
}
|
|
|
490 |
|
|
|
491 |
CourierDetailsReportMerger merger = new CourierDetailsReportMerger();
|
|
|
492 |
try {
|
|
|
493 |
Map<Long, String> warehouseIdFileNames = new HashMap<Long, String>();
|
| 4790 |
rajveer |
494 |
String fName;
|
|
|
495 |
fName = courierDetailsPath + "/courier-details-" + fileNameSuffix + "-temp.xls";
|
|
|
496 |
if((new File(fName)).exists()){
|
|
|
497 |
warehouseIdFileNames.put(0L, fName);
|
| 4411 |
rajveer |
498 |
}
|
| 4790 |
rajveer |
499 |
fName = courierDetailsPath + "/courier-details-" + fileNameSuffix + ".xls";
|
|
|
500 |
if((new File(fName)).exists()){
|
|
|
501 |
warehouseIdFileNames.put(1L, fName);
|
| 4411 |
rajveer |
502 |
}
|
| 4790 |
rajveer |
503 |
ByteArrayOutputStream binXLS = merger.mergeCourierDetailsReports(warehouseIdFileNames);
|
|
|
504 |
FileOutputStream f = new FileOutputStream(courierDetailsPath + "/courier-details-" + fileNameSuffix + ".xls");
|
| 4411 |
rajveer |
505 |
binXLS.writeTo(f);
|
|
|
506 |
f.close();
|
| 4790 |
rajveer |
507 |
File tempFile = new File(courierDetailsPath + "/courier-details-" + fileNameSuffix + "-temp.xls");
|
|
|
508 |
if(tempFile.exists()){
|
|
|
509 |
tempFile.delete();
|
|
|
510 |
}
|
| 4411 |
rajveer |
511 |
} catch (FileNotFoundException e) {
|
|
|
512 |
logger.error("Error while creating the Courier Details report", e);
|
|
|
513 |
} catch (IOException e) {
|
|
|
514 |
logger.error("IO error while writing the Courier Details report", e);
|
|
|
515 |
}
|
|
|
516 |
return true;
|
|
|
517 |
}
|
|
|
518 |
|
| 19224 |
manish.sha |
519 |
|
| 20776 |
amit.gupta |
520 |
public static List<Order> getOrdersFromThirftOrders(List<in.shop2020.model.v1.order.Order> orders, Long billingWarehouseId){
|
| 19224 |
manish.sha |
521 |
List<Order> ordersToReturn = new ArrayList<Order>();
|
| 20830 |
amit.gupta |
522 |
Map<Long, Warehouse> warehousesMap = CatalogUtils.getAllWarehousesForBillingWarehouse(0);
|
| 19224 |
manish.sha |
523 |
List<Long> itemIds = new ArrayList<Long>();
|
|
|
524 |
Map<Long, List<in.shop2020.model.v1.order.Order>> txnOrdersMap = new HashMap<Long, List<in.shop2020.model.v1.order.Order>>();
|
| 20776 |
amit.gupta |
525 |
|
| 19224 |
manish.sha |
526 |
Date date = new Date(System.currentTimeMillis());
|
|
|
527 |
for(in.shop2020.model.v1.order.Order t_order : orders){
|
|
|
528 |
if(!itemIds.contains(t_order.getLineitems().get(0).getItem_id())){
|
|
|
529 |
itemIds.add(t_order.getLineitems().get(0).getItem_id());
|
|
|
530 |
}
|
|
|
531 |
List<in.shop2020.model.v1.order.Order> txnOrders = null;
|
|
|
532 |
if(txnOrdersMap.containsKey(t_order.getTransactionId())){
|
|
|
533 |
txnOrders = txnOrdersMap.get(t_order.getTransactionId());
|
|
|
534 |
}else{
|
|
|
535 |
txnOrders = new ArrayList<in.shop2020.model.v1.order.Order>();
|
|
|
536 |
}
|
|
|
537 |
txnOrders.add(t_order);
|
|
|
538 |
txnOrdersMap.put(t_order.getTransactionId(), txnOrders);
|
|
|
539 |
}
|
|
|
540 |
try {
|
|
|
541 |
in.shop2020.model.v1.catalog.CatalogService.Client client = new CatalogClient().getClient();
|
|
|
542 |
Map<Long, Item> itemsMap = client.getItems(itemIds);
|
|
|
543 |
|
|
|
544 |
in.shop2020.model.v1.order.TransactionService.Client tClient = new TransactionClient().getClient();
|
| 19227 |
manish.sha |
545 |
InventoryClient inventoryServiceClient = new InventoryClient();
|
|
|
546 |
InventoryService.Client inventoryClient = inventoryServiceClient.getClient();
|
| 19224 |
manish.sha |
547 |
for(in.shop2020.model.v1.order.Order t_order : orders){
|
| 28834 |
amit.gupta |
548 |
System.out.println("Order - " + t_order.getId());
|
| 19224 |
manish.sha |
549 |
LineItem lineItem = t_order.getLineitems().get(0);
|
|
|
550 |
String pickFromWarehouse = warehousesMap.get(t_order.getFulfilmentWarehouseId()).getDisplayName();
|
|
|
551 |
Item item = itemsMap.get(lineItem.getItem_id());
|
| 20776 |
amit.gupta |
552 |
in.shop2020.logistics.Provider provider = getProvidersMap().get(t_order.getLogistics_provider_id());
|
| 19224 |
manish.sha |
553 |
Warehouse fulfillmentWarehouse = warehousesMap.get(t_order.getFulfilmentWarehouseId());
|
|
|
554 |
Map<Long, Map<String, String>> acceptTogetherOrdersMap = null;
|
|
|
555 |
Map<Long, Map<String, String>> billTogetherOrdersMap = null;
|
|
|
556 |
if(!t_order.isSetAccepted_timestamp()){
|
|
|
557 |
acceptTogetherOrdersMap = new HashMap<Long, Map<String, String>>();
|
|
|
558 |
Map<String, String> orderValuesMap = new HashMap<String, String>();
|
|
|
559 |
orderValuesMap.put("ProductName", getItemDisplayName(lineItem));
|
|
|
560 |
orderValuesMap.put("Quantity", lineItem.getQuantity()+"");
|
|
|
561 |
orderValuesMap.put("Promised_Shipping", sdf.format(new Date(t_order.getPromised_shipping_time())));
|
|
|
562 |
orderValuesMap.put("Weight", formatter.format(lineItem.getUnit_weight()));
|
|
|
563 |
orderValuesMap.put("UnitPrice", rformatter.format(lineItem.getUnit_price()));
|
|
|
564 |
orderValuesMap.put("PackQuantity", item.getPackQuantity()+"");
|
|
|
565 |
orderValuesMap.put("WarehouseType", fulfillmentWarehouse.getWarehouseType().toString());
|
|
|
566 |
acceptTogetherOrdersMap.put(t_order.getId(), orderValuesMap);
|
|
|
567 |
List<in.shop2020.model.v1.order.Order> taOrders = null;
|
|
|
568 |
if(txnOrdersMap.containsKey(t_order.getTransactionId())){
|
|
|
569 |
taOrders = txnOrdersMap.get(t_order.getTransactionId());
|
|
|
570 |
}else{
|
|
|
571 |
try{
|
|
|
572 |
taOrders = tClient.getOrdersForTransaction(t_order.getTransactionId(), t_order.getCustomer_id());
|
|
|
573 |
}catch(Exception te){
|
|
|
574 |
tClient = new TransactionClient().getClient();
|
|
|
575 |
taOrders = tClient.getOrdersForTransaction(t_order.getTransactionId(), t_order.getCustomer_id());
|
|
|
576 |
}
|
|
|
577 |
}
|
|
|
578 |
for(in.shop2020.model.v1.order.Order taOrder : taOrders){
|
|
|
579 |
LineItem lineItem1 = taOrder.getLineitems().get(0);
|
|
|
580 |
if(t_order.getId()==taOrder.getId()){
|
|
|
581 |
continue;
|
|
|
582 |
}
|
|
|
583 |
else if(taOrder.getSource()!=OrderSource.WEBSITE.getValue()){
|
|
|
584 |
continue;
|
|
|
585 |
}else{
|
|
|
586 |
orderValuesMap = new HashMap<String, String>();
|
|
|
587 |
if(provider.isGroupShipmentAllowed() && !taOrder.isSetAccepted_timestamp() && t_order.getStatus()==taOrder.getStatus()
|
|
|
588 |
&& taOrder.isLogisticsCod()==t_order.isLogisticsCod() && taOrder.getWarehouse_id() == t_order.getWarehouse_id()
|
|
|
589 |
&& taOrder.getOrderType() == t_order.getOrderType() && taOrder.getPickupStoreId() == t_order.getPickupStoreId()){
|
|
|
590 |
orderValuesMap.put("ProductName", getItemDisplayName(lineItem1));
|
|
|
591 |
orderValuesMap.put("Quantity", lineItem1.getQuantity()+"");
|
| 19227 |
manish.sha |
592 |
if(warehousesMap.containsKey(taOrder.getFulfilmentWarehouseId())){
|
|
|
593 |
fulfillmentWarehouse = warehousesMap.get(taOrder.getFulfilmentWarehouseId());
|
|
|
594 |
}else{
|
|
|
595 |
try{
|
|
|
596 |
fulfillmentWarehouse = inventoryClient.getWarehouse(taOrder.getFulfilmentWarehouseId());
|
|
|
597 |
warehousesMap.put(fulfillmentWarehouse.getId(), fulfillmentWarehouse);
|
|
|
598 |
}
|
|
|
599 |
catch(Exception ie){
|
|
|
600 |
ie.printStackTrace();
|
|
|
601 |
inventoryClient = inventoryServiceClient.getClient();
|
|
|
602 |
fulfillmentWarehouse = inventoryClient.getWarehouse(taOrder.getFulfilmentWarehouseId());
|
|
|
603 |
warehousesMap.put(fulfillmentWarehouse.getId(), fulfillmentWarehouse);
|
|
|
604 |
}
|
|
|
605 |
}
|
| 19224 |
manish.sha |
606 |
orderValuesMap.put("WarehouseType", fulfillmentWarehouse.getWarehouseType().toString());
|
|
|
607 |
orderValuesMap.put("Promised_Shipping", sdf.format(new Date(taOrder.getPromised_shipping_time())));
|
|
|
608 |
orderValuesMap.put("UnitPrice", rformatter.format(lineItem1.getUnit_price()));
|
|
|
609 |
orderValuesMap.put("Weight", formatter.format(lineItem1.getUnit_weight()));
|
|
|
610 |
if(itemsMap.containsKey(lineItem1.getItem_id())){
|
|
|
611 |
Item orderItem = itemsMap.get(lineItem1.getItem_id());
|
|
|
612 |
orderValuesMap.put("PackQuantity", orderItem.getPackQuantity()+"");
|
|
|
613 |
}else{
|
|
|
614 |
try{
|
|
|
615 |
Item orderItem = client.getItem(lineItem1.getItem_id());
|
|
|
616 |
orderValuesMap.put("PackQuantity", orderItem.getPackQuantity()+"");
|
|
|
617 |
itemsMap.put(orderItem.getId(), orderItem);
|
|
|
618 |
}catch(Exception ce){
|
|
|
619 |
ce.printStackTrace();
|
|
|
620 |
client = new CatalogClient().getClient();
|
|
|
621 |
Item orderItem = client.getItem(lineItem1.getItem_id());
|
|
|
622 |
orderValuesMap.put("PackQuantity", orderItem.getPackQuantity()+"");
|
|
|
623 |
itemsMap.put(orderItem.getId(), orderItem);
|
|
|
624 |
}
|
|
|
625 |
}
|
|
|
626 |
}
|
|
|
627 |
if(orderValuesMap!=null && orderValuesMap.size()>0){
|
|
|
628 |
acceptTogetherOrdersMap.put(taOrder.getId(), orderValuesMap);
|
|
|
629 |
}
|
|
|
630 |
}
|
|
|
631 |
}
|
|
|
632 |
}
|
|
|
633 |
|
|
|
634 |
if(t_order.isSetLogisticsTransactionId()){
|
|
|
635 |
billTogetherOrdersMap = new HashMap<Long, Map<String, String>>();
|
|
|
636 |
Map<String, String> orderValuesMap = new HashMap<String, String>();
|
|
|
637 |
if(t_order.getStatus()==OrderStatus.ACCEPTED || t_order.getStatus()==OrderStatus.RTO_IN_TRANSIT ){
|
|
|
638 |
orderValuesMap.put("ProductName", getItemDisplayName(lineItem));
|
|
|
639 |
orderValuesMap.put("Quantity", lineItem.getQuantity()+"");
|
|
|
640 |
if(ItemType.SERIALIZED==item.getType()){
|
|
|
641 |
orderValuesMap.put("IsSerialized", "true");
|
|
|
642 |
}else{
|
|
|
643 |
orderValuesMap.put("IsSerialized", "false");
|
|
|
644 |
}
|
|
|
645 |
if(t_order.isSetFreebieItemId() && t_order.getFreebieItemId()!=0){
|
|
|
646 |
orderValuesMap.put("IsFreebie", "true");
|
|
|
647 |
} else {
|
|
|
648 |
orderValuesMap.put("IsFreebie", "false");
|
|
|
649 |
}
|
|
|
650 |
billTogetherOrdersMap.put(t_order.getId(), orderValuesMap);
|
| 22695 |
amit.gupta |
651 |
logger.info("order Values Map- "+ orderValuesMap);
|
| 19224 |
manish.sha |
652 |
}
|
|
|
653 |
|
|
|
654 |
List<in.shop2020.model.v1.order.Order> taOrders = null;
|
|
|
655 |
try{
|
|
|
656 |
taOrders = tClient.getGroupOrdersByLogisticsTxnId(t_order.getLogisticsTransactionId());
|
|
|
657 |
}catch(Exception te){
|
|
|
658 |
tClient = new TransactionClient().getClient();
|
|
|
659 |
taOrders = tClient.getGroupOrdersByLogisticsTxnId(t_order.getLogisticsTransactionId());
|
|
|
660 |
}
|
|
|
661 |
|
|
|
662 |
for(in.shop2020.model.v1.order.Order taOrder: taOrders){
|
|
|
663 |
if(taOrder.getStatus()==OrderStatus.ACCEPTED || taOrder.getStatus()==OrderStatus.RTO_IN_TRANSIT ){
|
|
|
664 |
if(taOrder.getId()==t_order.getId()){
|
|
|
665 |
continue;
|
|
|
666 |
} else {
|
|
|
667 |
orderValuesMap = new HashMap<String, String>();
|
|
|
668 |
Item orderItem = null;
|
|
|
669 |
if(itemsMap.containsKey(taOrder.getLineitems().get(0).getItem_id())){
|
| 19296 |
manish.sha |
670 |
orderItem = itemsMap.get(taOrder.getLineitems().get(0).getItem_id());
|
| 19224 |
manish.sha |
671 |
}else{
|
|
|
672 |
try{
|
|
|
673 |
orderItem = client.getItem(taOrder.getLineitems().get(0).getItem_id());
|
|
|
674 |
itemsMap.put(orderItem.getId(), orderItem);
|
|
|
675 |
}catch(Exception ce){
|
|
|
676 |
ce.printStackTrace();
|
|
|
677 |
client = new CatalogClient().getClient();
|
|
|
678 |
orderItem = client.getItem(taOrder.getLineitems().get(0).getItem_id());
|
|
|
679 |
itemsMap.put(orderItem.getId(), orderItem);
|
|
|
680 |
}
|
|
|
681 |
}
|
|
|
682 |
|
|
|
683 |
orderValuesMap.put("ProductName", getProductName(orderItem));
|
|
|
684 |
orderValuesMap.put("Quantity", taOrder.getLineitems().get(0).getQuantity()+"");
|
|
|
685 |
if(ItemType.SERIALIZED==orderItem.getType()){
|
|
|
686 |
orderValuesMap.put("IsSerialized", "true");
|
|
|
687 |
}else{
|
|
|
688 |
orderValuesMap.put("IsSerialized", "false");
|
|
|
689 |
}
|
|
|
690 |
if(taOrder.isSetFreebieItemId() && taOrder.getFreebieItemId()!=0){
|
|
|
691 |
orderValuesMap.put("IsFreebie", "true");
|
|
|
692 |
} else {
|
|
|
693 |
orderValuesMap.put("IsFreebie", "false");
|
|
|
694 |
}
|
|
|
695 |
billTogetherOrdersMap.put(taOrder.getId(), orderValuesMap);
|
|
|
696 |
}
|
|
|
697 |
}
|
|
|
698 |
}
|
|
|
699 |
|
|
|
700 |
}else{
|
|
|
701 |
billTogetherOrdersMap = new HashMap<Long, Map<String, String>>();
|
|
|
702 |
Map<String, String> orderValuesMap = new HashMap<String, String>();
|
|
|
703 |
orderValuesMap.put("ProductName", getItemDisplayName(lineItem));
|
|
|
704 |
orderValuesMap.put("Quantity", lineItem.getQuantity()+"");
|
|
|
705 |
if(ItemType.SERIALIZED==item.getType()){
|
|
|
706 |
orderValuesMap.put("IsSerialized", "true");
|
|
|
707 |
}else{
|
|
|
708 |
orderValuesMap.put("IsSerialized", "false");
|
|
|
709 |
}
|
|
|
710 |
if(t_order.isSetFreebieItemId() && t_order.getFreebieItemId()!=0){
|
|
|
711 |
orderValuesMap.put("IsFreebie", "true");
|
|
|
712 |
} else {
|
|
|
713 |
orderValuesMap.put("IsFreebie", "false");
|
|
|
714 |
}
|
|
|
715 |
billTogetherOrdersMap.put(t_order.getId(), orderValuesMap);
|
|
|
716 |
}
|
|
|
717 |
String delayReason = null;
|
|
|
718 |
if(t_order.getDelayReason() != null)
|
|
|
719 |
delayReason = t_order.getDelayReason().name();
|
|
|
720 |
|
|
|
721 |
String osource = OrderSource.findByValue((int)t_order.getSource()).toString();
|
|
|
722 |
|
|
|
723 |
Order order = new Order(t_order.getId(),
|
|
|
724 |
t_order.getCustomer_id(),
|
|
|
725 |
t_order.getCustomer_name(),
|
|
|
726 |
t_order.getCustomer_mobilenumber(),
|
|
|
727 |
t_order.getCustomer_pincode(),
|
|
|
728 |
t_order.getCustomer_address1(),
|
|
|
729 |
t_order.getCustomer_address2(),
|
|
|
730 |
t_order.getCustomer_city(),
|
|
|
731 |
t_order.getCustomer_state(),
|
|
|
732 |
t_order.getCustomer_email(),
|
|
|
733 |
t_order.getCreated_timestamp(),
|
|
|
734 |
t_order.getShipping_timestamp(),
|
|
|
735 |
t_order.getVerification_timestamp(),
|
|
|
736 |
t_order.getExpected_delivery_time(),
|
|
|
737 |
t_order.getPromised_delivery_time(),
|
|
|
738 |
t_order.getExpected_shipping_time(),
|
|
|
739 |
t_order.getPromised_shipping_time(),
|
|
|
740 |
t_order.getStatus().getValue(),
|
|
|
741 |
t_order.getStatusDescription(),
|
|
|
742 |
t_order.getOrderType().name(),
|
|
|
743 |
lineItem.getItem_id(),
|
|
|
744 |
lineItem.getProductGroup(),
|
|
|
745 |
lineItem.getBrand(),
|
|
|
746 |
lineItem.getModel_name(),
|
|
|
747 |
lineItem.getModel_number(),
|
|
|
748 |
lineItem.getColor(),
|
|
|
749 |
lineItem.getExtra_info(),
|
|
|
750 |
lineItem.getDealText(),
|
|
|
751 |
lineItem.getQuantity(),
|
|
|
752 |
t_order.getTotal_amount(),
|
|
|
753 |
t_order.getTotal_weight(),
|
|
|
754 |
t_order.getAirwaybill_no(),
|
|
|
755 |
t_order.getBilled_by(),
|
|
|
756 |
t_order.getInvoice_number(),
|
|
|
757 |
t_order.getJacket_number(),
|
|
|
758 |
lineItem.getItem_number(),
|
|
|
759 |
lineItem.getSerial_number(),
|
|
|
760 |
t_order.getBatchNo(),
|
|
|
761 |
t_order.getSerialNo(),
|
|
|
762 |
t_order.isDoaFlag(),
|
|
|
763 |
t_order.getPickupRequestNo(),
|
|
|
764 |
t_order.isLogisticsCod(),
|
|
|
765 |
delayReason,
|
|
|
766 |
pickFromWarehouse,
|
|
|
767 |
ItemType.SERIALIZED.equals(item.getType()),
|
|
|
768 |
item.isHasItemNo(),
|
|
|
769 |
t_order.getFulfilmentWarehouseId(),
|
|
|
770 |
t_order.getWarehouse_id(),
|
|
|
771 |
t_order.getPickupStoreId(),
|
|
|
772 |
t_order.getFreebieItemId(),
|
|
|
773 |
osource,
|
|
|
774 |
new Long(t_order.getProductCondition().getValue()),
|
|
|
775 |
t_order.getTransactionId());
|
|
|
776 |
if(acceptTogetherOrdersMap!=null && acceptTogetherOrdersMap.size()>0){
|
|
|
777 |
order.setAcceptTogetherOrdersMap(acceptTogetherOrdersMap);
|
|
|
778 |
}
|
|
|
779 |
if(billTogetherOrdersMap!=null && billTogetherOrdersMap.size()>0){
|
|
|
780 |
order.setBillTogetherOrdersMap(billTogetherOrdersMap);
|
|
|
781 |
}
|
|
|
782 |
if(t_order.isSetLogisticsTransactionId()){
|
|
|
783 |
order.setLogisticsTransactionId(t_order.getLogisticsTransactionId());
|
|
|
784 |
}
|
|
|
785 |
|
|
|
786 |
|
|
|
787 |
long currentDateTime = 0;
|
|
|
788 |
long promisedShippingTime =0 ;
|
|
|
789 |
long currentTime = date.getTime();
|
|
|
790 |
try{
|
|
|
791 |
currentDateTime = newSdf.parse(newSdf.format(date)).getTime();
|
|
|
792 |
promisedShippingTime = newSdf.parse(newSdf.format(new Date(order.getPromisedShippingTime()))).getTime();
|
|
|
793 |
}catch(Exception e){
|
| 22729 |
amit.gupta |
794 |
logger.error("Error formatting date for order" + order.getOrderId());
|
|
|
795 |
logger.error("Error formatting date " + date.getTime());
|
|
|
796 |
logger.error("Error formatting date " + order.getPromisedShippingTime());
|
| 19224 |
manish.sha |
797 |
e.printStackTrace();
|
|
|
798 |
}
|
|
|
799 |
if(promisedShippingTime >0 && (order.getStatus()==3 || order.getStatus()==5 || order.getStatus()==41 ||
|
|
|
800 |
order.getStatus()==35 || order.getStatus()==36 || order.getStatus()==37)){
|
|
|
801 |
if(promisedShippingTime <= currentDateTime){
|
|
|
802 |
if(loadVirtualWarehouseDetails().contains(order.getFulfilmentWarehouseId())){
|
|
|
803 |
order.setAlert(OrderAlert.TODAY_SHIPPING_NOT_IN_STOCK);
|
|
|
804 |
}else{
|
|
|
805 |
order.setAlert(OrderAlert.TODAY_SHIPPING_IN_STOCK);
|
|
|
806 |
}
|
|
|
807 |
}else{
|
|
|
808 |
if(!loadVirtualWarehouseDetails().contains(order.getFulfilmentWarehouseId())){
|
|
|
809 |
order.setAlert(OrderAlert.LATER_SHIPPING_IN_STOCK);
|
|
|
810 |
}
|
|
|
811 |
}
|
|
|
812 |
}
|
|
|
813 |
|
|
|
814 |
ordersToReturn.add(order);
|
|
|
815 |
}
|
|
|
816 |
}
|
|
|
817 |
catch (Exception e) {
|
|
|
818 |
e.printStackTrace();
|
|
|
819 |
}
|
|
|
820 |
|
|
|
821 |
return ordersToReturn;
|
|
|
822 |
|
|
|
823 |
}
|
|
|
824 |
|
|
|
825 |
|
| 671 |
chandransh |
826 |
/**
|
| 2449 |
chandransh |
827 |
*
|
| 671 |
chandransh |
828 |
* @param t_order
|
| 2449 |
chandransh |
829 |
* A thrift order object with line items.
|
|
|
830 |
* @return an Order bean which can be used for rendering on the client side.
|
| 671 |
chandransh |
831 |
*/
|
|
|
832 |
public static Order getOrderFromThriftOrder(in.shop2020.model.v1.order.Order t_order) {
|
| 914 |
chandransh |
833 |
LineItem lineItem = t_order.getLineitems().get(0);
|
| 5110 |
mandeep.dh |
834 |
String pickFromWarehouse = null;
|
|
|
835 |
Item item = null;
|
| 19004 |
manish.sha |
836 |
String warehouseType = "";
|
| 13146 |
manish.sha |
837 |
|
|
|
838 |
Map<Long, Map<String, String>> acceptTogetherOrdersMap = null;
|
|
|
839 |
Map<Long, Map<String, String>> billTogetherOrdersMap = null;
|
| 5110 |
mandeep.dh |
840 |
|
|
|
841 |
try {
|
| 5945 |
mandeep.dh |
842 |
in.shop2020.model.v1.catalog.CatalogService.Client client = new CatalogClient().getClient();
|
| 5948 |
mandeep.dh |
843 |
in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = new InventoryClient().getClient();
|
| 5110 |
mandeep.dh |
844 |
item = client.getItem(lineItem.getItem_id());
|
| 20830 |
amit.gupta |
845 |
pickFromWarehouse = CatalogUtils.getWarehousesForBillingWarehouse(0)
|
| 5110 |
mandeep.dh |
846 |
.get(t_order.getFulfilmentWarehouseId());
|
|
|
847 |
|
|
|
848 |
if (pickFromWarehouse == null) {
|
| 5948 |
mandeep.dh |
849 |
Warehouse warehouse = inventoryClient.getWarehouse(t_order.getFulfilmentWarehouseId());
|
|
|
850 |
pickFromWarehouse = inventoryClient.getWarehouses(null, InventoryType.GOOD, warehouse.getVendor().getId(), t_order.getWarehouse_id(), 0).get(0).getDisplayName();
|
| 13146 |
manish.sha |
851 |
}
|
|
|
852 |
if(!t_order.isSetAccepted_timestamp()){
|
|
|
853 |
acceptTogetherOrdersMap = new HashMap<Long, Map<String, String>>();
|
|
|
854 |
Map<String, String> orderValuesMap = new HashMap<String, String>();
|
|
|
855 |
orderValuesMap.put("ProductName", getItemDisplayName(lineItem));
|
|
|
856 |
orderValuesMap.put("Quantity", lineItem.getQuantity()+"");
|
| 18100 |
manish.sha |
857 |
if(!inventoryClient.isAlive()){
|
|
|
858 |
inventoryClient = new InventoryClient().getClient();
|
|
|
859 |
}
|
|
|
860 |
Warehouse fulfillmentWarehouse = inventoryClient.getWarehouse(t_order.getFulfilmentWarehouseId());
|
| 19004 |
manish.sha |
861 |
warehouseType = fulfillmentWarehouse.getWarehouseType().toString();
|
| 18100 |
manish.sha |
862 |
orderValuesMap.put("WarehouseType", fulfillmentWarehouse.getWarehouseType().toString());
|
| 19054 |
manish.sha |
863 |
SimpleDateFormat sdf = new SimpleDateFormat("EEE MMM dd HH:mm:ss yyyy");
|
| 18938 |
manish.sha |
864 |
orderValuesMap.put("Promised_Shipping", sdf.format(new Date(t_order.getPromised_shipping_time())));
|
| 18964 |
manish.sha |
865 |
NumberFormat formatter = new DecimalFormat("#0.000");
|
|
|
866 |
orderValuesMap.put("Weight", formatter.format(t_order.getLineitems().get(0).getUnit_weight()));
|
|
|
867 |
formatter = new DecimalFormat("#0.00");
|
| 18938 |
manish.sha |
868 |
orderValuesMap.put("UnitPrice", formatter.format(t_order.getLineitems().get(0).getUnit_price()));
|
| 18964 |
manish.sha |
869 |
orderValuesMap.put("PackQuantity", item.getPackQuantity()+"");
|
| 13146 |
manish.sha |
870 |
acceptTogetherOrdersMap.put(t_order.getId(), orderValuesMap);
|
|
|
871 |
List<in.shop2020.model.v1.order.Order> taOrders = new TransactionClient().getClient().getOrdersForTransaction(t_order.getTransactionId(), t_order.getCustomer_id());
|
|
|
872 |
in.shop2020.logistics.Provider provider = new LogisticsClient().getClient().getProvider(t_order.getLogistics_provider_id());
|
|
|
873 |
for(in.shop2020.model.v1.order.Order taOrder : taOrders){
|
|
|
874 |
LineItem lineItem1 = taOrder.getLineitems().get(0);
|
|
|
875 |
if(t_order.getId()==taOrder.getId()){
|
|
|
876 |
continue;
|
| 13156 |
manish.sha |
877 |
}
|
|
|
878 |
else if(taOrder.getSource()!=OrderSource.WEBSITE.getValue()){
|
|
|
879 |
continue;
|
|
|
880 |
}
|
|
|
881 |
else{
|
| 13146 |
manish.sha |
882 |
orderValuesMap = new HashMap<String, String>();
|
| 13323 |
manish.sha |
883 |
if(provider.isGroupShipmentAllowed() && !taOrder.isSetAccepted_timestamp() && t_order.getStatus()==taOrder.getStatus()
|
|
|
884 |
&& taOrder.isLogisticsCod()==t_order.isLogisticsCod() && taOrder.getWarehouse_id() == t_order.getWarehouse_id()
|
|
|
885 |
&& taOrder.getOrderType() == t_order.getOrderType() && taOrder.getPickupStoreId() == t_order.getPickupStoreId()){
|
| 13146 |
manish.sha |
886 |
orderValuesMap.put("ProductName", getItemDisplayName(lineItem1));
|
|
|
887 |
orderValuesMap.put("Quantity", lineItem1.getQuantity()+"");
|
| 18100 |
manish.sha |
888 |
if(!inventoryClient.isAlive()){
|
|
|
889 |
inventoryClient = new InventoryClient().getClient();
|
|
|
890 |
}
|
|
|
891 |
fulfillmentWarehouse = inventoryClient.getWarehouse(taOrder.getFulfilmentWarehouseId());
|
|
|
892 |
orderValuesMap.put("WarehouseType", fulfillmentWarehouse.getWarehouseType().toString());
|
| 18938 |
manish.sha |
893 |
orderValuesMap.put("Promised_Shipping", sdf.format(new Date(taOrder.getPromised_shipping_time())));
|
|
|
894 |
orderValuesMap.put("UnitPrice", formatter.format(taOrder.getLineitems().get(0).getUnit_price()));
|
| 18964 |
manish.sha |
895 |
formatter = new DecimalFormat("#0.000");
|
|
|
896 |
orderValuesMap.put("Weight", formatter.format(taOrder.getLineitems().get(0).getUnit_weight()));
|
|
|
897 |
Item orderItem = client.getItem(taOrder.getLineitems().get(0).getItem_id());
|
|
|
898 |
orderValuesMap.put("PackQuantity", orderItem.getPackQuantity()+"");
|
| 13146 |
manish.sha |
899 |
}
|
|
|
900 |
if(orderValuesMap!=null && orderValuesMap.size()>0){
|
|
|
901 |
acceptTogetherOrdersMap.put(taOrder.getId(), orderValuesMap);
|
|
|
902 |
}
|
|
|
903 |
}
|
|
|
904 |
}
|
| 5110 |
mandeep.dh |
905 |
}
|
| 13146 |
manish.sha |
906 |
|
|
|
907 |
if(t_order.isSetLogisticsTransactionId()){
|
|
|
908 |
billTogetherOrdersMap = new HashMap<Long, Map<String, String>>();
|
|
|
909 |
Map<String, String> orderValuesMap = new HashMap<String, String>();
|
| 19091 |
manish.sha |
910 |
if(t_order.getStatus()==OrderStatus.ACCEPTED || t_order.getStatus()==OrderStatus.RTO_IN_TRANSIT ){
|
| 18100 |
manish.sha |
911 |
orderValuesMap.put("ProductName", getItemDisplayName(lineItem));
|
|
|
912 |
orderValuesMap.put("Quantity", lineItem.getQuantity()+"");
|
|
|
913 |
if(ItemType.SERIALIZED==item.getType()){
|
|
|
914 |
orderValuesMap.put("IsSerialized", "true");
|
|
|
915 |
}else{
|
|
|
916 |
orderValuesMap.put("IsSerialized", "false");
|
|
|
917 |
}
|
|
|
918 |
if(t_order.isSetFreebieItemId() && t_order.getFreebieItemId()!=0){
|
|
|
919 |
orderValuesMap.put("IsFreebie", "true");
|
|
|
920 |
} else {
|
|
|
921 |
orderValuesMap.put("IsFreebie", "false");
|
|
|
922 |
}
|
|
|
923 |
billTogetherOrdersMap.put(t_order.getId(), orderValuesMap);
|
| 13146 |
manish.sha |
924 |
}
|
|
|
925 |
Map<Long, Item> orderItemMap = new HashMap<Long, Item>();
|
|
|
926 |
List<in.shop2020.model.v1.order.Order> taOrders = new TransactionClient().getClient().getGroupOrdersByLogisticsTxnId(t_order.getLogisticsTransactionId());
|
|
|
927 |
for(in.shop2020.model.v1.order.Order ord1: taOrders){
|
| 19091 |
manish.sha |
928 |
if(ord1.getStatus()==OrderStatus.ACCEPTED || ord1.getStatus()==OrderStatus.RTO_IN_TRANSIT ){
|
| 18100 |
manish.sha |
929 |
if(ord1.getId()== t_order.getId()){
|
|
|
930 |
orderItemMap.put(ord1.getId(), item);
|
|
|
931 |
} else {
|
|
|
932 |
if(!client.isAlive()){
|
|
|
933 |
client = new CatalogClient().getClient();
|
|
|
934 |
}
|
|
|
935 |
Item it = client.getItem(ord1.getLineitems().get(0).getItem_id());
|
|
|
936 |
orderItemMap.put(ord1.getId(), it);
|
| 13146 |
manish.sha |
937 |
}
|
|
|
938 |
}
|
|
|
939 |
}
|
|
|
940 |
|
|
|
941 |
for(in.shop2020.model.v1.order.Order taOrder: taOrders){
|
| 19091 |
manish.sha |
942 |
if(taOrder.getStatus()==OrderStatus.ACCEPTED || taOrder.getStatus()==OrderStatus.RTO_IN_TRANSIT ){
|
| 18100 |
manish.sha |
943 |
if(taOrder.getId()==t_order.getId()){
|
|
|
944 |
continue;
|
|
|
945 |
} else {
|
|
|
946 |
orderValuesMap = new HashMap<String, String>();
|
|
|
947 |
Item orderItem = orderItemMap.get(taOrder.getId());
|
|
|
948 |
orderValuesMap.put("ProductName", getProductName(orderItem));
|
|
|
949 |
orderValuesMap.put("Quantity", taOrder.getLineitems().get(0).getQuantity()+"");
|
|
|
950 |
if(ItemType.SERIALIZED==orderItem.getType()){
|
|
|
951 |
orderValuesMap.put("IsSerialized", "true");
|
|
|
952 |
}else{
|
|
|
953 |
orderValuesMap.put("IsSerialized", "false");
|
|
|
954 |
}
|
|
|
955 |
if(taOrder.isSetFreebieItemId() && taOrder.getFreebieItemId()!=0){
|
|
|
956 |
orderValuesMap.put("IsFreebie", "true");
|
|
|
957 |
} else {
|
|
|
958 |
orderValuesMap.put("IsFreebie", "false");
|
|
|
959 |
}
|
|
|
960 |
billTogetherOrdersMap.put(taOrder.getId(), orderValuesMap);
|
|
|
961 |
}
|
| 13146 |
manish.sha |
962 |
}
|
|
|
963 |
}
|
|
|
964 |
}
|
|
|
965 |
else{
|
|
|
966 |
billTogetherOrdersMap = new HashMap<Long, Map<String, String>>();
|
|
|
967 |
Map<String, String> orderValuesMap = new HashMap<String, String>();
|
|
|
968 |
orderValuesMap.put("ProductName", getItemDisplayName(lineItem));
|
|
|
969 |
orderValuesMap.put("Quantity", lineItem.getQuantity()+"");
|
|
|
970 |
if(ItemType.SERIALIZED==item.getType()){
|
|
|
971 |
orderValuesMap.put("IsSerialized", "true");
|
|
|
972 |
}else{
|
|
|
973 |
orderValuesMap.put("IsSerialized", "false");
|
|
|
974 |
}
|
|
|
975 |
if(t_order.isSetFreebieItemId() && t_order.getFreebieItemId()!=0){
|
|
|
976 |
orderValuesMap.put("IsFreebie", "true");
|
|
|
977 |
} else {
|
|
|
978 |
orderValuesMap.put("IsFreebie", "false");
|
|
|
979 |
}
|
|
|
980 |
billTogetherOrdersMap.put(t_order.getId(), orderValuesMap);
|
|
|
981 |
}
|
| 5110 |
mandeep.dh |
982 |
}
|
|
|
983 |
catch (Exception e) {
|
|
|
984 |
logger.error("Error looking up warehouse: " + t_order.getVendorId(), e);
|
|
|
985 |
}
|
|
|
986 |
|
| 3553 |
chandransh |
987 |
String delayReason = null;
|
|
|
988 |
if(t_order.getDelayReason() != null)
|
| 7433 |
rajveer |
989 |
delayReason = t_order.getDelayReason().name();
|
| 3553 |
chandransh |
990 |
|
| 7556 |
rajveer |
991 |
String osource = OrderSource.findByValue((int)t_order.getSource()).toString();
|
| 7433 |
rajveer |
992 |
|
| 966 |
chandransh |
993 |
Order order = new Order(t_order.getId(),
|
|
|
994 |
t_order.getCustomer_id(),
|
|
|
995 |
t_order.getCustomer_name(),
|
|
|
996 |
t_order.getCustomer_mobilenumber(),
|
|
|
997 |
t_order.getCustomer_pincode(),
|
|
|
998 |
t_order.getCustomer_address1(),
|
|
|
999 |
t_order.getCustomer_address2(),
|
|
|
1000 |
t_order.getCustomer_city(),
|
|
|
1001 |
t_order.getCustomer_state(),
|
|
|
1002 |
t_order.getCustomer_email(),
|
|
|
1003 |
t_order.getCreated_timestamp(),
|
| 4004 |
chandransh |
1004 |
t_order.getShipping_timestamp(),
|
|
|
1005 |
t_order.getVerification_timestamp(),
|
| 966 |
chandransh |
1006 |
t_order.getExpected_delivery_time(),
|
| 3994 |
chandransh |
1007 |
t_order.getPromised_delivery_time(),
|
| 4004 |
chandransh |
1008 |
t_order.getExpected_shipping_time(),
|
| 4666 |
rajveer |
1009 |
t_order.getPromised_shipping_time(),
|
| 966 |
chandransh |
1010 |
t_order.getStatus().getValue(),
|
|
|
1011 |
t_order.getStatusDescription(),
|
| 5527 |
anupam.sin |
1012 |
t_order.getOrderType().name(),
|
| 966 |
chandransh |
1013 |
lineItem.getItem_id(),
|
|
|
1014 |
lineItem.getProductGroup(),
|
|
|
1015 |
lineItem.getBrand(),
|
|
|
1016 |
lineItem.getModel_name(),
|
|
|
1017 |
lineItem.getModel_number(),
|
|
|
1018 |
lineItem.getColor(),
|
|
|
1019 |
lineItem.getExtra_info(),
|
| 4172 |
rajveer |
1020 |
lineItem.getDealText(),
|
| 5387 |
rajveer |
1021 |
lineItem.getQuantity(),
|
| 2782 |
chandransh |
1022 |
t_order.getTotal_amount(),
|
|
|
1023 |
t_order.getTotal_weight(),
|
|
|
1024 |
t_order.getAirwaybill_no(),
|
|
|
1025 |
t_order.getBilled_by(),
|
|
|
1026 |
t_order.getInvoice_number(),
|
|
|
1027 |
t_order.getJacket_number(),
|
|
|
1028 |
lineItem.getItem_number(),
|
| 4659 |
mandeep.dh |
1029 |
lineItem.getSerial_number(),
|
| 3065 |
chandransh |
1030 |
t_order.getBatchNo(),
|
|
|
1031 |
t_order.getSerialNo(),
|
| 2509 |
chandransh |
1032 |
t_order.isDoaFlag(),
|
| 3065 |
chandransh |
1033 |
t_order.getPickupRequestNo(),
|
| 5556 |
rajveer |
1034 |
t_order.isLogisticsCod(),
|
| 5110 |
mandeep.dh |
1035 |
delayReason,
|
|
|
1036 |
pickFromWarehouse,
|
| 6028 |
rajveer |
1037 |
ItemType.SERIALIZED.equals(item.getType()),
|
|
|
1038 |
item.isHasItemNo(),
|
| 5769 |
rajveer |
1039 |
t_order.getFulfilmentWarehouseId(),
|
| 9263 |
amar.kumar |
1040 |
t_order.getWarehouse_id(),
|
| 7190 |
amar.kumar |
1041 |
t_order.getPickupStoreId(),
|
| 7422 |
rajveer |
1042 |
t_order.getFreebieItemId(),
|
| 8717 |
amar.kumar |
1043 |
osource,
|
| 13146 |
manish.sha |
1044 |
new Long(t_order.getProductCondition().getValue()),
|
|
|
1045 |
t_order.getTransactionId());
|
|
|
1046 |
if(acceptTogetherOrdersMap!=null && acceptTogetherOrdersMap.size()>0){
|
|
|
1047 |
order.setAcceptTogetherOrdersMap(acceptTogetherOrdersMap);
|
|
|
1048 |
}
|
|
|
1049 |
if(billTogetherOrdersMap!=null && billTogetherOrdersMap.size()>0){
|
|
|
1050 |
order.setBillTogetherOrdersMap(billTogetherOrdersMap);
|
|
|
1051 |
}
|
|
|
1052 |
if(t_order.isSetLogisticsTransactionId()){
|
|
|
1053 |
order.setLogisticsTransactionId(t_order.getLogisticsTransactionId());
|
|
|
1054 |
}
|
| 19054 |
manish.sha |
1055 |
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
| 19032 |
manish.sha |
1056 |
Date date = new Date(System.currentTimeMillis());
|
|
|
1057 |
long currentDateTime = 0;
|
| 19196 |
manish.sha |
1058 |
long promisedShippingTime =0 ;
|
| 19032 |
manish.sha |
1059 |
long currentTime = date.getTime();
|
| 19054 |
manish.sha |
1060 |
try{
|
|
|
1061 |
currentDateTime = sdf.parse(sdf.format(date)).getTime();
|
| 19196 |
manish.sha |
1062 |
promisedShippingTime = sdf.parse(sdf.format(new Date(order.getPromisedShippingTime()))).getTime();
|
| 19054 |
manish.sha |
1063 |
}catch(Exception e){
|
|
|
1064 |
e.printStackTrace();
|
|
|
1065 |
}
|
| 19196 |
manish.sha |
1066 |
if(promisedShippingTime >0 && (order.getStatus()==3 || order.getStatus()==5 || order.getStatus()==41 ||
|
| 19058 |
manish.sha |
1067 |
order.getStatus()==35 || order.getStatus()==36 || order.getStatus()==37)){
|
| 19196 |
manish.sha |
1068 |
if(promisedShippingTime <= currentDateTime){
|
| 19050 |
manish.sha |
1069 |
if(loadVirtualWarehouseDetails().contains(order.getFulfilmentWarehouseId())){
|
| 19032 |
manish.sha |
1070 |
order.setAlert(OrderAlert.TODAY_SHIPPING_NOT_IN_STOCK);
|
|
|
1071 |
}else{
|
|
|
1072 |
order.setAlert(OrderAlert.TODAY_SHIPPING_IN_STOCK);
|
|
|
1073 |
}
|
|
|
1074 |
}else{
|
| 19162 |
manish.sha |
1075 |
if(!loadVirtualWarehouseDetails().contains(order.getFulfilmentWarehouseId())){
|
| 19164 |
manish.sha |
1076 |
order.setAlert(OrderAlert.LATER_SHIPPING_IN_STOCK);
|
| 19032 |
manish.sha |
1077 |
}
|
|
|
1078 |
}
|
|
|
1079 |
}
|
| 966 |
chandransh |
1080 |
return order;
|
| 671 |
chandransh |
1081 |
}
|
|
|
1082 |
|
| 2449 |
chandransh |
1083 |
/**
|
| 2697 |
chandransh |
1084 |
* Queries the transction server to get the list of all return orders that
|
|
|
1085 |
* have to be processed.
|
|
|
1086 |
*
|
|
|
1087 |
* @return A list of all return orders to be processed.
|
|
|
1088 |
*/
|
|
|
1089 |
public static List<ReturnOrder> getReturnOrders(long warehouseId){
|
|
|
1090 |
List<ReturnOrder> retOrders = new ArrayList<ReturnOrder>();
|
|
|
1091 |
try{
|
| 3132 |
rajveer |
1092 |
TransactionClient client = new TransactionClient();
|
| 2697 |
chandransh |
1093 |
Client c = client.getClient();
|
|
|
1094 |
List<in.shop2020.model.v1.order.ReturnOrder> tRetOrders = c.getReturnOrders(warehouseId, 0L, new Date().getTime());
|
|
|
1095 |
for(in.shop2020.model.v1.order.ReturnOrder retOrder : tRetOrders){
|
|
|
1096 |
retOrders.add(getReturnOrderFromThriftRO(retOrder));
|
|
|
1097 |
}
|
|
|
1098 |
}catch(Exception e){
|
|
|
1099 |
e.printStackTrace();
|
|
|
1100 |
}
|
|
|
1101 |
return retOrders;
|
|
|
1102 |
}
|
|
|
1103 |
|
| 2700 |
chandransh |
1104 |
public static ReturnOrder getReturnOrderFromThriftRO(in.shop2020.model.v1.order.ReturnOrder tRetOrder){
|
|
|
1105 |
ReturnOrder retOrder = new ReturnOrder(tRetOrder.getOrderId(),
|
|
|
1106 |
tRetOrder.getWarehouseId(),
|
|
|
1107 |
tRetOrder.getItemId(),
|
|
|
1108 |
tRetOrder.getProductGroup(),
|
|
|
1109 |
tRetOrder.getBrand(),
|
|
|
1110 |
tRetOrder.getModelName(),
|
|
|
1111 |
tRetOrder.getModelNumber(),
|
|
|
1112 |
tRetOrder.getColor(),
|
|
|
1113 |
tRetOrder.getInvoiceNumber(),
|
|
|
1114 |
tRetOrder.getJacketNumber(),
|
|
|
1115 |
tRetOrder.getTotalPrice(),
|
|
|
1116 |
tRetOrder.getTransferPrice(),
|
|
|
1117 |
false,
|
|
|
1118 |
tRetOrder.getCreatedAt());
|
| 2697 |
chandransh |
1119 |
return retOrder;
|
|
|
1120 |
}
|
|
|
1121 |
|
|
|
1122 |
/**
|
| 2449 |
chandransh |
1123 |
* This method maps a given type to a list of statuses.
|
|
|
1124 |
*
|
|
|
1125 |
* @param type
|
|
|
1126 |
* The type of orders to fetch.
|
|
|
1127 |
* @return The list of Thrift statuses associated with a particular order
|
|
|
1128 |
* type.
|
|
|
1129 |
*/
|
| 4361 |
rajveer |
1130 |
public static List<OrderStatus> getStatuses(OrderType type) {
|
| 2449 |
chandransh |
1131 |
List<OrderStatus> statuses = new ArrayList<OrderStatus>();
|
|
|
1132 |
|
|
|
1133 |
switch (type) {
|
|
|
1134 |
case ACCEPTED:
|
|
|
1135 |
statuses.add(OrderStatus.ACCEPTED);
|
|
|
1136 |
break;
|
|
|
1137 |
|
| 4361 |
rajveer |
1138 |
case ALL_PENDING:
|
|
|
1139 |
statuses.add(OrderStatus.SUBMITTED_FOR_PROCESSING);
|
| 4421 |
mandeep.dh |
1140 |
statuses.add(OrderStatus.CAPTURE_IN_PROCESS);
|
| 4361 |
rajveer |
1141 |
statuses.add(OrderStatus.INVENTORY_LOW);
|
|
|
1142 |
statuses.add(OrderStatus.LOW_INV_PO_RAISED);
|
|
|
1143 |
statuses.add(OrderStatus.LOW_INV_REVERSAL_IN_PROCESS);
|
|
|
1144 |
statuses.add(OrderStatus.LOW_INV_NOT_AVAILABLE_AT_HOTSPOT);
|
| 2449 |
chandransh |
1145 |
break;
|
|
|
1146 |
|
|
|
1147 |
case NEW:
|
|
|
1148 |
statuses.add(OrderStatus.SUBMITTED_FOR_PROCESSING);
|
| 4421 |
mandeep.dh |
1149 |
statuses.add(OrderStatus.CAPTURE_IN_PROCESS);
|
| 2449 |
chandransh |
1150 |
break;
|
|
|
1151 |
|
|
|
1152 |
case BILLED:
|
|
|
1153 |
statuses.add(OrderStatus.BILLED);
|
|
|
1154 |
break;
|
|
|
1155 |
|
| 4308 |
rajveer |
1156 |
case LOW_INVENTORY:
|
| 2449 |
chandransh |
1157 |
statuses.add(OrderStatus.INVENTORY_LOW);
|
|
|
1158 |
break;
|
| 4248 |
rajveer |
1159 |
|
| 4308 |
rajveer |
1160 |
case PO_RAISED:
|
|
|
1161 |
statuses.add(OrderStatus.LOW_INV_PO_RAISED);
|
|
|
1162 |
break;
|
|
|
1163 |
|
|
|
1164 |
case REVERSAL_INITIATED:
|
|
|
1165 |
statuses.add(OrderStatus.LOW_INV_REVERSAL_IN_PROCESS);
|
|
|
1166 |
break;
|
|
|
1167 |
|
|
|
1168 |
case NOT_AVAILABLE:
|
|
|
1169 |
statuses.add(OrderStatus.LOW_INV_NOT_AVAILABLE_AT_HOTSPOT);
|
|
|
1170 |
break;
|
|
|
1171 |
|
| 4248 |
rajveer |
1172 |
case CANCEL_CONFIRMED:
|
|
|
1173 |
statuses.add(OrderStatus.CANCEL_REQUEST_CONFIRMED);
|
|
|
1174 |
break;
|
| 2449 |
chandransh |
1175 |
|
| 4459 |
rajveer |
1176 |
case DOA_REQUEST_AUTHORIZED:
|
|
|
1177 |
statuses.add(OrderStatus.DOA_REQUEST_AUTHORIZED);
|
| 4515 |
mandeep.dh |
1178 |
statuses.add(OrderStatus.DOA_PICKUP_REQUEST_RAISED);
|
| 4459 |
rajveer |
1179 |
break;
|
|
|
1180 |
|
| 4666 |
rajveer |
1181 |
case LOST_IN_TRANSIT:
|
|
|
1182 |
statuses.add(OrderStatus.LOST_IN_TRANSIT);
|
|
|
1183 |
break;
|
|
|
1184 |
|
| 4459 |
rajveer |
1185 |
case DOA_LOST_IN_TRANSIT:
|
|
|
1186 |
statuses.add(OrderStatus.DOA_LOST_IN_TRANSIT);
|
| 4478 |
rajveer |
1187 |
break;
|
|
|
1188 |
|
|
|
1189 |
case DOA_RECEIVED_DAMAGED:
|
| 4459 |
rajveer |
1190 |
statuses.add(OrderStatus.DOA_RECEIVED_DAMAGED);
|
|
|
1191 |
break;
|
| 4495 |
rajveer |
1192 |
|
|
|
1193 |
case RET_REQUEST_AUTHORIZED:
|
|
|
1194 |
statuses.add(OrderStatus.RET_REQUEST_AUTHORIZED);
|
| 4515 |
mandeep.dh |
1195 |
statuses.add(OrderStatus.RET_PICKUP_REQUEST_RAISED);
|
| 4495 |
rajveer |
1196 |
break;
|
|
|
1197 |
|
|
|
1198 |
case RET_AWAITED:
|
|
|
1199 |
statuses.add(OrderStatus.RET_RETURN_IN_TRANSIT);
|
| 4515 |
mandeep.dh |
1200 |
statuses.add(OrderStatus.RET_PICKUP_CONFIRMED);
|
| 4495 |
rajveer |
1201 |
break;
|
| 4459 |
rajveer |
1202 |
|
| 4495 |
rajveer |
1203 |
case RET_RECEIVED_PRESTINE:
|
|
|
1204 |
statuses.add(OrderStatus.RET_RECEIVED_PRESTINE);
|
| 4515 |
mandeep.dh |
1205 |
statuses.add(OrderStatus.RET_PRODUCT_USABLE);
|
| 4495 |
rajveer |
1206 |
break;
|
|
|
1207 |
|
|
|
1208 |
case RET_LOST_IN_TRANSIT:
|
|
|
1209 |
statuses.add(OrderStatus.RET_LOST_IN_TRANSIT);
|
|
|
1210 |
break;
|
|
|
1211 |
|
|
|
1212 |
case RET_RECEIVED_DAMAGED:
|
|
|
1213 |
statuses.add(OrderStatus.RET_RECEIVED_DAMAGED);
|
| 4515 |
mandeep.dh |
1214 |
statuses.add(OrderStatus.RET_PRODUCT_UNUSABLE);
|
| 4495 |
rajveer |
1215 |
break;
|
|
|
1216 |
|
| 2449 |
chandransh |
1217 |
case REJECTED:
|
|
|
1218 |
statuses.add(OrderStatus.REJECTED);
|
|
|
1219 |
break;
|
|
|
1220 |
|
|
|
1221 |
case SHIPPED:
|
|
|
1222 |
statuses.add(OrderStatus.SHIPPED_FROM_WH);
|
|
|
1223 |
statuses.add(OrderStatus.SHIPPED_TO_LOGST);
|
| 5016 |
phani.kuma |
1224 |
statuses.add(OrderStatus.SHIPPED_TO_DESTINATION_CITY);
|
|
|
1225 |
statuses.add(OrderStatus.REACHED_DESTINATION_CITY);
|
|
|
1226 |
statuses.add(OrderStatus.FIRST_DELIVERY_ATTEMPT_MADE);
|
| 2449 |
chandransh |
1227 |
break;
|
|
|
1228 |
|
|
|
1229 |
case DELIVERED:
|
|
|
1230 |
statuses.add(OrderStatus.DELIVERY_SUCCESS);
|
| 4452 |
rajveer |
1231 |
statuses.add(OrderStatus.DOA_PICKUP_REQUEST_RAISED);
|
| 2449 |
chandransh |
1232 |
break;
|
| 2610 |
chandransh |
1233 |
|
|
|
1234 |
case DOA_AWAITED:
|
| 4452 |
rajveer |
1235 |
statuses.add(OrderStatus.DOA_PICKUP_CONFIRMED);
|
| 2610 |
chandransh |
1236 |
statuses.add(OrderStatus.DOA_RETURN_IN_TRANSIT);
|
| 4452 |
rajveer |
1237 |
statuses.add(OrderStatus.DOA_RECEIVED_PRESTINE);
|
| 2610 |
chandransh |
1238 |
break;
|
| 2449 |
chandransh |
1239 |
|
| 4495 |
rajveer |
1240 |
case RTO_AWAITED:
|
| 4484 |
rajveer |
1241 |
statuses.add(OrderStatus.RTO_IN_TRANSIT);
|
| 2509 |
chandransh |
1242 |
break;
|
|
|
1243 |
|
| 4515 |
mandeep.dh |
1244 |
case RTO_RECEIVED_DAMAGED:
|
|
|
1245 |
statuses.add(OrderStatus.RTO_RECEIVED_DAMAGED);
|
|
|
1246 |
break;
|
|
|
1247 |
|
|
|
1248 |
case DOA_RECEIVED_PRESTINE:
|
| 2610 |
chandransh |
1249 |
statuses.add(OrderStatus.DOA_CERT_VALID);
|
| 4515 |
mandeep.dh |
1250 |
statuses.add(OrderStatus.DOA_CERT_INVALID);
|
| 2610 |
chandransh |
1251 |
break;
|
|
|
1252 |
|
| 4495 |
rajveer |
1253 |
case RTO_RETURNED:
|
| 4484 |
rajveer |
1254 |
statuses.add(OrderStatus.RTO_RECEIVED_PRESTINE);
|
| 2509 |
chandransh |
1255 |
break;
|
|
|
1256 |
|
| 2628 |
chandransh |
1257 |
case RESHIPPED:
|
| 4484 |
rajveer |
1258 |
statuses.add(OrderStatus.RTO_RESHIPPED);
|
| 2628 |
chandransh |
1259 |
statuses.add(OrderStatus.DOA_INVALID_RESHIPPED);
|
| 4452 |
rajveer |
1260 |
statuses.add(OrderStatus.DOA_VALID_RESHIPPED);
|
| 2628 |
chandransh |
1261 |
break;
|
|
|
1262 |
|
|
|
1263 |
case REFUNDED:
|
| 4682 |
rajveer |
1264 |
statuses.add(OrderStatus.COD_VERIFICATION_FAILED);
|
| 4484 |
rajveer |
1265 |
statuses.add(OrderStatus.RTO_REFUNDED);
|
| 2628 |
chandransh |
1266 |
statuses.add(OrderStatus.DOA_INVALID_REFUNDED);
|
|
|
1267 |
statuses.add(OrderStatus.DOA_VALID_REFUNDED);
|
| 4682 |
rajveer |
1268 |
statuses.add(OrderStatus.CANCELLED_DUE_TO_LOW_INVENTORY);
|
| 2628 |
chandransh |
1269 |
break;
|
| 2509 |
chandransh |
1270 |
|
| 3065 |
chandransh |
1271 |
case VERIFICATION_PENDING:
|
| 4664 |
rajveer |
1272 |
statuses.add(OrderStatus.COD_VERIFICATION_PENDING);
|
| 3065 |
chandransh |
1273 |
break;
|
| 2449 |
chandransh |
1274 |
default:
|
|
|
1275 |
break;
|
|
|
1276 |
}
|
|
|
1277 |
return statuses;
|
|
|
1278 |
}
|
| 13146 |
manish.sha |
1279 |
|
|
|
1280 |
public static List<Long> getEligibleOrdersToBeAccepted(Order order){
|
|
|
1281 |
List<Long> orders = new ArrayList<Long>();
|
|
|
1282 |
try {
|
|
|
1283 |
|
|
|
1284 |
TransactionClient client = new TransactionClient();
|
|
|
1285 |
Client c = client.getClient();
|
|
|
1286 |
|
|
|
1287 |
in.shop2020.model.v1.order.Order thriftOrder = c.getOrder(order.getOrderId());
|
|
|
1288 |
long provider_id = thriftOrder.getLogistics_provider_id();
|
|
|
1289 |
boolean cod = thriftOrder.isLogisticsCod();
|
|
|
1290 |
|
|
|
1291 |
List<in.shop2020.model.v1.order.Order> torders = c.getOrdersForTransaction(thriftOrder.getTransactionId(), thriftOrder.getCustomer_id());
|
|
|
1292 |
for(in.shop2020.model.v1.order.Order torder: torders){
|
|
|
1293 |
if(torder.getLogistics_provider_id() == provider_id && torder.isLogisticsCod() == cod){
|
|
|
1294 |
orders.add(torder.getId());
|
|
|
1295 |
}
|
|
|
1296 |
}
|
|
|
1297 |
|
|
|
1298 |
}catch(Exception e){
|
|
|
1299 |
e.printStackTrace();
|
|
|
1300 |
}
|
|
|
1301 |
return orders;
|
|
|
1302 |
}
|
|
|
1303 |
|
|
|
1304 |
public static String getItemDisplayName(LineItem lineitem){
|
|
|
1305 |
StringBuffer itemName = new StringBuffer();
|
|
|
1306 |
if (lineitem.getBrand() != null)
|
|
|
1307 |
itemName.append(lineitem.getBrand() + " ");
|
|
|
1308 |
if (lineitem.getModel_name() != null)
|
|
|
1309 |
itemName.append(lineitem.getModel_name() + " ");
|
|
|
1310 |
if (lineitem.getModel_number() != null)
|
|
|
1311 |
itemName.append(lineitem.getModel_number() + " ");
|
|
|
1312 |
if (lineitem.getColor() != null
|
|
|
1313 |
&& !lineitem.getColor().trim().equals("NA"))
|
|
|
1314 |
itemName.append("(" + lineitem.getColor() + ")");
|
|
|
1315 |
|
|
|
1316 |
return itemName.toString();
|
|
|
1317 |
}
|
|
|
1318 |
|
| 22939 |
amit.gupta |
1319 |
public static String getShortDisplayName(LineItem lineitem){
|
|
|
1320 |
StringBuffer itemName = new StringBuffer();
|
|
|
1321 |
itemName.append(lineitem.getQuantity()).append(" ");
|
|
|
1322 |
if (lineitem.getBrand() != null)
|
|
|
1323 |
itemName.append(lineitem.getBrand() + " ");
|
|
|
1324 |
if (lineitem.getModel_name() != null)
|
|
|
1325 |
itemName.append(lineitem.getModel_name() + " ");
|
|
|
1326 |
if (lineitem.getModel_number() != null)
|
|
|
1327 |
itemName.append(lineitem.getModel_number() + " ");
|
|
|
1328 |
return itemName.toString();
|
|
|
1329 |
}
|
|
|
1330 |
|
| 13146 |
manish.sha |
1331 |
public static String getProductName(in.shop2020.model.v1.catalog.Item item){
|
|
|
1332 |
StringBuffer itemName = new StringBuffer();
|
|
|
1333 |
if (item.getBrand() != null)
|
|
|
1334 |
itemName.append(item.getBrand() + " ");
|
|
|
1335 |
if (item.getModelName() != null)
|
|
|
1336 |
itemName.append(item.getModelName() + " ");
|
|
|
1337 |
if (item.getModelNumber() != null)
|
|
|
1338 |
itemName.append(item.getModelNumber() + " ");
|
|
|
1339 |
if (item.getColor() != null
|
|
|
1340 |
&& !item.getColor().trim().equals("NA"))
|
|
|
1341 |
itemName.append("(" + item.getColor() + ")");
|
|
|
1342 |
|
|
|
1343 |
return itemName.toString();
|
|
|
1344 |
}
|
| 19050 |
manish.sha |
1345 |
|
|
|
1346 |
public static List<Long> loadVirtualWarehouseDetails(){
|
|
|
1347 |
EhcacheWrapper<String, List<Long>> virtualWhCache = new EhcacheWrapper<String, List<Long>>(
|
|
|
1348 |
"VirtualWarehouses", CacheManager.create());
|
|
|
1349 |
|
|
|
1350 |
List<Long> virtualWarehouseIds = virtualWhCache.get("virtual_warehouses");
|
|
|
1351 |
|
|
|
1352 |
if(virtualWarehouseIds!=null && virtualWarehouseIds.size()>0){
|
|
|
1353 |
return virtualWarehouseIds;
|
|
|
1354 |
}else{
|
| 20776 |
amit.gupta |
1355 |
logger.info("Virtual Warehouse Not Exists, creating them");
|
| 19050 |
manish.sha |
1356 |
virtualWarehouseIds = new ArrayList<Long>();
|
|
|
1357 |
try{
|
|
|
1358 |
in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = new InventoryClient().getClient();
|
|
|
1359 |
List<Warehouse> allWarehouses = inventoryClient.getWarehouses(null, null, 0, 0, 0);
|
|
|
1360 |
for(Warehouse wh:allWarehouses){
|
|
|
1361 |
if(wh.getWarehouseType()==WarehouseType.THIRD_PARTY){
|
|
|
1362 |
virtualWarehouseIds.add(wh.getId());
|
|
|
1363 |
}
|
|
|
1364 |
}
|
|
|
1365 |
}catch(Exception e){
|
|
|
1366 |
e.printStackTrace();
|
|
|
1367 |
}
|
|
|
1368 |
virtualWhCache.put("virtual_warehouses", virtualWarehouseIds);
|
|
|
1369 |
}
|
|
|
1370 |
|
|
|
1371 |
return virtualWarehouseIds;
|
|
|
1372 |
}
|
| 493 |
rajveer |
1373 |
}
|