Commit c63bc59d authored by Vijay Akula's avatar Vijay Akula

Refactored the code for Project Resources and Billing with their

respective Controller Service and Repository layers
parent cf947c85
package com.nisum.mytime.controller;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.nisum.mytime.exception.handler.MyTimeException;
import com.nisum.mytime.model.Billing;
import com.nisum.mytime.service.IBillingService;
import lombok.extern.slf4j.Slf4j;
@RestController
@Slf4j
public class BillingController {
@Autowired
private IBillingService billingService;
// @RequestMapping(value = "/addEmployeeBilling"
@RequestMapping(value = "/billing", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Billing> addEmployeeBilling(@RequestBody Billing billing,
@RequestParam(value = "loginEmpId") String loginEmpId) throws MyTimeException {
Billing billingList = billingService.addBilling(billing, loginEmpId);
return new ResponseEntity<>(billingList, HttpStatus.OK);
}
// @RequestMapping(value = "/updateEmployeeBilling",
@RequestMapping(value = "/billing", method = RequestMethod.PUT, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Billing> updateEmployeeBilling(@RequestBody Billing billing,
@RequestParam(value = "loginEmpId") String loginEmpId) throws MyTimeException {
Billing billingList = billingService.updateBilling(billing, loginEmpId);
return new ResponseEntity<>(billingList, HttpStatus.OK);
}
// @RequestMapping(value = "/deleteEmployeeBilling"
@RequestMapping(value = "/billing", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Billing> deleteEmployeeBilling(@RequestBody Billing billing) throws MyTimeException {
billingService.deleteBilling(billing);
return new ResponseEntity<>(null, HttpStatus.OK);
}
// @RequestMapping(value = "/getEmployeeBillingDetailsAll"
@RequestMapping(value = "/billing", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<Billing>> getAllBillingsForEmployee(@RequestParam("employeeId") String employeeId)
throws MyTimeException {
List<Billing> billingList = billingService.getBillingsForEmployee(employeeId);
return new ResponseEntity<>(billingList, HttpStatus.OK);
}
// @RequestMapping(value = "/getEmployeeBillingDetails"
@RequestMapping(value = "/billing/project/{projectId}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<Billing>> getBillingsForProject(@PathVariable("projectId") String projectId,
@RequestParam("employeeId") String employeeId) throws MyTimeException {
List<Billing> billingList = billingService.getBillingsForProject(employeeId, projectId);
return new ResponseEntity<>(billingList, HttpStatus.OK);
}
}
package com.nisum.mytime.controller; package com.nisum.mytime.controller;
import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
...@@ -213,5 +214,19 @@ public class EmployeeController { ...@@ -213,5 +214,19 @@ public class EmployeeController {
return new ResponseEntity<ResponseDetails>(getRespDetails, HttpStatus.OK); return new ResponseEntity<ResponseDetails>(getRespDetails, HttpStatus.OK);
} }
@RequestMapping(value = "/employees/active/sortByName", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<Employee>> getActiveEmployeesSortByName() throws MyTimeException {
List<Employee> employeesList = new ArrayList<>();
if (empService.getActiveEmployees() != null) {
employeesList = empService.getActiveEmployees().stream()
.sorted((o1, o2) -> o1.getEmployeeName().compareTo(o2.getEmployeeName()))
.collect(Collectors.toList());
}
return new ResponseEntity<>(employeesList, HttpStatus.OK);
}
} }
\ No newline at end of file
...@@ -12,78 +12,75 @@ import org.springframework.web.bind.annotation.RequestMapping; ...@@ -12,78 +12,75 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import com.nisum.mytime.exception.handler.MyTimeException; import com.nisum.mytime.exception.handler.MyTimeException;
import com.nisum.mytime.model.Account; import com.nisum.mytime.model.Account;
import com.nisum.mytime.model.Employee;
import com.nisum.mytime.model.Project; import com.nisum.mytime.model.Project;
import com.nisum.mytime.repository.AccountRepo; import com.nisum.mytime.repository.AccountRepo;
import com.nisum.mytime.repository.ProjectRepo; import com.nisum.mytime.repository.ProjectRepo;
import com.nisum.mytime.service.IProjectService;
import com.nisum.mytime.service.IEmployeeService; import com.nisum.mytime.service.IEmployeeService;
import com.nisum.mytime.service.IProjectService;
import com.nisum.mytime.utils.MyTimeUtils; import com.nisum.mytime.utils.MyTimeUtils;
import lombok.extern.slf4j.Slf4j;
@RestController @RestController
@RequestMapping("/project") @Slf4j
public class ProjectController { public class ProjectController {
@Autowired @Autowired
private IEmployeeService userService; private IEmployeeService employeeService;
@Autowired @Autowired
private IProjectService projectService; private IProjectService projectService;
@Autowired @Autowired
private AccountRepo accountRepo; private AccountRepo accountRepo;
@Autowired @Autowired
private ProjectRepo projectRepo; private ProjectRepo projectRepo;
@RequestMapping(value = "/employee", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Employee> getEmployeeRole(@RequestParam("emailId") String emailId)
throws MyTimeException {
Employee employeesRole = userService.getEmployeeByEmaillId(emailId);
return new ResponseEntity<>(employeesRole, HttpStatus.OK);
}
@RequestMapping(value = "/addProject", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(value = "/projects", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<?> addProject(@RequestBody Project projectAdded, public ResponseEntity<?> createProject(@RequestBody Project projectReq,
@RequestParam(value = "loginEmpId") String loginEmpId) throws MyTimeException { @RequestParam(value = "loginEmpId") String loginEmpId) throws MyTimeException {
// checking project duplicateName // checking project duplicateName
int projectNameCount=0; int projectNameCount = 0;
if (projectAdded.getAccountId() != null) { if (projectReq.getAccountId() != null) {
List<Project> projects = projectRepo.findByDomainId(projectAdded.getDomainId());
List<Project> projects=projectService.getProjectsUnderDomain(projectReq.getDomainId());
for (Project existproject : projects) { for (Project existproject : projects) {
if (projectAdded.getProjectName().equalsIgnoreCase(existproject.getProjectName())) if (projectReq.getProjectName().equalsIgnoreCase(existproject.getProjectName()))
projectNameCount++; projectNameCount++;
} }
} }
if (projectNameCount > MyTimeUtils.INT_ZERO){ if (projectNameCount > MyTimeUtils.INT_ZERO) {
MyTimeException myTimeException= new MyTimeException("Project name already exist !!! try with new"); MyTimeException myTimeException = new MyTimeException("Project name already exist !!! try with new");
return new ResponseEntity<>(myTimeException, HttpStatus.OK); return new ResponseEntity<>(myTimeException, HttpStatus.OK);
}else{ } else {
String accountName=""; String accountName = "";
String accountId=projectAdded.getAccountId(); String accountId = projectReq.getAccountId();
// String accountName=projectAdded.getAccount(); // String accountName=projectAdded.getAccount();
Account account= accountRepo.findByAccountId(accountId); Account account = accountRepo.findByAccountId(accountId);
if(account!=null) if (account != null)
accountName=account.getAccountName(); accountName = account.getAccountName();
int sequenceNumber= account.getAccountProjectSequence(); int sequenceNumber = account.getAccountProjectSequence();
account.setAccountProjectSequence(sequenceNumber+1); account.setAccountProjectSequence(sequenceNumber + 1);
//account.setAuditFields(loginEmpId, MyTimeUtils.UPDATE); // account.setAuditFields(loginEmpId, MyTimeUtils.UPDATE);
accountRepo.save(account); accountRepo.save(account);
String projectId= accountName+String.format("%04d", sequenceNumber+1); String projectId = accountName + String.format("%04d", sequenceNumber + 1);
projectAdded.setProjectId(projectId); projectReq.setProjectId(projectId);
Project project = projectService.addProject(projectAdded, loginEmpId); Project project = projectService.createProject(projectReq, loginEmpId);
return new ResponseEntity<>(project, HttpStatus.OK); return new ResponseEntity<>(project, HttpStatus.OK);
} }
} }
@RequestMapping(value = "/updateProject", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) // @RequestMapping(value = "/updateProject"
public ResponseEntity<?> updateProject(@RequestBody Project project, @RequestMapping(value = "/projects", method = RequestMethod.PUT, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<?> updateProject(@RequestBody Project project,
@RequestParam(value = "loginEmpId") String loginEmpId) throws MyTimeException { @RequestParam(value = "loginEmpId") String loginEmpId) throws MyTimeException {
// checking project duplicateName // checking project duplicateName
int projectNameCount=0; int projectNameCount = 0;
if (project.getAccountId() != null) { if (project.getAccountId() != null) {
List<Project> projects = projectRepo.findByDomainId(project.getDomainId()); List<Project> projects = projectRepo.findByDomainId(project.getDomainId());
for (Project existproject : projects) { for (Project existproject : projects) {
...@@ -93,41 +90,57 @@ public class ProjectController { ...@@ -93,41 +90,57 @@ public class ProjectController {
} }
} }
} }
if (projectNameCount>0) if (projectNameCount > 0) {
{ MyTimeException myTimeException = new MyTimeException("Project name already exist !!! try with new");
MyTimeException myTimeException= new MyTimeException("Project name already exist !!! try with new");
return new ResponseEntity<>(myTimeException, HttpStatus.OK); return new ResponseEntity<>(myTimeException, HttpStatus.OK);
} }
Project updatedProject = projectService.updateProject(project, loginEmpId); Project updatedProject = projectService.updateProject(project, loginEmpId);
return new ResponseEntity<>(updatedProject, HttpStatus.OK); return new ResponseEntity<>(updatedProject, HttpStatus.OK);
} }
@RequestMapping(value = "/deleteProject", method = RequestMethod.DELETE, produces = MediaType.TEXT_PLAIN_VALUE) // @RequestMapping(value = "/deleteProject"
@RequestMapping(value = "/deleteProject", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<String> deleteProject(@RequestParam("projectId") String projectId) throws MyTimeException { public ResponseEntity<String> deleteProject(@RequestParam("projectId") String projectId) throws MyTimeException {
projectService.deleteProject(projectId); projectService.deleteProject(projectId);
return new ResponseEntity<>("Success", HttpStatus.OK); return new ResponseEntity<>("Success", HttpStatus.OK);
} }
@RequestMapping(value = "/getProjects", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) // @RequestMapping(value = "/getProjects"
public ResponseEntity<List<HashMap<Object, Object>>> getProjects(@RequestParam(value="empId", required = false, defaultValue = MyTimeUtils.ZERO) String empId) throws MyTimeException { @RequestMapping(value = "/projects", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<HashMap<Object, Object>>> getProjects(
@RequestParam(value = "empId", required = false, defaultValue = MyTimeUtils.ZERO) String empId)
throws MyTimeException {
List<HashMap<Object, Object>> projects = null; List<HashMap<Object, Object>> projects = null;
if(!"undefined".equalsIgnoreCase(empId) ) { if (!"undefined".equalsIgnoreCase(empId)) {
boolean isDl = userService.verifyEmployeeRole(empId,MyTimeUtils.DL) ; boolean isDl = employeeService.verifyEmployeeRole(empId, MyTimeUtils.DL);
if( isDl ){ if (isDl) {
projects = projectService.deliveryLeadProjects(empId); projects = projectService.deliveryLeadProjects(empId);
} }
}else { } else {
projects = projectService.getProjects(); projects = projectService.getProjects();
} }
return new ResponseEntity<>(projects, HttpStatus.OK); return new ResponseEntity<>(projects, HttpStatus.OK);
} }
@RequestMapping(value = "/getEmployeeRoleData", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Employee> getEmployeeRoleData(@RequestParam("empId") String empId) @RequestMapping(value = "/projects/{deliveryLeadId}", method = RequestMethod.GET,
throws MyTimeException { produces = MediaType.APPLICATION_JSON_VALUE)
Employee employeesRole = userService.getEmployeeById(empId); public ResponseEntity<List<Project>> getProjectsUnderDeliveryLead(
return new ResponseEntity<>(employeesRole, HttpStatus.OK); @RequestParam("deliveryLeadId") String deliveryLeadId)
throws MyTimeException {
List<Project> projects = projectService.getProjectsUnderDeliveryLead(deliveryLeadId);
return new ResponseEntity<>(projects, HttpStatus.OK);
}
@RequestMapping(value = "/getMyProjectAllocations", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<HashMap<Object, Object>>> getMyProjectAllocations(
@RequestParam("employeeId") String employeeId) throws MyTimeException {
List<HashMap<Object, Object>> empPrjtsInfo = projectService.getProjectsForEmployee(employeeId);
return new ResponseEntity<>(empPrjtsInfo, HttpStatus.OK);
} }
} }
\ No newline at end of file
...@@ -42,26 +42,24 @@ import com.nisum.mytime.model.ReportSeriesRecord; ...@@ -42,26 +42,24 @@ import com.nisum.mytime.model.ReportSeriesRecord;
import com.nisum.mytime.repository.EmployeeVisaRepo; import com.nisum.mytime.repository.EmployeeVisaRepo;
import com.nisum.mytime.repository.BillingRepo; import com.nisum.mytime.repository.BillingRepo;
import com.nisum.mytime.service.IProjectService; import com.nisum.mytime.service.IProjectService;
import com.nisum.mytime.service.IResourceService;
import com.nisum.mytime.service.IEmployeeService; import com.nisum.mytime.service.IEmployeeService;
@RestController @RestController
@RequestMapping("/reports") @RequestMapping("/reports")
public class ReportsController { public class ReportsController {
@Autowired
private IEmployeeService userService;
@Autowired @Autowired
private IProjectService projectService; private MongoTemplate mongoTemplate;
@Autowired @Autowired
private EmployeeVisaRepo employeeVisaRepo; private IResourceService resourceService;
@Autowired @Autowired
private MongoTemplate mongoTemplate; private IEmployeeService employeeService;
@Autowired
private BillingRepo teamMatesBillingRepo;
@RequestMapping(value = "/getEmployeesByFunctionalGroup1", @RequestMapping(value = "/getEmployeesByFunctionalGroup1",
method = RequestMethod.GET, method = RequestMethod.GET,
...@@ -148,7 +146,7 @@ public class ReportsController { ...@@ -148,7 +146,7 @@ public class ReportsController {
statusList.add("Non-Billable"); statusList.add("Non-Billable");
List<String> catagories = new ArrayList(); List<String> catagories = new ArrayList();
List<ReportSeriesRecord> seriesDetails = new ArrayList<ReportSeriesRecord>(); List<ReportSeriesRecord> seriesDetails = new ArrayList<ReportSeriesRecord>();
List<Account> accounts = userService.getAccounts(); List<Account> accounts = employeeService.getAccounts();
ColumnChartData reportData = new ColumnChartData(); ColumnChartData reportData = new ColumnChartData();
for (String status : statusList) { for (String status : statusList) {
catagories = new ArrayList(); catagories = new ArrayList();
...@@ -319,7 +317,7 @@ public class ReportsController { ...@@ -319,7 +317,7 @@ public class ReportsController {
public ResponseEntity<List<Employee>> getEmployeesByFG( public ResponseEntity<List<Employee>> getEmployeesByFG(
@RequestParam("fGroup") String fGroup) throws MyTimeException { @RequestParam("fGroup") String fGroup) throws MyTimeException {
List<Employee> empList = new ArrayList<>(); List<Employee> empList = new ArrayList<>();
empList = userService.getEmployeesByFunctionalGrp(fGroup); empList = employeeService.getEmployeesByFunctionalGrp(fGroup);
return new ResponseEntity<>(empList, HttpStatus.OK); return new ResponseEntity<>(empList, HttpStatus.OK);
} }
...@@ -333,7 +331,7 @@ public class ReportsController { ...@@ -333,7 +331,7 @@ public class ReportsController {
throws MyTimeException { throws MyTimeException {
List<Resource> empList = new ArrayList<>(); List<Resource> empList = new ArrayList<>();
if (account != null && !account.isEmpty()) { if (account != null && !account.isEmpty()) {
empList = projectService.findByAccountAndActiveAndBillableStatus( empList = resourceService.findByAccountAndActiveAndBillableStatus(
account, true, billabilityStatus); account, true, billabilityStatus);
} }
return new ResponseEntity<>(empList, HttpStatus.OK); return new ResponseEntity<>(empList, HttpStatus.OK);
......
package com.nisum.mytime.controller;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.stream.Collectors;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.nisum.mytime.exception.handler.MyTimeException;
import com.nisum.mytime.model.Employee;
import com.nisum.mytime.model.EmployeeDashboardVO;
import com.nisum.mytime.model.EmployeeVisa;
import com.nisum.mytime.model.Resource;
import com.nisum.mytime.repository.EmployeeVisaRepo;
import com.nisum.mytime.service.IEmployeeService;
import com.nisum.mytime.service.IProjectService;
import com.nisum.mytime.service.IResourceService;
import com.nisum.mytime.utils.MyTimeUtils;
@RestController
@RequestMapping("/projectTeam")
public class ResourceController {
@Autowired
private IEmployeeService employeeService;
@Autowired
private IProjectService projectService;
@Autowired
private EmployeeVisaRepo employeeVisaRepo;
@Autowired
private IResourceService resourceService;
// @RequestMapping(value = "/addEmployeeToTeam"
@RequestMapping(value = "/resources", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Resource> addResourceToTeam(@RequestBody Resource resource,
@RequestParam(value = "loginEmpId", required = false) String loginEmpId) throws MyTimeException {
resource.setActive(true);
resource.setAuditFields(loginEmpId, MyTimeUtils.CREATE);
Resource resourcePersisted = resourceService.addResource(resource, loginEmpId);
return new ResponseEntity<>(resourcePersisted, HttpStatus.OK);
}
// @RequestMapping(value = "/updateTeammate"
@RequestMapping(value = "/resources", method = RequestMethod.PUT, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<String> updateResource(@RequestBody Resource resource,
@RequestParam(value = "loginEmpId") String loginEmpId) throws MyTimeException {
resource.setAuditFields(loginEmpId, MyTimeUtils.UPDATE);
String response = resourceService.updateResource(resource, loginEmpId);
return new ResponseEntity<>(response, HttpStatus.OK);
}
// @RequestMapping(value = "/deleteTeammate"
@RequestMapping(value = "/resources", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<String> deleteResource(@RequestBody Resource resource,
@RequestParam(value = "loginEmpId") String loginEmpId) throws MyTimeException {
resourceService.deleteResource(resource.getEmployeeId(), resource.getProjectId(), resource.getId(), loginEmpId);
return new ResponseEntity<>("Success", HttpStatus.OK);
}
// @RequestMapping(value = "/getEmployeeProjectInfo"
@RequestMapping(value = "/resources", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<Resource>> getResourcesSortByStartDate(@RequestParam("empId") String empId)
throws MyTimeException {
List<Resource> projectInfo = resourceService.getResourcesSortByStartDate(empId);
return new ResponseEntity<>(projectInfo, HttpStatus.OK);
}
//@RequestMapping(value = "/getMyTeamDetails"
@RequestMapping(value = "/resources/active", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<Resource>> getActiveResources(@RequestParam("employeeId") String employeeId)
throws MyTimeException {
List<Resource> employeesRoles = resourceService.getActiveResources(employeeId);
return new ResponseEntity<>(employeesRoles, HttpStatus.OK);
}
// @RequestMapping(value = "/getShiftDetails"
@RequestMapping(value = "/resources/{shift}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<Resource>> getResourcesForShift(@PathVariable("shift") String shift)
throws MyTimeException {
List<Resource> resourcesList = resourceService.getResourcesForShift(shift);
return new ResponseEntity<>(resourcesList, HttpStatus.OK);
}
// @RequestMapping(value = "/getProjectAllocations"
@RequestMapping(value = "/resources/projects/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<Resource>> getResourcesAllocatedForAllProjects() throws MyTimeException {
List<Resource> resourcesList = resourceService.getResourcesForActiveProjects();
return new ResponseEntity<>(resourcesList, HttpStatus.OK);
}
// @RequestMapping(value = "/getProjectDetails"
@RequestMapping(value = "/resources/project/{projectId}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<Resource>> getResourcesForProject(@PathVariable("projectId") String projectId,
@RequestParam(value = "status", required = false, defaultValue = MyTimeUtils.ACTIVE) String status)
throws MyTimeException {
List<Resource> resourcesList = resourceService.getResourcesForProject(projectId, status);
return new ResponseEntity<>(resourcesList, HttpStatus.OK);
}
//@RequestMapping(value = "/getTeamDetails"
@RequestMapping(value = "/resources/deliverylead/{deliveryLeadId}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<Resource>> getTeamDetails(@PathVariable("deliveryLeadId") String deliveryLeadId)
throws MyTimeException {
List<Resource> resourcesList = resourceService.getResourcesUnderDeliveryLead(deliveryLeadId);
return new ResponseEntity<>(resourcesList, HttpStatus.OK);
}
@RequestMapping(value = "/getUnAssignedEmployees", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<Employee>> getUnAssignedEmployees() throws MyTimeException {
List<Employee> employeesList = projectService.getUnAssignedEmployees();
return new ResponseEntity<>(employeesList, HttpStatus.OK);
}
@RequestMapping(value = "/getEmployeesDashBoard", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<EmployeeDashboardVO>> getEmployeesDashBoard() throws MyTimeException {
List<EmployeeDashboardVO> employeeDashBoardList = projectService.getEmployeesDashBoard();
return new ResponseEntity<>(employeeDashBoardList, HttpStatus.OK);
}
@RequestMapping(value = "/getEmployeesHavingVisa", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<Employee>> getEmployeesHavingVisa(@RequestParam("visa") String passport)
throws MyTimeException {
List<Employee> employees = new ArrayList<>();
if (passport != null && !"passport".equalsIgnoreCase(passport)) {
List<EmployeeVisa> employeeVisas = employeeVisaRepo.findByVisaName(passport);
List<String> employeeIds = null;
if (employeeVisas != null) {
employeeIds = employeeVisas.stream().map(EmployeeVisa::getEmployeeId).collect(Collectors.toList());
}
if (employeeIds != null && !employeeIds.isEmpty()) {
List<Employee> emps = employeeService.getActiveEmployees();
for (Employee emp : emps) {
if (employeeIds.contains(emp.getEmployeeId())) {
employees.add(emp);
}
}
}
return new ResponseEntity<>(employees, HttpStatus.OK);
} else {
// List<EmployeeRoles> employees = new ArrayList<>();
if (employeeService.getActiveEmployees() != null) {
employees = employeeService.getActiveEmployees().stream()
.sorted((o1, o2) -> o1.getEmployeeName().compareTo(o2.getEmployeeName()))
.collect(Collectors.toList());
}
return new ResponseEntity<>(employees, HttpStatus.OK);
}
}
@RequestMapping(value = "/addEmployeeToTeamWithCheck", method = RequestMethod.POST, produces = MediaType.TEXT_PLAIN_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<String> addEmployeeToTeamWithCheck(@RequestBody Resource resource,
@RequestParam(value = "loginEmpId") String loginEmpId) throws MyTimeException {
String response = projectService.addProjectTeamMateWithCheck(resource, loginEmpId);
return new ResponseEntity<>(response, HttpStatus.OK);
}
}
// @RequestMapping(value = "/employee", method = RequestMethod.GET,
// public ResponseEntity<Employee> getEmployee(
// @RequestMapping(value = "/updateEmployeeRole", method =
// public ResponseEntity<Employee> updateEmployeeRole(@RequestBody Employee
// @RequestMapping(value = "/deleteEmployee"
// public ResponseEntity<String> deleteEmployee
// @RequestMapping(value = "/getEmployeeRoleData",
// public ResponseEntity<Employee> getEmployeeRoleData(
// @RequestMapping(value = "/addProject"
// public ResponseEntity<Project> addProject(
// @RequestMapping(value = "/getEmployeesToTeam"
// public ResponseEntity<List<Employee>> getActiveEmployeesSortByName() throws
// MyTimeException {
...@@ -23,27 +23,27 @@ import lombok.ToString; ...@@ -23,27 +23,27 @@ import lombok.ToString;
@Document(collection = "billing") @Document(collection = "billing")
public class Billing extends AuditFields implements Serializable { public class Billing extends AuditFields implements Serializable {
public Date getBillingEndDate() { public Date getBillingEndDate() {
return billingEndDate; return billingEndDate;
} }
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@Id @Id
private ObjectId id; private ObjectId id;
private String employeeId; private String employeeId;
private String employeeName; private String employeeName;
private String account; private String account;
private String projectId; private String projectId;
private String projectName; private String projectName;
private String billableStatus; private String billableStatus;
@DateTimeFormat(iso = ISO.DATE) @DateTimeFormat(iso = ISO.DATE)
private Date billingStartDate; private Date billingStartDate;
@DateTimeFormat(iso = ISO.DATE) @DateTimeFormat(iso = ISO.DATE)
private Date billingEndDate; private Date billingEndDate;
private String comments; private String comments;
private boolean active; private boolean active;
//@DateTimeFormat(pattern = "dd-MM-yyyy") // @DateTimeFormat(pattern = "dd-MM-yyyy")
// private Date createDate; // private Date createDate;
} }
...@@ -15,7 +15,7 @@ import lombok.ToString; ...@@ -15,7 +15,7 @@ import lombok.ToString;
@NoArgsConstructor @NoArgsConstructor
@ToString @ToString
@Document(collection = "employeeShifts") @Document(collection = "employeeShifts")
public class EmpShiftDetails extends AuditFields { public class EmployeeShift extends AuditFields {
@Id @Id
private String id; private String id;
......
...@@ -12,9 +12,9 @@ public interface BillingRepo extends MongoRepository<Billing, String> { ...@@ -12,9 +12,9 @@ public interface BillingRepo extends MongoRepository<Billing, String> {
List<Billing> findByProjectId(String projectId); List<Billing> findByProjectId(String projectId);
List<Billing> findByEmployeeId(String employeeId); List<Billing> findByEmployeeId(String employeeId);
Billing findById(ObjectId id); Billing findById(ObjectId id);
List<Billing> findByEmployeeIdAndProjectId(String employeeId, String projectId); List<Billing> findByEmployeeIdAndProjectId(String employeeId, String projectId);
} }
...@@ -2,8 +2,8 @@ package com.nisum.mytime.repository; ...@@ -2,8 +2,8 @@ package com.nisum.mytime.repository;
import org.springframework.data.mongodb.repository.MongoRepository; import org.springframework.data.mongodb.repository.MongoRepository;
import com.nisum.mytime.model.EmpShiftDetails; import com.nisum.mytime.model.EmployeeShift;
public interface EmpShiftDetailsRepo extends MongoRepository<EmpShiftDetails, String> { public interface EmployeeShiftRepo extends MongoRepository<EmployeeShift, String> {
} }
\ No newline at end of file
...@@ -10,8 +10,18 @@ import com.nisum.mytime.model.Employee; ...@@ -10,8 +10,18 @@ import com.nisum.mytime.model.Employee;
@Service @Service
public interface IBillingService { public interface IBillingService {
public Billing addBillingtoResource(Billing billing, Employee employee, String loginEmpId); Billing addBilling(Billing billingDetails, String loginEmpId);
public List<Billing> getEmployeeActiveBillingDetails(String empId, String projectId); Billing updateBilling(Billing billingDetails, String loginEmpId);
void deleteBilling(Billing teamMate);
Billing addBillingtoResource(Billing billing, Employee employee, String loginEmpId);
List<Billing> getBillingsForEmployee(String empId);
List<Billing> getActiveBillings(String empId, String projectId);
List<Billing> getBillingsForProject(String empId, String projectId);
} }
...@@ -44,5 +44,9 @@ public interface IEmployeeService { ...@@ -44,5 +44,9 @@ public interface IEmployeeService {
boolean verifyEmployeeRole(String empId, String roleName); boolean verifyEmployeeRole(String empId, String roleName);
List<Employee> getEmployeesFromList(Set<String> empIdsSet); List<Employee> getEmployeesFromList(Set<String> empIdsSet);
List<HashMap<String, String>> getDeliveryManagerMap(List deliveryManagerIdsList);
public List<Employee> getAllEmployees();
} }
...@@ -7,6 +7,8 @@ import com.nisum.mytime.model.Resource; ...@@ -7,6 +7,8 @@ import com.nisum.mytime.model.Resource;
@Service @Service
public interface IEmployeeShiftService { public interface IEmployeeShiftService {
void updateShiftDetails(Resource existingTeammate, String loginEmpId); public void addEmployeeShift(Resource resource, String loginEmpId);
void updateEmployeeShift(Resource existingTeammate, String loginEmpId);
} }
...@@ -4,96 +4,46 @@ import java.util.HashMap; ...@@ -4,96 +4,46 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import org.bson.types.ObjectId;
import com.nisum.mytime.exception.handler.MyTimeException; import com.nisum.mytime.exception.handler.MyTimeException;
import com.nisum.mytime.model.Billing;
import com.nisum.mytime.model.EmpLoginData; import com.nisum.mytime.model.EmpLoginData;
import com.nisum.mytime.model.EmployeeDashboardVO;
import com.nisum.mytime.model.Employee; import com.nisum.mytime.model.Employee;
import com.nisum.mytime.model.EmployeeDashboardVO;
import com.nisum.mytime.model.Project; import com.nisum.mytime.model.Project;
import com.nisum.mytime.model.Resource; import com.nisum.mytime.model.Resource;
public interface IProjectService { public interface IProjectService {
Project createProject(Project project, String loginEmpId) throws MyTimeException;
public Resource addNewBeanchAllocation(Employee employee,String loginEmpId);
List<EmpLoginData> employeeLoginsBasedOnDate(long id, String fromDate,
String toDate) throws MyTimeException;
List<HashMap<Object, Object>> getProjects() throws MyTimeException;
Project addProject(Project project, String loginEmpId) throws MyTimeException;
String generatePdfReport(long id, String fromDate, String toDate)
throws MyTimeException;
Employee getEmployeesRole(String emailId);
void deleteProject(String projectId);
Project updateProject(Project project, String loginEmpId)throws MyTimeException;
Employee getEmployeesRoleData(String empId);
List<Resource> getTeamDetails(String empId);
//MT-72
List<Resource> getProjectInfo(String empId);
public Resource addProjectTeamMate(Resource projectTeamMate, String loginEmpId)
throws MyTimeException;
String updateTeammate(Resource projectTeamMate, String loginEmpId) throws MyTimeException;
void deleteTeammate(String empId, String projectId, ObjectId id, String loginEmpId);
List<Project> getProjects(String managerId) throws MyTimeException;
List<Resource> getMyTeamDetails(String empId);
List<Employee> getUnAssignedEmployees();
List<Resource> getShiftDetails(String shift); Project updateProject(Project project, String loginEmpId) throws MyTimeException;
List<Resource> getAllProjectDetails(); void deleteProject(String projectId);
List<Resource> getProjectDetails(String projectId,String status); List<Project> getProjectsUnderDomain(String domainId);
public List<Resource> getMyProjectAllocations(String empId); List<HashMap<Object, Object>> getProjects() throws MyTimeException;
List<Billing> getEmployeeBillingDetails(String empId, List<Project> getProjectsUnderDeliveryLead(String managerId) throws MyTimeException;
String projectId);
Billing addEmployeeBillingDetails(Billing billingDetails, String loginEmpId); public Resource addNewBeanchAllocation(Employee employee, String loginEmpId);
Billing updateEmployeeBilling(Billing billingDetails, String loginEmpId); List<EmpLoginData> employeeLoginsBasedOnDate(long id, String fromDate, String toDate) throws MyTimeException;
void deleteEmployeeBilling(Billing teamMate); String generatePdfReport(long id, String fromDate, String toDate) throws MyTimeException;
public List<EmployeeDashboardVO> getEmployeesDashBoard(); List<Resource> getResourcesUnderProject(String empId);
List<Billing> getEmployeeActiveBillingDetails(String empId, List<Employee> getUnAssignedEmployees();
String projectId);
List<Billing> getEmployeeActiveNisumBench(String empId); public List<EmployeeDashboardVO> getEmployeesDashBoard();
List<Billing> getEmployeeBillingDetailsAll(String empId); public String addProjectTeamMateWithCheck(Resource projectTeamMate, String loginEmpId) throws MyTimeException;
public void updateShiftDetails(Resource existingTeammate, String loginEmpId); public List<HashMap<Object, Object>> getProjectsForEmployee(String empId);
public void addShiftDetails(Resource projectTeamMate, String loginEmpId); public Set<String> accountsAssignedToDl(String empId);
List<Resource> findByAccountAndActiveAndBillableStatus( public List<HashMap<Object, Object>> deliveryLeadProjects(String empId) throws MyTimeException;
String account, boolean status, String billableStatus);
public String addProjectTeamMateWithCheck(Resource projectTeamMate, String loginEmpId)
throws MyTimeException;
public List<HashMap<Object, Object>> projectsInfoByEmpId(String empId); public List<Project> getAllProjects();
public Set<String> accountsAssignedToDl(String empId);
public List<HashMap<Object, Object>> deliveryLeadProjects(String empId) throws MyTimeException;
} }
...@@ -2,20 +2,45 @@ package com.nisum.mytime.service; ...@@ -2,20 +2,45 @@ package com.nisum.mytime.service;
import java.util.List; import java.util.List;
import org.bson.types.ObjectId;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.nisum.mytime.model.Billing;
import com.nisum.mytime.model.Employee; import com.nisum.mytime.model.Employee;
import com.nisum.mytime.model.Resource; import com.nisum.mytime.model.Resource;
import com.nisum.mytime.exception.handler.MyTimeException;
@Service @Service
public interface IResourceService { public interface IResourceService {
public Resource save(Resource resource); Resource addResource(Resource projectTeamMate, String loginEmpId) throws MyTimeException;
String updateResource(Resource projectTeamMate, String loginEmpId) throws MyTimeException;
void deleteResource(String empId, String projectId, ObjectId id, String loginEmpId);
Resource save(Resource resource);
void addResources(Employee employee, String loginEmpId); void addResources(Employee employee, String loginEmpId);
void inactivateResource(Employee employeeReq, Employee employeeUpdated, String loginEmpId); void inactivateResource(Employee employeeReq, Employee employeeUpdated, String loginEmpId);
public List<Resource> getResources(String empId); 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);
} }
...@@ -3,6 +3,7 @@ package com.nisum.mytime.service.impl; ...@@ -3,6 +3,7 @@ package com.nisum.mytime.service.impl;
import java.util.Comparator; import java.util.Comparator;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate; import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria; import org.springframework.data.mongodb.core.query.Criteria;
...@@ -16,7 +17,6 @@ import com.nisum.mytime.utils.MyTimeUtils; ...@@ -16,7 +17,6 @@ import com.nisum.mytime.utils.MyTimeUtils;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@Service @Service
@Slf4j @Slf4j
public class BillingService implements IBillingService { public class BillingService implements IBillingService {
...@@ -28,21 +28,62 @@ public class BillingService implements IBillingService { ...@@ -28,21 +28,62 @@ public class BillingService implements IBillingService {
private MongoTemplate mongoTemplate; private MongoTemplate mongoTemplate;
@Override @Override
public List<Billing> getEmployeeActiveBillingDetails(String empId, String projectId) { public Billing addBilling(Billing billing, String loginEmpId) {
Query query4 = new Query(); billing.setAuditFields(loginEmpId, MyTimeUtils.CREATE);
query4.addCriteria(Criteria.where("active").is(new Boolean(true))); return billingRepo.save(billing);
query4.addCriteria(Criteria.where("employeeId").is(empId)); }
query4.addCriteria(Criteria.where("projectId").is(projectId));
List<Billing> billings = mongoTemplate.find(query4, Billing.class); @Override
List<Billing> billingsSorted = billings; public Billing updateBilling(Billing billing, String loginEmpId) {
try { billing.setAuditFields(loginEmpId, MyTimeUtils.UPDATE);
billingsSorted = (billings == null || billings.size() == 0) ? billings return billingRepo.save(billing);
: billings.stream().sorted(Comparator.comparing(Billing::getBillingStartDate).reversed()) }
.collect(Collectors.toList());
} catch (Exception e) { @Override
e.printStackTrace(); public void deleteBilling(Billing billing) {
billingRepo.delete(billing);
}
@Override
public List<Billing> getBillingsForProject(String empId, String projectId) {
List<Billing> billingsList = billingRepo.findByEmployeeIdAndProjectId(empId, projectId);
if (billingsList == null || billingsList.size() == 0) {
return billingsList;
} else {
return billingsList.stream().sorted(Comparator.comparing(Billing::getCreatedOn).reversed())
.collect(Collectors.toList());
}
}
@Override
public List<Billing> getBillingsForEmployee(String empId) {
List<Billing> billingsList = billingRepo.findByEmployeeId(empId);
if (billingsList == null || billingsList.size() == 0) {
return billingsList;
} else {
return billingsList.stream().sorted(Comparator.comparing(Billing::getCreatedOn).reversed())
.collect(Collectors.toList());
}
}
@Override
public List<Billing> getActiveBillings(String empId, String projectId) {
Query query = new Query();
query.addCriteria(Criteria.where("active").is(new Boolean(true)));
query.addCriteria(Criteria.where("employeeId").is(empId));
query.addCriteria(Criteria.where("projectId").is(projectId));
List<Billing> billingList = mongoTemplate.find(query, Billing.class);
if (billingList == null || billingList.size() == 0) {
return billingList;
} else {
return billingList.stream().sorted(Comparator.comparing(Billing::getBillingStartDate).reversed())
.collect(Collectors.toList());
} }
return billingsSorted;
} }
public Billing addBillingtoResource(Billing billing, Employee employee, String loginEmpId) { public Billing addBillingtoResource(Billing billing, Employee employee, String loginEmpId) {
...@@ -51,7 +92,6 @@ public class BillingService implements IBillingService { ...@@ -51,7 +92,6 @@ public class BillingService implements IBillingService {
billing.setActive(false); billing.setActive(false);
billing.setAuditFields(loginEmpId, MyTimeUtils.UPDATE); billing.setAuditFields(loginEmpId, MyTimeUtils.UPDATE);
return billingRepo.save(billing); return billingRepo.save(billing);
} }
} }
...@@ -169,7 +169,7 @@ public class EmployeeService implements IEmployeeService { ...@@ -169,7 +169,7 @@ public class EmployeeService implements IEmployeeService {
Employee employeePersisted = employeeRepo.save(existingEmployee); Employee employeePersisted = employeeRepo.save(existingEmployee);
if (mobileNumberChanged) { if (mobileNumberChanged) {
try { try {
List<Resource> resourcesList = resourceService.getResources(employeeReq.getEmployeeId()); List<Resource> resourcesList = resourceService.getResourcesForEmployee(employeeReq.getEmployeeId());
if (resourcesList != null && !resourcesList.isEmpty()) { if (resourcesList != null && !resourcesList.isEmpty()) {
for (Resource resource : resourcesList) { for (Resource resource : resourcesList) {
...@@ -267,23 +267,26 @@ public class EmployeeService implements IEmployeeService { ...@@ -267,23 +267,26 @@ public class EmployeeService implements IEmployeeService {
@Override @Override
public List<HashMap<String, String>> getDeliveryLeads(String domainId) { public List<HashMap<String, String>> getDeliveryLeads(String domainId) {
Domain domain = domainService.getDomainById(domainId); Domain domain = domainService.getDomainById(domainId);
return getEmployeeData(domain.getDeliveryManagers()); return getDeliveryManagerMap(domain.getDeliveryManagers());
} }
public List<HashMap<String, String>> getEmployeeData(List dmIdList) {
List<HashMap<String, String>> EmployeeList = new ArrayList<>();
Query query = new Query(Criteria.where("employeeId").in(dmIdList));
List<Employee> employeeList = mongoTemplate.find(query, Employee.class);
for (Employee employee : employeeList) {
HashMap<String, String> managerMap = new HashMap<>();
managerMap.put("employeeId", employee.getEmployeeId());
managerMap.put("employeeName", employee.getEmployeeName());
EmployeeList.add(managerMap);
}
return EmployeeList;
}
@Override
public List<HashMap<String, String>> getDeliveryManagerMap(List deliveryManagerIdsList) {
List<HashMap<String, String>> employeeList = new ArrayList<>();
Query query = new Query(Criteria.where("employeeId").in(deliveryManagerIdsList));
List<Employee> employeePersistedList = mongoTemplate.find(query,Employee.class);
for (Employee employee : employeePersistedList) {
HashMap<String, String> managerMap = new HashMap<>();
managerMap.put("employeeId", employee.getEmployeeId());
managerMap.put("employeeName", employee.getEmployeeName());
employeeList.add(managerMap);
}
return employeeList;
}
@Override @Override
public List<Employee> getEmployeesByFunctionalGrp(String functionalGrp) { public List<Employee> getEmployeesByFunctionalGrp(String functionalGrp) {
return employeeRepo.findByEmpStatusAndFunctionalGroup("Active", functionalGrp); return employeeRepo.findByEmpStatusAndFunctionalGroup("Active", functionalGrp);
...@@ -311,4 +314,11 @@ public class EmployeeService implements IEmployeeService { ...@@ -311,4 +314,11 @@ public class EmployeeService implements IEmployeeService {
} }
@Override
public List<Employee> getAllEmployees() {
return employeeRepo.findAll();
}
} }
package com.nisum.mytime.service.impl; package com.nisum.mytime.service.impl;
import java.util.Calendar;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate; import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria; import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query; import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.nisum.mytime.model.EmployeeShift;
import com.nisum.mytime.model.EmpShiftDetails;
import com.nisum.mytime.model.Resource; import com.nisum.mytime.model.Resource;
import com.nisum.mytime.repository.EmployeeShiftRepo;
import com.nisum.mytime.service.IEmployeeShiftService; import com.nisum.mytime.service.IEmployeeShiftService;
import com.nisum.mytime.utils.MyTimeUtils; import com.nisum.mytime.utils.MyTimeUtils;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@Service @Service
@Slf4j @Slf4j
public class EmployeeShiftService implements IEmployeeShiftService{ public class EmployeeShiftService implements IEmployeeShiftService {
@Autowired
private EmployeeShiftRepo empShiftsRepo;
@Autowired @Autowired
private MongoTemplate mongoTemplate; private MongoTemplate mongoTemplate;
public void updateShiftDetails(Resource existingTeammate, String loginEmpId) { @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, MyTimeUtils.CREATE);
empShiftsRepo.save(empShift);
log.info("The Employee Shift has been Persisted ::" + empShift);
}
public void updateEmployeeShift(Resource resource, String loginEmpId) {
Query getQuery = new Query(); Query getQuery = new Query();
getQuery.addCriteria(new Criteria().andOperator(Criteria.where("active").is(true), getQuery.addCriteria(new Criteria().andOperator(Criteria.where("active").is(true),
Criteria.where("employeeId").is(existingTeammate.getEmployeeId()))); Criteria.where("employeeId").is(resource.getEmployeeId())));
Calendar cal = Calendar.getInstance(); EmployeeShift existingEmpShift = mongoTemplate.findOne(getQuery, EmployeeShift.class);
cal.add(Calendar.DATE, -1); if (existingEmpShift != null) {
EmpShiftDetails existingShift = mongoTemplate.findOne(getQuery, EmpShiftDetails.class); existingEmpShift.setActive(false);
if (existingShift != null) { existingEmpShift.setAuditFields(loginEmpId, MyTimeUtils.UPDATE);
existingShift.setActive(false); mongoTemplate.save(existingEmpShift);
// existingShift.setUpdatedDate(new Date());// Commented as added log.info("The shift has been updated::" + existingEmpShift);
// common audit fields
existingShift.setAuditFields(loginEmpId, MyTimeUtils.UPDATE);
mongoTemplate.save(existingShift);
} }
} }
} }
...@@ -25,4 +25,8 @@ public class ShiftService implements IShiftService { ...@@ -25,4 +25,8 @@ public class ShiftService implements IShiftService {
log.info("The shift list details::" + shiftsList); log.info("The shift list details::" + shiftsList);
return shiftsList; return shiftsList;
} }
} }
server.port=8080 server.port=8080
server.context-path=/myTeam/ server.context-path=/myTeam/
#Mongo DB configuration
spring.data.mongodb.host=10.3.45.11
spring.data.mongodb.port=27017
spring.data.mongodb.database=mytimedb
spring.data.mongodb.username=mytime
spring.data.mongodb.password=nisum@123
#Local configuration #Local configuration
#spring.data.mongodb.host=localhost spring.data.mongodb.host=localhost
#spring.data.mongodb.port=27017 spring.data.mongodb.port=27017
#spring.data.mongodb.database=mytime spring.data.mongodb.database=mytime
quartz.enabled=true quartz.enabled=true
cron.expression=0 45 10/3 1/1 * ? * cron.expression=0 45 10/3 1/1 * ? *
...@@ -38,9 +31,7 @@ spring.mail.properties.mail.smtp.starttls.required=true ...@@ -38,9 +31,7 @@ spring.mail.properties.mail.smtp.starttls.required=true
spring.mvc.favicon.enabled = false spring.mvc.favicon.enabled = false
#MS SQL configuration #MS SQL configuration
myTime.data.mssqldb.driver=com.microsoft.sqlserver.jdbc.SQLServerDriver myTime.data.mssqldb.driver=
#myTime.data.mssqldb.url=jdbc:sqlserver://10.3.45.105:1433;databaseName=smartiSCC myTime.data.mssqldb.url=
myTime.data.mssqldb.url=jdbc:sqlserver://10.3.45.218:1433;databaseName=smartiSCC myTime.data.mssqldb.username=
myTime.data.mssqldb.username=sa myTime.data.mssqldb.password=
#myTime.data.mssqldb.password=nisum@123 \ No newline at end of file
myTime.data.mssqldb.password=admin@123
\ No newline at end of file
...@@ -53,7 +53,7 @@ ...@@ -53,7 +53,7 @@
<script src="js/app.js"></script> <script src="js/app.js"></script>
<script src="js/date-text-filter.js"></script> <script src="js/date-text-filter.js"></script>
<script src="js/ui-grid-edit-datepicker.js"></script> <script src="js/ui-grid-edit-datepicker.js"></script>
<script src="controllers/assignAccountsController.js"></script> <script src="controllers/AccountsController.js"></script>
<script src="controllers/LoginController.js"></script> <script src="controllers/LoginController.js"></script>
<script src="controllers/HeaderController.js"></script> <script src="controllers/HeaderController.js"></script>
<script src="controllers/LeftMenuController.js"></script> <script src="controllers/LeftMenuController.js"></script>
...@@ -63,7 +63,7 @@ ...@@ -63,7 +63,7 @@
<script src="controllers/ReportsController.js"></script> <script src="controllers/ReportsController.js"></script>
<script src="controllers/AssignRolesController.js"></script> <script src="controllers/AssignRolesController.js"></script>
<script src="controllers/ProjectController.js"></script> <script src="controllers/ProjectController.js"></script>
<script src="controllers/ProjectTeamController.js"></script> <script src="controllers/ResourceController.js"></script>
<script src="controllers/ProjectMyTeamController.js"></script> <script src="controllers/ProjectMyTeamController.js"></script>
<script src="controllers/AttendanceReportController.js"></script> <script src="controllers/AttendanceReportController.js"></script>
<script src="controllers/ShiftDetailsController.js"></script> <script src="controllers/ShiftDetailsController.js"></script>
......
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