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

"UIReport Service implemented"

parent 6574f8fd
package com.nisum.myteam.controller;
import com.nisum.myteam.exception.handler.MyTeamException;
import com.nisum.myteam.exception.handler.ResponseDetails;
import com.nisum.myteam.model.ColumnChartData;
import com.nisum.myteam.model.GroupByCount;
import com.nisum.myteam.model.ReportSeriesRecord;
import com.nisum.myteam.model.dao.Account;
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 static org.springframework.data.mongodb.core.aggregation.Aggregation.group;
import static org.springframework.data.mongodb.core.aggregation.Aggregation.newAggregation;
import static org.springframework.data.mongodb.core.aggregation.Aggregation.project;
import static org.springframework.data.mongodb.core.aggregation.Aggregation.sort;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Sort;
import org.springframework.data.mongodb.core.MongoTemplate;
......@@ -25,15 +27,24 @@ import org.springframework.data.mongodb.core.query.Query;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
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 java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
import static org.springframework.data.mongodb.core.aggregation.Aggregation.*;
import com.nisum.myteam.exception.handler.MyTeamException;
import com.nisum.myteam.model.BillableEmployee;
import com.nisum.myteam.model.ColumnChartData;
import com.nisum.myteam.model.GroupByCount;
import com.nisum.myteam.model.ReportSeriesRecord;
import com.nisum.myteam.model.dao.Account;
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;
......@@ -245,13 +256,13 @@ public class ReportsController {
return new ResponseEntity<>(list, HttpStatus.OK);
}
@RequestMapping(value = "/fetchEmployeeDetailsByFG",
@RequestMapping(value = "/fetchEmployeeDetailsByFGAndBillability",
method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<Employee>> getEmployeesByFG(
@RequestParam("fGroup") String fGroup) throws MyTeamException {
List<Employee> empList = new ArrayList<>();
empList = employeeService.getEmployeesByFunctionalGrp(fGroup);
public ResponseEntity<List<BillableEmployee>> getEmployeesByFGAndBillability(
@RequestParam("fGroup") String fGroup , @RequestParam("billableStatus") String billableStatus) throws MyTeamException {
List<BillableEmployee> empList = new ArrayList<>();
empList = employeeService.getEmployeeDetailsByFGAndBillability(fGroup,billableStatus);
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;
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.Employee;
import org.springframework.stereotype.Service;
......@@ -52,4 +53,6 @@ public interface IEmployeeService {
public List<Employee> getEmployeesByEmpStatusAndShift(String empStatus, String shift);
List<BillableEmployee> getEmployeeDetailsByFGAndBillability(String fGroup, String billableStatus);
}
......@@ -64,6 +64,8 @@ public interface IResourceService {
public List<ReserveReportsVO> getResourceReportsByBillingStatus(String resourceStatus);
List<Resource> findByBillableStatus(String billableStatus);
// List<Resource> getAllResourcesForProject(String projectId, String status);
......
package com.nisum.myteam.service.impl;
import com.nisum.myteam.exception.handler.MyTeamException;
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.repository.EmployeeRepo;
import com.nisum.myteam.service.*;
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;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Sort;
......@@ -20,8 +18,27 @@ import org.springframework.data.mongodb.core.query.Query;
import org.springframework.data.mongodb.core.query.Update;
import org.springframework.stereotype.Service;
import java.util.*;
import java.util.stream.Collectors;
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.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
@Slf4j
......@@ -324,6 +341,42 @@ public class EmployeeService implements IEmployeeService {
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 {
return allocationList;
}
@Override
public List<Resource> findByBillableStatus(String billableStatus) {
return resourceRepo.findByBillableStatus(billableStatus);
}
}//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