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
2dae5af4
Commit
2dae5af4
authored
Jan 17, 2020
by
Md Suleman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Employee In active and utilization report enhancement changes
parent
926185b7
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
113 additions
and
269 deletions
+113
-269
EmployeeController.java
.../java/com/nisum/myteam/controller/EmployeeController.java
+12
-10
ReportsController.java
...n/java/com/nisum/myteam/controller/ReportsController.java
+34
-45
IReportService.java
src/main/java/com/nisum/myteam/service/IReportService.java
+5
-5
IResourceService.java
src/main/java/com/nisum/myteam/service/IResourceService.java
+2
-0
EmployeeService.java
...n/java/com/nisum/myteam/service/impl/EmployeeService.java
+19
-27
ReportService.java
...ain/java/com/nisum/myteam/service/impl/ReportService.java
+20
-60
ResourceService.java
...n/java/com/nisum/myteam/service/impl/ResourceService.java
+18
-119
MyTeamDateUtils.java
src/main/java/com/nisum/myteam/utils/MyTeamDateUtils.java
+3
-3
No files found.
src/main/java/com/nisum/myteam/controller/EmployeeController.java
View file @
2dae5af4
...
@@ -32,7 +32,6 @@ import com.nisum.myteam.exception.handler.ResponseDetails;
...
@@ -32,7 +32,6 @@ import com.nisum.myteam.exception.handler.ResponseDetails;
import
com.nisum.myteam.model.dao.Account
;
import
com.nisum.myteam.model.dao.Account
;
import
com.nisum.myteam.model.dao.Employee
;
import
com.nisum.myteam.model.dao.Employee
;
import
com.nisum.myteam.service.IEmployeeRoleService
;
import
com.nisum.myteam.service.IEmployeeRoleService
;
import
com.nisum.myteam.service.IEmployeeService
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
...
@@ -55,7 +54,8 @@ public class EmployeeController {
...
@@ -55,7 +54,8 @@ public class EmployeeController {
@RequestMapping
(
value
=
"/employees/{empId}"
,
method
=
RequestMethod
.
POST
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
,
consumes
=
MediaType
.
APPLICATION_JSON_VALUE
)
@RequestMapping
(
value
=
"/employees/{empId}"
,
method
=
RequestMethod
.
POST
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
,
consumes
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<?>
createEmployee
(
@RequestBody
Employee
employeeReq
,
public
ResponseEntity
<?>
createEmployee
(
@RequestBody
Employee
employeeReq
,
@PathVariable
(
value
=
"empId"
)
String
loginEmpId
,
HttpServletRequest
request
)
throws
MyTeamException
{
@PathVariable
(
value
=
"empId"
)
String
loginEmpId
,
HttpServletRequest
request
)
throws
MyTeamException
{
if
(
empService
.
isEmployeeExistsById
(
loginEmpId
))
{
if
(
empService
.
isEmployeeExistsById
(
loginEmpId
))
{
Employee
employeePersisted
=
empService
.
createEmployee
(
employeeReq
,
loginEmpId
);
Employee
employeePersisted
=
empService
.
createEmployee
(
employeeReq
,
loginEmpId
);
...
@@ -75,7 +75,8 @@ public class EmployeeController {
...
@@ -75,7 +75,8 @@ public class EmployeeController {
@RequestMapping
(
value
=
"/employees/{empId}"
,
method
=
RequestMethod
.
PUT
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
,
consumes
=
MediaType
.
APPLICATION_JSON_VALUE
)
@RequestMapping
(
value
=
"/employees/{empId}"
,
method
=
RequestMethod
.
PUT
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
,
consumes
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<?>
updateEmployee
(
@RequestBody
Employee
employeeReq
,
public
ResponseEntity
<?>
updateEmployee
(
@RequestBody
Employee
employeeReq
,
@PathVariable
(
value
=
"empId"
)
String
loginEmpId
,
HttpServletRequest
request
)
throws
MyTeamException
,
ParseException
{
@PathVariable
(
value
=
"empId"
)
String
loginEmpId
,
HttpServletRequest
request
)
throws
MyTeamException
,
ParseException
{
if
(
empService
.
isEmployeeExistsById
(
loginEmpId
))
{
if
(
empService
.
isEmployeeExistsById
(
loginEmpId
))
{
Employee
employeeUpdated
=
empService
.
updateEmployee
(
employeeReq
,
loginEmpId
);
Employee
employeeUpdated
=
empService
.
updateEmployee
(
employeeReq
,
loginEmpId
);
...
@@ -93,8 +94,8 @@ public class EmployeeController {
...
@@ -93,8 +94,8 @@ public class EmployeeController {
}
}
@RequestMapping
(
value
=
"/employees/{empId}"
,
method
=
RequestMethod
.
DELETE
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
@RequestMapping
(
value
=
"/employees/{empId}"
,
method
=
RequestMethod
.
DELETE
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<?>
deleteEmployee
(
@PathVariable
(
"empId"
)
String
empId
,
HttpServletRequest
request
)
public
ResponseEntity
<?>
deleteEmployee
(
@PathVariable
(
"empId"
)
String
empId
,
throws
MyTeamException
{
HttpServletRequest
request
)
{
if
(
empService
.
isEmployeeExistsById
(
empId
))
{
if
(
empService
.
isEmployeeExistsById
(
empId
))
{
...
@@ -117,7 +118,8 @@ public class EmployeeController {
...
@@ -117,7 +118,8 @@ public class EmployeeController {
@RequestMapping
(
value
=
"/employees/employeeId/{empId}"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
@RequestMapping
(
value
=
"/employees/employeeId/{empId}"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<?>
getEmployeeById
(
@PathVariable
(
"empId"
)
String
empId
,
HttpServletRequest
request
)
public
ResponseEntity
<?>
getEmployeeById
(
@PathVariable
(
"empId"
)
String
empId
,
HttpServletRequest
request
)
throws
MyTeamException
{
throws
MyTeamException
{
Employee
employee
=
empService
.
getEmployeeById
(
empId
);
Employee
employee
=
empService
.
getEmployeeById
(
empId
);
ResponseDetails
getRespDetails
=
new
ResponseDetails
(
new
Date
(),
904
,
"Retrieved Employee successfully"
,
ResponseDetails
getRespDetails
=
new
ResponseDetails
(
new
Date
(),
904
,
"Retrieved Employee successfully"
,
...
@@ -296,9 +298,9 @@ public class EmployeeController {
...
@@ -296,9 +298,9 @@ public class EmployeeController {
}
}
@RequestMapping
(
value
=
"/employeesBasedOnSubStatusForGivenDates"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
@RequestMapping
(
value
=
"/employeesBasedOnSubStatusForGivenDates"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<?>
employeesBasedOnSubStatusForGivenDates
(
@RequestParam
(
"fromDate"
)
@DateTimeFormat
(
iso
=
DateTimeFormat
.
ISO
.
DATE
)
Date
fromDate
,
public
ResponseEntity
<?>
employeesBasedOnSubStatusForGivenDates
(
@RequestParam
(
"fromDate"
)
@DateTimeFormat
(
iso
=
DateTimeFormat
.
ISO
.
DATE
)
Date
fromDate
,
@RequestParam
(
"toDate"
)
@DateTimeFormat
(
iso
=
DateTimeFormat
.
ISO
.
DATE
)
Date
toDate
,
@RequestParam
(
"toDate"
)
@DateTimeFormat
(
iso
=
DateTimeFormat
.
ISO
.
DATE
)
Date
toDate
,
@RequestParam
(
"subStatus"
)
String
subStatus
,
@RequestParam
(
"subStatus"
)
String
subStatus
,
HttpServletRequest
request
){
HttpServletRequest
request
){
List
<
EmployeeSubStatusVO
>
employees
=
subStatusService
.
employeesBasedOnSubStatusForGivenDates
(
fromDate
,
toDate
,
subStatus
);
List
<
EmployeeSubStatusVO
>
employees
=
subStatusService
.
employeesBasedOnSubStatusForGivenDates
(
fromDate
,
toDate
,
subStatus
);
...
...
src/main/java/com/nisum/myteam/controller/ReportsController.java
View file @
2dae5af4
package
com
.
nisum
.
myteam
.
controller
;
package
com
.
nisum
.
myteam
.
controller
;
import
static
org
.
springframework
.
data
.
mongodb
.
core
.
aggregation
.
Aggregation
.
group
;
import
com.nisum.myteam.exception.handler.MyTeamException
;
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.Reports
;
import
java.text.ParseException
;
import
com.nisum.myteam.model.dao.Account
;
import
java.text.SimpleDateFormat
;
import
com.nisum.myteam.model.dao.Employee
;
import
java.util.ArrayList
;
import
com.nisum.myteam.model.dao.Project
;
import
java.util.Calendar
;
import
com.nisum.myteam.model.dao.Resource
;
import
java.util.Date
;
import
com.nisum.myteam.model.vo.ReportVo
;
import
java.util.HashMap
;
import
com.nisum.myteam.service.IAccountService
;
import
java.util.List
;
import
com.nisum.myteam.service.IEmployeeService
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
import
com.nisum.myteam.service.IReportService
;
import
com.nisum.myteam.service.IReportService
;
import
com.nisum.myteam.service.IResourceService
;
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
;
...
@@ -26,6 +24,7 @@ import org.springframework.data.mongodb.core.aggregation.MatchOperation;
...
@@ -26,6 +24,7 @@ import org.springframework.data.mongodb.core.aggregation.MatchOperation;
import
org.springframework.data.mongodb.core.aggregation.ProjectionOperation
;
import
org.springframework.data.mongodb.core.aggregation.ProjectionOperation
;
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.format.annotation.DateTimeFormat
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.MediaType
;
import
org.springframework.http.MediaType
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.http.ResponseEntity
;
...
@@ -34,22 +33,11 @@ import org.springframework.web.bind.annotation.RequestMethod;
...
@@ -34,22 +33,11 @@ import org.springframework.web.bind.annotation.RequestMethod;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
import
com.nisum.myteam.exception.handler.MyTeamException
;
import
java.text.ParseException
;
import
com.nisum.myteam.model.Reports
;
import
java.text.SimpleDateFormat
;
import
com.nisum.myteam.model.ColumnChartData
;
import
java.util.*
;
import
com.nisum.myteam.model.GroupByCount
;
import
com.nisum.myteam.model.ReportSeriesRecord
;
import
com.nisum.myteam.model.dao.Account
;
import
com.nisum.myteam.model.dao.Employee
;
import
com.nisum.myteam.model.dao.Project
;
import
com.nisum.myteam.model.dao.Resource
;
import
com.nisum.myteam.model.vo.ReportVo
;
import
com.nisum.myteam.model.vo.ResourceVO
;
import
com.nisum.myteam.service.IAccountService
;
import
com.nisum.myteam.service.IEmployeeService
;
import
com.nisum.myteam.service.IResourceService
;
import
javax.ws.rs.QueryParam
;
import
static
org
.
springframework
.
data
.
mongodb
.
core
.
aggregation
.
Aggregation
.*
;
//import com.nisum.myteam.model.dao.Resource;
//import com.nisum.myteam.model.dao.Resource;
...
@@ -267,20 +255,23 @@ public class ReportsController {
...
@@ -267,20 +255,23 @@ public class ReportsController {
@RequestMapping
(
value
=
"/fetchEmployeeDetailsByFGAndBillability"
,
@RequestMapping
(
value
=
"/fetchEmployeeDetailsByFGAndBillability"
,
method
=
RequestMethod
.
GET
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
List
<
Reports
>>
getEmployeesByFGAndBillability
(
public
ResponseEntity
<
List
<
Reports
>>
getEmployeesByFGAndBillability
(
@RequestParam
(
"fGroup"
)
String
fGroup
,
@RequestParam
(
"fGroup"
)
String
fGroup
,
@RequestParam
(
"billableStatus"
)
String
billableStatus
)
throws
MyTeamException
{
@RequestParam
(
"billableStatus"
)
String
billableStatus
,
@RequestParam
(
"onDate"
)
@DateTimeFormat
(
iso
=
DateTimeFormat
.
ISO
.
DATE
)
Date
onDate
)
throws
MyTeamException
{
List
<
Reports
>
empList
=
null
;
List
<
Reports
>
empList
=
null
;
empList
=
reportService
.
getEmployeeDetailsByFGAndBillability
(
fGroup
,
billableStatus
);
empList
=
reportService
.
getEmployeeDetailsByFGAndBillability
(
fGroup
,
billableStatus
,
onDate
);
return
new
ResponseEntity
<>(
empList
,
HttpStatus
.
OK
);
return
new
ResponseEntity
<>(
empList
,
HttpStatus
.
OK
);
}
}
@RequestMapping
(
value
=
"/fetchEmployeeDetailsByFGAccountAndBillability"
,
@RequestMapping
(
value
=
"/fetchEmployeeDetailsByFGAccountAndBillability"
,
method
=
RequestMethod
.
GET
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
List
<
Reports
>>
getEmployeesByFGAccountAndBillability
(
public
ResponseEntity
<
List
<
Reports
>>
getEmployeesByFGAccountAndBillability
(
@RequestParam
(
"fGroup"
)
String
fGroup
,
@RequestParam
(
"fGroup"
)
String
fGroup
,
@RequestParam
(
"billableStatus"
)
String
billableStatus
,
@RequestParam
(
"acccount"
)
String
account
)
throws
MyTeamException
{
@RequestParam
(
"billableStatus"
)
String
billableStatus
,
@RequestParam
(
"acccount"
)
String
account
,
@RequestParam
(
"onDate"
)
@DateTimeFormat
(
iso
=
DateTimeFormat
.
ISO
.
DATE
)
Date
onDate
)
throws
MyTeamException
{
List
<
Reports
>
empList
=
null
;
List
<
Reports
>
empList
=
null
;
empList
=
reportService
.
getEmployeeDetailsByFGAccountAndBillability
(
fGroup
,
billableStatus
,
account
);
empList
=
reportService
.
getEmployeeDetailsByFGAccountAndBillability
(
fGroup
,
billableStatus
,
account
,
onDate
);
return
new
ResponseEntity
<>(
empList
,
HttpStatus
.
OK
);
return
new
ResponseEntity
<>(
empList
,
HttpStatus
.
OK
);
}
}
...
@@ -288,10 +279,9 @@ public class ReportsController {
...
@@ -288,10 +279,9 @@ public class ReportsController {
@RequestMapping
(
value
=
"/getBarChartReport"
,
@RequestMapping
(
value
=
"/getBarChartReport"
,
method
=
RequestMethod
.
GET
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ReportVo
billabilityReportByFunctionalGroup
(
@RequestParam
(
"byType"
)
String
byType
)
throws
MyTeamException
{
public
ReportVo
billabilityReportByFunctionalGroup
(
@RequestParam
(
"byType"
)
String
byType
,
@RequestParam
(
"onDate"
)
@DateTimeFormat
(
iso
=
DateTimeFormat
.
ISO
.
DATE
)
Date
onDate
)
throws
MyTeamException
{
return
reportService
.
getBarChartReport
(
byType
,
onDate
);
return
reportService
.
getBarChartReport
(
byType
);
}
}
...
@@ -371,13 +361,12 @@ public class ReportsController {
...
@@ -371,13 +361,12 @@ public class ReportsController {
@RequestMapping
(
value
=
"/fetchEmployeeDetailsByAccountBillability"
,
@RequestMapping
(
value
=
"/fetchEmployeeDetailsByAccountBillability"
,
method
=
RequestMethod
.
GET
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
List
<
Reports
>>
fetchEmployeeDetailsByAccountBillability
(
public
ResponseEntity
<
List
<
Reports
>>
fetchEmployeeDetailsByAccountBillability
(
@RequestParam
(
"account"
)
String
account
,
@RequestParam
(
"account"
)
String
account
,
@RequestParam
(
"billabilityStatus"
)
String
billabilityStatus
,
@RequestParam
(
"billabilityStatus"
)
String
billabilityStatus
)
@RequestParam
(
"onDate"
)
@DateTimeFormat
(
iso
=
DateTimeFormat
.
ISO
.
DATE
)
Date
onDate
)
throws
MyTeamException
{
throws
MyTeamException
{
List
<
Reports
>
resourcesList
=
new
ArrayList
<>();
List
<
Reports
>
resourcesList
=
new
ArrayList
<>();
if
(
account
!=
null
&&
!
account
.
isEmpty
())
{
if
(
account
!=
null
&&
!
account
.
isEmpty
())
{
resourcesList
=
reportService
.
getEmployeeDetailsByAccountBillability
(
account
,
billabilityStatus
);
resourcesList
=
reportService
.
getEmployeeDetailsByAccountBillability
(
account
,
billabilityStatus
,
onDate
);
}
}
return
new
ResponseEntity
<>(
resourcesList
,
HttpStatus
.
OK
);
return
new
ResponseEntity
<>(
resourcesList
,
HttpStatus
.
OK
);
}
}
...
...
src/main/java/com/nisum/myteam/service/IReportService.java
View file @
2dae5af4
package
com
.
nisum
.
myteam
.
service
;
package
com
.
nisum
.
myteam
.
service
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.List
;
import
com.nisum.myteam.exception.handler.MyTeamException
;
import
com.nisum.myteam.exception.handler.MyTeamException
;
import
com.nisum.myteam.model.Reports
;
import
com.nisum.myteam.model.Reports
;
import
com.nisum.myteam.model.dao.Project
;
import
com.nisum.myteam.model.dao.Project
;
import
com.nisum.myteam.model.vo.ReportVo
;
import
com.nisum.myteam.model.vo.ReportVo
;
import
com.nisum.myteam.model.vo.ResourceVO
;
public
interface
IReportService
{
public
interface
IReportService
{
public
ReportVo
getBarChartReport
(
String
byType
)
throws
MyTeamException
;
public
ReportVo
getBarChartReport
(
String
byType
,
Date
onDate
)
throws
MyTeamException
;
public
List
<
Reports
>
getEmployeeDetailsByFGAndBillability
(
String
fGroup
,
String
billableStatus
)
throws
MyTeamException
;
public
List
<
Reports
>
getEmployeeDetailsByFGAndBillability
(
String
fGroup
,
String
billableStatus
,
Date
onDate
)
throws
MyTeamException
;
public
List
<
Reports
>
getEmployeeDetailsByAccountBillability
(
String
account
,
String
billabilityStatus
)
throws
MyTeamException
;
public
List
<
Reports
>
getEmployeeDetailsByAccountBillability
(
String
account
,
String
billabilityStatus
,
Date
onDate
)
throws
MyTeamException
;
public
Project
getProjectById
(
String
employeeId
);
public
Project
getProjectById
(
String
employeeId
);
public
List
<
Reports
>
getEmployeeDetailsByFGAccountAndBillability
(
String
fGroup
,
String
billableStatus
,
String
account
)
;
public
List
<
Reports
>
getEmployeeDetailsByFGAccountAndBillability
(
String
fGroup
,
String
billableStatus
,
String
account
,
Date
onDate
)
throws
MyTeamException
;
}
}
\ No newline at end of file
src/main/java/com/nisum/myteam/service/IResourceService.java
View file @
2dae5af4
...
@@ -71,6 +71,8 @@ public interface IResourceService {
...
@@ -71,6 +71,8 @@ public interface IResourceService {
Resource
getCurrentAllocation
(
String
employeeId
);
Resource
getCurrentAllocation
(
String
employeeId
);
public
Resource
makeResourceInactive
(
String
employeeId
,
Date
endDate
);
// List<Resource> getAllResourcesForProject(String projectId, String status);
// List<Resource> getAllResourcesForProject(String projectId, String status);
// List<Resource> getResourcesForEmployee(String empId);
// List<Resource> getResourcesForEmployee(String empId);
...
...
src/main/java/com/nisum/myteam/service/impl/EmployeeService.java
View file @
2dae5af4
package
com
.
nisum
.
myteam
.
service
.
impl
;
package
com
.
nisum
.
myteam
.
service
.
impl
;
import
java.text.Parse
Exception
;
import
com.nisum.myteam.exception.handler.MyTeam
Exception
;
import
java.text.SimpleDateForma
t
;
import
com.nisum.myteam.model.dao.Accoun
t
;
import
java.util.*
;
import
com.nisum.myteam.model.dao.Domain
;
import
java.util.stream.Collectors
;
import
com.nisum.myteam.model.dao.Employee
;
import
com.nisum.myteam.model.dao.EmployeeSubStatus
;
import
com.nisum.myteam.
model.dao.*
;
import
com.nisum.myteam.
repository.EmployeeRepo
;
import
com.nisum.myteam.service.*
;
import
com.nisum.myteam.service.*
;
import
com.nisum.myteam.utils.MyTeamUtils
;
import
com.nisum.myteam.utils.constants.ApplicationRole
;
import
com.nisum.myteam.utils.constants.RoleConstant
;
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.beans.factory.annotation.Qualifier
;
import
org.springframework.data.domain.Sort
;
import
org.springframework.data.domain.Sort
;
import
org.springframework.data.mongodb.core.FindAndModifyOptions
;
import
org.springframework.data.mongodb.core.FindAndModifyOptions
;
import
org.springframework.data.mongodb.core.MongoTemplate
;
import
org.springframework.data.mongodb.core.MongoTemplate
;
...
@@ -18,14 +21,11 @@ import org.springframework.data.mongodb.core.query.Query;
...
@@ -18,14 +21,11 @@ import org.springframework.data.mongodb.core.query.Query;
import
org.springframework.data.mongodb.core.query.Update
;
import
org.springframework.data.mongodb.core.query.Update
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
com.nisum.myteam.exception.handler.MyTeamException
;
import
javax.transaction.Transactional
;
import
com.nisum.myteam.repository.EmployeeRepo
;
import
java.text.ParseException
;
import
com.nisum.myteam.statuscodes.ResourceStatus
;
import
java.text.SimpleDateFormat
;
import
com.nisum.myteam.utils.MyTeamUtils
;
import
java.util.*
;
import
com.nisum.myteam.utils.constants.ApplicationRole
;
import
java.util.stream.Collectors
;
import
com.nisum.myteam.utils.constants.RoleConstant
;
import
lombok.extern.slf4j.Slf4j
;
@Service
@Service
@Slf4j
@Slf4j
...
@@ -165,6 +165,7 @@ public class EmployeeService implements IEmployeeService {
...
@@ -165,6 +165,7 @@ public class EmployeeService implements IEmployeeService {
// }
// }
@Override
@Override
@Transactional
public
Employee
updateEmployee
(
Employee
employeeReq
,
String
loginEmpId
)
throws
ParseException
{
public
Employee
updateEmployee
(
Employee
employeeReq
,
String
loginEmpId
)
throws
ParseException
{
response
.
put
(
"messege"
,
"Employee has been updated"
);
response
.
put
(
"messege"
,
"Employee has been updated"
);
// update all emp details to inactive if employee is inactive
// update all emp details to inactive if employee is inactive
...
@@ -177,10 +178,8 @@ public class EmployeeService implements IEmployeeService {
...
@@ -177,10 +178,8 @@ public class EmployeeService implements IEmployeeService {
update
.
set
(
"gender"
,
employeeReq
.
getGender
());
update
.
set
(
"gender"
,
employeeReq
.
getGender
());
update
.
set
(
"functionalGroup"
,
employeeReq
.
getFunctionalGroup
());
update
.
set
(
"functionalGroup"
,
employeeReq
.
getFunctionalGroup
());
update
.
set
(
"empStatus"
,
employeeReq
.
getEmpStatus
());
update
.
set
(
"empStatus"
,
employeeReq
.
getEmpStatus
());
// update.set("empSubStatus", employeeReq.getEmpSubStatus());
update
.
set
(
"employmentType"
,
employeeReq
.
getEmploymentType
());
update
.
set
(
"employmentType"
,
employeeReq
.
getEmploymentType
());
update
.
set
(
"empLocation"
,
employeeReq
.
getEmpLocation
());
update
.
set
(
"empLocation"
,
employeeReq
.
getEmpLocation
());
// update.set("domain", employeeReq.getDomain());
update
.
set
(
"designation"
,
employeeReq
.
getDesignation
());
update
.
set
(
"designation"
,
employeeReq
.
getDesignation
());
update
.
set
(
"dateOfBirth"
,
employeeReq
.
getDateOfBirth
());
update
.
set
(
"dateOfBirth"
,
employeeReq
.
getDateOfBirth
());
update
.
set
(
"dateOfJoining"
,
employeeReq
.
getDateOfJoining
());
update
.
set
(
"dateOfJoining"
,
employeeReq
.
getDateOfJoining
());
...
@@ -194,7 +193,6 @@ public class EmployeeService implements IEmployeeService {
...
@@ -194,7 +193,6 @@ public class EmployeeService implements IEmployeeService {
if
(
employeeReq
.
getEmpStatus
().
equalsIgnoreCase
(
MyTeamUtils
.
IN_ACTIVE_SPACE
))
{
if
(
employeeReq
.
getEmpStatus
().
equalsIgnoreCase
(
MyTeamUtils
.
IN_ACTIVE_SPACE
))
{
update
.
set
(
"endDate"
,
employeeReq
.
getEndDate
());
update
.
set
(
"endDate"
,
employeeReq
.
getEndDate
());
// update.set("empSubStatus", null);
}
}
// update employee location
// update employee location
if
(
employeeReq
.
getEmpLocation
()
!=
null
&&
!
employeeReq
.
getEmpLocation
().
equals
(
""
))
{
if
(
employeeReq
.
getEmpLocation
()
!=
null
&&
!
employeeReq
.
getEmpLocation
().
equals
(
""
))
{
...
@@ -244,16 +242,10 @@ public class EmployeeService implements IEmployeeService {
...
@@ -244,16 +242,10 @@ public class EmployeeService implements IEmployeeService {
options
.
returnNew
(
true
);
options
.
returnNew
(
true
);
options
.
upsert
(
true
);
options
.
upsert
(
true
);
Employee
employeeUpdated
=
mongoTemplate
.
findAndModify
(
query
,
update
,
options
,
Employee
.
class
);
Employee
employeeUpdated
=
mongoTemplate
.
findAndModify
(
query
,
update
,
options
,
Employee
.
class
);
if
(
employeeReq
.
getEmpStatus
().
equals
(
"In Active"
)){
try
{
resourceService
.
makeResourceInactive
(
employeeReq
.
getEmployeeId
(),
employeeReq
.
getEndDate
());
// add to resource collection
//resourceService.addResources(employeeUpdated, loginEmpId);
// inactive the employee from the assigned project.
//resourceService.inactivateResource(employeeReq, employeeUpdated, loginEmpId);
}
catch
(
Exception
e
)
{
}
}
return
employeeUpdated
;
return
employeeUpdated
;
}
}
...
...
src/main/java/com/nisum/myteam/service/impl/ReportService.java
View file @
2dae5af4
...
@@ -2,16 +2,12 @@ package com.nisum.myteam.service.impl;
...
@@ -2,16 +2,12 @@ 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.Reports
;
import
com.nisum.myteam.model.Reports
;
import
com.nisum.myteam.model.dao.Account
;
import
com.nisum.myteam.model.dao.Employee
;
import
com.nisum.myteam.model.dao.Employee
;
import
com.nisum.myteam.model.dao.Project
;
import
com.nisum.myteam.model.dao.Project
;
import
com.nisum.myteam.model.dao.Resource
;
import
com.nisum.myteam.model.dao.Resource
;
import
com.nisum.myteam.model.vo.ReportVo
;
import
com.nisum.myteam.model.vo.ReportVo
;
import
com.nisum.myteam.model.vo.ResourceVO
;
import
com.nisum.myteam.service.IReportService
;
import
com.nisum.myteam.service.IReportService
;
import
com.nisum.myteam.statuscodes.ResourceStatus
;
import
com.nisum.myteam.utils.MyTeamUtils
;
import
com.nisum.myteam.utils.MyTeamUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
...
@@ -21,10 +17,6 @@ import java.util.stream.Collectors;
...
@@ -21,10 +17,6 @@ import java.util.stream.Collectors;
@Service
@Service
public
class
ReportService
implements
IReportService
{
public
class
ReportService
implements
IReportService
{
private
static
final
String
Shadow
=
"Shadow"
;
private
static
final
String
Reserved
=
"Reserved"
;
@Autowired
@Autowired
private
EmployeeService
employeeService
;
private
EmployeeService
employeeService
;
...
@@ -40,12 +32,12 @@ public class ReportService implements IReportService {
...
@@ -40,12 +32,12 @@ public class ReportService implements IReportService {
@Autowired
@Autowired
private
FunctionalGroupService
functionalGroupService
;
private
FunctionalGroupService
functionalGroupService
;
public
ReportVo
getBarChartReport
(
String
byType
)
throws
MyTeamException
{
public
ReportVo
getBarChartReport
(
String
byType
,
Date
onDate
)
throws
MyTeamException
{
ReportVo
reportVo
=
new
ReportVo
();
ReportVo
reportVo
=
new
ReportVo
();
if
(
byType
.
equals
(
"AllFunctionalGroup"
))
{
if
(
byType
.
equals
(
"AllFunctionalGroup"
))
{
functionalGroupService
.
getAllFunctionalGroups
().
stream
().
functionalGroupService
.
getAllFunctionalGroups
().
stream
().
filter
(
f
->
!
Arrays
.
asList
(
"IT"
,
"Recruiter"
,
"Admin"
,
"HR"
,
"Accounts"
).
contains
(
f
.
getName
())).
filter
(
f
->
!
Arrays
.
asList
(
"IT"
,
"Recruiter"
,
"Admin"
,
"HR"
,
"Accounts"
,
"Delivery Org"
,
"Global Mobility"
).
contains
(
f
.
getName
())).
forEach
(
f
->
reportVo
.
getCategoriesList
().
add
(
f
.
getName
()));
forEach
(
f
->
reportVo
.
getCategoriesList
().
add
(
f
.
getName
()));
}
else
{
}
else
{
accountService
.
getAllAccounts
().
forEach
(
a
->
reportVo
.
getCategoriesList
().
add
(
a
.
getAccountName
()));
accountService
.
getAllAccounts
().
forEach
(
a
->
reportVo
.
getCategoriesList
().
add
(
a
.
getAccountName
()));
...
@@ -80,9 +72,11 @@ public class ReportService implements IReportService {
...
@@ -80,9 +72,11 @@ public class ReportService implements IReportService {
employeeList
=
getEmployeesByAccAndFG
(
category
,
byType
);
employeeList
=
getEmployeesByAccAndFG
(
category
,
byType
);
}
}
for
(
Employee
employee:
employeeList
){
for
(
Employee
employee:
employeeList
){
Resource
resource
=
resourceService
.
getCurrentAllocationIfNotReturnNull
(
employee
.
getEmployeeId
());
//getCurrentAllocation(employee.getEmployeeId());
Resource
resource
=
null
;
if
(
Objects
.
nonNull
(
onDate
)){
resource
=
resourceService
.
getAllocationOfDate
(
employee
.
getEmployeeId
(),
onDate
);
}
if
(
resource
!=
null
&&
resource
.
getBillableStatus
().
equals
(
"Billable"
)){
if
(
resource
!=
null
&&
resource
.
getBillableStatus
().
equals
(
"Billable"
)){
billableC
++;
billableC
++;
}
else
if
(
resource
!=
null
&&
resource
.
getBillableStatus
().
equals
(
"Trainee"
))
{
}
else
if
(
resource
!=
null
&&
resource
.
getBillableStatus
().
equals
(
"Trainee"
))
{
traineeC
++;
traineeC
++;
...
@@ -92,13 +86,10 @@ public class ReportService implements IReportService {
...
@@ -92,13 +86,10 @@ public class ReportService implements IReportService {
}
}
billper
=
((
billableC
/
(
float
)(
employeeList
.
size
()
-
traineeC
))*
100
);
billper
=
((
billableC
/
(
float
)(
employeeList
.
size
()
-
traineeC
))*
100
);
nonBillPer
=
nonBillableC
/(
float
)
(
employeeList
.
size
()-
traineeC
)*
100
;
nonBillPer
=
nonBillableC
/(
float
)
(
employeeList
.
size
()-
traineeC
)*
100
;
// traineePer = traineeC / (float) employeeList.size()*100;
billableObj
.
put
(
"percent"
,
billper
);
billableObj
.
put
(
"percent"
,
billper
);
billableObj
.
put
(
"y"
,
billableC
);
billableObj
.
put
(
"y"
,
billableC
);
nonbillableObj
.
put
(
"percent"
,
nonBillPer
);
nonbillableObj
.
put
(
"percent"
,
nonBillPer
);
nonbillableObj
.
put
(
"y"
,
nonBillableC
);
nonbillableObj
.
put
(
"y"
,
nonBillableC
);
// traineeObj.put("percent", traineePer);
// traineeObj.put("y", traineeC);
billableCount
.
add
(
billableObj
);
billableCount
.
add
(
billableObj
);
nonBillableCount
.
add
(
nonbillableObj
);
nonBillableCount
.
add
(
nonbillableObj
);
traineeCount
.
add
(
traineeC
);
traineeCount
.
add
(
traineeC
);
...
@@ -113,7 +104,7 @@ public class ReportService implements IReportService {
...
@@ -113,7 +104,7 @@ public class ReportService implements IReportService {
}
}
private
List
<
Employee
>
getEmployeesByAccAndFG
(
String
account
,
String
functionalGroup
)
{
private
List
<
Employee
>
getEmployeesByAccAndFG
(
String
account
,
String
functionalGroup
)
{
List
<
Employee
>
empList
=
new
ArrayList
<
Employee
>()
;
List
<
Employee
>
empList
;
empList
=
getEmployeeByAccounts
(
account
).
stream
().
filter
(
e
->
e
.
getFunctionalGroup
().
equals
(
functionalGroup
)).
collect
(
Collectors
.
toList
());
empList
=
getEmployeeByAccounts
(
account
).
stream
().
filter
(
e
->
e
.
getFunctionalGroup
().
equals
(
functionalGroup
)).
collect
(
Collectors
.
toList
());
return
empList
;
return
empList
;
}
}
...
@@ -138,29 +129,33 @@ public class ReportService implements IReportService {
...
@@ -138,29 +129,33 @@ public class ReportService implements IReportService {
}
}
@Override
@Override
public
List
<
Reports
>
getEmployeeDetailsByFGAndBillability
(
String
fGroup
,
String
billableStatus
)
public
List
<
Reports
>
getEmployeeDetailsByFGAndBillability
(
String
fGroup
,
String
billableStatus
,
Date
onDate
)
throws
MyTeamException
{
throws
MyTeamException
{
List
<
Employee
>
employeesByFG
=
employeeService
.
getEmployeesByFunctionalGrp
(
fGroup
);
List
<
Employee
>
employeesByFG
=
employeeService
.
getEmployeesByFunctionalGrp
(
fGroup
);
return
resultantEmployeeWithBillability
(
employeesByFG
,
billableStatus
);
return
resultantEmployeeWithBillability
(
employeesByFG
,
billableStatus
,
onDate
);
}
}
@Override
@Override
public
List
<
Reports
>
getEmployeeDetailsByAccountBillability
(
String
accountName
,
String
billabilityStatus
)
public
List
<
Reports
>
getEmployeeDetailsByAccountBillability
(
String
accountName
,
String
billabilityStatus
,
Date
onDate
)
throws
MyTeamException
{
throws
MyTeamException
{
return
resultantEmployeeWithBillability
(
getEmployeeByAccounts
(
accountName
),
billabilityStatus
);
return
resultantEmployeeWithBillability
(
getEmployeeByAccounts
(
accountName
),
billabilityStatus
,
onDate
);
}
@Override
public
List
<
Reports
>
getEmployeeDetailsByFGAccountAndBillability
(
String
fGroup
,
String
billableStatus
,
String
account
,
Date
onDate
)
throws
MyTeamException
{
List
<
Employee
>
empList
=
getEmployeesByAccAndFG
(
account
,
fGroup
);
return
resultantEmployeeWithBillability
(
empList
,
billableStatus
,
onDate
);
}
}
private
List
<
Reports
>
resultantEmployeeWithBillability
(
List
<
Employee
>
employees
,
private
List
<
Reports
>
resultantEmployeeWithBillability
(
List
<
Employee
>
employees
,
String
billableStatus
)
{
String
billableStatus
,
Date
ondate
)
throws
MyTeamException
{
List
<
Reports
>
billableEmployees
=
new
ArrayList
<
Reports
>();
List
<
Reports
>
billableEmployees
=
new
ArrayList
<
Reports
>();
List
<
Reports
>
nonBillableEmployees
=
new
ArrayList
<
Reports
>();
List
<
Reports
>
nonBillableEmployees
=
new
ArrayList
<
Reports
>();
List
<
Reports
>
trainees
=
new
ArrayList
<
Reports
>();
List
<
Reports
>
trainees
=
new
ArrayList
<
Reports
>();
for
(
Employee
employee:
employees
){
for
(
Employee
employee:
employees
){
Resource
resource
=
resourceService
.
get
CurrentAllocationIfNotReturnNull
(
employee
.
getEmployeeId
());
//getCurrentAllocation(employee.getEmployeeId()
);
Resource
resource
=
resourceService
.
get
AllocationOfDate
(
employee
.
getEmployeeId
(),
ondate
);
if
(
resource
!=
null
&&
resource
.
getBillableStatus
().
equals
(
"Billable"
)){
if
(
resource
!=
null
&&
resource
.
getBillableStatus
().
equals
(
"Billable"
)){
billableEmployees
.
add
(
mappingReports
(
employee
,
resource
));
billableEmployees
.
add
(
mappingReports
(
employee
,
resource
));
}
else
if
(
resource
!=
null
&&
resource
.
getBillableStatus
().
equals
(
"Trainee"
))
{
}
else
if
(
resource
!=
null
&&
resource
.
getBillableStatus
().
equals
(
"Trainee"
))
{
...
@@ -178,29 +173,14 @@ public class ReportService implements IReportService {
...
@@ -178,29 +173,14 @@ public class ReportService implements IReportService {
else
else
return
nonBillableEmployees
;
return
nonBillableEmployees
;
// List<Reports> resultantEmployees=new ArrayList<Reports>();
// for(Employee employee:employees) {
// Resource resourceObj=resourceService.getCurrentAllocation(employee.getEmployeeId());
//
// if(resourceObj.getBillableStatus().equals(billableStatus) ||( billableStatus.equals("Non-Billable") && (resourceObj.getBillableStatus().equals(Shadow)||resourceObj.getBillableStatus().equals(Reserved)))) {
//
// resultantEmployees.add(mappingReports(employee,resourceObj));
// }
// }
// return resultantEmployees;
}
}
// if(!resourceService.isAllocationActiveToday(resourceObj) && billableStatus.equals("Non-Billable")) {
// //resultantEmployees.add((mappingReports)
// }
private
Reports
mappingReports
(
Employee
employee
,
Resource
resourceObj
){
private
Reports
mappingReports
(
Employee
employee
,
Resource
resourceObj
){
Reports
Reports
=
new
Reports
();
Reports
Reports
=
new
Reports
();
Reports
.
setEmployeeName
(
employee
.
getEmployeeName
());
Reports
.
setEmployeeName
(
employee
.
getEmployeeName
());
Reports
.
setEmailId
(
employee
.
getEmailId
());
Reports
.
setEmailId
(
employee
.
getEmailId
());
Reports
.
setFunctionalGroup
(
employee
.
getFunctionalGroup
());
Reports
.
setFunctionalGroup
(
employee
.
getFunctionalGroup
());
Reports
.
setEmployeeId
(
employee
.
getEmployeeId
());
Reports
.
setEmployeeId
(
employee
.
getEmployeeId
());
// Reports.setBillableStatus("BillingEnded");
if
(
resourceObj
!=
null
)
{
if
(
resourceObj
!=
null
)
{
Project
project
=
projectService
.
getProjectByProjectId
(
resourceObj
.
getProjectId
());
Project
project
=
projectService
.
getProjectByProjectId
(
resourceObj
.
getProjectId
());
Reports
.
setProjectName
(
project
.
getProjectName
());
Reports
.
setProjectName
(
project
.
getProjectName
());
...
@@ -213,29 +193,9 @@ public class ReportService implements IReportService {
...
@@ -213,29 +193,9 @@ public class ReportService implements IReportService {
return
Reports
;
return
Reports
;
}
}
// private Reports mappingReports(Employee employee,Resource resourceObj){
// Reports Reports=new Reports();
// Project project=projectService.getProjectByProjectId(resourceObj.getProjectId());
// Reports.setEmployeeId(resourceObj.getEmployeeId());
// Reports.setEmployeeName(employee.getEmployeeName());
// Reports.setEmailId(employee.getEmailId());
// Reports.setProjectName(project.getProjectName());
// Reports.setBillingStartDate(resourceObj.getBillingStartDate());
// Reports.setBillableStatus(resourceObj.getBillableStatus());
// Reports.setBillingEndDate(resourceObj.getBillingEndDate());
// Reports.setFunctionalGroup(employee.getFunctionalGroup());
// return Reports;
// }
@Override
@Override
public
Project
getProjectById
(
String
projectId
)
{
public
Project
getProjectById
(
String
projectId
)
{
return
projectService
.
getProjectByProjectId
(
projectId
);
return
projectService
.
getProjectByProjectId
(
projectId
);
}
}
@Override
public
List
<
Reports
>
getEmployeeDetailsByFGAccountAndBillability
(
String
fGroup
,
String
billableStatus
,
String
account
)
{
List
<
Employee
>
empList
=
getEmployeesByAccAndFG
(
account
,
fGroup
);
return
resultantEmployeeWithBillability
(
empList
,
billableStatus
);
}
}
}
src/main/java/com/nisum/myteam/service/impl/ResourceService.java
View file @
2dae5af4
...
@@ -220,11 +220,6 @@ public class ResourceService implements IResourceService {
...
@@ -220,11 +220,6 @@ public class ResourceService implements IResourceService {
respMap
.
put
(
"message"
,
"Billing start date should be after previous allocation billing end date in this project"
);
respMap
.
put
(
"message"
,
"Billing start date should be after previous allocation billing end date in this project"
);
isValid
=
false
;
isValid
=
false
;
}
}
// if (prevAllocation.getBillableStatus().equalsIgnoreCase(resourceReq.getBillableStatus())) {
// respMap.put("statusCode", 811);
// respMap.put("message", "Resource is already in " + prevAllocation.getBillableStatus() + " status only");
// isValid = false;
// }
}
}
return
isValid
;
return
isValid
;
}
}
...
@@ -299,10 +294,6 @@ public class ResourceService implements IResourceService {
...
@@ -299,10 +294,6 @@ public class ResourceService implements IResourceService {
}
}
public
boolean
isDatesAvailableForAllocation
(
Resource
resource
){
public
boolean
isDatesAvailableForAllocation
(
Resource
resource
){
String
message
=
""
;
String
message
=
""
;
List
<
Resource
>
allocationList
=
resourceRepo
.
findByEmployeeId
(
resource
.
getEmployeeId
());
List
<
Resource
>
allocationList
=
resourceRepo
.
findByEmployeeId
(
resource
.
getEmployeeId
());
...
@@ -326,38 +317,6 @@ public class ResourceService implements IResourceService {
...
@@ -326,38 +317,6 @@ public class ResourceService implements IResourceService {
}
}
// public boolean isDatesAvailableForAllocation(Resource resource){
//
//
//
//
//
//
//
// String message = "";
// List<Resource> allocationList = resourceRepo.findByEmployeeId(resource.getEmployeeId());
//
// List<Resource> matchedList = allocationList.stream().filter(r -> !r.getProjectId().equals(MyTeamUtils.BENCH_PROJECT_ID) &&
// !r.getId().equals(resource.getId()) &&
// ( (r.getBillingStartDate().compareTo(resource.getBillingStartDate())<=0 && r.getBillingEndDate().compareTo(resource.getBillingStartDate())>=0)||
// (r.getBillingStartDate().compareTo(resource.getBillingEndDate())<=0 && r.getBillingEndDate().compareTo(resource.getBillingEndDate())>=0 )))
// .collect(Collectors.toList());
// if(!matchedList.isEmpty()){
// message = "Resource is already alocated for projects:\n";
// for(Resource resourcel:matchedList){
// Project project = projectService.getProjectByProjectId(resourcel.getProjectId());
// message += "Project:"+project.getProjectName()+" From:"+MyTeamDateUtils.getRadableDate().format(resourcel.getBillingStartDate())+" To:"
// +MyTeamDateUtils.getRadableDate().format(resourcel.getBillingEndDate())+"\n";
// }
// respMap.put("statusCode", 815);
// respMap.put("message", message);
// return false;
// }else
// return true;
//
// }
public
boolean
isResourceAvailable
(
Resource
resourceReq
)
{
public
boolean
isResourceAvailable
(
Resource
resourceReq
)
{
boolean
isAssigned
=
true
;
boolean
isAssigned
=
true
;
...
@@ -380,26 +339,6 @@ public class ResourceService implements IResourceService {
...
@@ -380,26 +339,6 @@ public class ResourceService implements IResourceService {
}
}
respMap
.
put
(
"statusCode"
,
815
);
respMap
.
put
(
"statusCode"
,
815
);
respMap
.
put
(
"message"
,
message
);
respMap
.
put
(
"message"
,
message
);
// Resource resourceLatestRecord = getLatestAllocation(resourceAllocList.stream().
// filter(r -> r.getProjectId().equalsIgnoreCase(MyTeamUtils.BENCH_PROJECT_ID)).collect(Collectors.toList())); //getting latest allocation of employee in bench project
//
// if (resourceLatestRecord != null && !isAllocationActiveToday(resourceLatestRecord)){
// Resource latestProjectResource = getLatestAllocation(resourceAllocList.stream().
// filter(r -> !r.getProjectId().equalsIgnoreCase(MyTeamUtils.BENCH_PROJECT_ID)).collect(Collectors.toList()));
// if(!resourceReq.getProjectId().equalsIgnoreCase(latestProjectResource.getProjectId())) {
// message = "Resource " + latestProjectResource.getEmployeeId() + " already Assigned to the "
// + projectService.getProjectByProjectId(latestProjectResource.getProjectId()).getProjectName()
// + " Project" + " from " + latestProjectResource.getBillingStartDate() + "to " + latestProjectResource.getBillingEndDate();
// isAssigned = false;
// respMap.put("statusCode", 815);
// respMap.put("message", message);
// }
// }else{
// if(!validateResourceBillingEndDateAgainstBench(resourceReq)){
// isAssigned = false;
// }
// }
return
isAssigned
;
return
isAssigned
;
}
}
...
@@ -480,6 +419,12 @@ public class ResourceService implements IResourceService {
...
@@ -480,6 +419,12 @@ public class ResourceService implements IResourceService {
return
isActive
;
return
isActive
;
}
}
public
Resource
getAllocationOfDate
(
String
employeeId
,
Date
onDate
){
List
<
Resource
>
resources
=
this
.
getResourcesByEmployeeId
(
employeeId
);
return
resources
.
stream
().
filter
(
resource
->
resource
.
getBillingStartDate
().
compareTo
(
onDate
)
<=
0
&&
resource
.
getBillingEndDate
().
compareTo
(
onDate
)>=
0
).
findFirst
().
orElse
(
null
);
}
public
void
deleteResource
(
Resource
resourceReq
,
String
loginEmpId
)
{
public
void
deleteResource
(
Resource
resourceReq
,
String
loginEmpId
)
{
resourceRepo
.
delete
(
resourceReq
);
resourceRepo
.
delete
(
resourceReq
);
...
@@ -1194,64 +1139,18 @@ public class ResourceService implements IResourceService {
...
@@ -1194,64 +1139,18 @@ public class ResourceService implements IResourceService {
public
Resource
getCurrentAllocationIfNotReturnNull
(
String
employeeId
)
{
public
Resource
getCurrentAllocationIfNotReturnNull
(
String
employeeId
)
{
return
resourceRepo
.
findByEmployeeId
(
employeeId
).
stream
().
filter
(
resource
->
isAllocationActiveToday
(
resource
)).
findAny
().
orElse
(
null
);
return
resourceRepo
.
findByEmployeeId
(
employeeId
).
stream
().
filter
(
resource
->
isAllocationActiveToday
(
resource
)).
findAny
().
orElse
(
null
);
}
}
}
//class
/*
@Override
public List<ResourceVO> getActiveResources(String empId) {
List<ResourceVO> finalResourcesList = new ArrayList<>();
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());
Employee employee=employeeService.getEmployeeById(resource.getEmployeeId());
resourceVO.setEmployeeName(employee.getEmployeeName());
resourceVO.setDesignation(employee.getDesignation());
resourceVO.setEmailId(employee.getEmailId());
resourceVO.setMobileNo(employee.getMobileNumber());
resourceVO.setProjectName(projectService.getProjectByProjectId(resource.getProjectId()).getProjectName());
if (resource.getBillingEndDate().compareTo(new Date()) > 0) {
finalResourcesList.addAll(getAllResourcesForProject(resource.getProjectId()));
}
}
return finalResourcesList;
}
*/
/*
@Override
@Override
public List<ResourceVO> getActiveResources(String empId) {
public
Resource
makeResourceInactive
(
String
employeeId
,
Date
endDate
){
List<ResourceVO> finalResourcesList = new ArrayList<>();
Resource
latestAllocation
=
this
.
getLatestResourceByEmpId
(
employeeId
);
Employee employee = null;
Resource
currentAllocation
=
this
.
getCurrentAllocationIfNotReturnNull
(
employeeId
);
if
(
Objects
.
nonNull
(
latestAllocation
)
&&
latestAllocation
.
getBillingStartDate
().
compareTo
(
new
Date
())>
0
){
List<Resource> resourceList = resourceRepo.findByEmployeeId(empId);
resourceRepo
.
delete
(
latestAllocation
);
Optional<Resource> optionalResource = resourceList.stream().filter(resource -> resource.getBillingEndDate().compareTo(new Date()) > 0).findAny();
}
if (optionalResource.isPresent()) {
currentAllocation
.
setBillingEndDate
(
endDate
);
finalResourcesList = prepareProjectTeamMembersList(optionalResource.get().getProjectId());
latestAllocation
.
setBillingEndDate
(
endDate
);
}
resourceRepo
.
save
(
currentAllocation
);
return finalResourcesList;
resourceRepo
.
save
(
latestAllocation
);
return
null
;
}
}
}
*/
\ No newline at end of file
src/main/java/com/nisum/myteam/utils/MyTeamDateUtils.java
View file @
2dae5af4
...
@@ -2,14 +2,14 @@ package com.nisum.myteam.utils;
...
@@ -2,14 +2,14 @@ package com.nisum.myteam.utils;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.hsqldb.lib.StringUtil
;
import
org.springframework.beans.factory.annotation.Value
;
import
java.text.ParseException
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.text.SimpleDateFormat
;
import
java.time.LocalDate
;
import
java.time.LocalDate
;
import
java.time.ZoneId
;
import
java.time.ZoneId
;
import
java.util.*
;
import
java.util.Arrays
;
import
java.util.Calendar
;
import
java.util.Date
;
@Slf4j
@Slf4j
public
class
MyTeamDateUtils
{
public
class
MyTeamDateUtils
{
...
...
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