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
0861416c
Commit
0861416c
authored
May 04, 2019
by
Vijay Akula
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added response format for the get methods of resource controller
parent
97c144c6
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
298 additions
and
233 deletions
+298
-233
ResourceController.java
.../java/com/nisum/myteam/controller/ResourceController.java
+230
-174
ResourceService.java
...n/java/com/nisum/myteam/service/impl/ResourceService.java
+68
-59
No files found.
src/main/java/com/nisum/myteam/controller/ResourceController.java
View file @
0861416c
...
...
@@ -97,75 +97,131 @@ public class ResourceController {
// @RequestMapping(value = "/getEmployeeProjectInfo"
@RequestMapping
(
value
=
"/resources/employeeId/{employeeId}"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
List
<
Resource
>>
getResourcesSortByStartDate
(
@PathVariable
(
value
=
"employeeId"
,
required
=
true
)
String
employeeId
)
public
ResponseEntity
<?>
getResourcesSortByStartDate
(
@PathVariable
(
value
=
"employeeId"
,
required
=
true
)
String
employeeId
,
HttpServletRequest
request
)
throws
MyTeamException
{
List
<
Resource
>
projectInfo
=
resourceService
.
getResourcesSortByStartDate
(
employeeId
);
return
new
ResponseEntity
<>(
projectInfo
,
HttpStatus
.
OK
);
if
(
StringUtils
.
isNotBlank
(
employeeId
))
{
List
<
Resource
>
resourcesList
=
resourceService
.
getResourcesSortByStartDate
(
employeeId
);
ResponseDetails
responseDetails
=
new
ResponseDetails
(
new
Date
(),
602
,
"Resources have been retrieved successfully"
,
"List of Resources for an employee"
,
resourcesList
,
request
.
getRequestURI
(),
"Resource List details"
,
null
);
return
new
ResponseEntity
<
ResponseDetails
>(
responseDetails
,
HttpStatus
.
OK
);
}
ResponseDetails
responseDetails
=
new
ResponseDetails
(
new
Date
(),
602
,
"Please provide the valid Employee Id"
,
"Employee Id is not valid"
,
null
,
request
.
getRequestURI
(),
"Resource details"
,
null
);
return
new
ResponseEntity
<
ResponseDetails
>(
responseDetails
,
HttpStatus
.
OK
);
}
//@RequestMapping(value = "/getMyTeamDetails"
@RequestMapping
(
value
=
"/resources/active"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
List
<
Resource
>>
getActiveResources
(
@RequestParam
(
"employeeId"
)
String
employeeId
)
public
ResponseEntity
<?>
getActiveResources
(
@RequestParam
(
value
=
"employeeId"
,
required
=
false
)
String
employeeId
,
HttpServletRequest
request
)
throws
MyTeamException
{
if
(
StringUtils
.
isNotBlank
(
employeeId
))
{
List
<
Resource
>
employeesRoles
=
resourceService
.
getActiveResources
(
employeeId
);
return
new
ResponseEntity
<>(
employeesRoles
,
HttpStatus
.
OK
);
}
ResponseDetails
responseDetails
=
new
ResponseDetails
(
new
Date
(),
602
,
"Resources have been retrieved successfully"
,
"List of Resources who are active in the projects"
,
employeesRoles
,
request
.
getRequestURI
(),
"Resource List details"
,
null
);
return
new
ResponseEntity
<
ResponseDetails
>(
responseDetails
,
HttpStatus
.
OK
);
}
ResponseDetails
responseDetails
=
new
ResponseDetails
(
new
Date
(),
602
,
"Please provide the valid Employee Id"
,
"Employee Id is not valid"
,
null
,
request
.
getRequestURI
(),
"Resource details"
,
null
);
return
new
ResponseEntity
<
ResponseDetails
>(
responseDetails
,
HttpStatus
.
OK
);
}
// @RequestMapping(value = "/getShiftDetails"
@RequestMapping
(
value
=
"/resources/shifts/{shift}"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
List
<
Resource
>>
getResourcesForShift
(
@PathVariable
(
"shift"
)
String
shif
t
)
public
ResponseEntity
<?>
getResourcesForShift
(
@PathVariable
(
value
=
"shift"
,
required
=
true
)
String
shift
,
HttpServletRequest
reques
t
)
throws
MyTeamException
{
if
(
StringUtils
.
isNotBlank
(
shift
))
{
List
<
Resource
>
resourcesList
=
resourceService
.
getResourcesForShift
(
shift
);
return
new
ResponseEntity
<>(
resourcesList
,
HttpStatus
.
OK
);
ResponseDetails
responseDetails
=
new
ResponseDetails
(
new
Date
(),
602
,
"Resources have been retrieved successfully"
,
"List of Resources for the provided shift"
,
resourcesList
,
request
.
getRequestURI
(),
"Resource List for shift"
,
null
);
return
new
ResponseEntity
<
ResponseDetails
>(
responseDetails
,
HttpStatus
.
OK
);
}
ResponseDetails
responseDetails
=
new
ResponseDetails
(
new
Date
(),
602
,
"Please provide the valid Shift value"
,
"List of Resources for the provided shift"
,
null
,
request
.
getRequestURI
(),
"Resource details"
,
null
);
return
new
ResponseEntity
<
ResponseDetails
>(
responseDetails
,
HttpStatus
.
OK
);
}
// @RequestMapping(value = "/getProjectAllocations"
@RequestMapping
(
value
=
"/resources/projects"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
List
<
Resource
>>
getResourcesAllocatedForAllProjects
()
throws
MyTeamException
{
public
ResponseEntity
<?>
getResourcesAllocatedForAllProjects
(
HttpServletRequest
request
)
throws
MyTeamException
{
List
<
Resource
>
resourcesList
=
resourceService
.
getResourcesForActiveProjects
();
return
new
ResponseEntity
<>(
resourcesList
,
HttpStatus
.
OK
);
ResponseDetails
responseDetails
=
new
ResponseDetails
(
new
Date
(),
602
,
"Resources have been retrieved successfully"
,
"List of Resources for the projects"
,
resourcesList
,
request
.
getRequestURI
(),
"Resource details"
,
null
);
return
new
ResponseEntity
<
ResponseDetails
>(
responseDetails
,
HttpStatus
.
OK
);
}
// @RequestMapping(value = "/getProjectDetails"
@RequestMapping
(
value
=
"/resources/project/{projectId}"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
List
<
Resource
>>
getResourcesForProject
(
@PathVariable
(
"projectId"
)
String
projectId
,
@RequestParam
(
value
=
"status"
,
required
=
false
,
defaultValue
=
MyTeamUtils
.
ACTIVE
)
String
status
)
public
ResponseEntity
<?>
getResourcesForProject
(
@PathVariable
(
value
=
"projectId"
,
required
=
true
)
String
projectId
,
@RequestParam
(
value
=
"status"
,
required
=
false
,
defaultValue
=
MyTeamUtils
.
ACTIVE
)
String
status
,
HttpServletRequest
request
)
throws
MyTeamException
{
if
(
StringUtils
.
isNotBlank
(
projectId
))
{
List
<
Resource
>
resourcesList
=
resourceService
.
getResourcesForProject
(
projectId
,
status
);
return
new
ResponseEntity
<>(
resourcesList
,
HttpStatus
.
OK
);
ResponseDetails
responseDetails
=
new
ResponseDetails
(
new
Date
(),
602
,
"Resources have been retrieved successfully"
,
"List of Resources for a project"
,
resourcesList
,
request
.
getRequestURI
(),
"Resource details"
,
null
);
return
new
ResponseEntity
<
ResponseDetails
>(
responseDetails
,
HttpStatus
.
OK
);
}
ResponseDetails
responseDetails
=
new
ResponseDetails
(
new
Date
(),
602
,
"Please provide ProjectId"
,
"List of Resources for a project"
,
null
,
request
.
getRequestURI
(),
"Resource details"
,
null
);
return
new
ResponseEntity
<
ResponseDetails
>(
responseDetails
,
HttpStatus
.
OK
);
}
//@RequestMapping(value = "/getTeamDetails"
@RequestMapping
(
value
=
"/resources/deliverylead/{deliveryLeadId}"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
List
<
Resource
>>
getTeamDetails
(
@PathVariable
(
"deliveryLeadId"
)
String
deliveryLeadId
)
public
ResponseEntity
<?>
getTeamDetails
(
@PathVariable
(
value
=
"deliveryLeadId"
,
required
=
true
)
String
deliveryLeadId
,
HttpServletRequest
request
)
throws
MyTeamException
{
if
(
StringUtils
.
isNotBlank
(
deliveryLeadId
))
{
List
<
Resource
>
resourcesList
=
resourceService
.
getResourcesUnderDeliveryLead
(
deliveryLeadId
);
return
new
ResponseEntity
<>(
resourcesList
,
HttpStatus
.
OK
);
ResponseDetails
responseDetails
=
new
ResponseDetails
(
new
Date
(),
602
,
"Resources have been retrieved successfully"
,
"List of Resources for a project"
,
resourcesList
,
request
.
getRequestURI
(),
"Resource details"
,
null
);
}
ResponseDetails
responseDetails
=
new
ResponseDetails
(
new
Date
(),
602
,
"Please provide ProjectId"
,
"List of Resources for DeliveryLead"
,
null
,
request
.
getRequestURI
(),
"Resource details"
,
null
);
return
new
ResponseEntity
<
ResponseDetails
>(
responseDetails
,
HttpStatus
.
OK
);
}
@RequestMapping
(
value
=
"resources/unAssignedEmployees"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
List
<
Employee
>>
getUnAssignedEmployees
(
)
throws
MyTeamException
{
public
ResponseEntity
<?>
getUnAssignedEmployees
(
HttpServletRequest
request
)
throws
MyTeamException
{
List
<
Employee
>
employeesList
=
projectService
.
getUnAssignedEmployees
();
return
new
ResponseEntity
<>(
employeesList
,
HttpStatus
.
OK
);
}
ResponseDetails
responseDetails
=
new
ResponseDetails
(
new
Date
(),
602
,
"Resources have been retrieved successfully"
,
"List of Resources who are not assigned to project"
,
employeesList
,
request
.
getRequestURI
(),
"Resource details"
,
null
);
return
new
ResponseEntity
<
ResponseDetails
>(
responseDetails
,
HttpStatus
.
OK
);
}
@RequestMapping
(
value
=
"/getEmployeesDashBoard"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
List
<
EmployeeDashboardVO
>>
getEmployeesDashBoard
(
)
throws
MyTeamException
{
public
ResponseEntity
<?>
getEmployeesDashBoard
(
HttpServletRequest
request
)
throws
MyTeamException
{
List
<
EmployeeDashboardVO
>
employeeDashBoardList
=
projectService
.
getEmployeesDashBoard
();
return
new
ResponseEntity
<>(
employeeDashBoardList
,
HttpStatus
.
OK
);
ResponseDetails
responseDetails
=
new
ResponseDetails
(
new
Date
(),
602
,
"Resources have been retrieved successfully"
,
"List of Resources for dashboard"
,
employeeDashBoardList
,
request
.
getRequestURI
(),
"Resource details"
,
null
);
return
new
ResponseEntity
<
ResponseDetails
>(
responseDetails
,
HttpStatus
.
OK
);
}
@RequestMapping
(
value
=
"/getEmployeesHavingVisa"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
List
<
Employee
>>
getEmployeesHavingVisa
(
@RequestParam
(
"visa"
)
String
passpor
t
)
public
ResponseEntity
<?>
getEmployeesHavingVisa
(
@RequestParam
(
"visa"
)
String
passport
,
HttpServletRequest
reques
t
)
throws
MyTeamException
{
List
<
Employee
>
employees
=
new
ArrayList
<>();
if
(
passport
!=
null
&&
!
"passport"
.
equalsIgnoreCase
(
passport
))
{
List
<
EmployeeVisa
>
employeeVisas
=
employeeVisaRepo
.
findByVisaName
(
passport
);
List
<
String
>
employeeIds
=
null
;
...
...
@@ -180,20 +236,20 @@ public class ResourceController {
}
}
}
return
new
ResponseEntity
<>(
employees
,
HttpStatus
.
OK
);
}
else
{
// List<EmployeeRoles> employees = new ArrayList<>();
if
(
employeeService
.
getActiveEmployees
()
!=
null
)
{
employees
=
employeeService
.
getActiveEmployees
().
stream
()
.
sorted
((
o1
,
o2
)
->
o1
.
getEmployeeName
().
compareTo
(
o2
.
getEmployeeName
()))
.
collect
(
Collectors
.
toList
());
}
return
new
ResponseEntity
<>(
employees
,
HttpStatus
.
OK
);
}
}
ResponseDetails
responseDetails
=
new
ResponseDetails
(
new
Date
(),
602
,
"Resources have been retrieved successfully"
,
"List of Resources who has visa"
,
employees
,
request
.
getRequestURI
(),
"Resource details"
,
null
);
return
new
ResponseEntity
<
ResponseDetails
>(
responseDetails
,
HttpStatus
.
OK
);
}
@RequestMapping
(
value
=
"/addEmployeeToTeamWithCheck"
,
method
=
RequestMethod
.
POST
,
produces
=
MediaType
.
TEXT_PLAIN_VALUE
,
consumes
=
MediaType
.
APPLICATION_JSON_VALUE
)
...
...
src/main/java/com/nisum/myteam/service/impl/ResourceService.java
View file @
0861416c
...
...
@@ -127,22 +127,25 @@ public class ResourceService implements IResourceService {
}
@Override
public
String
updateResource
(
Resource
resource
,
String
loginEmpId
)
throws
MyTeamException
{
public
String
updateResource
(
Resource
resource
Req
,
String
loginEmpId
)
throws
MyTeamException
{
// String result = null;
MyTeamResultDTO
myResultDto
=
new
MyTeamResultDTO
();
myResultDto
.
setResultCode
(
MyTeamResultDTO
.
SUCCESS_CODE
);
myResultDto
.
setResultData
(
"TeamMate updated successfuly"
);
Resource
existingTeammate
=
resourceRepo
.
findById
(
resource
.
getId
());
Resource
existingResource
=
resourceRepo
.
findById
(
resourceReq
.
getId
());
log
.
info
(
"From database: Resource Details::"
+
existingResource
);
List
<
Billing
>
listBD
=
billingService
.
getActiveBillings
(
resource
.
getEmployeeId
(),
resource
.
getProjectId
());
Date
resEndDate
=
resource
.
getEndDate
();
Date
resEndDate
=
resourceReq
.
getEndDate
();
log
.
info
(
"ResEndDate::"
+
resEndDate
);
List
<
Billing
>
listBD
=
billingService
.
getActiveBillings
(
resourceReq
.
getEmployeeId
(),
resourceReq
.
getProjectId
());
// Handling past or present endDate (To "Inactive" the Resource)
if
(
resEndDate
.
compareTo
(
new
Date
())
<=
0
&&
resEndDate
.
compareTo
(
existing
Teammat
e
.
getEndDate
())
!=
0
)
{
existing
Teammat
e
.
setActive
(
false
);
existing
Teammat
e
.
setEndDate
(
resEndDate
);
if
(
resEndDate
.
compareTo
(
new
Date
())
<=
0
&&
resEndDate
.
compareTo
(
existing
Resourc
e
.
getEndDate
())
!=
0
)
{
existing
Resourc
e
.
setActive
(
false
);
existing
Resourc
e
.
setEndDate
(
resEndDate
);
if
(
listBD
!=
null
&&
!
listBD
.
isEmpty
())
{
Billing
billingDetailsExisting
=
listBD
.
get
(
0
);
Date
actualEndDate
=
resEndDate
;
...
...
@@ -159,8 +162,8 @@ public class ResourceService implements IResourceService {
billingDetails
.
setBillingStartDate
(
resEndDate
);
billingDetails
.
setAccount
(
MyTeamUtils
.
BENCH_ACCOUNT
);
billingDetails
.
setActive
(
true
);
billingDetails
.
setEmployeeId
(
existing
Teammat
e
.
getEmployeeId
());
billingDetails
.
setEmployeeName
(
existing
Teammat
e
.
getEmployeeName
());
billingDetails
.
setEmployeeId
(
existing
Resourc
e
.
getEmployeeId
());
billingDetails
.
setEmployeeName
(
existing
Resourc
e
.
getEmployeeName
());
// billingDetails.setCreateDate(new Date());// Commented as added
// common audit fields
billingDetails
.
setProjectId
(
MyTeamUtils
.
BENCH_PROJECT_ID
);
...
...
@@ -175,14 +178,14 @@ public class ResourceService implements IResourceService {
billingService
.
addBilling
(
billingDetails
,
loginEmpId
);
newBenchAllocation
.
setBillableStatus
(
MyTeamUtils
.
BENCH_BILLABILITY_STATUS
);
newBenchAllocation
.
setDesignation
(
existing
Teammat
e
.
getDesignation
());
newBenchAllocation
.
setEmailId
(
existing
Teammat
e
.
getEmailId
());
newBenchAllocation
.
setEmployeeId
(
existing
Teammat
e
.
getEmployeeId
());
newBenchAllocation
.
setDesignation
(
existing
Resourc
e
.
getDesignation
());
newBenchAllocation
.
setEmailId
(
existing
Resourc
e
.
getEmailId
());
newBenchAllocation
.
setEmployeeId
(
existing
Resourc
e
.
getEmployeeId
());
newBenchAllocation
.
setActive
(
true
);
newBenchAllocation
.
setEmployeeName
(
existing
Teammat
e
.
getEmployeeName
());
newBenchAllocation
.
setEmployeeName
(
existing
Resourc
e
.
getEmployeeName
());
newBenchAllocation
.
setProjectId
(
MyTeamUtils
.
BENCH_PROJECT_ID
);
newBenchAllocation
.
setShift
(
existing
Teammat
e
.
getShift
());
newBenchAllocation
.
setRole
(
existing
Teammat
e
.
getRole
());
newBenchAllocation
.
setShift
(
existing
Resourc
e
.
getShift
());
newBenchAllocation
.
setRole
(
existing
Resourc
e
.
getRole
());
Calendar
cal
=
Calendar
.
getInstance
();
cal
.
setTime
(
resEndDate
);
...
...
@@ -197,11 +200,17 @@ public class ResourceService implements IResourceService {
myResultDto
.
setResultCode
(
MyTeamResultDTO
.
SUCCESS_CODE
);
myResultDto
.
setResultData
(
"Resource Successfully moved from "
+
resource
.
getProjectName
()
+
" project to Bench."
);
"Resource Successfully moved from "
+
resource
Req
.
getProjectName
()
+
" project to Bench."
);
}
else
{
log
.
info
(
"Before compare billable status::"
);
log
.
info
(
"Existing Resource:::"
+
existingResource
);
log
.
info
(
"Resource Request Details::"
+
resourceReq
);
// Handling Resource Project Billability Status change
if
(
resource
.
getBillableStatus
()
!=
null
&&
existingTeammat
e
.
getBillableStatus
()
!=
null
&&
!
existing
Teammate
.
getBillableStatus
().
equalsIgnoreCase
(
resource
.
getBillableStatus
()))
{
if
(
resource
Req
.
getBillableStatus
()
!=
null
&&
existingResourc
e
.
getBillableStatus
()
!=
null
&&
!
existing
Resource
.
getBillableStatus
().
equalsIgnoreCase
(
resourceReq
.
getBillableStatus
()))
{
/*
* List<BillingDetails> bDetailsList =
* teamMatesBillingRepo.findByEmployeeId(projectTeamMate.
...
...
@@ -209,20 +218,20 @@ public class ResourceService implements IResourceService {
* (!e.isActive())).sorted(Comparator.comparing(BillingDetails::
* getBillingEndDate).reversed()) .collect(Collectors.toList());
*/
String
result
=
validateBillabilityStartDate
(
listBD
,
resource
);
String
result
=
validateBillabilityStartDate
(
listBD
,
resource
Req
);
if
(
result
!=
null
)
{
// Invalid Billability Start date
return
result
;
}
if
(
listBD
!=
null
&&
!
listBD
.
isEmpty
())
{
Billing
billingDetails
=
listBD
.
get
(
0
);
Calendar
cal
=
Calendar
.
getInstance
();
cal
.
setTime
(
resource
.
getNewBillingStartDate
());
cal
.
setTime
(
resource
Req
.
getNewBillingStartDate
());
cal
.
add
(
Calendar
.
DAY_OF_MONTH
,
-
1
);
Date
startDate
=
existing
Teammat
e
.
getNewBillingStartDate
()
!=
null
?
existing
Teammate
.
getNewBillingStartDate
()
:
existingTeammat
e
.
getStartDate
();
if
(
startDate
.
getDate
()
==
resource
.
getNewBillingStartDate
().
getDate
())
{
Date
startDate
=
existing
Resourc
e
.
getNewBillingStartDate
()
!=
null
?
existing
Resource
.
getNewBillingStartDate
()
:
existingResourc
e
.
getStartDate
();
if
(
startDate
.
getDate
()
==
resource
Req
.
getNewBillingStartDate
().
getDate
())
{
billingDetails
.
setBillingEndDate
(
DateUtils
.
truncate
(
resource
.
getNewBillingStartDate
(),
Calendar
.
DATE
));
DateUtils
.
truncate
(
resource
Req
.
getNewBillingStartDate
(),
Calendar
.
DATE
));
}
else
{
billingDetails
.
setBillingEndDate
(
DateUtils
.
truncate
(
cal
.
getTime
(),
Calendar
.
DATE
));
}
...
...
@@ -230,41 +239,41 @@ public class ResourceService implements IResourceService {
billingService
.
updateBilling
(
billingDetails
,
loginEmpId
);
}
Billing
billings
=
new
Billing
();
billings
.
setEmployeeId
(
resource
.
getEmployeeId
());
billings
.
setEmployeeName
(
resource
.
getEmployeeName
());
billings
.
setProjectId
(
resource
.
getProjectId
());
billings
.
setAccount
(
existing
Teammat
e
.
getAccount
());
billings
.
setProjectName
(
resource
.
getProjectName
());
billings
.
setBillableStatus
(
resource
.
getBillableStatus
());
billings
.
setEmployeeId
(
resource
Req
.
getEmployeeId
());
billings
.
setEmployeeName
(
resource
Req
.
getEmployeeName
());
billings
.
setProjectId
(
resource
Req
.
getProjectId
());
billings
.
setAccount
(
existing
Resourc
e
.
getAccount
());
billings
.
setProjectName
(
resource
Req
.
getProjectName
());
billings
.
setBillableStatus
(
resource
Req
.
getBillableStatus
());
billings
.
setActive
(
true
);
billings
.
setBillingStartDate
(
DateUtils
.
truncate
(
resource
.
getNewBillingStartDate
(),
Calendar
.
DATE
));
billings
.
setBillingStartDate
(
DateUtils
.
truncate
(
resource
Req
.
getNewBillingStartDate
(),
Calendar
.
DATE
));
billings
.
setBillingEndDate
(
DateUtils
.
truncate
(
resEndDate
,
Calendar
.
DATE
));
// billings.setCreateDate(new Date());// Commented as added
// common audit fields
billingService
.
addBilling
(
billings
,
loginEmpId
);
existing
Teammate
.
setBillableStatus
(
resource
.
getBillableStatus
());
existing
Teammat
e
.
setNewBillingStartDate
(
DateUtils
.
truncate
(
resource
.
getNewBillingStartDate
(),
Calendar
.
DATE
));
existing
Resource
.
setBillableStatus
(
resourceReq
.
getBillableStatus
());
existing
Resourc
e
.
setNewBillingStartDate
(
DateUtils
.
truncate
(
resource
Req
.
getNewBillingStartDate
(),
Calendar
.
DATE
));
}
else
{
// Handling Billability Start Date change
List
<
Billing
>
bDetailsList
=
billingRepo
.
findByEmployeeId
(
resource
.
getEmployeeId
()).
stream
()
List
<
Billing
>
bDetailsList
=
billingRepo
.
findByEmployeeId
(
resource
Req
.
getEmployeeId
()).
stream
()
.
filter
(
e
->
(!
e
.
isActive
()))
.
sorted
(
Comparator
.
comparing
(
Billing:
:
getBillingEndDate
).
reversed
())
.
collect
(
Collectors
.
toList
());
String
result
=
validateBillabilityStartDate
(
bDetailsList
,
resource
);
String
result
=
validateBillabilityStartDate
(
bDetailsList
,
resource
Req
);
if
(
result
!=
null
)
{
// Invalid Billability Start date
return
result
;
}
if
(
bDetailsList
!=
null
&&
!
bDetailsList
.
isEmpty
())
{
Calendar
cal
=
Calendar
.
getInstance
();
cal
.
setTime
(
resource
.
getNewBillingStartDate
());
cal
.
setTime
(
resource
Req
.
getNewBillingStartDate
());
cal
.
add
(
Calendar
.
DAY_OF_MONTH
,
-
1
);
Billing
preBillingDetails
=
bDetailsList
.
get
(
0
);
if
(
preBillingDetails
.
getBillingStartDate
().
getDate
()
==
resource
.
getNewBillingStartDate
()
if
(
preBillingDetails
.
getBillingStartDate
().
getDate
()
==
resource
Req
.
getNewBillingStartDate
()
.
getDate
())
{
preBillingDetails
.
setBillingEndDate
(
DateUtils
.
truncate
(
resource
.
getNewBillingStartDate
(),
Calendar
.
DATE
));
DateUtils
.
truncate
(
resource
Req
.
getNewBillingStartDate
(),
Calendar
.
DATE
));
}
else
{
preBillingDetails
.
setBillingEndDate
(
DateUtils
.
truncate
(
cal
.
getTime
(),
Calendar
.
DATE
));
}
...
...
@@ -273,46 +282,46 @@ public class ResourceService implements IResourceService {
if
(
listBD
!=
null
&&
!
listBD
.
isEmpty
())
{
Billing
billingDetails
=
listBD
.
get
(
0
);
billingDetails
.
setBillingStartDate
(
DateUtils
.
truncate
(
resource
.
getNewBillingStartDate
(),
Calendar
.
DATE
));
.
setBillingStartDate
(
DateUtils
.
truncate
(
resource
Req
.
getNewBillingStartDate
(),
Calendar
.
DATE
));
billingDetails
.
setBillingEndDate
(
DateUtils
.
truncate
(
resEndDate
,
Calendar
.
DATE
));
billingService
.
addBilling
(
billingDetails
,
loginEmpId
);
}
existing
Teammat
e
.
setNewBillingStartDate
(
DateUtils
.
truncate
(
resource
.
getNewBillingStartDate
(),
Calendar
.
DATE
));
existing
Resourc
e
.
setNewBillingStartDate
(
DateUtils
.
truncate
(
resource
Req
.
getNewBillingStartDate
(),
Calendar
.
DATE
));
}
if
(
resEndDate
.
compareTo
(
existing
Teammat
e
.
getEndDate
())
!=
0
)
{
existing
Teammat
e
.
setEndDate
(
resEndDate
);
if
(
resEndDate
.
compareTo
(
existing
Resourc
e
.
getEndDate
())
!=
0
)
{
existing
Resourc
e
.
setEndDate
(
resEndDate
);
}
}
if
(
MyTeamResultDTO
.
SUCCESS_CODE
.
equals
(
myResultDto
.
getResultCode
()))
{
// Handling Role change
if
((
existing
Teammate
.
getRole
()
!=
null
&&
!
existingTeammate
.
getRole
().
equalsIgnoreCase
(
resource
.
getRole
()))
||
(
resource
.
getRole
()
!=
null
)
&&
!
resource
.
getRole
().
equalsIgnoreCase
(
existingTeammat
e
.
getRole
()))
{
existing
Teammate
.
setRole
(
resource
.
getRole
());
addOrUpdateTeamMateRole
(
resource
.
getRole
(),
resource
.
getProjectId
(),
resource
.
getEmployeeId
(),
true
,
if
((
existing
Resource
.
getRole
()
!=
null
&&
!
existingResource
.
getRole
().
equalsIgnoreCase
(
resourceReq
.
getRole
()))
||
(
resource
Req
.
getRole
()
!=
null
)
&&
!
resource
Req
.
getRole
().
equalsIgnoreCase
(
existingResourc
e
.
getRole
()))
{
existing
Resource
.
setRole
(
resourceReq
.
getRole
());
addOrUpdateTeamMateRole
(
resource
Req
.
getRole
(),
resourceReq
.
getProjectId
(),
resourceReq
.
getEmployeeId
(),
true
,
loginEmpId
);
}
// Handling Shift change
if
((
existing
Teammat
e
.
getShift
()
!=
null
&&
!
existing
Teammate
.
getShift
().
equalsIgnoreCase
(
resource
.
getShift
()))
||
(
resource
.
getShift
()
!=
null
)
&&
!
resource
.
getShift
().
equalsIgnoreCase
(
existingTeammat
e
.
getShift
()))
{
if
((
existing
Resourc
e
.
getShift
()
!=
null
&&
!
existing
Resource
.
getShift
().
equalsIgnoreCase
(
resourceReq
.
getShift
()))
||
(
resource
Req
.
getShift
()
!=
null
)
&&
!
resource
Req
.
getShift
().
equalsIgnoreCase
(
existingResourc
e
.
getShift
()))
{
empShiftService
.
updateEmployeeShift
(
existing
Teammat
e
,
loginEmpId
);
empShiftService
.
updateEmployeeShift
(
existing
Resourc
e
,
loginEmpId
);
existing
Teammate
.
setShift
(
resource
.
getShift
());
Employee
employeeDB
=
employeeRoleRepo
.
findByEmployeeId
(
resource
.
getEmployeeId
());
employeeDB
.
setShift
(
resource
.
getShift
());
existing
Resource
.
setShift
(
resourceReq
.
getShift
());
Employee
employeeDB
=
employeeRoleRepo
.
findByEmployeeId
(
resource
Req
.
getEmployeeId
());
employeeDB
.
setShift
(
resource
Req
.
getShift
());
employeeDB
.
setModifiedBy
(
loginEmpId
);
employeeDB
.
setLastModifiedOn
(
new
Date
());
employeeRoleRepo
.
save
(
employeeDB
);
}
existing
Teammat
e
.
setAuditFields
(
loginEmpId
,
MyTeamUtils
.
UPDATE
);
// Setting
existing
Resourc
e
.
setAuditFields
(
loginEmpId
,
MyTeamUtils
.
UPDATE
);
// Setting
// audit
// fields
resourceRepo
.
save
(
existing
Teammat
e
);
resourceRepo
.
save
(
existing
Resourc
e
);
}
return
myResultDto
.
getResultData
()[
myResultDto
.
getDataArrayCounter
()];
}
...
...
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