240 lines
8.2 KiB
Plaintext
Executable File
240 lines
8.2 KiB
Plaintext
Executable File
package com.fp.frontend.controller.armas.solicitud;
|
|
|
|
import java.text.SimpleDateFormat;
|
|
import java.util.ArrayList;
|
|
import java.util.Date;
|
|
import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
|
|
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.event.SelectEvent;
|
|
|
|
import com.fp.dto.AbstractDataTransport;
|
|
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.pcustomer.lov.PersonLovController;
|
|
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.pcustomer.gene.TcustPersonAddress;
|
|
import com.fp.persistence.pcustomer.gene.TcustPersonDetail;
|
|
import com.fp.persistence.pgeneral.gene.TgeneParameters;
|
|
import com.fp.persistence.pgeneral.safe.TsafeUserDetail;
|
|
|
|
/**
|
|
* Controlador principal Consulta Agencias y Sucursales
|
|
*
|
|
*/
|
|
@SuppressWarnings("serial")
|
|
@ManagedBean(name="reporteAgenciasSucursalesController")
|
|
@ViewScoped
|
|
public class ReporteAgenciasSucursalesController extends AbstractController<AbstractDataTransport> {
|
|
|
|
@ManagedProperty(value = "#{reportController}")
|
|
private ReportController reportController;
|
|
|
|
private String institucionCentroControl="";
|
|
private TarmCentroControl centroControl = new TarmCentroControl();
|
|
|
|
/**
|
|
* Nombre/razón social
|
|
*/
|
|
private String nombreRazonSocial;
|
|
/**
|
|
* numedo de identificacion
|
|
*/
|
|
private String numeroDocumento;
|
|
|
|
/**
|
|
* Filtro de los codigos de los tramites
|
|
*/
|
|
private String filtro;
|
|
|
|
/**
|
|
* Codigo de la persona
|
|
*/
|
|
private Integer personcode;
|
|
|
|
|
|
public ReporteAgenciasSucursalesController() throws Exception {
|
|
super(AbstractDataTransport.class);
|
|
}
|
|
|
|
/**
|
|
* Método que se ejecuta después del constructor
|
|
*/
|
|
@PostConstruct
|
|
private void postconstruct() {
|
|
this.init();
|
|
}
|
|
|
|
/**
|
|
* Inicializa valores del controlador
|
|
*/
|
|
private void init() {
|
|
try {
|
|
recperpage = 15; // Cambiar al # reg a mirar.
|
|
lrecord = new ArrayList<>();
|
|
beanalias = "REPORTEAGENCIASUCURSAL";
|
|
TsafeUserDetail userDetail = (TsafeUserDetail) FacesContext.getCurrentInstance().getExternalContext().getSessionMap().get("TSAFEUSERDETAIL");
|
|
TgeneParameters parametroCodigosTramite = ParametersController.find("CODTRAMAGESUC", userDetail.getCompanycode().toString());
|
|
filtro=parametroCodigosTramite.getTextvalue();
|
|
} catch (Exception e) {
|
|
MessageHelper.setMessageError(e);
|
|
}
|
|
}
|
|
|
|
protected void querydatabase() {
|
|
}
|
|
|
|
@Override
|
|
public void save() {
|
|
}
|
|
|
|
/**
|
|
* Abre el lov de persona
|
|
*/
|
|
public void openPersonLov() {
|
|
Map<String, List<String>> params = new HashMap<>();
|
|
PersonLovController.openLov(params);
|
|
}
|
|
|
|
/**
|
|
* Maneja la respuesta del Lov de Personas
|
|
* @param event
|
|
* @throws Exception
|
|
*/
|
|
public void onReturnPersonLov(SelectEvent event) throws Exception {
|
|
|
|
TcustPersonDetail personaDetailSelecionada = (TcustPersonDetail) event.getObject();
|
|
nombreRazonSocial=personaDetailSelecionada.getName();
|
|
numeroDocumento=personaDetailSelecionada.getIdentification();
|
|
personcode=personaDetailSelecionada.getPk().getPersoncode();
|
|
}
|
|
|
|
/**
|
|
* Metodo que se debe ejecutar cuando es una transaccion de tipo verificar armas
|
|
* @throws Exception
|
|
*/
|
|
private void obtenerCentroControl() throws Exception {
|
|
TsafeUserDetail tsafeUserDetail = (TsafeUserDetail) FacesContext.getCurrentInstance().getExternalContext().getSessionMap().get("TSAFEUSERDETAIL");
|
|
PersonAddressController personAddressController = new PersonAddressController();
|
|
TcustPersonAddress tcustPersonAddres=personAddressController.findPrincipal(tsafeUserDetail.getPk().getPersoncode().toString());
|
|
TarmCentroControlJur centroControlJur= TarmCentroControlJurController.findxProvincia(tcustPersonAddres.getProvincecode());
|
|
centroControl= CentroControlArmasController.findPorCodigo(centroControlJur.getCcentrocontrol());
|
|
institucionCentroControl = CatalogDetailController.findxCodigoCodcatalogo( centroControl.getNombreinstitucion(), centroControl.getNombreinstitucioncodigo()).getDescription();
|
|
}
|
|
|
|
public void generarReporte(){
|
|
if(personcode==null){
|
|
MessageHelper.setMessageError(MsgControlArmas.getProperty("msg_seleccione_nombre"));
|
|
return;
|
|
}
|
|
String path = "armas/reports/reporteAgenciaSucursal";
|
|
//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");
|
|
try {
|
|
//Usuario logueado en la aplicacion
|
|
String nombreUsuario;
|
|
TsafeUserDetail userDetail=(TsafeUserDetail)FacesContext.getCurrentInstance().getExternalContext().getSessionMap().get("TSAFEUSERDETAIL");
|
|
if(userDetail.getPk().getPersoncode()!=null){
|
|
nombreUsuario = PersonDetailController.find(userDetail.getPk().getPersoncode().toString()).getName();
|
|
parameters.put("personcode", userDetail.getPk().getPersoncode());
|
|
}
|
|
else{
|
|
nombreUsuario = "";
|
|
}
|
|
parameters.put("usuario", nombreUsuario);
|
|
obtenerCentroControl();
|
|
parameters.put("unidadmilitar", institucionCentroControl);
|
|
|
|
parameters.put("nombreRazonSocial", nombreRazonSocial);
|
|
parameters.put("centroControl", institucionCentroControl);
|
|
Date fechaActual= new Date();
|
|
SimpleDateFormat parseador = new SimpleDateFormat("dd/MM/yyyy hh:mm");
|
|
parameters.put("fecActual", parseador.format(fechaActual));
|
|
|
|
parameters.put("filtro",filtro);
|
|
parameters.put("filtro2",personcode);
|
|
|
|
String format="pdf";
|
|
String filename="Certificado";
|
|
this.reportController.execute(path, parameters, format, filename, this.getLoginController());
|
|
} catch (Exception ex) {
|
|
MessageHelper.setMessageError(ex);
|
|
}
|
|
}
|
|
|
|
public ReportController getReportController() {
|
|
return reportController;
|
|
}
|
|
|
|
public void setReportController(ReportController reportController) {
|
|
this.reportController = reportController;
|
|
}
|
|
|
|
public String getInstitucionCentroControl() {
|
|
return institucionCentroControl;
|
|
}
|
|
|
|
public void setInstitucionCentroControl(String institucionCentroControl) {
|
|
this.institucionCentroControl = institucionCentroControl;
|
|
}
|
|
|
|
public TarmCentroControl getCentroControl() {
|
|
return centroControl;
|
|
}
|
|
|
|
public void setCentroControl(TarmCentroControl centroControl) {
|
|
this.centroControl = centroControl;
|
|
}
|
|
|
|
public String getNombreRazonSocial() {
|
|
return nombreRazonSocial;
|
|
}
|
|
|
|
public void setNombreRazonSocial(String nombreRazonSocial) {
|
|
this.nombreRazonSocial = nombreRazonSocial;
|
|
}
|
|
|
|
public String getNumeroDocumento() {
|
|
return numeroDocumento;
|
|
}
|
|
|
|
public void setNumeroDocumento(String numeroDocumento) {
|
|
this.numeroDocumento = numeroDocumento;
|
|
}
|
|
|
|
public String getFiltro() {
|
|
return filtro;
|
|
}
|
|
|
|
public void setFiltro(String filtro) {
|
|
this.filtro = filtro;
|
|
}
|
|
|
|
public Integer getPersoncode() {
|
|
return personcode;
|
|
}
|
|
|
|
public void setPersoncode(Integer personcode) {
|
|
this.personcode = personcode;
|
|
}
|
|
|
|
}
|