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.

132 lines
5.3 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 ZonewiseReports {
  15. @Autowired
  16. DBConnection dbcon;
  17. public String getzoneQuery(String sFrDate,String sToDate,String DEPT_NAME) {
  18. String sQry= "Select c.dept_name,a.iduser,a.user_name,nvl(b.extrafield2,' ') MOBILENO,a.nos,a.deptid from (SELECT cd.deptid,u.user_name, COUNT (cd.complaintid) nos,max(u.id_user) iduser"
  19. +" FROM eggr_complaintdetails@erp cd,"
  20. +" eggr_redressaldetails@erp rd,"
  21. +" eggr_complaintstatus@erp st,"
  22. +" eg_user@erp u"
  23. +" WHERE cd.complaintid = rd.complaintid "
  24. +" AND rd.complaintstatusid = st.complaintstatusid"
  25. +" AND rd.redressalofficerid = u.id_user and complaintdate >= '25-oct-2010'";
  26. int iPenReOpen=0;
  27. if ( iPenReOpen == 0 )
  28. sQry += " AND st.statusname IN ('REGISTERED', 'PROCESSING', 'FORWARDED','REOPENED') and rd.COMPLAINTSTATUSID IN(2,3,4,9) ";
  29. else if ( iPenReOpen == 1 ) // Pending
  30. sQry += " AND st.statusname IN ('REGISTERED', 'PROCESSING', 'FORWARDED') and rd.COMPLAINTSTATUSID IN(2,3,4) ";
  31. else if ( iPenReOpen == 2 ) // ReOpen
  32. sQry += " AND st.statusname IN ('REOPENED') and rd.COMPLAINTSTATUSID IN(9) ";
  33. int iRptID=0;
  34. if ( iRptID == 1 ) sQry += " and nvl(RECEIVINGCENTERID,0)=1 ";
  35. else if ( iRptID == 2 ) sQry += " and nvl(RECEIVINGCENTERID,0) !=1 ";
  36. //Object sComplainttype = "";
  37. // if ( sComplainttype .equals("52,1,22,32,57,59,70,18,69,7,71,19,58,75,43") ) sQry += " and complainttype not in("+ sComplainttype +") ";
  38. // else if ( !sComplainttype.equals("0") ) sQry += " and complainttype in("+ sComplainttype +") ";
  39. //if ( !sFrDate.equals("") ) sQry += " and trunc(complaintdate)=to_date('"+ sFrDate +"','dd/mm/yyyy') ";
  40. if ( !sFrDate.equals("") )
  41. {
  42. if (sToDate == null || sToDate.equals("") ) sToDate = sFrDate;
  43. //sQry += " trunc(complaintdate)=to_date('"+ sFrDate +"','dd/mm/yyyy') and ";
  44. sQry += " and trunc(complaintdate) between to_date('"+ sFrDate +"','yyyy/mm/dd') and to_date('"+ sToDate +"','yyyy/mm/dd') ";
  45. }
  46. int iDaysID=0;
  47. if ( iDaysID == 1 ) sQry += " and (sysdate-complaintdate)>90 ";
  48. else if ( iDaysID == 2 ) sQry += " and sysdate-complaintdate>60 and sysdate-complaintdate<=90 ";
  49. else if ( iDaysID == 3 ) sQry += " and sysdate-complaintdate>30 and sysdate-complaintdate<=60 ";
  50. else if ( iDaysID == 4 ) sQry += " and sysdate-complaintdate>15 and sysdate-complaintdate<=30 ";
  51. else if ( iDaysID == 5 ) sQry += " and sysdate-complaintdate>0 and sysdate-complaintdate<=15 ";
  52. sQry += " GROUP BY cd.deptid,u.user_name ORDER BY cd.deptid,u.user_name) a , eg_user@erp b,eg_department@erp c where a.deptid=c.id_dept(+) and ";
  53. sQry += " a.user_name=b.user_name AND (NVL(DEPT_NAME,0) NOT LIKE 'F%' AND DEPT_NAME IS NOT NULL)";
  54. int iDeptID = 0 ;
  55. if ( (iDeptID == 48 || iDeptID == 49 || iDeptID == 50) && iPenReOpen == 2) // ReOpen & Region
  56. {
  57. if ( iDeptID == 48 )
  58. sQry += " and nvl(a.deptid,0) in (32,33,34,35,36,48)";
  59. else if ( iDeptID == 49 )
  60. sQry += " and nvl(a.deptid,0) in (42,43,44,45,46,49)";
  61. else if ( iDeptID == 50 )
  62. sQry += " and nvl(a.deptid,0) in (37,38,39,40,41,50)";
  63. }
  64. else if ( iDeptID != 0 ) sQry += " and nvl(a.deptid,0)= "+ iDeptID;
  65. if (DEPT_NAME != null && !DEPT_NAME.equals("0")) {
  66. sQry += " AND UPPER(NVL(DEPT_NAME, '')) = UPPER('" + DEPT_NAME + "')";
  67. }
  68. //if ( sComplainttype.equals("52,1,22,32,57,59,70,18,69,7,71") ) sQry += " and a.complainttype not in("+ sComplainttype +") ";
  69. //else if ( !sComplainttype.equals("") ) sQry += " and complainttype in("+ sComplainttype +") ";
  70. sQry += " order by c.dept_name,a.user_name";
  71. System.out.println("Gen Query:" + sQry);
  72. return sQry;
  73. }
  74. public List<Map<String, Object>> getZonewise(String sFrDate,String sToDate,String DEPT_NAME) {
  75. Connection con =DBConnection.getConnection();
  76. Statement stmt3;
  77. try {
  78. stmt3 = con.createStatement();
  79. System.out.println( "checkingzonewise...");
  80. //String sComplainttype = "52,1,22,32,57,59,70,18,69,7,71,19,75,58,43,146,97,113,114,130,145,118,138,99,152,119,181,112,166";
  81. ResultSet rs3 = stmt3.executeQuery(getzoneQuery(sFrDate,sToDate,DEPT_NAME));
  82. List<Map<String, Object>> rows = new ArrayList<>();
  83. while (rs3.next()) {
  84. Map<String, Object> row = new HashMap<>();
  85. ResultSetMetaData metaData = rs3.getMetaData();
  86. int columnCount = metaData.getColumnCount();
  87. for (int i = 1; i <= columnCount; i++) {
  88. String columnName = metaData.getColumnName(i);
  89. Object columnValue = rs3.getObject(i);
  90. //System.out.println(columnName+" :"+columnValue);
  91. row.put(columnName, columnValue);
  92. }
  93. rows.add(row);
  94. }
  95. return rows;
  96. }
  97. catch (Exception e){
  98. e.printStackTrace();
  99. }
  100. return null;
  101. }
  102. }