307 lines
9.2 KiB
Plaintext
Executable File
307 lines
9.2 KiB
Plaintext
Executable File
package com.fp.frontend.controller.armas.solicitud;
|
|
|
|
|
|
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 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.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.security.LoginController;
|
|
import com.fp.frontend.helper.MessageHelper;
|
|
import com.fp.frontend.utility.Utilidades;
|
|
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.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 ReporteEstadisticasTramitesController extends AbstractController<AbstractDataTransport> {
|
|
|
|
/**
|
|
* Fecha a partir de la cual se sacan datos para el reporte
|
|
* */
|
|
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;
|
|
|
|
/**
|
|
* Lista de centros de control de armas
|
|
*/
|
|
private List<TarmCentroControl> centroControlList;
|
|
|
|
|
|
private List<TgeneCatalogDetail> autorizacionList;
|
|
|
|
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 ReporteEstadisticasTramitesController() 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 = "RPRTEESTADISTICASTRAMITE";
|
|
centroControlList = CentroControlArmasController.findAll();
|
|
autorizacionList = CatalogDetailController.find("TIPOAUTORIZACION");
|
|
obtenerCentroControl();
|
|
} catch (Exception e) {
|
|
MessageHelper.setMessageError(e);
|
|
}
|
|
}
|
|
|
|
|
|
@SuppressWarnings("unchecked")
|
|
@Override
|
|
protected void querydatabase() {
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
public void postCommit(Response response) throws Exception {
|
|
super.postCommitGeneric(response, beanalias);
|
|
}
|
|
|
|
|
|
/**
|
|
* Genera un reporte de armas a destruir
|
|
*
|
|
*/
|
|
public void generateReport() {
|
|
Calendar fechaActualCldr = Calendar.getInstance();
|
|
String path = "armas/reports/estadisticastramites";
|
|
String filename="estadisticastramites";
|
|
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 = "";
|
|
}
|
|
|
|
parameters.put("pathLogoIzquierda", "repo:/maia/1/image/comandoconjunto");
|
|
parameters.put("pathLogoDerecha", "repo:/maia/1/image/selloarmas");
|
|
parameters.put("unidadmilitar", institucionCentroControl);
|
|
parameters.put("lugarFecha", Utilidades.armarFormatoFechaConHora(fechaActualCldr));
|
|
parameters.put("usuario", nombreUsuario);
|
|
parameters.put("idCentroControl", "TODOS".equalsIgnoreCase(idCentroControl)?null:idCentroControl);
|
|
parameters.put("idAutorizacion", "TODOS".equalsIgnoreCase(idAutorizacion)?null:idAutorizacion);
|
|
parameters.put("fechaInicio", this.fechaInicio==null?null:Utilidades.armarFormatoFechaSinHora(this.fechaInicio));
|
|
parameters.put("fechaFin", this.fechaFin==null?null:Utilidades.armarFormatoFechaSinHora(this.fechaFin));
|
|
|
|
try{
|
|
this.reportController.executeXls(path, parameters, format, filename, this.getLoginController());
|
|
} catch (Exception ex) {
|
|
MessageHelper.setMessageError(ex);
|
|
}
|
|
|
|
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
public List<TarmCentroControl> getCentroControlList() {
|
|
return centroControlList;
|
|
}
|
|
|
|
public void setCentroControlList(List<TarmCentroControl> centroControlList) {
|
|
this.centroControlList = centroControlList;
|
|
}
|
|
|
|
public List<TgeneCatalogDetail> getAutorizacionList() {
|
|
return autorizacionList;
|
|
}
|
|
|
|
public void setAutorizacionList(List<TgeneCatalogDetail> autorizacionList) {
|
|
this.autorizacionList = autorizacionList;
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
|
|
}
|