package com.ejie.ad74a.dao;

import java.rmi.UnmarshalException;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;
import javax.sql.DataSource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.dao.support.DataAccessUtils;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
import org.springframework.jdbc.support.GeneratedKeyHolder;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import com.ejie.ad74a.exceptions.ManagerErrors;
import com.ejie.ad74a.model.DatosTarea;
import com.ejie.ad74a.model.DatosTareaAportarDocu;
import com.ejie.ad74a.model.DatosTareaEstudio;
import com.ejie.ad74a.model.DatosTareaEstudioAlta;
import com.ejie.ad74a.model.DatosTareaEstudioBaja;
import com.ejie.ad74a.model.DatosTareaEstudioInforme;
import com.ejie.ad74a.model.DatosTareaEstudioModDireccion;
import com.ejie.ad74a.model.DatosTareaEstudioRevision;
import com.ejie.ad74a.model.MaestroTareas;
import com.ejie.ad74a.model.MaestroTiposDoc;
import com.ejie.ad74a.model.MaestroTramites;
import com.ejie.ad74a.model.TareasTramite;
import com.ejie.ad74a.model.TramitesExpediente;
import com.ejie.ad74a.util.UtilSQL;
import com.ejie.ad74a.util.comun.Utilidades;
import com.ejie.ad74a.util.comun.UtilidadesXML;
import com.ejie.ad74a.util.constantes.ProcedimientosEnum;
import com.ejie.ad74a.util.constantes.TareasEnum;
import com.ejie.ad74a.util.constantes.TramitesEnum;
import com.ejie.x38.dao.RowNumResultSetExtractor;
import com.ejie.x38.dto.JerarquiaDto;
import com.ejie.x38.dto.TableManager;
import com.ejie.x38.dto.TableManagerJerarquia;
import com.ejie.x38.dto.TableRequestDto;
import com.ejie.x38.dto.TableRowDto;

/**
 * TareasTramiteDaoImpl generated by UDA, 22-mar-2023 17:10:15.
 * 
 * @author UDA
 */

@Repository
@Transactional
public class TareasTramiteDaoImpl implements TareasTramiteDao {

	public static final String[] ORDER_BY_WHITE_LIST = new String[] { "IDTAREATRAM11", "IDESTADO11", "TASKGUID11",
			"FINICIO11", "FFIN11", "FNOTIFICACION11", "FACUSE11", "TEXTOREQ11", "FREGISTRO11", "NUMREGISTRO11",
			"ESTADODOCUMENTACION11", "IDNOTIFICACION11", "FALTA11", "USUALTA11", "FMODIF11", "USUMODIF11",
			"MATAREASIDTAREA38", "MATAREASTIPOTAREA38", "MATAREASDESCES38", "MATAREASDESCEU38", "TRAEXPIDTRAMITEEXP10",
			"TRAEXPIDEXPEDIENTE10", "TRAEXPIDESTADO10", "TRAEXPFINICIO10", "TRAEXPFREALIZACION10",
			"TRAEXPOBSERVACIONES10", "TRAEXPFALTA10", "TRAEXPUSUALTA10", "TRAEXPFMODIF10", "TRAEXPUSUMODIF10",
			"MATAREASIDTIPODOC38", "MATAREASIDTRAMITE38", "TRAEXPIDTRAMITE10" };

	private JdbcTemplate jdbcTemplate;
	private DataSource ds;
	private StringBuilder wherePS = new StringBuilder(" WHERE 1=1  ");

	public static final String SEQUENCE_TAREAS_TRAMITE = "SEQ_TAREAS_TRAMITE";

	private static final Logger logger = LoggerFactory.getLogger(TareasTramiteDaoImpl.class);

	/*
	 * ROW_MAPPERS
	 */
	private RowMapper<TareasTramite> rwMap = new RowMapper<TareasTramite>() {
		public TareasTramite mapRow(ResultSet resultSet, int rowNum) throws SQLException {

			TareasTramite tareasTramite = new TareasTramite(UtilSQL.getLong(resultSet, "IDTAREATRAM11"),
					resultSet.getString("IDESTADO11"), resultSet.getString("TASKGUID11"),
					resultSet.getDate("FINICIO11"), resultSet.getDate("FFIN11"), resultSet.getDate("FNOTIFICACION11"),
					resultSet.getDate("FACUSE11"), resultSet.getString("TEXTOREQ11"), resultSet.getDate("FREGISTRO11"),
					resultSet.getString("NUMREGISTRO11"), resultSet.getString("ESTADODOCUMENTACION11"),
					resultSet.getString("IDNOTIFICACION11"), resultSet.getDate("FALTA11"),
					resultSet.getString("USUALTA11"), resultSet.getDate("FMODIF11"), resultSet.getString("USUMODIF11"),
					new MaestroTareas(UtilSQL.getLong(resultSet, "MATAREASIDTAREA38"),
							resultSet.getString("MATAREASTIPOTAREA38"), resultSet.getString("MATAREASDESCES38"),
							resultSet.getString("MATAREASDESCEU38"),
							new MaestroTiposDoc(UtilSQL.getLong(resultSet, "MATAREASIDTIPODOC38"), null, null, null,
									null, null, null, null, null, null),
							new MaestroTramites(UtilSQL.getLong(resultSet, "MATAREASIDTRAMITE38"), null, null, null,
									null)),
					new TramitesExpediente(UtilSQL.getLong(resultSet, "TRAEXPIDTRAMITEEXP10"),
							UtilSQL.getLong(resultSet, "TRAEXPIDEXPEDIENTE10"), resultSet.getString("TRAEXPIDESTADO10"),
							resultSet.getDate("TRAEXPFINICIO10"), resultSet.getDate("TRAEXPFREALIZACION10"),
							resultSet.getString("TRAEXPOBSERVACIONES10"), resultSet.getDate("TRAEXPFALTA10"),
							resultSet.getString("TRAEXPUSUALTA10"), resultSet.getDate("TRAEXPFMODIF10"),
							resultSet.getString("TRAEXPUSUMODIF10"), new MaestroTramites(
									UtilSQL.getLong(resultSet, "TRAEXPIDTRAMITE10"), null, null, null, null),
							null),
					resultSet.getClob("DATOSTAREA11"));

			String datosTareaXml = tareasTramite.getDatosTareaStr();

			if (!Utilidades.esBlancoNulo(datosTareaXml)) {
				DatosTarea datosTarea = null;
				try {
					datosTarea = (DatosTarea) UtilidadesXML.unmarshallerObject(datosTareaXml, DatosTarea.class);

					Long idTarea = datosTarea.getIdTarea();

					if (TareasEnum.ESTUDIO.getId().equals(idTarea)) {
						DatosTareaEstudio datosTareaEstudio = (DatosTareaEstudio) UtilidadesXML
								.unmarshallerObject(datosTareaXml, DatosTareaEstudio.class);
						String idProcedimiento00 = datosTareaEstudio.getIdProcedimiento00();
						if (ProcedimientosEnum.ALTA.getId().equalsIgnoreCase(idProcedimiento00)) {
							// ESTUDIO ALTA
							DatosTareaEstudioAlta datosTareaEstudioAlta = (DatosTareaEstudioAlta) UtilidadesXML
									.unmarshallerObject(datosTareaXml, DatosTareaEstudioAlta.class);
							tareasTramite.setDatosTareaEstudioAlta(datosTareaEstudioAlta);
						} else if (ProcedimientosEnum.BAJA.getId().equalsIgnoreCase(idProcedimiento00)) {
							// ESTUDIO BAJA
							DatosTareaEstudioBaja datosTareaEstudiobaja = (DatosTareaEstudioBaja) UtilidadesXML
									.unmarshallerObject(datosTareaXml, DatosTareaEstudioBaja.class);
							tareasTramite.setDatosTareaEstudioBaja(datosTareaEstudiobaja);
						} else if (ProcedimientosEnum.MODIFICACION.getId().equalsIgnoreCase(idProcedimiento00)) {
							// ESTUDIO MODIFICACION
							DatosTareaEstudioModDireccion datosTareaEstudioModDireccion = (DatosTareaEstudioModDireccion) UtilidadesXML
									.unmarshallerObject(datosTareaXml, DatosTareaEstudioModDireccion.class);
							tareasTramite.setDatosTareaEstudioModDireccion(datosTareaEstudioModDireccion);
						} else if (ProcedimientosEnum.INFORME.getId().equalsIgnoreCase(idProcedimiento00)) {
							// ESTUDIO INFORME
							DatosTareaEstudioInforme datosTareaEstudioInforme = (DatosTareaEstudioInforme) UtilidadesXML
									.unmarshallerObject(datosTareaXml, DatosTareaEstudioInforme.class);
							tareasTramite.setDatosTareaEstudioInforme(datosTareaEstudioInforme);
						} else if (ProcedimientosEnum.REVISION_PRECIO.getId().equalsIgnoreCase(idProcedimiento00)) {
							// ESTUDIO REVISION_PRECIO
							DatosTareaEstudioRevision datosTareaEstudioRevision = (DatosTareaEstudioRevision) UtilidadesXML
									.unmarshallerObject(datosTareaXml, DatosTareaEstudioRevision.class);
							tareasTramite.setDatosTareaEstudioRevision(datosTareaEstudioRevision);
						}
					} else if (TareasEnum.ADJUNTAR_DOCUMENTACION.getId().equals(idTarea)) {
						DatosTareaAportarDocu datosTareaAportarDocu = (DatosTareaAportarDocu) UtilidadesXML
								.unmarshallerObject(datosTareaXml, DatosTareaAportarDocu.class);
						tareasTramite.setDatosTareaAportarDocu(datosTareaAportarDocu);
					}

				} catch (UnmarshalException e) {
					ManagerErrors.manageException(e, "Error al parsear el CLOB de los datos de tarea");
				}
			}
			return tareasTramite;

		}
	};

	private RowMapper<TareasTramite> rwMapPK = new RowMapper<TareasTramite>() {
		public TareasTramite mapRow(ResultSet resultSet, int rowNum) throws SQLException {
			return new TareasTramite(UtilSQL.getLong(resultSet, "IDTAREATRAM11"));
		}
	};

	/**
	 * Rowmapper para Jerarquía
	 *
	 * @param dataSource DataSource
	 * @return
	 */
	private RowMapper<JerarquiaDto<TareasTramite>> rwMapJerarquia = new RowMapper<JerarquiaDto<TareasTramite>>() {
		public JerarquiaDto<TareasTramite> mapRow(ResultSet resultSet, int rowNum) throws SQLException {

			TareasTramite tareastramite = new TareasTramite(UtilSQL.getLong(resultSet, "IDTAREATRAM11"),
					resultSet.getString("IDESTADO11"), resultSet.getString("TASKGUID11"),
					resultSet.getDate("FINICIO11"), resultSet.getDate("FFIN11"), resultSet.getDate("FNOTIFICACION11"),
					resultSet.getDate("FACUSE11"), resultSet.getString("TEXTOREQ11"), resultSet.getDate("FREGISTRO11"),
					resultSet.getString("NUMREGISTRO11"), resultSet.getString("ESTADODOCUMENTACION11"),
					resultSet.getString("IDNOTIFICACION11"), resultSet.getDate("FALTA11"),
					resultSet.getString("USUALTA11"), resultSet.getDate("FMODIF11"), resultSet.getString("USUMODIF11"),
					new MaestroTareas(UtilSQL.getLong(resultSet, "MATAREASIDTAREA38"),
							resultSet.getString("MATAREASTIPOTAREA38"), resultSet.getString("MATAREASDESCES38"),
							resultSet.getString("MATAREASDESCEU38"),
							new MaestroTiposDoc(UtilSQL.getLong(resultSet, "MATAREASIDTIPODOC38"), null, null, null,
									null, null, null, null, null, null),
							new MaestroTramites(UtilSQL.getLong(resultSet, "MATAREASIDTRAMITE38"), null, null, null,
									null)),
					new TramitesExpediente(UtilSQL.getLong(resultSet, "TRAEXPIDTRAMITEEXP10"),
							UtilSQL.getLong(resultSet, "TRAEXPIDEXPEDIENTE10"), resultSet.getString("TRAEXPIDESTADO10"),
							resultSet.getDate("TRAEXPFINICIO10"), resultSet.getDate("TRAEXPFREALIZACION10"),
							resultSet.getString("TRAEXPOBSERVACIONES10"), resultSet.getDate("TRAEXPFALTA10"),
							resultSet.getString("TRAEXPUSUALTA10"), resultSet.getDate("TRAEXPFMODIF10"),
							resultSet.getString("TRAEXPUSUMODIF10"), new MaestroTramites(
									UtilSQL.getLong(resultSet, "TRAEXPIDTRAMITE10"), null, null, null, null),
							null),
					resultSet.getClob("DATOSTAREA11"));

			JerarquiaDto<TareasTramite> jerarquia = new JerarquiaDto<TareasTramite>();
			jerarquia.setModel(tareastramite);
			jerarquia.setLevel(resultSet.getBigDecimal("LEVEL").intValue());
			jerarquia.setParentNodes(resultSet.getString("PARENTNODES"));
			jerarquia.setIsLeaf(Boolean.parseBoolean(resultSet.getString("ISLEAF")));
			jerarquia.setFilter(Boolean.parseBoolean(resultSet.getString("FILTER")));
			return jerarquia;
		}
	};

	/**
	 * Method use to set the datasource.
	 *
	 * @param dataSource DataSource
	 * @return
	 */
	@Resource
	public void setDataSource(DataSource dataSource) {
		this.jdbcTemplate = new JdbcTemplate(dataSource);
	}

	/*
	 * OPERACIONES CRUD
	 */

	/**
	 * Inserts a single row in the TareasTramite table.
	 *
	 * @param tareastramite TareasTramite
	 * @return TareasTramite
	 */
	public TareasTramite add(TareasTramite tareastramite) {

		GeneratedKeyHolder generatedKeyHolder = new GeneratedKeyHolder();

		String query = "INSERT INTO TAREAS_TRAMITE (ID_TAREA_TRAM_11, ID_TAREA_11, ID_TRAMITE_EXP_11, ID_ESTADO_11, TASKGUID_11, F_INICIO_11, F_FIN_11, F_NOTIFICACION_11, F_ACUSE_11, TEXTO_REQ_11, F_REGISTRO_11, NUM_REGISTRO_11, ESTADO_DOCUMENTACION_11, ID_NOTIFICACION_11, F_ALTA_11, USU_ALTA_11, F_MODIF_11, USU_MODIF_11) "
				+ "VALUES (" + SEQUENCE_TAREAS_TRAMITE
				+ ".NEXTVAL,:idTarea,:idTramiteExp,:idEstado,:taskGuid,:fInicio,:fFin,:fNotificacion,:fAcuse,:texReq,:fRegistro,:numRegistro,:estadoDoc,:idNotif,sysdate,:usuAlta,sysdate,:usuModif)";
		Object getMaestroTareasIdTarea38Aux = null;
		if (tareastramite.getMaestroTareas() != null && tareastramite.getMaestroTareas().getIdTarea38() != null) {
			getMaestroTareasIdTarea38Aux = tareastramite.getMaestroTareas().getIdTarea38();
		}
		Object getTramitesExpedienteIdTramiteExp10Aux = null;
		if (tareastramite.getTramitesExpediente() != null
				&& tareastramite.getTramitesExpediente().getIdTramiteExp10() != null) {
			getTramitesExpedienteIdTramiteExp10Aux = tareastramite.getTramitesExpediente().getIdTramiteExp10();
		}
		MapSqlParameterSource parameters = new MapSqlParameterSource().addValue("idTarea", getMaestroTareasIdTarea38Aux)
				.addValue("idTramiteExp", getTramitesExpedienteIdTramiteExp10Aux)
				.addValue("idEstado", tareastramite.getIdEstado11()).addValue("taskGuid", tareastramite.getTaskguid11())
				.addValue("fInicio", tareastramite.getfInicio11()).addValue("fFin", tareastramite.getfFin11())
				.addValue("fNotificacion", tareastramite.getfNotificacion11())
				.addValue("fAcuse", tareastramite.getfAcuse11()).addValue("texReq", tareastramite.getTextoReq11())
				.addValue("fRegistro", tareastramite.getfRegistro11())
				.addValue("numRegistro", tareastramite.getNumRegistro11())
				.addValue("estadoDoc", tareastramite.getEstadoDocumentacion11())
				.addValue("idNotif", tareastramite.getIdNotificacion11())
				.addValue("usuAlta", tareastramite.getUsuAlta11()).addValue("usuModif", tareastramite.getUsuModif11());

		NamedParameterJdbcTemplate namedParameterJdbcTemplate = new NamedParameterJdbcTemplate(jdbcTemplate);
		namedParameterJdbcTemplate.update(query, parameters, generatedKeyHolder, new String[] { "ID_TAREA_TRAM_11" });
		tareastramite.setIdTareaTram11(generatedKeyHolder.getKey().longValue());

		return tareastramite;
	}

	/**
	 * Updates a single row in the TareasTramite table.
	 *
	 * @param tareastramite TareasTramite
	 * @return TareasTramite
	 */
	public TareasTramite update(TareasTramite tareastramite) {
		String query = "UPDATE TAREAS_TRAMITE SET ID_TAREA_11=?, ID_TRAMITE_EXP_11=?, ID_ESTADO_11=?, TASKGUID_11=?, F_INICIO_11=?, F_FIN_11=?, F_NOTIFICACION_11=?, F_ACUSE_11=?, TEXTO_REQ_11=?, F_REGISTRO_11=?, NUM_REGISTRO_11=?, ESTADO_DOCUMENTACION_11=?, ID_NOTIFICACION_11=?, F_ALTA_11=?, USU_ALTA_11=?, F_MODIF_11=?, USU_MODIF_11=?, DATOS_TAREA_11 = ? WHERE ID_TAREA_TRAM_11=?";
		Object getMaestroTareasIdTarea38Aux = null;
		if (tareastramite.getMaestroTareas() != null && tareastramite.getMaestroTareas().getIdTarea38() != null) {
			getMaestroTareasIdTarea38Aux = tareastramite.getMaestroTareas().getIdTarea38();
		}
		Object getTramitesExpedienteIdTramiteExp10Aux = null;
		if (tareastramite.getTramitesExpediente() != null
				&& tareastramite.getTramitesExpediente().getIdTramiteExp10() != null) {
			getTramitesExpedienteIdTramiteExp10Aux = tareastramite.getTramitesExpediente().getIdTramiteExp10();
		}

		this.jdbcTemplate.update(query, getMaestroTareasIdTarea38Aux, getTramitesExpedienteIdTramiteExp10Aux,
				tareastramite.getIdEstado11(), tareastramite.getTaskguid11(), tareastramite.getfInicio11(),
				tareastramite.getfFin11(), tareastramite.getfNotificacion11(), tareastramite.getfAcuse11(),
				tareastramite.getTextoReq11(), tareastramite.getfRegistro11(), tareastramite.getNumRegistro11(),
				tareastramite.getEstadoDocumentacion11(), tareastramite.getIdNotificacion11(),
				tareastramite.getfAlta11(), tareastramite.getUsuAlta11(), tareastramite.getfModif11(),
				tareastramite.getUsuModif11(), UtilSQL.clobToString(tareastramite.getDatosTarea11()),
				tareastramite.getIdTareaTram11());
		return tareastramite;
	}

	/**
	 * Finds a single row in the TareasTramite table.
	 *
	 * @param tareastramite TareasTramite
	 * @return TareasTramite
	 */
	@Transactional(readOnly = true)
	public TareasTramite find(TareasTramite tareastramite) {
		StringBuilder query = new StringBuilder(
				"SELECT t1.ID_TAREA_TRAM_11 IDTAREATRAM11, t1.ID_ESTADO_11 IDESTADO11, t1.TASKGUID_11 TASKGUID11, t1.F_INICIO_11 FINICIO11, t1.F_FIN_11 FFIN11, t1.F_NOTIFICACION_11 FNOTIFICACION11, t1.F_ACUSE_11 FACUSE11, t1.TEXTO_REQ_11 TEXTOREQ11, t1.F_REGISTRO_11 FREGISTRO11, t1.NUM_REGISTRO_11 NUMREGISTRO11, t1.ESTADO_DOCUMENTACION_11 ESTADODOCUMENTACION11, t1.ID_NOTIFICACION_11 IDNOTIFICACION11, t1.F_ALTA_11 FALTA11, t1.USU_ALTA_11 USUALTA11, t1.F_MODIF_11 FMODIF11, t1.USU_MODIF_11 USUMODIF11, t1.DATOS_TAREA_11 DATOSTAREA11 ");
		query.append(
				" ,t2.ID_TAREA_38 MATAREASIDTAREA38, t2.TIPO_TAREA_38 MATAREASTIPOTAREA38, t2.DESC_ES_38 MATAREASDESCES38, t2.DESC_EU_38 MATAREASDESCEU38");
		query.append(
				" ,t3.ID_TRAMITE_EXP_10 TRAEXPIDTRAMITEEXP10, t3.ID_EXPEDIENTE_10 TRAEXPIDEXPEDIENTE10, t3.ID_ESTADO_10 TRAEXPIDESTADO10, t3.F_INICIO_10 TRAEXPFINICIO10, t3.F_REALIZACION_10 TRAEXPFREALIZACION10, t3.OBSERVACIONES_10 TRAEXPOBSERVACIONES10, t3.F_ALTA_10 TRAEXPFALTA10, t3.USU_ALTA_10 TRAEXPUSUALTA10, t3.F_MODIF_10 TRAEXPFMODIF10, t3.USU_MODIF_10 TRAEXPUSUMODIF10, t2.ID_TIPO_DOC_38 MATAREASIDTIPODOC38, t2.ID_TRAMITE_38 MATAREASIDTRAMITE38, t3.ID_TRAMITE_10 TRAEXPIDTRAMITE10 FROM TAREAS_TRAMITE t1 , MAESTRO_TAREAS t2 , TRAMITES_EXPEDIENTE t3  WHERE t1.ID_TAREA_TRAM_11 = ?   AND t1.ID_TAREA_11= t2.ID_TAREA_38(+) AND t1.ID_TRAMITE_EXP_11= t3.ID_TRAMITE_EXP_10(+)");

		List<TareasTramite> tareastramiteList = this.jdbcTemplate.query(query.toString(), this.rwMap,
				tareastramite.getIdTareaTram11());
		return (TareasTramite) DataAccessUtils.uniqueResult(tareastramiteList);
	}

	/**
	 * Removes a single row in the TareasTramite table.
	 *
	 * @param tareastramite TareasTramite
	 * @return
	 */
	public void remove(TareasTramite tareastramite) {
		String query = "DELETE FROM TAREAS_TRAMITE WHERE ID_TAREA_TRAM_11=?";
		this.jdbcTemplate.update(query, tareastramite.getIdTareaTram11());
	}

	/**
	 * Exporta Datos al clipBoard
	 *
	 */
	public List<TareasTramite> getMultiple(TareasTramite filterTareasTramite, TableRequestDto tableRequestDto,
			Boolean startsWith) {

		StringBuilder query = new StringBuilder(
				"SELECT t1.ID_TAREA_TRAM_11 IDTAREATRAM11, t1.ID_ESTADO_11 IDESTADO11, t1.TASKGUID_11 TASKGUID11, t1.F_INICIO_11 FINICIO11, t1.F_FIN_11 FFIN11, t1.F_NOTIFICACION_11 FNOTIFICACION11, t1.F_ACUSE_11 FACUSE11, t1.TEXTO_REQ_11 TEXTOREQ11, t1.F_REGISTRO_11 FREGISTRO11, t1.NUM_REGISTRO_11 NUMREGISTRO11, t1.ESTADO_DOCUMENTACION_11 ESTADODOCUMENTACION11, t1.ID_NOTIFICACION_11 IDNOTIFICACION11, t1.F_ALTA_11 FALTA11, t1.USU_ALTA_11 USUALTA11, t1.F_MODIF_11 FMODIF11, t1.USU_MODIF_11 USUMODIF11, t1.DATOS_TAREA_11 DATOSTAREA11 ");
		query.append(
				", t2.ID_TAREA_38 MATAREASIDTAREA38, t2.TIPO_TAREA_38 MATAREASTIPOTAREA38, t2.DESC_ES_38 MATAREASDESCES38, t2.DESC_EU_38 MATAREASDESCEU38");
		query.append(
				", t3.ID_TRAMITE_EXP_10 TRAEXPIDTRAMITEEXP10, t3.ID_EXPEDIENTE_10 TRAEXPIDEXPEDIENTE10, t3.ID_ESTADO_10 TRAEXPIDESTADO10, t3.F_INICIO_10 TRAEXPFINICIO10, t3.F_REALIZACION_10 TRAEXPFREALIZACION10, t3.OBSERVACIONES_10 TRAEXPOBSERVACIONES10, t3.F_ALTA_10 TRAEXPFALTA10, t3.USU_ALTA_10 TRAEXPUSUALTA10, t3.F_MODIF_10 TRAEXPFMODIF10, t3.USU_MODIF_10 TRAEXPUSUMODIF10, t2.ID_TIPO_DOC_38 MATAREASIDTIPODOC38, t2.ID_TRAMITE_38 MATAREASIDTRAMITE38, t3.ID_TRAMITE_10 TRAEXPIDTRAMITE10");
		query.append(" FROM TAREAS_TRAMITE t1 , MAESTRO_TAREAS t2 , TRAMITES_EXPEDIENTE t3  ");
		// Where clause & Params
		Map<String, Object> mapaWhere = this.getWhereLikeMap(filterTareasTramite, startsWith);
		StringBuilder where = new StringBuilder(query + " WHERE 1=1 ");
		where.append(mapaWhere.get("query"));

		@SuppressWarnings("unchecked")
		List<Object> params = (List<Object>) mapaWhere.get("params");

		StringBuilder sbMultipleSQL = TableManager.getSelectMultipleQuery(tableRequestDto, TareasTramite.class, params,
				"ID_TAREA_TRAM_11");
		where.append(sbMultipleSQL);

		return this.jdbcTemplate.query(where.toString(), this.rwMap, params.toArray());
	}

	/**
	 * Finds a list of rows in the TareasTramite table.
	 *
	 * @param tareastramite   TareasTramite
	 * @param tableRequestDto TableRequestDto
	 * @return List<TareasTramite>
	 */
	@Transactional(readOnly = true)
	public List<TareasTramite> findAll(TareasTramite tareastramite, TableRequestDto tableRequestDto) {
		StringBuilder query = new StringBuilder(
				"SELECT  t1.ID_TAREA_TRAM_11 IDTAREATRAM11,t1.ID_ESTADO_11 IDESTADO11,t1.TASKGUID_11 TASKGUID11,t1.F_INICIO_11 FINICIO11,t1.F_FIN_11 FFIN11,t1.F_NOTIFICACION_11 FNOTIFICACION11,t1.F_ACUSE_11 FACUSE11,t1.TEXTO_REQ_11 TEXTOREQ11,t1.F_REGISTRO_11 FREGISTRO11,t1.NUM_REGISTRO_11 NUMREGISTRO11,t1.ESTADO_DOCUMENTACION_11 ESTADODOCUMENTACION11,t1.ID_NOTIFICACION_11 IDNOTIFICACION11,t1.F_ALTA_11 FALTA11,t1.USU_ALTA_11 USUALTA11,t1.F_MODIF_11 FMODIF11,t1.USU_MODIF_11 USUMODIF11, t1.DATOS_TAREA_11 DATOSTAREA11 "
						+ ",t2.ID_TAREA_38 MATAREASIDTAREA38,t2.TIPO_TAREA_38 MATAREASTIPOTAREA38,t2.DESC_ES_38 MATAREASDESCES38,t2.DESC_EU_38 MATAREASDESCEU38,"
						+ "t3.ID_TRAMITE_EXP_10 TRAEXPIDTRAMITEEXP10,t3.ID_EXPEDIENTE_10 TRAEXPIDEXPEDIENTE10,t3.ID_ESTADO_10 TRAEXPIDESTADO10,t3.F_INICIO_10 TRAEXPFINICIO10,t3.F_REALIZACION_10 TRAEXPFREALIZACION10,t3.OBSERVACIONES_10 TRAEXPOBSERVACIONES10,t3.F_ALTA_10 TRAEXPFALTA10,t3.USU_ALTA_10 TRAEXPUSUALTA10,t3.F_MODIF_10 TRAEXPFMODIF10,t3.USU_MODIF_10 TRAEXPUSUMODIF10,t2.ID_TIPO_DOC_38 MATAREASIDTIPODOC38,t2.ID_TRAMITE_38 MATAREASIDTRAMITE38,t3.ID_TRAMITE_10 TRAEXPIDTRAMITE10 ");
		query.append("FROM TAREAS_TRAMITE t1 ,MAESTRO_TAREAS t2 ,TRAMITES_EXPEDIENTE t3 ");

		// Where clause & Params

		Map<String, ?> mapaWhere = this.getWhereMap(tareastramite);
		StringBuilder where = new StringBuilder(
				" WHERE 1=1 AND t1.ID_TAREA_11= t2.ID_TAREA_38(+) AND t1.ID_TRAMITE_EXP_11= t3.ID_TRAMITE_EXP_10(+) ");
		where.append(mapaWhere.get("query"));
		query.append(where);

		List<?> params = (List<?>) mapaWhere.get("params");

		// CSI-IM-Problema TimeOut Tramitación. Nueva conexion.
		/*
		 * ds = new DataSourceImpl("ad74a.ad74aDataSource",
		 * "jdbc:oracle:thin:@//ad74d:1530/ad74.ejie.eus", "ad74a", "ad74a"); // ds =
		 * new weblogic.jdbc.jta.DataSource(); try (Connection con = ds.getConnection();
		 * PreparedStatement ps = con.prepareStatement(query.toString());) { ps =
		 * this.getWhereMapPS(tareastramite, ps);
		 * 
		 * wherePS.
		 * append(" AND t1.ID_TAREA_11= t2.ID_TAREA_38(+) AND t1.ID_TRAMITE_EXP_11= t3.ID_TRAMITE_EXP_10(+)"
		 * ); query.append(wherePS); if (tableRequestDto != null) { query =
		 * TableManager.getPaginationQuery(tableRequestDto, query,
		 * TareasTramiteDaoImpl.ORDER_BY_WHITE_LIST); } ResultSet rs =
		 * ps.executeQuery(); rs.setFetchSize(200); return (List<TareasTramite>)
		 * this.rwMap(rs,null); } catch (SQLException e) {
		 * 
		 * }
		 */

		if (tableRequestDto != null) {
			query = TableManager.getPaginationQuery(tableRequestDto, query, TareasTramiteDaoImpl.ORDER_BY_WHITE_LIST);
		}
		return (List<TareasTramite>) this.jdbcTemplate.query(query.toString(), this.rwMap, params.toArray());
	}

	/**
	 * Finds rows in the TareasTramite table using like.
	 *
	 * @param tareastramite   TareasTramite
	 * @param tableRequestDto TableRequestDto
	 * @param startsWith      Boolean
	 * @return List<TareasTramite>
	 */
	@Transactional(readOnly = true)
	public List<TareasTramite> findAllLike(TareasTramite tareastramite, TableRequestDto tableRequestDto,
			Boolean startsWith) {
		StringBuilder query = new StringBuilder(
				"SELECT  t1.ID_TAREA_TRAM_11 IDTAREATRAM11,t1.ID_ESTADO_11 IDESTADO11,t1.TASKGUID_11 TASKGUID11,t1.F_INICIO_11 FINICIO11,t1.F_FIN_11 FFIN11,t1.F_NOTIFICACION_11 FNOTIFICACION11,t1.F_ACUSE_11 FACUSE11,t1.TEXTO_REQ_11 TEXTOREQ11,t1.F_REGISTRO_11 FREGISTRO11,t1.NUM_REGISTRO_11 NUMREGISTRO11,t1.ESTADO_DOCUMENTACION_11 ESTADODOCUMENTACION11,t1.ID_NOTIFICACION_11 IDNOTIFICACION11,t1.F_ALTA_11 FALTA11,t1.USU_ALTA_11 USUALTA11,t1.F_MODIF_11 FMODIF11,t1.USU_MODIF_11 USUMODIF11,, t1.DATOS_TAREA_11 DATOSTAREA11 ");
		query.append(
				"t2.ID_TAREA_38 MATAREASIDTAREA38,t2.TIPO_TAREA_38 MATAREASTIPOTAREA38,t2.DESC_ES_38 MATAREASDESCES38,t2.DESC_EU_38 MATAREASDESCEU38,");
		query.append(
				"t3.ID_TRAMITE_EXP_10 TRAEXPIDTRAMITEEXP10,t3.ID_EXPEDIENTE_10 TRAEXPIDEXPEDIENTE10,t3.ID_ESTADO_10 TRAEXPIDESTADO10,t3.F_INICIO_10 TRAEXPFINICIO10,t3.F_REALIZACION_10 TRAEXPFREALIZACION10,t3.OBSERVACIONES_10 TRAEXPOBSERVACIONES10,t3.F_ALTA_10 TRAEXPFALTA10,t3.USU_ALTA_10 TRAEXPUSUALTA10,t3.F_MODIF_10 TRAEXPFMODIF10,t3.USU_MODIF_10 TRAEXPUSUMODIF10,t2.ID_TIPO_DOC_38 MATAREASIDTIPODOC38,t2.ID_TRAMITE_38 MATAREASIDTRAMITE38,t3.ID_TRAMITE_10 TRAEXPIDTRAMITE10 ");
		query.append("FROM TAREAS_TRAMITE t1 ,MAESTRO_TAREAS t2 ,TRAMITES_EXPEDIENTE t3 ");

		// Where clause & Params
		Map<String, ?> mapaWhere = this.getWhereLikeMap(tareastramite, startsWith);
		StringBuilder where = new StringBuilder(
				" WHERE 1=1 AND t1.ID_TAREA_11= t2.ID_TAREA_38(+) AND t1.ID_TRAMITE_EXP_11= t3.ID_TRAMITE_EXP_10(+) ");
		where.append(mapaWhere.get("query"));
		query.append(where);

		List<?> params = (List<?>) mapaWhere.get("params");

		if (tableRequestDto != null) {
			query = TableManager.getPaginationQuery(tableRequestDto, query, TareasTramiteDaoImpl.ORDER_BY_WHITE_LIST);
		}

		return (List<TareasTramite>) this.jdbcTemplate.query(query.toString(), this.rwMap, params.toArray());
	}

	/*
	 * OPERACIONES RUP_TABLE
	 */

	/**
	 * Counts rows in the TareasTramite table.
	 *
	 * @param tareastramite TareasTramite
	 * @return Long
	 */
	@Transactional(readOnly = true)
	public Long findAllCount(TareasTramite tareastramite) {
		StringBuilder query = new StringBuilder(
				"SELECT COUNT(1) FROM TAREAS_TRAMITE t1 , MAESTRO_TAREAS t2 , TRAMITES_EXPEDIENTE t3 ");

		// Where clause & Params
		Map<String, ?> mapaWhere = this.getWhereMap(tareastramite);
		StringBuilder where = new StringBuilder(
				" WHERE 1=1 AND t1.ID_TAREA_11= t2.ID_TAREA_38(+) AND t1.ID_TRAMITE_EXP_11= t3.ID_TRAMITE_EXP_10(+) ");
		where.append(mapaWhere.get("query"));
		query.append(where);

		List<?> params = (List<?>) mapaWhere.get("params");

		return this.jdbcTemplate.queryForObject(query.toString(), params.toArray(), Long.class);
	}

	/**
	 * Counts rows in the TareasTramite table using like.
	 *
	 * @param tareastramite TareasTramite
	 * @param startsWith    Boolean
	 * @return Long
	 */
	@Transactional(readOnly = true)
	public Long findAllLikeCount(TareasTramite tareastramite, Boolean startsWith) {
		StringBuilder query = new StringBuilder(
				"SELECT COUNT(1) FROM TAREAS_TRAMITE t1 ,MAESTRO_TAREAS t2 ,TRAMITES_EXPEDIENTE t3 ");

		// Where clause & Params
		Map<String, ?> mapaWhere = this.getWhereLikeMap(tareastramite, startsWith);
		StringBuilder where = new StringBuilder(
				" WHERE 1=1 AND t1.ID_TAREA_11= t2.ID_TAREA_38(+) AND t1.ID_TRAMITE_EXP_11= t3.ID_TRAMITE_EXP_10(+) ");
		where.append(mapaWhere.get("query"));
		query.append(where);

		List<?> params = (List<?>) mapaWhere.get("params");

		return this.jdbcTemplate.queryForObject(query.toString(), params.toArray(), Long.class);
	}

	/**
	 * Reorder the data list of TareasTramite selected for rup_table
	 *
	 * @param tareastramite   TareasTramite
	 * @param tableRequestDto TableRequestDto
	 * @param startsWith      Boolean
	 * @return List<TableRowDto<TareasTramite>>
	 */
	@Override
	public List<TableRowDto<TareasTramite>> reorderSelection(TareasTramite tareastramite,
			TableRequestDto tableRequestDto, Boolean startsWith) {
		// SELECT
		StringBuilder query = new StringBuilder(
				"SELECT t1.ID_TAREA_TRAM_11 IDTAREATRAM11,t1.ID_ESTADO_11 IDESTADO11,t1.TASKGUID_11 TASKGUID11,t1.F_INICIO_11 FINICIO11,t1.F_FIN_11 FFIN11,t1.F_NOTIFICACION_11 FNOTIFICACION11,t1.F_ACUSE_11 FACUSE11,t1.TEXTO_REQ_11 TEXTOREQ11,t1.F_REGISTRO_11 FREGISTRO11,t1.NUM_REGISTRO_11 NUMREGISTRO11,t1.ESTADO_DOCUMENTACION_11 ESTADODOCUMENTACION11,t1.ID_NOTIFICACION_11 IDNOTIFICACION11,t1.F_ALTA_11 FALTA11,t1.USU_ALTA_11 USUALTA11,t1.F_MODIF_11 FMODIF11,t1.USU_MODIF_11 USUMODIF11,t2.ID_TAREA_38 MATAREASIDTAREA38,t2.TIPO_TAREA_38 MATAREASTIPOTAREA38,t2.DESC_ES_38 MATAREASDESCES38,t2.DESC_EU_38 MATAREASDESCEU38,t3.ID_TRAMITE_EXP_10 TRAEXPIDTRAMITEEXP10,t3.ID_EXPEDIENTE_10 TRAEXPIDEXPEDIENTE10,t3.ID_ESTADO_10 TRAEXPIDESTADO10,t3.F_INICIO_10 TRAEXPFINICIO10,t3.F_REALIZACION_10 TRAEXPFREALIZACION10,t3.OBSERVACIONES_10 TRAEXPOBSERVACIONES10,t3.F_ALTA_10 TRAEXPFALTA10,t3.USU_ALTA_10 TRAEXPUSUALTA10,t3.F_MODIF_10 TRAEXPFMODIF10,t3.USU_MODIF_10 TRAEXPUSUMODIF10,t2.ID_TIPO_DOC_38 MATAREASIDTIPODOC38,t2.ID_TRAMITE_38 MATAREASIDTRAMITE38,t3.ID_TRAMITE_10 TRAEXPIDTRAMITE10 ");
		// FROM
		query.append("FROM TAREAS_TRAMITE t1 ,MAESTRO_TAREAS t2 ,TRAMITES_EXPEDIENTE t3 ");
		// FILTRADO
		// Where clause & Params
		Map<String, ?> mapaWhere = this.getWhereLikeMap(tareastramite, startsWith);
		StringBuilder where = new StringBuilder(
				" WHERE 1=1 AND t1.ID_TAREA_11= t2.ID_TAREA_38(+) AND t1.ID_TRAMITE_EXP_11= t3.ID_TRAMITE_EXP_10(+) ");
		where.append(mapaWhere.get("query"));
		query.append(where);

		// Parámetros de filtrado
		@SuppressWarnings("unchecked")
		List<Object> filterParamList = (List<Object>) mapaWhere.get("params");

		// SQL para la reordenación
		StringBuilder sbReorderSelectionSQL = TableManager.getReorderQuery(query, tableRequestDto, TareasTramite.class,
				filterParamList, "IDTAREATRAM11");

		return this.jdbcTemplate.query(sbReorderSelectionSQL.toString(),
				new RowNumResultSetExtractor<TareasTramite>(this.rwMapPK, tableRequestDto), filterParamList.toArray());
	}

	/**
	 * Search method for rup_table
	 *
	 * @param filterParams    TareasTramite
	 * @param searchParams    TareasTramite
	 * @param tableRequestDto TableRequestDto
	 * @param startsWith      Boolean
	 * @return List<TableRowDto<TareasTramite>>
	 */
	@Override
	public List<TableRowDto<TareasTramite>> search(TareasTramite filterParams, TareasTramite searchParams,
			TableRequestDto tableRequestDto, Boolean startsWith) {
		// SELECT
		StringBuilder query = new StringBuilder(
				"SELECT t1.ID_TAREA_TRAM_11 IDTAREATRAM11,t1.ID_ESTADO_11 IDESTADO11,t1.TASKGUID_11 TASKGUID11,t1.F_INICIO_11 FINICIO11,t1.F_FIN_11 FFIN11,t1.F_NOTIFICACION_11 FNOTIFICACION11,t1.F_ACUSE_11 FACUSE11,t1.TEXTO_REQ_11 TEXTOREQ11,t1.F_REGISTRO_11 FREGISTRO11,t1.NUM_REGISTRO_11 NUMREGISTRO11,t1.ESTADO_DOCUMENTACION_11 ESTADODOCUMENTACION11,t1.ID_NOTIFICACION_11 IDNOTIFICACION11,t1.F_ALTA_11 FALTA11,t1.USU_ALTA_11 USUALTA11,t1.F_MODIF_11 FMODIF11,t1.USU_MODIF_11 USUMODIF11,t2.ID_TAREA_38 MATAREASIDTAREA38,t2.TIPO_TAREA_38 MATAREASTIPOTAREA38,t2.DESC_ES_38 MATAREASDESCES38,t2.DESC_EU_38 MATAREASDESCEU38,t3.ID_TRAMITE_EXP_10 TRAEXPIDTRAMITEEXP10,t3.ID_EXPEDIENTE_10 TRAEXPIDEXPEDIENTE10,t3.ID_ESTADO_10 TRAEXPIDESTADO10,t3.F_INICIO_10 TRAEXPFINICIO10,t3.F_REALIZACION_10 TRAEXPFREALIZACION10,t3.OBSERVACIONES_10 TRAEXPOBSERVACIONES10,t3.F_ALTA_10 TRAEXPFALTA10,t3.USU_ALTA_10 TRAEXPUSUALTA10,t3.F_MODIF_10 TRAEXPFMODIF10,t3.USU_MODIF_10 TRAEXPUSUMODIF10,t2.ID_TIPO_DOC_38 MATAREASIDTIPODOC38,t2.ID_TRAMITE_38 MATAREASIDTRAMITE38,t3.ID_TRAMITE_10 TRAEXPIDTRAMITE10 ");
		// FROM
		query.append("FROM TAREAS_TRAMITE t1 ,MAESTRO_TAREAS t2 ,TRAMITES_EXPEDIENTE t3 ");
		// TABLAS_ALIAS
		List<String> from_alias = new ArrayList<String>();
		from_alias.add(" t1 ");
		from_alias.add(" t2 ");
		from_alias.add(" t3 ");

		// FILTRADO
		Map<String, ?> mapaWhereFilter = this.getWhereLikeMap(filterParams, startsWith);
		StringBuilder where = new StringBuilder(
				" WHERE 1=1 AND t1.ID_TAREA_11= t2.ID_TAREA_38(+) AND t1.ID_TRAMITE_EXP_11= t3.ID_TRAMITE_EXP_10(+) ");
		where.append(mapaWhereFilter.get("query"));
		query.append(where);
		// Filter params
		@SuppressWarnings("unchecked")
		List<Object> filterParamList = (List<Object>) mapaWhereFilter.get("params");

		// BUSQUEDA
		Map<String, Object> mapaWhereSearch = this.getWhereLikeMap(searchParams, startsWith);
		String searchSQL = ((StringBuilder) mapaWhereSearch.get("query")).toString();
		// Search params
		@SuppressWarnings("unchecked")
		List<Object> searchParamList = (List<Object>) mapaWhereSearch.get("params");

		// SQL
		StringBuilder sbReorderSelectionSQL = TableManager.getSearchQuery(query, tableRequestDto, TareasTramite.class,
				filterParamList, searchSQL, searchParamList, from_alias, "IDTAREATRAM11");

		return this.jdbcTemplate.query(sbReorderSelectionSQL.toString(),
				new RowNumResultSetExtractor<TareasTramite>(this.rwMapPK, tableRequestDto), filterParamList.toArray());
	}

	/**
	 * Remove multiple method for rup_table
	 *
	 * @param tableRequestDto TableRequestDto
	 */
	@Override
	public void removeMultiple(TableRequestDto tableRequestDto) {
		StringBuilder sbRemoveMultipleSQL = TableManager.getRemoveMultipleQuery(tableRequestDto, TareasTramite.class,
				"TAREAS_TRAMITE", new String[] { "IDTAREATRAM11" });

		List<String> params = tableRequestDto.getMultiselection().getSelectedIds();

		this.jdbcTemplate.update(sbRemoveMultipleSQL.toString(), params.toArray());
	}

	/**
	 * Filter in the hierarchical TareasTramite table.
	 *
	 * @param filterTareasTramite TareasTramite
	 * @param tableRequestDto     TableRequestDto
	 * @return List<JerarquiaDto<TareasTramite>>
	 */
	@Override
	public List<JerarquiaDto<TareasTramite>> findAllLikeJerarquia(TareasTramite filterTareasTramite,
			TableRequestDto tableRequestDto) {
		// SELECT
		StringBuilder query = new StringBuilder(
				"SELECT t1.ID_TAREA_TRAM_11 IDTAREATRAM11,t1.ID_ESTADO_11 IDESTADO11,t1.TASKGUID_11 TASKGUID11,t1.F_INICIO_11 FINICIO11,t1.F_FIN_11 FFIN11,t1.F_NOTIFICACION_11 FNOTIFICACION11,t1.F_ACUSE_11 FACUSE11,t1.TEXTO_REQ_11 TEXTOREQ11,t1.F_REGISTRO_11 FREGISTRO11,t1.NUM_REGISTRO_11 NUMREGISTRO11,t1.ESTADO_DOCUMENTACION_11 ESTADODOCUMENTACION11,t1.ID_NOTIFICACION_11 IDNOTIFICACION11,t1.F_ALTA_11 FALTA11,t1.USU_ALTA_11 USUALTA11,t1.F_MODIF_11 FMODIF11,t1.USU_MODIF_11 USUMODIF11, t1.DATOS_TAREA_11 DATOSTAREA11 ");
		query.append(
				",t2.ID_TAREA_38 MATAREASIDTAREA38,t2.TIPO_TAREA_38 MATAREASTIPOTAREA38,t2.DESC_ES_38 MATAREASDESCES38,t2.DESC_EU_38 MATAREASDESCEU38");
		query.append(
				",t3.ID_TRAMITE_EXP_10 TRAEXPIDTRAMITEEXP10,t3.ID_EXPEDIENTE_10 TRAEXPIDEXPEDIENTE10,t3.ID_ESTADO_10 TRAEXPIDESTADO10,t3.F_INICIO_10 TRAEXPFINICIO10,t3.F_REALIZACION_10 TRAEXPFREALIZACION10,t3.OBSERVACIONES_10 TRAEXPOBSERVACIONES10,t3.F_ALTA_10 TRAEXPFALTA10,t3.USU_ALTA_10 TRAEXPUSUALTA10,t3.F_MODIF_10 TRAEXPFMODIF10,t3.USU_MODIF_10 TRAEXPUSUMODIF10,t2.ID_TIPO_DOC_38 MATAREASIDTIPODOC38,t2.ID_TRAMITE_38 MATAREASIDTRAMITE38,t3.ID_TRAMITE_10 TRAEXPIDTRAMITE10 ");
		// FROM
		// StringBuilder from = new StringBuilder("FROM TAREAS_TRAMITE t1
		// ,MAESTRO_TAREAS t2 ,TRAMITES_EXPEDIENTE t3 ");
		List<String> from = new ArrayList<String>();
		from.add("TAREAS_TRAMITE");
		from.add("MAESTRO_TAREAS");
		from.add("TRAMITES_EXPEDIENTE");
		// TABLAS_ALIAS
		List<String> from_alias = new ArrayList<String>();
		from_alias.add(" t1 ");
		from_alias.add(" t2 ");
		from_alias.add(" t3 ");

		// JOINS TABLAS
		/*
		 * Ejemplo de como indicar joins entre las tablas de la query
		 */
		/*
		 * StringBuilder joins = new StringBuilder("");
		 * joins.append("AND T1.ID=T2.ID_T1");
		 */

		// CONDICIONES (negocio)
		/*
		 * Ejemplo de como incluir condiciones de negocio en la consulta de la jerarquía
		 */
		/*
		 * StringBuilder businessFilters = new StringBuilder(); List<Object>
		 * businessParams = new ArrayList<Object>();
		 * businessFilters.append("   AND t1.EJIE = ?  "); businessParams.add("1");
		 */

		// FILTRO
		Map<String, ?> mapaWhere = this.getWhereLikeMap(filterTareasTramite, false);

		// JERARQUIA
		// Especificar la columna padre correspondiente en lugar de la generada por
		// defecto (ID_PADRE)
		query = TableManagerJerarquia.getQuery(tableRequestDto, query, mapaWhere, "IDTAREATRAM11", "ID_PADRE", "NOMBRE",
				from, from_alias);

		/*
		 * Ejemplo de llamada en caso de indicar joins entre tablas y condiciones de
		 * negocio
		 */
//		query = TableManagerJerarquia.getQuery(tableRequestDto, query, mapaWhere, "ID", "ID_PADRE", "NOMBRE", from, from_alias, joins, businessFilters, businessParams);

		// PAGINACION
		if (tableRequestDto != null) {
			query = TableManagerJerarquia.getPaginationQuery(tableRequestDto, query,
					TareasTramiteDaoImpl.ORDER_BY_WHITE_LIST);
		}

		List<?> params = (List<?>) mapaWhere.get("params");
		return this.jdbcTemplate.query(query.toString(), this.rwMapJerarquia, params.toArray());
	}

	/**
	 * Count rows in hierarchy
	 *
	 * @param filterTareasTramite TareasTramite
	 * @param tableRequestDto     TableRequestDto
	 * @return Long
	 */
	@Override
	public Long findAllLikeCountJerarquia(TareasTramite filterTareasTramite, TableRequestDto tableRequestDto) {
		// FROM
		// StringBuilder from = new StringBuilder("FROM TAREAS_TRAMITE t1
		// ,MAESTRO_TAREAS t2 ,TRAMITES_EXPEDIENTE t3 ");
		List<String> from = new ArrayList<String>();
		from.add("TAREAS_TRAMITE");
		from.add("MAESTRO_TAREAS");
		from.add("TRAMITES_EXPEDIENTE");

		// TABLAS_ALIAS
		List<String> from_alias = new ArrayList<String>();
		from_alias.add(" t1 ");
		from_alias.add(" t2 ");
		from_alias.add(" t3 ");

		// JOINS TABLAS
		/*
		 * Ejemplo de como indicar joins entre las tablas de la query
		 */
		/*
		 * StringBuilder joins = new StringBuilder("");
		 * joins.append("AND T1.ID=T2.ID_T1");
		 */

		// CONDICIONES (negocio)
		/*
		 * Ejemplo de como incluir condiciones de negocio en la consulta de la jerarquía
		 */
		/*
		 * StringBuilder businessFilters = new StringBuilder(); List<Object>
		 * businessParams = new ArrayList<Object>();
		 * businessFilters.append("   AND t1.EJIE = ?  "); businessParams.add("1");
		 */

		// FILTRO
		Map<String, ?> mapaWhere = this.getWhereLikeMap(filterTareasTramite, false);

		// JERARQUIA
		// Especificar la columna padre correspondiente en lugar de la generada por
		// defecto (ID_PADRE)
		StringBuilder query = TableManagerJerarquia.getQueryCount(tableRequestDto, mapaWhere, "IDTAREATRAM11",
				"ID_PADRE", from, from_alias);

		/*
		 * Ejemplo de llamada en caso de indicar joins entre tablas y condiciones de
		 * negocio
		 */
//		StringBuilder query = TableManagerJerarquia.getQueryCount(tableRequestDto, mapaWhere, "ID", "ID_PADRE", from, from_alias, joins, businessFilters, businessParams);

		List<?> params = (List<?>) mapaWhere.get("params");
		return this.jdbcTemplate.queryForObject(query.toString(), params.toArray(), Long.class);
	}

	/**
	 * Find dependent hierarchical rows
	 *
	 * @param filterTareasTramite TareasTramite
	 * @param tableRequestDto     TableRequestDto
	 * @return List<TableRowDto<TareasTramite>>
	 */
	@Override
	public List<TableRowDto<TareasTramite>> findAllChild(TareasTramite filterTareasTramite,
			TableRequestDto tableRequestDto) {

		// FROM
		// StringBuilder from = new StringBuilder("FROM TAREAS_TRAMITE t1
		// ,MAESTRO_TAREAS t2 ,TRAMITES_EXPEDIENTE t3 ");
		List<String> from = new ArrayList<String>();
		from.add("TAREAS_TRAMITE");
		from.add("MAESTRO_TAREAS");
		from.add("TRAMITES_EXPEDIENTE");

		// TABLAS_ALIAS
		List<String> from_alias = new ArrayList<String>();
		from_alias.add(" t1 ");
		from_alias.add(" t2 ");
		from_alias.add(" t3 ");

		// JOINS TABLAS
		/*
		 * Ejemplo de como indicar joins entre las tablas de la query
		 */
		/*
		 * StringBuilder joins = new StringBuilder("");
		 * joins.append("AND T1.ID=T2.ID_T1");
		 */

		// CONDICIONES (negocio)
		/*
		 * Ejemplo de como incluir condiciones de negocio en la consulta de la jerarquía
		 */
		/*
		 * StringBuilder businessFilters = new StringBuilder(); List<Object>
		 * businessParams = new ArrayList<Object>();
		 * businessFilters.append("   AND t1.EJIE = ?  "); businessParams.add("1");
		 */

		// FILTRO
		Map<String, ?> mapaWhere = this.getWhereLikeMap(filterTareasTramite, false);

		// MULTISELECCION
		// Especificar la columna padre correspondiente en lugar de la generada por
		// defecto (ID_PADRE)
		StringBuilder query = TableManagerJerarquia.getQueryChildren(tableRequestDto, mapaWhere, "IDTAREATRAM11",
				"ID_PADRE", from, from_alias);

		/*
		 * Ejemplo de llamada en caso de indicar joins entre tablas y condiciones de
		 * negocio
		 */
//		StringBuilder query = TableManagerJerarquia.getQueryChildren(tableRequestDto, mapaWhere, "ID", "ID_PADRE", from, from_alias, joins, businessFilters, businessParams);

		List<?> params = (List<?>) mapaWhere.get("params");

		return this.jdbcTemplate.query(query.toString(),
				new RowNumResultSetExtractor<TareasTramite>(this.rwMapPK, "IDTAREATRAM11"), params.toArray());
	}

	/*
	 * MÉTODOS PRIVADOS
	 */

	/**
	 * Returns a map with the needed value to create the conditions to filter by the
	 * TareasTramite entity
	 *
	 * @param tareastramite TareasTramite Bean with the criteria values to filter
	 *                      by.
	 * @return Map created with two keys key query stores the sql query syntax key
	 *         params stores the parameter values to be used in the condition
	 *         sentence.
	 */
	// CHECKSTYLE:OFF CyclomaticComplexity - Generación de código de UDA
	private Map<String, ?> getWhereMap(TareasTramite tareastramite) {

		StringBuilder where = new StringBuilder(TareasTramiteDaoImpl.STRING_BUILDER_INIT);
		List<Object> params = new ArrayList<Object>();

		if (tareastramite != null && tareastramite.getIdTareaTram11() != null) {
			where.append(" AND t1.ID_TAREA_TRAM_11 = ?");
			params.add(tareastramite.getIdTareaTram11());
		}
		if (tareastramite != null && tareastramite.getMaestroTareas() != null
				&& tareastramite.getMaestroTareas().getIdTarea38() != null) {
			where.append(" AND t2.ID_TAREA_38 = ?");
			params.add(tareastramite.getMaestroTareas().getIdTarea38());
		}
		if (tareastramite != null && tareastramite.getMaestroTareas() != null
				&& tareastramite.getMaestroTareas().getMaestroTiposDoc() != null
				&& tareastramite.getMaestroTareas().getMaestroTiposDoc().getIdTipoDoc36() != null) {
			where.append(" AND t2.ID_TIPO_DOC_38 = ?");
			params.add(tareastramite.getMaestroTareas().getMaestroTiposDoc().getIdTipoDoc36());
		}
		if (tareastramite != null && tareastramite.getMaestroTareas() != null
				&& tareastramite.getMaestroTareas().getMaestroTramites() != null
				&& tareastramite.getMaestroTareas().getMaestroTramites().getIdTramite37() != null) {
			where.append(" AND t2.ID_TRAMITE_38 = ?");
			params.add(tareastramite.getMaestroTareas().getMaestroTramites().getIdTramite37());
		}
		if (tareastramite != null && tareastramite.getMaestroTareas() != null
				&& tareastramite.getMaestroTareas().getTipoTarea38() != null) {
			where.append(" AND t2.TIPO_TAREA_38 = ?");
			params.add(tareastramite.getMaestroTareas().getTipoTarea38());
		}
		if (tareastramite != null && tareastramite.getMaestroTareas() != null
				&& tareastramite.getMaestroTareas().getDescEs38() != null) {
			where.append(" AND t2.DESC_ES_38 = ?");
			params.add(tareastramite.getMaestroTareas().getDescEs38());
		}
		if (tareastramite != null && tareastramite.getMaestroTareas() != null
				&& tareastramite.getMaestroTareas().getDescEu38() != null) {
			where.append(" AND t2.DESC_EU_38 = ?");
			params.add(tareastramite.getMaestroTareas().getDescEu38());
		}
		if (tareastramite != null && tareastramite.getTramitesExpediente() != null
				&& tareastramite.getTramitesExpediente().getIdTramiteExp10() != null) {
			where.append(" AND t3.ID_TRAMITE_EXP_10 = ?");
			params.add(tareastramite.getTramitesExpediente().getIdTramiteExp10());
		}
		if (tareastramite != null && tareastramite.getTramitesExpediente() != null
				&& tareastramite.getTramitesExpediente().getMaestroTramites() != null
				&& tareastramite.getTramitesExpediente().getMaestroTramites().getIdTramite37() != null) {
			where.append(" AND t3.ID_TRAMITE_10 = ?");
			params.add(tareastramite.getTramitesExpediente().getMaestroTramites().getIdTramite37());
		}
		if (tareastramite != null && tareastramite.getTramitesExpediente() != null
				&& tareastramite.getTramitesExpediente().getIdExpediente10() != null) {
			where.append(" AND t3.ID_EXPEDIENTE_10 = ?");
			params.add(tareastramite.getTramitesExpediente().getIdExpediente10());
		}
		if (tareastramite != null && tareastramite.getTramitesExpediente() != null
				&& tareastramite.getTramitesExpediente().getIdEstado10() != null) {
			where.append(" AND t3.ID_ESTADO_10 = ?");
			params.add(tareastramite.getTramitesExpediente().getIdEstado10());
		}
		if (tareastramite != null && tareastramite.getTramitesExpediente() != null
				&& tareastramite.getTramitesExpediente().getfInicio10() != null) {
			where.append(" AND t3.F_INICIO_10 = ?");
			params.add(tareastramite.getTramitesExpediente().getfInicio10());
		}
		if (tareastramite != null && tareastramite.getTramitesExpediente() != null
				&& tareastramite.getTramitesExpediente().getfRealizacion10() != null) {
			where.append(" AND t3.F_REALIZACION_10 = ?");
			params.add(tareastramite.getTramitesExpediente().getfRealizacion10());
		}
		if (tareastramite != null && tareastramite.getTramitesExpediente() != null
				&& tareastramite.getTramitesExpediente().getObservaciones10() != null) {
			where.append(" AND t3.OBSERVACIONES_10 = ?");
			params.add(tareastramite.getTramitesExpediente().getObservaciones10());
		}
		if (tareastramite != null && tareastramite.getTramitesExpediente() != null
				&& tareastramite.getTramitesExpediente().getfAlta10() != null) {
			where.append(" AND t3.F_ALTA_10 = ?");
			params.add(tareastramite.getTramitesExpediente().getfAlta10());
		}
		if (tareastramite != null && tareastramite.getTramitesExpediente() != null
				&& tareastramite.getTramitesExpediente().getUsuAlta10() != null) {
			where.append(" AND t3.USU_ALTA_10 = ?");
			params.add(tareastramite.getTramitesExpediente().getUsuAlta10());
		}
		if (tareastramite != null && tareastramite.getTramitesExpediente() != null
				&& tareastramite.getTramitesExpediente().getfModif10() != null) {
			where.append(" AND t3.F_MODIF_10 = ?");
			params.add(tareastramite.getTramitesExpediente().getfModif10());
		}
		if (tareastramite != null && tareastramite.getTramitesExpediente() != null
				&& tareastramite.getTramitesExpediente().getUsuModif10() != null) {
			where.append(" AND t3.USU_MODIF_10 = ?");
			params.add(tareastramite.getTramitesExpediente().getUsuModif10());
		}
		if (tareastramite != null && tareastramite.getIdEstado11() != null) {
			where.append(" AND t1.ID_ESTADO_11 = ?");
			params.add(tareastramite.getIdEstado11());
		}
		if (tareastramite != null && tareastramite.getTaskguid11() != null) {
			where.append(" AND t1.TASKGUID_11 = ?");
			params.add(tareastramite.getTaskguid11());
		}
		if (tareastramite != null && tareastramite.getfInicio11() != null) {
			where.append(" AND t1.F_INICIO_11 = ?");
			params.add(tareastramite.getfInicio11());
		}
		if (tareastramite != null && tareastramite.getfFin11() != null) {
			where.append(" AND t1.F_FIN_11 = ?");
			params.add(tareastramite.getfFin11());
		}
		if (tareastramite != null && tareastramite.getfNotificacion11() != null) {
			where.append(" AND t1.F_NOTIFICACION_11 = ?");
			params.add(tareastramite.getfNotificacion11());
		}
		if (tareastramite != null && tareastramite.getfAcuse11() != null) {
			where.append(" AND t1.F_ACUSE_11 = ?");
			params.add(tareastramite.getfAcuse11());
		}
		if (tareastramite != null && tareastramite.getTextoReq11() != null) {
			where.append(" AND t1.TEXTO_REQ_11 = ?");
			params.add(tareastramite.getTextoReq11());
		}
		if (tareastramite != null && tareastramite.getfRegistro11() != null) {
			where.append(" AND t1.F_REGISTRO_11 = ?");
			params.add(tareastramite.getfRegistro11());
		}
		if (tareastramite != null && tareastramite.getNumRegistro11() != null) {
			where.append(" AND t1.NUM_REGISTRO_11 = ?");
			params.add(tareastramite.getNumRegistro11());
		}
		if (tareastramite != null && tareastramite.getEstadoDocumentacion11() != null) {
			where.append(" AND t1.ESTADO_DOCUMENTACION_11 = ?");
			params.add(tareastramite.getEstadoDocumentacion11());
		}
		if (tareastramite != null && tareastramite.getIdNotificacion11() != null) {
			where.append(" AND t1.ID_NOTIFICACION_11 = ?");
			params.add(tareastramite.getIdNotificacion11());
		}
		if (tareastramite != null && tareastramite.getfAlta11() != null) {
			where.append(" AND t1.F_ALTA_11 = ?");
			params.add(tareastramite.getfAlta11());
		}
		if (tareastramite != null && tareastramite.getUsuAlta11() != null) {
			where.append(" AND t1.USU_ALTA_11 = ?");
			params.add(tareastramite.getUsuAlta11());
		}
		if (tareastramite != null && tareastramite.getfModif11() != null) {
			where.append(" AND t1.F_MODIF_11 = ?");
			params.add(tareastramite.getfModif11());
		}
		if (tareastramite != null && tareastramite.getUsuModif11() != null) {
			where.append(" AND t1.USU_MODIF_11 = ?");
			params.add(tareastramite.getUsuModif11());
		}

		Map<String, Object> mapWhere = new HashMap<String, Object>();
		mapWhere.put("query", where);
		mapWhere.put("params", params);

		return mapWhere;
	}
	// CHECKSTYLE:ON CyclomaticComplexity - Generación de código de UDA

	/**
	 * Returns a map with the needed value to create the conditions to filter by the
	 * TareasTramite entity
	 *
	 * @param tareastramite TareasTramite Bean with the criteria values to filter
	 *                      by.
	 * @param startsWith    Boolean
	 * @return Map created with two keys key query stores the sql query syntax key
	 *         params stores the parameter values to be used in the condition
	 *         sentence.
	 */
	// CHECKSTYLE:OFF CyclomaticComplexity - Generación de código de UDA
	private Map<String, Object> getWhereLikeMap(TareasTramite tareastramite, Boolean startsWith) {

		StringBuilder where = new StringBuilder(TareasTramiteDaoImpl.STRING_BUILDER_INIT);
		List<Object> params = new ArrayList<Object>();

		if (tareastramite != null && tareastramite.getIdTareaTram11() != null) {
			where.append(" AND t1.ID_TAREA_TRAM_11 = ?");
			params.add(tareastramite.getIdTareaTram11());
		}
		if (tareastramite != null && tareastramite.getMaestroTareas() != null
				&& tareastramite.getMaestroTareas().getIdTarea38() != null) {
			where.append(" AND t2.ID_TAREA_38 = ?");
			params.add(tareastramite.getMaestroTareas().getIdTarea38());
		}
		if (tareastramite != null && tareastramite.getMaestroTareas() != null
				&& tareastramite.getMaestroTareas().getMaestroTiposDoc() != null
				&& tareastramite.getMaestroTareas().getMaestroTiposDoc().getIdTipoDoc36() != null) {
			where.append(" AND t2.ID_TIPO_DOC_38 = ?");
			params.add(tareastramite.getMaestroTareas().getMaestroTiposDoc().getIdTipoDoc36());
		}
		if (tareastramite != null && tareastramite.getMaestroTareas() != null
				&& tareastramite.getMaestroTareas().getMaestroTramites() != null
				&& tareastramite.getMaestroTareas().getMaestroTramites().getIdTramite37() != null) {
			where.append(" AND t2.ID_TRAMITE_38 = ?");
			params.add(tareastramite.getMaestroTareas().getMaestroTramites().getIdTramite37());
		}
		if (tareastramite != null && tareastramite.getMaestroTareas() != null
				&& tareastramite.getMaestroTareas().getTipoTarea38() != null) {
			where.append(" AND UPPER(t2.TIPO_TAREA_38) like ? ESCAPE  '\\'");
			if (startsWith) {
				params.add(tareastramite.getMaestroTareas().getTipoTarea38().toUpperCase() + "%");
			} else {
				params.add("%" + tareastramite.getMaestroTareas().getTipoTarea38().toUpperCase() + "%");
			}
			where.append(" AND t2.TIPO_TAREA_38 IS NOT NULL");
		}
		if (tareastramite != null && tareastramite.getMaestroTareas() != null
				&& tareastramite.getMaestroTareas().getDescEs38() != null) {
			where.append(" AND UPPER(t2.DESC_ES_38) like ? ESCAPE  '\\'");
			if (startsWith) {
				params.add(tareastramite.getMaestroTareas().getDescEs38().toUpperCase() + "%");
			} else {
				params.add("%" + tareastramite.getMaestroTareas().getDescEs38().toUpperCase() + "%");
			}
			where.append(" AND t2.DESC_ES_38 IS NOT NULL");
		}
		if (tareastramite != null && tareastramite.getMaestroTareas() != null
				&& tareastramite.getMaestroTareas().getDescEu38() != null) {
			where.append(" AND UPPER(t2.DESC_EU_38) like ? ESCAPE  '\\'");
			if (startsWith) {
				params.add(tareastramite.getMaestroTareas().getDescEu38().toUpperCase() + "%");
			} else {
				params.add("%" + tareastramite.getMaestroTareas().getDescEu38().toUpperCase() + "%");
			}
			where.append(" AND t2.DESC_EU_38 IS NOT NULL");
		}
		if (tareastramite != null && tareastramite.getTramitesExpediente() != null
				&& tareastramite.getTramitesExpediente().getIdTramiteExp10() != null) {
			where.append(" AND t3.ID_TRAMITE_EXP_10 = ?");
			params.add(tareastramite.getTramitesExpediente().getIdTramiteExp10());
		}
		if (tareastramite != null && tareastramite.getTramitesExpediente() != null
				&& tareastramite.getTramitesExpediente().getMaestroTramites() != null
				&& tareastramite.getTramitesExpediente().getMaestroTramites().getIdTramite37() != null) {
			where.append(" AND t3.ID_TRAMITE_10 = ?");
			params.add(tareastramite.getTramitesExpediente().getMaestroTramites().getIdTramite37());
		}
		if (tareastramite != null && tareastramite.getTramitesExpediente() != null
				&& tareastramite.getTramitesExpediente().getIdExpediente10() != null) {
			where.append(" AND t3.ID_EXPEDIENTE_10 = ?");
			params.add(tareastramite.getTramitesExpediente().getIdExpediente10());
		}
		if (tareastramite != null && tareastramite.getTramitesExpediente() != null
				&& tareastramite.getTramitesExpediente().getIdEstado10() != null) {
			where.append(" AND t3.ID_ESTADO_10 = ?");
			params.add(tareastramite.getTramitesExpediente().getIdEstado10());
		}
		if (tareastramite != null && tareastramite.getTramitesExpediente() != null
				&& tareastramite.getTramitesExpediente().getfInicio10() != null) {
			where.append(" AND t3.F_INICIO_10 = ?");
			params.add(tareastramite.getTramitesExpediente().getfInicio10());
		}
		if (tareastramite != null && tareastramite.getTramitesExpediente() != null
				&& tareastramite.getTramitesExpediente().getfRealizacion10() != null) {
			where.append(" AND t3.F_REALIZACION_10 = ?");
			params.add(tareastramite.getTramitesExpediente().getfRealizacion10());
		}
		if (tareastramite != null && tareastramite.getTramitesExpediente() != null
				&& tareastramite.getTramitesExpediente().getObservaciones10() != null) {
			where.append(" AND UPPER(t3.OBSERVACIONES_10) like ? ESCAPE  '\\'");
			if (startsWith) {
				params.add(tareastramite.getTramitesExpediente().getObservaciones10().toUpperCase() + "%");
			} else {
				params.add("%" + tareastramite.getTramitesExpediente().getObservaciones10().toUpperCase() + "%");
			}
			where.append(" AND t3.OBSERVACIONES_10 IS NOT NULL");
		}
		if (tareastramite != null && tareastramite.getTramitesExpediente() != null
				&& tareastramite.getTramitesExpediente().getfAlta10() != null) {
			where.append(" AND t3.F_ALTA_10 = ?");
			params.add(tareastramite.getTramitesExpediente().getfAlta10());
		}
		if (tareastramite != null && tareastramite.getTramitesExpediente() != null
				&& tareastramite.getTramitesExpediente().getUsuAlta10() != null) {
			where.append(" AND UPPER(t3.USU_ALTA_10) like ? ESCAPE  '\\'");
			if (startsWith) {
				params.add(tareastramite.getTramitesExpediente().getUsuAlta10().toUpperCase() + "%");
			} else {
				params.add("%" + tareastramite.getTramitesExpediente().getUsuAlta10().toUpperCase() + "%");
			}
			where.append(" AND t3.USU_ALTA_10 IS NOT NULL");
		}
		if (tareastramite != null && tareastramite.getTramitesExpediente() != null
				&& tareastramite.getTramitesExpediente().getfModif10() != null) {
			where.append(" AND t3.F_MODIF_10 = ?");
			params.add(tareastramite.getTramitesExpediente().getfModif10());
		}
		if (tareastramite != null && tareastramite.getTramitesExpediente() != null
				&& tareastramite.getTramitesExpediente().getUsuModif10() != null) {
			where.append(" AND UPPER(t3.USU_MODIF_10) like ? ESCAPE  '\\'");
			if (startsWith) {
				params.add(tareastramite.getTramitesExpediente().getUsuModif10().toUpperCase() + "%");
			} else {
				params.add("%" + tareastramite.getTramitesExpediente().getUsuModif10().toUpperCase() + "%");
			}
			where.append(" AND t3.USU_MODIF_10 IS NOT NULL");
		}
		if (tareastramite != null && tareastramite.getIdEstado11() != null) {
			where.append(" AND UPPER(t1.ID_ESTADO_11) like ? ESCAPE  '\\'");
			if (startsWith) {
				params.add(tareastramite.getIdEstado11().toUpperCase() + "%");
			} else {
				params.add("%" + tareastramite.getIdEstado11().toUpperCase() + "%");
			}
			where.append(" AND t1.ID_ESTADO_11 IS NOT NULL");
		}
		if (tareastramite != null && tareastramite.getTaskguid11() != null) {
			where.append(" AND UPPER(t1.TASKGUID_11) like ? ESCAPE  '\\'");
			if (startsWith) {
				params.add(tareastramite.getTaskguid11().toUpperCase() + "%");
			} else {
				params.add("%" + tareastramite.getTaskguid11().toUpperCase() + "%");
			}
			where.append(" AND t1.TASKGUID_11 IS NOT NULL");
		}
		if (tareastramite != null && tareastramite.getfInicio11() != null) {
			where.append(" AND t1.F_INICIO_11 = ?");
			params.add(tareastramite.getfInicio11());
		}
		if (tareastramite != null && tareastramite.getfFin11() != null) {
			where.append(" AND t1.F_FIN_11 = ?");
			params.add(tareastramite.getfFin11());
		}
		if (tareastramite != null && tareastramite.getfNotificacion11() != null) {
			where.append(" AND t1.F_NOTIFICACION_11 = ?");
			params.add(tareastramite.getfNotificacion11());
		}
		if (tareastramite != null && tareastramite.getfAcuse11() != null) {
			where.append(" AND t1.F_ACUSE_11 = ?");
			params.add(tareastramite.getfAcuse11());
		}
		if (tareastramite != null && tareastramite.getTextoReq11() != null) {
			where.append(" AND UPPER(t1.TEXTO_REQ_11) like ? ESCAPE  '\\'");
			if (startsWith) {
				params.add(tareastramite.getTextoReq11().toUpperCase() + "%");
			} else {
				params.add("%" + tareastramite.getTextoReq11().toUpperCase() + "%");
			}
			where.append(" AND t1.TEXTO_REQ_11 IS NOT NULL");
		}
		if (tareastramite != null && tareastramite.getfRegistro11() != null) {
			where.append(" AND t1.F_REGISTRO_11 = ?");
			params.add(tareastramite.getfRegistro11());
		}
		if (tareastramite != null && tareastramite.getNumRegistro11() != null) {
			where.append(" AND UPPER(t1.NUM_REGISTRO_11) like ? ESCAPE  '\\'");
			if (startsWith) {
				params.add(tareastramite.getNumRegistro11().toUpperCase() + "%");
			} else {
				params.add("%" + tareastramite.getNumRegistro11().toUpperCase() + "%");
			}
			where.append(" AND t1.NUM_REGISTRO_11 IS NOT NULL");
		}
		if (tareastramite != null && tareastramite.getEstadoDocumentacion11() != null) {
			where.append(" AND UPPER(t1.ESTADO_DOCUMENTACION_11) like ? ESCAPE  '\\'");
			if (startsWith) {
				params.add(tareastramite.getEstadoDocumentacion11().toUpperCase() + "%");
			} else {
				params.add("%" + tareastramite.getEstadoDocumentacion11().toUpperCase() + "%");
			}
			where.append(" AND t1.ESTADO_DOCUMENTACION_11 IS NOT NULL");
		}
		if (tareastramite != null && tareastramite.getIdNotificacion11() != null) {
			where.append(" AND UPPER(t1.ID_NOTIFICACION_11) like ? ESCAPE  '\\'");
			if (startsWith) {
				params.add(tareastramite.getIdNotificacion11().toUpperCase() + "%");
			} else {
				params.add("%" + tareastramite.getIdNotificacion11().toUpperCase() + "%");
			}
			where.append(" AND t1.ID_NOTIFICACION_11 IS NOT NULL");
		}
		if (tareastramite != null && tareastramite.getfAlta11() != null) {
			where.append(" AND t1.F_ALTA_11 = ?");
			params.add(tareastramite.getfAlta11());
		}
		if (tareastramite != null && tareastramite.getUsuAlta11() != null) {
			where.append(" AND UPPER(t1.USU_ALTA_11) like ? ESCAPE  '\\'");
			if (startsWith) {
				params.add(tareastramite.getUsuAlta11().toUpperCase() + "%");
			} else {
				params.add("%" + tareastramite.getUsuAlta11().toUpperCase() + "%");
			}
			where.append(" AND t1.USU_ALTA_11 IS NOT NULL");
		}
		if (tareastramite != null && tareastramite.getfModif11() != null) {
			where.append(" AND t1.F_MODIF_11 = ?");
			params.add(tareastramite.getfModif11());
		}
		if (tareastramite != null && tareastramite.getUsuModif11() != null) {
			where.append(" AND UPPER(t1.USU_MODIF_11) like ? ESCAPE  '\\'");
			if (startsWith) {
				params.add(tareastramite.getUsuModif11().toUpperCase() + "%");
			} else {
				params.add("%" + tareastramite.getUsuModif11().toUpperCase() + "%");
			}
			where.append(" AND t1.USU_MODIF_11 IS NOT NULL");
		}

		Map<String, Object> mapWhere = new HashMap<String, Object>();
		mapWhere.put("query", where);
		mapWhere.put("params", params);

		return mapWhere;
	}
	// CHECKSTYLE:ON CyclomaticComplexity - Generación de código de UDA

	/**
	 * StringBuilder initilization value
	 */
	public static final int STRING_BUILDER_INIT = 4096;

	/**
	 * Recupera las tareas no ejecutadas para el tipo de tarea facilitado
	 * 
	 * @param idExpediente
	 * @return List<TareasTramite>
	 */
	@Transactional(readOnly = true)
	public List<TareasTramite> getLastExecutedTask(Long idExpediente, TramitesEnum tramite) {
		StringBuilder query = new StringBuilder(
				"SELECT  t1.ID_TAREA_TRAM_11 IDTAREATRAM11,t1.ID_ESTADO_11 IDESTADO11,t1.TASKGUID_11 TASKGUID11,t1.F_INICIO_11 FINICIO11,t1.F_FIN_11 FFIN11,t1.F_NOTIFICACION_11 FNOTIFICACION11,t1.F_ACUSE_11 FACUSE11,t1.TEXTO_REQ_11 TEXTOREQ11,t1.F_REGISTRO_11 FREGISTRO11,t1.NUM_REGISTRO_11 NUMREGISTRO11,t1.ESTADO_DOCUMENTACION_11 ESTADODOCUMENTACION11,t1.ID_NOTIFICACION_11 IDNOTIFICACION11,t1.F_ALTA_11 FALTA11,t1.USU_ALTA_11 USUALTA11,t1.F_MODIF_11 FMODIF11,t1.USU_MODIF_11 USUMODIF11, t1.DATOS_TAREA_11 DATOSTAREA11 "
						+ ",t2.ID_TAREA_38 MATAREASIDTAREA38,t2.TIPO_TAREA_38 MATAREASTIPOTAREA38,t2.DESC_ES_38 MATAREASDESCES38,t2.DESC_EU_38 MATAREASDESCEU38,"
						+ "t3.ID_TRAMITE_EXP_10 TRAEXPIDTRAMITEEXP10,t3.ID_EXPEDIENTE_10 TRAEXPIDEXPEDIENTE10,t3.ID_ESTADO_10 TRAEXPIDESTADO10,t3.F_INICIO_10 TRAEXPFINICIO10,t3.F_REALIZACION_10 TRAEXPFREALIZACION10,t3.OBSERVACIONES_10 TRAEXPOBSERVACIONES10,t3.F_ALTA_10 TRAEXPFALTA10,t3.USU_ALTA_10 TRAEXPUSUALTA10,t3.F_MODIF_10 TRAEXPFMODIF10,t3.USU_MODIF_10 TRAEXPUSUMODIF10,t2.ID_TIPO_DOC_38 MATAREASIDTIPODOC38,t2.ID_TRAMITE_38 MATAREASIDTRAMITE38,t3.ID_TRAMITE_10 TRAEXPIDTRAMITE10 ");
		query.append("FROM TAREAS_TRAMITE t1 ,MAESTRO_TAREAS t2 ,TRAMITES_EXPEDIENTE t3 ");

		StringBuilder where = new StringBuilder(
				" WHERE 1=1 AND t1.ID_TAREA_11= t2.ID_TAREA_38(+) AND t1.ID_TRAMITE_EXP_11= t3.ID_TRAMITE_EXP_10(+) AND ID_TAREA_11 = ? AND F_FIN_11 IS NOT NULL AND t3.ID_EXPEDIENTE_10 = ? ORDER BY F_FIN_11 DESC");

		query.append(where);

		List<Object> params = new ArrayList<Object>();
		params.add(tramite.getId());
		params.add(idExpediente);

		return (List<TareasTramite>) this.jdbcTemplate.query(query.toString(), this.rwMap, params.toArray());
	}

	/**
	 * Recupera las tareas no ejecutadas para el tipo de tarea facilitado
	 * 
	 * @param idExpediente
	 * @return List<TareasTramite>
	 */
	@Transactional(readOnly = true)
	public List<TareasTramite> getLastNotExecutedTask(Long idExpediente, TramitesEnum tramite) {
		StringBuilder query = new StringBuilder(
				"SELECT  t1.ID_TAREA_TRAM_11 IDTAREATRAM11,t1.ID_ESTADO_11 IDESTADO11,t1.TASKGUID_11 TASKGUID11,t1.F_INICIO_11 FINICIO11,t1.F_FIN_11 FFIN11,t1.F_NOTIFICACION_11 FNOTIFICACION11,t1.F_ACUSE_11 FACUSE11,t1.TEXTO_REQ_11 TEXTOREQ11,t1.F_REGISTRO_11 FREGISTRO11,t1.NUM_REGISTRO_11 NUMREGISTRO11,t1.ESTADO_DOCUMENTACION_11 ESTADODOCUMENTACION11,t1.ID_NOTIFICACION_11 IDNOTIFICACION11,t1.F_ALTA_11 FALTA11,t1.USU_ALTA_11 USUALTA11,t1.F_MODIF_11 FMODIF11,t1.USU_MODIF_11 USUMODIF11, t1.DATOS_TAREA_11 DATOSTAREA11 "
						+ ",t2.ID_TAREA_38 MATAREASIDTAREA38,t2.TIPO_TAREA_38 MATAREASTIPOTAREA38,t2.DESC_ES_38 MATAREASDESCES38,t2.DESC_EU_38 MATAREASDESCEU38,"
						+ "t3.ID_TRAMITE_EXP_10 TRAEXPIDTRAMITEEXP10,t3.ID_EXPEDIENTE_10 TRAEXPIDEXPEDIENTE10,t3.ID_ESTADO_10 TRAEXPIDESTADO10,t3.F_INICIO_10 TRAEXPFINICIO10,t3.F_REALIZACION_10 TRAEXPFREALIZACION10,t3.OBSERVACIONES_10 TRAEXPOBSERVACIONES10,t3.F_ALTA_10 TRAEXPFALTA10,t3.USU_ALTA_10 TRAEXPUSUALTA10,t3.F_MODIF_10 TRAEXPFMODIF10,t3.USU_MODIF_10 TRAEXPUSUMODIF10,t2.ID_TIPO_DOC_38 MATAREASIDTIPODOC38,t2.ID_TRAMITE_38 MATAREASIDTRAMITE38,t3.ID_TRAMITE_10 TRAEXPIDTRAMITE10 ");
		query.append("FROM TAREAS_TRAMITE t1 ,MAESTRO_TAREAS t2 ,TRAMITES_EXPEDIENTE t3 ");

		StringBuilder where = new StringBuilder(
				" WHERE 1=1 AND t1.ID_TAREA_11= t2.ID_TAREA_38(+) AND t1.ID_TRAMITE_EXP_11= t3.ID_TRAMITE_EXP_10(+) AND ID_TAREA_11 = ? AND F_FIN_11 IS NULL AND t3.ID_EXPEDIENTE_10 = ? ORDER BY F_FIN_11 DESC");

		query.append(where);

		List<Object> params = new ArrayList<Object>();
		params.add(tramite.getId());
		params.add(idExpediente);

		return (List<TareasTramite>) this.jdbcTemplate.query(query.toString(), this.rwMap, params.toArray());
	}

	private PreparedStatement getWhereMapPS(TareasTramite tareastramite, PreparedStatement psAux) {

		StringBuilder wherePS = new StringBuilder(TareasTramiteDaoImpl.STRING_BUILDER_INIT);
		List<Object> params = new ArrayList<Object>();
		int contParam = 0;
		try {
			if (tareastramite != null && tareastramite.getIdTareaTram11() != null) {
				wherePS.append(" AND t1.ID_TAREA_TRAM_11 = ?");

				psAux.setLong(contParam++, tareastramite.getIdTareaTram11());
			}
			if (tareastramite != null && tareastramite.getMaestroTareas() != null
					&& tareastramite.getMaestroTareas().getIdTarea38() != null) {
				wherePS.append(" AND t2.ID_TAREA_38 = ?");

				psAux.setLong(contParam++, tareastramite.getMaestroTareas().getIdTarea38());
			}
			if (tareastramite != null && tareastramite.getMaestroTareas() != null
					&& tareastramite.getMaestroTareas().getMaestroTiposDoc() != null
					&& tareastramite.getMaestroTareas().getMaestroTiposDoc().getIdTipoDoc36() != null) {
				wherePS.append(" AND t2.ID_TIPO_DOC_38 = ?");

				psAux.setLong(contParam++, tareastramite.getMaestroTareas().getMaestroTiposDoc().getIdTipoDoc36());
			}
			if (tareastramite != null && tareastramite.getMaestroTareas() != null
					&& tareastramite.getMaestroTareas().getMaestroTramites() != null
					&& tareastramite.getMaestroTareas().getMaestroTramites().getIdTramite37() != null) {
				wherePS.append(" AND t2.ID_TRAMITE_38 = ?");

				psAux.setLong(contParam++, tareastramite.getMaestroTareas().getMaestroTramites().getIdTramite37());
			}
			if (tareastramite != null && tareastramite.getMaestroTareas() != null
					&& tareastramite.getMaestroTareas().getTipoTarea38() != null) {
				wherePS.append(" AND t2.TIPO_TAREA_38 = ?");

				psAux.setString(contParam++, tareastramite.getMaestroTareas().getTipoTarea38());
			}
			if (tareastramite != null && tareastramite.getMaestroTareas() != null
					&& tareastramite.getMaestroTareas().getDescEs38() != null) {
				wherePS.append(" AND t2.DESC_ES_38 = ?");

				psAux.setString(contParam++, tareastramite.getMaestroTareas().getDescEs38());
			}
			if (tareastramite != null && tareastramite.getMaestroTareas() != null
					&& tareastramite.getMaestroTareas().getDescEu38() != null) {
				wherePS.append(" AND t2.DESC_EU_38 = ?");

				psAux.setString(contParam++, tareastramite.getMaestroTareas().getDescEu38());
			}
			if (tareastramite != null && tareastramite.getTramitesExpediente() != null
					&& tareastramite.getTramitesExpediente().getIdTramiteExp10() != null) {
				wherePS.append(" AND t3.ID_TRAMITE_EXP_10 = ?");

				psAux.setLong(contParam++, tareastramite.getTramitesExpediente().getIdTramiteExp10());
			}
			if (tareastramite != null && tareastramite.getTramitesExpediente() != null
					&& tareastramite.getTramitesExpediente().getMaestroTramites() != null
					&& tareastramite.getTramitesExpediente().getMaestroTramites().getIdTramite37() != null) {
				wherePS.append(" AND t3.ID_TRAMITE_10 = ?");

				psAux.setLong(contParam++, tareastramite.getMaestroTareas().getMaestroTramites().getIdTramite37());
			}
			if (tareastramite != null && tareastramite.getTramitesExpediente() != null
					&& tareastramite.getTramitesExpediente().getIdExpediente10() != null) {
				wherePS.append(" AND t3.ID_EXPEDIENTE_10 = ?");

				psAux.setLong(contParam++, tareastramite.getTramitesExpediente().getIdExpediente10());
			}
			if (tareastramite != null && tareastramite.getTramitesExpediente() != null
					&& tareastramite.getTramitesExpediente().getIdEstado10() != null) {
				wherePS.append(" AND t3.ID_ESTADO_10 = ?");

				psAux.setString(contParam++, tareastramite.getTramitesExpediente().getIdEstado10());
			}
			if (tareastramite != null && tareastramite.getTramitesExpediente() != null
					&& tareastramite.getTramitesExpediente().getfInicio10() != null) {
				wherePS.append(" AND t3.F_INICIO_10 = ?");

				// psAux.setDate(contParam++, new
				// Date(tareastramite.getTramitesExpediente().getfInicio10(.toString()));
			}
			if (tareastramite != null && tareastramite.getTramitesExpediente() != null
					&& tareastramite.getTramitesExpediente().getfRealizacion10() != null) {
				wherePS.append(" AND t3.F_REALIZACION_10 = ?");

				// psAux.setLong(contParam++,
				// tareastramite.getMaestroTareas().getMaestroTramites().getIdTramite37());
			}
			if (tareastramite != null && tareastramite.getTramitesExpediente() != null
					&& tareastramite.getTramitesExpediente().getObservaciones10() != null) {
				wherePS.append(" AND t3.OBSERVACIONES_10 = ?");

				psAux.setString(contParam++, tareastramite.getTramitesExpediente().getObservaciones10());
			}
			if (tareastramite != null && tareastramite.getTramitesExpediente() != null
					&& tareastramite.getTramitesExpediente().getfAlta10() != null) {
				wherePS.append(" AND t3.F_ALTA_10 = ?");

				// psAux.setLong(contParam++,
				// tareastramite.getMaestroTareas().getMaestroTramites().getIdTramite37());
			}
			if (tareastramite != null && tareastramite.getTramitesExpediente() != null
					&& tareastramite.getTramitesExpediente().getUsuAlta10() != null) {
				wherePS.append(" AND t3.USU_ALTA_10 = ?");

				psAux.setString(contParam++, tareastramite.getTramitesExpediente().getUsuAlta10());
			}
			if (tareastramite != null && tareastramite.getTramitesExpediente() != null
					&& tareastramite.getTramitesExpediente().getfModif10() != null) {
				wherePS.append(" AND t3.F_MODIF_10 = ?");

				// psAux.setLong(contParam++,
				// tareastramite.getMaestroTareas().getMaestroTramites().getIdTramite37());
			}
			if (tareastramite != null && tareastramite.getTramitesExpediente() != null
					&& tareastramite.getTramitesExpediente().getUsuModif10() != null) {
				wherePS.append(" AND t3.USU_MODIF_10 = ?");

				psAux.setString(contParam++, tareastramite.getTramitesExpediente().getUsuModif10());
			}
			if (tareastramite != null && tareastramite.getIdEstado11() != null) {
				wherePS.append(" AND t1.ID_ESTADO_11 = ?");

				psAux.setString(contParam++, tareastramite.getIdEstado11());
			}
			if (tareastramite != null && tareastramite.getTaskguid11() != null) {
				wherePS.append(" AND t1.TASKGUID_11 = ?");

				psAux.setString(contParam++, tareastramite.getTaskguid11());
			}
			if (tareastramite != null && tareastramite.getfInicio11() != null) {
				wherePS.append(" AND t1.F_INICIO_11 = ?");

				// psAux.setLong(contParam++,
				// tareastramite.getMaestroTareas().getMaestroTramites().getIdTramite37());
			}
			if (tareastramite != null && tareastramite.getfFin11() != null) {
				wherePS.append(" AND t1.F_FIN_11 = ?");
				// psAux.setLong(contParam++,
				// tareastramite.getMaestroTareas().getMaestroTramites().getIdTramite37());
			}
			if (tareastramite != null && tareastramite.getfNotificacion11() != null) {
				wherePS.append(" AND t1.F_NOTIFICACION_11 = ?");

				// psAux.setLong(contParam++,
				// tareastramite.getMaestroTareas().getMaestroTramites().getIdTramite37());
			}
			if (tareastramite != null && tareastramite.getfAcuse11() != null) {
				wherePS.append(" AND t1.F_ACUSE_11 = ?");

				// psAux.setLong(contParam++,
				// tareastramite.getMaestroTareas().getMaestroTramites().getIdTramite37());
			}
			if (tareastramite != null && tareastramite.getTextoReq11() != null) {
				wherePS.append(" AND t1.TEXTO_REQ_11 = ?");

				psAux.setString(contParam++, tareastramite.getTextoReq11());
			}
			if (tareastramite != null && tareastramite.getfRegistro11() != null) {
				wherePS.append(" AND t1.F_REGISTRO_11 = ?");

				// psAux.setLong(contParam++,
				// tareastramite.getMaestroTareas().getMaestroTramites().getIdTramite37());
			}
			if (tareastramite != null && tareastramite.getNumRegistro11() != null) {
				wherePS.append(" AND t1.NUM_REGISTRO_11 = ?");

				psAux.setString(contParam++, tareastramite.getNumRegistro11());
			}
			if (tareastramite != null && tareastramite.getEstadoDocumentacion11() != null) {
				wherePS.append(" AND t1.ESTADO_DOCUMENTACION_11 = ?");

				psAux.setString(contParam++, tareastramite.getEstadoDocumentacion11());
			}
			if (tareastramite != null && tareastramite.getIdNotificacion11() != null) {
				wherePS.append(" AND t1.ID_NOTIFICACION_11 = ?");

				psAux.setString(contParam++, tareastramite.getIdNotificacion11());
			}
			if (tareastramite != null && tareastramite.getfAlta11() != null) {
				wherePS.append(" AND t1.F_ALTA_11 = ?");

				// psAux.setLong(contParam++,
				// tareastramite.getMaestroTareas().getMaestroTramites().getIdTramite37());
			}
			if (tareastramite != null && tareastramite.getUsuAlta11() != null) {
				wherePS.append(" AND t1.USU_ALTA_11 = ?");

				psAux.setString(contParam++, tareastramite.getUsuAlta11());
			}
			if (tareastramite != null && tareastramite.getfModif11() != null) {
				wherePS.append(" AND t1.F_MODIF_11 = ?");

				// psAux.setLong(contParam++,
				// tareastramite.getMaestroTareas().getMaestroTramites().getIdTramite37());
			}
			if (tareastramite != null && tareastramite.getUsuModif11() != null) {
				wherePS.append(" AND t1.USU_MODIF_11 = ?");

				psAux.setString(contParam++, tareastramite.getUsuModif11());
			}
		} catch (SQLException sqle) {

		}

		return psAux;
	}

	/**
	 * Finds a single row in the TareasTramite table.
	 *
	 * @param tareastramite TareasTramite
	 * @return TareasTramite
	 */
//	@Transactional(readOnly = true)
//	public TareasTramite findIdTareaByTaskguid11(TareasTramite tareastramite) {
//
//		TareasTramiteDaoImpl.logger.info("TareasTramiteDaoImpl.findIdTareaByTaskguid11 - inicio  {}",
//				tareastramite.getTaskguid11());
//
//		StringBuilder query = new StringBuilder(
//				"SELECT ID_TAREA_TRAM_11 IDTAREATRAM11 FROM TAREAS_TRAMITE WHERE TASKGUID_11 = ?");
//
////		List<TareasTramite> tareastramiteList = this.jdbcTemplate.query(query.toString(), this.rwMapPK,
////				tareastramite.getTaskguid11());
//		TareasTramite result = new TareasTramite();
//		result.setTaskguid11(tareastramite.getTaskguid11());
//		ds = new DataSourceImpl("ad74a.ad74aDataSource", "jdbc:oracle:thin:@//ad74d:1530/ad74.ejie.eus", "ad74a",
//				"ad74a");
//
//		TareasTramiteDaoImpl.logger.info("TareasTramiteDaoImpl.findIdTareaByTaskguid11 - PRE TRY  ");
//		try (Connection con = ds.getConnection(); PreparedStatement ps = con.prepareStatement(query.toString());) {
//			TareasTramiteDaoImpl.logger.info("TareasTramiteDaoImpl.findIdTareaByTaskguid11 - TRY  1 ");
//			ps.setString(1, tareastramite.getTaskguid11());
//			TareasTramiteDaoImpl.logger.info("TareasTramiteDaoImpl.findIdTareaByTaskguid11 - TRY  2 ");
//			ResultSet rs = ps.executeQuery();
//			TareasTramiteDaoImpl.logger.info("TareasTramiteDaoImpl.findIdTareaByTaskguid11 - TRY  3 ");
//			rs.setFetchSize(1);
//			TareasTramiteDaoImpl.logger.info("TareasTramiteDaoImpl.findIdTareaByTaskguid11 - TRY  4 ");
//			// result.setIdTareaTram11(rs.getLong(1));
//			while (rs.next()) {
//				TareasTramiteDaoImpl.logger.info("TareasTramiteDaoImpl.findIdTareaByTaskguid11 - WHILE 1");
//				result.setIdTareaTram11(rs.getLong(1));
//				TareasTramiteDaoImpl.logger.info("TareasTramiteDaoImpl.findIdTareaByTaskguid11 - WHILE 2 -- {}",
//						result.getIdTareaTram11());
//			}
//		} catch (SQLException e) {
//			TareasTramiteDaoImpl.logger.info("TareasTramiteDaoImpl.findIdTareaByTaskguid11 - ERROR:{}", e.getMessage());
//		}
//
//		// return (TareasTramite) DataAccessUtils.uniqueResult(tareastramiteList);
//		return result;
//	}

	/**
	 * Finds a single row in the TareasTramite table.
	 *
	 * @param tareastramite TareasTramite
	 * @return TareasTramite
	 */
	@Transactional(readOnly = true)
	public TareasTramite findIdTareaByTaskguid11(TareasTramite tareastramite) {
		StringBuilder query = new StringBuilder(
				"SELECT ID_TAREA_TRAM_11 IDTAREATRAM11 FROM TAREAS_TRAMITE WHERE TASKGUID_11 = ?");

		List<TareasTramite> tareastramiteList = this.jdbcTemplate.query(query.toString(), this.rwMapPK,
				tareastramite.getTaskguid11());
		return (TareasTramite) DataAccessUtils.uniqueResult(tareastramiteList);
	}

}
