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
73a120f3
Commit
73a120f3
authored
Feb 28, 2020
by
Mallikarjun Yerrabothu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
scheduler related changes
parent
d84b248e
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
222 additions
and
19 deletions
+222
-19
EffectiveLoginTimeController.java
...nisum/myteam/controller/EffectiveLoginTimeController.java
+28
-3
EffectiveLoginData.java
...n/java/com/nisum/myteam/model/dao/EffectiveLoginData.java
+1
-0
EffectiveLoginDataRepo.java
...a/com/nisum/myteam/repository/EffectiveLoginDataRepo.java
+1
-0
IEffectiveLoginTimeService.java
.../com/nisum/myteam/service/IEffectiveLoginTimeService.java
+4
-2
IMailService.java
src/main/java/com/nisum/myteam/service/IMailService.java
+3
-0
EffectiveLoginTimeService.java
.../nisum/myteam/service/impl/EffectiveLoginTimeService.java
+130
-13
MailService.java
src/main/java/com/nisum/myteam/service/impl/MailService.java
+39
-0
MyTeamUtils.java
src/main/java/com/nisum/myteam/utils/MyTeamUtils.java
+12
-1
application.properties
src/main/resources/application.properties
+4
-0
No files found.
src/main/java/com/nisum/myteam/controller/EffectiveLoginTimeController.java
View file @
73a120f3
...
@@ -2,6 +2,7 @@ package com.nisum.myteam.controller;
...
@@ -2,6 +2,7 @@ package com.nisum.myteam.controller;
import
com.nisum.myteam.exception.handler.MyTeamException
;
import
com.nisum.myteam.exception.handler.MyTeamException
;
import
com.nisum.myteam.exception.handler.ResponseDetails
;
import
com.nisum.myteam.model.dao.EffectiveLoginData
;
import
com.nisum.myteam.model.dao.EffectiveLoginData
;
import
com.nisum.myteam.model.dao.Employee
;
import
com.nisum.myteam.model.dao.Employee
;
import
com.nisum.myteam.service.IEffectiveLoginTimeService
;
import
com.nisum.myteam.service.IEffectiveLoginTimeService
;
...
@@ -9,10 +10,11 @@ import com.nisum.myteam.service.IEmployeeService;
...
@@ -9,10 +10,11 @@ import com.nisum.myteam.service.IEmployeeService;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.format.annotation.DateTimeFormat
;
import
org.springframework.format.annotation.DateTimeFormat
;
import
org.springframework.
web.bind.annotation.GetMapping
;
import
org.springframework.
http.HttpStatus
;
import
org.springframework.
web.bind.annotation.RequestParam
;
import
org.springframework.
http.ResponseEntity
;
import
org.springframework.web.bind.annotation.
RestController
;
import
org.springframework.web.bind.annotation.
*
;
import
javax.servlet.http.HttpServletRequest
;
import
java.text.ParseException
;
import
java.text.ParseException
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.Date
;
...
@@ -48,4 +50,27 @@ public class EffectiveLoginTimeController {
...
@@ -48,4 +50,27 @@ public class EffectiveLoginTimeController {
return
effectiveLoginTimeService
.
getEmployeesEffLoginData
(
employeeId
,
fromDate
,
toDate
);
return
effectiveLoginTimeService
.
getEmployeesEffLoginData
(
employeeId
,
fromDate
,
toDate
);
}
}
@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/model/dao/EffectiveLoginData.java
View file @
73a120f3
...
@@ -32,6 +32,7 @@ public class EffectiveLoginData implements Serializable{
...
@@ -32,6 +32,7 @@ public class EffectiveLoginData implements Serializable{
private
String
loginTime
;
private
String
loginTime
;
private
String
logoutTime
;
private
String
logoutTime
;
private
String
durationAtWorkPlace
;
private
String
durationAtWorkPlace
;
private
Date
createdDate
;
private
List
<
String
>
orphanLogin
;
private
List
<
String
>
orphanLogin
;
public
EffectiveLoginData
(){
public
EffectiveLoginData
(){
orphanLogin
=
new
ArrayList
<>();
orphanLogin
=
new
ArrayList
<>();
...
...
src/main/java/com/nisum/myteam/repository/EffectiveLoginDataRepo.java
View file @
73a120f3
...
@@ -11,4 +11,5 @@ public interface EffectiveLoginDataRepo extends MongoRepository<EffectiveLoginDa
...
@@ -11,4 +11,5 @@ public interface EffectiveLoginDataRepo extends MongoRepository<EffectiveLoginDa
List
<
EffectiveLoginData
>
findByEmployeeId
(
String
employeeId
);
List
<
EffectiveLoginData
>
findByEmployeeId
(
String
employeeId
);
List
<
EffectiveLoginData
>
findByDateBetween
(
Date
from
,
Date
to
);
List
<
EffectiveLoginData
>
findByDateBetween
(
Date
from
,
Date
to
);
}
}
src/main/java/com/nisum/myteam/service/IEffectiveLoginTimeService.java
View file @
73a120f3
package
com
.
nisum
.
myteam
.
service
;
package
com
.
nisum
.
myteam
.
service
;
import
com.nisum.myteam.exception.handler.MyTeamException
;
import
com.nisum.myteam.exception.handler.MyTeamException
;
import
com.nisum.myteam.model.EmployeeLoginData
;
import
com.nisum.myteam.model.dao.EffectiveLoginData
;
import
com.nisum.myteam.model.dao.EffectiveLoginData
;
import
com.nisum.myteam.model.dao.Employee
;
import
com.nisum.myteam.model.dao.Employee
;
import
java.text.ParseException
;
import
java.text.ParseException
;
import
java.util.Date
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
public
interface
IEffectiveLoginTimeService
{
public
interface
IEffectiveLoginTimeService
{
...
@@ -15,4 +13,8 @@ public interface IEffectiveLoginTimeService {
...
@@ -15,4 +13,8 @@ public interface IEffectiveLoginTimeService {
public
EffectiveLoginData
calculateEffectiveLoginTimeForEmpAndSave
(
Employee
employee
)
throws
MyTeamException
;
public
EffectiveLoginData
calculateEffectiveLoginTimeForEmpAndSave
(
Employee
employee
)
throws
MyTeamException
;
public
Map
<
String
,
Object
>
getEmployeesEffLoginData
(
long
employeeId
,
Date
fromDate
,
Date
toDate
)
throws
ParseException
;
public
Map
<
String
,
Object
>
getEmployeesEffLoginData
(
long
employeeId
,
Date
fromDate
,
Date
toDate
)
throws
ParseException
;
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/IMailService.java
View file @
73a120f3
...
@@ -5,9 +5,11 @@ package com.nisum.myteam.service;
...
@@ -5,9 +5,11 @@ package com.nisum.myteam.service;
import
com.nisum.myteam.model.EmailDomain
;
import
com.nisum.myteam.model.EmailDomain
;
import
com.nisum.myteam.model.Mail
;
import
com.nisum.myteam.model.Mail
;
import
com.nisum.myteam.model.vo.LoginDetailsVO
;
import
javax.mail.MessagingException
;
import
javax.mail.MessagingException
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.util.List
;
/**
/**
* @author nisum
* @author nisum
...
@@ -23,5 +25,6 @@ public interface IMailService {
...
@@ -23,5 +25,6 @@ public interface IMailService {
public
void
sendWorkAnniversaryNotification
(
Mail
mail
)
throws
MessagingException
,
IOException
;
public
void
sendWorkAnniversaryNotification
(
Mail
mail
)
throws
MessagingException
,
IOException
;
public
void
sendExemptHoursEmployeDetailsToLeads
(
Mail
mail
,
List
<
LoginDetailsVO
>
hoursExemptEmployeeList
)
throws
MessagingException
,
IOException
;
}
}
src/main/java/com/nisum/myteam/service/impl/EffectiveLoginTimeService.java
View file @
73a120f3
...
@@ -7,6 +7,7 @@ import com.nisum.myteam.model.dao.EffectiveLoginData;
...
@@ -7,6 +7,7 @@ import com.nisum.myteam.model.dao.EffectiveLoginData;
import
com.nisum.myteam.model.dao.Employee
;
import
com.nisum.myteam.model.dao.Employee
;
import
com.nisum.myteam.repository.EffectiveLoginDataRepo
;
import
com.nisum.myteam.repository.EffectiveLoginDataRepo
;
import
com.nisum.myteam.service.IEffectiveLoginTimeService
;
import
com.nisum.myteam.service.IEffectiveLoginTimeService
;
import
com.nisum.myteam.service.IEmployeeService
;
import
com.nisum.myteam.utils.CommomUtil
;
import
com.nisum.myteam.utils.CommomUtil
;
import
com.nisum.myteam.utils.MyTeamDateUtils
;
import
com.nisum.myteam.utils.MyTeamDateUtils
;
import
com.nisum.myteam.utils.MyTeamLogger
;
import
com.nisum.myteam.utils.MyTeamLogger
;
...
@@ -21,7 +22,9 @@ import java.sql.ResultSet;
...
@@ -21,7 +22,9 @@ import java.sql.ResultSet;
import
java.sql.Statement
;
import
java.sql.Statement
;
import
java.sql.Time
;
import
java.sql.Time
;
import
java.text.ParseException
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.util.*
;
import
java.util.*
;
import
java.util.stream.Collectors
;
@Slf4j
@Slf4j
@Service
@Service
...
@@ -33,9 +36,12 @@ public class EffectiveLoginTimeService implements IEffectiveLoginTimeService {
...
@@ -33,9 +36,12 @@ public class EffectiveLoginTimeService implements IEffectiveLoginTimeService {
@Autowired
@Autowired
private
EffectiveLoginDataRepo
effectiveLoginDataRepo
;
private
EffectiveLoginDataRepo
effectiveLoginDataRepo
;
@Autowired
private
IEmployeeService
employeeService
;
@Override
@Override
public
EffectiveLoginData
calculateEffectiveLoginTimeForEmpAndSave
(
Employee
employee
)
throws
MyTeamException
{
public
EffectiveLoginData
calculateEffectiveLoginTimeForEmpAndSave
(
Employee
employee
)
throws
MyTeamException
{
log
.
info
(
" start"
);
String
query
=
String
.
format
(
MyTeamUtils
.
EMPLOYEE_YESTERDAY_LOGIN_DETAILS_QUERY
,
employee
.
getEmployeeId
());
String
query
=
String
.
format
(
MyTeamUtils
.
EMPLOYEE_YESTERDAY_LOGIN_DETAILS_QUERY
,
employee
.
getEmployeeId
());
EffectiveLoginData
effectiveLoginData
=
null
;
EffectiveLoginData
effectiveLoginData
=
null
;
try
(
Connection
connection
=
dbConnection
.
getDBConnection
();
try
(
Connection
connection
=
dbConnection
.
getDBConnection
();
...
@@ -92,29 +98,34 @@ public class EffectiveLoginTimeService implements IEffectiveLoginTimeService {
...
@@ -92,29 +98,34 @@ public class EffectiveLoginTimeService implements IEffectiveLoginTimeService {
MyTeamLogger
.
getInstance
().
error
(
e
.
getMessage
());
MyTeamLogger
.
getInstance
().
error
(
e
.
getMessage
());
throw
new
MyTeamException
(
e
.
getMessage
());
throw
new
MyTeamException
(
e
.
getMessage
());
}
}
log
.
info
(
" end"
);
return
effectiveLoginData
;
return
effectiveLoginData
;
}
}
@Override
@Override
public
Map
<
String
,
Object
>
getEmployeesEffLoginData
(
long
employeeId
,
Date
fromDate
,
Date
toDate
)
throws
ParseException
{
public
Map
<
String
,
Object
>
getEmployeesEffLoginData
(
long
employeeId
,
Date
fromDate
,
Date
toDate
)
throws
ParseException
{
Map
<
String
,
Object
>
response
=
new
HashMap
<>();
Map
<
String
,
Object
>
response
=
new
HashMap
<>();
if
(
fromDate
.
compareTo
(
toDate
)
<=
0
)
{
if
(
fromDate
.
compareTo
(
toDate
)
<=
0
)
{
List
<
EffectiveLoginData
>
loginDataList
=
effectiveLoginDataRepo
.
findByDateBetween
(
MyTeamDateUtils
.
getDayLessThanDate
(
fromDate
),
toDate
);
final
Date
frmDate
=
MyTeamDateUtils
.
getDayLessThanDate
(
fromDate
);
List
<
EffectiveLoginData
>
loginDataList
=
effectiveLoginDataRepo
.
findByDateBetween
(
frmDate
,
toDate
);
if
(
Objects
.
nonNull
(
loginDataList
)
&&
employeeId
!=
0
)
{
if
(
Objects
.
nonNull
(
loginDataList
)
&&
employeeId
!=
0
)
{
long
totalTime
=
0
;
long
totalTime
=
0
;
loginDataList
.
removeIf
(
effectiveLoginData
->
!
effectiveLoginData
.
getEmployeeId
().
equals
(
String
.
valueOf
(
employeeId
)));
loginDataList
.
removeIf
(
effectiveLoginData
->
!
effectiveLoginData
.
getEmployeeId
().
equals
(
String
.
valueOf
(
employeeId
)));
for
(
EffectiveLoginData
effectiveLoginData
:
loginDataList
)
{
for
(
EffectiveLoginData
effectiveLoginData
:
loginDataList
)
{
if
(
effectiveLoginData
.
getDurationAtWorkPlace
()
!=
null
)
{
Date
loginTime
=
MyTeamUtils
.
tdf
.
parse
(
effectiveLoginData
.
getDurationAtWorkPlace
());
Date
loginTime
=
MyTeamUtils
.
tdf
.
parse
(
effectiveLoginData
.
getDurationAtWorkPlace
());
totalTime
+=
loginTime
.
getTime
();
totalTime
+=
loginTime
.
getTime
();
}
}
}
if
(
totalTime
!=
0
&&
!
loginDataList
.
isEmpty
())
response
.
put
(
"averageTime"
,
MyTeamUtils
.
tdf
.
format
(
totalTime
/
loginDataList
.
size
()));
response
.
put
(
"averageTime"
,
MyTeamUtils
.
tdf
.
format
(
totalTime
/
loginDataList
.
size
()));
}
}
response
.
put
(
"data"
,
loginDataList
);
response
.
put
(
"data"
,
loginDataList
);
}
else
{
}
else
{
response
.
put
(
"data"
,
"Invalid Dates"
);
response
.
put
(
"data"
,
"Invalid Dates"
);
}
}
log
.
info
(
"getEmployeesEffLoginData end"
);
return
response
;
return
response
;
}
}
...
@@ -126,4 +137,110 @@ public class EffectiveLoginTimeService implements IEffectiveLoginTimeService {
...
@@ -126,4 +137,110 @@ public class EffectiveLoginTimeService implements IEffectiveLoginTimeService {
return
CommomUtil
.
appendZero
(
hours
)
+
":"
+
CommomUtil
.
appendZero
(
minutes
)
+
":"
return
CommomUtil
.
appendZero
(
hours
)
+
":"
+
CommomUtil
.
appendZero
(
minutes
)
+
":"
+
CommomUtil
.
appendZero
(
seconds
);
+
CommomUtil
.
appendZero
(
seconds
);
}
}
@Override
public
void
deleteEmployeeLoginData
(
String
employeeId
,
Date
fromDate
,
Date
toDate
)
throws
MyTeamException
{
log
.
info
(
"Start"
);
List
<
EffectiveLoginData
>
loginDataList
=
effectiveLoginDataRepo
.
findByDateBetween
(
fromDate
,
toDate
);
System
.
out
.
println
(
loginDataList
.
size
());
List
<
Employee
>
allEmployees
=
employeeService
.
getActiveEmployees
();
List
<
Object
>
deleteLoginData
=
new
ArrayList
<>();
allEmployees
.
stream
().
forEach
(
e
->
{
List
<
EffectiveLoginData
>
data
=
loginDataList
.
stream
().
filter
(
l
->
(
e
.
getEmployeeId
().
equalsIgnoreCase
(
l
.
getEmployeeId
())
)).
collect
(
Collectors
.
toList
());
//System.out.println(" Data size " +data.size());
//System.out.println(data);
if
(
data
.
size
()
>
1
)
{
//System.out.println(" Data TESTTTTT " +data);
deleteLoginData
.
add
(
Optional
.
ofNullable
(
data
).
get
().
get
(
0
).
getId
());
//effectiveLoginDataRepo.delete(Optional.ofNullable(data).get().get(0));
}
//System.out.println(effectiveLoginData + " effective login data : " + effectiveLoginData.getEmployeeId() + " Login ID " + effectiveLoginData.getId());
});
deleteLoginData
.
stream
().
forEach
(
System
.
out
::
println
);
// System.out.println("size" + deleteLoginData.size());
// deleteLoginData.stream().forEach(e -> System.out.println(e));
//System.out.println("Data between Days" + loginDataList.size());
//List<EffectiveLoginData> loginData= loginDataList.stream().collect(EffectiveLoginData:fromDate).filter(s->"40270".equalsIgnoreCase(s.getEmployeeId())).findFirst();
log
.
info
(
"end"
);
}
@Override
public
EffectiveLoginData
calculateEffectiveLoginTimeForEmpAndSave
(
Employee
employee
,
Date
fromDate
,
Date
toDate
)
throws
MyTeamException
{
log
.
info
(
" start"
);
String
query
=
String
.
format
(
MyTeamUtils
.
EMPLOYEE_LOGIN_DETAILS_QUERY_BY_DATES
,
employee
.
getEmployeeId
(),
parseDate
(
fromDate
),
parseDate
(
toDate
));
EffectiveLoginData
effectiveLoginData
=
null
;
HashMap
<
String
,
EffectiveLoginData
>
loginDataHashMap
=
new
HashMap
<>();
try
(
Connection
connection
=
dbConnection
.
getDBConnection
();
Statement
statement
=
connection
.
createStatement
();
ResultSet
resultSet
=
statement
.
executeQuery
(
query
.
toString
()))
{
String
entryType
=
null
;
long
time
=
0
;
long
totalTime
=
0
;
StringBuilder
times
=
new
StringBuilder
();
while
(
resultSet
.
next
())
{
long
differenceTime
;
EmployeeLoginData
employeeLoginData
=
new
EmployeeLoginData
();
employeeLoginData
.
setEmployeeId
(
resultSet
.
getString
(
"EmployeeCode"
));
employeeLoginData
.
setName
(
resultSet
.
getString
(
"FirstName"
));
employeeLoginData
.
setDate
(
resultSet
.
getDate
(
"TransactionDateTime"
));
employeeLoginData
.
setTime
(
resultSet
.
getTime
(
"TransactionDateTime"
));
employeeLoginData
.
setEntryType
(
resultSet
.
getString
(
"IOEntryStatus"
));
employeeLoginData
.
setEntryDoor
(
resultSet
.
getString
(
"ReaderName"
));
if
(
Objects
.
nonNull
(
entryType
)
&&
entryType
.
equals
(
employeeLoginData
.
getEntryType
())){
String
type
=
entryType
.
equals
(
"IN"
)
?
entryType
+
"-"
+
new
Time
(
time
)
:
employeeLoginData
.
getEntryType
()
+
"-"
+
new
Time
(
employeeLoginData
.
getTime
().
getTime
());
effectiveLoginData
.
getOrphanLogin
().
add
(
type
);
}
if
(
Strings
.
isNullOrEmpty
(
entryType
)){
effectiveLoginData
=
new
EffectiveLoginData
();
entryType
=
employeeLoginData
.
getEntryType
();
effectiveLoginData
.
setName
(
employee
.
getEmployeeName
());
effectiveLoginData
.
setEmployeeId
(
employeeLoginData
.
getEmployeeId
());
effectiveLoginData
.
setDate
(
employeeLoginData
.
getDate
());
effectiveLoginData
.
setLoginTime
(
employeeLoginData
.
getTime
().
toString
());
effectiveLoginData
.
setLogoutTime
(
employeeLoginData
.
getTime
().
toString
());
effectiveLoginData
.
setDurationAtWorkPlace
(
getTimeInString
(
totalTime
));
if
(
entryType
.
equals
(
"OUT"
))
effectiveLoginData
.
getOrphanLogin
().
add
(
"OUT-"
+
employeeLoginData
.
getTime
().
toString
());
}
if
(
entryType
.
equals
(
"IN"
)
&&
employeeLoginData
.
getEntryType
().
equals
(
"OUT"
)){
differenceTime
=
employeeLoginData
.
getTime
().
getTime
()
-
time
;
totalTime
+=
differenceTime
;
effectiveLoginData
.
setLogoutTime
(
employeeLoginData
.
getTime
().
toString
());
effectiveLoginData
.
setDurationAtWorkPlace
(
getTimeInString
(
totalTime
));
}
time
=
employeeLoginData
.
getTime
().
getTime
();
entryType
=
employeeLoginData
.
getEntryType
();
loginDataHashMap
.
put
(
parseDate
(
employeeLoginData
.
getDate
()),
effectiveLoginData
);
}
if
(
Objects
.
nonNull
(
effectiveLoginData
)){
log
.
info
(
"Storing effective login time for employee:{}"
,
effectiveLoginData
.
getEmployeeId
());
if
(
"40270"
.
equalsIgnoreCase
(
employee
.
getEmployeeId
()))
effectiveLoginDataRepo
.
save
(
effectiveLoginData
);
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
MyTeamLogger
.
getInstance
().
error
(
e
.
getMessage
());
throw
new
MyTeamException
(
e
.
getMessage
());
}
log
.
info
(
" end"
);
return
effectiveLoginData
;
}
public
static
Date
parseDate
(
String
date
)
{
try
{
return
new
SimpleDateFormat
(
"yyyy-MM-dd"
).
parse
(
date
);
}
catch
(
ParseException
e
)
{
return
null
;
}
}
public
static
String
parseDate
(
Date
date
)
{
return
new
SimpleDateFormat
(
"yyyy-MM-dd"
).
format
(
date
);
}
}
}
src/main/java/com/nisum/myteam/service/impl/MailService.java
View file @
73a120f3
...
@@ -5,6 +5,7 @@ package com.nisum.myteam.service.impl;
...
@@ -5,6 +5,7 @@ package com.nisum.myteam.service.impl;
import
com.nisum.myteam.model.EmailDomain
;
import
com.nisum.myteam.model.EmailDomain
;
import
com.nisum.myteam.model.Mail
;
import
com.nisum.myteam.model.Mail
;
import
com.nisum.myteam.model.vo.LoginDetailsVO
;
import
com.nisum.myteam.service.IMailService
;
import
com.nisum.myteam.service.IMailService
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
@@ -29,6 +30,9 @@ import java.io.IOException;
...
@@ -29,6 +30,9 @@ import java.io.IOException;
import
java.io.InputStream
;
import
java.io.InputStream
;
import
java.nio.file.Files
;
import
java.nio.file.Files
;
import
java.util.Date
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Optional
;
/**
/**
* @author nisum
* @author nisum
*
*
...
@@ -175,5 +179,40 @@ public class MailService implements IMailService {
...
@@ -175,5 +179,40 @@ public class MailService implements IMailService {
emailSender
.
send
(
message
);
emailSender
.
send
(
message
);
}
}
@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
);
StringBuilder
exemptEmployeeRowsData
=
new
StringBuilder
();
hoursExemptEmployeeList
.
stream
().
forEach
(
e
->
{
exemptEmployeeRowsData
.
append
(
"<tr><td style = \"padding: 10px;\">"
);
exemptEmployeeRowsData
.
append
(
e
.
getEmployeeId
());
exemptEmployeeRowsData
.
append
(
"</td><td style = \"padding: 10px;\">"
);
exemptEmployeeRowsData
.
append
(
e
.
getEmployeeName
());
exemptEmployeeRowsData
.
append
(
"</td><td style = \"padding: 10px;\">"
);
exemptEmployeeRowsData
.
append
(
e
.
getAvgHours
());
exemptEmployeeRowsData
.
append
(
"</td><td style = \"padding: 10px;\">"
);
exemptEmployeeRowsData
.
append
(
e
.
getOrphanLogin
());
exemptEmployeeRowsData
.
append
(
"</td>"
);
});
File
file
=
ResourceUtils
.
getFile
(
"classpath:"
+
environment
.
getProperty
(
"email.exempt.hours.employeelist.template.file.path"
));
//Read File Content
String
content
=
new
String
(
Files
.
readAllBytes
(
file
.
toPath
()));
content
=
content
.
replaceAll
(
"employeeList"
,
exemptEmployeeRowsData
.
toString
());
System
.
out
.
println
(
content
);
helper
.
setTo
(
mail
.
getTo
());
helper
.
setText
(
content
,
true
);
helper
.
setSubject
(
mail
.
getSubject
());
helper
.
setFrom
(
mail
.
getFrom
());
helper
.
setCc
(
mail
.
getCc
());
//helper.setBcc(mail.getBcc());
if
(
exemptEmployeeRowsData
.
toString
()
!=
null
&&
!
exemptEmployeeRowsData
.
toString
().
isEmpty
())
{
emailSender
.
send
(
message
);
}
}
}
}
}
src/main/java/com/nisum/myteam/utils/MyTeamUtils.java
View file @
73a120f3
...
@@ -7,6 +7,7 @@ public class MyTeamUtils {
...
@@ -7,6 +7,7 @@ public class MyTeamUtils {
private
MyTeamUtils
()
{
private
MyTeamUtils
()
{
}
}
...
@@ -194,4 +195,14 @@ public class MyTeamUtils {
...
@@ -194,4 +195,14 @@ public class MyTeamUtils {
public
final
static
String
TEXT_DESIGNATIONS
=
"designations"
;
public
final
static
String
TEXT_DESIGNATIONS
=
"designations"
;
public
final
static
String
TEXT_ENABLE
=
"enable"
;
public
final
static
String
TEXT_ENABLE
=
"enable"
;
public
final
static
String
TEXT_DISABLE
=
"disable"
;
public
final
static
String
TEXT_DISABLE
=
"disable"
;
public
final
static
String
EMPLOYEE_LOGIN_DETAILS_QUERY
=
"SELECT top 30 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) " +
"ORDER BY pd.TransactionDateTime desc"
;
public
final
static
String
EMPLOYEE_LOGIN_DETAILS_QUERY_BY_DATES
=
"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 BETWEEN CONVERT(datetime,'%2$s') AND CONVERT(datetime,'%3$s') "
+
"ORDER BY pd.TransactionDateTime"
;
}
}
src/main/resources/application.properties
View file @
73a120f3
...
@@ -43,6 +43,7 @@ myTeam.data.mssqldb.password=admin@123
...
@@ -43,6 +43,7 @@ myTeam.data.mssqldb.password=admin@123
email.leave.notification.template.file.path
=
email/absentMailTemplate.html
email.leave.notification.template.file.path
=
email/absentMailTemplate.html
email.leave.notification.from
=
mytime.nisum@gmail.com
email.leave.notification.from
=
mytime.nisum@gmail.com
email.leave.notification.subject
=
Employee Leave Email Notification
email.leave.notification.subject
=
Employee Leave Email Notification
email.exempt.hours.employeelist.template.file.path
=
email/employeesExemptHours.html
#0 * * * * ?===>for every minute
#0 * * * * ?===>for every minute
...
@@ -67,6 +68,9 @@ email.project.notification.cron=00 00 15 * * 1-5
...
@@ -67,6 +68,9 @@ email.project.notification.cron=00 00 15 * * 1-5
email.workAnniversary.notification.from
=
mytime.nisum@gmail.com
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.subject
=
Happy Work Anniversary
email.workAnniversary.notification.cron
=
00 00 06 * * 1-7
email.workAnniversary.notification.cron
=
00 00 06 * * 1-7
...
...
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