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
bbf76717
Commit
bbf76717
authored
Jun 11, 2019
by
Md Suleman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Changes in Resource allocation to projects add allocation and update allocation
parent
c046bc6c
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
80 additions
and
34 deletions
+80
-34
LeaveNotificationScheduler.java
...om/nisum/myteam/schedular/LeaveNotificationScheduler.java
+5
-5
ResourceService.java
...n/java/com/nisum/myteam/service/impl/ResourceService.java
+60
-25
MyTeamDateUtils.java
src/main/java/com/nisum/myteam/utils/MyTeamDateUtils.java
+14
-4
MyTeamUtils.java
src/main/java/com/nisum/myteam/utils/MyTeamUtils.java
+1
-0
No files found.
src/main/java/com/nisum/myteam/schedular/LeaveNotificationScheduler.java
View file @
bbf76717
...
@@ -52,7 +52,7 @@ public class LeaveNotificationScheduler {
...
@@ -52,7 +52,7 @@ public class LeaveNotificationScheduler {
private
IFunctionalGroupService
functionalGroupService
;
private
IFunctionalGroupService
functionalGroupService
;
@Scheduled
(
cron
=
"${email.leave.notification.shift1.cron}"
)
//
@Scheduled(cron = "${email.leave.notification.shift1.cron}")
public
void
scheduleLeaveMailForShift1Empls
()
throws
IOException
,
MessagingException
,
MyTeamException
{
public
void
scheduleLeaveMailForShift1Empls
()
throws
IOException
,
MessagingException
,
MyTeamException
{
//Shift 1(9:00 AM - 6:00 PM)
//Shift 1(9:00 AM - 6:00 PM)
logger
.
info
(
Shifts
.
SHIFT1
.
getShiftType
()
+
" :: Execution Time - {}"
,
dateTimeFormatter
.
format
(
LocalDateTime
.
now
()));
logger
.
info
(
Shifts
.
SHIFT1
.
getShiftType
()
+
" :: Execution Time - {}"
,
dateTimeFormatter
.
format
(
LocalDateTime
.
now
()));
...
@@ -60,7 +60,7 @@ public class LeaveNotificationScheduler {
...
@@ -60,7 +60,7 @@ public class LeaveNotificationScheduler {
}
}
@Scheduled
(
cron
=
"${email.leave.notification.shift2.cron}"
)
//
@Scheduled(cron = "${email.leave.notification.shift2.cron}")
public
void
scheduleLeaveMailForShift2Empls
()
throws
IOException
,
MessagingException
,
MyTeamException
{
public
void
scheduleLeaveMailForShift2Empls
()
throws
IOException
,
MessagingException
,
MyTeamException
{
//Shift-2(2:00 PM - 11:00 PM)--General Shift
//Shift-2(2:00 PM - 11:00 PM)--General Shift
logger
.
info
(
Shifts
.
SHIFT2
.
getShiftType
()
+
" :: Execution Time - {}"
,
dateTimeFormatter
.
format
(
LocalDateTime
.
now
()));
logger
.
info
(
Shifts
.
SHIFT2
.
getShiftType
()
+
" :: Execution Time - {}"
,
dateTimeFormatter
.
format
(
LocalDateTime
.
now
()));
...
@@ -68,7 +68,7 @@ public class LeaveNotificationScheduler {
...
@@ -68,7 +68,7 @@ public class LeaveNotificationScheduler {
}
}
@Scheduled
(
cron
=
"${email.leave.notification.shift3.cron}"
)
//
@Scheduled(cron = "${email.leave.notification.shift3.cron}")
public
void
scheduleLeaveMailForShift3Empls
()
throws
IOException
,
MessagingException
,
MyTeamException
{
public
void
scheduleLeaveMailForShift3Empls
()
throws
IOException
,
MessagingException
,
MyTeamException
{
//Shift 3(10:00 PM - 6:00 AM)
//Shift 3(10:00 PM - 6:00 AM)
logger
.
info
(
Shifts
.
SHIFT3
.
getShiftType
()
+
" :: Execution Time - {}"
,
dateTimeFormatter
.
format
(
LocalDateTime
.
now
()));
logger
.
info
(
Shifts
.
SHIFT3
.
getShiftType
()
+
" :: Execution Time - {}"
,
dateTimeFormatter
.
format
(
LocalDateTime
.
now
()));
...
@@ -76,7 +76,7 @@ public class LeaveNotificationScheduler {
...
@@ -76,7 +76,7 @@ public class LeaveNotificationScheduler {
}
}
@Scheduled
(
cron
=
"${email.leave.notification.shift4.cron}"
)
//
@Scheduled(cron = "${email.leave.notification.shift4.cron}")
public
void
scheduleLeaveMailForShift4Empls
()
throws
IOException
,
MessagingException
,
MyTeamException
{
public
void
scheduleLeaveMailForShift4Empls
()
throws
IOException
,
MessagingException
,
MyTeamException
{
//Shift 4(7:30 AM - 3:30 PM)
//Shift 4(7:30 AM - 3:30 PM)
logger
.
info
(
Shifts
.
SHIFT4
.
getShiftType
()
+
" :: Execution Time - {}"
,
dateTimeFormatter
.
format
(
LocalDateTime
.
now
()));
logger
.
info
(
Shifts
.
SHIFT4
.
getShiftType
()
+
" :: Execution Time - {}"
,
dateTimeFormatter
.
format
(
LocalDateTime
.
now
()));
...
@@ -84,7 +84,7 @@ public class LeaveNotificationScheduler {
...
@@ -84,7 +84,7 @@ public class LeaveNotificationScheduler {
}
}
@Scheduled
(
cron
=
"${email.leave.notification.shift5.cron}"
)
//
@Scheduled(cron = "${email.leave.notification.shift5.cron}")
public
void
scheduleLeaveMailForShift5Empls
()
throws
IOException
,
MessagingException
,
MyTeamException
{
public
void
scheduleLeaveMailForShift5Empls
()
throws
IOException
,
MessagingException
,
MyTeamException
{
//Shift 5(11:30 AM - 7:30 PM)
//Shift 5(11:30 AM - 7:30 PM)
logger
.
info
(
Shifts
.
SHIFT5
.
getShiftType
()
+
" :: Execution Time - {}"
,
dateTimeFormatter
.
format
(
LocalDateTime
.
now
()));
logger
.
info
(
Shifts
.
SHIFT5
.
getShiftType
()
+
" :: Execution Time - {}"
,
dateTimeFormatter
.
format
(
LocalDateTime
.
now
()));
...
...
src/main/java/com/nisum/myteam/service/impl/ResourceService.java
View file @
bbf76717
...
@@ -70,25 +70,43 @@ public class ResourceService implements IResourceService {
...
@@ -70,25 +70,43 @@ 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
>
resourceAllocList
=
resourceRepo
.
findByEmployeeIdAndProjectId
(
resourceReq
.
getEmployeeId
(),
resourceReq
.
getProjectId
());
List
<
Resource
>
resourceAllocationList
=
resourceRepo
.
findByEmployeeId
(
resourceReq
.
getEmployeeId
());
Resource
prevAllocation
=
this
.
getLatestAllocation
(
resourceAllocList
);
Resource
prevAllocation
=
this
.
getLatestAllocation
(
resourceAllocationList
);
if
(
prevAllocation
!=
null
)
{
if
(
prevAllocation
.
getBillingEndDate
().
compareTo
(
new
Date
())
==
0
)
{
if
(
prevAllocation
!=
null
){
prevAllocation
.
setBillingEndDate
(
new
Date
());
if
(
prevAllocation
.
getProjectId
().
equalsIgnoreCase
(
MyTeamUtils
.
BENCH_PROJECT_ID
)
&&
}
else
{
prevAllocation
.
getBillingStartDate
().
compareTo
(
employeeService
.
getEmployeeById
(
prevAllocation
.
getEmployeeId
()).
getDateOfJoining
())
!=
0
){
prevAllocation
.
setBillingEndDate
(
MyTeamDateUtils
.
getDayLessThanDate
(
resourceReq
.
getBillingStartDate
()));
//adding resource.
Resource
projectPrevAllocation
=
this
.
getLatestAllocation
(
resourceAllocationList
.
stream
().
}
filter
(
r
->
!
r
.
getProjectId
().
equalsIgnoreCase
(
MyTeamUtils
.
BENCH_PROJECT_ID
)).
collect
(
Collectors
.
toList
()));
this
.
updateExistedResource
(
prevAllocation
);
projectPrevAllocation
.
setBillingEndDate
(
MyTeamDateUtils
.
getDayLessThanDate
(
resourceReq
.
getBillingStartDate
()));
}
updateExistedResource
(
projectPrevAllocation
);
if
(
resourceAllocList
.
isEmpty
())
{
prevAllocation
.
setBillingStartDate
(
MyTeamDateUtils
.
getDayMoreThanDate
(
resourceReq
.
getBillingEndDate
()));
List
<
Resource
>
resourceBenchList
=
resourceRepo
.
findByEmployeeIdAndProjectId
(
resourceReq
.
getEmployeeId
(),
MyTeamUtils
.
BENCH_PROJECT_ID
);
updateExistedResource
(
prevAllocation
);
if
(!
resourceBenchList
.
isEmpty
())
{
}
else
{
Resource
resourceBench
=
resourceBenchList
.
get
(
0
);
prevAllocation
.
setBillingEndDate
(
MyTeamDateUtils
.
getDayLessThanDate
(
resourceReq
.
getBillingStartDate
()));
resourceBench
.
setBillingEndDate
(
MyTeamDateUtils
.
getDayLessThanDate
(
resourceReq
.
getBillingStartDate
()));
updateExistedResource
(
prevAllocation
);
resourceRepo
.
save
(
resourceBench
);
}
}
}
}
// List<Resource> resourceAllocList = resourceRepo.findByEmployeeIdAndProjectId(resourceReq.getEmployeeId(), resourceReq.getProjectId());
//
// Resource prevAllocation = this.getLatestAllocation(resourceAllocList);
// if (prevAllocation != null) {
// if (prevAllocation.getBillingEndDate().compareTo(new Date()) == 0) {
// prevAllocation.setBillingEndDate(new Date());
// } else {
// prevAllocation.setBillingEndDate(MyTeamDateUtils.getDayLessThanDate(resourceReq.getBillingStartDate())); //adding resource.
// }
// this.updateExistedResource(prevAllocation);
// } else {
// List<Resource> resourceAllocationList = resourceRepo.findByEmployeeId(resourceReq.getEmployeeId());
// if (!resourceAllocationList.isEmpty()) {
// Resource resourceBench = resourceAllocationList.get(0);
// resourceBench.setBillingEndDate(MyTeamDateUtils.getDayLessThanDate(resourceReq.getBillingStartDate()));
// resourceRepo.save(resourceBench);
// }
// }
return
resourceRepo
.
save
(
resourceReq
);
return
resourceRepo
.
save
(
resourceReq
);
}
}
...
@@ -137,6 +155,22 @@ public class ResourceService implements IResourceService {
...
@@ -137,6 +155,22 @@ public class ResourceService implements IResourceService {
Resource
resource
=
resourceRepo
.
findById
(
resourceReq
.
getId
());
Resource
resource
=
resourceRepo
.
findById
(
resourceReq
.
getId
());
if
(
resource
!=
null
)
{
if
(
resource
!=
null
)
{
this
.
updateExistedResource
(
resourceReq
);
this
.
updateExistedResource
(
resourceReq
);
Resource
latestAllocation
=
this
.
getLatestAllocation
(
resourceRepo
.
findByEmployeeId
(
resourceReq
.
getEmployeeId
()));
if
(
latestAllocation
!=
null
&&
latestAllocation
.
getId
().
equals
(
resourceReq
.
getId
())
&&
!
latestAllocation
.
getProjectId
().
equalsIgnoreCase
(
MyTeamUtils
.
BENCH_PROJECT_ID
)){
Resource
resourceBench
=
new
Resource
();
resourceBench
.
setProjectId
(
MyTeamUtils
.
BENCH_PROJECT_ID
);
resourceBench
.
setEmployeeId
(
resourceReq
.
getEmployeeId
());
resourceBench
.
setResourceRole
(
resourceReq
.
getResourceRole
());
resourceBench
.
setBillingStartDate
(
MyTeamDateUtils
.
getDayMoreThanDate
(
resourceReq
.
getBillingEndDate
()));
resourceBench
.
setBillingEndDate
(
projectService
.
getProjectByProjectId
(
MyTeamUtils
.
BENCH_PROJECT_ID
).
getProjectEndDate
());
resourceBench
.
setBillableStatus
(
MyTeamUtils
.
BENCH_BILLABILITY_STATUS
);
resourceBench
.
setAuditFields
(
loginEmpId
,
MyTeamUtils
.
CREATE
);
resourceRepo
.
save
(
resourceBench
);
}
else
if
(
latestAllocation
!=
null
&&
latestAllocation
.
getProjectId
().
equalsIgnoreCase
(
MyTeamUtils
.
BENCH_PROJECT_ID
)){
latestAllocation
.
setBillingStartDate
(
MyTeamDateUtils
.
getDayMoreThanDate
(
resourceReq
.
getBillingEndDate
()));
updateExistedResource
(
latestAllocation
);
}
}
else
{
}
else
{
respMap
.
put
(
"statusCode"
,
801
);
respMap
.
put
(
"statusCode"
,
801
);
respMap
.
put
(
"message"
,
"Record Not Found"
);
respMap
.
put
(
"message"
,
"Record Not Found"
);
...
@@ -246,22 +280,23 @@ public class ResourceService implements IResourceService {
...
@@ -246,22 +280,23 @@ public class ResourceService implements IResourceService {
//List<Resource> resourceAllocList = resourceRepo.findByEmployeeIdAndProjectId(resourceAllocReq.getEmployeeId(), resourceAllocReq.getProjectId());
//List<Resource> resourceAllocList = resourceRepo.findByEmployeeIdAndProjectId(resourceAllocReq.getEmployeeId(), resourceAllocReq.getProjectId());
List
<
Resource
>
resourceAllocList
=
resourceRepo
.
findByEmployeeId
(
resourceReq
.
getEmployeeId
());
List
<
Resource
>
resourceAllocList
=
resourceRepo
.
findByEmployeeId
(
resourceReq
.
getEmployeeId
());
List
<
Resource
>
resourceListWithLatestRecord
=
resourceAllocList
.
stream
().
filter
(
resource
->
resource
.
getBillingEndDate
().
compareTo
(
new
Date
())
>=
0
).
collect
(
Collectors
.
toList
());
Resource
resourceLatestRecord
=
getLatestAllocation
(
resourceAllocList
.
stream
().
filter
(
r
->
!
r
.
getProjectId
().
equalsIgnoreCase
(
MyTeamUtils
.
BENCH_PROJECT_ID
)).
collect
(
Collectors
.
toList
()));
// resourceAllocList.stream().filter(resource -> resource.getBillingEndDate().compareTo(new Date()) >= 0).collect(Collectors.toList());
if
(
resourceListWithLatestRecord
!=
null
&&
resourceListWithLatestRecord
.
size
()
>
0
)
{
if
(
resourceLatestRecord
!=
null
&&
Resource
resourcePrev
=
resourceListWithLatestRecord
.
get
(
0
);
//latest resource record.
resourceLatestRecord
.
getBillableStatus
().
equalsIgnoreCase
(
MyTeamUtils
.
BILLABLE_TEXT
)
)
{
if
(!
resourceLatestRecord
.
getProjectId
().
equalsIgnoreCase
(
resourceReq
.
getProjectId
())){
if
(!
resourcePrev
.
getProjectId
().
equalsIgnoreCase
(
MyTeamUtils
.
BENCH_PROJECT_ID
)
&&
!
resourceReq
.
getProjectId
().
equalsIgnoreCase
(
resourcePrev
.
getProjectId
()))
{
message
=
"Resource "
+
resourceLatestRecord
.
getEmployeeId
()
+
" already Assigned to the "
message
=
"Resource "
+
resourcePrev
.
getEmployeeId
()
+
" already Assigned to the "
+
projectService
.
getProjectByProjectId
(
resourceLatestRecord
.
getProjectId
()).
getProjectName
()
+
projectService
.
getProjectByProjectId
(
resourcePrev
.
getProjectId
()).
getProjectName
()
+
" Project"
+
" from "
+
resourceLatestRecord
.
getBillingStartDate
()
+
"to "
+
resourceLatestRecord
.
getBillingEndDate
();
+
" Project"
+
" from "
+
resourcePrev
.
getBillingStartDate
()
+
"to "
+
resourcePrev
.
getBillingEndDate
();
isAssigned
=
true
;
isAssigned
=
true
;
respMap
.
put
(
"statusCode"
,
815
);
respMap
.
put
(
"statusCode"
,
815
);
respMap
.
put
(
"message"
,
message
);
respMap
.
put
(
"message"
,
message
);
}
}
}
}
return
isAssigned
;
return
isAssigned
;
}
}
...
...
src/main/java/com/nisum/myteam/utils/MyTeamDateUtils.java
View file @
bbf76717
...
@@ -32,9 +32,19 @@ public class MyTeamDateUtils {
...
@@ -32,9 +32,19 @@ public class MyTeamDateUtils {
return
yesterday
;
return
yesterday
;
}
}
//public static void main(String[] args)
public
static
Date
getDayMoreThanDate
(
Date
date
)
//{
{
// MyTeamDateUtils.getDayLessThanDate(new Date());
Calendar
calendar
=
Calendar
.
getInstance
();
// }
calendar
.
setTime
(
date
);
calendar
.
add
(
Calendar
.
DATE
,
+
1
);
Date
yesterday
=
calendar
.
getTime
();
log
.
info
(
"Day after Date is::"
+
yesterday
);
return
yesterday
;
}
// public static void main(String[] args)
// {
// MyTeamDateUtils.getDayMoreThanDate(new Date());
// }
}
}
src/main/java/com/nisum/myteam/utils/MyTeamUtils.java
View file @
bbf76717
...
@@ -131,6 +131,7 @@ public class MyTeamUtils {
...
@@ -131,6 +131,7 @@ public class MyTeamUtils {
public
final
static
String
BENCH_ACCOUNT
=
"Nisum India"
;
public
final
static
String
BENCH_ACCOUNT
=
"Nisum India"
;
public
final
static
String
BENCH_PROJECT_ID
=
"Nisum0000"
;
public
final
static
String
BENCH_PROJECT_ID
=
"Nisum0000"
;
public
final
static
String
BENCH_BILLABILITY_STATUS
=
"Non-Billable"
;
public
final
static
String
BENCH_BILLABILITY_STATUS
=
"Non-Billable"
;
public
final
static
String
BILLABLE_TEXT
=
"Billable"
;
public
final
static
int
INT_ZERO
=
0
;
public
final
static
int
INT_ZERO
=
0
;
public
final
static
int
INT_TWO
=
2
;
public
final
static
int
INT_TWO
=
2
;
...
...
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