Commit 60934eb4 authored by vikram singh's avatar vikram singh

fixed the issue in updating future substatus of the employee

parent 1b16b517
...@@ -76,6 +76,94 @@ public class EmployeeService implements IEmployeeService { ...@@ -76,6 +76,94 @@ public class EmployeeService implements IEmployeeService {
return employeeRepo.save(employee); return employeeRepo.save(employee);
} }
// @Override
// public Employee updateEmployee(Employee employeeReq, String loginEmpId) throws ParseException {
// response.put("messege" , "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();
// update.set("employeeName", employeeReq.getEmployeeName());
// update.set("emailId", employeeReq.getEmailId());
// update.set("role", employeeReq.getRole());
// update.set("gender", employeeReq.getGender());
// update.set("functionalGroup", employeeReq.getFunctionalGroup());
// update.set("empStatus", employeeReq.getEmpStatus());
//// update.set("empSubStatus", employeeReq.getEmpSubStatus());
// update.set("employmentType", employeeReq.getEmploymentType());
// update.set("empLocation", employeeReq.getEmpLocation());
//// update.set("domain", employeeReq.getDomain());
// update.set("designation", employeeReq.getDesignation());
// update.set("dateOfBirth", employeeReq.getDateOfBirth());
// update.set("dateOfJoining", employeeReq.getDateOfJoining());
// update.set("lastModifiedOn", new Date());
// update.set("hasPassort", employeeReq.getHasPassort());
// update.set("hasB1", employeeReq.getHasB1());
// update.set("passportExpiryDate", employeeReq.getPassportExpiryDate());
// update.set("b1ExpiryDate", employeeReq.getB1ExpiryDate());
//
// update.set("modifiedBy", loginEmpId);
//
// if (employeeReq.getEmpStatus().equalsIgnoreCase(MyTeamUtils.IN_ACTIVE_SPACE)) {
// update.set("endDate", employeeReq.getEndDate());
//// update.set("empSubStatus", null);
// }
// // update employee location
// if (employeeReq.getEmpLocation() != null && !employeeReq.getEmpLocation().equals("")) {
// Employee existingEmployee = employeeRepo.findByEmployeeId(employeeReq.getEmployeeId());
// if (!existingEmployee.getEmpLocation().equals(employeeReq.getEmpLocation())) {
// empLocationService.update(employeeReq, false);
// }
//
// }
//
// //update substatus
// if(employeeReq.getEmpSubStatus()!=null) {
// HashMap<String, Object> substatus = (LinkedHashMap) employeeReq.getEmpSubStatus();
// if (substatus.keySet().contains("subStatus") && substatus.get("subStatus") != null) {
// EmployeeSubStatus latestSubStatus = new EmployeeSubStatus();
// latestSubStatus.setEmployeeID(substatus.get("employeeID").toString());
// latestSubStatus.setSubStatus(substatus.get("subStatus").toString());
// latestSubStatus.setFromDate(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").parse(substatus.get("fromDate").toString()));
// latestSubStatus.setToDate(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").parse(substatus.get("toDate").toString()));
// EmployeeSubStatus currentSubStatus = subStatusService.getCurrentSubStatus(employeeReq.getEmployeeId());
// if (currentSubStatus != null) {
// if (currentSubStatus.getSubStatus().equals(latestSubStatus.getSubStatus())) {
// latestSubStatus.setId(currentSubStatus.getId());
// subStatusService.updateExistingEmplyeeSubStatus(loginEmpId,latestSubStatus);
// } else {
// response.put("messege", "Employee is already " + currentSubStatus.getSubStatus() + " from " + currentSubStatus.getFromDate() + " to " + currentSubStatus.getToDate());
// }
// } else {
//// currentSubStatus = subStatusService.getLatestEmployeeSubStatus(employeeReq.getEmployeeId());
//// if(currentSubStatus == null)
// subStatusService.addEmployeeSubStatus(loginEmpId,latestSubStatus);
//// else {
//// latestSubStatus.setId(currentSubStatus.getId());
//// subStatusService.updateExistingEmplyeeSubStatus(latestSubStatus);
//// }
// }
// }
// }
//
//
// // update employee details
// FindAndModifyOptions options = new FindAndModifyOptions();
// options.returnNew(true);
// options.upsert(true);
// Employee employeeUpdated = mongoTemplate.findAndModify(query, update, options, Employee.class);
//
// try {
// // add to resource collection
// //resourceService.addResources(employeeUpdated, loginEmpId);
//
// // inactive the employee from the assigned project.
// //resourceService.inactivateResource(employeeReq, employeeUpdated, loginEmpId);
//
// } catch (Exception e) {
// }
// return employeeUpdated;
// }
@Override @Override
public Employee updateEmployee(Employee employeeReq, String loginEmpId) throws ParseException { public Employee updateEmployee(Employee employeeReq, String loginEmpId) throws ParseException {
response.put("messege" , "Employee has been updated"); response.put("messege" , "Employee has been updated");
...@@ -134,13 +222,17 @@ public class EmployeeService implements IEmployeeService { ...@@ -134,13 +222,17 @@ public class EmployeeService implements IEmployeeService {
response.put("messege", "Employee is already " + currentSubStatus.getSubStatus() + " from " + currentSubStatus.getFromDate() + " to " + currentSubStatus.getToDate()); response.put("messege", "Employee is already " + currentSubStatus.getSubStatus() + " from " + currentSubStatus.getFromDate() + " to " + currentSubStatus.getToDate());
} }
} else { } else {
// currentSubStatus = subStatusService.getLatestEmployeeSubStatus(employeeReq.getEmployeeId()); currentSubStatus = subStatusService.getLatestEmployeeSubStatus(employeeReq.getEmployeeId());
// if(currentSubStatus == null) if(currentSubStatus!=null && !currentSubStatus.getFromDate().before(new Date())) {
latestSubStatus.setId(currentSubStatus.getId());
subStatusService.updateExistingEmplyeeSubStatus(loginEmpId,latestSubStatus);
}
else {
subStatusService.addEmployeeSubStatus(loginEmpId,latestSubStatus); subStatusService.addEmployeeSubStatus(loginEmpId,latestSubStatus);
// else {
// latestSubStatus.setId(currentSubStatus.getId()); }
// subStatusService.updateExistingEmplyeeSubStatus(latestSubStatus);
// }
} }
} }
} }
...@@ -163,6 +255,7 @@ public class EmployeeService implements IEmployeeService { ...@@ -163,6 +255,7 @@ public class EmployeeService implements IEmployeeService {
} }
return employeeUpdated; return employeeUpdated;
} }
@Override @Override
public Employee deleteEmployee(String employeeId) { public Employee deleteEmployee(String employeeId) {
......
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