Commit 099feaf1 authored by vikram singh's avatar vikram singh

"UIReport Service implemented"

parent 6574f8fd
package com.nisum.myteam.controller; package com.nisum.myteam.controller;
import com.nisum.myteam.exception.handler.MyTeamException; import static org.springframework.data.mongodb.core.aggregation.Aggregation.group;
import com.nisum.myteam.exception.handler.ResponseDetails; import static org.springframework.data.mongodb.core.aggregation.Aggregation.newAggregation;
import com.nisum.myteam.model.ColumnChartData; import static org.springframework.data.mongodb.core.aggregation.Aggregation.project;
import com.nisum.myteam.model.GroupByCount; import static org.springframework.data.mongodb.core.aggregation.Aggregation.sort;
import com.nisum.myteam.model.ReportSeriesRecord;
import com.nisum.myteam.model.dao.Account; import java.text.ParseException;
import com.nisum.myteam.model.dao.Employee; import java.text.SimpleDateFormat;
import com.nisum.myteam.model.dao.Resource; import java.util.ArrayList;
import com.nisum.myteam.model.vo.ReportVo; import java.util.Calendar;
import com.nisum.myteam.model.vo.ResourceVO; import java.util.Date;
import com.nisum.myteam.service.IAccountService; import java.util.HashMap;
import com.nisum.myteam.service.IEmployeeService; import java.util.List;
import com.nisum.myteam.service.IResourceService; import java.util.Map;
import java.util.stream.Collectors;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Sort; import org.springframework.data.domain.Sort;
import org.springframework.data.mongodb.core.MongoTemplate; import org.springframework.data.mongodb.core.MongoTemplate;
...@@ -25,15 +27,24 @@ import org.springframework.data.mongodb.core.query.Query; ...@@ -25,15 +27,24 @@ import org.springframework.data.mongodb.core.query.Query;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*; 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 javax.servlet.http.HttpServletRequest; import com.nisum.myteam.exception.handler.MyTeamException;
import java.text.ParseException; import com.nisum.myteam.model.BillableEmployee;
import java.text.SimpleDateFormat; import com.nisum.myteam.model.ColumnChartData;
import java.util.*; import com.nisum.myteam.model.GroupByCount;
import java.util.stream.Collectors; import com.nisum.myteam.model.ReportSeriesRecord;
import com.nisum.myteam.model.dao.Account;
import static org.springframework.data.mongodb.core.aggregation.Aggregation.*; import com.nisum.myteam.model.dao.Employee;
import com.nisum.myteam.model.dao.Resource;
import com.nisum.myteam.model.vo.ReportVo;
import com.nisum.myteam.model.vo.ResourceVO;
import com.nisum.myteam.service.IAccountService;
import com.nisum.myteam.service.IEmployeeService;
import com.nisum.myteam.service.IResourceService;
//import com.nisum.myteam.model.dao.Resource; //import com.nisum.myteam.model.dao.Resource;
...@@ -245,13 +256,13 @@ public class ReportsController { ...@@ -245,13 +256,13 @@ public class ReportsController {
return new ResponseEntity<>(list, HttpStatus.OK); return new ResponseEntity<>(list, HttpStatus.OK);
} }
@RequestMapping(value = "/fetchEmployeeDetailsByFG", @RequestMapping(value = "/fetchEmployeeDetailsByFGAndBillability",
method = RequestMethod.GET, method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE) produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<Employee>> getEmployeesByFG( public ResponseEntity<List<BillableEmployee>> getEmployeesByFGAndBillability(
@RequestParam("fGroup") String fGroup) throws MyTeamException { @RequestParam("fGroup") String fGroup , @RequestParam("billableStatus") String billableStatus) throws MyTeamException {
List<Employee> empList = new ArrayList<>(); List<BillableEmployee> empList = new ArrayList<>();
empList = employeeService.getEmployeesByFunctionalGrp(fGroup); empList = employeeService.getEmployeeDetailsByFGAndBillability(fGroup,billableStatus);
return new ResponseEntity<>(empList, HttpStatus.OK); return new ResponseEntity<>(empList, HttpStatus.OK);
} }
......
package com.nisum.myteam.model;
import java.io.Serializable;
import java.util.Date;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
@Setter
@Getter
@AllArgsConstructor
@NoArgsConstructor
@ToString
public class BillableEmployee implements Serializable {
private static final long serialVersionUID = 1L;
private String employeeId;
private String employeeName;
private String emailId;
private String projectName;
private String billableStatus;
private Date billingStartDate;
private Date billingEndDate;
private String functionalGroup;
}
package com.nisum.myteam.service; package com.nisum.myteam.service;
import com.nisum.myteam.exception.handler.MyTeamException; import com.nisum.myteam.exception.handler.MyTeamException;
import com.nisum.myteam.model.BillableEmployee;
import com.nisum.myteam.model.dao.Account; import com.nisum.myteam.model.dao.Account;
import com.nisum.myteam.model.dao.Employee; import com.nisum.myteam.model.dao.Employee;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -52,4 +53,6 @@ public interface IEmployeeService { ...@@ -52,4 +53,6 @@ public interface IEmployeeService {
public List<Employee> getEmployeesByEmpStatusAndShift(String empStatus, String shift); public List<Employee> getEmployeesByEmpStatusAndShift(String empStatus, String shift);
List<BillableEmployee> getEmployeeDetailsByFGAndBillability(String fGroup, String billableStatus);
} }
...@@ -64,6 +64,8 @@ public interface IResourceService { ...@@ -64,6 +64,8 @@ public interface IResourceService {
public List<ReserveReportsVO> getResourceReportsByBillingStatus(String resourceStatus); public List<ReserveReportsVO> getResourceReportsByBillingStatus(String resourceStatus);
List<Resource> findByBillableStatus(String billableStatus);
// List<Resource> getAllResourcesForProject(String projectId, String status); // List<Resource> getAllResourcesForProject(String projectId, String status);
......
package com.nisum.myteam.service.impl; package com.nisum.myteam.service.impl;
import com.nisum.myteam.exception.handler.MyTeamException; import java.util.ArrayList;
import com.nisum.myteam.model.dao.Account; import java.util.Comparator;
import com.nisum.myteam.model.dao.Domain; import java.util.Date;
import com.nisum.myteam.model.dao.Employee; import java.util.HashMap;
import com.nisum.myteam.repository.EmployeeRepo; import java.util.List;
import com.nisum.myteam.service.*; import java.util.Set;
import com.nisum.myteam.utils.MyTeamUtils; import java.util.stream.Collectors;
import com.nisum.myteam.utils.constants.ApplicationRole;
import com.nisum.myteam.utils.constants.RoleConstant;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Sort; import org.springframework.data.domain.Sort;
...@@ -20,8 +18,27 @@ import org.springframework.data.mongodb.core.query.Query; ...@@ -20,8 +18,27 @@ import org.springframework.data.mongodb.core.query.Query;
import org.springframework.data.mongodb.core.query.Update; import org.springframework.data.mongodb.core.query.Update;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.*; import com.nisum.myteam.exception.handler.MyTeamException;
import java.util.stream.Collectors; import com.nisum.myteam.model.BillableEmployee;
import com.nisum.myteam.model.dao.Account;
import com.nisum.myteam.model.dao.Domain;
import com.nisum.myteam.model.dao.Employee;
import com.nisum.myteam.model.dao.Project;
import com.nisum.myteam.model.dao.Resource;
import com.nisum.myteam.repository.EmployeeRepo;
import com.nisum.myteam.service.IAccountService;
import com.nisum.myteam.service.IDomainService;
import com.nisum.myteam.service.IEmployeeLocationService;
import com.nisum.myteam.service.IEmployeeRoleService;
import com.nisum.myteam.service.IEmployeeService;
import com.nisum.myteam.service.IProjectService;
import com.nisum.myteam.service.IResourceService;
import com.nisum.myteam.statuscodes.ResourceStatus;
import com.nisum.myteam.utils.MyTeamUtils;
import com.nisum.myteam.utils.constants.ApplicationRole;
import com.nisum.myteam.utils.constants.RoleConstant;
import lombok.extern.slf4j.Slf4j;
@Service @Service
@Slf4j @Slf4j
...@@ -324,6 +341,42 @@ public class EmployeeService implements IEmployeeService { ...@@ -324,6 +341,42 @@ public class EmployeeService implements IEmployeeService {
return employeeRepo.findByEmployeeIdIn(empIdsSet); return employeeRepo.findByEmployeeIdIn(empIdsSet);
} }
@Override
public List<BillableEmployee> getEmployeeDetailsByFGAndBillability(String fGroup, String billableStatus) {
List<Resource> resources=resourceService.findByBillableStatus(billableStatus);
return getBillableEmployeeByfunctionalGroup(fGroup,resources);
}
private List<BillableEmployee> getBillableEmployeeByfunctionalGroup(String fGroup, List<Resource> resources) {
List<BillableEmployee> employeesForUI=new ArrayList<>();
List<Employee> employeeswithFG=employeeRepo.findByEmpStatusAndFunctionalGroup(ResourceStatus.ACTIVE.getStatus(), fGroup);
for(Resource resourceObj:resources) {
Project project=projectService.getProjectByProjectId(resourceObj.getProjectId());
for(Employee employee:employeeswithFG) {
if(employee.getEmployeeId().equals(resourceObj.getEmployeeId())) {
BillableEmployee billableEmployee=new BillableEmployee();
billableEmployee.setEmployeeId(resourceObj.getEmployeeId());
billableEmployee.setEmployeeName(employee.getEmployeeName());
billableEmployee.setEmailId(employee.getEmailId());
billableEmployee.setProjectName(project.getProjectName());
billableEmployee.setBillingStartDate(resourceObj.getBillingStartDate());
billableEmployee.setBillableStatus(resourceObj.getBillableStatus());
billableEmployee.setBillingEndDate(resourceObj.getBillingEndDate());
billableEmployee.setFunctionalGroup(fGroup);
employeesForUI.add(billableEmployee);
}
}
}
return employeesForUI;
}
} }
...@@ -842,6 +842,10 @@ public class ResourceService implements IResourceService { ...@@ -842,6 +842,10 @@ public class ResourceService implements IResourceService {
return allocationList; return allocationList;
} }
@Override
public List<Resource> findByBillableStatus(String billableStatus) {
return resourceRepo.findByBillableStatus(billableStatus);
}
}//class }//class
......
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