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
2568e7cb
Commit
2568e7cb
authored
Jul 24, 2019
by
Prayas Jain
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated Resource Service
parent
9e0a776c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
70 additions
and
15 deletions
+70
-15
ResourceService.java
...n/java/com/nisum/myteam/service/impl/ResourceService.java
+66
-12
AssignRolesController.js
src/main/webapp/WEB-INF/controllers/AssignRolesController.js
+1
-1
newRoleTemplate.html
src/main/webapp/WEB-INF/templates/newRoleTemplate.html
+3
-2
No files found.
src/main/java/com/nisum/myteam/service/impl/ResourceService.java
View file @
2568e7cb
...
@@ -20,6 +20,10 @@ import org.springframework.data.mongodb.core.query.Criteria;
...
@@ -20,6 +20,10 @@ import org.springframework.data.mongodb.core.query.Criteria;
import
org.springframework.data.mongodb.core.query.Query
;
import
org.springframework.data.mongodb.core.query.Query
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
java.time.Instant
;
import
java.time.LocalDate
;
import
java.time.LocalDateTime
;
import
java.time.ZoneId
;
import
java.util.*
;
import
java.util.*
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
...
@@ -77,21 +81,15 @@ public class ResourceService implements IResourceService {
...
@@ -77,21 +81,15 @@ public class ResourceService implements IResourceService {
public
Resource
addResource
(
Resource
resourceReq
,
String
loginEmpId
)
throws
MyTeamException
{
public
Resource
addResource
(
Resource
resourceReq
,
String
loginEmpId
)
throws
MyTeamException
{
List
<
Resource
>
resourceAllocationList
=
resourceRepo
.
findByEmployeeId
(
resourceReq
.
getEmployeeId
());
Resource
currentAllocation
=
getCurrentAllocationIfNotReturnNull
(
resourceReq
.
getEmployeeId
());
Resource
currentAllocation
=
getCurrentAllocationIfNotReturnNull
(
resourceReq
.
getEmployeeId
());
Resource
latestAllocation
=
getLatestAllocation
(
resourceAllocationList
);
Resource
resourcePers
=
null
;
Resource
resourcePers
=
null
;
if
(
currentAllocation
!=
null
&&
currentAllocation
.
getProjectId
().
equals
(
MyTeamUtils
.
BENCH_PROJECT_ID
)){
if
(
currentAllocation
!=
null
&&
currentAllocation
.
getProjectId
().
equals
(
MyTeamUtils
.
BENCH_PROJECT_ID
)){
currentAllocation
.
setBillingEndDate
(
MyTeamDateUtils
.
getDayLessThanDate
(
resourceReq
.
getBillingStartDate
()));
currentAllocation
.
setBillingEndDate
(
MyTeamDateUtils
.
getDayLessThanDate
(
resourceReq
.
getBillingStartDate
()));
this
.
updateExistedResource
(
currentAllocation
);
//updateLatestProjectAllocationToEnd
this
.
updateExistedResource
(
currentAllocation
);
//updateLatestProjectAllocationToEnd
resourcePers
=
resourceRepo
.
save
(
resourceReq
);
//createNewProjectAllocationtoStart
resourcePers
=
resourceRepo
.
save
(
resourceReq
);
//createNewProjectAllocationtoStart
respMap
.
put
(
"message"
,
"Resource has been created"
);
// added on 21-7 2019
respMap
.
put
(
"message"
,
"Resource has been created"
);
// added on 21-7 2019
}
else
if
(
isAllocationActiveToday
(
resourceReq
)){
Project
project
=
projectService
.
getProjectByProjectId
(
latestAllocation
.
getProjectId
());
respMap
.
put
(
"statusCode"
,
811
);
respMap
.
put
(
"message"
,
"resource is not yet released from "
+
project
.
getProjectName
()
+
" project"
);
//resource is not yet released from latest project
}
else
{
}
else
{
resourcePers
=
resourceRepo
.
save
(
resourceReq
);
resourcePers
=
resourceRepo
.
save
(
resourceReq
);
respMap
.
put
(
"message"
,
"Resource has been created"
);
respMap
.
put
(
"message"
,
"Resource has been created"
);
...
@@ -279,15 +277,34 @@ public class ResourceService implements IResourceService {
...
@@ -279,15 +277,34 @@ public class ResourceService implements IResourceService {
}
}
return
isValid
;
return
isValid
;
}
}
private
boolean
isDateCommon
(
Resource
e
,
Date
fromDate
,
Date
toDate
)
{
for
(
LocalDate
datei
=
convert
(
fromDate
);
datei
.
isBefore
(
convert
(
toDate
).
plusDays
(
1
));
datei
=
datei
.
plusDays
(
1
))
for
(
LocalDate
datej
=
convert
(
e
.
getBillingStartDate
());
datej
.
isBefore
(
convert
(
e
.
getBillingEndDate
()).
plusDays
(
1
));
datej
=
datej
.
plusDays
(
1
))
if
(
datej
.
equals
(
datei
))
return
true
;
return
false
;
}
private
LocalDate
convert
(
Date
date
)
{
Instant
instant
=
Instant
.
ofEpochMilli
(
date
.
getTime
());
LocalDateTime
localDateTime
=
LocalDateTime
.
ofInstant
(
instant
,
ZoneId
.
systemDefault
());
return
localDateTime
.
toLocalDate
();
}
public
boolean
isDatesAvailableForAllocation
(
Resource
resource
){
public
boolean
isDatesAvailableForAllocation
(
Resource
resource
){
String
message
=
""
;
String
message
=
""
;
List
<
Resource
>
allocationList
=
resourceRepo
.
findByEmployeeId
(
resource
.
getEmployeeId
());
List
<
Resource
>
allocationList
=
resourceRepo
.
findByEmployeeId
(
resource
.
getEmployeeId
());
List
<
Resource
>
matchedList
=
allocationList
.
stream
().
filter
(
r
->
!
r
.
getProjectId
().
equals
(
MyTeamUtils
.
BENCH_PROJECT_ID
)
&&
List
<
Resource
>
matchedList
=
allocationList
.
stream
().
filter
(
r
->
!
r
.
getProjectId
().
equals
(
MyTeamUtils
.
BENCH_PROJECT_ID
)
&&
!
r
.
getId
().
equals
(
resource
.
getId
())
&&
!
r
.
getId
().
equals
(
resource
.
getId
())
&&
isDateCommon
(
resource
,
r
.
getBillingStartDate
(),
r
.
getBillingEndDate
())
(
(
r
.
getBillingStartDate
().
compareTo
(
resource
.
getBillingStartDate
())<=
0
&&
r
.
getBillingEndDate
().
compareTo
(
resource
.
getBillingStartDate
())>=
0
)||
)
(
r
.
getBillingStartDate
().
compareTo
(
resource
.
getBillingEndDate
())<=
0
&&
r
.
getBillingEndDate
().
compareTo
(
resource
.
getBillingEndDate
())>=
0
)))
.
collect
(
Collectors
.
toList
());
.
collect
(
Collectors
.
toList
());
if
(!
matchedList
.
isEmpty
()){
if
(!
matchedList
.
isEmpty
()){
message
=
"Resource is already alocated for projects:\n"
;
message
=
"Resource is already alocated for projects:\n"
;
...
@@ -303,6 +320,39 @@ public class ResourceService implements IResourceService {
...
@@ -303,6 +320,39 @@ public class ResourceService implements IResourceService {
return
true
;
return
true
;
}
}
// public boolean isDatesAvailableForAllocation(Resource resource){
//
//
//
//
//
//
//
// String message = "";
// List<Resource> allocationList = resourceRepo.findByEmployeeId(resource.getEmployeeId());
//
// List<Resource> matchedList = allocationList.stream().filter(r -> !r.getProjectId().equals(MyTeamUtils.BENCH_PROJECT_ID) &&
// !r.getId().equals(resource.getId()) &&
// ( (r.getBillingStartDate().compareTo(resource.getBillingStartDate())<=0 && r.getBillingEndDate().compareTo(resource.getBillingStartDate())>=0)||
// (r.getBillingStartDate().compareTo(resource.getBillingEndDate())<=0 && r.getBillingEndDate().compareTo(resource.getBillingEndDate())>=0 )))
// .collect(Collectors.toList());
// if(!matchedList.isEmpty()){
// message = "Resource is already alocated for projects:\n";
// for(Resource resourcel:matchedList){
// Project project = projectService.getProjectByProjectId(resourcel.getProjectId());
// message += "Project:"+project.getProjectName()+" From:"+MyTeamDateUtils.getRadableDate().format(resourcel.getBillingStartDate())+" To:"
// +MyTeamDateUtils.getRadableDate().format(resourcel.getBillingEndDate())+"\n";
// }
// respMap.put("statusCode", 815);
// respMap.put("message", message);
// return false;
// }else
// return true;
//
// }
public
boolean
isResourceAvailable
(
Resource
resourceReq
)
{
public
boolean
isResourceAvailable
(
Resource
resourceReq
)
{
...
@@ -613,7 +663,7 @@ public class ResourceService implements IResourceService {
...
@@ -613,7 +663,7 @@ public class ResourceService implements IResourceService {
// Active
// Active
if
(
statusFlag
.
equals
(
ResourceStatus
.
ACTIVE
.
getStatus
())
&&
if
(
statusFlag
.
equals
(
ResourceStatus
.
ACTIVE
.
getStatus
())
&&
(
resource
.
getStatus
().
equals
(
MyTeamUtils
.
STATUS_ENGAGED
)
||
(
resource
.
getStatus
().
equals
(
MyTeamUtils
.
STATUS_ENGAGED
)
||
(
resource
.
getProjectId
().
equalsIgnoreCase
(
MyTeamUtils
.
BENCH_PROJECT_ID
)
&&
this
.
isAllocationActiveToday
(
resource
)
)))
{
(
resource
.
getProjectId
().
equalsIgnoreCase
(
MyTeamUtils
.
BENCH_PROJECT_ID
))))
{
resourceVO
.
setResourceStatus
(
ResourceStatus
.
ACTIVE
.
getStatus
());
resourceVO
.
setResourceStatus
(
ResourceStatus
.
ACTIVE
.
getStatus
());
resourcesList
.
add
(
resourceVO
);
resourcesList
.
add
(
resourceVO
);
}
else
if
(
statusFlag
.
equals
(
ResourceStatus
.
IN_ACTIVE
.
getStatus
())
&&
resource
.
getStatus
().
equals
(
MyTeamUtils
.
STATUS_RELEASED
))
{
}
else
if
(
statusFlag
.
equals
(
ResourceStatus
.
IN_ACTIVE
.
getStatus
())
&&
resource
.
getStatus
().
equals
(
MyTeamUtils
.
STATUS_RELEASED
))
{
...
@@ -816,6 +866,7 @@ public class ResourceService implements IResourceService {
...
@@ -816,6 +866,7 @@ public class ResourceService implements IResourceService {
Resource
resourcePersisted
=
null
;
Resource
resourcePersisted
=
null
;
Resource
resourceBench
=
new
Resource
();
Resource
resourceBench
=
new
Resource
();
resourceBench
.
setAuditFields
(
loginEmpId
,
MyTeamUtils
.
CREATE
);
resourceBench
.
setProjectId
(
MyTeamUtils
.
BENCH_PROJECT_ID
);
resourceBench
.
setProjectId
(
MyTeamUtils
.
BENCH_PROJECT_ID
);
resourceBench
.
setEmployeeId
(
employee
.
getEmployeeId
());
resourceBench
.
setEmployeeId
(
employee
.
getEmployeeId
());
resourceBench
.
setResourceRole
(
employee
.
getRole
());
resourceBench
.
setResourceRole
(
employee
.
getRole
());
...
@@ -824,7 +875,10 @@ public class ResourceService implements IResourceService {
...
@@ -824,7 +875,10 @@ public class ResourceService implements IResourceService {
resourceBench
.
setBillableStatus
(
MyTeamUtils
.
BENCH_BILLABILITY_STATUS
);
resourceBench
.
setBillableStatus
(
MyTeamUtils
.
BENCH_BILLABILITY_STATUS
);
resourceBench
.
setEmployeeId
(
employee
.
getEmployeeId
());
resourceBench
.
setEmployeeId
(
employee
.
getEmployeeId
());
resourceBench
.
setBillingEndDate
(
projectService
.
getProjectByProjectId
(
MyTeamUtils
.
BENCH_PROJECT_ID
).
getProjectEndDate
());
resourceBench
.
setBillingEndDate
(
projectService
.
getProjectByProjectId
(
MyTeamUtils
.
BENCH_PROJECT_ID
).
getProjectEndDate
());
resourcePersisted
=
addResource
(
resourceBench
,
loginEmpId
);
// resourcePersisted = addResource(resourceBench, loginEmpId);
resourcePersisted
=
resourceRepo
.
save
(
resourceBench
);
respMap
.
put
(
"message"
,
"Resource has been created"
);
return
resourcePersisted
;
return
resourcePersisted
;
...
...
src/main/webapp/WEB-INF/controllers/AssignRolesController.js
View file @
2568e7cb
...
@@ -255,7 +255,7 @@ myApp.controller("assignRoleController",function($scope, myFactory, $mdDialog, $
...
@@ -255,7 +255,7 @@ myApp.controller("assignRoleController",function($scope, myFactory, $mdDialog, $
if
(
dataToPass
.
action
==
"Add"
){
if
(
dataToPass
.
action
==
"Add"
){
$scope
.
empId
=
""
;
$scope
.
empId
=
""
;
$scope
.
empName
=
""
;
$scope
.
empName
=
""
;
$scope
.
gender
=
""
;
$scope
.
gender
;
$scope
.
empRole
;
$scope
.
empRole
;
$scope
.
empEmail
=
""
;
$scope
.
empEmail
=
""
;
$scope
.
functionalGroup
;
$scope
.
functionalGroup
;
...
...
src/main/webapp/WEB-INF/templates/newRoleTemplate.html
View file @
2568e7cb
...
@@ -35,9 +35,10 @@
...
@@ -35,9 +35,10 @@
<tr>
<tr>
<td
colspan=
"-10"
><b>
Gender:
</b><span
class=
"mandatory"
></span></td>
<td
colspan=
"-10"
><b>
Gender:
</b><span
class=
"mandatory"
></span></td>
<td
colspan=
"8"
><md-select
ng-model=
"gender"
ng-blur=
"validateMessage()"
name=
"gender"
<td
colspan=
"8"
><md-select
ng-model=
"gender"
ng-blur=
"validateMessage()"
name=
"gender"
md-selected-text=
"getSelectedGender()"
id=
"gender"
>
md-selected-text=
"getSelectedGender()"
id=
"gender"
><md-optgroup
label=
"Select Gender"
>
<md-option
ng-model=
"gender"
value=
"Male"
>
Male
</md-option>
<md-option
<md-option
ng-model=
"gender"
value=
"Male"
>
Male
</md-option>
<md-option
ng-model=
"gender"
value=
"Female"
>
Female
</md-option>
</md-select></td>
ng-model=
"gender"
value=
"Female"
>
Female
</md-option>
</md-optgroup>
</md-select></td>
</tr>
</tr>
<tr>
<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