From 6c0cbc662e0b61a0e8b357406df26e4b8d65480c Mon Sep 17 00:00:00 2001 From: yoganandhan Date: Thu, 30 Apr 2026 15:05:49 +0530 Subject: [PATCH] changes in food distribution api controller and service and pages newly added detailed report --- .../FoodDistrubutionReportApiController.java | 34 +- .../controller/MainController.java | 5 + .../service/Fooddistributionservice.java | 47 +- .../fooddistributiondetailedreport.html | 566 ++++++++++++++++++ .../fooddistributionreport.html | 59 +- 5 files changed, 697 insertions(+), 14 deletions(-) create mode 100644 src/main/resources/templates/modules/fooddistribution/fooddistributiondetailedreport.html diff --git a/src/main/java/com/gcc/commissionerreview/controller/FoodDistrubutionReportApiController.java b/src/main/java/com/gcc/commissionerreview/controller/FoodDistrubutionReportApiController.java index 0571574..cc1a3ac 100644 --- a/src/main/java/com/gcc/commissionerreview/controller/FoodDistrubutionReportApiController.java +++ b/src/main/java/com/gcc/commissionerreview/controller/FoodDistrubutionReportApiController.java @@ -34,6 +34,34 @@ public class FoodDistrubutionReportApiController { return ResponseEntity.ok(response); } + @GetMapping("/hubs") + public ResponseEntity> getHubs() { + Map response = new HashMap<>(); + try { + List> hubs = fooddistributionservice.getHubs(); + response.put("status", "success"); + response.put("data", hubs); + } catch (Exception e) { + response.put("status", "error"); + response.put("message", e.getMessage()); + } + return ResponseEntity.ok(response); + } + + @GetMapping("/shifts") + public ResponseEntity> getShiftsWise() { + Map response = new HashMap<>(); + try { + List> shifts = fooddistributionservice.getShifts(); + response.put("status", "success"); + response.put("data", shifts); + } catch (Exception e) { + response.put("status", "error"); + response.put("message", e.getMessage()); + } + return ResponseEntity.ok(response); + } + @GetMapping("/complianceAbstract") public ResponseEntity> getComplianceAbstractReport( @RequestParam(value = "fromDate", required = false) String fromDate, @@ -55,10 +83,10 @@ public class FoodDistrubutionReportApiController { public ResponseEntity> getComplianceDetailedReport( @RequestParam(value = "fromDate", required = false) String fromDate, @RequestParam(value = "toDate", required = false) String toDate, - @RequestParam("hubId") Integer hubId, + @RequestParam(value = "hubId", required = false) Integer hubId, @RequestParam(value = "shiftId", required = false) Integer shiftId, - @RequestParam("qid") Integer qid, - @RequestParam("statusFilter") String statusFilter) { + @RequestParam(value = "qid", required = false) Integer qid, + @RequestParam(value = "statusFilter", required = false) String statusFilter) { Map response = new HashMap<>(); try { List> detailedData = fooddistributionservice.getComplianceDetailedReport(fromDate, diff --git a/src/main/java/com/gcc/commissionerreview/controller/MainController.java b/src/main/java/com/gcc/commissionerreview/controller/MainController.java index d2a4e6e..bdbaece 100644 --- a/src/main/java/com/gcc/commissionerreview/controller/MainController.java +++ b/src/main/java/com/gcc/commissionerreview/controller/MainController.java @@ -306,4 +306,9 @@ public class MainController { return "modules/fooddistribution/fooddistributionreport"; } + @GetMapping("/fooddistributiondetailedreport") + public String fooddistributiondetailedreport(Model model) { + return "modules/fooddistribution/fooddistributiondetailedreport"; + } + } diff --git a/src/main/java/com/gcc/commissionerreview/service/Fooddistributionservice.java b/src/main/java/com/gcc/commissionerreview/service/Fooddistributionservice.java index fa90951..30a9600 100644 --- a/src/main/java/com/gcc/commissionerreview/service/Fooddistributionservice.java +++ b/src/main/java/com/gcc/commissionerreview/service/Fooddistributionservice.java @@ -34,6 +34,20 @@ public class Fooddistributionservice { return jdbcTemplate.queryForList(sql); } + public List> getHubs() { + String sql = "SELECT id as hub_id, " + + "CONCAT(IFNULL(NULLIF(si_name, ''), CONCAT('Kitchen ', id)), " + + "IF(permanent_location IS NOT NULL AND permanent_location != '', CONCAT(' - ', permanent_location), '')) as hub_name " + + + "FROM hub_master WHERE is_active = 1 AND is_delete = 0 ORDER BY id"; + return jdbcTemplate.queryForList(sql); + } + + public List> getShifts() { + String sql = "SELECT shiftid, name as shift_name FROM shift_master WHERE isactive = 1 AND isdelete = 0 ORDER BY orderby"; + return jdbcTemplate.queryForList(sql); + } + public List> getComplianceAbstractReport(String fromDate, String toDate) { String dateFilter = ""; java.util.List params = new java.util.ArrayList<>(); @@ -106,6 +120,21 @@ public class Fooddistributionservice { shiftFilter = " AND pa.shiftid = ? "; } + String hubFilter = ""; + if (hubId != null && hubId > 0) { + hubFilter = " AND hm.id = ? "; + } + + String qidFilter = ""; + if (qid != null && qid > 0) { + qidFilter = " AND pqm.qid = ? "; + } + + String statusFilter = ""; + if (status != null && !status.trim().isEmpty()) { + statusFilter = " AND pam.english_name = ? "; + } + String sql = "SELECT " + "pf.id, " + "DATE_FORMAT(pa.cdate, '%d/%m/%y %h:%i %p') AS auditDate, " + @@ -133,11 +162,11 @@ public class Fooddistributionservice { "FROM pmc_feedback pf " + "JOIN pmc_audit pa ON pa.id = pf.pmc_audit_id AND pa.isactive = 1 AND pa.isdelete = 0 " + dateFilter + shiftFilter + - "JOIN hub_master hm ON hm.id = pa.hub_id AND hm.id = ? " + + "JOIN hub_master hm ON hm.id = pa.hub_id " + hubFilter + "LEFT JOIN shift_master sm ON sm.shiftid = pa.shiftid AND sm.isactive = 1 AND sm.isdelete = 0 " + - "JOIN pmc_questions_master pqm ON pqm.qid = pf.questions AND pqm.qid = ? " + + "JOIN pmc_questions_master pqm ON pqm.qid = pf.questions " + qidFilter + "JOIN questions_category_master qcm ON qcm.qcm_id = pf.qcmid " + - "JOIN pmc_answer_master pam ON pam.aid = pf.answer AND pam.english_name = ? " + + "JOIN pmc_answer_master pam ON pam.aid = pf.answer " + statusFilter + "LEFT JOIN driver_login dl ON pa.cby = dl.loginid " + "LEFT JOIN driver_login dl2 ON pf.fs_cby = dl2.loginid " + "WHERE pf.isactive = 1 AND pf.isdelete = 0 " + @@ -146,9 +175,15 @@ public class Fooddistributionservice { if (shiftId != null && shiftId > 0) { params.add(shiftId); } - params.add(hubId); - params.add(qid); - params.add(status); + if (hubId != null && hubId > 0) { + params.add(hubId); + } + if (qid != null && qid > 0) { + params.add(qid); + } + if (status != null && !status.trim().isEmpty()) { + params.add(status); + } return jdbcTemplate.queryForList(sql, params.toArray()); } diff --git a/src/main/resources/templates/modules/fooddistribution/fooddistributiondetailedreport.html b/src/main/resources/templates/modules/fooddistribution/fooddistributiondetailedreport.html new file mode 100644 index 0000000..65b2d1f --- /dev/null +++ b/src/main/resources/templates/modules/fooddistribution/fooddistributiondetailedreport.html @@ -0,0 +1,566 @@ + + + + + Food Distribution Detailed Report + + + + + + + + + + + + + + +
+
+ Back to Abstract +

Food Distribution Detailed Report

+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ +
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
S.NoAudit DateShiftZoneWardAddressAudit CategoryQuestionAnswerKitchen SI NameRaised ByPMC RemarksPMC Image/Video ViewerFS StatusFS Challenged ByFS RemarksFS Image/Video ViewerCE StatusCE RemarksCE Updated ByPenalty Amount
+
+ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/templates/modules/fooddistribution/fooddistributionreport.html b/src/main/resources/templates/modules/fooddistribution/fooddistributionreport.html index 394ceb6..19dd6ad 100644 --- a/src/main/resources/templates/modules/fooddistribution/fooddistributionreport.html +++ b/src/main/resources/templates/modules/fooddistribution/fooddistributionreport.html @@ -155,6 +155,10 @@ filter: invert(1); } + .swal2-container.swal2-custom-zindex { + z-index: 1070 !important; + } + #modalDataTable th { white-space: normal !important; /* allow wrapping */ @@ -211,6 +215,10 @@
+
@@ -220,7 +228,7 @@ Zone + style="vertical-align: middle; white-space: normal; word-break: break-word; min-width: 150px; max-width: 200px;"> Kitchen Name / Address Shift @@ -389,6 +397,10 @@ var match = data.match(/showMedia\('([^']+)'/); if (match) return match[1]; } + if (typeof data === 'string' && data.indexOf('data-fulltext') !== -1) { + var match = data.match(/data-fulltext="([^"]+)"/); + if (match) return decodeURIComponent(match[1]); + } var div = document.createElement("div"); div.innerHTML = data; return div.textContent || div.innerText || ""; @@ -409,6 +421,10 @@ var match = data.match(/showMedia\('([^']+)'/); if (match) return match[1]; } + if (typeof data === 'string' && data.indexOf('data-fulltext') !== -1) { + var match = data.match(/data-fulltext="([^"]+)"/); + if (match) return decodeURIComponent(match[1]); + } var div = document.createElement("div"); div.innerHTML = data; return div.textContent || div.innerText || ""; @@ -667,7 +683,7 @@ if (index === 0) { tr.append('' + hub.zone + ''); - tr.append('' + hub.name_address + ''); + tr.append('' + hub.name_address + ''); } else { // Maintain perfect column counts for DataTables matrix validation to completely prevent tn/18 error! tr.append(''); @@ -784,14 +800,14 @@ item.english_name || '-', item.name || '-', item.raisedBy || '-', - item.pmcRemarks || '-', + formatRemark(item.pmcRemarks, 'PMC Remarks'), imgBtn, item.fsStatus || '-', item.fsChallengedBy || '-', - item.fsRemarks || '-', + formatRemark(item.fsRemarks, 'FS Remarks'), fsImgBtn, item.chief_engineer_status || '-', - item.chief_engineer_remarks || '-', + formatRemark(item.chief_engineer_remarks, 'CE Remarks'), item.chief_engineer || '-', finalPenalty ]); @@ -802,6 +818,32 @@ }, 300); } + function formatRemark(text, title) { + if (!text || text === '-' || String(text).trim() === '' || String(text) === 'null') { + return '-'; + } + var str = String(text); + if (str.length > 100) { + var truncated = $('
').text(str.substring(0, 100) + '...').html(); + var encodedText = encodeURIComponent(str); + return '' + truncated + ''; + } + return $('
').text(str).html(); + } + + function showFullRemark(title, encodedText) { + var text = decodeURIComponent(encodedText); + Swal.fire({ + title: title, + html: '
' + $('
').text(text).html() + '
', + width: '600px', + confirmButtonText: 'Close', + customClass: { + popup: 'swal2-custom-zindex' // Just in case it needs to be higher than bootstrap modal + } + }); + } + function showMedia(url, isVideo) { var mediaHtml = ''; if (isVideo) { @@ -942,6 +984,13 @@ } }); + // if (true) { + // var a = 5; + + // } + // console.log(a); + + // Error // Recalculate precisely after Bootstrap entirely finishes destroying modal padding