Servicio de cola de impresion - Only Control
This commit is contained in:
parent
b698acb879
commit
9c615cc167
|
|
@ -21,209 +21,211 @@ import com.fp.persistence.parmas.soli.TarmDocumentoHabilitante;
|
||||||
import com.fp.persistence.parmas.soli.TarmSolicitud;
|
import com.fp.persistence.parmas.soli.TarmSolicitud;
|
||||||
|
|
||||||
public class ColaImpresionUtil {
|
public class ColaImpresionUtil {
|
||||||
|
|
||||||
public static final String QUERY_SOLICITUD_NUM = "SELECT o FROM TarmSolicitud o WHERE o.numerosolicitud=:numerosolicitud";
|
|
||||||
private static ColaImpresionUtil INSTANCIA = new ColaImpresionUtil();
|
|
||||||
|
|
||||||
private ColaImpresionUtil(){}
|
public static final String QUERY_SOLICITUD_NUM = "SELECT o FROM TarmSolicitud o WHERE o.numerosolicitud=:numerosolicitud";
|
||||||
|
private static ColaImpresionUtil INSTANCIA = new ColaImpresionUtil();
|
||||||
public static ColaImpresionUtil getInstancia() {
|
|
||||||
return INSTANCIA;
|
private ColaImpresionUtil() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public static ColaImpresionUtil getInstancia() {
|
||||||
* Método en el que se completa la información que se va a exponer en el web service
|
return INSTANCIA;
|
||||||
* @param coladeImpresionList una lista de {@link TarmColadeImpresion}
|
}
|
||||||
* @param personcode código de la persona
|
|
||||||
* @param usercode código del usuario
|
/**
|
||||||
* @return
|
* Método en el que se completa la información que se va a exponer en el web service
|
||||||
* @throws Exception
|
*
|
||||||
*/
|
* @param coladeImpresionList una lista de {@link TarmColadeImpresion}
|
||||||
@SuppressWarnings("unchecked")
|
* @param personcode código de la persona
|
||||||
public List<ColaImpresionDto> completaColaImpresion(List<TarmColadeImpresion> coladeImpresionList, Integer personcode, String usercode) throws Exception{
|
* @param usercode código del usuario
|
||||||
List<ColaImpresionDto> lcolaImpresion = null;
|
* @return
|
||||||
if(coladeImpresionList != null && !coladeImpresionList.isEmpty()){
|
* @throws Exception
|
||||||
lcolaImpresion = new ArrayList<ColaImpresionDto>();
|
*/
|
||||||
for (TarmColadeImpresion tarmColadeImpresion : coladeImpresionList) {
|
@SuppressWarnings("unchecked")
|
||||||
ColaImpresionDto colaImpresion = new ColaImpresionDto();
|
public List<ColaImpresionDto> completaColaImpresion(List<TarmColadeImpresion> coladeImpresionList, Integer personcode, String usercode) throws Exception {
|
||||||
colaImpresion.setIdImpresion(tarmColadeImpresion.getPk());
|
List<ColaImpresionDto> lcolaImpresion = null;
|
||||||
colaImpresion.setFechaImpresion(tarmColadeImpresion.getFechaimpresion());
|
if (coladeImpresionList != null && !coladeImpresionList.isEmpty()) {
|
||||||
colaImpresion.setFechaRegistro(new Timestamp(tarmColadeImpresion.getFecharegistro().getTime()));
|
lcolaImpresion = new ArrayList<ColaImpresionDto>();
|
||||||
|
for (TarmColadeImpresion tarmColadeImpresion : coladeImpresionList) {
|
||||||
TarmDocumentoHabilitante documento = TarmDocumentoHabilitante.find(PersistenceHelper.getEntityManager(), tarmColadeImpresion.getCdocumento());
|
ColaImpresionDto colaImpresion = new ColaImpresionDto();
|
||||||
PersonaDto personaDto = PersonaUtil.getInstancia().obtenerPersonaPorId(documento.getPersoncode(), usercode);
|
colaImpresion.setIdImpresion(tarmColadeImpresion.getPk());
|
||||||
colaImpresion.setPersona(personaDto);
|
colaImpresion.setFechaImpresion(tarmColadeImpresion.getFechaimpresion());
|
||||||
colaImpresion.setDocumento(obtenerDocumentoId(tarmColadeImpresion.getCdocumento(), personaDto));
|
colaImpresion.setFechaRegistro(new Timestamp(tarmColadeImpresion.getFecharegistro().getTime()));
|
||||||
|
|
||||||
List<TarmArmaPruebas> pruebas=null;
|
TarmDocumentoHabilitante documento = TarmDocumentoHabilitante.find(PersistenceHelper.getEntityManager(), tarmColadeImpresion.getCdocumento());
|
||||||
List<TarmArmaPruebas> pruebasRealizadasAlArma=null;
|
PersonaDto personaDto = PersonaUtil.getInstancia().obtenerPersonaPorId(documento.getPersoncode(), usercode);
|
||||||
if(colaImpresion.getDocumento()!=null && colaImpresion.getDocumento().getCarma()!=null){
|
colaImpresion.setPersona(personaDto);
|
||||||
StringBuilder sql = new StringBuilder("select o from TarmArmaPruebas o where o.pk=(select max(p.pk) from TarmArmaPruebas p where p.carma='"+colaImpresion.getDocumento().getCarma()+"' and p.apruebaevaluacion='Y')");
|
colaImpresion.setDocumento(obtenerDocumentoId(tarmColadeImpresion.getCdocumento(), personaDto));
|
||||||
System.out.println("sql....."+sql);
|
|
||||||
pruebas=PersistenceHelper.getEntityManager().createQuery(sql.toString()).getResultList();
|
List<TarmArmaPruebas> pruebas = null;
|
||||||
// Se valida si existe alguna prueba de registro balistico para el arma
|
List<TarmArmaPruebas> pruebasRealizadasAlArma = null;
|
||||||
StringBuilder sql2 = new StringBuilder("select o from TarmArmaPruebas o where o.carma='"+colaImpresion.getDocumento().getCarma()+"'");
|
if (colaImpresion.getDocumento() != null && colaImpresion.getDocumento().getCarma() != null) {
|
||||||
pruebasRealizadasAlArma=PersistenceHelper.getEntityManager().createQuery(sql2.toString()).getResultList();
|
StringBuilder sql = new StringBuilder("select o from TarmArmaPruebas o where o.pk=(select max(p.pk) from TarmArmaPruebas p where p.carma='" + colaImpresion.getDocumento().getCarma() + "' and p.apruebaevaluacion='Y')");
|
||||||
}
|
System.out.println("sql....." + sql);
|
||||||
|
pruebas = PersistenceHelper.getEntityManager().createQuery(sql.toString()).getResultList();
|
||||||
if(pruebas!=null && pruebas.size()>0){
|
// Se valida si existe alguna prueba de registro balistico para el arma
|
||||||
//ingresa el arma
|
StringBuilder sql2 = new StringBuilder("select o from TarmArmaPruebas o where o.carma='" + colaImpresion.getDocumento().getCarma() + "'");
|
||||||
ArmaDto arma=ArmaUtil.getInstancia().obtenerArmaId(colaImpresion.getDocumento().getCarma());
|
pruebasRealizadasAlArma = PersistenceHelper.getEntityManager().createQuery(sql2.toString()).getResultList();
|
||||||
colaImpresion.setArma(arma);
|
}
|
||||||
colaImpresion.setEsAutorizacion(verificaTipoTramite(colaImpresion.getDocumento().getNumeroSolicitud()));
|
|
||||||
lcolaImpresion.add(colaImpresion);
|
if (pruebas != null && pruebas.size() > 0) {
|
||||||
}else if(pruebas!=null && pruebas.size()==0 && pruebasRealizadasAlArma.isEmpty()){
|
//ingresa el arma
|
||||||
// Usado para los datos migrados que no fueron ingresados por solicitud y no tienen prueba de registro balistico
|
ArmaDto arma = ArmaUtil.getInstancia().obtenerArmaId(colaImpresion.getDocumento().getCarma());
|
||||||
ArmaDto arma=ArmaUtil.getInstancia().obtenerArmaId(colaImpresion.getDocumento().getCarma());
|
colaImpresion.setArma(arma);
|
||||||
if(arma!=null && arma.getIdArma()!=null){
|
colaImpresion.setEsAutorizacion(verificaTipoTramite(colaImpresion.getDocumento().getNumeroSolicitud()));
|
||||||
colaImpresion.setArma(arma);
|
lcolaImpresion.add(colaImpresion);
|
||||||
colaImpresion.setEsAutorizacion(verificaTipoTramite(colaImpresion.getDocumento().getNumeroSolicitud()));
|
} else if (pruebas != null && pruebas.size() == 0 && pruebasRealizadasAlArma.isEmpty()) {
|
||||||
lcolaImpresion.add(colaImpresion);
|
// Usado para los datos migrados que no fueron ingresados por solicitud y no tienen prueba de registro balistico
|
||||||
}
|
ArmaDto arma = ArmaUtil.getInstancia().obtenerArmaId(colaImpresion.getDocumento().getCarma());
|
||||||
|
if (arma != null && arma.getIdArma() != null) {
|
||||||
}else if(colaImpresion.getDocumento().getCarma()==null || colaImpresion.getDocumento().getCarma().trim().length()==0){
|
colaImpresion.setArma(arma);
|
||||||
colaImpresion.setArma(null);
|
colaImpresion.setEsAutorizacion(verificaTipoTramite(colaImpresion.getDocumento().getNumeroSolicitud()));
|
||||||
System.out.println("numsilicitud.1....."+colaImpresion.getDocumento().getNumeroSolicitud());
|
lcolaImpresion.add(colaImpresion);
|
||||||
colaImpresion.setEsAutorizacion(verificaTipoTramite(colaImpresion.getDocumento().getNumeroSolicitud()));
|
}
|
||||||
lcolaImpresion.add(colaImpresion);
|
|
||||||
}
|
} else if (colaImpresion.getDocumento().getCarma() == null || colaImpresion.getDocumento().getCarma().trim().length() == 0) {
|
||||||
}
|
colaImpresion.setArma(null);
|
||||||
}
|
System.out.println("numsilicitud.1....." + colaImpresion.getDocumento().getNumeroSolicitud());
|
||||||
return lcolaImpresion;
|
colaImpresion.setEsAutorizacion(verificaTipoTramite(colaImpresion.getDocumento().getNumeroSolicitud()));
|
||||||
}
|
lcolaImpresion.add(colaImpresion);
|
||||||
|
}
|
||||||
/**
|
}
|
||||||
* Devuelve la cola de impresión con los datos completos
|
}
|
||||||
* @param coladeImpresionList
|
return lcolaImpresion;
|
||||||
* @return
|
}
|
||||||
* @throws Exception
|
|
||||||
*/
|
/**
|
||||||
@SuppressWarnings("unchecked")
|
* Devuelve la cola de impresión con los datos completos
|
||||||
public List<ColaImpresionDto> completaColaImpresion(List<TarmColadeImpresion> coladeImpresionList) throws Exception {
|
*
|
||||||
List<ColaImpresionDto> lcolaImpresion = null;
|
* @param coladeImpresionList
|
||||||
if(coladeImpresionList != null && !coladeImpresionList.isEmpty()){
|
* @return
|
||||||
lcolaImpresion = new ArrayList<ColaImpresionDto>();
|
* @throws Exception
|
||||||
for (TarmColadeImpresion tarmColadeImpresion : coladeImpresionList) {
|
*/
|
||||||
TarmDocumentoHabilitante tarmDocumentoHabilitante = PersistenceHelper.getEntityManager().find(TarmDocumentoHabilitante.class, tarmColadeImpresion.getCdocumento());
|
@SuppressWarnings("unchecked")
|
||||||
if(tarmDocumentoHabilitante != null){
|
public List<ColaImpresionDto> completaColaImpresion(List<TarmColadeImpresion> coladeImpresionList) throws Exception {
|
||||||
ColaImpresionDto colaImpresion = new ColaImpresionDto();
|
List<ColaImpresionDto> lcolaImpresion = null;
|
||||||
colaImpresion.setIdImpresion(tarmColadeImpresion.getPk());
|
if (coladeImpresionList != null && !coladeImpresionList.isEmpty()) {
|
||||||
colaImpresion.setFechaImpresion(tarmColadeImpresion.getFechaimpresion());
|
lcolaImpresion = new ArrayList<ColaImpresionDto>();
|
||||||
colaImpresion.setFechaRegistro(new Timestamp(tarmColadeImpresion.getFecharegistro().getTime()));
|
for (TarmColadeImpresion tarmColadeImpresion : coladeImpresionList) {
|
||||||
PersonaDto personaDto = PersonaUtil.getInstancia().obtenerPersonaPorId(tarmDocumentoHabilitante.getPersoncode(), null);
|
TarmDocumentoHabilitante tarmDocumentoHabilitante = PersistenceHelper.getEntityManager().find(TarmDocumentoHabilitante.class, tarmColadeImpresion.getCdocumento());
|
||||||
colaImpresion.setPersona(personaDto);
|
if (tarmDocumentoHabilitante != null) {
|
||||||
colaImpresion.setDocumento(obtenerDocumentoId(tarmColadeImpresion.getCdocumento(), personaDto));
|
ColaImpresionDto colaImpresion = new ColaImpresionDto();
|
||||||
|
colaImpresion.setIdImpresion(tarmColadeImpresion.getPk());
|
||||||
List<TarmArmaPruebas> pruebas=null;
|
colaImpresion.setFechaImpresion(tarmColadeImpresion.getFechaimpresion());
|
||||||
List<TarmArmaPruebas> pruebasRealizadasAlArma=null;
|
colaImpresion.setFechaRegistro(new Timestamp(tarmColadeImpresion.getFecharegistro().getTime()));
|
||||||
if(colaImpresion.getDocumento()!=null && colaImpresion.getDocumento().getCarma()!=null){
|
PersonaDto personaDto = PersonaUtil.getInstancia().obtenerPersonaPorId(tarmDocumentoHabilitante.getPersoncode(), null);
|
||||||
StringBuilder sql = new StringBuilder("select o from TarmArmaPruebas o where o.pk=(select max(p.pk) from TarmArmaPruebas p where p.carma='"+colaImpresion.getDocumento().getCarma()+"' and p.apruebaevaluacion='Y')");
|
colaImpresion.setPersona(personaDto);
|
||||||
|
colaImpresion.setDocumento(obtenerDocumentoId(tarmColadeImpresion.getCdocumento(), personaDto));
|
||||||
|
|
||||||
|
List<TarmArmaPruebas> pruebas = null;
|
||||||
|
List<TarmArmaPruebas> pruebasRealizadasAlArma = null;
|
||||||
|
if (colaImpresion.getDocumento() != null && colaImpresion.getDocumento().getCarma() != null) {
|
||||||
|
StringBuilder sql = new StringBuilder("select o from TarmArmaPruebas o where o.pk=(select max(p.pk) from TarmArmaPruebas p where p.carma='" + colaImpresion.getDocumento().getCarma() + "' and p.apruebaevaluacion='Y')");
|
||||||
// System.out.println("sql....."+sql);
|
// System.out.println("sql....."+sql);
|
||||||
pruebas=PersistenceHelper.getEntityManager().createQuery(sql.toString()).getResultList();
|
pruebas = PersistenceHelper.getEntityManager().createQuery(sql.toString()).getResultList();
|
||||||
// Se valida si existe alguna prueba de registro balistico para el arma
|
// Se valida si existe alguna prueba de registro balistico para el arma
|
||||||
StringBuilder sql2 = new StringBuilder("select o from TarmArmaPruebas o where o.carma='"+colaImpresion.getDocumento().getCarma()+"'");
|
StringBuilder sql2 = new StringBuilder("select o from TarmArmaPruebas o where o.carma='" + colaImpresion.getDocumento().getCarma() + "'");
|
||||||
pruebasRealizadasAlArma=PersistenceHelper.getEntityManager().createQuery(sql2.toString()).getResultList();
|
pruebasRealizadasAlArma = PersistenceHelper.getEntityManager().createQuery(sql2.toString()).getResultList();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(pruebas!=null && pruebas.size()>0){
|
|
||||||
colaImpresion.setArma(ArmaUtil.getInstancia().obtenerArmaId(colaImpresion.getDocumento().getCarma()));
|
|
||||||
colaImpresion.setEsAutorizacion(verificaTipoTramite(colaImpresion.getDocumento().getNumeroSolicitud()));
|
|
||||||
lcolaImpresion.add(colaImpresion);
|
|
||||||
}else if(pruebas!=null && pruebas.size()==0 && pruebasRealizadasAlArma.isEmpty()){
|
|
||||||
// Usado para los datos migrados que no fueron ingresados por solicitud y no tienen prueba de registro balistico
|
|
||||||
ArmaDto arma=ArmaUtil.getInstancia().obtenerArmaId(colaImpresion.getDocumento().getCarma());
|
|
||||||
if(arma!=null && arma.getIdArma()!=null){
|
|
||||||
colaImpresion.setArma(arma);
|
|
||||||
colaImpresion.setEsAutorizacion(verificaTipoTramite(colaImpresion.getDocumento().getNumeroSolicitud()));
|
|
||||||
lcolaImpresion.add(colaImpresion);
|
|
||||||
}
|
|
||||||
|
|
||||||
}else if(colaImpresion.getDocumento().getCarma()==null || colaImpresion.getDocumento().getCarma().trim().length()==0){
|
|
||||||
colaImpresion.setArma(null);
|
|
||||||
// System.out.println("numsilicitud.2....."+colaImpresion.getDocumento().getNumeroSolicitud());
|
|
||||||
colaImpresion.setEsAutorizacion(verificaTipoTramite(colaImpresion.getDocumento().getNumeroSolicitud()));
|
|
||||||
lcolaImpresion.add(colaImpresion);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return lcolaImpresion;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Devuelve un documento en base al id enviado
|
|
||||||
* @param codigoDocumento
|
|
||||||
* @param personaDto
|
|
||||||
* @return DocumentoDto
|
|
||||||
*/
|
|
||||||
public DocumentoDto obtenerDocumentoId(Long codigoDocumento, PersonaDto personaDto){
|
|
||||||
DocumentoDto documento = null;
|
|
||||||
TarmDocumentoHabilitante tarmDocumentoHabilitante = PersistenceHelper.getEntityManager().find(TarmDocumentoHabilitante.class, codigoDocumento);
|
|
||||||
if(tarmDocumentoHabilitante != null){
|
|
||||||
documento = new DocumentoDto();
|
|
||||||
documento.setCodigoDocumento(tarmDocumentoHabilitante.getPk());
|
|
||||||
documento.setFechaEmision(tarmDocumentoHabilitante.getFechaemision());
|
|
||||||
documento.setFechaExpiracion(tarmDocumentoHabilitante.getFechaexpiracion());
|
|
||||||
documento.setNumeroDocumento(tarmDocumentoHabilitante.getNumerodocumento());
|
|
||||||
if(tarmDocumentoHabilitante.getCsolicitud()!=null){
|
|
||||||
procesaDatosTramite(documento, tarmDocumentoHabilitante.getCsolicitud());
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
String querySolicitud = "select max(csolicitud) from tarmsolicituddocumento where cdocumento = '"+codigoDocumento.toString()+"'";
|
|
||||||
String codigosolicitud = PersistenceHelper.getEntityManager().createNativeQuery(querySolicitud).getSingleResult().toString();
|
|
||||||
if(codigosolicitud!=null){
|
|
||||||
procesaDatosTramite(documento, codigosolicitud);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
documento.setCarma(tarmDocumentoHabilitante.getCarma());
|
|
||||||
if(tarmDocumentoHabilitante.getCtramite() != null){//buscamos datos del tramite
|
|
||||||
try {
|
|
||||||
TarmTramite tarmTramite = TarmTramite.find(PersistenceHelper.getEntityManager(), tarmDocumentoHabilitante.getCtramite());
|
|
||||||
if(tarmTramite != null){
|
|
||||||
documento.setTipoTramite(CatalogoUtil.getInstancia().getDescripcion(tarmTramite.getTipotramite(), tarmTramite.getTipotramitecodigo()));
|
|
||||||
documento.setTramite(CatalogoUtil.getInstancia().getDescripcion(tarmTramite.getTipoautorizacion(), tarmTramite.getTipoautorizacioncodigo()));
|
|
||||||
documento.setCategoria(CatalogoUtil.getInstancia().getDescripcion(tarmTramite.getCategoria(), tarmTramite.getCategoriacodigo()));
|
|
||||||
documento.setUsoActividad(CatalogoUtil.getInstancia().getDescripcion(tarmTramite.getUsoactividad(), tarmTramite.getUsoactividadcodigo()));
|
|
||||||
documento.setEsFechaExpiracion(tarmTramite.getValidaFechaExpiracion());
|
|
||||||
documento.setDescripcion(tarmTramite.getVisualizarPorFechaExpiracion());
|
|
||||||
documento.setDescripcion1(buscarJuri(CatalogoUtil.getInstancia().getDescripcion(tarmTramite.getJurisdiccion(), tarmTramite.getJurisdiccioncode()), personaDto));
|
|
||||||
|
|
||||||
documento.setDescripcion2(tarmTramite.getPie());
|
|
||||||
}
|
|
||||||
} catch (CommondbException e) {
|
|
||||||
} catch (Exception e) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return documento;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Devuelve la jurisdiccion con el valor de la misma, sea direccion con la
|
|
||||||
* respectiva direccion de la persona que le emiten el carnet.
|
|
||||||
*
|
|
||||||
* @param descripcion
|
|
||||||
* @param personaDto
|
|
||||||
* @return String
|
|
||||||
*/
|
|
||||||
private String buscarJuri(String descripcion, PersonaDto personaDto) {
|
|
||||||
StringBuilder srtDescrip = new StringBuilder();
|
|
||||||
srtDescrip.append(descripcion);
|
|
||||||
if (!descripcion.equals("ECUADOR")) {
|
|
||||||
srtDescrip.append(": ");
|
|
||||||
if (descripcion.equals("PROVINCIA")) {
|
|
||||||
srtDescrip.append(personaDto.getProvincia());
|
|
||||||
} else if (descripcion.equals("CANTÓN")) {
|
|
||||||
srtDescrip.append(personaDto.getCanton());
|
|
||||||
} else if (descripcion.equals("PARROQUIA")) {
|
|
||||||
srtDescrip.append(personaDto.getParroquia());
|
|
||||||
} else if (descripcion.equals("DIRECCIÓN")) {
|
|
||||||
srtDescrip.append(personaDto.getDireccion());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return srtDescrip.toString();
|
if (pruebas != null && pruebas.size() > 0) {
|
||||||
}
|
colaImpresion.setArma(ArmaUtil.getInstancia().obtenerArmaId(colaImpresion.getDocumento().getCarma()));
|
||||||
|
colaImpresion.setEsAutorizacion(verificaTipoTramite(colaImpresion.getDocumento().getNumeroSolicitud()));
|
||||||
|
lcolaImpresion.add(colaImpresion);
|
||||||
|
} else if (pruebas != null && pruebas.size() == 0 && pruebasRealizadasAlArma.isEmpty()) {
|
||||||
|
// Usado para los datos migrados que no fueron ingresados por solicitud y no tienen prueba de registro balistico
|
||||||
|
ArmaDto arma = ArmaUtil.getInstancia().obtenerArmaId(colaImpresion.getDocumento().getCarma());
|
||||||
|
if (arma != null && arma.getIdArma() != null) {
|
||||||
|
colaImpresion.setArma(arma);
|
||||||
|
colaImpresion.setEsAutorizacion(verificaTipoTramite(colaImpresion.getDocumento().getNumeroSolicitud()));
|
||||||
|
lcolaImpresion.add(colaImpresion);
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if (colaImpresion.getDocumento().getCarma() == null || colaImpresion.getDocumento().getCarma().trim().length() == 0) {
|
||||||
|
colaImpresion.setArma(null);
|
||||||
|
// System.out.println("numsilicitud.2....."+colaImpresion.getDocumento().getNumeroSolicitud());
|
||||||
|
colaImpresion.setEsAutorizacion(verificaTipoTramite(colaImpresion.getDocumento().getNumeroSolicitud()));
|
||||||
|
lcolaImpresion.add(colaImpresion);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return lcolaImpresion;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Devuelve un documento en base al id enviado
|
||||||
|
*
|
||||||
|
* @param codigoDocumento
|
||||||
|
* @param personaDto
|
||||||
|
* @return DocumentoDto
|
||||||
|
*/
|
||||||
|
public DocumentoDto obtenerDocumentoId(Long codigoDocumento, PersonaDto personaDto) {
|
||||||
|
DocumentoDto documento = null;
|
||||||
|
TarmDocumentoHabilitante tarmDocumentoHabilitante = PersistenceHelper.getEntityManager().find(TarmDocumentoHabilitante.class, codigoDocumento);
|
||||||
|
if (tarmDocumentoHabilitante != null) {
|
||||||
|
documento = new DocumentoDto();
|
||||||
|
documento.setCodigoDocumento(tarmDocumentoHabilitante.getPk());
|
||||||
|
documento.setFechaEmision(tarmDocumentoHabilitante.getFechaemision());
|
||||||
|
documento.setFechaExpiracion(tarmDocumentoHabilitante.getFechaexpiracion());
|
||||||
|
documento.setNumeroDocumento(tarmDocumentoHabilitante.getNumerodocumento());
|
||||||
|
if (tarmDocumentoHabilitante.getCsolicitud() != null) {
|
||||||
|
procesaDatosTramite(documento, tarmDocumentoHabilitante.getCsolicitud());
|
||||||
|
} else {
|
||||||
|
String querySolicitud = "select max(csolicitud) from tarmsolicituddocumento where cdocumento = '" + codigoDocumento + "'";
|
||||||
|
String codigosolicitud = PersistenceHelper.getEntityManager().createNativeQuery(querySolicitud).getSingleResult().toString();
|
||||||
|
if (codigosolicitud != null) {
|
||||||
|
procesaDatosTramite(documento, codigosolicitud);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
documento.setCarma(tarmDocumentoHabilitante.getCarma());
|
||||||
|
if (tarmDocumentoHabilitante.getCtramite() != null) {//buscamos datos del tramite
|
||||||
|
try {
|
||||||
|
TarmTramite tarmTramite = TarmTramite.find(PersistenceHelper.getEntityManager(), tarmDocumentoHabilitante.getCtramite());
|
||||||
|
if (tarmTramite != null) {
|
||||||
|
documento.setTipoTramite(CatalogoUtil.getInstancia().getDescripcion(tarmTramite.getTipotramite(), tarmTramite.getTipotramitecodigo()));
|
||||||
|
documento.setTramite(CatalogoUtil.getInstancia().getDescripcion(tarmTramite.getTipoautorizacion(), tarmTramite.getTipoautorizacioncodigo()));
|
||||||
|
documento.setCategoria(CatalogoUtil.getInstancia().getDescripcion(tarmTramite.getCategoria(), tarmTramite.getCategoriacodigo()));
|
||||||
|
documento.setUsoActividad(CatalogoUtil.getInstancia().getDescripcion(tarmTramite.getUsoactividad(), tarmTramite.getUsoactividadcodigo()));
|
||||||
|
documento.setEsFechaExpiracion(tarmTramite.getValidaFechaExpiracion());
|
||||||
|
documento.setDescripcion(tarmTramite.getVisualizarPorFechaExpiracion());
|
||||||
|
documento.setDescripcion1(buscarJuri(CatalogoUtil.getInstancia().getDescripcion(tarmTramite.getJurisdiccion(), tarmTramite.getJurisdiccioncode()), personaDto));
|
||||||
|
|
||||||
|
documento.setDescripcion2(tarmTramite.getPie());
|
||||||
|
}
|
||||||
|
} catch (CommondbException e) {
|
||||||
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return documento;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Devuelve la jurisdiccion con el valor de la misma, sea direccion con la respectiva direccion de la persona que le emiten el carnet.
|
||||||
|
*
|
||||||
|
* @param descripcion
|
||||||
|
* @param personaDto
|
||||||
|
* @return String
|
||||||
|
*/
|
||||||
|
private String buscarJuri(String descripcion, PersonaDto personaDto) {
|
||||||
|
StringBuilder srtDescrip = new StringBuilder();
|
||||||
|
srtDescrip.append(descripcion);
|
||||||
|
if (!descripcion.equals("ECUADOR")) {
|
||||||
|
srtDescrip.append(": ");
|
||||||
|
if (descripcion.equals("PROVINCIA")) {
|
||||||
|
srtDescrip.append(personaDto.getProvincia());
|
||||||
|
} else if (descripcion.equals("CANTÓN")) {
|
||||||
|
srtDescrip.append(personaDto.getCanton());
|
||||||
|
} else if (descripcion.equals("PARROQUIA")) {
|
||||||
|
srtDescrip.append(personaDto.getParroquia());
|
||||||
|
} else if (descripcion.equals("DIRECCIÓN")) {
|
||||||
|
srtDescrip.append(personaDto.getDireccion());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return srtDescrip.toString();
|
||||||
|
}
|
||||||
|
|
||||||
// public String getNumeroSolicitud(String csolicitud) {
|
// public String getNumeroSolicitud(String csolicitud) {
|
||||||
// String numerosolicitud = null;
|
// String numerosolicitud = null;
|
||||||
|
|
@ -239,50 +241,51 @@ public class ColaImpresionUtil {
|
||||||
//
|
//
|
||||||
// return numerosolicitud;
|
// return numerosolicitud;
|
||||||
// }
|
// }
|
||||||
|
/**
|
||||||
/**
|
* Verifica si es o no autorización
|
||||||
* Verifica si es o no autorización
|
*
|
||||||
* @param numerosolicitud
|
* @param numerosolicitud
|
||||||
* @return
|
* @return
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
* @throws CommondbException
|
* @throws CommondbException
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public String verificaTipoTramite(String numerosolicitud) throws CommondbException, Exception {
|
public String verificaTipoTramite(String numerosolicitud) throws CommondbException, Exception {
|
||||||
String tipoTramite = null;
|
String tipoTramite = null;
|
||||||
if(numerosolicitud != null){
|
if (numerosolicitud != null) {
|
||||||
Query query = PersistenceHelper.getEntityManager().createQuery(QUERY_SOLICITUD_NUM);
|
Query query = PersistenceHelper.getEntityManager().createQuery(QUERY_SOLICITUD_NUM);
|
||||||
query.setParameter("numerosolicitud", numerosolicitud);
|
query.setParameter("numerosolicitud", numerosolicitud);
|
||||||
List<TarmSolicitud> ltarmSolicitud = query.getResultList();
|
List<TarmSolicitud> ltarmSolicitud = query.getResultList();
|
||||||
if(ltarmSolicitud != null && !ltarmSolicitud.isEmpty()){
|
if (ltarmSolicitud != null && !ltarmSolicitud.isEmpty()) {
|
||||||
TarmSolicitud tarmSolicitud = ltarmSolicitud.iterator().next();
|
TarmSolicitud tarmSolicitud = ltarmSolicitud.iterator().next();
|
||||||
TarmTramite tarmTramite = TarmTramite.find(PersistenceHelper.getEntityManager(), tarmSolicitud.getCtramite());
|
TarmTramite tarmTramite = TarmTramite.find(PersistenceHelper.getEntityManager(), tarmSolicitud.getCtramite());
|
||||||
if(tarmTramite.getTipoautorizacion().equals("1") && tarmTramite.getTipoautorizacioncodigo().equals("TIPOAUTORIZACION")){
|
if (tarmTramite.getTipoautorizacion().equals("1") && tarmTramite.getTipoautorizacioncodigo().equals("TIPOAUTORIZACION")) {
|
||||||
tipoTramite = Constant.STR_Y;
|
tipoTramite = Constant.STR_Y;
|
||||||
} else if(tarmTramite.getTipoautorizacion().equals("6") && tarmTramite.getTipoautorizacioncodigo().equals("TIPOAUTORIZACION")){
|
} else if (tarmTramite.getTipoautorizacion().equals("6") && tarmTramite.getTipoautorizacioncodigo().equals("TIPOAUTORIZACION")) {
|
||||||
tipoTramite = Constant.STR_N;
|
tipoTramite = Constant.STR_N;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return tipoTramite;
|
return tipoTramite;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Procesa datos del trámite y completa la información
|
* Procesa datos del trámite y completa la información
|
||||||
* @param documento
|
*
|
||||||
* @param csolicitud
|
* @param documento
|
||||||
*/
|
* @param csolicitud
|
||||||
private void procesaDatosTramite(DocumentoDto documento, String csolicitud){
|
*/
|
||||||
TarmSolicitud tarmSolicitud;
|
private void procesaDatosTramite(DocumentoDto documento, String csolicitud) {
|
||||||
try {
|
TarmSolicitud tarmSolicitud;
|
||||||
tarmSolicitud = TarmSolicitud.find(PersistenceHelper.getEntityManager(), csolicitud);
|
try {
|
||||||
if(tarmSolicitud != null){
|
tarmSolicitud = TarmSolicitud.find(PersistenceHelper.getEntityManager(), csolicitud);
|
||||||
documento.setNumeroSolicitud(tarmSolicitud.getNumerosolicitud());
|
if (tarmSolicitud != null) {
|
||||||
documento.setEstadoTramite(CatalogoUtil.getInstancia().getDescripcion(tarmSolicitud.getEstado(), tarmSolicitud.getEstadocodigo()));
|
documento.setNumeroSolicitud(tarmSolicitud.getNumerosolicitud());
|
||||||
}
|
documento.setEstadoTramite(CatalogoUtil.getInstancia().getDescripcion(tarmSolicitud.getEstado(), tarmSolicitud.getEstadocodigo()));
|
||||||
} catch (Exception e) {
|
}
|
||||||
APPLogger.getLogger().error(e.getMessage(), e);
|
} catch (Exception e) {
|
||||||
}
|
APPLogger.getLogger().error(e.getMessage(), e);
|
||||||
|
}
|
||||||
}
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue