Commit a108af67 authored by Vijay Akula's avatar Vijay Akula

Resolved the dashboard page

parent 465732ba
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 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.dao.Account;
import com.nisum.myteam.model.dao.Employee;
import com.nisum.myteam.model.dao.ResourceAllocation;
import com.nisum.myteam.service.IEmployeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Sort;
import org.springframework.data.mongodb.core.MongoTemplate;
......@@ -31,33 +25,26 @@ 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.dao.Account;
import com.nisum.myteam.model.dao.Billing;
import com.nisum.myteam.model.ColumnChartData;
import com.nisum.myteam.model.dao.Employee;
import com.nisum.myteam.model.GroupByCount;
import com.nisum.myteam.model.ReportSeriesRecord;
import com.nisum.myteam.model.dao.Resource;
import com.nisum.myteam.service.IEmployeeService;
import com.nisum.myteam.service.IResourceService;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import static org.springframework.data.mongodb.core.aggregation.Aggregation.*;
//import com.nisum.myteam.model.dao.Resource;
@RestController
@RequestMapping("/reports")
public class ReportsController {
@Autowired
private MongoTemplate mongoTemplate;
@Autowired
private IResourceService resourceService;
@Autowired
private IEmployeeService employeeService;
//Ok Response
@RequestMapping(value = "/getEmployeesByFunctionalGroup1",
method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
......@@ -85,6 +72,8 @@ public class ReportsController {
return new ResponseEntity<>(result, HttpStatus.OK);
}
//Ok Response
@RequestMapping(value = "/getEmployeesByFunctionalGroupForReport",
method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
......@@ -115,6 +104,8 @@ public class ReportsController {
return new ResponseEntity<>(reportData, HttpStatus.OK);
}
//Not Ok Response
@RequestMapping(value = "/getBillabilityDetailsByAccount",
method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
......@@ -133,7 +124,7 @@ public class ReportsController {
// Convert the aggregation result into a List
AggregationResults<ColumnChartData> groupResults = mongoTemplate
.aggregate(aggregate, Billing.class,
.aggregate(aggregate, ResourceAllocation.class,
ColumnChartData.class);
List<ColumnChartData> result = groupResults.getMappedResults();
List<String> statusList = new ArrayList();
......@@ -155,11 +146,11 @@ public class ReportsController {
for (ColumnChartData columnChartData : result) {
if (columnChartData.getCategories() != null
&& columnChartData.getSeriesName() != null
& columnChartData.getCategories()
.equalsIgnoreCase(
acct.getAccountName())
& columnChartData.getCategories()
.equalsIgnoreCase(
acct.getAccountName())
&& columnChartData.getSeriesName()
.equalsIgnoreCase(status)) {
.equalsIgnoreCase(status)) {
seriesDataExists = true;
seriesData[i] = columnChartData.getCount();
}
......@@ -181,6 +172,8 @@ public class ReportsController {
return new ResponseEntity<>(reportData, HttpStatus.OK);
}
//ok response
@RequestMapping(value = "/getBillabilityDetailsByMonth",
method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
......@@ -244,11 +237,10 @@ public class ReportsController {
// Convert the aggregation result into a List
AggregationResults<ColumnChartData> groupResults1 = mongoTemplate
.aggregate(agg1, Billing.class,
.aggregate(agg1, ResourceAllocation.class,
ColumnChartData.class);
List<ColumnChartData> result1 = groupResults1.getMappedResults();
// List<ColumnChartData> result2 = groupResults.getMappedResults();
List<String> statusList = new ArrayList();
statusList.add("Billable");
statusList.add("Shadow");
......@@ -259,7 +251,7 @@ public class ReportsController {
for (ColumnChartData columnChartData : result1) {
if (columnChartData.getBillableStatus() != null
&& columnChartData.getBillableStatus()
.equalsIgnoreCase(status)) {
.equalsIgnoreCase(status)) {
ReportSeriesRecord record = (ReportSeriesRecord) m
.get(status);
record.getData()[i] = columnChartData.getCount();
......@@ -276,6 +268,7 @@ public class ReportsController {
return new ResponseEntity<>(reportData, HttpStatus.OK);
}
//ok response
@RequestMapping(value = "/getEmployeesByFunctionalGroup",
method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
......@@ -319,29 +312,29 @@ public class ReportsController {
return new ResponseEntity<>(empList, HttpStatus.OK);
}
@RequestMapping(value = "/fetchEmployeeDetailsByAccountBillability",
method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<Resource>> fetchEmployeeDetailsByAccountBillability(
@RequestParam("account") String account,
@RequestParam("billabilityStatus") String billabilityStatus)
throws MyTeamException {
List<Resource> empList = new ArrayList<>();
if (account != null && !account.isEmpty()) {
empList = resourceService.findByAccountAndActiveAndBillableStatus(
account, true, billabilityStatus);
}
return new ResponseEntity<>(empList, HttpStatus.OK);
}
// @RequestMapping(value = "/fetchEmployeeDetailsByAccountBillability",
// method = RequestMethod.GET,
// produces = MediaType.APPLICATION_JSON_VALUE)
// public ResponseEntity<List<ResourceAllocation>> fetchEmployeeDetailsByAccountBillability(
// @RequestParam("account") String account,
// @RequestParam("billabilityStatus") String billabilityStatus)
// throws MyTeamException {
// List<ResourceAllocation> resourcesList = new ArrayList<>();
// if (account != null && !account.isEmpty()) {
// resourcesList = resourceService.findByAccountAndActiveAndBillableStatus(
// account, true, billabilityStatus);
// }
// return new ResponseEntity<>(resourcesList, HttpStatus.OK);
// }
@RequestMapping(value = "/fetchEmployeeDetailsByDateBillability",
method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<Billing>> fetchEmployeeDetailsByDateBillability(
public ResponseEntity<List<ResourceAllocation>> fetchEmployeeDetailsByDateBillability(
@RequestParam("billabilityStatus") String billabilityStatus,
@RequestParam("reportDate") String reportDateString)
throws MyTeamException {
List<Billing> empList = new ArrayList<>();
List<ResourceAllocation> empList = new ArrayList<>();
if (reportDateString != null && !reportDateString.isEmpty()) {
String pattern = "MM-dd-yyyy";
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern);
......@@ -364,7 +357,7 @@ public class ReportsController {
criteriaV1.orOperator(criteriaV21, criteriaV22));
Query query = new Query();
query.addCriteria(criteriaV221);
empList = mongoTemplate.find(query, Billing.class);
empList = mongoTemplate.find(query, ResourceAllocation.class);
}
return new ResponseEntity<>(empList, HttpStatus.OK);
}
......
......@@ -236,9 +236,9 @@ public class ResourceAllocationController {
//@RequestMapping(value = "/getEmployeeBillingDetailsAll"
@RequestMapping(value = "/resources/billing", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<ResourceAllocation>> getAllBillingsForEmployee(@RequestParam("employeeId") String employeeId)
public ResponseEntity<List<ResourceVO>> getAllBillingsForEmployee(@RequestParam("employeeId") String employeeId)
throws MyTeamException {
List<ResourceAllocation> resourceAllocList = resourceAllocService.getBillingsForEmployee(employeeId);
List<ResourceVO> resourceAllocList = resourceAllocService.getBillingsForEmployee(employeeId);
return new ResponseEntity<>(resourceAllocList, HttpStatus.OK);
}
......
......@@ -30,7 +30,7 @@ public class EmployeeDashboardVO {
private String shift;
private String projectId;
private String projectName;
private String account;
private String accountName;
private String managerId;
private String managerName;
private String experience;
......@@ -42,10 +42,19 @@ public class EmployeeDashboardVO {
private String empSubStatus;
private String employmentType;
private String domain;
@DateTimeFormat(iso = ISO.DATE)
private Date projectStartDate;
@DateTimeFormat(iso = ISO.DATE)
private Date startDate;
private Date projectEndDate;
@DateTimeFormat(iso = ISO.DATE)
private Date endDate;
private Date billingStartDate;
@DateTimeFormat(iso = ISO.DATE)
private Date billingEndDate;
private boolean active;
private boolean projectAssigned;
private boolean hasB1Visa;
......
......@@ -31,4 +31,13 @@ public class MyProjectAllocationVO {
private List<HashMap<String, String>> deliveryLeadIds;
@DateTimeFormat(iso = DateTimeFormat.ISO.DATE)
private Date projectStartDate;
@DateTimeFormat(iso = DateTimeFormat.ISO.DATE)
private Date projectEndDate;
private String projectStatus;
}
......@@ -37,4 +37,16 @@ public class ResourceVO {
private String resourceRole;
private String mobileNo;
private String accountName;
@DateTimeFormat(iso = DateTimeFormat.ISO.DATE, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSX")
private Date projectStartDate;
@DateTimeFormat(iso = DateTimeFormat.ISO.DATE, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSX")
private Date projectEndDate;
private String projectStatus;
}
......@@ -26,6 +26,8 @@ public interface EmployeeRepo
List<Employee> findByEmployeeIdIn(Set<String> empIdsSet);
List<Employee> findByEmpSubStatusOrderByEmployeeNameAsc(String subStatus);
List<Employee> findByEmpStatusAndShiftLikeOrderByEmployeeIdDesc(String status,String shift);
}
......@@ -50,4 +50,6 @@ public interface IEmployeeService {
public List<Employee> getAllEmployees();
public List<Employee> getEmployeesByEmpStatusAndShift(String empStatus, String shift);
}
......@@ -2,13 +2,12 @@ package com.nisum.myteam.service;
import org.springframework.stereotype.Service;
import com.nisum.myteam.model.dao.Resource;
@Service
public interface IEmployeeShiftService {
public void addEmployeeShift(Resource resource, String loginEmpId);
//public void addEmployeeShift(Resource resource, String loginEmpId);
void updateEmployeeShift(Resource existingTeammate, String loginEmpId);
//void updateEmployeeShift(Resource existingTeammate, String loginEmpId);
}
package com.nisum.myteam.service;
import com.nisum.myteam.exception.handler.MyTeamException;
import com.nisum.myteam.model.dao.*;
import com.nisum.myteam.model.dao.Account;
import com.nisum.myteam.model.dao.EmpLoginData;
import com.nisum.myteam.model.dao.Project;
import com.nisum.myteam.model.dao.ResourceAllocation;
import java.util.HashMap;
import java.util.List;
......@@ -33,15 +36,12 @@ public interface IProjectService {
List<Project> getProjectsUnderDeliveryLead(String managerId) throws MyTeamException;
public Resource addNewBeanchAllocation(Employee employee, String loginEmpId);
// public Resource addNewBeanchAllocation(Employee employee, String loginEmpId);
List<EmpLoginData> employeeLoginsBasedOnDate(long id, String fromDate, String toDate) throws MyTeamException;
String generatePdfReport(long id, String fromDate, String toDate) throws MyTeamException;
//public List<HashMap<Object, Object>> getProjectsForEmployee(String empId);
public Set<String> accountsAssignedToDl(String empId);
public List<HashMap<Object, Object>> deliveryLeadProjects(String empId) throws MyTeamException;
......@@ -58,7 +58,7 @@ public interface IProjectService {
public List<Project> getProjectsForDeliveryLead(String deliveryLeadId);
List<Resource> getResourcesUnderProject(String empId);
List<ResourceAllocation> getResourcesUnderProject(String empId);
}
......@@ -5,9 +5,7 @@ import com.nisum.myteam.model.dao.Employee;
import com.nisum.myteam.model.dao.ResourceAllocation;
import com.nisum.myteam.model.vo.MyProjectAllocationVO;
import com.nisum.myteam.model.vo.ResourceVO;
import org.bson.types.ObjectId;
import java.util.HashMap;
import java.util.List;
public interface IResourceAllocationService {
......@@ -39,7 +37,6 @@ public interface IResourceAllocationService {
List<ResourceVO> getActiveResources(String empId);
// List<Resource> getResourcesForShift(String shift);
public List<ResourceVO> getResourcesForProject(String projectId, String statusFlag);
......@@ -47,13 +44,12 @@ public interface IResourceAllocationService {
public List<ResourceAllocation> getResourcesUnderDeliveryLead(String empId);
public List<ResourceAllocation> getBillingsForEmployee(String empId);
public List<ResourceVO> getBillingsForEmployee(String empId);
public List<ResourceAllocation> getBillingsForProject(String empId, String projectId);
public List<MyProjectAllocationVO> getWorkedProjectsForResource(String empId);
......@@ -61,6 +57,8 @@ public interface IResourceAllocationService {
public List<ResourceAllocation> getAllResources();
public List<ResourceVO> getAllResourcesVO();
public void deleteResourcesUnderProject(String projectId);
......
......@@ -12,37 +12,37 @@ import java.util.List;
@Service
public interface IResourceService {
Resource addResource(Resource projectTeamMate, String loginEmpId) throws MyTeamException;
String updateResource(Resource projectTeamMate, String loginEmpId) throws MyTeamException;
Resource deleteResource(String empId, String projectId, ObjectId id, String loginEmpId);
Resource save(Resource resource);
void addResources(Employee employee, String loginEmpId);
void inactivateResource(Employee employeeReq, Employee employeeUpdated, String loginEmpId);
List<Resource> findByAccountAndActiveAndBillableStatus(String account, boolean status, String billableStatus);
List<Resource> getResourcesSortByStartDate(String employeeId);
List<Resource> getResourcesForProject(String projectId, String status);
List<Resource> getResourcesForEmployee(String empId);
List<Resource> getResourcesForProject(String projectId);
List<Resource> getActiveResources(String empId);
List<Resource> getResourcesForActiveProjects();
List<Resource> getResourcesForShift(String shift);
public List<Resource> getResourcesUnderDeliveryLead(String empId);
public HashMap<String, Object> verifyResourceAssignedToAnyProject(Resource projectTeamMate, String loginEmpId) throws MyTeamException;
// Resource addResource(Resource projectTeamMate, String loginEmpId) throws MyTeamException;
//
// String updateResource(Resource projectTeamMate, String loginEmpId) throws MyTeamException;
//
// Resource deleteResource(String empId, String projectId, ObjectId id, String loginEmpId);
//
// Resource save(Resource resource);
//
// void addResources(Employee employee, String loginEmpId);
//
// void inactivateResource(Employee employeeReq, Employee employeeUpdated, String loginEmpId);
//
// List<Resource> findByAccountAndActiveAndBillableStatus(String account, boolean status, String billableStatus);
//
// List<Resource> getResourcesSortByStartDate(String employeeId);
//
// List<Resource> getResourcesForProject(String projectId, String status);
//
// List<Resource> getResourcesForEmployee(String empId);
//
// List<Resource> getResourcesForProject(String projectId);
//
// List<Resource> getActiveResources(String empId);
//
// List<Resource> getResourcesForActiveProjects();
//
// List<Resource> getResourcesForShift(String shift);
//
// public List<Resource> getResourcesUnderDeliveryLead(String empId);
//
// public HashMap<String, Object> verifyResourceAssignedToAnyProject(Resource projectTeamMate, String loginEmpId) throws MyTeamException;
}
......@@ -4,6 +4,7 @@ import com.nisum.myteam.model.dao.Employee;
import com.nisum.myteam.model.dao.Project;
import com.nisum.myteam.model.dao.ResourceAllocation;
import com.nisum.myteam.model.vo.EmployeeDashboardVO;
import com.nisum.myteam.model.vo.ResourceVO;
import com.nisum.myteam.service.IDashboardService;
import com.nisum.myteam.service.IEmployeeService;
import com.nisum.myteam.service.IProjectService;
......@@ -34,31 +35,35 @@ public class DashboardService implements IDashboardService {
List<Employee> allEmployees = employeeService.getAllEmployees();
List<EmployeeDashboardVO> employeeDashboard = new ArrayList<>();
Map<String, Object> teamMatesMap = new HashMap();
Map<String, Object> resourcesMap = new HashMap();
Map<String, Object> teamMatesStatusMap = new HashMap();
// Find all active employees
List<ResourceAllocation> resources = resourceService.getAllResources();
//List<ResourceAllocation> resources = resourceService.getAllResources();
for (ResourceAllocation resource : resources) {
List<ResourceVO> resources = resourceService.getAllResourcesVO();
for (ResourceVO resource : resources) {
//if (resource.isActive()) {
if (resource.getBillingEndDate().compareTo(new Date())>0) {
if (resource.getBillingEndDate().compareTo(new Date()) > 0) {
Project project = projectService.getProjectByProjectId(resource.getProjectId());
if (project != null && project.getStatus() != null
&& !"Completed".equalsIgnoreCase(project.getStatus())) {
Object projectTeamMate = teamMatesMap
.get(resource.getEmployeeId());
Object projectResource = resourcesMap.get(resource.getEmployeeId());
if (projectTeamMate == null) {
if (projectResource == null) {
List listOfObjects = new ArrayList<>();
listOfObjects.add(resource);
// A person can have multiple active projects with billability
teamMatesMap.put(resource.getEmployeeId(), listOfObjects);
resourcesMap.put(resource.getEmployeeId(), listOfObjects);
} else {
List existingRecordsInMap = (List) teamMatesMap
List existingRecordsInMap = (List) resourcesMap
.get(resource.getEmployeeId());
existingRecordsInMap.add(resource);
teamMatesMap.put(resource.getEmployeeId(),
resourcesMap.put(resource.getEmployeeId(),
existingRecordsInMap);
}
......@@ -66,13 +71,13 @@ public class DashboardService implements IDashboardService {
}
}
for (Employee emp : allEmployees) {
if (teamMatesMap.containsKey(emp.getEmployeeId())) {
Object value = teamMatesMap.get(emp.getEmployeeId());
if (resourcesMap.containsKey(emp.getEmployeeId())) {
Object value = resourcesMap.get(emp.getEmployeeId());
if (value instanceof List) {
List listOfTeamMates = (List) value;
String billableStatus = "NA";
for (Object obj : listOfTeamMates) {
ResourceAllocation projectTeamMate = (ResourceAllocation) obj;
ResourceVO projectTeamMate = (ResourceVO) obj;
String status = projectTeamMate.getBillableStatus();
if (status == null) {
status = "NA";
......
......@@ -7,7 +7,6 @@ import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Service;
import com.nisum.myteam.model.dao.EmployeeShift;
import com.nisum.myteam.model.dao.Resource;
import com.nisum.myteam.repository.EmployeeShiftRepo;
import com.nisum.myteam.service.IEmployeeShiftService;
import com.nisum.myteam.utils.MyTeamUtils;
......@@ -24,29 +23,29 @@ public class EmployeeShiftService implements IEmployeeShiftService {
@Autowired
private MongoTemplate mongoTemplate;
@Override
public void addEmployeeShift(Resource resource, String loginEmpId) {
EmployeeShift empShift = new EmployeeShift();
empShift.setEmployeeName(resource.getEmployeeName());
empShift.setEmployeeId(resource.getEmployeeId());
empShift.setShift(resource.getShift());
empShift.setActive(resource.isActive());
empShift.setAuditFields(loginEmpId, MyTeamUtils.CREATE);
empShiftsRepo.save(empShift);
log.info("The Employee Shift has been Persisted ::" + empShift);
}
public void updateEmployeeShift(Resource resource, String loginEmpId) {
Query getQuery = new Query();
getQuery.addCriteria(new Criteria().andOperator(Criteria.where("active").is(true),
Criteria.where("employeeId").is(resource.getEmployeeId())));
EmployeeShift existingEmpShift = mongoTemplate.findOne(getQuery, EmployeeShift.class);
if (existingEmpShift != null) {
existingEmpShift.setActive(false);
existingEmpShift.setAuditFields(loginEmpId, MyTeamUtils.UPDATE);
mongoTemplate.save(existingEmpShift);
log.info("The shift has been updated::" + existingEmpShift);
}
}
// @Override
// public void addEmployeeShift(Resource resource, String loginEmpId) {
// EmployeeShift empShift = new EmployeeShift();
// empShift.setEmployeeName(resource.getEmployeeName());
// empShift.setEmployeeId(resource.getEmployeeId());
// empShift.setShift(resource.getShift());
// empShift.setActive(resource.isActive());
// empShift.setAuditFields(loginEmpId, MyTeamUtils.CREATE);
// empShiftsRepo.save(empShift);
// log.info("The Employee Shift has been Persisted ::" + empShift);
// }
// public void updateEmployeeShift(Resource resource, String loginEmpId) {
// Query getQuery = new Query();
// getQuery.addCriteria(new Criteria().andOperator(Criteria.where("active").is(true),
// Criteria.where("employeeId").is(resource.getEmployeeId())));
// EmployeeShift existingEmpShift = mongoTemplate.findOne(getQuery, EmployeeShift.class);
// if (existingEmpShift != null) {
// existingEmpShift.setActive(false);
// existingEmpShift.setAuditFields(loginEmpId, MyTeamUtils.UPDATE);
// mongoTemplate.save(existingEmpShift);
// log.info("The shift has been updated::" + existingEmpShift);
// }
// }
}
......@@ -193,6 +193,54 @@ public class ResourceAllocationService implements IResourceAllocationService {
}
public List<ResourceVO> getAllResourcesVO() {
return getAllResources().stream().map(resource -> {
ResourceVO resourceVO = new ResourceVO();
resourceVO.setId(resource.getId());
resourceVO.setProjectId(resource.getProjectId());
resourceVO.setEmployeeId(resource.getEmployeeId());
Employee employee = employeeService.getEmployeeById(resource.getEmployeeId());
if (employee != null) {
resourceVO.setEmployeeName(employee.getEmployeeName());
resourceVO.setDesignation(employee.getDesignation());
resourceVO.setEmailId(employee.getEmailId());
resourceVO.setMobileNo(employee.getMobileNumber());
}
Project project = projectService.getProjectByProjectId(resource.getProjectId());
if (project != null) {
resourceVO.setProjectName(project.getProjectName());
resourceVO.setProjectStartDate(project.getProjectStartDate());
resourceVO.setProjectEndDate(project.getProjectEndDate());
resourceVO.setProjectStatus(project.getStatus());
if (project.getAccountId() != null) {
Account account = accountService.getAccountById(project.getAccountId());
if (account != null) {
resourceVO.setAccountName(account.getAccountName());
}
}
}
//Account account=accountService.getAccountById(domainService.getDomainById(project.getProjectId()).getAccountId());
resourceVO.setBillableStatus(resource.getBillableStatus());
resourceVO.setBillingStartDate(resource.getBillingStartDate());
resourceVO.setBillingEndDate(resource.getBillingEndDate());
resourceVO.setResourceRole(resource.getResourceRole());
if (resource.getBillingEndDate().compareTo(new Date()) > 0) {
resourceVO.setResourceStatus(ResourceStatus.ACTIVE.getStatus());
} else {
resourceVO.setResourceStatus(ResourceStatus.IN_ACTIVE.getStatus());
}
return resourceVO;
}).collect(Collectors.toList());
}
public List<ResourceAllocation> getResourcesSortByBillingStartDate(String employeeId) {
Query query = prepareQuery(employeeId, MyTeamUtils.BILLING_START_DATE);
return mongoTemplate.find(query, ResourceAllocation.class);
......@@ -334,6 +382,9 @@ public class ResourceAllocationService implements IResourceAllocationService {
MyProjectAllocationVO myProject = new MyProjectAllocationVO();
myProject.setProjectId(project.getProjectId());
myProject.setProjectName(project.getProjectName());
myProject.setProjectStartDate(project.getProjectStartDate());
myProject.setProjectEndDate(project.getProjectEndDate());
myProject.setProjectStatus(project.getStatus());
myProject.setAccountName(account.getAccountName());
myProject.setBillableStatus(resourceAlloc.getBillableStatus());
......@@ -377,17 +428,17 @@ public class ResourceAllocationService implements IResourceAllocationService {
@Override
public List<ResourceAllocation> getBillingsForEmployee(String empId) {
// List<Billing> billingsList = billingRepo.findByEmployeeId(empId);
public List<ResourceVO> getBillingsForEmployee(String empId) {
List<ResourceVO> finalList=new ArrayList<>();
List<ResourceAllocation> resourcesList = resourceAllocationRepo.findByEmployeeId(empId);
if (resourcesList == null || resourcesList.size() == 0) {
return resourcesList;
} else {
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());
return resourcesList.stream().sorted(Comparator.comparing(ResourceAllocation::getBillingStartDate).reversed()).collect(Collectors.toList());
List<ResourceAllocation> sortedList = resourcesList.stream().sorted(Comparator.comparing(ResourceAllocation::getBillingStartDate).reversed()).collect(Collectors.toList());
finalList= convertResourcesToResourcesVO(sortedList);
}
return finalList;
}
@Override
......@@ -434,6 +485,59 @@ public class ResourceAllocationService implements IResourceAllocationService {
}
private List<ResourceVO> convertResourcesToResourcesVO(List<ResourceAllocation> resourcesList) {
List<ResourceVO> finalList = new ArrayList<>();
if (resourcesList != null && resourcesList.size() > 0) {
finalList = resourcesList.stream().map(resource -> {
ResourceVO resourceVO = new ResourceVO();
resourceVO.setId(resource.getId());
resourceVO.setProjectId(resource.getProjectId());
resourceVO.setEmployeeId(resource.getEmployeeId());
Employee employee = employeeService.getEmployeeById(resource.getEmployeeId());
if (employee != null) {
resourceVO.setEmployeeName(employee.getEmployeeName());
resourceVO.setDesignation(employee.getDesignation());
resourceVO.setEmailId(employee.getEmailId());
resourceVO.setMobileNo(employee.getMobileNumber());
}
Project project = projectService.getProjectByProjectId(resource.getProjectId());
if (project != null) {
resourceVO.setProjectName(project.getProjectName());
resourceVO.setProjectStartDate(project.getProjectStartDate());
resourceVO.setProjectEndDate(project.getProjectEndDate());
resourceVO.setProjectStatus(project.getStatus());
if (project.getAccountId() != null) {
Account account = accountService.getAccountById(project.getAccountId());
if (account != null) {
resourceVO.setAccountName(account.getAccountName());
}
}
}
//Account account=accountService.getAccountById(domainService.getDomainById(project.getProjectId()).getAccountId());
resourceVO.setBillableStatus(resource.getBillableStatus());
resourceVO.setBillingStartDate(resource.getBillingStartDate());
resourceVO.setBillingEndDate(resource.getBillingEndDate());
resourceVO.setResourceRole(resource.getResourceRole());
if (resource.getBillingEndDate().compareTo(new Date()) > 0) {
resourceVO.setResourceStatus(ResourceStatus.ACTIVE.getStatus());
} else {
resourceVO.setResourceStatus(ResourceStatus.IN_ACTIVE.getStatus());
}
return resourceVO;
}).collect(Collectors.toList());
}
return finalList;
}
}
......
......@@ -67,7 +67,6 @@ public class ResourceService implements IResourceService {
return resourceRepo.save(resource);
}
@Override
public Resource addResource(Resource resourceReq, String loginEmpId) throws MyTeamException {
// calling a method
......@@ -111,7 +110,7 @@ public class ResourceService implements IResourceService {
billingService.addBilling(billings, loginEmpId);
empShiftService.addEmployeeShift(resourceReq, loginEmpId);
//empShiftService.addEmployeeShift(resourceReq, loginEmpId);
// calling method
addOrUpdateTeamMateRole(resourceReq.getRole(), resourceReq.getProjectId(), resourceReq.getEmployeeId(), false,
......@@ -120,7 +119,6 @@ public class ResourceService implements IResourceService {
return resourcePersisted;
}
@Override
public String updateResource(Resource resourceReq, String loginEmpId) throws MyTeamException {
// String result = null;
MyTeamResultDTO myResultDto = new MyTeamResultDTO();
......@@ -303,7 +301,7 @@ public class ResourceService implements IResourceService {
|| (resourceReq.getShift() != null)
&& !resourceReq.getShift().equalsIgnoreCase(existingResource.getShift())) {
empShiftService.updateEmployeeShift(existingResource, loginEmpId);
//empShiftService.updateEmployeeShift(existingResource, loginEmpId);
existingResource.setShift(resourceReq.getShift());
Employee employeeDB = employeeRepo.findByEmployeeId(resourceReq.getEmployeeId());
......@@ -336,7 +334,7 @@ public class ResourceService implements IResourceService {
}
@Override
// @Override
public Resource deleteResource(String empId, String projectId, ObjectId id, String loginEmpId) {
Resource existingResource = resourceRepo.findById(id);
existingResource.setActive(false);
......@@ -384,7 +382,7 @@ public class ResourceService implements IResourceService {
// audit
// fields
Resource resource=resourceRepo.save(resourceBench);
empShiftService.updateEmployeeShift(existingResource, loginEmpId);
//empShiftService.updateEmployeeShift(existingResource, loginEmpId);
return resource;
}
......@@ -471,43 +469,43 @@ public class ResourceService implements IResourceService {
// return null;
}
public void inactivateResource(Employee employeeReq, Employee employeeUpdated, String loginEmpId) {
// inactive the employee from the assigned project
if (employeeReq.getEmpStatus().equals(MyTeamUtils.IN_ACTIVE_SPACE) && employeeReq.getEndDate() != null
&& employeeReq.getEndDate().compareTo(new Date()) <= 0) {
List<Resource> resourcesList = resourceRepo.findByEmployeeIdAndActive(employeeReq.getEmployeeId(), true);
if (resourcesList.size() == 1) {
Resource resource = resourcesList.get(0);
resource.setActive(false);
resource.setEndDate(employeeReq.getEndDate());
List<Billing> billingList = billingService.getActiveBillings(resource.getEmployeeId(),
resource.getProjectId());
if (billingList != null && !billingList.isEmpty()) {
billingService.addBillingtoResource(billingList.get(0), employeeUpdated, loginEmpId);
}
resource.setAuditFields(loginEmpId, MyTeamUtils.UPDATE);
resourceRepo.save(resource);
empShiftService.updateEmployeeShift(resource, loginEmpId);
}
}
}
@Override
//public void inactivateResource(Employee employeeReq, Employee employeeUpdated, String loginEmpId) {
// // inactive the employee from the assigned project
// if (employeeReq.getEmpStatus().equals(MyTeamUtils.IN_ACTIVE_SPACE) && employeeReq.getEndDate() != null
// && employeeReq.getEndDate().compareTo(new Date()) <= 0) {
//
// List<Resource> resourcesList = resourceRepo.findByEmployeeIdAndActive(employeeReq.getEmployeeId(), true);
// if (resourcesList.size() == 1) {
// Resource resource = resourcesList.get(0);
// resource.setActive(false);
// resource.setEndDate(employeeReq.getEndDate());
//
// List<Billing> billingList = billingService.getActiveBillings(resource.getEmployeeId(),
// resource.getProjectId());
// if (billingList != null && !billingList.isEmpty()) {
// billingService.addBillingtoResource(billingList.get(0), employeeUpdated, loginEmpId);
// }
// resource.setAuditFields(loginEmpId, MyTeamUtils.UPDATE);
// resourceRepo.save(resource);
// empShiftService.updateEmployeeShift(resource, loginEmpId);
// }
// }
// }
// @Override
public List<Resource> findByAccountAndActiveAndBillableStatus(String account, boolean status,
String billableStatus) {
return resourceRepo.findByAccountAndActiveAndBillableStatus(account, status, billableStatus);
}
@Override
// @Override
public List<Resource> getResourcesSortByStartDate(String employeeId) {
Query query = prepareQuery(employeeId, MyTeamUtils.START_DATE);
return mongoTemplate.find(query, Resource.class);
}
@Override
// @Override
public List<Resource> getResourcesForProject(String projectId, String statusFlag) {
List<Resource> resourcesList = new ArrayList<>();
List<Resource> resourceListPersisted = resourceRepo.findByProjectId(projectId);
......@@ -526,7 +524,7 @@ public class ResourceService implements IResourceService {
return resourcesList;
}
@Override
// @Override
public List<Resource> getResourcesForEmployee(String empId) {
return resourceRepo.findByEmployeeId(empId);
}
......@@ -539,7 +537,7 @@ public class ResourceService implements IResourceService {
return resourceRepo.findAll();
}
@Override
// @Override
public List<Resource> getActiveResources(String empId) {
List<Resource> resourcesList = new ArrayList<>();
List<Resource> resourcesListPers = resourceRepo.findByEmployeeId(empId);
......@@ -551,7 +549,7 @@ public class ResourceService implements IResourceService {
return resourcesList;
}
@Override
// @Override
public List<Resource> getResourcesForActiveProjects() {
List<Project> projects = projectService.getAllProjects();
List<Resource> resourceList = new ArrayList<>();
......@@ -565,7 +563,7 @@ public class ResourceService implements IResourceService {
return resourceList;
}
@Override
// @Override
public List<Resource> getResourcesForShift(String shift) {
List<Resource> resourcesListPers = null;
List<Resource> resourcesList = new ArrayList<>();
......@@ -588,7 +586,7 @@ public class ResourceService implements IResourceService {
@Override
// @Override
public List<Resource> getResourcesUnderDeliveryLead(String deliveryLeadId) {
List<String> projectIdsList = new ArrayList<>();
List<Resource> resourcesList = new ArrayList<>();
......@@ -614,7 +612,7 @@ public class ResourceService implements IResourceService {
@Override
// @Override
public HashMap<String,Object> verifyResourceAssignedToAnyProject(Resource resourceReq, String loginEmpId) throws MyTeamException {
boolean flag = false;
String projectName = null;
......
......@@ -31,11 +31,11 @@ myApp.controller("dashboardController", function($scope, $http, myFactory,export
columnDefs : [
{field : 'employeeId',displayName: 'Emp ID', enableColumnMenu: false, enableSorting: false,enableFiltering:true, width:100,cellTemplate: getEmpDetTemplate},
{field : 'employeeName',displayName: 'Employee Name ', enableColumnMenu: false, enableSorting: true,enableFiltering:true,width:200},
{field : 'account',displayName: 'Client', enableColumnMenu: false, enableSorting: true,enableFiltering:false,width:100},
{field : 'accountName',displayName: 'Client', enableColumnMenu: false, enableSorting: true,enableFiltering:false,width:100},
{field : 'domain',displayName: 'Domain', enableColumnMenu: false, enableSorting: true,enableFiltering:false,width:100},
{field : 'projectName',displayName: 'Project', enableColumnMenu: false, enableSorting: false,enableFiltering:false,width:150},
{field : 'startDate',displayName: 'Billing Start Date', enableColumnMenu: false, enableSorting: true,cellFilter: 'date:"dd-MMM-yyyy"',enableFiltering:false,width:150},
{field : 'endDate',displayName: 'Billing End Date', enableColumnMenu: false, enableSorting: true,cellFilter: 'date:"dd-MMM-yyyy"',enableFiltering:false,width:150},
{field : 'billingStartDate',displayName: 'Billing Start Date', enableColumnMenu: false, enableSorting: true,cellFilter: 'date:"dd-MMM-yyyy"',enableFiltering:false,width:150},
{field : 'billingEndDate',displayName: 'Billing End Date', enableColumnMenu: false, enableSorting: true,cellFilter: 'date:"dd-MMM-yyyy"',enableFiltering:false,width:150},
{field : 'empStatus',displayName: 'Status', enableColumnMenu: false, enableSorting: true,enableFiltering: true,width:80},
{field : 'empSubStatus',displayName: 'Sub Status', enableColumnMenu: false, enableSorting: true,enableFiltering:true,width:120,cellClass:function(grid,row,col){
......@@ -208,11 +208,12 @@ myApp.controller("dashboardController", function($scope, $http, myFactory,export
{field : 'billableStatus',displayName: 'Billability', enableColumnMenu: false, enableSorting: false,minWidth : 100,width: 150},
{field : 'projectStartDate',displayName: 'Start Date', enableColumnMenu: false, enableSorting: false, cellFilter: 'date:"dd-MMM-yyyy"',minWidth : 100,width: 150},
{field : 'projectEndDate',displayName: 'End Date', enableColumnMenu: false, enableSorting: false, cellFilter: 'date:"dd-MMM-yyyy"' ,minWidth : 100,width: 150},
{field : 'resourceStatus',displayName: 'Status', enableColumnMenu: false,enableSorting: false,minWidth : 100,width: 150}
{field : 'projectStatus',displayName: 'Status', enableColumnMenu: false,enableSorting: false,minWidth : 100,width: 150}
]
};
$scope.gridOptionsEmpLocationDetails = {
paginationPageSizes : [ 10, 20, 30, 40, 50, 100],
paginationPageSize : 10,
......@@ -257,7 +258,7 @@ myApp.controller("dashboardController", function($scope, $http, myFactory,export
enableCellEditOnFocus: true,
columnDefs : [
{field : 'projectName',displayName: 'Project', enableColumnMenu: true, enableSorting: true,minWidth : 100,width: 150},
{field : 'account',displayName: 'Account', enableColumnMenu: false, enableSorting: false,minWidth : 100,width: 150},
{field : 'accountName',displayName: 'Account', enableColumnMenu: false, enableSorting: false,minWidth : 100,width: 150},
{field: 'billingStartDate',displayName: 'Start Date',
cellFilter: 'date:"dd-MMM-yyyy"',minWidth : 100,width: 150
},
......@@ -267,7 +268,7 @@ myApp.controller("dashboardController", function($scope, $http, myFactory,export
cellFilter: 'date:"dd-MMM-yyyy"',minWidth : 100,width: 150
},
{field : 'comments',displayName: 'Comments', enableColumnMenu: false, enableSorting: false,minWidth : 100,width: 150},
{field : 'active',displayName: 'Active',enableColumnMenu: false, enableSorting: false,cellTemplate:getCellActiveTemplateBilling,enableCellEdit: false,minWidth : 100,width: 150}
{field : 'resourceStatus',displayName: 'Status',enableColumnMenu: false, enableSorting: false,cellTemplate:getCellActiveTemplateBilling,enableCellEdit: false,minWidth : 100,width: 150}
]
};
......
......@@ -16,10 +16,8 @@ function($mdDateLocaleProvider) {
//TODO: Replace this appUri with the domain name created
myApp.constant('appConfig', {
appName: "MyTime",
<<<<<<< Updated upstream
=======
//appUri: "http://10.3.45.11:8080/myTeam/",
>>>>>>> Stashed changes
appUri: "http://localhost:8080/myTeam/",
version:"1.0",
empStartId:16001,
......
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