Commit f04bcb2a authored by Vijay Akula's avatar Vijay Akula

Shift details page implementation

parent 3a7ad803
......@@ -107,7 +107,6 @@ public class EmployeeController {
}
// @RequestMapping(value = "/getEmployeeRoleData"
@RequestMapping(value = "/employees/employeeId/{empId}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<?> getEmployeeById(@PathVariable("empId") String empId, HttpServletRequest request)
throws MyTeamException {
......@@ -147,7 +146,6 @@ public class EmployeeController {
return new ResponseEntity<ResponseDetails>(getRespDetails, HttpStatus.OK);
}
// @RequestMapping(value = "/getManagers"
@RequestMapping(value = "/employees/managers/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<?> getManagers(HttpServletRequest request) throws MyTeamException {
ResponseDetails getRespDetails = new ResponseDetails(new Date(), 905, "Retrieved Managers successfully",
......@@ -156,7 +154,6 @@ public class EmployeeController {
}
// @RequestMapping(value = "/getUserRoles"
@RequestMapping(value = "/employees/active", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<?> getActiveEmployees(HttpServletRequest request) throws MyTeamException {
......@@ -167,7 +164,6 @@ public class EmployeeController {
}
// @RequestMapping(value = "/getAccounts"
@RequestMapping(value = "/employees/accounts/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<?> getAccounts(HttpServletRequest request) throws MyTeamException {
List<Account> activeAccountList = empService.getAccounts().stream()
......@@ -183,7 +179,6 @@ public class EmployeeController {
}
// @RequestMapping(value = "/getEmployeeByStatus
@RequestMapping(value = "/employees/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<?> getEmployeeByStatus(@RequestParam("status") String status, HttpServletRequest request) {
......@@ -209,7 +204,6 @@ public class EmployeeController {
return new ResponseEntity<>(details, HttpStatus.OK);
}
// @RequestMapping(value = "/getDeliveryLeads",
@RequestMapping(value = "/employees/deliveryLeads/{domainId}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<?> getDeliveryLeads(@PathVariable("domainId") String domainId, HttpServletRequest request)
throws MyTeamException {
......
......@@ -5,6 +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.ResourceAllocation;
import com.nisum.myteam.model.vo.EmployeeShiftsVO;
import com.nisum.myteam.model.vo.ResourceVO;
import com.nisum.myteam.repository.EmployeeVisaRepo;
import com.nisum.myteam.service.IEmployeeService;
......@@ -40,7 +41,6 @@ public class ResourceAllocationController {
@Autowired
private ResourceAllocationService resourceAllocService;
//tested in all the cases.ok
@RequestMapping(value = "/resources", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<?> createResource(@RequestBody ResourceAllocation resourceAllocationReq,
@RequestParam(value = "loginEmpId", required = true) String loginEmpId, HttpServletRequest request) throws MyTeamException {
......@@ -72,7 +72,6 @@ public class ResourceAllocationController {
}
//tested in all the cases.ok
@RequestMapping(value = "/resources", method = RequestMethod.PUT, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<?> updateResource(@RequestBody ResourceAllocation resourceAllocationReq,
@RequestParam(value = "loginEmpId") String loginEmpId, HttpServletRequest request) throws MyTeamException {
......@@ -94,7 +93,6 @@ public class ResourceAllocationController {
return new ResponseEntity<ResponseDetails>(responseDetails, HttpStatus.OK);
}
//Tested Ok
@RequestMapping(value = "/resources", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<?> deleteResource(@RequestBody ResourceAllocation resourceReq,
@RequestParam(value = "loginEmpId", required = true) String loginEmpId, HttpServletRequest request) throws MyTeamException {
......@@ -112,9 +110,6 @@ public class ResourceAllocationController {
}
//Ok Tested in all of the cases
@RequestMapping(value = "/resources/project/{projectId}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<?> getResourcesForProject(@PathVariable(value = "projectId", required = true) String projectId,
@RequestParam(value = "status", required = false, defaultValue = MyTeamUtils.ACTIVE) String status,
......@@ -133,8 +128,6 @@ public class ResourceAllocationController {
return new ResponseEntity<ResponseDetails>(responseDetails, HttpStatus.OK);
}
//ok
///getMyProjectAllocations
@RequestMapping(value = "/resources/getMyProjectAllocations", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<?> getMyProjectAllocations(
@RequestParam("employeeId") String employeeId, HttpServletRequest request) throws MyTeamException {
......@@ -185,7 +178,6 @@ public class ResourceAllocationController {
}
//ok tested
@RequestMapping(value = "/resources/active", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<?> getActiveResources(@RequestParam(value = "employeeId", required = false) String employeeId, HttpServletRequest request)
throws MyTeamException {
......@@ -204,7 +196,6 @@ public class ResourceAllocationController {
//ok working
@RequestMapping(value = "/resources/deliverylead/{deliveryLeadId}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<?> getTeamDetails(@PathVariable(value = "deliveryLeadId", required = true) String deliveryLeadId, HttpServletRequest request)
throws MyTeamException {
......@@ -223,7 +214,6 @@ public class ResourceAllocationController {
}
//ok tested working
@RequestMapping(value = "/resources/unAssignedEmployees", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<?> getUnAssignedEmployees(HttpServletRequest request) throws MyTeamException {
List<Employee> employeesList = resourceAllocService.getUnAssignedEmployees();
......@@ -234,7 +224,6 @@ public class ResourceAllocationController {
}
//@RequestMapping(value = "/getEmployeeBillingDetailsAll"
@RequestMapping(value = "/resources/billing", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<ResourceVO>> getAllBillingsForEmployee(@RequestParam("employeeId") String employeeId)
throws MyTeamException {
......@@ -242,7 +231,6 @@ public class ResourceAllocationController {
return new ResponseEntity<>(resourceAllocList, HttpStatus.OK);
}
// @RequestMapping(value = "/getEmployeeBillingDetails"
@RequestMapping(value = "/resources/billing/project/{projectId}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<ResourceAllocation>> getBillingsForProject(@PathVariable("projectId") String projectId,
@RequestParam("employeeId") String employeeId) throws MyTeamException {
......@@ -251,42 +239,22 @@ public class ResourceAllocationController {
}
@RequestMapping(value = "/resources/shifts/{shift}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<?> getResourcesForShift(@PathVariable(value = "shift", required = true) String shift, HttpServletRequest request)
throws MyTeamException {
if (StringUtils.isNotBlank(shift)) {
List<EmployeeShiftsVO> resourcesList = resourceAllocService.getResourcesForShift(shift);
ResponseDetails responseDetails = new ResponseDetails(new Date(), 602, "Resources have been retrieved successfully",
"List of Resources for the provided shift", resourcesList, request.getRequestURI(), "Resource List for shift", null);
return new ResponseEntity<ResponseDetails>(responseDetails, HttpStatus.OK);
}
ResponseDetails responseDetails = new ResponseDetails(new Date(), 602, "Please provide the valid Shift value",
"List of Resources for the provided shift", null, request.getRequestURI(), "Resource details", null);
return new ResponseEntity<ResponseDetails>(responseDetails, HttpStatus.OK);
}
// @RequestMapping(value = "/resources/shifts/{shift}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
// public ResponseEntity<?> getResourcesForShift(@PathVariable(value = "shift", required = true) String shift, HttpServletRequest request)
// throws MyTeamException {
//
// if (StringUtils.isNotBlank(shift)) {
// List<Resource> resourcesList = resourceService.getResourcesForShift(shift);
// ResponseDetails responseDetails = new ResponseDetails(new Date(), 602, "Resources have been retrieved successfully",
// "List of Resources for the provided shift", resourcesList, request.getRequestURI(), "Resource List for shift", null);
// return new ResponseEntity<ResponseDetails>(responseDetails, HttpStatus.OK);
// }
// ResponseDetails responseDetails = new ResponseDetails(new Date(), 602, "Please provide the valid Shift value",
// "List of Resources for the provided shift", null, request.getRequestURI(), "Resource details", null);
// return new ResponseEntity<ResponseDetails>(responseDetails, HttpStatus.OK);
//
// }
// @RequestMapping(value = "/resourceAllocation/addEmployeeToTeamWithCheck", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
// public ResponseEntity<?> addEmployeeToTeamWithCheck(@RequestBody ResourceAllocation resourceReq,
// @RequestParam(value = "loginEmpId") String loginEmpId, HttpServletRequest request) throws MyTeamException {
//
// if (StringUtils.isNotBlank(loginEmpId)) {
// HashMap<String, Object> responseMap = resourceAllocService.verifyResourceAssignedToAnyProject(resourceReq, loginEmpId);
//
// ResponseDetails responseDetails = new ResponseDetails(new Date(), 602, responseMap.get("message").toString(),
// "List of Resources for dashboard", responseMap.get("resourceObj"), request.getRequestURI(), "Resource details", null);
// return new ResponseEntity<ResponseDetails>(responseDetails, HttpStatus.OK);
// }
// ResponseDetails responseDetails = new ResponseDetails(new Date(), 602, "Please provide Valid Employee Id",
// "Verification of resource in Bench Project", null, request.getRequestURI(), "Resource details", resourceReq);
// return new ResponseEntity<ResponseDetails>(responseDetails, HttpStatus.OK);
//
// }
}
package com.nisum.myteam.model.vo;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
public class EmployeeShiftsVO {
private String employeeId;
private String employeeName;
private String emailId;
private String projectName;
private String mobileNo;
}
......@@ -5,5 +5,7 @@ import org.springframework.data.mongodb.repository.MongoRepository;
import com.nisum.myteam.model.dao.EmployeeShift;
public interface EmployeeShiftRepo extends MongoRepository<EmployeeShift, String> {
public EmployeeShift findByEmployeeId(String employeeId);
}
\ No newline at end of file
package com.nisum.myteam.service;
import com.nisum.myteam.model.dao.EmployeeShift;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public interface IEmployeeShiftService {
......@@ -9,5 +12,9 @@ public interface IEmployeeShiftService {
//public void addEmployeeShift(Resource resource, String loginEmpId);
//void updateEmployeeShift(Resource existingTeammate, String loginEmpId);
public List<EmployeeShift> getAllEmployeeShifts();
public EmployeeShift getEmployeeShift(String employeeId);
}
......@@ -3,6 +3,7 @@ package com.nisum.myteam.service;
import com.nisum.myteam.exception.handler.MyTeamException;
import com.nisum.myteam.model.dao.Employee;
import com.nisum.myteam.model.dao.ResourceAllocation;
import com.nisum.myteam.model.vo.EmployeeShiftsVO;
import com.nisum.myteam.model.vo.MyProjectAllocationVO;
import com.nisum.myteam.model.vo.ResourceVO;
......@@ -51,7 +52,7 @@ public interface IResourceAllocationService {
public ResourceAllocation addResourceToBenchProject(Employee employee, String loginEmpId) throws MyTeamException;
// List<Resource> getResourcesForShift(String shift);
public List<EmployeeShiftsVO> getResourcesForShift(String shift);
// List<Resource> getAllResourcesForProject(String projectId, String status);
......
package com.nisum.myteam.service.impl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Service;
import com.nisum.myteam.model.dao.EmployeeShift;
import com.nisum.myteam.repository.EmployeeShiftRepo;
import com.nisum.myteam.service.IEmployeeShiftService;
import com.nisum.myteam.utils.MyTeamUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
@Slf4j
public class EmployeeShiftService implements IEmployeeShiftService {
@Autowired
private EmployeeShiftRepo empShiftsRepo;
@Autowired
private EmployeeShiftRepo empShiftsRepo;
@Autowired
private MongoTemplate mongoTemplate;
@Autowired
private MongoTemplate mongoTemplate;
// @Override
// public void addEmployeeShift(Resource resource, String loginEmpId) {
......@@ -48,4 +46,18 @@ public class EmployeeShiftService implements IEmployeeShiftService {
// }
// }
public List<EmployeeShift> getAllEmployeeShifts() {
return empShiftsRepo.findAll();
}
public EmployeeShift getEmployeeShift(String employeeId) {
EmployeeShift empShift = null;
if (StringUtils.isNotBlank(employeeId)) {
empShift = empShiftsRepo.findByEmployeeId(employeeId);
}
return empShift;
}
}
......@@ -2,6 +2,7 @@ package com.nisum.myteam.service.impl;
import com.nisum.myteam.exception.handler.MyTeamException;
import com.nisum.myteam.model.dao.*;
import com.nisum.myteam.model.vo.EmployeeShiftsVO;
import com.nisum.myteam.model.vo.MyProjectAllocationVO;
import com.nisum.myteam.model.vo.ResourceVO;
import com.nisum.myteam.repository.ResourceAllocationRepo;
......@@ -9,6 +10,7 @@ import com.nisum.myteam.service.*;
import com.nisum.myteam.statuscodes.ResourceStatus;
import com.nisum.myteam.utils.MyTeamDateUtils;
import com.nisum.myteam.utils.MyTeamUtils;
import com.nisum.myteam.utils.constants.Shifts;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Sort;
......@@ -42,6 +44,8 @@ public class ResourceAllocationService implements IResourceAllocationService {
@Autowired
private IEmployeeService employeeService;
@Autowired
private IEmployeeShiftService empShiftService;
public HashMap<String, Object> respMap = new HashMap<>();
......@@ -131,8 +135,9 @@ public class ResourceAllocationService implements IResourceAllocationService {
log.info("ResourceALloc Req::" + resourceAllocation);
log.info("" + project.getProjectEndDate().toString());
if (!resourceAllocation.getBillingEndDate().before(project.getProjectEndDate())) {
log.info("Billing end date should be before Project End Date.");
//if (!resourceAllocation.getBillingEndDate().before(project.getProjectEndDate())|| !resourceAllocation.getBillingEndDate().equals(project.getProjectEndDate())) {
if(!(resourceAllocation.getBillingEndDate().compareTo(project.getProjectEndDate())<=0)) {
log.info("Billing end date should be on or before Project End Date.");
respMap.put("statusCode", 813);
respMap.put("message", "Billing end date should be before Project End Date.");
isValid = false;
......@@ -566,9 +571,57 @@ public class ResourceAllocationService implements IResourceAllocationService {
}
@Override
public List<EmployeeShiftsVO> getResourcesForShift(String shift) {
List<ResourceAllocation> resourcesListPers = null;
List<EmployeeShiftsVO> resourcesList = new ArrayList<>();
List<Project> projects = projectService.getAllProjects();
for (Project project : projects) {
if ("Active".equalsIgnoreCase(project.getStatus())) {
resourcesListPers = getAllResourcesForProject(project.getProjectId());
for (ResourceAllocation resource : resourcesListPers) {
// EmployeeShift empShift = empShiftService.getEmployeeShift(resource.getEmployeeId());
// if (empShift != null) {
// if (empShift.getShift() != null && empShift.getShift().equalsIgnoreCase(shift))
// resourcesList.add(resource);
// else if (empShift.getShift() == null && Shifts.SHIFT1.getShiftType().equalsIgnoreCase(shift))
// resourcesList.add(resource);
//
// }
Employee employee = employeeService.getEmployeeById(resource.getEmployeeId());
EmployeeShiftsVO shiftsVO = new EmployeeShiftsVO();
shiftsVO.setEmployeeId(employee.getEmployeeId());
shiftsVO.setEmployeeName(employee.getEmployeeName());
shiftsVO.setEmailId(employee.getEmailId());
shiftsVO.setMobileNo(employee.getMobileNumber());
shiftsVO.setProjectName(project.getProjectName());
if (employee != null) {
if (shift.equalsIgnoreCase(employee.getShift()))
resourcesList.add(shiftsVO);
else if (employee.getShift() == null && Shifts.SHIFT1.getShiftType().equalsIgnoreCase(shift))
resourcesList.add(shiftsVO);
}
}//for
}
}
return resourcesList;
}
}
}//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