| 11874 |
manish.sha |
1 |
package in.shop2020;
|
|
|
2 |
|
|
|
3 |
import in.shop2020.model.v1.catalog.FlipkartItem;
|
|
|
4 |
import in.shop2020.model.v1.catalog.Item;
|
|
|
5 |
import in.shop2020.model.v1.catalog.SnapdealItemDetails;
|
|
|
6 |
import in.shop2020.model.v1.inventory.InventoryType;
|
|
|
7 |
import in.shop2020.model.v1.inventory.ItemInventory;
|
|
|
8 |
import in.shop2020.model.v1.inventory.Vendor;
|
|
|
9 |
import in.shop2020.model.v1.inventory.Warehouse;
|
|
|
10 |
import in.shop2020.model.v1.inventory.WarehouseLocation;
|
|
|
11 |
import in.shop2020.model.v1.inventory.WarehouseType;
|
|
|
12 |
import in.shop2020.thrift.clients.CatalogClient;
|
|
|
13 |
import in.shop2020.thrift.clients.InventoryClient;
|
|
|
14 |
import in.shop2020.thrift.clients.TransactionClient;
|
|
|
15 |
import in.shop2020.utils.GmailUtils;
|
|
|
16 |
//import inventory.Inventory;
|
|
|
17 |
import inventory.FlipkartInventoryItem;
|
|
|
18 |
import inventory.NlcLeftOutInventory;
|
|
|
19 |
//import inventory.SnapdealItemForInventory;
|
|
|
20 |
|
|
|
21 |
import java.io.BufferedReader;
|
|
|
22 |
import java.io.BufferedWriter;
|
|
|
23 |
import java.io.File;
|
| 11944 |
manish.sha |
24 |
import java.io.FileReader;
|
| 11874 |
manish.sha |
25 |
import java.io.FileWriter;
|
|
|
26 |
import java.io.IOException;
|
|
|
27 |
import java.io.InputStreamReader;
|
|
|
28 |
import java.util.ArrayList;
|
| 11940 |
manish.sha |
29 |
import java.util.Collections;
|
| 11874 |
manish.sha |
30 |
import java.util.HashMap;
|
| 11882 |
manish.sha |
31 |
import java.util.HashSet;
|
|
|
32 |
import java.util.Iterator;
|
| 11874 |
manish.sha |
33 |
import java.util.List;
|
|
|
34 |
import java.util.Map;
|
| 11882 |
manish.sha |
35 |
import java.util.Set;
|
| 11874 |
manish.sha |
36 |
|
|
|
37 |
import javax.mail.MessagingException;
|
|
|
38 |
|
|
|
39 |
import org.apache.commons.lang.StringUtils;
|
|
|
40 |
import org.apache.http.Header;
|
|
|
41 |
import org.apache.http.HttpResponse;
|
|
|
42 |
import org.apache.http.NameValuePair;
|
|
|
43 |
import org.apache.http.client.ClientProtocolException;
|
|
|
44 |
import org.apache.http.client.HttpClient;
|
|
|
45 |
import org.apache.http.client.entity.UrlEncodedFormEntity;
|
|
|
46 |
import org.apache.http.client.methods.HttpGet;
|
|
|
47 |
import org.apache.http.client.methods.HttpPost;
|
|
|
48 |
import org.apache.http.impl.client.DefaultHttpClient;
|
|
|
49 |
import org.apache.http.message.BasicNameValuePair;
|
|
|
50 |
import org.apache.http.params.HttpParams;
|
|
|
51 |
import org.apache.thrift.TException;
|
|
|
52 |
import org.apache.thrift.transport.TTransportException;
|
|
|
53 |
|
| 11940 |
manish.sha |
54 |
public class NlcLeftOutInventoryDetailScript {
|
| 11874 |
manish.sha |
55 |
|
| 11940 |
manish.sha |
56 |
// private static ArrayList<Inventory> currentInventoryItemList;
|
| 11874 |
manish.sha |
57 |
private static List<SnapdealItemDetails> snapdealItems;
|
|
|
58 |
private static List<FlipkartItem> flipkartItems;
|
|
|
59 |
private static List<FlipkartItem> flipkartInventoryItems = new ArrayList<FlipkartItem>();
|
| 11940 |
manish.sha |
60 |
static Map<Long, SnapdealItemDetails> snapdealItemMap = new HashMap<Long, SnapdealItemDetails>();
|
|
|
61 |
static Map<Long, FlipkartItem> flipkartItemMap = new HashMap<Long, FlipkartItem>();
|
|
|
62 |
// private static Map<Long, SnapdealItemForInventory> allItemsInventoryMap =
|
|
|
63 |
// new HashMap<Long, SnapdealItemForInventory>();
|
| 11874 |
manish.sha |
64 |
private static Map<Long, String> vendorDataMap = new HashMap<Long, String>();
|
| 11940 |
manish.sha |
65 |
// static java.text.SimpleDateFormat sdf;
|
| 11874 |
manish.sha |
66 |
static String emailFromAddress;
|
|
|
67 |
static String password;
|
|
|
68 |
static GmailUtils mailer;
|
|
|
69 |
static String sendTo[];
|
| 11889 |
manish.sha |
70 |
private static Map<String, Map<Long, NlcLeftOutInventory>> nlcLoiItemsMapSD = new HashMap<String, Map<Long, NlcLeftOutInventory>>();
|
|
|
71 |
private static Map<String, Map<Long, NlcLeftOutInventory>> nlcLoiItemsMapFK = new HashMap<String, Map<Long, NlcLeftOutInventory>>();
|
| 11874 |
manish.sha |
72 |
|
| 11940 |
manish.sha |
73 |
private static List<NlcLeftOutInventory> mainNlcLoiItemsListSD = new ArrayList<NlcLeftOutInventory>();
|
|
|
74 |
private static List<NlcLeftOutInventory> mainNlcLoiItemsListFK = new ArrayList<NlcLeftOutInventory>();
|
|
|
75 |
|
|
|
76 |
static {
|
| 11891 |
manish.sha |
77 |
emailFromAddress = "build-staging@shop2020.in";
|
|
|
78 |
password = "shop2020";
|
| 11874 |
manish.sha |
79 |
mailer = new GmailUtils();
|
| 11940 |
manish.sha |
80 |
sendTo = new String[] { "vikram.raghav@shop2020.in",
|
| 11944 |
manish.sha |
81 |
"manish.sharma@shop2020.in" };
|
| 11940 |
manish.sha |
82 |
/*
|
|
|
83 |
* sendTo = new String[]{ "sandeep.sachdeva@shop2020.in",
|
|
|
84 |
* "vikram.raghav@shop2020.in", "rajneesh.arora@shop2020.in",
|
|
|
85 |
* "khushal.bhatia@shop2020.in"
|
|
|
86 |
* ,"manoj.kumar@saholic.com","chaitnaya.vats@saholic.com",
|
|
|
87 |
* "yukti.jain@shop2020.in"
|
|
|
88 |
* ,"manisha.sharma@shop2020.in","chandan.kumar@shop2020.in"
|
|
|
89 |
* ,"ankush.dhingra@shop2020.in"};
|
|
|
90 |
*/
|
| 11874 |
manish.sha |
91 |
CatalogClient catalogServiceClient = null;
|
|
|
92 |
try {
|
|
|
93 |
catalogServiceClient = new CatalogClient();
|
|
|
94 |
} catch (TTransportException e1) {
|
|
|
95 |
// TODO Auto-generated catch block
|
|
|
96 |
e1.printStackTrace();
|
|
|
97 |
}
|
| 11940 |
manish.sha |
98 |
in.shop2020.model.v1.catalog.CatalogService.Client catalogClient = catalogServiceClient
|
| 11944 |
manish.sha |
99 |
.getClient();
|
| 11874 |
manish.sha |
100 |
|
|
|
101 |
try {
|
|
|
102 |
snapdealItems = catalogClient.getAllSnapdealItems();
|
|
|
103 |
flipkartItems = catalogClient.getAllFlipkartItems();
|
|
|
104 |
} catch (TException e) {
|
|
|
105 |
// TODO Auto-generated catch block
|
|
|
106 |
e.printStackTrace();
|
|
|
107 |
}
|
| 11940 |
manish.sha |
108 |
for (FlipkartItem flipkartItem : flipkartItems) {
|
|
|
109 |
if (flipkartItem.isIsListedOnFlipkart()
|
|
|
110 |
&& !flipkartItem.isSuppressInventoryFeed())
|
| 11874 |
manish.sha |
111 |
flipkartInventoryItems.add(flipkartItem);
|
|
|
112 |
}
|
|
|
113 |
|
| 11940 |
manish.sha |
114 |
for (FlipkartItem flipkartItem : flipkartItems) {
|
|
|
115 |
if (flipkartItem.isIsListedOnFlipkart()
|
|
|
116 |
&& !flipkartItem.isSuppressInventoryFeed()) {
|
| 11874 |
manish.sha |
117 |
flipkartItemMap.put(flipkartItem.getItem_id(), flipkartItem);
|
|
|
118 |
}
|
|
|
119 |
}
|
|
|
120 |
|
| 11940 |
manish.sha |
121 |
for (SnapdealItemDetails snapdealItem : snapdealItems) {
|
|
|
122 |
snapdealItemMap.put(snapdealItem.getItem_id(), snapdealItem);
|
| 11874 |
manish.sha |
123 |
}
|
|
|
124 |
|
| 11940 |
manish.sha |
125 |
if (flipkartItemMap.size() == 0) {
|
| 11874 |
manish.sha |
126 |
String text = "";
|
|
|
127 |
try {
|
| 11940 |
manish.sha |
128 |
mailer.sendSSLMessage(sendTo,
|
|
|
129 |
"No items to check not sent Inventory Data ",
|
|
|
130 |
emailFromAddress, password, text);
|
| 11874 |
manish.sha |
131 |
System.exit(0);
|
|
|
132 |
} catch (MessagingException e) {
|
|
|
133 |
e.printStackTrace();
|
|
|
134 |
}
|
|
|
135 |
}
|
|
|
136 |
|
| 11940 |
manish.sha |
137 |
if (snapdealItemMap.size() == 0) {
|
| 11874 |
manish.sha |
138 |
String text = "";
|
|
|
139 |
try {
|
| 11940 |
manish.sha |
140 |
mailer.sendSSLMessage(sendTo,
|
|
|
141 |
"No items to check not sent Inventory Data ",
|
|
|
142 |
emailFromAddress, password, text);
|
| 11874 |
manish.sha |
143 |
System.exit(0);
|
|
|
144 |
} catch (MessagingException e) {
|
|
|
145 |
e.printStackTrace();
|
|
|
146 |
}
|
|
|
147 |
}
|
|
|
148 |
}
|
|
|
149 |
|
| 11940 |
manish.sha |
150 |
private static void calculateinventory() {
|
| 11874 |
manish.sha |
151 |
CatalogClient catalogServiceClient = null;
|
| 11940 |
manish.sha |
152 |
Map<Long, ItemInventory> availability = new HashMap<Long, ItemInventory>();
|
| 11874 |
manish.sha |
153 |
try {
|
|
|
154 |
catalogServiceClient = new CatalogClient();
|
|
|
155 |
} catch (TTransportException e) {
|
|
|
156 |
e.printStackTrace();
|
|
|
157 |
}
|
| 11940 |
manish.sha |
158 |
in.shop2020.model.v1.catalog.CatalogService.Client catalogClient = catalogServiceClient
|
| 11944 |
manish.sha |
159 |
.getClient();
|
| 11874 |
manish.sha |
160 |
try {
|
|
|
161 |
List<Item> aliveItems = catalogClient.getAllAliveItems();
|
| 11940 |
manish.sha |
162 |
Map<Long, Item> aliveItemsMap = new HashMap<Long, Item>();
|
|
|
163 |
for (in.shop2020.model.v1.catalog.Item thriftItem : aliveItems) {
|
| 11874 |
manish.sha |
164 |
aliveItemsMap.put(thriftItem.getId(), thriftItem);
|
|
|
165 |
|
|
|
166 |
}
|
|
|
167 |
InventoryClient inventoryServiceClient = new InventoryClient();
|
|
|
168 |
try {
|
|
|
169 |
inventoryServiceClient = new InventoryClient();
|
|
|
170 |
} catch (TTransportException e) {
|
|
|
171 |
e.printStackTrace();
|
|
|
172 |
}
|
| 11940 |
manish.sha |
173 |
in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = inventoryServiceClient
|
| 11944 |
manish.sha |
174 |
.getClient();
|
| 11874 |
manish.sha |
175 |
List<Vendor> allVendors = inventoryClient.getAllVendors();
|
| 11940 |
manish.sha |
176 |
for (Vendor v : allVendors) {
|
| 11874 |
manish.sha |
177 |
vendorDataMap.put(v.getId(), v.getName());
|
|
|
178 |
}
|
| 11940 |
manish.sha |
179 |
List<in.shop2020.model.v1.inventory.IgnoredInventoryUpdateItems> ignoreItems = inventoryClient
|
| 11944 |
manish.sha |
180 |
.getIgnoredWarehouseidsAndItemids();
|
| 11889 |
manish.sha |
181 |
|
| 11874 |
manish.sha |
182 |
availability = inventoryClient.getInventorySnapshot(0);
|
| 11940 |
manish.sha |
183 |
List<Warehouse> allwarehouses = inventoryClient.getWarehouses(null,
|
|
|
184 |
null, 0, 0, 0);
|
|
|
185 |
Map<Long, Warehouse> allWarehousesMap = new HashMap<Long, Warehouse>();
|
|
|
186 |
for (Warehouse warehouse : allwarehouses) {
|
|
|
187 |
allWarehousesMap.put(warehouse.getId(), warehouse);
|
| 11874 |
manish.sha |
188 |
}
|
| 11940 |
manish.sha |
189 |
List<Warehouse> warehouses = inventoryClient.getWarehouses(
|
|
|
190 |
WarehouseType.OURS_THIRDPARTY, null, 0, 0, 0);
|
|
|
191 |
List<Warehouse> ours_warehouses = inventoryClient.getWarehouses(
|
|
|
192 |
WarehouseType.OURS, InventoryType.GOOD, 0, 0, 0);
|
| 11874 |
manish.sha |
193 |
List<Long> thirdpartywarehouseids = new ArrayList<Long>();
|
|
|
194 |
List<Long> oursGoodWarehouse = new ArrayList<Long>();
|
| 11940 |
manish.sha |
195 |
for (Warehouse warehouse : warehouses) {
|
| 11874 |
manish.sha |
196 |
thirdpartywarehouseids.add(warehouse.getId());
|
|
|
197 |
}
|
| 11940 |
manish.sha |
198 |
for (Warehouse warehouse : ours_warehouses) {
|
| 11874 |
manish.sha |
199 |
oursGoodWarehouse.add(warehouse.getId());
|
|
|
200 |
}
|
| 11940 |
manish.sha |
201 |
/*
|
|
|
202 |
* long available=0; long reserve=0; long total_warehouse_held=0;
|
|
|
203 |
* long heldForSource=0; long total_held=0;
|
|
|
204 |
*/
|
|
|
205 |
double nlc = 0;
|
|
|
206 |
double maxnlcSD = 0;
|
|
|
207 |
double maxnlcFK = 0;
|
| 11874 |
manish.sha |
208 |
|
| 11886 |
manish.sha |
209 |
Map<String, Map<Long, NlcLeftOutInventory>> snapdealLeftInvDataMap = new HashMap<String, Map<Long, NlcLeftOutInventory>>();
|
|
|
210 |
Map<String, Map<Long, NlcLeftOutInventory>> flipkartLeftInvDataMap = new HashMap<String, Map<Long, NlcLeftOutInventory>>();
|
| 11874 |
manish.sha |
211 |
|
| 11940 |
manish.sha |
212 |
for (Item thriftItem : aliveItems) {
|
| 11874 |
manish.sha |
213 |
SnapdealItemDetails snapdealItem = null;
|
|
|
214 |
FlipkartItem flipkartItem = null;
|
|
|
215 |
NlcLeftOutInventory nlcLOISD;
|
|
|
216 |
NlcLeftOutInventory nlcLOIFK;
|
| 11940 |
manish.sha |
217 |
maxnlcSD = 0;
|
|
|
218 |
maxnlcFK = 0;
|
| 11886 |
manish.sha |
219 |
Map<Long, NlcLeftOutInventory> nlcLoiMapSD = new HashMap<Long, NlcLeftOutInventory>();
|
|
|
220 |
Map<Long, NlcLeftOutInventory> nlcLoiMapFK = new HashMap<Long, NlcLeftOutInventory>();
|
| 11882 |
manish.sha |
221 |
Set<NlcLeftOutInventory> nlcLoiSetSD = new HashSet<NlcLeftOutInventory>();
|
|
|
222 |
Set<NlcLeftOutInventory> nlcLoiSetFK = new HashSet<NlcLeftOutInventory>();
|
| 11940 |
manish.sha |
223 |
if (snapdealItemMap.containsKey(thriftItem.getId())) {
|
| 11874 |
manish.sha |
224 |
snapdealItem = snapdealItemMap.get(thriftItem.getId());
|
|
|
225 |
maxnlcSD = snapdealItem.getMaxNlc();
|
|
|
226 |
}
|
| 11940 |
manish.sha |
227 |
if (flipkartItemMap.containsKey(thriftItem.getId())) {
|
| 11874 |
manish.sha |
228 |
flipkartItem = flipkartItemMap.get(thriftItem.getId());
|
|
|
229 |
maxnlcFK = flipkartItem.getMaxNlc();
|
|
|
230 |
}
|
| 11940 |
manish.sha |
231 |
nlc = 0;
|
|
|
232 |
List<Warehouse> vendor_warehouses = null;
|
|
|
233 |
if (availability.get(thriftItem.getId()) != null) {
|
|
|
234 |
ItemInventory iteminventory = availability.get(thriftItem
|
|
|
235 |
.getId());
|
|
|
236 |
Map<Long, Long> itemavailability = new HashMap<Long, Long>();
|
| 11874 |
manish.sha |
237 |
itemavailability = iteminventory.getAvailability();
|
| 11940 |
manish.sha |
238 |
if (thriftItem.isIsWarehousePreferenceSticky()
|
|
|
239 |
&& thriftItem.getPreferredVendor() != 0) {
|
|
|
240 |
// System.out.println("Item id "+thriftItem.getId()+".Found prefered vendor and warehouse is marked sticky (Calculating availability)"+thriftItem.getPreferredVendor());
|
|
|
241 |
vendor_warehouses = inventoryClient.getWarehouses(
|
|
|
242 |
WarehouseType.THIRD_PARTY, InventoryType.GOOD,
|
|
|
243 |
thriftItem.getPreferredVendor(), 0, 0);
|
| 11874 |
manish.sha |
244 |
vendor_warehouses.addAll(ours_warehouses);
|
| 11940 |
manish.sha |
245 |
for (Warehouse warehouse : vendor_warehouses) {
|
|
|
246 |
if (warehouse.getBillingWarehouseId() != 7) {
|
|
|
247 |
if (warehouse.getLogisticsLocation().equals(
|
|
|
248 |
WarehouseLocation.Delhi)
|
|
|
249 |
&& warehouse.getWarehouseType().equals(
|
|
|
250 |
WarehouseType.THIRD_PARTY)
|
| 11944 |
manish.sha |
251 |
&& warehouse.getVendor().getId() != 1) {
|
| 11874 |
manish.sha |
252 |
|
| 11940 |
manish.sha |
253 |
} else {
|
| 11874 |
manish.sha |
254 |
continue;
|
|
|
255 |
}
|
|
|
256 |
}
|
|
|
257 |
in.shop2020.model.v1.inventory.IgnoredInventoryUpdateItems ignoredItem = new in.shop2020.model.v1.inventory.IgnoredInventoryUpdateItems();
|
|
|
258 |
ignoredItem.setItemId(thriftItem.getId());
|
|
|
259 |
ignoredItem.setWarehouseId(warehouse.getId());
|
| 11940 |
manish.sha |
260 |
if (itemavailability.get(warehouse.getId()) != null
|
|
|
261 |
&& !thirdpartywarehouseids
|
| 11944 |
manish.sha |
262 |
.contains(warehouse.getId())
|
| 11940 |
manish.sha |
263 |
&& !ignoreItems.contains(ignoredItem)) {
|
|
|
264 |
try {
|
|
|
265 |
nlc = inventoryClient.getNlcForWarehouse(
|
|
|
266 |
warehouse.getId(),
|
|
|
267 |
thriftItem.getId());
|
| 11874 |
manish.sha |
268 |
|
| 11940 |
manish.sha |
269 |
} catch (TTransportException e) {
|
|
|
270 |
inventoryClient = inventoryServiceClient
|
| 11944 |
manish.sha |
271 |
.getClient();
|
| 11940 |
manish.sha |
272 |
nlc = inventoryClient.getNlcForWarehouse(
|
|
|
273 |
warehouse.getId(),
|
|
|
274 |
thriftItem.getId());
|
| 11874 |
manish.sha |
275 |
}
|
|
|
276 |
|
| 11940 |
manish.sha |
277 |
// maxnlc =
|
|
|
278 |
// catalogClient.getSnapdealItem(thriftItem.getId()).getMaxNlc();
|
| 11874 |
manish.sha |
279 |
|
| 11940 |
manish.sha |
280 |
if (snapdealItem != null) {
|
|
|
281 |
if (nlc != 0 && (maxnlcSD >= nlc)) {
|
|
|
282 |
/*
|
|
|
283 |
* total_warehouse_held =
|
|
|
284 |
* inventoryClient.
|
|
|
285 |
* getHoldInventoryDetailForItemForWarehouseIdExceptSource
|
|
|
286 |
* (thriftItem.getId(),
|
|
|
287 |
* warehouse.getId(), 0); heldForSource
|
|
|
288 |
* = heldForSource +
|
|
|
289 |
* total_warehouse_held -
|
|
|
290 |
* inventoryClient.
|
|
|
291 |
* getHoldInventoryDetailForItemForWarehouseIdExceptSource
|
|
|
292 |
* (thriftItem.getId(),
|
|
|
293 |
* warehouse.getId(), 7); available =
|
|
|
294 |
* available +
|
|
|
295 |
* itemavailability.get(warehouse
|
|
|
296 |
* .getId()); total_held = total_held +
|
|
|
297 |
* total_warehouse_held;
|
|
|
298 |
*/
|
|
|
299 |
// continue;
|
|
|
300 |
// System.out.println("itemId:" +
|
|
|
301 |
// thriftItem.getId() + "\ttotal_held: "
|
|
|
302 |
// + total_held + "\theldForSource:" +
|
|
|
303 |
// heldForSource + "\tavailable:" +
|
|
|
304 |
// available);
|
|
|
305 |
} else if (maxnlcSD == 0) {
|
|
|
306 |
/*
|
|
|
307 |
* total_warehouse_held =
|
|
|
308 |
* inventoryClient.
|
|
|
309 |
* getHoldInventoryDetailForItemForWarehouseIdExceptSource
|
|
|
310 |
* (thriftItem.getId(),
|
|
|
311 |
* warehouse.getId(), 0); heldForSource
|
|
|
312 |
* = heldForSource +
|
|
|
313 |
* total_warehouse_held -
|
|
|
314 |
* inventoryClient.
|
|
|
315 |
* getHoldInventoryDetailForItemForWarehouseIdExceptSource
|
|
|
316 |
* (thriftItem.getId(),
|
|
|
317 |
* warehouse.getId(), 7); available =
|
|
|
318 |
* available +
|
|
|
319 |
* itemavailability.get(warehouse
|
|
|
320 |
* .getId()); total_held = total_held +
|
|
|
321 |
* total_warehouse_held;
|
|
|
322 |
*/
|
|
|
323 |
// continue;
|
|
|
324 |
// System.out.println("itemId:" +
|
|
|
325 |
// thriftItem.getId() + "\ttotal_held: "
|
|
|
326 |
// + total_held + "\theldForSource:" +
|
|
|
327 |
// heldForSource + "\tavailable:" +
|
|
|
328 |
// available);
|
|
|
329 |
} else {
|
|
|
330 |
long available = itemavailability
|
| 11944 |
manish.sha |
331 |
.get(warehouse.getId());
|
| 11940 |
manish.sha |
332 |
if (available > 0) {
|
|
|
333 |
nlcLOISD = new NlcLeftOutInventory();
|
|
|
334 |
nlcLOISD.setItemId(snapdealItem
|
|
|
335 |
.getItem_id());
|
|
|
336 |
nlcLOISD.setProductName(snapdealItem
|
|
|
337 |
.getBrand()
|
|
|
338 |
+ " "
|
|
|
339 |
+ snapdealItem
|
| 11944 |
manish.sha |
340 |
.getModel_name()
|
| 11940 |
manish.sha |
341 |
+ " "
|
|
|
342 |
+ snapdealItem
|
| 11944 |
manish.sha |
343 |
.getModel_number()
|
| 11940 |
manish.sha |
344 |
+ " "
|
|
|
345 |
+ snapdealItem.getColor());
|
| 11875 |
manish.sha |
346 |
nlcLOISD.setOurNlc(maxnlcSD);
|
| 11940 |
manish.sha |
347 |
nlcLOISD.setSkuAtSource(snapdealItem
|
|
|
348 |
.getSkuAtSnapdeal());
|
|
|
349 |
nlcLOISD.setVendorName(warehouse
|
|
|
350 |
.getVendor().getName());
|
| 11875 |
manish.sha |
351 |
nlcLOISD.setVendorAvailability(available);
|
|
|
352 |
nlcLOISD.setVendorNlc(nlc);
|
| 11940 |
manish.sha |
353 |
nlcLOISD.setVendorWarehouseId(warehouse
|
|
|
354 |
.getId());
|
|
|
355 |
nlcLOISD.setWarehouseType(warehouse
|
|
|
356 |
.getWarehouseType()
|
|
|
357 |
.toString());
|
|
|
358 |
if (!nlcLoiMapSD
|
|
|
359 |
.containsKey(warehouse
|
|
|
360 |
.getId()))
|
|
|
361 |
nlcLoiMapSD.put(
|
|
|
362 |
warehouse.getId(),
|
|
|
363 |
nlcLOISD);
|
| 11889 |
manish.sha |
364 |
|
| 11875 |
manish.sha |
365 |
}
|
| 11874 |
manish.sha |
366 |
}
|
|
|
367 |
}
|
|
|
368 |
|
| 11940 |
manish.sha |
369 |
if (flipkartItem != null) {
|
|
|
370 |
if (nlc != 0 && (maxnlcFK >= nlc)) {
|
|
|
371 |
/*
|
|
|
372 |
* total_warehouse_held =
|
|
|
373 |
* inventoryClient.
|
|
|
374 |
* getHoldInventoryDetailForItemForWarehouseIdExceptSource
|
|
|
375 |
* (thriftItem.getId(),
|
|
|
376 |
* warehouse.getId(), 0); heldForSource
|
|
|
377 |
* = heldForSource +
|
|
|
378 |
* total_warehouse_held -
|
|
|
379 |
* inventoryClient.
|
|
|
380 |
* getHoldInventoryDetailForItemForWarehouseIdExceptSource
|
|
|
381 |
* (thriftItem.getId(),
|
|
|
382 |
* warehouse.getId(), 8); available =
|
|
|
383 |
* available +
|
|
|
384 |
* itemavailability.get(warehouse
|
|
|
385 |
* .getId()); total_held = total_held +
|
|
|
386 |
* total_warehouse_held;
|
|
|
387 |
*/
|
|
|
388 |
// continue;
|
|
|
389 |
// System.out.println("itemId:" +
|
|
|
390 |
// thriftItem.getId() + "\ttotal_held: "
|
|
|
391 |
// + total_held + "\theldForSource:" +
|
|
|
392 |
// heldForSource + "\tavailable:" +
|
|
|
393 |
// available);
|
|
|
394 |
} else if (maxnlcFK == 0) {
|
|
|
395 |
/*
|
|
|
396 |
* total_warehouse_held =
|
|
|
397 |
* inventoryClient.
|
|
|
398 |
* getHoldInventoryDetailForItemForWarehouseIdExceptSource
|
|
|
399 |
* (thriftItem.getId(),
|
|
|
400 |
* warehouse.getId(), 0); heldForSource
|
|
|
401 |
* = heldForSource +
|
|
|
402 |
* total_warehouse_held -
|
|
|
403 |
* inventoryClient.
|
|
|
404 |
* getHoldInventoryDetailForItemForWarehouseIdExceptSource
|
|
|
405 |
* (thriftItem.getId(),
|
|
|
406 |
* warehouse.getId(), 8); available =
|
|
|
407 |
* available +
|
|
|
408 |
* itemavailability.get(warehouse
|
|
|
409 |
* .getId()); total_held = total_held +
|
|
|
410 |
* total_warehouse_held;
|
|
|
411 |
*/
|
|
|
412 |
// continue;
|
|
|
413 |
// System.out.println("itemId:" +
|
|
|
414 |
// thriftItem.getId() + "\ttotal_held: "
|
|
|
415 |
// + total_held + "\theldForSource:" +
|
|
|
416 |
// heldForSource + "\tavailable:" +
|
|
|
417 |
// available);
|
|
|
418 |
} else {
|
|
|
419 |
long available = itemavailability
|
| 11944 |
manish.sha |
420 |
.get(warehouse.getId());
|
| 11940 |
manish.sha |
421 |
if (available > 0) {
|
| 11875 |
manish.sha |
422 |
nlcLOIFK = new NlcLeftOutInventory();
|
| 11940 |
manish.sha |
423 |
nlcLOIFK.setItemId(flipkartItem
|
|
|
424 |
.getItem_id());
|
|
|
425 |
nlcLOIFK.setProductName(thriftItem
|
|
|
426 |
.getBrand()
|
|
|
427 |
+ " "
|
|
|
428 |
+ thriftItem.getModelName()
|
|
|
429 |
+ " "
|
|
|
430 |
+ thriftItem
|
| 11944 |
manish.sha |
431 |
.getModelNumber()
|
| 11940 |
manish.sha |
432 |
+ " "
|
|
|
433 |
+ thriftItem.getColor());
|
| 11875 |
manish.sha |
434 |
nlcLOIFK.setOurNlc(maxnlcFK);
|
| 11940 |
manish.sha |
435 |
nlcLOIFK.setSkuAtSource(flipkartItem
|
|
|
436 |
.getSkuAtFlipkart());
|
|
|
437 |
nlcLOIFK.setVendorName(warehouse
|
|
|
438 |
.getVendor().getName());
|
| 11875 |
manish.sha |
439 |
nlcLOIFK.setVendorAvailability(available);
|
|
|
440 |
nlcLOIFK.setVendorNlc(nlc);
|
| 11940 |
manish.sha |
441 |
nlcLOIFK.setVendorWarehouseId(warehouse
|
|
|
442 |
.getId());
|
|
|
443 |
nlcLOIFK.setWarehouseType(warehouse
|
|
|
444 |
.getWarehouseType()
|
|
|
445 |
.toString());
|
|
|
446 |
if (!nlcLoiMapFK
|
|
|
447 |
.containsKey(warehouse
|
|
|
448 |
.getId()))
|
|
|
449 |
nlcLoiMapFK.put(
|
|
|
450 |
warehouse.getId(),
|
|
|
451 |
nlcLOIFK);
|
| 11875 |
manish.sha |
452 |
}
|
| 11874 |
manish.sha |
453 |
}
|
|
|
454 |
}
|
| 11940 |
manish.sha |
455 |
// System.out.println("itemId:" +
|
|
|
456 |
// thriftItem.getId() + "\tmaxnlc: " + maxnlc +
|
|
|
457 |
// "\tnlc:" + nlc + "\twid:" + warehouse.getId()
|
|
|
458 |
// );
|
| 11874 |
manish.sha |
459 |
|
|
|
460 |
}
|
|
|
461 |
}
|
| 11940 |
manish.sha |
462 |
if (nlcLoiMapSD != null && nlcLoiMapSD.size() > 0) {
|
|
|
463 |
snapdealLeftInvDataMap.put(
|
|
|
464 |
snapdealItem.getSkuAtSnapdeal(),
|
|
|
465 |
nlcLoiMapSD);
|
| 11884 |
manish.sha |
466 |
}
|
| 11940 |
manish.sha |
467 |
if (nlcLoiMapFK != null && nlcLoiMapFK.size() > 0) {
|
|
|
468 |
flipkartLeftInvDataMap.put(
|
|
|
469 |
flipkartItem.getSkuAtFlipkart(),
|
|
|
470 |
nlcLoiMapFK);
|
| 11884 |
manish.sha |
471 |
}
|
| 11940 |
manish.sha |
472 |
} else {
|
|
|
473 |
for (Map.Entry<Long, Long> entry : itemavailability
|
|
|
474 |
.entrySet()) {
|
|
|
475 |
if (allWarehousesMap.get(entry.getKey())
|
|
|
476 |
.getBillingWarehouseId() != 7) {
|
|
|
477 |
if (allWarehousesMap.get(entry.getKey())
|
|
|
478 |
.getLogisticsLocation()
|
|
|
479 |
.equals(WarehouseLocation.Delhi)
|
|
|
480 |
&& allWarehousesMap
|
| 11944 |
manish.sha |
481 |
.get(entry.getKey())
|
|
|
482 |
.getWarehouseType()
|
|
|
483 |
.equals(WarehouseType.THIRD_PARTY)
|
| 11940 |
manish.sha |
484 |
&& allWarehousesMap.get(entry.getKey())
|
| 11944 |
manish.sha |
485 |
.getVendor().getId() != 1) {
|
| 11874 |
manish.sha |
486 |
|
| 11940 |
manish.sha |
487 |
} else {
|
| 11874 |
manish.sha |
488 |
continue;
|
|
|
489 |
}
|
|
|
490 |
}
|
|
|
491 |
in.shop2020.model.v1.inventory.IgnoredInventoryUpdateItems ignoredItem = new in.shop2020.model.v1.inventory.IgnoredInventoryUpdateItems();
|
|
|
492 |
ignoredItem.setItemId(thriftItem.getId());
|
|
|
493 |
ignoredItem.setWarehouseId(entry.getKey());
|
| 11940 |
manish.sha |
494 |
if (!thirdpartywarehouseids
|
|
|
495 |
.contains(entry.getKey())
|
|
|
496 |
&& !ignoreItems.contains(ignoredItem)) {
|
| 11874 |
manish.sha |
497 |
|
| 11940 |
manish.sha |
498 |
nlc = inventoryClient.getNlcForWarehouse(
|
|
|
499 |
entry.getKey(), thriftItem.getId());
|
| 11874 |
manish.sha |
500 |
|
| 11940 |
manish.sha |
501 |
// System.out.println("itemId:" +
|
|
|
502 |
// thriftItem.getId() + "\tmaxnlc: " + maxnlc +
|
|
|
503 |
// "\tnlc:" + nlc + "\twid:" + entry.getKey() );
|
|
|
504 |
if (snapdealItem != null) {
|
|
|
505 |
if (nlc != 0 && (maxnlcSD >= nlc)) {
|
|
|
506 |
/*
|
|
|
507 |
* total_warehouse_held =
|
|
|
508 |
* inventoryClient.
|
|
|
509 |
* getHoldInventoryDetailForItemForWarehouseIdExceptSource
|
|
|
510 |
* (thriftItem.getId(), entry.getKey(),
|
|
|
511 |
* 0); heldForSource = heldForSource +
|
|
|
512 |
* total_warehouse_held -
|
|
|
513 |
* inventoryClient.
|
|
|
514 |
* getHoldInventoryDetailForItemForWarehouseIdExceptSource
|
|
|
515 |
* (thriftItem.getId(), entry.getKey(),
|
|
|
516 |
* 7); available = available +
|
|
|
517 |
* entry.getValue(); total_held =
|
|
|
518 |
* total_held + total_warehouse_held;
|
|
|
519 |
*/
|
|
|
520 |
// continue;
|
|
|
521 |
// System.out.println("itemId:" +
|
|
|
522 |
// thriftItem.getId() + "\ttotal_held: "
|
|
|
523 |
// + total_held + "\theldForSource:" +
|
|
|
524 |
// heldForSource + "\tavailable:" +
|
|
|
525 |
// available);
|
|
|
526 |
} else if (maxnlcSD == 0) {
|
|
|
527 |
/*
|
|
|
528 |
* total_warehouse_held =
|
|
|
529 |
* inventoryClient.
|
|
|
530 |
* getHoldInventoryDetailForItemForWarehouseIdExceptSource
|
|
|
531 |
* (thriftItem.getId(), entry.getKey(),
|
|
|
532 |
* 0); heldForSource = heldForSource +
|
|
|
533 |
* total_warehouse_held -
|
|
|
534 |
* inventoryClient.
|
|
|
535 |
* getHoldInventoryDetailForItemForWarehouseIdExceptSource
|
|
|
536 |
* (thriftItem.getId(), entry.getKey(),
|
|
|
537 |
* 7); available = available +
|
|
|
538 |
* itemavailability.get(entry.getKey());
|
|
|
539 |
* total_held = total_held +
|
|
|
540 |
* total_warehouse_held;
|
|
|
541 |
*/
|
| 11874 |
manish.sha |
542 |
|
| 11940 |
manish.sha |
543 |
// continue;
|
|
|
544 |
// System.out.println("itemId:" +
|
|
|
545 |
// thriftItem.getId() + "\ttotal_held: "
|
|
|
546 |
// + total_held + "\theldForSource:" +
|
|
|
547 |
// heldForSource + "\tavailable:" +
|
|
|
548 |
// available);
|
|
|
549 |
} else {
|
|
|
550 |
long available = itemavailability
|
| 11944 |
manish.sha |
551 |
.get(entry.getKey());
|
| 11940 |
manish.sha |
552 |
if (available > 0) {
|
| 11875 |
manish.sha |
553 |
nlcLOISD = new NlcLeftOutInventory();
|
| 11940 |
manish.sha |
554 |
nlcLOISD.setItemId(snapdealItem
|
|
|
555 |
.getItem_id());
|
|
|
556 |
nlcLOISD.setProductName(snapdealItem
|
|
|
557 |
.getBrand()
|
|
|
558 |
+ " "
|
|
|
559 |
+ snapdealItem
|
| 11944 |
manish.sha |
560 |
.getModel_name()
|
| 11940 |
manish.sha |
561 |
+ " "
|
|
|
562 |
+ snapdealItem
|
| 11944 |
manish.sha |
563 |
.getModel_number()
|
| 11940 |
manish.sha |
564 |
+ " "
|
|
|
565 |
+ snapdealItem.getColor());
|
| 11875 |
manish.sha |
566 |
nlcLOISD.setOurNlc(maxnlcSD);
|
| 11940 |
manish.sha |
567 |
nlcLOISD.setSkuAtSource(snapdealItem
|
|
|
568 |
.getSkuAtSnapdeal());
|
|
|
569 |
nlcLOISD.setVendorName(vendorDataMap
|
|
|
570 |
.get(allWarehousesMap
|
|
|
571 |
.get(entry.getKey())
|
|
|
572 |
.getVendor()
|
|
|
573 |
.getId()));
|
| 11875 |
manish.sha |
574 |
nlcLOISD.setVendorAvailability(available);
|
|
|
575 |
nlcLOISD.setVendorNlc(nlc);
|
| 11940 |
manish.sha |
576 |
nlcLOISD.setVendorWarehouseId(entry
|
|
|
577 |
.getKey());
|
|
|
578 |
nlcLOISD.setWarehouseType(allWarehousesMap
|
|
|
579 |
.get(entry.getKey())
|
|
|
580 |
.getWarehouseType()
|
|
|
581 |
.toString());
|
|
|
582 |
if (!nlcLoiMapSD.containsKey(entry
|
|
|
583 |
.getKey()))
|
|
|
584 |
nlcLoiMapSD.put(entry.getKey(),
|
|
|
585 |
nlcLOISD);
|
| 11875 |
manish.sha |
586 |
}
|
| 11874 |
manish.sha |
587 |
}
|
|
|
588 |
}
|
|
|
589 |
|
| 11940 |
manish.sha |
590 |
if (flipkartItem != null) {
|
|
|
591 |
if (nlc != 0 && (maxnlcFK >= nlc)) {
|
|
|
592 |
/*
|
|
|
593 |
* total_warehouse_held =
|
|
|
594 |
* inventoryClient.
|
|
|
595 |
* getHoldInventoryDetailForItemForWarehouseIdExceptSource
|
|
|
596 |
* (thriftItem.getId(), entry.getKey(),
|
|
|
597 |
* 0); heldForSource = heldForSource +
|
|
|
598 |
* total_warehouse_held -
|
|
|
599 |
* inventoryClient.
|
|
|
600 |
* getHoldInventoryDetailForItemForWarehouseIdExceptSource
|
|
|
601 |
* (thriftItem.getId(), entry.getKey(),
|
|
|
602 |
* 8); available = available +
|
|
|
603 |
* entry.getValue(); total_held =
|
|
|
604 |
* total_held + total_warehouse_held;
|
|
|
605 |
*/
|
|
|
606 |
// continue;
|
|
|
607 |
// System.out.println("itemId:" +
|
|
|
608 |
// thriftItem.getId() + "\ttotal_held: "
|
|
|
609 |
// + total_held + "\theldForSource:" +
|
|
|
610 |
// heldForSource + "\tavailable:" +
|
|
|
611 |
// available);
|
|
|
612 |
} else if (maxnlcFK == 0) {
|
|
|
613 |
/*
|
|
|
614 |
* total_warehouse_held =
|
|
|
615 |
* inventoryClient.
|
|
|
616 |
* getHoldInventoryDetailForItemForWarehouseIdExceptSource
|
|
|
617 |
* (thriftItem.getId(), entry.getKey(),
|
|
|
618 |
* 0); heldForSource = heldForSource +
|
|
|
619 |
* total_warehouse_held -
|
|
|
620 |
* inventoryClient.
|
|
|
621 |
* getHoldInventoryDetailForItemForWarehouseIdExceptSource
|
|
|
622 |
* (thriftItem.getId(), entry.getKey(),
|
|
|
623 |
* 8); available = available +
|
|
|
624 |
* itemavailability.get(entry.getKey());
|
|
|
625 |
* total_held = total_held +
|
|
|
626 |
* total_warehouse_held;
|
|
|
627 |
*/
|
|
|
628 |
// continue;
|
|
|
629 |
// System.out.println("itemId:" +
|
|
|
630 |
// thriftItem.getId() + "\ttotal_held: "
|
|
|
631 |
// + total_held + "\theldForSource:" +
|
|
|
632 |
// heldForSource + "\tavailable:" +
|
|
|
633 |
// available);
|
|
|
634 |
} else {
|
|
|
635 |
long available = itemavailability
|
| 11944 |
manish.sha |
636 |
.get(entry.getKey());
|
| 11940 |
manish.sha |
637 |
if (available > 0) {
|
| 11875 |
manish.sha |
638 |
nlcLOIFK = new NlcLeftOutInventory();
|
| 11940 |
manish.sha |
639 |
nlcLOIFK.setItemId(flipkartItem
|
|
|
640 |
.getItem_id());
|
|
|
641 |
nlcLOIFK.setProductName(thriftItem
|
|
|
642 |
.getBrand()
|
|
|
643 |
+ " "
|
|
|
644 |
+ thriftItem.getModelName()
|
|
|
645 |
+ " "
|
|
|
646 |
+ thriftItem
|
| 11944 |
manish.sha |
647 |
.getModelNumber()
|
| 11940 |
manish.sha |
648 |
+ " "
|
|
|
649 |
+ thriftItem.getColor());
|
| 11875 |
manish.sha |
650 |
nlcLOIFK.setOurNlc(maxnlcFK);
|
| 11940 |
manish.sha |
651 |
nlcLOIFK.setSkuAtSource(flipkartItem
|
|
|
652 |
.getSkuAtFlipkart());
|
|
|
653 |
nlcLOIFK.setVendorName(vendorDataMap
|
|
|
654 |
.get(allWarehousesMap
|
|
|
655 |
.get(entry.getKey())
|
|
|
656 |
.getVendor()
|
|
|
657 |
.getId()));
|
| 11875 |
manish.sha |
658 |
nlcLOIFK.setVendorAvailability(available);
|
|
|
659 |
nlcLOIFK.setVendorNlc(nlc);
|
| 11940 |
manish.sha |
660 |
nlcLOIFK.setVendorWarehouseId(entry
|
|
|
661 |
.getKey());
|
|
|
662 |
nlcLOIFK.setWarehouseType(allWarehousesMap
|
|
|
663 |
.get(entry.getKey())
|
|
|
664 |
.getWarehouseType()
|
|
|
665 |
.toString());
|
|
|
666 |
if (!nlcLoiMapFK.containsKey(entry
|
|
|
667 |
.getKey()))
|
|
|
668 |
nlcLoiMapFK.put(entry.getKey(),
|
|
|
669 |
nlcLOIFK);
|
| 11875 |
manish.sha |
670 |
}
|
| 11874 |
manish.sha |
671 |
}
|
|
|
672 |
}
|
|
|
673 |
|
|
|
674 |
}
|
|
|
675 |
}
|
| 11940 |
manish.sha |
676 |
if (nlcLoiMapSD != null && nlcLoiMapSD.size() > 0) {
|
|
|
677 |
snapdealLeftInvDataMap.put(
|
|
|
678 |
snapdealItem.getSkuAtSnapdeal(),
|
|
|
679 |
nlcLoiMapSD);
|
| 11884 |
manish.sha |
680 |
}
|
| 11940 |
manish.sha |
681 |
if (nlcLoiMapFK != null && nlcLoiMapFK.size() > 0) {
|
|
|
682 |
flipkartLeftInvDataMap.put(
|
|
|
683 |
flipkartItem.getSkuAtFlipkart(),
|
|
|
684 |
nlcLoiMapFK);
|
| 11884 |
manish.sha |
685 |
}
|
| 11874 |
manish.sha |
686 |
}
|
|
|
687 |
|
| 11940 |
manish.sha |
688 |
Map<Long, Long> itemreserve = new HashMap<Long, Long>();
|
| 11874 |
manish.sha |
689 |
itemreserve = iteminventory.getReserved();
|
| 11940 |
manish.sha |
690 |
if (thriftItem.isIsWarehousePreferenceSticky()
|
|
|
691 |
&& thriftItem.getPreferredVendor() != 0) {
|
|
|
692 |
// System.out.println("Item id "+thriftItem.getId()+".Found prefered vendor and warehouse is marked sticky (Calculating Reserve)"+thriftItem.getPreferredVendor());
|
|
|
693 |
for (Warehouse warehouse : vendor_warehouses) {
|
|
|
694 |
if (warehouse.getBillingWarehouseId() != 7) {
|
|
|
695 |
if (warehouse.getLogisticsLocation().equals(
|
|
|
696 |
WarehouseLocation.Delhi)
|
|
|
697 |
&& warehouse.getWarehouseType().equals(
|
|
|
698 |
WarehouseType.THIRD_PARTY)
|
| 11944 |
manish.sha |
699 |
&& warehouse.getVendor().getId() != 1) {
|
| 11874 |
manish.sha |
700 |
|
| 11940 |
manish.sha |
701 |
} else {
|
| 11874 |
manish.sha |
702 |
continue;
|
|
|
703 |
}
|
|
|
704 |
}
|
|
|
705 |
in.shop2020.model.v1.inventory.IgnoredInventoryUpdateItems ignoredItem = new in.shop2020.model.v1.inventory.IgnoredInventoryUpdateItems();
|
|
|
706 |
ignoredItem.setItemId(thriftItem.getId());
|
|
|
707 |
ignoredItem.setWarehouseId(warehouse.getId());
|
| 11940 |
manish.sha |
708 |
if (itemreserve.get(warehouse.getId()) != null
|
|
|
709 |
&& !thirdpartywarehouseids
|
| 11944 |
manish.sha |
710 |
.contains(warehouse.getId())
|
| 11940 |
manish.sha |
711 |
&& !ignoreItems.contains(warehouse.getId())) {
|
|
|
712 |
nlc = inventoryClient.getNlcForWarehouse(
|
|
|
713 |
warehouse.getId(), thriftItem.getId());
|
|
|
714 |
// maxnlc =
|
|
|
715 |
// catalogClient.getSnapdealItem(thriftItem.getId()).getMaxNlc();
|
|
|
716 |
// System.out.println("itemId:" +
|
|
|
717 |
// thriftItem.getId() + "\tmaxnlc: " + maxnlc +
|
|
|
718 |
// "\tnlc:" + nlc + "\twid:" + warehouse.getId()
|
|
|
719 |
// );
|
|
|
720 |
if (snapdealItem != null) {
|
|
|
721 |
if (nlc != 0 && (maxnlcSD >= nlc)) {
|
|
|
722 |
// reserve = reserve +
|
|
|
723 |
// itemreserve.get(warehouse.getId());
|
|
|
724 |
// System.out.println("itemId:" +
|
|
|
725 |
// thriftItem.getId() + "\ttotal_held: "
|
|
|
726 |
// + total_held + "\theldForSource:" +
|
|
|
727 |
// heldForSource + "\treserve:" +
|
|
|
728 |
// reserve);
|
|
|
729 |
// continue;
|
|
|
730 |
} else if (maxnlcSD == 0) {
|
|
|
731 |
// reserve = reserve +
|
|
|
732 |
// itemreserve.get(warehouse.getId());
|
|
|
733 |
// System.out.println("itemId:" +
|
|
|
734 |
// thriftItem.getId() + "\ttotal_held: "
|
|
|
735 |
// + total_held + "\theldForSource:" +
|
|
|
736 |
// heldForSource + "\treserve:" +
|
|
|
737 |
// reserve);
|
|
|
738 |
// continue;
|
|
|
739 |
} else {
|
|
|
740 |
if (snapdealLeftInvDataMap
|
|
|
741 |
.containsKey(snapdealItem
|
|
|
742 |
.getSkuAtSnapdeal())) {
|
|
|
743 |
Map<Long, NlcLeftOutInventory> newNlcObjMap = snapdealLeftInvDataMap
|
| 11944 |
manish.sha |
744 |
.get(snapdealItem
|
|
|
745 |
.getSkuAtSnapdeal());
|
| 11940 |
manish.sha |
746 |
if (newNlcObjMap
|
|
|
747 |
.containsKey(warehouse
|
|
|
748 |
.getId())) {
|
|
|
749 |
NlcLeftOutInventory newObj = newNlcObjMap
|
| 11944 |
manish.sha |
750 |
.get(warehouse.getId());
|
| 11940 |
manish.sha |
751 |
newObj.setReserved(itemreserve
|
|
|
752 |
.get(warehouse.getId()));
|
|
|
753 |
newObj.setTotalAvailability(newObj
|
|
|
754 |
.getVendorAvailability()
|
|
|
755 |
- itemreserve.get(warehouse
|
|
|
756 |
.getId()));
|
|
|
757 |
newNlcObjMap.remove(warehouse
|
|
|
758 |
.getId());
|
|
|
759 |
newNlcObjMap.put(
|
|
|
760 |
warehouse.getId(),
|
|
|
761 |
newObj);
|
| 11889 |
manish.sha |
762 |
|
|
|
763 |
}
|
|
|
764 |
nlcLoiMapSD = newNlcObjMap;
|
| 11874 |
manish.sha |
765 |
}
|
|
|
766 |
}
|
|
|
767 |
}
|
|
|
768 |
|
| 11940 |
manish.sha |
769 |
if (flipkartItem != null) {
|
|
|
770 |
if (nlc != 0 && (maxnlcFK >= nlc)) {
|
|
|
771 |
// reserve = reserve +
|
|
|
772 |
// itemreserve.get(warehouse.getId());
|
|
|
773 |
// System.out.println("itemId:" +
|
|
|
774 |
// thriftItem.getId() + "\ttotal_held: "
|
|
|
775 |
// + total_held + "\theldForSource:" +
|
|
|
776 |
// heldForSource + "\treserve:" +
|
|
|
777 |
// reserve);
|
|
|
778 |
// continue;
|
|
|
779 |
} else if (maxnlcFK == 0) {
|
|
|
780 |
// reserve = reserve +
|
|
|
781 |
// itemreserve.get(warehouse.getId());
|
|
|
782 |
// System.out.println("itemId:" +
|
|
|
783 |
// thriftItem.getId() + "\ttotal_held: "
|
|
|
784 |
// + total_held + "\theldForSource:" +
|
|
|
785 |
// heldForSource + "\treserve:" +
|
|
|
786 |
// reserve);
|
|
|
787 |
// continue;
|
|
|
788 |
} else {
|
|
|
789 |
if (flipkartLeftInvDataMap
|
|
|
790 |
.containsKey(flipkartItem
|
|
|
791 |
.getSkuAtFlipkart())) {
|
|
|
792 |
Map<Long, NlcLeftOutInventory> newNlcObjMap = flipkartLeftInvDataMap
|
| 11944 |
manish.sha |
793 |
.get(flipkartItem
|
|
|
794 |
.getSkuAtFlipkart());
|
| 11940 |
manish.sha |
795 |
if (newNlcObjMap
|
|
|
796 |
.containsKey(warehouse
|
|
|
797 |
.getId())) {
|
|
|
798 |
NlcLeftOutInventory newObj = newNlcObjMap
|
| 11944 |
manish.sha |
799 |
.get(warehouse.getId());
|
| 11940 |
manish.sha |
800 |
newObj.setReserved(itemreserve
|
|
|
801 |
.get(warehouse.getId()));
|
|
|
802 |
newObj.setTotalAvailability(newObj
|
|
|
803 |
.getVendorAvailability()
|
|
|
804 |
- itemreserve.get(warehouse
|
|
|
805 |
.getId()));
|
|
|
806 |
newNlcObjMap.remove(warehouse
|
|
|
807 |
.getId());
|
|
|
808 |
newNlcObjMap.put(
|
|
|
809 |
warehouse.getId(),
|
|
|
810 |
newObj);
|
| 11889 |
manish.sha |
811 |
|
|
|
812 |
}
|
|
|
813 |
nlcLoiMapFK = newNlcObjMap;
|
| 11874 |
manish.sha |
814 |
}
|
|
|
815 |
}
|
|
|
816 |
}
|
|
|
817 |
|
|
|
818 |
}
|
|
|
819 |
}
|
| 11889 |
manish.sha |
820 |
|
| 11940 |
manish.sha |
821 |
if (nlcLoiMapSD != null && nlcLoiMapSD.size() > 0) {
|
|
|
822 |
snapdealLeftInvDataMap.put(
|
|
|
823 |
snapdealItem.getSkuAtSnapdeal(),
|
|
|
824 |
nlcLoiMapSD);
|
| 11884 |
manish.sha |
825 |
}
|
| 11940 |
manish.sha |
826 |
if (nlcLoiMapFK != null && nlcLoiMapFK.size() > 0) {
|
|
|
827 |
flipkartLeftInvDataMap.put(
|
|
|
828 |
flipkartItem.getSkuAtFlipkart(),
|
|
|
829 |
nlcLoiMapFK);
|
| 11884 |
manish.sha |
830 |
}
|
| 11889 |
manish.sha |
831 |
|
| 11940 |
manish.sha |
832 |
} else {
|
|
|
833 |
for (Map.Entry<Long, Long> entry : itemreserve
|
|
|
834 |
.entrySet()) {
|
|
|
835 |
if (allWarehousesMap.get(entry.getKey())
|
|
|
836 |
.getBillingWarehouseId() != 7) {
|
|
|
837 |
if (allWarehousesMap.get(entry.getKey())
|
|
|
838 |
.getLogisticsLocation()
|
|
|
839 |
.equals(WarehouseLocation.Delhi)
|
|
|
840 |
&& allWarehousesMap
|
| 11944 |
manish.sha |
841 |
.get(entry.getKey())
|
|
|
842 |
.getWarehouseType()
|
|
|
843 |
.equals(WarehouseType.THIRD_PARTY)
|
| 11940 |
manish.sha |
844 |
&& allWarehousesMap.get(entry.getKey())
|
| 11944 |
manish.sha |
845 |
.getVendor().getId() != 1) {
|
| 11874 |
manish.sha |
846 |
|
| 11940 |
manish.sha |
847 |
} else {
|
| 11874 |
manish.sha |
848 |
continue;
|
|
|
849 |
}
|
|
|
850 |
}
|
|
|
851 |
in.shop2020.model.v1.inventory.IgnoredInventoryUpdateItems ignoredItem = new in.shop2020.model.v1.inventory.IgnoredInventoryUpdateItems();
|
|
|
852 |
ignoredItem.setItemId(thriftItem.getId());
|
|
|
853 |
ignoredItem.setWarehouseId(entry.getKey());
|
| 11940 |
manish.sha |
854 |
if (!thirdpartywarehouseids
|
|
|
855 |
.contains(entry.getKey())
|
|
|
856 |
&& !ignoreItems.contains(ignoredItem)) {
|
|
|
857 |
nlc = inventoryClient.getNlcForWarehouse(
|
|
|
858 |
entry.getKey(), thriftItem.getId());
|
|
|
859 |
// System.out.println("itemId:" +
|
|
|
860 |
// thriftItem.getId() + "\tmaxnlc: " + maxnlc +
|
|
|
861 |
// "\tnlc:" + nlc + "\twid:" + entry.getKey() );
|
|
|
862 |
if (snapdealItem != null) {
|
|
|
863 |
if (nlc != 0 && (maxnlcSD >= nlc)) {
|
|
|
864 |
// reserve = reserve + entry.getValue();
|
|
|
865 |
// System.out.println("itemId:" +
|
|
|
866 |
// thriftItem.getId() + "\ttotal_held: "
|
|
|
867 |
// + total_held + "\theldForSource:" +
|
|
|
868 |
// heldForSource + "\treserve:" +
|
|
|
869 |
// reserve);
|
|
|
870 |
// continue;
|
|
|
871 |
} else if (maxnlcSD == 0) {
|
|
|
872 |
// reserve = reserve + entry.getValue();
|
|
|
873 |
// System.out.println("itemId:" +
|
|
|
874 |
// thriftItem.getId() + "\ttotal_held: "
|
|
|
875 |
// + total_held + "\theldForSource:" +
|
|
|
876 |
// heldForSource + "\treserve:" +
|
|
|
877 |
// reserve);
|
|
|
878 |
// continue;
|
|
|
879 |
} else {
|
|
|
880 |
if (snapdealLeftInvDataMap
|
|
|
881 |
.containsKey(snapdealItem
|
|
|
882 |
.getSkuAtSnapdeal())) {
|
|
|
883 |
Map<Long, NlcLeftOutInventory> newNlcObjMap = snapdealLeftInvDataMap
|
| 11944 |
manish.sha |
884 |
.get(snapdealItem
|
|
|
885 |
.getSkuAtSnapdeal());
|
| 11940 |
manish.sha |
886 |
if (newNlcObjMap.containsKey(entry
|
|
|
887 |
.getKey())) {
|
|
|
888 |
NlcLeftOutInventory newObj = newNlcObjMap
|
| 11944 |
manish.sha |
889 |
.get(entry.getKey());
|
| 11940 |
manish.sha |
890 |
newObj.setReserved(itemreserve
|
|
|
891 |
.get(entry.getKey()));
|
|
|
892 |
newObj.setTotalAvailability(newObj
|
|
|
893 |
.getVendorAvailability()
|
|
|
894 |
- itemreserve.get(entry
|
|
|
895 |
.getKey()));
|
|
|
896 |
newNlcObjMap.remove(entry
|
|
|
897 |
.getKey());
|
|
|
898 |
newNlcObjMap.put(
|
|
|
899 |
entry.getKey(), newObj);
|
| 11889 |
manish.sha |
900 |
|
|
|
901 |
}
|
|
|
902 |
nlcLoiMapSD = newNlcObjMap;
|
| 11874 |
manish.sha |
903 |
}
|
|
|
904 |
}
|
|
|
905 |
}
|
| 11940 |
manish.sha |
906 |
if (flipkartItem != null) {
|
|
|
907 |
if (nlc != 0 && (maxnlcFK >= nlc)) {
|
|
|
908 |
// reserve = reserve + entry.getValue();
|
|
|
909 |
// System.out.println("itemId:" +
|
|
|
910 |
// thriftItem.getId() + "\ttotal_held: "
|
|
|
911 |
// + total_held + "\theldForSource:" +
|
|
|
912 |
// heldForSource + "\treserve:" +
|
|
|
913 |
// reserve);
|
|
|
914 |
// continue;
|
|
|
915 |
} else if (maxnlcFK == 0) {
|
|
|
916 |
// reserve = reserve + entry.getValue();
|
|
|
917 |
// System.out.println("itemId:" +
|
|
|
918 |
// thriftItem.getId() + "\ttotal_held: "
|
|
|
919 |
// + total_held + "\theldForSource:" +
|
|
|
920 |
// heldForSource + "\treserve:" +
|
|
|
921 |
// reserve);
|
|
|
922 |
// continue;
|
|
|
923 |
} else {
|
|
|
924 |
if (flipkartLeftInvDataMap
|
|
|
925 |
.containsKey(flipkartItem
|
|
|
926 |
.getSkuAtFlipkart())) {
|
|
|
927 |
Map<Long, NlcLeftOutInventory> newNlcObjMap = flipkartLeftInvDataMap
|
| 11944 |
manish.sha |
928 |
.get(flipkartItem
|
|
|
929 |
.getSkuAtFlipkart());
|
| 11940 |
manish.sha |
930 |
if (newNlcObjMap.containsKey(entry
|
|
|
931 |
.getKey())) {
|
|
|
932 |
NlcLeftOutInventory newObj = newNlcObjMap
|
| 11944 |
manish.sha |
933 |
.get(entry.getKey());
|
| 11940 |
manish.sha |
934 |
newObj.setReserved(itemreserve
|
|
|
935 |
.get(entry.getKey()));
|
|
|
936 |
newObj.setTotalAvailability(newObj
|
|
|
937 |
.getVendorAvailability()
|
|
|
938 |
- itemreserve.get(entry
|
|
|
939 |
.getKey()));
|
|
|
940 |
newNlcObjMap.remove(entry
|
|
|
941 |
.getKey());
|
|
|
942 |
newNlcObjMap.put(
|
|
|
943 |
entry.getKey(), newObj);
|
| 11889 |
manish.sha |
944 |
|
|
|
945 |
}
|
|
|
946 |
nlcLoiMapFK = newNlcObjMap;
|
| 11874 |
manish.sha |
947 |
}
|
|
|
948 |
}
|
|
|
949 |
}
|
|
|
950 |
|
|
|
951 |
}
|
|
|
952 |
|
| 11940 |
manish.sha |
953 |
else {
|
|
|
954 |
// System.out.println("skipping inventory for warehouse id "
|
|
|
955 |
// + entry.getKey());
|
| 11874 |
manish.sha |
956 |
}
|
|
|
957 |
}
|
| 11889 |
manish.sha |
958 |
|
| 11940 |
manish.sha |
959 |
if (nlcLoiMapSD != null && nlcLoiMapSD.size() > 0) {
|
|
|
960 |
snapdealLeftInvDataMap.put(
|
|
|
961 |
snapdealItem.getSkuAtSnapdeal(),
|
|
|
962 |
nlcLoiMapSD);
|
| 11884 |
manish.sha |
963 |
}
|
| 11940 |
manish.sha |
964 |
if (nlcLoiMapFK != null && nlcLoiMapFK.size() > 0) {
|
|
|
965 |
flipkartLeftInvDataMap.put(
|
|
|
966 |
flipkartItem.getSkuAtFlipkart(),
|
|
|
967 |
nlcLoiMapFK);
|
| 11884 |
manish.sha |
968 |
}
|
| 11874 |
manish.sha |
969 |
}
|
|
|
970 |
|
|
|
971 |
}
|
|
|
972 |
|
| 11889 |
manish.sha |
973 |
nlcLoiItemsMapSD = snapdealLeftInvDataMap;
|
|
|
974 |
nlcLoiItemsMapFK = flipkartLeftInvDataMap;
|
| 11940 |
manish.sha |
975 |
|
| 11874 |
manish.sha |
976 |
}
|
|
|
977 |
} catch (TException e) {
|
|
|
978 |
// TODO Auto-generated catch block
|
|
|
979 |
e.printStackTrace();
|
|
|
980 |
}
|
|
|
981 |
|
|
|
982 |
}
|
|
|
983 |
|
| 11940 |
manish.sha |
984 |
private static void createAndSendLeftOutInventoryFile(
|
|
|
985 |
Map<String, Map<Long, NlcLeftOutInventory>> nlcLeftoutInventoryItems,
|
|
|
986 |
String fileName) {
|
| 11874 |
manish.sha |
987 |
try {
|
|
|
988 |
|
| 11944 |
manish.sha |
989 |
File file = new File("/tmp/" + fileName + "-leftOutInv.xls");
|
|
|
990 |
BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(
|
|
|
991 |
file));
|
|
|
992 |
bufferedWriter.write(StringUtils.join(new String[] { "ItemId",
|
|
|
993 |
"Product Name", "SkuAtSource", "Vendor Name",
|
|
|
994 |
"Vendor Warehouse Id", "Warehouse Type", "Max Our NLC",
|
|
|
995 |
"Vendor NLC", "Availability Count", "Reserved Count",
|
|
|
996 |
"Net Availabilty" }, '\t'));
|
|
|
997 |
//id -0, name -1, sku - 2, vname 3, wh 4, wt 5, mnlc 6, vnlc 7, av8, r9, na 10
|
|
|
998 |
// System.out.println(fileName+
|
|
|
999 |
// " Main Map Size "+nlcLeftoutInventoryItems.size());
|
|
|
1000 |
|
|
|
1001 |
for (Map<Long, NlcLeftOutInventory> nlcLOImap : nlcLeftoutInventoryItems
|
|
|
1002 |
.values()) {
|
|
|
1003 |
// System.out.println("Inner Map Size "+nlcLOImap.size());
|
|
|
1004 |
for (NlcLeftOutInventory nlcLOI : nlcLOImap.values()) {
|
|
|
1005 |
bufferedWriter.newLine();
|
|
|
1006 |
|
|
|
1007 |
bufferedWriter.write(StringUtils.join(
|
|
|
1008 |
new String[] {
|
|
|
1009 |
String.valueOf(nlcLOI.getItemId()),
|
|
|
1010 |
nlcLOI.getProductName(),
|
|
|
1011 |
nlcLOI.getSkuAtSource(),
|
|
|
1012 |
nlcLOI.getVendorName(),
|
|
|
1013 |
String.valueOf(nlcLOI
|
|
|
1014 |
.getVendorWarehouseId()),
|
|
|
1015 |
nlcLOI.getWarehouseType(),
|
|
|
1016 |
String.valueOf(nlcLOI.getOurNlc()),
|
|
|
1017 |
String.valueOf(nlcLOI.getVendorNlc()),
|
|
|
1018 |
String.valueOf(nlcLOI
|
|
|
1019 |
.getVendorAvailability()),
|
|
|
1020 |
String.valueOf(nlcLOI.getReserved()),
|
|
|
1021 |
String.valueOf(nlcLOI
|
|
|
1022 |
.getTotalAvailability()) }, '\t'));
|
|
|
1023 |
|
|
|
1024 |
}
|
|
|
1025 |
}
|
|
|
1026 |
bufferedWriter.close();
|
|
|
1027 |
|
|
|
1028 |
List<NlcLeftOutInventory> subNlcLoiItemsListSD1 = new ArrayList<NlcLeftOutInventory>();
|
|
|
1029 |
List<NlcLeftOutInventory> subNlcLoiItemsListSD2 = new ArrayList<NlcLeftOutInventory>();
|
|
|
1030 |
List<NlcLeftOutInventory> subNlcLoiItemsListFK1 = new ArrayList<NlcLeftOutInventory>();
|
|
|
1031 |
List<NlcLeftOutInventory> subNlcLoiItemsListFK2 = new ArrayList<NlcLeftOutInventory>();
|
|
|
1032 |
|
|
|
1033 |
|
|
|
1034 |
BufferedReader reader = null;
|
|
|
1035 |
File readfile = new File("/tmp/" + fileName + "-leftOutInv.xls");
|
|
|
1036 |
reader = new BufferedReader(new FileReader(readfile));
|
|
|
1037 |
String line;
|
|
|
1038 |
String values[];
|
| 11945 |
manish.sha |
1039 |
int i=1;
|
| 11944 |
manish.sha |
1040 |
//id -0, name -1, sku - 2, vname 3, wh 4, wt 5, mnlc 6, vnlc 7, av8, r9, na 10
|
|
|
1041 |
while ((line = reader.readLine()) != null) {
|
| 11945 |
manish.sha |
1042 |
if(i==1){
|
|
|
1043 |
i= i++;
|
|
|
1044 |
continue;
|
|
|
1045 |
}
|
| 11944 |
manish.sha |
1046 |
values = line.split("\t");
|
|
|
1047 |
NlcLeftOutInventory nlcLoI = new NlcLeftOutInventory();
|
|
|
1048 |
nlcLoI.setItemId(Long.parseLong(values[0]));
|
|
|
1049 |
nlcLoI.setProductName(values[1]);
|
|
|
1050 |
nlcLoI.setOurNlc(Double.parseDouble(values[6]));
|
|
|
1051 |
nlcLoI.setSkuAtSource(values[2]);
|
|
|
1052 |
nlcLoI.setVendorName(values[3]);
|
|
|
1053 |
nlcLoI.setVendorAvailability(Long.parseLong(values[8]));
|
|
|
1054 |
nlcLoI.setVendorNlc(Double.parseDouble(values[7]));
|
|
|
1055 |
nlcLoI.setVendorWarehouseId(Long.parseLong(values[4]));
|
|
|
1056 |
nlcLoI.setWarehouseType(values[5]);
|
|
|
1057 |
nlcLoI.setReserved(Long.parseLong(values[9]));
|
|
|
1058 |
nlcLoI.setTotalAvailability(Long.parseLong(values[10]));
|
|
|
1059 |
|
|
|
1060 |
if(fileName.equalsIgnoreCase("SNAPDEAL")){
|
| 11946 |
manish.sha |
1061 |
if (values[5].equalsIgnoreCase("OURS")) {
|
| 11944 |
manish.sha |
1062 |
subNlcLoiItemsListSD1.add(nlcLoI);
|
|
|
1063 |
}
|
| 11946 |
manish.sha |
1064 |
if (values[5].equalsIgnoreCase("THIRD_PARTY")) {
|
| 11944 |
manish.sha |
1065 |
subNlcLoiItemsListSD2.add(nlcLoI);
|
|
|
1066 |
}
|
|
|
1067 |
}
|
|
|
1068 |
if(fileName.equalsIgnoreCase("FLIPKART")){
|
| 11946 |
manish.sha |
1069 |
if (values[5].equalsIgnoreCase("OURS")) {
|
| 11944 |
manish.sha |
1070 |
subNlcLoiItemsListFK1.add(nlcLoI);
|
|
|
1071 |
}
|
| 11946 |
manish.sha |
1072 |
if (values[5].equalsIgnoreCase("THIRD_PARTY")) {
|
| 11944 |
manish.sha |
1073 |
subNlcLoiItemsListFK2.add(nlcLoI);
|
|
|
1074 |
}
|
|
|
1075 |
}
|
| 11945 |
manish.sha |
1076 |
i++;
|
| 11944 |
manish.sha |
1077 |
}
|
|
|
1078 |
StringBuffer sb = new StringBuffer();
|
| 11940 |
manish.sha |
1079 |
sb.append("<html><table border=\"1\" align=\"center\">"
|
|
|
1080 |
+ "<caption><b>" + "LEFT OUT INVENTORY DETAIL" + "</b></caption>"
|
|
|
1081 |
+ "<tr>" + "<td><b>" + "ITEM-ID" + "</b></td>" + "<td><b>"
|
|
|
1082 |
+ "PRODUCT-NAME" + "</b></td>" + "<td><b>" + "SKU-AT-SOURCE"
|
|
|
1083 |
+ "</b></td>" + "<td><b>" + "VENDOR-NAME" + "</b></td>"
|
|
|
1084 |
+ "<td><b>" + "VENDOR-WAREHOUSE" + "</b></td>" + "<td><b>"
|
|
|
1085 |
+ "WAREHOUSE-TYPE" + "</b></td>" + "<td><b>" + "MAX-OUR-NLC"
|
|
|
1086 |
+ "</b></td>" + "</b></td>" + "<td><b>" + "VENDOR-NLC"
|
|
|
1087 |
+ "</b></td>" + "<td><b>" + "AVAILABILITY-COUNT" + "</b></td>"
|
|
|
1088 |
+ "<td><b>" + "RESERVED-COUNT" + "</b></td>"
|
|
|
1089 |
+ "<td><b>" + "NET-AVAILABILITY" + "</b></td>"
|
|
|
1090 |
+ "</tr>");
|
| 11944 |
manish.sha |
1091 |
|
|
|
1092 |
if(fileName.equalsIgnoreCase("SNAPDEAL")){
|
|
|
1093 |
if (subNlcLoiItemsListSD1 != null
|
|
|
1094 |
&& subNlcLoiItemsListSD1.size() >= 2) {
|
|
|
1095 |
Collections.sort(subNlcLoiItemsListSD1,
|
|
|
1096 |
new NlcLeftOutInventoryComparator());
|
|
|
1097 |
}
|
|
|
1098 |
if (subNlcLoiItemsListSD2 != null
|
|
|
1099 |
&& subNlcLoiItemsListSD2.size() >= 2) {
|
|
|
1100 |
Collections.sort(subNlcLoiItemsListSD2,
|
|
|
1101 |
new NlcLeftOutInventoryComparator());
|
|
|
1102 |
}
|
|
|
1103 |
mainNlcLoiItemsListSD.addAll(subNlcLoiItemsListSD1);
|
|
|
1104 |
mainNlcLoiItemsListSD.addAll(subNlcLoiItemsListSD2);
|
|
|
1105 |
|
| 11940 |
manish.sha |
1106 |
for(NlcLeftOutInventory obj: mainNlcLoiItemsListSD){
|
|
|
1107 |
sb.append("<tr>"+"<td>"+obj.getItemId()+"</td>"
|
|
|
1108 |
+"<td>"+obj.getProductName()+"</td>"
|
|
|
1109 |
+"<td>"+obj.getSkuAtSource()+"</td>"
|
|
|
1110 |
+"<td>"+obj.getVendorName()+"</td>"
|
|
|
1111 |
+"<td>"+obj.getVendorWarehouseId()+"</td>"
|
|
|
1112 |
+"<td>"+obj.getWarehouseType()+"</td>"
|
|
|
1113 |
+"<td>"+obj.getOurNlc()+"</td>"
|
|
|
1114 |
+"<td>"+obj.getVendorNlc()+"</td>"
|
|
|
1115 |
+"<td>"+obj.getVendorAvailability()+"</td>"
|
|
|
1116 |
+"<td>"+obj.getReserved()+"</td>"
|
|
|
1117 |
+"<td>"+obj.getTotalAvailability()+"</td>"+"</tr>"
|
| 11944 |
manish.sha |
1118 |
);
|
| 11940 |
manish.sha |
1119 |
}
|
| 11944 |
manish.sha |
1120 |
}
|
| 11940 |
manish.sha |
1121 |
|
| 11944 |
manish.sha |
1122 |
if(fileName.equalsIgnoreCase("FLIPKART")){
|
|
|
1123 |
if (subNlcLoiItemsListFK1 != null
|
|
|
1124 |
&& subNlcLoiItemsListFK1.size() >= 2) {
|
|
|
1125 |
Collections.sort(subNlcLoiItemsListFK1,
|
|
|
1126 |
new NlcLeftOutInventoryComparator());
|
|
|
1127 |
}
|
|
|
1128 |
if (subNlcLoiItemsListFK2 != null
|
|
|
1129 |
&& subNlcLoiItemsListFK2.size() >= 2) {
|
|
|
1130 |
Collections.sort(subNlcLoiItemsListFK2,
|
|
|
1131 |
new NlcLeftOutInventoryComparator());
|
|
|
1132 |
}
|
|
|
1133 |
mainNlcLoiItemsListFK.addAll(subNlcLoiItemsListFK1);
|
|
|
1134 |
mainNlcLoiItemsListFK.addAll(subNlcLoiItemsListFK2);
|
|
|
1135 |
|
| 11940 |
manish.sha |
1136 |
for(NlcLeftOutInventory obj: mainNlcLoiItemsListFK){
|
|
|
1137 |
sb.append("<tr>"+"<td>"+obj.getItemId()+"</td>"
|
|
|
1138 |
+"<td>"+obj.getProductName()+"</td>"
|
|
|
1139 |
+"<td>"+obj.getSkuAtSource()+"</td>"
|
|
|
1140 |
+"<td>"+obj.getVendorName()+"</td>"
|
|
|
1141 |
+"<td>"+obj.getVendorWarehouseId()+"</td>"
|
|
|
1142 |
+"<td>"+obj.getWarehouseType()+"</td>"
|
|
|
1143 |
+"<td>"+obj.getOurNlc()+"</td>"
|
|
|
1144 |
+"<td>"+obj.getVendorNlc()+"</td>"
|
|
|
1145 |
+"<td>"+obj.getVendorAvailability()+"</td>"
|
|
|
1146 |
+"<td>"+obj.getReserved()+"</td>"
|
|
|
1147 |
+"<td>"+obj.getTotalAvailability()+"</td>"+"</tr>"
|
| 11944 |
manish.sha |
1148 |
);
|
| 11940 |
manish.sha |
1149 |
}
|
| 11944 |
manish.sha |
1150 |
}
|
|
|
1151 |
|
| 11940 |
manish.sha |
1152 |
sb.append("</table></html>");
|
| 11944 |
manish.sha |
1153 |
|
| 11940 |
manish.sha |
1154 |
BufferedWriter out = new BufferedWriter(new FileWriter("/tmp/"+fileName+"-leftOutInv-file.htm"));
|
|
|
1155 |
out.write(sb.toString());
|
|
|
1156 |
out.flush();
|
|
|
1157 |
out.close();
|
|
|
1158 |
|
| 11944 |
manish.sha |
1159 |
|
| 11874 |
manish.sha |
1160 |
List<File> files = new ArrayList<File>();
|
|
|
1161 |
files.add(file);
|
|
|
1162 |
|
| 11940 |
manish.sha |
1163 |
mailer.sendSSLMessage(sendTo,
|
|
|
1164 |
"Inventory not Sent due to NLC Limitaion in case of - "
|
| 11944 |
manish.sha |
1165 |
+ fileName, "Please find attached file.",
|
| 11940 |
manish.sha |
1166 |
emailFromAddress, password, "/tmp/" + fileName + "-leftOutInv.xls", "/tmp/"+fileName+"-leftOutInv-file.htm");
|
|
|
1167 |
/*mailer.sendSSLMessage(sendTo,
|
|
|
1168 |
"Inventory not Sent due to NLC Limitaion in case of - "
|
|
|
1169 |
+ fileName, "Please find attached file.",
|
|
|
1170 |
emailFromAddress, password, files);*/
|
| 11874 |
manish.sha |
1171 |
} catch (Exception e) {
|
|
|
1172 |
e.printStackTrace();
|
| 11891 |
manish.sha |
1173 |
try {
|
| 11940 |
manish.sha |
1174 |
mailer.sendSSLMessage(sendTo,
|
|
|
1175 |
"Error while creating file from data ",
|
|
|
1176 |
emailFromAddress, password, "");
|
| 11874 |
manish.sha |
1177 |
} catch (MessagingException e1) {
|
|
|
1178 |
e1.printStackTrace();
|
| 11891 |
manish.sha |
1179 |
}
|
| 11874 |
manish.sha |
1180 |
}
|
|
|
1181 |
}
|
|
|
1182 |
|
| 11940 |
manish.sha |
1183 |
// private static DefaultHttpClient client = new DefaultHttpClient();
|
| 11874 |
manish.sha |
1184 |
|
|
|
1185 |
public static void main(String[] args) throws Exception {
|
|
|
1186 |
calculateinventory();
|
| 11889 |
manish.sha |
1187 |
createAndSendLeftOutInventoryFile(nlcLoiItemsMapSD, "SNAPDEAL");
|
|
|
1188 |
createAndSendLeftOutInventoryFile(nlcLoiItemsMapFK, "FLIPKART");
|
| 11874 |
manish.sha |
1189 |
|
| 11940 |
manish.sha |
1190 |
/*
|
|
|
1191 |
* HttpPost post = new
|
|
|
1192 |
* HttpPost("http://selleraccounts.snapdeal.com/keymaker/login");
|
|
|
1193 |
* HttpGet get = new HttpGet(
|
|
|
1194 |
* "http://seller.snapdeal.com/pricing/search?gridType=normal&_search=false&nd=1392188583467&rows=30&page=1&sidx=&sord=asc"
|
|
|
1195 |
* ); BufferedReader rd= null; List<NameValuePair> nameValuePairs = new
|
|
|
1196 |
* ArrayList<NameValuePair>(); nameValuePairs.add(new
|
|
|
1197 |
* BasicNameValuePair("username", "khushal.bhatia@saholic.com"));
|
|
|
1198 |
* nameValuePairs.add(new BasicNameValuePair("password", "sonline"));
|
|
|
1199 |
* nameValuePairs.add(new BasicNameValuePair("lt",
|
|
|
1200 |
* "LT-14717-oFCLyRTRMWfMDeczgXm0aaufUjfwPV")); nameValuePairs.add(new
|
|
|
1201 |
* BasicNameValuePair("execution", "e1s1")); nameValuePairs.add(new
|
|
|
1202 |
* BasicNameValuePair("_eventId", "submit")); nameValuePairs.add(new
|
|
|
1203 |
* BasicNameValuePair("submit", "LOGIN")); //post.setEntity(new
|
|
|
1204 |
* UrlEncodedFormEntity(nameValuePairs,"utf-8"));
|
|
|
1205 |
*
|
|
|
1206 |
* HttpResponse response = null; try { response = client.execute(post);
|
|
|
1207 |
* } catch (ClientProtocolException e) { // TODO Auto-generated catch
|
|
|
1208 |
* block e.printStackTrace(); } catch (IOException e) { // TODO
|
|
|
1209 |
* Auto-generated catch block e.printStackTrace(); }
|
|
|
1210 |
*
|
|
|
1211 |
* try { rd = new BufferedReader(new
|
|
|
1212 |
* InputStreamReader(response.getEntity().getContent())); } catch
|
|
|
1213 |
* (IllegalStateException e1) { // TODO Auto-generated catch block
|
|
|
1214 |
* e1.printStackTrace(); } catch (IOException e1) { // TODO
|
|
|
1215 |
* Auto-generated catch block e1.printStackTrace(); } String line = "";
|
|
|
1216 |
* try { while ((line = rd.readLine()) != null) {
|
|
|
1217 |
* System.out.println(line); } } catch (IOException e) { // TODO
|
|
|
1218 |
* Auto-generated catch block e.printStackTrace(); }
|
|
|
1219 |
*
|
|
|
1220 |
* for(Header h: response.getAllHeaders()){
|
|
|
1221 |
* System.out.println(h.getName()+" "+h.getValue()); }
|
|
|
1222 |
*
|
|
|
1223 |
*
|
|
|
1224 |
* try { response = client.execute(get); } catch
|
|
|
1225 |
* (ClientProtocolException e) { // TODO Auto-generated catch block
|
|
|
1226 |
* e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated
|
|
|
1227 |
* catch block e.printStackTrace(); }
|
|
|
1228 |
*
|
|
|
1229 |
* try { rd = new BufferedReader(new
|
|
|
1230 |
* InputStreamReader(response.getEntity().getContent())); } catch
|
|
|
1231 |
* (IllegalStateException e1) { // TODO Auto-generated catch block
|
|
|
1232 |
* e1.printStackTrace(); } catch (IOException e1) { // TODO
|
|
|
1233 |
* Auto-generated catch block e1.printStackTrace(); }
|
|
|
1234 |
*
|
|
|
1235 |
* System.out.println("Get Response for Get Request");
|
|
|
1236 |
*
|
|
|
1237 |
* try { while ((line = rd.readLine()) != null) {
|
|
|
1238 |
* System.out.println(line); } } catch (IOException e) { // TODO
|
|
|
1239 |
* Auto-generated catch block e.printStackTrace(); }
|
|
|
1240 |
*/
|
| 11874 |
manish.sha |
1241 |
|
|
|
1242 |
}
|
|
|
1243 |
}
|