Commit 17c1b523 authored by Vijay Akula's avatar Vijay Akula

Provided the code for not triggering mail to other functional heads

parent 1b2ad8af
......@@ -11,6 +11,7 @@ import com.nisum.myteam.service.IMailService;
import com.nisum.myteam.service.impl.AttendanceService;
import com.nisum.myteam.service.impl.EmployeeService;
import com.nisum.myteam.statuscodes.EmployeeStatus;
import com.nisum.myteam.utils.MyTeamDateUtils;
import com.nisum.myteam.utils.MyTeamUtils;
import com.nisum.myteam.utils.constants.EmpSubStatus;
import com.nisum.myteam.utils.constants.Shifts;
......@@ -94,14 +95,12 @@ public class LeaveNotificationScheduler {
private void sendMailToAbsentees(String shift) throws IOException, MessagingException, MyTeamException {
Mail mail = new Mail();
mail.setFrom(environment.getProperty("email.leave.notification.from"));
mail.setSubject(environment.getProperty("email.leave.notification.subject"));
Map<String, Object> model = new HashMap<String, Object>();
String currentDate = dateTimeFormatter.format(LocalDateTime.now());
String functionalGroupName;
FunctionalGroup functionalGroup;
final String mailSubject = environment.getProperty("email.leave.notification.subject").concat("for the day::").concat(MyTeamDateUtils.parseDateForMailSubject());
Employee employee;
String empSubStatus;
try {
......@@ -111,24 +110,29 @@ public class LeaveNotificationScheduler {
List<AttendenceData> absentiesList = attendenceList.stream()
.filter(attendance -> attendance.getPresent().equalsIgnoreCase(MyTeamUtils.ABSENT)).collect(Collectors.toList());
for (AttendenceData absentee : absentiesList) {
//model.put("employeeName", );//mail.setModel(model);
Mail mail = new Mail();
mail.setFrom(environment.getProperty("email.leave.notification.from"));
mail.setSubject(mailSubject);
employee = employeeService.getEmployeeById(absentee.getEmployeeId());
empSubStatus = employee.getEmpSubStatus();
if(empSubStatus==null)
empSubStatus="";
if (empSubStatus == null)
empSubStatus = "";
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.ONSITE_TRAVEL.getLeaveType())&&
!empSubStatus.equalsIgnoreCase(EmpSubStatus.ONSITE_TRAVEL.getLeaveType()) &&
!empSubStatus.equalsIgnoreCase(EmpSubStatus.AT_CLIENT_LOCATION.getLeaveType()))) {
logger.info("Mail Notification is sending to:" + absentee.getEmployeeName() + "::" + absentee.getEmailId());
mail.setEmpName(absentee.getEmployeeName());
mail.setTo(absentee.getEmailId());//mail.setEmpName("Prayas");//mail.setTo("pjain@nisum.com");
functionalGroup = functionalGroupService.getFunctionalGroup(employee.getFunctionalGroup());
FunctionalGroup functionalGroup = functionalGroupService.getFunctionalGroup(employee.getFunctionalGroup());
if (functionalGroup != null) {
mail.setCc(new String[]{functionalGroup.getGroupHeadEmailId()});//mail.setCc(new String[]{"prayasjain21@gmail.com"});
}
......
......@@ -2,6 +2,7 @@ package com.nisum.myteam.utils;
import lombok.extern.slf4j.Slf4j;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.ZoneId;
import java.util.Calendar;
......@@ -42,6 +43,12 @@ public class MyTeamDateUtils {
return yesterday;
}
public static String parseDateForMailSubject()
{
Date date=new Date();
SimpleDateFormat dateFormat=new SimpleDateFormat("dd-MM-yyyy");
return dateFormat.format(date);
}
// public static void main(String[] args)
// {
// MyTeamDateUtils.getDayMoreThanDate(new Date());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment