Commit 570708e6 authored by vikram singh's avatar vikram singh

Updated Report By FG service

parent 099feaf1
...@@ -7,6 +7,7 @@ import org.springframework.data.mongodb.repository.MongoRepository; ...@@ -7,6 +7,7 @@ import org.springframework.data.mongodb.repository.MongoRepository;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Set;
public interface ResourceRepo public interface ResourceRepo
extends MongoRepository<Resource, String> { extends MongoRepository<Resource, String> {
...@@ -24,6 +25,8 @@ public interface ResourceRepo ...@@ -24,6 +25,8 @@ public interface ResourceRepo
List<Resource> findByBillingStartDateGreaterThan(Date billingStartDate); List<Resource> findByBillingStartDateGreaterThan(Date billingStartDate);
List<Resource> findByBillingStartDateBetween(Date fromDate,Date toDate); List<Resource> findByBillingStartDateBetween(Date fromDate,Date toDate);
//Set<Resource> findByBillableStatus(String resourceAllocationStatus);
// List<Resource> findByEmployeeIdAndActive(String employeeId, boolean status); // List<Resource> findByEmployeeIdAndActive(String employeeId, boolean status);
......
...@@ -10,6 +10,7 @@ import com.nisum.myteam.model.vo.ResourceVO; ...@@ -10,6 +10,7 @@ import com.nisum.myteam.model.vo.ResourceVO;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Set;
public interface IResourceService { public interface IResourceService {
...@@ -64,7 +65,7 @@ public interface IResourceService { ...@@ -64,7 +65,7 @@ public interface IResourceService {
public List<ReserveReportsVO> getResourceReportsByBillingStatus(String resourceStatus); public List<ReserveReportsVO> getResourceReportsByBillingStatus(String resourceStatus);
List<Resource> findByBillableStatus(String billableStatus); Set<Resource> findByBillableStatus(String billableStatus);
// List<Resource> getAllResourcesForProject(String projectId, String status); // List<Resource> getAllResourcesForProject(String projectId, String status);
......
...@@ -5,6 +5,7 @@ import java.util.Comparator; ...@@ -5,6 +5,7 @@ import java.util.Comparator;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -343,40 +344,16 @@ public class EmployeeService implements IEmployeeService { ...@@ -343,40 +344,16 @@ public class EmployeeService implements IEmployeeService {
} }
@Override @Override
public List<BillableEmployee> getEmployeeDetailsByFGAndBillability(String fGroup, String billableStatus) { public List<BillableEmployee> getEmployeeDetailsByFGAndBillability(String fGroup, String billableStatus) {
Map<String,Resource> resourceMap=resourceService.findByBillableStatus(billableStatus).stream().collect(Collectors.toMap(e->e.getEmployeeId(), e->e));
List<Resource> resources=resourceService.findByBillableStatus(billableStatus); return employeeRepo.findByEmpStatusAndFunctionalGroup(ResourceStatus.ACTIVE.getStatus(), fGroup).stream().filter(e->resourceMap.keySet().contains(e.getEmployeeId())).map(e-> mappingBillableEmployee(e,fGroup,resourceMap)).collect(Collectors.toList());
return getBillableEmployeeByfunctionalGroup(fGroup,resources);
} }
private BillableEmployee mappingBillableEmployee(Employee e,String fGroup,Map<String,Resource> resourceMap ) {
Resource resource=resourceMap.get(e.getEmployeeId());
private List<BillableEmployee> getBillableEmployeeByfunctionalGroup(String fGroup, List<Resource> resources) { Project project=projectService.getProjectByProjectId(resource.getProjectId());
return new BillableEmployee(e.getEmployeeId(),e.getEmployeeName(),e.getEmailId(),project.getProjectName(),resource.getBillableStatus(),resource.getBillingStartDate(),resource.getBillingEndDate(),fGroup);
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;
} }
} }
...@@ -843,8 +843,9 @@ public class ResourceService implements IResourceService { ...@@ -843,8 +843,9 @@ public class ResourceService implements IResourceService {
return allocationList; return allocationList;
} }
@Override @Override
public List<Resource> findByBillableStatus(String billableStatus) { public Set<Resource> findByBillableStatus(String billableStatus) {
return resourceRepo.findByBillableStatus(billableStatus); List<String> uniqueEmployeeIds=new ArrayList<>();
return resourceRepo.findByBillableStatus(billableStatus).stream().filter(e->!uniqueEmployeeIds.contains(e.getEmployeeId())).map(e->{uniqueEmployeeIds.add(e.getEmployeeId()); return e;}).collect(Collectors.toSet());
} }
......
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