380 lines
13 KiB
Plaintext
Executable File
380 lines
13 KiB
Plaintext
Executable File
package com.fp.frontend.controller.armas.solicitud;
|
|
|
|
import java.sql.Date;
|
|
import java.util.ArrayList;
|
|
import java.util.HashMap;
|
|
import java.util.List;
|
|
|
|
import javax.annotation.PostConstruct;
|
|
import javax.faces.bean.ManagedBean;
|
|
import javax.faces.bean.ManagedProperty;
|
|
import javax.faces.bean.ViewScoped;
|
|
import javax.faces.event.AjaxBehaviorEvent;
|
|
|
|
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.helper.MessageHelper;
|
|
import com.fp.persistence.parmas.inte.TarmColadeImpresion;
|
|
import com.fp.persistence.parmas.soli.TarmArmas;
|
|
import com.fp.persistence.parmas.soli.TarmDocumentoHabilitante;
|
|
import com.fp.persistence.parmas.soli.TarmSolicitud;
|
|
import com.fp.persistence.parmas.soli.TarmSolicitudDocumento;
|
|
|
|
|
|
@SuppressWarnings("serial")
|
|
@ManagedBean
|
|
@ViewScoped
|
|
public class VerificacionInformacionCertificado extends AbstractController<TarmSolicitudDocumento> {
|
|
|
|
|
|
/*
|
|
* Variable que indica si se seleciona el check o no
|
|
*/
|
|
private Boolean verifica = false;
|
|
/*
|
|
* Variable que almacena el código de solicitud
|
|
*/
|
|
private String csolicitud;
|
|
/*
|
|
* Bean de tipo TarmSolicitud
|
|
*/
|
|
private TarmSolicitud solicitud = new TarmSolicitud();
|
|
/*
|
|
* Bean del tipo ColaImpresionController
|
|
*/
|
|
private ColaImpresionController colaimpresion = new ColaImpresionController();
|
|
|
|
@ManagedProperty(value = "#{docHabilitanteController}")
|
|
private DocumentoHabilitanteController docHabilitanteController;
|
|
|
|
@ManagedProperty(value = "#{solicitudController}")
|
|
private SolicitudController solicitudController;
|
|
|
|
@ManagedProperty(value = "#{recepcionArmasController}")
|
|
private RecepcionArmasController recepcionArmasController;
|
|
|
|
/**
|
|
* Constructor
|
|
* @throws Exception
|
|
*/
|
|
public VerificacionInformacionCertificado() throws Exception {
|
|
super(TarmSolicitudDocumento.class);
|
|
}
|
|
|
|
/**
|
|
* Método invocado después de instanciar el controlador
|
|
* @throws Exception
|
|
*/
|
|
@PostConstruct
|
|
private void postconstruct() throws Exception {
|
|
this.init();
|
|
this.solicitud= SolicitudController.findSolicitudxcodsolicitud("135");
|
|
this.getMfilters().put("pk.csolicitud", this.solicitud.getPk());
|
|
this.getMfilelds().put("numerosolicitud", this.solicitud.getNumerosolicitud());
|
|
|
|
// Inicializa autoconsulta
|
|
super.startQuery();
|
|
}
|
|
|
|
/**
|
|
* Incializa variables del controlador, cuando se está utilizando una página que utliza el controlador.
|
|
*/
|
|
private void init() {
|
|
try {
|
|
this.recperpage = 10; // Cambiar al # reg a mirar.
|
|
this.lrecord = new ArrayList<>();
|
|
this.beanalias = "VERIFICARDOCUMENTOS";
|
|
} catch (Exception e) {
|
|
MessageHelper.setMessageError(e);
|
|
}
|
|
}
|
|
|
|
/* (non-Javadoc)
|
|
* @see com.fp.frontend.controller.AbstractController#querydatabase()
|
|
*/
|
|
@SuppressWarnings("unchecked")
|
|
@Override
|
|
protected void querydatabase() {
|
|
try {
|
|
Request request = this.callerhelper.getRequest();
|
|
DtoQuery dto = super.getDtoQuery(true);
|
|
dto.setOrderby("t.pk"); // En en string van todos los campos de orden ("t.pk, t.nombre, t.cpais").
|
|
SubQuery qry = new SubQuery("TarmSolicitud", "ccentrocontrol", "ccentrocontrol", "i.pk = t.pk.csolicitud");
|
|
dto.addSubQuery(qry);
|
|
SubQuery qry2 = new SubQuery("TgeneCatalogDetail", "description", "tramitedesc",
|
|
"i.pk.catalog = (select a.tipotramite from TarmTramite a where a.pk = (select s.ctramite from TarmSolicitud s where s.pk = t.pk.csolicitud)) and "
|
|
+ "i.pk.catalogcode = (select a.tipotramitecodigo from TarmTramite a where a.pk = (select s.ctramite from TarmSolicitud s where s.pk = t.pk.csolicitud))");
|
|
dto.addSubQuery(qry2);
|
|
SubQuery qry3 = new SubQuery("TgeneCatalogDetail", "description", "categoriadesc",
|
|
"i.pk.catalog = (select a.categoria from TarmTramite a where a.pk = (select s.ctramite from TarmSolicitud s where s.pk = t.pk.csolicitud)) and "
|
|
+ "i.pk.catalogcode = (select a.categoriacodigo from TarmTramite a where a.pk = (select s.ctramite from TarmSolicitud s where s.pk = t.pk.csolicitud))");
|
|
dto.addSubQuery(qry3);
|
|
SubQuery qry4 = new SubQuery("TgeneCatalogDetail", "description", "usoactdesc",
|
|
"i.pk.catalog = (select a.usoactividad from TarmTramite a where a.pk = (select s.ctramite from TarmSolicitud s where s.pk = t.pk.csolicitud)) and "
|
|
+ "i.pk.catalogcode = (select a.usoactividadcodigo from TarmTramite a where a.pk = (select s.ctramite from TarmSolicitud s where s.pk = t.pk.csolicitud))");
|
|
dto.addSubQuery(qry4);
|
|
SubQuery qry5 = new SubQuery("TarmDocumentoHabilitante", "fechaemision", "fechaemision", "i.pk = t.pk.cdocumento and i.csolicitud = t.pk.csolicitud");
|
|
dto.addSubQuery(qry5);
|
|
SubQuery qry6 = new SubQuery("TarmDocumentoHabilitante", "fechaexpiracion", "fechaexpiracion", "i.pk = t.pk.cdocumento and i.csolicitud = t.pk.csolicitud");
|
|
dto.addSubQuery(qry6);
|
|
SubQuery qry7 = new SubQuery("TgeneCatalogDetail", "description", "estado",
|
|
"i.pk.catalog = (select a.estado from TarmDocumentoHabilitante a where a.csolicitud = t.pk.csolicitud and a.pk = t.pk.cdocumento) and "
|
|
+ "i.pk.catalogcode = (select a.estadocode from TarmDocumentoHabilitante a where a.csolicitud = t.pk.csolicitud and a.pk = t.pk.cdocumento)");
|
|
dto.addSubQuery(qry7);
|
|
SubQuery qry8 = new SubQuery("TarmDocumentoHabilitante", "carma", "carma", "i.pk = t.pk.cdocumento and i.csolicitud = t.pk.csolicitud");
|
|
dto.addSubQuery(qry8);
|
|
SubQuery qry9 = new SubQuery("TarmDocumentoHabilitante", "codigoarma", "codigoarma", "i.pk = t.pk.cdocumento and i.csolicitud = t.pk.csolicitud");
|
|
dto.addSubQuery(qry9);
|
|
SubQuery qry10 = new SubQuery("TgeneCatalogDetail", "description", "tipoautorizacion",
|
|
"i.pk.catalog = (select a.tipoautorizacion from TarmTramite a where a.pk = (select s.ctramite from TarmSolicitud s where s.pk = t.pk.csolicitud)) and "
|
|
+ "i.pk.catalogcode = (select a.tipoautorizacioncodigo from TarmTramite a where a.pk = (select s.ctramite from TarmSolicitud s where s.pk = t.pk.csolicitud))");
|
|
dto.addSubQuery(qry10);
|
|
HashMap<String, DtoQuery> mtables = new HashMap<String, DtoQuery>();
|
|
mtables.put(this.beanalias, dto); // permite adicionar mas de una tabla.
|
|
request.setQueryTables(mtables);
|
|
request.put("querytype", "P");
|
|
request.put("queryalias", "VDOCUMENTO");
|
|
Response resp = this.callerhelper.executeQuery(request);
|
|
if (resp.getResponseCode().compareTo(Response.RESPONSE_OK) != 0) {
|
|
this.lrecord = new ArrayList<TarmSolicitudDocumento>();
|
|
|
|
MessageHelper.setMessageError(resp);
|
|
} else {
|
|
this.lrecord = (List<TarmSolicitudDocumento>) resp.get(this.beanalias);
|
|
this.completaArmas();
|
|
super.postQuery(this.lrecord);
|
|
lista();
|
|
}
|
|
} catch (Throwable e) {
|
|
MessageHelper.setMessageError(e);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Verifica la selección del documento según el check de
|
|
* reimpresion
|
|
*/
|
|
public void lista(){
|
|
for (TarmSolicitudDocumento solicituddoc : lrecord) {
|
|
if(solicituddoc.getChkcertificado()!= null && solicituddoc.getChkcertificado().equals("Y")){
|
|
solicituddoc.getModifiedData().put("verificador", Boolean.TRUE);
|
|
}else{
|
|
solicituddoc.getModifiedData().put("verificador", Boolean.FALSE);
|
|
}
|
|
}
|
|
}
|
|
/* (non-Javadoc)
|
|
* @see com.fp.frontend.controller.AbstractController#save()
|
|
*/
|
|
@Override
|
|
public void save(){
|
|
try {
|
|
this.actualizaVerificado();
|
|
Request request = this.callerhelper.getRequest();
|
|
DtoSave dtosave = super.getDtoSave();
|
|
if(!dtosave.pendingProcess()){
|
|
return;
|
|
}
|
|
HashMap<String, DtoSave> msave = new HashMap<String, DtoSave>();
|
|
msave.put(this.beanalias, dtosave); // adicionar metadata de mantenimiento para cada tabla.
|
|
request.setSaveTables(msave);
|
|
Response resp = this.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);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Selecciona los registros para establecer si el registro se reimprime o no.
|
|
*/
|
|
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 (TarmSolicitudDocumento solicituddoc : lrecord) {
|
|
solicituddoc.getModifiedData().put("verificador", valorColocar);
|
|
}
|
|
} catch (Throwable e) {
|
|
MessageHelper.setMessageError(e);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Actualiza la selección del documento según el check de
|
|
* reimpresion
|
|
* @throws Exception
|
|
*/
|
|
public void actualizaVerificado() throws Exception{
|
|
for (TarmSolicitudDocumento solicituddoc : lrecord) {
|
|
if(solicituddoc.getModifiedData().get("verificador").equals(Boolean.TRUE)){
|
|
solicituddoc.setChkcertificado("Y");
|
|
}else {
|
|
solicituddoc.setChkcertificado("N");
|
|
}
|
|
record=solicituddoc;
|
|
super.update();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@SuppressWarnings("unchecked")
|
|
protected void querydatabaseDocumentos() {
|
|
try {
|
|
|
|
DtoQuery dto = super.getDtoQuery(true);
|
|
|
|
if(csolicitud !=null )
|
|
{
|
|
dto.addFiltro(new Filter("pk.csolicitud", csolicitud));
|
|
}
|
|
|
|
//solicitudTramite = TarmSolicitudTramiteController.findPorCSolicitud(codigoSolicitud);
|
|
solicitud = ValidacionTramiteLibreTransitoController.findPorSolicitudSimple(csolicitud);
|
|
|
|
HashMap<String, DtoQuery> mtables = new HashMap<String, DtoQuery>();
|
|
mtables.put(beanalias, dto); // permite adicionar mas de una tabla.
|
|
|
|
Request request = callerhelper.getRequest();
|
|
request.setQueryTables(mtables);
|
|
|
|
Response resp = callerhelper.executeQuery(request);
|
|
|
|
if (resp.getResponseCode().compareTo(Response.RESPONSE_OK) != 0) {
|
|
lrecord = new ArrayList<TarmSolicitudDocumento>();
|
|
MessageHelper.setMessageError(resp);
|
|
} else {
|
|
lrecord = (List<TarmSolicitudDocumento>) resp.get(beanalias);
|
|
if (lrecord != null && !lrecord.isEmpty()) {
|
|
record = lrecord.get(0);
|
|
|
|
|
|
seleccionarDocumentos();
|
|
}
|
|
super.postQuery(lrecord);
|
|
|
|
}
|
|
|
|
} catch (Throwable e) {
|
|
MessageHelper.setMessageError(e);
|
|
}
|
|
}
|
|
/**
|
|
* Método que asigna la selección del documento según el check de
|
|
* reimpresion
|
|
*
|
|
* @throws Exception
|
|
*/
|
|
@SuppressWarnings("unused")
|
|
private void seleccionarDocumentos() throws Exception {
|
|
for (int i = 0; i < lrecord.size(); i++) {
|
|
TarmSolicitudDocumento docSeleccionada = lrecord.get(i);
|
|
|
|
if (docSeleccionada.getVerificado().equalsIgnoreCase("Y")) {
|
|
docSeleccionada.modifiedData().put("seleccion", Boolean.TRUE);
|
|
} else {
|
|
docSeleccionada.modifiedData().put("seleccion", Boolean.FALSE);
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
/**
|
|
* Método que completa la información del arma para los registros de la
|
|
* tabla TarmSolicitudDocumento
|
|
*/
|
|
public void completaArmas(){
|
|
for(int i=0;i<this.lrecord.size();i++){
|
|
if(lrecord.get(i).getModifiedData().get("carma")!=null)
|
|
{
|
|
TarmArmas arm=ArmasController.findxCodigo(lrecord.get(i).getModifiedData().get("carma").toString());
|
|
try {
|
|
lrecord.get(i).getModifiedData().put("clasearma", arm.modifiedData.get("clase").toString());
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
}
|
|
try {
|
|
lrecord.get(i).getModifiedData().put("tipoarma", arm.modifiedData.get("tipo").toString());
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
}
|
|
try {
|
|
lrecord.get(i).getModifiedData().put("marcaarma", arm.modifiedData.get("marca").toString());
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
}
|
|
try {
|
|
lrecord.get(i).getModifiedData().put("calibrearma", arm.modifiedData.get("calibre").toString());
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
}
|
|
try {
|
|
lrecord.get(i).getModifiedData().put("seriearma", arm.modifiedData.get("lote").toString());
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public Boolean getVerifica() {
|
|
return verifica;
|
|
}
|
|
|
|
public void setVerifica(Boolean verifica) {
|
|
this.verifica = verifica;
|
|
}
|
|
|
|
public SolicitudController getSolicitudController() {
|
|
return solicitudController;
|
|
}
|
|
|
|
public void setSolicitudController(SolicitudController solicitudController) {
|
|
this.solicitudController = solicitudController;
|
|
}
|
|
|
|
public String getCsolicitud() {
|
|
return csolicitud;
|
|
}
|
|
|
|
public void setCsolicitud(String csolicitud) {
|
|
this.csolicitud = csolicitud;
|
|
}
|
|
|
|
public RecepcionArmasController getRecepcionArmasController() {
|
|
return recepcionArmasController;
|
|
}
|
|
|
|
public void setRecepcionArmasController(
|
|
RecepcionArmasController recepcionArmasController) {
|
|
this.recepcionArmasController = recepcionArmasController;
|
|
}
|
|
|
|
public DocumentoHabilitanteController getDocHabilitanteController() {
|
|
return docHabilitanteController;
|
|
}
|
|
|
|
public void setDocHabilitanteController(
|
|
DocumentoHabilitanteController docHabilitanteController) {
|
|
this.docHabilitanteController = docHabilitanteController;
|
|
}
|
|
}
|