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;
|
||||
|
||||
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 ColaImpresionUtil getInstancia() {
|
||||
return INSTANCIA;
|
||||
}
|
||||
|
||||
/**
|
||||
* Método en el que se completa la información que se va a exponer en el web service
|
||||
* @param coladeImpresionList una lista de {@link TarmColadeImpresion}
|
||||
* @param personcode código de la persona
|
||||
* @param usercode código del usuario
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<ColaImpresionDto> completaColaImpresion(List<TarmColadeImpresion> coladeImpresionList, Integer personcode, String usercode) throws Exception{
|
||||
List<ColaImpresionDto> lcolaImpresion = null;
|
||||
if(coladeImpresionList != null && !coladeImpresionList.isEmpty()){
|
||||
lcolaImpresion = new ArrayList<ColaImpresionDto>();
|
||||
for (TarmColadeImpresion tarmColadeImpresion : coladeImpresionList) {
|
||||
ColaImpresionDto colaImpresion = new ColaImpresionDto();
|
||||
colaImpresion.setIdImpresion(tarmColadeImpresion.getPk());
|
||||
colaImpresion.setFechaImpresion(tarmColadeImpresion.getFechaimpresion());
|
||||
colaImpresion.setFechaRegistro(new Timestamp(tarmColadeImpresion.getFecharegistro().getTime()));
|
||||
|
||||
TarmDocumentoHabilitante documento = TarmDocumentoHabilitante.find(PersistenceHelper.getEntityManager(), tarmColadeImpresion.getCdocumento());
|
||||
PersonaDto personaDto = PersonaUtil.getInstancia().obtenerPersonaPorId(documento.getPersoncode(), usercode);
|
||||
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);
|
||||
pruebas=PersistenceHelper.getEntityManager().createQuery(sql.toString()).getResultList();
|
||||
// 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()+"'");
|
||||
pruebasRealizadasAlArma=PersistenceHelper.getEntityManager().createQuery(sql2.toString()).getResultList();
|
||||
}
|
||||
|
||||
if(pruebas!=null && pruebas.size()>0){
|
||||
//ingresa el arma
|
||||
ArmaDto arma=ArmaUtil.getInstancia().obtenerArmaId(colaImpresion.getDocumento().getCarma());
|
||||
colaImpresion.setArma(arma);
|
||||
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.1....."+colaImpresion.getDocumento().getNumeroSolicitud());
|
||||
colaImpresion.setEsAutorizacion(verificaTipoTramite(colaImpresion.getDocumento().getNumeroSolicitud()));
|
||||
lcolaImpresion.add(colaImpresion);
|
||||
}
|
||||
}
|
||||
}
|
||||
return lcolaImpresion;
|
||||
}
|
||||
|
||||
/**
|
||||
* Devuelve la cola de impresión con los datos completos
|
||||
* @param coladeImpresionList
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<ColaImpresionDto> completaColaImpresion(List<TarmColadeImpresion> coladeImpresionList) throws Exception {
|
||||
List<ColaImpresionDto> lcolaImpresion = null;
|
||||
if(coladeImpresionList != null && !coladeImpresionList.isEmpty()){
|
||||
lcolaImpresion = new ArrayList<ColaImpresionDto>();
|
||||
for (TarmColadeImpresion tarmColadeImpresion : coladeImpresionList) {
|
||||
TarmDocumentoHabilitante tarmDocumentoHabilitante = PersistenceHelper.getEntityManager().find(TarmDocumentoHabilitante.class, tarmColadeImpresion.getCdocumento());
|
||||
if(tarmDocumentoHabilitante != null){
|
||||
ColaImpresionDto colaImpresion = new ColaImpresionDto();
|
||||
colaImpresion.setIdImpresion(tarmColadeImpresion.getPk());
|
||||
colaImpresion.setFechaImpresion(tarmColadeImpresion.getFechaimpresion());
|
||||
colaImpresion.setFechaRegistro(new Timestamp(tarmColadeImpresion.getFecharegistro().getTime()));
|
||||
PersonaDto personaDto = PersonaUtil.getInstancia().obtenerPersonaPorId(tarmDocumentoHabilitante.getPersoncode(), null);
|
||||
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')");
|
||||
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 ColaImpresionUtil getInstancia() {
|
||||
return INSTANCIA;
|
||||
}
|
||||
|
||||
/**
|
||||
* Método en el que se completa la información que se va a exponer en el web service
|
||||
*
|
||||
* @param coladeImpresionList una lista de {@link TarmColadeImpresion}
|
||||
* @param personcode código de la persona
|
||||
* @param usercode código del usuario
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<ColaImpresionDto> completaColaImpresion(List<TarmColadeImpresion> coladeImpresionList, Integer personcode, String usercode) throws Exception {
|
||||
List<ColaImpresionDto> lcolaImpresion = null;
|
||||
if (coladeImpresionList != null && !coladeImpresionList.isEmpty()) {
|
||||
lcolaImpresion = new ArrayList<ColaImpresionDto>();
|
||||
for (TarmColadeImpresion tarmColadeImpresion : coladeImpresionList) {
|
||||
ColaImpresionDto colaImpresion = new ColaImpresionDto();
|
||||
colaImpresion.setIdImpresion(tarmColadeImpresion.getPk());
|
||||
colaImpresion.setFechaImpresion(tarmColadeImpresion.getFechaimpresion());
|
||||
colaImpresion.setFechaRegistro(new Timestamp(tarmColadeImpresion.getFecharegistro().getTime()));
|
||||
|
||||
TarmDocumentoHabilitante documento = TarmDocumentoHabilitante.find(PersistenceHelper.getEntityManager(), tarmColadeImpresion.getCdocumento());
|
||||
PersonaDto personaDto = PersonaUtil.getInstancia().obtenerPersonaPorId(documento.getPersoncode(), usercode);
|
||||
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);
|
||||
pruebas = PersistenceHelper.getEntityManager().createQuery(sql.toString()).getResultList();
|
||||
// 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() + "'");
|
||||
pruebasRealizadasAlArma = PersistenceHelper.getEntityManager().createQuery(sql2.toString()).getResultList();
|
||||
}
|
||||
|
||||
if (pruebas != null && pruebas.size() > 0) {
|
||||
//ingresa el arma
|
||||
ArmaDto arma = ArmaUtil.getInstancia().obtenerArmaId(colaImpresion.getDocumento().getCarma());
|
||||
colaImpresion.setArma(arma);
|
||||
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.1....." + colaImpresion.getDocumento().getNumeroSolicitud());
|
||||
colaImpresion.setEsAutorizacion(verificaTipoTramite(colaImpresion.getDocumento().getNumeroSolicitud()));
|
||||
lcolaImpresion.add(colaImpresion);
|
||||
}
|
||||
}
|
||||
}
|
||||
return lcolaImpresion;
|
||||
}
|
||||
|
||||
/**
|
||||
* Devuelve la cola de impresión con los datos completos
|
||||
*
|
||||
* @param coladeImpresionList
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<ColaImpresionDto> completaColaImpresion(List<TarmColadeImpresion> coladeImpresionList) throws Exception {
|
||||
List<ColaImpresionDto> lcolaImpresion = null;
|
||||
if (coladeImpresionList != null && !coladeImpresionList.isEmpty()) {
|
||||
lcolaImpresion = new ArrayList<ColaImpresionDto>();
|
||||
for (TarmColadeImpresion tarmColadeImpresion : coladeImpresionList) {
|
||||
TarmDocumentoHabilitante tarmDocumentoHabilitante = PersistenceHelper.getEntityManager().find(TarmDocumentoHabilitante.class, tarmColadeImpresion.getCdocumento());
|
||||
if (tarmDocumentoHabilitante != null) {
|
||||
ColaImpresionDto colaImpresion = new ColaImpresionDto();
|
||||
colaImpresion.setIdImpresion(tarmColadeImpresion.getPk());
|
||||
colaImpresion.setFechaImpresion(tarmColadeImpresion.getFechaimpresion());
|
||||
colaImpresion.setFechaRegistro(new Timestamp(tarmColadeImpresion.getFecharegistro().getTime()));
|
||||
PersonaDto personaDto = PersonaUtil.getInstancia().obtenerPersonaPorId(tarmDocumentoHabilitante.getPersoncode(), null);
|
||||
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);
|
||||
pruebas=PersistenceHelper.getEntityManager().createQuery(sql.toString()).getResultList();
|
||||
// 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()+"'");
|
||||
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());
|
||||
}
|
||||
}
|
||||
pruebas = PersistenceHelper.getEntityManager().createQuery(sql.toString()).getResultList();
|
||||
// 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() + "'");
|
||||
pruebasRealizadasAlArma = PersistenceHelper.getEntityManager().createQuery(sql2.toString()).getResultList();
|
||||
}
|
||||
|
||||
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) {
|
||||
// String numerosolicitud = null;
|
||||
|
|
@ -239,50 +241,51 @@ public class ColaImpresionUtil {
|
|||
//
|
||||
// return numerosolicitud;
|
||||
// }
|
||||
|
||||
/**
|
||||
* Verifica si es o no autorización
|
||||
* @param numerosolicitud
|
||||
* @return
|
||||
* @throws Exception
|
||||
* @throws CommondbException
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public String verificaTipoTramite(String numerosolicitud) throws CommondbException, Exception {
|
||||
String tipoTramite = null;
|
||||
if(numerosolicitud != null){
|
||||
Query query = PersistenceHelper.getEntityManager().createQuery(QUERY_SOLICITUD_NUM);
|
||||
query.setParameter("numerosolicitud", numerosolicitud);
|
||||
List<TarmSolicitud> ltarmSolicitud = query.getResultList();
|
||||
if(ltarmSolicitud != null && !ltarmSolicitud.isEmpty()){
|
||||
TarmSolicitud tarmSolicitud = ltarmSolicitud.iterator().next();
|
||||
TarmTramite tarmTramite = TarmTramite.find(PersistenceHelper.getEntityManager(), tarmSolicitud.getCtramite());
|
||||
if(tarmTramite.getTipoautorizacion().equals("1") && tarmTramite.getTipoautorizacioncodigo().equals("TIPOAUTORIZACION")){
|
||||
tipoTramite = Constant.STR_Y;
|
||||
} else if(tarmTramite.getTipoautorizacion().equals("6") && tarmTramite.getTipoautorizacioncodigo().equals("TIPOAUTORIZACION")){
|
||||
tipoTramite = Constant.STR_N;
|
||||
}
|
||||
}
|
||||
}
|
||||
return tipoTramite;
|
||||
}
|
||||
|
||||
/**
|
||||
* Procesa datos del trámite y completa la información
|
||||
* @param documento
|
||||
* @param csolicitud
|
||||
*/
|
||||
private void procesaDatosTramite(DocumentoDto documento, String csolicitud){
|
||||
TarmSolicitud tarmSolicitud;
|
||||
try {
|
||||
tarmSolicitud = TarmSolicitud.find(PersistenceHelper.getEntityManager(), csolicitud);
|
||||
if(tarmSolicitud != null){
|
||||
documento.setNumeroSolicitud(tarmSolicitud.getNumerosolicitud());
|
||||
documento.setEstadoTramite(CatalogoUtil.getInstancia().getDescripcion(tarmSolicitud.getEstado(), tarmSolicitud.getEstadocodigo()));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
APPLogger.getLogger().error(e.getMessage(), e);
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* Verifica si es o no autorización
|
||||
*
|
||||
* @param numerosolicitud
|
||||
* @return
|
||||
* @throws Exception
|
||||
* @throws CommondbException
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public String verificaTipoTramite(String numerosolicitud) throws CommondbException, Exception {
|
||||
String tipoTramite = null;
|
||||
if (numerosolicitud != null) {
|
||||
Query query = PersistenceHelper.getEntityManager().createQuery(QUERY_SOLICITUD_NUM);
|
||||
query.setParameter("numerosolicitud", numerosolicitud);
|
||||
List<TarmSolicitud> ltarmSolicitud = query.getResultList();
|
||||
if (ltarmSolicitud != null && !ltarmSolicitud.isEmpty()) {
|
||||
TarmSolicitud tarmSolicitud = ltarmSolicitud.iterator().next();
|
||||
TarmTramite tarmTramite = TarmTramite.find(PersistenceHelper.getEntityManager(), tarmSolicitud.getCtramite());
|
||||
if (tarmTramite.getTipoautorizacion().equals("1") && tarmTramite.getTipoautorizacioncodigo().equals("TIPOAUTORIZACION")) {
|
||||
tipoTramite = Constant.STR_Y;
|
||||
} else if (tarmTramite.getTipoautorizacion().equals("6") && tarmTramite.getTipoautorizacioncodigo().equals("TIPOAUTORIZACION")) {
|
||||
tipoTramite = Constant.STR_N;
|
||||
}
|
||||
}
|
||||
}
|
||||
return tipoTramite;
|
||||
}
|
||||
|
||||
/**
|
||||
* Procesa datos del trámite y completa la información
|
||||
*
|
||||
* @param documento
|
||||
* @param csolicitud
|
||||
*/
|
||||
private void procesaDatosTramite(DocumentoDto documento, String csolicitud) {
|
||||
TarmSolicitud tarmSolicitud;
|
||||
try {
|
||||
tarmSolicitud = TarmSolicitud.find(PersistenceHelper.getEntityManager(), csolicitud);
|
||||
if (tarmSolicitud != null) {
|
||||
documento.setNumeroSolicitud(tarmSolicitud.getNumerosolicitud());
|
||||
documento.setEstadoTramite(CatalogoUtil.getInstancia().getDescripcion(tarmSolicitud.getEstado(), tarmSolicitud.getEstadocodigo()));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
APPLogger.getLogger().error(e.getMessage(), e);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue