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
099feaf1
Commit
099feaf1
authored
Jun 07, 2019
by
vikram singh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
"UIReport Service implemented"
parent
6574f8fd
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
1906 additions
and
1803 deletions
+1906
-1803
ReportsController.java
...n/java/com/nisum/myteam/controller/ReportsController.java
+450
-439
BillableEmployee.java
src/main/java/com/nisum/myteam/model/BillableEmployee.java
+30
-0
IEmployeeService.java
src/main/java/com/nisum/myteam/service/IEmployeeService.java
+58
-55
IResourceService.java
src/main/java/com/nisum/myteam/service/IResourceService.java
+82
-80
EmployeeService.java
...n/java/com/nisum/myteam/service/impl/EmployeeService.java
+382
-329
ResourceService.java
...n/java/com/nisum/myteam/service/impl/ResourceService.java
+904
-900
No files found.
src/main/java/com/nisum/myteam/controller/ReportsController.java
View file @
099feaf1
package
com
.
nisum
.
myteam
.
controller
;
package
com
.
nisum
.
myteam
.
controller
;
import
com.nisum.myteam.exception.handler.MyTeamException
;
import
static
org
.
springframework
.
data
.
mongodb
.
core
.
aggregation
.
Aggregation
.
group
;
import
com.nisum.myteam.exception.handler.ResponseDetails
;
import
static
org
.
springframework
.
data
.
mongodb
.
core
.
aggregation
.
Aggregation
.
newAggregation
;
import
com.nisum.myteam.model.ColumnChartData
;
import
static
org
.
springframework
.
data
.
mongodb
.
core
.
aggregation
.
Aggregation
.
project
;
import
com.nisum.myteam.model.GroupByCount
;
import
static
org
.
springframework
.
data
.
mongodb
.
core
.
aggregation
.
Aggregation
.
sort
;
import
com.nisum.myteam.model.ReportSeriesRecord
;
import
com.nisum.myteam.model.dao.Account
;
import
java.text.ParseException
;
import
com.nisum.myteam.model.dao.Employee
;
import
java.text.SimpleDateFormat
;
import
com.nisum.myteam.model.dao.Resource
;
import
java.util.ArrayList
;
import
com.nisum.myteam.model.vo.ReportVo
;
import
java.util.Calendar
;
import
com.nisum.myteam.model.vo.ResourceVO
;
import
java.util.Date
;
import
com.nisum.myteam.service.IAccountService
;
import
java.util.HashMap
;
import
com.nisum.myteam.service.IEmployeeService
;
import
java.util.List
;
import
com.nisum.myteam.service.IResourceService
;
import
java.util.Map
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
java.util.stream.Collectors
;
import
org.springframework.data.domain.Sort
;
import
org.springframework.data.mongodb.core.MongoTemplate
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.mongodb.core.aggregation.Aggregation
;
import
org.springframework.data.domain.Sort
;
import
org.springframework.data.mongodb.core.aggregation.AggregationResults
;
import
org.springframework.data.mongodb.core.MongoTemplate
;
import
org.springframework.data.mongodb.core.aggregation.MatchOperation
;
import
org.springframework.data.mongodb.core.aggregation.Aggregation
;
import
org.springframework.data.mongodb.core.aggregation.ProjectionOperation
;
import
org.springframework.data.mongodb.core.aggregation.AggregationResults
;
import
org.springframework.data.mongodb.core.query.Criteria
;
import
org.springframework.data.mongodb.core.aggregation.MatchOperation
;
import
org.springframework.data.mongodb.core.query.Query
;
import
org.springframework.data.mongodb.core.aggregation.ProjectionOperation
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.data.mongodb.core.query.Criteria
;
import
org.springframework.http.MediaType
;
import
org.springframework.data.mongodb.core.query.Query
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.http.MediaType
;
import
org.springframework.http.ResponseEntity
;
import
javax.servlet.http.HttpServletRequest
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
java.text.ParseException
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
java.text.SimpleDateFormat
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
java.util.*
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.util.stream.Collectors
;
import
com.nisum.myteam.exception.handler.MyTeamException
;
import
static
org
.
springframework
.
data
.
mongodb
.
core
.
aggregation
.
Aggregation
.*;
import
com.nisum.myteam.model.BillableEmployee
;
import
com.nisum.myteam.model.ColumnChartData
;
//import com.nisum.myteam.model.dao.Resource;
import
com.nisum.myteam.model.GroupByCount
;
import
com.nisum.myteam.model.ReportSeriesRecord
;
@RestController
import
com.nisum.myteam.model.dao.Account
;
@RequestMapping
(
"/reports"
)
import
com.nisum.myteam.model.dao.Employee
;
public
class
ReportsController
{
import
com.nisum.myteam.model.dao.Resource
;
import
com.nisum.myteam.model.vo.ReportVo
;
import
com.nisum.myteam.model.vo.ResourceVO
;
@Autowired
import
com.nisum.myteam.service.IAccountService
;
private
MongoTemplate
mongoTemplate
;
import
com.nisum.myteam.service.IEmployeeService
;
import
com.nisum.myteam.service.IResourceService
;
@Autowired
private
IEmployeeService
employeeService
;
//import com.nisum.myteam.model.dao.Resource;
@Autowired
@RestController
private
IResourceService
resourceService
;
@RequestMapping
(
"/reports"
)
public
class
ReportsController
{
@Autowired
private
IAccountService
accountService
;
@Autowired
//Ok Response
private
MongoTemplate
mongoTemplate
;
@RequestMapping
(
value
=
"/getEmployeesByFunctionalGroup1"
,
method
=
RequestMethod
.
GET
,
@Autowired
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
private
IEmployeeService
employeeService
;
public
ResponseEntity
<
List
<
GroupByCount
>>
getEmployeesByFunctionalGroup
()
throws
MyTeamException
{
@Autowired
ProjectionOperation
projectToMatchModel
=
project
()
private
IResourceService
resourceService
;
.
andExpression
(
"functionalGroup"
).
as
(
"name"
).
andExpression
(
"y"
)
.
as
(
"y"
);
@Autowired
private
IAccountService
accountService
;
Aggregation
agg
=
newAggregation
(
// match(Criteria.where("employeeId").gt(10)),
//Ok Response
group
(
"functionalGroup"
).
count
().
as
(
"y"
),
@RequestMapping
(
value
=
"/getEmployeesByFunctionalGroup1"
,
project
(
"y"
).
and
(
"functionalGroup"
).
previousOperation
(),
method
=
RequestMethod
.
GET
,
projectToMatchModel
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
List
<
GroupByCount
>>
getEmployeesByFunctionalGroup
()
sort
(
Sort
.
Direction
.
DESC
,
"y"
)
throws
MyTeamException
{
ProjectionOperation
projectToMatchModel
=
project
()
);
.
andExpression
(
"functionalGroup"
).
as
(
"name"
).
andExpression
(
"y"
)
.
as
(
"y"
);
// Convert the aggregation result into a List
AggregationResults
<
GroupByCount
>
groupResults
=
mongoTemplate
Aggregation
agg
=
newAggregation
(
.
aggregate
(
agg
,
Employee
.
class
,
GroupByCount
.
class
);
// match(Criteria.where("employeeId").gt(10)),
List
<
GroupByCount
>
result
=
groupResults
.
getMappedResults
();
group
(
"functionalGroup"
).
count
().
as
(
"y"
),
project
(
"y"
).
and
(
"functionalGroup"
).
previousOperation
(),
return
new
ResponseEntity
<>(
result
,
HttpStatus
.
OK
);
projectToMatchModel
,
}
sort
(
Sort
.
Direction
.
DESC
,
"y"
)
//Ok Response
);
@RequestMapping
(
value
=
"/getEmployeesByFunctionalGroupForReport"
,
method
=
RequestMethod
.
GET
,
// Convert the aggregation result into a List
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
AggregationResults
<
GroupByCount
>
groupResults
=
mongoTemplate
public
ResponseEntity
<
ColumnChartData
>
getEmployeesByFunctionalGroupForReport
()
.
aggregate
(
agg
,
Employee
.
class
,
GroupByCount
.
class
);
throws
MyTeamException
{
List
<
GroupByCount
>
result
=
groupResults
.
getMappedResults
();
ProjectionOperation
projectToMatchModel
=
project
()
.
andExpression
(
"functionalGroup"
).
as
(
"name"
).
andExpression
(
"y"
)
return
new
ResponseEntity
<>(
result
,
HttpStatus
.
OK
);
.
as
(
"y"
);
}
MatchOperation
matchStage
=
Aggregation
.
match
(
new
Criteria
(
"empStatus"
).
is
(
"Active"
));
Aggregation
agg
=
newAggregation
(
//Ok Response
// match(Criteria.where("employeeId").gt(10)),
@RequestMapping
(
value
=
"/getEmployeesByFunctionalGroupForReport"
,
matchStage
,
group
(
"functionalGroup"
).
count
().
as
(
"y"
),
method
=
RequestMethod
.
GET
,
project
(
"y"
).
and
(
"functionalGroup"
).
previousOperation
(),
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
projectToMatchModel
,
public
ResponseEntity
<
ColumnChartData
>
getEmployeesByFunctionalGroupForReport
()
throws
MyTeamException
{
sort
(
Sort
.
Direction
.
DESC
,
"y"
)
ProjectionOperation
projectToMatchModel
=
project
()
.
andExpression
(
"functionalGroup"
).
as
(
"name"
).
andExpression
(
"y"
)
);
.
as
(
"y"
);
MatchOperation
matchStage
=
Aggregation
// Convert the aggregation result into a List
.
match
(
new
Criteria
(
"empStatus"
).
is
(
"Active"
));
AggregationResults
<
GroupByCount
>
groupResults
=
mongoTemplate
Aggregation
agg
=
newAggregation
(
.
aggregate
(
agg
,
Employee
.
class
,
GroupByCount
.
class
);
// match(Criteria.where("employeeId").gt(10)),
List
<
GroupByCount
>
result
=
groupResults
.
getMappedResults
();
matchStage
,
group
(
"functionalGroup"
).
count
().
as
(
"y"
),
ColumnChartData
reportData
=
new
ColumnChartData
();
project
(
"y"
).
and
(
"functionalGroup"
).
previousOperation
(),
reportData
.
setCategories
(
"data"
);
projectToMatchModel
,
reportData
.
setSeriesDataList
(
result
);
return
new
ResponseEntity
<>(
reportData
,
HttpStatus
.
OK
);
sort
(
Sort
.
Direction
.
DESC
,
"y"
)
}
);
// Convert the aggregation result into a List
AggregationResults
<
GroupByCount
>
groupResults
=
mongoTemplate
//ok response
.
aggregate
(
agg
,
Employee
.
class
,
GroupByCount
.
class
);
@RequestMapping
(
value
=
"/getBillabilityDetailsByMonth"
,
List
<
GroupByCount
>
result
=
groupResults
.
getMappedResults
();
method
=
RequestMethod
.
GET
,
ColumnChartData
reportData
=
new
ColumnChartData
();
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
reportData
.
setCategories
(
"data"
);
public
ResponseEntity
<
ColumnChartData
>
getBillabilityDetailsByMonth
()
reportData
.
setSeriesDataList
(
result
);
throws
MyTeamException
{
return
new
ResponseEntity
<>(
reportData
,
HttpStatus
.
OK
);
Date
reportDate
=
new
Date
();
}
Map
m
=
new
HashMap
();
ReportSeriesRecord
reportSeriesRecordBillable
=
new
ReportSeriesRecord
();
reportSeriesRecordBillable
.
setName
(
"Billable"
);
reportSeriesRecordBillable
.
setData
(
new
long
[
12
]);
//ok response
m
.
put
(
"Billable"
,
reportSeriesRecordBillable
);
@RequestMapping
(
value
=
"/getBillabilityDetailsByMonth"
,
method
=
RequestMethod
.
GET
,
ReportSeriesRecord
reportSeriesRecordShadow
=
new
ReportSeriesRecord
();
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
reportSeriesRecordShadow
.
setName
(
"Shadow"
);
public
ResponseEntity
<
ColumnChartData
>
getBillabilityDetailsByMonth
()
reportSeriesRecordShadow
.
setData
(
new
long
[
12
]);
throws
MyTeamException
{
m
.
put
(
"Shadow"
,
reportSeriesRecordShadow
);
Date
reportDate
=
new
Date
();
ReportSeriesRecord
reportSeriesRecordReserved
=
new
ReportSeriesRecord
();
Map
m
=
new
HashMap
();
reportSeriesRecordReserved
.
setName
(
"Reserved"
);
ReportSeriesRecord
reportSeriesRecordBillable
=
new
ReportSeriesRecord
();
reportSeriesRecordReserved
.
setData
(
new
long
[
12
]);
reportSeriesRecordBillable
.
setName
(
"Billable"
);
m
.
put
(
"Reserved"
,
reportSeriesRecordReserved
);
reportSeriesRecordBillable
.
setData
(
new
long
[
12
]);
m
.
put
(
"Billable"
,
reportSeriesRecordBillable
);
ReportSeriesRecord
reportSeriesRecordNBillable
=
new
ReportSeriesRecord
();
reportSeriesRecordNBillable
.
setName
(
"Non-Billable"
);
ReportSeriesRecord
reportSeriesRecordShadow
=
new
ReportSeriesRecord
();
reportSeriesRecordNBillable
.
setData
(
new
long
[
12
]);
reportSeriesRecordShadow
.
setName
(
"Shadow"
);
m
.
put
(
"Non-Billable"
,
reportSeriesRecordNBillable
);
reportSeriesRecordShadow
.
setData
(
new
long
[
12
]);
List
<
String
>
catagories
=
new
ArrayList
();
m
.
put
(
"Shadow"
,
reportSeriesRecordShadow
);
for
(
int
i
=
0
;
i
<
12
;
i
++)
{
ReportSeriesRecord
reportSeriesRecordReserved
=
new
ReportSeriesRecord
();
reportDate
=
new
Date
();
reportSeriesRecordReserved
.
setName
(
"Reserved"
);
reportDate
.
setDate
(
1
);
reportSeriesRecordReserved
.
setData
(
new
long
[
12
]);
reportDate
.
setMonth
(
i
);
m
.
put
(
"Reserved"
,
reportSeriesRecordReserved
);
Calendar
calendar
=
Calendar
.
getInstance
();
ReportSeriesRecord
reportSeriesRecordNBillable
=
new
ReportSeriesRecord
();
calendar
.
setTime
(
reportDate
);
reportSeriesRecordNBillable
.
setName
(
"Non-Billable"
);
int
lastDate
=
calendar
.
getActualMaximum
(
Calendar
.
DATE
);
reportSeriesRecordNBillable
.
setData
(
new
long
[
12
]);
reportDate
.
setDate
(
lastDate
);
m
.
put
(
"Non-Billable"
,
reportSeriesRecordNBillable
);
List
<
String
>
catagories
=
new
ArrayList
();
String
pattern
=
"MM-dd-yyyy"
;
SimpleDateFormat
simpleDateFormat
=
new
SimpleDateFormat
(
pattern
);
for
(
int
i
=
0
;
i
<
12
;
i
++)
{
String
date
=
simpleDateFormat
.
format
(
reportDate
);
reportDate
=
new
Date
();
catagories
.
add
(
date
);
reportDate
.
setDate
(
1
);
reportDate
.
setMonth
(
i
);
Criteria
criteriaV1
=
Criteria
.
where
(
"billingStartDate"
)
.
lt
(
reportDate
);
Calendar
calendar
=
Calendar
.
getInstance
();
Criteria
criteriaV21
=
Criteria
.
where
(
"billingEndDate"
).
is
(
null
);
calendar
.
setTime
(
reportDate
);
Criteria
criteriaV22
=
Criteria
.
where
(
"billingEndDate"
)
int
lastDate
=
calendar
.
getActualMaximum
(
Calendar
.
DATE
);
.
gt
(
reportDate
);
reportDate
.
setDate
(
lastDate
);
Criteria
criteriaV221
=
criteriaV1
.
orOperator
(
criteriaV21
,
criteriaV22
);
String
pattern
=
"MM-dd-yyyy"
;
/*
SimpleDateFormat
simpleDateFormat
=
new
SimpleDateFormat
(
pattern
);
* MatchOperation matchStage = Aggregation.match(new Criteria()
String
date
=
simpleDateFormat
.
format
(
reportDate
);
* .andOperator(criteriaV1).andOperator(criteriaV221));
catagories
.
add
(
date
);
*/
MatchOperation
matchStage
=
Aggregation
.
match
(
criteriaV221
);
Criteria
criteriaV1
=
Criteria
.
where
(
"billingStartDate"
)
.
lt
(
reportDate
);
Aggregation
agg1
=
newAggregation
(
matchStage
,
Criteria
criteriaV21
=
Criteria
.
where
(
"billingEndDate"
).
is
(
null
);
group
(
"billableStatus"
).
count
().
as
(
"count"
),
Criteria
criteriaV22
=
Criteria
.
where
(
"billingEndDate"
)
project
(
"count"
).
and
(
"billableStatus"
).
previousOperation
());
.
gt
(
reportDate
);
Criteria
criteriaV221
=
criteriaV1
.
orOperator
(
criteriaV21
,
// Convert the aggregation result into a List
criteriaV22
);
AggregationResults
<
ColumnChartData
>
groupResults1
=
mongoTemplate
/*
.
aggregate
(
agg1
,
Resource
.
class
,
* MatchOperation matchStage = Aggregation.match(new Criteria()
ColumnChartData
.
class
);
* .andOperator(criteriaV1).andOperator(criteriaV221));
List
<
ColumnChartData
>
result1
=
groupResults1
.
getMappedResults
();
*/
MatchOperation
matchStage
=
Aggregation
.
match
(
criteriaV221
);
List
<
String
>
statusList
=
new
ArrayList
();
statusList
.
add
(
"Billable"
);
Aggregation
agg1
=
newAggregation
(
matchStage
,
statusList
.
add
(
"Shadow"
);
group
(
"billableStatus"
).
count
().
as
(
"count"
),
statusList
.
add
(
"Reserved"
);
project
(
"count"
).
and
(
"billableStatus"
).
previousOperation
());
statusList
.
add
(
"Non-Billable"
);
for
(
String
status
:
statusList
)
{
// Convert the aggregation result into a List
AggregationResults
<
ColumnChartData
>
groupResults1
=
mongoTemplate
for
(
ColumnChartData
columnChartData
:
result1
)
{
.
aggregate
(
agg1
,
Resource
.
class
,
if
(
columnChartData
.
getBillableStatus
()
!=
null
ColumnChartData
.
class
);
&&
columnChartData
.
getBillableStatus
()
List
<
ColumnChartData
>
result1
=
groupResults1
.
getMappedResults
();
.
equalsIgnoreCase
(
status
))
{
ReportSeriesRecord
record
=
(
ReportSeriesRecord
)
m
List
<
String
>
statusList
=
new
ArrayList
();
.
get
(
status
);
statusList
.
add
(
"Billable"
);
record
.
getData
()[
i
]
=
columnChartData
.
getCount
();
statusList
.
add
(
"Shadow"
);
}
statusList
.
add
(
"Reserved"
);
statusList
.
add
(
"Non-Billable"
);
}
for
(
String
status
:
statusList
)
{
}
}
for
(
ColumnChartData
columnChartData
:
result1
)
{
ColumnChartData
reportData
=
new
ColumnChartData
();
if
(
columnChartData
.
getBillableStatus
()
!=
null
System
.
out
.
println
(
"catagories"
+
catagories
);
&&
columnChartData
.
getBillableStatus
()
System
.
out
.
println
(
"m.values()"
+
m
.
values
());
.
equalsIgnoreCase
(
status
))
{
reportData
.
setCategoriesList
(
catagories
);
ReportSeriesRecord
record
=
(
ReportSeriesRecord
)
m
reportData
.
setSeriesDataList
(
new
ArrayList
<
String
>(
m
.
values
()));
.
get
(
status
);
return
new
ResponseEntity
<>(
reportData
,
HttpStatus
.
OK
);
record
.
getData
()[
i
]
=
columnChartData
.
getCount
();
}
}
//ok response
}
@RequestMapping
(
value
=
"/getEmployeesByFunctionalGroup"
,
}
method
=
RequestMethod
.
GET
,
}
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
ColumnChartData
reportData
=
new
ColumnChartData
();
public
ResponseEntity
<
List
<
Map
<
String
,
List
<
GroupByCount
>>>>
getEmployeesByFunctionalGroup1
()
System
.
out
.
println
(
"catagories"
+
catagories
);
throws
MyTeamException
{
System
.
out
.
println
(
"m.values()"
+
m
.
values
());
ProjectionOperation
projectToMatchModel
=
project
()
reportData
.
setCategoriesList
(
catagories
);
.
andExpression
(
"functionalGroup"
).
as
(
"name"
).
andExpression
(
"y"
)
reportData
.
setSeriesDataList
(
new
ArrayList
<
String
>(
m
.
values
()));
.
as
(
"y"
);
return
new
ResponseEntity
<>(
reportData
,
HttpStatus
.
OK
);
MatchOperation
matchStage
=
Aggregation
}
.
match
(
new
Criteria
(
"empStatus"
).
is
(
"Active"
));
Aggregation
agg
=
newAggregation
(
//ok response
// match(Criteria.where("employeeId").gt(10)),
@RequestMapping
(
value
=
"/getEmployeesByFunctionalGroup"
,
matchStage
,
group
(
"functionalGroup"
).
count
().
as
(
"y"
),
method
=
RequestMethod
.
GET
,
project
(
"y"
).
and
(
"functionalGroup"
).
previousOperation
(),
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
projectToMatchModel
,
public
ResponseEntity
<
List
<
Map
<
String
,
List
<
GroupByCount
>>>>
getEmployeesByFunctionalGroup1
()
throws
MyTeamException
{
sort
(
Sort
.
Direction
.
DESC
,
"y"
)
ProjectionOperation
projectToMatchModel
=
project
()
.
andExpression
(
"functionalGroup"
).
as
(
"name"
).
andExpression
(
"y"
)
);
.
as
(
"y"
);
MatchOperation
matchStage
=
Aggregation
// Convert the aggregation result into a List
.
match
(
new
Criteria
(
"empStatus"
).
is
(
"Active"
));
AggregationResults
<
GroupByCount
>
groupResults
=
mongoTemplate
Aggregation
agg
=
newAggregation
(
.
aggregate
(
agg
,
Employee
.
class
,
GroupByCount
.
class
);
// match(Criteria.where("employeeId").gt(10)),
List
<
GroupByCount
>
result
=
groupResults
.
getMappedResults
();
matchStage
,
group
(
"functionalGroup"
).
count
().
as
(
"y"
),
Map
<
String
,
List
<
GroupByCount
>>
map
=
new
HashMap
<
String
,
List
<
GroupByCount
>>();
project
(
"y"
).
and
(
"functionalGroup"
).
previousOperation
(),
map
.
put
(
"data"
,
result
);
projectToMatchModel
,
List
<
Map
<
String
,
List
<
GroupByCount
>>>
list
=
new
ArrayList
<
Map
<
String
,
List
<
GroupByCount
>>>();
list
.
add
(
map
);
sort
(
Sort
.
Direction
.
DESC
,
"y"
)
return
new
ResponseEntity
<>(
list
,
HttpStatus
.
OK
);
);
}
// Convert the aggregation result into a List
@RequestMapping
(
value
=
"/fetchEmployeeDetailsByFG"
,
AggregationResults
<
GroupByCount
>
groupResults
=
mongoTemplate
method
=
RequestMethod
.
GET
,
.
aggregate
(
agg
,
Employee
.
class
,
GroupByCount
.
class
);
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
List
<
GroupByCount
>
result
=
groupResults
.
getMappedResults
();
public
ResponseEntity
<
List
<
Employee
>>
getEmployeesByFG
(
Map
<
String
,
List
<
GroupByCount
>>
map
=
new
HashMap
<
String
,
List
<
GroupByCount
>>();
@RequestParam
(
"fGroup"
)
String
fGroup
)
throws
MyTeamException
{
map
.
put
(
"data"
,
result
);
List
<
Employee
>
empList
=
new
ArrayList
<>();
List
<
Map
<
String
,
List
<
GroupByCount
>>>
list
=
new
ArrayList
<
Map
<
String
,
List
<
GroupByCount
>>>();
empList
=
employeeService
.
getEmployeesByFunctionalGrp
(
fGroup
);
list
.
add
(
map
);
return
new
ResponseEntity
<>(
empList
,
HttpStatus
.
OK
);
return
new
ResponseEntity
<>(
list
,
HttpStatus
.
OK
);
}
}
@RequestMapping
(
value
=
"/fetchEmployeeDetailsByAccountBillability"
,
@RequestMapping
(
value
=
"/fetchEmployeeDetailsByFGAndBillability"
,
method
=
RequestMethod
.
GET
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
List
<
ResourceVO
>>
fetchEmployeeDetailsByAccountBillability
(
public
ResponseEntity
<
List
<
BillableEmployee
>>
getEmployeesByFGAndBillability
(
@RequestParam
(
"account"
)
String
account
,
@RequestParam
(
"fGroup"
)
String
fGroup
,
@RequestParam
(
"billableStatus"
)
String
billableStatus
)
throws
MyTeamException
{
@RequestParam
(
"billabilityStatus"
)
String
billabilityStatus
)
List
<
BillableEmployee
>
empList
=
new
ArrayList
<>();
throws
MyTeamException
{
empList
=
employeeService
.
getEmployeeDetailsByFGAndBillability
(
fGroup
,
billableStatus
);
List
<
ResourceVO
>
resourcesList
=
new
ArrayList
<>();
if
(
account
!=
null
&&
!
account
.
isEmpty
())
{
return
new
ResponseEntity
<>(
empList
,
HttpStatus
.
OK
);
}
resourcesList
=
resourceService
.
getAllResourcesVO
();
@RequestMapping
(
value
=
"/fetchEmployeeDetailsByAccountBillability"
,
}
method
=
RequestMethod
.
GET
,
return
new
ResponseEntity
<>(
resourcesList
,
HttpStatus
.
OK
);
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
}
public
ResponseEntity
<
List
<
ResourceVO
>>
fetchEmployeeDetailsByAccountBillability
(
@RequestParam
(
"account"
)
String
account
,
@RequestParam
(
"billabilityStatus"
)
String
billabilityStatus
)
@RequestMapping
(
value
=
"/fetchEmployeeDetailsByDateBillability"
,
throws
MyTeamException
{
method
=
RequestMethod
.
GET
,
List
<
ResourceVO
>
resourcesList
=
new
ArrayList
<>();
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
if
(
account
!=
null
&&
!
account
.
isEmpty
())
{
public
ResponseEntity
<
List
<
Resource
>>
fetchEmployeeDetailsByDateBillability
(
@RequestParam
(
"billabilityStatus"
)
String
billabilityStatus
,
resourcesList
=
resourceService
.
getAllResourcesVO
();
@RequestParam
(
"reportDate"
)
String
reportDateString
)
throws
MyTeamException
{
}
List
<
Resource
>
empList
=
new
ArrayList
<>();
return
new
ResponseEntity
<>(
resourcesList
,
HttpStatus
.
OK
);
if
(
reportDateString
!=
null
&&
!
reportDateString
.
isEmpty
())
{
}
String
pattern
=
"MM-dd-yyyy"
;
SimpleDateFormat
simpleDateFormat
=
new
SimpleDateFormat
(
pattern
);
Date
reportDateValue
=
new
Date
();
@RequestMapping
(
value
=
"/fetchEmployeeDetailsByDateBillability"
,
try
{
method
=
RequestMethod
.
GET
,
reportDateValue
=
simpleDateFormat
.
parse
(
reportDateString
);
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
}
catch
(
ParseException
e
)
{
public
ResponseEntity
<
List
<
Resource
>>
fetchEmployeeDetailsByDateBillability
(
// TODO Auto-generated catch block
@RequestParam
(
"billabilityStatus"
)
String
billabilityStatus
,
e
.
printStackTrace
();
@RequestParam
(
"reportDate"
)
String
reportDateString
)
}
throws
MyTeamException
{
List
<
Resource
>
empList
=
new
ArrayList
<>();
Criteria
status
=
Criteria
.
where
(
"billableStatus"
)
if
(
reportDateString
!=
null
&&
!
reportDateString
.
isEmpty
())
{
.
is
(
billabilityStatus
);
String
pattern
=
"MM-dd-yyyy"
;
Criteria
criteriaV1
=
Criteria
.
where
(
"billingStartDate"
)
SimpleDateFormat
simpleDateFormat
=
new
SimpleDateFormat
(
pattern
);
.
lt
(
reportDateValue
);
Date
reportDateValue
=
new
Date
();
Criteria
criteriaV21
=
Criteria
.
where
(
"billingEndDate"
).
is
(
null
);
try
{
Criteria
criteriaV22
=
Criteria
.
where
(
"billingEndDate"
)
reportDateValue
=
simpleDateFormat
.
parse
(
reportDateString
);
.
gt
(
reportDateValue
);
}
catch
(
ParseException
e
)
{
Criteria
criteriaV221
=
status
.
andOperator
(
// TODO Auto-generated catch block
criteriaV1
.
orOperator
(
criteriaV21
,
criteriaV22
));
e
.
printStackTrace
();
Query
query
=
new
Query
();
}
query
.
addCriteria
(
criteriaV221
);
empList
=
mongoTemplate
.
find
(
query
,
Resource
.
class
);
Criteria
status
=
Criteria
.
where
(
"billableStatus"
)
}
.
is
(
billabilityStatus
);
return
new
ResponseEntity
<>(
empList
,
HttpStatus
.
OK
);
Criteria
criteriaV1
=
Criteria
.
where
(
"billingStartDate"
)
}
.
lt
(
reportDateValue
);
Criteria
criteriaV21
=
Criteria
.
where
(
"billingEndDate"
).
is
(
null
);
@RequestMapping
(
value
=
"/billabilityByFunctionalGroup"
,
Criteria
criteriaV22
=
Criteria
.
where
(
"billingEndDate"
)
method
=
RequestMethod
.
GET
,
.
gt
(
reportDateValue
);
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
Criteria
criteriaV221
=
status
.
andOperator
(
public
ReportVo
billabilityReportByFunctionalGroup
(){
criteriaV1
.
orOperator
(
criteriaV21
,
criteriaV22
));
Query
query
=
new
Query
();
ReportVo
reportVo
=
new
ReportVo
();
query
.
addCriteria
(
criteriaV221
);
Map
<
String
,
Object
>
billableData
=
new
HashMap
();
empList
=
mongoTemplate
.
find
(
query
,
Resource
.
class
);
Map
<
String
,
Object
>
nonBillableData
=
new
HashMap
();
}
List
<
Object
>
billableCount
=
new
ArrayList
<>();
return
new
ResponseEntity
<>(
empList
,
HttpStatus
.
OK
);
List
<
Object
>
nonBillableCount
=
new
ArrayList
<>();
}
billableData
.
put
(
"name"
,
"Billable"
);
nonBillableData
.
put
(
"name"
,
"Non Billable"
);
@RequestMapping
(
value
=
"/billabilityByFunctionalGroup"
,
for
(
String
functionalGroup:
reportVo
.
getCategoriesList
()){
method
=
RequestMethod
.
GET
,
Map
<
String
,
Object
>
billableObj
=
new
HashMap
();
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
Map
<
String
,
Object
>
nonbillableObj
=
new
HashMap
();
public
ReportVo
billabilityReportByFunctionalGroup
(){
Integer
billableC
=
0
;
Integer
nonBillableC
=
0
;
ReportVo
reportVo
=
new
ReportVo
();
float
billper
;
Map
<
String
,
Object
>
billableData
=
new
HashMap
();
float
nonBillPer
;
Map
<
String
,
Object
>
nonBillableData
=
new
HashMap
();
List
<
Employee
>
employeeList
=
employeeService
.
getAllEmployees
().
stream
().
List
<
Object
>
billableCount
=
new
ArrayList
<>();
filter
(
e
->
e
.
getFunctionalGroup
().
equals
(
functionalGroup
)).
collect
(
Collectors
.
toList
());
List
<
Object
>
nonBillableCount
=
new
ArrayList
<>();
for
(
Employee
employee:
employeeList
){
billableData
.
put
(
"name"
,
"Billable"
);
Resource
resource
=
resourceService
.
getLatestResourceByEmpId
(
employee
.
getEmployeeId
());
nonBillableData
.
put
(
"name"
,
"Non Billable"
);
if
(
resource
!=
null
&&
resource
.
getBillableStatus
().
equals
(
"Billable"
)){
for
(
String
functionalGroup:
reportVo
.
getCategoriesList
()){
billableC
++;
Map
<
String
,
Object
>
billableObj
=
new
HashMap
();
}
else
{
Map
<
String
,
Object
>
nonbillableObj
=
new
HashMap
();
nonBillableC
++;
Integer
billableC
=
0
;
}
Integer
nonBillableC
=
0
;
}
float
billper
;
billper
=
((
billableC
/
(
float
)
employeeList
.
size
())*
100
);
float
nonBillPer
;
nonBillPer
=
nonBillableC
/(
float
)
employeeList
.
size
()*
100
;
List
<
Employee
>
employeeList
=
employeeService
.
getAllEmployees
().
stream
().
billableObj
.
put
(
"percent"
,
billper
);
filter
(
e
->
e
.
getFunctionalGroup
().
equals
(
functionalGroup
)).
collect
(
Collectors
.
toList
());
billableObj
.
put
(
"y"
,
billableC
);
for
(
Employee
employee:
employeeList
){
nonbillableObj
.
put
(
"percent"
,
nonBillPer
);
Resource
resource
=
resourceService
.
getLatestResourceByEmpId
(
employee
.
getEmployeeId
());
nonbillableObj
.
put
(
"y"
,
nonBillableC
);
if
(
resource
!=
null
&&
resource
.
getBillableStatus
().
equals
(
"Billable"
)){
billableCount
.
add
(
billableObj
);
billableC
++;
nonBillableCount
.
add
(
nonbillableObj
);
}
else
{
}
nonBillableC
++;
billableData
.
put
(
"data"
,
billableCount
);
}
nonBillableData
.
put
(
"data"
,
nonBillableCount
);
}
reportVo
.
getSeriesDataList
().
add
(
billableData
);
billper
=
((
billableC
/
(
float
)
employeeList
.
size
())*
100
);
reportVo
.
getSeriesDataList
().
add
(
nonBillableData
);
nonBillPer
=
nonBillableC
/(
float
)
employeeList
.
size
()*
100
;
return
reportVo
;
billableObj
.
put
(
"percent"
,
billper
);
}
billableObj
.
put
(
"y"
,
billableC
);
nonbillableObj
.
put
(
"percent"
,
nonBillPer
);
nonbillableObj
.
put
(
"y"
,
nonBillableC
);
billableCount
.
add
(
billableObj
);
//Not Ok Response
nonBillableCount
.
add
(
nonbillableObj
);
@RequestMapping
(
value
=
"/getBillabilityDetailsByAccount"
,
}
method
=
RequestMethod
.
GET
,
billableData
.
put
(
"data"
,
billableCount
);
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
nonBillableData
.
put
(
"data"
,
nonBillableCount
);
public
ResponseEntity
<
ColumnChartData
>
getBillabilityDetailsByAccount
()
reportVo
.
getSeriesDataList
().
add
(
billableData
);
throws
MyTeamException
{
reportVo
.
getSeriesDataList
().
add
(
nonBillableData
);
return
reportVo
;
}
ProjectionOperation
projectToMatchModel
=
project
()
.
andExpression
(
"account"
).
as
(
"categories"
)
.
andExpression
(
"billableStatus"
).
as
(
"seriesName"
)
.
andExpression
(
"count"
).
as
(
"count"
);
//Not Ok Response
@RequestMapping
(
value
=
"/getBillabilityDetailsByAccount"
,
MatchOperation
matchStage
=
Aggregation
method
=
RequestMethod
.
GET
,
.
match
(
new
Criteria
(
"active"
).
is
(
true
));
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
Aggregation
aggregate
=
Aggregation
.
newAggregation
(
matchStage
,
public
ResponseEntity
<
ColumnChartData
>
getBillabilityDetailsByAccount
()
Aggregation
.
group
(
"account"
,
"billableStatus"
).
count
()
throws
MyTeamException
{
.
as
(
"count"
),
projectToMatchModel
);
ProjectionOperation
projectToMatchModel
=
project
()
.
andExpression
(
"account"
).
as
(
"categories"
)
// Convert the aggregation result into a List
.
andExpression
(
"billableStatus"
).
as
(
"seriesName"
)
AggregationResults
<
ColumnChartData
>
groupResults
=
mongoTemplate
.
aggregate
(
aggregate
,
Resource
.
class
,
.
andExpression
(
"count"
).
as
(
"count"
);
ColumnChartData
.
class
);
List
<
ColumnChartData
>
result
=
groupResults
.
getMappedResults
();
MatchOperation
matchStage
=
Aggregation
List
<
String
>
statusList
=
new
ArrayList
();
.
match
(
new
Criteria
(
"active"
).
is
(
true
));
statusList
.
add
(
"Billable"
);
Aggregation
aggregate
=
Aggregation
.
newAggregation
(
matchStage
,
statusList
.
add
(
"Shadow"
);
Aggregation
.
group
(
"account"
,
"billableStatus"
).
count
()
statusList
.
add
(
"Reserved"
);
.
as
(
"count"
),
statusList
.
add
(
"Non-Billable"
);
projectToMatchModel
);
List
<
String
>
catagories
=
new
ArrayList
();
List
<
ReportSeriesRecord
>
seriesDetails
=
new
ArrayList
<
ReportSeriesRecord
>();
// Convert the aggregation result into a List
AggregationResults
<
ColumnChartData
>
groupResults
=
mongoTemplate
.
aggregate
(
aggregate
,
Resource
.
class
,
//List<Account> accounts = employeeService.getAccounts();
ColumnChartData
.
class
);
List
<
ColumnChartData
>
result
=
groupResults
.
getMappedResults
();
List
<
Account
>
accounts
=
accountService
.
getAllAccounts
();
List
<
String
>
statusList
=
new
ArrayList
();
statusList
.
add
(
"Billable"
);
statusList
.
add
(
"Shadow"
);
ColumnChartData
reportData
=
new
ColumnChartData
();
statusList
.
add
(
"Reserved"
);
for
(
String
status
:
statusList
)
{
statusList
.
add
(
"Non-Billable"
);
catagories
=
new
ArrayList
();
List
<
String
>
catagories
=
new
ArrayList
();
long
seriesData
[]
=
new
long
[
accounts
.
size
()];
List
<
ReportSeriesRecord
>
seriesDetails
=
new
ArrayList
<
ReportSeriesRecord
>();
int
i
=
0
;
for
(
Account
acct
:
accounts
)
{
boolean
seriesDataExists
=
false
;
//List<Account> accounts = employeeService.getAccounts();
catagories
.
add
(
acct
.
getAccountName
());
for
(
ColumnChartData
columnChartData
:
result
)
{
List
<
Account
>
accounts
=
accountService
.
getAllAccounts
();
if
(
columnChartData
.
getCategories
()
!=
null
&&
columnChartData
.
getSeriesName
()
!=
null
&
columnChartData
.
getCategories
()
ColumnChartData
reportData
=
new
ColumnChartData
();
.
equalsIgnoreCase
(
for
(
String
status
:
statusList
)
{
acct
.
getAccountName
())
catagories
=
new
ArrayList
();
&&
columnChartData
.
getSeriesName
()
long
seriesData
[]
=
new
long
[
accounts
.
size
()];
.
equalsIgnoreCase
(
status
))
{
int
i
=
0
;
seriesDataExists
=
true
;
for
(
Account
acct
:
accounts
)
{
seriesData
[
i
]
=
columnChartData
.
getCount
();
boolean
seriesDataExists
=
false
;
}
catagories
.
add
(
acct
.
getAccountName
());
}
for
(
ColumnChartData
columnChartData
:
result
)
{
if
(!
seriesDataExists
)
{
if
(
columnChartData
.
getCategories
()
!=
null
// seriesData[i] = 0;
&&
columnChartData
.
getSeriesName
()
!=
null
}
&
columnChartData
.
getCategories
()
i
++;
.
equalsIgnoreCase
(
}
acct
.
getAccountName
())
ReportSeriesRecord
reportSeriesRecord
=
new
ReportSeriesRecord
();
&&
columnChartData
.
getSeriesName
()
reportSeriesRecord
.
setName
(
status
);
.
equalsIgnoreCase
(
status
))
{
reportSeriesRecord
.
setData
(
seriesData
);
seriesDataExists
=
true
;
seriesDetails
.
add
(
reportSeriesRecord
);
seriesData
[
i
]
=
columnChartData
.
getCount
();
}
}
}
System
.
out
.
println
(
seriesDetails
);
if
(!
seriesDataExists
)
{
// seriesData[i] = 0;
}
reportData
.
setCategoriesList
(
catagories
);
i
++;
reportData
.
setSeriesDataList
(
seriesDetails
);
}
return
new
ResponseEntity
<>(
reportData
,
HttpStatus
.
OK
);
ReportSeriesRecord
reportSeriesRecord
=
new
ReportSeriesRecord
();
}
reportSeriesRecord
.
setName
(
status
);
reportSeriesRecord
.
setData
(
seriesData
);
seriesDetails
.
add
(
reportSeriesRecord
);
}
}
System
.
out
.
println
(
seriesDetails
);
reportData
.
setCategoriesList
(
catagories
);
reportData
.
setSeriesDataList
(
seriesDetails
);
return
new
ResponseEntity
<>(
reportData
,
HttpStatus
.
OK
);
}
}
src/main/java/com/nisum/myteam/model/BillableEmployee.java
0 → 100644
View file @
099feaf1
package
com
.
nisum
.
myteam
.
model
;
import
java.io.Serializable
;
import
java.util.Date
;
import
lombok.AllArgsConstructor
;
import
lombok.Getter
;
import
lombok.NoArgsConstructor
;
import
lombok.Setter
;
import
lombok.ToString
;
@Setter
@Getter
@AllArgsConstructor
@NoArgsConstructor
@ToString
public
class
BillableEmployee
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
private
String
employeeId
;
private
String
employeeName
;
private
String
emailId
;
private
String
projectName
;
private
String
billableStatus
;
private
Date
billingStartDate
;
private
Date
billingEndDate
;
private
String
functionalGroup
;
}
src/main/java/com/nisum/myteam/service/IEmployeeService.java
View file @
099feaf1
package
com
.
nisum
.
myteam
.
service
;
package
com
.
nisum
.
myteam
.
service
;
import
com.nisum.myteam.exception.handler.MyTeamException
;
import
com.nisum.myteam.exception.handler.MyTeamException
;
import
com.nisum.myteam.model.dao.Account
;
import
com.nisum.myteam.model.BillableEmployee
;
import
com.nisum.myteam.model.dao.Employee
;
import
com.nisum.myteam.model.dao.Account
;
import
org.springframework.stereotype.Service
;
import
com.nisum.myteam.model.dao.Employee
;
import
org.springframework.stereotype.Service
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.HashMap
;
import
java.util.Set
;
import
java.util.List
;
import
java.util.Set
;
@Service
public
interface
IEmployeeService
{
@Service
public
interface
IEmployeeService
{
boolean
isEmployeeExistsById
(
String
employeeId
);
boolean
isEmployeeExistsById
(
String
employeeId
);
Employee
createEmployee
(
Employee
employeeRoles
,
String
empId
)
throws
MyTeamException
;
Employee
createEmployee
(
Employee
employeeRoles
,
String
empId
)
throws
MyTeamException
;
Employee
updateEmployee
(
Employee
employeeRoles
,
String
empId
);
Employee
updateEmployee
(
Employee
employeeRoles
,
String
empId
);
Employee
deleteEmployee
(
String
empId
);
Employee
deleteEmployee
(
String
empId
);
Employee
updateProfile
(
Employee
employeeRoles
)
throws
MyTeamException
;
Employee
updateProfile
(
Employee
employeeRoles
)
throws
MyTeamException
;
Employee
getEmployeeById
(
String
empId
);
Employee
getEmployeeById
(
String
empId
);
Employee
getEmployeeByEmaillId
(
String
emailId
);
Employee
getEmployeeByEmaillId
(
String
emailId
);
List
<
Employee
>
getManagers
()
throws
MyTeamException
;
List
<
Employee
>
getManagers
()
throws
MyTeamException
;
List
<
Employee
>
getActiveEmployees
()
throws
MyTeamException
;
List
<
Employee
>
getActiveEmployees
()
throws
MyTeamException
;
List
<
Employee
>
getEmployeesByStatus
(
String
status
);
List
<
Employee
>
getEmployeesByStatus
(
String
status
);
List
<
Account
>
getAccounts
()
throws
MyTeamException
;
List
<
Account
>
getAccounts
()
throws
MyTeamException
;
Employee
getEmployeeRoleDataForSearchCriteria
(
String
searchId
,
String
searchAttribute
);
Employee
getEmployeeRoleDataForSearchCriteria
(
String
searchId
,
String
searchAttribute
);
List
<
String
>
getEmployeeDetailsForAutocomplete
();
List
<
String
>
getEmployeeDetailsForAutocomplete
();
List
<
HashMap
<
String
,
String
>>
getDeliveryLeads
(
String
domainId
);
List
<
HashMap
<
String
,
String
>>
getDeliveryLeads
(
String
domainId
);
List
<
Employee
>
getEmployeesByFunctionalGrp
(
String
functionalGrp
);
List
<
Employee
>
getEmployeesByFunctionalGrp
(
String
functionalGrp
);
boolean
verifyEmployeeRole
(
String
empId
,
String
roleName
);
boolean
verifyEmployeeRole
(
String
empId
,
String
roleName
);
List
<
Employee
>
getEmployeesFromList
(
Set
<
String
>
empIdsSet
);
List
<
Employee
>
getEmployeesFromList
(
Set
<
String
>
empIdsSet
);
List
<
HashMap
<
String
,
String
>>
getDeliveryManagerMap
(
List
deliveryManagerIdsList
);
List
<
HashMap
<
String
,
String
>>
getDeliveryManagerMap
(
List
deliveryManagerIdsList
);
public
List
<
Employee
>
getAllEmployees
();
public
List
<
Employee
>
getAllEmployees
();
public
List
<
Employee
>
getEmployeesByEmpStatusAndShift
(
String
empStatus
,
String
shift
);
public
List
<
Employee
>
getEmployeesByEmpStatusAndShift
(
String
empStatus
,
String
shift
);
}
List
<
BillableEmployee
>
getEmployeeDetailsByFGAndBillability
(
String
fGroup
,
String
billableStatus
);
}
src/main/java/com/nisum/myteam/service/IResourceService.java
View file @
099feaf1
package
com
.
nisum
.
myteam
.
service
;
package
com
.
nisum
.
myteam
.
service
;
import
com.nisum.myteam.exception.handler.MyTeamException
;
import
com.nisum.myteam.exception.handler.MyTeamException
;
import
com.nisum.myteam.model.dao.Employee
;
import
com.nisum.myteam.model.dao.Employee
;
import
com.nisum.myteam.model.dao.Resource
;
import
com.nisum.myteam.model.dao.Resource
;
import
com.nisum.myteam.model.vo.EmployeeShiftsVO
;
import
com.nisum.myteam.model.vo.EmployeeShiftsVO
;
import
com.nisum.myteam.model.vo.MyProjectAllocationVO
;
import
com.nisum.myteam.model.vo.MyProjectAllocationVO
;
import
com.nisum.myteam.model.vo.ReserveReportsVO
;
import
com.nisum.myteam.model.vo.ReserveReportsVO
;
import
com.nisum.myteam.model.vo.ResourceVO
;
import
com.nisum.myteam.model.vo.ResourceVO
;
import
java.util.Date
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.List
;
public
interface
IResourceService
{
public
interface
IResourceService
{
Resource
addResource
(
Resource
resourceAllocation
,
String
loginEmpId
)
throws
MyTeamException
;
Resource
addResource
(
Resource
resourceAllocation
,
String
loginEmpId
)
throws
MyTeamException
;
public
void
updateExistedResource
(
Resource
resourceAlloc
)
throws
MyTeamException
;
public
void
updateExistedResource
(
Resource
resourceAlloc
)
throws
MyTeamException
;
public
void
insertNewResourceWithNewStatus
(
Resource
resourceAllocReq
,
String
loginEmpId
)
throws
MyTeamException
;
public
void
insertNewResourceWithNewStatus
(
Resource
resourceAllocReq
,
String
loginEmpId
)
throws
MyTeamException
;
void
deleteResource
(
Resource
resource
,
String
loginEmpId
);
void
deleteResource
(
Resource
resource
,
String
loginEmpId
);
List
<
Resource
>
getAllResourcesForAllActiveProjects
();
List
<
Resource
>
getAllResourcesForAllActiveProjects
();
List
<
Resource
>
getResourcesSortByBillingStartDate
(
String
employeeId
);
List
<
Resource
>
getResourcesSortByBillingStartDate
(
String
employeeId
);
List
<
ResourceVO
>
getActiveResources
(
String
empId
);
List
<
ResourceVO
>
getActiveResources
(
String
empId
);
public
List
<
ResourceVO
>
getResourcesForProject
(
String
projectId
,
String
statusFlag
);
public
List
<
ResourceVO
>
getResourcesForProject
(
String
projectId
,
String
statusFlag
);
public
List
<
Resource
>
getResourcesUnderDeliveryLead
(
String
empId
);
public
List
<
Resource
>
getResourcesUnderDeliveryLead
(
String
empId
);
public
List
<
ResourceVO
>
getBillingsForEmployee
(
String
empId
);
public
List
<
ResourceVO
>
getBillingsForEmployee
(
String
empId
);
public
List
<
Resource
>
getBillingsForProject
(
String
empId
,
String
projectId
);
public
List
<
Resource
>
getBillingsForProject
(
String
empId
,
String
projectId
);
public
List
<
MyProjectAllocationVO
>
getWorkedProjectsForResource
(
String
empId
);
public
List
<
MyProjectAllocationVO
>
getWorkedProjectsForResource
(
String
empId
);
public
List
<
Employee
>
getUnAssignedEmployees
();
public
List
<
Employee
>
getUnAssignedEmployees
();
public
List
<
Resource
>
getAllResources
();
public
List
<
Resource
>
getAllResources
();
public
List
<
ResourceVO
>
getAllResourcesVO
();
public
List
<
ResourceVO
>
getAllResourcesVO
();
public
void
deleteResourcesUnderProject
(
String
projectId
);
public
void
deleteResourcesUnderProject
(
String
projectId
);
public
Resource
addResourceToBenchProject
(
Employee
employee
,
String
loginEmpId
)
throws
MyTeamException
;
public
Resource
addResourceToBenchProject
(
Employee
employee
,
String
loginEmpId
)
throws
MyTeamException
;
public
List
<
EmployeeShiftsVO
>
getResourcesForShift
(
String
shift
);
public
List
<
EmployeeShiftsVO
>
getResourcesForShift
(
String
shift
);
public
Resource
getLatestResourceByEmpId
(
String
employeeId
);
public
Resource
getLatestResourceByEmpId
(
String
employeeId
);
public
List
<
Resource
>
getResourcesByBillingStatus
(
String
resourceStatus
);
public
List
<
Resource
>
getResourcesByBillingStatus
(
String
resourceStatus
);
public
List
<
ReserveReportsVO
>
prepareReserveReports
(
List
<
Resource
>
resourcesList
);
public
List
<
ReserveReportsVO
>
prepareReserveReports
(
List
<
Resource
>
resourcesList
);
public
List
<
ReserveReportsVO
>
getResourceReportsByBillingStatus
(
String
resourceStatus
);
public
List
<
ReserveReportsVO
>
getResourceReportsByBillingStatus
(
String
resourceStatus
);
List
<
Resource
>
findByBillableStatus
(
String
billableStatus
);
// List<Resource> getAllResourcesForProject(String projectId, String status);
// List<Resource> getResourcesForEmployee(String empId);
// List<Resource> getAllResourcesForProject(String projectId, String status);
// List<Resource> getAllResourcesForProject(String projectId);
// List<Resource> getResourcesForEmployee(String empId);
// Resource save(Resource resource);
// List<Resource> getAllResourcesForProject(String projectId);
// void addResources(Employee employee, String loginEmpId);
// Resource save(Resource resource);
// void inactivateResource(Employee employeeReq, Employee employeeUpdated, String loginEmpId);
// void addResources(Employee employee, String loginEmpId);
}
// void inactivateResource(Employee employeeReq, Employee employeeUpdated, String loginEmpId);
}
src/main/java/com/nisum/myteam/service/impl/EmployeeService.java
View file @
099feaf1
package
com
.
nisum
.
myteam
.
service
.
impl
;
package
com
.
nisum
.
myteam
.
service
.
impl
;
import
com.nisum.myteam.exception.handler.MyTeamException
;
import
java.util.ArrayList
;
import
com.nisum.myteam.model.dao.Account
;
import
java.util.Comparator
;
import
com.nisum.myteam.model.dao.Domain
;
import
java.util.Date
;
import
com.nisum.myteam.model.dao.Employee
;
import
java.util.HashMap
;
import
com.nisum.myteam.repository.EmployeeRepo
;
import
java.util.List
;
import
com.nisum.myteam.service.*
;
import
java.util.Set
;
import
com.nisum.myteam.utils.MyTeamUtils
;
import
java.util.stream.Collectors
;
import
com.nisum.myteam.utils.constants.ApplicationRole
;
import
com.nisum.myteam.utils.constants.RoleConstant
;
import
org.apache.commons.lang.StringUtils
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.apache.commons.lang.StringUtils
;
import
org.springframework.data.domain.Sort
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.mongodb.core.FindAndModifyOptions
;
import
org.springframework.data.domain.Sort
;
import
org.springframework.data.mongodb.core.MongoTemplate
;
import
org.springframework.data.mongodb.core.FindAndModifyOptions
;
import
org.springframework.data.mongodb.core.query.Criteria
;
import
org.springframework.data.mongodb.core.MongoTemplate
;
import
org.springframework.data.mongodb.core.query.Query
;
import
org.springframework.data.mongodb.core.query.Criteria
;
import
org.springframework.data.mongodb.core.query.Update
;
import
org.springframework.data.mongodb.core.query.Query
;
import
org.springframework.stereotype.Service
;
import
org.springframework.data.mongodb.core.query.Update
;
import
org.springframework.stereotype.Service
;
import
com.nisum.myteam.exception.handler.MyTeamException
;
import
com.nisum.myteam.model.BillableEmployee
;
import
java.util.*
;
import
com.nisum.myteam.model.dao.Account
;
import
java.util.stream.Collectors
;
import
com.nisum.myteam.model.dao.Domain
;
import
com.nisum.myteam.model.dao.Employee
;
@Service
import
com.nisum.myteam.model.dao.Project
;
@Slf4j
import
com.nisum.myteam.model.dao.Resource
;
public
class
EmployeeService
implements
IEmployeeService
{
import
com.nisum.myteam.repository.EmployeeRepo
;
import
com.nisum.myteam.service.IAccountService
;
import
com.nisum.myteam.service.IDomainService
;
@Autowired
import
com.nisum.myteam.service.IEmployeeLocationService
;
private
EmployeeRepo
employeeRepo
;
import
com.nisum.myteam.service.IEmployeeRoleService
;
import
com.nisum.myteam.service.IEmployeeService
;
@Autowired
import
com.nisum.myteam.service.IProjectService
;
private
MongoTemplate
mongoTemplate
;
import
com.nisum.myteam.service.IResourceService
;
import
com.nisum.myteam.statuscodes.ResourceStatus
;
@Autowired
import
com.nisum.myteam.utils.MyTeamUtils
;
private
IAccountService
accountService
;
import
com.nisum.myteam.utils.constants.ApplicationRole
;
import
com.nisum.myteam.utils.constants.RoleConstant
;
@Autowired
private
IProjectService
projectService
;
import
lombok.extern.slf4j.Slf4j
;
@Autowired
@Service
private
IDomainService
domainService
;
@Slf4j
public
class
EmployeeService
implements
IEmployeeService
{
@Autowired
private
IEmployeeRoleService
employeeRoleService
;
@Autowired
@Autowired
private
EmployeeRepo
employeeRepo
;
private
IEmployeeLocationService
empLocationService
;
@Autowired
@Autowired
private
MongoTemplate
mongoTemplate
;
private
IResourceService
resourceService
;
@Autowired
@Override
private
IAccountService
accountService
;
public
Employee
createEmployee
(
Employee
employee
,
String
loginEmpId
)
throws
MyTeamException
{
employee
.
setCreatedOn
(
new
Date
());
@Autowired
employee
.
setCreatedBy
(
loginEmpId
);
private
IProjectService
projectService
;
employee
.
setModifiedBy
(
loginEmpId
);
@Autowired
// adding employee to Bench Allocation
private
IDomainService
domainService
;
resourceService
.
addResourceToBenchProject
(
employee
,
loginEmpId
);
@Autowired
// Saving employee Location Details.
private
IEmployeeRoleService
employeeRoleService
;
empLocationService
.
save
(
employee
);
@Autowired
return
employeeRepo
.
save
(
employee
);
private
IEmployeeLocationService
empLocationService
;
}
@Autowired
@Override
private
IResourceService
resourceService
;
public
Employee
updateEmployee
(
Employee
employeeReq
,
String
loginEmpId
)
{
// update all emp details to inactive if employee is inactive
@Override
Query
query
=
new
Query
(
Criteria
.
where
(
"employeeId"
).
is
(
employeeReq
.
getEmployeeId
()));
public
Employee
createEmployee
(
Employee
employee
,
String
loginEmpId
)
throws
MyTeamException
{
Update
update
=
new
Update
();
employee
.
setCreatedOn
(
new
Date
());
update
.
set
(
"employeeName"
,
employeeReq
.
getEmployeeName
());
employee
.
setCreatedBy
(
loginEmpId
);
update
.
set
(
"emailId"
,
employeeReq
.
getEmailId
());
employee
.
setModifiedBy
(
loginEmpId
);
update
.
set
(
"role"
,
employeeReq
.
getRole
());
update
.
set
(
"gender"
,
employeeReq
.
getGender
());
// adding employee to Bench Allocation
update
.
set
(
"functionalGroup"
,
employeeReq
.
getFunctionalGroup
());
resourceService
.
addResourceToBenchProject
(
employee
,
loginEmpId
);
update
.
set
(
"empStatus"
,
employeeReq
.
getEmpStatus
());
update
.
set
(
"empSubStatus"
,
employeeReq
.
getEmpSubStatus
());
// Saving employee Location Details.
update
.
set
(
"employmentType"
,
employeeReq
.
getEmploymentType
());
empLocationService
.
save
(
employee
);
update
.
set
(
"empLocation"
,
employeeReq
.
getEmpLocation
());
// update.set("domain", employeeReq.getDomain());
return
employeeRepo
.
save
(
employee
);
update
.
set
(
"designation"
,
employeeReq
.
getDesignation
());
}
update
.
set
(
"dateOfBirth"
,
employeeReq
.
getDateOfBirth
());
update
.
set
(
"dateOfJoining"
,
employeeReq
.
getDateOfJoining
());
@Override
update
.
set
(
"lastModifiedOn"
,
new
Date
());
public
Employee
updateEmployee
(
Employee
employeeReq
,
String
loginEmpId
)
{
update
.
set
(
"hasPassort"
,
employeeReq
.
getHasPassort
());
// update all emp details to inactive if employee is inactive
update
.
set
(
"hasB1"
,
employeeReq
.
getHasB1
());
Query
query
=
new
Query
(
Criteria
.
where
(
"employeeId"
).
is
(
employeeReq
.
getEmployeeId
()));
update
.
set
(
"passportExpiryDate"
,
employeeReq
.
getPassportExpiryDate
());
Update
update
=
new
Update
();
update
.
set
(
"b1ExpiryDate"
,
employeeReq
.
getB1ExpiryDate
());
update
.
set
(
"employeeName"
,
employeeReq
.
getEmployeeName
());
update
.
set
(
"emailId"
,
employeeReq
.
getEmailId
());
update
.
set
(
"modifiedBy"
,
loginEmpId
);
update
.
set
(
"role"
,
employeeReq
.
getRole
());
update
.
set
(
"gender"
,
employeeReq
.
getGender
());
if
(
employeeReq
.
getEmpStatus
().
equalsIgnoreCase
(
MyTeamUtils
.
IN_ACTIVE_SPACE
))
{
update
.
set
(
"functionalGroup"
,
employeeReq
.
getFunctionalGroup
());
update
.
set
(
"endDate"
,
employeeReq
.
getEndDate
());
update
.
set
(
"empStatus"
,
employeeReq
.
getEmpStatus
());
update
.
set
(
"empSubStatus"
,
null
);
update
.
set
(
"empSubStatus"
,
employeeReq
.
getEmpSubStatus
());
update
.
set
(
"employmentType"
,
employeeReq
.
getEmploymentType
());
}
update
.
set
(
"empLocation"
,
employeeReq
.
getEmpLocation
());
// update employee location
// update.set("domain", employeeReq.getDomain());
if
(
employeeReq
.
getEmpLocation
()
!=
null
&&
!
employeeReq
.
getEmpLocation
().
equals
(
""
))
{
update
.
set
(
"designation"
,
employeeReq
.
getDesignation
());
Employee
existingEmployee
=
employeeRepo
.
findByEmployeeId
(
employeeReq
.
getEmployeeId
());
update
.
set
(
"dateOfBirth"
,
employeeReq
.
getDateOfBirth
());
if
(!
existingEmployee
.
getEmpLocation
().
equals
(
employeeReq
.
getEmpLocation
()))
{
update
.
set
(
"dateOfJoining"
,
employeeReq
.
getDateOfJoining
());
empLocationService
.
update
(
employeeReq
,
false
);
update
.
set
(
"lastModifiedOn"
,
new
Date
());
}
update
.
set
(
"hasPassort"
,
employeeReq
.
getHasPassort
());
update
.
set
(
"hasB1"
,
employeeReq
.
getHasB1
());
}
update
.
set
(
"passportExpiryDate"
,
employeeReq
.
getPassportExpiryDate
());
update
.
set
(
"b1ExpiryDate"
,
employeeReq
.
getB1ExpiryDate
());
// update employee details
FindAndModifyOptions
options
=
new
FindAndModifyOptions
();
update
.
set
(
"modifiedBy"
,
loginEmpId
);
options
.
returnNew
(
true
);
options
.
upsert
(
true
);
if
(
employeeReq
.
getEmpStatus
().
equalsIgnoreCase
(
MyTeamUtils
.
IN_ACTIVE_SPACE
))
{
Employee
employeeUpdated
=
mongoTemplate
.
findAndModify
(
query
,
update
,
options
,
Employee
.
class
);
update
.
set
(
"endDate"
,
employeeReq
.
getEndDate
());
update
.
set
(
"empSubStatus"
,
null
);
try
{
// add to resource collection
}
//resourceService.addResources(employeeUpdated, loginEmpId);
// update employee location
if
(
employeeReq
.
getEmpLocation
()
!=
null
&&
!
employeeReq
.
getEmpLocation
().
equals
(
""
))
{
// inactive the employee from the assigned project.
Employee
existingEmployee
=
employeeRepo
.
findByEmployeeId
(
employeeReq
.
getEmployeeId
());
//resourceService.inactivateResource(employeeReq, employeeUpdated, loginEmpId);
if
(!
existingEmployee
.
getEmpLocation
().
equals
(
employeeReq
.
getEmpLocation
()))
{
empLocationService
.
update
(
employeeReq
,
false
);
}
catch
(
Exception
e
)
{
}
}
return
employeeUpdated
;
}
}
// update employee details
@Override
FindAndModifyOptions
options
=
new
FindAndModifyOptions
();
public
Employee
deleteEmployee
(
String
employeeId
)
{
options
.
returnNew
(
true
);
Query
query
=
new
Query
();
options
.
upsert
(
true
);
query
.
addCriteria
(
Criteria
.
where
(
"employeeId"
).
is
(
employeeId
));
Employee
employeeUpdated
=
mongoTemplate
.
findAndModify
(
query
,
update
,
options
,
Employee
.
class
);
Update
update
=
new
Update
();
update
.
set
(
"empStatus"
,
"InActive"
);
try
{
Employee
employeeUpdated
=
mongoTemplate
.
findAndModify
(
query
,
update
,
Employee
.
class
);
// add to resource collection
log
.
info
(
"The Deletion operation Result::"
+
employeeUpdated
);
//resourceService.addResources(employeeUpdated, loginEmpId);
return
employeeUpdated
;
}
// inactive the employee from the assigned project.
//resourceService.inactivateResource(employeeReq, employeeUpdated, loginEmpId);
@Override
public
Employee
updateProfile
(
Employee
employeeReq
)
throws
MyTeamException
{
}
catch
(
Exception
e
)
{
boolean
mobileNumberChanged
=
false
;
}
employeeReq
.
setLastModifiedOn
(
new
Date
());
return
employeeUpdated
;
Employee
existingEmployee
=
employeeRepo
.
findByEmployeeId
(
employeeReq
.
getEmployeeId
());
}
String
newMobileNumber
=
employeeReq
.
getMobileNumber
();
if
(
newMobileNumber
!=
null
&&
!
newMobileNumber
.
equalsIgnoreCase
(
""
))
{
@Override
if
((
existingEmployee
!=
null
&&
existingEmployee
.
getMobileNumber
()
!=
null
public
Employee
deleteEmployee
(
String
employeeId
)
{
&&
!
existingEmployee
.
getMobileNumber
().
equalsIgnoreCase
(
newMobileNumber
))
Query
query
=
new
Query
();
||
(
existingEmployee
.
getMobileNumber
()
==
null
))
{
query
.
addCriteria
(
Criteria
.
where
(
"employeeId"
).
is
(
employeeId
));
mobileNumberChanged
=
true
;
Update
update
=
new
Update
();
}
update
.
set
(
"empStatus"
,
"InActive"
);
}
Employee
employeeUpdated
=
mongoTemplate
.
findAndModify
(
query
,
update
,
Employee
.
class
);
existingEmployee
.
setMobileNumber
(
employeeReq
.
getMobileNumber
());
log
.
info
(
"The Deletion operation Result::"
+
employeeUpdated
);
existingEmployee
.
setAlternateMobileNumber
(
employeeReq
.
getAlternateMobileNumber
());
return
employeeUpdated
;
existingEmployee
.
setPersonalEmailId
(
employeeReq
.
getPersonalEmailId
());
}
existingEmployee
.
setBaseTechnology
(
employeeReq
.
getBaseTechnology
());
existingEmployee
.
setTechnologyKnown
(
employeeReq
.
getTechnologyKnown
());
@Override
Employee
employeePersisted
=
employeeRepo
.
save
(
existingEmployee
);
public
Employee
updateProfile
(
Employee
employeeReq
)
throws
MyTeamException
{
return
employeePersisted
;
boolean
mobileNumberChanged
=
false
;
employeeReq
.
setLastModifiedOn
(
new
Date
());
}
Employee
existingEmployee
=
employeeRepo
.
findByEmployeeId
(
employeeReq
.
getEmployeeId
());
String
newMobileNumber
=
employeeReq
.
getMobileNumber
();
public
boolean
isEmployeeExistsById
(
String
employeeId
)
{
if
(
newMobileNumber
!=
null
&&
!
newMobileNumber
.
equalsIgnoreCase
(
""
))
{
Employee
employeeFound
=
getEmployeeById
(
employeeId
);
if
((
existingEmployee
!=
null
&&
existingEmployee
.
getMobileNumber
()
!=
null
return
(
employeeFound
==
null
)
?
false
:
true
;
&&
!
existingEmployee
.
getMobileNumber
().
equalsIgnoreCase
(
newMobileNumber
))
||
(
existingEmployee
.
getMobileNumber
()
==
null
))
{
}
mobileNumberChanged
=
true
;
}
@Override
}
public
Employee
getEmployeeById
(
String
employeeId
)
{
existingEmployee
.
setMobileNumber
(
employeeReq
.
getMobileNumber
());
log
.
info
(
"The employeeId::"
+
employeeId
);
existingEmployee
.
setAlternateMobileNumber
(
employeeReq
.
getAlternateMobileNumber
());
existingEmployee
.
setPersonalEmailId
(
employeeReq
.
getPersonalEmailId
());
Employee
employee
=
employeeRepo
.
findByEmployeeId
(
employeeId
);
existingEmployee
.
setBaseTechnology
(
employeeReq
.
getBaseTechnology
());
log
.
info
(
"Employee Found in Repo::"
+
employee
);
existingEmployee
.
setTechnologyKnown
(
employeeReq
.
getTechnologyKnown
());
return
employee
;
Employee
employeePersisted
=
employeeRepo
.
save
(
existingEmployee
);
}
return
employeePersisted
;
@Override
}
public
List
<
Employee
>
getAllEmployees
()
{
return
employeeRepo
.
findAll
();
public
boolean
isEmployeeExistsById
(
String
employeeId
)
{
}
Employee
employeeFound
=
getEmployeeById
(
employeeId
);
return
(
employeeFound
==
null
)
?
false
:
true
;
@Override
public
Employee
getEmployeeByEmaillId
(
String
emailId
)
{
}
return
employeeRepo
.
findByEmailId
(
emailId
);
}
@Override
public
Employee
getEmployeeById
(
String
employeeId
)
{
@Override
log
.
info
(
"The employeeId::"
+
employeeId
);
public
List
<
Employee
>
getEmployeesByEmpStatusAndShift
(
String
empStatus
,
String
shift
)
{
return
employeeRepo
.
findByEmpStatusAndShiftLikeOrderByEmployeeIdDesc
(
empStatus
,
shift
);
Employee
employee
=
employeeRepo
.
findByEmployeeId
(
employeeId
);
}
log
.
info
(
"Employee Found in Repo::"
+
employee
);
return
employee
;
public
List
<
Employee
>
getManagers
()
throws
MyTeamException
{
}
List
<
Employee
>
activeEmpsList
=
getActiveEmployees
();
List
<
Employee
>
managers
=
activeEmpsList
.
stream
()
@Override
.
filter
(
employee
->
(
RoleConstant
.
DIRECTOR
.
getRoleName
().
equalsIgnoreCase
(
employee
.
getRole
())
public
List
<
Employee
>
getAllEmployees
()
{
||
RoleConstant
.
DELIVERY_MANAGER
.
getRoleName
().
equalsIgnoreCase
(
employee
.
getRole
())
return
employeeRepo
.
findAll
();
||
RoleConstant
.
MANAGER
.
getRoleName
().
equalsIgnoreCase
(
employee
.
getRole
())
}
||
RoleConstant
.
HR_MANAGER
.
getRoleName
().
equalsIgnoreCase
(
employee
.
getRole
())
||
RoleConstant
.
LEAD
.
getRoleName
().
equalsIgnoreCase
(
employee
.
getRole
())))
@Override
.
sorted
(
Comparator
.
comparing
(
Employee:
:
getEmployeeName
)).
collect
(
Collectors
.
toList
());
public
Employee
getEmployeeByEmaillId
(
String
emailId
)
{
return
managers
;
return
employeeRepo
.
findByEmailId
(
emailId
);
}
}
@Override
@Override
public
List
<
Employee
>
getActiveEmployees
()
throws
MyTeamException
{
public
List
<
Employee
>
getEmployeesByEmpStatusAndShift
(
String
empStatus
,
String
shift
)
{
return
employeeRepo
.
findByEmpStatus
(
MyTeamUtils
.
ACTIVE
);
return
employeeRepo
.
findByEmpStatusAndShiftLikeOrderByEmployeeIdDesc
(
empStatus
,
shift
);
}
}
@Override
public
List
<
Employee
>
getManagers
()
throws
MyTeamException
{
public
List
<
Employee
>
getEmployeesByStatus
(
String
status
)
{
List
<
Employee
>
activeEmpsList
=
getActiveEmployees
();
if
(
status
.
equals
(
"all"
))
{
List
<
Employee
>
managers
=
activeEmpsList
.
stream
()
return
employeeRepo
.
findAll
(
new
Sort
(
Sort
.
Direction
.
ASC
,
"employeeName"
));
.
filter
(
employee
->
(
RoleConstant
.
DIRECTOR
.
getRoleName
().
equalsIgnoreCase
(
employee
.
getRole
())
}
else
if
(
status
.
equals
(
"Vacation"
))
{
||
RoleConstant
.
DELIVERY_MANAGER
.
getRoleName
().
equalsIgnoreCase
(
employee
.
getRole
())
Query
query
=
new
Query
();
||
RoleConstant
.
MANAGER
.
getRoleName
().
equalsIgnoreCase
(
employee
.
getRole
())
query
.
addCriteria
(
Criteria
.
where
(
"empSubStatus"
).
ne
(
"Resigned"
).
andOperator
(
Criteria
.
where
(
"empSubStatus"
).
ne
(
null
),
Criteria
.
where
(
"empSubStatus"
).
ne
(
""
)));
||
RoleConstant
.
HR_MANAGER
.
getRoleName
().
equalsIgnoreCase
(
employee
.
getRole
())
return
mongoTemplate
.
find
(
query
,
Employee
.
class
);
||
RoleConstant
.
LEAD
.
getRoleName
().
equalsIgnoreCase
(
employee
.
getRole
())))
}
else
if
(
status
.
equals
(
"Resigned"
))
{
.
sorted
(
Comparator
.
comparing
(
Employee:
:
getEmployeeName
)).
collect
(
Collectors
.
toList
());
return
employeeRepo
.
findByEmpSubStatusOrderByEmployeeNameAsc
(
"Resigned"
);
return
managers
;
}
else
{
}
return
employeeRepo
.
findByEmpStatus
(
status
);
}
@Override
}
public
List
<
Employee
>
getActiveEmployees
()
throws
MyTeamException
{
return
employeeRepo
.
findByEmpStatus
(
MyTeamUtils
.
ACTIVE
);
}
@Override
public
List
<
Account
>
getAccounts
()
throws
MyTeamException
{
@Override
return
accountService
.
getAllAccounts
();
public
List
<
Employee
>
getEmployeesByStatus
(
String
status
)
{
if
(
status
.
equals
(
"all"
))
{
}
return
employeeRepo
.
findAll
(
new
Sort
(
Sort
.
Direction
.
ASC
,
"employeeName"
));
}
else
if
(
status
.
equals
(
"Vacation"
))
{
@Override
Query
query
=
new
Query
();
public
Employee
getEmployeeRoleDataForSearchCriteria
(
String
searchId
,
String
searchAttribute
)
{
query
.
addCriteria
(
Criteria
.
where
(
"empSubStatus"
).
ne
(
"Resigned"
).
andOperator
(
Criteria
.
where
(
"empSubStatus"
).
ne
(
null
),
Criteria
.
where
(
"empSubStatus"
).
ne
(
""
)));
if
(
MyTeamUtils
.
EMPLOYEE_NAME
.
equals
(
searchAttribute
))
{
return
mongoTemplate
.
find
(
query
,
Employee
.
class
);
return
employeeRepo
.
findByEmployeeName
(
searchId
);
}
else
if
(
status
.
equals
(
"Resigned"
))
{
}
else
if
(
MyTeamUtils
.
EMAIL_ID
.
equals
(
searchAttribute
))
{
return
employeeRepo
.
findByEmpSubStatusOrderByEmployeeNameAsc
(
"Resigned"
);
return
employeeRepo
.
findByEmailId
(
searchId
);
}
else
{
}
return
employeeRepo
.
findByEmpStatus
(
status
);
return
null
;
}
}
}
@Override
@Override
public
List
<
String
>
getEmployeeDetailsForAutocomplete
()
{
public
List
<
Account
>
getAccounts
()
throws
MyTeamException
{
List
<
Employee
>
employeeList
=
employeeRepo
.
findAll
();
return
accountService
.
getAllAccounts
();
List
<
String
>
resultList
=
new
ArrayList
<>();
employeeList
.
stream
().
sorted
(
java
.
util
.
Comparator
.
comparing
(
Employee:
:
getEmployeeId
))
}
.
collect
(
Collectors
.
toList
()).
forEach
(
employee
->
{
resultList
.
add
(
employee
.
getEmployeeId
());
@Override
});
public
Employee
getEmployeeRoleDataForSearchCriteria
(
String
searchId
,
String
searchAttribute
)
{
employeeList
.
stream
().
sorted
(
java
.
util
.
Comparator
.
comparing
(
Employee:
:
getEmployeeName
))
if
(
MyTeamUtils
.
EMPLOYEE_NAME
.
equals
(
searchAttribute
))
{
.
collect
(
Collectors
.
toList
()).
forEach
(
employee
->
{
return
employeeRepo
.
findByEmployeeName
(
searchId
);
resultList
.
add
(
employee
.
getEmployeeName
());
}
else
if
(
MyTeamUtils
.
EMAIL_ID
.
equals
(
searchAttribute
))
{
});
return
employeeRepo
.
findByEmailId
(
searchId
);
employeeList
.
stream
().
sorted
(
java
.
util
.
Comparator
.
comparing
(
Employee:
:
getEmailId
)).
collect
(
Collectors
.
toList
())
}
.
forEach
(
employee
->
{
return
null
;
resultList
.
add
(
employee
.
getEmailId
());
});
}
return
resultList
;
}
@Override
public
List
<
String
>
getEmployeeDetailsForAutocomplete
()
{
@Override
List
<
Employee
>
employeeList
=
employeeRepo
.
findAll
();
public
List
<
HashMap
<
String
,
String
>>
getDeliveryLeads
(
String
domainId
)
{
List
<
String
>
resultList
=
new
ArrayList
<>();
Domain
domain
=
domainService
.
getDomainById
(
domainId
);
employeeList
.
stream
().
sorted
(
java
.
util
.
Comparator
.
comparing
(
Employee:
:
getEmployeeId
))
return
getDeliveryManagerMap
(
domain
.
getDeliveryManagers
());
.
collect
(
Collectors
.
toList
()).
forEach
(
employee
->
{
}
resultList
.
add
(
employee
.
getEmployeeId
());
});
@Override
employeeList
.
stream
().
sorted
(
java
.
util
.
Comparator
.
comparing
(
Employee:
:
getEmployeeName
))
public
List
<
HashMap
<
String
,
String
>>
getDeliveryManagerMap
(
List
deliveryManagerIdsList
)
{
.
collect
(
Collectors
.
toList
()).
forEach
(
employee
->
{
List
<
HashMap
<
String
,
String
>>
employeeList
=
new
ArrayList
<>();
resultList
.
add
(
employee
.
getEmployeeName
());
});
Query
query
=
new
Query
(
Criteria
.
where
(
"employeeId"
).
in
(
deliveryManagerIdsList
));
employeeList
.
stream
().
sorted
(
java
.
util
.
Comparator
.
comparing
(
Employee:
:
getEmailId
)).
collect
(
Collectors
.
toList
())
List
<
Employee
>
employeePersistedList
=
mongoTemplate
.
find
(
query
,
Employee
.
class
);
.
forEach
(
employee
->
{
for
(
Employee
employee
:
employeePersistedList
)
{
resultList
.
add
(
employee
.
getEmailId
());
HashMap
<
String
,
String
>
managerMap
=
new
HashMap
<>();
});
managerMap
.
put
(
"employeeId"
,
employee
.
getEmployeeId
());
return
resultList
;
managerMap
.
put
(
"employeeName"
,
employee
.
getEmployeeName
());
}
employeeList
.
add
(
managerMap
);
}
@Override
return
employeeList
;
public
List
<
HashMap
<
String
,
String
>>
getDeliveryLeads
(
String
domainId
)
{
}
Domain
domain
=
domainService
.
getDomainById
(
domainId
);
return
getDeliveryManagerMap
(
domain
.
getDeliveryManagers
());
}
@Override
public
List
<
Employee
>
getEmployeesByFunctionalGrp
(
String
functionalGrp
)
{
@Override
return
employeeRepo
.
findByEmpStatusAndFunctionalGroup
(
"Active"
,
functionalGrp
);
public
List
<
HashMap
<
String
,
String
>>
getDeliveryManagerMap
(
List
deliveryManagerIdsList
)
{
List
<
HashMap
<
String
,
String
>>
employeeList
=
new
ArrayList
<>();
}
Query
query
=
new
Query
(
Criteria
.
where
(
"employeeId"
).
in
(
deliveryManagerIdsList
));
@Override
List
<
Employee
>
employeePersistedList
=
mongoTemplate
.
find
(
query
,
Employee
.
class
);
public
boolean
verifyEmployeeRole
(
String
empId
,
String
roleIdReq
)
{
for
(
Employee
employee
:
employeePersistedList
)
{
boolean
flag
=
false
;
HashMap
<
String
,
String
>
managerMap
=
new
HashMap
<>();
managerMap
.
put
(
"employeeId"
,
employee
.
getEmployeeId
());
log
.
info
(
"The employeeId::"
+
empId
);
managerMap
.
put
(
"employeeName"
,
employee
.
getEmployeeName
());
employeeList
.
add
(
managerMap
);
Employee
employee
=
getEmployeeById
(
empId
);
}
log
.
info
(
"Employee::::in EmployeeService::"
+
employee
);
return
employeeList
;
}
String
roleName
=
employee
.
getRole
();
log
.
info
(
"The employee role::"
+
roleName
);
if
(
StringUtils
.
isNotBlank
(
roleName
)
&&
!
ApplicationRole
.
ADMIN
.
getRoleName
().
equalsIgnoreCase
(
roleName
))
{
@Override
public
List
<
Employee
>
getEmployeesByFunctionalGrp
(
String
functionalGrp
)
{
if
(
ApplicationRole
.
FUNCTIONAL_MANAGER
.
getRoleName
().
equalsIgnoreCase
(
roleName
)
||
return
employeeRepo
.
findByEmpStatusAndFunctionalGroup
(
"Active"
,
functionalGrp
);
ApplicationRole
.
DELIVERY_LEAD
.
getRoleName
().
equalsIgnoreCase
(
roleName
))
{
flag
=
true
;
}
log
.
info
(
"in if block"
);
}
else
{
@Override
log
.
info
(
"in else block"
);
public
boolean
verifyEmployeeRole
(
String
empId
,
String
roleIdReq
)
{
Set
<
String
>
roleSet
=
employeeRoleService
.
empRolesMapInfoByEmpId
(
empId
);
boolean
flag
=
false
;
if
(
null
!=
roleSet
&&
!
roleSet
.
isEmpty
()
&&
MyTeamUtils
.
INT_ZERO
<
roleSet
.
size
())
{
if
(
roleSet
.
contains
(
roleIdReq
))
{
log
.
info
(
"The employeeId::"
+
empId
);
flag
=
true
;
}
Employee
employee
=
getEmployeeById
(
empId
);
}
log
.
info
(
"Employee::::in EmployeeService::"
+
employee
);
}
String
roleName
=
employee
.
getRole
();
log
.
info
(
"The employee role::"
+
roleName
);
if
(
StringUtils
.
isNotBlank
(
roleName
)
&&
!
ApplicationRole
.
ADMIN
.
getRoleName
().
equalsIgnoreCase
(
roleName
))
{
}
log
.
info
(
"before return flag::"
+
flag
);
if
(
ApplicationRole
.
FUNCTIONAL_MANAGER
.
getRoleName
().
equalsIgnoreCase
(
roleName
)
||
return
flag
;
ApplicationRole
.
DELIVERY_LEAD
.
getRoleName
().
equalsIgnoreCase
(
roleName
))
{
}
flag
=
true
;
log
.
info
(
"in if block"
);
public
List
<
Employee
>
getEmployeesFromList
(
Set
<
String
>
empIdsSet
)
{
}
else
{
return
employeeRepo
.
findByEmployeeIdIn
(
empIdsSet
);
log
.
info
(
"in else block"
);
Set
<
String
>
roleSet
=
employeeRoleService
.
empRolesMapInfoByEmpId
(
empId
);
}
if
(
null
!=
roleSet
&&
!
roleSet
.
isEmpty
()
&&
MyTeamUtils
.
INT_ZERO
<
roleSet
.
size
())
{
if
(
roleSet
.
contains
(
roleIdReq
))
{
flag
=
true
;
}
}
}
}
}
log
.
info
(
"before return flag::"
+
flag
);
return
flag
;
}
public
List
<
Employee
>
getEmployeesFromList
(
Set
<
String
>
empIdsSet
)
{
return
employeeRepo
.
findByEmployeeIdIn
(
empIdsSet
);
}
@Override
public
List
<
BillableEmployee
>
getEmployeeDetailsByFGAndBillability
(
String
fGroup
,
String
billableStatus
)
{
List
<
Resource
>
resources
=
resourceService
.
findByBillableStatus
(
billableStatus
);
return
getBillableEmployeeByfunctionalGroup
(
fGroup
,
resources
);
}
private
List
<
BillableEmployee
>
getBillableEmployeeByfunctionalGroup
(
String
fGroup
,
List
<
Resource
>
resources
)
{
List
<
BillableEmployee
>
employeesForUI
=
new
ArrayList
<>();
List
<
Employee
>
employeeswithFG
=
employeeRepo
.
findByEmpStatusAndFunctionalGroup
(
ResourceStatus
.
ACTIVE
.
getStatus
(),
fGroup
);
for
(
Resource
resourceObj:
resources
)
{
Project
project
=
projectService
.
getProjectByProjectId
(
resourceObj
.
getProjectId
());
for
(
Employee
employee:
employeeswithFG
)
{
if
(
employee
.
getEmployeeId
().
equals
(
resourceObj
.
getEmployeeId
()))
{
BillableEmployee
billableEmployee
=
new
BillableEmployee
();
billableEmployee
.
setEmployeeId
(
resourceObj
.
getEmployeeId
());
billableEmployee
.
setEmployeeName
(
employee
.
getEmployeeName
());
billableEmployee
.
setEmailId
(
employee
.
getEmailId
());
billableEmployee
.
setProjectName
(
project
.
getProjectName
());
billableEmployee
.
setBillingStartDate
(
resourceObj
.
getBillingStartDate
());
billableEmployee
.
setBillableStatus
(
resourceObj
.
getBillableStatus
());
billableEmployee
.
setBillingEndDate
(
resourceObj
.
getBillingEndDate
());
billableEmployee
.
setFunctionalGroup
(
fGroup
);
employeesForUI
.
add
(
billableEmployee
);
}
}
}
return
employeesForUI
;
}
}
src/main/java/com/nisum/myteam/service/impl/ResourceService.java
View file @
099feaf1
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
>
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
);
}
}
if
(
resourceAllocList
.
isEmpty
()){
if
(
resourceAllocList
.
isEmpty
()){
List
<
Resource
>
resourceBenchList
=
resourceRepo
.
findByEmployeeIdAndProjectId
(
resourceReq
.
getEmployeeId
(),
MyTeamUtils
.
BENCH_PROJECT_ID
);
List
<
Resource
>
resourceBenchList
=
resourceRepo
.
findByEmployeeIdAndProjectId
(
resourceReq
.
getEmployeeId
(),
MyTeamUtils
.
BENCH_PROJECT_ID
);
if
(!
resourceBenchList
.
isEmpty
()){
if
(!
resourceBenchList
.
isEmpty
()){
Resource
resourceBench
=
resourceBenchList
.
get
(
0
);
Resource
resourceBench
=
resourceBenchList
.
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
);
}
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
());
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.
if
(!
resourcePrev
.
getProjectId
().
equalsIgnoreCase
(
MyTeamUtils
.
BENCH_PROJECT_ID
)
&&
!
resourceReq
.
getProjectId
().
equalsIgnoreCase
(
resourcePrev
.
getProjectId
()))
{
if
(!
resourcePrev
.
getProjectId
().
equalsIgnoreCase
(
MyTeamUtils
.
BENCH_PROJECT_ID
)
&&
!
resourceReq
.
getProjectId
().
equalsIgnoreCase
(
resourcePrev
.
getProjectId
()))
{
message
=
"Resource "
+
resourcePrev
.
getEmployeeId
()
+
" already Assigned to the "
message
=
"Resource "
+
resourcePrev
.
getEmployeeId
()
+
" already Assigned to the "
+
projectService
.
getProjectByProjectId
(
resourcePrev
.
getProjectId
()).
getProjectName
()
+
projectService
.
getProjectByProjectId
(
resourcePrev
.
getProjectId
()).
getProjectName
()
+
" Project"
+
" from "
+
resourcePrev
.
getBillingStartDate
()
+
"to "
+
resourcePrev
.
getBillingEndDate
();
+
" Project"
+
" from "
+
resourcePrev
.
getBillingStartDate
()
+
"to "
+
resourcePrev
.
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
){
List
<
Resource
>
resourceList
=
resourceRepo
.
findByEmployeeId
(
employeeId
).
stream
().
List
<
Resource
>
resourceList
=
resourceRepo
.
findByEmployeeId
(
employeeId
).
stream
().
filter
(
r
->
r
.
getBillingEndDate
().
after
(
new
Date
())).
collect
(
Collectors
.
toList
());
filter
(
r
->
r
.
getBillingEndDate
().
after
(
new
Date
())).
collect
(
Collectors
.
toList
());
if
(!
resourceList
.
isEmpty
())
if
(!
resourceList
.
isEmpty
())
return
resourceList
.
get
(
0
);
return
resourceList
.
get
(
0
);
else
else
return
null
;
return
null
;
}
}
@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
;
}
}
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
prepareAllocationResources
(
getResourcesBetweenBillingStartDates
(
fromDate
,
toDate
));
return
prepareAllocationResources
(
getResourcesBetweenBillingStartDates
(
fromDate
,
toDate
));
}
}
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
public
List
<
Resource
>
findByBillableStatus
(
String
billableStatus
)
{
}
//class
return
resourceRepo
.
findByBillableStatus
(
billableStatus
);
}
}
//class
// @Override
// public List<ResourceVO> getActiveResources(String empId) {
// List<ResourceVO> finalResourcesList = new ArrayList<>();
//
// List<Resource> resourceList = resourceRepo.findByEmployeeId(empId);
// @Override
// if (resourceList != null && resourceList.size() > 0) {
// public List<ResourceVO> getActiveResources(String empId) {
//
// List<ResourceVO> finalResourcesList = new ArrayList<>();
// Resource resourceAlloc=resourceList.get(0);
//
//
// List<Resource> resourceList = resourceRepo.findByEmployeeId(empId);
//
// if (resourceList != null && resourceList.size() > 0) {
//
//
//
// Resource resourceAlloc=resourceList.get(0);
// }
//
//
//
// for (Resource resource : resourceRepo.findByEmployeeId(empId)) {
//
//
//
// ResourceVO resourceVO=new ResourceVO();
// }
// resourceVO.setEmployeeId(resource.getEmployeeId());
//
//
// for (Resource resource : resourceRepo.findByEmployeeId(empId)) {
// Employee employee=employeeService.getEmployeeById(resource.getEmployeeId());
//
// resourceVO.setEmployeeName(employee.getEmployeeName());
// ResourceVO resourceVO=new ResourceVO();
// resourceVO.setDesignation(employee.getDesignation());
// resourceVO.setEmployeeId(resource.getEmployeeId());
// resourceVO.setEmailId(employee.getEmailId());
//
// resourceVO.setMobileNo(employee.getMobileNumber());
// Employee employee=employeeService.getEmployeeById(resource.getEmployeeId());
//
// resourceVO.setEmployeeName(employee.getEmployeeName());
// resourceVO.setProjectName(projectService.getProjectByProjectId(resource.getProjectId()).getProjectName());
// resourceVO.setDesignation(employee.getDesignation());
//
// resourceVO.setEmailId(employee.getEmailId());
//
// resourceVO.setMobileNo(employee.getMobileNumber());
// if (resource.getBillingEndDate().compareTo(new Date()) > 0) {
//
// finalResourcesList.addAll(getAllResourcesForProject(resource.getProjectId()));
// resourceVO.setProjectName(projectService.getProjectByProjectId(resource.getProjectId()).getProjectName());
// }
//
//
//
//
// if (resource.getBillingEndDate().compareTo(new Date()) > 0) {
// }
// finalResourcesList.addAll(getAllResourcesForProject(resource.getProjectId()));
// return finalResourcesList;
// }
// }
//
//
// }
// @Override
// return finalResourcesList;
// public List<ResourceVO> getActiveResources(String empId) {
// }
// List<ResourceVO> finalResourcesList = new ArrayList<>();
// Employee employee = null;
//
// @Override
// List<Resource> resourceList = resourceRepo.findByEmployeeId(empId);
// public List<ResourceVO> getActiveResources(String empId) {
// Optional<Resource> optionalResource = resourceList.stream().filter(resource -> resource.getBillingEndDate().compareTo(new Date()) > 0).findAny();
// List<ResourceVO> finalResourcesList = new ArrayList<>();
// if (optionalResource.isPresent()) {
// Employee employee = null;
// finalResourcesList = prepareProjectTeamMembersList(optionalResource.get().getProjectId());
//
// }
// List<Resource> resourceList = resourceRepo.findByEmployeeId(empId);
// return finalResourcesList;
// Optional<Resource> optionalResource = resourceList.stream().filter(resource -> resource.getBillingEndDate().compareTo(new Date()) > 0).findAny();
// if (optionalResource.isPresent()) {
// finalResourcesList = prepareProjectTeamMembersList(optionalResource.get().getProjectId());
// }
// return finalResourcesList;
// }
// }
\ No newline at end of file
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