/** * @(#) PersistenciaVTamovextttactmed.java */ package com.tarisan.control; import com.tarisan.data.VTamovextTtactmed; import com.tarisan.log.*; import com.tarisan.util.Utilidades; import com.tarisan.excepcion.ExcepcionTarisan; import java.sql.*; import java.util.Vector; /** * Controla los accesos a la persistencia para la entidad VTamovextttactmed. * @author Dpto. Informática. * @version 1.0, 24/09/2003 */ public class PersistenciaVTamovextTtactmed { /** * El objeto Paginacion que controla el número de filas a mostrar por cada página. */ private Paginacion objPaginacion = new Paginacion(); /** * Obtiene el valor del objeto Paginacion para saber que página se está visualizando. * @return El objeto Paginacion. */ public Paginacion getPaginacion() { return objPaginacion; } /** * Selecciona los registros de la JOIN entre las tablas TAMOVEXT y ttactmed en función de la sentencia SELECT indicada. * @param sqlSelect La sentencia SELECT de selección. * @param pagina Número de página a mostrar. * @param aCondiciones Array que contiene los parámetros utilizados en la sentencia SELECT. * @return El Vector con los registros seleccionados (todos pertenencientes a la clase VTamovextttactmed). * @throws */ public Vector seleccionar(String sqlSelect, int pagina, Object[] aCondiciones) throws ExcepcionTarisan { int elementosPaginacion=1; Vector vResultado = new Vector(); VTamovextTtactmed Vtamovextttactmed = null; try { Connection conexion = ParametrosConfiguracion.dataStore.obtenerConexion(); ResultSet rs = ParametrosConfiguracion.dataStore.seleccionar(conexion, sqlSelect, aCondiciones); objPaginacion.inicializarPaginacion(rs); if (objPaginacion.getNumeroRegistrosTotales()!=0) { objPaginacion.realizarPaginacion(rs, pagina); while(rs.next() && (elementosPaginacion <= Paginacion.getFilasPorPagina())) { Vtamovextttactmed = new VTamovextTtactmed(); Vtamovextttactmed.setActo(rs.getInt("ACTO")); Vtamovextttactmed.setDescripcionActoMedico(rs.getString("DESCRIPCIONACTOMEDICO")); Vtamovextttactmed.setCantidad(rs.getInt("CANTIDAD")); Vtamovextttactmed.setPrecioActoMedico(rs.getDouble("PRECIOACTOMEDICO")); Vtamovextttactmed.setImporteActoMedico(Vtamovextttactmed.getCantidad() * Vtamovextttactmed.getPrecioActoMedico()); vResultado.addElement(Vtamovextttactmed); if (pagina!=0) //Se quiere realizar la paginacion elementosPaginacion++; } } rs.close(); ParametrosConfiguracion.dataStore.liberarConexion(conexion); LogTarisan.logger.log(NivelLog.DEBUG, "Seleccionados " + vResultado.size() + " registros de la tabla TAMOVEXT (" + sqlSelect + ")"); } catch (ExcepcionTarisan sqle) { LogTarisan.logger.log(NivelLog.ERROR, "Error en la selección de TAMOVEXT: " + sqle + " (" + sqlSelect + ")"); throw (ExcepcionTarisan)sqle; } catch(SQLException sqle) { LogTarisan.logger.log(NivelLog.ERROR, "Error en la selección de TAMOVEXT: " + sqle + " (" + sqlSelect + ")"); throw new ExcepcionTarisan(sqle.getMessage()); } catch(Exception sqle) { LogTarisan.logger.log(NivelLog.ERROR, "Error en la selección de TAMOVEXT: " + sqle + " (" + sqlSelect + ")"); throw new ExcepcionTarisan(sqle.getMessage()); } catch(Throwable sqle) { LogTarisan.logger.log(NivelLog.ERROR, "Error en la selección de TAMOVEXT: " + sqle + " (" + sqlSelect + ")"); throw new ExcepcionTarisan(sqle.getMessage()); } return vResultado; } public Vector listado_liquidaciones_por_medico(int medico, int especialidad, String fecha, int intPagina) { Vector resul = new Vector(); StringBuffer strSql = new StringBuffer(); Object [] aCondiciones = new Object[2]; String consulta = ""; strSql.append("SELECT TAMOVEXT.Acto, Count(TAMOVEXT.Acto) as cantidad, TAMOVEXT.Precio as precioActoMedico, TTACTMED.descripcion as descripcionActoMedico"); strSql.append(" FROM TAMOVEXT, TTACTMED"); strSql.append(" WHERE (TAMOVEXT.Acto = TTACTMED.Acto)"); strSql.append(" AND (TAMOVEXT.Especialidad = TTACTMED.Especialidad)"); strSql.append(" AND TAMOVEXT.Medico=?"); strSql.append(" AND TAMOVEXT.Especialidad=?"); strSql.append(" and tamovext.fecha >= to_date('01/"); strSql.append(fecha); strSql.append("','dd/mm/yyyy')"); strSql.append(" GROUP BY TAMOVEXT.Acto, TAMOVEXT.Precio, TTACTMED.descripcion"); strSql.append(" ORDER BY TAMOVEXT.Acto ASC"); aCondiciones[0] = Integer.valueOf( medico); aCondiciones[1] = Integer.valueOf( especialidad ); try { resul = this.seleccionar(strSql.toString(), intPagina, aCondiciones); consulta = Utilidades.obtenerSentenciaSQL(strSql, null, aCondiciones); } catch (ExcepcionTarisan e) { LogTarisan.logger.log(NivelLog.ERROR, "Error en la selección de Tamovext-ttactmed (listado_liquidaciones_por_medico): " + e + " (" + consulta + ")"); } return resul; } }