Commit 276c4723 authored by vikram singh's avatar vikram singh

Updated Move to bench and updated reports

parent c64cc99d
...@@ -78,8 +78,9 @@ public class ReportService implements IReportService { ...@@ -78,8 +78,9 @@ public class ReportService implements IReportService {
// .getAllEmployees().stream(). // .getAllEmployees().stream().
// filter(e -> e.getFunctionalGroup().equals(functionalGroup)).collect(Collectors.toList()); // filter(e -> e.getFunctionalGroup().equals(functionalGroup)).collect(Collectors.toList());
for(Employee employee:employeeList){ for(Employee employee:employeeList){
Resource resource = resourceService.getLatestResourceByEmpId(employee.getEmployeeId()); Resource resource = resourceService.getCurrentAllocationIfNotReturnNull(employee.getEmployeeId());//getCurrentAllocation(employee.getEmployeeId());
if(resource!=null && resource.getBillableStatus().equals("Billable")){ if(resource!=null && resource.getBillableStatus().equals("Billable")){
billableC++; billableC++;
}else if(resource!=null && resource.getBillableStatus().equals("Trainee")) { }else if(resource!=null && resource.getBillableStatus().equals("Trainee")) {
traineeC++; traineeC++;
...@@ -139,30 +140,77 @@ public class ReportService implements IReportService { ...@@ -139,30 +140,77 @@ public class ReportService implements IReportService {
private List<Reports> resultantEmployeeWithBillability(List<Employee> employees, private List<Reports> resultantEmployeeWithBillability(List<Employee> employees,
String billableStatus) { String billableStatus) {
List<Reports> resultantEmployees=new ArrayList<Reports>();
for(Employee employee:employees) { List<Reports> billableEmployees=new ArrayList<Reports>();
Resource resourceObj=resourceService.getLatestResourceByEmpId(employee.getEmployeeId()); List<Reports> nonBillableEmployees=new ArrayList<Reports>();
if(resourceObj.getBillableStatus().equals(billableStatus) ||( billableStatus.equals("Non-Billable") && (resourceObj.getBillableStatus().equals(Shadow)||resourceObj.getBillableStatus().equals(Reserved)))) { List<Reports> trainees=new ArrayList<Reports>();
resultantEmployees.add(mappingReports(employee,resourceObj)); for(Employee employee:employees){
Resource resource = resourceService.getCurrentAllocationIfNotReturnNull(employee.getEmployeeId());//getCurrentAllocation(employee.getEmployeeId());
if(resource!=null && resource.getBillableStatus().equals("Billable")){
billableEmployees.add(mappingReports(employee,resource));
}else if(resource!=null && resource.getBillableStatus().equals("Trainee")) {
trainees.add(mappingReports(employee,resource));
} else{
nonBillableEmployees.add(mappingReports(employee,resource));
}
}
if(billableStatus.equals("Billable")) {
return billableEmployees;
} }
else if(billableStatus.equals("Trainee")) {
return trainees;
} }
return resultantEmployees; else
return nonBillableEmployees;
// List<Reports> resultantEmployees=new ArrayList<Reports>();
// for(Employee employee:employees) {
// Resource resourceObj=resourceService.getCurrentAllocation(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;
} }
// if(!resourceService.isAllocationActiveToday(resourceObj) && billableStatus.equals("Non-Billable")) {
// //resultantEmployees.add((mappingReports)
// }
private Reports mappingReports(Employee employee,Resource resourceObj){ private Reports mappingReports(Employee employee,Resource resourceObj){
Reports Reports=new Reports(); Reports Reports=new Reports();
Project project=projectService.getProjectByProjectId(resourceObj.getProjectId());
Reports.setEmployeeId(resourceObj.getEmployeeId());
Reports.setEmployeeName(employee.getEmployeeName()); Reports.setEmployeeName(employee.getEmployeeName());
Reports.setEmailId(employee.getEmailId()); Reports.setEmailId(employee.getEmailId());
Reports.setFunctionalGroup(employee.getFunctionalGroup());
Reports.setEmployeeId(employee.getEmployeeId());
// Reports.setBillableStatus("BillingEnded");
if(resourceObj!=null) {
Project project=projectService.getProjectByProjectId(resourceObj.getProjectId());
Reports.setProjectName(project.getProjectName()); Reports.setProjectName(project.getProjectName());
Reports.setBillingStartDate(resourceObj.getBillingStartDate()); Reports.setBillingStartDate(resourceObj.getBillingStartDate());
Reports.setBillableStatus(resourceObj.getBillableStatus()); Reports.setBillableStatus(resourceObj.getBillableStatus());
Reports.setBillingEndDate(resourceObj.getBillingEndDate()); Reports.setBillingEndDate(resourceObj.getBillingEndDate());
Reports.setFunctionalGroup(employee.getFunctionalGroup()); }
return Reports; return Reports;
} }
// 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;
// }
@Override @Override
public Project getProjectById(String projectId) { public Project getProjectById(String projectId) {
return projectService.getProjectByProjectId(projectId); return projectService.getProjectByProjectId(projectId);
......
...@@ -127,7 +127,7 @@ public class ResourceService implements IResourceService { ...@@ -127,7 +127,7 @@ public class ResourceService implements IResourceService {
Resource resource = resourceRepo.findById(resourceReq.getId()); Resource resource = resourceRepo.findById(resourceReq.getId());
if (resource != null) { if (resource != null) {
if(!resourceReq.getStatus().equalsIgnoreCase(MyTeamUtils.RELEASED_STATUS)){ if(!resourceReq.getStatus().equalsIgnoreCase(MyTeamUtils.STATUS_RELEASED)){
Resource latestAllocation = this.getLatestAllocation(resourceRepo.findByEmployeeId(resourceReq.getEmployeeId())); Resource latestAllocation = this.getLatestAllocation(resourceRepo.findByEmployeeId(resourceReq.getEmployeeId()));
if(latestAllocation!=null && !latestAllocation.getProjectId().equalsIgnoreCase(resourceReq.getProjectId())&& if(latestAllocation!=null && !latestAllocation.getProjectId().equalsIgnoreCase(resourceReq.getProjectId())&&
...@@ -503,7 +503,7 @@ public class ResourceService implements IResourceService { ...@@ -503,7 +503,7 @@ public class ResourceService implements IResourceService {
if (statusFlag.equals(ResourceStatus.ACTIVE.getStatus()) && resource.getStatus().equals(MyTeamUtils.STATUS_ENGAGED)) { if (statusFlag.equals(ResourceStatus.ACTIVE.getStatus()) && resource.getStatus().equals(MyTeamUtils.STATUS_ENGAGED)) {
resourceVO.setResourceStatus(ResourceStatus.ACTIVE.getStatus()); resourceVO.setResourceStatus(ResourceStatus.ACTIVE.getStatus());
resourcesList.add(resourceVO); resourcesList.add(resourceVO);
} else if (statusFlag.equals(ResourceStatus.IN_ACTIVE.getStatus()) && resource.getStatus().equals(MyTeamUtils.RELEASED_STATUS)) { } else if (statusFlag.equals(ResourceStatus.IN_ACTIVE.getStatus()) && resource.getStatus().equals(MyTeamUtils.STATUS_RELEASED)) {
resourceVO.setResourceStatus(ResourceStatus.IN_ACTIVE.getStatus()); resourceVO.setResourceStatus(ResourceStatus.IN_ACTIVE.getStatus());
resourcesList.add(resourceVO); resourcesList.add(resourceVO);
} else if (statusFlag.equals(MyTeamUtils.STATUS_PROPOSED) && resource.getStatus().equals(MyTeamUtils.STATUS_PROPOSED)){ } else if (statusFlag.equals(MyTeamUtils.STATUS_PROPOSED) && resource.getStatus().equals(MyTeamUtils.STATUS_PROPOSED)){
...@@ -706,7 +706,7 @@ public class ResourceService implements IResourceService { ...@@ -706,7 +706,7 @@ public class ResourceService implements IResourceService {
resourceBench.setProjectId(MyTeamUtils.BENCH_PROJECT_ID); resourceBench.setProjectId(MyTeamUtils.BENCH_PROJECT_ID);
resourceBench.setEmployeeId(employee.getEmployeeId()); resourceBench.setEmployeeId(employee.getEmployeeId());
resourceBench.setResourceRole(employee.getRole()); resourceBench.setResourceRole(employee.getRole());
resourceBench.setStatus(MyTeamUtils.RELEASED_STATUS); resourceBench.setStatus(MyTeamUtils.STATUS_RELEASED);
resourceBench.setBillingStartDate(employee.getDateOfJoining() != null ? employee.getDateOfJoining() : new Date()); resourceBench.setBillingStartDate(employee.getDateOfJoining() != null ? employee.getDateOfJoining() : new Date());
resourceBench.setBillableStatus(MyTeamUtils.BENCH_BILLABILITY_STATUS); resourceBench.setBillableStatus(MyTeamUtils.BENCH_BILLABILITY_STATUS);
resourceBench.setEmployeeId(employee.getEmployeeId()); resourceBench.setEmployeeId(employee.getEmployeeId());
...@@ -968,8 +968,12 @@ public class ResourceService implements IResourceService { ...@@ -968,8 +968,12 @@ public class ResourceService implements IResourceService {
} }
public Resource sendResourceToOpenPool(Resource resource,String loginId) { public Resource sendResourceToOpenPool(Resource resource,String loginId) {
Resource proposedResource=resourceRepo.findOneByEmployeeIdAndStatus(resource.getEmployeeId(),MyTeamUtils.STATUS_PROPOSED);
Resource existingresource = resourceRepo.findById(resource.getId()); Resource existingresource = resourceRepo.findById(resource.getId());
existingresource.setStatus(MyTeamUtils.RELEASED_STATUS);
existingresource.setStatus(MyTeamUtils.STATUS_RELEASED);
this.updateExistedResource(existingresource); this.updateExistedResource(existingresource);
// isResourceAvailableinBenchbygraterthanEndDate= // isResourceAvailableinBenchbygraterthanEndDate=
...@@ -979,9 +983,15 @@ public class ResourceService implements IResourceService { ...@@ -979,9 +983,15 @@ public class ResourceService implements IResourceService {
benchResource.setEmployeeId(resource.getEmployeeId()); benchResource.setEmployeeId(resource.getEmployeeId());
benchResource.setResourceRole(resource.getResourceRole()); benchResource.setResourceRole(resource.getResourceRole());
benchResource.setBillingStartDate(MyTeamDateUtils.getDayMoreThanDate(resource.getBillingEndDate())); benchResource.setBillingStartDate(MyTeamDateUtils.getDayMoreThanDate(resource.getBillingEndDate()));
if(proposedResource!=null) {
benchResource.setBillingEndDate(MyTeamDateUtils.getDayLessThanDate(proposedResource.getBillingStartDate()));
}
else {
benchResource.setBillingEndDate(projectService.getProjectByProjectId(MyTeamUtils.BENCH_PROJECT_ID).getProjectEndDate()); benchResource.setBillingEndDate(projectService.getProjectByProjectId(MyTeamUtils.BENCH_PROJECT_ID).getProjectEndDate());
}
benchResource.setBillableStatus(MyTeamUtils.BENCH_BILLABILITY_STATUS); benchResource.setBillableStatus(MyTeamUtils.BENCH_BILLABILITY_STATUS);
benchResource.setStatus(MyTeamUtils.RELEASED_STATUS); benchResource.setStatus(MyTeamUtils.STATUS_RELEASED);
benchResource.setAuditFields(loginId, MyTeamUtils.CREATE); benchResource.setAuditFields(loginId, MyTeamUtils.CREATE);
Resource resourcePers = resourceRepo.save(benchResource); Resource resourcePers = resourceRepo.save(benchResource);
respMap.put("statusCode", 801); respMap.put("statusCode", 801);
...@@ -993,6 +1003,9 @@ public class ResourceService implements IResourceService { ...@@ -993,6 +1003,9 @@ public class ResourceService implements IResourceService {
public Resource getCurrentAllocation(String employeeId) { public Resource getCurrentAllocation(String employeeId) {
return resourceRepo.findByEmployeeId(employeeId).stream().filter(resource-> isAllocationActiveToday(resource)).findAny().orElse(getLatestResourceByEmpId(employeeId)); return resourceRepo.findByEmployeeId(employeeId).stream().filter(resource-> isAllocationActiveToday(resource)).findAny().orElse(getLatestResourceByEmpId(employeeId));
} }
public Resource getCurrentAllocationIfNotReturnNull(String employeeId) {
return resourceRepo.findByEmployeeId(employeeId).stream().filter(resource-> isAllocationActiveToday(resource)).findAny().orElse(null);
}
} }
//class //class
......
...@@ -13,7 +13,7 @@ public class MyTeamUtils { ...@@ -13,7 +13,7 @@ public class MyTeamUtils {
//public final static String driverUrl = "jdbc:ucanaccess://"; //public final static String driverUrl = "jdbc:ucanaccess://";
//public final static String msdriveUrl ="jdbc:sqlserver://"; //public final static String msdriveUrl ="jdbc:sqlserver://";
public final static String RELEASED_STATUS="Released"; public final static String STATUS_RELEASED="Released";
public final static String STATUS_ENGAGED ="Engaged"; public final static String STATUS_ENGAGED ="Engaged";
public static final String STATUS_PROPOSED ="Proposed" ; public static final String STATUS_PROPOSED ="Proposed" ;
......
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