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