Commit 85d15817 authored by Md Suleman's avatar Md Suleman

Updated response object for substatus

parent c5b5d564
#Tue Jun 18 14:38:29 IST 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.5.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-3.5.1-all.zip
......@@ -11,6 +11,7 @@ import javax.servlet.http.HttpServletRequest;
import com.nisum.myteam.model.dao.EmployeeVisa;
import com.nisum.myteam.repository.EmployeeVisaRepo;
import com.nisum.myteam.service.impl.EmployeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
......@@ -36,7 +37,7 @@ import lombok.extern.slf4j.Slf4j;
public class EmployeeController {
@Autowired
private IEmployeeService empService;
private EmployeeService empService;
@Autowired
private IEmployeeRoleService employeeRoleService;
......@@ -71,7 +72,7 @@ public class EmployeeController {
if (empService.isEmployeeExistsById(loginEmpId)) {
Employee employeeUpdated = empService.updateEmployee(employeeReq, loginEmpId);
ResponseDetails updateRespDetails = new ResponseDetails(new Date(), 906, "Employee has been updated",
ResponseDetails updateRespDetails = new ResponseDetails(new Date(), 906, empService.messege ,
"Employee Updation", null, request.getRequestURI(), "Updation Employee details",
employeeUpdated);
return new ResponseEntity<ResponseDetails>(updateRespDetails, HttpStatus.OK);
......
......@@ -6,10 +6,12 @@ import com.nisum.myteam.model.AttendenceData;
import com.nisum.myteam.model.FunctionalGroup;
import com.nisum.myteam.model.Mail;
import com.nisum.myteam.model.dao.Employee;
import com.nisum.myteam.model.dao.EmployeeSubStatus;
import com.nisum.myteam.service.IFunctionalGroupService;
import com.nisum.myteam.service.IMailService;
import com.nisum.myteam.service.impl.AttendanceService;
import com.nisum.myteam.service.impl.EmployeeService;
import com.nisum.myteam.service.impl.SubStatusService;
import com.nisum.myteam.statuscodes.EmployeeStatus;
import com.nisum.myteam.utils.MyTeamDateUtils;
import com.nisum.myteam.utils.MyTeamUtils;
......@@ -52,6 +54,9 @@ public class LeaveNotificationScheduler {
@Autowired
private IFunctionalGroupService functionalGroupService;
@Autowired
private SubStatusService subStatusService;
// @Scheduled(cron = "${email.leave.notification.shift1.cron}")
public void scheduleLeaveMailForShift1Empls() throws IOException, MessagingException, MyTeamException {
......@@ -118,7 +123,8 @@ public class LeaveNotificationScheduler {
mail.setSubject(mailSubject);
employee = employeeService.getEmployeeById(absentee.getEmployeeId());
empSubStatus = (String)employee.getEmpSubStatus();
EmployeeSubStatus subStatus = subStatusService.getCurrentSubStatus(employee.getEmployeeId());
empSubStatus = (String)subStatus.getSubStatus();
if (empSubStatus == null)
empSubStatus = "";
......
......@@ -13,6 +13,8 @@ import java.util.Set;
@Service
public interface IEmployeeService {
public String messege = "";
boolean isEmployeeExistsById(String employeeId);
Employee createEmployee(Employee employeeRoles, String empId) throws MyTeamException;
......
......@@ -9,6 +9,7 @@ import com.nisum.myteam.model.dao.*;
import com.nisum.myteam.service.*;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.domain.Sort;
import org.springframework.data.mongodb.core.FindAndModifyOptions;
import org.springframework.data.mongodb.core.MongoTemplate;
......@@ -50,7 +51,7 @@ public class EmployeeService implements IEmployeeService {
private IEmployeeRoleService employeeRoleService;
@Autowired
private IEmployeeLocationService empLocationService;
private EmployeeLocationService empLocationService;
@Autowired
private IResourceService resourceService;
......@@ -58,6 +59,8 @@ public class EmployeeService implements IEmployeeService {
@Autowired
private ISubStatusService subStatusService;
public String message = "";
@Override
public Employee createEmployee(Employee employee, String loginEmpId) throws MyTeamException {
employee.setCreatedOn(new Date());
......@@ -75,6 +78,7 @@ public class EmployeeService implements IEmployeeService {
@Override
public Employee updateEmployee(Employee employeeReq, String loginEmpId) throws ParseException {
message = "Employee has been updated";
// update all emp details to inactive if employee is inactive
Query query = new Query(Criteria.where("employeeId").is(employeeReq.getEmployeeId()));
Update update = new Update();
......@@ -126,16 +130,16 @@ public class EmployeeService implements IEmployeeService {
latestSubStatus.setId(currentSubStatus.getId());
subStatusService.updateExistingEmplyeeSubStatus(latestSubStatus);
}else{
subStatusService.addEmployeeSubStatus(latestSubStatus);
message = "Employee is already "+currentSubStatus.getSubStatus()+" from "+currentSubStatus.getFromDate()+" to "+currentSubStatus.getToDate();
}
}else{
currentSubStatus = subStatusService.getLatestEmployeeSubStatus(employeeReq.getEmployeeId());
if(currentSubStatus == null)
// currentSubStatus = subStatusService.getLatestEmployeeSubStatus(employeeReq.getEmployeeId());
// if(currentSubStatus == null)
subStatusService.addEmployeeSubStatus(latestSubStatus);
else {
latestSubStatus.setId(currentSubStatus.getId());
subStatusService.updateExistingEmplyeeSubStatus(latestSubStatus);
}
// else {
// latestSubStatus.setId(currentSubStatus.getId());
// subStatusService.updateExistingEmplyeeSubStatus(latestSubStatus);
// }
}
}
......@@ -241,17 +245,38 @@ public class EmployeeService implements IEmployeeService {
@Override
public List<Employee> getEmployeesByStatus(String status) {
// if (status.equals("all")) {
// return employeeRepo.findAll(new Sort(Sort.Direction.ASC, "employeeName"));
// } else if (status.equals("Vacation")) {
// Query query = new Query();
// query.addCriteria(Criteria.where("empSubStatus").ne("Resigned").andOperator(Criteria.where("empSubStatus").ne(null),Criteria.where("empSubStatus").ne("")));
// return mongoTemplate.find(query, Employee.class);
// } else if (status.equals("Resigned")) {
// return employeeRepo.findByEmpSubStatusOrderByEmployeeNameAsc("Resigned");
// } else {
// return employeeRepo.findByEmpStatus(status);
// }
List<Employee> employeesList = employeeRepo.findAll(new Sort(Sort.Direction.ASC, "employeeName"));
employeesList.stream().forEach(e -> {
EmployeeSubStatus subStatus = subStatusService.getCurrentSubStatus(e.getEmployeeId());
if(subStatus!=null)
e.setEmpSubStatus((EmployeeSubStatus) subStatus);
else
e.setEmpSubStatus(null);
});
if (status.equals("all")) {
return employeeRepo.findAll(new Sort(Sort.Direction.ASC, "employeeName"));
return employeesList;
} else if (status.equals("Vacation")) {
Query query = new Query();
query.addCriteria(Criteria.where("empSubStatus").ne("Resigned").andOperator(Criteria.where("empSubStatus").ne(null),Criteria.where("empSubStatus").ne("")));
return mongoTemplate.find(query, Employee.class);
return employeesList.stream().filter(e -> e.getEmpSubStatus()!= null ||
(e.getEmpSubStatus()!=null && !e.getEmpSubStatus().equals("Resigned")) ||
(e.getEmpSubStatus()!=null && !e.getEmpSubStatus().equals(""))).collect(Collectors.toList());
} else if (status.equals("Resigned")) {
return employeeRepo.findByEmpSubStatusOrderByEmployeeNameAsc("Resigned");
} else {
return employeeRepo.findByEmpStatus(status);
return employeesList.stream().filter(e->e.getEmpStatus().equals(status)).collect(Collectors.toList());
}
}
......@@ -276,15 +301,15 @@ public class EmployeeService implements IEmployeeService {
public List<String> getEmployeeDetailsForAutocomplete() {
List<Employee> employeeList = employeeRepo.findAll();
List<String> resultList = new ArrayList<>();
employeeList.stream().sorted(java.util.Comparator.comparing(Employee::getEmployeeId))
employeeList.stream().sorted(Comparator.comparing(Employee::getEmployeeId))
.collect(Collectors.toList()).forEach(employee -> {
resultList.add(employee.getEmployeeId());
});
employeeList.stream().sorted(java.util.Comparator.comparing(Employee::getEmployeeName))
employeeList.stream().sorted(Comparator.comparing(Employee::getEmployeeName))
.collect(Collectors.toList()).forEach(employee -> {
resultList.add(employee.getEmployeeName());
});
employeeList.stream().sorted(java.util.Comparator.comparing(Employee::getEmailId)).collect(Collectors.toList())
employeeList.stream().sorted(Comparator.comparing(Employee::getEmailId)).collect(Collectors.toList())
.forEach(employee -> {
resultList.add(employee.getEmailId());
});
......
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