| 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;
|
|
|
24 |
import java.io.FileWriter;
|
|
|
25 |
import java.io.IOException;
|
|
|
26 |
import java.io.InputStreamReader;
|
|
|
27 |
import java.util.ArrayList;
|
|
|
28 |
import java.util.HashMap;
|
| 11882 |
manish.sha |
29 |
import java.util.HashSet;
|
|
|
30 |
import java.util.Iterator;
|
| 11874 |
manish.sha |
31 |
import java.util.List;
|
|
|
32 |
import java.util.Map;
|
| 11882 |
manish.sha |
33 |
import java.util.Set;
|
| 11874 |
manish.sha |
34 |
|
|
|
35 |
import javax.mail.MessagingException;
|
|
|
36 |
|
|
|
37 |
import org.apache.commons.lang.StringUtils;
|
|
|
38 |
import org.apache.http.Header;
|
|
|
39 |
import org.apache.http.HttpResponse;
|
|
|
40 |
import org.apache.http.NameValuePair;
|
|
|
41 |
import org.apache.http.client.ClientProtocolException;
|
|
|
42 |
import org.apache.http.client.HttpClient;
|
|
|
43 |
import org.apache.http.client.entity.UrlEncodedFormEntity;
|
|
|
44 |
import org.apache.http.client.methods.HttpGet;
|
|
|
45 |
import org.apache.http.client.methods.HttpPost;
|
|
|
46 |
import org.apache.http.impl.client.DefaultHttpClient;
|
|
|
47 |
import org.apache.http.message.BasicNameValuePair;
|
|
|
48 |
import org.apache.http.params.HttpParams;
|
|
|
49 |
import org.apache.thrift.TException;
|
|
|
50 |
import org.apache.thrift.transport.TTransportException;
|
|
|
51 |
|
|
|
52 |
|
|
|
53 |
public class NlcLeftOutInventoryDetailScript{
|
|
|
54 |
|
|
|
55 |
//private static ArrayList<Inventory> currentInventoryItemList;
|
|
|
56 |
private static List<SnapdealItemDetails> snapdealItems;
|
|
|
57 |
private static List<FlipkartItem> flipkartItems;
|
|
|
58 |
private static List<FlipkartItem> flipkartInventoryItems = new ArrayList<FlipkartItem>();
|
|
|
59 |
static Map<Long,SnapdealItemDetails> snapdealItemMap = new HashMap<Long,SnapdealItemDetails>();
|
|
|
60 |
static Map<Long,FlipkartItem> flipkartItemMap = new HashMap<Long,FlipkartItem>();
|
|
|
61 |
//private static Map<Long, SnapdealItemForInventory> allItemsInventoryMap = new HashMap<Long, SnapdealItemForInventory>();
|
|
|
62 |
private static Map<Long, String> vendorDataMap = new HashMap<Long, String>();
|
|
|
63 |
//static java.text.SimpleDateFormat sdf;
|
|
|
64 |
static String emailFromAddress;
|
|
|
65 |
static String password;
|
|
|
66 |
static GmailUtils mailer;
|
|
|
67 |
static String sendTo[];
|
|
|
68 |
private static List<NlcLeftOutInventory> nlcLeftOutInventoryItemsSD = new ArrayList<NlcLeftOutInventory>();
|
|
|
69 |
private static List<NlcLeftOutInventory> nlcLeftOutInventoryItemsFK = new ArrayList<NlcLeftOutInventory>();
|
|
|
70 |
|
|
|
71 |
static{
|
|
|
72 |
emailFromAddress = "build@shop2020.in";
|
|
|
73 |
password = "cafe@nes";
|
|
|
74 |
mailer = new GmailUtils();
|
|
|
75 |
sendTo = new String[]{"vikram.raghav@shop2020.in", "manish.sharma@shop2020.in"};
|
|
|
76 |
/*sendTo = new String[]{ "sandeep.sachdeva@shop2020.in", "vikram.raghav@shop2020.in", "rajneesh.arora@shop2020.in",
|
|
|
77 |
"khushal.bhatia@shop2020.in","manoj.kumar@saholic.com","chaitnaya.vats@saholic.com",
|
|
|
78 |
"yukti.jain@shop2020.in","manisha.sharma@shop2020.in","chandan.kumar@shop2020.in","ankush.dhingra@shop2020.in"};*/
|
|
|
79 |
CatalogClient catalogServiceClient = null;
|
|
|
80 |
try {
|
|
|
81 |
catalogServiceClient = new CatalogClient();
|
|
|
82 |
} catch (TTransportException e1) {
|
|
|
83 |
// TODO Auto-generated catch block
|
|
|
84 |
e1.printStackTrace();
|
|
|
85 |
}
|
|
|
86 |
in.shop2020.model.v1.catalog.CatalogService.Client catalogClient = catalogServiceClient.getClient();
|
|
|
87 |
|
|
|
88 |
try {
|
|
|
89 |
snapdealItems = catalogClient.getAllSnapdealItems();
|
|
|
90 |
flipkartItems = catalogClient.getAllFlipkartItems();
|
|
|
91 |
} catch (TException e) {
|
|
|
92 |
// TODO Auto-generated catch block
|
|
|
93 |
e.printStackTrace();
|
|
|
94 |
}
|
|
|
95 |
for(FlipkartItem flipkartItem:flipkartItems){
|
|
|
96 |
if(flipkartItem.isIsListedOnFlipkart() && !flipkartItem.isSuppressInventoryFeed())
|
|
|
97 |
flipkartInventoryItems.add(flipkartItem);
|
|
|
98 |
}
|
|
|
99 |
|
|
|
100 |
for(FlipkartItem flipkartItem:flipkartItems){
|
|
|
101 |
if(flipkartItem.isIsListedOnFlipkart() && !flipkartItem.isSuppressInventoryFeed()){
|
|
|
102 |
flipkartItemMap.put(flipkartItem.getItem_id(), flipkartItem);
|
|
|
103 |
}
|
|
|
104 |
}
|
|
|
105 |
|
|
|
106 |
for(SnapdealItemDetails snapdealItem:snapdealItems){
|
|
|
107 |
snapdealItemMap.put(snapdealItem.getItem_id(),snapdealItem);
|
|
|
108 |
}
|
|
|
109 |
|
|
|
110 |
if(flipkartItemMap.size()==0){
|
|
|
111 |
String text = "";
|
|
|
112 |
try {
|
|
|
113 |
mailer.sendSSLMessage(sendTo,"No items to check not sent Inventory Data ", emailFromAddress, password, text);
|
|
|
114 |
System.exit(0);
|
|
|
115 |
} catch (MessagingException e) {
|
|
|
116 |
e.printStackTrace();
|
|
|
117 |
}
|
|
|
118 |
}
|
|
|
119 |
|
|
|
120 |
if(snapdealItemMap.size()==0){
|
|
|
121 |
String text = "";
|
|
|
122 |
try {
|
|
|
123 |
mailer.sendSSLMessage(sendTo,"No items to check not sent Inventory Data ", emailFromAddress, password, text);
|
|
|
124 |
System.exit(0);
|
|
|
125 |
} catch (MessagingException e) {
|
|
|
126 |
e.printStackTrace();
|
|
|
127 |
}
|
|
|
128 |
}
|
|
|
129 |
}
|
|
|
130 |
|
|
|
131 |
private static void calculateinventory(){
|
|
|
132 |
CatalogClient catalogServiceClient = null;
|
|
|
133 |
Map<Long,ItemInventory> availability= new HashMap<Long,ItemInventory>();
|
|
|
134 |
try {
|
|
|
135 |
catalogServiceClient = new CatalogClient();
|
|
|
136 |
} catch (TTransportException e) {
|
|
|
137 |
e.printStackTrace();
|
|
|
138 |
}
|
|
|
139 |
in.shop2020.model.v1.catalog.CatalogService.Client catalogClient = catalogServiceClient.getClient();
|
|
|
140 |
try {
|
|
|
141 |
List<Item> aliveItems = catalogClient.getAllAliveItems();
|
|
|
142 |
Map<Long,Item> aliveItemsMap = new HashMap<Long,Item>();
|
|
|
143 |
for(in.shop2020.model.v1.catalog.Item thriftItem:aliveItems){
|
|
|
144 |
aliveItemsMap.put(thriftItem.getId(), thriftItem);
|
|
|
145 |
|
|
|
146 |
}
|
|
|
147 |
InventoryClient inventoryServiceClient = new InventoryClient();
|
|
|
148 |
try {
|
|
|
149 |
inventoryServiceClient = new InventoryClient();
|
|
|
150 |
} catch (TTransportException e) {
|
|
|
151 |
e.printStackTrace();
|
|
|
152 |
}
|
|
|
153 |
in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = inventoryServiceClient.getClient();
|
|
|
154 |
List<Vendor> allVendors = inventoryClient.getAllVendors();
|
|
|
155 |
for(Vendor v: allVendors){
|
|
|
156 |
vendorDataMap.put(v.getId(), v.getName());
|
|
|
157 |
}
|
|
|
158 |
List<in.shop2020.model.v1.inventory.IgnoredInventoryUpdateItems> ignoreItems = inventoryClient.getIgnoredWarehouseidsAndItemids();
|
| 11882 |
manish.sha |
159 |
|
| 11874 |
manish.sha |
160 |
availability = inventoryClient.getInventorySnapshot(0);
|
|
|
161 |
List<Warehouse> allwarehouses = inventoryClient.getWarehouses(null,null,0,0,0);
|
|
|
162 |
Map<Long,Warehouse> allWarehousesMap = new HashMap<Long,Warehouse>();
|
|
|
163 |
for(Warehouse warehouse:allwarehouses){
|
|
|
164 |
allWarehousesMap.put(warehouse.getId(),warehouse);
|
|
|
165 |
}
|
|
|
166 |
List<Warehouse> warehouses = inventoryClient.getWarehouses(WarehouseType.OURS_THIRDPARTY,null,0,0,0);
|
|
|
167 |
List<Warehouse> ours_warehouses = inventoryClient.getWarehouses(WarehouseType.OURS, InventoryType.GOOD, 0, 0, 0);
|
|
|
168 |
List<Long> thirdpartywarehouseids = new ArrayList<Long>();
|
|
|
169 |
List<Long> oursGoodWarehouse = new ArrayList<Long>();
|
|
|
170 |
for(Warehouse warehouse:warehouses){
|
|
|
171 |
thirdpartywarehouseids.add(warehouse.getId());
|
|
|
172 |
}
|
|
|
173 |
for (Warehouse warehouse:ours_warehouses){
|
|
|
174 |
oursGoodWarehouse.add(warehouse.getId());
|
|
|
175 |
}
|
|
|
176 |
/*long available=0;
|
|
|
177 |
long reserve=0;
|
|
|
178 |
long total_warehouse_held=0;
|
|
|
179 |
long heldForSource=0;
|
|
|
180 |
long total_held=0;*/
|
|
|
181 |
double nlc=0;
|
|
|
182 |
double maxnlcSD=0;
|
|
|
183 |
double maxnlcFK=0;
|
|
|
184 |
|
| 11886 |
manish.sha |
185 |
Map<String, Map<Long, NlcLeftOutInventory>> snapdealLeftInvDataMap = new HashMap<String, Map<Long, NlcLeftOutInventory>>();
|
|
|
186 |
Map<String, Map<Long, NlcLeftOutInventory>> flipkartLeftInvDataMap = new HashMap<String, Map<Long, NlcLeftOutInventory>>();
|
| 11874 |
manish.sha |
187 |
|
|
|
188 |
|
|
|
189 |
for(Item thriftItem : aliveItems){
|
|
|
190 |
SnapdealItemDetails snapdealItem = null;
|
|
|
191 |
FlipkartItem flipkartItem = null;
|
|
|
192 |
NlcLeftOutInventory nlcLOISD;
|
|
|
193 |
NlcLeftOutInventory nlcLOIFK;
|
|
|
194 |
maxnlcSD=0;
|
|
|
195 |
maxnlcFK=0;
|
| 11886 |
manish.sha |
196 |
Map<Long, NlcLeftOutInventory> nlcLoiMapSD = new HashMap<Long, NlcLeftOutInventory>();
|
|
|
197 |
Map<Long, NlcLeftOutInventory> nlcLoiMapFK = new HashMap<Long, NlcLeftOutInventory>();
|
| 11882 |
manish.sha |
198 |
Set<NlcLeftOutInventory> nlcLoiSetSD = new HashSet<NlcLeftOutInventory>();
|
|
|
199 |
Set<NlcLeftOutInventory> nlcLoiSetFK = new HashSet<NlcLeftOutInventory>();
|
| 11874 |
manish.sha |
200 |
if(snapdealItemMap.containsKey(thriftItem.getId())){
|
|
|
201 |
snapdealItem = snapdealItemMap.get(thriftItem.getId());
|
|
|
202 |
maxnlcSD = snapdealItem.getMaxNlc();
|
|
|
203 |
}
|
|
|
204 |
if(flipkartItemMap.containsKey(thriftItem.getId())){
|
|
|
205 |
flipkartItem = flipkartItemMap.get(thriftItem.getId());
|
|
|
206 |
maxnlcFK = flipkartItem.getMaxNlc();
|
|
|
207 |
}
|
|
|
208 |
nlc=0;
|
|
|
209 |
List<Warehouse> vendor_warehouses=null;
|
|
|
210 |
if(availability.get(thriftItem.getId())!=null){
|
|
|
211 |
ItemInventory iteminventory = availability.get(thriftItem.getId());
|
|
|
212 |
Map<Long,Long> itemavailability = new HashMap<Long,Long>();
|
|
|
213 |
itemavailability = iteminventory.getAvailability();
|
|
|
214 |
if (thriftItem.isIsWarehousePreferenceSticky() && thriftItem.getPreferredVendor()!=0){
|
|
|
215 |
//System.out.println("Item id "+thriftItem.getId()+".Found prefered vendor and warehouse is marked sticky (Calculating availability)"+thriftItem.getPreferredVendor());
|
|
|
216 |
vendor_warehouses = inventoryClient.getWarehouses(WarehouseType.THIRD_PARTY,InventoryType.GOOD , thriftItem.getPreferredVendor(), 0, 0);
|
|
|
217 |
vendor_warehouses.addAll(ours_warehouses);
|
|
|
218 |
for (Warehouse warehouse:vendor_warehouses){
|
|
|
219 |
if(warehouse.getBillingWarehouseId()!=7){
|
|
|
220 |
if(warehouse.getLogisticsLocation().equals(WarehouseLocation.Delhi) && warehouse.getWarehouseType().equals(WarehouseType.THIRD_PARTY) && warehouse.getVendor().getId()!=1){
|
|
|
221 |
|
|
|
222 |
}
|
|
|
223 |
else{
|
|
|
224 |
continue;
|
|
|
225 |
}
|
|
|
226 |
}
|
|
|
227 |
in.shop2020.model.v1.inventory.IgnoredInventoryUpdateItems ignoredItem = new in.shop2020.model.v1.inventory.IgnoredInventoryUpdateItems();
|
|
|
228 |
ignoredItem.setItemId(thriftItem.getId());
|
|
|
229 |
ignoredItem.setWarehouseId(warehouse.getId());
|
|
|
230 |
if (itemavailability.get(warehouse.getId())!=null && !thirdpartywarehouseids.contains(warehouse.getId()) && !ignoreItems.contains(ignoredItem)){
|
|
|
231 |
try{
|
|
|
232 |
nlc = inventoryClient.getNlcForWarehouse(warehouse.getId(),thriftItem.getId());
|
|
|
233 |
|
|
|
234 |
}
|
|
|
235 |
catch(TTransportException e){
|
|
|
236 |
inventoryClient = inventoryServiceClient.getClient();
|
|
|
237 |
nlc = inventoryClient.getNlcForWarehouse(warehouse.getId(),thriftItem.getId());
|
|
|
238 |
}
|
|
|
239 |
|
|
|
240 |
//maxnlc = catalogClient.getSnapdealItem(thriftItem.getId()).getMaxNlc();
|
|
|
241 |
|
|
|
242 |
if(snapdealItem!=null){
|
|
|
243 |
if(nlc !=0 && (maxnlcSD >= nlc)){
|
|
|
244 |
/*total_warehouse_held = inventoryClient.getHoldInventoryDetailForItemForWarehouseIdExceptSource(thriftItem.getId(), warehouse.getId(), 0);
|
|
|
245 |
heldForSource = heldForSource + total_warehouse_held - inventoryClient.getHoldInventoryDetailForItemForWarehouseIdExceptSource(thriftItem.getId(), warehouse.getId(), 7);
|
|
|
246 |
available = available + itemavailability.get(warehouse.getId());
|
|
|
247 |
total_held = total_held + total_warehouse_held;*/
|
| 11876 |
manish.sha |
248 |
//continue;
|
| 11874 |
manish.sha |
249 |
//System.out.println("itemId:" + thriftItem.getId() + "\ttotal_held: " + total_held + "\theldForSource:" + heldForSource + "\tavailable:" + available);
|
|
|
250 |
}
|
|
|
251 |
else if(maxnlcSD==0){
|
|
|
252 |
/*total_warehouse_held = inventoryClient.getHoldInventoryDetailForItemForWarehouseIdExceptSource(thriftItem.getId(), warehouse.getId(), 0);
|
|
|
253 |
heldForSource = heldForSource + total_warehouse_held - inventoryClient.getHoldInventoryDetailForItemForWarehouseIdExceptSource(thriftItem.getId(), warehouse.getId(), 7);
|
|
|
254 |
available = available + itemavailability.get(warehouse.getId());
|
|
|
255 |
total_held = total_held + total_warehouse_held;*/
|
| 11876 |
manish.sha |
256 |
//continue;
|
| 11874 |
manish.sha |
257 |
//System.out.println("itemId:" + thriftItem.getId() + "\ttotal_held: " + total_held + "\theldForSource:" + heldForSource + "\tavailable:" + available);
|
|
|
258 |
}
|
|
|
259 |
else{
|
| 11875 |
manish.sha |
260 |
long available = itemavailability.get(warehouse.getId());
|
|
|
261 |
if(available>0){
|
|
|
262 |
nlcLOISD= new NlcLeftOutInventory();
|
|
|
263 |
nlcLOISD.setItemId(snapdealItem.getItem_id());
|
|
|
264 |
nlcLOISD.setProductName(snapdealItem.getBrand()+" " +snapdealItem.getModel_name() + " "+ snapdealItem.getModel_number() + " " + snapdealItem.getColor());
|
|
|
265 |
nlcLOISD.setOurNlc(maxnlcSD);
|
|
|
266 |
nlcLOISD.setSkuAtSource(snapdealItem.getSkuAtSnapdeal());
|
|
|
267 |
nlcLOISD.setVendorName(warehouse.getVendor().getName());
|
|
|
268 |
nlcLOISD.setVendorAvailability(available);
|
|
|
269 |
nlcLOISD.setVendorNlc(nlc);
|
| 11882 |
manish.sha |
270 |
nlcLOISD.setVendorWarehouseId(warehouse.getId());
|
| 11886 |
manish.sha |
271 |
if(!nlcLoiMapSD.containsKey(warehouse.getId()))
|
|
|
272 |
nlcLoiMapSD.put(warehouse.getId(), nlcLOISD);
|
| 11882 |
manish.sha |
273 |
|
| 11875 |
manish.sha |
274 |
}
|
| 11874 |
manish.sha |
275 |
}
|
|
|
276 |
}
|
|
|
277 |
|
|
|
278 |
if(flipkartItem!=null){
|
|
|
279 |
if(nlc !=0 && (maxnlcFK >= nlc)){
|
|
|
280 |
/*total_warehouse_held = inventoryClient.getHoldInventoryDetailForItemForWarehouseIdExceptSource(thriftItem.getId(), warehouse.getId(), 0);
|
|
|
281 |
heldForSource = heldForSource + total_warehouse_held - inventoryClient.getHoldInventoryDetailForItemForWarehouseIdExceptSource(thriftItem.getId(), warehouse.getId(), 8);
|
|
|
282 |
available = available + itemavailability.get(warehouse.getId());
|
|
|
283 |
total_held = total_held + total_warehouse_held; */
|
| 11876 |
manish.sha |
284 |
//continue;
|
| 11874 |
manish.sha |
285 |
//System.out.println("itemId:" + thriftItem.getId() + "\ttotal_held: " + total_held + "\theldForSource:" + heldForSource + "\tavailable:" + available);
|
|
|
286 |
}
|
|
|
287 |
else if(maxnlcFK==0){
|
|
|
288 |
/*total_warehouse_held = inventoryClient.getHoldInventoryDetailForItemForWarehouseIdExceptSource(thriftItem.getId(), warehouse.getId(), 0);
|
|
|
289 |
heldForSource = heldForSource + total_warehouse_held - inventoryClient.getHoldInventoryDetailForItemForWarehouseIdExceptSource(thriftItem.getId(), warehouse.getId(), 8);
|
|
|
290 |
available = available + itemavailability.get(warehouse.getId());
|
|
|
291 |
total_held = total_held + total_warehouse_held;*/
|
| 11876 |
manish.sha |
292 |
//continue;
|
| 11874 |
manish.sha |
293 |
//System.out.println("itemId:" + thriftItem.getId() + "\ttotal_held: " + total_held + "\theldForSource:" + heldForSource + "\tavailable:" + available);
|
|
|
294 |
}
|
|
|
295 |
else{
|
| 11875 |
manish.sha |
296 |
long available = itemavailability.get(warehouse.getId());
|
|
|
297 |
if(available>0){
|
|
|
298 |
nlcLOIFK = new NlcLeftOutInventory();
|
|
|
299 |
nlcLOIFK.setItemId(flipkartItem.getItem_id());
|
|
|
300 |
nlcLOIFK.setProductName(thriftItem.getBrand()+" " +thriftItem.getModelName() + " "+ thriftItem.getModelNumber() + " " + thriftItem.getColor());
|
|
|
301 |
nlcLOIFK.setOurNlc(maxnlcFK);
|
|
|
302 |
nlcLOIFK.setSkuAtSource(flipkartItem.getSkuAtFlipkart());
|
|
|
303 |
nlcLOIFK.setVendorName(warehouse.getVendor().getName());
|
|
|
304 |
nlcLOIFK.setVendorAvailability(available);
|
|
|
305 |
nlcLOIFK.setVendorNlc(nlc);
|
| 11882 |
manish.sha |
306 |
nlcLOIFK.setVendorWarehouseId(warehouse.getId());
|
| 11886 |
manish.sha |
307 |
if(!nlcLoiMapFK.containsKey(warehouse.getId()))
|
|
|
308 |
nlcLoiMapFK.put(warehouse.getId(), nlcLOIFK);
|
| 11875 |
manish.sha |
309 |
}
|
| 11874 |
manish.sha |
310 |
}
|
|
|
311 |
}
|
|
|
312 |
//System.out.println("itemId:" + thriftItem.getId() + "\tmaxnlc: " + maxnlc + "\tnlc:" + nlc + "\twid:" + warehouse.getId() );
|
|
|
313 |
|
|
|
314 |
}
|
|
|
315 |
}
|
| 11886 |
manish.sha |
316 |
if(nlcLoiMapSD!=null && nlcLoiMapSD.size()>0){
|
|
|
317 |
snapdealLeftInvDataMap.put(snapdealItem.getSkuAtSnapdeal(), nlcLoiMapSD);
|
| 11884 |
manish.sha |
318 |
}
|
| 11886 |
manish.sha |
319 |
if(nlcLoiMapFK!=null && nlcLoiMapFK.size()>0){
|
|
|
320 |
flipkartLeftInvDataMap.put(flipkartItem.getSkuAtFlipkart(), nlcLoiMapFK);
|
| 11884 |
manish.sha |
321 |
}
|
| 11874 |
manish.sha |
322 |
}
|
|
|
323 |
else{
|
|
|
324 |
for (Map.Entry<Long,Long> entry : itemavailability.entrySet()) {
|
|
|
325 |
if(allWarehousesMap.get(entry.getKey()).getBillingWarehouseId()!=7){
|
|
|
326 |
if(allWarehousesMap.get(entry.getKey()).getLogisticsLocation().equals(WarehouseLocation.Delhi) && allWarehousesMap.get(entry.getKey()).getWarehouseType().equals(WarehouseType.THIRD_PARTY) && allWarehousesMap.get(entry.getKey()).getVendor().getId()!=1){
|
|
|
327 |
|
|
|
328 |
}
|
|
|
329 |
else{
|
|
|
330 |
continue;
|
|
|
331 |
}
|
|
|
332 |
}
|
|
|
333 |
in.shop2020.model.v1.inventory.IgnoredInventoryUpdateItems ignoredItem = new in.shop2020.model.v1.inventory.IgnoredInventoryUpdateItems();
|
|
|
334 |
ignoredItem.setItemId(thriftItem.getId());
|
|
|
335 |
ignoredItem.setWarehouseId(entry.getKey());
|
|
|
336 |
if(!thirdpartywarehouseids.contains(entry.getKey()) && !ignoreItems.contains(ignoredItem)){
|
|
|
337 |
|
|
|
338 |
nlc = inventoryClient.getNlcForWarehouse(entry.getKey(),thriftItem.getId());
|
|
|
339 |
|
|
|
340 |
//System.out.println("itemId:" + thriftItem.getId() + "\tmaxnlc: " + maxnlc + "\tnlc:" + nlc + "\twid:" + entry.getKey() );
|
|
|
341 |
if(snapdealItem!=null){
|
|
|
342 |
if(nlc !=0 && (maxnlcSD >= nlc)){
|
|
|
343 |
/*total_warehouse_held = inventoryClient.getHoldInventoryDetailForItemForWarehouseIdExceptSource(thriftItem.getId(), entry.getKey(), 0);
|
|
|
344 |
heldForSource = heldForSource + total_warehouse_held - inventoryClient.getHoldInventoryDetailForItemForWarehouseIdExceptSource(thriftItem.getId(), entry.getKey(), 7);
|
|
|
345 |
available = available + entry.getValue();
|
|
|
346 |
total_held = total_held + total_warehouse_held;*/
|
| 11876 |
manish.sha |
347 |
//continue;
|
| 11874 |
manish.sha |
348 |
//System.out.println("itemId:" + thriftItem.getId() + "\ttotal_held: " + total_held + "\theldForSource:" + heldForSource + "\tavailable:" + available);
|
|
|
349 |
}
|
|
|
350 |
else if(maxnlcSD==0){
|
|
|
351 |
/*total_warehouse_held = inventoryClient.getHoldInventoryDetailForItemForWarehouseIdExceptSource(thriftItem.getId(), entry.getKey(), 0);
|
|
|
352 |
heldForSource = heldForSource + total_warehouse_held - inventoryClient.getHoldInventoryDetailForItemForWarehouseIdExceptSource(thriftItem.getId(), entry.getKey(), 7);
|
|
|
353 |
available = available + itemavailability.get(entry.getKey());
|
|
|
354 |
total_held = total_held + total_warehouse_held;*/
|
|
|
355 |
|
| 11876 |
manish.sha |
356 |
//continue;
|
| 11874 |
manish.sha |
357 |
//System.out.println("itemId:" + thriftItem.getId() + "\ttotal_held: " + total_held + "\theldForSource:" + heldForSource + "\tavailable:" + available);
|
|
|
358 |
}
|
|
|
359 |
else{
|
| 11875 |
manish.sha |
360 |
long available = itemavailability.get(entry.getKey());
|
|
|
361 |
if(available>0){
|
|
|
362 |
nlcLOISD = new NlcLeftOutInventory();
|
|
|
363 |
nlcLOISD.setItemId(snapdealItem.getItem_id());
|
|
|
364 |
nlcLOISD.setProductName(snapdealItem.getBrand()+" " +snapdealItem.getModel_name() + " "+ snapdealItem.getModel_number() + " " + snapdealItem.getColor());
|
|
|
365 |
nlcLOISD.setOurNlc(maxnlcSD);
|
|
|
366 |
nlcLOISD.setSkuAtSource(snapdealItem.getSkuAtSnapdeal());
|
| 11882 |
manish.sha |
367 |
nlcLOISD.setVendorName(vendorDataMap.get(allWarehousesMap.get(entry.getKey()).getVendor().getId()));
|
| 11875 |
manish.sha |
368 |
nlcLOISD.setVendorAvailability(available);
|
|
|
369 |
nlcLOISD.setVendorNlc(nlc);
|
| 11886 |
manish.sha |
370 |
if(!nlcLoiMapSD.containsKey(entry.getKey()))
|
|
|
371 |
nlcLoiMapSD.put(entry.getKey(), nlcLOISD);
|
| 11875 |
manish.sha |
372 |
}
|
| 11874 |
manish.sha |
373 |
}
|
|
|
374 |
}
|
|
|
375 |
|
|
|
376 |
if(flipkartItem!=null){
|
|
|
377 |
if(nlc !=0 && (maxnlcFK >= nlc)){
|
|
|
378 |
/*total_warehouse_held = inventoryClient.getHoldInventoryDetailForItemForWarehouseIdExceptSource(thriftItem.getId(), entry.getKey(), 0);
|
|
|
379 |
heldForSource = heldForSource + total_warehouse_held - inventoryClient.getHoldInventoryDetailForItemForWarehouseIdExceptSource(thriftItem.getId(), entry.getKey(), 8);
|
|
|
380 |
available = available + entry.getValue();
|
|
|
381 |
total_held = total_held + total_warehouse_held;*/
|
| 11876 |
manish.sha |
382 |
//continue;
|
| 11874 |
manish.sha |
383 |
//System.out.println("itemId:" + thriftItem.getId() + "\ttotal_held: " + total_held + "\theldForSource:" + heldForSource + "\tavailable:" + available);
|
|
|
384 |
}
|
|
|
385 |
else if(maxnlcFK==0){
|
|
|
386 |
/*total_warehouse_held = inventoryClient.getHoldInventoryDetailForItemForWarehouseIdExceptSource(thriftItem.getId(), entry.getKey(), 0);
|
|
|
387 |
heldForSource = heldForSource + total_warehouse_held - inventoryClient.getHoldInventoryDetailForItemForWarehouseIdExceptSource(thriftItem.getId(), entry.getKey(), 8);
|
|
|
388 |
available = available + itemavailability.get(entry.getKey());
|
|
|
389 |
total_held = total_held + total_warehouse_held;*/
|
| 11876 |
manish.sha |
390 |
//continue;
|
| 11874 |
manish.sha |
391 |
//System.out.println("itemId:" + thriftItem.getId() + "\ttotal_held: " + total_held + "\theldForSource:" + heldForSource + "\tavailable:" + available);
|
|
|
392 |
}
|
|
|
393 |
else{
|
| 11875 |
manish.sha |
394 |
long available = itemavailability.get(entry.getKey());
|
|
|
395 |
if(available>0){
|
|
|
396 |
nlcLOIFK = new NlcLeftOutInventory();
|
|
|
397 |
nlcLOIFK.setItemId(flipkartItem.getItem_id());
|
|
|
398 |
nlcLOIFK.setProductName(thriftItem.getBrand()+" " +thriftItem.getModelName() + " "+ thriftItem.getModelNumber() + " " + thriftItem.getColor());
|
|
|
399 |
nlcLOIFK.setOurNlc(maxnlcFK);
|
|
|
400 |
nlcLOIFK.setSkuAtSource(flipkartItem.getSkuAtFlipkart());
|
| 11882 |
manish.sha |
401 |
nlcLOIFK.setVendorName(vendorDataMap.get(allWarehousesMap.get(entry.getKey()).getVendor().getId()));
|
| 11875 |
manish.sha |
402 |
nlcLOIFK.setVendorAvailability(available);
|
|
|
403 |
nlcLOIFK.setVendorNlc(nlc);
|
| 11886 |
manish.sha |
404 |
if(!nlcLoiMapFK.containsKey(entry.getKey()))
|
|
|
405 |
nlcLoiMapFK.put(entry.getKey(), nlcLOIFK);
|
| 11875 |
manish.sha |
406 |
}
|
| 11874 |
manish.sha |
407 |
}
|
|
|
408 |
}
|
|
|
409 |
|
|
|
410 |
|
|
|
411 |
}
|
|
|
412 |
}
|
| 11886 |
manish.sha |
413 |
if(nlcLoiMapSD!=null && nlcLoiMapSD.size()>0){
|
|
|
414 |
snapdealLeftInvDataMap.put(snapdealItem.getSkuAtSnapdeal(), nlcLoiMapSD);
|
| 11884 |
manish.sha |
415 |
}
|
| 11886 |
manish.sha |
416 |
if(nlcLoiMapFK!=null && nlcLoiMapFK.size()>0){
|
|
|
417 |
flipkartLeftInvDataMap.put(flipkartItem.getSkuAtFlipkart(), nlcLoiMapFK);
|
| 11884 |
manish.sha |
418 |
}
|
| 11874 |
manish.sha |
419 |
}
|
|
|
420 |
|
|
|
421 |
Map<Long,Long> itemreserve = new HashMap<Long,Long>();
|
|
|
422 |
itemreserve = iteminventory.getReserved();
|
|
|
423 |
if (thriftItem.isIsWarehousePreferenceSticky() && thriftItem.getPreferredVendor()!=0){
|
|
|
424 |
//System.out.println("Item id "+thriftItem.getId()+".Found prefered vendor and warehouse is marked sticky (Calculating Reserve)"+thriftItem.getPreferredVendor());
|
|
|
425 |
for (Warehouse warehouse:vendor_warehouses){
|
|
|
426 |
if(warehouse.getBillingWarehouseId()!=7){
|
|
|
427 |
if(warehouse.getLogisticsLocation().equals(WarehouseLocation.Delhi) && warehouse.getWarehouseType().equals(WarehouseType.THIRD_PARTY) && warehouse.getVendor().getId()!=1){
|
|
|
428 |
|
|
|
429 |
}
|
|
|
430 |
else{
|
|
|
431 |
continue;
|
|
|
432 |
}
|
|
|
433 |
}
|
|
|
434 |
in.shop2020.model.v1.inventory.IgnoredInventoryUpdateItems ignoredItem = new in.shop2020.model.v1.inventory.IgnoredInventoryUpdateItems();
|
|
|
435 |
ignoredItem.setItemId(thriftItem.getId());
|
|
|
436 |
ignoredItem.setWarehouseId(warehouse.getId());
|
|
|
437 |
if (itemreserve.get(warehouse.getId())!=null && !thirdpartywarehouseids.contains(warehouse.getId()) && !ignoreItems.contains(warehouse.getId())){
|
|
|
438 |
nlc = inventoryClient.getNlcForWarehouse(warehouse.getId(),thriftItem.getId());
|
|
|
439 |
//maxnlc = catalogClient.getSnapdealItem(thriftItem.getId()).getMaxNlc();
|
|
|
440 |
//System.out.println("itemId:" + thriftItem.getId() + "\tmaxnlc: " + maxnlc + "\tnlc:" + nlc + "\twid:" + warehouse.getId() );
|
|
|
441 |
if(snapdealItem!=null){
|
|
|
442 |
if(nlc !=0 && (maxnlcSD >= nlc)){
|
|
|
443 |
//reserve = reserve + itemreserve.get(warehouse.getId());
|
|
|
444 |
//System.out.println("itemId:" + thriftItem.getId() + "\ttotal_held: " + total_held + "\theldForSource:" + heldForSource + "\treserve:" + reserve);
|
| 11876 |
manish.sha |
445 |
//continue;
|
| 11874 |
manish.sha |
446 |
}
|
|
|
447 |
else if(maxnlcSD==0){
|
|
|
448 |
//reserve = reserve + itemreserve.get(warehouse.getId());
|
|
|
449 |
//System.out.println("itemId:" + thriftItem.getId() + "\ttotal_held: " + total_held + "\theldForSource:" + heldForSource + "\treserve:" + reserve);
|
| 11876 |
manish.sha |
450 |
//continue;
|
| 11874 |
manish.sha |
451 |
}
|
|
|
452 |
else{
|
| 11882 |
manish.sha |
453 |
if(snapdealLeftInvDataMap.containsKey(snapdealItem.getSkuAtSnapdeal())){
|
| 11886 |
manish.sha |
454 |
Map<Long, NlcLeftOutInventory> newNlcObjMap = snapdealLeftInvDataMap.get(snapdealItem.getSkuAtSnapdeal());
|
|
|
455 |
if(newNlcObjMap.containsKey(warehouse.getId())){
|
|
|
456 |
NlcLeftOutInventory newObj = newNlcObjMap.get(warehouse.getId());
|
| 11882 |
manish.sha |
457 |
newObj.setReserved(itemreserve.get(warehouse.getId()));
|
|
|
458 |
newObj.setTotalAvailability(newObj.getVendorAvailability()-itemreserve.get(warehouse.getId()));
|
| 11886 |
manish.sha |
459 |
newNlcObjMap.remove(warehouse.getId());
|
|
|
460 |
newNlcObjMap.put(warehouse.getId(), newObj);
|
|
|
461 |
|
| 11882 |
manish.sha |
462 |
}
|
| 11886 |
manish.sha |
463 |
nlcLoiMapSD = newNlcObjMap;
|
| 11874 |
manish.sha |
464 |
}
|
|
|
465 |
}
|
|
|
466 |
}
|
|
|
467 |
|
|
|
468 |
if(flipkartItem!=null){
|
|
|
469 |
if(nlc !=0 && (maxnlcFK >= nlc)){
|
|
|
470 |
//reserve = reserve + itemreserve.get(warehouse.getId());
|
|
|
471 |
//System.out.println("itemId:" + thriftItem.getId() + "\ttotal_held: " + total_held + "\theldForSource:" + heldForSource + "\treserve:" + reserve);
|
| 11876 |
manish.sha |
472 |
//continue;
|
| 11874 |
manish.sha |
473 |
}
|
|
|
474 |
else if(maxnlcFK==0){
|
|
|
475 |
//reserve = reserve + itemreserve.get(warehouse.getId());
|
|
|
476 |
//System.out.println("itemId:" + thriftItem.getId() + "\ttotal_held: " + total_held + "\theldForSource:" + heldForSource + "\treserve:" + reserve);
|
| 11876 |
manish.sha |
477 |
//continue;
|
| 11874 |
manish.sha |
478 |
}
|
|
|
479 |
else{
|
| 11882 |
manish.sha |
480 |
if(flipkartLeftInvDataMap.containsKey(flipkartItem.getSkuAtFlipkart())){
|
| 11886 |
manish.sha |
481 |
Map<Long, NlcLeftOutInventory> newNlcObjMap = flipkartLeftInvDataMap.get(flipkartItem.getSkuAtFlipkart());
|
|
|
482 |
if(newNlcObjMap.containsKey(warehouse.getId())){
|
|
|
483 |
NlcLeftOutInventory newObj = newNlcObjMap.get(warehouse.getId());
|
| 11882 |
manish.sha |
484 |
newObj.setReserved(itemreserve.get(warehouse.getId()));
|
|
|
485 |
newObj.setTotalAvailability(newObj.getVendorAvailability()-itemreserve.get(warehouse.getId()));
|
| 11886 |
manish.sha |
486 |
newNlcObjMap.remove(warehouse.getId());
|
|
|
487 |
newNlcObjMap.put(warehouse.getId(), newObj);
|
|
|
488 |
|
| 11882 |
manish.sha |
489 |
}
|
| 11886 |
manish.sha |
490 |
nlcLoiMapFK = newNlcObjMap;
|
| 11874 |
manish.sha |
491 |
}
|
|
|
492 |
}
|
|
|
493 |
}
|
|
|
494 |
|
|
|
495 |
|
|
|
496 |
}
|
|
|
497 |
}
|
| 11882 |
manish.sha |
498 |
|
| 11886 |
manish.sha |
499 |
if(nlcLoiMapSD!=null && nlcLoiMapSD.size()>0){
|
|
|
500 |
snapdealLeftInvDataMap.put(snapdealItem.getSkuAtSnapdeal(), nlcLoiMapSD);
|
| 11884 |
manish.sha |
501 |
}
|
| 11886 |
manish.sha |
502 |
if(nlcLoiMapFK!=null && nlcLoiMapFK.size()>0){
|
|
|
503 |
flipkartLeftInvDataMap.put(flipkartItem.getSkuAtFlipkart(), nlcLoiMapFK);
|
| 11884 |
manish.sha |
504 |
}
|
| 11882 |
manish.sha |
505 |
|
| 11874 |
manish.sha |
506 |
}else{
|
|
|
507 |
for (Map.Entry<Long,Long> entry : itemreserve.entrySet()) {
|
|
|
508 |
if(allWarehousesMap.get(entry.getKey()).getBillingWarehouseId()!=7){
|
|
|
509 |
if(allWarehousesMap.get(entry.getKey()).getLogisticsLocation().equals(WarehouseLocation.Delhi) && allWarehousesMap.get(entry.getKey()).getWarehouseType().equals(WarehouseType.THIRD_PARTY) && allWarehousesMap.get(entry.getKey()).getVendor().getId()!=1){
|
|
|
510 |
|
|
|
511 |
}
|
|
|
512 |
else{
|
|
|
513 |
continue;
|
|
|
514 |
}
|
|
|
515 |
}
|
|
|
516 |
in.shop2020.model.v1.inventory.IgnoredInventoryUpdateItems ignoredItem = new in.shop2020.model.v1.inventory.IgnoredInventoryUpdateItems();
|
|
|
517 |
ignoredItem.setItemId(thriftItem.getId());
|
|
|
518 |
ignoredItem.setWarehouseId(entry.getKey());
|
|
|
519 |
if(!thirdpartywarehouseids.contains(entry.getKey()) && !ignoreItems.contains(ignoredItem)){
|
|
|
520 |
nlc = inventoryClient.getNlcForWarehouse(entry.getKey(),thriftItem.getId());
|
|
|
521 |
//System.out.println("itemId:" + thriftItem.getId() + "\tmaxnlc: " + maxnlc + "\tnlc:" + nlc + "\twid:" + entry.getKey() );
|
|
|
522 |
if(snapdealItem!=null){
|
|
|
523 |
if(nlc !=0 && (maxnlcSD >= nlc)){
|
|
|
524 |
//reserve = reserve + entry.getValue();
|
|
|
525 |
//System.out.println("itemId:" + thriftItem.getId() + "\ttotal_held: " + total_held + "\theldForSource:" + heldForSource + "\treserve:" + reserve);
|
| 11876 |
manish.sha |
526 |
//continue;
|
| 11874 |
manish.sha |
527 |
}
|
|
|
528 |
else if(maxnlcSD==0){
|
|
|
529 |
//reserve = reserve + entry.getValue();
|
|
|
530 |
//System.out.println("itemId:" + thriftItem.getId() + "\ttotal_held: " + total_held + "\theldForSource:" + heldForSource + "\treserve:" + reserve);
|
| 11876 |
manish.sha |
531 |
//continue;
|
| 11874 |
manish.sha |
532 |
}
|
|
|
533 |
else{
|
| 11882 |
manish.sha |
534 |
if(snapdealLeftInvDataMap.containsKey(snapdealItem.getSkuAtSnapdeal())){
|
| 11886 |
manish.sha |
535 |
Map<Long, NlcLeftOutInventory> newNlcObjMap = snapdealLeftInvDataMap.get(snapdealItem.getSkuAtSnapdeal());
|
|
|
536 |
if(newNlcObjMap.containsKey(entry.getKey())){
|
|
|
537 |
NlcLeftOutInventory newObj = newNlcObjMap.get(entry.getKey());
|
| 11882 |
manish.sha |
538 |
newObj.setReserved(itemreserve.get(entry.getKey()));
|
|
|
539 |
newObj.setTotalAvailability(newObj.getVendorAvailability()-itemreserve.get(entry.getKey()));
|
| 11886 |
manish.sha |
540 |
newNlcObjMap.remove(entry.getKey());
|
|
|
541 |
newNlcObjMap.put(entry.getKey(), newObj);
|
|
|
542 |
|
| 11882 |
manish.sha |
543 |
}
|
| 11886 |
manish.sha |
544 |
nlcLoiMapSD = newNlcObjMap;
|
| 11874 |
manish.sha |
545 |
}
|
|
|
546 |
}
|
|
|
547 |
}
|
|
|
548 |
if(flipkartItem!=null){
|
|
|
549 |
if(nlc !=0 && (maxnlcFK >= nlc)){
|
|
|
550 |
//reserve = reserve + entry.getValue();
|
|
|
551 |
//System.out.println("itemId:" + thriftItem.getId() + "\ttotal_held: " + total_held + "\theldForSource:" + heldForSource + "\treserve:" + reserve);
|
| 11876 |
manish.sha |
552 |
//continue;
|
| 11874 |
manish.sha |
553 |
}
|
|
|
554 |
else if(maxnlcFK==0){
|
|
|
555 |
//reserve = reserve + entry.getValue();
|
|
|
556 |
//System.out.println("itemId:" + thriftItem.getId() + "\ttotal_held: " + total_held + "\theldForSource:" + heldForSource + "\treserve:" + reserve);
|
| 11876 |
manish.sha |
557 |
//continue;
|
| 11874 |
manish.sha |
558 |
}
|
|
|
559 |
else{
|
| 11882 |
manish.sha |
560 |
if(flipkartLeftInvDataMap.containsKey(flipkartItem.getSkuAtFlipkart())){
|
| 11886 |
manish.sha |
561 |
Map<Long, NlcLeftOutInventory> newNlcObjMap = flipkartLeftInvDataMap.get(flipkartItem.getSkuAtFlipkart());
|
|
|
562 |
if(newNlcObjMap.containsKey(entry.getKey())){
|
|
|
563 |
NlcLeftOutInventory newObj = newNlcObjMap.get(entry.getKey());
|
| 11882 |
manish.sha |
564 |
newObj.setReserved(itemreserve.get(entry.getKey()));
|
|
|
565 |
newObj.setTotalAvailability(newObj.getVendorAvailability()-itemreserve.get(entry.getKey()));
|
| 11886 |
manish.sha |
566 |
newNlcObjMap.remove(entry.getKey());
|
|
|
567 |
newNlcObjMap.put(entry.getKey(), newObj);
|
|
|
568 |
|
| 11882 |
manish.sha |
569 |
}
|
| 11886 |
manish.sha |
570 |
nlcLoiMapFK = newNlcObjMap;
|
| 11874 |
manish.sha |
571 |
}
|
|
|
572 |
}
|
|
|
573 |
}
|
|
|
574 |
|
|
|
575 |
}
|
|
|
576 |
|
|
|
577 |
else{
|
|
|
578 |
//System.out.println("skipping inventory for warehouse id " + entry.getKey());
|
|
|
579 |
}
|
|
|
580 |
}
|
| 11882 |
manish.sha |
581 |
|
| 11886 |
manish.sha |
582 |
if(nlcLoiMapSD!=null && nlcLoiMapSD.size()>0){
|
|
|
583 |
snapdealLeftInvDataMap.put(snapdealItem.getSkuAtSnapdeal(), nlcLoiMapSD);
|
| 11884 |
manish.sha |
584 |
}
|
| 11886 |
manish.sha |
585 |
if(nlcLoiMapFK!=null && nlcLoiMapFK.size()>0){
|
|
|
586 |
flipkartLeftInvDataMap.put(flipkartItem.getSkuAtFlipkart(), nlcLoiMapFK);
|
| 11884 |
manish.sha |
587 |
}
|
| 11874 |
manish.sha |
588 |
}
|
|
|
589 |
|
|
|
590 |
|
|
|
591 |
}
|
|
|
592 |
|
| 11886 |
manish.sha |
593 |
for (Map.Entry<String,Map<Long, NlcLeftOutInventory>> entry : snapdealLeftInvDataMap.entrySet()){
|
|
|
594 |
for(NlcLeftOutInventory nlcLOI : entry.getValue().values()){
|
| 11882 |
manish.sha |
595 |
nlcLeftOutInventoryItemsSD.add(nlcLOI);
|
|
|
596 |
}
|
| 11874 |
manish.sha |
597 |
}
|
| 11886 |
manish.sha |
598 |
for (Map.Entry<String,Map<Long, NlcLeftOutInventory>> entry : flipkartLeftInvDataMap.entrySet()){
|
|
|
599 |
for(NlcLeftOutInventory nlcLOI : entry.getValue().values()){
|
| 11882 |
manish.sha |
600 |
nlcLeftOutInventoryItemsFK.add(nlcLOI);
|
|
|
601 |
}
|
| 11874 |
manish.sha |
602 |
}
|
|
|
603 |
|
|
|
604 |
}
|
|
|
605 |
} catch (TException e) {
|
|
|
606 |
// TODO Auto-generated catch block
|
|
|
607 |
e.printStackTrace();
|
|
|
608 |
}
|
|
|
609 |
|
|
|
610 |
}
|
|
|
611 |
|
|
|
612 |
private static void createAndSendLeftOutInventoryFile(List<NlcLeftOutInventory> nlcLeftoutInventoryItems, String fileName){
|
|
|
613 |
try {
|
|
|
614 |
File file = new File("/tmp/" + fileName +"-leftOutInv.xls");
|
|
|
615 |
BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(file));
|
|
|
616 |
bufferedWriter.write(StringUtils.join(new String[] {
|
|
|
617 |
"ItemId",
|
|
|
618 |
"Product Name",
|
|
|
619 |
"SkuAtSource",
|
|
|
620 |
"Vendor Name",
|
|
|
621 |
"Max Our NLC",
|
|
|
622 |
"Vendor NLC",
|
|
|
623 |
"Availability Count",
|
|
|
624 |
"Reserved Count",
|
|
|
625 |
"Total Availabilty"
|
|
|
626 |
}, '\t'));
|
|
|
627 |
|
|
|
628 |
for(NlcLeftOutInventory nlcLOI : nlcLeftoutInventoryItems){
|
|
|
629 |
bufferedWriter.newLine();
|
|
|
630 |
|
|
|
631 |
bufferedWriter.write(StringUtils.join(
|
|
|
632 |
new String[] {
|
|
|
633 |
String.valueOf(nlcLOI.getItemId()),
|
|
|
634 |
nlcLOI.getProductName(),
|
|
|
635 |
nlcLOI.getSkuAtSource(),
|
|
|
636 |
nlcLOI.getVendorName(),
|
|
|
637 |
String.valueOf(nlcLOI.getOurNlc()),
|
|
|
638 |
String.valueOf(nlcLOI.getVendorNlc()),
|
|
|
639 |
String.valueOf(nlcLOI.getVendorAvailability()),
|
|
|
640 |
String.valueOf(nlcLOI.getReserved()),
|
|
|
641 |
String.valueOf(nlcLOI.getTotalAvailability())}, '\t'));
|
|
|
642 |
|
|
|
643 |
}
|
|
|
644 |
bufferedWriter.close();
|
|
|
645 |
|
|
|
646 |
List<File> files = new ArrayList<File>();
|
|
|
647 |
files.add(file);
|
|
|
648 |
|
| 11882 |
manish.sha |
649 |
//mailer.sendSSLMessage(sendTo, "Inventory not Sent due to NLC Limitaion in case of - "+ fileName , "Please find attached file.", emailFromAddress, password, files);
|
| 11874 |
manish.sha |
650 |
} catch (Exception e) {
|
|
|
651 |
e.printStackTrace();
|
| 11882 |
manish.sha |
652 |
/*try {
|
|
|
653 |
//mailer.sendSSLMessage(sendTo,"Error while creating file from data ", emailFromAddress, password, "");
|
| 11874 |
manish.sha |
654 |
} catch (MessagingException e1) {
|
|
|
655 |
e1.printStackTrace();
|
| 11882 |
manish.sha |
656 |
}*/
|
| 11874 |
manish.sha |
657 |
}
|
|
|
658 |
}
|
|
|
659 |
|
|
|
660 |
//private static DefaultHttpClient client = new DefaultHttpClient();
|
|
|
661 |
|
|
|
662 |
public static void main(String[] args) throws Exception {
|
|
|
663 |
calculateinventory();
|
|
|
664 |
createAndSendLeftOutInventoryFile(nlcLeftOutInventoryItemsSD, "SNAPDEAL");
|
|
|
665 |
createAndSendLeftOutInventoryFile(nlcLeftOutInventoryItemsFK, "FLIPKART");
|
|
|
666 |
|
|
|
667 |
|
|
|
668 |
/*HttpPost post = new HttpPost("http://selleraccounts.snapdeal.com/keymaker/login");
|
|
|
669 |
HttpGet get = new HttpGet("http://seller.snapdeal.com/pricing/search?gridType=normal&_search=false&nd=1392188583467&rows=30&page=1&sidx=&sord=asc");
|
|
|
670 |
BufferedReader rd= null;
|
|
|
671 |
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
|
|
|
672 |
nameValuePairs.add(new BasicNameValuePair("username",
|
|
|
673 |
"khushal.bhatia@saholic.com"));
|
|
|
674 |
nameValuePairs.add(new BasicNameValuePair("password",
|
|
|
675 |
"sonline"));
|
|
|
676 |
nameValuePairs.add(new BasicNameValuePair("lt",
|
|
|
677 |
"LT-14717-oFCLyRTRMWfMDeczgXm0aaufUjfwPV"));
|
|
|
678 |
nameValuePairs.add(new BasicNameValuePair("execution",
|
|
|
679 |
"e1s1"));
|
|
|
680 |
nameValuePairs.add(new BasicNameValuePair("_eventId",
|
|
|
681 |
"submit"));
|
|
|
682 |
nameValuePairs.add(new BasicNameValuePair("submit",
|
|
|
683 |
"LOGIN"));
|
|
|
684 |
//post.setEntity(new UrlEncodedFormEntity(nameValuePairs,"utf-8"));
|
|
|
685 |
|
|
|
686 |
HttpResponse response = null;
|
|
|
687 |
try {
|
|
|
688 |
response = client.execute(post);
|
|
|
689 |
} catch (ClientProtocolException e) {
|
|
|
690 |
// TODO Auto-generated catch block
|
|
|
691 |
e.printStackTrace();
|
|
|
692 |
} catch (IOException e) {
|
|
|
693 |
// TODO Auto-generated catch block
|
|
|
694 |
e.printStackTrace();
|
|
|
695 |
}
|
|
|
696 |
|
|
|
697 |
try {
|
|
|
698 |
rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
|
|
|
699 |
} catch (IllegalStateException e1) {
|
|
|
700 |
// TODO Auto-generated catch block
|
|
|
701 |
e1.printStackTrace();
|
|
|
702 |
} catch (IOException e1) {
|
|
|
703 |
// TODO Auto-generated catch block
|
|
|
704 |
e1.printStackTrace();
|
|
|
705 |
}
|
|
|
706 |
String line = "";
|
|
|
707 |
try {
|
|
|
708 |
while ((line = rd.readLine()) != null) {
|
|
|
709 |
System.out.println(line);
|
|
|
710 |
}
|
|
|
711 |
} catch (IOException e) {
|
|
|
712 |
// TODO Auto-generated catch block
|
|
|
713 |
e.printStackTrace();
|
|
|
714 |
}
|
|
|
715 |
|
|
|
716 |
for(Header h: response.getAllHeaders()){
|
|
|
717 |
System.out.println(h.getName()+" "+h.getValue());
|
|
|
718 |
}
|
|
|
719 |
|
|
|
720 |
|
|
|
721 |
try {
|
|
|
722 |
response = client.execute(get);
|
|
|
723 |
} catch (ClientProtocolException e) {
|
|
|
724 |
// TODO Auto-generated catch block
|
|
|
725 |
e.printStackTrace();
|
|
|
726 |
} catch (IOException e) {
|
|
|
727 |
// TODO Auto-generated catch block
|
|
|
728 |
e.printStackTrace();
|
|
|
729 |
}
|
|
|
730 |
|
|
|
731 |
try {
|
|
|
732 |
rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
|
|
|
733 |
} catch (IllegalStateException e1) {
|
|
|
734 |
// TODO Auto-generated catch block
|
|
|
735 |
e1.printStackTrace();
|
|
|
736 |
} catch (IOException e1) {
|
|
|
737 |
// TODO Auto-generated catch block
|
|
|
738 |
e1.printStackTrace();
|
|
|
739 |
}
|
|
|
740 |
|
|
|
741 |
System.out.println("Get Response for Get Request");
|
|
|
742 |
|
|
|
743 |
try {
|
|
|
744 |
while ((line = rd.readLine()) != null) {
|
|
|
745 |
System.out.println(line);
|
|
|
746 |
}
|
|
|
747 |
} catch (IOException e) {
|
|
|
748 |
// TODO Auto-generated catch block
|
|
|
749 |
e.printStackTrace();
|
|
|
750 |
}*/
|
|
|
751 |
|
|
|
752 |
}
|
|
|
753 |
}
|