From d73cb87a15ed66d0767ad8412e8c9dd98ec972e3 Mon Sep 17 00:00:00 2001
From: KaNi-04 <136799210+KaNi-04@users.noreply.github.com>
Date: Mon, 13 Jul 2026 14:36:01 +0530
Subject: [PATCH] Hall creation and Gcc Blocking(New) concept implemented in
the Admin, HQ and officer login
---
.classpath | 6 -
.gitignore | 1 +
jwtToken.txt | 2 +-
.../controller/AdminAPIController.java | 115 +-
.../controller/Admincontroller.java | 487 ++-
.../controller/HQAPIController.java | 1502 ++++++++++
.../controller/HeadquartersController.java | 74 +
.../controller/OfficerAPIController.java | 1119 ++++---
.../controller/OfficerController.java | 20 +
.../controller/UserAPIController.java | 58 +-
.../communityHall/entity/FloorDetails.java | 142 +-
.../gcc/communityHall/entity/HallDetails.java | 2 +
.../TransactionResponseRepository.java | 85 +-
.../repository/BookingCalendarRepository.java | 80 +-
.../repository/BookingDetailsRepository.java | 3 +
.../repository/FloorDetailsRepository.java | 22 +-
.../repository/GccBlockingDateRepository.java | 29 +-
.../communityHall/service/BookingService.java | 258 +-
.../service/HallDetailService.java | 99 +-
.../service/Impl/BookingServiceImpl.java | 350 ++-
.../service/Impl/HallDetailServiceImpl.java | 264 +-
src/main/resources/paymentConfig.properties | 2 +-
.../resources/templates/admin/developer.html | 467 +--
.../templates/admin/gccblocking-new.html | 1033 +++++++
.../templates/admin/halldetailslist.html | 2669 ++++++++---------
.../templates/admin/login-creation.html | 1543 ++++++++++
.../templates/fragments/adminMenu.html | 21 +-
.../templates/fragments/headquartersMenu.html | 18 +-
.../templates/fragments/menuOfficer.html | 6 +
.../headquarters/gccblocking-new.html | 1044 +++++++
.../headquarters/halldetailslist.html | 1862 ++++++++++++
.../templates/officer/gccblocking-new.html | 1154 +++++++
.../resources/templates/officiallogin.html | 1265 ++++----
.../templates/user/hallbookingform.html | 132 +-
.../templates/user/viewhallform.html | 1204 ++++----
.../resources/templates/user/viewhistory.html | 61 +-
36 files changed, 13278 insertions(+), 3921 deletions(-)
create mode 100644 src/main/java/com/gcc/communityHall/controller/HQAPIController.java
create mode 100644 src/main/resources/templates/admin/gccblocking-new.html
create mode 100644 src/main/resources/templates/admin/login-creation.html
create mode 100644 src/main/resources/templates/headquarters/gccblocking-new.html
create mode 100644 src/main/resources/templates/headquarters/halldetailslist.html
create mode 100644 src/main/resources/templates/officer/gccblocking-new.html
diff --git a/.classpath b/.classpath
index d91be04b..2d9bac5e 100644
--- a/.classpath
+++ b/.classpath
@@ -39,17 +39,11 @@
-
-
-
-
-
-
diff --git a/.gitignore b/.gitignore
index c2187eec..422e7586 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,3 +5,4 @@ target/classes/
target/classes/application-dev.properties
target/classes/application-prod.properties
+/communityHallDocuments_test
diff --git a/jwtToken.txt b/jwtToken.txt
index 944441b6..9014d974 100644
--- a/jwtToken.txt
+++ b/jwtToken.txt
@@ -1 +1 @@
-eyJhbGciOiJIUzUxMiJ9.eyJ1c2VyVHlwZSI6ImhlYWRxdWFydGVycyIsImhhbGxJZCI6MywiaGFsbElkcyI6IjMiLCJtb2JpbGVOdW1iZXIiOjEyMzQ1Njc4OTEsImVtcGxveWVlSWQiOiI2Iiwiem9uZSI6IjAwIiwiZXhwIjoxNzgxNTA2NDEwfQ.GsMmYYsPT_S2rsgB_q1hFaX-2uu3Z1HvKwijAbA1Ck5ruG9Q2JaV_ZGZGic-Jl0LLRUPHi5Xs_6jCvfg6UbiNA
\ No newline at end of file
+eyJhbGciOiJIUzUxMiJ9.eyJ1c2VyVHlwZSI6ImhlYWRxdWFydGVycyIsImhhbGxJZCI6MCwiaGFsbElkcyI6IiIsIm1vYmlsZU51bWJlciI6OTUxNzUzODUyNCwiem9uZSI6IjAwIiwiZXhwIjoxNzgzOTI4NDY4fQ.JDuWljfRXzemAjgmLj4MFq3DgmL9Z1hbE8_LoLpQQ0jLZp4wBbyvmEopk9BHmWtzh8SlDN6dxQHEJDsxTRt0_Q
\ No newline at end of file
diff --git a/src/main/java/com/gcc/communityHall/controller/AdminAPIController.java b/src/main/java/com/gcc/communityHall/controller/AdminAPIController.java
index 02c703a8..946aea7c 100644
--- a/src/main/java/com/gcc/communityHall/controller/AdminAPIController.java
+++ b/src/main/java/com/gcc/communityHall/controller/AdminAPIController.java
@@ -543,16 +543,8 @@ public class AdminAPIController {
@Operation(summary = " GCC Blocked Booking Details REST API", description = "REST API to get the GCC Blocked BookingDetails")
// retrieving the GCC Blocked BookingDetails
@GetMapping("/blockedevents")
- public ResponseEntity> getBlockedEvents(
- @RequestParam("fromDate") @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate fromDate,
- @RequestParam("toDate") @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate toDate,
- @RequestParam("hallIds") List hallIds) {
- // System.out.println("Blocked Events Request - fromDate: " + fromDate + ",
- // toDate: " + toDate + ", hallIds: " + hallIds );
- List blockedBookings = bookingService.getBlockedEvents(fromDate, toDate, hallIds);
-
- // List bookingDetails =
- // bookingService.getByBookingId(fromDate,toDate,hallIds,blockingId,bookingId);
+ public ResponseEntity> getBlockedEvents() {
+ List blockedBookings = bookingService.getBlockedEvents();
if (blockedBookings.isEmpty()) {
// System.out.println("No blocked bookings found.");
@@ -579,50 +571,69 @@ public class AdminAPIController {
return ResponseEntity.status(HttpStatus.NOT_FOUND).body("Blocking ID not found.");
}
- // Get the booking IDs from the blocking date entity
+ // Get the booking IDs from the blocking date entity (may be null/empty for
+ // block-only entries)
String bookingIds = blockingDate.getBookingIds();
String hallIds = blockingDate.getHallId();
- // Convert the booking IDs to a list of integers
- List bookingIdList = Arrays.stream(bookingIds.split(","))
- .map(Integer::parseInt)
- .collect(Collectors.toList());
+ // Parse booking IDs only if present
+ List bookingIdList = (bookingIds != null && !bookingIds.trim().isEmpty())
+ ? Arrays.stream(bookingIds.split(","))
+ .map(String::trim)
+ .filter(s -> !s.isEmpty())
+ .map(Integer::parseInt)
+ .collect(Collectors.toList())
+ : Collections.emptyList();
// Convert the hall IDs to a list of longs if provided
- List hallIdList = hallIds != null ? Arrays.stream(hallIds.split(","))
- .map(Long::parseLong)
- .collect(Collectors.toList())
+ List hallIdList = (hallIds != null && !hallIds.trim().isEmpty())
+ ? Arrays.stream(hallIds.split(","))
+ .map(Long::parseLong)
+ .collect(Collectors.toList())
: Collections.emptyList();
// Fetch the booking calendar entries within the date range
List bookingCalendars = bookingService.getBookedslots(fromDate, endDate, hallIdList);
- if (bookingCalendars.isEmpty()) {
- return ResponseEntity.status(HttpStatus.NOT_FOUND)
- .body("No booking slots found for the given date range and hall IDs.");
- }
-
- // Iterate over bookingCalendars and update them as needed
+ // ── Smart unblock: per-slot decision ──────────────────────────────────
+ // If morning+evening+is_blocked are all true AND an APPROVED user booking
+ // exists for that hall/date → only clear is_blocked (leave slots intact).
+ // Otherwise (GCC-owned slot) → clear everything.
for (BookingCalendar bookingslots : bookingCalendars) {
- bookingslots.setBookingId_1(null);
- bookingslots.setBookingId_2(null);
- bookingslots.setMorningSlot(false);
- bookingslots.setEveningSlot(false);
- bookingslots.setIs_blocked(false);
+ if (bookingslots.isMorningSlot() && bookingslots.isEveningSlot() && bookingslots.getIs_blocked()) {
+ List approvedBookings = bookingDetailsRepository.findByHallIdAndDate(
+ bookingslots.getBdate(), bookingslots.getHallId());
+ if (!approvedBookings.isEmpty()) {
+ // Approved user booking owns the slots — only remove gcc flag
+ bookingslots.setIs_blocked(false);
+ } else {
+ // GCC owned this slot fully — release everything
+ bookingslots.setBookingId_1(null);
+ bookingslots.setBookingId_2(null);
+ bookingslots.setMorningSlot(false);
+ bookingslots.setEveningSlot(false);
+ bookingslots.setIs_blocked(false);
+ }
+ } else {
+ // Partial slot scenario — only clear the gcc overlay flag
+ bookingslots.setIs_blocked(false);
+ }
bookingCalendarRepository.save(bookingslots);
}
blockingDate.setBlockedStatus(GccBlockingDate.BlockedStatus.UNBLOCKED);
blockingDateRepository.save(blockingDate);
- // Process each bookingId and update the booking details
+ // Update GCC_BLOCKED booking_details entries back to GCC_UNBLOCKED
for (int bookingId : bookingIdList) {
Optional bookingDetails = bookingDetailsRepo.findById(bookingId);
if (bookingDetails.isPresent()) {
BookingDetails bookings = bookingDetails.get();
- bookings.setBookingStatus(BookingDetails.BookingStatus.GCC_UNBLOCKED);
- bookings.setRefundStatus(BookingDetails.RefundStatus.NA);
- bookingDetailsRepo.save(bookings);
+ if (bookings.getBookingStatus() == BookingDetails.BookingStatus.GCC_BLOCKED) {
+ bookings.setBookingStatus(BookingDetails.BookingStatus.GCC_UNBLOCKED);
+ bookings.setRefundStatus(BookingDetails.RefundStatus.NA);
+ bookingDetailsRepo.save(bookings);
+ }
}
}
String adminname = (String) session.getAttribute("usertype");
@@ -755,6 +766,44 @@ public class AdminAPIController {
return hallService.getHallImages(hallId);
}
+ @Operation(summary = "GCC Block Without Cancelling REST API", description = "REST API to Block halls without cancelling existing bookings (smart slot logic)")
+ @PostMapping("/blockWithoutCancel")
+ public ResponseEntity blockWithoutCancel(
+ @RequestParam("fromDate") String fromDate,
+ @RequestParam("toDate") String toDate,
+ @RequestParam("hallID") String hallID,
+ @RequestParam("reasonforblocking") String reasonforblocking,
+ @RequestParam(value = "description", required = false) String[] descriptions,
+ @RequestParam(value = "document", required = false) MultipartFile[] documents,
+ HttpSession session) {
+
+ String updatedBy = (String) session.getAttribute("employeeId");
+ List hallIdsList = Arrays.stream(hallID.split(","))
+ .map(Long::parseLong)
+ .collect(Collectors.toList());
+
+ bookingService.blockWithoutCancellingBookings(fromDate, toDate, hallIdsList, reasonforblocking,
+ updatedBy, descriptions, documents);
+
+ String adminname = (String) session.getAttribute("usertype");
+ Integer loginid = (Integer) session.getAttribute("id");
+ ApplicationLogs logs = new ApplicationLogs();
+ logs.setComments("Action by " + adminname);
+ logs.setLoginId(loginid);
+ logs.setLogType("Gcc Block Without Cancel for the Reason:-" + reasonforblocking);
+ InetAddress inetAddress;
+ try {
+ inetAddress = InetAddress.getLocalHost();
+ String hostname = InetAddress.getLocalHost().getHostName();
+ logs.setIpaddress(inetAddress.getHostAddress());
+ logs.setSystemName(hostname);
+ } catch (UnknownHostException e) {
+ e.printStackTrace();
+ }
+ applicationLogsRepository.save(logs);
+ return ResponseEntity.ok("Success");
+ }
+
@Operation(summary = "GCC Blocking REST API", description = "REST API to Block the Halls by Admin")
// GccBlocking Api
@PostMapping("/cancelAll")
diff --git a/src/main/java/com/gcc/communityHall/controller/Admincontroller.java b/src/main/java/com/gcc/communityHall/controller/Admincontroller.java
index 355ae670..045ff91c 100644
--- a/src/main/java/com/gcc/communityHall/controller/Admincontroller.java
+++ b/src/main/java/com/gcc/communityHall/controller/Admincontroller.java
@@ -30,6 +30,7 @@ import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException;
import org.springframework.web.multipart.MultipartFile;
@@ -43,6 +44,8 @@ import com.gcc.communityHall.entity.HallDetails;
import com.gcc.communityHall.entity.Notification;
import com.gcc.communityHall.entity.Settlement;
import com.gcc.communityHall.entity.Users;
+import com.gcc.communityHall.entity.Login;
+import com.gcc.communityHall.entity.LoginHallId;
import com.gcc.communityHall.others.UserSession;
import com.gcc.communityHall.paymentService.entity.TransactionResponse;
import com.gcc.communityHall.paymentService.repository.TransactionResponseRepository;
@@ -54,12 +57,15 @@ import com.gcc.communityHall.repository.HallDetailsRepository;
import com.gcc.communityHall.repository.NotificationRepository;
import com.gcc.communityHall.repository.SettlementRepository;
import com.gcc.communityHall.repository.UsersRepository;
+import com.gcc.communityHall.repository.LoginHallIdRepository;
+import com.gcc.communityHall.repository.LoginRepository;
import com.gcc.communityHall.service.BookingService;
import com.gcc.communityHall.service.HallDetailService;
import com.gcc.communityHall.service.ReasonMasterService;
import com.gcc.communityHall.service.UserService;
import jakarta.servlet.http.HttpSession;
+import jakarta.transaction.Transactional;
@Controller
@RequestMapping("/communityhall/admin")
@@ -110,6 +116,12 @@ public class Admincontroller {
@Autowired
private TransactionResponseRepository transactionResponseRepository;
+ @Autowired
+ private LoginRepository loginRepository;
+
+ @Autowired
+ private LoginHallIdRepository loginHallIdRepository;
+
@GetMapping("/dashboard")
public String viewDashboard(
@RequestParam(required = false, defaultValue = "all zones") String zone,
@@ -120,7 +132,7 @@ public class Admincontroller {
// Validate JWT token
if (token != null && jwtUtil.validateToken(token)) {
- //System.out.println("tokennnnnnnnnnnnnnns"+token);
+ // System.out.println("tokennnnnnnnnnnnnnns"+token);
// Token is valid, proceed with dashboard logic
String adminName = (String) session.getAttribute("usertype");
long mobileno = (long) session.getAttribute("mobileno");
@@ -147,7 +159,6 @@ public class Admincontroller {
}
}
-
@GetMapping("/Reports")
public String viewReports(Model model, HttpSession session) {
String adminname = (String) session.getAttribute("usertype");
@@ -174,7 +185,6 @@ public class Admincontroller {
}
}
-
@GetMapping("/HallDetails")
public String viewHallDetails(Model model, HttpSession session) {
String adminname = (String) session.getAttribute("usertype");
@@ -263,9 +273,9 @@ public class Admincontroller {
List cancelledbookings = bookingDetailsRepository.findAllSettlementCancelledList();
List rejectedbookings = bookingDetailsRepository.findAllSettlementRejectedList();
model.addAttribute("settlementlist", settlement);
- //AKI
+ // AKI
List settlementIntiated = bookingDetailsRepository.findSettlementInitiatedPending();
- model.addAttribute("settlementIntiated", settlementIntiated);
+ model.addAttribute("settlementIntiated", settlementIntiated);
model.addAttribute("cancelledbookings", cancelledbookings);
model.addAttribute("rejectedbookings", rejectedbookings);
System.out.println("Settlement List: " + settlement);
@@ -287,8 +297,10 @@ public class Admincontroller {
String zone = (String) session.getAttribute("zone");
model.addAttribute("zone", zone);
List settlementrefundfailed = bookingDetailsRepository.findAllSettlementRefundFailed();
- List refundfailedcancelledbookings = bookingDetailsRepository.findAllRefundFaileCancelledList();
- List refundfailedrejectedbookings = bookingDetailsRepository.findAllRefundFaileRejectedList();
+ List refundfailedcancelledbookings = bookingDetailsRepository
+ .findAllRefundFaileCancelledList();
+ List refundfailedrejectedbookings = bookingDetailsRepository
+ .findAllRefundFaileRejectedList();
model.addAttribute("settlementrefundfailed", settlementrefundfailed);
model.addAttribute("refundfailedcancelledbookings", refundfailedcancelledbookings);
model.addAttribute("refundfailedrejectedbookings", refundfailedrejectedbookings);
@@ -392,6 +404,20 @@ public class Admincontroller {
}
}
+ // ── New enhanced GCC Blocking page (does NOT affect the existing page) ──
+ @GetMapping("/GccblockingNew")
+ public String viewGccBlockingNew(Model model, HttpSession session) {
+ String adminname = (String) session.getAttribute("usertype");
+ if (adminname != null) {
+ long mobileno = (long) session.getAttribute("mobileno");
+ model.addAttribute("mobileno", mobileno);
+ model.addAttribute("adminname", adminname);
+ return "admin/gccblocking-new";
+ } else {
+ session.invalidate();
+ return "redirect:/communityhall/login";
+ }
+ }
// Utility method to ensure distinct by a key
private static Predicate distinctByKey(Function super T, ?> keyExtractor) {
@@ -410,7 +436,7 @@ public class Admincontroller {
@RequestParam float hallArea,
@RequestParam String ebNumber,
@RequestParam float ebCostPerUnit,
- @RequestParam int parkingCapacity,
+ @RequestParam String parkingCapacity,
@RequestParam int seatingCapacity,
@RequestParam String doorNo,
@RequestParam String street,
@@ -426,8 +452,10 @@ public class Admincontroller {
@RequestParam long hallInchargeNo,
@RequestParam("hallImages") MultipartFile[] hallImages, HttpSession session) {
String updatedId = (String) session.getAttribute("employeeId");
- hallDetailService.saveHall(hallName, depositAmount, halfDayAmt, fullDayAmt, gst, hallArea, ebNumber, ebCostPerUnit, parkingCapacity, seatingCapacity, doorNo,
- street, area, zone, division, landMark, city, pinCode, latitude, longitude, hallInchargeName, hallInchargeNo, updatedId, hallImages, halfdepositAmt);
+ hallDetailService.saveHallByAdmin(hallName, depositAmount, halfDayAmt, fullDayAmt, gst, hallArea, ebNumber,
+ ebCostPerUnit, parkingCapacity, seatingCapacity, doorNo,
+ street, area, zone, division, landMark, city, pinCode, latitude, longitude, hallInchargeName,
+ hallInchargeNo, updatedId, hallImages, halfdepositAmt);
String adminname = (String) session.getAttribute("usertype");
Integer loginid = (Integer) session.getAttribute("id");
ApplicationLogs logs = new ApplicationLogs();
@@ -444,7 +472,8 @@ public class Admincontroller {
e.printStackTrace();
}
applicationLogsRepository.save(logs);
- // Redirect to a success page or return a ModelAndView as per your application flow
+ // Redirect to a success page or return a ModelAndView as per your application
+ // flow
return "redirect:/communityhall/admin/halldetailslist";
}
@@ -558,48 +587,60 @@ public class Admincontroller {
@PostMapping("/getReport")
public String generateReport(Model model,
- @RequestParam(name = "FromDate") @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) String fromDate,
- @RequestParam(name = "ToDate") @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) String toDate,
- @RequestParam(name = "request") String request,
- @RequestParam(name = "userstatus", required = false) String userstatus,
- @RequestParam(name = "usertype", required = false) String usertype,
- @RequestParam(name = "bookingStatus", required = false) String bookingStatus,
- @RequestParam(name = "refundStatus", required = false) String refundStatus,
- @RequestParam(name = "paymentStatus", required = false) String paymentStatus,
- @RequestParam(name = "filterby", required = false) String filterby,
- @RequestParam(name = "zone1", required = false, defaultValue = "ALL") String zone,
- @RequestParam(name = "division1", required = false, defaultValue = "ALL") String division,
- @RequestParam(name = "hall1", required = false) Integer hallid,
- @RequestParam(name = "basedon", required = false) String basedon,
- @RequestParam(name = "bookingId", required = false) Long bookingId,
- @RequestParam(name = "reporttype", required = false) String reporttype,
- @RequestParam(name = "counterId", required = false) String counterId, HttpSession session) throws JsonProcessingException {
+ @RequestParam(name = "FromDate") @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) String fromDate,
+ @RequestParam(name = "ToDate") @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) String toDate,
+ @RequestParam(name = "request") String request,
+ @RequestParam(name = "userstatus", required = false) String userstatus,
+ @RequestParam(name = "usertype", required = false) String usertype,
+ @RequestParam(name = "bookingStatus", required = false) String bookingStatus,
+ @RequestParam(name = "refundStatus", required = false) String refundStatus,
+ @RequestParam(name = "paymentStatus", required = false) String paymentStatus,
+ @RequestParam(name = "filterby", required = false) String filterby,
+ @RequestParam(name = "zone1", required = false, defaultValue = "ALL") String zone,
+ @RequestParam(name = "division1", required = false, defaultValue = "ALL") String division,
+ @RequestParam(name = "hall1", required = false) Integer hallid,
+ @RequestParam(name = "basedon", required = false) String basedon,
+ @RequestParam(name = "bookingId", required = false) Long bookingId,
+ @RequestParam(name = "reporttype", required = false) String reporttype,
+ @RequestParam(name = "counterId", required = false) String counterId, HttpSession session)
+ throws JsonProcessingException {
String adminname = (String) session.getAttribute("usertype");
if (adminname != null) {
long mobileno = (long) session.getAttribute("mobileno");
model.addAttribute("mobileno", mobileno);
List userList = handleUserRequest(request, fromDate, toDate, userstatus, usertype);
- List