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.

114 lines
3.6 KiB

3 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. package in.gov.chennaicorporation.gccoffice.pgr.service;
  2. import java.sql.Connection;
  3. import java.sql.ResultSet;
  4. import java.sql.ResultSetMetaData;
  5. import java.sql.Statement;
  6. import java.util.ArrayList;
  7. import java.util.HashMap;
  8. import java.util.List;
  9. import java.util.Map;
  10. import org.springframework.beans.factory.annotation.Autowired;
  11. import org.springframework.stereotype.Service;
  12. import in.gov.chennaicorporation.gccoffice.pgr.dbconnection.DBConnection;
  13. @Service
  14. public class QaQcReports {
  15. @Autowired
  16. DBConnection dbcon;
  17. public String getqaqcQuery(String sFrDate, String sToDate) {
  18. String sQry= " select cd.COMPLAINTNUMBER,dep.DEPT_NAME,ct.COMPLAINTTYPENAME,"+
  19. " TO_CHAR(cd.COMPLAINTDATE,'DD-MM-RRRR') COMPLAINTDATE,"+
  20. " TO_CHAR(cd.COMPLAINTDATE,'HH:MI:SS AM') COMPLAINTTIME,"+
  21. " cd.COMPLAINTDETAILS,cd.COMPLAINANTFIRSTNAME, cd.MOBILENUMBER AS COMPLAINANTMOBILENUMBER, usr.USER_NAME, usr.extrafield2 as Mobile_number, "+
  22. " c.compl_date as COMPLAINTCOMPLETIONDATE, "+
  23. " DECODE ( qa.STATUS,null,'Not Attended','Attended') STATUS "+
  24. " from EGGR_COMPLAINTDETAILS@erp cd , eg_department@erp dep, EGGR_COMPLAINTTYPES@erp ct, eg_user@erp usr, eggr_qams_store@erp qa, EGGR_REDRESSALDETAILS@erp rd, "+
  25. " (SELECT c.redressalid, MAX(c.TIMESTAMP) compl_date "+
  26. " FROM eggr_status_tracker@erp c,eggr_redressaldetails@ERP d WHERE c.statusid in(5,10) AND d.COMPLAINTSTATUSID in(5,10) "+
  27. " AND d.REDRESSALID=c.redressalid GROUP BY c.redressalid) c "+
  28. " where cd.DEPTID=dep.ID_DEPT and cd.COMPLAINTTYPE=ct.COMPLAINTTYPEID AND rd.COMPLAINTID =cd.COMPLAINTID "+
  29. //" and ct.COMPLAINTTYPENAME in ('Removal of garbage', 'Removal of fallen trees', 'Stagnation of water') "+
  30. " AND rd.REDRESSALOFFICERID =usr.id_user and qa.FDBK_OBJ_REF =cd.COMPLAINTID(+) and "+
  31. " rd.COMPLAINTSTATUSID not in(2,3,4,9) and rd.redressalid=c.redressalid(+) and ";
  32. String sFrTime = "00:00:00 AM";
  33. String sToTime = "";
  34. // String sFrDate = "";
  35. // String sToDate = "";
  36. if (sFrTime.toUpperCase().equals("00:00:00 AM"))
  37. {
  38. sQry+=" TRUNC(cd.COMPLAINTDATE) between TO_DATE('"+sFrDate+"', 'yyyy-MM-dd') and TO_DATE('"+sToDate+"', 'yyyy-MM-dd') ";
  39. }
  40. else
  41. {
  42. sQry+=" cd.COMPLAINTDATE between TO_DATE('"+sFrDate+" "+sFrTime+"', 'DD-MM-RRRR hh:mi:ss am') and TO_DATE('"+sToDate+" "+sToTime+ "', 'DD-MM-RRRR hh:mi:ss am') ";
  43. }
  44. sQry+=" order by dept_name";
  45. System.out.println("qaqcquery:" + sQry);
  46. return sQry;
  47. }
  48. public List<Map<String, Object>> check1(String sFrDate, String sToDate) {
  49. Connection con =DBConnection.getConnection();
  50. Statement stmt3;
  51. try {
  52. stmt3 = con.createStatement();
  53. System.out.println( "checkingqaqc...");
  54. ResultSet rs3 = stmt3.executeQuery(getqaqcQuery(sFrDate, sToDate));
  55. List<Map<String, Object>> rows = new ArrayList<>();
  56. while (rs3.next()) {
  57. Map<String, Object> row = new HashMap<>();
  58. ResultSetMetaData metaData = rs3.getMetaData();
  59. int columnCount = metaData.getColumnCount();
  60. for (int i = 1; i <= columnCount; i++) {
  61. String columnName = metaData.getColumnName(i);
  62. Object columnValue = rs3.getObject(i);
  63. //System.out.println(columnName+" :"+columnValue);
  64. if (columnValue instanceof String) {
  65. columnValue = HtmlEntityDecoder.convertHtmlEntitiesToUtf8((String) columnValue);
  66. }
  67. row.put(columnName, columnValue);
  68. }
  69. rows.add(row);
  70. }
  71. return rows;
  72. }
  73. catch (Exception e){
  74. e.printStackTrace();
  75. }
  76. return null;
  77. }
  78. }