452 lines
16 KiB
Plaintext
Executable File
452 lines
16 KiB
Plaintext
Executable File
package com.fp.frontend.controller.armas.solicitud;
|
|
|
|
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 org.primefaces.context.RequestContext;
|
|
|
|
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.alfresco.AlfrescoController;
|
|
import com.fp.frontend.helper.MessageHelper;
|
|
import com.fp.frontend.utility.MsgControlArmas;
|
|
import com.fp.persistence.parmas.soli.TarmArmas;
|
|
import com.fp.persistence.parmas.soli.TarmSolicitud;
|
|
import com.fp.persistence.parmas.soli.TarmSolicitudDocumento;
|
|
|
|
@SuppressWarnings("serial")
|
|
@ManagedBean
|
|
@ViewScoped
|
|
public class ImprimirVerificacionReimpresionController extends AbstractController<TarmSolicitudDocumento> {
|
|
|
|
|
|
/*
|
|
* Variable para verificar seleccion de documento
|
|
*/
|
|
private Boolean verifica = false;
|
|
/*
|
|
* Variable para habilitar documentos a imprimir
|
|
*/
|
|
private Boolean habimprimir = Boolean.TRUE;
|
|
/*
|
|
* Variable que coloca en verdadero o en falso.
|
|
*/
|
|
private Boolean valorColocar = Boolean.FALSE;
|
|
/*
|
|
* Hailita el boton del flujo
|
|
*/
|
|
private Boolean btnFlujo = Boolean.FALSE;
|
|
/*
|
|
* Bean del tipo TarmSolicitud
|
|
*/
|
|
TarmSolicitud solic= new TarmSolicitud();
|
|
/*
|
|
* Variable que almacena el codigo de la solicitud
|
|
*/
|
|
private String csolicitud;
|
|
|
|
@ManagedProperty(value = "#{solicitudController}")
|
|
private SolicitudController solicitudController;
|
|
|
|
@ManagedProperty(value = "#{alfrescoController}")
|
|
private AlfrescoController alfrescoController;
|
|
|
|
/**
|
|
* Constructor
|
|
* @throws Exception
|
|
*/
|
|
public ImprimirVerificacionReimpresionController() throws Exception {
|
|
super(TarmSolicitudDocumento.class);
|
|
}
|
|
|
|
/**
|
|
* Metodo invocado despues de instanciar el controlador
|
|
*/
|
|
@PostConstruct
|
|
private void postconstruct() {
|
|
try {
|
|
this.pasteBpmScreenParameters();
|
|
super.startQuery();
|
|
|
|
if(super.getMfilters().get("csolicitud")==null || super.getMfilters().get("csolicitud").isEmpty()){
|
|
MessageHelper.setMessageError(MsgControlArmas.getProperty("msg_error_noexistesolicitud"));
|
|
return;
|
|
}
|
|
|
|
csolicitud=super.getMfilters().get("csolicitud");
|
|
this.getMfilters().clear();
|
|
//this.getMfilters().put("pk.csolicitud", csolicitud);
|
|
solic= SolicitudController.findSolicitudxcodsolicitud(csolicitud);
|
|
this.getMfilelds().put("numerosolicitud", solic.getNumerosolicitud());
|
|
// Inicializa autoconsulta
|
|
this.init();
|
|
} catch (Exception e) {
|
|
// TODO Auto-generated catch block
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Incializa variables del controlador, cuando se esta utilizando una pagina que utliza el controlador.
|
|
*/
|
|
private void init() {
|
|
try {
|
|
this.recperpage = 10; // Cambiar al # reg a mirar.
|
|
this.lrecord = new ArrayList<>();
|
|
this.beanalias = "VERIFICARDOCUMENTOS";
|
|
querydatabase();
|
|
} 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);
|
|
Filter filtroSinImpresionSolicitud=new Filter();
|
|
filtroSinImpresionSolicitud.setSql("t.chkimpresion='Y' and t.pk.csolicitud = '" + solic.getPk() + "'");
|
|
dto.addFiltro(filtroSinImpresionSolicitud);
|
|
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 = (select o.csolicitud from TarmDocumentoHabilitante o where o.pk=t.pk.cdocumento))) "// 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 = (select o.csolicitud from TarmDocumentoHabilitante o where o.pk=t.pk.cdocumento)))");
|
|
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 = (select o.csolicitud from TarmDocumentoHabilitante o where o.pk=t.pk.cdocumento)))"
|
|
+ " and "
|
|
+ "i.pk.catalogcode = (select a.categoriacodigo from TarmTramite a where a.pk = (select s.ctramite from TarmSolicitud s where s.pk = (select o.csolicitud from TarmDocumentoHabilitante o where o.pk=t.pk.cdocumento)))");
|
|
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 = (select o.csolicitud from TarmDocumentoHabilitante o where o.pk=t.pk.cdocumento)))"
|
|
+ " and "
|
|
+ "i.pk.catalogcode = (select a.usoactividadcodigo from TarmTramite a where a.pk = (select s.ctramite from TarmSolicitud s where s.pk = (select o.csolicitud from TarmDocumentoHabilitante o where o.pk=t.pk.cdocumento)))");
|
|
dto.addSubQuery(qry4);
|
|
SubQuery qry42 = new SubQuery("TgeneCatalogDetail", "description", "tipoautodesc",
|
|
"i.pk.catalog = (select a.tipoautorizacion from TarmTramite a where a.pk = (select s.ctramite from TarmSolicitud s where s.pk = (select o.csolicitud from TarmDocumentoHabilitante o where o.pk=t.pk.cdocumento)))"
|
|
+ " and "
|
|
+ "i.pk.catalogcode = (select a.tipoautorizacioncodigo from TarmTramite a where a.pk = (select s.ctramite from TarmSolicitud s where s.pk = (select o.csolicitud from TarmDocumentoHabilitante o where o.pk=t.pk.cdocumento)))");
|
|
dto.addSubQuery(qry42);
|
|
|
|
|
|
//ubicacion
|
|
SubQuery qryUbicacion = new SubQuery("TgeneProvince", "description", "ubicaciondesc",
|
|
"i.pk.countrycode = 'EC'"
|
|
+ " and "
|
|
+ "i.pk.provincecode = (select a.provincecode from TcustPersonAddress a where a.pk.personcode =(select o.personcode from TarmDocumentoHabilitante o where o.pk= t.pk.cdocumento )"
|
|
+ " and a.principal='Y'"
|
|
+ " and a.pk.dateto = to_date('2999-12-31', 'YYYY-MM-DD') )");//
|
|
dto.addSubQuery(qryUbicacion);
|
|
//TarmSolicitudDocumento
|
|
|
|
SubQuery qry5 = new SubQuery("TarmDocumentoHabilitante", "fechaemision", "fechaemision", "i.pk= t.pk.cdocumento");
|
|
dto.addSubQuery(qry5);
|
|
SubQuery qry6 = new SubQuery("TarmDocumentoHabilitante", "fechaexpiracion", "fechaexpiracion", "i.pk= t.pk.cdocumento");
|
|
dto.addSubQuery(qry6);
|
|
SubQuery qry61 = new SubQuery("TarmDocumentoHabilitante", "estado ", "estado1", "i.pk= t.pk.cdocumento");
|
|
dto.addSubQuery(qry61);
|
|
SubQuery qry611 = new SubQuery("TarmDocumentoHabilitante", "estadocode ", "estado11", "i.pk= t.pk.cdocumento");
|
|
dto.addSubQuery(qry611);
|
|
SubQuery qry7 = new SubQuery("TgeneCatalogDetail", "description", "estado",
|
|
"i.pk.catalog = (select a.estado from TarmDocumentoHabilitante a where a.pk= t.pk.cdocumento) and "
|
|
+ "i.pk.catalogcode = (select a.estadocode from TarmDocumentoHabilitante a where a.pk= t.pk.cdocumento)");
|
|
dto.addSubQuery(qry7);
|
|
SubQuery qry8 = new SubQuery("TarmDocumentoHabilitante", "carma", "carma", "i.pk = t.pk.cdocumento and i.pk= t.pk.cdocumento");
|
|
dto.addSubQuery(qry8);
|
|
SubQuery qry9 = new SubQuery("TarmDocumentoHabilitante", "codigoarma", "codigoarma", "i.pk= t.pk.cdocumento");
|
|
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);
|
|
|
|
SubQuery qry11 = new SubQuery("TarmDocumentoHabilitante", "xpath", "xpath", "i.pk = t.pk.cdocumento ");
|
|
dto.addSubQuery(qry11);
|
|
/* Filter seleccionados = new Filter();
|
|
seleccionados.setSql("chkimpresion = 'Y'");
|
|
dto.getLfilter().add(seleccionados);*/
|
|
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 reimpresión
|
|
*/
|
|
public void lista(){
|
|
for (TarmSolicitudDocumento solicituddoc : lrecord) {
|
|
if(solicituddoc.getChkimpresion().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();
|
|
dtosave.setReturnpk(true);
|
|
/*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);
|
|
btnFlujo = true;
|
|
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 {
|
|
|
|
if(Boolean.valueOf(event.getComponent().getAttributes().get("value") != null ? event.getComponent().getAttributes().get("value").toString() : "false")){
|
|
this.valorColocar = Boolean.TRUE;
|
|
}else {
|
|
this.valorColocar = Boolean.FALSE;
|
|
}
|
|
for (TarmSolicitudDocumento solicituddoc : lrecord) {
|
|
solicituddoc.getModifiedData().put("verificado", valorColocar);
|
|
}
|
|
} catch (Throwable e) {
|
|
MessageHelper.setMessageError(e);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Metodo que verifica la eleccion del check
|
|
*/
|
|
public void verificar(){
|
|
for (TarmSolicitudDocumento solicituddoc : lrecord) {
|
|
if(solicituddoc.getChkimpresion() == "Y"){
|
|
this.verifica = true;
|
|
}else {
|
|
this.verifica = false;
|
|
}
|
|
}
|
|
}
|
|
/**
|
|
* Método que actualiza la elección del check
|
|
* @throws Exception
|
|
*/
|
|
public void actualizaVerificado() throws Exception{
|
|
for (TarmSolicitudDocumento solicituddoc : lrecord) {
|
|
if( solicituddoc.getModifiedData().get("verificado").equals(Boolean.TRUE)){
|
|
solicituddoc.setVerificado("Y");
|
|
}else {
|
|
solicituddoc.setVerificado("N");
|
|
}
|
|
record=solicituddoc;
|
|
super.update();
|
|
}
|
|
}
|
|
/**
|
|
* Método que habilita el botón imprimir según check seleccionado
|
|
* @param event
|
|
*/
|
|
public void habilitaImprimir(AjaxBehaviorEvent event){
|
|
try {
|
|
if(Boolean.valueOf(event.getComponent().getAttributes().get("value") != null ? event.getComponent().getAttributes().get("value").toString() : "false")){
|
|
this.habimprimir = Boolean.FALSE;
|
|
}else {
|
|
this.habimprimir = Boolean.TRUE;
|
|
}
|
|
|
|
} catch (Throwable e) {
|
|
MessageHelper.setMessageError(e);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 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")==null?"": arm.modifiedData.get("clase").toString());
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
}
|
|
try {
|
|
lrecord.get(i).getModifiedData().put("tipoarma",arm.modifiedData.get("tipo")==null?"": arm.modifiedData.get("tipo").toString());
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
}
|
|
try {
|
|
lrecord.get(i).getModifiedData().put("marcaarma", arm.modifiedData.get("marca")==null?"": arm.modifiedData.get("marca").toString());
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
}
|
|
try {
|
|
lrecord.get(i).getModifiedData().put("calibrearma", arm.modifiedData.get("calibre")==null?"": arm.modifiedData.get("calibre").toString());
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
}
|
|
try {
|
|
lrecord.get(i).getModifiedData().put("seriearma", arm.modifiedData.get("lote")==null?"": arm.modifiedData.get("lote").toString());
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Metodo para finalizar la tarea del flujo
|
|
*/
|
|
public void completarTarea() {
|
|
|
|
try {
|
|
|
|
Request request = callerhelper.getRequest();
|
|
// limpiar request para finalizar la tarea.
|
|
super.cleanRequest(request);
|
|
//request.modifiedData().put("csolicitud", this.solicitud.getPk());
|
|
request.modifiedData().put("TID", tid);
|
|
|
|
request.modifiedData().put("BPMStatus", bpmDataStatus == null ? "A" : bpmDataStatus);
|
|
|
|
// A,D,R
|
|
request.modifiedData().put("BPMObs", bpmDataComment == null ? "OK" : bpmDataComment);
|
|
|
|
Response resp = callerhelper.executeSave(request);
|
|
|
|
if (resp.getResponseCode().compareTo(Response.RESPONSE_OK) == 0) {
|
|
MessageHelper.setMessageInfo(resp);
|
|
btnFlujo=Boolean.FALSE;
|
|
RequestContext.getCurrentInstance().execute("Maia.refreshusertasks()");
|
|
} else {
|
|
MessageHelper.setMessageError(resp);
|
|
}
|
|
} catch (Throwable e) {
|
|
MessageHelper.setMessageError(e);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
public Boolean getHabimprimir() {
|
|
return habimprimir;
|
|
}
|
|
|
|
public void setHabimprimir(Boolean habimprimir) {
|
|
this.habimprimir = habimprimir;
|
|
}
|
|
|
|
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 AlfrescoController getAlfrescoController() {
|
|
return alfrescoController;
|
|
}
|
|
|
|
public void setAlfrescoController(AlfrescoController alfrescoController) {
|
|
this.alfrescoController = alfrescoController;
|
|
}
|
|
|
|
|
|
|
|
public void verifica(){
|
|
System.out.println("RECORD "+this.record);
|
|
}
|
|
|
|
public Boolean getValorColocar() {
|
|
return valorColocar;
|
|
}
|
|
|
|
public void setValorColocar(Boolean valorColocar) {
|
|
this.valorColocar = valorColocar;
|
|
}
|
|
|
|
public Boolean getBtnFlujo() {
|
|
return btnFlujo;
|
|
}
|
|
|
|
public void setBtnFlujo(Boolean btnFlujo) {
|
|
this.btnFlujo = btnFlujo;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|