Browse Source

added matser enable logic

main
AJITHKUMAR12 5 months ago
parent
commit
6d719818c2
  1. 128
      gcc_officer_portal/src/main/java/in/gov/chennaicorporation/gccoffice/childrensurvey/Service/ChildrenSurveyService.java
  2. 68
      gcc_officer_portal/src/main/resources/templates/modules/childrensurvey/childlist.html
  3. 2
      gcc_officer_portal/src/main/resources/templates/modules/childrensurvey/surveylist.html

128
gcc_officer_portal/src/main/java/in/gov/chennaicorporation/gccoffice/childrensurvey/Service/ChildrenSurveyService.java

@ -583,35 +583,139 @@ public class ChildrenSurveyService {
* return rawAnswer; * return rawAnswer;
* } * }
*/ */
/*
* public List<Map<String, Object>> 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<Object> 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<Map<String, Object>> getSurveyorsList( public List<Map<String, Object>> getSurveyorsList(
String name, String name,
String area, String area,
String fromDate, String fromDate,
String toDate) { String toDate) {
// ld.survey_id AS surveyor_id,
StringBuilder sql = new StringBuilder(""" StringBuilder sql = new StringBuilder("""
SELECT SELECT
d.user_name, d.user_name,
d.mobile_no, d.mobile_no,
ld.loginId, ld.loginId,
lm.id as location_id,
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 INNER JOIN surveyor_location_details ld
ON d.uid = ld.loginId ON d.uid = ld.loginId
INNER JOIN child_survey_response sr
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 ON sr.survey_id = ld.survey_id
LEFT JOIN child_survey_response csr LEFT JOIN child_survey_response csr
@ -621,8 +725,7 @@ public class ChildrenSurveyService {
LEFT JOIN location_master lm LEFT JOIN location_master lm
ON lm.id = csr.answer ON lm.id = csr.answer
WHERE sr.isactive = 1
AND sr.isdelete = 0
WHERE 1 = 1
"""); """);
@ -661,7 +764,7 @@ public class ChildrenSurveyService {
params.add(fromDate); params.add(fromDate);
params.add(toDate); params.add(toDate);
} }
// ld.survey_id,
sql.append(""" sql.append("""
GROUP BY GROUP BY
@ -669,10 +772,11 @@ public class ChildrenSurveyService {
d.user_name, d.user_name,
d.mobile_no, d.mobile_no,
ld.loginId, ld.loginId,
lm.id
lm.id,
DATE(sr.cdate)
ORDER BY ORDER BY
MAX(sr.cdate) DESC
DATE(sr.cdate) DESC
"""); """);
@ -866,7 +970,7 @@ public class ChildrenSurveyService {
( (
COUNT(DISTINCT CASE COUNT(DISTINCT CASE
WHEN qid = 25 WHEN qid = 25
AND answer = 1
AND answer = 9
THEN survey_id THEN survey_id
END) END)
* 100.0 * 100.0

68
gcc_officer_portal/src/main/resources/templates/modules/childrensurvey/childlist.html

@ -541,7 +541,7 @@
let slno = 1; let slno = 1;
for (const rowNode of rows) {
/*for (const rowNode of rows) {
// GET SURVEY ID FROM TABLE // GET SURVEY ID FROM TABLE
let surveyId = $(rowNode[1]).text() || rowNode[1]; let surveyId = $(rowNode[1]).text() || rowNode[1];
@ -583,6 +583,50 @@
excelData.push(rowData); 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++; slno++;
} }
@ -590,16 +634,34 @@
const worksheet = XLSX.utils.json_to_sheet(excelData); const worksheet = XLSX.utils.json_to_sheet(excelData);
// AUTO COLUMN WIDTH // AUTO COLUMN WIDTH
const columns = [];
//const columns = [];
Object.keys(excelData[0]).forEach(function () {
/*Object.keys(excelData[0]).forEach(function () {
columns.push({ wch: 30 }); 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; worksheet['!cols'] = columns;
// CREATE WORKBOOK // CREATE WORKBOOK
const workbook = XLSX.utils.book_new(); const workbook = XLSX.utils.book_new();

2
gcc_officer_portal/src/main/resources/templates/modules/childrensurvey/surveylist.html

@ -419,6 +419,8 @@
});*/ });*/
$(document).ready(function () { $(document).ready(function () {
$("#fromDate").val('');
$("#toDate").val('');
// 🔹 Load dropdowns when page loads // 🔹 Load dropdowns when page loads
loadDropdowns(); loadDropdowns();

Loading…
Cancel
Save