935 lines
38 KiB
Plaintext
Executable File
935 lines
38 KiB
Plaintext
Executable File
package com.fp.frontend.controller.armas.solicitud;
|
|
|
|
import java.io.InputStream;
|
|
import java.text.SimpleDateFormat;
|
|
import java.util.ArrayList;
|
|
import java.util.Calendar;
|
|
import java.util.Date;
|
|
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 org.primefaces.context.RequestContext;
|
|
|
|
import com.fp.dto.Request;
|
|
import com.fp.dto.Response;
|
|
import com.fp.dto.query.DtoQuery;
|
|
import com.fp.dto.query.SubQuery;
|
|
import com.fp.frontend.controller.AbstractController;
|
|
import com.fp.frontend.controller.ReportController;
|
|
import com.fp.frontend.controller.alfresco.AlfrescoController;
|
|
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;
|
|
|
|
@SuppressWarnings("serial")
|
|
@ManagedBean
|
|
@ViewScoped
|
|
public class DocumentoHabilitanteConErrorController extends AbstractController<TarmSolicitudTramite> {
|
|
|
|
|
|
|
|
@ManagedProperty(value = "#{reportController}")
|
|
private ReportController reportController;
|
|
|
|
@ManagedProperty(value="#{alfrescoController}")
|
|
private AlfrescoController alfrescoController;
|
|
|
|
@ManagedProperty(value="#{documentoHabilitanteController}")
|
|
private DocumentoHabilitanteController documentoHabilitanteController;
|
|
|
|
@ManagedProperty(value="#{pesonAddressController}")
|
|
private PersonAddressController pesonAddressController;
|
|
|
|
@ManagedProperty(value="#{solicitudController}")
|
|
private SolicitudController solicitudController;
|
|
|
|
|
|
|
|
TarmSolicitudTramite solicitudTramite;
|
|
TarmSolicitud solicitud;
|
|
TarmTramite fila;
|
|
TcustPersonDetail detallesPersona;
|
|
TcustPersonDetail usuario;
|
|
TarmDocumentoHabilitante documentoHabilitante;
|
|
String numeroSolicitud;
|
|
String numeroTramite;
|
|
String nombreRazonSocial;
|
|
private String xpathflujo="";//cm:Pruebas/cm:ID_1715819825001";
|
|
private String formato = "pdf";
|
|
private String mostrarFormato="PDF";
|
|
// TcustPersonDetail detallesPersona;
|
|
List<TarmSolicitud> lsolicitud;
|
|
// String numeroTramite;
|
|
// String nombreRazonSocial;
|
|
String identificacion;
|
|
String tipoidentificacion;
|
|
private String tramiteflujo="";
|
|
private String solicitudflujo="";
|
|
|
|
|
|
private List<TgeneCatalogDetail> ldocumentos;
|
|
private String institucionCentroControl="";
|
|
private TarmCentroControl centroControl = new TarmCentroControl();
|
|
private TcustPersonDetail responsableCentroControl= null;
|
|
|
|
public DocumentoHabilitanteConErrorController() throws Exception {
|
|
super(TarmSolicitudTramite.class);
|
|
}
|
|
|
|
@PostConstruct
|
|
private void postconstruct() {
|
|
try {
|
|
// this.pasteBpmScreenParameters();
|
|
// tramiteflujo=super.getMfilters().get("numerotransaccion");
|
|
// solicitudflujo=super.getMfilters().get("csolicitud");
|
|
|
|
this.init();
|
|
// super.getMfilters().clear();
|
|
|
|
// super.query();
|
|
} catch (Exception e) {
|
|
// TODO Auto-generated catch block
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
|
|
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(solicitudflujo);
|
|
|
|
//Obteniendo la solicitud
|
|
solicitud=ValidacionTramiteLibreTransitoController.findPorSolicitudSimple(solicitudflujo);
|
|
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(solicitudflujo);
|
|
obtenerCentroControl();
|
|
|
|
} catch (Exception e) {
|
|
MessageHelper.setMessageError(e);
|
|
}
|
|
}
|
|
|
|
public String getNumeroTramite() {
|
|
return numeroTramite;
|
|
}
|
|
|
|
public void setNumeroTramite(String numeroTramite) {
|
|
this.numeroTramite = numeroTramite;
|
|
}
|
|
|
|
@Override
|
|
protected void querydatabase() {
|
|
TarmSolicitud solicitudObj=SolicitudController.findSolicitudxnumerosolicitud(numeroSolicitud);
|
|
if(solicitudObj!=null && solicitudObj.getPk()!=null && solicitudObj.getCtramite()!=null){
|
|
tramiteflujo=solicitudObj.getCtramite().toString();
|
|
solicitudflujo=solicitudObj.getPk();
|
|
}
|
|
init();
|
|
try {
|
|
addFilter("numerotramite", numeroTramite);
|
|
|
|
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").
|
|
SubQuery subqueryUso= new SubQuery("TarmTramite","usoactividad","actividad","i.pk=t.pk.ctramite");
|
|
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=t.pk.ctramite");
|
|
dto.addSubQuery(subqueryTipo);
|
|
SubQuery subqueryTipocodigo=new SubQuery("TarmTramite", "tipoautorizacioncodigo", "tramitecodigo", "i.pk=t.pk.ctramite");
|
|
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());
|
|
TcustPersonDetail person = PersonDetailController.find(this.lrecord.get(i).getModifiedData().get("persona").toString());
|
|
this.lrecord.get(i).getModifiedData().put("nombre", person.getName());
|
|
this.lrecord.get(i).getModifiedData().put("identificacion", person.getIdentification());
|
|
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.getDescription());
|
|
}
|
|
}
|
|
|
|
|
|
} catch (Throwable e) {
|
|
MessageHelper.setMessageError(e);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Método para completar la tarea
|
|
*/
|
|
public void completarTarea() {
|
|
try {
|
|
if(xpathflujo==null || xpathflujo.isEmpty()){
|
|
MessageHelper.setMessageError(MsgControlArmas.getProperty("msg_error_generarReporteRequerido"));
|
|
return;
|
|
}
|
|
Request request = callerhelper.getRequest();
|
|
super.cleanRequest(request);
|
|
request.modifiedData().put("TID", tid);
|
|
request.modifiedData().put("BPMStatus", bpmDataStatus == null ? "A" : bpmDataStatus); // A,D,R
|
|
request.modifiedData().put("BPMObs", bpmDataComment == null ? "OK" : bpmDataComment);
|
|
|
|
Response resp = callerhelper.executeSave(request);
|
|
|
|
if (resp.getResponseCode().compareTo(Response.RESPONSE_OK) == 0) {
|
|
MessageHelper.setMessageInfo(resp);
|
|
RequestContext.getCurrentInstance().execute("Maia.refreshusertasks()");
|
|
} else {
|
|
MessageHelper.setMessageError(resp);
|
|
}
|
|
} catch (Throwable e) {
|
|
MessageHelper.setMessageError(e);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
public void imprimir(TarmSolicitudTramite fila){
|
|
try {
|
|
boolean flagRequisitos = false;
|
|
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();
|
|
TarmSolicitud solicitud = SolicitudController.findSolicitudxcodsolicitud(fila.getPk().getCsolicitud());
|
|
TarmTramite tramite = TarmTramiteController.findSimple(fila.getPk().getCtramite().toString());
|
|
documentoHabilitante=documentoHabilitanteController.findPorSolicitud(fila.getPk().getCsolicitud());
|
|
|
|
xpathflujo=generarXpath(fila.getNumerotramite());
|
|
System.out.println("..." + xpathflujo);
|
|
|
|
//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);
|
|
InputStream pdf=this.reporteCertificados(solicitud.getPk(), flagAgencia, flagArmas, flagDoc, flagGuardias);
|
|
alfrescoController.uploadFile(pdf, documentoHabilitante.getNumerodocumento()+".pdf", xpathflujo) ;
|
|
xpathflujo = xpathflujo + "/cm:" + documentoHabilitante.getNumerodocumento()+".pdf";
|
|
actualizarXpath(documentoHabilitante, xpathflujo);
|
|
return;
|
|
}else if (tipotramite.equals("4")) {
|
|
InputStream pdf=this.reporteGuiaLibreTransito();
|
|
alfrescoController.uploadFile(pdf, documentoHabilitante.getNumerodocumento()+".pdf", xpathflujo) ;
|
|
xpathflujo = xpathflujo + "/cm:" + documentoHabilitante.getNumerodocumento()+".pdf";
|
|
actualizarXpath(documentoHabilitante, xpathflujo);
|
|
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;
|
|
}
|
|
}
|
|
InputStream pdf=this.reporteGeneral(solicitud.getPk(),flagAgencia,flagArmas,flagDoc,flagGuardias,flagRequisitos,nombreArchivo);
|
|
alfrescoController.uploadFile(pdf, documentoHabilitante.getNumerodocumento()+".pdf", xpathflujo) ;
|
|
xpathflujo = xpathflujo + "/cm:" + documentoHabilitante.getNumerodocumento()+".pdf";
|
|
actualizarXpath(documentoHabilitante, xpathflujo);
|
|
|
|
} catch (Exception e) {
|
|
xpathflujo=null;
|
|
MessageHelper.setMessageError(MsgControlArmas.getProperty("msg_error_generar_reporte"));
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
* Metodo para actualziar en la tabla tarmdocumentohabilitante con el xpath de la ruta de alfreco donde se guardo el documento
|
|
* @param documentoHabilitante
|
|
* @param xPath
|
|
* @throws Exception
|
|
*/
|
|
private void actualizarXpath(TarmDocumentoHabilitante documentoHabilitante, String xPath) throws Exception{
|
|
documentoHabilitanteController.setRecord(documentoHabilitante);
|
|
documentoHabilitanteController.getRecord().setXpath(xPath);
|
|
documentoHabilitanteController.update();
|
|
documentoHabilitanteController.save();
|
|
}
|
|
|
|
public String generarXpath(String tramite){
|
|
Calendar calendar = Calendar.getInstance();
|
|
calendar.setTime(new Date());
|
|
tramite=tramite.replace("TRA", "SOL");
|
|
StringBuilder ruta=new StringBuilder("cm:Solicitud");
|
|
ruta = ruta.append("/cm:A-").append(calendar.get(Calendar.YEAR));
|
|
ruta = ruta.append("/cm:M-").append((calendar.get(Calendar.MONTH)+1) <= 9 ? "0" + (calendar.get(Calendar.MONTH) + 1) : (calendar.get(Calendar.MONTH)+1));
|
|
ruta = ruta.append("/cm:"+tramite);
|
|
return ruta.toString();
|
|
}
|
|
|
|
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());
|
|
|
|
String csolicitud=null;
|
|
for(TarmSolicitud soli : lsolicitud){
|
|
if(csolicitud==null){
|
|
csolicitud="csolicitud='"+soli.getPk()+"'";
|
|
}
|
|
else{
|
|
csolicitud+=" or csolicitud='"+soli.getPk()+"'";
|
|
}
|
|
}
|
|
return csolicitud;
|
|
}
|
|
|
|
|
|
@Override
|
|
public void save() {
|
|
// TODO Auto-generated method stub
|
|
super.save();
|
|
}
|
|
|
|
/**
|
|
* Ejecuta un reporte de armas
|
|
* @param name Nombre del reporte a generar.
|
|
*/
|
|
public InputStream 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());
|
|
TarmSolicitud sol = this.solicitudController.findSolicitudxcodsolicitud(this.solicitudflujo);
|
|
//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());
|
|
|
|
//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()+" - ";
|
|
}
|
|
|
|
//Lugar origen y destino
|
|
if(sol!=null){
|
|
parameters.put("provinciaorigen", sol.modifiedData().get("provinciaorigen").toString());
|
|
parameters.put("cantonorigen", sol.modifiedData().get("cantonorigen").toString());
|
|
parameters.put("lugarorigen", sol.getLugarorigen().toString());
|
|
parameters.put("provinciadestino", sol.modifiedData().get("provinciadestino").toString());
|
|
parameters.put("cantondestino", sol.modifiedData().get("cantondestino").toString());
|
|
parameters.put("lugardestino", sol.getLugardestino().toString());
|
|
|
|
}
|
|
|
|
//Funcionario
|
|
parameters.put("gradoNombreFuncionario",gradoFuncionario+this.responsableCentroControl.getName());
|
|
parameters.put("personcode",this.responsableCentroControl.getPk().getPersoncode());
|
|
parameters.put("centroControl","JEFE DEL "+this.institucionCentroControl);
|
|
parameters.put("nombreCentro", this.institucionCentroControl);
|
|
//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";
|
|
InputStream pdf = this.reportController.jaspertoInputstream(path, parameters, format, filename, this.getLoginController());
|
|
return pdf;
|
|
} catch (Exception ex) {
|
|
MessageHelper.setMessageError(ex);
|
|
}
|
|
return null;
|
|
}
|
|
|
|
/**
|
|
* 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.
|
|
*/
|
|
|
|
|
|
|
|
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);
|
|
}
|
|
}
|
|
|
|
/* 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");
|
|
|
|
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 InputStream reporteGeneral(String solicitud,boolean flagAgencia,boolean flagArmas,boolean flagDoc,boolean flagGuardias,boolean flagRequisitos,String nombreArchivo) {
|
|
try {
|
|
String path = "armas/reports/generalReportHabilita";
|
|
String filename=nombreArchivo;
|
|
TsafeUserDetail tsafeUserDetail = (TsafeUserDetail) FacesContext.getCurrentInstance().getExternalContext().getSessionMap().get("TSAFEUSERDETAIL");
|
|
TcustPersonDetail user = PersonDetailController.find(tsafeUserDetail.getPk().getPersoncode().toString());
|
|
// TgeneCatalogDetail grado = CatalogDetailController.findxCodigoCodcatalogo(user.getMilitarygrade(), user.getMilitarygradecode());
|
|
TgeneCatalogDetail grado =null;
|
|
if(this.responsableCentroControl.getMilitarygrade()!=null && this.responsableCentroControl.getMilitarygradecode()!=null){
|
|
grado = CatalogDetailController.findxCodigoCodcatalogo(this.responsableCentroControl.getMilitarygrade(), this.responsableCentroControl.getMilitarygradecode());
|
|
}
|
|
|
|
String gradoUsuario="";
|
|
if(grado!=null){
|
|
gradoUsuario = grado.getDescription()+" - "+this.responsableCentroControl.getName();
|
|
}else{
|
|
gradoUsuario = 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", solicitudflujo);
|
|
|
|
//Obteniendo la solicitud
|
|
TarmSolicitud s=SolicitudController.findSolicitudxcodsolicitud(solicitudflujo);
|
|
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(solicitudflujo);
|
|
|
|
|
|
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", " ");
|
|
}
|
|
|
|
//Pie
|
|
if(t.getPie()!=null){
|
|
parameters.put("pie", t.getPie());
|
|
}else{
|
|
parameters.put("pie", " ");
|
|
}
|
|
|
|
//fecha de solicitud
|
|
if(s.getFregistro()!=null){
|
|
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
|
|
parameters.put("fecSolicitud", sdf.format(s.getFregistro()));
|
|
}
|
|
else {
|
|
parameters.put("fecSolicitud", "");
|
|
}
|
|
|
|
|
|
|
|
}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", " ");
|
|
parameters.put("pie", " ");
|
|
}
|
|
|
|
//Obteniendo la direccion
|
|
String email=" ",direccion=" ";
|
|
List<TcustPersonAddress> direcciones=PersonAddressController.findAllByPersonCode(s.getPersoncode().toString());
|
|
for (TcustPersonAddress d : direcciones) {
|
|
Calendar calendario=Calendar.getInstance();
|
|
calendario.setTime(d.getPk().getDateto());
|
|
if(calendario.get(Calendar.YEAR)==2999){
|
|
if(d.getAddresstypecatalog().equalsIgnoreCase("3")){
|
|
email=d.getAddress();
|
|
}else if(d.getPrincipal()!=null && d.getPrincipal().equalsIgnoreCase("Y")){
|
|
direccion=d.getAddress();
|
|
}
|
|
}
|
|
}
|
|
|
|
//Email
|
|
parameters.put("email", email);
|
|
|
|
//Direccion
|
|
parameters.put("direccion", direccion);
|
|
|
|
|
|
//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("flagRequisitos", flagRequisitos);
|
|
parameters.put("centroControl", this.obtenerCentroControl());
|
|
parameters.put("gradoUsuario", gradoUsuario);
|
|
parameters.put("codResponsable", this.responsableCentroControl.getPk().getPersoncode());
|
|
parameters.put("usuario",user.getName());
|
|
String format = "pdf";
|
|
InputStream pdf=this.reportController.jaspertoInputstream(path, parameters, format, filename, this.getLoginController());
|
|
return pdf;
|
|
} catch (Exception ex) {
|
|
MessageHelper.setMessageError(ex);
|
|
}
|
|
return null;
|
|
}
|
|
|
|
/**
|
|
* Obtiene el centro de control segun usurio logeado.
|
|
* @throws Exception
|
|
*
|
|
*/
|
|
private String obtenerCentroControl() throws Exception {
|
|
TsafeUserDetail tsafeUserDetail = (TsafeUserDetail) FacesContext.getCurrentInstance().getExternalContext().getSessionMap().get("TSAFEUSERDETAIL");
|
|
PersonAddressController direccion = new PersonAddressController();
|
|
TcustPersonAddress tcustPersonAddres= direccion.findPrincipal(tsafeUserDetail.getPk().getPersoncode().toString());
|
|
TarmCentroControlJur centroControlJur= TarmCentroControlJurController.findxProvincia(tcustPersonAddres.getProvincecode());
|
|
this.centroControl= CentroControlArmasController.findPorCodigo(centroControlJur.getCcentrocontrol());
|
|
//Reponsable
|
|
Integer responsable = this.centroControl.getPersoncode();
|
|
this.responsableCentroControl = PersonDetailController.find(responsable.toString());
|
|
return setInstitucionCentroControl(CatalogDetailController.findxCodigoCodcatalogo( centroControl.getNombreinstitucion(), centroControl.getNombreinstitucioncodigo()).getDescription());
|
|
|
|
|
|
|
|
}
|
|
|
|
/**
|
|
* Ejecuta reporte general de informacion de armas, guardias, agencias y sucursales
|
|
* @param name Nombre del reporte a generar.
|
|
*/
|
|
|
|
public InputStream reporteCertificados(String solicitud,boolean flagAgencia,boolean flagArmas,boolean flagDoc,boolean flagGuardias) {
|
|
try {
|
|
String gradoUsuario ="";
|
|
String path = "armas/reports/reporteCertificado";
|
|
String filename="reporteCertificado";
|
|
TsafeUserDetail tsafeUserDetail = (TsafeUserDetail) FacesContext.getCurrentInstance().getExternalContext().getSessionMap().get("TSAFEUSERDETAIL");
|
|
TcustPersonDetail user = PersonDetailController.find(tsafeUserDetail.getPk().getPersoncode().toString());
|
|
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(solicitudflujo);
|
|
//Obteniendo la direccion
|
|
String email=" ",direccion=" ";
|
|
List<TcustPersonAddress> direcciones=PersonAddressController.findAllByPersonCode(s.getPersoncode().toString());
|
|
for (TcustPersonAddress d : direcciones) {
|
|
Calendar calendario=Calendar.getInstance();
|
|
calendario.setTime(d.getPk().getDateto());
|
|
if(calendario.get(Calendar.YEAR)==2999){
|
|
if(d.getAddresstypecatalog().equalsIgnoreCase("3")){
|
|
email=d.getAddress();
|
|
}else if(d.getAddresstypecatalog().equalsIgnoreCase("1")){
|
|
direccion=d.getAddress();
|
|
}
|
|
}
|
|
}
|
|
|
|
//Email
|
|
parameters.put("email", email);
|
|
//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",user.getName());
|
|
parameters.put("codResponsable", this.responsableCentroControl.getPk().getPersoncode());
|
|
String format = "pdf";
|
|
//this.reportController.execute(path, parameters, format, filename, this.getLoginController());
|
|
InputStream pdf=this.reportController.jaspertoInputstream(path, parameters, format, filename, this.getLoginController());
|
|
return pdf;
|
|
} catch (Exception ex) {
|
|
MessageHelper.setMessageError(ex);
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public List<TgeneCatalogDetail> getLdocumentos() {
|
|
return ldocumentos;
|
|
}
|
|
|
|
public String getXpathflujo() {
|
|
return xpathflujo;
|
|
}
|
|
|
|
public void setXpathflujo(String xpathflujo) {
|
|
this.xpathflujo = xpathflujo;
|
|
}
|
|
|
|
public void setLdocumentos(List<TgeneCatalogDetail> ldocumentos) {
|
|
this.ldocumentos = ldocumentos;
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
TarmTramite getFila() {
|
|
return fila;
|
|
}
|
|
|
|
public void setFila(TarmTramite fila) {
|
|
this.fila = fila;
|
|
}
|
|
|
|
|
|
|
|
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 String getTramiteflujo() {
|
|
return tramiteflujo;
|
|
}
|
|
|
|
public void setTramiteflujo(String tramiteflujo) {
|
|
this.tramiteflujo = tramiteflujo;
|
|
}
|
|
|
|
public String getInstitucionCentroControl() {
|
|
return institucionCentroControl;
|
|
}
|
|
|
|
public String setInstitucionCentroControl(String institucionCentroControl) {
|
|
this.institucionCentroControl = institucionCentroControl;
|
|
return institucionCentroControl;
|
|
}
|
|
|
|
public AlfrescoController getAlfrescoController() {
|
|
return alfrescoController;
|
|
}
|
|
|
|
public void setAlfrescoController(AlfrescoController alfrescoController) {
|
|
this.alfrescoController = alfrescoController;
|
|
}
|
|
|
|
public ReportController getReportController() {
|
|
return reportController;
|
|
}
|
|
|
|
public void setReportController(ReportController reportController) {
|
|
this.reportController = reportController;
|
|
}
|
|
|
|
public DocumentoHabilitanteController getDocumentoHabilitanteController() {
|
|
return documentoHabilitanteController;
|
|
}
|
|
|
|
public void setDocumentoHabilitanteController(
|
|
DocumentoHabilitanteController documentoHabilitanteController) {
|
|
this.documentoHabilitanteController = documentoHabilitanteController;
|
|
}
|
|
|
|
public PersonAddressController getPesonAddressController() {
|
|
return pesonAddressController;
|
|
}
|
|
|
|
public void setPesonAddressController(
|
|
PersonAddressController pesonAddressController) {
|
|
this.pesonAddressController = pesonAddressController;
|
|
}
|
|
|
|
public SolicitudController getSolicitudController() {
|
|
return solicitudController;
|
|
}
|
|
|
|
public void setSolicitudController(SolicitudController solicitudController) {
|
|
this.solicitudController = solicitudController;
|
|
}
|
|
|
|
public String getNumeroSolicitud() {
|
|
return numeroSolicitud;
|
|
}
|
|
|
|
public void setNumeroSolicitud(String numeroSolicitud) {
|
|
this.numeroSolicitud = numeroSolicitud;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|