127 lines
4.7 KiB
Plaintext
Executable File
127 lines
4.7 KiB
Plaintext
Executable File
package com.fp.frontend.controller.armas.funcionalidad;
|
|
|
|
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 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.pcustomer.PersonDetailController;
|
|
import com.fp.frontend.controller.pgeneral.gene.ParametersController;
|
|
import com.fp.frontend.helper.MessageHelper;
|
|
import com.fp.persistence.parmas.param.TarmCentroControl;
|
|
import com.fp.persistence.pgeneral.gene.TgeneParameters;
|
|
import com.fp.persistence.pgeneral.safe.TsafeUserDetail;
|
|
|
|
/**
|
|
*
|
|
* @author David Cruz
|
|
*
|
|
*/
|
|
@ManagedBean
|
|
@ViewScoped
|
|
public class ReportePermisosAutorizacionesCconController extends AbstractController<AbstractDataTransport> {
|
|
|
|
@ManagedProperty(value = "#{reportController}")
|
|
private ReportController reportController;
|
|
private TsafeUserDetail userDetail;
|
|
private TgeneParameters paramDiasCaducidad;
|
|
private String centroControl="";
|
|
private List<TarmCentroControl> lcentroControl;
|
|
|
|
|
|
public ReportePermisosAutorizacionesCconController() throws Exception {
|
|
super(AbstractDataTransport.class);
|
|
}
|
|
|
|
@PostConstruct
|
|
public void init() {
|
|
beanalias = "REPORTE";
|
|
lrecord = new ArrayList<>();
|
|
userDetail=(TsafeUserDetail)FacesContext.getCurrentInstance().getExternalContext().getSessionMap().get("TSAFEUSERDETAIL");
|
|
paramDiasCaducidad = ParametersController.find("DIASCADUCIDADCERT", "1");
|
|
lcentroControl = CentroControlArmasController.findAll();
|
|
}
|
|
|
|
private static final long serialVersionUID = 1L;
|
|
|
|
@Override
|
|
protected void querydatabase() {
|
|
// TODO Auto-generated method stub
|
|
|
|
}
|
|
|
|
public void generarReporte() {
|
|
String path = "armas/reports/reportePermisosAutorizacionesxSuspCcon";
|
|
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;
|
|
if(userDetail.getPk().getPersoncode()!=null){
|
|
nombreUsuario = PersonDetailController.find(userDetail.getPk().getPersoncode().toString()).getName();
|
|
parameters.put("personcode", userDetail.getPk().getPersoncode());
|
|
}
|
|
else{
|
|
nombreUsuario = "";
|
|
}
|
|
// TarmCentroControl ccentroControl= CentroControlArmasController.findPorCodigo(centroControl);
|
|
// String institucionCentroControl = CatalogDetailController.findxCodigoCodcatalogo( ccentroControl.getNombreinstitucion(), ccentroControl.getNombreinstitucioncodigo()).getDescription();
|
|
SimpleDateFormat fechatxt=new SimpleDateFormat("dd/MM/yyyy");
|
|
Date fechainicial = Calendar.getInstance().getTime();
|
|
Calendar calendar = Calendar.getInstance();
|
|
calendar.setTime(fechainicial);
|
|
calendar.add(Calendar.DATE, (paramDiasCaducidad != null && paramDiasCaducidad.getNumbervalue() != null) ? paramDiasCaducidad.getNumbervalue().intValue() : 0);
|
|
Date fechafinal = calendar.getTime();
|
|
parameters.put("usuario", nombreUsuario);
|
|
// parameters.put("centroControl", centroControl);
|
|
// parameters.put("nombrecentro", institucionCentroControl);
|
|
parameters.put("fechainicio", fechatxt.format(fechainicial));
|
|
parameters.put("fechafin", fechatxt.format(fechafinal));
|
|
String format="xlsx";
|
|
String filename= "permisosautorizacionesxsusp";
|
|
//Fecha actual
|
|
this.reportController.executeXls(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 getCentroControl() {
|
|
return centroControl;
|
|
}
|
|
|
|
public void setCentroControl(String centroControl) {
|
|
this.centroControl = centroControl;
|
|
}
|
|
|
|
public List<TarmCentroControl> getLcentroControl() {
|
|
return lcentroControl;
|
|
}
|
|
|
|
public void setLcentroControl(List<TarmCentroControl> lcentroControl) {
|
|
this.lcentroControl = lcentroControl;
|
|
}
|
|
|
|
}
|