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
fed165ca
Commit
fed165ca
authored
May 12, 2019
by
Vijay Akula
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Modified code for all operations in resources as per new db design
parent
3ff7c67b
Changes
18
Hide whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
1079 additions
and
868 deletions
+1079
-868
BillingController.java
...n/java/com/nisum/myteam/controller/BillingController.java
+2
-3
EmployeeController.java
.../java/com/nisum/myteam/controller/EmployeeController.java
+44
-1
ProjectController.java
...n/java/com/nisum/myteam/controller/ProjectController.java
+2
-17
ResourceAllocationController.java
...nisum/myteam/controller/ResourceAllocationController.java
+176
-147
ResourceController.java
.../java/com/nisum/myteam/controller/ResourceController.java
+22
-57
Employee.java
src/main/java/com/nisum/myteam/model/dao/Employee.java
+2
-1
Project.java
src/main/java/com/nisum/myteam/model/dao/Project.java
+0
-1
ResourceAllocation.java
...n/java/com/nisum/myteam/model/dao/ResourceAllocation.java
+6
-14
ResourceAllocationRepo.java
...a/com/nisum/myteam/repository/ResourceAllocationRepo.java
+4
-4
IDashboardService.java
...main/java/com/nisum/myteam/service/IDashboardService.java
+6
-1
IEmployeeService.java
src/main/java/com/nisum/myteam/service/IEmployeeService.java
+26
-26
IProjectService.java
src/main/java/com/nisum/myteam/service/IProjectService.java
+16
-18
IResourceAllocationService.java
.../com/nisum/myteam/service/IResourceAllocationService.java
+38
-13
ProjectService.java
...in/java/com/nisum/myteam/service/impl/ProjectService.java
+374
-524
ResourceAllocationService.java
.../nisum/myteam/service/impl/ResourceAllocationService.java
+325
-19
ResourceService.java
...n/java/com/nisum/myteam/service/impl/ResourceService.java
+21
-19
ResourceStatus.java
...ain/java/com/nisum/myteam/statuscodes/ResourceStatus.java
+13
-1
MyTeamUtils.java
src/main/java/com/nisum/myteam/utils/MyTeamUtils.java
+2
-2
No files found.
src/main/java/com/nisum/myteam/controller/BillingController.java
View file @
fed165ca
package
com
.
nisum
.
myteam
.
controller
;
import
java.util.List
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.MediaType
;
...
...
@@ -12,11 +11,9 @@ import org.springframework.web.bind.annotation.RequestMapping;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
com.nisum.myteam.exception.handler.MyTeamException
;
import
com.nisum.myteam.model.dao.Billing
;
import
com.nisum.myteam.service.IBillingService
;
import
lombok.extern.slf4j.Slf4j
;
@RestController
...
...
@@ -50,6 +47,8 @@ public class BillingController {
return
new
ResponseEntity
<>(
null
,
HttpStatus
.
OK
);
}
// @RequestMapping(value = "/getEmployeeBillingDetailsAll"
@RequestMapping
(
value
=
"/billing"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
List
<
Billing
>>
getAllBillingsForEmployee
(
@RequestParam
(
"employeeId"
)
String
employeeId
)
...
...
src/main/java/com/nisum/myteam/controller/EmployeeController.java
View file @
fed165ca
...
...
@@ -8,6 +8,8 @@ import java.util.stream.Collectors;
import
javax.servlet.http.HttpServletRequest
;
import
com.nisum.myteam.model.dao.EmployeeVisa
;
import
com.nisum.myteam.repository.EmployeeVisaRepo
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.MediaType
;
...
...
@@ -38,6 +40,10 @@ public class EmployeeController {
@Autowired
private
IEmployeeRoleService
employeeRoleService
;
@Autowired
private
EmployeeVisaRepo
employeeVisaRepo
;
@RequestMapping
(
value
=
"/employees/{empId}"
,
method
=
RequestMethod
.
POST
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
,
consumes
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<?>
createEmployee
(
@RequestBody
Employee
employeeReq
,
@PathVariable
(
value
=
"empId"
)
String
loginEmpId
,
HttpServletRequest
request
)
throws
MyTeamException
{
...
...
@@ -227,6 +233,43 @@ public class EmployeeController {
return
new
ResponseEntity
<>(
employeesList
,
HttpStatus
.
OK
);
}
@RequestMapping
(
value
=
"/getEmployeesHavingVisa"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<?>
getEmployeesHavingVisa
(
@RequestParam
(
"visa"
)
String
passport
,
HttpServletRequest
request
)
throws
MyTeamException
{
List
<
Employee
>
employees
=
new
ArrayList
<>();
if
(
passport
!=
null
&&
!
"passport"
.
equalsIgnoreCase
(
passport
))
{
List
<
EmployeeVisa
>
employeeVisas
=
employeeVisaRepo
.
findByVisaName
(
passport
);
List
<
String
>
employeeIds
=
null
;
if
(
employeeVisas
!=
null
)
{
employeeIds
=
employeeVisas
.
stream
().
map
(
EmployeeVisa:
:
getEmployeeId
).
collect
(
Collectors
.
toList
());
}
if
(
employeeIds
!=
null
&&
!
employeeIds
.
isEmpty
())
{
List
<
Employee
>
emps
=
empService
.
getActiveEmployees
();
for
(
Employee
emp
:
emps
)
{
if
(
employeeIds
.
contains
(
emp
.
getEmployeeId
()))
{
employees
.
add
(
emp
);
}
}
}
}
else
{
if
(
empService
.
getActiveEmployees
()
!=
null
)
{
employees
=
empService
.
getActiveEmployees
().
stream
()
.
sorted
((
o1
,
o2
)
->
o1
.
getEmployeeName
().
compareTo
(
o2
.
getEmployeeName
()))
.
collect
(
Collectors
.
toList
());
}
}
ResponseDetails
responseDetails
=
new
ResponseDetails
(
new
Date
(),
602
,
"Resources have been retrieved successfully"
,
"List of Resources who has visa"
,
employees
,
request
.
getRequestURI
(),
"Resource details"
,
null
);
return
new
ResponseEntity
<
ResponseDetails
>(
responseDetails
,
HttpStatus
.
OK
);
}
}
\ No newline at end of file
src/main/java/com/nisum/myteam/controller/ProjectController.java
View file @
fed165ca
...
...
@@ -7,7 +7,6 @@ import com.nisum.myteam.model.dao.Project;
import
com.nisum.myteam.service.IEmployeeService
;
import
com.nisum.myteam.service.IProjectService
;
import
com.nisum.myteam.statuscodes.ProjectStatus
;
import
com.nisum.myteam.utils.MyTeamUtils
;
import
com.nisum.myteam.utils.constants.ApplicationRole
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -38,7 +37,7 @@ public class ProjectController {
public
ResponseEntity
<?>
createProject
(
@Valid
@RequestBody
Project
projectReq
,
@RequestParam
(
value
=
"loginEmpId"
)
String
loginEmpId
,
HttpServletRequest
request
)
throws
MyTeamException
{
if
(!
projectService
.
isProjectExists
(
projectReq
.
getProjectName
()))
{
if
(!
projectService
.
isProjectExists
ByName
(
projectReq
.
getProjectName
()))
{
String
accountName
=
""
;
Account
account
=
projectService
.
getProjectAccount
(
projectReq
.
getAccountId
());
...
...
@@ -80,7 +79,7 @@ public class ProjectController {
@RequestParam
(
value
=
"loginEmpId"
)
String
loginEmpId
,
HttpServletRequest
request
)
throws
MyTeamException
{
if
(
projectService
.
isProjectExistsById
(
projectId
))
{
if
(
projectService
.
isProjectExists
(
project
.
getProjectName
()))
{
if
(
projectService
.
isProjectExists
ByName
(
project
.
getProjectName
()))
{
Project
updatedProject
=
projectService
.
updateProject
(
project
,
loginEmpId
);
ResponseDetails
getRespDetails
=
new
ResponseDetails
(
new
Date
(),
ProjectStatus
.
UPDATE
.
getCode
(),
ProjectStatus
.
UPDATE
.
getMessage
(),
"Project Updation Description"
,
null
,
...
...
@@ -183,21 +182,7 @@ public class ProjectController {
}
@RequestMapping
(
value
=
"/getMyProjectAllocations"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<?>
getMyProjectAllocations
(
@RequestParam
(
"employeeId"
)
String
employeeId
,
HttpServletRequest
request
)
throws
MyTeamException
{
if
(
employeeId
!=
null
&&
!
""
.
equalsIgnoreCase
(
employeeId
))
{
ResponseDetails
getRespDetails
=
new
ResponseDetails
(
new
Date
(),
604
,
"Retrieved the project allocations successfully"
,
"Projects allocations for an employee"
,
projectService
.
getProjectsForEmployee
(
employeeId
),
request
.
getRequestURI
(),
"Project details"
,
null
);
return
new
ResponseEntity
<
ResponseDetails
>(
getRespDetails
,
HttpStatus
.
OK
);
}
ResponseDetails
getRespDetails
=
new
ResponseDetails
(
new
Date
(),
606
,
"Please Provide valid employee id"
,
"Project allocations for an employee"
,
null
,
request
.
getRequestURI
(),
"Project details"
,
null
);
return
new
ResponseEntity
<
ResponseDetails
>(
getRespDetails
,
HttpStatus
.
OK
);
}
}
...
...
src/main/java/com/nisum/myteam/controller/ResourceAllocationController.java
View file @
fed165ca
...
...
@@ -3,13 +3,15 @@ package com.nisum.myteam.controller;
import
com.nisum.myteam.exception.handler.MyTeamException
;
import
com.nisum.myteam.exception.handler.ResponseDetails
;
import
com.nisum.myteam.model.dao.
Resourc
e
;
import
com.nisum.myteam.model.dao.
Employe
e
;
import
com.nisum.myteam.model.dao.ResourceAllocation
;
import
com.nisum.myteam.model.vo.ResourceVO
;
import
com.nisum.myteam.repository.EmployeeVisaRepo
;
import
com.nisum.myteam.service.IEmployeeService
;
import
com.nisum.myteam.service.IProjectService
;
import
com.nisum.myteam.service.
I
ResourceAllocationService
;
import
com.nisum.myteam.service.
impl.
ResourceAllocationService
;
import
com.nisum.myteam.utils.MyTeamUtils
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.HttpStatus
;
...
...
@@ -19,11 +21,11 @@ import org.springframework.web.bind.annotation.*;
import
javax.servlet.http.HttpServletRequest
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.List
;
@RestController
@RequestMapping
@Slf4j
public
class
ResourceAllocationController
{
@Autowired
...
...
@@ -36,51 +38,71 @@ public class ResourceAllocationController {
private
EmployeeVisaRepo
employeeVisaRepo
;
@Autowired
private
IResourceAllocationService
resourceAllocationService
;
private
ResourceAllocationService
resourceAllocService
;
//tested in all the cases.ok
@RequestMapping
(
value
=
"/resourceAllocation"
,
method
=
RequestMethod
.
POST
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
,
consumes
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<?>
createResource
(
@RequestBody
ResourceAllocation
resourceAllocationReq
,
@RequestParam
(
value
=
"loginEmpId"
,
required
=
true
)
String
loginEmpId
,
HttpServletRequest
request
)
throws
MyTeamException
{
if
(
StringUtils
.
isNotBlank
(
loginEmpId
))
{
resourceAllocationReq
.
setAuditFields
(
loginEmpId
,
MyTeamUtils
.
CREATE
);
ResourceAllocation
resourcePersisted
=
resourceAllocationService
.
addResourceAllocation
(
resourceAllocationReq
,
loginEmpId
);
ResponseDetails
createResponseDetails
=
new
ResponseDetails
(
new
Date
(),
601
,
"Resource has been created"
,
"Resource description"
,
null
,
request
.
getContextPath
(),
"details"
,
resourcePersisted
);
return
new
ResponseEntity
<
ResponseDetails
>(
createResponseDetails
,
HttpStatus
.
OK
);
}
if
(
resourceAllocService
.
validateBillingStartEndDateAgainstProjectStartEndDate
(
resourceAllocationReq
,
loginEmpId
))
{
if
(
resourceAllocService
.
validateBillingStartDateAgainstDOJ
(
resourceAllocationReq
))
{
if
(!
resourceAllocService
.
isResourceAssignedToAnyProject
(
resourceAllocationReq
))
{
ResourceAllocation
resourcePersisted
=
resourceAllocService
.
addResourceAllocation
(
resourceAllocationReq
,
loginEmpId
);
ResponseDetails
createResponseDetails
=
new
ResponseDetails
(
new
Date
(),
601
,
"Resource has been created"
,
"Resource description"
,
null
,
request
.
getContextPath
(),
"details"
,
resourcePersisted
);
return
new
ResponseEntity
<
ResponseDetails
>(
createResponseDetails
,
HttpStatus
.
OK
);
}
}
}
ResponseDetails
responseDetails
=
new
ResponseDetails
(
new
Date
(),
602
,
resourceAllocService
.
respMap
.
get
(
"message"
).
toString
(),
"Error message desc"
,
null
,
request
.
getRequestURI
(),
"Resource details"
,
resourceAllocationReq
);
return
new
ResponseEntity
<
ResponseDetails
>(
responseDetails
,
HttpStatus
.
OK
);
}
ResponseDetails
responseDetails
=
new
ResponseDetails
(
new
Date
(),
602
,
"Please provide the valid Employee Id"
,
"Employee Id is not valid"
,
null
,
request
.
getRequestURI
(),
"Resource details"
,
resourceAllocationReq
);
return
new
ResponseEntity
<
ResponseDetails
>(
responseDetails
,
HttpStatus
.
OK
);
}
//tested in all the cases.ok
@RequestMapping
(
value
=
"/resourceAllocation"
,
method
=
RequestMethod
.
PUT
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
,
consumes
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<?>
updateResource
(
@RequestBody
ResourceAllocation
resourceReq
,
public
ResponseEntity
<?>
updateResource
(
@RequestBody
ResourceAllocation
resource
Allocation
Req
,
@RequestParam
(
value
=
"loginEmpId"
)
String
loginEmpId
,
HttpServletRequest
request
)
throws
MyTeamException
{
if
(
StringUtils
.
isNotBlank
(
loginEmpId
))
{
resourceReq
.
setAuditFields
(
loginEmpId
,
MyTeamUtils
.
UPDATE
);
HashMap
<
String
,
Object
>
responseMap
=
resourceAllocationService
.
updateResource
(
resourceReq
,
loginEmpId
);
ResponseDetails
createResponseDetails
=
new
ResponseDetails
(
new
Date
(),
601
,
responseMap
.
get
(
"message"
).
toString
(),
"Resource description"
,
null
,
request
.
getContextPath
(),
"Resource details"
,
resourceReq
);
resourceAllocationReq
.
setAuditFields
(
loginEmpId
,
MyTeamUtils
.
UPDATE
);
if
(
resourceAllocService
.
isResourceExistsForProject
(
resourceAllocationReq
.
getEmployeeId
(),
resourceAllocationReq
.
getProjectId
()))
{
resourceAllocService
.
updatePreviousResource
(
resourceAllocationReq
,
loginEmpId
);
resourceAllocService
.
updateResource
(
resourceAllocationReq
,
loginEmpId
);
}
ResponseDetails
createResponseDetails
=
new
ResponseDetails
(
new
Date
(),
601
,
resourceAllocService
.
respMap
.
get
(
"message"
).
toString
(),
"Resource description"
,
null
,
request
.
getContextPath
(),
"Resource details"
,
resourceAllocationReq
);
return
new
ResponseEntity
<
ResponseDetails
>(
createResponseDetails
,
HttpStatus
.
OK
);
}
ResponseDetails
responseDetails
=
new
ResponseDetails
(
new
Date
(),
602
,
"Please provide the valid Employee Id"
,
"Employee Id is not valid"
,
null
,
request
.
getRequestURI
(),
"Resource details"
,
resourceReq
);
"Employee Id is not valid"
,
null
,
request
.
getRequestURI
(),
"Resource details"
,
resource
Allocation
Req
);
return
new
ResponseEntity
<
ResponseDetails
>(
responseDetails
,
HttpStatus
.
OK
);
}
//Tested Ok
@RequestMapping
(
value
=
"/resourceAllocation"
,
method
=
RequestMethod
.
DELETE
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
,
consumes
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<?>
deleteResource
(
@RequestBody
Resource
resourceReq
,
public
ResponseEntity
<?>
deleteResource
(
@RequestBody
Resource
Allocation
resourceReq
,
@RequestParam
(
value
=
"loginEmpId"
,
required
=
true
)
String
loginEmpId
,
HttpServletRequest
request
)
throws
MyTeamException
{
if
(
StringUtils
.
isNotBlank
(
loginEmpId
))
{
Resource
resourceDeleted
=
resourceAllocationService
.
deleteResource
(
resourceReq
.
getEmployeeId
(),
resourceReq
.
getProjectId
(),
resourceReq
.
getId
()
,
loginEmpId
);
resourceAllocService
.
deleteResource
(
resourceReq
,
loginEmpId
);
ResponseDetails
createResponseDetails
=
new
ResponseDetails
(
new
Date
(),
601
,
"Resource has been deleted"
,
"Resource description"
,
null
,
request
.
getContextPath
(),
"Resource details"
,
resource
Deleted
);
"Resource description"
,
null
,
request
.
getContextPath
(),
"Resource details"
,
resource
Req
);
return
new
ResponseEntity
<
ResponseDetails
>(
createResponseDetails
,
HttpStatus
.
OK
);
}
...
...
@@ -89,12 +111,68 @@ public class ResourceAllocationController {
return
new
ResponseEntity
<
ResponseDetails
>(
responseDetails
,
HttpStatus
.
OK
);
}
//Ok Tested in all of the cases
@RequestMapping
(
value
=
"/resourceAllocation/project/{projectId}"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<?>
getResourcesForProject
(
@PathVariable
(
value
=
"projectId"
,
required
=
true
)
String
projectId
,
@RequestParam
(
value
=
"status"
,
required
=
false
,
defaultValue
=
MyTeamUtils
.
ACTIVE
)
String
status
,
HttpServletRequest
request
)
throws
MyTeamException
{
if
(
StringUtils
.
isNotBlank
(
projectId
))
{
List
<
ResourceVO
>
resourcesList
=
resourceAllocService
.
getResourcesForProject
(
projectId
,
status
);
ResponseDetails
responseDetails
=
new
ResponseDetails
(
new
Date
(),
602
,
"Resources have been retrieved successfully"
,
"List of Resources for a project"
,
resourcesList
,
request
.
getRequestURI
(),
"Resource details"
,
null
);
return
new
ResponseEntity
<
ResponseDetails
>(
responseDetails
,
HttpStatus
.
OK
);
}
ResponseDetails
responseDetails
=
new
ResponseDetails
(
new
Date
(),
602
,
"Please provide ProjectId"
,
"List of Resources for a project"
,
null
,
request
.
getRequestURI
(),
"Resource details"
,
null
);
return
new
ResponseEntity
<
ResponseDetails
>(
responseDetails
,
HttpStatus
.
OK
);
}
//ok
///getMyProjectAllocations
@RequestMapping
(
value
=
"/resourceAllocation/getMyProjectAllocations"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<?>
getMyProjectAllocations
(
@RequestParam
(
"employeeId"
)
String
employeeId
,
HttpServletRequest
request
)
throws
MyTeamException
{
if
(
employeeId
!=
null
&&
!
""
.
equalsIgnoreCase
(
employeeId
))
{
ResponseDetails
getRespDetails
=
new
ResponseDetails
(
new
Date
(),
604
,
"Retrieved the project allocations successfully"
,
"Projects allocations for an employee"
,
resourceAllocService
.
getWorkedProjectsForResource
(
employeeId
),
request
.
getRequestURI
(),
"Project details"
,
null
);
return
new
ResponseEntity
<
ResponseDetails
>(
getRespDetails
,
HttpStatus
.
OK
);
}
ResponseDetails
getRespDetails
=
new
ResponseDetails
(
new
Date
(),
606
,
"Please Provide valid employee id"
,
"Project allocations for an employee"
,
null
,
request
.
getRequestURI
(),
"Project details"
,
null
);
return
new
ResponseEntity
<
ResponseDetails
>(
getRespDetails
,
HttpStatus
.
OK
);
}
//ok
///resourceAllocation/projects has to be changed to /resourceAllocation/activeProjects
@RequestMapping
(
value
=
"/resourceAllocation/projects"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<?>
getResourcesAllocatedForAllProjects
(
HttpServletRequest
request
)
throws
MyTeamException
{
List
<
ResourceAllocation
>
resourcesList
=
resourceAllocService
.
getAllResourcesForAllActiveProjects
();
ResponseDetails
responseDetails
=
new
ResponseDetails
(
new
Date
(),
602
,
"Resources have been retrieved successfully"
,
"List of Resources for the projects"
,
resourcesList
,
request
.
getRequestURI
(),
"Resource details"
,
null
);
return
new
ResponseEntity
<
ResponseDetails
>(
responseDetails
,
HttpStatus
.
OK
);
}
//ok //Getting Current active resource record
@RequestMapping
(
value
=
"/resourceAllocation/employeeId/{employeeId}"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<?>
getResourcesSortByProjectStartDate
(
@PathVariable
(
value
=
"employeeId"
,
required
=
true
)
String
employeeId
,
HttpServletRequest
request
)
throws
MyTeamException
{
if
(
StringUtils
.
isNotBlank
(
employeeId
))
{
List
<
ResourceAllocation
>
resourcesList
=
resourceAlloc
ationService
.
getResourcesSortByProject
StartDate
(
employeeId
);
List
<
ResourceAllocation
>
resourcesList
=
resourceAlloc
Service
.
getResourcesSortByBilling
StartDate
(
employeeId
);
ResponseDetails
responseDetails
=
new
ResponseDetails
(
new
Date
(),
602
,
"Resources have been retrieved successfully"
,
"List of Resources for an employee"
,
resourcesList
,
request
.
getRequestURI
(),
"Resource List details"
,
null
);
return
new
ResponseEntity
<
ResponseDetails
>(
responseDetails
,
HttpStatus
.
OK
);
...
...
@@ -105,25 +183,78 @@ public class ResourceAllocationController {
return
new
ResponseEntity
<
ResponseDetails
>(
responseDetails
,
HttpStatus
.
OK
);
}
//
// @RequestMapping(value = "/resources/active", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
// public ResponseEntity<?> getActiveResources(@RequestParam(value = "employeeId", required = false) String employeeId, HttpServletRequest request)
// throws MyTeamException {
// if (StringUtils.isNotBlank(employeeId)) {
// List<Resource> employeesRoles = resourceService.getActiveResources(employeeId);
//
// ResponseDetails responseDetails = new ResponseDetails(new Date(), 602, "Resources have been retrieved successfully",
// "List of Resources who are active in the projects", employeesRoles, request.getRequestURI(), "Resource List details", null);
// return new ResponseEntity<ResponseDetails>(responseDetails, HttpStatus.OK);
//
// }
// ResponseDetails responseDetails = new ResponseDetails(new Date(), 602, "Please provide the valid Employee Id",
// "Employee Id is not valid", null, request.getRequestURI(), "Resource details", null);
// return new ResponseEntity<ResponseDetails>(responseDetails, HttpStatus.OK);
// }
//
//
// @RequestMapping(value = "/resources/shifts/{shift}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
//ok tested
@RequestMapping
(
value
=
"/resourceAllocation/active"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<?>
getActiveResources
(
@RequestParam
(
value
=
"employeeId"
,
required
=
false
)
String
employeeId
,
HttpServletRequest
request
)
throws
MyTeamException
{
if
(
StringUtils
.
isNotBlank
(
employeeId
))
{
List
<
ResourceAllocation
>
employeesRoles
=
resourceAllocService
.
getActiveResources
(
employeeId
);
ResponseDetails
responseDetails
=
new
ResponseDetails
(
new
Date
(),
602
,
"Resources have been retrieved successfully"
,
"List of Resources who are active in the projects"
,
employeesRoles
,
request
.
getRequestURI
(),
"Resource List details"
,
null
);
return
new
ResponseEntity
<
ResponseDetails
>(
responseDetails
,
HttpStatus
.
OK
);
}
ResponseDetails
responseDetails
=
new
ResponseDetails
(
new
Date
(),
602
,
"Please provide the valid Employee Id"
,
"Employee Id is not valid"
,
null
,
request
.
getRequestURI
(),
"Resource details"
,
null
);
return
new
ResponseEntity
<
ResponseDetails
>(
responseDetails
,
HttpStatus
.
OK
);
}
//ok working
@RequestMapping
(
value
=
"/resourceAllocation/deliverylead/{deliveryLeadId}"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<?>
getTeamDetails
(
@PathVariable
(
value
=
"deliveryLeadId"
,
required
=
true
)
String
deliveryLeadId
,
HttpServletRequest
request
)
throws
MyTeamException
{
if
(
StringUtils
.
isNotBlank
(
deliveryLeadId
))
{
List
<
ResourceAllocation
>
resourcesList
=
resourceAllocService
.
getResourcesUnderDeliveryLead
(
deliveryLeadId
);
ResponseDetails
responseDetails
=
new
ResponseDetails
(
new
Date
(),
602
,
"Resources have been retrieved successfully"
,
"List of Resources for a Delivery Lead"
,
resourcesList
,
request
.
getRequestURI
(),
"Resource details"
,
null
);
return
new
ResponseEntity
<
ResponseDetails
>(
responseDetails
,
HttpStatus
.
OK
);
}
ResponseDetails
responseDetails
=
new
ResponseDetails
(
new
Date
(),
602
,
"Please provide Valid Delivery Lead Id"
,
"List of Resources for DeliveryLead"
,
null
,
request
.
getRequestURI
(),
"Resource details"
,
null
);
return
new
ResponseEntity
<
ResponseDetails
>(
responseDetails
,
HttpStatus
.
OK
);
}
//ok tested working
@RequestMapping
(
value
=
"/resourceAllocation/unAssignedEmployees"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<?>
getUnAssignedEmployees
(
HttpServletRequest
request
)
throws
MyTeamException
{
List
<
Employee
>
employeesList
=
resourceAllocService
.
getUnAssignedEmployees
();
ResponseDetails
responseDetails
=
new
ResponseDetails
(
new
Date
(),
602
,
"Resources have been retrieved successfully"
,
"List of Resources who are not assigned to project"
,
employeesList
,
request
.
getRequestURI
(),
"Resource details"
,
null
);
return
new
ResponseEntity
<
ResponseDetails
>(
responseDetails
,
HttpStatus
.
OK
);
}
//@RequestMapping(value = "/getEmployeeBillingDetailsAll"
@RequestMapping
(
value
=
"/resourceAllocation/billing"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
List
<
ResourceAllocation
>>
getAllBillingsForEmployee
(
@RequestParam
(
"employeeId"
)
String
employeeId
)
throws
MyTeamException
{
List
<
ResourceAllocation
>
resourceAllocList
=
resourceAllocService
.
getBillingsForEmployee
(
employeeId
);
return
new
ResponseEntity
<>(
resourceAllocList
,
HttpStatus
.
OK
);
}
// @RequestMapping(value = "/getEmployeeBillingDetails"
@RequestMapping
(
value
=
"/resourceAllocation/billing/project/{projectId}"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
List
<
ResourceAllocation
>>
getBillingsForProject
(
@PathVariable
(
"projectId"
)
String
projectId
,
@RequestParam
(
"employeeId"
)
String
employeeId
)
throws
MyTeamException
{
List
<
ResourceAllocation
>
resourceAllocList
=
resourceAllocService
.
getBillingsForProject
(
employeeId
,
projectId
);
return
new
ResponseEntity
<>(
resourceAllocList
,
HttpStatus
.
OK
);
}
// @RequestMapping(value = "/resources/shifts/{shift}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
// public ResponseEntity<?> getResourcesForShift(@PathVariable(value = "shift", required = true) String shift, HttpServletRequest request)
// throws MyTeamException {
//
...
...
@@ -138,116 +269,15 @@ public class ResourceAllocationController {
// return new ResponseEntity<ResponseDetails>(responseDetails, HttpStatus.OK);
//
// }
//
// @RequestMapping(value = "/resources/projects", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
// public ResponseEntity<?> getResourcesAllocatedForAllProjects(HttpServletRequest request) throws MyTeamException {
//
// List<Resource> resourcesList = resourceService.getResourcesForActiveProjects();
// ResponseDetails responseDetails = new ResponseDetails(new Date(), 602, "Resources have been retrieved successfully",
// "List of Resources for the projects", resourcesList, request.getRequestURI(), "Resource details", null);
// return new ResponseEntity<ResponseDetails>(responseDetails, HttpStatus.OK);
//
// }
//
// @RequestMapping(value = "/resources/project/{projectId}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
// public ResponseEntity<?> getResourcesForProject(@PathVariable(value = "projectId", required = true) String projectId,
// @RequestParam(value = "status", required = false, defaultValue = MyTeamUtils.ACTIVE) String status,
// HttpServletRequest request)
// throws MyTeamException {
//
// if (StringUtils.isNotBlank(projectId)) {
// List<Resource> resourcesList = resourceService.getResourcesForProject(projectId, status);
// ResponseDetails responseDetails = new ResponseDetails(new Date(), 602, "Resources have been retrieved successfully",
// "List of Resources for a project", resourcesList, request.getRequestURI(), "Resource details", null);
// return new ResponseEntity<ResponseDetails>(responseDetails, HttpStatus.OK);
//
// }
// ResponseDetails responseDetails = new ResponseDetails(new Date(), 602, "Please provide ProjectId",
// "List of Resources for a project", null, request.getRequestURI(), "Resource details", null);
// return new ResponseEntity<ResponseDetails>(responseDetails, HttpStatus.OK);
// }
//
//
// @RequestMapping(value = "/resources/deliverylead/{deliveryLeadId}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
// public ResponseEntity<?> getTeamDetails(@PathVariable(value = "deliveryLeadId", required = true) String deliveryLeadId, HttpServletRequest request)
// throws MyTeamException {
//
// if (StringUtils.isNotBlank(deliveryLeadId)) {
// List<Resource> resourcesList = resourceService.getResourcesUnderDeliveryLead(deliveryLeadId);
//
// ResponseDetails responseDetails = new ResponseDetails(new Date(), 602, "Resources have been retrieved successfully",
// "List of Resources for a project", resourcesList, request.getRequestURI(), "Resource details", null);
// }
//
// ResponseDetails responseDetails = new ResponseDetails(new Date(), 602, "Please provide Valid Delivery Lead Id",
// "List of Resources for DeliveryLead", null, request.getRequestURI(), "Resource details", null);
// return new ResponseEntity<ResponseDetails>(responseDetails, HttpStatus.OK);
//
// }
//
//
// @RequestMapping(value = "resources/unAssignedEmployees", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
// public ResponseEntity<?> getUnAssignedEmployees(HttpServletRequest request) throws MyTeamException {
// List<Employee> employeesList = projectService.getUnAssignedEmployees();
//
// ResponseDetails responseDetails = new ResponseDetails(new Date(), 602, "Resources have been retrieved successfully",
// "List of Resources who are not assigned to project", employeesList, request.getRequestURI(), "Resource details", null);
// return new ResponseEntity<ResponseDetails>(responseDetails, HttpStatus.OK);
// }
//
//
// @RequestMapping(value = "/getEmployeesDashBoard", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
// public ResponseEntity<?> getEmployeesDashBoard(HttpServletRequest request) throws MyTeamException {
// List<EmployeeDashboardVO> employeeDashBoardList = projectService.getEmployeesDashBoard();
//
// ResponseDetails responseDetails = new ResponseDetails(new Date(), 602, "Resources have been retrieved successfully",
// "List of Resources for dashboard", employeeDashBoardList, request.getRequestURI(), "Resource details", null);
// return new ResponseEntity<ResponseDetails>(responseDetails, HttpStatus.OK);
// }
//
// @RequestMapping(value = "/getEmployeesHavingVisa", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
// public ResponseEntity<?> getEmployeesHavingVisa(@RequestParam("visa") String passport,HttpServletRequest request)
// throws MyTeamException {
// List<Employee> employees = new ArrayList<>();
//
// if (passport != null && !"passport".equalsIgnoreCase(passport)) {
//
// List<EmployeeVisa> employeeVisas = employeeVisaRepo.findByVisaName(passport);
//
// List<String> employeeIds = null;
// if (employeeVisas != null) {
// employeeIds = employeeVisas.stream().map(EmployeeVisa::getEmployeeId).collect(Collectors.toList());
// }
// if (employeeIds != null && !employeeIds.isEmpty()) {
// List<Employee> emps = employeeService.getActiveEmployees();
// for (Employee emp : emps) {
// if (employeeIds.contains(emp.getEmployeeId())) {
// employees.add(emp);
// }
// }
// }
// } else {
// if (employeeService.getActiveEmployees() != null) {
// employees = employeeService.getActiveEmployees().stream()
// .sorted((o1, o2) -> o1.getEmployeeName().compareTo(o2.getEmployeeName()))
// .collect(Collectors.toList());
// }
//
// }
//
// ResponseDetails responseDetails = new ResponseDetails(new Date(), 602, "Resources have been retrieved successfully",
// "List of Resources who has visa", employees, request.getRequestURI(), "Resource details", null);
// return new ResponseEntity<ResponseDetails>(responseDetails, HttpStatus.OK);
//
// }
//
//
// @RequestMapping(value = "/addEmployeeToTeamWithCheck", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
// public ResponseEntity<?> addEmployeeToTeamWithCheck(@RequestBody Resource resourceReq,
// @RequestMapping(value = "/resourceAllocation/addEmployeeToTeamWithCheck", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
// public ResponseEntity<?> addEmployeeToTeamWithCheck(@RequestBody ResourceAllocation resourceReq,
// @RequestParam(value = "loginEmpId") String loginEmpId, HttpServletRequest request) throws MyTeamException {
//
// if (StringUtils.isNotBlank(loginEmpId)) {
// HashMap<String, Object> responseMap =
project
Service.verifyResourceAssignedToAnyProject(resourceReq, loginEmpId);
// HashMap<String, Object> responseMap =
resourceAlloc
Service.verifyResourceAssignedToAnyProject(resourceReq, loginEmpId);
//
// ResponseDetails responseDetails = new ResponseDetails(new Date(), 602, responseMap.get("message").toString(),
// "List of Resources for dashboard", responseMap.get("resourceObj"), request.getRequestURI(), "Resource details", null);
...
...
@@ -259,5 +289,4 @@ public class ResourceAllocationController {
//
// }
}
src/main/java/com/nisum/myteam/controller/ResourceController.java
View file @
fed165ca
...
...
@@ -42,6 +42,7 @@ public class ResourceController {
private
IResourceService
resourceService
;
@RequestMapping
(
value
=
"/resources"
,
method
=
RequestMethod
.
POST
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
,
consumes
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<?>
createResource
(
@RequestBody
Resource
resourceReq
,
@RequestParam
(
value
=
"loginEmpId"
,
required
=
true
)
String
loginEmpId
,
HttpServletRequest
request
)
throws
MyTeamException
{
...
...
@@ -190,63 +191,27 @@ public class ResourceController {
}
@RequestMapping
(
value
=
"resources/unAssignedEmployees"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<?>
getUnAssignedEmployees
(
HttpServletRequest
request
)
throws
MyTeamException
{
List
<
Employee
>
employeesList
=
projectService
.
getUnAssignedEmployees
();
ResponseDetails
responseDetails
=
new
ResponseDetails
(
new
Date
(),
602
,
"Resources have been retrieved successfully"
,
"List of Resources who are not assigned to project"
,
employeesList
,
request
.
getRequestURI
(),
"Resource details"
,
null
);
return
new
ResponseEntity
<
ResponseDetails
>(
responseDetails
,
HttpStatus
.
OK
);
}
@RequestMapping
(
value
=
"/getEmployeesDashBoard"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<?>
getEmployeesDashBoard
(
HttpServletRequest
request
)
throws
MyTeamException
{
List
<
EmployeeDashboardVO
>
employeeDashBoardList
=
projectService
.
getEmployeesDashBoard
();
ResponseDetails
responseDetails
=
new
ResponseDetails
(
new
Date
(),
602
,
"Resources have been retrieved successfully"
,
"List of Resources for dashboard"
,
employeeDashBoardList
,
request
.
getRequestURI
(),
"Resource details"
,
null
);
return
new
ResponseEntity
<
ResponseDetails
>(
responseDetails
,
HttpStatus
.
OK
);
}
@RequestMapping
(
value
=
"/getEmployeesHavingVisa"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<?>
getEmployeesHavingVisa
(
@RequestParam
(
"visa"
)
String
passport
,
HttpServletRequest
request
)
throws
MyTeamException
{
List
<
Employee
>
employees
=
new
ArrayList
<>();
if
(
passport
!=
null
&&
!
"passport"
.
equalsIgnoreCase
(
passport
))
{
List
<
EmployeeVisa
>
employeeVisas
=
employeeVisaRepo
.
findByVisaName
(
passport
);
List
<
String
>
employeeIds
=
null
;
if
(
employeeVisas
!=
null
)
{
employeeIds
=
employeeVisas
.
stream
().
map
(
EmployeeVisa:
:
getEmployeeId
).
collect
(
Collectors
.
toList
());
}
if
(
employeeIds
!=
null
&&
!
employeeIds
.
isEmpty
())
{
List
<
Employee
>
emps
=
employeeService
.
getActiveEmployees
();
for
(
Employee
emp
:
emps
)
{
if
(
employeeIds
.
contains
(
emp
.
getEmployeeId
()))
{
employees
.
add
(
emp
);
}
}
}
}
else
{
if
(
employeeService
.
getActiveEmployees
()
!=
null
)
{
employees
=
employeeService
.
getActiveEmployees
().
stream
()
.
sorted
((
o1
,
o2
)
->
o1
.
getEmployeeName
().
compareTo
(
o2
.
getEmployeeName
()))
.
collect
(
Collectors
.
toList
());
}
}
ResponseDetails
responseDetails
=
new
ResponseDetails
(
new
Date
(),
602
,
"Resources have been retrieved successfully"
,
"List of Resources who has visa"
,
employees
,
request
.
getRequestURI
(),
"Resource details"
,
null
);
return
new
ResponseEntity
<
ResponseDetails
>(
responseDetails
,
HttpStatus
.
OK
);
}
@RequestMapping
(
value
=
"/addEmployeeToTeamWithCheck"
,
method
=
RequestMethod
.
POST
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
,
consumes
=
MediaType
.
APPLICATION_JSON_VALUE
)
// @RequestMapping(value = "resources/unAssignedEmployees", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
// public ResponseEntity<?> getUnAssignedEmployees(HttpServletRequest request) throws MyTeamException {
// List<Employee> employeesList = projectService.getUnAssignedEmployees();
//
// ResponseDetails responseDetails = new ResponseDetails(new Date(), 602, "Resources have been retrieved successfully",
// "List of Resources who are not assigned to project", employeesList, request.getRequestURI(), "Resource details", null);
// return new ResponseEntity<ResponseDetails>(responseDetails, HttpStatus.OK);
// }
//
//
// @RequestMapping(value = "/resources/getEmployeesDashBoard", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
// public ResponseEntity<?> getEmployeesDashBoard(HttpServletRequest request) throws MyTeamException {
// List<EmployeeDashboardVO> employeeDashBoardList = projectService.getEmployeesDashBoard();
//
// ResponseDetails responseDetails = new ResponseDetails(new Date(), 602, "Resources have been retrieved successfully",
// "List of Resources for dashboard", employeeDashBoardList, request.getRequestURI(), "Resource details", null);
// return new ResponseEntity<ResponseDetails>(responseDetails, HttpStatus.OK);
// }
@RequestMapping
(
value
=
"resources/addEmployeeToTeamWithCheck"
,
method
=
RequestMethod
.
POST
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
,
consumes
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<?>
addEmployeeToTeamWithCheck
(
@RequestBody
Resource
resourceReq
,
@RequestParam
(
value
=
"loginEmpId"
)
String
loginEmpId
,
HttpServletRequest
request
)
throws
MyTeamException
{
...
...
src/main/java/com/nisum/myteam/model/dao/Employee.java
View file @
fed165ca
...
...
@@ -7,6 +7,7 @@ import javax.validation.constraints.NotNull;
import
javax.validation.constraints.Pattern
;
import
javax.validation.constraints.Size
;
import
org.bson.types.ObjectId
;
import
org.hibernate.validator.constraints.Email
;
import
org.hibernate.validator.constraints.NotBlank
;
import
org.springframework.data.annotation.Id
;
...
...
@@ -31,7 +32,7 @@ public class Employee implements Serializable {
private
static
final
long
serialVersionUID
=
1L
;
@Id
private
String
id
;
private
ObjectId
id
;
@NotBlank
(
message
=
"Employee Id cannot be blank"
)
...
...
src/main/java/com/nisum/myteam/model/dao/Project.java
View file @
fed165ca
...
...
@@ -32,7 +32,6 @@ public class Project extends AuditFields implements Serializable {
private
String
projectId
;
private
String
projectName
;
private
String
domainId
;
private
String
domain
;
private
String
accountId
;
private
String
status
;
private
List
<
String
>
employeeIds
;
...
...
src/main/java/com/nisum/myteam/model/dao/ResourceAllocation.java
View file @
fed165ca
...
...
@@ -27,28 +27,20 @@ public class ResourceAllocation extends AuditFields implements Serializable {
private
String
employeeId
;
private
String
projectId
;
private
String
projectName
;
//
private String projectName;
@DateTimeFormat
(
iso
=
ISO
.
DATE
)
private
String
billableStatus
;
@DateTimeFormat
(
iso
=
ISO
.
DATE
)
@DateTimeFormat
(
iso
=
ISO
.
DATE
,
pattern
=
"yyyy-MM-dd'T'HH:mm:ss.SSSX"
)
private
Date
billingStartDate
;
@DateTimeFormat
(
iso
=
ISO
.
DATE
)
@DateTimeFormat
(
iso
=
ISO
.
DATE
,
pattern
=
"yyyy-MM-dd'T'HH:mm:ss.SSSX"
)
private
Date
billingEndDate
;
//private boolean active;
// private String role;
// @DateTimeFormat(iso = ISO.DATE)
// private Date projectStartDate;
//
// @DateTimeFormat(iso = ISO.DATE)
// private Date projectEndDate;
// private boolean active;
private
String
resourceRole
;
}
src/main/java/com/nisum/myteam/repository/ResourceAllocationRepo.java
View file @
fed165ca
...
...
@@ -11,13 +11,13 @@ import java.util.List;
public
interface
ResourceAllocationRepo
extends
MongoRepository
<
ResourceAllocation
,
String
>
{
List
<
Resource
>
findByProjectId
(
String
projectId
);
List
<
Resource
Allocation
>
findByProjectId
(
String
projectId
);
List
<
Resource
>
findByEmployeeId
(
String
employeeId
);
List
<
Resource
Allocation
>
findByEmployeeId
(
String
employeeId
);
Resource
findById
(
ObjectId
id
);
Resource
Allocation
findById
(
ObjectId
id
);
Resource
findByEmployeeIdAndProjectId
(
String
employeeId
,
String
projectId
);
List
<
ResourceAllocation
>
findByEmployeeIdAndProjectId
(
String
employeeId
,
String
projectId
);
// List<Resource> findByEmployeeIdAndActive(String employeeId, boolean status);
...
...
src/main/java/com/nisum/myteam/service/IDashboardService.java
View file @
fed165ca
package
com
.
nisum
.
myteam
.
service
;
public
class
IDashboardService
{
import
com.nisum.myteam.model.vo.EmployeeDashboardVO
;
import
java.util.List
;
public
interface
IDashboardService
{
public
List
<
EmployeeDashboardVO
>
getEmployeesDashBoard
();
}
src/main/java/com/nisum/myteam/service/IEmployeeService.java
View file @
fed165ca
package
com
.
nisum
.
myteam
.
service
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Set
;
import
org.springframework.stereotype.Service
;
import
com.nisum.myteam.exception.handler.MyTeamException
;
import
com.nisum.myteam.model.dao.Account
;
import
com.nisum.myteam.model.dao.Employee
;
import
org.springframework.stereotype.Service
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Set
;
@Service
public
interface
IEmployeeService
{
boolean
isEmployeeExistsById
(
String
employeeId
);
boolean
isEmployeeExistsById
(
String
employeeId
);
Employee
createEmployee
(
Employee
employeeRoles
,
String
empId
)
throws
MyTeamException
;
Employee
updateEmployee
(
Employee
employeeRoles
,
String
empId
);
Employee
createEmployee
(
Employee
employeeRoles
,
String
empId
)
throws
MyTeamException
;
Employee
deleteEmployee
(
String
empId
)
;
Employee
updateEmployee
(
Employee
employeeRoles
,
String
empId
)
;
Employee
updateProfile
(
Employee
employeeRoles
)
throws
MyTeamException
;
Employee
deleteEmployee
(
String
empId
);
Employee
getEmployeeById
(
String
empId
);
Employee
updateProfile
(
Employee
employeeRoles
)
throws
MyTeamException
;
Employee
getEmployeeByEmaillId
(
String
emailId
)
;
Employee
getEmployeeById
(
String
empId
)
;
List
<
Employee
>
getManagers
()
throws
MyTeamException
;
Employee
getEmployeeByEmaillId
(
String
emailId
)
;
List
<
Employee
>
getActiveEmployees
()
throws
MyTeamException
;
List
<
Employee
>
getManagers
()
throws
MyTeamException
;
List
<
Employee
>
getEmployeesByStatus
(
String
status
)
;
List
<
Employee
>
getActiveEmployee
s
()
throws
MyTeamException
;
List
<
Account
>
getAccount
s
()
throws
MyTeamException
;
List
<
Employee
>
getEmployeesByStatus
(
String
status
);
Employee
getEmployeeRoleDataForSearchCriteria
(
String
searchId
,
String
searchAttribute
);
List
<
Account
>
getAccounts
()
throws
MyTeamException
;
List
<
String
>
getEmployeeDetailsForAutocomplete
()
;
Employee
getEmployeeRoleDataForSearchCriteria
(
String
searchId
,
String
searchAttribute
);
List
<
HashMap
<
String
,
String
>>
getDeliveryLeads
(
String
domainId
);
List
<
String
>
getEmployeeDetailsForAutocomplete
(
);
List
<
Employee
>
getEmployeesByFunctionalGrp
(
String
functionalGrp
);
List
<
HashMap
<
String
,
String
>>
getDeliveryLeads
(
String
domainId
);
boolean
verifyEmployeeRole
(
String
empId
,
String
roleName
);
List
<
Employee
>
getEmployeesByFunctionalGrp
(
String
functionalGrp
);
List
<
Employee
>
getEmployeesFromList
(
Set
<
String
>
empIdsSet
);
boolean
verifyEmployeeRole
(
String
empId
,
String
roleName
);
List
<
HashMap
<
String
,
String
>>
getDeliveryManagerMap
(
List
deliveryManagerIdsList
);
List
<
Employee
>
getEmployeesFromList
(
Set
<
String
>
empIdsSet
);
List
<
HashMap
<
String
,
String
>>
getDeliveryManagerMap
(
List
deliveryManagerIdsList
);
public
List
<
Employee
>
getAllEmployees
();
public
List
<
Employee
>
getAllEmployees
();
}
src/main/java/com/nisum/myteam/service/IProjectService.java
View file @
fed165ca
...
...
@@ -16,10 +16,22 @@ public interface IProjectService {
void
deleteProject
(
String
projectId
);
List
<
Project
>
getProjectsUnderDomain
(
String
domainId
);
public
boolean
isProjectExistsByName
(
String
projectName
);
public
boolean
isProjectExistsById
(
String
projectId
);
public
Project
getProjectByProjectId
(
String
projectId
);
public
long
getProjectsCount
();
public
List
<
Project
>
getAllProjects
();
List
<
HashMap
<
Object
,
Object
>>
getProjects
()
throws
MyTeamException
;
public
List
<
Project
>
getOnlyActiveProjects
();
List
<
Project
>
getProjectsUnderDomain
(
String
domainId
);
List
<
Project
>
getProjectsUnderDeliveryLead
(
String
managerId
)
throws
MyTeamException
;
public
Resource
addNewBeanchAllocation
(
Employee
employee
,
String
loginEmpId
);
...
...
@@ -28,37 +40,23 @@ public interface IProjectService {
String
generatePdfReport
(
long
id
,
String
fromDate
,
String
toDate
)
throws
MyTeamException
;
List
<
Resource
>
getResourcesUnderProject
(
String
empId
);
List
<
Employee
>
getUnAssignedEmployees
();
public
List
<
EmployeeDashboardVO
>
getEmployeesDashBoard
();
public
List
<
HashMap
<
Object
,
Object
>>
getProjectsForEmployee
(
String
empId
);
//
public List<HashMap<Object, Object>> getProjectsForEmployee(String empId);
public
Set
<
String
>
accountsAssignedToDl
(
String
empId
);
public
List
<
HashMap
<
Object
,
Object
>>
deliveryLeadProjects
(
String
empId
)
throws
MyTeamException
;
public
List
<
Project
>
getAllProjects
();
public
boolean
isProjectExists
(
String
projectName
);
public
boolean
isProjectExistsById
(
String
projectId
);
public
long
getProjectsCount
();
public
Account
getProjectAccount
(
String
accountId
);
public
Account
updateProjSeqinAccount
(
Account
account
)
throws
MyTeamException
;
public
List
<
HashMap
<
Object
,
Object
>>
getRoleBasedProjects
(
String
empId
)
throws
MyTeamException
;
public
List
<
HashMap
<
Object
,
Object
>>
getProjectsInsteadOfRole
()
throws
MyTeamException
;
public
List
<
Project
>
getProjectsForDeliveryLead
(
String
deliveryLeadId
);
public
Project
getProjectByProjectId
(
String
project
Id
);
List
<
Resource
>
getResourcesUnderProject
(
String
emp
Id
);
}
src/main/java/com/nisum/myteam/service/IResourceAllocationService.java
View file @
fed165ca
...
...
@@ -4,6 +4,8 @@ import com.nisum.myteam.exception.handler.MyTeamException;
import
com.nisum.myteam.model.dao.Employee
;
import
com.nisum.myteam.model.dao.Resource
;
import
com.nisum.myteam.model.dao.ResourceAllocation
;
import
com.nisum.myteam.model.vo.MyProjectAllocationVO
;
import
com.nisum.myteam.model.vo.ResourceVO
;
import
org.bson.types.ObjectId
;
import
java.util.HashMap
;
...
...
@@ -11,31 +13,54 @@ import java.util.List;
public
interface
IResourceAllocationService
{
ResourceAllocation
addResourceAllocation
(
ResourceAllocation
resourceAllocation
,
String
loginEmpId
)
throws
MyTeamException
;
HashMap
<
String
,
Object
>
updateResource
(
ResourceAllocation
resourceAllocation
,
String
loginEmpId
)
throws
MyTeamException
;
void
updateResource
(
ResourceAllocation
resourceAllocation
,
String
loginEmpId
)
throws
MyTeamException
;
void
deleteResource
(
ResourceAllocation
resource
,
String
loginEmpId
);
List
<
ResourceAllocation
>
getAllResourcesForAllActiveProjects
();
// Resource save(Resource resource);
// void addResources(Employee employee, String loginEmpId);
// void inactivateResource(Employee employeeReq, Employee employeeUpdated, String loginEmpId);
List
<
ResourceAllocation
>
getResourcesSortByBillingStartDate
(
String
employeeId
);
// List<Resource> getAllResourcesForProject(String projectId, String status);
// List<Resource> getResourcesForEmployee(String empId);
// List<Resource> getAllResourcesForProject(String projectId);
List
<
ResourceAllocation
>
getActiveResources
(
String
empId
);
// List<Resource> getResourcesForShift(String shift);
public
List
<
ResourceVO
>
getResourcesForProject
(
String
projectId
,
String
statusFlag
);
public
List
<
ResourceAllocation
>
getResourcesUnderDeliveryLead
(
String
empId
);
Resource
deleteResource
(
String
empId
,
String
projectId
,
ObjectId
id
,
String
loginEmpId
);
// Resource save(Resource resource
);
public
List
<
ResourceAllocation
>
getBillingsForEmployee
(
String
empId
);
// void addResources(Employee employee, String loginEmpId);
// void inactivateResource(Employee employeeReq, Employee employeeUpdated, String loginEmp
Id);
public
List
<
ResourceAllocation
>
getBillingsForProject
(
String
empId
,
String
project
Id
);
List
<
ResourceAllocation
>
getResourcesSortByProjectStartDate
(
String
employeeId
);
// List<Resource> getResourcesForProject(String projectId, String status);
// List<Resource> getResourcesForEmploye
e(String empId);
public
List
<
MyProjectAllocationVO
>
getWorkedProjectsForResourc
e
(
String
empId
);
// List<Resource> getResourcesForProject(String projectId);
// List<Resource> getActiveResources(String empId
);
public
List
<
Employee
>
getUnAssignedEmployees
(
);
// List<Resource> getResourcesForActiveProject
s();
public
List
<
ResourceAllocation
>
getAllResource
s
();
// List<Resource> getResourcesForShift(String shift);
// public List<Resource> getResourcesUnderDeliveryLead(String empId);
}
src/main/java/com/nisum/myteam/service/impl/ProjectService.java
View file @
fed165ca
...
...
@@ -3,7 +3,8 @@ package com.nisum.myteam.service.impl;
import
com.nisum.myteam.exception.handler.MyTeamException
;
import
com.nisum.myteam.model.dao.*
;
import
com.nisum.myteam.model.vo.EmployeeDashboardVO
;
import
com.nisum.myteam.repository.*
;
import
com.nisum.myteam.repository.ProjectRepo
;
import
com.nisum.myteam.repository.ResourceRepo
;
import
com.nisum.myteam.service.IAccountService
;
import
com.nisum.myteam.service.IDomainService
;
import
com.nisum.myteam.service.IEmployeeService
;
...
...
@@ -34,7 +35,7 @@ public class ProjectService implements IProjectService {
@Autowired
private
ResourceRepo
resourceRepo
;
@Autowired
private
EmployeeDataService
employeeDataBaseService
;
...
...
@@ -44,218 +45,216 @@ public class ProjectService implements IProjectService {
@Autowired
private
MongoTemplate
mongoTemplate
;
@Autowired
private
IDomainService
domainService
;
@Autowired
private
BillingService
billingService
;
@Autowired
private
ResourceService
resourceService
;
@Autowired
private
EmployeeShiftService
empShiftService
;
@Autowired
private
IEmployeeService
employeeService
;
@Autowired
private
IAccountService
accountService
;
@Override
public
List
<
Project
>
getProjectsUnderDomain
(
String
domainId
)
{
return
projectRepo
.
findByDomainId
(
domainId
);
}
public
boolean
isProjectExists
(
String
projectName
)
{
boolean
isProjectExists
=
false
;
if
(
projectName
!=
null
&&
!
""
.
equalsIgnoreCase
(
projectName
))
{
Project
project
=
projectRepo
.
findByProjectName
(
projectName
);
isProjectExists
=
(
project
==
null
)
?
false
:
true
;
}
return
isProjectExists
;
}
public
boolean
isProjectExistsById
(
String
projectId
)
{
boolean
isProjectExists
=
false
;
if
(
projectId
!=
null
&&
!
""
.
equalsIgnoreCase
(
projectId
))
{
Project
project
=
projectRepo
.
findByProjectId
(
projectId
);
isProjectExists
=
(
project
==
null
)
?
false
:
true
;
}
return
isProjectExists
;
}
public
long
getProjectsCount
()
{
return
projectRepo
.
count
();
}
public
Account
getProjectAccount
(
String
accountId
)
{
Account
account
=
null
;
if
(
accountId
!=
null
&&
!
""
.
equalsIgnoreCase
(
accountId
))
{
return
accountService
.
getAccountById
(
accountId
);
}
return
account
;
}
public
Account
updateProjSeqinAccount
(
Account
account
)
throws
MyTeamException
{
return
accountService
.
updateAccountSequence
(
account
);
}
@Autowired
private
IDomainService
domainService
;
@Autowired
private
BillingService
billingService
;
@Autowired
private
ResourceService
resourceService
;
@Autowired
private
EmployeeShiftService
empShiftService
;
@Autowired
private
IEmployeeService
employeeService
;
@Autowired
private
IAccountService
accountService
;
@Override
public
Project
createProject
(
Project
project
,
String
loginEmpId
)
throws
MyTeamException
{
public
List
<
Project
>
getProjectsUnderDomain
(
String
domainId
)
{
return
projectRepo
.
findByDomainId
(
domainId
);
}
public
boolean
isProjectExistsByName
(
String
projectName
)
{
boolean
isProjectExists
=
false
;
if
(
projectName
!=
null
&&
!
""
.
equalsIgnoreCase
(
projectName
))
{
Project
project
=
projectRepo
.
findByProjectName
(
projectName
);
isProjectExists
=
(
project
==
null
)
?
false
:
true
;
}
return
isProjectExists
;
}
public
boolean
isProjectExistsById
(
String
projectId
)
{
boolean
isProjectExists
=
false
;
if
(
projectId
!=
null
&&
!
""
.
equalsIgnoreCase
(
projectId
))
{
Project
project
=
projectRepo
.
findByProjectId
(
projectId
);
isProjectExists
=
(
project
==
null
)
?
false
:
true
;
}
return
isProjectExists
;
}
public
long
getProjectsCount
()
{
return
projectRepo
.
count
();
}
public
Account
getProjectAccount
(
String
accountId
)
{
Account
account
=
null
;
if
(
accountId
!=
null
&&
!
""
.
equalsIgnoreCase
(
accountId
))
{
return
accountService
.
getAccountById
(
accountId
);
}
return
account
;
}
public
Account
updateProjSeqinAccount
(
Account
account
)
throws
MyTeamException
{
return
accountService
.
updateAccountSequence
(
account
);
}
@Override
public
Project
createProject
(
Project
project
,
String
loginEmpId
)
throws
MyTeamException
{
if
(
project
.
getDomainId
()
==
null
)
{
//List<Domain> domainsList = domainRepo.findByAccountId(project.getAccountId());
List
<
Domain
>
domainsList
=
domainService
.
getDomainsUnderAccount
(
project
.
getAccountId
());
List
<
Domain
>
domainsList
=
domainService
.
getDomainsUnderAccount
(
project
.
getAccountId
());
Domain
savedDomain
=
domainsList
.
get
(
0
);
project
.
setDomainId
(
savedDomain
.
getDomainId
());
project
.
setDomain
(
savedDomain
.
getDomainName
());
//
project.setDomain(savedDomain.getDomainName());
}
project
.
setAuditFields
(
loginEmpId
,
MyTeamUtils
.
CREATE
);
return
projectRepo
.
save
(
project
);
}
@Override
public
Project
updateProject
(
Project
project
,
String
loginEmpId
)
throws
MyTeamException
{
//Inactivate the Project based on endDate
Project
existingProject
=
projectRepo
.
findByProjectId
(
project
.
getProjectId
());
List
<
Resource
>
existingTeammates
=
resourceRepo
.
findByProjectId
(
project
.
getProjectId
());
if
(
project
.
getProjectEndDate
().
compareTo
(
new
Date
())
<=
0
&&
project
.
getProjectEndDate
().
compareTo
(
existingProject
.
getProjectEndDate
())
!=
0
)
{
existingProject
.
setStatus
(
MyTeamUtils
.
IN_ACTIVE
);
existingProject
.
setProjectEndDate
(
project
.
getProjectEndDate
());
existingProject
.
setAuditFields
(
loginEmpId
,
MyTeamUtils
.
UPDATE
);
projectRepo
.
save
(
existingProject
);
for
(
Resource
existingTeammate
:
existingTeammates
)
{
existingTeammate
.
setActive
(
false
);
existingTeammate
.
setEndDate
(
project
.
getProjectEndDate
());
existingTeammate
.
setAuditFields
(
loginEmpId
,
MyTeamUtils
.
UPDATE
);
resourceRepo
.
save
(
existingTeammate
);
Billing
billingDetails
=
new
Billing
();
Resource
newBenchAllocation
=
new
Resource
();
billingDetails
.
setBillableStatus
(
MyTeamUtils
.
BENCH_BILLABILITY_STATUS
);
List
<
Billing
>
listBD
=
billingService
.
getActiveBillings
(
existingTeammate
.
getEmployeeId
(),
existingTeammate
.
getProjectId
());
if
(
listBD
!=
null
&&
!
listBD
.
isEmpty
())
{
Billing
billingDetailsExisting
=
listBD
.
get
(
0
);
billingDetailsExisting
.
setBillingEndDate
(
project
.
getProjectEndDate
());
billingDetailsExisting
.
setActive
(
false
);
billingService
.
updateBilling
(
billingDetailsExisting
,
loginEmpId
);
}
Project
benchProject
=
projectRepo
.
findByProjectId
(
MyTeamUtils
.
BENCH_PROJECT_ID
);
Date
sd
=
project
.
getProjectEndDate
();
billingDetails
.
setBillingStartDate
(
sd
);
billingDetails
.
setAccount
(
MyTeamUtils
.
BENCH_ACCOUNT
);
billingDetails
.
setActive
(
true
);
billingDetails
.
setEmployeeId
(
existingTeammate
.
getEmployeeId
());
billingDetails
.
setEmployeeName
(
existingTeammate
.
getEmployeeName
());
//billingDetails.setCreateDate(new Date());// Commented as added common audit fields
billingDetails
.
setProjectId
(
MyTeamUtils
.
BENCH_PROJECT_ID
);
billingDetails
.
setProjectName
(
MyTeamUtils
.
FREE_POLL
);
if
(
benchProject
!=
null
)
{
billingDetails
.
setBillingEndDate
(
benchProject
.
getProjectEndDate
());
newBenchAllocation
.
setAccountId
(
benchProject
.
getAccountId
());
newBenchAllocation
.
setProjectName
(
benchProject
.
getProjectName
());
newBenchAllocation
.
setDomainId
(
benchProject
.
getDomainId
());
newBenchAllocation
.
setEndDate
(
benchProject
.
getProjectEndDate
());
}
//addEmployeeBillingDetails(billingDetails,loginEmpId);
billingService
.
addBilling
(
billingDetails
,
loginEmpId
);
newBenchAllocation
.
setRole
(
existingTeammate
.
getRole
());
newBenchAllocation
.
setAccount
(
MyTeamUtils
.
BENCH_ACCOUNT
);
newBenchAllocation
.
setShift
(
existingTeammate
.
getShift
());
newBenchAllocation
.
setBillableStatus
(
MyTeamUtils
.
BENCH_BILLABILITY_STATUS
);
newBenchAllocation
.
setDesignation
(
existingTeammate
.
getDesignation
());
newBenchAllocation
.
setEmailId
(
existingTeammate
.
getEmailId
());
newBenchAllocation
.
setEmployeeId
(
existingTeammate
.
getEmployeeId
());
newBenchAllocation
.
setActive
(
true
);
newBenchAllocation
.
setEmployeeName
(
existingTeammate
.
getEmployeeName
());
newBenchAllocation
.
setProjectId
(
MyTeamUtils
.
BENCH_PROJECT_ID
);
newBenchAllocation
.
setStartDate
(
sd
);
newBenchAllocation
.
setAuditFields
(
loginEmpId
,
MyTeamUtils
.
CREATE
);
resourceRepo
.
save
(
newBenchAllocation
);
empShiftService
.
updateEmployeeShift
(
existingTeammate
,
loginEmpId
);
}
return
existingProject
;
}
else
{
Query
query
=
new
Query
(
Criteria
.
where
(
"projectId"
).
is
(
project
.
getProjectId
()));
Update
update
=
new
Update
();
update
.
set
(
"projectName"
,
project
.
getProjectName
());
if
(
project
.
getDeliveryLeadIds
()
!=
null
)
{
update
.
set
(
"deliveryLeadIds"
,
project
.
getDeliveryLeadIds
());
}
/*
* if(project.getManagerIds()!= null) { update.set("managerIds",
* project.getManagerIds()); }
*//*
* else{
* update.set("managerIds",Arrays.asList(project.getManagerId())); }
*/
update
.
set
(
"domain"
,
project
.
getDomain
());
update
.
set
(
"domainId"
,
project
.
getDomainId
());
update
.
set
(
"accountId"
,
project
.
getAccountId
());
update
.
set
(
"status"
,
project
.
getStatus
());
update
.
set
(
"projectStartDate"
,
project
.
getProjectStartDate
());
update
.
set
(
"projectEndDate"
,
project
.
getProjectEndDate
());
FindAndModifyOptions
options
=
new
FindAndModifyOptions
();
//Setting audit fileds
update
.
set
(
"modifiedBy"
,
loginEmpId
);
update
.
set
(
"lastModifiedOn"
,
new
Date
());
options
.
returnNew
(
true
);
options
.
upsert
(
true
);
Project
projectDB
=
mongoTemplate
.
findAndModify
(
query
,
update
,
options
,
Project
.
class
);
List
<
Resource
>
employeeDetails
=
resourceRepo
.
findByProjectId
(
project
.
getProjectId
());
if
(
employeeDetails
!=
null
&&
projectDB
!=
null
)
{
for
(
Resource
teamMate
:
employeeDetails
)
{
// emp.setManagerId(projectDB.getManagerId());
// emp.setManagerName(projectDB.getManagerName());
teamMate
.
setAccountId
(
projectDB
.
getAccountId
());
teamMate
.
setProjectName
(
projectDB
.
getProjectName
());
// MT-79:Maintatin the managerids in List
// emp.setManagerIds(projectDB.getManagerIds());
teamMate
.
setEndDate
(
projectDB
.
getProjectEndDate
());
teamMate
.
setAuditFields
(
loginEmpId
,
MyTeamUtils
.
UPDATE
);
//Setting audit fields
resourceRepo
.
save
(
teamMate
);
public
Project
updateProject
(
Project
project
,
String
loginEmpId
)
throws
MyTeamException
{
//Inactivate the Project based on endDate
Project
existingProject
=
projectRepo
.
findByProjectId
(
project
.
getProjectId
());
List
<
Resource
>
existingTeammates
=
resourceRepo
.
findByProjectId
(
project
.
getProjectId
());
if
(
project
.
getProjectEndDate
().
compareTo
(
new
Date
())
<=
0
&&
project
.
getProjectEndDate
().
compareTo
(
existingProject
.
getProjectEndDate
())
!=
0
)
{
existingProject
.
setStatus
(
MyTeamUtils
.
IN_ACTIVE
);
existingProject
.
setProjectEndDate
(
project
.
getProjectEndDate
());
existingProject
.
setAuditFields
(
loginEmpId
,
MyTeamUtils
.
UPDATE
);
projectRepo
.
save
(
existingProject
);
for
(
Resource
existingTeammate
:
existingTeammates
)
{
existingTeammate
.
setActive
(
false
);
existingTeammate
.
setEndDate
(
project
.
getProjectEndDate
());
existingTeammate
.
setAuditFields
(
loginEmpId
,
MyTeamUtils
.
UPDATE
);
resourceRepo
.
save
(
existingTeammate
);
Billing
billingDetails
=
new
Billing
();
Resource
newBenchAllocation
=
new
Resource
();
billingDetails
.
setBillableStatus
(
MyTeamUtils
.
BENCH_BILLABILITY_STATUS
);
List
<
Billing
>
listBD
=
billingService
.
getActiveBillings
(
existingTeammate
.
getEmployeeId
(),
existingTeammate
.
getProjectId
());
if
(
listBD
!=
null
&&
!
listBD
.
isEmpty
())
{
Billing
billingDetailsExisting
=
listBD
.
get
(
0
);
billingDetailsExisting
.
setBillingEndDate
(
project
.
getProjectEndDate
());
billingDetailsExisting
.
setActive
(
false
);
billingService
.
updateBilling
(
billingDetailsExisting
,
loginEmpId
);
}
Project
benchProject
=
projectRepo
.
findByProjectId
(
MyTeamUtils
.
BENCH_PROJECT_ID
);
Date
sd
=
project
.
getProjectEndDate
();
billingDetails
.
setBillingStartDate
(
sd
);
billingDetails
.
setAccount
(
MyTeamUtils
.
BENCH_ACCOUNT
);
billingDetails
.
setActive
(
true
);
billingDetails
.
setEmployeeId
(
existingTeammate
.
getEmployeeId
());
billingDetails
.
setEmployeeName
(
existingTeammate
.
getEmployeeName
());
//billingDetails.setCreateDate(new Date());// Commented as added common audit fields
billingDetails
.
setProjectId
(
MyTeamUtils
.
BENCH_PROJECT_ID
);
billingDetails
.
setProjectName
(
MyTeamUtils
.
FREE_POLL
);
if
(
benchProject
!=
null
)
{
billingDetails
.
setBillingEndDate
(
benchProject
.
getProjectEndDate
());
newBenchAllocation
.
setAccountId
(
benchProject
.
getAccountId
());
newBenchAllocation
.
setProjectName
(
benchProject
.
getProjectName
());
newBenchAllocation
.
setDomainId
(
benchProject
.
getDomainId
());
newBenchAllocation
.
setEndDate
(
benchProject
.
getProjectEndDate
());
}
//addEmployeeBillingDetails(billingDetails,loginEmpId);
billingService
.
addBilling
(
billingDetails
,
loginEmpId
);
newBenchAllocation
.
setRole
(
existingTeammate
.
getRole
());
newBenchAllocation
.
setAccount
(
MyTeamUtils
.
BENCH_ACCOUNT
);
newBenchAllocation
.
setShift
(
existingTeammate
.
getShift
());
newBenchAllocation
.
setBillableStatus
(
MyTeamUtils
.
BENCH_BILLABILITY_STATUS
);
newBenchAllocation
.
setDesignation
(
existingTeammate
.
getDesignation
());
newBenchAllocation
.
setEmailId
(
existingTeammate
.
getEmailId
());
newBenchAllocation
.
setEmployeeId
(
existingTeammate
.
getEmployeeId
());
newBenchAllocation
.
setActive
(
true
);
newBenchAllocation
.
setEmployeeName
(
existingTeammate
.
getEmployeeName
());
newBenchAllocation
.
setProjectId
(
MyTeamUtils
.
BENCH_PROJECT_ID
);
newBenchAllocation
.
setStartDate
(
sd
);
newBenchAllocation
.
setAuditFields
(
loginEmpId
,
MyTeamUtils
.
CREATE
);
resourceRepo
.
save
(
newBenchAllocation
);
empShiftService
.
updateEmployeeShift
(
existingTeammate
,
loginEmpId
);
}
return
existingProject
;
}
else
{
Query
query
=
new
Query
(
Criteria
.
where
(
"projectId"
).
is
(
project
.
getProjectId
()));
Update
update
=
new
Update
();
update
.
set
(
"projectName"
,
project
.
getProjectName
());
if
(
project
.
getDeliveryLeadIds
()
!=
null
)
{
update
.
set
(
"deliveryLeadIds"
,
project
.
getDeliveryLeadIds
());
}
/*
* if(project.getManagerIds()!= null) { update.set("managerIds",
* project.getManagerIds()); }
*//*
* else{
* update.set("managerIds",Arrays.asList(project.getManagerId())); }
*/
//update.set("domain", project.getDomain());
update
.
set
(
"domain"
,
domainService
.
getDomainById
(
project
.
getDomainId
()).
getDomainName
());
update
.
set
(
"domainId"
,
project
.
getDomainId
());
update
.
set
(
"accountId"
,
project
.
getAccountId
());
update
.
set
(
"status"
,
project
.
getStatus
());
update
.
set
(
"projectStartDate"
,
project
.
getProjectStartDate
());
update
.
set
(
"projectEndDate"
,
project
.
getProjectEndDate
());
FindAndModifyOptions
options
=
new
FindAndModifyOptions
();
//Setting audit fileds
update
.
set
(
"modifiedBy"
,
loginEmpId
);
update
.
set
(
"lastModifiedOn"
,
new
Date
());
options
.
returnNew
(
true
);
options
.
upsert
(
true
);
Project
projectDB
=
mongoTemplate
.
findAndModify
(
query
,
update
,
options
,
Project
.
class
);
List
<
Resource
>
employeeDetails
=
resourceRepo
.
findByProjectId
(
project
.
getProjectId
());
if
(
employeeDetails
!=
null
&&
projectDB
!=
null
)
{
for
(
Resource
teamMate
:
employeeDetails
)
{
// emp.setManagerId(projectDB.getManagerId());
// emp.setManagerName(projectDB.getManagerName());
teamMate
.
setAccountId
(
projectDB
.
getAccountId
());
teamMate
.
setProjectName
(
projectDB
.
getProjectName
());
// MT-79:Maintatin the managerids in List
// emp.setManagerIds(projectDB.getManagerIds());
teamMate
.
setEndDate
(
projectDB
.
getProjectEndDate
());
teamMate
.
setAuditFields
(
loginEmpId
,
MyTeamUtils
.
UPDATE
);
//Setting audit fields
resourceRepo
.
save
(
teamMate
);
}
}
return
projectDB
;
}
return
projectDB
;
}
}
@Override
public
void
deleteProject
(
String
projectId
)
{
Project
project
=
projectRepo
.
findByProjectId
(
projectId
);
projectRepo
.
delete
(
project
);
Query
query
=
new
Query
(
Criteria
.
where
(
"projectId"
).
is
(
projectId
));
List
<
Resource
>
list
=
mongoTemplate
.
find
(
query
,
Resource
.
class
);
resourceRepo
.
delete
(
list
);
}
@Override
public
void
deleteProject
(
String
projectId
)
{
Project
project
=
projectRepo
.
findByProjectId
(
projectId
);
projectRepo
.
delete
(
project
);
Query
query
=
new
Query
(
Criteria
.
where
(
"projectId"
).
is
(
projectId
));
List
<
Resource
>
list
=
mongoTemplate
.
find
(
query
,
Resource
.
class
);
resourceRepo
.
delete
(
list
);
}
@Override
public
List
<
HashMap
<
Object
,
Object
>>
getProjects
()
throws
MyTeamException
{
/*
...
...
@@ -267,7 +266,7 @@ public class ProjectService implements IProjectService {
List
<
HashMap
<
String
,
String
>>
EmployeeList
=
null
;
List
<
HashMap
<
String
,
String
>>
managerList
=
null
;
List
<
Project
>
projects
=
projectRepo
.
findAll
();
for
(
Project
project
:
projects
)
{
HashMap
<
Object
,
Object
>
projectMap
=
new
HashMap
<>();
projectMap
.
put
(
"id"
,
project
.
getId
());
...
...
@@ -275,10 +274,10 @@ public class ProjectService implements IProjectService {
projectMap
.
put
(
"projectName"
,
project
.
getProjectName
());
Account
account
=
accountService
.
getAccountById
(
project
.
getAccountId
());
Account
account
=
accountService
.
getAccountById
(
project
.
getAccountId
());
//Domain domain = domainRepo.findByDomainId(project.getDomainId());
Domain
domain
=
domainService
.
getDomainById
(
project
.
getDomainId
());
Domain
domain
=
domainService
.
getDomainById
(
project
.
getDomainId
());
if
(
domain
!=
null
)
projectMap
.
put
(
"domain"
,
domain
.
getDomainName
());
if
(
account
!=
null
)
...
...
@@ -290,7 +289,7 @@ public class ProjectService implements IProjectService {
projectMap
.
put
(
"projectStartDate"
,
project
.
getProjectStartDate
());
projectMap
.
put
(
"projectEndDate"
,
project
.
getProjectEndDate
());
if
(
project
.
getDeliveryLeadIds
()
!=
null
)
{
if
(
project
.
getDeliveryLeadIds
()
!=
null
)
{
List
<
String
>
deliverLeadsId
=
project
.
getDeliveryLeadIds
();
EmployeeList
=
employeeService
.
getDeliveryManagerMap
(
deliverLeadsId
);
...
...
@@ -307,24 +306,21 @@ public class ProjectService implements IProjectService {
return
projectList
;
}
public
Resource
addNewBeanchAllocation
(
Employee
employee
,
String
loginEmpId
)
{
Resource
resourcePersisted
=
null
;
Resource
resourceBench
=
new
Resource
();
public
Resource
addNewBeanchAllocation
(
Employee
employee
,
String
loginEmpId
)
{
Resource
resourcePersisted
=
null
;
Resource
resourceBench
=
new
Resource
();
resourceBench
.
setAccount
(
MyTeamUtils
.
BENCH_ACCOUNT
);
resourceBench
.
setBillableStatus
(
MyTeamUtils
.
BENCH_BILLABILITY_STATUS
);
resourceBench
.
setDesignation
(
employee
.
getDesignation
());
resourceBench
.
setEmailId
(
employee
.
getEmailId
());
resourceBench
.
setEmployeeId
(
employee
.
getEmployeeId
());
resourceBench
.
setMobileNumber
(
employee
.
getMobileNumber
());
resourceBench
.
setEmployeeName
(
employee
.
getEmployeeName
());
resourceBench
.
setProjectId
(
MyTeamUtils
.
BENCH_PROJECT_ID
);
resourceBench
.
setStartDate
(
employee
.
getDateOfJoining
()
!=
null
?
employee
.
getDateOfJoining
()
:
new
Date
());
Project
project
=
projectRepo
.
findByProjectId
(
MyTeamUtils
.
BENCH_PROJECT_ID
);
resourceBench
.
setProjectName
(
project
.
getProjectName
());
resourceBench
.
setAccountId
(
project
.
getAccountId
());
...
...
@@ -332,7 +328,7 @@ public class ProjectService implements IProjectService {
resourceBench
.
setShift
(
employee
.
getShift
());
resourceBench
.
setRole
(
employee
.
getRole
());
if
(
null
!=
employee
.
getEmpStatus
()
&&
employee
.
getEmpStatus
().
trim
().
equalsIgnoreCase
(
MyTeamUtils
.
IN_ACTIVE_SPACE
))
{
if
(
null
!=
employee
.
getEmpStatus
()
&&
employee
.
getEmpStatus
().
trim
().
equalsIgnoreCase
(
MyTeamUtils
.
IN_ACTIVE_SPACE
))
{
resourceBench
.
setEndDate
(
employee
.
getEndDate
());
resourceBench
.
setActive
(
false
);
}
else
{
...
...
@@ -340,21 +336,20 @@ public class ProjectService implements IProjectService {
resourceBench
.
setEndDate
(
project
.
getProjectEndDate
());
resourceBench
.
setActive
(
true
);
}
try
{
resourcePersisted
=
resourceService
.
addResource
(
resourceBench
,
loginEmpId
);
resourcePersisted
=
resourceService
.
addResource
(
resourceBench
,
loginEmpId
);
}
catch
(
MyTeamException
e
)
{
e
.
printStackTrace
();
}
return
resourcePersisted
;
}
return
resourcePersisted
;
}
@Override
public
List
<
EmpLoginData
>
employeeLoginsBasedOnDate
(
long
id
,
String
fromDate
,
String
toDate
)
throws
MyTeamException
{
String
fromDate
,
String
toDate
)
throws
MyTeamException
{
return
employeeDataBaseService
.
fetchEmployeeLoginsBasedOnDates
(
id
,
fromDate
,
toDate
);
}
...
...
@@ -363,26 +358,19 @@ public class ProjectService implements IProjectService {
return
pdfReportGenerator
.
generateeReport
(
id
,
fromDate
,
toDate
);
}
@Override
public
List
<
Resource
>
getResourcesUnderProject
(
String
empId
)
{
List
<
String
>
projectsIdsList
=
new
ArrayList
<>();
List
<
Resource
>
resourcesList
=
new
ArrayList
<>();
List
<
Project
>
projectsList
=
projectRepo
.
findByDeliveryLeadIds
(
empId
);
for
(
Project
project
:
projectsList
)
projectsIdsList
.
add
(
project
.
getProjectId
());
Query
query
=
new
Query
(
Criteria
.
where
(
"projectId"
).
in
(
projectsIdsList
));
List
<
Resource
>
resourcesListPersisted
=
mongoTemplate
.
find
(
query
,
Resource
.
class
);
for
(
Resource
resource
:
resourcesListPersisted
)
{
if
(!
resource
.
getEmployeeId
().
equals
(
empId
))
resourcesList
.
add
(
resource
);
...
...
@@ -392,249 +380,105 @@ public class ProjectService implements IProjectService {
}
@Override
public
List
<
Project
>
getProjectsUnderDeliveryLead
(
String
deliveryLeadId
)
throws
MyTeamException
{
@Override
public
List
<
Project
>
getProjectsUnderDeliveryLead
(
String
deliveryLeadId
)
throws
MyTeamException
{
List
<
Project
>
projectList
=
new
ArrayList
<>();
List
<
Project
>
projectListPersisted
=
projectRepo
.
findByDeliveryLeadIds
(
deliveryLeadId
);
for
(
Project
project
:
projectListPersisted
)
{
//accountService.getAccountById(project.getAccountId()).getAccountName();
List
<
Project
>
projectList
=
new
ArrayList
<>();
List
<
Project
>
projectListPersisted
=
projectRepo
.
findByDeliveryLeadIds
(
deliveryLeadId
);
for
(
Project
project
:
projectListPersisted
)
{
//accountService.getAccountById(project.getAccountId()).getAccountName();
if
(!
project
.
getStatus
().
equals
(
"Completed"
))
{
projectList
.
add
(
project
);
}
if
(!
project
.
getStatus
().
equals
(
"Completed"
))
{
projectList
.
add
(
project
);
}
}
return
projectList
;
}
}
return
projectList
;
}
@Override
public
List
<
Project
>
getAllProjects
()
{
return
projectRepo
.
findAll
();
}
@Override
public
List
<
Employee
>
getUnAssignedEmployees
()
{
List
<
Employee
>
employeesList
=
employeeService
.
getAllEmployees
();
List
<
Employee
>
notAssignedEmployees
=
new
ArrayList
<>();
List
<
String
>
resourceIdsList
=
new
ArrayList
<>();
List
<
Resource
>
resourceListPersisted
=
resourceService
.
getAllResources
();
for
(
Resource
resource
:
resourceListPersisted
)
{
Project
project
=
projectRepo
.
findByProjectId
(
resource
.
getProjectId
());
if
(
project
!=
null
&&
project
.
getStatus
()
!=
null
&&
!
"Completed"
.
equalsIgnoreCase
(
project
.
getStatus
()))
{
resourceIdsList
.
add
(
resource
.
getEmployeeId
());
}
}
for
(
Employee
employee
:
employeesList
)
{
if
(!
resourceIdsList
.
contains
(
employee
.
getEmployeeId
()))
{
notAssignedEmployees
.
add
(
employee
);
}
}
@Override
public
List
<
Project
>
getOnlyActiveProjects
()
{
return
notAssignedEmployees
;
}
return
getAllProjects
().
stream
()
.
filter
(
project
->
!
project
.
getStatus
().
equalsIgnoreCase
(
"Completed"
))
.
collect
(
Collectors
.
toList
());
}
@Override
public
List
<
Project
>
getAllProjects
()
{
return
projectRepo
.
findAll
();
}
private
String
validateAgainstDOJ
(
Resource
projectTeamMate
)
{
String
response
=
null
;
//Date empDoj = employeeRepo.findByEmployeeId(projectTeamMate.getEmployeeId()).getDateOfJoining
();
Date
empDoj
=
employeeService
.
getEmployeeById
(
projectTeamMate
.
getEmployeeId
()).
getDateOfJoining
();
if
(
projectTeamMate
.
getNewBillingStartDate
().
compareTo
(
empDoj
)
<
0
)
{
response
=
"Resource Start Date ("
+
projectTeamMate
.
getNewBillingStartDate
()
+
" ) in "
+
projectTeamMate
.
getProjectName
()
+
" project should not be before Date of Joining ( "
+
empDoj
+
")."
;
}
return
response
;
}
@Override
public
List
<
EmployeeDashboardVO
>
getEmployeesDashBoard
()
{
//List<Employee> allEmployees = employeeRepo.findAll();
List
<
Employee
>
allEmployees
=
employeeService
.
getAllEmployees
();
List
<
EmployeeDashboardVO
>
employeeDashboard
=
new
ArrayList
<>();
Map
<
String
,
Object
>
teamMatesMap
=
new
HashMap
();
Map
<
String
,
Object
>
teamMatesStatusMap
=
new
HashMap
();
// Find all active employees
List
<
Resource
>
teamMates
=
resourceRepo
.
findAll
();
for
(
Resource
teamMate
:
teamMates
)
{
if
(
teamMate
.
isActive
())
{
Project
project
=
projectRepo
.
findByProjectId
(
teamMate
.
getProjectId
());
if
(
project
!=
null
&&
project
.
getStatus
()
!=
null
&&
!
"Completed"
.
equalsIgnoreCase
(
project
.
getStatus
()))
{
Object
projectTeamMate
=
teamMatesMap
.
get
(
teamMate
.
getEmployeeId
());
if
(
projectTeamMate
==
null
)
{
List
listOfObjects
=
new
ArrayList
<>();
listOfObjects
.
add
(
teamMate
);
// A person can have multiple active projects with billability
teamMatesMap
.
put
(
teamMate
.
getEmployeeId
(),
listOfObjects
);
}
else
{
List
existingRecordsInMap
=
(
List
)
teamMatesMap
.
get
(
teamMate
.
getEmployeeId
());
existingRecordsInMap
.
add
(
teamMate
);
teamMatesMap
.
put
(
teamMate
.
getEmployeeId
(),
existingRecordsInMap
);
}
}
}
}
for
(
Employee
emp
:
allEmployees
)
{
if
(
teamMatesMap
.
containsKey
(
emp
.
getEmployeeId
()))
{
Object
value
=
teamMatesMap
.
get
(
emp
.
getEmployeeId
());
if
(
value
instanceof
List
)
{
List
listOfTeamMates
=
(
List
)
value
;
String
billableStatus
=
"NA"
;
for
(
Object
obj
:
listOfTeamMates
)
{
Resource
projectTeamMate
=
(
Resource
)
obj
;
String
status
=
projectTeamMate
.
getBillableStatus
();
if
(
status
==
null
)
{
status
=
"NA"
;
}
EmployeeDashboardVO
empVo
=
new
EmployeeDashboardVO
();
BeanUtils
.
copyProperties
(
emp
,
empVo
);
BeanUtils
.
copyProperties
(
projectTeamMate
,
empVo
,
"employeeId"
,
"employeeName"
,
"emailId"
,
"role"
,
"designation"
,
"mobileNumber"
);
employeeDashboard
.
add
(
empVo
);
}
}
}
else
{
EmployeeDashboardVO
empVo
=
new
EmployeeDashboardVO
();
BeanUtils
.
copyProperties
(
emp
,
empVo
);
empVo
.
setBillableStatus
(
"UA"
);
empVo
.
setProjectAssigned
(
false
);
employeeDashboard
.
add
(
empVo
);
public
Set
<
String
>
accountsAssignedToDl
(
String
empId
)
{
Set
<
String
>
accIdsSet
=
new
HashSet
<
String
>();
List
<
Project
>
prjtsList
=
projectRepo
.
findByDeliveryLeadIds
(
empId
);
if
(
null
!=
prjtsList
&&
!
prjtsList
.
isEmpty
()
&&
MyTeamUtils
.
INT_ZERO
<
prjtsList
.
size
())
{
for
(
Project
obj
:
prjtsList
)
{
accIdsSet
.
add
(
obj
.
getAccountId
());
}
}
return
employeeDashboard
;
return
accIdsSet
;
}
private
String
validateAgainstDOJ
(
Resource
projectTeamMate
)
{
String
response
=
null
;
//Date empDoj = employeeRepo.findByEmployeeId(projectTeamMate.getEmployeeId()).getDateOfJoining();
Date
empDoj
=
employeeService
.
getEmployeeById
(
projectTeamMate
.
getEmployeeId
()).
getDateOfJoining
();
if
(
projectTeamMate
.
getNewBillingStartDate
().
compareTo
(
empDoj
)
<
0
)
{
response
=
"Resource Start Date ("
+
projectTeamMate
.
getNewBillingStartDate
()
+
" ) in "
+
projectTeamMate
.
getProjectName
()
+
" project should not be before Date of Joining ( "
+
empDoj
+
")."
;
}
return
response
;
}
@Override
public
List
<
HashMap
<
Object
,
Object
>>
getProjectsForEmployee
(
String
empId
){
HashMap
<
Object
,
Object
>
projectMap
=
null
;
List
<
HashMap
<
Object
,
Object
>>
projectList
=
new
ArrayList
<>();
Project
project
=
null
;
Account
account
=
null
;
Domain
domain
=
null
;
List
<
Resource
>
resourcesAllocatedList
=
resourceService
.
getResourcesForEmployee
(
empId
);
if
(
null
!=
resourcesAllocatedList
&&
!
resourcesAllocatedList
.
isEmpty
()
&&
MyTeamUtils
.
INT_ZERO
<
resourcesAllocatedList
.
size
())
{
for
(
Resource
resource
:
resourcesAllocatedList
)
{
projectMap
=
new
HashMap
<>();
project
=
projectRepo
.
findByProjectId
(
resource
.
getProjectId
());
//account = accountRepo.findByAccountId(resource.getAccountId());
account
=
accountService
.
getAccountById
(
resource
.
getAccountId
());
//domain = domainRepo.findByDomainId(resource.getDomainId());
domain
=
domainService
.
getDomainById
(
resource
.
getDomainId
());
projectMap
.
put
(
"id"
,
project
.
getId
());
projectMap
.
put
(
"projectId"
,
project
.
getProjectId
());
projectMap
.
put
(
"projectName"
,
project
.
getProjectName
());
if
(
domain
!=
null
)
projectMap
.
put
(
"domain"
,
domain
.
getDomainName
());
if
(
account
!=
null
)
projectMap
.
put
(
"account"
,
account
.
getAccountName
());
projectMap
.
put
(
"accountId"
,
account
!=
null
?
account
.
getAccountId
():
resource
.
getAccountId
());
projectMap
.
put
(
"domainId"
,
domain
!=
null
?
domain
.
getDomainId
()
:
resource
.
getDomainId
()
);
projectMap
.
put
(
"status"
,
resource
.
isActive
());
projectMap
.
put
(
"projectStartDate"
,
resource
.
getStartDate
());
projectMap
.
put
(
"projectEndDate"
,
resource
.
getEndDate
());
projectMap
.
put
(
"employeeIds"
,
resource
.
getEmployeeId
());
projectMap
.
put
(
"shift"
,
resource
.
getShift
());
projectMap
.
put
(
"billableStatus"
,
resource
.
getBillableStatus
());
if
(
project
.
getDeliveryLeadIds
()
!=
null
)
{
projectMap
.
put
(
"deliveryLeadIds"
,
employeeService
.
getDeliveryManagerMap
(
project
.
getDeliveryLeadIds
()));
}
if
(
project
.
getManagerIds
()
!=
null
)
{
projectMap
.
put
(
"managerIds"
,
employeeService
.
getDeliveryManagerMap
(
project
.
getManagerIds
()));
}
projectList
.
add
(
projectMap
);
}
}
return
projectList
;
}
@Override
public
Set
<
String
>
accountsAssignedToDl
(
String
empId
)
{
Set
<
String
>
accIdsSet
=
new
HashSet
<
String
>()
;
List
<
Project
>
prjtsList
=
projectRepo
.
findByDeliveryLeadIds
(
empId
);
if
(
null
!=
prjtsList
&&
!
prjtsList
.
isEmpty
()
&&
MyTeamUtils
.
INT_ZERO
<
prjtsList
.
size
())
{
for
(
Project
obj
:
prjtsList
)
{
accIdsSet
.
add
(
obj
.
getAccountId
());
}
}
return
accIdsSet
;
}
@Override
public
List
<
HashMap
<
Object
,
Object
>>
deliveryLeadProjects
(
String
empId
)
throws
MyTeamException
{
List
<
HashMap
<
Object
,
Object
>>
projectsList
=
new
ArrayList
<
HashMap
<
Object
,
Object
>>
();
Set
<
String
>
accIdsSet
=
domainService
.
accountsAssignedToDeliveryLead
(
empId
);
List
<
Project
>
prjts
=
projectRepo
.
findByAccountIdIn
(
accIdsSet
);
if
(
null
!=
prjts
&&
!
prjts
.
isEmpty
()
&&
MyTeamUtils
.
INT_ZERO
<
prjts
.
size
())
{
Account
account
=
null
;
Domain
domain
=
null
;
HashMap
<
Object
,
Object
>
projectMap
=
null
;
for
(
Project
obj
:
prjts
)
{
projectMap
=
new
HashMap
<>();
//account = accountRepo.findByAccountId(obj.getAccountId());
account
=
accountService
.
getAccountById
(
obj
.
getAccountId
());
//domain = domainRepo.findByDomainId(obj.getDomainId());
domain
=
domainService
.
getDomainById
(
obj
.
getDomainId
());
projectMap
.
put
(
"projectId"
,
obj
.
getProjectId
());
projectMap
.
put
(
"projectName"
,
obj
.
getProjectName
());
projectMap
.
put
(
"accountId"
,
obj
.
getAccountId
());
projectMap
.
put
(
"domainId"
,
obj
.
getDomainId
());
projectMap
.
put
(
"account"
,
null
!=
account
?
account
.
getAccountName
():
""
);
projectMap
.
put
(
"domain"
,
null
!=
domain
?
domain
.
getDomainName
()
:
""
);
projectMap
.
put
(
"status"
,
obj
.
getStatus
());
projectMap
.
put
(
"deliveryLeadIds"
,
null
!=
obj
.
getDeliveryLeadIds
()
?
employeeService
.
getDeliveryManagerMap
(
obj
.
getDeliveryLeadIds
())
:
""
);
projectMap
.
put
(
"managerIds"
,
null
!=
obj
.
getManagerIds
()
?
employeeService
.
getDeliveryManagerMap
(
obj
.
getManagerIds
())
:
""
);
projectsList
.
add
(
projectMap
);
}
}
return
projectsList
;
}
@Override
public
List
<
HashMap
<
Object
,
Object
>>
deliveryLeadProjects
(
String
empId
)
throws
MyTeamException
{
List
<
HashMap
<
Object
,
Object
>>
projectsList
=
new
ArrayList
<
HashMap
<
Object
,
Object
>>();
Set
<
String
>
accIdsSet
=
domainService
.
accountsAssignedToDeliveryLead
(
empId
);
List
<
Project
>
prjts
=
projectRepo
.
findByAccountIdIn
(
accIdsSet
);
if
(
null
!=
prjts
&&
!
prjts
.
isEmpty
()
&&
MyTeamUtils
.
INT_ZERO
<
prjts
.
size
())
{
Account
account
=
null
;
Domain
domain
=
null
;
HashMap
<
Object
,
Object
>
projectMap
=
null
;
for
(
Project
obj
:
prjts
)
{
projectMap
=
new
HashMap
<>();
account
=
accountService
.
getAccountById
(
obj
.
getAccountId
());
domain
=
domainService
.
getDomainById
(
obj
.
getDomainId
());
projectMap
.
put
(
"projectId"
,
obj
.
getProjectId
());
projectMap
.
put
(
"projectName"
,
obj
.
getProjectName
());
projectMap
.
put
(
"accountId"
,
obj
.
getAccountId
());
projectMap
.
put
(
"domainId"
,
obj
.
getDomainId
());
projectMap
.
put
(
"account"
,
null
!=
account
?
account
.
getAccountName
()
:
""
);
projectMap
.
put
(
"domain"
,
null
!=
domain
?
domain
.
getDomainName
()
:
""
);
projectMap
.
put
(
"status"
,
obj
.
getStatus
());
projectMap
.
put
(
"deliveryLeadIds"
,
null
!=
obj
.
getDeliveryLeadIds
()
?
employeeService
.
getDeliveryManagerMap
(
obj
.
getDeliveryLeadIds
())
:
""
);
projectMap
.
put
(
"managerIds"
,
null
!=
obj
.
getManagerIds
()
?
employeeService
.
getDeliveryManagerMap
(
obj
.
getManagerIds
())
:
""
);
projectsList
.
add
(
projectMap
);
}
}
return
projectsList
;
}
...
...
@@ -644,73 +488,79 @@ public class ProjectService implements IProjectService {
Need to refactor the following code
*/
@Override
public
List
<
HashMap
<
Object
,
Object
>>
getRoleBasedProjects
(
String
empId
)
throws
MyTeamException
{
List
<
HashMap
<
Object
,
Object
>>
projectsList
=
new
ArrayList
<
HashMap
<
Object
,
Object
>>();
Set
<
String
>
accountIdSet
=
domainService
.
accountsAssignedToDeliveryLead
(
empId
);
List
<
Project
>
projectList
=
projectRepo
.
findByAccountIdIn
(
accountIdSet
);
for
(
Project
proj
:
projectList
)
{
addToProjectList
(
projectsList
,
proj
);
}
return
projectsList
;
}
@Override
public
List
<
HashMap
<
Object
,
Object
>>
getProjectsInsteadOfRole
()
throws
MyTeamException
{
List
<
HashMap
<
Object
,
Object
>>
projectList
=
new
ArrayList
<>();
List
<
Project
>
projects
=
projectRepo
.
findAll
();
for
(
Project
proj
:
projects
)
{
addToProjectList
(
projectList
,
proj
);
}
return
projectList
;
}
private
void
addToProjectList
(
List
<
HashMap
<
Object
,
Object
>>
projectList
,
Project
proj
)
{
HashMap
<
Object
,
Object
>
projectMap
=
new
HashMap
<>();
buildProjectProperties
(
proj
,
projectMap
);
projectMap
.
put
(
"status"
,
proj
.
getStatus
());
projectMap
.
put
(
"projectStartDate"
,
proj
.
getProjectStartDate
());
projectMap
.
put
(
"projectEndDate"
,
proj
.
getProjectEndDate
());
projectList
.
add
(
projectMap
);
}
private
void
buildProjectProperties
(
Project
proj
,
HashMap
<
Object
,
Object
>
projectMap
)
{
projectMap
.
put
(
"id"
,
proj
.
getId
());
projectMap
.
put
(
"projectId"
,
proj
.
getProjectId
());
projectMap
.
put
(
"projectName"
,
proj
.
getProjectName
());
Account
account
=
accountService
.
getAccountById
(
proj
.
getAccountId
());
Domain
domain
=
domainService
.
getDomainById
(
proj
.
getDomainId
());
if
(
domain
!=
null
)
projectMap
.
put
(
"domain"
,
domain
.
getDomainName
());
if
(
account
!=
null
)
projectMap
.
put
(
"account"
,
account
.
getAccountName
());
projectMap
.
put
(
"accountId"
,
proj
.
getAccountId
());
projectMap
.
put
(
"domainId"
,
proj
.
getDomainId
());
projectMap
.
put
(
"domain"
,
proj
.
getDomain
());
projectMap
.
put
(
"employeeIds"
,
proj
.
getEmployeeIds
());
if
(
proj
.
getDeliveryLeadIds
()
!=
null
)
{
//employeeService.getDeliveryManagerMap(proj.getDeliveryLeadIds()).stream().map(mapObj->mapObj.get("employeeId")).collect(Collectors.toList());
projectMap
.
put
(
"deliveryLeadIds"
,
employeeService
.
getDeliveryManagerMap
(
proj
.
getDeliveryLeadIds
()));
}
if
(
proj
.
getManagerIds
()
!=
null
)
{
projectMap
.
put
(
"managerIds"
,
employeeService
.
getDeliveryManagerMap
(
proj
.
getManagerIds
()));
}
}
public
Project
getProjectByProjectId
(
String
projectId
)
{
Project
project
=
null
;
if
(
StringUtils
.
isNotBlank
(
projectId
))
{
project
=
projectRepo
.
findByProjectId
(
projectId
);
}
return
project
;
}
@Override
public
List
<
HashMap
<
Object
,
Object
>>
getRoleBasedProjects
(
String
empId
)
throws
MyTeamException
{
List
<
HashMap
<
Object
,
Object
>>
projectsList
=
new
ArrayList
<
HashMap
<
Object
,
Object
>>();
Set
<
String
>
accountIdSet
=
domainService
.
accountsAssignedToDeliveryLead
(
empId
);
List
<
Project
>
projectList
=
projectRepo
.
findByAccountIdIn
(
accountIdSet
);
for
(
Project
proj
:
projectList
)
{
addToProjectList
(
projectsList
,
proj
);
}
return
projectsList
;
}
@Override
public
List
<
HashMap
<
Object
,
Object
>>
getProjectsInsteadOfRole
()
throws
MyTeamException
{
List
<
HashMap
<
Object
,
Object
>>
projectList
=
new
ArrayList
<>();
List
<
Project
>
projects
=
projectRepo
.
findAll
();
for
(
Project
proj
:
projects
)
{
addToProjectList
(
projectList
,
proj
);
}
return
projectList
;
}
private
void
addToProjectList
(
List
<
HashMap
<
Object
,
Object
>>
projectList
,
Project
proj
)
{
HashMap
<
Object
,
Object
>
projectMap
=
new
HashMap
<>();
buildProjectProperties
(
proj
,
projectMap
);
projectMap
.
put
(
"status"
,
proj
.
getStatus
());
projectMap
.
put
(
"projectStartDate"
,
proj
.
getProjectStartDate
());
projectMap
.
put
(
"projectEndDate"
,
proj
.
getProjectEndDate
());
projectList
.
add
(
projectMap
);
}
private
void
buildProjectProperties
(
Project
proj
,
HashMap
<
Object
,
Object
>
projectMap
)
{
projectMap
.
put
(
"id"
,
proj
.
getId
());
projectMap
.
put
(
"projectId"
,
proj
.
getProjectId
());
projectMap
.
put
(
"projectName"
,
proj
.
getProjectName
());
Account
account
=
accountService
.
getAccountById
(
proj
.
getAccountId
());
Domain
domain
=
domainService
.
getDomainById
(
proj
.
getDomainId
());
if
(
domain
!=
null
)
projectMap
.
put
(
"domain"
,
domain
.
getDomainName
());
if
(
account
!=
null
)
projectMap
.
put
(
"account"
,
account
.
getAccountName
());
projectMap
.
put
(
"accountId"
,
proj
.
getAccountId
());
projectMap
.
put
(
"domainId"
,
proj
.
getDomainId
());
projectMap
.
put
(
"employeeIds"
,
proj
.
getEmployeeIds
());
if
(
proj
.
getDeliveryLeadIds
()
!=
null
)
{
//employeeService.getDeliveryManagerMap(proj.getDeliveryLeadIds()).stream().map(mapObj->mapObj.get("employeeId")).collect(Collectors.toList());
projectMap
.
put
(
"deliveryLeadIds"
,
employeeService
.
getDeliveryManagerMap
(
proj
.
getDeliveryLeadIds
()));
}
if
(
proj
.
getManagerIds
()
!=
null
)
{
projectMap
.
put
(
"managerIds"
,
employeeService
.
getDeliveryManagerMap
(
proj
.
getManagerIds
()));
}
}
public
Project
getProjectByProjectId
(
String
projectId
)
{
Project
project
=
null
;
if
(
StringUtils
.
isNotBlank
(
projectId
))
{
project
=
projectRepo
.
findByProjectId
(
projectId
);
}
return
project
;
}
public
List
<
Project
>
getProjectsForDeliveryLead
(
String
deliveryLeadId
)
{
List
<
Project
>
projectsList
=
projectRepo
.
findByDeliveryLeadIds
(
deliveryLeadId
);
return
projectsList
;
}
}
src/main/java/com/nisum/myteam/service/impl/ResourceAllocationService.java
View file @
fed165ca
package
com
.
nisum
.
myteam
.
service
.
impl
;
import
com.nisum.myteam.exception.handler.MyTeamException
;
import
com.nisum.myteam.model.dao.
Project
;
import
com.nisum.myteam.model.
dao.Resource
;
import
com.nisum.myteam.model.
dao.ResourceAllocation
;
import
com.nisum.myteam.model.dao.
*
;
import
com.nisum.myteam.model.
vo.MyProjectAllocationVO
;
import
com.nisum.myteam.model.
vo.ResourceVO
;
import
com.nisum.myteam.repository.ResourceAllocationRepo
;
import
com.nisum.myteam.service.IProjectService
;
import
com.nisum.myteam.service.IResourceAllocationService
;
import
com.nisum.myteam.service.*
;
import
com.nisum.myteam.statuscodes.ResourceStatus
;
import
com.nisum.myteam.utils.MyTeamDateUtils
;
import
com.nisum.myteam.utils.MyTeamUtils
;
import
lombok.extern.slf4j.Slf4j
;
import
org.bson.types.ObjectId
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Sort
;
import
org.springframework.data.mongodb.core.MongoTemplate
;
...
...
@@ -17,9 +17,8 @@ import org.springframework.data.mongodb.core.query.Criteria;
import
org.springframework.data.mongodb.core.query.Query
;
import
org.springframework.stereotype.Service
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.*
;
import
java.util.stream.Collectors
;
@Service
@Slf4j
...
...
@@ -31,38 +30,163 @@ public class ResourceAllocationService implements IResourceAllocationService {
@Autowired
private
ResourceAllocationRepo
resourceAllocationRepo
;
@Autowired
private
IAccountService
accountService
;
@Autowired
private
IDomainService
domainService
;
@Autowired
private
IProjectService
projectService
;
@Autowired
private
IEmployeeService
employeeService
;
public
HashMap
<
String
,
Object
>
respMap
=
new
HashMap
<>();
public
ResourceAllocation
addResourceAllocation
(
ResourceAllocation
resourceAllocation
,
String
loginEmpId
)
throws
MyTeamException
{
return
resourceAllocationRepo
.
save
(
resourceAllocation
);
}
public
HashMap
<
String
,
Object
>
updateResource
(
ResourceAllocation
resourceAllocReq
,
String
loginEmpId
)
throws
MyTeamException
{
public
boolean
isResourceExistsForProject
(
String
employeeId
,
String
projectId
)
{
boolean
isExists
=
false
;
List
<
ResourceAllocation
>
resourceList
=
resourceAllocationRepo
.
findByEmployeeIdAndProjectId
(
employeeId
,
projectId
);
if
(
resourceList
!=
null
&&
resourceList
.
size
()
>
0
)
{
isExists
=
true
;
HashMap
<
String
,
Object
>
respMap
=
new
HashMap
<>();
}
respMap
.
put
(
"message"
,
"Resource Not Found"
);
return
isExists
;
}
Project
project
=
projectService
.
getProjectByProjectId
(
resourceAllocReq
.
getProjectId
());
if
(
resourceAllocReq
.
getBillingEndDate
().
compareTo
(
new
Date
())
>
0
)
{
public
void
updateResourceAlloc
(
ResourceAllocation
resourceAlloc
)
{
if
(
resourceAlloc
!=
null
)
{
ResourceAllocation
resourcePers
=
resourceAllocationRepo
.
save
(
resourceAlloc
);
respMap
.
put
(
"message"
,
"resource has been updated"
);
respMap
.
put
(
"resourceObj"
,
resourcePers
);
}
}
ResourceAllocation
resourceAllocationPers
=
resourceAllocationRepo
.
save
(
resourceAllocReq
);
public
void
updatePreviousResource
(
ResourceAllocation
resourceAllocReq
,
String
loginEmpId
)
throws
MyTeamException
{
List
<
ResourceAllocation
>
resourceAllocList
=
resourceAllocationRepo
.
findByEmployeeIdAndProjectId
(
resourceAllocReq
.
getEmployeeId
(),
resourceAllocReq
.
getProjectId
());
List
<
ResourceAllocation
>
resourceListWithLatestRecord
=
resourceAllocList
.
stream
().
filter
(
resource
->
resource
.
getBillingEndDate
().
compareTo
(
new
Date
())
>=
0
).
collect
(
Collectors
.
toList
());
if
(
resourceListWithLatestRecord
!=
null
&&
resourceListWithLatestRecord
.
size
()
>
0
)
{
ResourceAllocation
resourceAllocPrev
=
resourceListWithLatestRecord
.
get
(
0
);
//latest resource record.
log
.
info
(
"The before date is::"
+
MyTeamDateUtils
.
getYesterdayDate
());
resourceAllocPrev
.
setBillingEndDate
(
MyTeamDateUtils
.
getYesterdayDate
());
//adding resource.
//resourceAllocPrev.setBillingEndDate(); //adding resource.
log
.
info
(
"After setting the date:::before saving the Resource::"
+
resourceAllocPrev
);
this
.
updateResourceAlloc
(
resourceAllocPrev
);
}
}
public
boolean
validateBillingStartEndDateAgainstProjectStartEndDate
(
ResourceAllocation
resourceAllocation
,
String
loginEmpId
)
throws
MyTeamException
{
boolean
isValid
=
true
;
Project
project
=
projectService
.
getProjectByProjectId
(
resourceAllocation
.
getProjectId
());
log
.
info
(
"Project::"
+
project
);
if
(!
resourceAllocation
.
getBillingStartDate
().
after
(
project
.
getProjectStartDate
()))
{
log
.
info
(
"Billing start date should be after Project start date"
);
respMap
.
put
(
"message"
,
"Billing start date should be after Project start date"
);
isValid
=
false
;
}
if
(!
resourceAllocation
.
getBillingStartDate
().
before
(
resourceAllocation
.
getBillingEndDate
()))
{
log
.
info
(
"Billing start date should be before Billing End Date."
);
respMap
.
put
(
"message"
,
"Billing start date should be before Billing End Date."
);
isValid
=
false
;
}
log
.
info
(
"ResourceALloc Req::"
+
resourceAllocation
);
log
.
info
(
""
+
project
.
getProjectEndDate
().
toString
());
if
(!
resourceAllocation
.
getBillingEndDate
().
before
(
project
.
getProjectEndDate
()))
{
log
.
info
(
"Billing end date should be before Project End Date."
);
respMap
.
put
(
"message"
,
"Billing end date should be before Project End Date."
);
isValid
=
false
;
}
respMap
.
put
(
"resourceObj"
,
resourceAllocation
);
return
isValid
;
}
public
boolean
validateBillingStartDateAgainstDOJ
(
ResourceAllocation
resource
)
{
String
message
=
""
;
boolean
isValid
=
true
;
Employee
employee
=
employeeService
.
getEmployeeById
(
resource
.
getEmployeeId
());
Date
empDoj
=
employeeService
.
getEmployeeById
(
resource
.
getEmployeeId
()).
getDateOfJoining
();
if
(
resource
.
getBillingStartDate
().
compareTo
(
empDoj
)
<
0
)
{
message
=
"Resource Billing Start Date ("
+
resource
.
getBillingStartDate
()
+
" ) in "
+
projectService
.
getProjectByProjectId
(
resource
.
getProjectId
()).
getProjectName
()
+
" project should not be before Date of Joining ( "
+
empDoj
+
")."
;
isValid
=
false
;
respMap
.
put
(
"message"
,
message
);
}
return
isValid
;
}
public
boolean
isResourceAssignedToAnyProject
(
ResourceAllocation
resourceAllocReq
)
{
boolean
isAssigned
=
false
;
String
message
=
""
;
//List<ResourceAllocation> resourceAllocList = resourceAllocationRepo.findByEmployeeIdAndProjectId(resourceAllocReq.getEmployeeId(), resourceAllocReq.getProjectId());
List
<
ResourceAllocation
>
resourceAllocList
=
resourceAllocationRepo
.
findByEmployeeId
(
resourceAllocReq
.
getEmployeeId
());
List
<
ResourceAllocation
>
resourceListWithLatestRecord
=
resourceAllocList
.
stream
().
filter
(
resource
->
resource
.
getBillingEndDate
().
compareTo
(
new
Date
())
>=
0
).
collect
(
Collectors
.
toList
());
if
(
resourceListWithLatestRecord
!=
null
&&
resourceListWithLatestRecord
.
size
()
>
0
)
{
ResourceAllocation
resourceAllocPrev
=
resourceListWithLatestRecord
.
get
(
0
);
//latest resource record.
message
=
"Resource "
+
resourceAllocPrev
.
getEmployeeId
()
+
" already Assigned to the "
+
projectService
.
getProjectByProjectId
(
resourceAllocPrev
.
getProjectId
()).
getProjectName
()
+
" Project"
+
" from "
+
resourceAllocPrev
.
getBillingStartDate
()
+
"to "
+
resourceAllocPrev
.
getBillingEndDate
();
isAssigned
=
true
;
respMap
.
put
(
"message"
,
message
);
}
return
isAssigned
;
}
public
void
updateResource
(
ResourceAllocation
resourceAllocReq
,
String
loginEmpId
)
throws
MyTeamException
{
ResourceAllocation
resourceAllocationPers
=
resourceAllocationRepo
.
save
(
resourceAllocReq
);
respMap
.
put
(
"message"
,
"Resource updated successfully"
);
respMap
.
put
(
"resourceObj"
,
resourceAllocationPers
);
return
respMap
;
}
public
Resource
deleteResource
(
String
empId
,
String
projectId
,
ObjectId
id
,
String
loginEmpId
)
{
return
null
;
public
void
deleteResource
(
ResourceAllocation
resourceReq
,
String
loginEmpId
)
{
List
<
ResourceAllocation
>
resourcesList
=
resourceAllocationRepo
.
findByEmployeeIdAndProjectId
(
resourceReq
.
getEmployeeId
(),
resourceReq
.
getProjectId
());
resourcesList
.
forEach
(
resource
->
resourceAllocationRepo
.
delete
(
resource
));
}
@Override
public
List
<
ResourceAllocation
>
getAllResources
()
{
return
resourceAllocationRepo
.
findAll
();
}
public
List
<
ResourceAllocation
>
getResourcesSortByProjectStartDate
(
String
employeeId
)
{
Query
query
=
prepareQuery
(
employeeId
,
MyTeamUtils
.
PROJECT_START_DATE
);
public
List
<
ResourceAllocation
>
getResourcesSortByBillingStartDate
(
String
employeeId
)
{
Query
query
=
prepareQuery
(
employeeId
,
MyTeamUtils
.
BILLING_START_DATE
);
return
mongoTemplate
.
find
(
query
,
ResourceAllocation
.
class
);
}
...
...
@@ -74,5 +198,187 @@ public class ResourceAllocationService implements IResourceAllocationService {
return
query
;
}
@Override
public
List
<
ResourceAllocation
>
getActiveResources
(
String
empId
)
{
List
<
ResourceAllocation
>
resourcesList
=
new
ArrayList
<>();
for
(
ResourceAllocation
resource
:
resourceAllocationRepo
.
findByEmployeeId
(
empId
))
{
//if (resource.isActive()) {
if
(
resource
.
getBillingEndDate
().
compareTo
(
new
Date
())
>
0
)
{
resourcesList
.
addAll
(
getAllResourcesForProject
(
resource
.
getProjectId
()));
}
}
return
resourcesList
;
}
public
List
<
ResourceAllocation
>
getAllResourcesForProject
(
String
projectId
)
{
return
resourceAllocationRepo
.
findByProjectId
(
projectId
);
}
@Override
public
List
<
ResourceAllocation
>
getAllResourcesForAllActiveProjects
()
{
List
<
ResourceAllocation
>
resourceList
=
new
ArrayList
<>();
for
(
Project
activeProject
:
projectService
.
getOnlyActiveProjects
())
{
resourceList
.
addAll
(
getAllResourcesForProject
(
activeProject
.
getProjectId
()));
}
return
resourceList
;
}
@Override
public
List
<
ResourceVO
>
getResourcesForProject
(
String
projectId
,
String
statusFlag
)
{
List
<
ResourceVO
>
resourcesList
=
new
ArrayList
<>();
for
(
ResourceAllocation
resource
:
resourceAllocationRepo
.
findByProjectId
(
projectId
))
{
Date
billingEndDate
=
resource
.
getBillingEndDate
();
if
(
billingEndDate
!=
null
)
{
ResourceVO
resourceVO
=
new
ResourceVO
();
resourceVO
.
setId
(
resource
.
getId
());
resourceVO
.
setProjectId
(
resource
.
getProjectId
());
resourceVO
.
setProjectName
(
projectService
.
getProjectByProjectId
(
resource
.
getProjectId
()).
getProjectName
());
resourceVO
.
setResourceRole
(
resource
.
getResourceRole
());
resourceVO
.
setBillingStartDate
(
resource
.
getBillingStartDate
());
resourceVO
.
setBillingEndDate
(
resource
.
getBillingEndDate
());
resourceVO
.
setBillableStatus
(
resource
.
getBillableStatus
());
resourceVO
.
setEmployeeId
(
resource
.
getEmployeeId
());
Employee
employee
=
employeeService
.
getEmployeeById
(
resource
.
getEmployeeId
());
resourceVO
.
setEmailId
(
employee
.
getEmailId
());
resourceVO
.
setEmployeeName
(
employee
.
getEmployeeName
());
resourceVO
.
setDesignation
(
employee
.
getDesignation
());
// Active
if
(
statusFlag
.
equals
(
ResourceStatus
.
ACTIVE
.
getStatus
())
&&
billingEndDate
.
compareTo
(
new
Date
())
>=
0
)
{
resourceVO
.
setResourceStatus
(
ResourceStatus
.
ACTIVE
.
getStatus
());
resourcesList
.
add
(
resourceVO
);
}
else
if
(
statusFlag
.
equals
(
ResourceStatus
.
IN_ACTIVE
.
getStatus
())
&&
billingEndDate
.
compareTo
(
new
Date
())
<
0
)
{
resourceVO
.
setResourceStatus
(
ResourceStatus
.
IN_ACTIVE
.
getStatus
());
resourcesList
.
add
(
resourceVO
);
}
else
if
(
statusFlag
.
equals
(
MyTeamUtils
.
BOTH
))
resourcesList
.
add
(
resourceVO
);
}
}
return
resourcesList
;
}
@Override
public
List
<
MyProjectAllocationVO
>
getWorkedProjectsForResource
(
String
empId
)
{
Project
project
=
null
;
Account
account
=
null
;
Domain
domain
=
null
;
Employee
employee
=
null
;
List
<
MyProjectAllocationVO
>
myProjectList
=
new
ArrayList
<>();
List
<
ResourceAllocation
>
resourcesAllocatedList
=
resourceAllocationRepo
.
findByEmployeeId
(
empId
);
if
(
null
!=
resourcesAllocatedList
&&
!
resourcesAllocatedList
.
isEmpty
()
&&
MyTeamUtils
.
INT_ZERO
<
resourcesAllocatedList
.
size
())
{
for
(
ResourceAllocation
resourceAlloc
:
resourcesAllocatedList
)
{
project
=
projectService
.
getProjectByProjectId
(
resourceAlloc
.
getProjectId
());
account
=
accountService
.
getAccountById
(
project
.
getAccountId
());
domain
=
domainService
.
getDomainById
(
project
.
getDomainId
());
employee
=
employeeService
.
getEmployeeById
(
resourceAlloc
.
getEmployeeId
());
MyProjectAllocationVO
myProject
=
new
MyProjectAllocationVO
();
myProject
.
setProjectName
(
project
.
getProjectName
());
myProject
.
setAccountName
(
account
.
getAccountName
());
myProject
.
setBillableStatus
(
resourceAlloc
.
getBillableStatus
());
myProject
.
setBillingStartDate
(
resourceAlloc
.
getBillingStartDate
());
myProject
.
setBillingEndDate
(
resourceAlloc
.
getBillingEndDate
());
myProject
.
setShift
(
employee
.
getShift
());
if
(
resourceAlloc
.
getBillingEndDate
().
compareTo
(
new
Date
())
>
0
)
{
myProject
.
setResourceStatus
(
ResourceStatus
.
ACTIVE
.
getStatus
());
}
else
{
myProject
.
setResourceStatus
(
ResourceStatus
.
IN_ACTIVE
.
getStatus
());
}
if
(
project
.
getDeliveryLeadIds
()
!=
null
)
{
myProject
.
setDeliverLeadIds
(
employeeService
.
getDeliveryManagerMap
(
project
.
getDeliveryLeadIds
()));
}
myProjectList
.
add
(
myProject
);
}
}
return
myProjectList
;
}
@Override
public
List
<
ResourceAllocation
>
getResourcesUnderDeliveryLead
(
String
deliveryLeadId
)
{
List
<
String
>
projectIdsList
=
new
ArrayList
<>();
List
<
ResourceAllocation
>
resourcesList
=
new
ArrayList
<>();
for
(
Project
project
:
projectService
.
getProjectsForDeliveryLead
(
deliveryLeadId
))
projectIdsList
.
add
(
project
.
getProjectId
());
Query
query
=
new
Query
(
Criteria
.
where
(
"projectId"
).
in
(
projectIdsList
));
List
<
ResourceAllocation
>
resourcesListPersisted
=
mongoTemplate
.
find
(
query
,
ResourceAllocation
.
class
);
for
(
ResourceAllocation
resourceAlloc
:
resourcesListPersisted
)
{
if
(!
resourceAlloc
.
getEmployeeId
().
equals
(
deliveryLeadId
))
resourcesList
.
add
(
resourceAlloc
);
}
return
resourcesList
;
}
@Override
public
List
<
ResourceAllocation
>
getBillingsForEmployee
(
String
empId
)
{
// List<Billing> billingsList = billingRepo.findByEmployeeId(empId);
List
<
ResourceAllocation
>
resourcesList
=
resourceAllocationRepo
.
findByEmployeeId
(
empId
);
if
(
resourcesList
==
null
||
resourcesList
.
size
()
==
0
)
{
return
resourcesList
;
}
else
{
log
.
info
(
"The resources billing list before sorting::"
+
resourcesList
);
//return billingsList.stream().sorted(Comparator.comparing(Billing::getCreatedOn).reversed()).collect(Collectors.toList());
return
resourcesList
.
stream
().
sorted
(
Comparator
.
comparing
(
ResourceAllocation:
:
getBillingStartDate
).
reversed
()).
collect
(
Collectors
.
toList
());
}
}
@Override
public
List
<
ResourceAllocation
>
getBillingsForProject
(
String
empId
,
String
projectId
)
{
List
<
ResourceAllocation
>
resourcesList
=
resourceAllocationRepo
.
findByEmployeeIdAndProjectId
(
empId
,
projectId
);
if
(
resourcesList
==
null
||
resourcesList
.
size
()
==
0
)
{
return
resourcesList
;
}
else
{
//return billingsList.stream().sorted(Comparator.comparing(Billing::getCreatedOn).reversed()).collect(Collectors.toList());
return
resourcesList
.
stream
().
sorted
(
Comparator
.
comparing
(
ResourceAllocation:
:
getBillingStartDate
).
reversed
()).
collect
(
Collectors
.
toList
());
}
}
@Override
public
List
<
Employee
>
getUnAssignedEmployees
()
{
List
<
Employee
>
notAssignedEmployees
=
new
ArrayList
<>();
List
<
String
>
resourceIdsList
=
new
ArrayList
<>();
for
(
ResourceAllocation
resource
:
this
.
getAllResources
())
{
Project
project
=
projectService
.
getProjectByProjectId
(
resource
.
getProjectId
());
if
(
project
!=
null
&&
project
.
getStatus
()
!=
null
&&
!
"Completed"
.
equalsIgnoreCase
(
project
.
getStatus
()))
{
resourceIdsList
.
add
(
resource
.
getEmployeeId
());
}
}
for
(
Employee
employee
:
employeeService
.
getAllEmployees
())
{
if
(!
resourceIdsList
.
contains
(
employee
.
getEmployeeId
()))
{
notAssignedEmployees
.
add
(
employee
);
}
}
return
notAssignedEmployees
;
}
}
src/main/java/com/nisum/myteam/service/impl/ResourceService.java
View file @
fed165ca
...
...
@@ -61,7 +61,7 @@ public class ResourceService implements IResourceService {
private
ProjectService
projectService
;
@Autowired
private
EmployeeRepo
employeeR
oleR
epo
;
private
EmployeeRepo
employeeRepo
;
public
Resource
save
(
Resource
resource
)
{
return
resourceRepo
.
save
(
resource
);
...
...
@@ -306,11 +306,11 @@ public class ResourceService implements IResourceService {
empShiftService
.
updateEmployeeShift
(
existingResource
,
loginEmpId
);
existingResource
.
setShift
(
resourceReq
.
getShift
());
Employee
employeeDB
=
employeeR
oleR
epo
.
findByEmployeeId
(
resourceReq
.
getEmployeeId
());
Employee
employeeDB
=
employeeRepo
.
findByEmployeeId
(
resourceReq
.
getEmployeeId
());
employeeDB
.
setShift
(
resourceReq
.
getShift
());
employeeDB
.
setModifiedBy
(
loginEmpId
);
employeeDB
.
setLastModifiedOn
(
new
Date
());
employeeR
oleR
epo
.
save
(
employeeDB
);
employeeRepo
.
save
(
employeeDB
);
}
existingResource
.
setAuditFields
(
loginEmpId
,
MyTeamUtils
.
UPDATE
);
// Setting
// audit
...
...
@@ -335,15 +335,6 @@ public class ResourceService implements IResourceService {
return
response
;
}
private
String
validateAgainstDOJ
(
Resource
resource
)
{
String
response
=
null
;
Date
empDoj
=
employeeRoleRepo
.
findByEmployeeId
(
resource
.
getEmployeeId
()).
getDateOfJoining
();
if
(
resource
.
getNewBillingStartDate
().
compareTo
(
empDoj
)
<
0
)
{
response
=
"Resource Start Date ("
+
resource
.
getNewBillingStartDate
()
+
" ) in "
+
resource
.
getProjectName
()
+
" project should not be before Date of Joining ( "
+
empDoj
+
")."
;
}
return
response
;
}
@Override
public
Resource
deleteResource
(
String
empId
,
String
projectId
,
ObjectId
id
,
String
loginEmpId
)
{
...
...
@@ -668,17 +659,28 @@ public class ResourceService implements IResourceService {
}
private
String
validateNewProjectAssignmentStartDate
(
List
<
Resource
>
teamMateList
,
Resource
projectTeamMate
)
{
private
String
validateNewProjectAssignmentStartDate
(
List
<
Resource
>
resourceList
,
Resource
resourceReq
)
{
String
response
=
null
;
if
(
teamMateList
!=
null
&&
teamMat
eList
.
size
()
>
0
)
{
Resource
ptMate
=
teamMat
eList
.
get
(
0
);
if
(
projectTeamMate
.
getNewBillingStartDate
().
compareTo
(
ptMat
e
.
getEndDate
())
<=
0
)
{
response
=
"Resource Start Date ("
+
projectTeamMate
.
getNewBillingStartDate
()
+
" ) in "
+
projectTeamMate
.
getProjectName
()
+
" project should be after "
+
ptMate
.
getProjectName
()
+
" project End Date ( "
+
ptMat
e
.
getEndDate
()
+
")."
;
if
(
resourceList
!=
null
&&
resourc
eList
.
size
()
>
0
)
{
Resource
resource
=
resourc
eList
.
get
(
0
);
if
(
resourceReq
.
getNewBillingStartDate
().
compareTo
(
resourc
e
.
getEndDate
())
<=
0
)
{
response
=
"Resource Start Date ("
+
resourceReq
.
getNewBillingStartDate
()
+
" ) in "
+
resourceReq
.
getProjectName
()
+
" project should be after "
+
resource
.
getProjectName
()
+
" project End Date ( "
+
resourc
e
.
getEndDate
()
+
")."
;
}
}
else
{
response
=
validateAgainstDOJ
(
projectTeamMate
);
response
=
validateAgainstDOJ
(
resourceReq
);
}
return
response
;
}
private
String
validateAgainstDOJ
(
Resource
resource
)
{
String
response
=
null
;
Date
empDoj
=
employeeRepo
.
findByEmployeeId
(
resource
.
getEmployeeId
()).
getDateOfJoining
();
if
(
resource
.
getNewBillingStartDate
().
compareTo
(
empDoj
)
<
0
)
{
response
=
"Resource Start Date ("
+
resource
.
getNewBillingStartDate
()
+
" ) in "
+
resource
.
getProjectName
()
+
" project should not be before Date of Joining ( "
+
empDoj
+
")."
;
}
return
response
;
}
}
src/main/java/com/nisum/myteam/statuscodes/ResourceStatus.java
View file @
fed165ca
package
com
.
nisum
.
myteam
.
statuscodes
;
public
class
ResourceStatus
{
public
enum
ResourceStatus
{
ACTIVE
(
"Active"
),
IN_ACTIVE
(
"InActive"
);
private
String
status
;
private
ResourceStatus
(
String
status
)
{
this
.
status
=
status
;
}
public
String
getStatus
()
{
return
this
.
status
;
}
}
src/main/java/com/nisum/myteam/utils/MyTeamUtils.java
View file @
fed165ca
...
...
@@ -155,8 +155,8 @@ public class MyTeamUtils {
public
final
static
String
PROJECT_START_DATE
=
"ProjectStartDate"
;
public
final
static
String
PROJECT_END_DATE
=
"ProjectEndDate"
;
public
final
static
String
BILLING_START_DATE
=
"
B
illingStartDate"
;
public
final
static
String
BILLING_END_DATE
=
"
B
illingEndDate"
;
public
final
static
String
BILLING_START_DATE
=
"
b
illingStartDate"
;
public
final
static
String
BILLING_END_DATE
=
"
b
illingEndDate"
;
}
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