Unverified Commit 47402225 authored by mshaik-nisum-com's avatar mshaik-nisum-com Committed by GitHub

Merge pull request #180 from nisum-inc/FEATURE/Login_Report_Based_On_Date_Time

MT-175:Login Report Based on Date and Time
parents 915e62a3 2ec35378
package com.nisum.mytime.service;
import java.sql.SQLException;
import java.text.ParseException;
import java.util.List;
import com.nisum.mytime.exception.handler.MyTimeException;
......@@ -14,5 +15,5 @@ public interface AttendanceService {
String 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;
String toDate,String fromTime,String toTime) throws MyTimeException, ParseException;
}
......@@ -3,8 +3,13 @@ package com.nisum.mytime.service;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
......@@ -45,20 +50,38 @@ public class AttendanceServiceImpl implements AttendanceService {
MyTimeLogger.getInstance().info("Time Taken for " + (System.currentTimeMillis() - start_ms));
return listOfEmployees;
}
@Override
public List<EmpLoginData> employeeLoginReportBasedOnDateTime(long id, String fromDate, String toDate,String fromTime,String toTime) throws MyTimeException {
@Override
public List<EmpLoginData> employeeLoginReportBasedOnDateTime(long id, String fromDate, String toDate,String fromTime,String toTime) throws MyTimeException, ParseException {
String timeSignFrom=fromTime.substring(7,9);
String timeSignTo=toTime.substring(7,9);
//Getting Sign AM/PM of Time
String timeSignFrom=fromTime.substring(6,8);
String timeSignTo=toTime.substring(6,8);
int from=Integer.parseInt(fromTime.substring(0,2));
int to=Integer.parseInt(toTime.substring(0,2));
String nextDate=fromDate;
if(to<from) {
LocalDate newtoDate = LocalDate.parse(toDate).plusDays(1);
// Converting the Time from 12 Hours to 24 Hours Format
SimpleDateFormat displayFormat = new SimpleDateFormat("HH:mm");
SimpleDateFormat parseFormat = new SimpleDateFormat("hh:mm a");
// Given Format
Date from = parseFormat.parse(fromTime);
Date to = parseFormat.parse(toTime);
//Required Format
String timeFrom=displayFormat.format(from);
String timeTo=displayFormat.format(to);
//Getting Hours from Time
String nextDate=fromDate;
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");
LocalDate newtoDate = (LocalDate.parse(fromDate,formatter)).plusDays(1);
nextDate=newtoDate.toString();
}
return employeeDataBaseService.fetchEmployeeLoginsBasedOnDates1(id, fromDate,nextDate, toDate);
nextDate=nextDate.replace("-", "/");
}
return employeeDataBaseService.fetchEmployeeLoginsBasedOnDatesTime(id, fromDate,nextDate, toDate,timeFrom,timeTo);
}
@Override
......
......@@ -100,6 +100,14 @@ public class MyTimeUtils {
public final static String ALL = "All";
public final static String SHIFT = "Shift";
public final static String LOGIN_REPORT_BY_TIME="select emp.EmployeeCode,emp.FirstName,MIN(tr.aDateTime) AS FirstLogin,MAX(tr.aDateTime) AS LastLogin \n" +
" from [smartiSCC].[dbo].[Transactions] as tr,[smartiSCC].[dbo].[EmployeeMaster] as emp \n" +
" where tr.EmployeemasterID=emp.EmployeeMasterID and \n" +
" tr.aDateTime >= ";
public final static String LOGIN_REPORT_BY_TIME2 =" and tr.aDateTime<= ";
public final static String LOGIN_REPORT_BY_TIME3=" and emp.EmployeeCode = ";
public final static String LOGIN_REPORT_BY_TIME4=" group by emp.EmployeeCode, emp.FirstName ";
// Role Mapping Info
public static final String ACCOUNT = "Delivery Manager";
public static final String DOMAIN = "Delivery Lead";
......
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