|
|
|
@ -0,0 +1,35 @@ |
|
|
|
package jumapacelaya.gob.mx.cobranza.servicio; |
|
|
|
|
|
|
|
import jakarta.inject.Singleton; |
|
|
|
|
|
|
|
import javax.sql.DataSource; |
|
|
|
import java.sql.Connection; |
|
|
|
import java.sql.PreparedStatement; |
|
|
|
import java.sql.ResultSet; |
|
|
|
|
|
|
|
@Singleton |
|
|
|
public class CobranzaServicio { |
|
|
|
|
|
|
|
private final DataSource dataSource; |
|
|
|
|
|
|
|
public CobranzaServicio(DataSource dataSource) { |
|
|
|
this.dataSource = dataSource; |
|
|
|
} |
|
|
|
|
|
|
|
public int obtenerTotalPredios() { |
|
|
|
String query = "SELECT COUNT(*) AS TotalPredios FROM cobranza.tblcarteravencida"; |
|
|
|
try (Connection connection = dataSource.getConnection(); |
|
|
|
PreparedStatement stmt = connection.prepareStatement(query); |
|
|
|
ResultSet rs = stmt.executeQuery()) { |
|
|
|
|
|
|
|
if (rs.next()) { |
|
|
|
return rs.getInt("TotalPredios"); |
|
|
|
} else { |
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
throw new RuntimeException("Error al obtener total de predios en cartera vencida", e); |
|
|
|
} |
|
|
|
} |
|
|
|
} |