Commit 13fe6835 authored by Rajeshekar's avatar Rajeshekar

[Rajeshekar] MT-48:Capture Date of Joining and Date of Birth and show

Date of Joining in Dashboard
MT-51: Capture the project team mate status with dates
parent ae8613d6
package com.nisum.mytime.controller; package com.nisum.mytime.controller;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -16,12 +15,12 @@ import org.springframework.web.bind.annotation.RequestParam; ...@@ -16,12 +15,12 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import com.nisum.mytime.exception.handler.MyTimeException; import com.nisum.mytime.exception.handler.MyTimeException;
import com.nisum.mytime.model.BillingDetails;
import com.nisum.mytime.model.EmployeeDashboardVO; import com.nisum.mytime.model.EmployeeDashboardVO;
import com.nisum.mytime.model.EmployeeRoles; import com.nisum.mytime.model.EmployeeRoles;
import com.nisum.mytime.model.EmployeeVisa; import com.nisum.mytime.model.EmployeeVisa;
import com.nisum.mytime.model.Project; import com.nisum.mytime.model.Project;
import com.nisum.mytime.model.ProjectTeamMate; import com.nisum.mytime.model.ProjectTeamMate;
import com.nisum.mytime.model.TeamMateBilling;
import com.nisum.mytime.repository.EmployeeVisaRepo; import com.nisum.mytime.repository.EmployeeVisaRepo;
import com.nisum.mytime.service.ProjectService; import com.nisum.mytime.service.ProjectService;
import com.nisum.mytime.service.UserService; import com.nisum.mytime.service.UserService;
...@@ -39,173 +38,261 @@ public class ProjectTeamController { ...@@ -39,173 +38,261 @@ public class ProjectTeamController {
@Autowired @Autowired
private EmployeeVisaRepo employeeVisaRepo; private EmployeeVisaRepo employeeVisaRepo;
@RequestMapping(value = "/employee", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(value = "/employee", method = RequestMethod.GET,
public ResponseEntity<EmployeeRoles> getEmployeeRole(@RequestParam("emailId") String emailId) produces = MediaType.APPLICATION_JSON_VALUE)
throws MyTimeException { public ResponseEntity<EmployeeRoles> getEmployeeRole(
@RequestParam("emailId") String emailId) throws MyTimeException {
EmployeeRoles employeesRole = userService.getEmployeesRole(emailId); EmployeeRoles employeesRole = userService.getEmployeesRole(emailId);
return new ResponseEntity<>(employeesRole, HttpStatus.OK); return new ResponseEntity<>(employeesRole, HttpStatus.OK);
} }
@RequestMapping(value = "/addProject", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(value = "/addProject", method = RequestMethod.POST,
public ResponseEntity<Project> addProject(@RequestBody Project employeeRoles) throws MyTimeException { produces = MediaType.APPLICATION_JSON_VALUE,
consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Project> addProject(
@RequestBody Project employeeRoles) throws MyTimeException {
Project project = projectService.addProject(employeeRoles); Project project = projectService.addProject(employeeRoles);
return new ResponseEntity<>(project, HttpStatus.OK); return new ResponseEntity<>(project, HttpStatus.OK);
} }
@RequestMapping(value = "/updateEmployeeRole", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(value = "/updateEmployeeRole", method = RequestMethod.POST,
public ResponseEntity<EmployeeRoles> updateEmployeeRole(@RequestBody EmployeeRoles employeeRoles) produces = MediaType.APPLICATION_JSON_VALUE,
throws MyTimeException { consumes = MediaType.APPLICATION_JSON_VALUE)
EmployeeRoles employeeRole = userService.updateEmployeeRole(employeeRoles); public ResponseEntity<EmployeeRoles> updateEmployeeRole(
@RequestBody EmployeeRoles employeeRoles) throws MyTimeException {
EmployeeRoles employeeRole = userService
.updateEmployeeRole(employeeRoles);
return new ResponseEntity<>(employeeRole, HttpStatus.OK); return new ResponseEntity<>(employeeRole, HttpStatus.OK);
} }
@RequestMapping(value = "/deleteEmployee", method = RequestMethod.DELETE, produces = MediaType.TEXT_PLAIN_VALUE) @RequestMapping(value = "/deleteEmployee", method = RequestMethod.DELETE,
public ResponseEntity<String> deleteEmployee(@RequestParam("empId") String empId) throws MyTimeException { produces = MediaType.TEXT_PLAIN_VALUE)
public ResponseEntity<String> deleteEmployee(
@RequestParam("empId") String empId) throws MyTimeException {
userService.deleteEmployee(empId); userService.deleteEmployee(empId);
return new ResponseEntity<>("Success", HttpStatus.OK); return new ResponseEntity<>("Success", HttpStatus.OK);
} }
@RequestMapping(value = "/getEmployeeRoleData", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(value = "/getEmployeeRoleData", method = RequestMethod.GET,
public ResponseEntity<EmployeeRoles> getEmployeeRoleData(@RequestParam("empId") String empId) produces = MediaType.APPLICATION_JSON_VALUE)
throws MyTimeException { public ResponseEntity<EmployeeRoles> getEmployeeRoleData(
@RequestParam("empId") String empId) throws MyTimeException {
EmployeeRoles employeesRole = userService.getEmployeesRoleData(empId); EmployeeRoles employeesRole = userService.getEmployeesRoleData(empId);
return new ResponseEntity<>(employeesRole, HttpStatus.OK); return new ResponseEntity<>(employeesRole, HttpStatus.OK);
} }
@RequestMapping(value = "/getEmployeesToTeam", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(value = "/getEmployeesToTeam", method = RequestMethod.GET,
public ResponseEntity<List<EmployeeRoles>> getManagers() throws MyTimeException { produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<EmployeeRoles>> getManagers()
throws MyTimeException {
List<EmployeeRoles> employeesRoles = new ArrayList<>(); List<EmployeeRoles> employeesRoles = new ArrayList<>();
if(userService.getEmployeeRoles()!=null) { if (userService.getEmployeeRoles() != null) {
employeesRoles=userService.getEmployeeRoles().stream().sorted((o1, o2)->o1.getEmployeeName(). employeesRoles = userService.getEmployeeRoles().stream()
compareTo(o2.getEmployeeName())). .sorted((o1, o2) -> o1.getEmployeeName()
collect(Collectors.toList()); .compareTo(o2.getEmployeeName()))
.collect(Collectors.toList());
} }
return new ResponseEntity<>(employeesRoles, HttpStatus.OK); return new ResponseEntity<>(employeesRoles, HttpStatus.OK);
} }
@RequestMapping(value = "/getTeamDetails", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(value = "/getTeamDetails", method = RequestMethod.GET,
public ResponseEntity<List<ProjectTeamMate>> getTeamDetails(@RequestParam("employeeId") String employeeId) produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<ProjectTeamMate>> getTeamDetails(
@RequestParam("employeeId") String employeeId)
throws MyTimeException { throws MyTimeException {
List<ProjectTeamMate> employeesRoles = projectService.getTeamDetails(employeeId); List<ProjectTeamMate> employeesRoles = projectService
.getTeamDetails(employeeId);
return new ResponseEntity<>(employeesRoles, HttpStatus.OK); return new ResponseEntity<>(employeesRoles, HttpStatus.OK);
} }
@RequestMapping(value = "/addEmployeeToTeam", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(value = "/addEmployeeToTeam", method = RequestMethod.POST,
public ResponseEntity<ProjectTeamMate> addEmployeeToTeam(@RequestBody ProjectTeamMate teamMate) produces = MediaType.APPLICATION_JSON_VALUE,
throws MyTimeException { consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<ProjectTeamMate> addEmployeeToTeam(
@RequestBody ProjectTeamMate teamMate) throws MyTimeException {
teamMate.setActive(true); teamMate.setActive(true);
teamMate.setStartDate(new Date()); // teamMate.setStartDate(new Date());
ProjectTeamMate teamMateDB = projectService.addProjectTeamMate(teamMate); ProjectTeamMate teamMateDB = projectService
.addProjectTeamMate(teamMate);
return new ResponseEntity<>(teamMateDB, HttpStatus.OK); return new ResponseEntity<>(teamMateDB, HttpStatus.OK);
} }
@RequestMapping(value = "/updateTeammate", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(value = "/updateTeammate", method = RequestMethod.POST,
public ResponseEntity<ProjectTeamMate> updateTeammate(@RequestBody ProjectTeamMate projectTeamMate) produces = MediaType.APPLICATION_JSON_VALUE,
consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<ProjectTeamMate> updateTeammate(
@RequestBody ProjectTeamMate projectTeamMate)
throws MyTimeException { throws MyTimeException {
ProjectTeamMate updatedTeammate = projectService.updateTeammate(projectTeamMate); ProjectTeamMate updatedTeammate = projectService
.updateTeammate(projectTeamMate);
return new ResponseEntity<>(updatedTeammate, HttpStatus.OK); return new ResponseEntity<>(updatedTeammate, HttpStatus.OK);
} }
@RequestMapping(value = "/deleteTeammate", method = RequestMethod.POST,produces = MediaType.TEXT_PLAIN_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(value = "/deleteTeammate", method = RequestMethod.POST,
public ResponseEntity<String> deleteTeammate(@RequestBody ProjectTeamMate projectTeamMate) throws MyTimeException { produces = MediaType.TEXT_PLAIN_VALUE,
projectService.deleteTeammate(projectTeamMate.getEmployeeId(), projectTeamMate.getProjectId(),projectTeamMate.getId()); consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<String> deleteTeammate(
@RequestBody ProjectTeamMate projectTeamMate)
throws MyTimeException {
projectService.deleteTeammate(projectTeamMate.getEmployeeId(),
projectTeamMate.getProjectId(), projectTeamMate.getId());
return new ResponseEntity<>("Success", HttpStatus.OK); return new ResponseEntity<>("Success", HttpStatus.OK);
} }
@RequestMapping(value = "/getProjects", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(value = "/getProjects", method = RequestMethod.GET,
public ResponseEntity<List<Project>> getProjects(@RequestParam("employeeId") String employeeId) produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<Project>> getProjects(
@RequestParam("employeeId") String employeeId)
throws MyTimeException { throws MyTimeException {
List<Project> projects = projectService.getProjects(employeeId); List<Project> projects = projectService.getProjects(employeeId);
return new ResponseEntity<>(projects, HttpStatus.OK); return new ResponseEntity<>(projects, HttpStatus.OK);
} }
@RequestMapping(value = "/getMyTeamDetails", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(value = "/getMyTeamDetails", method = RequestMethod.GET,
public ResponseEntity<List<ProjectTeamMate>> getMyTeamDetails(@RequestParam("employeeId") String employeeId) produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<ProjectTeamMate>> getMyTeamDetails(
@RequestParam("employeeId") String employeeId)
throws MyTimeException { throws MyTimeException {
List<ProjectTeamMate> employeesRoles = projectService.getMyTeamDetails(employeeId); List<ProjectTeamMate> employeesRoles = projectService
.getMyTeamDetails(employeeId);
return new ResponseEntity<>(employeesRoles, HttpStatus.OK); return new ResponseEntity<>(employeesRoles, HttpStatus.OK);
} }
@RequestMapping(value = "/getUnAssignedEmployees", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(value = "/getUnAssignedEmployees",
public ResponseEntity<List<EmployeeRoles>> getUnAssignedEmployees() throws MyTimeException { method = RequestMethod.GET,
List<EmployeeRoles> employeesRoles = projectService.getUnAssignedEmployees(); produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<EmployeeRoles>> getUnAssignedEmployees()
throws MyTimeException {
List<EmployeeRoles> employeesRoles = projectService
.getUnAssignedEmployees();
return new ResponseEntity<>(employeesRoles, HttpStatus.OK); return new ResponseEntity<>(employeesRoles, HttpStatus.OK);
} }
@RequestMapping(value = "/getShiftDetails", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(value = "/getShiftDetails", method = RequestMethod.GET,
public ResponseEntity<List<ProjectTeamMate>> getShiftDetails(@RequestParam("shift") String shift) produces = MediaType.APPLICATION_JSON_VALUE)
throws MyTimeException { public ResponseEntity<List<ProjectTeamMate>> getShiftDetails(
List<ProjectTeamMate> employeesRoles = projectService.getShiftDetails(shift); @RequestParam("shift") String shift) throws MyTimeException {
List<ProjectTeamMate> employeesRoles = projectService
.getShiftDetails(shift);
return new ResponseEntity<>(employeesRoles, HttpStatus.OK); return new ResponseEntity<>(employeesRoles, HttpStatus.OK);
} }
@RequestMapping(value = "/getProjectAllocations", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(value = "/getProjectAllocations",
method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<ProjectTeamMate>> getProjectAllocations() public ResponseEntity<List<ProjectTeamMate>> getProjectAllocations()
throws MyTimeException { throws MyTimeException {
List<ProjectTeamMate> employeesRoles = projectService.getAllProjectDetails(); List<ProjectTeamMate> employeesRoles = projectService
.getAllProjectDetails();
return new ResponseEntity<>(employeesRoles, HttpStatus.OK); return new ResponseEntity<>(employeesRoles, HttpStatus.OK);
} }
@RequestMapping(value = "/getProjectDetails", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(value = "/getProjectDetails", method = RequestMethod.GET,
public ResponseEntity<List<ProjectTeamMate>> getProjectDetails(@RequestParam("projectId") String projectId) produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<ProjectTeamMate>> getProjectDetails(
@RequestParam("projectId") String projectId)
throws MyTimeException { throws MyTimeException {
List<ProjectTeamMate> employeesRoles = projectService.getProjectDetails(projectId); List<ProjectTeamMate> employeesRoles = projectService
.getProjectDetails(projectId);
return new ResponseEntity<>(employeesRoles, HttpStatus.OK); return new ResponseEntity<>(employeesRoles, HttpStatus.OK);
} }
@RequestMapping(value = "/getMyProjectAllocations", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<ProjectTeamMate>> getMyProjectAllocations(@RequestParam("employeeId") String employeeId) @RequestMapping(value = "/getMyProjectAllocations",
method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<ProjectTeamMate>> getMyProjectAllocations(
@RequestParam("employeeId") String employeeId)
throws MyTimeException { throws MyTimeException {
List<ProjectTeamMate> projectAllocations = projectService.getMyProjectAllocations(employeeId); List<ProjectTeamMate> projectAllocations = projectService
.getMyProjectAllocations(employeeId);
return new ResponseEntity<>(projectAllocations, HttpStatus.OK); return new ResponseEntity<>(projectAllocations, HttpStatus.OK);
} }
@RequestMapping(value = "/getEmployeeBillingDetails", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<TeamMateBilling>> getEmployeeBillingDetails(@RequestParam("employeeId") String employeeId,@RequestParam("projectId") String projectId) @RequestMapping(value = "/getEmployeeBillingDetails",
method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<BillingDetails>> getEmployeeBillingDetails(
@RequestParam("employeeId") String employeeId,
@RequestParam("projectId") String projectId)
throws MyTimeException { throws MyTimeException {
List<TeamMateBilling> billings = projectService.getEmployeeBillingDetails(employeeId,projectId); List<BillingDetails> billings = projectService
.getEmployeeBillingDetails(employeeId, projectId);
return new ResponseEntity<>(billings, HttpStatus.OK); return new ResponseEntity<>(billings, HttpStatus.OK);
} }
@RequestMapping(value = "/addEmployeeBilling", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<TeamMateBilling> addEmployeeBilling(@RequestBody TeamMateBilling teamMate) @RequestMapping(value = "/addEmployeeBilling", method = RequestMethod.POST,
throws MyTimeException { produces = MediaType.APPLICATION_JSON_VALUE,
TeamMateBilling billings = projectService.addEmployeeBillingDetails(teamMate); consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<BillingDetails> addEmployeeBilling(
@RequestBody BillingDetails teamMate) throws MyTimeException {
BillingDetails billings = projectService
.addEmployeeBillingDetails(teamMate);
return new ResponseEntity<>(billings, HttpStatus.OK); return new ResponseEntity<>(billings, HttpStatus.OK);
} }
@RequestMapping(value = "/updateEmployeeBilling", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<TeamMateBilling> updateEmployeeBilling(@RequestBody TeamMateBilling teamMate) @RequestMapping(value = "/updateEmployeeBilling",
throws MyTimeException { method = RequestMethod.POST,
TeamMateBilling billings = projectService.updateEmployeeBilling(teamMate); produces = MediaType.APPLICATION_JSON_VALUE,
consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<BillingDetails> updateEmployeeBilling(
@RequestBody BillingDetails teamMate) throws MyTimeException {
BillingDetails billings = projectService
.updateEmployeeBilling(teamMate);
return new ResponseEntity<>(billings, HttpStatus.OK); return new ResponseEntity<>(billings, HttpStatus.OK);
} }
@RequestMapping(value = "/getEmployeesDashBoard", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<EmployeeDashboardVO>> getEmployeesDashBoard() throws MyTimeException { @RequestMapping(value = "/deleteEmployeeBilling",
List<EmployeeDashboardVO> employeesRoles = projectService.getEmployeesDashBoard(); method = RequestMethod.POST,
produces = MediaType.APPLICATION_JSON_VALUE,
consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<BillingDetails> deleteEmployeeBilling(
@RequestBody BillingDetails teamMate) throws MyTimeException {
projectService.deleteEmployeeBilling(teamMate);
return new ResponseEntity<>(null, HttpStatus.OK);
}
@RequestMapping(value = "/getEmployeesDashBoard",
method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<EmployeeDashboardVO>> getEmployeesDashBoard()
throws MyTimeException {
List<EmployeeDashboardVO> employeesRoles = projectService
.getEmployeesDashBoard();
return new ResponseEntity<>(employeesRoles, HttpStatus.OK); return new ResponseEntity<>(employeesRoles, HttpStatus.OK);
} }
@RequestMapping(value = "/getEmployeesHavingVisa", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<EmployeeRoles>> getEmployeesHavingVisa(@RequestParam("visa") String visa) throws MyTimeException { @RequestMapping(value = "/getEmployeesHavingVisa",
if(visa!=null&&!visa.equalsIgnoreCase("passport")) { method = RequestMethod.GET,
List<EmployeeVisa> employeeVisas= employeeVisaRepo.findByVisaName(visa); produces = MediaType.APPLICATION_JSON_VALUE)
List<String> employeeIds=new ArrayList(); public ResponseEntity<List<EmployeeRoles>> getEmployeesHavingVisa(
@RequestParam("visa") String visa) throws MyTimeException {
if (visa != null && !visa.equalsIgnoreCase("passport")) {
List<EmployeeVisa> employeeVisas = employeeVisaRepo
.findByVisaName(visa);
List<String> employeeIds = new ArrayList();
List<EmployeeRoles> employeesRoles = new ArrayList<>(); List<EmployeeRoles> employeesRoles = new ArrayList<>();
if(employeeVisas!=null) { if (employeeVisas != null) {
employeeIds=employeeVisas.stream().map(EmployeeVisa::getEmployeeId).collect(Collectors.toList()); employeeIds = employeeVisas.stream()
.map(EmployeeVisa::getEmployeeId)
.collect(Collectors.toList());
} }
if(employeeIds!=null&&employeeIds.size()>0) { if (employeeIds != null && employeeIds.size() > 0) {
List<EmployeeRoles> emps=userService.getEmployeeRoles(); List<EmployeeRoles> emps = userService.getEmployeeRoles();
for(EmployeeRoles e:emps) { for (EmployeeRoles e : emps) {
if(employeeIds.contains(e.getEmployeeId())) { if (employeeIds.contains(e.getEmployeeId())) {
employeesRoles.add(e); employeesRoles.add(e);
} }
} }
} }
return new ResponseEntity<>(employeesRoles, HttpStatus.OK); return new ResponseEntity<>(employeesRoles, HttpStatus.OK);
}else { } else {
List<EmployeeRoles> employeesRoles = new ArrayList<>(); List<EmployeeRoles> employeesRoles = new ArrayList<>();
if(userService.getEmployeeRoles()!=null) { if (userService.getEmployeeRoles() != null) {
employeesRoles=userService.getEmployeeRoles().stream().sorted((o1, o2)->o1.getEmployeeName(). employeesRoles = userService.getEmployeeRoles().stream()
compareTo(o2.getEmployeeName())). .sorted((o1, o2) -> o1.getEmployeeName()
collect(Collectors.toList()); .compareTo(o2.getEmployeeName()))
.collect(Collectors.toList());
} }
return new ResponseEntity<>(employeesRoles, HttpStatus.OK); return new ResponseEntity<>(employeesRoles, HttpStatus.OK);
} }
......
...@@ -20,8 +20,8 @@ import lombok.ToString; ...@@ -20,8 +20,8 @@ import lombok.ToString;
@AllArgsConstructor @AllArgsConstructor
@NoArgsConstructor @NoArgsConstructor
@ToString @ToString
@Document(collection = "TeamMateBilling") @Document(collection = "BillingDetails")
public class TeamMateBilling implements Serializable { public class BillingDetails implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
...@@ -31,6 +31,7 @@ public class TeamMateBilling implements Serializable { ...@@ -31,6 +31,7 @@ public class TeamMateBilling implements Serializable {
private String employeeName; private String employeeName;
private String projectId; private String projectId;
private String projectName; private String projectName;
private String billableStatus;
@DateTimeFormat(iso = ISO.DATE) @DateTimeFormat(iso = ISO.DATE)
private Date billingStartDate; private Date billingStartDate;
@DateTimeFormat(iso = ISO.DATE) @DateTimeFormat(iso = ISO.DATE)
......
...@@ -5,6 +5,8 @@ import java.util.Date; ...@@ -5,6 +5,8 @@ import java.util.Date;
import org.springframework.data.annotation.Id; import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document; import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.format.annotation.DateTimeFormat.ISO;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Getter; import lombok.Getter;
...@@ -17,7 +19,7 @@ import lombok.ToString; ...@@ -17,7 +19,7 @@ import lombok.ToString;
@AllArgsConstructor @AllArgsConstructor
@NoArgsConstructor @NoArgsConstructor
@ToString @ToString
@Document(collection = "EmployeeRoles") @Document(collection = "EmployeeDetails")
public class EmployeeRoles implements Serializable { public class EmployeeRoles implements Serializable {
/** /**
...@@ -43,6 +45,10 @@ public class EmployeeRoles implements Serializable { ...@@ -43,6 +45,10 @@ public class EmployeeRoles implements Serializable {
private String functionalGroup; private String functionalGroup;
private String empStatus; private String empStatus;
private String employmentType; private String employmentType;
@DateTimeFormat(iso = ISO.DATE)
private Date dateOfJoining;
@DateTimeFormat(iso = ISO.DATE)
private Date dateOfBirth;
private Date createdOn; private Date createdOn;
private Date lastModifiedOn; private Date lastModifiedOn;
......
...@@ -18,10 +18,9 @@ import lombok.ToString; ...@@ -18,10 +18,9 @@ import lombok.ToString;
@AllArgsConstructor @AllArgsConstructor
@NoArgsConstructor @NoArgsConstructor
@ToString @ToString
@Document(collection = "Projects") @Document(collection = "Team")
public class Project implements Serializable { public class Project implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@Id @Id
......
...@@ -20,7 +20,7 @@ import lombok.ToString; ...@@ -20,7 +20,7 @@ import lombok.ToString;
@AllArgsConstructor @AllArgsConstructor
@NoArgsConstructor @NoArgsConstructor
@ToString @ToString
@Document(collection = "ProjectTeamMate") @Document(collection = "TeamDetails")
public class ProjectTeamMate implements Serializable { public class ProjectTeamMate implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
......
...@@ -5,16 +5,16 @@ import java.util.List; ...@@ -5,16 +5,16 @@ import java.util.List;
import org.bson.types.ObjectId; import org.bson.types.ObjectId;
import org.springframework.data.mongodb.repository.MongoRepository; import org.springframework.data.mongodb.repository.MongoRepository;
import com.nisum.mytime.model.TeamMateBilling; import com.nisum.mytime.model.BillingDetails;
public interface TeamMatesBillingRepo extends MongoRepository<TeamMateBilling, String> { public interface TeamMatesBillingRepo extends MongoRepository<BillingDetails, String> {
List<TeamMateBilling> findByProjectId(String projectId); List<BillingDetails> findByProjectId(String projectId);
List<TeamMateBilling> findByEmployeeId(String employeeId); List<BillingDetails> findByEmployeeId(String employeeId);
TeamMateBilling findById(ObjectId id); BillingDetails findById(ObjectId id);
List<TeamMateBilling> findByEmployeeIdAndProjectId(String employeeId, String projectId); List<BillingDetails> findByEmployeeIdAndProjectId(String employeeId, String projectId);
} }
...@@ -5,22 +5,24 @@ import java.util.List; ...@@ -5,22 +5,24 @@ import java.util.List;
import org.bson.types.ObjectId; import org.bson.types.ObjectId;
import com.nisum.mytime.exception.handler.MyTimeException; import com.nisum.mytime.exception.handler.MyTimeException;
import com.nisum.mytime.model.BillingDetails;
import com.nisum.mytime.model.EmpLoginData; import com.nisum.mytime.model.EmpLoginData;
import com.nisum.mytime.model.EmployeeDashboardVO; import com.nisum.mytime.model.EmployeeDashboardVO;
import com.nisum.mytime.model.EmployeeRoles; import com.nisum.mytime.model.EmployeeRoles;
import com.nisum.mytime.model.Project; import com.nisum.mytime.model.Project;
import com.nisum.mytime.model.ProjectTeamMate; import com.nisum.mytime.model.ProjectTeamMate;
import com.nisum.mytime.model.TeamMateBilling;
public interface ProjectService { public interface ProjectService {
List<EmpLoginData> employeeLoginsBasedOnDate(long id, String fromDate, String toDate) throws MyTimeException; List<EmpLoginData> employeeLoginsBasedOnDate(long id, String fromDate,
String toDate) throws MyTimeException;
List<Project> getProjects() throws MyTimeException; List<Project> getProjects() throws MyTimeException;
Project addProject(Project project) throws MyTimeException; Project addProject(Project project) throws MyTimeException;
String generatePdfReport(long id, String fromDate, String toDate) throws MyTimeException; String generatePdfReport(long id, String fromDate, String toDate)
throws MyTimeException;
EmployeeRoles getEmployeesRole(String emailId); EmployeeRoles getEmployeesRole(String emailId);
...@@ -32,11 +34,12 @@ public interface ProjectService { ...@@ -32,11 +34,12 @@ public interface ProjectService {
List<ProjectTeamMate> getTeamDetails(String empId); List<ProjectTeamMate> getTeamDetails(String empId);
public ProjectTeamMate addProjectTeamMate(ProjectTeamMate projectTeamMate) throws MyTimeException; public ProjectTeamMate addProjectTeamMate(ProjectTeamMate projectTeamMate)
throws MyTimeException;
ProjectTeamMate updateTeammate(ProjectTeamMate projectTeamMate); ProjectTeamMate updateTeammate(ProjectTeamMate projectTeamMate);
void deleteTeammate(String empId, String projectId,ObjectId id); void deleteTeammate(String empId, String projectId, ObjectId id);
List<Project> getProjects(String managerId) throws MyTimeException; List<Project> getProjects(String managerId) throws MyTimeException;
...@@ -52,11 +55,17 @@ public interface ProjectService { ...@@ -52,11 +55,17 @@ public interface ProjectService {
public List<ProjectTeamMate> getMyProjectAllocations(String empId); public List<ProjectTeamMate> getMyProjectAllocations(String empId);
List<TeamMateBilling> getEmployeeBillingDetails(String empId,String projectId); List<BillingDetails> getEmployeeBillingDetails(String empId,
String projectId);
TeamMateBilling addEmployeeBillingDetails(TeamMateBilling teamMate); BillingDetails addEmployeeBillingDetails(BillingDetails teamMate);
TeamMateBilling updateEmployeeBilling(TeamMateBilling teamMate); BillingDetails updateEmployeeBilling(BillingDetails teamMate);
void deleteEmployeeBilling(BillingDetails teamMate);
public List<EmployeeDashboardVO> getEmployeesDashBoard(); public List<EmployeeDashboardVO> getEmployeesDashBoard();
List<BillingDetails> getEmployeeActiveBillingDetails(String empId,
String projectId);
} }
package com.nisum.mytime.service; package com.nisum.mytime.service;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection;
import java.util.Comparator; import java.util.Comparator;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
...@@ -12,7 +11,6 @@ import java.util.stream.Collectors; ...@@ -12,7 +11,6 @@ import java.util.stream.Collectors;
import org.bson.types.ObjectId; import org.bson.types.ObjectId;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Sort;
import org.springframework.data.mongodb.core.FindAndModifyOptions; import org.springframework.data.mongodb.core.FindAndModifyOptions;
import org.springframework.data.mongodb.core.MongoTemplate; import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria; import org.springframework.data.mongodb.core.query.Criteria;
...@@ -21,12 +19,12 @@ import org.springframework.data.mongodb.core.query.Update; ...@@ -21,12 +19,12 @@ import org.springframework.data.mongodb.core.query.Update;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.nisum.mytime.exception.handler.MyTimeException; import com.nisum.mytime.exception.handler.MyTimeException;
import com.nisum.mytime.model.BillingDetails;
import com.nisum.mytime.model.EmpLoginData; import com.nisum.mytime.model.EmpLoginData;
import com.nisum.mytime.model.EmployeeDashboardVO; import com.nisum.mytime.model.EmployeeDashboardVO;
import com.nisum.mytime.model.EmployeeRoles; import com.nisum.mytime.model.EmployeeRoles;
import com.nisum.mytime.model.Project; import com.nisum.mytime.model.Project;
import com.nisum.mytime.model.ProjectTeamMate; import com.nisum.mytime.model.ProjectTeamMate;
import com.nisum.mytime.model.TeamMateBilling;
import com.nisum.mytime.repository.EmployeeRolesRepo; import com.nisum.mytime.repository.EmployeeRolesRepo;
import com.nisum.mytime.repository.ProjectRepo; import com.nisum.mytime.repository.ProjectRepo;
import com.nisum.mytime.repository.ProjectTeamMatesRepo; import com.nisum.mytime.repository.ProjectTeamMatesRepo;
...@@ -56,13 +54,15 @@ public class ProjectServiceImpl implements ProjectService { ...@@ -56,13 +54,15 @@ public class ProjectServiceImpl implements ProjectService {
private MongoTemplate mongoTemplate; private MongoTemplate mongoTemplate;
@Override @Override
public List<EmpLoginData> employeeLoginsBasedOnDate(long id, String fromDate, String toDate) public List<EmpLoginData> employeeLoginsBasedOnDate(long id,
throws MyTimeException { String fromDate, String toDate) throws MyTimeException {
return employeeDataBaseService.fetchEmployeeLoginsBasedOnDates(id, fromDate, toDate); return employeeDataBaseService.fetchEmployeeLoginsBasedOnDates(id,
fromDate, toDate);
} }
@Override @Override
public String generatePdfReport(long id, String fromDate, String toDate) throws MyTimeException { public String generatePdfReport(long id, String fromDate, String toDate)
throws MyTimeException {
return pdfReportGenerator.generateEmployeeReport(id, fromDate, toDate); return pdfReportGenerator.generateEmployeeReport(id, fromDate, toDate);
} }
...@@ -87,13 +87,15 @@ public class ProjectServiceImpl implements ProjectService { ...@@ -87,13 +87,15 @@ public class ProjectServiceImpl implements ProjectService {
Project project = projectRepo.findByProjectId(projectId); Project project = projectRepo.findByProjectId(projectId);
projectRepo.delete(project); projectRepo.delete(project);
Query query = new Query(Criteria.where("projectId").is(projectId)); Query query = new Query(Criteria.where("projectId").is(projectId));
List<ProjectTeamMate> list = mongoTemplate.find(query, ProjectTeamMate.class); List<ProjectTeamMate> list = mongoTemplate.find(query,
ProjectTeamMate.class);
projectTeamMatesRepo.delete(list); projectTeamMatesRepo.delete(list);
} }
@Override @Override
public Project updateProject(Project project) { public Project updateProject(Project project) {
Query query = new Query(Criteria.where("projectId").is(project.getProjectId())); Query query = new Query(
Criteria.where("projectId").is(project.getProjectId()));
Update update = new Update(); Update update = new Update();
update.set("projectName", project.getProjectName()); update.set("projectName", project.getProjectName());
update.set("managerId", project.getManagerId()); update.set("managerId", project.getManagerId());
...@@ -103,8 +105,10 @@ public class ProjectServiceImpl implements ProjectService { ...@@ -103,8 +105,10 @@ public class ProjectServiceImpl implements ProjectService {
FindAndModifyOptions options = new FindAndModifyOptions(); FindAndModifyOptions options = new FindAndModifyOptions();
options.returnNew(true); options.returnNew(true);
options.upsert(true); options.upsert(true);
Project projectDB = mongoTemplate.findAndModify(query, update, options, Project.class); Project projectDB = mongoTemplate.findAndModify(query, update, options,
List<ProjectTeamMate> employeeDetails = projectTeamMatesRepo.findByProjectId(project.getProjectId()); Project.class);
List<ProjectTeamMate> employeeDetails = projectTeamMatesRepo
.findByProjectId(project.getProjectId());
if (employeeDetails != null && projectDB != null) { if (employeeDetails != null && projectDB != null) {
for (ProjectTeamMate emp : employeeDetails) { for (ProjectTeamMate emp : employeeDetails) {
emp.setManagerId(projectDB.getManagerId()); emp.setManagerId(projectDB.getManagerId());
...@@ -129,21 +133,66 @@ public class ProjectServiceImpl implements ProjectService { ...@@ -129,21 +133,66 @@ public class ProjectServiceImpl implements ProjectService {
} }
@Override @Override
public ProjectTeamMate addProjectTeamMate(ProjectTeamMate projectTeamMate) throws MyTimeException { public ProjectTeamMate addProjectTeamMate(ProjectTeamMate projectTeamMate)
return projectTeamMatesRepo.save(projectTeamMate); throws MyTimeException {
ProjectTeamMate pT = projectTeamMatesRepo.save(projectTeamMate);
BillingDetails billings = new BillingDetails();
billings.setEmployeeId(pT.getEmployeeId());
billings.setEmployeeName(pT.getEmployeeName());
billings.setProjectId(pT.getProjectId());
billings.setProjectName(pT.getProjectName());
billings.setBillableStatus(pT.getBillableStatus());
billings.setActive(true);
billings.setBillingStartDate(pT.getStartDate());
billings.setBillingEndDate(pT.getEndDate());
billings.setCreateDate(new Date());
addEmployeeBillingDetails(billings);
return pT;
} }
@Override @Override
public ProjectTeamMate updateTeammate(ProjectTeamMate projectTeamMate) { public ProjectTeamMate updateTeammate(ProjectTeamMate projectTeamMate) {
ProjectTeamMate existingTeammate = projectTeamMatesRepo ProjectTeamMate existingTeammate = projectTeamMatesRepo
.findByEmployeeIdAndProjectId(projectTeamMate.getEmployeeId(), projectTeamMate.getProjectId()); .findByEmployeeIdAndProjectId(projectTeamMate.getEmployeeId(),
projectTeamMate.getProjectId());
existingTeammate.setProjectId(projectTeamMate.getProjectId()); existingTeammate.setProjectId(projectTeamMate.getProjectId());
existingTeammate.setProjectName(projectTeamMate.getProjectName()); existingTeammate.setProjectName(projectTeamMate.getProjectName());
if (existingTeammate.getBillableStatus() == null
|| projectTeamMate.getBillableStatus() != null
&& existingTeammate.getBillableStatus() != null
&& !existingTeammate.getBillableStatus()
.equalsIgnoreCase(
projectTeamMate.getBillableStatus())) {
List<BillingDetails> listBD = getEmployeeActiveBillingDetails(
projectTeamMate.getEmployeeId(),
projectTeamMate.getProjectId());
if (listBD != null && !listBD.isEmpty()) {
BillingDetails billingDetails = listBD.get(0);
billingDetails.setBillingEndDate(new Date());
billingDetails.setActive(false);
updateEmployeeBilling(billingDetails);
}
BillingDetails billings = new BillingDetails();
billings.setEmployeeId(projectTeamMate.getEmployeeId());
billings.setEmployeeName(projectTeamMate.getEmployeeName());
billings.setProjectId(projectTeamMate.getProjectId());
billings.setProjectName(projectTeamMate.getProjectName());
billings.setBillableStatus(projectTeamMate.getBillableStatus());
billings.setActive(true);
billings.setBillingStartDate(new Date());
billings.setBillingEndDate(projectTeamMate.getEndDate());
billings.setCreateDate(new Date());
addEmployeeBillingDetails(billings);
// TODO
}
existingTeammate.setBillableStatus(projectTeamMate.getBillableStatus()); existingTeammate.setBillableStatus(projectTeamMate.getBillableStatus());
existingTeammate.setStartDate(projectTeamMate.getStartDate());
existingTeammate.setEndDate(projectTeamMate.getEndDate());
existingTeammate.setShift(projectTeamMate.getShift()); existingTeammate.setShift(projectTeamMate.getShift());
ProjectTeamMate teamMate = projectTeamMatesRepo.save(existingTeammate); ProjectTeamMate teamMate = projectTeamMatesRepo.save(existingTeammate);
EmployeeRoles employeeDB = employeeRolesRepo.findByEmployeeId(teamMate.getEmployeeId()); EmployeeRoles employeeDB = employeeRolesRepo
.findByEmployeeId(teamMate.getEmployeeId());
employeeDB.setShift(teamMate.getShift()); employeeDB.setShift(teamMate.getShift());
employeeRolesRepo.save(employeeDB); employeeRolesRepo.save(employeeDB);
return teamMate; return teamMate;
...@@ -159,17 +208,20 @@ public class ProjectServiceImpl implements ProjectService { ...@@ -159,17 +208,20 @@ public class ProjectServiceImpl implements ProjectService {
@Override @Override
public List<Project> getProjects(String managerId) throws MyTimeException { public List<Project> getProjects(String managerId) throws MyTimeException {
Query query = new Query(Criteria.where("managerId").is(managerId).and("status").ne("Completed")); Query query = new Query(Criteria.where("managerId").is(managerId)
.and("status").ne("Completed"));
return mongoTemplate.find(query, Project.class); return mongoTemplate.find(query, Project.class);
} }
@Override @Override
public List<ProjectTeamMate> getMyTeamDetails(String empId) { public List<ProjectTeamMate> getMyTeamDetails(String empId) {
List<ProjectTeamMate> teamMates = new ArrayList<>(); List<ProjectTeamMate> teamMates = new ArrayList<>();
List<ProjectTeamMate> empRecords = projectTeamMatesRepo.findByEmployeeId(empId); List<ProjectTeamMate> empRecords = projectTeamMatesRepo
.findByEmployeeId(empId);
for (ProjectTeamMate pt : empRecords) { for (ProjectTeamMate pt : empRecords) {
if (pt.isActive()) { if (pt.isActive()) {
teamMates.addAll(projectTeamMatesRepo.findByProjectId(pt.getProjectId())); teamMates.addAll(projectTeamMatesRepo
.findByProjectId(pt.getProjectId()));
} }
} }
return teamMates; return teamMates;
...@@ -183,7 +235,8 @@ public class ProjectServiceImpl implements ProjectService { ...@@ -183,7 +235,8 @@ public class ProjectServiceImpl implements ProjectService {
List<ProjectTeamMate> empRecords = projectTeamMatesRepo.findAll(); List<ProjectTeamMate> empRecords = projectTeamMatesRepo.findAll();
for (ProjectTeamMate pt : empRecords) { for (ProjectTeamMate pt : empRecords) {
Project project = projectRepo.findByProjectId(pt.getProjectId()); Project project = projectRepo.findByProjectId(pt.getProjectId());
if (project != null && project.getStatus() != null && !"Completed".equalsIgnoreCase(project.getStatus())) { if (project != null && project.getStatus() != null
&& !"Completed".equalsIgnoreCase(project.getStatus())) {
teamMates.add(pt.getEmployeeId()); teamMates.add(pt.getEmployeeId());
} }
} }
...@@ -203,11 +256,15 @@ public class ProjectServiceImpl implements ProjectService { ...@@ -203,11 +256,15 @@ public class ProjectServiceImpl implements ProjectService {
List<ProjectTeamMate> shiftEmpDetails = new ArrayList<>(); List<ProjectTeamMate> shiftEmpDetails = new ArrayList<>();
for (Project pt : projects) { for (Project pt : projects) {
if ("Active".equalsIgnoreCase(pt.getStatus())) { if ("Active".equalsIgnoreCase(pt.getStatus())) {
List<ProjectTeamMate> employeeDetails = projectTeamMatesRepo.findByProjectId(pt.getProjectId()); List<ProjectTeamMate> employeeDetails = projectTeamMatesRepo
.findByProjectId(pt.getProjectId());
for (ProjectTeamMate emp : employeeDetails) { for (ProjectTeamMate emp : employeeDetails) {
if (emp.getShift() != null && emp.getShift().equalsIgnoreCase(shift)) { if (emp.getShift() != null
&& emp.getShift().equalsIgnoreCase(shift)) {
shiftEmpDetails.add(emp); shiftEmpDetails.add(emp);
} else if (emp.getShift() == null && "Shift 1(09:00 AM - 06:00 PM)".equalsIgnoreCase(shift)) } else if (emp.getShift() == null
&& "Shift 1(09:00 AM - 06:00 PM)"
.equalsIgnoreCase(shift))
shiftEmpDetails.add(emp); shiftEmpDetails.add(emp);
} }
} }
...@@ -221,7 +278,8 @@ public class ProjectServiceImpl implements ProjectService { ...@@ -221,7 +278,8 @@ public class ProjectServiceImpl implements ProjectService {
List<ProjectTeamMate> allprojectMates = new ArrayList<>(); List<ProjectTeamMate> allprojectMates = new ArrayList<>();
for (Project pt : projects) { for (Project pt : projects) {
if (!"Completed".equalsIgnoreCase(pt.getStatus())) { if (!"Completed".equalsIgnoreCase(pt.getStatus())) {
List<ProjectTeamMate> employeeDetails = projectTeamMatesRepo.findByProjectId(pt.getProjectId()); List<ProjectTeamMate> employeeDetails = projectTeamMatesRepo
.findByProjectId(pt.getProjectId());
allprojectMates.addAll(employeeDetails); allprojectMates.addAll(employeeDetails);
} }
...@@ -241,95 +299,152 @@ public class ProjectServiceImpl implements ProjectService { ...@@ -241,95 +299,152 @@ public class ProjectServiceImpl implements ProjectService {
} }
@Override @Override
public List<TeamMateBilling> getEmployeeBillingDetails(String empId,String projectId) { public List<BillingDetails> getEmployeeBillingDetails(String empId,
String projectId) {
List<TeamMateBilling> billings= teamMatesBillingRepo.findByEmployeeIdAndProjectId(empId, projectId); List<BillingDetails> billings = teamMatesBillingRepo
List<TeamMateBilling> billingsSorted=billings; .findByEmployeeIdAndProjectId(empId, projectId);
List<BillingDetails> billingsSorted = billings;
try { try {
billingsSorted=(billings==null || billings.size()==0)?billings: billings.stream().sorted(Comparator.comparing(TeamMateBilling::getCreateDate).reversed()).collect(Collectors.toList()); billingsSorted = (billings == null || billings.size() == 0)
}catch (Exception e) { ? billings
: billings.stream()
.sorted(Comparator
.comparing(BillingDetails::getCreateDate)
.reversed())
.collect(Collectors.toList());
} catch (Exception e) {
// TODO: handle exception // TODO: handle exception
} }
return billingsSorted; return billingsSorted;
} }
@Override @Override
public TeamMateBilling addEmployeeBillingDetails(TeamMateBilling teamMate) { public List<BillingDetails> getEmployeeActiveBillingDetails(String empId,
List<TeamMateBilling> billingsPast = getEmployeeBillingDetails(teamMate.getEmployeeId(),teamMate.getProjectId()); String projectId) {
for(TeamMateBilling tB:billingsPast) { Query query4 = new Query();
tB.setActive(false); query4.addCriteria(Criteria.where("active").is(new Boolean(true)));
teamMatesBillingRepo.save(tB); List<BillingDetails> billings = mongoTemplate.find(query4,
BillingDetails.class);
List<BillingDetails> billingsSorted = billings;
try {
billingsSorted = (billings == null || billings.size() == 0)
? billings
: billings.stream()
.sorted(Comparator
.comparing(
BillingDetails::getBillingStartDate)
.reversed())
.collect(Collectors.toList());
} catch (Exception e) {
// TODO: handle exception
}
return billingsSorted;
} }
@Override
public BillingDetails addEmployeeBillingDetails(BillingDetails teamMate) {
List<BillingDetails> billingsPast = getEmployeeBillingDetails(
teamMate.getEmployeeId(), teamMate.getProjectId());
/*
* for (BillingDetails tB : billingsPast) { tB.setActive(false);
* teamMatesBillingRepo.save(tB); }
*/
teamMate.setCreateDate(new Date()); teamMate.setCreateDate(new Date());
return teamMatesBillingRepo.save(teamMate); return teamMatesBillingRepo.save(teamMate);
} }
@Override @Override
public TeamMateBilling updateEmployeeBilling(TeamMateBilling teamMate) { public BillingDetails updateEmployeeBilling(BillingDetails teamMate) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
return teamMatesBillingRepo.save(teamMate); return teamMatesBillingRepo.save(teamMate);
} }
@Override
public void deleteEmployeeBilling(BillingDetails teamMate) {
// TODO Auto-generated method stub
teamMatesBillingRepo.delete(teamMate);
}
@Override @Override
public List<EmployeeDashboardVO> getEmployeesDashBoard() { public List<EmployeeDashboardVO> getEmployeesDashBoard() {
List<EmployeeRoles> allEmployees = employeeRolesRepo.findAll(); List<EmployeeRoles> allEmployees = employeeRolesRepo.findAll();
List<EmployeeRoles> notAssignedEmployees = new ArrayList<>(); List<EmployeeRoles> notAssignedEmployees = new ArrayList<>();
List<EmployeeDashboardVO> employeeDashboard = new ArrayList<>(); List<EmployeeDashboardVO> employeeDashboard = new ArrayList<>();
Map<String,Object> teamMatesMap=new HashMap(); Map<String, Object> teamMatesMap = new HashMap();
Map<String,Object> teamMatesStatusMap=new HashMap(); Map<String, Object> teamMatesStatusMap = new HashMap();
List<ProjectTeamMate> empRecords = projectTeamMatesRepo.findAll(); //find all active employees List<ProjectTeamMate> empRecords = projectTeamMatesRepo.findAll(); // find
// all
// active
// employees
for (ProjectTeamMate pt : empRecords) { for (ProjectTeamMate pt : empRecords) {
if(pt.isActive()) { if (pt.isActive()) {
Project project = projectRepo.findByProjectId(pt.getProjectId()); Project project = projectRepo
if (project != null && project.getStatus() != null && !"Completed".equalsIgnoreCase(project.getStatus())) { .findByProjectId(pt.getProjectId());
Object projectTeamMate= teamMatesMap.get(pt.getEmployeeId()); if (project != null && project.getStatus() != null
&& !"Completed".equalsIgnoreCase(project.getStatus())) {
if(projectTeamMate==null) { Object projectTeamMate = teamMatesMap
List listOfObjects=new ArrayList<>(); .get(pt.getEmployeeId());
if (projectTeamMate == null) {
List listOfObjects = new ArrayList<>();
listOfObjects.add(pt); listOfObjects.add(pt);
teamMatesMap.put(pt.getEmployeeId(),listOfObjects);//TODO a person can have multiple active projects with billability teamMatesMap.put(pt.getEmployeeId(), listOfObjects);// TODO
}else { // a
List existingRecordsInMap=(List) teamMatesMap.get(pt.getEmployeeId()); // person
// can
// have
// multiple
// active
// projects
// with
// billability
} else {
List existingRecordsInMap = (List) teamMatesMap
.get(pt.getEmployeeId());
existingRecordsInMap.add(pt); existingRecordsInMap.add(pt);
teamMatesMap.put(pt.getEmployeeId(),existingRecordsInMap); teamMatesMap.put(pt.getEmployeeId(),
existingRecordsInMap);
} }
} }
} }
} }
for (EmployeeRoles emp : allEmployees) { for (EmployeeRoles emp : allEmployees) {
if(emp.getEmployeeId()!=null&&emp.getEmployeeId().equalsIgnoreCase("16112")) { if (emp.getEmployeeId() != null
&& emp.getEmployeeId().equalsIgnoreCase("16112")) {
System.out.println(emp); System.out.println(emp);
} }
if (teamMatesMap.containsKey(emp.getEmployeeId())) { if (teamMatesMap.containsKey(emp.getEmployeeId())) {
System.out.println("***************** Empl alrady assigned"); System.out.println("***************** Empl alrady assigned");
Object value= teamMatesMap.get(emp.getEmployeeId()); Object value = teamMatesMap.get(emp.getEmployeeId());
if(value instanceof List) { if (value instanceof List) {
List listOfTeamMates=(List) value; List listOfTeamMates = (List) value;
String billableStatus="NA"; String billableStatus = "NA";
for(Object obj:listOfTeamMates) { for (Object obj : listOfTeamMates) {
ProjectTeamMate projectTeamMate=(ProjectTeamMate) obj; ProjectTeamMate projectTeamMate = (ProjectTeamMate) obj;
String status=projectTeamMate.getBillableStatus(); String status = projectTeamMate.getBillableStatus();
if(status==null) { if (status == null) {
status="NA"; status = "NA";
} }
System.out.println("---------------------------"); System.out.println("---------------------------");
EmployeeDashboardVO empVo=new EmployeeDashboardVO(); EmployeeDashboardVO empVo = new EmployeeDashboardVO();
System.out.println(emp); System.out.println(emp);
BeanUtils.copyProperties(emp, empVo); BeanUtils.copyProperties(emp, empVo);
BeanUtils.copyProperties(projectTeamMate, empVo,"employeeId","employeeName" ,"emailId","role","designation","mobileNumber"); BeanUtils.copyProperties(projectTeamMate, empVo,
"employeeId", "employeeName", "emailId", "role",
"designation", "mobileNumber");
employeeDashboard.add(empVo); employeeDashboard.add(empVo);
} }
} }
}else { } else {
EmployeeDashboardVO empVo=new EmployeeDashboardVO(); EmployeeDashboardVO empVo = new EmployeeDashboardVO();
System.out.println(emp); System.out.println(emp);
BeanUtils.copyProperties(emp, empVo); BeanUtils.copyProperties(emp, empVo);
...@@ -338,7 +453,7 @@ public class ProjectServiceImpl implements ProjectService { ...@@ -338,7 +453,7 @@ public class ProjectServiceImpl implements ProjectService {
employeeDashboard.add(empVo); employeeDashboard.add(empVo);
} }
System.out.println("&&&&&&&&&&"); System.out.println("&&&&&&&&&&");
//System.out.println(empVo); // System.out.println(empVo);
System.out.println("---------------------------"); System.out.println("---------------------------");
......
...@@ -129,6 +129,8 @@ public class UserServiceImpl implements UserService { ...@@ -129,6 +129,8 @@ public class UserServiceImpl implements UserService {
update.set("empLocation", employeeRoles.getEmpLocation()); update.set("empLocation", employeeRoles.getEmpLocation());
update.set("domain", employeeRoles.getDomain()); update.set("domain", employeeRoles.getDomain());
update.set("designation", employeeRoles.getDesignation()); update.set("designation", employeeRoles.getDesignation());
update.set("dateOfBirth", employeeRoles.getDateOfBirth());
update.set("dateOfJoining", employeeRoles.getDateOfJoining());
update.set("lastModifiedOn", new Date()); update.set("lastModifiedOn", new Date());
FindAndModifyOptions options = new FindAndModifyOptions(); FindAndModifyOptions options = new FindAndModifyOptions();
options.returnNew(true); options.returnNew(true);
......
...@@ -63,6 +63,9 @@ myApp.controller("assignRoleController",function($scope, myFactory, $mdDialog, $ ...@@ -63,6 +63,9 @@ myApp.controller("assignRoleController",function($scope, myFactory, $mdDialog, $
$scope.parentData.empStatus = row.entity.empStatus; $scope.parentData.empStatus = row.entity.empStatus;
$scope.parentData.employmentType = row.entity.employmentType; $scope.parentData.employmentType = row.entity.employmentType;
$scope.parentData.domain = row.entity.domain; $scope.parentData.domain = row.entity.domain;
$scope.parentData.dateOfJoining = row.entity.dateOfJoining;
$scope.parentData.dateOfBirth = row.entity.dateOfBirth;
if(action == "Update") if(action == "Update")
$scope.assignRole(action, $scope.parentData); $scope.assignRole(action, $scope.parentData);
else if(action == "Delete") else if(action == "Delete")
...@@ -246,6 +249,8 @@ myApp.controller("assignRoleController",function($scope, myFactory, $mdDialog, $ ...@@ -246,6 +249,8 @@ myApp.controller("assignRoleController",function($scope, myFactory, $mdDialog, $
$scope.employmentType = dataToPass.employmentType; $scope.employmentType = dataToPass.employmentType;
$scope.domain = dataToPass.domain; $scope.domain = dataToPass.domain;
$scope.designation = dataToPass.designation; $scope.designation = dataToPass.designation;
$scope.dateOfJoining = new Date(dataToPass.dateOfJoining);
$scope.dateOfBirth = new Date(dataToPass.dateOfBirth);;
$scope.isDisabled = true; $scope.isDisabled = true;
} }
$scope.domains = myFactory.getDomains(); $scope.domains = myFactory.getDomains();
...@@ -381,7 +386,8 @@ myApp.controller("assignRoleController",function($scope, myFactory, $mdDialog, $ ...@@ -381,7 +386,8 @@ myApp.controller("assignRoleController",function($scope, myFactory, $mdDialog, $
document.getElementById('empRole').focus(); document.getElementById('empRole').focus();
}else{ }else{
$scope.alertMsg = ""; $scope.alertMsg = "";
var record = {"employeeId":$scope.empId, "employeeName": $scope.empName, "emailId": $scope.empEmail, "role": $scope.empRole, "empLocation": $scope.empLocation,"designation": $scope.designation,"functionalGroup": $scope.functionalGroup,"empStatus": $scope.empStatus,"employmentType": $scope.employmentType,"domain": $scope.domain};
var record = {"employeeId":$scope.empId, "employeeName": $scope.empName, "emailId": $scope.empEmail, "role": $scope.empRole, "empLocation": $scope.empLocation,"designation": $scope.designation,"functionalGroup": $scope.functionalGroup,"empStatus": $scope.empStatus,"employmentType": $scope.employmentType,"domain": $scope.domain,"dateOfJoining":$scope.dateOfJoining,"dateOfBirth":$scope.dateOfBirth};
addOrUpdateRole(record, $scope.templateTitle); addOrUpdateRole(record, $scope.templateTitle);
$timeout(function(){updateGrid($scope.templateTitle, record)},500); $timeout(function(){updateGrid($scope.templateTitle, record)},500);
} }
......
...@@ -93,7 +93,6 @@ myApp.controller("loginController",function($scope, myFactory, $compile, $window ...@@ -93,7 +93,6 @@ myApp.controller("loginController",function($scope, myFactory, $compile, $window
method : "GET", method : "GET",
url : appConfig.appUri + "user/getMasterData" url : appConfig.appUri + "user/getMasterData"
}).then(function mySuccess(response) { }).then(function mySuccess(response) {
myFactory.setTechnologies(response.data);
myFactory.setEmployementTypes(response.data['EmpType']); myFactory.setEmployementTypes(response.data['EmpType']);
myFactory.setFunctionalgroups(response.data['FunctionalGrp']) myFactory.setFunctionalgroups(response.data['FunctionalGrp'])
myFactory.setEmployeeStatus(response.data['EmployeeStatus']); myFactory.setEmployeeStatus(response.data['EmployeeStatus']);
......
...@@ -17,6 +17,8 @@ myApp.controller("projectTeamController",function($scope, myFactory, $mdDialog, ...@@ -17,6 +17,8 @@ myApp.controller("projectTeamController",function($scope, myFactory, $mdDialog,
"designation":"", "designation":"",
"billableStatus":"", "billableStatus":"",
"mobileNumber":"", "mobileNumber":"",
"startDate":"",
"endDate":"",
"action":"" "action":""
}; };
$scope.employees = []; $scope.employees = [];
...@@ -85,6 +87,9 @@ myApp.controller("projectTeamController",function($scope, myFactory, $mdDialog, ...@@ -85,6 +87,9 @@ myApp.controller("projectTeamController",function($scope, myFactory, $mdDialog,
$scope.parentData.designation = row.entity.designation; $scope.parentData.designation = row.entity.designation;
$scope.parentData.billableStatus = row.entity.billableStatus; $scope.parentData.billableStatus = row.entity.billableStatus;
$scope.parentData.mobileNumber = row.entity.mobileNumber; $scope.parentData.mobileNumber = row.entity.mobileNumber;
$scope.parentData.startDate = row.entity.startDate;
$scope.parentData.endDate = row.entity.endDate;
if(action == "Update"){ if(action == "Update"){
$scope.updateEmployee(action, $scope.parentData); $scope.updateEmployee(action, $scope.parentData);
} }
...@@ -326,6 +331,8 @@ myApp.controller("projectTeamController",function($scope, myFactory, $mdDialog, ...@@ -326,6 +331,8 @@ myApp.controller("projectTeamController",function($scope, myFactory, $mdDialog,
$scope.mobileNumber = dataToPass.mobileNumber; $scope.mobileNumber = dataToPass.mobileNumber;
$scope.experience = dataToPass.experience; $scope.experience = dataToPass.experience;
$scope.designation = dataToPass.designation; $scope.designation = dataToPass.designation;
$scope.startDate = new Date(dataToPass.startDate);
$scope.endDate = new Date(dataToPass.endDate);
$scope.isDisabled = true; $scope.isDisabled = true;
$scope.projectModel = { $scope.projectModel = {
'projectName': dataToPass.projectName, 'projectName': dataToPass.projectName,
...@@ -389,6 +396,7 @@ myApp.controller("projectTeamController",function($scope, myFactory, $mdDialog, ...@@ -389,6 +396,7 @@ myApp.controller("projectTeamController",function($scope, myFactory, $mdDialog,
type: 'info' type: 'info'
}); });
}; };
$scope.toggleBillability = function() { $scope.toggleBillability = function() {
$scope.showBillable = !$scope.showBillable; $scope.showBillable = !$scope.showBillable;
}; };
...@@ -405,6 +413,10 @@ myApp.controller("projectTeamController",function($scope, myFactory, $mdDialog, ...@@ -405,6 +413,10 @@ myApp.controller("projectTeamController",function($scope, myFactory, $mdDialog,
}else if(action == "Update"){ }else if(action == "Update"){
urlRequest = appConfig.appUri+ "projectTeam/updateEmployeeBilling"; urlRequest = appConfig.appUri+ "projectTeam/updateEmployeeBilling";
} }
else if(action == "Delete"){
urlRequest = appConfig.appUri+ "projectTeam/deleteEmployeeBilling";
}
var req = { var req = {
method : 'POST', method : 'POST',
url : urlRequest, url : urlRequest,
...@@ -421,6 +433,7 @@ myApp.controller("projectTeamController",function($scope, myFactory, $mdDialog, ...@@ -421,6 +433,7 @@ myApp.controller("projectTeamController",function($scope, myFactory, $mdDialog,
url : appConfig.appUri + "/projectTeam/getEmployeeBillingDetails?employeeId="+record.employeeId+"&projectId="+record.projectId url : appConfig.appUri + "/projectTeam/getEmployeeBillingDetails?employeeId="+record.employeeId+"&projectId="+record.projectId
}).then(function mySuccess(response) { }).then(function mySuccess(response) {
$scope.gridOptions.data = response.data; $scope.gridOptions.data = response.data;
}, function myError(response) { }, function myError(response) {
showAlert("Something went wrong while fetching data!!!"); showAlert("Something went wrong while fetching data!!!");
$scope.gridOptions.data = []; $scope.gridOptions.data = [];
...@@ -428,11 +441,11 @@ myApp.controller("projectTeamController",function($scope, myFactory, $mdDialog, ...@@ -428,11 +441,11 @@ myApp.controller("projectTeamController",function($scope, myFactory, $mdDialog,
if(action == "Add"){ if(action == "Add"){
$scope.toggleBillability(); $scope.toggleBillability();
} }
alert("Billability added successfully!!!") alert("Billability details modifed successfully!!!")
//showAlert("Billability added successfully!!!"); //showAlert("Billability added successfully!!!");
}, function myError(response){ }, function myError(response){
$scope.result = "Error"; $scope.result = "Error";
alert("Error Adding billability!!!") alert("Error modifying billability!!!")
//showAlert("Error Adding billability!!!"); //showAlert("Error Adding billability!!!");
}); });
}; };
...@@ -446,6 +459,15 @@ myApp.controller("projectTeamController",function($scope, myFactory, $mdDialog, ...@@ -446,6 +459,15 @@ myApp.controller("projectTeamController",function($scope, myFactory, $mdDialog,
$scope.gridOptions.data[index].editrow = false; $scope.gridOptions.data[index].editrow = false;
addOrUpdateBilling(row,"Update"); addOrUpdateBilling(row,"Update");
}; };
$scope.deleteRow = function (row) {
//get the index of selected row
var index = $scope.gridOptions.data.indexOf(row);
//Remove the edit mode when user click on Save button
$scope.gridOptions.data[index].editrow = false;
addOrUpdateBilling(row,"Delete");
};
var getCellActiveTemplateBilling='<div ng-show="COL_FIELD==true"><p class="col-lg-12">Y</P></div><div ng-show="COL_FIELD==false"><p class="col-lg-12">N</p></div>'; var getCellActiveTemplateBilling='<div ng-show="COL_FIELD==true"><p class="col-lg-12">Y</P></div><div ng-show="COL_FIELD==false"><p class="col-lg-12">N</p></div>';
$scope.gridOptions = { $scope.gridOptions = {
...@@ -480,6 +502,8 @@ myApp.controller("projectTeamController",function($scope, myFactory, $mdDialog, ...@@ -480,6 +502,8 @@ myApp.controller("projectTeamController",function($scope, myFactory, $mdDialog,
columnDefs : [ columnDefs : [
{name : 'id',displayName: 'Id', enableColumnMenu: false, enableSorting: false,cellTemplate: '<div>{{rowRenderIndex + 1}}</div>',enableCellEdit: false}, {name : 'id',displayName: 'Id', enableColumnMenu: false, enableSorting: false,cellTemplate: '<div>{{rowRenderIndex + 1}}</div>',enableCellEdit: false},
// {field : 'billingStartDate',displayName: 'Start Date', enableColumnMenu: false,enableSorting: false,cellTemplate: '<div ng-if="!row.entity.editrow">{{COL_FIELD|date:"dd-MMM-yyyy"}}</div> <div ng-if="row.entity.editrow"><input ng-class="\'colt\' + col.index" datepicker-popup is-open="false" ng-model="COL_FIELD" /></div>'}, // {field : 'billingStartDate',displayName: 'Start Date', enableColumnMenu: false,enableSorting: false,cellTemplate: '<div ng-if="!row.entity.editrow">{{COL_FIELD|date:"dd-MMM-yyyy"}}</div> <div ng-if="row.entity.editrow"><input ng-class="\'colt\' + col.index" datepicker-popup is-open="false" ng-model="COL_FIELD" /></div>'},
{field : 'billableStatus',displayName: 'Billable Status', enableColumnMenu: false, enableSorting: false},
{ {
field: 'billingStartDate', field: 'billingStartDate',
displayName: 'Start Date', displayName: 'Start Date',
...@@ -502,6 +526,7 @@ myApp.controller("projectTeamController",function($scope, myFactory, $mdDialog, ...@@ -502,6 +526,7 @@ myApp.controller("projectTeamController",function($scope, myFactory, $mdDialog,
cellTemplate: '<div><button ng-show="!row.entity.editrow" ng-click="grid.appScope.edit(row.entity)"><i class="fa fa-edit"></i></button>' + //Edit Button cellTemplate: '<div><button ng-show="!row.entity.editrow" ng-click="grid.appScope.edit(row.entity)"><i class="fa fa-edit"></i></button>' + //Edit Button
'<button ng-show="row.entity.editrow" ng-click="grid.appScope.saveRow(row.entity)"><i class="fa fa-floppy-o"></i></button>' +//Save Button '<button ng-show="row.entity.editrow" ng-click="grid.appScope.saveRow(row.entity)"><i class="fa fa-floppy-o"></i></button>' +//Save Button
'<button ng-show="row.entity.editrow" ng-click="grid.appScope.cancelEdit(row.entity)"><i class="fa fa-times"></i></button>' + //Cancel Button '<button ng-show="row.entity.editrow" ng-click="grid.appScope.cancelEdit(row.entity)"><i class="fa fa-times"></i></button>' + //Cancel Button
'<button ng-show="!row.entity.editrow" ng-click="grid.appScope.deleteRow(row.entity)"><i class="fa fa-minus-circle"></i></button>' +//Delete Button
'</div>', width: 100 '</div>', width: 100
} }
],rowStyle: function(row){/* ],rowStyle: function(row){/*
...@@ -597,13 +622,13 @@ myApp.controller("projectTeamController",function($scope, myFactory, $mdDialog, ...@@ -597,13 +622,13 @@ myApp.controller("projectTeamController",function($scope, myFactory, $mdDialog,
$scope.alertMsg = "Employee is already assigned to the selected project"; $scope.alertMsg = "Employee is already assigned to the selected project";
} else { } else {
$scope.alertMsg = ""; $scope.alertMsg = "";
var record = {"employeeId":employeeModel.employeeId, "employeeName":employeeModel.employeeName, "emailId": employeeModel.emailId, "role": employeeModel.role, "designation":employeeModel.designation,"shift": employeeModel.shift,"projectId":projectModel.projectId,"projectName":projectModel.projectName,"account":$scope.projectModel.account,"managerId":myFactory.getEmpId(),"managerName":myFactory.getEmpName(),"mobileNumber":employeeModel.mobileNumber,"active":true}; var record = {"employeeId":employeeModel.employeeId, "employeeName":employeeModel.employeeName, "emailId": employeeModel.emailId, "role": employeeModel.role, "designation":employeeModel.designation,"shift": employeeModel.shift,"projectId":projectModel.projectId,"projectName":projectModel.projectName,"account":$scope.projectModel.account,"managerId":myFactory.getEmpId(),"managerName":myFactory.getEmpName(),"mobileNumber":employeeModel.mobileNumber,"active":true,"billableStatus":$scope.empBillableStatus,"startDate":$scope.startDate,"endDate":$scope.endDate};
addOrUpdateRole(record, $scope.templateTitle); addOrUpdateRole(record, $scope.templateTitle);
$timeout(function(){updateGrid($scope.templateTitle, record)},500); $timeout(function(){updateGrid($scope.templateTitle, record)},500);
} }
}else{ }else{
$scope.alertMsg = ""; $scope.alertMsg = "";
var record = {"id":$scope.id,"employeeId":$scope.employeeId, "employeeName":$scope.employeeName, "emailId": $scope.emailId, "role": $scope.role, "shift": $scope.shift,"projectId":$scope.projectModel.projectId,"projectName":$scope.projectModel.projectName,"account":$scope.projectModel.account,"managerId":myFactory.getEmpId(),"managerName":myFactory.getEmpName(),"designation":$scope.empDesignation,"billableStatus":$scope.empBillableStatus,"experience":$scope.experience,"mobileNumber":$scope.mobileNumber}; var record = {"id":$scope.id,"employeeId":$scope.employeeId, "employeeName":$scope.employeeName, "emailId": $scope.emailId, "role": $scope.role, "shift": $scope.shift,"projectId":$scope.projectModel.projectId,"projectName":$scope.projectModel.projectName,"account":$scope.projectModel.account,"managerId":myFactory.getEmpId(),"managerName":myFactory.getEmpName(),"designation":$scope.empDesignation,"billableStatus":$scope.empBillableStatus,"experience":$scope.experience,"mobileNumber":$scope.mobileNumber,"startDate":$scope.startDate,"endDate":$scope.endDate};
addOrUpdateRole(record, $scope.templateTitle); addOrUpdateRole(record, $scope.templateTitle);
$timeout(function(){updateGrid($scope.templateTitle, record)},500); $timeout(function(){updateGrid($scope.templateTitle, record)},500);
} }
......
...@@ -35,6 +35,14 @@ ...@@ -35,6 +35,14 @@
<md-select ng-model="empBillableStatus" md-selected-text="getSelectedBillableStatus()" id="empBillableStatus"> <md-select ng-model="empBillableStatus" md-selected-text="getSelectedBillableStatus()" id="empBillableStatus">
<md-optgroup label="billable statuses"> <md-option ng-value="billableStatus" <md-optgroup label="billable statuses"> <md-option ng-value="billableStatus"
ng-repeat="billableStatus in billableStatuses">{{billableStatus}}</md-option> </md-optgroup> </md-select> ng-repeat="billableStatus in billableStatuses">{{billableStatus}}</md-option> </md-optgroup> </md-select>
<md-datepicker ng-model="startDate" md-placeholder="Start Date"
md-min-date="minDate" md-max-date="maxDate"
onkeydown="return false"
></md-datepicker>
<md-datepicker ng-model="endDate" md-placeholder="Projected End Date"
md-min-date="minDate" md-max-date="maxDate"
onkeydown="return false"
></md-datepicker>
<!-- <input type="text" class="form-control" id="experience" <!-- <input type="text" class="form-control" id="experience"
name="experience" ng-model="experience" placeholder="Experience" /><br> name="experience" ng-model="experience" placeholder="Experience" /><br>
<input type="text" class="form-control" id="mobileNumber" <input type="text" class="form-control" id="mobileNumber"
......
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
<div class="row col-lg-12" style="margin-left: -25px;"> <div class="row col-lg-12" style="margin-left: -25px;">
<div class="col-xs-4" style="margin-left: 0px;"> <div class="col-xs-4" style="margin-left: 0px;">
<md-button class="md-raised" ng-click="toggleBillability()" style="width:220px;background: cadetblue;color:white;">Add Billability </md-button> <!-- <md-button class="md-raised" ng-click="toggleBillability()" style="width:220px;background: cadetblue;color:white;">Add Billability </md-button> -->
</div> </div>
</div> </div>
......
...@@ -93,6 +93,24 @@ ...@@ -93,6 +93,24 @@
<md-optgroup label="Employment Status"> <md-option ng-value="status" <md-optgroup label="Employment Status"> <md-option ng-value="status"
ng-repeat="status in empStatuses">{{status}}</md-option> </md-optgroup> </md-select> ng-repeat="status in empStatuses">{{status}}</md-option> </md-optgroup> </md-select>
</td> </td>
</tr>
<tr>
<td colspan="4">
<b >Date of Joining</b></td>
<td colspan="8"> <md-datepicker ng-model="dateOfJoining" md-placeholder="Date of Joining"
md-min-date="minDate" md-max-date="maxDate"
onkeydown="return false"
></md-datepicker>
</td>
</tr>
<tr>
<td colspan="4">
<b >Date of Birth</b></td>
<td colspan="8"> <md-datepicker ng-model="dateOfBirth" md-placeholder="Date of Birth"
md-min-date="minDate" md-max-date="maxDate"
onkeydown="return false"
></md-datepicker>
</td>
</tr> </tr>
<tr> <tr>
<td colspan="12"> <td colspan="12">
...@@ -103,7 +121,10 @@ ...@@ -103,7 +121,10 @@
</tr> </tr>
</table> </table>
<!-- <!-- <md-datepicker ng-model="expiryDate" md-placeholder="Expiry date"
md-min-date="minDate" md-max-date="maxDate"
onkeydown="return false"
></md-datepicker>
<div class="row col-lg-12 col-xs-12"> <div class="row col-lg-12 col-xs-12">
<div class="col-lg-5 col-xs-6" > <div class="col-lg-5 col-xs-6" >
<p> <p>
......
<md-dialog aria-label="Role Template" style="width:520px;height:440px;" ng-init="getProjects()"> <md-dialog aria-label="Role Template" style="width:520px;height:800px;" ng-init="getProjects()">
<form ng-cloak name="myForm"> <form ng-cloak name="myForm">
<md-toolbar> <md-toolbar>
<div class="md-toolbar-tools" <div class="md-toolbar-tools"
...@@ -25,6 +25,17 @@ ...@@ -25,6 +25,17 @@
<output>Email Id : {{employeeModel.emailId}}</output> <output>Email Id : {{employeeModel.emailId}}</output>
<output>Role : {{employeeModel.role}}</output> <output>Role : {{employeeModel.role}}</output>
<output>Designation : {{employeeModel.designation}}</output> <output>Designation : {{employeeModel.designation}}</output>
<md-select ng-model="empBillableStatus" md-selected-text="getSelectedBillableStatus()" id="empBillableStatus">
<md-optgroup label="billable statuses"> <md-option ng-value="billableStatus"
ng-repeat="billableStatus in billableStatuses">{{billableStatus}}</md-option> </md-optgroup> </md-select>
<md-datepicker ng-model="startDate" md-placeholder="Start Date"
md-min-date="minDate" md-max-date="maxDate"
onkeydown="return false"
></md-datepicker></br>
<md-datepicker ng-model="endDate" md-placeholder="Projected End Date"
md-min-date="minDate" md-max-date="maxDate"
onkeydown="return false"
></md-datepicker>
<div role="alert"> <div role="alert">
<span class="error" style="color: red;">{{alertMsg}}</span> <span class="error" style="color: red;">{{alertMsg}}</span>
......
...@@ -230,6 +230,36 @@ ...@@ -230,6 +230,36 @@
</div> </div>
<div class="row col-lg-12 col-xs-12">
<div class="col-lg-5 col-xs-6">
<p>
<b>Date of Joining</b>
</p>
</div>
<div class="col-lg-7 col-xs-6">
<p>
<b>:</b> {{profile.dateOfJoining | date:'dd-MMM-yyyy'}}
</p>
</div>
</div>
<div class="row col-lg-12 col-xs-12">
<div class="col-lg-5 col-xs-6">
<p>
<b>Date of Birth</b>
</p>
</div>
<div class="col-lg-7 col-xs-6">
<p>
<b>:</b> {{profile.dateOfBirth | date:'dd-MMM-yyyy'}}
</p>
</div>
</div>
</div>
</div> </div>
<div class="col-lg-2" style="cursor: pointer; float: left;"> <div class="col-lg-2" style="cursor: pointer; float: left;">
<md-button class="md-raised md-primary" <md-button class="md-raised md-primary"
......
...@@ -58,7 +58,8 @@ public class ProjectControllerTest { ...@@ -58,7 +58,8 @@ public class ProjectControllerTest {
EmployeeRoles employeesRole = new EmployeeRoles( EmployeeRoles employeesRole = new EmployeeRoles(
"5976ef15874c902c98b8a05d", null, null, "user@nisum.com", null, "5976ef15874c902c98b8a05d", null, null, "user@nisum.com", null,
null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null,
null, null, new Date(2017 - 11 - 12), new Date(2017 - 12 - 12)); null, null, new Date(2017 - 11 - 12), new Date(2017 - 12 - 12),
null, null);
when(userService.getEmployeesRole("user@nisum.com")) when(userService.getEmployeesRole("user@nisum.com"))
.thenReturn(employeesRole); .thenReturn(employeesRole);
mockMvc.perform( mockMvc.perform(
...@@ -131,7 +132,8 @@ public class ProjectControllerTest { ...@@ -131,7 +132,8 @@ public class ProjectControllerTest {
EmployeeRoles employeesRole = new EmployeeRoles( EmployeeRoles employeesRole = new EmployeeRoles(
"5976ef15874c902c98b8a05d", "16127", null, null, null, null, "5976ef15874c902c98b8a05d", "16127", null, null, null, null,
null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null,
null, new Date(2017 - 11 - 18), new Date(2017 - 12 - 18)); null, new Date(2017 - 11 - 18), new Date(2017 - 12 - 18), null,
null);
when(userService.getEmployeesRoleData("16127")) when(userService.getEmployeesRoleData("16127"))
.thenReturn(employeesRole); .thenReturn(employeesRole);
mockMvc.perform( mockMvc.perform(
......
...@@ -27,7 +27,7 @@ import com.nisum.mytime.controller.ProjectTeamController; ...@@ -27,7 +27,7 @@ import com.nisum.mytime.controller.ProjectTeamController;
import com.nisum.mytime.model.EmployeeRoles; import com.nisum.mytime.model.EmployeeRoles;
import com.nisum.mytime.model.Project; import com.nisum.mytime.model.Project;
import com.nisum.mytime.model.ProjectTeamMate; import com.nisum.mytime.model.ProjectTeamMate;
import com.nisum.mytime.model.TeamMateBilling; import com.nisum.mytime.model.BillingDetails;
import com.nisum.mytime.service.ProjectService; import com.nisum.mytime.service.ProjectService;
import com.nisum.mytime.service.UserService; import com.nisum.mytime.service.UserService;
...@@ -56,7 +56,8 @@ public class ProjectTeamControllerTest { ...@@ -56,7 +56,8 @@ public class ProjectTeamControllerTest {
EmployeeRoles employeesRole = new EmployeeRoles( EmployeeRoles employeesRole = new EmployeeRoles(
"5976ef15874c902c98b8a05d", null, null, null, null, null, null, "5976ef15874c902c98b8a05d", null, null, null, null, null, null,
null, null, null, null, null, null, "user@nisum.com", null, null, null, null, null, null, null, "user@nisum.com", null,
null, null, new Date(2017 - 11 - 20), new Date(2107 - 12 - 23)); null, null, new Date(2017 - 11 - 20), new Date(2107 - 12 - 23),
null, null);
when(userService.getEmployeesRole("user@nisum.com")) when(userService.getEmployeesRole("user@nisum.com"))
.thenReturn(employeesRole); .thenReturn(employeesRole);
mockMvc.perform( mockMvc.perform(
...@@ -91,7 +92,7 @@ public class ProjectTeamControllerTest { ...@@ -91,7 +92,7 @@ public class ProjectTeamControllerTest {
"vsingh@nisum.com", "Manager", null, "09:00-06:00", "Java/J2EE", "vsingh@nisum.com", "Manager", null, "09:00-06:00", "Java/J2EE",
"Testing", "8755672341", "8800543678", "vsingh@gmail.com", null, "Testing", "8755672341", "8800543678", "vsingh@gmail.com", null,
null, null, null, null, new Date(2017 - 11 - 29), null, null, null, null, new Date(2017 - 11 - 29),
new Date(2017 - 12 - 20)); new Date(2017 - 12 - 20), null, null);
ObjectMapper mapper = new ObjectMapper(); ObjectMapper mapper = new ObjectMapper();
String jsonString = mapper.writeValueAsString(employeesRoles2); String jsonString = mapper.writeValueAsString(employeesRoles2);
when(userService.updateEmployeeRole(any())).thenReturn(employeesRoles2); when(userService.updateEmployeeRole(any())).thenReturn(employeesRoles2);
...@@ -115,7 +116,8 @@ public class ProjectTeamControllerTest { ...@@ -115,7 +116,8 @@ public class ProjectTeamControllerTest {
EmployeeRoles employeesRole = new EmployeeRoles( EmployeeRoles employeesRole = new EmployeeRoles(
"5976ef15874c902c98b8a05d", "16127", null, null, null, null, "5976ef15874c902c98b8a05d", "16127", null, null, null, null,
null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null,
null, new Date(2017 - 11 - 20), new Date(2107 - 12 - 23)); null, new Date(2017 - 11 - 20), new Date(2107 - 12 - 23), null,
null);
when(userService.getEmployeesRoleData("16127")) when(userService.getEmployeesRoleData("16127"))
.thenReturn(employeesRole); .thenReturn(employeesRole);
mockMvc.perform( mockMvc.perform(
...@@ -273,7 +275,7 @@ public class ProjectTeamControllerTest { ...@@ -273,7 +275,7 @@ public class ProjectTeamControllerTest {
@Test @Test
public void testgetEmployeeBillingDetails() throws Exception { public void testgetEmployeeBillingDetails() throws Exception {
List<TeamMateBilling> billings = CreateTeamMateBilling(); List<BillingDetails> billings = CreateTeamMateBilling();
System.out.println(billings); System.out.println(billings);
when(projectService.getEmployeeBillingDetails("16127", "101")) when(projectService.getEmployeeBillingDetails("16127", "101"))
.thenReturn(billings); .thenReturn(billings);
...@@ -283,10 +285,10 @@ public class ProjectTeamControllerTest { ...@@ -283,10 +285,10 @@ public class ProjectTeamControllerTest {
verify(projectService).getEmployeeBillingDetails("16127", "101"); verify(projectService).getEmployeeBillingDetails("16127", "101");
} }
private List<TeamMateBilling> CreateTeamMateBilling() { private List<BillingDetails> CreateTeamMateBilling() {
List<TeamMateBilling> data = new ArrayList<>(); List<BillingDetails> data = new ArrayList<>();
TeamMateBilling team1 = new TeamMateBilling(); BillingDetails team1 = new BillingDetails();
team1.setId(new ObjectId("5976ef15874c902c98b8a05d")); team1.setId(new ObjectId("5976ef15874c902c98b8a05d"));
team1.setEmployeeId("16127"); team1.setEmployeeId("16127");
team1.setEmployeeName("Employee1"); team1.setEmployeeName("Employee1");
...@@ -297,7 +299,7 @@ public class ProjectTeamControllerTest { ...@@ -297,7 +299,7 @@ public class ProjectTeamControllerTest {
team1.setActive(true); team1.setActive(true);
data.add(team1); data.add(team1);
TeamMateBilling team2 = new TeamMateBilling(); BillingDetails team2 = new BillingDetails();
team2.setId(new ObjectId("1976ef15874c902c98b8a05d")); team2.setId(new ObjectId("1976ef15874c902c98b8a05d"));
team2.setEmployeeId("16128"); team2.setEmployeeId("16128");
team2.setEmployeeName("Employee2"); team2.setEmployeeName("Employee2");
......
...@@ -55,7 +55,8 @@ public class UserControllerTest { ...@@ -55,7 +55,8 @@ public class UserControllerTest {
EmployeeRoles employeesRole = new EmployeeRoles( EmployeeRoles employeesRole = new EmployeeRoles(
"5976ef15874c902c98b8a05d", null, null, "user@nisum.com", null, "5976ef15874c902c98b8a05d", null, null, "user@nisum.com", null,
null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null,
null, null, new Date(2017 - 11 - 20), new Date(2017 - 12 - 23)); null, null, new Date(2017 - 11 - 20), new Date(2017 - 12 - 23),
null, null);
when(userService.getEmployeesRole("user@nisum.com")) when(userService.getEmployeesRole("user@nisum.com"))
.thenReturn(employeesRole); .thenReturn(employeesRole);
mockMvc.perform( mockMvc.perform(
...@@ -71,7 +72,7 @@ public class UserControllerTest { ...@@ -71,7 +72,7 @@ public class UserControllerTest {
"user1@nisum.com", "HR", "Human Resource Lead", "06:00-09:00", "user1@nisum.com", "HR", "Human Resource Lead", "06:00-09:00",
"Java/J2EE", "Spring", "8767893452", "5687234567", "Java/J2EE", "Spring", "8767893452", "5687234567",
"user1@gmail.com", null, null, null, null, null, "user1@gmail.com", null, null, null, null, null,
new Date(2017 - 11 - 20), new Date(2017 - 12 - 23)); new Date(2017 - 11 - 20), new Date(2017 - 12 - 23), null, null);
ObjectMapper mapper = new ObjectMapper(); ObjectMapper mapper = new ObjectMapper();
String jsonString = mapper.writeValueAsString(employeeRole); String jsonString = mapper.writeValueAsString(employeeRole);
when(userService.assigingEmployeeRole(anyObject())) when(userService.assigingEmployeeRole(anyObject()))
...@@ -90,7 +91,7 @@ public class UserControllerTest { ...@@ -90,7 +91,7 @@ public class UserControllerTest {
"user2@nisum.com", "Manager", "Senior Software Engineer", "user2@nisum.com", "Manager", "Senior Software Engineer",
"09:00am-06:00am", "php", "Hibernate", "9878678956", "09:00am-06:00am", "php", "Hibernate", "9878678956",
"9989782210", "user2@gmail.com", null, null, null, null, null, "9989782210", "user2@gmail.com", null, null, null, null, null,
new Date(2017 - 11 - 20), new Date(2017 - 12 - 23)); new Date(2017 - 11 - 20), new Date(2017 - 12 - 23), null, null);
ObjectMapper mapper = new ObjectMapper(); ObjectMapper mapper = new ObjectMapper();
String jsonString = mapper.writeValueAsString(employeeRole2); String jsonString = mapper.writeValueAsString(employeeRole2);
when(userService.updateEmployeeRole(anyObject())) when(userService.updateEmployeeRole(anyObject()))
...@@ -124,7 +125,8 @@ public class UserControllerTest { ...@@ -124,7 +125,8 @@ public class UserControllerTest {
EmployeeRoles employeesRole = new EmployeeRoles( EmployeeRoles employeesRole = new EmployeeRoles(
"5976ef15874c902c98b8a05d", "16127", null, null, null, null, "5976ef15874c902c98b8a05d", "16127", null, null, null, null,
null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null,
null, new Date(2017 - 11 - 13), new Date(2017 - 12 - 20)); null, new Date(2017 - 11 - 13), new Date(2017 - 12 - 20), null,
null);
when(userService.getEmployeesRoleData("16127")) when(userService.getEmployeesRoleData("16127"))
.thenReturn(employeesRole); .thenReturn(employeesRole);
mockMvc.perform(get("/user/getEmployeeRoleData").param("empId", "16127") mockMvc.perform(get("/user/getEmployeeRoleData").param("empId", "16127")
...@@ -140,7 +142,8 @@ public class UserControllerTest { ...@@ -140,7 +142,8 @@ public class UserControllerTest {
EmployeeRoles employeesRole = new EmployeeRoles( EmployeeRoles employeesRole = new EmployeeRoles(
"5976ef15874c902c98b8a05d", "16209", null, null, null, null, "5976ef15874c902c98b8a05d", "16209", null, null, null, null,
null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null,
null, new Date(2017 - 11 - 13), new Date(2017 - 12 - 20)); null, new Date(2017 - 11 - 13), new Date(2017 - 12 - 20), null,
null);
when(userService.getEmployeeRoleDataForSearchCriteria("dummy@nisum.com", when(userService.getEmployeeRoleDataForSearchCriteria("dummy@nisum.com",
"emailId")).thenReturn(employeesRole); "emailId")).thenReturn(employeesRole);
mockMvc.perform(get("/user/getEmployeeRoleDataForSearchCriteria") mockMvc.perform(get("/user/getEmployeeRoleDataForSearchCriteria")
...@@ -160,7 +163,8 @@ public class UserControllerTest { ...@@ -160,7 +163,8 @@ public class UserControllerTest {
EmployeeRoles employeesRole = new EmployeeRoles( EmployeeRoles employeesRole = new EmployeeRoles(
"5976ef15874c902c98b8a05d", "16209", null, null, null, null, "5976ef15874c902c98b8a05d", "16209", null, null, null, null,
null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null,
null, new Date(2017 - 11 - 13), new Date(2017 - 12 - 20)); null, new Date(2017 - 11 - 13), new Date(2017 - 12 - 20), null,
null);
when(userService.getEmployeeRoleDataForSearchCriteria( when(userService.getEmployeeRoleDataForSearchCriteria(
"Mahesh Kumar Gutam", "employeeName")) "Mahesh Kumar Gutam", "employeeName"))
.thenReturn(employeesRole); .thenReturn(employeesRole);
...@@ -247,7 +251,8 @@ public class UserControllerTest { ...@@ -247,7 +251,8 @@ public class UserControllerTest {
"msrivastava@nisum.com", "Employee", "Software Engineer", "msrivastava@nisum.com", "Employee", "Software Engineer",
"09:00-06:00", "Java/J2EE", "Spring", "8765588388", "09:00-06:00", "Java/J2EE", "Spring", "8765588388",
"9978567723", "msrivastava@gmail.com", null, null, null, null, "9978567723", "msrivastava@gmail.com", null, null, null, null,
null, new Date(2017 - 01 - 01), new Date(2017 - 03 - 01)); null, new Date(2017 - 01 - 01), new Date(2017 - 03 - 01), null,
null);
System.out.println(employeeRole); System.out.println(employeeRole);
ObjectMapper mapper = new ObjectMapper(); ObjectMapper mapper = new ObjectMapper();
String jsonString = mapper.writeValueAsString(employeeRole); String jsonString = mapper.writeValueAsString(employeeRole);
......
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