diff --git a/src/main/java/com/gcc/commissionerreview/controller/MainController.java b/src/main/java/com/gcc/commissionerreview/controller/MainController.java index 854f9f0..7a2cea0 100644 --- a/src/main/java/com/gcc/commissionerreview/controller/MainController.java +++ b/src/main/java/com/gcc/commissionerreview/controller/MainController.java @@ -4,6 +4,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpStatus; @@ -17,6 +18,7 @@ import org.springframework.web.client.RestTemplate; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; +import com.gcc.commissionerreview.service.VphService; import jakarta.servlet.http.HttpSession; @@ -26,6 +28,8 @@ import jakarta.servlet.http.HttpSession; public class MainController { private static final String LOGIN_URL = "http://3.26.245.178:3000/login"; + @Autowired + private VphService vphservice; @GetMapping("/uphcreport") public String uphcreport(Model model) { @@ -205,4 +209,22 @@ public class MainController { return "modules/pet/petreport"; } + @GetMapping("/vphreport") + public String vphreport(Model model) { + Map categoryTotals = vphservice.getCategoryTotalsTillToday(); + + int hallBookingCount = vphservice.getHallBookingCountTillToday(); + + Map visitorTotals = vphservice.getVisitorTotalsTillToday(); + + int visitorBookingCount = vphservice.getVisitorBookingCountTillToday(); + + model.addAttribute("categoryTotals", categoryTotals); + model.addAttribute("hallBookingCount", hallBookingCount); + model.addAttribute("visitorTotals", visitorTotals); + model.addAttribute("visitorBookingCount", visitorBookingCount); + + return "modules/vphreport"; + } + } diff --git a/src/main/java/com/gcc/commissionerreview/controller/VphApiController.java b/src/main/java/com/gcc/commissionerreview/controller/VphApiController.java new file mode 100644 index 0000000..177673d --- /dev/null +++ b/src/main/java/com/gcc/commissionerreview/controller/VphApiController.java @@ -0,0 +1,45 @@ +package com.gcc.commissionerreview.controller; + +import java.util.List; +import java.util.Map; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +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.VphService; + +@RestController +@RequestMapping("/commissionerreview/api") +public class VphApiController { + + @Autowired + private VphService vphservice; + + // ak + @GetMapping("/visitor-category") + public List> visitorCategory( + @RequestParam String fromDate, + @RequestParam String toDate) { + return vphservice.getVisitorCategory(fromDate, toDate); + } + + @GetMapping("/total-visitors") + public List> totalVisitors( + @RequestParam String fromDate, + @RequestParam String toDate) { + return vphservice.getTotalVisitors(fromDate, toDate); + } + + @GetMapping("/hall-bookings") + public List> hallBookings( + @RequestParam String fromDate, + @RequestParam String toDate) { + return vphservice.getHallBookings(fromDate, toDate); + } + +} diff --git a/src/main/java/com/gcc/commissionerreview/service/VphService.java b/src/main/java/com/gcc/commissionerreview/service/VphService.java new file mode 100644 index 0000000..8fb0037 --- /dev/null +++ b/src/main/java/com/gcc/commissionerreview/service/VphService.java @@ -0,0 +1,162 @@ +package com.gcc.commissionerreview.service; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +import javax.imageio.ImageIO; +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; + +@Service +public class VphService { + + @Autowired + private JdbcTemplate jdbcTemplate; + + @Autowired + public void setFeedbackDataSource(@Qualifier("mysqlVphDataSource") DataSource dataSource) { + this.jdbcTemplate = new JdbcTemplate(dataSource); + } + + public List> getVisitorCategory(String fromDate, String toDate) { + + String sql = """ + SELECT DATE_FORMAT(rd.visit_date,'%d-%m-%Y') AS visitDate, + COALESCE(SUM(CASE WHEN vac.user_type='Adult ' THEN vcd.no_of_people END),0) Adult, + COALESCE(SUM(CASE WHEN vac.user_type='Children [ below 10 year]' THEN vcd.no_of_people END),0) Children, + COALESCE(SUM(CASE WHEN vac.user_type='Senior Citizen [above 60+]' THEN vcd.no_of_people END),0) SeniorCitizen, + COALESCE(SUM(CASE WHEN vac.user_type='Students' THEN vcd.no_of_people END),0) Students, + COALESCE(SUM(CASE WHEN vac.user_type='Foreigner' THEN vcd.no_of_people END),0) Foreigner, + COALESCE(SUM(CASE WHEN vac.user_type='Physically challeged' THEN vcd.no_of_people END),0) PhysicallyChallenged, + COALESCE(SUM(vcd.no_of_people),0) TotalCount + FROM reg_details rd + LEFT JOIN visitor_count_details vcd ON rd.ref_id=vcd.ref_id + LEFT JOIN visit_amount_config vac ON vcd.user_type_id=vac.id + WHERE rd.booking_flag='B' + AND DATE(rd.visit_date) BETWEEN ? AND ? + GROUP BY rd.visit_date + ORDER BY rd.visit_date + """; + + return jdbcTemplate.queryForList(sql, fromDate, toDate); + } + + public List> getTotalVisitors(String fromDate, String toDate) { + + String sql = """ + SELECT DATE_FORMAT(visit_date,'%d-%m-%Y') visitDate, + SUM(no_of_people) RegisteredCount + FROM reg_details + WHERE booking_flag='B' + AND DATE(visit_date) BETWEEN ? AND ? + GROUP BY visit_date + ORDER BY visit_date + """; + + return jdbcTemplate.queryForList(sql, fromDate, toDate); + } + + public List> getHallBookings(String fromDate, String toDate) { + + String sql = """ + SELECT hd.hall_name, + us.name userName, + DATE_FORMAT(bd.booking_date,'%d-%m-%Y') bookingDate, + DATE_FORMAT(bd.end_date,'%d-%m-%Y') eventDate + FROM booking_details bd + LEFT JOIN hall_details hd ON bd.hall_details_hall_id=hd.hall_id + LEFT JOIN users us ON bd.users_user_id=us.user_id + WHERE bd.booking_status IN ('WAITING_FOR_NOC','APPROVED') + AND DATE(bd.booking_date) BETWEEN ? AND ? + ORDER BY bd.booking_date + """; + + return jdbcTemplate.queryForList(sql, fromDate, toDate); + } + + // card + public Map getCategoryTotalsTillToday() { + + String sql = """ + SELECT + IFNULL(vac.user_type, 'TOTAL') AS userCategory, + COALESCE(SUM(rd.no_of_people), 0) AS registeredCount + FROM reg_details rd + LEFT JOIN visitor_count_details vcd ON rd.ref_id = vcd.ref_id + LEFT JOIN visit_amount_config vac ON vcd.user_type_id = vac.id + WHERE rd.booking_flag = 'B' + AND date(rd.cdate) <= CURDATE() + GROUP BY vac.user_type WITH ROLLUP + """; + + Map result = new HashMap<>(); + + jdbcTemplate.query(sql, rs -> { + result.put( + rs.getString("userCategory"), + rs.getInt("registeredCount")); + }); + + return result; + } + + /* ================= HALL BOOKING COUNT ================= */ + public int getHallBookingCountTillToday() { + + String sql = """ + SELECT COUNT(*) + FROM booking_details + WHERE booking_status IN ('WAITING_FOR_NOC', 'APPROVED') + AND DATE(booking_date) <= CURDATE() + """; + + return jdbcTemplate.queryForObject(sql, Integer.class); + } + + // visitor + public Map getVisitorTotalsTillToday() { + + String sql = """ + SELECT + IFNULL(vac.user_type, 'TOTAL') AS userCategory, + COALESCE(SUM(rd.accepted_people), 0) AS registeredCount + FROM reg_details rd + LEFT JOIN visitor_count_details vcd ON rd.ref_id = vcd.ref_id + LEFT JOIN visit_amount_config vac ON vcd.user_type_id = vac.id + WHERE rd.booking_flag = 'B' + AND date(rd.visit_date) <= CURDATE() + GROUP BY vac.user_type WITH ROLLUP + """; + + Map result = new HashMap<>(); + + jdbcTemplate.query(sql, rs -> { + result.put( + rs.getString("userCategory"), + rs.getInt("registeredCount")); + }); + + return result; + } + + /* ================= HALL BOOKING COUNT ================= */ + public int getVisitorBookingCountTillToday() { + + String sql = """ + SELECT COUNT(*) + FROM booking_details + WHERE booking_status IN ('WAITING_FOR_NOC', 'APPROVED') + AND DATE(booking_date) <= CURDATE() + """; + + return jdbcTemplate.queryForObject(sql, Integer.class); + } +} \ No newline at end of file diff --git a/src/main/resources/templates/modules/pet/petreport.html b/src/main/resources/templates/modules/pet/petreport.html index 6fc7b96..945c74a 100644 --- a/src/main/resources/templates/modules/pet/petreport.html +++ b/src/main/resources/templates/modules/pet/petreport.html @@ -1073,12 +1073,14 @@ { extend: 'excelHtml5', title: 'Pet_License_MIS_Report', - text: 'Download Excel' + text: 'Download Excel', + footer: true }, { extend: 'pdfHtml5', title: 'Pet_License_MIS_Report', text: 'Download PDF', + footer: true, pageSize: 'A4' } diff --git a/src/main/resources/templates/modules/vphreport.html b/src/main/resources/templates/modules/vphreport.html new file mode 100644 index 0000000..2862b89 --- /dev/null +++ b/src/main/resources/templates/modules/vphreport.html @@ -0,0 +1,509 @@ + + + + + + Victoria MIS Dashboard + + + + + + + + + +
+
+
+ + + + +
+ + +
+ + +
+

Victoria Public Hall

+
+ + +
+
+ + + +
+
+ +
+ +
+
+
+
+
Total Visitors
+ +

Registered count : + 0 +

+

Visitor count : + 0 +

+
+
+
+
+
+
+
Senior Citizen
+

Registered count : + 0 +

+

Visitor count : + 0 +

+
+
+
+ +
+
+
+
Adult
+

Registered count : + 0 +

+

Visitor count : + 0 +

+
+
+
+ +
+
+
+
Children
+

Registered count : + 0 +

+

Visitor count : + 0 +

+
+
+
+ + + +
+
+
+
Students
+

Registered count : + 0 +

+

Visitor count : + 0 +

+
+
+
+ +
+
+
+
Foreigner
+

Registered count : + 0 +

+

Visitor count : + 0 +

+
+
+
+ +
+
+
+
Physically Challenged
+

Registered count : + 0 +

+

Visitor count : + 0 +

+
+
+
+ + + +
+
+
+
Hall Bookings
+

0

+
+
+
+ +
+ + + + + + + + + +
Visitor Booking Details – Category Wise
+
+ + + + + + + + + + + + + + + +
DateAdultChildrenSenior CitizenStudentsForeignerPhysically ChallengedTotal
+ + + + + +
Hall Booking Details
+
+ + + + + + + + + + + +
Hall NameUser NameBooking DateEvent Date
+ +
+
+
+ + + + + + + + + + + + + + + + + + + \ No newline at end of file