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

Export excel and pdf

parent ea70b142
...@@ -12,7 +12,7 @@ public interface AttendanceService { ...@@ -12,7 +12,7 @@ public interface AttendanceService {
List<AttendenceData> getAttendanciesReport(String reportDate,String shift) throws MyTimeException, SQLException; 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, List<EmpLoginData> employeeLoginReportBasedOnDateTime(long id, String fromDate,
String toDate,String fromTime,String toTime) throws MyTimeException, ParseException; String toDate,String fromTime,String toTime) throws MyTimeException, ParseException;
......
...@@ -61,8 +61,8 @@ public class AttendanceServiceImpl implements AttendanceService { ...@@ -61,8 +61,8 @@ public class AttendanceServiceImpl implements AttendanceService {
} }
@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 { throws MyTimeException {
return pdfReportGenerator.generateEmployeeReport(id, fromDate, toDate); return pdfReportGenerator.generateEmployeeReport(id, fromDate, toDate);
} }
......
...@@ -100,7 +100,7 @@ public class ProjectServiceImpl implements ProjectService { ...@@ -100,7 +100,7 @@ public class ProjectServiceImpl implements ProjectService {
@Override @Override
public String generatePdfReport(long id, String fromDate, String toDate) throws MyTimeException { public String generatePdfReport(long id, String fromDate, String toDate) throws MyTimeException {
return pdfReportGenerator.generateEmployeeReport(id, fromDate, toDate); return pdfReportGenerator.generateeReport(id, fromDate, toDate);
} }
@Override @Override
...@@ -771,8 +771,7 @@ public class ProjectServiceImpl implements ProjectService { ...@@ -771,8 +771,7 @@ public class ProjectServiceImpl implements ProjectService {
billingsSorted = (billings == null || billings.size() == 0) ? billings : billings.stream().sorted( billingsSorted = (billings == null || billings.size() == 0) ? billings : billings.stream().sorted(
Comparator.comparing(BillingDetails::getCreateDate).reversed()).collect(Collectors.toList()); Comparator.comparing(BillingDetails::getCreateDate).reversed()).collect(Collectors.toList());
} catch (Exception e) { } catch (Exception e) {
// TODO: handle exception }
}
return billingsSorted; return billingsSorted;
} }
...@@ -784,7 +783,6 @@ public class ProjectServiceImpl implements ProjectService { ...@@ -784,7 +783,6 @@ public class ProjectServiceImpl implements ProjectService {
billingsSorted = (billings == null || billings.size() == 0) ? billings : billings.stream().sorted( billingsSorted = (billings == null || billings.size() == 0) ? billings : billings.stream().sorted(
Comparator.comparing(BillingDetails::getCreateDate).reversed()).collect(Collectors.toList()); Comparator.comparing(BillingDetails::getCreateDate).reversed()).collect(Collectors.toList());
} catch (Exception e) { } catch (Exception e) {
// TODO: handle exception
} }
return billingsSorted; return billingsSorted;
} }
...@@ -801,7 +799,6 @@ public class ProjectServiceImpl implements ProjectService { ...@@ -801,7 +799,6 @@ public class ProjectServiceImpl implements ProjectService {
billingsSorted = (billings == null || billings.size() == 0) ? billings : billings.stream().sorted( billingsSorted = (billings == null || billings.size() == 0) ? billings : billings.stream().sorted(
Comparator.comparing(BillingDetails::getBillingStartDate).reversed()).collect(Collectors.toList()); Comparator.comparing(BillingDetails::getBillingStartDate).reversed()).collect(Collectors.toList());
} catch (Exception e) { } catch (Exception e) {
// TODO: handle exception
} }
return billingsSorted; return billingsSorted;
} }
...@@ -818,7 +815,6 @@ public class ProjectServiceImpl implements ProjectService { ...@@ -818,7 +815,6 @@ public class ProjectServiceImpl implements ProjectService {
billingsSorted = (billings == null || billings.size() == 0) ? billings : billings.stream().sorted( billingsSorted = (billings == null || billings.size() == 0) ? billings : billings.stream().sorted(
Comparator.comparing(BillingDetails::getBillingStartDate).reversed()).collect(Collectors.toList()); Comparator.comparing(BillingDetails::getBillingStartDate).reversed()).collect(Collectors.toList());
} catch (Exception e) { } catch (Exception e) {
// TODO: handle exception
} }
return billingsSorted; return billingsSorted;
} }
......
...@@ -56,6 +56,16 @@ public class PdfReportGenerator { ...@@ -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 { 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);
......
...@@ -55,7 +55,8 @@ public class AttendanceControllerTest { ...@@ -55,7 +55,8 @@ public class AttendanceControllerTest {
@Test @Test
public void testgeneratePdfReport() throws Exception { 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()); 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"); 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