Commit ea70b142 authored by Mahesh Mudrakola's avatar Mahesh Mudrakola

Export Excel and Pdf Feature enabled

parent 337099ad
...@@ -48,22 +48,22 @@ public class AttendanceController { ...@@ -48,22 +48,22 @@ public class AttendanceController {
} }
@RequestMapping(value = "generatePdfReport/{id}/{fromDate}/{toDate}", @RequestMapping(value = "generatePdfReport/{id}/{fromDate}/{toDate}",
method = RequestMethod.GET, produces = MediaType.TEXT_PLAIN_VALUE) method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<String> generatePdfReport(@PathVariable("id") long id, public ResponseEntity<List> generatePdfReport(@PathVariable("id") long id,
@PathVariable("fromDate") String fromDate, @PathVariable("fromDate") String fromDate,
@PathVariable("toDate") String toDate) throws MyTimeException { @PathVariable("toDate") String toDate) throws MyTimeException {
String result = userService.generatePdfReport(id, fromDate, toDate); List result = userService.generatePdfReport(id, fromDate, toDate);
return new ResponseEntity<>(result, HttpStatus.OK); return new ResponseEntity<>(result, HttpStatus.OK);
} }
@RequestMapping(value = "generatePdfReport/{id}/{fromDate}/{toDate}/{fromTime}/{toTime}", @RequestMapping(value = "generatePdfReport/{id}/{fromDate}/{toDate}/{fromTime}/{toTime}",
method = RequestMethod.GET, produces = MediaType.TEXT_PLAIN_VALUE) method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<String> generatePdfReport(@PathVariable("id") long id, public ResponseEntity<List> generatePdfReport(@PathVariable("id") long id,
@PathVariable("fromDate") String fromDate, @PathVariable("fromDate") String fromDate,
@PathVariable("toDate") String toDate, @PathVariable("toDate") String toDate,
@PathVariable("fromTime") String fromTime, @PathVariable("fromTime") String fromTime,
@PathVariable("toTime") String toTime) throws MyTimeException, ParseException { @PathVariable("toTime") String toTime) throws MyTimeException, ParseException {
String result = userService.generatePdfReport(id, fromDate, toDate,fromTime,toTime); List result = userService.generatePdfReport(id, fromDate, toDate,fromTime,toTime);
return new ResponseEntity<>(result, HttpStatus.OK); return new ResponseEntity<>(result, HttpStatus.OK);
} }
......
...@@ -33,10 +33,10 @@ public interface UserService { ...@@ -33,10 +33,10 @@ public interface UserService {
EmployeeRoles assigingEmployeeRole(EmployeeRoles employeeRoles, String empId) EmployeeRoles assigingEmployeeRole(EmployeeRoles employeeRoles, String empId)
throws MyTimeException; throws MyTimeException;
String generatePdfReport(long id, String fromDate, String toDate) List generatePdfReport(long id, String fromDate, String toDate)
throws MyTimeException; throws MyTimeException;
String generatePdfReport(long id, String fromDate, String toDate,String fromTime,String toTime) List generatePdfReport(long id, String fromDate, String toDate,String fromTime,String toTime)
throws MyTimeException, ParseException; throws MyTimeException, ParseException;
EmployeeRoles getEmployeesRole(String emailId); EmployeeRoles getEmployeesRole(String emailId);
......
...@@ -128,13 +128,13 @@ public class UserServiceImpl implements UserService { ...@@ -128,13 +128,13 @@ public class UserServiceImpl implements UserService {
} }
@Override @Override
public String generatePdfReport(long id, String fromDate, String toDate) public List generatePdfReport(long id, String fromDate, String toDate)
throws MyTimeException { throws MyTimeException {
return pdfReportGenerator.generateEmployeeReport(id, fromDate, toDate); return pdfReportGenerator.generateEmployeeReport(id, fromDate, toDate);
} }
@Override @Override
public String generatePdfReport(long id, String fromDate, String toDate,String fromTime,String toTime) public List generatePdfReport(long id, String fromDate, String toDate,String fromTime,String toTime)
throws MyTimeException, ParseException { throws MyTimeException, ParseException {
return pdfReportGenerator.generateEmployeeReport(id, fromDate, toDate,fromTime,toTime); return pdfReportGenerator.generateEmployeeReport(id, fromDate, toDate,fromTime,toTime);
} }
......
...@@ -3,6 +3,7 @@ package com.nisum.mytime.utils; ...@@ -3,6 +3,7 @@ package com.nisum.mytime.utils;
import java.io.File; import java.io.File;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.text.ParseException; import java.text.ParseException;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -39,23 +40,35 @@ public class PdfReportGenerator { ...@@ -39,23 +40,35 @@ public class PdfReportGenerator {
@Autowired @Autowired
private AttendanceService attendanceService; private AttendanceService attendanceService;
public String generateEmployeeReport(long employeeId, String startDate, String endDate) throws MyTimeException { public List generateEmployeeReport(long employeeId, String startDate, String endDate) throws MyTimeException {
String fileName = employeeId + "_" + startDate + "_" + endDate + ".pdf"; String fileName = employeeId + "_" + startDate + "_" + endDate + ".pdf";
List<EmpLoginData> empLoginDetails = getEmployeeData(employeeId, startDate, endDate); List<EmpLoginData> empLoginDetails = getEmployeeData(employeeId, startDate, endDate);
List filenameData=new ArrayList<>();
if (empLoginDetails.isEmpty()) { if (empLoginDetails.isEmpty()) {
return "No data available"; String message= "No data available";
filenameData.add(message);
return filenameData;
} else { } else {
return createPDF(fileName, empLoginDetails, employeeId); String file= createPDF(fileName, empLoginDetails, employeeId);
filenameData.add(file);
filenameData.add(empLoginDetails);
return filenameData;
} }
} }
public String generateEmployeeReport(long employeeId, String startDate, String endDate,String fromTime,String toTime) throws MyTimeException, ParseException { public List generateEmployeeReport(long employeeId, String startDate, String endDate,String fromTime,String toTime) throws MyTimeException, ParseException {
String fileName = employeeId + "_" + startDate + "_" + endDate + ".pdf"; String fileName = employeeId + "_" + startDate + "_" + endDate + ".pdf";
List<EmpLoginData> empLoginDetails = getEmployeeData(employeeId, startDate, endDate,fromTime,toTime); List<EmpLoginData> empLoginDetails = getEmployeeData(employeeId, startDate, endDate,fromTime,toTime);
List filenameData=new ArrayList<>();
if (empLoginDetails.isEmpty()) { if (empLoginDetails.isEmpty()) {
return "No data available"; String message= "No data available";
filenameData.add(message);
return filenameData;
} else { } else {
return createPDF(fileName, empLoginDetails, employeeId); String file= createPDF(fileName, empLoginDetails, employeeId);
filenameData.add(file);
filenameData.add(empLoginDetails);
return filenameData;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment