Commit 49aabae2 authored by Md Suleman's avatar Md Suleman

Bar chart report updated

parent 80af1825
...@@ -6,6 +6,7 @@ import com.nisum.myteam.model.GroupByCount; ...@@ -6,6 +6,7 @@ import com.nisum.myteam.model.GroupByCount;
import com.nisum.myteam.model.ReportSeriesRecord; import com.nisum.myteam.model.ReportSeriesRecord;
import com.nisum.myteam.model.dao.Employee; import com.nisum.myteam.model.dao.Employee;
import com.nisum.myteam.model.dao.Resource; 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.model.vo.ResourceVO;
import com.nisum.myteam.service.IEmployeeService; import com.nisum.myteam.service.IEmployeeService;
import com.nisum.myteam.service.IResourceService; import com.nisum.myteam.service.IResourceService;
...@@ -29,6 +30,7 @@ import org.springframework.web.bind.annotation.RestController; ...@@ -29,6 +30,7 @@ import org.springframework.web.bind.annotation.RestController;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
import java.util.stream.Collectors;
import static org.springframework.data.mongodb.core.aggregation.Aggregation.*; import static org.springframework.data.mongodb.core.aggregation.Aggregation.*;
...@@ -372,4 +374,39 @@ public class ReportsController { ...@@ -372,4 +374,39 @@ public class ReportsController {
return new ResponseEntity<>(empList, HttpStatus.OK); return new ResponseEntity<>(empList, HttpStatus.OK);
} }
@RequestMapping(value = "/billabilityByFunctionalGroup",
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();
List<Integer> billableCount = new ArrayList<>();
List<Integer> nonBillableCount = new ArrayList<>();
billableData.put("name","Billable");
nonBillableData.put("name","Non Billable");
for(String functionalGroup:reportVo.getCategories()){
Integer billableC=0;
Integer nonBillableC=0;
List<Employee> employeeList = employeeService.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{
nonBillableC++;
}
}
billableCount.add(billableC);
nonBillableCount.add(nonBillableC);
}
billableData.put("data",billableCount);
nonBillableData.put("data",nonBillableCount);
reportVo.getSeries().add(billableData);
reportVo.getSeries().add(nonBillableData);
return reportVo;
}
} }
\ No newline at end of file
...@@ -5,6 +5,7 @@ import com.nisum.myteam.exception.handler.MyTeamException; ...@@ -5,6 +5,7 @@ import com.nisum.myteam.exception.handler.MyTeamException;
import com.nisum.myteam.exception.handler.ResponseDetails; import com.nisum.myteam.exception.handler.ResponseDetails;
import com.nisum.myteam.model.dao.Employee; import com.nisum.myteam.model.dao.Employee;
import com.nisum.myteam.model.dao.Resource; import com.nisum.myteam.model.dao.Resource;
import com.nisum.myteam.model.vo.ChangedResourceVO;
import com.nisum.myteam.model.vo.EmployeeShiftsVO; import com.nisum.myteam.model.vo.EmployeeShiftsVO;
import com.nisum.myteam.model.vo.ResourceVO; import com.nisum.myteam.model.vo.ResourceVO;
import com.nisum.myteam.repository.EmployeeVisaRepo; import com.nisum.myteam.repository.EmployeeVisaRepo;
...@@ -21,6 +22,7 @@ import org.springframework.http.ResponseEntity; ...@@ -21,6 +22,7 @@ import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
...@@ -258,6 +260,12 @@ public class ResourceController { ...@@ -258,6 +260,12 @@ public class ResourceController {
} }
@RequestMapping(value="getResourceAllocation/{fromDate}/{toDate}",method = RequestMethod.GET ,produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<?> getUpdatedResourceAllocationsByDate(@PathVariable("") String fromDate,@PathVariable String toDate){
List<ChangedResourceVO> changedResourceVOList = resourceService.getChangedResourceByDate(fromDate,toDate);
return null;
}
} }
package com.nisum.myteam.model.vo;
import lombok.*;
import java.util.Date;
@Setter
@Getter
@NoArgsConstructor
@AllArgsConstructor
@ToString
public class ChangedResourceVO {
private String emplyeeId;
private String employeeName;
private String prevBillingStatus;
private String prevClient;
private String prevProject;
private Date prevBillingStartingDate;
private Date prevBillingEndDate;
private String currentBillingStatus;
private String currentClient;
private String currentProject;
private Date currentBillingStartingDate;
private Date currentBillingEndDate;
}
package com.nisum.myteam.model.vo;
import lombok.Getter;
import lombok.Setter;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@Setter
@Getter
public class ReportVo {
List<String> categories = new ArrayList();
List<Map<String,Object>> series = new ArrayList();
public ReportVo(){
categories.add("ES");
categories.add("CI");
categories.add("APPS");
categories.add("ACI - QE");
categories.add("ACI - DevOps");
categories.add("ACI - Support");
categories.add("I&A");
}
}
...@@ -54,6 +54,8 @@ public interface IResourceService { ...@@ -54,6 +54,8 @@ public interface IResourceService {
public List<EmployeeShiftsVO> getResourcesForShift(String shift); public List<EmployeeShiftsVO> getResourcesForShift(String shift);
public Resource getLatestResourceByEmpId(String employeeId);
// List<Resource> getAllResourcesForProject(String projectId, String status); // List<Resource> getAllResourcesForProject(String projectId, String status);
// List<Resource> getResourcesForEmployee(String empId); // List<Resource> getResourcesForEmployee(String empId);
......
...@@ -2,6 +2,7 @@ package com.nisum.myteam.service.impl; ...@@ -2,6 +2,7 @@ package com.nisum.myteam.service.impl;
import com.nisum.myteam.exception.handler.MyTeamException; import com.nisum.myteam.exception.handler.MyTeamException;
import com.nisum.myteam.model.dao.*; import com.nisum.myteam.model.dao.*;
import com.nisum.myteam.model.vo.ChangedResourceVO;
import com.nisum.myteam.model.vo.EmployeeShiftsVO; import com.nisum.myteam.model.vo.EmployeeShiftsVO;
import com.nisum.myteam.model.vo.MyProjectAllocationVO; import com.nisum.myteam.model.vo.MyProjectAllocationVO;
import com.nisum.myteam.model.vo.ResourceVO; import com.nisum.myteam.model.vo.ResourceVO;
...@@ -19,6 +20,7 @@ import org.springframework.data.mongodb.core.query.Criteria; ...@@ -19,6 +20,7 @@ import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query; import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -689,6 +691,56 @@ public class ResourceService implements IResourceService { ...@@ -689,6 +691,56 @@ public class ResourceService implements IResourceService {
return resourcesList; return resourcesList;
} }
@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;
}
public List<ChangedResourceVO> getChangedResourceByDate(String fromDatestr, String toDatestr){
// List<ChangedResourceVO> changedResourceVOList = new ArrayList();
// SimpleDateFormat format = new SimpleDateFormat("dd/MM/yyyy");
//
// try {
// final Date fromDate = format.parse(fromDatestr);
// final Date toDate = format.parse(toDatestr);
// resourceRepo.findAll().stream().
// filter(r -> r.getBillingStartDate().before(toDate)&&r.getBillingEndDate().after(fromDate)).forEach(r -> {
// ChangedResourceVO crv = new ChangedResourceVO();
// Project project = projectService.getProjectByProjectId(r.getProjectId());
// Employee emp = employeeService.getEmployeeById(r.getEmployeeId());
// Account account = accountService.getAccountById(project.getAccountId());
//
//
// if(changedResourceVOList.isEmpty()){
// crv.setEmplyeeId(r.getEmployeeId());
// crv.setEmployeeName(emp.getEmployeeName());
// crv.setPrevBillingStatus(r.getBillableStatus());
// crv.setPrevBillingStartingDate(r.getBillingStartDate());
// crv.setPrevBillingEndDate(r.getBillingEndDate());
// crv.setPrevClient(account.getAccountName());
// crv.setPrevProject(project.getProjectName());
// }else {
//
// if(!crvList.isEmpty()){
//
// }else{
//
// }
// }
// changedResourceVOList.add(crv);
// });
//
// }catch (Exception e){}
//
return null;
}
......
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