|
|
@ -2,6 +2,8 @@ package com.gcc.commissionerreview.service; |
|
|
|
|
|
|
|
|
import javax.sql.DataSource; |
|
|
import javax.sql.DataSource; |
|
|
|
|
|
|
|
|
|
|
|
import org.slf4j.Logger; |
|
|
|
|
|
import org.slf4j.LoggerFactory; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.beans.factory.annotation.Qualifier; |
|
|
import org.springframework.beans.factory.annotation.Qualifier; |
|
|
import org.springframework.jdbc.core.JdbcTemplate; |
|
|
import org.springframework.jdbc.core.JdbcTemplate; |
|
|
@ -9,7 +11,9 @@ import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
|
import java.sql.Date; |
|
|
import java.sql.Date; |
|
|
import java.time.LocalDate; |
|
|
import java.time.LocalDate; |
|
|
|
|
|
import java.time.LocalDateTime; |
|
|
import java.time.format.DateTimeFormatter; |
|
|
import java.time.format.DateTimeFormatter; |
|
|
|
|
|
import java.util.Collections; |
|
|
import java.util.List; |
|
|
import java.util.List; |
|
|
import java.util.Locale; |
|
|
import java.util.Locale; |
|
|
import java.util.Map; |
|
|
import java.util.Map; |
|
|
@ -17,17 +21,25 @@ import java.util.Map; |
|
|
@Service |
|
|
@Service |
|
|
public class AttendanceService { |
|
|
public class AttendanceService { |
|
|
|
|
|
|
|
|
|
|
|
private static final Logger logger = LoggerFactory.getLogger(AttendanceService.class); |
|
|
|
|
|
|
|
|
@Autowired |
|
|
@Autowired |
|
|
private JdbcTemplate jdbcTemplate; |
|
|
private JdbcTemplate jdbcTemplate; |
|
|
|
|
|
|
|
|
@Autowired |
|
|
@Autowired |
|
|
public void setDataSource(@Qualifier("mysqlNULMDataSource") DataSource dataSource) { |
|
|
public void setDataSource(@Qualifier("mysqlNULMDataSource") DataSource dataSource) { |
|
|
|
|
|
try { |
|
|
this.jdbcTemplate = new JdbcTemplate(dataSource); |
|
|
this.jdbcTemplate = new JdbcTemplate(dataSource); |
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
logger.error("Method: setDataSource | Parameters: dataSource={} | Date: {} | Exception: {} - {}", |
|
|
|
|
|
dataSource, LocalDateTime.now(), e.getClass().getName(), e.getMessage(), e); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private static final DateTimeFormatter INPUT_FORMAT = DateTimeFormatter.ofPattern("dd-MM-yyyy", Locale.ENGLISH); |
|
|
private static final DateTimeFormatter INPUT_FORMAT = DateTimeFormatter.ofPattern("dd-MM-yyyy", Locale.ENGLISH); |
|
|
|
|
|
|
|
|
public List<Map<String, Object>> getAbstractCounts() { |
|
|
public List<Map<String, Object>> getAbstractCounts() { |
|
|
|
|
|
try { |
|
|
String sql = "SELECT emp_type, COUNT(enrollment_id) AS totalCount, " |
|
|
String sql = "SELECT emp_type, COUNT(enrollment_id) AS totalCount, " |
|
|
+ "SUM(CASE WHEN facial_attendance = 1 THEN 1 ELSE 0 END) AS facialRegistered, " |
|
|
+ "SUM(CASE WHEN facial_attendance = 1 THEN 1 ELSE 0 END) AS facialRegistered, " |
|
|
+ "SUM(CASE WHEN facial_attendance = 0 THEN 1 ELSE 0 END) AS facialNotRegistered " |
|
|
+ "SUM(CASE WHEN facial_attendance = 0 THEN 1 ELSE 0 END) AS facialNotRegistered " |
|
|
@ -36,9 +48,15 @@ public class AttendanceService { |
|
|
+ "GROUP BY emp_type"; |
|
|
+ "GROUP BY emp_type"; |
|
|
|
|
|
|
|
|
return jdbcTemplate.queryForList(sql); |
|
|
return jdbcTemplate.queryForList(sql); |
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
logger.error("Method: getAbstractCounts | Parameters: none | Date: {} | Exception: {} - {}", |
|
|
|
|
|
LocalDateTime.now(), e.getClass().getName(), e.getMessage(), e); |
|
|
|
|
|
return Collections.emptyList(); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public List<Map<String, Object>> getZoneWisePercentage(String fromDateStr, String toDateStr) { |
|
|
public List<Map<String, Object>> getZoneWisePercentage(String fromDateStr, String toDateStr) { |
|
|
|
|
|
try { |
|
|
LocalDate fromDate; |
|
|
LocalDate fromDate; |
|
|
LocalDate toDate; |
|
|
LocalDate toDate; |
|
|
|
|
|
|
|
|
@ -89,9 +107,16 @@ public class AttendanceService { |
|
|
return jdbcTemplate.queryForList(sql, new Object[] { |
|
|
return jdbcTemplate.queryForList(sql, new Object[] { |
|
|
fromDateFormatted, toDateFormatted, |
|
|
fromDateFormatted, toDateFormatted, |
|
|
fromDateFormatted, toDateFormatted }); |
|
|
fromDateFormatted, toDateFormatted }); |
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
logger.error( |
|
|
|
|
|
"Method: getZoneWisePercentage | Parameters: fromDateStr={}, toDateStr={} | Date: {} | Exception: {} - {}", |
|
|
|
|
|
fromDateStr, toDateStr, LocalDateTime.now(), e.getClass().getName(), e.getMessage(), e); |
|
|
|
|
|
return Collections.emptyList(); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public List<Map<String, Object>> getZoneSummary(String empType, String fromDateStr, String toDateStr) { |
|
|
public List<Map<String, Object>> getZoneSummary(String empType, String fromDateStr, String toDateStr) { |
|
|
|
|
|
try { |
|
|
LocalDate fromDate; |
|
|
LocalDate fromDate; |
|
|
LocalDate toDate; |
|
|
LocalDate toDate; |
|
|
|
|
|
|
|
|
@ -138,10 +163,17 @@ public class AttendanceService { |
|
|
|
|
|
|
|
|
return jdbcTemplate.queryForList(sql, new Object[] { empType, fromDateTime, toDateTime, fromDateTime, |
|
|
return jdbcTemplate.queryForList(sql, new Object[] { empType, fromDateTime, toDateTime, fromDateTime, |
|
|
toDateTime, fromDateTime, toDateTime, empType }); |
|
|
toDateTime, fromDateTime, toDateTime, empType }); |
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
logger.error( |
|
|
|
|
|
"Method: getZoneSummary | Parameters: empType={}, fromDateStr={}, toDateStr={} | Date: {} | Exception: {} - {}", |
|
|
|
|
|
empType, fromDateStr, toDateStr, LocalDateTime.now(), e.getClass().getName(), e.getMessage(), e); |
|
|
|
|
|
return Collections.emptyList(); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public List<Map<String, Object>> getDetailedList(String empType, String category, String fromDateStr, |
|
|
public List<Map<String, Object>> getDetailedList(String empType, String category, String fromDateStr, |
|
|
String toDateStr, Integer zone, String parkName) { |
|
|
String toDateStr, Integer zone, String parkName) { |
|
|
|
|
|
try { |
|
|
LocalDate fromDate; |
|
|
LocalDate fromDate; |
|
|
LocalDate toDate; |
|
|
LocalDate toDate; |
|
|
|
|
|
|
|
|
@ -196,7 +228,8 @@ public class AttendanceService { |
|
|
|
|
|
|
|
|
// sql += " order by " + dateColumn + " desc "; |
|
|
// sql += " order by " + dateColumn + " desc "; |
|
|
|
|
|
|
|
|
System.out.println("EmpType: " + empType + ", Category: " + category + ", From: " + fromDateTime + ", To: " |
|
|
|
|
|
|
|
|
System.out.println( |
|
|
|
|
|
"EmpType: " + empType + ", Category: " + category + ", From: " + fromDateTime + ", To: " |
|
|
+ toDateTime + ", Zone: " + zone + ", ParkName: " + parkName); |
|
|
+ toDateTime + ", Zone: " + zone + ", ParkName: " + parkName); |
|
|
return jdbcTemplate.queryForList(sql, params.toArray()); |
|
|
return jdbcTemplate.queryForList(sql, params.toArray()); |
|
|
} else if (category != null && category.equals("notregistered")) { |
|
|
} else if (category != null && category.equals("notregistered")) { |
|
|
@ -222,7 +255,8 @@ public class AttendanceService { |
|
|
|
|
|
|
|
|
// sql += " order by " + dateColumn + " desc "; |
|
|
// sql += " order by " + dateColumn + " desc "; |
|
|
|
|
|
|
|
|
System.out.println("EmpType: " + empType + ", Category: " + category + ", From: " + fromDateTime + ", To: " |
|
|
|
|
|
|
|
|
System.out.println( |
|
|
|
|
|
"EmpType: " + empType + ", Category: " + category + ", From: " + fromDateTime + ", To: " |
|
|
+ toDateTime + ", Zone: " + zone + ", ParkName: " + parkName); |
|
|
+ toDateTime + ", Zone: " + zone + ", ParkName: " + parkName); |
|
|
return jdbcTemplate.queryForList(sql, params.toArray()); |
|
|
return jdbcTemplate.queryForList(sql, params.toArray()); |
|
|
|
|
|
|
|
|
@ -311,13 +345,22 @@ public class AttendanceService { |
|
|
|
|
|
|
|
|
sql += " order by " + dateColumn + " desc "; |
|
|
sql += " order by " + dateColumn + " desc "; |
|
|
|
|
|
|
|
|
System.out.println("EmpType: " + empType + ", Category: " + category + ", From: " + fromDateTime + ", To: " |
|
|
|
|
|
|
|
|
System.out.println( |
|
|
|
|
|
"EmpType: " + empType + ", Category: " + category + ", From: " + fromDateTime + ", To: " |
|
|
+ toDateTime + ", Zone: " + zone + ", ParkName: " + parkName); |
|
|
+ toDateTime + ", Zone: " + zone + ", ParkName: " + parkName); |
|
|
return jdbcTemplate.queryForList(sql, params.toArray()); |
|
|
return jdbcTemplate.queryForList(sql, params.toArray()); |
|
|
} |
|
|
} |
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
logger.error( |
|
|
|
|
|
"Method: getDetailedList | Parameters: empType={}, category={}, fromDateStr={}, toDateStr={}, zone={}, parkName={} | Date: {} | Exception: {} - {}", |
|
|
|
|
|
empType, category, fromDateStr, toDateStr, zone, parkName, LocalDateTime.now(), |
|
|
|
|
|
e.getClass().getName(), e.getMessage(), e); |
|
|
|
|
|
return Collections.emptyList(); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public List<Map<String, Object>> getParkWiseSummary(String fromDateStr, String toDateStr, Integer zone) { |
|
|
public List<Map<String, Object>> getParkWiseSummary(String fromDateStr, String toDateStr, Integer zone) { |
|
|
|
|
|
try { |
|
|
LocalDate fromDate; |
|
|
LocalDate fromDate; |
|
|
LocalDate toDate; |
|
|
LocalDate toDate; |
|
|
|
|
|
|
|
|
@ -362,7 +405,14 @@ public class AttendanceService { |
|
|
+ "GROUP BY et.park_id, pd.park_name, pd.supervisor_name, pd.supervisor_mobile, fd.facialRegistered, fd.facialNotRegistered " |
|
|
+ "GROUP BY et.park_id, pd.park_name, pd.supervisor_name, pd.supervisor_mobile, fd.facialRegistered, fd.facialNotRegistered " |
|
|
+ "ORDER BY pd.park_name"; |
|
|
+ "ORDER BY pd.park_name"; |
|
|
|
|
|
|
|
|
return jdbcTemplate.queryForList(sql, new Object[] { zone, fromDateTime, toDateTime, fromDateTime, toDateTime, |
|
|
|
|
|
|
|
|
return jdbcTemplate.queryForList(sql, |
|
|
|
|
|
new Object[] { zone, fromDateTime, toDateTime, fromDateTime, toDateTime, |
|
|
fromDateTime, toDateTime, zone }); |
|
|
fromDateTime, toDateTime, zone }); |
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
logger.error( |
|
|
|
|
|
"Method: getParkWiseSummary | Parameters: fromDateStr={}, toDateStr={}, zone={} | Date: {} | Exception: {} - {}", |
|
|
|
|
|
fromDateStr, toDateStr, zone, LocalDateTime.now(), e.getClass().getName(), e.getMessage(), e); |
|
|
|
|
|
return Collections.emptyList(); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |