diff --git a/service/ZonewiseReports.java b/service/ZonewiseReports.java index 84cb798..45a7af7 100644 --- a/service/ZonewiseReports.java +++ b/service/ZonewiseReports.java @@ -1,12 +1,12 @@ 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; @@ -15,6 +15,7 @@ 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.Department; @Service public class ZonewiseReports { @@ -22,7 +23,54 @@ public class ZonewiseReports { @Autowired DBConnection dbcon; + public List getAlldeparments() { + List complaintdept = new ArrayList<>(); + Connection con = DBConnection.getConnection(); + Statement stmt = null; + ResultSet rs = null; + + try { + stmt = con.createStatement(); + rs = stmt.executeQuery(getDepartmentQuery()); + + while (rs.next()) { + Department departments = new Department(); + departments.setId(rs.getString("id_dept")); + departments.setName(rs.getString("dept_name")); + complaintdept.add(departments); + } + + 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 getDepartmentQuery() { + 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 getzoneQuery(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"