Commit 3f3ed5bd authored by Md Suleman's avatar Md Suleman

Updated status propesed in resource response

parent ade1a202
......@@ -50,6 +50,7 @@ public class ResourceService implements IResourceService {
public HashMap<String, Object> respMap = new HashMap<>();
private Resource getLatestAllocation(List<Resource> resourceAllocList) {
Resource latestAlloc = null;
if (!resourceAllocList.isEmpty()) {
......@@ -70,14 +71,13 @@ public class ResourceService implements IResourceService {
public Resource addResource(Resource resourceReq, String loginEmpId) throws MyTeamException {
List<Resource> resourceAllocationList = resourceRepo.findByEmployeeId(resourceReq.getEmployeeId());
Resource prevAllocation = getLatestAllocation(
resourceAllocationList.stream().filter(r -> isAllocationActiveToday(r)).collect(Collectors.toList()));
Resource prevAllocation = getLatestAllocation(resourceAllocationList.stream().filter(r -> isAllocationActiveToday(r)).collect(Collectors.toList()));
Resource resourcePers = null;
if (prevAllocation != null) {
if(prevAllocation != null){
prevAllocation.setBillingEndDate(MyTeamDateUtils.getDayLessThanDate(resourceReq.getBillingStartDate()));
this.updateExistedResource(prevAllocation); // updateLatestProjectAllocationToEnd
resourcePers = resourceRepo.save(resourceReq); // createNewProjectAllocationtoStart
this.updateExistedResource(prevAllocation); //updateLatestProjectAllocationToEnd
resourcePers = resourceRepo.save(resourceReq); //createNewProjectAllocationtoStart
}
return resourcePers;
}
......@@ -96,6 +96,7 @@ public class ResourceService implements IResourceService {
return isExists;
}
public void updateResourceDetails(Resource resourceReq, String loginEmpId) throws MyTeamException {
// List<Resource> resourceAllocList = resourceRepo.findByEmployeeIdAndProjectId(resourceReq.getEmployeeId(), resourceReq.getProjectId());
......@@ -126,35 +127,30 @@ public class ResourceService implements IResourceService {
Resource resource = resourceRepo.findById(resourceReq.getId());
if (resource != null) {
if (!resourceReq.getStatus().equalsIgnoreCase(MyTeamUtils.RELEASED_STATUS)) {
Resource latestAllocation = this
.getLatestAllocation(resourceRepo.findByEmployeeId(resourceReq.getEmployeeId()));
if(!resourceReq.getStatus().equalsIgnoreCase(MyTeamUtils.RELEASED_STATUS)){
Resource latestAllocation = this.getLatestAllocation(resourceRepo.findByEmployeeId(resourceReq.getEmployeeId()));
if (latestAllocation != null
&& !latestAllocation.getProjectId().equalsIgnoreCase(resourceReq.getProjectId())
&& !latestAllocation.getBillingStartDate().after(resourceReq.getBillingEndDate())) {
if(latestAllocation!=null && !latestAllocation.getProjectId().equalsIgnoreCase(resourceReq.getProjectId())&&
!latestAllocation.getBillingStartDate().after(resourceReq.getBillingEndDate())) {
respMap.put("statusCode", 811);
respMap.put("message",
"Resource is already allocated after " + latestAllocation.getBillingStartDate());
} else {
respMap.put("message", "Resource is already allocated after "+latestAllocation.getBillingStartDate());
}else{
if (resourceReq.getBillingEndDate().compareTo(new Date()) < 0) {
resourceReq.setStatus(MyTeamUtils.RELEASED_STATUS);// update Status of allocation
resourceReq.setStatus(MyTeamUtils.RELEASED_STATUS);//update Status of allocation
Resource resourceBench = new Resource();
resourceBench.setProjectId(MyTeamUtils.BENCH_PROJECT_ID);
resourceBench.setEmployeeId(resourceReq.getEmployeeId());
resourceBench.setResourceRole(resourceReq.getResourceRole());
resourceBench.setStatus(MyTeamUtils.RELEASED_STATUS);// add alocation status as Released
resourceBench.setBillingStartDate(
MyTeamDateUtils.getDayMoreThanDate(resourceReq.getBillingEndDate()));
resourceBench.setBillingEndDate(
projectService.getProjectByProjectId(MyTeamUtils.BENCH_PROJECT_ID).getProjectEndDate());
resourceBench.setStatus(MyTeamUtils.RELEASED_STATUS);//add alocation status as Released
resourceBench.setBillingStartDate(MyTeamDateUtils.getDayMoreThanDate(resourceReq.getBillingEndDate()));
resourceBench.setBillingEndDate(projectService.getProjectByProjectId(MyTeamUtils.BENCH_PROJECT_ID).getProjectEndDate());
resourceBench.setBillableStatus(MyTeamUtils.BENCH_BILLABILITY_STATUS);
resourceBench.setAuditFields(loginEmpId, MyTeamUtils.CREATE);
resourceRepo.save(resourceBench);
}
this.updateExistedResource(resourceReq);
}
} else {
}else{
respMap.put("statusCode", 811);
respMap.put("message", "Resource is already released from you, And you can't update this allocation");
}
......@@ -190,8 +186,7 @@ public class ResourceService implements IResourceService {
public boolean validateAllocationAgainstPrevAllocation(Resource resourceReq) {
boolean isValid = true;
List<Resource> resourceAllocList = resourceRepo.findByEmployeeIdAndProjectId(resourceReq.getEmployeeId(),
resourceReq.getProjectId());
List<Resource> resourceAllocList = resourceRepo.findByEmployeeIdAndProjectId(resourceReq.getEmployeeId(), resourceReq.getProjectId());
Resource prevAllocation = this.getLatestAllocation(resourceAllocList);
if (prevAllocation != null) {
if (!prevAllocation.getBillingStartDate().before(resourceReq.getBillingStartDate())) {
......@@ -208,8 +203,7 @@ public class ResourceService implements IResourceService {
return isValid;
}
public boolean validateBillingStartEndDateAgainstProjectStartEndDate(Resource resource, String loginEmpId)
throws MyTeamException {
public boolean validateBillingStartEndDateAgainstProjectStartEndDate(Resource resource, String loginEmpId) throws MyTeamException {
boolean isValid = true;
......@@ -232,10 +226,7 @@ public class ResourceService implements IResourceService {
log.info("ResourceALloc Req::" + resource);
log.info("" + project.getProjectEndDate().toString());
// if
// (!resourceAllocation.getBillingEndDate().before(project.getProjectEndDate())||
// !resourceAllocation.getBillingEndDate().equals(project.getProjectEndDate()))
// {
//if (!resourceAllocation.getBillingEndDate().before(project.getProjectEndDate())|| !resourceAllocation.getBillingEndDate().equals(project.getProjectEndDate())) {
if (!(resource.getBillingEndDate().compareTo(project.getProjectEndDate()) <= 0)) {
log.info("Billing end date should be on or before Project End Date.");
respMap.put("statusCode", 813);
......@@ -247,6 +238,7 @@ public class ResourceService implements IResourceService {
return isValid;
}
public boolean validateBillingStartDateAgainstDOJ(Resource resource) {
String message = "";
boolean isValid = true;
......@@ -264,58 +256,51 @@ public class ResourceService implements IResourceService {
return isValid;
}
public boolean isResourceAvailable(Resource resourceReq) {
boolean isAssigned = true;
String message = "";
List<Resource> resourceAllocList = resourceRepo.findByEmployeeId(resourceReq.getEmployeeId()); // getting all
// allocations
// of employee
Resource resourceLatestRecord = getLatestAllocation(
resourceAllocList.stream().filter(r -> r.getProjectId().equalsIgnoreCase(MyTeamUtils.BENCH_PROJECT_ID))
.collect(Collectors.toList())); // getting latest allocation of employee in bench project
if (resourceLatestRecord != null && !isAllocationActiveToday(resourceLatestRecord)) {
Resource latestProjectResource = getLatestAllocation(resourceAllocList.stream()
.filter(r -> !r.getProjectId().equalsIgnoreCase(MyTeamUtils.BENCH_PROJECT_ID))
.collect(Collectors.toList()));
if (!resourceReq.getProjectId().equalsIgnoreCase(latestProjectResource.getProjectId())) {
List<Resource> resourceAllocList = resourceRepo.findByEmployeeId(resourceReq.getEmployeeId()); //getting all allocations of employee
Resource resourceLatestRecord = getLatestAllocation(resourceAllocList.stream().
filter(r -> r.getProjectId().equalsIgnoreCase(MyTeamUtils.BENCH_PROJECT_ID)).collect(Collectors.toList())); //getting latest allocation of employee in bench project
if (resourceLatestRecord != null && !isAllocationActiveToday(resourceLatestRecord)){
Resource latestProjectResource = getLatestAllocation(resourceAllocList.stream().
filter(r -> !r.getProjectId().equalsIgnoreCase(MyTeamUtils.BENCH_PROJECT_ID)).collect(Collectors.toList()));
if(!resourceReq.getProjectId().equalsIgnoreCase(latestProjectResource.getProjectId())) {
message = "Resource " + latestProjectResource.getEmployeeId() + " already Assigned to the "
+ projectService.getProjectByProjectId(latestProjectResource.getProjectId()).getProjectName()
+ " Project" + " from " + latestProjectResource.getBillingStartDate() + "to "
+ latestProjectResource.getBillingEndDate();
+ " Project" + " from " + latestProjectResource.getBillingStartDate() + "to " + latestProjectResource.getBillingEndDate();
isAssigned = false;
respMap.put("statusCode", 815);
respMap.put("message", message);
}
} else {
if (!validateResourceBillingEndDateAgainstBench(resourceReq)) {
}else{
if(!validateResourceBillingEndDateAgainstBench(resourceReq)){
isAssigned = false;
}
}
return isAssigned;
}
public boolean validateResourceBillingEndDateAgainstBench(Resource resourceReq) {
public boolean validateResourceBillingEndDateAgainstBench(Resource resourceReq){
boolean isValid = true;
String message = "";
List<Resource> resourceAllocList = resourceRepo.findByEmployeeIdAndProjectId(resourceReq.getEmployeeId(),
MyTeamUtils.BENCH_PROJECT_ID);
List<Resource> resourceAllocList = resourceRepo.findByEmployeeIdAndProjectId(resourceReq.getEmployeeId(),MyTeamUtils.BENCH_PROJECT_ID);
Resource resourceBenchLatestRecord = getLatestAllocation(
resourceAllocList.stream().filter(r -> r.getProjectId().equalsIgnoreCase(MyTeamUtils.BENCH_PROJECT_ID))
.collect(Collectors.toList()));
Resource resourceBenchLatestRecord = getLatestAllocation(resourceAllocList.stream().
filter(r -> r.getProjectId().equalsIgnoreCase(MyTeamUtils.BENCH_PROJECT_ID)).collect(Collectors.toList()));
if (!isAllocationActiveToday(resourceBenchLatestRecord)) {
if(!isAllocationActiveToday(resourceBenchLatestRecord)){
isValid = false;
message = "Resource is not available for allocation";
} else if (!(resourceReq.getBillingEndDate().before(resourceBenchLatestRecord.getBillingEndDate())
&& resourceReq.getBillingStartDate().after(resourceBenchLatestRecord.getBillingStartDate()))) {
message = "Resource is available from " + resourceBenchLatestRecord.getBillingStartDate() + " to "
+ resourceBenchLatestRecord.getBillingEndDate();
}else if(!(resourceReq.getBillingEndDate().before(resourceBenchLatestRecord.getBillingEndDate()) &&
resourceReq.getBillingStartDate().after(resourceBenchLatestRecord.getBillingStartDate()))){
message = "Resource is available from "+resourceBenchLatestRecord.getBillingStartDate()+" to "+resourceBenchLatestRecord.getBillingEndDate();
isValid = false;
}
respMap.put("statusCode", 810);
......@@ -323,36 +308,35 @@ public class ResourceService implements IResourceService {
return isValid;
}
public boolean isAllocationActiveToday(Resource resource) {
public boolean isAllocationActiveToday(Resource resource){
boolean isActive = true;
if (resource.getBillingStartDate().compareTo(new Date()) <= 0
&& resource.getBillingEndDate().compareTo(new Date()) >= 0) {
if(resource.getBillingStartDate().compareTo(new Date()) <=0 &&
resource.getBillingEndDate().compareTo(new Date())>=0){
isActive = true;
} else {
}else{
isActive = false;
}
return isActive;
}
public void deleteResource(Resource resourceReq, String loginEmpId) {
resourceRepo.delete(resourceReq);
}
public void deleteAndUpdateAllocation(Resource resourceReq, String loginEmpId) {
public void deleteAndUpdateAllocation(Resource resourceReq,String loginEmpId){
List<Resource> empAllAllocations = resourceRepo.findByEmployeeId(resourceReq.getEmployeeId());
Resource latestAllocation = this.getLatestAllocation(empAllAllocations.stream()
.filter(r -> !r.getId().equals(resourceReq.getId())).collect(Collectors.toList()));
Resource latestAllocation = this.getLatestAllocation(empAllAllocations.stream().filter(r -> !r.getId().equals(resourceReq.getId())).collect(Collectors.toList()));
Resource resource = resourceRepo.findById(resourceReq.getId());
if (resource != null) {
if (latestAllocation != null
&& latestAllocation.getProjectId().equalsIgnoreCase(MyTeamUtils.BENCH_PROJECT_ID)) {
latestAllocation.setBillingEndDate(
projectService.getProjectByProjectId(MyTeamUtils.BENCH_PROJECT_ID).getProjectEndDate());
if(resource != null) {
if (latestAllocation != null && latestAllocation.getProjectId().equalsIgnoreCase(MyTeamUtils.BENCH_PROJECT_ID)) {
latestAllocation.setBillingEndDate(projectService.getProjectByProjectId(MyTeamUtils.BENCH_PROJECT_ID).getProjectEndDate());
this.updateExistedResource(latestAllocation);
}
this.deleteResource(resourceReq, loginEmpId);
}else {
}else{
respMap.put("statusCode", 811);
respMap.put("message", "Record Not Found");
}
......@@ -363,6 +347,7 @@ public class ResourceService implements IResourceService {
return resourceRepo.findAll();
}
public List<ResourceVO> getAllResourcesVO() {
return getAllResources().stream().map(resource -> {
......@@ -395,8 +380,7 @@ public class ResourceService implements IResourceService {
}
}
// Account
// account=accountService.getAccountById(domainService.getDomainById(project.getProjectId()).getAccountId());
//Account account=accountService.getAccountById(domainService.getDomainById(project.getProjectId()).getAccountId());
resourceVO.setBillableStatus(resource.getBillableStatus());
resourceVO.setBillingStartDate(resource.getBillingStartDate());
......@@ -437,6 +421,7 @@ public class ResourceService implements IResourceService {
return resourcesList;
}
public List<ResourceVO> prepareProjectTeamMembersList(String projectId) {
List<ResourceVO> finalResourcesList = new ArrayList<>();
Employee employee = null;
......@@ -476,6 +461,7 @@ public class ResourceService implements IResourceService {
return resourceRepo.findByProjectId(projectId);
}
@Override
public List<Resource> getAllResourcesForAllActiveProjects() {
List<Resource> resourceList = new ArrayList<>();
......@@ -487,6 +473,7 @@ public class ResourceService implements IResourceService {
return resourceList;
}
@Override
public List<ResourceVO> getResourcesForProject(String projectId, String statusFlag) {
List<ResourceVO> resourcesList = new ArrayList<>();
......@@ -498,8 +485,7 @@ public class ResourceService implements IResourceService {
ResourceVO resourceVO = new ResourceVO();
resourceVO.setId(resource.getId());
resourceVO.setProjectId(resource.getProjectId());
resourceVO
.setProjectName(projectService.getProjectByProjectId(resource.getProjectId()).getProjectName());
resourceVO.setProjectName(projectService.getProjectByProjectId(resource.getProjectId()).getProjectName());
resourceVO.setResourceRole(resource.getResourceRole());
resourceVO.setBillingStartDate(resource.getBillingStartDate());
resourceVO.setBillingEndDate(resource.getBillingEndDate());
......@@ -512,15 +498,18 @@ public class ResourceService implements IResourceService {
resourceVO.setEmployeeName(employee.getEmployeeName());
resourceVO.setDesignation(employee.getDesignation());
// Active
if (statusFlag.equals(ResourceStatus.ACTIVE.getStatus()) && billingEndDate.compareTo(new Date()) >= 0) {
resourceVO.setResourceStatus(ResourceStatus.ACTIVE.getStatus());
resourcesList.add(resourceVO);
} else if (statusFlag.equals(ResourceStatus.IN_ACTIVE.getStatus())
&& billingEndDate.compareTo(new Date()) < 0) {
} else if (statusFlag.equals(ResourceStatus.IN_ACTIVE.getStatus()) && billingEndDate.compareTo(new Date()) < 0) {
resourceVO.setResourceStatus(ResourceStatus.IN_ACTIVE.getStatus());
resourcesList.add(resourceVO);
} else if (statusFlag.equals(MyTeamUtils.BOTH))
} else if (statusFlag.equals(MyTeamUtils.STATUS_PROPOSED) && resource.getStatus().equals(MyTeamUtils.STATUS_PROPOSED)){
resourceVO.setResourceStatus(MyTeamUtils.STATUS_PROPOSED);
resourcesList.add(resourceVO);
}else if (statusFlag.equals(MyTeamUtils.BOTH))
resourcesList.add(resourceVO);
}
......@@ -529,6 +518,7 @@ public class ResourceService implements IResourceService {
return resourcesList;
}
@Override
public List<MyProjectAllocationVO> getWorkedProjectsForResource(String empId) {
......@@ -540,8 +530,7 @@ public class ResourceService implements IResourceService {
List<Resource> resourcesAllocatedList = resourceRepo.findByEmployeeId(empId);
if (null != resourcesAllocatedList && !resourcesAllocatedList.isEmpty()
&& MyTeamUtils.INT_ZERO < resourcesAllocatedList.size()) {
if (null != resourcesAllocatedList && !resourcesAllocatedList.isEmpty() && MyTeamUtils.INT_ZERO < resourcesAllocatedList.size()) {
for (Resource resourceAlloc : resourcesAllocatedList) {
project = projectService.getProjectByProjectId(resourceAlloc.getProjectId());
......@@ -576,6 +565,7 @@ public class ResourceService implements IResourceService {
return myProjectList;
}
@Override
public List<Resource> getResourcesUnderDeliveryLead(String deliveryLeadId) {
List<String> projectIdsList = new ArrayList<>();
......@@ -595,17 +585,15 @@ public class ResourceService implements IResourceService {
}
@Override
public List<ResourceVO> getBillingsForEmployee(String empId) {
List<ResourceVO> finalList = new ArrayList<>();
List<Resource> resourcesList = resourceRepo.findByEmployeeId(empId);
if (resourcesList != null && resourcesList.size() > 0) {
log.info("The resources billing list before sorting::" + resourcesList);
// return
// billingsList.stream().sorted(Comparator.comparing(Billing::getCreatedOn).reversed()).collect(Collectors.toList());
List<Resource> sortedList = resourcesList.stream()
.sorted(Comparator.comparing(Resource::getBillingStartDate).reversed())
.collect(Collectors.toList());
//return billingsList.stream().sorted(Comparator.comparing(Billing::getCreatedOn).reversed()).collect(Collectors.toList());
List<Resource> sortedList = resourcesList.stream().sorted(Comparator.comparing(Resource::getBillingStartDate).reversed()).collect(Collectors.toList());
finalList = convertResourcesToResourcesVO(sortedList);
}
......@@ -619,14 +607,13 @@ public class ResourceService implements IResourceService {
if (resourcesList == null || resourcesList.size() == 0) {
return resourcesList;
} else {
// return
// billingsList.stream().sorted(Comparator.comparing(Billing::getCreatedOn).reversed()).collect(Collectors.toList());
return resourcesList.stream().sorted(Comparator.comparing(Resource::getBillingStartDate).reversed())
.collect(Collectors.toList());
//return billingsList.stream().sorted(Comparator.comparing(Billing::getCreatedOn).reversed()).collect(Collectors.toList());
return resourcesList.stream().sorted(Comparator.comparing(Resource::getBillingStartDate).reversed()).collect(Collectors.toList());
}
}
@Override
public List<Employee> getUnAssignedEmployees() {
......@@ -648,6 +635,7 @@ public class ResourceService implements IResourceService {
return notAssignedEmployees;
}
public void deleteResourcesUnderProject(String projectId) {
Query query = new Query(Criteria.where("projectId").is(projectId));
List<Resource> list = mongoTemplate.find(query, Resource.class);
......@@ -655,6 +643,7 @@ public class ResourceService implements IResourceService {
resourceRepo.delete(list);
}
private List<ResourceVO> convertResourcesToResourcesVO(List<Resource> resourcesList) {
List<ResourceVO> finalList = new ArrayList<>();
......@@ -689,8 +678,7 @@ public class ResourceService implements IResourceService {
}
}
// Account
// account=accountService.getAccountById(domainService.getDomainById(project.getProjectId()).getAccountId());
//Account account=accountService.getAccountById(domainService.getDomainById(project.getProjectId()).getAccountId());
resourceVO.setBillableStatus(resource.getBillableStatus());
resourceVO.setBillingStartDate(resource.getBillingStartDate());
......@@ -709,6 +697,7 @@ public class ResourceService implements IResourceService {
return finalList;
}
@Override
public Resource addResourceToBenchProject(Employee employee, String loginEmpId) throws MyTeamException {
Resource resourcePersisted = null;
......@@ -718,18 +707,17 @@ public class ResourceService implements IResourceService {
resourceBench.setEmployeeId(employee.getEmployeeId());
resourceBench.setResourceRole(employee.getRole());
resourceBench.setStatus(MyTeamUtils.RELEASED_STATUS);
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.setEmployeeId(employee.getEmployeeId());
resourceBench.setBillingEndDate(
projectService.getProjectByProjectId(MyTeamUtils.BENCH_PROJECT_ID).getProjectEndDate());
resourceBench.setBillingEndDate(projectService.getProjectByProjectId(MyTeamUtils.BENCH_PROJECT_ID).getProjectEndDate());
resourcePersisted = addResource(resourceBench, loginEmpId);
return resourcePersisted;
}
@Override
public List<EmployeeShiftsVO> getResourcesForShift(String shift) {
List<Resource> resourcesListPers = null;
......@@ -764,14 +752,13 @@ public class ResourceService implements IResourceService {
if (employee != null) {
if (shift.equalsIgnoreCase(employee.getShift()))
resourcesList.add(shiftsVO);
else if (employee.getShift() == null
&& Shifts.SHIFT1.getShiftType().equalsIgnoreCase(shift))
else if (employee.getShift() == null && Shifts.SHIFT1.getShiftType().equalsIgnoreCase(shift))
resourcesList.add(shiftsVO);
}
}
} // for
}//for
}
}
......@@ -785,6 +772,7 @@ public class ResourceService implements IResourceService {
}
@Override
public List<Resource> getResourcesByBillingStatus(String resourceStatus) {
return resourceRepo.findByBillableStatus(resourceStatus);
......@@ -804,14 +792,12 @@ public class ResourceService implements IResourceService {
for (Resource resource : resourcesList) {
ReserveReportsVO reserveReportsVO = new ReserveReportsVO();
reserveReportsVO.setEmployeeId(resource.getEmployeeId());
reserveReportsVO
.setEmployeeName(employeeService.getEmployeeById(resource.getEmployeeId()).getEmployeeName());
reserveReportsVO.setEmployeeName(employeeService.getEmployeeById(resource.getEmployeeId()).getEmployeeName());
if (StringUtils.isNotBlank(resource.getProjectId())) {
project = projectService.getProjectByProjectId(resource.getProjectId());
if (project != null) {
reserveReportsVO.setProjectName(project.getProjectName());
reserveReportsVO
.setAccountName(accountService.getAccountById(project.getAccountId()).getAccountName());
reserveReportsVO.setAccountName(accountService.getAccountById(project.getAccountId()).getAccountName());
}
}
......@@ -827,10 +813,11 @@ public class ResourceService implements IResourceService {
}
@Override
public List<Resource> getResourceByProjectId(String projectId) {
public List<Resource> getResourceByProjectId(String projectId){
return resourceRepo.findByProjectId(projectId);
}
public List<ChangedResourceVO> getChangedResourceByDate(String fromDatestr, String toDatestr) {
// List<ChangedResourceVO> changedResourceVOList = new ArrayList();
// SimpleDateFormat format = new SimpleDateFormat("dd/MM/yyyy");
......@@ -868,9 +855,11 @@ public class ResourceService implements IResourceService {
// }catch (Exception e){}
//
return null;
}
public boolean validateResourceAllocationStatus(ResourceAllocationStatus resourceStatus) {
boolean isValidStatus = false;
switch (resourceStatus) {
......@@ -889,6 +878,7 @@ public class ResourceService implements IResourceService {
return isValidStatus;
}
public List<Resource> getResourcesGreaterThanBillingStartDate(Date billingStartDate) {
return resourceRepo.findByBillingStartDateGreaterThan(billingStartDate);
}
......@@ -904,26 +894,23 @@ public class ResourceService implements IResourceService {
Project project = null;
// Setting Current Billing details.
//Setting Current Billing details.
AllocationChangeVO allocationVO = new AllocationChangeVO();
allocationVO.setEmployeeId(resource.getEmployeeId());
allocationVO.setEmployeeName(
employeeService.getEmployeeById(resource.getEmployeeId()).getEmployeeName());
allocationVO.setEmployeeName(employeeService.getEmployeeById(resource.getEmployeeId()).getEmployeeName());
if (StringUtils.isNotBlank(resource.getProjectId())) {
project = projectService.getProjectByProjectId(resource.getProjectId());
if (project != null) {
allocationVO.setCurrentProjectName(project.getProjectName());
allocationVO.setCurrentAccountName(
accountService.getAccountById(project.getAccountId()).getAccountName());
allocationVO.setCurrentAccountName(accountService.getAccountById(project.getAccountId()).getAccountName());
}
}
allocationVO.setCurrentBillingStatus(resource.getBillableStatus());
allocationVO.setCurrentBillingStartDate(resource.getBillingStartDate());
allocationVO.setCurrentBillingEndDate(resource.getBillingEndDate());
Resource prevBilling = resourceRepo.findOneByEmployeeIdAndBillingEndDate(resource.getEmployeeId(),
MyTeamDateUtils.getDayLessThanDate(resource.getBillingStartDate()));
Resource prevBilling = resourceRepo.findOneByEmployeeIdAndBillingEndDate(resource.getEmployeeId(), MyTeamDateUtils.getDayLessThanDate(resource.getBillingStartDate()));
log.info("\n\n\n The prev billing info is::" + prevBilling);
if (prevBilling != null) {
......@@ -931,8 +918,7 @@ public class ResourceService implements IResourceService {
project = projectService.getProjectByProjectId(prevBilling.getProjectId());
if (project != null) {
allocationVO.setPrevProjectName(project.getProjectName());
allocationVO.setPrevAccountName(
accountService.getAccountById(project.getAccountId()).getAccountName());
allocationVO.setPrevAccountName(accountService.getAccountById(project.getAccountId()).getAccountName());
}
}
allocationVO.setPrevBillingStatus(prevBilling.getBillableStatus());
......@@ -953,15 +939,13 @@ public class ResourceService implements IResourceService {
AllocationChangeVO allocationVO = new AllocationChangeVO();
allocationVO.setEmployeeId(resource.getEmployeeId());
allocationVO
.setEmployeeName(employeeService.getEmployeeById(resource.getEmployeeId()).getEmployeeName());
allocationVO.setEmployeeName(employeeService.getEmployeeById(resource.getEmployeeId()).getEmployeeName());
if (StringUtils.isNotBlank(resource.getProjectId())) {
project = projectService.getProjectByProjectId(resource.getProjectId());
if (project != null) {
allocationVO.setCurrentProjectName(project.getProjectName());
allocationVO.setCurrentAccountName(
accountService.getAccountById(project.getAccountId()).getAccountName());
allocationVO.setCurrentAccountName(accountService.getAccountById(project.getAccountId()).getAccountName());
}
}
......@@ -977,13 +961,13 @@ public class ResourceService implements IResourceService {
return allocationList;
}
@Override
public Set<Resource> findByBillableStatus(String billableStatus) {
return resourceRepo.findByBillableStatus(billableStatus).stream()
.filter(r -> r.getBillingEndDate().after(new Date())).collect(Collectors.toSet());
return resourceRepo.findByBillableStatus(billableStatus).stream().filter(r -> r.getBillingEndDate().after(new Date())).collect(Collectors.toSet());
}
public Resource sendResourceToOpenPool(Resource resource, String loginId) {
public Resource sendResourceToOpenPool(Resource resource,String loginId) {
Resource existingresource = resourceRepo.findById(resource.getId());
existingresource.setStatus(MyTeamUtils.RELEASED_STATUS);
this.updateExistedResource(existingresource);
......@@ -995,8 +979,7 @@ public class ResourceService implements IResourceService {
benchResource.setEmployeeId(resource.getEmployeeId());
benchResource.setResourceRole(resource.getResourceRole());
benchResource.setBillingStartDate(MyTeamDateUtils.getDayMoreThanDate(resource.getBillingEndDate()));
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.setStatus(MyTeamUtils.RELEASED_STATUS);
benchResource.setAuditFields(loginId, MyTeamUtils.CREATE);
......@@ -1008,56 +991,66 @@ public class ResourceService implements IResourceService {
@Override
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));
}
}
//class
/*
* @Override public List<ResourceVO> getActiveResources(String empId) {
* List<ResourceVO> finalResourcesList = new ArrayList<>();
*
* List<Resource> resourceList = resourceRepo.findByEmployeeId(empId); if
* (resourceList != null && resourceList.size() > 0) {
*
* Resource resourceAlloc=resourceList.get(0); }
*
* for (Resource resource : resourceRepo.findByEmployeeId(empId)) {
*
* ResourceVO resourceVO=new ResourceVO();
* resourceVO.setEmployeeId(resource.getEmployeeId());
*
* Employee employee=employeeService.getEmployeeById(resource.getEmployeeId());
* resourceVO.setEmployeeName(employee.getEmployeeName());
* resourceVO.setDesignation(employee.getDesignation());
* resourceVO.setEmailId(employee.getEmailId());
* resourceVO.setMobileNo(employee.getMobileNumber());
*
* resourceVO.setProjectName(projectService.getProjectByProjectId(resource.
* getProjectId()).getProjectName());
*
*
* if (resource.getBillingEndDate().compareTo(new Date()) > 0) {
* finalResourcesList.addAll(getAllResourcesForProject(resource.getProjectId()))
* ; }
*
*
* } return finalResourcesList; }
*
*/
/*
*
* @Override public List<ResourceVO> getActiveResources(String empId) {
* List<ResourceVO> finalResourcesList = new ArrayList<>(); Employee employee =
* null;
*
* List<Resource> resourceList = resourceRepo.findByEmployeeId(empId);
* Optional<Resource> optionalResource = resourceList.stream().filter(resource
* -> resource.getBillingEndDate().compareTo(new Date()) > 0).findAny(); if
* (optionalResource.isPresent()) { finalResourcesList =
* prepareProjectTeamMembersList(optionalResource.get().getProjectId()); }
* return finalResourcesList; }
*
/*
@Override
public List<ResourceVO> getActiveResources(String empId) {
List<ResourceVO> finalResourcesList = new ArrayList<>();
List<Resource> resourceList = resourceRepo.findByEmployeeId(empId);
if (resourceList != null && resourceList.size() > 0) {
Resource resourceAlloc=resourceList.get(0);
}
for (Resource resource : resourceRepo.findByEmployeeId(empId)) {
ResourceVO resourceVO=new ResourceVO();
resourceVO.setEmployeeId(resource.getEmployeeId());
Employee employee=employeeService.getEmployeeById(resource.getEmployeeId());
resourceVO.setEmployeeName(employee.getEmployeeName());
resourceVO.setDesignation(employee.getDesignation());
resourceVO.setEmailId(employee.getEmailId());
resourceVO.setMobileNo(employee.getMobileNumber());
resourceVO.setProjectName(projectService.getProjectByProjectId(resource.getProjectId()).getProjectName());
if (resource.getBillingEndDate().compareTo(new Date()) > 0) {
finalResourcesList.addAll(getAllResourcesForProject(resource.getProjectId()));
}
}
return finalResourcesList;
}
*/
/*
@Override
public List<ResourceVO> getActiveResources(String empId) {
List<ResourceVO> finalResourcesList = new ArrayList<>();
Employee employee = null;
List<Resource> resourceList = resourceRepo.findByEmployeeId(empId);
Optional<Resource> optionalResource = resourceList.stream().filter(resource -> resource.getBillingEndDate().compareTo(new Date()) > 0).findAny();
if (optionalResource.isPresent()) {
finalResourcesList = prepareProjectTeamMembersList(optionalResource.get().getProjectId());
}
return finalResourcesList;
}
*/
......@@ -5,6 +5,8 @@ import java.text.SimpleDateFormat;
public class MyTeamUtils {
private MyTeamUtils() {
}
......@@ -13,6 +15,7 @@ public class MyTeamUtils {
//public final static String msdriveUrl ="jdbc:sqlserver://";
public final static String RELEASED_STATUS="Released";
public final static String Engaged_STATUS="Engaged";
public static final String STATUS_PROPOSED ="Proposed" ;
public final static DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
public final static DateFormat tdf = new SimpleDateFormat("HH:mm");
......
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