| 23755 |
amit.gupta |
1 |
package com.smartdukaan.cron;
|
| 23723 |
amit.gupta |
2 |
|
| 24122 |
govind |
3 |
import java.text.MessageFormat;
|
|
|
4 |
import java.time.LocalDate;
|
| 24174 |
govind |
5 |
import java.util.List;
|
| 23906 |
amit.gupta |
6 |
import java.util.Properties;
|
|
|
7 |
|
| 23723 |
amit.gupta |
8 |
import org.apache.logging.log4j.LogManager;
|
|
|
9 |
import org.apache.logging.log4j.Logger;
|
| 23898 |
amit.gupta |
10 |
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
11 |
import org.springframework.boot.ApplicationArguments;
|
|
|
12 |
import org.springframework.boot.ApplicationRunner;
|
| 23723 |
amit.gupta |
13 |
import org.springframework.boot.WebApplicationType;
|
|
|
14 |
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|
|
15 |
import org.springframework.boot.builder.SpringApplicationBuilder;
|
|
|
16 |
import org.springframework.cache.annotation.EnableCaching;
|
|
|
17 |
import org.springframework.context.annotation.Bean;
|
|
|
18 |
import org.springframework.context.annotation.ComponentScan;
|
| 23935 |
amit.gupta |
19 |
import org.springframework.context.annotation.Primary;
|
| 23723 |
amit.gupta |
20 |
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
|
|
|
21 |
import org.springframework.core.io.ClassPathResource;
|
| 23906 |
amit.gupta |
22 |
import org.springframework.mail.javamail.JavaMailSender;
|
|
|
23 |
import org.springframework.mail.javamail.JavaMailSenderImpl;
|
| 23723 |
amit.gupta |
24 |
import org.springframework.scheduling.annotation.EnableScheduling;
|
|
|
25 |
|
| 23898 |
amit.gupta |
26 |
import com.smartdukaan.cron.migrations.RunOnceTasks;
|
| 23929 |
amit.gupta |
27 |
import com.smartdukaan.cron.scheduled.ScheduledTasks;
|
| 24174 |
govind |
28 |
import com.spice.profitmandi.dao.entity.fofo.SaleHeadDetails;
|
|
|
29 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
|
|
30 |
import com.spice.profitmandi.dao.repository.fofo.FofoOrderRepository;
|
| 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;
|
|
|
42 |
|
| 23723 |
amit.gupta |
43 |
public static void main(String[] args) throws Throwable {
|
| 23738 |
amit.gupta |
44 |
new SpringApplicationBuilder(Application.class).web(WebApplicationType.NONE).run(args);
|
| 23723 |
amit.gupta |
45 |
}
|
| 24122 |
govind |
46 |
|
| 23723 |
amit.gupta |
47 |
@Bean
|
| 23738 |
amit.gupta |
48 |
public static PropertySourcesPlaceholderConfigurer propertyConfigurer1() {
|
| 23755 |
amit.gupta |
49 |
LOGGER.info("Called Configuration");
|
| 24122 |
govind |
50 |
PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer = new PropertySourcesPlaceholderConfigurer();
|
| 23723 |
amit.gupta |
51 |
propertySourcesPlaceholderConfigurer.setLocation(new ClassPathResource("/META-INF/env.properties"));
|
|
|
52 |
return propertySourcesPlaceholderConfigurer;
|
|
|
53 |
}
|
| 24122 |
govind |
54 |
|
|
|
55 |
@Bean(name = "mailSender")
|
| 23935 |
amit.gupta |
56 |
@Primary
|
| 24122 |
govind |
57 |
public JavaMailSender sendGridMailSender() {
|
|
|
58 |
JavaMailSenderImpl mailSender = new JavaMailSenderImpl();
|
| 23723 |
amit.gupta |
59 |
|
| 24122 |
govind |
60 |
// Using gmail
|
|
|
61 |
mailSender.setHost("smtp.sendgrid.net");
|
|
|
62 |
mailSender.setPort(587);
|
|
|
63 |
mailSender.setUsername("shop2020");
|
|
|
64 |
mailSender.setPassword("U2/=fP,t");
|
|
|
65 |
|
|
|
66 |
Properties javaMailProperties = new Properties();
|
|
|
67 |
javaMailProperties.put("mail.smtp.starttls.enable", "false");
|
|
|
68 |
javaMailProperties.put("mail.smtp.auth", "true");
|
|
|
69 |
javaMailProperties.put("mail.transport.protocol", "smtp");
|
|
|
70 |
javaMailProperties.put("mail.debug", "true");// Prints out everything on screen
|
|
|
71 |
|
|
|
72 |
mailSender.setJavaMailProperties(javaMailProperties);
|
|
|
73 |
return mailSender;
|
|
|
74 |
}
|
|
|
75 |
|
| 23935 |
amit.gupta |
76 |
@Bean
|
| 24122 |
govind |
77 |
public JavaMailSender googleMailSender() {
|
| 23935 |
amit.gupta |
78 |
JavaMailSenderImpl mailSender = new JavaMailSenderImpl();
|
| 24122 |
govind |
79 |
// Using gmail
|
| 23935 |
amit.gupta |
80 |
mailSender.setHost("smtp.gmail.com");
|
|
|
81 |
mailSender.setPort(587);
|
|
|
82 |
mailSender.setUsername("build@shop2020.in");
|
|
|
83 |
mailSender.setPassword("cafe@nes");
|
| 24122 |
govind |
84 |
|
| 23935 |
amit.gupta |
85 |
Properties javaMailProperties = new Properties();
|
|
|
86 |
javaMailProperties.put("mail.smtp.starttls.enable", "true");
|
|
|
87 |
javaMailProperties.put("mail.smtp.auth", "true");
|
|
|
88 |
javaMailProperties.put("mail.transport.protocol", "smtp");
|
| 24122 |
govind |
89 |
javaMailProperties.put("mail.debug", "true");// Prints out everything on screen
|
| 23935 |
amit.gupta |
90 |
mailSender.setJavaMailProperties(javaMailProperties);
|
|
|
91 |
return mailSender;
|
|
|
92 |
}
|
|
|
93 |
|
| 24122 |
govind |
94 |
@Autowired
|
| 23898 |
amit.gupta |
95 |
private RunOnceTasks runOnceTasks;
|
| 24122 |
govind |
96 |
|
|
|
97 |
@Autowired
|
| 23929 |
amit.gupta |
98 |
private ScheduledTasks scheduledTasks;
|
| 24122 |
govind |
99 |
|
| 23898 |
amit.gupta |
100 |
@Override
|
|
|
101 |
public void run(ApplicationArguments args) throws Exception {
|
|
|
102 |
LOGGER.info("Called run method");
|
| 24122 |
govind |
103 |
if (args.containsOption("once")) {
|
|
|
104 |
if (args.containsOption("1")) {
|
|
|
105 |
scheduledTasks.sendPartnerInvestmentDetails();
|
|
|
106 |
System.exit(0);
|
|
|
107 |
}
|
| 24174 |
govind |
108 |
if (args.containsOption("saleHeads")) {
|
|
|
109 |
List<SaleHeadDetails> saleHeadDetails=fofoStoreRepository.selectAllSalesHeadDetails();
|
|
|
110 |
for(SaleHeadDetails saleHeadDetail:saleHeadDetails)
|
|
|
111 |
{
|
|
|
112 |
scheduledTasks.sendMailToSalesHeadAboutTargetAndSales(saleHeadDetail);
|
|
|
113 |
}
|
| 24122 |
govind |
114 |
System.exit(0);
|
| 24174 |
govind |
115 |
|
| 24122 |
govind |
116 |
}
|
| 24174 |
govind |
117 |
if (args.containsOption("partners")) {
|
|
|
118 |
scheduledTasks.sendMailToPartnerAboutTargetAndSales();
|
|
|
119 |
System.exit(0);
|
|
|
120 |
|
|
|
121 |
}
|
| 24151 |
amit.gupta |
122 |
if (args.containsOption("3")) {
|
|
|
123 |
scheduledTasks.processScheme();
|
|
|
124 |
System.exit(0);
|
|
|
125 |
}
|
| 24122 |
govind |
126 |
|
| 23898 |
amit.gupta |
127 |
}
|
| 24122 |
govind |
128 |
|
| 23898 |
amit.gupta |
129 |
}
|
|
|
130 |
|
| 23723 |
amit.gupta |
131 |
}
|