732 lines
26 KiB
Java
732 lines
26 KiB
Java
package com.tarisan.control;
|
|
|
|
import java.sql.Connection;
|
|
import java.sql.ResultSet;
|
|
import java.sql.SQLException;
|
|
import java.util.Calendar;
|
|
|
|
import com.tarisan.data.Tarjeta;
|
|
import com.tarisan.excepcion.ExcepcionTarisan;
|
|
import com.tarisan.log.LogTarisan;
|
|
import com.tarisan.log.NivelLog;
|
|
import com.tarisan.util.Utilidades;
|
|
|
|
public class PersistenciaTabenefi implements Constantes
|
|
{
|
|
/**
|
|
* Funcion que cargará colectivo, poliza, orden y fecha baja en el objeto tarjeta a partir del número de tarjeta
|
|
* @param tarjeta
|
|
* @return
|
|
*/
|
|
public Tarjeta generarObjetoTarjeta(int tarjeta)
|
|
{
|
|
Tarjeta resultado = new Tarjeta();
|
|
|
|
StringBuffer sqlSelect = new StringBuffer();
|
|
sqlSelect.append("SELECT COLECTIVO");
|
|
sqlSelect.append(", POLIZA");
|
|
sqlSelect.append(", FECHA_BAJA");
|
|
sqlSelect.append(", ORDEN");
|
|
sqlSelect.append(", ENTIDAD");
|
|
sqlSelect.append(", TARJETA_CHIPCARD");
|
|
sqlSelect.append(" FROM ttbenefi");
|
|
sqlSelect.append(" WHERE TARJETA = ?");
|
|
sqlSelect.append(" and ttbenefi.fecha_baja is null and fecha_alta <= sysdate");
|
|
|
|
|
|
Connection conexion;
|
|
try {
|
|
conexion = ParametrosConfiguracion.dataStore.obtenerConexion();
|
|
Object aCondiciones[] = new Object[1];
|
|
aCondiciones[0] = Integer.valueOf(tarjeta);
|
|
resultado.setTarjeta(tarjeta);
|
|
ResultSet rs = ParametrosConfiguracion.dataStore.seleccionar(conexion, sqlSelect.toString(), aCondiciones);
|
|
|
|
while(rs.next())
|
|
{
|
|
resultado.setColectivo(rs.getLong("COLECTIVO"));
|
|
resultado.setPoliza(rs.getInt("POLIZA"));
|
|
resultado.setBeneficiario(rs.getInt("ORDEN"));
|
|
resultado.setEntidadIMQ(rs.getInt("ENTIDAD"));
|
|
resultado.setTarjetaDesplazado(rs.getString("TARJETA_CHIPCARD"));
|
|
resultado.setValida(true);
|
|
}
|
|
rs.close();
|
|
ParametrosConfiguracion.dataStore.liberarConexion(conexion);
|
|
PersistenciaTaiguala pertaiguala = new PersistenciaTaiguala();
|
|
int contrato = pertaiguala.obtenerContrato(resultado.getColectivo(), resultado.getPoliza(), resultado.getEntidadIMQ());
|
|
if(contrato > 0)
|
|
{
|
|
resultado.setContrato(contrato);
|
|
resultado.setValida(true);
|
|
}
|
|
else
|
|
{
|
|
resultado.setValida(false);
|
|
LogTarisan.logger.log(NivelLog.ERROR, "No se encuentra el contrato de la tarjeta: "+tarjeta);
|
|
}
|
|
|
|
} catch (ExcepcionTarisan e) {
|
|
LogTarisan.logger.log(NivelLog.ERROR, "Error al generar el objeto tarjeta a partir del número de tarjeta:"+tarjeta);
|
|
e.printStackTrace();
|
|
} catch (SQLException e) {
|
|
LogTarisan.logger.log(NivelLog.ERROR, "Error SQL: "+e.toString()+" al generar el objeto tarjeta a partir del número de tarjeta:"+tarjeta);
|
|
}
|
|
|
|
|
|
return resultado;
|
|
}
|
|
|
|
public boolean tiene_embosado(String tarjetachipcard)
|
|
{
|
|
boolean resul = false;
|
|
/**
|
|
* 16/02/2016 QUITAMOS EXCEPción PARA OBLIGAR A METER EL TROQUELADO A LOS DE SANITAS TAMBión. (MARTA)
|
|
*
|
|
*/
|
|
/*if(tarjetachipcard.startsWith(ParametrosConfiguracion.bin_chipcard_sanitas))
|
|
{
|
|
LogTarisan.logger.log(NivelLog.DEBUG, "Es de sanitas no hay que buscar");
|
|
resul = true;
|
|
}
|
|
else
|
|
{*/
|
|
LogTarisan.logger.log(NivelLog.DEBUG, "Comprobamos si la tarjeta "+tarjetachipcard+" tiene el Identificador introducido");
|
|
StringBuffer sqlSelect = new StringBuffer();
|
|
sqlSelect.append("SELECT TROQUELADO, TRATADO FROM TADESPLAZ");
|
|
sqlSelect.append(" WHERE TRIM(TARJETA_CHIPCARD) = TRIM(?)");
|
|
Connection conexion;
|
|
try
|
|
{
|
|
conexion = ParametrosConfiguracion.dataStore.obtenerConexion();
|
|
ResultSet rs = null;
|
|
Object aCondiciones[] = new Object[1];
|
|
aCondiciones[0] = new String(tarjetachipcard);
|
|
LogTarisan.logger.log(NivelLog.DEBUG, "SQL: "+Utilidades.obtenerSentenciaSQL(sqlSelect, null, aCondiciones));
|
|
rs = ParametrosConfiguracion.dataStore.seleccionar(conexion, sqlSelect.toString(), aCondiciones);
|
|
while(rs.next())
|
|
{
|
|
if(rs.getObject("TROQUELADO") == null && rs.getInt("TRATADO")==0)
|
|
{
|
|
LogTarisan.logger.log(NivelLog.DEBUG, "PersistenciaTabenefi - NO tiene_embosado hay que pedirlo");
|
|
resul = false;
|
|
}
|
|
// if(rs.getString("TROQUELADO").trim().length()>0)
|
|
else
|
|
{
|
|
//LogTarisan.logger.log(NivelLog.DEBUG, "PersistenciaTabenefi - tiene_embosado - "+ rs.getString("TROQUELADO").trim().length() + " - " + tarjetachipcard);
|
|
resul = true;
|
|
}
|
|
}
|
|
rs.close();
|
|
ParametrosConfiguracion.dataStore.liberarConexion(conexion);
|
|
}
|
|
catch (Exception e) {
|
|
LogTarisan.logger.log(NivelLog.DEBUG, "Excepcion Tarisan - "+e.toString());
|
|
}/* catch (SQLException e) {
|
|
LogTarisan.logger.log(NivelLog.DEBUG, "Excepcion SQL - "+e.toString());
|
|
}*/
|
|
//return true;
|
|
catch (ExcepcionTarisan e) {
|
|
// TODO Auto-generated catch block
|
|
e.printStackTrace();
|
|
}
|
|
/*}*/
|
|
return resul;
|
|
}
|
|
|
|
/*public boolean añade_embosado(String tarjetachipcard, String embosado)
|
|
{
|
|
boolean resul = false;
|
|
boolean resultado = false;
|
|
LogTarisan.logger.log(NivelLog.INFO, "Vamos a insertar el identificador de la tarjeta");
|
|
StringBuffer sqlInsert = new StringBuffer();
|
|
sqlInsert.append("UPDATE TADESPLAZ SET TROQUELADO = ? ");
|
|
sqlInsert.append("WHERE TADESPLAZ.TARJETA_CHIPCARD = ?");
|
|
Connection conexion = null;
|
|
try
|
|
{
|
|
conexion = ParametrosConfiguracion.dataStore.obtenerConexion();
|
|
ParametrosConfiguracion.dataStore.iniciarTransaccion(conexion);
|
|
Object aCondiciones[] = new Object[1];
|
|
aCondiciones[0] = new String(tarjetachipcard);
|
|
Object aValores[] = new Object[1];
|
|
aValores[0] = new String(embosado);
|
|
LogTarisan.logger.log(NivelLog.DEBUG, "Update embosado: "+Utilidades.obtenerSentenciaSQL(sqlInsert, aValores, aCondiciones));
|
|
resul = ParametrosConfiguracion.dataStore.actualizar(sqlInsert.toString(), aValores, aCondiciones);
|
|
ParametrosConfiguracion.dataStore.confirmarTransaccion(conexion);
|
|
|
|
StringBuffer sqlSelect = new StringBuffer();
|
|
sqlSelect.append("SELECT * FROM TADESPLAZ");
|
|
sqlSelect.append(" WHERE TRIM(TARJETA_CHIPCARD) = TRIM('"+ tarjetachipcard +"')");
|
|
sqlSelect.append(" AND TRIM(TROQUELADO) = TRIM('"+ embosado +"')");
|
|
ResultSet rs = null;
|
|
rs = ParametrosConfiguracion.dataStore.seleccionar(conexion, sqlSelect.toString());
|
|
while(rs.next())
|
|
{
|
|
resultado=true;
|
|
}
|
|
|
|
ParametrosConfiguracion.dataStore.liberarConexion(conexion);
|
|
}
|
|
catch(Exception e)
|
|
{
|
|
try {
|
|
LogTarisan.logger.log(NivelLog.ERROR, "Error al actualizar el embosado en tadesplaz."+e.toString());
|
|
ParametrosConfiguracion.dataStore.deshacerTransaccion(conexion);
|
|
} catch (ExcepcionTarisan e1) {
|
|
LogTarisan.logger.log(NivelLog.ERROR, "Error al actualizar el embosado en tadesplaz."+e1.toString());
|
|
}
|
|
} catch (ExcepcionTarisan e) {
|
|
// TODO Auto-generated catch block
|
|
e.printStackTrace();
|
|
}
|
|
LogTarisan.logger.log(NivelLog.DEBUG, "Resultado al actualizar embosado." + resul);
|
|
return resultado;
|
|
}*/
|
|
public boolean anade_embosado(String tarjetachipcard, String embosado)
|
|
{
|
|
boolean resul = false;
|
|
boolean resultado = false;
|
|
LogTarisan.logger.log(NivelLog.INFO, "Vamos a insertar el identificador de la tarjeta");
|
|
StringBuffer sqlInsert = new StringBuffer();
|
|
Connection conexion = null;
|
|
try
|
|
{
|
|
StringBuffer sqlSelect = new StringBuffer();
|
|
sqlSelect.append("SELECT * FROM TADESPLAZ");
|
|
sqlSelect.append(" WHERE TRIM(TARJETA_CHIPCARD) = TRIM('"+ tarjetachipcard +"')");
|
|
sqlSelect.append(" AND TRIM(TROQUELADO) = TRIM('"+ embosado +"')");
|
|
ResultSet rs = null;
|
|
rs = ParametrosConfiguracion.dataStore.seleccionar(conexion, sqlSelect.toString());
|
|
if (rs!=null){
|
|
while(rs.next())
|
|
{
|
|
resultado=true;
|
|
}
|
|
}
|
|
|
|
//ParametrosConfiguracion.dataStore.liberarConexion(conexion);
|
|
|
|
if (resultado) {
|
|
sqlInsert.append("UPDATE TADESPLAZ SET TROQUELADO = ? ");
|
|
sqlInsert.append("WHERE TADESPLAZ.TARJETA_CHIPCARD = ?");
|
|
conexion = ParametrosConfiguracion.dataStore.obtenerConexion();
|
|
ParametrosConfiguracion.dataStore.iniciarTransaccion(conexion);
|
|
Object aCondiciones[] = new Object[1];
|
|
aCondiciones[0] = new String(tarjetachipcard);
|
|
Object aValores[] = new Object[1];
|
|
aValores[0] = new String(embosado);
|
|
LogTarisan.logger.log(NivelLog.DEBUG, "Update embosado: "+Utilidades.obtenerSentenciaSQL(sqlInsert, aValores, aCondiciones));
|
|
resul = ParametrosConfiguracion.dataStore.actualizar(sqlInsert.toString(), aValores, aCondiciones);
|
|
ParametrosConfiguracion.dataStore.confirmarTransaccion(conexion);
|
|
ParametrosConfiguracion.dataStore.liberarConexion(conexion);
|
|
resultado = resul;
|
|
}
|
|
|
|
}
|
|
catch(Exception e)
|
|
{
|
|
try {
|
|
LogTarisan.logger.log(NivelLog.ERROR, "Error al actualizar el embosado en tadesplaz."+e.toString());
|
|
ParametrosConfiguracion.dataStore.deshacerTransaccion(conexion);
|
|
} catch (ExcepcionTarisan e1) {
|
|
LogTarisan.logger.log(NivelLog.ERROR, "Error al actualizar el embosado en tadesplaz."+e1.toString());
|
|
}
|
|
} catch (ExcepcionTarisan e) {
|
|
// TODO Auto-generated catch block
|
|
e.printStackTrace();
|
|
}
|
|
LogTarisan.logger.log(NivelLog.DEBUG, "Resultado al actualizar embosado." + resul);
|
|
return resultado;
|
|
}
|
|
|
|
public Calendar getFechaBaja(String tarjetachipcard)
|
|
{
|
|
Calendar resul = Calendar.getInstance();
|
|
LogTarisan.logger.log(NivelLog.DEBUG, "\nEntra en fechabaja para comprobar si la poliza está de baja.");
|
|
StringBuffer sqlSelect = new StringBuffer();
|
|
sqlSelect.append("SELECT FECHA_BAJA FROM TTBENEFI");
|
|
sqlSelect.append(" WHERE TRIM(TARJETA_CHIPCARD) = TRIM(?)");
|
|
Connection conexion;
|
|
try
|
|
{
|
|
conexion = ParametrosConfiguracion.dataStore.obtenerConexion();
|
|
ResultSet rs = null;
|
|
Object aCondiciones[] = new Object[1];
|
|
aCondiciones[0] = new String(tarjetachipcard);
|
|
rs = ParametrosConfiguracion.dataStore.seleccionar(conexion, sqlSelect.toString(), aCondiciones);
|
|
while(rs.next())
|
|
{
|
|
resul.setTime(rs.getDate("FECHA_BAJA"));
|
|
}
|
|
} catch (ExcepcionTarisan e) {
|
|
LogTarisan.logger.log(NivelLog.DEBUG, "Excepcion Tarisan - "+e.toString());
|
|
} catch (SQLException e) {
|
|
LogTarisan.logger.log(NivelLog.DEBUG, "Excepcion SQL - "+e.toString());
|
|
}
|
|
return resul;
|
|
}
|
|
|
|
public boolean existeTarjetaChipcard(String tarjetachipcard, int entidad)
|
|
{
|
|
boolean resultado = false;
|
|
LogTarisan.logger.log(NivelLog.DEBUG, "\nEntra en existeTarjetaChipcard con valores: tarjetachipcard = "+tarjetachipcard+", entidad = "+entidad+"\n");
|
|
StringBuffer sqlSelect = new StringBuffer();
|
|
sqlSelect.append("SELECT COLECTIVO");
|
|
sqlSelect.append(", POLIZA");
|
|
sqlSelect.append(", FECHA_BAJA");
|
|
sqlSelect.append(", ORDEN");
|
|
sqlSelect.append(", ENTIDAD");
|
|
sqlSelect.append(" FROM TTBENEFI");
|
|
sqlSelect.append(" WHERE TRIM(TARJETA_CHIPCARD) = TRIM(?)");
|
|
//sqlSelect.append(" and (ttbenefi.fecha_baja is null or ttbenefi.fecha_baja > sysdate)");
|
|
if(entidad > 0)
|
|
sqlSelect.append(" AND ENTIDAD = ?");
|
|
|
|
|
|
|
|
Connection conexion;
|
|
try {
|
|
conexion = ParametrosConfiguracion.dataStore.obtenerConexion();
|
|
ResultSet rs = null;
|
|
if(entidad > 0)
|
|
{
|
|
Object aCondiciones[] = new Object[2];
|
|
aCondiciones[0] = new String(tarjetachipcard);
|
|
aCondiciones[1] = Integer.valueOf(entidad);
|
|
|
|
rs = ParametrosConfiguracion.dataStore.seleccionar(conexion, sqlSelect.toString(), aCondiciones);
|
|
}
|
|
else
|
|
{
|
|
Object aCondiciones[] = new Object[1];
|
|
aCondiciones[0] = new String(tarjetachipcard);
|
|
|
|
rs = ParametrosConfiguracion.dataStore.seleccionar(conexion, sqlSelect.toString(), aCondiciones);
|
|
}
|
|
|
|
while(rs.next())
|
|
{
|
|
LogTarisan.logger.log(NivelLog.DEBUG, "Datos conseguidos COL="+rs.getLong("COLECTIVO")+", POL="+rs.getLong("POLIZA")+", ORD="+rs.getInt("ORDEN"));
|
|
resultado = true;
|
|
}
|
|
rs.close();
|
|
ParametrosConfiguracion.dataStore.liberarConexion(conexion);
|
|
} catch (ExcepcionTarisan e) {
|
|
LogTarisan.logger.log(NivelLog.DEBUG, "Excepcion Tarisan - "+e.toString());
|
|
} catch (SQLException e) {
|
|
LogTarisan.logger.log(NivelLog.DEBUG, "Excepcion SQL - "+e.toString());
|
|
}
|
|
LogTarisan.logger.log(NivelLog.DEBUG, "Datos conseguidos?: "+resultado);
|
|
return resultado;
|
|
|
|
}
|
|
|
|
public Tarjeta generarObjetoTarjetaChipcard(String tarjetachipcard, int entidad)
|
|
{
|
|
LogTarisan.logger.log(NivelLog.DEBUG, "\nEntra en generarobjetotarjetachipcard con valores: tarjetachipcard = "+tarjetachipcard+", entidad = "+entidad+"\n");
|
|
Tarjeta resultado = new Tarjeta();
|
|
|
|
StringBuffer sqlSelect = new StringBuffer();
|
|
sqlSelect.append("SELECT COLECTIVO");
|
|
sqlSelect.append(", POLIZA");
|
|
sqlSelect.append(", FECHA_BAJA");
|
|
sqlSelect.append(", ORDEN");
|
|
sqlSelect.append(", ENTIDAD");
|
|
sqlSelect.append(" FROM TTBENEFI");
|
|
sqlSelect.append(" WHERE TRIM(TARJETA_CHIPCARD) = TRIM(?)");
|
|
//sqlSelect.append(" and (ttbenefi.fecha_baja is null or ttbenefi.fecha_baja > sysdate)");
|
|
if(entidad > 0)
|
|
sqlSelect.append(" AND ENTIDAD = ?");
|
|
|
|
|
|
|
|
Connection conexion;
|
|
try {
|
|
conexion = ParametrosConfiguracion.dataStore.obtenerConexion();
|
|
ResultSet rs = null;
|
|
if(entidad > 0)
|
|
{
|
|
Object aCondiciones[] = new Object[2];
|
|
aCondiciones[0] = new String(tarjetachipcard);
|
|
aCondiciones[1] = Integer.valueOf(entidad);
|
|
resultado.setTarjetaDesplazado(tarjetachipcard);
|
|
rs = ParametrosConfiguracion.dataStore.seleccionar(conexion, sqlSelect.toString(), aCondiciones);
|
|
}
|
|
else
|
|
{
|
|
Object aCondiciones[] = new Object[1];
|
|
aCondiciones[0] = new String(tarjetachipcard);
|
|
resultado.setTarjetaDesplazado(tarjetachipcard);
|
|
rs = ParametrosConfiguracion.dataStore.seleccionar(conexion, sqlSelect.toString(), aCondiciones);
|
|
}
|
|
|
|
while(rs.next())
|
|
{
|
|
LogTarisan.logger.log(NivelLog.DEBUG, "Datos conseguidos COL="+rs.getLong("COLECTIVO")+", POL="+rs.getLong("POLIZA")+", ORD="+rs.getInt("ORDEN"));
|
|
resultado.setColectivo(rs.getLong("COLECTIVO"));
|
|
resultado.setPoliza(rs.getLong("POLIZA"));
|
|
resultado.setBeneficiario(rs.getInt("ORDEN"));
|
|
resultado.setEntidadIMQ(rs.getInt("ENTIDAD"));
|
|
PersistenciaTaiguala pertaiguala = new PersistenciaTaiguala();
|
|
resultado.setContrato(pertaiguala.obtenerContrato(resultado.getColectivo(), resultado.getPoliza(), resultado.getEntidadIMQ()));
|
|
LogTarisan.logger.log(NivelLog.DEBUG, "PersistenciaTabenefi - generarObjetoTarjetaChipcard - LLega 241");
|
|
Calendar hoy = Calendar.getInstance();
|
|
Calendar baja = Calendar.getInstance();
|
|
LogTarisan.logger.log(NivelLog.DEBUG, "PersistenciaTabenefi - generarObjetoTarjetaChipcard - LLega 244");
|
|
if(rs.getDate("FECHA_BAJA") == null)
|
|
{
|
|
LogTarisan.logger.log(NivelLog.DEBUG, "PersistenciaTabenefi - generarObjetoTarjetaChipcard - LLega 247");
|
|
baja = null;
|
|
}
|
|
else
|
|
baja.setTime(rs.getDate("FECHA_BAJA"));
|
|
LogTarisan.logger.log(NivelLog.DEBUG, "PersistenciaTabenefi - generarObjetoTarjetaChipcard - LLega 252");
|
|
if(baja == null || baja.compareTo(hoy) > 0)
|
|
{
|
|
resultado.setValida(true);
|
|
resultado.setEstadeBaja(false);
|
|
}
|
|
else
|
|
{
|
|
resultado.setValida(false);
|
|
resultado.setEstadeBaja(true);
|
|
LogTarisan.logger.log(NivelLog.DEBUG, "El asegurado esta de baja!!!");
|
|
}
|
|
}
|
|
rs.close();
|
|
ParametrosConfiguracion.dataStore.liberarConexion(conexion);
|
|
} catch (ExcepcionTarisan e) {
|
|
LogTarisan.logger.log(NivelLog.DEBUG, "Excepcion Tarisan - "+e.toString());
|
|
} catch (SQLException e) {
|
|
LogTarisan.logger.log(NivelLog.DEBUG, "Excepcion SQL - "+e.toString());
|
|
}
|
|
|
|
LogTarisan.logger.log(NivelLog.DEBUG, "Datos conseguidos: "+resultado.getColectivo()+"="+resultado.getPoliza()+"="+resultado.getEntidadIMQ());
|
|
return resultado;
|
|
}
|
|
|
|
public int obtenerNumCli(int tarjeta) throws ExcepcionTarisan
|
|
{
|
|
int cliente=0;
|
|
StringBuffer sqlSelect = new StringBuffer();
|
|
|
|
try
|
|
{
|
|
sqlSelect.append("SELECT CLIENTE");
|
|
sqlSelect.append(" FROM TTBENEFI");
|
|
sqlSelect.append(" WHERE TARJETA = ?");
|
|
|
|
Connection conexion = ParametrosConfiguracion.dataStore.obtenerConexion();
|
|
|
|
Object aCondiciones[] = new Object[1];
|
|
aCondiciones[0] = Integer.valueOf(tarjeta);
|
|
|
|
ResultSet rs = ParametrosConfiguracion.dataStore.seleccionar(conexion, sqlSelect.toString(), aCondiciones);
|
|
if(rs.next())
|
|
{
|
|
cliente = rs.getInt("CLIENTE");
|
|
}
|
|
rs.close();
|
|
|
|
ParametrosConfiguracion.dataStore.liberarConexion(conexion);
|
|
LogTarisan.logger.log(NivelLog.DEBUG, "Seleccionado el numero de cliente: " + cliente + " de la tabla TTBENEFI (" + sqlSelect + ")");
|
|
}
|
|
catch(SQLException sqle)
|
|
{
|
|
LogTarisan.logger.log(NivelLog.ERROR, "Error en la selección del numero del cliente: " + sqle + " (" + sqlSelect + ")");
|
|
throw new ExcepcionTarisan();
|
|
}
|
|
|
|
return cliente;
|
|
}
|
|
|
|
public int obtenerEntidad(int cliente, long tarjeta) throws ExcepcionTarisan
|
|
{
|
|
int entidad=0;
|
|
StringBuffer sqlSelect = new StringBuffer();
|
|
|
|
try
|
|
{
|
|
sqlSelect.append("SELECT ENTIDAD");
|
|
sqlSelect.append(" FROM TTBENEFI");
|
|
sqlSelect.append(" WHERE CLIENTE = ?");
|
|
sqlSelect.append(" AND TARJETA <> ?");
|
|
sqlSelect.append(" and (TTBENEFI.FECHA_BAJA > sysdate OR TTBENEFI.FECHA_BAJA IS NULL)");
|
|
|
|
Connection conexion = ParametrosConfiguracion.dataStore.obtenerConexion();
|
|
|
|
Object aCondiciones[] = new Object[2];
|
|
aCondiciones[0] = Integer.valueOf(cliente);
|
|
aCondiciones[1] = Long.valueOf(tarjeta);
|
|
|
|
ResultSet rs = ParametrosConfiguracion.dataStore.seleccionar(conexion, sqlSelect.toString(), aCondiciones);
|
|
if(rs.next())
|
|
{
|
|
entidad=(rs.getInt("ENTIDAD"));
|
|
|
|
}
|
|
else{
|
|
//Devuelvo -1 para saber que no ha encontrado ninguna entidad y diferenciarlo de la entidad=0
|
|
entidad=-1;
|
|
}
|
|
rs.close();
|
|
|
|
ParametrosConfiguracion.dataStore.liberarConexion(conexion);
|
|
LogTarisan.logger.log(NivelLog.DEBUG, "Seleccionado entidad y colectivo del cliente: " + cliente + " de la tabla TTBENEFI (" + sqlSelect + ")");
|
|
}
|
|
catch(SQLException sqle)
|
|
{
|
|
LogTarisan.logger.log(NivelLog.ERROR, "Error en la selección del entidad y colectivo del cliente: " + sqle + " (" + sqlSelect + ")");
|
|
throw new ExcepcionTarisan();
|
|
}
|
|
|
|
return entidad;
|
|
}
|
|
|
|
public long obtenerColectivo(int cliente, long tarjeta) throws ExcepcionTarisan
|
|
{
|
|
long colectivo=0;
|
|
StringBuffer sqlSelect = new StringBuffer();
|
|
|
|
try
|
|
{
|
|
sqlSelect.append("SELECT COLECTIVO");
|
|
sqlSelect.append(" FROM TTBENEFI");
|
|
sqlSelect.append(" WHERE CLIENTE = ?");
|
|
sqlSelect.append(" AND TARJETA <> ?");
|
|
sqlSelect.append(" and (TTBENEFI.FECHA_BAJA > sysdate OR TTBENEFI.FECHA_BAJA IS NULL)");
|
|
|
|
Connection conexion = ParametrosConfiguracion.dataStore.obtenerConexion();
|
|
|
|
Object aCondiciones[] = new Object[2];
|
|
aCondiciones[0] = Integer.valueOf(cliente);
|
|
aCondiciones[1] = Long.valueOf(tarjeta);
|
|
|
|
ResultSet rs = ParametrosConfiguracion.dataStore.seleccionar(conexion, sqlSelect.toString(), aCondiciones);
|
|
if(rs.next())
|
|
{
|
|
colectivo=(rs.getLong("COLECTIVO"));
|
|
|
|
}
|
|
else{
|
|
//Devuelvo -1 para saber que no ha encontrado ningun colectivo y diferenciarlo del colectivo=0
|
|
colectivo=-1;
|
|
}
|
|
rs.close();
|
|
|
|
ParametrosConfiguracion.dataStore.liberarConexion(conexion);
|
|
LogTarisan.logger.log(NivelLog.DEBUG, "Seleccionado entidad y colectivo del cliente: " + cliente + " de la tabla TTBENEFI (" + sqlSelect + ")");
|
|
}
|
|
catch(SQLException sqle)
|
|
{
|
|
LogTarisan.logger.log(NivelLog.ERROR, "Error en la selección del entidad y colectivo del cliente: " + sqle + " (" + sqlSelect + ")");
|
|
throw new ExcepcionTarisan();
|
|
}
|
|
|
|
return colectivo;
|
|
}
|
|
|
|
public String obtenerIdentificador(String tarjetachipcard) throws ExcepcionTarisan
|
|
{
|
|
String identificador="";
|
|
StringBuffer sqlSelect = new StringBuffer();
|
|
LogTarisan.logger.log(NivelLog.DEBUG, "Obtenemos el identificador de la tarjeta "+tarjetachipcard+" introducida");
|
|
|
|
try
|
|
{
|
|
|
|
sqlSelect.append("SELECT TROQUELADO, TRATADO FROM TADESPLAZ");
|
|
sqlSelect.append(" WHERE TRIM(TARJETA_CHIPCARD) = TRIM(?)");
|
|
|
|
Connection conexion = ParametrosConfiguracion.dataStore.obtenerConexion();
|
|
|
|
Object aCondiciones[] = new Object[1];
|
|
aCondiciones[0] = new String(tarjetachipcard);
|
|
|
|
ResultSet rs = ParametrosConfiguracion.dataStore.seleccionar(conexion, sqlSelect.toString(), aCondiciones);
|
|
if(rs.next())
|
|
{
|
|
identificador=(rs.getString("TROQUELADO"));
|
|
|
|
}
|
|
rs.close();
|
|
|
|
ParametrosConfiguracion.dataStore.liberarConexion(conexion);
|
|
LogTarisan.logger.log(NivelLog.DEBUG, "Seleccionado el identificador de la tabla TADESPLAZ (" + sqlSelect + ")");
|
|
}
|
|
catch(SQLException sqle)
|
|
{
|
|
LogTarisan.logger.log(NivelLog.ERROR, "Error en la selección del identificador de la tabla TADESPLAZ: " + sqle + " (" + sqlSelect + ")");
|
|
throw new ExcepcionTarisan();
|
|
}
|
|
|
|
return identificador;
|
|
}
|
|
|
|
public String obtenerIdentificador(long col, Double pol, int ord) throws ExcepcionTarisan
|
|
{
|
|
String identificador="";
|
|
StringBuffer sqlSelect = new StringBuffer();
|
|
LogTarisan.logger.log(NivelLog.DEBUG, "Obtenemos el identificador del colectivo "+col+", poliza "+pol+"y orden "+ord+" introducidos");
|
|
|
|
try
|
|
{
|
|
|
|
sqlSelect.append("SELECT TRIM(IDENTIFICADOR) IDENTIFICADOR FROM TTBENEFI");
|
|
sqlSelect.append(" WHERE COLECTIVO = ?");
|
|
sqlSelect.append(" AND POLIZA = ?");
|
|
sqlSelect.append(" AND ORDEN = ?");
|
|
|
|
Connection conexion = ParametrosConfiguracion.dataStore.obtenerConexion();
|
|
|
|
Object aCondiciones[] = new Object[3];
|
|
aCondiciones[0] = Long.valueOf(col);
|
|
aCondiciones[1] = Double.valueOf(pol);
|
|
aCondiciones[2] = Integer.valueOf(ord);
|
|
|
|
ResultSet rs = ParametrosConfiguracion.dataStore.seleccionar(conexion, sqlSelect.toString(), aCondiciones);
|
|
if(rs.next())
|
|
{
|
|
if (rs.getString("IDENTIFICADOR")!=null)
|
|
identificador=(rs.getString("IDENTIFICADOR"));
|
|
|
|
}
|
|
rs.close();
|
|
|
|
ParametrosConfiguracion.dataStore.liberarConexion(conexion);
|
|
LogTarisan.logger.log(NivelLog.DEBUG, "Seleccionado el identificador de la tabla TTBENEFI (" + sqlSelect + ")");
|
|
}
|
|
catch(SQLException sqle)
|
|
{
|
|
LogTarisan.logger.log(NivelLog.ERROR, "Error en la selección del identificador de la tabla TTBENEFI: " + sqle + " (" + sqlSelect + ")");
|
|
throw new ExcepcionTarisan();
|
|
}
|
|
|
|
return identificador;
|
|
}
|
|
|
|
public String obtenerTarjetaChipcard(int col, long pol, int ord) throws ExcepcionTarisan
|
|
{
|
|
String tarjeta="";
|
|
StringBuffer sqlSelect = new StringBuffer();
|
|
LogTarisan.logger.log(NivelLog.DEBUG, "Obtenemos la tarjeta_chipcard del "+col + " - " + pol + " - " + ord +" introducidos");
|
|
|
|
try
|
|
{
|
|
|
|
sqlSelect.append("SELECT TARJETA_CHIPCARD FROM TTBENEFI");
|
|
sqlSelect.append(" WHERE COLECTIVO = ?");
|
|
sqlSelect.append(" AND POLIZA = ?");
|
|
sqlSelect.append(" AND ORDEN = ?");
|
|
|
|
Connection conexion = ParametrosConfiguracion.dataStore.obtenerConexion();
|
|
|
|
Object aCondiciones[] = new Object[3];
|
|
aCondiciones[0] = Integer.valueOf(col);
|
|
aCondiciones[1] = Long.valueOf(pol);
|
|
aCondiciones[2] = Integer.valueOf(ord);
|
|
|
|
ResultSet rs = ParametrosConfiguracion.dataStore.seleccionar(conexion, sqlSelect.toString(), aCondiciones);
|
|
if(rs.next())
|
|
{
|
|
tarjeta=(rs.getString("TARJETA_CHIPCARD"));
|
|
|
|
}
|
|
rs.close();
|
|
|
|
ParametrosConfiguracion.dataStore.liberarConexion(conexion);
|
|
LogTarisan.logger.log(NivelLog.DEBUG, "Seleccionada la tarjeta_chipcard de la tabla TTBENEFI (" + sqlSelect + ")");
|
|
}
|
|
catch(SQLException sqle)
|
|
{
|
|
LogTarisan.logger.log(NivelLog.ERROR, "Error en la selección de la tarjeta_chipcard de la tabla TTBENEFI: " + sqle + " (" + sqlSelect + ")");
|
|
throw new ExcepcionTarisan();
|
|
}
|
|
|
|
return tarjeta;
|
|
}
|
|
|
|
public String obtenerTarjeta(int col, long pol, int ord) throws ExcepcionTarisan
|
|
{
|
|
String tarjeta="";
|
|
StringBuffer sqlSelect = new StringBuffer();
|
|
LogTarisan.logger.log(NivelLog.DEBUG, "Obtenemos la tarjeta del "+col + " - " + pol + " - " + ord +" introducidos");
|
|
|
|
try
|
|
{
|
|
|
|
sqlSelect.append("SELECT TARJETA FROM TTBENEFI");
|
|
sqlSelect.append(" WHERE COLECTIVO = ?");
|
|
sqlSelect.append(" AND POLIZA = ?");
|
|
sqlSelect.append(" AND ORDEN = ?");
|
|
|
|
Connection conexion = ParametrosConfiguracion.dataStore.obtenerConexion();
|
|
|
|
Object aCondiciones[] = new Object[3];
|
|
aCondiciones[0] = Integer.valueOf(col);
|
|
aCondiciones[1] = Long.valueOf(pol);
|
|
aCondiciones[2] = Integer.valueOf(ord);
|
|
|
|
ResultSet rs = ParametrosConfiguracion.dataStore.seleccionar(conexion, sqlSelect.toString(), aCondiciones);
|
|
if(rs.next())
|
|
{
|
|
tarjeta=(rs.getString("TARJETA"));
|
|
|
|
}
|
|
rs.close();
|
|
|
|
ParametrosConfiguracion.dataStore.liberarConexion(conexion);
|
|
LogTarisan.logger.log(NivelLog.DEBUG, "Seleccionada la tarjeta de la tabla TTBENEFI (" + sqlSelect + ")");
|
|
}
|
|
catch(SQLException sqle)
|
|
{
|
|
LogTarisan.logger.log(NivelLog.ERROR, "Error en la selección de la tarjeta de la tabla TTBENEFI: " + sqle + " (" + sqlSelect + ")");
|
|
throw new ExcepcionTarisan();
|
|
}
|
|
|
|
return tarjeta;
|
|
}
|
|
|
|
public Long obtenerTarjeta(long col, Double pol, int ord) throws ExcepcionTarisan
|
|
{
|
|
long tarjeta=0;
|
|
StringBuffer sqlSelect = new StringBuffer();
|
|
LogTarisan.logger.log(NivelLog.DEBUG, "Obtenemos la tarjeta del "+col + " - " + pol + " - " + ord +" introducidos");
|
|
|
|
try
|
|
{
|
|
|
|
sqlSelect.append("SELECT TARJETA FROM TTBENEFI");
|
|
sqlSelect.append(" WHERE COLECTIVO = ?");
|
|
sqlSelect.append(" AND POLIZA = ?");
|
|
sqlSelect.append(" AND ORDEN = ?");
|
|
|
|
Connection conexion = ParametrosConfiguracion.dataStore.obtenerConexion();
|
|
|
|
Object aCondiciones[] = new Object[3];
|
|
aCondiciones[0] = Long.valueOf(col);
|
|
aCondiciones[1] = Double.valueOf(pol);
|
|
aCondiciones[2] = Integer.valueOf(ord);
|
|
|
|
ResultSet rs = ParametrosConfiguracion.dataStore.seleccionar(conexion, sqlSelect.toString(), aCondiciones);
|
|
if(rs.next())
|
|
{
|
|
tarjeta=(rs.getLong("TARJETA"));
|
|
|
|
}
|
|
rs.close();
|
|
|
|
ParametrosConfiguracion.dataStore.liberarConexion(conexion);
|
|
LogTarisan.logger.log(NivelLog.DEBUG, "Seleccionada la tarjeta de la tabla TTBENEFI (" + sqlSelect + ")");
|
|
}
|
|
catch(SQLException sqle)
|
|
{
|
|
LogTarisan.logger.log(NivelLog.ERROR, "Error en la selección de la tarjeta de la tabla TTBENEFI: " + sqle + " (" + sqlSelect + ")");
|
|
throw new ExcepcionTarisan();
|
|
}
|
|
|
|
return tarjeta;
|
|
}
|
|
} |