Subversion Repositories SmartDukaan

Rev

Rev 8183 | Rev 9791 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 8183 Rev 9788
Line 8... Line 8...
8
import java.util.List;
8
import java.util.List;
9
import java.util.Map;
9
import java.util.Map;
10
 
10
 
11
import javax.mail.MessagingException;
11
import javax.mail.MessagingException;
12
 
12
 
-
 
13
import org.apache.commons.logging.Log;
-
 
14
import org.apache.commons.logging.LogFactory;
13
import org.apache.thrift.TException;
15
import org.apache.thrift.TException;
14
import org.apache.thrift.transport.TTransportException;
16
import org.apache.thrift.transport.TTransportException;
15
 
17
 
16
import in.shop2020.model.v1.catalog.CatalogService.Client;
18
import in.shop2020.model.v1.catalog.CatalogService.Client;
17
import in.shop2020.model.v1.catalog.Item;
19
import in.shop2020.model.v1.catalog.Item;
Line 20... Line 22...
20
import in.shop2020.thrift.clients.InventoryClient;
22
import in.shop2020.thrift.clients.InventoryClient;
21
import in.shop2020.thrift.clients.UserClient;
23
import in.shop2020.thrift.clients.UserClient;
22
import in.shop2020.utils.GmailUtils;
24
import in.shop2020.utils.GmailUtils;
23
 
25
 
24
public class OosStatusMarker {
26
public class OosStatusMarker {
-
 
27
	private static Log log = LogFactory.getLog(OosStatusMarker.class);
-
 
28
	
25
	private static final Integer OOS_STATUS_CUTOFF_HOUR = 23;
29
	private static final Integer OOS_STATUS_CUTOFF_HOUR = 23;
26
	private static final Integer OOS_STATUS_CUTOFF_MINUTE = 59;
30
	private static final Integer OOS_STATUS_CUTOFF_MINUTE = 59;
27
	
31
	
28
	private static final String[] tomail = {"amar.kumar@shop2020.in", "sandeep.sachdeva@shop2020.in", "khushal.bhatia@shop2020.in", "rajveer.singh@shop2020.in"};
32
	private static final String[] tomail = {"amar.kumar@shop2020.in", "sandeep.sachdeva@shop2020.in", "khushal.bhatia@shop2020.in", "rajveer.singh@shop2020.in"};
29
	//private static final String[] tomail = {"amar.kumar@shop2020.in"};
33
	//private static final String[] tomail = {"amar.kumar@shop2020.in"};
Line 47... Line 51...
47
		} catch (Exception e) {
51
		} catch (Exception e) {
48
			try {
52
			try {
49
				Client catalogClient = new CatalogClient().getClient();
53
				Client catalogClient = new CatalogClient().getClient();
50
				items = catalogClient.getAllAliveItems();
54
				items = catalogClient.getAllAliveItems();
51
			} catch (Exception ex) {
55
			} catch (Exception ex) {
-
 
56
				log.error("Exception while getting all items ", ex);
52
				sendMailForError("Exception while getting all items \n" + e);
57
				sendMailForError("Exception while getting all items \n" + ex);
53
			}
58
			}
54
		}
59
		}
55
		
60
		
56
		String failedItemsList = "";
61
		String failedItemsList = "";
57
		in.shop2020.model.v1.user.UserContextService.Client client = new UserClient().getClient();
62
		in.shop2020.model.v1.user.UserContextService.Client client = new UserClient().getClient();
Line 64... Line 69...
64
						oosStatusMap.put(item.getId(), false);
69
						oosStatusMap.put(item.getId(), false);
65
					} else {
70
					} else {
66
						oosStatusMap.put(item.getId(), true);
71
						oosStatusMap.put(item.getId(), true);
67
					}
72
					}
68
				} catch (TException e) {
73
				} catch (TException e) {
69
					failedItemsList = new Long(item.getId()).toString() + "\n";
74
					failedItemsList = failedItemsList + new Long(item.getId()).toString() + "\n";
70
					continue;
75
					continue;
71
				}
76
				}
72
			}
77
			}
73
		}
78
		}
74
		
79
		
75
		try {
80
		try {
76
			in.shop2020.model.v1.inventory.InventoryService.Client invClient = new InventoryClient().getClient();
81
			in.shop2020.model.v1.inventory.InventoryService.Client invClient = new InventoryClient().getClient();
77
			invClient.addOosStatusForItem(oosStatusMap, oosEvaluationDate.getTimeInMillis());
82
			invClient.addOosStatusForItem(oosStatusMap, oosEvaluationDate.getTimeInMillis());
78
		} catch(Exception e) {
83
		} catch(Exception e) {
-
 
84
			log.error("Error while adding OOS Status", e);
79
			sendMailForError("Error while adding OOS Status" + e);
85
			sendMailForError("Error while adding OOS Status");
-
 
86
			return;
80
		}
87
		}
81
		sendMailForSuccess(failedItemsList);
88
		sendMailForSuccess(failedItemsList);
82
	}
89
	}
83
 
90
 
84
	private static void sendMailForError(String errorMessage) {
91
	private static void sendMailForError(String errorMessage) {