| 23755 |
amit.gupta |
1 |
package com.smartdukaan.cron;
|
| 23723 |
amit.gupta |
2 |
|
| 24174 |
govind |
3 |
import java.util.List;
|
| 23906 |
amit.gupta |
4 |
import java.util.Properties;
|
|
|
5 |
|
| 23723 |
amit.gupta |
6 |
import org.apache.logging.log4j.LogManager;
|
|
|
7 |
import org.apache.logging.log4j.Logger;
|
| 23898 |
amit.gupta |
8 |
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
9 |
import org.springframework.boot.ApplicationArguments;
|
|
|
10 |
import org.springframework.boot.ApplicationRunner;
|
| 23723 |
amit.gupta |
11 |
import org.springframework.boot.WebApplicationType;
|
|
|
12 |
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|
|
13 |
import org.springframework.boot.builder.SpringApplicationBuilder;
|
|
|
14 |
import org.springframework.cache.annotation.EnableCaching;
|
|
|
15 |
import org.springframework.context.annotation.Bean;
|
|
|
16 |
import org.springframework.context.annotation.ComponentScan;
|
| 23935 |
amit.gupta |
17 |
import org.springframework.context.annotation.Primary;
|
| 23723 |
amit.gupta |
18 |
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
|
|
|
19 |
import org.springframework.core.io.ClassPathResource;
|
| 23906 |
amit.gupta |
20 |
import org.springframework.mail.javamail.JavaMailSender;
|
|
|
21 |
import org.springframework.mail.javamail.JavaMailSenderImpl;
|
| 23723 |
amit.gupta |
22 |
import org.springframework.scheduling.annotation.EnableScheduling;
|
|
|
23 |
|
| 23898 |
amit.gupta |
24 |
import com.smartdukaan.cron.migrations.RunOnceTasks;
|
| 24827 |
amit.gupta |
25 |
import com.smartdukaan.cron.scheduled.Reconciliation;
|
| 23929 |
amit.gupta |
26 |
import com.smartdukaan.cron.scheduled.ScheduledTasks;
|
| 25486 |
amit.gupta |
27 |
import com.spice.profitmandi.common.solr.SolrService;
|
| 24174 |
govind |
28 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
| 25503 |
amit.gupta |
29 |
import com.spice.profitmandi.dao.repository.fofo.PartnerTypeChangeRepository;
|
| 25486 |
amit.gupta |
30 |
import com.spice.profitmandi.service.scheme.SchemeService;
|
| 23724 |
amit.gupta |
31 |
|
| 23723 |
amit.gupta |
32 |
@SpringBootApplication
|
|
|
33 |
@EnableCaching
|
|
|
34 |
@EnableScheduling
|
| 23755 |
amit.gupta |
35 |
@ComponentScan("com.smartdukaan.cron.*, com.spice.profitmandi.common.*")
|
| 24122 |
govind |
36 |
public class Application implements ApplicationRunner {
|
|
|
37 |
|
|
|
38 |
private static final Logger LOGGER = LogManager.getLogger(Application.class);
|
|
|
39 |
|
| 24174 |
govind |
40 |
@Autowired
|
|
|
41 |
private FofoStoreRepository fofoStoreRepository;
|
| 25486 |
amit.gupta |
42 |
|
|
|
43 |
@Autowired
|
|
|
44 |
private SchemeService schemeService;
|
| 25503 |
amit.gupta |
45 |
|
|
|
46 |
@Autowired
|
|
|
47 |
private PartnerTypeChangeRepository partnerTypeChangeRepository;
|
| 24603 |
amit.gupta |
48 |
|
| 23723 |
amit.gupta |
49 |
public static void main(String[] args) throws Throwable {
|
| 23738 |
amit.gupta |
50 |
new SpringApplicationBuilder(Application.class).web(WebApplicationType.NONE).run(args);
|
| 23723 |
amit.gupta |
51 |
}
|
| 24122 |
govind |
52 |
|
| 23723 |
amit.gupta |
53 |
@Bean
|
| 23738 |
amit.gupta |
54 |
public static PropertySourcesPlaceholderConfigurer propertyConfigurer1() {
|
| 23755 |
amit.gupta |
55 |
LOGGER.info("Called Configuration");
|
| 24122 |
govind |
56 |
PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer = new PropertySourcesPlaceholderConfigurer();
|
| 23723 |
amit.gupta |
57 |
propertySourcesPlaceholderConfigurer.setLocation(new ClassPathResource("/META-INF/env.properties"));
|
|
|
58 |
return propertySourcesPlaceholderConfigurer;
|
|
|
59 |
}
|
| 24122 |
govind |
60 |
|
|
|
61 |
@Bean(name = "mailSender")
|
| 23935 |
amit.gupta |
62 |
@Primary
|
| 24122 |
govind |
63 |
public JavaMailSender sendGridMailSender() {
|
|
|
64 |
JavaMailSenderImpl mailSender = new JavaMailSenderImpl();
|
| 23723 |
amit.gupta |
65 |
|
| 24122 |
govind |
66 |
// Using gmail
|
|
|
67 |
mailSender.setHost("smtp.sendgrid.net");
|
|
|
68 |
mailSender.setPort(587);
|
|
|
69 |
mailSender.setUsername("shop2020");
|
|
|
70 |
mailSender.setPassword("U2/=fP,t");
|
|
|
71 |
|
|
|
72 |
Properties javaMailProperties = new Properties();
|
|
|
73 |
javaMailProperties.put("mail.smtp.starttls.enable", "false");
|
|
|
74 |
javaMailProperties.put("mail.smtp.auth", "true");
|
|
|
75 |
javaMailProperties.put("mail.transport.protocol", "smtp");
|
| 24603 |
amit.gupta |
76 |
// javaMailProperties.put("mail.debug", "true");// Prints out everything on
|
|
|
77 |
// screen
|
| 24122 |
govind |
78 |
|
|
|
79 |
mailSender.setJavaMailProperties(javaMailProperties);
|
|
|
80 |
return mailSender;
|
|
|
81 |
}
|
|
|
82 |
|
| 23935 |
amit.gupta |
83 |
@Bean
|
| 24122 |
govind |
84 |
public JavaMailSender googleMailSender() {
|
| 23935 |
amit.gupta |
85 |
JavaMailSenderImpl mailSender = new JavaMailSenderImpl();
|
| 24122 |
govind |
86 |
// Using gmail
|
| 23935 |
amit.gupta |
87 |
mailSender.setHost("smtp.gmail.com");
|
|
|
88 |
mailSender.setPort(587);
|
|
|
89 |
mailSender.setUsername("build@shop2020.in");
|
|
|
90 |
mailSender.setPassword("cafe@nes");
|
| 24122 |
govind |
91 |
|
| 23935 |
amit.gupta |
92 |
Properties javaMailProperties = new Properties();
|
|
|
93 |
javaMailProperties.put("mail.smtp.starttls.enable", "true");
|
|
|
94 |
javaMailProperties.put("mail.smtp.auth", "true");
|
|
|
95 |
javaMailProperties.put("mail.transport.protocol", "smtp");
|
| 24122 |
govind |
96 |
javaMailProperties.put("mail.debug", "true");// Prints out everything on screen
|
| 23935 |
amit.gupta |
97 |
mailSender.setJavaMailProperties(javaMailProperties);
|
|
|
98 |
return mailSender;
|
|
|
99 |
}
|
|
|
100 |
|
| 24122 |
govind |
101 |
@Autowired
|
| 23898 |
amit.gupta |
102 |
private RunOnceTasks runOnceTasks;
|
| 24122 |
govind |
103 |
|
|
|
104 |
@Autowired
|
| 23929 |
amit.gupta |
105 |
private ScheduledTasks scheduledTasks;
|
| 24848 |
amit.gupta |
106 |
|
| 24827 |
amit.gupta |
107 |
@Autowired
|
|
|
108 |
private Reconciliation reconciliation;
|
| 24122 |
govind |
109 |
|
| 25486 |
amit.gupta |
110 |
@Autowired
|
|
|
111 |
private SolrService solrService;
|
|
|
112 |
|
| 23898 |
amit.gupta |
113 |
@Override
|
|
|
114 |
public void run(ApplicationArguments args) throws Exception {
|
|
|
115 |
LOGGER.info("Called run method");
|
| 25503 |
amit.gupta |
116 |
|
|
|
117 |
if (args.containsOption("grouping")) {
|
|
|
118 |
scheduledTasks.grouping();
|
|
|
119 |
System.exit(0);
|
|
|
120 |
}
|
| 25312 |
amit.gupta |
121 |
if (args.containsOption("reconcileExpiredFixedSchemes")) {
|
| 25073 |
amit.gupta |
122 |
reconciliation.reconcileExpiredFixedSchemes();
|
|
|
123 |
System.exit(0);
|
|
|
124 |
}
|
| 25486 |
amit.gupta |
125 |
if(args.containsOption("test")) {
|
|
|
126 |
schemeService.processSchemeIn(9243,175138102);
|
|
|
127 |
throw new Exception();
|
|
|
128 |
}
|
| 25073 |
amit.gupta |
129 |
if (args.containsOption("fixSchemePayouts")) {
|
|
|
130 |
|
| 25029 |
amit.gupta |
131 |
runOnceTasks.fixSchemePayouts();
|
|
|
132 |
System.exit(0);
|
|
|
133 |
}
|
| 25312 |
amit.gupta |
134 |
if (args.containsOption("sendNotification")) {
|
| 25300 |
tejbeer |
135 |
scheduledTasks.sendNotification();
|
|
|
136 |
System.exit(0);
|
|
|
137 |
}
|
| 25022 |
amit.gupta |
138 |
if (args.containsOption("populateSchemes")) {
|
|
|
139 |
runOnceTasks.populateSchemes();
|
|
|
140 |
System.exit(0);
|
|
|
141 |
}
|
| 24855 |
amit.gupta |
142 |
if (args.containsOption("notify")) {
|
| 25073 |
amit.gupta |
143 |
if (args.containsOption("fofoId")) {
|
| 24988 |
tejbeer |
144 |
int fofoId = Integer.parseInt(args.getOptionValues("fofoId").get(0));
|
|
|
145 |
scheduledTasks.sendDailySalesReportNotificationToPartner(fofoId);
|
|
|
146 |
}
|
| 24855 |
amit.gupta |
147 |
System.exit(0);
|
|
|
148 |
}
|
| 24955 |
amit.gupta |
149 |
if (args.containsOption("findMismatchesInIndent")) {
|
|
|
150 |
runOnceTasks.findMismatchesInIndent();
|
|
|
151 |
System.exit(0);
|
|
|
152 |
}
|
| 24862 |
amit.gupta |
153 |
if (args.containsOption("notifyAll")) {
|
|
|
154 |
scheduledTasks.sendDailySalesReportNotificationToPartner(null);
|
|
|
155 |
System.exit(0);
|
|
|
156 |
}
|
| 25029 |
amit.gupta |
157 |
if (args.containsOption("OutSchemeReco")) {
|
| 25073 |
amit.gupta |
158 |
scheduledTasks.dryRunOutSchemeReco();
|
| 24848 |
amit.gupta |
159 |
// runOnceTasks.migrateChallansToInvoices();
|
| 25073 |
amit.gupta |
160 |
// reconciliation.dailyReconciliation();
|
| 24603 |
amit.gupta |
161 |
System.exit(0);
|
| 24592 |
amit.gupta |
162 |
}
|
| 25029 |
amit.gupta |
163 |
if (args.containsOption("dryRunSchemeReco")) {
|
|
|
164 |
scheduledTasks.dryRunSchemeReco();
|
|
|
165 |
// runOnceTasks.migrateChallansToInvoices();
|
| 25073 |
amit.gupta |
166 |
// reconciliation.dailyReconciliation();
|
| 24674 |
amit.gupta |
167 |
System.exit(0);
|
|
|
168 |
}
|
| 25029 |
amit.gupta |
169 |
if (args.containsOption("OutReco1")) {
|
|
|
170 |
scheduledTasks.dryRunSchemeOutReco1();
|
|
|
171 |
System.exit(0);
|
|
|
172 |
}
|
| 24883 |
amit.gupta |
173 |
if (args.containsOption("createTargets")) {
|
|
|
174 |
runOnceTasks.createMonthlyTargets();
|
|
|
175 |
System.exit(0);
|
|
|
176 |
}
|
| 24122 |
govind |
177 |
if (args.containsOption("once")) {
|
|
|
178 |
if (args.containsOption("1")) {
|
| 24603 |
amit.gupta |
179 |
if (args.containsOption("test")) {
|
| 24271 |
amit.gupta |
180 |
scheduledTasks.sendPartnerInvestmentDetails(args.getOptionValues("email"));
|
| 24272 |
amit.gupta |
181 |
} else {
|
|
|
182 |
scheduledTasks.sendPartnerInvestmentDetails();
|
| 24271 |
amit.gupta |
183 |
}
|
| 24122 |
govind |
184 |
System.exit(0);
|
|
|
185 |
}
|
| 24682 |
amit.gupta |
186 |
if (args.containsOption("2")) {
|
| 24696 |
amit.gupta |
187 |
if (args.containsOption("test")) {
|
| 24848 |
amit.gupta |
188 |
String[] emails = new String[args.getOptionValues("email").size()];
|
| 24696 |
amit.gupta |
189 |
scheduledTasks.sendAgeingReport(args.getOptionValues("email").toArray(emails));
|
|
|
190 |
} else {
|
|
|
191 |
scheduledTasks.sendAgeingReport();
|
|
|
192 |
}
|
| 24682 |
amit.gupta |
193 |
System.exit(0);
|
|
|
194 |
}
|
| 25312 |
amit.gupta |
195 |
if (args.containsOption("tvs")) {
|
| 25313 |
amit.gupta |
196 |
scheduledTasks.sendTargetVsSalesReport(null);
|
| 24122 |
govind |
197 |
System.exit(0);
|
|
|
198 |
}
|
| 24151 |
amit.gupta |
199 |
if (args.containsOption("3")) {
|
| 24603 |
amit.gupta |
200 |
if (args.getOptionNames().contains("offset")) {
|
| 24461 |
amit.gupta |
201 |
int offset = Integer.parseInt(args.getOptionValues("offset").get(0));
|
| 24603 |
amit.gupta |
202 |
if (args.getOptionNames().contains("days")) {
|
| 24461 |
amit.gupta |
203 |
int durationDays = Integer.parseInt(args.getOptionValues("days").get(0));
|
|
|
204 |
scheduledTasks.processScheme(offset, durationDays);
|
|
|
205 |
} else {
|
|
|
206 |
scheduledTasks.processScheme(offset);
|
|
|
207 |
}
|
| 24560 |
amit.gupta |
208 |
} else if (args.containsOption("catalogid")) {
|
| 24603 |
amit.gupta |
209 |
// scheduledTasks.processSchemeForModel(args.getOptionValues("catalogid").get(0));
|
| 24461 |
amit.gupta |
210 |
} else {
|
|
|
211 |
scheduledTasks.processScheme();
|
|
|
212 |
}
|
| 24151 |
amit.gupta |
213 |
System.exit(0);
|
|
|
214 |
}
|
| 24238 |
amit.gupta |
215 |
if (args.containsOption("4")) {
|
| 24241 |
amit.gupta |
216 |
scheduledTasks.evaluateExcessSchemeOut();
|
| 24256 |
amit.gupta |
217 |
}
|
|
|
218 |
if (args.containsOption("5")) {
|
|
|
219 |
int offset = Integer.parseInt(args.getOptionValues("offset").get(0));
|
|
|
220 |
scheduledTasks.processScheme(offset);
|
| 24238 |
amit.gupta |
221 |
System.exit(0);
|
|
|
222 |
}
|
| 24603 |
amit.gupta |
223 |
if (args.containsOption("cancelOrder")) {
|
| 24265 |
amit.gupta |
224 |
List<String> invoiceNumbers = args.getOptionValues("invoiceNumber");
|
|
|
225 |
runOnceTasks.cancelOrder(invoiceNumbers);
|
|
|
226 |
}
|
| 24641 |
amit.gupta |
227 |
if (args.containsOption("migratePurchase")) {
|
|
|
228 |
runOnceTasks.migratePurchase();
|
|
|
229 |
}
|
| 24603 |
amit.gupta |
230 |
if (args.containsOption("migratepd")) {
|
| 24431 |
amit.gupta |
231 |
scheduledTasks.moveImeisToPriceDropImeis();
|
|
|
232 |
}
|
| 24603 |
amit.gupta |
233 |
if (args.containsOption("walletmismatch")) {
|
| 24542 |
amit.gupta |
234 |
scheduledTasks.walletmismatch();
|
|
|
235 |
}
|
| 24603 |
amit.gupta |
236 |
if (args.containsOption("schemewalletmismatch")) {
|
| 24580 |
amit.gupta |
237 |
scheduledTasks.schemewalletmismatch();
|
|
|
238 |
}
|
| 24603 |
amit.gupta |
239 |
if (args.containsOption("gst")) {
|
| 24542 |
amit.gupta |
240 |
scheduledTasks.gst();
|
|
|
241 |
}
|
| 24265 |
amit.gupta |
242 |
System.exit(0);
|
| 23898 |
amit.gupta |
243 |
}
|
|
|
244 |
}
|
| 24603 |
amit.gupta |
245 |
|
| 24848 |
amit.gupta |
246 |
}
|