477 lines
16 KiB
Plaintext
Executable File
477 lines
16 KiB
Plaintext
Executable File
package com.fp.frontend.controller.armas.funcionalidad;
|
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
import java.util.ArrayList;
|
|
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.apache.log4j.Logger;
|
|
|
|
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.pgeneral.gene.CatalogDetailController;
|
|
import com.fp.frontend.helper.MessageHelper;
|
|
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.TgeneCatalogDetail;
|
|
import com.fp.persistence.pgeneral.safe.TsafeUserDetail;
|
|
|
|
@ManagedBean
|
|
@ViewScoped
|
|
public class ReporteTipoAutorizacionController extends AbstractController<AbstractDataTransport>{
|
|
|
|
/**
|
|
*
|
|
*/
|
|
public ReporteTipoAutorizacionController() throws Exception {
|
|
super(AbstractDataTransport.class);
|
|
// TODO Auto-generated constructor stub
|
|
}
|
|
|
|
private final static Logger LOGGER = Logger.getLogger(ReporteTipoAutorizacionController.class);
|
|
private static final long serialVersionUID = 1L;
|
|
@ManagedProperty(value = "#{reportController}")
|
|
private ReportController reportController;
|
|
|
|
@ManagedProperty(value = "#{personDetailController}")
|
|
private PersonDetailController personDetailController;
|
|
|
|
@ManagedProperty(value = "#{centroControlController}")
|
|
private CentroControlArmasController centroControlController;
|
|
|
|
|
|
|
|
private TcustPersonDetail customerperson;
|
|
private TsafeUserDetail userDetail;
|
|
private TcustPersonDetail responsableCentroControl= null;
|
|
private TsafeUserDetail tsafeUserDetailUsuario = null;
|
|
private TarmCentroControl centroControl = new TarmCentroControl();
|
|
private List<TarmCentroControl> lcentroControl = null;
|
|
private List<TgeneCatalogDetail> ltiporeg = null;
|
|
private List<TgeneCatalogDetail> ltipoAuto = null;
|
|
private List<TgeneCatalogDetail> ltipoArma = null;
|
|
private List<String> tipoAutoSeleccionado = null;
|
|
//Tipo de Arma Seleccionada
|
|
private List<String> tipoArmaSeleccionada = null;
|
|
|
|
private String institucionCentroControl="";
|
|
private Date fechainicial;
|
|
private Date fechafinal;
|
|
private String filtro="";
|
|
private String filtro2="";
|
|
private String idTipoReg;
|
|
private Date fec_actual;
|
|
private String codCentroControl;
|
|
|
|
|
|
|
|
@Override
|
|
protected void querydatabase() {
|
|
// TODO Auto-generated method stub
|
|
|
|
}
|
|
|
|
public String getInstitucionCentroControl() {
|
|
return institucionCentroControl;
|
|
}
|
|
|
|
@PostConstruct
|
|
private void postconstruct() {
|
|
this.init();
|
|
// Inicializa autoconsulta
|
|
}
|
|
/**
|
|
* Incializa el controlador, cuando se esta utilizando una pagina que utliza el controlador.
|
|
*/
|
|
private void init() {
|
|
try {
|
|
|
|
this.lrecord = new ArrayList<>();
|
|
this.beanalias = "REPORTE";
|
|
ltiporeg = CatalogDetailController.find("TIPOREGISTRO", "DECINC");
|
|
this.ltipoAuto = CatalogDetailController.find("TIPOAUTORIZACION");
|
|
//tipo de Arma
|
|
this.ltipoArma = CatalogDetailController.find("TIPOARMAEXPLOSIVO", "0010000001");
|
|
this.lcentroControl = CentroControlArmasController.findAll();
|
|
this.responsableCentroControl = new TcustPersonDetail();
|
|
// this.tsafeUserDetailUsuario = new TsafeUserDetail();
|
|
this.tsafeUserDetailUsuario = (TsafeUserDetail) FacesContext.getCurrentInstance().getExternalContext().getSessionMap().get("TSAFEUSERDETAIL");
|
|
//this.obtenerResponsableCentroControl();
|
|
this.idTipoReg="";
|
|
this.codCentroControl="";
|
|
|
|
} catch (Exception e) {
|
|
MessageHelper.setMessageError(e);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
* Obtiene el centro de control segun usurio logeado.
|
|
* @throws Exception
|
|
*
|
|
*/
|
|
private String obtenerCentroControl() throws Exception {
|
|
|
|
this.tsafeUserDetailUsuario = (TsafeUserDetail) FacesContext.getCurrentInstance().getExternalContext().getSessionMap().get("TSAFEUSERDETAIL");
|
|
PersonAddressController personAddressController = new PersonAddressController();
|
|
TcustPersonAddress tcustPersonAddres=personAddressController.findPrincipal(tsafeUserDetailUsuario.getPk().getPersoncode().toString());
|
|
if(tcustPersonAddres == null){
|
|
return null;
|
|
}
|
|
TarmCentroControlJur centroControlJur= TarmCentroControlJurController.findxProvincia(tcustPersonAddres.getProvincecode());
|
|
centroControl= CentroControlArmasController.findPorCodigo(centroControlJur.getCcentrocontrol());
|
|
return CatalogDetailController.findxCodigoCodcatalogo( centroControl.getNombreinstitucion(), centroControl.getNombreinstitucioncodigo()).getDescription();
|
|
}
|
|
|
|
/**
|
|
* Obtiene el responsable del Centro de Control
|
|
*/
|
|
public void obtenerResponsableCentroControl(){
|
|
Integer responsable = this.centroControl.getPersoncode();
|
|
this.responsableCentroControl = PersonDetailController.find(responsable.toString());
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
* Graba los registros en la base de datos
|
|
*/
|
|
@Override
|
|
public void save() {
|
|
|
|
|
|
}
|
|
|
|
/**
|
|
* Obtiene el reporte de Ficha de Armas
|
|
*/
|
|
public void reporteTipoAutorizacion() {
|
|
try {
|
|
String gradoUsuario ="";
|
|
String path = "armas/reports/reporteTipoAutorizacion";
|
|
//String filename=MsgControlArmas.getProperty("lbl_tramitesXcentro");
|
|
String filename="reporte";
|
|
|
|
//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");
|
|
|
|
//Centro de control
|
|
|
|
//Fecha actual
|
|
this.fec_actual = new Date();
|
|
SimpleDateFormat sdf=new SimpleDateFormat("dd/MM/yyyy hh:mm:ss");
|
|
parameters.put("fecActual", sdf.format(this.fec_actual));
|
|
|
|
//usuario
|
|
customerperson = PersonDetailController.find(this.tsafeUserDetailUsuario.getPk().getPersoncode().toString());
|
|
parameters.put("usuario", customerperson.getName());
|
|
|
|
//fechas inicial y final que vienen desde el controlador
|
|
// SimpleDateFormat df=new SimpleDateFormat("dd/MM/yyyy");
|
|
// parameters.put("fechainicial", df.format(this.fechainicial));
|
|
// parameters.put("fechafinal", df.format(this.fechafinal));
|
|
|
|
// if(this.idTipoReg.equals("DECO") && this.idTipoReg!=null){
|
|
// this.filtro = " and d.tipoproceso = '"+this.idTipoReg+"' ";
|
|
// parameters.put("filtro", this.filtro);
|
|
// }else if (this.idTipoReg.equals("INCA") && this.idTipoReg!=null) {
|
|
// this.filtro = " and d.tipoproceso = '"+this.idTipoReg+"' ";
|
|
// parameters.put("filtro", this.filtro);
|
|
// }else {
|
|
parameters.put("filtroEstados", obtenerEstadosSeleccionados());
|
|
|
|
|
|
// }
|
|
|
|
String format = "pdf";
|
|
|
|
try {
|
|
|
|
this.reportController.execute(path, parameters, format, filename, this.getLoginController());
|
|
} catch (Exception ex) {
|
|
MessageHelper.setMessageError(ex);
|
|
}
|
|
|
|
} catch (Exception ex) {
|
|
MessageHelper.setMessageError(ex);
|
|
}
|
|
}
|
|
|
|
|
|
public void reporteTipoAutorizacionXls() {
|
|
try {
|
|
String gradoUsuario ="";
|
|
String path = "armas/reports/reporteTipoAutorizacion";
|
|
//String filename=MsgControlArmas.getProperty("lbl_tramitesXcentro");
|
|
String filename="reporte";
|
|
|
|
//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");
|
|
|
|
//Centro de control
|
|
|
|
//Fecha actual
|
|
this.fec_actual = new Date();
|
|
SimpleDateFormat sdf=new SimpleDateFormat("dd/MM/yyyy hh:mm:ss");
|
|
parameters.put("fecActual", sdf.format(this.fec_actual));
|
|
|
|
//usuario
|
|
customerperson = PersonDetailController.find(this.tsafeUserDetailUsuario.getPk().getPersoncode().toString());
|
|
parameters.put("usuario", customerperson.getName());
|
|
|
|
//fechas inicial y final que vienen desde el controlador
|
|
// SimpleDateFormat df=new SimpleDateFormat("dd/MM/yyyy");
|
|
// parameters.put("fechainicial", df.format(this.fechainicial));
|
|
// parameters.put("fechafinal", df.format(this.fechafinal));
|
|
|
|
// if(this.idTipoReg.equals("DECO") && this.idTipoReg!=null){
|
|
// this.filtro = " and d.tipoproceso = '"+this.idTipoReg+"' ";
|
|
// parameters.put("filtro", this.filtro);
|
|
// }else if (this.idTipoReg.equals("INCA") && this.idTipoReg!=null) {
|
|
// this.filtro = " and d.tipoproceso = '"+this.idTipoReg+"' ";
|
|
// parameters.put("filtro", this.filtro);
|
|
// }else {
|
|
parameters.put("filtroEstados", obtenerEstadosSeleccionados());
|
|
|
|
|
|
// }
|
|
|
|
String format = "xls";
|
|
|
|
try {
|
|
|
|
this.reportController.execute(path, parameters, format, filename, this.getLoginController());
|
|
} catch (Exception ex) {
|
|
MessageHelper.setMessageError(ex);
|
|
}
|
|
|
|
} catch (Exception ex) {
|
|
MessageHelper.setMessageError(ex);
|
|
}
|
|
}
|
|
|
|
|
|
private String obtenerEstadosSeleccionados(){
|
|
StringBuilder filtro = new StringBuilder();
|
|
StringBuilder autorizacionSel = new StringBuilder();
|
|
for (String autorizacion : tipoAutoSeleccionado) {
|
|
autorizacionSel.append("'");
|
|
autorizacionSel.append(autorizacion);
|
|
autorizacionSel.append("',");
|
|
}
|
|
filtro.append(" AND autorizacion.CATALOG IN (");
|
|
filtro.append(autorizacionSel.substring(0, autorizacionSel.length() - 1));
|
|
filtro.append(")");
|
|
LOGGER.info("el filtro obtenido es el siguiente::" + filtro);
|
|
return filtro.toString();
|
|
}
|
|
|
|
|
|
private String obtenerTipoArmaSeleccionada(){
|
|
StringBuilder filtro = new StringBuilder();
|
|
StringBuilder armaSel = new StringBuilder();
|
|
for (String tipos : tipoArmaSeleccionada) {
|
|
armaSel.append("'");
|
|
armaSel.append(tipos);
|
|
armaSel.append("',");
|
|
}
|
|
|
|
filtro.append(" AND T.CATALOG IN (");
|
|
filtro.append(armaSel.substring(0, armaSel.length() - 1));
|
|
filtro.append(")");
|
|
LOGGER.info("el filtro obtenido tipo Arma es el siguiente::" + filtro);
|
|
return filtro.toString();
|
|
}
|
|
|
|
|
|
public ReportController getReportController() {
|
|
return reportController;
|
|
}
|
|
|
|
public void setReportController(ReportController reportController) {
|
|
this.reportController = reportController;
|
|
}
|
|
|
|
public TcustPersonDetail getCustomerperson() {
|
|
return customerperson;
|
|
}
|
|
|
|
public void setCustomerperson(TcustPersonDetail customerperson) {
|
|
this.customerperson = customerperson;
|
|
}
|
|
|
|
public TsafeUserDetail getUserDetail() {
|
|
return userDetail;
|
|
}
|
|
|
|
public void setUserDetail(TsafeUserDetail userDetail) {
|
|
this.userDetail = userDetail;
|
|
}
|
|
|
|
public TcustPersonDetail getResponsableCentroControl() {
|
|
return responsableCentroControl;
|
|
}
|
|
|
|
public void setResponsableCentroControl(
|
|
TcustPersonDetail responsableCentroControl) {
|
|
this.responsableCentroControl = responsableCentroControl;
|
|
}
|
|
|
|
public TsafeUserDetail getTsafeUserDetailUsuario() {
|
|
return tsafeUserDetailUsuario;
|
|
}
|
|
|
|
public void setTsafeUserDetailUsuario(TsafeUserDetail tsafeUserDetailUsuario) {
|
|
this.tsafeUserDetailUsuario = tsafeUserDetailUsuario;
|
|
}
|
|
|
|
public TarmCentroControl getCentroControl() {
|
|
return centroControl;
|
|
}
|
|
|
|
public void setCentroControl(TarmCentroControl centroControl) {
|
|
this.centroControl = centroControl;
|
|
}
|
|
|
|
public Date getFechainicial() {
|
|
return fechainicial;
|
|
}
|
|
|
|
public void setFechainicial(Date fechainicial) {
|
|
this.fechainicial = fechainicial;
|
|
}
|
|
|
|
public Date getFechafinal() {
|
|
return fechafinal;
|
|
}
|
|
|
|
public void setFechafinal(Date fechafinal) {
|
|
this.fechafinal = fechafinal;
|
|
}
|
|
|
|
public String getFiltro() {
|
|
return filtro;
|
|
}
|
|
|
|
public void setFiltro(String filtro) {
|
|
this.filtro = filtro;
|
|
}
|
|
|
|
public Date getFec_actual() {
|
|
return fec_actual;
|
|
}
|
|
|
|
public void setFec_actual(Date fec_actual) {
|
|
this.fec_actual = fec_actual;
|
|
}
|
|
|
|
public void setInstitucionCentroControl(String institucionCentroControl) {
|
|
this.institucionCentroControl = institucionCentroControl;
|
|
}
|
|
|
|
public String getIdTipoReg() {
|
|
return idTipoReg;
|
|
}
|
|
|
|
public void setIdTipoReg(String idTipoReg) {
|
|
this.idTipoReg = idTipoReg;
|
|
}
|
|
|
|
public List<TgeneCatalogDetail> getLtiporeg() {
|
|
return ltiporeg;
|
|
}
|
|
|
|
public void setLtiporeg(List<TgeneCatalogDetail> ltiporeg) {
|
|
this.ltiporeg = ltiporeg;
|
|
}
|
|
|
|
public PersonDetailController getPersonDetailController() {
|
|
return personDetailController;
|
|
}
|
|
|
|
public void setPersonDetailController(
|
|
PersonDetailController personDetailController) {
|
|
this.personDetailController = personDetailController;
|
|
}
|
|
|
|
public CentroControlArmasController getCentroControlController() {
|
|
return centroControlController;
|
|
}
|
|
|
|
public void setCentroControlController(
|
|
CentroControlArmasController centroControlController) {
|
|
this.centroControlController = centroControlController;
|
|
}
|
|
|
|
public List<TarmCentroControl> getLcentroControl() {
|
|
return lcentroControl;
|
|
}
|
|
|
|
public void setLcentroControl(List<TarmCentroControl> lcentroControl) {
|
|
this.lcentroControl = lcentroControl;
|
|
}
|
|
|
|
public String getCodCentroControl() {
|
|
return codCentroControl;
|
|
}
|
|
|
|
public void setCodCentroControl(String codCentroControl) {
|
|
this.codCentroControl = codCentroControl;
|
|
}
|
|
|
|
public List<TgeneCatalogDetail> getLtipoAuto() {
|
|
return ltipoAuto;
|
|
}
|
|
|
|
public void setLtipoAuto(List<TgeneCatalogDetail> lestadosArma) {
|
|
this.ltipoAuto = lestadosArma;
|
|
}
|
|
|
|
public List<String> getTipoAutoSeleccionado() {
|
|
return tipoAutoSeleccionado;
|
|
}
|
|
|
|
public void setTipoAutoSeleccionado(List<String> estadosSeleccionados) {
|
|
this.tipoAutoSeleccionado = estadosSeleccionados;
|
|
}
|
|
|
|
public List<TgeneCatalogDetail> getLtipoArma() {
|
|
return ltipoArma;
|
|
}
|
|
|
|
public void setLtipoArma(List<TgeneCatalogDetail> ltipoArma) {
|
|
this.ltipoArma = ltipoArma;
|
|
}
|
|
|
|
public List<String> getTipoArmaSeleccionada() {
|
|
return tipoArmaSeleccionada;
|
|
}
|
|
|
|
public void setTipoArmaSeleccionada(List<String> tipoArmaSeleccionada) {
|
|
this.tipoArmaSeleccionada = tipoArmaSeleccionada;
|
|
}
|
|
|
|
|
|
}
|