7 changed files with 3830 additions and 7 deletions
-
244gcc_officer_portal/src/main/java/in/gov/chennaicorporation/gccoffice/bulkwaste/Controller/APIController.java
-
38gcc_officer_portal/src/main/java/in/gov/chennaicorporation/gccoffice/bulkwaste/Controller/MainController.java
-
65gcc_officer_portal/src/main/java/in/gov/chennaicorporation/gccoffice/bulkwaste/Service/BulkMasterService.java
-
456gcc_officer_portal/src/main/java/in/gov/chennaicorporation/gccoffice/bulkwaste/Service/BulkWasteService.java
-
19gcc_officer_portal/src/main/java/in/gov/chennaicorporation/gccoffice/configuration/DataSourceConfig.java
-
8gcc_officer_portal/src/main/resources/application.properties
-
3007gcc_officer_portal/src/main/resources/templates/modules/bulkwaste/requestdetails.html
@ -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<Map<String, Object>> getWards( |
|||
@RequestParam String zoneName) { |
|||
|
|||
return masterService.getWards(zoneName); |
|||
} |
|||
|
|||
@GetMapping("/getBulkWasteRequestDetails") |
|||
public List<Map<String, Object>> 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<String, Object> 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<Map<String, Object>> 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<Map<String, Object>> 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 " |
|||
)); |
|||
} |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
} |
|||
@ -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"; |
|||
} |
|||
|
|||
} |
|||
@ -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<Map<String, Object>> 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<Map<String, Object>> getZones() { |
|||
|
|||
String sqlQuery = |
|||
"SELECT * FROM zones " + |
|||
"WHERE is_active = 1 AND is_delete = 0"; |
|||
|
|||
return jdbcTemplate.queryForList(sqlQuery); |
|||
} |
|||
|
|||
@Transactional(readOnly = true) |
|||
public List<Map<String, Object>> getWards(String zoneName) { |
|||
|
|||
String sqlQuery = |
|||
"SELECT * " + |
|||
"FROM wards " + |
|||
"WHERE is_active = 1 " + |
|||
"AND is_delete = 0 " + |
|||
"AND zone_name = ?"; |
|||
|
|||
return jdbcTemplate.queryForList(sqlQuery, zoneName); |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
} |
|||
@ -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<Map<String, Object>> 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<Object> params = new ArrayList<>(); |
|||
List<String> 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<String, Object> 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"; |
|||
} |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
} |
|||
3007
gcc_officer_portal/src/main/resources/templates/modules/bulkwaste/requestdetails.html
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
Write
Preview
Loading…
Cancel
Save
Reference in new issue