Commit c63bc59d authored by Vijay Akula's avatar Vijay Akula

Refactored the code for Project Resources and Billing with their

respective Controller Service and Repository layers
parent cf947c85
package com.nisum.mytime.controller;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.nisum.mytime.exception.handler.MyTimeException;
import com.nisum.mytime.model.Billing;
import com.nisum.mytime.service.IBillingService;
import lombok.extern.slf4j.Slf4j;
@RestController
@Slf4j
public class BillingController {
@Autowired
private IBillingService billingService;
// @RequestMapping(value = "/addEmployeeBilling"
@RequestMapping(value = "/billing", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Billing> addEmployeeBilling(@RequestBody Billing billing,
@RequestParam(value = "loginEmpId") String loginEmpId) throws MyTimeException {
Billing billingList = billingService.addBilling(billing, loginEmpId);
return new ResponseEntity<>(billingList, HttpStatus.OK);
}
// @RequestMapping(value = "/updateEmployeeBilling",
@RequestMapping(value = "/billing", method = RequestMethod.PUT, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Billing> updateEmployeeBilling(@RequestBody Billing billing,
@RequestParam(value = "loginEmpId") String loginEmpId) throws MyTimeException {
Billing billingList = billingService.updateBilling(billing, loginEmpId);
return new ResponseEntity<>(billingList, HttpStatus.OK);
}
// @RequestMapping(value = "/deleteEmployeeBilling"
@RequestMapping(value = "/billing", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Billing> deleteEmployeeBilling(@RequestBody Billing billing) throws MyTimeException {
billingService.deleteBilling(billing);
return new ResponseEntity<>(null, HttpStatus.OK);
}
// @RequestMapping(value = "/getEmployeeBillingDetailsAll"
@RequestMapping(value = "/billing", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<Billing>> getAllBillingsForEmployee(@RequestParam("employeeId") String employeeId)
throws MyTimeException {
List<Billing> billingList = billingService.getBillingsForEmployee(employeeId);
return new ResponseEntity<>(billingList, HttpStatus.OK);
}
// @RequestMapping(value = "/getEmployeeBillingDetails"
@RequestMapping(value = "/billing/project/{projectId}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<Billing>> getBillingsForProject(@PathVariable("projectId") String projectId,
@RequestParam("employeeId") String employeeId) throws MyTimeException {
List<Billing> billingList = billingService.getBillingsForProject(employeeId, projectId);
return new ResponseEntity<>(billingList, HttpStatus.OK);
}
}
package com.nisum.mytime.controller;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
......@@ -214,4 +215,18 @@ public class EmployeeController {
}
@RequestMapping(value = "/employees/active/sortByName", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<Employee>> getActiveEmployeesSortByName() throws MyTimeException {
List<Employee> employeesList = new ArrayList<>();
if (empService.getActiveEmployees() != null) {
employeesList = empService.getActiveEmployees().stream()
.sorted((o1, o2) -> o1.getEmployeeName().compareTo(o2.getEmployeeName()))
.collect(Collectors.toList());
}
return new ResponseEntity<>(employeesList, HttpStatus.OK);
}
}
\ No newline at end of file
......@@ -12,23 +12,23 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.nisum.mytime.exception.handler.MyTimeException;
import com.nisum.mytime.model.Account;
import com.nisum.mytime.model.Employee;
import com.nisum.mytime.model.Project;
import com.nisum.mytime.repository.AccountRepo;
import com.nisum.mytime.repository.ProjectRepo;
import com.nisum.mytime.service.IProjectService;
import com.nisum.mytime.service.IEmployeeService;
import com.nisum.mytime.service.IProjectService;
import com.nisum.mytime.utils.MyTimeUtils;
import lombok.extern.slf4j.Slf4j;
@RestController
@RequestMapping("/project")
@Slf4j
public class ProjectController {
@Autowired
private IEmployeeService userService;
private IEmployeeService employeeService;
@Autowired
private IProjectService projectService;
......@@ -39,51 +39,48 @@ public class ProjectController {
@Autowired
private ProjectRepo projectRepo;
@RequestMapping(value = "/employee", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Employee> getEmployeeRole(@RequestParam("emailId") String emailId)
throws MyTimeException {
Employee employeesRole = userService.getEmployeeByEmaillId(emailId);
return new ResponseEntity<>(employeesRole, HttpStatus.OK);
}
@RequestMapping(value = "/addProject", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<?> addProject(@RequestBody Project projectAdded,
@RequestMapping(value = "/projects", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<?> createProject(@RequestBody Project projectReq,
@RequestParam(value = "loginEmpId") String loginEmpId) throws MyTimeException {
// checking project duplicateName
int projectNameCount=0;
if (projectAdded.getAccountId() != null) {
List<Project> projects = projectRepo.findByDomainId(projectAdded.getDomainId());
int projectNameCount = 0;
if (projectReq.getAccountId() != null) {
List<Project> projects=projectService.getProjectsUnderDomain(projectReq.getDomainId());
for (Project existproject : projects) {
if (projectAdded.getProjectName().equalsIgnoreCase(existproject.getProjectName()))
if (projectReq.getProjectName().equalsIgnoreCase(existproject.getProjectName()))
projectNameCount++;
}
}
if (projectNameCount > MyTimeUtils.INT_ZERO){
MyTimeException myTimeException= new MyTimeException("Project name already exist !!! try with new");
if (projectNameCount > MyTimeUtils.INT_ZERO) {
MyTimeException myTimeException = new MyTimeException("Project name already exist !!! try with new");
return new ResponseEntity<>(myTimeException, HttpStatus.OK);
}else{
String accountName="";
String accountId=projectAdded.getAccountId();
} else {
String accountName = "";
String accountId = projectReq.getAccountId();
// String accountName=projectAdded.getAccount();
Account account= accountRepo.findByAccountId(accountId);
if(account!=null)
accountName=account.getAccountName();
int sequenceNumber= account.getAccountProjectSequence();
account.setAccountProjectSequence(sequenceNumber+1);
//account.setAuditFields(loginEmpId, MyTimeUtils.UPDATE);
Account account = accountRepo.findByAccountId(accountId);
if (account != null)
accountName = account.getAccountName();
int sequenceNumber = account.getAccountProjectSequence();
account.setAccountProjectSequence(sequenceNumber + 1);
// account.setAuditFields(loginEmpId, MyTimeUtils.UPDATE);
accountRepo.save(account);
String projectId= accountName+String.format("%04d", sequenceNumber+1);
projectAdded.setProjectId(projectId);
Project project = projectService.addProject(projectAdded, loginEmpId);
String projectId = accountName + String.format("%04d", sequenceNumber + 1);
projectReq.setProjectId(projectId);
Project project = projectService.createProject(projectReq, loginEmpId);
return new ResponseEntity<>(project, HttpStatus.OK);
}
}
@RequestMapping(value = "/updateProject", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
// @RequestMapping(value = "/updateProject"
@RequestMapping(value = "/projects", method = RequestMethod.PUT, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<?> updateProject(@RequestBody Project project,
@RequestParam(value = "loginEmpId") String loginEmpId) throws MyTimeException {
// checking project duplicateName
int projectNameCount=0;
int projectNameCount = 0;
if (project.getAccountId() != null) {
List<Project> projects = projectRepo.findByDomainId(project.getDomainId());
for (Project existproject : projects) {
......@@ -93,41 +90,57 @@ public class ProjectController {
}
}
}
if (projectNameCount>0)
{
MyTimeException myTimeException= new MyTimeException("Project name already exist !!! try with new");
if (projectNameCount > 0) {
MyTimeException myTimeException = new MyTimeException("Project name already exist !!! try with new");
return new ResponseEntity<>(myTimeException, HttpStatus.OK);
}
Project updatedProject = projectService.updateProject(project, loginEmpId);
return new ResponseEntity<>(updatedProject, HttpStatus.OK);
}
@RequestMapping(value = "/deleteProject", method = RequestMethod.DELETE, produces = MediaType.TEXT_PLAIN_VALUE)
// @RequestMapping(value = "/deleteProject"
@RequestMapping(value = "/deleteProject", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<String> deleteProject(@RequestParam("projectId") String projectId) throws MyTimeException {
projectService.deleteProject(projectId);
return new ResponseEntity<>("Success", HttpStatus.OK);
}
@RequestMapping(value = "/getProjects", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<HashMap<Object, Object>>> getProjects(@RequestParam(value="empId", required = false, defaultValue = MyTimeUtils.ZERO) String empId) throws MyTimeException {
// @RequestMapping(value = "/getProjects"
@RequestMapping(value = "/projects", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<HashMap<Object, Object>>> getProjects(
@RequestParam(value = "empId", required = false, defaultValue = MyTimeUtils.ZERO) String empId)
throws MyTimeException {
List<HashMap<Object, Object>> projects = null;
if(!"undefined".equalsIgnoreCase(empId) ) {
boolean isDl = userService.verifyEmployeeRole(empId,MyTimeUtils.DL) ;
if( isDl ){
if (!"undefined".equalsIgnoreCase(empId)) {
boolean isDl = employeeService.verifyEmployeeRole(empId, MyTimeUtils.DL);
if (isDl) {
projects = projectService.deliveryLeadProjects(empId);
}
}else {
} else {
projects = projectService.getProjects();
}
return new ResponseEntity<>(projects, HttpStatus.OK);
}
@RequestMapping(value = "/getEmployeeRoleData", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Employee> getEmployeeRoleData(@RequestParam("empId") String empId)
@RequestMapping(value = "/projects/{deliveryLeadId}", method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<Project>> getProjectsUnderDeliveryLead(
@RequestParam("deliveryLeadId") String deliveryLeadId)
throws MyTimeException {
Employee employeesRole = userService.getEmployeeById(empId);
return new ResponseEntity<>(employeesRole, HttpStatus.OK);
List<Project> projects = projectService.getProjectsUnderDeliveryLead(deliveryLeadId);
return new ResponseEntity<>(projects, HttpStatus.OK);
}
@RequestMapping(value = "/getMyProjectAllocations", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<HashMap<Object, Object>>> getMyProjectAllocations(
@RequestParam("employeeId") String employeeId) throws MyTimeException {
List<HashMap<Object, Object>> empPrjtsInfo = projectService.getProjectsForEmployee(employeeId);
return new ResponseEntity<>(empPrjtsInfo, HttpStatus.OK);
}
}
\ No newline at end of file
......@@ -42,26 +42,24 @@ import com.nisum.mytime.model.ReportSeriesRecord;
import com.nisum.mytime.repository.EmployeeVisaRepo;
import com.nisum.mytime.repository.BillingRepo;
import com.nisum.mytime.service.IProjectService;
import com.nisum.mytime.service.IResourceService;
import com.nisum.mytime.service.IEmployeeService;
@RestController
@RequestMapping("/reports")
public class ReportsController {
@Autowired
private IEmployeeService userService;
@Autowired
private IProjectService projectService;
@Autowired
private EmployeeVisaRepo employeeVisaRepo;
private MongoTemplate mongoTemplate;
@Autowired
private MongoTemplate mongoTemplate;
private IResourceService resourceService;
@Autowired
private BillingRepo teamMatesBillingRepo;
private IEmployeeService employeeService;
@RequestMapping(value = "/getEmployeesByFunctionalGroup1",
method = RequestMethod.GET,
......@@ -148,7 +146,7 @@ public class ReportsController {
statusList.add("Non-Billable");
List<String> catagories = new ArrayList();
List<ReportSeriesRecord> seriesDetails = new ArrayList<ReportSeriesRecord>();
List<Account> accounts = userService.getAccounts();
List<Account> accounts = employeeService.getAccounts();
ColumnChartData reportData = new ColumnChartData();
for (String status : statusList) {
catagories = new ArrayList();
......@@ -319,7 +317,7 @@ public class ReportsController {
public ResponseEntity<List<Employee>> getEmployeesByFG(
@RequestParam("fGroup") String fGroup) throws MyTimeException {
List<Employee> empList = new ArrayList<>();
empList = userService.getEmployeesByFunctionalGrp(fGroup);
empList = employeeService.getEmployeesByFunctionalGrp(fGroup);
return new ResponseEntity<>(empList, HttpStatus.OK);
}
......@@ -333,7 +331,7 @@ public class ReportsController {
throws MyTimeException {
List<Resource> empList = new ArrayList<>();
if (account != null && !account.isEmpty()) {
empList = projectService.findByAccountAndActiveAndBillableStatus(
empList = resourceService.findByAccountAndActiveAndBillableStatus(
account, true, billabilityStatus);
}
return new ResponseEntity<>(empList, HttpStatus.OK);
......
package com.nisum.mytime.controller;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.stream.Collectors;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.nisum.mytime.exception.handler.MyTimeException;
import com.nisum.mytime.model.Employee;
import com.nisum.mytime.model.EmployeeDashboardVO;
import com.nisum.mytime.model.EmployeeVisa;
import com.nisum.mytime.model.Resource;
import com.nisum.mytime.repository.EmployeeVisaRepo;
import com.nisum.mytime.service.IEmployeeService;
import com.nisum.mytime.service.IProjectService;
import com.nisum.mytime.service.IResourceService;
import com.nisum.mytime.utils.MyTimeUtils;
@RestController
@RequestMapping("/projectTeam")
public class ResourceController {
@Autowired
private IEmployeeService employeeService;
@Autowired
private IProjectService projectService;
@Autowired
private EmployeeVisaRepo employeeVisaRepo;
@Autowired
private IResourceService resourceService;
// @RequestMapping(value = "/addEmployeeToTeam"
@RequestMapping(value = "/resources", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Resource> addResourceToTeam(@RequestBody Resource resource,
@RequestParam(value = "loginEmpId", required = false) String loginEmpId) throws MyTimeException {
resource.setActive(true);
resource.setAuditFields(loginEmpId, MyTimeUtils.CREATE);
Resource resourcePersisted = resourceService.addResource(resource, loginEmpId);
return new ResponseEntity<>(resourcePersisted, HttpStatus.OK);
}
// @RequestMapping(value = "/updateTeammate"
@RequestMapping(value = "/resources", method = RequestMethod.PUT, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<String> updateResource(@RequestBody Resource resource,
@RequestParam(value = "loginEmpId") String loginEmpId) throws MyTimeException {
resource.setAuditFields(loginEmpId, MyTimeUtils.UPDATE);
String response = resourceService.updateResource(resource, loginEmpId);
return new ResponseEntity<>(response, HttpStatus.OK);
}
// @RequestMapping(value = "/deleteTeammate"
@RequestMapping(value = "/resources", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<String> deleteResource(@RequestBody Resource resource,
@RequestParam(value = "loginEmpId") String loginEmpId) throws MyTimeException {
resourceService.deleteResource(resource.getEmployeeId(), resource.getProjectId(), resource.getId(), loginEmpId);
return new ResponseEntity<>("Success", HttpStatus.OK);
}
// @RequestMapping(value = "/getEmployeeProjectInfo"
@RequestMapping(value = "/resources", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<Resource>> getResourcesSortByStartDate(@RequestParam("empId") String empId)
throws MyTimeException {
List<Resource> projectInfo = resourceService.getResourcesSortByStartDate(empId);
return new ResponseEntity<>(projectInfo, HttpStatus.OK);
}
//@RequestMapping(value = "/getMyTeamDetails"
@RequestMapping(value = "/resources/active", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<Resource>> getActiveResources(@RequestParam("employeeId") String employeeId)
throws MyTimeException {
List<Resource> employeesRoles = resourceService.getActiveResources(employeeId);
return new ResponseEntity<>(employeesRoles, HttpStatus.OK);
}
// @RequestMapping(value = "/getShiftDetails"
@RequestMapping(value = "/resources/{shift}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<Resource>> getResourcesForShift(@PathVariable("shift") String shift)
throws MyTimeException {
List<Resource> resourcesList = resourceService.getResourcesForShift(shift);
return new ResponseEntity<>(resourcesList, HttpStatus.OK);
}
// @RequestMapping(value = "/getProjectAllocations"
@RequestMapping(value = "/resources/projects/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<Resource>> getResourcesAllocatedForAllProjects() throws MyTimeException {
List<Resource> resourcesList = resourceService.getResourcesForActiveProjects();
return new ResponseEntity<>(resourcesList, HttpStatus.OK);
}
// @RequestMapping(value = "/getProjectDetails"
@RequestMapping(value = "/resources/project/{projectId}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<Resource>> getResourcesForProject(@PathVariable("projectId") String projectId,
@RequestParam(value = "status", required = false, defaultValue = MyTimeUtils.ACTIVE) String status)
throws MyTimeException {
List<Resource> resourcesList = resourceService.getResourcesForProject(projectId, status);
return new ResponseEntity<>(resourcesList, HttpStatus.OK);
}
//@RequestMapping(value = "/getTeamDetails"
@RequestMapping(value = "/resources/deliverylead/{deliveryLeadId}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<Resource>> getTeamDetails(@PathVariable("deliveryLeadId") String deliveryLeadId)
throws MyTimeException {
List<Resource> resourcesList = resourceService.getResourcesUnderDeliveryLead(deliveryLeadId);
return new ResponseEntity<>(resourcesList, HttpStatus.OK);
}
@RequestMapping(value = "/getUnAssignedEmployees", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<Employee>> getUnAssignedEmployees() throws MyTimeException {
List<Employee> employeesList = projectService.getUnAssignedEmployees();
return new ResponseEntity<>(employeesList, HttpStatus.OK);
}
@RequestMapping(value = "/getEmployeesDashBoard", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<EmployeeDashboardVO>> getEmployeesDashBoard() throws MyTimeException {
List<EmployeeDashboardVO> employeeDashBoardList = projectService.getEmployeesDashBoard();
return new ResponseEntity<>(employeeDashBoardList, HttpStatus.OK);
}
@RequestMapping(value = "/getEmployeesHavingVisa", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<Employee>> getEmployeesHavingVisa(@RequestParam("visa") String passport)
throws MyTimeException {
List<Employee> employees = new ArrayList<>();
if (passport != null && !"passport".equalsIgnoreCase(passport)) {
List<EmployeeVisa> employeeVisas = employeeVisaRepo.findByVisaName(passport);
List<String> employeeIds = null;
if (employeeVisas != null) {
employeeIds = employeeVisas.stream().map(EmployeeVisa::getEmployeeId).collect(Collectors.toList());
}
if (employeeIds != null && !employeeIds.isEmpty()) {
List<Employee> emps = employeeService.getActiveEmployees();
for (Employee emp : emps) {
if (employeeIds.contains(emp.getEmployeeId())) {
employees.add(emp);
}
}
}
return new ResponseEntity<>(employees, HttpStatus.OK);
} else {
// List<EmployeeRoles> employees = new ArrayList<>();
if (employeeService.getActiveEmployees() != null) {
employees = employeeService.getActiveEmployees().stream()
.sorted((o1, o2) -> o1.getEmployeeName().compareTo(o2.getEmployeeName()))
.collect(Collectors.toList());
}
return new ResponseEntity<>(employees, HttpStatus.OK);
}
}
@RequestMapping(value = "/addEmployeeToTeamWithCheck", method = RequestMethod.POST, produces = MediaType.TEXT_PLAIN_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<String> addEmployeeToTeamWithCheck(@RequestBody Resource resource,
@RequestParam(value = "loginEmpId") String loginEmpId) throws MyTimeException {
String response = projectService.addProjectTeamMateWithCheck(resource, loginEmpId);
return new ResponseEntity<>(response, HttpStatus.OK);
}
}
// @RequestMapping(value = "/employee", method = RequestMethod.GET,
// public ResponseEntity<Employee> getEmployee(
// @RequestMapping(value = "/updateEmployeeRole", method =
// public ResponseEntity<Employee> updateEmployeeRole(@RequestBody Employee
// @RequestMapping(value = "/deleteEmployee"
// public ResponseEntity<String> deleteEmployee
// @RequestMapping(value = "/getEmployeeRoleData",
// public ResponseEntity<Employee> getEmployeeRoleData(
// @RequestMapping(value = "/addProject"
// public ResponseEntity<Project> addProject(
// @RequestMapping(value = "/getEmployeesToTeam"
// public ResponseEntity<List<Employee>> getActiveEmployeesSortByName() throws
// MyTimeException {
......@@ -43,7 +43,7 @@ public class Billing extends AuditFields implements Serializable {
private Date billingEndDate;
private String comments;
private boolean active;
//@DateTimeFormat(pattern = "dd-MM-yyyy")
// @DateTimeFormat(pattern = "dd-MM-yyyy")
// private Date createDate;
}
......@@ -15,7 +15,7 @@ import lombok.ToString;
@NoArgsConstructor
@ToString
@Document(collection = "employeeShifts")
public class EmpShiftDetails extends AuditFields {
public class EmployeeShift extends AuditFields {
@Id
private String id;
......
......@@ -2,8 +2,8 @@ package com.nisum.mytime.repository;
import org.springframework.data.mongodb.repository.MongoRepository;
import com.nisum.mytime.model.EmpShiftDetails;
import com.nisum.mytime.model.EmployeeShift;
public interface EmpShiftDetailsRepo extends MongoRepository<EmpShiftDetails, String> {
public interface EmployeeShiftRepo extends MongoRepository<EmployeeShift, String> {
}
\ No newline at end of file
......@@ -10,8 +10,18 @@ import com.nisum.mytime.model.Employee;
@Service
public interface IBillingService {
public Billing addBillingtoResource(Billing billing, Employee employee, String loginEmpId);
Billing addBilling(Billing billingDetails, String loginEmpId);
public List<Billing> getEmployeeActiveBillingDetails(String empId, String projectId);
Billing updateBilling(Billing billingDetails, String loginEmpId);
void deleteBilling(Billing teamMate);
Billing addBillingtoResource(Billing billing, Employee employee, String loginEmpId);
List<Billing> getBillingsForEmployee(String empId);
List<Billing> getActiveBillings(String empId, String projectId);
List<Billing> getBillingsForProject(String empId, String projectId);
}
......@@ -45,4 +45,8 @@ public interface IEmployeeService {
List<Employee> getEmployeesFromList(Set<String> empIdsSet);
List<HashMap<String, String>> getDeliveryManagerMap(List deliveryManagerIdsList);
public List<Employee> getAllEmployees();
}
......@@ -7,6 +7,8 @@ import com.nisum.mytime.model.Resource;
@Service
public interface IEmployeeShiftService {
void updateShiftDetails(Resource existingTeammate, String loginEmpId);
public void addEmployeeShift(Resource resource, String loginEmpId);
void updateEmployeeShift(Resource existingTeammate, String loginEmpId);
}
......@@ -4,96 +4,46 @@ import java.util.HashMap;
import java.util.List;
import java.util.Set;
import org.bson.types.ObjectId;
import com.nisum.mytime.exception.handler.MyTimeException;
import com.nisum.mytime.model.Billing;
import com.nisum.mytime.model.EmpLoginData;
import com.nisum.mytime.model.EmployeeDashboardVO;
import com.nisum.mytime.model.Employee;
import com.nisum.mytime.model.EmployeeDashboardVO;
import com.nisum.mytime.model.Project;
import com.nisum.mytime.model.Resource;
public interface IProjectService {
Project createProject(Project project, String loginEmpId) throws MyTimeException;
public Resource addNewBeanchAllocation(Employee employee,String loginEmpId);
List<EmpLoginData> employeeLoginsBasedOnDate(long id, String fromDate,
String toDate) throws MyTimeException;
List<HashMap<Object, Object>> getProjects() throws MyTimeException;
Project addProject(Project project, String loginEmpId) throws MyTimeException;
String generatePdfReport(long id, String fromDate, String toDate)
throws MyTimeException;
Employee getEmployeesRole(String emailId);
Project updateProject(Project project, String loginEmpId) throws MyTimeException;
void deleteProject(String projectId);
Project updateProject(Project project, String loginEmpId)throws MyTimeException;
Employee getEmployeesRoleData(String empId);
List<Resource> getTeamDetails(String empId);
List<Project> getProjectsUnderDomain(String domainId);
//MT-72
List<Resource> getProjectInfo(String empId);
List<HashMap<Object, Object>> getProjects() throws MyTimeException;
public Resource addProjectTeamMate(Resource projectTeamMate, String loginEmpId)
throws MyTimeException;
List<Project> getProjectsUnderDeliveryLead(String managerId) throws MyTimeException;
String updateTeammate(Resource projectTeamMate, String loginEmpId) throws MyTimeException;
public Resource addNewBeanchAllocation(Employee employee, String loginEmpId);
void deleteTeammate(String empId, String projectId, ObjectId id, String loginEmpId);
List<EmpLoginData> employeeLoginsBasedOnDate(long id, String fromDate, String toDate) throws MyTimeException;
List<Project> getProjects(String managerId) throws MyTimeException;
String generatePdfReport(long id, String fromDate, String toDate) throws MyTimeException;
List<Resource> getMyTeamDetails(String empId);
List<Resource> getResourcesUnderProject(String empId);
List<Employee> getUnAssignedEmployees();
List<Resource> getShiftDetails(String shift);
List<Resource> getAllProjectDetails();
List<Resource> getProjectDetails(String projectId,String status);
public List<Resource> getMyProjectAllocations(String empId);
List<Billing> getEmployeeBillingDetails(String empId,
String projectId);
Billing addEmployeeBillingDetails(Billing billingDetails, String loginEmpId);
Billing updateEmployeeBilling(Billing billingDetails, String loginEmpId);
void deleteEmployeeBilling(Billing teamMate);
public List<EmployeeDashboardVO> getEmployeesDashBoard();
List<Billing> getEmployeeActiveBillingDetails(String empId,
String projectId);
List<Billing> getEmployeeActiveNisumBench(String empId);
public String addProjectTeamMateWithCheck(Resource projectTeamMate, String loginEmpId) throws MyTimeException;
List<Billing> getEmployeeBillingDetailsAll(String empId);
public void updateShiftDetails(Resource existingTeammate, String loginEmpId);
public void addShiftDetails(Resource projectTeamMate, String loginEmpId);
List<Resource> findByAccountAndActiveAndBillableStatus(
String account, boolean status, String billableStatus);
public String addProjectTeamMateWithCheck(Resource projectTeamMate, String loginEmpId)
throws MyTimeException;
public List<HashMap<Object, Object>> projectsInfoByEmpId(String empId);
public List<HashMap<Object, Object>> getProjectsForEmployee(String empId);
public Set<String> accountsAssignedToDl(String empId);
public List<HashMap<Object, Object>> deliveryLeadProjects(String empId) throws MyTimeException;
public List<Project> getAllProjects();
}
......@@ -2,20 +2,45 @@ package com.nisum.mytime.service;
import java.util.List;
import org.bson.types.ObjectId;
import org.springframework.stereotype.Service;
import com.nisum.mytime.model.Billing;
import com.nisum.mytime.model.Employee;
import com.nisum.mytime.model.Resource;
import com.nisum.mytime.exception.handler.MyTimeException;
@Service
public interface IResourceService {
public Resource save(Resource resource);
Resource addResource(Resource projectTeamMate, String loginEmpId) throws MyTimeException;
String updateResource(Resource projectTeamMate, String loginEmpId) throws MyTimeException;
void deleteResource(String empId, String projectId, ObjectId id, String loginEmpId);
Resource save(Resource resource);
void addResources(Employee employee, String loginEmpId);
void inactivateResource(Employee employeeReq, Employee employeeUpdated, String loginEmpId);
public List<Resource> getResources(String empId);
List<Resource> findByAccountAndActiveAndBillableStatus(String account, boolean status, String billableStatus);
List<Resource> getResourcesSortByStartDate(String employeeId);
List<Resource> getResourcesForProject(String projectId, String status);
List<Resource> getResourcesForEmployee(String empId);
List<Resource> getResourcesForProject(String projectId);
List<Resource> getActiveResources(String empId);
List<Resource> getResourcesForActiveProjects();
List<Resource> getResourcesForShift(String shift);
public List<Resource> getResourcesUnderDeliveryLead(String empId);
}
......@@ -3,6 +3,7 @@ package com.nisum.mytime.service.impl;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
......@@ -16,7 +17,6 @@ import com.nisum.mytime.utils.MyTimeUtils;
import lombok.extern.slf4j.Slf4j;
@Service
@Slf4j
public class BillingService implements IBillingService {
......@@ -28,21 +28,62 @@ public class BillingService implements IBillingService {
private MongoTemplate mongoTemplate;
@Override
public List<Billing> getEmployeeActiveBillingDetails(String empId, String projectId) {
Query query4 = new Query();
query4.addCriteria(Criteria.where("active").is(new Boolean(true)));
query4.addCriteria(Criteria.where("employeeId").is(empId));
query4.addCriteria(Criteria.where("projectId").is(projectId));
List<Billing> billings = mongoTemplate.find(query4, Billing.class);
List<Billing> billingsSorted = billings;
try {
billingsSorted = (billings == null || billings.size() == 0) ? billings
: billings.stream().sorted(Comparator.comparing(Billing::getBillingStartDate).reversed())
public Billing addBilling(Billing billing, String loginEmpId) {
billing.setAuditFields(loginEmpId, MyTimeUtils.CREATE);
return billingRepo.save(billing);
}
@Override
public Billing updateBilling(Billing billing, String loginEmpId) {
billing.setAuditFields(loginEmpId, MyTimeUtils.UPDATE);
return billingRepo.save(billing);
}
@Override
public void deleteBilling(Billing billing) {
billingRepo.delete(billing);
}
@Override
public List<Billing> getBillingsForProject(String empId, String projectId) {
List<Billing> billingsList = billingRepo.findByEmployeeIdAndProjectId(empId, projectId);
if (billingsList == null || billingsList.size() == 0) {
return billingsList;
} else {
return billingsList.stream().sorted(Comparator.comparing(Billing::getCreatedOn).reversed())
.collect(Collectors.toList());
}
}
@Override
public List<Billing> getBillingsForEmployee(String empId) {
List<Billing> billingsList = billingRepo.findByEmployeeId(empId);
if (billingsList == null || billingsList.size() == 0) {
return billingsList;
} else {
return billingsList.stream().sorted(Comparator.comparing(Billing::getCreatedOn).reversed())
.collect(Collectors.toList());
} catch (Exception e) {
e.printStackTrace();
}
return billingsSorted;
}
@Override
public List<Billing> getActiveBillings(String empId, String projectId) {
Query query = new Query();
query.addCriteria(Criteria.where("active").is(new Boolean(true)));
query.addCriteria(Criteria.where("employeeId").is(empId));
query.addCriteria(Criteria.where("projectId").is(projectId));
List<Billing> billingList = mongoTemplate.find(query, Billing.class);
if (billingList == null || billingList.size() == 0) {
return billingList;
} else {
return billingList.stream().sorted(Comparator.comparing(Billing::getBillingStartDate).reversed())
.collect(Collectors.toList());
}
}
public Billing addBillingtoResource(Billing billing, Employee employee, String loginEmpId) {
......@@ -51,7 +92,6 @@ public class BillingService implements IBillingService {
billing.setActive(false);
billing.setAuditFields(loginEmpId, MyTimeUtils.UPDATE);
return billingRepo.save(billing);
}
}
......@@ -169,7 +169,7 @@ public class EmployeeService implements IEmployeeService {
Employee employeePersisted = employeeRepo.save(existingEmployee);
if (mobileNumberChanged) {
try {
List<Resource> resourcesList = resourceService.getResources(employeeReq.getEmployeeId());
List<Resource> resourcesList = resourceService.getResourcesForEmployee(employeeReq.getEmployeeId());
if (resourcesList != null && !resourcesList.isEmpty()) {
for (Resource resource : resourcesList) {
......@@ -267,23 +267,26 @@ public class EmployeeService implements IEmployeeService {
@Override
public List<HashMap<String, String>> getDeliveryLeads(String domainId) {
Domain domain = domainService.getDomainById(domainId);
return getEmployeeData(domain.getDeliveryManagers());
return getDeliveryManagerMap(domain.getDeliveryManagers());
}
public List<HashMap<String, String>> getEmployeeData(List dmIdList) {
List<HashMap<String, String>> EmployeeList = new ArrayList<>();
Query query = new Query(Criteria.where("employeeId").in(dmIdList));
List<Employee> employeeList = mongoTemplate.find(query, Employee.class);
for (Employee employee : employeeList) {
@Override
public List<HashMap<String, String>> getDeliveryManagerMap(List deliveryManagerIdsList) {
List<HashMap<String, String>> employeeList = new ArrayList<>();
Query query = new Query(Criteria.where("employeeId").in(deliveryManagerIdsList));
List<Employee> employeePersistedList = mongoTemplate.find(query,Employee.class);
for (Employee employee : employeePersistedList) {
HashMap<String, String> managerMap = new HashMap<>();
managerMap.put("employeeId", employee.getEmployeeId());
managerMap.put("employeeName", employee.getEmployeeName());
EmployeeList.add(managerMap);
employeeList.add(managerMap);
}
return EmployeeList;
return employeeList;
}
@Override
public List<Employee> getEmployeesByFunctionalGrp(String functionalGrp) {
return employeeRepo.findByEmpStatusAndFunctionalGroup("Active", functionalGrp);
......@@ -311,4 +314,11 @@ public class EmployeeService implements IEmployeeService {
}
@Override
public List<Employee> getAllEmployees() {
return employeeRepo.findAll();
}
}
package com.nisum.mytime.service.impl;
import java.util.Calendar;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Service;
import com.nisum.mytime.model.EmpShiftDetails;
import com.nisum.mytime.model.EmployeeShift;
import com.nisum.mytime.model.Resource;
import com.nisum.mytime.repository.EmployeeShiftRepo;
import com.nisum.mytime.service.IEmployeeShiftService;
import com.nisum.mytime.utils.MyTimeUtils;
import lombok.extern.slf4j.Slf4j;
@Service
@Slf4j
public class EmployeeShiftService implements IEmployeeShiftService{
public class EmployeeShiftService implements IEmployeeShiftService {
@Autowired
private EmployeeShiftRepo empShiftsRepo;
@Autowired
private MongoTemplate mongoTemplate;
public void updateShiftDetails(Resource existingTeammate, String loginEmpId) {
@Override
public void addEmployeeShift(Resource resource, String loginEmpId) {
EmployeeShift empShift = new EmployeeShift();
empShift.setEmployeeName(resource.getEmployeeName());
empShift.setEmployeeId(resource.getEmployeeId());
empShift.setShift(resource.getShift());
empShift.setActive(resource.isActive());
empShift.setAuditFields(loginEmpId, MyTimeUtils.CREATE);
empShiftsRepo.save(empShift);
log.info("The Employee Shift has been Persisted ::" + empShift);
}
public void updateEmployeeShift(Resource resource, String loginEmpId) {
Query getQuery = new Query();
getQuery.addCriteria(new Criteria().andOperator(Criteria.where("active").is(true),
Criteria.where("employeeId").is(existingTeammate.getEmployeeId())));
Calendar cal = Calendar.getInstance();
cal.add(Calendar.DATE, -1);
EmpShiftDetails existingShift = mongoTemplate.findOne(getQuery, EmpShiftDetails.class);
if (existingShift != null) {
existingShift.setActive(false);
// existingShift.setUpdatedDate(new Date());// Commented as added
// common audit fields
existingShift.setAuditFields(loginEmpId, MyTimeUtils.UPDATE);
mongoTemplate.save(existingShift);
Criteria.where("employeeId").is(resource.getEmployeeId())));
EmployeeShift existingEmpShift = mongoTemplate.findOne(getQuery, EmployeeShift.class);
if (existingEmpShift != null) {
existingEmpShift.setActive(false);
existingEmpShift.setAuditFields(loginEmpId, MyTimeUtils.UPDATE);
mongoTemplate.save(existingEmpShift);
log.info("The shift has been updated::" + existingEmpShift);
}
}
}
......@@ -25,4 +25,8 @@ public class ShiftService implements IShiftService {
log.info("The shift list details::" + shiftsList);
return shiftsList;
}
}
server.port=8080
server.context-path=/myTeam/
#Mongo DB configuration
spring.data.mongodb.host=10.3.45.11
spring.data.mongodb.port=27017
spring.data.mongodb.database=mytimedb
spring.data.mongodb.username=mytime
spring.data.mongodb.password=nisum@123
#Local configuration
#spring.data.mongodb.host=localhost
#spring.data.mongodb.port=27017
#spring.data.mongodb.database=mytime
spring.data.mongodb.host=localhost
spring.data.mongodb.port=27017
spring.data.mongodb.database=mytime
quartz.enabled=true
cron.expression=0 45 10/3 1/1 * ? *
......@@ -38,9 +31,7 @@ spring.mail.properties.mail.smtp.starttls.required=true
spring.mvc.favicon.enabled = false
#MS SQL configuration
myTime.data.mssqldb.driver=com.microsoft.sqlserver.jdbc.SQLServerDriver
#myTime.data.mssqldb.url=jdbc:sqlserver://10.3.45.105:1433;databaseName=smartiSCC
myTime.data.mssqldb.url=jdbc:sqlserver://10.3.45.218:1433;databaseName=smartiSCC
myTime.data.mssqldb.username=sa
#myTime.data.mssqldb.password=nisum@123
myTime.data.mssqldb.password=admin@123
\ No newline at end of file
myTime.data.mssqldb.driver=
myTime.data.mssqldb.url=
myTime.data.mssqldb.username=
myTime.data.mssqldb.password=
\ No newline at end of file
......@@ -53,7 +53,7 @@
<script src="js/app.js"></script>
<script src="js/date-text-filter.js"></script>
<script src="js/ui-grid-edit-datepicker.js"></script>
<script src="controllers/assignAccountsController.js"></script>
<script src="controllers/AccountsController.js"></script>
<script src="controllers/LoginController.js"></script>
<script src="controllers/HeaderController.js"></script>
<script src="controllers/LeftMenuController.js"></script>
......@@ -63,7 +63,7 @@
<script src="controllers/ReportsController.js"></script>
<script src="controllers/AssignRolesController.js"></script>
<script src="controllers/ProjectController.js"></script>
<script src="controllers/ProjectTeamController.js"></script>
<script src="controllers/ResourceController.js"></script>
<script src="controllers/ProjectMyTeamController.js"></script>
<script src="controllers/AttendanceReportController.js"></script>
<script src="controllers/ShiftDetailsController.js"></script>
......
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