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
743d5b79
Commit
743d5b79
authored
Jun 13, 2019
by
Md Suleman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Merge branch 'FEATURE/REPORTS_ENHANCEMENTS' of E:\MyTime\mytime with conflicts.
parent
6ee8662d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
1020 additions
and
1020 deletions
+1020
-1020
ResourceController.java
.../java/com/nisum/myteam/controller/ResourceController.java
+3
-3
ResourceService.java
...n/java/com/nisum/myteam/service/impl/ResourceService.java
+1009
-1009
application.properties
src/main/resources/application.properties
+8
-8
No files found.
src/main/java/com/nisum/myteam/controller/ResourceController.java
View file @
743d5b79
...
@@ -10,7 +10,6 @@ import com.nisum.myteam.repository.EmployeeVisaRepo;
...
@@ -10,7 +10,6 @@ import com.nisum.myteam.repository.EmployeeVisaRepo;
import
com.nisum.myteam.service.IEmployeeService
;
import
com.nisum.myteam.service.IEmployeeService
;
import
com.nisum.myteam.service.IProjectService
;
import
com.nisum.myteam.service.IProjectService
;
import
com.nisum.myteam.service.impl.ResourceService
;
import
com.nisum.myteam.service.impl.ResourceService
;
import
com.nisum.myteam.statuscodes.ResourceAllocationStatus
;
import
com.nisum.myteam.utils.MyTeamUtils
;
import
com.nisum.myteam.utils.MyTeamUtils
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
...
@@ -50,14 +49,15 @@ public class ResourceController {
...
@@ -50,14 +49,15 @@ public class ResourceController {
if
(
resourceService
.
validateBillingStartEndDateAgainstProjectStartEndDate
(
resourceAllocationReq
,
loginEmpId
))
{
if
(
resourceService
.
validateBillingStartEndDateAgainstProjectStartEndDate
(
resourceAllocationReq
,
loginEmpId
))
{
if
(
resourceService
.
validateBillingStartDateAgainstDOJ
(
resourceAllocationReq
))
{
if
(
resourceService
.
validateBillingStartDateAgainstDOJ
(
resourceAllocationReq
))
{
if
(
!
resourceService
.
isResourceAssignedToAnyProject
(
resourceAllocationReq
))
{
if
(
resourceService
.
isResourceAvailable
(
resourceAllocationReq
))
{
if
(
resourceService
.
validateAllocationAgainstPrevAllocation
(
resourceAllocationReq
))
{
if
(
resourceService
.
validateAllocationAgainstPrevAllocation
(
resourceAllocationReq
))
{
Resource
resourcePersisted
=
resourceService
.
addResource
(
resourceAllocationReq
,
loginEmpId
);
Resource
resourcePersisted
=
resourceService
.
addResource
(
resourceAllocationReq
,
loginEmpId
);
ResponseDetails
createResponseDetails
=
new
ResponseDetails
(
new
Date
(),
800
,
"Resource has been created"
,
ResponseDetails
createResponseDetails
=
new
ResponseDetails
(
new
Date
(),
800
,
"Resource has been created"
,
"Resource description"
,
null
,
request
.
getContextPath
(),
"details"
,
resourcePersisted
);
"Resource description"
,
null
,
request
.
getContextPath
(),
"details"
,
resourcePersisted
);
return
new
ResponseEntity
<
ResponseDetails
>(
createResponseDetails
,
HttpStatus
.
OK
);
return
new
ResponseEntity
<
ResponseDetails
>(
createResponseDetails
,
HttpStatus
.
OK
);
}
}
}
}
}
}
}
}
...
...
src/main/java/com/nisum/myteam/service/impl/ResourceService.java
View file @
743d5b79
package
com
.
nisum
.
myteam
.
service
.
impl
;
package
com
.
nisum
.
myteam
.
service
.
impl
;
import
com.nisum.myteam.exception.handler.MyTeamException
;
import
com.nisum.myteam.exception.handler.MyTeamException
;
import
com.nisum.myteam.model.dao.*
;
import
com.nisum.myteam.model.dao.*
;
import
com.nisum.myteam.model.vo.*
;
import
com.nisum.myteam.model.vo.*
;
import
com.nisum.myteam.repository.ResourceRepo
;
import
com.nisum.myteam.repository.ResourceRepo
;
import
com.nisum.myteam.service.*
;
import
com.nisum.myteam.service.*
;
import
com.nisum.myteam.statuscodes.ResourceAllocationStatus
;
import
com.nisum.myteam.statuscodes.ResourceAllocationStatus
;
import
com.nisum.myteam.statuscodes.ResourceStatus
;
import
com.nisum.myteam.statuscodes.ResourceStatus
;
import
com.nisum.myteam.utils.MyTeamDateUtils
;
import
com.nisum.myteam.utils.MyTeamDateUtils
;
import
com.nisum.myteam.utils.MyTeamUtils
;
import
com.nisum.myteam.utils.MyTeamUtils
;
import
com.nisum.myteam.utils.constants.Shifts
;
import
com.nisum.myteam.utils.constants.Shifts
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang.StringUtils
;
import
org.apache.commons.lang.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Sort
;
import
org.springframework.data.domain.Sort
;
import
org.springframework.data.mongodb.core.MongoTemplate
;
import
org.springframework.data.mongodb.core.MongoTemplate
;
import
org.springframework.data.mongodb.core.query.Criteria
;
import
org.springframework.data.mongodb.core.query.Criteria
;
import
org.springframework.data.mongodb.core.query.Query
;
import
org.springframework.data.mongodb.core.query.Query
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
java.util.*
;
import
java.util.*
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
@Service
@Service
@Slf4j
@Slf4j
public
class
ResourceService
implements
IResourceService
{
public
class
ResourceService
implements
IResourceService
{
@Autowired
@Autowired
private
MongoTemplate
mongoTemplate
;
private
MongoTemplate
mongoTemplate
;
@Autowired
@Autowired
private
ResourceRepo
resourceRepo
;
private
ResourceRepo
resourceRepo
;
@Autowired
@Autowired
private
IAccountService
accountService
;
private
IAccountService
accountService
;
@Autowired
@Autowired
private
IDomainService
domainService
;
private
IDomainService
domainService
;
@Autowired
@Autowired
private
IProjectService
projectService
;
private
IProjectService
projectService
;
@Autowired
@Autowired
private
IEmployeeService
employeeService
;
private
IEmployeeService
employeeService
;
@Autowired
@Autowired
private
IEmployeeShiftService
empShiftService
;
private
IEmployeeShiftService
empShiftService
;
public
HashMap
<
String
,
Object
>
respMap
=
new
HashMap
<>();
public
HashMap
<
String
,
Object
>
respMap
=
new
HashMap
<>();
private
Resource
getLatestAllocation
(
List
<
Resource
>
resourceAllocList
)
{
private
Resource
getLatestAllocation
(
List
<
Resource
>
resourceAllocList
)
{
Resource
latestAlloc
=
null
;
Resource
latestAlloc
=
null
;
if
(!
resourceAllocList
.
isEmpty
())
{
if
(!
resourceAllocList
.
isEmpty
())
{
latestAlloc
=
resourceAllocList
.
get
(
0
);
latestAlloc
=
resourceAllocList
.
get
(
0
);
for
(
Resource
resource
:
resourceAllocList
)
{
for
(
Resource
resource
:
resourceAllocList
)
{
if
(
latestAlloc
.
getBillingEndDate
().
before
(
resource
.
getBillingEndDate
()))
if
(
latestAlloc
.
getBillingEndDate
().
before
(
resource
.
getBillingEndDate
()))
latestAlloc
=
resource
;
latestAlloc
=
resource
;
}
}
}
}
return
latestAlloc
;
return
latestAlloc
;
}
}
public
List
<
Resource
>
getResourcesByEmployeeId
(
String
employeeId
)
{
public
List
<
Resource
>
getResourcesByEmployeeId
(
String
employeeId
)
{
return
resourceRepo
.
findByEmployeeId
(
employeeId
);
return
resourceRepo
.
findByEmployeeId
(
employeeId
);
}
}
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
=
this
.
getLatestAllocation
(
resourceAllocationList
);
Resource
prevAllocation
=
this
.
getLatestAllocation
(
resourceAllocationList
);
if
(
prevAllocation
!=
null
){
if
(
prevAllocation
!=
null
){
if
(
prevAllocation
.
getProjectId
().
equalsIgnoreCase
(
MyTeamUtils
.
BENCH_PROJECT_ID
)
&&
if
(
prevAllocation
.
getProjectId
().
equalsIgnoreCase
(
MyTeamUtils
.
BENCH_PROJECT_ID
)
&&
prevAllocation
.
getBillingStartDate
().
compareTo
(
employeeService
.
getEmployeeById
(
prevAllocation
.
getEmployeeId
()).
getDateOfJoining
())
!=
0
){
prevAllocation
.
getBillingStartDate
().
compareTo
(
employeeService
.
getEmployeeById
(
prevAllocation
.
getEmployeeId
()).
getDateOfJoining
())
!=
0
){
Resource
projectPrevAllocation
=
this
.
getLatestAllocation
(
resourceAllocationList
.
stream
().
Resource
projectPrevAllocation
=
this
.
getLatestAllocation
(
resourceAllocationList
.
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
()));
projectPrevAllocation
.
setBillingEndDate
(
MyTeamDateUtils
.
getDayLessThanDate
(
resourceReq
.
getBillingStartDate
()));
projectPrevAllocation
.
setBillingEndDate
(
MyTeamDateUtils
.
getDayLessThanDate
(
resourceReq
.
getBillingStartDate
()));
updateExistedResource
(
projectPrevAllocation
);
updateExistedResource
(
projectPrevAllocation
);
prevAllocation
.
setBillingStartDate
(
MyTeamDateUtils
.
getDayMoreThanDate
(
resourceReq
.
getBillingEndDate
()));
prevAllocation
.
setBillingStartDate
(
MyTeamDateUtils
.
getDayMoreThanDate
(
resourceReq
.
getBillingEndDate
()));
updateExistedResource
(
prevAllocation
);
updateExistedResource
(
prevAllocation
);
}
else
{
}
else
{
prevAllocation
.
setBillingEndDate
(
MyTeamDateUtils
.
getDayLessThanDate
(
resourceReq
.
getBillingStartDate
()));
prevAllocation
.
setBillingEndDate
(
MyTeamDateUtils
.
getDayLessThanDate
(
resourceReq
.
getBillingStartDate
()));
updateExistedResource
(
prevAllocation
);
updateExistedResource
(
prevAllocation
);
}
}
}
}
// List<Resource> resourceAllocList = resourceRepo.findByEmployeeIdAndProjectId(resourceReq.getEmployeeId(), resourceReq.getProjectId());
// List<Resource> resourceAllocList = resourceRepo.findByEmployeeIdAndProjectId(resourceReq.getEmployeeId(), resourceReq.getProjectId());
//
//
// Resource prevAllocation = this.getLatestAllocation(resourceAllocList);
// Resource prevAllocation = this.getLatestAllocation(resourceAllocList);
// if (prevAllocation != null) {
// if (prevAllocation != null) {
// if (prevAllocation.getBillingEndDate().compareTo(new Date()) == 0) {
// if (prevAllocation.getBillingEndDate().compareTo(new Date()) == 0) {
// prevAllocation.setBillingEndDate(new Date());
// prevAllocation.setBillingEndDate(new Date());
// } else {
// } else {
// prevAllocation.setBillingEndDate(MyTeamDateUtils.getDayLessThanDate(resourceReq.getBillingStartDate())); //adding resource.
// prevAllocation.setBillingEndDate(MyTeamDateUtils.getDayLessThanDate(resourceReq.getBillingStartDate())); //adding resource.
// }
// }
// this.updateExistedResource(prevAllocation);
// this.updateExistedResource(prevAllocation);
// } else {
// } else {
// List<Resource> resourceAllocationList = resourceRepo.findByEmployeeId(resourceReq.getEmployeeId());
// List<Resource> resourceAllocationList = resourceRepo.findByEmployeeId(resourceReq.getEmployeeId());
// if (!resourceAllocationList.isEmpty()) {
// if (!resourceAllocationList.isEmpty()) {
// Resource resourceBench = resourceAllocationList.get(0);
// Resource resourceBench = resourceAllocationList.get(0);
// resourceBench.setBillingEndDate(MyTeamDateUtils.getDayLessThanDate(resourceReq.getBillingStartDate()));
// resourceBench.setBillingEndDate(MyTeamDateUtils.getDayLessThanDate(resourceReq.getBillingStartDate()));
// resourceRepo.save(resourceBench);
// resourceRepo.save(resourceBench);
// }
// }
// }
// }
return
resourceRepo
.
save
(
resourceReq
);
return
resourceRepo
.
save
(
resourceReq
);
}
}
public
boolean
isResourceExistsForProject
(
String
employeeId
,
String
projectId
)
{
public
boolean
isResourceExistsForProject
(
String
employeeId
,
String
projectId
)
{
boolean
isExists
=
false
;
boolean
isExists
=
false
;
List
<
Resource
>
resourceList
=
resourceRepo
.
findByEmployeeIdAndProjectId
(
employeeId
,
projectId
);
List
<
Resource
>
resourceList
=
resourceRepo
.
findByEmployeeIdAndProjectId
(
employeeId
,
projectId
);
if
(
resourceList
!=
null
&&
resourceList
.
size
()
>
0
)
{
if
(
resourceList
!=
null
&&
resourceList
.
size
()
>
0
)
{
isExists
=
true
;
isExists
=
true
;
respMap
.
put
(
"message"
,
"Resourse is already in the project"
);
respMap
.
put
(
"message"
,
"Resourse is already in the project"
);
return
isExists
;
return
isExists
;
}
}
respMap
.
put
(
"statusCode"
,
810
);
respMap
.
put
(
"statusCode"
,
810
);
respMap
.
put
(
"message"
,
"Resource Not Found"
);
respMap
.
put
(
"message"
,
"Resource Not Found"
);
return
isExists
;
return
isExists
;
}
}
public
void
updateResourceDetails
(
Resource
resourceReq
,
String
loginEmpId
)
throws
MyTeamException
{
public
void
updateResourceDetails
(
Resource
resourceReq
,
String
loginEmpId
)
throws
MyTeamException
{
// List<Resource> resourceAllocList = resourceRepo.findByEmployeeIdAndProjectId(resourceReq.getEmployeeId(), resourceReq.getProjectId());
// 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());
// List<Resource> resourceListWithLatestRecord = resourceAllocList.stream().filter(resource -> resource.getBillingEndDate().compareTo(new Date()) >= 0).collect(Collectors.toList());
//
//
// if (resourceListWithLatestRecord != null && resourceListWithLatestRecord.size() > 0) {
// if (resourceListWithLatestRecord != null && resourceListWithLatestRecord.size() > 0) {
//
//
// Resource resourcePrev = resourceListWithLatestRecord.get(0); //latest resource record.
// Resource resourcePrev = resourceListWithLatestRecord.get(0); //latest resource record.
// log.info("Requsting Resource Allocation BillingStart Date::::"+resourceReq.getBillingStartDate());
// log.info("Requsting Resource Allocation BillingStart Date::::"+resourceReq.getBillingStartDate());
// log.info("The before date is::" + MyTeamDateUtils.getDayLessThanDate(resourceReq.getBillingStartDate()));
// log.info("The before date is::" + MyTeamDateUtils.getDayLessThanDate(resourceReq.getBillingStartDate()));
// if(!resourcePrev.getBillableStatus().equals(resourceReq.getBillableStatus())) {
// if(!resourcePrev.getBillableStatus().equals(resourceReq.getBillableStatus())) {
// if (resourcePrev.getBillingEndDate().compareTo(new Date()) == 0) {
// if (resourcePrev.getBillingEndDate().compareTo(new Date()) == 0) {
// resourcePrev.setBillingEndDate(new Date());
// resourcePrev.setBillingEndDate(new Date());
// } else {
// } else {
// resourcePrev.setBillingEndDate(MyTeamDateUtils.getDayLessThanDate(resourceReq.getBillingStartDate())); //adding resource.
// resourcePrev.setBillingEndDate(MyTeamDateUtils.getDayLessThanDate(resourceReq.getBillingStartDate())); //adding resource.
// }
// }
// insertNewResourceWithNewStatus(resourceReq,loginEmpId);
// insertNewResourceWithNewStatus(resourceReq,loginEmpId);
// }else {
// }else {
// resourcePrev.setResourceRole(resourceReq.getResourceRole());
// resourcePrev.setResourceRole(resourceReq.getResourceRole());
// resourcePrev.setBillingStartDate(resourceReq.getBillingStartDate());
// resourcePrev.setBillingStartDate(resourceReq.getBillingStartDate());
// resourcePrev.setBillingEndDate(resourceReq.getBillingEndDate());
// resourcePrev.setBillingEndDate(resourceReq.getBillingEndDate());
// //resourceAllocPrev.setBillingEndDate(); //adding resource.
// //resourceAllocPrev.setBillingEndDate(); //adding resource.
// }
// }
// log.info("After setting the date:::before saving the Resource::" + resourcePrev);
// log.info("After setting the date:::before saving the Resource::" + resourcePrev);
// this.updateExistedResource(resourcePrev);
// this.updateExistedResource(resourcePrev);
// }
// }
Resource
resource
=
resourceRepo
.
findById
(
resourceReq
.
getId
());
Resource
resource
=
resourceRepo
.
findById
(
resourceReq
.
getId
());
if
(
resource
!=
null
)
{
if
(
resource
!=
null
)
{
this
.
updateExistedResource
(
resourceReq
);
this
.
updateExistedResource
(
resourceReq
);
Resource
latestAllocation
=
this
.
getLatestAllocation
(
resourceRepo
.
findByEmployeeId
(
resourceReq
.
getEmployeeId
()));
Resource
latestAllocation
=
this
.
getLatestAllocation
(
resourceRepo
.
findByEmployeeId
(
resourceReq
.
getEmployeeId
()));
if
(
latestAllocation
!=
null
&&
latestAllocation
.
getId
().
equals
(
resourceReq
.
getId
())
&&
if
(
latestAllocation
!=
null
&&
latestAllocation
.
getId
().
equals
(
resourceReq
.
getId
())
&&
!
latestAllocation
.
getProjectId
().
equalsIgnoreCase
(
MyTeamUtils
.
BENCH_PROJECT_ID
)){
!
latestAllocation
.
getProjectId
().
equalsIgnoreCase
(
MyTeamUtils
.
BENCH_PROJECT_ID
)){
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
.
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
)){
}
else
if
(
latestAllocation
!=
null
&&
latestAllocation
.
getProjectId
().
equalsIgnoreCase
(
MyTeamUtils
.
BENCH_PROJECT_ID
)){
latestAllocation
.
setBillingStartDate
(
MyTeamDateUtils
.
getDayMoreThanDate
(
resourceReq
.
getBillingEndDate
()));
latestAllocation
.
setBillingStartDate
(
MyTeamDateUtils
.
getDayMoreThanDate
(
resourceReq
.
getBillingEndDate
()));
updateExistedResource
(
latestAllocation
);
updateExistedResource
(
latestAllocation
);
}
}
}
else
{
}
else
{
respMap
.
put
(
"statusCode"
,
801
);
respMap
.
put
(
"statusCode"
,
801
);
respMap
.
put
(
"message"
,
"Record Not Found"
);
respMap
.
put
(
"message"
,
"Record Not Found"
);
}
}
}
}
public
void
updateExistedResource
(
Resource
resource
)
{
public
void
updateExistedResource
(
Resource
resource
)
{
if
(
resource
!=
null
)
{
if
(
resource
!=
null
)
{
Resource
resourcePers
=
resourceRepo
.
save
(
resource
);
Resource
resourcePers
=
resourceRepo
.
save
(
resource
);
respMap
.
put
(
"statusCode"
,
801
);
respMap
.
put
(
"statusCode"
,
801
);
respMap
.
put
(
"message"
,
"Resource updated successfully"
);
respMap
.
put
(
"message"
,
"Resource updated successfully"
);
respMap
.
put
(
"resourceObj"
,
resourcePers
);
respMap
.
put
(
"resourceObj"
,
resourcePers
);
}
}
}
}
public
void
insertNewResourceWithNewStatus
(
Resource
resourceReq
,
String
loginEmpId
)
throws
MyTeamException
{
public
void
insertNewResourceWithNewStatus
(
Resource
resourceReq
,
String
loginEmpId
)
throws
MyTeamException
{
resourceReq
.
setId
(
null
);
resourceReq
.
setId
(
null
);
Resource
resourcePers
=
resourceRepo
.
insert
(
resourceReq
);
Resource
resourcePers
=
resourceRepo
.
insert
(
resourceReq
);
respMap
.
put
(
"statusCode"
,
801
);
respMap
.
put
(
"statusCode"
,
801
);
respMap
.
put
(
"message"
,
"Resource updated successfully"
);
respMap
.
put
(
"message"
,
"Resource updated successfully"
);
respMap
.
put
(
"resourceObj"
,
resourcePers
);
respMap
.
put
(
"resourceObj"
,
resourcePers
);
}
}
public
boolean
validateAllocationAgainstPrevAllocation
(
Resource
resourceReq
)
{
public
boolean
validateAllocationAgainstPrevAllocation
(
Resource
resourceReq
)
{
boolean
isValid
=
true
;
boolean
isValid
=
true
;
List
<
Resource
>
resourceAllocList
=
resourceRepo
.
findByEmployeeIdAndProjectId
(
resourceReq
.
getEmployeeId
(),
resourceReq
.
getProjectId
());
List
<
Resource
>
resourceAllocList
=
resourceRepo
.
findByEmployeeIdAndProjectId
(
resourceReq
.
getEmployeeId
(),
resourceReq
.
getProjectId
());
Resource
prevAllocation
=
this
.
getLatestAllocation
(
resourceAllocList
);
Resource
prevAllocation
=
this
.
getLatestAllocation
(
resourceAllocList
);
if
(
prevAllocation
!=
null
)
{
if
(
prevAllocation
!=
null
)
{
if
(!
prevAllocation
.
getBillingStartDate
().
before
(
resourceReq
.
getBillingStartDate
()))
{
if
(!
prevAllocation
.
getBillingStartDate
().
before
(
resourceReq
.
getBillingStartDate
()))
{
respMap
.
put
(
"statusCode"
,
811
);
respMap
.
put
(
"statusCode"
,
811
);
respMap
.
put
(
"message"
,
"Billing start date should be after previous allocation start date"
);
respMap
.
put
(
"message"
,
"Billing start date should be after previous allocation start date"
);
isValid
=
false
;
isValid
=
false
;
}
}
if
(
prevAllocation
.
getBillableStatus
().
equalsIgnoreCase
(
resourceReq
.
getBillableStatus
()))
{
if
(
prevAllocation
.
getBillableStatus
().
equalsIgnoreCase
(
resourceReq
.
getBillableStatus
()))
{
respMap
.
put
(
"statusCode"
,
811
);
respMap
.
put
(
"statusCode"
,
811
);
respMap
.
put
(
"message"
,
"Resource is already in "
+
prevAllocation
.
getBillableStatus
()
+
" status only"
);
respMap
.
put
(
"message"
,
"Resource is already in "
+
prevAllocation
.
getBillableStatus
()
+
" status only"
);
isValid
=
false
;
isValid
=
false
;
}
}
}
}
return
isValid
;
return
isValid
;
}
}
public
boolean
validateBillingStartEndDateAgainstProjectStartEndDate
(
Resource
resource
,
String
loginEmpId
)
throws
MyTeamException
{
public
boolean
validateBillingStartEndDateAgainstProjectStartEndDate
(
Resource
resource
,
String
loginEmpId
)
throws
MyTeamException
{
boolean
isValid
=
true
;
boolean
isValid
=
true
;
Project
project
=
projectService
.
getProjectByProjectId
(
resource
.
getProjectId
());
Project
project
=
projectService
.
getProjectByProjectId
(
resource
.
getProjectId
());
log
.
info
(
"Project::"
+
project
);
log
.
info
(
"Project::"
+
project
);
if
(!
resource
.
getBillingStartDate
().
after
(
project
.
getProjectStartDate
()))
{
if
(!
resource
.
getBillingStartDate
().
after
(
project
.
getProjectStartDate
()))
{
log
.
info
(
"Billing start date should be after Project start date"
);
log
.
info
(
"Billing start date should be after Project start date"
);
respMap
.
put
(
"statusCode"
,
811
);
respMap
.
put
(
"statusCode"
,
811
);
respMap
.
put
(
"message"
,
"Billing start date should be after Project start date"
);
respMap
.
put
(
"message"
,
"Billing start date should be after Project start date"
);
isValid
=
false
;
isValid
=
false
;
}
}
if
(!
resource
.
getBillingStartDate
().
before
(
resource
.
getBillingEndDate
()))
{
if
(!
resource
.
getBillingStartDate
().
before
(
resource
.
getBillingEndDate
()))
{
log
.
info
(
"Billing start date should be before Billing End Date."
);
log
.
info
(
"Billing start date should be before Billing End Date."
);
respMap
.
put
(
"statusCode"
,
812
);
respMap
.
put
(
"statusCode"
,
812
);
respMap
.
put
(
"message"
,
"Billing start date should be before Billing End Date."
);
respMap
.
put
(
"message"
,
"Billing start date should be before Billing End Date."
);
isValid
=
false
;
isValid
=
false
;
}
}
log
.
info
(
"ResourceALloc Req::"
+
resource
);
log
.
info
(
"ResourceALloc Req::"
+
resource
);
log
.
info
(
""
+
project
.
getProjectEndDate
().
toString
());
log
.
info
(
""
+
project
.
getProjectEndDate
().
toString
());
//if (!resourceAllocation.getBillingEndDate().before(project.getProjectEndDate())|| !resourceAllocation.getBillingEndDate().equals(project.getProjectEndDate())) {
//if (!resourceAllocation.getBillingEndDate().before(project.getProjectEndDate())|| !resourceAllocation.getBillingEndDate().equals(project.getProjectEndDate())) {
if
(!(
resource
.
getBillingEndDate
().
compareTo
(
project
.
getProjectEndDate
())
<=
0
))
{
if
(!(
resource
.
getBillingEndDate
().
compareTo
(
project
.
getProjectEndDate
())
<=
0
))
{
log
.
info
(
"Billing end date should be on or before Project End Date."
);
log
.
info
(
"Billing end date should be on or before Project End Date."
);
respMap
.
put
(
"statusCode"
,
813
);
respMap
.
put
(
"statusCode"
,
813
);
respMap
.
put
(
"message"
,
"Billing end date should be before Project End Date."
);
respMap
.
put
(
"message"
,
"Billing end date should be before Project End Date."
);
isValid
=
false
;
isValid
=
false
;
}
}
respMap
.
put
(
"resourceObj"
,
resource
);
respMap
.
put
(
"resourceObj"
,
resource
);
return
isValid
;
return
isValid
;
}
}
public
boolean
validateBillingStartDateAgainstDOJ
(
Resource
resource
)
{
public
boolean
validateBillingStartDateAgainstDOJ
(
Resource
resource
)
{
String
message
=
""
;
String
message
=
""
;
boolean
isValid
=
true
;
boolean
isValid
=
true
;
Employee
employee
=
employeeService
.
getEmployeeById
(
resource
.
getEmployeeId
());
Employee
employee
=
employeeService
.
getEmployeeById
(
resource
.
getEmployeeId
());
Date
empDoj
=
employeeService
.
getEmployeeById
(
resource
.
getEmployeeId
()).
getDateOfJoining
();
Date
empDoj
=
employeeService
.
getEmployeeById
(
resource
.
getEmployeeId
()).
getDateOfJoining
();
if
(
resource
.
getBillingStartDate
().
compareTo
(
empDoj
)
<
0
)
{
if
(
resource
.
getBillingStartDate
().
compareTo
(
empDoj
)
<
0
)
{
message
=
"Resource Billing Start Date ("
+
resource
.
getBillingStartDate
()
+
" ) in "
message
=
"Resource Billing Start Date ("
+
resource
.
getBillingStartDate
()
+
" ) in "
+
projectService
.
getProjectByProjectId
(
resource
.
getProjectId
()).
getProjectName
()
+
projectService
.
getProjectByProjectId
(
resource
.
getProjectId
()).
getProjectName
()
+
" project should not be before Date of Joining ( "
+
empDoj
+
")."
;
+
" project should not be before Date of Joining ( "
+
empDoj
+
")."
;
isValid
=
false
;
isValid
=
false
;
respMap
.
put
(
"statusCode"
,
814
);
respMap
.
put
(
"statusCode"
,
814
);
respMap
.
put
(
"message"
,
message
);
respMap
.
put
(
"message"
,
message
);
}
}
return
isValid
;
return
isValid
;
}
}
public
boolean
isResourceAssignedToAnyProject
(
Resource
resourceReq
)
{
public
boolean
isResourceAssignedToAnyProject
(
Resource
resourceReq
)
{
boolean
isAssigned
=
false
;
boolean
isAssigned
=
false
;
String
message
=
""
;
String
message
=
""
;
//List<Resource> resourceAllocList = resourceRepo.findByEmployeeIdAndProjectId(resourceAllocReq.getEmployeeId(), resourceAllocReq.getProjectId());
//List<Resource> resourceAllocList = resourceRepo.findByEmployeeIdAndProjectId(resourceAllocReq.getEmployeeId(), resourceAllocReq.getProjectId());
List
<
Resource
>
resourceAllocList
=
resourceRepo
.
findByEmployeeId
(
resourceReq
.
getEmployeeId
());
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
()));
// resourceAllocList.stream().filter(resource -> resource.getBillingEndDate().compareTo(new Date()) >= 0).collect(Collectors.toList());
// resourceAllocList.stream().filter(resource -> resource.getBillingEndDate().compareTo(new Date()) >= 0).collect(Collectors.toList());
if
(
resourceLatestRecord
!=
null
&&
if
(
resourceLatestRecord
!=
null
&&
resourceLatestRecord
.
getBillableStatus
().
equalsIgnoreCase
(
MyTeamUtils
.
BILLABLE_TEXT
)
)
{
resourceLatestRecord
.
getBillableStatus
().
equalsIgnoreCase
(
MyTeamUtils
.
BILLABLE_TEXT
)
)
{
if
(!
resourceLatestRecord
.
getProjectId
().
equalsIgnoreCase
(
resourceReq
.
getProjectId
())){
if
(!
resourceLatestRecord
.
getProjectId
().
equalsIgnoreCase
(
resourceReq
.
getProjectId
())){
message
=
"Resource "
+
resourceLatestRecord
.
getEmployeeId
()
+
" already Assigned to the "
message
=
"Resource "
+
resourceLatestRecord
.
getEmployeeId
()
+
" already Assigned to the "
+
projectService
.
getProjectByProjectId
(
resourceLatestRecord
.
getProjectId
()).
getProjectName
()
+
projectService
.
getProjectByProjectId
(
resourceLatestRecord
.
getProjectId
()).
getProjectName
()
+
" Project"
+
" from "
+
resourceLatestRecord
.
getBillingStartDate
()
+
"to "
+
resourceLatestRecord
.
getBillingEndDate
();
+
" Project"
+
" from "
+
resourceLatestRecord
.
getBillingStartDate
()
+
"to "
+
resourceLatestRecord
.
getBillingEndDate
();
isAssigned
=
true
;
isAssigned
=
true
;
respMap
.
put
(
"statusCode"
,
815
);
respMap
.
put
(
"statusCode"
,
815
);
respMap
.
put
(
"message"
,
message
);
respMap
.
put
(
"message"
,
message
);
}
}
}
}
return
isAssigned
;
return
isAssigned
;
}
}
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
());
resourcesList
.
forEach
(
resource
->
resourceRepo
.
delete
(
resource
));
resourcesList
.
forEach
(
resource
->
resourceRepo
.
delete
(
resource
));
}
}
@Override
@Override
public
List
<
Resource
>
getAllResources
()
{
public
List
<
Resource
>
getAllResources
()
{
return
resourceRepo
.
findAll
();
return
resourceRepo
.
findAll
();
}
}
public
List
<
ResourceVO
>
getAllResourcesVO
()
{
public
List
<
ResourceVO
>
getAllResourcesVO
()
{
return
getAllResources
().
stream
().
map
(
resource
->
{
return
getAllResources
().
stream
().
map
(
resource
->
{
ResourceVO
resourceVO
=
new
ResourceVO
();
ResourceVO
resourceVO
=
new
ResourceVO
();
resourceVO
.
setId
(
resource
.
getId
());
resourceVO
.
setId
(
resource
.
getId
());
resourceVO
.
setProjectId
(
resource
.
getProjectId
());
resourceVO
.
setProjectId
(
resource
.
getProjectId
());
resourceVO
.
setEmployeeId
(
resource
.
getEmployeeId
());
resourceVO
.
setEmployeeId
(
resource
.
getEmployeeId
());
Employee
employee
=
employeeService
.
getEmployeeById
(
resource
.
getEmployeeId
());
Employee
employee
=
employeeService
.
getEmployeeById
(
resource
.
getEmployeeId
());
if
(
employee
!=
null
)
{
if
(
employee
!=
null
)
{
resourceVO
.
setEmployeeName
(
employee
.
getEmployeeName
());
resourceVO
.
setEmployeeName
(
employee
.
getEmployeeName
());
resourceVO
.
setDesignation
(
employee
.
getDesignation
());
resourceVO
.
setDesignation
(
employee
.
getDesignation
());
resourceVO
.
setEmailId
(
employee
.
getEmailId
());
resourceVO
.
setEmailId
(
employee
.
getEmailId
());
resourceVO
.
setMobileNo
(
employee
.
getMobileNumber
());
resourceVO
.
setMobileNo
(
employee
.
getMobileNumber
());
}
}
Project
project
=
projectService
.
getProjectByProjectId
(
resource
.
getProjectId
());
Project
project
=
projectService
.
getProjectByProjectId
(
resource
.
getProjectId
());
if
(
project
!=
null
)
{
if
(
project
!=
null
)
{
resourceVO
.
setProjectName
(
project
.
getProjectName
());
resourceVO
.
setProjectName
(
project
.
getProjectName
());
resourceVO
.
setProjectStartDate
(
project
.
getProjectStartDate
());
resourceVO
.
setProjectStartDate
(
project
.
getProjectStartDate
());
resourceVO
.
setProjectEndDate
(
project
.
getProjectEndDate
());
resourceVO
.
setProjectEndDate
(
project
.
getProjectEndDate
());
resourceVO
.
setProjectStatus
(
project
.
getStatus
());
resourceVO
.
setProjectStatus
(
project
.
getStatus
());
if
(
project
.
getAccountId
()
!=
null
)
{
if
(
project
.
getAccountId
()
!=
null
)
{
Account
account
=
accountService
.
getAccountById
(
project
.
getAccountId
());
Account
account
=
accountService
.
getAccountById
(
project
.
getAccountId
());
if
(
account
!=
null
)
{
if
(
account
!=
null
)
{
resourceVO
.
setAccountName
(
account
.
getAccountName
());
resourceVO
.
setAccountName
(
account
.
getAccountName
());
}
}
}
}
}
}
//Account account=accountService.getAccountById(domainService.getDomainById(project.getProjectId()).getAccountId());
//Account account=accountService.getAccountById(domainService.getDomainById(project.getProjectId()).getAccountId());
resourceVO
.
setBillableStatus
(
resource
.
getBillableStatus
());
resourceVO
.
setBillableStatus
(
resource
.
getBillableStatus
());
resourceVO
.
setBillingStartDate
(
resource
.
getBillingStartDate
());
resourceVO
.
setBillingStartDate
(
resource
.
getBillingStartDate
());
resourceVO
.
setBillingEndDate
(
resource
.
getBillingEndDate
());
resourceVO
.
setBillingEndDate
(
resource
.
getBillingEndDate
());
resourceVO
.
setResourceRole
(
resource
.
getResourceRole
());
resourceVO
.
setResourceRole
(
resource
.
getResourceRole
());
if
(
resource
.
getBillingEndDate
().
compareTo
(
new
Date
())
>
0
)
{
if
(
resource
.
getBillingEndDate
().
compareTo
(
new
Date
())
>
0
)
{
resourceVO
.
setResourceStatus
(
ResourceStatus
.
ACTIVE
.
getStatus
());
resourceVO
.
setResourceStatus
(
ResourceStatus
.
ACTIVE
.
getStatus
());
}
else
{
}
else
{
resourceVO
.
setResourceStatus
(
ResourceStatus
.
IN_ACTIVE
.
getStatus
());
resourceVO
.
setResourceStatus
(
ResourceStatus
.
IN_ACTIVE
.
getStatus
());
}
}
return
resourceVO
;
return
resourceVO
;
}).
collect
(
Collectors
.
toList
());
}).
collect
(
Collectors
.
toList
());
}
}
public
List
<
Resource
>
getResourcesSortByBillingStartDate
(
String
employeeId
)
{
public
List
<
Resource
>
getResourcesSortByBillingStartDate
(
String
employeeId
)
{
Query
query
=
prepareQuery
(
employeeId
,
MyTeamUtils
.
BILLING_START_DATE
);
Query
query
=
prepareQuery
(
employeeId
,
MyTeamUtils
.
BILLING_START_DATE
);
return
mongoTemplate
.
find
(
query
,
Resource
.
class
);
return
mongoTemplate
.
find
(
query
,
Resource
.
class
);
}
}
private
Query
prepareQuery
(
String
employeeId
,
String
dateColumn
)
{
private
Query
prepareQuery
(
String
employeeId
,
String
dateColumn
)
{
Query
query
=
new
Query
();
Query
query
=
new
Query
();
query
.
addCriteria
(
Criteria
.
where
(
MyTeamUtils
.
EMPLOYEE_ID
).
is
(
employeeId
));
query
.
addCriteria
(
Criteria
.
where
(
MyTeamUtils
.
EMPLOYEE_ID
).
is
(
employeeId
));
query
.
limit
(
MyTeamUtils
.
ONE
);
query
.
limit
(
MyTeamUtils
.
ONE
);
query
.
with
(
new
Sort
(
Sort
.
Direction
.
DESC
,
dateColumn
));
query
.
with
(
new
Sort
(
Sort
.
Direction
.
DESC
,
dateColumn
));
return
query
;
return
query
;
}
}
@Override
@Override
public
List
<
ResourceVO
>
getActiveResources
(
String
empId
)
{
public
List
<
ResourceVO
>
getActiveResources
(
String
empId
)
{
List
<
ResourceVO
>
resourcesList
=
new
ArrayList
<>();
List
<
ResourceVO
>
resourcesList
=
new
ArrayList
<>();
for
(
Resource
resource
:
resourceRepo
.
findByEmployeeId
(
empId
))
{
for
(
Resource
resource
:
resourceRepo
.
findByEmployeeId
(
empId
))
{
if
(
resource
.
getBillingEndDate
().
compareTo
(
new
Date
())
>
0
)
{
if
(
resource
.
getBillingEndDate
().
compareTo
(
new
Date
())
>
0
)
{
resourcesList
.
addAll
(
prepareProjectTeamMembersList
(
resource
.
getProjectId
()));
resourcesList
.
addAll
(
prepareProjectTeamMembersList
(
resource
.
getProjectId
()));
}
}
}
}
return
resourcesList
;
return
resourcesList
;
}
}
public
List
<
ResourceVO
>
prepareProjectTeamMembersList
(
String
projectId
)
{
public
List
<
ResourceVO
>
prepareProjectTeamMembersList
(
String
projectId
)
{
List
<
ResourceVO
>
finalResourcesList
=
new
ArrayList
<>();
List
<
ResourceVO
>
finalResourcesList
=
new
ArrayList
<>();
Employee
employee
=
null
;
Employee
employee
=
null
;
for
(
Resource
resource
:
getAllResourcesForProject
(
projectId
))
{
for
(
Resource
resource
:
getAllResourcesForProject
(
projectId
))
{
ResourceVO
resourceVO
=
new
ResourceVO
();
ResourceVO
resourceVO
=
new
ResourceVO
();
resourceVO
.
setId
(
resource
.
getId
());
resourceVO
.
setId
(
resource
.
getId
());
resourceVO
.
setProjectId
(
resource
.
getProjectId
());
resourceVO
.
setProjectId
(
resource
.
getProjectId
());
resourceVO
.
setEmployeeId
(
resource
.
getEmployeeId
());
resourceVO
.
setEmployeeId
(
resource
.
getEmployeeId
());
employee
=
employeeService
.
getEmployeeById
(
resource
.
getEmployeeId
());
employee
=
employeeService
.
getEmployeeById
(
resource
.
getEmployeeId
());
resourceVO
.
setEmployeeName
(
employee
.
getEmployeeName
());
resourceVO
.
setEmployeeName
(
employee
.
getEmployeeName
());
resourceVO
.
setDesignation
(
employee
.
getDesignation
());
resourceVO
.
setDesignation
(
employee
.
getDesignation
());
resourceVO
.
setEmailId
(
employee
.
getEmailId
());
resourceVO
.
setEmailId
(
employee
.
getEmailId
());
resourceVO
.
setMobileNo
(
employee
.
getMobileNumber
());
resourceVO
.
setMobileNo
(
employee
.
getMobileNumber
());
resourceVO
.
setProjectName
(
projectService
.
getProjectByProjectId
(
resource
.
getProjectId
()).
getProjectName
());
resourceVO
.
setProjectName
(
projectService
.
getProjectByProjectId
(
resource
.
getProjectId
()).
getProjectName
());
resourceVO
.
setBillableStatus
(
resource
.
getBillableStatus
());
resourceVO
.
setBillableStatus
(
resource
.
getBillableStatus
());
resourceVO
.
setBillingStartDate
(
resource
.
getBillingStartDate
());
resourceVO
.
setBillingStartDate
(
resource
.
getBillingStartDate
());
resourceVO
.
setBillingEndDate
(
resource
.
getBillingEndDate
());
resourceVO
.
setBillingEndDate
(
resource
.
getBillingEndDate
());
resourceVO
.
setResourceRole
(
resource
.
getResourceRole
());
resourceVO
.
setResourceRole
(
resource
.
getResourceRole
());
if
(
resource
.
getBillingEndDate
().
compareTo
(
new
Date
())
>
0
)
{
if
(
resource
.
getBillingEndDate
().
compareTo
(
new
Date
())
>
0
)
{
resourceVO
.
setResourceStatus
(
ResourceStatus
.
ACTIVE
.
getStatus
());
resourceVO
.
setResourceStatus
(
ResourceStatus
.
ACTIVE
.
getStatus
());
}
else
{
}
else
{
resourceVO
.
setResourceStatus
(
ResourceStatus
.
IN_ACTIVE
.
getStatus
());
resourceVO
.
setResourceStatus
(
ResourceStatus
.
IN_ACTIVE
.
getStatus
());
}
}
finalResourcesList
.
add
(
resourceVO
);
finalResourcesList
.
add
(
resourceVO
);
}
}
return
finalResourcesList
;
return
finalResourcesList
;
}
}
public
List
<
Resource
>
getAllResourcesForProject
(
String
projectId
)
{
public
List
<
Resource
>
getAllResourcesForProject
(
String
projectId
)
{
return
resourceRepo
.
findByProjectId
(
projectId
);
return
resourceRepo
.
findByProjectId
(
projectId
);
}
}
@Override
@Override
public
List
<
Resource
>
getAllResourcesForAllActiveProjects
()
{
public
List
<
Resource
>
getAllResourcesForAllActiveProjects
()
{
List
<
Resource
>
resourceList
=
new
ArrayList
<>();
List
<
Resource
>
resourceList
=
new
ArrayList
<>();
for
(
Project
activeProject
:
projectService
.
getOnlyActiveProjects
())
{
for
(
Project
activeProject
:
projectService
.
getOnlyActiveProjects
())
{
resourceList
.
addAll
(
getAllResourcesForProject
(
activeProject
.
getProjectId
()));
resourceList
.
addAll
(
getAllResourcesForProject
(
activeProject
.
getProjectId
()));
}
}
return
resourceList
;
return
resourceList
;
}
}
@Override
@Override
public
List
<
ResourceVO
>
getResourcesForProject
(
String
projectId
,
String
statusFlag
)
{
public
List
<
ResourceVO
>
getResourcesForProject
(
String
projectId
,
String
statusFlag
)
{
List
<
ResourceVO
>
resourcesList
=
new
ArrayList
<>();
List
<
ResourceVO
>
resourcesList
=
new
ArrayList
<>();
for
(
Resource
resource
:
resourceRepo
.
findByProjectId
(
projectId
))
{
for
(
Resource
resource
:
resourceRepo
.
findByProjectId
(
projectId
))
{
Date
billingEndDate
=
resource
.
getBillingEndDate
();
Date
billingEndDate
=
resource
.
getBillingEndDate
();
if
(
billingEndDate
!=
null
)
{
if
(
billingEndDate
!=
null
)
{
ResourceVO
resourceVO
=
new
ResourceVO
();
ResourceVO
resourceVO
=
new
ResourceVO
();
resourceVO
.
setId
(
resource
.
getId
());
resourceVO
.
setId
(
resource
.
getId
());
resourceVO
.
setProjectId
(
resource
.
getProjectId
());
resourceVO
.
setProjectId
(
resource
.
getProjectId
());
resourceVO
.
setProjectName
(
projectService
.
getProjectByProjectId
(
resource
.
getProjectId
()).
getProjectName
());
resourceVO
.
setProjectName
(
projectService
.
getProjectByProjectId
(
resource
.
getProjectId
()).
getProjectName
());
resourceVO
.
setResourceRole
(
resource
.
getResourceRole
());
resourceVO
.
setResourceRole
(
resource
.
getResourceRole
());
resourceVO
.
setBillingStartDate
(
resource
.
getBillingStartDate
());
resourceVO
.
setBillingStartDate
(
resource
.
getBillingStartDate
());
resourceVO
.
setBillingEndDate
(
resource
.
getBillingEndDate
());
resourceVO
.
setBillingEndDate
(
resource
.
getBillingEndDate
());
resourceVO
.
setBillableStatus
(
resource
.
getBillableStatus
());
resourceVO
.
setBillableStatus
(
resource
.
getBillableStatus
());
resourceVO
.
setEmployeeId
(
resource
.
getEmployeeId
());
resourceVO
.
setEmployeeId
(
resource
.
getEmployeeId
());
Employee
employee
=
employeeService
.
getEmployeeById
(
resource
.
getEmployeeId
());
Employee
employee
=
employeeService
.
getEmployeeById
(
resource
.
getEmployeeId
());
resourceVO
.
setEmailId
(
employee
.
getEmailId
());
resourceVO
.
setEmailId
(
employee
.
getEmailId
());
resourceVO
.
setEmployeeName
(
employee
.
getEmployeeName
());
resourceVO
.
setEmployeeName
(
employee
.
getEmployeeName
());
resourceVO
.
setDesignation
(
employee
.
getDesignation
());
resourceVO
.
setDesignation
(
employee
.
getDesignation
());
// Active
// Active
if
(
statusFlag
.
equals
(
ResourceStatus
.
ACTIVE
.
getStatus
())
&&
billingEndDate
.
compareTo
(
new
Date
())
>=
0
)
{
if
(
statusFlag
.
equals
(
ResourceStatus
.
ACTIVE
.
getStatus
())
&&
billingEndDate
.
compareTo
(
new
Date
())
>=
0
)
{
resourceVO
.
setResourceStatus
(
ResourceStatus
.
ACTIVE
.
getStatus
());
resourceVO
.
setResourceStatus
(
ResourceStatus
.
ACTIVE
.
getStatus
());
resourcesList
.
add
(
resourceVO
);
resourcesList
.
add
(
resourceVO
);
}
else
if
(
statusFlag
.
equals
(
ResourceStatus
.
IN_ACTIVE
.
getStatus
())
&&
billingEndDate
.
compareTo
(
new
Date
())
<
0
)
{
}
else
if
(
statusFlag
.
equals
(
ResourceStatus
.
IN_ACTIVE
.
getStatus
())
&&
billingEndDate
.
compareTo
(
new
Date
())
<
0
)
{
resourceVO
.
setResourceStatus
(
ResourceStatus
.
IN_ACTIVE
.
getStatus
());
resourceVO
.
setResourceStatus
(
ResourceStatus
.
IN_ACTIVE
.
getStatus
());
resourcesList
.
add
(
resourceVO
);
resourcesList
.
add
(
resourceVO
);
}
else
if
(
statusFlag
.
equals
(
MyTeamUtils
.
BOTH
))
}
else
if
(
statusFlag
.
equals
(
MyTeamUtils
.
BOTH
))
resourcesList
.
add
(
resourceVO
);
resourcesList
.
add
(
resourceVO
);
}
}
}
}
return
resourcesList
;
return
resourcesList
;
}
}
@Override
@Override
public
List
<
MyProjectAllocationVO
>
getWorkedProjectsForResource
(
String
empId
)
{
public
List
<
MyProjectAllocationVO
>
getWorkedProjectsForResource
(
String
empId
)
{
Project
project
=
null
;
Project
project
=
null
;
Account
account
=
null
;
Account
account
=
null
;
Domain
domain
=
null
;
Domain
domain
=
null
;
Employee
employee
=
null
;
Employee
employee
=
null
;
List
<
MyProjectAllocationVO
>
myProjectList
=
new
ArrayList
<>();
List
<
MyProjectAllocationVO
>
myProjectList
=
new
ArrayList
<>();
List
<
Resource
>
resourcesAllocatedList
=
resourceRepo
.
findByEmployeeId
(
empId
);
List
<
Resource
>
resourcesAllocatedList
=
resourceRepo
.
findByEmployeeId
(
empId
);
if
(
null
!=
resourcesAllocatedList
&&
!
resourcesAllocatedList
.
isEmpty
()
&&
MyTeamUtils
.
INT_ZERO
<
resourcesAllocatedList
.
size
())
{
if
(
null
!=
resourcesAllocatedList
&&
!
resourcesAllocatedList
.
isEmpty
()
&&
MyTeamUtils
.
INT_ZERO
<
resourcesAllocatedList
.
size
())
{
for
(
Resource
resourceAlloc
:
resourcesAllocatedList
)
{
for
(
Resource
resourceAlloc
:
resourcesAllocatedList
)
{
project
=
projectService
.
getProjectByProjectId
(
resourceAlloc
.
getProjectId
());
project
=
projectService
.
getProjectByProjectId
(
resourceAlloc
.
getProjectId
());
account
=
accountService
.
getAccountById
(
project
.
getAccountId
());
account
=
accountService
.
getAccountById
(
project
.
getAccountId
());
domain
=
domainService
.
getDomainById
(
project
.
getDomainId
());
domain
=
domainService
.
getDomainById
(
project
.
getDomainId
());
employee
=
employeeService
.
getEmployeeById
(
resourceAlloc
.
getEmployeeId
());
employee
=
employeeService
.
getEmployeeById
(
resourceAlloc
.
getEmployeeId
());
MyProjectAllocationVO
myProject
=
new
MyProjectAllocationVO
();
MyProjectAllocationVO
myProject
=
new
MyProjectAllocationVO
();
myProject
.
setProjectId
(
project
.
getProjectId
());
myProject
.
setProjectId
(
project
.
getProjectId
());
myProject
.
setProjectName
(
project
.
getProjectName
());
myProject
.
setProjectName
(
project
.
getProjectName
());
myProject
.
setProjectStartDate
(
project
.
getProjectStartDate
());
myProject
.
setProjectStartDate
(
project
.
getProjectStartDate
());
myProject
.
setProjectEndDate
(
project
.
getProjectEndDate
());
myProject
.
setProjectEndDate
(
project
.
getProjectEndDate
());
myProject
.
setProjectStatus
(
project
.
getStatus
());
myProject
.
setProjectStatus
(
project
.
getStatus
());
myProject
.
setAccountName
(
account
.
getAccountName
());
myProject
.
setAccountName
(
account
.
getAccountName
());
myProject
.
setBillableStatus
(
resourceAlloc
.
getBillableStatus
());
myProject
.
setBillableStatus
(
resourceAlloc
.
getBillableStatus
());
myProject
.
setBillingStartDate
(
resourceAlloc
.
getBillingStartDate
());
myProject
.
setBillingStartDate
(
resourceAlloc
.
getBillingStartDate
());
myProject
.
setBillingEndDate
(
resourceAlloc
.
getBillingEndDate
());
myProject
.
setBillingEndDate
(
resourceAlloc
.
getBillingEndDate
());
myProject
.
setShift
(
employee
.
getShift
());
myProject
.
setShift
(
employee
.
getShift
());
if
(
resourceAlloc
.
getBillingEndDate
().
compareTo
(
new
Date
())
>
0
)
{
if
(
resourceAlloc
.
getBillingEndDate
().
compareTo
(
new
Date
())
>
0
)
{
myProject
.
setResourceStatus
(
ResourceStatus
.
ACTIVE
.
getStatus
());
myProject
.
setResourceStatus
(
ResourceStatus
.
ACTIVE
.
getStatus
());
}
else
{
}
else
{
myProject
.
setResourceStatus
(
ResourceStatus
.
IN_ACTIVE
.
getStatus
());
myProject
.
setResourceStatus
(
ResourceStatus
.
IN_ACTIVE
.
getStatus
());
}
}
if
(
project
.
getDeliveryLeadIds
()
!=
null
)
{
if
(
project
.
getDeliveryLeadIds
()
!=
null
)
{
myProject
.
setDeliveryLeadIds
(
employeeService
.
getDeliveryManagerMap
(
project
.
getDeliveryLeadIds
()));
myProject
.
setDeliveryLeadIds
(
employeeService
.
getDeliveryManagerMap
(
project
.
getDeliveryLeadIds
()));
}
}
myProjectList
.
add
(
myProject
);
myProjectList
.
add
(
myProject
);
}
}
}
}
return
myProjectList
;
return
myProjectList
;
}
}
@Override
@Override
public
List
<
Resource
>
getResourcesUnderDeliveryLead
(
String
deliveryLeadId
)
{
public
List
<
Resource
>
getResourcesUnderDeliveryLead
(
String
deliveryLeadId
)
{
List
<
String
>
projectIdsList
=
new
ArrayList
<>();
List
<
String
>
projectIdsList
=
new
ArrayList
<>();
List
<
Resource
>
resourcesList
=
new
ArrayList
<>();
List
<
Resource
>
resourcesList
=
new
ArrayList
<>();
for
(
Project
project
:
projectService
.
getProjectsForDeliveryLead
(
deliveryLeadId
))
for
(
Project
project
:
projectService
.
getProjectsForDeliveryLead
(
deliveryLeadId
))
projectIdsList
.
add
(
project
.
getProjectId
());
projectIdsList
.
add
(
project
.
getProjectId
());
Query
query
=
new
Query
(
Criteria
.
where
(
"projectId"
).
in
(
projectIdsList
));
Query
query
=
new
Query
(
Criteria
.
where
(
"projectId"
).
in
(
projectIdsList
));
List
<
Resource
>
resourcesListPersisted
=
mongoTemplate
.
find
(
query
,
Resource
.
class
);
List
<
Resource
>
resourcesListPersisted
=
mongoTemplate
.
find
(
query
,
Resource
.
class
);
for
(
Resource
resourceAlloc
:
resourcesListPersisted
)
{
for
(
Resource
resourceAlloc
:
resourcesListPersisted
)
{
if
(!
resourceAlloc
.
getEmployeeId
().
equals
(
deliveryLeadId
))
if
(!
resourceAlloc
.
getEmployeeId
().
equals
(
deliveryLeadId
))
resourcesList
.
add
(
resourceAlloc
);
resourcesList
.
add
(
resourceAlloc
);
}
}
return
resourcesList
;
return
resourcesList
;
}
}
@Override
@Override
public
List
<
ResourceVO
>
getBillingsForEmployee
(
String
empId
)
{
public
List
<
ResourceVO
>
getBillingsForEmployee
(
String
empId
)
{
List
<
ResourceVO
>
finalList
=
new
ArrayList
<>();
List
<
ResourceVO
>
finalList
=
new
ArrayList
<>();
List
<
Resource
>
resourcesList
=
resourceRepo
.
findByEmployeeId
(
empId
);
List
<
Resource
>
resourcesList
=
resourceRepo
.
findByEmployeeId
(
empId
);
if
(
resourcesList
!=
null
&&
resourcesList
.
size
()
>
0
)
{
if
(
resourcesList
!=
null
&&
resourcesList
.
size
()
>
0
)
{
log
.
info
(
"The resources billing list before sorting::"
+
resourcesList
);
log
.
info
(
"The resources billing list before sorting::"
+
resourcesList
);
//return billingsList.stream().sorted(Comparator.comparing(Billing::getCreatedOn).reversed()).collect(Collectors.toList());
//return billingsList.stream().sorted(Comparator.comparing(Billing::getCreatedOn).reversed()).collect(Collectors.toList());
List
<
Resource
>
sortedList
=
resourcesList
.
stream
().
sorted
(
Comparator
.
comparing
(
Resource:
:
getBillingStartDate
).
reversed
()).
collect
(
Collectors
.
toList
());
List
<
Resource
>
sortedList
=
resourcesList
.
stream
().
sorted
(
Comparator
.
comparing
(
Resource:
:
getBillingStartDate
).
reversed
()).
collect
(
Collectors
.
toList
());
finalList
=
convertResourcesToResourcesVO
(
sortedList
);
finalList
=
convertResourcesToResourcesVO
(
sortedList
);
}
}
return
finalList
;
return
finalList
;
}
}
@Override
@Override
public
List
<
Resource
>
getBillingsForProject
(
String
empId
,
String
projectId
)
{
public
List
<
Resource
>
getBillingsForProject
(
String
empId
,
String
projectId
)
{
List
<
Resource
>
resourcesList
=
resourceRepo
.
findByEmployeeIdAndProjectId
(
empId
,
projectId
);
List
<
Resource
>
resourcesList
=
resourceRepo
.
findByEmployeeIdAndProjectId
(
empId
,
projectId
);
if
(
resourcesList
==
null
||
resourcesList
.
size
()
==
0
)
{
if
(
resourcesList
==
null
||
resourcesList
.
size
()
==
0
)
{
return
resourcesList
;
return
resourcesList
;
}
else
{
}
else
{
//return billingsList.stream().sorted(Comparator.comparing(Billing::getCreatedOn).reversed()).collect(Collectors.toList());
//return billingsList.stream().sorted(Comparator.comparing(Billing::getCreatedOn).reversed()).collect(Collectors.toList());
return
resourcesList
.
stream
().
sorted
(
Comparator
.
comparing
(
Resource:
:
getBillingStartDate
).
reversed
()).
collect
(
Collectors
.
toList
());
return
resourcesList
.
stream
().
sorted
(
Comparator
.
comparing
(
Resource:
:
getBillingStartDate
).
reversed
()).
collect
(
Collectors
.
toList
());
}
}
}
}
@Override
@Override
public
List
<
Employee
>
getUnAssignedEmployees
()
{
public
List
<
Employee
>
getUnAssignedEmployees
()
{
List
<
Employee
>
notAssignedEmployees
=
new
ArrayList
<>();
List
<
Employee
>
notAssignedEmployees
=
new
ArrayList
<>();
List
<
String
>
resourceIdsList
=
new
ArrayList
<>();
List
<
String
>
resourceIdsList
=
new
ArrayList
<>();
for
(
Resource
resource
:
this
.
getAllResources
())
{
for
(
Resource
resource
:
this
.
getAllResources
())
{
Project
project
=
projectService
.
getProjectByProjectId
(
resource
.
getProjectId
());
Project
project
=
projectService
.
getProjectByProjectId
(
resource
.
getProjectId
());
if
(
project
!=
null
&&
project
.
getStatus
()
!=
null
&&
!
"Completed"
.
equalsIgnoreCase
(
project
.
getStatus
()))
{
if
(
project
!=
null
&&
project
.
getStatus
()
!=
null
&&
!
"Completed"
.
equalsIgnoreCase
(
project
.
getStatus
()))
{
resourceIdsList
.
add
(
resource
.
getEmployeeId
());
resourceIdsList
.
add
(
resource
.
getEmployeeId
());
}
}
}
}
for
(
Employee
employee
:
employeeService
.
getAllEmployees
())
{
for
(
Employee
employee
:
employeeService
.
getAllEmployees
())
{
if
(!
resourceIdsList
.
contains
(
employee
.
getEmployeeId
()))
{
if
(!
resourceIdsList
.
contains
(
employee
.
getEmployeeId
()))
{
notAssignedEmployees
.
add
(
employee
);
notAssignedEmployees
.
add
(
employee
);
}
}
}
}
return
notAssignedEmployees
;
return
notAssignedEmployees
;
}
}
public
void
deleteResourcesUnderProject
(
String
projectId
)
{
public
void
deleteResourcesUnderProject
(
String
projectId
)
{
Query
query
=
new
Query
(
Criteria
.
where
(
"projectId"
).
is
(
projectId
));
Query
query
=
new
Query
(
Criteria
.
where
(
"projectId"
).
is
(
projectId
));
List
<
Resource
>
list
=
mongoTemplate
.
find
(
query
,
Resource
.
class
);
List
<
Resource
>
list
=
mongoTemplate
.
find
(
query
,
Resource
.
class
);
resourceRepo
.
delete
(
list
);
resourceRepo
.
delete
(
list
);
}
}
private
List
<
ResourceVO
>
convertResourcesToResourcesVO
(
List
<
Resource
>
resourcesList
)
{
private
List
<
ResourceVO
>
convertResourcesToResourcesVO
(
List
<
Resource
>
resourcesList
)
{
List
<
ResourceVO
>
finalList
=
new
ArrayList
<>();
List
<
ResourceVO
>
finalList
=
new
ArrayList
<>();
if
(
resourcesList
!=
null
&&
resourcesList
.
size
()
>
0
)
{
if
(
resourcesList
!=
null
&&
resourcesList
.
size
()
>
0
)
{
finalList
=
resourcesList
.
stream
().
map
(
resource
->
{
finalList
=
resourcesList
.
stream
().
map
(
resource
->
{
ResourceVO
resourceVO
=
new
ResourceVO
();
ResourceVO
resourceVO
=
new
ResourceVO
();
resourceVO
.
setId
(
resource
.
getId
());
resourceVO
.
setId
(
resource
.
getId
());
resourceVO
.
setProjectId
(
resource
.
getProjectId
());
resourceVO
.
setProjectId
(
resource
.
getProjectId
());
resourceVO
.
setEmployeeId
(
resource
.
getEmployeeId
());
resourceVO
.
setEmployeeId
(
resource
.
getEmployeeId
());
Employee
employee
=
employeeService
.
getEmployeeById
(
resource
.
getEmployeeId
());
Employee
employee
=
employeeService
.
getEmployeeById
(
resource
.
getEmployeeId
());
if
(
employee
!=
null
)
{
if
(
employee
!=
null
)
{
resourceVO
.
setEmployeeName
(
employee
.
getEmployeeName
());
resourceVO
.
setEmployeeName
(
employee
.
getEmployeeName
());
resourceVO
.
setDesignation
(
employee
.
getDesignation
());
resourceVO
.
setDesignation
(
employee
.
getDesignation
());
resourceVO
.
setEmailId
(
employee
.
getEmailId
());
resourceVO
.
setEmailId
(
employee
.
getEmailId
());
resourceVO
.
setMobileNo
(
employee
.
getMobileNumber
());
resourceVO
.
setMobileNo
(
employee
.
getMobileNumber
());
}
}
Project
project
=
projectService
.
getProjectByProjectId
(
resource
.
getProjectId
());
Project
project
=
projectService
.
getProjectByProjectId
(
resource
.
getProjectId
());
if
(
project
!=
null
)
{
if
(
project
!=
null
)
{
resourceVO
.
setProjectName
(
project
.
getProjectName
());
resourceVO
.
setProjectName
(
project
.
getProjectName
());
resourceVO
.
setProjectStartDate
(
project
.
getProjectStartDate
());
resourceVO
.
setProjectStartDate
(
project
.
getProjectStartDate
());
resourceVO
.
setProjectEndDate
(
project
.
getProjectEndDate
());
resourceVO
.
setProjectEndDate
(
project
.
getProjectEndDate
());
resourceVO
.
setProjectStatus
(
project
.
getStatus
());
resourceVO
.
setProjectStatus
(
project
.
getStatus
());
if
(
project
.
getAccountId
()
!=
null
)
{
if
(
project
.
getAccountId
()
!=
null
)
{
Account
account
=
accountService
.
getAccountById
(
project
.
getAccountId
());
Account
account
=
accountService
.
getAccountById
(
project
.
getAccountId
());
if
(
account
!=
null
)
{
if
(
account
!=
null
)
{
resourceVO
.
setAccountName
(
account
.
getAccountName
());
resourceVO
.
setAccountName
(
account
.
getAccountName
());
}
}
}
}
}
}
//Account account=accountService.getAccountById(domainService.getDomainById(project.getProjectId()).getAccountId());
//Account account=accountService.getAccountById(domainService.getDomainById(project.getProjectId()).getAccountId());
resourceVO
.
setBillableStatus
(
resource
.
getBillableStatus
());
resourceVO
.
setBillableStatus
(
resource
.
getBillableStatus
());
resourceVO
.
setBillingStartDate
(
resource
.
getBillingStartDate
());
resourceVO
.
setBillingStartDate
(
resource
.
getBillingStartDate
());
resourceVO
.
setBillingEndDate
(
resource
.
getBillingEndDate
());
resourceVO
.
setBillingEndDate
(
resource
.
getBillingEndDate
());
resourceVO
.
setResourceRole
(
resource
.
getResourceRole
());
resourceVO
.
setResourceRole
(
resource
.
getResourceRole
());
if
(
resource
.
getBillingEndDate
().
compareTo
(
new
Date
())
>
0
)
{
if
(
resource
.
getBillingEndDate
().
compareTo
(
new
Date
())
>
0
)
{
resourceVO
.
setResourceStatus
(
ResourceStatus
.
ACTIVE
.
getStatus
());
resourceVO
.
setResourceStatus
(
ResourceStatus
.
ACTIVE
.
getStatus
());
}
else
{
}
else
{
resourceVO
.
setResourceStatus
(
ResourceStatus
.
IN_ACTIVE
.
getStatus
());
resourceVO
.
setResourceStatus
(
ResourceStatus
.
IN_ACTIVE
.
getStatus
());
}
}
return
resourceVO
;
return
resourceVO
;
}).
collect
(
Collectors
.
toList
());
}).
collect
(
Collectors
.
toList
());
}
}
return
finalList
;
return
finalList
;
}
}
@Override
@Override
public
Resource
addResourceToBenchProject
(
Employee
employee
,
String
loginEmpId
)
throws
MyTeamException
{
public
Resource
addResourceToBenchProject
(
Employee
employee
,
String
loginEmpId
)
throws
MyTeamException
{
Resource
resourcePersisted
=
null
;
Resource
resourcePersisted
=
null
;
Resource
resourceBench
=
new
Resource
();
Resource
resourceBench
=
new
Resource
();
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
.
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
());
resourceBench
.
setBillingEndDate
(
projectService
.
getProjectByProjectId
(
MyTeamUtils
.
BENCH_PROJECT_ID
).
getProjectEndDate
());
resourceBench
.
setBillingEndDate
(
projectService
.
getProjectByProjectId
(
MyTeamUtils
.
BENCH_PROJECT_ID
).
getProjectEndDate
());
resourcePersisted
=
addResource
(
resourceBench
,
loginEmpId
);
resourcePersisted
=
addResource
(
resourceBench
,
loginEmpId
);
return
resourcePersisted
;
return
resourcePersisted
;
}
}
@Override
@Override
public
List
<
EmployeeShiftsVO
>
getResourcesForShift
(
String
shift
)
{
public
List
<
EmployeeShiftsVO
>
getResourcesForShift
(
String
shift
)
{
List
<
Resource
>
resourcesListPers
=
null
;
List
<
Resource
>
resourcesListPers
=
null
;
List
<
EmployeeShiftsVO
>
resourcesList
=
new
ArrayList
<>();
List
<
EmployeeShiftsVO
>
resourcesList
=
new
ArrayList
<>();
List
<
Project
>
projects
=
projectService
.
getAllProjects
();
List
<
Project
>
projects
=
projectService
.
getAllProjects
();
for
(
Project
project
:
projects
)
{
for
(
Project
project
:
projects
)
{
if
(
"Active"
.
equalsIgnoreCase
(
project
.
getStatus
()))
{
if
(
"Active"
.
equalsIgnoreCase
(
project
.
getStatus
()))
{
resourcesListPers
=
getAllResourcesForProject
(
project
.
getProjectId
());
resourcesListPers
=
getAllResourcesForProject
(
project
.
getProjectId
());
for
(
Resource
resource
:
resourcesListPers
)
{
for
(
Resource
resource
:
resourcesListPers
)
{
// EmployeeShift empShift = empShiftService.getEmployeeShift(resource.getEmployeeId());
// EmployeeShift empShift = empShiftService.getEmployeeShift(resource.getEmployeeId());
// if (empShift != null) {
// if (empShift != null) {
// if (empShift.getShift() != null && empShift.getShift().equalsIgnoreCase(shift))
// if (empShift.getShift() != null && empShift.getShift().equalsIgnoreCase(shift))
// resourcesList.add(resource);
// resourcesList.add(resource);
// else if (empShift.getShift() == null && Shifts.SHIFT1.getShiftType().equalsIgnoreCase(shift))
// else if (empShift.getShift() == null && Shifts.SHIFT1.getShiftType().equalsIgnoreCase(shift))
// resourcesList.add(resource);
// resourcesList.add(resource);
//
//
// }
// }
if
(
resource
.
getBillingEndDate
().
compareTo
(
new
Date
())
>=
0
)
{
if
(
resource
.
getBillingEndDate
().
compareTo
(
new
Date
())
>=
0
)
{
Employee
employee
=
employeeService
.
getEmployeeById
(
resource
.
getEmployeeId
());
Employee
employee
=
employeeService
.
getEmployeeById
(
resource
.
getEmployeeId
());
EmployeeShiftsVO
shiftsVO
=
new
EmployeeShiftsVO
();
EmployeeShiftsVO
shiftsVO
=
new
EmployeeShiftsVO
();
shiftsVO
.
setEmployeeId
(
employee
.
getEmployeeId
());
shiftsVO
.
setEmployeeId
(
employee
.
getEmployeeId
());
shiftsVO
.
setEmployeeName
(
employee
.
getEmployeeName
());
shiftsVO
.
setEmployeeName
(
employee
.
getEmployeeName
());
shiftsVO
.
setEmailId
(
employee
.
getEmailId
());
shiftsVO
.
setEmailId
(
employee
.
getEmailId
());
shiftsVO
.
setMobileNo
(
employee
.
getMobileNumber
());
shiftsVO
.
setMobileNo
(
employee
.
getMobileNumber
());
shiftsVO
.
setProjectName
(
project
.
getProjectName
());
shiftsVO
.
setProjectName
(
project
.
getProjectName
());
if
(
employee
!=
null
)
{
if
(
employee
!=
null
)
{
if
(
shift
.
equalsIgnoreCase
(
employee
.
getShift
()))
if
(
shift
.
equalsIgnoreCase
(
employee
.
getShift
()))
resourcesList
.
add
(
shiftsVO
);
resourcesList
.
add
(
shiftsVO
);
else
if
(
employee
.
getShift
()
==
null
&&
Shifts
.
SHIFT1
.
getShiftType
().
equalsIgnoreCase
(
shift
))
else
if
(
employee
.
getShift
()
==
null
&&
Shifts
.
SHIFT1
.
getShiftType
().
equalsIgnoreCase
(
shift
))
resourcesList
.
add
(
shiftsVO
);
resourcesList
.
add
(
shiftsVO
);
}
}
}
}
}
//for
}
//for
}
}
}
}
return
resourcesList
;
return
resourcesList
;
}
}
@Override
@Override
public
Resource
getLatestResourceByEmpId
(
String
employeeId
)
{
public
Resource
getLatestResourceByEmpId
(
String
employeeId
)
{
return
getLatestAllocation
(
resourceRepo
.
findByEmployeeId
(
employeeId
));
return
getLatestAllocation
(
resourceRepo
.
findByEmployeeId
(
employeeId
));
}
}
@Override
@Override
public
List
<
Resource
>
getResourcesByBillingStatus
(
String
resourceStatus
)
{
public
List
<
Resource
>
getResourcesByBillingStatus
(
String
resourceStatus
)
{
return
resourceRepo
.
findByBillableStatus
(
resourceStatus
);
return
resourceRepo
.
findByBillableStatus
(
resourceStatus
);
}
}
@Override
@Override
public
List
<
ReserveReportsVO
>
getResourceReportsByBillingStatus
(
String
resourceStatus
)
{
public
List
<
ReserveReportsVO
>
getResourceReportsByBillingStatus
(
String
resourceStatus
)
{
return
prepareReserveReports
(
getResourcesByBillingStatus
(
resourceStatus
));
return
prepareReserveReports
(
getResourcesByBillingStatus
(
resourceStatus
));
}
}
@Override
@Override
public
List
<
ReserveReportsVO
>
prepareReserveReports
(
List
<
Resource
>
resourcesList
)
{
public
List
<
ReserveReportsVO
>
prepareReserveReports
(
List
<
Resource
>
resourcesList
)
{
List
<
ReserveReportsVO
>
reserveReportsList
=
new
ArrayList
<>();
List
<
ReserveReportsVO
>
reserveReportsList
=
new
ArrayList
<>();
if
(
resourcesList
!=
null
&&
resourcesList
.
size
()
>
0
)
{
if
(
resourcesList
!=
null
&&
resourcesList
.
size
()
>
0
)
{
Project
project
=
null
;
Project
project
=
null
;
for
(
Resource
resource
:
resourcesList
)
{
for
(
Resource
resource
:
resourcesList
)
{
ReserveReportsVO
reserveReportsVO
=
new
ReserveReportsVO
();
ReserveReportsVO
reserveReportsVO
=
new
ReserveReportsVO
();
reserveReportsVO
.
setEmployeeId
(
resource
.
getEmployeeId
());
reserveReportsVO
.
setEmployeeId
(
resource
.
getEmployeeId
());
reserveReportsVO
.
setEmployeeName
(
employeeService
.
getEmployeeById
(
resource
.
getEmployeeId
()).
getEmployeeName
());
reserveReportsVO
.
setEmployeeName
(
employeeService
.
getEmployeeById
(
resource
.
getEmployeeId
()).
getEmployeeName
());
if
(
StringUtils
.
isNotBlank
(
resource
.
getProjectId
()))
{
if
(
StringUtils
.
isNotBlank
(
resource
.
getProjectId
()))
{
project
=
projectService
.
getProjectByProjectId
(
resource
.
getProjectId
());
project
=
projectService
.
getProjectByProjectId
(
resource
.
getProjectId
());
if
(
project
!=
null
)
{
if
(
project
!=
null
)
{
reserveReportsVO
.
setProjectName
(
project
.
getProjectName
());
reserveReportsVO
.
setProjectName
(
project
.
getProjectName
());
reserveReportsVO
.
setAccountName
(
accountService
.
getAccountById
(
project
.
getAccountId
()).
getAccountName
());
reserveReportsVO
.
setAccountName
(
accountService
.
getAccountById
(
project
.
getAccountId
()).
getAccountName
());
}
}
}
}
reserveReportsVO
.
setBillingStartDate
(
resource
.
getBillingStartDate
());
reserveReportsVO
.
setBillingStartDate
(
resource
.
getBillingStartDate
());
reserveReportsVO
.
setBillingEndDate
(
resource
.
getBillingEndDate
());
reserveReportsVO
.
setBillingEndDate
(
resource
.
getBillingEndDate
());
reserveReportsList
.
add
(
reserveReportsVO
);
reserveReportsList
.
add
(
reserveReportsVO
);
}
}
}
}
return
reserveReportsList
;
return
reserveReportsList
;
}
}
@Override
@Override
public
List
<
Resource
>
getResourceByProjectId
(
String
projectId
){
public
List
<
Resource
>
getResourceByProjectId
(
String
projectId
){
return
resourceRepo
.
findByProjectId
(
projectId
);
return
resourceRepo
.
findByProjectId
(
projectId
);
}
}
public
List
<
ChangedResourceVO
>
getChangedResourceByDate
(
String
fromDatestr
,
String
toDatestr
)
{
public
List
<
ChangedResourceVO
>
getChangedResourceByDate
(
String
fromDatestr
,
String
toDatestr
)
{
// List<ChangedResourceVO> changedResourceVOList = new ArrayList();
// List<ChangedResourceVO> changedResourceVOList = new ArrayList();
// SimpleDateFormat format = new SimpleDateFormat("dd/MM/yyyy");
// SimpleDateFormat format = new SimpleDateFormat("dd/MM/yyyy");
//
//
// try {
// try {
// final Date fromDate = format.parse(fromDatestr);
// final Date fromDate = format.parse(fromDatestr);
// final Date toDate = format.parse(toDatestr);
// final Date toDate = format.parse(toDatestr);
// resourceRepo.findAll().stream().
// resourceRepo.findAll().stream().
// filter(r -> r.getBillingStartDate().before(toDate)&&r.getBillingEndDate().after(fromDate)).forEach(r -> {
// filter(r -> r.getBillingStartDate().before(toDate)&&r.getBillingEndDate().after(fromDate)).forEach(r -> {
// ChangedResourceVO crv = new ChangedResourceVO();
// ChangedResourceVO crv = new ChangedResourceVO();
// Project project = projectService.getProjectByProjectId(r.getProjectId());
// Project project = projectService.getProjectByProjectId(r.getProjectId());
// Employee emp = employeeService.getEmployeeById(r.getEmployeeId());
// Employee emp = employeeService.getEmployeeById(r.getEmployeeId());
// Account account = accountService.getAccountById(project.getAccountId());
// Account account = accountService.getAccountById(project.getAccountId());
//
//
//
//
// if(changedResourceVOList.isEmpty()){
// if(changedResourceVOList.isEmpty()){
// crv.setEmplyeeId(r.getEmployeeId());
// crv.setEmplyeeId(r.getEmployeeId());
// crv.setEmployeeName(emp.getEmployeeName());
// crv.setEmployeeName(emp.getEmployeeName());
// crv.setPrevBillingStatus(r.getBillableStatus());
// crv.setPrevBillingStatus(r.getBillableStatus());
// crv.setPrevBillingStartingDate(r.getBillingStartDate());
// crv.setPrevBillingStartingDate(r.getBillingStartDate());
// crv.setPrevBillingEndDate(r.getBillingEndDate());
// crv.setPrevBillingEndDate(r.getBillingEndDate());
// crv.setPrevClient(account.getAccountName());
// crv.setPrevClient(account.getAccountName());
// crv.setPrevProject(project.getProjectName());
// crv.setPrevProject(project.getProjectName());
// }else {
// }else {
//
//
// if(!crvList.isEmpty()){
// if(!crvList.isEmpty()){
//
//
// }else{
// }else{
//
//
// }
// }
// }
// }
// changedResourceVOList.add(crv);
// changedResourceVOList.add(crv);
// });
// });
//
//
// }catch (Exception e){}
// }catch (Exception e){}
//
//
return
null
;
return
null
;
}
}
public
boolean
validateResourceAllocationStatus
(
ResourceAllocationStatus
resourceStatus
)
{
public
boolean
validateResourceAllocationStatus
(
ResourceAllocationStatus
resourceStatus
)
{
boolean
isValidStatus
=
false
;
boolean
isValidStatus
=
false
;
switch
(
resourceStatus
)
{
switch
(
resourceStatus
)
{
case
TRAINEE:
case
TRAINEE:
case
BILLABLE:
case
BILLABLE:
case
NON_BILLABLE:
case
NON_BILLABLE:
case
RESERVED:
case
RESERVED:
isValidStatus
=
true
;
isValidStatus
=
true
;
break
;
break
;
}
}
return
isValidStatus
;
return
isValidStatus
;
}
}
public
List
<
Resource
>
getResourcesGreaterThanBillingStartDate
(
Date
billingStartDate
)
{
public
List
<
Resource
>
getResourcesGreaterThanBillingStartDate
(
Date
billingStartDate
)
{
return
resourceRepo
.
findByBillingStartDateGreaterThan
(
billingStartDate
);
return
resourceRepo
.
findByBillingStartDateGreaterThan
(
billingStartDate
);
}
}
public
List
<
Resource
>
getResourcesBetweenBillingStartDates
(
Date
fromDate
,
Date
toDate
)
{
public
List
<
Resource
>
getResourcesBetweenBillingStartDates
(
Date
fromDate
,
Date
toDate
)
{
return
resourceRepo
.
findByBillingStartDateBetween
(
fromDate
,
toDate
);
return
resourceRepo
.
findByBillingStartDateBetween
(
fromDate
,
toDate
);
}
}
public
List
<
AllocationChangeVO
>
getAllocationReports
(
Date
fromDate
,
Date
toDate
)
{
public
List
<
AllocationChangeVO
>
getAllocationReports
(
Date
fromDate
,
Date
toDate
)
{
return
getResourcesBetweenBillingStartDates
(
fromDate
,
toDate
).
stream
()
return
getResourcesBetweenBillingStartDates
(
fromDate
,
toDate
).
stream
()
.
filter
(
resource
->
resource
.
getBillingEndDate
().
compareTo
(
new
Date
())
>=
0
).
map
(
resource
->
{
.
filter
(
resource
->
resource
.
getBillingEndDate
().
compareTo
(
new
Date
())
>=
0
).
map
(
resource
->
{
Project
project
=
null
;
Project
project
=
null
;
//Setting Current Billing details.
//Setting Current Billing details.
AllocationChangeVO
allocationVO
=
new
AllocationChangeVO
();
AllocationChangeVO
allocationVO
=
new
AllocationChangeVO
();
allocationVO
.
setEmployeeId
(
resource
.
getEmployeeId
());
allocationVO
.
setEmployeeId
(
resource
.
getEmployeeId
());
allocationVO
.
setEmployeeName
(
employeeService
.
getEmployeeById
(
resource
.
getEmployeeId
()).
getEmployeeName
());
allocationVO
.
setEmployeeName
(
employeeService
.
getEmployeeById
(
resource
.
getEmployeeId
()).
getEmployeeName
());
if
(
StringUtils
.
isNotBlank
(
resource
.
getProjectId
()))
{
if
(
StringUtils
.
isNotBlank
(
resource
.
getProjectId
()))
{
project
=
projectService
.
getProjectByProjectId
(
resource
.
getProjectId
());
project
=
projectService
.
getProjectByProjectId
(
resource
.
getProjectId
());
if
(
project
!=
null
)
{
if
(
project
!=
null
)
{
allocationVO
.
setCurrentProjectName
(
project
.
getProjectName
());
allocationVO
.
setCurrentProjectName
(
project
.
getProjectName
());
allocationVO
.
setCurrentAccountName
(
accountService
.
getAccountById
(
project
.
getAccountId
()).
getAccountName
());
allocationVO
.
setCurrentAccountName
(
accountService
.
getAccountById
(
project
.
getAccountId
()).
getAccountName
());
}
}
}
}
allocationVO
.
setCurrentBillingStatus
(
resource
.
getBillableStatus
());
allocationVO
.
setCurrentBillingStatus
(
resource
.
getBillableStatus
());
allocationVO
.
setCurrentBillingStartDate
(
resource
.
getBillingStartDate
());
allocationVO
.
setCurrentBillingStartDate
(
resource
.
getBillingStartDate
());
allocationVO
.
setCurrentBillingEndDate
(
resource
.
getBillingEndDate
());
allocationVO
.
setCurrentBillingEndDate
(
resource
.
getBillingEndDate
());
Resource
prevBilling
=
resourceRepo
.
findOneByEmployeeIdAndBillingEndDate
(
resource
.
getEmployeeId
(),
MyTeamDateUtils
.
getDayLessThanDate
(
resource
.
getBillingStartDate
()));
Resource
prevBilling
=
resourceRepo
.
findOneByEmployeeIdAndBillingEndDate
(
resource
.
getEmployeeId
(),
MyTeamDateUtils
.
getDayLessThanDate
(
resource
.
getBillingStartDate
()));
log
.
info
(
"\n\n\n The prev billing info is::"
+
prevBilling
);
log
.
info
(
"\n\n\n The prev billing info is::"
+
prevBilling
);
if
(
prevBilling
!=
null
)
{
if
(
prevBilling
!=
null
)
{
if
(
StringUtils
.
isNotBlank
(
prevBilling
.
getProjectId
()))
{
if
(
StringUtils
.
isNotBlank
(
prevBilling
.
getProjectId
()))
{
project
=
projectService
.
getProjectByProjectId
(
prevBilling
.
getProjectId
());
project
=
projectService
.
getProjectByProjectId
(
prevBilling
.
getProjectId
());
if
(
project
!=
null
)
{
if
(
project
!=
null
)
{
allocationVO
.
setPrevProjectName
(
project
.
getProjectName
());
allocationVO
.
setPrevProjectName
(
project
.
getProjectName
());
allocationVO
.
setPrevAccountName
(
accountService
.
getAccountById
(
project
.
getAccountId
()).
getAccountName
());
allocationVO
.
setPrevAccountName
(
accountService
.
getAccountById
(
project
.
getAccountId
()).
getAccountName
());
}
}
}
}
allocationVO
.
setPrevBillingStatus
(
prevBilling
.
getBillableStatus
());
allocationVO
.
setPrevBillingStatus
(
prevBilling
.
getBillableStatus
());
allocationVO
.
setPrevBillingStartDate
(
prevBilling
.
getBillingStartDate
());
allocationVO
.
setPrevBillingStartDate
(
prevBilling
.
getBillingStartDate
());
allocationVO
.
setPrevBillingEndDate
(
prevBilling
.
getBillingEndDate
());
allocationVO
.
setPrevBillingEndDate
(
prevBilling
.
getBillingEndDate
());
}
}
return
allocationVO
;
return
allocationVO
;
}).
collect
(
Collectors
.
toList
());
}).
collect
(
Collectors
.
toList
());
}
}
public
List
<
AllocationChangeVO
>
prepareAllocationResources
(
List
<
Resource
>
resourcesList
)
{
public
List
<
AllocationChangeVO
>
prepareAllocationResources
(
List
<
Resource
>
resourcesList
)
{
List
<
AllocationChangeVO
>
allocationList
=
new
ArrayList
<>();
List
<
AllocationChangeVO
>
allocationList
=
new
ArrayList
<>();
if
(
resourcesList
!=
null
&&
resourcesList
.
size
()
>
0
)
{
if
(
resourcesList
!=
null
&&
resourcesList
.
size
()
>
0
)
{
Project
project
=
null
;
Project
project
=
null
;
for
(
Resource
resource
:
resourcesList
)
{
for
(
Resource
resource
:
resourcesList
)
{
AllocationChangeVO
allocationVO
=
new
AllocationChangeVO
();
AllocationChangeVO
allocationVO
=
new
AllocationChangeVO
();
allocationVO
.
setEmployeeId
(
resource
.
getEmployeeId
());
allocationVO
.
setEmployeeId
(
resource
.
getEmployeeId
());
allocationVO
.
setEmployeeName
(
employeeService
.
getEmployeeById
(
resource
.
getEmployeeId
()).
getEmployeeName
());
allocationVO
.
setEmployeeName
(
employeeService
.
getEmployeeById
(
resource
.
getEmployeeId
()).
getEmployeeName
());
if
(
StringUtils
.
isNotBlank
(
resource
.
getProjectId
()))
{
if
(
StringUtils
.
isNotBlank
(
resource
.
getProjectId
()))
{
project
=
projectService
.
getProjectByProjectId
(
resource
.
getProjectId
());
project
=
projectService
.
getProjectByProjectId
(
resource
.
getProjectId
());
if
(
project
!=
null
)
{
if
(
project
!=
null
)
{
allocationVO
.
setCurrentProjectName
(
project
.
getProjectName
());
allocationVO
.
setCurrentProjectName
(
project
.
getProjectName
());
allocationVO
.
setCurrentAccountName
(
accountService
.
getAccountById
(
project
.
getAccountId
()).
getAccountName
());
allocationVO
.
setCurrentAccountName
(
accountService
.
getAccountById
(
project
.
getAccountId
()).
getAccountName
());
}
}
}
}
allocationVO
.
setCurrentBillingStatus
(
resource
.
getBillableStatus
());
allocationVO
.
setCurrentBillingStatus
(
resource
.
getBillableStatus
());
allocationVO
.
setCurrentBillingStartDate
(
resource
.
getBillingStartDate
());
allocationVO
.
setCurrentBillingStartDate
(
resource
.
getBillingStartDate
());
allocationVO
.
setCurrentBillingEndDate
(
resource
.
getBillingEndDate
());
allocationVO
.
setCurrentBillingEndDate
(
resource
.
getBillingEndDate
());
allocationList
.
add
(
allocationVO
);
allocationList
.
add
(
allocationVO
);
}
}
}
}
return
allocationList
;
return
allocationList
;
}
}
@Override
@Override
public
Set
<
Resource
>
findByBillableStatus
(
String
billableStatus
)
{
public
Set
<
Resource
>
findByBillableStatus
(
String
billableStatus
)
{
return
resourceRepo
.
findByBillableStatus
(
billableStatus
).
stream
().
filter
(
r
->
r
.
getBillingEndDate
().
after
(
new
Date
())).
collect
(
Collectors
.
toSet
());
return
resourceRepo
.
findByBillableStatus
(
billableStatus
).
stream
().
filter
(
r
->
r
.
getBillingEndDate
().
after
(
new
Date
())).
collect
(
Collectors
.
toSet
());
}
}
public
Resource
sendResourceToOpenPool
(
Resource
resource
,
String
loginId
)
{
public
Resource
sendResourceToOpenPool
(
Resource
resource
,
String
loginId
)
{
Resource
existingresource
=
resourceRepo
.
findById
(
resource
.
getId
());
Resource
existingresource
=
resourceRepo
.
findById
(
resource
.
getId
());
existingresource
.
setStatus
(
MyTeamUtils
.
RELEASED_STATUS
);
existingresource
.
setStatus
(
MyTeamUtils
.
RELEASED_STATUS
);
this
.
updateExistedResource
(
existingresource
);
this
.
updateExistedResource
(
existingresource
);
// isResourceAvailableinBenchbygraterthanEndDate=
// isResourceAvailableinBenchbygraterthanEndDate=
Resource
benchResource
=
new
Resource
();
Resource
benchResource
=
new
Resource
();
benchResource
.
setProjectId
(
MyTeamUtils
.
BENCH_PROJECT_ID
);
benchResource
.
setProjectId
(
MyTeamUtils
.
BENCH_PROJECT_ID
);
benchResource
.
setEmployeeId
(
resource
.
getEmployeeId
());
benchResource
.
setEmployeeId
(
resource
.
getEmployeeId
());
benchResource
.
setResourceRole
(
resource
.
getResourceRole
());
benchResource
.
setResourceRole
(
resource
.
getResourceRole
());
benchResource
.
setBillingStartDate
(
MyTeamDateUtils
.
getDayMoreThanDate
(
resource
.
getBillingEndDate
()));
benchResource
.
setBillingStartDate
(
MyTeamDateUtils
.
getDayMoreThanDate
(
resource
.
getBillingEndDate
()));
benchResource
.
setBillingEndDate
(
projectService
.
getProjectByProjectId
(
MyTeamUtils
.
BENCH_PROJECT_ID
).
getProjectEndDate
());
benchResource
.
setBillingEndDate
(
projectService
.
getProjectByProjectId
(
MyTeamUtils
.
BENCH_PROJECT_ID
).
getProjectEndDate
());
benchResource
.
setBillableStatus
(
MyTeamUtils
.
BENCH_BILLABILITY_STATUS
);
benchResource
.
setBillableStatus
(
MyTeamUtils
.
BENCH_BILLABILITY_STATUS
);
benchResource
.
setStatus
(
MyTeamUtils
.
RELEASED_STATUS
);
benchResource
.
setStatus
(
MyTeamUtils
.
RELEASED_STATUS
);
benchResource
.
setAuditFields
(
loginId
,
MyTeamUtils
.
CREATE
);
benchResource
.
setAuditFields
(
loginId
,
MyTeamUtils
.
CREATE
);
Resource
resourcePers
=
resourceRepo
.
save
(
benchResource
);
Resource
resourcePers
=
resourceRepo
.
save
(
benchResource
);
respMap
.
put
(
"statusCode"
,
801
);
respMap
.
put
(
"statusCode"
,
801
);
respMap
.
put
(
"message"
,
"Resource is moved to Bench Successfully"
);
respMap
.
put
(
"message"
,
"Resource is moved to Bench Successfully"
);
return
resourcePers
;
return
resourcePers
;
}
}
}
}
//class
//class
/*
/*
@Override
@Override
public List<ResourceVO> getActiveResources(String empId) {
public List<ResourceVO> getActiveResources(String empId) {
List<ResourceVO> finalResourcesList = new ArrayList<>();
List<ResourceVO> finalResourcesList = new ArrayList<>();
List<Resource> resourceList = resourceRepo.findByEmployeeId(empId);
List<Resource> resourceList = resourceRepo.findByEmployeeId(empId);
if (resourceList != null && resourceList.size() > 0) {
if (resourceList != null && resourceList.size() > 0) {
Resource resourceAlloc=resourceList.get(0);
Resource resourceAlloc=resourceList.get(0);
}
}
for (Resource resource : resourceRepo.findByEmployeeId(empId)) {
for (Resource resource : resourceRepo.findByEmployeeId(empId)) {
ResourceVO resourceVO=new ResourceVO();
ResourceVO resourceVO=new ResourceVO();
resourceVO.setEmployeeId(resource.getEmployeeId());
resourceVO.setEmployeeId(resource.getEmployeeId());
Employee employee=employeeService.getEmployeeById(resource.getEmployeeId());
Employee employee=employeeService.getEmployeeById(resource.getEmployeeId());
resourceVO.setEmployeeName(employee.getEmployeeName());
resourceVO.setEmployeeName(employee.getEmployeeName());
resourceVO.setDesignation(employee.getDesignation());
resourceVO.setDesignation(employee.getDesignation());
resourceVO.setEmailId(employee.getEmailId());
resourceVO.setEmailId(employee.getEmailId());
resourceVO.setMobileNo(employee.getMobileNumber());
resourceVO.setMobileNo(employee.getMobileNumber());
resourceVO.setProjectName(projectService.getProjectByProjectId(resource.getProjectId()).getProjectName());
resourceVO.setProjectName(projectService.getProjectByProjectId(resource.getProjectId()).getProjectName());
if (resource.getBillingEndDate().compareTo(new Date()) > 0) {
if (resource.getBillingEndDate().compareTo(new Date()) > 0) {
finalResourcesList.addAll(getAllResourcesForProject(resource.getProjectId()));
finalResourcesList.addAll(getAllResourcesForProject(resource.getProjectId()));
}
}
}
}
return finalResourcesList;
return finalResourcesList;
}
}
*/
*/
/*
/*
@Override
@Override
public List<ResourceVO> getActiveResources(String empId) {
public List<ResourceVO> getActiveResources(String empId) {
List<ResourceVO> finalResourcesList = new ArrayList<>();
List<ResourceVO> finalResourcesList = new ArrayList<>();
Employee employee = null;
Employee employee = null;
List<Resource> resourceList = resourceRepo.findByEmployeeId(empId);
List<Resource> resourceList = resourceRepo.findByEmployeeId(empId);
Optional<Resource> optionalResource = resourceList.stream().filter(resource -> resource.getBillingEndDate().compareTo(new Date()) > 0).findAny();
Optional<Resource> optionalResource = resourceList.stream().filter(resource -> resource.getBillingEndDate().compareTo(new Date()) > 0).findAny();
if (optionalResource.isPresent()) {
if (optionalResource.isPresent()) {
finalResourcesList = prepareProjectTeamMembersList(optionalResource.get().getProjectId());
finalResourcesList = prepareProjectTeamMembersList(optionalResource.get().getProjectId());
}
}
return finalResourcesList;
return finalResourcesList;
}
}
*/
*/
src/main/resources/application.properties
View file @
743d5b79
...
@@ -2,16 +2,16 @@ server.port=8080
...
@@ -2,16 +2,16 @@ server.port=8080
server.context-path
=
/myTeam/
server.context-path
=
/myTeam/
#Production configuration
#Production configuration
spring.data.mongodb.host
=
10.3.45.11
#
spring.data.mongodb.host=10.3.45.11
spring.data.mongodb.port
=
27017
#
spring.data.mongodb.port=27017
spring.data.mongodb.database
=
mytimedb
#
spring.data.mongodb.database=mytimedb
spring.data.mongodb.username
=
mytime
#
spring.data.mongodb.username=mytime
spring.data.mongodb.password
=
nisum@123
#
spring.data.mongodb.password=nisum@123
#Local Database configuration
#Local Database configuration
#
spring.data.mongodb.host=localhost
spring.data.mongodb.host
=
localhost
#
spring.data.mongodb.port=27017
spring.data.mongodb.port
=
27017
#
spring.data.mongodb.database=mytime
spring.data.mongodb.database
=
mytime
quartz.enabled
=
true
quartz.enabled
=
true
cron.expression
=
0 45 10/3 1/1 * ? *
cron.expression
=
0 45 10/3 1/1 * ? *
...
...
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