2315 lines
89 KiB
Plaintext
Executable File
2315 lines
89 KiB
Plaintext
Executable File
package com.fp.frontend.controller.armas.solicitud;
|
|
|
|
import java.io.InputStream;
|
|
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 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.context.FacesContext;
|
|
import javax.faces.event.AjaxBehaviorEvent;
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.primefaces.event.FileUploadEvent;
|
|
import org.primefaces.event.SelectEvent;
|
|
import org.primefaces.model.UploadedFile;
|
|
|
|
import com.fp.common.helper.Constant;
|
|
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.ReportController;
|
|
import com.fp.frontend.controller.alfresco.AlfrescoController;
|
|
import com.fp.frontend.controller.armas.funcionalidad.RegistroArmController;
|
|
import com.fp.frontend.controller.armas.lov.ArmaExplosivoLovController;
|
|
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.CantonController;
|
|
import com.fp.frontend.controller.pgeneral.gene.CatalogDetailController;
|
|
import com.fp.frontend.controller.pgeneral.gene.CityController;
|
|
import com.fp.frontend.controller.pgeneral.gene.CountryController;
|
|
import com.fp.frontend.controller.pgeneral.gene.ParametersController;
|
|
import com.fp.frontend.controller.pgeneral.gene.ParroquiaController;
|
|
import com.fp.frontend.controller.pgeneral.gene.ProvinceController;
|
|
import com.fp.frontend.helper.CallerHelper;
|
|
import com.fp.frontend.helper.MessageHelper;
|
|
import com.fp.frontend.utility.MsgControlArmas;
|
|
import com.fp.frontend.utility.Utilidades;
|
|
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.param.TarmTramite;
|
|
import com.fp.persistence.parmas.soli.TarmArmas;
|
|
import com.fp.persistence.pcustomer.gene.TcustPersonDetail;
|
|
import com.fp.persistence.pgeneral.gene.TgeneCanton;
|
|
import com.fp.persistence.pgeneral.gene.TgeneCatalogDetail;
|
|
import com.fp.persistence.pgeneral.gene.TgeneCity;
|
|
import com.fp.persistence.pgeneral.gene.TgeneCountry;
|
|
import com.fp.persistence.pgeneral.gene.TgeneParameters;
|
|
import com.fp.persistence.pgeneral.gene.TgeneParroquia;
|
|
import com.fp.persistence.pgeneral.gene.TgeneProvince;
|
|
import com.fp.persistence.pgeneral.safe.TsafeUserDetail;
|
|
|
|
/**
|
|
* Controlador principal de armas
|
|
* @author dcruz
|
|
*
|
|
*/
|
|
@SuppressWarnings("serial")
|
|
@ManagedBean
|
|
@ViewScoped
|
|
public class ArmasController extends AbstractController<TarmArmas> {
|
|
|
|
@ManagedProperty(value = "#{tiposArmasExplosivosController}")
|
|
private TiposArmasExplosivosController tiposArmasExplosivosController;
|
|
|
|
@ManagedProperty(value = "#{registroArmController}")
|
|
private RegistroArmController registroArmas;
|
|
|
|
/**
|
|
* Lista de tipos de identificación
|
|
*/
|
|
private List<TgeneCatalogDetail> ltipoidentificacion;
|
|
/**
|
|
* Listado de estados del arma
|
|
*/
|
|
private List<TgeneCatalogDetail> lestadoarma;
|
|
/**
|
|
* Listado de marcas
|
|
*/
|
|
private List<TgeneCatalogDetail> lmarca;
|
|
/**
|
|
* Listado de colores
|
|
*/
|
|
private List<TgeneCatalogDetail> lcolor;
|
|
/**
|
|
* Listado de tipos de fabricación
|
|
*/
|
|
private List<TgeneCatalogDetail> ltipofabricacion;
|
|
/**
|
|
* Listado de unidad de medida cantidad
|
|
*/
|
|
private List<TgeneCatalogDetail> lunidadmedidacantidad;
|
|
/**
|
|
* Listado de unidad medida peso
|
|
*/
|
|
private List<TgeneCatalogDetail> lunidadmedidapeso;
|
|
/**
|
|
* Listado de paises
|
|
*/
|
|
private List<TgeneCountry> lcountry;
|
|
/**
|
|
* Listado de provincias
|
|
*/
|
|
private List<TgeneProvince> lprovincias;
|
|
/**
|
|
* Listado de cantones
|
|
*/
|
|
private List<TgeneCanton> lcantones;
|
|
/**
|
|
* Listado de parroquias
|
|
*/
|
|
private List<TgeneParroquia> lparroquias;
|
|
/**
|
|
* Listado de ciudades
|
|
*/
|
|
private List<TgeneCity> lcities;
|
|
|
|
/**
|
|
* 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;
|
|
|
|
/**
|
|
* Bandera que indica que en realidad existe luego del ingreso de datos un tipo de arma explosivo válido
|
|
*/
|
|
private boolean existeTipoArmaExplosivo;
|
|
|
|
/**
|
|
* Bandera que escifica que se deba verificar que exista un arma explosivo válida
|
|
*/
|
|
private boolean verificaArmaExplosivo = Boolean.TRUE;
|
|
|
|
/**
|
|
* 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;
|
|
/**
|
|
* Contiene la referencia a nuevo propietario del arma
|
|
*/
|
|
private TcustPersonDetail nuevoPropietarioArma;
|
|
/**
|
|
* Tipo del arma explosivo
|
|
*/
|
|
private TarmTipoArmaExplosivo tipoArmaExplosivo ;
|
|
/**
|
|
* codigo del ruc
|
|
*/
|
|
private String codigoRuc;
|
|
/**
|
|
* codigo del ruc
|
|
*/
|
|
private String codigoCedula;
|
|
/**
|
|
* codigo del ruc
|
|
*/
|
|
private String codigoPasaporte;
|
|
|
|
|
|
private String razonSocial;
|
|
|
|
private String numeroDocumento;
|
|
|
|
private String filtroPersona;
|
|
|
|
private TsafeUserDetail userDetail;
|
|
/**
|
|
* Variable que nos permite cargar el documento al Alfresco
|
|
*/
|
|
private UploadedFile uploadedFile;
|
|
|
|
@ManagedProperty(value = "#{alfrescoController}")
|
|
private AlfrescoController alfrescoController;
|
|
|
|
@ManagedProperty(value = "#{reportController}")
|
|
private ReportController reportController;
|
|
|
|
public ArmasController() 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.
|
|
// record = new TarmArmas();
|
|
lrecord = new ArrayList<>();
|
|
beanalias = "ARMAS";
|
|
ltipoidentificacion = CatalogDetailController.find("IDENTIFICATION");
|
|
lestadoarma = CatalogDetailController.find("ESTADOARMA");
|
|
lmarca = CatalogDetailController.find("MARCA");
|
|
lcolor = CatalogDetailController.find("COLOR");
|
|
ltipofabricacion = CatalogDetailController.find("TIPOFABRICACION");
|
|
// lunidadmedidacantidad = CatalogDetailController.find("UCANTIDAD");
|
|
lunidadmedidapeso = CatalogDetailController.find("UNIDADMEDIDA");
|
|
lcountry = CountryController.find();
|
|
codigoRuc=codigos("CODIGO.RUC");
|
|
codigoCedula=codigos("CODIGO.CEDULA");
|
|
codigoPasaporte=codigos("CODIGO.PASAPORTE");
|
|
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 = "";
|
|
String sqlFiltroSancion = "";
|
|
String sqlFiltroEstados = "";
|
|
String sqlFiltroTipoFabricacion = "";
|
|
String sqlFiltroClaseArmas = "";
|
|
// String sqlFiltroFechaCaducidad = "";
|
|
String sqlFiltroValidacionArma = "";//si entre los estados existe renovacion entonces validamos que no pueda seleccionar las mismas armas
|
|
if(this.getMfilelds().get("personcode") != null){
|
|
sqlFiltroPersona = " t.cregistro in (SELECT c.pk FROM TarmRegistroArmas c WHERE c.personcode="+this.getMfilelds().get("personcode")+")";
|
|
}
|
|
//agregamos los filtros en base a la consideracion del field sancion, en caso de que lo sea buscamos los sancionados que hayan cumplido el tiempo de sancion
|
|
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
|
if(this.getMfilelds().containsKey("sancion") && this.getMfilelds().get("sancion").toString().equals(Constant.STR_Y)){
|
|
sqlFiltroSancion = " t.pk in (SELECT max(a.pk) FROM TarmArmas a WHERE a.codigoarma in (SELECT distinct(h.codigoarma) from TarmDocumentoHabilitante h WHERE h.pk in (SELECT d.cdocumento FROM TarmSancionDecomiso d WHERE d.personcode="+this.getMfilelds().get("personcode")+" AND d.fechafinal < TO_DATE('"+dateFormat.format(Calendar.getInstance().getTime())+"', 'YYYY-MM-DD'))) GROUP BY a.codigoarma)";
|
|
}
|
|
|
|
dto.setOrderby("pk");
|
|
if(this.getMfilelds().get("ESTADOS") != null){
|
|
String[] estados = this.getMfilelds().get("ESTADOS").toString().split(",");
|
|
StringBuffer sqlEstados = new StringBuffer(" t.estado IN (");
|
|
for (int i = 0; i < estados.length; i++) {
|
|
sqlEstados.append("'").append(estados[i]).append("'");
|
|
if(i < estados.length - 1){
|
|
sqlEstados.append(",");
|
|
}
|
|
}
|
|
sqlEstados.append(")");
|
|
sqlFiltroEstados = sqlEstados.toString();
|
|
}
|
|
|
|
if(this.getMfilelds().get("TIPOFABRICACION") != null){
|
|
String[] tipoFabricacion = this.getMfilelds().get("TIPOFABRICACION").toString().split(",");
|
|
StringBuffer sqlTipoFabricacion = new StringBuffer(" t.tipofabricacion IN (");
|
|
for (int i = 0; i < tipoFabricacion.length; i++) {
|
|
sqlTipoFabricacion.append("'").append(tipoFabricacion[i]).append("'");
|
|
if(i < tipoFabricacion.length - 1){
|
|
sqlTipoFabricacion.append(",");
|
|
}
|
|
}
|
|
sqlTipoFabricacion.append(")");
|
|
sqlFiltroTipoFabricacion = sqlTipoFabricacion.toString();
|
|
}
|
|
|
|
if(this.getMfilelds().get("TRAMITE") != null){
|
|
TarmTramite tarmTramite = (TarmTramite) this.getMfilelds().get("TRAMITE");
|
|
sqlFiltroValidacionArma = "t.pk not in (SELECT coalesce(max(a.pk),'-1') FROM TarmArmas a WHERE a.codigoarma in (SELECT distinct(h.codigoarma) from TarmDocumentoHabilitante h WHERE h.personcode="+this.getMfilelds().get("personcode")+" AND h.ctramite="+tarmTramite.getPk()+" AND h.estado = 'APR' AND trunc(h.fechaexpiracion) >= " + "TO_DATE('" +dateFormat.format(Calendar.getInstance().getTime())+ "','yyyy-MM-dd')) GROUP BY a.codigoarma)";
|
|
}
|
|
//estados del armas
|
|
if(this.getMfilelds().get("CLASEARMAS") != null){
|
|
String[] clasesarma = this.getMfilelds().get("CLASEARMAS").toString().split(",");
|
|
StringBuffer sqlclasesarmas = new StringBuffer(" t.ctipoarmaexplosivo IN (select o.pk from TarmTipoArmaExplosivo o where o.clase in(");
|
|
for (int i = 0; i < clasesarma.length; i++) {
|
|
sqlclasesarmas.append("'").append(clasesarma[i]).append("'");
|
|
if(i < clasesarma.length - 1){
|
|
sqlclasesarmas.append(",");
|
|
}
|
|
}
|
|
sqlclasesarmas.append(")) ");
|
|
sqlFiltroClaseArmas = sqlclasesarmas.toString();
|
|
}
|
|
|
|
// if(this.getMfilelds().get("FECHACADUCIDADARM") != null){
|
|
// sqlFiltroFechaCaducidad="t.fechacaducidad "+this.getMfilelds().get("FECHACADUCIDADARM");
|
|
// }
|
|
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, sqlFiltroEstados, sqlFiltroSancion, sqlFiltroValidacionArma,sqlFiltroClaseArmas,sqlFiltroFechaCaducidad, sqlActual);
|
|
String sqlFinal = obtenerFiltroBusquedaGeneral(sqlFiltroPersona, sqlFiltroEstados,sqlFiltroTipoFabricacion, sqlFiltroSancion, sqlFiltroValidacionArma,sqlFiltroClaseArmas,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();
|
|
}
|
|
|
|
@SuppressWarnings("unchecked")
|
|
public void querydatabaseSinFiltros() {
|
|
try {
|
|
DtoQuery dto = this.getDtoQuery();
|
|
|
|
HashMap<String, DtoQuery> mtables = new HashMap<String, DtoQuery>();
|
|
mtables.put(this.beanalias, dto); // permite adicionar mas de una tabla.
|
|
//se discrima las armas que sean distintas de destruidas y cambio de propietario
|
|
Filter filtro = new Filter();
|
|
String sql=" t.estado !='DEST' and t.estado !='CDP'";
|
|
filtro.setSql(sql);
|
|
dto.addFiltro(filtro);
|
|
|
|
Request request = this.callerhelper.getRequest();
|
|
request.setQueryTables(mtables);
|
|
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);
|
|
super.postQuery(this.lrecord);
|
|
}
|
|
} catch (Throwable e) {
|
|
MessageHelper.setMessageError(e);
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public void next() throws Exception {
|
|
// TODO Auto-generated method stub
|
|
super.next();
|
|
}
|
|
|
|
@SuppressWarnings("unchecked")
|
|
protected void querydatabasePorCodigo() {
|
|
try {
|
|
DtoQuery dto = super.getDtoQuery(true);
|
|
|
|
HashMap<String, DtoQuery> mtables = new HashMap<String, DtoQuery>();
|
|
mtables.put(this.beanalias, dto); // permite adicionar mas de una tabla.
|
|
|
|
//se discrima las armas que sean distintas de destruidas y cambio de propietario
|
|
Filter filtro = new Filter();
|
|
String sql=" t.estado !='DEST' and t.estado !='CDP'";
|
|
filtro.setSql(sql);
|
|
dto.addFiltro(filtro);
|
|
|
|
Request request = this.callerhelper.getRequest();
|
|
request.setQueryTables(mtables);
|
|
|
|
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);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 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;
|
|
}
|
|
|
|
@SuppressWarnings("unchecked")
|
|
protected void querydatabaseSimple() {
|
|
try {
|
|
DtoQuery dto = super.getDtoQuery(true);
|
|
|
|
HashMap<String, DtoQuery> mtables = new HashMap<String, DtoQuery>();
|
|
mtables.put(beanalias, dto); // permite adicionar mas de una tabla.
|
|
|
|
//se discrima las armas que sean distintas de destruidas y cambio de propietario
|
|
Filter filtro = new Filter();
|
|
String sql=" t.estado !='DEST' and t.estado !='CDP'";
|
|
filtro.setSql(sql);
|
|
dto.addFiltro(filtro);
|
|
|
|
Request request = callerhelper.getRequest();
|
|
request.setQueryTables(mtables);
|
|
|
|
Response resp = callerhelper.executeQuery(request);
|
|
|
|
if (resp.getResponseCode().compareTo(Response.RESPONSE_OK) != 0) {
|
|
lrecord = new ArrayList<TarmArmas>();
|
|
MessageHelper.setMessageError(resp);
|
|
} else {
|
|
lrecord = (List<TarmArmas>) resp.get(beanalias);
|
|
if(!lrecord.isEmpty()){
|
|
record=lrecord.get(0);
|
|
}
|
|
super.postQuery(lrecord);
|
|
}
|
|
} catch (Throwable e) {
|
|
MessageHelper.setMessageError(e);
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
public void save() {
|
|
try {
|
|
this.registroArmas.update();
|
|
DtoSave dtoSaveRegistro = registroArmas.getDtoSave();
|
|
dtoSaveRegistro.setIsForm(Boolean.TRUE);
|
|
dtoSaveRegistro.setReturnpk(Boolean.TRUE);
|
|
dtoSaveRegistro.setPosition(1);
|
|
DtoSave dtosave = super.getDtoSave();
|
|
dtosave.setReturnpk(Boolean.TRUE); // Para que el core devuelva el pk de los registros nuevos.
|
|
dtosave.setPosition(2);
|
|
HashMap<String, DtoSave> msave = new HashMap<String, DtoSave>();
|
|
msave.put(registroArmas.getBeanalias(), dtoSaveRegistro);
|
|
msave.put(beanalias, dtosave);
|
|
|
|
Request request = callerhelper.getRequest();
|
|
request.put("TIPODOC", tipoDoc);
|
|
request.put("NUMDOC", numDoc);
|
|
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();
|
|
}
|
|
|
|
public void saveFile() {
|
|
try {
|
|
DtoSave dtosave = super.getDtoSave();
|
|
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();
|
|
}
|
|
|
|
public void saveArmaSolicitud() {
|
|
try {
|
|
|
|
if(!isArmaDuplicada(record)){
|
|
|
|
record.getModifiedData().put("edit", "S");
|
|
|
|
this.registroArmas.update();
|
|
update();
|
|
if(!existeTipoArmaExplosivo){
|
|
return;
|
|
}
|
|
DtoSave dtosave = super.getDtoSave();
|
|
dtosave.setReturnpk(Boolean.TRUE); // Para que el core devuelva el pk de los registros nuevos.
|
|
dtosave.setPosition(2);
|
|
HashMap<String, DtoSave> msave = new HashMap<String, DtoSave>();
|
|
DtoSave dtoSaveRegistro = registroArmas.getDtoSave();
|
|
dtoSaveRegistro.setIsForm(Boolean.TRUE);
|
|
dtoSaveRegistro.setReturnpk(Boolean.TRUE);
|
|
dtoSaveRegistro.setPosition(1);
|
|
|
|
Request request = callerhelper.getRequest();
|
|
request.setTransactionModule("30");
|
|
request.setTransactionCode(15);
|
|
request.setTransactionVersion(1);
|
|
if(!verificaArmaExplosivo){
|
|
request.put("eseliminacion", Constant.STR_Y);
|
|
}else{
|
|
msave.put(registroArmas.getBeanalias(), dtoSaveRegistro);
|
|
}
|
|
msave.put(beanalias, dtosave); // adicionar metadata de mantenimiento para cada tabla.
|
|
|
|
request.put("TIPODOC", this.getMfilelds().get("tipodoc"));
|
|
request.put("NUMDOC", this.getMfilelds().get("numdoc"));
|
|
request.setSaveTables(msave);
|
|
Response resp = callerhelper.executeSave(request);
|
|
if (resp.getResponseCode().compareTo(Response.RESPONSE_OK) == 0) {
|
|
this.postCommit(resp);
|
|
this.registroArmas.postCommit(resp);
|
|
MessageHelper.setMessageInfo(resp);
|
|
} else {
|
|
MessageHelper.setMessageError(resp);
|
|
}
|
|
}else{
|
|
record= null;
|
|
MessageHelper.setMessageError(MsgControlArmas.getProperty("msg_armaDuplicada"));
|
|
}
|
|
|
|
|
|
} catch (Throwable e) {
|
|
MessageHelper.setMessageError(e);
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public void update() throws Exception {
|
|
TgeneCatalogDetail estado = CatalogDetailController.findxCodigoCodcatalogo(record.getEstado(), record.getEstadocodigo());
|
|
TgeneCatalogDetail marca = CatalogDetailController.findxCodigoCodcatalogo(record.getMarca(), record.getMarcacodigo());
|
|
record.getModifiedData().put("estado", estado.getDescription());
|
|
record.getModifiedData().put("marca", marca.getDescription());
|
|
for(TgeneCatalogDetail color:lcolor){
|
|
if(record.getColor()!=null && record.getColor().equals(color.getPk().getCatalog())){
|
|
record.getModifiedData().put("color", color.getDescription());
|
|
break;
|
|
}
|
|
}
|
|
if(verificaArmaExplosivo){
|
|
if(tipoArmaExplosivo == null){
|
|
MessageHelper.setMessageError(MsgControlArmas.getProperty("msg_error_seleccionClase"));
|
|
existeTipoArmaExplosivo = Boolean.FALSE;
|
|
return;
|
|
}else{
|
|
this.record.setCtipoarmaexplosivo(tipoArmaExplosivo.getPk());
|
|
existeTipoArmaExplosivo = Boolean.TRUE;
|
|
}
|
|
}
|
|
//valida si el estado es de perdida robo para obligar el adjuntar
|
|
if((record.getEstado()!=null && record.getEstado().equals("RPER")) ||
|
|
(record.getPk()==null)){
|
|
String xPathLocation="";
|
|
if(record.getEstado()!=null && record.getEstado().equals("RPER")){
|
|
xPathLocation= getRutaDocumentoSolBase("PerdidaRobo") + "/cm:"+record.getEstado()+"-" +this.record.getCodigoarma() ;
|
|
}else{
|
|
xPathLocation= getRutaDocumentoSolBase("Crear") +"/cm:"+record.getEstado()+"-" +this.numDoc ;
|
|
}
|
|
if(uploadedFile!=null && uploadedFile.getFileName()!=null){
|
|
String extencionArchivo=getExtension(uploadedFile.getFileName());
|
|
String nombreArchivo = record.getEstado()+"-"+(this.record.getPk()!=null?this.record.getPk():"NUEVA")+"."+extencionArchivo;
|
|
if(alfrescoController.uploadFile(uploadedFile.getInputstream(),nombreArchivo, xPathLocation)){
|
|
String pathRuta=xPathLocation + "/cm:" + nombreArchivo;
|
|
this.record.setPathDocumento(pathRuta);
|
|
uploadedFile=null;
|
|
}else{
|
|
MessageHelper.setMessageError("Adjunte el documento");
|
|
return;
|
|
}
|
|
}else{
|
|
MessageHelper.setMessageError("Adjunte el documento");
|
|
return;
|
|
}
|
|
}
|
|
|
|
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 {
|
|
verificaArmaExplosivo = Boolean.TRUE;
|
|
if(record.getCountrycode() == null){
|
|
record.setCountrycode("EC");
|
|
}
|
|
if(record.getCtipoarmaexplosivo()==null){
|
|
MessageHelper.setMessageError("NO ESTA ASOCIADO A UN TIPO DE ARMA EXPLOSIVO");
|
|
return;
|
|
}
|
|
tipoArmaExplosivo= TiposArmasExplosivosController.findarma(record.getCtipoarmaexplosivo());
|
|
lprovincias = ProvinceController.find(record.getCountrycode());
|
|
executeProvince();
|
|
if(record.getProvincecode() != null){
|
|
lcantones = CantonController.find(record.getCountrycode(), record.getProvincecode());
|
|
executeCanton();
|
|
}
|
|
completaInfTipoArma();
|
|
// Anade la descripcion del tipo de arma explosivo
|
|
if(tipoArmaExplosivo!=null){
|
|
if(this.tipoArmaExplosivo.getClase().equals("0010000003") || this.tipoArmaExplosivo.getClase().equals("0010000005") || this.tipoArmaExplosivo.getClase().equals("0010000007") || this.tipoArmaExplosivo.getClase().equals("0010000006")){
|
|
this.record.getModifiedData().put("unidadMedidaCantidad", null);
|
|
this.record.getModifiedData().put("unidadMedidaPeso", tipoArmaExplosivo.getModifiedData().get("nunidadMedidaPeso"));
|
|
}else if(this.tipoArmaExplosivo.getClase().equals("0010000001") || this.tipoArmaExplosivo.getClase().equals("0010000002") || this.tipoArmaExplosivo.getClase().equals("0010000004") || this.tipoArmaExplosivo.getClase().equals("0010000008")){
|
|
this.record.getModifiedData().put("unidadMedidaCantidad", tipoArmaExplosivo.getModifiedData().get("nunidadMedidaPeso"));
|
|
this.record.getModifiedData().put("unidadMedidaPeso", null);
|
|
}
|
|
}
|
|
verificarClaseArma();
|
|
registroArmas.clearAll();
|
|
registroArmas.addFilter("pk", record.getCregistro().toString());
|
|
registroArmas.query();
|
|
List<TarmRegistroArmas> registroArmasList = registroArmas.getLrecord();
|
|
registroArmas.setRecord(registroArmasList.get(0));
|
|
registroArmas.getRecord().setIsnew(Boolean.FALSE);
|
|
TcustPersonDetail tcustPersonDetail = PersonDetailController.find(registroArmas.getRecord().getPersoncode().toString());
|
|
tipoDoc = tcustPersonDetail.getIdentificationcatalog();
|
|
numDoc = tcustPersonDetail.getIdentification();
|
|
nombreRazon = tcustPersonDetail.getName();
|
|
}
|
|
|
|
/**
|
|
* Carga el archivo a grabar en la memoria para su posterior persistencia en el Alfresco
|
|
*/
|
|
public void handleUpload(FileUploadEvent event){
|
|
uploadedFile = event.getFile();
|
|
}
|
|
|
|
/**
|
|
* 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;
|
|
}
|
|
/**
|
|
* Método que completa la informaci´n del arma una vez se presiona el botón crear
|
|
*/
|
|
private void completaInfTipoArma(){
|
|
TarmArmas recordArma = findPorCodigo(record.getPk());
|
|
record.setCountrycode("EC");
|
|
clase = record.getModifiedData().get("clase") != null ? recordArma.getModifiedData().get("clase").toString() : null;
|
|
calibre = record.getModifiedData().get("ccalibre") != null ? Utilidades.formatearDecimalesEnTexto((recordArma.getModifiedData().get("ccalibre").toString()).replace("null", ""), "#.00") : null;
|
|
longitud = record.getModifiedData().get("clongitud") != null ? recordArma.getModifiedData().get("clongitud").toString() : null;
|
|
tipoarma = record.getModifiedData().get("ctipoarmaexplosivo") != null ? recordArma.getModifiedData().get("ctipoarmaexplosivo").toString() : null;
|
|
}
|
|
|
|
@Override
|
|
public void create() throws Exception {
|
|
super.create();
|
|
this.tipoDoc = null;
|
|
this.numDoc = null;
|
|
this.nombreRazon = null;
|
|
this.verificaArmaExplosivo = Boolean.TRUE;
|
|
this.registroArmas.create();
|
|
this.registroArmas.setLrecord(new ArrayList<TarmRegistroArmas>());
|
|
this.record.setCountrycode("EC");
|
|
// this.record.setEstado("REG");
|
|
this.record.setEstado("PREG");
|
|
this.record.setEstadocodigo("ESTADOARMA");
|
|
this.record.setMarcacodigo("MARCA");
|
|
this.record.setGeneracertificado("NO");
|
|
this.lprovincias = ProvinceController.find(record.getCountrycode());
|
|
this.executeProvince();
|
|
}
|
|
|
|
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 y estado
|
|
* @param armaCode código del arma
|
|
* @param estado estado del arma
|
|
* @return
|
|
*/
|
|
public static TarmArmas find(String armaCode,String estado) {
|
|
try {
|
|
|
|
if(armaCode==null){
|
|
return null;
|
|
}
|
|
ArmasController cc = new ArmasController();
|
|
cc.init();
|
|
cc.recperpage = 5000;
|
|
cc.addFilter("pk", armaCode);
|
|
if(estado!=null){
|
|
cc.addFilter("estado", estado);
|
|
cc.addFilter("estadocodigo", "ESTADOARMA");
|
|
}
|
|
cc.querydatabaseArmas();
|
|
|
|
if ((cc.lrecord != null) && !cc.lrecord.isEmpty()) {
|
|
TarmTipoArmaExplosivo tarmTipoArmaExplosivo = new TarmTipoArmaExplosivo();
|
|
tarmTipoArmaExplosivo = TiposArmasExplosivosController.findarma(cc.lrecord.get(0).getCtipoarmaexplosivo());
|
|
if(tarmTipoArmaExplosivo!=null && tarmTipoArmaExplosivo.getCalibrecodigo()!=null)
|
|
cc.record.modifiedData().put("calibre",tarmTipoArmaExplosivo==null?"":Utilidades.formatearDecimalesEnTexto((CatalogDetailController.findxCodigoCodcatalogo( tarmTipoArmaExplosivo.getCalibre(), tarmTipoArmaExplosivo.getCalibrecodigo()).getDescription()), "#.000"));
|
|
cc.record.modifiedData().put("tipo",tarmTipoArmaExplosivo==null?"":CatalogDetailController.findxCodigoCodcatalogo( tarmTipoArmaExplosivo.getTipoarmaexplosivo(), tarmTipoArmaExplosivo.getTipoarmaexplosivocodigo()).getDescription());
|
|
cc.record.modifiedData().put("clase",tarmTipoArmaExplosivo==null?"":CatalogDetailController.findxCodigoCodcatalogo( tarmTipoArmaExplosivo.getClase(), tarmTipoArmaExplosivo.getClasecodigo()).getDescription());
|
|
cc.record.modifiedData().put("seleccion", Boolean.FALSE);
|
|
cc.record.modifiedData().put("pais", cc.record.getCpaisorigen()==null?"":CountryController.findcountry(cc.record.getCpaisorigen()).getDescription());
|
|
|
|
return cc.lrecord.get(0);
|
|
}
|
|
return null;
|
|
} catch (Throwable e) {
|
|
MessageHelper.setMessageError(e);
|
|
return null;
|
|
}
|
|
}
|
|
|
|
/**
|
|
*
|
|
* @param codigopersona
|
|
* @return
|
|
*/
|
|
public static TarmArmas findBySerieMarca(String serie, String marca) {
|
|
try {
|
|
ArmasController cc = new ArmasController();
|
|
cc.init();
|
|
cc.recperpage = 5000;
|
|
if(serie!=null && !serie.isEmpty()){
|
|
cc.addFilter("lote", serie);
|
|
}
|
|
cc.addFilter("marca", marca);
|
|
cc.querydatabaseSimple();
|
|
if ((cc.lrecord != null) && !cc.lrecord.isEmpty()) {
|
|
return cc.lrecord.get(0);
|
|
}
|
|
return null;
|
|
} catch (Throwable e) {
|
|
MessageHelper.setMessageError(e);
|
|
return null;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Busca un arma por código
|
|
* @param armaCode
|
|
* @return
|
|
*/
|
|
public static TarmArmas findByPK(String cArma) {
|
|
try {
|
|
|
|
ArmasController cc = new ArmasController();
|
|
cc.init();
|
|
cc.recperpage = 5000;
|
|
cc.addFilter("pk", cArma);
|
|
cc.querydatabaseSinFiltros();
|
|
if ((cc.lrecord != null) && !cc.lrecord.isEmpty()) {
|
|
cc.record=cc.lrecord.get(0);
|
|
TarmTipoArmaExplosivo tarmTipoArmaExplosivo = TiposArmasExplosivosController.findarma(cc.lrecord.get(0).getCtipoarmaexplosivo());
|
|
if(tarmTipoArmaExplosivo!=null){
|
|
if(tarmTipoArmaExplosivo.getCalibre() != null && tarmTipoArmaExplosivo.getCalibrecodigo() != null){
|
|
cc.record.modifiedData().put("calibre", CatalogDetailController.findxCodigoCodcatalogo(tarmTipoArmaExplosivo.getCalibre(), tarmTipoArmaExplosivo.getCalibrecodigo())!=null?CatalogDetailController.findxCodigoCodcatalogo(tarmTipoArmaExplosivo.getCalibre(), tarmTipoArmaExplosivo.getCalibrecodigo()).getDescription():"");
|
|
}
|
|
if(tarmTipoArmaExplosivo.getTipoarmaexplosivo() != null && tarmTipoArmaExplosivo.getTipoarmaexplosivocodigo() != null){
|
|
cc.record.modifiedData().put("tipo",CatalogDetailController.findxCodigoCodcatalogo(tarmTipoArmaExplosivo.getTipoarmaexplosivo(), tarmTipoArmaExplosivo.getTipoarmaexplosivocodigo())!=null? CatalogDetailController.findxCodigoCodcatalogo(tarmTipoArmaExplosivo.getTipoarmaexplosivo(),tarmTipoArmaExplosivo.getTipoarmaexplosivocodigo()).getDescription():"");
|
|
}
|
|
if(tarmTipoArmaExplosivo.getClase() != null && tarmTipoArmaExplosivo.getClasecodigo() != null){
|
|
cc.record.modifiedData().put("clase",CatalogDetailController.findxCodigoCodcatalogo(tarmTipoArmaExplosivo.getClase(), tarmTipoArmaExplosivo.getClasecodigo())!=null?CatalogDetailController.findxCodigoCodcatalogo(tarmTipoArmaExplosivo.getClase(), tarmTipoArmaExplosivo.getClasecodigo()).getDescription():"");
|
|
}
|
|
|
|
TarmRegistroArmas registroArmas = new TarmRegistroArmas();
|
|
TcustPersonDetail detallePersona = new TcustPersonDetail();
|
|
if(cc.record.getCregistro()!=null ){
|
|
registroArmas = RegistroArmController.findByCodigo(String.valueOf(cc.record.getCregistro()));
|
|
if(registroArmas!=null){
|
|
detallePersona= PersonDetailController.find(String.valueOf(registroArmas.getPersoncode()));
|
|
}
|
|
}
|
|
cc.record.modifiedData().put("razonsPropietario",registroArmas ==null || detallePersona==null?"":detallePersona.getName());
|
|
cc.record.modifiedData().put("documentoPropietario",registroArmas ==null || detallePersona==null?"":detallePersona.getIdentification());
|
|
|
|
cc.record.modifiedData().put("seleccion", Boolean.FALSE);
|
|
|
|
return cc.lrecord.get(0);
|
|
}
|
|
}
|
|
return null;
|
|
} catch (Throwable e) {
|
|
MessageHelper.setMessageError(e);
|
|
return null;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Busca un arma por código
|
|
* @param armaCode
|
|
* @return
|
|
*/
|
|
public static TarmArmas findPorCodigo(String armaCode) {
|
|
try {
|
|
|
|
ArmasController cc = new ArmasController();
|
|
cc.init();
|
|
cc.recperpage = 5000;
|
|
cc.addFilter("pk", armaCode);
|
|
//cc.addFilter("REG", "ESTADOARMA");
|
|
cc.querydatabaseArmas();
|
|
|
|
if ((cc.lrecord != null) && !cc.lrecord.isEmpty()) {
|
|
TarmTipoArmaExplosivo tarmTipoArmaExplosivo = TiposArmasExplosivosController.findarma(cc.lrecord.get(0).getCtipoarmaexplosivo());
|
|
if(tarmTipoArmaExplosivo!=null){
|
|
if(tarmTipoArmaExplosivo.getCalibre() != null && tarmTipoArmaExplosivo.getCalibrecodigo() != null){
|
|
cc.record.modifiedData().put("calibre", CatalogDetailController.findxCodigoCodcatalogo(tarmTipoArmaExplosivo.getCalibre(), tarmTipoArmaExplosivo.getCalibrecodigo())!=null?CatalogDetailController.findxCodigoCodcatalogo(tarmTipoArmaExplosivo.getCalibre(), tarmTipoArmaExplosivo.getCalibrecodigo()).getDescription():"");
|
|
}
|
|
if(tarmTipoArmaExplosivo.getTipoarmaexplosivo() != null && tarmTipoArmaExplosivo.getTipoarmaexplosivocodigo() != null){
|
|
cc.record.modifiedData().put("tipo",CatalogDetailController.findxCodigoCodcatalogo(tarmTipoArmaExplosivo.getTipoarmaexplosivo(), tarmTipoArmaExplosivo.getTipoarmaexplosivocodigo())!=null? CatalogDetailController.findxCodigoCodcatalogo(tarmTipoArmaExplosivo.getTipoarmaexplosivo(),tarmTipoArmaExplosivo.getTipoarmaexplosivocodigo()).getDescription():"");
|
|
}
|
|
if(tarmTipoArmaExplosivo.getClase() != null && tarmTipoArmaExplosivo.getClasecodigo() != null){
|
|
cc.record.modifiedData().put("clase",CatalogDetailController.findxCodigoCodcatalogo(tarmTipoArmaExplosivo.getClase(), tarmTipoArmaExplosivo.getClasecodigo())!=null?CatalogDetailController.findxCodigoCodcatalogo(tarmTipoArmaExplosivo.getClase(), tarmTipoArmaExplosivo.getClasecodigo()).getDescription():"");
|
|
}
|
|
|
|
TarmRegistroArmas registroArmas = new TarmRegistroArmas();
|
|
TcustPersonDetail detallePersona = new TcustPersonDetail();
|
|
if(cc.record.getCregistro()!=null ){
|
|
registroArmas = RegistroArmController.findByCodigo(String.valueOf(cc.record.getCregistro()));
|
|
if(registroArmas!=null){
|
|
detallePersona= PersonDetailController.find(String.valueOf(registroArmas.getPersoncode()));
|
|
}
|
|
}
|
|
cc.record.modifiedData().put("razonsPropietario",registroArmas ==null || detallePersona==null?"":detallePersona.getName());
|
|
cc.record.modifiedData().put("documentoPropietario",registroArmas ==null || detallePersona==null?"":detallePersona.getIdentification());
|
|
cc.record.modifiedData().put("marca",(cc.record ==null || cc.record.getMarca()==null || cc.record.getMarca().isEmpty() || cc.record.getMarcacodigo()==null || cc.record.getMarcacodigo().isEmpty())?"":CatalogDetailController.findxCodigoCodcatalogo(cc.record.getMarca(), cc.record.getMarcacodigo()).getDescription());
|
|
|
|
cc.record.modifiedData().put("seleccion", Boolean.FALSE);
|
|
|
|
return cc.lrecord.get(0);
|
|
}
|
|
}
|
|
return null;
|
|
} catch (Throwable e) {
|
|
MessageHelper.setMessageError(e);
|
|
return null;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Busca un arma por código
|
|
* @param armaCode
|
|
* @return
|
|
*/
|
|
public static TarmArmas findXCodigo(String armaCode) {
|
|
try {
|
|
|
|
ArmasController cc = new ArmasController();
|
|
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;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Método para el evento change del combo provincias
|
|
*/
|
|
public void executeProvince() {
|
|
if ((record.getCountrycode() != null) && (record.getCountrycode().compareTo("") != 0)) {
|
|
lcantones = CantonController.find(record.getCountrycode(), record.getProvincecode());
|
|
lparroquias = new ArrayList<>();
|
|
lcities = new ArrayList<>();
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Método para el evento change del combo cantones
|
|
*/
|
|
public void executeCanton() {
|
|
if ((record.getCountrycode() != null) && (record.getCountrycode().compareTo("") != 0)) {
|
|
lparroquias = ParroquiaController.find(record.getCountrycode(), record.getProvincecode(), record.getCantoncode());
|
|
lcities = CityController.find(record.getCountrycode(), record.getProvincecode(), record.getCantoncode());
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
*
|
|
*
|
|
* @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>();
|
|
ArmasController armas = new ArmasController();
|
|
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 {
|
|
ArmasController cc = new ArmasController();
|
|
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();
|
|
}
|
|
|
|
/**
|
|
* Abre el LOV de la clase del arma
|
|
*/
|
|
public void openArmaExplosivoLov() {
|
|
this.record.getModifiedData().put("longitud", null);
|
|
this.record.getModifiedData().put("tipoarmaexplosivo", null);
|
|
this.record.getModifiedData().put("calibre", null);
|
|
record.setCantidad(null);
|
|
// descripcionUnidadpeso=null;
|
|
Map<String, List<String>> params = new HashMap<>();
|
|
ArmaExplosivoLovController.openLov(params);
|
|
}
|
|
|
|
/**
|
|
* Regresa del LOV de armas
|
|
* @param event
|
|
*/
|
|
public void onReturnArmaExplosivo(SelectEvent event) {
|
|
tipoArmaExplosivo = (TarmTipoArmaExplosivo) event.getObject();
|
|
//Setear descripciones a presentarse
|
|
this.record.getModifiedData().put("clase", tipoArmaExplosivo.getModifiedData().get("nclase"));
|
|
this.record.getModifiedData().put("tipoarmaexplosivo", tipoArmaExplosivo.getModifiedData().get("ntipo"));
|
|
this.record.getModifiedData().put("longitud", tipoArmaExplosivo.getModifiedData().get("nlongitud"));
|
|
this.record.getModifiedData().put("calibre", tipoArmaExplosivo.getModifiedData().get("ncalibre"));
|
|
// Setear valores en las variables correspondientes
|
|
if(tipoArmaExplosivo!=null){
|
|
this.clase = tipoArmaExplosivo.getClase();
|
|
this.longitud = tipoArmaExplosivo.getLongitud();
|
|
this.tipoarma = tipoArmaExplosivo.getTipoarmaexplosivo();
|
|
this.calibre = tipoArmaExplosivo.getCalibre();
|
|
this.record.setUnidadmedidacantidad(tipoArmaExplosivo.getUnidadmedidapeso());
|
|
if(tipoArmaExplosivo.getModifiedData().get("desunidad")!=null){
|
|
if(this.clase.equals("0010000003") || this.clase.equals("0010000005") || this.clase.equals("0010000007") || this.clase.equals("0010000006")){
|
|
this.record.getModifiedData().put("unidadMedidaCantidad", null);
|
|
this.record.getModifiedData().put("unidadMedidaPeso", tipoArmaExplosivo.getModifiedData().get("desunidad"));
|
|
}else if(this.clase.equals("0010000001") || this.clase.equals("0010000002") || this.clase.equals("0010000004") || this.clase.equals("0010000008")){
|
|
this.record.getModifiedData().put("unidadMedidaCantidad", tipoArmaExplosivo.getModifiedData().get("desunidad"));
|
|
this.record.getModifiedData().put("unidadMedidaPeso", null);
|
|
}
|
|
}
|
|
}
|
|
this.verificarClaseArma();
|
|
if(this.clase.equals("0010000001")||this.clase.equals("0010000008")){
|
|
record.setCantidad(1);//si es arma de fuego por default sea uno y no deje editar
|
|
this.bloquearUnidadCantidad = Boolean.TRUE;
|
|
}
|
|
// else{
|
|
// record.setCantidad(null);
|
|
// }
|
|
}
|
|
|
|
/**
|
|
* 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);
|
|
}
|
|
|
|
/**
|
|
* Acción de retorno de la selección del usuario
|
|
* @param event de retorno de la selección
|
|
*/
|
|
public void onReturnCambioUsuario(SelectEvent event) {
|
|
nuevoPropietarioArma = (TcustPersonDetail) event.getObject();
|
|
}
|
|
|
|
/**
|
|
* Abre el dialog del cambio de persona
|
|
*/
|
|
public void abrirDialogCambio() {
|
|
this.nuevoPropietarioArma = null;
|
|
}
|
|
|
|
/**
|
|
* Se cambia el propietario del arma
|
|
*/
|
|
public void cambiarArmaUsuario() {
|
|
try {
|
|
CallerHelper callerHelper = new CallerHelper();
|
|
Request request = callerHelper.getRequest();
|
|
request.setCompany(1);
|
|
request.setTransactionModule("30");
|
|
request.setTransactionCode(151);
|
|
request.setTransactionVersion(1);
|
|
request.put("ARMAACTUAL", this.record);
|
|
request.put("NUEVAPERSONA", this.nuevoPropietarioArma);
|
|
Response response = callerHelper.executeSave(request);
|
|
if(response.getResponseCode().compareTo(Response.RESPONSE_OK) == 0){
|
|
MessageHelper.setMessageInfo(response);
|
|
this.querydatabase();
|
|
} else{
|
|
MessageHelper.setMessageError(response);
|
|
}
|
|
} catch (Throwable e) {
|
|
MessageHelper.setMessageError(e);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 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 el listado de las armas por la serie/lote
|
|
* @param serieLote
|
|
* @return
|
|
*/
|
|
public static List<TarmArmas> findxSerieLote(String serieLote) {
|
|
try {
|
|
ArmasController cc = new ArmasController();
|
|
cc.init();
|
|
cc.recperpage = 1000;
|
|
cc.addFilter("lote", serieLote);
|
|
cc.querydatabaseFechaMax();
|
|
if ((cc.lrecord != null) && !cc.lrecord.isEmpty()) {
|
|
return cc.lrecord;
|
|
}
|
|
return null;
|
|
} catch (Throwable e) {
|
|
MessageHelper.setMessageError(e);
|
|
return null;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Metodo para obtener el listado de las armas por la lote
|
|
* @param serieLote
|
|
* @return
|
|
*/
|
|
public static List<TarmArmas> findPorLote(String lote) {
|
|
try {
|
|
ArmasController cc = new ArmasController();
|
|
cc.init();
|
|
cc.recperpage = 10000;
|
|
cc.addFilter("lote", lote);
|
|
cc.querydatabaseArmas();
|
|
if ((cc.lrecord != null) && !cc.lrecord.isEmpty()) {
|
|
return cc.lrecord;
|
|
}
|
|
return null;
|
|
} catch (Throwable e) {
|
|
MessageHelper.setMessageError(e);
|
|
return null;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Metodo para obtener los codigos
|
|
*/
|
|
private static String codigos(String parametro){
|
|
TgeneParameters tgeneParameters= ParametersController.find(parametro, "1");
|
|
return tgeneParameters.getTextvalue();
|
|
}
|
|
|
|
@SuppressWarnings("unchecked")
|
|
protected void querydatabaseFechaMax() {
|
|
try {
|
|
DtoQuery dto = this.getDtoQuery();
|
|
dto.setOrderby("pk");
|
|
String codigoEstadoIncautada=codigos("CODIGO.INCAUTADA");
|
|
String codigoEstadoDecomisada=codigos("CODIGO.DECOMISADA");
|
|
String codigoEstadoVendida=codigos("CODIGO.VENDIDA");
|
|
String codigoEstadoMatPrima=codigos("CODIGO.MATERIAPRIMA");
|
|
Filter filtro = new Filter();
|
|
String sql="t.fecharegistro=(select max(ta.fecharegistro) from TarmArmas ta where t.codigoarma=ta.codigoarma and t.cregistro=ta.cregistro)"//and t.cregistro=ta.cregistro para el manejo de los explosivos
|
|
+ " and t.estado !='DEST' and t.estado !='CDP' and t.estado !='"+codigoEstadoIncautada+"' and t.estado !='"+codigoEstadoDecomisada+"' and t.estado !='"+codigoEstadoVendida+"' and t.estado !='"+codigoEstadoMatPrima+"' ";
|
|
filtro.setSql(sql);
|
|
dto.addFiltro(filtro);
|
|
|
|
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);
|
|
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);
|
|
super.postQuery(this.lrecord);
|
|
}
|
|
} catch (Throwable e) {
|
|
MessageHelper.setMessageError(e);
|
|
}
|
|
}
|
|
|
|
public void actualizar(TarmArmas arma) throws Exception{
|
|
record=arma;
|
|
super.update();
|
|
}
|
|
|
|
/*Busca un arma por código
|
|
* @param armaCode
|
|
* @return
|
|
*/
|
|
public static TarmArmas findxCodigo(String armaCode) {
|
|
try {
|
|
|
|
ArmasController cc = new ArmasController();
|
|
cc.init();
|
|
cc.recperpage = 5000;
|
|
cc.addFilter("pk", armaCode);
|
|
cc.querydatabaseArmas();
|
|
cc.getRecord().getModifiedData().put("lmarca", cc.getLmarca());
|
|
if ((cc.lrecord != null) && !cc.lrecord.isEmpty()) {
|
|
return cc.lrecord.get(0);
|
|
}
|
|
return null;
|
|
} catch (Throwable e) {
|
|
MessageHelper.setMessageError(e);
|
|
return null;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @param lote
|
|
* @return
|
|
*/
|
|
public static List<TarmArmas> findxLotePerdidaRobo(String lote) {
|
|
List<TarmArmas> armasLista = null;
|
|
try {
|
|
armasLista = new ArrayList<TarmArmas>();
|
|
ArmasController armas = new ArmasController();
|
|
armas.init();
|
|
armas.recperpage = 4000;
|
|
armas.addFilter("lote", lote);//("personcode", personCode);
|
|
armas.querydatabaseArmaVenta(" and t.pathDocumento like '%/cm:PerdidaRobo/%'");
|
|
if(armas.getLrecord() != null && !armas.getLrecord().isEmpty()){
|
|
armasLista.addAll(armas.getLrecord());
|
|
}
|
|
return armasLista;
|
|
} catch (Throwable e) {
|
|
MessageHelper.setMessageError(e);
|
|
return armasLista;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @param lote
|
|
* @return
|
|
*/
|
|
public static List<TarmArmas> findxLoteRegistro(String lote) {
|
|
List<TarmArmas> armasLista = null;
|
|
try {
|
|
armasLista = new ArrayList<TarmArmas>();
|
|
ArmasController armas = new ArmasController();
|
|
armas.init();
|
|
armas.recperpage = 4000;
|
|
armas.addFilter("lote", lote);//("personcode", personCode);
|
|
armas.querydatabaseArmaVenta(" and t.pathDocumento like '%/cm:Crear/%'");
|
|
if(armas.getLrecord() != null && !armas.getLrecord().isEmpty()){
|
|
armasLista.addAll(armas.getLrecord());
|
|
}
|
|
return armasLista;
|
|
} catch (Throwable e) {
|
|
MessageHelper.setMessageError(e);
|
|
return armasLista;
|
|
}
|
|
}
|
|
|
|
@SuppressWarnings("unchecked")
|
|
protected void querydatabaseArmaVenta(String crear) {
|
|
try {
|
|
DtoQuery dto = this.getDtoQuery();
|
|
dto.setOrderby("pk");
|
|
String sqlFinal = " t.pathDocumento is not null "+crear;
|
|
Filter filtroFinal = new Filter();
|
|
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);
|
|
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);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public void generarReporte(TarmArmas arma) {
|
|
String path = "armas/reports/certificadoArmaCrear";
|
|
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 = "";
|
|
}
|
|
parameters.put("filtro", arma.getPk());
|
|
parameters.put("usuario", nombreUsuario);
|
|
//Fecha actual
|
|
Calendar fechaActualCldr = Calendar.getInstance();
|
|
StringBuilder fechaActualSB = new StringBuilder();
|
|
fechaActualSB = fechaActualSB.append((fechaActualCldr.get(Calendar.DAY_OF_MONTH)) <= 9 ? "0" + (fechaActualCldr.get(Calendar.DAY_OF_MONTH)) : (fechaActualCldr.get(Calendar.DAY_OF_MONTH)));
|
|
fechaActualSB = fechaActualSB.append("-").append((fechaActualCldr.get(Calendar.MONTH)+1) <= 9 ? "0" + (fechaActualCldr.get(Calendar.MONTH) + 1) : (fechaActualCldr.get(Calendar.MONTH)+1));
|
|
fechaActualSB = fechaActualSB.append("-").append(fechaActualCldr.get(Calendar.YEAR));
|
|
fechaActualSB = fechaActualSB.append(" ").append(fechaActualCldr.get(Calendar.HOUR_OF_DAY));
|
|
fechaActualSB = fechaActualSB.append(":").append((fechaActualCldr.get(Calendar.MINUTE)) <= 9 ? "0" + (fechaActualCldr.get(Calendar.MINUTE)) : (fechaActualCldr.get(Calendar.MINUTE)));
|
|
parameters.put("lugarfecha", fechaActualSB.toString());
|
|
|
|
String format = "pdf";
|
|
String filename = "certificadoArma";
|
|
|
|
InputStream inputStream = this.reportController.jaspertoInputstream(path,parameters, format, filename, this.getLoginController());
|
|
|
|
String nombreArchivo = (filename!=null && !filename.isEmpty()) ? filename+"."+format : null;
|
|
String xPathLocation= getRutaDocumentoSolBase()+"/cm:"+arma.getEstado() + "/cm:CP-" + arma.getModifiedData().get("personcode") + "/cm:CA-" + arma.getCodigoarma() ;
|
|
if (nombreArchivo != null && xPathLocation != null && inputStream != null) {
|
|
setRecord(arma);
|
|
if (alfrescoController.uploadFile(inputStream, nombreArchivo, xPathLocation)) {
|
|
record.setPathDocumentocrear(xPathLocation + "/cm:" + nombreArchivo);
|
|
record.setGeneracertificado("SI");
|
|
super.update();
|
|
saveFile();
|
|
}
|
|
} else {
|
|
MessageHelper.setMessageError(MsgControlArmas.getProperty("msg_error_subiroarchivoregistrorecibo").concat("("+nombreArchivo+")"));
|
|
|
|
}
|
|
} catch (Exception ex) {
|
|
MessageHelper.setMessageError(ex);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Retorna la ruta base donde se almacenara dicho archivo
|
|
*
|
|
* @return
|
|
*/
|
|
public String getRutaDocumentoSolBase() {
|
|
Calendar calendar = Calendar.getInstance();
|
|
StringBuilder ruta = new StringBuilder("cm:Armas/cm:Crear");
|
|
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_MONTH));
|
|
return ruta.toString();
|
|
}
|
|
|
|
public TiposArmasExplosivosController getTiposArmasExplosivosController() {
|
|
return tiposArmasExplosivosController;
|
|
}
|
|
|
|
|
|
public void setTiposArmasExplosivosController(
|
|
TiposArmasExplosivosController tiposArmasExplosivosController) {
|
|
this.tiposArmasExplosivosController = tiposArmasExplosivosController;
|
|
}
|
|
|
|
|
|
public RegistroArmController getRegistroArmas() {
|
|
return registroArmas;
|
|
}
|
|
|
|
|
|
public void setRegistroArmas(RegistroArmController registroArmas) {
|
|
this.registroArmas = registroArmas;
|
|
}
|
|
|
|
|
|
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 List<TgeneCatalogDetail> getLmarca() {
|
|
return lmarca;
|
|
}
|
|
|
|
|
|
public void setLmarca(List<TgeneCatalogDetail> lmarca) {
|
|
this.lmarca = lmarca;
|
|
}
|
|
|
|
|
|
public List<TgeneCatalogDetail> getLcolor() {
|
|
return lcolor;
|
|
}
|
|
|
|
|
|
public void setLcolor(List<TgeneCatalogDetail> lcolor) {
|
|
this.lcolor = lcolor;
|
|
}
|
|
|
|
|
|
public List<TgeneCatalogDetail> getLtipofabricacion() {
|
|
return ltipofabricacion;
|
|
}
|
|
|
|
|
|
public void setLtipofabricacion(List<TgeneCatalogDetail> ltipofabricacion) {
|
|
this.ltipofabricacion = ltipofabricacion;
|
|
}
|
|
|
|
|
|
public List<TgeneCountry> getLcountry() {
|
|
return lcountry;
|
|
}
|
|
|
|
|
|
public void setLcountry(List<TgeneCountry> lcountry) {
|
|
this.lcountry = lcountry;
|
|
}
|
|
|
|
|
|
public List<TgeneCatalogDetail> getLunidadmedidacantidad() {
|
|
return lunidadmedidacantidad;
|
|
}
|
|
|
|
|
|
public void setLunidadmedidacantidad(
|
|
List<TgeneCatalogDetail> lunidadmedidacantidad) {
|
|
this.lunidadmedidacantidad = lunidadmedidacantidad;
|
|
}
|
|
|
|
|
|
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 List<TgeneCatalogDetail> getLunidadmedidapeso() {
|
|
return lunidadmedidapeso;
|
|
}
|
|
|
|
|
|
public void setLunidadmedidapeso(List<TgeneCatalogDetail> lunidadmedidapeso) {
|
|
this.lunidadmedidapeso = lunidadmedidapeso;
|
|
}
|
|
|
|
|
|
public List<TgeneProvince> getLprovincias() {
|
|
return lprovincias;
|
|
}
|
|
|
|
|
|
public void setLprovincias(List<TgeneProvince> lprovincias) {
|
|
this.lprovincias = lprovincias;
|
|
}
|
|
|
|
|
|
public List<TgeneCanton> getLcantones() {
|
|
return lcantones;
|
|
}
|
|
|
|
|
|
public void setLcantones(List<TgeneCanton> lcantones) {
|
|
this.lcantones = lcantones;
|
|
}
|
|
|
|
|
|
public List<TgeneParroquia> getLparroquias() {
|
|
return lparroquias;
|
|
}
|
|
|
|
|
|
public void setLparroquias(List<TgeneParroquia> lparroquias) {
|
|
this.lparroquias = lparroquias;
|
|
}
|
|
|
|
|
|
public List<TgeneCity> getLcities() {
|
|
return lcities;
|
|
}
|
|
|
|
|
|
public void setLcities(List<TgeneCity> lcities) {
|
|
this.lcities = lcities;
|
|
}
|
|
|
|
|
|
public boolean isExisteTipoArmaExplosivo() {
|
|
return existeTipoArmaExplosivo;
|
|
}
|
|
|
|
|
|
public void setExisteTipoArmaExplosivo(boolean existeTipoArmaExplosivo) {
|
|
this.existeTipoArmaExplosivo = existeTipoArmaExplosivo;
|
|
}
|
|
|
|
|
|
public boolean isVerificaArmaExplosivo() {
|
|
return verificaArmaExplosivo;
|
|
}
|
|
|
|
|
|
public void setVerificaArmaExplosivo(boolean verificaArmaExplosivo) {
|
|
this.verificaArmaExplosivo = verificaArmaExplosivo;
|
|
}
|
|
|
|
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 TarmTipoArmaExplosivo getTipoArmaExplosivo() {
|
|
return tipoArmaExplosivo;
|
|
}
|
|
|
|
public void setTipoArmaExplosivo(TarmTipoArmaExplosivo tipoArmaExplosivo) {
|
|
this.tipoArmaExplosivo = tipoArmaExplosivo;
|
|
}
|
|
|
|
|
|
|
|
|
|
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;
|
|
}
|
|
|
|
protected void querydatabaseArmas() {
|
|
try {
|
|
DtoQuery dto = this.getDtoQuery();
|
|
|
|
dto.setOrderby("pk");
|
|
if(this.getMfilelds().get("ESTADOS") != null){
|
|
Filter filtroEstados = new Filter();
|
|
String[] estados = this.getMfilelds().get("ESTADOS").toString().split(",");
|
|
StringBuffer sqlEstados = new StringBuffer(" t.estado IN (");
|
|
for (int i = 0; i < estados.length; i++) {
|
|
sqlEstados.append("'").append(estados[i]).append("'");
|
|
if(i < estados.length - 1){
|
|
sqlEstados.append(",");
|
|
}
|
|
}
|
|
sqlEstados.append(")");
|
|
filtroEstados.setSql(sqlEstados.toString());
|
|
dto.addFiltro(filtroEstados);
|
|
}else{
|
|
//se discrima las armas que sean distintas de destruidas y cambio de propietario
|
|
Filter filtro = new Filter();
|
|
String sql=" t.estado !='DEST' and t.estado !='CDP'";
|
|
filtro.setSql(sql);
|
|
dto.addFiltro(filtro);
|
|
}
|
|
|
|
|
|
|
|
if(this.getMfilelds().get("ESTADOS") != null){
|
|
Filter filtroEstados = new Filter();
|
|
String[] estados = this.getMfilelds().get("ESTADOS").toString().split(",");
|
|
StringBuffer sqlEstados = new StringBuffer(" t.estado IN (");
|
|
for (int i = 0; i < estados.length; i++) {
|
|
sqlEstados.append("'").append(estados[i]).append("'");
|
|
if(i < estados.length - 1){
|
|
sqlEstados.append(",");
|
|
}
|
|
}
|
|
sqlEstados.append(")");
|
|
filtroEstados.setSql(sqlEstados.toString());
|
|
dto.addFiltro(filtroEstados);
|
|
}
|
|
|
|
if(this.getMfilelds().get("TIPOFABRICACION") != null){
|
|
Filter filtroTipoFab = new Filter();
|
|
String[] tipoFab = this.getMfilelds().get("TIPOFABRICACION").toString().split(",");
|
|
StringBuffer sqlTipoFab = new StringBuffer(" t.tipofabricacion IN (");
|
|
for (int i = 0; i < tipoFab.length; i++) {
|
|
sqlTipoFab.append("'").append(tipoFab[i]).append("'");
|
|
if(i < tipoFab.length - 1){
|
|
sqlTipoFab.append(",");
|
|
}
|
|
}
|
|
sqlTipoFab.append(")");
|
|
filtroTipoFab.setSql(sqlTipoFab.toString());
|
|
dto.addFiltro(filtroTipoFab);
|
|
}
|
|
|
|
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);
|
|
}
|
|
}
|
|
|
|
public TcustPersonDetail getNuevoPropietarioArma() {
|
|
return nuevoPropietarioArma;
|
|
}
|
|
|
|
public void setNuevoPropietarioArma(TcustPersonDetail nuevoPropietarioArma) {
|
|
this.nuevoPropietarioArma = nuevoPropietarioArma;
|
|
}
|
|
|
|
/**
|
|
* Busca un arma por código
|
|
* @param armaCode
|
|
* @return
|
|
*/
|
|
public static TarmArmas findXCodigoArma(String armaCode) {
|
|
try {
|
|
ArmasController cc = new ArmasController();
|
|
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;
|
|
}
|
|
}
|
|
|
|
public List<TarmArmas> findArmaRecep(String csolicitud) {
|
|
try {
|
|
ArmasController cc = new ArmasController();
|
|
cc.init();
|
|
cc.querydatabaserecep(csolicitud);
|
|
if ((cc.lrecord != null) && !cc.lrecord.isEmpty()) {
|
|
return cc.lrecord;
|
|
}
|
|
return null;
|
|
|
|
} catch (Throwable e) {
|
|
MessageHelper.setMessageError(e);
|
|
return null;
|
|
}
|
|
}
|
|
public void querydatabaserecep(String csolicitud) {
|
|
try {
|
|
DtoQuery dto = this.getDtoQuery();
|
|
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.put("csolicitud", csolicitud);
|
|
//QueryRule ArmasRecepcionQuery
|
|
request.put("queryalias", "ARMASRECEPLIST");
|
|
|
|
|
|
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);
|
|
super.postQuery(this.lrecord);
|
|
}
|
|
} catch (Throwable e) {
|
|
MessageHelper.setMessageError(e);
|
|
}
|
|
}
|
|
|
|
@SuppressWarnings("unchecked")
|
|
public void querydatabasesimple() {
|
|
try {
|
|
DtoQuery dto = this.getDtoQuery();
|
|
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);
|
|
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);
|
|
super.postQuery(this.lrecord);
|
|
}
|
|
} catch (Throwable e) {
|
|
MessageHelper.setMessageError(e);
|
|
}
|
|
}
|
|
|
|
|
|
@SuppressWarnings("unchecked")
|
|
public void querydatabaseArmaDuplicada(TarmArmas armaObj) {
|
|
try {
|
|
DtoQuery dto = this.getDtoQuery();
|
|
|
|
Filter filtro = new Filter();
|
|
filtro.setSql("t.marca='"+armaObj.getMarca()+"' and t.marcacodigo='"+armaObj.getMarcacodigo()+"' and upper(t.lote)='"+ armaObj.getLote().toUpperCase()+"'");
|
|
dto.addFiltro(filtro);
|
|
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);
|
|
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);
|
|
super.postQuery(this.lrecord);
|
|
}
|
|
} catch (Throwable e) {
|
|
MessageHelper.setMessageError(e);
|
|
}
|
|
}
|
|
|
|
public static TarmArmas findSimple(String carma) {
|
|
try {
|
|
ArmasController cc = new ArmasController();
|
|
cc.init();
|
|
cc.recperpage = 5000;
|
|
cc.addFilter("pk", carma);
|
|
cc.querydatabasesimple();
|
|
if ((cc.lrecord != null) && !cc.lrecord.isEmpty()) {
|
|
return cc.lrecord.get(0);
|
|
}
|
|
return null;
|
|
} catch (Throwable e) {
|
|
MessageHelper.setMessageError(e);
|
|
return null;
|
|
}
|
|
}
|
|
|
|
public static Boolean isArmaDuplicada(TarmArmas armaObj) {
|
|
Boolean isDuplicada = Boolean.FALSE;
|
|
ArmasController cc;
|
|
try {
|
|
cc = new ArmasController();
|
|
cc.init();
|
|
cc.recperpage = 300;
|
|
cc.querydatabaseArmaDuplicada(armaObj);
|
|
if ((cc.lrecord != null) && !cc.lrecord.isEmpty()) {
|
|
for(TarmArmas armaTmp:cc.lrecord){
|
|
TarmTipoArmaExplosivo tipoArmaExpTmp = TiposArmasExplosivosController.findarma(armaTmp.getCtipoarmaexplosivo());
|
|
TgeneCatalogDetail claseTmp = CatalogDetailController.findCatalogo(tipoArmaExpTmp.getClasecodigo(), tipoArmaExpTmp.getClase());
|
|
TgeneCatalogDetail tipoArmaTmp = CatalogDetailController.findCatalogo(tipoArmaExpTmp.getTipoarmaexplosivocodigo(), tipoArmaExpTmp.getTipoarmaexplosivo());
|
|
TgeneCatalogDetail calibreTmp = CatalogDetailController.findCatalogo(tipoArmaExpTmp.getCalibrecodigo(), tipoArmaExpTmp.getCalibre());
|
|
// Valido la clase, tipoarma y calibre solo para armas de fuego y armas no letales
|
|
if(claseTmp.getPk().getCatalog().equals("0010000001") || claseTmp.getPk().getCatalog().equals("0010000008")){
|
|
if(armaObj.getModifiedData().get("clase")!=null && armaObj.getModifiedData().get("tipoarmaexplosivo")!=null){
|
|
if(armaObj.getModifiedData().get("clase").toString().equalsIgnoreCase(claseTmp!=null?claseTmp.getDescription():"")&&
|
|
armaObj.getModifiedData().get("tipoarmaexplosivo").toString().equalsIgnoreCase(tipoArmaTmp!=null?tipoArmaTmp.getDescription():"")){
|
|
if(armaObj.getModifiedData().get("calibre")!=null && calibreTmp!=null && armaObj.getModifiedData().get("calibre").toString().equalsIgnoreCase(calibreTmp.getDescription())){
|
|
isDuplicada = Boolean.TRUE;
|
|
break;
|
|
}
|
|
}
|
|
}else{
|
|
MessageHelper.setMessageError("CLASE Y/O TIPO DE ARMA EXPLOSIVO INCORRECTOS");
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
return isDuplicada;
|
|
} catch (Exception e) {
|
|
// TODO Auto-generated catch block
|
|
MessageHelper.setMessageError(e);
|
|
return null;
|
|
}
|
|
}
|
|
|
|
|
|
public static TarmArmas find(String carma) {
|
|
try {
|
|
|
|
ArmasController cc = new ArmasController();
|
|
cc.init();
|
|
cc.recperpage = 5000;
|
|
cc.addFilter("pk", carma);
|
|
cc.querydatabasesimple();
|
|
|
|
if ((cc.lrecord != null) && !cc.lrecord.isEmpty()) {
|
|
TarmTipoArmaExplosivo tarmTipoArmaExplosivo = TiposArmasExplosivosController.findarma(cc.lrecord.get(0).getCtipoarmaexplosivo());
|
|
if(tarmTipoArmaExplosivo!=null){
|
|
if(tarmTipoArmaExplosivo.getCalibre() != null && tarmTipoArmaExplosivo.getCalibrecodigo() != null){
|
|
cc.record.modifiedData().put("calibre", CatalogDetailController.findxCodigoCodcatalogo(tarmTipoArmaExplosivo.getCalibre(), tarmTipoArmaExplosivo.getCalibrecodigo())!=null?CatalogDetailController.findxCodigoCodcatalogo(tarmTipoArmaExplosivo.getCalibre(), tarmTipoArmaExplosivo.getCalibrecodigo()).getDescription():"");
|
|
}
|
|
if(tarmTipoArmaExplosivo.getTipoarmaexplosivo() != null && tarmTipoArmaExplosivo.getTipoarmaexplosivocodigo() != null){
|
|
cc.record.modifiedData().put("tipo",CatalogDetailController.findxCodigoCodcatalogo(tarmTipoArmaExplosivo.getTipoarmaexplosivo(), tarmTipoArmaExplosivo.getTipoarmaexplosivocodigo())!=null? CatalogDetailController.findxCodigoCodcatalogo(tarmTipoArmaExplosivo.getTipoarmaexplosivo(),tarmTipoArmaExplosivo.getTipoarmaexplosivocodigo()).getDescription():"");
|
|
}
|
|
if(tarmTipoArmaExplosivo.getClase() != null && tarmTipoArmaExplosivo.getClasecodigo() != null){
|
|
cc.record.modifiedData().put("clase",CatalogDetailController.findxCodigoCodcatalogo(tarmTipoArmaExplosivo.getClase(), tarmTipoArmaExplosivo.getClasecodigo())!=null?CatalogDetailController.findxCodigoCodcatalogo(tarmTipoArmaExplosivo.getClase(), tarmTipoArmaExplosivo.getClasecodigo()).getDescription():"");
|
|
}
|
|
TarmRegistroArmas registroArmas = new TarmRegistroArmas();
|
|
TcustPersonDetail detallePersona = new TcustPersonDetail();
|
|
if(cc.record.getCregistro()!=null ){
|
|
registroArmas = RegistroArmController.findByCodigo(String.valueOf(cc.record.getCregistro()));
|
|
if(registroArmas!=null){
|
|
detallePersona= PersonDetailController.find(String.valueOf(registroArmas.getPersoncode()));
|
|
}
|
|
}
|
|
cc.record.modifiedData().put("razonsPropietario",registroArmas ==null || detallePersona==null?"":detallePersona.getName());
|
|
cc.record.modifiedData().put("documentoPropietario",registroArmas ==null || detallePersona==null?"":detallePersona.getIdentification());
|
|
cc.record.modifiedData().put("marca",(cc.record ==null || cc.record.getMarca()==null || cc.record.getMarca().isEmpty() || cc.record.getMarcacodigo()==null || cc.record.getMarcacodigo().isEmpty())?"":CatalogDetailController.findxCodigoCodcatalogo(cc.record.getMarca(), cc.record.getMarcacodigo()).getDescription());
|
|
cc.record.modifiedData().put("seleccion", Boolean.FALSE);
|
|
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();
|
|
}
|
|
|
|
public UploadedFile getUploadedFile() {
|
|
return uploadedFile;
|
|
}
|
|
|
|
public void setUploadedFile(UploadedFile uploadedFile) {
|
|
this.uploadedFile = uploadedFile;
|
|
}
|
|
|
|
public AlfrescoController getAlfrescoController() {
|
|
return alfrescoController;
|
|
}
|
|
|
|
public void setAlfrescoController(AlfrescoController alfrescoController) {
|
|
this.alfrescoController = alfrescoController;
|
|
}
|
|
|
|
public ReportController getReportController() {
|
|
return reportController;
|
|
}
|
|
|
|
public void setReportController(ReportController reportController) {
|
|
this.reportController = reportController;
|
|
}
|
|
|
|
|
|
}
|