You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

104 lines
2.7 KiB

3 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. package in.gov.chennaicorporation.gccoffice.pgr.service;
  2. import java.sql.Connection;
  3. import java.sql.PreparedStatement;
  4. import java.sql.ResultSet;
  5. import java.sql.ResultSetMetaData;
  6. import java.sql.SQLException;
  7. import java.sql.Statement;
  8. import java.util.ArrayList;
  9. import java.util.HashMap;
  10. import java.util.List;
  11. import java.util.Map;
  12. import org.springframework.beans.factory.annotation.Autowired;
  13. import org.springframework.stereotype.Service;
  14. import in.gov.chennaicorporation.gccoffice.pgr.dbconnection.DBConnection;
  15. @Service
  16. public class ReopenZonewiseComplaintDetails {
  17. @Autowired
  18. DBConnection dbcon;
  19. public String sFrDate ="";
  20. public String sToDate ="";
  21. public String getreopenzonecomdetailsQuery(String lCmpID) {
  22. Connection connection = DBConnection.getConnection();; // Initialize your database connection
  23. System.out.println("ICmpID.............:"+lCmpID);
  24. String query = "select a.*,nvl(to_char(a.complaintdate,'dd-mm-rrrr'),' ') compdate,c.DEPT_NAME from eggr_complaintdetails@erp a,EG_DEPARTMENT@ERP c where a.deptid=c.id_dept and a.complaintid="+ lCmpID;
  25. System.out.println(query);
  26. try {
  27. PreparedStatement preparedStatement = connection.prepareStatement(query);
  28. preparedStatement.setString(1, lCmpID); // Bind the parameter
  29. ResultSet resultSet = preparedStatement.executeQuery();
  30. // Process the result set and return the result
  31. resultSet.close();
  32. preparedStatement.close();
  33. } catch (SQLException e) {
  34. // Handle any SQL errors
  35. e.printStackTrace();
  36. } finally {
  37. // Close the database connection
  38. }
  39. return query;
  40. }
  41. public List<Map<String, Object>> check(String lCmpID) {
  42. Connection con =DBConnection.getConnection();
  43. Statement stmt3;
  44. try {
  45. stmt3 = con.createStatement();
  46. System.out.println( "checkingreopenzonewisecomplaintdetails...");
  47. ResultSet rs3 = stmt3.executeQuery(getreopenzonecomdetailsQuery(lCmpID));
  48. List<Map<String, Object>> rows = new ArrayList<>();
  49. while (rs3.next()) {
  50. Map<String, Object> row = new HashMap<>();
  51. ResultSetMetaData metaData = rs3.getMetaData();
  52. int columnCount = metaData.getColumnCount();
  53. for (int i = 1; i <= columnCount; i++) {
  54. String columnName = metaData.getColumnName(i);
  55. Object columnValue = rs3.getObject(i);
  56. //System.out.println(columnName+" :"+columnValue);
  57. if (columnValue instanceof String) {
  58. columnValue = HtmlEntityDecoder.convertHtmlEntitiesToUtf8((String) columnValue);
  59. }
  60. row.put(columnName, columnValue);
  61. }
  62. rows.add(row);
  63. }
  64. return rows;
  65. }
  66. catch (Exception e){
  67. e.printStackTrace();
  68. }
  69. return null;
  70. }
  71. }