From 19816ce6272aeedca4954f17e3f59db6055d3519 Mon Sep 17 00:00:00 2001 From: KaNi-04 <136799210+KaNi-04@users.noreply.github.com> Date: Sat, 18 Jul 2026 15:39:28 +0530 Subject: [PATCH] officer portal updated code --- .gitignore | 2 + .../bulkwaste/Controller/APIController.java | 244 + .../bulkwaste/Controller/MainController.java | 38 + .../bulkwaste/Service/BulkMasterService.java | 65 + .../bulkwaste/Service/BulkWasteService.java | 456 ++ .../controller/WhatsappController.java | 273 +- .../service/WhatsappqaqcMsgService.java | 67 +- .../Service/ChildrenSurveyService.java | 54 +- .../configuration/DataSourceConfig.java | 45 + .../controller/Maincontroller.java | 11 + .../controller/PendinglistApicontroller.java | 309 +- .../controller/ReportApicontroller.java | 60 +- .../service/PendinglistService.java | 673 +-- .../greencommittee/service/ReportService.java | 226 +- .../Controller/HomelessSurveyController.java | 815 ++++ .../Controller/MainController.java | 168 + .../Service/HomelessSurveyService.java | 4103 +++++++++++++++++ .../roadwar/controller/Maincontroller.java | 57 + .../controller/RegisterApiController.java | 258 ++ .../roadwar/service/LoginMappingService.java | 51 + .../roadwar/service/RegisterService.java | 777 ++++ .../vendor/controller/MainController.java | 17 + src/main/resources/application.properties | 4 +- .../modules/bulkwaste/requestdetails.html | 3007 ++++++++++++ .../callcenterqaqc/agentqaqccalls.html | 19 +- .../modules/childrensurvey/childlist.html | 5 +- .../modules/childrensurvey/nonchildlist.html | 5 +- .../modules/childrensurvey/surveylist.html | 5 +- .../modules/greencommittee/monitoring.html | 2 +- .../modules/greencommittee/pendinglist.html | 915 ++-- .../modules/greencommittee/reports.html | 489 +- .../greencommittee/treepruningreports.html | 1136 +++++ .../modules/homelesssurvey/aadhar.html | 576 +++ .../modules/homelesssurvey/bankpassbook.html | 576 +++ .../birthcertficatenoreason.html | 576 +++ .../modules/homelesssurvey/caste.html | 576 +++ .../modules/homelesssurvey/cminsurance.html | 576 +++ .../homelesssurvey/comeoutshelter.html | 576 +++ .../homelesssurvey/communitynoreason.html | 576 +++ .../homelesssurvey/currentlyliving.html | 576 +++ .../modules/homelesssurvey/disability.html | 576 +++ .../homelesssurvey/disabiltycertificate.html | 576 +++ .../modules/homelesssurvey/discontinued.html | 576 +++ .../modules/homelesssurvey/driver.html | 576 +++ .../modules/homelesssurvey/education.html | 576 +++ .../homelesssurvey/employmenttype.html | 576 +++ .../modules/homelesssurvey/gccshelter.html | 576 +++ .../modules/homelesssurvey/gendermaster.html | 576 +++ .../homelesssurvey/healthcondition.html | 576 +++ .../modules/homelesssurvey/homelesslist.html | 2085 +++++++++ .../homelesssurvey/homelessreason.html | 576 +++ .../modules/homelesssurvey/martial.html | 576 +++ .../modules/homelesssurvey/movingreason.html | 576 +++ .../homelesssurvey/nonsurveyedhomelist.html | 1007 ++++ .../modules/homelesssurvey/notemployed.html | 576 +++ .../modules/homelesssurvey/occupation.html | 576 +++ .../modules/homelesssurvey/relationtype.html | 576 +++ .../modules/homelesssurvey/religion.html | 576 +++ .../modules/homelesssurvey/sleepingspace.html | 576 +++ .../modules/homelesssurvey/smart.html | 576 +++ .../modules/homelesssurvey/surveyorlist.html | 1257 +++++ .../homelesssurvey/surveyorsreports.html | 1012 ++++ .../modules/homelesssurvey/voterid.html | 576 +++ .../templates/modules/roadwar/regform.html | 2427 ++++++++++ .../templates/modules/roadwar/updateform.html | 3543 ++++++++++++++ .../modules/vendors/certificate.html | 764 +++ 66 files changed, 40815 insertions(+), 1188 deletions(-) create mode 100644 .gitignore create mode 100644 src/main/java/in/gov/chennaicorporation/gccoffice/bulkwaste/Controller/APIController.java create mode 100644 src/main/java/in/gov/chennaicorporation/gccoffice/bulkwaste/Controller/MainController.java create mode 100644 src/main/java/in/gov/chennaicorporation/gccoffice/bulkwaste/Service/BulkMasterService.java create mode 100644 src/main/java/in/gov/chennaicorporation/gccoffice/bulkwaste/Service/BulkWasteService.java create mode 100644 src/main/java/in/gov/chennaicorporation/gccoffice/homelesssurvey/Controller/HomelessSurveyController.java create mode 100644 src/main/java/in/gov/chennaicorporation/gccoffice/homelesssurvey/Controller/MainController.java create mode 100644 src/main/java/in/gov/chennaicorporation/gccoffice/homelesssurvey/Service/HomelessSurveyService.java create mode 100644 src/main/java/in/gov/chennaicorporation/gccoffice/roadwar/controller/Maincontroller.java create mode 100644 src/main/java/in/gov/chennaicorporation/gccoffice/roadwar/controller/RegisterApiController.java create mode 100644 src/main/java/in/gov/chennaicorporation/gccoffice/roadwar/service/LoginMappingService.java create mode 100644 src/main/java/in/gov/chennaicorporation/gccoffice/roadwar/service/RegisterService.java create mode 100644 src/main/resources/templates/modules/bulkwaste/requestdetails.html create mode 100644 src/main/resources/templates/modules/greencommittee/treepruningreports.html create mode 100644 src/main/resources/templates/modules/homelesssurvey/aadhar.html create mode 100644 src/main/resources/templates/modules/homelesssurvey/bankpassbook.html create mode 100644 src/main/resources/templates/modules/homelesssurvey/birthcertficatenoreason.html create mode 100644 src/main/resources/templates/modules/homelesssurvey/caste.html create mode 100644 src/main/resources/templates/modules/homelesssurvey/cminsurance.html create mode 100644 src/main/resources/templates/modules/homelesssurvey/comeoutshelter.html create mode 100644 src/main/resources/templates/modules/homelesssurvey/communitynoreason.html create mode 100644 src/main/resources/templates/modules/homelesssurvey/currentlyliving.html create mode 100644 src/main/resources/templates/modules/homelesssurvey/disability.html create mode 100644 src/main/resources/templates/modules/homelesssurvey/disabiltycertificate.html create mode 100644 src/main/resources/templates/modules/homelesssurvey/discontinued.html create mode 100644 src/main/resources/templates/modules/homelesssurvey/driver.html create mode 100644 src/main/resources/templates/modules/homelesssurvey/education.html create mode 100644 src/main/resources/templates/modules/homelesssurvey/employmenttype.html create mode 100644 src/main/resources/templates/modules/homelesssurvey/gccshelter.html create mode 100644 src/main/resources/templates/modules/homelesssurvey/gendermaster.html create mode 100644 src/main/resources/templates/modules/homelesssurvey/healthcondition.html create mode 100644 src/main/resources/templates/modules/homelesssurvey/homelesslist.html create mode 100644 src/main/resources/templates/modules/homelesssurvey/homelessreason.html create mode 100644 src/main/resources/templates/modules/homelesssurvey/martial.html create mode 100644 src/main/resources/templates/modules/homelesssurvey/movingreason.html create mode 100644 src/main/resources/templates/modules/homelesssurvey/nonsurveyedhomelist.html create mode 100644 src/main/resources/templates/modules/homelesssurvey/notemployed.html create mode 100644 src/main/resources/templates/modules/homelesssurvey/occupation.html create mode 100644 src/main/resources/templates/modules/homelesssurvey/relationtype.html create mode 100644 src/main/resources/templates/modules/homelesssurvey/religion.html create mode 100644 src/main/resources/templates/modules/homelesssurvey/sleepingspace.html create mode 100644 src/main/resources/templates/modules/homelesssurvey/smart.html create mode 100644 src/main/resources/templates/modules/homelesssurvey/surveyorlist.html create mode 100644 src/main/resources/templates/modules/homelesssurvey/surveyorsreports.html create mode 100644 src/main/resources/templates/modules/homelesssurvey/voterid.html create mode 100644 src/main/resources/templates/modules/roadwar/regform.html create mode 100644 src/main/resources/templates/modules/roadwar/updateform.html create mode 100644 src/main/resources/templates/modules/vendors/certificate.html diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..cd9abe7 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/target +hs_err_pid38028.log diff --git a/src/main/java/in/gov/chennaicorporation/gccoffice/bulkwaste/Controller/APIController.java b/src/main/java/in/gov/chennaicorporation/gccoffice/bulkwaste/Controller/APIController.java new file mode 100644 index 0000000..72f5f6f --- /dev/null +++ b/src/main/java/in/gov/chennaicorporation/gccoffice/bulkwaste/Controller/APIController.java @@ -0,0 +1,244 @@ +package in.gov.chennaicorporation.gccoffice.bulkwaste.Controller; + +import java.math.BigDecimal; +import java.util.Date; +import java.util.List; +import java.util.Map; +import org.springframework.http.MediaType; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.format.annotation.DateTimeFormat; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.multipart.MultipartFile; + +import in.gov.chennaicorporation.gccoffice.bulkwaste.Service.BulkWasteService; +import in.gov.chennaicorporation.gccoffice.bulkwaste.Service.BulkMasterService; + +@RequestMapping("gcc/api/bulkwaste") +@RestController("BulkWasteAPIController") +public class APIController { + + @Autowired + private BulkMasterService masterService; + private BulkWasteService bulkWasteService; + + @Autowired + public APIController(BulkMasterService masterService, + BulkWasteService bulkWasteService) { + this.masterService = masterService; + this.bulkWasteService = bulkWasteService; + } + + @GetMapping(value="/getCategoryTypes") + public List getCategoryTypes() { + return masterService.getCategoryTypes(); + } + + @GetMapping(value="/getZones") + public List getZones() { + return masterService.getZones(); + } + + @GetMapping("/getWards") + public List> getWards( + @RequestParam String zoneName) { + + return masterService.getWards(zoneName); + } + + @GetMapping("/getBulkWasteRequestDetails") + public List> getBulkWasteRequestDetails( + + @RequestParam(value = "fromDate", required = false) + @DateTimeFormat(pattern = "yyyy-MM-dd") Date fromDate, + + @RequestParam(value = "toDate", required = false) + @DateTimeFormat(pattern = "yyyy-MM-dd") Date toDate, + + @RequestParam(value = "categoryType", required = false) String categoryType, + @RequestParam(value = "zoneType", required = false) String zoneType, + @RequestParam(value = "wardType", required = false) String wardType) { + + return bulkWasteService.getBulkWasteRequestDetails(fromDate, toDate, categoryType, zoneType, wardType); + } + + @GetMapping("/bulkWasteRequestView") + public Map bulkWasteRequestView( + @RequestParam Long requestId) { + + return bulkWasteService.getBulkWasteRequestView(requestId); + } + + @GetMapping("/getMinSurveyDate") + public String getMinSurveyDate() { + return bulkWasteService.getMinSurveyDate(); + } + + + + @PostMapping(value="/updateBulkWasteRequest", + consumes = MediaType.MULTIPART_FORM_DATA_VALUE) + public ResponseEntity> updateBulkWasteRequest( + + @RequestParam Long requestId, + + @RequestParam String name_of_establishment, @RequestParam Integer category_id, + @RequestParam Integer zone_id, @RequestParam Integer ward_id, + @RequestParam(required = false) String trade_license_No, + @RequestParam String person_name, @RequestParam String email_id, + @RequestParam String mobile_no, @RequestParam String address, + @RequestParam(required = false) String gst_No, + + + @RequestParam String total_builtup_area_sqmt, @RequestParam String establishment_type, + @RequestParam(required = false) Integer dwelling_units, + @RequestParam(required = false) Integer avg_daily_footfall, + @RequestParam String totalEmployees, + + @RequestParam BigDecimal wet_waste, @RequestParam BigDecimal dry_waste, + @RequestParam BigDecimal domestic_hazardous_waste, + @RequestParam BigDecimal sanitary_waste, + @RequestParam(required = false) BigDecimal cd_waste, + + @RequestParam(required = false) MultipartFile wasteAuditFile, + + @RequestParam String wet_waste_processed, + @RequestParam(required = false) String technology_used, + @RequestParam(required = false) String other_technology, + @RequestParam(required = false) BigDecimal installed_capacity_kg, + @RequestParam(required = false) Integer installation_year, + @RequestParam(required = false) String vendor_name, + @RequestParam(required = false) String unit_functional_status, + @RequestParam(required = false) MultipartFile installedUnitPhoto, + @RequestParam(defaultValue = "false") boolean removeInstalledPhoto, + + @RequestParam(required = false) String longitude, + @RequestParam(required = false) String latitude, + + @RequestParam String dry_waste_recycler, + @RequestParam(required = false) String recycler_name, + @RequestParam(required = false) String recycler_authorization_no, + + @RequestParam BigDecimal residual_waste_quantity, + @RequestParam String collection_frequency, + @RequestParam String vehicle_type, + + @RequestParam Integer update_by + + ) { + + try { + + String result = bulkWasteService.updateBulkWasteRequest( + + requestId, + + name_of_establishment, category_id, zone_id, ward_id, trade_license_No, + person_name, email_id, mobile_no, gst_No, address, + + total_builtup_area_sqmt, establishment_type, + dwelling_units, avg_daily_footfall, totalEmployees, + + wet_waste, dry_waste, domestic_hazardous_waste, sanitary_waste, cd_waste, + + wasteAuditFile, + + wet_waste_processed, technology_used, other_technology, + installed_capacity_kg, installation_year, + vendor_name, unit_functional_status, installedUnitPhoto, + + removeInstalledPhoto, // <-- ADD THIS + + longitude, latitude, + + dry_waste_recycler, recycler_name, recycler_authorization_no, + + residual_waste_quantity, collection_frequency, vehicle_type, + + update_by + ); + + if ("mobile_exists".equals(result)) { + + return ResponseEntity.ok(Map.of( + "status", false, + "message", "duplicate", + "description", "This Mobile Number is already registered." + )); + } + + if ("success".equals(result)) { + + return ResponseEntity.ok(Map.of( + "status", true, + "message", "success", + "description", "Bulk Waste Request Updated Successfully" + )); + } + + return ResponseEntity.ok(Map.of( + "status", false, + "message", "failed", + "description", "Update Failed" + )); + + } catch (Exception e) { + + e.printStackTrace(); + + return ResponseEntity.ok(Map.of( + "status", false, + "message", "error", + "description", "Something went wrong" + )); + } + } + + + @PostMapping("/deactivatebulk") + public ResponseEntity> DeactivateBulkRequest(@RequestParam int requestId, + //@RequestParam Integer userId, + @RequestParam("update_by") Integer updateBy) { + + try { + + String result = bulkWasteService.deactivatebulkrequest(requestId,updateBy); + + if (result == null || result.equals("error")) { + + return ResponseEntity.ok(Map.of( + "status", false, + "message", "failed", + "description", " Failed to Deleted Bulk " + )); + } + + return ResponseEntity.ok(Map.of( + "status", true, + "title", "success", + "message", " Bulk Deleted successfully " + )); + + } catch (Exception e) { + + e.printStackTrace(); + + return ResponseEntity.ok(Map.of( + "status", false, + "message", "error", + "description", " Something went wrong " + )); + } + } + + + + + + +} diff --git a/src/main/java/in/gov/chennaicorporation/gccoffice/bulkwaste/Controller/MainController.java b/src/main/java/in/gov/chennaicorporation/gccoffice/bulkwaste/Controller/MainController.java new file mode 100644 index 0000000..73419bf --- /dev/null +++ b/src/main/java/in/gov/chennaicorporation/gccoffice/bulkwaste/Controller/MainController.java @@ -0,0 +1,38 @@ +package in.gov.chennaicorporation.gccoffice.bulkwaste.Controller; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.client.RestTemplate; + +import in.gov.chennaicorporation.gccoffice.service.LoginUserInfo; + +@Controller("BulkWasteController") +@RequestMapping("/gcc/bulkwaste") +public class MainController { + + private final RestTemplate restTemplate; + private String BasePath = "modules/bulkwaste/"; + @Autowired + public MainController(RestTemplate restTemplate) { + this.restTemplate = restTemplate; + } + + + @GetMapping("bulkwastelist") + public String ownerList(Model model) { + String LoginUserId = LoginUserInfo.getLoginUserId(); + model.addAttribute("LoginUserId",LoginUserId); + return BasePath+"requestdetails"; + } + + @GetMapping("surveyorsreports") + public String surveyorsreports(Model model) { + String LoginUserId = LoginUserInfo.getLoginUserId(); + model.addAttribute("LoginUserId",LoginUserId); + return BasePath+"surveyorsreports"; + } + +} diff --git a/src/main/java/in/gov/chennaicorporation/gccoffice/bulkwaste/Service/BulkMasterService.java b/src/main/java/in/gov/chennaicorporation/gccoffice/bulkwaste/Service/BulkMasterService.java new file mode 100644 index 0000000..e3d3dc4 --- /dev/null +++ b/src/main/java/in/gov/chennaicorporation/gccoffice/bulkwaste/Service/BulkMasterService.java @@ -0,0 +1,65 @@ +package in.gov.chennaicorporation.gccoffice.bulkwaste.Service; + +import java.util.List; +import java.util.Map; + +import javax.sql.DataSource; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +@Service +public class BulkMasterService { + + private JdbcTemplate jdbcTemplate; + + @Autowired + public void setDataSource(@Qualifier("mysqlBulkWasteDataSource") DataSource dataSource) { + this.jdbcTemplate = new JdbcTemplate(dataSource); + } + + @Transactional(readOnly = true) + public List> getCategoryTypes() { + + String sqlQuery = + "SELECT * " + + "FROM category_master " + + "WHERE is_active = 1 " + + "AND is_delete = 0"; + +// getSpaceRearTypes + + return jdbcTemplate.queryForList(sqlQuery); + } + + @Transactional(readOnly = true) + public List> getZones() { + + String sqlQuery = + "SELECT * FROM zones " + + "WHERE is_active = 1 AND is_delete = 0"; + + return jdbcTemplate.queryForList(sqlQuery); + } + + @Transactional(readOnly = true) + public List> getWards(String zoneName) { + + String sqlQuery = + "SELECT * " + + "FROM wards " + + "WHERE is_active = 1 " + + "AND is_delete = 0 " + + "AND zone_name = ?"; + + return jdbcTemplate.queryForList(sqlQuery, zoneName); + } + + + + + +} diff --git a/src/main/java/in/gov/chennaicorporation/gccoffice/bulkwaste/Service/BulkWasteService.java b/src/main/java/in/gov/chennaicorporation/gccoffice/bulkwaste/Service/BulkWasteService.java new file mode 100644 index 0000000..a3d7f3a --- /dev/null +++ b/src/main/java/in/gov/chennaicorporation/gccoffice/bulkwaste/Service/BulkWasteService.java @@ -0,0 +1,456 @@ +package in.gov.chennaicorporation.gccoffice.bulkwaste.Service; + +import java.util.Date; +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Map; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.env.Environment; +import org.springframework.web.multipart.MultipartFile; + +import in.gov.chennaicorporation.gccoffice.controller.DateTimeUtil; + +import javax.sql.DataSource; + +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.dao.DataAccessException; +import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +@Service +public class BulkWasteService { + + private JdbcTemplate jdbcTemplate; + + private final Environment environment; + private String fileBaseUrl; + + public BulkWasteService(Environment environment) { + this.environment = environment; + this.fileBaseUrl = environment.getProperty("fileBaseUrl"); + } + + @Autowired + public void setDataSource(@Qualifier("mysqlBulkWasteDataSource") DataSource dataSource) { + this.jdbcTemplate = new JdbcTemplate(dataSource); + } + + + @Transactional(readOnly = true) + public List> getBulkWasteRequestDetails(Date fromDate, Date toDate, + String categoryType, String zoneType, String wardType) { + + try { + + StringBuilder sql = new StringBuilder( + "SELECT bwr.request_id, bwr.name_of_establishment, " + + "bwr.category_id, cm.category_name, " + + "bwr.zone_id, bwr.ward_id, " + + "bwr.person_name, bwr.mobile_no, bwr.cdate " + + "FROM bulk_waste_request bwr " + + "LEFT JOIN category_master cm ON cm.category_id = bwr.category_id " + ); + + List params = new ArrayList<>(); + List conditions = new ArrayList<>(); + + // Date Filter + if (fromDate != null && toDate != null) { + conditions.add("DATE(bwr.cdate) BETWEEN ? AND ?"); + params.add(fromDate); + params.add(toDate); + } + + // Category Filter + if (categoryType != null && !categoryType.trim().isEmpty()) { + conditions.add("bwr.category_id = ?"); + params.add(Integer.parseInt(categoryType)); + } + + // Zone Filter + if (zoneType != null && !zoneType.trim().isEmpty()) { + conditions.add("bwr.zone_id = ?"); + params.add(zoneType); + } + + // Ward Filter + if (wardType != null && !wardType.trim().isEmpty()) { + conditions.add("bwr.ward_id = ?"); + params.add(wardType); + } + + // Show only active records (Optional) + conditions.add("bwr.is_delete = 0"); + conditions.add("bwr.is_active = 1"); + + if (!conditions.isEmpty()) { + sql.append(" WHERE ").append(String.join(" AND ", conditions)); + } + + sql.append(" ORDER BY bwr.cdate DESC"); + + return jdbcTemplate.queryForList(sql.toString(), params.toArray()); + + } catch (DataAccessException e) { + e.printStackTrace(); + return Collections.emptyList(); + } + } + + @Transactional(readOnly = true) + public String getMinSurveyDate() { + + String sql = "SELECT DATE(MIN(cdate)) FROM bulk_waste_request"; + + return jdbcTemplate.queryForObject(sql, String.class); + } + + @Transactional(readOnly = true) + public Map getBulkWasteRequestView(Long requestId) { + + String sql = + "SELECT bwr.request_id, " + + "bwr.name_of_establishment, bwr.person_name, " + + "bwr.category_id, cm.category_name, bwr.email_id, bwr.mobile_no, " + + "bwr.zone_id, bwr.ward_id, bwr.trade_license_No, bwr.gst_No, " + + "bwr.address, " + + "bwr.total_builtup_area_sqmt, bwr.establishment_type, " + + "bwr.dwelling_units, bwr.avg_daily_footfall, bwr.totalEmployees, " + + "bwr.wet_waste, bwr.dry_waste, bwr.domestic_hazardous_waste, " + + "bwr.sanitary_waste, bwr.cd_waste, " + + "CONCAT('" + fileBaseUrl + "/gccofficialapp/files', bwr.waste_audit_report_file) AS waste_audit_report_file, " + + "bwr.wet_waste_processed, bwr.technology_used, bwr.other_technology, " + + "bwr.installed_capacity_kg, bwr.installation_year, " + + "bwr.vendor_name, bwr.unit_functional_status, " + + "CONCAT('" + fileBaseUrl + "/gccofficialapp/files', bwr.installed_unit_photo_file) AS installed_unit_photo_file, " + + "bwr.longitude, bwr.latitude, " + + "bwr.dry_waste_recycler, bwr.recycler_name, bwr.recycler_authorization_no, " + + "bwr.residual_waste_quantity, bwr.collection_frequency, bwr.vehicle_type, " + + "bwr.is_active, bwr.is_delete, bwr.cdate " + + "FROM bulk_waste_request bwr " + + "LEFT JOIN category_master cm ON cm.category_id = bwr.category_id " + + "WHERE bwr.request_id = ?"; + + return jdbcTemplate.queryForMap(sql, requestId); + } + + + + public String fileUpload(MultipartFile file, String name) { + + // Set the file path where you want to save it + String uploadDirectory = environment.getProperty("file.upload.directory.mobile"); + String serviceFolderName = environment.getProperty("bulk_waste_foldername"); + var year = DateTimeUtil.getCurrentYear(); + var month = DateTimeUtil.getCurrentMonth(); + + uploadDirectory = uploadDirectory + serviceFolderName + "/" + year + "/" + month; + + try { + // Create directory if it doesn't exist + Path directoryPath = Paths.get(uploadDirectory); + if (!Files.exists(directoryPath)) { + Files.createDirectories(directoryPath); + } + + // Datetime string + String datetimetxt = DateTimeUtil.getCurrentDateTime(); + + // File name + String fileName = name + "_" + datetimetxt + "_" + file.getOriginalFilename(); + fileName = fileName.replaceAll("\\s+", ""); // Remove space on filename + + String filePath = uploadDirectory + "/" + fileName; + + String filepath_txt = "/" + serviceFolderName + "/" + year + "/" + month + "/" + fileName; + + // Create a new Path object + Path path = Paths.get(filePath); + + // Get the bytes of the file + byte[] bytes = file.getBytes(); + + Files.write(path, bytes); + + // System.out.println(filePath); + return filepath_txt; + + } catch (IOException e) { + e.printStackTrace(); + return "Failed to save file " + file.getOriginalFilename(); + } + + } + + + @Transactional + public String updateBulkWasteRequest( + + Long requestId, + + String name_of_establishment, + Integer category_id, Integer zone_id, Integer ward_id, + String trade_license_No, String person_name, String email_id, + String mobile_no, String gst_No, String address, + + String total_builtup_area_sqmt, String establishment_type, + Integer dwelling_units, Integer avg_daily_footfall, String totalEmployees, + + BigDecimal wet_waste, BigDecimal dry_waste, + BigDecimal domestic_hazardous_waste, BigDecimal sanitary_waste, BigDecimal cd_waste, + + MultipartFile wasteAuditFile, + + String wet_waste_processed, String technology_used, String other_technology, + BigDecimal installed_capacity_kg, Integer installation_year, String vendor_name, + String unit_functional_status, MultipartFile installedUnitPhoto, + + boolean removeInstalledPhoto, + + String longitude, String latitude, + + String dry_waste_recycler, String recycler_name, String recycler_authorization_no, + + BigDecimal residual_waste_quantity, String collection_frequency, String vehicle_type, + + Integer update_by + + ) { + + try { + + //===================================================== + // Store Existing Record into Log Table + //===================================================== + + String logSql = + "INSERT INTO bulk_waste_request_log(" + + "request_id,name_of_establishment,category_id,zone_id,ward_id," + + "trade_license_No,person_name,email_id,mobile_no,gst_No,address," + + "total_builtup_area_sqmt,establishment_type,dwelling_units," + + "avg_daily_footfall,totalEmployees,wet_waste,dry_waste," + + "domestic_hazardous_waste,sanitary_waste,cd_waste," + + "waste_audit_report_file,wet_waste_processed,technology_used," + + "other_technology,installed_capacity_kg,installation_year," + + "vendor_name,unit_functional_status,installed_unit_photo_file," + + "longitude,latitude,dry_waste_recycler,recycler_name," + + "recycler_authorization_no,residual_waste_quantity," + + "collection_frequency,vehicle_type,is_active,is_delete," + + "cdate,update_date,update_by,log_cdate)" + + + " SELECT " + + "request_id,name_of_establishment,category_id,zone_id,ward_id," + + "trade_license_No,person_name,email_id,mobile_no,gst_No,address," + + "total_builtup_area_sqmt,establishment_type,dwelling_units," + + "avg_daily_footfall,totalEmployees,wet_waste,dry_waste," + + "domestic_hazardous_waste,sanitary_waste,cd_waste," + + "waste_audit_report_file,wet_waste_processed,technology_used," + + "other_technology,installed_capacity_kg,installation_year," + + "vendor_name,unit_functional_status,installed_unit_photo_file," + + "longitude,latitude,dry_waste_recycler,recycler_name," + + "recycler_authorization_no,residual_waste_quantity," + + "collection_frequency,vehicle_type,is_active,is_delete," + + "cdate,update_date,update_by,NOW()" + + " FROM bulk_waste_request WHERE request_id=?"; + + jdbcTemplate.update(logSql, requestId); + + //-------------------------------------------------- + // Existing File Paths + //-------------------------------------------------- + + String wasteAuditPath = jdbcTemplate.queryForObject( + "SELECT waste_audit_report_file FROM bulk_waste_request WHERE request_id=?", + String.class, + requestId); + + String installedPhotoPath = jdbcTemplate.queryForObject( + "SELECT installed_unit_photo_file FROM bulk_waste_request WHERE request_id=?", + String.class, + requestId); + + // Remove old installed photo + if(removeInstalledPhoto){ + installedPhotoPath = null; + } + + //-------------------------------------------------- + // Upload New Files + //-------------------------------------------------- + + if (wasteAuditFile != null && !wasteAuditFile.isEmpty()) { + wasteAuditPath = fileUpload(wasteAuditFile, "waste_audit"); + + } + + if (installedUnitPhoto != null && !installedUnitPhoto.isEmpty()) { + installedPhotoPath = fileUpload(installedUnitPhoto, "installed_unit"); + } + + //---------------------------------------------------- + // If Wet Waste = No + //---------------------------------------------------- + + if ("No".equalsIgnoreCase(wet_waste_processed)) { + + technology_used = null; + other_technology = null; + + installed_capacity_kg = null; + installation_year = null; + vendor_name = null; + + unit_functional_status = null; + + longitude = null; + latitude = null; + + installedPhotoPath = null; + } + + //---------------------------------------------------- + // If Recycler = No + //---------------------------------------------------- + + if ("No".equalsIgnoreCase(dry_waste_recycler)) { + + recycler_name = null; + recycler_authorization_no = null; + } + + //-------------------------------------------------- + // Check Duplicate Mobile Number + //-------------------------------------------------- + + Integer mobileCount = jdbcTemplate.queryForObject( + + "SELECT COUNT(*) FROM bulk_waste_request " + + "WHERE mobile_no=? AND request_id<>? AND is_delete=0", + + Integer.class, + + mobile_no, + requestId + ); + + if (mobileCount != null && mobileCount > 0) { + return "mobile_exists"; + } + + + + //-------------------------------------------------- + // Update + //-------------------------------------------------- + + String sql = + + "UPDATE bulk_waste_request SET " + + + "name_of_establishment=?,category_id=?,zone_id=?,ward_id=?,trade_license_No=?," + + "person_name=?,email_id=?,mobile_no=?,gst_No=?,address=?," + + + "total_builtup_area_sqmt=?,establishment_type=?,dwelling_units=?," + + "avg_daily_footfall=?,totalEmployees=?," + + + "wet_waste=?,dry_waste=?,domestic_hazardous_waste=?,sanitary_waste=?,cd_waste=?," + + "waste_audit_report_file=?," + + + "wet_waste_processed=?,technology_used=?,other_technology=?," + + "installed_capacity_kg=?,installation_year=?,vendor_name=?," + + "unit_functional_status=?,installed_unit_photo_file=?," + + + "longitude=?,latitude=?," + + + "dry_waste_recycler=?,recycler_name=?,recycler_authorization_no=?," + + + "residual_waste_quantity=?,collection_frequency=?,vehicle_type=?," + + + "update_date=NOW()," + + "update_by=? " + + + "WHERE request_id=?"; + + int count = jdbcTemplate.update( + + sql, + + name_of_establishment, category_id, zone_id, ward_id, + trade_license_No, person_name, email_id, mobile_no, gst_No, address, + + total_builtup_area_sqmt, establishment_type, dwelling_units, avg_daily_footfall, totalEmployees, + + wet_waste, dry_waste, domestic_hazardous_waste, sanitary_waste, cd_waste, + + wasteAuditPath, + + wet_waste_processed, technology_used, other_technology, installed_capacity_kg, + installation_year, vendor_name, unit_functional_status, installedPhotoPath, + + longitude, latitude, + + dry_waste_recycler, recycler_name, recycler_authorization_no, + + residual_waste_quantity, collection_frequency, vehicle_type, + + update_by, + + requestId + ); + + return count > 0 ? "success" : "error"; + + } catch (Exception e) { + + e.printStackTrace(); + return "error"; + } + } + + + // ============================== + // Delete Details + // ============================== + + + public String deactivatebulkrequest(int requestId,Integer updateBy) { + + try { + + String sql = + "UPDATE bulk_waste_request " + + "SET is_active = 0, is_delete = 1,update_by=?,update_date=NOW() " + + "WHERE request_id = ?"; + + + int count = jdbcTemplate.update(sql, updateBy,requestId); + + if (count > 0) { + return "success"; + } else { + return "error"; + } + + } catch (Exception e) { + e.printStackTrace(); + return "error"; + } + } + + + + + + + + +} diff --git a/src/main/java/in/gov/chennaicorporation/gccoffice/callcenterqaqc/controller/WhatsappController.java b/src/main/java/in/gov/chennaicorporation/gccoffice/callcenterqaqc/controller/WhatsappController.java index 631ee87..d439d73 100644 --- a/src/main/java/in/gov/chennaicorporation/gccoffice/callcenterqaqc/controller/WhatsappController.java +++ b/src/main/java/in/gov/chennaicorporation/gccoffice/callcenterqaqc/controller/WhatsappController.java @@ -56,11 +56,11 @@ public class WhatsappController { String result = sendWhatsappMsg(pname, complaintTypeName, mobnumber, complaintNumber,returnedAction); if(result.equals("200")) { - System.out.println("Whatsapp Message Triggered for "+complaintNumber); + System.out.println(returnedAction+" Whatsapp Message Triggered for "+complaintNumber); return true; } else { - System.out.println("Whatsapp Message Failed for "+complaintNumber); + System.out.println(returnedAction+ " Whatsapp Message Failed for "+complaintNumber); return false; } } @@ -72,33 +72,37 @@ public class WhatsappController { String urlString = ""; try { - + - if("COMPLETED".equalsIgnoreCase(returnedAction)) { - - } + String placeholders = + URLEncoder.encode( + pname + "|~|" + cat + "|~|" + complaintNumber, + StandardCharsets.UTF_8.toString()); + + String buttonPlaceholder = + URLEncoder.encode( + complaintNumber+ "|~|" +complaintNumber, + StandardCharsets.UTF_8.toString()); + + String mobile = + URLEncoder.encode( + mob_no, + StandardCharsets.UTF_8.toString()); + + + if("COMPLETED".equalsIgnoreCase(returnedAction)) { + + urlString="https://sendapiv1.pinbot.ai/pinwa/sendMessage?apikey=5c995535-6244-11f0-98fc-02c8a5e042bd&from=919445061913&to="+mobile+"&templateid=3310383&type=template&placeholders="+placeholders; + + } if("UNATTENDED".equalsIgnoreCase(returnedAction)) { - + + + urlString="https://sendapiv1.pinbot.ai/pinwa/sendMessage?apikey=5c995535-6244-11f0-98fc-02c8a5e042bd&from=919445061913&to="+mobile+"&templateid=3304038&type=template&placeholders="+placeholders+"&button_placeholder="+buttonPlaceholder; + } - String placeholders = - URLEncoder.encode( - pname + "|~|" + cat + "|~|" + complaintNumber, - StandardCharsets.UTF_8.toString()); - - String buttonPlaceholder = - URLEncoder.encode( - complaintNumber, - StandardCharsets.UTF_8.toString()); - - String mobile = - URLEncoder.encode( - mob_no, - StandardCharsets.UTF_8.toString()); - - - urlString=""; String res = hitURL(urlString); return res; @@ -120,7 +124,7 @@ public class WhatsappController { int responseCode = connection.getResponseCode(); response = String.valueOf(responseCode); - //System.out.println("Response Code for URL: " + urlString + " is " + responseCode); + System.out.println("Response Code for Whatsapp msg URL: " + urlString + " is " + responseCode); } catch (Exception e) { e.printStackTrace(); @@ -129,17 +133,224 @@ public class WhatsappController { return response; } - @GetMapping("/getclosefromuser") +// @GetMapping("/getclosefromuser") +// public String getclosefromuser(@RequestParam String complaintNumber) { +// +// return whatsappqaqcMsgService.getclosefromuser(complaintNumber); +// +// } + + @GetMapping(value = "/getclosefromuser", produces = "text/html") public String getclosefromuser(@RequestParam String complaintNumber) { - - return whatsappqaqcMsgService.getclosefromuser(complaintNumber); - + + String result = whatsappqaqcMsgService.getclosefromuser(complaintNumber); + + boolean success = result.contains("Successfully"); + String color = success ? "#28a745" : "#dc3545"; + + String logoUrl = "https://gccservices.in/gcc/assets/images/logo.png"; + + //background: #f5f5f5; + + return """ + + + + + GCC PGR Complaint Status + + + +
+ +
+ GCC Logo +

Thanks For Your Response !!!

+
+ +
+

%s

+
+ + + +
+ + + """.formatted(color, logoUrl, result); } - @GetMapping("/getreopenfromuser") + + @GetMapping(value="/getreopenfromuser", produces = "text/html") public String getreopenfromuser(@RequestParam String complaintNumber) { - return whatsappqaqcMsgService.getreopenfromuser(complaintNumber); + String result= whatsappqaqcMsgService.getreopenfromuser(complaintNumber); + + boolean success = result.contains("Successfully"); + String color = success ? "#28a745" : "#dc3545"; + + String logoUrl = "https://gccservices.in/gcc/assets/images/logo.png"; + + //background: #f5f5f5; + + return """ + + + + + GCC PGR Complaint Status + + + +
+ +
+ GCC Logo +

Thanks For Your Response !!!

+
+ +
+

%s

+
+ + + +
+ + + """.formatted(color, logoUrl, result); } diff --git a/src/main/java/in/gov/chennaicorporation/gccoffice/callcenterqaqc/service/WhatsappqaqcMsgService.java b/src/main/java/in/gov/chennaicorporation/gccoffice/callcenterqaqc/service/WhatsappqaqcMsgService.java index 1e7b012..28b7392 100644 --- a/src/main/java/in/gov/chennaicorporation/gccoffice/callcenterqaqc/service/WhatsappqaqcMsgService.java +++ b/src/main/java/in/gov/chennaicorporation/gccoffice/callcenterqaqc/service/WhatsappqaqcMsgService.java @@ -88,7 +88,7 @@ public class WhatsappqaqcMsgService { String sql = "SELECT call_status " + "FROM qaqc_upload_data_history " + - "WHERE complaint_number=? " + + "WHERE complaint_number=? AND call_category='CLOSED' " + "ORDER BY id DESC " + "LIMIT 20"; @@ -121,7 +121,7 @@ public class WhatsappqaqcMsgService { String sql = "SELECT call_status " + "FROM qaqc_upload_data_history " + - "WHERE complaint_number=? " + + "WHERE complaint_number=? AND call_category='CLOSED' " + "ORDER BY id DESC " + "LIMIT 5"; @@ -150,6 +150,15 @@ public class WhatsappqaqcMsgService { return response; } + + + public String getErpusername() { + + String query="SELECT erp_username FROM agents_list " + + "where calling_type='WHATSAPP_MSG'"; + + return jdbcTemplate.queryForObject(query,String.class); + } public String getclosefromuser(String complaintNumber) { @@ -164,27 +173,42 @@ public class WhatsappqaqcMsgService { ) ); - String Erpname="QAops72"; + + + String Erpname=getErpusername(); + + System.out.println("Erpname="+Erpname); if ("Action Taken - Level 2".equalsIgnoreCase(currentStatus)) { - boolean statusUpdated=qaqcCallsService.ChangeStatusInErp(complaintNumber, "", "COMPLETED",Erpname); + boolean statusUpdated=qaqcCallsService.ChangeStatusInErp(complaintNumber, "COMPLAINT CLOSED BY WHATSAPP MESSAGE", "COMPLETED",Erpname); if (statusUpdated) { - return complaintNumber+ " PGR Complaint closed Successfully"; + return "Your "+complaintNumber+ " PGR Complaint has been closed Successfully.\n If you need further assistance,\n Please contact GCC 1913 Helpline."; } else { - return "Unable to close "+complaintNumber+" PGR Complaint"; + return "We are unable to process your request at the moment.\n Please try again later."; } - } + } else { - return "Unable to close PGR "+complaintNumber+" Complaint,Because the complaint status is "+currentStatus; + if("FINAL_CLOSURE".equalsIgnoreCase(currentStatus)){ + + return "Your " + complaintNumber + " complaint has already been closed.\n\n" + + "If you need further assistance, please contact GCC 1913 Helpline."; + + } + else if("REOPENED".equalsIgnoreCase(currentStatus)) { + return "Your "+complaintNumber+" complaint has already been reopened. Once it is resolved, we will reach you by GCC’s 1913 helpline. If you need further assistance, please contact GCC 1913 Helpline."; + } + else { + return "Your "+complaintNumber+" complaint is Under Progress.\n Once it is resolved, \n we will reach you by GCC’s 1913 helpline."; + } } } catch (Exception e) { e.printStackTrace(); - return "Error in closing PGR complaint from user "+complaintNumber; + return "We are unable to process your request at the moment.\n Please try again later."; } @@ -204,27 +228,40 @@ public class WhatsappqaqcMsgService { ) ); - String Erpname="QAops72"; + String Erpname=getErpusername(); + + System.out.println("Erpname="+Erpname); if ("Action Taken - Level 2".equalsIgnoreCase(currentStatus)) { - boolean statusUpdated=qaqcCallsService.ChangeStatusInErp(complaintNumber, "", "REOPEN",Erpname); + boolean statusUpdated=qaqcCallsService.ChangeStatusInErp(complaintNumber, "COMPLAINT REOPENED BY WHATSAPP MESSAGE", "REOPEN",Erpname); if (statusUpdated) { - return complaintNumber+ " Complaint Reopened Successfully"; + return "Your "+complaintNumber+ " PGR complaint has been reopened Successfully.\n Once it is resolved , we will reach you by GCC’s 1913 helpline.If you need further assistance , please contact GCC 1913 Helpline."; } else { - return "Unable to Reopen "+complaintNumber+" Complaint"; + return "We are unable to process your request at the moment.\n Please try again later."; } } else { - return "Unable to Reopen "+complaintNumber+" Complaint,Because the complaint status is "+currentStatus; + + if("FINAL_CLOSURE".equalsIgnoreCase(currentStatus)){ + + return "Your " + complaintNumber + " complaint has already been closed.\n\n" + + "If you need further assistance, please contact GCC 1913 Helpline."; + } + else if("REOPENED".equalsIgnoreCase(currentStatus)) { + return "Your "+complaintNumber+" complaint has already been reopened. Once it is resolved, we will reach you by GCC’s 1913 helpline. If you have any further assistance, please contact GCC 1913 Helpline."; + } + else { + return "Your "+complaintNumber+" complaint is Under Progress.\n Once it is resolved, \n we will reach you by GCC’s 1913 helpline."; + } } } catch (Exception e) { e.printStackTrace(); - return "Error in Reopen complaint from user "+complaintNumber; + return "We are unable to process your request at the moment.\n Please try again later."; } diff --git a/src/main/java/in/gov/chennaicorporation/gccoffice/childrensurvey/Service/ChildrenSurveyService.java b/src/main/java/in/gov/chennaicorporation/gccoffice/childrensurvey/Service/ChildrenSurveyService.java index 110082b..1b124f9 100644 --- a/src/main/java/in/gov/chennaicorporation/gccoffice/childrensurvey/Service/ChildrenSurveyService.java +++ b/src/main/java/in/gov/chennaicorporation/gccoffice/childrensurvey/Service/ChildrenSurveyService.java @@ -91,7 +91,18 @@ public class ChildrenSurveyService { 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 = 'q7' + THEN CASE + WHEN csr.others_answer IS NOT NULL + AND TRIM(csr.others_answer) <> '' + THEN csr.others_answer + ELSE gm.english_name + END + 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, @@ -118,6 +129,7 @@ public class ChildrenSurveyService { """); List params = new ArrayList<>(); + // MAX(CASE WHEN cqm.field_name = 'q7' THEN gm.english_name END) AS gender, // 🔍 NAME if (name != null && !name.isEmpty()) { @@ -241,12 +253,16 @@ public class ChildrenSurveyService { String rawAnswer = row.get("answer") != null ? row.get("answer").toString() : ""; + String othersAnswer = row.get("others_answer") != null + ? row.get("others_answer").toString().trim() + : ""; String finalAnswer = resolveAnswer( qid, questionType, masterTable, - rawAnswer); + rawAnswer, + othersAnswer); // PERSONAL INFORMATION /* @@ -335,10 +351,16 @@ public class ChildrenSurveyService { Integer qid, String questionType, String masterTable, - String rawAnswer) { + String rawAnswer, + String othersAnswer) { try { + if (othersAnswer != null + && !othersAnswer.trim().isEmpty()) { + + return othersAnswer; + } if (rawAnswer == null || rawAnswer.trim().isEmpty()) { return ""; } @@ -983,11 +1005,20 @@ public class ChildrenSurveyService { WHEN cqm.field_name = 'q6' THEN csr.answer END) AS child_name, + MAX( + CASE + WHEN cqm.field_name = 'q7' + THEN CASE + WHEN csr.others_answer IS NOT NULL + AND TRIM(csr.others_answer) <> '' + THEN csr.others_answer + ELSE gm.english_name + END + END + ) AS gender, + + - MAX(CASE - WHEN cqm.field_name = 'q7' - THEN gm.english_name - END) AS gender, MAX(CASE WHEN cqm.field_name = 'q10' @@ -1058,6 +1089,12 @@ public class ChildrenSurveyService { """; return jdbcTemplate.queryForList(sql, loginId, locationId, surveyDate); + /* + * MAX(CASE + * WHEN cqm.field_name = 'q7' + * THEN gm.english_name + * END) AS gender, + */ } // dashboard @@ -3362,8 +3399,7 @@ public class ChildrenSurveyService { GROUP BY pr.survey_id - ORDER BY pr.cdate desc - + ORDER BY MAX(pr.cdate) DESC """); // ORDER BY pr.survey_id diff --git a/src/main/java/in/gov/chennaicorporation/gccoffice/configuration/DataSourceConfig.java b/src/main/java/in/gov/chennaicorporation/gccoffice/configuration/DataSourceConfig.java index 58618a8..5bcb8cf 100644 --- a/src/main/java/in/gov/chennaicorporation/gccoffice/configuration/DataSourceConfig.java +++ b/src/main/java/in/gov/chennaicorporation/gccoffice/configuration/DataSourceConfig.java @@ -408,6 +408,51 @@ public class DataSourceConfig { return dataSource; } + /////////////// Road War ///////////////////// + @Bean(name = "mysqlRoadWarDataSource") + public DataSource mysqlRoadWarDataSource() { + DriverManagerDataSource dataSource = new DriverManagerDataSource(); + dataSource.setDriverClassName("com.mysql.cj.jdbc.Driver"); + dataSource.setUrl("jdbc:mysql://" + host + "/gcc_roadwar_web"); + dataSource.setUsername("root"); + dataSource.setPassword(dbpassword); + return dataSource; + } + + // homeles + @Bean(name = "mysqlHomelessSurveyDataSource") + public DataSource mysqlHomelessSurveyDataSource() { + DriverManagerDataSource dataSource = new DriverManagerDataSource(); + dataSource.setDriverClassName("com.mysql.cj.jdbc.Driver"); + dataSource.setUrl("jdbc:mysql://" + host + "/gcc_homeless_survey"); + // dataSource.setUrl("jdbc:mysql://" + host + "/gcc_homeless_survey_live"); + dataSource.setUsername("root"); + dataSource.setPassword(dbpassword); + return dataSource; + } + + /////////////// Bulk Waste Generator ///////////////////// + @Bean(name = "mysqlBulkWasteDataSource") + public DataSource mysqlBulkWasteDataSource() { + DriverManagerDataSource dataSource = new DriverManagerDataSource(); + dataSource.setDriverClassName("com.mysql.cj.jdbc.Driver"); + dataSource.setUrl("jdbc:mysql://" + host + "/bulk_waste"); + dataSource.setUsername("root"); + dataSource.setPassword(dbpassword); + return dataSource; + } + + //////////////////////////////(For GCC USER) //////////////////////// + @Bean(name = "mysqlGCCUserDataSource") + public DataSource mysqlGCCUserDataSource() { + DriverManagerDataSource dataSource = new DriverManagerDataSource(); + dataSource.setDriverClassName("com.mysql.cj.jdbc.Driver"); + dataSource.setUrl("jdbc:mysql://" + host + "/gcc_users"); + dataSource.setUsername("root"); + dataSource.setPassword(dbpassword); + return dataSource; + } + ////////////////////////////// ORACLE //////////////////////// @Bean(name = "oracleDataSource") public DataSource oracleDataSource() { diff --git a/src/main/java/in/gov/chennaicorporation/gccoffice/greencommittee/controller/Maincontroller.java b/src/main/java/in/gov/chennaicorporation/gccoffice/greencommittee/controller/Maincontroller.java index cb481c8..379acc2 100644 --- a/src/main/java/in/gov/chennaicorporation/gccoffice/greencommittee/controller/Maincontroller.java +++ b/src/main/java/in/gov/chennaicorporation/gccoffice/greencommittee/controller/Maincontroller.java @@ -78,4 +78,15 @@ public class Maincontroller { return "modules/greencommittee/reports"; } + @GetMapping("/treepruningreports") + public String viewtreepruningreports(Model model) { + String LoginUserId = LoginUserInfo.getLoginUserId(); + model.addAttribute("LoginUserId", LoginUserId); + + String UserRole = LoginUserInfo.getUserRole(); + model.addAttribute("UserRole", UserRole); + + return "modules/greencommittee/treepruningreports"; + } + } diff --git a/src/main/java/in/gov/chennaicorporation/gccoffice/greencommittee/controller/PendinglistApicontroller.java b/src/main/java/in/gov/chennaicorporation/gccoffice/greencommittee/controller/PendinglistApicontroller.java index 06eae55..9739a80 100644 --- a/src/main/java/in/gov/chennaicorporation/gccoffice/greencommittee/controller/PendinglistApicontroller.java +++ b/src/main/java/in/gov/chennaicorporation/gccoffice/greencommittee/controller/PendinglistApicontroller.java @@ -24,160 +24,159 @@ public class PendinglistApicontroller { @Autowired private PendinglistService pendinglistService; - - + @GetMapping("/getzones") - public List> ViewZoneDropdown() { - - return pendinglistService.ViewZoneDropdown(); - - } - - @GetMapping("/getwardbyzone") - public List> ViewWardDropdown(@RequestParam String zone) { - - return pendinglistService.ViewWardDropdown(zone); - - } - - @GetMapping("/dropdown-Event") - public ResponseEntity>> ViewDropdownEvent() { - try { - List> result = pendinglistService.ViewDropdownEvent(); - return ResponseEntity.ok(result); - } catch (Exception e) { - Map error = new HashMap<>(); - error.put("error", "Unable to fetch event list"); - error.put("details", e.getMessage()); - return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) - .body(Collections.singletonList(error)); - } - } - -// @GetMapping("/getgreencommitteelist") -// public List> getgreencommitteelist(@RequestParam String date, -// @RequestParam String zones) { -// -// List refnums = pendinglistService.getrefnums(date, zones); -// //System.out.println("refnums="+refnums); -// List> savedids=pendinglistService.getvcsavedrefids(); -// //System.err.println("savedids="+savedids); -// // Convert to List -// List savedRefIds = savedids.stream() -// .map(m -> m.get("ref_id").toString()) -// .toList(); -// -// //System.out.println("savedRefIds=" + savedRefIds); -// -// List> finalList = new ArrayList<>(); -// -// if (refnums.isEmpty()) { -// return Collections.emptyList(); -// } -// -// // REMOVE already saved ref_ids -// List filteredRefIds = refnums.stream() -// .filter(ref -> !savedRefIds.contains(ref)) -// .toList(); -// -// //System.out.println("filteredRefIds="+filteredRefIds); -// -// for (String ref : filteredRefIds) { -// Map data = pendinglistService.getlistdata(ref); -// if (data != null && !data.isEmpty()) { -// finalList.add(data); -// } -// } -// -// return finalList; -// } - - - @GetMapping("/getgreencommitteelist") - public List> getgreencommitteelist( - @RequestParam String date, @RequestParam String zones) { - - List> refnums = pendinglistService.getrefnums(date, zones); - System.out.println("refnums="+refnums); - List> savedIds = pendinglistService.getvcsavedrefids(); - System.out.println("savedIds="+savedIds); - // Convert savedIds → List - List savedRefList = new ArrayList<>(); - for (Map m : savedIds) { - savedRefList.add(m.get("ref_id").toString()); - } - - List> finalList = new ArrayList<>(); - - for (Map row : refnums) { - - String refId = row.get("ref_id").toString(); - Integer inspReinsId = row.get("latest_reinspection_id") != null ? - Integer.parseInt(row.get("latest_reinspection_id").toString()) - : null; - - // Skip if already committee decided - if (savedRefList.contains(refId)) continue; - - // Get reinspection latest id - Integer dbLatest = pendinglistService.getLatestReinspectionId(refId); - - // Rule: if inspection reinspection ID is NULL but in DB exists → skip - if (inspReinsId == null && dbLatest != null) continue; - - // Rule: if BOTH exist AND not equal → skip - if (inspReinsId != null && dbLatest != null && !inspReinsId.equals(dbLatest)) - continue; - - // 👍 Valid, add final data - Map data = pendinglistService.getlistdata(refId); - if (data != null && !data.isEmpty()) { - - System.out.println("inside="+refId); - finalList.add(data); - } - } - - return finalList; - } - - - @GetMapping("/getdetailsbyrefid") - public Map getdetailsbyrefid(@RequestParam String refid) { - return pendinglistService.getdetailsbyrefid(refid); - } - - @GetMapping("/getCommitteeActions") - public List> getCommitteeActions() { - - return pendinglistService.getCommitteeActions(); - - } - - @PostMapping("/savecommittee") - public Map saveCommittee(@RequestBody Map payload) { - - String refId = (String) payload.get("ref_id"); - String remarks = (String) payload.get("remarks"); - int userId = Integer.parseInt(payload.get("userId").toString()); - int meetingid = Integer.parseInt(payload.get("meetingid").toString()); - - List> decisions = (List>) payload.get("decisions"); - - return pendinglistService.saveCommittee(refId, remarks, meetingid, userId, decisions); - } - - @PostMapping("/savereinspection") - public Map saveReInspection(@RequestBody Map payload) { - - String refId = payload.get("ref_id").toString(); - int committeeAction = Integer.parseInt(payload.get("committee_action").toString()); - int meetingId = Integer.parseInt(payload.get("meeting_id").toString()); - String remarks = payload.get("remarks") != null ? payload.get("remarks").toString() : null; - int userId = Integer.parseInt(payload.get("userId").toString()); - - return pendinglistService.saveReInspection(refId, committeeAction, meetingId, remarks, userId); - } - - + public List> ViewZoneDropdown() { + + return pendinglistService.ViewZoneDropdown(); + + } + + @GetMapping("/getwardbyzone") + public List> ViewWardDropdown(@RequestParam String zone) { + + return pendinglistService.ViewWardDropdown(zone); + + } + + @GetMapping("/dropdown-Event") + public ResponseEntity>> ViewDropdownEvent() { + try { + List> result = pendinglistService.ViewDropdownEvent(); + return ResponseEntity.ok(result); + } catch (Exception e) { + Map error = new HashMap<>(); + error.put("error", "Unable to fetch event list"); + error.put("details", e.getMessage()); + return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) + .body(Collections.singletonList(error)); + } + } + + // @GetMapping("/getgreencommitteelist") + // public List> getgreencommitteelist(@RequestParam String + // date, + // @RequestParam String zones) { + // + // List refnums = pendinglistService.getrefnums(date, zones); + // //System.out.println("refnums="+refnums); + // List> savedids=pendinglistService.getvcsavedrefids(); + // //System.err.println("savedids="+savedids); + // // Convert to List + // List savedRefIds = savedids.stream() + // .map(m -> m.get("ref_id").toString()) + // .toList(); + // + // //System.out.println("savedRefIds=" + savedRefIds); + // + // List> finalList = new ArrayList<>(); + // + // if (refnums.isEmpty()) { + // return Collections.emptyList(); + // } + // + // // REMOVE already saved ref_ids + // List filteredRefIds = refnums.stream() + // .filter(ref -> !savedRefIds.contains(ref)) + // .toList(); + // + // //System.out.println("filteredRefIds="+filteredRefIds); + // + // for (String ref : filteredRefIds) { + // Map data = pendinglistService.getlistdata(ref); + // if (data != null && !data.isEmpty()) { + // finalList.add(data); + // } + // } + // + // return finalList; + // } + + @GetMapping("/getgreencommitteelist") + public List> getgreencommitteelist( + @RequestParam String date, @RequestParam String zones) { + + List> refnums = pendinglistService.getrefnums(date, zones); + System.out.println("refnums=" + refnums); + List> savedIds = pendinglistService.getvcsavedrefids(); + System.out.println("savedIds=" + savedIds); + // Convert savedIds → List + List savedRefList = new ArrayList<>(); + for (Map m : savedIds) { + savedRefList.add(m.get("ref_id").toString()); + } + + List> finalList = new ArrayList<>(); + + for (Map row : refnums) { + + String refId = row.get("ref_id").toString(); + Integer inspReinsId = row.get("latest_reinspection_id") != null + ? Integer.parseInt(row.get("latest_reinspection_id").toString()) + : null; + + // Skip if already committee decided + if (savedRefList.contains(refId)) + continue; + + // Get reinspection latest id + Integer dbLatest = pendinglistService.getLatestReinspectionId(refId); + + // Rule: if inspection reinspection ID is NULL but in DB exists → skip + if (inspReinsId == null && dbLatest != null) + continue; + + // Rule: if BOTH exist AND not equal → skip + if (inspReinsId != null && dbLatest != null && !inspReinsId.equals(dbLatest)) + continue; + + // 👍 Valid, add final data + Map data = pendinglistService.getlistdata(refId); + if (data != null && !data.isEmpty()) { + + System.out.println("inside=" + refId); + finalList.add(data); + } + } + + return finalList; + } + + @GetMapping("/getdetailsbyrefid") + public Map getdetailsbyrefid(@RequestParam String refid) { + return pendinglistService.getdetailsbyrefid(refid); + } + + @GetMapping("/getCommitteeActions") + public List> getCommitteeActions() { + + return pendinglistService.getCommitteeActions(); + + } + + @PostMapping("/savecommittee") + public Map saveCommittee(@RequestBody Map payload) { + + String refId = (String) payload.get("ref_id"); + String remarks = (String) payload.get("remarks"); + int userId = Integer.parseInt(payload.get("userId").toString()); + int meetingid = Integer.parseInt(payload.get("meetingid").toString()); + + List> decisions = (List>) payload.get("decisions"); + + return pendinglistService.saveCommittee(refId, remarks, meetingid, userId, decisions); + } + + @PostMapping("/savereinspection") + public Map saveReInspection(@RequestBody Map payload) { + + String refId = payload.get("ref_id").toString(); + int committeeAction = Integer.parseInt(payload.get("committee_action").toString()); + int meetingId = Integer.parseInt(payload.get("meeting_id").toString()); + String remarks = payload.get("remarks") != null ? payload.get("remarks").toString() : null; + int userId = Integer.parseInt(payload.get("userId").toString()); + + return pendinglistService.saveReInspection(refId, committeeAction, meetingId, remarks, userId); + } + } diff --git a/src/main/java/in/gov/chennaicorporation/gccoffice/greencommittee/controller/ReportApicontroller.java b/src/main/java/in/gov/chennaicorporation/gccoffice/greencommittee/controller/ReportApicontroller.java index 42b1a7b..9a3984b 100644 --- a/src/main/java/in/gov/chennaicorporation/gccoffice/greencommittee/controller/ReportApicontroller.java +++ b/src/main/java/in/gov/chennaicorporation/gccoffice/greencommittee/controller/ReportApicontroller.java @@ -7,9 +7,11 @@ import java.util.List; import java.util.Map; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.ResponseEntity; 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.greencommittee.service.ReportService; @@ -23,9 +25,9 @@ public class ReportApicontroller { @GetMapping("/getgreencommitteelist") public List> getgreencommitteelist(@RequestParam String meetingid, - @RequestParam String zones) { + @RequestParam String zones, @RequestParam String deptid, @RequestParam String appType) { - List refnums = reportService.getrefnums(meetingid, zones); + List refnums = reportService.getrefnums(meetingid, zones, deptid, appType); System.out.println("refnums=" + refnums); List> finalList = new ArrayList<>(); @@ -130,4 +132,58 @@ public class ReportApicontroller { return response; } + @GetMapping("/getDepartments") + @ResponseBody + public List> getDepartments() { + return reportService.getDepartments(); + } + + @GetMapping("/wards") + public List> getWards(@RequestParam Integer zoneId) { + + return reportService.getWards(zoneId); + + } + + @GetMapping("/zones") + public List> getZones() { + return reportService.getZones(); + } + + @GetMapping("/details") + public ResponseEntity getComplaintDetails( + @RequestParam String complaintId) { + + return ResponseEntity.ok( + reportService.getComplaintDetailsreport(complaintId)); + } + + @GetMapping("/getreport") + public ResponseEntity>> getTreePruningReport( + + @RequestParam String fromDate, + @RequestParam String toDate, + + @RequestParam(required = false) String zone, + + @RequestParam(required = false) String ward, + + @RequestParam(required = false) String status + + ) { + + return ResponseEntity.ok( + + reportService.getReport( + + fromDate, + toDate, + zone, + ward, + status) + + ); + + } + } diff --git a/src/main/java/in/gov/chennaicorporation/gccoffice/greencommittee/service/PendinglistService.java b/src/main/java/in/gov/chennaicorporation/gccoffice/greencommittee/service/PendinglistService.java index ab8e53f..9bf542b 100644 --- a/src/main/java/in/gov/chennaicorporation/gccoffice/greencommittee/service/PendinglistService.java +++ b/src/main/java/in/gov/chennaicorporation/gccoffice/greencommittee/service/PendinglistService.java @@ -4,10 +4,13 @@ import java.sql.PreparedStatement; import java.sql.Statement; import java.sql.Types; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collections; +import java.util.Comparator; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.stream.Collectors; import javax.sql.DataSource; @@ -26,401 +29,421 @@ public class PendinglistService { @Autowired private JdbcTemplate jdbcTemplate; - + @Value("${fileBaseUrl}") private String fileBaseUrl; - + @Autowired public void setDataSource(@Qualifier("mysqlGreenCommitteeDataSource") DataSource dataSource) { this.jdbcTemplate = new JdbcTemplate(dataSource); } - + public List> ViewWardDropdown(String zone) { String sql = "SELECT ward_name " - + "FROM ward_master " - + "WHERE is_active=1 AND is_delete=0 AND zone_id=?"; - try { - return jdbcTemplate.queryForList(sql,zone); + + "FROM ward_master " + + "WHERE is_active=1 AND is_delete=0 AND zone_id=?"; + try { + return jdbcTemplate.queryForList(sql, zone); } catch (Exception e) { // TODO: handle exception - e.printStackTrace(); - return Collections.emptyList(); + e.printStackTrace(); + return Collections.emptyList(); } } public List> ViewZoneDropdown() { String sql = "SELECT zone_name " - + "FROM zone_master " - + "WHERE is_active=1 AND is_delete=0"; - try { - return jdbcTemplate.queryForList(sql); + + "FROM zone_master " + + "WHERE is_active=1 AND is_delete=0"; + try { + return jdbcTemplate.queryForList(sql); } catch (Exception e) { // TODO: handle exception - e.printStackTrace(); - return Collections.emptyList(); + e.printStackTrace(); + return Collections.emptyList(); } } - + public List> ViewDropdownEvent() { - String sql = "SELECT * FROM create_meeting WHERE isactive=1 AND isdelete=0"; - return jdbcTemplate.queryForList(sql); + String sql = "SELECT * FROM create_meeting WHERE isactive=1 AND isdelete=0"; + return jdbcTemplate.queryForList(sql); } -// public List getrefnums(String date, String zones) { -// -// try { -// -// StringBuilder sql = new StringBuilder( -// "SELECT t.ref_id " + -// "FROM ( " + -// " SELECT ref_id, inspection_by, MAX(cdate) AS latest_date " + -// " FROM inspection_data " + -// " WHERE DATE(cdate) <= STR_TO_DATE(?, '%d-%m-%Y') " + -// " AND isactive = 1 " -// ); -// -// List params = new ArrayList<>(); -// params.add(date); -// -// if (zones != null && !zones.isEmpty()) { -// sql.append(" AND zone = ? "); -// params.add(zones); -// } -// -// sql.append( -// " GROUP BY ref_id, inspection_by " + -// ") AS t " + -// "GROUP BY t.ref_id " + -// "HAVING COUNT(DISTINCT t.inspection_by) = 3 " + -// "ORDER BY MAX(t.latest_date) DESC" -// ); -// -// return jdbcTemplate.queryForList(sql.toString(), params.toArray(), String.class); -// -// } catch (Exception e) { -// -// System.err.println("Error in getrefums(): " + e.getMessage()); -// e.printStackTrace(); -// return Collections.emptyList(); -// } -// } - + // public List getrefnums(String date, String zones) { + // + // try { + // + // StringBuilder sql = new StringBuilder( + // "SELECT t.ref_id " + + // "FROM ( " + + // " SELECT ref_id, inspection_by, MAX(cdate) AS latest_date " + + // " FROM inspection_data " + + // " WHERE DATE(cdate) <= STR_TO_DATE(?, '%d-%m-%Y') " + + // " AND isactive = 1 " + // ); + // + // List params = new ArrayList<>(); + // params.add(date); + // + // if (zones != null && !zones.isEmpty()) { + // sql.append(" AND zone = ? "); + // params.add(zones); + // } + // + // sql.append( + // " GROUP BY ref_id, inspection_by " + + // ") AS t " + + // "GROUP BY t.ref_id " + + // "HAVING COUNT(DISTINCT t.inspection_by) = 3 " + + // "ORDER BY MAX(t.latest_date) DESC" + // ); + // + // return jdbcTemplate.queryForList(sql.toString(), params.toArray(), + // String.class); + // + // } catch (Exception e) { + // + // System.err.println("Error in getrefums(): " + e.getMessage()); + // e.printStackTrace(); + // return Collections.emptyList(); + // } + // } + public List> getrefnums(String date, String zones) { + System.out.println(date + " " + zones); - try { - - StringBuilder sql = new StringBuilder( - "SELECT ref_id, " + - " MAX(latest_reinspection_id) AS latest_reinspection_id " + - "FROM ( " + - " SELECT ref_id, inspection_by, " + - " MAX(cdate) AS latest_date, " + - " MAX(reinspection_id) AS latest_reinspection_id " + - " FROM inspection_data " + - " WHERE DATE(cdate) <= STR_TO_DATE(?, '%d-%m-%Y') " + - " AND isactive = 1 " - ); - - List params = new ArrayList<>(); - params.add(date); - - if (zones != null && !zones.isEmpty()) { - sql.append(" AND zone = ? "); - params.add(zones); - } - - sql.append( - " GROUP BY ref_id, inspection_by " + - ") AS x " + - "GROUP BY ref_id " + - "HAVING COUNT(DISTINCT inspection_by) = 3 " + - "ORDER BY MAX(latest_date) DESC" - ); - - return jdbcTemplate.queryForList(sql.toString(), params.toArray()); - - } catch (Exception e) { - e.printStackTrace(); - return Collections.emptyList(); - } - } + try { + StringBuilder sql = new StringBuilder( + "SELECT ref_id, " + + " MAX(latest_reinspection_id) AS latest_reinspection_id " + + "FROM ( " + + " SELECT ref_id, inspection_by, " + + " MAX(cdate) AS latest_date, " + + " MAX(reinspection_id) AS latest_reinspection_id " + + " FROM inspection_data " + + " WHERE DATE(cdate) <= STR_TO_DATE(?, '%d-%m-%Y') " + + " AND isactive = 1 "); + + List params = new ArrayList<>(); + params.add(date); + + if (zones != null && !zones.isEmpty()) { + sql.append(" AND zone = ? "); + params.add(zones); + } - - public Integer getLatestReinspectionId(String refId) { - try { - String sql = "SELECT id FROM reinspection WHERE ref_id=? ORDER BY id DESC LIMIT 1"; - return jdbcTemplate.queryForObject(sql, Integer.class, refId); - } catch (Exception e) { - return null; - } - } + sql.append( + " GROUP BY ref_id, inspection_by " + + ") AS x " + + "GROUP BY ref_id " + + "HAVING COUNT(DISTINCT inspection_by) >= 2 " + + "ORDER BY MAX(latest_date) DESC"); + return jdbcTemplate.queryForList(sql.toString(), params.toArray()); + } catch (Exception e) { + e.printStackTrace(); + return Collections.emptyList(); + } + } + + public Integer getLatestReinspectionId(String refId) { + try { + String sql = "SELECT id FROM reinspection WHERE ref_id=? ORDER BY id DESC LIMIT 1"; + return jdbcTemplate.queryForObject(sql, Integer.class, refId); + } catch (Exception e) { + return null; + } + } public Map getlistdata(String ref) { - Map regDetails = getRegDetails(ref); + Map regDetails = getRegDetails(ref); - List> compDetails = getComplaintDetails(ref); + List> compDetails = getComplaintDetails(ref); - regDetails.put("comp_details", compDetails); + regDetails.put("comp_details", compDetails); - return regDetails; + return regDetails; } - + public Map getRegDetails(String ref) { - String sql = "SELECT * FROM reg_details WHERE is_active = 1 AND ref_id = ?"; - return jdbcTemplate.queryForMap(sql, ref); + String sql = "SELECT * FROM reg_details WHERE is_active = 1 AND ref_id = ?"; + return jdbcTemplate.queryForMap(sql, ref); } public List> getComplaintDetails(String ref) { - String sql = "SELECT cn.name AS nature, SUM(cd.no_of_trees) AS total_trees " + - "FROM complaint_details cd " + - "JOIN comp_nature cn ON cn.id = cd.comp_nature_id " + - "WHERE cd.is_active = 1 AND cd.ref_id = ? " + - "GROUP BY cn.name"; + String sql = "SELECT cn.name AS nature, SUM(cd.no_of_trees) AS total_trees " + + "FROM complaint_details cd " + + "JOIN comp_nature cn ON cn.id = cd.comp_nature_id " + + "WHERE cd.is_active = 1 AND cd.ref_id = ? " + + "GROUP BY cn.name"; - return jdbcTemplate.queryForList(sql, ref); + return jdbcTemplate.queryForList(sql, ref); } - public Map getdetailsbyrefid(String refId) { - Map response = new HashMap<>(); - - // 1 — Application details - Map app = jdbcTemplate.queryForMap( - "SELECT *,DATE_FORMAT(cdate, '%d-%m-%Y %l:%i %p') as r_Cdate FROM reg_details WHERE ref_id=? AND is_active=1", - refId - ); - - // 2 — Complaint details (grouped) - List> complaints = jdbcTemplate.queryForList( - "SELECT cn.name AS nature, SUM(cd.no_of_trees) AS count " + - "FROM complaint_details cd JOIN comp_nature cn ON cn.id=cd.comp_nature_id " + - "WHERE cd.ref_id=? GROUP BY cn.name", refId - ); - - // 3 — Complaint images - List compImages = jdbcTemplate.queryForList( - "SELECT img_path FROM img_uploads WHERE ref_id=? AND is_active=1", - new Object[]{refId}, String.class - ).stream() - .map(path -> fileBaseUrl + "/gccofficialapp/files" + path) - .collect(Collectors.toList()); - - app.put("complaints", complaints); - app.put("images", compImages); - response.put("application", app); - - // 4 — Inspection details - List> inspectionList = new ArrayList<>(); - - String sql = - "SELECT id.*, um.name AS inspector_name, " + - " DATE_FORMAT(id.cdate, '%d-%m-%Y %l:%i %p') AS f_Cdate " + - "FROM inspection_data id " + - "LEFT JOIN user_maping um ON um.userid = id.cby " + - "INNER JOIN ( " + - " SELECT inspection_by, MAX(cdate) AS latest_date " + - " FROM inspection_data " + - " WHERE ref_id = ? AND isactive = 1 " + - " GROUP BY inspection_by " + - ") latest ON id.inspection_by = latest.inspection_by " + - " AND id.cdate = latest.latest_date " + - "WHERE id.ref_id = ? AND id.isactive = 1 " + - "ORDER BY FIELD(id.inspection_by, 'GCC', 'NGO', 'TNFD')"; - - List> rows = jdbcTemplate.queryForList( - sql, refId, refId - ); - - - for (Map row : rows) { - - Integer inspId = (Integer) row.get("inspection_data_id"); - - // 4a — Recommendation details - List> recommend = jdbcTemplate.queryForList( - "SELECT rm.name, itd.nooftrees AS count " + - "FROM inspection_tree_data itd " + - "JOIN inspection_recommend_master rm ON rm.rid = itd.action " + - "WHERE itd.inspection_data_id=? AND itd.isactive=1", - inspId - ); - - row.put("recommendations", recommend); - - // 4b — Images (thumbnail list) - List imgs = new ArrayList<>(); - if (row.get("file_1") != null) { - imgs.add(fileBaseUrl + "/gccofficialapp/files" + row.get("file_1").toString()); - } - if (row.get("file_2") != null) { - imgs.add(fileBaseUrl + "/gccofficialapp/files" + row.get("file_2").toString()); - } - if (row.get("file_3") != null) { - imgs.add(fileBaseUrl + "/gccofficialapp/files" + row.get("file_3").toString()); - } - - row.put("images", imgs); - - inspectionList.add(row); - } - - response.put("inspections", inspectionList); - - // 5 — Re-Inspection Details - String reSql = - "SELECT r.id AS reins_id, r.committee_action, r.remarks AS reins_remarks, " + - " DATE_FORMAT(r.cdate, '%d-%m-%Y %l:%i %p') AS reins_date, " + - " cm.event_name, DATE_FORMAT(cm.event_date, '%d-%m-%Y') AS event_date " + - "FROM reinspection r " + - "LEFT JOIN create_meeting cm ON cm.id = r.meeting_id " + - "WHERE r.ref_id = ? AND r.isactive = 1 " + - "ORDER BY r.id DESC"; - - List> reinspectionList = jdbcTemplate.queryForList(reSql, refId); - - response.put("reinspections", reinspectionList); - - - return response; + Map response = new HashMap<>(); + + // 1 — Application details + Map app = jdbcTemplate.queryForMap( + "SELECT *,DATE_FORMAT(cdate, '%d-%m-%Y %l:%i %p') as r_Cdate FROM reg_details WHERE ref_id=? AND is_active=1", + refId); + + // 2 — Complaint details (grouped) + List> complaints = jdbcTemplate.queryForList( + "SELECT cn.name AS nature, SUM(cd.no_of_trees) AS count " + + "FROM complaint_details cd JOIN comp_nature cn ON cn.id=cd.comp_nature_id " + + "WHERE cd.ref_id=? GROUP BY cn.name", + refId); + + // 3 — Complaint images + List compImages = jdbcTemplate.queryForList( + "SELECT img_path FROM img_uploads WHERE ref_id=? AND is_active=1", + new Object[] { refId }, String.class).stream() + .map(path -> fileBaseUrl + "/gccofficialapp/files" + path) + .collect(Collectors.toList()); + + app.put("complaints", complaints); + app.put("images", compImages); + response.put("application", app); + + // 4 — Inspection details + List> inspectionList = new ArrayList<>(); + + String sql = "SELECT id.*, um.name AS inspector_name, " + + " DATE_FORMAT(id.cdate, '%d-%m-%Y %l:%i %p') AS f_Cdate " + + "FROM inspection_data id " + + "LEFT JOIN user_maping um ON um.userid = id.cby " + + "INNER JOIN ( " + + " SELECT inspection_by, MAX(cdate) AS latest_date " + + " FROM inspection_data " + + " WHERE ref_id = ? AND isactive = 1 " + + " GROUP BY inspection_by " + + ") latest ON id.inspection_by = latest.inspection_by " + + " AND id.cdate = latest.latest_date " + + "WHERE id.ref_id = ? AND id.isactive = 1 " + + "ORDER BY FIELD(id.inspection_by, 'GCC', 'NGO', 'TNFD')"; + + List> rows = jdbcTemplate.queryForList( + sql, refId, refId); + + for (Map row : rows) { + + Integer inspId = (Integer) row.get("inspection_data_id"); + + // 4a — Recommendation details + List> recommend = jdbcTemplate.queryForList( + "SELECT rm.name, itd.nooftrees AS count,itd.treename as treename " + + "FROM inspection_tree_data itd " + + "JOIN inspection_recommend_master rm ON rm.rid = itd.action " + + "WHERE itd.inspection_data_id=? AND itd.isactive=1", + inspId); + + row.put("recommendations", recommend); + + // 4b — Images (thumbnail list) + List imgs = new ArrayList<>(); + if (row.get("file_1") != null) { + imgs.add(fileBaseUrl + "/gccofficialapp/files" + row.get("file_1").toString()); + } + if (row.get("file_2") != null) { + imgs.add(fileBaseUrl + "/gccofficialapp/files" + row.get("file_2").toString()); + } + if (row.get("file_3") != null) { + imgs.add(fileBaseUrl + "/gccofficialapp/files" + row.get("file_3").toString()); + } + + row.put("images", imgs); + + inspectionList.add(row); + } + // ak + // Expected inspection stages + List expected = Arrays.asList("GCC", "NGO", "TNFD"); + + // Completed stages + Set completed = inspectionList.stream() + .map(m -> String.valueOf(m.get("inspection_by"))) + .collect(Collectors.toSet()); + + // Add pending cards + for (String type : expected) { + + if (!completed.contains(type)) { + + Map pending = new HashMap<>(); + + pending.put("inspection_by", type); + pending.put("status", "PENDING"); + pending.put("inspector_name", ""); + pending.put("f_Cdate", ""); + pending.put("remarks", ""); + pending.put("recommendations", new ArrayList<>()); + pending.put("images", new ArrayList<>()); + + inspectionList.add(pending); + } + } + + // Sort in order GCC -> NGO -> TNFD + Map order = new HashMap<>(); + order.put("GCC", 1); + order.put("NGO", 2); + order.put("TNFD", 3); + + inspectionList.sort( + Comparator.comparingInt( + m -> order.getOrDefault(String.valueOf(m.get("inspection_by")), 99))); + + response.put("inspections", inspectionList); + + // 5 — Re-Inspection Details + String reSql = "SELECT r.id AS reins_id, r.committee_action, r.remarks AS reins_remarks, " + + " DATE_FORMAT(r.cdate, '%d-%m-%Y %l:%i %p') AS reins_date, " + + " cm.event_name, DATE_FORMAT(cm.event_date, '%d-%m-%Y') AS event_date " + + "FROM reinspection r " + + "LEFT JOIN create_meeting cm ON cm.id = r.meeting_id " + + "WHERE r.ref_id = ? AND r.isactive = 1 " + + "ORDER BY r.id DESC"; + + List> reinspectionList = jdbcTemplate.queryForList(reSql, refId); + + response.put("reinspections", reinspectionList); + + return response; } public List> getCommitteeActions() { String sql = "SELECT id,name " - + "FROM committee_recommend_master " - + "WHERE isactive=1 AND isdelete=0 " - + "ORDER BY orderby"; - try { - return jdbcTemplate.queryForList(sql); + + "FROM committee_recommend_master " + + "WHERE isactive=1 AND isdelete=0 " + + "ORDER BY orderby"; + try { + return jdbcTemplate.queryForList(sql); } catch (Exception e) { // TODO: handle exception - e.printStackTrace(); - return Collections.emptyList(); + e.printStackTrace(); + return Collections.emptyList(); } } - public Map saveCommittee( - String refId, - String remarks, - int meetingid, - int userId, - List> decisions - ) { + String refId, + String remarks, + int meetingid, + int userId, + List> decisions) { - Map response = new HashMap<>(); + Map response = new HashMap<>(); - try { - // 1️⃣ Save committee_data and get generated ID - int committeeDataId = saveCommitteeData(refId, remarks, meetingid, userId); + try { + // 1️⃣ Save committee_data and get generated ID + int committeeDataId = saveCommitteeData(refId, remarks, meetingid, userId); - List insertedTreeIds = saveCommitteeTreeData(decisions, committeeDataId, refId, userId); + List insertedTreeIds = saveCommitteeTreeData(decisions, committeeDataId, refId, userId); - response.put("committee_data_id", committeeDataId); - response.put("tree_ids", insertedTreeIds); - response.put("status", "success"); - response.put("message", "Committee decision saved!"); + response.put("committee_data_id", committeeDataId); + response.put("tree_ids", insertedTreeIds); + response.put("status", "success"); + response.put("message", "Committee decision saved!"); - } catch (Exception e) { - response.put("status", "error"); - response.put("message", e.getMessage()); - } + } catch (Exception e) { + response.put("status", "error"); + response.put("message", e.getMessage()); + } - return response; + return response; } - + public int saveCommitteeData(String refId, String remarks, int meetingid, int userId) { - - String remarksValue = (remarks == null || remarks.trim().isEmpty()) ? null : remarks.trim(); - - String sql = "INSERT INTO committee_data (ref_id, meeting_id, remarks, cby) VALUES (?, ?, ?, ?)"; - - KeyHolder keyHolder = new GeneratedKeyHolder(); - - jdbcTemplate.update(connection -> { - PreparedStatement ps = connection.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS); - ps.setString(1, refId); - ps.setInt(2, meetingid); - if (remarksValue == null) { - ps.setNull(3, Types.VARCHAR); - } else { - ps.setString(3, remarksValue); - } - ps.setInt(4, userId); - return ps; - }, keyHolder); - - return keyHolder.getKey().intValue(); // generated committee_data.id - } + String remarksValue = (remarks == null || remarks.trim().isEmpty()) ? null : remarks.trim(); + + String sql = "INSERT INTO committee_data (ref_id, meeting_id, remarks, cby) VALUES (?, ?, ?, ?)"; + + KeyHolder keyHolder = new GeneratedKeyHolder(); + + jdbcTemplate.update(connection -> { + PreparedStatement ps = connection.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS); + ps.setString(1, refId); + ps.setInt(2, meetingid); + if (remarksValue == null) { + ps.setNull(3, Types.VARCHAR); + } else { + ps.setString(3, remarksValue); + } + ps.setInt(4, userId); + return ps; + }, keyHolder); + + return keyHolder.getKey().intValue(); // generated committee_data.id + } public List saveCommitteeTreeData( - List> decisions, - int committeeDataId, - String refId, - int userId - ) { + List> decisions, + int committeeDataId, + String refId, + int userId) { - String sql = "INSERT INTO committee_tree_data (nooftrees, committee_action, committee_data_id, ref_id, cby) " + - "VALUES (?, ?, ?, ?, ?)"; + String sql = "INSERT INTO committee_tree_data (nooftrees, committee_action, committee_data_id, ref_id, cby) " + + "VALUES (?, ?, ?, ?, ?)"; - List insertedIds = new ArrayList<>(); + List insertedIds = new ArrayList<>(); - for (Map row : decisions) { + for (Map row : decisions) { - int actionId = Integer.parseInt(row.get("id").toString()); - int count = Integer.parseInt(row.get("count").toString()); + int actionId = Integer.parseInt(row.get("id").toString()); + int count = Integer.parseInt(row.get("count").toString()); - KeyHolder keyHolder = new GeneratedKeyHolder(); + KeyHolder keyHolder = new GeneratedKeyHolder(); - jdbcTemplate.update(connection -> { - PreparedStatement ps = connection.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS); - ps.setInt(1, count); - ps.setInt(2, actionId); - ps.setInt(3, committeeDataId); - ps.setString(4, refId); - ps.setInt(5, userId); - return ps; - }, keyHolder); + jdbcTemplate.update(connection -> { + PreparedStatement ps = connection.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS); + ps.setInt(1, count); + ps.setInt(2, actionId); + ps.setInt(3, committeeDataId); + ps.setString(4, refId); + ps.setInt(5, userId); + return ps; + }, keyHolder); - insertedIds.add(keyHolder.getKey().intValue()); - } + insertedIds.add(keyHolder.getKey().intValue()); + } - return insertedIds; + return insertedIds; } public List> getvcsavedrefids() { - String sql="SELECT ref_id FROM committee_data WHERE isactive=1"; + String sql = "SELECT ref_id FROM committee_data WHERE isactive=1"; try { return jdbcTemplate.queryForList(sql); } catch (Exception e) { // TODO: handle exception e.printStackTrace(); return Collections.emptyList(); - + } } - + @Transactional public Map saveReInspection(String refId, int action, int meetingId, - String remarks, int userId) { + String remarks, int userId) { - Map response = new HashMap<>(); + Map response = new HashMap<>(); try { - - // Insert into reinspection table - String sql = "INSERT INTO reinspection (ref_id, committee_action, meeting_id, remarks, cby) " + - "VALUES (?, ?, ?, ?, ?)"; - - KeyHolder keyHolder = new GeneratedKeyHolder(); - - jdbcTemplate.update(connection -> { + + // Insert into reinspection table + String sql = "INSERT INTO reinspection (ref_id, committee_action, meeting_id, remarks, cby) " + + "VALUES (?, ?, ?, ?, ?)"; + + KeyHolder keyHolder = new GeneratedKeyHolder(); + + jdbcTemplate.update(connection -> { PreparedStatement ps = connection.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS); ps.setString(1, refId); ps.setInt(2, action); @@ -428,30 +451,26 @@ public class PendinglistService { ps.setString(4, remarks); ps.setInt(5, userId); return ps; - }, keyHolder); - - int generatedId = keyHolder.getKey().intValue(); - - // Update reg_details.reinspection_id - jdbcTemplate.update("UPDATE reg_details SET reinspection_id=? WHERE ref_id=?",generatedId, refId); - - jdbcTemplate.update("UPDATE inspection_data SET isactive=0,isdelete=1 WHERE ref_id=?", refId); - - response.put("status", "success"); - response.put("message", "Committee decision saved!"); - response.put("reinspection_id", generatedId); - - } - catch (Exception e) - { - response.put("status", "error"); - response.put("message", e.getMessage()); - } - - return response; - + }, keyHolder); + + int generatedId = keyHolder.getKey().intValue(); + + // Update reg_details.reinspection_id + jdbcTemplate.update("UPDATE reg_details SET reinspection_id=? WHERE ref_id=?", generatedId, refId); + + jdbcTemplate.update("UPDATE inspection_data SET isactive=0,isdelete=1 WHERE ref_id=?", refId); + + response.put("status", "success"); + response.put("message", "Committee decision saved!"); + response.put("reinspection_id", generatedId); + + } catch (Exception e) { + response.put("status", "error"); + response.put("message", e.getMessage()); } + return response; + } } diff --git a/src/main/java/in/gov/chennaicorporation/gccoffice/greencommittee/service/ReportService.java b/src/main/java/in/gov/chennaicorporation/gccoffice/greencommittee/service/ReportService.java index 6d01996..cdff117 100644 --- a/src/main/java/in/gov/chennaicorporation/gccoffice/greencommittee/service/ReportService.java +++ b/src/main/java/in/gov/chennaicorporation/gccoffice/greencommittee/service/ReportService.java @@ -1,5 +1,8 @@ package in.gov.chennaicorporation.gccoffice.greencommittee.service; +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.net.HttpURLConnection; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; @@ -15,6 +18,12 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.stereotype.Service; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import java.net.URL; +import java.net.URLEncoder; +import com.fasterxml.jackson.core.type.TypeReference; + @Service public class ReportService { @@ -29,7 +38,7 @@ public class ReportService { this.jdbcTemplate = new JdbcTemplate(dataSource); } - public List getrefnums(String meetingid, String zones) { + public List getrefnums(String meetingid, String zones, String deptid, String appType) { try { StringBuilder sql = new StringBuilder( @@ -80,6 +89,22 @@ public class ReportService { params.add(zones); } + if (deptid != null && !deptid.isEmpty()) { + sql.append( + " AND ref_id IN ( " + + " SELECT ref_id FROM reg_details WHERE dept_id = ? " + + " ) "); + params.add(deptid); + } + + if (appType != null && !appType.isEmpty()) { + sql.append( + " AND ref_id IN ( " + + " SELECT ref_id FROM reg_details WHERE cby = ? " + + " ) "); + params.add(appType); + } + return jdbcTemplate.queryForList( sql.toString(), params.toArray(), @@ -182,7 +207,7 @@ public class ReportService { } public Map getRegDetails(String ref) { - String sql = "SELECT * FROM reg_details WHERE is_active = 1 AND ref_id = ?"; + String sql = "SELECT rd.*,dm.name as department_name FROM reg_details rd left join dept_master dm on dm.id=rd.dept_id WHERE rd.is_active = 1 AND rd.ref_id = ?"; return jdbcTemplate.queryForMap(sql, ref); } @@ -518,4 +543,201 @@ public class ReportService { return response; } + public List> getDepartments() { + + String sql = "SELECT id, name FROM dept_master WHERE is_active = 1 ORDER BY id"; + + return jdbcTemplate.queryForList(sql); + } + + public List> getZones() { + + String sql = """ + SELECT id, zone_name + FROM gcc_street_vendor.zone_master + ORDER BY zone_name + """; + + return jdbcTemplate.queryForList(sql); + } + + public List> getWards(Integer zoneId) { + + String sql = """ + SELECT id, + ward_name + FROM gcc_street_vendor.ward_master + WHERE zone_id=? + ORDER BY ward_name + """; + + return jdbcTemplate.queryForList(sql, zoneId); + + } + + public List> getReport( + String fromDate, + String toDate, + String zone, + String ward, + String status) { + + List> result = new ArrayList<>(); + + try { + + String externalUrl = "https://erp.chennaicorporation.gov.in/pgr/newmobileservice"; + + StringBuilder url = new StringBuilder(externalUrl); + + url.append("?serviceId=ms_dashboard_details"); + + // Mandatory + url.append("&From_date=").append(URLEncoder.encode(fromDate, "UTF-8")); + url.append("&To_date=").append(URLEncoder.encode(toDate, "UTF-8")); + url.append("&jsonResp=Yes"); + + // Status + if (status == null || status.trim().isEmpty()) { + url.append("&Status=total"); + } else { + url.append("&Status=").append(URLEncoder.encode(status, "UTF-8")); + } + + // Mandatory Parameters + url.append("&isQcuser=Yes"); + url.append("&ComplaintType=") + .append(URLEncoder.encode("Tree Pruning", "UTF-8")); + + url.append("&ComplaintGroupId=") + .append(URLEncoder.encode("Park and Playground", "UTF-8")); + + // Zone + if (zone != null && !zone.trim().isEmpty()) { + url.append("&Zoneid=N") + .append(String.format("%02d", Integer.parseInt(zone))); + } else { + url.append("&Zoneid="); + } + + // Mandatory blank + url.append("&RegionId="); + + // Ward + if (ward != null && !ward.trim().isEmpty()) { + url.append("&WardId=N") + .append(String.format("%03d", Integer.parseInt(ward))); + } else { + url.append("&WardId="); + } + + System.out.println("======================================"); + System.out.println("Calling URL:"); + System.out.println(url.toString()); + System.out.println("======================================"); + + URL api = new URL(url.toString()); + + HttpURLConnection conn = (HttpURLConnection) api.openConnection(); + conn.setRequestMethod("GET"); + conn.setRequestProperty("Accept", "application/json"); + + int responseCode = conn.getResponseCode(); + + System.out.println("Response Code : " + responseCode); + + BufferedReader br; + + if (responseCode >= 200 && responseCode < 300) { + br = new BufferedReader( + new InputStreamReader(conn.getInputStream())); + } else { + br = new BufferedReader( + new InputStreamReader(conn.getErrorStream())); + } + + StringBuilder response = new StringBuilder(); + + String line; + + while ((line = br.readLine()) != null) { + response.append(line); + } + + br.close(); + + System.out.println("API Response:"); + System.out.println(response.toString()); + + ObjectMapper mapper = new ObjectMapper(); + + JsonNode root = mapper.readTree(response.toString()); + + JsonNode details = root.get("Details"); + + if (details != null && details.isArray()) { + + result = mapper.convertValue( + details, + new TypeReference>>() { + }); + + } + + } catch (Exception e) { + + e.printStackTrace(); + + } + + return result; + } + + public Map getComplaintDetailsreport(String complaintId) { + + try { + + String url = "https://erp.chennaicorporation.gov.in/pgr/newmobileservice" + + "?serviceId=getComplaintByID" + + "&ComplaintId=" + URLEncoder.encode(complaintId, "UTF-8") + + "&imgUrlonly=yes" + + "&isQcuser=Yes" + + "&jsonResp=Yes"; + + HttpURLConnection conn = (HttpURLConnection) new URL(url).openConnection(); + + conn.setRequestMethod("GET"); + + BufferedReader br = new BufferedReader( + new InputStreamReader(conn.getInputStream())); + + StringBuilder sb = new StringBuilder(); + + String line; + + while ((line = br.readLine()) != null) { + sb.append(line); + } + + br.close(); + + ObjectMapper mapper = new ObjectMapper(); + + List> response = mapper.readValue( + sb.toString(), + new TypeReference>>() { + }); + + Map root = response.get(0); + + List> history = (List>) root.get("ComplaintListHistory"); + + return history.get(0); + + } catch (Exception e) { + e.printStackTrace(); + return Collections.emptyMap(); + } + } + } diff --git a/src/main/java/in/gov/chennaicorporation/gccoffice/homelesssurvey/Controller/HomelessSurveyController.java b/src/main/java/in/gov/chennaicorporation/gccoffice/homelesssurvey/Controller/HomelessSurveyController.java new file mode 100644 index 0000000..ad91feb --- /dev/null +++ b/src/main/java/in/gov/chennaicorporation/gccoffice/homelesssurvey/Controller/HomelessSurveyController.java @@ -0,0 +1,815 @@ +package in.gov.chennaicorporation.gccoffice.homelesssurvey.Controller; + +import java.io.ByteArrayOutputStream; +import java.io.InputStream; +import java.net.URL; +import java.net.http.HttpHeaders; +import java.util.List; +import java.util.Map; +import java.util.zip.ZipEntry; +import java.util.zip.ZipOutputStream; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.io.ByteArrayResource; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +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.bind.annotation.RestController; +import org.springframework.core.io.ByteArrayResource; +import org.springframework.core.io.Resource; + +import in.gov.chennaicorporation.gccoffice.homelesssurvey.Service.HomelessSurveyService; + +@RestController +@RequestMapping("/gcc/api/homeless-survey") +public class HomelessSurveyController { + + @Autowired + private HomelessSurveyService service; + + @GetMapping("/list") + public ResponseEntity>> getHomelessSurveyList( + + @RequestParam(required = false) String zone, + @RequestParam(required = false) String ward, + @RequestParam(required = false) String fromDate, + @RequestParam(required = false) String toDate) { + + return ResponseEntity.ok( + service.getHomelessSurveyList( + zone, + ward, + fromDate, + toDate)); + } + + @GetMapping("/zones") + public ResponseEntity>> getZones() { + + return ResponseEntity.ok( + service.getZones()); + } + + @GetMapping("/wards") + public ResponseEntity>> getWards( + @RequestParam String zoneId) { + + return ResponseEntity.ok( + service.getWards(zoneId)); + } + + @GetMapping("/nonsurveyed/list") + @ResponseBody + public List> getHomelessNonSurveyedList( + + @RequestParam(required = false) String zone, + @RequestParam(required = false) String ward, + @RequestParam(required = false) String fromDate, + @RequestParam(required = false) String toDate) { + + return service.getHomelessNonSurveyedList( + zone, + ward, + fromDate, + toDate); + } + + @GetMapping("/details") + public ResponseEntity>> getSurveyDetails( + @RequestParam String surveyId) { + + return ResponseEntity.ok( + service.getHomelessSurveyDetails(surveyId)); + } + + @GetMapping("/document-count") + public ResponseEntity getDocumentCount( + @RequestParam String surveyId) { + + return ResponseEntity.ok( + service.getDocumentCount(surveyId)); + } + + @GetMapping("/documents") + public ResponseEntity>> getDocuments( + @RequestParam String surveyId) { + System.out.println("surveyId"); + System.out.println(surveyId); + + return ResponseEntity.ok( + service.getSurveyDocuments(surveyId)); + } + + /* + * @GetMapping("/download") + * public ResponseEntity downloadFile( + * + * @RequestParam String fileUrl) throws Exception { + * + * URL url = new URL(fileUrl); + * + * InputStream inputStream = url.openStream(); + * + * byte[] bytes = inputStream.readAllBytes(); + * + * ByteArrayResource resource = new ByteArrayResource(bytes); + * + * String fileName = fileUrl.substring( + * fileUrl.lastIndexOf("/") + 1); + * + * return ResponseEntity.ok() + * .header( + * HttpHeaders.CONTENT_DISPOSITION, + * "attachment; filename=\"" + + * fileName + "\"") + * .contentLength(bytes.length) + * .body(resource); + * } + */ + @GetMapping("/download-all-documents") + public ResponseEntity downloadAllDocuments( + @RequestParam String surveyId) throws Exception { + + List> documents = service.getSurveyDocuments(surveyId); + + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + + ZipOutputStream zipOut = new ZipOutputStream(baos); + + for (Map doc : documents) { + + String fileUrl = String.valueOf(doc.get("file_url")); + + String documentName = String.valueOf(doc.get("document_name")) + .replaceAll("\\s+", "_"); + + URL url = new URL(fileUrl); + + InputStream is = url.openStream(); + + byte[] fileBytes = is.readAllBytes(); + + String extension = fileUrl.substring(fileUrl.lastIndexOf(".")); + + ZipEntry zipEntry = new ZipEntry( + documentName + "_" + + surveyId + + extension); + + zipOut.putNextEntry(zipEntry); + + zipOut.write(fileBytes); + + zipOut.closeEntry(); + + is.close(); + } + + zipOut.close(); + + return ResponseEntity.ok() + .header( + "Content-Disposition", + "attachment; filename=\"" + + surveyId + + "_Documents.zip\"") + .header( + "Content-Type", + "application/zip") + .body(baos.toByteArray()); + } + + /* + * @GetMapping("/download-document") + * public ResponseEntity downloadDocument( + * + * @RequestParam String fileUrl, + * + * @RequestParam String fileName) { + * + * try { + * + * URL url = new URL(fileUrl); + * + * InputStream is = url.openStream(); + * + * byte[] fileBytes = is.readAllBytes(); + * + * String extension = fileUrl.substring( + * fileUrl.lastIndexOf(".")); + * + * return ResponseEntity.ok() + * .header( + * "Content-Disposition", + * "attachment; filename=\"" + fileName + extension + "\"") + * .header( + * "Content-Type", + * "application/octet-stream") + * .body(fileBytes); + * + * } catch (Exception e) { + * + * throw new RuntimeException(e); + * } + * } + */ + @GetMapping("/categories") + public ResponseEntity>> getCategories() { + + return ResponseEntity.ok( + service.getCategories()); + } + + @GetMapping("/getSurveyorsList") + @ResponseBody + public List> getSurveyorsList( + + @RequestParam(required = false) String zone, + @RequestParam(required = false) String ward, + @RequestParam(required = false) String fromDate, + @RequestParam(required = false) String toDate) { + + return service.getSurveyorsList( + zone, + ward, + fromDate, + toDate); + } + + @GetMapping("/surveyor-details") + public ResponseEntity>> getSurveyorDetails( + + @RequestParam String loginId, + @RequestParam String zone, + @RequestParam String ward, + @RequestParam String surveyDate) { + + return ResponseEntity.ok( + service.getSurveyorWiseSurveyList( + loginId, + zone, + ward, + surveyDate)); + } + + @GetMapping("/gendermasterlist") + public List> getGenderList() { + + return service.getGenderList(); + } + + @PostMapping("/gendersave") + public String saveGender( + @RequestBody Map req) { + + service.saveGender(req); + + return "SUCCESS"; + } + + @PostMapping("/gender-status") + public String updateGenderStatus( + @RequestBody Map req) { + + service.updateGenderStatus(req); + + return "SUCCESS"; + } + + @GetMapping("/relationtypemasterlist") + public List> getRelationTypeList() { + + return service.getRelationTypeList(); + } + + @PostMapping("/relationtypesave") + public String saveRelationType( + @RequestBody Map req) { + + service.saveRelationType(req); + + return "SUCCESS"; + } + + @PostMapping("/relationtype-status") + public String updateRelationTypeStatus( + @RequestBody Map req) { + + service.updateRelationTypeStatus(req); + + return "SUCCESS"; + } + + @GetMapping("/currentlylivingmasterlist") + public List> getCurrentlyLivingList() { + + return service.getCurrentlyLivingList(); + } + + @PostMapping("/currentlylivingsave") + public String saveCurrentlyLiving( + @RequestBody Map req) { + + service.saveCurrentlyLiving(req); + + return "SUCCESS"; + } + + @PostMapping("/currentlyliving-status") + public String updateCurrentlyLivingStatus( + @RequestBody Map req) { + + service.updateCurrentlyLivingStatus(req); + + return "SUCCESS"; + } + + @GetMapping("/martialmasterlist") + public List> getMartialList() { + + return service.getMartialList(); + } + + @PostMapping("/martialsave") + public String saveMartial( + @RequestBody Map req) { + + service.saveMartial(req); + + return "SUCCESS"; + } + + @PostMapping("/martial-status") + public String updateMartialStatus( + @RequestBody Map req) { + + service.updateMartialStatus(req); + + return "SUCCESS"; + } + + @GetMapping("/disabilitytype") + public List> getDisabilityTypeList() { + return service.getDisabilityTypeList(); + } + + @PostMapping("/disabilitytypesave") + public String saveDisabilityType( + @RequestBody Map req) { + service.saveDisabilityType(req); + return "SUCCESS"; + } + + @PostMapping("/disabilitytype-status") + public String updateDisabilityTypeStatus( + @RequestBody Map req) { + service.updateDisabilityTypeStatus(req); + return "SUCCESS"; + } + + @GetMapping("/disabiltycertificatelist") + public List> getDisabilityCertificateMasterList() { + return service.getDisabilityCertificateMasterList(); + } + + @PostMapping("/disabiltycertificategersave") + public String saveDisabilityCertificateMaster( + @RequestBody Map req) { + service.saveDisabilityCertificateMaster(req); + return "SUCCESS"; + } + + @PostMapping("/disabiltycertificate-status") + public String updateDisabilityCertificateMasterStatus( + @RequestBody Map req) { + service.updateDisabilityCertificateMasterStatus(req); + return "SUCCESS"; + } + + @GetMapping("/healthconditionlist") + public List> getHealthConditionList() { + return service.getHealthConditionList(); + } + + @PostMapping("/healthconditionsave") + public String saveHealthCondition( + @RequestBody Map req) { + service.saveHealthCondition(req); + return "SUCCESS"; + } + + @PostMapping("/healthcondition-status") + public String updateHealthConditionStatus( + @RequestBody Map req) { + service.updateHealthConditionStatus(req); + return "SUCCESS"; + } + + @GetMapping("/educationmasterlist") + public List> getEducationMasterList() { + return service.getEducationMasterList(); + } + + @PostMapping("/educationsave") + public String saveEducationMaster( + @RequestBody Map req) { + service.saveEducationMaster(req); + return "SUCCESS"; + } + + @PostMapping("/education-status") + public String updateEducationMasterStatus( + @RequestBody Map req) { + service.updateEducationMasterStatus(req); + return "SUCCESS"; + } + + @GetMapping("/discontinuedlist") + public List> getDiscontinuedList() { + return service.getDiscontinuedList(); + } + + @PostMapping("/discontinuedsave") + public String saveDiscontinuedMaster( + @RequestBody Map req) { + service.saveDiscontinuedMaster(req); + return "SUCCESS"; + } + + @PostMapping("/discontinued-status") + public String updateDiscontinuedMasterStatus( + @RequestBody Map req) { + service.updateDiscontinuedMasterStatus(req); + return "SUCCESS"; + } + + @GetMapping("/employmenttypelist") + public List> getEmploymentTypeList() { + return service.getEmploymentTypeList(); + } + + @PostMapping("/employmenttypesave") + public String saveEmploymentType( + @RequestBody Map req) { + service.saveEmploymentType(req); + return "SUCCESS"; + } + + @PostMapping("/employmenttype-status") + public String updateEmploymentTypeStatus( + @RequestBody Map req) { + service.updateEmploymentTypeStatus(req); + return "SUCCESS"; + } + + @GetMapping("/occupationlist") + public List> getOccupationList() { + return service.getOccupationList(); + } + + @PostMapping("/occupationsave") + public String saveOccupation( + @RequestBody Map req) { + service.saveOccupation(req); + return "SUCCESS"; + } + + @PostMapping("/occupation-status") + public String updateOccupationStatus( + @RequestBody Map req) { + service.updateOccupationStatus(req); + return "SUCCESS"; + } + + @GetMapping("/notemployedlist") + public List> getNotEmployedList() { + return service.getNotEmployedList(); + } + + @PostMapping("/notemployedsave") + public String saveNotEmployed( + @RequestBody Map req) { + service.saveNotEmployed(req); + return "SUCCESS"; + } + + @PostMapping("/notemployed-status") + public String updateNotEmployedStatus( + @RequestBody Map req) { + service.updateNotEmployedStatus(req); + return "SUCCESS"; + } + + @GetMapping("/homelessreasonmasterlist") + public List> getReasonHomelessList() { + return service.getReasonHomelessList(); + } + + @PostMapping("/homelessreasonmasterlist") + public String saveReasonHomeless( + @RequestBody Map req) { + service.saveHomelessReason(req); + return "SUCCESS"; + } + + @PostMapping("/homelessreasonmaster-status") + public String updateHomelessReasonStatus( + @RequestBody Map req) { + service.updateHomelessReasonStatus(req); + return "SUCCESS"; + } + + @GetMapping("/sleepingspacemasterlist") + public List> getSleepingSpaceList() { + return service.getSleepingSpaceList(); + } + + @PostMapping("/sleepingspacesave") + public String saveSleepingSpace( + @RequestBody Map req) { + service.saveSleepingSpace(req); + return "SUCCESS"; + } + + @PostMapping("/sleepingspace-status") + public String updateSleepingSpaceStatus( + @RequestBody Map req) { + service.updateSleepingSpaceStatus(req); + return "SUCCESS"; + } + + @GetMapping("/movingreasonmasterlist") + public List> getMovingReasonList() { + return service.getMovingReasonList(); + } + + @PostMapping("/movingreasonmasterdatasave") + public String saveMovingReason( + @RequestBody Map req) { + service.saveMovingReason(req); + return "SUCCESS"; + } + + @PostMapping("/movingreasonmasterdata-status") + public String updateMovingReasonStatus( + @RequestBody Map req) { + service.updateMovingReasonStatus(req); + return "SUCCESS"; + } + + @GetMapping("/comeoutsheltermasterlist") + public List> getComeOutShelterList() { + return service.getComeOutShelterList(); + } + + @PostMapping("/comeoutsheltersave") + public String saveComeOutShelter( + @RequestBody Map req) { + service.saveComeOutShelter(req); + return "SUCCESS"; + } + + @PostMapping("/comeoutshelter-status") + public String updateComeOutShelterStatus( + @RequestBody Map req) { + service.updateComeOutShelterStatus(req); + return "SUCCESS"; + } + + @GetMapping("/gccsheltermasterlist") + public List> getGCCShelterMasterList() { + return service.getGCCShelterMasterList(); + } + + @PostMapping("/gccsheltermasterdatasave") + public String saveGCCShelterMaster( + @RequestBody Map req) { + service.saveGCCShelterMaster(req); + return "SUCCESS"; + } + + @PostMapping("/gccsheltermasterdata-status") + public String updateGCCShelterMasterStatus( + @RequestBody Map req) { + service.updateGCCShelterMasterStatus(req); + return "SUCCESS"; + } + + @GetMapping("/birthcertificatmasterlist") + public List> getBirthCertificateNoReasonMasterList() { + return service.getBirthCertificateNoReasonMasterList(); + } + + @PostMapping("/birthcertificatmasterdatasave") + public String saveBirthCertificateNoReasonMaster( + @RequestBody Map req) { + service.saveBirthCertificateNoReasonMaster(req); + return "SUCCESS"; + } + + @PostMapping("/birthcertificatmasterdata-status") + public String updateBirthCertificateNoReasonMasterStatus( + @RequestBody Map req) { + service.updateBirthCertificateNoReasonMasterStatus(req); + return "SUCCESS"; + } + + @GetMapping("/communitymasterlist") + public List> getCommunityMasterList() { + return service.getCommunityMasterList(); + } + + @PostMapping("/communitycertmasterdatasave") + public String saveCommunityMaster( + @RequestBody Map req) { + service.saveCommunityMaster(req); + return "SUCCESS"; + } + + @PostMapping("/communitycertmasterdata-status") + public String updateCommunityMasterStatus( + @RequestBody Map req) { + service.updateCommunityMasterStatus(req); + return "SUCCESS"; + } + + @GetMapping("/voteridmasterlist") + public List> getVoterIdMasterList() { + return service.getVoterIdMasterList(); + } + + @PostMapping("/voteridmastersave") + public String saveVoterIdMaster( + @RequestBody Map req) { + service.saveVoterIdMaster(req); + return "SUCCESS"; + } + + @PostMapping("/voteridmaster-status") + public String updateVoterIdMasterStatus( + @RequestBody Map req) { + service.updateVoterIdMasterStatus(req); + return "SUCCESS"; + } + + @GetMapping("/aadharnoreasonlst") + public List> getAadharCertificateNoReasonMasterList() { + return service.getAadharCertificateNoReasonMasterList(); + } + + @PostMapping("/aadharnoreasonsave") + public String saveAadharCertificateNoReasonMaster( + @RequestBody Map req) { + service.saveAadharCertificateNoReasonMaster(req); + return "SUCCESS"; + } + + @PostMapping("/aadharnoreason-status") + public String updateAadharCertificateNoReasonMasterStatus( + @RequestBody Map req) { + service.updateAadharCertificateNoReasonMasterStatus(req); + return "SUCCESS"; + } + + @GetMapping("/smartcardnoreasonmasterlist") + public List> getSmartCardNoReasonMasterList() { + return service.getSmartCardNoReasonMasterList(); + } + + @PostMapping("/smartcardnoreasonsave") + public String saveSmartCardNoReasonMaster( + @RequestBody Map req) { + service.saveSmartCardNoReasonMaster(req); + return "SUCCESS"; + } + + @PostMapping("/smartcardnoreasonstatus") + public String updateSmartCardNoReasonMasterStatus( + @RequestBody Map req) { + service.updateSmartCardNoReasonMasterStatus(req); + return "SUCCESS"; + } + + @GetMapping("/driverlicensemasterlist") + public List> getDriverLicenseNoReasonMasterList() { + return service.getDriverLicenseNoReasonMasterList(); + } + + @PostMapping("/driverlicensesave") + public String saveDriverLicenseNoReasonMaster( + @RequestBody Map req) { + service.saveDriverLicenseNoReasonMaster(req); + return "SUCCESS"; + } + + @PostMapping("/driverlicense-status") + public String updateDriverLicenseNoReasonMasterStatus( + @RequestBody Map req) { + service.updateDriverLicenseNoReasonMasterStatus(req); + return "SUCCESS"; + } + + @GetMapping("/cminsurancemasterlist") + public List> getCmInsuranceNoReasonMasterList() { + return service.getCmInsuranceNoReasonMasterList(); + } + + @PostMapping("/cminsurancesave") + public String saveCmInsuranceNoReasonMaster( + @RequestBody Map req) { + service.saveCmInsuranceNoReasonMaster(req); + return "SUCCESS"; + } + + @PostMapping("/cminsurance-status") + public String updateCmInsuranceNoReasonMasterStatus( + @RequestBody Map req) { + service.updateCmInsuranceNoReasonMasterStatus(req); + return "SUCCESS"; + } + + @GetMapping("/bankpassbookreasonmasterlist") + public List> getBankPassbookNoReasonMasterList() { + return service.getBankPassbookNoReasonMasterList(); + } + + @PostMapping("/bankpassbookreasonmaster-save") + public String saveBankPassbookNoReasonMaster( + @RequestBody Map req) { + service.saveBankPassbookNoReasonMaster(req); + return "SUCCESS"; + } + + @PostMapping("/bankpassbookreasonmasterstatus") + public String updateBankPassbookNoReasonMasterStatus( + @RequestBody Map req) { + service.updateBankPassbookNoReasonMasterStatus(req); + return "SUCCESS"; + } + + @GetMapping("/religionmasterlist") + public List> getReligionMasterList() { + return service.getReligionMasterList(); + } + + @PostMapping("/religionmasterdatasave") + public String saveReligionMaster( + @RequestBody Map req) { + service.saveReligionMaster(req); + return "SUCCESS"; + } + + @PostMapping("/religionmasterdata-status") + public String updateReligionMasterStatus( + @RequestBody Map req) { + service.updateReligionMasterStatus(req); + return "SUCCESS"; + } + + @GetMapping("/castemasterlist") + public List> getCasteMasterList() { + return service.getCasteMasterList(); + } + + @PostMapping("/castemasterdatasave") + public String saveCasteMaster( + @RequestBody Map req) { + service.saveCasteMaster(req); + return "SUCCESS"; + } + + @PostMapping("/castemasterdata-status") + public String updateCasteMasterStatus( + @RequestBody Map req) { + service.updateCasteMasterStatus(req); + return "SUCCESS"; + } + + @GetMapping("/dashboard") + public ResponseEntity> getDashboard() { + + return ResponseEntity.ok( + service.getDashboard()); + } + + @GetMapping("/zone-wise") + public ResponseEntity>> getZoneWiseCount() { + + return ResponseEntity.ok( + service.getZoneWiseCount()); + } + + @GetMapping("/ward-wise") + public ResponseEntity>> getWardWiseCount( + @RequestParam String zone) { + + return ResponseEntity.ok( + service.getWardWiseCount(zone)); + } + +} diff --git a/src/main/java/in/gov/chennaicorporation/gccoffice/homelesssurvey/Controller/MainController.java b/src/main/java/in/gov/chennaicorporation/gccoffice/homelesssurvey/Controller/MainController.java new file mode 100644 index 0000000..839a686 --- /dev/null +++ b/src/main/java/in/gov/chennaicorporation/gccoffice/homelesssurvey/Controller/MainController.java @@ -0,0 +1,168 @@ +package in.gov.chennaicorporation.gccoffice.homelesssurvey.Controller; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; + +@Controller("HomelessSurveyController") +@RequestMapping("/gcc/homelesssurvey") +public class MainController { + + @GetMapping("/homelesslist/surveyedlist") + public String surveyedlist() { + return "modules/homelesssurvey/homelesslist"; + } + + @GetMapping("/homelesslist/nonsurveyedlist") + public String nonsurveyedlist() { + return "modules/homelesssurvey/nonsurveyedhomelist"; + } + + @GetMapping("/surveylist") + + public String surveylist() { + return "modules/homelesssurvey/surveyorlist"; + } + + @GetMapping("/surveyorsreports") + + public String surveyorsreports() { + return "modules/homelesssurvey/surveyorsreports"; + } + + @GetMapping("/homelesslist/gender") + public String gender() { + return "modules/homelesssurvey/gendermaster"; + } + + @GetMapping("/homelesslist/relationtype") + public String relationtype() { + return "modules/homelesssurvey/relationtype"; + } + + @GetMapping("/homelesslist/currentlyliving") + public String currentlyliving() { + return "modules/homelesssurvey/currentlyliving"; + } + + @GetMapping("/homelesslist/martial") + public String martialstatus() { + return "modules/homelesssurvey/martial"; + } + + @GetMapping("/homelesslist/disabilitytype") + public String disabilitytype() { + return "modules/homelesssurvey/disability"; + } + + @GetMapping("/homelesslist/diable") + public String disabiltycertificate() { + return "modules/homelesssurvey/disabiltycertificate"; + } + + @GetMapping("/homelesslist/healthcondition") + public String healthcondition() { + return "modules/homelesssurvey/healthcondition"; + } + + @GetMapping("/homelesslist/education") + public String education() { + return "modules/homelesssurvey/education"; + } + + @GetMapping("/homelesslist/discontinued") + public String discontinued() { + return "modules/homelesssurvey/discontinued"; + } + + @GetMapping("/homelesslist/employment") + public String employmenttype() { + return "modules/homelesssurvey/employmenttype"; + } + + @GetMapping("/homelesslist/occupation") + public String occupation() { + return "modules/homelesssurvey/occupation"; + } + + @GetMapping("/homelesslist/notemployed") + public String notemployed() { + return "modules/homelesssurvey/notemployed"; + } + + @GetMapping("/homelesslist/homeless") + public String homelessreason() { + return "modules/homelesssurvey/homelessreason"; + } + + @GetMapping("/homelesslist/sleepingspace") + public String sleepingspace() { + return "modules/homelesssurvey/sleepingspace"; + } + + @GetMapping("/homelesslist/moving") + public String movingreason() { + return "modules/homelesssurvey/movingreason"; + } + + @GetMapping("/homelesslist/comeoutshelter") + public String comeoutshelter() { + return "modules/homelesssurvey/comeoutshelter"; + } + + @GetMapping("/homelesslist/gccshelter") + public String gccshelter() { + return "modules/homelesssurvey/gccshelter"; + } + + @GetMapping("/homelesslist/birthcertificate") + public String birthcertficatenoreason() { + return "modules/homelesssurvey/birthcertficatenoreason"; + } + + @GetMapping("/homelesslist/communitycertificate") + public String communitycertificate() { + return "modules/homelesssurvey/communitynoreason"; + } + + @GetMapping("/homelesslist/votercertificate") + public String voterid() { + return "modules/homelesssurvey/voterid"; + } + + @GetMapping("/homelesslist/aadharcertificate") + public String aadhar() { + return "modules/homelesssurvey/aadhar"; + } + + @GetMapping("/homelesslist/smartcertificate") + public String smartcard() { + return "modules/homelesssurvey/smart"; + } + + @GetMapping("/homelesslist/drivercertificate") + public String driverlicense() { + return "modules/homelesssurvey/driver"; + } + + @GetMapping("/homelesslist/cmrcertificate") + public String cminsurance() { + return "modules/homelesssurvey/cminsurance"; + } + + @GetMapping("/homelesslist/bankpassbook") + public String bankpassbook() { + return "modules/homelesssurvey/bankpassbook"; + } + + @GetMapping("/homelesslist/religion") + public String religion() { + return "modules/homelesssurvey/religion"; + } + + @GetMapping("/homelesslist/caste") + public String caste() { + return "modules/homelesssurvey/caste"; + } + +} diff --git a/src/main/java/in/gov/chennaicorporation/gccoffice/homelesssurvey/Service/HomelessSurveyService.java b/src/main/java/in/gov/chennaicorporation/gccoffice/homelesssurvey/Service/HomelessSurveyService.java new file mode 100644 index 0000000..b3fffed --- /dev/null +++ b/src/main/java/in/gov/chennaicorporation/gccoffice/homelesssurvey/Service/HomelessSurveyService.java @@ -0,0 +1,4103 @@ +package in.gov.chennaicorporation.gccoffice.homelesssurvey.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 HomelessSurveyService { + @Autowired + @Value("${fileBaseUrl}") + + private String fileBaseUrl; + + @Autowired + private JdbcTemplate jdbcTemplate; + @Autowired + private Environment environment; + + @Autowired + public void setDataSource(@Qualifier("mysqlHomelessSurveyDataSource") DataSource dataSource) { + this.jdbcTemplate = new JdbcTemplate(dataSource); + } + + public HomelessSurveyService(Environment environment) { + + this.environment = environment; + + this.fileBaseUrl = environment.getProperty("fileBaseUrl"); + } + + public List> getHomelessSurveyList( + String zone, + String ward, + String fromDate, + String toDate) { + + StringBuilder sql = new StringBuilder(""" + + SELECT + + DATE(MAX(hr.cdate)) AS survey_date, + + hr.survey_id, + + MAX(CASE + WHEN hr.qid = 2 + THEN hr.answer + END) AS name, + + MAX( + CASE + WHEN hr.qid = 7 + THEN CASE + WHEN hr.others_answer IS NOT NULL + AND TRIM(hr.others_answer) <> '' + THEN hr.others_answer + ELSE gm.english_name + END + END + ) AS gender, + + sld.zone AS zone, + + sld.ward AS ward + + FROM homeless_survey_response hr + + LEFT JOIN gender_master gm + ON hr.qid = 7 + AND gm.id = hr.answer + + LEFT JOIN surveyor_location_details sld + ON sld.survey_id = hr.survey_id + + + + + WHERE hr.isactive = 1 + AND hr.isdelete = 0 + AND NOT EXISTS ( + SELECT 1 + FROM homeless_survey_response hr2 + INNER JOIN homeless_survey_questions_master hqm2 + ON hqm2.qid = hr2.qid + WHERE hr2.survey_id = hr.survey_id + AND hqm2.flag = 'N' + ) + + """); + + List params = new ArrayList<>(); + + if (zone != null && !zone.isBlank()) { + + sql.append(""" + AND CAST(sld.zone AS UNSIGNED) = ? + """); + + params.add(zone); + } + + if (ward != null && !ward.isBlank()) { + + sql.append(""" + AND CAST(sld.ward AS UNSIGNED) = ? + """); + + params.add(ward); + } + + if (fromDate != null && !fromDate.isBlank() + && toDate != null && !toDate.isBlank()) { + + sql.append(""" + AND DATE(hr.cdate) BETWEEN ? AND ? + """); + + params.add(fromDate); + params.add(toDate); + } + + sql.append(""" + + GROUP BY + + hr.survey_id, + sld.zone, + sld.ward + + ORDER BY + + MAX(hr.cdate) DESC + + """); + + return jdbcTemplate.queryForList( + sql.toString(), + params.toArray()); + } + + public List> getZones() { + + String sql = """ + + SELECT + + id, + zone_name + FROM gcc_street_vendor.zone_master + ORDER BY zone_name + + """; + + return jdbcTemplate.queryForList(sql); + } + + public List> getWards(String zoneId) { + + String sql = """ + + SELECT + id, + ward_name + FROM gcc_street_vendor.ward_master + WHERE zone_id = ? + ORDER BY ward_name + + """; + + return jdbcTemplate.queryForList( + sql, + zoneId); + } + + public List> getHomelessNonSurveyedList( + String zone, + String ward, + String fromDate, + String toDate) { + + StringBuilder sql = new StringBuilder( + + "SELECT " + + + "DATE(MAX(hr.cdate)) AS survey_date, " + + "hr.survey_id, " + + + "MAX(CASE " + + "WHEN hr.qid = 2 THEN hr.answer " + + "END) AS name, " + + + "MAX(CASE " + + "WHEN hr.qid = 78 THEN hr.answer " + + "END) AS age, " + + + "MAX(CASE " + + "WHEN hr.qid = 8 THEN hr.answer " + + "END) AS dob, " + + + "MAX(CASE " + + "WHEN hr.qid = 79 THEN hr.answer " + + "END) AS remarks, " + + + "IFNULL(MAX(CASE " + + "WHEN hr.qid = 77 " + + "THEN CONCAT('" + fileBaseUrl + "/gccofficialapp/files', hr.answer) " + + "END),'') AS image_url, " + + + "sld.zone AS zone, " + + "sld.ward AS ward " + + + "FROM homeless_survey_response hr " + + + "LEFT JOIN surveyor_location_details sld " + + "ON sld.survey_id = hr.survey_id " + + + "WHERE hr.isactive = 1 " + + "AND hr.isdelete = 0 " + + "AND EXISTS ( " + + "SELECT 1 " + + "FROM homeless_survey_response hr2 " + + "INNER JOIN homeless_survey_questions_master hqm2 " + + "ON hqm2.qid = hr2.qid " + + "WHERE hr2.survey_id = hr.survey_id " + + "AND hqm2.flag = 'N')"); + + List params = new ArrayList<>(); + + if (zone != null && !zone.isBlank()) { + + sql.append( + " AND CAST(sld.zone AS UNSIGNED) = ? "); + + params.add(Integer.parseInt(zone)); + } + + if (ward != null && !ward.isBlank()) { + + sql.append( + " AND CAST(sld.ward AS UNSIGNED) = ? "); + + params.add(Integer.parseInt(ward)); + } + + if (fromDate != null + && !fromDate.isBlank() + && toDate != null + && !toDate.isBlank()) { + + sql.append( + " AND DATE(hr.cdate) BETWEEN ? AND ? "); + + params.add(fromDate); + params.add(toDate); + } + + sql.append( + + " GROUP BY " + + " hr.survey_id, " + + " sld.zone, " + + " sld.ward " + + + " ORDER BY MAX(hr.cdate) DESC "); + + return jdbcTemplate.queryForList( + sql.toString(), + params.toArray()); + } + + public List> getHomelessSurveyDetails( + String surveyId) { + + String sql = + + "SELECT " + + + "hqm.cid, " + + "qcm.english_name AS category_name, " + + + "hqm.qid, " + + "hqm.q_english AS question, " + + "hqm.question_type, " + + "hqm.master_table_name, " + + + "CASE " + + + "WHEN hqm.question_type = 'image' " + + "THEN CONCAT('" + fileBaseUrl + "/gccofficialapp/files', hr.answer) " + + + "WHEN hr.others_answer IS NOT NULL " + + "AND TRIM(hr.others_answer) <> '' " + + "THEN hr.others_answer " + + + "WHEN hqm.question_type = 'radio' " + + "THEN ham.answer " + + + "ELSE hr.answer " + + + "END AS answer " + + + "FROM homeless_survey_response hr " + + + "INNER JOIN homeless_survey_questions_master hqm " + + "ON hqm.qid = hr.qid " + + + "LEFT JOIN question_category_master qcm " + + "ON qcm.id = hqm.cid " + + + "LEFT JOIN homeless_survey_answer_master ham " + + "ON ham.qid = hr.qid " + + "AND ham.id = CAST(hr.answer AS UNSIGNED) " + + + "WHERE hr.survey_id = ? " + + "AND hr.isactive = 1 " + + "AND hr.isdelete = 0 " + + + "ORDER BY hqm.cid, hqm.orderby"; + + List> result = jdbcTemplate.queryForList( + sql, + surveyId); + + for (Map row : result) { + + 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 answer = row.get("answer") == null + * ? "" + * : row.get("answer").toString(); + */ + String answer = row.get("answer") == null + ? "" + : row.get("answer").toString().trim(); + + try { + + // DROPDOWN + if ("dropdown".equalsIgnoreCase(questionType) + && !masterTable.isBlank() + && answer.matches("\\d+")) { + + String valueSql = "SELECT english_name FROM " + + masterTable + + " WHERE id = ?"; + + String value = jdbcTemplate.queryForObject( + valueSql, + String.class, + Integer.parseInt(answer)); + + row.put("answer", value); + } + + // CHECKBOX / MULTICHECK + else if (("checkbox".equalsIgnoreCase(questionType) + || "multicheck".equalsIgnoreCase(questionType)) + && !masterTable.isBlank() + && !answer.isBlank()) { + + String[] ids = answer.split(","); + + StringBuilder placeholders = new StringBuilder(); + + for (int i = 0; i < ids.length; i++) { + + placeholders.append("?"); + + if (i < ids.length - 1) { + placeholders.append(","); + } + } + + String checkboxSql = "SELECT english_name FROM " + + masterTable + + " WHERE id IN (" + + placeholders + + ") ORDER BY id"; + + List values = jdbcTemplate.query( + checkboxSql, + ids, + (rs, rowNum) -> rs.getString("english_name")); + + row.put( + "answer", + String.join(", ", values)); + } + + } catch (Exception e) { + + System.out.println( + "Master value fetch failed for qid : " + + row.get("qid")); + } + } + + return result; + } + + public List> getSurveyDocuments(String surveyId) { + + String sql = + + "SELECT " + + + "hr.survey_id, " + + + "(" + + " SELECT q2.q_english " + + " FROM homeless_survey_questions_master q2 " + + " WHERE q2.cid = hqm.cid " + + " AND q2.question_type = 'radio' " + + " AND q2.orderby < hqm.orderby " + + " ORDER BY q2.orderby DESC " + + " LIMIT 1 " + + ") AS document_name, " + + + "CONCAT('" + fileBaseUrl + + "/gccofficialapp/files', hr.answer) AS file_url " + + + "FROM homeless_survey_response hr " + + + "INNER JOIN homeless_survey_questions_master hqm " + + "ON hqm.qid = hr.qid " + + + "WHERE hr.survey_id = ? " + + "AND hqm.cid = 5 " + + "AND hqm.question_type = 'image' " + + + "ORDER BY hqm.orderby"; + + return jdbcTemplate.queryForList( + sql, + surveyId); + } + + /* + * public List> getSurveyDocuments(String surveyId) { + * + * String sql = "SELECT " + + * "hr.survey_id, " + + * "hqm.q_english, " + + * "CONCAT('" + fileBaseUrl + + * "/gccofficialapp/files', hr.answer) AS file_url " + + * + * "FROM homeless_survey_response hr " + + * + * "INNER JOIN homeless_survey_questions_master hqm " + + * "ON hqm.qid = hr.qid " + + * + * "WHERE hr.survey_id = ? " + + * "AND hqm.cid = 5 " + + * "AND hqm.question_type = 'image'"; + * + * return jdbcTemplate.queryForList(sql, surveyId); + * } + */ + public List> getCategories() { + + String sql = + + "SELECT " + + "id, " + + "english_name, " + + "orderby " + + + "FROM question_category_master " + + + "WHERE isactive = 1 " + + "AND isdelete = 0 " + + + "ORDER BY orderby"; + + return jdbcTemplate.queryForList(sql); + } + + public List> getSurveyorsList( + + String zone, + String ward, + String fromDate, + String toDate) { + + StringBuilder sql = new StringBuilder(""" + + SELECT + + d.user_name, + d.mobile_no, + sl.loginId, + + sl.zone, + sl.ward, + + COUNT(DISTINCT hs.survey_id) + AS total_survey_done, + + DATE(hs.cdate) + AS survey_date + + FROM homeless_survey_response hs + + INNER JOIN surveyor_location_details sl + ON sl.survey_id = hs.survey_id + + INNER JOIN login_details d + ON d.uid = sl.loginId + + WHERE 1 = 1 + + """); + + List params = new ArrayList<>(); + + if (zone != null && !zone.isEmpty()) { + + sql.append(""" + AND CAST(sl.zone AS UNSIGNED) = ? + """); + + params.add(zone); + } + + if (ward != null && !ward.isEmpty()) { + + sql.append(""" + AND CAST(sl.ward AS UNSIGNED) = ? + """); + + params.add(ward); + } + + if (fromDate != null + && toDate != null + && !fromDate.isEmpty() + && !toDate.isEmpty()) { + + sql.append(""" + AND DATE(hs.cdate) + BETWEEN ? AND ? + """); + + params.add(fromDate); + params.add(toDate); + } + + sql.append(""" + + GROUP BY + + d.user_name, + d.mobile_no, + sl.loginId, + sl.zone, + sl.ward, + DATE(hs.cdate) + + ORDER BY DATE(hs.cdate) DESC + + """); + + return jdbcTemplate.queryForList( + sql.toString(), + params.toArray()); + } + + public List> getSurveyorWiseSurveyList( + String loginId, + String zone, + String ward, + String surveyDate) { + + StringBuilder sql = new StringBuilder(""" + + SELECT + + DATE(MAX(hr.cdate)) AS survey_date, + + hr.survey_id, + + MAX(CASE + WHEN hr.qid = 2 + THEN hr.answer + END) AS name, + MAX( + CASE + WHEN hr.qid = 7 + THEN CASE + WHEN hr.others_answer IS NOT NULL + AND TRIM(hr.others_answer) <> '' + THEN hr.others_answer + ELSE gm.english_name + END + END + ) AS gender, + + + + sld.zone AS zone, + + sld.ward AS ward + + FROM homeless_survey_response hr + + LEFT JOIN gender_master gm + ON hr.qid = 7 + AND gm.id = hr.answer + + LEFT JOIN surveyor_location_details sld + ON sld.survey_id = hr.survey_id + + WHERE hr.isactive = 1 + AND hr.isdelete = 0 + AND sld.loginId = ? + + """); + + List params = new ArrayList<>(); + params.add(loginId); + /* + * MAX(CASE + * WHEN hr.qid = 7 + * THEN gm.english_name + * END) AS gender, + */ + + if (zone != null && !zone.isBlank()) { + + sql.append(""" + AND sld.zone = ? + """); + + params.add(zone); + } + + if (ward != null && !ward.isBlank()) { + + sql.append(""" + AND sld.ward = ? + """); + + params.add(ward); + } + + if (surveyDate != null && !surveyDate.isBlank()) { + + sql.append(""" + AND DATE(hr.cdate) = ? + """); + + params.add(surveyDate); + } + + sql.append(""" + + GROUP BY + + hr.survey_id, + sld.zone, + sld.ward + + ORDER BY + + MAX(hr.cdate) DESC + + """); + + return jdbcTemplate.queryForList( + sql.toString(), + params.toArray()); + } + + public List> getBulkExcelData(String zone, + String ward, + String fromDate, + String toDate) { + + String sql = "SELECT " + + " hs.survey_id, " + + " qm.q_english, " + + " hs.answer " + + "FROM homeless_survey_response hs " + + "INNER JOIN homeless_survey_questions_master qm " + + " ON qm.qid = hs.qid " + + "INNER JOIN surveyor_location_details sl " + + " ON sl.survey_id = hs.survey_id " + + "WHERE hs.isactive = 1 " + + "AND hs.isdelete = 0 "; + + List params = new ArrayList<>(); + + if (zone != null && !zone.isEmpty()) { + sql += " AND sl.zone = ? "; + params.add(zone); + } + + if (ward != null && !ward.isEmpty()) { + sql += " AND sl.ward = ? "; + params.add(ward); + } + + if (fromDate != null && !fromDate.isEmpty()) { + sql += " AND DATE(hs.cdate) >= ? "; + params.add(fromDate); + } + + if (toDate != null && !toDate.isEmpty()) { + sql += " AND DATE(hs.cdate) <= ? "; + params.add(toDate); + } + + sql += " ORDER BY hs.survey_id,qm.orderby "; + + List> rows = jdbcTemplate.queryForList(sql, params.toArray()); + + Map> surveyMap = new LinkedHashMap<>(); + + for (Map row : rows) { + + String surveyId = String.valueOf(row.get("survey_id")); + + String question = String.valueOf(row.get("q_english")); + + String answer = row.get("answer") == null ? "" : String.valueOf(row.get("answer")); + + surveyMap.putIfAbsent( + surveyId, + new LinkedHashMap<>()); + + surveyMap.get(surveyId) + .put("Survey ID", surveyId); + + surveyMap.get(surveyId) + .put(question, answer); + } + + return new ArrayList<>(surveyMap.values()); + } + + public List> getGenderList() { + + String sql = """ + + SELECT + id, + english_name, + isactive, + isdelete + FROM gender_master + WHERE isactive = 1 + AND isdelete = 0 + ORDER BY orderby + + """; + + return jdbcTemplate.queryForList(sql); + } + + public void saveGender(Map req) { + + Integer id = req.get("id") != null + ? Integer.parseInt(req.get("id").toString()) + : 0; + + // UPDATE + if (id > 0) { + + String updateSql = """ + + UPDATE gender_master + SET english_name = ? + WHERE id = ? + + """; + + jdbcTemplate.update( + updateSql, + req.get("english_name"), + id); + } + + // INSERT + else { + + Integer nextOrder = jdbcTemplate.queryForObject( + """ + + SELECT IFNULL(MAX(orderby),0) + 1 + FROM gender_master + + """, + Integer.class); + + String insertSql = """ + + INSERT INTO gender_master + ( + english_name, + orderby, + + isactive, + isdelete + ) + VALUES + ( + ?, + ?, + + 1, + 0 + ) + + """; + + jdbcTemplate.update( + insertSql, + req.get("english_name"), + nextOrder); + } + } + + public void updateGenderStatus( + Map req) { + + Integer id = Integer.parseInt( + req.get("id").toString()); + + Integer status = Integer.parseInt( + req.get("status").toString()); + + String sql = """ + + UPDATE gender_master + SET + isactive = ?, + isdelete = ? + WHERE id = ? + + """; + + jdbcTemplate.update( + sql, + status, + status == 1 ? 0 : 1, + id); + } + + public List> getRelationTypeList() { + + String sql = """ + + SELECT + id, + english_name, + isactive, + isdelete + FROM relation_type_master + WHERE isactive = 1 + AND isdelete = 0 + ORDER BY orderby + + """; + + return jdbcTemplate.queryForList(sql); + } + + public void saveRelationType(Map req) { + + Integer id = req.get("id") != null + ? Integer.parseInt(req.get("id").toString()) + : 0; + + // UPDATE + if (id > 0) { + + String updateSql = """ + + UPDATE relation_type_master + SET english_name = ? + WHERE id = ? + + """; + + jdbcTemplate.update( + updateSql, + req.get("english_name"), + id); + } + + // INSERT + else { + + Integer nextOrder = jdbcTemplate.queryForObject( + """ + + SELECT IFNULL(MAX(orderby),0) + 1 + FROM relation_type_master + + """, + Integer.class); + + String insertSql = """ + + INSERT INTO relation_type_master + ( + english_name, + orderby, + + isactive, + isdelete + ) + VALUES + ( + ?, + ?, + + 1, + 0 + ) + + """; + + jdbcTemplate.update( + insertSql, + req.get("english_name"), + nextOrder); + } + } + + public void updateRelationTypeStatus( + Map req) { + + Integer id = Integer.parseInt( + req.get("id").toString()); + + Integer status = Integer.parseInt( + req.get("status").toString()); + + String sql = """ + + UPDATE relation_type_master + SET + isactive = ?, + isdelete = ? + WHERE id = ? + + """; + + jdbcTemplate.update( + sql, + status, + status == 1 ? 0 : 1, + id); + } + + public List> getCurrentlyLivingList() { + + String sql = """ + + SELECT + id, + english_name, + isactive, + isdelete + FROM current_living_master + WHERE isactive = 1 + AND isdelete = 0 + ORDER BY orderby + + """; + + return jdbcTemplate.queryForList(sql); + } + + public void saveCurrentlyLiving(Map req) { + + Integer id = req.get("id") != null + ? Integer.parseInt(req.get("id").toString()) + : 0; + + // UPDATE + if (id > 0) { + + String updateSql = """ + + UPDATE current_living_master + SET english_name = ? + WHERE id = ? + + """; + + jdbcTemplate.update( + updateSql, + req.get("english_name"), + id); + } + + // INSERT + else { + + Integer nextOrder = jdbcTemplate.queryForObject( + """ + + SELECT IFNULL(MAX(orderby),0) + 1 + FROM current_living_master + + """, + Integer.class); + + String insertSql = """ + + INSERT INTO current_living_master + ( + english_name, + orderby, + + isactive, + isdelete + ) + VALUES + ( + ?, + ?, + + 1, + 0 + ) + + """; + + jdbcTemplate.update( + insertSql, + req.get("english_name"), + nextOrder); + } + } + + public void updateCurrentlyLivingStatus( + Map req) { + + Integer id = Integer.parseInt( + req.get("id").toString()); + + Integer status = Integer.parseInt( + req.get("status").toString()); + + String sql = """ + + UPDATE current_living_master + SET + isactive = ?, + isdelete = ? + WHERE id = ? + + """; + + jdbcTemplate.update( + sql, + status, + status == 1 ? 0 : 1, + id); + } + + public List> getMartialList() { + + String sql = """ + + SELECT + id, + english_name, + isactive, + isdelete + FROM martial_master + WHERE isactive = 1 + AND isdelete = 0 + ORDER BY orderby + + """; + + return jdbcTemplate.queryForList(sql); + } + + public void saveMartial(Map req) { + + Integer id = req.get("id") != null + ? Integer.parseInt(req.get("id").toString()) + : 0; + + // UPDATE + if (id > 0) { + + String updateSql = """ + + UPDATE martial_master + SET english_name = ? + WHERE id = ? + + """; + + jdbcTemplate.update( + updateSql, + req.get("english_name"), + id); + } + + // INSERT + else { + + Integer nextOrder = jdbcTemplate.queryForObject( + """ + + SELECT IFNULL(MAX(orderby),0) + 1 + FROM martial_master + + """, + Integer.class); + + String insertSql = """ + + INSERT INTO martial_master + ( + english_name, + orderby, + + isactive, + isdelete + ) + VALUES + ( + ?, + ?, + + 1, + 0 + ) + + """; + + jdbcTemplate.update( + insertSql, + req.get("english_name"), + nextOrder); + } + } + + public void updateMartialStatus( + Map req) { + + Integer id = Integer.parseInt( + req.get("id").toString()); + + Integer status = Integer.parseInt( + req.get("status").toString()); + + String sql = """ + + UPDATE martial_master + SET + isactive = ?, + isdelete = ? + WHERE id = ? + + """; + + jdbcTemplate.update( + sql, + status, + status == 1 ? 0 : 1, + id); + } + + public List> getDisabilityTypeList() { + + String sql = """ + + SELECT + id, + english_name, + isactive, + isdelete + FROM disability_type_master + WHERE isactive = 1 + AND isdelete = 0 + ORDER BY orderby + + """; + + return jdbcTemplate.queryForList(sql); + } + + public void saveDisabilityType(Map req) { + + Integer id = req.get("id") != null + ? Integer.parseInt(req.get("id").toString()) + : 0; + + // UPDATE + if (id > 0) { + + String updateSql = """ + + UPDATE disability_type_master + SET english_name = ? + WHERE id = ? + + """; + + jdbcTemplate.update( + updateSql, + req.get("english_name"), + id); + } + + // INSERT + else { + + Integer nextOrder = jdbcTemplate.queryForObject( + """ + + SELECT IFNULL(MAX(orderby),0) + 1 + FROM disability_type_master + + """, + Integer.class); + + String insertSql = """ + + INSERT INTO disability_type_master + ( + english_name, + orderby, + + isactive, + isdelete + ) + VALUES + ( + ?, + ?, + + 1, + 0 + ) + + """; + + jdbcTemplate.update( + insertSql, + req.get("english_name"), + nextOrder); + } + } + + public void updateDisabilityTypeStatus( + Map req) { + + Integer id = Integer.parseInt( + req.get("id").toString()); + + Integer status = Integer.parseInt( + req.get("status").toString()); + + String sql = """ + + UPDATE disability_type_master + SET + isactive = ?, + isdelete = ? + WHERE id = ? + + """; + + jdbcTemplate.update( + sql, + status, + status == 1 ? 0 : 1, + id); + } + + public List> getDisabilityCertificateMasterList() { + + String sql = """ + + SELECT + id, + english_name, + isactive, + isdelete + FROM disable_cert_no_reason_master + WHERE isactive = 1 + AND isdelete = 0 + ORDER BY orderby + + """; + + return jdbcTemplate.queryForList(sql); + } + + public void saveDisabilityCertificateMaster(Map req) { + + Integer id = req.get("id") != null + ? Integer.parseInt(req.get("id").toString()) + : 0; + + // UPDATE + if (id > 0) { + + String updateSql = """ + + UPDATE disable_cert_no_reason_master + SET english_name = ? + WHERE id = ? + + """; + + jdbcTemplate.update( + updateSql, + req.get("english_name"), + id); + } + + // INSERT + else { + + Integer nextOrder = jdbcTemplate.queryForObject( + """ + + SELECT IFNULL(MAX(orderby),0) + 1 + FROM disable_cert_no_reason_master + + """, + Integer.class); + + String insertSql = """ + + INSERT INTO disable_cert_no_reason_master + ( + english_name, + orderby, + + isactive, + isdelete + ) + VALUES + ( + ?, + ?, + + 1, + 0 + ) + + """; + + jdbcTemplate.update( + insertSql, + req.get("english_name"), + nextOrder); + } + } + + public void updateDisabilityCertificateMasterStatus( + Map req) { + + Integer id = Integer.parseInt( + req.get("id").toString()); + + Integer status = Integer.parseInt( + req.get("status").toString()); + + String sql = """ + + UPDATE disable_cert_no_reason_master + SET + isactive = ?, + isdelete = ? + WHERE id = ? + + """; + + jdbcTemplate.update( + sql, + status, + status == 1 ? 0 : 1, + id); + } + + public List> getHealthConditionList() { + + String sql = """ + + SELECT + id, + english_name, + isactive, + isdelete + FROM health_condition_master + WHERE isactive = 1 + AND isdelete = 0 + ORDER BY orderby + + """; + + return jdbcTemplate.queryForList(sql); + } + + public void saveHealthCondition(Map req) { + + Integer id = req.get("id") != null + ? Integer.parseInt(req.get("id").toString()) + : 0; + + // UPDATE + if (id > 0) { + + String updateSql = """ + + UPDATE health_condition_master + SET english_name = ? + WHERE id = ? + + """; + + jdbcTemplate.update( + updateSql, + req.get("english_name"), + id); + } + + // INSERT + else { + + Integer nextOrder = jdbcTemplate.queryForObject( + """ + + SELECT IFNULL(MAX(orderby),0) + 1 + FROM health_condition_master + + """, + Integer.class); + + String insertSql = """ + + INSERT INTO health_condition_master + ( + english_name, + orderby, + + isactive, + isdelete + ) + VALUES + ( + ?, + ?, + + 1, + 0 + ) + + """; + + jdbcTemplate.update( + insertSql, + req.get("english_name"), + nextOrder); + } + } + + public void updateHealthConditionStatus( + Map req) { + + Integer id = Integer.parseInt( + req.get("id").toString()); + + Integer status = Integer.parseInt( + req.get("status").toString()); + + String sql = """ + + UPDATE health_condition_master + SET + isactive = ?, + isdelete = ? + WHERE id = ? + + """; + + jdbcTemplate.update( + sql, + status, + status == 1 ? 0 : 1, + id); + } + + public List> getEducationMasterList() { + + String sql = """ + + SELECT + id, + english_name, + isactive, + isdelete + FROM education_master + WHERE isactive = 1 + AND isdelete = 0 + ORDER BY orderby + + """; + + return jdbcTemplate.queryForList(sql); + } + + public void saveEducationMaster(Map req) { + + Integer id = req.get("id") != null + ? Integer.parseInt(req.get("id").toString()) + : 0; + + // UPDATE + if (id > 0) { + + String updateSql = """ + + UPDATE education_master + SET english_name = ? + WHERE id = ? + + """; + + jdbcTemplate.update( + updateSql, + req.get("english_name"), + id); + } + + // INSERT + else { + + Integer nextOrder = jdbcTemplate.queryForObject( + """ + + SELECT IFNULL(MAX(orderby),0) + 1 + FROM education_master + + """, + Integer.class); + + String insertSql = """ + + INSERT INTO education_master + ( + english_name, + orderby, + + isactive, + isdelete + ) + VALUES + ( + ?, + ?, + + 1, + 0 + ) + + """; + + jdbcTemplate.update( + insertSql, + req.get("english_name"), + nextOrder); + } + } + + public void updateEducationMasterStatus( + Map req) { + + Integer id = Integer.parseInt( + req.get("id").toString()); + + Integer status = Integer.parseInt( + req.get("status").toString()); + + String sql = """ + + UPDATE education_master + SET + isactive = ?, + isdelete = ? + WHERE id = ? + + """; + + jdbcTemplate.update( + sql, + status, + status == 1 ? 0 : 1, + id); + } + + public List> getDiscontinuedList() { + + String sql = """ + + SELECT + id, + english_name, + isactive, + isdelete + FROM discontinued_reason_master + WHERE isactive = 1 + AND isdelete = 0 + ORDER BY orderby + + """; + + return jdbcTemplate.queryForList(sql); + } + + public void saveDiscontinuedMaster(Map req) { + + Integer id = req.get("id") != null + ? Integer.parseInt(req.get("id").toString()) + : 0; + + // UPDATE + if (id > 0) { + + String updateSql = """ + + UPDATE discontinued_reason_master + SET english_name = ? + WHERE id = ? + + """; + + jdbcTemplate.update( + updateSql, + req.get("english_name"), + id); + } + + // INSERT + else { + + Integer nextOrder = jdbcTemplate.queryForObject( + """ + + SELECT IFNULL(MAX(orderby),0) + 1 + FROM discontinued_reason_master + + """, + Integer.class); + + String insertSql = """ + + INSERT INTO discontinued_reason_master + ( + english_name, + orderby, + + isactive, + isdelete + ) + VALUES + ( + ?, + ?, + + 1, + 0 + ) + + """; + + jdbcTemplate.update( + insertSql, + req.get("english_name"), + nextOrder); + } + } + + public void updateDiscontinuedMasterStatus( + Map req) { + + Integer id = Integer.parseInt( + req.get("id").toString()); + + Integer status = Integer.parseInt( + req.get("status").toString()); + + String sql = """ + + UPDATE discontinued_reason_master + SET + isactive = ?, + isdelete = ? + WHERE id = ? + + """; + + jdbcTemplate.update( + sql, + status, + status == 1 ? 0 : 1, + id); + } + + public List> getEmploymentTypeList() { + + String sql = """ + + SELECT + id, + english_name, + isactive, + isdelete + FROM employment_type_master + WHERE isactive = 1 + AND isdelete = 0 + ORDER BY orderby + + """; + + return jdbcTemplate.queryForList(sql); + } + + public void saveEmploymentType(Map req) { + + Integer id = req.get("id") != null + ? Integer.parseInt(req.get("id").toString()) + : 0; + + // UPDATE + if (id > 0) { + + String updateSql = """ + + UPDATE employment_type_master + SET english_name = ? + WHERE id = ? + + """; + + jdbcTemplate.update( + updateSql, + req.get("english_name"), + id); + } + + // INSERT + else { + + Integer nextOrder = jdbcTemplate.queryForObject( + """ + + SELECT IFNULL(MAX(orderby),0) + 1 + FROM employment_type_master + + """, + Integer.class); + + String insertSql = """ + + INSERT INTO employment_type_master + ( + english_name, + orderby, + + isactive, + isdelete + ) + VALUES + ( + ?, + ?, + + 1, + 0 + ) + + """; + + jdbcTemplate.update( + insertSql, + req.get("english_name"), + nextOrder); + } + } + + public void updateEmploymentTypeStatus( + Map req) { + + Integer id = Integer.parseInt( + req.get("id").toString()); + + Integer status = Integer.parseInt( + req.get("status").toString()); + + String sql = """ + + UPDATE employment_type_master + SET + isactive = ?, + isdelete = ? + WHERE id = ? + + """; + + jdbcTemplate.update( + sql, + status, + status == 1 ? 0 : 1, + id); + } + + public List> getOccupationList() { + + String sql = """ + + SELECT + id, + english_name, + isactive, + isdelete + FROM occupation_master + WHERE isactive = 1 + AND isdelete = 0 + ORDER BY orderby + + """; + + return jdbcTemplate.queryForList(sql); + } + + public void saveOccupation(Map req) { + + Integer id = req.get("id") != null + ? Integer.parseInt(req.get("id").toString()) + : 0; + + // UPDATE + if (id > 0) { + + String updateSql = """ + + UPDATE occupation_master + SET english_name = ? + WHERE id = ? + + """; + + jdbcTemplate.update( + updateSql, + req.get("english_name"), + id); + } + + // INSERT + else { + + Integer nextOrder = jdbcTemplate.queryForObject( + """ + + SELECT IFNULL(MAX(orderby),0) + 1 + FROM occupation_master + + """, + Integer.class); + + String insertSql = """ + + INSERT INTO occupation_master + ( + english_name, + orderby, + + isactive, + isdelete + ) + VALUES + ( + ?, + ?, + + 1, + 0 + ) + + """; + + jdbcTemplate.update( + insertSql, + req.get("english_name"), + nextOrder); + } + } + + public void updateOccupationStatus( + Map req) { + + Integer id = Integer.parseInt( + req.get("id").toString()); + + Integer status = Integer.parseInt( + req.get("status").toString()); + + String sql = """ + + UPDATE occupation_master + SET + isactive = ?, + isdelete = ? + WHERE id = ? + + """; + + jdbcTemplate.update( + sql, + status, + status == 1 ? 0 : 1, + id); + } + + public List> getNotEmployedList() { + + String sql = """ + + SELECT + id, + english_name, + isactive, + isdelete + FROM not_employed_reason_master + WHERE isactive = 1 + AND isdelete = 0 + ORDER BY orderby + + """; + + return jdbcTemplate.queryForList(sql); + } + + public void saveNotEmployed(Map req) { + + Integer id = req.get("id") != null + ? Integer.parseInt(req.get("id").toString()) + : 0; + + // UPDATE + if (id > 0) { + + String updateSql = """ + + UPDATE not_employed_reason_master + SET english_name = ? + WHERE id = ? + + """; + + jdbcTemplate.update( + updateSql, + req.get("english_name"), + id); + } + + // INSERT + else { + + Integer nextOrder = jdbcTemplate.queryForObject( + """ + + SELECT IFNULL(MAX(orderby),0) + 1 + FROM not_employed_reason_master + + """, + Integer.class); + + String insertSql = """ + + INSERT INTO not_employed_reason_master + ( + english_name, + orderby, + + isactive, + isdelete + ) + VALUES + ( + ?, + ?, + + 1, + 0 + ) + + """; + + jdbcTemplate.update( + insertSql, + req.get("english_name"), + nextOrder); + } + } + + public void updateNotEmployedStatus( + Map req) { + + Integer id = Integer.parseInt( + req.get("id").toString()); + + Integer status = Integer.parseInt( + req.get("status").toString()); + + String sql = """ + + UPDATE not_employed_reason_master + SET + isactive = ?, + isdelete = ? + WHERE id = ? + + """; + + jdbcTemplate.update( + sql, + status, + status == 1 ? 0 : 1, + id); + } + + public List> getReasonHomelessList() { + + String sql = """ + + SELECT + id, + english_name, + isactive, + isdelete + FROM reason_homeless_master + WHERE isactive = 1 + AND isdelete = 0 + ORDER BY orderby + + """; + + return jdbcTemplate.queryForList(sql); + } + + public void saveHomelessReason(Map req) { + + Integer id = req.get("id") != null + ? Integer.parseInt(req.get("id").toString()) + : 0; + + // UPDATE + if (id > 0) { + + String updateSql = """ + + UPDATE reason_homeless_master + SET english_name = ? + WHERE id = ? + + """; + + jdbcTemplate.update( + updateSql, + req.get("english_name"), + id); + } + + // INSERT + else { + + Integer nextOrder = jdbcTemplate.queryForObject( + """ + + SELECT IFNULL(MAX(orderby),0) + 1 + FROM reason_homeless_master + + """, + Integer.class); + + String insertSql = """ + + INSERT INTO reason_homeless_master + ( + english_name, + orderby, + + isactive, + isdelete + ) + VALUES + ( + ?, + ?, + + 1, + 0 + ) + + """; + + jdbcTemplate.update( + insertSql, + req.get("english_name"), + nextOrder); + } + } + + public void updateHomelessReasonStatus( + Map req) { + + Integer id = Integer.parseInt( + req.get("id").toString()); + + Integer status = Integer.parseInt( + req.get("status").toString()); + + String sql = """ + + UPDATE reason_homeless_master + SET + isactive = ?, + isdelete = ? + WHERE id = ? + + """; + + jdbcTemplate.update( + sql, + status, + status == 1 ? 0 : 1, + id); + } + + public List> getSleepingSpaceList() { + + String sql = """ + + SELECT + id, + english_name, + isactive, + isdelete + FROM sleepingspace_master + WHERE isactive = 1 + AND isdelete = 0 + ORDER BY orderby + + """; + + return jdbcTemplate.queryForList(sql); + } + + public void saveSleepingSpace(Map req) { + + Integer id = req.get("id") != null + ? Integer.parseInt(req.get("id").toString()) + : 0; + + // UPDATE + if (id > 0) { + + String updateSql = """ + + UPDATE sleepingspace_master + SET english_name = ? + WHERE id = ? + + """; + + jdbcTemplate.update( + updateSql, + req.get("english_name"), + id); + } + + // INSERT + else { + + Integer nextOrder = jdbcTemplate.queryForObject( + """ + + SELECT IFNULL(MAX(orderby),0) + 1 + FROM sleepingspace_master + + """, + Integer.class); + + String insertSql = """ + + INSERT INTO sleepingspace_master + ( + english_name, + orderby, + + isactive, + isdelete + ) + VALUES + ( + ?, + ?, + + 1, + 0 + ) + + """; + + jdbcTemplate.update( + insertSql, + req.get("english_name"), + nextOrder); + } + } + + public void updateSleepingSpaceStatus( + Map req) { + + Integer id = Integer.parseInt( + req.get("id").toString()); + + Integer status = Integer.parseInt( + req.get("status").toString()); + + String sql = """ + + UPDATE sleepingspace_master + SET + isactive = ?, + isdelete = ? + WHERE id = ? + + """; + + jdbcTemplate.update( + sql, + status, + status == 1 ? 0 : 1, + id); + } + + public List> getMovingReasonList() { + + String sql = """ + + SELECT + id, + english_name, + isactive, + isdelete + FROM reason_moving_master + WHERE isactive = 1 + AND isdelete = 0 + ORDER BY orderby + + """; + + return jdbcTemplate.queryForList(sql); + } + + public void saveMovingReason(Map req) { + + Integer id = req.get("id") != null + ? Integer.parseInt(req.get("id").toString()) + : 0; + + // UPDATE + if (id > 0) { + + String updateSql = """ + + UPDATE reason_moving_master + SET english_name = ? + WHERE id = ? + + """; + + jdbcTemplate.update( + updateSql, + req.get("english_name"), + id); + } + + // INSERT + else { + + Integer nextOrder = jdbcTemplate.queryForObject( + """ + + SELECT IFNULL(MAX(orderby),0) + 1 + FROM reason_moving_master + + """, + Integer.class); + + String insertSql = """ + + INSERT INTO reason_moving_master + ( + english_name, + orderby, + + isactive, + isdelete + ) + VALUES + ( + ?, + ?, + + 1, + 0 + ) + + """; + + jdbcTemplate.update( + insertSql, + req.get("english_name"), + nextOrder); + } + } + + public void updateMovingReasonStatus( + Map req) { + + Integer id = Integer.parseInt( + req.get("id").toString()); + + Integer status = Integer.parseInt( + req.get("status").toString()); + + String sql = """ + + UPDATE reason_moing_master + SET + isactive = ?, + isdelete = ? + WHERE id = ? + + """; + + jdbcTemplate.update( + sql, + status, + status == 1 ? 0 : 1, + id); + } + + public List> getComeOutShelterList() { + + String sql = """ + + SELECT + id, + english_name, + isactive, + isdelete + FROM reason_comeoutshelter_master + WHERE isactive = 1 + AND isdelete = 0 + ORDER BY orderby + + """; + + return jdbcTemplate.queryForList(sql); + } + + public void saveComeOutShelter(Map req) { + + Integer id = req.get("id") != null + ? Integer.parseInt(req.get("id").toString()) + : 0; + + // UPDATE + if (id > 0) { + + String updateSql = """ + + UPDATE reason_comeoutshelter_master + SET english_name = ? + WHERE id = ? + + """; + + jdbcTemplate.update( + updateSql, + req.get("english_name"), + id); + } + + // INSERT + else { + + Integer nextOrder = jdbcTemplate.queryForObject( + """ + + SELECT IFNULL(MAX(orderby),0) + 1 + FROM reason_comeoutshelter_master + + """, + Integer.class); + + String insertSql = """ + + INSERT INTO reason_comeoutshelter_master + ( + english_name, + orderby, + + isactive, + isdelete + ) + VALUES + ( + ?, + ?, + + 1, + 0 + ) + + """; + + jdbcTemplate.update( + insertSql, + req.get("english_name"), + nextOrder); + } + } + + public void updateComeOutShelterStatus( + Map req) { + + Integer id = Integer.parseInt( + req.get("id").toString()); + + Integer status = Integer.parseInt( + req.get("status").toString()); + + String sql = """ + + UPDATE reason_comeoutshelter_master + SET + isactive = ?, + isdelete = ? + WHERE id = ? + + """; + + jdbcTemplate.update( + sql, + status, + status == 1 ? 0 : 1, + id); + } + + public List> getGCCShelterMasterList() { + + String sql = """ + + SELECT + id, + english_name, + isactive, + isdelete + FROM gccshelter_notstayed_master + WHERE isactive = 1 + AND isdelete = 0 + ORDER BY orderby + + """; + + return jdbcTemplate.queryForList(sql); + } + + public void saveGCCShelterMaster(Map req) { + + Integer id = req.get("id") != null + ? Integer.parseInt(req.get("id").toString()) + : 0; + + // UPDATE + if (id > 0) { + + String updateSql = """ + + UPDATE gccshelter_notstayed_master + SET english_name = ? + WHERE id = ? + + """; + + jdbcTemplate.update( + updateSql, + req.get("english_name"), + id); + } + + // INSERT + else { + + Integer nextOrder = jdbcTemplate.queryForObject( + """ + + SELECT IFNULL(MAX(orderby),0) + 1 + FROM gccshelter_notstayed_master + """, + Integer.class); + + String insertSql = """ + + INSERT INTO gccshelter_notstayed_master + ( + english_name, + orderby, + + isactive, + isdelete + ) + VALUES + ( + ?, + ?, + + 1, + 0 + ) + + """; + + jdbcTemplate.update( + insertSql, + req.get("english_name"), + nextOrder); + } + } + + public void updateGCCShelterMasterStatus( + Map req) { + + Integer id = Integer.parseInt( + req.get("id").toString()); + + Integer status = Integer.parseInt( + req.get("status").toString()); + + String sql = """ + + UPDATE gccshelter_notstayed_master + SET + isactive = ?, + isdelete = ? + WHERE id = ? + + """; + + jdbcTemplate.update( + sql, + status, + status == 1 ? 0 : 1, + id); + } + + public List> getBirthCertificateNoReasonMasterList() { + + String sql = """ + + SELECT + id, + english_name, + isactive, + isdelete + FROM birth_cert_no_reason_master + WHERE isactive = 1 + AND isdelete = 0 + ORDER BY orderby + + """; + + return jdbcTemplate.queryForList(sql); + } + + public void saveBirthCertificateNoReasonMaster(Map req) { + + Integer id = req.get("id") != null + ? Integer.parseInt(req.get("id").toString()) + : 0; + + // UPDATE + if (id > 0) { + + String updateSql = """ + + UPDATE birth_cert_no_reason_master + SET english_name = ? + WHERE id = ? + + """; + + jdbcTemplate.update( + updateSql, + req.get("english_name"), + id); + } + + // INSERT + else { + + Integer nextOrder = jdbcTemplate.queryForObject( + """ + + SELECT IFNULL(MAX(orderby),0) + 1 + FROM birth_cert_no_reason_master + """, + Integer.class); + + String insertSql = """ + + INSERT INTO birth_cert_no_reason_master + ( + english_name, + orderby, + + isactive, + isdelete + ) + VALUES + ( + ?, + ?, + + 1, + 0 + ) + + """; + + jdbcTemplate.update( + insertSql, + req.get("english_name"), + nextOrder); + } + } + + public void updateBirthCertificateNoReasonMasterStatus( + Map req) { + + Integer id = Integer.parseInt( + req.get("id").toString()); + + Integer status = Integer.parseInt( + req.get("status").toString()); + + String sql = """ + + UPDATE birth_cert_no_reason_master + SET + isactive = ?, + isdelete = ? + WHERE id = ? + + """; + + jdbcTemplate.update( + sql, + status, + status == 1 ? 0 : 1, + id); + } + + public List> getCommunityMasterList() { + + String sql = """ + + SELECT + id, + english_name, + isactive, + isdelete + FROM commu_cert_no_reason_master + WHERE isactive = 1 + AND isdelete = 0 + ORDER BY orderby + + """; + + return jdbcTemplate.queryForList(sql); + } + + public void saveCommunityMaster(Map req) { + + Integer id = req.get("id") != null + ? Integer.parseInt(req.get("id").toString()) + : 0; + + // UPDATE + if (id > 0) { + + String updateSql = """ + + UPDATE commu_cert_no_reason_master + SET english_name = ? + WHERE id = ? + + """; + + jdbcTemplate.update( + updateSql, + req.get("english_name"), + id); + } + + // INSERT + else { + + Integer nextOrder = jdbcTemplate.queryForObject( + """ + + SELECT IFNULL(MAX(orderby),0) + 1 + FROM commu_cert_no_reason_master + """, + Integer.class); + + String insertSql = """ + + INSERT INTO commu_cert_no_reason_master + ( + english_name, + orderby, + + isactive, + isdelete + ) + VALUES + ( + ?, + ?, + + 1, + 0 + ) + + """; + + jdbcTemplate.update( + insertSql, + req.get("english_name"), + nextOrder); + } + } + + public void updateCommunityMasterStatus( + Map req) { + + Integer id = Integer.parseInt( + req.get("id").toString()); + + Integer status = Integer.parseInt( + req.get("status").toString()); + + String sql = """ + + UPDATE commu_cert_no_reason_master + SET + isactive = ?, + isdelete = ? + WHERE id = ? + + """; + + jdbcTemplate.update( + sql, + status, + status == 1 ? 0 : 1, + id); + } + + public List> getVoterIdMasterList() { + + String sql = """ + + SELECT + id, + english_name, + isactive, + isdelete + FROM voter_id_no_reason_master + WHERE isactive = 1 + AND isdelete = 0 + ORDER BY orderby + + """; + + return jdbcTemplate.queryForList(sql); + } + + public void saveVoterIdMaster(Map req) { + + Integer id = req.get("id") != null + ? Integer.parseInt(req.get("id").toString()) + : 0; + + // UPDATE + if (id > 0) { + + String updateSql = """ + + UPDATE voter_id_no_reason_master + SET english_name = ? + WHERE id = ? + + """; + + jdbcTemplate.update( + updateSql, + req.get("english_name"), + id); + } + + // INSERT + else { + + Integer nextOrder = jdbcTemplate.queryForObject( + """ + + SELECT IFNULL(MAX(orderby),0) + 1 + FROM voter_id_no_reason_master + """, + Integer.class); + + String insertSql = """ + + INSERT INTO voter_id_no_reason_master + ( + english_name, + orderby, + + isactive, + isdelete + ) + VALUES + ( + ?, + ?, + + 1, + 0 + ) + + """; + + jdbcTemplate.update( + insertSql, + req.get("english_name"), + nextOrder); + } + } + + public void updateVoterIdMasterStatus( + Map req) { + + Integer id = Integer.parseInt( + req.get("id").toString()); + + Integer status = Integer.parseInt( + req.get("status").toString()); + + String sql = """ + + UPDATE voter_id_no_reason_master + SET + isactive = ?, + isdelete = ? + WHERE id = ? + + """; + + jdbcTemplate.update( + sql, + status, + status == 1 ? 0 : 1, + id); + } + + public List> getAadharCertificateNoReasonMasterList() { + + String sql = """ + + SELECT + id, + english_name, + isactive, + isdelete + FROM adhar_card_no_reason_master + WHERE isactive = 1 + AND isdelete = 0 + ORDER BY orderby + + """; + + return jdbcTemplate.queryForList(sql); + } + + public void saveAadharCertificateNoReasonMaster(Map req) { + + Integer id = req.get("id") != null + ? Integer.parseInt(req.get("id").toString()) + : 0; + + // UPDATE + if (id > 0) { + + String updateSql = """ + + UPDATE adhar_card_no_reason_master + SET english_name = ? + WHERE id = ? + + """; + + jdbcTemplate.update( + updateSql, + req.get("english_name"), + id); + } + + // INSERT + else { + + Integer nextOrder = jdbcTemplate.queryForObject( + """ + + SELECT IFNULL(MAX(orderby),0) + 1 + FROM adhar_card_no_reason_master + """, + Integer.class); + + String insertSql = """ + + INSERT INTO adhar_card_no_reason_master + ( + english_name, + orderby, + + isactive, + isdelete + ) + VALUES + ( + ?, + ?, + + 1, + 0 + ) + + """; + + jdbcTemplate.update( + insertSql, + req.get("english_name"), + nextOrder); + } + } + + public void updateAadharCertificateNoReasonMasterStatus( + Map req) { + + Integer id = Integer.parseInt( + req.get("id").toString()); + + Integer status = Integer.parseInt( + req.get("status").toString()); + + String sql = """ + + UPDATE adhar_card_no_reason_master + SET + isactive = ?, + isdelete = ? + WHERE id = ? + + """; + + jdbcTemplate.update( + sql, + status, + status == 1 ? 0 : 1, + id); + } + + public List> getSmartCardNoReasonMasterList() { + + String sql = """ + + SELECT + id, + english_name, + isactive, + isdelete + FROM smart_card_no_reason_master + WHERE isactive = 1 + AND isdelete = 0 + ORDER BY orderby + + """; + + return jdbcTemplate.queryForList(sql); + } + + public void saveSmartCardNoReasonMaster(Map req) { + + Integer id = req.get("id") != null + ? Integer.parseInt(req.get("id").toString()) + : 0; + + // UPDATE + if (id > 0) { + + String updateSql = """ + + UPDATE smart_card_no_reason_master + SET english_name = ? + WHERE id = ? + + """; + + jdbcTemplate.update( + updateSql, + req.get("english_name"), + id); + } + + // INSERT + else { + + Integer nextOrder = jdbcTemplate.queryForObject( + """ + + SELECT IFNULL(MAX(orderby),0) + 1 + FROM smart_card_no_reason_master + """, + Integer.class); + + String insertSql = """ + + INSERT INTO smart_card_no_reason_master + ( + english_name, + orderby, + + isactive, + isdelete + ) + VALUES + ( + ?, + ?, + + 1, + 0 + ) + + """; + + jdbcTemplate.update( + insertSql, + req.get("english_name"), + nextOrder); + } + } + + public void updateSmartCardNoReasonMasterStatus( + Map req) { + + Integer id = Integer.parseInt( + req.get("id").toString()); + + Integer status = Integer.parseInt( + req.get("status").toString()); + + String sql = """ + + UPDATE smart_card_no_reason_master + SET + isactive = ?, + isdelete = ? + WHERE id = ? + + """; + + jdbcTemplate.update( + sql, + status, + status == 1 ? 0 : 1, + id); + } + + public List> getDriverLicenseNoReasonMasterList() { + + String sql = """ + + SELECT + id, + english_name, + isactive, + isdelete + FROM dri_license_no_reason_master + WHERE isactive = 1 + AND isdelete = 0 + ORDER BY orderby + + """; + + return jdbcTemplate.queryForList(sql); + } + + public void saveDriverLicenseNoReasonMaster(Map req) { + + Integer id = req.get("id") != null + ? Integer.parseInt(req.get("id").toString()) + : 0; + + // UPDATE + if (id > 0) { + + String updateSql = """ + + UPDATE dri_license_no_reason_master + SET english_name = ? + WHERE id = ? + + """; + + jdbcTemplate.update( + updateSql, + req.get("english_name"), + id); + } + + // INSERT + else { + + Integer nextOrder = jdbcTemplate.queryForObject( + """ + + SELECT IFNULL(MAX(orderby),0) + 1 + FROM dri_license_no_reason_master + """, + Integer.class); + + String insertSql = """ + + INSERT INTO dri_license_no_reason_master + ( + english_name, + orderby, + + isactive, + isdelete + ) + VALUES + ( + ?, + ?, + + 1, + 0 + ) + + """; + + jdbcTemplate.update( + insertSql, + req.get("english_name"), + nextOrder); + } + } + + public void updateDriverLicenseNoReasonMasterStatus( + Map req) { + + Integer id = Integer.parseInt( + req.get("id").toString()); + + Integer status = Integer.parseInt( + req.get("status").toString()); + + String sql = """ + + UPDATE dri_license_no_reason_master + SET + isactive = ?, + isdelete = ? + WHERE id = ? + + """; + + jdbcTemplate.update( + sql, + status, + status == 1 ? 0 : 1, + id); + } + + public List> getCmInsuranceNoReasonMasterList() { + + String sql = """ + + SELECT + id, + english_name, + isactive, + isdelete + FROM cm_insurance_no_reason_master + WHERE isactive = 1 + AND isdelete = 0 + ORDER BY orderby + + """; + + return jdbcTemplate.queryForList(sql); + } + + public void saveCmInsuranceNoReasonMaster(Map req) { + + Integer id = req.get("id") != null + ? Integer.parseInt(req.get("id").toString()) + : 0; + + // UPDATE + if (id > 0) { + + String updateSql = """ + + UPDATE cm_insurance_no_reason_master + SET english_name = ? + WHERE id = ? + + """; + + jdbcTemplate.update( + updateSql, + req.get("english_name"), + id); + } + + // INSERT + else { + + Integer nextOrder = jdbcTemplate.queryForObject( + """ + + SELECT IFNULL(MAX(orderby),0) + 1 + FROM cm_insurance_no_reason_master + """, + Integer.class); + + String insertSql = """ + + INSERT INTO cm_insurance_no_reason_master + ( + english_name, + orderby, + + isactive, + isdelete + ) + VALUES + ( + ?, + ?, + + 1, + 0 + ) + + """; + + jdbcTemplate.update( + insertSql, + req.get("english_name"), + nextOrder); + } + } + + public void updateCmInsuranceNoReasonMasterStatus( + Map req) { + + Integer id = Integer.parseInt( + req.get("id").toString()); + + Integer status = Integer.parseInt( + req.get("status").toString()); + + String sql = """ + + UPDATE cm_insurance_no_reason_master + SET + isactive = ?, + isdelete = ? + WHERE id = ? + + """; + + jdbcTemplate.update( + sql, + status, + status == 1 ? 0 : 1, + id); + } + + public List> getBankPassbookNoReasonMasterList() { + + String sql = """ + + SELECT + id, + english_name, + isactive, + isdelete + FROM bank_passbook_no_reason_master + WHERE isactive = 1 + AND isdelete = 0 + ORDER BY orderby + + """; + + return jdbcTemplate.queryForList(sql); + } + + public void saveBankPassbookNoReasonMaster(Map req) { + + Integer id = req.get("id") != null + ? Integer.parseInt(req.get("id").toString()) + : 0; + + // UPDATE + if (id > 0) { + + String updateSql = """ + + UPDATE bank_passbook_no_reason_master + SET english_name = ? + WHERE id = ? + + """; + + jdbcTemplate.update( + updateSql, + req.get("english_name"), + id); + } + + // INSERT + else { + + Integer nextOrder = jdbcTemplate.queryForObject( + """ + + SELECT IFNULL(MAX(orderby),0) + 1 + FROM bank_passbook_no_reason_master + """, + Integer.class); + + String insertSql = """ + + INSERT INTO bank_passbook_no_reason_master + ( + english_name, + orderby, + + isactive, + isdelete + ) + VALUES + ( + ?, + ?, + + 1, + 0 + ) + + """; + + jdbcTemplate.update( + insertSql, + req.get("english_name"), + nextOrder); + } + } + + public void updateBankPassbookNoReasonMasterStatus( + Map req) { + + Integer id = Integer.parseInt( + req.get("id").toString()); + + Integer status = Integer.parseInt( + req.get("status").toString()); + + String sql = """ + + UPDATE bank_passbook_no_reason_master + SET + isactive = ?, + isdelete = ? + WHERE id = ? + + """; + + jdbcTemplate.update( + sql, + status, + status == 1 ? 0 : 1, + id); + } + + public List> getReligionMasterList() { + + String sql = """ + + SELECT + id, + english_name, + isactive, + isdelete + FROM religion_master + WHERE isactive = 1 + AND isdelete = 0 + ORDER BY orderby + + """; + + return jdbcTemplate.queryForList(sql); + } + + public void saveReligionMaster(Map req) { + + Integer id = req.get("id") != null + ? Integer.parseInt(req.get("id").toString()) + : 0; + + // UPDATE + if (id > 0) { + + String updateSql = """ + + UPDATE religion_master + SET english_name = ? + WHERE id = ? + + """; + + jdbcTemplate.update( + updateSql, + req.get("english_name"), + id); + } + + // INSERT + else { + + Integer nextOrder = jdbcTemplate.queryForObject( + """ + + SELECT IFNULL(MAX(orderby),0) + 1 + FROM religion_master + """, + Integer.class); + + String insertSql = """ + + INSERT INTO religion_master + ( + english_name, + orderby, + + isactive, + isdelete + ) + VALUES + ( + ?, + ?, + + 1, + 0 + ) + + """; + + jdbcTemplate.update( + insertSql, + req.get("english_name"), + nextOrder); + } + } + + public void updateReligionMasterStatus( + Map req) { + + Integer id = Integer.parseInt( + req.get("id").toString()); + + Integer status = Integer.parseInt( + req.get("status").toString()); + + String sql = """ + + UPDATE religion_master + SET + isactive = ?, + isdelete = ? + WHERE id = ? + + """; + + jdbcTemplate.update( + sql, + status, + status == 1 ? 0 : 1, + id); + } + + public List> getCasteMasterList() { + + String sql = """ + + SELECT + id, + english_name, + isactive, + isdelete + FROM caste_master + WHERE isactive = 1 + AND isdelete = 0 + ORDER BY orderby + + """; + + return jdbcTemplate.queryForList(sql); + } + + public void saveCasteMaster(Map req) { + + Integer id = req.get("id") != null + ? Integer.parseInt(req.get("id").toString()) + : 0; + + // UPDATE + if (id > 0) { + + String updateSql = """ + + UPDATE caste_master + SET english_name = ? + WHERE id = ? + + """; + + jdbcTemplate.update( + updateSql, + req.get("english_name"), + id); + } + + // INSERT + else { + + Integer nextOrder = jdbcTemplate.queryForObject( + """ + + SELECT IFNULL(MAX(orderby),0) + 1 + FROM caste_master + """, + Integer.class); + + String insertSql = """ + + INSERT INTO caste_master + ( + english_name, + orderby, + + isactive, + isdelete + ) + VALUES + ( + ?, + ?, + + 1, + 0 + ) + + """; + + jdbcTemplate.update( + insertSql, + req.get("english_name"), + nextOrder); + } + } + + public void updateCasteMasterStatus( + Map req) { + + Integer id = Integer.parseInt( + req.get("id").toString()); + + Integer status = Integer.parseInt( + req.get("status").toString()); + + String sql = """ + + UPDATE caste_master + SET + isactive = ?, + isdelete = ? + WHERE id = ? + + """; + + jdbcTemplate.update( + sql, + status, + status == 1 ? 0 : 1, + id); + } + + public List> getZoneWiseCount() { + + String sql = + + "SELECT " + + + "zm.zone_name AS zone, " + + + "COUNT(DISTINCT sld.survey_id) AS total " + + + "FROM gcc_street_vendor.zone_master zm " + + + "LEFT JOIN surveyor_location_details sld " + + "ON sld.zone = zm.zone_name " + + + "GROUP BY zm.zone_name " + + + "ORDER BY CAST(zm.zone_name AS UNSIGNED)"; + + return jdbcTemplate.queryForList(sql); + } + + public List> getWardWiseCount( + String zone) { + + String sql = + + "SELECT " + + + "wm.ward_name AS ward, " + + + "COUNT(DISTINCT sld.survey_id) AS total " + + + "FROM gcc_street_vendor.ward_master wm " + + + "LEFT JOIN surveyor_location_details sld " + + "ON sld.zone = wm.zone_id " + + "AND sld.ward = wm.ward_name " + + + "WHERE wm.zone_id = ? " + + + "GROUP BY wm.ward_name " + + + "ORDER BY CAST(wm.ward_name AS UNSIGNED)"; + + return jdbcTemplate.queryForList( + sql, + zone); + } + + public Map getDashboard() { + + Map response = new HashMap<>(); + + response.put( + "totalHomeless", + getTotalHomeless()); + + response.put( + "zonesCovered", + getZonesCovered()); + + response.put( + "maleCount", + getMaleCount()); + + response.put( + "femaleCount", + getFemaleCount()); + + response.put( + "othersCount", + getOthersCount()); + + response.put( + "zoneWise", + getZoneWiseCount()); + + response.put( + "casteWise", + getCasteWiseCount()); + response.put( + "employedCount", + getEmployedCount()); + + response.put( + "unEmployedCount", + getUnEmployedCount()); + + response.put( + "shelterStayedYes", + getShelterStayedYesCount()); + + response.put( + "shelterStayedNo", + getShelterStayedNoCount()); + response.put( + "youngAdults", + getYoungAdultsCount()); + + response.put( + "middleAgedAdults", + getMiddleAgedCount()); + + response.put( + "olderAdults", + getOlderAdultsCount()); + + return response; + } + + private int getShelterStayedNoCount() { + + String sql = + + "SELECT COUNT(DISTINCT survey_id) " + + + "FROM homeless_survey_response " + + + "WHERE qid = 44 " + + + "AND answer = '17' " + + + "AND isactive = 1 " + + + "AND isdelete = 0"; + + return jdbcTemplate.queryForObject( + sql, + Integer.class); + } + + private int getShelterStayedYesCount() { + + String sql = + + "SELECT COUNT(DISTINCT survey_id) " + + + "FROM homeless_survey_response " + + + "WHERE qid = 44 " + + + "AND answer = '16' " + + + "AND isactive = 1 " + + + "AND isdelete = 0"; + + return jdbcTemplate.queryForObject( + sql, + Integer.class); + } + + private int getUnEmployedCount() { + + String sql = + + "SELECT COUNT(DISTINCT survey_id) " + + + "FROM homeless_survey_response " + + + "WHERE qid = 27 " + + + "AND answer = '13' " + + + "AND isactive = 1 " + + + "AND isdelete = 0"; + + return jdbcTemplate.queryForObject( + sql, + Integer.class); + } + + private int getEmployedCount() { + + String sql = + + "SELECT COUNT(DISTINCT survey_id) " + + + "FROM homeless_survey_response " + + + "WHERE qid = 27 " + + + "AND answer = '12' " + + + "AND isactive = 1 " + + + "AND isdelete = 0"; + + return jdbcTemplate.queryForObject( + sql, + Integer.class); + } + + private int getOlderAdultsCount() { + + String sql = + + "SELECT COUNT(DISTINCT survey_id) " + + + "FROM homeless_survey_response " + + + "WHERE qid = 78 " + + + "AND CAST(answer AS UNSIGNED) >= 55 " + + + "AND isactive = 1 " + + + "AND isdelete = 0"; + + return jdbcTemplate.queryForObject( + sql, + Integer.class); + } + + private int getYoungAdultsCount() { + + String sql = + + "SELECT COUNT(DISTINCT survey_id) " + + + "FROM homeless_survey_response " + + + "WHERE qid = 78 " + + + "AND CAST(answer AS UNSIGNED) BETWEEN 18 AND 34 " + + + "AND isactive = 1 " + + + "AND isdelete = 0"; + + return jdbcTemplate.queryForObject( + sql, + Integer.class); + } + + public Integer getDocumentCount(String surveyId) { + + String sql = """ + + SELECT COUNT(*) + + FROM homeless_survey_response + + WHERE survey_id = ? + + AND qid IN (50,53,56,59,62,65,68,71) + + AND answer IS NOT NULL + + AND TRIM(answer) <> '' + + AND isactive = 1 + + AND isdelete = 0 + + """; + + return jdbcTemplate.queryForObject( + sql, + Integer.class, + surveyId); + } + + private int getMiddleAgedCount() { + + String sql = + + "SELECT COUNT(DISTINCT survey_id) " + + + "FROM homeless_survey_response " + + + "WHERE qid = 78 " + + + "AND CAST(answer AS UNSIGNED) BETWEEN 35 AND 54 " + + + "AND isactive = 1 " + + + "AND isdelete = 0"; + + return jdbcTemplate.queryForObject( + sql, + Integer.class); + } + + private int getMiddleAgedCount1() { + + String sql = + + "SELECT COUNT(DISTINCT survey_id) " + + + "FROM homeless_survey_response " + + + "WHERE qid = 78 " + + + "AND CAST(answer AS UNSIGNED) BETWEEN 35 AND 54 " + + + "AND isactive = 1 " + + + "AND isdelete = 0"; + + return jdbcTemplate.queryForObject( + sql, + Integer.class); + } + + private int getTotalHomeless() { + + String sql = + + "SELECT COUNT(DISTINCT survey_id) " + + "FROM homeless_survey_response " + + "WHERE isactive = 1 " + + "AND isdelete = 0"; + + return jdbcTemplate.queryForObject( + sql, + Integer.class); + } + + private int getZonesCovered() { + + String sql = + + "SELECT COUNT(DISTINCT zone) " + + "FROM surveyor_location_details"; + + return jdbcTemplate.queryForObject( + sql, + Integer.class); + } + + public List> getCasteWiseCount() { + + String sql = + + "SELECT " + + + "cm.id, " + + + "cm.english_name AS caste, " + + + "COALESCE(COUNT(DISTINCT hr.survey_id), 0) AS total " + + + "FROM caste_master cm " + + + "LEFT JOIN homeless_survey_response hr " + + + "ON hr.qid = 13 " + + + "AND CAST(hr.answer AS UNSIGNED) = cm.id " + + + "AND hr.isactive = 1 " + + + "AND hr.isdelete = 0 " + + + "WHERE cm.isactive = 1 " + + + "AND cm.isdelete = 0 " + + + "GROUP BY cm.id, cm.english_name " + + + "ORDER BY cm.orderby"; + + return jdbcTemplate.queryForList(sql); + } + + private int getMaleCount() { + + String sql = + + "SELECT COUNT(DISTINCT survey_id) " + + "FROM homeless_survey_response " + + "WHERE qid = 7 " + + "AND answer = '1'"; + + return jdbcTemplate.queryForObject( + sql, + Integer.class); + } + + private int getFemaleCount() { + + String sql = + + "SELECT COUNT(DISTINCT survey_id) " + + "FROM homeless_survey_response " + + "WHERE qid = 7 " + + "AND answer = '2'"; + + return jdbcTemplate.queryForObject( + sql, + Integer.class); + } + + private int getOthersCount() { + + String sql = + + "SELECT COUNT(DISTINCT survey_id) " + + "FROM homeless_survey_response " + + "WHERE qid = 7 " + + "AND answer = '3'"; + + Integer count = jdbcTemplate.queryForObject( + sql, + Integer.class); + + return count == null ? 0 : count; + } + +} diff --git a/src/main/java/in/gov/chennaicorporation/gccoffice/roadwar/controller/Maincontroller.java b/src/main/java/in/gov/chennaicorporation/gccoffice/roadwar/controller/Maincontroller.java new file mode 100644 index 0000000..a00ecb6 --- /dev/null +++ b/src/main/java/in/gov/chennaicorporation/gccoffice/roadwar/controller/Maincontroller.java @@ -0,0 +1,57 @@ +package in.gov.chennaicorporation.gccoffice.roadwar.controller; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; + +import in.gov.chennaicorporation.gccoffice.roadwar.service.LoginMappingService; +import in.gov.chennaicorporation.gccoffice.service.LoginUserInfo; + +@RequestMapping("/gcc/roadwarweb") +@Controller("RoadWarMainController") +public class Maincontroller { + + @Autowired + private LoginUserInfo loginUserInfo; + + @Autowired + private LoginMappingService loginMappingService; + + @GetMapping("/regform") + public String viewdashboard(Model model) { + String LoginUserId = LoginUserInfo.getLoginUserId(); + model.addAttribute("LoginUserId", LoginUserId); + + String zone=loginMappingService.getZoneByUserId(LoginUserId); + String ward=loginMappingService.getWardByUserId(LoginUserId); + + model.addAttribute("Loginzone", zone); + model.addAttribute("Loginward", ward); + + String UserRole = LoginUserInfo.getUserRole(); + model.addAttribute("UserRole", UserRole); + + return "modules/roadwar/regform"; + } + + + @GetMapping("/updateform") + public String updateForm(Model model) { + String LoginUserId = LoginUserInfo.getLoginUserId(); + model.addAttribute("LoginUserId", LoginUserId); + + String zone=loginMappingService.getZoneByUserId(LoginUserId); + String ward=loginMappingService.getWardByUserId(LoginUserId); + + model.addAttribute("Loginzone", zone); + model.addAttribute("Loginward", ward); + + String UserRole = LoginUserInfo.getUserRole(); + model.addAttribute("UserRole", UserRole); + + return "modules/roadwar/updateform"; + } + +} diff --git a/src/main/java/in/gov/chennaicorporation/gccoffice/roadwar/controller/RegisterApiController.java b/src/main/java/in/gov/chennaicorporation/gccoffice/roadwar/controller/RegisterApiController.java new file mode 100644 index 0000000..6ea8d30 --- /dev/null +++ b/src/main/java/in/gov/chennaicorporation/gccoffice/roadwar/controller/RegisterApiController.java @@ -0,0 +1,258 @@ +package in.gov.chennaicorporation.gccoffice.roadwar.controller; + +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +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.RestController; + +import in.gov.chennaicorporation.gccoffice.roadwar.service.RegisterService; + +@RestController +@RequestMapping("/gcc/api/roadwarweb/register") +public class RegisterApiController { + + + @Autowired + private RegisterService registerService; + + + @GetMapping("/getzones") + public Map ViewZoneDropdown() { + + Map response = new HashMap<>(); + + List> zones = registerService.ViewZoneDropdown(); + + if (!zones.isEmpty()) { + response.put("status", true); + response.put("message", "Zone list fetched successfully"); + response.put("data", zones); + } else { + response.put("status", false); + response.put("message", "No zones found"); + response.put("data", Collections.emptyList()); + } + + return response; + } + + @GetMapping("/getwardbyzone") + public Map ViewWardDropdown(@RequestParam String zone) { + + Map response = new HashMap<>(); + + List> wards = registerService.ViewWardDropdown(zone); + + if (!wards.isEmpty()) { + response.put("status", true); + response.put("message", "Ward list fetched successfully"); + response.put("data", wards); + } else { + response.put("status", false); + response.put("message", "No wards found"); + response.put("data", Collections.emptyList()); + } + + return response; + } + + + + @GetMapping("/getRoadNamesByWard") + public Map getRoadNamesByWard(@RequestParam String ward) { + Map response = new HashMap<>(); + List> roads = registerService.getRoadNamesByWard(ward); + if (!roads.isEmpty()) { + response.put("status", true); + response.put("message", "Road names fetched successfully"); + response.put("data", roads); + } else { + response.put("status", false); + response.put("message", "No roads found for ward: " + ward); + response.put("data", Collections.emptyList()); + } + return response; + } + + + @GetMapping("/getRoadType") + public Map getRoadType() { + Map response = new HashMap<>(); + List> roadTypes = registerService.getRoadType(); + if (!roadTypes.isEmpty()) { + response.put("status", true); + response.put("message", "Road types fetched successfully"); + response.put("data", roadTypes); + } else { + response.put("status", false); + response.put("message", "No road types found"); + response.put("data", Collections.emptyList()); + } + return response; + } + + + @GetMapping("/getRoadTypeMaterial") + public Map getRoadTypeMaterial() { + Map response = new HashMap<>(); + List> roadTypes = registerService.getRoadTypeMaterial(); + if (!roadTypes.isEmpty()) { + response.put("status", true); + response.put("message", "Roadtype Material fetched successfully"); + response.put("data", roadTypes); + } else { + response.put("status", false); + response.put("message", "No roadtype material found"); + response.put("data", Collections.emptyList()); + } + return response; + } + + @GetMapping("/getFootpathType") + public Map getFootpathType() { + Map response = new HashMap<>(); + List> roadTypes = registerService.getFootpathType(); + if (!roadTypes.isEmpty()) { + response.put("status", true); + response.put("message", "Footpath Types fetched successfully"); + response.put("data", roadTypes); + } else { + response.put("status", false); + response.put("message", "No Footpath Types found"); + response.put("data", Collections.emptyList()); + } + return response; + } + + @GetMapping("/getRoadSide") + public Map getRoadSide() { + Map response = new HashMap<>(); + List> roadTypes = registerService.getRoadSide(); + if (!roadTypes.isEmpty()) { + response.put("status", true); + response.put("message", "Road sides fetched successfully"); + response.put("data", roadTypes); + } else { + response.put("status", false); + response.put("message", "No Road sides found"); + response.put("data", Collections.emptyList()); + } + return response; + } + + @GetMapping("/getMonthList") + public Map getMonthList() { + Map response = new HashMap<>(); + List> months = registerService.getMonthList(); + if (!months.isEmpty()) { + response.put("status", true); + response.put("message", "Month list fetched successfully"); + response.put("data", months); + } else { + response.put("status", false); + response.put("message", "No months found"); + response.put("data", Collections.emptyList()); + } + return response; + } + + + + @GetMapping("/getYearList") + public Map getYearList() { + Map response = new HashMap<>(); + List> years = registerService.getYearList(); + if (!years.isEmpty()) { + response.put("status", true); + response.put("message", "Year list fetched successfully"); + response.put("data", years); + } else { + response.put("status", false); + response.put("message", "No Year found"); + response.put("data", Collections.emptyList()); + } + return response; + } + + + @PostMapping("/saveRoadWarDetails") + public Map saveRoadWarDetails(@RequestBody Map payload) { + return registerService.saveRoadWarDetails(payload); + } + + + @GetMapping("/getAllRoadWarDetails") + public ResponseEntity getAllRoadWarDetails( + @RequestParam(required = false) String userid, + @RequestParam(required = false) String zone, + @RequestParam(required = false) String ward, + @RequestParam(required = false) String roadId) { + + try { + + List> response = + registerService.getAllRoadWarDetails(userid,zone, ward, roadId); + + return ResponseEntity.ok(response); + + } catch (Exception e) { + + return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) + .body(Collections.singletonMap("error", + "Failed to fetch data : " + e.getMessage())); + } + } + + + + @GetMapping("/getRoadWarDetailsById") + public ResponseEntity getRoadWarDetailsById( + @RequestParam String refid) { + + try { + + Map response = + registerService.getRoadWarDetailsById(refid); + + return ResponseEntity.ok(response); + + } catch (Exception e) { + + Map error = new HashMap<>(); + error.put("status", false); + error.put("message", "Failed to fetch data : " + e.getMessage()); + + return ResponseEntity + .status(HttpStatus.INTERNAL_SERVER_ERROR) + .body(error); + } + } + + @GetMapping("/checkRoadExists") + public Map checkRoadExists(@RequestParam("roadId") Integer roadId) { + return registerService.checkRoadExists(roadId); + } + + @PostMapping("/updateRoadWarDetails") + public Map updateRoadWarDetails(@RequestBody Map payload) { + return registerService.updateRoadWarDetails(payload); + } + + @PostMapping("/deleteRoadWarDetails") + public Map deleteRoadWarDetails( + @RequestParam String refId,@RequestParam String updatedby) { + + return registerService.deleteRoadWarDetails(refId,updatedby); + } + +} diff --git a/src/main/java/in/gov/chennaicorporation/gccoffice/roadwar/service/LoginMappingService.java b/src/main/java/in/gov/chennaicorporation/gccoffice/roadwar/service/LoginMappingService.java new file mode 100644 index 0000000..d8d97b8 --- /dev/null +++ b/src/main/java/in/gov/chennaicorporation/gccoffice/roadwar/service/LoginMappingService.java @@ -0,0 +1,51 @@ +package in.gov.chennaicorporation.gccoffice.roadwar.service; + +import java.util.Collections; + +import javax.sql.DataSource; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.dao.EmptyResultDataAccessException; +import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.stereotype.Service; + +@Service +public class LoginMappingService { + + @Autowired + private JdbcTemplate jdbcTemplate; + + @Autowired + public void setDataSource(@Qualifier("mysqlGCCUserDataSource") DataSource dataSource) { + this.jdbcTemplate = new JdbcTemplate(dataSource); + } + + public String getZoneByUserId(String userid) { + + String sql = "SELECT zone FROM user_mapping_details WHERE userid=?"; + + try { + return jdbcTemplate.queryForObject(sql, String.class, userid); + }catch (EmptyResultDataAccessException e) { + return ""; + } catch (Exception e) { + e.printStackTrace(); + return ""; + } + } + + public String getWardByUserId(String userid) { + + String sql = "SELECT ward FROM user_mapping_details WHERE userid=?"; + + try { + return jdbcTemplate.queryForObject(sql, String.class, userid); + } catch (EmptyResultDataAccessException e) { + return ""; + }catch (Exception e) { + e.printStackTrace(); + return ""; + } + } +} diff --git a/src/main/java/in/gov/chennaicorporation/gccoffice/roadwar/service/RegisterService.java b/src/main/java/in/gov/chennaicorporation/gccoffice/roadwar/service/RegisterService.java new file mode 100644 index 0000000..6c44dd2 --- /dev/null +++ b/src/main/java/in/gov/chennaicorporation/gccoffice/roadwar/service/RegisterService.java @@ -0,0 +1,777 @@ +package in.gov.chennaicorporation.gccoffice.roadwar.service; + +import java.net.URI; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +import javax.sql.DataSource; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.core.env.Environment; +import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.jdbc.core.PreparedStatementCreator; +import org.springframework.jdbc.support.GeneratedKeyHolder; +import org.springframework.jdbc.support.KeyHolder; +import org.springframework.stereotype.Service; +import org.springframework.web.client.RestTemplate; +import org.springframework.transaction.annotation.Transactional; + +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; + +@Service +public class RegisterService { + + @Autowired + private JdbcTemplate jdbcTemplate; + + @Autowired + private Environment environment; + + @Autowired + public void setDataSource(@Qualifier("mysqlRoadWarDataSource") DataSource dataSource) { + this.jdbcTemplate = new JdbcTemplate(dataSource); + } + + public List> ViewZoneDropdown() { + String sql = "SELECT zone_name " + + "FROM zone_master " + + "WHERE is_active=1 AND is_delete=0"; + try { + return jdbcTemplate.queryForList(sql); + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + return Collections.emptyList(); + } + } + + public List> ViewWardDropdown(String zone) { + String sql = "SELECT ward_name " + + "FROM ward_master " + + "WHERE is_active=1 AND is_delete=0 AND zone_id=?"; + try { + return jdbcTemplate.queryForList(sql, zone); + } catch (Exception e) { + // TODO: handle exception + e.printStackTrace(); + return Collections.emptyList(); + } + } + + public List> getRoadNamesByWard(String ward) { + try { + String encodedWard = URLEncoder.encode("'" + ward + "'", StandardCharsets.UTF_8.toString()); + String url = "https://gisgcc.chennaicorporation.gov.in/server/rest/services/GCCDepts/EDPMobile2025/FeatureServer/0/query" + + "?where=new_ward%3D" + encodedWard + + "&fullText=&objectIds=&time=&geometry=&geometryType=esriGeometryPoint&inSR=4326&defaultSR=4326&spatialRel=esriSpatialRelIntersects&distance=&units=esriSRUnit_Meter&relationParam=" + + "&outFields=road_id%2Croad_name%2Clocality%2Carea_name%2Ctype" + + "&returnGeometry=false" + + "&maxAllowableOffset=&geometryPrecision=&outSR=&havingClause=&gdbVersion=&historicMoment=&returnDistinctValues=false&returnIdsOnly=false&returnCountOnly=false&returnExtentOnly=false&orderByFields=&groupByFieldsForStatistics=&outStatistics=&returnZ=false&returnM=false&multipatchOption=xyFootprint&resultOffset=&resultRecordCount=&returnTrueCurves=false&returnExceededLimitFeatures=false&quantizationParameters=&returnCentroid=false&returnEnvelope=false&timeReferenceUnknownClient=false&maxRecordCountFactor=&sqlFormat=none&resultType=&featureEncoding=esriDefault&datumTransformation=&cacheHint=false" + + "&f=geojson"; + + RestTemplate restTemplate = new RestTemplate(); + String responseBody = restTemplate.getForObject(URI.create(url), String.class); + + ObjectMapper objectMapper = new ObjectMapper(); + JsonNode root = objectMapper.readTree(responseBody); + JsonNode features = root.path("features"); + + List> roadList = new ArrayList<>(); + if (features.isArray()) { + for (JsonNode feature : features) { + JsonNode props = feature.path("properties"); + String roadId = props.path("road_id").asText(); + String roadName = props.path("road_name").asText(); + String locality = props.path("locality").asText(); + String areaName = props.path("area_name").asText(); + String type = props.path("type").asText(); + + Map roadInfo = new HashMap<>(); + roadInfo.put("road_id", roadId); + roadInfo.put("road_name", roadName); + roadInfo.put("locality", locality); + roadInfo.put("area_name", areaName); + roadInfo.put("type", type); + + roadList.add(roadInfo); + } + } + return roadList; + + } catch (Exception e) { + e.printStackTrace(); + return Collections.emptyList(); + } + } + + public List> getRoadType() { + String sql = "Select id,road_type as roadType from road_type_master where is_active = 1 and is_delete = 0"; + try { + return jdbcTemplate.queryForList(sql); + } catch (Exception e) { + e.printStackTrace(); + return Collections.emptyList(); + } + } + + public List> getRoadTypeMaterial() { + String sql = "Select id,roadtype_material from roadtype_material_master where is_active = 1 and is_delete = 0"; + try { + return jdbcTemplate.queryForList(sql); + } catch (Exception e) { + e.printStackTrace(); + return Collections.emptyList(); + } + } + + public List> getFootpathType() { + String sql = "Select id,footpath_type_name from footpath_type_master where is_active = 1 and is_delete = 0"; + try { + return jdbcTemplate.queryForList(sql); + } catch (Exception e) { + e.printStackTrace(); + return Collections.emptyList(); + } + } + + public List> getRoadSide() { + String sql = "Select id,road_side_name from road_side_master where is_active = 1 and is_delete = 0"; + try { + return jdbcTemplate.queryForList(sql); + } catch (Exception e) { + e.printStackTrace(); + return Collections.emptyList(); + } + } + + public List> getMonthList() { + String sql = "SELECT id, month_name FROM month_master WHERE is_active = 1 AND is_delete = 0 ORDER BY id"; + try { + return jdbcTemplate.queryForList(sql); + } catch (Exception e) { + e.printStackTrace(); + return Collections.emptyList(); + } + } + + public List> getYearList() { + String sql = "SELECT id, year_name FROM year_master WHERE is_active = 1 AND is_delete = 0 ORDER BY id DESC"; + try { + return jdbcTemplate.queryForList(sql); + } catch (Exception e) { + e.printStackTrace(); + return Collections.emptyList(); + } + } + + public Map saveRoadWarDetails(Map payload) { + Map result = new HashMap<>(); + try { + String roadId = String.valueOf(payload.get("road_id")); + + Integer count = jdbcTemplate.queryForObject( + "SELECT COUNT(*) " + + "FROM road_details_master " + + "WHERE road_id = ? " + + "AND is_active = 1 " + + "AND is_delete = 0", + Integer.class, + roadId); + + if (count != null && count > 0) { + + result.put("status", false); + result.put("message", + "Selected road is already mapped to another Road War record"); + + return result; + } + + String insertRoad = "INSERT INTO road_details_master " + + "(zone, ward, road_name, road_type, road_length, road_avg_width, road_area, " + + " footpath_material, footpath_length, footpath_width, footpath_from_location, footpath_to_location, " + + " is_swd, swd_from, swd_to, swd_length, swd_size, " + + " is_scp, scp_count, is_manhole, manhole_count, manhole_at, " + + " is_cpipe, cpipe_count, is_rwh, rwh_count, " + + " sewer_length, sewer_size, " + + " is_electric_poles, ep_count, is_hml, culvert_bridge_count, details, " + + " is_busshelter, busshelter_count, is_centermedian, erp_asset_code, cby,road_id,road_type_material,road_min_width,road_max_width, " + + " hml_count,is_streetlight_poles,streetlight_poles_count,is_mml,mml_count,road_from,road_to,is_footpath,footpath_at,area_name,locality_name,road_row_width, " + + " r_footpath_material,r_footpath_length,r_footpath_width,swd_at,rhs_swdlength,rhs_swdsize,scp_at,rhs_scpCount,r_mhCount,cp_at,r_cpCount,rwh_at,r_rwCount )" + + "VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; + + KeyHolder keyHolder = new GeneratedKeyHolder(); + + jdbcTemplate.update((PreparedStatementCreator) con -> { + var ps = con.prepareStatement(insertRoad, new String[] { "id" }); + ps.setObject(1, payload.get("zone")); + ps.setObject(2, payload.get("ward")); + ps.setObject(3, payload.get("road_name")); + ps.setObject(4, payload.get("road_type")); + // ps.setObject(5, payload.get("highway_ans")); + ps.setObject(5, payload.get("road_length")); + ps.setObject(6, payload.get("road_avg_width")); + ps.setObject(7, payload.get("road_area")); + ps.setObject(8, payload.get("footpath_material")); + ps.setObject(9, payload.get("footpath_length")); + ps.setObject(10, payload.get("footpath_width")); + ps.setObject(11, payload.get("footpath_from_location")); + ps.setObject(12, payload.get("footpath_to_location")); + ps.setObject(13, payload.get("is_swd")); + ps.setObject(14, payload.get("swd_from")); + ps.setObject(15, payload.get("swd_to")); + ps.setObject(16, payload.get("swd_length")); + ps.setObject(17, payload.get("swd_size")); + ps.setObject(18, payload.get("is_scp")); + ps.setObject(19, payload.get("scp_count")); + ps.setObject(20, payload.get("is_manhole")); + ps.setObject(21, payload.get("manhole_count")); + ps.setObject(22, payload.get("manhole_at")); + ps.setObject(23, payload.get("is_cpipe")); + ps.setObject(24, payload.get("cpipe_count")); + ps.setObject(25, payload.get("is_rwh")); + ps.setObject(26, payload.get("rwh_count")); + ps.setObject(27, payload.get("sewer_length")); + ps.setObject(28, payload.get("sewer_size")); + ps.setObject(29, payload.get("is_electric_poles")); + ps.setObject(30, payload.get("ep_count")); + ps.setObject(31, payload.get("is_hml")); + ps.setObject(32, payload.get("culvert_bridge_count")); + ps.setObject(33, payload.get("details")); + ps.setObject(34, payload.get("is_busshelter")); + ps.setObject(35, payload.get("busshelter_count")); + ps.setObject(36, payload.get("is_centermedian")); + ps.setObject(37, payload.get("erp_asset_code")); + ps.setObject(38, payload.get("cby")); + ps.setObject(39, payload.get("road_id")); + ps.setObject(40, payload.get("road_type_material")); + ps.setObject(41, payload.get("road_min_width")); + ps.setObject(42, payload.get("road_max_width")); + ps.setObject(43, payload.get("hml_count")); + ps.setObject(44, payload.get("is_streetlight_poles")); + ps.setObject(45, payload.get("streetlight_poles_count")); + ps.setObject(46, payload.get("is_mml")); + ps.setObject(47, payload.get("mml_count")); + ps.setObject(48, payload.get("roadfrom")); + ps.setObject(49, payload.get("roadto")); + ps.setObject(50, payload.get("is_footpath")); + ps.setObject(51, payload.get("footpathat")); + ps.setObject(52, payload.get("areaname")); + ps.setObject(53, payload.get("localityname")); + ps.setObject(54, payload.get("road_row_width")); + ps.setObject(55, payload.get("rhs_footpathDropdown")); + ps.setObject(56, payload.get("rhs_fplength")); + ps.setObject(57, payload.get("rhs_fpwidth")); + ps.setObject(58, payload.get("swd_at")); + ps.setObject(59, payload.get("rhs_swdlength")); + ps.setObject(60, payload.get("rhs_swdsize")); + ps.setObject(61, payload.get("scp_at")); + ps.setObject(62, payload.get("rhs_scpCount")); + ps.setObject(63, payload.get("r_mhCount")); + ps.setObject(64, payload.get("cp_at")); + ps.setObject(65, payload.get("r_cpCount")); + ps.setObject(66, payload.get("rwh_at")); + ps.setObject(67, payload.get("r_rwCount")); + return ps; + }, keyHolder); + + long generatedId = keyHolder.getKey().longValue(); + String datePrefix = LocalDate.now().format(DateTimeFormatter.ofPattern("ddMMYYYY")); + String refId = datePrefix + generatedId; + + jdbcTemplate.update( + "UPDATE road_details_master SET ref_id = ? WHERE id = ?", + refId, generatedId); + + List> relayingList = (List>) payload.get("relaying_details"); + + if (relayingList != null && !relayingList.isEmpty()) { + String insertRelay = "INSERT INTO relaying_details " + + "(road_ref_id, relay_month, relay_year,road_type_material ,cr_value, road_type, remarks, cby) " + + "VALUES (?,?,?,?,?,?,?,?)"; + + for (Map relay : relayingList) { + jdbcTemplate.update(insertRelay, + refId, + relay.get("relay_month"), + relay.get("relay_year"), + relay.get("road_type_material"), + relay.get("cr_value"), + relay.get("road_type"), + relay.get("remarks"), + payload.get("cby")); + } + } + + result.put("status", true); + result.put("message", "Road war details saved successfully"); + result.put("ref_id", refId); + + } catch (Exception e) { + e.printStackTrace(); + result.put("status", false); + result.put("message", "Failed to save road war details: " + e.getMessage()); + } + return result; + } + + public List> getAllRoadWarDetails( + String userid, + String zone, + String ward, + String roadId) { + + StringBuilder sql = new StringBuilder( + " SELECT rdm.*,rtm.road_type as road_type_name,rtmm.roadtype_material as roadtype_material_name,ftm.footpath_type_name as footpath_material_name FROM road_details_master rdm " + + + " LEFT JOIN road_type_master rtm ON rtm.id= rdm.road_type " + + " LEFT JOIN roadtype_material_master rtmm ON rtmm.id= rdm.road_type_material " + + " LEFT JOIN footpath_type_master ftm ON ftm.id= rdm.footpath_material " + + " WHERE 1=1 "); + + List params = new ArrayList<>(); + + if (userid != null && !userid.isEmpty()) { + sql.append(" AND rdm.cby = ?"); + params.add(userid); + } + + if (zone != null && !zone.isEmpty()) { + sql.append(" AND rdm.zone = ?"); + params.add(zone); + } + + if (ward != null && !ward.isEmpty()) { + sql.append(" AND rdm.ward = ?"); + params.add(ward); + } + + if (roadId != null && !roadId.isEmpty()) { + sql.append(" AND rdm.road_id = ?"); + params.add(roadId); + } + + sql.append(" AND rdm.is_active=1 AND rdm.is_delete=0 "); + + sql.append(" ORDER BY rdm.id DESC"); + + return jdbcTemplate.queryForList(sql.toString(), params.toArray()); + } + + public Map getRoadWarDetailsById(String refid) { + + Map result = new HashMap<>(); + + try { + + String sql = "SELECT rdm.*, rtm.road_type As road_type_name,rtmm.roadtype_material as roadtype_material,ftm.footpath_type_name as footpath_material_name " + + + "FROM road_details_master rdm " + + "LEFT JOIN road_type_master rtm ON rtm.id = rdm.road_type " + + "LEFT JOIN roadtype_material_master rtmm ON rtmm.id = rdm.road_type_material " + + "LEFT JOIN footpath_type_master ftm ON ftm.id= rdm.footpath_material " + + "WHERE rdm.ref_id = ? AND rdm.is_active=1 AND rdm.is_delete=0 "; + + Map road = jdbcTemplate.queryForMap(sql, refid); + + result.putAll(road); + + List> relayingDetails = jdbcTemplate.queryForList( + " SELECT rd.*,mm.month_name,ym.year_name,rtmm.roadtype_material " + + " FROM relaying_details rd " + + " LEFT JOIN month_master mm on mm.id = rd.relay_month " + + " LEFT JOIN year_master ym on ym.id = rd.relay_year " + + " LEFT JOIN roadtype_material_master rtmm on rtmm.id = rd.road_type_material " + + " WHERE rd.road_ref_id = ? AND rd.is_active=1 AND rd.is_delete=0 ", + refid); + + result.put("relayingDetails", relayingDetails); + result.put("status", true); + + } catch (Exception e) { + + result.put("status", false); + result.put("message", e.getMessage()); + + } + + return result; + } + + public Map checkRoadExists(Integer roadId) { + + Map response = new HashMap<>(); + + try { + + String sql = " SELECT COUNT(*) FROM road_details_master " + + + " WHERE road_id = ? AND is_active=1 AND is_delete = 0 "; + + Integer count = jdbcTemplate.queryForObject( + sql, + Integer.class, + roadId); + + response.put("status", true); + response.put("exists", count != null && count > 0); + + } catch (Exception e) { + + e.printStackTrace(); + + response.put("status", false); + response.put("message", "Error while checking road"); + + } + + return response; + } + + @Transactional + public Map updateRoadWarDetails(Map payload) { + + Map result = new HashMap<>(); + + try { + + String refId = String.valueOf(payload.get("ref_id")); + String updatedBy = String.valueOf(payload.get("updated_by")); + + String roadId = String.valueOf(payload.get("road_id")); + + Integer count = jdbcTemplate.queryForObject( + "SELECT COUNT(*) " + + "FROM road_details_master " + + "WHERE road_id = ? " + + "AND ref_id <> ? " + + "AND is_active = 1 " + + "AND is_delete = 0", + Integer.class, + roadId, + refId); + + if (count != null && count > 0) { + + result.put("status", false); + result.put("message", + "Selected road is already mapped to another Road War record"); + + return result; + } + + // COPY CURRENT RECORD TO LOG TABLE + + String logSql = "INSERT INTO road_details_master_log (" + + "id, zone, ward, road_id, road_name,area_name,locality_name, road_type,road_type_material, highway_ans, " + + + "road_length,road_row_width, road_avg_width,road_min_width,road_max_width, road_area, " + + "road_from,road_to,is_footpath,footpath_at, " + + "footpath_material, footpath_length, footpath_width, " + + "r_footpath_material, r_footpath_length, r_footpath_width, " + + "footpath_from_location, footpath_to_location, " + + "swd_at,rhs_swdlength,rhs_swdsize,scp_at,rhs_scpCount,manhole_at,r_mhCount,cp_at,r_cpCount,rwh_at,r_rwCount, " + + + "is_swd, swd_from, swd_to, swd_length, swd_size, " + + "is_scp, scp_count, is_manhole, manhole_count, manhole_location, " + + "is_cpipe, cpipe_count, is_rwh, rwh_count, " + + "sewer_length, sewer_size, is_electric_poles, ep_count, is_hml,hml_count, " + + "is_streetlight_poles,streetlight_poles_count,is_mml,mml_count, " + + "culvert_bridge_count, details, is_busshelter, busshelter_count, " + + "is_centermedian, erp_asset_code, ref_id, cdate, cby, " + + "updated_date, updated_by, is_active, is_delete) " + + "SELECT " + + "id, zone, ward, road_id, road_name,area_name,locality_name, road_type,road_type_material, highway_ans, " + + + "road_length,road_row_width, road_avg_width,road_min_width,road_max_width, road_area, " + + "road_from,road_to,is_footpath,footpath_at, " + + "footpath_material, footpath_length, footpath_width, " + + "r_footpath_material, r_footpath_length, r_footpath_width, " + + "footpath_from_location, footpath_to_location, " + + "swd_at,rhs_swdlength,rhs_swdsize,scp_at,rhs_scpCount,manhole_at,r_mhCount,cp_at,r_cpCount,rwh_at,r_rwCount, " + + + "is_swd, swd_from, swd_to, swd_length, swd_size, " + + "is_scp, scp_count, is_manhole, manhole_count, manhole_location, " + + "is_cpipe, cpipe_count, is_rwh, rwh_count, " + + "sewer_length, sewer_size, is_electric_poles, ep_count, is_hml,hml_count, " + + "is_streetlight_poles,streetlight_poles_count,is_mml,mml_count, " + + "culvert_bridge_count, details, is_busshelter, busshelter_count, " + + "is_centermedian, erp_asset_code, ref_id, cdate, cby, " + + "updated_date, updated_by, is_active, is_delete " + + "FROM road_details_master " + + "WHERE ref_id=?"; + + jdbcTemplate.update(logSql, refId); + + // 3. UPDATE ROAD MASTER + + String updateSql = "UPDATE road_details_master SET " + + "zone=?, " + + "ward=?, " + + "road_id=?, " + + "road_name=?, " + + "area_name=?, " + + "locality_name=?, " + + "road_type=?, " + + "road_type_material=?, " + + "road_length=?, " + + "road_row_width=?, " + + "road_avg_width=?, " + + "road_min_width=?, " + + "road_max_width=?, " + + "road_area=?, " + + "road_from=?, " + + "road_to=?, " + + "is_footpath=?, " + + "footpath_at=?, " + + "footpath_material=?, " + + "footpath_length=?, " + + "footpath_width=?, " + + "r_footpath_material=?, " + + "r_footpath_length=?, " + + "r_footpath_width=?, " + + "footpath_from_location=?, " + + "footpath_to_location=?, " + + "is_swd=?, " + + "swd_from=?, " + + "swd_to=?, " + + "swd_at=?," + + "swd_length=?, " + + "swd_size=?, " + + "rhs_swdlength=?, " + + "rhs_swdsize=?, " + + "is_scp=?, " + + "scp_at=?, " + + "scp_count=?, " + + "rhs_scpCount=?," + + "is_manhole=?, " + + "manhole_count=?, " + + "manhole_at=?, " + + "r_mhCount=?, " + + "is_cpipe=?, " + + "cpipe_count=?, " + + "cp_at=?, " + + "r_cpCount=?, " + + "is_rwh=?, " + + "rwh_count=?, " + + "rwh_at=?, " + + "r_rwCount=?, " + + "sewer_length=?, " + + "sewer_size=?, " + + "is_electric_poles=?, " + + "ep_count=?, " + + "is_hml=?, " + + "hml_count=?, " + + "is_streetlight_poles=?, " + + "streetlight_poles_count=?, " + + "is_mml=?, " + + "mml_count=?, " + + "culvert_bridge_count=?, " + + "details=?, " + + "is_busshelter=?, " + + "busshelter_count=?, " + + "is_centermedian=?, " + + "updated_date=NOW(), " + + "updated_by=? " + + "WHERE ref_id=?"; + + jdbcTemplate.update(updateSql, + + payload.get("zone"), + payload.get("ward"), + payload.get("road_id"), + payload.get("road_name"), + payload.get("road_areaname"), + payload.get("road_localityname"), + payload.get("road_type"), + payload.get("road_type_material"), + + payload.get("road_length"), + payload.get("road_row_width"), + payload.get("road_avg_width"), + payload.get("road_min_width"), + payload.get("road_max_width"), + payload.get("road_area"), + payload.get("road_from"), + payload.get("road_to"), + + payload.get("is_footpath"), + payload.get("footpath_at"), + + payload.get("footpath_material"), + payload.get("footpath_length"), + payload.get("footpath_width"), + payload.get("rhs_footpathDropdown"), + payload.get("rhs_fplength"), + payload.get("rhs_fpwidth"), + + payload.get("footpath_from_location"), + payload.get("footpath_to_location"), + + payload.get("is_swd"), + payload.get("swd_from"), + payload.get("swd_to"), + payload.get("swd_at"), + payload.get("swd_length"), + payload.get("swd_size"), + payload.get("rhs_swdlength"), + payload.get("rhs_swdsize"), + + payload.get("is_scp"), + payload.get("scp_at"), + payload.get("scp_count"), + payload.get("rhs_scpCount"), + + payload.get("is_manhole"), + payload.get("manhole_count"), + payload.get("manhole_at"), + payload.get("r_mhCount"), + + payload.get("is_cpipe"), + payload.get("cpipe_count"), + payload.get("cp_at"), + payload.get("r_cpCount"), + + payload.get("is_rwh"), + payload.get("rwh_count"), + payload.get("rwh_at"), + payload.get("r_rwCount"), + + payload.get("sewer_length"), + payload.get("sewer_size"), + + payload.get("is_electric_poles"), + payload.get("ep_count"), + + payload.get("is_hml"), + payload.get("hml_count"), + payload.get("is_streetlight_poles"), + payload.get("streetlight_poles_count"), + payload.get("is_mml"), + payload.get("mml_count"), + + payload.get("culvert_bridge_count"), + payload.get("details"), + + payload.get("is_busshelter"), + payload.get("busshelter_count"), + + payload.get("is_centermedian"), + + updatedBy, + refId); + + // 4. SOFT DELETE OLD RELAYING RECORDS + + jdbcTemplate.update( + "UPDATE relaying_details " + + "SET is_active=0, " + + "is_delete=1, " + + "updated_date=NOW(), " + + "updated_by=? " + + "WHERE road_ref_id=? " + + "AND is_active=1", + updatedBy, + refId); + + // 5. INSERT NEW RELAYING RECORDS + + @SuppressWarnings("unchecked") + List> relays = (List>) payload.get("relaying_details"); + + String insertRelay = "INSERT INTO relaying_details " + + "(road_ref_id, relay_month, relay_year,road_type_material, cr_value, road_type, remarks, cby) " + + "VALUES (?,?,?,?,?,?,?,?)"; + + if (relays != null) { + + for (Map relay : relays) { + + jdbcTemplate.update( + insertRelay, + refId, + relay.get("relay_month"), + relay.get("relay_year"), + relay.get("road_type_material"), + relay.get("cr_value"), + relay.get("road_type"), + relay.get("remarks"), + updatedBy); + } + } + + result.put("status", true); + result.put("message", "Road details updated successfully"); + + } catch (Exception e) { + + e.printStackTrace(); + + result.put("status", false); + result.put("message", e.getMessage()); + } + + return result; + } + + public Map deleteRoadWarDetails(String refId, String updatedby) { + Map result = new HashMap<>(); + + try { + + int roadUpdated = jdbcTemplate.update( + "UPDATE road_details_master " + + "SET is_active=0, " + + "is_delete=1, " + + "updated_by=?, " + + "updated_date=NOW() " + + "WHERE ref_id=? " + + "AND is_active=1", + updatedby, refId); + + jdbcTemplate.update( + "UPDATE relaying_details " + + "SET is_active=0, " + + "is_delete=1, " + + "updated_by=?, " + + "updated_date=NOW() " + + "WHERE road_ref_id=? " + + "AND is_active=1", + updatedby, refId); + + if (roadUpdated > 0) { + + result.put("status", true); + result.put("message", + "Road War details deleted successfully"); + + } else { + + result.put("status", false); + result.put("message", "Record not found"); + } + + } catch (Exception e) { + + e.printStackTrace(); + + result.put("status", false); + result.put("message", + "Failed to delete Road War details"); + } + + return result; + } + +} diff --git a/src/main/java/in/gov/chennaicorporation/gccoffice/vendor/controller/MainController.java b/src/main/java/in/gov/chennaicorporation/gccoffice/vendor/controller/MainController.java index 704d414..98e83ac 100644 --- a/src/main/java/in/gov/chennaicorporation/gccoffice/vendor/controller/MainController.java +++ b/src/main/java/in/gov/chennaicorporation/gccoffice/vendor/controller/MainController.java @@ -195,5 +195,22 @@ public class MainController { } + @GetMapping("/certificate") + public String viewcertificate(Model model) + { + String LoginUserId = LoginUserInfo.getLoginUserId(); + int userId = Integer.parseInt(LoginUserId); + model.addAttribute("LoginUserId",LoginUserId); + + String zone=streetVendorService.getloginUserZone(userId); + model.addAttribute("zone",zone); + //System.out.println("zone="+zone); + + String UserRole = LoginUserInfo.getUserRole(); + model.addAttribute("UserRole", UserRole); + + return "modules/vendors/certificate"; + } + } diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 376e518..2f562e6 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -119,4 +119,6 @@ street_vendor_foldername=street_vendor_files green_committee_foldername=green_committee_files -socialmedia_1913_regcomp_foldername=socialmedia_1913_regcompfiles \ No newline at end of file +socialmedia_1913_regcomp_foldername=socialmedia_1913_regcompfiles + +bulk_waste_foldername=bulk_waste_files \ No newline at end of file diff --git a/src/main/resources/templates/modules/bulkwaste/requestdetails.html b/src/main/resources/templates/modules/bulkwaste/requestdetails.html new file mode 100644 index 0000000..4a6c69c --- /dev/null +++ b/src/main/resources/templates/modules/bulkwaste/requestdetails.html @@ -0,0 +1,3007 @@ + + + + + + + + +
+ +
+ + +
+ +
+ +
+
+ + +
+
+
+
+ +
+
+ + +
+
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + + + + +
+ + +
+ +
+ + + + + + + + + + + + + + + + + + + + + +
S.NoDateName of EstablishmentPerson NameCategoryMobile NumberZoneWardAction
+
+ +
+
+ +
+
+ +
+
+
+ + + +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/templates/modules/callcenterqaqc/agentqaqccalls.html b/src/main/resources/templates/modules/callcenterqaqc/agentqaqccalls.html index ffb241a..f77d8e7 100644 --- a/src/main/resources/templates/modules/callcenterqaqc/agentqaqccalls.html +++ b/src/main/resources/templates/modules/callcenterqaqc/agentqaqccalls.html @@ -780,17 +780,9 @@ //console.log("valid phone number"); $('.submitid').prop('disabled', false).text('Submit'); // Trigger WhatsApp message functions based on action -// if (action === "UNATTENDED") { - //sendWhatsAppMessageUnattended(name, complaintNumber, cellnumber, complaintTypeName); -// } else if (action === "REOPEN") { - //sendWhatsAppMessageReopened(name, complaintNumber, cellnumber, complaintTypeName); -// } - - - - if (action === "UNATTENDED" || action === "COMPLETED" ) { - - //checkforUnattendedwhatsappmsg(complaintNumber,action,complaintTypeName,cellnumber,name); + + if (action === "UNATTENDED" || action === "COMPLETED" ) { + checkforUnattendedwhatsappmsg(complaintNumber,action,complaintTypeName,cellnumber,name); } } @@ -1035,13 +1027,16 @@ return detailsHtml; //checkforwhatsappmsg function checkforUnattendedwhatsappmsg(complaintNumber,action,complaintTypeName,cellnumber,name) { + + + console.log(complaintNumber); $.ajax({ url: '/gcc/api/qaqc/whatsapp/checkforwhatsappmsg', type: 'GET', data: { complaintNumber: complaintNumber,action:action, complaintTypeName:complaintTypeName,mobnumber:cellnumber, - name:pname}, + pname:name}, success: function(response) { //console.log('WhatsApp message sent successfully', response); console.log(response); diff --git a/src/main/resources/templates/modules/childrensurvey/childlist.html b/src/main/resources/templates/modules/childrensurvey/childlist.html index 94122e6..9617f94 100644 --- a/src/main/resources/templates/modules/childrensurvey/childlist.html +++ b/src/main/resources/templates/modules/childrensurvey/childlist.html @@ -1058,7 +1058,10 @@ tbody += ` - ${formatDate(row.survey_date)} + + + ${formatDate(row.survey_date)} + ${row.survey_id || ''} ${row.child_name || ''} diff --git a/src/main/resources/templates/modules/childrensurvey/nonchildlist.html b/src/main/resources/templates/modules/childrensurvey/nonchildlist.html index e5a038d..46bada3 100644 --- a/src/main/resources/templates/modules/childrensurvey/nonchildlist.html +++ b/src/main/resources/templates/modules/childrensurvey/nonchildlist.html @@ -827,7 +827,10 @@ tbody += ` - ${formatDate(row.survey_date)} + + + ${formatDate(row.survey_date)} + ${row.survey_id || ''} diff --git a/src/main/resources/templates/modules/childrensurvey/surveylist.html b/src/main/resources/templates/modules/childrensurvey/surveylist.html index 7c2c175..e00fa22 100644 --- a/src/main/resources/templates/modules/childrensurvey/surveylist.html +++ b/src/main/resources/templates/modules/childrensurvey/surveylist.html @@ -792,7 +792,10 @@ // ${item.survey_date || ''} rows += ` - ${formatDate(item.survey_date)} + + + ${formatDate(item.survey_date)} + ${item.user_name || ''} ${item.mobile_no || ''} diff --git a/src/main/resources/templates/modules/greencommittee/monitoring.html b/src/main/resources/templates/modules/greencommittee/monitoring.html index dec6723..4972af2 100644 --- a/src/main/resources/templates/modules/greencommittee/monitoring.html +++ b/src/main/resources/templates/modules/greencommittee/monitoring.html @@ -407,7 +407,7 @@ function fetchgreenCommitteeList(){ renderDetails(details); - $('#viewModalLabel').text(`Apploication Details - ${id}`); + $('#viewModalLabel').text(`Application Details - ${id}`); $('#viewModal').modal('show'); }, error: function (xhr) { diff --git a/src/main/resources/templates/modules/greencommittee/pendinglist.html b/src/main/resources/templates/modules/greencommittee/pendinglist.html index d5aab49..88a6326 100644 --- a/src/main/resources/templates/modules/greencommittee/pendinglist.html +++ b/src/main/resources/templates/modules/greencommittee/pendinglist.html @@ -1,218 +1,232 @@ + - - - - -
- -
- - -
- -
- -
-
- -
- -
- -
-
-
-
-
- - -
- -
- - -
-
-
-
Green Committee Pending List

-
- -
- - - - - - - - - - - - - - - - - - - - - - - - - -
S.NoApplication NoZoneWardTypeNameMobileAddressRemarksNo of treesDetails of ComplaintsAction
-
-
-
-
- -
- - -
+ + + + + +
+ +
+ + +
+ +
+ +
+
+ +
+ +
+ +
+
+
+
+
+ + +
+ +
+ + +
+
+
+
Green Committee Pending List
+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
S.NoApplication NoZoneWardTypeNameMobileAddressRemarksNo of treesDetails of ComplaintsAction
+
+
+
+
+ +
+ +
- - - - - - - +
+ + + + + + + + + + + + +
+
+ +
+ + +
+ + + + + + - - - - - + + + + \ No newline at end of file diff --git a/src/main/resources/templates/modules/greencommittee/reports.html b/src/main/resources/templates/modules/greencommittee/reports.html index 32856bd..2006643 100644 --- a/src/main/resources/templates/modules/greencommittee/reports.html +++ b/src/main/resources/templates/modules/greencommittee/reports.html @@ -1,146 +1,170 @@ + - - - - -
- -
- - -
- -
- -
-
- -
- -
-
-
- -
-
-
- - -
- -
- - -
-
-
-
Green Committee Reports

-
- -
- - - - - - - - - - - - - - - - - - - - - - -
S.NoApplication NoNameAddressReasonNo of treesInspectedCommittee Decision
TNFDGCCNGO
-
-
-
-
-
- - -
+ + + + + +
+ +
+ + +
+ +
+ +
+
+ +
+ +
+
+
+ +
+
+
+ + +
+ +
+ + +
+
+ + +
+
+ + +
+ +
+
+
Green Committee Reports
+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
S.NoApplication NoDepartment NameNameAddressReasonNo of treesInspectedCommittee Decision
TNFDGCCNGO
+
+
+
+
+
+ + +
+
+ + + - -
- - -
- - - - - - + + + + - + + + + \ No newline at end of file diff --git a/src/main/resources/templates/modules/greencommittee/treepruningreports.html b/src/main/resources/templates/modules/greencommittee/treepruningreports.html new file mode 100644 index 0000000..6c02881 --- /dev/null +++ b/src/main/resources/templates/modules/greencommittee/treepruningreports.html @@ -0,0 +1,1136 @@ + + + + + + + + + + + +
+ +
+ + +
+ +
+ +
+
+ +
+ +
+
+
+ +
+
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ +
+ + + + +
+ + +
+ + +
+ + +
+ + + +
+ +
+ +
+ +
+
+
Green Committee Reports
+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
S.NoComplaint NoPerson NameZone / WardAddressModeOpened DateStatusAction
+
+
+
+
+
+ + +
+
+ + + + + + + +
+
+ +
+ + +
+ + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/templates/modules/homelesssurvey/aadhar.html b/src/main/resources/templates/modules/homelesssurvey/aadhar.html new file mode 100644 index 0000000..549bc2c --- /dev/null +++ b/src/main/resources/templates/modules/homelesssurvey/aadhar.html @@ -0,0 +1,576 @@ + + + + + + + + + +
+
+ +
+
+
+
+ + + +
+ +
+ + + + + + + + + + + + + + + + +
SlnoAadhar No ReasonStatusDeleteEdit
+ +
+ + + + + + + + +
+
+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/templates/modules/homelesssurvey/bankpassbook.html b/src/main/resources/templates/modules/homelesssurvey/bankpassbook.html new file mode 100644 index 0000000..e1a59ca --- /dev/null +++ b/src/main/resources/templates/modules/homelesssurvey/bankpassbook.html @@ -0,0 +1,576 @@ + + + + + + + + + +
+
+ +
+
+
+
+ + + +
+ +
+ + + + + + + + + + + + + + + + +
SlnoBank Passbook No Reason NameStatusDeleteEdit
+ +
+ + + + + + + + +
+
+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/templates/modules/homelesssurvey/birthcertficatenoreason.html b/src/main/resources/templates/modules/homelesssurvey/birthcertficatenoreason.html new file mode 100644 index 0000000..c71abc9 --- /dev/null +++ b/src/main/resources/templates/modules/homelesssurvey/birthcertficatenoreason.html @@ -0,0 +1,576 @@ + + + + + + + + + +
+
+ +
+
+
+
+ + + +
+ +
+ + + + + + + + + + + + + + + + +
SlnoBirth Certificate no ReasonStatusDeleteEdit
+ +
+ + + + + + + + +
+
+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/templates/modules/homelesssurvey/caste.html b/src/main/resources/templates/modules/homelesssurvey/caste.html new file mode 100644 index 0000000..20ff158 --- /dev/null +++ b/src/main/resources/templates/modules/homelesssurvey/caste.html @@ -0,0 +1,576 @@ + + + + + + + + + +
+
+ +
+
+
+
+ + + +
+ +
+ + + + + + + + + + + + + + + + +
SlnoCaste NameStatusDeleteEdit
+ +
+ + + + + + + + +
+
+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/templates/modules/homelesssurvey/cminsurance.html b/src/main/resources/templates/modules/homelesssurvey/cminsurance.html new file mode 100644 index 0000000..8dfdb33 --- /dev/null +++ b/src/main/resources/templates/modules/homelesssurvey/cminsurance.html @@ -0,0 +1,576 @@ + + + + + + + + + +
+
+ +
+
+
+
+ + + +
+ +
+ + + + + + + + + + + + + + + + +
SlnoCM Insurance No ReasonStatusDeleteEdit
+ +
+ + + + + + + + +
+
+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/templates/modules/homelesssurvey/comeoutshelter.html b/src/main/resources/templates/modules/homelesssurvey/comeoutshelter.html new file mode 100644 index 0000000..ffbe2ba --- /dev/null +++ b/src/main/resources/templates/modules/homelesssurvey/comeoutshelter.html @@ -0,0 +1,576 @@ + + + + + + + + + +
+
+ +
+
+
+
+ + + +
+ +
+ + + + + + + + + + + + + + + + +
SlnoComing Out of ShelterStatusDeleteEdit
+ +
+ + + + + + + + +
+
+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/templates/modules/homelesssurvey/communitynoreason.html b/src/main/resources/templates/modules/homelesssurvey/communitynoreason.html new file mode 100644 index 0000000..bc05c33 --- /dev/null +++ b/src/main/resources/templates/modules/homelesssurvey/communitynoreason.html @@ -0,0 +1,576 @@ + + + + + + + + + +
+
+ +
+
+
+
+ + + +
+ +
+ + + + + + + + + + + + + + + + +
SlnoCommunity No Reason NameStatusDeleteEdit
+ +
+ + + + + + + + +
+
+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/templates/modules/homelesssurvey/currentlyliving.html b/src/main/resources/templates/modules/homelesssurvey/currentlyliving.html new file mode 100644 index 0000000..fc1a63a --- /dev/null +++ b/src/main/resources/templates/modules/homelesssurvey/currentlyliving.html @@ -0,0 +1,576 @@ + + + + + + + + + +
+
+ +
+
+
+
+ + + +
+ +
+ + + + + + + + + + + + + + + + +
SlnoCurrently Living NameStatusDeleteEdit
+ +
+ + + + + + + + +
+
+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/templates/modules/homelesssurvey/disability.html b/src/main/resources/templates/modules/homelesssurvey/disability.html new file mode 100644 index 0000000..2fe1248 --- /dev/null +++ b/src/main/resources/templates/modules/homelesssurvey/disability.html @@ -0,0 +1,576 @@ + + + + + + + + + +
+
+ +
+
+
+
+ + + +
+ +
+ + + + + + + + + + + + + + + + +
SlnoDisablity TypeStatusDeleteEdit
+ +
+ + + + + + + + +
+
+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/templates/modules/homelesssurvey/disabiltycertificate.html b/src/main/resources/templates/modules/homelesssurvey/disabiltycertificate.html new file mode 100644 index 0000000..3d01ec3 --- /dev/null +++ b/src/main/resources/templates/modules/homelesssurvey/disabiltycertificate.html @@ -0,0 +1,576 @@ + + + + + + + + + +
+
+ +
+
+
+
+ + + +
+ +
+ + + + + + + + + + + + + + + + +
SlnoDisabilty Certificate NameStatusDeleteEdit
+ +
+ + + + + + + + +
+
+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/templates/modules/homelesssurvey/discontinued.html b/src/main/resources/templates/modules/homelesssurvey/discontinued.html new file mode 100644 index 0000000..46856b2 --- /dev/null +++ b/src/main/resources/templates/modules/homelesssurvey/discontinued.html @@ -0,0 +1,576 @@ + + + + + + + + + +
+
+ +
+
+
+
+ + + +
+ +
+ + + + + + + + + + + + + + + + +
SlnoDiscontinued ReasonStatusDeleteEdit
+ +
+ + + + + + + + +
+
+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/templates/modules/homelesssurvey/driver.html b/src/main/resources/templates/modules/homelesssurvey/driver.html new file mode 100644 index 0000000..eb2d3b1 --- /dev/null +++ b/src/main/resources/templates/modules/homelesssurvey/driver.html @@ -0,0 +1,576 @@ + + + + + + + + + +
+
+ +
+
+
+
+ + + +
+ +
+ + + + + + + + + + + + + + + + +
SlnoDriver License No ReasonStatusDeleteEdit
+ +
+ + + + + + + + +
+
+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/templates/modules/homelesssurvey/education.html b/src/main/resources/templates/modules/homelesssurvey/education.html new file mode 100644 index 0000000..8601ff1 --- /dev/null +++ b/src/main/resources/templates/modules/homelesssurvey/education.html @@ -0,0 +1,576 @@ + + + + + + + + + +
+
+ +
+
+
+
+ + + +
+ +
+ + + + + + + + + + + + + + + + +
SlnoEducation NameStatusDeleteEdit
+ +
+ + + + + + + + +
+
+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/templates/modules/homelesssurvey/employmenttype.html b/src/main/resources/templates/modules/homelesssurvey/employmenttype.html new file mode 100644 index 0000000..dec98d3 --- /dev/null +++ b/src/main/resources/templates/modules/homelesssurvey/employmenttype.html @@ -0,0 +1,576 @@ + + + + + + + + + +
+
+ +
+
+
+
+ + + +
+ +
+ + + + + + + + + + + + + + + + +
SlnoEmployment TypeStatusDeleteEdit
+ +
+ + + + + + + + +
+
+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/templates/modules/homelesssurvey/gccshelter.html b/src/main/resources/templates/modules/homelesssurvey/gccshelter.html new file mode 100644 index 0000000..1997385 --- /dev/null +++ b/src/main/resources/templates/modules/homelesssurvey/gccshelter.html @@ -0,0 +1,576 @@ + + + + + + + + + +
+
+ +
+
+
+
+ + + +
+ +
+ + + + + + + + + + + + + + + + +
SlnoGCCShelter Not Stayed NameStatusDeleteEdit
+ +
+ + + + + + + + +
+
+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/templates/modules/homelesssurvey/gendermaster.html b/src/main/resources/templates/modules/homelesssurvey/gendermaster.html new file mode 100644 index 0000000..b9964d8 --- /dev/null +++ b/src/main/resources/templates/modules/homelesssurvey/gendermaster.html @@ -0,0 +1,576 @@ + + + + + + + + + +
+
+ +
+
+
+
+ + + +
+ +
+ + + + + + + + + + + + + + + + +
SlnoGender NameStatusDeleteEdit
+ +
+ + + + + + + + +
+
+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/templates/modules/homelesssurvey/healthcondition.html b/src/main/resources/templates/modules/homelesssurvey/healthcondition.html new file mode 100644 index 0000000..e60aa67 --- /dev/null +++ b/src/main/resources/templates/modules/homelesssurvey/healthcondition.html @@ -0,0 +1,576 @@ + + + + + + + + + +
+
+ +
+
+
+
+ + + +
+ +
+ + + + + + + + + + + + + + + + +
SlnoHealth Condition NameStatusDeleteEdit
+ +
+ + + + + + + + +
+
+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/templates/modules/homelesssurvey/homelesslist.html b/src/main/resources/templates/modules/homelesssurvey/homelesslist.html new file mode 100644 index 0000000..8eadaed --- /dev/null +++ b/src/main/resources/templates/modules/homelesssurvey/homelesslist.html @@ -0,0 +1,2085 @@ + + + + + + + + + +
+
+ +
+
+
+
+ + + +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + + +
+ +
+ + +
+ +
+ +
+ + + +
+ + + + + + + + + + + + + + + + + + +
DateSurvey IDNameGenderZoneWardAction
+
+ +
+ + +
+
+ +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/templates/modules/homelesssurvey/homelessreason.html b/src/main/resources/templates/modules/homelesssurvey/homelessreason.html new file mode 100644 index 0000000..8da2b58 --- /dev/null +++ b/src/main/resources/templates/modules/homelesssurvey/homelessreason.html @@ -0,0 +1,576 @@ + + + + + + + + + +
+
+ +
+
+
+
+ + + +
+ +
+ + + + + + + + + + + + + + + + +
SlnoHomeless Reason NameStatusDeleteEdit
+ +
+ + + + + + + + +
+
+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/templates/modules/homelesssurvey/martial.html b/src/main/resources/templates/modules/homelesssurvey/martial.html new file mode 100644 index 0000000..f75e245 --- /dev/null +++ b/src/main/resources/templates/modules/homelesssurvey/martial.html @@ -0,0 +1,576 @@ + + + + + + + + + +
+
+ +
+
+
+
+ + + +
+ +
+ + + + + + + + + + + + + + + + +
SlnoMartial Status NameStatusDeleteEdit
+ +
+ + + + + + + + +
+
+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/templates/modules/homelesssurvey/movingreason.html b/src/main/resources/templates/modules/homelesssurvey/movingreason.html new file mode 100644 index 0000000..89f961a --- /dev/null +++ b/src/main/resources/templates/modules/homelesssurvey/movingreason.html @@ -0,0 +1,576 @@ + + + + + + + + + +
+
+ +
+
+
+
+ + + +
+ +
+ + + + + + + + + + + + + + + + +
SlnoMoving ReasonStatusDeleteEdit
+ +
+ + + + + + + + +
+
+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/templates/modules/homelesssurvey/nonsurveyedhomelist.html b/src/main/resources/templates/modules/homelesssurvey/nonsurveyedhomelist.html new file mode 100644 index 0000000..1e7eb7a --- /dev/null +++ b/src/main/resources/templates/modules/homelesssurvey/nonsurveyedhomelist.html @@ -0,0 +1,1007 @@ + + + + + + + + + +
+
+ +
+
+
+
+ + + +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + + +
+ +
+ + +
+ +
+ +
+ + + +
+ + + + + + + + + + + + + + + + + + + + +
DateSurvey IDNameAgeDOBZoneWardPhotoRemarks
+
+ +
+ + +
+
+ +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/templates/modules/homelesssurvey/notemployed.html b/src/main/resources/templates/modules/homelesssurvey/notemployed.html new file mode 100644 index 0000000..8126ae7 --- /dev/null +++ b/src/main/resources/templates/modules/homelesssurvey/notemployed.html @@ -0,0 +1,576 @@ + + + + + + + + + +
+
+ +
+
+
+
+ + + +
+ +
+ + + + + + + + + + + + + + + + +
SlnoNot Employed Reason NameStatusDeleteEdit
+ +
+ + + + + + + + +
+
+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/templates/modules/homelesssurvey/occupation.html b/src/main/resources/templates/modules/homelesssurvey/occupation.html new file mode 100644 index 0000000..b93a864 --- /dev/null +++ b/src/main/resources/templates/modules/homelesssurvey/occupation.html @@ -0,0 +1,576 @@ + + + + + + + + + +
+
+ +
+
+
+
+ + + +
+ +
+ + + + + + + + + + + + + + + + +
SlnoOccupation NameStatusDeleteEdit
+ +
+ + + + + + + + +
+
+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/templates/modules/homelesssurvey/relationtype.html b/src/main/resources/templates/modules/homelesssurvey/relationtype.html new file mode 100644 index 0000000..0383ed5 --- /dev/null +++ b/src/main/resources/templates/modules/homelesssurvey/relationtype.html @@ -0,0 +1,576 @@ + + + + + + + + + +
+
+ +
+
+
+
+ + + +
+ +
+ + + + + + + + + + + + + + + + +
SlnoRelation Type NameStatusDeleteEdit
+ +
+ + + + + + + + +
+
+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/templates/modules/homelesssurvey/religion.html b/src/main/resources/templates/modules/homelesssurvey/religion.html new file mode 100644 index 0000000..59a0ab1 --- /dev/null +++ b/src/main/resources/templates/modules/homelesssurvey/religion.html @@ -0,0 +1,576 @@ + + + + + + + + + +
+
+ +
+
+
+
+ + + +
+ +
+ + + + + + + + + + + + + + + + +
SlnoReligion NameStatusDeleteEdit
+ +
+ + + + + + + + +
+
+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/templates/modules/homelesssurvey/sleepingspace.html b/src/main/resources/templates/modules/homelesssurvey/sleepingspace.html new file mode 100644 index 0000000..62b47aa --- /dev/null +++ b/src/main/resources/templates/modules/homelesssurvey/sleepingspace.html @@ -0,0 +1,576 @@ + + + + + + + + + +
+
+ +
+
+
+
+ + + +
+ +
+ + + + + + + + + + + + + + + + +
SlnoSleeping SpaceStatusDeleteEdit
+ +
+ + + + + + + + +
+
+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/templates/modules/homelesssurvey/smart.html b/src/main/resources/templates/modules/homelesssurvey/smart.html new file mode 100644 index 0000000..ec2df2b --- /dev/null +++ b/src/main/resources/templates/modules/homelesssurvey/smart.html @@ -0,0 +1,576 @@ + + + + + + + + + +
+
+ +
+
+
+
+ + + +
+ +
+ + + + + + + + + + + + + + + + +
SlnoSmart Card No ReasonStatusDeleteEdit
+ +
+ + + + + + + + +
+
+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/templates/modules/homelesssurvey/surveyorlist.html b/src/main/resources/templates/modules/homelesssurvey/surveyorlist.html new file mode 100644 index 0000000..e1db238 --- /dev/null +++ b/src/main/resources/templates/modules/homelesssurvey/surveyorlist.html @@ -0,0 +1,1257 @@ + + + + + + + + + +
+
+ +
+
+
+
+ + + +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + + +
+ +
+ + +
+ +
+ + + + + + + + + + + + + + + + + + +
DateSurveyor NameMobile NumberZoneWardTotal Survey DoneAction
+
+ +
+ + + + + + +
+
+ +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/templates/modules/homelesssurvey/surveyorsreports.html b/src/main/resources/templates/modules/homelesssurvey/surveyorsreports.html new file mode 100644 index 0000000..f71ade9 --- /dev/null +++ b/src/main/resources/templates/modules/homelesssurvey/surveyorsreports.html @@ -0,0 +1,1012 @@ + + + + + + + + + + + + + + + + + +
+
+ +
+
+
+
+ + + + + + +
+ + +
+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/templates/modules/homelesssurvey/voterid.html b/src/main/resources/templates/modules/homelesssurvey/voterid.html new file mode 100644 index 0000000..fdd788e --- /dev/null +++ b/src/main/resources/templates/modules/homelesssurvey/voterid.html @@ -0,0 +1,576 @@ + + + + + + + + + +
+
+ +
+
+
+
+ + + +
+ +
+ + + + + + + + + + + + + + + + +
SlnoVoterId No ReasonStatusDeleteEdit
+ +
+ + + + + + + + +
+
+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/templates/modules/roadwar/regform.html b/src/main/resources/templates/modules/roadwar/regform.html new file mode 100644 index 0000000..7770d62 --- /dev/null +++ b/src/main/resources/templates/modules/roadwar/regform.html @@ -0,0 +1,2427 @@ + + + + + + + + + + + +
+ +
+ + +
+ +
+ +
+
+ + +
+
+
+
+
Road Details
+ + + + +
+ +
+ + + + +
+ + +
+ +
+ + +
+ + +
+ + + +
+ + +
+ + +
+ +
+ + +
+ + +
+ + + +
+ +
+ + + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ + +
+ + +
+ +
+ + +
+ +
+ +
+
+ + +
+ +
+ + +
+
+ +
+ +
+ + +
+ + + +
+ +
+
+ + + + + + + +
+ + + +
+ + +
SWD Details
+
+ +
+
+ + +
+ + + +
+
+ + + + + + + +
+
+ +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + + +
+ +
+ + +
+ +
+ + + + +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ +
+ + + + + +
+
+
Relaying Details
+
+ +
+
+ +
+ + +
+ +
+ + +
+ + +
+ + +
+ +
+ + +
+ +
+ + +
+ + +
+ + +
+ +
+ +
+ +
+
+ +
+ +
+ +
+ +
+ + + +
+ +
+
+
+ + + +
+
+ +
+ + + + +
+
+ +
+ + + + +
+ + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/templates/modules/roadwar/updateform.html b/src/main/resources/templates/modules/roadwar/updateform.html new file mode 100644 index 0000000..5ce1f24 --- /dev/null +++ b/src/main/resources/templates/modules/roadwar/updateform.html @@ -0,0 +1,3543 @@ + + + + + + + + + + +
+ +
+ +
+ +
+ + + +
+
+ + +
+
+
+
+ Filters + +
+
+
+ +
+ + +
+ +
+ + +
+ + +
+ + + +
+ + +
+ + + + +
+ + +
+
+
+
+ +
+
+
+ Road war List +
+
+
+ + + + + + + + + + + + + + + + + + + + + +
S.NoZoneWardRoad NameRoad TypeRoad Length(m)Road Average Width(m)Area(m2)UpdateDelete
+
+
+
+
+ +
+
+ +
+ + + + + + +
+ +
+ +
+ + + + + + + + +
+ + + + + + + + + + + diff --git a/src/main/resources/templates/modules/vendors/certificate.html b/src/main/resources/templates/modules/vendors/certificate.html new file mode 100644 index 0000000..16eaaee --- /dev/null +++ b/src/main/resources/templates/modules/vendors/certificate.html @@ -0,0 +1,764 @@ + + + + + + + + + +
+ +
+ + +
+ +
+ +
+
+ +
+ +
+ + +
+
+
+ Filters +
+
+
+ +
+ + +
+ + + + +
+ + +
+ +
+ + +
+ + + +
+ +
+
+ + + +
+
+ +
+ +
+
+
Vendors(ID card) Approved List
+
+
+ + + + + + + + + + + + + + + + + + +
S.NoRequest NoZoneWardPublic NameMobileID StatusView Details
+ +
+
+
+ + +
+
+ +
+ + + + + + + + + + + +
+
+ +
+ + +
+ + + + + + + + + + + + \ No newline at end of file