Commit 75c2d0cc authored by Md Suleman's avatar Md Suleman

Bar chart report by account wise is updated and some dashboard changes

parent 9f7a9675
......@@ -16,6 +16,7 @@ import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import com.nisum.myteam.service.IReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Sort;
import org.springframework.data.mongodb.core.MongoTemplate;
......@@ -47,6 +48,8 @@ import com.nisum.myteam.service.IAccountService;
import com.nisum.myteam.service.IEmployeeService;
import com.nisum.myteam.service.IResourceService;
import javax.ws.rs.QueryParam;
//import com.nisum.myteam.model.dao.Resource;
@RestController
......@@ -66,7 +69,10 @@ public class ReportsController {
@Autowired
private IAccountService accountService;
//Ok Response
@Autowired
private IReportService reportService;
//Ok Response
@RequestMapping(value = "/getEmployeesByFunctionalGroup1",
method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
......@@ -320,62 +326,13 @@ public class ReportsController {
return new ResponseEntity<>(empList, HttpStatus.OK);
}
@RequestMapping(value = "/billabilityByFunctionalGroup",
@RequestMapping(value = "/getBarChartReport",
method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
public ReportVo billabilityReportByFunctionalGroup(){
ReportVo reportVo = new ReportVo();
Map<String,Object> billableData = new HashMap();
Map<String,Object> nonBillableData = new HashMap();
Map<String,Object> traineeData = new HashMap();
List<Object> billableCount = new ArrayList<>();
List<Object> nonBillableCount = new ArrayList<>();
List<Object> traineeCount = new ArrayList<>();
billableData.put("name","Billable");
nonBillableData.put("name","Non-Billable");
traineeData.put("name", "Trainee");
for(String functionalGroup:reportVo.getCategoriesList()){
Map<String,Object> billableObj = new HashMap();
Map<String,Object> nonbillableObj = new HashMap();
// Map<String,Object> traineeObj = new HashMap();
Integer billableC=0;
Integer nonBillableC=0;
Integer traineeC=0;
// float traineePer;
float billper;
float nonBillPer;
List<Employee> employeeList = employeeService.getEmployeesByFunctionalGrp(functionalGroup);
for(Employee employee:employeeList){
Resource resource = resourceService.getLatestResourceByEmpId(employee.getEmployeeId());
if(resource!=null && resource.getBillableStatus().equals("Billable")){
billableC++;
}else if(resource!=null && resource.getBillableStatus().equals("Trainee")) {
traineeC++;
} else{
nonBillableC++;
}
}
billper = ((billableC / (float)(employeeList.size() - traineeC))*100);
nonBillPer = nonBillableC /(float) (employeeList.size()-traineeC)*100;
// traineePer = traineeC / (float) employeeList.size()*100;
billableObj.put("percent", billper);
billableObj.put("y", billableC);
nonbillableObj.put("percent", nonBillPer);
nonbillableObj.put("y", nonBillableC);
// traineeObj.put("percent", traineePer);
// traineeObj.put("y", traineeC);
billableCount.add(billableObj);
nonBillableCount.add(nonbillableObj);
traineeCount.add(traineeC);
}
billableData.put("data",billableCount);
nonBillableData.put("data",nonBillableCount);
traineeData.put("data", traineeCount);
reportVo.getSeriesDataList().add(billableData);
reportVo.getSeriesDataList().add(nonBillableData);
reportVo.getSeriesDataList().add(traineeData);
return reportVo;
public ReportVo billabilityReportByFunctionalGroup(@RequestParam("byType") String byType) throws MyTeamException {
return reportService.getBarChartReport(byType);
}
......@@ -403,7 +360,7 @@ public class ReportsController {
// Convert the aggregation result into a List
AggregationResults<ColumnChartData> groupResults = mongoTemplate.aggregate(aggregate, Resource.class,
ColumnChartData.class);
ColumnChartData.class);
List<ColumnChartData> result = groupResults.getMappedResults();
List<String> statusList = new ArrayList();
statusList.add("Billable");
......@@ -456,4 +413,6 @@ public class ReportsController {
}
}
......@@ -15,13 +15,13 @@ public class ReportVo {
List<String> categoriesList = new ArrayList();
List<Map<String,Object>> seriesDataList = new ArrayList();
public ReportVo(){
categoriesList.add("ES");
categoriesList.add("CI");
categoriesList.add("APPS");
categoriesList.add("ACI - QE");
categoriesList.add("ACI - DevOps");
categoriesList.add("ACI - Support");
categoriesList.add("I&A");
}
// public ReportVo(){
// categoriesList.add("ES");
// categoriesList.add("CI");
// categoriesList.add("APPS");
// categoriesList.add("ACI - QE");
// categoriesList.add("ACI - DevOps");
// categoriesList.add("ACI - Support");
// categoriesList.add("I&A");
// }
}
......@@ -29,4 +29,6 @@ public interface IAccountService {
Account deleteAccount(String accountId) throws MyTeamException;
public Account getAccountByName(String name);
}
package com.nisum.myteam.service;
import com.nisum.myteam.exception.handler.MyTeamException;
import com.nisum.myteam.model.vo.EmployeeDashboardVO;
import java.util.List;
public interface IDashboardService {
public List<EmployeeDashboardVO> getEmployeesDashBoard();
public List<EmployeeDashboardVO> getDashBoardData();
public List<EmployeeDashboardVO> getDashBoardData() throws MyTeamException;
}
......@@ -60,5 +60,7 @@ public interface IProjectService {
List<Resource> getResourcesUnderProject(String empId);
public List<Project> getProjectsByAccountId(String accId);
}
package com.nisum.myteam.service;
import com.nisum.myteam.exception.handler.MyTeamException;
import com.nisum.myteam.model.vo.ReportVo;
public interface IReportService {
public ReportVo getBarChartReport(String byType) throws MyTeamException;
}
......@@ -67,6 +67,8 @@ public interface IResourceService {
Set<Resource> findByBillableStatus(String billableStatus);
public List<Resource> getResourceByProjectId(String projectId);
// List<Resource> getAllResourcesForProject(String projectId, String status);
......
......@@ -163,6 +163,11 @@ public class AccountService implements IAccountService {
return updatedAccount;
}
@Override
public Account getAccountByName(String name) {
return accountRepo.findByAccountNameIgnoreCase(name);
}
// generating the account id.
// accountId format is "Acc001"
private String generateAccountId() throws MyTeamException {
......
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;
......@@ -110,19 +111,19 @@ public class DashboardService implements IDashboardService {
}
@Override
public List<EmployeeDashboardVO> getDashBoardData(){
List<EmployeeDashboardVO> employeeDashboardList = new ArrayList<>();
List<Employee> allEmployeesList = employeeService.getAllEmployees();
List<ResourceVO> resourcesList = resourceService.getAllResourcesVO();
public List<EmployeeDashboardVO> getDashBoardData() throws MyTeamException {
List<EmployeeDashboardVO> employeeDashboard = new ArrayList<>();
List<Employee> allEmployees = employeeService.getActiveEmployees();
List<ResourceVO> resources = resourceService.getAllResourcesVO();
for (Employee employee:allEmployeesList){
for (Employee employee:allEmployees){
EmployeeDashboardVO employeeDashboardVO = new EmployeeDashboardVO();
BeanUtils.copyProperties(employee, employeeDashboardVO);
employeeDashboardList.add(employeeDashboardVO);
employeeDashboard.add(employeeDashboardVO);
}
employeeDashboardList.stream().forEach(emp -> {
List<ResourceVO> latestResourceList = resourcesList.stream().
employeeDashboard.stream().forEach(emp -> {
List<ResourceVO> latestResourceList = resources.stream().
filter(res -> (res.getEmployeeId().equals(emp.getEmployeeId())&&res.getBillingEndDate().after(new Date()))).collect(Collectors.toList());
if(!latestResourceList.isEmpty()){
ResourceVO latestResource = latestResourceList.get(0);
......@@ -139,6 +140,6 @@ public class DashboardService implements IDashboardService {
}
}
});
return employeeDashboardList;
return employeeDashboard;
}
}
......@@ -233,6 +233,13 @@ public class ProjectService implements IProjectService {
}
@Override
public List<Project> getProjectsByAccountId(String accId) {
return projectRepo.findByAccountId(accId);
}
@Override
public List<Project> getProjectsUnderDeliveryLead(String deliveryLeadId) throws MyTeamException {
......
package com.nisum.myteam.service.impl;
import com.nisum.myteam.exception.handler.MyTeamException;
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.service.IReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.*;
import java.util.stream.Collectors;
@Service
public class ReportService implements IReportService {
@Autowired
private EmployeeService employeeService;
@Autowired
private ResourceService resourceService;
@Autowired
private AccountService accountService;
@Autowired
private ProjectService projectService;
@Autowired
private FunctionalGroupService functionalGroupService;
public ReportVo getBarChartReport(String byType) throws MyTeamException {
ReportVo reportVo = new ReportVo();
if(byType.equals("FunctionalGroup")) {
functionalGroupService.getAllFunctionalGroups().forEach(f -> reportVo.getCategoriesList().add(f.getName()));
} else {
accountService.getAllAccounts().forEach(a -> reportVo.getCategoriesList().add(a.getAccountName()));
}
Map<String,Object> billableData = new HashMap();
Map<String,Object> nonBillableData = new HashMap();
Map<String,Object> traineeData = new HashMap();
List<Object> billableCount = new ArrayList<>();
List<Object> nonBillableCount = new ArrayList<>();
List<Object> traineeCount = new ArrayList<>();
billableData.put("name","Billable");
nonBillableData.put("name","Non-Billable");
traineeData.put("name", "Trainee");
for(String category:reportVo.getCategoriesList()){
Map<String,Object> billableObj = new HashMap();
Map<String,Object> nonbillableObj = new HashMap();
// Map<String,Object> traineeObj = new HashMap();
Integer billableC=0;
Integer nonBillableC=0;
Integer traineeC=0;
// float traineePer;
float billper;
float nonBillPer;
List<Employee> employeeList = new ArrayList<>();
if(byType.equals("FunctionalGroup")) {
employeeList = getEmployeesByFunctionalGroup(category);
} else {
employeeList = getEmployeeByAccounts(category);
}
// .getAllEmployees().stream().
// filter(e -> e.getFunctionalGroup().equals(functionalGroup)).collect(Collectors.toList());
for(Employee employee:employeeList){
Resource resource = resourceService.getLatestResourceByEmpId(employee.getEmployeeId());
if(resource!=null && resource.getBillableStatus().equals("Billable")){
billableC++;
}else if(resource!=null && resource.getBillableStatus().equals("Trainee")) {
traineeC++;
} else{
nonBillableC++;
}
}
billper = ((billableC / (float)(employeeList.size() - traineeC))*100);
nonBillPer = nonBillableC /(float) (employeeList.size()-traineeC)*100;
// traineePer = traineeC / (float) employeeList.size()*100;
billableObj.put("percent", billper);
billableObj.put("y", billableC);
nonbillableObj.put("percent", nonBillPer);
nonbillableObj.put("y", nonBillableC);
// traineeObj.put("percent", traineePer);
// traineeObj.put("y", traineeC);
billableCount.add(billableObj);
nonBillableCount.add(nonbillableObj);
traineeCount.add(traineeC);
}
billableData.put("data",billableCount);
nonBillableData.put("data",nonBillableCount);
traineeData.put("data", traineeCount);
reportVo.getSeriesDataList().add(billableData);
reportVo.getSeriesDataList().add(nonBillableData);
reportVo.getSeriesDataList().add(traineeData);
return reportVo;
}
private List<Employee> getEmployeesByFunctionalGroup(String functionalGroup){
return employeeService.getEmployeesByFunctionalGrp(functionalGroup);
}
private List<Employee> getEmployeeByAccounts(String accountName){
List<Employee> employeeList = new ArrayList<>();
List<Project> projects = projectService.getProjectsByAccountId(accountService.getAccountByName(accountName).getAccountId());
projects.stream().forEach(p -> {
resourceService.getResourceByProjectId(p.getProjectId()).stream().filter(r -> r.getBillingEndDate().after(new Date())).
forEach(r ->employeeList.add(employeeService.getEmployeeById(r.getEmployeeId())));
});
return employeeList;
}
}
......@@ -737,6 +737,11 @@ public class ResourceService implements IResourceService {
}
@Override
public List<Resource> getResourceByProjectId(String projectId){
return resourceRepo.findByProjectId(projectId);
}
public List<ChangedResourceVO> getChangedResourceByDate(String fromDatestr, String toDatestr) {
// List<ChangedResourceVO> changedResourceVOList = new ArrayList();
......
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