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
dc35fcc2
Commit
dc35fcc2
authored
Jun 13, 2019
by
Md Suleman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updated resource allocation service and controller
parent
743d5b79
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
110 additions
and
68 deletions
+110
-68
ResourceController.java
.../java/com/nisum/myteam/controller/ResourceController.java
+18
-0
ResourceVO.java
src/main/java/com/nisum/myteam/model/vo/ResourceVO.java
+1
-0
ResourceService.java
...n/java/com/nisum/myteam/service/impl/ResourceService.java
+91
-68
No files found.
src/main/java/com/nisum/myteam/controller/ResourceController.java
View file @
dc35fcc2
...
@@ -293,5 +293,23 @@ public class ResourceController {
...
@@ -293,5 +293,23 @@ public class ResourceController {
}
}
@RequestMapping
(
value
=
"/resources/moveToOpenPool"
,
method
=
RequestMethod
.
PUT
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
,
consumes
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<?>
moveResourceToOpenPool
(
@RequestBody
Resource
resource
,
@RequestParam
(
value
=
"loginEmpId"
)
String
loginEmpId
,
HttpServletRequest
request
)
throws
MyTeamException
{
ResponseDetails
responseDetails
;
if
(
StringUtils
.
isNotBlank
(
loginEmpId
))
{
Resource
result
=
resourceService
.
sendResourceToOpenPool
(
resource
,
loginEmpId
);
responseDetails
=
new
ResponseDetails
(
new
Date
(),
Integer
.
parseInt
(
resourceService
.
respMap
.
get
(
"statusCode"
).
toString
()),
resourceService
.
respMap
.
get
(
"message"
).
toString
(),
"Resource description"
,
null
,
request
.
getContextPath
(),
"Resource details"
,
result
);
}
else
{
responseDetails
=
new
ResponseDetails
(
new
Date
(),
820
,
"Please provide the valid Employee Id"
,
"Employee Id is not valid"
,
null
,
request
.
getRequestURI
(),
"Resource details"
,
resource
);
}
return
new
ResponseEntity
<
ResponseDetails
>(
responseDetails
,
HttpStatus
.
OK
);
}
}
}
src/main/java/com/nisum/myteam/model/vo/ResourceVO.java
View file @
dc35fcc2
...
@@ -23,6 +23,7 @@ public class ResourceVO {
...
@@ -23,6 +23,7 @@ public class ResourceVO {
private
String
emailId
;
private
String
emailId
;
private
String
projectId
;
private
String
projectId
;
private
String
projectName
;
private
String
projectName
;
private
String
status
;
@DateTimeFormat
(
iso
=
DateTimeFormat
.
ISO
.
DATE
)
@DateTimeFormat
(
iso
=
DateTimeFormat
.
ISO
.
DATE
)
private
String
billableStatus
;
private
String
billableStatus
;
...
...
src/main/java/com/nisum/myteam/service/impl/ResourceService.java
View file @
dc35fcc2
...
@@ -71,43 +71,21 @@ public class ResourceService implements IResourceService {
...
@@ -71,43 +71,21 @@ public class ResourceService implements IResourceService {
public
Resource
addResource
(
Resource
resourceReq
,
String
loginEmpId
)
throws
MyTeamException
{
public
Resource
addResource
(
Resource
resourceReq
,
String
loginEmpId
)
throws
MyTeamException
{
List
<
Resource
>
resourceAllocationList
=
resourceRepo
.
findByEmployeeId
(
resourceReq
.
getEmployeeId
());
List
<
Resource
>
resourceAllocationList
=
resourceRepo
.
findByEmployeeId
(
resourceReq
.
getEmployeeId
());
Resource
prevAllocation
=
getLatestAllocation
(
resourceAllocationList
.
stream
().
filter
(
r
->
isAllocationActiveToday
(
r
)).
collect
(
Collectors
.
toList
()));
Resource
prevAllocation
=
this
.
getLatestAllocation
(
resourceAllocationList
)
;
Resource
resourcePers
=
null
;
if
(
prevAllocation
!=
null
){
if
(
prevAllocation
!=
null
){
if
(
prevAllocation
.
getProjectId
().
equalsIgnoreCase
(
MyTeamUtils
.
BENCH_PROJECT_ID
)
&&
// Resource projectPrevAllocation = this.getLatestAllocation(resourceAllocationList.stream().
prevAllocation
.
getBillingStartDate
().
compareTo
(
employeeService
.
getEmployeeById
(
prevAllocation
.
getEmployeeId
()).
getDateOfJoining
())
!=
0
){
// filter(r -> !r.getProjectId().equalsIgnoreCase(MyTeamUtils.BENCH_PROJECT_ID)).collect(Collectors.toList()));
Resource
projectPrevAllocation
=
this
.
getLatestAllocation
(
resourceAllocationList
.
stream
().
// projectPrevAllocation.setBillingEndDate(MyTeamDateUtils.getDayLessThanDate(resourceReq.getBillingStartDate()));
filter
(
r
->
!
r
.
getProjectId
().
equalsIgnoreCase
(
MyTeamUtils
.
BENCH_PROJECT_ID
)).
collect
(
Collectors
.
toList
()));
// updateExistedResource(projectPrevAllocation);
projectPrevAllocation
.
setBillingEndDate
(
MyTeamDateUtils
.
getDayLessThanDate
(
resourceReq
.
getBillingStartDate
()));
// prevAllocation.setBillingStartDate(MyTeamDateUtils.getDayMoreThanDate(resourceReq.getBillingEndDate()));
updateExistedResource
(
projectPrevAllocation
);
prevAllocation
.
setBillingStartDate
(
MyTeamDateUtils
.
getDayMoreThanDate
(
resourceReq
.
getBillingEndDate
()));
updateExistedResource
(
prevAllocation
);
}
else
{
prevAllocation
.
setBillingEndDate
(
MyTeamDateUtils
.
getDayLessThanDate
(
resourceReq
.
getBillingStartDate
()));
prevAllocation
.
setBillingEndDate
(
MyTeamDateUtils
.
getDayLessThanDate
(
resourceReq
.
getBillingStartDate
()));
updateExistedResource
(
prevAllocation
);
updateExistedResource
(
prevAllocation
);
//updateLatestProjectAllocationToEnd
resourcePers
=
resourceRepo
.
save
(
resourceReq
);
//createNewProjectAllocationtoStart
}
}
}
return
resourcePers
;
// List<Resource> resourceAllocList = resourceRepo.findByEmployeeIdAndProjectId(resourceReq.getEmployeeId(), resourceReq.getProjectId());
//
// Resource prevAllocation = this.getLatestAllocation(resourceAllocList);
// if (prevAllocation != null) {
// if (prevAllocation.getBillingEndDate().compareTo(new Date()) == 0) {
// prevAllocation.setBillingEndDate(new Date());
// } else {
// prevAllocation.setBillingEndDate(MyTeamDateUtils.getDayLessThanDate(resourceReq.getBillingStartDate())); //adding resource.
// }
// this.updateExistedResource(prevAllocation);
// } else {
// List<Resource> resourceAllocationList = resourceRepo.findByEmployeeId(resourceReq.getEmployeeId());
// if (!resourceAllocationList.isEmpty()) {
// Resource resourceBench = resourceAllocationList.get(0);
// resourceBench.setBillingEndDate(MyTeamDateUtils.getDayLessThanDate(resourceReq.getBillingStartDate()));
// resourceRepo.save(resourceBench);
// }
// }
return
resourceRepo
.
save
(
resourceReq
);
}
}
public
boolean
isResourceExistsForProject
(
String
employeeId
,
String
projectId
)
{
public
boolean
isResourceExistsForProject
(
String
employeeId
,
String
projectId
)
{
...
@@ -154,24 +132,29 @@ public class ResourceService implements IResourceService {
...
@@ -154,24 +132,29 @@ public class ResourceService implements IResourceService {
// }
// }
Resource
resource
=
resourceRepo
.
findById
(
resourceReq
.
getId
());
Resource
resource
=
resourceRepo
.
findById
(
resourceReq
.
getId
());
if
(
resource
!=
null
)
{
if
(
resource
!=
null
)
{
this
.
updateExistedResource
(
resourceReq
);
Resource
latestAllocation
=
this
.
getLatestAllocation
(
resourceRepo
.
findByEmployeeId
(
resourceReq
.
getEmployeeId
()));
if
(
resourceReq
.
getStatus
().
equalsIgnoreCase
(
MyTeamUtils
.
Engaged_STATUS
)){
if
(
latestAllocation
!=
null
&&
latestAllocation
.
getId
().
equals
(
resourceReq
.
getId
())
&&
if
(
resourceReq
.
getBillingEndDate
().
compareTo
(
new
Date
())<
0
){
!
latestAllocation
.
getProjectId
().
equalsIgnoreCase
(
MyTeamUtils
.
BENCH_PROJECT_ID
)){
resourceReq
.
setStatus
(
MyTeamUtils
.
RELEASED_STATUS
);
//update Status of allocation
Resource
resourceBench
=
new
Resource
();
Resource
resourceBench
=
new
Resource
();
resourceBench
.
setProjectId
(
MyTeamUtils
.
BENCH_PROJECT_ID
);
resourceBench
.
setProjectId
(
MyTeamUtils
.
BENCH_PROJECT_ID
);
resourceBench
.
setEmployeeId
(
resourceReq
.
getEmployeeId
());
resourceBench
.
setEmployeeId
(
resourceReq
.
getEmployeeId
());
resourceBench
.
setResourceRole
(
resourceReq
.
getResourceRole
());
resourceBench
.
setResourceRole
(
resourceReq
.
getResourceRole
());
resourceBench
.
setStatus
(
MyTeamUtils
.
RELEASED_STATUS
);
//add alocation status as Released
resourceBench
.
setBillingStartDate
(
MyTeamDateUtils
.
getDayMoreThanDate
(
resourceReq
.
getBillingEndDate
()));
resourceBench
.
setBillingStartDate
(
MyTeamDateUtils
.
getDayMoreThanDate
(
resourceReq
.
getBillingEndDate
()));
resourceBench
.
setBillingEndDate
(
projectService
.
getProjectByProjectId
(
MyTeamUtils
.
BENCH_PROJECT_ID
).
getProjectEndDate
());
resourceBench
.
setBillingEndDate
(
projectService
.
getProjectByProjectId
(
MyTeamUtils
.
BENCH_PROJECT_ID
).
getProjectEndDate
());
resourceBench
.
setBillableStatus
(
MyTeamUtils
.
BENCH_BILLABILITY_STATUS
);
resourceBench
.
setBillableStatus
(
MyTeamUtils
.
BENCH_BILLABILITY_STATUS
);
resourceBench
.
setAuditFields
(
loginEmpId
,
MyTeamUtils
.
CREATE
);
resourceBench
.
setAuditFields
(
loginEmpId
,
MyTeamUtils
.
CREATE
);
resourceRepo
.
save
(
resourceBench
);
resourceRepo
.
save
(
resourceBench
);
}
else
if
(
latestAllocation
!=
null
&&
latestAllocation
.
getProjectId
().
equalsIgnoreCase
(
MyTeamUtils
.
BENCH_PROJECT_ID
)){
latestAllocation
.
setBillingStartDate
(
MyTeamDateUtils
.
getDayMoreThanDate
(
resourceReq
.
getBillingEndDate
()));
updateExistedResource
(
latestAllocation
);
}
}
this
.
updateExistedResource
(
resourceReq
);
}
else
{
respMap
.
put
(
"statusCode"
,
801
);
respMap
.
put
(
"message"
,
"Resource is already released from you, And you can't update this allocation"
);
//>>>>>>> Stashed changes
}
}
else
{
}
else
{
respMap
.
put
(
"statusCode"
,
801
);
respMap
.
put
(
"statusCode"
,
801
);
respMap
.
put
(
"message"
,
"Record Not Found"
);
respMap
.
put
(
"message"
,
"Record Not Found"
);
...
@@ -274,33 +257,68 @@ public class ResourceService implements IResourceService {
...
@@ -274,33 +257,68 @@ public class ResourceService implements IResourceService {
}
}
public
boolean
isResourceA
ssignedToAnyProject
(
Resource
resourceReq
)
{
public
boolean
isResourceA
vailable
(
Resource
resourceReq
)
{
boolean
isAssigned
=
fals
e
;
boolean
isAssigned
=
tru
e
;
String
message
=
""
;
String
message
=
""
;
//List<Resource> resourceAllocList = resourceRepo.findByEmployeeIdAndProjectId(resourceAllocReq.getEmployeeId(), resourceAllocReq.getProjectId());
List
<
Resource
>
resourceAllocList
=
resourceRepo
.
findByEmployeeId
(
resourceReq
.
getEmployeeId
());
//getting all allocations of employee
List
<
Resource
>
resourceAllocList
=
resourceRepo
.
findByEmployeeId
(
resourceReq
.
getEmployeeId
());
Resource
resourceLatestRecord
=
getLatestAllocation
(
resourceAllocList
.
stream
().
Resource
resourceLatestRecord
=
getLatestAllocation
(
resourceAllocList
.
stream
().
filter
(
r
->
!
r
.
getProjectId
().
equalsIgnoreCase
(
MyTeamUtils
.
BENCH_PROJECT_ID
)).
collect
(
Collectors
.
toList
()));
filter
(
r
->
r
.
getProjectId
().
equalsIgnoreCase
(
MyTeamUtils
.
BENCH_PROJECT_ID
)).
collect
(
Collectors
.
toList
()));
//getting latest allocation of employee in bench project
// resourceAllocList.stream().filter(resource -> resource.getBillingEndDate().compareTo(new Date()) >= 0).collect(Collectors.toList());
if
(
resourceLatestRecord
!=
null
&&
if
(
resourceLatestRecord
!=
null
&&
!
isAllocationActiveToday
(
resourceLatestRecord
)){
resourceLatestRecord
.
getBillableStatus
().
equalsIgnoreCase
(
MyTeamUtils
.
BILLABLE_TEXT
)
)
{
Resource
latestProjectResource
=
getLatestAllocation
(
resourceAllocList
.
stream
().
if
(!
resourceLatestRecord
.
getProjectId
().
equalsIgnoreCase
(
resourceReq
.
getProjectId
())){
filter
(
r
->
!
r
.
getProjectId
().
equalsIgnoreCase
(
MyTeamUtils
.
BENCH_PROJECT_ID
)).
collect
(
Collectors
.
toList
()));
if
(!
resourceReq
.
getProjectId
().
equalsIgnoreCase
(
latestProjectResource
.
getProjectId
()))
{
message
=
"Resource "
+
resourceLatestRecord
.
getEmployeeId
()
+
" already Assigned to the "
message
=
"Resource "
+
latestProjectResource
.
getEmployeeId
()
+
" already Assigned to the "
+
projectService
.
getProjectByProjectId
(
resourceLatestRecord
.
getProjectId
()).
getProjectName
()
+
projectService
.
getProjectByProjectId
(
latestProjectResource
.
getProjectId
()).
getProjectName
()
+
" Project"
+
" from "
+
resourceLatestRecord
.
getBillingStartDate
()
+
"to "
+
resourceLatestRecord
.
getBillingEndDate
();
+
" Project"
+
" from "
+
latestProjectResource
.
getBillingStartDate
()
+
"to "
+
latestProjectResource
.
getBillingEndDate
();
isAssigned
=
tru
e
;
isAssigned
=
fals
e
;
respMap
.
put
(
"statusCode"
,
815
);
respMap
.
put
(
"statusCode"
,
815
);
respMap
.
put
(
"message"
,
message
);
respMap
.
put
(
"message"
,
message
);
}
}
}
else
{
if
(!
validateResourceBillingEndDateAgainstBench
(
resourceReq
)){
isAssigned
=
false
;
}
}
}
return
isAssigned
;
return
isAssigned
;
}
}
public
boolean
validateResourceBillingEndDateAgainstBench
(
Resource
resourceReq
){
boolean
isValid
=
true
;
String
message
=
""
;
List
<
Resource
>
resourceAllocList
=
resourceRepo
.
findByEmployeeIdAndProjectId
(
resourceReq
.
getEmployeeId
(),
MyTeamUtils
.
BENCH_PROJECT_ID
);
Resource
resourceBenchLatestRecord
=
getLatestAllocation
(
resourceAllocList
.
stream
().
filter
(
r
->
r
.
getProjectId
().
equalsIgnoreCase
(
MyTeamUtils
.
BENCH_PROJECT_ID
)).
collect
(
Collectors
.
toList
()));
if
(!
isAllocationActiveToday
(
resourceBenchLatestRecord
)){
isValid
=
false
;
message
=
"Resource is not available for allocation"
;
}
else
if
(!(
resourceReq
.
getBillingEndDate
().
before
(
resourceBenchLatestRecord
.
getBillingEndDate
())
&&
resourceReq
.
getBillingStartDate
().
after
(
resourceBenchLatestRecord
.
getBillingStartDate
()))){
message
=
"Resource is available from "
+
resourceBenchLatestRecord
.
getBillingStartDate
()+
" to "
+
resourceBenchLatestRecord
.
getBillingEndDate
();
isValid
=
false
;
}
respMap
.
put
(
"statusCode"
,
810
);
respMap
.
put
(
"message"
,
message
);
return
isValid
;
}
public
boolean
isAllocationActiveToday
(
Resource
resource
){
boolean
isActive
=
true
;
if
(
resource
.
getBillingStartDate
().
compareTo
(
new
Date
())
<=
0
&&
resource
.
getBillingEndDate
().
compareTo
(
new
Date
())>=
0
){
isActive
=
true
;
}
else
{
isActive
=
false
;
}
return
isActive
;
}
public
void
deleteResource
(
Resource
resourceReq
,
String
loginEmpId
)
{
public
void
deleteResource
(
Resource
resourceReq
,
String
loginEmpId
)
{
List
<
Resource
>
resourcesList
=
resourceRepo
.
findByEmployeeIdAndProjectId
(
resourceReq
.
getEmployeeId
(),
resourceReq
.
getProjectId
());
List
<
Resource
>
resourcesList
=
resourceRepo
.
findByEmployeeIdAndProjectId
(
resourceReq
.
getEmployeeId
(),
resourceReq
.
getProjectId
());
...
@@ -322,6 +340,7 @@ public class ResourceService implements IResourceService {
...
@@ -322,6 +340,7 @@ public class ResourceService implements IResourceService {
resourceVO
.
setId
(
resource
.
getId
());
resourceVO
.
setId
(
resource
.
getId
());
resourceVO
.
setProjectId
(
resource
.
getProjectId
());
resourceVO
.
setProjectId
(
resource
.
getProjectId
());
resourceVO
.
setEmployeeId
(
resource
.
getEmployeeId
());
resourceVO
.
setEmployeeId
(
resource
.
getEmployeeId
());
resourceVO
.
setStatus
(
resource
.
getStatus
());
Employee
employee
=
employeeService
.
getEmployeeById
(
resource
.
getEmployeeId
());
Employee
employee
=
employeeService
.
getEmployeeById
(
resource
.
getEmployeeId
());
if
(
employee
!=
null
)
{
if
(
employee
!=
null
)
{
...
@@ -397,6 +416,7 @@ public class ResourceService implements IResourceService {
...
@@ -397,6 +416,7 @@ public class ResourceService implements IResourceService {
resourceVO
.
setId
(
resource
.
getId
());
resourceVO
.
setId
(
resource
.
getId
());
resourceVO
.
setProjectId
(
resource
.
getProjectId
());
resourceVO
.
setProjectId
(
resource
.
getProjectId
());
resourceVO
.
setEmployeeId
(
resource
.
getEmployeeId
());
resourceVO
.
setEmployeeId
(
resource
.
getEmployeeId
());
resourceVO
.
setStatus
(
resource
.
getStatus
());
employee
=
employeeService
.
getEmployeeById
(
resource
.
getEmployeeId
());
employee
=
employeeService
.
getEmployeeById
(
resource
.
getEmployeeId
());
resourceVO
.
setEmployeeName
(
employee
.
getEmployeeName
());
resourceVO
.
setEmployeeName
(
employee
.
getEmployeeName
());
...
@@ -455,6 +475,7 @@ public class ResourceService implements IResourceService {
...
@@ -455,6 +475,7 @@ public class ResourceService implements IResourceService {
resourceVO
.
setBillingEndDate
(
resource
.
getBillingEndDate
());
resourceVO
.
setBillingEndDate
(
resource
.
getBillingEndDate
());
resourceVO
.
setBillableStatus
(
resource
.
getBillableStatus
());
resourceVO
.
setBillableStatus
(
resource
.
getBillableStatus
());
resourceVO
.
setEmployeeId
(
resource
.
getEmployeeId
());
resourceVO
.
setEmployeeId
(
resource
.
getEmployeeId
());
resourceVO
.
setStatus
(
resource
.
getStatus
());
Employee
employee
=
employeeService
.
getEmployeeById
(
resource
.
getEmployeeId
());
Employee
employee
=
employeeService
.
getEmployeeById
(
resource
.
getEmployeeId
());
resourceVO
.
setEmailId
(
employee
.
getEmailId
());
resourceVO
.
setEmailId
(
employee
.
getEmailId
());
...
@@ -614,6 +635,7 @@ public class ResourceService implements IResourceService {
...
@@ -614,6 +635,7 @@ public class ResourceService implements IResourceService {
resourceVO
.
setId
(
resource
.
getId
());
resourceVO
.
setId
(
resource
.
getId
());
resourceVO
.
setProjectId
(
resource
.
getProjectId
());
resourceVO
.
setProjectId
(
resource
.
getProjectId
());
resourceVO
.
setEmployeeId
(
resource
.
getEmployeeId
());
resourceVO
.
setEmployeeId
(
resource
.
getEmployeeId
());
resourceVO
.
setStatus
(
resource
.
getStatus
());
Employee
employee
=
employeeService
.
getEmployeeById
(
resource
.
getEmployeeId
());
Employee
employee
=
employeeService
.
getEmployeeById
(
resource
.
getEmployeeId
());
if
(
employee
!=
null
)
{
if
(
employee
!=
null
)
{
...
@@ -665,6 +687,7 @@ public class ResourceService implements IResourceService {
...
@@ -665,6 +687,7 @@ public class ResourceService implements IResourceService {
resourceBench
.
setProjectId
(
MyTeamUtils
.
BENCH_PROJECT_ID
);
resourceBench
.
setProjectId
(
MyTeamUtils
.
BENCH_PROJECT_ID
);
resourceBench
.
setEmployeeId
(
employee
.
getEmployeeId
());
resourceBench
.
setEmployeeId
(
employee
.
getEmployeeId
());
resourceBench
.
setResourceRole
(
employee
.
getRole
());
resourceBench
.
setResourceRole
(
employee
.
getRole
());
resourceBench
.
setStatus
(
MyTeamUtils
.
RELEASED_STATUS
);
resourceBench
.
setBillingStartDate
(
employee
.
getDateOfJoining
()
!=
null
?
employee
.
getDateOfJoining
()
:
new
Date
());
resourceBench
.
setBillingStartDate
(
employee
.
getDateOfJoining
()
!=
null
?
employee
.
getDateOfJoining
()
:
new
Date
());
resourceBench
.
setBillableStatus
(
MyTeamUtils
.
BENCH_BILLABILITY_STATUS
);
resourceBench
.
setBillableStatus
(
MyTeamUtils
.
BENCH_BILLABILITY_STATUS
);
resourceBench
.
setEmployeeId
(
employee
.
getEmployeeId
());
resourceBench
.
setEmployeeId
(
employee
.
getEmployeeId
());
...
...
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