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
324a252b
Unverified
Commit
324a252b
authored
Sep 05, 2018
by
mshaik-nisum-com
Committed by
GitHub
Sep 05, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #182 from nisum-inc/FEATURE/Get_LoginReport_Based_On_DateTime
MT-175:Login Report Based On Selected Time and Date
parents
856aa6c9
337f8970
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
108 additions
and
87 deletions
+108
-87
AttendanceController.java
...ava/com/nisum/mytime/controller/AttendanceController.java
+12
-18
AttendanceServiceImpl.java
.../java/com/nisum/mytime/service/AttendanceServiceImpl.java
+3
-6
EmployeeDataService.java
...in/java/com/nisum/mytime/service/EmployeeDataService.java
+58
-59
UserService.java
src/main/java/com/nisum/mytime/service/UserService.java
+4
-0
UserServiceImpl.java
src/main/java/com/nisum/mytime/service/UserServiceImpl.java
+8
-1
PdfReportGenerator.java
src/main/java/com/nisum/mytime/utils/PdfReportGenerator.java
+21
-1
ReportsController.js
src/main/webapp/WEB-INF/controllers/ReportsController.js
+2
-2
No files found.
src/main/java/com/nisum/mytime/controller/AttendanceController.java
View file @
324a252b
package
com
.
nisum
.
mytime
.
controller
;
import
java.sql.SQLException
;
import
java.text.ParseException
;
import
java.util.ArrayList
;
import
java.util.List
;
...
...
@@ -46,24 +47,6 @@ public class AttendanceController {
return
new
ResponseEntity
<>(
message
,
HttpStatus
.
OK
);
}
@RequestMapping
(
value
=
"employeeLoginReportBasedOnDateTime"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
ResponseEntity
<
List
<
EmpLoginData
>>
employeeLoginReportBasedOnDateTime
(
@RequestParam
(
"empId"
)
long
id
,
@RequestParam
(
"fromDate"
)
String
fromDate
,
@RequestParam
(
"toDate"
)
String
toDate
,
@RequestParam
(
"fromTime"
)
String
fromTime
,
@RequestParam
(
"toTime"
)
String
toTime
)
throws
MyTimeException
{
List
<
EmpLoginData
>
message
=
new
ArrayList
<>();
try
{
message
=
attendanceService
.
employeeLoginReportBasedOnDateTime
(
id
,
fromDate
,
toDate
,
fromTime
,
toTime
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
new
ResponseEntity
<>(
message
,
HttpStatus
.
OK
);
}
@RequestMapping
(
value
=
"generatePdfReport/{id}/{fromDate}/{toDate}"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
TEXT_PLAIN_VALUE
)
public
ResponseEntity
<
String
>
generatePdfReport
(
@PathVariable
(
"id"
)
long
id
,
...
...
@@ -73,6 +56,17 @@ public class AttendanceController {
return
new
ResponseEntity
<>(
result
,
HttpStatus
.
OK
);
}
@RequestMapping
(
value
=
"generatePdfReport/{id}/{fromDate}/{toDate}/{fromTime}/{toTime}"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
TEXT_PLAIN_VALUE
)
public
ResponseEntity
<
String
>
generatePdfReport
(
@PathVariable
(
"id"
)
long
id
,
@PathVariable
(
"fromDate"
)
String
fromDate
,
@PathVariable
(
"toDate"
)
String
toDate
,
@PathVariable
(
"fromTime"
)
String
fromTime
,
@PathVariable
(
"toTime"
)
String
toTime
)
throws
MyTimeException
,
ParseException
{
String
result
=
userService
.
generatePdfReport
(
id
,
fromDate
,
toDate
,
fromTime
,
toTime
);
return
new
ResponseEntity
<>(
result
,
HttpStatus
.
OK
);
}
@RequestMapping
(
value
=
"attendanciesReport/{reportDate}"
,
method
=
RequestMethod
.
GET
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
...
...
src/main/java/com/nisum/mytime/service/AttendanceServiceImpl.java
View file @
324a252b
...
...
@@ -75,15 +75,12 @@ public class AttendanceServiceImpl implements AttendanceService {
int
hoursFrom
=
Integer
.
parseInt
(
timeFrom
.
substring
(
0
,
2
));
int
hoursTo
=
Integer
.
parseInt
(
timeTo
.
substring
(
0
,
2
));
if
(
hoursTo
<=
hoursFrom
&&
timeSignFrom
.
equals
(
timeSignTo
)
||
hoursTo
<=
hoursFrom
)
{
DateTimeFormatter
formatter
=
DateTimeFormatter
.
ofPattern
(
"yyyy
/MM/
d"
);
DateTimeFormatter
formatter
=
DateTimeFormatter
.
ofPattern
(
"yyyy
-MM-
d"
);
LocalDate
newtoDate
=
(
LocalDate
.
parse
(
fromDate
,
formatter
)).
plusDays
(
1
);
nextDate
=
newtoDate
.
toString
();
nextDate
=
nextDate
.
replace
(
"-"
,
"/"
);
}
return
employeeDataBaseService
.
fetchEmployeeLoginsBasedOnDatesTime
(
id
,
fromDate
,
nextDate
,
toDate
,
timeFrom
,
timeTo
);
}
@Override
public
String
generatePdfReport
(
long
id
,
String
fromDate
,
String
toDate
,
String
fromTime
,
String
toTime
)
throws
MyTimeException
{
...
...
src/main/java/com/nisum/mytime/service/EmployeeDataService.java
View file @
324a252b
...
...
@@ -87,7 +87,7 @@ public class EmployeeDataService {
}
public
List
<
EmpLoginData
>
fetchEmployeeLoginsBasedOnDatesTime
(
long
employeeId
,
String
fromDate
,
String
nextDate
,
String
toDate
,
String
fromTime
,
String
toTime
)
throws
MyTimeException
{
DateTimeFormatter
formatter
=
DateTimeFormatter
.
ofPattern
(
"yyyy/MM/
dd"
);
DateTimeFormatter
formatter
=
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-
dd"
);
LocalDate
formatedFromDate
=
LocalDate
.
parse
(
fromDate
,
formatter
);
LocalDate
formatedNextDate
=
LocalDate
.
parse
(
nextDate
,
formatter
);
LocalDate
formatedToDate
=
LocalDate
.
parse
(
toDate
,
formatter
);
...
...
@@ -148,5 +148,4 @@ public class EmployeeDataService {
}
return
listOfEmpLoginData
;
}
}
\ No newline at end of file
src/main/java/com/nisum/mytime/service/UserService.java
View file @
324a252b
package
com
.
nisum
.
mytime
.
service
;
import
java.text.ParseException
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
...
...
@@ -35,6 +36,9 @@ public interface UserService {
String
generatePdfReport
(
long
id
,
String
fromDate
,
String
toDate
)
throws
MyTimeException
;
String
generatePdfReport
(
long
id
,
String
fromDate
,
String
toDate
,
String
fromTime
,
String
toTime
)
throws
MyTimeException
,
ParseException
;
EmployeeRoles
getEmployeesRole
(
String
emailId
);
void
deleteEmployee
(
String
empId
);
...
...
src/main/java/com/nisum/mytime/service/UserServiceImpl.java
View file @
324a252b
package
com
.
nisum
.
mytime
.
service
;
import
java.text.ParseException
;
import
java.util.ArrayList
;
import
java.util.Calendar
;
import
java.util.Comparator
;
...
...
@@ -133,6 +134,12 @@ public class UserServiceImpl implements UserService {
return
pdfReportGenerator
.
generateEmployeeReport
(
id
,
fromDate
,
toDate
);
}
@Override
public
String
generatePdfReport
(
long
id
,
String
fromDate
,
String
toDate
,
String
fromTime
,
String
toTime
)
throws
MyTimeException
,
ParseException
{
return
pdfReportGenerator
.
generateEmployeeReport
(
id
,
fromDate
,
toDate
,
fromTime
,
toTime
);
}
@Override
public
List
<
EmployeeRoles
>
getEmployeeRoles
()
throws
MyTimeException
{
//return employeeRolesRepo.findAll();
...
...
src/main/java/com/nisum/mytime/utils/PdfReportGenerator.java
View file @
324a252b
...
...
@@ -2,6 +2,7 @@ package com.nisum.mytime.utils;
import
java.io.File
;
import
java.io.FileOutputStream
;
import
java.text.ParseException
;
import
java.util.List
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -23,6 +24,7 @@ import com.itextpdf.text.pdf.PdfPTable;
import
com.itextpdf.text.pdf.PdfWriter
;
import
com.nisum.mytime.exception.handler.MyTimeException
;
import
com.nisum.mytime.model.EmpLoginData
;
import
com.nisum.mytime.service.AttendanceService
;
import
com.nisum.mytime.service.EmployeeDataService
;
@Component
...
...
@@ -34,6 +36,9 @@ public class PdfReportGenerator {
@Autowired
private
EmployeeDataService
employeeDataBaseService
;
@Autowired
private
AttendanceService
attendanceService
;
public
String
generateEmployeeReport
(
long
employeeId
,
String
startDate
,
String
endDate
)
throws
MyTimeException
{
String
fileName
=
employeeId
+
"_"
+
startDate
+
"_"
+
endDate
+
".pdf"
;
List
<
EmpLoginData
>
empLoginDetails
=
getEmployeeData
(
employeeId
,
startDate
,
endDate
);
...
...
@@ -44,11 +49,26 @@ public class PdfReportGenerator {
}
}
public
String
generateEmployeeReport
(
long
employeeId
,
String
startDate
,
String
endDate
,
String
fromTime
,
String
toTime
)
throws
MyTimeException
,
ParseException
{
String
fileName
=
employeeId
+
"_"
+
startDate
+
"_"
+
endDate
+
".pdf"
;
List
<
EmpLoginData
>
empLoginDetails
=
getEmployeeData
(
employeeId
,
startDate
,
endDate
,
fromTime
,
toTime
);
if
(
empLoginDetails
.
isEmpty
())
{
return
"No data available"
;
}
else
{
return
createPDF
(
fileName
,
empLoginDetails
,
employeeId
);
}
}
private
List
<
EmpLoginData
>
getEmployeeData
(
long
employeeId
,
String
fromDate
,
String
toDate
)
throws
MyTimeException
{
return
employeeDataBaseService
.
fetchEmployeeLoginsBasedOnDates
(
employeeId
,
fromDate
,
toDate
);
}
private
List
<
EmpLoginData
>
getEmployeeData
(
long
employeeId
,
String
fromDate
,
String
toDate
,
String
fromTime
,
String
toTime
)
throws
MyTimeException
,
ParseException
{
return
attendanceService
.
employeeLoginReportBasedOnDateTime
(
employeeId
,
fromDate
,
toDate
,
fromTime
,
toTime
);
}
private
String
createPDF
(
String
pdfFilename
,
List
<
EmpLoginData
>
empLoginDatas
,
long
employeeId
)
throws
MyTimeException
{
Document
doc
=
null
;
...
...
src/main/webapp/WEB-INF/controllers/ReportsController.js
View file @
324a252b
...
...
@@ -200,7 +200,7 @@ myApp.controller("reportsController", function($scope, $http, myFactory, $mdDial
empId
=
data
.
empId
;
}
var
defaultURL
=
appConfig
.
appUri
+
"attendance/generatePdfReport/"
+
empId
+
"/"
+
data
.
fromDate
+
"/"
+
data
.
toDate
;
var
overrideURL
=
appConfig
.
appUri
+
"attendance/
employeeLoginReportBasedOnDateTime?empId="
+
empId
+
"&fromDate="
+
data
.
fromDate
+
"&toDate="
+
data
.
toDate
+
"&fromTime="
+
data
.
fromTime
+
"&toTime=
"
+
data
.
toTime
;
var
overrideURL
=
appConfig
.
appUri
+
"attendance/
generatePdfReport/"
+
empId
+
"/"
+
data
.
fromDate
+
"/"
+
data
.
toDate
+
"/"
+
data
.
fromTime
+
"/
"
+
data
.
toTime
;
var
url
=
data
.
isOverride
?
overrideURL
:
defaultURL
;
$http
({
method
:
"GET"
,
...
...
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