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
abd738af
Commit
abd738af
authored
Jun 10, 2019
by
Vijay Akula
Browse files
Options
Browse Files
Download
Plain Diff
Allocation Change Service implementation
parents
f3e83121
125a898d
Changes
14
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
770 additions
and
616 deletions
+770
-616
ReportsController.java
...n/java/com/nisum/myteam/controller/ReportsController.java
+64
-38
BillableEmployee.java
src/main/java/com/nisum/myteam/model/BillableEmployee.java
+30
-0
ResourceRepo.java
src/main/java/com/nisum/myteam/repository/ResourceRepo.java
+7
-0
IEmployeeService.java
src/main/java/com/nisum/myteam/service/IEmployeeService.java
+58
-55
IResourceService.java
src/main/java/com/nisum/myteam/service/IResourceService.java
+83
-80
EmployeeService.java
...n/java/com/nisum/myteam/service/impl/EmployeeService.java
+357
-323
ResourceService.java
...n/java/com/nisum/myteam/service/impl/ResourceService.java
+141
-95
application.properties
src/main/resources/application.properties
+8
-8
AllocationChangeController.js
.../webapp/WEB-INF/controllers/AllocationChangeController.js
+11
-11
ChartsController.js
src/main/webapp/WEB-INF/controllers/ChartsController.js
+5
-2
custom-theme.css
src/main/webapp/WEB-INF/css/custom-theme.css
+3
-0
app.js
src/main/webapp/WEB-INF/js/app.js
+1
-1
login.html
src/main/webapp/WEB-INF/templates/login.html
+1
-2
projectTeamDetails.html
src/main/webapp/WEB-INF/templates/projectTeamDetails.html
+1
-1
No files found.
src/main/java/com/nisum/myteam/controller/ReportsController.java
View file @
abd738af
package
com
.
nisum
.
myteam
.
controller
;
import
com.nisum.myteam.exception.handler.MyTeamException
;
import
com.nisum.myteam.exception.handler.ResponseDetails
;
import
com.nisum.myteam.model.ColumnChartData
;
import
com.nisum.myteam.model.GroupByCount
;
import
com.nisum.myteam.model.ReportSeriesRecord
;
import
com.nisum.myteam.model.dao.Account
;
import
com.nisum.myteam.model.dao.Employee
;
import
com.nisum.myteam.model.dao.Resource
;
import
com.nisum.myteam.model.vo.ReportVo
;
import
com.nisum.myteam.model.vo.ResourceVO
;
import
com.nisum.myteam.service.IAccountService
;
import
com.nisum.myteam.service.IEmployeeService
;
import
com.nisum.myteam.service.IResourceService
;
import
static
org
.
springframework
.
data
.
mongodb
.
core
.
aggregation
.
Aggregation
.
group
;
import
static
org
.
springframework
.
data
.
mongodb
.
core
.
aggregation
.
Aggregation
.
newAggregation
;
import
static
org
.
springframework
.
data
.
mongodb
.
core
.
aggregation
.
Aggregation
.
project
;
import
static
org
.
springframework
.
data
.
mongodb
.
core
.
aggregation
.
Aggregation
.
sort
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.util.ArrayList
;
import
java.util.Calendar
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Sort
;
import
org.springframework.data.mongodb.core.MongoTemplate
;
...
...
@@ -25,19 +28,26 @@ import org.springframework.data.mongodb.core.query.Query;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.MediaType
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.web.bind.annotation.*
;
import
javax.servlet.http.HttpServletRequest
;
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
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.util.*
;
import
java.util.stream.Collectors
;
import
static
org
.
springframework
.
data
.
mongodb
.
core
.
aggregation
.
Aggregation
.*;
import
com.nisum.myteam.exception.handler.MyTeamException
;
import
com.nisum.myteam.model.BillableEmployee
;
import
com.nisum.myteam.model.ColumnChartData
;
import
com.nisum.myteam.model.GroupByCount
;
import
com.nisum.myteam.model.ReportSeriesRecord
;
import
com.nisum.myteam.model.dao.Account
;
import
com.nisum.myteam.model.dao.Employee
;
import
com.nisum.myteam.model.dao.Resource
;
import
com.nisum.myteam.model.vo.ReportVo
;
import
com.nisum.myteam.model.vo.ResourceVO
;
import
com.nisum.myteam.service.IAccountService
;
import
com.nisum.myteam.service.IEmployeeService
;
import
com.nisum.myteam.service.IResourceService
;
//import com.nisum.myteam.model.dao.Resource;
@RestController
@RequestMapping
(
"/reports"
)
...
...
@@ -56,7 +66,7 @@ public class ReportsController {
@Autowired
private
IAccountService
accountService
;
//Ok Response
//Ok Response
@RequestMapping
(
value
=
"/getEmployeesByFunctionalGroup1"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
...
...
@@ -220,7 +230,6 @@ public class ReportsController {
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
List
<
Map
<
String
,
List
<
GroupByCount
>>>>
getEmployeesByFunctionalGroup1
()
throws
MyTeamException
{
ProjectionOperation
projectToMatchModel
=
project
()
.
andExpression
(
"functionalGroup"
).
as
(
"name"
).
andExpression
(
"y"
)
.
as
(
"y"
);
...
...
@@ -248,13 +257,13 @@ public class ReportsController {
return
new
ResponseEntity
<>(
list
,
HttpStatus
.
OK
);
}
@RequestMapping
(
value
=
"/fetchEmployeeDetailsByFG"
,
@RequestMapping
(
value
=
"/fetchEmployeeDetailsByFG
AndBillability
"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
List
<
Employee
>>
getEmployeesByFG
(
@RequestParam
(
"fGroup"
)
String
fGroup
)
throws
MyTeamException
{
List
<
Employee
>
empList
=
new
ArrayList
<>();
empList
=
employeeService
.
getEmployee
sByFunctionalGrp
(
fGroup
);
public
ResponseEntity
<
List
<
BillableEmployee
>>
getEmployeesByFGAndBillability
(
@RequestParam
(
"fGroup"
)
String
fGroup
,
@RequestParam
(
"billableStatus"
)
String
billableStatus
)
throws
MyTeamException
{
List
<
Billable
Employee
>
empList
=
new
ArrayList
<>();
empList
=
employeeService
.
getEmployee
DetailsByFGAndBillability
(
fGroup
,
billableStatus
);
return
new
ResponseEntity
<>(
empList
,
HttpStatus
.
OK
);
}
...
...
@@ -311,7 +320,6 @@ public class ReportsController {
return
new
ResponseEntity
<>(
empList
,
HttpStatus
.
OK
);
}
@RequestMapping
(
value
=
"/billabilityByFunctionalGroup"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
...
...
@@ -320,44 +328,58 @@ public class ReportsController {
ReportVo
reportVo
=
new
ReportVo
();
Map
<
String
,
Object
>
billableData
=
new
HashMap
();
Map
<
String
,
Object
>
nonBillableData
=
new
HashMap
();
Map
<
String
,
Object
>
traineeData
=
new
HashMap
();
List
<
Object
>
billableCount
=
new
ArrayList
<>();
List
<
Object
>
nonBillableCount
=
new
ArrayList
<>();
List
<
Object
>
traineeCount
=
new
ArrayList
<>();
billableData
.
put
(
"name"
,
"Billable"
);
nonBillableData
.
put
(
"name"
,
"Non Billable"
);
nonBillableData
.
put
(
"name"
,
"Non-Billable"
);
traineeData
.
put
(
"name"
,
"Trainee"
);
for
(
String
functionalGroup:
reportVo
.
getCategoriesList
()){
Map
<
String
,
Object
>
billableObj
=
new
HashMap
();
Map
<
String
,
Object
>
nonbillableObj
=
new
HashMap
();
// Map<String,Object> traineeObj = new HashMap();
Integer
billableC
=
0
;
Integer
nonBillableC
=
0
;
Integer
traineeC
=
0
;
// float traineePer;
float
billper
;
float
nonBillPer
;
List
<
Employee
>
employeeList
=
employeeService
.
getAllEmployees
().
stream
().
filter
(
e
->
e
.
getFunctionalGroup
().
equals
(
functionalGroup
)).
collect
(
Collectors
.
toList
());
List
<
Employee
>
employeeList
=
employeeService
.
getEmployeesByFunctionalGrp
(
functionalGroup
);
for
(
Employee
employee:
employeeList
){
Resource
resource
=
resourceService
.
getLatestResourceByEmpId
(
employee
.
getEmployeeId
());
if
(
resource
!=
null
&&
resource
.
getBillableStatus
().
equals
(
"Billable"
)){
billableC
++;
}
else
{
}
else
if
(
resource
!=
null
&&
resource
.
getBillableStatus
().
equals
(
"Trainee"
))
{
traineeC
++;
}
else
{
nonBillableC
++;
}
}
billper
=
((
billableC
/
(
float
)
employeeList
.
size
())*
100
);
nonBillPer
=
nonBillableC
/(
float
)
employeeList
.
size
()*
100
;
billper
=
((
billableC
/
(
float
)(
employeeList
.
size
()
-
traineeC
))*
100
);
nonBillPer
=
nonBillableC
/(
float
)
(
employeeList
.
size
()-
traineeC
)*
100
;
// traineePer = traineeC / (float) employeeList.size()*100;
billableObj
.
put
(
"percent"
,
billper
);
billableObj
.
put
(
"y"
,
billableC
);
nonbillableObj
.
put
(
"percent"
,
nonBillPer
);
nonbillableObj
.
put
(
"y"
,
nonBillableC
);
// traineeObj.put("percent", traineePer);
// traineeObj.put("y", traineeC);
billableCount
.
add
(
billableObj
);
nonBillableCount
.
add
(
nonbillableObj
);
traineeCount
.
add
(
traineeC
);
}
billableData
.
put
(
"data"
,
billableCount
);
nonBillableData
.
put
(
"data"
,
nonBillableCount
);
traineeData
.
put
(
"data"
,
traineeCount
);
reportVo
.
getSeriesDataList
().
add
(
billableData
);
reportVo
.
getSeriesDataList
().
add
(
nonBillableData
);
reportVo
.
getSeriesDataList
().
add
(
traineeData
);
return
reportVo
;
}
//Not Ok Response
@RequestMapping
(
value
=
"/getBillabilityDetailsByAccount"
,
method
=
RequestMethod
.
GET
,
...
...
@@ -365,6 +387,7 @@ public class ReportsController {
public
ResponseEntity
<
ColumnChartData
>
getBillabilityDetailsByAccount
()
throws
MyTeamException
{
ProjectionOperation
projectToMatchModel
=
project
()
.
andExpression
(
"account"
).
as
(
"categories"
)
.
andExpression
(
"billableStatus"
).
as
(
"seriesName"
)
...
...
@@ -380,7 +403,7 @@ public class ReportsController {
// Convert the aggregation result into a List
AggregationResults
<
ColumnChartData
>
groupResults
=
mongoTemplate
.
aggregate
(
aggregate
,
Resource
.
class
,
ColumnChartData
.
class
);
ColumnChartData
.
class
);
List
<
ColumnChartData
>
result
=
groupResults
.
getMappedResults
();
List
<
String
>
statusList
=
new
ArrayList
();
statusList
.
add
(
"Billable"
);
...
...
@@ -390,7 +413,12 @@ public class ReportsController {
List
<
String
>
catagories
=
new
ArrayList
();
List
<
ReportSeriesRecord
>
seriesDetails
=
new
ArrayList
<
ReportSeriesRecord
>();
List
<
Account
>
accounts
=
accountService
.
getAllAccounts
();
//List<Account> accounts = employeeService.getAccounts();
List
<
Account
>
accounts
=
accountService
.
getAllAccounts
();
ColumnChartData
reportData
=
new
ColumnChartData
();
for
(
String
status
:
statusList
)
{
catagories
=
new
ArrayList
();
...
...
@@ -422,7 +450,6 @@ public class ReportsController {
seriesDetails
.
add
(
reportSeriesRecord
);
}
System
.
out
.
println
(
seriesDetails
);
reportData
.
setCategoriesList
(
catagories
);
reportData
.
setSeriesDataList
(
seriesDetails
);
return
new
ResponseEntity
<>(
reportData
,
HttpStatus
.
OK
);
...
...
@@ -430,4 +457,3 @@ public class ReportsController {
}
src/main/java/com/nisum/myteam/model/BillableEmployee.java
0 → 100644
View file @
abd738af
package
com
.
nisum
.
myteam
.
model
;
import
java.io.Serializable
;
import
java.util.Date
;
import
lombok.AllArgsConstructor
;
import
lombok.Getter
;
import
lombok.NoArgsConstructor
;
import
lombok.Setter
;
import
lombok.ToString
;
@Setter
@Getter
@AllArgsConstructor
@NoArgsConstructor
@ToString
public
class
BillableEmployee
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
private
String
employeeId
;
private
String
employeeName
;
private
String
emailId
;
private
String
projectName
;
private
String
billableStatus
;
private
Date
billingStartDate
;
private
Date
billingEndDate
;
private
String
functionalGroup
;
}
src/main/java/com/nisum/myteam/repository/ResourceRepo.java
View file @
abd738af
...
...
@@ -7,6 +7,7 @@ import org.springframework.data.mongodb.repository.MongoRepository;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Set
;
public
interface
ResourceRepo
extends
MongoRepository
<
Resource
,
String
>
{
...
...
@@ -24,6 +25,12 @@ public interface ResourceRepo
List
<
Resource
>
findByBillingStartDateGreaterThan
(
Date
billingStartDate
);
List
<
Resource
>
findByBillingStartDateBetween
(
Date
fromDate
,
Date
toDate
);
//Set<Resource> findByBillableStatus(String resourceAllocationStatus);
Resource
findOneByProjectIdAndEmployeeIdAndBillingEndDate
(
String
projectId
,
String
employeeId
,
Date
billingEndDate
);
Resource
findOneByEmployeeIdAndBillingEndDate
(
String
employeeId
,
Date
billingEndDate
);
// List<Resource> findByEmployeeIdAndActive(String employeeId, boolean status);
...
...
src/main/java/com/nisum/myteam/service/IEmployeeService.java
View file @
abd738af
package
com
.
nisum
.
myteam
.
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
);
Employee
createEmployee
(
Employee
employeeRoles
,
String
empId
)
throws
MyTeamException
;
Employee
updateEmployee
(
Employee
employeeRoles
,
String
empId
);
Employee
deleteEmployee
(
String
empId
);
Employee
updateProfile
(
Employee
employeeRoles
)
throws
MyTeamException
;
Employee
getEmployeeById
(
String
empId
);
Employee
getEmployeeByEmaillId
(
String
emailId
);
List
<
Employee
>
getManagers
()
throws
MyTeamException
;
List
<
Employee
>
getActiveEmployees
()
throws
MyTeamException
;
List
<
Employee
>
getEmployeesByStatus
(
String
status
);
List
<
Account
>
getAccounts
()
throws
MyTeamException
;
Employee
getEmployeeRoleDataForSearchCriteria
(
String
searchId
,
String
searchAttribute
);
List
<
String
>
getEmployeeDetailsForAutocomplete
();
List
<
HashMap
<
String
,
String
>>
getDeliveryLeads
(
String
domainId
);
List
<
Employee
>
getEmployeesByFunctionalGrp
(
String
functionalGrp
);
boolean
verifyEmployeeRole
(
String
empId
,
String
roleName
);
List
<
Employee
>
getEmployeesFromList
(
Set
<
String
>
empIdsSet
);
List
<
HashMap
<
String
,
String
>>
getDeliveryManagerMap
(
List
deliveryManagerIdsList
);
public
List
<
Employee
>
getAllEmployees
();
public
List
<
Employee
>
getEmployeesByEmpStatusAndShift
(
String
empStatus
,
String
shift
);
}
package
com
.
nisum
.
myteam
.
service
;
import
com.nisum.myteam.exception.handler.MyTeamException
;
import
com.nisum.myteam.model.BillableEmployee
;
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
);
Employee
createEmployee
(
Employee
employeeRoles
,
String
empId
)
throws
MyTeamException
;
Employee
updateEmployee
(
Employee
employeeRoles
,
String
empId
);
Employee
deleteEmployee
(
String
empId
);
Employee
updateProfile
(
Employee
employeeRoles
)
throws
MyTeamException
;
Employee
getEmployeeById
(
String
empId
);
Employee
getEmployeeByEmaillId
(
String
emailId
);
List
<
Employee
>
getManagers
()
throws
MyTeamException
;
List
<
Employee
>
getActiveEmployees
()
throws
MyTeamException
;
List
<
Employee
>
getEmployeesByStatus
(
String
status
);
List
<
Account
>
getAccounts
()
throws
MyTeamException
;
Employee
getEmployeeRoleDataForSearchCriteria
(
String
searchId
,
String
searchAttribute
);
List
<
String
>
getEmployeeDetailsForAutocomplete
();
List
<
HashMap
<
String
,
String
>>
getDeliveryLeads
(
String
domainId
);
List
<
Employee
>
getEmployeesByFunctionalGrp
(
String
functionalGrp
);
boolean
verifyEmployeeRole
(
String
empId
,
String
roleName
);
List
<
Employee
>
getEmployeesFromList
(
Set
<
String
>
empIdsSet
);
List
<
HashMap
<
String
,
String
>>
getDeliveryManagerMap
(
List
deliveryManagerIdsList
);
public
List
<
Employee
>
getAllEmployees
();
public
List
<
Employee
>
getEmployeesByEmpStatusAndShift
(
String
empStatus
,
String
shift
);
List
<
BillableEmployee
>
getEmployeeDetailsByFGAndBillability
(
String
fGroup
,
String
billableStatus
);
}
src/main/java/com/nisum/myteam/service/IResourceService.java
View file @
abd738af
package
com
.
nisum
.
myteam
.
service
;
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.vo.EmployeeShiftsVO
;
import
com.nisum.myteam.model.vo.MyProjectAllocationVO
;
import
com.nisum.myteam.model.vo.ReserveReportsVO
;
import
com.nisum.myteam.model.vo.ResourceVO
;
import
java.util.Date
;
import
java.util.List
;
public
interface
IResourceService
{
Resource
addResource
(
Resource
resourceAllocation
,
String
loginEmpId
)
throws
MyTeamException
;
public
void
updateExistedResource
(
Resource
resourceAlloc
)
throws
MyTeamException
;
public
void
insertNewResourceWithNewStatus
(
Resource
resourceAllocReq
,
String
loginEmpId
)
throws
MyTeamException
;
void
deleteResource
(
Resource
resource
,
String
loginEmpId
);
List
<
Resource
>
getAllResourcesForAllActiveProjects
();
List
<
Resource
>
getResourcesSortByBillingStartDate
(
String
employeeId
);
List
<
ResourceVO
>
getActiveResources
(
String
empId
);
public
List
<
ResourceVO
>
getResourcesForProject
(
String
projectId
,
String
statusFlag
);
public
List
<
Resource
>
getResourcesUnderDeliveryLead
(
String
empId
);
public
List
<
ResourceVO
>
getBillingsForEmployee
(
String
empId
);
public
List
<
Resource
>
getBillingsForProject
(
String
empId
,
String
projectId
);
public
List
<
MyProjectAllocationVO
>
getWorkedProjectsForResource
(
String
empId
);
public
List
<
Employee
>
getUnAssignedEmployees
();
public
List
<
Resource
>
getAllResources
();
public
List
<
ResourceVO
>
getAllResourcesVO
();
public
void
deleteResourcesUnderProject
(
String
projectId
);
public
Resource
addResourceToBenchProject
(
Employee
employee
,
String
loginEmpId
)
throws
MyTeamException
;
public
List
<
EmployeeShiftsVO
>
getResourcesForShift
(
String
shift
);
public
Resource
getLatestResourceByEmpId
(
String
employeeId
);
public
List
<
Resource
>
getResourcesByBillingStatus
(
String
resourceStatus
);
public
List
<
ReserveReportsVO
>
prepareReserveReports
(
List
<
Resource
>
resourcesList
);
public
List
<
ReserveReportsVO
>
getResourceReportsByBillingStatus
(
String
resourceStatus
);
// List<Resource> getAllResourcesForProject(String projectId, String status);
// List<Resource> getResourcesForEmployee(String empId);
// List<Resource> getAllResourcesForProject(String projectId);
// Resource save(Resource resource);
// void addResources(Employee employee, String loginEmpId);
// void inactivateResource(Employee employeeReq, Employee employeeUpdated, String loginEmpId);
}
package
com
.
nisum
.
myteam
.
service
;
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.vo.EmployeeShiftsVO
;
import
com.nisum.myteam.model.vo.MyProjectAllocationVO
;
import
com.nisum.myteam.model.vo.ReserveReportsVO
;
import
com.nisum.myteam.model.vo.ResourceVO
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Set
;
public
interface
IResourceService
{
Resource
addResource
(
Resource
resourceAllocation
,
String
loginEmpId
)
throws
MyTeamException
;
public
void
updateExistedResource
(
Resource
resourceAlloc
)
throws
MyTeamException
;
public
void
insertNewResourceWithNewStatus
(
Resource
resourceAllocReq
,
String
loginEmpId
)
throws
MyTeamException
;
void
deleteResource
(
Resource
resource
,
String
loginEmpId
);
List
<
Resource
>
getAllResourcesForAllActiveProjects
();
List
<
Resource
>
getResourcesSortByBillingStartDate
(
String
employeeId
);
List
<
ResourceVO
>
getActiveResources
(
String
empId
);
public
List
<
ResourceVO
>
getResourcesForProject
(
String
projectId
,
String
statusFlag
);
public
List
<
Resource
>
getResourcesUnderDeliveryLead
(
String
empId
);
public
List
<
ResourceVO
>
getBillingsForEmployee
(
String
empId
);
public
List
<
Resource
>
getBillingsForProject
(
String
empId
,
String
projectId
);
public
List
<
MyProjectAllocationVO
>
getWorkedProjectsForResource
(
String
empId
);
public
List
<
Employee
>
getUnAssignedEmployees
();
public
List
<
Resource
>
getAllResources
();
public
List
<
ResourceVO
>
getAllResourcesVO
();
public
void
deleteResourcesUnderProject
(
String
projectId
);
public
Resource
addResourceToBenchProject
(
Employee
employee
,
String
loginEmpId
)
throws
MyTeamException
;
public
List
<
EmployeeShiftsVO
>
getResourcesForShift
(
String
shift
);
public
Resource
getLatestResourceByEmpId
(
String
employeeId
);
public
List
<
Resource
>
getResourcesByBillingStatus
(
String
resourceStatus
);
public
List
<
ReserveReportsVO
>
prepareReserveReports
(
List
<
Resource
>
resourcesList
);
public
List
<
ReserveReportsVO
>
getResourceReportsByBillingStatus
(
String
resourceStatus
);
Set
<
Resource
>
findByBillableStatus
(
String
billableStatus
);
// List<Resource> getAllResourcesForProject(String projectId, String status);
// List<Resource> getResourcesForEmployee(String empId);
// List<Resource> getAllResourcesForProject(String projectId);
// Resource save(Resource resource);
// void addResources(Employee employee, String loginEmpId);
// void inactivateResource(Employee employeeReq, Employee employeeUpdated, String loginEmpId);
}
src/main/java/com/nisum/myteam/service/impl/EmployeeService.java
View file @
abd738af
package
com
.
nisum
.
myteam
.
service
.
impl
;
import
com.nisum.myteam.exception.handler.MyTeamException
;
import
com.nisum.myteam.model.dao.Account
;
import
com.nisum.myteam.model.dao.Domain
;
import
com.nisum.myteam.model.dao.Employee
;
import
com.nisum.myteam.repository.EmployeeRepo
;
import
com.nisum.myteam.service.*
;
import
com.nisum.myteam.utils.MyTeamUtils
;
import
com.nisum.myteam.utils.constants.ApplicationRole
;
import
com.nisum.myteam.utils.constants.RoleConstant
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Sort
;
import
org.springframework.data.mongodb.core.FindAndModifyOptions
;
import
org.springframework.data.mongodb.core.MongoTemplate
;
import
org.springframework.data.mongodb.core.query.Criteria
;
import
org.springframework.data.mongodb.core.query.Query
;
import
org.springframework.data.mongodb.core.query.Update
;
import
org.springframework.stereotype.Service
;
import
java.util.*
;
import
java.util.stream.Collectors
;
@Service
@Slf4j
public
class
EmployeeService
implements
IEmployeeService
{
@Autowired
private
EmployeeRepo
employeeRepo
;
@Autowired
private
MongoTemplate
mongoTemplate
;
@Autowired
private
IAccountService
accountService
;
@Autowired
private
IProjectService
projectService
;
@Autowired
private
IDomainService
domainService
;
@Autowired
private
IEmployeeRoleService
employeeRoleService
;
@Autowired
private
IEmployeeLocationService
empLocationService
;
@Autowired
private
IResourceService
resourceService
;
@Override
public
Employee
createEmployee
(
Employee
employee
,
String
loginEmpId
)
throws
MyTeamException
{
employee
.
setCreatedOn
(
new
Date
());
employee
.
setCreatedBy
(
loginEmpId
);
employee
.
setModifiedBy
(
loginEmpId
);
// adding employee to Bench Allocation
resourceService
.
addResourceToBenchProject
(
employee
,
loginEmpId
);
// Saving employee Location Details.
empLocationService
.
save
(
employee
);
return
employeeRepo
.
save
(
employee
);
}
@Override
public
Employee
updateEmployee
(
Employee
employeeReq
,
String
loginEmpId
)
{
// update all emp details to inactive if employee is inactive
Query
query
=
new
Query
(
Criteria
.
where
(
"employeeId"
).
is
(
employeeReq
.
getEmployeeId
()));
Update
update
=
new
Update
();
update
.
set
(
"employeeName"
,
employeeReq
.
getEmployeeName
());
update
.
set
(
"emailId"
,
employeeReq
.
getEmailId
());
update
.
set
(
"role"
,
employeeReq
.
getRole
());
update
.
set
(
"gender"
,
employeeReq
.
getGender
());
update
.
set
(
"functionalGroup"
,
employeeReq
.
getFunctionalGroup
());
update
.
set
(
"empStatus"
,
employeeReq
.
getEmpStatus
());
update
.
set
(
"empSubStatus"
,
employeeReq
.
getEmpSubStatus
());
update
.
set
(
"employmentType"
,
employeeReq
.
getEmploymentType
());
update
.
set
(
"empLocation"
,
employeeReq
.
getEmpLocation
());
// update.set("domain", employeeReq.getDomain());
update
.
set
(
"designation"
,
employeeReq
.
getDesignation
());
update
.
set
(
"dateOfBirth"
,
employeeReq
.
getDateOfBirth
());
update
.
set
(
"dateOfJoining"
,
employeeReq
.
getDateOfJoining
());
update
.
set
(
"lastModifiedOn"
,
new
Date
());
update
.
set
(
"hasPassort"
,
employeeReq
.
getHasPassort
());
update
.
set
(
"hasB1"
,
employeeReq
.
getHasB1
());
update
.
set
(
"passportExpiryDate"
,
employeeReq
.
getPassportExpiryDate
());
update
.
set
(
"b1ExpiryDate"
,
employeeReq
.
getB1ExpiryDate
());
update
.
set
(
"modifiedBy"
,
loginEmpId
);
if
(
employeeReq
.
getEmpStatus
().
equalsIgnoreCase
(
MyTeamUtils
.
IN_ACTIVE_SPACE
))
{
update
.
set
(
"endDate"
,
employeeReq
.
getEndDate
());
update
.
set
(
"empSubStatus"
,
null
);
}
// update employee location
if
(
employeeReq
.
getEmpLocation
()
!=
null
&&
!
employeeReq
.
getEmpLocation
().
equals
(
""
))
{
Employee
existingEmployee
=
employeeRepo
.
findByEmployeeId
(
employeeReq
.
getEmployeeId
());
if
(!
existingEmployee
.
getEmpLocation
().
equals
(
employeeReq
.
getEmpLocation
()))
{
empLocationService
.
update
(
employeeReq
,
false
);
}
}
// update employee details
FindAndModifyOptions
options
=
new
FindAndModifyOptions
();
options
.
returnNew
(
true
);
options
.
upsert
(
true
);
Employee
employeeUpdated
=
mongoTemplate
.
findAndModify
(
query
,
update
,
options
,
Employee
.
class
);
try
{
// add to resource collection
//resourceService.addResources(employeeUpdated, loginEmpId);
// inactive the employee from the assigned project.
//resourceService.inactivateResource(employeeReq, employeeUpdated, loginEmpId);
}
catch
(
Exception
e
)
{
}
return
employeeUpdated
;
}
@Override
public
Employee
deleteEmployee
(
String
employeeId
)
{
Query
query
=
new
Query
();
query
.
addCriteria
(
Criteria
.
where
(
"employeeId"
).
is
(
employeeId
));
Update
update
=
new
Update
();
update
.
set
(
"empStatus"
,
"InActive"
);
Employee
employeeUpdated
=
mongoTemplate
.
findAndModify
(
query
,
update
,
Employee
.
class
);
log
.
info
(
"The Deletion operation Result::"
+
employeeUpdated
);
return
employeeUpdated
;
}
@Override
public
Employee
updateProfile
(
Employee
employeeReq
)
throws
MyTeamException
{
boolean
mobileNumberChanged
=
false
;
employeeReq
.
setLastModifiedOn
(
new
Date
());
Employee
existingEmployee
=
employeeRepo
.
findByEmployeeId
(
employeeReq
.
getEmployeeId
());
String
newMobileNumber
=
employeeReq
.
getMobileNumber
();
if
(
newMobileNumber
!=
null
&&
!
newMobileNumber
.
equalsIgnoreCase
(
""
))
{
if
((
existingEmployee
!=
null
&&
existingEmployee
.
getMobileNumber
()
!=
null
&&
!
existingEmployee
.
getMobileNumber
().
equalsIgnoreCase
(
newMobileNumber
))
||
(
existingEmployee
.
getMobileNumber
()
==
null
))
{
mobileNumberChanged
=
true
;
}
}
existingEmployee
.
setMobileNumber
(
employeeReq
.
getMobileNumber
());
existingEmployee
.
setAlternateMobileNumber
(
employeeReq
.
getAlternateMobileNumber
());
existingEmployee
.
setPersonalEmailId
(
employeeReq
.
getPersonalEmailId
());
existingEmployee
.
setBaseTechnology
(
employeeReq
.
getBaseTechnology
());
existingEmployee
.
setTechnologyKnown
(
employeeReq
.
getTechnologyKnown
());
Employee
employeePersisted
=
employeeRepo
.
save
(
existingEmployee
);
return
employeePersisted
;
}
public
boolean
isEmployeeExistsById
(
String
employeeId
)
{
Employee
employeeFound
=
getEmployeeById
(
employeeId
);
return
(
employeeFound
==
null
)
?
false
:
true
;
}
@Override
public
Employee
getEmployeeById
(
String
employeeId
)
{
log
.
info
(
"The employeeId::"
+
employeeId
);
Employee
employee
=
employeeRepo
.
findByEmployeeId
(
employeeId
);
log
.
info
(
"Employee Found in Repo::"
+
employee
);
return
employee
;
}
@Override
public
List
<
Employee
>
getAllEmployees
()
{
return
employeeRepo
.
findAll
();
}
@Override
public
Employee
getEmployeeByEmaillId
(
String
emailId
)
{
return
employeeRepo
.
findByEmailId
(
emailId
);
}
@Override
public
List
<
Employee
>
getEmployeesByEmpStatusAndShift
(
String
empStatus
,
String
shift
)
{
return
employeeRepo
.
findByEmpStatusAndShiftLikeOrderByEmployeeIdDesc
(
empStatus
,
shift
);
}
public
List
<
Employee
>
getManagers
()
throws
MyTeamException
{
List
<
Employee
>
activeEmpsList
=
getActiveEmployees
();
List
<
Employee
>
managers
=
activeEmpsList
.
stream
()
.
filter
(
employee
->
(
RoleConstant
.
DIRECTOR
.
getRoleName
().
equalsIgnoreCase
(
employee
.
getRole
())
||
RoleConstant
.
DELIVERY_MANAGER
.
getRoleName
().
equalsIgnoreCase
(
employee
.
getRole
())
||
RoleConstant
.
MANAGER
.
getRoleName
().
equalsIgnoreCase
(
employee
.
getRole
())
||
RoleConstant
.
HR_MANAGER
.
getRoleName
().
equalsIgnoreCase
(
employee
.
getRole
())
||
RoleConstant
.
LEAD
.
getRoleName
().
equalsIgnoreCase
(
employee
.
getRole
())))
.
sorted
(
Comparator
.
comparing
(
Employee:
:
getEmployeeName
)).
collect
(
Collectors
.
toList
());
return
managers
;
}
@Override
public
List
<
Employee
>
getActiveEmployees
()
throws
MyTeamException
{
return
employeeRepo
.
findByEmpStatus
(
MyTeamUtils
.
ACTIVE
);
}
@Override
public
List
<
Employee
>
getEmployeesByStatus
(
String
status
)
{
if
(
status
.
equals
(
"all"
))
{
return
employeeRepo
.
findAll
(
new
Sort
(
Sort
.
Direction
.
ASC
,
"employeeName"
));
}
else
if
(
status
.
equals
(
"Vacation"
))
{
Query
query
=
new
Query
();
query
.
addCriteria
(
Criteria
.
where
(
"empSubStatus"
).
ne
(
"Resigned"
).
andOperator
(
Criteria
.
where
(
"empSubStatus"
).
ne
(
null
),
Criteria
.
where
(
"empSubStatus"
).
ne
(
""
)));
return
mongoTemplate
.
find
(
query
,
Employee
.
class
);
}
else
if
(
status
.
equals
(
"Resigned"
))
{
return
employeeRepo
.
findByEmpSubStatusOrderByEmployeeNameAsc
(
"Resigned"
);
}
else
{
return
employeeRepo
.
findByEmpStatus
(
status
);
}
}
@Override
public
List
<
Account
>
getAccounts
()
throws
MyTeamException
{
return
accountService
.
getAllAccounts
();
}
@Override
public
Employee
getEmployeeRoleDataForSearchCriteria
(
String
searchId
,
String
searchAttribute
)
{
if
(
MyTeamUtils
.
EMPLOYEE_NAME
.
equals
(
searchAttribute
))
{
return
employeeRepo
.
findByEmployeeName
(
searchId
);
}
else
if
(
MyTeamUtils
.
EMAIL_ID
.
equals
(
searchAttribute
))
{
return
employeeRepo
.
findByEmailId
(
searchId
);
}
return
null
;
}
@Override
public
List
<
String
>
getEmployeeDetailsForAutocomplete
()
{
List
<
Employee
>
employeeList
=
employeeRepo
.
findAll
();
List
<
String
>
resultList
=
new
ArrayList
<>();
employeeList
.
stream
().
sorted
(
java
.
util
.
Comparator
.
comparing
(
Employee:
:
getEmployeeId
))
.
collect
(
Collectors
.
toList
()).
forEach
(
employee
->
{
resultList
.
add
(
employee
.
getEmployeeId
());
});
employeeList
.
stream
().
sorted
(
java
.
util
.
Comparator
.
comparing
(
Employee:
:
getEmployeeName
))
.
collect
(
Collectors
.
toList
()).
forEach
(
employee
->
{
resultList
.
add
(
employee
.
getEmployeeName
());
});
employeeList
.
stream
().
sorted
(
java
.
util
.
Comparator
.
comparing
(
Employee:
:
getEmailId
)).
collect
(
Collectors
.
toList
())
.
forEach
(
employee
->
{
resultList
.
add
(
employee
.
getEmailId
());
});
return
resultList
;
}
@Override
public
List
<
HashMap
<
String
,
String
>>
getDeliveryLeads
(
String
domainId
)
{
Domain
domain
=
domainService
.
getDomainById
(
domainId
);
return
getDeliveryManagerMap
(
domain
.
getDeliveryManagers
());
}
@Override
public
List
<
HashMap
<
String
,
String
>>
getDeliveryManagerMap
(
List
deliveryManagerIdsList
)
{
List
<
HashMap
<
String
,
String
>>
employeeList
=
new
ArrayList
<>();
Query
query
=
new
Query
(
Criteria
.
where
(
"employeeId"
).
in
(
deliveryManagerIdsList
));
List
<
Employee
>
employeePersistedList
=
mongoTemplate
.
find
(
query
,
Employee
.
class
);
for
(
Employee
employee
:
employeePersistedList
)
{
HashMap
<
String
,
String
>
managerMap
=
new
HashMap
<>();
managerMap
.
put
(
"employeeId"
,
employee
.
getEmployeeId
());
managerMap
.
put
(
"employeeName"
,
employee
.
getEmployeeName
());
employeeList
.
add
(
managerMap
);
}
return
employeeList
;
}
@Override
public
List
<
Employee
>
getEmployeesByFunctionalGrp
(
String
functionalGrp
)
{
return
employeeRepo
.
findByEmpStatusAndFunctionalGroup
(
"Active"
,
functionalGrp
);
}
@Override
public
boolean
verifyEmployeeRole
(
String
empId
,
String
roleIdReq
)
{
boolean
flag
=
false
;
Employee
employee
=
getEmployeeById
(
empId
);
String
roleName
=
employee
.
getRole
();
log
.
info
(
"The employee role::"
+
roleName
);
if
(
StringUtils
.
isNotBlank
(
roleName
)
&&
!
ApplicationRole
.
ADMIN
.
getRoleName
().
equalsIgnoreCase
(
roleName
))
{
if
(
ApplicationRole
.
FUNCTIONAL_MANAGER
.
getRoleName
().
equalsIgnoreCase
(
roleName
)
||
ApplicationRole
.
DELIVERY_LEAD
.
getRoleName
().
equalsIgnoreCase
(
roleName
))
{
flag
=
true
;
}
else
{
Set
<
String
>
roleSet
=
employeeRoleService
.
empRolesMapInfoByEmpId
(
empId
);
if
(
null
!=
roleSet
&&
!
roleSet
.
isEmpty
()
&&
MyTeamUtils
.
INT_ZERO
<
roleSet
.
size
())
{
if
(
roleSet
.
contains
(
roleIdReq
))
{
flag
=
true
;
}
}
}
}
return
flag
;
}
public
List
<
Employee
>
getEmployeesFromList
(
Set
<
String
>
empIdsSet
)
{
return
employeeRepo
.
findByEmployeeIdIn
(
empIdsSet
);
}
}
package
com
.
nisum
.
myteam
.
service
.
impl
;
import
java.util.ArrayList
;
import
java.util.Comparator
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Set
;
import
java.util.stream.Collectors
;
import
org.apache.commons.lang.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Sort
;
import
org.springframework.data.mongodb.core.FindAndModifyOptions
;
import
org.springframework.data.mongodb.core.MongoTemplate
;
import
org.springframework.data.mongodb.core.query.Criteria
;
import
org.springframework.data.mongodb.core.query.Query
;
import
org.springframework.data.mongodb.core.query.Update
;
import
org.springframework.stereotype.Service
;
import
com.nisum.myteam.exception.handler.MyTeamException
;
import
com.nisum.myteam.model.BillableEmployee
;
import
com.nisum.myteam.model.dao.Account
;
import
com.nisum.myteam.model.dao.Domain
;
import
com.nisum.myteam.model.dao.Employee
;
import
com.nisum.myteam.model.dao.Project
;
import
com.nisum.myteam.model.dao.Resource
;
import
com.nisum.myteam.repository.EmployeeRepo
;
import
com.nisum.myteam.service.IAccountService
;
import
com.nisum.myteam.service.IDomainService
;
import
com.nisum.myteam.service.IEmployeeLocationService
;
import
com.nisum.myteam.service.IEmployeeRoleService
;
import
com.nisum.myteam.service.IEmployeeService
;
import
com.nisum.myteam.service.IProjectService
;
import
com.nisum.myteam.service.IResourceService
;
import
com.nisum.myteam.statuscodes.ResourceStatus
;
import
com.nisum.myteam.utils.MyTeamUtils
;
import
com.nisum.myteam.utils.constants.ApplicationRole
;
import
com.nisum.myteam.utils.constants.RoleConstant
;
import
lombok.extern.slf4j.Slf4j
;
@Service
@Slf4j
public
class
EmployeeService
implements
IEmployeeService
{
@Autowired
private
EmployeeRepo
employeeRepo
;
@Autowired
private
MongoTemplate
mongoTemplate
;
@Autowired
private
IAccountService
accountService
;
@Autowired
private
IProjectService
projectService
;
@Autowired
private
IDomainService
domainService
;
@Autowired
private
IEmployeeRoleService
employeeRoleService
;
@Autowired
private
IEmployeeLocationService
empLocationService
;
@Autowired
private
IResourceService
resourceService
;
@Override
public
Employee
createEmployee
(
Employee
employee
,
String
loginEmpId
)
throws
MyTeamException
{
employee
.
setCreatedOn
(
new
Date
());
employee
.
setCreatedBy
(
loginEmpId
);
employee
.
setModifiedBy
(
loginEmpId
);
// adding employee to Bench Allocation
resourceService
.
addResourceToBenchProject
(
employee
,
loginEmpId
);
// Saving employee Location Details.
empLocationService
.
save
(
employee
);
return
employeeRepo
.
save
(
employee
);
}
@Override
public
Employee
updateEmployee
(
Employee
employeeReq
,
String
loginEmpId
)
{
// update all emp details to inactive if employee is inactive
Query
query
=
new
Query
(
Criteria
.
where
(
"employeeId"
).
is
(
employeeReq
.
getEmployeeId
()));
Update
update
=
new
Update
();
update
.
set
(
"employeeName"
,
employeeReq
.
getEmployeeName
());
update
.
set
(
"emailId"
,
employeeReq
.
getEmailId
());
update
.
set
(
"role"
,
employeeReq
.
getRole
());
update
.
set
(
"gender"
,
employeeReq
.
getGender
());
update
.
set
(
"functionalGroup"
,
employeeReq
.
getFunctionalGroup
());
update
.
set
(
"empStatus"
,
employeeReq
.
getEmpStatus
());
update
.
set
(
"empSubStatus"
,
employeeReq
.
getEmpSubStatus
());
update
.
set
(
"employmentType"
,
employeeReq
.
getEmploymentType
());
update
.
set
(
"empLocation"
,
employeeReq
.
getEmpLocation
());
// update.set("domain", employeeReq.getDomain());
update
.
set
(
"designation"
,
employeeReq
.
getDesignation
());
update
.
set
(
"dateOfBirth"
,
employeeReq
.
getDateOfBirth
());
update
.
set
(
"dateOfJoining"
,
employeeReq
.
getDateOfJoining
());
update
.
set
(
"lastModifiedOn"
,
new
Date
());
update
.
set
(
"hasPassort"
,
employeeReq
.
getHasPassort
());
update
.
set
(
"hasB1"
,
employeeReq
.
getHasB1
());
update
.
set
(
"passportExpiryDate"
,
employeeReq
.
getPassportExpiryDate
());
update
.
set
(
"b1ExpiryDate"
,
employeeReq
.
getB1ExpiryDate
());
update
.
set
(
"modifiedBy"
,
loginEmpId
);
if
(
employeeReq
.
getEmpStatus
().
equalsIgnoreCase
(
MyTeamUtils
.
IN_ACTIVE_SPACE
))
{
update
.
set
(
"endDate"
,
employeeReq
.
getEndDate
());
update
.
set
(
"empSubStatus"
,
null
);
}
// update employee location
if
(
employeeReq
.
getEmpLocation
()
!=
null
&&
!
employeeReq
.
getEmpLocation
().
equals
(
""
))
{
Employee
existingEmployee
=
employeeRepo
.
findByEmployeeId
(
employeeReq
.
getEmployeeId
());
if
(!
existingEmployee
.
getEmpLocation
().
equals
(
employeeReq
.
getEmpLocation
()))
{
empLocationService
.
update
(
employeeReq
,
false
);
}
}
// update employee details
FindAndModifyOptions
options
=
new
FindAndModifyOptions
();
options
.
returnNew
(
true
);
options
.
upsert
(
true
);
Employee
employeeUpdated
=
mongoTemplate
.
findAndModify
(
query
,
update
,
options
,
Employee
.
class
);
try
{
// add to resource collection
//resourceService.addResources(employeeUpdated, loginEmpId);
// inactive the employee from the assigned project.
//resourceService.inactivateResource(employeeReq, employeeUpdated, loginEmpId);
}
catch
(
Exception
e
)
{
}
return
employeeUpdated
;
}
@Override
public
Employee
deleteEmployee
(
String
employeeId
)
{
Query
query
=
new
Query
();
query
.
addCriteria
(
Criteria
.
where
(
"employeeId"
).
is
(
employeeId
));
Update
update
=
new
Update
();
update
.
set
(
"empStatus"
,
"InActive"
);
Employee
employeeUpdated
=
mongoTemplate
.
findAndModify
(
query
,
update
,
Employee
.
class
);
log
.
info
(
"The Deletion operation Result::"
+
employeeUpdated
);
return
employeeUpdated
;
}
@Override
public
Employee
updateProfile
(
Employee
employeeReq
)
throws
MyTeamException
{
boolean
mobileNumberChanged
=
false
;
employeeReq
.
setLastModifiedOn
(
new
Date
());
Employee
existingEmployee
=
employeeRepo
.
findByEmployeeId
(
employeeReq
.
getEmployeeId
());
String
newMobileNumber
=
employeeReq
.
getMobileNumber
();
if
(
newMobileNumber
!=
null
&&
!
newMobileNumber
.
equalsIgnoreCase
(
""
))
{
if
((
existingEmployee
!=
null
&&
existingEmployee
.
getMobileNumber
()
!=
null
&&
!
existingEmployee
.
getMobileNumber
().
equalsIgnoreCase
(
newMobileNumber
))
||
(
existingEmployee
.
getMobileNumber
()
==
null
))
{
mobileNumberChanged
=
true
;
}
}
existingEmployee
.
setMobileNumber
(
employeeReq
.
getMobileNumber
());
existingEmployee
.
setAlternateMobileNumber
(
employeeReq
.
getAlternateMobileNumber
());
existingEmployee
.
setPersonalEmailId
(
employeeReq
.
getPersonalEmailId
());
existingEmployee
.
setBaseTechnology
(
employeeReq
.
getBaseTechnology
());
existingEmployee
.
setTechnologyKnown
(
employeeReq
.
getTechnologyKnown
());
Employee
employeePersisted
=
employeeRepo
.
save
(
existingEmployee
);
return
employeePersisted
;
}
public
boolean
isEmployeeExistsById
(
String
employeeId
)
{
Employee
employeeFound
=
getEmployeeById
(
employeeId
);
return
(
employeeFound
==
null
)
?
false
:
true
;
}
@Override
public
Employee
getEmployeeById
(
String
employeeId
)
{
log
.
info
(
"The employeeId::"
+
employeeId
);
Employee
employee
=
employeeRepo
.
findByEmployeeId
(
employeeId
);
log
.
info
(
"Employee Found in Repo::"
+
employee
);
return
employee
;
}
@Override
public
List
<
Employee
>
getAllEmployees
()
{
return
employeeRepo
.
findAll
();
}
@Override
public
Employee
getEmployeeByEmaillId
(
String
emailId
)
{
return
employeeRepo
.
findByEmailId
(
emailId
);
}
@Override
public
List
<
Employee
>
getEmployeesByEmpStatusAndShift
(
String
empStatus
,
String
shift
)
{
return
employeeRepo
.
findByEmpStatusAndShiftLikeOrderByEmployeeIdDesc
(
empStatus
,
shift
);
}
public
List
<
Employee
>
getManagers
()
throws
MyTeamException
{
List
<
Employee
>
activeEmpsList
=
getActiveEmployees
();
List
<
Employee
>
managers
=
activeEmpsList
.
stream
()
.
filter
(
employee
->
(
RoleConstant
.
DIRECTOR
.
getRoleName
().
equalsIgnoreCase
(
employee
.
getRole
())
||
RoleConstant
.
DELIVERY_MANAGER
.
getRoleName
().
equalsIgnoreCase
(
employee
.
getRole
())
||
RoleConstant
.
MANAGER
.
getRoleName
().
equalsIgnoreCase
(
employee
.
getRole
())
||
RoleConstant
.
HR_MANAGER
.
getRoleName
().
equalsIgnoreCase
(
employee
.
getRole
())
||
RoleConstant
.
LEAD
.
getRoleName
().
equalsIgnoreCase
(
employee
.
getRole
())))
.
sorted
(
Comparator
.
comparing
(
Employee:
:
getEmployeeName
)).
collect
(
Collectors
.
toList
());
return
managers
;
}
@Override
public
List
<
Employee
>
getActiveEmployees
()
throws
MyTeamException
{
return
employeeRepo
.
findByEmpStatus
(
MyTeamUtils
.
ACTIVE
);
}
@Override
public
List
<
Employee
>
getEmployeesByStatus
(
String
status
)
{
if
(
status
.
equals
(
"all"
))
{
return
employeeRepo
.
findAll
(
new
Sort
(
Sort
.
Direction
.
ASC
,
"employeeName"
));
}
else
if
(
status
.
equals
(
"Vacation"
))
{
Query
query
=
new
Query
();
query
.
addCriteria
(
Criteria
.
where
(
"empSubStatus"
).
ne
(
"Resigned"
).
andOperator
(
Criteria
.
where
(
"empSubStatus"
).
ne
(
null
),
Criteria
.
where
(
"empSubStatus"
).
ne
(
""
)));
return
mongoTemplate
.
find
(
query
,
Employee
.
class
);
}
else
if
(
status
.
equals
(
"Resigned"
))
{
return
employeeRepo
.
findByEmpSubStatusOrderByEmployeeNameAsc
(
"Resigned"
);
}
else
{
return
employeeRepo
.
findByEmpStatus
(
status
);
}
}
@Override
public
List
<
Account
>
getAccounts
()
throws
MyTeamException
{
return
accountService
.
getAllAccounts
();
}
@Override
public
Employee
getEmployeeRoleDataForSearchCriteria
(
String
searchId
,
String
searchAttribute
)
{
if
(
MyTeamUtils
.
EMPLOYEE_NAME
.
equals
(
searchAttribute
))
{
return
employeeRepo
.
findByEmployeeName
(
searchId
);
}
else
if
(
MyTeamUtils
.
EMAIL_ID
.
equals
(
searchAttribute
))
{
return
employeeRepo
.
findByEmailId
(
searchId
);
}
return
null
;
}
@Override
public
List
<
String
>
getEmployeeDetailsForAutocomplete
()
{
List
<
Employee
>
employeeList
=
employeeRepo
.
findAll
();
List
<
String
>
resultList
=
new
ArrayList
<>();
employeeList
.
stream
().
sorted
(
java
.
util
.
Comparator
.
comparing
(
Employee:
:
getEmployeeId
))
.
collect
(
Collectors
.
toList
()).
forEach
(
employee
->
{
resultList
.
add
(
employee
.
getEmployeeId
());
});
employeeList
.
stream
().
sorted
(
java
.
util
.
Comparator
.
comparing
(
Employee:
:
getEmployeeName
))
.
collect
(
Collectors
.
toList
()).
forEach
(
employee
->
{
resultList
.
add
(
employee
.
getEmployeeName
());
});
employeeList
.
stream
().
sorted
(
java
.
util
.
Comparator
.
comparing
(
Employee:
:
getEmailId
)).
collect
(
Collectors
.
toList
())
.
forEach
(
employee
->
{
resultList
.
add
(
employee
.
getEmailId
());
});
return
resultList
;
}
@Override
public
List
<
HashMap
<
String
,
String
>>
getDeliveryLeads
(
String
domainId
)
{
Domain
domain
=
domainService
.
getDomainById
(
domainId
);
return
getDeliveryManagerMap
(
domain
.
getDeliveryManagers
());
}
@Override
public
List
<
HashMap
<
String
,
String
>>
getDeliveryManagerMap
(
List
deliveryManagerIdsList
)
{
List
<
HashMap
<
String
,
String
>>
employeeList
=
new
ArrayList
<>();
Query
query
=
new
Query
(
Criteria
.
where
(
"employeeId"
).
in
(
deliveryManagerIdsList
));
List
<
Employee
>
employeePersistedList
=
mongoTemplate
.
find
(
query
,
Employee
.
class
);
for
(
Employee
employee
:
employeePersistedList
)
{
HashMap
<
String
,
String
>
managerMap
=
new
HashMap
<>();
managerMap
.
put
(
"employeeId"
,
employee
.
getEmployeeId
());
managerMap
.
put
(
"employeeName"
,
employee
.
getEmployeeName
());
employeeList
.
add
(
managerMap
);
}
return
employeeList
;
}
@Override
public
List
<
Employee
>
getEmployeesByFunctionalGrp
(
String
functionalGrp
)
{
return
employeeRepo
.
findByEmpStatusAndFunctionalGroup
(
"Active"
,
functionalGrp
);
}
@Override
public
boolean
verifyEmployeeRole
(
String
empId
,
String
roleIdReq
)
{
boolean
flag
=
false
;
log
.
info
(
"The employeeId::"
+
empId
);
Employee
employee
=
getEmployeeById
(
empId
);
log
.
info
(
"Employee::::in EmployeeService::"
+
employee
);
String
roleName
=
employee
.
getRole
();
log
.
info
(
"The employee role::"
+
roleName
);
if
(
StringUtils
.
isNotBlank
(
roleName
)
&&
!
ApplicationRole
.
ADMIN
.
getRoleName
().
equalsIgnoreCase
(
roleName
))
{
if
(
ApplicationRole
.
FUNCTIONAL_MANAGER
.
getRoleName
().
equalsIgnoreCase
(
roleName
)
||
ApplicationRole
.
DELIVERY_LEAD
.
getRoleName
().
equalsIgnoreCase
(
roleName
))
{
flag
=
true
;
log
.
info
(
"in if block"
);
}
else
{
log
.
info
(
"in else block"
);
Set
<
String
>
roleSet
=
employeeRoleService
.
empRolesMapInfoByEmpId
(
empId
);
if
(
null
!=
roleSet
&&
!
roleSet
.
isEmpty
()
&&
MyTeamUtils
.
INT_ZERO
<
roleSet
.
size
())
{
if
(
roleSet
.
contains
(
roleIdReq
))
{
flag
=
true
;
}
}
}
}
log
.
info
(
"before return flag::"
+
flag
);
return
flag
;
}
public
List
<
Employee
>
getEmployeesFromList
(
Set
<
String
>
empIdsSet
)
{
return
employeeRepo
.
findByEmployeeIdIn
(
empIdsSet
);
}
@Override
public
List
<
BillableEmployee
>
getEmployeeDetailsByFGAndBillability
(
String
fGroup
,
String
billableStatus
)
{
Map
<
String
,
Resource
>
resourceMap
=
resourceService
.
findByBillableStatus
(
billableStatus
).
stream
().
collect
(
Collectors
.
toMap
(
e
->
e
.
getEmployeeId
(),
e
->
e
));
return
employeeRepo
.
findByEmpStatusAndFunctionalGroup
(
ResourceStatus
.
ACTIVE
.
getStatus
(),
fGroup
).
stream
().
filter
(
e
->
resourceMap
.
keySet
().
contains
(
e
.
getEmployeeId
())).
map
(
e
->
mappingBillableEmployee
(
e
,
fGroup
,
resourceMap
)).
collect
(
Collectors
.
toList
());
}
private
BillableEmployee
mappingBillableEmployee
(
Employee
e
,
String
fGroup
,
Map
<
String
,
Resource
>
resourceMap
)
{
Resource
resource
=
resourceMap
.
get
(
e
.
getEmployeeId
());
Project
project
=
projectService
.
getProjectByProjectId
(
resource
.
getProjectId
());
return
new
BillableEmployee
(
e
.
getEmployeeId
(),
e
.
getEmployeeName
(),
e
.
getEmailId
(),
project
.
getProjectName
(),
resource
.
getBillableStatus
(),
resource
.
getBillingStartDate
(),
resource
.
getBillingEndDate
(),
fGroup
);
}
}
src/main/java/com/nisum/myteam/service/impl/ResourceService.java
View file @
abd738af
...
...
@@ -50,10 +50,9 @@ public class ResourceService implements IResourceService {
public
HashMap
<
String
,
Object
>
respMap
=
new
HashMap
<>();
private
Resource
getLatestAllocation
(
List
<
Resource
>
resourceAllocList
){
private
Resource
getLatestAllocation
(
List
<
Resource
>
resourceAllocList
)
{
Resource
latestAlloc
=
null
;
if
(!
resourceAllocList
.
isEmpty
())
{
if
(!
resourceAllocList
.
isEmpty
())
{
latestAlloc
=
resourceAllocList
.
get
(
0
);
for
(
Resource
resource
:
resourceAllocList
)
{
if
(
latestAlloc
.
getBillingEndDate
().
before
(
resource
.
getBillingEndDate
()))
...
...
@@ -62,10 +61,12 @@ public class ResourceService implements IResourceService {
}
return
latestAlloc
;
}
public
List
<
Resource
>
getResourcesByEmployeeId
(
String
employeeId
){
public
List
<
Resource
>
getResourcesByEmployeeId
(
String
employeeId
)
{
return
resourceRepo
.
findByEmployeeId
(
employeeId
);
}
public
Resource
addResource
(
Resource
resourceReq
,
String
loginEmpId
)
throws
MyTeamException
{
List
<
Resource
>
resourceAllocList
=
resourceRepo
.
findByEmployeeIdAndProjectId
(
resourceReq
.
getEmployeeId
(),
resourceReq
.
getProjectId
());
...
...
@@ -79,9 +80,9 @@ public class ResourceService implements IResourceService {
}
this
.
updateExistedResource
(
prevAllocation
);
}
if
(
resourceAllocList
.
isEmpty
())
{
List
<
Resource
>
resourceBenchList
=
resourceRepo
.
findByEmployeeIdAndProjectId
(
resourceReq
.
getEmployeeId
(),
MyTeamUtils
.
BENCH_PROJECT_ID
);
if
(!
resourceBenchList
.
isEmpty
())
{
if
(
resourceAllocList
.
isEmpty
())
{
List
<
Resource
>
resourceBenchList
=
resourceRepo
.
findByEmployeeIdAndProjectId
(
resourceReq
.
getEmployeeId
(),
MyTeamUtils
.
BENCH_PROJECT_ID
);
if
(!
resourceBenchList
.
isEmpty
())
{
Resource
resourceBench
=
resourceBenchList
.
get
(
0
);
resourceBench
.
setBillingEndDate
(
MyTeamDateUtils
.
getDayLessThanDate
(
resourceReq
.
getBillingStartDate
()));
resourceRepo
.
save
(
resourceBench
);
...
...
@@ -105,8 +106,6 @@ public class ResourceService implements IResourceService {
}
public
void
updateResourceDetails
(
Resource
resourceReq
,
String
loginEmpId
)
throws
MyTeamException
{
// List<Resource> resourceAllocList = resourceRepo.findByEmployeeIdAndProjectId(resourceReq.getEmployeeId(), resourceReq.getProjectId());
...
...
@@ -135,9 +134,9 @@ public class ResourceService implements IResourceService {
// this.updateExistedResource(resourcePrev);
// }
Resource
resource
=
resourceRepo
.
findById
(
resourceReq
.
getId
());
if
(
resource
!=
null
)
{
if
(
resource
!=
null
)
{
this
.
updateExistedResource
(
resourceReq
);
}
else
{
}
else
{
respMap
.
put
(
"statusCode"
,
801
);
respMap
.
put
(
"message"
,
"Record Not Found"
);
}
...
...
@@ -165,24 +164,26 @@ public class ResourceService implements IResourceService {
respMap
.
put
(
"resourceObj"
,
resourcePers
);
}
public
boolean
validateAllocationAgainstPrevAllocation
(
Resource
resourceReq
){
public
boolean
validateAllocationAgainstPrevAllocation
(
Resource
resourceReq
)
{
boolean
isValid
=
true
;
List
<
Resource
>
resourceAllocList
=
resourceRepo
.
findByEmployeeIdAndProjectId
(
resourceReq
.
getEmployeeId
(),
resourceReq
.
getProjectId
());
Resource
prevAllocation
=
this
.
getLatestAllocation
(
resourceAllocList
);
if
(
prevAllocation
!=
null
)
{
if
(!
prevAllocation
.
getBillingStartDate
().
before
(
resourceReq
.
getBillingStartDate
()))
{
if
(!
prevAllocation
.
getBillingStartDate
().
before
(
resourceReq
.
getBillingStartDate
()))
{
respMap
.
put
(
"statusCode"
,
811
);
respMap
.
put
(
"message"
,
"Billing start date should be after previous allocation start date"
);
isValid
=
false
;
}
if
(
prevAllocation
.
getBillableStatus
().
equalsIgnoreCase
(
resourceReq
.
getBillableStatus
()))
{
if
(
prevAllocation
.
getBillableStatus
().
equalsIgnoreCase
(
resourceReq
.
getBillableStatus
()))
{
respMap
.
put
(
"statusCode"
,
811
);
respMap
.
put
(
"message"
,
"Resource is already in "
+
prevAllocation
.
getBillableStatus
()+
" status only"
);
respMap
.
put
(
"message"
,
"Resource is already in "
+
prevAllocation
.
getBillableStatus
()
+
" status only"
);
isValid
=
false
;
}
}
return
isValid
;
}
public
boolean
validateBillingStartEndDateAgainstProjectStartEndDate
(
Resource
resource
,
String
loginEmpId
)
throws
MyTeamException
{
boolean
isValid
=
true
;
...
...
@@ -207,7 +208,7 @@ public class ResourceService implements IResourceService {
log
.
info
(
""
+
project
.
getProjectEndDate
().
toString
());
//if (!resourceAllocation.getBillingEndDate().before(project.getProjectEndDate())|| !resourceAllocation.getBillingEndDate().equals(project.getProjectEndDate())) {
if
(!(
resource
.
getBillingEndDate
().
compareTo
(
project
.
getProjectEndDate
())<=
0
))
{
if
(!(
resource
.
getBillingEndDate
().
compareTo
(
project
.
getProjectEndDate
())
<=
0
))
{
log
.
info
(
"Billing end date should be on or before Project End Date."
);
respMap
.
put
(
"statusCode"
,
813
);
respMap
.
put
(
"message"
,
"Billing end date should be before Project End Date."
);
...
...
@@ -264,8 +265,6 @@ public class ResourceService implements IResourceService {
}
public
void
deleteResource
(
Resource
resourceReq
,
String
loginEmpId
)
{
List
<
Resource
>
resourcesList
=
resourceRepo
.
findByEmployeeIdAndProjectId
(
resourceReq
.
getEmployeeId
(),
resourceReq
.
getProjectId
());
resourcesList
.
forEach
(
resource
->
resourceRepo
.
delete
(
resource
));
...
...
@@ -357,31 +356,29 @@ public class ResourceService implements IResourceService {
for
(
Resource
resource
:
getAllResourcesForProject
(
projectId
))
{
ResourceVO
resourceVO
=
new
ResourceVO
();
resourceVO
.
setId
(
resource
.
getId
());
resourceVO
.
setProjectId
(
resource
.
getProjectId
());
resourceVO
.
setEmployeeId
(
resource
.
getEmployeeId
());
ResourceVO
resourceVO
=
new
ResourceVO
();
resourceVO
.
setId
(
resource
.
getId
());
resourceVO
.
setProjectId
(
resource
.
getProjectId
());
resourceVO
.
setEmployeeId
(
resource
.
getEmployeeId
());
employee
=
employeeService
.
getEmployeeById
(
resource
.
getEmployeeId
());
resourceVO
.
setEmployeeName
(
employee
.
getEmployeeName
());
resourceVO
.
setDesignation
(
employee
.
getDesignation
());
resourceVO
.
setEmailId
(
employee
.
getEmailId
());
resourceVO
.
setMobileNo
(
employee
.
getMobileNumber
());
employee
=
employeeService
.
getEmployeeById
(
resource
.
getEmployeeId
());
resourceVO
.
setEmployeeName
(
employee
.
getEmployeeName
());
resourceVO
.
setDesignation
(
employee
.
getDesignation
());
resourceVO
.
setEmailId
(
employee
.
getEmailId
());
resourceVO
.
setMobileNo
(
employee
.
getMobileNumber
());
resourceVO
.
setProjectName
(
projectService
.
getProjectByProjectId
(
resource
.
getProjectId
()).
getProjectName
());
resourceVO
.
setBillableStatus
(
resource
.
getBillableStatus
());
resourceVO
.
setBillingStartDate
(
resource
.
getBillingStartDate
());
resourceVO
.
setBillingEndDate
(
resource
.
getBillingEndDate
());
resourceVO
.
setResourceRole
(
resource
.
getResourceRole
());
if
(
resource
.
getBillingEndDate
().
compareTo
(
new
Date
())>
0
)
{
resourceVO
.
setResourceStatus
(
ResourceStatus
.
ACTIVE
.
getStatus
());
}
else
{
resourceVO
.
setResourceStatus
(
ResourceStatus
.
IN_ACTIVE
.
getStatus
());
}
resourceVO
.
setProjectName
(
projectService
.
getProjectByProjectId
(
resource
.
getProjectId
()).
getProjectName
());
resourceVO
.
setBillableStatus
(
resource
.
getBillableStatus
());
resourceVO
.
setBillingStartDate
(
resource
.
getBillingStartDate
());
resourceVO
.
setBillingEndDate
(
resource
.
getBillingEndDate
());
resourceVO
.
setResourceRole
(
resource
.
getResourceRole
());
if
(
resource
.
getBillingEndDate
().
compareTo
(
new
Date
())
>
0
)
{
resourceVO
.
setResourceStatus
(
ResourceStatus
.
ACTIVE
.
getStatus
());
}
else
{
resourceVO
.
setResourceStatus
(
ResourceStatus
.
IN_ACTIVE
.
getStatus
());
}
finalResourcesList
.
add
(
resourceVO
);
finalResourcesList
.
add
(
resourceVO
);
}
return
finalResourcesList
;
...
...
@@ -514,16 +511,16 @@ public class ResourceService implements IResourceService {
@Override
public
List
<
ResourceVO
>
getBillingsForEmployee
(
String
empId
)
{
List
<
ResourceVO
>
finalList
=
new
ArrayList
<>();
List
<
ResourceVO
>
finalList
=
new
ArrayList
<>();
List
<
Resource
>
resourcesList
=
resourceRepo
.
findByEmployeeId
(
empId
);
if
(
resourcesList
!=
null
&&
resourcesList
.
size
()
>
0
)
{
log
.
info
(
"The resources billing list before sorting::"
+
resourcesList
);
//return billingsList.stream().sorted(Comparator.comparing(Billing::getCreatedOn).reversed()).collect(Collectors.toList());
List
<
Resource
>
sortedList
=
resourcesList
.
stream
().
sorted
(
Comparator
.
comparing
(
Resource:
:
getBillingStartDate
).
reversed
()).
collect
(
Collectors
.
toList
());
finalList
=
convertResourcesToResourcesVO
(
sortedList
);
finalList
=
convertResourcesToResourcesVO
(
sortedList
);
}
return
finalList
;
return
finalList
;
}
@Override
...
...
@@ -689,11 +686,12 @@ public class ResourceService implements IResourceService {
return
resourcesList
;
}
@Override
public
Resource
getLatestResourceByEmpId
(
String
employeeId
){
public
Resource
getLatestResourceByEmpId
(
String
employeeId
)
{
List
<
Resource
>
resourceList
=
resourceRepo
.
findByEmployeeId
(
employeeId
).
stream
().
filter
(
r
->
r
.
getBillingEndDate
().
after
(
new
Date
())).
collect
(
Collectors
.
toList
());
if
(!
resourceList
.
isEmpty
())
if
(!
resourceList
.
isEmpty
())
return
resourceList
.
get
(
0
);
else
return
null
;
...
...
@@ -709,6 +707,7 @@ public class ResourceService implements IResourceService {
public
List
<
ReserveReportsVO
>
getResourceReportsByBillingStatus
(
String
resourceStatus
)
{
return
prepareReserveReports
(
getResourcesByBillingStatus
(
resourceStatus
));
}
@Override
public
List
<
ReserveReportsVO
>
prepareReserveReports
(
List
<
Resource
>
resourcesList
)
{
...
...
@@ -739,7 +738,7 @@ public class ResourceService implements IResourceService {
}
public
List
<
ChangedResourceVO
>
getChangedResourceByDate
(
String
fromDatestr
,
String
toDatestr
){
public
List
<
ChangedResourceVO
>
getChangedResourceByDate
(
String
fromDatestr
,
String
toDatestr
)
{
// List<ChangedResourceVO> changedResourceVOList = new ArrayList();
// SimpleDateFormat format = new SimpleDateFormat("dd/MM/yyyy");
//
...
...
@@ -809,7 +808,46 @@ public class ResourceService implements IResourceService {
}
public
List
<
AllocationChangeVO
>
getAllocationReports
(
Date
fromDate
,
Date
toDate
)
{
return
prepareAllocationResources
(
getResourcesBetweenBillingStartDates
(
fromDate
,
toDate
));
return
getResourcesBetweenBillingStartDates
(
fromDate
,
toDate
).
stream
()
.
filter
(
resource
->
resource
.
getBillingEndDate
().
compareTo
(
new
Date
())
>=
0
).
map
(
resource
->
{
Project
project
=
null
;
//Setting Current Billing details.
AllocationChangeVO
allocationVO
=
new
AllocationChangeVO
();
allocationVO
.
setEmployeeId
(
resource
.
getEmployeeId
());
allocationVO
.
setEmployeeName
(
employeeService
.
getEmployeeById
(
resource
.
getEmployeeId
()).
getEmployeeName
());
if
(
StringUtils
.
isNotBlank
(
resource
.
getProjectId
()))
{
project
=
projectService
.
getProjectByProjectId
(
resource
.
getProjectId
());
if
(
project
!=
null
)
{
allocationVO
.
setCurrentProjectName
(
project
.
getProjectName
());
allocationVO
.
setCurrentAccountName
(
accountService
.
getAccountById
(
project
.
getAccountId
()).
getAccountName
());
}
}
allocationVO
.
setCurrentBillingStatus
(
resource
.
getBillableStatus
());
allocationVO
.
setCurrentBillingStartDate
(
resource
.
getBillingStartDate
());
allocationVO
.
setCurrentBillingEndDate
(
resource
.
getBillingEndDate
());
Resource
prevBilling
=
resourceRepo
.
findOneByEmployeeIdAndBillingEndDate
(
resource
.
getEmployeeId
(),
MyTeamDateUtils
.
getDayLessThanDate
(
resource
.
getBillingStartDate
()));
log
.
info
(
"\n\n\n The prev billing info is::"
+
prevBilling
);
if
(
prevBilling
!=
null
)
{
if
(
StringUtils
.
isNotBlank
(
prevBilling
.
getProjectId
()))
{
project
=
projectService
.
getProjectByProjectId
(
prevBilling
.
getProjectId
());
if
(
project
!=
null
)
{
allocationVO
.
setPrevProjectName
(
project
.
getProjectName
());
allocationVO
.
setPrevAccountName
(
accountService
.
getAccountById
(
project
.
getAccountId
()).
getAccountName
());
}
}
allocationVO
.
setPrevBillingStatus
(
prevBilling
.
getBillableStatus
());
allocationVO
.
setPrevBilingStartDate
(
prevBilling
.
getBillingStartDate
());
allocationVO
.
setPrevBillingEndDate
(
prevBilling
.
getBillingEndDate
());
}
return
allocationVO
;
}).
collect
(
Collectors
.
toList
());
}
public
List
<
AllocationChangeVO
>
prepareAllocationResources
(
List
<
Resource
>
resourcesList
)
{
...
...
@@ -843,59 +881,67 @@ public class ResourceService implements IResourceService {
return
allocationList
;
}
@Override
public
Set
<
Resource
>
findByBillableStatus
(
String
billableStatus
)
{
return
resourceRepo
.
findByBillableStatus
(
billableStatus
).
stream
().
filter
(
r
->
r
.
getBillingEndDate
().
after
(
new
Date
())).
collect
(
Collectors
.
toSet
());
}
}
//class
// @Override
// public List<ResourceVO> getActiveResources(String empId) {
// List<ResourceVO> finalResourcesList = new ArrayList<>();
//
// List<Resource> resourceList = resourceRepo.findByEmployeeId(empId);
// if (resourceList != null && resourceList.size() > 0) {
//
// Resource resourceAlloc=resourceList.get(0);
//
//
//
//
// }
//
// for (Resource resource : resourceRepo.findByEmployeeId(empId)) {
//
// ResourceVO resourceVO=new ResourceVO();
// resourceVO.setEmployeeId(resource.getEmployeeId());
//
// Employee employee=employeeService.getEmployeeById(resource.getEmployeeId());
// resourceVO.setEmployeeName(employee.getEmployeeName());
// resourceVO.setDesignation(employee.getDesignation());
// resourceVO.setEmailId(employee.getEmailId());
// resourceVO.setMobileNo(employee.getMobileNumber());
//
// resourceVO.setProjectName(projectService.getProjectByProjectId(resource.getProjectId()).getProjectName());
//
//
// if (resource.getBillingEndDate().compareTo(new Date()) > 0) {
// finalResourcesList.addAll(getAllResourcesForProject(resource.getProjectId()));
// }
//
//
// }
// return finalResourcesList;
// }
/*
@Override
public List<ResourceVO> getActiveResources(String empId) {
List<ResourceVO> finalResourcesList = new ArrayList<>();
// @Override
// public List<ResourceVO> getActiveResources(String empId) {
// List<ResourceVO> finalResourcesList = new ArrayList<>();
// Employee employee = null;
//
// List<Resource> resourceList = resourceRepo.findByEmployeeId(empId);
// Optional<Resource> optionalResource = resourceList.stream().filter(resource -> resource.getBillingEndDate().compareTo(new Date()) > 0).findAny();
// if (optionalResource.isPresent()) {
// finalResourcesList = prepareProjectTeamMembersList(optionalResource.get().getProjectId());
// }
// return finalResourcesList;
// }
\ No newline at end of file
List<Resource> resourceList = resourceRepo.findByEmployeeId(empId);
if (resourceList != null && resourceList.size() > 0) {
Resource resourceAlloc=resourceList.get(0);
}
for (Resource resource : resourceRepo.findByEmployeeId(empId)) {
ResourceVO resourceVO=new ResourceVO();
resourceVO.setEmployeeId(resource.getEmployeeId());
Employee employee=employeeService.getEmployeeById(resource.getEmployeeId());
resourceVO.setEmployeeName(employee.getEmployeeName());
resourceVO.setDesignation(employee.getDesignation());
resourceVO.setEmailId(employee.getEmailId());
resourceVO.setMobileNo(employee.getMobileNumber());
resourceVO.setProjectName(projectService.getProjectByProjectId(resource.getProjectId()).getProjectName());
if (resource.getBillingEndDate().compareTo(new Date()) > 0) {
finalResourcesList.addAll(getAllResourcesForProject(resource.getProjectId()));
}
}
return finalResourcesList;
}
*/
/*
@Override
public List<ResourceVO> getActiveResources(String empId) {
List<ResourceVO> finalResourcesList = new ArrayList<>();
Employee employee = null;
List<Resource> resourceList = resourceRepo.findByEmployeeId(empId);
Optional<Resource> optionalResource = resourceList.stream().filter(resource -> resource.getBillingEndDate().compareTo(new Date()) > 0).findAny();
if (optionalResource.isPresent()) {
finalResourcesList = prepareProjectTeamMembersList(optionalResource.get().getProjectId());
}
return finalResourcesList;
}
*/
\ No newline at end of file
src/main/resources/application.properties
View file @
abd738af
...
...
@@ -2,16 +2,16 @@ server.port=8080
server.context-path
=
/myTeam/
#Production configuration
#
spring.data.mongodb.host=10.3.45.11
#
spring.data.mongodb.port=27017
#
spring.data.mongodb.database=mytimedb
#
spring.data.mongodb.username=mytime
#
spring.data.mongodb.password=nisum@123
spring.data.mongodb.host
=
10.3.45.11
spring.data.mongodb.port
=
27017
spring.data.mongodb.database
=
mytimedb
spring.data.mongodb.username
=
mytime
spring.data.mongodb.password
=
nisum@123
#Local Database configuration
spring.data.mongodb.host
=
localhost
spring.data.mongodb.port
=
27017
spring.data.mongodb.database
=
myTeamDB
#
spring.data.mongodb.host=localhost
#
spring.data.mongodb.port=27017
#
spring.data.mongodb.database=myTeamDB
quartz.enabled
=
true
cron.expression
=
0 45 10/3 1/1 * ? *
...
...
src/main/webapp/WEB-INF/controllers/AllocationChangeController.js
View file @
abd738af
...
...
@@ -18,16 +18,16 @@ myApp.controller("allocationChangeReportController",function($scope,exportUiGrid
enableFiltering
:
true
,
enableHorizontalScrollbar
:
1
,
columnDefs
:
[
{
field
:
'employeeId'
,
displayName
:
'Emp
loyee
Id'
,
enableColumnMenu
:
false
,
enableSorting
:
false
,
enableFiltering
:
true
,
width
:
100
},
{
field
:
'employeeName'
,
displayName
:
'Emp
loyee Name'
,
enableColumnMenu
:
false
,
enableSorting
:
true
,
enableFiltering
:
true
,
width
:
200
},
{
name
:
' prevAccountName'
,
displayName
:
'Previous Client'
,
enableColumnMenu
:
false
,
enableSorting
:
false
,
enableFiltering
:
fals
e
,
width
:
100
},
{
field
:
'prevProjectName'
,
displayName
:
'Prev
ious Project'
,
enableColumnMenu
:
false
,
enableSorting
:
true
,
enableFiltering
:
true
,
width
:
150
},
{
name
:
'prevBillableStatus'
,
displayName
:
'Prev
ious
Billability'
,
enableColumnMenu
:
false
,
enableSorting
:
false
,
enableFiltering
:
false
,
width
:
100
},
{
name
:
'prevBillingStartDate'
,
displayName
:
'Prev
ious
Billing Start Date'
,
cellFilter
:
'date:"dd-MMM-yyyy"'
,
enableColumnMenu
:
false
,
enableSorting
:
false
,
enableFiltering
:
false
,
width
:
150
},
{
name
:
'prevBillingEndDate'
,
displayName
:
'Prev
ious
Billing Start Date'
,
cellFilter
:
'date:"dd-MMM-yyyy"'
,
enableColumnMenu
:
false
,
enableSorting
:
false
,
enableFiltering
:
false
,
width
:
150
},
{
field
:
'employeeId'
,
displayName
:
'Emp Id'
,
enableColumnMenu
:
false
,
enableSorting
:
false
,
enableFiltering
:
true
,
width
:
100
},
{
field
:
'employeeName'
,
displayName
:
'Emp
Name'
,
enableColumnMenu
:
false
,
enableSorting
:
true
,
enableFiltering
:
true
,
width
:
200
},
{
name
:
'prevAccountName'
,
displayName
:
'Prev Client'
,
enableColumnMenu
:
false
,
enableSorting
:
false
,
enableFiltering
:
tru
e
,
width
:
100
},
{
field
:
'prevProjectName'
,
displayName
:
'Prev
Project'
,
enableColumnMenu
:
false
,
enableSorting
:
true
,
enableFiltering
:
true
,
width
:
150
},
{
name
:
'prevBillableStatus'
,
displayName
:
'Prev Billability'
,
enableColumnMenu
:
false
,
enableSorting
:
false
,
enableFiltering
:
false
,
width
:
100
},
{
name
:
'prevBillingStartDate'
,
displayName
:
'Prev Billing Start Date'
,
cellFilter
:
'date:"dd-MMM-yyyy"'
,
enableColumnMenu
:
false
,
enableSorting
:
false
,
enableFiltering
:
false
,
width
:
150
},
{
name
:
'prevBillingEndDate'
,
displayName
:
'Prev Billing Start Date'
,
cellFilter
:
'date:"dd-MMM-yyyy"'
,
enableColumnMenu
:
false
,
enableSorting
:
false
,
enableFiltering
:
false
,
width
:
150
},
{
name
:
'currentAccountName'
,
displayName
:
'Current Client'
,
enableColumnMenu
:
false
,
enableSorting
:
false
,
enableFiltering
:
false
,
width
:
100
},
{
name
:
'currentBillableStatus'
,
displayName
:
'Current Billability'
,
enableColumnMenu
:
false
,
enableSorting
:
false
,
enableFiltering
:
false
,
width
:
100
},
{
field
:
'currentProjectName'
,
displayName
:
'Current Project'
,
enableColumnMenu
:
false
,
enableSorting
:
true
,
enableFiltering
:
true
,
width
:
150
},
{
field
:
'currentProjectName'
,
displayName
:
'Current Project'
,
enableColumnMenu
:
false
,
enableSorting
:
true
,
enableFiltering
:
true
,
width
:
150
},
{
name
:
'currentBillingStartDate'
,
displayName
:
'Current Billing Start Date'
,
cellFilter
:
'date:"dd-MMM-yyyy"'
,
enableColumnMenu
:
false
,
enableSorting
:
false
,
enableFiltering
:
false
,
width
:
150
},
{
name
:
'currentBillingEndDate'
,
displayName
:
'Current Billing End Date'
,
cellFilter
:
'date:"dd-MMM-yyyy"'
,
enableColumnMenu
:
false
,
enableSorting
:
false
,
enableFiltering
:
false
,
width
:
150
},
...
...
@@ -36,12 +36,12 @@ myApp.controller("allocationChangeReportController",function($scope,exportUiGrid
enableSelectAll
:
true
,
exporterMenuExcel
:
false
,
exporterMenuCsv
:
false
,
exporterCsvFilename
:
'
EmployeeEfforts
.csv'
,
exporterExcelFilename
:
'
EmployeeEfforts
'
,
exporterCsvFilename
:
'
AllocationChange
.csv'
,
exporterExcelFilename
:
'
Allocation Change
'
,
exporterPdfDefaultStyle
:
{
fontSize
:
9
},
exporterPdfTableStyle
:
{
margin
:
[
15
,
15
,
15
,
15
]},
exporterPdfTableHeaderStyle
:
{
fontSize
:
10
,
bold
:
true
,
italics
:
true
,
color
:
'red'
},
exporterPdfHeader
:
{
text
:
"
Employee Efforts
"
,
style
:
'headerStyle'
},
exporterPdfHeader
:
{
text
:
"
Allocation Change Report
"
,
style
:
'headerStyle'
},
exporterPdfFooter
:
function
(
currentPage
,
pageCount
)
{
return
{
text
:
currentPage
.
toString
()
+
' of '
+
pageCount
.
toString
(),
style
:
'footerStyle'
};
},
...
...
src/main/webapp/WEB-INF/controllers/ChartsController.js
View file @
abd738af
...
...
@@ -91,10 +91,13 @@ myApp.directive('hcPieChart', function () {
$scope
.
getMyTeamDetails
=
function
(
seriesName
,
category
,
optionName
,
title
){
if
(
title
.
trim
()
==
'Employees Overview Report'
){
if
(
title
.
trim
()
==
'Billability By Functional Group'
){
if
(
category
==
'I&A'
){
category
=
'I%26A'
;
}
$http
({
method
:
"GET"
,
url
:
appConfig
.
appUri
+
"
/reports/fetchEmployeeDetailsByFG?fGroup="
+
option
Name
url
:
appConfig
.
appUri
+
"
reports/fetchEmployeeDetailsByFGAndBillability?fGroup="
+
category
+
"&billableStatus="
+
series
Name
}).
then
(
function
mySuccess
(
response
)
{
$scope
.
gridOptions
.
data
=
response
.
data
;
if
(
response
.
data
.
length
>
10
){
...
...
src/main/webapp/WEB-INF/css/custom-theme.css
View file @
abd738af
...
...
@@ -512,6 +512,9 @@ i.fa.fa-refresh:hover {
height: auto !important;
max-height: calc(350px - 20px);
} */
.ui-grid-icon-cancel
{
color
:
black
;
}
md-toolbar
._md-toolbar-transitions
{
min-height
:
50px
!important
;
}
...
...
src/main/webapp/WEB-INF/js/app.js
View file @
abd738af
...
...
@@ -17,7 +17,7 @@ function($mdDateLocaleProvider) {
myApp
.
constant
(
'appConfig'
,
{
appName
:
"MyTime"
,
//
appUri: "http://10.3.45.11:8080/myTeam/",
//
appUri: "http://10.3.45.11:8080/myTeam/",
appUri
:
"http://localhost:8080/myTeam/"
,
version
:
"1.0"
,
empStartId
:
16001
,
...
...
src/main/webapp/WEB-INF/templates/login.html
View file @
abd738af
...
...
@@ -16,8 +16,8 @@
function
renderButton
()
{
gapi
.
load
(
'auth2'
,
function
()
{
gapi
.
auth2
.
init
({
//client_id: "951338644595-32q4i4n2rv4jevvteq77m7jpcq9sbrec.apps.googleusercontent.com",
client_id
:
"685521475239-ujm7l2hkgrltk7loi8efl0ed702asm2r.apps.googleusercontent.com"
,
//client_id: "951338644595-32q4i4n2rv4jevvteq77m7jpcq9sbrec.apps.googleusercontent.com",
hosted_domain
:
'nisum.com'
});
});
...
...
@@ -33,7 +33,6 @@
}
</script>
<script
src=
"https://apis.google.com/js/platform.js?onload=renderButton"
></script>
<!--<meta name="google-signin-client_id" content="10230597574-gv1bg8nehm0a63n9hh5mu9um563uqaq1.apps.googleusercontent.com">-->
<meta
name=
"google-signin-client_id"
content=
"685521475239-ujm7l2hkgrltk7loi8efl0ed702asm2r.apps.googleusercontent.com"
>
<!--<meta name="google-signin-client_id" content="951338644595-32q4i4n2rv4jevvteq77m7jpcq9sbrec.apps.googleusercontent.com">-->
...
...
src/main/webapp/WEB-INF/templates/projectTeamDetails.html
View file @
abd738af
...
...
@@ -152,7 +152,7 @@
<tr
ng-show=
"empBillableStatus"
>
<td
class=
"Employee"
>
{{empBillableStatus}} Start Date
</td>
<td>
<md-datepicker
ng-model=
"newBillingStartDate"
md-placeholder=
"Plase select Date "
id=
"newBillingStartDate "
md-min-date=
"minDate "
<md-datepicker
ng-model=
"newBillingStartDate"
md-placeholder=
"Pl
e
ase select Date "
id=
"newBillingStartDate "
md-min-date=
"minDate "
md-max-date=
"maxDate "
onkeydown=
"return false "
ng-change=
"currentBillabilityDateChange()"
name=
"newBillingStartDate"
></md-datepicker>
</td>
</tr>
...
...
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