Commit 66ba5d97 authored by Vijay Akula's avatar Vijay Akula

Implementing AllocationChange Service

parent 067cc325
......@@ -5,10 +5,7 @@ import com.nisum.myteam.exception.handler.MyTeamException;
import com.nisum.myteam.exception.handler.ResponseDetails;
import com.nisum.myteam.model.dao.Employee;
import com.nisum.myteam.model.dao.Resource;
import com.nisum.myteam.model.vo.ChangedResourceVO;
import com.nisum.myteam.model.vo.EmployeeShiftsVO;
import com.nisum.myteam.model.vo.ReserveReportsVO;
import com.nisum.myteam.model.vo.ResourceVO;
import com.nisum.myteam.model.vo.*;
import com.nisum.myteam.repository.EmployeeVisaRepo;
import com.nisum.myteam.service.IEmployeeService;
import com.nisum.myteam.service.IProjectService;
......@@ -18,6 +15,7 @@ import com.nisum.myteam.utils.MyTeamUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
......@@ -269,7 +267,7 @@ public class ResourceController {
@RequestMapping(value = "/resources/reports", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<?> getDeliveryLeads(@RequestParam(value = "resourceStatus",defaultValue = "Reserved") String resourceStatus, HttpServletRequest request)
public ResponseEntity<?> getReserveReports(@RequestParam(value = "resourceStatus",defaultValue = "Reserved") String resourceStatus, HttpServletRequest request)
throws MyTeamException {
List<ReserveReportsVO> reservedResources = resourceService.getResourceReportsByBillingStatus(resourceStatus);
......@@ -280,5 +278,20 @@ public class ResourceController {
}
@RequestMapping(value = "/resources/allocationReports", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<?> getAllocationChangeReports(@RequestParam("fromDate") @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) Date fromDate,
@RequestParam("toDate") @DateTimeFormat(iso = DateTimeFormat.ISO.DATE)Date toDate, HttpServletRequest request)
throws MyTeamException {
//List<Resource> allocationResources = resourceService.getResourcesGreaterThanBillingStartDate(fromDate);
List<AllocationChangeVO> allocationResources = resourceService.getAllocationReports(fromDate,toDate);
log.info("The resources::"+allocationResources);
ResponseDetails getRespDetails = new ResponseDetails(new Date(), 905, "Retrieved Resources List successfully",
"Resource Allocation List Details", allocationResources, request.getRequestURI(), "Resource Allocation List Details", null);
return new ResponseEntity<ResponseDetails>(getRespDetails, HttpStatus.OK);
}
}
package com.nisum.myteam.model.vo;
import lombok.*;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
@AllArgsConstructor
@NoArgsConstructor
@Getter
@Setter
@ToString
public class AllocationChangeVO {
private String employeeId;
private String employeeName;
private String previousAccountName;
private String previousProjectName;
private String prevBillingStatus;
@DateTimeFormat(iso = DateTimeFormat.ISO.DATE)
private Date prevBilingStartDate;
@DateTimeFormat(iso = DateTimeFormat.ISO.DATE)
private Date prevBillingEndDate;
private String currentAccountName;
private String currentProjectName;
private String currentBillingStatus;
@DateTimeFormat(iso = DateTimeFormat.ISO.DATE)
private Date CurrentBillingStartDate;
@DateTimeFormat(iso = DateTimeFormat.ISO.DATE)
private Date currentBillingEndDate;
}
......@@ -5,6 +5,7 @@ import com.nisum.myteam.model.dao.Resource;
import org.bson.types.ObjectId;
import org.springframework.data.mongodb.repository.MongoRepository;
import java.util.Date;
import java.util.List;
public interface ResourceRepo
......@@ -20,6 +21,8 @@ public interface ResourceRepo
List<Resource> findByBillableStatus(String resourceAllocationStatus);
List<Resource> findByBillingStartDateGreaterThan(Date billingStartDate);
// List<Resource> findByEmployeeIdAndActive(String employeeId, boolean status);
// List<Resource> findByEmployeeIdAndProjectIdAndActive(String employeeId, String projectId, boolean status);
......
......@@ -800,6 +800,46 @@ public class ResourceService implements IResourceService {
}
public List<Resource> getResourcesGreaterThanBillingStartDate(Date billingStartDate) {
return resourceRepo.findByBillingStartDateGreaterThan(billingStartDate);
}
public List<AllocationChangeVO> getAllocationReports(Date fromDate, Date toDate) {
return prepareAllocationResources(getResourcesGreaterThanBillingStartDate(fromDate));
}
public List<AllocationChangeVO> prepareAllocationResources(List<Resource> resourcesList) {
List<AllocationChangeVO> allocationList = new ArrayList<>();
if (resourcesList != null && resourcesList.size() > 0) {
Project project = null;
for (Resource resource : resourcesList) {
AllocationChangeVO allocationVO = new AllocationChangeVO();
allocationVO.setEmployeeId(resource.getEmployeeId());
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.setCurrentBillingStatus(resource.getBillableStatus());
allocationVO.setCurrentBillingStartDate(resource.getBillingStartDate());
allocationVO.setCurrentBillingEndDate(resource.getBillingEndDate());
allocationList.add(allocationVO);
}
}
return allocationList;
}
}//class
......
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