From c69b31cc043093a238b20aa8b54ad9449a501248 Mon Sep 17 00:00:00 2001 From: AJITHKUMAR12 <48044092+AJITHKUMAR12@users.noreply.github.com> Date: Fri, 8 May 2026 17:49:05 +0530 Subject: [PATCH] Implemented childsurvey on officer portal --- .../Controller/ChildrenSurveyController.java | 89 ++ .../Controller/MainController.java | 26 + .../Service/ChildrenSurveyService.java | 853 ++++++++++++++++++ .../configuration/DataSourceConfig.java | 18 +- .../modules/childrensurvey/childlist.html | 527 +++++++++++ .../modules/childrensurvey/surveylist.html | 836 +++++++++++++++++ .../childrensurvey/surveyorsreports.html | 668 ++++++++++++++ 7 files changed, 3013 insertions(+), 4 deletions(-) create mode 100644 gcc_officer_portal/src/main/java/in/gov/chennaicorporation/gccoffice/childrensurvey/Controller/ChildrenSurveyController.java create mode 100644 gcc_officer_portal/src/main/java/in/gov/chennaicorporation/gccoffice/childrensurvey/Controller/MainController.java create mode 100644 gcc_officer_portal/src/main/java/in/gov/chennaicorporation/gccoffice/childrensurvey/Service/ChildrenSurveyService.java create mode 100644 gcc_officer_portal/src/main/resources/templates/modules/childrensurvey/childlist.html create mode 100644 gcc_officer_portal/src/main/resources/templates/modules/childrensurvey/surveylist.html create mode 100644 gcc_officer_portal/src/main/resources/templates/modules/childrensurvey/surveyorsreports.html diff --git a/gcc_officer_portal/src/main/java/in/gov/chennaicorporation/gccoffice/childrensurvey/Controller/ChildrenSurveyController.java b/gcc_officer_portal/src/main/java/in/gov/chennaicorporation/gccoffice/childrensurvey/Controller/ChildrenSurveyController.java new file mode 100644 index 00000000..e9935372 --- /dev/null +++ b/gcc_officer_portal/src/main/java/in/gov/chennaicorporation/gccoffice/childrensurvey/Controller/ChildrenSurveyController.java @@ -0,0 +1,89 @@ +package in.gov.chennaicorporation.gccoffice.childrensurvey.Controller; + +import java.util.List; +import java.util.Map; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.GetMapping; +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.bind.annotation.RestController; + +import in.gov.chennaicorporation.gccoffice.childrensurvey.Service.ChildrenSurveyService; + +@RestController +@RequestMapping("/gcc/api/children-survey") +public class ChildrenSurveyController { + + @Autowired + private ChildrenSurveyService service; + + @GetMapping("/gender") + public List> getGender() { + return service.getGender(); + } + + @GetMapping("/location") + public List> getLocation() { + return service.getLocation(); + } + + @GetMapping("/education") + public List> getEducation() { + return service.getEducation(); + } + + @GetMapping("/list") + public List> getSurveyList( + @RequestParam(required = false) String name, + @RequestParam(required = false) String gender, + @RequestParam(required = false) String age, + @RequestParam(required = false) String area, + @RequestParam(required = false) String education, + @RequestParam(required = false) String fromDate, + @RequestParam(required = false) String toDate) { + return service.getSurveyList(name, gender, age, area, education, fromDate, toDate); + } + + @GetMapping("/details") + public Map getSurveyDetails( + @RequestParam String surveyId) { + return service.getSurveyDetails(surveyId); + } + + @GetMapping("/getSurveyorsList") + @ResponseBody + public List> getSurveyorsList( + + @RequestParam(required = false) String name, + @RequestParam(required = false) String area, + @RequestParam(required = false) String fromDate, + @RequestParam(required = false) String toDate) { + + return service.getSurveyorsList( + name, + area, + fromDate, + toDate); + } + + @GetMapping("/survey-breakup") + @ResponseBody + public List> getSurveyBreakup( + + @RequestParam(required = false) String loginId, + @RequestParam(required = false) String locationId, + @RequestParam(required = false) String surveyDate) { + + return service.getSurveyBreakup(loginId, locationId, surveyDate); + } + + @GetMapping("/dashboard") + public Map dashboard() { + + return service.getDashboardData(); + } + +} diff --git a/gcc_officer_portal/src/main/java/in/gov/chennaicorporation/gccoffice/childrensurvey/Controller/MainController.java b/gcc_officer_portal/src/main/java/in/gov/chennaicorporation/gccoffice/childrensurvey/Controller/MainController.java new file mode 100644 index 00000000..f0d13fd0 --- /dev/null +++ b/gcc_officer_portal/src/main/java/in/gov/chennaicorporation/gccoffice/childrensurvey/Controller/MainController.java @@ -0,0 +1,26 @@ +package in.gov.chennaicorporation.gccoffice.childrensurvey.Controller; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; + +@Controller("ChildrenSurveyController") +@RequestMapping("/gcc/childrensurvey") +public class MainController { + + @GetMapping("/surveylist") + public String surveylist() { + return "modules/childrensurvey/surveylist"; + } + + @GetMapping("/childlist") + public String childlist() { + return "modules/childrensurvey/childlist"; + } + + @GetMapping("/surveyorsreports") + public String surveyorsreports() { + return "modules/childrensurvey/surveyorsreports"; + } + +} 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 new file mode 100644 index 00000000..22b73cc4 --- /dev/null +++ b/gcc_officer_portal/src/main/java/in/gov/chennaicorporation/gccoffice/childrensurvey/Service/ChildrenSurveyService.java @@ -0,0 +1,853 @@ +package in.gov.chennaicorporation.gccoffice.childrensurvey.Service; + +import java.nio.file.Path; +import java.sql.PreparedStatement; +import java.sql.Timestamp; +import java.time.LocalDate; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.Date; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.stream.Collectors; +import java.nio.file.Files; +import javax.sql.DataSource; +import java.nio.file.Paths; +import java.awt.image.BufferedImage; +import javax.imageio.ImageIO; +import java.io.ByteArrayInputStream; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.core.env.Environment; +import org.springframework.dao.DataAccessException; +import org.springframework.dao.EmptyResultDataAccessException; +import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.jdbc.support.GeneratedKeyHolder; +import org.springframework.jdbc.support.KeyHolder; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.multipart.MultipartFile; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import javax.imageio.ImageWriteParam; +import javax.imageio.ImageWriter; +import javax.imageio.stream.ImageOutputStream; +import java.sql.Statement; +import in.gov.chennaicorporation.gccoffice.controller.DateTimeUtil; +import in.gov.chennaicorporation.gccoffice.nulm.repository.NulmRepository; + +@Service +public class ChildrenSurveyService { + + @Autowired + private JdbcTemplate jdbcTemplate; + + @Autowired + public void setDataSource(@Qualifier("mysqlChildrenSurveyDataSource") DataSource dataSource) { + this.jdbcTemplate = new JdbcTemplate(dataSource); + } + + public List> getGender() { + + String sql = "SELECT id, english_name FROM gender_master"; + + return jdbcTemplate.queryForList(sql); + } + + public List> getLocation() { + return jdbcTemplate.queryForList( + "SELECT id, english_name FROM location_master"); + } + + public List> getEducation() { + return jdbcTemplate.queryForList( + "SELECT id, english_name FROM education_master"); + } + + public List> getSurveyList( + String name, + String gender, + String age, + String area, + String education, + String fromDate, + String toDate) { + System.out.println("name: " + name); + System.out.println("gender: " + gender); + System.out.println("age: " + age); + System.out.println("area: " + area); + System.out.println("education: " + education); + System.out.println("fromDate: " + fromDate); + System.out.println("toDate: " + toDate); + + StringBuilder sql = new StringBuilder(""" + SELECT + csr.survey_id, + + MAX(CASE WHEN cqm.field_name = 'q6' THEN csr.answer END) AS child_name, + MAX(CASE WHEN cqm.field_name = 'q7' THEN gm.english_name END) AS gender, + MAX(CASE WHEN cqm.field_name = 'q10' THEN csr.answer END) AS age, + MAX(CASE WHEN cqm.field_name = 'q24' THEN csr.answer END) AS mobile_number, + MAX(CASE WHEN cqm.field_name = 'q1' THEN lm.english_name END) AS area, + MAX(CASE WHEN cqm.field_name = 'q25' THEN em.english_name END) AS education, + MAX(csr.cby) AS cby, + DATE(MAX(csr.cdate)) AS survey_date + + FROM child_survey_response csr + + INNER JOIN child_survey_questions_master cqm + ON csr.qid = cqm.qid + + LEFT JOIN gender_master gm + ON gm.id = csr.answer AND cqm.field_name = 'q7' + + LEFT JOIN location_master lm + ON lm.id = csr.answer AND cqm.field_name = 'q1' + + LEFT JOIN education_master em + ON em.id = csr.answer AND cqm.field_name = 'q25' + + WHERE csr.isactive = 1 + AND csr.isdelete = 0 + """); + + List params = new ArrayList<>(); + + // 🔍 NAME + if (name != null && !name.isEmpty()) { + sql.append( + " AND csr.survey_id IN (SELECT survey_id FROM child_survey_response WHERE answer LIKE ?)"); + params.add("%" + name + "%"); + } + + // 🔍 GENDER + if (gender != null && !gender.isEmpty()) { + sql.append( + " AND csr.survey_id IN (SELECT survey_id FROM child_survey_response WHERE qid = 7 AND answer = ?)"); + params.add(gender); + } + + // 🔍 AREA + if (area != null && !area.isEmpty()) { + sql.append( + " AND csr.survey_id IN (SELECT survey_id FROM child_survey_response WHERE qid = 1 AND answer = ?)"); + params.add(area); + } + + // 🔍 EDUCATION + if (education != null && !education.isEmpty()) { + sql.append( + " AND csr.survey_id IN (SELECT survey_id FROM child_survey_response WHERE qid = 25 AND answer = ?)"); + params.add(education); + } + + // 🔍 AGE RANGE + if (age != null && !age.isEmpty()) { + + String[] range = age.split("-"); + + sql.append(""" + AND csr.survey_id IN ( + SELECT survey_id + FROM child_survey_response + WHERE qid = 10 + AND CAST(answer AS UNSIGNED) BETWEEN ? AND ? + ) + """); + + params.add(Integer.parseInt(range[0])); + params.add(Integer.parseInt(range[1])); + } + + // 🔍 DATE FILTER + if (fromDate != null && toDate != null && !fromDate.isEmpty() && !toDate.isEmpty()) { + sql.append(" AND DATE(csr.cdate) BETWEEN ? AND ?"); + params.add(fromDate); + params.add(toDate); + } + + sql.append(" GROUP BY csr.survey_id ORDER BY MAX(csr.cdate) DESC"); + + return jdbcTemplate.queryForList(sql.toString(), params.toArray()); + } + + public Map getSurveyDetails(String surveyId) { + + String sql = """ + SELECT + csr.qid, + csr.answer, + csr.others_answer, + csr.cby, + csr.survey_id, + + cqm.q_english, + cqm.question_type, + cqm.master_table_name, + cqm.field_name + + FROM child_survey_response csr + + INNER JOIN child_survey_questions_master cqm + ON csr.qid = cqm.qid + + WHERE csr.isactive = 1 + AND csr.isdelete = 0 + AND csr.survey_id = ? + + ORDER BY cqm.orderby + """; + + List> responseList = jdbcTemplate.queryForList(sql, surveyId); + + Map finalResponse = new LinkedHashMap<>(); + + for (Map row : responseList) { + + String question = row.get("q_english") != null + ? row.get("q_english").toString() + : ""; + + String questionType = row.get("question_type") != null + ? row.get("question_type").toString() + : ""; + + String masterTable = row.get("master_table_name") != null + ? row.get("master_table_name").toString() + : ""; + + String rawAnswer = row.get("answer") != null + ? row.get("answer").toString() + : ""; + + String finalAnswer = resolveAnswer( + questionType, + masterTable, + rawAnswer); + + finalResponse.put(question, finalAnswer); + } + + return finalResponse; + } + + // ========================================= + // ANSWER RESOLVER + // ========================================= + + private String resolveAnswer( + String questionType, + String masterTable, + String rawAnswer) { + + try { + + if (rawAnswer == null || rawAnswer.isEmpty()) { + return ""; + } + + // TEXT + if ("text".equalsIgnoreCase(questionType) + || "textarea".equalsIgnoreCase(questionType) + || "number".equalsIgnoreCase(questionType)) { + + return rawAnswer; + } + + // RADIO + if ("radio".equalsIgnoreCase(questionType)) { + + String sql = """ + SELECT english_name + FROM child_survey_answer_master + WHERE aid = ? + """; + + return jdbcTemplate.queryForObject( + sql, + String.class, + Integer.parseInt(rawAnswer)); + } + + // MULTICHECK + if ("multicheck".equalsIgnoreCase(questionType)) { + + String[] ids = rawAnswer.split(","); + + List values = new ArrayList<>(); + + String sql = """ + SELECT english_name + FROM child_survey_answer_master + WHERE aid = ? + """; + + for (String id : ids) { + + String value = jdbcTemplate.queryForObject( + sql, + String.class, + Integer.parseInt(id.trim())); + + values.add(value); + } + + return String.join(", ", values); + } + + // DROPDOWN + if (masterTable != null + && !masterTable.isEmpty()) { + + String dynamicSql = "SELECT english_name FROM " + + masterTable + + " WHERE id = ?"; + + return jdbcTemplate.queryForObject( + dynamicSql, + String.class, + Integer.parseInt(rawAnswer)); + } + + } catch (Exception e) { + + e.printStackTrace(); + } + + 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> getSurveyBreakup(String loginId, String locationId, String surveyDate) { + System.out.println("......................................................."); + System.out.println(loginId + " " + locationId + " " + surveyDate); + System.out.println("......................................................."); + System.out.println("surveyDate=" + surveyDate); + System.out.println("locationId=" + locationId); + System.out.println("loginId=" + loginId); + String sql = """ + + SELECT + + sr.survey_id, + + MAX(CASE + WHEN cqm.field_name = 'q6' + THEN csr.answer + END) AS child_name, + + MAX(CASE + WHEN cqm.field_name = 'q7' + THEN gm.english_name + END) AS gender, + + MAX(CASE + WHEN cqm.field_name = 'q10' + THEN csr.answer + END) AS age, + + MAX(CASE + WHEN cqm.field_name = 'q24' + THEN csr.answer + END) AS mobile_number, + + MAX(CASE + WHEN cqm.field_name = 'q1' + THEN lm.english_name + END) AS area, + + MAX(CASE + WHEN cqm.field_name = 'q25' + THEN em.english_name + END) AS education, + + DATE(MAX(sr.cdate)) AS survey_date + + FROM surveyor_location_details sld + + INNER JOIN child_survey_response sr + ON sr.survey_id = sld.survey_id + + INNER JOIN child_survey_response csr + ON csr.survey_id = sr.survey_id + + INNER JOIN child_survey_questions_master cqm + ON cqm.qid = csr.qid + + LEFT JOIN gender_master gm + ON gm.id = csr.answer + AND cqm.field_name = 'q7' + + LEFT JOIN location_master lm + ON lm.id = csr.answer + AND cqm.field_name = 'q1' + + LEFT JOIN education_master em + ON em.id = csr.answer + AND cqm.field_name = 'q25' + + where sld.loginId = ? + AND sr.survey_id IN ( + + SELECT survey_id + FROM child_survey_response + WHERE qid = 1 + AND answer = ? + + + + ) + and DATE(sr.cdate) = ? + + + AND sr.isactive = 1 + AND sr.isdelete = 0 + + GROUP BY sr.survey_id + + ORDER BY MAX(sr.cdate) DESC + + """; + + return jdbcTemplate.queryForList(sql, loginId, locationId, surveyDate); + } + + // dashboard + + public Map getDashboardData() { + + Map response = new LinkedHashMap<>(); + + // TOTAL CHILDREN + + String totalSql = """ + SELECT COUNT(DISTINCT survey_id) + FROM child_survey_response + WHERE isactive = 1 + AND isdelete = 0 + """; + + Integer totalChildren = jdbcTemplate.queryForObject(totalSql, Integer.class); + + response.put("totalChildren", totalChildren); + + // AREAS COVERED + + String areaCountSql = """ + SELECT COUNT(*) + FROM location_master + """; + + Integer areasCovered = jdbcTemplate.queryForObject(areaCountSql, Integer.class); + + response.put("areasCovered", areasCovered); + + // MALE + + String maleSql = """ + SELECT COUNT(DISTINCT survey_id) + FROM child_survey_response + WHERE qid = 7 + AND answer = 1 + """; + + response.put( + "maleCount", + jdbcTemplate.queryForObject(maleSql, Integer.class)); + + // FEMALE + + String femaleSql = """ + SELECT COUNT(DISTINCT survey_id) + FROM child_survey_response + WHERE qid = 7 + AND answer = 2 + """; + + response.put( + "femaleCount", + jdbcTemplate.queryForObject(femaleSql, Integer.class)); + + // CURRENTLY STUDYING + + /* + * String studyingSql = """ + * SELECT COUNT(DISTINCT survey_id) + * FROM child_survey_response + * WHERE qid = 25 + * AND answer = 1 + * """; + * + * response.put( + * "currentlyStudying", + * jdbcTemplate.queryForObject(studyingSql, Integer.class)); + */ + String studyingSql = """ + + SELECT + + ROUND( + ( + COUNT(DISTINCT CASE + WHEN qid = 25 + AND answer = 1 + THEN survey_id + END) + * 100.0 + ) + / + COUNT(DISTINCT survey_id), + 0) AS studying_percentage + + FROM child_survey_response + + WHERE isactive = 1 + AND isdelete = 0 + + """; + + response.put( + "currentlyStudying", + jdbcTemplate.queryForObject( + studyingSql, + Integer.class)); + + // AGE 4-8 + + String age4to8Sql = """ + SELECT COUNT(DISTINCT survey_id) + FROM child_survey_response + WHERE qid = 10 + AND CAST(answer AS UNSIGNED) BETWEEN 4 AND 8 + """; + + response.put( + "age4to8", + jdbcTemplate.queryForObject(age4to8Sql, Integer.class)); + + // AGE 9-13 + + String age9to13Sql = """ + SELECT COUNT(DISTINCT survey_id) + FROM child_survey_response + WHERE qid = 10 + AND CAST(answer AS UNSIGNED) BETWEEN 9 AND 13 + """; + + response.put( + "age9to13", + jdbcTemplate.queryForObject(age9to13Sql, Integer.class)); + + // AGE 14-18 + + String age14to18Sql = """ + SELECT COUNT(DISTINCT survey_id) + FROM child_survey_response + WHERE qid = 10 + AND CAST(answer AS UNSIGNED) BETWEEN 14 AND 18 + """; + + response.put( + "age14to18", + jdbcTemplate.queryForObject(age14to18Sql, Integer.class)); + + // AREA WISE + + String areaWiseSql = """ + SELECT + + lm.english_name AS area, + + COUNT(DISTINCT csr.survey_id) AS total_children + + FROM location_master lm + + LEFT JOIN child_survey_response csr + ON lm.id = csr.answer + AND csr.qid = 1 + AND csr.isactive = 1 + AND csr.isdelete = 0 + + GROUP BY lm.id, lm.english_name + + ORDER BY lm.orderby + """; + + response.put( + "areaWise", + jdbcTemplate.queryForList(areaWiseSql)); + + // VULNERABILITY + + String vulnerabilitySql = """ + SELECT + + vm.english_name AS vulnerability, + + COUNT(DISTINCT csr.survey_id) AS total + + FROM vulnerability_master vm + + LEFT JOIN child_survey_response csr + ON FIND_IN_SET(vm.id, csr.answer) + AND csr.qid = 48 + AND csr.isactive = 1 + AND csr.isdelete = 0 + + GROUP BY vm.id, vm.english_name + + ORDER BY vm.orderby + """; + + response.put( + "vulnerability", + jdbcTemplate.queryForList(vulnerabilitySql)); + + // EDUCATION STATUS + + // EDUCATION STATUS + + String educationSql = """ + SELECT + + ( + SELECT COUNT(DISTINCT survey_id) + FROM child_survey_response + WHERE qid = 25 + AND answer = 1 + AND isactive = 1 + AND isdelete = 0 + ) AS currently_studying, + + ( + SELECT COUNT(DISTINCT survey_id) + FROM child_survey_response + WHERE qid = 25 + AND answer = 2 + AND isactive = 1 + AND isdelete = 0 + ) AS not_studying, + + ( + SELECT COUNT(DISTINCT survey_id) + FROM child_survey_response + WHERE qid = 34 + AND answer = 1 + AND isactive = 1 + AND isdelete = 0 + ) AS continue_education_intent + """; + + response.put( + "educationStatus", + jdbcTemplate.queryForMap(educationSql)); + // HEALTH OVERVIEW + + String healthSql = """ + + SELECT + + CASE + + WHEN LOWER(cam.english_name) = 'yes' + THEN 'Health Issue' + + WHEN LOWER(cam.english_name) = 'no' + THEN 'No Health Issue' + + ELSE cam.english_name + + END AS status, + + COUNT(DISTINCT csr.survey_id) AS total + + FROM child_survey_response csr + + INNER JOIN child_survey_answer_master cam + ON cam.aid = csr.answer + AND csr.qid = 39 + + WHERE csr.qid = 39 + AND csr.isactive = 1 + AND csr.isdelete = 0 + + GROUP BY status + + """; + + response.put( + "healthOverview", + jdbcTemplate.queryForList(healthSql)); + + // CERTIFICATE DETAILS + + String certificateSql = """ + + SELECT + + ( + SELECT COUNT(DISTINCT survey_id) + FROM child_survey_response + WHERE qid = 42 + AND answer = 1 + AND isactive = 1 + AND isdelete = 0 + ) AS aadhar_yes, + + ( + SELECT COUNT(DISTINCT survey_id) + FROM child_survey_response + WHERE qid = 42 + AND answer = 2 + AND isactive = 1 + AND isdelete = 0 + ) AS aadhar_no, + + ( + SELECT COUNT(DISTINCT survey_id) + FROM child_survey_response + WHERE qid = 44 + AND answer = 1 + AND isactive = 1 + AND isdelete = 0 + ) AS community_yes, + + ( + SELECT COUNT(DISTINCT survey_id) + FROM child_survey_response + WHERE qid = 44 + AND answer = 2 + AND isactive = 1 + AND isdelete = 0 + ) AS community_no, + + ( + SELECT COUNT(DISTINCT survey_id) + FROM child_survey_response + WHERE qid = 45 + AND answer = 1 + AND isactive = 1 + AND isdelete = 0 + ) AS birth_yes, + + ( + SELECT COUNT(DISTINCT survey_id) + FROM child_survey_response + WHERE qid = 45 + AND answer = 2 + AND isactive = 1 + AND isdelete = 0 + ) AS birth_no + + """; + + response.put( + "certificateDetails", + jdbcTemplate.queryForMap(certificateSql)); + + return response; + } +} diff --git a/gcc_officer_portal/src/main/java/in/gov/chennaicorporation/gccoffice/configuration/DataSourceConfig.java b/gcc_officer_portal/src/main/java/in/gov/chennaicorporation/gccoffice/configuration/DataSourceConfig.java index 6faee8d8..771a7b2c 100644 --- a/gcc_officer_portal/src/main/java/in/gov/chennaicorporation/gccoffice/configuration/DataSourceConfig.java +++ b/gcc_officer_portal/src/main/java/in/gov/chennaicorporation/gccoffice/configuration/DataSourceConfig.java @@ -24,14 +24,14 @@ import java.util.Properties; @EnableTransactionManagement public class DataSourceConfig { -// private static String host = "localhost:3306"; -// private static String dbpassword = "root"; + // private static String host = "localhost:3306"; + // private static String dbpassword = "root"; // private static String dbpassword = "gccroot"; // AWS - private static String host ="gcc-facial-db-instance-1.cf48eqcciziq.ap-south-1.rds.amazonaws.com:3306"; - private static String dbpassword = "gcc-facial-password"; + private static String host = "gcc-facial-db-instance-1.cf48eqcciziq.ap-south-1.rds.amazonaws.com:3306"; + private static String dbpassword = "gcc-facial-password"; ////////////////////////////// (For GCC APP) //////////////////////// @Configuration @@ -398,6 +398,16 @@ public class DataSourceConfig { return dataSource; } + @Bean(name = "mysqlChildrenSurveyDataSource") + public DataSource mysqlChildrenSurveyDataSource() { + DriverManagerDataSource dataSource = new DriverManagerDataSource(); + dataSource.setDriverClassName("com.mysql.cj.jdbc.Driver"); + dataSource.setUrl("jdbc:mysql://" + host + "/gcc_children_survey"); + dataSource.setUsername("root"); + dataSource.setPassword(dbpassword); + return dataSource; + } + ////////////////////////////// ORACLE //////////////////////// @Bean(name = "oracleDataSource") public DataSource oracleDataSource() { 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 new file mode 100644 index 00000000..b5c8381f --- /dev/null +++ b/gcc_officer_portal/src/main/resources/templates/modules/childrensurvey/childlist.html @@ -0,0 +1,527 @@ + + + + + + + + + +
+
+ +
+
+
+
+ + + +
+ + +
+ + + +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + + +
DateSurvey IDNameGenderAgeMobileAreaEducationAction
+
+ + +
+
+ + + +
+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file 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 new file mode 100644 index 00000000..a11aee6d --- /dev/null +++ b/gcc_officer_portal/src/main/resources/templates/modules/childrensurvey/surveylist.html @@ -0,0 +1,836 @@ + + + + + + + + +
+
+ +
+
+
+
+ + + +
+ + +
+ + + + + +
+ +
+ + + +
+ +
+ +
+ + +
+ + + + + + + + + + + + + + + + + +
DateSurveyor NameMobile NumberAreaTotal Survey DoneAction
+ +
+ + +
+
+ + +
+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/gcc_officer_portal/src/main/resources/templates/modules/childrensurvey/surveyorsreports.html b/gcc_officer_portal/src/main/resources/templates/modules/childrensurvey/surveyorsreports.html new file mode 100644 index 00000000..25675b00 --- /dev/null +++ b/gcc_officer_portal/src/main/resources/templates/modules/childrensurvey/surveyorsreports.html @@ -0,0 +1,668 @@ + + + + + + + + + + + + + + + + + +
+
+ +
+
+
+
+ + + + +
+ +
+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file