//package in.gov.chennaicorporation.gccoffice.pgr.service; // //import java.sql.Connection; //import java.sql.ResultSet; //import java.sql.ResultSetMetaData; //import java.sql.Statement; //import java.util.ArrayList; //import java.util.HashMap; //import java.util.List; //import java.util.Map; // //import org.springframework.beans.factory.annotation.Autowired; //import org.springframework.stereotype.Service; // //import in.gov.chennaicorporation.gccoffice.pgr.dbconnection.DBConnection; // //@Service //public class MobileAgeAnalysisReports { // // @Autowired // DBConnection dbcon; // // public String sFrDate =""; // public String sToDate =""; // // // // public String getmobileageanalysisQuery(int iPenReOpen, int iRptID, int iDaysID, int iDeptID) { // 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" // +" FROM eggr_complaintdetails@erp cd," // +" eggr_redressaldetails@erp rd," // +" eggr_complaintstatus@erp st," // +" eg_user@erp u" // +" WHERE cd.complaintid = rd.complaintid " // +" AND rd.complaintstatusid = st.complaintstatusid" // +" AND rd.redressalofficerid = u.id_user and complaintdate >= '25-oct-2010'"; // // if ( iPenReOpen == 0 ) // sQry += " AND st.statusname IN ('REGISTERED', 'PROCESSING', 'FORWARDED','REOPENED') and rd.COMPLAINTSTATUSID IN(2,3,4,9) "; // else if ( iPenReOpen == 1 ) // Pending // sQry += " AND st.statusname IN ('REGISTERED', 'PROCESSING', 'FORWARDED') and rd.COMPLAINTSTATUSID IN(2,3,4) "; // else if ( iPenReOpen == 2 ) // ReOpen // sQry += " AND st.statusname IN ('REOPENED') and rd.COMPLAINTSTATUSID IN(9) "; // // if ( iRptID == 1 ) sQry += " and nvl(RECEIVINGCENTERID,0)=1 "; // else if ( iRptID == 2 ) sQry += " and nvl(RECEIVINGCENTERID,0) !=1 "; // //Object sComplainttype = ""; //// if ( sComplainttype .equals("52,1,22,32,57,59,70,18,69,7,71,19,58,75,43") ) sQry += " and complainttype not in("+ sComplainttype +") "; //// else if ( !sComplainttype.equals("0") ) sQry += " and complainttype in("+ sComplainttype +") "; // // //if ( !sFrDate.equals("") ) sQry += " and trunc(complaintdate)=to_date('"+ sFrDate +"','dd/mm/yyyy') "; // if ( !sFrDate.equals("") ) // { // if (sToDate == null || sToDate.equals("") ) sToDate = sFrDate; // //sQry += " trunc(complaintdate)=to_date('"+ sFrDate +"','dd/mm/yyyy') and "; // sQry += " and trunc(complaintdate) between to_date('"+ sFrDate +"','dd/mm/yyyy') and to_date('"+ sToDate +"','dd/mm/yyyy') "; // } // // if ( iDaysID == 1 ) sQry += " and (sysdate-complaintdate)>90 "; // else if ( iDaysID == 2 ) sQry += " and sysdate-complaintdate>60 and sysdate-complaintdate<=90 "; // else if ( iDaysID == 3 ) sQry += " and sysdate-complaintdate>30 and sysdate-complaintdate<=60 "; // else if ( iDaysID == 4 ) sQry += " and sysdate-complaintdate>15 and sysdate-complaintdate<=30 "; // else if ( iDaysID == 5 ) sQry += " and sysdate-complaintdate>0 and sysdate-complaintdate<=15 "; // // 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 "; // sQry += " a.user_name=b.user_name AND (NVL(DEPT_NAME,0) NOT LIKE 'F%' AND DEPT_NAME IS NOT NULL)"; // // if ( (iDeptID == 48 || iDeptID == 49 || iDeptID == 50) && iPenReOpen == 2) // ReOpen & Region // { // if ( iDeptID == 48 ) // sQry += " and nvl(a.deptid,0) in (32,33,34,35,36,48)"; // else if ( iDeptID == 49 ) // sQry += " and nvl(a.deptid,0) in (42,43,44,45,46,49)"; // else if ( iDeptID == 50 ) // sQry += " and nvl(a.deptid,0) in (37,38,39,40,41,50)"; // } // else if ( iDeptID != 0 ) sQry += " and nvl(a.deptid,0)= "+ iDeptID; // // // // //if ( sComplainttype.equals("52,1,22,32,57,59,70,18,69,7,71") ) sQry += " and a.complainttype not in("+ sComplainttype +") "; // //else if ( !sComplainttype.equals("") ) sQry += " and complainttype in("+ sComplainttype +") "; // // sQry += " order by c.dept_name,a.user_name"; // System.out.println("Gen Query:" + sQry); // return sQry.toString(); // } // // public List> getMobileAgeAnalysiswise(String iPenReOpen, String sComplaintType, String rptId, String deptId, String zoneAge,String PgrUserID,String fromDate, String toDate) { // Connection con =DBConnection.getConnection(); // Statement stmt3; // try { // stmt3 = con.createStatement(); // // // System.out.println( "checkingMobileAgeAnalysis..."); // ResultSet rs3 = stmt3.executeQuery(getmobileageanalysisQuery(0, 0, 0, 0)); // // // List> rows = new ArrayList<>(); // // while (rs3.next()) { // // Map row = new HashMap<>(); // // // ResultSetMetaData metaData = rs3.getMetaData(); // int columnCount = metaData.getColumnCount(); // for (int i = 1; i <= columnCount; i++) { // String columnName = metaData.getColumnName(i); // Object columnValue = rs3.getObject(i); // System.out.println(columnName+" :"+columnValue); // row.put(columnName, columnValue); // } // // // rows.add(row); // } // return rows; // } // catch (Exception e){ // e.printStackTrace(); // } // return null; // //} // // //}