| Line 74... |
Line 74... |
| 74 |
static String emailFromAddress;
|
74 |
static String emailFromAddress;
|
| 75 |
static String password;
|
75 |
static String password;
|
| 76 |
static GmailUtils mailer;
|
76 |
static GmailUtils mailer;
|
| 77 |
static String sendTo[];
|
77 |
static String sendTo[];
|
| 78 |
static StringBuffer notMappedItems =new StringBuffer();
|
78 |
static StringBuffer notMappedItems =new StringBuffer();
|
| 79 |
|
79 |
|
| 80 |
public static void initilaize() {
|
80 |
public static void initilaize() {
|
| 81 |
sdf = new java.text.SimpleDateFormat("yyyy-MM-dd-HH:mm:ss");
|
81 |
sdf = new java.text.SimpleDateFormat("yyyy-MM-dd-HH:mm:ss");
|
| 82 |
emailFromAddress = "build@shop2020.in";
|
82 |
emailFromAddress = "build@shop2020.in";
|
| 83 |
password = "cafe@nes";
|
83 |
password = "cafe@nes";
|
| 84 |
mailer = new GmailUtils();
|
84 |
mailer = new GmailUtils();
|
| 85 |
sendTo = new String[]{"vikram.raghav@shop2020.in"};
|
85 |
sendTo = new String[]{"vikram.raghav@shop2020.in"};
|
| 86 |
/*sendTo = new String[]{ "sandeep.sachdeva@shop2020.in", "vikram.raghav@shop2020.in", "rajneesh.arora@shop2020.in",
|
86 |
/*sendTo = new String[]{ "sandeep.sachdeva@shop2020.in", "vikram.raghav@shop2020.in", "rajneesh.arora@shop2020.in",
|
| 87 |
"khushal.bhatia@shop2020.in","manoj.kumar@saholic.com","chaitnaya.vats@saholic.com",
|
87 |
"khushal.bhatia@shop2020.in","manoj.kumar@saholic.com","chaitnaya.vats@saholic.com",
|
| 88 |
"yukti.jain@shop2020.in","manisha.sharma@shop2020.in","chandan.kumar@shop2020.in","ankush.dhingra@shop2020.in"};
|
88 |
"yukti.jain@shop2020.in","manisha.sharma@shop2020.in","chandan.kumar@shop2020.in","ankush.dhingra@shop2020.in"};
|
| 89 |
*/itemIdpendingOrdersMap = new HashMap<Long,Long>();
|
89 |
*/itemIdpendingOrdersMap = new HashMap<Long,Long>();
|
| 90 |
CatalogClient catalogServiceClient = null;
|
90 |
CatalogClient catalogServiceClient = null;
|
| 91 |
try {
|
91 |
try {
|
| 92 |
catalogServiceClient = new CatalogClient();
|
92 |
catalogServiceClient = new CatalogClient();
|
| 93 |
} catch (TTransportException e1) {
|
93 |
} catch (TTransportException e1) {
|
| 94 |
e1.printStackTrace();
|
94 |
e1.printStackTrace();
|
| 95 |
}
|
95 |
}
|
| 96 |
in.shop2020.model.v1.catalog.CatalogService.Client catalogClient = catalogServiceClient.getClient();
|
96 |
in.shop2020.model.v1.catalog.CatalogService.Client catalogClient = catalogServiceClient.getClient();
|
| 97 |
List<SnapdealItemDetails> allSnapdealItems = null;
|
97 |
List<SnapdealItemDetails> allSnapdealItems = null;
|
| 98 |
try {
|
98 |
try {
|
| 99 |
allSnapdealItems = catalogClient.getAllSnapdealItems();
|
99 |
allSnapdealItems = catalogClient.getAllSnapdealItems();
|
| 100 |
} catch (TException e) {
|
100 |
} catch (TException e) {
|
| 101 |
|
101 |
|
| 102 |
e.printStackTrace();
|
102 |
e.printStackTrace();
|
| 103 |
}
|
103 |
}
|
| 104 |
for(SnapdealItemDetails snapdealItem:allSnapdealItems){
|
104 |
for(SnapdealItemDetails snapdealItem:allSnapdealItems){
|
| 105 |
snapdealItemMap.put(snapdealItem.getSkuAtSnapdeal(),snapdealItem);
|
105 |
snapdealItemMap.put(snapdealItem.getSkuAtSnapdeal(),snapdealItem);
|
| 106 |
itemSnapdealMap.put(snapdealItem.getItem_id(), snapdealItem);
|
106 |
itemSnapdealMap.put(snapdealItem.getItem_id(), snapdealItem);
|
| 107 |
//System.out.println("Creating Item and Snapdeal Map " + snapdealItem.getItem_id() + " " + snapdealItem.getSkuAtSnapdeal());
|
107 |
//System.out.println("Creating Item and Snapdeal Map " + snapdealItem.getItem_id() + " " + snapdealItem.getSkuAtSnapdeal());
|
| 108 |
}
|
108 |
}
|
| 109 |
in.shop2020.model.v1.order.TransactionService.Client transactionClient = null;
|
109 |
in.shop2020.model.v1.order.TransactionService.Client transactionClient = null;
|
| 110 |
try {
|
110 |
try {
|
| 111 |
transactionClient = new TransactionClient("support_transaction_service_server_host","transaction_service_server_port").getClient();
|
111 |
transactionClient = new TransactionClient("support_transaction_service_server_host","transaction_service_server_port").getClient();
|
| 112 |
lastUpdatedInventoryTime = transactionClient.getSourceDetail(7).getLastUpdatedOn();
|
112 |
lastUpdatedInventoryTime = transactionClient.getSourceDetail(7).getLastUpdatedOn();
|
| 113 |
//System.out.println("Time is " + lastUpdatedInventoryTime);
|
113 |
//System.out.println("Time is " + lastUpdatedInventoryTime);
|
| 114 |
} catch (Exception e) {
|
114 |
} catch (Exception e) {
|
| 115 |
try {
|
115 |
try {
|
| 116 |
transactionClient = new TransactionClient("support_transaction_service_server_host","transaction_service_server_port").getClient();
|
116 |
transactionClient = new TransactionClient("support_transaction_service_server_host","transaction_service_server_port").getClient();
|
| 117 |
lastUpdatedInventoryTime = transactionClient.getSourceDetail(7).getLastUpdatedOn();
|
117 |
lastUpdatedInventoryTime = transactionClient.getSourceDetail(7).getLastUpdatedOn();
|
| 118 |
} catch (Exception ex) {
|
118 |
} catch (Exception ex) {
|
| 119 |
ex.printStackTrace();
|
119 |
ex.printStackTrace();
|
| 120 |
}
|
120 |
}
|
| 121 |
}
|
121 |
}
|
| 122 |
|
122 |
|
| 123 |
}
|
123 |
}
|
| 124 |
|
124 |
|
| 125 |
private static void calculateinventory(){
|
125 |
private static void calculateinventory(){
|
| 126 |
CatalogClient catalogServiceClient = null;
|
126 |
CatalogClient catalogServiceClient = null;
|
| Line 730... |
Line 730... |
| 730 |
StringBuffer inventoryChangeItems =new StringBuffer();
|
730 |
StringBuffer inventoryChangeItems =new StringBuffer();
|
| 731 |
StringBuffer heldMoreThanAvailable =new StringBuffer();
|
731 |
StringBuffer heldMoreThanAvailable =new StringBuffer();
|
| 732 |
long sku = 0;
|
732 |
long sku = 0;
|
| 733 |
SnapdealItemDetails snapdealitem;
|
733 |
SnapdealItemDetails snapdealitem;
|
| 734 |
long lastSentInventoryTime = System.currentTimeMillis();
|
734 |
long lastSentInventoryTime = System.currentTimeMillis();
|
| 735 |
List<SnapdealInventoryItem> snapdealInventoryItemList = null;
|
735 |
List<SnapdealInventoryItem> snapdealInventoryItemList = new ArrayList<SnapdealInventoryItem>();;
|
| 736 |
for(Inventory inventory:currentInventoryItemList){
|
736 |
for(Inventory inventory:currentInventoryItemList){
|
| 737 |
//System.out.println(inventory.getSupc()+" "+inventory.getSellerSku()+ " " +inventory.getProductName()+" "+inventory.getAvailableInventory()+" "+inventory.isLive()+" "+itemIdpendingOrdersMap.get(Long.parseLong(inventory.getSellerSku())));
|
737 |
//System.out.println(inventory.getSupc()+" "+inventory.getSellerSku()+ " " +inventory.getProductName()+" "+inventory.getAvailableInventory()+" "+inventory.isLive()+" "+itemIdpendingOrdersMap.get(Long.parseLong(inventory.getSellerSku())));
|
| 738 |
snapdealInventoryItemList = new ArrayList<SnapdealInventoryItem>();
|
- |
|
| 739 |
if(snapdealItemMap.containsKey(inventory.getSellerSku())){
|
738 |
if(snapdealItemMap.containsKey(inventory.getSellerSku())){
|
| 740 |
snapdealitem = snapdealItemMap.get(inventory.getSellerSku());
|
739 |
snapdealitem = snapdealItemMap.get(inventory.getSellerSku());
|
| 741 |
sku = snapdealitem.getItem_id();
|
740 |
sku = snapdealitem.getItem_id();
|
| 742 |
}
|
741 |
}
|
| 743 |
else{
|
742 |
else{
|
| Line 993... |
Line 992... |
| 993 |
ex.printStackTrace();
|
992 |
ex.printStackTrace();
|
| 994 |
}
|
993 |
}
|
| 995 |
}
|
994 |
}
|
| 996 |
InventoryClient inventoryServiceClient = null;
|
995 |
InventoryClient inventoryServiceClient = null;
|
| 997 |
try {
|
996 |
try {
|
| 998 |
inventoryServiceClient = new InventoryClient("inventory_service_server_host","inventory_service_server_port");
|
997 |
inventoryServiceClient = new InventoryClient();
|
| 999 |
} catch (TTransportException e1) {
|
998 |
} catch (TTransportException e1) {
|
| 1000 |
e1.printStackTrace();
|
999 |
e1.printStackTrace();
|
| 1001 |
}
|
1000 |
}
|
| 1002 |
in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = inventoryServiceClient.getClient();
|
- |
|
| 1003 |
try {
|
- |
|
| 1004 |
System.out.println("Before updating to database");
|
1001 |
if(snapdealInventoryItemList.size() > 0){
|
| 1005 |
inventoryClient.addOrUpdateAllSnapdealInventory(snapdealInventoryItemList);
|
- |
|
| 1006 |
} catch (TException e) {
|
- |
|
| 1007 |
e.printStackTrace();
|
- |
|
| 1008 |
inventoryClient = inventoryServiceClient.getClient();
|
1002 |
in.shop2020.model.v1.inventory.InventoryService.Client inventoryClient = inventoryServiceClient.getClient();
|
| 1009 |
try {
|
1003 |
try {
|
| - |
|
1004 |
System.out.println("Before updating to database");
|
| - |
|
1005 |
for(SnapdealInventoryItem item:snapdealInventoryItemList){
|
| - |
|
1006 |
System.out.println("Item ID " + item.getItem_id());
|
| - |
|
1007 |
System.out.println("Availability " + item.getAvailability());
|
| - |
|
1008 |
System.out.println("Updated time " + sdf.format(item.getLastUpdatedOnSnapdeal()));
|
| - |
|
1009 |
System.out.println("Pending Orders " + item.getPendingOrders());
|
| - |
|
1010 |
}
|
| - |
|
1011 |
System.out.println("Snapdeal inventory list size" + snapdealInventoryItemList.size());
|
| 1010 |
inventoryClient.addOrUpdateAllSnapdealInventory(snapdealInventoryItemList);
|
1012 |
inventoryClient.addOrUpdateAllSnapdealInventory(snapdealInventoryItemList);
|
| - |
|
1013 |
} catch (TException e) {
|
| - |
|
1014 |
e.printStackTrace();
|
| - |
|
1015 |
inventoryClient = inventoryServiceClient.getClient();
|
| - |
|
1016 |
try {
|
| - |
|
1017 |
inventoryClient.addOrUpdateAllSnapdealInventory(snapdealInventoryItemList);
|
| 1011 |
} catch (TException e1) {
|
1018 |
} catch (TException e1) {
|
| 1012 |
e1.printStackTrace();
|
1019 |
e1.printStackTrace();
|
| - |
|
1020 |
}
|
| 1013 |
}
|
1021 |
}
|
| 1014 |
}
|
1022 |
}
|
| 1015 |
emailSubjectTxt = "Products back in stock on Snapdeal "+sdf.format(lastSentInventoryTime) + PANEL_TEXT_MAIL;
|
1023 |
emailSubjectTxt = "Products back in stock on Snapdeal "+sdf.format(lastSentInventoryTime) + PANEL_TEXT_MAIL;
|
| 1016 |
tableHeader = "<tr>"
|
1024 |
tableHeader = "<tr>"
|
| 1017 |
+ "<td>" + "Product Name" +"</td>"
|
1025 |
+ "<td>" + "Product Name" +"</td>"
|
| 1018 |
+"<td>" + "Item ID" + "</td>"
|
1026 |
+"<td>" + "Item ID" + "</td>"
|
| 1019 |
+"<td>" + "Old Inventory" + "</td>"
|
1027 |
+"<td>" + "Old Inventory" + "</td>"
|
| 1020 |
+"<td>" + "New Inventory" + "</td>"
|
1028 |
+"<td>" + "New Inventory" + "</td>"
|
| 1021 |
+"</tr>";
|
1029 |
+"</tr>";
|
| 1022 |
|
1030 |
|
| 1023 |
if(backInStockItems.length() > 0){
|
1031 |
if(backInStockItems.length() > 0){
|
| 1024 |
text = "<html><table border=\"1\" align=\"center\">"+tableHeader+backInStockItems.toString()+"</table></html>";
|
1032 |
text = "<html><table border=\"1\" align=\"center\">"+tableHeader+backInStockItems.toString()+"</table></html>";
|
| 1025 |
try {
|
1033 |
try {
|
| 1026 |
mailer.sendSSLMessage(sendTo,emailSubjectTxt, emailFromAddress, password, text);
|
1034 |
mailer.sendSSLMessage(sendTo,emailSubjectTxt, emailFromAddress, password, text);
|
| 1027 |
//mailer.sendSSLMessage(sendTo, emailSubjectTxt, text, emailFromAddress, password, new ArrayList<File>());
|
1035 |
//mailer.sendSSLMessage(sendTo, emailSubjectTxt, text, emailFromAddress, password, new ArrayList<File>());
|
| Line 1104... |
Line 1112... |
| 1104 |
}
|
1112 |
}
|
| 1105 |
}
|
1113 |
}
|
| 1106 |
|
1114 |
|
| 1107 |
}
|
1115 |
}
|
| 1108 |
|
1116 |
|
| 1109 |
public static void main(String[] args){
|
1117 |
public static void main(String[] args){
|
| 1110 |
while(true){
|
1118 |
while(true){
|
| 1111 |
sendsnapdealinventory();
|
1119 |
sendsnapdealinventory();
|
| 1112 |
}
|
1120 |
}
|
| 1113 |
|
1121 |
|
| 1114 |
}
|
1122 |
}
|
| 1115 |
|
1123 |
|
| 1116 |
}
|
1124 |
}
|