Commit cccf47bb authored by b v s satyanarayana's avatar b v s satyanarayana

MT-53 :SNS :: ImportEmployeeDataValidations

parent c14c38e3
...@@ -15,6 +15,7 @@ import org.springframework.web.bind.annotation.RequestMapping; ...@@ -15,6 +15,7 @@ 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 org.springframework.web.multipart.MultipartFile;
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;
...@@ -30,8 +31,11 @@ import com.nisum.mytime.model.Skill; ...@@ -30,8 +31,11 @@ import com.nisum.mytime.model.Skill;
import com.nisum.mytime.service.RoleMappingService; import com.nisum.mytime.service.RoleMappingService;
import com.nisum.mytime.service.UserService; import com.nisum.mytime.service.UserService;
import lombok.extern.slf4j.Slf4j;
@RestController @RestController
@RequestMapping("/user") @RequestMapping("/user")
@Slf4j
public class UserController { public class UserController {
@Autowired @Autowired
...@@ -276,5 +280,14 @@ public class UserController { ...@@ -276,5 +280,14 @@ public class UserController {
.collect(Collectors.toList()); .collect(Collectors.toList());
return new ResponseEntity<>(domains, HttpStatus.OK); return new ResponseEntity<>(domains, HttpStatus.OK);
} }
@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, @RequestParam(value="empId") String loginEmpId)
throws MyTimeException {
log.info("Uploaded file: {} with size: {}", file.getOriginalFilename(), file.getSize());
String result = userService.exportDataFromExcelFile(file,loginEmpId);
return new ResponseEntity<>(result, HttpStatus.OK);
}
} }
\ No newline at end of file
...@@ -9,9 +9,7 @@ import org.springframework.http.ResponseEntity; ...@@ -9,9 +9,7 @@ import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; 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.RestController; import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import com.nisum.mytime.exception.handler.MyTimeException; import com.nisum.mytime.exception.handler.MyTimeException;
import com.nisum.mytime.model.EmployeeVisa; import com.nisum.mytime.model.EmployeeVisa;
...@@ -19,11 +17,8 @@ import com.nisum.mytime.model.TravelRequest; ...@@ -19,11 +17,8 @@ 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 lombok.extern.slf4j.Slf4j;
@RestController @RestController
@RequestMapping("/visa") @RequestMapping("/visa")
@Slf4j
public class VisaController { public class VisaController {
@Autowired @Autowired
...@@ -84,13 +79,4 @@ public class VisaController { ...@@ -84,13 +79,4 @@ public class VisaController {
visaService.deleteEmployeeVisas(eVisa); visaService.deleteEmployeeVisas(eVisa);
return new ResponseEntity<>("Success", HttpStatus.OK); return new ResponseEntity<>("Success", HttpStatus.OK);
} }
@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, @RequestParam(value="empId") String loginEmpId)
throws MyTimeException {
log.info("Uploaded file: {} with size: {}", file.getOriginalFilename(), file.getSize());
String result = visaService.exportDataFromExcelFile(file,loginEmpId);
return new ResponseEntity<>(result, HttpStatus.OK);
}
} }
\ No newline at end of file
...@@ -15,7 +15,7 @@ import lombok.Setter; ...@@ -15,7 +15,7 @@ import lombok.Setter;
import lombok.ToString; import lombok.ToString;
@Setter @Setter
@Getter @Getter
@AllArgsConstructor @AllArgsConstructor
@NoArgsConstructor @NoArgsConstructor
@ToString @ToString
...@@ -109,4 +109,31 @@ public class EmployeeRoles implements Serializable { ...@@ -109,4 +109,31 @@ public class EmployeeRoles implements Serializable {
private String modifiedBy; private String modifiedBy;
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((employeeId == null) ? 0 : employeeId.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
EmployeeRoles other = (EmployeeRoles) obj;
if (employeeId == null) {
if (other.employeeId != null)
return false;
} else if (!employeeId.equals(other.employeeId))
return false;
return true;
}
} }
package com.nisum.mytime.repository; package com.nisum.mytime.repository;
import java.util.List; import java.util.List;
import java.util.Set;
import org.springframework.data.mongodb.repository.MongoRepository; import org.springframework.data.mongodb.repository.MongoRepository;
...@@ -20,5 +21,8 @@ public interface EmployeeRolesRepo ...@@ -20,5 +21,8 @@ public interface EmployeeRolesRepo
List<EmployeeRoles> findByEmpStatusOrderByEmployeeNameAsc(String empStatus); List<EmployeeRoles> findByEmpStatusOrderByEmployeeNameAsc(String empStatus);
List<EmployeeRoles> findByEmpStatus(String status); List<EmployeeRoles> findByEmpStatus(String status);
List<EmployeeRoles> findByEmployeeIdIn(Set<String> empIdsSet);
} }
\ No newline at end of file
package com.nisum.mytime.repository; package com.nisum.mytime.repository;
import java.util.List;
import org.springframework.data.mongodb.repository.MongoRepository; import org.springframework.data.mongodb.repository.MongoRepository;
import com.nisum.mytime.model.Location; import com.nisum.mytime.model.Location;
public interface LocationRepo extends MongoRepository<Location, String> { public interface LocationRepo extends MongoRepository<Location, String> {
List<Location> findByLocationAndActiveStatus(String location, boolean activeStatus);
} }
\ No newline at end of file
package com.nisum.mytime.repository; package com.nisum.mytime.repository;
import java.util.List;
import org.springframework.data.mongodb.repository.MongoRepository; import org.springframework.data.mongodb.repository.MongoRepository;
import com.nisum.mytime.model.MasterData; import com.nisum.mytime.model.MasterData;
public interface MasterDataRepo extends MongoRepository<MasterData, String> { public interface MasterDataRepo extends MongoRepository<MasterData, String> {
List<MasterData> findByMasterDataTypeAndMasterDataNameAndActiveStatus(String masterDataType, String masterDataName, boolean activeStatus);
} }
\ No newline at end of file
...@@ -3,6 +3,8 @@ package com.nisum.mytime.service; ...@@ -3,6 +3,8 @@ package com.nisum.mytime.service;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import org.springframework.web.multipart.MultipartFile;
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.AccountInfo; import com.nisum.mytime.model.AccountInfo;
...@@ -78,4 +80,6 @@ public interface UserService { ...@@ -78,4 +80,6 @@ public interface UserService {
public List<Domains> getDomains(String accountId)throws MyTimeException; public List<Domains> getDomains(String accountId)throws MyTimeException;
public boolean verifyRole(String empId, String roleName); public boolean verifyRole(String empId, String roleName);
String exportDataFromExcelFile(MultipartFile file, String empId) throws MyTimeException;
} }
...@@ -5,8 +5,11 @@ import java.util.Calendar; ...@@ -5,8 +5,11 @@ import java.util.Calendar;
import java.util.Comparator; import java.util.Comparator;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.stream.Collector;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -17,6 +20,7 @@ import org.springframework.data.mongodb.core.query.Criteria; ...@@ -17,6 +20,7 @@ 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.data.mongodb.core.query.Update; import org.springframework.data.mongodb.core.query.Update;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
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;
...@@ -47,10 +51,17 @@ import com.nisum.mytime.repository.ProjectTeamMatesRepo; ...@@ -47,10 +51,17 @@ import com.nisum.mytime.repository.ProjectTeamMatesRepo;
import com.nisum.mytime.repository.ShiftRepo; import com.nisum.mytime.repository.ShiftRepo;
import com.nisum.mytime.repository.TeamMatesBillingRepo; import com.nisum.mytime.repository.TeamMatesBillingRepo;
import com.nisum.mytime.repository.TechnologyRepo; import com.nisum.mytime.repository.TechnologyRepo;
import com.nisum.mytime.utils.DataValidations;
import com.nisum.mytime.utils.MyTimeUtils; import com.nisum.mytime.utils.MyTimeUtils;
import com.nisum.mytime.utils.PdfReportGenerator; import com.nisum.mytime.utils.PdfReportGenerator;
import com.poiji.bind.Poiji;
import com.poiji.exception.PoijiExcelType;
import com.poiji.option.PoijiOptions;
import lombok.extern.slf4j.Slf4j;
@Service("userService") @Service("userService")
@Slf4j
public class UserServiceImpl implements UserService { public class UserServiceImpl implements UserService {
@Autowired @Autowired
...@@ -108,8 +119,6 @@ public class UserServiceImpl implements UserService { ...@@ -108,8 +119,6 @@ public class UserServiceImpl implements UserService {
@Override @Override
public Boolean fetchEmployeesData(String perticularDate, public Boolean fetchEmployeesData(String perticularDate,
boolean resynchFlag) throws MyTimeException { boolean resynchFlag) throws MyTimeException {
/* return employeeDataBaseService.fetchEmployeesData(perticularDate,
resynchFlag);*/
return true; return true;
} }
...@@ -136,9 +145,6 @@ public class UserServiceImpl implements UserService { ...@@ -136,9 +145,6 @@ public class UserServiceImpl implements UserService {
employeeRoles.setCreatedOn(new Date()); employeeRoles.setCreatedOn(new Date());
employeeRoles.setCreatedBy(empId); employeeRoles.setCreatedBy(empId);
employeeRoles.setModifiedBy(empId); employeeRoles.setModifiedBy(empId);
if (employeeRoles.getEmploymentType() == null || employeeRoles.getEmploymentType().isEmpty()) {
employeeRoles.setEmploymentType("Full Time");
}
ProjectTeamMate newBenchAllocation = new ProjectTeamMate(); ProjectTeamMate newBenchAllocation = new ProjectTeamMate();
newBenchAllocation.setAccount(MyTimeUtils.BENCH_ACCOUNT); newBenchAllocation.setAccount(MyTimeUtils.BENCH_ACCOUNT);
...@@ -158,14 +164,11 @@ public class UserServiceImpl implements UserService { ...@@ -158,14 +164,11 @@ public class UserServiceImpl implements UserService {
newBenchAllocation.setShift(employeeRoles.getShift()); newBenchAllocation.setShift(employeeRoles.getShift());
newBenchAllocation.setRole(employeeRoles.getRole()); newBenchAllocation.setRole(employeeRoles.getRole());
if (employeeRoles.getEmpStatus() != null if ( null != employeeRoles.getEmpStatus() && employeeRoles.getEmpStatus().trim().equalsIgnoreCase(MyTimeUtils.IN_ACTIVE_SPACE)) {
&& (employeeRoles.getEmpStatus().trim().equalsIgnoreCase("InActive")
|| employeeRoles.getEmpStatus().trim().equalsIgnoreCase("In Active"))) {
employeeRoles.setEmpStatus("In Active");
newBenchAllocation.setEndDate(employeeRoles.getEndDate()); newBenchAllocation.setEndDate(employeeRoles.getEndDate());
newBenchAllocation.setActive(false); newBenchAllocation.setActive(false);
} else { } else {
employeeRoles.setEmpStatus("Active"); employeeRoles.setEmpStatus(MyTimeUtils.ACTIVE);
newBenchAllocation.setEndDate(p.getProjectEndDate()); newBenchAllocation.setEndDate(p.getProjectEndDate());
newBenchAllocation.setActive(true); newBenchAllocation.setActive(true);
} }
...@@ -175,20 +178,6 @@ public class UserServiceImpl implements UserService { ...@@ -175,20 +178,6 @@ public class UserServiceImpl implements UserService {
} catch (MyTimeException e) { } catch (MyTimeException e) {
e.printStackTrace(); e.printStackTrace();
} }
/*
* BillingDetails billingDetails = new BillingDetails();
* billingDetails.setBillableStatus("Bench"); billingDetails
* .setBillingStartDate(employeeRoles.getDateOfJoining() != null ?
* employeeRoles.getDateOfJoining() : new Date());
* billingDetails.setActive(true);
* billingDetails.setEmployeeId(employeeRoles.getEmployeeId());
* billingDetails.setEmployeeName(employeeRoles.getEmployeeName());
* billingDetails.setCreateDate(new Date());
* billingDetails.setProjectId("Nisum0000");
* billingDetails.setProjectName("Bench");
* projectService.addEmployeeBillingDetails(billingDetails);
*/
saveEmployeeLocationDetails(employeeRoles); saveEmployeeLocationDetails(employeeRoles);
return employeeRolesRepo.save(employeeRoles); return employeeRolesRepo.save(employeeRoles);
} }
...@@ -556,4 +545,169 @@ public class UserServiceImpl implements UserService { ...@@ -556,4 +545,169 @@ public class UserServiceImpl implements UserService {
} }
return flag; return flag;
} }
@Override
public String exportDataFromExcelFile(MultipartFile file, String empId)
throws MyTimeException {
String result = "Failure";
int counter = 0;
try {
PoijiOptions options = PoijiOptions.PoijiOptionsBuilder.settings()
.preferNullOverDefault(true).datePattern("dd-MMM-yyyy")
.build();
List<EmployeeRoles> employees = Poiji.fromExcel(
file.getInputStream(), PoijiExcelType.XLS,
EmployeeRoles.class, options);
validateExcelRecords(employees);
if (!employees.isEmpty()) {
for (EmployeeRoles employee : employees) {
if (null != employee.getEmployeeId()) {
findAndModifyEmployeeRole(employee,empId);
}else {
counter++;
}
}
if (counter == 0) {
result = "Success";
log.info("Exported {} employee records from file: {}", employees.size(), file.getOriginalFilename());
} else {
log.info( "Uploaded file: {}, does not contain valid employee records", file.getOriginalFilename());
}
}
} catch (Exception e) {
log.error("Exception occured while exporting the data from excel file due to: {}",e);
throw new MyTimeException("");
}
return result;
}
private void findAndModifyEmployeeRole(EmployeeRoles employee,String empId) {
try {
if(null == employee.getRole() || employee.getRole().isEmpty()) {
employee.setRole(MyTimeUtils.EMPLOYEE);
}
if (employee.getEmploymentType() == null || employee.getEmploymentType().isEmpty()) {
employee.setEmploymentType(MyTimeUtils.FULL_TIME);
}
if (employee.getEmpStatus() != null
&& (employee.getEmpStatus().trim().equalsIgnoreCase(MyTimeUtils.IN_ACTIVE)
|| employee.getEmpStatus().trim().equalsIgnoreCase(MyTimeUtils.IN_ACTIVE_SPACE) || employee.getEmpStatus().trim().equalsIgnoreCase(MyTimeUtils.IN_HYPEN_ACTIVE_SPACE) )) {
employee.setEmpStatus(MyTimeUtils.IN_ACTIVE_SPACE);
} else {
employee.setEmpStatus(MyTimeUtils.ACTIVE);
}
if ( null != employee.getGender() && !employee.getGender().isEmpty()) {
if(employee.getGender().equalsIgnoreCase(MyTimeUtils.MALE)) {
employee.setGender(MyTimeUtils.MALE);
}else if(employee.getGender().equalsIgnoreCase(MyTimeUtils.FEMALE)){
employee.setGender(MyTimeUtils.FEMALE);
}
}
assigingEmployeeRole(employee,empId);
} catch (MyTimeException e) {
e.printStackTrace();
}
}
private Map<String,Object> validateExcelRecords(List<EmployeeRoles> employees) {
boolean flag = false;
Map<String, String> invalidEmpRecsMap = new HashMap<String, String>();
Map<String,Object> finalMap = new HashMap<String, Object>();
if(null != employees && employees.size() > MyTimeUtils.INT_ZERO) {
int rowNumber = MyTimeUtils.INT_TWO;
List<EmployeeRoles> invalidEmpRecs = new ArrayList<EmployeeRoles>();
Set<String> empIdsSet = employees.stream().map(EmployeeRoles :: getEmployeeId).collect(Collectors.toSet());
empIdsSet.remove(MyTimeUtils.EMPTY_STRING);
List<EmployeeRoles> existingEmployess = employeeRolesRepo.findByEmployeeIdIn(empIdsSet);
if(existingEmployess.size() > MyTimeUtils.INT_ZERO) {
finalMap.put("Below emp records already avilable in db", existingEmployess.stream().map(EmployeeRoles :: getEmployeeId).collect(Collectors.toSet()).toString());
employees.removeAll(existingEmployess);
}
for(EmployeeRoles empRole : employees) {
if(! DataValidations.validateNumber(empRole.getEmployeeId())) {
flag = false;
}else if(! DataValidations.validateName(empRole.getEmployeeName())) {
flag = false;
}else if(! DataValidations.isValidGender(empRole.getGender())) {
flag = false;
}else if(! DataValidations.isValidDate(empRole.getDateOfJoining())) {
flag = false;
}else if(! DataValidations.isValidFunctionalGroup(empRole.getFunctionalGroup())) {
flag = false;
}else if(! DataValidations.isValidDesignation(empRole.getDesignation())) {
flag = false;
}else if(! DataValidations.isValidWorkLocation(empRole.getEmpLocation())) {
flag = false;
}else if(! DataValidations.isValidEmploymentType(empRole.getEmploymentType())) {
flag = false;
}else if(! DataValidations.isValidRole(empRole.getRole())) {
flag = false;
}else if(! DataValidations.isYesOrNo(empRole.getHasPassort())) {
flag = false;
}else if(! DataValidations.isYesOrNo(empRole.getHasB1())) {
flag = false;
}else {
flag = true;
}
if( flag) {
if(empRole.getDateOfBirth() != null) {
flag = DataValidations.isAgeGreaterThanTwenty(empRole.getDateOfBirth(), empRole.getDateOfJoining());
}
if(MyTimeUtils.YES.equals(empRole.getHasPassort())){
flag = DataValidations.isFutureDate(empRole.getPassportExpiryDate());
}
if(MyTimeUtils.YES.equals(empRole.getHasB1())) {
flag = DataValidations.isFutureDate(empRole.getB1ExpiryDate());
}
if(null != empRole.getEmpStatus() && ! MyTimeUtils.EMPTY_STRING.equals(empRole.getEmpStatus().trim()) ) {
String empStatus = empRole.getEmpStatus().trim();
if(empStatus.equalsIgnoreCase(MyTimeUtils.IN_ACTIVE) || MyTimeUtils.IN_ACTIVE_SPACE.equalsIgnoreCase(empStatus) || MyTimeUtils.IN_HYPEN_ACTIVE_SPACE.equalsIgnoreCase(empStatus)) {
flag = DataValidations.isValidDate(empRole.getEndDate());
}
}
if(flag) {
empIdsSet.add(empRole.getEmployeeId().trim());
}else {
invalidEmpRecsMap.put(Integer.toString(rowNumber), empRole.getEmployeeName());
invalidEmpRecs.add(empRole);
}
}else {
invalidEmpRecsMap.put(Integer.toString(rowNumber), empRole.getEmployeeName());
invalidEmpRecs.add(empRole);
}
rowNumber += 1;
}
if(invalidEmpRecs.size() > MyTimeUtils.INT_ZERO) {
employees.removeAll(invalidEmpRecs);
}
}
finalMap.put("Below emp records are not valid", invalidEmpRecsMap);
return finalMap;
}
public void getExistingEmployess(List<EmployeeRoles> employees) {
List<EmployeeRoles> existingEmployess = employeeRolesRepo.findByEmployeeIdIn(employees.stream().map(EmployeeRoles :: getEmployeeId).collect(Collectors.toSet()));
}
} }
...@@ -35,6 +35,4 @@ public interface VisaService { ...@@ -35,6 +35,4 @@ public interface VisaService {
TravelRequest updateTravelRequest(TravelRequest e); TravelRequest updateTravelRequest(TravelRequest e);
void deleteEmployeeVisas(TravelRequest e); void deleteEmployeeVisas(TravelRequest e);
String exportDataFromExcelFile(MultipartFile file,String empId) throws MyTimeException;
} }
...@@ -7,28 +7,20 @@ import java.util.List; ...@@ -7,28 +7,20 @@ import java.util.List;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import com.nisum.mytime.exception.handler.MyTimeException;
import com.nisum.mytime.model.EmployeeRoles;
import com.nisum.mytime.model.EmployeeVisa; 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.repository.EmployeeRolesRepo;
import com.nisum.mytime.repository.EmployeeVisaRepo; import com.nisum.mytime.repository.EmployeeVisaRepo;
import com.nisum.mytime.repository.TravelRepo; import com.nisum.mytime.repository.TravelRepo;
import com.nisum.mytime.repository.VisaRepo; import com.nisum.mytime.repository.VisaRepo;
import com.poiji.bind.Poiji;
import com.poiji.exception.PoijiExcelType;
import com.poiji.option.PoijiOptions;
import lombok.extern.slf4j.Slf4j;
/** /**
* @author nisum * @author nisum
* *
*/ */
@Service @Service
@Slf4j
public class VisaServiceImpl implements VisaService { public class VisaServiceImpl implements VisaService {
@Autowired @Autowired
...@@ -41,6 +33,10 @@ public class VisaServiceImpl implements VisaService { ...@@ -41,6 +33,10 @@ public class VisaServiceImpl implements VisaService {
@Autowired @Autowired
private UserService userService; private UserService userService;
@Autowired
private EmployeeRolesRepo employeeRolesRepo;
@Override @Override
public List<Visa> getAllVisas() { public List<Visa> getAllVisas() {
...@@ -87,88 +83,4 @@ public class VisaServiceImpl implements VisaService { ...@@ -87,88 +83,4 @@ public class VisaServiceImpl implements VisaService {
travelRepo.delete(e); travelRepo.delete(e);
} }
@Override }
public String exportDataFromExcelFile(MultipartFile file, String empId)
throws MyTimeException {
String result = "Failure";
int counter = 0;
try {
PoijiOptions options = PoijiOptions.PoijiOptionsBuilder.settings()
.preferNullOverDefault(true).datePattern("dd-MMM-yyyy")
.build();
List<EmployeeRoles> employees = Poiji.fromExcel(
file.getInputStream(), PoijiExcelType.XLS,
EmployeeRoles.class, options);
if (!employees.isEmpty()) {
for (EmployeeRoles employee : employees) {
System.out.println("test employee" + employee);
if (null != employee.getEmployeeId())
findAndModifyEmployeeRole(employee,empId);
else
counter++;
}
if (counter == 0) {
result = "Success";
log.info("Exported {} employee records from file: {}",
employees.size(), file.getOriginalFilename());
} else {
log.info(
"Uploaded file: {}, does not contain valid employee records",
file.getOriginalFilename());
}
}
} catch (Exception e) {
log.error(
"Exception occured while exporting the data from excel file due to: {}",
e);
throw new MyTimeException("");
}
return result;
}
private void findAndModifyEmployeeRole(EmployeeRoles employee,String empId) {
/*
* Query query = new
* Query(Criteria.where("employeeId").is(employee.getEmployeeId()))
* .addCriteria(Criteria.where("emailId").is(employee.getEmailId()));
* Update update = new Update(); update.set("employeeId",
* employee.getEmployeeId()); update.set("employeeName",
* employee.getEmployeeName()); update.set("emailId",
* employee.getEmailId()); update.set("role", employee.getRole());
* update.set("functionalGroup", employee.getFunctionalGroup());
* update.set("empStatus", employee.getEmpStatus());
* update.set("employmentType", employee.getEmploymentType());
* update.set("empLocation", employee.getEmpLocation());
* update.set("domain", employee.getDomain()); update.set("designation",
* employee.getDesignation()); update.set("dateOfBirth",
* employee.getDateOfBirth()); update.set("dateOfJoining",
* employee.getDateOfJoining()); update.set("shift",
* employee.getShift()); update.set("baseTechnology",
* employee.getBaseTechnology()); update.set("technologyKnown",
* employee.getTechnologyKnown()); update.set("mobileNumber",
* employee.getMobileNumber()); update.set("alternateMobileNumber",
* employee.getAlternateMobileNumber()); update.set("personalEmailId",
* employee.getPersonalEmailId()); update.set("createdOn", new Date());
* update.set("lastModifiedOn", new Date()); FindAndModifyOptions
* options = new FindAndModifyOptions(); options.returnNew(true);
* options.upsert(true); mongoTemplate.findAndModify(query, update,
* options, EmployeeRoles.class);
* log.info("Inserted Employee record with Id: {}",
* employee.getEmployeeId());
*/
EmployeeRoles emp = userService.getEmployeesRoleData(employee.getEmployeeId());
if (emp == null) {
try {
if(employee.getRole()==null || employee.getRole().isEmpty()) {
employee.setRole("Employee");
}
userService.assigingEmployeeRole(employee,empId);
} catch (MyTimeException e) {
e.printStackTrace();
}
}
}
}
...@@ -9,13 +9,15 @@ public class MyTimeUtils { ...@@ -9,13 +9,15 @@ public class MyTimeUtils {
} }
public final static String driverUrl = "jdbc:ucanaccess://"; //public final static String driverUrl = "jdbc:ucanaccess://";
public final static String msdriveUrl ="jdbc:sqlserver://"; //public final static String msdriveUrl ="jdbc:sqlserver://";
public final static DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); public final static DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
public final static DateFormat tdf = new SimpleDateFormat("HH:mm"); public final static DateFormat tdf = new SimpleDateFormat("HH:mm");
public final static DateFormat dfmt = new SimpleDateFormat("yyyy-MM-dd"); public final static DateFormat dfmt = new SimpleDateFormat("yyyy-MM-dd");
//public final static DateFormat dfmtDdMmmYyyy = new SimpleDateFormat("dd-MM-yyyy");
public final static String UNDER_SCORE = "_"; public final static String UNDER_SCORE = "_";
public final static String DATE_OF_LOGIN = "dateOfLogin"; public final static String DATE_OF_LOGIN = "dateOfLogin";
public final static String EMPLOYEE = "Employee";
public final static String EMPLOYEE_ID = "employeeId"; public final static String EMPLOYEE_ID = "employeeId";
public final static String EMPLOYEE_NAME = "employeeName"; public final static String EMPLOYEE_NAME = "employeeName";
public final static String FIRST_LOGIN = "firstLogin"; public final static String FIRST_LOGIN = "firstLogin";
...@@ -53,6 +55,7 @@ public class MyTimeUtils { ...@@ -53,6 +55,7 @@ public class MyTimeUtils {
public static final String ACTIVE = "Active"; public static final String ACTIVE = "Active";
public static final String IN_ACTIVE = "InActive"; public static final String IN_ACTIVE = "InActive";
public static final String IN_ACTIVE_SPACE = "In Active"; public static final String IN_ACTIVE_SPACE = "In Active";
public static final String IN_HYPEN_ACTIVE_SPACE = "In-Active";
public final static String TEAMDETAILS_COLLECTION_NAME = "TeamDetails"; public final static String TEAMDETAILS_COLLECTION_NAME = "TeamDetails";
public final static String BILLINGDETAILS_COLLECTION_NAME = "BillingDetails"; public final static String BILLINGDETAILS_COLLECTION_NAME = "BillingDetails";
public final static String ENDDATE_COLUMN = "endDate"; public final static String ENDDATE_COLUMN = "endDate";
...@@ -109,9 +112,28 @@ public class MyTimeUtils { ...@@ -109,9 +112,28 @@ public class MyTimeUtils {
public final static String BENCH_BILLABILITY_STATUS="Non-Billable"; public final static String BENCH_BILLABILITY_STATUS="Non-Billable";
public final static int INT_ZERO = 0; public final static int INT_ZERO = 0;
public final static int INT_TWO = 2;
public final static int INT_TWENTY = 20;
public final static String DM= "DM"; public final static String DM= "DM";
public final static String DL= "DL"; public final static String DL= "DL";
public final static String L= "L"; public final static String L= "L";
public final static String EMPTY_STRING = "";
public final static String MALE = "Male";
public final static String FEMALE ="Female";
public final static String YES = "Yes";
public final static String NO = "No";
public final static long EMPID_START = 16001;
public final static long EMPID_END = 99999;
public final static String MASTERDATA_FG = "FunctionalGrp";
public final static String MASTERDATA_DESIGNATION = "designations";
public final static String MASTERDATAD_EMLOYMENT_TYPE = "EmpType";
public final static String MASTERDATA_ROLES = "roles";
public final static String FULL_TIME ="Full Time";
} }
...@@ -42,7 +42,7 @@ myApp ...@@ -42,7 +42,7 @@ myApp
$http $http
.post( .post(
appConfig.appUri appConfig.appUri
+ "visa/fileUpload?empId="+empId, + "user/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