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.
177 lines
6.6 KiB
177 lines
6.6 KiB
package in.gov.chennaicorporation.gccoffice.pgr.service;
|
|
|
|
import java.sql.Connection;
|
|
import java.sql.ResultSet;
|
|
import java.sql.ResultSetMetaData;
|
|
import java.sql.SQLException;
|
|
import java.sql.Statement;
|
|
import java.util.ArrayList;
|
|
import java.util.Collections;
|
|
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;
|
|
import in.gov.chennaicorporation.gccoffice.pgr.dto.Dtoworeopen;
|
|
|
|
@Service
|
|
public class ReopenZonewiseReports {
|
|
|
|
@Autowired
|
|
DBConnection dbcon;
|
|
|
|
public List<Dtoworeopen> getAlldtoworeopen() {
|
|
List<Dtoworeopen> complaintdept = new ArrayList<>();
|
|
Connection con = DBConnection.getConnection();
|
|
Statement stmt = null;
|
|
ResultSet rs = null;
|
|
|
|
try {
|
|
stmt = con.createStatement();
|
|
rs = stmt.executeQuery(getdtoworeopenQuery());
|
|
|
|
while (rs.next()) {
|
|
Dtoworeopen dtoworeopens = new Dtoworeopen();
|
|
dtoworeopens.setId(rs.getString("id_dept"));
|
|
dtoworeopens.setName(rs.getString("dept_name"));
|
|
complaintdept.add(dtoworeopens);
|
|
}
|
|
|
|
return complaintdept;
|
|
} catch (SQLException e) {
|
|
e.printStackTrace();
|
|
} finally {
|
|
try {
|
|
if (rs != null) {
|
|
rs.close();
|
|
}
|
|
if (stmt != null) {
|
|
stmt.close();
|
|
}
|
|
if (con != null) {
|
|
con.close();
|
|
}
|
|
} catch (SQLException e) {
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
|
|
return Collections.emptyList(); // Return an empty list if there's an error
|
|
}
|
|
|
|
|
|
private String getdtoworeopenQuery() {
|
|
return "SELECT id_dept, dept_name "
|
|
+ "FROM EG_DEPARTMENT@ERP "
|
|
+ "WHERE NVL(dept_name, '0') NOT LIKE 'F%' AND dept_name IS NOT NULL AND id_dept >= 32 "
|
|
+ "ORDER BY id_dept";
|
|
}
|
|
|
|
public String getreopenzoneQuery(String sFrDate,String sToDate,String DEPT_NAME) {
|
|
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'";
|
|
|
|
int iPenReOpen = 1;
|
|
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) ";
|
|
|
|
int iRptID = 0;
|
|
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 +"','yyyy/mm/dd') and to_date('"+ sToDate +"','yyyy/mm/dd') ";
|
|
}
|
|
|
|
int iDaysID = 0;
|
|
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)";
|
|
|
|
int iDeptID = 0;
|
|
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 (DEPT_NAME != null && !DEPT_NAME.equals("0")) {
|
|
sQry += " AND UPPER(NVL(DEPT_NAME, '')) = UPPER('" + DEPT_NAME + "')";
|
|
}
|
|
|
|
//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;
|
|
}
|
|
|
|
public List<Map<String, Object>> getReopenZonewise(String sFrDate,String sToDate,String DEPT_NAME) {
|
|
Connection con =DBConnection.getConnection();
|
|
Statement stmt3;
|
|
try {
|
|
stmt3 = con.createStatement();
|
|
|
|
System.out.println( "checkingreopenzonewise...");
|
|
ResultSet rs3 = stmt3.executeQuery(getreopenzoneQuery(sFrDate,sToDate,DEPT_NAME));
|
|
|
|
List<Map<String, Object>> rows = new ArrayList<>();
|
|
|
|
while (rs3.next()) {
|
|
|
|
Map<String, Object> 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;
|
|
|
|
}
|
|
|
|
|
|
}
|