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