842 lines
33 KiB
Plaintext
Executable File
842 lines
33 KiB
Plaintext
Executable File
package com.fp.frontend.controller.armas.solicitud;
|
|
|
|
import java.text.SimpleDateFormat;
|
|
import java.util.ArrayList;
|
|
import java.util.Calendar;
|
|
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.context.FacesContext;
|
|
|
|
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.frontend.controller.AbstractController;
|
|
import com.fp.frontend.controller.ReportController;
|
|
import com.fp.frontend.controller.armas.parametros.CentroControlArmasController;
|
|
import com.fp.frontend.controller.armas.parametros.TarmCentroControlJurController;
|
|
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.ParametersController;
|
|
import com.fp.frontend.helper.MessageHelper;
|
|
import com.fp.frontend.utility.MsgControlArmas;
|
|
import com.fp.persistence.parmas.param.TarmCentroControl;
|
|
import com.fp.persistence.parmas.param.TarmCentroControlJur;
|
|
import com.fp.persistence.parmas.param.TarmTramite;
|
|
import com.fp.persistence.parmas.soli.TarmDocumentoHabilitante;
|
|
import com.fp.persistence.parmas.soli.TarmSolicitud;
|
|
import com.fp.persistence.parmas.soli.TarmSolicitudTramite;
|
|
import com.fp.persistence.pcustomer.gene.TcustPersonAddress;
|
|
import com.fp.persistence.pcustomer.gene.TcustPersonDetail;
|
|
import com.fp.persistence.pgeneral.gene.TgeneCatalogDetail;
|
|
import com.fp.persistence.pgeneral.gene.TgeneParameters;
|
|
import com.fp.persistence.pgeneral.safe.TsafeUserDetail;
|
|
|
|
|
|
/**
|
|
* Descarga el Documento Habilitante dependidendo del tramite que se seleccione
|
|
* @author Andres Cevallos
|
|
*/
|
|
@SuppressWarnings("serial")
|
|
@ManagedBean
|
|
@ViewScoped
|
|
public class EmitirDocumentoHabilitante extends AbstractController<TarmSolicitudTramite> {
|
|
|
|
|
|
|
|
|
|
/**
|
|
* Controlador Inyectado ReportController
|
|
*/
|
|
@ManagedProperty(value = "#{reportController}")
|
|
private ReportController reportController;
|
|
|
|
/**
|
|
*Controador Inyectado TarmTramiteController
|
|
*/
|
|
@ManagedProperty(value = "#{tramiteController}")
|
|
private TarmTramiteController tramiteController;
|
|
|
|
|
|
|
|
/**
|
|
*Referencia al Centro de control;
|
|
*/
|
|
private TarmCentroControl centroControl = new TarmCentroControl();
|
|
|
|
|
|
/**
|
|
*Referencia a la solicitud del tramite
|
|
*/
|
|
private TarmSolicitudTramite solicitudTramite;
|
|
|
|
/**
|
|
*Referencia a la Solicitud
|
|
*/
|
|
private TarmSolicitud solicitud;
|
|
/**
|
|
*Fila de la lista de tramites
|
|
*/
|
|
private TarmTramite fila;
|
|
/**
|
|
*Detalles de la persona
|
|
*/
|
|
private TcustPersonDetail detallesPersona;
|
|
/**
|
|
* Detalle del usuario
|
|
*/
|
|
private TcustPersonDetail usuario;
|
|
/**
|
|
*Documento Habilitante relacionado con el tramite
|
|
*/
|
|
private TarmDocumentoHabilitante documentoHabilitante;
|
|
/**
|
|
* Numero de Tramite realizado
|
|
*/
|
|
private String numeroTramite;
|
|
/**
|
|
* Nombre de la persona
|
|
*/
|
|
private String nombreRazonSocial;
|
|
/**
|
|
* Formato de generacion de pdf
|
|
*/
|
|
private String formato = "pdf";
|
|
/**
|
|
* Formato que se muestra en pantalla
|
|
*/
|
|
private String mostrarFormato="PDF";
|
|
// TcustPersonDetail detallesPersona;
|
|
/**
|
|
*Lista de Solicitudes
|
|
*/
|
|
private List<TarmSolicitud> lsolicitud;
|
|
/**
|
|
*Responsable de centro de control
|
|
*/
|
|
private TcustPersonDetail responsableCentroControl= null;
|
|
/**
|
|
* Detalle de Usuarios
|
|
*/
|
|
private TsafeUserDetail tsafeUserDetailUsuario = null;
|
|
// String numeroTramite;
|
|
// String nombreRazonSocial;
|
|
/**
|
|
* Detalle de identificacion
|
|
*/
|
|
private String identificacion;
|
|
/**
|
|
* Tipo de identificacion
|
|
*/
|
|
private String tipoidentificacion;
|
|
/**
|
|
*Habilita y deshabilita la impresion
|
|
*/
|
|
private boolean imprimir;
|
|
|
|
/**
|
|
*Nombre de la Institucion
|
|
*/
|
|
private String nombreInstitucion;
|
|
|
|
|
|
|
|
private List<TgeneCatalogDetail> ldocumentos;
|
|
|
|
public EmitirDocumentoHabilitante() throws Exception {
|
|
super(TarmSolicitudTramite.class);
|
|
}
|
|
|
|
@PostConstruct
|
|
private void postconstruct() {
|
|
this.init();
|
|
// super.startQuery();
|
|
}
|
|
|
|
private void init() {
|
|
try {
|
|
recperpage = 15; // Cambiar al # reg a mirar.
|
|
// lrecord = new ArrayList<>();
|
|
beanalias = "EMITIRDOCUMENTOHABILITANTE";
|
|
ldocumentos = new ArrayList<TgeneCatalogDetail>();
|
|
ldocumentos = CatalogDetailController.find("IDENTIFICATION");
|
|
//Obteniendo el tramite
|
|
//solicitudTramite=TarmSolicitudTramiteController.findPorCSolicitud("1");
|
|
|
|
//Obteniendo la solicitud
|
|
//solicitud=ValidacionTramiteLibreTransitoController.findPorSolicitudSimple("1");
|
|
//this.numeroTramite=solicitudTramite.getNumerotramite();
|
|
|
|
//Obteniendo los datos del usuario logueado
|
|
TsafeUserDetail tsafeUserDetail=(TsafeUserDetail)FacesContext.getCurrentInstance().getExternalContext().getSessionMap().get("TSAFEUSERDETAIL");
|
|
usuario=PersonDetailController.find(tsafeUserDetail.getPk().getPersoncode().toString());
|
|
|
|
//Obteniendo el documento habilitante
|
|
// documentoHabilitante=DocumentoHabilitanteController.findPorSolicitud("1");
|
|
this.responsableCentroControl = new TcustPersonDetail();
|
|
this.tsafeUserDetailUsuario = new TsafeUserDetail();
|
|
this.obtenerCentroControl();
|
|
this.obtenerResponsableCentroControl();
|
|
|
|
} catch (Exception e) {
|
|
MessageHelper.setMessageError(e);
|
|
}
|
|
}
|
|
|
|
@Override
|
|
protected void querydatabase() {
|
|
|
|
try {
|
|
String sql=encontrarUsuario();
|
|
|
|
Request request = this.callerhelper.getRequest();
|
|
DtoQuery dto = super.getDtoQuery(true);
|
|
dto.setOrderby("t.pk"); // En en string van todos los campos de orden ("t.pk, t.nombre, t.cpais").
|
|
if(sql!=null){
|
|
Filter filtro = new Filter();
|
|
filtro.setSql(sql);
|
|
dto.addFiltro(filtro);
|
|
}
|
|
else{
|
|
this.lrecord = null;
|
|
return;
|
|
}
|
|
SubQuery subqueryUso= new SubQuery("TarmTramite","usoactividad","actividad","i.pk in (select a.ctramite from TarmSolicitud a where a.pk=t.pk.csolicitud)");
|
|
dto.addSubQuery(subqueryUso);
|
|
SubQuery subqueryPersona= new SubQuery("TarmSolicitud","personcode","persona","i.pk=t.pk.csolicitud");
|
|
dto.addSubQuery(subqueryPersona);
|
|
SubQuery subqueryTipo=new SubQuery("TarmTramite", "tipoautorizacion", "tramite", "i.pk in (select a.ctramite from TarmSolicitud a where a.pk=t.pk.csolicitud)");
|
|
dto.addSubQuery(subqueryTipo);
|
|
SubQuery subqueryCategoria= new SubQuery("TarmTramite", "categoria", "categoria", "i.pk in (select a.ctramite from TarmSolicitud a where a.pk=t.pk.csolicitud)");
|
|
dto.addSubQuery(subqueryCategoria);
|
|
SubQuery subqueryCategoriaCodigo= new SubQuery("TarmTramite", "categoriacodigo", "categoriacodigo", "i.pk in (select a.ctramite from TarmSolicitud a where a.pk=t.pk.csolicitud)");
|
|
dto.addSubQuery(subqueryCategoriaCodigo);
|
|
SubQuery subqueryTipocodigo=new SubQuery("TarmTramite", "tipoautorizacioncodigo", "tramitecodigo", "i.pk in (select a.ctramite from TarmSolicitud a where a.pk=t.pk.csolicitud)");
|
|
dto.addSubQuery(subqueryTipocodigo);
|
|
SubQuery subqueryEstado=new SubQuery("TgeneCatalogDetail","description","desc","i.pk.catalog=t.estadotramite and i.pk.catalogcode=t.estadotramitecodigo");
|
|
dto.addSubQuery(subqueryEstado);
|
|
HashMap<String, DtoQuery> mtables = new HashMap<String, DtoQuery>();
|
|
mtables.put(this.beanalias, dto); // permite adicionar mas de una tabla.
|
|
request.setQueryTables(mtables);
|
|
Response resp = this.callerhelper.executeQuery(request);
|
|
if (resp.getResponseCode().compareTo(Response.RESPONSE_OK) != 0) {
|
|
this.lrecord = new ArrayList<TarmSolicitudTramite>();
|
|
MessageHelper.setMessageError(resp);
|
|
} else {
|
|
this.lrecord = (List<TarmSolicitudTramite>) resp.get(this.beanalias);
|
|
super.postQuery(this.lrecord);
|
|
for(int i=0;i< this.lrecord.size();i++){
|
|
this.lrecord.get(i).getModifiedData().put("usodes", CatalogDetailController.findxCodigoCodcatalogo(this.lrecord.get(i).getModifiedData().get("actividad").toString(), "USOACTIVIDAD").getDescription());
|
|
this.lrecord.get(i).getModifiedData().put("imprimir", true);
|
|
TcustPersonDetail person = PersonDetailController.find(this.lrecord.get(i).getModifiedData().get("persona").toString());
|
|
this.lrecord.get(i).getModifiedData().put("nombre",person!=null?person.getName():"");
|
|
this.lrecord.get(i).getModifiedData().put("identificacion", person!=null?person.getIdentification():"");
|
|
try{
|
|
TgeneCatalogDetail cate=CatalogDetailController.findxCodigoCodcatalogo(this.lrecord.get(i).getModifiedData().get("categoria").toString(),this.lrecord.get(i).getModifiedData().get("categoriacodigo").toString() );
|
|
this.lrecord.get(i).getModifiedData().put("categoriadesc", cate!=null?cate.getDescription():"");
|
|
}
|
|
catch(Exception e){
|
|
e.printStackTrace();
|
|
}
|
|
try{
|
|
TgeneCatalogDetail tipo = CatalogDetailController.findxCodigoCodcatalogo(this.lrecord.get(i).getModifiedData().get("tramite").toString(), this.lrecord.get(i).getModifiedData().get("tramitecodigo").toString());
|
|
this.lrecord.get(i).getModifiedData().put("tipotramdesc", tipo!=null?tipo.getDescription():"");
|
|
if(!lrecord.get(i).getEstadotramite().equals("APB")){
|
|
lrecord.get(i).getModifiedData().put("imprimir", "true");
|
|
}
|
|
else{
|
|
lrecord.get(i).getModifiedData().put("imprimir", "false");
|
|
}
|
|
}
|
|
|
|
catch(Exception e){
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
} catch (Throwable e) {
|
|
MessageHelper.setMessageError(e);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Metodo que genera el reporte
|
|
* @param fila
|
|
*/
|
|
public void imprimir(TarmSolicitudTramite fila){
|
|
boolean flagArmas = false;
|
|
boolean flagGuardias = false;
|
|
boolean flagAgencia = false;
|
|
boolean flagDoc = false;
|
|
String tipotramite=fila.getModifiedData().get("tramite").toString();
|
|
String nombreArchivo = fila.getModifiedData().get("tipotramdesc").toString();
|
|
solicitud = SolicitudController.findSolicitudxcodsolicitud(fila.getPk().getCsolicitud());
|
|
solicitudTramite=TarmSolicitudTramiteController.findPorCSolicitud(fila.getPk().getCsolicitud());
|
|
numeroTramite=solicitudTramite.getNumerotramite();
|
|
documentoHabilitante=DocumentoHabilitanteController.findPorSolicitud(fila.getPk().getCsolicitud());
|
|
TarmTramite tramite = TarmTramiteController.findSimple(fila.getPk().getCtramite().toString());
|
|
String tipoReporte = tramite.getRegistroagenciasucursal();
|
|
//solicitud=ValidacionTramiteLibreTransitoController.findPorSolicitudSimple(tipotramite);
|
|
if(tipotramite==null){
|
|
MessageHelper.setMessageError("ERROR NO MANEJADO POR LA APLICACION CONTACTE AL PROVEEDOR");
|
|
return;
|
|
}
|
|
|
|
|
|
if(tipotramite.equals("2")){
|
|
if(tramite.getRegistroagenciasucursal().equalsIgnoreCase("Y")){
|
|
flagAgencia = true;
|
|
}
|
|
if (tramite.getRegistroarmas().equalsIgnoreCase("Y")) {
|
|
flagArmas = true;
|
|
}
|
|
if (tramite.getRegistroguardia().equalsIgnoreCase("Y")) {
|
|
flagGuardias = true;
|
|
}
|
|
if(tramite.getDocumentohabilitante().equalsIgnoreCase("Y")) {
|
|
flagDoc = true;
|
|
}
|
|
this.reporteCertificados(solicitud.getPk(), flagAgencia, flagArmas, flagDoc, flagGuardias);
|
|
return;
|
|
}else if (tipotramite.equals("4")) {
|
|
this.reporteGuiaLibreTransito();
|
|
return;
|
|
}else {
|
|
if(tramite.getRegistroagenciasucursal().equalsIgnoreCase("Y")){
|
|
flagAgencia = true;
|
|
}
|
|
if (tramite.getRegistroarmas().equalsIgnoreCase("Y")) {
|
|
flagArmas = true;
|
|
}
|
|
if (tramite.getRegistroguardia().equalsIgnoreCase("Y")) {
|
|
flagGuardias = true;
|
|
}
|
|
if(tramite.getDocumentohabilitante().equalsIgnoreCase("Y")) {
|
|
flagDoc = true;
|
|
}
|
|
}
|
|
|
|
this.reporteGeneral(solicitud.getPk(),flagAgencia,flagArmas,flagDoc,flagGuardias,nombreArchivo);
|
|
|
|
}
|
|
|
|
/**
|
|
* Encuentra el usuario logueado
|
|
* @return
|
|
*/
|
|
public String encontrarUsuario(){
|
|
if(identificacion==null || identificacion=="")
|
|
return null;
|
|
detallesPersona=PersonDetailController.findxidentification(identificacion, tipoidentificacion);
|
|
if(detallesPersona==null)
|
|
return null;
|
|
lsolicitud=SolicitudController.findSolicitudxPersona(detallesPersona.getPk().getPersoncode().toString());
|
|
|
|
if(lsolicitud == null || lsolicitud.isEmpty()){
|
|
return null;
|
|
}
|
|
|
|
String csolicitud=null;
|
|
for(TarmSolicitud soli : lsolicitud){
|
|
if(csolicitud==null){
|
|
csolicitud="csolicitud='"+soli.getPk()+"'";
|
|
}
|
|
else{
|
|
csolicitud+=" or csolicitud='"+soli.getPk()+"'";
|
|
}
|
|
}
|
|
return csolicitud ;
|
|
}
|
|
|
|
public List<TgeneCatalogDetail> getLdocumentos() {
|
|
return ldocumentos;
|
|
}
|
|
|
|
public void setLdocumentos(List<TgeneCatalogDetail> ldocumentos) {
|
|
this.ldocumentos = ldocumentos;
|
|
}
|
|
|
|
@Override
|
|
public void save() {
|
|
// TODO Auto-generated method stub
|
|
super.save();
|
|
}
|
|
|
|
/**
|
|
* Ejecuta un reporte de armas
|
|
* @param name Nombre del reporte a generar.
|
|
*/
|
|
public void reporteGuiaLibreTransito() {
|
|
try {
|
|
String path = "armas/reports/guiaLibreTransito";
|
|
String filename=MsgControlArmas.getProperty("lbl_guiaLibreTransito");
|
|
|
|
detallesPersona = PersonDetailController.find(String.valueOf(solicitud.getPersoncode().toString()));
|
|
solicitudTramite=TarmSolicitudTramiteController.findPorCSolicitud(solicitud.getPk());
|
|
|
|
//Fija parametros del report.
|
|
HashMap<String, Object> parameters = new HashMap<>();
|
|
parameters.put("pathLogoIzquierda", "repo:/maia/1/image/comandoconjunto");
|
|
parameters.put("pathLogoDerecha", "repo:/maia/1/image/selloarmas");
|
|
|
|
parameters.put("csolicitud", solicitudTramite.getPk().getCsolicitud());
|
|
|
|
//Nombre del centro de control
|
|
parameters.put("nombreCentro", this.nombreInstitucion);
|
|
|
|
//No. Guia
|
|
parameters.put("noGuia", this.numeroTramite);
|
|
|
|
//Codigo de barras
|
|
String codigoBarras=this.numeroTramite.replace("-", "").toLowerCase();
|
|
Boolean caracterEliminado=false;
|
|
for (int i = 0; i < codigoBarras.length(); i++) {
|
|
if(caracterEliminado){
|
|
i=0;
|
|
caracterEliminado=false;
|
|
}
|
|
if(codigoBarras.toCharArray()[i]!='0' && codigoBarras.toCharArray()[i]!='1' && codigoBarras.toCharArray()[i]!='2'
|
|
&& codigoBarras.toCharArray()[i]!='3' && codigoBarras.toCharArray()[i]!='4' && codigoBarras.toCharArray()[i]!='5'
|
|
&& codigoBarras.toCharArray()[i]!='6' && codigoBarras.toCharArray()[i]!='7' && codigoBarras.toCharArray()[i]!='8'
|
|
&& codigoBarras.toCharArray()[i]!='9'){
|
|
|
|
String caracterExtranno="";
|
|
caracterExtranno+=codigoBarras.toCharArray()[i];
|
|
codigoBarras=codigoBarras.replace(caracterExtranno, "");
|
|
caracterEliminado=true;
|
|
}
|
|
}
|
|
parameters.put("codigoBarras", codigoBarras);
|
|
|
|
//Nombre/Razon Social
|
|
parameters.put("nombreRazon", detallesPersona.getName());
|
|
|
|
// Vendedor
|
|
parameters.put("tipodocumentoorigen", solicitud.getTipodocumentoorigen());
|
|
parameters.put("numerodocumentoorigen", solicitud.getNumerodocumentoorigen());
|
|
parameters.put("nombrerazonsocialorigen", solicitud.getNombrerazonsocialorigen());
|
|
|
|
//Cedula
|
|
parameters.put("cedula", detallesPersona.getIdentification());
|
|
|
|
//Desde
|
|
parameters.put("desde", solicitud.getLugarorigen());
|
|
|
|
//Hasta
|
|
parameters.put("hasta", solicitud.getLugardestino());
|
|
|
|
//Fechas
|
|
SimpleDateFormat sdf=new SimpleDateFormat("dd-MM-yyyy");
|
|
if(documentoHabilitante!=null){
|
|
parameters.put("fechaExpide", sdf.format(documentoHabilitante.getFechaemision()));
|
|
parameters.put("fechaCaduca", sdf.format(documentoHabilitante.getFechaexpiracion()));
|
|
}else{
|
|
parameters.put("fechaExpide", " ");
|
|
parameters.put("fechaCaduca", " ");
|
|
}
|
|
|
|
//Grado
|
|
String gradoFuncionario="";
|
|
TgeneCatalogDetail grado=CatalogDetailController.findxCodigoCodcatalogo(this.responsableCentroControl.getMilitarygrade(),
|
|
this.responsableCentroControl.getMilitarygradecode());
|
|
if(grado!=null){
|
|
gradoFuncionario=grado.getDescription()+" - ";
|
|
}
|
|
|
|
//Funcionario
|
|
parameters.put("gradoNombreFuncionario",gradoFuncionario+this.responsableCentroControl.getName());
|
|
parameters.put("personcode",this.responsableCentroControl.getPk().getPersoncode());
|
|
parameters.put("centroControl","JEFE DEL "+this.nombreInstitucion);
|
|
|
|
//Usuario
|
|
parameters.put("usuario",this.usuario.getName());
|
|
sdf=new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
|
|
String fechaHora=sdf.format(Calendar.getInstance().getTime());
|
|
parameters.put("fechaHora",fechaHora);
|
|
|
|
String format = "pdf";
|
|
|
|
|
|
this.reportController.execute(path, parameters, format, filename, this.getLoginController());
|
|
} catch (Exception ex) {
|
|
MessageHelper.setMessageError(ex);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Ejecuta un reporte de certificado de armas
|
|
* @param name Nombre del reporte a generar.
|
|
*/
|
|
|
|
public void reporteCertificadoArmas() {
|
|
try {
|
|
String path = "armas/reports/certificadoArmas";
|
|
String filename="certificadoarmas";
|
|
|
|
//Fija parametros del report.
|
|
HashMap<String, Object> parameters = new HashMap<>();
|
|
parameters.put("pathLogoIzquierda", "repo:/maia/1/image/comandoconjunto");
|
|
parameters.put("pathLogoDerecha", "repo:/maia/1/image/selloarmas");
|
|
|
|
parameters.put("csolicitud", solicitudTramite.getPk().getCsolicitud());
|
|
|
|
//Fecha
|
|
SimpleDateFormat sdf=new SimpleDateFormat("dd-MM-yyyy");
|
|
parameters.put("lugarFecha", sdf.format(Calendar.getInstance().getTime()));
|
|
|
|
|
|
|
|
String format = "pdf";
|
|
|
|
|
|
this.reportController.execute(path, parameters, format, filename, this.getLoginController());
|
|
} catch (Exception ex) {
|
|
MessageHelper.setMessageError(ex);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Ejecuta un reporte de certificado de armas
|
|
* @param name Nombre del reporte a generar.
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
* Reporte de Agencias
|
|
*/
|
|
public void reporteAgencias() {
|
|
try {
|
|
String path = "armas/reports/aperturaAgenciasSucursales";
|
|
String filename="aperturaagenciassucursales";
|
|
|
|
//Fija parametros del report.
|
|
HashMap<String, Object> parameters = new HashMap<>();
|
|
parameters.put("pathLogoIzquierda", "repo:/maia/1/image/comandoconjunto");
|
|
parameters.put("pathLogoDerecha", "repo:/maia/1/image/selloarmas");
|
|
|
|
parameters.put("csolicitud", solicitudTramite.getPk().getCsolicitud());
|
|
|
|
//Fecha
|
|
SimpleDateFormat sdf=new SimpleDateFormat("dd-MM-yyyy");
|
|
parameters.put("lugarFecha", sdf.format(Calendar.getInstance().getTime()));
|
|
|
|
|
|
|
|
String format = "pdf";
|
|
|
|
|
|
this.reportController.execute(path, parameters, format, filename, this.getLoginController());
|
|
} catch (Exception ex) {
|
|
MessageHelper.setMessageError(ex);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Reporte de Inscripcion de Armas
|
|
* @param solicitud
|
|
*/
|
|
public void reporteInscripcion(TarmSolicitud solicitud) {
|
|
try {
|
|
String path = "armas/reports/reporteInscripcion";
|
|
String filename="armas";
|
|
|
|
detallesPersona = PersonDetailController.find(String.valueOf(solicitud.getPersoncode().toString()));
|
|
solicitudTramite=TarmSolicitudTramiteController.findPorCSolicitud(solicitud.getPk());
|
|
|
|
//Fija parametros del report.
|
|
HashMap<String, Object> parameters = new HashMap<>();
|
|
|
|
parameters.put("pathLogoIzquierda", "repo:/maia/1/image/comandoconjunto");
|
|
parameters.put("pathLogoDerecha", "repo:/maia/1/image/selloarmas");
|
|
|
|
|
|
//No. Guia
|
|
parameters.put("nombreCompania", detallesPersona.getName());
|
|
|
|
//Nombre/Razon Social
|
|
parameters.put("nombrepersona",detallesPersona.getLegalrepresent());
|
|
SimpleDateFormat sdf=new SimpleDateFormat("dd-MM-yyyy");
|
|
parameters.put("fecha", sdf.format(solicitud.getFregistro()));
|
|
parameters.put("ciudad", "Quito");
|
|
|
|
//Grado
|
|
/* String gradoFuncionario="";
|
|
TgeneCatalogDetail grado=CatalogDetailController.findxCodigoCodcatalogo(usuario.getMilitarygrade(), usuario.getMilitarygradecode());
|
|
if(grado!=null){
|
|
gradoFuncionario=grado.getDescription()+" - ";
|
|
}
|
|
|
|
//Funcionario
|
|
parameters.put("gradoNombreFuncionario",gradoFuncionario+usuario.getName());
|
|
*/
|
|
String format = "pdf";
|
|
|
|
|
|
this.reportController.execute(path, parameters, format, filename, this.getLoginController());
|
|
} catch (Exception ex) {
|
|
MessageHelper.setMessageError(ex);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
* Obtiene el centro de control segun usurio logeado.
|
|
* @throws Exception
|
|
*
|
|
*/
|
|
private String obtenerCentroControl() throws Exception {
|
|
String institucionCentroControl="";
|
|
this.tsafeUserDetailUsuario = (TsafeUserDetail) FacesContext.getCurrentInstance().getExternalContext().getSessionMap().get("TSAFEUSERDETAIL");
|
|
PersonAddressController direccion = new PersonAddressController();
|
|
TcustPersonAddress tcustPersonAddres= direccion.findPrincipal(tsafeUserDetailUsuario.getPk().getPersoncode().toString());
|
|
TarmCentroControlJur centroControlJur= TarmCentroControlJurController.findxProvincia(tcustPersonAddres.getProvincecode());
|
|
this.centroControl= CentroControlArmasController.findPorCodigo(centroControlJur.getCcentrocontrol());
|
|
this.nombreInstitucion=CatalogDetailController.findxCodigoCodcatalogo( centroControl.getNombreinstitucion(), centroControl.getNombreinstitucioncodigo()).getDescription();
|
|
institucionCentroControl=this.nombreInstitucion;
|
|
|
|
return institucionCentroControl;
|
|
}
|
|
|
|
/**
|
|
* Obtiene el responsable del Centro de Control
|
|
*/
|
|
public void obtenerResponsableCentroControl(){
|
|
Integer responsable = this.centroControl.getPersoncode();
|
|
this.responsableCentroControl = PersonDetailController.find(responsable.toString());
|
|
|
|
}
|
|
|
|
/**
|
|
* Ejecuta reporte general de informacion de armas, guardias, agencias y sucursales
|
|
* @param name Nombre del reporte a generar.
|
|
*/
|
|
|
|
public void reporteGeneral(String solicitud,boolean flagAgencia,boolean flagArmas,boolean flagDoc,boolean flagGuardias,String nombreArchivo) {
|
|
try {
|
|
String gradoUsuario ="";
|
|
String path = "armas/reports/generalReportHabilita";
|
|
String filename=nombreArchivo;
|
|
TgeneCatalogDetail grado = CatalogDetailController.findxCodigoCodcatalogo(this.responsableCentroControl.getMilitarygrade(), this.responsableCentroControl.getMilitarygradecode());
|
|
if(grado != null){
|
|
gradoUsuario = grado.getDescription()+" - "+this.responsableCentroControl.getName();
|
|
}else{
|
|
gradoUsuario = "Sin Grado - "+this.responsableCentroControl.getName();
|
|
}
|
|
|
|
|
|
//Fija parametros del report.
|
|
HashMap<String, Object> parameters = new HashMap<>();
|
|
parameters.put("pathLogoIzquierda", "repo:/maia/1/image/comandoconjunto");
|
|
parameters.put("pathLogoDerecha", "repo:/maia/1/image/selloarmas");
|
|
parameters.put("csolicitud", solicitud);
|
|
|
|
//Obteniendo la solicitud
|
|
TarmSolicitud s=SolicitudController.findSolicitudxcodsolicitud(solicitud);
|
|
TarmTramite t;
|
|
Boolean datosTramiteVacios=false;
|
|
|
|
if(s!=null){
|
|
//Obteniendo el tramite
|
|
t=TarmTramiteController.find(s.getCtramite().toString());
|
|
|
|
//Obteniendo la solicitud trmite
|
|
TarmSolicitudTramite st=TarmSolicitudTramiteController.findPorCSolicitud(solicitud);
|
|
|
|
if(t!=null){
|
|
|
|
//No de tramite
|
|
if(st!=null){
|
|
parameters.put("noTramite", st.getNumerotramite());
|
|
}else{
|
|
parameters.put("noTramite", " ");
|
|
}
|
|
|
|
//Tipo de tramite
|
|
if(t.getModifiedData().get("tipotramite")!=null){
|
|
parameters.put("tipoTramite", t.getModifiedData().get("tipotramite"));
|
|
}else{
|
|
parameters.put("tipoTramite", " ");
|
|
}
|
|
|
|
//Tipo de autorizacion
|
|
if(t.getModifiedData().get("tipoautorizacion")!=null){
|
|
parameters.put("tipoAutorizacion", t.getModifiedData().get("tipoautorizacion"));
|
|
}else{
|
|
parameters.put("tipoAutorizacion", " ");
|
|
}
|
|
|
|
//Categoria
|
|
if(t.getModifiedData().get("categoria")!=null){
|
|
parameters.put("categoria", t.getModifiedData().get("categoria"));
|
|
}else{
|
|
parameters.put("categoria", " ");
|
|
}
|
|
|
|
//Uso actividad
|
|
if(t.getModifiedData().get("usoactividad")!=null){
|
|
parameters.put("usoActividad", t.getModifiedData().get("usoactividad"));
|
|
}else{
|
|
parameters.put("usoActividad", " ");
|
|
}
|
|
|
|
//Cabecera
|
|
if(t.getCabecera()!=null){
|
|
parameters.put("cabecera", t.getCabecera());
|
|
}else{
|
|
parameters.put("cabecera", " ");
|
|
}
|
|
|
|
}else{
|
|
datosTramiteVacios=true;
|
|
}
|
|
}else{
|
|
datosTramiteVacios=true;
|
|
}
|
|
|
|
if(datosTramiteVacios){
|
|
parameters.put("noTramite", " ");
|
|
parameters.put("tipoTramite", " ");
|
|
parameters.put("tipoAutorizacion", " ");
|
|
parameters.put("categoria", "-");
|
|
parameters.put("usoActividad", " ");
|
|
parameters.put("cabecera", " ");
|
|
}
|
|
|
|
|
|
//Fecha
|
|
SimpleDateFormat sdf=new SimpleDateFormat("dd-MM-yyyy / hh:mm:ss");
|
|
parameters.put("lugarFecha", sdf.format(Calendar.getInstance().getTime()));
|
|
parameters.put("flagAgencia", flagAgencia);
|
|
parameters.put("flagArmas", flagArmas);
|
|
parameters.put("flagDoc", flagDoc);
|
|
parameters.put("flagGuardias", flagGuardias);
|
|
parameters.put("centroControl", this.obtenerCentroControl());
|
|
parameters.put("gradoUsuario", gradoUsuario);
|
|
parameters.put("usuario",PersonDetailController.find(this.tsafeUserDetailUsuario.getPk().getPersoncode().toString()).getName());
|
|
parameters.put("codResponsable", this.responsableCentroControl.getPk().getPersoncode());
|
|
String format = "pdf";
|
|
this.reportController.execute(path, parameters, format, filename, this.getLoginController());
|
|
} catch (Exception ex) {
|
|
MessageHelper.setMessageError(ex);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Ejecuta reporte general de informacion de armas, guardias, agencias y sucursales
|
|
* @param name Nombre del reporte a generar.
|
|
*/
|
|
|
|
public void reporteCertificados(String solicitud,boolean flagAgencia,boolean flagArmas,boolean flagDoc,boolean flagGuardias) {
|
|
try {
|
|
String gradoUsuario ="";
|
|
String path = "armas/reports/reporteCertificado";
|
|
String filename="reporteCertificado";
|
|
TgeneCatalogDetail grado = CatalogDetailController.findxCodigoCodcatalogo(this.responsableCentroControl.getMilitarygrade(), this.responsableCentroControl.getMilitarygradecode());
|
|
if(grado != null){
|
|
gradoUsuario = grado.getDescription()+" - "+this.responsableCentroControl.getName();
|
|
}else{
|
|
gradoUsuario = "Sin Grado - "+this.responsableCentroControl.getName();
|
|
}
|
|
|
|
|
|
//Fija parametros del report.
|
|
HashMap<String, Object> parameters = new HashMap<>();
|
|
parameters.put("pathLogoIzquierda", "repo:/maia/1/image/comandoconjunto");
|
|
parameters.put("pathLogoDerecha", "repo:/maia/1/image/selloarmas");
|
|
parameters.put("csolicitud", solicitud);
|
|
//Fecha
|
|
SimpleDateFormat sdf=new SimpleDateFormat("dd-MM-yyyy / hh:mm:ss");
|
|
parameters.put("lugarFecha", sdf.format(Calendar.getInstance().getTime()));
|
|
parameters.put("flagAgencia", flagAgencia);
|
|
parameters.put("flagArmas", flagArmas);
|
|
parameters.put("flagDoc", flagDoc);
|
|
parameters.put("flagGuardias", flagGuardias);
|
|
parameters.put("centroControl", this.obtenerCentroControl());
|
|
parameters.put("gradoUsuario", gradoUsuario);
|
|
parameters.put("usuario",PersonDetailController.find(this.tsafeUserDetailUsuario.getPk().getPersoncode().toString()).getName());
|
|
parameters.put("codResponsable", this.responsableCentroControl.getPk().getPersoncode());
|
|
String format = "pdf";
|
|
this.reportController.execute(path, parameters, format, filename, this.getLoginController());
|
|
} catch (Exception ex) {
|
|
MessageHelper.setMessageError(ex);
|
|
}
|
|
}
|
|
|
|
public String getFormato() {
|
|
return formato;
|
|
}
|
|
|
|
public void setFormato(String formato) {
|
|
this.formato = formato;
|
|
}
|
|
|
|
public String getMostrarFormato() {
|
|
return mostrarFormato;
|
|
}
|
|
|
|
public void setMostrarFormato(String mostrarFormato) {
|
|
this.mostrarFormato = mostrarFormato;
|
|
}
|
|
|
|
public boolean isImprimir() {
|
|
return imprimir;
|
|
}
|
|
|
|
public void setImprimir(boolean imprimir) {
|
|
this.imprimir = imprimir;
|
|
}
|
|
|
|
|
|
public TarmTramiteController getTramiteController() {
|
|
return tramiteController;
|
|
}
|
|
|
|
public void setTramiteController(TarmTramiteController tramiteController) {
|
|
this.tramiteController = tramiteController;
|
|
}
|
|
|
|
public ReportController getReportController() {
|
|
return reportController;
|
|
}
|
|
|
|
public void setReportController(ReportController reportController) {
|
|
this.reportController = reportController;
|
|
}
|
|
|
|
|
|
public TarmTramite getFila() {
|
|
return fila;
|
|
}
|
|
|
|
public void setFila(TarmTramite fila) {
|
|
this.fila = fila;
|
|
}
|
|
|
|
public String getIdentificacion() {
|
|
return identificacion;
|
|
}
|
|
|
|
public void setIdentificacion(String identificacion) {
|
|
this.identificacion = identificacion;
|
|
}
|
|
|
|
public String getTipoidentificacion() {
|
|
return tipoidentificacion;
|
|
}
|
|
|
|
public void setTipoidentificacion(String tipoidentificacion) {
|
|
this.tipoidentificacion = tipoidentificacion;
|
|
}
|
|
|
|
}
|