From a2cb726d81f4eb1238b54b8170078574bc48f5f5 Mon Sep 17 00:00:00 2001 From: AJITHKUMAR12 <48044092+AJITHKUMAR12@users.noreply.github.com> Date: Fri, 14 Aug 2026 16:39:38 +0530 Subject: [PATCH] implemented boat service --- .../configuration/DataSourceConfig.java | 11 + .../BoatServiceReportController.java | 68 + .../controller/MainController.java | 5 + .../service/BoatServiceReportService.java | 165 ++ .../templates/modules/boatreport.html | 1764 +++++++++++++++++ 5 files changed, 2013 insertions(+) create mode 100644 src/main/java/com/gcc/commissionerreview/controller/BoatServiceReportController.java create mode 100644 src/main/java/com/gcc/commissionerreview/service/BoatServiceReportService.java create mode 100644 src/main/resources/templates/modules/boatreport.html diff --git a/src/main/java/com/gcc/commissionerreview/configuration/DataSourceConfig.java b/src/main/java/com/gcc/commissionerreview/configuration/DataSourceConfig.java index f290539..2472fe3 100644 --- a/src/main/java/com/gcc/commissionerreview/configuration/DataSourceConfig.java +++ b/src/main/java/com/gcc/commissionerreview/configuration/DataSourceConfig.java @@ -268,4 +268,15 @@ public class DataSourceConfig { return dataSource; } + ////////// boatservice ////////////////////// + @Bean(name = "mysqlbootDataSource") + public DataSource mysqlbootDataSource() { + DriverManagerDataSource dataSource = new DriverManagerDataSource(); + dataSource.setDriverClassName("com.mysql.cj.jdbc.Driver"); + dataSource.setUrl("jdbc:mysql://" + host + "/boat_service"); + dataSource.setUsername("root"); + dataSource.setPassword(dbpassword); + return dataSource; + } + } diff --git a/src/main/java/com/gcc/commissionerreview/controller/BoatServiceReportController.java b/src/main/java/com/gcc/commissionerreview/controller/BoatServiceReportController.java new file mode 100644 index 0000000..a526bc9 --- /dev/null +++ b/src/main/java/com/gcc/commissionerreview/controller/BoatServiceReportController.java @@ -0,0 +1,68 @@ +package com.gcc.commissionerreview.controller; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.ResponseEntity; +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; +import com.gcc.commissionerreview.service.BoatServiceReportService; + +@RestController +@RequestMapping("/commissionerreview/api/boatController") +public class BoatServiceReportController { + @Autowired + private BoatServiceReportService boatServiceReportService; + + @GetMapping("/report") + public ResponseEntity getBoatServiceReport( + @RequestParam String fromDate, + @RequestParam String toDate) { + + try { + + List> report = boatServiceReportService + .getBoatServiceReport( + fromDate, + toDate); + + return ResponseEntity.ok(report); + + } catch (Exception e) { + + e.printStackTrace(); + + return ResponseEntity + .internalServerError() + .body("Failed to load Boat Service Report"); + + } + + } + + @GetMapping("/summary") + public ResponseEntity getBoatSummary() { + + try { + + Map summary = boatServiceReportService.getBoatSummary(); + + return ResponseEntity.ok(summary); + + } catch (Exception e) { + + e.printStackTrace(); + + return ResponseEntity + .internalServerError() + .body("Unable to fetch boat summary"); + + } + } + +} diff --git a/src/main/java/com/gcc/commissionerreview/controller/MainController.java b/src/main/java/com/gcc/commissionerreview/controller/MainController.java index c3979b0..1b83664 100644 --- a/src/main/java/com/gcc/commissionerreview/controller/MainController.java +++ b/src/main/java/com/gcc/commissionerreview/controller/MainController.java @@ -383,4 +383,9 @@ public class MainController { return "modules/swimmingpoolreport"; } + @GetMapping("/boatreport") + public String bootreport(Model model) { + return "modules/boatreport"; + } + } diff --git a/src/main/java/com/gcc/commissionerreview/service/BoatServiceReportService.java b/src/main/java/com/gcc/commissionerreview/service/BoatServiceReportService.java new file mode 100644 index 0000000..ac78b93 --- /dev/null +++ b/src/main/java/com/gcc/commissionerreview/service/BoatServiceReportService.java @@ -0,0 +1,165 @@ +package com.gcc.commissionerreview.service; + +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.Qualifier; +import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.stereotype.Service; + +import java.sql.Date; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; + +@Service +public class BoatServiceReportService { + + @Autowired + private JdbcTemplate jdbcTemplate; + + @Autowired + public void setDataSource(@Qualifier("mysqlbootDataSource") DataSource dataSource) { + this.jdbcTemplate = new JdbcTemplate(dataSource); + } + + public List> getBoatServiceReport( + String fromDate, + String toDate) { + + String sql = """ + + SELECT + + sl.zone AS zone, + + sl.name AS location, + + DATE(tkt.ticketdatetime) + AS report_date, + + tkt.boat_name + AS boat_name, + + COALESCE( + SUM(tkt.adult_count), + 0 + ) AS no_of_adults, + + COALESCE( + SUM(tkt.child_count), + 0 + ) AS no_of_kids, + + COUNT(tkt.ticketid) + AS total_bookings, + + COALESCE( + SUM(tkt.ticket_amount), + 0 + ) AS total_collection + + + FROM tickets tkt + + + LEFT JOIN + service_location sl + + ON tkt.lid = sl.lid + + + + WHERE tkt.status = 'Transaction success' + AND + + tkt.ticketdatetime >= ? + + AND + + tkt.ticketdatetime < ? + + + GROUP BY + + sl.zone, + + sl.name, + + DATE(tkt.ticketdatetime), + + tkt.boat_name + + + ORDER BY + + sl.zone, + + sl.name, + + DATE(tkt.ticketdatetime), + + tkt.boat_name + + """; + + return jdbcTemplate.queryForList( + sql, + fromDate, + toDate); + + } + + public Map getBoatSummary() { + + Map response = new HashMap<>(); + + // ========================================== + // 1. Total Bookings & Total Revenue + // ========================================== + + String summarySql = "SELECT " + + "COUNT(ticketid) AS totalbooking, " + + "COALESCE(SUM(ticket_amount), 0) AS totalamount " + + "FROM tickets"; + + Map summary = jdbcTemplate.queryForMap(summarySql); + + // ========================================== + // 2. Boat Price + // ========================================== + + String priceSql = "SELECT " + + "bcid, " + + "name, " + + "adult_price, " + + "child_price " + + "FROM boat_config " + + "WHERE bcid IN (1, 3) " + + "ORDER BY bcid"; + + List> boatPrices = jdbcTemplate.queryForList(priceSql); + + // ========================================== + // Add both responses + // ========================================== + + response.put("totalbooking", + summary.get("totalbooking")); + + response.put("totalamount", + summary.get("totalamount")); + + response.put("boatPrices", + boatPrices); + + return response; + } +} diff --git a/src/main/resources/templates/modules/boatreport.html b/src/main/resources/templates/modules/boatreport.html new file mode 100644 index 0000000..f297446 --- /dev/null +++ b/src/main/resources/templates/modules/boatreport.html @@ -0,0 +1,1764 @@ + + + + + + + + Boat Service Report + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + +
+ +

+ Boat Service Report +

+ +
+
+ + +
+ + +
+ +
+ +
+ +
+ +
+ +
+ +
+ Total Bookings +
+ +
+ 0 +
+ +
+ +
+ +
+ +
+ + + +
+ +
+ +
+ +
+ +
+ +
+ +
+ Total Revenue +
+ +
+ ₹ 0 +
+ +
+ +
+ +
+ +
+ + + +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ Boat Price +
+ +
+ +
+ + +
+ + +
+ +
+ PEDALING BOAT +
+ +
+ + + Adult: + + ₹ 0 + + + + + Child: + + ₹ 0 + + + +
+ +
+ + + +
+ +
+ SPEED BOAT +
+ +
+ + + Adult: + + ₹ 0 + + + + + Child: + + ₹ 0 + + + +
+ +
+ +
+ +
+ +
+ +
+ +
+ + + + + + + +
+ +
+ + + + +
+ + + + + +
+ + + + + +
+ + + + + +
+ + + + + +
+ + + + + +
+ + + + +
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Sl.NoZoneLocationDate + PEDALING BOAT + + SPEED BOAT + + OVERALL TOTAL +
Adults KidsTotal
Bookings
Total
Collection
Adults KidsTotal
Bookings
Total
Collection
Total BookingsTotal Collection
+ +
+ + +
+ + + + + + + +
+ +
+ +
+ +
+ +

+ Please wait... +

+ +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file