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
fc54bb12
Commit
fc54bb12
authored
May 21, 2019
by
Md Suleman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated_Resourse_Allocation(Add_And_Update)
parent
2f30a641
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
28 deletions
+45
-28
ResourceController.java
.../java/com/nisum/myteam/controller/ResourceController.java
+0
-2
ResourceService.java
...n/java/com/nisum/myteam/service/impl/ResourceService.java
+45
-26
No files found.
src/main/java/com/nisum/myteam/controller/ResourceController.java
View file @
fc54bb12
...
...
@@ -50,13 +50,11 @@ public class ResourceController {
if
(
resourceService
.
validateBillingStartEndDateAgainstProjectStartEndDate
(
resourceAllocationReq
,
loginEmpId
))
{
if
(
resourceService
.
validateBillingStartDateAgainstDOJ
(
resourceAllocationReq
))
{
if
(!
resourceService
.
isResourceAssignedToAnyProject
(
resourceAllocationReq
))
{
if
(!
resourceService
.
isResourceExistsForProject
(
resourceAllocationReq
.
getEmployeeId
(),
resourceAllocationReq
.
getProjectId
()))
{
Resource
resourcePersisted
=
resourceService
.
addResource
(
resourceAllocationReq
,
loginEmpId
);
ResponseDetails
createResponseDetails
=
new
ResponseDetails
(
new
Date
(),
800
,
"Resource has been created"
,
"Resource description"
,
null
,
request
.
getContextPath
(),
"details"
,
resourcePersisted
);
return
new
ResponseEntity
<
ResponseDetails
>(
createResponseDetails
,
HttpStatus
.
OK
);
}
}
}
}
...
...
src/main/java/com/nisum/myteam/service/impl/ResourceService.java
View file @
fc54bb12
...
...
@@ -50,9 +50,21 @@ public class ResourceService implements IResourceService {
public
HashMap
<
String
,
Object
>
respMap
=
new
HashMap
<>();
public
Resource
addResource
(
Resource
resource
,
String
loginEmpId
)
throws
MyTeamException
{
public
Resource
addResource
(
Resource
resource
Req
,
String
loginEmpId
)
throws
MyTeamException
{
return
resourceRepo
.
save
(
resource
);
List
<
Resource
>
resourceAllocList
=
resourceRepo
.
findByEmployeeIdAndProjectId
(
resourceReq
.
getEmployeeId
(),
resourceReq
.
getProjectId
());
//
List
<
Resource
>
resourceListWithLatestRecord
=
resourceAllocList
.
stream
().
filter
(
res
->
res
.
getBillingEndDate
().
compareTo
(
new
Date
())
>=
0
).
collect
(
Collectors
.
toList
());
if
(
resourceListWithLatestRecord
!=
null
&&
resourceListWithLatestRecord
.
size
()
>
0
)
{
Resource
resourcePrev
=
resourceListWithLatestRecord
.
get
(
0
);
if
(
resourcePrev
.
getBillingEndDate
().
compareTo
(
new
Date
())
==
0
)
{
resourcePrev
.
setBillingEndDate
(
new
Date
());
}
else
{
resourcePrev
.
setBillingEndDate
(
MyTeamDateUtils
.
getDayLessThanDate
(
resourceReq
.
getBillingStartDate
()));
//adding resource.
}
this
.
updateExistedResource
(
resourcePrev
);
}
return
resourceRepo
.
save
(
resourceReq
);
}
public
boolean
isResourceExistsForProject
(
String
employeeId
,
String
projectId
)
{
...
...
@@ -74,30 +86,37 @@ public class ResourceService implements IResourceService {
public
void
updateResourceDetails
(
Resource
resourceReq
,
String
loginEmpId
)
throws
MyTeamException
{
List
<
Resource
>
resourceAllocList
=
resourceRepo
.
findByEmployeeIdAndProjectId
(
resourceReq
.
getEmployeeId
(),
resourceReq
.
getProjectId
());
List
<
Resource
>
resourceListWithLatestRecord
=
resourceAllocList
.
stream
().
filter
(
resource
->
resource
.
getBillingEndDate
().
compareTo
(
new
Date
())
>=
0
).
collect
(
Collectors
.
toList
());
if
(
resourceListWithLatestRecord
!=
null
&&
resourceListWithLatestRecord
.
size
()
>
0
)
{
Resource
resourcePrev
=
resourceListWithLatestRecord
.
get
(
0
);
//latest resource record.
log
.
info
(
"Requsting Resource Allocation BillingStart Date::::"
+
resourceReq
.
getBillingStartDate
());
log
.
info
(
"The before date is::"
+
MyTeamDateUtils
.
getDayLessThanDate
(
resourceReq
.
getBillingStartDate
()));
if
(!
resourcePrev
.
getBillableStatus
().
equals
(
resourceReq
.
getBillableStatus
()))
{
if
(
resourcePrev
.
getBillingEndDate
().
compareTo
(
new
Date
())
==
0
)
{
resourcePrev
.
setBillingEndDate
(
new
Date
());
}
else
{
resourcePrev
.
setBillingEndDate
(
MyTeamDateUtils
.
getDayLessThanDate
(
resourceReq
.
getBillingStartDate
()));
//adding resource.
}
insertNewResourceWithNewStatus
(
resourceReq
,
loginEmpId
);
}
else
{
resourcePrev
.
setResourceRole
(
resourceReq
.
getResourceRole
());
resourcePrev
.
setBillingStartDate
(
resourceReq
.
getBillingStartDate
());
resourcePrev
.
setBillingEndDate
(
resourceReq
.
getBillingEndDate
());
//resourceAllocPrev.setBillingEndDate(); //adding resource.
}
log
.
info
(
"After setting the date:::before saving the Resource::"
+
resourcePrev
);
this
.
updateExistedResource
(
resourcePrev
);
// List<Resource> resourceAllocList = resourceRepo.findByEmployeeIdAndProjectId(resourceReq.getEmployeeId(), resourceReq.getProjectId());
//
// List<Resource> resourceListWithLatestRecord = resourceAllocList.stream().filter(resource -> resource.getBillingEndDate().compareTo(new Date()) >= 0).collect(Collectors.toList());
//
// if (resourceListWithLatestRecord != null && resourceListWithLatestRecord.size() > 0) {
//
// Resource resourcePrev = resourceListWithLatestRecord.get(0); //latest resource record.
// log.info("Requsting Resource Allocation BillingStart Date::::"+resourceReq.getBillingStartDate());
// log.info("The before date is::" + MyTeamDateUtils.getDayLessThanDate(resourceReq.getBillingStartDate()));
// if(!resourcePrev.getBillableStatus().equals(resourceReq.getBillableStatus())) {
// if (resourcePrev.getBillingEndDate().compareTo(new Date()) == 0) {
// resourcePrev.setBillingEndDate(new Date());
// } else {
// resourcePrev.setBillingEndDate(MyTeamDateUtils.getDayLessThanDate(resourceReq.getBillingStartDate())); //adding resource.
// }
// insertNewResourceWithNewStatus(resourceReq,loginEmpId);
// }else {
// resourcePrev.setResourceRole(resourceReq.getResourceRole());
// resourcePrev.setBillingStartDate(resourceReq.getBillingStartDate());
// resourcePrev.setBillingEndDate(resourceReq.getBillingEndDate());
// //resourceAllocPrev.setBillingEndDate(); //adding resource.
// }
// log.info("After setting the date:::before saving the Resource::" + resourcePrev);
// this.updateExistedResource(resourcePrev);
// }
Resource
resource
=
resourceRepo
.
findById
(
resourceReq
.
getId
());
if
(
resource
!=
null
){
this
.
updateExistedResource
(
resourceReq
);
}
else
{
respMap
.
put
(
"statusCode"
,
801
);
respMap
.
put
(
"message"
,
"Record Not Found"
);
}
}
...
...
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