From 6d719818c24a7d99ec4cd2218848a57df7c94a17 Mon Sep 17 00:00:00 2001 From: AJITHKUMAR12 <48044092+AJITHKUMAR12@users.noreply.github.com> Date: Fri, 22 May 2026 11:45:02 +0530 Subject: [PATCH] added matser enable logic --- .../Service/ChildrenSurveyService.java | 168 ++++++++++++++---- .../modules/childrensurvey/childlist.html | 68 ++++++- .../modules/childrensurvey/surveylist.html | 2 + 3 files changed, 203 insertions(+), 35 deletions(-) diff --git a/gcc_officer_portal/src/main/java/in/gov/chennaicorporation/gccoffice/childrensurvey/Service/ChildrenSurveyService.java b/gcc_officer_portal/src/main/java/in/gov/chennaicorporation/gccoffice/childrensurvey/Service/ChildrenSurveyService.java index ced26691..2c170623 100644 --- a/gcc_officer_portal/src/main/java/in/gov/chennaicorporation/gccoffice/childrensurvey/Service/ChildrenSurveyService.java +++ b/gcc_officer_portal/src/main/java/in/gov/chennaicorporation/gccoffice/childrensurvey/Service/ChildrenSurveyService.java @@ -583,46 +583,149 @@ public class ChildrenSurveyService { * return rawAnswer; * } */ + /* + * public List> getSurveyorsList( + * String name, + * String area, + * String fromDate, + * String toDate) { + * // ld.survey_id AS surveyor_id, + * StringBuilder sql = new StringBuilder(""" + * + * SELECT + * + * + * d.user_name, + * d.mobile_no, + * ld.loginId, + * lm.id as location_id, + * + * + * MAX(lm.english_name) AS area, + * + * COUNT(DISTINCT ld.survey_id) AS total_survey_done, + * + * DATE(MAX(sr.cdate)) AS survey_date + * + * FROM login_details d + * + * INNER JOIN surveyor_location_details ld + * ON d.uid = ld.loginId + * + * INNER JOIN child_survey_response sr + * ON sr.survey_id = ld.survey_id + * + * LEFT JOIN child_survey_response csr + * ON csr.survey_id = ld.survey_id + * AND csr.qid = 1 + * + * LEFT JOIN location_master lm + * ON lm.id = csr.answer + * + * WHERE sr.isactive = 1 + * AND sr.isdelete = 0 + * + * """); + * + * List params = new ArrayList<>(); + * + * // NAME FILTER + * if (name != null && !name.isEmpty()) { + * + * sql.append(""" + * AND d.user_name LIKE ? + * """); + * + * params.add("%" + name + "%"); + * } + * + * // AREA FILTER + * if (area != null && !area.isEmpty()) { + * + * sql.append(""" + * AND csr.answer = ? + * """); + * + * params.add(area); + * } + * + * // DATE FILTER + * if (fromDate != null + * && toDate != null + * && !fromDate.isEmpty() + * && !toDate.isEmpty()) { + * + * sql.append(""" + * AND DATE(sr.cdate) BETWEEN ? AND ? + * """); + * + * params.add(fromDate); + * params.add(toDate); + * } + * // ld.survey_id, + * sql.append(""" + * + * GROUP BY + * + * d.user_name, + * d.mobile_no, + * ld.loginId, + * lm.id + * + * ORDER BY + * MAX(sr.cdate) DESC + * + * """); + * + * return jdbcTemplate.queryForList( + * sql.toString(), + * params.toArray()); + * } + */ public List> getSurveyorsList( String name, String area, String fromDate, String toDate) { - // ld.survey_id AS surveyor_id, - StringBuilder sql = new StringBuilder(""" - - SELECT + StringBuilder sql = new StringBuilder(""" - d.user_name, - d.mobile_no, - ld.loginId, - lm.id as location_id, + SELECT + d.user_name, + d.mobile_no, + ld.loginId, + lm.id AS location_id, - MAX(lm.english_name) AS area, + MAX(lm.english_name) AS area, - COUNT(DISTINCT ld.survey_id) AS total_survey_done, + COUNT(DISTINCT ld.survey_id) AS total_survey_done, - DATE(MAX(sr.cdate)) AS survey_date + DATE(sr.cdate) AS survey_date - FROM login_details d + FROM login_details d - INNER JOIN surveyor_location_details ld - ON d.uid = ld.loginId + INNER JOIN surveyor_location_details ld + ON d.uid = ld.loginId - INNER JOIN child_survey_response sr - ON sr.survey_id = ld.survey_id + INNER JOIN ( + SELECT DISTINCT + survey_id, + DATE(cdate) AS cdate + FROM child_survey_response + WHERE isactive = 1 + AND isdelete = 0 + ) sr + ON sr.survey_id = ld.survey_id - LEFT JOIN child_survey_response csr - ON csr.survey_id = ld.survey_id - AND csr.qid = 1 + LEFT JOIN child_survey_response csr + ON csr.survey_id = ld.survey_id + AND csr.qid = 1 - LEFT JOIN location_master lm - ON lm.id = csr.answer + LEFT JOIN location_master lm + ON lm.id = csr.answer - WHERE sr.isactive = 1 - AND sr.isdelete = 0 + WHERE 1 = 1 """); @@ -661,18 +764,19 @@ public class ChildrenSurveyService { params.add(fromDate); params.add(toDate); } - // ld.survey_id, + sql.append(""" - GROUP BY + GROUP BY - d.user_name, - d.mobile_no, - ld.loginId, - lm.id + d.user_name, + d.mobile_no, + ld.loginId, + lm.id, + DATE(sr.cdate) - ORDER BY - MAX(sr.cdate) DESC + ORDER BY + DATE(sr.cdate) DESC """); @@ -866,7 +970,7 @@ public class ChildrenSurveyService { ( COUNT(DISTINCT CASE WHEN qid = 25 - AND answer = 1 + AND answer = 9 THEN survey_id END) * 100.0 diff --git a/gcc_officer_portal/src/main/resources/templates/modules/childrensurvey/childlist.html b/gcc_officer_portal/src/main/resources/templates/modules/childrensurvey/childlist.html index b2f87500..89779b5b 100644 --- a/gcc_officer_portal/src/main/resources/templates/modules/childrensurvey/childlist.html +++ b/gcc_officer_portal/src/main/resources/templates/modules/childrensurvey/childlist.html @@ -541,7 +541,7 @@ let slno = 1; - for (const rowNode of rows) { + /*for (const rowNode of rows) { // GET SURVEY ID FROM TABLE let surveyId = $(rowNode[1]).text() || rowNode[1]; @@ -583,6 +583,50 @@ excelData.push(rowData); + slno++; + }*/ + for (const rowNode of rows) { + + let surveyId = $(rowNode[1]).text() || rowNode[1]; + + surveyId = surveyId.toString().trim(); + + // SKIP EMPTY ROWS + if (!surveyId || surveyId === "") { + continue; + } + + let surveyData = await $.ajax({ + url: "/gcc/api/children-survey/details", + type: "GET", + data: { + surveyId: surveyId + } + }); + + let allQuestions = { + + ...surveyData.personalInformation, + ...surveyData.locationDetails, + ...surveyData.educationDetails, + ...surveyData.healthDetails, + ...surveyData.documentDetails, + ...surveyData.vulnerabilityDetails + }; + + let rowData = { + "S.No": slno, + "Survey ID": surveyId + }; + + Object.keys(allQuestions).forEach(function (question) { + + rowData[question] = allQuestions[question]; + + }); + + excelData.push(rowData); + slno++; } @@ -590,16 +634,34 @@ const worksheet = XLSX.utils.json_to_sheet(excelData); // AUTO COLUMN WIDTH - const columns = []; + //const columns = []; - Object.keys(excelData[0]).forEach(function () { + /*Object.keys(excelData[0]).forEach(function () { columns.push({ wch: 30 }); }); + worksheet['!cols'] = columns;*/ + const columns = []; + + Object.keys(excelData[0]).forEach(function (key) { + + if (key === "S.No") { + + columns.push({ wch: 8 }); + + } else { + + columns.push({ wch: 25 }); + + } + + }); + worksheet['!cols'] = columns; + // CREATE WORKBOOK const workbook = XLSX.utils.book_new(); diff --git a/gcc_officer_portal/src/main/resources/templates/modules/childrensurvey/surveylist.html b/gcc_officer_portal/src/main/resources/templates/modules/childrensurvey/surveylist.html index 56395a25..05379e80 100644 --- a/gcc_officer_portal/src/main/resources/templates/modules/childrensurvey/surveylist.html +++ b/gcc_officer_portal/src/main/resources/templates/modules/childrensurvey/surveylist.html @@ -419,6 +419,8 @@ });*/ $(document).ready(function () { + $("#fromDate").val(''); + $("#toDate").val(''); // 🔹 Load dropdowns when page loads loadDropdowns();