| Line 46... |
Line 46... |
| 46 |
import org.apache.thrift.transport.TTransportException;
|
46 |
import org.apache.thrift.transport.TTransportException;
|
| 47 |
|
47 |
|
| 48 |
|
48 |
|
| 49 |
public class FlipkartInventoryReconcillation {
|
49 |
public class FlipkartInventoryReconcillation {
|
| 50 |
|
50 |
|
| 51 |
|
51 |
|
| 52 |
public static void main(String... args) throws ClientProtocolException, IOException, TException, CatalogServiceException{
|
52 |
public static void main(String... args) throws ClientProtocolException, IOException, TException{
|
| 53 |
SimpleDateFormat sdf = new java.text.SimpleDateFormat("yyyy-MM-dd-HH:mm:ss");
|
53 |
SimpleDateFormat sdf = new java.text.SimpleDateFormat("yyyy-MM-dd-HH:mm:ss");
|
| 54 |
String emailFromAddress = "build@shop2020.in";
|
54 |
String emailFromAddress = "build@shop2020.in";
|
| 55 |
String password = "cafe@nes";
|
55 |
String password = "cafe@nes";
|
| 56 |
GmailUtils mailer = new GmailUtils();
|
56 |
GmailUtils mailer = new GmailUtils();
|
| 57 |
String[] sendTo = new String[]{"vikram.raghav@shop2020.in"};
|
57 |
String[] sendTo = new String[]{"vikram.raghav@shop2020.in"};
|
| 58 |
/*String[] sendTo = new String[]{ "sandeep.sachdeva@shop2020.in", "vikram.raghav@shop2020.in", "rajneesh.arora@shop2020.in",
|
58 |
/*String[] sendTo = new String[]{ "sandeep.sachdeva@shop2020.in", "vikram.raghav@shop2020.in", "rajneesh.arora@shop2020.in",
|
| 59 |
"khushal.bhatia@shop2020.in","manoj.kumar@saholic.com","chaitnaya.vats@saholic.com",
|
59 |
"khushal.bhatia@shop2020.in","manoj.kumar@saholic.com","chaitnaya.vats@saholic.com",
|
| 60 |
"yukti.jain@shop2020.in","manoj.pal@shop2020.in","chandan.kumar@shop2020.in","ankush.dhingra@shop2020.in","amar.kumar@shop2020.in"};
|
60 |
"yukti.jain@shop2020.in","manoj.pal@shop2020.in","chandan.kumar@shop2020.in","ankush.dhingra@shop2020.in","amar.kumar@shop2020.in"};
|
| 61 |
*/
|
61 |
*/
|
| 62 |
Map<String,Long> itemInventoryMap = FetchInventoryAtFlipkart();
|
62 |
Map<String,Long> itemInventoryMap = FetchInventoryAtFlipkart();
|
| 63 |
in.shop2020.model.v1.catalog.CatalogService.Client catalogClient = new CatalogClient().getClient();
|
63 |
in.shop2020.model.v1.catalog.CatalogService.Client catalogClient = new CatalogClient().getClient();
|
| 64 |
List<Item> aliveItems = catalogClient.getAllAliveItems();
|
64 |
List<Item> aliveItems = null;
|
| 65 |
List<FlipkartItem> flipkartItems;
|
65 |
List<FlipkartItem> flipkartItems = null;
|
| 66 |
try{
|
66 |
try {
|
| 67 |
flipkartItems = catalogClient.getAllFlipkartItems();
|
67 |
flipkartItems = catalogClient.getAllFlipkartItems();
|
| 68 |
}
|
- |
|
| 69 |
catch(Exception ex){
|
68 |
} catch (TException e1) {
|
| 70 |
catalogClient = new CatalogClient().getClient();
|
69 |
catalogClient = new CatalogClient().getClient();
|
| 71 |
flipkartItems = catalogClient.getAllFlipkartItems();
|
70 |
flipkartItems = catalogClient.getAllFlipkartItems();
|
| - |
|
71 |
e1.printStackTrace();
|
| - |
|
72 |
}
|
| - |
|
73 |
try {
|
| - |
|
74 |
aliveItems = catalogClient.getAllAliveItems();
|
| - |
|
75 |
} catch (TException e1) {
|
| - |
|
76 |
catalogClient = new CatalogClient().getClient();
|
| - |
|
77 |
aliveItems = catalogClient.getAllAliveItems();
|
| - |
|
78 |
e1.printStackTrace();
|
| 72 |
}
|
79 |
}
|
| 73 |
Map<Long,FlipkartItem> flipkartItemsMap = new HashMap<Long,FlipkartItem>();
|
80 |
Map<Long,FlipkartItem> flipkartItemsMap = new HashMap<Long,FlipkartItem>();
|
| 74 |
Map<Long,Item> aliveItemsMap = new HashMap<Long,Item>();
|
81 |
Map<Long,Item> aliveItemsMap = new HashMap<Long,Item>();
|
| 75 |
for(Item item:aliveItems){
|
82 |
for(Item item:aliveItems){
|
| 76 |
aliveItemsMap.put(item.getId(),item);
|
83 |
aliveItemsMap.put(item.getId(),item);
|
| Line 114... |
Line 121... |
| 114 |
snapshot.getItem_id();
|
121 |
snapshot.getItem_id();
|
| 115 |
snapshot.getAvailability();
|
122 |
snapshot.getAvailability();
|
| 116 |
snapshot.getCreatedOrders();
|
123 |
snapshot.getCreatedOrders();
|
| 117 |
snapshot.getHeldOrders();
|
124 |
snapshot.getHeldOrders();
|
| 118 |
if(snapshot.getAvailability() - snapshot.getCreatedOrders() - snapshot.getHeldOrders() !=0){
|
125 |
if(snapshot.getAvailability() - snapshot.getCreatedOrders() - snapshot.getHeldOrders() !=0){
|
| 119 |
reconcilledItems .append("<tr>"
|
126 |
reconcilledItems .append("<tr>"
|
| 120 |
+ "<td>" +getProductName(item)+"</td>"
|
127 |
+ "<td>" +getProductName(item)+"</td>"
|
| 121 |
+"<td>" + snapshot.getItem_id() + "</td>"
|
128 |
+"<td>" + snapshot.getItem_id() + "</td>"
|
| 122 |
+"<td>" + snapshot.getAvailability() + "</td>"
|
129 |
+"<td>" + snapshot.getAvailability() + "</td>"
|
| 123 |
+"<td>" + availabilityAtFlipkart + "</td>"
|
130 |
+"<td>" + availabilityAtFlipkart + "</td>"
|
| 124 |
+"<td>" + snapshot.getCreatedOrders() + "</td>"
|
131 |
+"<td>" + snapshot.getCreatedOrders() + "</td>"
|
| 125 |
+"<td>" + snapshot.getHeldOrders() + "</td>"
|
132 |
+"<td>" + snapshot.getHeldOrders() + "</td>"
|
| 126 |
+"<td>" + (snapshot.getAvailability() - snapshot.getCreatedOrders() - snapshot.getHeldOrders()) + "</td>"
|
133 |
+"<td>" + (snapshot.getAvailability() - snapshot.getCreatedOrders() - snapshot.getHeldOrders()) + "</td>"
|
| 127 |
+"</tr>");
|
134 |
+"</tr>");
|
| 128 |
}
|
135 |
}
|
| 129 |
}
|
136 |
}
|
| 130 |
String text = tableHeader+reconcilledItems.toString()+tableFooter;
|
137 |
String text = tableHeader+reconcilledItems.toString()+tableFooter;
|
| 131 |
try {
|
138 |
try {
|
| 132 |
mailer.sendSSLMessage(sendTo,"Flipkart Inventory Reconcillation ", emailFromAddress, password, text);
|
139 |
mailer.sendSSLMessage(sendTo,"Flipkart Inventory Reconcillation ", emailFromAddress, password, text);
|