Subversion Repositories SmartDukaan

Rev

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

Rev 24592 Rev 24603
Line 36... Line 36...
36
 
36
 
37
	private static final Logger LOGGER = LogManager.getLogger(Application.class);
37
	private static final Logger LOGGER = LogManager.getLogger(Application.class);
38
 
38
 
39
	@Autowired
39
	@Autowired
40
	private FofoStoreRepository fofoStoreRepository;
40
	private FofoStoreRepository fofoStoreRepository;
41
	
41
 
42
	public static void main(String[] args) throws Throwable {
42
	public static void main(String[] args) throws Throwable {
43
		new SpringApplicationBuilder(Application.class).web(WebApplicationType.NONE).run(args);
43
		new SpringApplicationBuilder(Application.class).web(WebApplicationType.NONE).run(args);
44
	}
44
	}
45
 
45
 
46
	@Bean
46
	@Bean
Line 64... Line 64...
64
 
64
 
65
		Properties javaMailProperties = new Properties();
65
		Properties javaMailProperties = new Properties();
66
		javaMailProperties.put("mail.smtp.starttls.enable", "false");
66
		javaMailProperties.put("mail.smtp.starttls.enable", "false");
67
		javaMailProperties.put("mail.smtp.auth", "true");
67
		javaMailProperties.put("mail.smtp.auth", "true");
68
		javaMailProperties.put("mail.transport.protocol", "smtp");
68
		javaMailProperties.put("mail.transport.protocol", "smtp");
69
		//javaMailProperties.put("mail.debug", "true");// Prints out everything on screen
69
		// javaMailProperties.put("mail.debug", "true");// Prints out everything on
-
 
70
		// screen
70
 
71
 
71
		mailSender.setJavaMailProperties(javaMailProperties);
72
		mailSender.setJavaMailProperties(javaMailProperties);
72
		return mailSender;
73
		return mailSender;
73
	}
74
	}
74
 
75
 
Line 96... Line 97...
96
	@Autowired
97
	@Autowired
97
	private ScheduledTasks scheduledTasks;
98
	private ScheduledTasks scheduledTasks;
98
 
99
 
99
	@Override
100
	@Override
100
	public void run(ApplicationArguments args) throws Exception {
101
	public void run(ApplicationArguments args) throws Exception {
101
		
102
 
102
		LOGGER.info("Called run method");
103
		LOGGER.info("Called run method");
-
 
104
		if (args.containsOption("reco")) {
103
		try {
105
			try {
104
			scheduledTasks.dryRunSchemeReco();
106
				scheduledTasks.dryRunSchemeReco();
105
		} catch (Exception e) {
107
			} catch (Exception e) {
106
			e.printStackTrace();
108
				e.printStackTrace();
-
 
109
			}
-
 
110
			System.exit(0);
107
		}
111
		}
108
		System.exit(0);
-
 
109
		if (args.containsOption("once")) {
112
		if (args.containsOption("once")) {
110
			if (args.containsOption("1")) {
113
			if (args.containsOption("1")) {
111
				if(args.containsOption("test")) {
114
				if (args.containsOption("test")) {
112
					scheduledTasks.sendPartnerInvestmentDetails(args.getOptionValues("email"));
115
					scheduledTasks.sendPartnerInvestmentDetails(args.getOptionValues("email"));
113
				} else {
116
				} else {
114
					scheduledTasks.sendPartnerInvestmentDetails();
117
					scheduledTasks.sendPartnerInvestmentDetails();
115
				}
118
				}
116
				System.exit(0);
119
				System.exit(0);
117
			}
120
			}
118
			if (args.containsOption("saleHeads")) {
121
			if (args.containsOption("saleHeads")) {
119
				List<SaleHeadDetails> saleHeadDetails=fofoStoreRepository.selectAllSalesHeadDetails();
122
				List<SaleHeadDetails> saleHeadDetails = fofoStoreRepository.selectAllSalesHeadDetails();
120
				for(SaleHeadDetails saleHeadDetail:saleHeadDetails)
123
				for (SaleHeadDetails saleHeadDetail : saleHeadDetails) {
121
				{
-
 
122
					scheduledTasks.sendMailToSalesHeadAboutTargetAndSales(saleHeadDetail);
124
					scheduledTasks.sendMailToSalesHeadAboutTargetAndSales(saleHeadDetail);
123
				}
125
				}
124
				System.exit(0);
126
				System.exit(0);
125
				
127
 
126
			}
128
			}
127
			if (args.containsOption("partners")) {
129
			if (args.containsOption("partners")) {
128
					scheduledTasks.sendMailToPartnerAboutTargetAndSales();
130
				scheduledTasks.sendMailToPartnerAboutTargetAndSales();
129
				System.exit(0);
131
				System.exit(0);
130
				
132
 
131
			}
133
			}
132
			if (args.containsOption("3")) {
134
			if (args.containsOption("3")) {
133
				if(args.getOptionNames().contains("offset")) {
135
				if (args.getOptionNames().contains("offset")) {
134
					int offset = Integer.parseInt(args.getOptionValues("offset").get(0));
136
					int offset = Integer.parseInt(args.getOptionValues("offset").get(0));
135
					if(args.getOptionNames().contains("days")) {
137
					if (args.getOptionNames().contains("days")) {
136
						int durationDays = Integer.parseInt(args.getOptionValues("days").get(0));
138
						int durationDays = Integer.parseInt(args.getOptionValues("days").get(0));
137
						scheduledTasks.processScheme(offset, durationDays);
139
						scheduledTasks.processScheme(offset, durationDays);
138
					} else {
140
					} else {
139
						scheduledTasks.processScheme(offset);
141
						scheduledTasks.processScheme(offset);
140
					}
142
					}
141
				} else if (args.containsOption("catalogid")) {
143
				} else if (args.containsOption("catalogid")) {
142
					//scheduledTasks.processSchemeForModel(args.getOptionValues("catalogid").get(0));
144
					// scheduledTasks.processSchemeForModel(args.getOptionValues("catalogid").get(0));
143
				} else {
145
				} else {
144
					scheduledTasks.processScheme();
146
					scheduledTasks.processScheme();
145
				}
147
				}
146
				System.exit(0);
148
				System.exit(0);
147
			}
149
			}
Line 151... Line 153...
151
			if (args.containsOption("5")) {
153
			if (args.containsOption("5")) {
152
				int offset = Integer.parseInt(args.getOptionValues("offset").get(0));
154
				int offset = Integer.parseInt(args.getOptionValues("offset").get(0));
153
				scheduledTasks.processScheme(offset);
155
				scheduledTasks.processScheme(offset);
154
				System.exit(0);
156
				System.exit(0);
155
			}
157
			}
156
			if(args.containsOption("cancelOrder")) {
158
			if (args.containsOption("cancelOrder")) {
157
				List<String> invoiceNumbers = args.getOptionValues("invoiceNumber");
159
				List<String> invoiceNumbers = args.getOptionValues("invoiceNumber");
158
				runOnceTasks.cancelOrder(invoiceNumbers);
160
				runOnceTasks.cancelOrder(invoiceNumbers);
159
			}
161
			}
160
			if(args.containsOption("scrapejd")) {
162
			if (args.containsOption("scrapejd")) {
161
				this.scrapeJD();
163
				this.scrapeJD();
162
			}
164
			}
163
			if(args.containsOption("migratepd")) {
165
			if (args.containsOption("migratepd")) {
164
				scheduledTasks.moveImeisToPriceDropImeis();
166
				scheduledTasks.moveImeisToPriceDropImeis();
165
			}
167
			}
166
			if(args.containsOption("walletmismatch")) {
168
			if (args.containsOption("walletmismatch")) {
167
				scheduledTasks.walletmismatch();
169
				scheduledTasks.walletmismatch();
168
			}
170
			}
169
			if(args.containsOption("schemewalletmismatch")) {
171
			if (args.containsOption("schemewalletmismatch")) {
170
				scheduledTasks.schemewalletmismatch();
172
				scheduledTasks.schemewalletmismatch();
171
			}
173
			}
172
			if(args.containsOption("gst")) {
174
			if (args.containsOption("gst")) {
173
				scheduledTasks.gst();
175
				scheduledTasks.gst();
174
			}
176
			}
175
			System.exit(0);
177
			System.exit(0);
176
		}
178
		}
177
	}
179
	}
178
	
180
 
179
	private void scrapeJD() {
181
	private void scrapeJD() {
180
		String jdUrlTemplate = "https://www.justdial.com/Delhi/Mobile-Phone-Dealers/nct-11216691/page-{0}";
182
		String jdUrlTemplate = "https://www.justdial.com/Delhi/Mobile-Phone-Dealers/nct-11216691/page-{0}";
181
		Formatter formatter = new Formatter();
183
		Formatter formatter = new Formatter();
182
		
184
 
183
	}
185
	}
184
}
186
}