Commit aa1086d2 authored by Md Suleman's avatar Md Suleman

Updated_Manage_Projects_and_team

parent cc43ba84
......@@ -50,14 +50,14 @@ public class ResourceAllocationController {
if (resourceAllocService.validateBillingStartEndDateAgainstProjectStartEndDate(resourceAllocationReq, loginEmpId)) {
if (resourceAllocService.validateBillingStartDateAgainstDOJ(resourceAllocationReq)) {
if (!resourceAllocService.isResourceAssignedToAnyProject(resourceAllocationReq)) {
if(!resourceAllocService.isResourceExistsForProject(resourceAllocationReq.getEmployeeId(),resourceAllocationReq.getProjectId())) {
ResourceAllocation resourcePersisted = resourceAllocService.addResourceAllocation(resourceAllocationReq, loginEmpId);
ResponseDetails createResponseDetails = new ResponseDetails(new Date(), 800, "Resource has been created",
"Resource description", null, request.getContextPath(), "details", resourcePersisted);
return new ResponseEntity<ResponseDetails>(createResponseDetails, HttpStatus.OK);
}
}
}
}
......@@ -80,12 +80,15 @@ public class ResourceAllocationController {
resourceAllocationReq.setAuditFields(loginEmpId, MyTeamUtils.UPDATE);
if (resourceAllocService.isResourceExistsForProject(resourceAllocationReq.getEmployeeId(), resourceAllocationReq.getProjectId())) {
resourceAllocService.updatePreviousResource(resourceAllocationReq, loginEmpId);
resourceAllocService.insertNewResourceAllocWithNewStatus(resourceAllocationReq, loginEmpId);
resourceAllocService.updateResourceDetails(resourceAllocationReq, loginEmpId);
// resourceAllocService.insertNewResourceAllocWithNewStatus(resourceAllocationReq, loginEmpId);
}
ResponseDetails createResponseDetails = new ResponseDetails(new Date(), Integer.parseInt(resourceAllocService.respMap.get("statusCode").toString()), resourceAllocService.respMap.get("message").toString(),
"Resource description", null, request.getContextPath(), "Resource details", resourceAllocationReq);
ResponseDetails createResponseDetails = new ResponseDetails(new Date(), Integer.parseInt(resourceAllocService.respMap.get("statusCode").toString()),
resourceAllocService.respMap.get("message").toString(), "Resource description", null, request.getContextPath(),
"Resource details", resourceAllocationReq);
return new ResponseEntity<ResponseDetails>(createResponseDetails, HttpStatus.OK);
}
ResponseDetails responseDetails = new ResponseDetails(new Date(), 820, "Please provide the valid Employee Id",
......
......@@ -115,6 +115,9 @@ public class ProjectService implements IProjectService {
existingProject.setProjectEndDate(project.getProjectEndDate());
existingProject.setAuditFields(loginEmpId, MyTeamUtils.UPDATE);
projectRepo.save(existingProject);
}else{
project.setId(existingProject.getId());
projectRepo.save(project);
}
return existingProject;
}
......
......@@ -61,7 +61,8 @@ public class ResourceAllocationService implements IResourceAllocationService {
List<ResourceAllocation> resourceList = resourceAllocationRepo.findByEmployeeIdAndProjectId(employeeId, projectId);
if (resourceList != null && resourceList.size() > 0) {
isExists = true;
respMap.put("message", "Resourse is already in the project");
return isExists;
}
respMap.put("statusCode", 810);
respMap.put("message", "Resource Not Found");
......@@ -71,19 +72,30 @@ public class ResourceAllocationService implements IResourceAllocationService {
public void updatePreviousResource(ResourceAllocation resourceAllocReq, String loginEmpId) throws MyTeamException {
public void updateResourceDetails(ResourceAllocation resourceAllocReq, String loginEmpId) throws MyTeamException {
List<ResourceAllocation> resourceAllocList = resourceAllocationRepo.findByEmployeeIdAndProjectId(resourceAllocReq.getEmployeeId(), resourceAllocReq.getProjectId());
List<ResourceAllocation> resourceListWithLatestRecord = resourceAllocList.stream().filter(resource -> resource.getBillingEndDate().compareTo(new Date()) >= 0).collect(Collectors.toList());
if (resourceListWithLatestRecord != null && resourceListWithLatestRecord.size() > 0) {
ResourceAllocation resourceAllocPrev = resourceListWithLatestRecord.get(0);//latest resource record.
ResourceAllocation resourceAllocPrev = resourceListWithLatestRecord.get(0); //latest resource record.
log.info("Requsting Resource Allocation BillingStart Date::::"+resourceAllocReq.getBillingStartDate());
log.info("The before date is::" + MyTeamDateUtils.getDayLessThanDate(resourceAllocReq.getBillingStartDate()));
if(!resourceAllocPrev.getBillableStatus().equals(resourceAllocReq.getBillableStatus())) {
if (resourceAllocPrev.getBillingEndDate().compareTo(new Date()) == 0) {
resourceAllocPrev.setBillingEndDate(new Date());
} else {
resourceAllocPrev.setBillingEndDate(MyTeamDateUtils.getDayLessThanDate(resourceAllocReq.getBillingStartDate())); //adding resource.
}
insertNewResourceAllocWithNewStatus(resourceAllocReq,loginEmpId);
}else {
resourceAllocPrev.setResourceRole(resourceAllocReq.getResourceRole());
resourceAllocPrev.setBillingStartDate(resourceAllocReq.getBillingStartDate());
resourceAllocPrev.setBillingEndDate(resourceAllocReq.getBillingEndDate());
//resourceAllocPrev.setBillingEndDate(); //adding resource.
}
log.info("After setting the date:::before saving the Resource::" + resourceAllocPrev);
this.updateExistedResourceAlloc(resourceAllocPrev);
}
......@@ -95,7 +107,7 @@ public class ResourceAllocationService implements IResourceAllocationService {
if (resourceAlloc != null) {
ResourceAllocation resourcePers = resourceAllocationRepo.save(resourceAlloc);
respMap.put("statusCode", 801);
respMap.put("message", "resource has been updated");
respMap.put("message", "Resource updated successfully");
respMap.put("resourceObj", resourcePers);
}
......
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