|
|
|
@ -1,10 +1,15 @@ |
|
|
|
package in.gov.chennaicorporation.gccoffice.pgr.service; |
|
|
|
|
|
|
|
import java.sql.Statement; |
|
|
|
|
|
|
|
import java.sql.Connection; |
|
|
|
|
|
|
|
import java.sql.PreparedStatement; |
|
|
|
import java.sql.ResultSet; |
|
|
|
import java.sql.ResultSetMetaData; |
|
|
|
import java.sql.SQLException; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.Collections; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
@ -15,17 +20,109 @@ import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
|
|
|
|
import in.gov.chennaicorporation.gccoffice.pgr.dbconnection.DBConnection; |
|
|
|
import in.gov.chennaicorporation.gccoffice.pgr.dto.ComplaintGroup; |
|
|
|
import in.gov.chennaicorporation.gccoffice.pgr.dto.ComplaintType; |
|
|
|
//import in.gov.chennaicorporation.gccoffice.pgr.repository.PgrReportRepository; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Service |
|
|
|
public class AllReports{ |
|
|
|
@Autowired |
|
|
|
DBConnection dbcon; |
|
|
|
|
|
|
|
public String getQuery(String sFrDate, String sToDate, String sRptGroup, String sRptType, String cbCompStatus,String mode) { |
|
|
|
//ComplaintTypes options method |
|
|
|
public List<ComplaintType> getAllComplaintTypes() { |
|
|
|
List<ComplaintType> complaintTypes = new ArrayList<>(); |
|
|
|
Connection con = DBConnection.getConnection(); |
|
|
|
Statement stmt = null; |
|
|
|
ResultSet rs = null; |
|
|
|
|
|
|
|
try { |
|
|
|
stmt = con.createStatement(); |
|
|
|
rs = stmt.executeQuery(getComplainttypeQuery()); |
|
|
|
|
|
|
|
while (rs.next()) { |
|
|
|
ComplaintType complaintType = new ComplaintType(); |
|
|
|
complaintType.setId(rs.getString("complainttypeid")); |
|
|
|
complaintType.setName(rs.getString("complainttypename")); |
|
|
|
complaintTypes.add(complaintType); |
|
|
|
} |
|
|
|
|
|
|
|
return complaintTypes; |
|
|
|
} 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 getComplainttypeQuery() { |
|
|
|
return "SELECT DISTINCT ct.complainttypeid, ct.complainttypename " + |
|
|
|
"FROM EGGR_COMPLAINTTYPES@erp ct"; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
//complaint group options method |
|
|
|
|
|
|
|
public List<ComplaintGroup> getAllComplaintgroups() { |
|
|
|
List<ComplaintGroup> complaintGroups = new ArrayList<>(); |
|
|
|
Connection con = DBConnection.getConnection(); |
|
|
|
Statement stmt = null; |
|
|
|
ResultSet rs = null; |
|
|
|
|
|
|
|
try { |
|
|
|
stmt = con.createStatement(); |
|
|
|
rs = stmt.executeQuery(getComplaintgroupQuery()); |
|
|
|
|
|
|
|
while (rs.next()) { |
|
|
|
ComplaintGroup complaintGroup = new ComplaintGroup(); |
|
|
|
complaintGroup.setId(rs.getString("id_complaintgroup")); |
|
|
|
complaintGroup.setName(rs.getString("complaintgroupname")); |
|
|
|
complaintGroups.add(complaintGroup); |
|
|
|
} |
|
|
|
|
|
|
|
return complaintGroups; |
|
|
|
} 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 getComplaintgroupQuery() { |
|
|
|
return "SELECT DISTINCT id_complaintgroup, complaintgroupname " + |
|
|
|
"FROM eggr_complaintgroup@erp"; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public String getQuery(String sFrDate, String sToDate, String sRptGroup, String sRptType, String cbCompStatus,String mode) { |
|
|
|
|
|
|
|
String sQry = "SELECT z.name AS zone_name, dn.name AS division_name, location.name AS location, " + |
|
|
|
"dept_name, TO_CHAR(complaintdate, 'dd-mm-yyyy') COMPDATE, TO_CHAR(complaintdate, 'HH24:MI:SS') Time, " + |
|
|
|
@ -53,8 +150,6 @@ public String getQuery(String sFrDate, String sToDate, String sRptGroup, String |
|
|
|
params.add(sFrDate); |
|
|
|
params.add(sToDate); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (cbCompStatus != null && cbCompStatus.equals("Pending")) { |
|
|
|
conditions.add("cs.complaintstatusid NOT IN (5,6,8,10,11)"); |
|
|
|
} else if (cbCompStatus != null && cbCompStatus.equals("Completed")) { |
|
|
|
@ -77,15 +172,11 @@ public String getQuery(String sFrDate, String sToDate, String sRptGroup, String |
|
|
|
conditions.add("ct.complainttypename = ?"); |
|
|
|
params.add(sRptType); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (mode != null && !mode.equals("0")) { |
|
|
|
conditions.add("cd.ID_MODE = ?"); |
|
|
|
params.add(mode); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!conditions.isEmpty()) { |
|
|
|
sQry += " AND " + String.join(" AND ", conditions); |
|
|
|
} |
|
|
|
@ -119,8 +210,6 @@ public String getQuery(String sFrDate, String sToDate, String sRptGroup, String |
|
|
|
stmt3.setString(parameterIndex++, sRptType); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (cbCompStatus != null && !cbCompStatus.equals("0")) { |
|
|
|
// No need to set a parameter for the status condition |
|
|
|
} |
|
|
|
@ -159,12 +248,7 @@ public String getQuery(String sFrDate, String sToDate, String sRptGroup, String |
|
|
|
} |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|