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
cf947c85
Commit
cf947c85
authored
Oct 04, 2018
by
Vijay Akula
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[vijay.A] Refactored the code for Employee Controller Service and
repositories
parent
a6abbc45
Changes
67
Show whitespace changes
Inline
Side-by-side
Showing
67 changed files
with
1877 additions
and
1619 deletions
+1877
-1619
AccountController.java
...n/java/com/nisum/mytime/controller/AccountController.java
+35
-18
AttendanceController.java
...ava/com/nisum/mytime/controller/AttendanceController.java
+45
-65
DesignationController.java
...va/com/nisum/mytime/controller/DesignationController.java
+12
-5
DomainController.java
...in/java/com/nisum/mytime/controller/DomainController.java
+15
-4
EmployeeController.java
.../java/com/nisum/mytime/controller/EmployeeController.java
+133
-161
EmployeeLocationController.java
...m/nisum/mytime/controller/EmployeeLocationController.java
+17
-7
MasterDataController.java
...ava/com/nisum/mytime/controller/MasterDataController.java
+3
-0
OrgLocationController.java
...va/com/nisum/mytime/controller/OrgLocationController.java
+25
-14
ProjectController.java
...n/java/com/nisum/mytime/controller/ProjectController.java
+2
-2
ProjectTeamController.java
...va/com/nisum/mytime/controller/ProjectTeamController.java
+34
-34
ReportsController.java
...n/java/com/nisum/mytime/controller/ReportsController.java
+12
-11
ShiftController.java
...ain/java/com/nisum/mytime/controller/ShiftController.java
+22
-10
SkillController.java
...ain/java/com/nisum/mytime/controller/SkillController.java
+17
-6
UploadXLController.java
.../java/com/nisum/mytime/controller/UploadXLController.java
+33
-0
EmployeeNotFoundException.java
...m/mytime/exception/handler/EmployeeNotFoundException.java
+15
-0
GlobalExceptionHandler.java
...isum/mytime/exception/handler/GlobalExceptionHandler.java
+16
-1
Billing.java
src/main/java/com/nisum/mytime/model/Billing.java
+2
-2
EmpShiftDetails.java
src/main/java/com/nisum/mytime/model/EmpShiftDetails.java
+1
-1
Employee.java
src/main/java/com/nisum/mytime/model/Employee.java
+26
-4
EmployeeLocation.java
src/main/java/com/nisum/mytime/model/EmployeeLocation.java
+13
-9
EmployeeLocationDetails.java
.../java/com/nisum/mytime/model/EmployeeLocationDetails.java
+0
-41
EmployeeRole.java
src/main/java/com/nisum/mytime/model/EmployeeRole.java
+3
-2
OrgLocation.java
src/main/java/com/nisum/mytime/model/OrgLocation.java
+2
-2
Resource.java
src/main/java/com/nisum/mytime/model/Resource.java
+2
-3
AccountInfoRepo.java
...ain/java/com/nisum/mytime/repository/AccountInfoRepo.java
+0
-10
BillingRepo.java
src/main/java/com/nisum/mytime/repository/BillingRepo.java
+20
-0
EmployeeLocationRepo.java
...ava/com/nisum/mytime/repository/EmployeeLocationRepo.java
+14
-0
EmployeeRepo.java
src/main/java/com/nisum/mytime/repository/EmployeeRepo.java
+7
-1
EmployeeRoleRepo.java
...in/java/com/nisum/mytime/repository/EmployeeRoleRepo.java
+14
-0
OrgLocationRepo.java
...ain/java/com/nisum/mytime/repository/OrgLocationRepo.java
+11
-0
ProjectTeamMatesRepo.java
...ava/com/nisum/mytime/repository/ProjectTeamMatesRepo.java
+0
-29
ResourceRepo.java
src/main/java/com/nisum/mytime/repository/ResourceRepo.java
+29
-0
RoleRepo.java
src/main/java/com/nisum/mytime/repository/RoleRepo.java
+1
-1
IAccountService.java
src/main/java/com/nisum/mytime/service/IAccountService.java
+2
-0
IAttendanceService.java
...ain/java/com/nisum/mytime/service/IAttendanceService.java
+14
-4
IBillingService.java
src/main/java/com/nisum/mytime/service/IBillingService.java
+17
-0
IDomainService.java
src/main/java/com/nisum/mytime/service/IDomainService.java
+6
-0
IEmployeeLocationService.java
...va/com/nisum/mytime/service/IEmployeeLocationService.java
+6
-5
IEmployeeRoleService.java
...n/java/com/nisum/mytime/service/IEmployeeRoleService.java
+7
-1
IEmployeeService.java
src/main/java/com/nisum/mytime/service/IEmployeeService.java
+18
-64
IEmployeeShiftService.java
.../java/com/nisum/mytime/service/IEmployeeShiftService.java
+12
-0
IMasterDataService.java
...ain/java/com/nisum/mytime/service/IMasterDataService.java
+3
-0
IOrgLocationService.java
...in/java/com/nisum/mytime/service/IOrgLocationService.java
+4
-2
IProjectService.java
src/main/java/com/nisum/mytime/service/IProjectService.java
+23
-23
IResourceService.java
src/main/java/com/nisum/mytime/service/IResourceService.java
+21
-0
IRoleService.java
src/main/java/com/nisum/mytime/service/IRoleService.java
+4
-1
IUploadXLService.java
src/main/java/com/nisum/mytime/service/IUploadXLService.java
+12
-0
AccountService.java
...in/java/com/nisum/mytime/service/impl/AccountService.java
+25
-16
AttendanceService.java
...java/com/nisum/mytime/service/impl/AttendanceService.java
+31
-7
BillingService.java
...in/java/com/nisum/mytime/service/impl/BillingService.java
+57
-0
DesignationService.java
...ava/com/nisum/mytime/service/impl/DesignationService.java
+1
-0
DomainService.java
...ain/java/com/nisum/mytime/service/impl/DomainService.java
+12
-9
EmployeeLocationService.java
...om/nisum/mytime/service/impl/EmployeeLocationService.java
+57
-27
EmployeeRoleService.java
...va/com/nisum/mytime/service/impl/EmployeeRoleService.java
+24
-17
EmployeeService.java
...n/java/com/nisum/mytime/service/impl/EmployeeService.java
+247
-763
EmployeeShiftService.java
...a/com/nisum/mytime/service/impl/EmployeeShiftService.java
+42
-0
MasterDataService.java
...java/com/nisum/mytime/service/impl/MasterDataService.java
+9
-1
OrgLocationService.java
...ava/com/nisum/mytime/service/impl/OrgLocationService.java
+17
-5
ProjectService.java
...in/java/com/nisum/mytime/service/impl/ProjectService.java
+151
-142
ResourceService.java
...n/java/com/nisum/mytime/service/impl/ResourceService.java
+75
-0
RoleService.java
src/main/java/com/nisum/mytime/service/impl/RoleService.java
+9
-6
ShiftService.java
...main/java/com/nisum/mytime/service/impl/ShiftService.java
+13
-8
SkillService.java
...main/java/com/nisum/mytime/service/impl/SkillService.java
+3
-0
UploadXLService.java
...n/java/com/nisum/mytime/service/impl/UploadXLService.java
+299
-0
DataValidations.java
src/main/java/com/nisum/mytime/utils/DataValidations.java
+20
-14
AttendanceControllerTest.java
...nisum/mytime/controllertest/AttendanceControllerTest.java
+30
-36
EmployeeControllerTest.java
...m/nisum/mytime/controllertest/EmployeeControllerTest.java
+25
-25
No files found.
src/main/java/com/nisum/mytime/controller/AccountController.java
View file @
cf947c85
...
...
@@ -4,6 +4,7 @@ import java.util.ArrayList;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.validation.Valid
;
...
...
@@ -18,6 +19,7 @@ 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
;
...
...
@@ -25,21 +27,22 @@ import com.nisum.mytime.exception.handler.ResponseDetails;
import
com.nisum.mytime.model.Account
;
import
com.nisum.mytime.service.IAccountService
;
import
lombok.extern.slf4j.Slf4j
;
@Slf4j
@RestController
public
class
AccountController
{
@Autowired
private
IAccountService
accountService
;
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
AccountController
.
class
);
@RequestMapping
(
value
=
"/accounts"
,
method
=
RequestMethod
.
POST
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
,
consumes
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<?>
createAccount
(
@Valid
@RequestBody
Account
account
,
HttpServletRequest
request
)
throws
MyTimeException
{
log
ger
.
info
(
"Serving the Account Creation action"
);
log
.
info
(
"Serving the Account Creation action"
);
boolean
isAccountExists
=
accountService
.
isAccountExists
(
account
);
log
ger
.
info
(
"is Account exists with the name "
+
account
.
getAccountName
()
+
":::"
+
isAccountExists
);
log
.
info
(
"is Account exists with the name "
+
account
.
getAccountName
()
+
":::"
+
isAccountExists
);
if
(!
isAccountExists
)
{
Account
accountPersisted
=
accountService
.
createAccount
(
account
);
...
...
@@ -57,7 +60,7 @@ public class AccountController {
@RequestMapping
(
value
=
"/accounts/{accountId}"
,
method
=
RequestMethod
.
PUT
,
consumes
=
MediaType
.
APPLICATION_JSON_VALUE
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<?>
updateAccount
(
@RequestBody
Account
account
,
@PathVariable
String
accountId
,
HttpServletRequest
request
)
throws
MyTimeException
{
log
ger
.
info
(
"Updating the account with details::"
+
account
);
log
.
info
(
"Updating the account with details::"
+
account
);
boolean
isAccountExists
=
accountService
.
isAccountExists
(
account
);
if
(
isAccountExists
==
true
)
{
Account
accountPersisted
=
accountService
.
updateAccount
(
account
);
...
...
@@ -75,10 +78,26 @@ public class AccountController {
}
@RequestMapping
(
value
=
"/accounts/{accountId}"
,
method
=
RequestMethod
.
DELETE
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<?>
deleteAccount
(
@PathVariable
String
accountId
,
HttpServletRequest
request
)
throws
MyTimeException
{
log
.
info
(
"Deleting account with accountId:"
+
accountId
);
Account
accountDeleted
=
accountService
.
deleteAccount
(
accountId
);
ResponseDetails
deleteRespDetails
=
new
ResponseDetails
(
new
Date
(),
604
,
"Account has been deleted successfully"
,
"status description"
,
null
,
request
.
getRequestURI
(),
"details"
,
accountDeleted
);
return
new
ResponseEntity
<
ResponseDetails
>(
deleteRespDetails
,
HttpStatus
.
OK
);
}
@RequestMapping
(
value
=
"/accounts"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<?>
getAccounts
(
HttpServletRequest
request
)
throws
MyTimeException
{
List
<
Map
<
Object
,
Object
>>
accountsList
=
accountService
.
getAccountsList
();
log
ger
.
info
(
"The accounts list::"
+
accountsList
);
log
.
info
(
"The accounts list::"
+
accountsList
);
ResponseDetails
getRespDetails
=
new
ResponseDetails
(
new
Date
(),
604
,
"Retrieved the accounts successfully"
,
"Accounts list"
,
accountsList
,
request
.
getRequestURI
(),
"details"
,
null
);
...
...
@@ -87,6 +106,7 @@ public class AccountController {
}
@RequestMapping
(
value
=
"/accounts/names"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<?>
getAccountNames
(
HttpServletRequest
request
)
throws
MyTimeException
{
List
<
Account
>
acountsList
=
accountService
.
getAccounts
();
...
...
@@ -95,7 +115,7 @@ public class AccountController {
for
(
Account
account
:
acountsList
)
{
accountNamesList
.
add
(
account
.
getAccountName
());
}
log
ger
.
info
(
"The account names list::"
+
accountNamesList
);
log
.
info
(
"The account names list::"
+
accountNamesList
);
ResponseDetails
getRespDetails
=
new
ResponseDetails
(
new
Date
(),
604
,
"Retrieved the account names successfully"
,
"Account names list"
,
accountNamesList
,
...
...
@@ -105,16 +125,13 @@ public class AccountController {
}
@RequestMapping
(
value
=
"/accounts/{accountId}"
,
method
=
RequestMethod
.
DELETE
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<?>
deleteAccount
(
@PathVariable
String
accountId
,
HttpServletRequest
request
)
throws
MyTimeException
{
logger
.
info
(
"Deleting account with accountId:"
+
accountId
);
Account
accountDeleted
=
accountService
.
deleteAccount
(
accountId
);
ResponseDetails
deleteRespDetails
=
new
ResponseDetails
(
new
Date
(),
604
,
"Account has been deleted successfully"
,
"status description"
,
null
,
request
.
getRequestURI
(),
"details"
,
accountDeleted
);
return
new
ResponseEntity
<
ResponseDetails
>(
deleteRespDetails
,
HttpStatus
.
OK
);
//get the accounts based on status(Active or inactive)
@RequestMapping
(
value
=
"/accounts/status"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
List
<
Account
>>
getAccounts
(
@RequestParam
(
"status"
)
String
status
)
throws
MyTimeException
{
List
<
Account
>
accountsList
=
accountService
.
getAccountsAll
().
stream
()
.
filter
(
e
->
"Active"
.
equalsIgnoreCase
(
e
.
getStatus
())).
collect
(
Collectors
.
toList
());
return
new
ResponseEntity
<>(
accountsList
,
HttpStatus
.
OK
);
}
}
\ No newline at end of file
src/main/java/com/nisum/mytime/controller/AttendanceController.java
View file @
cf947c85
...
...
@@ -25,75 +25,55 @@ import com.nisum.mytime.service.IEmployeeService;
@RequestMapping
(
"/attendance"
)
public
class
AttendanceController
{
@Autowired
private
IEmployeeService
userService
;
@Autowired
private
IAttendanceService
attendanceService
;
@RequestMapping
(
value
=
"employeeLoginsBasedOnDate"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
List
<
EmpLoginData
>>
employeeLoginsBasedOnDate
(
@RequestParam
(
"empId"
)
long
id
,
@RequestParam
(
"fromDate"
)
String
fromDate
,
@RequestParam
(
"toDate"
)
String
toDate
)
throws
MyTimeException
{
@RequestMapping
(
value
=
"employeeLoginsBasedOnDate"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
List
<
EmpLoginData
>>
employeeLoginsBasedOnDate
(
@RequestParam
(
"empId"
)
long
id
,
@RequestParam
(
"fromDate"
)
String
fromDate
,
@RequestParam
(
"toDate"
)
String
toDate
)
throws
MyTimeException
{
List
<
EmpLoginData
>
message
=
new
ArrayList
<>();
try
{
message
=
user
Service
.
employeeLoginsBasedOnDate
(
id
,
fromDate
,
toDate
);
message
=
attendance
Service
.
employeeLoginsBasedOnDate
(
id
,
fromDate
,
toDate
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
new
ResponseEntity
<>(
message
,
HttpStatus
.
OK
);
}
@RequestMapping
(
value
=
"generatePdfReport/{id}/{fromDate}/{toDate}"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
@RequestMapping
(
value
=
"generatePdfReport/{id}/{fromDate}/{toDate}"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
List
>
generatePdfReport
(
@PathVariable
(
"id"
)
long
id
,
@PathVariable
(
"fromDate"
)
String
fromDate
,
@PathVariable
(
"toDate"
)
String
toDate
)
throws
MyTimeException
{
List
result
=
userService
.
generatePdfReport
(
id
,
fromDate
,
toDate
);
@PathVariable
(
"fromDate"
)
String
fromDate
,
@PathVariable
(
"toDate"
)
String
toDate
)
throws
MyTimeException
{
List
result
=
attendanceService
.
generatePdfReport
(
id
,
fromDate
,
toDate
);
return
new
ResponseEntity
<>(
result
,
HttpStatus
.
OK
);
}
@RequestMapping
(
value
=
"generatePdfReport/{id}/{fromDate}/{toDate}/{fromTime}/{toTime}"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
@RequestMapping
(
value
=
"generatePdfReport/{id}/{fromDate}/{toDate}/{fromTime}/{toTime}"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
List
>
generatePdfReport
(
@PathVariable
(
"id"
)
long
id
,
@PathVariable
(
"fromDate"
)
String
fromDate
,
@PathVariable
(
"toDate"
)
String
toDate
,
@PathVariable
(
"fromTime"
)
String
fromTime
,
@PathVariable
(
"toTime"
)
String
toTime
)
throws
MyTimeException
,
ParseException
{
List
result
=
userService
.
generatePdfReport
(
id
,
fromDate
,
toDate
,
fromTime
,
toTime
);
@PathVariable
(
"fromDate"
)
String
fromDate
,
@PathVariable
(
"toDate"
)
String
toDate
,
@PathVariable
(
"fromTime"
)
String
fromTime
,
@PathVariable
(
"toTime"
)
String
toTime
)
throws
MyTimeException
,
ParseException
{
List
result
=
attendanceService
.
generatePdfReport
(
id
,
fromDate
,
toDate
,
fromTime
,
toTime
);
return
new
ResponseEntity
<>(
result
,
HttpStatus
.
OK
);
}
@RequestMapping
(
value
=
"attendanciesReport/{reportDate}"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
List
<
AttendenceData
>>
attendanciesReport
(
@PathVariable
(
"reportDate"
)
String
reportDate
,
@RequestParam
(
value
=
"shift"
,
required
=
false
,
defaultValue
=
"All"
)
String
shift
)
@RequestMapping
(
value
=
"attendanciesReport/{reportDate}"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
List
<
AttendenceData
>>
attendanciesReport
(
@PathVariable
(
"reportDate"
)
String
reportDate
,
@RequestParam
(
value
=
"shift"
,
required
=
false
,
defaultValue
=
"All"
)
String
shift
)
throws
MyTimeException
,
SQLException
{
List
<
AttendenceData
>
lisOfAttendenceData
=
attendanceService
.
getAttendanciesReport
(
reportDate
,
shift
);
List
<
AttendenceData
>
lisOfAttendenceData
=
attendanceService
.
getAttendanciesReport
(
reportDate
,
shift
);
return
new
ResponseEntity
<>(
lisOfAttendenceData
,
HttpStatus
.
OK
);
}
@RequestMapping
(
value
=
"employeesDataSave/{searchDate}"
,
method
=
RequestMethod
.
POST
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
Boolean
>
employeesDataSave
(
@PathVariable
(
"searchDate"
)
String
searchDate
)
@RequestMapping
(
value
=
"employeesDataSave/{searchDate}"
,
method
=
RequestMethod
.
POST
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
Boolean
>
employeesDataSave
(
@PathVariable
(
"searchDate"
)
String
searchDate
)
throws
MyTimeException
{
Boolean
result
=
user
Service
.
fetchEmployeesData
(
searchDate
,
false
);
Boolean
result
=
attendance
Service
.
fetchEmployeesData
(
searchDate
,
false
);
return
new
ResponseEntity
<>(
result
,
HttpStatus
.
OK
);
}
@RequestMapping
(
value
=
"resyncMonthData/{fromDate}"
,
method
=
RequestMethod
.
POST
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
Boolean
>
resyncMonthData
(
@PathVariable
(
"fromDate"
)
String
fromDate
)
throws
MyTimeException
{
Boolean
result
=
userService
.
fetchEmployeesData
(
fromDate
,
true
);
@RequestMapping
(
value
=
"resyncMonthData/{fromDate}"
,
method
=
RequestMethod
.
POST
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
Boolean
>
resyncMonthData
(
@PathVariable
(
"fromDate"
)
String
fromDate
)
throws
MyTimeException
{
Boolean
result
=
attendanceService
.
fetchEmployeesData
(
fromDate
,
true
);
return
new
ResponseEntity
<>(
result
,
HttpStatus
.
OK
);
}
...
...
src/main/java/com/nisum/mytime/controller/DesignationController.java
View file @
cf947c85
package
com
.
nisum
.
mytime
.
controller
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.stream.Collectors
;
import
javax.servlet.http.HttpServletRequest
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.MediaType
;
...
...
@@ -12,23 +15,27 @@ import org.springframework.web.bind.annotation.RequestMethod;
import
org.springframework.web.bind.annotation.RestController
;
import
com.nisum.mytime.exception.handler.MyTimeException
;
import
com.nisum.mytime.exception.handler.ResponseDetails
;
import
com.nisum.mytime.model.Designation
;
import
com.nisum.mytime.service.IDesignationService
;
import
com.nisum.mytime.service.impl.DesignationService
;
@RestController
public
class
DesignationController
{
@Autowired
DesignationService
designationService
;
I
DesignationService
designationService
;
// @RequestMapping(value = "/getAllDesignations", method =
// RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
// @RequestMapping(value = "/getAllDesignations"
@RequestMapping
(
value
=
"/employees/designations/"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
List
<
String
>>
getAllDesignations
(
)
throws
MyTimeException
{
public
ResponseEntity
<
?>
getAllDesignations
(
HttpServletRequest
request
)
throws
MyTimeException
{
List
<
String
>
designations
=
designationService
.
getAllDesignations
().
stream
()
.
filter
(
e
->
"Y"
.
equalsIgnoreCase
(
e
.
getActiveStatus
())).
map
(
Designation:
:
getDesignationName
).
sorted
()
.
collect
(
Collectors
.
toList
());
return
new
ResponseEntity
<>(
designations
,
HttpStatus
.
OK
);
ResponseDetails
getRespDetails
=
new
ResponseDetails
(
new
Date
(),
908
,
"Retrieved Designations successfully"
,
"Designations list"
,
designations
,
request
.
getRequestURI
(),
"Employee Designation Details"
,
null
);
return
new
ResponseEntity
<>(
getRespDetails
,
HttpStatus
.
OK
);
}
}
src/main/java/com/nisum/mytime/controller/DomainController.java
View file @
cf947c85
...
...
@@ -3,6 +3,7 @@ package com.nisum.mytime.controller;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.stream.Collectors
;
import
javax.servlet.http.HttpServletRequest
;
...
...
@@ -29,23 +30,24 @@ import com.nisum.mytime.service.IDomainService;
import
com.nisum.mytime.utils.MyTimeUtils
;
import
lombok.extern.slf4j.Slf4j
;
/**
* @author Vijay
*
*/
@RestController
@Slf4j
public
class
DomainController
{
@Autowired
private
IDomainService
domainService
;
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
DomainController
.
class
);
@RequestMapping
(
value
=
"/domains"
,
method
=
RequestMethod
.
POST
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
,
consumes
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<?>
createDomain
(
@RequestBody
Domain
domain
,
HttpServletRequest
request
)
throws
MyTimeException
{
log
ger
.
info
(
"Domain Creation"
);
log
.
info
(
"Domain Creation"
);
if
(!
domainService
.
isDomainExists
(
domain
))
{
Domain
domainPeristed
=
domainService
.
create
(
domain
);
...
...
@@ -54,7 +56,7 @@ public class DomainController {
"Domain Creation"
,
null
,
""
,
"details"
,
domainPeristed
);
return
new
ResponseEntity
<
ResponseDetails
>(
createRespDetails
,
HttpStatus
.
OK
);
}
log
ger
.
info
(
"A domain is already existed with the requested name"
+
domain
.
getDomainName
());
log
.
info
(
"A domain is already existed with the requested name"
+
domain
.
getDomainName
());
ResponseDetails
responseDetails
=
new
ResponseDetails
(
new
Date
(),
802
,
"Domain is already existed"
,
"Choose the different domain name"
,
null
,
request
.
getRequestURI
(),
"Domain details"
,
domain
);
...
...
@@ -102,4 +104,13 @@ public class DomainController {
}
//getting domains list under accountId which is an active.
@RequestMapping
(
value
=
"/domains/{accountId}"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
List
<
Domain
>>
getDomains
(
@PathVariable
(
"accountId"
)
String
accountId
)
throws
MyTimeException
{
List
<
Domain
>
domains
=
domainService
.
getDomainsUnderAccount
(
accountId
).
stream
()
.
filter
(
e
->
"Active"
.
equalsIgnoreCase
(
e
.
getStatus
())).
collect
(
Collectors
.
toList
());
return
new
ResponseEntity
<>(
domains
,
HttpStatus
.
OK
);
}
}
\ No newline at end of file
src/main/java/com/nisum/mytime/controller/EmployeeController.java
View file @
cf947c85
package
com
.
nisum
.
mytime
.
controller
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.stream.Collectors
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.validation.Valid
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.MediaType
;
...
...
@@ -16,20 +18,16 @@ 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.exception.handler.ResponseDetails
;
import
com.nisum.mytime.model.Account
;
import
com.nisum.mytime.model.AccountInfo
;
import
com.nisum.mytime.model.Domain
;
import
com.nisum.mytime.model.Employee
;
import
com.nisum.mytime.service.IEmployeeRoleService
;
import
com.nisum.mytime.service.IEmployeeService
;
import
com.nisum.mytime.service.IRoleMappingService
;
import
lombok.extern.slf4j.Slf4j
;
@RestController
@Slf4j
public
class
EmployeeController
{
...
...
@@ -37,141 +35,158 @@ public class EmployeeController {
private
IEmployeeService
empService
;
@Autowired
private
I
RoleMappingService
roleMapping
Service
;
private
I
EmployeeRoleService
employeeRole
Service
;
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
EmployeeController
.
class
);
@RequestMapping
(
value
=
"/employees/{empId}"
,
method
=
RequestMethod
.
POST
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
,
consumes
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<?>
createEmployee
(
@Valid
@RequestBody
Employee
employeeReq
,
@PathVariable
(
value
=
"empId"
)
String
loginEmpId
,
HttpServletRequest
request
)
throws
MyTimeException
{
if
(!
empService
.
isEmployeeExistsById
(
loginEmpId
))
{
Employee
employeePersisted
=
empService
.
createEmployee
(
employeeReq
,
loginEmpId
);
ResponseDetails
createRespDetails
=
new
ResponseDetails
(
new
Date
(),
901
,
"Employee has been created"
,
"Employee Creation"
,
null
,
request
.
getContextPath
(),
"Employee Creation Details"
,
employeePersisted
);
return
new
ResponseEntity
<
ResponseDetails
>(
createRespDetails
,
HttpStatus
.
OK
);
@RequestMapping
(
value
=
"/employees"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
Employee
>
getEmployee
(
@RequestParam
(
"emailId"
)
String
emailId
)
throws
MyTimeException
{
Employee
employee
=
empService
.
getEmployeeByEmaillId
(
emailId
);
if
(
employee
!=
null
)
{
if
(
employee
.
getRole
()
!=
null
&&
employee
.
getRole
().
equalsIgnoreCase
(
"Admin"
))
{
employee
.
setRole
(
"Admin"
);
}
else
{
String
roleName
=
roleMappingService
.
getEmployeeRole
(
employee
.
getEmployeeId
());
if
(
roleName
!=
null
)
{
employee
.
setRole
(
roleName
);
}
}
}
System
.
out
.
println
(
"emailId"
+
emailId
+
"result"
+
employee
);
return
new
ResponseEntity
<>(
employee
,
HttpStatus
.
OK
);
}
ResponseDetails
createRespDetails
=
new
ResponseDetails
(
new
Date
(),
907
,
"An Employee is already existed by the Id"
,
"Choose the different employee Id"
,
null
,
request
.
getRequestURI
(),
"Employee details"
,
loginEmpId
);
return
new
ResponseEntity
<
ResponseDetails
>(
createRespDetails
,
HttpStatus
.
OK
);
@RequestMapping
(
value
=
"/employees/{empId}"
,
method
=
RequestMethod
.
POST
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
,
consumes
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
Employee
>
createEmployee
(
@RequestBody
Employee
employeeReq
,
@PathVariable
(
value
=
"empId"
)
String
loginEmpId
)
throws
MyTimeException
{
Employee
employeePersisted
=
empService
.
createEmployee
(
employeeReq
,
loginEmpId
);
return
new
ResponseEntity
<>(
employeePersisted
,
HttpStatus
.
OK
);
}
@RequestMapping
(
value
=
"/employees/{empId}"
,
method
=
RequestMethod
.
PUT
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
,
consumes
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
Employee
>
updateEmployee
(
@RequestBody
Employee
employeeRoles
,
@PathVariable
(
value
=
"empId"
)
String
loginEmpId
)
throws
MyTimeException
{
Employee
employeeRole
=
empService
.
updateEmployeeRole
(
employeeRoles
,
loginEmpId
);
return
new
ResponseEntity
<>(
employeeRole
,
HttpStatus
.
OK
);
public
ResponseEntity
<?>
updateEmployee
(
@RequestBody
Employee
employeeReq
,
@PathVariable
(
value
=
"empId"
)
String
loginEmpId
,
HttpServletRequest
request
)
throws
MyTimeException
{
if
(
empService
.
isEmployeeExistsById
(
loginEmpId
))
{
Employee
employeeUpdated
=
empService
.
updateEmployee
(
employeeReq
,
loginEmpId
);
ResponseDetails
updateRespDetails
=
new
ResponseDetails
(
new
Date
(),
906
,
"Employee has been updated"
,
"Employee Updation"
,
null
,
request
.
getRequestURI
(),
"Updation Employee details"
,
employeeUpdated
);
return
new
ResponseEntity
<
ResponseDetails
>(
updateRespDetails
,
HttpStatus
.
OK
);
}
ResponseDetails
updateRespDetails
=
new
ResponseDetails
(
new
Date
(),
907
,
"Employee is Not found"
,
"Choose the correct Employee Id"
,
null
,
request
.
getRequestURI
(),
"Employee Updation details"
,
loginEmpId
);
return
new
ResponseEntity
<
ResponseDetails
>(
updateRespDetails
,
HttpStatus
.
NOT_FOUND
);
}
@RequestMapping
(
value
=
"/employees/{empId}"
,
method
=
RequestMethod
.
DELETE
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
String
>
deleteEmployee
(
@PathVariable
(
"empId"
)
String
empId
)
throws
MyTimeException
{
public
ResponseEntity
<?>
deleteEmployee
(
@PathVariable
(
"empId"
)
String
empId
,
HttpServletRequest
request
)
throws
MyTimeException
{
if
(
empService
.
isEmployeeExistsById
(
empId
))
{
empService
.
deleteEmployee
(
empId
);
return
new
ResponseEntity
<>(
"Success"
,
HttpStatus
.
OK
);
}
//@RequestMapping(value = "/getUserRoles", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
@RequestMapping
(
value
=
"/employees/active"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
List
<
Employee
>>
getUserRoles
()
throws
MyTimeException
{
List
<
Employee
>
employeesRoles
=
empService
.
getActiveEmployees
();
return
new
ResponseEntity
<>(
employeesRoles
,
HttpStatus
.
OK
);
ResponseDetails
deleteRespDetails
=
new
ResponseDetails
(
new
Date
(),
908
,
"Employee status is deActivated"
,
"Employee Deletion"
,
null
,
request
.
getRequestURI
(),
"Employee Deletion details"
,
empId
);
return
new
ResponseEntity
<
ResponseDetails
>(
deleteRespDetails
,
HttpStatus
.
OK
);
}
ResponseDetails
deleteRespDetails
=
new
ResponseDetails
(
new
Date
(),
907
,
"Employee is Not found"
,
"Choose correct Employee Id"
,
null
,
request
.
getRequestURI
(),
"Employee Updation details"
,
empId
);
return
new
ResponseEntity
<
ResponseDetails
>(
deleteRespDetails
,
HttpStatus
.
NOT_FOUND
);
}
//@RequestMapping(value = "/getEmployeeRoleData", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
@RequestMapping
(
value
=
"/employees/{empId}"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
Employee
>
getEmployeeRoleData
(
@PathVariable
(
"empId"
)
String
empId
)
throws
MyTimeException
{
Employee
employeesRole
=
empService
.
getEmployeesRoleData
(
empId
);
return
new
ResponseEntity
<>(
employeesRole
,
HttpStatus
.
OK
);
@RequestMapping
(
value
=
"/employees/updateProfile"
,
method
=
RequestMethod
.
POST
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
,
consumes
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
Employee
>
updateProfile
(
@RequestBody
Employee
employee
)
throws
MyTimeException
{
Employee
employeeUpdated
=
empService
.
updateProfile
(
employee
);
return
new
ResponseEntity
<>(
employeeUpdated
,
HttpStatus
.
OK
);
}
/*
@RequestMapping(value = "/getEmployeeLocations", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<EmployeeLocationDetails>> getEmployeeLocations(@RequestParam("employeeId") String empId)
// @RequestMapping(value = "/getEmployeeRoleData"
@RequestMapping
(
value
=
"/employees/employeeId/{empId}"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<?>
getEmployeeById
(
@PathVariable
(
"empId"
)
String
empId
,
HttpServletRequest
request
)
throws
MyTimeException
{
List<EmployeeLocationDetails> employeeLocationDetails = empService.getEmployeeLocationDetails(empId);
return new ResponseEntity<>(employeeLocationDetails, HttpStatus.OK);
}
*/
Employee
employee
=
empService
.
getEmployeeById
(
empId
);
ResponseDetails
getRespDetails
=
new
ResponseDetails
(
new
Date
(),
904
,
"Retrieved Employee successfully"
,
"Employee"
,
employee
,
request
.
getRequestURI
(),
"Employee Details"
,
null
);
// @RequestMapping(value = "/getManagers"
@RequestMapping
(
value
=
"/employees/managers/"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
List
<
Employee
>>
getManagers
()
throws
MyTimeException
{
List
<
Employee
>
managersList
=
empService
.
getManagers
();
return
new
ResponseEntity
<>(
managersList
,
HttpStatus
.
OK
);
return
new
ResponseEntity
<
ResponseDetails
>(
getRespDetails
,
HttpStatus
.
OK
);
}
/*
// @RequestMapping(value = "/getAllShifts", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
@RequestMapping(value = "/employees/shifts/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<String>> getAllShifts() throws MyTimeException {
List<String> shifts = empService.getAllShifts().stream().filter(e -> "Y".equalsIgnoreCase(e.getActiveStatus()))
.map(Shift::getShiftName).sorted().collect(Collectors.toList());
return new ResponseEntity<>(shifts, HttpStatus.OK);
@RequestMapping
(
value
=
"/employees/emailId/{emailId:.+}"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<?>
getEmployee
(
@PathVariable
(
"emailId"
)
String
emailId
,
HttpServletRequest
request
)
throws
MyTimeException
{
Employee
employee
=
empService
.
getEmployeeByEmaillId
(
emailId
);
if
(
employee
==
null
)
{
ResponseDetails
errorDetails
=
new
ResponseDetails
(
new
Date
(),
902
,
"The Employee you are looking for is not found"
,
"Employee List"
,
emailId
,
request
.
getContextPath
(),
"Employee Details"
,
null
);
return
new
ResponseEntity
<
Object
>(
errorDetails
,
HttpStatus
.
NOT_FOUND
);
}
else
{
if
(
employee
.
getRole
()
!=
null
&&
employee
.
getRole
().
equalsIgnoreCase
(
"Admin"
))
{
employee
.
setRole
(
"Admin"
);
}
else
{
String
roleName
=
employeeRoleService
.
getEmployeeRole
(
employee
.
getEmployeeId
());
if
(
roleName
!=
null
)
{
employee
.
setRole
(
roleName
);
}
}
*/
/*
// @RequestMapping(value = "/getAllDesignations", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
@RequestMapping(value = "/employees/designations/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<String>> getAllDesignations() throws MyTimeException {
List<String> designations = empService.getAllDesignations().stream()
.filter(e -> "Y".equalsIgnoreCase(e.getActiveStatus())).map(Designation::getDesignationName).sorted()
.collect(Collectors.toList());
return new ResponseEntity<>(designations, HttpStatus.OK);
}
*/
log
.
info
(
"emailId"
+
emailId
+
"result"
+
employee
);
/*
// @RequestMapping(value = "/getSkills", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
@RequestMapping(value = "/employees/skills/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<String>> getTechnologies() throws MyTimeException {
List<String> technologies = empService.getTechnologies().stream()
.filter(e -> "Y".equalsIgnoreCase(e.getActiveStatus())).map(Skill::getSkillName).sorted()
.collect(Collectors.toList());
return new ResponseEntity<>(technologies, HttpStatus.OK);
ResponseDetails
getRespDetails
=
new
ResponseDetails
(
new
Date
(),
904
,
"Retrieved Employee successfully"
,
"Employee list"
,
employee
,
request
.
getRequestURI
(),
"Employee Details"
,
null
);
return
new
ResponseEntity
<
ResponseDetails
>(
getRespDetails
,
HttpStatus
.
OK
);
}
*/
/*
//@RequestMapping(value = "/getLocations", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
@RequestMapping(value = "/employees/locations/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<String>> getLocations() throws MyTimeException {
System.out.println(" userService.getLocations()" + empService.getLocations());
List<String> locations = empService.getLocations().stream().filter(e -> (e.isActiveStatus() == true))
.map(Location::getLocation).sorted().collect(Collectors.toList());
logger.info("getLocations " + locations);
return new ResponseEntity<>(locations, HttpStatus.OK);
// @RequestMapping(value = "/getManagers"
@RequestMapping
(
value
=
"/employees/managers/"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<?>
getManagers
(
HttpServletRequest
request
)
throws
MyTimeException
{
ResponseDetails
getRespDetails
=
new
ResponseDetails
(
new
Date
(),
905
,
"Retrieved Managers successfully"
,
"Managers list"
,
empService
.
getManagers
(),
request
.
getRequestURI
(),
"Managers Details"
,
null
);
return
new
ResponseEntity
<
ResponseDetails
>(
getRespDetails
,
HttpStatus
.
OK
);
}
*/
@RequestMapping
(
value
=
"/updateProfile"
,
method
=
RequestMethod
.
POST
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
,
consumes
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
Employee
>
updateProfile
(
@RequestBody
Employee
employeeRoles
)
throws
MyTimeException
{
Employee
employeeRole
=
empService
.
updateProfile
(
employeeRoles
);
return
new
ResponseEntity
<>(
employeeRole
,
HttpStatus
.
OK
);
// @RequestMapping(value = "/getUserRoles"
@RequestMapping
(
value
=
"/employees/active"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<?>
getActiveEmployees
(
HttpServletRequest
request
)
throws
MyTimeException
{
ResponseDetails
getRespDetails
=
new
ResponseDetails
(
new
Date
(),
905
,
"Retrieved Active Employees successfully"
,
"Active Employees list"
,
empService
.
getActiveEmployees
(),
request
.
getRequestURI
(),
"Active Employees Details"
,
null
);
return
new
ResponseEntity
<
ResponseDetails
>(
getRespDetails
,
HttpStatus
.
OK
);
}
//@RequestMapping(value = "/getAccounts", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
@RequestMapping
(
value
=
"/employee/accounts/"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
List
<
Account
>>
getAccounts
()
throws
MyTimeException
{
List
<
Account
>
technologies
=
empService
.
getAccounts
().
stream
().
filter
(
e
->
"Y"
.
equalsIgnoreCase
(
e
.
getStatus
()))
// @RequestMapping(value = "/getAccounts"
@RequestMapping
(
value
=
"/employees/accounts/"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<?>
getAccounts
(
HttpServletRequest
request
)
throws
MyTimeException
{
List
<
Account
>
activeAccountList
=
empService
.
getAccounts
().
stream
()
.
filter
(
e
->
"Y"
.
equalsIgnoreCase
(
e
.
getStatus
()))
// .filter(a -> !("Nisum
// India".equalsIgnoreCase(a.getAccountName())))
// .map(Account::getAccountName).sorted()
.
collect
(
Collectors
.
toList
());
return
new
ResponseEntity
<>(
technologies
,
HttpStatus
.
OK
);
ResponseDetails
getRespDetails
=
new
ResponseDetails
(
new
Date
(),
905
,
"Retrieved Accounts successfully"
,
"Accounts list"
,
activeAccountList
,
request
.
getRequestURI
(),
"Account Details"
,
null
);
return
new
ResponseEntity
<
ResponseDetails
>(
getRespDetails
,
HttpStatus
.
OK
);
}
// @RequestMapping(value = "/getEmployeeByStatus
@RequestMapping
(
value
=
"/employees/"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<?>
getEmployeeByStatus
(
@RequestParam
(
"status"
)
String
status
,
HttpServletRequest
request
)
{
List
<
Employee
>
employeeList
=
empService
.
getEmployeesByStatus
(
status
);
ResponseDetails
getRespDetails
=
new
ResponseDetails
(
new
Date
(),
905
,
"Retrieved Employees successfully"
,
"Employees list by status"
,
employeeList
,
request
.
getRequestURI
(),
"Employee Details: Status"
,
null
);
return
new
ResponseEntity
<
ResponseDetails
>(
getRespDetails
,
HttpStatus
.
OK
);
}
@RequestMapping
(
value
=
"/getEmployeeRoleDataForSearchCriteria"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
...
...
@@ -187,59 +202,16 @@ public class EmployeeController {
return
new
ResponseEntity
<>(
details
,
HttpStatus
.
OK
);
}
/*@RequestMapping(value = "/getMasterData", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, List<String>>> getMasterData() throws MyTimeException {
Map<String, List<String>> masterDataMap = new HashMap<>();
Map<String, List<MasterData>> result = empService.getMasterData().stream()
.filter(e -> (e.isActiveStatus() == true))
.collect(Collectors.groupingBy(MasterData::getMasterDataType));
for (String key : result.keySet()) {
List<MasterData> valueList = result.get(key);
List<String> technologies = valueList.stream().map(MasterData::getMasterDataName).sorted()
.collect(Collectors.toList());
masterDataMap.put(key, technologies);
}
return new ResponseEntity<>(masterDataMap, HttpStatus.OK);
}
*/
//@RequestMapping(value = "/getEmployeeByStatus", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
@RequestMapping
(
value
=
"/employees/status/"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
List
<
Employee
>>
getEmployeeByStatus
(
@RequestParam
(
"status"
)
String
status
)
{
List
<
Employee
>
employeesRoles
=
empService
.
getEmployeesByStatus
(
status
);
return
new
ResponseEntity
<>(
employeesRoles
,
HttpStatus
.
OK
);
}
//@RequestMapping(value = "/getDeliveryLeads", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
// @RequestMapping(value = "/getDeliveryLeads",
@RequestMapping
(
value
=
"/employees/deliveryLeads/{domainId}"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
List
<
HashMap
<
String
,
String
>>>
getDeliveryLeads
(
@PathVariable
(
"domainId"
)
String
domainId
)
public
ResponseEntity
<
?>
getDeliveryLeads
(
@PathVariable
(
"domainId"
)
String
domainId
,
HttpServletRequest
request
)
throws
MyTimeException
{
List
<
HashMap
<
String
,
String
>>
managers
=
empService
.
getDeliveryLeads
(
domainId
);
return
new
ResponseEntity
<>(
managers
,
HttpStatus
.
OK
);
}
@RequestMapping
(
value
=
"/getAccountsInfo"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
List
<
AccountInfo
>>
getAccountsInfo
()
throws
MyTimeException
{
List
<
AccountInfo
>
technologies
=
empService
.
getAccountsInfo
().
stream
()
.
filter
(
e
->
"Active"
.
equalsIgnoreCase
(
e
.
getStatus
())).
collect
(
Collectors
.
toList
());
return
new
ResponseEntity
<>(
technologies
,
HttpStatus
.
OK
);
}
List
<
HashMap
<
String
,
String
>>
managersList
=
empService
.
getDeliveryLeads
(
domainId
);
@RequestMapping
(
value
=
"/getDomains"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
List
<
Domain
>>
getDomains
(
@RequestParam
(
"accountId"
)
String
accountId
)
throws
MyTimeException
{
List
<
Domain
>
domains
=
empService
.
getDomains
(
accountId
).
stream
()
.
filter
(
e
->
"Active"
.
equalsIgnoreCase
(
e
.
getStatus
())).
collect
(
Collectors
.
toList
());
return
new
ResponseEntity
<>(
domains
,
HttpStatus
.
OK
);
}
ResponseDetails
getRespDetails
=
new
ResponseDetails
(
new
Date
(),
905
,
"Retrieved Delivery Leads successfully"
,
"Delivery Leads list"
,
managersList
,
request
.
getRequestURI
(),
"Delivery Leads Details"
,
null
);
return
new
ResponseEntity
<
ResponseDetails
>(
getRespDetails
,
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
=
empService
.
importDataFromExcelFile
(
file
,
loginEmpId
);
return
new
ResponseEntity
<>(
result
,
HttpStatus
.
OK
);
}
}
\ No newline at end of file
src/main/java/com/nisum/mytime/controller/EmployeeLocationController.java
View file @
cf947c85
package
com
.
nisum
.
mytime
.
controller
;
import
java.util.Date
;
import
java.util.List
;
import
javax.servlet.http.HttpServletRequest
;
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.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.EmployeeLocationDetails
;
import
com.nisum.mytime.exception.handler.ResponseDetails
;
import
com.nisum.mytime.model.EmployeeLocation
;
import
com.nisum.mytime.service.IEmployeeLocationService
;
import
com.nisum.mytime.service.impl.EmployeeLocationService
;
@RestController
public
class
EmployeeLocationController
{
@Autowired
EmployeeLocationService
empLocationService
;
I
EmployeeLocationService
empLocationService
;
@RequestMapping
(
value
=
"/
getEmployeeLocations
"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
List
<
EmployeeLocationDetails
>>
getEmployeeLocations
(
@RequestParam
(
"employeeId"
)
String
empId
)
@RequestMapping
(
value
=
"/
employees/locations/{employeeId}
"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
?>
getEmployeeLocations
(
@PathVariable
(
"employeeId"
)
String
empId
,
HttpServletRequest
request
)
throws
MyTimeException
{
List
<
EmployeeLocationDetails
>
employeeLocationDetails
=
empLocationService
.
getEmployeeLocationDetails
(
empId
);
return
new
ResponseEntity
<>(
employeeLocationDetails
,
HttpStatus
.
OK
);
List
<
EmployeeLocation
>
employeeLocationDetails
=
empLocationService
.
getEmployeeLocations
(
empId
);
ResponseDetails
getRespDetails
=
new
ResponseDetails
(
new
Date
(),
701
,
"Retrieved Employee Locations successfylly"
,
"Employee Locations"
,
employeeLocationDetails
,
request
.
getRequestURI
(),
"Employee Location Details"
,
null
);
return
new
ResponseEntity
<>(
getRespDetails
,
HttpStatus
.
OK
);
}
}
src/main/java/com/nisum/mytime/controller/MasterDataController.java
View file @
cf947c85
...
...
@@ -17,7 +17,10 @@ import com.nisum.mytime.exception.handler.MyTimeException;
import
com.nisum.mytime.model.MasterData
;
import
com.nisum.mytime.service.IMasterDataService
;
import
lombok.extern.slf4j.Slf4j
;
@RestController
@Slf4j
public
class
MasterDataController
{
@Autowired
...
...
src/main/java/com/nisum/mytime/controller/OrgLocationController.java
View file @
cf947c85
package
com
.
nisum
.
mytime
.
controller
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.stream.Collectors
;
import
javax.servlet.http.HttpServletRequest
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -14,26 +17,34 @@ import org.springframework.web.bind.annotation.RequestMethod;
import
org.springframework.web.bind.annotation.RestController
;
import
com.nisum.mytime.exception.handler.MyTimeException
;
import
com.nisum.mytime.model.Location
;
import
com.nisum.mytime.exception.handler.ResponseDetails
;
import
com.nisum.mytime.model.OrgLocation
;
import
com.nisum.mytime.service.IOrgLocationService
;
import
com.nisum.mytime.service.impl.OrgLocationService
;
import
lombok.extern.slf4j.Slf4j
;
@RestController
@Slf4j
public
class
OrgLocationController
{
@Autowired
OrgLocationService
orgLocationService
;
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
OrgLocationController
.
class
);
// @RequestMapping(value = "/getLocations", method = RequestMethod.GET,
// produces = MediaType.APPLICATION_JSON_VALUE)
@RequestMapping
(
value
=
"/employees/locations/"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
List
<
String
>>
getLocations
()
throws
MyTimeException
{
// System.out.println(" userService.getLocations()" +
// orgLocationService.getLocations());
List
<
String
>
locations
=
orgLocationService
.
getLocations
().
stream
().
filter
(
e
->
(
e
.
isActiveStatus
()
==
true
))
.
map
(
Location:
:
getLocation
).
sorted
().
collect
(
Collectors
.
toList
());
logger
.
info
(
"getLocations "
+
locations
);
return
new
ResponseEntity
<>(
locations
,
HttpStatus
.
OK
);
IOrgLocationService
orgLocationService
;
// @RequestMapping(value = "/getLocations"
@RequestMapping
(
value
=
"/organization/locations/"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<?>
getLocations
(
HttpServletRequest
request
)
throws
MyTimeException
{
List
<
String
>
locationsList
=
orgLocationService
.
getLocations
().
stream
()
.
filter
(
e
->
(
e
.
isActiveStatus
()
==
true
)).
map
(
OrgLocation:
:
getLocation
).
sorted
()
.
collect
(
Collectors
.
toList
());
log
.
info
(
"getLocations "
+
locationsList
);
ResponseDetails
getRespDetails
=
new
ResponseDetails
(
new
Date
(),
905
,
"Retrieved Organization Locations successfully"
,
"Organization Locations List"
,
locationsList
,
request
.
getRequestURI
(),
"Organization Location Details"
,
null
);
return
new
ResponseEntity
<>(
getRespDetails
,
HttpStatus
.
OK
);
}
}
src/main/java/com/nisum/mytime/controller/ProjectController.java
View file @
cf947c85
...
...
@@ -113,7 +113,7 @@ public class ProjectController {
List
<
HashMap
<
Object
,
Object
>>
projects
=
null
;
if
(!
"undefined"
.
equalsIgnoreCase
(
empId
)
)
{
boolean
isDl
=
userService
.
verifyRole
(
empId
,
MyTimeUtils
.
DL
)
;
boolean
isDl
=
userService
.
verify
Employee
Role
(
empId
,
MyTimeUtils
.
DL
)
;
if
(
isDl
){
projects
=
projectService
.
deliveryLeadProjects
(
empId
);
}
...
...
@@ -126,7 +126,7 @@ public class ProjectController {
@RequestMapping
(
value
=
"/getEmployeeRoleData"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
Employee
>
getEmployeeRoleData
(
@RequestParam
(
"empId"
)
String
empId
)
throws
MyTimeException
{
Employee
employeesRole
=
userService
.
getEmployee
sRoleData
(
empId
);
Employee
employeesRole
=
userService
.
getEmployee
ById
(
empId
);
return
new
ResponseEntity
<>(
employeesRole
,
HttpStatus
.
OK
);
}
...
...
src/main/java/com/nisum/mytime/controller/ProjectTeamController.java
View file @
cf947c85
...
...
@@ -16,12 +16,12 @@ 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
Details
;
import
com.nisum.mytime.model.Billing
;
import
com.nisum.mytime.model.EmployeeDashboardVO
;
import
com.nisum.mytime.model.Employee
;
import
com.nisum.mytime.model.EmployeeVisa
;
import
com.nisum.mytime.model.Project
;
import
com.nisum.mytime.model.
ProjectTeamMat
e
;
import
com.nisum.mytime.model.
Resourc
e
;
import
com.nisum.mytime.repository.EmployeeVisaRepo
;
import
com.nisum.mytime.service.IProjectService
;
import
com.nisum.mytime.service.IEmployeeService
;
...
...
@@ -62,7 +62,7 @@ public class ProjectTeamController {
consumes
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
Employee
>
updateEmployeeRole
(
@RequestBody
Employee
emp
,
@RequestParam
(
value
=
"empId"
)
String
loginEmpId
)
throws
MyTimeException
{
Employee
employeeRole
=
userService
.
updateEmployee
Role
(
emp
,
loginEmpId
);
Employee
employeeRole
=
userService
.
updateEmployee
(
emp
,
loginEmpId
);
return
new
ResponseEntity
<>(
employeeRole
,
HttpStatus
.
OK
);
}
...
...
@@ -78,16 +78,16 @@ public class ProjectTeamController {
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
Employee
>
getEmployeeRoleData
(
@RequestParam
(
"empId"
)
String
empId
)
throws
MyTimeException
{
Employee
employeesRole
=
userService
.
getEmployee
sRoleData
(
empId
);
Employee
employeesRole
=
userService
.
getEmployee
ById
(
empId
);
return
new
ResponseEntity
<>(
employeesRole
,
HttpStatus
.
OK
);
}
//MT-72
@RequestMapping
(
value
=
"/getEmployeeProjectInfo"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
List
<
ProjectTeamMat
e
>>
getEmployeeProjectInfo
(
public
ResponseEntity
<
List
<
Resourc
e
>>
getEmployeeProjectInfo
(
@RequestParam
(
"empId"
)
String
empId
)
throws
MyTimeException
{
List
<
ProjectTeamMat
e
>
projectInfo
=
projectService
.
getProjectInfo
(
empId
);
List
<
Resourc
e
>
projectInfo
=
projectService
.
getProjectInfo
(
empId
);
return
new
ResponseEntity
<>(
projectInfo
,
HttpStatus
.
OK
);
}
...
...
@@ -109,10 +109,10 @@ public class ProjectTeamController {
@RequestMapping
(
value
=
"/getTeamDetails"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
List
<
ProjectTeamMat
e
>>
getTeamDetails
(
public
ResponseEntity
<
List
<
Resourc
e
>>
getTeamDetails
(
@RequestParam
(
"employeeId"
)
String
employeeId
)
throws
MyTimeException
{
List
<
ProjectTeamMat
e
>
employeesRoles
=
projectService
List
<
Resourc
e
>
employeesRoles
=
projectService
.
getTeamDetails
(
employeeId
);
return
new
ResponseEntity
<>(
employeesRoles
,
HttpStatus
.
OK
);
}
...
...
@@ -120,18 +120,18 @@ public class ProjectTeamController {
@RequestMapping
(
value
=
"/addEmployeeToTeam"
,
method
=
RequestMethod
.
POST
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
,
consumes
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
ProjectTeamMat
e
>
addEmployeeToTeam
(
@RequestBody
ProjectTeamMat
e
teamMate
,
@RequestParam
(
value
=
"loginEmpId"
,
required
=
false
)
String
loginEmpId
)
throws
MyTimeException
{
public
ResponseEntity
<
Resourc
e
>
addEmployeeToTeam
(
@RequestBody
Resourc
e
teamMate
,
@RequestParam
(
value
=
"loginEmpId"
,
required
=
false
)
String
loginEmpId
)
throws
MyTimeException
{
teamMate
.
setActive
(
true
);
teamMate
.
setAuditFields
(
loginEmpId
,
MyTimeUtils
.
CREATE
);
ProjectTeamMat
e
teamMateDB
=
projectService
.
addProjectTeamMate
(
teamMate
,
loginEmpId
);
Resourc
e
teamMateDB
=
projectService
.
addProjectTeamMate
(
teamMate
,
loginEmpId
);
return
new
ResponseEntity
<>(
teamMateDB
,
HttpStatus
.
OK
);
}
@RequestMapping
(
value
=
"/updateTeammate"
,
method
=
RequestMethod
.
POST
,
produces
=
MediaType
.
TEXT_PLAIN_VALUE
,
consumes
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
String
>
updateTeammate
(
@RequestBody
ProjectTeamMat
e
projectTeamMate
,
@RequestParam
(
value
=
"loginEmpId"
)
String
loginEmpId
)
public
ResponseEntity
<
String
>
updateTeammate
(
@RequestBody
Resourc
e
projectTeamMate
,
@RequestParam
(
value
=
"loginEmpId"
)
String
loginEmpId
)
throws
MyTimeException
{
projectTeamMate
.
setAuditFields
(
loginEmpId
,
MyTimeUtils
.
UPDATE
);
String
response
=
projectService
.
updateTeammate
(
projectTeamMate
,
loginEmpId
);
...
...
@@ -142,7 +142,7 @@ public class ProjectTeamController {
produces
=
MediaType
.
TEXT_PLAIN_VALUE
,
consumes
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
String
>
deleteTeammate
(
@RequestBody
ProjectTeamMat
e
projectTeamMate
,
@RequestParam
(
value
=
"loginEmpId"
)
String
loginEmpId
)
@RequestBody
Resourc
e
projectTeamMate
,
@RequestParam
(
value
=
"loginEmpId"
)
String
loginEmpId
)
throws
MyTimeException
{
projectService
.
deleteTeammate
(
projectTeamMate
.
getEmployeeId
(),
projectTeamMate
.
getProjectId
(),
projectTeamMate
.
getId
(),
loginEmpId
);
...
...
@@ -160,10 +160,10 @@ public class ProjectTeamController {
@RequestMapping
(
value
=
"/getMyTeamDetails"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
List
<
ProjectTeamMat
e
>>
getMyTeamDetails
(
public
ResponseEntity
<
List
<
Resourc
e
>>
getMyTeamDetails
(
@RequestParam
(
"employeeId"
)
String
employeeId
)
throws
MyTimeException
{
List
<
ProjectTeamMat
e
>
employeesRoles
=
projectService
List
<
Resourc
e
>
employeesRoles
=
projectService
.
getMyTeamDetails
(
employeeId
);
return
new
ResponseEntity
<>(
employeesRoles
,
HttpStatus
.
OK
);
}
...
...
@@ -180,9 +180,9 @@ public class ProjectTeamController {
@RequestMapping
(
value
=
"/getShiftDetails"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
List
<
ProjectTeamMat
e
>>
getShiftDetails
(
public
ResponseEntity
<
List
<
Resourc
e
>>
getShiftDetails
(
@RequestParam
(
"shift"
)
String
shift
)
throws
MyTimeException
{
List
<
ProjectTeamMat
e
>
employeesRoles
=
projectService
List
<
Resourc
e
>
employeesRoles
=
projectService
.
getShiftDetails
(
shift
);
return
new
ResponseEntity
<>(
employeesRoles
,
HttpStatus
.
OK
);
}
...
...
@@ -190,20 +190,20 @@ public class ProjectTeamController {
@RequestMapping
(
value
=
"/getProjectAllocations"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
List
<
ProjectTeamMat
e
>>
getProjectAllocations
()
public
ResponseEntity
<
List
<
Resourc
e
>>
getProjectAllocations
()
throws
MyTimeException
{
List
<
ProjectTeamMat
e
>
employeesRoles
=
projectService
List
<
Resourc
e
>
employeesRoles
=
projectService
.
getAllProjectDetails
();
return
new
ResponseEntity
<>(
employeesRoles
,
HttpStatus
.
OK
);
}
@RequestMapping
(
value
=
"/getProjectDetails"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
List
<
ProjectTeamMat
e
>>
getProjectDetails
(
public
ResponseEntity
<
List
<
Resourc
e
>>
getProjectDetails
(
@RequestParam
(
"projectId"
)
String
projectId
,
@RequestParam
(
value
=
"status"
,
required
=
false
,
defaultValue
=
MyTimeUtils
.
ACTIVE
)
String
status
)
throws
MyTimeException
{
List
<
ProjectTeamMat
e
>
employeesRoles
=
projectService
List
<
Resourc
e
>
employeesRoles
=
projectService
.
getProjectDetails
(
projectId
,
status
);
return
new
ResponseEntity
<>(
employeesRoles
,
HttpStatus
.
OK
);
}
...
...
@@ -223,11 +223,11 @@ public class ProjectTeamController {
@RequestMapping
(
value
=
"/getEmployeeBillingDetails"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
List
<
Billing
Details
>>
getEmployeeBillingDetails
(
public
ResponseEntity
<
List
<
Billing
>>
getEmployeeBillingDetails
(
@RequestParam
(
"employeeId"
)
String
employeeId
,
@RequestParam
(
"projectId"
)
String
projectId
)
throws
MyTimeException
{
List
<
Billing
Details
>
billings
=
projectService
List
<
Billing
>
billings
=
projectService
.
getEmployeeBillingDetails
(
employeeId
,
projectId
);
return
new
ResponseEntity
<>(
billings
,
HttpStatus
.
OK
);
}
...
...
@@ -235,10 +235,10 @@ public class ProjectTeamController {
@RequestMapping
(
value
=
"/getEmployeeBillingDetailsAll"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
List
<
Billing
Details
>>
getEmployeeBillingDetailsAll
(
public
ResponseEntity
<
List
<
Billing
>>
getEmployeeBillingDetailsAll
(
@RequestParam
(
"employeeId"
)
String
employeeId
)
throws
MyTimeException
{
List
<
Billing
Details
>
billings
=
projectService
List
<
Billing
>
billings
=
projectService
.
getEmployeeBillingDetailsAll
(
employeeId
);
return
new
ResponseEntity
<>(
billings
,
HttpStatus
.
OK
);
}
...
...
@@ -246,9 +246,9 @@ public class ProjectTeamController {
@RequestMapping
(
value
=
"/addEmployeeBilling"
,
method
=
RequestMethod
.
POST
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
,
consumes
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
Billing
Details
>
addEmployeeBilling
(
@RequestBody
Billing
Details
billingDetails
,
@RequestParam
(
value
=
"loginEmpId"
)
String
loginEmpId
)
throws
MyTimeException
{
Billing
Details
billings
=
projectService
public
ResponseEntity
<
Billing
>
addEmployeeBilling
(
@RequestBody
Billing
billingDetails
,
@RequestParam
(
value
=
"loginEmpId"
)
String
loginEmpId
)
throws
MyTimeException
{
Billing
billings
=
projectService
.
addEmployeeBillingDetails
(
billingDetails
,
loginEmpId
);
return
new
ResponseEntity
<>(
billings
,
HttpStatus
.
OK
);
...
...
@@ -258,9 +258,9 @@ public class ProjectTeamController {
method
=
RequestMethod
.
POST
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
,
consumes
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
Billing
Details
>
updateEmployeeBilling
(
@RequestBody
Billing
Details
billingDetails
,
@RequestParam
(
value
=
"loginEmpId"
)
String
loginEmpId
)
throws
MyTimeException
{
Billing
Details
billings
=
projectService
public
ResponseEntity
<
Billing
>
updateEmployeeBilling
(
@RequestBody
Billing
billingDetails
,
@RequestParam
(
value
=
"loginEmpId"
)
String
loginEmpId
)
throws
MyTimeException
{
Billing
billings
=
projectService
.
updateEmployeeBilling
(
billingDetails
,
loginEmpId
);
return
new
ResponseEntity
<>(
billings
,
HttpStatus
.
OK
);
}
...
...
@@ -269,8 +269,8 @@ public class ProjectTeamController {
method
=
RequestMethod
.
POST
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
,
consumes
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
Billing
Details
>
deleteEmployeeBilling
(
@RequestBody
Billing
Details
teamMate
)
throws
MyTimeException
{
public
ResponseEntity
<
Billing
>
deleteEmployeeBilling
(
@RequestBody
Billing
teamMate
)
throws
MyTimeException
{
projectService
.
deleteEmployeeBilling
(
teamMate
);
return
new
ResponseEntity
<>(
null
,
HttpStatus
.
OK
);
}
...
...
@@ -326,7 +326,7 @@ public class ProjectTeamController {
produces
=
MediaType
.
TEXT_PLAIN_VALUE
,
consumes
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
String
>
addEmployeeToTeamWithCheck
(
@RequestBody
ProjectTeamMat
e
teamMate
,
@RequestParam
(
value
=
"loginEmpId"
)
String
loginEmpId
)
throws
MyTimeException
{
@RequestBody
Resourc
e
teamMate
,
@RequestParam
(
value
=
"loginEmpId"
)
String
loginEmpId
)
throws
MyTimeException
{
String
response
=
projectService
.
addProjectTeamMateWithCheck
(
teamMate
,
loginEmpId
);
return
new
ResponseEntity
<>(
response
,
HttpStatus
.
OK
);
}
...
...
src/main/java/com/nisum/mytime/controller/ReportsController.java
View file @
cf947c85
...
...
@@ -33,14 +33,14 @@ import org.springframework.web.bind.annotation.RestController;
import
com.nisum.mytime.exception.handler.MyTimeException
;
import
com.nisum.mytime.model.Account
;
import
com.nisum.mytime.model.Billing
Details
;
import
com.nisum.mytime.model.Billing
;
import
com.nisum.mytime.model.ColumnChartData
;
import
com.nisum.mytime.model.Employee
;
import
com.nisum.mytime.model.GroupByCount
;
import
com.nisum.mytime.model.
ProjectTeamMat
e
;
import
com.nisum.mytime.model.
Resourc
e
;
import
com.nisum.mytime.model.ReportSeriesRecord
;
import
com.nisum.mytime.repository.EmployeeVisaRepo
;
import
com.nisum.mytime.repository.
TeamMates
BillingRepo
;
import
com.nisum.mytime.repository.BillingRepo
;
import
com.nisum.mytime.service.IProjectService
;
import
com.nisum.mytime.service.IEmployeeService
;
...
...
@@ -56,11 +56,12 @@ public class ReportsController {
@Autowired
private
EmployeeVisaRepo
employeeVisaRepo
;
@Autowired
private
MongoTemplate
mongoTemplate
;
@Autowired
private
TeamMates
BillingRepo
teamMatesBillingRepo
;
private
BillingRepo
teamMatesBillingRepo
;
@RequestMapping
(
value
=
"/getEmployeesByFunctionalGroup1"
,
method
=
RequestMethod
.
GET
,
...
...
@@ -137,7 +138,7 @@ public class ReportsController {
// Convert the aggregation result into a List
AggregationResults
<
ColumnChartData
>
groupResults
=
mongoTemplate
.
aggregate
(
aggregate
,
Billing
Details
.
class
,
.
aggregate
(
aggregate
,
Billing
.
class
,
ColumnChartData
.
class
);
List
<
ColumnChartData
>
result
=
groupResults
.
getMappedResults
();
List
<
String
>
statusList
=
new
ArrayList
();
...
...
@@ -248,7 +249,7 @@ public class ReportsController {
// Convert the aggregation result into a List
AggregationResults
<
ColumnChartData
>
groupResults1
=
mongoTemplate
.
aggregate
(
agg1
,
Billing
Details
.
class
,
.
aggregate
(
agg1
,
Billing
.
class
,
ColumnChartData
.
class
);
List
<
ColumnChartData
>
result1
=
groupResults1
.
getMappedResults
();
...
...
@@ -326,11 +327,11 @@ public class ReportsController {
@RequestMapping
(
value
=
"/fetchEmployeeDetailsByAccountBillability"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
List
<
ProjectTeamMat
e
>>
fetchEmployeeDetailsByAccountBillability
(
public
ResponseEntity
<
List
<
Resourc
e
>>
fetchEmployeeDetailsByAccountBillability
(
@RequestParam
(
"account"
)
String
account
,
@RequestParam
(
"billabilityStatus"
)
String
billabilityStatus
)
throws
MyTimeException
{
List
<
ProjectTeamMat
e
>
empList
=
new
ArrayList
<>();
List
<
Resourc
e
>
empList
=
new
ArrayList
<>();
if
(
account
!=
null
&&
!
account
.
isEmpty
())
{
empList
=
projectService
.
findByAccountAndActiveAndBillableStatus
(
account
,
true
,
billabilityStatus
);
...
...
@@ -341,11 +342,11 @@ public class ReportsController {
@RequestMapping
(
value
=
"/fetchEmployeeDetailsByDateBillability"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
List
<
Billing
Details
>>
fetchEmployeeDetailsByDateBillability
(
public
ResponseEntity
<
List
<
Billing
>>
fetchEmployeeDetailsByDateBillability
(
@RequestParam
(
"billabilityStatus"
)
String
billabilityStatus
,
@RequestParam
(
"reportDate"
)
String
reportDateString
)
throws
MyTimeException
{
List
<
Billing
Details
>
empList
=
new
ArrayList
<>();
List
<
Billing
>
empList
=
new
ArrayList
<>();
if
(
reportDateString
!=
null
&&
!
reportDateString
.
isEmpty
())
{
String
pattern
=
"MM-dd-yyyy"
;
SimpleDateFormat
simpleDateFormat
=
new
SimpleDateFormat
(
pattern
);
...
...
@@ -368,7 +369,7 @@ public class ReportsController {
criteriaV1
.
orOperator
(
criteriaV21
,
criteriaV22
));
Query
query
=
new
Query
();
query
.
addCriteria
(
criteriaV221
);
empList
=
mongoTemplate
.
find
(
query
,
Billing
Details
.
class
);
empList
=
mongoTemplate
.
find
(
query
,
Billing
.
class
);
}
return
new
ResponseEntity
<>(
empList
,
HttpStatus
.
OK
);
}
...
...
src/main/java/com/nisum/mytime/controller/ShiftController.java
View file @
cf947c85
package
com
.
nisum
.
mytime
.
controller
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.stream.Collectors
;
import
javax.servlet.http.HttpServletRequest
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.MediaType
;
...
...
@@ -12,23 +15,32 @@ import org.springframework.web.bind.annotation.RequestMethod;
import
org.springframework.web.bind.annotation.RestController
;
import
com.nisum.mytime.exception.handler.MyTimeException
;
import
com.nisum.mytime.exception.handler.ResponseDetails
;
import
com.nisum.mytime.model.Shift
;
import
com.nisum.mytime.service.IShiftService
;
import
com.nisum.mytime.service.impl.ShiftService
;
import
lombok.extern.slf4j.Slf4j
;
@RestController
@Slf4j
public
class
ShiftController
{
@Autowired
ShiftService
shiftService
;
I
ShiftService
shiftService
;
// @RequestMapping(value = "/getAllShifts", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
// @RequestMapping(value = "/getAllShifts"
@RequestMapping
(
value
=
"/employees/shifts/"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
List
<
String
>>
getAllShifts
()
throws
MyTimeException
{
public
ResponseEntity
<?>
getAllShifts
(
HttpServletRequest
request
)
throws
MyTimeException
{
List
<
String
>
shiftsList
=
shiftService
.
getAllShifts
().
stream
()
.
filter
(
e
->
"Y"
.
equalsIgnoreCase
(
e
.
getActiveStatus
())).
map
(
Shift:
:
getShiftName
).
sorted
()
.
collect
(
Collectors
.
toList
());
log
.
info
(
"The Active shift names:"
+
shiftsList
);
ResponseDetails
getRespDetails
=
new
ResponseDetails
(
new
Date
(),
905
,
"Retrieved Employee Shifts successfully"
,
"Employee Shifts List"
,
shiftsList
,
request
.
getRequestURI
(),
"Employee Shifts Details"
,
null
);
List
<
String
>
shifts
=
shiftService
.
getAllShifts
().
stream
().
filter
(
e
->
"Y"
.
equalsIgnoreCase
(
e
.
getActiveStatus
()))
.
map
(
Shift:
:
getShiftName
).
sorted
().
collect
(
Collectors
.
toList
());
return
new
ResponseEntity
<>(
shifts
,
HttpStatus
.
OK
);
return
new
ResponseEntity
<
ResponseDetails
>(
getRespDetails
,
HttpStatus
.
OK
);
}
}
src/main/java/com/nisum/mytime/controller/SkillController.java
View file @
cf947c85
package
com
.
nisum
.
mytime
.
controller
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.stream.Collectors
;
import
javax.servlet.http.HttpServletRequest
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.MediaType
;
...
...
@@ -12,23 +15,31 @@ import org.springframework.web.bind.annotation.RequestMethod;
import
org.springframework.web.bind.annotation.RestController
;
import
com.nisum.mytime.exception.handler.MyTimeException
;
import
com.nisum.mytime.exception.handler.ResponseDetails
;
import
com.nisum.mytime.model.Skill
;
import
com.nisum.mytime.service.ISkillService
;
import
com.nisum.mytime.service.impl.SkillService
;
import
lombok.extern.slf4j.Slf4j
;
@RestController
@Slf4j
public
class
SkillController
{
@Autowired
SkillService
skillService
;
I
SkillService
skillService
;
// @RequestMapping(value = "/getSkills", method = RequestMethod.GET,
// produces = MediaType.APPLICATION_JSON_VALUE)
// @RequestMapping(value = "/getSkills"
@RequestMapping
(
value
=
"/employees/skills/"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
List
<
String
>>
getTechnologies
(
)
throws
MyTimeException
{
List
<
String
>
technologies
=
skillService
.
getTechnologies
().
stream
()
public
ResponseEntity
<
?>
getTechnologies
(
HttpServletRequest
request
)
throws
MyTimeException
{
List
<
String
>
skillsList
=
skillService
.
getTechnologies
().
stream
()
.
filter
(
e
->
"Y"
.
equalsIgnoreCase
(
e
.
getActiveStatus
())).
map
(
Skill:
:
getSkillName
).
sorted
()
.
collect
(
Collectors
.
toList
());
return
new
ResponseEntity
<>(
technologies
,
HttpStatus
.
OK
);
log
.
info
(
"The Employee skills Lis::"
+
skillsList
);
ResponseDetails
getRespDetails
=
new
ResponseDetails
(
new
Date
(),
905
,
"Retrieved Employee Skills successfully"
,
"Employee Skills List"
,
skillsList
,
request
.
getRequestURI
(),
"Employee Skills Details"
,
null
);
return
new
ResponseEntity
<
ResponseDetails
>(
getRespDetails
,
HttpStatus
.
OK
);
}
}
src/main/java/com/nisum/mytime/controller/UploadXLController.java
0 → 100644
View file @
cf947c85
package
com
.
nisum
.
mytime
.
controller
;
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.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.service.IUploadXLService
;
import
lombok.extern.slf4j.Slf4j
;
@RestController
@Slf4j
public
class
UploadXLController
{
@Autowired
private
IUploadXLService
uploadService
;
@RequestMapping
(
value
=
"/employee/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
=
uploadService
.
importDataFromExcelFile
(
file
,
loginEmpId
);
return
new
ResponseEntity
<>(
result
,
HttpStatus
.
OK
);
}
}
src/main/java/com/nisum/mytime/exception/handler/EmployeeNotFoundException.java
0 → 100644
View file @
cf947c85
package
com
.
nisum
.
mytime
.
exception
.
handler
;
public
class
EmployeeNotFoundException
extends
RuntimeException
{
/**
*
*/
private
static
final
long
serialVersionUID
=
1L
;
public
EmployeeNotFoundException
(
String
message
)
{
super
(
message
);
}
}
src/main/java/com/nisum/mytime/exception/handler/GlobalExceptionHandler.java
View file @
cf947c85
...
...
@@ -17,11 +17,15 @@ import org.springframework.web.bind.annotation.RestControllerAdvice;
import
org.springframework.web.context.request.WebRequest
;
import
org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler
;
import
lombok.extern.slf4j.Slf4j
;
@RestControllerAdvice
@RestController
@Slf4j
public
class
GlobalExceptionHandler
extends
ResponseEntityExceptionHandler
{
private
static
final
Logger
log
=
LoggerFactory
.
getLogger
(
GlobalExceptionHandler
.
class
);
// private static final Logger log =
// LoggerFactory.getLogger(GlobalExceptionHandler.class);
@ExceptionHandler
(
DataAccessException
.
class
)
public
String
handleDataAccessExceptions
(
DataAccessException
ex
)
{
...
...
@@ -40,15 +44,26 @@ public class GlobalExceptionHandler extends ResponseEntityExceptionHandler {
@ExceptionHandler
(
AccountNotFoundException
.
class
)
public
final
ResponseEntity
<
Object
>
handleUserNotFoundException
(
AccountNotFoundException
ex
,
WebRequest
request
)
{
log
.
error
(
"Exception occured due to::"
,
ex
);
ResponseDetails
errorDetails
=
new
ResponseDetails
(
new
Date
(),
602
,
"The Account you are looking for is not found"
,
ex
.
getMessage
(),
null
,
request
.
getContextPath
(),
request
.
getDescription
(
false
),
null
);
return
new
ResponseEntity
<
Object
>(
errorDetails
,
HttpStatus
.
NOT_FOUND
);
}
@ExceptionHandler
(
EmployeeNotFoundException
.
class
)
public
final
ResponseEntity
<
Object
>
handleEmployeeNotFoundException
(
EmployeeNotFoundException
ex
,
WebRequest
request
)
{
log
.
error
(
"Exception occured due to::"
,
ex
);
ResponseDetails
errorDetails
=
new
ResponseDetails
(
new
Date
(),
902
,
"The Employee you are looking for is not found"
,
ex
.
getMessage
(),
null
,
request
.
getContextPath
(),
request
.
getDescription
(
false
),
null
);
return
new
ResponseEntity
<
Object
>(
errorDetails
,
HttpStatus
.
NOT_FOUND
);
}
@Override
protected
ResponseEntity
<
Object
>
handleMethodArgumentNotValid
(
MethodArgumentNotValidException
ex
,
HttpHeaders
headers
,
HttpStatus
status
,
WebRequest
request
)
{
log
.
error
(
"The exception is occured due to ::"
,
ex
);
ResponseDetails
errorDetails
=
new
ResponseDetails
(
new
Date
(),
702
,
"Method Arguement is not validated"
,
"Validation Failed"
,
null
,
request
.
getContextPath
(),
ex
.
getBindingResult
().
toString
(),
null
);
return
new
ResponseEntity
<
Object
>(
errorDetails
,
HttpStatus
.
BAD_REQUEST
);
...
...
src/main/java/com/nisum/mytime/model/Billing
Details
.java
→
src/main/java/com/nisum/mytime/model/Billing.java
View file @
cf947c85
...
...
@@ -20,8 +20,8 @@ import lombok.ToString;
@AllArgsConstructor
@NoArgsConstructor
@ToString
@Document
(
collection
=
"
BillingDetails
"
)
public
class
Billing
Details
extends
AuditFields
implements
Serializable
{
@Document
(
collection
=
"
billing
"
)
public
class
Billing
extends
AuditFields
implements
Serializable
{
public
Date
getBillingEndDate
()
{
return
billingEndDate
;
...
...
src/main/java/com/nisum/mytime/model/EmpShiftDetails.java
View file @
cf947c85
...
...
@@ -14,7 +14,7 @@ import lombok.ToString;
@AllArgsConstructor
@NoArgsConstructor
@ToString
@Document
(
collection
=
"
EmpShiftDetail
s"
)
@Document
(
collection
=
"
employeeShift
s"
)
public
class
EmpShiftDetails
extends
AuditFields
{
@Id
...
...
src/main/java/com/nisum/mytime/model/Employee.java
View file @
cf947c85
...
...
@@ -3,6 +3,12 @@ package com.nisum.mytime.model;
import
java.io.Serializable
;
import
java.util.Date
;
import
javax.validation.constraints.NotNull
;
import
javax.validation.constraints.Pattern
;
import
javax.validation.constraints.Size
;
import
org.hibernate.validator.constraints.Email
;
import
org.hibernate.validator.constraints.NotBlank
;
import
org.springframework.data.annotation.Id
;
import
org.springframework.data.mongodb.core.mapping.Document
;
...
...
@@ -15,7 +21,7 @@ import lombok.Setter;
import
lombok.ToString
;
@Setter
@Getter
@Getter
@AllArgsConstructor
@NoArgsConstructor
@ToString
...
...
@@ -27,23 +33,32 @@ public class Employee implements Serializable {
@Id
private
String
id
;
@NotBlank
(
message
=
"Employee Id cannot be blank"
)
//@Pattern(regexp = "^\\d{6}", message = "Invalid Employee code, It should be 5 digit")
@ExcelCellName
(
"Employee ID"
)
private
String
employeeId
;
@NotBlank
(
message
=
"Employee name should not be empty"
)
@Size
(
min
=
2
,
max
=
80
,
message
=
"Employee Name should have atlast 2 and less than 200 characters"
)
@ExcelCellName
(
"Employee Name"
)
private
String
employeeName
;
@Email
(
message
=
"Invalid email id"
)
@ExcelCellName
(
"Email ID"
)
private
String
emailId
;
@ExcelCellName
(
"Role"
)
private
String
role
;
@ExcelCellName
(
"Shift"
)
private
String
shift
;
@NotBlank
(
message
=
"Designation cannot be blank"
)
@ExcelCellName
(
"Designation"
)
private
String
designation
;
@ExcelCellName
(
"Shift"
)
private
String
shift
;
@ExcelCellName
(
"Primary Skill"
)
private
String
baseTechnology
;
...
...
@@ -57,12 +72,17 @@ public class Employee implements Serializable {
@ExcelCellName
(
"Skills"
)
private
String
technologyKnown
;
@NotBlank
@Pattern
(
regexp
=
"(^$|[0-9]{10})"
,
message
=
"Invalid mobile number"
)
@ExcelCellName
(
"Primary Mobile"
)
private
String
mobileNumber
;
@NotBlank
@Pattern
(
regexp
=
"(^$|[0-9]{10})"
,
message
=
"Invalid alternate mobile number"
)
@ExcelCellName
(
"Alternate Mobile"
)
private
String
alternateMobileNumber
;
@Email
(
message
=
"Invalid personal email id"
)
@ExcelCellName
(
"Personal Email"
)
private
String
personalEmailId
;
...
...
@@ -75,9 +95,11 @@ public class Employee implements Serializable {
@ExcelCellName
(
"Employment Type"
)
private
String
employmentType
;
@NotNull
@ExcelCellName
(
"Date Of Joining"
)
private
Date
dateOfJoining
;
@ExcelCellName
(
"Date Of Birth"
)
private
Date
dateOfBirth
;
...
...
src/main/java/com/nisum/mytime/model/
AccountInfo
.java
→
src/main/java/com/nisum/mytime/model/
EmployeeLocation
.java
View file @
cf947c85
package
com
.
nisum
.
mytime
.
model
;
import
java.io.Serializable
;
import
java.util.Date
;
import
java.util.List
;
import
org.bson.types.ObjectId
;
import
org.springframework.data.annotation.Id
;
import
org.springframework.data.mongodb.core.mapping.Document
;
import
com.poiji.annotation.ExcelCellName
;
import
lombok.AllArgsConstructor
;
import
lombok.Getter
;
import
lombok.NoArgsConstructor
;
...
...
@@ -18,19 +21,20 @@ import lombok.ToString;
@AllArgsConstructor
@NoArgsConstructor
@ToString
@Document
(
collection
=
"AccountInfo"
)
public
class
AccountInfo
implements
Serializable
{
@Document
(
collection
=
"employeeLocations"
)
public
class
EmployeeLocation
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
@Id
private
ObjectId
id
;
private
String
accountId
;
private
String
accountName
;
private
String
status
;
private
String
clientAddress
;
private
String
industryType
;
List
<
String
>
deliveryManagers
;
private
String
employeeId
;
private
String
employeeName
;
private
String
empLocation
;
private
Date
startDate
;
private
Date
endDate
;
private
Date
createDate
;
private
Date
updatedDate
;
private
boolean
active
;
}
src/main/java/com/nisum/mytime/model/EmployeeLocationDetails.java
deleted
100644 → 0
View file @
a6abbc45
package
com
.
nisum
.
mytime
.
model
;
import
java.io.Serializable
;
import
java.util.Date
;
import
java.util.List
;
import
org.bson.types.ObjectId
;
import
org.springframework.data.annotation.Id
;
import
org.springframework.data.mongodb.core.mapping.Document
;
import
com.poiji.annotation.ExcelCellName
;
import
lombok.AllArgsConstructor
;
import
lombok.Getter
;
import
lombok.NoArgsConstructor
;
import
lombok.Setter
;
import
lombok.ToString
;
@Setter
@Getter
@AllArgsConstructor
@NoArgsConstructor
@ToString
@Document
(
collection
=
"EmployeeLocationDetails"
)
public
class
EmployeeLocationDetails
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
@Id
private
ObjectId
id
;
private
String
employeeId
;
private
String
employeeName
;
private
String
empLocation
;
private
Date
startDate
;
private
Date
endDate
;
private
Date
createDate
;
private
Date
updatedDate
;
private
boolean
active
;
}
src/main/java/com/nisum/mytime/model/
RoleMappingInfo
.java
→
src/main/java/com/nisum/mytime/model/
EmployeeRole
.java
View file @
cf947c85
...
...
@@ -16,8 +16,9 @@ import lombok.ToString;
@AllArgsConstructor
@NoArgsConstructor
@ToString
@Document
(
collection
=
"EmpAssignedRoleMappingInfo"
)
public
class
RoleMappingInfo
implements
Serializable
{
//@Document(collection = "EmpAssignedRoleMappingInfo")
@Document
(
collection
=
"employeeRoles"
)
public
class
EmployeeRole
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
@Id
...
...
src/main/java/com/nisum/mytime/model/Location.java
→
src/main/java/com/nisum/mytime/model/
Org
Location.java
View file @
cf947c85
...
...
@@ -17,8 +17,8 @@ import lombok.ToString;
@AllArgsConstructor
@NoArgsConstructor
@ToString
@Document
(
collection
=
"Locations"
)
public
class
Location
implements
Serializable
{
@Document
(
collection
=
"
org
Locations"
)
public
class
Org
Location
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
...
...
src/main/java/com/nisum/mytime/model/
ProjectTeamMat
e.java
→
src/main/java/com/nisum/mytime/model/
Resourc
e.java
View file @
cf947c85
...
...
@@ -20,8 +20,8 @@ import lombok.ToString;
@AllArgsConstructor
@NoArgsConstructor
@ToString
@Document
(
collection
=
"
TeamDetail
s"
)
public
class
ProjectTeamMat
e
extends
AuditFields
implements
Serializable
{
@Document
(
collection
=
"
resource
s"
)
public
class
Resourc
e
extends
AuditFields
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
...
...
@@ -35,7 +35,6 @@ public class ProjectTeamMate extends AuditFields implements Serializable {
private
String
projectId
;
private
String
projectName
;
private
String
account
;
private
String
experience
;
private
String
designation
;
private
String
billableStatus
;
...
...
src/main/java/com/nisum/mytime/repository/AccountInfoRepo.java
deleted
100644 → 0
View file @
a6abbc45
package
com
.
nisum
.
mytime
.
repository
;
import
org.springframework.data.mongodb.repository.MongoRepository
;
import
com.nisum.mytime.model.AccountInfo
;
public
interface
AccountInfoRepo
extends
MongoRepository
<
AccountInfo
,
String
>
{
AccountInfo
findByAccountName
(
String
accontName
);
}
\ No newline at end of file
src/main/java/com/nisum/mytime/repository/
TeamMates
BillingRepo.java
→
src/main/java/com/nisum/mytime/repository/BillingRepo.java
View file @
cf947c85
...
...
@@ -5,16 +5,16 @@ import java.util.List;
import
org.bson.types.ObjectId
;
import
org.springframework.data.mongodb.repository.MongoRepository
;
import
com.nisum.mytime.model.Billing
Details
;
import
com.nisum.mytime.model.Billing
;
public
interface
TeamMatesBillingRepo
extends
MongoRepository
<
BillingDetails
,
String
>
{
public
interface
BillingRepo
extends
MongoRepository
<
Billing
,
String
>
{
List
<
Billing
Details
>
findByProjectId
(
String
projectId
);
List
<
Billing
>
findByProjectId
(
String
projectId
);
List
<
Billing
Details
>
findByEmployeeId
(
String
employeeId
);
List
<
Billing
>
findByEmployeeId
(
String
employeeId
);
Billing
Details
findById
(
ObjectId
id
);
Billing
findById
(
ObjectId
id
);
List
<
Billing
Details
>
findByEmployeeIdAndProjectId
(
String
employeeId
,
String
projectId
);
List
<
Billing
>
findByEmployeeIdAndProjectId
(
String
employeeId
,
String
projectId
);
}
src/main/java/com/nisum/mytime/repository/EmployeeLocation
Details
Repo.java
→
src/main/java/com/nisum/mytime/repository/EmployeeLocationRepo.java
View file @
cf947c85
...
...
@@ -4,12 +4,11 @@ import java.util.List;
import
org.springframework.data.mongodb.repository.MongoRepository
;
import
com.nisum.mytime.model.EmployeeLocation
Details
;
import
com.nisum.mytime.model.EmployeeLocation
;
public
interface
EmployeeLocation
DetailsRepo
extends
MongoRepository
<
EmployeeLocationDetails
,
String
>
{
public
interface
EmployeeLocation
Repo
extends
MongoRepository
<
EmployeeLocation
,
String
>
{
List
<
EmployeeLocation
>
findByEmployeeId
(
String
employeeId
);
List
<
EmployeeLocationDetails
>
findByEmployeeId
(
String
employeeId
);
EmployeeLocationDetails
findByEmployeeName
(
String
employeeName
);
EmployeeLocation
findByEmployeeName
(
String
employeeName
);
}
src/main/java/com/nisum/mytime/repository/EmployeeRepo.java
View file @
cf947c85
package
com
.
nisum
.
mytime
.
repository
;
import
java.util.List
;
import
java.util.Optional
;
import
java.util.Set
;
import
org.springframework.data.domain.Example
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.data.domain.Sort
;
import
org.springframework.data.mongodb.repository.MongoRepository
;
import
com.nisum.mytime.model.Employee
;
...
...
@@ -24,5 +29,6 @@ public interface EmployeeRepo
List
<
Employee
>
findByEmpStatus
(
String
status
);
List
<
Employee
>
findByEmployeeIdIn
(
Set
<
String
>
empIdsSet
);
}
src/main/java/com/nisum/mytime/repository/
RoleMappingInfo
Repo.java
→
src/main/java/com/nisum/mytime/repository/
EmployeeRole
Repo.java
View file @
cf947c85
...
...
@@ -4,11 +4,11 @@ import java.util.List;
import
org.springframework.data.mongodb.repository.MongoRepository
;
import
com.nisum.mytime.model.
RoleMappingInfo
;
import
com.nisum.mytime.model.
EmployeeRole
;
public
interface
RoleMappingInfoRepo
extends
MongoRepository
<
RoleMappingInfo
,
String
>
{
public
interface
EmployeeRoleRepo
extends
MongoRepository
<
EmployeeRole
,
String
>
{
RoleMappingInfo
findByEmployeeIdAndRoleId
(
String
employeeId
,
String
roleId
);
EmployeeRole
findByEmployeeIdAndRoleId
(
String
employeeId
,
String
roleId
);
List
<
RoleMappingInfo
>
findByEmployeeId
(
String
employeeId
);
List
<
EmployeeRole
>
findByEmployeeId
(
String
employeeId
);
}
\ No newline at end of file
src/main/java/com/nisum/mytime/repository/LocationRepo.java
→
src/main/java/com/nisum/mytime/repository/
Org
LocationRepo.java
View file @
cf947c85
...
...
@@ -4,8 +4,8 @@ import java.util.List;
import
org.springframework.data.mongodb.repository.MongoRepository
;
import
com.nisum.mytime.model.Location
;
import
com.nisum.mytime.model.
Org
Location
;
public
interface
LocationRepo
extends
MongoRepository
<
Location
,
String
>
{
List
<
Location
>
findByLocationAndActiveStatus
(
String
location
,
boolean
activeStatus
);
public
interface
OrgLocationRepo
extends
MongoRepository
<
Org
Location
,
String
>
{
List
<
Org
Location
>
findByLocationAndActiveStatus
(
String
location
,
boolean
activeStatus
);
}
\ No newline at end of file
src/main/java/com/nisum/mytime/repository/ProjectTeamMatesRepo.java
deleted
100644 → 0
View file @
a6abbc45
package
com
.
nisum
.
mytime
.
repository
;
import
java.util.List
;
import
java.util.Optional
;
import
org.bson.types.ObjectId
;
import
org.springframework.data.mongodb.repository.MongoRepository
;
import
com.nisum.mytime.model.ProjectTeamMate
;
public
interface
ProjectTeamMatesRepo
extends
MongoRepository
<
ProjectTeamMate
,
String
>
{
List
<
ProjectTeamMate
>
findByProjectId
(
String
projectId
);
List
<
ProjectTeamMate
>
findByEmployeeId
(
String
employeeId
);
ProjectTeamMate
findById
(
ObjectId
id
);
ProjectTeamMate
findByEmployeeIdAndProjectId
(
String
employeeId
,
String
projectId
);
List
<
ProjectTeamMate
>
findByEmployeeIdAndActive
(
String
employeeId
,
boolean
status
);
List
<
ProjectTeamMate
>
findByEmployeeIdAndProjectIdAndActive
(
String
employeeId
,
String
projectId
,
boolean
status
);
List
<
ProjectTeamMate
>
findByAccountAndActiveAndBillableStatus
(
String
account
,
boolean
status
,
String
billableStatus
);
Optional
<
List
<
ProjectTeamMate
>>
findByActiveAndShiftLikeOrderByEmployeeIdDesc
(
boolean
active
,
String
shift
);
}
src/main/java/com/nisum/mytime/repository/ResourceRepo.java
0 → 100644
View file @
cf947c85
package
com
.
nisum
.
mytime
.
repository
;
import
java.util.List
;
import
java.util.Optional
;
import
org.bson.types.ObjectId
;
import
org.springframework.data.mongodb.repository.MongoRepository
;
import
com.nisum.mytime.model.Resource
;
public
interface
ResourceRepo
extends
MongoRepository
<
Resource
,
String
>
{
List
<
Resource
>
findByProjectId
(
String
projectId
);
List
<
Resource
>
findByEmployeeId
(
String
employeeId
);
Resource
findById
(
ObjectId
id
);
Resource
findByEmployeeIdAndProjectId
(
String
employeeId
,
String
projectId
);
List
<
Resource
>
findByEmployeeIdAndActive
(
String
employeeId
,
boolean
status
);
List
<
Resource
>
findByEmployeeIdAndProjectIdAndActive
(
String
employeeId
,
String
projectId
,
boolean
status
);
List
<
Resource
>
findByAccountAndActiveAndBillableStatus
(
String
account
,
boolean
status
,
String
billableStatus
);
Optional
<
List
<
Resource
>>
findByActiveAndShiftLikeOrderByEmployeeIdDesc
(
boolean
active
,
String
shift
);
}
src/main/java/com/nisum/mytime/repository/Role
Info
Repo.java
→
src/main/java/com/nisum/mytime/repository/RoleRepo.java
View file @
cf947c85
...
...
@@ -4,7 +4,7 @@ import org.springframework.data.mongodb.repository.MongoRepository;
import
com.nisum.mytime.model.Role
;
public
interface
Role
Info
Repo
extends
MongoRepository
<
Role
,
String
>
{
public
interface
RoleRepo
extends
MongoRepository
<
Role
,
String
>
{
Role
findByRoleName
(
String
roleName
);
...
...
src/main/java/com/nisum/mytime/service/IAccountService.java
View file @
cf947c85
...
...
@@ -23,4 +23,6 @@ public interface IAccountService {
Account
deleteAccount
(
String
accountId
)
throws
MyTimeException
;
public
List
<
Account
>
getAccountsAll
()
throws
MyTimeException
;
}
src/main/java/com/nisum/mytime/service/IAttendanceService.java
View file @
cf947c85
...
...
@@ -10,10 +10,20 @@ import com.nisum.mytime.model.EmpLoginData;
public
interface
IAttendanceService
{
List
<
AttendenceData
>
getAttendanciesReport
(
String
reportDate
,
String
shift
)
throws
MyTimeException
,
SQLException
;
List
<
AttendenceData
>
getAttendanciesReport
(
String
reportDate
,
String
shift
)
throws
MyTimeException
,
SQLException
;
List
generatePdfReport
(
long
id
,
String
fromDate
,
String
toDate
,
String
fromTime
,
String
toTime
)
throws
MyTimeException
;
List
generatePdfReport
(
long
id
,
String
fromDate
,
String
toDate
,
String
fromTime
,
String
toTime
)
throws
MyTimeException
;
List
<
EmpLoginData
>
employeeLoginReportBasedOnDateTime
(
long
id
,
String
fromDate
,
String
toDate
,
String
fromTime
,
String
toTime
)
throws
MyTimeException
,
ParseException
;
Boolean
fetchEmployeesData
(
String
perticularDate
,
boolean
resynchFlag
)
throws
MyTimeException
;
List
<
EmpLoginData
>
employeeLoginsBasedOnDate
(
long
id
,
String
fromDate
,
String
toDate
)
throws
MyTimeException
;
List
generatePdfReport
(
long
id
,
String
fromDate
,
String
toDate
)
throws
MyTimeException
;
List
<
EmpLoginData
>
employeeLoginReportBasedOnDateTime
(
long
id
,
String
fromDate
,
String
toDate
,
String
fromTime
,
String
toTime
)
throws
MyTimeException
,
ParseException
;
}
src/main/java/com/nisum/mytime/service/IBillingService.java
0 → 100644
View file @
cf947c85
package
com
.
nisum
.
mytime
.
service
;
import
java.util.List
;
import
org.springframework.stereotype.Service
;
import
com.nisum.mytime.model.Billing
;
import
com.nisum.mytime.model.Employee
;
@Service
public
interface
IBillingService
{
public
Billing
addBillingtoResource
(
Billing
billing
,
Employee
employee
,
String
loginEmpId
);
public
List
<
Billing
>
getEmployeeActiveBillingDetails
(
String
empId
,
String
projectId
);
}
src/main/java/com/nisum/mytime/service/IDomainService.java
View file @
cf947c85
...
...
@@ -32,4 +32,10 @@ public interface IDomainService {
Set
<
String
>
accountsAssignedToDeliveryLead
(
String
empId
)
throws
MyTimeException
;
List
<
Domain
>
getDomainsUnderAccount
(
String
accountId
)
throws
MyTimeException
;
Domain
getDomainById
(
String
domainId
);
}
src/main/java/com/nisum/mytime/service/IEmployeeLocationService.java
View file @
cf947c85
...
...
@@ -5,13 +5,14 @@ import java.util.List;
import
org.springframework.stereotype.Service
;
import
com.nisum.mytime.model.Employee
;
import
com.nisum.mytime.model.EmployeeLocation
Details
;
import
com.nisum.mytime.model.EmployeeLocation
;
@Service
public
interface
IEmployeeLocationService
{
public
void
save
(
Employee
employee
);
public
void
saveEmployeeLocationDetails
(
Employee
employee
)
;
public
List
<
EmployeeLocation
>
getEmployeeLocations
(
String
empId
)
;
public
List
<
EmployeeLocationDetails
>
getEmployeeLocationDetails
(
String
empId
);
void
update
(
Employee
employee
,
boolean
delete
);
}
src/main/java/com/nisum/mytime/service/I
RoleMapping
Service.java
→
src/main/java/com/nisum/mytime/service/I
EmployeeRole
Service.java
View file @
cf947c85
...
...
@@ -3,10 +3,16 @@ package com.nisum.mytime.service;
import
java.util.List
;
import
java.util.Set
;
import
org.springframework.stereotype.Service
;
import
com.mongodb.WriteResult
;
import
com.nisum.mytime.exception.handler.MyTimeException
;
import
com.nisum.mytime.model.EmployeeRole
;
@Service
public
interface
IEmployeeRoleService
{
public
interface
IRoleMappingService
{
List
<
EmployeeRole
>
findByEmployeeId
(
String
employeeId
);
void
addEmployeeRole
(
String
employeeId
,
String
roleId
)
throws
MyTimeException
;
...
...
src/main/java/com/nisum/mytime/service/IEmployeeService.java
View file @
cf947c85
package
com
.
nisum
.
mytime
.
service
;
import
java.text.ParseException
;
import
java.util.HashMap
;
import
java.util.List
;
import
org.springframework.http.ResponseEntity
;
import
java.util.Set
;
import
org.springframework.stereotype.Service
;
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
;
import
com.nisum.mytime.model.Designation
;
import
com.nisum.mytime.model.Domain
;
import
com.nisum.mytime.model.EmpLoginData
;
import
com.nisum.mytime.model.EmployeeLocationDetails
;
import
com.nisum.mytime.model.Employee
;
import
com.nisum.mytime.model.Location
;
import
com.nisum.mytime.model.MasterData
;
import
com.nisum.mytime.model.Shift
;
import
com.nisum.mytime.model.Skill
;
@Service
public
interface
IEmployeeService
{
List
<
Employee
>
getManagers
()
throws
MyTimeException
;
boolean
isEmployeeExistsById
(
String
employeeId
)
;
Boolean
fetchEmployeesData
(
String
perticularDate
,
boolean
resynchFlag
)
throws
MyTimeException
;
Employee
createEmployee
(
Employee
employeeRoles
,
String
empId
)
throws
MyTimeException
;
List
<
EmpLoginData
>
employeeLoginsBasedOnDate
(
long
id
,
String
fromDate
,
String
toDate
)
throws
MyTimeException
;
Employee
updateEmployee
(
Employee
employeeRoles
,
String
empId
);
List
<
Employee
>
getActiveEmployees
()
throws
MyTimeException
;
Employee
deleteEmployee
(
String
empId
)
;
Employee
createEmployee
(
Employee
employeeRoles
,
String
empId
)
throws
MyTimeException
;
Employee
updateProfile
(
Employee
employeeRoles
)
throws
MyTimeException
;
List
generatePdfReport
(
long
id
,
String
fromDate
,
String
toDate
)
throws
MyTimeException
;
List
generatePdfReport
(
long
id
,
String
fromDate
,
String
toDate
,
String
fromTime
,
String
toTime
)
throws
MyTimeException
,
ParseException
;
Employee
getEmployeeById
(
String
empId
);
Employee
getEmployeeByEmaillId
(
String
emailId
);
void
deleteEmployee
(
String
empId
);
Employee
updateEmployeeRole
(
Employee
employeeRoles
,
String
empId
);
void
updateEmployeeLocationDetails
(
Employee
employeeRoles
,
boolean
delete
);
//void saveEmployeeLocationDetails(Employee employeeRoles);
Employee
getEmployeesRoleData
(
String
empId
);
//List<EmployeeLocationDetails> getEmployeeLocationDetails(String empId);
// List<Shift> getAllShifts() throws MyTimeException;
List
<
Employee
>
getManagers
()
throws
MyTimeException
;
// List<Designation> getAllDesignations() throws MyTimeException;
//List<Skill> getTechnologies() throws MyTimeException;
public
Employee
updateProfile
(
Employee
employeeRoles
)
throws
MyTimeException
;
List
<
Employee
>
getActiveEmployees
()
throws
MyTimeException
;
public
List
<
Account
>
getAccounts
()
throws
MyTimeException
;
List
<
Employee
>
getEmployeesByStatus
(
String
status
)
;
//List<Location> getLocation
s() throws MyTimeException;
List
<
Account
>
getAccount
s
()
throws
MyTimeException
;
Employee
getEmployeeRoleDataForSearchCriteria
(
String
searchId
,
String
searchAttribute
);
Employee
getEmployeeRoleDataForSearchCriteria
(
String
searchId
,
String
searchAttribute
);
List
<
String
>
getEmployeeDetailsForAutocomplete
();
//List<MasterData> getMasterData() throws MyTimeException;
List
<
Employee
>
getEmployeesByFunctionalGrp
(
String
functionalGrp
);
List
<
Employee
>
getEmployeesByStatus
(
String
status
);
List
<
HashMap
<
String
,
String
>>
getDeliveryLeads
(
String
domainId
);
public
List
<
AccountInfo
>
getAccountsInfo
()
throws
MyTimeException
;
List
<
Employee
>
getEmployeesByFunctionalGrp
(
String
functionalGrp
)
;
public
List
<
Domain
>
getDomains
(
String
accountId
)
throws
MyTimeException
;
boolean
verifyEmployeeRole
(
String
empId
,
String
roleName
)
;
public
boolean
verifyRole
(
String
empId
,
String
roleName
);
List
<
Employee
>
getEmployeesFromList
(
Set
<
String
>
empIdsSet
);
String
importDataFromExcelFile
(
MultipartFile
file
,
String
empId
)
throws
MyTimeException
;
}
src/main/java/com/nisum/mytime/service/IEmployeeShiftService.java
0 → 100644
View file @
cf947c85
package
com
.
nisum
.
mytime
.
service
;
import
org.springframework.stereotype.Service
;
import
com.nisum.mytime.model.Resource
;
@Service
public
interface
IEmployeeShiftService
{
void
updateShiftDetails
(
Resource
existingTeammate
,
String
loginEmpId
);
}
src/main/java/com/nisum/mytime/service/IMasterDataService.java
View file @
cf947c85
...
...
@@ -11,4 +11,7 @@ import com.nisum.mytime.model.MasterData;
public
interface
IMasterDataService
{
List
<
MasterData
>
getMasterData
()
throws
MyTimeException
;
List
<
MasterData
>
findByMasterDataTypeAndMasterDataNameAndActiveStatus
(
String
masterDataType
,
String
masterDataName
,
boolean
activeStatus
);
}
src/main/java/com/nisum/mytime/service/IOrgLocationService.java
View file @
cf947c85
...
...
@@ -5,10 +5,12 @@ import java.util.List;
import
org.springframework.stereotype.Service
;
import
com.nisum.mytime.exception.handler.MyTimeException
;
import
com.nisum.mytime.model.Location
;
import
com.nisum.mytime.model.
Org
Location
;
@Service
public
interface
IOrgLocationService
{
List
<
Location
>
getLocations
()
throws
MyTimeException
;
List
<
OrgLocation
>
getLocations
()
throws
MyTimeException
;
List
<
OrgLocation
>
findByLocationAndActiveStatus
(
String
location
,
boolean
activeStatus
);
}
src/main/java/com/nisum/mytime/service/IProjectService.java
View file @
cf947c85
...
...
@@ -7,17 +7,17 @@ import java.util.Set;
import
org.bson.types.ObjectId
;
import
com.nisum.mytime.exception.handler.MyTimeException
;
import
com.nisum.mytime.model.Billing
Details
;
import
com.nisum.mytime.model.Billing
;
import
com.nisum.mytime.model.EmpLoginData
;
import
com.nisum.mytime.model.EmployeeDashboardVO
;
import
com.nisum.mytime.model.Employee
;
import
com.nisum.mytime.model.Project
;
import
com.nisum.mytime.model.
ProjectTeamMat
e
;
import
com.nisum.mytime.model.
Resourc
e
;
public
interface
IProjectService
{
public
ProjectTeamMat
e
addNewBeanchAllocation
(
Employee
employee
,
String
loginEmpId
);
public
Resourc
e
addNewBeanchAllocation
(
Employee
employee
,
String
loginEmpId
);
List
<
EmpLoginData
>
employeeLoginsBasedOnDate
(
long
id
,
String
fromDate
,
String
toDate
)
throws
MyTimeException
;
...
...
@@ -37,58 +37,58 @@ public interface IProjectService {
Employee
getEmployeesRoleData
(
String
empId
);
List
<
ProjectTeamMat
e
>
getTeamDetails
(
String
empId
);
List
<
Resourc
e
>
getTeamDetails
(
String
empId
);
//MT-72
List
<
ProjectTeamMat
e
>
getProjectInfo
(
String
empId
);
List
<
Resourc
e
>
getProjectInfo
(
String
empId
);
public
ProjectTeamMate
addProjectTeamMate
(
ProjectTeamMat
e
projectTeamMate
,
String
loginEmpId
)
public
Resource
addProjectTeamMate
(
Resourc
e
projectTeamMate
,
String
loginEmpId
)
throws
MyTimeException
;
String
updateTeammate
(
ProjectTeamMat
e
projectTeamMate
,
String
loginEmpId
)
throws
MyTimeException
;
String
updateTeammate
(
Resourc
e
projectTeamMate
,
String
loginEmpId
)
throws
MyTimeException
;
void
deleteTeammate
(
String
empId
,
String
projectId
,
ObjectId
id
,
String
loginEmpId
);
List
<
Project
>
getProjects
(
String
managerId
)
throws
MyTimeException
;
List
<
ProjectTeamMat
e
>
getMyTeamDetails
(
String
empId
);
List
<
Resourc
e
>
getMyTeamDetails
(
String
empId
);
List
<
Employee
>
getUnAssignedEmployees
();
List
<
ProjectTeamMat
e
>
getShiftDetails
(
String
shift
);
List
<
Resourc
e
>
getShiftDetails
(
String
shift
);
List
<
ProjectTeamMat
e
>
getAllProjectDetails
();
List
<
Resourc
e
>
getAllProjectDetails
();
List
<
ProjectTeamMat
e
>
getProjectDetails
(
String
projectId
,
String
status
);
List
<
Resourc
e
>
getProjectDetails
(
String
projectId
,
String
status
);
public
List
<
ProjectTeamMat
e
>
getMyProjectAllocations
(
String
empId
);
public
List
<
Resourc
e
>
getMyProjectAllocations
(
String
empId
);
List
<
Billing
Details
>
getEmployeeBillingDetails
(
String
empId
,
List
<
Billing
>
getEmployeeBillingDetails
(
String
empId
,
String
projectId
);
Billing
Details
addEmployeeBillingDetails
(
BillingDetails
billingDetails
,
String
loginEmpId
);
Billing
addEmployeeBillingDetails
(
Billing
billingDetails
,
String
loginEmpId
);
Billing
Details
updateEmployeeBilling
(
BillingDetails
billingDetails
,
String
loginEmpId
);
Billing
updateEmployeeBilling
(
Billing
billingDetails
,
String
loginEmpId
);
void
deleteEmployeeBilling
(
Billing
Details
teamMate
);
void
deleteEmployeeBilling
(
Billing
teamMate
);
public
List
<
EmployeeDashboardVO
>
getEmployeesDashBoard
();
List
<
Billing
Details
>
getEmployeeActiveBillingDetails
(
String
empId
,
List
<
Billing
>
getEmployeeActiveBillingDetails
(
String
empId
,
String
projectId
);
List
<
Billing
Details
>
getEmployeeActiveNisumBench
(
String
empId
);
List
<
Billing
>
getEmployeeActiveNisumBench
(
String
empId
);
List
<
Billing
Details
>
getEmployeeBillingDetailsAll
(
String
empId
);
List
<
Billing
>
getEmployeeBillingDetailsAll
(
String
empId
);
public
void
updateShiftDetails
(
ProjectTeamMat
e
existingTeammate
,
String
loginEmpId
);
public
void
updateShiftDetails
(
Resourc
e
existingTeammate
,
String
loginEmpId
);
public
void
addShiftDetails
(
ProjectTeamMat
e
projectTeamMate
,
String
loginEmpId
);
public
void
addShiftDetails
(
Resourc
e
projectTeamMate
,
String
loginEmpId
);
List
<
ProjectTeamMat
e
>
findByAccountAndActiveAndBillableStatus
(
List
<
Resourc
e
>
findByAccountAndActiveAndBillableStatus
(
String
account
,
boolean
status
,
String
billableStatus
);
public
String
addProjectTeamMateWithCheck
(
ProjectTeamMat
e
projectTeamMate
,
String
loginEmpId
)
public
String
addProjectTeamMateWithCheck
(
Resourc
e
projectTeamMate
,
String
loginEmpId
)
throws
MyTimeException
;
public
List
<
HashMap
<
Object
,
Object
>>
projectsInfoByEmpId
(
String
empId
);
...
...
src/main/java/com/nisum/mytime/service/IResourceService.java
0 → 100644
View file @
cf947c85
package
com
.
nisum
.
mytime
.
service
;
import
java.util.List
;
import
org.springframework.stereotype.Service
;
import
com.nisum.mytime.model.Employee
;
import
com.nisum.mytime.model.Resource
;
@Service
public
interface
IResourceService
{
public
Resource
save
(
Resource
resource
);
void
addResources
(
Employee
employee
,
String
loginEmpId
);
void
inactivateResource
(
Employee
employeeReq
,
Employee
employeeUpdated
,
String
loginEmpId
);
public
List
<
Resource
>
getResources
(
String
empId
);
}
src/main/java/com/nisum/mytime/service/IRole
Info
Service.java
→
src/main/java/com/nisum/mytime/service/IRoleService.java
View file @
cf947c85
package
com
.
nisum
.
mytime
.
service
;
import
org.springframework.stereotype.Service
;
import
com.nisum.mytime.exception.handler.MyTimeException
;
import
com.nisum.mytime.model.Role
;
public
interface
IRoleInfoService
{
@Service
public
interface
IRoleService
{
public
Role
addRole
(
Role
roleInfo
)
throws
MyTimeException
;
...
...
src/main/java/com/nisum/mytime/service/IUploadXLService.java
0 → 100644
View file @
cf947c85
package
com
.
nisum
.
mytime
.
service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.web.multipart.MultipartFile
;
import
com.nisum.mytime.exception.handler.MyTimeException
;
@Service
public
interface
IUploadXLService
{
String
importDataFromExcelFile
(
MultipartFile
file
,
String
empId
)
throws
MyTimeException
;
}
src/main/java/com/nisum/mytime/service/impl/AccountService.java
View file @
cf947c85
...
...
@@ -22,12 +22,15 @@ import com.nisum.mytime.model.Account;
import
com.nisum.mytime.model.Employee
;
import
com.nisum.mytime.repository.AccountRepo
;
import
com.nisum.mytime.service.IAccountService
;
import
com.nisum.mytime.service.IRole
Info
Service
;
import
com.nisum.mytime.service.I
RoleMapping
Service
;
import
com.nisum.mytime.service.IRoleService
;
import
com.nisum.mytime.service.I
EmployeeRole
Service
;
import
com.nisum.mytime.utils.CommomUtil
;
import
com.nisum.mytime.utils.MyTimeUtils
;
import
lombok.extern.slf4j.Slf4j
;
@Service
@Slf4j
public
class
AccountService
implements
IAccountService
{
@Autowired
...
...
@@ -37,12 +40,11 @@ public class AccountService implements IAccountService {
private
MongoTemplate
mongoTemplate
;
@Autowired
private
IRole
Info
Service
roleInfoService
;
private
IRoleService
roleInfoService
;
@Autowired
private
I
RoleMapping
Service
roleMappingService
;
private
I
EmployeeRole
Service
roleMappingService
;
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
AccountService
.
class
);
@Override
public
Account
createAccount
(
Account
accountReq
)
throws
MyTimeException
{
...
...
@@ -50,16 +52,16 @@ public class AccountService implements IAccountService {
accountReq
.
setAccountId
(
generateAccountId
());
accountReq
.
setStatus
(
MyTimeUtils
.
STRING_Y
);
Account
accountPersisted
=
accountRepo
.
save
(
accountReq
);
if
(
log
ger
.
isInfoEnabled
())
{
log
ger
.
info
(
"Account has been persisted in database with account details::"
+
accountPersisted
);
if
(
log
.
isInfoEnabled
())
{
log
.
info
(
"Account has been persisted in database with account details::"
+
accountPersisted
);
}
if
(
accountPersisted
!=
null
)
{
List
<
String
>
accountDmsList
=
accountReq
.
getDeliveryManagers
();
if
(
accountDmsList
!=
null
&&
!
accountDmsList
.
isEmpty
()
&&
accountDmsList
.
size
()
>
0
)
{
String
roleId
=
roleInfoService
.
getRole
(
MyTimeUtils
.
ACCOUNT
);
log
ger
.
info
(
"Going to add DM role id for account delivery managers::::"
+
accountDmsList
);
log
.
info
(
"Going to add DM role id for account delivery managers::::"
+
accountDmsList
);
roleMappingService
.
saveUniqueEmployeeAndRole
(
accountDmsList
,
roleId
);
log
ger
.
info
(
"Added roleids for delivery managers in rolemapping collection"
);
log
.
info
(
"Added roleids for delivery managers in rolemapping collection"
);
}
}
...
...
@@ -73,15 +75,15 @@ public class AccountService implements IAccountService {
accountUpdating
.
setStatus
(
accountBeforeUpdate
.
getStatus
());
accountUpdating
.
setAccountName
(
accountUpdating
.
getAccountName
().
trim
());
log
ger
.
info
(
"Updating the roleids of DeliveryManagers in RoleMapping Collection"
);
log
.
info
(
"Updating the roleids of DeliveryManagers in RoleMapping Collection"
);
final
String
roleId
=
roleInfoService
.
getRole
(
MyTimeUtils
.
ACCOUNT
);
updateRoleIdsForDeliveryManager
(
accountUpdating
,
roleId
);
log
ger
.
info
(
"Deleting the roleids of DeliveryManagers in RoleMapping Collection"
);
log
.
info
(
"Deleting the roleids of DeliveryManagers in RoleMapping Collection"
);
deleteRoleIdsForDeliveryManager
(
accountUpdating
,
roleId
);
Account
accountUpdated
=
accountRepo
.
save
(
accountUpdating
);
log
ger
.
info
(
"Account updated::"
+
accountUpdated
);
log
.
info
(
"Account updated::"
+
accountUpdated
);
return
accountUpdated
;
}
...
...
@@ -105,8 +107,8 @@ public class AccountService implements IAccountService {
List
<
Map
<
String
,
String
>>
updatedEmployeeList
=
null
;
for
(
Account
account
:
accountRepo
.
findAll
())
{
updatedEmployeeList
=
new
ArrayList
<>();
for
(
Employee
employee
sRole
:
getEmployeeDetails
(
account
))
{
updatedEmployeeList
.
add
(
getEmployeeDetails
(
employee
sRole
));
for
(
Employee
employee
:
getEmployeeDetails
(
account
))
{
updatedEmployeeList
.
add
(
getEmployeeDetails
(
employee
));
}
updatedAccountList
.
add
(
getAccuntDetails
(
account
,
updatedEmployeeList
));
}
...
...
@@ -117,7 +119,7 @@ public class AccountService implements IAccountService {
public
Account
deleteAccount
(
String
accountId
)
throws
MyTimeException
{
// delete the documents for deliveryManagers in rolemapping collection.
log
ger
.
info
(
"After updation:: Deleting the Roleids for DeliveryManagers in RoleMapping collection"
);
log
.
info
(
"After updation:: Deleting the Roleids for DeliveryManagers in RoleMapping collection"
);
deleteRoleidsForDeliveryManagers
(
accountId
);
// updating the status to "InActive".
...
...
@@ -128,7 +130,7 @@ public class AccountService implements IAccountService {
options
.
upsert
(
true
);
Account
updatedAccount
=
mongoTemplate
.
findAndModify
(
query
,
update
,
options
,
Account
.
class
);
log
ger
.
info
(
"The account updated::"
+
updatedAccount
);
log
.
info
(
"The account updated::"
+
updatedAccount
);
return
updatedAccount
;
}
...
...
@@ -237,4 +239,11 @@ public class AccountService implements IAccountService {
}
}
@Override
public
List
<
Account
>
getAccountsAll
()
throws
MyTimeException
{
return
accountRepo
.
findAll
();
}
}
src/main/java/com/nisum/mytime/service/impl/AttendanceService.java
View file @
cf947c85
...
...
@@ -21,8 +21,8 @@ import com.nisum.mytime.configuration.DbConnection;
import
com.nisum.mytime.exception.handler.MyTimeException
;
import
com.nisum.mytime.model.AttendenceData
;
import
com.nisum.mytime.model.EmpLoginData
;
import
com.nisum.mytime.model.
ProjectTeamMat
e
;
import
com.nisum.mytime.repository.
ProjectTeamMates
Repo
;
import
com.nisum.mytime.model.
Resourc
e
;
import
com.nisum.mytime.repository.
Resource
Repo
;
import
com.nisum.mytime.service.IAttendanceService
;
import
com.nisum.mytime.utils.CommomUtil
;
import
com.nisum.mytime.utils.MyTimeLogger
;
...
...
@@ -39,7 +39,7 @@ public class AttendanceService implements IAttendanceService {
DbConnection
dbConnection
;
@Autowired
ProjectTeamMates
Repo
projectTeamMatesRepo
;
Resource
Repo
projectTeamMatesRepo
;
@Autowired
private
PdfReportGenerator
pdfReportGenerator
;
...
...
@@ -67,11 +67,14 @@ public class AttendanceService implements IAttendanceService {
return
pdfReportGenerator
.
generateEmployeeReport
(
id
,
fromDate
,
toDate
);
}
private
List
<
AttendenceData
>
getEmpsAttendenceByShiftWise
(
String
reportDate
,
String
shift
)
throws
MyTimeException
{
List
<
AttendenceData
>
listOfEmployees
=
new
ArrayList
<
AttendenceData
>();
Optional
<
List
<
ProjectTeamMat
e
>>
list
=
findEmpIdsByShiftWise
(
shift
);
Optional
<
List
<
Resourc
e
>>
list
=
findEmpIdsByShiftWise
(
shift
);
if
(
list
.
isPresent
())
{
List
<
String
>
empIdList
=
list
.
get
().
stream
().
map
(
ProjectTeamMat
e:
:
getEmployeeId
).
collect
(
Collectors
.
toList
());
List
<
String
>
empIdList
=
list
.
get
().
stream
().
map
(
Resourc
e:
:
getEmployeeId
).
collect
(
Collectors
.
toList
());
if
(
null
!=
empIdList
&&
empIdList
.
size
()
>
MyTimeUtils
.
INT_ZERO
)
{
String
query
=
buildSqlQuery
(
reportDate
,
empIdList
.
toString
().
substring
(
1
,
empIdList
.
toString
().
length
()-
1
),
MyTimeUtils
.
PRESENT
);
listOfEmployees
.
addAll
(
getAttendenceData
(
query
,
MyTimeUtils
.
PRESENT
));
...
...
@@ -87,8 +90,8 @@ public class AttendanceService implements IAttendanceService {
return
listOfEmployees
;
}
private
Optional
<
List
<
ProjectTeamMat
e
>>
findEmpIdsByShiftWise
(
String
shift
)
{
Optional
<
List
<
ProjectTeamMat
e
>>
list
=
null
;
private
Optional
<
List
<
Resourc
e
>>
findEmpIdsByShiftWise
(
String
shift
)
{
Optional
<
List
<
Resourc
e
>>
list
=
null
;
if
(
MyTimeUtils
.
ALL
.
equalsIgnoreCase
(
shift
))
{
list
=
projectTeamMatesRepo
.
findByActiveAndShiftLikeOrderByEmployeeIdDesc
(
true
,
MyTimeUtils
.
SHIFT
);
}
else
{
...
...
@@ -129,6 +132,27 @@ public class AttendanceService implements IAttendanceService {
}
return
listOfEmployees
;
}
// @Override
public
Boolean
fetchEmployeesData
(
String
perticularDate
,
boolean
resynchFlag
)
throws
MyTimeException
{
return
true
;
}
// @Override
public
List
<
EmpLoginData
>
employeeLoginsBasedOnDate
(
long
id
,
String
fromDate
,
String
toDate
)
throws
MyTimeException
{
return
employeeDataBaseService
.
fetchEmployeeLoginsBasedOnDates
(
id
,
fromDate
,
toDate
);
}
@Override
public
List
generatePdfReport
(
long
id
,
String
fromDate
,
String
toDate
)
throws
MyTimeException
{
return
pdfReportGenerator
.
generateEmployeeReport
(
id
,
fromDate
,
toDate
);
}
}
src/main/java/com/nisum/mytime/service/impl/BillingService.java
0 → 100644
View file @
cf947c85
package
com
.
nisum
.
mytime
.
service
.
impl
;
import
java.util.Comparator
;
import
java.util.List
;
import
java.util.stream.Collectors
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.mongodb.core.MongoTemplate
;
import
org.springframework.data.mongodb.core.query.Criteria
;
import
org.springframework.data.mongodb.core.query.Query
;
import
org.springframework.stereotype.Service
;
import
com.nisum.mytime.model.Billing
;
import
com.nisum.mytime.model.Employee
;
import
com.nisum.mytime.repository.BillingRepo
;
import
com.nisum.mytime.service.IBillingService
;
import
com.nisum.mytime.utils.MyTimeUtils
;
import
lombok.extern.slf4j.Slf4j
;
@Service
@Slf4j
public
class
BillingService
implements
IBillingService
{
@Autowired
private
BillingRepo
billingRepo
;
@Autowired
private
MongoTemplate
mongoTemplate
;
@Override
public
List
<
Billing
>
getEmployeeActiveBillingDetails
(
String
empId
,
String
projectId
)
{
Query
query4
=
new
Query
();
query4
.
addCriteria
(
Criteria
.
where
(
"active"
).
is
(
new
Boolean
(
true
)));
query4
.
addCriteria
(
Criteria
.
where
(
"employeeId"
).
is
(
empId
));
query4
.
addCriteria
(
Criteria
.
where
(
"projectId"
).
is
(
projectId
));
List
<
Billing
>
billings
=
mongoTemplate
.
find
(
query4
,
Billing
.
class
);
List
<
Billing
>
billingsSorted
=
billings
;
try
{
billingsSorted
=
(
billings
==
null
||
billings
.
size
()
==
0
)
?
billings
:
billings
.
stream
().
sorted
(
Comparator
.
comparing
(
Billing:
:
getBillingStartDate
).
reversed
())
.
collect
(
Collectors
.
toList
());
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
billingsSorted
;
}
public
Billing
addBillingtoResource
(
Billing
billing
,
Employee
employee
,
String
loginEmpId
)
{
billing
.
setBillingEndDate
(
employee
.
getEndDate
());
billing
.
setActive
(
false
);
billing
.
setAuditFields
(
loginEmpId
,
MyTimeUtils
.
UPDATE
);
return
billingRepo
.
save
(
billing
);
}
}
src/main/java/com/nisum/mytime/service/impl/DesignationService.java
View file @
cf947c85
...
...
@@ -9,6 +9,7 @@ import com.nisum.mytime.exception.handler.MyTimeException;
import
com.nisum.mytime.model.Designation
;
import
com.nisum.mytime.repository.DesignationRepo
;
import
com.nisum.mytime.service.IDesignationService
;
@Service
public
class
DesignationService
implements
IDesignationService
{
...
...
src/main/java/com/nisum/mytime/service/impl/DomainService.java
View file @
cf947c85
...
...
@@ -22,16 +22,19 @@ import com.nisum.mytime.model.Domain;
import
com.nisum.mytime.model.Employee
;
import
com.nisum.mytime.repository.DomainRepo
;
import
com.nisum.mytime.service.IDomainService
;
import
com.nisum.mytime.service.IRole
Info
Service
;
import
com.nisum.mytime.service.I
RoleMapping
Service
;
import
com.nisum.mytime.service.IRoleService
;
import
com.nisum.mytime.service.I
EmployeeRole
Service
;
import
com.nisum.mytime.utils.CommomUtil
;
import
com.nisum.mytime.utils.MyTimeUtils
;
import
lombok.extern.slf4j.Slf4j
;
/**
* @author Vijay
*
*/
@Service
@Slf4j
public
class
DomainService
implements
IDomainService
{
@Autowired
...
...
@@ -41,12 +44,12 @@ public class DomainService implements IDomainService {
private
MongoTemplate
mongoTemplate
;
@Autowired
private
IRole
Info
Service
roleInfoService
;
private
IRoleService
roleInfoService
;
@Autowired
private
IRoleMappingService
roleMappingService
;
private
IEmployeeRoleService
roleMappingService
;
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
DomainService
.
class
);
public
boolean
isDomainExists
(
Domain
domainReq
)
{
boolean
isDomainExists
=
false
;
...
...
@@ -83,16 +86,16 @@ public class DomainService implements IDomainService {
@Override
public
Domain
update
(
Domain
domainReq
)
throws
MyTimeException
{
log
ger
.
info
(
"updating the roles for DeliveryManager in EmployeeRoleMapping collection"
);
log
.
info
(
"updating the roles for DeliveryManager in EmployeeRoleMapping collection"
);
final
String
roleId
=
roleInfoService
.
getRole
(
MyTimeUtils
.
DOMAIN
);
updateRoleIdsForDMs
(
domainReq
,
roleId
);
log
ger
.
info
(
"deleting roleids for DeliveryManagers in EmployeeRoleMapping collection"
);
log
.
info
(
"deleting roleids for DeliveryManagers in EmployeeRoleMapping collection"
);
deleteRoleIdsForDMs
(
domainReq
,
roleId
);
log
ger
.
info
(
"updating the domain details"
);
log
.
info
(
"updating the domain details"
);
domainReq
.
setStatus
(
MyTimeUtils
.
ACTIVE
);
Domain
domainPersisted
=
domainRepo
.
save
(
domainReq
);
log
ger
.
info
(
"After update the domain details::"
+
domainPersisted
);
log
.
info
(
"After update the domain details::"
+
domainPersisted
);
return
domainPersisted
;
}
...
...
src/main/java/com/nisum/mytime/service/impl/EmployeeLocationService.java
View file @
cf947c85
package
com
.
nisum
.
mytime
.
service
.
impl
;
import
java.util.Calendar
;
import
java.util.Date
;
import
java.util.List
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.mongodb.core.MongoTemplate
;
import
org.springframework.data.mongodb.core.query.Criteria
;
import
org.springframework.data.mongodb.core.query.Query
;
import
org.springframework.stereotype.Service
;
import
com.nisum.mytime.model.Employee
;
import
com.nisum.mytime.model.EmployeeLocation
Details
;
import
com.nisum.mytime.repository.EmployeeLocation
Details
Repo
;
import
com.nisum.mytime.model.EmployeeLocation
;
import
com.nisum.mytime.repository.EmployeeLocationRepo
;
import
com.nisum.mytime.service.IEmployeeLocationService
;
import
lombok.extern.slf4j.Slf4j
;
@Service
public
class
EmployeeLocationService
implements
IEmployeeLocationService
{
@Slf4j
public
class
EmployeeLocationService
implements
IEmployeeLocationService
{
@Autowired
private
EmployeeLocationRepo
employeeLocationRepo
;
@Autowired
private
EmployeeLocationDetailsRepo
employeeLocationDetailsRepo
;
private
MongoTemplate
mongoTemplate
;
@Override
public
void
saveEmployeeLocationDetails
(
Employee
employee
)
{
EmployeeLocationDetails
employeeLocationDetails
=
new
EmployeeLocationDetails
();
employeeLocationDetails
.
setActive
(
employee
.
getEmpStatus
().
equalsIgnoreCase
(
"Active"
));
employeeLocationDetails
.
setEmployeeId
(
employee
.
getEmployeeId
());
employeeLocationDetails
.
setEmployeeName
(
employee
.
getEmployeeName
());
employeeLocationDetails
.
setCreateDate
(
new
Date
());
employeeLocationDetails
.
setEndDate
(
new
Date
());
employeeLocationDetails
.
setUpdatedDate
(
new
Date
());
employeeLocationDetails
.
setStartDate
(
new
Date
());
employeeLocationDetails
.
setEmpLocation
(
employee
.
getEmpLocation
());
employeeLocationDetailsRepo
.
save
(
employeeLocationDetails
);
public
void
save
(
Employee
employee
)
{
EmployeeLocation
employeeLocation
=
new
EmployeeLocation
();
employeeLocation
.
setActive
(
employee
.
getEmpStatus
().
equalsIgnoreCase
(
"Active"
));
employeeLocation
.
setEmployeeId
(
employee
.
getEmployeeId
());
employeeLocation
.
setEmployeeName
(
employee
.
getEmployeeName
());
employeeLocation
.
setCreateDate
(
new
Date
());
employeeLocation
.
setEndDate
(
new
Date
());
employeeLocation
.
setUpdatedDate
(
new
Date
());
employeeLocation
.
setStartDate
(
new
Date
());
employeeLocation
.
setEmpLocation
(
employee
.
getEmpLocation
());
employeeLocationRepo
.
save
(
employeeLocation
);
}
@Override
public
List
<
EmployeeLocationDetails
>
getEmployeeLocationDetails
(
String
empId
)
{
return
employeeLocationDetailsRepo
.
findByEmployeeId
(
empId
);
public
List
<
EmployeeLocation
>
getEmployeeLocations
(
String
empId
)
{
List
<
EmployeeLocation
>
empLocationList
=
employeeLocationRepo
.
findByEmployeeId
(
empId
);
log
.
info
(
"The Employee Locations: findByEmployeeId"
+
empLocationList
);
return
empLocationList
;
}
@Override
public
void
update
(
Employee
employee
,
boolean
delete
)
{
try
{
Query
getQuery
=
new
Query
();
getQuery
.
addCriteria
(
new
Criteria
().
andOperator
(
Criteria
.
where
(
"active"
).
is
(
true
),
Criteria
.
where
(
"employeeId"
).
is
(
employee
.
getEmployeeId
())));
Calendar
cal
=
Calendar
.
getInstance
();
cal
.
add
(
Calendar
.
DATE
,
-
1
);
EmployeeLocation
existingLocation
=
mongoTemplate
.
findOne
(
getQuery
,
EmployeeLocation
.
class
);
if
(
existingLocation
!=
null
)
{
existingLocation
.
setActive
(
false
);
existingLocation
.
setEndDate
(
cal
.
getTime
());
existingLocation
.
setUpdatedDate
(
new
Date
());
mongoTemplate
.
save
(
existingLocation
);
}
if
(!
delete
)
save
(
employee
);
}
catch
(
Exception
ex
)
{
System
.
out
.
println
(
ex
);
}
}
}
src/main/java/com/nisum/mytime/service/impl/
RoleMapping
Service.java
→
src/main/java/com/nisum/mytime/service/impl/
EmployeeRole
Service.java
View file @
cf947c85
...
...
@@ -16,24 +16,25 @@ import org.springframework.stereotype.Service;
import
com.mongodb.WriteResult
;
import
com.nisum.mytime.exception.handler.MyTimeException
;
import
com.nisum.mytime.model.
RoleMappingInfo
;
import
com.nisum.mytime.repository.Role
Info
Repo
;
import
com.nisum.mytime.repository.
RoleMappingInfo
Repo
;
import
com.nisum.mytime.service.I
RoleMapping
Service
;
import
com.nisum.mytime.model.
EmployeeRole
;
import
com.nisum.mytime.repository.RoleRepo
;
import
com.nisum.mytime.repository.
EmployeeRole
Repo
;
import
com.nisum.mytime.service.I
EmployeeRole
Service
;
import
com.nisum.mytime.utils.MyTimeUtils
;
@Service
public
class
RoleMappingService
implements
IRoleMapping
Service
{
public
class
EmployeeRoleService
implements
IEmployeeRole
Service
{
@Autowired
private
RoleMappingInfoRepo
roleMappingInfo
Repo
;
private
EmployeeRoleRepo
employeeRole
Repo
;
@Autowired
private
Role
InfoRepo
roleInfo
Repo
;
private
Role
Repo
role
Repo
;
@Autowired
private
MongoTemplate
mongoTemplate
;
@Override
public
void
saveUniqueEmployeeAndRole
(
List
<
String
>
employeeIds
,
String
roleId
)
throws
MyTimeException
{
for
(
String
employeeId
:
employeeIds
)
{
...
...
@@ -42,10 +43,10 @@ public class RoleMappingService implements IRoleMappingService {
}
public
void
addEmployeeRole
(
String
employeeId
,
String
roleId
)
throws
MyTimeException
{
RoleMappingInfo
roleMappingInfo
=
roleMappingInfo
Repo
.
findByEmployeeIdAndRoleId
(
employeeId
,
roleId
);
EmployeeRole
roleMappingInfo
=
employeeRole
Repo
.
findByEmployeeIdAndRoleId
(
employeeId
,
roleId
);
boolean
isChanged
=
false
;
if
(
roleMappingInfo
==
null
)
{
roleMappingInfo
=
new
RoleMappingInfo
();
roleMappingInfo
=
new
EmployeeRole
();
roleMappingInfo
.
setEmployeeId
(
employeeId
);
roleMappingInfo
.
setRoleId
(
roleId
);
roleMappingInfo
.
setIsActive
(
"Y"
);
...
...
@@ -55,16 +56,22 @@ public class RoleMappingService implements IRoleMappingService {
isChanged
=
true
;
}
if
(
isChanged
)
{
roleMappingInfo
Repo
.
save
(
roleMappingInfo
);
employeeRole
Repo
.
save
(
roleMappingInfo
);
}
}
@Override
public
List
<
EmployeeRole
>
findByEmployeeId
(
String
employeeId
)
{
return
employeeRoleRepo
.
findByEmployeeId
(
employeeId
);
}
@Override
public
WriteResult
deleteRole
(
String
employeeId
,
String
roleId
)
throws
MyTimeException
{
Query
query
=
new
Query
(
Criteria
.
where
(
"employeeId"
).
is
(
employeeId
).
and
(
"roleId"
).
is
(
roleId
));
Update
update
=
new
Update
();
update
.
set
(
MyTimeUtils
.
IS_ACTIVE
,
"N"
);
return
mongoTemplate
.
upsert
(
query
,
update
,
RoleMappingInfo
.
class
);
return
mongoTemplate
.
upsert
(
query
,
update
,
EmployeeRole
.
class
);
}
@Override
...
...
@@ -72,17 +79,17 @@ public class RoleMappingService implements IRoleMappingService {
Map
<
Integer
,
String
>
roleInfoMap
=
new
LinkedHashMap
<
Integer
,
String
>();
String
roleName
=
null
;
List
<
RoleMappingInfo
>
listOfEmployeeRoles
=
roleMappingInfo
Repo
.
findByEmployeeId
(
employeeId
).
stream
()
List
<
EmployeeRole
>
listOfEmployeeRoles
=
employeeRole
Repo
.
findByEmployeeId
(
employeeId
).
stream
()
.
filter
(
e
->
(
"N"
.
equalsIgnoreCase
(
e
.
getIsActive
()))).
collect
(
Collectors
.
toList
());
if
(
listOfEmployeeRoles
!=
null
&&
listOfEmployeeRoles
.
size
()
>
0
)
{
for
(
RoleMappingInfo
employee
:
listOfEmployeeRoles
)
{
roleInfoMap
.
put
((
role
Info
Repo
.
findByRoleId
(
employee
.
getRoleId
())).
getPriority
(),
employee
.
getRoleId
());
for
(
EmployeeRole
employee
:
listOfEmployeeRoles
)
{
roleInfoMap
.
put
((
roleRepo
.
findByRoleId
(
employee
.
getRoleId
())).
getPriority
(),
employee
.
getRoleId
());
}
roleInfoMap
=
roleInfoMap
.
entrySet
().
stream
().
sorted
(
Map
.
Entry
.
comparingByKey
()).
collect
(
Collectors
.
toMap
(
Map
.
Entry
::
getKey
,
Map
.
Entry
::
getValue
,
(
oldValue
,
newValue
)
->
oldValue
,
LinkedHashMap:
:
new
));
if
(!
roleInfoMap
.
isEmpty
())
{
Map
.
Entry
<
Integer
,
String
>
entry
=
roleInfoMap
.
entrySet
().
iterator
().
next
();
roleName
=
role
Info
Repo
.
findByRoleId
(
entry
.
getValue
()).
getRoleName
();
roleName
=
roleRepo
.
findByRoleId
(
entry
.
getValue
()).
getRoleName
();
}
}
return
roleName
;
...
...
@@ -92,11 +99,11 @@ public class RoleMappingService implements IRoleMappingService {
@Override
public
Set
<
String
>
empRolesMapInfoByEmpId
(
String
employeeId
)
{
Set
<
String
>
roleSet
=
new
HashSet
<
String
>();
List
<
RoleMappingInfo
>
listOfEmployeeRoles
=
roleMappingInfo
Repo
.
findByEmployeeId
(
employeeId
).
stream
().
filter
(
e
->(
List
<
EmployeeRole
>
listOfEmployeeRoles
=
employeeRole
Repo
.
findByEmployeeId
(
employeeId
).
stream
().
filter
(
e
->(
"N"
.
equalsIgnoreCase
(
e
.
getIsActive
()))).
collect
(
Collectors
.
toList
());
if
(
null
!=
listOfEmployeeRoles
&&
!
listOfEmployeeRoles
.
isEmpty
()
&&
MyTimeUtils
.
INT_ZERO
<
listOfEmployeeRoles
.
size
())
{
for
(
RoleMappingInfo
obj
:
listOfEmployeeRoles
)
{
for
(
EmployeeRole
obj
:
listOfEmployeeRoles
)
{
roleSet
.
add
(
obj
.
getRoleId
());
}
}
...
...
src/main/java/com/nisum/mytime/service/impl/EmployeeService.java
View file @
cf947c85
package
com
.
nisum
.
mytime
.
service
.
impl
;
import
java.lang.reflect.InvocationTargetException
;
import
java.lang.reflect.Method
;
import
java.text.ParseException
;
import
java.util.ArrayList
;
import
java.util.Calendar
;
import
java.util.Comparator
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Set
;
import
java.util.stream.Collectors
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Sort
;
import
org.springframework.data.mongodb.core.FindAndModifyOptions
;
...
...
@@ -20,213 +15,102 @@ 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.mongodb.WriteResult
;
import
com.nisum.mytime.exception.handler.MyTimeException
;
import
com.nisum.mytime.model.Account
;
import
com.nisum.mytime.model.AccountInfo
;
import
com.nisum.mytime.model.BillingDetails
;
import
com.nisum.mytime.model.Designation
;
import
com.nisum.mytime.model.Domain
;
import
com.nisum.mytime.model.EmpLoginData
;
import
com.nisum.mytime.model.EmpShiftDetails
;
import
com.nisum.mytime.model.EmployeeLocationDetails
;
import
com.nisum.mytime.model.Employee
;
import
com.nisum.mytime.model.Location
;
import
com.nisum.mytime.model.MasterData
;
import
com.nisum.mytime.model.Project
;
import
com.nisum.mytime.model.ProjectTeamMate
;
import
com.nisum.mytime.model.Shift
;
import
com.nisum.mytime.model.Skill
;
import
com.nisum.mytime.repository.AccountInfoRepo
;
import
com.nisum.mytime.repository.AccountRepo
;
import
com.nisum.mytime.repository.DesignationRepo
;
import
com.nisum.mytime.repository.DomainRepo
;
import
com.nisum.mytime.repository.EmployeeLocationDetailsRepo
;
import
com.nisum.mytime.model.EmployeeRole
;
import
com.nisum.mytime.model.Resource
;
import
com.nisum.mytime.repository.EmployeeRepo
;
import
com.nisum.mytime.repository.LocationRepo
;
import
com.nisum.mytime.repository.MasterDataRepo
;
import
com.nisum.mytime.repository.ProjectRepo
;
import
com.nisum.mytime.repository.ProjectTeamMatesRepo
;
import
com.nisum.mytime.repository.ShiftRepo
;
import
com.nisum.mytime.repository.TeamMatesBillingRepo
;
import
com.nisum.mytime.service.IAccountService
;
import
com.nisum.mytime.service.IDomainService
;
import
com.nisum.mytime.service.IEmployeeLocationService
;
import
com.nisum.mytime.service.IEmployeeRoleService
;
import
com.nisum.mytime.service.IEmployeeService
;
import
com.nisum.mytime.service.IProjectService
;
import
com.nisum.mytime.service.IRoleMappingService
;
import
com.nisum.mytime.repository.SkillRepo
;
import
com.nisum.mytime.utils.DataValidations
;
import
com.nisum.mytime.service.IResourceService
;
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"
)
@Service
@Slf4j
public
class
EmployeeService
implements
IEmployeeService
{
@Autowired
private
EmployeeRepo
employeeRepo
;
@Autowired
private
ProjectRepo
projectRepo
;
@Autowired
private
ProjectTeamMatesRepo
projectTeamMatesRepo
;
@Autowired
private
IProjectService
projectService
;
// @Autowired
// private AccountRepo accountRepo;
@Autowired
DomainService
domainService
;
//@Autowired
//private MasterDataRepo masterDataRepo;
//@Autowired
// private TechnologyRepo technologyRepo;
//@Autowired
// private LocationRepo locationRepo;
@Autowired
private
EmployeeDataService
employeeDataBaseService
;
@Autowired
private
PdfReportGenerator
pdfReportGenerator
;
@Autowired
private
MongoTemplate
mongoTemplate
;
// @Autowired
// private EmployeeLocationDetailsRepo employeeLocationDetailsRepo;
//@Autowired
// private DomainRepo domainRepo;
@Autowired
private
AccountInfoRepo
accountInfoRepo
;
private
IAccountService
accountService
;
@Autowired
private
TeamMatesBillingRepo
teamMatesBillingRepo
;
private
IProjectService
projectService
;
@Autowired
private
IRoleMappingService
roleMapping
Service
;
private
IDomainService
domain
Service
;
@Autowired
EmployeeLocationService
empLocationService
;
private
IEmployeeRoleService
employeeRoleService
;
@Autowired
AccountService
accountService
;
@Override
public
Boolean
fetchEmployeesData
(
String
perticularDate
,
boolean
resynchFlag
)
throws
MyTimeException
{
return
true
;
}
@Override
public
List
<
EmpLoginData
>
employeeLoginsBasedOnDate
(
long
id
,
String
fromDate
,
String
toDate
)
throws
MyTimeException
{
return
employeeDataBaseService
.
fetchEmployeeLoginsBasedOnDates
(
id
,
fromDate
,
toDate
);
}
@Override
public
List
generatePdfReport
(
long
id
,
String
fromDate
,
String
toDate
)
throws
MyTimeException
{
return
pdfReportGenerator
.
generateEmployeeReport
(
id
,
fromDate
,
toDate
);
}
@Override
public
List
generatePdfReport
(
long
id
,
String
fromDate
,
String
toDate
,
String
fromTime
,
String
toTime
)
throws
MyTimeException
,
ParseException
{
return
pdfReportGenerator
.
generateEmployeeReport
(
id
,
fromDate
,
toDate
,
fromTime
,
toTime
);
}
private
IEmployeeLocationService
empLocationService
;
@Override
public
List
<
Employee
>
getActiveEmployees
()
throws
MyTimeException
{
//return employeeRolesRepo.findAll();
return
employeeRepo
.
findByEmpStatus
(
MyTimeUtils
.
ACTIVE
);
}
public
List
<
Employee
>
getManagers
()
throws
MyTimeException
{
List
<
Employee
>
employeesList
=
getActiveEmployees
();
List
<
Employee
>
managers
=
employeesList
.
stream
()
.
filter
(
e
->
(
"Director"
.
equalsIgnoreCase
(
e
.
getRole
())
||
"Delivery Manager"
.
equalsIgnoreCase
(
e
.
getRole
())
||
"Manager"
.
equalsIgnoreCase
(
e
.
getRole
())
||
"HR Manager"
.
equalsIgnoreCase
(
e
.
getRole
())
||
"Lead"
.
equalsIgnoreCase
(
e
.
getRole
())))
.
sorted
(
Comparator
.
comparing
(
Employee:
:
getEmployeeName
)).
collect
(
Collectors
.
toList
());
return
managers
;
}
@Autowired
private
IResourceService
resourceService
;
@Override
public
Employee
createEmployee
(
Employee
employeeReq
,
String
loginEmpId
)
throws
MyTimeException
{
employeeReq
.
setCreatedOn
(
new
Date
());
employeeReq
.
setCreatedBy
(
loginEmpId
);
employeeReq
.
setModifiedBy
(
loginEmpId
);
public
Employee
createEmployee
(
Employee
employee
,
String
loginEmpId
)
throws
MyTimeException
{
employee
.
setCreatedOn
(
new
Date
());
employee
.
setCreatedBy
(
loginEmpId
);
employee
.
setModifiedBy
(
loginEmpId
);
//adding new Bench Allocation
projectService
.
addNewBeanchAllocation
(
employeeReq
,
loginEmpId
);
//Saving Location Details.
empLocationService
.
saveEmployeeLocationDetails
(
employeeReq
);
return
employeeRepo
.
save
(
employeeReq
);
}
@Override
public
Employee
getEmployeeByEmaillId
(
String
emailId
)
{
return
employeeRepo
.
findByEmailId
(
emailId
);
// adding employee to Bench Allocation
projectService
.
addNewBeanchAllocation
(
employee
,
loginEmpId
);
}
// Saving employee Location Details.
empLocationService
.
save
(
employee
);
@Override
public
void
deleteEmployee
(
String
employeeId
)
{
Employee
role
=
employeeRepo
.
findByEmployeeId
(
employeeId
);
employeeRepo
.
delete
(
role
);
return
employeeRepo
.
save
(
employee
);
}
@Override
public
Employee
updateEmployeeRole
(
Employee
employeeRoles
,
String
loginEmpId
)
{
public
Employee
updateEmployee
(
Employee
employeeReq
,
String
loginEmpId
)
{
// update all emp details to inactive if employee is inactive
Query
query
=
new
Query
(
Criteria
.
where
(
"employeeId"
).
is
(
employeeRoles
.
getEmployeeId
()));
Query
query
=
new
Query
(
Criteria
.
where
(
"employeeId"
).
is
(
employeeReq
.
getEmployeeId
()));
Update
update
=
new
Update
();
update
.
set
(
"employeeName"
,
employeeRoles
.
getEmployeeName
());
update
.
set
(
"emailId"
,
employeeRoles
.
getEmailId
());
update
.
set
(
"role"
,
employeeRoles
.
getRole
());
update
.
set
(
"gender"
,
employeeRoles
.
getGender
());
update
.
set
(
"functionalGroup"
,
employeeRoles
.
getFunctionalGroup
());
update
.
set
(
"empStatus"
,
employeeRoles
.
getEmpStatus
());
update
.
set
(
"employmentType"
,
employeeRoles
.
getEmploymentType
());
update
.
set
(
"empLocation"
,
employeeRoles
.
getEmpLocation
());
update
.
set
(
"domain"
,
employeeRoles
.
getDomain
());
update
.
set
(
"designation"
,
employeeRoles
.
getDesignation
());
update
.
set
(
"dateOfBirth"
,
employeeRoles
.
getDateOfBirth
());
update
.
set
(
"dateOfJoining"
,
employeeRoles
.
getDateOfJoining
());
update
.
set
(
"employeeName"
,
employeeReq
.
getEmployeeName
());
update
.
set
(
"emailId"
,
employeeReq
.
getEmailId
());
update
.
set
(
"role"
,
employeeReq
.
getRole
());
update
.
set
(
"gender"
,
employeeReq
.
getGender
());
update
.
set
(
"functionalGroup"
,
employeeReq
.
getFunctionalGroup
());
update
.
set
(
"empStatus"
,
employeeReq
.
getEmpStatus
());
update
.
set
(
"employmentType"
,
employeeReq
.
getEmploymentType
());
update
.
set
(
"empLocation"
,
employeeReq
.
getEmpLocation
());
update
.
set
(
"domain"
,
employeeReq
.
getDomain
());
update
.
set
(
"designation"
,
employeeReq
.
getDesignation
());
update
.
set
(
"dateOfBirth"
,
employeeReq
.
getDateOfBirth
());
update
.
set
(
"dateOfJoining"
,
employeeReq
.
getDateOfJoining
());
update
.
set
(
"lastModifiedOn"
,
new
Date
());
update
.
set
(
"hasPassort"
,
employeeRoles
.
getHasPassort
());
update
.
set
(
"hasB1"
,
employeeRoles
.
getHasB1
());
update
.
set
(
"passportExpiryDate"
,
employeeRoles
.
getPassportExpiryDate
());
update
.
set
(
"b1ExpiryDate"
,
employeeRoles
.
getB1ExpiryDate
());
update
.
set
(
"hasPassort"
,
employeeReq
.
getHasPassort
());
update
.
set
(
"hasB1"
,
employeeReq
.
getHasB1
());
update
.
set
(
"passportExpiryDate"
,
employeeReq
.
getPassportExpiryDate
());
update
.
set
(
"b1ExpiryDate"
,
employeeReq
.
getB1ExpiryDate
());
update
.
set
(
"modifiedBy"
,
loginEmpId
);
if
(
employeeRoles
.
getEmpStatus
().
equalsIgnoreCase
(
MyTimeUtils
.
IN_ACTIVE_SPACE
))
{
update
.
set
(
"endDate"
,
employeeRoles
.
getEndDate
());
if
(
employeeReq
.
getEmpStatus
().
equalsIgnoreCase
(
MyTimeUtils
.
IN_ACTIVE_SPACE
))
{
update
.
set
(
"endDate"
,
employeeReq
.
getEndDate
());
}
// update employee location
if
(
employeeRoles
.
getEmpLocation
()
!=
null
&&
!
employeeRoles
.
getEmpLocation
().
equals
(
""
))
{
Employee
existingEmployee
=
employeeRepo
.
findByEmployeeId
(
employeeRoles
.
getEmployeeId
());
if
(!
existingEmployee
.
getEmpLocation
().
equals
(
employeeRoles
.
getEmpLocation
()))
{
updateEmployeeLocationDetails
(
employeeRoles
,
false
);
if
(
employeeReq
.
getEmpLocation
()
!=
null
&&
!
employeeReq
.
getEmpLocation
().
equals
(
""
))
{
Employee
existingEmployee
=
employeeRepo
.
findByEmployeeId
(
employeeReq
.
getEmployeeId
());
if
(!
existingEmployee
.
getEmpLocation
().
equals
(
employeeReq
.
getEmpLocation
()))
{
empLocationService
.
update
(
employeeReq
,
false
);
}
}
...
...
@@ -235,246 +119,104 @@ public class EmployeeService implements IEmployeeService {
FindAndModifyOptions
options
=
new
FindAndModifyOptions
();
options
.
returnNew
(
true
);
options
.
upsert
(
true
);
Employee
emp
=
mongoTemplate
.
findAndModify
(
query
,
update
,
options
,
Employee
.
class
);
try
{
// update employee location
if
(
employeeRoles
.
getEmpLocation
()
!=
null
&&
!
employeeRoles
.
getEmpLocation
().
equals
(
""
))
{
Employee
existingEmployee
=
employeeRepo
.
findByEmployeeId
(
employeeRoles
.
getEmployeeId
());
if
(!
existingEmployee
.
getEmpLocation
().
equals
(
employeeRoles
.
getEmpLocation
()))
{
updateEmployeeLocationDetails
(
employeeRoles
,
false
);
}
}
Employee
employeeUpdated
=
mongoTemplate
.
findAndModify
(
query
,
update
,
options
,
Employee
.
class
);
// update employee details
List
<
ProjectTeamMate
>
employeeProfiles
=
projectTeamMatesRepo
.
findByEmployeeId
(
emp
.
getEmployeeId
());
if
(
employeeProfiles
!=
null
&&
!
employeeProfiles
.
isEmpty
())
{
for
(
ProjectTeamMate
profile
:
employeeProfiles
)
{
profile
.
setRole
(
emp
.
getRole
());
profile
.
setAuditFields
(
loginEmpId
,
MyTimeUtils
.
UPDATE
);
projectTeamMatesRepo
.
save
(
profile
);
}
}
// inactive the employee from the assigned project
if
(
employeeRoles
.
getEmpStatus
().
equals
(
MyTimeUtils
.
IN_ACTIVE_SPACE
)
&&
employeeRoles
.
getEndDate
()
!=
null
&&
employeeRoles
.
getEndDate
().
compareTo
(
new
Date
())
<=
0
)
{
List
<
ProjectTeamMate
>
projectTeamMate
=
projectTeamMatesRepo
.
findByEmployeeIdAndActive
(
employeeRoles
.
getEmployeeId
(),
true
);
if
(
projectTeamMate
.
size
()==
1
)
{
ProjectTeamMate
teamMate
=
projectTeamMate
.
get
(
0
);
teamMate
.
setActive
(
false
);
teamMate
.
setEndDate
(
employeeRoles
.
getEndDate
());
List
<
BillingDetails
>
listBD
=
getEmployeeActiveBillingDetails
(
teamMate
.
getEmployeeId
(),
teamMate
.
getProjectId
());
if
(
listBD
!=
null
&&
!
listBD
.
isEmpty
())
{
BillingDetails
billingDetailsExisting
=
listBD
.
get
(
0
);
billingDetailsExisting
.
setBillingEndDate
(
employeeRoles
.
getEndDate
());
billingDetailsExisting
.
setActive
(
false
);
billingDetailsExisting
.
setAuditFields
(
loginEmpId
,
MyTimeUtils
.
UPDATE
);
teamMatesBillingRepo
.
save
(
billingDetailsExisting
);
}
teamMate
.
setAuditFields
(
loginEmpId
,
MyTimeUtils
.
UPDATE
);
projectTeamMatesRepo
.
save
(
teamMate
);
updateShiftDetails
(
teamMate
,
loginEmpId
);
}
}
}
catch
(
Exception
e
)
{
}
return
emp
;
}
try
{
// add to resource collection
resourceService
.
addResources
(
employeeUpdated
,
loginEmpId
);
@Override
public
Employee
getEmployeesRoleData
(
String
employeeId
)
{
return
employeeRepo
.
findByEmployeeId
(
employeeId
);
}
// inactive the employee from the assigned project.
resourceService
.
inactivateResource
(
employeeReq
,
employeeUpdated
,
loginEmpId
);
/* @Override
public List<Shift> getAllShifts() throws MyTimeException {
return shiftRepo.findAll();
}
catch
(
Exception
e
)
{
}
*/
/* @Override
public List<Designation> getAllDesignations() throws MyTimeException {
return designationRepo.findAll();
return
employeeUpdated
;
}
*/
@Override
public
List
<
Account
>
getAccounts
()
throws
MyTimeException
{
return
accountService
.
getAccounts
();
public
Employee
deleteEmployee
(
String
employeeId
)
{
// Employee employee = employeeRepo.findByEmployeeId(employeeId);
// employee.setEmpStatus("InActive");
// employeeRepo.save(employee);
Query
query
=
new
Query
();
query
.
addCriteria
(
Criteria
.
where
(
"employeeId"
).
is
(
employeeId
));
Update
update
=
new
Update
();
update
.
set
(
"empStatus"
,
"InActive"
);
Employee
employeeUpdated
=
mongoTemplate
.
findAndModify
(
query
,
update
,
Employee
.
class
);
log
.
info
(
"The Deletion operation Result::"
+
employeeUpdated
);
return
employeeUpdated
;
}
/*
@Override
public List<Skill> getTechnologies() throws MyTimeException {
return technologyRepo.findAll();
}
*/
/*
@Override
public List<Location> getLocations() throws MyTimeException {
return locationRepo.findAll();
}
*/
@Override
public
Employee
updateProfile
(
Employee
employeeRoles
)
throws
MyTimeException
{
public
Employee
updateProfile
(
Employee
employeeReq
)
throws
MyTimeException
{
boolean
mobileNumberChanged
=
false
;
employeeRoles
.
setLastModifiedOn
(
new
Date
());
Employee
existingEmployee
=
employeeRepo
.
findByEmployeeId
(
employeeRoles
.
getEmployeeId
());
String
newMobileNumber
=
employeeRoles
.
getMobileNumber
();
employeeReq
.
setLastModifiedOn
(
new
Date
());
Employee
existingEmployee
=
employeeRepo
.
findByEmployeeId
(
employeeReq
.
getEmployeeId
());
String
newMobileNumber
=
employeeReq
.
getMobileNumber
();
if
(
newMobileNumber
!=
null
&&
!
newMobileNumber
.
equalsIgnoreCase
(
""
))
{
if
((
existingEmployee
!=
null
&&
existingEmployee
.
getMobileNumber
()
!=
null
&&
!
existingEmployee
.
getMobileNumber
()
.
equalsIgnoreCase
(
newMobileNumber
))
if
((
existingEmployee
!=
null
&&
existingEmployee
.
getMobileNumber
()
!=
null
&&
!
existingEmployee
.
getMobileNumber
().
equalsIgnoreCase
(
newMobileNumber
))
||
(
existingEmployee
.
getMobileNumber
()
==
null
))
{
mobileNumberChanged
=
true
;
}
}
existingEmployee
.
setMobileNumber
(
employeeRoles
.
getMobileNumber
());
existingEmployee
.
setAlternateMobileNumber
(
employeeRoles
.
getAlternateMobileNumber
());
existingEmployee
.
setPersonalEmailId
(
employeeRoles
.
getPersonalEmailId
());
existingEmployee
.
setBaseTechnology
(
employeeRoles
.
getBaseTechnology
());
existingEmployee
.
setTechnologyKnown
(
employeeRoles
.
getTechnologyKnown
());
Employee
employeeRolesDB
=
employeeRepo
.
save
(
existingEmployee
);
existingEmployee
.
setMobileNumber
(
employeeReq
.
getMobileNumber
());
existingEmployee
.
setAlternateMobileNumber
(
employeeReq
.
getAlternateMobileNumber
());
existingEmployee
.
setPersonalEmailId
(
employeeReq
.
getPersonalEmailId
());
existingEmployee
.
setBaseTechnology
(
employeeReq
.
getBaseTechnology
());
existingEmployee
.
setTechnologyKnown
(
employeeReq
.
getTechnologyKnown
());
Employee
employeePersisted
=
employeeRepo
.
save
(
existingEmployee
);
if
(
mobileNumberChanged
)
{
try
{
List
<
ProjectTeamMate
>
employeeProfiles
=
projectTeamMatesRepo
.
findByEmployeeId
(
employeeRoles
.
getEmployeeId
());
if
(
employeeProfiles
!=
null
&&
!
employeeProfiles
.
isEmpty
())
{
for
(
ProjectTeamMate
profile
:
employeeProfiles
)
{
profile
.
setMobileNumber
(
employeeRolesDB
.
getMobileNumber
());
projectTeamMatesRepo
.
save
(
profil
e
);
List
<
Resource
>
resourcesList
=
resourceService
.
getResources
(
employeeReq
.
getEmployeeId
());
if
(
resourcesList
!=
null
&&
!
resourcesList
.
isEmpty
())
{
for
(
Resource
resource
:
resourcesList
)
{
resource
.
setMobileNumber
(
employeePersisted
.
getMobileNumber
());
resourceService
.
save
(
resourc
e
);
}
}
}
catch
(
Exception
e
)
{
}
}
return
employeeRolesDB
;
}
return
employeePersisted
;
/*
* (non-Javadoc)
*
* @see
* com.nisum.mytime.service.UserService#getEmployeeRoleDataForSearchCriteria
* (java.lang.String, java.lang.String)
*/
@Override
public
Employee
getEmployeeRoleDataForSearchCriteria
(
String
searchId
,
String
searchAttribute
)
{
if
(
MyTimeUtils
.
EMPLOYEE_NAME
.
equals
(
searchAttribute
))
{
return
employeeRepo
.
findByEmployeeName
(
searchId
);
}
else
if
(
MyTimeUtils
.
EMAIL_ID
.
equals
(
searchAttribute
))
{
return
employeeRepo
.
findByEmailId
(
searchId
);
}
return
null
;
}
public
boolean
isEmployeeExistsById
(
String
employeeId
)
{
Employee
employeeFound
=
getEmployeeById
(
employeeId
);
return
(
employeeFound
==
null
)
?
false
:
true
;
/*
* (non-Javadoc)
*
* @see
* com.nisum.mytime.service.UserService#getEmployeeDetailsForAutocomplete()
*/
@Override
public
List
<
String
>
getEmployeeDetailsForAutocomplete
()
{
List
<
Employee
>
roles
=
employeeRepo
.
findAll
();
List
<
String
>
details
=
new
ArrayList
<>();
roles
.
stream
()
.
sorted
(
java
.
util
.
Comparator
.
comparing
(
Employee:
:
getEmployeeId
))
.
collect
(
Collectors
.
toList
()).
forEach
(
role
->
{
details
.
add
(
role
.
getEmployeeId
());
});
roles
.
stream
()
.
sorted
(
java
.
util
.
Comparator
.
comparing
(
Employee:
:
getEmployeeName
))
.
collect
(
Collectors
.
toList
()).
forEach
(
role
->
{
details
.
add
(
role
.
getEmployeeName
());
});
roles
.
stream
()
.
sorted
(
java
.
util
.
Comparator
.
comparing
(
Employee:
:
getEmailId
))
.
collect
(
Collectors
.
toList
()).
forEach
(
role
->
{
details
.
add
(
role
.
getEmailId
());
});
return
details
;
}
/*
@Override
public List<MasterData> getMasterData() throws MyTimeException
{
return masterDataRepo.findAll(
);
public
Employee
getEmployeeById
(
String
employeeId
)
{
return
employeeRepo
.
findByEmployeeId
(
employeeId
);
}
*/
@Override
public
void
updateEmployeeLocationDetails
(
Employee
employeeRoles
,
boolean
delete
)
{
try
{
Query
getQuery
=
new
Query
();
getQuery
.
addCriteria
(
new
Criteria
().
andOperator
(
Criteria
.
where
(
"active"
).
is
(
true
),
Criteria
.
where
(
"employeeId"
)
.
is
(
employeeRoles
.
getEmployeeId
())));
Calendar
cal
=
Calendar
.
getInstance
();
cal
.
add
(
Calendar
.
DATE
,
-
1
);
EmployeeLocationDetails
existingLocation
=
mongoTemplate
.
findOne
(
getQuery
,
EmployeeLocationDetails
.
class
);
if
(
existingLocation
!=
null
)
{
existingLocation
.
setActive
(
false
);
existingLocation
.
setEndDate
(
cal
.
getTime
());
existingLocation
.
setUpdatedDate
(
new
Date
());
mongoTemplate
.
save
(
existingLocation
);
}
if
(!
delete
)
empLocationService
.
saveEmployeeLocationDetails
(
employeeRoles
);
}
catch
(
Exception
ex
)
{
System
.
out
.
println
(
ex
);
}
public
Employee
getEmployeeByEmaillId
(
String
emailId
)
{
return
employeeRepo
.
findByEmailId
(
emailId
);
}
/*
@Override
public void saveEmployeeLocationDetails(Employee employee) {
EmployeeLocationDetails employeeLocationDetails = new EmployeeLocationDetails();
employeeLocationDetails.setActive(employee.getEmpStatus().equalsIgnoreCase("Active"));
employeeLocationDetails.setEmployeeId(employee.getEmployeeId());
employeeLocationDetails.setEmployeeName(employee.getEmployeeName());
employeeLocationDetails.setCreateDate(new Date());
employeeLocationDetails.setEndDate(new Date());
employeeLocationDetails.setUpdatedDate(new Date());
employeeLocationDetails.setStartDate(new Date());
employeeLocationDetails.setEmpLocation(employee.getEmpLocation());
employeeLocationDetailsRepo.save(employeeLocationDetails);
}
*/
/*
@Override
public List<EmployeeLocationDetails> getEmployeeLocationDetails(String empId) {
return employeeLocationDetailsRepo.findByEmployeeId(empId);
public
List
<
Employee
>
getManagers
()
throws
MyTimeException
{
List
<
Employee
>
activeEmpsList
=
getActiveEmployees
();
List
<
Employee
>
managers
=
activeEmpsList
.
stream
()
.
filter
(
e
->
(
"Director"
.
equalsIgnoreCase
(
e
.
getRole
())
||
"Delivery Manager"
.
equalsIgnoreCase
(
e
.
getRole
())
||
"Manager"
.
equalsIgnoreCase
(
e
.
getRole
())
||
"HR Manager"
.
equalsIgnoreCase
(
e
.
getRole
())
||
"Lead"
.
equalsIgnoreCase
(
e
.
getRole
())))
.
sorted
(
Comparator
.
comparing
(
Employee:
:
getEmployeeName
)).
collect
(
Collectors
.
toList
());
return
managers
;
}
*/
@Override
public
List
<
Employee
>
getEmployeesByFunctionalGrp
(
String
functionalGrp
)
{
return
employeeRepo
.
findByEmpStatusAndFunctionalGroup
(
"Active"
,
functionalGrp
);
public
List
<
Employee
>
getActiveEmployees
()
throws
MyTimeException
{
return
employeeRepo
.
findByEmpStatus
(
MyTimeUtils
.
ACTIVE
);
}
@Override
...
...
@@ -486,345 +228,87 @@ public class EmployeeService implements IEmployeeService {
}
}
@Override
public
List
<
HashMap
<
String
,
String
>>
getDeliveryLeads
(
String
domainId
)
{
List
<
HashMap
<
String
,
String
>>
EmployeeList
=
null
;
Domain
domains
=
domainService
.
getDomainById
(
domainId
);
EmployeeList
=
getEmployeeData
(
domains
.
getDeliveryManagers
());
return
EmployeeList
;
}
public
List
<
HashMap
<
String
,
String
>>
getEmployeeData
(
List
ids
)
{
List
<
HashMap
<
String
,
String
>>
EmployeeList
=
new
ArrayList
<>();
public
List
<
Account
>
getAccounts
()
throws
MyTimeException
{
return
accountService
.
getAccounts
();
Query
query
=
new
Query
(
Criteria
.
where
(
"employeeId"
).
in
(
ids
));
List
<
Employee
>
employeeRoles
=
mongoTemplate
.
find
(
query
,
Employee
.
class
);
for
(
Employee
employeesRole
:
employeeRoles
)
{
HashMap
<
String
,
String
>
managerMap
=
new
HashMap
<>();
managerMap
.
put
(
"employeeId"
,
employeesRole
.
getEmployeeId
());
managerMap
.
put
(
"employeeName"
,
employeesRole
.
getEmployeeName
());
EmployeeList
.
add
(
managerMap
);
}
return
EmployeeList
;
}
@Override
public
List
<
AccountInfo
>
getAccountsInfo
()
throws
MyTimeException
{
return
accountInfoRepo
.
findAll
();
}
@Override
public
List
<
Domain
>
getDomains
(
String
accountId
)
throws
MyTimeException
{
return
domainService
.
getDomainsUnderAccount
(
accountId
);
}
public
List
<
BillingDetails
>
getEmployeeActiveBillingDetails
(
String
empId
,
String
projectId
)
{
Query
query4
=
new
Query
();
query4
.
addCriteria
(
Criteria
.
where
(
"active"
).
is
(
new
Boolean
(
true
)));
query4
.
addCriteria
(
Criteria
.
where
(
"employeeId"
).
is
(
empId
));
query4
.
addCriteria
(
Criteria
.
where
(
"projectId"
).
is
(
projectId
));
List
<
BillingDetails
>
billings
=
mongoTemplate
.
find
(
query4
,
BillingDetails
.
class
);
List
<
BillingDetails
>
billingsSorted
=
billings
;
try
{
billingsSorted
=
(
billings
==
null
||
billings
.
size
()
==
0
)
?
billings
:
billings
.
stream
().
sorted
(
Comparator
.
comparing
(
BillingDetails:
:
getBillingStartDate
).
reversed
())
.
collect
(
Collectors
.
toList
());
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
billingsSorted
;
public
Employee
getEmployeeRoleDataForSearchCriteria
(
String
searchId
,
String
searchAttribute
)
{
if
(
MyTimeUtils
.
EMPLOYEE_NAME
.
equals
(
searchAttribute
))
{
return
employeeRepo
.
findByEmployeeName
(
searchId
);
}
else
if
(
MyTimeUtils
.
EMAIL_ID
.
equals
(
searchAttribute
))
{
return
employeeRepo
.
findByEmailId
(
searchId
);
}
return
null
;
public
void
updateShiftDetails
(
ProjectTeamMate
existingTeammate
,
String
loginEmpId
)
{
Query
getQuery
=
new
Query
();
getQuery
.
addCriteria
(
new
Criteria
().
andOperator
(
Criteria
.
where
(
"active"
).
is
(
true
),
Criteria
.
where
(
"employeeId"
).
is
(
existingTeammate
.
getEmployeeId
())));
Calendar
cal
=
Calendar
.
getInstance
();
cal
.
add
(
Calendar
.
DATE
,
-
1
);
EmpShiftDetails
existingShift
=
mongoTemplate
.
findOne
(
getQuery
,
EmpShiftDetails
.
class
);
if
(
existingShift
!=
null
)
{
existingShift
.
setActive
(
false
);
//existingShift.setUpdatedDate(new Date());// Commented as added common audit fields
existingShift
.
setAuditFields
(
loginEmpId
,
MyTimeUtils
.
UPDATE
);
mongoTemplate
.
save
(
existingShift
);
}
}
@Override
public
boolean
verifyRole
(
String
empId
,
String
roleName
)
{
boolean
flag
=
false
;
String
role
=
getEmployeesRoleData
(
empId
).
getRole
();
if
(
null
!=
role
&&
""
!=
role
&&
!
"Admin"
.
equalsIgnoreCase
(
role
)
)
{
Set
<
String
>
roleSet
=
roleMappingService
.
empRolesMapInfoByEmpId
(
empId
);
if
(
null
!=
roleSet
&&
!
roleSet
.
isEmpty
()
&&
MyTimeUtils
.
INT_ZERO
<
roleSet
.
size
()
)
{
if
(
roleSet
.
contains
(
roleName
)
)
{
flag
=
true
;
}
}
}
return
flag
;
public
List
<
String
>
getEmployeeDetailsForAutocomplete
()
{
List
<
Employee
>
employeeList
=
employeeRepo
.
findAll
();
List
<
String
>
resultList
=
new
ArrayList
<>();
employeeList
.
stream
().
sorted
(
java
.
util
.
Comparator
.
comparing
(
Employee:
:
getEmployeeId
))
.
collect
(
Collectors
.
toList
()).
forEach
(
employee
->
{
resultList
.
add
(
employee
.
getEmployeeId
());
});
employeeList
.
stream
().
sorted
(
java
.
util
.
Comparator
.
comparing
(
Employee:
:
getEmployeeName
))
.
collect
(
Collectors
.
toList
()).
forEach
(
employee
->
{
resultList
.
add
(
employee
.
getEmployeeName
());
});
employeeList
.
stream
().
sorted
(
java
.
util
.
Comparator
.
comparing
(
Employee:
:
getEmailId
)).
collect
(
Collectors
.
toList
())
.
forEach
(
employee
->
{
resultList
.
add
(
employee
.
getEmailId
());
});
return
resultList
;
}
@Override
public
String
importDataFromExcelFile
(
MultipartFile
file
,
String
logInEmpId
)
throws
MyTimeException
{
String
result
=
""
;
try
{
PoijiOptions
options
=
PoijiOptions
.
PoijiOptionsBuilder
.
settings
().
preferNullOverDefault
(
true
).
datePattern
(
"dd-MMM-yyyy"
).
build
();
List
<
Employee
>
employees
=
Poiji
.
fromExcel
(
file
.
getInputStream
(),
PoijiExcelType
.
XLS
,
Employee
.
class
,
options
);
if
(!
employees
.
isEmpty
())
{
result
=
allColumnsExistCheckInExcel
(
employees
.
get
(
MyTimeUtils
.
INT_ZERO
));
if
(!
result
.
isEmpty
())
{
log
.
info
(
"Imported Excel file {} missing column {}"
,
file
.
getOriginalFilename
(),
result
);
return
result
;
}
result
=
duplicateEmpIAndEmptyEmpIdsCheckInImportedExcel
(
employees
);
result
+=
validateExcelRecords
(
employees
);
log
.
info
(
"Partial Import :: Imported {} employee records from file: {}"
,
employees
.
size
(),
file
.
getOriginalFilename
());
for
(
Employee
employee
:
employees
)
{
addEmployee
(
employee
,
logInEmpId
);
}
}
else
{
result
=
"Uploaded file: {"
+
file
.
getOriginalFilename
()
+
"}, is Empty"
;
log
.
info
(
"Uploaded file: {}, is Empty"
,
file
.
getOriginalFilename
());
}
if
(
result
.
isEmpty
())
{
result
=
"Successfully Employees added"
;
log
.
info
(
"Full Import :: Imported {} employee records from file: {}"
,
employees
.
size
(),
file
.
getOriginalFilename
());
}
}
catch
(
Exception
e
)
{
log
.
error
(
"Exception occured while exporting the data from excel file due to: {}"
,
e
);
throw
new
MyTimeException
(
"Exception occured while exporting the data from excel file due to :"
+
e
.
getMessage
());
}
return
result
;
}
private
void
addEmployee
(
Employee
employee
,
String
empId
)
{
try
{
if
(
employee
.
getRole
().
trim
().
isEmpty
())
{
employee
.
setRole
(
MyTimeUtils
.
EMPLOYEE
);
}
if
(
employee
.
getEmploymentType
().
trim
().
isEmpty
())
{
employee
.
setEmploymentType
(
MyTimeUtils
.
FULL_TIME
);
}
String
empStatus
=
employee
.
getEmpStatus
().
trim
();
if
(
empStatus
.
isEmpty
()
)
{
if
(
null
==
employee
.
getEndDate
())
{
employee
.
setEmpStatus
(
MyTimeUtils
.
ACTIVE
);
}
else
{
employee
.
setEmpStatus
(
MyTimeUtils
.
IN_ACTIVE_SPACE
);
}
}
else
if
(
(
empStatus
.
equalsIgnoreCase
(
MyTimeUtils
.
IN_ACTIVE
)
||
empStatus
.
equalsIgnoreCase
(
MyTimeUtils
.
IN_ACTIVE_SPACE
)
||
empStatus
.
equalsIgnoreCase
(
MyTimeUtils
.
IN_HYPEN_ACTIVE_SPACE
))
&&
null
!=
employee
.
getEndDate
()
)
{
employee
.
setEmpStatus
(
MyTimeUtils
.
IN_ACTIVE_SPACE
);
}
if
(!
employee
.
getGender
().
trim
().
isEmpty
())
{
if
(
employee
.
getGender
().
equalsIgnoreCase
(
MyTimeUtils
.
MALE
))
{
employee
.
setGender
(
MyTimeUtils
.
MALE
);
}
else
if
(
employee
.
getGender
().
equalsIgnoreCase
(
MyTimeUtils
.
FEMALE
)){
employee
.
setGender
(
MyTimeUtils
.
FEMALE
);
}
}
createEmployee
(
employee
,
empId
);
}
catch
(
MyTimeException
e
)
{
e
.
printStackTrace
();
}
public
List
<
HashMap
<
String
,
String
>>
getDeliveryLeads
(
String
domainId
)
{
Domain
domain
=
domainService
.
getDomainById
(
domainId
);
return
getEmployeeData
(
domain
.
getDeliveryManagers
());
}
private
String
validateExcelRecords
(
List
<
Employee
>
employees
)
{
List
<
String
>
inValidEmpRecList
=
new
ArrayList
<
String
>();
String
result
=
""
;
boolean
mandatoryFlag
=
true
;
int
rowNumber
=
1
;
List
<
Employee
>
invalidEmpRecs
=
new
ArrayList
<
Employee
>();
Set
<
String
>
empIdsSet
=
employees
.
stream
().
map
(
Employee
::
getEmployeeId
).
collect
(
Collectors
.
toSet
());
List
<
Employee
>
existingEmployess
=
employeeRepo
.
findByEmployeeIdIn
(
empIdsSet
);
if
(
existingEmployess
.
size
()
>
MyTimeUtils
.
INT_ZERO
)
{
result
=
"Below employee records already existed : \n"
+
existingEmployess
.
stream
().
map
(
Employee
::
getEmployeeId
).
collect
(
Collectors
.
toSet
()).
toString
();
employees
.
removeAll
(
existingEmployess
);
}
for
(
Employee
emp
:
employees
)
{
rowNumber
+=
1
;
mandatoryFlag
=
importExcelMandatoryColumnsValidation
(
emp
);
public
List
<
HashMap
<
String
,
String
>>
getEmployeeData
(
List
dmIdList
)
{
List
<
HashMap
<
String
,
String
>>
EmployeeList
=
new
ArrayList
<>();
if
(
mandatoryFlag
)
{
importExcelAdditionalColumnVAlidation
(
emp
,
inValidEmpRecList
,
invalidEmpRecs
,
rowNumber
);
}
else
{
addInValidRecord
(
inValidEmpRecList
,
invalidEmpRecs
,
emp
,
rowNumber
);
}
}
if
(
invalidEmpRecs
.
size
()
>
MyTimeUtils
.
INT_ZERO
)
{
employees
.
removeAll
(
invalidEmpRecs
);
result
+=
"Please check the following row number records : \n"
+
inValidEmpRecList
.
toString
();
}
return
result
;
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
);
}
private
void
addInValidRecord
(
List
<
String
>
inValidEmpRecList
,
List
<
Employee
>
invalidEmpRecs
,
Employee
emp
,
int
rowNumber
)
{
inValidEmpRecList
.
add
(
Integer
.
toString
(
rowNumber
));
invalidEmpRecs
.
add
(
emp
);
return
EmployeeList
;
}
@Override
public
List
<
Employee
>
getEmployeesByFunctionalGrp
(
String
functionalGrp
)
{
return
employeeRepo
.
findByEmpStatusAndFunctionalGroup
(
"Active"
,
functionalGrp
);
private
String
allColumnsExistCheckInExcel
(
Employee
emp
)
{
String
resultString
=
"In excel sheet following coloumns are missing::"
;
StringBuffer
result
=
new
StringBuffer
(
resultString
);
Method
[]
empMethodList
=
emp
.
getClass
().
getMethods
();
for
(
Method
empMethod
:
empMethodList
)
{
String
mName
=
empMethod
.
getName
();
if
(
mName
.
startsWith
(
"get"
)
&&
isMethodInvocationRequired
(
mName
))
{
try
{
Object
returnData
=
empMethod
.
invoke
(
emp
);
if
(
returnData
==
null
)
{
mName
=
mName
.
substring
(
3
,
mName
.
length
());
result
.
append
(
mName
).
append
(
MyTimeUtils
.
CAMA
);
}
}
catch
(
IllegalAccessException
|
IllegalArgumentException
|
InvocationTargetException
e
)
{
e
.
printStackTrace
();
}
}
}
resultString
=
result
.
substring
(
resultString
.
length
()-
1
,
result
.
length
()-
1
);
if
(
resultString
.
length
()
>
0
)
{
resultString
=
result
.
substring
(
0
,
result
.
length
()-
1
);
}
return
resultString
;
}
private
boolean
isMethodInvocationRequired
(
String
mName
)
{
boolean
isRequired
=
true
;
if
(
mName
.
contains
(
"getCreatedBy"
))
{
isRequired
=
false
;
}
if
(
mName
.
contains
(
"getModifiedBy"
))
{
isRequired
=
false
;
}
if
(
mName
.
contains
(
"getCreatedOn"
))
{
isRequired
=
false
;
}
if
(
mName
.
contains
(
"getLastModifiedOn"
))
{
isRequired
=
false
;
}
if
(
mName
.
contains
(
"getEndDate"
))
{
isRequired
=
false
;
}
if
(
mName
.
contains
(
"getId"
))
{
isRequired
=
false
;
}
if
(
mName
.
contains
(
"getClass"
))
{
isRequired
=
false
;
}
if
(
mName
.
contains
(
"getPassportExpiryDate"
))
{
isRequired
=
false
;
}
if
(
mName
.
contains
(
"getB1ExpiryDate"
))
{
isRequired
=
false
;
}
if
(
mName
.
contains
(
"getDateOfBirth"
))
{
isRequired
=
false
;
@Override
public
boolean
verifyEmployeeRole
(
String
empId
,
String
roleName
)
{
boolean
flag
=
false
;
String
role
=
getEmployeeById
(
empId
).
getRole
();
if
(
null
!=
role
&&
""
!=
role
&&
!
"Admin"
.
equalsIgnoreCase
(
role
))
{
Set
<
String
>
roleSet
=
employeeRoleService
.
empRolesMapInfoByEmpId
(
empId
);
if
(
null
!=
roleSet
&&
!
roleSet
.
isEmpty
()
&&
MyTimeUtils
.
INT_ZERO
<
roleSet
.
size
())
{
if
(
roleSet
.
contains
(
roleName
))
{
flag
=
true
;
}
return
isRequired
;
}
private
boolean
importExcelMandatoryColumnsValidation
(
Employee
emp
)
{
boolean
mandatoryFlag
=
true
;
// if(! DataValidations.validateNumber(emp.getEmployeeId())) {
// mandatoryFlag = false;
// }else if(! DataValidations.validateName(emp.getEmployeeName())) {
// mandatoryFlag = false;
// }else if(! DataValidations.isValidGender(emp.getGender())) {
// mandatoryFlag = false;
// }else if(! DataValidations.isValidDate(emp.getDateOfJoining())) {
// mandatoryFlag = false;
// }else if(! DataValidations.isValidFunctionalGroup(emp.getFunctionalGroup(),masterDataRepo)) {
// mandatoryFlag = false;
// }else if(! DataValidations.isValidDesignation(emp.getDesignation(),masterDataRepo)) {
// mandatoryFlag = false;
// }
// //else if(! DataValidations.isValidWorkLocation(emp.getEmpLocation(), locationRepo)) {
// //mandatoryFlag = false;
// // }
// else if(! DataValidations.isValidEmploymentType(emp.getEmploymentType(),masterDataRepo)) {
// mandatoryFlag = false;
// }else if(! DataValidations.isValidRole(emp.getRole(),masterDataRepo)) {
// mandatoryFlag = false;
// }else if(! DataValidations.isYesOrNo(emp.getHasPassort())) {
// mandatoryFlag = false;
// }else if(! DataValidations.isYesOrNo(emp.getHasB1())) {
// mandatoryFlag = false;
// }else if(!DataValidations.isValidEmail(emp.getEmailId())) {
// mandatoryFlag = false;
// }
return
mandatoryFlag
;
}
return
flag
;
}
public
List
<
Employee
>
getEmployeesFromList
(
Set
<
String
>
empIdsSet
)
{
return
employeeRepo
.
findByEmployeeIdIn
(
empIdsSet
);
private
void
importExcelAdditionalColumnVAlidation
(
Employee
emp
,
List
<
String
>
inValidEmpRecList
,
List
<
Employee
>
invalidEmpRecs
,
int
rowNumber
)
{
if
(!
DataValidations
.
isAgeGreaterThanTwenty
(
emp
.
getDateOfBirth
(),
emp
.
getDateOfJoining
()))
{
addInValidRecord
(
inValidEmpRecList
,
invalidEmpRecs
,
emp
,
rowNumber
);
return
;
}
if
(
MyTimeUtils
.
YES
.
equalsIgnoreCase
(
emp
.
getHasPassort
().
trim
())||
MyTimeUtils
.
STRING_Y
.
equalsIgnoreCase
(
emp
.
getHasPassort
().
trim
()))
{
if
(!
DataValidations
.
isFutureDate
(
emp
.
getPassportExpiryDate
()))
{
addInValidRecord
(
inValidEmpRecList
,
invalidEmpRecs
,
emp
,
rowNumber
);
return
;
}
}
if
(
emp
.
getHasPassort
().
trim
().
isEmpty
()
||
MyTimeUtils
.
NO
.
equalsIgnoreCase
(
emp
.
getHasPassort
().
trim
())||
MyTimeUtils
.
STRING_N
.
equalsIgnoreCase
(
emp
.
getHasPassort
().
trim
()))
{
if
(
null
!=
emp
.
getPassportExpiryDate
()
||
null
!=
emp
.
getHasB1
().
trim
()
||
null
!=
emp
.
getB1ExpiryDate
())
{
addInValidRecord
(
inValidEmpRecList
,
invalidEmpRecs
,
emp
,
rowNumber
);
return
;
}
}
if
((
MyTimeUtils
.
YES
.
equals
(
emp
.
getHasB1
())
||
MyTimeUtils
.
STRING_Y
.
equals
(
emp
.
getHasB1
()))&&
!
DataValidations
.
isFutureDate
(
emp
.
getB1ExpiryDate
()))
{
addInValidRecord
(
inValidEmpRecList
,
invalidEmpRecs
,
emp
,
rowNumber
);
return
;
}
if
(!
emp
.
getEmpStatus
().
trim
().
isEmpty
())
{
if
(
null
!=
emp
.
getEndDate
()
&&
(
emp
.
getEmpStatus
().
trim
().
equalsIgnoreCase
(
MyTimeUtils
.
IN_ACTIVE
)
||
emp
.
getEmpStatus
().
trim
().
equalsIgnoreCase
(
MyTimeUtils
.
IN_ACTIVE_SPACE
)
||
emp
.
getEmpStatus
().
trim
().
equalsIgnoreCase
(
MyTimeUtils
.
IN_HYPEN_ACTIVE_SPACE
)
))
{
addInValidRecord
(
inValidEmpRecList
,
invalidEmpRecs
,
emp
,
rowNumber
);
return
;
}
if
(
emp
.
getEmpStatus
().
trim
().
equalsIgnoreCase
(
MyTimeUtils
.
ACTIVE
)
&&
null
!=
emp
.
getEndDate
())
{
addInValidRecord
(
inValidEmpRecList
,
invalidEmpRecs
,
emp
,
rowNumber
);
return
;
}
}
}
private
String
duplicateEmpIAndEmptyEmpIdsCheckInImportedExcel
(
List
<
Employee
>
employees
)
{
int
rowNum
=
MyTimeUtils
.
INT_TWO
;
StringBuffer
emptyEmpIds
=
new
StringBuffer
();
StringBuffer
duplicteEmpIds
=
new
StringBuffer
();
List
<
String
>
empIdsList
=
new
ArrayList
<
String
>();
String
result
=
""
;
for
(
Employee
emp
:
employees
)
{
String
empId
=
emp
.
getEmployeeId
().
trim
();
if
(
empId
.
isEmpty
())
{
employees
.
remove
(
emp
);
emptyEmpIds
.
append
(
rowNum
).
append
(
MyTimeUtils
.
CAMA
);
}
else
if
(
empIdsList
.
contains
(
empId
))
{
employees
.
remove
(
emp
);
duplicteEmpIds
.
append
(
empId
).
append
(
MyTimeUtils
.
CAMA
);
}
else
{
empIdsList
.
add
(
empId
);
// For, Duplicate check.
}
++
rowNum
;
}
if
(
emptyEmpIds
.
length
()
>
0
)
{
result
=
"Below employee records have empty employee id :"
+
emptyEmpIds
.
toString
();
}
if
(
duplicteEmpIds
.
length
()
>
0
)
{
result
+=
":: \n Below employee records have duplicate employee Ids "
+
duplicteEmpIds
.
toString
();
}
return
result
;
}
}
src/main/java/com/nisum/mytime/service/impl/EmployeeShiftService.java
0 → 100644
View file @
cf947c85
package
com
.
nisum
.
mytime
.
service
.
impl
;
import
java.util.Calendar
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.mongodb.core.MongoTemplate
;
import
org.springframework.data.mongodb.core.query.Criteria
;
import
org.springframework.data.mongodb.core.query.Query
;
import
org.springframework.stereotype.Service
;
import
com.nisum.mytime.model.EmpShiftDetails
;
import
com.nisum.mytime.model.Resource
;
import
com.nisum.mytime.service.IEmployeeShiftService
;
import
com.nisum.mytime.utils.MyTimeUtils
;
import
lombok.extern.slf4j.Slf4j
;
@Service
@Slf4j
public
class
EmployeeShiftService
implements
IEmployeeShiftService
{
@Autowired
private
MongoTemplate
mongoTemplate
;
public
void
updateShiftDetails
(
Resource
existingTeammate
,
String
loginEmpId
)
{
Query
getQuery
=
new
Query
();
getQuery
.
addCriteria
(
new
Criteria
().
andOperator
(
Criteria
.
where
(
"active"
).
is
(
true
),
Criteria
.
where
(
"employeeId"
).
is
(
existingTeammate
.
getEmployeeId
())));
Calendar
cal
=
Calendar
.
getInstance
();
cal
.
add
(
Calendar
.
DATE
,
-
1
);
EmpShiftDetails
existingShift
=
mongoTemplate
.
findOne
(
getQuery
,
EmpShiftDetails
.
class
);
if
(
existingShift
!=
null
)
{
existingShift
.
setActive
(
false
);
// existingShift.setUpdatedDate(new Date());// Commented as added
// common audit fields
existingShift
.
setAuditFields
(
loginEmpId
,
MyTimeUtils
.
UPDATE
);
mongoTemplate
.
save
(
existingShift
);
}
}
}
src/main/java/com/nisum/mytime/service/impl/MasterDataService.java
View file @
cf947c85
...
...
@@ -9,6 +9,7 @@ import com.nisum.mytime.exception.handler.MyTimeException;
import
com.nisum.mytime.model.MasterData
;
import
com.nisum.mytime.repository.MasterDataRepo
;
import
com.nisum.mytime.service.IMasterDataService
;
import
com.nisum.mytime.utils.MyTimeUtils
;
@Service
(
"masterDataService"
)
public
class
MasterDataService
implements
IMasterDataService
{
...
...
@@ -20,4 +21,11 @@ public class MasterDataService implements IMasterDataService {
public
List
<
MasterData
>
getMasterData
()
throws
MyTimeException
{
return
masterDataRepo
.
findAll
();
}
@Override
public
List
<
MasterData
>
findByMasterDataTypeAndMasterDataNameAndActiveStatus
(
String
masterDataType
,
String
masterDataName
,
boolean
activeStatus
)
{
return
masterDataRepo
.
findByMasterDataTypeAndMasterDataNameAndActiveStatus
(
masterDataType
,
masterDataName
,
activeStatus
);
}
}
src/main/java/com/nisum/mytime/service/impl/OrgLocationService.java
View file @
cf947c85
...
...
@@ -6,18 +6,30 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.stereotype.Service
;
import
com.nisum.mytime.exception.handler.MyTimeException
;
import
com.nisum.mytime.model.Location
;
import
com.nisum.mytime.repository.LocationRepo
;
import
com.nisum.mytime.model.
Org
Location
;
import
com.nisum.mytime.repository.
Org
LocationRepo
;
import
com.nisum.mytime.service.IOrgLocationService
;
import
lombok.extern.slf4j.Slf4j
;
@Service
@Slf4j
public
class
OrgLocationService
implements
IOrgLocationService
{
@Autowired
private
LocationRepo
locationRepo
;
private
OrgLocationRepo
orgLocationRepo
;
@Override
public
List
<
OrgLocation
>
getLocations
()
throws
MyTimeException
{
List
<
OrgLocation
>
orgLocationList
=
orgLocationRepo
.
findAll
();
log
.
info
(
"The Organization Location Details::"
+
orgLocationList
);
return
orgLocationList
;
}
@Override
public
List
<
Location
>
getLocations
()
throws
MyTimeException
{
return
locationRepo
.
findAll
(
);
public
List
<
OrgLocation
>
findByLocationAndActiveStatus
(
String
location
,
boolean
activeStatus
)
{
return
orgLocationRepo
.
findByLocationAndActiveStatus
(
location
,
activeStatus
);
}
}
src/main/java/com/nisum/mytime/service/impl/ProjectService.java
View file @
cf947c85
...
...
@@ -28,30 +28,33 @@ import org.springframework.util.CollectionUtils;
import
com.nisum.mytime.controller.DomainController
;
import
com.nisum.mytime.exception.handler.MyTimeException
;
import
com.nisum.mytime.model.Account
;
import
com.nisum.mytime.model.Billing
Details
;
import
com.nisum.mytime.model.Billing
;
import
com.nisum.mytime.model.Domain
;
import
com.nisum.mytime.model.EmpLoginData
;
import
com.nisum.mytime.model.EmpShiftDetails
;
import
com.nisum.mytime.model.EmployeeDashboardVO
;
import
com.nisum.mytime.model.Employee
;
import
com.nisum.mytime.model.Project
;
import
com.nisum.mytime.model.
ProjectTeamMat
e
;
import
com.nisum.mytime.model.
Resourc
e
;
import
com.nisum.mytime.repository.AccountRepo
;
import
com.nisum.mytime.repository.DomainRepo
;
import
com.nisum.mytime.repository.EmpShiftDetailsRepo
;
import
com.nisum.mytime.repository.EmployeeRepo
;
import
com.nisum.mytime.repository.ProjectRepo
;
import
com.nisum.mytime.repository.
ProjectTeamMates
Repo
;
import
com.nisum.mytime.repository.
TeamMates
BillingRepo
;
import
com.nisum.mytime.repository.
Resource
Repo
;
import
com.nisum.mytime.repository.BillingRepo
;
import
com.nisum.mytime.service.IDomainService
;
import
com.nisum.mytime.service.IProjectService
;
import
com.nisum.mytime.service.IRole
Info
Service
;
import
com.nisum.mytime.service.I
RoleMapping
Service
;
import
com.nisum.mytime.service.IRoleService
;
import
com.nisum.mytime.service.I
EmployeeRole
Service
;
import
com.nisum.mytime.utils.MyTeamResultDTO
;
import
com.nisum.mytime.utils.MyTimeUtils
;
import
com.nisum.mytime.utils.PdfReportGenerator
;
import
lombok.extern.slf4j.Slf4j
;
@Service
(
"projectService"
)
@Slf4j
public
class
ProjectService
implements
IProjectService
{
@Autowired
...
...
@@ -61,10 +64,10 @@ public class ProjectService implements IProjectService {
private
ProjectRepo
projectRepo
;
@Autowired
private
ProjectTeamMates
Repo
projectTeamMatesRepo
;
private
Resource
Repo
projectTeamMatesRepo
;
@Autowired
private
TeamMates
BillingRepo
teamMatesBillingRepo
;
private
BillingRepo
teamMatesBillingRepo
;
@Autowired
private
EmployeeDataService
employeeDataBaseService
;
...
...
@@ -82,10 +85,10 @@ public class ProjectService implements IProjectService {
private
DomainController
domainController
;
@Autowired
private
IRole
Info
Service
roleInfoService
;
private
IRoleService
roleInfoService
;
@Autowired
private
I
RoleMapping
Service
roleMappingService
;
private
I
EmployeeRole
Service
roleMappingService
;
@Autowired
private
AccountRepo
accountRepo
;
...
...
@@ -97,43 +100,44 @@ public class ProjectService implements IProjectService {
private
IDomainService
domainService
;
public
ProjectTeamMat
e
addNewBeanchAllocation
(
Employee
employee
,
String
loginEmpId
)
public
Resourc
e
addNewBeanchAllocation
(
Employee
employee
,
String
loginEmpId
)
{
ProjectTeamMate
teamatePersisted
=
null
;
ProjectTeamMate
newBenchAllocation
=
new
ProjectTeamMate
();
newBenchAllocation
.
setAccount
(
MyTimeUtils
.
BENCH_ACCOUNT
);
newBenchAllocation
.
setBillableStatus
(
MyTimeUtils
.
BENCH_BILLABILITY_STATUS
);
newBenchAllocation
.
setDesignation
(
employee
.
getDesignation
());
newBenchAllocation
.
setEmailId
(
employee
.
getEmailId
());
newBenchAllocation
.
setEmployeeId
(
employee
.
getEmployeeId
());
newBenchAllocation
.
setMobileNumber
(
employee
.
getMobileNumber
());
Resource
resourcePersisted
=
null
;
Resource
resourceBench
=
new
Resource
();
resourceBench
.
setAccount
(
MyTimeUtils
.
BENCH_ACCOUNT
);
resourceBench
.
setBillableStatus
(
MyTimeUtils
.
BENCH_BILLABILITY_STATUS
);
resourceBench
.
setDesignation
(
employee
.
getDesignation
());
resourceBench
.
setEmailId
(
employee
.
getEmailId
());
resourceBench
.
setEmployeeId
(
employee
.
getEmployeeId
());
resourceBench
.
setMobileNumber
(
employee
.
getMobileNumber
());
resourceBench
.
setEmployeeName
(
employee
.
getEmployeeName
());
resourceBench
.
setProjectId
(
MyTimeUtils
.
BENCH_PROJECT_ID
);
resourceBench
.
setStartDate
(
employee
.
getDateOfJoining
()
!=
null
?
employee
.
getDateOfJoining
()
:
new
Date
());
newBenchAllocation
.
setEmployeeName
(
employee
.
getEmployeeName
());
newBenchAllocation
.
setProjectId
(
MyTimeUtils
.
BENCH_PROJECT_ID
);
newBenchAllocation
.
setStartDate
(
employee
.
getDateOfJoining
()
!=
null
?
employee
.
getDateOfJoining
()
:
new
Date
());
Project
p
=
projectRepo
.
findByProjectId
(
MyTimeUtils
.
BENCH_PROJECT_ID
);
newBenchAllocation
.
setProjectName
(
p
.
getProjectName
());
newBenchAllocation
.
setAccountId
(
p
.
getAccountId
());
newBenchAllocation
.
setDomainId
(
p
.
getDomainId
());
newBenchAllocation
.
setShift
(
employee
.
getShift
());
newBenchAllocation
.
setRole
(
employee
.
getRole
());
Project
project
=
projectRepo
.
findByProjectId
(
MyTimeUtils
.
BENCH_PROJECT_ID
);
resourceBench
.
setProjectName
(
project
.
getProjectName
());
resourceBench
.
setAccountId
(
project
.
getAccountId
());
resourceBench
.
setDomainId
(
project
.
getDomainId
());
resourceBench
.
setShift
(
employee
.
getShift
());
resourceBench
.
setRole
(
employee
.
getRole
());
if
(
null
!=
employee
.
getEmpStatus
()
&&
employee
.
getEmpStatus
().
trim
().
equalsIgnoreCase
(
MyTimeUtils
.
IN_ACTIVE_SPACE
))
{
newBenchAllocation
.
setEndDate
(
employee
.
getEndDate
());
newBenchAllocation
.
setActive
(
false
);
resourceBench
.
setEndDate
(
employee
.
getEndDate
());
resourceBench
.
setActive
(
false
);
}
else
{
employee
.
setEmpStatus
(
MyTimeUtils
.
ACTIVE
);
newBenchAllocation
.
setEndDate
(
p
.
getProjectEndDate
());
newBenchAllocation
.
setActive
(
true
);
resourceBench
.
setEndDate
(
project
.
getProjectEndDate
());
resourceBench
.
setActive
(
true
);
}
try
{
teamatePersisted
=
addProjectTeamMate
(
newBenchAllocation
,
loginEmpId
);
resourcePersisted
=
addProjectTeamMate
(
resourceBench
,
loginEmpId
);
}
catch
(
MyTimeException
e
)
{
e
.
printStackTrace
();
}
return
teamat
ePersisted
;
return
resourc
ePersisted
;
}
...
...
@@ -230,8 +234,8 @@ public class ProjectService implements IProjectService {
Project
project
=
projectRepo
.
findByProjectId
(
projectId
);
projectRepo
.
delete
(
project
);
Query
query
=
new
Query
(
Criteria
.
where
(
"projectId"
).
is
(
projectId
));
List
<
ProjectTeamMat
e
>
list
=
mongoTemplate
.
find
(
query
,
ProjectTeamMat
e
.
class
);
List
<
Resourc
e
>
list
=
mongoTemplate
.
find
(
query
,
Resourc
e
.
class
);
projectTeamMatesRepo
.
delete
(
list
);
}
...
...
@@ -239,7 +243,7 @@ public class ProjectService implements IProjectService {
public
Project
updateProject
(
Project
project
,
String
loginEmpId
)
throws
MyTimeException
{
//Inactivate the Project based on endDate
Project
existingProject
=
projectRepo
.
findByProjectId
(
project
.
getProjectId
());
List
<
ProjectTeamMat
e
>
existingTeammates
=
projectTeamMatesRepo
.
findByProjectId
(
project
.
getProjectId
());
List
<
Resourc
e
>
existingTeammates
=
projectTeamMatesRepo
.
findByProjectId
(
project
.
getProjectId
());
if
(
project
.
getProjectEndDate
().
compareTo
(
new
Date
())
<=
0
&&
project
.
getProjectEndDate
().
compareTo
(
existingProject
.
getProjectEndDate
())
!=
0
)
{
...
...
@@ -248,19 +252,19 @@ public class ProjectService implements IProjectService {
existingProject
.
setProjectEndDate
(
project
.
getProjectEndDate
());
existingProject
.
setAuditFields
(
loginEmpId
,
MyTimeUtils
.
UPDATE
);
projectRepo
.
save
(
existingProject
);
for
(
ProjectTeamMat
e
existingTeammate
:
existingTeammates
)
{
for
(
Resourc
e
existingTeammate
:
existingTeammates
)
{
existingTeammate
.
setActive
(
false
);
existingTeammate
.
setEndDate
(
project
.
getProjectEndDate
());
existingTeammate
.
setAuditFields
(
loginEmpId
,
MyTimeUtils
.
UPDATE
);
projectTeamMatesRepo
.
save
(
existingTeammate
);
Billing
Details
billingDetails
=
new
BillingDetails
();
ProjectTeamMate
newBenchAllocation
=
new
ProjectTeamMat
e
();
Billing
billingDetails
=
new
Billing
();
Resource
newBenchAllocation
=
new
Resourc
e
();
billingDetails
.
setBillableStatus
(
MyTimeUtils
.
BENCH_BILLABILITY_STATUS
);
List
<
Billing
Details
>
listBD
=
getEmployeeActiveBillingDetails
(
existingTeammate
.
getEmployeeId
(),
List
<
Billing
>
listBD
=
getEmployeeActiveBillingDetails
(
existingTeammate
.
getEmployeeId
(),
existingTeammate
.
getProjectId
());
if
(
listBD
!=
null
&&
!
listBD
.
isEmpty
())
{
Billing
Details
billingDetailsExisting
=
listBD
.
get
(
0
);
Billing
billingDetailsExisting
=
listBD
.
get
(
0
);
billingDetailsExisting
.
setBillingEndDate
(
project
.
getProjectEndDate
());
billingDetailsExisting
.
setActive
(
false
);
updateEmployeeBilling
(
billingDetailsExisting
,
loginEmpId
);
...
...
@@ -332,9 +336,9 @@ public class ProjectService implements IProjectService {
options
.
returnNew
(
true
);
options
.
upsert
(
true
);
Project
projectDB
=
mongoTemplate
.
findAndModify
(
query
,
update
,
options
,
Project
.
class
);
List
<
ProjectTeamMat
e
>
employeeDetails
=
projectTeamMatesRepo
.
findByProjectId
(
project
.
getProjectId
());
List
<
Resourc
e
>
employeeDetails
=
projectTeamMatesRepo
.
findByProjectId
(
project
.
getProjectId
());
if
(
employeeDetails
!=
null
&&
projectDB
!=
null
)
{
for
(
ProjectTeamMat
e
teamMate
:
employeeDetails
)
{
for
(
Resourc
e
teamMate
:
employeeDetails
)
{
// emp.setManagerId(projectDB.getManagerId());
// emp.setManagerName(projectDB.getManagerName());
teamMate
.
setAccountId
(
projectDB
.
getAccountId
());
...
...
@@ -356,17 +360,17 @@ public class ProjectService implements IProjectService {
}
@Override
public
List
<
ProjectTeamMat
e
>
getTeamDetails
(
String
empId
)
{
public
List
<
Resourc
e
>
getTeamDetails
(
String
empId
)
{
List
<
String
>
projectsId
=
new
ArrayList
<>();
List
<
ProjectTeamMat
e
>
listOfTeamMates
=
new
ArrayList
<>();
List
<
Resourc
e
>
listOfTeamMates
=
new
ArrayList
<>();
// return projectTeamMatesRepo.findById(empId);
// Query query = new Query(Criteria.where("deliveryLeadIds").("empId"));
List
<
Project
>
projects
=
projectRepo
.
findByDeliveryLeadIds
(
empId
);
// mongoTemplate.find(query, Project.class);
for
(
Project
project
:
projects
)
projectsId
.
add
(
project
.
getProjectId
());
Query
query1
=
new
Query
(
Criteria
.
where
(
"projectId"
).
in
(
projectsId
));
List
<
ProjectTeamMate
>
projectMateList
=
mongoTemplate
.
find
(
query1
,
ProjectTeamMat
e
.
class
);
for
(
ProjectTeamMat
e
projectTeamMate
:
projectMateList
)
{
List
<
Resource
>
projectMateList
=
mongoTemplate
.
find
(
query1
,
Resourc
e
.
class
);
for
(
Resourc
e
projectTeamMate
:
projectMateList
)
{
if
(!
projectTeamMate
.
getEmployeeId
().
equals
(
empId
))
listOfTeamMates
.
add
(
projectTeamMate
);
}
...
...
@@ -376,20 +380,20 @@ public class ProjectService implements IProjectService {
// MT-72: fetching the projectteammate details.
@Override
public
List
<
ProjectTeamMat
e
>
getProjectInfo
(
String
employeeId
)
{
public
List
<
Resourc
e
>
getProjectInfo
(
String
employeeId
)
{
return
mongoTemplate
.
find
(
getQuery
(
employeeId
,
MyTimeUtils
.
START_DATE
),
ProjectTeamMat
e
.
class
);
Resourc
e
.
class
);
}
@Override
public
ProjectTeamMate
addProjectTeamMate
(
ProjectTeamMat
e
projectTeamMate
,
String
loginEmpId
)
throws
MyTimeException
{
public
Resource
addProjectTeamMate
(
Resourc
e
projectTeamMate
,
String
loginEmpId
)
throws
MyTimeException
{
updateProjectEndDateInProjectTeamMate
(
projectTeamMate
,
loginEmpId
);
projectTeamMate
.
setAuditFields
(
loginEmpId
,
MyTimeUtils
.
CREATE
);
ProjectTeamMat
e
pT
=
projectTeamMatesRepo
.
save
(
projectTeamMate
);
List
<
Billing
Details
>
listBD
=
getEmployeeActiveNisumBench
(
pT
.
getEmployeeId
());
Resourc
e
pT
=
projectTeamMatesRepo
.
save
(
projectTeamMate
);
List
<
Billing
>
listBD
=
getEmployeeActiveNisumBench
(
pT
.
getEmployeeId
());
Date
startDate
=
pT
.
getStartDate
()
!=
null
?
pT
.
getStartDate
()
:
new
Date
();
if
(
listBD
!=
null
&&
listBD
.
size
()
>
0
)
{
Billing
Details
bDetails
=
listBD
.
get
(
0
);
Billing
bDetails
=
listBD
.
get
(
0
);
if
(
startDate
.
compareTo
(
bDetails
.
getBillingStartDate
())
>
0
)
{
bDetails
.
setBillingEndDate
(
DateUtils
.
truncate
(
DateUtils
.
addDays
(
startDate
,
-
1
),
Calendar
.
DATE
));
}
else
{
...
...
@@ -398,7 +402,7 @@ public class ProjectService implements IProjectService {
bDetails
.
setActive
(
false
);
updateEmployeeBilling
(
bDetails
,
loginEmpId
);
}
Billing
Details
billings
=
new
BillingDetails
();
Billing
billings
=
new
Billing
();
billings
.
setEmployeeId
(
pT
.
getEmployeeId
());
billings
.
setEmployeeName
(
pT
.
getEmployeeName
());
billings
.
setProjectId
(
pT
.
getProjectId
());
...
...
@@ -441,7 +445,7 @@ public class ProjectService implements IProjectService {
project
.
setAuditFields
(
loginEmpId
,
MyTimeUtils
.
UPDATE
);
//setting audit fields
projectRepo
.
save
(
project
);
Query
query
=
new
Query
(
Criteria
.
where
(
"employeeId"
).
is
(
empId
).
and
(
"role"
).
is
(
"Lead"
));
List
<
ProjectTeamMate
>
projectMates
=
mongoTemplate
.
find
(
query
,
ProjectTeamMat
e
.
class
);
List
<
Resource
>
projectMates
=
mongoTemplate
.
find
(
query
,
Resourc
e
.
class
);
String
roleId
=
roleInfoService
.
getRole
(
MyTimeUtils
.
LEAD
);
if
(
operationType
==
1
)
{
roleMappingService
.
addEmployeeRole
(
empId
,
roleId
);
...
...
@@ -452,13 +456,13 @@ public class ProjectService implements IProjectService {
}
@Override
public
String
updateTeammate
(
ProjectTeamMat
e
projectTeamMate
,
String
loginEmpId
)
throws
MyTimeException
{
public
String
updateTeammate
(
Resourc
e
projectTeamMate
,
String
loginEmpId
)
throws
MyTimeException
{
//String result = null;
MyTeamResultDTO
myResultDto
=
new
MyTeamResultDTO
();
myResultDto
.
setResultCode
(
MyTeamResultDTO
.
SUCCESS_CODE
);
myResultDto
.
setResultData
(
"TeamMate updated successfuly"
);
ProjectTeamMat
e
existingTeammate
=
projectTeamMatesRepo
.
findById
(
projectTeamMate
.
getId
());
List
<
Billing
Details
>
listBD
=
getEmployeeActiveBillingDetails
(
projectTeamMate
.
getEmployeeId
(),
projectTeamMate
.
getProjectId
());
Resourc
e
existingTeammate
=
projectTeamMatesRepo
.
findById
(
projectTeamMate
.
getId
());
List
<
Billing
>
listBD
=
getEmployeeActiveBillingDetails
(
projectTeamMate
.
getEmployeeId
(),
projectTeamMate
.
getProjectId
());
Date
resEndDate
=
projectTeamMate
.
getEndDate
();
//Handling past or present endDate (To "Inactive" the Resource)
...
...
@@ -466,15 +470,15 @@ public class ProjectService implements IProjectService {
existingTeammate
.
setActive
(
false
);
existingTeammate
.
setEndDate
(
resEndDate
);
if
(
listBD
!=
null
&&
!
listBD
.
isEmpty
())
{
Billing
Details
billingDetailsExisting
=
listBD
.
get
(
0
);
Billing
billingDetailsExisting
=
listBD
.
get
(
0
);
Date
actualEndDate
=
resEndDate
;
billingDetailsExisting
.
setBillingEndDate
(
actualEndDate
);
billingDetailsExisting
.
setActive
(
false
);
updateEmployeeBilling
(
billingDetailsExisting
,
loginEmpId
);
}
Project
project
=
projectRepo
.
findByProjectId
(
MyTimeUtils
.
BENCH_PROJECT_ID
);
ProjectTeamMate
newBenchAllocation
=
new
ProjectTeamMat
e
();
Billing
Details
billingDetails
=
new
BillingDetails
();
Resource
newBenchAllocation
=
new
Resourc
e
();
Billing
billingDetails
=
new
Billing
();
billingDetails
.
setBillableStatus
(
MyTimeUtils
.
BENCH_BILLABILITY_STATUS
);
billingDetails
.
setBillingStartDate
(
resEndDate
);
billingDetails
.
setAccount
(
MyTimeUtils
.
BENCH_ACCOUNT
);
...
...
@@ -526,7 +530,7 @@ public class ProjectService implements IProjectService {
return
result
;
}
if
(
listBD
!=
null
&&
!
listBD
.
isEmpty
())
{
Billing
Details
billingDetails
=
listBD
.
get
(
0
);
Billing
billingDetails
=
listBD
.
get
(
0
);
Calendar
cal
=
Calendar
.
getInstance
();
cal
.
setTime
(
projectTeamMate
.
getNewBillingStartDate
());
cal
.
add
(
Calendar
.
DAY_OF_MONTH
,
-
1
);
...
...
@@ -540,7 +544,7 @@ public class ProjectService implements IProjectService {
billingDetails
.
setActive
(
false
);
updateEmployeeBilling
(
billingDetails
,
loginEmpId
);
}
Billing
Details
billings
=
new
BillingDetails
();
Billing
billings
=
new
Billing
();
billings
.
setEmployeeId
(
projectTeamMate
.
getEmployeeId
());
billings
.
setEmployeeName
(
projectTeamMate
.
getEmployeeName
());
billings
.
setProjectId
(
projectTeamMate
.
getProjectId
());
...
...
@@ -557,8 +561,8 @@ public class ProjectService implements IProjectService {
existingTeammate
.
setNewBillingStartDate
(
DateUtils
.
truncate
(
projectTeamMate
.
getNewBillingStartDate
(),
Calendar
.
DATE
));
}
else
{
//Handling Billability Start Date change
List
<
Billing
Details
>
bDetailsList
=
teamMatesBillingRepo
.
findByEmployeeId
(
projectTeamMate
.
getEmployeeId
()).
stream
()
.
filter
(
e
->
(!
e
.
isActive
())).
sorted
(
Comparator
.
comparing
(
Billing
Details
:
:
getBillingEndDate
).
reversed
())
List
<
Billing
>
bDetailsList
=
teamMatesBillingRepo
.
findByEmployeeId
(
projectTeamMate
.
getEmployeeId
()).
stream
()
.
filter
(
e
->
(!
e
.
isActive
())).
sorted
(
Comparator
.
comparing
(
Billing:
:
getBillingEndDate
).
reversed
())
.
collect
(
Collectors
.
toList
());
String
result
=
validateBillabilityStartDate
(
bDetailsList
,
projectTeamMate
);
if
(
result
!=
null
)
{
//Invalid Billability Start date
...
...
@@ -568,7 +572,7 @@ public class ProjectService implements IProjectService {
Calendar
cal
=
Calendar
.
getInstance
();
cal
.
setTime
(
projectTeamMate
.
getNewBillingStartDate
());
cal
.
add
(
Calendar
.
DAY_OF_MONTH
,
-
1
);
Billing
Details
preBillingDetails
=
bDetailsList
.
get
(
0
);
Billing
preBillingDetails
=
bDetailsList
.
get
(
0
);
if
(
preBillingDetails
.
getBillingStartDate
().
getDate
()
==
projectTeamMate
.
getNewBillingStartDate
().
getDate
())
{
preBillingDetails
.
setBillingEndDate
(
DateUtils
.
truncate
(
projectTeamMate
.
getNewBillingStartDate
(),
Calendar
.
DATE
));
}
else
{
...
...
@@ -577,7 +581,7 @@ public class ProjectService implements IProjectService {
updateEmployeeBilling
(
preBillingDetails
,
loginEmpId
);
}
if
(
listBD
!=
null
&&
!
listBD
.
isEmpty
())
{
Billing
Details
billingDetails
=
listBD
.
get
(
0
);
Billing
billingDetails
=
listBD
.
get
(
0
);
billingDetails
.
setBillingStartDate
(
DateUtils
.
truncate
(
projectTeamMate
.
getNewBillingStartDate
(),
Calendar
.
DATE
));
billingDetails
.
setBillingEndDate
(
DateUtils
.
truncate
(
resEndDate
,
Calendar
.
DATE
));
addEmployeeBillingDetails
(
billingDetails
,
loginEmpId
);
...
...
@@ -613,10 +617,10 @@ public class ProjectService implements IProjectService {
return
myResultDto
.
getResultData
()[
myResultDto
.
getDataArrayCounter
()];
}
private
String
validateBillabilityStartDate
(
List
<
Billing
Details
>
bDetailsList
,
ProjectTeamMat
e
projectTeamMate
)
{
private
String
validateBillabilityStartDate
(
List
<
Billing
>
bDetailsList
,
Resourc
e
projectTeamMate
)
{
String
response
=
null
;
if
(
bDetailsList
!=
null
&&
bDetailsList
.
size
()
>
0
)
{
Billing
Details
bDetails
=
bDetailsList
.
get
(
0
);
Billing
bDetails
=
bDetailsList
.
get
(
0
);
if
(
projectTeamMate
.
getNewBillingStartDate
().
compareTo
(
bDetails
.
getBillingStartDate
())
<
0
)
{
response
=
"Resource Billability Start Date ("
+
projectTeamMate
.
getNewBillingStartDate
()
+
" ) for "
+
projectTeamMate
.
getBillableStatus
()
+
" status should be later than previous billability ("
...
...
@@ -629,7 +633,7 @@ public class ProjectService implements IProjectService {
}
@Override
public
void
updateShiftDetails
(
ProjectTeamMat
e
existingTeammate
,
String
loginEmpId
)
{
public
void
updateShiftDetails
(
Resourc
e
existingTeammate
,
String
loginEmpId
)
{
Query
getQuery
=
new
Query
();
getQuery
.
addCriteria
(
new
Criteria
().
andOperator
(
Criteria
.
where
(
"active"
).
is
(
true
),
Criteria
.
where
(
"employeeId"
).
is
(
existingTeammate
.
getEmployeeId
())));
...
...
@@ -645,7 +649,7 @@ public class ProjectService implements IProjectService {
}
@Override
public
void
addShiftDetails
(
ProjectTeamMat
e
projectTeamMate
,
String
loginEmpId
)
{
public
void
addShiftDetails
(
Resourc
e
projectTeamMate
,
String
loginEmpId
)
{
EmpShiftDetails
empShiftDetails
=
new
EmpShiftDetails
();
//empShiftDetails.setCreateDate(new Date());// Commented as added common audit fields
//empShiftDetails.setUpdatedDate(new Date());// Commented as added common audit fields
...
...
@@ -659,10 +663,10 @@ public class ProjectService implements IProjectService {
@Override
public
void
deleteTeammate
(
String
empId
,
String
projectId
,
ObjectId
id
,
String
loginEmpId
)
{
ProjectTeamMat
e
existingTeammate
=
projectTeamMatesRepo
.
findById
(
id
);
Resourc
e
existingTeammate
=
projectTeamMatesRepo
.
findById
(
id
);
existingTeammate
.
setActive
(
false
);
existingTeammate
.
setEndDate
(
new
Date
());
Billing
Details
billingDetails
=
new
BillingDetails
();
Billing
billingDetails
=
new
Billing
();
billingDetails
.
setBillableStatus
(
"Non-Billable"
);
billingDetails
.
setBillingStartDate
(
new
Date
());
billingDetails
.
setAccount
(
"Nisum"
);
...
...
@@ -673,10 +677,10 @@ public class ProjectService implements IProjectService {
billingDetails
.
setProjectId
(
"Nisum0000"
);
billingDetails
.
setProjectName
(
MyTimeUtils
.
FREE_POLL
);
addEmployeeBillingDetails
(
billingDetails
,
loginEmpId
);
List
<
Billing
Details
>
listBD
=
getEmployeeActiveBillingDetails
(
empId
,
List
<
Billing
>
listBD
=
getEmployeeActiveBillingDetails
(
empId
,
projectId
);
if
(
listBD
!=
null
&&
!
listBD
.
isEmpty
())
{
Billing
Details
billingDetailsExisting
=
listBD
.
get
(
0
);
Billing
billingDetailsExisting
=
listBD
.
get
(
0
);
Date
d
=
new
Date
();
d
.
setDate
(
d
.
getDate
()
-
1
);
billingDetailsExisting
.
setBillingEndDate
(
d
);
...
...
@@ -685,7 +689,7 @@ public class ProjectService implements IProjectService {
}
existingTeammate
.
setAuditFields
(
loginEmpId
,
MyTimeUtils
.
UPDATE
);
//Setting audit fields
projectTeamMatesRepo
.
save
(
existingTeammate
);
ProjectTeamMate
newBenchAllocation
=
new
ProjectTeamMat
e
();
Resource
newBenchAllocation
=
new
Resourc
e
();
newBenchAllocation
.
setAccount
(
"Nisum"
);
newBenchAllocation
.
setBillableStatus
(
"Non-Billable"
);
newBenchAllocation
.
setDesignation
(
existingTeammate
.
getDesignation
());
...
...
@@ -723,11 +727,11 @@ public class ProjectService implements IProjectService {
}
@Override
public
List
<
ProjectTeamMat
e
>
getMyTeamDetails
(
String
empId
)
{
List
<
ProjectTeamMat
e
>
teamMates
=
new
ArrayList
<>();
List
<
ProjectTeamMat
e
>
empRecords
=
projectTeamMatesRepo
public
List
<
Resourc
e
>
getMyTeamDetails
(
String
empId
)
{
List
<
Resourc
e
>
teamMates
=
new
ArrayList
<>();
List
<
Resourc
e
>
empRecords
=
projectTeamMatesRepo
.
findByEmployeeId
(
empId
);
for
(
ProjectTeamMat
e
pt
:
empRecords
)
{
for
(
Resourc
e
pt
:
empRecords
)
{
if
(
pt
.
isActive
())
{
teamMates
.
addAll
(
projectTeamMatesRepo
.
findByProjectId
(
pt
.
getProjectId
()));
...
...
@@ -741,8 +745,8 @@ public class ProjectService implements IProjectService {
List
<
Employee
>
allEmployees
=
employeeRolesRepo
.
findAll
();
List
<
Employee
>
notAssignedEmployees
=
new
ArrayList
<>();
List
<
String
>
teamMates
=
new
ArrayList
<>();
List
<
ProjectTeamMat
e
>
empRecords
=
projectTeamMatesRepo
.
findAll
();
for
(
ProjectTeamMat
e
pt
:
empRecords
)
{
List
<
Resourc
e
>
empRecords
=
projectTeamMatesRepo
.
findAll
();
for
(
Resourc
e
pt
:
empRecords
)
{
Project
project
=
projectRepo
.
findByProjectId
(
pt
.
getProjectId
());
if
(
project
!=
null
&&
project
.
getStatus
()
!=
null
&&
!
"Completed"
.
equalsIgnoreCase
(
project
.
getStatus
()))
{
...
...
@@ -760,14 +764,14 @@ public class ProjectService implements IProjectService {
}
@Override
public
List
<
ProjectTeamMat
e
>
getShiftDetails
(
String
shift
)
{
List
<
ProjectTeamMat
e
>
employeeDetails
=
null
;
List
<
ProjectTeamMat
e
>
shiftEmpDetails
=
new
ArrayList
<>();
public
List
<
Resourc
e
>
getShiftDetails
(
String
shift
)
{
List
<
Resourc
e
>
employeeDetails
=
null
;
List
<
Resourc
e
>
shiftEmpDetails
=
new
ArrayList
<>();
List
<
Project
>
projects
=
projectRepo
.
findAll
();
for
(
Project
pt
:
projects
)
{
if
(
"Active"
.
equalsIgnoreCase
(
pt
.
getStatus
()))
{
employeeDetails
=
projectTeamMatesRepo
.
findByProjectId
(
pt
.
getProjectId
());
for
(
ProjectTeamMat
e
emp
:
employeeDetails
)
{
for
(
Resourc
e
emp
:
employeeDetails
)
{
if
(
emp
.
getShift
()
!=
null
&&
emp
.
getShift
().
equalsIgnoreCase
(
shift
)
&&
emp
.
isActive
())
{
shiftEmpDetails
.
add
(
emp
);
}
else
if
(
emp
.
getShift
()
==
null
&&
"Shift 1(9:00 AM - 6:00 PM)"
.
equalsIgnoreCase
(
shift
)
&&
emp
.
isActive
())
...
...
@@ -779,12 +783,12 @@ public class ProjectService implements IProjectService {
}
@Override
public
List
<
ProjectTeamMat
e
>
getAllProjectDetails
()
{
public
List
<
Resourc
e
>
getAllProjectDetails
()
{
List
<
Project
>
projects
=
projectRepo
.
findAll
();
List
<
ProjectTeamMat
e
>
allprojectMates
=
new
ArrayList
<>();
List
<
Resourc
e
>
allprojectMates
=
new
ArrayList
<>();
for
(
Project
pt
:
projects
)
{
if
(!
"Completed"
.
equalsIgnoreCase
(
pt
.
getStatus
()))
{
List
<
ProjectTeamMat
e
>
employeeDetails
=
projectTeamMatesRepo
List
<
Resourc
e
>
employeeDetails
=
projectTeamMatesRepo
.
findByProjectId
(
pt
.
getProjectId
());
allprojectMates
.
addAll
(
employeeDetails
);
}
...
...
@@ -794,10 +798,10 @@ public class ProjectService implements IProjectService {
}
@Override
public
List
<
ProjectTeamMat
e
>
getProjectDetails
(
String
projectId
,
String
statusFlag
)
{
List
<
ProjectTeamMat
e
>
teamMatesList
=
new
ArrayList
<>();
List
<
ProjectTeamMat
e
>
teamMates
=
projectTeamMatesRepo
.
findByProjectId
(
projectId
);
for
(
ProjectTeamMat
e
projectTeamMate
:
teamMates
)
{
public
List
<
Resourc
e
>
getProjectDetails
(
String
projectId
,
String
statusFlag
)
{
List
<
Resourc
e
>
teamMatesList
=
new
ArrayList
<>();
List
<
Resourc
e
>
teamMates
=
projectTeamMatesRepo
.
findByProjectId
(
projectId
);
for
(
Resourc
e
projectTeamMate
:
teamMates
)
{
Date
endDate
=
projectTeamMate
.
getEndDate
();
if
(
endDate
!=
null
)
{
// Active
...
...
@@ -813,84 +817,87 @@ public class ProjectService implements IProjectService {
}
@Override
public
List
<
ProjectTeamMat
e
>
getMyProjectAllocations
(
String
empId
)
{
public
List
<
Resourc
e
>
getMyProjectAllocations
(
String
empId
)
{
return
projectTeamMatesRepo
.
findByEmployeeId
(
empId
);
}
@Override
public
List
<
Billing
Details
>
getEmployeeBillingDetails
(
String
empId
,
String
projectId
)
{
List
<
Billing
Details
>
billings
=
teamMatesBillingRepo
.
findByEmployeeIdAndProjectId
(
empId
,
projectId
);
List
<
Billing
Details
>
billingsSorted
=
billings
;
public
List
<
Billing
>
getEmployeeBillingDetails
(
String
empId
,
String
projectId
)
{
List
<
Billing
>
billings
=
teamMatesBillingRepo
.
findByEmployeeIdAndProjectId
(
empId
,
projectId
);
List
<
Billing
>
billingsSorted
=
billings
;
try
{
billingsSorted
=
(
billings
==
null
||
billings
.
size
()
==
0
)
?
billings
:
billings
.
stream
().
sorted
(
Comparator
.
comparing
(
Billing
Details
:
:
getCreatedOn
).
reversed
()).
collect
(
Collectors
.
toList
());
Comparator
.
comparing
(
Billing:
:
getCreatedOn
).
reversed
()).
collect
(
Collectors
.
toList
());
}
catch
(
Exception
e
)
{
}
return
billingsSorted
;
}
@Override
public
List
<
Billing
Details
>
getEmployeeBillingDetailsAll
(
String
empId
)
{
List
<
Billing
Details
>
billings
=
teamMatesBillingRepo
.
findByEmployeeId
(
empId
);
List
<
Billing
Details
>
billingsSorted
=
billings
;
public
List
<
Billing
>
getEmployeeBillingDetailsAll
(
String
empId
)
{
List
<
Billing
>
billings
=
teamMatesBillingRepo
.
findByEmployeeId
(
empId
);
List
<
Billing
>
billingsSorted
=
billings
;
try
{
billingsSorted
=
(
billings
==
null
||
billings
.
size
()
==
0
)
?
billings
:
billings
.
stream
().
sorted
(
Comparator
.
comparing
(
Billing
Details
:
:
getCreatedOn
).
reversed
()).
collect
(
Collectors
.
toList
());
Comparator
.
comparing
(
Billing:
:
getCreatedOn
).
reversed
()).
collect
(
Collectors
.
toList
());
}
catch
(
Exception
e
)
{
}
return
billingsSorted
;
}
@Override
public
List
<
Billing
Details
>
getEmployeeActiveBillingDetails
(
String
empId
,
String
projectId
)
{
public
List
<
Billing
>
getEmployeeActiveBillingDetails
(
String
empId
,
String
projectId
)
{
Query
query4
=
new
Query
();
query4
.
addCriteria
(
Criteria
.
where
(
"active"
).
is
(
new
Boolean
(
true
)));
query4
.
addCriteria
(
Criteria
.
where
(
"employeeId"
).
is
(
empId
));
query4
.
addCriteria
(
Criteria
.
where
(
"projectId"
).
is
(
projectId
));
List
<
Billing
Details
>
billings
=
mongoTemplate
.
find
(
query4
,
BillingDetails
.
class
);
List
<
Billing
Details
>
billingsSorted
=
billings
;
List
<
Billing
>
billings
=
mongoTemplate
.
find
(
query4
,
Billing
.
class
);
List
<
Billing
>
billingsSorted
=
billings
;
try
{
billingsSorted
=
(
billings
==
null
||
billings
.
size
()
==
0
)
?
billings
:
billings
.
stream
().
sorted
(
Comparator
.
comparing
(
Billing
Details
:
:
getBillingStartDate
).
reversed
()).
collect
(
Collectors
.
toList
());
Comparator
.
comparing
(
Billing:
:
getBillingStartDate
).
reversed
()).
collect
(
Collectors
.
toList
());
}
catch
(
Exception
e
)
{
}
return
billingsSorted
;
}
@Override
public
List
<
Billing
Details
>
getEmployeeActiveNisumBench
(
String
empId
)
{
public
List
<
Billing
>
getEmployeeActiveNisumBench
(
String
empId
)
{
Query
query4
=
new
Query
();
query4
.
addCriteria
(
Criteria
.
where
(
"active"
).
is
(
new
Boolean
(
true
)));
query4
.
addCriteria
(
Criteria
.
where
(
"projectId"
).
is
(
"Nisum0000"
));
query4
.
addCriteria
(
Criteria
.
where
(
"employeeId"
).
is
(
empId
));
List
<
Billing
Details
>
billings
=
mongoTemplate
.
find
(
query4
,
BillingDetails
.
class
);
List
<
Billing
Details
>
billingsSorted
=
billings
;
List
<
Billing
>
billings
=
mongoTemplate
.
find
(
query4
,
Billing
.
class
);
List
<
Billing
>
billingsSorted
=
billings
;
try
{
billingsSorted
=
(
billings
==
null
||
billings
.
size
()
==
0
)
?
billings
:
billings
.
stream
().
sorted
(
Comparator
.
comparing
(
Billing
Details
:
:
getBillingStartDate
).
reversed
()).
collect
(
Collectors
.
toList
());
Comparator
.
comparing
(
Billing:
:
getBillingStartDate
).
reversed
()).
collect
(
Collectors
.
toList
());
}
catch
(
Exception
e
)
{
}
return
billingsSorted
;
}
@Override
public
Billing
Details
addEmployeeBillingDetails
(
BillingDetails
billingDetails
,
String
loginEmpId
)
{
public
Billing
addEmployeeBillingDetails
(
Billing
billingDetails
,
String
loginEmpId
)
{
billingDetails
.
setAuditFields
(
loginEmpId
,
MyTimeUtils
.
CREATE
);
//Setting audit fields
return
teamMatesBillingRepo
.
save
(
billingDetails
);
}
@Override
public
Billing
Details
updateEmployeeBilling
(
BillingDetails
billingDetails
,
String
loginEmpId
)
{
public
Billing
updateEmployeeBilling
(
Billing
billingDetails
,
String
loginEmpId
)
{
billingDetails
.
setAuditFields
(
loginEmpId
,
MyTimeUtils
.
UPDATE
);
//Setting audit fields
return
teamMatesBillingRepo
.
save
(
billingDetails
);
}
// Update ProjectEndDate column data in ProjectTeamMate.
private
void
updateProjectEndDateInProjectTeamMate
(
ProjectTeamMate
projectTeamMate
,
String
loginEmpId
)
{
List
<
ProjectTeamMate
>
projectTeamMateList
=
mongoTemplate
.
find
(
getQuery
(
projectTeamMate
.
getEmployeeId
(),
MyTimeUtils
.
ENDDATE_COLUMN
),
ProjectTeamMate
.
class
);
private
void
updateProjectEndDateInProjectTeamMate
(
Resource
projectTeamMate
,
String
loginEmpId
)
{
List
<
Resource
>
projectTeamMateList
=
mongoTemplate
.
find
(
getQuery
(
projectTeamMate
.
getEmployeeId
(),
MyTimeUtils
.
ENDDATE_COLUMN
),
Resource
.
class
);
log
.
info
(
"the project teamates list is::"
+
projectTeamMateList
);
if
(!
CollectionUtils
.
isEmpty
(
projectTeamMateList
))
{
ProjectTeamMate
teamMate
=
projectTeamMateList
.
get
(
0
);
Resource
teamMate
=
projectTeamMateList
.
get
(
0
);
if
(
projectTeamMate
.
getNewBillingStartDate
()!=
null
)
{
Date
d
=
projectTeamMate
.
getNewBillingStartDate
();
Calendar
cal
=
Calendar
.
getInstance
();
cal
.
setTime
(
d
);
...
...
@@ -902,6 +909,8 @@ public class ProjectService implements IProjectService {
}
else
{
teamMate
.
setEndDate
(
DateUtils
.
truncate
(
oneDayLess
,
Calendar
.
DATE
));
}
}
teamMate
.
setActive
(
false
);
teamMate
.
setAuditFields
(
loginEmpId
,
MyTimeUtils
.
UPDATE
);
//Setting audit fields
projectTeamMatesRepo
.
save
(
teamMate
);
...
...
@@ -952,7 +961,7 @@ public class ProjectService implements IProjectService {
}
@Override
public
void
deleteEmployeeBilling
(
Billing
Details
teamMate
)
{
public
void
deleteEmployeeBilling
(
Billing
teamMate
)
{
teamMatesBillingRepo
.
delete
(
teamMate
);
}
...
...
@@ -964,8 +973,8 @@ public class ProjectService implements IProjectService {
Map
<
String
,
Object
>
teamMatesStatusMap
=
new
HashMap
();
// Find all active employees
List
<
ProjectTeamMat
e
>
teamMates
=
projectTeamMatesRepo
.
findAll
();
for
(
ProjectTeamMat
e
teamMate
:
teamMates
)
{
List
<
Resourc
e
>
teamMates
=
projectTeamMatesRepo
.
findAll
();
for
(
Resourc
e
teamMate
:
teamMates
)
{
if
(
teamMate
.
isActive
())
{
Project
project
=
projectRepo
.
findByProjectId
(
teamMate
.
getProjectId
());
...
...
@@ -997,7 +1006,7 @@ public class ProjectService implements IProjectService {
List
listOfTeamMates
=
(
List
)
value
;
String
billableStatus
=
"NA"
;
for
(
Object
obj
:
listOfTeamMates
)
{
ProjectTeamMate
projectTeamMate
=
(
ProjectTeamMat
e
)
obj
;
Resource
projectTeamMate
=
(
Resourc
e
)
obj
;
String
status
=
projectTeamMate
.
getBillableStatus
();
if
(
status
==
null
)
{
status
=
"NA"
;
...
...
@@ -1022,7 +1031,7 @@ public class ProjectService implements IProjectService {
}
@Override
public
List
<
ProjectTeamMat
e
>
findByAccountAndActiveAndBillableStatus
(
public
List
<
Resourc
e
>
findByAccountAndActiveAndBillableStatus
(
String
account
,
boolean
status
,
String
billableStatus
)
{
return
projectTeamMatesRepo
.
findByAccountAndActiveAndBillableStatus
(
account
,
status
,
billableStatus
);
...
...
@@ -1044,18 +1053,18 @@ public class ProjectService implements IProjectService {
}
@Override
public
String
addProjectTeamMateWithCheck
(
ProjectTeamMat
e
projectTeamMate
,
String
loginEmpId
)
throws
MyTimeException
{
public
String
addProjectTeamMateWithCheck
(
Resourc
e
projectTeamMate
,
String
loginEmpId
)
throws
MyTimeException
{
boolean
flag
=
false
;
String
projectName
=
null
;
String
fromDate
=
null
;
String
toDate
=
null
;
String
result
=
null
;
List
<
ProjectTeamMat
e
>
teamMateList
=
projectTeamMatesRepo
.
findByEmployeeId
(
projectTeamMate
.
getEmployeeId
()).
stream
()
List
<
Resourc
e
>
teamMateList
=
projectTeamMatesRepo
.
findByEmployeeId
(
projectTeamMate
.
getEmployeeId
()).
stream
()
.
filter
(
e
->
!(
"Nisum0000"
.
equalsIgnoreCase
(
e
.
getProjectId
())))
.
sorted
(
Comparator
.
comparing
(
ProjectTeamMat
e:
:
getEndDate
).
reversed
())
.
sorted
(
Comparator
.
comparing
(
Resourc
e:
:
getEndDate
).
reversed
())
.
collect
(
Collectors
.
toList
());
// Checking, if resource has existing project assignment.
for
(
ProjectTeamMat
e
projectMate
:
teamMateList
)
{
for
(
Resourc
e
projectMate
:
teamMateList
)
{
if
(
projectMate
.
getEndDate
()
!=
null
&&
(
projectMate
.
getEndDate
().
compareTo
(
new
Date
())
>
0
))
{
flag
=
true
;
projectName
=
projectMate
.
getProjectName
();
...
...
@@ -1078,10 +1087,10 @@ public class ProjectService implements IProjectService {
}
private
String
validateNewProjectAssignmentStartDate
(
List
<
ProjectTeamMate
>
teamMateList
,
ProjectTeamMat
e
projectTeamMate
)
{
private
String
validateNewProjectAssignmentStartDate
(
List
<
Resource
>
teamMateList
,
Resourc
e
projectTeamMate
)
{
String
response
=
null
;
if
(
teamMateList
!=
null
&&
teamMateList
.
size
()
>
0
)
{
ProjectTeamMat
e
ptMate
=
teamMateList
.
get
(
0
);
Resourc
e
ptMate
=
teamMateList
.
get
(
0
);
if
(
projectTeamMate
.
getNewBillingStartDate
().
compareTo
(
ptMate
.
getEndDate
())
<=
0
)
{
response
=
"Resource Start Date ("
+
projectTeamMate
.
getNewBillingStartDate
()
+
" ) in "
+
projectTeamMate
.
getProjectName
()
+
" project should be after "
+
ptMate
.
getProjectName
()
+
" project End Date ( "
+
ptMate
.
getEndDate
()
+
")."
;
...
...
@@ -1092,7 +1101,7 @@ public class ProjectService implements IProjectService {
return
response
;
}
private
String
validateAgainstDOJ
(
ProjectTeamMat
e
projectTeamMate
)
{
private
String
validateAgainstDOJ
(
Resourc
e
projectTeamMate
)
{
String
response
=
null
;
Date
empDoj
=
employeeRolesRepo
.
findByEmployeeId
(
projectTeamMate
.
getEmployeeId
()).
getDateOfJoining
();
if
(
projectTeamMate
.
getNewBillingStartDate
().
compareTo
(
empDoj
)
<
0
)
{
...
...
@@ -1111,10 +1120,10 @@ public class ProjectService implements IProjectService {
Account
account
=
null
;
Domain
domain
=
null
;
List
<
ProjectTeamMat
e
>
projectAllocations
=
getMyProjectAllocations
(
empId
);
List
<
Resourc
e
>
projectAllocations
=
getMyProjectAllocations
(
empId
);
if
(
null
!=
projectAllocations
&&
!
projectAllocations
.
isEmpty
()
&&
MyTimeUtils
.
INT_ZERO
<
projectAllocations
.
size
())
{
for
(
ProjectTeamMat
e
ptm
:
projectAllocations
)
{
for
(
Resourc
e
ptm
:
projectAllocations
)
{
projectMap
=
new
HashMap
<>();
project
=
projectRepo
.
findByProjectId
(
ptm
.
getProjectId
());
...
...
src/main/java/com/nisum/mytime/service/impl/ResourceService.java
0 → 100644
View file @
cf947c85
package
com
.
nisum
.
mytime
.
service
.
impl
;
import
java.util.Date
;
import
java.util.List
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
com.nisum.mytime.model.Billing
;
import
com.nisum.mytime.model.Employee
;
import
com.nisum.mytime.model.Resource
;
import
com.nisum.mytime.repository.ResourceRepo
;
import
com.nisum.mytime.service.IResourceService
;
import
com.nisum.mytime.utils.MyTimeUtils
;
import
lombok.extern.slf4j.Slf4j
;
@Service
@Slf4j
public
class
ResourceService
implements
IResourceService
{
@Autowired
private
BillingService
billingService
;
@Autowired
private
EmployeeShiftService
empShiftService
;
@Autowired
private
ResourceRepo
resourceRepo
;
public
Resource
save
(
Resource
resource
)
{
return
resourceRepo
.
save
(
resource
);
}
public
void
addResources
(
Employee
employee
,
String
loginEmpId
)
{
List
<
Resource
>
resourceList
=
resourceRepo
.
findByEmployeeId
(
employee
.
getEmployeeId
());
if
(
resourceList
!=
null
&&
!
resourceList
.
isEmpty
())
{
for
(
Resource
resource
:
resourceList
)
{
resource
.
setRole
(
employee
.
getRole
());
resource
.
setAuditFields
(
loginEmpId
,
MyTimeUtils
.
UPDATE
);
resourceRepo
.
save
(
resource
);
}
}
// return null;
}
public
void
inactivateResource
(
Employee
employeeReq
,
Employee
employeeUpdated
,
String
loginEmpId
)
{
// inactive the employee from the assigned project
if
(
employeeReq
.
getEmpStatus
().
equals
(
MyTimeUtils
.
IN_ACTIVE_SPACE
)
&&
employeeReq
.
getEndDate
()
!=
null
&&
employeeReq
.
getEndDate
().
compareTo
(
new
Date
())
<=
0
)
{
List
<
Resource
>
resourcesList
=
resourceRepo
.
findByEmployeeIdAndActive
(
employeeReq
.
getEmployeeId
(),
true
);
if
(
resourcesList
.
size
()
==
1
)
{
Resource
resource
=
resourcesList
.
get
(
0
);
resource
.
setActive
(
false
);
resource
.
setEndDate
(
employeeReq
.
getEndDate
());
List
<
Billing
>
billingList
=
billingService
.
getEmployeeActiveBillingDetails
(
resource
.
getEmployeeId
(),
resource
.
getProjectId
());
if
(
billingList
!=
null
&&
!
billingList
.
isEmpty
())
{
billingService
.
addBillingtoResource
(
billingList
.
get
(
0
),
employeeUpdated
,
loginEmpId
);
}
resource
.
setAuditFields
(
loginEmpId
,
MyTimeUtils
.
UPDATE
);
resourceRepo
.
save
(
resource
);
empShiftService
.
updateShiftDetails
(
resource
,
loginEmpId
);
}
}
}
public
List
<
Resource
>
getResources
(
String
empId
)
{
return
resourceRepo
.
findByEmployeeId
(
empId
);
}
}
src/main/java/com/nisum/mytime/service/impl/Role
Info
Service.java
→
src/main/java/com/nisum/mytime/service/impl/RoleService.java
View file @
cf947c85
...
...
@@ -5,25 +5,28 @@ import org.springframework.stereotype.Service;
import
com.nisum.mytime.exception.handler.MyTimeException
;
import
com.nisum.mytime.model.Role
;
import
com.nisum.mytime.repository.RoleInfoRepo
;
import
com.nisum.mytime.service.IRoleInfoService
;
import
com.nisum.mytime.repository.RoleRepo
;
import
com.nisum.mytime.service.IRoleService
;
import
lombok.extern.slf4j.Slf4j
;
@Service
public
class
RoleInfoService
implements
IRoleInfoService
{
@Slf4j
public
class
RoleService
implements
IRoleService
{
@Autowired
Role
InfoRepo
roleInfo
Repo
;
Role
Repo
role
Repo
;
@Override
public
Role
addRole
(
Role
roleInfo
)
throws
MyTimeException
{
return
role
Info
Repo
.
save
(
roleInfo
);
return
roleRepo
.
save
(
roleInfo
);
}
@Override
public
String
getRole
(
String
roleName
)
throws
MyTimeException
{
return
role
Info
Repo
.
findByRoleName
(
roleName
).
getRoleId
();
return
roleRepo
.
findByRoleName
(
roleName
).
getRoleId
();
}
}
src/main/java/com/nisum/mytime/service/impl/ShiftService.java
View file @
cf947c85
...
...
@@ -10,14 +10,19 @@ import com.nisum.mytime.model.Shift;
import
com.nisum.mytime.repository.ShiftRepo
;
import
com.nisum.mytime.service.IShiftService
;
import
lombok.extern.slf4j.Slf4j
;
@Service
public
class
ShiftService
implements
IShiftService
{
@Slf4j
public
class
ShiftService
implements
IShiftService
{
@Autowired
private
ShiftRepo
shiftRepo
;
//
@Override
@Override
public
List
<
Shift
>
getAllShifts
()
throws
MyTimeException
{
return
shiftRepo
.
findAll
();
List
<
Shift
>
shiftsList
=
shiftRepo
.
findAll
();
log
.
info
(
"The shift list details::"
+
shiftsList
);
return
shiftsList
;
}
}
src/main/java/com/nisum/mytime/service/impl/SkillService.java
View file @
cf947c85
...
...
@@ -10,7 +10,10 @@ import com.nisum.mytime.model.Skill;
import
com.nisum.mytime.repository.SkillRepo
;
import
com.nisum.mytime.service.ISkillService
;
import
lombok.extern.slf4j.Slf4j
;
@Service
@Slf4j
public
class
SkillService
implements
ISkillService
{
@Autowired
...
...
src/main/java/com/nisum/mytime/service/impl/UploadXLService.java
0 → 100644
View file @
cf947c85
package
com
.
nisum
.
mytime
.
service
.
impl
;
import
java.lang.reflect.InvocationTargetException
;
import
java.lang.reflect.Method
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Set
;
import
java.util.stream.Collectors
;
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.Employee
;
import
com.nisum.mytime.service.IUploadXLService
;
import
com.nisum.mytime.utils.DataValidations
;
import
com.nisum.mytime.utils.MyTimeUtils
;
import
com.poiji.bind.Poiji
;
import
com.poiji.exception.PoijiExcelType
;
import
com.poiji.option.PoijiOptions
;
import
lombok.extern.slf4j.Slf4j
;
@Service
@Slf4j
public
class
UploadXLService
implements
IUploadXLService
{
@Autowired
EmployeeService
employeeService
;
@Override
public
String
importDataFromExcelFile
(
MultipartFile
file
,
String
logInEmpId
)
throws
MyTimeException
{
String
result
=
""
;
try
{
PoijiOptions
options
=
PoijiOptions
.
PoijiOptionsBuilder
.
settings
().
preferNullOverDefault
(
true
)
.
datePattern
(
"dd-MMM-yyyy"
).
build
();
List
<
Employee
>
employees
=
Poiji
.
fromExcel
(
file
.
getInputStream
(),
PoijiExcelType
.
XLS
,
Employee
.
class
,
options
);
if
(!
employees
.
isEmpty
())
{
result
=
allColumnsExistCheckInExcel
(
employees
.
get
(
MyTimeUtils
.
INT_ZERO
));
if
(!
result
.
isEmpty
())
{
log
.
info
(
"Imported Excel file {} missing column {}"
,
file
.
getOriginalFilename
(),
result
);
return
result
;
}
result
=
duplicateEmpIAndEmptyEmpIdsCheckInImportedExcel
(
employees
);
result
+=
validateExcelRecords
(
employees
);
log
.
info
(
"Partial Import :: Imported {} employee records from file: {}"
,
employees
.
size
(),
file
.
getOriginalFilename
());
for
(
Employee
employee
:
employees
)
{
addEmployee
(
employee
,
logInEmpId
);
}
}
else
{
result
=
"Uploaded file: {"
+
file
.
getOriginalFilename
()
+
"}, is Empty"
;
log
.
info
(
"Uploaded file: {}, is Empty"
,
file
.
getOriginalFilename
());
}
if
(
result
.
isEmpty
())
{
result
=
"Successfully Employees added"
;
log
.
info
(
"Full Import :: Imported {} employee records from file: {}"
,
employees
.
size
(),
file
.
getOriginalFilename
());
}
}
catch
(
Exception
e
)
{
log
.
error
(
"Exception occured while exporting the data from excel file due to: {}"
,
e
);
throw
new
MyTimeException
(
"Exception occured while exporting the data from excel file due to :"
+
e
.
getMessage
());
}
return
result
;
}
private
String
allColumnsExistCheckInExcel
(
Employee
emp
)
{
String
resultString
=
"In excel sheet following coloumns are missing::"
;
StringBuffer
result
=
new
StringBuffer
(
resultString
);
Method
[]
empMethodList
=
emp
.
getClass
().
getMethods
();
for
(
Method
empMethod
:
empMethodList
)
{
String
mName
=
empMethod
.
getName
();
if
(
mName
.
startsWith
(
"get"
)
&&
isMethodInvocationRequired
(
mName
))
{
try
{
Object
returnData
=
empMethod
.
invoke
(
emp
);
if
(
returnData
==
null
)
{
mName
=
mName
.
substring
(
3
,
mName
.
length
());
result
.
append
(
mName
).
append
(
MyTimeUtils
.
CAMA
);
}
}
catch
(
IllegalAccessException
|
IllegalArgumentException
|
InvocationTargetException
e
)
{
e
.
printStackTrace
();
}
}
}
resultString
=
result
.
substring
(
resultString
.
length
()
-
1
,
result
.
length
()
-
1
);
if
(
resultString
.
length
()
>
0
)
{
resultString
=
result
.
substring
(
0
,
result
.
length
()
-
1
);
}
return
resultString
;
}
private
boolean
isMethodInvocationRequired
(
String
mName
)
{
boolean
isRequired
=
true
;
if
(
mName
.
contains
(
"getCreatedBy"
))
{
isRequired
=
false
;
}
if
(
mName
.
contains
(
"getModifiedBy"
))
{
isRequired
=
false
;
}
if
(
mName
.
contains
(
"getCreatedOn"
))
{
isRequired
=
false
;
}
if
(
mName
.
contains
(
"getLastModifiedOn"
))
{
isRequired
=
false
;
}
if
(
mName
.
contains
(
"getEndDate"
))
{
isRequired
=
false
;
}
if
(
mName
.
contains
(
"getId"
))
{
isRequired
=
false
;
}
if
(
mName
.
contains
(
"getClass"
))
{
isRequired
=
false
;
}
if
(
mName
.
contains
(
"getPassportExpiryDate"
))
{
isRequired
=
false
;
}
if
(
mName
.
contains
(
"getB1ExpiryDate"
))
{
isRequired
=
false
;
}
if
(
mName
.
contains
(
"getDateOfBirth"
))
{
isRequired
=
false
;
}
return
isRequired
;
}
private
String
duplicateEmpIAndEmptyEmpIdsCheckInImportedExcel
(
List
<
Employee
>
employees
)
{
int
rowNum
=
MyTimeUtils
.
INT_TWO
;
StringBuffer
emptyEmpIds
=
new
StringBuffer
();
StringBuffer
duplicteEmpIds
=
new
StringBuffer
();
List
<
String
>
empIdsList
=
new
ArrayList
<
String
>();
String
result
=
""
;
for
(
Employee
emp
:
employees
)
{
String
empId
=
emp
.
getEmployeeId
().
trim
();
if
(
empId
.
isEmpty
())
{
employees
.
remove
(
emp
);
emptyEmpIds
.
append
(
rowNum
).
append
(
MyTimeUtils
.
CAMA
);
}
else
if
(
empIdsList
.
contains
(
empId
))
{
employees
.
remove
(
emp
);
duplicteEmpIds
.
append
(
empId
).
append
(
MyTimeUtils
.
CAMA
);
}
else
{
empIdsList
.
add
(
empId
);
// For, Duplicate check.
}
++
rowNum
;
}
if
(
emptyEmpIds
.
length
()
>
0
)
{
result
=
"Below employee records have empty employee id :"
+
emptyEmpIds
.
toString
();
}
if
(
duplicteEmpIds
.
length
()
>
0
)
{
result
+=
":: \n Below employee records have duplicate employee Ids "
+
duplicteEmpIds
.
toString
();
}
return
result
;
}
private
String
validateExcelRecords
(
List
<
Employee
>
employees
)
{
List
<
String
>
inValidEmpRecList
=
new
ArrayList
<
String
>();
String
result
=
""
;
boolean
mandatoryFlag
=
true
;
int
rowNumber
=
1
;
List
<
Employee
>
invalidEmpRecs
=
new
ArrayList
<
Employee
>();
Set
<
String
>
empIdsSet
=
employees
.
stream
().
map
(
Employee:
:
getEmployeeId
).
collect
(
Collectors
.
toSet
());
List
<
Employee
>
existingEmployess
=
employeeService
.
getEmployeesFromList
(
empIdsSet
);
if
(
existingEmployess
.
size
()
>
MyTimeUtils
.
INT_ZERO
)
{
result
=
"Below employee records already existed : \n"
+
existingEmployess
.
stream
().
map
(
Employee:
:
getEmployeeId
).
collect
(
Collectors
.
toSet
()).
toString
();
employees
.
removeAll
(
existingEmployess
);
}
for
(
Employee
emp
:
employees
)
{
rowNumber
+=
1
;
mandatoryFlag
=
importExcelMandatoryColumnsValidation
(
emp
);
if
(
mandatoryFlag
)
{
importExcelAdditionalColumnVAlidation
(
emp
,
inValidEmpRecList
,
invalidEmpRecs
,
rowNumber
);
}
else
{
addInValidRecord
(
inValidEmpRecList
,
invalidEmpRecs
,
emp
,
rowNumber
);
}
}
if
(
invalidEmpRecs
.
size
()
>
MyTimeUtils
.
INT_ZERO
)
{
employees
.
removeAll
(
invalidEmpRecs
);
result
+=
"Please check the following row number records : \n"
+
inValidEmpRecList
.
toString
();
}
return
result
;
}
private
boolean
importExcelMandatoryColumnsValidation
(
Employee
emp
)
{
boolean
mandatoryFlag
=
true
;
if
(!
DataValidations
.
validateNumber
(
emp
.
getEmployeeId
()))
{
mandatoryFlag
=
false
;
}
else
if
(!
DataValidations
.
validateName
(
emp
.
getEmployeeName
()))
{
mandatoryFlag
=
false
;
}
else
if
(!
DataValidations
.
isValidGender
(
emp
.
getGender
()))
{
mandatoryFlag
=
false
;
}
else
if
(!
DataValidations
.
isValidDate
(
emp
.
getDateOfJoining
()))
{
mandatoryFlag
=
false
;
}
else
if
(!
DataValidations
.
isValidFunctionalGroup
(
emp
.
getFunctionalGroup
()))
{
mandatoryFlag
=
false
;
}
else
if
(!
DataValidations
.
isValidDesignation
(
emp
.
getDesignation
()))
{
mandatoryFlag
=
false
;
}
else
if
(!
DataValidations
.
isValidWorkLocation
(
emp
.
getEmpLocation
()))
{
mandatoryFlag
=
false
;
}
else
if
(!
DataValidations
.
isValidEmploymentType
(
emp
.
getEmploymentType
()))
{
mandatoryFlag
=
false
;
}
else
if
(!
DataValidations
.
isValidRole
(
emp
.
getRole
()))
{
mandatoryFlag
=
false
;
}
else
if
(!
DataValidations
.
isYesOrNo
(
emp
.
getHasPassort
()))
{
mandatoryFlag
=
false
;
}
else
if
(!
DataValidations
.
isYesOrNo
(
emp
.
getHasB1
()))
{
mandatoryFlag
=
false
;
}
else
if
(!
DataValidations
.
isValidEmail
(
emp
.
getEmailId
()))
{
mandatoryFlag
=
false
;
}
return
mandatoryFlag
;
}
private
void
importExcelAdditionalColumnVAlidation
(
Employee
emp
,
List
<
String
>
inValidEmpRecList
,
List
<
Employee
>
invalidEmpRecs
,
int
rowNumber
)
{
if
(!
DataValidations
.
isAgeGreaterThanTwenty
(
emp
.
getDateOfBirth
(),
emp
.
getDateOfJoining
()))
{
addInValidRecord
(
inValidEmpRecList
,
invalidEmpRecs
,
emp
,
rowNumber
);
return
;
}
if
(
MyTimeUtils
.
YES
.
equalsIgnoreCase
(
emp
.
getHasPassort
().
trim
())
||
MyTimeUtils
.
STRING_Y
.
equalsIgnoreCase
(
emp
.
getHasPassort
().
trim
()))
{
if
(!
DataValidations
.
isFutureDate
(
emp
.
getPassportExpiryDate
()))
{
addInValidRecord
(
inValidEmpRecList
,
invalidEmpRecs
,
emp
,
rowNumber
);
return
;
}
}
if
(
emp
.
getHasPassort
().
trim
().
isEmpty
()
||
MyTimeUtils
.
NO
.
equalsIgnoreCase
(
emp
.
getHasPassort
().
trim
())
||
MyTimeUtils
.
STRING_N
.
equalsIgnoreCase
(
emp
.
getHasPassort
().
trim
()))
{
if
(
null
!=
emp
.
getPassportExpiryDate
()
||
null
!=
emp
.
getHasB1
().
trim
()
||
null
!=
emp
.
getB1ExpiryDate
())
{
addInValidRecord
(
inValidEmpRecList
,
invalidEmpRecs
,
emp
,
rowNumber
);
return
;
}
}
if
((
MyTimeUtils
.
YES
.
equals
(
emp
.
getHasB1
())
||
MyTimeUtils
.
STRING_Y
.
equals
(
emp
.
getHasB1
()))
&&
!
DataValidations
.
isFutureDate
(
emp
.
getB1ExpiryDate
()))
{
addInValidRecord
(
inValidEmpRecList
,
invalidEmpRecs
,
emp
,
rowNumber
);
return
;
}
if
(!
emp
.
getEmpStatus
().
trim
().
isEmpty
())
{
if
(
null
!=
emp
.
getEndDate
()
&&
(
emp
.
getEmpStatus
().
trim
().
equalsIgnoreCase
(
MyTimeUtils
.
IN_ACTIVE
)
||
emp
.
getEmpStatus
().
trim
().
equalsIgnoreCase
(
MyTimeUtils
.
IN_ACTIVE_SPACE
)
||
emp
.
getEmpStatus
().
trim
().
equalsIgnoreCase
(
MyTimeUtils
.
IN_HYPEN_ACTIVE_SPACE
)))
{
addInValidRecord
(
inValidEmpRecList
,
invalidEmpRecs
,
emp
,
rowNumber
);
return
;
}
if
(
emp
.
getEmpStatus
().
trim
().
equalsIgnoreCase
(
MyTimeUtils
.
ACTIVE
)
&&
null
!=
emp
.
getEndDate
())
{
addInValidRecord
(
inValidEmpRecList
,
invalidEmpRecs
,
emp
,
rowNumber
);
return
;
}
}
}
private
void
addEmployee
(
Employee
employee
,
String
empId
)
{
try
{
if
(
employee
.
getRole
().
trim
().
isEmpty
())
{
employee
.
setRole
(
MyTimeUtils
.
EMPLOYEE
);
}
if
(
employee
.
getEmploymentType
().
trim
().
isEmpty
())
{
employee
.
setEmploymentType
(
MyTimeUtils
.
FULL_TIME
);
}
String
empStatus
=
employee
.
getEmpStatus
().
trim
();
if
(
empStatus
.
isEmpty
())
{
if
(
null
==
employee
.
getEndDate
())
{
employee
.
setEmpStatus
(
MyTimeUtils
.
ACTIVE
);
}
else
{
employee
.
setEmpStatus
(
MyTimeUtils
.
IN_ACTIVE_SPACE
);
}
}
else
if
((
empStatus
.
equalsIgnoreCase
(
MyTimeUtils
.
IN_ACTIVE
)
||
empStatus
.
equalsIgnoreCase
(
MyTimeUtils
.
IN_ACTIVE_SPACE
)
||
empStatus
.
equalsIgnoreCase
(
MyTimeUtils
.
IN_HYPEN_ACTIVE_SPACE
))
&&
null
!=
employee
.
getEndDate
())
{
employee
.
setEmpStatus
(
MyTimeUtils
.
IN_ACTIVE_SPACE
);
}
if
(!
employee
.
getGender
().
trim
().
isEmpty
())
{
if
(
employee
.
getGender
().
equalsIgnoreCase
(
MyTimeUtils
.
MALE
))
{
employee
.
setGender
(
MyTimeUtils
.
MALE
);
}
else
if
(
employee
.
getGender
().
equalsIgnoreCase
(
MyTimeUtils
.
FEMALE
))
{
employee
.
setGender
(
MyTimeUtils
.
FEMALE
);
}
}
employeeService
.
createEmployee
(
employee
,
empId
);
}
catch
(
MyTimeException
e
)
{
e
.
printStackTrace
();
}
}
private
void
addInValidRecord
(
List
<
String
>
inValidEmpRecList
,
List
<
Employee
>
invalidEmpRecs
,
Employee
emp
,
int
rowNumber
)
{
inValidEmpRecList
.
add
(
Integer
.
toString
(
rowNumber
));
invalidEmpRecs
.
add
(
emp
);
}
}
src/main/java/com/nisum/mytime/utils/DataValidations.java
View file @
cf947c85
...
...
@@ -5,15 +5,21 @@ import java.util.Date;
import
java.util.List
;
import
java.util.regex.Matcher
;
import
java.util.regex.Pattern
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
com.nisum.mytime.model.MasterData
;
import
com.nisum.mytime.
repository.LocationRepo
;
import
com.nisum.mytime.
repository.MasterDataRepo
;
import
com.nisum.mytime.
service.IMasterDataService
;
import
com.nisum.mytime.
service.impl.OrgLocationService
;
@Service
public
class
DataValidations
{
@Autowired
static
IMasterDataService
masterDataService
;
@Autowired
static
OrgLocationService
orgLocationService
;
public
static
boolean
validateNumber
(
String
number
)
{
boolean
flag
=
false
;
number
=
number
.
trim
();
...
...
@@ -72,46 +78,46 @@ public class DataValidations {
return
flag
;
}
public
static
boolean
isValidFunctionalGroup
(
String
functionalGroup
,
MasterDataRepo
masterDataRepo
)
{
public
static
boolean
isValidFunctionalGroup
(
String
functionalGroup
)
{
boolean
flag
=
false
;
functionalGroup
=
functionalGroup
.
trim
();
if
(!
MyTimeUtils
.
EMPTY_STRING
.
equals
(
functionalGroup
))
{
List
<
MasterData
>
fsData
=
masterData
Repo
.
findByMasterDataTypeAndMasterDataNameAndActiveStatus
(
MyTimeUtils
.
MASTERDATA_FG
,
functionalGroup
,
true
);
List
<
MasterData
>
fsData
=
masterData
Service
.
findByMasterDataTypeAndMasterDataNameAndActiveStatus
(
MyTimeUtils
.
MASTERDATA_FG
,
functionalGroup
,
true
);
flag
=
fsData
.
size
()
>
MyTimeUtils
.
INT_ZERO
;
}
return
flag
;
}
public
static
boolean
isValidDesignation
(
String
designation
,
MasterDataRepo
masterDataRepo
)
{
public
static
boolean
isValidDesignation
(
String
designation
)
{
boolean
flag
=
false
;
designation
=
designation
.
trim
();
if
(
!
MyTimeUtils
.
EMPTY_STRING
.
equals
(
designation
))
{
List
<
MasterData
>
designationData
=
masterData
Repo
.
findByMasterDataTypeAndMasterDataNameAndActiveStatus
(
MyTimeUtils
.
MASTERDATA_DESIGNATION
,
designation
,
true
);
List
<
MasterData
>
designationData
=
masterData
Service
.
findByMasterDataTypeAndMasterDataNameAndActiveStatus
(
MyTimeUtils
.
MASTERDATA_DESIGNATION
,
designation
,
true
);
flag
=
designationData
.
size
()
>
MyTimeUtils
.
INT_ZERO
;
}
return
flag
;
}
public
static
boolean
isValidEmploymentType
(
String
employmentType
,
MasterDataRepo
masterDataRepo
)
{
public
static
boolean
isValidEmploymentType
(
String
employmentType
)
{
boolean
flag
=
false
;
employmentType
=
employmentType
.
trim
();
if
(
MyTimeUtils
.
EMPTY_STRING
.
equals
(
employmentType
)){
flag
=
true
;
}
else
if
(
!
MyTimeUtils
.
EMPTY_STRING
.
equals
(
employmentType
))
{
List
<
MasterData
>
empTypeData
=
masterData
Repo
.
findByMasterDataTypeAndMasterDataNameAndActiveStatus
(
MyTimeUtils
.
MASTERDATAD_EMLOYMENT_TYPE
,
employmentType
,
true
);
List
<
MasterData
>
empTypeData
=
masterData
Service
.
findByMasterDataTypeAndMasterDataNameAndActiveStatus
(
MyTimeUtils
.
MASTERDATAD_EMLOYMENT_TYPE
,
employmentType
,
true
);
flag
=
empTypeData
.
size
()
>
MyTimeUtils
.
INT_ZERO
;
}
return
flag
;
}
public
static
boolean
isValidRole
(
String
role
,
MasterDataRepo
masterDataRepo
)
{
public
static
boolean
isValidRole
(
String
role
)
{
boolean
flag
=
false
;
role
=
role
.
trim
();
if
(
MyTimeUtils
.
EMPTY_STRING
.
equals
(
role
)){
flag
=
true
;
}
else
if
(!
MyTimeUtils
.
EMPTY_STRING
.
equals
(
role
))
{
List
<
MasterData
>
roleData
=
masterData
Repo
.
findByMasterDataTypeAndMasterDataNameAndActiveStatus
(
MyTimeUtils
.
MASTERDATA_ROLES
,
role
,
true
);
List
<
MasterData
>
roleData
=
masterData
Service
.
findByMasterDataTypeAndMasterDataNameAndActiveStatus
(
MyTimeUtils
.
MASTERDATA_ROLES
,
role
,
true
);
flag
=
roleData
.
size
()
>
MyTimeUtils
.
INT_ZERO
;
}
return
flag
;
...
...
@@ -144,11 +150,11 @@ public class DataValidations {
}
public
static
boolean
isValidWorkLocation
(
String
workLocation
,
LocationRepo
locationRepo
)
{
public
static
boolean
isValidWorkLocation
(
String
workLocation
)
{
boolean
flag
=
false
;
workLocation
=
workLocation
.
trim
();
if
(!
MyTimeUtils
.
EMPTY_STRING
.
equals
(
workLocation
))
{
flag
=
locationRepo
.
findByLocationAndActiveStatus
(
workLocation
,
true
).
size
()
>
MyTimeUtils
.
INT_ZERO
;
flag
=
orgLocationService
.
findByLocationAndActiveStatus
(
workLocation
,
true
).
size
()
>
MyTimeUtils
.
INT_ZERO
;
}
return
flag
;
}
...
...
src/test/java/com/nisum/mytime/controllertest/AttendanceControllerTest.java
View file @
cf947c85
...
...
@@ -25,9 +25,6 @@ import com.nisum.mytime.service.IEmployeeService;
public
class
AttendanceControllerTest
{
@Mock
IEmployeeService
userService
;
@Mock
IAttendanceService
attendanceService
;
...
...
@@ -36,56 +33,57 @@ public class AttendanceControllerTest {
private
MockMvc
mockMvc
;
@Before
public
void
setup
()
{
MockitoAnnotations
.
initMocks
(
this
);
mockMvc
=
MockMvcBuilders
.
standaloneSetup
(
attendanceController
).
build
();
}
@Test
public
void
testemployeeLoginsBasedOnDate
()
throws
Exception
{
List
<
EmpLoginData
>
message
=
createLoginData
();
when
(
user
Service
.
employeeLoginsBasedOnDate
(
12345
,
"2017-11-15"
,
"2017-12-15"
)).
thenReturn
(
message
);
mockMvc
.
perform
(
get
(
"/attendance/employeeLoginsBasedOnDate?empId="
+
12345
).
param
(
"fromDate"
,
"2017-11-15"
).
param
(
"toDate"
,
"2017-12-15"
)
)
.
andDo
(
print
()).
andExpect
(
status
().
isOk
());
when
(
attendance
Service
.
employeeLoginsBasedOnDate
(
12345
,
"2017-11-15"
,
"2017-12-15"
)).
thenReturn
(
message
);
mockMvc
.
perform
(
get
(
"/attendance/employeeLoginsBasedOnDate?empId="
+
12345
).
param
(
"fromDate"
,
"2017-11-15"
)
.
param
(
"toDate"
,
"2017-12-15"
)).
andDo
(
print
()).
andExpect
(
status
().
isOk
());
}
@Test
public
void
testgeneratePdfReport
()
throws
Exception
{
List
list
=
new
ArrayList
();
when
(
userService
.
generatePdfReport
(
12345
,
"2017-11-18"
,
"2017-12-18"
)).
thenReturn
(
list
);
mockMvc
.
perform
(
get
(
"/attendance/generatePdfReport/12345/2017-11-18/2017-12-18"
)).
andExpect
(
MockMvcResultMatchers
.
status
().
isOk
());
verify
(
userService
).
generatePdfReport
(
12345
,
"2017-11-18"
,
"2017-12-18"
);
when
(
attendanceService
.
generatePdfReport
(
12345
,
"2017-11-18"
,
"2017-12-18"
)).
thenReturn
(
list
);
mockMvc
.
perform
(
get
(
"/attendance/generatePdfReport/12345/2017-11-18/2017-12-18"
))
.
andExpect
(
MockMvcResultMatchers
.
status
().
isOk
());
verify
(
attendanceService
).
generatePdfReport
(
12345
,
"2017-11-18"
,
"2017-12-18"
);
}
@Test
public
void
testattendanciesReport
()
throws
Exception
{
public
void
testattendanciesReport
()
throws
Exception
{
List
<
AttendenceData
>
lisOfAttendenceData
=
createAttendenceData
();
when
(
attendanceService
.
getAttendanciesReport
(
"2017-12-29"
,
"All"
)).
thenReturn
(
lisOfAttendenceData
);
mockMvc
.
perform
(
get
(
"/attendance/attendanciesReport/2017-12-29"
).
param
(
"shift"
,
"All"
)).
andExpect
(
MockMvcResultMatchers
.
status
().
isOk
());
verify
(
attendanceService
).
getAttendanciesReport
(
"2017-12-29"
,
"All"
);
when
(
attendanceService
.
getAttendanciesReport
(
"2017-12-29"
,
"All"
)).
thenReturn
(
lisOfAttendenceData
);
mockMvc
.
perform
(
get
(
"/attendance/attendanciesReport/2017-12-29"
).
param
(
"shift"
,
"All"
))
.
andExpect
(
MockMvcResultMatchers
.
status
().
isOk
());
verify
(
attendanceService
).
getAttendanciesReport
(
"2017-12-29"
,
"All"
);
}
@Test
public
void
testemployeesDataSave
()
throws
Exception
{
when
(
userService
.
fetchEmployeesData
(
"2018-01-01"
,
false
)).
thenReturn
(
true
);
mockMvc
.
perform
(
post
(
"/attendance/employeesDataSave/2018-01-01"
)).
andExpect
(
MockMvcResultMatchers
.
status
().
isOk
());
verify
(
userService
).
fetchEmployeesData
(
"2018-01-01"
,
false
);
public
void
testemployeesDataSave
()
throws
Exception
{
when
(
attendanceService
.
fetchEmployeesData
(
"2018-01-01"
,
false
)).
thenReturn
(
true
);
mockMvc
.
perform
(
post
(
"/attendance/employeesDataSave/2018-01-01"
))
.
andExpect
(
MockMvcResultMatchers
.
status
().
isOk
());
verify
(
attendanceService
).
fetchEmployeesData
(
"2018-01-01"
,
false
);
}
private
List
<
AttendenceData
>
createAttendenceData
()
{
List
<
AttendenceData
>
data
=
new
ArrayList
<>();
AttendenceData
record1
=
new
AttendenceData
();
AttendenceData
record1
=
new
AttendenceData
();
record1
.
setEmployeeId
(
"16127"
);
record1
.
setEmployeeName
(
"Monika Srivastava"
);
record1
.
setPresent
(
"Present"
);
record1
.
setTotalAbsent
(
0
);
record1
.
setTotalPresent
(
31
);
AttendenceData
record2
=
new
AttendenceData
();
AttendenceData
record2
=
new
AttendenceData
();
record2
.
setEmployeeId
(
"16157"
);
record2
.
setEmployeeName
(
"Syed Parveen"
);
record2
.
setPresent
(
"Present"
);
...
...
@@ -98,7 +96,6 @@ public class AttendanceControllerTest {
return
data
;
}
private
List
<
EmpLoginData
>
createLoginData
()
{
List
<
EmpLoginData
>
data
=
new
ArrayList
<>();
...
...
@@ -113,7 +110,6 @@ public class AttendanceControllerTest {
data1
.
setDirection
(
"1"
);
data1
.
setTotalAvgTime
(
"08:28"
);
EmpLoginData
data2
=
new
EmpLoginData
();
data2
.
setId
(
"5976ef15874c902c98b8a05c"
);
data2
.
setEmployeeId
(
"01234"
);
...
...
@@ -125,12 +121,10 @@ public class AttendanceControllerTest {
data2
.
setDirection
(
"2"
);
data2
.
setTotalAvgTime
(
"07:51"
);
data
.
add
(
data1
);
data
.
add
(
data2
);
return
data
;
}
}
src/test/java/com/nisum/mytime/controllertest/EmployeeControllerTest.java
View file @
cf947c85
...
...
@@ -33,13 +33,13 @@ import com.nisum.mytime.controller.EmployeeController;
import
com.nisum.mytime.model.Account
;
import
com.nisum.mytime.model.Designation
;
import
com.nisum.mytime.model.Domain
;
import
com.nisum.mytime.model.EmployeeLocation
Details
;
import
com.nisum.mytime.model.EmployeeLocation
;
import
com.nisum.mytime.model.Employee
;
import
com.nisum.mytime.model.Location
;
import
com.nisum.mytime.model.
Org
Location
;
import
com.nisum.mytime.model.MasterData
;
import
com.nisum.mytime.model.Shift
;
import
com.nisum.mytime.model.Skill
;
import
com.nisum.mytime.service.I
RoleMapping
Service
;
import
com.nisum.mytime.service.I
EmployeeRole
Service
;
import
com.nisum.mytime.service.impl.DesignationService
;
import
com.nisum.mytime.service.impl.EmployeeLocationService
;
import
com.nisum.mytime.service.impl.MasterDataService
;
...
...
@@ -54,7 +54,7 @@ public class EmployeeControllerTest {
IEmployeeService
employeeService
;
@Mock
I
RoleMapping
Service
roleMappingService
;
I
EmployeeRole
Service
roleMappingService
;
@InjectMocks
EmployeeController
employeeController
;
...
...
@@ -137,11 +137,11 @@ public class EmployeeControllerTest {
new
Date
(
2018
-
02
-
15
),
new
Date
(
2018
-
02
-
15
),
"Mahesh"
,
"Mahesh"
);
ObjectMapper
mapper
=
new
ObjectMapper
();
String
jsonString
=
mapper
.
writeValueAsString
(
employeeRole2
);
when
(
employeeService
.
updateEmployee
Role
(
anyObject
(),
anyObject
())).
thenReturn
(
employeeRole2
);
when
(
employeeService
.
updateEmployee
(
anyObject
(),
anyObject
())).
thenReturn
(
employeeRole2
);
mockMvc
.
perform
(
post
(
"/user/updateEmployeeRole"
).
param
(
"empId"
,
"16999"
)
.
contentType
(
MediaType
.
APPLICATION_JSON_VALUE
).
content
(
jsonString
))
.
andExpect
(
MockMvcResultMatchers
.
status
().
isOk
());
verify
(
employeeService
).
updateEmployee
Role
(
anyObject
(),
anyObject
());
verify
(
employeeService
).
updateEmployee
(
anyObject
(),
anyObject
());
}
@Test
...
...
@@ -167,27 +167,27 @@ public class EmployeeControllerTest {
null
,
null
,
null
,
"ACI - Support"
,
"Active"
,
null
,
new
Date
(
2017
-
11
-
20
),
new
Date
(
2107
-
12
-
23
),
"Male"
,
null
,
new
Date
(
2020
-
01
-
01
),
null
,
new
Date
(
2018
-
01
-
01
),
new
Date
(
2018
-
02
-
15
),
new
Date
(
2018
-
02
-
15
),
null
,
"Mahesh"
,
"Mahesh"
);
when
(
employeeService
.
getEmployee
sRoleData
(
"16694"
)).
thenReturn
(
employeesRole
);
when
(
employeeService
.
getEmployee
ById
(
"16694"
)).
thenReturn
(
employeesRole
);
mockMvc
.
perform
(
get
(
"/user/getEmployeeRoleData"
).
param
(
"empId"
,
"16694"
).
contentType
(
MediaType
.
APPLICATION_JSON_VALUE
))
.
andExpect
(
MockMvcResultMatchers
.
status
().
isOk
()).
andExpect
(
jsonPath
(
"$.employeeId"
,
is
(
"16694"
)))
.
andDo
(
print
());
verify
(
employeeService
).
getEmployee
sRoleData
(
"16694"
);
verify
(
employeeService
).
getEmployee
ById
(
"16694"
);
}
@Test
public
void
testgetEmployeeLocations
()
throws
Exception
{
List
<
EmployeeLocation
Details
>
empLocList
=
new
ArrayList
<
EmployeeLocationDetails
>();
EmployeeLocation
Details
empLocation
=
new
EmployeeLocationDetails
(
new
ObjectId
(
"5b307d7d708ef705c4ca59c4"
),
List
<
EmployeeLocation
>
empLocList
=
new
ArrayList
<
EmployeeLocation
>();
EmployeeLocation
empLocation
=
new
EmployeeLocation
(
new
ObjectId
(
"5b307d7d708ef705c4ca59c4"
),
"16090"
,
"Dharmendra Kumar Jampana"
,
"Hyderabad"
,
new
Date
(
2020
-
01
-
01
),
new
Date
(
2018
-
01
-
01
),
new
Date
(
2018
-
02
-
15
),
new
Date
(
2018
-
02
-
15
),
true
);
empLocList
.
add
(
empLocation
);
when
(
empLocationService
.
getEmployeeLocation
Detail
s
(
"16090"
)).
thenReturn
(
empLocList
);
when
(
empLocationService
.
getEmployeeLocations
(
"16090"
)).
thenReturn
(
empLocList
);
mockMvc
.
perform
(
get
(
"/user/getEmployeeLocations"
).
param
(
"employeeId"
,
"16090"
)
.
contentType
(
MediaType
.
APPLICATION_JSON_VALUE
)).
andExpect
(
MockMvcResultMatchers
.
status
().
isOk
());
verify
(
empLocationService
).
getEmployeeLocation
Detail
s
(
"16090"
);
verify
(
empLocationService
).
getEmployeeLocations
(
"16090"
);
}
@Test
...
...
@@ -329,15 +329,15 @@ public class EmployeeControllerTest {
verify
(
employeeService
).
getEmployeesByStatus
(
"Active"
);
}
@Test
public
void
testgetdomains
()
throws
Exception
{
when
(
employeeService
.
getDomains
(
"Acc001"
)).
thenReturn
(
domains
());
mockMvc
.
perform
(
get
(
"/user/getDomains"
).
param
(
"accountId"
,
"Acc001"
))
.
andExpect
(
MockMvcResultMatchers
.
status
().
isOk
());
verify
(
employeeService
).
getDomains
(
"Acc001"
);
}
//
@Test
//
public void testgetdomains() throws Exception {
//
//
when(employeeService.getDomains("Acc001")).thenReturn(domains());
//
mockMvc.perform(get("/user/getDomains").param("accountId", "Acc001"))
//
.andExpect(MockMvcResultMatchers.status().isOk());
//
verify(employeeService).getDomains("Acc001");
//
//
}
@Test
public
void
testgetDeliveryLeads
()
throws
Exception
{
...
...
@@ -523,12 +523,12 @@ public class EmployeeControllerTest {
return
employeeRoles
;
}
private
List
<
Location
>
locations
()
{
List
<
Location
>
empLocation
=
new
ArrayList
<
Location
>();
private
List
<
Org
Location
>
locations
()
{
List
<
OrgLocation
>
empLocation
=
new
ArrayList
<
Org
Location
>();
Location
l1
=
new
Location
(
new
ObjectId
(
"5b307c9c927173017882543b"
),
"IN_HYD"
,
"Hyderabad Appstek Building"
,
OrgLocation
l1
=
new
Org
Location
(
new
ObjectId
(
"5b307c9c927173017882543b"
),
"IN_HYD"
,
"Hyderabad Appstek Building"
,
"India"
,
"Telangana"
,
"Hyderabad"
,
true
,
"testing"
);
Location
l2
=
new
Location
(
new
ObjectId
(
"5b307c9c927173017882543a"
),
"NY_SF"
,
"Pleasonton Gap Office"
,
"USA"
,
OrgLocation
l2
=
new
Org
Location
(
new
ObjectId
(
"5b307c9c927173017882543a"
),
"NY_SF"
,
"Pleasonton Gap Office"
,
"USA"
,
"CA"
,
"SanFransisco"
,
true
,
"testing"
);
empLocation
.
add
(
l1
);
empLocation
.
add
(
l2
);
...
...
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