423 lines
17 KiB
Plaintext
Executable File
423 lines
17 KiB
Plaintext
Executable File
package com.fp.frontend.controller.armas.solicitud;
|
|
|
|
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 javax.faces.event.AjaxBehaviorEvent;
|
|
|
|
import org.primefaces.event.SelectEvent;
|
|
|
|
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.pcustomer.PersonAddressController;
|
|
import com.fp.frontend.controller.pcustomer.PersonDetailController;
|
|
import com.fp.frontend.controller.pcustomer.PersonPhoneController;
|
|
import com.fp.frontend.controller.pgeneral.gene.CatalogDetailController;
|
|
import com.fp.frontend.controller.pgeneral.gene.ParametersController;
|
|
import com.fp.frontend.helper.MessageHelper;
|
|
import com.fp.frontend.utility.MsgControlArmas;
|
|
import com.fp.persistence.parmas.param.TarmCentroControl;
|
|
import com.fp.persistence.parmas.soli.TarmDecomisoArma;
|
|
import com.fp.persistence.pcustomer.gene.TcustPersonAddress;
|
|
import com.fp.persistence.pcustomer.gene.TcustPersonDetail;
|
|
import com.fp.persistence.pcustomer.gene.TcustPersonPhone;
|
|
import com.fp.persistence.pgeneral.gene.TgeneCatalogDetail;
|
|
import com.fp.persistence.pgeneral.gene.TgeneParameters;
|
|
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 ReporteIngresoVentaArmExpController extends AbstractController<TarmDecomisoArma> {
|
|
|
|
/**
|
|
* 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 numeroDocumento;
|
|
|
|
|
|
/**
|
|
* Tipo de documento seleccionado cedula/ruc
|
|
*/
|
|
private String tipoDocumento;
|
|
/**
|
|
* Lista de centros de control de armas
|
|
*/
|
|
private List<TarmCentroControl> centroControlList;
|
|
/**
|
|
* Codigo del catalogo de PHONETYPE telefono fijo
|
|
*/
|
|
private String codigoTelefonoFijo;
|
|
|
|
/**
|
|
* Atributo para la lista de objetos TgeneCatalogDetail de identificación
|
|
*/
|
|
private List<TgeneCatalogDetail> ltipoidenti;
|
|
|
|
/**
|
|
* Clase controladora de reportes
|
|
*/
|
|
@ManagedProperty(value = "#{reportController}")
|
|
private ReportController reportController;
|
|
|
|
|
|
public ReporteIngresoVentaArmExpController() throws Exception {
|
|
super(TarmDecomisoArma.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.
|
|
lrecord = new ArrayList<TarmDecomisoArma>();
|
|
codigoTelefonoFijo=codigos("CODIGO.PHONE.FIJO");
|
|
beanalias = "RPRTELIQUIDACIONECONOMICA";
|
|
centroControlList = CentroControlArmasController.findAll();
|
|
//TgeneCatalogDetail grado = CatalogDetailController.findxCodigoCodcatalogo(this.responsableCentroControl.getMilitarygrade(), this.responsableCentroControl.getMilitarygradecode());
|
|
ltipoidenti = CatalogDetailController.find("IDENTIFICATION");
|
|
} catch (Exception e) {
|
|
MessageHelper.setMessageError(e);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Metodo para obtener los codigos
|
|
*/
|
|
public String codigos(String parametro){
|
|
TgeneParameters tgeneParameters= ParametersController.find(parametro, "1");
|
|
return tgeneParameters.getTextvalue();
|
|
}
|
|
|
|
@SuppressWarnings("unchecked")
|
|
@Override
|
|
protected void querydatabase() {
|
|
|
|
}
|
|
|
|
/**
|
|
* Metodo para reconsultar en base a una nueva fecha de corte seleccionada
|
|
*/
|
|
public void cambioFechaDeCorte(SelectEvent event){
|
|
querydatabase();
|
|
}
|
|
|
|
/**
|
|
* Genera un reporte de armas a destruir
|
|
*
|
|
*/
|
|
public void generateReport2() {
|
|
|
|
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;
|
|
}
|
|
try {
|
|
String path = "armas/reports/ingresoVentaArmasExplosivos";
|
|
String filename="ingresoVentaArmasExplosivos";
|
|
HashMap<String, Object> parameters = new HashMap<>();
|
|
parameters.put("pathLogoIzquierda", "repo:/maia/1/image/comandoconjunto");
|
|
parameters.put("pathLogoDerecha", "repo:/maia/1/image/selloarmas");
|
|
|
|
//usuario
|
|
TsafeUserDetail tsafeUserDetailUsuario = (TsafeUserDetail) FacesContext.getCurrentInstance().getExternalContext().getSessionMap().get("TSAFEUSERDETAIL");
|
|
TcustPersonDetail personLoged = PersonDetailController.find(tsafeUserDetailUsuario.getPk().getPersoncode().toString());
|
|
TcustPersonDetail personConsulted = PersonDetailController.findByIdentification(this.numeroDocumento);
|
|
parameters.put("usuario", personLoged.getName());
|
|
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
|
|
parameters.put("fechaInicio", sdf.format(this.fechaInicio));
|
|
parameters.put("fechaFin", sdf.format(this.fechaFin));
|
|
parameters.put("fechaReporte", sdf.format(new Date()));
|
|
|
|
if(personConsulted != null){
|
|
parameters.put("nombreRazonSocial", personConsulted.getName());
|
|
parameters.put("tipoDocumento", personConsulted.getIdentificationcatalog());
|
|
parameters.put("numeroDocumento", personConsulted.getIdentification());
|
|
parameters.put("representanteLegal", personConsulted.getLegalrepresent());
|
|
parameters.put("representanteLegalIdent", personConsulted.getLegalrepresentidentification());
|
|
parameters.put("personcode", personConsulted.getPk().getPersoncode().toString());
|
|
PersonAddressController address = new PersonAddressController();
|
|
TcustPersonAddress personAddress = address.findPrincipal(personConsulted.getPk().getPersoncode().toString());
|
|
if(personAddress != null){
|
|
parameters.put("direccion", personAddress.getAddress());
|
|
}else {
|
|
parameters.put("direccion", "");
|
|
}
|
|
}
|
|
|
|
TcustPersonPhone personPhone = PersonPhoneController.find(personConsulted.getPk().getPersoncode().toString(), "2");
|
|
if(personPhone != null && personPhone.getPhonenumber() != null){
|
|
parameters.put("telefono",personPhone.getPhonenumber());
|
|
}else {
|
|
parameters.put("telefono","");
|
|
}
|
|
this.reportController.executeXls(path, parameters, format, filename, this.getLoginController());
|
|
} catch (Exception e) {
|
|
// TODO: handle exception
|
|
}
|
|
|
|
|
|
}
|
|
|
|
/**
|
|
* Genera un reporte de armas a destruir
|
|
*
|
|
*/
|
|
public void generateReport() {
|
|
Calendar fechaActualCldr = Calendar.getInstance();
|
|
Calendar fechaInicioCldr = Calendar.getInstance();
|
|
Calendar fechaFinCldr = Calendar.getInstance();
|
|
fechaInicioCldr.setTime(fechaInicio);
|
|
fechaFinCldr.setTime(fechaFin);
|
|
if(fechaActualCldr.compareTo(fechaInicioCldr)>=0){
|
|
if(fechaActualCldr.compareTo(fechaFinCldr)>=0){
|
|
if(fechaFinCldr.compareTo(fechaInicioCldr)>=0){
|
|
String filename="ingresoVentaArmasExplosivos";
|
|
// 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");
|
|
|
|
try {
|
|
//Usuario logueado en la aplicacion
|
|
String nombreUsuario;
|
|
if(userDetail.getPk().getPersoncode()!=null){
|
|
nombreUsuario = PersonDetailController.find(userDetail.getPk().getPersoncode().toString()).getName();
|
|
}
|
|
else{
|
|
nombreUsuario = "";
|
|
}
|
|
parameters.put("usuario", nombreUsuario);
|
|
parameters.put("fechaInicio", armarFormatoFechaSinHora(fechaInicioCldr));
|
|
parameters.put("fechaFin", armarFormatoFechaSinHora(fechaFinCldr));
|
|
parameters.put("fechaReporte", armarFormatoFechaConHora(fechaActualCldr));
|
|
|
|
String path;
|
|
|
|
path = "armas/reports/ingresoVentaArmasExplosivos";
|
|
parameters.put("numeroDocumento", numeroDocumento);
|
|
// Persona objetivo de la consulta de movimientos
|
|
TcustPersonDetail personDetailConsultadaObj = PersonDetailController.findxidentification(numeroDocumento,tipoDocumento);
|
|
if(personDetailConsultadaObj != null){
|
|
parameters.put("nombreRazonSocial", personDetailConsultadaObj.getName());
|
|
parameters.put("tipoDocumento", tipoDocumento);
|
|
parameters.put("numeroDocumento", personDetailConsultadaObj.getIdentification());
|
|
parameters.put("representanteLegal", personDetailConsultadaObj.getLegalrepresent());
|
|
parameters.put("representanteLegalIdent", personDetailConsultadaObj.getLegalrepresentidentification());
|
|
PersonAddressController personAddressController = new PersonAddressController();
|
|
TcustPersonAddress tcustPersonAddresObj=personAddressController.findPrincipal (personDetailConsultadaObj.getPk().getPersoncode().toString());
|
|
if(tcustPersonAddresObj!=null){
|
|
parameters.put("direccion", tcustPersonAddresObj.getAddress());
|
|
}
|
|
else{
|
|
parameters.put("direccion", "");
|
|
}
|
|
TcustPersonPhone personPhoneObj= PersonPhoneController.find(personDetailConsultadaObj.getPk().getPersoncode().toString(), codigoTelefonoFijo);
|
|
if(personPhoneObj!=null){
|
|
parameters.put("telefono",personPhoneObj.getPhonenumber());
|
|
}
|
|
else{
|
|
parameters.put("telefono","");
|
|
}
|
|
}
|
|
|
|
// Datos del CENTRO DE CONTROL
|
|
// TarmCentroControl centroControlObj = CentroControlArmasController.findPorCodigo(idCentroControl);
|
|
// String nombreCentroControl = CatalogDetailController.findxCodigoCodcatalogo(centroControlObj.getNombreinstitucion(),centroControlObj.getNombreinstitucioncodigo()).getDescription();
|
|
// parameters.put("nombreCentroControl", nombreCentroControl);
|
|
// // Datos del jefe del centro
|
|
// if(centroControlObj.getPersoncode()!=null){
|
|
// TcustPersonDetail supervisorMilitarObj = PersonDetailController.find(centroControlObj.getPersoncode().toString());
|
|
// String gradoSupMilitar = supervisorMilitarObj.getMilitarygrade()==null?"": supervisorMilitarObj.getMilitarygrade() + " - ";
|
|
// parameters.put("nombreJefCentro", gradoSupMilitar + supervisorMilitarObj.getName()==null?"":supervisorMilitarObj.getName());
|
|
// parameters.put("personCodeJefCentro", supervisorMilitarObj.getPk().getPersoncode()==null?"1001":supervisorMilitarObj.getPk().getPersoncode());
|
|
//
|
|
// }
|
|
|
|
this.reportController.executeXls(path, parameters, format, filename, this.getLoginController());
|
|
|
|
} catch (Exception ex) {
|
|
MessageHelper.setMessageError(ex);
|
|
}
|
|
}
|
|
else{
|
|
MessageHelper.setMessageError(MsgControlArmas.getProperty("msg_error_liqeco_fechaInicioMayorAFechaFin"));
|
|
}
|
|
}else{
|
|
MessageHelper.setMessageError(MsgControlArmas.getProperty("msg_error_liqeco_fechaFinMayorAFechaActual"));
|
|
}
|
|
}else{
|
|
MessageHelper.setMessageError(MsgControlArmas.getProperty("msg_error_liqeco_fechaInicioMayorAFechaActual"));
|
|
}
|
|
|
|
}
|
|
|
|
// parameters.put("fechaCorte", fechaCorteSB.toString());
|
|
// parameters.put("codArmasDecomisadasLst", actualizarArmasSeleccionadas());
|
|
|
|
public StringBuilder armarFormatoFechaSinHora(Calendar fechaCldr){
|
|
StringBuilder fechaStr= new StringBuilder();
|
|
fechaStr = fechaStr.append((fechaCldr.get(Calendar.DAY_OF_MONTH)) <= 9 ? "0" + (fechaCldr.get(Calendar.DAY_OF_MONTH)) : (fechaCldr.get(Calendar.DAY_OF_MONTH)));
|
|
fechaStr = fechaStr.append("-").append((fechaCldr.get(Calendar.MONTH)+1) <= 9 ? "0" + (fechaCldr.get(Calendar.MONTH) + 1) : (fechaCldr.get(Calendar.MONTH)+1));
|
|
fechaStr = fechaStr.append("-").append(fechaCldr.get(Calendar.YEAR));
|
|
return fechaStr;
|
|
}
|
|
|
|
public StringBuilder armarFormatoFechaConHora(Calendar fechaCldr){
|
|
StringBuilder fechaStr= new StringBuilder();
|
|
fechaStr = fechaStr.append((fechaCldr.get(Calendar.DAY_OF_MONTH)) <= 9 ? "0" + (fechaCldr.get(Calendar.DAY_OF_MONTH)) : (fechaCldr.get(Calendar.DAY_OF_MONTH)));
|
|
fechaStr = fechaStr.append("-").append((fechaCldr.get(Calendar.MONTH)+1) <= 9 ? "0" + (fechaCldr.get(Calendar.MONTH) + 1) : (fechaCldr.get(Calendar.MONTH)+1));
|
|
fechaStr = fechaStr.append("-").append(fechaCldr.get(Calendar.YEAR));
|
|
fechaStr = fechaStr.append(" ").append(fechaCldr.get(Calendar.HOUR_OF_DAY));
|
|
fechaStr = fechaStr.append(":").append((fechaCldr.get(Calendar.MINUTE)) <= 9 ? "0" + (fechaCldr.get(Calendar.MINUTE)) : (fechaCldr.get(Calendar.MINUTE)));
|
|
return fechaStr;
|
|
}
|
|
|
|
/**
|
|
* 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 getNumeroDocumento() {
|
|
return numeroDocumento;
|
|
}
|
|
|
|
public void setNumeroDocumento(String numeroDocumento) {
|
|
this.numeroDocumento = numeroDocumento;
|
|
}
|
|
|
|
public String getTipoDocumento() {
|
|
return tipoDocumento;
|
|
}
|
|
|
|
public void setTipoDocumento(String tipoDocumento) {
|
|
this.tipoDocumento = tipoDocumento;
|
|
}
|
|
|
|
public List<TgeneCatalogDetail> getLtipoidenti() {
|
|
return ltipoidenti;
|
|
}
|
|
|
|
public void setLtipoidenti(List<TgeneCatalogDetail> ltipoidenti) {
|
|
this.ltipoidenti = ltipoidenti;
|
|
}
|
|
|
|
public List<TarmCentroControl> getCentroControlList() {
|
|
return centroControlList;
|
|
}
|
|
|
|
public void setCentroControlList(List<TarmCentroControl> centroControlList) {
|
|
this.centroControlList = centroControlList;
|
|
}
|
|
|
|
public ReportController getReportController() {
|
|
return reportController;
|
|
}
|
|
|
|
public void setReportController(ReportController reportController) {
|
|
this.reportController = reportController;
|
|
}
|
|
|
|
|
|
|
|
}
|