Commit c8931b7f authored by vikram singh's avatar vikram singh

"Added Service for Account by billability."

parent a3ec008a
......@@ -35,7 +35,7 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.nisum.myteam.exception.handler.MyTeamException;
import com.nisum.myteam.model.BillableEmployee;
import com.nisum.myteam.model.Reports;
import com.nisum.myteam.model.ColumnChartData;
import com.nisum.myteam.model.GroupByCount;
import com.nisum.myteam.model.ReportSeriesRecord;
......@@ -266,29 +266,27 @@ public class ReportsController {
@RequestMapping(value = "/fetchEmployeeDetailsByFGAndBillability",
method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<BillableEmployee>> getEmployeesByFGAndBillability(
public ResponseEntity<List<Reports>> getEmployeesByFGAndBillability(
@RequestParam("fGroup") String fGroup , @RequestParam("billableStatus") String billableStatus) throws MyTeamException {
List<BillableEmployee> empList = new ArrayList<>();
empList = employeeService.getEmployeeDetailsByFGAndBillability(fGroup,billableStatus);
List<Reports> empList=null;
empList = reportService.getEmployeeDetailsByFGAndBillability(fGroup,billableStatus);
return new ResponseEntity<>(empList, HttpStatus.OK);
}
@RequestMapping(value = "/fetchEmployeeDetailsByAccountBillability",
method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<ResourceVO>> fetchEmployeeDetailsByAccountBillability(
@RequestParam("account") String account,
@RequestParam("billabilityStatus") String billabilityStatus)
throws MyTeamException {
List<ResourceVO> resourcesList = new ArrayList<>();
if (account != null && !account.isEmpty()) {
resourcesList = resourceService.getAllResourcesVO();
}
return new ResponseEntity<>(resourcesList, HttpStatus.OK);
}
// @RequestMapping(value = "/fetchEmployeeDetailsByAccountBillability",
// method = RequestMethod.GET,
// produces = MediaType.APPLICATION_JSON_VALUE)
// public ResponseEntity<List<ResourceVO>> fetchEmployeeDetailsByAccountBillability(
// @RequestParam("account") String account,
// @RequestParam("billabilityStatus") String billabilityStatus)
// throws MyTeamException {
// List<ResourceVO> resourcesList = new ArrayList<>();
// if (account != null && !account.isEmpty()) {
// resourcesList = resourceService.getAllResourcesVO();
//
// }
// return new ResponseEntity<>(resourcesList, HttpStatus.OK);
// }
@RequestMapping(value = "/fetchEmployeeDetailsByDateBillability",
......@@ -370,9 +368,6 @@ public class ReportsController {
List<String> catagories = new ArrayList();
List<ReportSeriesRecord> seriesDetails = new ArrayList<ReportSeriesRecord>();
//List<Account> accounts = employeeService.getAccounts();
List<Account> accounts = accountService.getAllAccounts();
......@@ -412,7 +407,20 @@ public class ReportsController {
return new ResponseEntity<>(reportData, HttpStatus.OK);
}
@RequestMapping(value = "/fetchEmployeeDetailsByAccountBillability",
method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<Reports>> fetchEmployeeDetailsByAccountBillability(
@RequestParam("account") String account,
@RequestParam("billabilityStatus") String billabilityStatus)
throws MyTeamException {
List<Reports> resourcesList = new ArrayList<>();
if (account != null && !account.isEmpty()) {
resourcesList = reportService.getEmployeeDetailsByAccountBillability(account,billabilityStatus);
}
return new ResponseEntity<>(resourcesList, 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 Reports 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;
......@@ -53,6 +52,4 @@ public interface IEmployeeService {
public List<Employee> getEmployeesByEmpStatusAndShift(String empStatus, String shift);
List<BillableEmployee> getEmployeeDetailsByFGAndBillability(String fGroup, String billableStatus);
}
package com.nisum.myteam.service;
import java.util.List;
import com.nisum.myteam.exception.handler.MyTeamException;
import com.nisum.myteam.model.Reports;
import com.nisum.myteam.model.vo.ReportVo;
import com.nisum.myteam.model.vo.ResourceVO;
public interface IReportService {
public ReportVo getBarChartReport(String byType) throws MyTeamException;
public List<Reports> getEmployeeDetailsByFGAndBillability(String fGroup, String billableStatus) throws MyTeamException;
public List<Reports> getEmployeeDetailsByAccountBillability(String account, String billabilityStatus)throws MyTeamException;
}
\ No newline at end of file
......@@ -20,7 +20,6 @@ import org.springframework.data.mongodb.core.query.Update;
import org.springframework.stereotype.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.Domain;
import com.nisum.myteam.model.dao.Employee;
......@@ -343,40 +342,4 @@ public class EmployeeService implements IEmployeeService {
}
@Override
public List<BillableEmployee> getEmployeeDetailsByFGAndBillability(String fGroup, String billableStatus) {
BillableEmployee billableEmployee=new BillableEmployee();
List<BillableEmployee> resultantEmployees=new ArrayList<BillableEmployee>();
List<Employee> employeesByFG=employeeRepo.findByEmpStatusAndFunctionalGroup(ResourceStatus.ACTIVE.getStatus(), fGroup);
for(Employee employee:employeesByFG) {
Resource resourceObj=resourceService.getLatestResourceByEmpId(employee.getEmployeeId());
if(resourceObj!=null && resourceObj.getBillableStatus().equals(billableStatus)) {
Project project=projectService.getProjectByProjectId(resourceObj.getProjectId());
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);
resultantEmployees.add(billableEmployee );
}
// else if(resourceObj==null ) {
// billableEmployee.setEmployeeId(employee.getEmployeeId());
// billableEmployee.setEmployeeName(employee.getEmployeeName());
// billableEmployee.setEmailId(employee.getEmailId());
// billableEmployee.setFunctionalGroup(fGroup);
// resultantEmployees.add(billableEmployee);
//
// }
}
return resultantEmployees;
//Map<String,Resource> resourceMap=resourceService.findByBillableStatus(billableStatus).stream().collect(Collectors.toMap(e->e.getEmployeeId(), e->e));
//return employeeRepo.findByEmpStatusAndFunctionalGroup(ResourceStatus.ACTIVE.getStatus(), fGroup).stream().filter(e->resourceMap.keySet().contains(e.getEmployeeId())).map(e-> mappingBillableEmployee(e,fGroup,resourceMap)).collect(Collectors.toList());
}
}
package com.nisum.myteam.service.impl;
import com.nisum.myteam.exception.handler.MyTeamException;
import com.nisum.myteam.model.Reports;
import com.nisum.myteam.model.dao.Account;
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.model.vo.ReportVo;
import com.nisum.myteam.model.vo.ResourceVO;
import com.nisum.myteam.service.IReportService;
import com.nisum.myteam.statuscodes.ResourceStatus;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -15,6 +20,9 @@ import java.util.stream.Collectors;
@Service
public class ReportService implements IReportService {
private static final String Shadow = "Shadow";
private static final String Reserved = "Reserved";
@Autowired
private EmployeeService employeeService;
......@@ -113,4 +121,44 @@ public class ReportService implements IReportService {
return employeeList;
}
@Override
public List<Reports> getEmployeeDetailsByFGAndBillability(String fGroup, String billableStatus)
throws MyTeamException {
List<Employee> employeesByFG=employeeService.getEmployeesByFunctionalGrp(fGroup);
return resultantEmployeeWithBillability(employeesByFG,billableStatus);
}
@Override
public List<Reports> getEmployeeDetailsByAccountBillability(String accountName, String billabilityStatus)
throws MyTeamException {
return resultantEmployeeWithBillability(getEmployeeByAccounts(accountName),billabilityStatus);
}
private List<Reports> resultantEmployeeWithBillability(List<Employee> employees,
String billableStatus) {
List<Reports> resultantEmployees=new ArrayList<Reports>();
for(Employee employee:employees) {
Resource resourceObj=resourceService.getLatestResourceByEmpId(employee.getEmployeeId());
if(resourceObj.getBillableStatus().equals(billableStatus) ||( billableStatus.equals("Non-Billable") && (resourceObj.getBillableStatus().equals(Shadow)||resourceObj.getBillableStatus().equals(Reserved)))) {
resultantEmployees.add(mappingReports(employee,resourceObj) );
}
}
return resultantEmployees;
}
private Reports mappingReports(Employee employee,Resource resourceObj){
Reports Reports=new Reports();
Project project=projectService.getProjectByProjectId(resourceObj.getProjectId());
Reports.setEmployeeId(resourceObj.getEmployeeId());
Reports.setEmployeeName(employee.getEmployeeName());
Reports.setEmailId(employee.getEmailId());
Reports.setProjectName(project.getProjectName());
Reports.setBillingStartDate(resourceObj.getBillingStartDate());
Reports.setBillableStatus(resourceObj.getBillableStatus());
Reports.setBillingEndDate(resourceObj.getBillingEndDate());
Reports.setFunctionalGroup(employee.getFunctionalGroup());
return Reports;
}
}
......@@ -690,12 +690,8 @@ public class ResourceService implements IResourceService {
@Override
public Resource getLatestResourceByEmpId(String employeeId) {
List<Resource> resourceList = resourceRepo.findByEmployeeId(employeeId).stream().
filter(r -> r.getBillingEndDate().after(new Date())).collect(Collectors.toList());
if (!resourceList.isEmpty())
return resourceList.get(0);
else
return null;
return getLatestAllocation(resourceRepo.findByEmployeeId(employeeId));
}
......
......@@ -175,7 +175,7 @@ myApp.directive('hcPieChart', function () {
Highcharts.chart(element[0], {
chart: {
type: chartName,
height: (9 / 16 * 100) + '%'
height: '300px'
},
title: {
text: title
......
......@@ -663,3 +663,6 @@ cursor: pointer;
.allocation-change-report {
height: calc(85vh - 168px) !important;
}
.utilization-report {
height: calc(86vh - 346px) !important;
}
......@@ -13,7 +13,7 @@
<div class="row col-lg-12">
<div id="gridTest" ui-grid="gridOptions" ui-grid-pagination ui-grid-exporter
class="myGrid" style="width:100%;height:186px;margin-left:0px;">
class="myGrid utilization-report">
<div class="watermark" ng-show="!gridOptions.data.length">No
data available</div>
</div>
......
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