928 lines
31 KiB
Plaintext
Executable File
928 lines
31 KiB
Plaintext
Executable File
package com.fp.frontend.controller.armas.solicitud;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.Calendar;
|
|
import java.util.Date;
|
|
import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
|
|
import javax.annotation.PostConstruct;
|
|
import javax.faces.bean.ManagedBean;
|
|
import javax.faces.bean.ManagedProperty;
|
|
import javax.faces.bean.ViewScoped;
|
|
import javax.faces.event.AjaxBehaviorEvent;
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.primefaces.event.SelectEvent;
|
|
|
|
import com.fp.dto.Request;
|
|
import com.fp.dto.Response;
|
|
import com.fp.dto.query.DtoQuery;
|
|
import com.fp.dto.query.Filter;
|
|
import com.fp.dto.query.SubQuery;
|
|
import com.fp.dto.save.DtoSave;
|
|
import com.fp.frontend.controller.AbstractController;
|
|
import com.fp.frontend.controller.armas.funcionalidad.RegistroArmController;
|
|
import com.fp.frontend.controller.armas.parametros.CalibreLovController;
|
|
import com.fp.frontend.controller.armas.parametros.ClaseLovController;
|
|
import com.fp.frontend.controller.armas.parametros.LongitudLovController;
|
|
import com.fp.frontend.controller.armas.parametros.TipoArmaExpLovController;
|
|
import com.fp.frontend.controller.armas.parametros.TiposArmasExplosivosController;
|
|
import com.fp.frontend.controller.pcustomer.PersonDetailController;
|
|
import com.fp.frontend.controller.pcustomer.lov.PersonLovController;
|
|
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.frontend.utility.ValidateIdentification;
|
|
import com.fp.persistence.parmas.fun.TarmRegistroArmas;
|
|
import com.fp.persistence.parmas.param.TarmTipoArmaExplosivo;
|
|
import com.fp.persistence.parmas.soli.TarmArmas;
|
|
import com.fp.persistence.pcustomer.gene.TcustPersonDetail;
|
|
import com.fp.persistence.pgeneral.gene.TgeneCatalogDetail;
|
|
import com.fp.persistence.pgeneral.gene.TgeneParameters;
|
|
|
|
/**
|
|
* Controlador principal de armas
|
|
* @author dcruz
|
|
*
|
|
*/
|
|
@SuppressWarnings("serial")
|
|
@ManagedBean
|
|
@ViewScoped
|
|
public class ArmasBloqueoController extends AbstractController<TarmArmas> {
|
|
|
|
@ManagedProperty(value = "#{tiposArmasExplosivosController}")
|
|
private TiposArmasExplosivosController tiposArmasExplosivosController;
|
|
|
|
/**
|
|
* Lista de tipos de identificación
|
|
*/
|
|
private List<TgeneCatalogDetail> ltipoidentificacion;
|
|
/**
|
|
* Listado de estados del arma
|
|
*/
|
|
private List<TgeneCatalogDetail> lestadoarma;
|
|
|
|
/**
|
|
* Tipo documento
|
|
*/
|
|
private String tipoDoc;
|
|
|
|
/**
|
|
* Número documento
|
|
*/
|
|
private String numDoc;
|
|
|
|
/**
|
|
* Nombre/razón social
|
|
*/
|
|
private String nombreRazon;
|
|
|
|
/**
|
|
* Longitud arma
|
|
*/
|
|
private String longitud;
|
|
/**
|
|
* Calibre arma
|
|
*/
|
|
private String calibre;
|
|
/**
|
|
* Clase arma
|
|
*/
|
|
private String clase;
|
|
/**
|
|
* Tipo de arma
|
|
*/
|
|
private String tipoarma;
|
|
/**
|
|
* unidad medida peso
|
|
*/
|
|
private String unidadmedidapeso;
|
|
|
|
/**
|
|
* Bloquea la unidad de cantidad
|
|
*/
|
|
private boolean bloquearUnidadCantidad = Boolean.TRUE;
|
|
|
|
/**
|
|
* Bloquea la unidad de peso
|
|
*/
|
|
private boolean bloquearUnidadPeso = Boolean.TRUE;
|
|
/**
|
|
* Contiene la fecha actual del sistema
|
|
*/
|
|
private Date fechaActual;
|
|
/**
|
|
* codigo del ruc
|
|
*/
|
|
private String codigoRuc;
|
|
/**
|
|
* codigo del ruc
|
|
*/
|
|
private String codigoCedula;
|
|
|
|
private String razonSocial;
|
|
|
|
private String numeroDocumento;
|
|
|
|
private String filtroPersona;
|
|
|
|
public ArmasBloqueoController() throws Exception {
|
|
super(TarmArmas.class);
|
|
}
|
|
|
|
/**
|
|
* Método que se ejecuta después del constructor
|
|
*/
|
|
@PostConstruct
|
|
private void postconstruct() {
|
|
this.init();
|
|
super.startQuery();
|
|
}
|
|
|
|
/**
|
|
* Inicializa valores del controlador
|
|
*/
|
|
private void init() {
|
|
try {
|
|
fechaActual = new Date();
|
|
recperpage = 15; // Cambiar al # reg a mirar.
|
|
lrecord = new ArrayList<>();
|
|
beanalias = "ARMAS";
|
|
ltipoidentificacion = CatalogDetailController.find("IDENTIFICATION");
|
|
codigoRuc=codigos("CODIGO.RUC");
|
|
codigoCedula=codigos("CODIGO.CEDULA");
|
|
filtroPersona = "";
|
|
//userDetail=(TsafeUserDetail)FacesContext.getCurrentInstance().getExternalContext().getSessionMap().get("TSAFEUSERDETAIL");
|
|
} catch (Exception e) {
|
|
MessageHelper.setMessageError(e);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@SuppressWarnings("unchecked")
|
|
@Override
|
|
protected void querydatabase() {
|
|
try {
|
|
DtoQuery dto = this.getDtoQuery();
|
|
String sqlFiltroPersona = "";
|
|
if(this.getMfilelds().get("personcode") != null){
|
|
sqlFiltroPersona = " t.cregistro in (SELECT c.pk FROM TarmRegistroArmas c WHERE c.personcode="+this.getMfilelds().get("personcode")+")";
|
|
}
|
|
|
|
dto.setOrderby("pk");
|
|
|
|
//estados del armas
|
|
|
|
String sqlActual = "";
|
|
if(this.getMfilelds().get("personcode")==null){
|
|
sqlActual = " t.fecharegistro=(select max(ta.fecharegistro) from TarmArmas ta where t.codigoarma=ta.codigoarma) "
|
|
+ " and t.estado !='DEST' and t.estado!='VEND' and t.estado!='MING' and t.estado!='DUPL' and t.estado!='CUSTEM'"
|
|
+ " and (t.peso>0 or t.cantidad>0)";//distintas de destruidas y cambio de propietario and t.cregistro=ta.cregistro para el manejo de los explosivos
|
|
}else{
|
|
sqlActual = " t.fecharegistro=(select max(ta.fecharegistro) from TarmArmas ta where t.codigoarma=ta.codigoarma and t.cregistro=ta.cregistro) "
|
|
+ " and t.estado !='DEST' and t.estado!='VEND' and t.estado!='MING' and t.estado!='DUPL' and t.estado!='CUSTEM'"
|
|
+ " and (t.peso>0 or t.cantidad>0)";//distintas de destruidas y cambio de propietario and t.cregistro=ta.cregistro para el manejo de los explosivos
|
|
}
|
|
|
|
sqlActual=sqlActual+ filtroPersona;
|
|
|
|
String sqlFinal = obtenerFiltroBusquedaGeneral(sqlFiltroPersona,sqlActual);
|
|
Filter filtroFinal = new Filter();
|
|
sqlFinal= sqlFinal+ " and t.estadoventa is null ";
|
|
filtroFinal.setSql(sqlFinal);
|
|
dto.addFiltro(filtroFinal);
|
|
HashMap<String, DtoQuery> mtables = new HashMap<String, DtoQuery>();
|
|
mtables.put(this.beanalias, dto); // permite adicionar mas de una tabla.
|
|
|
|
Request request = this.callerhelper.getRequest();
|
|
request.setQueryTables(mtables);
|
|
request.put("queryalias", "ARMASCOMPLETE");
|
|
|
|
Response resp = this.callerhelper.executeQuery(request);
|
|
|
|
if (resp.getResponseCode().compareTo(Response.RESPONSE_OK) != 0) {
|
|
this.lrecord = new ArrayList<TarmArmas>();
|
|
MessageHelper.setMessageError(resp);
|
|
} else {
|
|
this.lrecord = (List<TarmArmas>) resp.get(this.beanalias);
|
|
if(!lrecord.isEmpty()){
|
|
record=lrecord.get(0);
|
|
}
|
|
super.postQuery(this.lrecord);
|
|
}
|
|
|
|
} catch (Throwable e) {
|
|
MessageHelper.setMessageError(e);
|
|
}
|
|
}
|
|
|
|
private String obtenerFiltroBusquedaGeneral(String... sqlFiltros ){
|
|
StringBuffer sqlFinal = new StringBuffer();
|
|
for (int i = 0; i < sqlFiltros.length ; i++) {
|
|
if(sqlFinal.length() > 0 && !StringUtils.endsWith(StringUtils.trim(sqlFinal.toString()), "AND")){
|
|
sqlFinal.append( " AND ");
|
|
}
|
|
sqlFinal.append(sqlFiltros[i]);
|
|
}
|
|
return sqlFinal.toString();
|
|
}
|
|
|
|
|
|
@Override
|
|
public void next() throws Exception {
|
|
// TODO Auto-generated method stub
|
|
super.next();
|
|
}
|
|
|
|
|
|
/**
|
|
* Retorna un {@link DtoQuery} con los atributos a presentarse
|
|
* @return
|
|
* @throws Exception
|
|
*/
|
|
private DtoQuery getDtoQuery() throws Exception{
|
|
DtoQuery dto = super.getDtoQuery(true);
|
|
SubQuery subqueryMarca= new SubQuery("TgeneCatalogDetail","description","marca","i.pk.catalog=t.marca and i.pk.catalogcode=t.marcacodigo");
|
|
dto.addSubQuery(subqueryMarca);
|
|
SubQuery subqueryColor= new SubQuery("TgeneCatalogDetail","description","color","i.pk.catalog=t.color and i.pk.catalogcode=t.colorcodigo");
|
|
dto.addSubQuery(subqueryColor);
|
|
SubQuery subqueryTipoFab= new SubQuery("TgeneCatalogDetail","description","tipofabricacion","i.pk.catalog=t.tipofabricacion and i.pk.catalogcode='TIPOFABRICACION'");
|
|
dto.addSubQuery(subqueryTipoFab);
|
|
SubQuery subqueryEstado= new SubQuery("TgeneCatalogDetail","description","estado","i.pk.catalog=t.estado and i.pk.catalogcode=t.estadocodigo");
|
|
dto.addSubQuery(subqueryEstado);
|
|
SubQuery subqueryClase= new SubQuery("TarmTipoArmaExplosivo","clase","cclase","i.pk=t.ctipoarmaexplosivo");
|
|
dto.addSubQuery(subqueryClase);
|
|
SubQuery subqueryClaseCodigo= new SubQuery("TarmTipoArmaExplosivo","clasecodigo","cclasecodigo","i.pk=t.ctipoarmaexplosivo");
|
|
dto.addSubQuery(subqueryClaseCodigo);
|
|
SubQuery subqueryLongitud= new SubQuery("TarmTipoArmaExplosivo","longitud","clongitud","i.pk=t.ctipoarmaexplosivo");
|
|
dto.addSubQuery(subqueryLongitud);
|
|
SubQuery subqueryLongitudCodigo= new SubQuery("TarmTipoArmaExplosivo","longitudcodigo","clongitudcodigo","i.pk=t.ctipoarmaexplosivo");
|
|
dto.addSubQuery(subqueryLongitudCodigo);
|
|
SubQuery subqueryCalibre= new SubQuery("TarmTipoArmaExplosivo","calibre","ccalibre","i.pk=t.ctipoarmaexplosivo");
|
|
dto.addSubQuery(subqueryCalibre);
|
|
SubQuery subqueryCalibreCodigo= new SubQuery("TarmTipoArmaExplosivo","calibrecodigo","ccalibrecodigo","i.pk=t.ctipoarmaexplosivo");
|
|
dto.addSubQuery(subqueryCalibreCodigo);
|
|
SubQuery subqueryTipoArma= new SubQuery("TarmTipoArmaExplosivo","tipoarmaexplosivo","ctipoarmaexplosivo","i.pk=t.ctipoarmaexplosivo");
|
|
dto.addSubQuery(subqueryTipoArma);
|
|
SubQuery subqueryTipoArmaCodigo= new SubQuery("TarmTipoArmaExplosivo","tipoarmaexplosivocodigo","ctipoarmaexplosivocodigo","i.pk=t.ctipoarmaexplosivo");
|
|
dto.addSubQuery(subqueryTipoArmaCodigo);
|
|
SubQuery subqueryUnidad= new SubQuery("TarmTipoArmaExplosivo","unidadmedidapeso","cunidadmedidapeso","i.pk=t.ctipoarmaexplosivo");
|
|
dto.addSubQuery(subqueryUnidad);
|
|
SubQuery subqueryUnidadTipo= new SubQuery("TgeneCatalogDetail","description","unidadmedidadesc","i.pk.catalog= (select o.unidadmedidapeso from TarmTipoArmaExplosivo o where o.pk=t.ctipoarmaexplosivo) and "
|
|
+ " i.pk.catalogcode=(select o.unidadmedidapesocodigo from TarmTipoArmaExplosivo o where o.pk=t.ctipoarmaexplosivo)");
|
|
dto.addSubQuery(subqueryUnidadTipo);
|
|
SubQuery subqueryUnidadCodigo= new SubQuery("TarmTipoArmaExplosivo","unidadmedidapesocodigo","cunidadmedidapesocodigo","i.pk=t.ctipoarmaexplosivo");
|
|
dto.addSubQuery(subqueryUnidadCodigo);
|
|
SubQuery subqueryUnidadMedida= new SubQuery("TgeneCatalogDetail","description","unidadmedida","i.pk.catalog=t.unidadmedidacantidad and i.pk.catalogcode=t.unidadmedidacantidadcodigo");
|
|
dto.addSubQuery(subqueryUnidadMedida);
|
|
SubQuery subquerycpersoncode= new SubQuery("TarmRegistroArmas","personcode","personcode","i.pk=t.cregistro");
|
|
dto.addSubQuery(subquerycpersoncode);
|
|
SubQuery subqueryTipo= new SubQuery("TgeneCatalogDetail","description","tipo","i.pk.catalog= (select o.tipoarmaexplosivo from TarmTipoArmaExplosivo o where o.pk=t.ctipoarmaexplosivo) and "
|
|
+ " i.pk.catalogcode=(select o.tipoarmaexplosivocodigo from TarmTipoArmaExplosivo o where o.pk=t.ctipoarmaexplosivo)");
|
|
dto.addSubQuery(subqueryTipo);
|
|
SubQuery subqueryTipoArmaExplosivo= new SubQuery("TgeneCatalogDetail","description","tipoarmaexplosivo","i.pk.catalog= (select o.tipoarmaexplosivo from TarmTipoArmaExplosivo o where o.pk=t.ctipoarmaexplosivo) and "
|
|
+ " i.pk.catalogcode=(select o.tipoarmaexplosivocodigo from TarmTipoArmaExplosivo o where o.pk=t.ctipoarmaexplosivo)");
|
|
dto.addSubQuery(subqueryTipoArmaExplosivo);
|
|
SubQuery subqueryClasecatalogo= new SubQuery("TgeneCatalogDetail","description","clase","i.pk.catalog= (select o.clase from TarmTipoArmaExplosivo o where o.pk=t.ctipoarmaexplosivo) and "
|
|
+ " i.pk.catalogcode=(select o.clasecodigo from TarmTipoArmaExplosivo o where o.pk=t.ctipoarmaexplosivo)");
|
|
dto.addSubQuery(subqueryClasecatalogo);
|
|
|
|
return dto;
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
public void save() {
|
|
try {
|
|
DtoSave dtosave = super.getDtoSave();
|
|
dtosave.setReturnpk(Boolean.TRUE); // Para que el core devuelva el pk de los registros nuevos.
|
|
HashMap<String, DtoSave> msave = new HashMap<String, DtoSave>();
|
|
msave.put(beanalias, dtosave);
|
|
|
|
Request request = callerhelper.getRequest();
|
|
request.setSaveTables(msave);
|
|
Response resp = callerhelper.executeSave(request);
|
|
if (resp.getResponseCode().compareTo(Response.RESPONSE_OK) == 0) {
|
|
this.postCommit(resp);
|
|
MessageHelper.setMessageInfo(resp);
|
|
} else {
|
|
MessageHelper.setMessageError(resp);
|
|
}
|
|
} catch (Throwable e) {
|
|
MessageHelper.setMessageError(e);
|
|
}
|
|
querydatabase();
|
|
}
|
|
|
|
@Override
|
|
public void update() throws Exception {
|
|
TgeneCatalogDetail estado = CatalogDetailController.findxCodigoCodcatalogo(record.getEstado(), record.getEstadocodigo());
|
|
record.getModifiedData().put("estado", estado.getDescription());
|
|
super.update();
|
|
}
|
|
|
|
/*
|
|
* Metodo que retorna la extencion del documento que se desea subir al alfresco
|
|
*/
|
|
public String getExtension(String filename) {
|
|
int index = filename.lastIndexOf('.');
|
|
if (index == -1) {
|
|
return "";
|
|
} else {
|
|
return filename.substring(index + 1);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Retorna la ruta base donde se almacenara dicho archivo
|
|
*
|
|
* @return
|
|
*/
|
|
public String getRutaDocumentoSolBase(String carpeta) {
|
|
Calendar calendar = Calendar.getInstance();
|
|
calendar.setTime(new Date());
|
|
StringBuilder ruta = new StringBuilder("cm:Registro");
|
|
ruta = ruta.append("/cm:"+carpeta);
|
|
ruta = ruta.append("/cm:A-").append(calendar.get(Calendar.YEAR));
|
|
ruta = ruta.append("/cm:M-").append((calendar.get(Calendar.MONTH)+1) <= 9 ? "0" + (calendar.get(Calendar.MONTH) + 1) : (calendar.get(Calendar.MONTH)+1));
|
|
ruta = ruta.append("/cm:D-").append(calendar.get(Calendar.DAY_OF_WEEK));
|
|
return ruta.toString();
|
|
}
|
|
public void updateAutorizacion()throws Exception {
|
|
super.update();
|
|
}
|
|
|
|
/**
|
|
* Método que se ejecuta al carga edición
|
|
* @throws Exception
|
|
*/
|
|
public void loadEdit() throws Exception {
|
|
if(record.getCountrycode() == null){
|
|
record.setCountrycode("EC");
|
|
}
|
|
if(record.getCtipoarmaexplosivo()==null){
|
|
MessageHelper.setMessageError("NO ESTA ASOCIADO A UN TIPO DE ARMA EXPLOSIVO");
|
|
return;
|
|
}
|
|
TarmRegistroArmas registroArmas=RegistroArmController.findByCodigo( record.getCregistro().toString());
|
|
TcustPersonDetail tcustPersonDetail = PersonDetailController.find(registroArmas.getPersoncode().toString());
|
|
tipoDoc = tcustPersonDetail.getIdentificationcatalog();
|
|
numDoc = tcustPersonDetail.getIdentification();
|
|
nombreRazon = tcustPersonDetail.getName();
|
|
//
|
|
lestadoarma= new ArrayList<>();
|
|
String catalogoabre=record.getEstado()!=null && record.getEstado().equals("BLOQ")?"REG":"BLOQ";
|
|
TgeneCatalogDetail catalogo=CatalogDetailController.findCatalogo("ESTADOARMA",catalogoabre);
|
|
lestadoarma.add(catalogo);
|
|
}
|
|
|
|
|
|
/**
|
|
* Recorta el nombre del archivo a cargarse
|
|
* @param nombre
|
|
* @return nombre recortado
|
|
*/
|
|
public String recorteNombre(String nombre){
|
|
String fielname=nombre;
|
|
if(fielname.length()>30){
|
|
fielname=fielname.substring(0,30)+extencionArchivo(nombre);
|
|
}
|
|
return fielname;
|
|
}
|
|
/**
|
|
* Obtiene la extencion del archivo a cargar
|
|
* @param nombre
|
|
* @return
|
|
*/
|
|
private String extencionArchivo(String nombre){
|
|
int pos=nombre.lastIndexOf('.');
|
|
nombre=nombre.substring(pos);
|
|
return nombre;
|
|
}
|
|
|
|
@Override
|
|
public void create() throws Exception {
|
|
super.create();
|
|
this.tipoDoc = null;
|
|
this.numDoc = null;
|
|
this.nombreRazon = null;
|
|
this.record.setCountrycode("EC");
|
|
// this.record.setEstado("REG");
|
|
this.record.setEstado("PREG");
|
|
this.record.setEstadocodigo("ESTADOARMA");
|
|
this.record.setMarcacodigo("MARCA");
|
|
this.record.setGeneracertificado("NO");
|
|
}
|
|
|
|
public void update(TarmArmas bean) throws Exception {
|
|
record=bean;
|
|
updateAutorizacion();
|
|
}
|
|
|
|
public void validacionDocumento(String numeroDocumento, String tipoDocumento){
|
|
if(numeroDocumento==null || tipoDocumento==null){
|
|
MessageHelper.setMessageError(MsgControlArmas.getProperty("mg_error_seleccioneeltipodedocumentooingreselacedula"));
|
|
return;
|
|
}
|
|
TcustPersonDetail tcustPersonDetail=null;
|
|
if(tipoDocumento.equals(codigoCedula)){
|
|
//----------validamos si es valida la CEDULA
|
|
if(!ValidateIdentification.cedula(numeroDocumento)){
|
|
MessageHelper.setMessageError(MsgControlArmas.getProperty("msg_error_nodocumentoinvalido"));
|
|
return;
|
|
}
|
|
//envia a buscar en MAIA
|
|
tcustPersonDetail=buscarPersonaMaia(numeroDocumento,tipoDocumento);
|
|
}else if(tipoDocumento.equals(codigoRuc)){
|
|
//----------validamos si es valida el RUC
|
|
if(!ValidateIdentification.ruc(numeroDocumento)){
|
|
MessageHelper.setMessageError(MsgControlArmas.getProperty("msg_error_nodocumentoinvalido"));
|
|
return;
|
|
}
|
|
//envia a buscar en maia
|
|
tcustPersonDetail=buscarPersonaMaia(numeroDocumento,tipoDocumento);
|
|
}else{
|
|
//----------si es PASAPORTE
|
|
tcustPersonDetail=buscarPersonaMaia(numeroDocumento,tipoDocumento);
|
|
}
|
|
if(tcustPersonDetail==null){
|
|
nombreRazon=null;
|
|
numDoc=null;
|
|
MessageHelper.setMessageError("La datos de la persona ingresada no existen, por favor crear primero la persona");
|
|
return;
|
|
}else{
|
|
nombreRazon=tcustPersonDetail.getName();
|
|
}
|
|
}
|
|
|
|
/** Método para validar si la persona existe en la BD de Maia
|
|
* @param numeroDocumento
|
|
* @param tipoDocumento
|
|
* @return TcustPersonDetail
|
|
*/
|
|
public TcustPersonDetail buscarPersonaMaia(String numeroDocumento, String tipoDocumento){
|
|
return PersonDetailController.findxidentification(numeroDocumento,tipoDocumento);
|
|
}
|
|
|
|
|
|
/**
|
|
* Busca un arma por código
|
|
* @param armaCode
|
|
* @return
|
|
*/
|
|
public static TarmArmas findXCodigo(String armaCode) {
|
|
try {
|
|
|
|
ArmasBloqueoController cc = new ArmasBloqueoController();
|
|
cc.init();
|
|
cc.recperpage = 5000;
|
|
cc.addFilter("pk", armaCode);
|
|
//cc.addFilter("REG", "ESTADOARMA");
|
|
cc.querydatabase();
|
|
|
|
if ((cc.lrecord != null) && !cc.lrecord.isEmpty()) {
|
|
return cc.lrecord.get(0);
|
|
}
|
|
return null;
|
|
} catch (Throwable e) {
|
|
MessageHelper.setMessageError(e);
|
|
return null;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
*
|
|
*
|
|
* @param personCode
|
|
* @param estados estados del arma separados por coma
|
|
* @param tipoFab tipos de fabricacion del arma separados por coma
|
|
* @return Una lista de Armas encontradas
|
|
*/
|
|
public List<TarmArmas> findxPersona(Long personCode, String estados, String tipoFab, String clase, String fechaCaducidad) {
|
|
List<TarmArmas> armasLista = null;
|
|
try {
|
|
armasLista = new ArrayList<TarmArmas>();
|
|
ArmasBloqueoController armas = new ArmasBloqueoController();
|
|
armas.init();
|
|
armas.recperpage = 4000;
|
|
armas.addField("personcode", personCode);
|
|
if(this.getMfilelds().get("sancion") != null){
|
|
armas.addField("sancion", this.getMfilelds().get("sancion"));
|
|
}
|
|
if(this.getMfilelds().get("TRAMITE") != null){
|
|
armas.addField("TRAMITE", this.getMfilelds().get("TRAMITE"));
|
|
}
|
|
if(estados == null){
|
|
armas.addFilter("estado", "REG");
|
|
} else{
|
|
armas.addField("ESTADOS", estados);
|
|
}
|
|
if(tipoFab != null && tipoFab .trim().length()>0){
|
|
armas.addField("TIPOFABRICACION", tipoFab);
|
|
}
|
|
if(clase != null && clase .trim().length()>0){
|
|
armas.addField("CLASEARMAS", clase);
|
|
}
|
|
// if(fechaCaducidad != null && fechaCaducidad .trim().length()>0){
|
|
// armas.addField("FECHACADUCIDADARM", fechaCaducidad);
|
|
// }
|
|
armas.query();
|
|
if(armas.getLrecord() != null && !armas.getLrecord().isEmpty()){
|
|
armasLista.addAll(armas.getLrecord());
|
|
}
|
|
|
|
return armasLista;
|
|
} catch (Throwable e) {
|
|
MessageHelper.setMessageError(e);
|
|
return armasLista;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
* Lista de Armas por Registro
|
|
**/
|
|
public static List<TarmArmas> findxRegistro(String registrocode) {
|
|
try {
|
|
ArmasBloqueoController cc = new ArmasBloqueoController();
|
|
cc.init();
|
|
cc.recperpage = 5000;
|
|
cc.addFilter("cregistro", registrocode);
|
|
|
|
cc.querydatabase();
|
|
|
|
if ((cc.lrecord != null) && !cc.lrecord.isEmpty()) {
|
|
for(TarmArmas item : cc.lrecord){
|
|
TarmTipoArmaExplosivo tarmTipoArmaExplosivo = TiposArmasExplosivosController.findarma(item.getCtipoarmaexplosivo());
|
|
item.modifiedData().put("clase",CatalogDetailController.findxCodigoCodcatalogo( tarmTipoArmaExplosivo.getClase(), tarmTipoArmaExplosivo.getClasecodigo()).getDescription());
|
|
if(tarmTipoArmaExplosivo.getLongitud()!=null && tarmTipoArmaExplosivo.getLongitudcodigo()!=null){
|
|
item.modifiedData().put("longitud",CatalogDetailController.findxCodigoCodcatalogo( tarmTipoArmaExplosivo.getLongitud(), tarmTipoArmaExplosivo.getLongitudcodigo()).getDescription());
|
|
}
|
|
item.modifiedData().put("tipo",CatalogDetailController.findxCodigoCodcatalogo( tarmTipoArmaExplosivo.getTipoarmaexplosivo(), tarmTipoArmaExplosivo.getTipoarmaexplosivocodigo()).getDescription());
|
|
if(tarmTipoArmaExplosivo.getCalibre()!=null && tarmTipoArmaExplosivo.getCalibrecodigo()!=null){
|
|
item.modifiedData().put("calibre",CatalogDetailController.findxCodigoCodcatalogo( tarmTipoArmaExplosivo.getCalibre(), tarmTipoArmaExplosivo.getCalibrecodigo()).getDescription());
|
|
}
|
|
item.modifiedData().put("unidadMedidaCantidad",CatalogDetailController.findxCodigoCodcatalogo(tarmTipoArmaExplosivo.getUnidadmedidapeso(), tarmTipoArmaExplosivo.getUnidadmedidapesocodigo()).getDescription());
|
|
}
|
|
|
|
return cc.lrecord;
|
|
}
|
|
return null;
|
|
} catch (Throwable e) {
|
|
MessageHelper.setMessageError(e);
|
|
return null;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Abre el LOV de la clase del arma
|
|
*/
|
|
public void openLovClase() {
|
|
Map<String, List<String>> params = new HashMap<String, List<String>>();
|
|
ClaseLovController.openLov(params);
|
|
}
|
|
|
|
/**
|
|
* Regresa del LOV de armas
|
|
* @param event
|
|
*/
|
|
public void onReturnClase(SelectEvent event) {
|
|
TgeneCatalogDetail clase = (TgeneCatalogDetail) event.getObject();
|
|
this.record.getModifiedData().put("clase", clase.getDescription());
|
|
this.clase = clase.getPk().getCatalog();
|
|
this.verificarClaseArma();
|
|
}
|
|
|
|
|
|
/**
|
|
* Método en el cual se determina si se bloquea unidad o cantidad al momento de cargar los datos del arma
|
|
* @param clase
|
|
*/
|
|
private void verificarClaseArma(){
|
|
if(this.clase==null){
|
|
this.bloquearUnidadPeso = Boolean.TRUE;
|
|
this.bloquearUnidadCantidad = Boolean.TRUE;
|
|
return;
|
|
}
|
|
|
|
if( this.clase.equals("0010000003") || this.clase.equals("0010000005") || this.clase.equals("0010000007") || this.clase.equals("0010000006")){
|
|
this.bloquearUnidadPeso = Boolean.FALSE;
|
|
} else{
|
|
this.bloquearUnidadPeso = Boolean.TRUE;
|
|
}
|
|
if(this.clase.equals("0010000001") || this.clase.equals("0010000002") || this.clase.equals("0010000004")){
|
|
this.bloquearUnidadCantidad = Boolean.FALSE;
|
|
} else{
|
|
this.bloquearUnidadCantidad = Boolean.TRUE;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Abre el LOV de la longitud del arma
|
|
*/
|
|
public void openLovLongitud() {
|
|
Map<String, List<String>> params = new HashMap<String, List<String>>();
|
|
LongitudLovController.openLov(params);
|
|
}
|
|
|
|
/**
|
|
* Regresa del LOV de longitud
|
|
* @param event
|
|
*/
|
|
public void onReturnLongitud(SelectEvent event) {
|
|
TgeneCatalogDetail longitud = (TgeneCatalogDetail) event.getObject();
|
|
this.record.getModifiedData().put("longitud", longitud.getDescription());
|
|
this.longitud = longitud.getPk().getCatalog();
|
|
}
|
|
|
|
/**
|
|
* Abre el LOV del tipo de arma
|
|
*/
|
|
public void openLovTipoArma() {
|
|
Map<String, List<String>> params = new HashMap<String, List<String>>();
|
|
TipoArmaExpLovController.openLov(params);
|
|
}
|
|
|
|
/**
|
|
* Regresa del LOV de tipo de arma
|
|
* @param event
|
|
*/
|
|
public void onReturnTipoArma(SelectEvent event) {
|
|
TgeneCatalogDetail tipoArma = (TgeneCatalogDetail) event.getObject();
|
|
this.record.getModifiedData().put("tipoarmaexplosivo", tipoArma.getDescription());
|
|
this.tipoarma = tipoArma.getPk().getCatalog();
|
|
}
|
|
|
|
/**
|
|
* Abre el LOV de Calibre
|
|
*/
|
|
public void openLovCalibre() {
|
|
Map<String, List<String>> params = new HashMap<String, List<String>>();
|
|
CalibreLovController.openLov(params);
|
|
}
|
|
|
|
/**
|
|
* Regresa del LOV del calibre
|
|
* @param event
|
|
*/
|
|
public void onReturnCalibre(SelectEvent event) {
|
|
TgeneCatalogDetail calibre = (TgeneCatalogDetail) event.getObject();
|
|
this.record.getModifiedData().put("calibre", calibre.getDescription());
|
|
this.calibre = calibre.getPk().getCatalog();
|
|
}
|
|
|
|
/**
|
|
* Abre el LOV cambio de usuario
|
|
*/
|
|
public void openLovCambioUsuario() {
|
|
Map<String, List<String>> params = new HashMap<>();
|
|
PersonLovController.openLov(params);
|
|
}
|
|
|
|
|
|
/**
|
|
* Seleccionado todos los registros de la tabla
|
|
*/
|
|
public void seleccionarTodos(AjaxBehaviorEvent event) {
|
|
try {
|
|
Boolean valorColocar = Boolean.FALSE;
|
|
if(Boolean.valueOf(event.getComponent().getAttributes().get("value") != null ? event.getComponent().getAttributes().get("value").toString() : "false")){
|
|
valorColocar = Boolean.TRUE;
|
|
}
|
|
for (TarmArmas guardias : lrecord) {
|
|
guardias.getModifiedData().put("seleccionado", valorColocar);
|
|
}
|
|
} catch (Throwable e) {
|
|
MessageHelper.setMessageError(e);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
* Metodo para obtener los codigos
|
|
*/
|
|
private static String codigos(String parametro){
|
|
TgeneParameters tgeneParameters= ParametersController.find(parametro, "1");
|
|
return tgeneParameters.getTextvalue();
|
|
}
|
|
|
|
|
|
public void actualizar(TarmArmas arma) throws Exception{
|
|
record=arma;
|
|
super.update();
|
|
}
|
|
|
|
public TiposArmasExplosivosController getTiposArmasExplosivosController() {
|
|
return tiposArmasExplosivosController;
|
|
}
|
|
|
|
|
|
public void setTiposArmasExplosivosController(
|
|
TiposArmasExplosivosController tiposArmasExplosivosController) {
|
|
this.tiposArmasExplosivosController = tiposArmasExplosivosController;
|
|
}
|
|
|
|
|
|
public List<TgeneCatalogDetail> getLtipoidentificacion() {
|
|
return ltipoidentificacion;
|
|
}
|
|
|
|
|
|
public void setLtipoidentificacion(List<TgeneCatalogDetail> ltipoidentificacion) {
|
|
this.ltipoidentificacion = ltipoidentificacion;
|
|
}
|
|
|
|
|
|
public String getTipoDoc() {
|
|
return tipoDoc;
|
|
}
|
|
|
|
|
|
public void setTipoDoc(String tipoDoc) {
|
|
this.tipoDoc = tipoDoc;
|
|
}
|
|
|
|
|
|
public String getNumDoc() {
|
|
return numDoc;
|
|
}
|
|
|
|
|
|
public void setNumDoc(String numDoc) {
|
|
this.numDoc = numDoc;
|
|
}
|
|
|
|
|
|
public String getNombreRazon() {
|
|
return nombreRazon;
|
|
}
|
|
|
|
|
|
public void setNombreRazon(String nombreRazon) {
|
|
this.nombreRazon = nombreRazon;
|
|
}
|
|
|
|
|
|
public List<TgeneCatalogDetail> getLestadoarma() {
|
|
return lestadoarma;
|
|
}
|
|
|
|
|
|
public void setLestadoarma(List<TgeneCatalogDetail> lestadoarma) {
|
|
this.lestadoarma = lestadoarma;
|
|
}
|
|
|
|
|
|
public String getLongitud() {
|
|
return longitud;
|
|
}
|
|
|
|
|
|
public void setLongitud(String longitud) {
|
|
this.longitud = longitud;
|
|
}
|
|
|
|
|
|
public String getCalibre() {
|
|
return calibre;
|
|
}
|
|
|
|
|
|
public void setCalibre(String calibre) {
|
|
this.calibre = calibre;
|
|
}
|
|
|
|
|
|
public String getClase() {
|
|
return clase;
|
|
}
|
|
|
|
|
|
public void setClase(String clase) {
|
|
this.clase = clase;
|
|
}
|
|
|
|
|
|
public String getTipoarma() {
|
|
return tipoarma;
|
|
}
|
|
|
|
|
|
public void setTipoarma(String tipoarma) {
|
|
this.tipoarma = tipoarma;
|
|
}
|
|
|
|
|
|
public String getUnidadmedidapeso() {
|
|
return unidadmedidapeso;
|
|
}
|
|
|
|
|
|
public void setUnidadmedidapeso(String unidadmedidapeso) {
|
|
this.unidadmedidapeso = unidadmedidapeso;
|
|
}
|
|
|
|
public boolean isBloquearUnidadCantidad() {
|
|
return bloquearUnidadCantidad;
|
|
}
|
|
|
|
public void setBloquearUnidadCantidad(boolean bloquearUnidadCantidad) {
|
|
this.bloquearUnidadCantidad = bloquearUnidadCantidad;
|
|
}
|
|
|
|
public boolean isBloquearUnidadPeso() {
|
|
return bloquearUnidadPeso;
|
|
}
|
|
|
|
public void setBloquearUnidadPeso(boolean bloquearUnidadPeso) {
|
|
this.bloquearUnidadPeso = bloquearUnidadPeso;
|
|
}
|
|
|
|
public Date getFechaActual() {
|
|
return fechaActual;
|
|
}
|
|
|
|
public void setFechaActual(Date fechaActual) {
|
|
this.fechaActual = fechaActual;
|
|
}
|
|
|
|
public String getRazonSocial() {
|
|
return razonSocial;
|
|
}
|
|
|
|
public void setRazonSocial(String razonSocial) {
|
|
this.razonSocial = razonSocial;
|
|
}
|
|
|
|
public String getNumeroDocumento() {
|
|
return numeroDocumento;
|
|
}
|
|
|
|
public void setNumeroDocumento(String numeroDocumento) {
|
|
this.numeroDocumento = numeroDocumento;
|
|
}
|
|
|
|
public String getFiltroPersona() {
|
|
return filtroPersona;
|
|
}
|
|
|
|
public void setFiltroPersona(String filtroPersona) {
|
|
this.filtroPersona = filtroPersona;
|
|
}
|
|
|
|
|
|
/**
|
|
* Busca un arma por código
|
|
* @param armaCode
|
|
* @return
|
|
*/
|
|
public static TarmArmas findXCodigoArma(String armaCode) {
|
|
try {
|
|
ArmasBloqueoController cc = new ArmasBloqueoController();
|
|
cc.init();
|
|
cc.recperpage = 5000;
|
|
cc.addFilter("codigoarma", armaCode);
|
|
cc.querydatabase();
|
|
if ((cc.lrecord != null) && !cc.lrecord.isEmpty()) {
|
|
return cc.lrecord.get(0);
|
|
}
|
|
return null;
|
|
} catch (Throwable e) {
|
|
MessageHelper.setMessageError(e);
|
|
return null;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Abre el lov de persona
|
|
*/
|
|
public void openPersonLov() {
|
|
Map<String, List<String>> params = new HashMap<>();
|
|
PersonLovController.openLov(params);
|
|
}
|
|
/**
|
|
* Maneja la respuesta del Lov de Personas
|
|
*
|
|
* @param event
|
|
* @throws Exception
|
|
*/
|
|
public void onReturnPersonLov(SelectEvent event) throws Exception {
|
|
|
|
TcustPersonDetail personaDetailSelecionada = (TcustPersonDetail) event.getObject();
|
|
razonSocial = personaDetailSelecionada.getName();
|
|
numeroDocumento = personaDetailSelecionada.getIdentification();
|
|
filtroPersona = " and t.cregistro in (select i.pk from TarmRegistroArmas i where i.personcode ="
|
|
+ personaDetailSelecionada.getPk().getPersoncode() + ")";
|
|
|
|
querydatabase();
|
|
}
|
|
|
|
}
|