maia_modificado/.svn/pristine/00/00b9a4e1c5f0bc4ef339bc02898...

368 lines
11 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.eclipse.jdt.core.dom.ThisExpression;
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.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.TgeneCatalogDetail;
import com.fp.persistence.pgeneral.safe.TsafeUserDetail;
/**
* @author DLO
* Clase Controladora la cual genera el reporte de trámite por centro de control
*/
@ManagedBean
@ViewScoped
public class ReporteDecomisoController extends AbstractController<AbstractDataTransport> {
public ReporteDecomisoController() throws Exception {
super(AbstractDataTransport.class);
// TODO Auto-generated constructor stub
}
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<TgeneCatalogDetail> ltiporeg = null;
private List<TgeneCatalogDetail> lorgcontrol = 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 idOrgControl;
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.lorgcontrol = CatalogDetailController.find("INSTITUCION");
this.responsableCentroControl = new TcustPersonDetail();
this.tsafeUserDetailUsuario = new TsafeUserDetail();
//this.obtenerResponsableCentroControl();
this.idTipoReg="";
this.idOrgControl="";
} 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());
}
@Override
protected void querydatabase() {
}
/**
* Graba los registros en la base de datos
*/
@Override
public void save() {
}
/**
* Obtiene el reporte de Ficha de Armas
*/
public void reporteTramitesCentro() {
try {
if(this.fechainicial.getTime()>this.fechafinal.getTime()){
MessageHelper.setMessageError(MsgControlArmas.getProperty("msg_fechafinal"));
return;
}
String gradoUsuario ="";
String path = "armas/reports/reporteDecomiso";
//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
parameters.put("centroControl", this.obtenerCentroControl());
//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("filtro", "");
}
if(this.idOrgControl!=null && !this.idOrgControl.equals("TODOS")){
this.filtro2 = " and cc.institucion = '"+this.idOrgControl+"' ";
parameters.put("filtro2", this.filtro2);
}else {
parameters.put("filtro2", "");
}
String format = "xlsx";
try {
this.reportController.executeXls(path, parameters, format, filename, this.getLoginController());
} catch (Exception ex) {
MessageHelper.setMessageError(ex);
}
} catch (Exception ex) {
MessageHelper.setMessageError(ex);
}
}
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<TgeneCatalogDetail> getLorgcontrol() {
return lorgcontrol;
}
public void setLorgcontrol(List<TgeneCatalogDetail> lorgcontrol) {
this.lorgcontrol = lorgcontrol;
}
public String getIdOrgControl() {
return idOrgControl;
}
public void setIdOrgControl(String idOrgControl) {
this.idOrgControl = idOrgControl;
}
}