package com.fp.frontend.controller.armas.solicitud; import java.sql.Date; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Calendar; import java.util.GregorianCalendar; import java.util.HashMap; import java.util.List; import javax.annotation.PostConstruct; import javax.faces.bean.ManagedBean; import javax.faces.bean.ManagedProperty; import javax.faces.bean.ViewScoped; import javax.faces.event.AjaxBehaviorEvent; import com.fp.dto.Request; import com.fp.dto.Response; import com.fp.dto.query.DtoQuery; import com.fp.dto.query.Filter; import com.fp.dto.query.SubQuery; import com.fp.dto.save.DtoSave; import com.fp.frontend.controller.AbstractController; import com.fp.frontend.controller.armas.parametros.IngresoDatosTipoTramite; import com.fp.frontend.controller.pcustomer.PersonAddressController; import com.fp.frontend.controller.pcustomer.PersonDetailController; import com.fp.frontend.controller.pgeneral.gene.CatalogDetailController; import com.fp.frontend.controller.pgeneral.gene.ProvinceController; import com.fp.frontend.helper.MessageHelper; import com.fp.frontend.utility.MsgControlArmas; import com.fp.frontend.utility.Utilidades; import com.fp.persistence.parmas.fun.TarmRegistroArmas; import com.fp.persistence.parmas.param.TarmCentroControl; import com.fp.persistence.parmas.param.TarmTramite; import com.fp.persistence.parmas.soli.TarmAgenciaSucursal; import com.fp.persistence.parmas.soli.TarmArmas; import com.fp.persistence.parmas.soli.TarmDocumentoHabilitante; import com.fp.persistence.parmas.soli.TarmSolicitud; import com.fp.persistence.pcustomer.gene.TcustPersonDetail; import com.fp.persistence.pgeneral.gene.TgeneCatalogDetail; import com.fp.persistence.pgeneral.gene.TgeneProvince; /** * Controlador que maneja los documentos habilitantes del sistema * @author dcruz *O */ @ManagedBean @ViewScoped public class DocumentoHabilitanteController extends AbstractController { private static final long serialVersionUID = 1L; Date fechaInicio, fechaFin; @ManagedProperty(value = "#{personAddressController}") private PersonAddressController personAddressController; public DocumentoHabilitanteController() throws Exception{ super(TarmDocumentoHabilitante.class); } @PostConstruct public void postConstruct() { this.init(); super.startQuery(); } private void init(){ this.beanalias = "DOCUMENTOHABILITANTE"; this.recperpage = 15; this.lrecord = new ArrayList<>(); } @SuppressWarnings("unchecked") @Override protected void querydatabase() { try { DtoQuery dto = super.getDtoQuery(Boolean.TRUE); HashMap mtables = new HashMap(); mtables.put(beanalias, dto); // permite adicionar mas de una tabla. SubQuery subqueryCategoriaCodigo= new SubQuery("TgeneCatalogDetail", "description", "description", "i.pk.catalog = (select a.tipotramite from TarmTramite a where a.pk=t.ctramite)" + "and i.pk.catalogcode=(select a.tipotramitecodigo from TarmTramite a where a.pk=t.ctramite)"); dto.addSubQuery(subqueryCategoriaCodigo); SubQuery subqueryTipocodigo=new SubQuery("TgeneCatalogDetail", "description", "descriptiontram", "i.pk.catalog = (select a.categoria from TarmTramite a where a.pk=t.ctramite)" + "and i.pk.catalogcode=(select a.categoriacodigo from TarmTramite a where a.pk=t.ctramite)"); dto.addSubQuery(subqueryTipocodigo); SubQuery subqueryUsocodigo=new SubQuery("TgeneCatalogDetail", "description", "descriptionact", "i.pk.catalog = (select a.usoactividad from TarmTramite a where a.pk=t.ctramite)" + "and i.pk.catalogcode=(select a.usoactividadcodigo from TarmTramite a where a.pk=t.ctramite)"); dto.addSubQuery(subqueryUsocodigo); SubQuery subqueryEstadoDoc=new SubQuery("TgeneCatalogDetail", "description", "estadodocumento", "i.pk.catalog = t.estado" + " and i.pk.catalogcode= t.estadocode"); dto.addSubQuery(subqueryEstadoDoc); Request request = callerhelper.getRequest(); request.setQueryTables(mtables); Response resp = callerhelper.executeQuery(request); if (resp.getResponseCode().compareTo(Response.RESPONSE_OK) != 0) { lrecord = new ArrayList<>(); MessageHelper.setMessageError(resp); } else { lrecord = (List) resp.get(beanalias); if(lrecord!=null && !lrecord.isEmpty()){ for (TarmDocumentoHabilitante doc : lrecord) { doc.put("seleccionado", Boolean.FALSE); TarmArmas tarmArma = new TarmArmas(); tarmArma = ArmasController.find(doc.getCarma(), null); doc.modifiedData().put("carma",tarmArma==null?"":tarmArma.getPk()); doc.modifiedData().put("clase", tarmArma==null || tarmArma.getModifiedData().get("clase")==null?"":tarmArma.getModifiedData().get("clase")); doc.modifiedData().put("tipo", tarmArma==null || tarmArma.getModifiedData().get("tipo")==null ?"":tarmArma.getModifiedData().get("tipo")); doc.modifiedData().put("seriecanon",tarmArma==null || tarmArma.getSeriecanon()==null || tarmArma.getSeriecanon().isEmpty()?"":tarmArma.getSeriecanon()); doc.modifiedData().put("calibre", tarmArma==null || tarmArma.getModifiedData().get("calibre")==null?"":Utilidades.formatearDecimalesEnTexto(tarmArma.getModifiedData().get("calibre").toString(), "#.000")); doc.modifiedData().put("marca", tarmArma==null || tarmArma.getModifiedData().get("marca")==null?"":tarmArma.getModifiedData().get("marca")); doc.modifiedData().put("estado", tarmArma==null || tarmArma.getEstado()==null || tarmArma.getEstado().isEmpty() || tarmArma.getEstadocodigo()==null || tarmArma.getEstadocodigo().isEmpty()?"":CatalogDetailController.findxCodigoCodcatalogo( tarmArma.getEstado(), tarmArma.getEstadocodigo()).getDescription()); } record=lrecord.get(0); } super.postQuery(lrecord); } } catch (Throwable e) { MessageHelper.setMessageError(e); } } /** * Query para filtro por ciertos registros de codigo de tramites * @param listadosTramites */ protected void querydatabaseDocumentosCriterioFiltro(List listadosTramites, Boolean validarCaducidadBln, String codigopersona) { try { DtoQuery dto = super.getDtoQuery(Boolean.TRUE); java.util.Date fechaActual = new java.util.Date(); Filter filtroDocumento = new Filter(); StringBuffer bufferQuery = new StringBuffer(); SimpleDateFormat formato= new SimpleDateFormat("yyyy-MM-dd"); bufferQuery.append("("); if(validarCaducidadBln){ bufferQuery.append("t.fechaexpiracion >= " + "TO_DATE('" + formato.format(fechaActual)+ "','yyyy-MM-dd') and "); } int count=0; bufferQuery.append("t.personcode = " + codigopersona); bufferQuery.append(" and t.ctramite in ("); for(TarmTramite tramite:listadosTramites){ count++; bufferQuery.append(tramite.getPk()); if(count <= listadosTramites.size()-1){ bufferQuery.append(","); } } bufferQuery.append(")"); bufferQuery.append(" and t.estado = 'APR'"); bufferQuery.append(")"); filtroDocumento.setSql(bufferQuery.toString()); dto.addFiltro(filtroDocumento); HashMap mtables = new HashMap(); mtables.put(beanalias, dto); // permite adicionar mas de una tabla. Request request = callerhelper.getRequest(); request.setQueryTables(mtables); Response resp = callerhelper.executeQuery(request); if (resp.getResponseCode().compareTo(Response.RESPONSE_OK) != 0) { lrecord = new ArrayList<>(); MessageHelper.setMessageError(resp); } else { lrecord = (List) resp.get(beanalias); if(lrecord!=null && !lrecord.isEmpty()){ for (TarmDocumentoHabilitante doc : lrecord) { doc.put("seleccionado", Boolean.FALSE); TarmArmas tarmArma = new TarmArmas(); tarmArma = ArmasController.find(doc.getCarma(), null); doc.modifiedData().put("carma",tarmArma==null?"":tarmArma.getCodigoarma()); doc.modifiedData().put("clase", tarmArma==null || tarmArma.getModifiedData().get("clase")==null?"":tarmArma.getModifiedData().get("clase")); doc.modifiedData().put("tipo", tarmArma==null || tarmArma.getModifiedData().get("tipo")==null ?"":tarmArma.getModifiedData().get("tipo")); doc.modifiedData().put("seriecanon",tarmArma==null || tarmArma.getSeriecanon()==null || tarmArma.getSeriecanon().isEmpty()?"":tarmArma.getSeriecanon()); doc.modifiedData().put("calibre", tarmArma==null || tarmArma.getModifiedData().get("calibre")==null?"":Utilidades.formatearDecimalesEnTexto(tarmArma.getModifiedData().get("calibre").toString(), "#.000")); doc.modifiedData().put("marca", tarmArma==null || tarmArma.getModifiedData().get("marca")==null?"":tarmArma.getModifiedData().get("marca")); doc.modifiedData().put("estado", tarmArma==null || tarmArma.getEstado()==null || tarmArma.getEstado().isEmpty() || tarmArma.getEstadocodigo()==null || tarmArma.getEstadocodigo().isEmpty()?"":CatalogDetailController.findxCodigoCodcatalogo( tarmArma.getEstado(), tarmArma.getEstadocodigo()).getDescription()); } record=lrecord.get(0); } super.postQuery(lrecord); } } catch (Throwable e) { MessageHelper.setMessageError(e); } } protected void documentosXPersona(Integer codigoPersona) throws Exception { DtoQuery dto = super.getDtoQuery(Boolean.TRUE); java.util.Date fechaActual = new java.util.Date(); //Filter fechaFiltro= new Filter(); SimpleDateFormat formato= new SimpleDateFormat("yyyy-MM-dd"); Filter fechaEstadoFiltro= new Filter(); StringBuffer bufferQuery = new StringBuffer(); int count=0; bufferQuery.append("t.estado = 'APR' and" + " t.personcode = '" + codigoPersona.toString() + "' and trunc(t.fechaexpiracion) >= " + "TO_DATE('" + formato.format(fechaActual)+ "','yyyy-MM-dd')"); fechaEstadoFiltro.setSql(bufferQuery.toString()); dto.addFiltro(fechaEstadoFiltro); HashMap mtables = new HashMap(); mtables.put(beanalias, dto); // permite adicionar mas de una tabla. Request request = callerhelper.getRequest(); request.setQueryTables(mtables); Response resp; try { try { resp = callerhelper.executeQuery(request); } catch (Throwable e) { // TODO Auto-generated catch block throw new Exception(); } if (resp.getResponseCode().compareTo(Response.RESPONSE_OK) != 0) { lrecord = new ArrayList<>(); //MessageHelper.setMessageError(resp); throw new Exception(); } else { lrecord = (List) resp.get(beanalias); if(lrecord!=null && !lrecord.isEmpty()){ for (TarmDocumentoHabilitante doc : lrecord) { doc.put("seleccionado", Boolean.FALSE); TarmArmas tarmArma = new TarmArmas(); tarmArma = ArmasController.find(doc.getCarma(), null); doc.modifiedData().put("carma",tarmArma==null?"":tarmArma.getCodigoarma()); doc.modifiedData().put("clase", tarmArma==null || tarmArma.getModifiedData().get("clase")==null?"":tarmArma.getModifiedData().get("clase")); doc.modifiedData().put("tipo", tarmArma==null || tarmArma.getModifiedData().get("tipo")==null ?"":tarmArma.getModifiedData().get("tipo")); doc.modifiedData().put("lote",tarmArma==null || tarmArma.getLote()==null || tarmArma.getLote().isEmpty()?"":tarmArma.getLote()); doc.modifiedData().put("calibre", tarmArma==null || tarmArma.getModifiedData().get("calibre")==null?"":Utilidades.formatearDecimalesEnTexto(tarmArma.getModifiedData().get("calibre").toString(), "#.00")); doc.modifiedData().put("marca", tarmArma==null || tarmArma.getModifiedData().get("marca")==null?"":tarmArma.getModifiedData().get("marca")); doc.modifiedData().put("estado", tarmArma==null || tarmArma.getEstado()==null || tarmArma.getEstado().isEmpty() || tarmArma.getEstadocodigo()==null || tarmArma.getEstadocodigo().isEmpty()?"":CatalogDetailController.findxCodigoCodcatalogo( tarmArma.getEstado(), tarmArma.getEstadocodigo()).getDescription()); TarmTramite tramiteDocumento = IngresoDatosTipoTramite.find(doc.getCtramite().toString()); if(tramiteDocumento!=null){ doc.modifiedData().put("destipoTramite", tramiteDocumento.getModifiedData().get("destipoTramite")!=null?tramiteDocumento.getModifiedData().get("destipoTramite").toString():null); doc.modifiedData().put("destipoAutorizacion", tramiteDocumento.getModifiedData().get("destipoAutorizacion")!=null?tramiteDocumento.getModifiedData().get("destipoAutorizacion").toString():null); doc.modifiedData().put("descategoria", tramiteDocumento.getModifiedData().get("descategoria")!=null?tramiteDocumento.getModifiedData().get("descategoria").toString():null); doc.modifiedData().put("desusoactividad", tramiteDocumento.getModifiedData().get("desusoactividad")!=null?tramiteDocumento.getModifiedData().get("desusoactividad").toString():null); } else{ doc.modifiedData().put("destipoTramite", null); doc.modifiedData().put("destipoAutorizacion", null); doc.modifiedData().put("descategoria", null); doc.modifiedData().put("desusoactividad", null); } } record=lrecord.get(0); } super.postQuery(lrecord); } } catch (Exception e) { // TODO Auto-generated catch block throw new Exception(); } } protected void documentosXTramite(List listadoTramites, Integer codigoPersona) throws Exception { DtoQuery dto = super.getDtoQuery(Boolean.TRUE); java.util.Date fechaActual = new java.util.Date(); //Filter fechaFiltro= new Filter(); SimpleDateFormat formato= new SimpleDateFormat("yyyy-MM-dd"); Filter tramitesFiltro= new Filter(); StringBuffer bufferQuery = new StringBuffer(); int count=0; bufferQuery.append("("); if(listadoTramites!=null){ for(TarmTramite tramite:listadoTramites){ count++; bufferQuery.append("(t.ctramite = " + tramite.getPk() +") "); if(count <= listadoTramites.size()-1){ bufferQuery.append(" or "); } } } bufferQuery.append(") and t.estado = 'APR' and" + " t.personcode = '" + codigoPersona.toString() + "' and trunc(t.fechaexpiracion) >= " + "TO_DATE('" + formato.format(fechaActual)+ "','yyyy-MM-dd')"); tramitesFiltro.setSql(bufferQuery.toString()); dto.addFiltro(tramitesFiltro); HashMap mtables = new HashMap(); mtables.put(beanalias, dto); // permite adicionar mas de una tabla. Request request = callerhelper.getRequest(); request.setQueryTables(mtables); Response resp; try { try { resp = callerhelper.executeQuery(request); } catch (Throwable e) { // TODO Auto-generated catch block throw new Exception(); } if (resp.getResponseCode().compareTo(Response.RESPONSE_OK) != 0) { lrecord = new ArrayList<>(); //MessageHelper.setMessageError(resp); throw new Exception(); } else { lrecord = (List) resp.get(beanalias); if(lrecord!=null && !lrecord.isEmpty()){ for (TarmDocumentoHabilitante doc : lrecord) { doc.put("seleccionado", Boolean.FALSE); TarmArmas tarmArma = new TarmArmas(); tarmArma = ArmasController.find(doc.getCarma(), null); doc.modifiedData().put("carma",tarmArma==null?"":tarmArma.getCodigoarma()); doc.modifiedData().put("clase", tarmArma==null || tarmArma.getModifiedData().get("clase")==null?"":tarmArma.getModifiedData().get("clase")); doc.modifiedData().put("tipo", tarmArma==null || tarmArma.getModifiedData().get("tipo")==null ?"":tarmArma.getModifiedData().get("tipo")); doc.modifiedData().put("lote",tarmArma==null || tarmArma.getLote()==null || tarmArma.getLote().isEmpty()?"":tarmArma.getLote()); doc.modifiedData().put("calibre", tarmArma==null || tarmArma.getModifiedData().get("calibre")==null?"":Utilidades.formatearDecimalesEnTexto(tarmArma.getModifiedData().get("calibre").toString(), "#.00")); doc.modifiedData().put("marca", tarmArma==null || tarmArma.getModifiedData().get("marca")==null?"":tarmArma.getModifiedData().get("marca")); doc.modifiedData().put("estado", tarmArma==null || tarmArma.getEstado()==null || tarmArma.getEstado().isEmpty() || tarmArma.getEstadocodigo()==null || tarmArma.getEstadocodigo().isEmpty()?"":CatalogDetailController.findxCodigoCodcatalogo( tarmArma.getEstado(), tarmArma.getEstadocodigo()).getDescription()); TarmTramite tramiteDocumento = IngresoDatosTipoTramite.find(doc.getCtramite().toString()); if(tramiteDocumento!=null){ doc.modifiedData().put("destipoTramite", tramiteDocumento.getModifiedData().get("destipoTramite")!=null?tramiteDocumento.getModifiedData().get("destipoTramite").toString():null); doc.modifiedData().put("destipoAutorizacion", tramiteDocumento.getModifiedData().get("destipoAutorizacion")!=null?tramiteDocumento.getModifiedData().get("destipoAutorizacion").toString():null); doc.modifiedData().put("descategoria", tramiteDocumento.getModifiedData().get("descategoria")!=null?tramiteDocumento.getModifiedData().get("descategoria").toString():null); doc.modifiedData().put("desusoactividad", tramiteDocumento.getModifiedData().get("desusoactividad")!=null?tramiteDocumento.getModifiedData().get("desusoactividad").toString():null); } else{ doc.modifiedData().put("destipoTramite", null); doc.modifiedData().put("destipoAutorizacion", null); doc.modifiedData().put("descategoria", null); doc.modifiedData().put("desusoactividad", null); } } record=lrecord.get(0); } super.postQuery(lrecord); } } catch (Exception e) { // TODO Auto-generated catch block throw new Exception(); } } /** * Query para filtro por ciertos registros de codigo de tramites * @param listadoSolicitudes * @throws Exception * @throws Throwable */ protected void querydatabaseDocumentosCriterioFiltro(List listadoSolicitudes, Integer codigoPersona) throws Exception { DtoQuery dto = super.getDtoQuery(Boolean.TRUE); java.util.Date fechaActual = new java.util.Date(); //Filter fechaFiltro= new Filter(); SimpleDateFormat formato= new SimpleDateFormat("yyyy-MM-dd"); Filter tramitesFiltro= new Filter(); StringBuffer bufferQuery = new StringBuffer(); int count=0; bufferQuery.append("("); if(listadoSolicitudes!=null){ for(TarmSolicitud solicitud:listadoSolicitudes){ count++; bufferQuery.append("(t.ctramite = " + solicitud.getCtramite() + " and t.csolicitud = " + solicitud.getPk() + ") "); if(count <= listadoSolicitudes.size()-1){ bufferQuery.append(" or "); } } } bufferQuery.append(") and t.estado = 'APR' and" + " t.personcode = '" + codigoPersona.toString() + "' and trunc(t.fechaexpiracion) >= " + "TO_DATE('" + formato.format(fechaActual)+ "','yyyy-MM-dd')"); tramitesFiltro.setSql(bufferQuery.toString()); dto.addFiltro(tramitesFiltro); HashMap mtables = new HashMap(); mtables.put(beanalias, dto); // permite adicionar mas de una tabla. Request request = callerhelper.getRequest(); request.setQueryTables(mtables); Response resp; try { try { resp = callerhelper.executeQuery(request); } catch (Throwable e) { // TODO Auto-generated catch block throw new Exception(); } if (resp.getResponseCode().compareTo(Response.RESPONSE_OK) != 0) { lrecord = new ArrayList<>(); //MessageHelper.setMessageError(resp); throw new Exception(); } else { lrecord = (List) resp.get(beanalias); if(lrecord!=null && !lrecord.isEmpty()){ for (TarmDocumentoHabilitante doc : lrecord) { doc.put("seleccionado", Boolean.FALSE); TarmArmas tarmArma = new TarmArmas(); tarmArma = ArmasController.find(doc.getCarma(), null); doc.modifiedData().put("carma",tarmArma==null?"":tarmArma.getCodigoarma()); doc.modifiedData().put("clase", tarmArma==null || tarmArma.getModifiedData().get("clase")==null?"":tarmArma.getModifiedData().get("clase")); doc.modifiedData().put("tipo", tarmArma==null || tarmArma.getModifiedData().get("tipo")==null ?"":tarmArma.getModifiedData().get("tipo")); doc.modifiedData().put("seriecanon",tarmArma==null || tarmArma.getSeriecanon()==null || tarmArma.getSeriecanon().isEmpty()?"":tarmArma.getSeriecanon()); doc.modifiedData().put("calibre", tarmArma==null || tarmArma.getModifiedData().get("calibre")==null?"":Utilidades.formatearDecimalesEnTexto(tarmArma.getModifiedData().get("calibre").toString(), "#.00")); doc.modifiedData().put("marca", tarmArma==null || tarmArma.getModifiedData().get("marca")==null?"":tarmArma.getModifiedData().get("marca")); doc.modifiedData().put("estado", tarmArma==null || tarmArma.getEstado()==null || tarmArma.getEstado().isEmpty() || tarmArma.getEstadocodigo()==null || tarmArma.getEstadocodigo().isEmpty()?"":CatalogDetailController.findxCodigoCodcatalogo( tarmArma.getEstado(), tarmArma.getEstadocodigo()).getDescription()); } record=lrecord.get(0); } super.postQuery(lrecord); } } catch (Exception e) { // TODO Auto-generated catch block throw new Exception(); } } @SuppressWarnings("unchecked") protected void querybase() { try { DtoQuery dto = super.getDtoQuery(Boolean.TRUE); dto.setOrderby("t.fechaemision"); if(getMfilelds().get("auxfiltro")!=null){ Filter filtro= new Filter(); filtro.setSql(getMfilelds().get("auxfiltro").toString());//"t.ctramite in (Select ctramite from tarmtramite where tipoautorizacion='1'"); dto.addFiltro(filtro); } if(getMfilelds().get("fechafiltro")!=null){ Filter filtrofecha=new Filter(); filtrofecha.setSql(getMfilelds().get("fechafiltro").toString()); dto.addFiltro(filtrofecha); } if(getMfilelds().get("numdocumentoshabilitante")!=null){ Filter filtrodoc=new Filter(); filtrodoc.setSql(getMfilelds().get("numdocumentoshabilitante").toString()); dto.addFiltro(filtrodoc); } SubQuery subQuerytipotramite= new SubQuery("TarmTramite","tipotramite","tipotramite","i.pk=t.ctramite"); dto.addSubQuery(subQuerytipotramite); SubQuery subQuerytipotramitecodigo= new SubQuery("TarmTramite","tipotramitecodigo","tipotramitecodigo","i.pk=t.ctramite"); dto.addSubQuery(subQuerytipotramitecodigo); SubQuery subQuerytipoautorizacion= new SubQuery("TarmTramite","tipoautorizacion","tipoautorizacion","i.pk=t.ctramite"); dto.addSubQuery(subQuerytipoautorizacion); SubQuery subQuerytipoautorizacioncodigo= new SubQuery("TarmTramite","tipoautorizacioncodigo","tipoautorizacioncodigo","i.pk=t.ctramite"); dto.addSubQuery(subQuerytipoautorizacioncodigo); SubQuery subQuerycategoria= new SubQuery("TarmTramite","categoria","categoria","i.pk=t.ctramite"); dto.addSubQuery(subQuerycategoria); SubQuery subQuerycategoriacodigo= new SubQuery("TarmTramite","categoriacodigo","categoriacodigo","i.pk=t.ctramite"); dto.addSubQuery(subQuerycategoriacodigo); HashMap mtables = new HashMap(); mtables.put(beanalias, dto); // permite adicionar mas de una tabla. Request request = callerhelper.getRequest(); request.setQueryTables(mtables); Response resp = callerhelper.executeQuery(request); if (resp.getResponseCode().compareTo(Response.RESPONSE_OK) != 0) { lrecord = new ArrayList<>(); MessageHelper.setMessageError(resp); } else { lrecord = (List) resp.get(beanalias); if(lrecord!=null && !lrecord.isEmpty()){ record=lrecord.get(0); } super.postQuery(lrecord); for(int i=0;i< this.lrecord.size();i++){ try{ TgeneCatalogDetail tipotramite=CatalogDetailController.findxCodigoCodcatalogo(this.lrecord.get(i).getModifiedData().get("tipotramite").toString(),this.lrecord.get(i).getModifiedData().get("tipotramitecodigo").toString() ); this.lrecord.get(i).getModifiedData().put("tipotramitedesc", tipotramite.getDescription()); } catch(Exception e){ e.printStackTrace(); } try{ TgeneCatalogDetail tipo = CatalogDetailController.findxCodigoCodcatalogo(this.lrecord.get(i).getModifiedData().get("tipoautorizacion").toString(), this.lrecord.get(i).getModifiedData().get("tipoautorizacioncodigo").toString()); this.lrecord.get(i).getModifiedData().put("tipoautorizacioncodigodesc", tipo.getDescription()); } catch(Exception e){ e.printStackTrace(); } try{ TgeneCatalogDetail tipo = CatalogDetailController.findxCodigoCodcatalogo(this.lrecord.get(i).getModifiedData().get("categoria").toString(), this.lrecord.get(i).getModifiedData().get("categoriacodigo").toString()); this.lrecord.get(i).getModifiedData().put("categoriacodigodesc", tipo.getDescription()); } catch(Exception e){ e.printStackTrace(); } } } } catch (Throwable e) { MessageHelper.setMessageError(e); } } protected void querydatabaseInspeccion2(Date fechaInicio, Date fechaFin,TarmCentroControl centroControl){ try { DtoQuery dto = super.getDtoQuery(Boolean.TRUE); SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); dto.setOrderby("fechaexpiracion"); //Nombre/Razon social SubQuery subqueryNombre= new SubQuery("TcustPersonDetail","name", "nombre", "i.pk.personcode=t.personcode and i.pk.dateto = to_date('2999-12-31', 'YYYY-MM-DD')"); dto.addSubQuery(subqueryNombre); SubQuery subqueryNDocumento= new SubQuery("TcustPersonDetail","identification","nodocumento","i.pk.personcode=t.personcode and i.pk.dateto= to_date('2999-12-31', 'YYYY-MM-DD')"); dto.addSubQuery(subqueryNDocumento); //datos del tramite //Tipo de tramite SubQuery subqueryTipoTramite= new SubQuery("TgeneCatalogDetail","description","tipotramite","i.pk.catalog= (select o.tipotramite from TarmTramite o where o.pk=t.ctramite) and" + " i.pk.catalogcode=(select o.tipotramitecodigo from TarmTramite o where o.pk=t.ctramite)"); dto.addSubQuery(subqueryTipoTramite); SubQuery subqueryTramite= new SubQuery("TgeneCatalogDetail","description","tipoautorizacion","i.pk.catalog= (select o.tipoautorizacion from TarmTramite o where o.pk=t.ctramite) and" + " i.pk.catalogcode=(select o.tipoautorizacioncodigo from TarmTramite o where o.pk=t.ctramite) "); dto.addSubQuery(subqueryTramite); //Uso/Actividad SubQuery subqueryUsoActividad= new SubQuery("TgeneCatalogDetail","description","usoactividad","i.pk.catalog= (select o.usoactividad from TarmTramite o where o.pk=t.ctramite) and" + " i.pk.catalogcode=(select o.usoactividadcodigo from TarmTramite o where o.pk=t.ctramite)"); dto.addSubQuery(subqueryUsoActividad); //Categoria SubQuery subqueryCategoria= new SubQuery("TgeneCatalogDetail","description","categoria","i.pk.catalog= (select o.categoria from TarmTramite o where o.pk=t.ctramite) and" + " i.pk.catalogcode=(select o.categoriacodigo from TarmTramite o where o.pk=t.ctramite)"); dto.addSubQuery(subqueryCategoria); SubQuery subqueryCodTramite=new SubQuery("TarmTramite", "pk", "ctramite", "i.pk= t.ctramite"); dto.addSubQuery(subqueryCodTramite); //Filtros de fecha inicio y fin if(fechaInicio!=null){ //dto.addFiltro(new Filter("fechaexpiracion", ">=", fechaInicio.toString())); //dto.addFiltro(new Filter("fechaexpiracion", "<", this.fechaFin.toString())); Filter filtro= new Filter(); filtro.setSql( //+ "t.fechaexpiracion>=TO_DATE('" + dateFormat.format(fechaInicio)+ "','yyyy-MM-dd')" "TRUNC(t.fechaexpiracion)<=TO_DATE('" + dateFormat.format(fechaFin)+ "','yyyy-MM-dd')" + " and t.ctramite in (select o.pk from TarmTramite o where o.tipoautorizacion = '1' and o.requiereinspeccion = 'Y') " +" and t.centrocontrol ='" + centroControl.getPk() + "'" //+ " and t.csolicitud in (select q.pk from TarmSolicitud q where q.ccentrocontrol = '" + centroControl.getPk() + "' )" + " and t.estado = 'APR'"); dto.addFiltro(filtro); } HashMap mtables = new HashMap(); mtables.put(beanalias, dto); // permite adicionar mas de una tabla. Request request = callerhelper.getRequest(); request.setQueryTables(mtables); Response resp = callerhelper.executeQuery(request); if (resp.getResponseCode().compareTo(Response.RESPONSE_OK) != 0) { lrecord = new ArrayList<>(); MessageHelper.setMessageError(resp); } else { lrecord = (List) resp.get(beanalias); if(lrecord!=null && !lrecord.isEmpty()){ for (TarmDocumentoHabilitante doc : lrecord) { doc.put("seleccionado", Boolean.FALSE); } record=lrecord.get(0); } super.postQuery(lrecord); } } catch (Throwable e) { MessageHelper.setMessageError(e); } } //Anteriormente se usaba para consultar actualmente ya no protected void querydatabaseInspeccion() { try { DtoQuery dto = super.getDtoQuery(Boolean.TRUE); dto.setOrderby("fechaexpiracion"); //Nombre/Razon social //SubQuery subqueryNombre= new SubQuery("TcustPersonDetail","name","nombre","i.pk.personcode=t.personcode"); //dto.addSubQuery(subqueryNombre); //Filtros de fecha inicio y fin if(this.fechaInicio!=null){ dto.addFiltro(new Filter("fechaexpiracion", ">=", this.fechaInicio.toString())); //dto.addFiltro(new Filter("fechaexpiracion", "<", this.fechaFin.toString())); } HashMap mtables = new HashMap(); mtables.put(beanalias, dto); // permite adicionar mas de una tabla. Request request = callerhelper.getRequest(); request.setQueryTables(mtables); Response resp = callerhelper.executeQuery(request); if (resp.getResponseCode().compareTo(Response.RESPONSE_OK) != 0) { lrecord = new ArrayList<>(); MessageHelper.setMessageError(resp); } else { lrecord = (List) resp.get(beanalias); if(lrecord!=null && !lrecord.isEmpty()){ for (TarmDocumentoHabilitante doc : lrecord) { doc.put("seleccionado", Boolean.FALSE); } record=lrecord.get(0); } super.postQuery(lrecord); } } catch (Throwable e) { MessageHelper.setMessageError(e); } } @Override public void save() { try { DtoSave dtosave = super.getDtoSave(); dtosave.setReturnpk(true); // Para que el core devuelva el pk de los registros nuevos. if(!dtosave.pendingProcess()){ return; } HashMap msave = new HashMap(); Request request = callerhelper.getRequest(); msave.put(beanalias, dtosave); // adicionar metadata de mantenimiento para cada tabla. request.setSaveTables(msave); Response resp = callerhelper.executeSave(request); if (resp.getResponseCode().compareTo(Response.RESPONSE_OK) == 0) { this.postCommit(resp); MessageHelper.setMessageInfo(resp); } else { MessageHelper.setMessageError(resp); } } catch (Throwable e) { MessageHelper.setMessageError(e); } } /** * Metodo para guardar el documento habilitante * @throws Throwable */ public void saveDocumentoHabilitante() throws Throwable { DtoSave dtosave = super.getDtoSave(); dtosave.setReturnpk(true); // Para que el core devuelva el pk de los registros nuevos. HashMap msave = new HashMap(); Request request = callerhelper.getRequest(); msave.put(beanalias, dtosave); // adicionar metadata de mantenimiento para cada tabla. request.setSaveTables(msave); Response resp = callerhelper.executeSave(request); if (resp.getResponseCode().compareTo(Response.RESPONSE_OK) == 0) { this.postCommit(resp); MessageHelper.setMessageInfo(resp); } else { MessageHelper.setMessageError(resp); } } /** * Devueleve el tipo de tramite de un documento * @param documento * @return */ public String tipoTramite(TarmDocumentoHabilitante documento){ String tipo=""; try { //Obteniendo la solicitud TarmSolicitud solicitud= ValidacionTramiteLibreTransitoController.findPorSolicitudSimple(documento.getCsolicitud()); if(solicitud!=null){ TarmTramite tramite=TarmTramiteController.find(solicitud.getCtramite().toString()); if(tramite!=null && tramite.getTipotramite()!=null && !tramite.getTipotramite().isEmpty() && tramite.getTipotramitecodigo()!=null && !tramite.getTipotramitecodigo().isEmpty()){ TgeneCatalogDetail catalogoTipoTramite= CatalogDetailController.findxCodigoCodcatalogo(tramite.getTipotramite(), tramite.getTipotramitecodigo()); if(catalogoTipoTramite!=null){ tipo=catalogoTipoTramite.getDescription(); } } } } catch (Exception e) { MessageHelper.setMessageError(e); } return tipo; } public String tramite(TarmDocumentoHabilitante documento) { String tipo=""; try { //Obteniendo la solicitud TarmSolicitud solicitud= ValidacionTramiteLibreTransitoController.findPorSolicitudSimple(documento.getCsolicitud()); if(solicitud!=null){ TarmTramite tramite=TarmTramiteController.find(solicitud.getCtramite().toString()); if(tramite!=null && tramite.getTipoautorizacion()!=null && !tramite.getTipoautorizacion().isEmpty() && tramite.getTipoautorizacioncodigo()!=null && !tramite.getTipoautorizacioncodigo().isEmpty()){ TgeneCatalogDetail catalogoTramite= CatalogDetailController.findxCodigoCodcatalogo(tramite.getTipoautorizacion(), tramite.getTipoautorizacioncodigo()); if(catalogoTramite!=null){ tipo=catalogoTramite.getDescription(); } } } } catch (Exception e) { MessageHelper.setMessageError(e); } return tipo; } /** * Devueleve la categoria de un documento * @param documento * @return */ public String categoria(TarmDocumentoHabilitante documento){ String categoria=""; try { //Obteniendo la solicitud TarmSolicitud solicitud= ValidacionTramiteLibreTransitoController.findPorSolicitudSimple(documento.getCsolicitud()); if(solicitud!=null){ TarmTramite tramite=TarmTramiteController.find(solicitud.getCtramite().toString()); if(tramite!=null && tramite.getCategoria()!=null && !tramite.getCategoria().isEmpty() && tramite.getCategoriacodigo()!=null && !tramite.getCategoriacodigo().isEmpty()){ TgeneCatalogDetail catalogoCategoria= CatalogDetailController.findxCodigoCodcatalogo(tramite.getCategoria(), tramite.getCategoriacodigo()); if(catalogoCategoria!=null){ categoria=catalogoCategoria.getDescription(); } } } } catch (Exception e) { MessageHelper.setMessageError(e); } return categoria; } public static List findInspeccionesGenerar(Date fechaInicio, Date fechaFin, TarmCentroControl centroControl) { try { DocumentoHabilitanteController cc = new DocumentoHabilitanteController(); cc.init(); cc.recperpage = 300000; //cc.addFilter("personcode", personcode); cc.querydatabaseInspeccion2(fechaInicio,fechaFin,centroControl); if (cc.lrecord != null) { return cc.lrecord; } return null; } catch (Throwable e) { MessageHelper.setMessageError(e); return null; } } public static List findDocumentosDelTramite(String personcode, String filtro) { try { DocumentoHabilitanteController cc = new DocumentoHabilitanteController(); cc.init(); cc.recperpage = 3000; cc.addFilter("personcode", personcode); cc.getMfilelds().put("auxfiltro",filtro); cc.querybase(); if (cc.lrecord != null) { return cc.lrecord; } return null; } catch (Throwable e) { MessageHelper.setMessageError(e); return null; } } public static List findPorPersoncode(String personcode) { try { DocumentoHabilitanteController cc = new DocumentoHabilitanteController(); cc.init(); cc.recperpage = 3000; cc.addFilter("personcode", personcode); cc.querybase(); if (cc.lrecord != null) { return cc.lrecord; } return null; } catch (Throwable e) { MessageHelper.setMessageError(e); return null; } } /** * buscar el permiso de coumento habilitante por arma * @return */ public static TarmDocumentoHabilitante findxarma( String codigoarma, String personcode){ try { DocumentoHabilitanteController cc = new DocumentoHabilitanteController(); cc.init(); cc.recperpage = 30; cc.addFilter("codigoarma", codigoarma); cc.addFilter("personcode", personcode); cc.querybase(); if (cc.record != null) { return cc.record; } return null; } catch (Throwable e) { MessageHelper.setMessageError(e); return null; } } public static List findPorPersoncodeaut(String personcode) { try { DocumentoHabilitanteController cc = new DocumentoHabilitanteController(); cc.init(); cc.recperpage = 30; cc.addFilter("personcode", personcode); cc.addFilter("estado", "APR"); cc.getMfilelds().put("auxfiltro", "t.ctramite in (Select ta.pk from com.fp.persistence.parmas.param.TarmTramite ta where ta.tipoautorizacion='1') and" +" ctramite in (select o from TarmTramite o where o.sancionable is not null and o.sancionable='Y') ");//tramite que sean sancionables cc.getMfilelds().put("fechafiltro", "t.fechaemision = (Select max(ta.fechaemision) from com.fp.persistence.parmas.soli.TarmDocumentoHabilitante ta where t.ctramite=ta.ctramite and t.personcode=ta.personcode )"); cc.querybase(); if (cc.lrecord != null) { return cc.lrecord; } return null; } catch (Throwable e) { MessageHelper.setMessageError(e); return null; } } public static List findXSolicitudNueva(String csolicitud) { try { DocumentoHabilitanteController cc = new DocumentoHabilitanteController(); cc.init(); cc.recperpage = 30; cc.getMfilelds().put("numdocumentoshabilitante", "t.pk in (Select sd.pk.cdocumento from com.fp.persistence.parmas.soli.TarmSolicitud s, com.fp.persistence.parmas.soli.TarmSolicitudDocumento sd where s.pk = sd.pk.csolicitud and s.pk = '"+csolicitud+"')"); cc.querybase(); if (cc.lrecord != null) { return cc.lrecord; } return null; } catch (Throwable e) { MessageHelper.setMessageError(e); return null; } } /** * Devueleve la categoria de un documento * @param documento * @return */ public String usoActividad(TarmDocumentoHabilitante documento){ String usoActividad=""; try { //Obteniendo la solicitud TarmSolicitud solicitud= ValidacionTramiteLibreTransitoController.findPorSolicitudSimple(documento.getCsolicitud()); if(solicitud!=null){ TarmTramite tramite=TarmTramiteController.find(solicitud.getCtramite().toString()); if(tramite!=null && tramite.getUsoactividad()!=null && !tramite.getUsoactividad().isEmpty() && tramite.getUsoactividadcodigo()!=null && !tramite.getUsoactividadcodigo().isEmpty()){ TgeneCatalogDetail catalogoUso= CatalogDetailController.findxCodigoCodcatalogo(tramite.getUsoactividad(), tramite.getUsoactividadcodigo()); if(catalogoUso!=null){ usoActividad=catalogoUso.getDescription(); } } } } catch (Exception e) { MessageHelper.setMessageError(e); } return usoActividad; } /** * Devueleve la ubicacion de un documento * @param documento * @return */ public String ubicacion(TarmDocumentoHabilitante documento){ String ubicacion=""; try { TcustPersonDetail detallesPersona=PersonDetailController.find(documento.getPersoncode().toString()); if(detallesPersona!=null){ personAddressController.findPrincipal(String.valueOf(documento.getPersoncode())) ; if(personAddressController.getLrecord().get(0).getProvincecode()!=null && !personAddressController.getLrecord().get(0).getProvincecode().isEmpty()){ List provinceList = ProvinceController.findPorCodigo("EC", personAddressController.getLrecord().get(0).getProvincecode()); ubicacion = provinceList.get(0).getDescription(); } } } catch (Exception e) { MessageHelper.setMessageError(e); } return ubicacion; } /** * Devuelve el estado de un documento habilitante * @param documento documento * @return estado */ public String estado(TarmDocumentoHabilitante documento){ TgeneCatalogDetail estado = new TgeneCatalogDetail(); try { if(documento==null){ return ""; } estado = CatalogDetailController.findxCodigoCodcatalogo(documento.getEstado(),documento.getEstadocode()); } catch (Exception e) { MessageHelper.setMessageError(e); } return estado.getDescription(); } /** * Seleccionado todos los registros de la tabla */ public void seleccionarTodos(AjaxBehaviorEvent event) { try { Boolean valorColocar = Boolean.FALSE; if(Boolean.valueOf(event.getComponent().getAttributes().get("value") != null ? event.getComponent().getAttributes().get("value").toString() : "false")){ valorColocar = Boolean.TRUE; } for (TarmDocumentoHabilitante documentoHabilitante : lrecord) { documentoHabilitante.getModifiedData().put("seleccionado", valorColocar); } } catch (Throwable e) { MessageHelper.setMessageError(e); } } /** * Metodod que devuelve un documento habilitante por el codigo de solicitud * @param codigoSolicitud * @return */ public static TarmDocumentoHabilitante findPorSolicitud(String codigoSolicitud) { try { if(codigoSolicitud==null || codigoSolicitud.isEmpty()){ return null; } DocumentoHabilitanteController cc = new DocumentoHabilitanteController(); cc.init(); cc.recperpage = 300; cc.addFilter("csolicitud", codigoSolicitud); cc.querydatabase(); if (cc.record != null) { return cc.record; } return null; } catch (Throwable e) { MessageHelper.setMessageError(e); return null; } } /** * Metodod que devuelve un documento habilitante por el codigo de solicitud * @param codigoSolicitud * @return */ public static TarmDocumentoHabilitante findPorTramite(String codigoTramite) { try { DocumentoHabilitanteController cc = new DocumentoHabilitanteController(); cc.init(); cc.recperpage = 300; cc.addFilter("ctramite", codigoTramite); cc.querydatabase(); if (cc.record != null) { return cc.record; } return null; } catch (Throwable e) { MessageHelper.setMessageError(e); return null; } } /** * Metodod que obtiene un documento habilitante por su codigo * @param codigoSolicitud * @return */ public static TarmDocumentoHabilitante findPorCodigo(String cdocumento) { try { DocumentoHabilitanteController cc = new DocumentoHabilitanteController(); cc.init(); cc.recperpage = 300; cc.addFilter("pk", cdocumento); cc.querydatabase(); if (cc.record != null) { return cc.record; } return null; } catch (Throwable e) { MessageHelper.setMessageError(e); return null; } } /** * Método que retorna el documento habilitante por id * @param cdocumento * @return */ public static TarmDocumentoHabilitante find(String cdocumento) { try { DocumentoHabilitanteController cc = new DocumentoHabilitanteController(); cc.init(); cc.recperpage = 300; cc.addFilter("pk", cdocumento); cc.querydatabase(); if (cc.record != null) { return cc.record; } return null; } catch (Throwable e) { MessageHelper.setMessageError(e); return null; } } /** * buscar el permiso de coumento habilitante por arma * @return */ public static TarmDocumentoHabilitante findxarma( String codigoarma){ try { DocumentoHabilitanteController cc = new DocumentoHabilitanteController(); cc.init(); cc.recperpage = 300; cc.addFilter("codigoarma", codigoarma); cc.querydatabase(); if (cc.record != null) { return cc.record; } return null; } catch (Throwable e) { MessageHelper.setMessageError(e); return null; } } /** * Método que consulta de la entidad TarmDocumentoHabilitante por código de documento */ public static TarmDocumentoHabilitante findPorCDocumento(String cdocumento) { try { DocumentoHabilitanteController cc = new DocumentoHabilitanteController(); cc.init(); cc.recperpage = 15; cc.addFilter("pk", cdocumento); cc.querybase(); if (cc.record != null) { return cc.record; } return null; } catch (Throwable e) { MessageHelper.setMessageError(e); return null; } } public static List findByPerson_Inventario(String personcode) { try { DocumentoHabilitanteController cc = new DocumentoHabilitanteController(); cc.init(); cc.recperpage = 30; cc.addFilter("personcode", personcode); cc.addFilter("estado", "APR"); cc.getMfilelds().put("fechafiltro", "t.fechaexpiracion >=sysdate and" + " ctramite in (select tra.pk from TarmTramite tra where tra.categoria in ('2','3','4','5','8','11') and tipoautorizacion='1')");//1 autorizacion cc.querybasesimle(); if (cc.lrecord != null) { return cc.lrecord; } return null; } catch (Throwable e) { MessageHelper.setMessageError(e); return null; } } public static List findpersoncode(String personcode,String categoria) { try { DocumentoHabilitanteController cc = new DocumentoHabilitanteController(); cc.init(); cc.recperpage = 30; cc.addFilter("personcode", personcode); cc.addFilter("estado", "APR"); if(categoria.equals("4")){ cc.getMfilelds().put("fechafiltro", "t.fechaexpiracion >=sysdate and" + " ctramite in (select tra.pk from TarmTramite tra where tra.categoria in ('2','3','4','5','8','11') and tipoautorizacion='1')");//1 autorizacion } else{ cc.getMfilelds().put("fechafiltro", "t.fechaexpiracion >=to_date(sysdate,'dd/MM/yyyy') and" + " ctramite in (select tra.pk from TarmTramite tra where tra.categoria='"+categoria+"' and tipoautorizacion='1')");//1 autorizacion } cc.querybasesimle(); if (cc.lrecord != null) { return cc.lrecord; } return null; } catch (Throwable e) { MessageHelper.setMessageError(e); return null; } } public static List findpersoncodeInventario(String personcode,String categoria) { try { DocumentoHabilitanteController cc = new DocumentoHabilitanteController(); cc.init(); cc.recperpage = 30; cc.addFilter("personcode", personcode); cc.addFilter("estado", "APR"); if(categoria.equals("4")){ cc.getMfilelds().put("fechafiltro", "ctramite in (select tra.pk from TarmTramite tra where tra.categoria in ('2','3','4','5','8','11') and tipoautorizacion='1')");//1 autorizacion } else{ cc.getMfilelds().put("fechafiltro", "ctramite in (select tra.pk from TarmTramite tra where tra.categoria='"+categoria+"' and tipoautorizacion='1')");//1 autorizacion } cc.querybasesimle(); if (cc.lrecord != null) { return cc.lrecord; } return null; } catch (Throwable e) { MessageHelper.setMessageError(e); return null; } } /** * Metodo que busca los documentos habilitantes por persona para registro de produccion * @param personcode * @return List */ public static List findByPerson_Produccion(String personcode) { try { DocumentoHabilitanteController cc = new DocumentoHabilitanteController(); cc.init(); cc.recperpage = 5000; cc.addFilter("personcode", personcode); cc.addFilter("estado", "APR"); cc.getMfilelds().put("fechafiltro", "t.fechaexpiracion >=sysdate and" + " ctramite in (select tra.pk from TarmTramite tra where tra.categoria in ('4','5') and tipoautorizacion='1')");//1 autorizacion cc.querybasesimle(); if (cc.lrecord != null) { return cc.lrecord; } return null; } catch (Throwable e) { MessageHelper.setMessageError(e); return null; } } /** * Metodo que busca los documentos habilitantes por persona para registro de importaciones * @param personcode * @return List */ public static List findByPerson_Importacion(String personcode) { try { DocumentoHabilitanteController cc = new DocumentoHabilitanteController(); cc.init(); cc.recperpage = 5000; cc.addFilter("personcode", personcode); cc.addFilter("estado", "APR"); // FILTROS: tipoautorizacion='1' --> 1 AUTORIZACION // FILTROS: tra.categoria='8' --> 8 IMPORTADOR cc.getMfilelds().put("fechafiltro", "t.fechaexpiracion >=to_date(sysdate,'dd/MM/yyyy') and" + " ctramite in (select tra.pk from TarmTramite tra where tra.categoria='8' and tipoautorizacion='1')"); cc.querybasesimle(); if (cc.lrecord != null) { return cc.lrecord; } return null; } catch (Throwable e) { MessageHelper.setMessageError(e); return null; } } @SuppressWarnings("unchecked") protected void querybasesimle() { try { DtoQuery dto = super.getDtoQuery(Boolean.TRUE); dto.setOrderby("t.fechaemision"); if(getMfilelds().get("auxfiltro")!=null){ Filter filtro= new Filter(); filtro.setSql(getMfilelds().get("auxfiltro").toString());//"t.ctramite in (Select ctramite from tarmtramite where tipoautorizacion='1'"); dto.addFiltro(filtro); } if(getMfilelds().get("fechafiltro")!=null){ Filter filtrofecha=new Filter(); filtrofecha.setSql(getMfilelds().get("fechafiltro").toString()); dto.addFiltro(filtrofecha); } if(getMfilelds().get("numdocumentoshabilitante")!=null){ Filter filtrodoc=new Filter(); filtrodoc.setSql(getMfilelds().get("numdocumentoshabilitante").toString()); dto.addFiltro(filtrodoc); } SubQuery subqueryCategoriaCodigo= new SubQuery("TgeneCatalogDetail", "description", "description", "i.pk.catalog = (select a.tipotramite from TarmTramite a where a.pk=t.ctramite)" + "and i.pk.catalogcode=(select a.tipotramitecodigo from TarmTramite a where a.pk=t.ctramite)"); dto.addSubQuery(subqueryCategoriaCodigo); SubQuery subqueryTipocodigo=new SubQuery("TgeneCatalogDetail", "description", "descriptiontram", "i.pk.catalog = (select a.categoria from TarmTramite a where a.pk=t.ctramite)" + "and i.pk.catalogcode=(select a.categoriacodigo from TarmTramite a where a.pk=t.ctramite)"); dto.addSubQuery(subqueryTipocodigo); SubQuery subqueryUsocodigo=new SubQuery("TgeneCatalogDetail", "description", "descriptionact", "i.pk.catalog = (select a.usoactividad from TarmTramite a where a.pk=t.ctramite)" + "and i.pk.catalogcode=(select a.usoactividadcodigo from TarmTramite a where a.pk=t.ctramite)"); dto.addSubQuery(subqueryUsocodigo); SubQuery subQuerytipotramite= new SubQuery("TarmTramite","tipotramite","tipotramite","i.pk=t.ctramite"); dto.addSubQuery(subQuerytipotramite); SubQuery subQuerytipotramitecodigo= new SubQuery("TarmTramite","tipotramitecodigo","tipotramitecodigo","i.pk=t.ctramite"); dto.addSubQuery(subQuerytipotramitecodigo); SubQuery subQuerytipoautorizacion= new SubQuery("TarmTramite","tipoautorizacion","tipoautorizacion","i.pk=t.ctramite"); dto.addSubQuery(subQuerytipoautorizacion); SubQuery subQuerytipoautorizacioncodigo= new SubQuery("TarmTramite","tipoautorizacioncodigo","tipoautorizacioncodigo","i.pk=t.ctramite"); dto.addSubQuery(subQuerytipoautorizacioncodigo); SubQuery subQuerycategoria= new SubQuery("TarmTramite","categoria","categoria","i.pk=t.ctramite"); dto.addSubQuery(subQuerycategoria); SubQuery subQuerycategoriacodigo= new SubQuery("TarmTramite","categoriacodigo","categoriacodigo","i.pk=t.ctramite"); dto.addSubQuery(subQuerycategoriacodigo); SubQuery subQueryclase= new SubQuery("TarmTramite","clase","clase","i.pk=t.ctramite"); dto.addSubQuery(subQueryclase); HashMap mtables = new HashMap(); mtables.put(beanalias, dto); // permite adicionar mas de una tabla. Request request = callerhelper.getRequest(); request.setQueryTables(mtables); Response resp = callerhelper.executeQuery(request); if (resp.getResponseCode().compareTo(Response.RESPONSE_OK) != 0) { lrecord = new ArrayList<>(); MessageHelper.setMessageError(resp); } else { lrecord = (List) resp.get(beanalias); super.postQuery(lrecord); } } catch (Throwable e) { MessageHelper.setMessageError(e); } } public static List findByCSolicitud(String csolicitud) { try { DocumentoHabilitanteController cc = new DocumentoHabilitanteController(); cc.init(); cc.recperpage = 5000; if(csolicitud!=null){ cc.addFilter("csolicitud", csolicitud); } cc.getMfilelds().put("pathSuspencion", "t.pathSuspencion is not null"); cc.querydocumhabsusp(); if (cc.lrecord != null) { return cc.lrecord; } return null; } catch (Throwable e) { MessageHelper.setMessageError(e); return null; } } @SuppressWarnings("unchecked") protected void querydocumhabsusp() { try { DtoQuery dto = super.getDtoQuery(Boolean.TRUE); dto.setOrderby("t.fechaemision"); if(getMfilelds().get("pathSuspencion")!=null){ Filter filtrodoc=new Filter(); filtrodoc.setSql(getMfilelds().get("pathSuspencion").toString()); dto.addFiltro(filtrodoc); } //Nombre/Razon social SubQuery subqueryNombre= new SubQuery("TcustPersonDetail","name","nombre","i.pk.personcode=t.personcode and i.pk.dateto = to_date('2999-12-31', 'YYYY-MM-DD')"); dto.addSubQuery(subqueryNombre); SubQuery subqueryNDocumento= new SubQuery("TcustPersonDetail","identification","nodocumento","i.pk.personcode=t.personcode and i.pk.dateto= to_date('2999-12-31', 'YYYY-MM-DD')"); dto.addSubQuery(subqueryNDocumento); SubQuery subqueryCategoriaCodigo= new SubQuery("TgeneCatalogDetail", "description", "description", "i.pk.catalog = (select a.tipotramite from TarmTramite a where a.pk=t.ctramite)" + "and i.pk.catalogcode=(select a.tipotramitecodigo from TarmTramite a where a.pk=t.ctramite)"); dto.addSubQuery(subqueryCategoriaCodigo); SubQuery subqueryTipocodigo=new SubQuery("TgeneCatalogDetail", "description", "descriptiontram", "i.pk.catalog = (select a.categoria from TarmTramite a where a.pk=t.ctramite)" + "and i.pk.catalogcode=(select a.categoriacodigo from TarmTramite a where a.pk=t.ctramite)"); dto.addSubQuery(subqueryTipocodigo); SubQuery subqueryUsocodigo=new SubQuery("TgeneCatalogDetail", "description", "descriptionact", "i.pk.catalog = (select a.usoactividad from TarmTramite a where a.pk=t.ctramite)" + "and i.pk.catalogcode=(select a.usoactividadcodigo from TarmTramite a where a.pk=t.ctramite)"); dto.addSubQuery(subqueryUsocodigo); SubQuery subQuerytipotramite= new SubQuery("TarmTramite","tipotramite","tipotramite","i.pk=t.ctramite"); dto.addSubQuery(subQuerytipotramite); SubQuery subQuerytipotramitecodigo= new SubQuery("TarmTramite","tipotramitecodigo","tipotramitecodigo","i.pk=t.ctramite"); dto.addSubQuery(subQuerytipotramitecodigo); SubQuery subQuerytipoautorizacion= new SubQuery("TarmTramite","tipoautorizacion","tipoautorizacion","i.pk=t.ctramite"); dto.addSubQuery(subQuerytipoautorizacion); SubQuery subQuerytipoautorizacioncodigo= new SubQuery("TarmTramite","tipoautorizacioncodigo","tipoautorizacioncodigo","i.pk=t.ctramite"); dto.addSubQuery(subQuerytipoautorizacioncodigo); SubQuery subQuerycategoria= new SubQuery("TarmTramite","categoria","categoria","i.pk=t.ctramite"); dto.addSubQuery(subQuerycategoria); SubQuery subQuerycategoriacodigo= new SubQuery("TarmTramite","categoriacodigo","categoriacodigo","i.pk=t.ctramite"); dto.addSubQuery(subQuerycategoriacodigo); SubQuery subQueryclase= new SubQuery("TarmTramite","clase","clase","i.pk=t.ctramite"); dto.addSubQuery(subQueryclase); HashMap mtables = new HashMap(); mtables.put(beanalias, dto); // permite adicionar mas de una tabla. Request request = callerhelper.getRequest(); request.setQueryTables(mtables); Response resp = callerhelper.executeQuery(request); if (resp.getResponseCode().compareTo(Response.RESPONSE_OK) != 0) { lrecord = new ArrayList<>(); MessageHelper.setMessageError(resp); } else { lrecord = (List) resp.get(beanalias); super.postQuery(lrecord); } } catch (Throwable e) { MessageHelper.setMessageError(e); } } public PersonAddressController getPersonAddressController() { return personAddressController; } public void setPersonAddressController( PersonAddressController personAddressController) { this.personAddressController = personAddressController; } public Date getFechaInicio() { return fechaInicio; } public void setFechaInicio(Date fechaInicio) { this.fechaInicio = fechaInicio; } public Date getFechaFin() { return fechaFin; } public void setFechaFin(Date fechaFin) { this.fechaFin = fechaFin; } /** * Valida que no se puedan seleccionar documentos de fecha emision anterior al sistema MAIA * @param event */ public void validaNoSeleccionDocAnteriores(AjaxBehaviorEvent event) { TarmDocumentoHabilitante documentoSeleccionado = this.getLrecord().get(Integer.parseInt(event.getComponent().getAttributes().get("documentoSeleccionado").toString())); // FECHA 15 DE JUNIO DEL 2015 - PUESTA EN PRODUCCION Calendar datePuestaProduccion = new GregorianCalendar(2015, 5, 15); //2015, 06, 15 if(documentoSeleccionado.getFechaemision().before(datePuestaProduccion.getTime())){ documentoSeleccionado.getModifiedData().put("seleccionado", Boolean.FALSE); MessageHelper.setMessageInfo(MsgControlArmas.getProperty("msg_reimpresionprevianopermitida")); } } public void update(TarmDocumentoHabilitante bean) throws Exception { record=bean; super.update(); } }