577 lines
18 KiB
Plaintext
Executable File
577 lines
18 KiB
Plaintext
Executable File
package com.fp.frontend.controller.armas.solicitud;
|
||
|
||
|
||
import java.util.ArrayList;
|
||
import java.util.Arrays;
|
||
import java.util.Calendar;
|
||
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.common.helper.Constant;
|
||
import com.fp.dto.AbstractDataTransport;
|
||
import com.fp.dto.Response;
|
||
import com.fp.frontend.controller.AbstractController;
|
||
import com.fp.frontend.controller.ReportController;
|
||
import com.fp.frontend.controller.armas.parametros.BuscarTramiteLovController;
|
||
import com.fp.frontend.controller.armas.parametros.CentroControlArmasController;
|
||
import com.fp.frontend.controller.armas.parametros.OrigenTramiteController;
|
||
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.controller.security.LoginController;
|
||
import com.fp.frontend.helper.MessageHelper;
|
||
import com.fp.frontend.utility.MsgControlArmas;
|
||
import com.fp.frontend.utility.Utilidades;
|
||
import com.fp.persistence.parmas.param.TarmCentroControl;
|
||
import com.fp.persistence.parmas.param.TarmCentroControlJur;
|
||
import com.fp.persistence.parmas.param.TarmOrigenTramite;
|
||
import com.fp.persistence.parmas.param.TarmRequisitoPorTipoTramite;
|
||
import com.fp.persistence.parmas.param.TarmTramite;
|
||
import com.fp.persistence.parmas.soli.TarmSolicitudRequisitosKey;
|
||
import com.fp.persistence.pcustomer.gene.TcustPersonAddress;
|
||
import com.fp.persistence.pgeneral.gene.TgeneCatalogDetail;
|
||
import com.fp.persistence.pgeneral.safe.TsafeUserDetail;
|
||
|
||
/**
|
||
* Clase controladora de reporte de liquidacion economica
|
||
*
|
||
* @author Christian Pazmino.
|
||
* @version 2.1
|
||
*/
|
||
|
||
@SuppressWarnings("serial")
|
||
@ManagedBean
|
||
@ViewScoped
|
||
public class ReporteAutorizacionesController extends AbstractController<AbstractDataTransport> {
|
||
|
||
/**
|
||
* Fecha a partir de la cual se sacan datos para el reporte
|
||
* */
|
||
|
||
/**
|
||
* Controlador que maneja las armas dentro de la solicitud
|
||
*/
|
||
@ManagedProperty(value = "#{solicitudArmasController}")
|
||
private SolicitudArmasController solicitud;
|
||
|
||
|
||
private TarmTramite tarmTramite;
|
||
|
||
TgeneCatalogDetail tipoTramite = null ;
|
||
TgeneCatalogDetail tipoAutorizacion = null;
|
||
TgeneCatalogDetail actividad = null;
|
||
TgeneCatalogDetail categoria = null;
|
||
|
||
/**
|
||
* Habilita campos en actualización de datos generales
|
||
*/
|
||
private boolean actualizaDatosGenerales;
|
||
|
||
/**
|
||
* Aprueba si es guía de libre tránsito
|
||
*/
|
||
private boolean guiaLibreTransito;
|
||
|
||
/**
|
||
* Indica si se debe activar la pestana de ingresar requisitos
|
||
*/
|
||
private boolean ingresarRequisitos;
|
||
|
||
/**
|
||
* Indica si se debe activar la pestana de seleccionar armas
|
||
*/
|
||
private boolean seleccionarArmas;
|
||
|
||
private Date fechaInicio;
|
||
/**
|
||
* Fecha a partir de la cual se sacan datos para el reporte
|
||
* */
|
||
private Date fechaFin;
|
||
/**
|
||
* Formato de reporte que se va a generar
|
||
* */
|
||
private String format = "pdf";
|
||
/**
|
||
* Usuario actual logueado en el sistema
|
||
* */
|
||
private TsafeUserDetail userDetail;
|
||
/**
|
||
* Nombre del reporte generado en el Alfresco
|
||
* */
|
||
private String nombreReporte;
|
||
|
||
/**
|
||
* Id del centro de control seleccionado por el usuario
|
||
* */
|
||
private String idCentroControl;
|
||
|
||
/**
|
||
* Id del tipo de tramite
|
||
*/
|
||
private String idAutorizacion;
|
||
private String idIdentificacion;
|
||
|
||
private String numeroDocumento;
|
||
|
||
private String idCategoria;
|
||
|
||
private String idActividad;
|
||
|
||
/**
|
||
* Id del tipo de tramite
|
||
*/
|
||
private String idControl;
|
||
|
||
/**
|
||
* Lista de centros de control de armas
|
||
*/
|
||
// private List<TarmCentroControl> centroControlList;
|
||
private List<TgeneCatalogDetail> tipoDocumentoList;
|
||
|
||
private List<TgeneCatalogDetail> centroControlList;
|
||
|
||
private List<TgeneCatalogDetail> autorizacionList;
|
||
|
||
private List<TgeneCatalogDetail> categoriaList;
|
||
|
||
private List<TgeneCatalogDetail> actividadList;
|
||
|
||
private List<TgeneCatalogDetail> controlList;
|
||
|
||
private TgeneCatalogDetail tipoControl = new TgeneCatalogDetail();
|
||
|
||
private String institucionCentroControl="";
|
||
private TarmCentroControl centroControl = new TarmCentroControl();
|
||
|
||
|
||
|
||
/**
|
||
* Clase controladora de reportes
|
||
*/
|
||
@ManagedProperty(value = "#{reportController}")
|
||
private ReportController reportController;
|
||
|
||
@ManagedProperty(value = "#{logincontroller}")
|
||
private LoginController logincontroller;
|
||
|
||
|
||
public ReporteAutorizacionesController() throws Exception {
|
||
super(AbstractDataTransport.class);
|
||
// TODO Auto-generated constructor stub
|
||
}
|
||
|
||
@PostConstruct
|
||
private void postconstruct() {
|
||
this.init();
|
||
// Inicializa autoconsulta
|
||
super.startQuery();
|
||
}
|
||
|
||
/**
|
||
* Incializa el controlador, cuando se esta utilizando una pagina que utliza el controlador.
|
||
*/
|
||
private void init() {
|
||
try {
|
||
userDetail=(TsafeUserDetail)FacesContext.getCurrentInstance().getExternalContext().getSessionMap().get("TSAFEUSERDETAIL");
|
||
recperpage = 10000; // Cambiar al # reg a mirar.
|
||
beanalias = "RPRTEAUTORIZACIONES";
|
||
// centroControlList = CentroControlArmasController.findAll();
|
||
centroControlList = CatalogDetailController.find("ESTADOAUTORIZACION");
|
||
// autorizacionList = CatalogDetailController.find("TIPOAUTORIZACION"); // tipo de tramite
|
||
// categoriaList = CatalogDetailController.find("CATEGORIA"); //catetegoria
|
||
// actividadList = CatalogDetailController.find("USOACTIVIDAD"); // actividad
|
||
tipoDocumentoList = CatalogDetailController.find("IDENTIFICATION");
|
||
controlList = CatalogDetailController.find("NOMBREINSTITUCION");
|
||
//obtenerCentroControl();
|
||
} catch (Exception e) {
|
||
MessageHelper.setMessageError(e);
|
||
}
|
||
}
|
||
|
||
|
||
@SuppressWarnings("unchecked")
|
||
@Override
|
||
protected void querydatabase() {
|
||
|
||
}
|
||
|
||
/**
|
||
* Metodo para reconsultar en base a una nueva fecha de corte seleccionada
|
||
*/
|
||
public void cambioFechaDeCorte(SelectEvent event){
|
||
querydatabase();
|
||
}
|
||
|
||
@Override
|
||
public void postCommit(Response response) throws Exception {
|
||
super.postCommitGeneric(response, beanalias);
|
||
}
|
||
|
||
|
||
/**
|
||
* Genera un reporte de armas a destruir
|
||
*
|
||
*/
|
||
public void generateReport() {
|
||
|
||
if(this.tipoTramite == null){
|
||
MessageHelper.setMessageError("ERROR: CAMPO TIPO TR<54>MITE REQUERIDO");
|
||
return;
|
||
}
|
||
|
||
|
||
if(this.fechaInicio!=null || this.fechaFin!=null)
|
||
{
|
||
if(this.fechaInicio.getTime() > this.fechaFin.getTime()){
|
||
MessageHelper.setMessageError(MsgControlArmas.getProperty("msg_error_liqeco_fechaInicioMayorAFechaFin"));
|
||
return;
|
||
}
|
||
if(this.fechaInicio.getTime() > new Date().getTime()){
|
||
MessageHelper.setMessageError(MsgControlArmas.getProperty("msg_error_liqeco_fechaInicioMayorAFechaActual"));
|
||
return;
|
||
}
|
||
if(this.fechaFin.getTime() > new Date().getTime()){
|
||
MessageHelper.setMessageError(MsgControlArmas.getProperty("msg_error_liqeco_fechaFinMayorAFechaActual"));
|
||
return;
|
||
}
|
||
}
|
||
|
||
Calendar fechaActualCldr = Calendar.getInstance();
|
||
String path = "armas/reports/autorizaciones";
|
||
String filename="autorizaciones";
|
||
String nombreUsuario="";
|
||
|
||
// Fija parametros del report.
|
||
HashMap<String, Object> parameters = new HashMap<>();
|
||
|
||
if(userDetail.getPk().getPersoncode()!=null){
|
||
nombreUsuario = PersonDetailController.find(userDetail.getPk().getPersoncode().toString()).getName();
|
||
}
|
||
else{
|
||
nombreUsuario = "";
|
||
}
|
||
// institucionCentroControl
|
||
parameters.put("pathLogoIzquierda", "repo:/maia/1/image/comandoconjunto");
|
||
parameters.put("pathLogoDerecha", "repo:/maia/1/image/selloarmas");
|
||
//parameters.put("unidadmilitar", "hola");
|
||
parameters.put("lugarFecha", Utilidades.armarFormatoFechaConHora(fechaActualCldr));
|
||
parameters.put("usuario", nombreUsuario);
|
||
parameters.put("numeroDocumento"," ".equalsIgnoreCase(numeroDocumento)?null:numeroDocumento);
|
||
parameters.put("idControl", "TODOS".equalsIgnoreCase(idControl)?null:idControl); //centro de control
|
||
parameters.put("idCentroControl","TODOS".equalsIgnoreCase(idCentroControl)?null:idCentroControl); // estado
|
||
//parameters.put("idAutorizacion", "TODOS".equalsIgnoreCase(idAutorizacion)?null:idAutorizacion); // tipo de tramite
|
||
//parameters.put("idCategoria", "TODOS".equalsIgnoreCase(idCategoria)?null:idCategoria); // categoria
|
||
//parameters.put("idActividad", "TODOS".equalsIgnoreCase(idActividad)?null:idActividad); // uso actividad
|
||
parameters.put("idIdentificacion", "TODOS".equalsIgnoreCase(idIdentificacion)?null:idIdentificacion); // tipo de identificacion
|
||
parameters.put("fechaInicio", this.fechaInicio==null?null:Utilidades.armarFormatoFechaSinHora(this.fechaInicio));
|
||
parameters.put("fechaFin", this.fechaFin==null?null:Utilidades.armarFormatoFechaSinHora(this.fechaFin));
|
||
TgeneCatalogDetail obj = CatalogDetailController.findCatalogo("NOMBREINSTITUCION", idControl);
|
||
parameters.put("tipocentro", "TODOS".equalsIgnoreCase(idControl)?"TODOS":obj.getDescription()) ; //centro de control detalle
|
||
TgeneCatalogDetail obj1 = CatalogDetailController.findCatalogo("ESTADOAUTORIZACION", idCentroControl);
|
||
parameters.put("pestado", "TODOS".equalsIgnoreCase(idCentroControl)?"TODOS":obj1.getDescription()) ; //estado detalle
|
||
TgeneCatalogDetail obj2 = CatalogDetailController.findCatalogo("IDENTIFICATION", idIdentificacion);
|
||
parameters.put("pdocumento", "TODOS".equalsIgnoreCase(idIdentificacion)?"TODOS":obj2.getDescription()) ; //tipo documento detalle
|
||
|
||
parameters.put("idAutorizacion", tipoAutorizacion.getPk().getCatalog());
|
||
parameters.put("idCategoria", categoria.getPk().getCatalog());
|
||
parameters.put("idActividad", actividad.getPk().getCatalog());
|
||
parameters.put("Tipotramite", tipoTramite.getPk().getCatalog());
|
||
|
||
|
||
|
||
try{
|
||
this.reportController.executeXls(path, parameters, format, filename, this.getLoginController());
|
||
} catch (Exception ex) {
|
||
MessageHelper.setMessageError(ex);
|
||
}
|
||
|
||
|
||
}
|
||
|
||
|
||
/**
|
||
* Abre el LOV de trámite
|
||
*/
|
||
public void openLovTramite() {
|
||
Map<String, List<String>> params = new HashMap<String, List<String>>();
|
||
List<String> ltipopersona = new ArrayList<>();
|
||
ltipopersona = null;
|
||
params.put("tipopersonasol", ltipopersona);
|
||
BuscarTramiteLovController.openLov(params);
|
||
}
|
||
|
||
|
||
|
||
/**
|
||
* Regresa del LOV para cargar valores
|
||
* @param event {@link SelectEvent}
|
||
*/
|
||
public void onReturnTramite(SelectEvent event) {
|
||
try{
|
||
TarmTramite tramite = (TarmTramite) event.getObject();
|
||
this.tarmTramite = tramite;
|
||
// if(!procedeTramite(TarmTramiteController.find(tramite.getCtramitepadre() != null ? tramite.getCtramitepadre().toString() : "-1"),tramite.getPk())){
|
||
|
||
|
||
solicitud.getRecord().setCtramite(tramite.getPk());
|
||
tipoTramite = CatalogDetailController.findxCodigoCodcatalogo(tramite.getTipotramite(), tramite.getTipotramitecodigo());
|
||
tipoAutorizacion = CatalogDetailController.findxCodigoCodcatalogo(tramite.getTipoautorizacion(), tramite.getTipoautorizacioncodigo());
|
||
categoria = CatalogDetailController.findxCodigoCodcatalogo(tramite.getCategoria(), tramite.getCategoriacodigo());
|
||
actividad = CatalogDetailController.findxCodigoCodcatalogo(tramite.getUsoactividad(), tramite.getUsoactividadcodigo());
|
||
this.getSolicitud().addField("tipoTramite", tipoTramite.getDescription());
|
||
this.getSolicitud().addField("tipoAutorizacion", tipoAutorizacion.getDescription());
|
||
this.getSolicitud().addField("categoria", categoria.getDescription());
|
||
this.getSolicitud().addField("actividad", actividad.getDescription());
|
||
|
||
|
||
|
||
|
||
} catch(Throwable e){
|
||
MessageHelper.setMessageError(e);
|
||
}
|
||
|
||
|
||
}
|
||
|
||
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();
|
||
}
|
||
|
||
|
||
/**
|
||
* Método para el inicio de flujo. Guardar el reporte creado para su posterior aprobacion en otras instancias del flujo
|
||
*/
|
||
@Override
|
||
public void save(){
|
||
|
||
}
|
||
|
||
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;
|
||
}
|
||
|
||
public String getFormat() {
|
||
return format;
|
||
}
|
||
|
||
public void setFormat(String format) {
|
||
this.format = format;
|
||
}
|
||
|
||
public TsafeUserDetail getUserDetail() {
|
||
return userDetail;
|
||
}
|
||
|
||
public void setUserDetail(TsafeUserDetail userDetail) {
|
||
this.userDetail = userDetail;
|
||
}
|
||
|
||
public String getNombreReporte() {
|
||
return nombreReporte;
|
||
}
|
||
|
||
public void setNombreReporte(String nombreReporte) {
|
||
this.nombreReporte = nombreReporte;
|
||
}
|
||
|
||
public String getIdCentroControl() {
|
||
return idCentroControl;
|
||
}
|
||
|
||
public void setIdCentroControl(String idCentroControl) {
|
||
this.idCentroControl = idCentroControl;
|
||
}
|
||
|
||
public String getIdAutorizacion() {
|
||
return idAutorizacion;
|
||
}
|
||
|
||
public void setIdAutorizacion(String idAutorizacion) {
|
||
this.idAutorizacion = idAutorizacion;
|
||
}
|
||
|
||
//idIdentificacion
|
||
|
||
public String getIdIdentificacion() {
|
||
return idIdentificacion;
|
||
}
|
||
|
||
public void setIdIdentificacion(String idIdentificacion) {
|
||
this.idIdentificacion = idIdentificacion;
|
||
}
|
||
//public List<TarmCentroControl> getCentroControlList() {
|
||
// return centroControlList;
|
||
//}
|
||
|
||
//public void setCentroControlList(List<TarmCentroControl> centroControlList) {
|
||
//this.centroControlList = centroControlList;
|
||
//}
|
||
|
||
public List<TgeneCatalogDetail> getCentroControlList() {
|
||
return centroControlList;
|
||
}
|
||
|
||
public void setCentroControlList(List<TgeneCatalogDetail> centroControlList) {
|
||
this.centroControlList = centroControlList;
|
||
}
|
||
|
||
/*CFLORES*/
|
||
public List<TgeneCatalogDetail> getTipoDocumentoList() {
|
||
return tipoDocumentoList;
|
||
}
|
||
|
||
public void getTipoDocumentoList(List<TgeneCatalogDetail> tipoDocumentoList) {
|
||
this.tipoDocumentoList = tipoDocumentoList;
|
||
}
|
||
/**/
|
||
|
||
public List<TgeneCatalogDetail> getAutorizacionList() {
|
||
return autorizacionList;
|
||
}
|
||
|
||
public void setAutorizacionList(List<TgeneCatalogDetail> autorizacionList) {
|
||
this.autorizacionList = autorizacionList;
|
||
}
|
||
|
||
/*cflores*/
|
||
public List<TgeneCatalogDetail> getControlList() {
|
||
return controlList;
|
||
}
|
||
|
||
public void setControlList(List<TgeneCatalogDetail> controlList) {
|
||
this.controlList = controlList;
|
||
}
|
||
|
||
public String getIdControl() {
|
||
return idControl;
|
||
}
|
||
|
||
public void setIdControl(String idControl) {
|
||
this.idControl = idControl;
|
||
}
|
||
/*categoria*/
|
||
public List<TgeneCatalogDetail> getCategoriaList() {
|
||
return categoriaList;
|
||
}
|
||
|
||
public void setCategoriaList(List<TgeneCatalogDetail> categoriaList) {
|
||
this.categoriaList = categoriaList;
|
||
}
|
||
|
||
public String getIdCategoria() {
|
||
return idCategoria;
|
||
}
|
||
|
||
public void setIdCategoria(String idCategoria) {
|
||
this.idCategoria = idCategoria;
|
||
}
|
||
/**/
|
||
|
||
/*actividad*/
|
||
public List<TgeneCatalogDetail> getActividadList() {
|
||
return actividadList;
|
||
}
|
||
|
||
public void setActividadList(List<TgeneCatalogDetail> actividadList) {
|
||
this.actividadList = actividadList;
|
||
}
|
||
|
||
public String getIdActividad() {
|
||
return idActividad;
|
||
}
|
||
|
||
public void setIdActividad(String idActividad) {
|
||
this.idActividad = idActividad;
|
||
}
|
||
/**/
|
||
public String getNumeroDocumento() {
|
||
return numeroDocumento;
|
||
}
|
||
|
||
public void setNumeroDocumento(String numeroDocumento) {
|
||
this.numeroDocumento = numeroDocumento;
|
||
}
|
||
/**/
|
||
|
||
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 LoginController getLogincontroller() {
|
||
return logincontroller;
|
||
}
|
||
|
||
public void setLogincontroller(LoginController logincontroller) {
|
||
this.logincontroller = logincontroller;
|
||
}
|
||
|
||
public TarmCentroControl getCentroControl() {
|
||
return centroControl;
|
||
}
|
||
|
||
public void setCentroControl(TarmCentroControl centroControl) {
|
||
this.centroControl = centroControl;
|
||
}
|
||
|
||
/**
|
||
* Entrega el valor de: solicitud
|
||
*
|
||
* @return SolicitudArmasController
|
||
*/
|
||
public SolicitudArmasController getSolicitud() {
|
||
return solicitud;
|
||
}
|
||
|
||
/**
|
||
* Fija el valor de: solicitud
|
||
*
|
||
* @param solicitud Valor a fijar en el atributo.
|
||
*/
|
||
public void setSolicitud(SolicitudArmasController solicitud) {
|
||
this.solicitud = solicitud;
|
||
}
|
||
|
||
|
||
}
|