Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mytime
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Narendar Vakiti
mytime
Commits
ed2d5cc3
Commit
ed2d5cc3
authored
Jun 26, 2019
by
Vijay Akula
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Leave notification changes
parent
b5b23ffa
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
27 deletions
+40
-27
LeaveNotificationScheduler.java
...om/nisum/myteam/schedular/LeaveNotificationScheduler.java
+39
-26
MailService.java
src/main/java/com/nisum/myteam/service/impl/MailService.java
+1
-1
No files found.
src/main/java/com/nisum/myteam/schedular/LeaveNotificationScheduler.java
View file @
ed2d5cc3
...
@@ -17,12 +17,12 @@ import com.nisum.myteam.utils.MyTeamDateUtils;
...
@@ -17,12 +17,12 @@ import com.nisum.myteam.utils.MyTeamDateUtils;
import
com.nisum.myteam.utils.MyTeamUtils
;
import
com.nisum.myteam.utils.MyTeamUtils
;
import
com.nisum.myteam.utils.constants.EmpSubStatus
;
import
com.nisum.myteam.utils.constants.EmpSubStatus
;
import
com.nisum.myteam.utils.constants.Shifts
;
import
com.nisum.myteam.utils.constants.Shifts
;
import
org.slf4j.Logger
;
import
lombok.extern.slf4j.Slf4j
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.core.env.Environment
;
import
org.springframework.core.env.Environment
;
import
org.springframework.stereotype.Component
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.stereotype.Component
;
import
javax.mail.MessagingException
;
import
javax.mail.MessagingException
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.time.LocalDateTime
;
import
java.time.LocalDateTime
;
...
@@ -32,10 +32,10 @@ import java.util.List;
...
@@ -32,10 +32,10 @@ import java.util.List;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
@Slf4j
@Component
@Component
public
class
LeaveNotificationScheduler
{
public
class
LeaveNotificationScheduler
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
LeaveNotificationScheduler
.
class
);
//
private static final Logger logger = LoggerFactory.getLogger(LeaveNotificationScheduler.class);
private
static
final
DateTimeFormatter
dateTimeFormatter
=
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-dd"
);
private
static
final
DateTimeFormatter
dateTimeFormatter
=
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-dd"
);
...
@@ -58,84 +58,97 @@ public class LeaveNotificationScheduler {
...
@@ -58,84 +58,97 @@ public class LeaveNotificationScheduler {
private
SubStatusService
subStatusService
;
private
SubStatusService
subStatusService
;
@Scheduled
(
cron
=
"${email.leave.notification.shift1.cron}"
)
//@Scheduled(cron = "${email.leave.notification.shift1.cron}")
@Scheduled
(
cron
=
"0 * * * * ?"
)
public
void
scheduleLeaveMailForShift1Empls
()
throws
IOException
,
MessagingException
,
MyTeamException
{
public
void
scheduleLeaveMailForShift1Empls
()
throws
IOException
,
MessagingException
,
MyTeamException
{
//Shift 1(9:00 AM - 6:00 PM)
//Shift 1(9:00 AM - 6:00 PM)
log
ger
.
info
(
Shifts
.
SHIFT1
.
getShiftType
()
+
" :: Execution Time - {}"
,
dateTimeFormatter
.
format
(
LocalDateTime
.
now
()));
log
.
info
(
Shifts
.
SHIFT1
.
getShiftType
()
+
" :: Execution Time - {}"
,
dateTimeFormatter
.
format
(
LocalDateTime
.
now
()));
sendMailToAbsentees
(
Shifts
.
SHIFT1
.
getShiftType
());
sendMailToAbsentees
(
Shifts
.
SHIFT1
.
getShiftType
());
}
}
@Scheduled
(
cron
=
"${email.leave.notification.shift2.cron}"
)
//
@Scheduled(cron = "${email.leave.notification.shift2.cron}")
public
void
scheduleLeaveMailForShift2Empls
()
throws
IOException
,
MessagingException
,
MyTeamException
{
public
void
scheduleLeaveMailForShift2Empls
()
throws
IOException
,
MessagingException
,
MyTeamException
{
//Shift-2(2:00 PM - 11:00 PM)--General Shift
//Shift-2(2:00 PM - 11:00 PM)--General Shift
log
ger
.
info
(
Shifts
.
SHIFT2
.
getShiftType
()
+
" :: Execution Time - {}"
,
dateTimeFormatter
.
format
(
LocalDateTime
.
now
()));
log
.
info
(
Shifts
.
SHIFT2
.
getShiftType
()
+
" :: Execution Time - {}"
,
dateTimeFormatter
.
format
(
LocalDateTime
.
now
()));
sendMailToAbsentees
(
Shifts
.
SHIFT2
.
getShiftType
());
sendMailToAbsentees
(
Shifts
.
SHIFT2
.
getShiftType
());
}
}
@Scheduled
(
cron
=
"${email.leave.notification.shift3.cron}"
)
//
@Scheduled(cron = "${email.leave.notification.shift3.cron}")
public
void
scheduleLeaveMailForShift3Empls
()
throws
IOException
,
MessagingException
,
MyTeamException
{
public
void
scheduleLeaveMailForShift3Empls
()
throws
IOException
,
MessagingException
,
MyTeamException
{
//Shift 3(10:00 PM - 6:00 AM)
//Shift 3(10:00 PM - 6:00 AM)
log
ger
.
info
(
Shifts
.
SHIFT3
.
getShiftType
()
+
" :: Execution Time - {}"
,
dateTimeFormatter
.
format
(
LocalDateTime
.
now
()));
log
.
info
(
Shifts
.
SHIFT3
.
getShiftType
()
+
" :: Execution Time - {}"
,
dateTimeFormatter
.
format
(
LocalDateTime
.
now
()));
sendMailToAbsentees
(
Shifts
.
SHIFT3
.
getShiftType
());
sendMailToAbsentees
(
Shifts
.
SHIFT3
.
getShiftType
());
}
}
@Scheduled
(
cron
=
"${email.leave.notification.shift4.cron}"
)
//
@Scheduled(cron = "${email.leave.notification.shift4.cron}")
public
void
scheduleLeaveMailForShift4Empls
()
throws
IOException
,
MessagingException
,
MyTeamException
{
public
void
scheduleLeaveMailForShift4Empls
()
throws
IOException
,
MessagingException
,
MyTeamException
{
//Shift 4(7:30 AM - 3:30 PM)
//Shift 4(7:30 AM - 3:30 PM)
log
ger
.
info
(
Shifts
.
SHIFT4
.
getShiftType
()
+
" :: Execution Time - {}"
,
dateTimeFormatter
.
format
(
LocalDateTime
.
now
()));
log
.
info
(
Shifts
.
SHIFT4
.
getShiftType
()
+
" :: Execution Time - {}"
,
dateTimeFormatter
.
format
(
LocalDateTime
.
now
()));
sendMailToAbsentees
(
Shifts
.
SHIFT4
.
getShiftType
());
sendMailToAbsentees
(
Shifts
.
SHIFT4
.
getShiftType
());
}
}
@Scheduled
(
cron
=
"${email.leave.notification.shift5.cron}"
)
//
@Scheduled(cron = "${email.leave.notification.shift5.cron}")
public
void
scheduleLeaveMailForShift5Empls
()
throws
IOException
,
MessagingException
,
MyTeamException
{
public
void
scheduleLeaveMailForShift5Empls
()
throws
IOException
,
MessagingException
,
MyTeamException
{
//Shift 5(11:30 AM - 7:30 PM)
//Shift 5(11:30 AM - 7:30 PM)
log
ger
.
info
(
Shifts
.
SHIFT5
.
getShiftType
()
+
" :: Execution Time - {}"
,
dateTimeFormatter
.
format
(
LocalDateTime
.
now
()));
log
.
info
(
Shifts
.
SHIFT5
.
getShiftType
()
+
" :: Execution Time - {}"
,
dateTimeFormatter
.
format
(
LocalDateTime
.
now
()));
sendMailToAbsentees
(
Shifts
.
SHIFT5
.
getShiftType
());
sendMailToAbsentees
(
Shifts
.
SHIFT5
.
getShiftType
());
}
}
private
void
sendMailToAbsentees
(
String
shift
)
throws
IOException
,
MessagingException
,
MyTeamException
{
private
void
sendMailToAbsentees
(
String
shift
)
throws
IOException
,
MessagingException
,
MyTeamException
{
Map
<
String
,
Object
>
model
=
new
HashMap
<
String
,
Object
>();
Map
<
String
,
Object
>
model
=
new
HashMap
<
String
,
Object
>();
String
currentDate
=
dateTimeFormatter
.
format
(
LocalDateTime
.
now
());
String
currentDate
=
dateTimeFormatter
.
format
(
LocalDateTime
.
now
());
String
functionalGroupName
;
String
functionalGroupName
;
final
String
mailSubject
=
String
.
valueOf
(
"Date::"
).
concat
(
MyTeamDateUtils
.
FormatTodaysDate
()
+
"::"
).
concat
(
environment
.
getProperty
(
"email.leave.notification.subject"
));
final
String
mailSubject
=
String
.
valueOf
(
"Date::"
).
concat
(
MyTeamDateUtils
.
FormatTodaysDate
()
+
"::"
).
concat
(
environment
.
getProperty
(
"email.leave.notification.subject"
));
Employee
employee
;
Employee
employee
=
new
Employee
()
;
String
empSubStatus
;
String
empSubStatus
=
""
;
try
{
try
{
if
(!
MyTeamDateUtils
.
isTodayHoliday
(
environment
.
getProperty
(
"email.holidays.list.2019"
,
"14-01-2019,21-03-2019,19-04-2019,05-06-2019,12-08-2019,15-08-2019,02-09-2019,02-10-2019,08-10-2019,25-12-2019"
)))
{
if
(!
MyTeamDateUtils
.
isTodayHoliday
(
environment
.
getProperty
(
"email.holidays.list.2019"
,
"14-01-2019,21-03-2019,19-04-2019,05-06-2019,12-08-2019,15-08-2019,02-09-2019,02-10-2019,08-10-2019,25-12-2019"
)))
{
log
.
info
(
"Inside not holiday"
);
List
<
AttendenceData
>
attendenceList
=
attendanceService
.
getAttendanciesReport
(
currentDate
,
shift
);
List
<
AttendenceData
>
attendenceList
=
attendanceService
.
getAttendanciesReport
(
currentDate
,
shift
);
List
<
AttendenceData
>
absentiesList
=
attendenceList
.
stream
()
List
<
AttendenceData
>
absentiesList
=
attendenceList
.
stream
()
.
filter
(
attendance
->
attendance
.
getPresent
().
equalsIgnoreCase
(
MyTeamUtils
.
ABSENT
)).
collect
(
Collectors
.
toList
());
.
filter
(
attendance
->
attendance
.
getPresent
().
equalsIgnoreCase
(
MyTeamUtils
.
ABSENT
)).
collect
(
Collectors
.
toList
());
for
(
AttendenceData
absentee
:
absentiesList
)
{
for
(
AttendenceData
absentee
:
absentiesList
)
{
//model.put("employeeName", );//mail.setModel(model);
//model.put("employeeName", );//mail.setModel(model);
System
.
out
.
println
(
"inside loop"
);
Mail
mail
=
new
Mail
();
Mail
mail
=
new
Mail
();
mail
.
setFrom
(
environment
.
getProperty
(
"email.leave.notification.from"
));
mail
.
setFrom
(
environment
.
getProperty
(
"email.leave.notification.from"
));
mail
.
setSubject
(
mailSubject
);
mail
.
setSubject
(
mailSubject
);
employee
=
employeeService
.
getEmployeeById
(
absentee
.
getEmployeeId
());
try
{
EmployeeSubStatus
subStatus
=
subStatusService
.
getCurrentSubStatus
(
employee
.
getEmployeeId
());
employee
=
employeeService
.
getEmployeeById
(
absentee
.
getEmployeeId
());
empSubStatus
=
(
String
)
subStatus
.
getSubStatus
();
System
.
out
.
println
(
"employee Details::"
+
employee
);
EmployeeSubStatus
subStatusObj
=
subStatusService
.
getCurrentSubStatus
(
employee
.
getEmployeeId
());
if
(
empSubStatus
==
null
)
System
.
out
.
println
(
"Emplyee SubStatusObj::"
+
subStatusObj
);
empSubStatus
=
""
;
if
(
subStatusObj
!=
null
)
{
if
(
subStatusObj
.
getSubStatus
()
!=
null
)
{
empSubStatus
=
(
String
)
subStatusObj
.
getSubStatus
();
System
.
out
.
println
(
"The empSubssttatus::"
+
empSubStatus
);
}
else
{
empSubStatus
=
""
;
}
}
System
.
out
.
println
(
"After IF"
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
System
.
out
.
println
(
"The final empSubStatus::"
+
empSubStatus
);
if
(
employee
.
getEmpStatus
().
equalsIgnoreCase
(
EmployeeStatus
.
ACTIVE
.
getStatus
())
&&
if
(
employee
.
getEmpStatus
().
equalsIgnoreCase
(
EmployeeStatus
.
ACTIVE
.
getStatus
())
&&
(!
empSubStatus
.
equalsIgnoreCase
(
EmpSubStatus
.
LONG_LEAVE
.
getLeaveType
())
&&
(!
empSubStatus
.
equalsIgnoreCase
(
EmpSubStatus
.
LONG_LEAVE
.
getLeaveType
())
&&
!
empSubStatus
.
equalsIgnoreCase
(
EmpSubStatus
.
MATERNITY_LEAVE
.
getLeaveType
())
&&
!
empSubStatus
.
equalsIgnoreCase
(
EmpSubStatus
.
MATERNITY_LEAVE
.
getLeaveType
())
&&
!
empSubStatus
.
equalsIgnoreCase
(
EmpSubStatus
.
ONSITE_TRAVEL
.
getLeaveType
())
&&
!
empSubStatus
.
equalsIgnoreCase
(
EmpSubStatus
.
ONSITE_TRAVEL
.
getLeaveType
())
&&
!
empSubStatus
.
equalsIgnoreCase
(
EmpSubStatus
.
AT_CLIENT_LOCATION
.
getLeaveType
())))
{
!
empSubStatus
.
equalsIgnoreCase
(
EmpSubStatus
.
AT_CLIENT_LOCATION
.
getLeaveType
())))
{
log
ger
.
info
(
"Mail Notification is sending to:"
+
absentee
.
getEmployeeName
()
+
"::"
+
absentee
.
getEmailId
());
log
.
info
(
"Mail Notification is sending to:"
+
absentee
.
getEmployeeName
()
+
"::"
+
absentee
.
getEmailId
());
mail
.
setEmpName
(
absentee
.
getEmployeeName
());
mail
.
setEmpName
(
absentee
.
getEmployeeName
());
mail
.
setTo
(
absentee
.
getEmailId
());
//mail.setEmpName("Prayas");//mail.setTo("pjain@nisum.com");
mail
.
setTo
(
absentee
.
getEmailId
());
//mail.setEmpName("Prayas");//mail.setTo("pjain@nisum.com");
...
...
src/main/java/com/nisum/myteam/service/impl/MailService.java
View file @
ed2d5cc3
...
@@ -112,7 +112,7 @@ public class MailService implements IMailService {
...
@@ -112,7 +112,7 @@ public class MailService implements IMailService {
helper
.
setCc
(
mail
.
getCc
());
//helper.setBcc(mail.getBcc());//log.info("Mail Content::"+content);//log.info("The Mail Object::"+mail);
helper
.
setCc
(
mail
.
getCc
());
//helper.setBcc(mail.getBcc());//log.info("Mail Content::"+content);//log.info("The Mail Object::"+mail);
}
}
emailSender
.
send
(
message
);
//
emailSender.send(message);
}
}
public
void
sendProjectNotification
(
Mail
mail
)
throws
MessagingException
,
IOException
public
void
sendProjectNotification
(
Mail
mail
)
throws
MessagingException
,
IOException
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment