Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mytime
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Narendar Vakiti
mytime
Commits
cccf47bb
Commit
cccf47bb
authored
Sep 04, 2018
by
b v s satyanarayana
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MT-53 :SNS :: ImportEmployeeDataValidations
parent
c14c38e3
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
265 additions
and
140 deletions
+265
-140
UserController.java
...main/java/com/nisum/mytime/controller/UserController.java
+13
-0
VisaController.java
...main/java/com/nisum/mytime/controller/VisaController.java
+0
-14
EmployeeRoles.java
src/main/java/com/nisum/mytime/model/EmployeeRoles.java
+28
-1
EmployeeRolesRepo.java
...n/java/com/nisum/mytime/repository/EmployeeRolesRepo.java
+5
-1
LocationRepo.java
src/main/java/com/nisum/mytime/repository/LocationRepo.java
+3
-1
MasterDataRepo.java
...main/java/com/nisum/mytime/repository/MasterDataRepo.java
+3
-0
UserService.java
src/main/java/com/nisum/mytime/service/UserService.java
+4
-0
UserServiceImpl.java
src/main/java/com/nisum/mytime/service/UserServiceImpl.java
+178
-24
VisaService.java
src/main/java/com/nisum/mytime/service/VisaService.java
+0
-2
VisaServiceImpl.java
src/main/java/com/nisum/mytime/service/VisaServiceImpl.java
+6
-94
MyTimeUtils.java
src/main/java/com/nisum/mytime/utils/MyTimeUtils.java
+24
-2
ExportDataController.js
src/main/webapp/WEB-INF/controllers/ExportDataController.js
+1
-1
No files found.
src/main/java/com/nisum/mytime/controller/UserController.java
View file @
cccf47bb
...
...
@@ -15,6 +15,7 @@ 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
org.springframework.web.multipart.MultipartFile
;
import
com.nisum.mytime.exception.handler.MyTimeException
;
import
com.nisum.mytime.model.Account
;
...
...
@@ -30,8 +31,11 @@ import com.nisum.mytime.model.Skill;
import
com.nisum.mytime.service.RoleMappingService
;
import
com.nisum.mytime.service.UserService
;
import
lombok.extern.slf4j.Slf4j
;
@RestController
@RequestMapping
(
"/user"
)
@Slf4j
public
class
UserController
{
@Autowired
...
...
@@ -276,5 +280,14 @@ public class UserController {
.
collect
(
Collectors
.
toList
());
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
src/main/java/com/nisum/mytime/controller/VisaController.java
View file @
cccf47bb
...
...
@@ -9,9 +9,7 @@ import org.springframework.http.ResponseEntity;
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
org.springframework.web.multipart.MultipartFile
;
import
com.nisum.mytime.exception.handler.MyTimeException
;
import
com.nisum.mytime.model.EmployeeVisa
;
...
...
@@ -19,11 +17,8 @@ import com.nisum.mytime.model.TravelRequest;
import
com.nisum.mytime.model.Visa
;
import
com.nisum.mytime.service.VisaService
;
import
lombok.extern.slf4j.Slf4j
;
@RestController
@RequestMapping
(
"/visa"
)
@Slf4j
public
class
VisaController
{
@Autowired
...
...
@@ -84,13 +79,4 @@ public class VisaController {
visaService
.
deleteEmployeeVisas
(
eVisa
);
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
src/main/java/com/nisum/mytime/model/EmployeeRoles.java
View file @
cccf47bb
...
...
@@ -15,7 +15,7 @@ import lombok.Setter;
import
lombok.ToString
;
@Setter
@Getter
@Getter
@AllArgsConstructor
@NoArgsConstructor
@ToString
...
...
@@ -109,4 +109,31 @@ public class EmployeeRoles implements Serializable {
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
;
}
}
src/main/java/com/nisum/mytime/repository/EmployeeRolesRepo.java
View file @
cccf47bb
package
com
.
nisum
.
mytime
.
repository
;
import
java.util.List
;
import
java.util.Set
;
import
org.springframework.data.mongodb.repository.MongoRepository
;
...
...
@@ -20,5 +21,8 @@ public interface EmployeeRolesRepo
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
src/main/java/com/nisum/mytime/repository/LocationRepo.java
View file @
cccf47bb
package
com
.
nisum
.
mytime
.
repository
;
import
java.util.List
;
import
org.springframework.data.mongodb.repository.MongoRepository
;
import
com.nisum.mytime.model.Location
;
public
interface
LocationRepo
extends
MongoRepository
<
Location
,
String
>
{
List
<
Location
>
findByLocationAndActiveStatus
(
String
location
,
boolean
activeStatus
);
}
\ No newline at end of file
src/main/java/com/nisum/mytime/repository/MasterDataRepo.java
View file @
cccf47bb
package
com
.
nisum
.
mytime
.
repository
;
import
java.util.List
;
import
org.springframework.data.mongodb.repository.MongoRepository
;
import
com.nisum.mytime.model.MasterData
;
public
interface
MasterDataRepo
extends
MongoRepository
<
MasterData
,
String
>
{
List
<
MasterData
>
findByMasterDataTypeAndMasterDataNameAndActiveStatus
(
String
masterDataType
,
String
masterDataName
,
boolean
activeStatus
);
}
\ No newline at end of file
src/main/java/com/nisum/mytime/service/UserService.java
View file @
cccf47bb
...
...
@@ -3,6 +3,8 @@ package com.nisum.mytime.service;
import
java.util.HashMap
;
import
java.util.List
;
import
org.springframework.web.multipart.MultipartFile
;
import
com.nisum.mytime.exception.handler.MyTimeException
;
import
com.nisum.mytime.model.Account
;
import
com.nisum.mytime.model.AccountInfo
;
...
...
@@ -78,4 +80,6 @@ public interface UserService {
public
List
<
Domains
>
getDomains
(
String
accountId
)
throws
MyTimeException
;
public
boolean
verifyRole
(
String
empId
,
String
roleName
);
String
exportDataFromExcelFile
(
MultipartFile
file
,
String
empId
)
throws
MyTimeException
;
}
src/main/java/com/nisum/mytime/service/UserServiceImpl.java
View file @
cccf47bb
...
...
@@ -5,8 +5,11 @@ import java.util.Calendar;
import
java.util.Comparator
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Set
;
import
java.util.stream.Collector
;
import
java.util.stream.Collectors
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -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.Update
;
import
org.springframework.stereotype.Service
;
import
org.springframework.web.multipart.MultipartFile
;
import
com.nisum.mytime.exception.handler.MyTimeException
;
import
com.nisum.mytime.model.Account
;
...
...
@@ -47,10 +51,17 @@ import com.nisum.mytime.repository.ProjectTeamMatesRepo;
import
com.nisum.mytime.repository.ShiftRepo
;
import
com.nisum.mytime.repository.TeamMatesBillingRepo
;
import
com.nisum.mytime.repository.TechnologyRepo
;
import
com.nisum.mytime.utils.DataValidations
;
import
com.nisum.mytime.utils.MyTimeUtils
;
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"
)
@Slf4j
public
class
UserServiceImpl
implements
UserService
{
@Autowired
...
...
@@ -108,8 +119,6 @@ public class UserServiceImpl implements UserService {
@Override
public
Boolean
fetchEmployeesData
(
String
perticularDate
,
boolean
resynchFlag
)
throws
MyTimeException
{
/* return employeeDataBaseService.fetchEmployeesData(perticularDate,
resynchFlag);*/
return
true
;
}
...
...
@@ -136,9 +145,6 @@ public class UserServiceImpl implements UserService {
employeeRoles
.
setCreatedOn
(
new
Date
());
employeeRoles
.
setCreatedBy
(
empId
);
employeeRoles
.
setModifiedBy
(
empId
);
if
(
employeeRoles
.
getEmploymentType
()
==
null
||
employeeRoles
.
getEmploymentType
().
isEmpty
())
{
employeeRoles
.
setEmploymentType
(
"Full Time"
);
}
ProjectTeamMate
newBenchAllocation
=
new
ProjectTeamMate
();
newBenchAllocation
.
setAccount
(
MyTimeUtils
.
BENCH_ACCOUNT
);
...
...
@@ -158,14 +164,11 @@ public class UserServiceImpl implements UserService {
newBenchAllocation
.
setShift
(
employeeRoles
.
getShift
());
newBenchAllocation
.
setRole
(
employeeRoles
.
getRole
());
if
(
employeeRoles
.
getEmpStatus
()
!=
null
&&
(
employeeRoles
.
getEmpStatus
().
trim
().
equalsIgnoreCase
(
"InActive"
)
||
employeeRoles
.
getEmpStatus
().
trim
().
equalsIgnoreCase
(
"In Active"
)))
{
employeeRoles
.
setEmpStatus
(
"In Active"
);
if
(
null
!=
employeeRoles
.
getEmpStatus
()
&&
employeeRoles
.
getEmpStatus
().
trim
().
equalsIgnoreCase
(
MyTimeUtils
.
IN_ACTIVE_SPACE
))
{
newBenchAllocation
.
setEndDate
(
employeeRoles
.
getEndDate
());
newBenchAllocation
.
setActive
(
false
);
}
else
{
employeeRoles
.
setEmpStatus
(
"Active"
);
employeeRoles
.
setEmpStatus
(
MyTimeUtils
.
ACTIVE
);
newBenchAllocation
.
setEndDate
(
p
.
getProjectEndDate
());
newBenchAllocation
.
setActive
(
true
);
}
...
...
@@ -175,20 +178,6 @@ public class UserServiceImpl implements UserService {
}
catch
(
MyTimeException
e
)
{
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
);
return
employeeRolesRepo
.
save
(
employeeRoles
);
}
...
...
@@ -556,4 +545,169 @@ public class UserServiceImpl implements UserService {
}
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
()));
}
}
src/main/java/com/nisum/mytime/service/VisaService.java
View file @
cccf47bb
...
...
@@ -35,6 +35,4 @@ public interface VisaService {
TravelRequest
updateTravelRequest
(
TravelRequest
e
);
void
deleteEmployeeVisas
(
TravelRequest
e
);
String
exportDataFromExcelFile
(
MultipartFile
file
,
String
empId
)
throws
MyTimeException
;
}
src/main/java/com/nisum/mytime/service/VisaServiceImpl.java
View file @
cccf47bb
...
...
@@ -7,28 +7,20 @@ import java.util.List;
import
org.springframework.beans.factory.annotation.Autowired
;
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.TravelRequest
;
import
com.nisum.mytime.model.Visa
;
import
com.nisum.mytime.repository.EmployeeRolesRepo
;
import
com.nisum.mytime.repository.EmployeeVisaRepo
;
import
com.nisum.mytime.repository.TravelRepo
;
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
*
*/
@Service
@Slf4j
public
class
VisaServiceImpl
implements
VisaService
{
@Autowired
...
...
@@ -41,6 +33,10 @@ public class VisaServiceImpl implements VisaService {
@Autowired
private
UserService
userService
;
@Autowired
private
EmployeeRolesRepo
employeeRolesRepo
;
@Override
public
List
<
Visa
>
getAllVisas
()
{
...
...
@@ -87,88 +83,4 @@ public class VisaServiceImpl implements VisaService {
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
();
}
}
}
}
}
src/main/java/com/nisum/mytime/utils/MyTimeUtils.java
View file @
cccf47bb
...
...
@@ -9,13 +9,15 @@ public class MyTimeUtils {
}
public
final
static
String
driverUrl
=
"jdbc:ucanaccess://"
;
public
final
static
String
msdriveUrl
=
"jdbc:sqlserver://"
;
//
public final static String driverUrl = "jdbc:ucanaccess://";
//
public final static String msdriveUrl ="jdbc:sqlserver://";
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
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
DATE_OF_LOGIN
=
"dateOfLogin"
;
public
final
static
String
EMPLOYEE
=
"Employee"
;
public
final
static
String
EMPLOYEE_ID
=
"employeeId"
;
public
final
static
String
EMPLOYEE_NAME
=
"employeeName"
;
public
final
static
String
FIRST_LOGIN
=
"firstLogin"
;
...
...
@@ -53,6 +55,7 @@ public class MyTimeUtils {
public
static
final
String
ACTIVE
=
"Active"
;
public
static
final
String
IN_ACTIVE
=
"InActive"
;
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
BILLINGDETAILS_COLLECTION_NAME
=
"BillingDetails"
;
public
final
static
String
ENDDATE_COLUMN
=
"endDate"
;
...
...
@@ -109,9 +112,28 @@ public class MyTimeUtils {
public
final
static
String
BENCH_BILLABILITY_STATUS
=
"Non-Billable"
;
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
DL
=
"DL"
;
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"
;
}
src/main/webapp/WEB-INF/controllers/ExportDataController.js
View file @
cccf47bb
...
...
@@ -42,7 +42,7 @@ myApp
$http
.
post
(
appConfig
.
appUri
+
"
visa
/fileUpload?empId="
+
empId
,
+
"
user
/fileUpload?empId="
+
empId
,
formData
,
{
transformRequest
:
angular
.
identity
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment