Commit 35fe87d0 authored by bsatyanarayana-nisum-com's avatar bsatyanarayana-nisum-com Committed by tdutta-nisum-com

MT-152 :SNS :: Add_createdBy_modifiedBy_fileds_to_EmployeeDetails (#145)

parent 3cf1654e
...@@ -75,7 +75,7 @@ public class ProjectController { ...@@ -75,7 +75,7 @@ public class ProjectController {
public ResponseEntity<List<HashMap<Object, Object>>> getProjects(@RequestParam(value="empId", required = false, defaultValue = MyTimeUtils.ZERO) String empId) throws MyTimeException { 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(!MyTimeUtils.ZERO.equals(empId)) { if(!"undefined".equalsIgnoreCase(empId) ) {
boolean isDl = userService.verifyRole(empId,MyTimeUtils.DL) ; boolean isDl = userService.verifyRole(empId,MyTimeUtils.DL) ;
if( isDl ){ if( isDl ){
projects = projectService.deliveryLeadProjects(empId); projects = projectService.deliveryLeadProjects(empId);
......
...@@ -65,9 +65,9 @@ public class UserController { ...@@ -65,9 +65,9 @@ public class UserController {
produces = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE,
consumes = MediaType.APPLICATION_JSON_VALUE) consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<EmployeeRoles> assigingEmployeeRole( public ResponseEntity<EmployeeRoles> assigingEmployeeRole(
@RequestBody EmployeeRoles employeeRoles) throws MyTimeException { @RequestBody EmployeeRoles employeeRoles, @RequestParam(value="empId") String loginEmpId) throws MyTimeException {
EmployeeRoles employeeRole = userService EmployeeRoles employeeRole = userService
.assigingEmployeeRole(employeeRoles); .assigingEmployeeRole(employeeRoles,loginEmpId);
return new ResponseEntity<>(employeeRole, HttpStatus.OK); return new ResponseEntity<>(employeeRole, HttpStatus.OK);
} }
...@@ -75,9 +75,10 @@ public class UserController { ...@@ -75,9 +75,10 @@ public class UserController {
produces = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE,
consumes = MediaType.APPLICATION_JSON_VALUE) consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<EmployeeRoles> updateEmployeeRole( public ResponseEntity<EmployeeRoles> updateEmployeeRole(
@RequestBody EmployeeRoles employeeRoles) throws MyTimeException { @RequestBody EmployeeRoles employeeRoles,
@RequestParam(value="empId") String loginEmpId) throws MyTimeException {
EmployeeRoles employeeRole = userService EmployeeRoles employeeRole = userService
.updateEmployeeRole(employeeRoles); .updateEmployeeRole(employeeRoles,loginEmpId);
return new ResponseEntity<>(employeeRole, HttpStatus.OK); return new ResponseEntity<>(employeeRole, HttpStatus.OK);
} }
......
...@@ -18,6 +18,7 @@ import com.nisum.mytime.model.EmployeeVisa; ...@@ -18,6 +18,7 @@ import com.nisum.mytime.model.EmployeeVisa;
import com.nisum.mytime.model.TravelRequest; import com.nisum.mytime.model.TravelRequest;
import com.nisum.mytime.model.Visa; import com.nisum.mytime.model.Visa;
import com.nisum.mytime.service.VisaService; import com.nisum.mytime.service.VisaService;
import com.nisum.mytime.utils.MyTimeUtils;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
...@@ -86,10 +87,10 @@ public class VisaController { ...@@ -86,10 +87,10 @@ public class VisaController {
} }
@RequestMapping(value = "/fileUpload", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.MULTIPART_FORM_DATA_VALUE) @RequestMapping(value = "/fileUpload", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
public ResponseEntity<String> exportDataFromFile(@RequestParam(value = "file") MultipartFile file) public ResponseEntity<String> exportDataFromFile(@RequestParam(value = "file") MultipartFile file, @RequestParam(value="empId") String loginEmpId)
throws MyTimeException { throws MyTimeException {
log.info("Uploaded file: {} with size: {}", file.getOriginalFilename(), file.getSize()); log.info("Uploaded file: {} with size: {}", file.getOriginalFilename(), file.getSize());
String result = visaService.exportDataFromExcelFile(file); String result = visaService.exportDataFromExcelFile(file,loginEmpId);
return new ResponseEntity<>(result, HttpStatus.OK); return new ResponseEntity<>(result, HttpStatus.OK);
} }
......
...@@ -104,5 +104,9 @@ public class EmployeeRoles implements Serializable { ...@@ -104,5 +104,9 @@ public class EmployeeRoles implements Serializable {
@ExcelCellName("Exit Date") @ExcelCellName("Exit Date")
private Date endDate; private Date endDate;
private String createdBy;
private String modifiedBy;
} }
...@@ -26,7 +26,7 @@ public interface UserService { ...@@ -26,7 +26,7 @@ public interface UserService {
List<EmployeeRoles> getEmployeeRoles() throws MyTimeException; List<EmployeeRoles> getEmployeeRoles() throws MyTimeException;
EmployeeRoles assigingEmployeeRole(EmployeeRoles employeeRoles) EmployeeRoles assigingEmployeeRole(EmployeeRoles employeeRoles, String empId)
throws MyTimeException; throws MyTimeException;
String generatePdfReport(long id, String fromDate, String toDate) String generatePdfReport(long id, String fromDate, String toDate)
...@@ -36,7 +36,7 @@ public interface UserService { ...@@ -36,7 +36,7 @@ public interface UserService {
void deleteEmployee(String empId); void deleteEmployee(String empId);
EmployeeRoles updateEmployeeRole(EmployeeRoles employeeRoles); EmployeeRoles updateEmployeeRole(EmployeeRoles employeeRoles,String empId);
void updateEmployeeLocationDetails(EmployeeRoles employeeRoles, void updateEmployeeLocationDetails(EmployeeRoles employeeRoles,
boolean delete); boolean delete);
......
...@@ -133,9 +133,13 @@ public class UserServiceImpl implements UserService { ...@@ -133,9 +133,13 @@ public class UserServiceImpl implements UserService {
} }
@Override @Override
public EmployeeRoles assigingEmployeeRole(EmployeeRoles employeeRoles) public EmployeeRoles assigingEmployeeRole(EmployeeRoles employeeRoles, String empId)
throws MyTimeException { throws MyTimeException {
employeeRoles.setCreatedOn(new Date()); employeeRoles.setCreatedOn(new Date());
employeeRoles.setCreatedBy(empId);
employeeRoles.setModifiedBy(empId);
if (employeeRoles.getEmploymentType() != null if (employeeRoles.getEmploymentType() != null
&& !employeeRoles.getEmploymentType().isEmpty() && !employeeRoles.getEmploymentType().isEmpty()
&& !employeeRoles.getEmploymentType() && !employeeRoles.getEmploymentType()
...@@ -204,7 +208,7 @@ public class UserServiceImpl implements UserService { ...@@ -204,7 +208,7 @@ public class UserServiceImpl implements UserService {
} }
@Override @Override
public EmployeeRoles updateEmployeeRole(EmployeeRoles employeeRoles) { public EmployeeRoles updateEmployeeRole(EmployeeRoles employeeRoles,String empId) {
// TODO update all emp details to inactive if employee is inactive // TODO update all emp details to inactive if employee is inactive
Query query = new Query( Query query = new Query(
Criteria.where("employeeId").is(employeeRoles.getEmployeeId())); Criteria.where("employeeId").is(employeeRoles.getEmployeeId()));
...@@ -226,6 +230,9 @@ public class UserServiceImpl implements UserService { ...@@ -226,6 +230,9 @@ public class UserServiceImpl implements UserService {
update.set("hasB1", employeeRoles.getHasB1()); update.set("hasB1", employeeRoles.getHasB1());
update.set("passportExpiryDate", employeeRoles.getPassportExpiryDate()); update.set("passportExpiryDate", employeeRoles.getPassportExpiryDate());
update.set("b1ExpiryDate", employeeRoles.getB1ExpiryDate()); update.set("b1ExpiryDate", employeeRoles.getB1ExpiryDate());
update.set("modifiedBy",empId);
if(employeeRoles.getEmpStatus().equalsIgnoreCase(MyTimeUtils.IN_ACTIVE_SPACE)) { if(employeeRoles.getEmpStatus().equalsIgnoreCase(MyTimeUtils.IN_ACTIVE_SPACE)) {
update.set("endDate", employeeRoles.getEndDate()); update.set("endDate", employeeRoles.getEndDate());
} }
......
...@@ -36,5 +36,5 @@ public interface VisaService { ...@@ -36,5 +36,5 @@ public interface VisaService {
void deleteEmployeeVisas(TravelRequest e); void deleteEmployeeVisas(TravelRequest e);
String exportDataFromExcelFile(MultipartFile file) throws MyTimeException; String exportDataFromExcelFile(MultipartFile file,String empId) throws MyTimeException;
} }
...@@ -88,7 +88,7 @@ public class VisaServiceImpl implements VisaService { ...@@ -88,7 +88,7 @@ public class VisaServiceImpl implements VisaService {
} }
@Override @Override
public String exportDataFromExcelFile(MultipartFile file) public String exportDataFromExcelFile(MultipartFile file,String empId)
throws MyTimeException { throws MyTimeException {
String result = "Failure"; String result = "Failure";
int counter = 0; int counter = 0;
...@@ -104,7 +104,7 @@ public class VisaServiceImpl implements VisaService { ...@@ -104,7 +104,7 @@ public class VisaServiceImpl implements VisaService {
for (EmployeeRoles employee : employees) { for (EmployeeRoles employee : employees) {
System.out.println("test employee" + employee); System.out.println("test employee" + employee);
if (null != employee.getEmployeeId()) if (null != employee.getEmployeeId())
findAndModifyEmployeeRole(employee); findAndModifyEmployeeRole(employee,empId);
else else
counter++; counter++;
} }
...@@ -127,7 +127,7 @@ public class VisaServiceImpl implements VisaService { ...@@ -127,7 +127,7 @@ public class VisaServiceImpl implements VisaService {
return result; return result;
} }
private void findAndModifyEmployeeRole(EmployeeRoles employee) { private void findAndModifyEmployeeRole(EmployeeRoles employee,String empId) {
/* /*
* Query query = new * Query query = new
* Query(Criteria.where("employeeId").is(employee.getEmployeeId())) * Query(Criteria.where("employeeId").is(employee.getEmployeeId()))
...@@ -158,11 +158,12 @@ public class VisaServiceImpl implements VisaService { ...@@ -158,11 +158,12 @@ public class VisaServiceImpl implements VisaService {
* employee.getEmployeeId()); * employee.getEmployeeId());
*/ */
employee.setRole("Employee"); employee.setRole("Employee");
EmployeeRoles emp = userService EmployeeRoles emp = userService
.getEmployeesRoleData(employee.getEmployeeId()); .getEmployeesRoleData(employee.getEmployeeId());
if (emp == null) { if (emp == null) {
try { try {
userService.assigingEmployeeRole(employee); userService.assigingEmployeeRole(employee,empId);
} catch (MyTimeException e) { } catch (MyTimeException e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
......
...@@ -27,6 +27,7 @@ myApp ...@@ -27,6 +27,7 @@ myApp
$scope.uploadFiles = function() { $scope.uploadFiles = function() {
var file = $scope.file; var file = $scope.file;
var empId = myFactory.getEmpId();
if (file == "" || file.length == 0) { if (file == "" || file.length == 0) {
showAlert('Please choose a file to import data...'); showAlert('Please choose a file to import data...');
$scope.refreshPage(); $scope.refreshPage();
...@@ -41,7 +42,7 @@ myApp ...@@ -41,7 +42,7 @@ myApp
$http $http
.post( .post(
appConfig.appUri appConfig.appUri
+ "visa/fileUpload", + "visa/fileUpload?empId="+empId,
formData, formData,
{ {
transformRequest : angular.identity, transformRequest : angular.identity,
......
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