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