Commit c09dddb7 authored by Ashok Kumar K's avatar Ashok Kumar K

implementation of Manage Designation page

parents 2c1ef7be 123699ea
package com.nisum.myteam.controller;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
......@@ -27,10 +28,10 @@ public class FunctionalGroupController {
@RequestMapping(value = "/getAllFunctionalGroups", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<?> getAllFunctionalGroups(HttpServletRequest request) {
List<String> functionalGroupsList = functionalGroupService.getAllFunctionalGroups().stream().
filter(f -> !Arrays.asList("IT","Recruiter","Admin","HR","Accounts").contains(f.getName())).map(f -> f.getName()).collect(Collectors.toList());
List<String> functionalGroupsList = new ArrayList<>();
functionalGroupsList.add("ALL");
functionalGroupsList.addAll(functionalGroupService.getAllFunctionalGroups().stream().
filter(f -> !Arrays.asList("IT","Recruiter","Admin","HR","Accounts").contains(f.getName())).map(f -> f.getName()).collect(Collectors.toList()));
ResponseDetails getRespDetails = new ResponseDetails(new Date(), 905, "Retrieved FunctionalGroups successfully",
"FunctionalGroups list", functionalGroupsList, request.getRequestURI(), "FunctionalGroups Details: Status", null);
return new ResponseEntity<ResponseDetails>(getRespDetails, HttpStatus.OK);
......
......@@ -426,5 +426,25 @@ public class ReportsController {
}
return new ResponseEntity<>(reports, HttpStatus.OK);
}
@RequestMapping(value = "/getPieChartReport",
method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
public ReportVo allBillabilityReport(@RequestParam("byType") String byType,
@RequestParam("onDate") @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) Date onDate) throws MyTeamException {
System.out.println("allBillabilityReport start");
return reportService.getPieChartReport(byType,onDate);
}
@RequestMapping(value = "/fetchEmployeesByBillabilityType",
method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<Reports>> getEmployeesByBillabilityType(
@RequestParam("billableStatus") String billableStatus,
@RequestParam("onDate") @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) Date onDate) throws MyTeamException {
List<Reports> empList = null;
empList = reportService.getEmployeeDetailsByBillabilityType(billableStatus, onDate);
return new ResponseEntity<>(empList, HttpStatus.OK);
}
}
package com.nisum.myteam.service;
import com.nisum.myteam.exception.handler.MyTeamException;
import com.nisum.myteam.model.FunctionalGroup;
import com.nisum.myteam.model.dao.Account;
import com.nisum.myteam.model.dao.Employee;
import org.springframework.stereotype.Service;
......@@ -55,6 +56,8 @@ public interface IEmployeeService {
public List<Employee> getEmployeesByEmpStatusAndShift(String empStatus, String shift);
public List<Employee> getAllEmployeeListByFunGrps(List<String> functionalGroupList);
public List<Employee> getEmployeesByDesignation(String designation);
public int getEmployeesCountByDesignation(String designation);
......
......@@ -9,4 +9,6 @@ public interface IFunctionalGroupService {
public List<FunctionalGroup> getAllFunctionalGroups();
public FunctionalGroup getFunctionalGroup(String functionalGroupName);
public List<FunctionalGroup> getAllBillableFunctionalGroups();
}
......@@ -19,5 +19,9 @@ public interface IReportService {
public Project getProjectById(String employeeId);
public List<Reports> getEmployeeDetailsByFGAccountAndBillability(String fGroup, String billableStatus, String account,Date onDate) throws MyTeamException;
public ReportVo getPieChartReport(String byType, Date onDate) throws MyTeamException;
public List<Reports> getEmployeeDetailsByBillabilityType(String billabilityType, Date onDate) throws MyTeamException;
}
\ No newline at end of file
package com.nisum.myteam.service.impl;
import com.nisum.myteam.exception.handler.MyTeamException;
import com.nisum.myteam.model.FunctionalGroup;
import com.nisum.myteam.model.dao.Account;
import com.nisum.myteam.model.dao.Domain;
import com.nisum.myteam.model.dao.Employee;
......@@ -483,4 +484,10 @@ public class EmployeeService implements IEmployeeService {
return employeeRepo.findByEmployeeIdAndEmpStatus(employeeId, active);
}
public List<Employee> getAllEmployeeListByFunGrps(List<String> functionalGroupList){
Query query = new Query(Criteria.where("empStatus").is("Active").andOperator(Criteria.where("functionalGroup").in(functionalGroupList)));
List<Employee> employeePersistedList = mongoTemplate.find(query, Employee.class);
return employeePersistedList;
}
}
package com.nisum.myteam.service.impl;
import com.nisum.myteam.model.FunctionalGroup;
import com.nisum.myteam.model.dao.Employee;
import com.nisum.myteam.repository.FunctionalGroupRepo;
import com.nisum.myteam.service.IFunctionalGroupService;
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 java.util.Arrays;
import java.util.List;
@Service
public class FunctionalGroupService implements IFunctionalGroupService {
@Autowired
private MongoTemplate mongoTemplate;
@Autowired
private FunctionalGroupRepo functionalGroupRepo;
......@@ -22,4 +30,11 @@ public class FunctionalGroupService implements IFunctionalGroupService {
public FunctionalGroup getFunctionalGroup(String functionalGroupName) {
return functionalGroupRepo.findByName(functionalGroupName);
}
@Override
public List<FunctionalGroup> getAllBillableFunctionalGroups() {
Query query = new Query(Criteria.where("name").nin(Arrays.asList("IT","Recruiter","Admin","HR","Accounts","Delivery Org","Global Mobility")));
List<FunctionalGroup> functionalGroupList = mongoTemplate.find(query, FunctionalGroup.class);
return functionalGroupList;
}
}
package com.nisum.myteam.service.impl;
import com.nisum.myteam.exception.handler.MyTeamException;
import com.nisum.myteam.model.FunctionalGroup;
import com.nisum.myteam.model.Reports;
import com.nisum.myteam.model.dao.Employee;
import com.nisum.myteam.model.dao.Project;
......@@ -149,7 +150,19 @@ public class ReportService implements IReportService {
return resultantEmployeeWithBillability(empList,billableStatus,onDate);
}
private List<Reports> resultantEmployeeWithBillability(List<Employee> employees,
@Override
public ReportVo getPieChartReport(String byType, Date onDate) throws MyTeamException {
List<Employee> employeeList = employeeService.getAllEmployeeListByFunGrps(functionalGroupService.getAllBillableFunctionalGroups().stream().collect(Collectors.mapping(FunctionalGroup::getName, Collectors.toList())));
return preparePieChartData(byType, onDate, employeeList);
}
@Override
public List<Reports> getEmployeeDetailsByBillabilityType(String billabilityType, Date onDate) throws MyTeamException {
List<Employee> employeeList = employeeService.getAllEmployeeListByFunGrps(functionalGroupService.getAllBillableFunctionalGroups().stream().collect(Collectors.mapping(FunctionalGroup::getName, Collectors.toList())));
return resultantEmployeeWithBillability(employeeList, billabilityType, onDate);
}
private List<Reports> resultantEmployeeWithBillability(List<Employee> employees,
String billableStatus,Date ondate) throws MyTeamException {
List<Reports> billableEmployees=new ArrayList<Reports>();
......@@ -199,4 +212,48 @@ public class ReportService implements IReportService {
return projectService.getProjectByProjectId(projectId);
}
public ReportVo preparePieChartData(String byType, Date onDate, List<Employee> employeeList) throws MyTeamException {
ReportVo reportVo = new ReportVo();
Integer billableCount = 0;
Integer nonBillableCount = 0;
Integer traineeCount = 0;
Integer allEmployeesSize = employeeList.size();
float traineePer;
float billper;
Map<String, Object> billableObj = new HashMap();
Map<String, Object> nonBillableObj = new HashMap();
Map<String, Object> traineeObj = new HashMap();
float nonBillPer;
Map<String,List<Resource>> resourceServiceAllocationOfDateMap = resourceService.getAllocationOfDateMap(employeeList.stream().collect(Collectors.mapping(Employee::getEmployeeId, Collectors.toList())), onDate);
Map<String, Integer> utilityResourceDataMap = new HashMap<>();
utilityResourceDataMap.put("Billable", billableCount);
utilityResourceDataMap.put("Non-Billable", nonBillableCount);
utilityResourceDataMap.put("Trainee", traineeCount);
resourceServiceAllocationOfDateMap.forEach((s, resources) -> {
Resource resource = resources.stream().findFirst().get();
if (resource != null && resource.getBillableStatus().equals("Billable")) {
utilityResourceDataMap.put("Billable", utilityResourceDataMap.get("Billable")+1);
} else if (resource != null && resource.getBillableStatus().equals("Trainee")) {
utilityResourceDataMap.put("Trainee", utilityResourceDataMap.get("Trainee")+1);
} else if (resource != null) {
utilityResourceDataMap.put("Non-Billable", utilityResourceDataMap.get("Non-Billable")+1);
}
});
billper = ((utilityResourceDataMap.get("Billable") / (float) (allEmployeesSize - utilityResourceDataMap.get("Trainee"))) * 100);
nonBillPer = utilityResourceDataMap.get("Non-Billable") / (float) (allEmployeesSize - utilityResourceDataMap.get("Trainee")) * 100;
traineePer = utilityResourceDataMap.get("Trainee") / (float) (allEmployeesSize - (utilityResourceDataMap.get("Billable") + utilityResourceDataMap.get("Non-Billable"))) * 100;
billableObj.put("percent", billper);
billableObj.put("y", utilityResourceDataMap.get("Billable"));
billableObj.put("name", "Billable");
nonBillableObj.put("percent", nonBillPer);
nonBillableObj.put("y", utilityResourceDataMap.get("Non-Billable"));
nonBillableObj.put("name", "Non-Billable");
traineeObj.put("y", utilityResourceDataMap.get("Trainee"));
traineeObj.put("name", "Trainee");
traineeObj.put("percent", traineePer);
reportVo.getSeriesDataList().add(billableObj);
reportVo.getSeriesDataList().add(nonBillableObj);
reportVo.getSeriesDataList().add(traineeObj);
return reportVo;
}
}
......@@ -1161,4 +1161,12 @@ public class ResourceService implements IResourceService {
}
return null;
}
public Map<String,List<Resource>> getAllocationOfDateMap(List<String> employeeIdList,Date onDate){
Query query = new Query(Criteria.where("employeeId").in(employeeIdList).andOperator(Criteria.where("billingStartDate").lte(onDate),Criteria.where("billingEndDate").gte(onDate)));
List<Resource> resourceList = mongoTemplate.find(query, Resource.class);
Map<String,List<Resource>> resourceMap = resourceList.stream().collect(Collectors.groupingBy(Resource::getEmployeeId,Collectors.toList()));
System.out.println(resourceMap);
return resourceMap;
}
}
\ No newline at end of file
......@@ -32,7 +32,6 @@
<script src="js/pdf/angular-pdf.min.js"></script>
<script src="js/pdf/print.min.js"></script>
<link rel="stylesheet" href="css/bootstrap.min.css"></link>
<!-- <link rel="stylesheet" href="css/default-styles.css"></link> -->
<link rel="stylesheet" href="css/custom-theme.css"></link>
<script src="js/bootstrap.min.js"></script>
<script src="js/angular-idle.js"></script>
......@@ -48,9 +47,7 @@
<link rel="stylesheet" href="http://ui-grid.info/release/ui-grid.css" type="text/css">
<!-- <link rel="stylesheet" href="css/leftmenu.css"></link> -->
<link rel="stylesheet" href="css/pdf-viewer.css"></link>
<!-- <link rel="stylesheet" href="css/user-profile.css"></link> -->
<script src="js/app.js"></script>
<script src="js/date-text-filter.js"></script>
<script src="js/ui-grid-edit-datepicker.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