Commit 0219d4d3 authored by Mahesh Mudrakola's avatar Mahesh Mudrakola

Export excel and pdf

parent ea70b142
......@@ -12,7 +12,7 @@ public interface AttendanceService {
List<AttendenceData> getAttendanciesReport(String reportDate,String shift) throws MyTimeException, SQLException;
String generatePdfReport(long id, String fromDate, String toDate, String fromTime, String toTime) throws MyTimeException;
List generatePdfReport(long id, String fromDate, String toDate, String fromTime, String toTime) throws MyTimeException;
List<EmpLoginData> employeeLoginReportBasedOnDateTime(long id, String fromDate,
String toDate,String fromTime,String toTime) throws MyTimeException, ParseException;
......
......@@ -61,7 +61,7 @@ public class AttendanceServiceImpl implements AttendanceService {
}
@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 {
return pdfReportGenerator.generateEmployeeReport(id, fromDate, toDate);
}
......
......@@ -100,7 +100,7 @@ public class ProjectServiceImpl implements ProjectService {
@Override
public String generatePdfReport(long id, String fromDate, String toDate) throws MyTimeException {
return pdfReportGenerator.generateEmployeeReport(id, fromDate, toDate);
return pdfReportGenerator.generateeReport(id, fromDate, toDate);
}
@Override
......@@ -771,7 +771,6 @@ public class ProjectServiceImpl implements ProjectService {
billingsSorted = (billings == null || billings.size() == 0) ? billings : billings.stream().sorted(
Comparator.comparing(BillingDetails::getCreateDate).reversed()).collect(Collectors.toList());
} catch (Exception e) {
// TODO: handle exception
}
return billingsSorted;
}
......@@ -784,7 +783,6 @@ public class ProjectServiceImpl implements ProjectService {
billingsSorted = (billings == null || billings.size() == 0) ? billings : billings.stream().sorted(
Comparator.comparing(BillingDetails::getCreateDate).reversed()).collect(Collectors.toList());
} catch (Exception e) {
// TODO: handle exception
}
return billingsSorted;
}
......@@ -801,7 +799,6 @@ public class ProjectServiceImpl implements ProjectService {
billingsSorted = (billings == null || billings.size() == 0) ? billings : billings.stream().sorted(
Comparator.comparing(BillingDetails::getBillingStartDate).reversed()).collect(Collectors.toList());
} catch (Exception e) {
// TODO: handle exception
}
return billingsSorted;
}
......@@ -818,7 +815,6 @@ public class ProjectServiceImpl implements ProjectService {
billingsSorted = (billings == null || billings.size() == 0) ? billings : billings.stream().sorted(
Comparator.comparing(BillingDetails::getBillingStartDate).reversed()).collect(Collectors.toList());
} catch (Exception e) {
// TODO: handle exception
}
return billingsSorted;
}
......
......@@ -56,6 +56,16 @@ public class PdfReportGenerator {
}
}
public String generateeReport(long employeeId, String startDate, String endDate) throws MyTimeException {
String fileName = employeeId + "_" + startDate + "_" + endDate + ".pdf";
List<EmpLoginData> empLoginDetails = getEmployeeData(employeeId, startDate, endDate);
if (empLoginDetails.isEmpty()) {
String message= "No data available";
return message;
} else {
return fileName;
}
}
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);
......
......@@ -55,7 +55,8 @@ public class AttendanceControllerTest {
@Test
public void testgeneratePdfReport() throws Exception {
when(userService.generatePdfReport(12345,"2017-11-18","2017-12-18")).thenReturn("empLoginDetails");
List list = new ArrayList();
when(userService.generatePdfReport(12345,"2017-11-18","2017-12-18")).thenReturn(list);
mockMvc.perform(get("/attendance/generatePdfReport/12345/2017-11-18/2017-12-18")).andExpect(MockMvcResultMatchers.status().isOk());
verify(userService).generatePdfReport(12345,"2017-11-18" , "2017-12-18");
}
......
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