Subversion Repositories SmartDukaan

Rev

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

Rev 29801 Rev 30049
Line 1... Line 1...
1
package com.smartdukaan.cron.scheduled;
1
package com.smartdukaan.cron.scheduled;
2
 
2
 
3
import java.time.LocalDate;
3
import com.smartdukaan.cron.migrations.RunOnceTasks;
4
import java.time.LocalDateTime;
4
import com.smartdukaan.cron.monitored.NagiosMonitorTasks;
5
import java.util.Date;
5
import com.smartdukaan.cron.properties.WriteToPropertiesFile;
6
import java.util.LinkedHashMap;
6
import com.smartdukaan.cron.scheduled.leadsync.LeadSyncRunner;
7
 
-
 
8
import org.apache.logging.log4j.LogManager;
7
import org.apache.logging.log4j.LogManager;
9
import org.apache.logging.log4j.Logger;
8
import org.apache.logging.log4j.Logger;
10
import org.springframework.beans.factory.annotation.Autowired;
9
import org.springframework.beans.factory.annotation.Autowired;
11
import org.springframework.scheduling.annotation.Scheduled;
10
import org.springframework.scheduling.annotation.Scheduled;
12
import org.springframework.stereotype.Component;
11
import org.springframework.stereotype.Component;
13
 
12
 
14
import com.smartdukaan.cron.migrations.RunOnceTasks;
13
import java.time.LocalDate;
15
import com.smartdukaan.cron.monitored.NagiosMonitorTasks;
14
import java.time.LocalDateTime;
16
import com.smartdukaan.cron.properties.WriteToPropertiesFile;
15
import java.util.Date;
17
import com.smartdukaan.cron.scheduled.leadsync.LeadSyncRunner;
16
import java.util.LinkedHashMap;
18
 
17
 
19
@Component
18
@Component
20
public class ScheduledSkeleton {
19
public class ScheduledSkeleton {
21
 
20
 
22
	private static final Logger log = LogManager.getLogger(ScheduledSkeleton.class);
21
	private static final Logger log = LogManager.getLogger(ScheduledSkeleton.class);
Line 45... Line 44...
45
	@Autowired
44
	@Autowired
46
	private WriteToPropertiesFile writeToPropertiesFile;
45
	private WriteToPropertiesFile writeToPropertiesFile;
47
 
46
 
48
	String nagiosCronPropertiesFile = "/var/log/services/nagios-Cron-Monitoring.properties";
47
	String nagiosCronPropertiesFile = "/var/log/services/nagios-Cron-Monitoring.properties";
49
 
48
 
50
	// @Scheduled(cron = "0 0 2 * * *")
49
	@Scheduled(cron = "0 0 2 * * *")
51
	public void processDailySchemes() throws Exception {
50
	public void processDailySchemes() throws Exception {
52
 
51
 
53
		LinkedHashMap<String, String> propertiesDetails = new LinkedHashMap<>();
52
		LinkedHashMap<String, String> propertiesDetails = new LinkedHashMap<>();
54
		propertiesDetails.put("processDailySchemes", "0");
53
		propertiesDetails.put("processDailySchemes", "0");
55
 
54
 
56
		writeToPropertiesFile.saveParamChanges(propertiesDetails, nagiosCronPropertiesFile);
55
		writeToPropertiesFile.saveParamChanges(propertiesDetails, nagiosCronPropertiesFile);
57
 
-
 
-
 
56
		int maxMinusDays = 5;
-
 
57
		int currentDayOfMonth = LocalDate.now().getDayOfMonth();
-
 
58
		int minusDays = currentDayOfMonth > maxMinusDays ? maxMinusDays : currentDayOfMonth - 1;
-
 
59
		if (minusDays > 0) {
58
		scheduledTasks.processScheme(LocalDateTime.now().minusDays(7), LocalDateTime.now(), false);
60
			scheduledTasks.processScheme(LocalDateTime.now().minusDays(minusDays), LocalDateTime.now(), false);
59
 
61
		}
60
		propertiesDetails.put("processDailySchemes", "1");
62
		propertiesDetails.put("processDailySchemes", "1");
61
		writeToPropertiesFile.saveParamChanges(propertiesDetails, nagiosCronPropertiesFile);
63
		writeToPropertiesFile.saveParamChanges(propertiesDetails, nagiosCronPropertiesFile);
62
 
64
 
63
	}
65
	}
64
 
66
 
Line 200... Line 202...
200
 
202
 
201
	@Scheduled(cron = "0 0 1 * * *")
203
	@Scheduled(cron = "0 0 1 * * *")
202
	public void selectFinServiceFollowUpDateByCurrDate() throws Exception {
204
	public void selectFinServiceFollowUpDateByCurrDate() throws Exception {
203
		log.info("selectFinServiceFollowUpDateByCurrDate");
205
		log.info("selectFinServiceFollowUpDateByCurrDate");
204
		scheduledTasks.selectFinServiceFollowUpDateByCurrDate(LocalDate.now());
206
		scheduledTasks.selectFinServiceFollowUpDateByCurrDate(LocalDate.now());
205
		
207
 
206
	}
208
	}
207
	
209
 
208
	@Scheduled(cron = "0 0 1 * * *")
210
	@Scheduled(cron = "0 0 1 * * *")
209
	public void processActivation() throws Exception {
211
	public void processActivation() throws Exception {
210
 
212
 
211
		LinkedHashMap<String, String> propertiesDetails = new LinkedHashMap<>();
213
		LinkedHashMap<String, String> propertiesDetails = new LinkedHashMap<>();
212
		propertiesDetails.put("processActivation", "0");
214
		propertiesDetails.put("processActivation", "0");