From 780731a031cab44693da7d2eb48dd8ed9f202e24 Mon Sep 17 00:00:00 2001 From: kanimozhi Date: Tue, 10 Feb 2026 11:51:20 +0530 Subject: [PATCH] Attendance Dashboard - Park wise summary added --- .../controller/AttendanceController.java | 17 +- .../service/AttendanceService.java | 46 +- .../modules/attendance-dashboard.html | 725 +++++++++++------- 3 files changed, 491 insertions(+), 297 deletions(-) diff --git a/src/main/java/com/gcc/commissionerreview/controller/AttendanceController.java b/src/main/java/com/gcc/commissionerreview/controller/AttendanceController.java index 65db546..1e0afd4 100644 --- a/src/main/java/com/gcc/commissionerreview/controller/AttendanceController.java +++ b/src/main/java/com/gcc/commissionerreview/controller/AttendanceController.java @@ -53,19 +53,30 @@ public class AttendanceController { return result; } + @GetMapping("/parkWiseSummary") + public List> getParkWiseSummary( + @RequestParam(name = "fromDate", required = false) String fromDate, + @RequestParam(name = "toDate", required = false) String toDate, + @RequestParam(name = "zone", required = false) Integer zone) { + List> result = attendanceService.getParkWiseSummary(fromDate, toDate, zone); + System.out.println("Park Wise Summary Result: " + result); + return result; + } + @GetMapping("/detailed") public List> getDetailed(@RequestParam(name = "empType") String empType, @RequestParam(name = "category") String category, @RequestParam(name = "fromDate", required = false) String fromDate, @RequestParam(name = "toDate", required = false) String toDate, - @RequestParam(name = "zone", required = false) Integer zone) { + @RequestParam(name = "zone", required = false) Integer zone, + @RequestParam(name = "parkName", required = false) String parkName) { - List> result = attendanceService.getDetailedList(empType, category, fromDate, toDate, zone); + List> result = attendanceService.getDetailedList(empType, category, fromDate, toDate, zone, parkName); System.out.println("Detailed Result: " + result); return result; - // return attendanceService.getDetailedList(empType, category, fromDate, toDate, zone); + // return attendanceService.getDetailedList(empType, category, fromDate, toDate, zone, parkName); } } diff --git a/src/main/java/com/gcc/commissionerreview/service/AttendanceService.java b/src/main/java/com/gcc/commissionerreview/service/AttendanceService.java index bee275c..9dd6cd0 100644 --- a/src/main/java/com/gcc/commissionerreview/service/AttendanceService.java +++ b/src/main/java/com/gcc/commissionerreview/service/AttendanceService.java @@ -50,7 +50,6 @@ public class AttendanceService { toDate = LocalDate.parse(toDateStr, INPUT_FORMAT); } - // Convert to datetime range (start of fromDate to end of toDate) String fromDateTime = fromDate + " 00:00:00"; String toDateTime = toDate + " 23:59:59"; @@ -68,7 +67,7 @@ public class AttendanceService { return jdbcTemplate.queryForList(sql, new Object[] { fromDateTime, toDateTime, fromDateTime, toDateTime, fromDateTime, toDateTime, empType }); } - public List> getDetailedList(String empType, String category, String fromDateStr, String toDateStr, Integer zone) { + public List> getDetailedList(String empType, String category, String fromDateStr, String toDateStr, Integer zone, String parkName) { LocalDate fromDate; LocalDate toDate; @@ -84,11 +83,9 @@ public class AttendanceService { toDate = LocalDate.parse(toDateStr, INPUT_FORMAT); } - // Convert to datetime range String fromDateTime = fromDate + " 00:00:00"; String toDateTime = toDate + " 23:59:59"; - // determine which datetime column to filter/order by String dateColumn; String filterDateColumn; switch (category == null ? "present" : category.toLowerCase()) { @@ -105,7 +102,6 @@ public class AttendanceService { filterDateColumn = "att.indatetime"; } - // Base query - simplified and optimized String sql = "SELECT et.enrollment_id, et.name, et.designation, et.department, et.incharge_name, et.incharge_phoneno, et.emp_id, et.park_name, " + "DATE_FORMAT(att.indatetime, '%d-%m-%Y %h:%i %p') as intime, att.inphoto as inphoto, att.inby, " + "DATE_FORMAT(att.outdatetime, '%d-%m-%Y %h:%i %p') as outtime, att.outphoto as outphoto, att.outby, " @@ -127,10 +123,48 @@ public class AttendanceService { params.add(zone); } + if (parkName != null && !parkName.isEmpty()) { + sql += " and et.park_name = ? "; + params.add(parkName); + } + sql += " order by " + dateColumn + " desc "; - System.out.println("EmpType: " + empType + ", Category: " + category + ", From: " + fromDateTime + ", To: " + toDateTime + ", Zone: " + zone); + System.out.println("EmpType: " + empType + ", Category: " + category + ", From: " + fromDateTime + ", To: " + toDateTime + ", Zone: " + zone + ", ParkName: " + parkName); return jdbcTemplate.queryForList(sql, params.toArray()); } + + public List> getParkWiseSummary(String fromDateStr, String toDateStr, Integer zone) { + LocalDate fromDate; + LocalDate toDate; + + if (fromDateStr == null || fromDateStr.trim().isEmpty()) { + fromDate = LocalDate.now(); + } else { + fromDate = LocalDate.parse(fromDateStr, INPUT_FORMAT); + } + + if (toDateStr == null || toDateStr.trim().isEmpty()) { + toDate = LocalDate.now(); + } else { + toDate = LocalDate.parse(toDateStr, INPUT_FORMAT); + } + + String fromDateTime = fromDate + " 00:00:00"; + String toDateTime = toDate + " 23:59:59"; + + System.out.println("Zone: " + zone + ", From: " + fromDateTime + ", To: " + toDateTime); + + String sql = "SELECT et.park_name, count(distinct et.enrollment_id) as TotalCount, " + + "count(distinct case when att.indatetime >= ? and att.indatetime <= ? then att.enrollment_id end) as AttendanceMarked, " + + "count(distinct case when att.oddatetime >= ? and att.oddatetime <= ? then att.enrollment_id end) as ODCount, " + + "count(distinct case when att.leavedatetime >= ? and att.leavedatetime <= ? then att.enrollment_id end) as LeaveCount " + + "FROM enrollment_table et " + + "left join attendance att on et.enrollment_id = att.enrollment_id " + + "where et.isactive =1 and et.isdelete = 0 and et.emp_type = 'Park' and et.zone !=0 and et.zone = ? and et.park_name != '' " + + "group by et.park_name order by et.park_name"; + + return jdbcTemplate.queryForList(sql, new Object[] { fromDateTime, toDateTime, fromDateTime, toDateTime, fromDateTime, toDateTime, zone }); + } } diff --git a/src/main/resources/templates/modules/attendance-dashboard.html b/src/main/resources/templates/modules/attendance-dashboard.html index 5c3463b..5a05560 100644 --- a/src/main/resources/templates/modules/attendance-dashboard.html +++ b/src/main/resources/templates/modules/attendance-dashboard.html @@ -1,5 +1,6 @@ + @@ -12,27 +13,32 @@ align-items: center; min-height: 200px; } + .spinner-border { width: 3rem; height: 3rem; color: #007bff; } + .zone-summary-row { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; } + @media (max-width: 768px) { .zone-summary-row { grid-template-columns: 1fr; } } + .zone-summary-card { border: 1px solid #ddd; border-radius: 4px; padding: 15px; background-color: #f9f9f9; } + .disabled-count { color: #6c757d; cursor: default; @@ -42,6 +48,7 @@ } +

Attendance Dashboard

@@ -80,319 +87,460 @@
+ + + - + + \ No newline at end of file