Commit aa1086d2 authored by Md Suleman's avatar Md Suleman

Updated_Manage_Projects_and_team

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