From 6407670ddd37e3b0ab5686e04a7d6e1ae715c4cc Mon Sep 17 00:00:00 2001 From: yoganandhan Date: Mon, 9 Feb 2026 12:08:38 +0530 Subject: [PATCH] added greencommittee controller,service and attendance controller ,service and html pages --- .../configuration/DataSourceConfig.java | 29 +- .../controller/AttendanceController.java | 71 ++ .../GreenCommitteeApicontroller.java | 116 +++ .../service/AttendanceService.java | 136 ++++ .../service/GreenCommitteeService.java | 392 ++++++++++ .../modules/attendance-dashboard.html | 407 ++++++++++ .../modules/greencommittee/gcreport.html | 737 ++++++++++++++++++ 7 files changed, 1887 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/gcc/commissionerreview/controller/AttendanceController.java create mode 100644 src/main/java/com/gcc/commissionerreview/controller/GreenCommitteeApicontroller.java create mode 100644 src/main/java/com/gcc/commissionerreview/service/AttendanceService.java create mode 100644 src/main/java/com/gcc/commissionerreview/service/GreenCommitteeService.java create mode 100644 src/main/resources/templates/modules/attendance-dashboard.html create mode 100644 src/main/resources/templates/modules/greencommittee/gcreport.html diff --git a/src/main/java/com/gcc/commissionerreview/configuration/DataSourceConfig.java b/src/main/java/com/gcc/commissionerreview/configuration/DataSourceConfig.java index 62b8ddc..01ba3fa 100644 --- a/src/main/java/com/gcc/commissionerreview/configuration/DataSourceConfig.java +++ b/src/main/java/com/gcc/commissionerreview/configuration/DataSourceConfig.java @@ -124,7 +124,34 @@ public class DataSourceConfig { public DataSource mysqlFlagPoleManagerSystemDataSource() { DriverManagerDataSource dataSource = new DriverManagerDataSource(); dataSource.setDriverClassName("com.mysql.cj.jdbc.Driver"); - dataSource.setUrl("jdbc:mysql://" + host + "/gcc_flag_pole07022026"); + dataSource.setUrl("jdbc:mysql://" + host + "/gcc_flag_pole"); + dataSource.setUsername("root"); + dataSource.setPassword(dbpassword); + return dataSource; + } + + ////////////////////////////// NULM Attendance //////////////////////// + @Bean(name = "mysqlNULMDataSource") + public DataSource mysqlNULMDataSource() { + HikariConfig config = new HikariConfig(); + config.setJdbcUrl("jdbc:mysql://" + host + "/gcc_nulm"); + config.setUsername("root"); + config.setPassword(dbpassword); + config.setMaximumPoolSize(20); + config.setMinimumIdle(5); + config.setConnectionTimeout(30000); + config.setIdleTimeout(600000); + config.setMaxLifetime(1800000); + config.setAutoCommit(true); + return new HikariDataSource(config); + } + + ////////////////////////////// Green Committee ///////////////// + @Bean(name = "mysqlGreenCommitteeDataSource") + public DataSource mysqlGreenCommitteeDataSource() { + DriverManagerDataSource dataSource = new DriverManagerDataSource(); + dataSource.setDriverClassName("com.mysql.cj.jdbc.Driver"); + dataSource.setUrl("jdbc:mysql://" + host + "/green_committee"); dataSource.setUsername("root"); dataSource.setPassword(dbpassword); return dataSource; diff --git a/src/main/java/com/gcc/commissionerreview/controller/AttendanceController.java b/src/main/java/com/gcc/commissionerreview/controller/AttendanceController.java new file mode 100644 index 0000000..65db546 --- /dev/null +++ b/src/main/java/com/gcc/commissionerreview/controller/AttendanceController.java @@ -0,0 +1,71 @@ +package com.gcc.commissionerreview.controller; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestParam; + +import java.util.List; +import java.util.Map; + +import com.gcc.commissionerreview.service.AttendanceService; + +@RestController +@RequestMapping("/commissionerreview/api/attendanceController") +public class AttendanceController { + + @Autowired + AttendanceService attendanceService; + + @GetMapping("/abstractCounts") + public List> getAbstractCounts() { + return attendanceService.getAbstractCounts(); + } + + @GetMapping("/zoneSummary") + public List> getZoneSummary(@RequestParam(name = "empType") String empType, + @RequestParam(name = "fromDate", required = false) String fromDate, + @RequestParam(name = "toDate", required = false) String toDate) { + + List> result = attendanceService.getZoneSummary(empType, fromDate, toDate); + System.out.println("Zone Summary Result for "+empType+ ":"+ result); + return result; + + // return attendanceService.getZoneSummary(empType, fromDate, toDate); + } + + @GetMapping("/zoneSummaryPark") + public List> getZoneSummaryPark( + @RequestParam(name = "fromDate", required = false) String fromDate, + @RequestParam(name = "toDate", required = false) String toDate) { + List> result = attendanceService.getZoneSummary("Park", fromDate, toDate); + System.out.println("Zone Summary Result for Park: " + result); + return result; + } + + @GetMapping("/zoneSummaryNULM") + public List> getZoneSummaryNULM( + @RequestParam(name = "fromDate", required = false) String fromDate, + @RequestParam(name = "toDate", required = false) String toDate) { + List> result = attendanceService.getZoneSummary("NULM", fromDate, toDate); + System.out.println("Zone Summary Result for NULM: " + 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) { + + List> result = attendanceService.getDetailedList(empType, category, fromDate, toDate, zone); + System.out.println("Detailed Result: " + result); + + return result; + + // return attendanceService.getDetailedList(empType, category, fromDate, toDate, zone); + } + +} diff --git a/src/main/java/com/gcc/commissionerreview/controller/GreenCommitteeApicontroller.java b/src/main/java/com/gcc/commissionerreview/controller/GreenCommitteeApicontroller.java new file mode 100644 index 0000000..ac4cac2 --- /dev/null +++ b/src/main/java/com/gcc/commissionerreview/controller/GreenCommitteeApicontroller.java @@ -0,0 +1,116 @@ +package com.gcc.commissionerreview.controller; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import com.gcc.commissionerreview.service.GreenCommitteeService; + +@RestController +@RequestMapping("/commissionerreview/api/greencommittee") +public class GreenCommitteeApicontroller { + + @Autowired + private GreenCommitteeService gcservice; + + @GetMapping("/getZoneReport") + public Map getabscount(@RequestParam(required = false) String startDate, + @RequestParam(required = false) String endDate) + { + + Map response = new HashMap<>(); + + try { + List> data = gcservice.getabscount(startDate, endDate); + + response.put("data", data); + response.put("message", "Zone-wise abstract report"); + response.put("status", "Success"); + + } catch (Exception e) { + e.printStackTrace(); + + response.put("data", Collections.emptyList()); + response.put("message", "Failed to fetch abstract report"); + response.put("status", "Error"); + } + + return response; + } + + + @GetMapping("/getWardDetailsByZone") + public Map getWardDetailsByZone(@RequestParam(required = true) String zone, + @RequestParam(required = false) String startDate, + @RequestParam(required = false) String endDate) + { + + Map response = new HashMap<>(); + + try { + List> data = gcservice.getWardDetailsByZone(zone,startDate,endDate); + + response.put("data", data); + response.put("message", "Ward-wise abstract report"); + response.put("status", "Success"); + + } catch (Exception e) { + e.printStackTrace(); + + response.put("data", Collections.emptyList()); + response.put("message", "Failed to fetch abstract report"); + response.put("status", "Error"); + } + + return response; + } + + @GetMapping("/getPendingDetails") + public Map getPendingDetails( + @RequestParam String zone, + @RequestParam(required = false) String ward, + @RequestParam String type, + @RequestParam(required = false) String startDate, + @RequestParam(required = false) String endDate) { + + + Map response = new HashMap<>(); + + try { + List refIds =gcservice.getPendingRefIds(zone, ward, type,startDate, endDate); + + List> dataList = new ArrayList<>(); + + for (String refId : refIds) { + Map fullData = gcservice.getfulldetailsdata(refId); + if (fullData != null && !fullData.isEmpty()) { + dataList.add((Map) fullData.get("data")); + } + } + + response.put("data", dataList); + response.put("message", "Complaint List"); + response.put("status", "Success"); + + } catch (Exception e) { + e.printStackTrace(); + response.put("data", Collections.emptyList()); + response.put("message", "Failed to fetch complaints"); + response.put("status", "Error"); + } + + + return response; + } + + + +} diff --git a/src/main/java/com/gcc/commissionerreview/service/AttendanceService.java b/src/main/java/com/gcc/commissionerreview/service/AttendanceService.java new file mode 100644 index 0000000..7500c3c --- /dev/null +++ b/src/main/java/com/gcc/commissionerreview/service/AttendanceService.java @@ -0,0 +1,136 @@ +package com.gcc.commissionerreview.service; + +import javax.sql.DataSource; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.stereotype.Service; + +import java.sql.Date; +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; +import java.util.List; +import java.util.Locale; +import java.util.Map; + +@Service +public class AttendanceService { + + @Autowired + private JdbcTemplate jdbcTemplate; + + @Autowired + public void setFeedbackDataSource(@Qualifier("mysqlNULMDataSource") DataSource dataSource) { + this.jdbcTemplate = new JdbcTemplate(dataSource); + } + + private static final DateTimeFormatter INPUT_FORMAT = DateTimeFormatter.ofPattern("dd-MM-yyyy", Locale.ENGLISH); + + public List> getAbstractCounts() { + String sql = "SELECT emp_type, count(enrollment_id) as totalCount FROM enrollment_table " + + "where isactive =1 and isdelete = 0 and zone != 0 group by emp_type"; + + return jdbcTemplate.queryForList(sql); + } + + public List> getZoneSummary(String empType, String fromDateStr, String toDateStr) { + 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); + } + + // Convert to datetime range (start of fromDate to end of toDate) + String fromDateTime = fromDate + " 00:00:00"; + String toDateTime = toDate + " 23:59:59"; + + System.out.println("EmpType: " + empType + ", From: " + fromDateTime + ", To: " + toDateTime); + + String sql = "SELECT et.zone, 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 = ? and et.zone !=0 " + + "group by et.zone order by et.zone"; + + 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) { + 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); + } + + // 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()) { + case "od": + dateColumn = "att.oddatetime"; + filterDateColumn = "att.oddatetime"; + break; + case "leave": + dateColumn = "att.leavedatetime"; + filterDateColumn = "att.leavedatetime"; + break; + default: + dateColumn = "att.indatetime"; + 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, " + + "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, " + + "DATE_FORMAT(att.oddatetime, '%d-%m-%Y %h:%i %p') as odtime, att.odby, et.zone, " + + "DATE_FORMAT(att.leavedatetime, '%d-%m-%Y %h:%i %p') as leavedatetime, att.leaveby " + + "FROM enrollment_table et " + + "inner join attendance att on et.enrollment_id = att.enrollment_id " + + " and " + filterDateColumn + " >= ? and " + filterDateColumn + " <= ? " + + "where et.isactive =1 and et.isdelete = 0 and et.emp_type = ? and et.zone !=0 " + + " and " + filterDateColumn + " is not null "; + + java.util.List params = new java.util.ArrayList<>(); + params.add(fromDateTime); + params.add(toDateTime); + params.add(empType); + + if (zone != null) { + sql += " and et.zone = ? "; + params.add(zone); + } + + sql += " order by " + dateColumn + " desc "; + + System.out.println("EmpType: " + empType + ", Category: " + category + ", From: " + fromDateTime + ", To: " + toDateTime + ", Zone: " + zone); + return jdbcTemplate.queryForList(sql, params.toArray()); + } +} + diff --git a/src/main/java/com/gcc/commissionerreview/service/GreenCommitteeService.java b/src/main/java/com/gcc/commissionerreview/service/GreenCommitteeService.java new file mode 100644 index 0000000..3b75f77 --- /dev/null +++ b/src/main/java/com/gcc/commissionerreview/service/GreenCommitteeService.java @@ -0,0 +1,392 @@ +package com.gcc.commissionerreview.service; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +import javax.sql.DataSource; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.core.env.Environment; +import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.stereotype.Service; + +import com.gcc.commissionerreview.configuration.AppConfig; + +@Service +public class GreenCommitteeService { + + + @Autowired + private JdbcTemplate jdbcTemplate; + @Autowired + private Environment environment; + + @Autowired + private AppConfig appConfig; + + @Autowired + @Value("${fileBaseUrl}") + + private String fileBaseUrl; + + public GreenCommitteeService (Environment environment) { + + this.environment = environment; + + this.fileBaseUrl = environment.getProperty("fileBaseUrl"); + } + + @Autowired + public void setFeedbackDataSource(@Qualifier("mysqlGreenCommitteeDataSource") DataSource dataSource) { + this.jdbcTemplate = new JdbcTemplate(dataSource); + } + + public List> getabscount(String startDate, String endDate) { + + String baseSql = + "SELECT " + + " zm.zone_name, " + + " COALESCE(COUNT(DISTINCT rd.ref_id), 0) AS total_requests, " + + + " COALESCE(SUM(CASE " + + " WHEN rd.ref_id IS NOT NULL " + + " AND rd.is_withdraw = 0 " + + " AND rd.ref_id NOT IN (SELECT ref_id FROM committee_data WHERE isactive=1) " + + " AND rd.ref_id NOT IN (SELECT ref_id FROM reinspection WHERE isactive=1) " + + " AND rd.ref_id NOT IN ( " + + " SELECT id.ref_id FROM inspection_data id " + + " WHERE id.inspection_by='NGO' AND id.isactive=1 " + + " AND ( (rd.reinspection_id IS NULL AND id.reinspection_id IS NULL) " + + " OR (rd.reinspection_id=id.reinspection_id) ) " + + " ) " + + " THEN 1 ELSE 0 END), 0) AS ngo_pending, " + + + " COALESCE(SUM(CASE " + + " WHEN rd.ref_id IS NOT NULL " + + " AND rd.is_withdraw = 0 " + + " AND rd.ref_id NOT IN (SELECT ref_id FROM committee_data WHERE isactive=1) " + + " AND rd.ref_id NOT IN (SELECT ref_id FROM reinspection WHERE isactive=1) " + + " AND rd.ref_id NOT IN ( " + + " SELECT id.ref_id FROM inspection_data id " + + " WHERE id.inspection_by='GCC' AND id.isactive=1 " + + " AND ( (rd.reinspection_id IS NULL AND id.reinspection_id IS NULL) " + + " OR (rd.reinspection_id=id.reinspection_id) ) " + + " ) " + + " THEN 1 ELSE 0 END), 0) AS gcc_pending, " + + + " COALESCE(SUM(CASE " + + " WHEN rd.ref_id IS NOT NULL " + + " AND rd.is_withdraw = 0 " + + " AND rd.ref_id NOT IN (SELECT ref_id FROM committee_data WHERE isactive=1) " + + " AND rd.ref_id NOT IN (SELECT ref_id FROM reinspection WHERE isactive=1) " + + " AND rd.ref_id NOT IN ( " + + " SELECT id.ref_id FROM inspection_data id " + + " WHERE id.inspection_by='TNFD' AND id.isactive=1 " + + " AND ( (rd.reinspection_id IS NULL AND id.reinspection_id IS NULL) " + + " OR (rd.reinspection_id=id.reinspection_id) ) " + + " ) " + + " THEN 1 ELSE 0 END), 0) AS tnfd_pending, " + + + " COALESCE(SUM(CASE " + + " WHEN rd.ref_id IS NOT NULL " + + " AND rd.is_withdraw = 0 " + + " AND rd.ref_id NOT IN (SELECT ref_id FROM committee_data WHERE isactive=1) " + + " AND rd.ref_id NOT IN (SELECT ref_id FROM reinspection WHERE isactive=1) " + + " AND ( " + + " SELECT COUNT(DISTINCT inspection_by) " + + " FROM inspection_data id " + + " WHERE id.ref_id = rd.ref_id AND id.isactive=1 " + + " AND ( (rd.reinspection_id IS NULL AND id.reinspection_id IS NULL) " + + " OR (rd.reinspection_id=id.reinspection_id) ) " + + " ) = 3 " + + " THEN 1 ELSE 0 END), 0) AS committee_pending, " + + + " COALESCE(SUM(CASE WHEN rd.is_withdraw = 1 THEN 1 ELSE 0 END), 0) AS withdrawn, " + + + " COALESCE(SUM(CASE " + + " WHEN rd.ref_id IN (SELECT ref_id FROM committee_data WHERE isactive=1) " + + " THEN 1 ELSE 0 END), 0) AS completed " + + + "FROM zone_master zm " + + "LEFT JOIN reg_details rd " + + " ON rd.zone = zm.zone_name " + + " AND rd.is_active = 1 "; + + StringBuilder sql = new StringBuilder(baseSql); + List params = new ArrayList<>(); + + if (startDate != null && !startDate.isEmpty()) { + sql.append(" AND DATE(rd.cdate) >= ? "); + params.add(startDate); + } + + if (endDate != null && !endDate.isEmpty()) { + sql.append(" AND DATE(rd.cdate) <= ? "); + params.add(endDate); + } + + sql.append( + " WHERE zm.is_active = 1 " + + " AND zm.is_delete = 0 " + + " GROUP BY zm.zone_name " + + " ORDER BY zm.zone_name " + ); + + return jdbcTemplate.queryForList(sql.toString(), params.toArray()); + } + + + public List> getWardDetailsByZone( + String zone, + String startDate, + String endDate) { + + String baseSql = + "SELECT " + + " wm.ward_name, " + + + " COALESCE(COUNT(DISTINCT rd.ref_id), 0) AS total_requests, " + + + " COALESCE(SUM(CASE " + + " WHEN rd.ref_id IS NOT NULL " + + " AND rd.is_withdraw = 0 " + + " AND rd.ref_id NOT IN (SELECT ref_id FROM committee_data WHERE isactive=1) " + + " AND rd.ref_id NOT IN (SELECT ref_id FROM reinspection WHERE isactive=1) " + + " AND rd.ref_id NOT IN ( " + + " SELECT id.ref_id FROM inspection_data id " + + " WHERE id.inspection_by='NGO' AND id.isactive=1 " + + " AND ( (rd.reinspection_id IS NULL AND id.reinspection_id IS NULL) " + + " OR (rd.reinspection_id = id.reinspection_id) ) " + + " ) " + + " THEN 1 ELSE 0 END), 0) AS ngo_pending, " + + + " COALESCE(SUM(CASE " + + " WHEN rd.ref_id IS NOT NULL " + + " AND rd.is_withdraw = 0 " + + " AND rd.ref_id NOT IN (SELECT ref_id FROM committee_data WHERE isactive=1) " + + " AND rd.ref_id NOT IN (SELECT ref_id FROM reinspection WHERE isactive=1) " + + " AND rd.ref_id NOT IN ( " + + " SELECT id.ref_id FROM inspection_data id " + + " WHERE id.inspection_by='GCC' AND id.isactive=1 " + + " AND ( (rd.reinspection_id IS NULL AND id.reinspection_id IS NULL) " + + " OR (rd.reinspection_id = id.reinspection_id) ) " + + " ) " + + " THEN 1 ELSE 0 END), 0) AS gcc_pending, " + + + " COALESCE(SUM(CASE " + + " WHEN rd.ref_id IS NOT NULL " + + " AND rd.is_withdraw = 0 " + + " AND rd.ref_id NOT IN (SELECT ref_id FROM committee_data WHERE isactive=1) " + + " AND rd.ref_id NOT IN (SELECT ref_id FROM reinspection WHERE isactive=1) " + + " AND rd.ref_id NOT IN ( " + + " SELECT id.ref_id FROM inspection_data id " + + " WHERE id.inspection_by='TNFD' AND id.isactive=1 " + + " AND ( (rd.reinspection_id IS NULL AND id.reinspection_id IS NULL) " + + " OR (rd.reinspection_id = id.reinspection_id) ) " + + " ) " + + " THEN 1 ELSE 0 END), 0) AS tnfd_pending, " + + + " COALESCE(SUM(CASE " + + " WHEN rd.ref_id IS NOT NULL " + + " AND rd.is_withdraw = 0 " + + " AND rd.ref_id NOT IN (SELECT ref_id FROM committee_data WHERE isactive=1) " + + " AND rd.ref_id NOT IN (SELECT ref_id FROM reinspection WHERE isactive=1) " + + " AND ( " + + " SELECT COUNT(DISTINCT inspection_by) " + + " FROM inspection_data id " + + " WHERE id.ref_id = rd.ref_id AND id.isactive=1 " + + " AND ( (rd.reinspection_id IS NULL AND id.reinspection_id IS NULL) " + + " OR (rd.reinspection_id = id.reinspection_id) ) " + + " ) = 3 " + + " THEN 1 ELSE 0 END), 0) AS committee_pending, " + + + " COALESCE(SUM(CASE WHEN rd.is_withdraw=1 THEN 1 ELSE 0 END), 0) AS withdrawn, " + + + " COALESCE(SUM(CASE " + + " WHEN rd.ref_id IN (SELECT ref_id FROM committee_data WHERE isactive=1) " + + " THEN 1 ELSE 0 END), 0) AS completed " + + + "FROM ward_master wm " + + "JOIN zone_master zm ON zm.id = wm.zone_id AND zm.zone_name = ? " + + "LEFT JOIN reg_details rd " + + " ON rd.ward = wm.ward_name " + + " AND rd.is_active = 1 "; + + StringBuilder sql = new StringBuilder(baseSql); + List params = new ArrayList<>(); + + + params.add(zone); + + + if (startDate != null && !startDate.isEmpty()) { + sql.append(" AND DATE(rd.cdate) >= ? "); + params.add(startDate); + } + + if (endDate != null && !endDate.isEmpty()) { + sql.append(" AND DATE(rd.cdate) <= ? "); + params.add(endDate); + } + + sql.append( + " WHERE wm.is_active=1 AND wm.is_delete=0 " + + " GROUP BY wm.zone_id, wm.ward_name " + + " ORDER BY wm.ward_name " + ); + + return jdbcTemplate.queryForList(sql.toString(), params.toArray()); + } + + + + public List getPendingRefIds( + String zone, + String ward, + String type, + String startDate, + String endDate) { + + String baseSql; + + switch (type.toUpperCase()) { + + case "NGO": + baseSql = + "SELECT rd.ref_id FROM reg_details rd " + + "WHERE rd.zone=? " + + "AND rd.is_active=1 AND rd.is_withdraw=0 " + + "AND rd.ref_id NOT IN (SELECT ref_id FROM committee_data WHERE isactive=1) " + + "AND rd.ref_id NOT IN (SELECT ref_id FROM reinspection WHERE isactive=1) " + + "AND rd.ref_id NOT IN ( " + + " SELECT id.ref_id FROM inspection_data id " + + " WHERE id.inspection_by='NGO' AND id.isactive=1 " + + " AND ( (rd.reinspection_id IS NULL AND id.reinspection_id IS NULL) " + + " OR (rd.reinspection_id = id.reinspection_id) ) " + + ")"; + break; + + case "GCC": + baseSql = + "SELECT rd.ref_id FROM reg_details rd " + + "WHERE rd.zone=? " + + "AND rd.is_active=1 AND rd.is_withdraw=0 " + + "AND rd.ref_id NOT IN (SELECT ref_id FROM committee_data WHERE isactive=1) " + + "AND rd.ref_id NOT IN (SELECT ref_id FROM reinspection WHERE isactive=1) " + + "AND rd.ref_id NOT IN ( " + + " SELECT id.ref_id FROM inspection_data id " + + " WHERE id.inspection_by='GCC' AND id.isactive=1 " + + " AND ( (rd.reinspection_id IS NULL AND id.reinspection_id IS NULL) " + + " OR (rd.reinspection_id = id.reinspection_id) ) " + + ")"; + break; + + case "TNFD": + baseSql = + "SELECT rd.ref_id FROM reg_details rd " + + "WHERE rd.zone=? " + + "AND rd.is_active=1 AND rd.is_withdraw=0 " + + "AND rd.ref_id NOT IN (SELECT ref_id FROM committee_data WHERE isactive=1) " + + "AND rd.ref_id NOT IN (SELECT ref_id FROM reinspection WHERE isactive=1) " + + "AND rd.ref_id NOT IN ( " + + " SELECT id.ref_id FROM inspection_data id " + + " WHERE id.inspection_by='TNFD' AND id.isactive=1 " + + " AND ( (rd.reinspection_id IS NULL AND id.reinspection_id IS NULL) " + + " OR (rd.reinspection_id = id.reinspection_id) ) " + + ")"; + break; + + case "WITHDRAW": + baseSql = + "SELECT rd.ref_id FROM reg_details rd " + + "WHERE rd.zone=? AND rd.is_withdraw=1"; + break; + + default: + return Collections.emptyList(); + } + + StringBuilder sql = new StringBuilder(baseSql); + List params = new ArrayList<>(); + + params.add(zone); + + if (ward != null && !ward.isEmpty()) { + sql.append(" AND rd.ward = ? "); + params.add(ward); + } + + if (startDate != null && !startDate.isEmpty()) { + sql.append(" AND DATE(rd.cdate) >= ? "); + params.add(startDate); + } + + if (endDate != null && !endDate.isEmpty()) { + sql.append(" AND DATE(rd.cdate) <= ? "); + params.add(endDate); + } + + return jdbcTemplate.query( + sql.toString(), + params.toArray(), + (rs, rowNum) -> rs.getString("ref_id") + ); + } + + + + + + public Map getfulldetailsdata(String refId) { + + Map response = new HashMap<>(); + + // 1 — Application details + Map app = jdbcTemplate.queryForMap( + "SELECT *,DATE_FORMAT(cdate, '%d-%m-%Y %l:%i %p') as r_Cdate,IFNULL(reinspection_id, '') AS com_reinspection_id FROM reg_details WHERE ref_id=? AND is_active=1", + refId + ); + + // 2 — Complaint details (grouped) + List> complaints = jdbcTemplate.queryForList( + "SELECT cn.name AS nature, SUM(cd.no_of_trees) AS count " + + "FROM complaint_details cd JOIN comp_nature cn ON cn.id=cd.comp_nature_id " + + "WHERE cd.ref_id=? GROUP BY cn.name", refId + ); + + String compDetails = complaints.stream() + .map(c -> c.get("nature") + "-" + c.get("count")) + .collect(Collectors.joining(",")); + + // 3 — Complaint images + List> imagePaths = + jdbcTemplate.queryForList( + "SELECT img_path FROM img_uploads WHERE ref_id=? AND is_active=1", + new Object[]{refId} + ).stream() + .map(row -> { + Map img = new HashMap<>(); + img.put( + "img_path", + fileBaseUrl + "/gccofficialapp/files" + row.get("img_path").toString() + ); + return img; + }) + .collect(Collectors.toList()); + + app.put("complaints", complaints); + app.put("comp_details", compDetails); + app.put("image_paths", imagePaths); + + response.put("data", app); + + return response; + } + +} diff --git a/src/main/resources/templates/modules/attendance-dashboard.html b/src/main/resources/templates/modules/attendance-dashboard.html new file mode 100644 index 0000000..26a4213 --- /dev/null +++ b/src/main/resources/templates/modules/attendance-dashboard.html @@ -0,0 +1,407 @@ + + + + + + Attendance Dashboard + + + + +
+

Attendance Dashboard

+ +
+
+ + +
+
+ + +
+
+
+ +
+
+
+ +

Abstract Counts

+
+ +

Zone Summary

+
+
+
Park
+
+
+
+
NULM
+
+
+
+ +
+ + + + + + + diff --git a/src/main/resources/templates/modules/greencommittee/gcreport.html b/src/main/resources/templates/modules/greencommittee/gcreport.html new file mode 100644 index 0000000..1689172 --- /dev/null +++ b/src/main/resources/templates/modules/greencommittee/gcreport.html @@ -0,0 +1,737 @@ + + + +Green Committe Report + + + + + + + + + + + + + + +
+

Green Committee - Zonewise Report

+
+ +
+
+ + +
+ + +
+ + +
+ + +
+ + + +
+ +
+ + + +
+
+ + +
+
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ZonesTotal RequestNGO PendingGCC PendingTNFD PendingCommittee PendingWithdrawCompleted
TOTAL
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file