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
7865ca77
Commit
7865ca77
authored
Feb 28, 2020
by
Md Suleman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
effective time period changes and employee inactive changes
parent
9744b7fc
Changes
10
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
191 additions
and
149 deletions
+191
-149
EffectiveLoginTimeController.java
...nisum/myteam/controller/EffectiveLoginTimeController.java
+35
-24
EffectiveLoginDataRepo.java
...a/com/nisum/myteam/repository/EffectiveLoginDataRepo.java
+2
-1
EffectiveLoginTimeScheduler.java
...m/nisum/myteam/schedular/EffectiveLoginTimeScheduler.java
+1
-1
EmployeeAVGHoursScheduler.java
...com/nisum/myteam/schedular/EmployeeAVGHoursScheduler.java
+10
-8
IEffectiveLoginTimeService.java
.../com/nisum/myteam/service/IEffectiveLoginTimeService.java
+5
-3
EffectiveLoginTimeService.java
.../nisum/myteam/service/impl/EffectiveLoginTimeService.java
+121
-104
EmployeeService.java
...n/java/com/nisum/myteam/service/impl/EmployeeService.java
+5
-1
MailService.java
src/main/java/com/nisum/myteam/service/impl/MailService.java
+0
-1
MyTeamUtils.java
src/main/java/com/nisum/myteam/utils/MyTeamUtils.java
+7
-2
application.properties
src/main/resources/application.properties
+5
-4
No files found.
src/main/java/com/nisum/myteam/controller/EffectiveLoginTimeController.java
View file @
7865ca77
...
...
@@ -10,10 +10,12 @@ import com.nisum.myteam.service.IEmployeeService;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.format.annotation.DateTimeFormat
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.web.bind.annotation.*
;
import
javax.transaction.Transactional
;
import
javax.servlet.http.HttpServletRequest
;
import
java.text.ParseException
;
import
java.util.ArrayList
;
...
...
@@ -31,17 +33,26 @@ public class EffectiveLoginTimeController {
@Autowired
private
IEmployeeService
employeeService
;
@GetMapping
(
"/updateLogins"
)
public
List
<
EffectiveLoginData
>
getLoginData
()
throws
MyTeamException
{
@Transactional
@PostMapping
(
"/updateLogins"
)
public
List
<
EffectiveLoginData
>
getLoginData
(
@RequestParam
(
"date"
)
@DateTimeFormat
(
iso
=
DateTimeFormat
.
ISO
.
DATE
)
Date
date
)
throws
MyTeamException
,
ParseException
{
effectiveLoginTimeService
.
deleteLogins
(
date
);
List
<
EffectiveLoginData
>
loginData
=
new
ArrayList
<>();
List
<
Employee
>
allEmployees
=
employeeService
.
getActiveEmployees
();
for
(
Employee
employee:
allEmployees
){
EffectiveLoginData
effectiveLoginData
=
effectiveLoginTimeService
.
calculateEffectiveLoginTimeForEmpAndSave
(
employee
);
effectiveLoginTimeService
.
calculateEffectiveLoginTimeForEmpAndSave
(
employee
,
date
);
loginData
.
add
(
effectiveLoginData
);
}
return
loginData
;
}
@DeleteMapping
(
"/deleteLogins"
)
public
void
deleteLoginDate
(
@RequestParam
(
"date"
)
@DateTimeFormat
(
iso
=
DateTimeFormat
.
ISO
.
DATE
)
Date
date
)
throws
ParseException
{
effectiveLoginTimeService
.
deleteLogins
(
date
);
}
@GetMapping
(
"/effectiveLogin"
)
public
Map
<
String
,
Object
>
getAllEmployeesLoginData
(
@RequestParam
(
"employeeId"
)
long
employeeId
,
...
...
@@ -52,25 +63,25 @@ public class EffectiveLoginTimeController {
}
@DeleteMapping
(
"/deleteLoginData"
)
public
ResponseEntity
<?>
deleteLoginData
(
@RequestParam
(
"fromDate"
)
@DateTimeFormat
(
iso
=
DateTimeFormat
.
ISO
.
DATE
)
Date
fromDate
,
@RequestParam
(
"toDate"
)
@DateTimeFormat
(
iso
=
DateTimeFormat
.
ISO
.
DATE
)
Date
toDate
,
@RequestParam
(
"employeeId"
)
String
employeeId
,
HttpServletRequest
request
)
throws
MyTeamException
{
effectiveLoginTimeService
.
deleteEmployeeLoginData
(
employeeId
,
fromDate
,
toDate
);
ResponseDetails
responseDetails
=
new
ResponseDetails
(
new
Date
(),
904
,
"delete Employees Login details Successfully"
,
"delete Employees Login details Successfully"
,
null
,
request
.
getRequestURI
(),
"Login details"
,
null
);
return
new
ResponseEntity
<
ResponseDetails
>(
responseDetails
,
HttpStatus
.
OK
);
}
@PostMapping
(
"/syncLoginDataByDateRange"
)
public
List
<
EffectiveLoginData
>
syncLoginDataByDateRange
(
@RequestParam
(
"fromDate"
)
@DateTimeFormat
(
iso
=
DateTimeFormat
.
ISO
.
DATE
)
Date
fromDate
,
@RequestParam
(
"toDate"
)
@DateTimeFormat
(
iso
=
DateTimeFormat
.
ISO
.
DATE
)
Date
toDate
)
throws
MyTeamException
{
List
<
EffectiveLoginData
>
loginData
=
new
ArrayList
<>();
List
<
Employee
>
allEmployees
=
employeeService
.
getActiveEmployees
();
//allEmployees.removeIf(s -> !"40270".equalsIgnoreCase(s.getEmployeeId()));
for
(
Employee
employee
:
allEmployees
)
{
EffectiveLoginData
effectiveLoginData
=
effectiveLoginTimeService
.
calculateEffectiveLoginTimeForEmpAndSave
(
employee
,
fromDate
,
toDate
);
loginData
.
add
(
effectiveLoginData
);
}
return
loginData
;
}
//
@DeleteMapping("/deleteLoginData")
//
public ResponseEntity<?> deleteLoginData(@RequestParam("fromDate") @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) Date fromDate,
//
@RequestParam("toDate") @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) Date toDate, @RequestParam("employeeId") String employeeId, HttpServletRequest request) throws MyTeamException {
//
effectiveLoginTimeService.deleteEmployeeLoginData(employeeId,fromDate,toDate);
//
ResponseDetails responseDetails = new ResponseDetails(new Date(), 904, "delete Employees Login details Successfully",
//
"delete Employees Login details Successfully", null, request.getRequestURI(), "Login details", null);
//
return new ResponseEntity<ResponseDetails>(responseDetails, HttpStatus.OK);
//
}
//
@PostMapping("/syncLoginDataByDateRange")
//
public List<EffectiveLoginData> syncLoginDataByDateRange(@RequestParam("fromDate") @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) Date fromDate,
//
@RequestParam("toDate") @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) Date toDate) throws MyTeamException {
//
List<EffectiveLoginData> loginData = new ArrayList<>();
//
List<Employee> allEmployees = employeeService.getActiveEmployees();
//
//allEmployees.removeIf(s -> !"40270".equalsIgnoreCase(s.getEmployeeId()));
//
for (Employee employee : allEmployees) {
//
EffectiveLoginData effectiveLoginData =
//
effectiveLoginTimeService.calculateEffectiveLoginTimeForEmpAndSave(employee, fromDate, toDate);
//
loginData.add(effectiveLoginData);
//
}
//
return loginData;
//
}
}
src/main/java/com/nisum/myteam/repository/EffectiveLoginDataRepo.java
View file @
7865ca77
...
...
@@ -10,6 +10,7 @@ public interface EffectiveLoginDataRepo extends MongoRepository<EffectiveLoginDa
List
<
EffectiveLoginData
>
findByEmployeeId
(
String
employeeId
);
List
<
EffectiveLoginData
>
findByDateBetween
(
Date
from
,
Date
to
);
List
<
EffectiveLoginData
>
findByDateBetween
OrderByDate
(
Date
from
,
Date
to
);
void
deleteByDate
(
Date
date
);
}
src/main/java/com/nisum/myteam/schedular/EffectiveLoginTimeScheduler.java
View file @
7865ca77
...
...
@@ -29,7 +29,7 @@ public class EffectiveLoginTimeScheduler {
List
<
Employee
>
allEmployees
=
employeeService
.
getActiveEmployees
();
for
(
Employee
employee:
allEmployees
){
EffectiveLoginData
effectiveLoginData
=
effectiveLoginTimeService
.
calculateEffectiveLoginTimeForEmpAndSave
(
employee
);
effectiveLoginTimeService
.
calculateEffectiveLoginTimeForEmpAndSave
(
employee
,
null
);
}
}
}
src/main/java/com/nisum/myteam/schedular/EmployeeAVGHoursScheduler.java
View file @
7865ca77
...
...
@@ -64,29 +64,29 @@ public class EmployeeAVGHoursScheduler {
logger
.
info
(
"sendEmployessAvgHoursMailToLeadsnotification::"
);
SchedulersLogsDetails
schedulersLogsDetails
=
schedulersLogsDetailsService
.
getCurrentSchedulerLogDetails
(
"EmployeeAVGHoursScheduler"
,
new
Date
());
if
(
schedulersLogsDetails
==
null
||
!
"Active"
.
equalsIgnoreCase
(
schedulersLogsDetails
.
getSchedulerStatus
()))
{
sendhoursExemptEmpListToLeads
();
}
sendhoursExemptEmpListToLeads
();
}
private
void
sendhoursExemptEmpListToLeads
()
throws
MessagingException
{
logger
.
info
(
"sending avg hours list to managers"
);
SchedulersLogsDetails
schedulersLogsDetails
;
Mail
mail
=
new
Mail
();
LocalDate
dt
=
LocalDate
.
now
(
);
LocalDate
lastWeekDay
=
LocalDate
.
now
().
minusWeeks
(
1
);
try
{
Date
friday
=
Date
.
from
(
dt
.
with
(
TemporalAdjusters
.
previous
(
DayOfWeek
.
FRIDAY
)).
atStartOfDay
().
atZone
(
ZoneId
.
systemDefault
()).
toInstant
());
Date
monday
=
Date
.
from
(
dt
.
with
(
TemporalAdjusters
.
previous
(
DayOfWeek
.
MONDAY
)).
atStartOfDay
().
atZone
(
ZoneId
.
systemDefault
()).
toInstant
());
Date
monday
=
Date
.
from
(
lastWeekDay
.
with
(
DayOfWeek
.
MONDAY
).
atStartOfDay
(
ZoneId
.
systemDefault
()).
toInstant
());
Date
sunday
=
Date
.
from
(
lastWeekDay
.
with
(
DayOfWeek
.
SUNDAY
).
atStartOfDay
(
ZoneId
.
systemDefault
()).
toInstant
());
List
<
Employee
>
activeEmpList
=
employeeService
.
getActiveEmployees
();
List
<
LoginDetailsVO
>
hoursExemptEmployeeList
=
new
ArrayList
<>();
activeEmpList
.
removeIf
(
e
->
"At Client Location"
.
equalsIgnoreCase
(
e
.
getEmpSubStatus
()
instanceof
String
?
(
String
)
e
.
getEmpSubStatus
()
:
null
));
activeEmpList
.
removeIf
(
e
->
{
try
{
Map
<
String
,
Object
>
obj
=
effectiveLoginTimeService
.
getEmployeesEffLoginData
(
new
Long
(
e
.
getEmployeeId
()),
monday
,
fri
day
);
Map
<
String
,
Object
>
obj
=
effectiveLoginTimeService
.
getEmployeesEffLoginData
(
new
Long
(
e
.
getEmployeeId
()),
monday
,
sun
day
);
if
(
obj
!=
null
&&
(
String
)
obj
.
get
(
"averageTime"
)
!=
null
)
{
String
hoursMins
[]
=
((
String
)
obj
.
get
(
"averageTime"
)).
split
(
":"
);
if
(
hoursMins
!=
null
)
{
boolean
isHoursExemptEmployee
=
new
Long
(
hoursMins
[
0
])
<
8
;
if
(
isHoursExemptEmployee
)
{
//System.out.println(" Hours avg " + obj.get("data"));
LoginDetailsVO
loginDetailsVO
=
new
LoginDetailsVO
();
loginDetailsVO
.
setEmployeeId
(
e
.
getEmployeeId
());
loginDetailsVO
.
setEmployeeName
(
e
.
getEmployeeName
());
...
...
@@ -96,7 +96,9 @@ public class EmployeeAVGHoursScheduler {
StringBuilder
orphanLoginSB
=
new
StringBuilder
();
effectiveLoginDataList
.
stream
().
forEach
(
eloginData
->
{
if
(
eloginData
.
getOrphanLogin
()
!=
null
&&
!
eloginData
.
getOrphanLogin
().
isEmpty
())
orphanLoginSB
.
append
(
" "
+
parseDate
(
eloginData
.
getDate
(),
"dd-MMM-yyyy"
)
+
" - "
+
eloginData
.
getOrphanLogin
().
stream
().
collect
(
Collectors
.
joining
(
","
,
"["
,
"]"
)));
orphanLoginSB
.
append
(
" "
+
parseDate
(
eloginData
.
getDate
(),
"dd-MMM-yyyy"
)
+
" - "
+
eloginData
.
getOrphanLogin
().
stream
()
.
collect
(
Collectors
.
joining
(
","
,
"["
,
"]"
)));
});
loginDetailsVO
.
setOrphanLogin
(
orphanLoginSB
.
toString
());
hoursExemptEmployeeList
.
add
(
loginDetailsVO
);
...
...
src/main/java/com/nisum/myteam/service/IEffectiveLoginTimeService.java
View file @
7865ca77
...
...
@@ -10,11 +10,13 @@ import java.util.Map;
public
interface
IEffectiveLoginTimeService
{
public
EffectiveLoginData
calculateEffectiveLoginTimeForEmpAndSave
(
Employee
employee
)
throws
MyTeamException
;
public
EffectiveLoginData
calculateEffectiveLoginTimeForEmpAndSave
(
Employee
employee
,
Date
date
)
throws
MyTeamException
;
public
Map
<
String
,
Object
>
getEmployeesEffLoginData
(
long
employeeId
,
Date
fromDate
,
Date
toDate
)
throws
ParseException
;
public
void
delete
EmployeeLoginData
(
String
employeeId
,
Date
fromDate
,
Date
toDate
)
throws
MyTeam
Exception
;
public
void
delete
Logins
(
Date
date
)
throws
Parse
Exception
;
EffectiveLoginData
calculateEffectiveLoginTimeForEmpAndSave
(
Employee
employee
,
Date
fromDate
,
Date
toDate
)
throws
MyTeamException
;
// public void deleteEmployeeLoginData(String employeeId, Date fromDate, Date toDate) throws MyTeamException;
//
// EffectiveLoginData calculateEffectiveLoginTimeForEmpAndSave(Employee employee, Date fromDate, Date toDate) throws MyTeamException;
}
src/main/java/com/nisum/myteam/service/impl/EffectiveLoginTimeService.java
View file @
7865ca77
This diff is collapsed.
Click to expand it.
src/main/java/com/nisum/myteam/service/impl/EmployeeService.java
View file @
7865ca77
...
...
@@ -24,6 +24,7 @@ import org.springframework.stereotype.Service;
import
org.springframework.web.multipart.MultipartFile
;
import
java.io.IOException
;
import
javax.transaction.Transactional
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.util.*
;
...
...
@@ -167,6 +168,7 @@ public class EmployeeService implements IEmployeeService {
// }
@Override
@Transactional
public
Employee
updateEmployee
(
Employee
employeeReq
,
String
loginEmpId
)
throws
ParseException
{
// update all emp details to inactive if employee is inactive
...
...
@@ -241,10 +243,12 @@ public class EmployeeService implements IEmployeeService {
FindAndModifyOptions
options
=
new
FindAndModifyOptions
();
options
.
returnNew
(
true
);
options
.
upsert
(
true
);
Employee
employeeUpdated
=
mongoTemplate
.
findAndModify
(
query
,
update
,
options
,
Employee
.
class
);
if
(
employeeReq
.
getEmpStatus
().
equals
(
"In Active"
))
{
resourceService
.
makeResourceInactive
(
employeeReq
.
getEmployeeId
(),
employeeReq
.
getEndDate
());
update
.
set
(
"emailId"
,
employeeReq
.
getEmailId
()+
MyTeamUtils
.
_OLD
);
update
.
set
(
"employeeId"
,
employeeReq
.
getEmployeeId
()+
MyTeamUtils
.
_OLD
);
}
Employee
employeeUpdated
=
mongoTemplate
.
findAndModify
(
query
,
update
,
options
,
Employee
.
class
);
response
.
put
(
"messege"
,
"Employee has been updated"
);
return
employeeUpdated
;
}
...
...
src/main/java/com/nisum/myteam/service/impl/MailService.java
View file @
7865ca77
...
...
@@ -181,7 +181,6 @@ public class MailService implements IMailService {
@Override
public
void
sendExemptHoursEmployeDetailsToLeads
(
Mail
mail
,
List
<
LoginDetailsVO
>
hoursExemptEmployeeList
)
throws
MessagingException
,
IOException
{
System
.
out
.
println
(
hoursExemptEmployeeList
.
size
());
if
(
Optional
.
ofNullable
(
hoursExemptEmployeeList
).
isPresent
()
)
{
MimeMessage
message
=
emailSender
.
createMimeMessage
();
MimeMessageHelper
helper
=
new
MimeMessageHelper
(
message
,
true
);
...
...
src/main/java/com/nisum/myteam/utils/MyTeamUtils.java
View file @
7865ca77
...
...
@@ -108,9 +108,13 @@ public class MyTeamUtils {
public
final
static
String
EMPLOYEE_YESTERDAY_LOGIN_DETAILS_QUERY
=
"SELECT emp.FirstName, emp.EmployeeCode, pd.TransactionDateTime, re.IOEntryStatus, re.ReaderName\n"
+
"FROM ProcessData AS pd , EmployeeMaster AS emp, Readers AS re \n"
+
"WHERE emp.EmployeeMasterID = pd.EmployeeID AND re.ReaderID = pd.ReaderID AND emp.EmployeeCode = %s \n"
+
"AND pd.TransactionDateTime <
=
CONVERT(date,GETDATE()) AND pd.TransactionDateTime >= CONVERT(date,GETDATE()-1) "
+
"AND pd.TransactionDateTime < CONVERT(date,GETDATE()) AND pd.TransactionDateTime >= CONVERT(date,GETDATE()-1) "
+
"ORDER BY pd.TransactionDateTime"
;
public
final
static
String
EMPLOYEE_LOGIN_DETAILS_QUERY_OF_DATE
=
"SELECT emp.FirstName, emp.EmployeeCode, pd.TransactionDateTime, re.IOEntryStatus, re.ReaderName\n"
+
"FROM ProcessData AS pd , EmployeeMaster AS emp, Readers AS re \n"
+
"WHERE emp.EmployeeMasterID = pd.EmployeeID AND re.ReaderID = pd.ReaderID AND emp.EmployeeCode = %s\n"
+
"AND pd.TransactionDateTime >= '%s' and pd.TransactionDateTime < DATEADD(day,+1,'%s') ORDER BY pd.TransactionDateTime"
;
public
final
static
String
UNION
=
" Union "
;
...
...
@@ -205,4 +209,5 @@ public class MyTeamUtils {
"WHERE emp.EmployeeMasterID = pd.EmployeeID AND re.ReaderID = pd.ReaderID AND emp.EmployeeCode = %s \n"
+
"AND pd.TransactionDateTime BETWEEN CONVERT(datetime,'%2$s') AND CONVERT(datetime,'%3$s') "
+
"ORDER BY pd.TransactionDateTime"
;
public
final
static
String
_OLD
=
"_old"
;
}
src/main/resources/application.properties
View file @
7865ca77
...
...
@@ -43,7 +43,6 @@ myTeam.data.mssqldb.password=admin@123
email.leave.notification.template.file.path
=
email/absentMailTemplate.html
email.leave.notification.from
=
mytime.nisum@gmail.com
email.leave.notification.subject
=
Employee Leave Email Notification
email.exempt.hours.employeelist.template.file.path
=
email/employeesExemptHours.html
#0 * * * * ?===>for every minute
...
...
@@ -68,13 +67,15 @@ email.project.notification.cron=00 00 15 * * 1-5
email.workAnniversary.notification.from
=
mytime.nisum@gmail.com
myTeam.exemptHours.fromemail
=
myerrabothu@nisum.com
myTeam.exemptHours.toemail
=
myerrabothu@nisum.com
email.exemptHours.notification.cron
=
0 10 10 ? * MON
email.workAnniversary.notification.subject
=
Happy Work Anniversary
email.workAnniversary.notification.cron
=
00 00 06 * * 1-7
effective.login.time.cron
=
00 05 00 * * 1-7
myTeam.exemptHours.fromemail
=
mytime.nisum@gmail.com
myTeam.exemptHours.toemail
=
msuleman@nisum.com
email.exemptHours.notification.cron
=
00 12 18 * * 1-7
email.exempt.hours.employeelist.template.file.path
=
email/employeesExemptHours.html
spring.profiles.active
=
development
message
=
this is from default configuration
\ No newline at end of file
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