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 {
}
@RequestMapping(value = "generatePdfReport/{id}/{fromDate}/{toDate}",
method = RequestMethod.GET, produces = MediaType.TEXT_PLAIN_VALUE)
public ResponseEntity<String> generatePdfReport(@PathVariable("id") long id,
method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List> generatePdfReport(@PathVariable("id") long id,
@PathVariable("fromDate") String fromDate,
@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);
}
@RequestMapping(value = "generatePdfReport/{id}/{fromDate}/{toDate}/{fromTime}/{toTime}",
method = RequestMethod.GET, produces = MediaType.TEXT_PLAIN_VALUE)
public ResponseEntity<String> generatePdfReport(@PathVariable("id") long id,
method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List> 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);
List result = userService.generatePdfReport(id, fromDate, toDate,fromTime,toTime);
return new ResponseEntity<>(result, HttpStatus.OK);
}
......
......@@ -33,10 +33,10 @@ public interface UserService {
EmployeeRoles assigingEmployeeRole(EmployeeRoles employeeRoles, String empId)
throws MyTimeException;
String generatePdfReport(long id, String fromDate, String toDate)
List generatePdfReport(long id, String fromDate, String toDate)
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;
EmployeeRoles getEmployeesRole(String emailId);
......
......@@ -128,13 +128,13 @@ public class UserServiceImpl implements UserService {
}
@Override
public String generatePdfReport(long id, String fromDate, String toDate)
public List generatePdfReport(long id, String fromDate, String toDate)
throws MyTimeException {
return pdfReportGenerator.generateEmployeeReport(id, fromDate, toDate);
}
@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 {
return pdfReportGenerator.generateEmployeeReport(id, fromDate, toDate,fromTime,toTime);
}
......
......@@ -3,6 +3,7 @@ package com.nisum.mytime.utils;
import java.io.File;
import java.io.FileOutputStream;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -39,23 +40,35 @@ public class PdfReportGenerator {
@Autowired
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";
List<EmpLoginData> empLoginDetails = getEmployeeData(employeeId, startDate, endDate);
List filenameData=new ArrayList<>();
if (empLoginDetails.isEmpty()) {
return "No data available";
} else {
return createPDF(fileName, empLoginDetails, employeeId);
}
String message= "No data available";
filenameData.add(message);
return filenameData;
} else {
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";
List<EmpLoginData> empLoginDetails = getEmployeeData(employeeId, startDate, endDate,fromTime,toTime);
List filenameData=new ArrayList<>();
if (empLoginDetails.isEmpty()) {
return "No data available";
String message= "No data available";
filenameData.add(message);
return filenameData;
} 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