Commit 2dae5af4 authored by Md Suleman's avatar Md Suleman

Employee In active and utilization report enhancement changes

parent 926185b7
......@@ -32,7 +32,6 @@ import com.nisum.myteam.exception.handler.ResponseDetails;
import com.nisum.myteam.model.dao.Account;
import com.nisum.myteam.model.dao.Employee;
import com.nisum.myteam.service.IEmployeeRoleService;
import com.nisum.myteam.service.IEmployeeService;
import lombok.extern.slf4j.Slf4j;
......@@ -55,7 +54,8 @@ public class EmployeeController {
@RequestMapping(value = "/employees/{empId}", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<?> createEmployee( @RequestBody Employee employeeReq,
@PathVariable(value = "empId") String loginEmpId, HttpServletRequest request) throws MyTeamException {
@PathVariable(value = "empId") String loginEmpId,
HttpServletRequest request) throws MyTeamException {
if (empService.isEmployeeExistsById(loginEmpId)) {
Employee employeePersisted = empService.createEmployee(employeeReq, loginEmpId);
......@@ -75,7 +75,8 @@ public class EmployeeController {
@RequestMapping(value = "/employees/{empId}", method = RequestMethod.PUT, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<?> updateEmployee(@RequestBody Employee employeeReq,
@PathVariable(value = "empId") String loginEmpId, HttpServletRequest request) throws MyTeamException, ParseException {
@PathVariable(value = "empId") String loginEmpId,
HttpServletRequest request) throws MyTeamException, ParseException {
if (empService.isEmployeeExistsById(loginEmpId)) {
Employee employeeUpdated = empService.updateEmployee(employeeReq, loginEmpId);
......@@ -93,8 +94,8 @@ public class EmployeeController {
}
@RequestMapping(value = "/employees/{empId}", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<?> deleteEmployee(@PathVariable("empId") String empId, HttpServletRequest request)
throws MyTeamException {
public ResponseEntity<?> deleteEmployee(@PathVariable("empId") String empId,
HttpServletRequest request) {
if (empService.isEmployeeExistsById(empId)) {
......@@ -117,7 +118,8 @@ public class EmployeeController {
@RequestMapping(value = "/employees/employeeId/{empId}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<?> getEmployeeById(@PathVariable("empId") String empId, HttpServletRequest request)
public ResponseEntity<?> getEmployeeById(@PathVariable("empId") String empId,
HttpServletRequest request)
throws MyTeamException {
Employee employee = empService.getEmployeeById(empId);
ResponseDetails getRespDetails = new ResponseDetails(new Date(), 904, "Retrieved Employee successfully",
......@@ -296,10 +298,10 @@ public class EmployeeController {
}
@RequestMapping(value = "/employeesBasedOnSubStatusForGivenDates", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<?> employeesBasedOnSubStatusForGivenDates(@RequestParam("fromDate") @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) Date fromDate ,
@RequestParam("toDate") @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) Date toDate,
@RequestParam("subStatus") String subStatus ,
HttpServletRequest request){
public ResponseEntity<?> employeesBasedOnSubStatusForGivenDates(@RequestParam("fromDate") @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) Date fromDate,
@RequestParam("toDate") @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) Date toDate,
@RequestParam("subStatus") String subStatus,
HttpServletRequest request){
List<EmployeeSubStatusVO> employees = subStatusService.employeesBasedOnSubStatusForGivenDates(fromDate,toDate,subStatus);
ResponseDetails responseDetails = new ResponseDetails(new Date(), 904, "Fetched Employees Successfully",
......
package com.nisum.myteam.controller;
import static org.springframework.data.mongodb.core.aggregation.Aggregation.group;
import static org.springframework.data.mongodb.core.aggregation.Aggregation.newAggregation;
import static org.springframework.data.mongodb.core.aggregation.Aggregation.project;
import static org.springframework.data.mongodb.core.aggregation.Aggregation.sort;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import com.nisum.myteam.exception.handler.MyTeamException;
import com.nisum.myteam.model.ColumnChartData;
import com.nisum.myteam.model.GroupByCount;
import com.nisum.myteam.model.ReportSeriesRecord;
import com.nisum.myteam.model.Reports;
import com.nisum.myteam.model.dao.Account;
import com.nisum.myteam.model.dao.Employee;
import com.nisum.myteam.model.dao.Project;
import com.nisum.myteam.model.dao.Resource;
import com.nisum.myteam.model.vo.ReportVo;
import com.nisum.myteam.service.IAccountService;
import com.nisum.myteam.service.IEmployeeService;
import com.nisum.myteam.service.IReportService;
import com.nisum.myteam.service.IResourceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Sort;
import org.springframework.data.mongodb.core.MongoTemplate;
......@@ -26,6 +24,7 @@ import org.springframework.data.mongodb.core.aggregation.MatchOperation;
import org.springframework.data.mongodb.core.aggregation.ProjectionOperation;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
......@@ -34,22 +33,11 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.nisum.myteam.exception.handler.MyTeamException;
import com.nisum.myteam.model.Reports;
import com.nisum.myteam.model.ColumnChartData;
import com.nisum.myteam.model.GroupByCount;
import com.nisum.myteam.model.ReportSeriesRecord;
import com.nisum.myteam.model.dao.Account;
import com.nisum.myteam.model.dao.Employee;
import com.nisum.myteam.model.dao.Project;
import com.nisum.myteam.model.dao.Resource;
import com.nisum.myteam.model.vo.ReportVo;
import com.nisum.myteam.model.vo.ResourceVO;
import com.nisum.myteam.service.IAccountService;
import com.nisum.myteam.service.IEmployeeService;
import com.nisum.myteam.service.IResourceService;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import javax.ws.rs.QueryParam;
import static org.springframework.data.mongodb.core.aggregation.Aggregation.*;
//import com.nisum.myteam.model.dao.Resource;
......@@ -267,20 +255,23 @@ public class ReportsController {
@RequestMapping(value = "/fetchEmployeeDetailsByFGAndBillability",
method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<Reports>> getEmployeesByFGAndBillability(
@RequestParam("fGroup") String fGroup , @RequestParam("billableStatus") String billableStatus) throws MyTeamException {
public ResponseEntity<List<Reports>> getEmployeesByFGAndBillability(@RequestParam("fGroup") String fGroup,
@RequestParam("billableStatus") String billableStatus,
@RequestParam("onDate") @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) Date onDate) throws MyTeamException {
List<Reports> empList=null;
empList = reportService.getEmployeeDetailsByFGAndBillability(fGroup,billableStatus);
empList = reportService.getEmployeeDetailsByFGAndBillability(fGroup,billableStatus,onDate);
return new ResponseEntity<>(empList, HttpStatus.OK);
}
@RequestMapping(value = "/fetchEmployeeDetailsByFGAccountAndBillability",
method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<Reports>> getEmployeesByFGAccountAndBillability(
@RequestParam("fGroup") String fGroup , @RequestParam("billableStatus") String billableStatus,@RequestParam("acccount") String account) throws MyTeamException {
public ResponseEntity<List<Reports>> getEmployeesByFGAccountAndBillability(@RequestParam("fGroup") String fGroup,
@RequestParam("billableStatus") String billableStatus,
@RequestParam("acccount") String account,
@RequestParam("onDate") @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) Date onDate) throws MyTeamException {
List<Reports> empList=null;
empList = reportService.getEmployeeDetailsByFGAccountAndBillability(fGroup,billableStatus,account);
empList = reportService.getEmployeeDetailsByFGAccountAndBillability(fGroup,billableStatus,account,onDate);
return new ResponseEntity<>(empList, HttpStatus.OK);
}
......@@ -288,10 +279,9 @@ public class ReportsController {
@RequestMapping(value = "/getBarChartReport",
method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
public ReportVo billabilityReportByFunctionalGroup(@RequestParam("byType") String byType) throws MyTeamException {
return reportService.getBarChartReport(byType);
public ReportVo billabilityReportByFunctionalGroup(@RequestParam("byType") String byType,
@RequestParam("onDate") @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) Date onDate) throws MyTeamException {
return reportService.getBarChartReport(byType,onDate);
}
......@@ -371,13 +361,12 @@ public class ReportsController {
@RequestMapping(value = "/fetchEmployeeDetailsByAccountBillability",
method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<Reports>> fetchEmployeeDetailsByAccountBillability(
@RequestParam("account") String account,
@RequestParam("billabilityStatus") String billabilityStatus)
throws MyTeamException {
public ResponseEntity<List<Reports>> fetchEmployeeDetailsByAccountBillability(@RequestParam("account") String account,
@RequestParam("billabilityStatus") String billabilityStatus,
@RequestParam("onDate") @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) Date onDate) throws MyTeamException {
List<Reports> resourcesList = new ArrayList<>();
if (account != null && !account.isEmpty()) {
resourcesList = reportService.getEmployeeDetailsByAccountBillability(account,billabilityStatus);
resourcesList = reportService.getEmployeeDetailsByAccountBillability(account,billabilityStatus,onDate);
}
return new ResponseEntity<>(resourcesList, HttpStatus.OK);
}
......
package com.nisum.myteam.service;
import java.util.Date;
import java.util.List;
import com.nisum.myteam.exception.handler.MyTeamException;
import com.nisum.myteam.model.Reports;
import com.nisum.myteam.model.dao.Project;
import com.nisum.myteam.model.vo.ReportVo;
import com.nisum.myteam.model.vo.ResourceVO;
public interface IReportService {
public ReportVo getBarChartReport(String byType) throws MyTeamException;
public ReportVo getBarChartReport(String byType, Date onDate) throws MyTeamException;
public List<Reports> getEmployeeDetailsByFGAndBillability(String fGroup, String billableStatus) throws MyTeamException;
public List<Reports> getEmployeeDetailsByFGAndBillability(String fGroup, String billableStatus,Date onDate) throws MyTeamException;
public List<Reports> getEmployeeDetailsByAccountBillability(String account, String billabilityStatus)throws MyTeamException;
public List<Reports> getEmployeeDetailsByAccountBillability(String account, String billabilityStatus,Date onDate)throws MyTeamException;
public Project getProjectById(String employeeId);
public List<Reports> getEmployeeDetailsByFGAccountAndBillability(String fGroup, String billableStatus, String account);
public List<Reports> getEmployeeDetailsByFGAccountAndBillability(String fGroup, String billableStatus, String account,Date onDate) throws MyTeamException;
}
\ No newline at end of file
......@@ -71,6 +71,8 @@ public interface IResourceService {
Resource getCurrentAllocation(String employeeId);
public Resource makeResourceInactive(String employeeId,Date endDate);
// List<Resource> getAllResourcesForProject(String projectId, String status);
// List<Resource> getResourcesForEmployee(String empId);
......
package com.nisum.myteam.service.impl;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
import com.nisum.myteam.model.dao.*;
import com.nisum.myteam.exception.handler.MyTeamException;
import com.nisum.myteam.model.dao.Account;
import com.nisum.myteam.model.dao.Domain;
import com.nisum.myteam.model.dao.Employee;
import com.nisum.myteam.model.dao.EmployeeSubStatus;
import com.nisum.myteam.repository.EmployeeRepo;
import com.nisum.myteam.service.*;
import com.nisum.myteam.utils.MyTeamUtils;
import com.nisum.myteam.utils.constants.ApplicationRole;
import com.nisum.myteam.utils.constants.RoleConstant;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.domain.Sort;
import org.springframework.data.mongodb.core.FindAndModifyOptions;
import org.springframework.data.mongodb.core.MongoTemplate;
......@@ -18,14 +21,11 @@ import org.springframework.data.mongodb.core.query.Query;
import org.springframework.data.mongodb.core.query.Update;
import org.springframework.stereotype.Service;
import com.nisum.myteam.exception.handler.MyTeamException;
import com.nisum.myteam.repository.EmployeeRepo;
import com.nisum.myteam.statuscodes.ResourceStatus;
import com.nisum.myteam.utils.MyTeamUtils;
import com.nisum.myteam.utils.constants.ApplicationRole;
import com.nisum.myteam.utils.constants.RoleConstant;
import lombok.extern.slf4j.Slf4j;
import javax.transaction.Transactional;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
@Service
@Slf4j
......@@ -165,6 +165,7 @@ public class EmployeeService implements IEmployeeService {
// }
@Override
@Transactional
public Employee updateEmployee(Employee employeeReq, String loginEmpId) throws ParseException {
response.put("messege" , "Employee has been updated");
// update all emp details to inactive if employee is inactive
......@@ -177,10 +178,8 @@ public class EmployeeService implements IEmployeeService {
update.set("gender", employeeReq.getGender());
update.set("functionalGroup", employeeReq.getFunctionalGroup());
update.set("empStatus", employeeReq.getEmpStatus());
// update.set("empSubStatus", employeeReq.getEmpSubStatus());
update.set("employmentType", employeeReq.getEmploymentType());
update.set("empLocation", employeeReq.getEmpLocation());
// update.set("domain", employeeReq.getDomain());
update.set("designation", employeeReq.getDesignation());
update.set("dateOfBirth", employeeReq.getDateOfBirth());
update.set("dateOfJoining", employeeReq.getDateOfJoining());
......@@ -194,7 +193,6 @@ public class EmployeeService implements IEmployeeService {
if (employeeReq.getEmpStatus().equalsIgnoreCase(MyTeamUtils.IN_ACTIVE_SPACE)) {
update.set("endDate", employeeReq.getEndDate());
// update.set("empSubStatus", null);
}
// update employee location
if (employeeReq.getEmpLocation() != null && !employeeReq.getEmpLocation().equals("")) {
......@@ -244,16 +242,10 @@ public class EmployeeService implements IEmployeeService {
options.returnNew(true);
options.upsert(true);
Employee employeeUpdated = mongoTemplate.findAndModify(query, update, options, Employee.class);
try {
// add to resource collection
//resourceService.addResources(employeeUpdated, loginEmpId);
// inactive the employee from the assigned project.
//resourceService.inactivateResource(employeeReq, employeeUpdated, loginEmpId);
} catch (Exception e) {
if(employeeReq.getEmpStatus().equals("In Active")){
resourceService.makeResourceInactive(employeeReq.getEmployeeId(),employeeReq.getEndDate());
}
return employeeUpdated;
}
......
......@@ -2,16 +2,12 @@ package com.nisum.myteam.service.impl;
import com.nisum.myteam.exception.handler.MyTeamException;
import com.nisum.myteam.model.Reports;
import com.nisum.myteam.model.dao.Account;
import com.nisum.myteam.model.dao.Employee;
import com.nisum.myteam.model.dao.Project;
import com.nisum.myteam.model.dao.Resource;
import com.nisum.myteam.model.vo.ReportVo;
import com.nisum.myteam.model.vo.ResourceVO;
import com.nisum.myteam.service.IReportService;
import com.nisum.myteam.statuscodes.ResourceStatus;
import com.nisum.myteam.utils.MyTeamUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -21,10 +17,6 @@ import java.util.stream.Collectors;
@Service
public class ReportService implements IReportService {
private static final String Shadow = "Shadow";
private static final String Reserved = "Reserved";
@Autowired
private EmployeeService employeeService;
......@@ -40,12 +32,12 @@ public class ReportService implements IReportService {
@Autowired
private FunctionalGroupService functionalGroupService;
public ReportVo getBarChartReport(String byType) throws MyTeamException {
public ReportVo getBarChartReport(String byType,Date onDate) throws MyTeamException {
ReportVo reportVo = new ReportVo();
if(byType.equals("AllFunctionalGroup")) {
functionalGroupService.getAllFunctionalGroups().stream().
filter(f -> !Arrays.asList("IT","Recruiter","Admin","HR","Accounts").contains(f.getName())).
filter(f -> !Arrays.asList("IT","Recruiter","Admin","HR","Accounts","Delivery Org","Global Mobility").contains(f.getName())).
forEach(f -> reportVo.getCategoriesList().add(f.getName()));
} else {
accountService.getAllAccounts().forEach(a -> reportVo.getCategoriesList().add(a.getAccountName()));
......@@ -80,9 +72,11 @@ public class ReportService implements IReportService {
employeeList = getEmployeesByAccAndFG(category,byType);
}
for(Employee employee:employeeList){
Resource resource = resourceService.getCurrentAllocationIfNotReturnNull(employee.getEmployeeId());//getCurrentAllocation(employee.getEmployeeId());
Resource resource = null;
if(Objects.nonNull(onDate)){
resource = resourceService.getAllocationOfDate(employee.getEmployeeId(),onDate);
}
if(resource!=null && resource.getBillableStatus().equals("Billable")){
billableC++;
}else if(resource!=null && resource.getBillableStatus().equals("Trainee")) {
traineeC++;
......@@ -92,13 +86,10 @@ public class ReportService implements IReportService {
}
billper = ((billableC / (float)(employeeList.size() - traineeC))*100);
nonBillPer = nonBillableC /(float) (employeeList.size()-traineeC)*100;
// traineePer = traineeC / (float) employeeList.size()*100;
billableObj.put("percent", billper);
billableObj.put("y", billableC);
nonbillableObj.put("percent", nonBillPer);
nonbillableObj.put("y", nonBillableC);
// traineeObj.put("percent", traineePer);
// traineeObj.put("y", traineeC);
billableCount.add(billableObj);
nonBillableCount.add(nonbillableObj);
traineeCount.add(traineeC);
......@@ -113,7 +104,7 @@ public class ReportService implements IReportService {
}
private List<Employee> getEmployeesByAccAndFG(String account, String functionalGroup) {
List<Employee> empList = new ArrayList<Employee>();
List<Employee> empList;
empList = getEmployeeByAccounts(account).stream().filter(e -> e.getFunctionalGroup().equals(functionalGroup)).collect(Collectors.toList());
return empList;
}
......@@ -138,29 +129,33 @@ public class ReportService implements IReportService {
}
@Override
public List<Reports> getEmployeeDetailsByFGAndBillability(String fGroup, String billableStatus)
public List<Reports> getEmployeeDetailsByFGAndBillability(String fGroup, String billableStatus,Date onDate)
throws MyTeamException {
List<Employee> employeesByFG=employeeService.getEmployeesByFunctionalGrp(fGroup);
return resultantEmployeeWithBillability(employeesByFG,billableStatus);
return resultantEmployeeWithBillability(employeesByFG,billableStatus,onDate);
}
@Override
public List<Reports> getEmployeeDetailsByAccountBillability(String accountName, String billabilityStatus)
public List<Reports> getEmployeeDetailsByAccountBillability(String accountName, String billabilityStatus,Date onDate)
throws MyTeamException {
return resultantEmployeeWithBillability(getEmployeeByAccounts(accountName),billabilityStatus);
return resultantEmployeeWithBillability(getEmployeeByAccounts(accountName),billabilityStatus,onDate);
}
@Override
public List<Reports> getEmployeeDetailsByFGAccountAndBillability(String fGroup, String billableStatus, String account,Date onDate) throws MyTeamException {
List<Employee> empList = getEmployeesByAccAndFG(account,fGroup);
return resultantEmployeeWithBillability(empList,billableStatus,onDate);
}
private List<Reports> resultantEmployeeWithBillability(List<Employee> employees,
String billableStatus) {
String billableStatus,Date ondate) throws MyTeamException {
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());
Resource resource = resourceService.getAllocationOfDate(employee.getEmployeeId(),ondate);
if(resource!=null && resource.getBillableStatus().equals("Billable")){
billableEmployees.add(mappingReports(employee,resource));
}else if(resource!=null && resource.getBillableStatus().equals("Trainee")) {
......@@ -177,30 +172,15 @@ public class ReportService implements IReportService {
}
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();
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());
......@@ -212,30 +192,10 @@ public class ReportService implements IReportService {
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) {
return projectService.getProjectByProjectId(projectId);
}
@Override
public List<Reports> getEmployeeDetailsByFGAccountAndBillability(String fGroup, String billableStatus, String account) {
List<Employee> empList = getEmployeesByAccAndFG(account,fGroup);
return resultantEmployeeWithBillability(empList,billableStatus);
}
}
......@@ -220,11 +220,6 @@ public class ResourceService implements IResourceService {
respMap.put("message", "Billing start date should be after previous allocation billing end date in this project");
isValid = false;
}
// if (prevAllocation.getBillableStatus().equalsIgnoreCase(resourceReq.getBillableStatus())) {
// respMap.put("statusCode", 811);
// respMap.put("message", "Resource is already in " + prevAllocation.getBillableStatus() + " status only");
// isValid = false;
// }
}
return isValid;
}
......@@ -299,10 +294,6 @@ public class ResourceService implements IResourceService {
}
public boolean isDatesAvailableForAllocation(Resource resource){
String message = "";
List<Resource> allocationList = resourceRepo.findByEmployeeId(resource.getEmployeeId());
......@@ -324,39 +315,7 @@ public class ResourceService implements IResourceService {
return true;
}
// public boolean isDatesAvailableForAllocation(Resource resource){
//
//
//
//
//
//
//
// String message = "";
// List<Resource> allocationList = resourceRepo.findByEmployeeId(resource.getEmployeeId());
//
// List<Resource> matchedList = allocationList.stream().filter(r -> !r.getProjectId().equals(MyTeamUtils.BENCH_PROJECT_ID) &&
// !r.getId().equals(resource.getId()) &&
// ( (r.getBillingStartDate().compareTo(resource.getBillingStartDate())<=0 && r.getBillingEndDate().compareTo(resource.getBillingStartDate())>=0)||
// (r.getBillingStartDate().compareTo(resource.getBillingEndDate())<=0 && r.getBillingEndDate().compareTo(resource.getBillingEndDate())>=0 )))
// .collect(Collectors.toList());
// if(!matchedList.isEmpty()){
// message = "Resource is already alocated for projects:\n";
// for(Resource resourcel:matchedList){
// Project project = projectService.getProjectByProjectId(resourcel.getProjectId());
// message += "Project:"+project.getProjectName()+" From:"+MyTeamDateUtils.getRadableDate().format(resourcel.getBillingStartDate())+" To:"
// +MyTeamDateUtils.getRadableDate().format(resourcel.getBillingEndDate())+"\n";
// }
// respMap.put("statusCode", 815);
// respMap.put("message", message);
// return false;
// }else
// return true;
//
// }
public boolean isResourceAvailable(Resource resourceReq) {
......@@ -380,26 +339,6 @@ public class ResourceService implements IResourceService {
}
respMap.put("statusCode", 815);
respMap.put("message", message);
// 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();
// isAssigned = false;
// respMap.put("statusCode", 815);
// respMap.put("message", message);
// }
// }else{
// if(!validateResourceBillingEndDateAgainstBench(resourceReq)){
// isAssigned = false;
// }
// }
return isAssigned;
}
......@@ -480,6 +419,12 @@ public class ResourceService implements IResourceService {
return isActive;
}
public Resource getAllocationOfDate(String employeeId,Date onDate){
List<Resource> resources = this.getResourcesByEmployeeId(employeeId);
return resources.stream().filter(resource -> resource.getBillingStartDate().compareTo(onDate) <=0 &&
resource.getBillingEndDate().compareTo(onDate)>=0).findFirst().orElse(null);
}
public void deleteResource(Resource resourceReq, String loginEmpId) {
resourceRepo.delete(resourceReq);
......@@ -1194,64 +1139,18 @@ public class ResourceService implements IResourceService {
public Resource getCurrentAllocationIfNotReturnNull(String employeeId) {
return resourceRepo.findByEmployeeId(employeeId).stream().filter(resource-> isAllocationActiveToday(resource)).findAny().orElse(null);
}
}
//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());
@Override
public Resource makeResourceInactive(String employeeId,Date endDate){
Resource latestAllocation = this.getLatestResourceByEmpId(employeeId);
Resource currentAllocation = this.getCurrentAllocationIfNotReturnNull(employeeId);
if(Objects.nonNull(latestAllocation) && latestAllocation.getBillingStartDate().compareTo(new Date())>0){
resourceRepo.delete(latestAllocation);
}
return finalResourcesList;
currentAllocation.setBillingEndDate(endDate);
latestAllocation.setBillingEndDate(endDate);
resourceRepo.save(currentAllocation);
resourceRepo.save(latestAllocation);
return null;
}
*/
}
\ No newline at end of file
......@@ -2,14 +2,14 @@ package com.nisum.myteam.utils;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.hsqldb.lib.StringUtil;
import org.springframework.beans.factory.annotation.Value;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.ZoneId;
import java.util.*;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
@Slf4j
public class MyTeamDateUtils {
......
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