first commit
This commit is contained in:
commit
67a085b1d7
|
|
@ -0,0 +1 @@
|
|||
/target/
|
||||
|
|
@ -0,0 +1,204 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.qsoft</groupId>
|
||||
<artifactId>werp-domain</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.stripe</groupId>
|
||||
<artifactId>stripe-java</artifactId>
|
||||
<version>20.6.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.wildbit.java</groupId>
|
||||
<artifactId>postmark</artifactId>
|
||||
<version>1.7.4</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sparkjava</groupId>
|
||||
<artifactId>spark-core</artifactId>
|
||||
<version>2.5</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.reflections</groupId>
|
||||
<artifactId>reflections</artifactId>
|
||||
<version>0.9.12</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.github.librepdf</groupId>
|
||||
<artifactId>openpdf</artifactId>
|
||||
<version>1.3.20</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.rubrica</groupId>
|
||||
<artifactId>rubrica</artifactId>
|
||||
<version>0.1.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.auth0</groupId>
|
||||
<artifactId>java-jwt</artifactId>
|
||||
<version>3.9.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mapstruct</groupId>
|
||||
<artifactId>mapstruct</artifactId>
|
||||
<version>1.3.1.Final</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.qsoft</groupId>
|
||||
<artifactId>werp-model</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<type>jar</type>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.qsoft.util</groupId>
|
||||
<artifactId>qsoft-util</artifactId>
|
||||
<version>1.1.1-SNAPSHOT</version>
|
||||
<type>jar</type>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.seleniumhq.selenium</groupId>
|
||||
<artifactId>selenium-java</artifactId>
|
||||
<scope>test</scope>
|
||||
<version>2.44.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.quartz-scheduler</groupId>
|
||||
<artifactId>quartz</artifactId>
|
||||
<version>2.3.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.opera</groupId>
|
||||
<artifactId>operadriver</artifactId>
|
||||
<scope>test</scope>
|
||||
<version>1.5</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.seleniumhq.selenium</groupId>
|
||||
<artifactId>selenium-remote-driver</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<scope>test</scope>
|
||||
<version>4.11</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
<version>2.10.1</version>
|
||||
<type>jar</type>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.qsoft</groupId>
|
||||
<artifactId>otp-util</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<type>jar</type>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>2.5</version>
|
||||
<type>jar</type>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-core</artifactId>
|
||||
<version>2.12.0</version>
|
||||
<type>jar</type>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax</groupId>
|
||||
<artifactId>javaee-api</artifactId>
|
||||
<version>8.0</version>
|
||||
<type>jar</type>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax</groupId>
|
||||
<artifactId>javaee-web-api</artifactId>
|
||||
<version>7.0</version>
|
||||
<type>jar</type>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-codec</groupId>
|
||||
<artifactId>commons-codec</artifactId>
|
||||
<version>1.14</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi</artifactId>
|
||||
<version>4.1.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.sf.jasperreports</groupId>
|
||||
<artifactId>jasperreports</artifactId>
|
||||
<version>6.17.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.sf.jasperreports</groupId>
|
||||
<artifactId>jasperreports-fonts</artifactId>
|
||||
<version>6.17.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.itextpdf</groupId>
|
||||
<artifactId>itextpdf</artifactId>
|
||||
<version>5.5.13.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>xalan</groupId>
|
||||
<artifactId>xalan</artifactId>
|
||||
<version>2.7.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.codehaus.groovy</groupId>
|
||||
<artifactId>groovy-all</artifactId>
|
||||
<version>2.5.8</version>
|
||||
<type>pom</type>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.pdfbox</groupId>
|
||||
<artifactId>pdfbox</artifactId>
|
||||
<version>2.0.18</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.pdfbox</groupId>
|
||||
<artifactId>pdfbox-tools</artifactId>
|
||||
<version>2.0.18</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<maven.compiler.source>11</maven.compiler.source>
|
||||
<maven.compiler.target>11</maven.compiler.target>
|
||||
</properties>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.5.1</version>
|
||||
<configuration>
|
||||
<source>11</source>
|
||||
<target>11</target>
|
||||
<annotationProcessorPaths>
|
||||
<path>
|
||||
<groupId>org.mapstruct</groupId>
|
||||
<artifactId>mapstruct-processor</artifactId>
|
||||
<version>1.3.1.Final</version>
|
||||
</path>
|
||||
</annotationProcessorPaths>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.qsoft.erp.constantes;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author james
|
||||
*/
|
||||
public enum AccionEnum {
|
||||
|
||||
CONSULTA(0x000),
|
||||
REGISTRO(0x001),
|
||||
ACTUALIZA(0x002),
|
||||
ELIMINACION(0x003),
|
||||
CONSULTA_COMPLEJA(0x00A),
|
||||
REGITRO_COMPLEJO(0x00B),
|
||||
ACTUALIZACION_COMPLEJA(0x00C),
|
||||
ELIMINACION_COMPLEJA(0x00D);
|
||||
|
||||
private int codigo;
|
||||
|
||||
private AccionEnum(int codigo) {
|
||||
this.codigo = codigo;
|
||||
}
|
||||
|
||||
public int getCodigo() {
|
||||
return codigo;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,52 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.qsoft.erp.constantes;
|
||||
|
||||
import com.qsoft.dao.exception.DaoException;
|
||||
import com.qsoft.erp.dao.DaoGenerico;
|
||||
import com.qsoft.erp.model.Catalogo;
|
||||
import java.util.TreeMap;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author james
|
||||
*/
|
||||
public enum CatalogoEnum {
|
||||
PERIO(27),
|
||||
ESTPOL(18),
|
||||
GENER(28),
|
||||
TIPM(11);
|
||||
|
||||
private Catalogo plantilla;
|
||||
private final Integer codigo;
|
||||
private TreeMap<String, String> parametros;
|
||||
|
||||
private CatalogoEnum(Integer codigo) {
|
||||
this.codigo = codigo;
|
||||
this.plantilla = new Catalogo(codigo);
|
||||
}
|
||||
|
||||
public Integer getCodigo() {
|
||||
return codigo;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Catalogo getCatalogo() {
|
||||
if (plantilla.getCatNemonico() == null && this.codigo != null) {
|
||||
DaoGenerico<Catalogo, Integer> dao = new DaoGenerico<>(Catalogo.class);
|
||||
try {
|
||||
this.plantilla = dao.cargar(this.codigo);
|
||||
} catch (DaoException ex) {
|
||||
System.out.println("ERROR CARGANDO PLANTILLA " + ex);
|
||||
}
|
||||
}
|
||||
return this.plantilla;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.qsoft.erp.constantes;
|
||||
|
||||
import com.qsoft.dao.exception.DaoException;
|
||||
import com.qsoft.erp.dao.DaoGenerico;
|
||||
import com.qsoft.erp.model.DetalleCatalogo;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author james
|
||||
*/
|
||||
public enum ComprobanteEnum {
|
||||
FACVEN("COMPROBANTE"),
|
||||
COTIZA("COMPROBANTE"),
|
||||
NOTVEN("COMPROBANTE"),
|
||||
FACCOM("COMPROBANTE"),
|
||||
LIQCOM("COMPROBANTE");
|
||||
|
||||
private String tipo;
|
||||
private DetalleCatalogo detalle;
|
||||
|
||||
private ComprobanteEnum(String tipo) {
|
||||
this.tipo = tipo;
|
||||
}
|
||||
|
||||
public String getTipo() {
|
||||
return tipo;
|
||||
}
|
||||
|
||||
public DetalleCatalogo getDetalle() {
|
||||
if (this.detalle.getDetNemonico() == null && this.tipo != null) {
|
||||
DaoGenerico<DetalleCatalogo, Integer> dao = new DaoGenerico<>(DetalleCatalogo.class);
|
||||
try {
|
||||
this.detalle = new DetalleCatalogo();
|
||||
this.detalle.setDetNemonico(this.name());
|
||||
this.detalle.setDetTipo(tipo);
|
||||
this.detalle = dao.buscarUnico(detalle);
|
||||
} catch (DaoException ex) {
|
||||
System.out.println("ERROR CARGANDO DETALLE CATALOGO " + ex);
|
||||
}
|
||||
}
|
||||
return detalle;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,70 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.qsoft.erp.constantes;
|
||||
|
||||
import com.qsoft.dao.exception.DaoException;
|
||||
import com.qsoft.erp.dao.DaoGenerico;
|
||||
import com.qsoft.erp.model.Catalogo;
|
||||
import com.qsoft.erp.model.DetalleCatalogo;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author james
|
||||
*/
|
||||
public enum DetalleCatalogoEnum {
|
||||
CED(2), RUC(2), PAS(2),
|
||||
OTPREI(1), CRONCP(1), WSDL(1),
|
||||
PASCPN(1), URLFIL(1), USRCPN(1),
|
||||
COPMAI(1), URLPAS(1), DIAWS(1),
|
||||
URLLIQ(1), URLPOL(1), URLREP(1),
|
||||
URLACE(1), URLCBT(1), URLFPC(1),
|
||||
REPLIQ(1), URLAGE(1), URLSMS(1),
|
||||
STRAKY(1),
|
||||
PTITU(12), HABIL(8),
|
||||
ESINI(18), ESFIR(18), ESTBLO(18),
|
||||
ESTACT(18), ESTAMO(18), ESTAOTP(18),
|
||||
ESTAINA(18), ESTCAN(18), ESTCAD(18),
|
||||
ESTSUS(18),
|
||||
TIPLQPR(22), TIPLQRE(22),
|
||||
ATAH(24), ATHE(24), ATHOS(24),
|
||||
DEBCTA(38), PAGEFE(38),
|
||||
I0079(25), TMM(11), TELEF(31),
|
||||
TICAH(26),TICCO(26), TICTC(26),
|
||||
PAG(32), PAG1(32), PAGM(32), PAGC(32),
|
||||
ESTALI(23), ESTDI(23), ESTLI(23),
|
||||
ESTAU(23), ESTLIC(23), ESTPAG(23),
|
||||
ESTAFHI(40), ESTAFIN(40), ESTAFV(40);
|
||||
|
||||
private DetalleCatalogo detalle;
|
||||
|
||||
private Integer codigo;
|
||||
|
||||
private DetalleCatalogoEnum(int codigo) {
|
||||
this.codigo = codigo;
|
||||
this.detalle = new DetalleCatalogo();
|
||||
}
|
||||
|
||||
public Integer getCodigo() {
|
||||
return codigo;
|
||||
}
|
||||
|
||||
public DetalleCatalogo getDetalle(){
|
||||
if (this.codigo != null) {
|
||||
DaoGenerico<DetalleCatalogo, Integer> dao = new DaoGenerico<>(DetalleCatalogo.class);
|
||||
DetalleCatalogo dc = new DetalleCatalogo();
|
||||
dc.setCatCodigo(new Catalogo(codigo));
|
||||
dc.setDetNemonico(this.name());
|
||||
try {
|
||||
this.detalle = dao.buscarUnico(dc);
|
||||
} catch (DaoException ex) {
|
||||
System.out.println("ERROR CARGANDO DETALLE CATALOGO " + ex);
|
||||
}
|
||||
}
|
||||
return detalle;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,143 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.qsoft.erp.constantes;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author james
|
||||
*/
|
||||
public class DominioConstantes {
|
||||
|
||||
public final static Integer ROL_CLI = 5;
|
||||
public static final String CIUDAD = "Quito";
|
||||
public static final String PERSONA = "PERSONA";
|
||||
public final static String POLIZA = "POLIZA";
|
||||
public final static String LIQUIDACION = "LIQUIDACION";
|
||||
public final static String JOBGROUP_NAME = "WMP_GROUP";
|
||||
public final static String TRIGGER_NAME = "CPN_TRIGGER";
|
||||
public final static String TGGROUP_NAME = "WMP_GROUP";
|
||||
public final static String JOB_NAME = "CPNJob";
|
||||
public final static String ACTUALIZAR = "-Actualizar-";
|
||||
public final static String PERIODICIDAD = "PERIODICIDAD";
|
||||
public final static Integer DIAS_COBERTURA = 365;
|
||||
public final static String FORMATO_FECHA_FRONT = "yyyy-MM-dd HH:mm:ss";
|
||||
public final static String FORMATO_FECHA_HORA = "dd/MM/yyyy HH:mm:ss";
|
||||
public final static String FORMATO_BDD = "yyyy-MM-dd HH:mm:ss";
|
||||
public final static String FORMATO_FECHA = "dd/MM/yyyy";
|
||||
public final static String FECHA_OBSERVACION_FORMATO = "yyyy-MM-dd";
|
||||
public final static String FECHA_AÑO = "yyyy";
|
||||
|
||||
public static final SimpleDateFormat FORMAT_DT = new SimpleDateFormat(FORMATO_FECHA_HORA);
|
||||
public static final SimpleDateFormat FORMAT_D = new SimpleDateFormat(FORMATO_FECHA);
|
||||
public static final SimpleDateFormat FORMAT_DB = new SimpleDateFormat(FORMATO_BDD);
|
||||
public static final SimpleDateFormat FORMAT_OBS = new SimpleDateFormat(FECHA_OBSERVACION_FORMATO);
|
||||
public static final SimpleDateFormat FORMAT_AÑO_SDF = new SimpleDateFormat(FECHA_AÑO);
|
||||
|
||||
public static final String TIPO_AGENDA = "tipoAgendamiento";
|
||||
public static final String BENEFICIARIO = "perBeneficiario";
|
||||
public static final String POL_CODIGO = "polCodigo";
|
||||
public static final String COBERTURA = "copCodigo";
|
||||
public static final String USUARIO = "user";
|
||||
public static final String EXISTENCIAS = "existencias";
|
||||
public static final String PASSWORD = "password";
|
||||
public static final String TOKEN = "token";
|
||||
public static final String OTP = "otp";
|
||||
public static final String EMAIL = "email";
|
||||
public static final String SEPARADOR = ":";
|
||||
public static final String RESET = "RESET";
|
||||
public static final String WE_SECRET_KEY = "QSoft2020&EnigmaBuilWeMedicalProKey";
|
||||
public static final Short ACTIVO = 1;
|
||||
public static final Integer REINTENTOS_OTP = 3;
|
||||
public static final Integer TOPE_MESES_MORA = 3;
|
||||
public static final Integer DELAY_JOB = 60000;
|
||||
public static final Integer CPN = 2;
|
||||
public static final Long MES_MILIS = 2592000000l; ///un mes en milisegundos
|
||||
public static final Integer TIEMPO_RESET = 86400; //24 horas en segundos
|
||||
public static final Short INACTIVO = 0;
|
||||
public static final Short CANCELADO = 2;
|
||||
public static final String NO_INFO = "No posee información bancaria";
|
||||
public static final String ESTADO_INI = "ESTADO FINANCIERO INICIAL";
|
||||
public static final String NOMBRE_APP = "USUARIO APP";
|
||||
public static final String APELLIDO_APP = "APELLIDOS APP";
|
||||
public static final String NACIONALIDAD = "ECUATORIANO";
|
||||
public static final String DATO_AUTO = "DATO CARGADO DESDE EL SISTEMA";
|
||||
public static final String DATO_MASIVO_POLIZA = "DATO CARGADO DESDE EL SISTEMA - MASIVO POLIZA";
|
||||
|
||||
public static final String MENSAJE_AUTO = "LIQUIDACION ABIERTA AFILIADO";
|
||||
public static final String PARAMETRO_URL = "URL_TOKEN";
|
||||
public static final String DESCRIPCION_POLIZA = "INACTIVA - POLIZA CREADA";
|
||||
public static final String DESCRIPCION_POLIZA_ACTIVA = "POLIZA ACTIVO - POLIZA CREADA";
|
||||
public static final String DESCRIPCION_POLIZA_SUSPENDIDA_BATCH = "POLIZA SUSPENDIDA AUTOMATICO - EXCEDE LA EDAD %s";
|
||||
public static final String DESCRIPCION_POLIZA_FALTA_PAGO = "POLIZA SUSPENDIDA AUTOMATICO - ADEUDA %s CUOTAS POR UN VALOR DE %S";
|
||||
public static final String DESCRIPCION_POLIZA_CADUCADA = "POLIZA VENCIDA AUTOMATICO";
|
||||
|
||||
public static final String ORIGEN_POLIZA = "APP-CARIDEL";
|
||||
public static final String DESCRIPCION_POLIZA_AC = "ACTIVA - POLIZA CREADA PAGO CPN";
|
||||
public static final String URL_CARIDEL = "https://salud.caridel.net/";
|
||||
public static final String CARIDEL = "MEDI-MEDICINA PREPAGADA";
|
||||
public static final String MAIL_CARIDEL = "notificaciones@segurosmedi.com";
|
||||
public static final String URL_WMP = "http://wmp.qsoftec.com/";
|
||||
public final static Integer CONSULTA = 1;
|
||||
public final static Integer COUNT = 2;
|
||||
public final static Integer IMAGEN = 3;
|
||||
public final static Integer ARCHIVOS_MASIVO = 4; /*--------> de momento solo por liquidacion*/
|
||||
|
||||
public final static String IMAGE = "/data/wmp/poliza/logo.png";
|
||||
public final static String FONDO = "/data/wmp/poliza/fondo.png";
|
||||
public final static String FONDOV = "/data/wmp/poliza/fondov.png";
|
||||
public final static String FORMA_PAGO = "DEBITO BANCARIO";
|
||||
public final static String PAG_OBSERVACION_DEBITO = "DEBITO";
|
||||
public final static String PAG_OBSERVACION_TARJETA_CREDITO = "TARJETA DE CRÉDITO";
|
||||
|
||||
public static String getDateTime() {
|
||||
return DominioConstantes.FORMAT_DT.format(new Date());
|
||||
}
|
||||
|
||||
public static String getDate() {
|
||||
return DominioConstantes.FORMAT_D.format(new Date());
|
||||
}
|
||||
|
||||
public static String getBddDate() {
|
||||
return DominioConstantes.FORMAT_DB.format(new Date());
|
||||
}
|
||||
|
||||
public static String getBddDate(Date date) {
|
||||
return DominioConstantes.FORMAT_DB.format(date);
|
||||
}
|
||||
|
||||
public static String getDateTime(Date fecha) {
|
||||
return DominioConstantes.FORMAT_DT.format(fecha);
|
||||
}
|
||||
|
||||
public static String getDate(Date fecha) {
|
||||
return DominioConstantes.FORMAT_D.format(fecha);
|
||||
}
|
||||
|
||||
public static Date getDateTime(String fecha) {
|
||||
Date resul = null;
|
||||
try {
|
||||
resul = DominioConstantes.FORMAT_DT.parse(fecha);
|
||||
} catch (ParseException ex) {
|
||||
resul = getDate(fecha);
|
||||
}
|
||||
return resul;
|
||||
}
|
||||
|
||||
public static Date getDate(String fecha) {
|
||||
Date resul = null;
|
||||
try {
|
||||
resul = DominioConstantes.FORMAT_D.parse(fecha);
|
||||
} catch (ParseException ex) {
|
||||
ex.printStackTrace(System.err);
|
||||
}
|
||||
return resul;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,88 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.qsoft.erp.constantes;
|
||||
import com.qsoft.erp.dto.*;
|
||||
import com.qsoft.erp.dominio.mapper.*;
|
||||
import com.qsoft.erp.model.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author james
|
||||
*/
|
||||
public enum EntidadEnum {
|
||||
Agendamiento(Agendamiento.class, AgendamientoDTO.class, AgendamientoMapper.class),
|
||||
EstadoAgendamiento(EstadoAgendamiento.class, EstadoAgendamientoDTO.class, EstadoAgendamientoMapper.class),
|
||||
Catalogo(Catalogo.class, CatalogoDTO.class, CatalogoMapper.class),
|
||||
CuentaBancaria(CuentaBancaria.class, CuentaBancariaDTO.class, CuentaBancariaMapper.class),
|
||||
CoberturasPlan(CoberturasPlan.class, CoberturasPlanDTO.class, CoberturasPlanMapper.class),
|
||||
Opcion(Opcion.class, OpcionDTO.class, OpcionMapper.class),
|
||||
Liquidacion(Liquidacion.class, LiquidacionDTO.class, LiquidacionMapper.class),
|
||||
EstadoLiquidacion(EstadoLiquidacion.class, EstadoLiquidacionDTO.class, EstadoLiquidacionMapper.class),
|
||||
Documento(Documento.class, DocumentoDTO.class, DocumentoMapper.class),
|
||||
DetalleLiquidacion(DetalleLiquidacion.class, DetalleLiquidacionDTO.class, DetalleLiquidacionMapper.class),
|
||||
Empresa(Empresa.class, EmpresaDTO.class, EmpresaMapper.class),
|
||||
DetalleCatalogo(DetalleCatalogo.class, DetalleCatalogoDTO.class, DetalleCatalogoMapper.class),
|
||||
UsuarioPassword(UsuarioPassword.class, UsuarioPasswordDTO.class, UsuarioPasswordMapper.class),
|
||||
Privilegio(Privilegio.class, PrivilegioDTO.class, PrivilegioMapper.class),
|
||||
Persona(Persona.class, PersonaDTO.class, PersonaMapper.class),
|
||||
PersonaPoliza(PersonaPoliza.class, PersonaPolizaDTO.class, PersonaPolizaMapper.class),
|
||||
Telefono(Telefono.class, TelefonoDTO.class, TelefonoMapper.class),
|
||||
Tarifario(Tarifario.class, TarifarioDTO.class, TarifarioMapper.class),
|
||||
TarifaLiquidacion(TarifaLiquidacion.class, TarifaLiquidacionDTO.class, TarifaLiquidacionMapper.class),
|
||||
Rol(Rol.class, RolDTO.class, RolMapper.class),
|
||||
Formulario(Formulario.class, FormularioDTO.class, FormularioMapper.class),
|
||||
Plan(Plan.class, PlanDTO.class, PlanMapper.class),
|
||||
PlanBroker(PlanBroker.class, PlanBrokerDTO.class, PlanBrokerMapper.class),
|
||||
Poliza(Poliza.class, PolizaDTO.class, PolizaMapper.class),
|
||||
Prestador(Prestador.class, PrestadorDTO.class, PrestadorMapper.class),
|
||||
Pago(Pago.class, PagoDTO.class, PagoMapper.class),
|
||||
Usuario(Usuario.class, UsuarioDTO.class, UsuarioMapper.class),
|
||||
Email(Email.class, EmailDTO.class, EmailMapper.class),
|
||||
Honorario(Honorario.class, HonorarioDTO.class, HonorarioMapper.class),
|
||||
HonorarioPlan(HonorarioPlan.class, HonorarioPlanDTO.class, HonorarioPlanMapper.class),
|
||||
PlantillaSmtp(PlantillaSmtp.class, PlantillaSmtpDTO.class, PlantillaSmtpMapper.class),
|
||||
Localizacion(Localizacion.class, LocalizacionDTO.class, LocalizacionMapper.class),
|
||||
Otp(Otp.class, OtpDTO.class, OtpMapper.class),
|
||||
RolUsuario(RolUsuario.class, RolUsuarioDTO.class, RolUsuarioMapper.class),
|
||||
Servicios(Servicios.class, ServiciosDTO.class, ServiciosMapper.class),
|
||||
SucursalEmpresa(SucursalEmpresa.class, SucursalEmpresaDTO.class, SucursalEmpresaMapper.class),
|
||||
Plantilla(Plantilla.class, PlantillaDTO.class, PlantillaMapper.class),
|
||||
Mensaje(Mensaje.class, MensajeDTO.class, MensajeMapper.class),
|
||||
Parametro(Parametro.class, ParametroDTO.class, ParametroMapper.class),
|
||||
Secuencia(Secuencia.class, SecuenciaDTO.class, SecuenciaMapper.class),
|
||||
Auditoria(Auditoria.class, AuditoriaDTO.class, AuditoriaMapper.class),
|
||||
VwUsuarioPersonaPolizaPlan(VwUsuarioPersonaPolizaPlan.class, VwUsuarioPersonaPolizaPlanDTO.class, VwUsuarioPersonaPolizaPlanMapper.class),
|
||||
VwPolPerBan(VwPolPerBan.class, VwPolPerBanDTO.class, VwPolPerBanMapper.class),
|
||||
VwLiqperpol(VwLiqperpol.class, VwLiqperpolDTO.class, VwLiqperpolMapper.class),
|
||||
VwLiqto(VwLiqto.class, VwLiqtoDTO.class, VwLiqtoMapper.class),
|
||||
VwRepprimaPlan(VwRepprimaPlan.class, VwRepprimaPlanDTO.class, VwRepprimaPlanMapper.class),
|
||||
VwPagosCpn(VwPagosCpn.class, VwPagosCpnDTO.class, VwPagosCpnMapper.class),
|
||||
VwReporteProduccion(VwReporteProduccion.class, VwReporteProduccionDTO.class, VwReporteProduccionMapper.class),
|
||||
VwPrestacionesPlan(VwPrestacionesPlan.class, VwPrestacionesPlanDTO.class, VwPrestacionesPlanMapper.class),;
|
||||
|
||||
private final Class entidad;
|
||||
private final Class dto;
|
||||
private final Class mapper;
|
||||
|
||||
private EntidadEnum(Class entidad, Class dto, Class mapper) {
|
||||
this.entidad = entidad;
|
||||
this.dto = dto;
|
||||
this.mapper = mapper;
|
||||
}
|
||||
|
||||
public Class getEntidad() {
|
||||
return entidad;
|
||||
}
|
||||
|
||||
public Class getDto() {
|
||||
return dto;
|
||||
}
|
||||
|
||||
public Class getMapper() {
|
||||
return mapper;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,169 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.qsoft.erp.constantes;
|
||||
|
||||
import com.qsoft.dao.exception.DaoException;
|
||||
import com.qsoft.dao.util.Fila;
|
||||
import com.qsoft.erp.dao.DaoGenerico;
|
||||
import com.qsoft.erp.model.DetalleCatalogo;
|
||||
import com.qsoft.erp.model.RolUsuario;
|
||||
import com.qsoft.erp.model.Usuario;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author james
|
||||
*/
|
||||
public enum EstadoLiquidacionEnum {
|
||||
|
||||
ESTALI(1, "CLI"),
|
||||
ESTLI(2, "LIQUI"),
|
||||
ESTAU(3, "AUD"),
|
||||
ESTLQC(4, "LIQUI"),
|
||||
ESTLIC(5, "CONT"),
|
||||
ESTPAG(6, "CONT"),
|
||||
ESTFIN(7 , "LIQUI"),
|
||||
ESTCAN(-1, "LIQUI");
|
||||
|
||||
private static final String TIPO = "ESTADOLIQ";
|
||||
|
||||
private static List<DetalleCatalogo> estados;
|
||||
|
||||
private final Integer orden;
|
||||
private final String rolNemonico;
|
||||
|
||||
private EstadoLiquidacionEnum(int codigo, String rolNemonico) {
|
||||
this.orden = codigo;
|
||||
this.rolNemonico =rolNemonico;
|
||||
}
|
||||
|
||||
public Integer getOrden() {
|
||||
return orden;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param detCodigo
|
||||
* @param avanza
|
||||
* @return
|
||||
*/
|
||||
public static DetalleCatalogo getSiguiente(int detCodigo, boolean avanza) {
|
||||
DetalleCatalogo estado = null;
|
||||
int nuevo = Integer.parseInt(getDetalleCodigo(detCodigo).getDetOrigen());
|
||||
if (avanza) {
|
||||
nuevo++;
|
||||
} else {
|
||||
nuevo--;
|
||||
}
|
||||
for (DetalleCatalogo de : getEstados()) {
|
||||
if (de.getDetOrigen().equalsIgnoreCase("" + nuevo)) {
|
||||
estado = de;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return estado;
|
||||
}
|
||||
|
||||
public String getRolNemonico() {
|
||||
return rolNemonico;
|
||||
}
|
||||
|
||||
private static List<DetalleCatalogo> getEstados() {
|
||||
if (estados == null || estados.isEmpty()) {
|
||||
try {
|
||||
DaoGenerico<DetalleCatalogo, Integer> dao = new DaoGenerico<>(DetalleCatalogo.class);
|
||||
DetalleCatalogo plantilla = new DetalleCatalogo();
|
||||
plantilla.setDetTipo(TIPO);
|
||||
plantilla.setDetEstado(DominioConstantes.ACTIVO);
|
||||
estados = dao.buscarLista(plantilla);
|
||||
} catch (DaoException ex) {
|
||||
System.out.println("Error cargando estados de poliza " + ex);
|
||||
}
|
||||
}
|
||||
return estados;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param detCodigo
|
||||
* @return
|
||||
*/
|
||||
public static DetalleCatalogo getDetalleCodigo(int detCodigo) {
|
||||
DetalleCatalogo detalle = null;
|
||||
for (DetalleCatalogo de : getEstados()) {
|
||||
if (de.getDetCodigo() == detCodigo) {
|
||||
detalle = de;
|
||||
}
|
||||
}
|
||||
return detalle;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public DetalleCatalogo getDetalleOrden() {
|
||||
DetalleCatalogo detalle = null;
|
||||
if (this.orden != null) {
|
||||
for (DetalleCatalogo de : getEstados()) {
|
||||
if (de.getDetOrigen().equalsIgnoreCase("" + this.orden)) {
|
||||
detalle = de;
|
||||
}
|
||||
}
|
||||
}
|
||||
return detalle;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public DetalleCatalogo getDetalleNemonico() {
|
||||
DetalleCatalogo detalle = null;
|
||||
if (this.orden != null) {
|
||||
for (DetalleCatalogo de : getEstados()) {
|
||||
if (de.getDetNemonico().equalsIgnoreCase(this.name())) {
|
||||
detalle = de;
|
||||
}
|
||||
}
|
||||
}
|
||||
return detalle;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public DetalleCatalogo getDetalle() {
|
||||
DetalleCatalogo detalle = null;
|
||||
if (this.name() != null) {
|
||||
for (DetalleCatalogo de : getEstados()) {
|
||||
if (de.getDetNemonico().equals(this.name())) {
|
||||
detalle = de;
|
||||
}
|
||||
}
|
||||
}
|
||||
return detalle;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Usuario getUsuarioGenerico(){
|
||||
DaoGenerico<RolUsuario, Integer> dao = new DaoGenerico<>(RolUsuario.class);
|
||||
String query = String.format(QueryEnum.USUGEN.getParametro().getParValor(), rolNemonico);
|
||||
List<Fila> usuarios = dao.ejecutarConsultaNativaList(query);
|
||||
Usuario usuario = new Usuario();
|
||||
for(Fila fila: usuarios){
|
||||
if (fila.getEntero(0) != null){
|
||||
usuario.setUsuCodigo(fila.getEntero(0));
|
||||
}
|
||||
}
|
||||
return usuario;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.qsoft.erp.constantes;
|
||||
|
||||
import com.qsoft.dao.exception.DaoException;
|
||||
import com.qsoft.erp.dao.DaoGenerico;
|
||||
import com.qsoft.erp.model.Parametro;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author james
|
||||
*/
|
||||
public enum ParametroEnum {
|
||||
OTPUSR(13), REIN(-8),
|
||||
CAD(-7), FALL(-6),
|
||||
ENV(-5), PRO(-4),
|
||||
ENC(-3), REG(-2),
|
||||
OTPREI(-27), OPTOK(-26),
|
||||
OTPFAL(-25), OTPCAD(-24),
|
||||
OTPNOT(-23), OTPCOL(-22),
|
||||
OTPGEN(-21);
|
||||
|
||||
private Parametro parametro;
|
||||
private final Integer codigo;
|
||||
|
||||
private ParametroEnum(Integer codigo) {
|
||||
this.codigo = codigo;
|
||||
this.parametro = new Parametro(codigo);
|
||||
}
|
||||
|
||||
public Integer getCodigo() {
|
||||
return codigo;
|
||||
}
|
||||
|
||||
public Parametro getParametro() {
|
||||
if (parametro.getParNemonico() == null && this.codigo != null) {
|
||||
DaoGenerico<Parametro, Integer> dao = new DaoGenerico<>(Parametro.class);
|
||||
try {
|
||||
this.parametro = dao.cargar(this.codigo);
|
||||
} catch (DaoException ex) {
|
||||
System.out.println("ERROR CARGANDO PARAMETRO " + ex);
|
||||
}
|
||||
}
|
||||
return this.parametro;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,73 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.qsoft.erp.constantes;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.qsoft.dao.exception.DaoException;
|
||||
import com.qsoft.erp.dao.DaoGenerico;
|
||||
import com.qsoft.erp.model.Plantilla;
|
||||
import java.util.TreeMap;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author james
|
||||
*/
|
||||
public enum PlantillaEnum {
|
||||
NOTFAC(1), NOTOTP(2),
|
||||
NOTCAR(3), NOTRES(4),
|
||||
NOTPOL(5), NOTLQG(6),
|
||||
NOTLQO(7), NOTLQE(8),
|
||||
NOTAPO(9), SMSAPO(10),
|
||||
NOTPOM(13), NOTANP(14)
|
||||
;
|
||||
|
||||
private Plantilla plantilla;
|
||||
private final Integer codigo;
|
||||
private TreeMap<String, String> parametros;
|
||||
|
||||
private PlantillaEnum(Integer codigo) {
|
||||
this.codigo = codigo;
|
||||
this.plantilla = new Plantilla(codigo);
|
||||
}
|
||||
|
||||
public Integer getCodigo() {
|
||||
return codigo;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Plantilla getPlantilla() {
|
||||
if (plantilla.getPlaNemonico() == null && this.codigo != null) {
|
||||
DaoGenerico<Plantilla, Integer> dao = new DaoGenerico<>(Plantilla.class);
|
||||
try {
|
||||
this.plantilla = dao.cargar(this.codigo);
|
||||
} catch (DaoException ex) {
|
||||
System.out.println("ERROR CARGANDO PLANTILLA " + ex);
|
||||
}
|
||||
}
|
||||
return this.plantilla;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public TreeMap<String, String> getParametros() {
|
||||
ObjectMapper obj = new ObjectMapper();
|
||||
try {
|
||||
this.parametros = obj.readValue(this.getPlantilla().getPlaParametros(), TreeMap.class);
|
||||
} catch (JsonProcessingException ex) {
|
||||
Logger.getLogger(PlantillaEnum.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
return parametros;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.qsoft.erp.constantes;
|
||||
|
||||
import com.qsoft.dao.exception.DaoException;
|
||||
import com.qsoft.erp.dao.DaoGenerico;
|
||||
import com.qsoft.erp.model.Parametro;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author james
|
||||
*/
|
||||
public enum QueryEnum {
|
||||
LOGIN, USULIQ, USUGEN, AUDINS, LIQTOT, LIQPOL,
|
||||
LOGIN2, LOGROL, AGEVAL, AGELIQ, AGELCO;
|
||||
|
||||
private static final String TIPO = "QUERY";
|
||||
private Parametro parametro;
|
||||
|
||||
private QueryEnum() {
|
||||
}
|
||||
|
||||
public Parametro getParametro() {
|
||||
Parametro p = new Parametro();
|
||||
p.setParTipo(TIPO);
|
||||
p.setParNemonico(this.name());
|
||||
DaoGenerico<Parametro, Integer> dao = new DaoGenerico<>(Parametro.class);
|
||||
try {
|
||||
this.parametro = dao.buscarUnico(p);
|
||||
} catch (DaoException ex) {
|
||||
System.out.println("ERROR CARGANDO PARAMETRO " + ex);
|
||||
}
|
||||
|
||||
return this.parametro;
|
||||
}
|
||||
|
||||
public String getQuery(){
|
||||
Parametro par = this.getParametro();
|
||||
return par != null? par.getParValor(): null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.qsoft.erp.constantes;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author james
|
||||
*/
|
||||
public enum SecuenciaEnum {
|
||||
FAV001, FAV002, FAV003,
|
||||
AGEMED,
|
||||
POLMED, LIQMED, PAGMED;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.qsoft.erp.constantes;
|
||||
|
||||
import com.qsoft.dao.exception.DaoException;
|
||||
import com.qsoft.erp.dao.DaoGenerico;
|
||||
import com.qsoft.erp.model.DetalleCatalogo;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author james
|
||||
*/
|
||||
public enum TransaccionEnum {
|
||||
CONSUL("0101000"), ACCION("0101100"),
|
||||
LOGIN("0101001"), RECPASS("0101002"), RESPASS("0101005"),
|
||||
ENVOTP("0101003"), VALOTP("0101004"),
|
||||
ALIQUI("0101110"),DETLIQ("0101102"), CLIQUI("0101111"),
|
||||
PERPOL("0101101"), REPORTE("0101010"),
|
||||
VALPER("0101011"), CUENTA("0101012"), AGEVAL("0101013"),
|
||||
POLIZA("0101112"), STRIPE("0101150"), STRSUS("0101151"),
|
||||
PERSONA("0101113"), AGENDA("0101114"), PLAN("0101115"),
|
||||
USER("0101116"), DOCUM("0101117"), CSVPAG("0101118"), CSVPPP("0101119"), CSVSIN("0101120"), CONDOC("0101121"), CSVPOC("0101122"), CSVPCR("0101123"),
|
||||
NOTIFI("0101130");
|
||||
|
||||
private final static String tipo = "TRANSACCION";
|
||||
|
||||
private DetalleCatalogo detalle;
|
||||
|
||||
private final String codigo;
|
||||
|
||||
private TransaccionEnum(String codigo) {
|
||||
this.codigo = codigo;
|
||||
}
|
||||
|
||||
public String getCodigo() {
|
||||
return codigo;
|
||||
}
|
||||
|
||||
public DetalleCatalogo getDetalle() {
|
||||
if (this.detalle.getDetNemonico() == null && this.codigo != null) {
|
||||
DaoGenerico<DetalleCatalogo, Integer> dao = new DaoGenerico<>(DetalleCatalogo.class);
|
||||
try {
|
||||
this.detalle = new DetalleCatalogo();
|
||||
this.detalle.setDetNemonico(this.name());
|
||||
this.detalle.setDetTipo(tipo);
|
||||
this.detalle = dao.buscarUnico(detalle);
|
||||
} catch (DaoException ex) {
|
||||
System.out.println("ERROR CARGANDO DETALLE CATALOGO " + ex);
|
||||
}
|
||||
}
|
||||
return detalle;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,252 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.qsoft.erp.dominio;
|
||||
|
||||
import com.qsoft.erp.dominio.util.DominioUtil;
|
||||
import com.qsoft.dao.exception.DaoException;
|
||||
import com.qsoft.util.constantes.CodigoRespuesta;
|
||||
import com.qsoft.util.constantes.ErrorTipo;
|
||||
import com.qsoft.util.ms.pojo.HeaderMS;
|
||||
import com.qsoft.erp.constantes.EntidadEnum;
|
||||
import com.qsoft.erp.constantes.TransaccionEnum;
|
||||
import com.qsoft.erp.dao.DaoGenerico;
|
||||
import com.qsoft.erp.dominio.exception.DominioExcepcion;
|
||||
import com.qsoft.erp.dominio.mapper.AgendamientoMapper;
|
||||
import com.qsoft.erp.dominio.mapper.DetalleLiquidacionMapper;
|
||||
import com.qsoft.erp.dominio.mapper.EmailMapper;
|
||||
import com.qsoft.erp.dominio.mapper.PersonaMapper;
|
||||
import com.qsoft.erp.dominio.mapper.PersonaPolizaMapper;
|
||||
import com.qsoft.erp.dominio.mapper.PlanMapper;
|
||||
import com.qsoft.erp.dominio.mapper.PolizaMapper;
|
||||
import com.qsoft.erp.dominio.mapper.UsuarioMapper;
|
||||
import com.qsoft.erp.dominio.transaccion.Stripe;
|
||||
import com.qsoft.erp.dominio.transaccion.UsuarioTransaccion;
|
||||
import com.qsoft.erp.dominio.util.AgendaUtil;
|
||||
import com.qsoft.erp.dominio.util.LiquidacionUtil;
|
||||
import com.qsoft.erp.dominio.util.NotificadorUtil;
|
||||
import com.qsoft.erp.dominio.util.PersonaUtil;
|
||||
import com.qsoft.erp.dominio.util.PlanUtil;
|
||||
import com.qsoft.erp.dominio.util.PolizaUtil;
|
||||
import com.qsoft.erp.model.Agendamiento;
|
||||
import com.qsoft.erp.model.DetalleLiquidacion;
|
||||
import com.qsoft.erp.model.Email;
|
||||
import com.qsoft.erp.model.Pago;
|
||||
import com.qsoft.erp.model.Persona;
|
||||
import com.qsoft.erp.model.PersonaPoliza;
|
||||
import com.qsoft.erp.model.Plan;
|
||||
import java.io.IOException;
|
||||
import com.qsoft.erp.model.Poliza;
|
||||
import com.qsoft.erp.model.Usuario;
|
||||
import com.stripe.exception.StripeException;
|
||||
import java.io.Serializable;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import javax.ejb.EJB;
|
||||
import javax.ejb.Stateless;
|
||||
import javax.transaction.Transactional;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author james
|
||||
*/
|
||||
@Stateless
|
||||
public class AccionGenerica {
|
||||
|
||||
public final static int CONSULTA = 0x000;
|
||||
public final static int GUARDA = 0x001;
|
||||
public final static int ACTUALIZA = 0x002;
|
||||
public final static int ELIMINA = 0x003;
|
||||
public final static int CANCELA = 0x005;
|
||||
public final static int GUARDA_ONSITE = 0x006;
|
||||
public final static int ACTUALIZA_ONSITE = 0x007;
|
||||
|
||||
@EJB
|
||||
private PersonaUtil personaUtil;
|
||||
|
||||
@EJB
|
||||
private DominioUtil dominioUtil;
|
||||
|
||||
@EJB
|
||||
private PolizaUtil polizaUtil;
|
||||
|
||||
@EJB
|
||||
private Stripe stripeUtil;
|
||||
|
||||
@EJB
|
||||
private PlanUtil planUtil;
|
||||
|
||||
@EJB
|
||||
private AgendaUtil agendaUtil;
|
||||
|
||||
@EJB
|
||||
private UsuarioTransaccion usuarioTransaccion;
|
||||
|
||||
@EJB
|
||||
private LiquidacionUtil liquidacionUtil;
|
||||
|
||||
@EJB
|
||||
private NotificadorUtil notificadorUtil;
|
||||
|
||||
/**
|
||||
* select * from LOCALIZACION WHERE LOC_PADRE = 9
|
||||
*
|
||||
* @param header
|
||||
* @param entidad
|
||||
* @param entidades
|
||||
* @param tipoAccion
|
||||
* @return
|
||||
* @throws com.qsoft.erp.dominio.exception.DominioExcepcion
|
||||
*/
|
||||
public List<Object> accionGenerica(HeaderMS header, EntidadEnum entidad, List<Map<String, Object>> entidades, int tipoAccion) throws DominioExcepcion, IOException, StripeException, DaoException {
|
||||
List<Object> data = new ArrayList<>();
|
||||
String tipoTransaccion = header.getTipoTransaccion() != null ? header.getTipoTransaccion() : "000000";
|
||||
if (TransaccionEnum.PERPOL.getCodigo().equals(tipoTransaccion)) {
|
||||
for (PersonaPoliza perpol : this.personaUtil.crearPersonaPoliza(header, entidades, tipoAccion)) {
|
||||
data.add(PersonaPolizaMapper.INSTANCE.getDto(perpol));
|
||||
}
|
||||
} else if (TransaccionEnum.DETLIQ.getCodigo().equals(tipoTransaccion)) {
|
||||
for (DetalleLiquidacion det : this.liquidacionUtil.procesarDetalleLiquidacion(header, entidades, tipoAccion)) {
|
||||
data.add(DetalleLiquidacionMapper.INSTANCE.getDto(det));
|
||||
}
|
||||
} else if (TransaccionEnum.PERSONA.getCodigo().equals(tipoTransaccion)) {
|
||||
for (Persona p : this.personaUtil.procesarPersona(header, entidades, tipoAccion)) {
|
||||
data.add(PersonaMapper.INSTANCE.getDto(p));
|
||||
}
|
||||
} else if (TransaccionEnum.USER.getCodigo().equals(tipoTransaccion)) {
|
||||
for (Usuario object : this.usuarioTransaccion.procesarUsuario(header, entidades, tipoAccion)) {
|
||||
data.add(UsuarioMapper.INSTANCE.getDto(object));
|
||||
}
|
||||
} else if (TransaccionEnum.POLIZA.getCodigo().equals(tipoTransaccion)) {
|
||||
for (Poliza pol : this.polizaUtil.procesarPoliza(header, entidades, tipoAccion)) {
|
||||
data.add(PolizaMapper.INSTANCE.getDto(pol));
|
||||
}
|
||||
} else if (TransaccionEnum.NOTIFI.getCodigo().equals(tipoTransaccion)) {
|
||||
for (Email object : this.notificadorUtil.notificar(header, entidades, tipoAccion)) {
|
||||
data.add(EmailMapper.INSTANCE.getDto(object));
|
||||
}
|
||||
} else if (TransaccionEnum.AGENDA.getCodigo().equals(tipoTransaccion)) {
|
||||
for (Agendamiento agenda : this.agendaUtil.procesarAgenda(header, entidades, tipoAccion)) {
|
||||
data.add(AgendamientoMapper.INSTANCE.getDto(agenda));
|
||||
}
|
||||
} else if (TransaccionEnum.STRIPE.getCodigo().equals(tipoTransaccion)) {
|
||||
Map<String, Object> generate = this.stripeUtil.generatePayment(header, entidades, tipoAccion);
|
||||
data.add(generate);
|
||||
} else if (TransaccionEnum.STRSUS.getCodigo().equals(tipoTransaccion)) {
|
||||
Map<String, Object> generate = this.stripeUtil.generatePayment(header, entidades, tipoAccion);
|
||||
data.add(generate);
|
||||
} else if (TransaccionEnum.PLAN.getCodigo().equals(tipoTransaccion)) {
|
||||
for (Plan p : this.planUtil.procesarPlan(header, entidades, tipoAccion)) {
|
||||
data.add(PlanMapper.INSTANCE.getDto(p));
|
||||
}
|
||||
} else if (TransaccionEnum.ACCION.getCodigo().equals(tipoTransaccion)) {
|
||||
for (Map<String, Object> ent : entidades) {
|
||||
Serializable objeto = (Serializable) dominioUtil.getEntidad(entidad.getMapper(),
|
||||
dominioUtil.crearObjeto(entidad.getDto(), ent));
|
||||
Object res = afectaBdd(header, tipoAccion, entidad, objeto);
|
||||
if (res != null) {
|
||||
data.add(dominioUtil.getDto(entidad.getMapper(), res));
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
throw new DominioExcepcion(ErrorTipo.FATAL, CodigoRespuesta.CODIGO_VALOR_NULO,
|
||||
"No existe una transaccion asociada al codigo " + header.getTipoTransaccion());
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
//entrada.getReceta(), entrada.getRec_items(), entrada.getRec_facturacion(), entrada.getRec_credito(), entrada.getTipo_facturacion()
|
||||
public Map<String, Object> accionFarmaenlace(Map<String, Object> receta, List<Map<String, Object>> rec_itemas, Map<String, Object> rec_facturacion, Map<String, Object> rec_credito, String tipo_facturacion) throws DominioExcepcion {
|
||||
Map<String, Object> results = new HashMap<String, Object>();
|
||||
results.put("receta", receta);
|
||||
results.put("rec_items", rec_itemas);
|
||||
results.put("rec_facturacion", rec_facturacion);
|
||||
results.put("rec_credito", rec_credito);
|
||||
results.put("tipo_facturacion", tipo_facturacion);
|
||||
return results;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param tipoAccion
|
||||
* @param dao
|
||||
* @param objeto
|
||||
* @return
|
||||
* @throws DominioExcepcion
|
||||
*/
|
||||
@Transactional(Transactional.TxType.REQUIRES_NEW)
|
||||
private Object afectaBdd(HeaderMS header, int tipoAccion, EntidadEnum entidad, Serializable objeto) throws DominioExcepcion {
|
||||
DaoGenerico dao = dominioUtil.generarDao(entidad);
|
||||
if (dao == null) {
|
||||
throw new DominioExcepcion(ErrorTipo.ERROR, CodigoRespuesta.CODIGO_DAO_NULO, "No se puede establecer la conexion a BDD");
|
||||
}
|
||||
Object en = null;
|
||||
switch (tipoAccion) {
|
||||
case CONSULTA: {
|
||||
throw new DominioExcepcion(ErrorTipo.ERROR, CodigoRespuesta.CODIGO_ERROR_GENERICO,
|
||||
"Operacion CONSULTA no soportada para este controlador");
|
||||
}
|
||||
// break;
|
||||
case GUARDA: {
|
||||
en = procesaTransaccionGuardar(header, dao, objeto);
|
||||
}
|
||||
break;
|
||||
case ACTUALIZA: {
|
||||
try {
|
||||
if (en instanceof Pago) {
|
||||
Pago p = (Pago) en;
|
||||
if (p.getPagFechaPago() == null) {
|
||||
p.setPagFechaPago(new Date());
|
||||
}
|
||||
}
|
||||
en = dao.actualizar(objeto);
|
||||
} catch (DaoException ex) {
|
||||
throw new DominioExcepcion(ErrorTipo.FATAL, CodigoRespuesta.CODIGO_ERROR_ACTUALIZA_BDD, ex.toString());
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ELIMINA: {
|
||||
throw new DominioExcepcion(ErrorTipo.ERROR, CodigoRespuesta.CODIGO_ERROR_GENERICO,
|
||||
"Operacion ELIMINACION aun no implementada");
|
||||
}
|
||||
// break;
|
||||
}
|
||||
return en;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param header
|
||||
* @param dao
|
||||
* @param entidad
|
||||
* @return
|
||||
* @throws DominioExcepcion
|
||||
*/
|
||||
@Transactional(Transactional.TxType.REQUIRES_NEW)
|
||||
public Object procesaTransaccionGuardar(HeaderMS header, DaoGenerico dao, Serializable entidad) throws DominioExcepcion {
|
||||
try {
|
||||
for (Field f : entidad.getClass().getDeclaredFields()) {
|
||||
if (f != null && Date.class.isAssignableFrom(f.getType())
|
||||
&& f.getName().toLowerCase().endsWith("fecharegistro")) {
|
||||
Boolean acces = f.canAccess(entidad);
|
||||
f.setAccessible(Boolean.TRUE);
|
||||
f.set(entidad, new Date());
|
||||
f.setAccessible(acces);
|
||||
}
|
||||
}
|
||||
dao.guardar(entidad);
|
||||
} catch (DaoException | IllegalArgumentException | IllegalAccessException ex) {
|
||||
throw new DominioExcepcion(ErrorTipo.FATAL, CodigoRespuesta.CODIGO_ERROR_GUARDA_BDD, ex.toString());
|
||||
}
|
||||
return entidad;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,404 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.qsoft.erp.dominio;
|
||||
|
||||
import com.qsoft.erp.dominio.util.DominioUtil;
|
||||
import com.qsoft.dao.exception.DaoException;
|
||||
import com.qsoft.dao.util.Fila;
|
||||
import com.qsoft.dao.util.Valor;
|
||||
import com.qsoft.util.constantes.CodigoRespuesta;
|
||||
import com.qsoft.util.constantes.ErrorTipo;
|
||||
import com.qsoft.util.ms.pojo.HeaderMS;
|
||||
import com.qsoft.erp.constantes.EntidadEnum;
|
||||
import com.qsoft.erp.constantes.DominioConstantes;
|
||||
import com.qsoft.erp.constantes.TransaccionEnum;
|
||||
import com.qsoft.erp.dao.DaoGenerico;
|
||||
import com.qsoft.erp.dominio.exception.DominioExcepcion;
|
||||
import com.qsoft.erp.dominio.transaccion.UsuarioTransaccion;
|
||||
import com.qsoft.erp.dominio.util.DBUtil;
|
||||
import com.qsoft.erp.dominio.util.PolizaUtil;
|
||||
import com.qsoft.erp.dominio.util.LiquidacionUtil;
|
||||
import com.qsoft.erp.dto.DetalleCatalogoDTO;
|
||||
import com.qsoft.erp.model.Liquidacion;
|
||||
import com.qsoft.erp.model.Parametro;
|
||||
import com.qsoft.erp.model.Persona;
|
||||
import com.qsoft.erp.reportes.PoiExport;
|
||||
import java.io.IOException;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import javax.ejb.EJB;
|
||||
import javax.ejb.Stateless;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author james
|
||||
*/
|
||||
@Stateless
|
||||
public class ConsultaGenerica {
|
||||
|
||||
@EJB
|
||||
private UsuarioTransaccion usuarioTransaccion;
|
||||
|
||||
@EJB
|
||||
private DominioUtil dominioUtil;
|
||||
|
||||
@EJB
|
||||
private PolizaUtil polizaUtil;
|
||||
|
||||
@EJB
|
||||
private DBUtil dBUtil;
|
||||
|
||||
@EJB
|
||||
private LiquidacionUtil liquidacionUtil;
|
||||
|
||||
/**
|
||||
* select * from LOCALIZACION WHERE LOC_PADRE = 9
|
||||
*
|
||||
* @param header
|
||||
* @param nombreEntidad
|
||||
* @param parametros
|
||||
* @param orden
|
||||
* @param maxRegistros
|
||||
* @param inicio
|
||||
* @param tipo
|
||||
* @return
|
||||
* @throws com.qsoft.erp.dominio.exception.DominioExcepcion
|
||||
*/
|
||||
public List consultaGenerica(HeaderMS header, String nombreEntidad, Map<String, Object> parametros, List<String> orden,
|
||||
Integer maxRegistros, Integer inicio, Integer tipo) throws DominioExcepcion {
|
||||
String tipoTransaccion = header.getTipoTransaccion() != null ? header.getTipoTransaccion() : "000000";
|
||||
List data = new ArrayList();
|
||||
|
||||
if (TransaccionEnum.REPORTE.getCodigo().equals(tipoTransaccion)) {
|
||||
data = this.generaReporte(nombreEntidad, parametros, tipo);
|
||||
if (data == null || data.isEmpty()) {
|
||||
throw new DominioExcepcion(ErrorTipo.ERROR, CodigoRespuesta.CODIGO_ERROR_CONSULTA_BDD, "No existen datos para el query solicitado");
|
||||
}
|
||||
} else {
|
||||
EntidadEnum entidad = null;
|
||||
try {
|
||||
entidad = Enum.valueOf(EntidadEnum.class, nombreEntidad);
|
||||
} catch (Exception e) {
|
||||
throw new DominioExcepcion(ErrorTipo.FATAL, CodigoRespuesta.CODIGO_VALOR_NULO,
|
||||
"No se puede identificar la entidad a la cual se desea acceder" + e.toString());
|
||||
}
|
||||
DaoGenerico dao = dominioUtil.generarDao(entidad, maxRegistros);
|
||||
if (dao == null) {
|
||||
System.out.println("=> ERROR FATAL EL DAO ES NULO ");
|
||||
throw new DominioExcepcion(ErrorTipo.ERROR, CodigoRespuesta.CODIGO_DAO_NULO, "No se puede establecer la conexion a BDD");
|
||||
} else {
|
||||
try {
|
||||
data = procesarConsulta(header, dao, entidad, parametros, orden, inicio, tipo, tipoTransaccion);
|
||||
} catch (DaoException ex) {
|
||||
throw new DominioExcepcion(ErrorTipo.FATAL, CodigoRespuesta.CODIGO_ERROR_CONSULTA_BDD, ex.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param transaccion
|
||||
* @return
|
||||
*/
|
||||
public List consultaGet(String cedula, String diagnostico) throws DominioExcepcion, DaoException {
|
||||
List data = new ArrayList();
|
||||
data = procesarConsultaDatos(cedula, diagnostico);
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param cedula
|
||||
* @param diagnostico
|
||||
* @return
|
||||
* @throws DominioExcepcion
|
||||
* @throws DaoException
|
||||
*/
|
||||
private List procesarConsultaDatos(String cedula, String diagnostico) throws DominioExcepcion, DaoException {
|
||||
List data = new ArrayList();
|
||||
data = this.polizaUtil.obtenerTitularDependienteFarma(cedula, diagnostico);
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param header
|
||||
* @param dao
|
||||
* @param entidad
|
||||
* @param parametros
|
||||
* @param inicio
|
||||
* @param tipoConsulta
|
||||
* @param tipoTransaccion
|
||||
* @return
|
||||
* @throws DominioExcepcion
|
||||
* @throws DaoException
|
||||
*/
|
||||
private List procesarConsulta(HeaderMS header, DaoGenerico dao, EntidadEnum entidad, Map<String, Object> parametros,
|
||||
List<String> orden, Integer inicio, Integer tipoConsulta, String tipoTransaccion) throws DominioExcepcion, DaoException {
|
||||
List data = new ArrayList();
|
||||
if(TransaccionEnum.CONDOC.getCodigo().equals(tipoTransaccion)){
|
||||
if(parametros.containsKey("liqCodigo")){
|
||||
Integer liqCodigo = Integer.parseInt(parametros.get("liqCodigo").toString());
|
||||
data.add(liquidacionUtil.obtenerTodosDocumentosLiquidacion(liqCodigo));
|
||||
}
|
||||
}
|
||||
else if ("0101666".equals(tipoTransaccion)) {
|
||||
data = this.usuarioTransaccion.login2(header, dao,
|
||||
parametros.get(DominioConstantes.USUARIO).toString().trim(), parametros.get(DominioConstantes.PASSWORD).toString().trim());
|
||||
if (data == null || data.isEmpty()) {
|
||||
throw new DominioExcepcion(ErrorTipo.ERROR, CodigoRespuesta.CODIGO_ERROR_CONSULTA_BDD, "Verifique que el usuario y contraseña sean válidos");
|
||||
}
|
||||
} else if (TransaccionEnum.LOGIN.getCodigo().equals(tipoTransaccion)) {
|
||||
data = this.usuarioTransaccion.login(header, dao,
|
||||
parametros.get(DominioConstantes.USUARIO).toString().trim(), parametros.get(DominioConstantes.PASSWORD).toString().trim());
|
||||
|
||||
|
||||
if (data == null || data.isEmpty()) {
|
||||
throw new DominioExcepcion(ErrorTipo.ERROR, CodigoRespuesta.CODIGO_ERROR_CONSULTA_BDD, "Verifique que el usuario y contraseña sean válidos");
|
||||
}
|
||||
} else if (TransaccionEnum.AGEVAL.getCodigo().equals(tipoTransaccion)) {
|
||||
String tipo = this.getValueString(parametros, DominioConstantes.TIPO_AGENDA);
|
||||
String beneficiario = this.getValueString(parametros, DominioConstantes.BENEFICIARIO);
|
||||
String poliza = this.getValueString(parametros, DominioConstantes.POL_CODIGO);
|
||||
String cobertura = "" + this.getValue(parametros, DominioConstantes.COBERTURA);
|
||||
|
||||
data = this.dBUtil.getValoresAgenda(header, tipo, beneficiario, poliza, cobertura);
|
||||
if (data == null || data.isEmpty()) {
|
||||
throw new DominioExcepcion(ErrorTipo.ERROR, CodigoRespuesta.CODIGO_ERROR_CONSULTA_BDD, "No se encontraron datos para la consulta");
|
||||
}
|
||||
} else if (TransaccionEnum.RECPASS.getCodigo().equals(tipoTransaccion)) {
|
||||
data = this.usuarioTransaccion.recuperaPassword(header, dao,
|
||||
parametros.get(DominioConstantes.USUARIO).toString().trim(), parametros.get(DominioConstantes.EMAIL).toString().trim());
|
||||
if (data == null || data.isEmpty()) {
|
||||
throw new DominioExcepcion(ErrorTipo.ERROR, CodigoRespuesta.CODIGO_ERROR_CONSULTA_BDD, "No existe ningun usuario que coincida");
|
||||
}
|
||||
} else if (TransaccionEnum.ENVOTP.getCodigo().equals(tipoTransaccion)) {
|
||||
data = this.usuarioTransaccion.enviaOtp(header, dao, parametros.get(DominioConstantes.USUARIO).toString().trim());
|
||||
if (data == null || data.isEmpty()) {
|
||||
throw new DominioExcepcion(ErrorTipo.ERROR, CodigoRespuesta.CODIGO_ERROR_CONSULTA_BDD, "Ha ocurrido un error en el envio de OTP");
|
||||
}
|
||||
} else if (TransaccionEnum.VALOTP.getCodigo().equals(tipoTransaccion)) {
|
||||
data = this.usuarioTransaccion.validaOtp(header, dao, parametros.get(
|
||||
DominioConstantes.USUARIO).toString(), parametros.get(DominioConstantes.OTP).toString().trim());
|
||||
if (data == null || data.isEmpty()) {
|
||||
throw new DominioExcepcion(ErrorTipo.ERROR, CodigoRespuesta.CODIGO_ERROR_CONSULTA_BDD, "Error en validacion de OTP");
|
||||
}
|
||||
} else if (TransaccionEnum.RESPASS.getCodigo().equals(tipoTransaccion)) {
|
||||
data = this.usuarioTransaccion.cambiaPassword(header, dao, parametros.get(
|
||||
DominioConstantes.TOKEN).toString().trim(), parametros.get(DominioConstantes.PASSWORD).toString().trim());
|
||||
if (data == null || data.isEmpty()) {
|
||||
throw new DominioExcepcion(ErrorTipo.ERROR, CodigoRespuesta.CODIGO_ERROR_CONSULTA_BDD, "No existe ningun usuario que coincida");
|
||||
}
|
||||
} else if (TransaccionEnum.VALPER.getCodigo().equals(tipoTransaccion)) {
|
||||
Persona plantilla = (Persona) dominioUtil.getEntidad(entidad.getMapper(), dominioUtil.crearObjeto(entidad.getDto(), parametros));
|
||||
|
||||
if (this.polizaUtil.existePoliza(plantilla.getPerIdentificacion(), plantilla.getDetTipoIdentificacion().getDetCodigo(), plantilla.getPerCodigo())) {
|
||||
throw new DominioExcepcion(ErrorTipo.ERROR, CodigoRespuesta.CODIGO_ERROR_CONSULTA_BDD, "Error el cliente "
|
||||
+ plantilla.getPerIdentificacion() + " ya posee una poliza activa no se modificara la informacion actual");
|
||||
}
|
||||
if(!this.polizaUtil.evaluarSiniestrado(plantilla.getPerIdentificacion())){
|
||||
throw new DominioExcepcion(ErrorTipo.ERROR, CodigoRespuesta.CODIGO_ERROR_CONSULTA_BDD,String.format("Socio %s identificado como 'Socio siniestroso', no tiene permitido relacionar una poliza al mismo", plantilla.getPerIdentificacion()) );
|
||||
}
|
||||
try {
|
||||
data = consultar(dao, plantilla, entidad, orden, inicio, tipoConsulta);
|
||||
} catch (DaoException ex) {
|
||||
ex.printStackTrace(System.err);
|
||||
throw new DominioExcepcion(ErrorTipo.FATAL, CodigoRespuesta.CODIGO_ERROR_CONSULTA_BDD, ex.toString());
|
||||
}
|
||||
} else if (TransaccionEnum.CONSUL.getCodigo().equals(tipoTransaccion)) {
|
||||
Serializable plantilla = (Serializable) dominioUtil.getEntidad(entidad.getMapper(),
|
||||
dominioUtil.crearObjeto(entidad.getDto(), parametros));
|
||||
try {
|
||||
data = consultar(dao, plantilla, entidad, orden, inicio, tipoConsulta);
|
||||
} catch (DaoException ex) {
|
||||
ex.printStackTrace(System.err);
|
||||
throw new DominioExcepcion(ErrorTipo.FATAL, CodigoRespuesta.CODIGO_ERROR_CONSULTA_BDD, ex.toString());
|
||||
}
|
||||
} else {
|
||||
throw new DominioExcepcion(ErrorTipo.FATAL, CodigoRespuesta.CODIGO_VALOR_NULO,
|
||||
"No existe una transaccion asociada al codigo " + header.getTipoTransaccion());
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param nemonico
|
||||
* @param parametros
|
||||
* @param tipo
|
||||
* @return
|
||||
* @throws DominioExcepcion
|
||||
*/
|
||||
public List generaReporte(String nemonico, Map<String, Object> parametros, int tipo) throws DominioExcepcion {
|
||||
List data = new ArrayList();
|
||||
Parametro param = this.dominioUtil.getParametro(nemonico, DominioUtil.TIPO_QUERY);
|
||||
if (param == null || param.getParValor() == null || param.getParValor().trim().isEmpty()) {
|
||||
throw new DominioExcepcion(ErrorTipo.ERROR, CodigoRespuesta.CODIGO_VALOR_NULO, "No existe consulta asociada al codigo solicitado");
|
||||
}
|
||||
String query = param.getParValor();
|
||||
String[] labels;
|
||||
for (Object s : parametros.values()) {
|
||||
query = query.replaceFirst("%s", s.toString());
|
||||
}
|
||||
|
||||
DaoGenerico<Parametro, Integer> dao = new DaoGenerico<>(Parametro.class);
|
||||
List<Fila> result = dao.ejecutarConsultaNativaList(query);
|
||||
if (result == null || result.isEmpty()) {
|
||||
throw new DominioExcepcion(ErrorTipo.ERROR, CodigoRespuesta.CODIGO_VALOR_NULO, "La consulta no arrojo resultados");
|
||||
}
|
||||
|
||||
if (param.getParDescripcion() != null && !param.getParDescripcion().trim().isEmpty()) {
|
||||
labels = param.getParDescripcion().split(DominioConstantes.SEPARADOR);
|
||||
} else {
|
||||
Fila f = result.get(0);
|
||||
labels = new String[f.size()];
|
||||
for (int i = 0; i < f.size(); i++) {
|
||||
labels[i] = "CAMPO_" + (i + 1);
|
||||
}
|
||||
}
|
||||
if (tipo == DominioConstantes.CONSULTA) {
|
||||
for (Fila f : result) {
|
||||
Map<String, Object> fila = new LinkedHashMap<>();
|
||||
int i = 0;
|
||||
for (Valor v : f) {
|
||||
if (v.getValor() instanceof Date) {
|
||||
Date fec = (Date) v.getValor();
|
||||
fila.put(labels[i], DominioConstantes.getBddDate(fec));
|
||||
} else {
|
||||
fila.put(labels[i], v.getValor());
|
||||
}
|
||||
i++;
|
||||
}
|
||||
data.add(fila);
|
||||
}
|
||||
} else if (tipo == DominioConstantes.COUNT) { //Generar CSV
|
||||
Map<String, Object> fila = new HashMap<>();
|
||||
try {
|
||||
fila.put(param.getParNombre(), PoiExport.getCSV(this.getData(labels, result)));
|
||||
} catch (IOException ex) {
|
||||
throw new DominioExcepcion(ErrorTipo.ERROR, CodigoRespuesta.CODIGO_VALOR_NULO, "No se puede generar el recurso CSV " + ex);
|
||||
}
|
||||
data.add(fila);
|
||||
} else if (tipo == DominioConstantes.IMAGEN) { //Generar XLS
|
||||
Map<String, Object> fila = new HashMap<>();
|
||||
try {
|
||||
fila.put(param.getParNombre(), PoiExport.getExcel(this.getData(labels, result), param.getParNombre()));
|
||||
} catch (IOException ex) {
|
||||
throw new DominioExcepcion(ErrorTipo.ERROR, CodigoRespuesta.CODIGO_VALOR_NULO, "No se puede generar el recurso XLS " + ex);
|
||||
}
|
||||
data.add(fila);
|
||||
} else {
|
||||
throw new DominioExcepcion(ErrorTipo.ERROR, CodigoRespuesta.CODIGO_VALOR_NULO, "No existe operacion asociada al codigo de consulta");
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param parametros
|
||||
* @param name
|
||||
* @return
|
||||
*/
|
||||
private Object getValue(Map<String, Object> parametros, String name) {
|
||||
Object result = null;
|
||||
if (parametros.containsKey(name)) {
|
||||
result = parametros.get(name);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param parametros
|
||||
* @param name
|
||||
* @return
|
||||
*/
|
||||
private String getValueString(Map<String, Object> parametros, String name) throws DominioExcepcion {
|
||||
String result = null;
|
||||
if (parametros.containsKey(name)) {
|
||||
result = parametros.get(name).toString().trim();
|
||||
} else {
|
||||
throw new DominioExcepcion(ErrorTipo.ERROR, CodigoRespuesta.CODIGO_ERROR_GENERICO, "Error, el campo " + name + "es obligatorio");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param labels
|
||||
* @param result
|
||||
* @return
|
||||
*/
|
||||
private List<List<Object>> getData(String[] labels, List<Fila> result) {
|
||||
List<List<Object>> matrix = new LinkedList<>();
|
||||
List header = new LinkedList<>();
|
||||
for (String l : labels) {
|
||||
header.add(l);
|
||||
}
|
||||
matrix.add(header);
|
||||
for (Fila f : result) {
|
||||
List fila = new LinkedList<>();
|
||||
for (Valor v : f) {
|
||||
fila.add(v.getValor());
|
||||
}
|
||||
matrix.add(fila);
|
||||
}
|
||||
return matrix;
|
||||
}
|
||||
|
||||
/**
|
||||
* Permite realizar consultas a BDD de forma generica y retornar un listado de DTO corespondiente
|
||||
*
|
||||
* @param dao
|
||||
* @param plantilla
|
||||
* @param entidad
|
||||
* @param orden
|
||||
* @param inicio
|
||||
* @param tipo
|
||||
* @return
|
||||
* @throws DaoException
|
||||
*/
|
||||
public List consultar(DaoGenerico dao, Serializable plantilla, EntidadEnum entidad, List<String> orden, Integer inicio, int tipo) throws DaoException {
|
||||
List data = new ArrayList();
|
||||
if (tipo == DominioConstantes.CONSULTA) {
|
||||
if (orden != null && !orden.isEmpty()) {
|
||||
String[] or = new String[orden.size()];
|
||||
for (Object o : dao.buscarLista(plantilla, inicio, orden.toArray(or))) {
|
||||
data.add(dominioUtil.getDto(entidad.getMapper(), o));
|
||||
}
|
||||
} else {
|
||||
for (Object o : dao.buscarLista(plantilla, inicio)) {
|
||||
data.add(dominioUtil.getDto(entidad.getMapper(), o));
|
||||
}
|
||||
}
|
||||
} else if (tipo == DominioConstantes.COUNT) {
|
||||
Map<String, Long> contador = new HashMap<>();
|
||||
contador.put(DominioConstantes.EXISTENCIAS, dao.contarExistencias(plantilla));
|
||||
data.add(contador);
|
||||
} else if (tipo == DominioConstantes.IMAGEN) {
|
||||
for (Object o : dao.buscarLista(plantilla)) {
|
||||
Object dto = dominioUtil.getDto(entidad.getMapper(), o);
|
||||
if (dto instanceof DetalleCatalogoDTO) {
|
||||
DetalleCatalogoDTO dec = (DetalleCatalogoDTO) dto;
|
||||
dec.setArchivo(DominioUtil.getArchivo(dec.getDetOrigen()));
|
||||
dec.setDetDestino(DominioUtil.getNombreArchivo(dec.getDetOrigen()));
|
||||
}
|
||||
data.add(dto);
|
||||
}
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,137 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.qsoft.erp.dominio;
|
||||
|
||||
import com.qsoft.erp.dominio.util.DominioUtil;
|
||||
import com.qsoft.util.constantes.CodigoRespuesta;
|
||||
import com.qsoft.util.constantes.ErrorTipo;
|
||||
import com.qsoft.util.ms.pojo.HeaderMS;
|
||||
import com.qsoft.erp.constantes.EntidadEnum;
|
||||
import com.qsoft.erp.constantes.TransaccionEnum;
|
||||
import com.qsoft.erp.dominio.exception.DominioExcepcion;
|
||||
import com.qsoft.erp.dominio.util.DocumentoUtil;
|
||||
import com.qsoft.erp.dominio.util.LiquidacionUtil;
|
||||
import com.qsoft.erp.dto.DocumentoDTO;
|
||||
import com.qsoft.erp.dto.LiquidacionDTO;
|
||||
import com.qsoft.erp.dto.PagoDTO;
|
||||
import com.qsoft.erp.dto.PersonaDTO;
|
||||
import com.qsoft.erp.dto.PersonaPolizaDTO;
|
||||
import com.qsoft.erp.dto.PolizaDTO;
|
||||
import com.qsoft.erp.model.Documento;
|
||||
import com.qsoft.erp.model.Liquidacion;
|
||||
import com.qsoft.erp.model.Pago;
|
||||
import com.qsoft.erp.model.Persona;
|
||||
import com.qsoft.erp.model.Poliza;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import javax.ejb.EJB;
|
||||
import javax.ejb.Stateless;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author james
|
||||
*/
|
||||
@Stateless
|
||||
public class MultipartService {
|
||||
|
||||
@EJB
|
||||
private LiquidacionUtil liquidacionUtil;
|
||||
|
||||
@EJB
|
||||
private DocumentoUtil documentoUtil;
|
||||
|
||||
@EJB
|
||||
private DominioUtil dominioUtil;
|
||||
|
||||
/**
|
||||
* select * from LOCALIZACION WHERE LOC_PADRE = 9
|
||||
*
|
||||
* @param header
|
||||
* @param entidad
|
||||
* @param datos
|
||||
* @param tipoAccion
|
||||
* @return
|
||||
* @throws com.qsoft.erp.dominio.exception.DominioExcepcion
|
||||
*/
|
||||
public List<Object> multipartLiquidacion(HeaderMS header, EntidadEnum entidad, Map<String, LiquidacionDTO> datos, int tipoAccion) throws DominioExcepcion {
|
||||
List<Object> data = new ArrayList<>();
|
||||
List<Liquidacion> dataL = new ArrayList<>();
|
||||
if (header.getTipoTransaccion().equals(TransaccionEnum.CLIQUI.getCodigo())) {
|
||||
dataL = this.liquidacionUtil.guardarLiquidacion(header, datos);
|
||||
} else if (header.getTipoTransaccion().equals(TransaccionEnum.ALIQUI.getCodigo())) {
|
||||
dataL = this.liquidacionUtil.actualizarLiquidacion(header, datos, tipoAccion);
|
||||
} else {
|
||||
throw new DominioExcepcion(ErrorTipo.FATAL, CodigoRespuesta.CODIGO_VALOR_NULO,
|
||||
"No existe una transaccion asociada al codigo " + header.getTipoTransaccion());
|
||||
}
|
||||
if (dataL != null && !dataL.isEmpty()) {
|
||||
for (Liquidacion liq : dataL) {
|
||||
LiquidacionDTO liquidacion = (LiquidacionDTO) dominioUtil.getDto(EntidadEnum.Liquidacion.getMapper(), liq);
|
||||
data.add(liquidacion);
|
||||
}
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param header
|
||||
* @param entidad
|
||||
* @param entidades
|
||||
* @param tipoAccion
|
||||
* @param documentoDTOs
|
||||
* @return
|
||||
* @throws DominioExcepcion
|
||||
*/
|
||||
public List<Object> multipartGenerico(HeaderMS header, EntidadEnum entidad, List<Map<String, Object>> entidades, int tipoAccion, List<DocumentoDTO> documentoDTOs) throws DominioExcepcion, Exception {
|
||||
List<Object> data = new ArrayList<>();
|
||||
List<Documento> dataL = new ArrayList<>();
|
||||
|
||||
if (header.getTipoTransaccion().equals(TransaccionEnum.DOCUM.getCodigo())) {
|
||||
dataL = this.documentoUtil.guardarDocumento(header, entidades, documentoDTOs, tipoAccion);
|
||||
for (Documento liq : dataL) {
|
||||
DocumentoDTO liquidacion = (DocumentoDTO) dominioUtil.getDto(EntidadEnum.Documento.getMapper(), liq);
|
||||
data.add(liquidacion);
|
||||
}
|
||||
} else if(header.getTipoTransaccion().equals(TransaccionEnum.CSVPAG.getCodigo())){
|
||||
for (Pago pago : this.documentoUtil.procesarCSV(header, entidades, documentoDTOs, tipoAccion)) {
|
||||
PagoDTO pagoDTO = (PagoDTO) dominioUtil.getDto(EntidadEnum.Pago.getMapper(), pago);
|
||||
data.add(pagoDTO);
|
||||
}
|
||||
|
||||
}else if(header.getTipoTransaccion().equals(TransaccionEnum.CSVPPP.getCodigo())){
|
||||
for (Pago pago : this.documentoUtil.analizarCSV(header, entidades, documentoDTOs, tipoAccion)) {
|
||||
PagoDTO pagoDTO = (PagoDTO) dominioUtil.getDto(EntidadEnum.Pago.getMapper(), pago);
|
||||
data.add(pagoDTO);
|
||||
}
|
||||
}
|
||||
else if(header.getTipoTransaccion().equals(TransaccionEnum.CSVSIN.getCodigo())){
|
||||
for (Persona persona : this.documentoUtil.procesarSiniestrosCSV(header, entidades, documentoDTOs, tipoAccion)) {
|
||||
PersonaDTO personaDTO = (PersonaDTO) dominioUtil.getDto(EntidadEnum.Persona.getMapper(), persona);
|
||||
data.add(personaDTO);
|
||||
}
|
||||
}
|
||||
else if(header.getTipoTransaccion().equals(TransaccionEnum.CSVPOC.getCodigo())){
|
||||
for (Poliza poliza : this.documentoUtil.procesarCancelacion(header, entidades, documentoDTOs, tipoAccion)) {
|
||||
PolizaDTO polizaDTO = (PolizaDTO) dominioUtil.getDto(EntidadEnum.Poliza.getMapper(), poliza);
|
||||
data.add(polizaDTO);
|
||||
}
|
||||
}
|
||||
else if(header.getTipoTransaccion().equals(TransaccionEnum.CSVPCR.getCodigo())){
|
||||
for (Poliza poliza : this.documentoUtil.procesarCreacionCsv(header, entidades, documentoDTOs, tipoAccion)) {
|
||||
PolizaDTO polizaDTO = (PolizaDTO) dominioUtil.getDto(EntidadEnum.Poliza.getMapper(), poliza);
|
||||
data.add(polizaDTO);
|
||||
}
|
||||
}
|
||||
else {
|
||||
throw new DominioExcepcion(ErrorTipo.FATAL, CodigoRespuesta.CODIGO_VALOR_NULO,
|
||||
"No existe una transaccion asociada al codigo " + header.getTipoTransaccion());
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.qsoft.erp.dominio.exception;
|
||||
|
||||
import com.qsoft.util.constantes.CodigoRespuesta;
|
||||
import com.qsoft.util.constantes.ErrorTipo;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author james
|
||||
*/
|
||||
public class DominioExcepcion extends Exception{
|
||||
|
||||
private final ErrorTipo tipo;
|
||||
private final CodigoRespuesta codigo;
|
||||
private final String mensaje;
|
||||
|
||||
public DominioExcepcion(ErrorTipo tipo, CodigoRespuesta codigo, String mensaje) {
|
||||
super(mensaje);
|
||||
this.tipo = tipo;
|
||||
this.codigo = codigo;
|
||||
this.mensaje = mensaje;
|
||||
}
|
||||
|
||||
public ErrorTipo getTipo() {
|
||||
return tipo;
|
||||
}
|
||||
|
||||
public CodigoRespuesta getCodigo() {
|
||||
return codigo;
|
||||
}
|
||||
|
||||
public String getMensaje() {
|
||||
return mensaje;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,79 @@
|
|||
package com.qsoft.erp.dominio.mapper;
|
||||
|
||||
import com.qsoft.erp.dto.AgendamientoDTO;
|
||||
import com.qsoft.erp.model.Agendamiento;
|
||||
import com.qsoft.erp.model.EstadoAgendamiento;
|
||||
import java.util.ArrayList;
|
||||
import org.mapstruct.AfterMapping;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.MappingTarget;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
@Mapper
|
||||
public interface AgendamientoMapper {
|
||||
|
||||
AgendamientoMapper INSTANCE = Mappers.getMapper(AgendamientoMapper.class);
|
||||
|
||||
@Mapping(source = "locCodigo", target = "locCodigo.locCodigo")
|
||||
@Mapping(source = "perBeneficiario", target = "perBeneficiario.perCodigo")
|
||||
@Mapping(source = "polCodigo", target = "polCodigo.polCodigo")
|
||||
@Mapping(source = "preCodigo", target = "preCodigo.preCodigo")
|
||||
@Mapping(source = "usuCodigo", target = "usuCodigo.usuCodigo")
|
||||
@Mapping(source = "detTipo", target = "detTipo.detCodigo")
|
||||
@Mapping(source = "locNombre", target = "locCodigo.locNombre")
|
||||
@Mapping(source = "perNombres", target = "perBeneficiario.perNombres")
|
||||
@Mapping(source = "perApellidos", target = "perBeneficiario.perApellidos")
|
||||
@Mapping(source = "perIdentificacion", target = "perBeneficiario.perIdentificacion")
|
||||
@Mapping(source = "polContrato", target = "polCodigo.polContrato")
|
||||
@Mapping(source = "preNombre", target = "preCodigo.preNombre")
|
||||
@Mapping(source = "detNemonico", target = "detTipo.detNemonico")
|
||||
@Mapping(source = "detNombre", target = "detTipo.detNombre")
|
||||
@Mapping(source = "usuUsuario", target = "usuCodigo.usuUsuario")
|
||||
Agendamiento getEntidad(AgendamientoDTO agendamientoDTO);
|
||||
|
||||
@Mapping(target = "locCodigo", source = "locCodigo.locCodigo")
|
||||
@Mapping(target = "perBeneficiario", source = "perBeneficiario.perCodigo")
|
||||
@Mapping(target = "polCodigo", source = "polCodigo.polCodigo")
|
||||
@Mapping(target = "preCodigo", source = "preCodigo.preCodigo")
|
||||
@Mapping(target = "usuCodigo", source = "usuCodigo.usuCodigo")
|
||||
@Mapping(target = "detTipo", source = "detTipo.detCodigo")
|
||||
@Mapping(target = "locNombre", source = "locCodigo.locNombre")
|
||||
@Mapping(target = "perNombres", source = "perBeneficiario.perNombres")
|
||||
@Mapping(target = "perApellidos", source = "perBeneficiario.perApellidos")
|
||||
@Mapping(target = "perIdentificacion", source = "perBeneficiario.perIdentificacion")
|
||||
@Mapping(target = "polContrato", source = "polCodigo.polContrato")
|
||||
@Mapping(target = "preNombre", source = "preCodigo.preNombre")
|
||||
@Mapping(target = "detNemonico", source = "detTipo.detNemonico")
|
||||
@Mapping(target = "detNombre", source = "detTipo.detNombre")
|
||||
@Mapping(target = "usuUsuario", source = "usuCodigo.usuUsuario")
|
||||
AgendamientoDTO getDto(Agendamiento agendamiento);
|
||||
|
||||
|
||||
@AfterMapping
|
||||
default void validaObjetos(Agendamiento agendamiento, @MappingTarget AgendamientoDTO agendamientoDTO) {
|
||||
agendamientoDTO.setEstado(new ArrayList<>());
|
||||
if (agendamiento.getEstadoAgendamientoCollection() != null && !agendamiento.getEstadoAgendamientoCollection().isEmpty()) {
|
||||
for (EstadoAgendamiento ea : agendamiento.getEstadoAgendamientoCollection()) {
|
||||
agendamientoDTO.getEstado().add(EstadoAgendamientoMapper.INSTANCE.getDto(ea));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@AfterMapping
|
||||
default void validaNulos(AgendamientoDTO agendamientoDTO, @MappingTarget Agendamiento agendamiento) {
|
||||
if (agendamiento.getPreCodigo() != null && agendamiento.getPreCodigo().getPreCodigo() == null) {
|
||||
agendamiento.setPreCodigo(null);
|
||||
}
|
||||
if (agendamiento.getPerBeneficiario() != null && agendamiento.getPerBeneficiario().getPerCodigo() == null) {
|
||||
agendamiento.setPerBeneficiario(null);
|
||||
}
|
||||
if (agendamiento.getLocCodigo() != null && agendamiento.getLocCodigo().getLocCodigo() == null) {
|
||||
agendamiento.setLocCodigo(null);
|
||||
}
|
||||
if (agendamiento.getDetTipo()!= null && agendamiento.getDetTipo().getDetCodigo()== null) {
|
||||
agendamiento.setDetTipo(null);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
package com.qsoft.erp.dominio.mapper;
|
||||
|
||||
import com.qsoft.erp.dto.AuditoriaDTO;
|
||||
import com.qsoft.erp.model.Auditoria;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
@Mapper
|
||||
public interface AuditoriaMapper {
|
||||
|
||||
AuditoriaMapper INSTANCE = Mappers.getMapper(AuditoriaMapper.class);
|
||||
|
||||
Auditoria getEntidad(AuditoriaDTO auditoriaDTO);
|
||||
|
||||
AuditoriaDTO getDto(Auditoria auditoria);
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.qsoft.erp.dominio.mapper;
|
||||
|
||||
import com.qsoft.erp.dto.CatalogoDTO;
|
||||
import com.qsoft.erp.model.Catalogo;
|
||||
import org.mapstruct.AfterMapping;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.MappingTarget;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author james
|
||||
*/
|
||||
@Mapper
|
||||
public interface CatalogoMapper {
|
||||
|
||||
CatalogoMapper INSTANCE = Mappers.getMapper(CatalogoMapper.class);
|
||||
|
||||
@Mapping(source = "empCodigo", target = "empCodigo.empCodigo")
|
||||
Catalogo getEntidad(CatalogoDTO catalogoDTO);
|
||||
|
||||
@Mapping(source = "empCodigo.empCodigo", target = "empCodigo")
|
||||
CatalogoDTO getDto(Catalogo catalogo);
|
||||
|
||||
@AfterMapping
|
||||
default void validaObjetos(CatalogoDTO catalogoDTO, @MappingTarget Catalogo catalogo){
|
||||
if(MapperUtil.isEmptyDTO(catalogo.getEmpCodigo())){
|
||||
catalogo.setEmpCodigo(null);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,89 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.qsoft.erp.dominio.mapper;
|
||||
|
||||
import com.qsoft.erp.dto.CoberturasPlanDTO;
|
||||
import com.qsoft.erp.model.CoberturasPlan;
|
||||
import org.mapstruct.AfterMapping;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.MappingTarget;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author james
|
||||
*/
|
||||
@Mapper
|
||||
public interface CoberturasPlanMapper {
|
||||
|
||||
CoberturasPlanMapper INSTANCE = Mappers.getMapper(CoberturasPlanMapper.class);
|
||||
|
||||
@Mapping(source = "detPrestacion", target = "detPrestacion.detCodigo")
|
||||
@Mapping(source = "detTipoModalidad", target = "detTipoModalidad.detCodigo")
|
||||
@Mapping(source = "detTipo", target = "detTipo.detCodigo")
|
||||
@Mapping(source = "detPais", target = "detPais.detCodigo")
|
||||
@Mapping(source = "plaCodigo", target = "plaCodigo.plaCodigo")
|
||||
@Mapping(source = "modalidadNemonico", target = "detTipoModalidad.detNemonico")
|
||||
@Mapping(source = "paisNemonico", target = "detPais.detNemonico")
|
||||
@Mapping(source = "tipoNemonico", target = "detTipo.detNemonico")
|
||||
@Mapping(source = "prestacionNemonico", target = "detPrestacion.detNemonico")
|
||||
@Mapping(source = "modalidadNombre", target = "detTipoModalidad.detNombre")
|
||||
@Mapping(source = "paisNombre", target = "detPais.detNombre")
|
||||
@Mapping(source = "tipoNombre", target = "detTipo.detNombre")
|
||||
@Mapping(source = "prestacionNombre", target = "detPrestacion.detNombre")
|
||||
@Mapping(source = "modalidadDescripcion", target = "detTipoModalidad.detDescripcion")
|
||||
@Mapping(source = "paisDescripcion", target = "detPais.detDescripcion")
|
||||
@Mapping(source = "tipoDescripcion", target = "detTipo.detDescripcion")
|
||||
@Mapping(source = "prestacionDescripcion", target = "detPrestacion.detDescripcion")
|
||||
@Mapping(source = "detTipoDeducible", target = "detTipoDeducible.detCodigo")
|
||||
@Mapping(source = "tipoDeducibleNemonico", target = "detTipoDeducible.detNemonico")
|
||||
@Mapping(source = "tipoDeducibleNombre", target = "detTipoDeducible.detNombre")
|
||||
CoberturasPlan getEntidad(CoberturasPlanDTO coberturasPlanDTO);
|
||||
|
||||
@Mapping(target = "detPrestacion", source = "detPrestacion.detCodigo")
|
||||
@Mapping(target = "detTipoModalidad", source = "detTipoModalidad.detCodigo")
|
||||
@Mapping(target = "detTipo", source = "detTipo.detCodigo")
|
||||
@Mapping(target = "detPais", source = "detPais.detCodigo")
|
||||
@Mapping(target = "plaCodigo", source = "plaCodigo.plaCodigo")
|
||||
@Mapping(target = "prestacionNemonico", source = "detPrestacion.detNemonico")
|
||||
@Mapping(target = "modalidadNemonico", source = "detTipoModalidad.detNemonico")
|
||||
@Mapping(target = "tipoNemonico", source = "detTipo.detNemonico")
|
||||
@Mapping(target = "paisNemonico", source = "detPais.detNemonico")
|
||||
@Mapping(target = "modalidadNombre", source = "detTipoModalidad.detNombre")
|
||||
@Mapping(target = "paisNombre", source = "detPais.detNombre")
|
||||
@Mapping(target = "tipoNombre", source = "detTipo.detNombre")
|
||||
@Mapping(target = "prestacionNombre", source = "detPrestacion.detNombre")
|
||||
@Mapping(target = "modalidadDescripcion", source = "detTipoModalidad.detDescripcion")
|
||||
@Mapping(target = "paisDescripcion", source = "detPais.detDescripcion")
|
||||
@Mapping(target = "tipoDescripcion", source = "detTipo.detDescripcion")
|
||||
@Mapping(target = "prestacionDescripcion", source = "detPrestacion.detDescripcion")
|
||||
@Mapping(target = "detTipoDeducible", source = "detTipoDeducible.detCodigo")
|
||||
@Mapping(target = "tipoDeducibleNemonico", source = "detTipoDeducible.detNemonico")
|
||||
@Mapping(target = "tipoDeducibleNombre", source = "detTipoDeducible.detNombre")
|
||||
CoberturasPlanDTO getDto(CoberturasPlan coberturasPlan);
|
||||
|
||||
@AfterMapping
|
||||
default void validaNulos(CoberturasPlanDTO coberturasPlanDTO, @MappingTarget CoberturasPlan coberturasPlan) {
|
||||
|
||||
if (coberturasPlan.getDetPrestacion() != null && coberturasPlan.getDetPrestacion().getDetCodigo() == null) {
|
||||
coberturasPlan.setDetPrestacion(null);
|
||||
}
|
||||
if (coberturasPlan.getDetPais() != null && coberturasPlan.getDetPais().getDetCodigo() == null) {
|
||||
coberturasPlan.setDetPais(null);
|
||||
}
|
||||
if (coberturasPlan.getDetTipoModalidad() != null && coberturasPlan.getDetTipoModalidad().getDetCodigo() == null) {
|
||||
coberturasPlan.setDetTipoModalidad(null);
|
||||
}
|
||||
if (coberturasPlan.getDetTipo() != null && coberturasPlan.getDetTipo().getDetCodigo() == null) {
|
||||
coberturasPlan.setDetTipo(null);
|
||||
}
|
||||
if (coberturasPlan.getPlaCodigo() != null && coberturasPlan.getPlaCodigo().getPlaCodigo() == null) {
|
||||
coberturasPlan.setPlaCodigo(null);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.qsoft.erp.dominio.mapper;
|
||||
|
||||
import com.qsoft.erp.dto.CuentaBancariaDTO;
|
||||
import com.qsoft.erp.dto.LiquidacionDTO;
|
||||
import com.qsoft.erp.model.CuentaBancaria;
|
||||
import com.qsoft.erp.model.Liquidacion;
|
||||
import org.mapstruct.AfterMapping;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.MappingTarget;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author james
|
||||
*/
|
||||
@Mapper
|
||||
public interface CuentaBancariaMapper {
|
||||
|
||||
CuentaBancariaMapper INSTANCE = Mappers.getMapper(CuentaBancariaMapper.class);
|
||||
|
||||
@Mapping(source = "perCodigo", target = "perCodigo.perCodigo")
|
||||
@Mapping(source = "detIfi", target = "detIfi.detCodigo")
|
||||
@Mapping(source = "detTipoCuenta", target = "detTipoCuenta.detCodigo")
|
||||
@Mapping(source = "detNombreIfi", target = "detIfi.detNombre")
|
||||
@Mapping(source = "detNombreTipoCuenta", target = "detTipoCuenta.detNombre")
|
||||
CuentaBancaria getEntidad(CuentaBancariaDTO cuentaBancariaDTO);
|
||||
|
||||
@Mapping(target = "perCodigo", source = "perCodigo.perCodigo")
|
||||
@Mapping(target = "detIfi", source = "detIfi.detCodigo")
|
||||
@Mapping(target = "detTipoCuenta", source = "detTipoCuenta.detCodigo")
|
||||
@Mapping(target = "detNombreIfi", source = "detIfi.detNombre")
|
||||
@Mapping(target = "detNombreTipoCuenta", source = "detTipoCuenta.detNombre")
|
||||
CuentaBancariaDTO getDto(CuentaBancaria cuentaBancaria);
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.qsoft.erp.dominio.mapper;
|
||||
|
||||
import com.qsoft.erp.dto.DetalleCatalogoDTO;
|
||||
import com.qsoft.erp.model.DetalleCatalogo;
|
||||
import org.mapstruct.AfterMapping;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.MappingTarget;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author james
|
||||
*/
|
||||
@Mapper
|
||||
public interface DetalleCatalogoMapper {
|
||||
|
||||
DetalleCatalogoMapper INSTANCE = Mappers.getMapper(DetalleCatalogoMapper.class);
|
||||
|
||||
@Mapping(source = "catCodigo", target = "catCodigo.catCodigo")
|
||||
@Mapping(source = "catNemonico", target = "catCodigo.catNemonico")
|
||||
@Mapping(source = "empCodigo", target = "catCodigo.empCodigo.empCodigo")
|
||||
DetalleCatalogo getEntidad(DetalleCatalogoDTO detalleCatalogoDTO);
|
||||
|
||||
@Mapping(target = "catCodigo", source = "catCodigo.catCodigo")
|
||||
@Mapping(target = "catNemonico", source = "catCodigo.catNemonico")
|
||||
@Mapping(target = "empCodigo", source = "catCodigo.empCodigo.empCodigo")
|
||||
DetalleCatalogoDTO getDto(DetalleCatalogo detalleCatalogo);
|
||||
|
||||
@AfterMapping
|
||||
default void validaNulos(DetalleCatalogoDTO detalleCatalogoDTO, @MappingTarget DetalleCatalogo detalleCatalogo) {
|
||||
|
||||
// if (detalleCatalogo.getDetOrigen() != null && detalleCatalogo.getDetOrigen().isBlank()) {
|
||||
// detalleCatalogo.setDetOrigen(null);
|
||||
// }
|
||||
// if (detalleCatalogo.getDetDestino() != null && detalleCatalogo.getDetDestino().isBlank()) {
|
||||
// detalleCatalogo.setDetDestino(null);
|
||||
// }
|
||||
// if (detalleCatalogo.getDetDescripcion() != null && detalleCatalogo.getDetDescripcion().isBlank()) {
|
||||
// detalleCatalogo.setDetDescripcion(null);
|
||||
// }
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,67 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.qsoft.erp.dominio.mapper;
|
||||
|
||||
import com.qsoft.erp.dto.DetalleLiquidacionDTO;
|
||||
import com.qsoft.erp.model.DetalleLiquidacion;
|
||||
import com.qsoft.erp.model.TarifaLiquidacion;
|
||||
import java.util.ArrayList;
|
||||
import org.mapstruct.AfterMapping;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.MappingTarget;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author james
|
||||
*/
|
||||
@Mapper
|
||||
public interface DetalleLiquidacionMapper {
|
||||
|
||||
DetalleLiquidacionMapper INSTANCE = Mappers.getMapper(DetalleLiquidacionMapper.class);
|
||||
|
||||
@Mapping(source = "detTipo", target = "detTipo.detCodigo")
|
||||
@Mapping(source = "liqCodigo", target = "liqCodigo.liqCodigo")
|
||||
@Mapping(source = "preCodigo", target = "preCodigo.preCodigo")
|
||||
@Mapping(source = "copCodigo", target = "copCodigo.copCodigo")
|
||||
@Mapping(source = "detCie10", target = "detCie10.detCodigo")
|
||||
@Mapping(source = "cie10Nemonico", target = "detCie10.detNemonico")
|
||||
@Mapping(source = "tipoNemonico", target = "detTipo.detNemonico")
|
||||
DetalleLiquidacion getEntidad(DetalleLiquidacionDTO detalleLiquidacionDTO);
|
||||
|
||||
@Mapping(target = "detTipo", source = "detTipo.detCodigo")
|
||||
@Mapping(target = "liqCodigo", source = "liqCodigo.liqCodigo")
|
||||
@Mapping(target = "preCodigo", source = "preCodigo.preCodigo")
|
||||
@Mapping(target = "copCodigo", source = "copCodigo.copCodigo")
|
||||
@Mapping(target = "detCie10", source = "detCie10.detCodigo")
|
||||
@Mapping(target = "cie10Nemonico", source = "detCie10.detNemonico")
|
||||
@Mapping(target = "tipoNemonico", source = "detTipo.detNemonico")
|
||||
DetalleLiquidacionDTO getDto(DetalleLiquidacion detalleLiquidacion);
|
||||
|
||||
@AfterMapping
|
||||
default void validaNulos(DetalleLiquidacionDTO detalleLiquidacionDTO, @MappingTarget DetalleLiquidacion detalleLiquidacion) {
|
||||
|
||||
if (detalleLiquidacion.getDetCie10() != null && detalleLiquidacion.getDetCie10().getDetCodigo() == null) {
|
||||
detalleLiquidacion.setDetCie10(null);
|
||||
}
|
||||
if (detalleLiquidacion.getDetTipo() != null && detalleLiquidacion.getDetTipo().getDetCodigo() == null) {
|
||||
detalleLiquidacion.setDetTipo(null);
|
||||
}
|
||||
if (detalleLiquidacion.getPreCodigo() != null && detalleLiquidacion.getPreCodigo().getPreCodigo() == null) {
|
||||
detalleLiquidacion.setPreCodigo(null);
|
||||
}
|
||||
}
|
||||
|
||||
@AfterMapping
|
||||
default void recuperarTarifa(DetalleLiquidacion detalleLiquidacion, @MappingTarget DetalleLiquidacionDTO detalleLiquidacionDTO) {
|
||||
detalleLiquidacionDTO.setDetalle(new ArrayList<>());
|
||||
for (TarifaLiquidacion tarli : detalleLiquidacion.getTarifaLiquidacionCollection()) {
|
||||
detalleLiquidacionDTO.getDetalle().add(TarifaLiquidacionMapper.INSTANCE.getDto(tarli));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,65 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.qsoft.erp.dominio.mapper;
|
||||
|
||||
import com.qsoft.erp.dominio.util.DominioUtil;
|
||||
import com.qsoft.erp.dto.DocumentoDTO;
|
||||
import com.qsoft.erp.model.Documento;
|
||||
import org.mapstruct.AfterMapping;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.MappingTarget;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author james
|
||||
*/
|
||||
@Mapper
|
||||
public interface DocumentoMapper {
|
||||
|
||||
DocumentoMapper INSTANCE = Mappers.getMapper(DocumentoMapper.class);
|
||||
|
||||
@Mapping(source = "detTipo", target = "detTipo.detCodigo")
|
||||
@Mapping(source = "liqCodigo", target = "liqCodigo.liqCodigo")
|
||||
@Mapping(source = "polCodigo", target = "polCodigo.polCodigo")
|
||||
@Mapping(source = "ageCodigo", target = "ageCodigo.ageCodigo")
|
||||
@Mapping(source = "tipoNemonico", target = "detTipo.detNemonico")
|
||||
Documento getEntidad(DocumentoDTO documentoDTO);
|
||||
|
||||
@Mapping(target = "detTipo", source = "detTipo.detCodigo")
|
||||
@Mapping(target = "liqCodigo", source = "liqCodigo.liqCodigo")
|
||||
@Mapping(target = "polCodigo", source = "polCodigo.polCodigo")
|
||||
@Mapping(target = "tipoNemonico", source = "detTipo.detNemonico")
|
||||
@Mapping(target = "ageCodigo", source = "ageCodigo.ageCodigo")
|
||||
DocumentoDTO getDto(Documento documento);
|
||||
|
||||
@AfterMapping
|
||||
default void cargaArchivo(Documento documento, @MappingTarget DocumentoDTO documentoDTO) {
|
||||
if (documentoDTO.getDocUrl() != null && !documentoDTO.getDocUrl().trim().isEmpty()) {
|
||||
documentoDTO.setDocumento(DominioUtil.getArchivo(documentoDTO.getDocUrl()));
|
||||
documentoDTO.setDocUrl(DominioUtil.getNombreArchivo(documentoDTO.getDocUrl()));
|
||||
}
|
||||
}
|
||||
|
||||
@AfterMapping
|
||||
default void validaNulos(DocumentoDTO documentoDTO, @MappingTarget Documento documento) {
|
||||
if (documento.getLiqCodigo()!= null && documento.getLiqCodigo().getLiqCodigo() == null) {
|
||||
documento.setLiqCodigo(null);
|
||||
}
|
||||
if (documento.getDetTipo()!= null && documento.getDetTipo().getDetCodigo()== null) {
|
||||
documento.setDetTipo(null);
|
||||
}
|
||||
if (documento.getAgeCodigo()!= null && documento.getAgeCodigo().getAgeCodigo() == null) {
|
||||
documento.setAgeCodigo(null);
|
||||
}
|
||||
|
||||
if (documento.getPolCodigo()!= null && documento.getPolCodigo().getPolCodigo() == null) {
|
||||
documento.setPolCodigo(null);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
package com.qsoft.erp.dominio.mapper;
|
||||
|
||||
import com.qsoft.erp.model.Email;
|
||||
import com.qsoft.erp.dto.EmailDTO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
@Mapper
|
||||
public interface EmailMapper {
|
||||
|
||||
EmailMapper INSTANCE = Mappers.getMapper(EmailMapper.class);
|
||||
|
||||
@Mapping(source = "parEstado", target = "parEstado.parCodigo")
|
||||
@Mapping(source = "plsmCodigo", target = "plsmCodigo.plsmCodigo")
|
||||
Email getEntidad(EmailDTO email);
|
||||
|
||||
@Mapping(target = "parEstado", source = "parEstado.parCodigo")
|
||||
@Mapping(target = "plsmCodigo", source = "plsmCodigo.plsmCodigo")
|
||||
EmailDTO getDto(Email email);
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.qsoft.erp.dominio.mapper;
|
||||
|
||||
import com.qsoft.erp.dto.EmpresaDTO;
|
||||
import com.qsoft.erp.model.Empresa;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author james
|
||||
*/
|
||||
@Mapper
|
||||
public interface EmpresaMapper {
|
||||
|
||||
EmpresaMapper INSTANCE = Mappers.getMapper(EmpresaMapper.class);
|
||||
|
||||
@Mapping(source = "detTipo", target = "detTipo.detCodigo")
|
||||
@Mapping(source = "tipoNemonico", target = "detTipo.detNemonico")
|
||||
@Mapping(source = "locCodigo", target = "locCodigo.locCodigo")
|
||||
@Mapping(source = "locNombre", target = "locCodigo.locNombre")
|
||||
Empresa getEntidad(EmpresaDTO empresaDTO);
|
||||
|
||||
@Mapping(target = "detTipo", source = "detTipo.detCodigo")
|
||||
@Mapping(target = "tipoNemonico", source = "detTipo.detNemonico")
|
||||
@Mapping(target = "locCodigo", source = "locCodigo.locCodigo")
|
||||
@Mapping(target = "locNombre", source = "locCodigo.locNombre")
|
||||
EmpresaDTO getDto(Empresa empresa);
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
package com.qsoft.erp.dominio.mapper;
|
||||
|
||||
import com.qsoft.erp.dto.EstadoAgendamientoDTO;
|
||||
import com.qsoft.erp.model.EstadoAgendamiento;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
@Mapper
|
||||
public interface EstadoAgendamientoMapper {
|
||||
|
||||
EstadoAgendamientoMapper INSTANCE = Mappers.getMapper(EstadoAgendamientoMapper.class);
|
||||
|
||||
@Mapping(source = "ageCodigo", target = "ageCodigo.ageCodigo")
|
||||
@Mapping(source = "detEstado", target = "detEstado.detCodigo")
|
||||
@Mapping(source = "usuCodigo", target = "usuCodigo.usuCodigo")
|
||||
@Mapping(source = "estadoNombre", target = "detEstado.detNombre")
|
||||
@Mapping(source = "usuUsuario", target = "usuCodigo.usuUsuario")
|
||||
@Mapping(source = "usuNombre", target = "usuCodigo.usuNombre")
|
||||
EstadoAgendamiento getEntidad(EstadoAgendamientoDTO estadoAgendamientoDTO);
|
||||
|
||||
@Mapping(target = "ageCodigo", source = "ageCodigo.ageCodigo")
|
||||
@Mapping(target = "detEstado", source = "detEstado.detCodigo")
|
||||
@Mapping(target = "usuCodigo", source = "usuCodigo.usuCodigo")
|
||||
@Mapping(target = "estadoNombre", source = "detEstado.detNombre")
|
||||
@Mapping(target = "usuUsuario", source = "usuCodigo.usuUsuario")
|
||||
@Mapping(target = "usuNombre", source = "usuCodigo.usuNombre")
|
||||
EstadoAgendamientoDTO getDto(EstadoAgendamiento agendamiento);
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.qsoft.erp.dominio.mapper;
|
||||
|
||||
import com.qsoft.erp.dto.EstadoLiquidacionDTO;
|
||||
import com.qsoft.erp.model.EstadoLiquidacion;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author james
|
||||
*/
|
||||
@Mapper
|
||||
public interface EstadoLiquidacionMapper {
|
||||
|
||||
EstadoLiquidacionMapper INSTANCE = Mappers.getMapper(EstadoLiquidacionMapper.class);
|
||||
|
||||
@Mapping(source = "detEstado", target = "detEstado.detCodigo")
|
||||
@Mapping(source = "liqCodigo", target = "liqCodigo.liqCodigo")
|
||||
@Mapping(source = "usuCodigo", target = "usuCodigo.usuCodigo")
|
||||
@Mapping(source = "usuUsuario", target = "usuCodigo.usuUsuario")
|
||||
@Mapping(source = "usuNombre", target = "usuCodigo.usuNombre")
|
||||
EstadoLiquidacion getEntidad(EstadoLiquidacionDTO estadoLiquidacionDTO);
|
||||
|
||||
@Mapping(target = "detEstado", source = "detEstado.detCodigo")
|
||||
@Mapping(target = "liqCodigo", source = "liqCodigo.liqCodigo")
|
||||
@Mapping(target = "usuCodigo", source = "usuCodigo.usuCodigo")
|
||||
@Mapping(target = "usuUsuario", source = "usuCodigo.usuUsuario")
|
||||
@Mapping(target = "usuNombre", source = "usuCodigo.usuNombre")
|
||||
EstadoLiquidacionDTO getDto(EstadoLiquidacion estadoLiquidacion);
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,94 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.qsoft.erp.dominio.mapper;
|
||||
|
||||
import com.qsoft.erp.dto.FormularioDTO;
|
||||
import com.qsoft.erp.model.Formulario;
|
||||
import org.mapstruct.AfterMapping;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.MappingTarget;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author james
|
||||
*/
|
||||
@Mapper
|
||||
public interface FormularioMapper {
|
||||
|
||||
FormularioMapper INSTANCE = Mappers.getMapper(FormularioMapper.class);
|
||||
|
||||
@Mapping(source = "empCodigo", target = "empCodigo.empCodigo")
|
||||
@Mapping(source = "liqCodigo", target = "liqCodigo.liqCodigo")
|
||||
@Mapping(source = "detTipo", target = "detTipo.detCodigo")
|
||||
@Mapping(source = "perTitular", target = "perTitular.perCodigo")
|
||||
@Mapping(source = "perPaciente", target = "perPaciente.perCodigo")
|
||||
@Mapping(source = "polCodigo", target = "polCodigo.polCodigo")
|
||||
@Mapping(source = "cueCodigo", target = "cueCodigo.cueCodigo")
|
||||
@Mapping(source = "detProcedimiento", target = "detProcedimiento.detCodigo")
|
||||
@Mapping(source = "detCie10", target = "detCie10.detCodigo")
|
||||
@Mapping(source = "plaCodigo", target = "plaCodigo.plaCodigo")
|
||||
@Mapping(source = "preCodigo", target = "preCodigo.preCodigo")
|
||||
@Mapping(source = "cie10Nemonico", target = "detCie10.detNemonico")
|
||||
@Mapping(source = "tipoNemonico", target = "detTipo.detNemonico")
|
||||
@Mapping(source = "procedimientoNemonico", target = "detProcedimiento.detNemonico")
|
||||
Formulario getEntidad(FormularioDTO formularioDTO);
|
||||
|
||||
@Mapping(target = "empCodigo", source = "empCodigo.empCodigo")
|
||||
@Mapping(target = "liqCodigo", source = "liqCodigo.liqCodigo")
|
||||
@Mapping(target = "detTipo", source = "detTipo.detCodigo")
|
||||
@Mapping(target = "perTitular", source = "perTitular.perCodigo")
|
||||
@Mapping(target = "perPaciente", source = "perPaciente.perCodigo")
|
||||
@Mapping(target = "polCodigo", source = "polCodigo.polCodigo")
|
||||
@Mapping(target = "cueCodigo", source = "cueCodigo.cueCodigo")
|
||||
@Mapping(target = "detProcedimiento", source = "detProcedimiento.detCodigo")
|
||||
@Mapping(target = "detCie10", source = "detCie10.detCodigo")
|
||||
@Mapping(target = "plaCodigo", source = "plaCodigo.plaCodigo")
|
||||
@Mapping(target = "preCodigo", source = "preCodigo.preCodigo")
|
||||
@Mapping(target = "cie10Nemonico", source = "detCie10.detNemonico")
|
||||
@Mapping(target = "tipoNemonico", source = "detTipo.detNemonico")
|
||||
@Mapping(target = "procedimientoNemonico", source = "detProcedimiento.detNemonico")
|
||||
FormularioDTO getDto(Formulario formulario);
|
||||
|
||||
@AfterMapping
|
||||
default void validaObjetos(FormularioDTO formularioDTO, @MappingTarget Formulario formulario) {
|
||||
if (formulario.getEmpCodigo().getEmpCodigo() == null) {
|
||||
formulario.setEmpCodigo(null);
|
||||
}
|
||||
if (formulario.getLiqCodigo().getLiqCodigo() == null) {
|
||||
formulario.setLiqCodigo(null);
|
||||
}
|
||||
if (formulario.getDetTipo().getDetCodigo() == null) {
|
||||
formulario.setDetTipo(null);
|
||||
}
|
||||
if (formulario.getPerPaciente().getPerCodigo() == null) {
|
||||
formulario.setPerPaciente(null);
|
||||
}
|
||||
if (formulario.getPerTitular().getPerCodigo() == null) {
|
||||
formulario.setPerTitular(null);
|
||||
}
|
||||
if (formulario.getPolCodigo().getPolCodigo() == null) {
|
||||
formulario.setPolCodigo(null);
|
||||
}
|
||||
if (formulario.getCueCodigo().getCueCodigo() == null) {
|
||||
formulario.setCueCodigo(null);
|
||||
}
|
||||
if (formulario.getDetProcedimiento().getDetCodigo() == null) {
|
||||
formulario.setDetProcedimiento(null);
|
||||
}
|
||||
if (formulario.getDetCie10().getDetCodigo() == null) {
|
||||
formulario.setDetCie10(null);
|
||||
}
|
||||
if (formulario.getPlaCodigo().getPlaCodigo() == null) {
|
||||
formulario.setPlaCodigo(null);
|
||||
}
|
||||
if (formulario.getPreCodigo().getPreCodigo() == null) {
|
||||
formulario.setPreCodigo(null);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
package com.qsoft.erp.dominio.mapper;
|
||||
|
||||
import com.qsoft.erp.dto.HonorarioDTO;
|
||||
import com.qsoft.erp.model.Honorario;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
@Mapper
|
||||
public interface HonorarioMapper {
|
||||
|
||||
HonorarioMapper INSTANCE = Mappers.getMapper(HonorarioMapper.class);
|
||||
|
||||
@Mapping(source = "detGrupo", target = "detGrupo.detCodigo")
|
||||
Honorario getEntidad(HonorarioDTO honorarioDTO);
|
||||
|
||||
@Mapping(target = "detGrupo", source = "detGrupo.detCodigo")
|
||||
HonorarioDTO getDto(Honorario email);
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
package com.qsoft.erp.dominio.mapper;
|
||||
|
||||
import com.qsoft.erp.dto.HonorarioPlanDTO;
|
||||
import com.qsoft.erp.model.HonorarioPlan;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
@Mapper
|
||||
public interface HonorarioPlanMapper {
|
||||
|
||||
HonorarioPlanMapper INSTANCE = Mappers.getMapper(HonorarioPlanMapper.class);
|
||||
|
||||
@Mapping(source = "plaCodigo", target = "plaCodigo.plaCodigo")
|
||||
@Mapping(source = "detAtencion", target = "detAtencion.detCodigo")
|
||||
HonorarioPlan getEntidad(HonorarioPlanDTO email);
|
||||
|
||||
@Mapping(target = "plaCodigo", source = "plaCodigo.plaCodigo")
|
||||
@Mapping(target = "detAtencion", source = "detAtencion.detCodigo")
|
||||
HonorarioPlanDTO getDto(HonorarioPlan email);
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,107 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.qsoft.erp.dominio.mapper;
|
||||
|
||||
import com.qsoft.erp.constantes.DominioConstantes;
|
||||
import com.qsoft.erp.dominio.util.DominioUtil;
|
||||
import com.qsoft.erp.dto.DocumentoDTO;
|
||||
import com.qsoft.erp.dto.LiquidacionDTO;
|
||||
import com.qsoft.erp.model.Documento;
|
||||
import com.qsoft.erp.model.EstadoLiquidacion;
|
||||
import com.qsoft.erp.model.Liquidacion;
|
||||
import java.util.ArrayList;
|
||||
import org.mapstruct.AfterMapping;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.MappingTarget;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author james
|
||||
*/
|
||||
@Mapper
|
||||
public interface LiquidacionMapper {
|
||||
|
||||
LiquidacionMapper INSTANCE = Mappers.getMapper(LiquidacionMapper.class);
|
||||
|
||||
@Mapping(source = "cueOrigen", target = "cueOrigen.cueCodigo")
|
||||
@Mapping(source = "cueDestino", target = "cueDestino.cueCodigo")
|
||||
@Mapping(source = "detTipo", target = "detTipo.detCodigo")
|
||||
@Mapping(source = "detIfi", target = "detIfi.detCodigo")
|
||||
@Mapping(source = "polCodigo", target = "polCodigo.polCodigo")
|
||||
@Mapping(source = "perBeneficiario", target = "perBeneficiario.perCodigo")
|
||||
@Mapping(source = "tipoNemonico", target = "detTipo.detNemonico")
|
||||
@Mapping(source = "ifiNemonico", target = "detIfi.detNemonico")
|
||||
@Mapping(source = "beneficiarioIdentificacion", target = "perBeneficiario.perIdentificacion")
|
||||
@Mapping(source = "beneficiarioNombre", target = "perBeneficiario.perNombres")
|
||||
@Mapping(source = "beneficiarioApellido", target = "perBeneficiario.perApellidos")
|
||||
@Mapping(source = "detAtencion", target = "detAtencion.detCodigo")
|
||||
@Mapping(source = "atencionNombre", target = "detAtencion.detNombre")
|
||||
Liquidacion getEntidad(LiquidacionDTO liquidacionDTO);
|
||||
|
||||
@Mapping(target = "cueOrigen", source = "cueOrigen.cueCodigo")
|
||||
@Mapping(target = "cueDestino", source = "cueDestino.cueCodigo")
|
||||
@Mapping(target = "detTipo", source = "detTipo.detCodigo")
|
||||
@Mapping(target = "detIfi", source = "detIfi.detCodigo")
|
||||
@Mapping(target = "polCodigo", source = "polCodigo.polCodigo")
|
||||
@Mapping(target = "perBeneficiario", source = "perBeneficiario.perCodigo")
|
||||
@Mapping(target = "tipoNemonico", source = "detTipo.detNemonico")
|
||||
@Mapping(target = "ifiNemonico", source = "detIfi.detNemonico")
|
||||
@Mapping(target = "beneficiarioIdentificacion", source = "perBeneficiario.perIdentificacion")
|
||||
@Mapping(target = "beneficiarioNombre", source = "perBeneficiario.perNombres")
|
||||
@Mapping(target = "beneficiarioApellido", source = "perBeneficiario.perApellidos")
|
||||
@Mapping(target = "detAtencion", source = "detAtencion.detCodigo")
|
||||
@Mapping(target = "atencionNombre", source = "detAtencion.detNombre")
|
||||
LiquidacionDTO getDto(Liquidacion liquidacion);
|
||||
|
||||
@AfterMapping
|
||||
default void validaNulos(LiquidacionDTO liquidacionDTO, @MappingTarget Liquidacion liquidacion) {
|
||||
if (liquidacion.getCueDestino() != null && liquidacion.getCueDestino().getCueCodigo() == null) {
|
||||
liquidacion.setCueDestino(null);
|
||||
}
|
||||
if (liquidacion.getCueOrigen() != null && liquidacion.getCueOrigen().getCueCodigo() == null) {
|
||||
liquidacion.setCueOrigen(null);
|
||||
}
|
||||
if (liquidacion.getDetIfi() != null && liquidacion.getDetIfi().getDetCodigo() == null) {
|
||||
liquidacion.setDetIfi(null);
|
||||
}
|
||||
if (liquidacion.getDetTipo() != null && liquidacion.getDetTipo().getDetCodigo() == null) {
|
||||
liquidacion.setDetTipo(null);
|
||||
}
|
||||
if (liquidacion.getDetAtencion() != null && liquidacion.getDetAtencion().getDetCodigo() == null) {
|
||||
liquidacion.setDetAtencion(null);
|
||||
}
|
||||
if (liquidacion.getPerBeneficiario() != null && liquidacion.getPerBeneficiario().getPerCodigo() == null) {
|
||||
liquidacion.setPerBeneficiario(null);
|
||||
}
|
||||
}
|
||||
|
||||
@AfterMapping
|
||||
default void validaObjetos(Liquidacion liquidacion, @MappingTarget LiquidacionDTO liquidacionDTO) {
|
||||
liquidacionDTO.setEstados(new ArrayList<>());
|
||||
liquidacionDTO.setDocumentos(new ArrayList<>());
|
||||
if (liquidacion.getEstadoLiquidacionCollection() != null && !liquidacion.getEstadoLiquidacionCollection().isEmpty()) {
|
||||
for (EstadoLiquidacion el : liquidacion.getEstadoLiquidacionCollection()) {
|
||||
liquidacionDTO.getEstados().add(EstadoLiquidacionMapper.INSTANCE.getDto(el));
|
||||
}
|
||||
}
|
||||
if (liquidacion.getDocumentoCollection() != null && !liquidacion.getDocumentoCollection().isEmpty()) {
|
||||
for (Documento doc : liquidacion.getDocumentoCollection()) {
|
||||
if (doc.getDocEstado().equals(DominioConstantes.ACTIVO)) {
|
||||
DocumentoDTO dcto = new DocumentoDTO();
|
||||
dcto.setDocCodigo(doc.getDocCodigo());
|
||||
dcto.setDocNombre(doc.getDocNombre());
|
||||
liquidacionDTO.getDocumentos().add(dcto);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (liquidacion.getLiqReporte() != null && !liquidacion.getLiqReporte().isBlank()) {
|
||||
liquidacionDTO.setLiqReporte(DominioUtil.getArchivo(liquidacion.getLiqReporte()));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
package com.qsoft.erp.dominio.mapper;
|
||||
|
||||
import com.qsoft.erp.model.Localizacion;
|
||||
import com.qsoft.erp.dto.LocalizacionDTO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
@Mapper
|
||||
public interface LocalizacionMapper {
|
||||
|
||||
LocalizacionMapper INSTANCE = Mappers.getMapper(LocalizacionMapper.class);
|
||||
|
||||
@Mapping(source = "locPadre", target = "locPadre.locCodigo")
|
||||
Localizacion getEntidad(LocalizacionDTO localizacion);
|
||||
|
||||
@Mapping(target = "locPadre", source = "locPadre.locCodigo")
|
||||
LocalizacionDTO getDto(Localizacion localizacion);
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.qsoft.erp.dominio.mapper;
|
||||
|
||||
import com.qsoft.dao.bdd.DaoBDDUtil;
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author james
|
||||
*/
|
||||
public class MapperUtil {
|
||||
|
||||
public static synchronized boolean isEmptyDTO(Object dto) {
|
||||
boolean estado = true;
|
||||
Object dato;
|
||||
|
||||
for (Field f : dto.getClass().getDeclaredFields()) {
|
||||
try {
|
||||
dato = DaoBDDUtil.getValue(f, dto);
|
||||
if (dato != null) {
|
||||
estado = false;
|
||||
break;
|
||||
}
|
||||
} catch (IllegalArgumentException | IllegalAccessException ex) {
|
||||
ex.printStackTrace(System.err);
|
||||
}
|
||||
}
|
||||
|
||||
return estado;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
package com.qsoft.erp.dominio.mapper;
|
||||
|
||||
import com.qsoft.erp.model.Mensaje;
|
||||
import com.qsoft.erp.dto.MensajeDTO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
@Mapper
|
||||
public interface MensajeMapper {
|
||||
|
||||
MensajeMapper INSTANCE = Mappers.getMapper(MensajeMapper.class);
|
||||
|
||||
@Mapping(source = "detIdioma", target = "detIdioma.detCodigo")
|
||||
@Mapping(source = "detAplicacion", target = "detAplicacion.detCodigo")
|
||||
@Mapping(source = "detServicio", target = "detServicio.detCodigo")
|
||||
@Mapping(source = "detTipoMensaje", target = "detTipoMensaje.detCodigo")
|
||||
@Mapping(source = "empCodigo", target = "empCodigo.empCodigo")
|
||||
Mensaje getEntidad(MensajeDTO mensaje);
|
||||
|
||||
@Mapping(target = "detIdioma", source = "detIdioma.detCodigo")
|
||||
@Mapping(target = "detAplicacion", source = "detAplicacion.detCodigo")
|
||||
@Mapping(target = "detServicio", source = "detServicio.detCodigo")
|
||||
@Mapping(target = "detTipoMensaje", source = "detTipoMensaje.detCodigo")
|
||||
@Mapping(target = "empCodigo", source = "empCodigo.empCodigo")
|
||||
MensajeDTO getDto(Mensaje mensaje);
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.qsoft.erp.dominio.mapper;
|
||||
|
||||
import com.qsoft.erp.dto.OpcionDTO;
|
||||
import com.qsoft.erp.model.Opcion;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author james
|
||||
*/
|
||||
@Mapper
|
||||
public interface OpcionMapper {
|
||||
|
||||
OpcionMapper INSTANCE = Mappers.getMapper(OpcionMapper.class);
|
||||
|
||||
@Mapping(source = "opcPadre", target = "opcPadre.opcCodigo")
|
||||
@Mapping(source = "detTipo", target = "detTipo.detCodigo")
|
||||
Opcion getEntidad(OpcionDTO opcionDTO);
|
||||
|
||||
@Mapping(source = "opcPadre.opcCodigo", target = "opcPadre")
|
||||
@Mapping(source = "detTipo.detCodigo", target = "detTipo")
|
||||
OpcionDTO getDto(Opcion opcion);
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
package com.qsoft.erp.dominio.mapper;
|
||||
|
||||
//@Mapper
|
||||
public interface OtpMapper {
|
||||
|
||||
// OtpMapper INSTANCE = Mappers.getMapper(OtpMapper.class);
|
||||
//
|
||||
// Otp getEntidad(OtpDTO otp);
|
||||
//
|
||||
// OtpDTO getDto(Otp otp);
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,52 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.qsoft.erp.dominio.mapper;
|
||||
|
||||
import com.qsoft.erp.dto.DocumentoDTO;
|
||||
import com.qsoft.erp.dto.PagoDTO;
|
||||
import com.qsoft.erp.model.Documento;
|
||||
import com.qsoft.erp.model.Pago;
|
||||
import org.mapstruct.AfterMapping;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.MappingTarget;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author james
|
||||
*/
|
||||
@Mapper
|
||||
public interface PagoMapper {
|
||||
|
||||
PagoMapper INSTANCE = Mappers.getMapper(PagoMapper.class);
|
||||
|
||||
@Mapping(source = "polCodigo", target = "polCodigo.polCodigo")
|
||||
@Mapping(source = "polContrato", target = "polCodigo.polContrato")
|
||||
@Mapping(source = "detEstado", target = "detEstado.detCodigo")
|
||||
@Mapping(source = "detNombre", target = "detEstado.detNombre")
|
||||
@Mapping(source = "detNemonico", target = "detEstado.detNemonico")
|
||||
Pago getEntidad(PagoDTO pagoDTO);
|
||||
|
||||
@Mapping(target = "polCodigo", source = "polCodigo.polCodigo")
|
||||
@Mapping(target = "polContrato", source = "polCodigo.polContrato")
|
||||
@Mapping(target = "detEstado", source = "detEstado.detCodigo")
|
||||
@Mapping(target = "detNombre", source = "detEstado.detNombre")
|
||||
@Mapping(target = "detNemonico", source = "detEstado.detNemonico")
|
||||
PagoDTO getDto(Pago pago);
|
||||
|
||||
@AfterMapping
|
||||
default void validaNulos(PagoDTO documentoDTO, @MappingTarget Pago documento) {
|
||||
|
||||
if (documento.getPolCodigo()!= null && documento.getPolCodigo().getPolCodigo()== null) {
|
||||
documento.setPolCodigo(null);
|
||||
}
|
||||
if (documento.getDetEstado()!= null && documento.getDetEstado().getDetCodigo()== null) {
|
||||
documento.setDetEstado(null);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
package com.qsoft.erp.dominio.mapper;
|
||||
|
||||
import com.qsoft.erp.model.Parametro;
|
||||
import com.qsoft.erp.dto.ParametroDTO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
@Mapper
|
||||
public interface ParametroMapper {
|
||||
|
||||
ParametroMapper INSTANCE = Mappers.getMapper(ParametroMapper.class);
|
||||
|
||||
@Mapping(source = "parCodigoPadre", target = "parCodigoPadre.parCodigo")
|
||||
Parametro getEntidad(ParametroDTO parametro);
|
||||
|
||||
@Mapping(target = "parCodigoPadre", source = "parCodigoPadre.parCodigo")
|
||||
ParametroDTO getDto(Parametro parametro);
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,76 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.qsoft.erp.dominio.mapper;
|
||||
|
||||
import com.qsoft.erp.dto.PersonaDTO;
|
||||
import com.qsoft.erp.model.CuentaBancaria;
|
||||
import com.qsoft.erp.model.Persona;
|
||||
import com.qsoft.erp.model.Telefono;
|
||||
import java.util.ArrayList;
|
||||
import org.mapstruct.AfterMapping;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.MappingTarget;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author james
|
||||
*/
|
||||
@Mapper
|
||||
public interface PersonaMapper {
|
||||
|
||||
PersonaMapper INSTANCE = Mappers.getMapper(PersonaMapper.class);
|
||||
|
||||
@Mapping(source = "detTipoIdentificacion", target = "detTipoIdentificacion.detCodigo")
|
||||
@Mapping(source = "detGenero", target = "detGenero.detCodigo")
|
||||
@Mapping(source = "locCodigo", target = "locCodigo.locCodigo")
|
||||
@Mapping(source = "locNombre", target = "locCodigo.locNombre")
|
||||
@Mapping(source = "detEstadoPoliza", target = "detEstadoPoliza.detCodigo")
|
||||
Persona getEntidad(PersonaDTO personaDTO);
|
||||
|
||||
@Mapping(target = "detTipoIdentificacion", source = "detTipoIdentificacion.detCodigo")
|
||||
@Mapping(target = "detGenero", source = "detGenero.detCodigo")
|
||||
@Mapping(target = "locCodigo", source = "locCodigo.locCodigo")
|
||||
@Mapping(target = "locNombre", source = "locCodigo.locNombre")
|
||||
@Mapping(target = "detEstadoPoliza", source = "detEstadoPoliza.detCodigo")
|
||||
PersonaDTO getDto(Persona persona);
|
||||
|
||||
@AfterMapping
|
||||
default void validaObjetos(Persona persona, @MappingTarget PersonaDTO personaDTO) {
|
||||
personaDTO.setTelefono(new ArrayList<>());
|
||||
if (persona.getTelefonoCollection() != null && !persona.getTelefonoCollection().isEmpty()) {
|
||||
for (Telefono el : persona.getTelefonoCollection()) {
|
||||
personaDTO.getTelefono().add(TelefonoMapper.INSTANCE.getDto(el));
|
||||
}
|
||||
}
|
||||
personaDTO.setCuentasBancarias(new ArrayList<>());
|
||||
if (persona.getCuentaBancariaCollection()!= null && !persona.getCuentaBancariaCollection().isEmpty()) {
|
||||
for (CuentaBancaria el : persona.getCuentaBancariaCollection()) {
|
||||
personaDTO.getCuentasBancarias().add(CuentaBancariaMapper.INSTANCE.getDto(el));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@AfterMapping
|
||||
default void validarNulos(Persona persona, @MappingTarget PersonaDTO personaDTO) {
|
||||
if (persona.getDetTipoIdentificacion()!= null && persona.getDetTipoIdentificacion().getDetCodigo()== null) {
|
||||
persona.setDetTipoIdentificacion(null);
|
||||
}
|
||||
|
||||
if (persona.getDetGenero()!= null && persona.getDetGenero().getDetCodigo()== null) {
|
||||
persona.setDetGenero(null);
|
||||
}
|
||||
if (persona.getDetEstadoPoliza()!= null && persona.getDetEstadoPoliza().getDetCodigo()== null) {
|
||||
persona.setDetEstadoPoliza(null);
|
||||
}
|
||||
if (persona.getLocCodigo()!= null && persona.getLocCodigo().getLocCodigo()== null) {
|
||||
persona.setLocCodigo(null);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.qsoft.erp.dominio.mapper;
|
||||
|
||||
import com.qsoft.erp.dto.PersonaPolizaDTO;
|
||||
import com.qsoft.erp.model.PersonaPoliza;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author james
|
||||
*/
|
||||
@Mapper
|
||||
public interface PersonaPolizaMapper {
|
||||
|
||||
PersonaPolizaMapper INSTANCE = Mappers.getMapper(PersonaPolizaMapper.class);
|
||||
|
||||
@Mapping(source = "detTipoPersona", target = "detTipoPersona.detCodigo")
|
||||
@Mapping(source = "perCodigo", target = "perCodigo.perCodigo")
|
||||
@Mapping(source = "polCodigo", target = "polCodigo.polCodigo")
|
||||
@Mapping(source = "polContrato", target = "polCodigo.polContrato")
|
||||
@Mapping(source = "perGenero", target = "perCodigo.detGenero.detCodigo")
|
||||
@Mapping(source = "perDireccion", target = "perCodigo.perDireccion")
|
||||
@Mapping(source = "perFechaNacimiento", target = "perCodigo.perFechaNacimiento")
|
||||
@Mapping(source = "detTipoIdentificacion", target = "perCodigo.detTipoIdentificacion.detCodigo")
|
||||
@Mapping(source = "perEstado", target = "perCodigo.perEstado")
|
||||
@Mapping(source = "perMail", target = "perCodigo.perMail")
|
||||
@Mapping(source = "perNacionalidad", target = "perCodigo.perNacionalidad")
|
||||
@Mapping(source = "perApellidos", target = "perCodigo.perApellidos")
|
||||
@Mapping(source = "perNombres", target = "perCodigo.perNombres")
|
||||
@Mapping(source = "perIdentificacion", target = "perCodigo.perIdentificacion")
|
||||
PersonaPoliza getEntidad(PersonaPolizaDTO personaPolizaDTO);
|
||||
|
||||
@Mapping(target = "detTipoPersona", source = "detTipoPersona.detCodigo")
|
||||
@Mapping(target = "perCodigo", source = "perCodigo.perCodigo")
|
||||
@Mapping(target = "polCodigo", source = "polCodigo.polCodigo")
|
||||
@Mapping(target = "polContrato", source = "polCodigo.polContrato")
|
||||
@Mapping(target = "perGenero", source = "perCodigo.detGenero.detCodigo")
|
||||
@Mapping(target = "perDireccion", source = "perCodigo.perDireccion")
|
||||
@Mapping(target = "perFechaNacimiento", source = "perCodigo.perFechaNacimiento")
|
||||
@Mapping(target = "detTipoIdentificacion", source = "perCodigo.detTipoIdentificacion.detCodigo")
|
||||
@Mapping(target = "perEstado", source = "perCodigo.perEstado")
|
||||
@Mapping(target = "perMail", source = "perCodigo.perMail")
|
||||
@Mapping(target = "perNacionalidad", source = "perCodigo.perNacionalidad")
|
||||
@Mapping(target = "perApellidos", source = "perCodigo.perApellidos")
|
||||
@Mapping(target = "perNombres", source = "perCodigo.perNombres")
|
||||
@Mapping(target = "perIdentificacion", source = "perCodigo.perIdentificacion")
|
||||
PersonaPolizaDTO getDto(PersonaPoliza personaPoliza);
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.qsoft.erp.dominio.mapper;
|
||||
|
||||
import com.qsoft.erp.dto.PlanBrokerDTO;
|
||||
import com.qsoft.erp.model.PlanBroker;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author james
|
||||
*/
|
||||
@Mapper
|
||||
public interface PlanBrokerMapper {
|
||||
|
||||
PlanBrokerMapper INSTANCE = Mappers.getMapper(PlanBrokerMapper.class);
|
||||
|
||||
@Mapping(source = "plaCodigo", target = "plaCodigo.plaCodigo")
|
||||
@Mapping(source = "plaNombre", target = "plaCodigo.plaNombre")
|
||||
@Mapping(source = "plaProducto", target = "plaCodigo.plaProducto")
|
||||
@Mapping(source = "plaValorAnual", target = "plaCodigo.plaValorAnual")
|
||||
@Mapping(source = "plaValorMensual", target = "plaCodigo.plaValorMensual")
|
||||
@Mapping(source = "empCodigo", target = "empCodigo.empCodigo")
|
||||
@Mapping(source = "empIdentificacion", target = "empCodigo.empIdentificacion")
|
||||
@Mapping(source = "empRazonSocial", target = "empCodigo.empRazonSocial")
|
||||
PlanBroker getEntidad(PlanBrokerDTO planBrokerDTO);
|
||||
|
||||
@Mapping(target = "plaCodigo", source = "plaCodigo.plaCodigo")
|
||||
@Mapping(target = "plaNombre", source = "plaCodigo.plaNombre")
|
||||
@Mapping(target = "plaProducto", source = "plaCodigo.plaProducto")
|
||||
@Mapping(target = "plaValorAnual", source = "plaCodigo.plaValorAnual")
|
||||
@Mapping(target = "plaValorMensual", source = "plaCodigo.plaValorMensual")
|
||||
@Mapping(target = "empCodigo", source = "empCodigo.empCodigo")
|
||||
@Mapping(target = "empIdentificacion", source = "empCodigo.empIdentificacion")
|
||||
@Mapping(target = "empRazonSocial", source = "empCodigo.empRazonSocial")
|
||||
PlanBrokerDTO getDto(PlanBroker planBroker);
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,53 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.qsoft.erp.dominio.mapper;
|
||||
|
||||
import com.qsoft.erp.dto.PlanDTO;
|
||||
import com.qsoft.erp.model.CoberturasPlan;
|
||||
import com.qsoft.erp.model.Plan;
|
||||
import java.util.ArrayList;
|
||||
import org.mapstruct.AfterMapping;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.MappingTarget;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author james
|
||||
*/
|
||||
@Mapper
|
||||
public interface PlanMapper {
|
||||
|
||||
PlanMapper INSTANCE = Mappers.getMapper(PlanMapper.class);
|
||||
|
||||
@Mapping(source = "detTipo", target = "detTipo.detCodigo")
|
||||
@Mapping(source = "detModalidad", target = "detModalidad.detCodigo")
|
||||
@Mapping(source = "detDeducible", target = "detDeducible.detCodigo")
|
||||
@Mapping(source = "detTarifario", target = "detTarifario.detCodigo")
|
||||
@Mapping(source = "empCodigo", target = "empCodigo.empCodigo")
|
||||
Plan getEntidad(PlanDTO rolDTO);
|
||||
|
||||
@Mapping(target = "detTipo", source = "detTipo.detCodigo")
|
||||
@Mapping(target = "detModalidad", source = "detModalidad.detCodigo")
|
||||
@Mapping(target = "detDeducible", source = "detDeducible.detCodigo")
|
||||
@Mapping(target = "detTarifario", source = "detTarifario.detCodigo")
|
||||
@Mapping(target = "empCodigo", source = "empCodigo.empCodigo")
|
||||
PlanDTO getDto(Plan rol);
|
||||
|
||||
@AfterMapping
|
||||
default void validaObjetos(Plan plan, @MappingTarget PlanDTO planDTO) {
|
||||
planDTO.setCoberturasPlan(new ArrayList<>());
|
||||
if (plan.getCoberturasPlanCollection() != null && !plan.getCoberturasPlanCollection().isEmpty()) {
|
||||
for (CoberturasPlan el : plan.getCoberturasPlanCollection()) {
|
||||
planDTO.getCoberturasPlan().add(CoberturasPlanMapper.INSTANCE.getDto(el));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
package com.qsoft.erp.dominio.mapper;
|
||||
|
||||
import com.qsoft.erp.model.Plantilla;
|
||||
import com.qsoft.erp.dto.PlantillaDTO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
@Mapper
|
||||
public interface PlantillaMapper {
|
||||
|
||||
PlantillaMapper INSTANCE = Mappers.getMapper(PlantillaMapper.class);
|
||||
|
||||
Plantilla getEntidad(PlantillaDTO plantilla);
|
||||
|
||||
PlantillaDTO getDto(Plantilla plantilla);
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
package com.qsoft.erp.dominio.mapper;
|
||||
|
||||
import com.qsoft.erp.model.PlantillaSmtp;
|
||||
import com.qsoft.erp.dto.PlantillaSmtpDTO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
@Mapper
|
||||
public interface PlantillaSmtpMapper {
|
||||
|
||||
PlantillaSmtpMapper INSTANCE = Mappers.getMapper(PlantillaSmtpMapper.class);
|
||||
|
||||
@Mapping(source = "parCodigo", target = "parCodigo.parCodigo")
|
||||
@Mapping(source = "plaCodigo", target = "plaCodigo.plaCodigo")
|
||||
PlantillaSmtp getEntidad(PlantillaSmtpDTO plantillaSmtp);
|
||||
|
||||
@Mapping(target = "parCodigo", source = "parCodigo.parCodigo")
|
||||
@Mapping(target = "plaCodigo", source = "plaCodigo.plaCodigo")
|
||||
PlantillaSmtpDTO getDto(PlantillaSmtp plantillaSmtp);
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,94 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.qsoft.erp.dominio.mapper;
|
||||
|
||||
import com.qsoft.dao.exception.DaoException;
|
||||
import com.qsoft.erp.dao.DaoGenerico;
|
||||
import com.qsoft.erp.dominio.util.DominioUtil;
|
||||
import com.qsoft.erp.dominio.util.PolizaUtil;
|
||||
import com.qsoft.erp.dto.PolizaDTO;
|
||||
import com.qsoft.erp.model.EstadoPoliza;
|
||||
import com.qsoft.erp.model.Poliza;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.mapstruct.AfterMapping;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.MappingTarget;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author james
|
||||
*/
|
||||
@Mapper
|
||||
public interface PolizaMapper {
|
||||
|
||||
PolizaMapper INSTANCE = Mappers.getMapper(PolizaMapper.class);
|
||||
|
||||
@Mapping(source = "detModalidad", target = "detModalidad.detCodigo")
|
||||
@Mapping(source = "detSucursalIfi", target = "detSucursalIfi.detCodigo")
|
||||
@Mapping(source = "detFormaPago", target = "detFormaPago.detCodigo")
|
||||
@Mapping(source = "detPeriodicidad", target = "detPeriodicidad.detCodigo")
|
||||
@Mapping(source = "plaCodigo", target = "plaCodigo.plaCodigo")
|
||||
@Mapping(source = "modalidadNemonico", target = "detModalidad.detNemonico")
|
||||
@Mapping(source = "periodicidadNemonico", target = "detPeriodicidad.detNemonico")
|
||||
@Mapping(source = "formaPagoNemonico", target = "detFormaPago.detNemonico")
|
||||
@Mapping(source = "detIfi", target = "detIfi.detCodigo")
|
||||
@Mapping(source = "empCodigo", target = "empCodigo.empCodigo")
|
||||
Poliza getEntidad(PolizaDTO pagoDTO);
|
||||
|
||||
@Mapping(target = "detModalidad", source = "detModalidad.detCodigo")
|
||||
@Mapping(target = "detSucursalIfi", source = "detSucursalIfi.detCodigo")
|
||||
@Mapping(target = "detPeriodicidad", source = "detPeriodicidad.detCodigo")
|
||||
@Mapping(target = "detFormaPago", source = "detFormaPago.detCodigo")
|
||||
@Mapping(target = "plaCodigo", source = "plaCodigo.plaCodigo")
|
||||
@Mapping(target = "modalidadNemonico", source = "detModalidad.detNemonico")
|
||||
@Mapping(target = "periodicidadNemonico", source = "detPeriodicidad.detNemonico")
|
||||
@Mapping(target = "formaPagoNemonico", source = "detFormaPago.detNemonico")
|
||||
@Mapping(target = "detIfi", source = "detIfi.detCodigo")
|
||||
@Mapping(target = "empCodigo", source = "empCodigo.empCodigo")
|
||||
PolizaDTO getDto(Poliza pago);
|
||||
|
||||
@AfterMapping
|
||||
default void cargaArchivos(Poliza poliza, @MappingTarget PolizaDTO polizaDTO) {
|
||||
if (poliza.getPolObservacion() != null && !poliza.getPolObservacion().isBlank()) {
|
||||
polizaDTO.setPoliza(DominioUtil.getArchivo(poliza.getPolObservacion()));
|
||||
polizaDTO.setPolObservacion(DominioUtil.getNombreArchivo(poliza.getPolObservacion().trim()));
|
||||
}
|
||||
|
||||
if (poliza.getPolAceptacion() != null && !poliza.getPolAceptacion().isBlank()) {
|
||||
polizaDTO.setPolAceptacion(DominioUtil.getArchivo(poliza.getPolAceptacion().trim()));
|
||||
}
|
||||
}
|
||||
|
||||
@AfterMapping
|
||||
default void validarNulos(Poliza poliza, @MappingTarget PolizaDTO polizaDTO){
|
||||
if(poliza.getPlaCodigo() != null && poliza.getPlaCodigo().getPlaCodigo() == null){
|
||||
poliza.setPlaCodigo(null);
|
||||
}
|
||||
if(poliza.getDetIfi() != null && poliza.getDetIfi().getDetCodigo() == null){
|
||||
poliza.setDetIfi(null);
|
||||
}
|
||||
if(poliza.getDetSucursalIfi()!= null && poliza.getDetSucursalIfi().getDetCodigo() == null){
|
||||
poliza.setDetSucursalIfi(null);
|
||||
}
|
||||
}
|
||||
|
||||
@AfterMapping
|
||||
default void cargarEstadoActual(Poliza poliza, @MappingTarget PolizaDTO polizaDTO){
|
||||
PolizaUtil polUtil = new PolizaUtil();
|
||||
try {
|
||||
EstadoPoliza ultimo = polUtil.buscarUltimoEstadoActivo(poliza, new DaoGenerico<>(EstadoPoliza.class));
|
||||
if(ultimo != null){
|
||||
polizaDTO.setDetEstado(ultimo.getDetEstado().getDetCodigo());
|
||||
polizaDTO.setEstadoNemonico(ultimo.getDetEstado().getDetNemonico());
|
||||
}
|
||||
} catch (DaoException ex) {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,65 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.qsoft.erp.dominio.mapper;
|
||||
|
||||
import com.qsoft.erp.dto.PrestadorDTO;
|
||||
import com.qsoft.erp.model.Prestador;
|
||||
import org.mapstruct.AfterMapping;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.MappingTarget;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author james
|
||||
*/
|
||||
@Mapper
|
||||
public interface PrestadorMapper {
|
||||
|
||||
PrestadorMapper INSTANCE = Mappers.getMapper(PrestadorMapper.class);
|
||||
|
||||
@Mapping(source = "detTipo", target = "detTipo.detCodigo")
|
||||
@Mapping(source = "preTipo", target = "detTipo.detNombre")
|
||||
@Mapping(source = "tipoNemonico", target = "detTipo.detNemonico")
|
||||
@Mapping(source = "detIfi", target = "detIfi.detCodigo")
|
||||
@Mapping(source = "ifiNombre", target = "detIfi.detNombre")
|
||||
@Mapping(source = "ifiNemonico", target = "detIfi.detNemonico")
|
||||
@Mapping(source = "detTipoCuenta", target = "detTipoCuenta.detCodigo")
|
||||
@Mapping(source = "tipoCuentaNombre", target = "detTipoCuenta.detNombre")
|
||||
@Mapping(source = "tipoCuentanemonico", target = "detTipoCuenta.detNemonico")
|
||||
@Mapping(source = "locCodigo", target = "locCodigo.locCodigo")
|
||||
@Mapping(source = "locNombre", target = "locCodigo.locNombre")
|
||||
Prestador getEntidad(PrestadorDTO prestadorDTO);
|
||||
|
||||
@Mapping(target = "detTipo", source = "detTipo.detCodigo")
|
||||
@Mapping(target = "preTipo", source = "detTipo.detNombre")
|
||||
@Mapping(target = "tipoNemonico", source = "detTipo.detNemonico")
|
||||
@Mapping(target = "detIfi", source = "detIfi.detCodigo")
|
||||
@Mapping(target = "ifiNombre", source = "detIfi.detNombre")
|
||||
@Mapping(target = "ifiNemonico", source = "detIfi.detNemonico")
|
||||
@Mapping(target = "detTipoCuenta", source = "detTipoCuenta.detCodigo")
|
||||
@Mapping(target = "tipoCuentaNombre", source = "detTipoCuenta.detNombre")
|
||||
@Mapping(target = "tipoCuentanemonico", source = "detTipoCuenta.detNemonico")
|
||||
@Mapping(target = "locCodigo", source = "locCodigo.locCodigo")
|
||||
@Mapping(target = "locNombre", source = "locCodigo.locNombre")
|
||||
PrestadorDTO getDto(Prestador prestador);
|
||||
|
||||
@AfterMapping
|
||||
default void validaNulos(PrestadorDTO prestadorDTO, @MappingTarget Prestador prestador) {
|
||||
if (prestador.getDetTipo() != null && prestador.getDetTipo().getDetCodigo() == null) {
|
||||
prestador.setDetTipo(null);
|
||||
}
|
||||
if (prestador.getDetIfi()!= null && prestador.getDetIfi().getDetCodigo() == null) {
|
||||
prestador.setDetIfi(null);
|
||||
}
|
||||
if (prestador.getDetTipoCuenta()!= null && prestador.getDetTipoCuenta().getDetCodigo() == null) {
|
||||
prestador.setDetTipoCuenta(null);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.qsoft.erp.dominio.mapper;
|
||||
|
||||
import com.qsoft.erp.dto.PrivilegioDTO;
|
||||
import com.qsoft.erp.model.Privilegio;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author james
|
||||
*/
|
||||
@Mapper
|
||||
public interface PrivilegioMapper {
|
||||
|
||||
PrivilegioMapper INSTANCE = Mappers.getMapper(PrivilegioMapper.class);
|
||||
|
||||
@Mapping(source = "opcCodigo", target = "opcCodigo.opcCodigo")
|
||||
@Mapping(source = "rolCodigo", target = "rolCodigo.rolCodigo")
|
||||
Privilegio getEntidad(PrivilegioDTO privilegioDTO);
|
||||
|
||||
@Mapping(source = "opcCodigo.opcCodigo", target = "opcCodigo")
|
||||
@Mapping(source = "rolCodigo.rolCodigo", target = "rolCodigo")
|
||||
PrivilegioDTO getDto(Privilegio privilegio);
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.qsoft.erp.dominio.mapper;
|
||||
|
||||
import com.qsoft.erp.dto.RolDTO;
|
||||
import com.qsoft.erp.model.Rol;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author james
|
||||
*/
|
||||
@Mapper
|
||||
public interface RolMapper {
|
||||
|
||||
RolMapper INSTANCE = Mappers.getMapper(RolMapper.class);
|
||||
|
||||
Rol getEntidad(RolDTO rolDTO);
|
||||
|
||||
RolDTO getDto(Rol rol);
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
package com.qsoft.erp.dominio.mapper;
|
||||
|
||||
import com.qsoft.erp.dto.RolUsuarioDTO;
|
||||
import com.qsoft.erp.model.RolUsuario;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
@Mapper
|
||||
public interface RolUsuarioMapper {
|
||||
|
||||
RolUsuarioMapper INSTANCE = Mappers.getMapper(RolUsuarioMapper.class);
|
||||
|
||||
@Mapping(source = "rolCodigo", target = "rolCodigo.rolCodigo")
|
||||
@Mapping(source = "usuCodigo", target = "usuCodigo.usuCodigo")
|
||||
RolUsuario getEntidad(RolUsuarioDTO rolUsuario);
|
||||
|
||||
@Mapping(target = "rolCodigo", source = "rolCodigo.rolCodigo")
|
||||
@Mapping(target = "usuCodigo", source = "usuCodigo.usuCodigo")
|
||||
RolUsuarioDTO getDto(RolUsuario rolUsuario);
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
package com.qsoft.erp.dominio.mapper;
|
||||
|
||||
import com.qsoft.erp.model.Secuencia;
|
||||
import com.qsoft.erp.dto.SecuenciaDTO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
@Mapper
|
||||
public interface SecuenciaMapper {
|
||||
|
||||
SecuenciaMapper INSTANCE = Mappers.getMapper(SecuenciaMapper.class);
|
||||
|
||||
Secuencia getEntidad(SecuenciaDTO secuencia);
|
||||
|
||||
SecuenciaDTO getDto(Secuencia secuencia);
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
package com.qsoft.erp.dominio.mapper;
|
||||
|
||||
public interface ServiciosMapper {
|
||||
|
||||
// ServiciosMapper INSTANCE = Mappers.getMapper(ServiciosMapper.class);
|
||||
//
|
||||
// Servicios getEntidad(ServiciosDTO servicios);
|
||||
//
|
||||
// ServiciosDTO getDto(Servicios servicios);
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
package com.qsoft.erp.dominio.mapper;
|
||||
|
||||
import com.qsoft.erp.model.SucursalEmpresa;
|
||||
import com.qsoft.erp.dto.SucursalEmpresaDTO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
@Mapper
|
||||
public interface SucursalEmpresaMapper {
|
||||
|
||||
SucursalEmpresaMapper INSTANCE = Mappers.getMapper(SucursalEmpresaMapper.class);
|
||||
|
||||
@Mapping(source = "empCodigo", target = "empCodigo.empCodigo")
|
||||
SucursalEmpresa getEntidad(SucursalEmpresaDTO sucursalEmpresa);
|
||||
|
||||
@Mapping(target = "empCodigo", source = "empCodigo.empCodigo")
|
||||
SucursalEmpresaDTO getDto(SucursalEmpresa sucursalEmpresa);
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,57 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.qsoft.erp.dominio.mapper;
|
||||
|
||||
import com.qsoft.erp.dto.TarifaLiquidacionDTO;
|
||||
import com.qsoft.erp.model.TarifaLiquidacion;
|
||||
import java.util.Objects;
|
||||
import org.mapstruct.AfterMapping;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.MappingTarget;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author james
|
||||
*/
|
||||
@Mapper
|
||||
public interface TarifaLiquidacionMapper {
|
||||
|
||||
TarifaLiquidacionMapper INSTANCE = Mappers.getMapper(TarifaLiquidacionMapper.class);
|
||||
|
||||
@Mapping(source = "delCodigo", target = "delCodigo.delCodigo")
|
||||
@Mapping(source = "tarCodigo", target = "tarCodigo.tarCodigo")
|
||||
@Mapping(source = "honCodigo", target = "honCodigo.honCodigo")
|
||||
@Mapping(source = "tarNombre", target = "tarCodigo.tarNombre")
|
||||
@Mapping(source = "tarFormaFarma", target = "tarCodigo.tarFormaFarma")
|
||||
@Mapping(source = "tarPresentacion", target = "tarCodigo.tarPresentacion")
|
||||
@Mapping(source = "tarConcentracion", target = "tarCodigo.tarConcentracion")
|
||||
TarifaLiquidacion getEntidad(TarifaLiquidacionDTO tarifaLiquidacionDTO);
|
||||
|
||||
@Mapping(target = "delCodigo", source = "delCodigo.delCodigo")
|
||||
@Mapping(target = "tarCodigo", source = "tarCodigo.tarCodigo")
|
||||
@Mapping(target = "honCodigo", source = "honCodigo.honCodigo")
|
||||
@Mapping(target = "tarNombre", source = "tarCodigo.tarNombre")
|
||||
@Mapping(target = "tarFormaFarma", source = "tarCodigo.tarFormaFarma")
|
||||
@Mapping(target = "tarPresentacion", source = "tarCodigo.tarPresentacion")
|
||||
@Mapping(target = "tarConcentracion", source = "tarCodigo.tarConcentracion")
|
||||
TarifaLiquidacionDTO getDto(TarifaLiquidacion tarifaLiquidacion);
|
||||
|
||||
@AfterMapping
|
||||
default void validaNulos(TarifaLiquidacionDTO tarifaLiquidacionDTO, @MappingTarget TarifaLiquidacion tarifaLiquidacion) {
|
||||
System.out.println(String.format("Esta enviando del talCodigo = %s, el valor .%s.", tarifaLiquidacion.getTalCodigo(), tarifaLiquidacionDTO.getTarCodigo()));
|
||||
if (tarifaLiquidacion.getTarCodigo().getTarCodigo() == null) {
|
||||
tarifaLiquidacion.setTarCodigo(null);
|
||||
}
|
||||
|
||||
|
||||
if (tarifaLiquidacion.getHonCodigo().getHonCodigo() == null) {
|
||||
tarifaLiquidacion.setHonCodigo(null);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.qsoft.erp.dominio.mapper;
|
||||
|
||||
import com.qsoft.erp.dto.TarifarioDTO;
|
||||
import com.qsoft.erp.model.Tarifario;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author james
|
||||
*/
|
||||
@Mapper
|
||||
public interface TarifarioMapper {
|
||||
|
||||
TarifarioMapper INSTANCE = Mappers.getMapper(TarifarioMapper.class);
|
||||
|
||||
@Mapping(source = "detTipo", target = "detTipo.detCodigo")
|
||||
@Mapping(source = "tipoNombre", target = "detTipo.detNemonico")
|
||||
@Mapping(source = "tipoNemonico", target = "detTipo.detNombre")
|
||||
Tarifario getEntidad(TarifarioDTO tarifarioDTO);
|
||||
|
||||
@Mapping(target = "detTipo", source = "detTipo.detCodigo")
|
||||
@Mapping(target = "tipoNombre", source = "detTipo.detNemonico")
|
||||
@Mapping(target = "tipoNemonico", source = "detTipo.detNombre")
|
||||
TarifarioDTO getDto(Tarifario tarifario);
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.qsoft.erp.dominio.mapper;
|
||||
|
||||
import com.qsoft.erp.dto.TelefonoDTO;
|
||||
import com.qsoft.erp.model.Telefono;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author james
|
||||
*/
|
||||
@Mapper
|
||||
public interface TelefonoMapper {
|
||||
|
||||
TelefonoMapper INSTANCE = Mappers.getMapper(TelefonoMapper.class);
|
||||
|
||||
@Mapping(source = "detTipo", target = "detTipo.detCodigo")
|
||||
@Mapping(source = "detNombreTipo", target = "detTipo.detNombre")
|
||||
@Mapping(source = "perCodigo", target = "perCodigo.perCodigo")
|
||||
Telefono getEntidad(TelefonoDTO telefonoDTO);
|
||||
|
||||
@Mapping(source = "detTipo.detCodigo", target = "detTipo")
|
||||
@Mapping(source = "detTipo.detNombre", target = "detNombreTipo")
|
||||
@Mapping(source = "perCodigo.perCodigo", target = "perCodigo")
|
||||
TelefonoDTO getDto(Telefono telefono);
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.qsoft.erp.dominio.mapper;
|
||||
|
||||
import com.qsoft.erp.dto.UsuarioDTO;
|
||||
import com.qsoft.erp.model.Usuario;
|
||||
import org.mapstruct.AfterMapping;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.MappingTarget;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author james
|
||||
*/
|
||||
@Mapper
|
||||
public interface UsuarioMapper {
|
||||
|
||||
UsuarioMapper INSTANCE = Mappers.getMapper(UsuarioMapper.class);
|
||||
|
||||
Usuario getEntidad(UsuarioDTO usuarioDTO);
|
||||
|
||||
UsuarioDTO getDto(Usuario usuario);
|
||||
|
||||
@AfterMapping
|
||||
default void validaObjetos(UsuarioDTO usuarioDTO, @MappingTarget Usuario usuario){
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.qsoft.erp.dominio.mapper;
|
||||
|
||||
import com.qsoft.erp.dto.UsuarioPasswordDTO;
|
||||
import com.qsoft.erp.model.UsuarioPassword;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author james
|
||||
*/
|
||||
@Mapper
|
||||
public interface UsuarioPasswordMapper {
|
||||
|
||||
UsuarioPasswordMapper INSTANCE = Mappers.getMapper(UsuarioPasswordMapper.class);
|
||||
|
||||
@Mapping(source = "usuCodigo", target = "usuCodigo.usuCodigo")
|
||||
UsuarioPassword getEntidad(UsuarioPasswordDTO usuarioPasswordDTO);
|
||||
|
||||
@Mapping(source = "usuCodigo.usuCodigo", target = "usuCodigo")
|
||||
UsuarioPasswordDTO getDto(UsuarioPassword usuarioPassword);
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,58 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.qsoft.erp.dominio.mapper;
|
||||
|
||||
import com.qsoft.dao.exception.DaoException;
|
||||
import com.qsoft.erp.constantes.DominioConstantes;
|
||||
import com.qsoft.erp.dao.DaoGenerico;
|
||||
import com.qsoft.erp.dto.VwLiqperpolDTO;
|
||||
import com.qsoft.erp.model.Documento;
|
||||
import com.qsoft.erp.model.Liquidacion;
|
||||
import com.qsoft.erp.model.VwLiqperpol;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import org.mapstruct.AfterMapping;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.MappingTarget;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author james
|
||||
*/
|
||||
@Mapper
|
||||
public interface VwLiqperpolMapper {
|
||||
|
||||
VwLiqperpolMapper INSTANCE = Mappers.getMapper(VwLiqperpolMapper.class);
|
||||
|
||||
VwLiqperpol getEntidad(VwLiqperpolDTO vwLiqperpolDTO);
|
||||
|
||||
VwLiqperpolDTO getDto(VwLiqperpol vwLiqperpol);
|
||||
|
||||
@AfterMapping
|
||||
default void validaObjetos(VwLiqperpol liquidacion, @MappingTarget VwLiqperpolDTO liquidacionDTO) {
|
||||
liquidacionDTO.setDocumentos(new ArrayList<>());
|
||||
DaoGenerico<Liquidacion, Integer> daol = new DaoGenerico<>(Liquidacion.class);
|
||||
try {
|
||||
Liquidacion liq = daol.cargar(liquidacion.getLiqCodigo());
|
||||
|
||||
if (liq.getDocumentoCollection() != null && !liq.getDocumentoCollection().isEmpty()) {
|
||||
for (Documento doc : liq.getDocumentoCollection()) {
|
||||
if (doc.getDocEstado().equals(DominioConstantes.ACTIVO)) {
|
||||
Map<String, String> fila = new HashMap<>();
|
||||
fila.put("docCodigo", "" + doc.getDocCodigo());
|
||||
fila.put("docNombre", doc.getDocNombre());
|
||||
liquidacionDTO.getDocumentos().add(fila);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (DaoException ex) {
|
||||
System.out.println("ERROR consultando liquidacion " + ex);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.qsoft.erp.dominio.mapper;
|
||||
|
||||
import com.qsoft.erp.dto.VwLiqtoDTO;
|
||||
import com.qsoft.erp.model.VwLiqto;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author james
|
||||
*/
|
||||
@Mapper
|
||||
public interface VwLiqtoMapper {
|
||||
|
||||
VwLiqtoMapper INSTANCE = Mappers.getMapper(VwLiqtoMapper.class);
|
||||
|
||||
VwLiqto getEntidad(VwLiqtoDTO vwPeliqpreDTO);
|
||||
|
||||
VwLiqtoDTO getDto(VwLiqto vwPeliqpre);
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.qsoft.erp.dominio.mapper;
|
||||
|
||||
import com.qsoft.erp.dto.VwPagosCpnDTO;
|
||||
import com.qsoft.erp.model.VwPagosCpn;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author james
|
||||
*/
|
||||
@Mapper
|
||||
public interface VwPagosCpnMapper {
|
||||
|
||||
VwPagosCpnMapper INSTANCE = Mappers.getMapper(VwPagosCpnMapper.class);
|
||||
|
||||
VwPagosCpn getEntidad(VwPagosCpnDTO vwPolPerBanDTO);
|
||||
|
||||
VwPagosCpnDTO getDto(VwPagosCpn vwPolPerBan);
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.qsoft.erp.dominio.mapper;
|
||||
|
||||
import com.qsoft.erp.dto.VwPeliqpreDTO;
|
||||
import com.qsoft.erp.model.VwPeliqpre;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author james
|
||||
*/
|
||||
@Mapper
|
||||
public interface VwPeliqpreMapper {
|
||||
|
||||
VwPeliqpreMapper INSTANCE = Mappers.getMapper(VwPeliqpreMapper.class);
|
||||
|
||||
VwPeliqpre getEntidad(VwPeliqpreDTO vwPeliqpreDTO);
|
||||
|
||||
VwPeliqpreDTO getDto(VwPeliqpre vwPeliqpre);
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.qsoft.erp.dominio.mapper;
|
||||
|
||||
import com.qsoft.erp.dto.VwPolPerBanDTO;
|
||||
import com.qsoft.erp.model.VwPolPerBan;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author james
|
||||
*/
|
||||
@Mapper
|
||||
public interface VwPolPerBanMapper {
|
||||
|
||||
VwPolPerBanMapper INSTANCE = Mappers.getMapper(VwPolPerBanMapper.class);
|
||||
|
||||
VwPolPerBan getEntidad(VwPolPerBanDTO vwPolPerBanDTO);
|
||||
|
||||
VwPolPerBanDTO getDto(VwPolPerBan vwPolPerBan);
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.qsoft.erp.dominio.mapper;
|
||||
|
||||
import com.qsoft.erp.dto.VwPrestacionesPlanDTO;
|
||||
import com.qsoft.erp.model.VwPrestacionesPlan;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author james
|
||||
*/
|
||||
@Mapper
|
||||
public interface VwPrestacionesPlanMapper {
|
||||
|
||||
VwPrestacionesPlanMapper INSTANCE = Mappers.getMapper(VwPrestacionesPlanMapper.class);
|
||||
|
||||
VwPrestacionesPlan getEntidad(VwPrestacionesPlanDTO vwPrestacionesPlanDTO);
|
||||
|
||||
VwPrestacionesPlanDTO getDto(VwPrestacionesPlan vwPrestacionesPlan);
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
package com.qsoft.erp.dominio.mapper;
|
||||
|
||||
import com.qsoft.erp.model.VwRepdr;
|
||||
import com.qsoft.erp.dto.VwRepdrDTO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
@Mapper
|
||||
public interface VwRepdrMapper {
|
||||
|
||||
VwRepdrMapper INSTANCE = Mappers.getMapper(VwRepdrMapper.class);
|
||||
|
||||
VwRepdr getEntidad(VwRepdrDTO vwRepdr);
|
||||
|
||||
VwRepdrDTO getDto(VwRepdr vwRepdr);
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.qsoft.erp.dominio.mapper;
|
||||
|
||||
import com.qsoft.erp.dto.VwReporteProduccionDTO;
|
||||
import com.qsoft.erp.model.VwReporteProduccion;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author james
|
||||
*/
|
||||
@Mapper
|
||||
public interface VwReporteProduccionMapper {
|
||||
|
||||
VwReporteProduccionMapper INSTANCE = Mappers.getMapper(VwReporteProduccionMapper.class);
|
||||
|
||||
VwReporteProduccion getEntidad(VwReporteProduccionDTO vwReporteProduccionDTO);
|
||||
|
||||
VwReporteProduccionDTO getDto(VwReporteProduccion vwReporteProduccion);
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.qsoft.erp.dominio.mapper;
|
||||
|
||||
import com.qsoft.erp.dto.VwRepprimaPlanDTO;
|
||||
import com.qsoft.erp.model.VwRepprimaPlan;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author james
|
||||
*/
|
||||
@Mapper
|
||||
public interface VwRepprimaPlanMapper {
|
||||
|
||||
VwRepprimaPlanMapper INSTANCE = Mappers.getMapper(VwRepprimaPlanMapper.class);
|
||||
|
||||
VwRepprimaPlan getEntidad(VwRepprimaPlanDTO vwReprimaPlanDTO);
|
||||
|
||||
VwRepprimaPlanDTO getDto(VwRepprimaPlan vwReprimaPlan);
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.qsoft.erp.dominio.mapper;
|
||||
|
||||
import com.qsoft.erp.dominio.util.DominioUtil;
|
||||
import com.qsoft.erp.dto.VwUsuarioPersonaPolizaPlanDTO;
|
||||
import com.qsoft.erp.model.VwUsuarioPersonaPolizaPlan;
|
||||
import org.mapstruct.AfterMapping;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.MappingTarget;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author james
|
||||
*/
|
||||
@Mapper
|
||||
public interface VwUsuarioPersonaPolizaPlanMapper {
|
||||
|
||||
VwUsuarioPersonaPolizaPlanMapper INSTANCE = Mappers.getMapper(VwUsuarioPersonaPolizaPlanMapper.class);
|
||||
|
||||
VwUsuarioPersonaPolizaPlan getEntidad(VwUsuarioPersonaPolizaPlanDTO vwUsuarioPersonaPolizaPlanDTO);
|
||||
|
||||
VwUsuarioPersonaPolizaPlanDTO getDto(VwUsuarioPersonaPolizaPlan vwUsuarioPersonaPolizaPlan);
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,131 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.qsoft.erp.dominio.transaccion;
|
||||
|
||||
import com.qsoft.dao.exception.DaoException;
|
||||
import com.qsoft.erp.dao.DaoGenerico;
|
||||
import com.qsoft.erp.model.CoberturasPlan;
|
||||
import com.qsoft.erp.model.DetalleCatalogo;
|
||||
import com.qsoft.erp.model.DetalleLiquidacion;
|
||||
import com.qsoft.erp.model.EstadoLiquidacion;
|
||||
import com.qsoft.erp.model.Liquidacion;
|
||||
import com.qsoft.erp.model.Persona;
|
||||
import com.qsoft.erp.model.Plan;
|
||||
import com.qsoft.erp.model.TarifaLiquidacion;
|
||||
import com.qsoft.erp.model.Tarifario;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author james
|
||||
*/
|
||||
public class AuxLiquidacion {
|
||||
|
||||
private Plan plaCodigo;
|
||||
private Persona perBeneficiario;
|
||||
private Liquidacion liqCodigo;
|
||||
private EstadoLiquidacion eslCodigo;
|
||||
private DetalleLiquidacion delCodigo;
|
||||
private TarifaLiquidacion talCodigo;
|
||||
private CoberturasPlan copCodigo;
|
||||
private Tarifario tarCodigo;
|
||||
private DetalleCatalogo detPrestacion;
|
||||
private DetalleCatalogo detCie10;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public void guardaTarifa() {
|
||||
try {
|
||||
if (this.getTalCodigo() != null && this.getTalCodigo().getTalCodigo() != null ) {
|
||||
DaoGenerico<TarifaLiquidacion, Integer> daoTl = new DaoGenerico<>(TarifaLiquidacion.class);
|
||||
daoTl.actualizar(this.getTalCodigo());
|
||||
}
|
||||
} catch (DaoException ex) {
|
||||
System.out.println("No se puede actualizar Tarifa " + ex);
|
||||
}
|
||||
}
|
||||
|
||||
public Plan getPlaCodigo() {
|
||||
return plaCodigo;
|
||||
}
|
||||
|
||||
public void setPlaCodigo(Plan plaCodigo) {
|
||||
this.plaCodigo = plaCodigo;
|
||||
}
|
||||
|
||||
public Persona getPerBeneficiario() {
|
||||
return perBeneficiario;
|
||||
}
|
||||
|
||||
public void setPerBeneficiario(Persona perBeneficiario) {
|
||||
this.perBeneficiario = perBeneficiario;
|
||||
}
|
||||
|
||||
public Liquidacion getLiqCodigo() {
|
||||
return liqCodigo;
|
||||
}
|
||||
|
||||
public void setLiqCodigo(Liquidacion liqCodigo) {
|
||||
this.liqCodigo = liqCodigo;
|
||||
}
|
||||
|
||||
public DetalleCatalogo getDetCie10() {
|
||||
return detCie10;
|
||||
}
|
||||
|
||||
public void setDetCie10(DetalleCatalogo detCie10) {
|
||||
this.detCie10 = detCie10;
|
||||
}
|
||||
|
||||
public EstadoLiquidacion getEslCodigo() {
|
||||
return eslCodigo;
|
||||
}
|
||||
|
||||
public void setEslCodigo(EstadoLiquidacion eslCodigo) {
|
||||
this.eslCodigo = eslCodigo;
|
||||
}
|
||||
|
||||
public DetalleLiquidacion getDelCodigo() {
|
||||
return delCodigo;
|
||||
}
|
||||
|
||||
public void setDelCodigo(DetalleLiquidacion delCodigo) {
|
||||
this.delCodigo = delCodigo;
|
||||
}
|
||||
|
||||
public TarifaLiquidacion getTalCodigo() {
|
||||
return talCodigo;
|
||||
}
|
||||
|
||||
public void setTalCodigo(TarifaLiquidacion talCodigo) {
|
||||
this.talCodigo = talCodigo;
|
||||
}
|
||||
|
||||
public CoberturasPlan getCopCodigo() {
|
||||
return copCodigo;
|
||||
}
|
||||
|
||||
public void setCopCodigo(CoberturasPlan copCodigo) {
|
||||
this.copCodigo = copCodigo;
|
||||
}
|
||||
|
||||
public Tarifario getTarCodigo() {
|
||||
return tarCodigo;
|
||||
}
|
||||
|
||||
public void setTarCodigo(Tarifario tarCodigo) {
|
||||
this.tarCodigo = tarCodigo;
|
||||
}
|
||||
|
||||
public DetalleCatalogo getDetPrestacion() {
|
||||
return detPrestacion;
|
||||
}
|
||||
|
||||
public void setDetPrestacion(DetalleCatalogo detPrestacion) {
|
||||
this.detPrestacion = detPrestacion;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,457 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.qsoft.erp.dominio.transaccion;
|
||||
|
||||
import com.qsoft.erp.dto.ValoresLiquidacion;
|
||||
import com.qsoft.erp.model.CoberturasPlan;
|
||||
import com.qsoft.erp.model.DetalleCatalogo;
|
||||
import com.qsoft.erp.model.DetalleLiquidacion;
|
||||
import com.qsoft.erp.model.Liquidacion;
|
||||
import com.qsoft.erp.model.Persona;
|
||||
import com.qsoft.erp.model.Plan;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public class LiquidacionSum {
|
||||
|
||||
private final static String LIMITE_CUPO = "Ha alcanzado el limite de cobertura para el asegurado";
|
||||
|
||||
ArrayList<AuxLiquidacion> data;
|
||||
ArrayList<AuxLiquidacion> histo;
|
||||
private Liquidacion liquidacion;
|
||||
|
||||
public LiquidacionSum(Liquidacion liquidacion) {
|
||||
this();
|
||||
this.liquidacion = liquidacion;
|
||||
}
|
||||
|
||||
public LiquidacionSum() {
|
||||
this.data = new ArrayList<>();
|
||||
this.histo = new ArrayList<>();
|
||||
}
|
||||
|
||||
public ArrayList<AuxLiquidacion> getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public ArrayList<AuxLiquidacion> getHisto() {
|
||||
return histo;
|
||||
}
|
||||
|
||||
public void setData(ArrayList<AuxLiquidacion> data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public void setHisto(ArrayList<AuxLiquidacion> histo) {
|
||||
this.histo = histo;
|
||||
}
|
||||
|
||||
public Liquidacion getLiquidacion() {
|
||||
return liquidacion;
|
||||
}
|
||||
|
||||
public void setLiquidacion(Liquidacion liquidacion) {
|
||||
this.liquidacion = liquidacion;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public void mayorizar() {
|
||||
this.liquidacion.setLiqCopago(0.0);
|
||||
this.liquidacion.setLiqDeducible(0.0);
|
||||
this.liquidacion.setLiqObjetado(0.0);
|
||||
this.liquidacion.setLiqRegistrado(0.0);
|
||||
this.liquidacion.setLiqTotalLiquidado(0.0);
|
||||
this.liquidacion.setLiqRetenido(0.0);
|
||||
System.out.println("************************* Mayorizar...");
|
||||
|
||||
for (DetalleLiquidacion del : this.getDetalles()) {
|
||||
Double delCopa = 0.0;
|
||||
Double delDedu = 0.0;
|
||||
Double delPag = 0.0;
|
||||
StringBuilder observa = new StringBuilder();
|
||||
for (AuxLiquidacion aux : this.data) {
|
||||
if (del.getDelCodigo().equals(aux.getDelCodigo().getDelCodigo())
|
||||
&& aux.getTalCodigo().getTarObservacion() != null && !aux.getTalCodigo().getTarObservacion().isBlank()) {
|
||||
observa.append(aux.getTalCodigo().getTarObservacion()).append("\n");
|
||||
}
|
||||
if (del.getDelCodigo().equals(aux.getDelCodigo().getDelCodigo())
|
||||
&& aux.getTalCodigo().getTalValorCopago() != null && aux.getTalCodigo().getTalValorCopago() > 0.0) {
|
||||
delCopa += aux.getTalCodigo().getTalValorCopago();
|
||||
}
|
||||
if (del.getDelCodigo().equals(aux.getDelCodigo().getDelCodigo())
|
||||
&& aux.getTalCodigo().getTalValorDeducible() != null && aux.getTalCodigo().getTalValorDeducible() > 0.0) {
|
||||
delDedu += aux.getTalCodigo().getTalValorDeducible();
|
||||
}
|
||||
if (del.getDelCodigo().equals(aux.getDelCodigo().getDelCodigo())
|
||||
&& aux.getTalCodigo().getTalValorPagado() != null && aux.getTalCodigo().getTalValorPagado() > 0.0) {
|
||||
delPag += aux.getTalCodigo().getTalValorPagado();
|
||||
}
|
||||
}
|
||||
del.setDelDescripcion(observa.toString());
|
||||
del.setDelCopagoPagado(delCopa);
|
||||
del.setDelDeduciblePagado(delDedu);
|
||||
del.setDelValorPagado(delPag);
|
||||
System.out.println("\t************ OK DETALLE " + del.getDelCodigo() + " =>COP: " + del.getDelCopagoPagado()
|
||||
+ " =>DED: " + del.getDelDeduciblePagado() + " PAG: " + del.getDelValorPagado());
|
||||
this.liquidacion.setLiqRegistrado(this.liquidacion.getLiqRegistrado() + del.getDelValorRegistrado());
|
||||
this.liquidacion.setLiqObjetado(this.liquidacion.getLiqObjetado() + del.getDelValorObjetado());
|
||||
this.liquidacion.setLiqCopago(this.liquidacion.getLiqCopago() + del.getDelCopagoPagado());
|
||||
this.liquidacion.setLiqDeducible(this.liquidacion.getLiqDeducible() + del.getDelDeduciblePagado());
|
||||
this.liquidacion.setLiqTotalLiquidado(this.liquidacion.getLiqTotalLiquidado() + del.getDelValorPagado());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param copagos
|
||||
* @param deducible
|
||||
* @param maxPoliza
|
||||
*/
|
||||
public void procesarPorCobertura(Map<CoberturasPlan, ValoresLiquidacion> copagos, ValoresLiquidacion deducible, Double maxPoliza) {
|
||||
for (Map.Entry<CoberturasPlan, ValoresLiquidacion> entry : copagos.entrySet()) {
|
||||
double maxCobertura = 0.0;
|
||||
if (entry.getValue().getCoberturaDisponible() <= maxPoliza) {
|
||||
maxCobertura = entry.getValue().getCoberturaDisponible();
|
||||
} else {
|
||||
maxCobertura = maxPoliza * 1.0;
|
||||
}
|
||||
double maxCopago = entry.getKey().getCopCopago();
|
||||
System.out.println(">>>>========== COPAGO => " + entry.getKey().getDetTipo().getDetDescripcion());
|
||||
System.out.println(">>>>========== MAXIMA COBERTURA=> " + maxCobertura);
|
||||
for (AuxLiquidacion aux : this.getData()) {
|
||||
if (aux.getCopCodigo().getCopCodigo().equals(entry.getKey().getCopCodigo())) {
|
||||
double objetado = 0.0;
|
||||
if (aux.getTalCodigo().getTalValorObjetado() != null && aux.getTalCodigo().getTalValorObjetado() > 0.0) {
|
||||
objetado = aux.getTalCodigo().getTalValorObjetado();
|
||||
}
|
||||
//TODO: validar
|
||||
/*
|
||||
objetado = this.procesaDeducible(aux, deducible, objetado);
|
||||
if (aux.getCopCodigo().getCopCodigo().equals(entry.getKey().getCopCodigo()) && objetado > 0.0) {
|
||||
Double[] data = this.procesaPago(aux, objetado, maxCobertura, maxCopago);
|
||||
objetado = data[0];
|
||||
maxCobertura = data[1];
|
||||
maxCopago = data[2];
|
||||
maxPoliza -= aux.getTalCodigo().getTalValorPagado() != null? aux.getTalCodigo().getTalValorPagado(): 0.0;
|
||||
}
|
||||
*/
|
||||
//objetado = this.procesaDeducible(aux, deducible, objetado);
|
||||
if (objetado > 0.0) {
|
||||
Double[] data = this.procesaPago(aux, objetado, maxCobertura, maxCopago, deducible);
|
||||
objetado = data[0];
|
||||
maxCobertura = data[1];
|
||||
maxCopago = data[2];
|
||||
maxPoliza -= aux.getTalCodigo().getTalValorPagado() != null ? aux.getTalCodigo().getTalValorPagado() : 0.0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param aux
|
||||
* @param objetado
|
||||
* @param maxCobertura
|
||||
* @param maxCopago
|
||||
* @return
|
||||
*/
|
||||
private Double[] procesaPago(AuxLiquidacion aux, Double objetado, Double maxCobertura, Double maxCopago, ValoresLiquidacion deducible) {
|
||||
double paga = 0.0;
|
||||
double copago = 0.0;
|
||||
if (maxCopago > 1.0) {
|
||||
objetado = this.procesaDeducible(aux, deducible, objetado); //TODO : pilas aqui
|
||||
if (objetado >= maxCopago) {
|
||||
copago = maxCopago;
|
||||
objetado -= copago;
|
||||
maxCopago = 0.0;
|
||||
} else {
|
||||
copago = objetado;
|
||||
objetado = 0.0;
|
||||
maxCopago -= objetado;
|
||||
}
|
||||
aux.getTalCodigo().setTalValorCopago(copago);
|
||||
if (objetado <= maxCobertura) {
|
||||
paga = objetado;
|
||||
maxCobertura -= objetado;
|
||||
objetado = 0.0;
|
||||
} else {
|
||||
paga = maxCobertura;
|
||||
objetado -= paga;
|
||||
maxCobertura = 0.0;
|
||||
}
|
||||
if (aux.getDelCodigo().getDelCodigo() == 2496) {
|
||||
System.out.println("\t >>> COPAGO POR VALOR max: " + maxCobertura + " cop: " + copago + " => pag: " + paga);
|
||||
}
|
||||
aux.getTalCodigo().setTalValorPagado(paga);
|
||||
} else { //COPAGO EN PORCENTAJE
|
||||
copago = objetado * maxCopago;
|
||||
objetado -= copago;
|
||||
double dedu = this.getDeducible(aux, deducible, objetado); //TODO : pilas aqui
|
||||
objetado -= dedu;
|
||||
if (objetado <= maxCobertura) {
|
||||
if (aux.getDelCodigo().getDelCodigo() == 2496) {
|
||||
System.out.println("\t\t >>> Reduce maximo cobertura(IF) max: " + maxCobertura + " paga: " + objetado);
|
||||
}
|
||||
paga = objetado;
|
||||
maxCobertura -= objetado;
|
||||
objetado = 0.0;
|
||||
} else { //TODO: revisar
|
||||
if (aux.getDelCodigo().getDelCodigo() == 2496) {
|
||||
System.out.println("\t\t >>> Reduce maximo cobertura(ELSE) max: " + maxCobertura + " paga: " + objetado);
|
||||
}
|
||||
paga = maxCobertura * (1 - maxCopago);
|
||||
copago = maxCobertura - paga;
|
||||
objetado -= (paga + copago);
|
||||
maxCobertura = 0.0;
|
||||
}
|
||||
aux.getTalCodigo().setTalValorCopago(copago);
|
||||
aux.getTalCodigo().setTalValorPagado(paga);
|
||||
if (aux.getDelCodigo().getDelCodigo() == 2496) {
|
||||
System.out.println("\t >>> COPAGO POR PORCENTAJE max: " + maxCobertura + " cop: " + copago + " pag: " + paga);
|
||||
}
|
||||
}
|
||||
return new Double[]{objetado, maxCobertura, maxCopago};
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param aux
|
||||
* @param deducible
|
||||
* @param objetado
|
||||
*/
|
||||
private Double procesaDeducible(AuxLiquidacion aux, ValoresLiquidacion deducible, Double objetado) {
|
||||
if (deducible.getDeduciblePendiente() > 0.0 && objetado > 0.0) { ///TODO: esta c ondicion no necesariamente esta bien
|
||||
if (aux.getTalCodigo().getTalValorObjetado() >= deducible.getDeduciblePendiente()) {
|
||||
aux.getTalCodigo().setTalValorDeducible(deducible.getDeduciblePendiente());
|
||||
deducible.setDeduciblePendiente(0.0);
|
||||
} else {
|
||||
aux.getTalCodigo().setTalValorDeducible(aux.getTalCodigo().getTalValorObjetado());
|
||||
deducible.setDeduciblePendiente(deducible.getDeduciblePendiente() - aux.getTalCodigo().getTalValorObjetado());
|
||||
}
|
||||
objetado = aux.getTalCodigo().getTalValorObjetado() - aux.getTalCodigo().getTalValorDeducible();
|
||||
if (aux.getDelCodigo().getDelCodigo() == 2496) {
|
||||
System.out.println("\t >>> CALCULO DEDUCIBLE ded: " + aux.getTalCodigo().getTalValorDeducible() + " max: " + objetado);
|
||||
}
|
||||
}
|
||||
return objetado;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param aux
|
||||
* @param deducible
|
||||
* @param maximo
|
||||
*/
|
||||
private Double getDeducible(AuxLiquidacion aux, ValoresLiquidacion deducible, Double maximo) {
|
||||
Double ded = 0.0;
|
||||
if (deducible.getDeduciblePendiente() > 0.0 && maximo > 0.0) { ///TODO: esta condicion no necesariamente esta bien
|
||||
if (maximo >= deducible.getDeduciblePendiente()) {
|
||||
aux.getTalCodigo().setTalValorDeducible(deducible.getDeduciblePendiente());
|
||||
deducible.setDeduciblePendiente(0.0);
|
||||
} else {
|
||||
aux.getTalCodigo().setTalValorDeducible(maximo);
|
||||
deducible.setDeduciblePendiente(deducible.getDeduciblePendiente() - maximo);
|
||||
}
|
||||
ded = aux.getTalCodigo().getTalValorDeducible();
|
||||
if (aux.getDelCodigo().getDelCodigo() == 2496) {
|
||||
System.out.println("\t >>> CALCULO DEDUCIBLE ded: " + ded + " max: " + maximo);
|
||||
}
|
||||
}
|
||||
return ded;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param histo
|
||||
* @return
|
||||
*/
|
||||
public Map<CoberturasPlan, ValoresLiquidacion> getCopagos() {
|
||||
Map<CoberturasPlan, ValoresLiquidacion> copagos = new HashMap<>();
|
||||
for (CoberturasPlan cob : this.getCoberturas()) {
|
||||
ValoresLiquidacion valCob = new ValoresLiquidacion();
|
||||
valCob.setCopago(cob.getCopCopago());
|
||||
valCob.setCobertura(cob.getCopTope());
|
||||
valCob.setCoberturaPagada(this.getPagoCubierto(cob, this.getBeneficiario()));
|
||||
valCob.setCoberturaDisponible(valCob.getCobertura() - valCob.getCoberturaPagada());
|
||||
valCob.setValorObjetado(this.getPagoObjetado(cob, this.getBeneficiario()));
|
||||
copagos.put(cob, valCob);
|
||||
System.out.println(">>>> TOPES COBERTURA " + cob.getCopCodigo() + " - " + cob.getDetTipo().getDetDescripcion() + "\n\t>> tope: " + cob.getCopTope() +
|
||||
" pagada: " + valCob.getCoberturaPagada() + " dispo: " + valCob.getCoberturaDisponible() + " obje: " + valCob.getValorObjetado());
|
||||
}
|
||||
return copagos;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param histo
|
||||
* @return
|
||||
*/
|
||||
public Map<DetalleCatalogo, ValoresLiquidacion> getDeducibles() {
|
||||
Map<DetalleCatalogo, ValoresLiquidacion> deducibles = new HashMap<>();
|
||||
for (DetalleCatalogo cie : this.getCie10()) {
|
||||
ValoresLiquidacion valCie = new ValoresLiquidacion();
|
||||
valCie.setDeducible(this.getPlan().getPlaValorDeducible());
|
||||
valCie.setDeduciblePendiente(this.getDeduciblePendiente(cie, this.getBeneficiario(), this.getPlan()));
|
||||
valCie.setDeduciblePagado(0.0);
|
||||
deducibles.put(cie, valCie);
|
||||
}
|
||||
return deducibles;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param cie10
|
||||
* @param beneficiario
|
||||
* @param plan
|
||||
* @return
|
||||
*/
|
||||
private Double getDeduciblePendiente(DetalleCatalogo cie10, Persona beneficiario, Plan plan) {
|
||||
Double deducible = plan.getPlaValorDeducible();
|
||||
for (AuxLiquidacion aux : this.histo) {
|
||||
if (aux.getPerBeneficiario().getPerCodigo().equals(beneficiario.getPerCodigo())
|
||||
&& aux.getDetCie10().getDetCodigo().equals(cie10.getDetCodigo())) {
|
||||
deducible -= aux.getTalCodigo().getTalValorDeducible() != null ? aux.getTalCodigo().getTalValorDeducible() : 0;
|
||||
}
|
||||
}
|
||||
return deducible;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param cobertura
|
||||
* @param beneficiario
|
||||
* @return
|
||||
*/
|
||||
private Double getPagoObjetado(CoberturasPlan cobertura, Persona beneficiario) {
|
||||
Double pago = 0.0;
|
||||
for (AuxLiquidacion aux : this.data) {
|
||||
if (aux.getPerBeneficiario().getPerCodigo().equals(beneficiario.getPerCodigo())
|
||||
&& aux.getCopCodigo().getCopCodigo().equals(cobertura.getCopCodigo())) {
|
||||
pago += aux.getTalCodigo().getTalValorObjetado() != null ? aux.getTalCodigo().getTalValorObjetado() : 0;
|
||||
}
|
||||
}
|
||||
return pago;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param cobertura
|
||||
* @param beneficiario
|
||||
* @return
|
||||
*/
|
||||
private Double getPagoObjetado(Persona beneficiario) {
|
||||
Double pago = 0.0;
|
||||
for (AuxLiquidacion aux : this.data) {
|
||||
if (aux.getPerBeneficiario().getPerCodigo().equals(beneficiario.getPerCodigo())) {
|
||||
pago += aux.getTalCodigo().getTalValorObjetado() != null ? aux.getTalCodigo().getTalValorObjetado() : 0;
|
||||
}
|
||||
}
|
||||
return pago;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param beneficiario
|
||||
* @return
|
||||
*/
|
||||
public Double getPagoCubierto(Persona beneficiario) {
|
||||
Double pago = 0.0;
|
||||
for (AuxLiquidacion aux : this.histo) {
|
||||
if (aux.getPerBeneficiario().getPerCodigo().equals(beneficiario.getPerCodigo())) {
|
||||
pago += aux.getTalCodigo().getTalValorPagado() != null ? aux.getTalCodigo().getTalValorPagado() : 0;
|
||||
}
|
||||
}
|
||||
return pago;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param cobertura
|
||||
* @param beneficiario
|
||||
* @return
|
||||
*/
|
||||
public Double getPagoCubierto(CoberturasPlan cobertura, Persona beneficiario) {
|
||||
Double pago = 0.0;
|
||||
for (AuxLiquidacion aux : this.data) {
|
||||
if (aux.getPerBeneficiario().getPerCodigo().equals(beneficiario.getPerCodigo())
|
||||
&& aux.getCopCodigo().getCopCodigo().equals(cobertura.getCopCodigo())) {
|
||||
pago += aux.getTalCodigo().getTalValorPagado() != null ? aux.getTalCodigo().getTalValorPagado() : 0.0;
|
||||
}
|
||||
}
|
||||
return pago;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Persona getBeneficiario() {
|
||||
for (AuxLiquidacion fila : this.data) {
|
||||
if (fila.getPerBeneficiario() != null) {
|
||||
return fila.getPerBeneficiario();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Plan getPlan() {
|
||||
for (AuxLiquidacion fila : this.data) {
|
||||
if (fila.getPlaCodigo() != null) {
|
||||
return fila.getPlaCodigo();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private Set<CoberturasPlan> getCoberturas() {
|
||||
Set<CoberturasPlan> data = new HashSet<>();
|
||||
for (AuxLiquidacion fila : this.data) {
|
||||
data.add(fila.getCopCodigo());
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private Set<DetalleCatalogo> getCie10() {
|
||||
Set<DetalleCatalogo> data = new HashSet<>();
|
||||
for (AuxLiquidacion fila : this.data) {
|
||||
data.add(fila.getDetCie10());
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param cobertura
|
||||
* @return
|
||||
*/
|
||||
public Set<DetalleLiquidacion> getDetalles() {
|
||||
Set<DetalleLiquidacion> data = new HashSet<>();
|
||||
for (AuxLiquidacion fila : this.data) {
|
||||
data.add(fila.getDelCodigo());
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.qsoft.erp.dominio.transaccion;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author pedantic
|
||||
*/
|
||||
|
||||
public class Model {
|
||||
private String month;
|
||||
private int numberOfHours;
|
||||
|
||||
public String getMonth() {
|
||||
return month;
|
||||
}
|
||||
|
||||
public void setMonth(String month) {
|
||||
this.month = month;
|
||||
}
|
||||
|
||||
public int getNumberOfHours() {
|
||||
return numberOfHours;
|
||||
}
|
||||
|
||||
public void setNumberOfHours(int numberOfHours) {
|
||||
this.numberOfHours = numberOfHours;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,109 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.qsoft.erp.dominio.transaccion;
|
||||
|
||||
import com.stripe.Stripe;
|
||||
import com.stripe.exception.*;
|
||||
import com.stripe.model.Charge;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.ejb.Stateless;
|
||||
import com.stripe.model.Charge;
|
||||
import com.stripe.model.Customer;
|
||||
import com.stripe.model.PaymentMethod;
|
||||
import com.stripe.model.Price;
|
||||
import com.stripe.model.Product;
|
||||
import com.stripe.model.Subscription;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
/**
|
||||
*
|
||||
* @author pedantic
|
||||
*/
|
||||
@Stateless
|
||||
public class PaymentService {
|
||||
|
||||
|
||||
public Charge charge(String token, BigDecimal chargeAmount, String paymentCurrency) throws StripeException {
|
||||
|
||||
Map<String, Object> chargeParams = new HashMap<>();
|
||||
DecimalFormat df = new DecimalFormat("#.00");
|
||||
String valueAmount = df.format(Double.parseDouble(chargeAmount.toString()));
|
||||
|
||||
valueAmount = valueAmount.replace(".", "");
|
||||
valueAmount = valueAmount.replace(",", "");
|
||||
Integer amount = Integer.parseInt(valueAmount);
|
||||
chargeParams.put("amount", amount);
|
||||
chargeParams.put("currency", "usd");
|
||||
chargeParams.put("source", token);
|
||||
chargeParams.put("description", "Pago Sistema de medicina prepagada Medicompanies S.A");
|
||||
|
||||
return Charge.create(chargeParams);
|
||||
}
|
||||
|
||||
public Customer createCustomer(String name, String mail) throws StripeException{
|
||||
Stripe.apiKey = "sk_test_51HRpHhJSiwKtwzlBGIMZWp5xHo2ywzD8d9Nq8cBP79wZKZA8XdEOcg9bU16xyxTiA5fO0w2XDGkd3yCfcHv5X2qF00fAwHG3ou";
|
||||
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("description","Cliente creado desde el sistema de medicina prepagada Medicompanies S.A");
|
||||
params.put("currency","usd");
|
||||
params.put("name",name);
|
||||
params.put("email",mail);
|
||||
|
||||
|
||||
return Customer.create(params);
|
||||
}
|
||||
|
||||
public Subscription createSuscription(Price price,Customer customer, Date inicioPeriodo, Date finPeriodo) throws StripeException{
|
||||
|
||||
List<Object> items = new ArrayList<>();
|
||||
Map<String, Object> item1 = new HashMap<>();
|
||||
item1.put(
|
||||
"price",
|
||||
price.getId()
|
||||
);
|
||||
items.add(item1);
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("customer", customer.getId());
|
||||
params.put("items", items);
|
||||
params.put("current_period_start", inicioPeriodo.getTime());
|
||||
params.put("current_period_end", finPeriodo.getTime());
|
||||
|
||||
|
||||
return Subscription.create(params);
|
||||
}
|
||||
|
||||
public Price createPrice (String interval, Double unitAmount, Product product) throws StripeException{
|
||||
|
||||
Map<String, Object> recurring = new HashMap<>();
|
||||
recurring.put("interval", interval );//"month"
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("unit_amount", unitAmount);
|
||||
params.put("currency", "usd");
|
||||
params.put("recurring", recurring);
|
||||
params.put("product", product.getId());
|
||||
|
||||
return Price.create(params);
|
||||
}
|
||||
|
||||
public Product createProduct(String name) throws StripeException{
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("name", name);
|
||||
|
||||
return Product.create(params);
|
||||
}
|
||||
|
||||
public PaymentMethod agregarPaymentMethodACustomer(String paymentMethodId, Customer customer) throws StripeException{
|
||||
PaymentMethod paymentMethod = PaymentMethod.retrieve(paymentMethodId);
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("customer", customer.getId());
|
||||
return paymentMethod.attach(params);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,166 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.qsoft.erp.dominio.transaccion;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import com.qsoft.dao.exception.DaoException;
|
||||
import com.qsoft.erp.constantes.DetalleCatalogoEnum;
|
||||
import static com.qsoft.erp.constantes.EntidadEnum.PersonaPoliza;
|
||||
import com.qsoft.erp.dao.DaoGenerico;
|
||||
import com.qsoft.erp.model.DetalleCatalogo;
|
||||
import com.qsoft.erp.model.DetalleLiquidacion;
|
||||
import com.qsoft.erp.model.Pago;
|
||||
import com.qsoft.erp.model.Persona;
|
||||
import com.qsoft.erp.model.PersonaPoliza;
|
||||
import com.qsoft.erp.model.Poliza;
|
||||
import com.qsoft.util.ms.pojo.HeaderMS;
|
||||
import com.stripe.exception.StripeException;
|
||||
import com.stripe.model.Card;
|
||||
import com.stripe.model.Charge;
|
||||
import com.stripe.model.Customer;
|
||||
import com.stripe.model.ExternalAccountCollection;
|
||||
import com.stripe.model.PaymentIntent;
|
||||
import com.stripe.model.PaymentMethod;
|
||||
import com.stripe.model.PaymentSourceCollection;
|
||||
import com.stripe.model.Price;
|
||||
import com.stripe.model.Product;
|
||||
import com.stripe.model.Subscription;
|
||||
import com.stripe.model.Token;
|
||||
import com.stripe.param.PaymentIntentCreateParams;
|
||||
import java.math.BigDecimal;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import javax.ejb.EJB;
|
||||
import javax.ejb.Stateless;
|
||||
import javax.inject.Inject;
|
||||
import static spark.Spark.staticFiles;
|
||||
/**
|
||||
*
|
||||
* @author christian
|
||||
*/
|
||||
@Stateless
|
||||
public class Stripe {
|
||||
|
||||
|
||||
|
||||
@EJB
|
||||
private PaymentService paymentService;
|
||||
|
||||
static class CreatePayment {
|
||||
@SerializedName("items")
|
||||
Object[] items;
|
||||
|
||||
public Object[] getItems() {
|
||||
return items;
|
||||
}
|
||||
}
|
||||
|
||||
static class CreatePaymentResponse {
|
||||
private String clientSecret;
|
||||
|
||||
public CreatePaymentResponse(String clientSecret) {
|
||||
this.clientSecret = clientSecret;
|
||||
}
|
||||
}
|
||||
|
||||
public Map<String, Object> generatePayment(HeaderMS header, List<Map<String, Object>> entidades, int tipoAccion) throws StripeException, JsonProcessingException, DaoException{
|
||||
DaoGenerico<Pago, Integer> daopag = new DaoGenerico<>(Pago.class);
|
||||
DaoGenerico<DetalleCatalogo, Integer> daodet = new DaoGenerico<>(DetalleCatalogo.class);
|
||||
|
||||
com.stripe.Stripe.apiKey = DetalleCatalogoEnum.STRAKY.getDetalle().getDetOrigen();
|
||||
|
||||
Map<String, Object> data = new HashMap<>();
|
||||
|
||||
for (Map<String, Object> entidade : entidades) {
|
||||
|
||||
Map < String, Object> tokenParam = new HashMap< String, Object> ();
|
||||
tokenParam.put("card", entidade.get("card"));
|
||||
|
||||
/** --------------------Pago -----*/
|
||||
Pago plantillaPago = new Pago();
|
||||
plantillaPago.setPagCodigo(Integer.parseInt(entidade.get("pagCodigo").toString()));
|
||||
Pago pago = daopag.buscarUnico(plantillaPago);
|
||||
|
||||
Charge charge = paymentService.charge(entidade.get("stripeToken").toString(), new BigDecimal(pago.getPagMonto()), "usd");
|
||||
|
||||
DetalleCatalogo plantillaDetCat = new DetalleCatalogo();
|
||||
plantillaDetCat.setDetNemonico("PAG");
|
||||
|
||||
DetalleCatalogo detEstado = daodet.buscarUnico(plantillaDetCat);
|
||||
pago.setDetEstado(detEstado);
|
||||
pago.setPagFechaPago(new Date());
|
||||
pago.setPagObservacion(entidade.get("stripeToken").toString());
|
||||
|
||||
daopag.actualizar(pago);
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
data.put("Pago_".concat(pago.getPagCodigo().toString()), mapper.readValue(charge.toJson(), Map.class));
|
||||
|
||||
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
public Map<String, Object> createSuscription(HeaderMS header, List<Map<String, Object>> entidades, int tipoAccion) throws StripeException, JsonProcessingException, DaoException{
|
||||
DaoGenerico<Pago, Integer> daopag = new DaoGenerico<>(Pago.class);
|
||||
DaoGenerico<DetalleCatalogo, Integer> daodet = new DaoGenerico<>(DetalleCatalogo.class);
|
||||
DaoGenerico<Poliza, Integer> daopol = new DaoGenerico<>(Poliza.class);
|
||||
DaoGenerico<PersonaPoliza, Integer> daoperpol = new DaoGenerico<>(PersonaPoliza.class);
|
||||
|
||||
//com.stripe.Stripe.apiKey = "sk_test_SVuYrJqSaU7VbjrfZVCI04Ow00gClipHQE";
|
||||
com.stripe.Stripe.apiKey = "sk_test_51HRpHhJSiwKtwzlBGIMZWp5xHo2ywzD8d9Nq8cBP79wZKZA8XdEOcg9bU16xyxTiA5fO0w2XDGkd3yCfcHv5X2qF00fAwHG3ou";
|
||||
|
||||
Map<String, Object> data = new HashMap<>();
|
||||
|
||||
for (Map<String, Object> entidade : entidades) {
|
||||
|
||||
//Charge charge = paymentService.charge(entidade.get("stripeToken").toString(), new BigDecimal(pago.getPagMonto()), "usd");
|
||||
Poliza polizaPlantilla = new Poliza();
|
||||
polizaPlantilla.setPolCodigo((Integer) entidade.get("polCodigo"));
|
||||
|
||||
Persona personaPlantilla = new Persona();
|
||||
DetalleCatalogo detalleCatalogoPlantilla = new DetalleCatalogo();
|
||||
detalleCatalogoPlantilla.setDetNemonico("PTITU");
|
||||
|
||||
PersonaPoliza personaPolizaPlantilla = new PersonaPoliza();
|
||||
personaPolizaPlantilla.setPolCodigo(polizaPlantilla);
|
||||
personaPolizaPlantilla.setDetTipoPersona(detalleCatalogoPlantilla);
|
||||
|
||||
PersonaPoliza personaPoliza = daoperpol.buscarUnico(personaPolizaPlantilla);
|
||||
if(personaPoliza.getPolCodigo().getDetPeriodicidad().getDetNemonico().equals("MENS")){
|
||||
Pago plantillaPago = new Pago();
|
||||
plantillaPago.setPolCodigo(personaPoliza.getPolCodigo());
|
||||
List<Pago> pagosPoliza = daopag.buscarLista(plantillaPago, new String[]{"pagFechaVencimiento","DESC"});
|
||||
Product product = paymentService.createProduct(personaPoliza.getPolCodigo().getPolContrato());
|
||||
Price price = paymentService.createPrice(entidade.get("intervalo").toString(), pagosPoliza.get(0).getPagMonto(), product);
|
||||
|
||||
Customer customer = paymentService.createCustomer(personaPoliza.getPerCodigo().getPerNombres().concat(" ").concat(personaPoliza.getPerCodigo().getPerApellidos()), personaPoliza.getPerCodigo().getPerMail());
|
||||
PaymentMethod paymentMethod = paymentService.agregarPaymentMethodACustomer(entidade.get("paymentMethodId").toString(), customer);
|
||||
Date fechaInicial = pagosPoliza.get(0).getPagFechaVencimiento();
|
||||
Date fechaFInal = pagosPoliza.get(pagosPoliza.size()-1).getPagFechaVencimiento();
|
||||
|
||||
Subscription subscription = paymentService.createSuscription(price, customer, fechaInicial, fechaFInal);
|
||||
|
||||
data.put(subscription.getId(), subscription.toJson());
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,659 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.qsoft.erp.dominio.transaccion;
|
||||
|
||||
import com.auth0.jwt.JWT;
|
||||
import com.auth0.jwt.JWTVerifier;
|
||||
import com.auth0.jwt.algorithms.Algorithm;
|
||||
import com.auth0.jwt.exceptions.JWTCreationException;
|
||||
import com.auth0.jwt.exceptions.JWTVerificationException;
|
||||
import com.auth0.jwt.interfaces.DecodedJWT;
|
||||
import com.qsoft.dao.exception.DaoException;
|
||||
import com.qsoft.dao.util.Fila;
|
||||
import com.qsoft.otp.OTP;
|
||||
import com.qsoft.util.constantes.CodigoRespuesta;
|
||||
import com.qsoft.util.constantes.ErrorTipo;
|
||||
import com.qsoft.util.ms.pojo.HeaderMS;
|
||||
import com.qsoft.erp.constantes.DetalleCatalogoEnum;
|
||||
import com.qsoft.erp.constantes.DominioConstantes;
|
||||
import com.qsoft.erp.constantes.ParametroEnum;
|
||||
import com.qsoft.erp.constantes.QueryEnum;
|
||||
import com.qsoft.erp.dao.DaoGenerico;
|
||||
import com.qsoft.erp.dominio.exception.DominioExcepcion;
|
||||
import com.qsoft.erp.dominio.mapper.UsuarioMapper;
|
||||
import com.qsoft.erp.dominio.util.DBUtil;
|
||||
import com.qsoft.erp.dominio.util.DominioUtil;
|
||||
import com.qsoft.erp.dominio.util.NotificadorUtil;
|
||||
import com.qsoft.erp.dominio.util.OTPUtil;
|
||||
import com.qsoft.erp.dto.UsuarioDTO;
|
||||
import com.qsoft.erp.model.Otp;
|
||||
import com.qsoft.erp.model.Poliza;
|
||||
import com.qsoft.erp.model.Usuario;
|
||||
import com.qsoft.erp.model.UsuarioPassword;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import javax.ejb.EJB;
|
||||
import javax.ejb.Stateless;
|
||||
import javax.transaction.Transactional;
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
import static com.qsoft.erp.dominio.AccionGenerica.ACTUALIZA;
|
||||
import static com.qsoft.erp.dominio.AccionGenerica.CANCELA;
|
||||
import static com.qsoft.erp.dominio.AccionGenerica.CONSULTA;
|
||||
import static com.qsoft.erp.dominio.AccionGenerica.ELIMINA;
|
||||
import static com.qsoft.erp.dominio.AccionGenerica.GUARDA;
|
||||
import com.qsoft.erp.dto.PrivilegioDTO;
|
||||
import com.qsoft.erp.dto.RolDTO;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author james
|
||||
*/
|
||||
@Stateless
|
||||
public class UsuarioTransaccion {
|
||||
|
||||
@EJB
|
||||
private DBUtil dBUtil;
|
||||
|
||||
@EJB
|
||||
private OTPUtil otpUtil;
|
||||
|
||||
@EJB
|
||||
private NotificadorUtil notificadorUtil;
|
||||
|
||||
@EJB
|
||||
private DominioUtil dominioUtil;
|
||||
|
||||
@Transactional(Transactional.TxType.REQUIRES_NEW)
|
||||
public List<Usuario> procesarUsuario(HeaderMS header, List<Map<String, Object>> entidades, int tipoAccion) throws DominioExcepcion {
|
||||
List<Usuario> data = new ArrayList<>();
|
||||
for (Map<String, Object> ent : entidades) {
|
||||
UsuarioDTO tramiteDTO = (UsuarioDTO) dominioUtil.crearObjeto(UsuarioDTO.class, ent);
|
||||
Usuario result = crudUsuario(header, tramiteDTO, tipoAccion);
|
||||
data.add(result);
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param header
|
||||
* @param usuario
|
||||
* @param tipoAccion
|
||||
* @param ent
|
||||
* @return
|
||||
* @throws DominioExcepcion
|
||||
*/
|
||||
@Transactional(Transactional.TxType.REQUIRES_NEW)
|
||||
private Usuario crudUsuario(HeaderMS header, UsuarioDTO usuario, int tipoAccion) throws DominioExcepcion {
|
||||
DaoGenerico<Usuario, Integer> daousu = new DaoGenerico<>(Usuario.class);
|
||||
Usuario result;
|
||||
result = UsuarioMapper.INSTANCE.getEntidad(usuario);
|
||||
switch (tipoAccion) {
|
||||
case CONSULTA: {
|
||||
throw new DominioExcepcion(ErrorTipo.ERROR, CodigoRespuesta.CODIGO_ERROR_GENERICO,
|
||||
"Operacion CONSULTA no soportada para el controlador de Accion");
|
||||
}
|
||||
case GUARDA: {
|
||||
try {
|
||||
String passwd = usuario.getUsuPassword();
|
||||
if (passwd == null || passwd.isBlank()) {
|
||||
throw new DominioExcepcion(ErrorTipo.ERROR, CodigoRespuesta.CODIGO_VALOR_NULO, "Error, el Password es requerido");
|
||||
}
|
||||
if (result.getUsuUsuario() == null || result.getUsuUsuario().isBlank()) {
|
||||
throw new DominioExcepcion(ErrorTipo.ERROR, CodigoRespuesta.CODIGO_VALOR_NULO, "Error, el Usuario es requerido");
|
||||
}
|
||||
if (result.getUsuNombre() == null || result.getUsuNombre().isBlank()) {
|
||||
throw new DominioExcepcion(ErrorTipo.ERROR, CodigoRespuesta.CODIGO_VALOR_NULO, "Error, el Nombre es requerido");
|
||||
}
|
||||
if (result.getUsuEmail() == null || result.getUsuEmail().isBlank()) {
|
||||
throw new DominioExcepcion(ErrorTipo.ERROR, CodigoRespuesta.CODIGO_VALOR_NULO, "Error, el Email es requerido");
|
||||
}
|
||||
String hash = dominioUtil.getSHAUsuario(usuario.getUsuUsuario(), passwd);
|
||||
UsuarioPassword up = new UsuarioPassword();
|
||||
up.setUsuCodigo(result);
|
||||
up.setPasFecha(new Date());
|
||||
up.setPasEstado(DominioConstantes.ACTIVO);
|
||||
up.setPasValor(hash);
|
||||
result.setUsuarioPasswordCollection(new ArrayList<>());
|
||||
result.getUsuarioPasswordCollection().add(up);
|
||||
daousu.guardar(result);
|
||||
} catch (DaoException ex) {
|
||||
throw new DominioExcepcion(ErrorTipo.FATAL, CodigoRespuesta.CODIGO_ERROR_GUARDA_BDD, ex.toString());
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ACTUALIZA: {
|
||||
try {
|
||||
daousu.actualizar(result);
|
||||
} catch (DaoException ex) {
|
||||
throw new DominioExcepcion(ErrorTipo.FATAL, CodigoRespuesta.CODIGO_ERROR_ACTUALIZA_BDD, ex.toString());
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ELIMINA: {
|
||||
throw new DominioExcepcion(ErrorTipo.ERROR, CodigoRespuesta.CODIGO_ERROR_GENERICO,
|
||||
"Operacion ELIMINACION aun no permitida");
|
||||
}
|
||||
case CANCELA: {
|
||||
throw new DominioExcepcion(ErrorTipo.ERROR, CodigoRespuesta.CODIGO_ERROR_GENERICO,
|
||||
"Operacion CANCELAR aun no permitida");
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param header
|
||||
* @param dao
|
||||
* @param token
|
||||
* @param password
|
||||
* @return
|
||||
* @throws DominioExcepcion
|
||||
* @throws DaoException
|
||||
*/
|
||||
public List<UsuarioDTO> cambiaPassword(HeaderMS header, DaoGenerico<Usuario, Integer> dao, String token, String password) throws DominioExcepcion, DaoException {
|
||||
List<UsuarioDTO> result = new ArrayList<>();
|
||||
List<Usuario> usuarios = getUsuarioToken(dao, token);
|
||||
if (usuarios != null) {
|
||||
for (Usuario user : usuarios) {
|
||||
Calendar compara = Calendar.getInstance();
|
||||
compara.setTime(user.getUsuFechaToken());
|
||||
compara.add(Calendar.SECOND, user.getUsuTiempoToken());
|
||||
if (compara.getTimeInMillis() >= System.currentTimeMillis()) {
|
||||
result.add(crearNuevoPassword(dao, user, password));
|
||||
} else {
|
||||
throw new DominioExcepcion(ErrorTipo.ERROR, CodigoRespuesta.CODIGO_VALOR_NULO, "Error el token a caducado por favor solicite nuevamente el cambio de clave ");
|
||||
}
|
||||
}
|
||||
}
|
||||
System.out.println("OK CAMBIA PASS " + result.size());
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param dao
|
||||
* @param user
|
||||
*/
|
||||
private UsuarioDTO crearNuevoPassword(DaoGenerico<Usuario, Integer> dao, Usuario user, String password) throws DaoException, DominioExcepcion {
|
||||
user.setUsuFechaToken(null);
|
||||
user.setUsuToken(null);
|
||||
user.setUsuTiempoToken(null);
|
||||
dao.actualizar(user);
|
||||
DaoGenerico<UsuarioPassword, Integer> daop = new DaoGenerico<>(UsuarioPassword.class);
|
||||
for (UsuarioPassword up : user.getUsuarioPasswordCollection()) {
|
||||
up.setPasEstado(DominioConstantes.INACTIVO);
|
||||
daop.actualizar(up);
|
||||
}
|
||||
UsuarioPassword pas = new UsuarioPassword();
|
||||
pas.setUsuCodigo(user);
|
||||
pas.setPasEstado(DominioConstantes.ACTIVO);
|
||||
pas.setPasFecha(new Date());
|
||||
pas.setPasValor(dominioUtil.getSHAUsuario(user.getUsuUsuario(), password));
|
||||
daop.guardar(pas);
|
||||
UsuarioDTO udto = (UsuarioDTO) dominioUtil.getDto(UsuarioMapper.class, user);
|
||||
return udto;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param header
|
||||
* @param dao
|
||||
* @param usuario
|
||||
* @param email
|
||||
* @return
|
||||
* @throws DominioExcepcion
|
||||
* @throws DaoException
|
||||
*/
|
||||
public List<UsuarioDTO> recuperaPassword(HeaderMS header, DaoGenerico<Usuario, Integer> dao, String usuario, String email)
|
||||
throws DominioExcepcion, DaoException {
|
||||
List<UsuarioDTO> result = new ArrayList<>();
|
||||
List<Usuario> usuarios = null;
|
||||
if (usuario != null && !usuario.isBlank()) {
|
||||
usuarios = getUsuarios(dao, usuario);
|
||||
} else if (email != null && !email.isBlank()) {
|
||||
usuarios = getUsuarioMail(dao, email);
|
||||
}
|
||||
if (usuarios != null) {
|
||||
for (Usuario user : usuarios) {
|
||||
UsuarioDTO udto = (UsuarioDTO) dominioUtil.getDto(UsuarioMapper.class, user);
|
||||
System.out.println("PRUEBA DE ENVIO PARA USUARIO " + udto.getUsuNombre());
|
||||
String token = this.getToken(header, true);
|
||||
System.out.println("TOKEN " + token);
|
||||
user.setUsuFechaToken(new Date());
|
||||
user.setUsuToken(token);
|
||||
user.setUsuTiempoToken(DominioConstantes.TIEMPO_RESET);
|
||||
dao.actualizar(user);
|
||||
result.add(udto);
|
||||
this.notificadorUtil.notificarReset(user);
|
||||
}
|
||||
}
|
||||
System.out.println("OK RECUPERA PASS " + result.size());
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param header
|
||||
* @param dao
|
||||
* @param usuario
|
||||
* @return
|
||||
* @throws DominioExcepcion
|
||||
* @throws DaoException
|
||||
*/
|
||||
public List<UsuarioDTO> enviaOtp(HeaderMS header, DaoGenerico<Usuario, Integer> dao, String usuario)
|
||||
throws DominioExcepcion, DaoException {
|
||||
List<UsuarioDTO> result = new ArrayList<>();
|
||||
List<Usuario> usuarios = null;
|
||||
if (usuario != null) {
|
||||
usuarios = getUsuarios(dao, usuario);
|
||||
}
|
||||
if (usuarios != null) {
|
||||
for (Usuario user : usuarios) {
|
||||
UsuarioDTO udto = (UsuarioDTO) dominioUtil.getDto(UsuarioMapper.class, user);
|
||||
System.out.println("ENVIA OTP " + udto.getUsuNombre());
|
||||
Otp otp = otpUtil.generarOtp(user, ParametroEnum.OTPUSR);
|
||||
user.setUsuFechaToken(null);
|
||||
user.setUsuToken(null);
|
||||
user.setUsuTiempoToken(null);
|
||||
Poliza poliza = dBUtil.actualizaPoliza(user, DetalleCatalogoEnum.ESTAOTP, true);
|
||||
if (poliza.getPolObservacion() != null && !poliza.getPolObservacion().isBlank()) {
|
||||
udto.setPoliza(DominioUtil.getArchivo(poliza.getPolObservacion().trim()));
|
||||
}
|
||||
if (poliza.getPolAceptacion() != null && !poliza.getPolAceptacion().isBlank()) {
|
||||
udto.setAceptacion(DominioUtil.getArchivo(poliza.getPolAceptacion().trim()));
|
||||
}
|
||||
|
||||
dao.actualizar(user);
|
||||
result.add(udto);
|
||||
this.notificadorUtil.notificarOTP(user, otp.getOptValor());
|
||||
}
|
||||
}
|
||||
System.out.println("OK ENVIA OTP " + result.size());
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param header
|
||||
* @param dao
|
||||
* @param usuario
|
||||
* @param otpCodigo
|
||||
* @return
|
||||
* @throws DominioExcepcion
|
||||
* @throws DaoException
|
||||
*/
|
||||
public List<UsuarioDTO> validaOtp(HeaderMS header, DaoGenerico<Usuario, Integer> dao, String usuario, String otpCodigo)
|
||||
throws DominioExcepcion, DaoException {
|
||||
List<UsuarioDTO> result = new ArrayList<>();
|
||||
System.out.println("===================> VALIDA OTP... ");
|
||||
List<Usuario> usuarios = null;
|
||||
if (usuario != null) {
|
||||
usuarios = getUsuarios(dao, usuario);
|
||||
}
|
||||
if (usuarios != null) {
|
||||
for (Usuario user : usuarios) {
|
||||
UsuarioDTO udto = (UsuarioDTO) dominioUtil.getDto(UsuarioMapper.class, user);
|
||||
System.out.println("VALIDAR OTP " + udto.getUsuNombre());
|
||||
Otp otp = otpUtil.validarOtp(user, otpCodigo);
|
||||
user.setUsuFechaToken(null);
|
||||
user.setUsuToken(null);
|
||||
user.setUsuTiempoToken(null);
|
||||
if (otp != null && otp.getOtpCodigo() != null) {
|
||||
Poliza poliza = dBUtil.actualizaPoliza(user, DetalleCatalogoEnum.ESTACT, false);
|
||||
dao.actualizar(user);
|
||||
this.notificadorUtil.notificarBienvenida(user, poliza);
|
||||
result.add(udto);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param header
|
||||
* @param dao
|
||||
* @param usuario
|
||||
* @param password
|
||||
* @return
|
||||
* @throws DominioExcepcion
|
||||
* @throws DaoException
|
||||
*/
|
||||
public List<UsuarioDTO> login2(HeaderMS header, DaoGenerico<Usuario, Integer> dao, String usuario, String password)
|
||||
throws DominioExcepcion, DaoException{
|
||||
|
||||
List<UsuarioDTO> result = new ArrayList<>();
|
||||
String hash = dominioUtil.getSHAUsuario(usuario, password);
|
||||
String query = String.format(QueryEnum.LOGIN.getParametro().getParValor(), hash);
|
||||
List<Fila> usuarios = dao.ejecutarConsultaNativaList(query);
|
||||
List<RolDTO> roles = new ArrayList<>();
|
||||
UsuarioDTO udto = null;
|
||||
if (usuarios != null && !usuarios.isEmpty()) {
|
||||
boolean imagen = true;
|
||||
String token = this.getToken(header, false);
|
||||
Set<Integer> idRol = new HashSet<>();
|
||||
for (Fila f : usuarios) {
|
||||
RolDTO rdt = new RolDTO();
|
||||
rdt.setRolCodigo(f.getEntero(9));
|
||||
rdt.setRolNemonico(f.getString(10));
|
||||
rdt.setRolNombre(f.getString(11));
|
||||
if (!roles.contains(rdt)) {
|
||||
idRol.add(rdt.getRolCodigo());
|
||||
roles.add(rdt);
|
||||
}
|
||||
if (udto == null) {
|
||||
udto = this.crearDto(f, token);
|
||||
if (imagen && udto.getUsuUrlImagen() != null && !udto.getUsuUrlImagen().isBlank()) {
|
||||
udto.setImagen(DominioUtil.getArchivo(udto.getUsuUrlImagen()));
|
||||
udto.setUsuUrlImagen(DominioUtil.getNombreArchivo(udto.getUsuUrlImagen()));
|
||||
imagen = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
String ids = idRol.toString().replace("[", "").replace("]", "");
|
||||
query = String.format(QueryEnum.LOGROL.getParametro().getParValor(), ids, ids, ids, ids);
|
||||
List<Fila> priv = dao.ejecutarConsultaNativaList(query);
|
||||
roles = crearPrivilegios(priv, roles);
|
||||
|
||||
udto.setRol(roles);
|
||||
result.add(udto);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param priv
|
||||
* @param roles
|
||||
* @return
|
||||
*/
|
||||
public List<RolDTO> crearPrivilegios(List<Fila> priv, List<RolDTO> roles) {
|
||||
List<PrivilegioDTO> tmp = new ArrayList<>();
|
||||
if (priv != null && !priv.isEmpty()) {
|
||||
for (Fila f : priv) {
|
||||
PrivilegioDTO pdto = new PrivilegioDTO();
|
||||
pdto.setRolCodigo(f.getEntero(0));
|
||||
pdto.setPriLectura(f.getEntero(1));
|
||||
pdto.setPriEscritura(f.getEntero(2));
|
||||
pdto.setPriCreacion(f.getEntero(3));
|
||||
pdto.setPriActualizacion(f.getEntero(4));
|
||||
pdto.setOpcCodigo(f.getEntero(5));
|
||||
pdto.setOpcPadre(f.getEntero(6));
|
||||
pdto.setOpcNemonico(f.getString(7));
|
||||
pdto.setOpcNombre(f.getString(8));
|
||||
pdto.setOpcDescripcion(f.getString(9));
|
||||
pdto.setOpcComando(f.getString(10));
|
||||
pdto.setOpcEjecucion(f.getString(11));
|
||||
pdto.setOpcIcono(f.getString(12));
|
||||
tmp.add(pdto);
|
||||
}
|
||||
}
|
||||
for (RolDTO rol : roles) {
|
||||
rol.setOpciones(new ArrayList<>());
|
||||
for (PrivilegioDTO pv : tmp) {
|
||||
if (pv.getRolCodigo() != null && pv.getRolCodigo().equals(rol.getRolCodigo())) {
|
||||
if (pv.getOpcPadre() != null) {
|
||||
try {
|
||||
this.setHijoPadre(tmp, rol, pv);
|
||||
} catch (CloneNotSupportedException ex) {
|
||||
System.out.println("ERROR FATAL " + ex);
|
||||
}
|
||||
} else {
|
||||
rol.getOpciones().add(pv);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return roles;
|
||||
}
|
||||
|
||||
/**
|
||||
* Permite recuperar el padre de un determinado Privilegio
|
||||
*
|
||||
* @param data
|
||||
* @param codPadre
|
||||
* @return
|
||||
*/
|
||||
private void setHijoPadre(List<PrivilegioDTO> data, RolDTO rol, PrivilegioDTO hijo) throws CloneNotSupportedException {
|
||||
PrivilegioDTO pv = null;
|
||||
for (PrivilegioDTO p : rol.getOpciones()) {
|
||||
if (p.getOpcCodigo().equals(hijo.getOpcPadre())) {
|
||||
pv = p;
|
||||
if (p.getSubmenu() == null) {
|
||||
p.setSubmenu(new ArrayList<>());
|
||||
}
|
||||
p.getSubmenu().add(hijo);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (pv == null) {
|
||||
for (PrivilegioDTO p : data) {
|
||||
if (p.getOpcCodigo().equals(hijo.getOpcPadre())) {
|
||||
pv = (PrivilegioDTO) p.clone();
|
||||
if (pv.getSubmenu() == null) {
|
||||
pv.setSubmenu(new ArrayList<>());
|
||||
}
|
||||
pv.getSubmenu().add(hijo);
|
||||
rol.getOpciones().add(pv);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param header
|
||||
* @param dao
|
||||
* @param usuario
|
||||
* @param password
|
||||
* @return
|
||||
* @throws DominioExcepcion
|
||||
* @throws DaoException
|
||||
*/
|
||||
public List<UsuarioDTO> login(HeaderMS header, DaoGenerico<Usuario, Integer> dao, String usuario, String password)
|
||||
throws DominioExcepcion, DaoException {
|
||||
List<UsuarioDTO> result = new ArrayList<>();
|
||||
List<UsuarioDTO> lstNoCancelados = new ArrayList<>();
|
||||
|
||||
String hash = dominioUtil.getSHAUsuario(usuario, password);
|
||||
|
||||
String query = String.format(QueryEnum.LOGIN.getParametro().getParValor(), hash);
|
||||
List<Fila> usuarios = dao.ejecutarConsultaNativaList(query);
|
||||
Set<String> roles = new HashSet<>();
|
||||
if (usuarios != null && !usuarios.isEmpty()) {
|
||||
boolean imagen = true;
|
||||
String token = this.getToken(header, false);
|
||||
for (Fila f : usuarios) {
|
||||
roles.add(f.getString(16));
|
||||
UsuarioDTO udto = this.crearDto(f, token);
|
||||
if (imagen && udto.getUsuUrlImagen() != null && !udto.getUsuUrlImagen().trim().isEmpty()) {
|
||||
udto.setImagen(DominioUtil.getArchivo(udto.getUsuUrlImagen()));
|
||||
udto.setUsuUrlImagen(DominioUtil.getNombreArchivo(udto.getUsuUrlImagen()));
|
||||
imagen = false;
|
||||
}
|
||||
result.add(udto);
|
||||
}
|
||||
}
|
||||
|
||||
if (roles.size() < result.size()) {
|
||||
int polCancela = 0;
|
||||
for(UsuarioDTO udto: result){
|
||||
if(udto.getPolEstado().equals(DetalleCatalogoEnum.ESTCAN.name())){
|
||||
polCancela ++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(polCancela < result.size()){
|
||||
for(UsuarioDTO udto: result){
|
||||
if(!udto.getPolEstado().equals(DetalleCatalogoEnum.ESTCAN.name())){
|
||||
lstNoCancelados.add(udto);
|
||||
// result.remove(udto);
|
||||
}
|
||||
}
|
||||
result = lstNoCancelados;
|
||||
|
||||
}
|
||||
}
|
||||
System.out.println("OK LOGIN " + result.size());
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param f
|
||||
* @param token
|
||||
* @return
|
||||
*/
|
||||
private UsuarioDTO crearDto(Fila f, String token) {
|
||||
UsuarioDTO udto = new UsuarioDTO();
|
||||
udto.setUsuCodigo(f.getEntero(0));
|
||||
udto.setUsuUsuario(f.getString(1));
|
||||
udto.setUsuNombre(f.getString(2));
|
||||
udto.setUsuDescripcion(f.getString(3));
|
||||
udto.setUsuUrlImagen(f.getString(4));
|
||||
udto.setUsuEstado(f.getEntero(7).shortValue());
|
||||
udto.setPerCodigo(f.getString(8));
|
||||
udto.setPerIdentificacion(f.getString(9));
|
||||
udto.setUsuIdOrigen(f.getString(10));
|
||||
udto.setUsuOrigen(f.getString(11));
|
||||
udto.setUsuEmail(f.getString(12));
|
||||
Integer polCodigo = f.getEntero(13);
|
||||
udto.setPolCodigo(polCodigo == null ? -1 : polCodigo);
|
||||
udto.setPolEstado(f.getString(14));
|
||||
udto.setRolCodigo(f.getEntero(15));
|
||||
udto.setRolNemonico(f.getString(16));
|
||||
udto.setRolNombre(f.getString(17));
|
||||
udto.setEmpCodigo(f.getEntero(18));
|
||||
udto.setToken(token);
|
||||
return udto;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param header
|
||||
* @param reset
|
||||
* @return
|
||||
* @throws com.qsoft.erp.dominio.exception.DominioExcepcion
|
||||
*/
|
||||
public String getToken(HeaderMS header, boolean reset) throws DominioExcepcion {
|
||||
String token = null;
|
||||
try {
|
||||
if (reset) {
|
||||
header.setUsuario(DominioConstantes.USUARIO);
|
||||
}
|
||||
String user = this.getUserString(header);
|
||||
if (reset) {
|
||||
user = user.concat(DominioConstantes.SEPARADOR).concat(DominioConstantes.RESET);
|
||||
}
|
||||
String uuid = UUID.nameUUIDFromBytes(user.getBytes()).toString().replace("-", "");
|
||||
String valorOtp = OTP.generate("" + uuid, "" + System.nanoTime(), 64, OTP.TOTP);
|
||||
token = DigestUtils.sha256Hex(valorOtp);
|
||||
//Algorithm algorithm = Algorithm.HMAC256(DominioConstantes.WE_SECRET_KEY);
|
||||
//token = JWT.create().withIssuer(user).sign(algorithm);
|
||||
} catch (JWTCreationException ex) {
|
||||
throw new DominioExcepcion(ErrorTipo.ERROR, CodigoRespuesta.CODIGO_VALOR_NULO,
|
||||
"No se puede generar el token, " + ex);
|
||||
}
|
||||
return token;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param header
|
||||
* @param token
|
||||
* @return
|
||||
* @throws com.qsoft.erp.dominio.exception.DominioExcepcion
|
||||
*/
|
||||
public boolean verificarToken(HeaderMS header, String token) throws DominioExcepcion {
|
||||
boolean estado = false;
|
||||
try {
|
||||
if (header.getAplicacion() != null && header.getUsuario() != null && header.getDispositivo() != null) {
|
||||
Algorithm algorithm = Algorithm.HMAC256(DominioConstantes.WE_SECRET_KEY);
|
||||
JWTVerifier verifier = JWT.require(algorithm)
|
||||
.withIssuer(getUserString(header))
|
||||
.build();
|
||||
DecodedJWT jwt = verifier.verify(token);
|
||||
System.out.println("> " + jwt.getPayload());
|
||||
System.out.println("> " + jwt.getHeader());
|
||||
System.out.println("> " + jwt.getSignature());
|
||||
}
|
||||
} catch (JWTVerificationException ex) {
|
||||
throw new DominioExcepcion(ErrorTipo.ERROR, CodigoRespuesta.CODIGO_VALOR_NULO,
|
||||
"No se puede validar el token, " + ex);
|
||||
}
|
||||
return estado;
|
||||
}
|
||||
|
||||
/**
|
||||
* Permite obtener el usuario para obtener y validar el token
|
||||
*
|
||||
* @param header
|
||||
* @return
|
||||
*/
|
||||
private String getUserString(HeaderMS header) throws DominioExcepcion {
|
||||
if (header.getAplicacion() != null && header.getUsuario() != null && header.getDispositivo() != null) {
|
||||
return header.getUsuario().concat(DominioConstantes.SEPARADOR).concat(header.getAplicacion()).concat(DominioConstantes.SEPARADOR).
|
||||
concat(header.getDispositivo());
|
||||
} else {
|
||||
throw new DominioExcepcion(ErrorTipo.ERROR, CodigoRespuesta.CODIGO_VALOR_NULO,
|
||||
"No se puede generar el token, usuario, dispositivo y aplicacion no pueden ser nulos");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param dao
|
||||
* @param email
|
||||
* @return
|
||||
* @throws com.qsoft.dao.exception.DaoException
|
||||
*/
|
||||
public List<Usuario> getUsuarioMail(DaoGenerico<Usuario, Integer> dao, String email) throws DaoException {
|
||||
Usuario user = new Usuario();
|
||||
user.setUsuEmail(email);
|
||||
user.setUsuEstado(DominioConstantes.ACTIVO);
|
||||
return dao.buscarLista(user);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param dao
|
||||
* @param token
|
||||
* @return
|
||||
* @throws com.qsoft.dao.exception.DaoException
|
||||
*/
|
||||
public List<Usuario> getUsuarioToken(DaoGenerico<Usuario, Integer> dao, String token) throws DaoException {
|
||||
Usuario user = new Usuario();
|
||||
user.setUsuToken(token);
|
||||
user.setUsuEstado(DominioConstantes.ACTIVO);
|
||||
return dao.buscarLista(user);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param dao
|
||||
* @param usuario
|
||||
* @return
|
||||
* @throws com.qsoft.dao.exception.DaoException
|
||||
*/
|
||||
public List<Usuario> getUsuarios(DaoGenerico<Usuario, Integer> dao, String usuario) throws DaoException {
|
||||
Usuario user = new Usuario();
|
||||
user.setUsuUsuario(usuario);
|
||||
user.setUsuEstado(DominioConstantes.ACTIVO);
|
||||
return dao.buscarLista(user);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,172 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.qsoft.erp.dominio.util;
|
||||
|
||||
import static com.qsoft.erp.dominio.AccionGenerica.ACTUALIZA;
|
||||
import static com.qsoft.erp.dominio.AccionGenerica.CANCELA;
|
||||
import static com.qsoft.erp.dominio.AccionGenerica.CONSULTA;
|
||||
import static com.qsoft.erp.dominio.AccionGenerica.ELIMINA;
|
||||
import static com.qsoft.erp.dominio.AccionGenerica.GUARDA;
|
||||
import com.qsoft.erp.dominio.exception.DominioExcepcion;
|
||||
import com.qsoft.erp.dominio.mapper.AgendamientoMapper;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.qsoft.util.constantes.CodigoRespuesta;
|
||||
import com.qsoft.erp.dto.EstadoAgendamientoDTO;
|
||||
import com.qsoft.erp.constantes.SecuenciaEnum;
|
||||
import com.qsoft.erp.model.EstadoAgendamiento;
|
||||
import com.fasterxml.jackson.core.JsonParser;
|
||||
import com.qsoft.dao.exception.DaoException;
|
||||
import com.qsoft.erp.constantes.DominioConstantes;
|
||||
import com.qsoft.erp.constantes.EntidadEnum;
|
||||
import com.qsoft.util.constantes.ErrorTipo;
|
||||
import com.qsoft.erp.dto.AgendamientoDTO;
|
||||
import com.qsoft.erp.model.Agendamiento;
|
||||
import com.qsoft.util.ms.pojo.HeaderMS;
|
||||
import javax.transaction.Transactional;
|
||||
import javax.annotation.PostConstruct;
|
||||
import com.qsoft.erp.dao.DaoGenerico;
|
||||
import java.util.ArrayList;
|
||||
import javax.ejb.Stateless;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import javax.ejb.EJB;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author james
|
||||
*/
|
||||
@Stateless
|
||||
public class AgendaUtil {
|
||||
|
||||
@EJB
|
||||
private DominioUtil dominioUtil;
|
||||
|
||||
@EJB
|
||||
private SecuenciaUtil secuenciaUtil;
|
||||
|
||||
@PostConstruct
|
||||
public void postConstruct() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Permite registrar la persona con los telefonos
|
||||
*
|
||||
* @param header
|
||||
* @param entidades
|
||||
* @param tipoAccion
|
||||
* @return
|
||||
* @throws DominioExcepcion
|
||||
*/
|
||||
@Transactional(Transactional.TxType.REQUIRES_NEW)
|
||||
public List<Agendamiento> procesarAgenda(HeaderMS header, List<Map<String, Object>> entidades, int tipoAccion) throws DominioExcepcion {
|
||||
List<Agendamiento> data = new ArrayList<>();
|
||||
for (Map<String, Object> ent : entidades) {
|
||||
AgendamientoDTO agenda = (AgendamientoDTO) dominioUtil.crearObjeto(AgendamientoDTO.class, ent);
|
||||
System.out.println("AGENDA VALORES=> " + agenda.getAgeCobertura() + " => " + agenda.getAgeObservaMedico());
|
||||
List<EstadoAgendamientoDTO> lista = new ArrayList<>();
|
||||
|
||||
ObjectMapper maper = new ObjectMapper();
|
||||
maper.configure(JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES, true);
|
||||
if (ent.containsKey("estado")) {
|
||||
System.out.println("========> OK ESTADOS");
|
||||
for (Object row : (List<Object>) ent.get("estado")) {
|
||||
EstadoAgendamientoDTO col = (EstadoAgendamientoDTO) dominioUtil.crearObjeto(EstadoAgendamientoDTO.class, (Map<String, Object>) row);
|
||||
lista.add(col);
|
||||
}
|
||||
}
|
||||
agenda.setEstado(lista);
|
||||
Agendamiento result = crudAgendamiento(agenda, tipoAccion);
|
||||
data.add(result);
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param agendamiento
|
||||
* @param tipoAccion
|
||||
* @return
|
||||
* @throws DominioExcepcion
|
||||
*/
|
||||
@Transactional(Transactional.TxType.REQUIRES_NEW)
|
||||
private Agendamiento crudAgendamiento(AgendamientoDTO agendamiento, int tipoAccion) throws DominioExcepcion {
|
||||
DaoGenerico<Agendamiento, Integer> daoage = new DaoGenerico<>(Agendamiento.class);
|
||||
Agendamiento result;
|
||||
result = AgendamientoMapper.INSTANCE.getEntidad(agendamiento);
|
||||
result.setEstadoAgendamientoCollection(this.crearEstados(agendamiento, result));
|
||||
switch (tipoAccion) {
|
||||
case CONSULTA: {
|
||||
throw new DominioExcepcion(ErrorTipo.ERROR, CodigoRespuesta.CODIGO_ERROR_GENERICO,
|
||||
"Operacion CONSULTA no soportada para el controlador de Accion");
|
||||
}
|
||||
case GUARDA: {
|
||||
try {
|
||||
result.setAgeFechaRegistro(new Date());
|
||||
long cod = this.secuenciaUtil.getSecuencia(SecuenciaEnum.AGEMED);
|
||||
result.setAgeNemonico(this.dominioUtil.getCodAgendamiento(cod));
|
||||
daoage.guardar(result);
|
||||
} catch (DaoException ex) {
|
||||
throw new DominioExcepcion(ErrorTipo.FATAL, CodigoRespuesta.CODIGO_ERROR_GUARDA_BDD, ex.toString());
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ACTUALIZA: {
|
||||
try {
|
||||
DaoGenerico<EstadoAgendamiento, Integer> daoest = new DaoGenerico<>(EstadoAgendamiento.class);
|
||||
EstadoAgendamiento esa = new EstadoAgendamiento();
|
||||
esa.setAgeCodigo(new Agendamiento(result.getAgeCodigo()));
|
||||
for (EstadoAgendamiento es : daoest.buscarLista(esa)) {
|
||||
if (Objects.equals(DominioConstantes.ACTIVO, es.getEsaEstado())) {
|
||||
es.setEsaEstado(DominioConstantes.INACTIVO);
|
||||
es.setEsaFechaFin(new Date());
|
||||
daoest.actualizar(es);
|
||||
}
|
||||
}
|
||||
for (EstadoAgendamiento estado : result.getEstadoAgendamientoCollection()) {
|
||||
if (estado.getEsaCodigo() == null) {
|
||||
daoest.guardar(estado);
|
||||
}
|
||||
}
|
||||
result = daoage.actualizar(result);
|
||||
} catch (DaoException ex) {
|
||||
throw new DominioExcepcion(ErrorTipo.FATAL, CodigoRespuesta.CODIGO_ERROR_ACTUALIZA_BDD, ex.toString());
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ELIMINA: {
|
||||
throw new DominioExcepcion(ErrorTipo.ERROR,
|
||||
CodigoRespuesta.CODIGO_ERROR_GENERICO, "Operacion ELIMINACION aun no permitida");
|
||||
}
|
||||
case CANCELA: {
|
||||
throw new DominioExcepcion(ErrorTipo.ERROR,
|
||||
CodigoRespuesta.CODIGO_ERROR_GENERICO, "Operacion CANCELAR aun no permitida");
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param agendamientoDTO
|
||||
* @return
|
||||
* @throws DaoException
|
||||
*/
|
||||
private List<EstadoAgendamiento> crearEstados(AgendamientoDTO agendamientoDTO, Agendamiento agendamiento) {
|
||||
List<EstadoAgendamiento> data = new ArrayList<>();
|
||||
for (EstadoAgendamientoDTO estadoDTO : agendamientoDTO.getEstado()) {
|
||||
EstadoAgendamiento estado = (EstadoAgendamiento) this.dominioUtil.getEntidad(EntidadEnum.EstadoAgendamiento.getMapper(), estadoDTO);
|
||||
estado.setEsaEstado(DominioConstantes.ACTIVO);
|
||||
estado.setEsaFechaInicio(new Date());
|
||||
estado.setAgeCodigo(agendamiento);
|
||||
data.add(estado);
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,63 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.qsoft.erp.dominio.util;
|
||||
|
||||
import com.qsoft.erp.constantes.QueryEnum;
|
||||
import com.qsoft.erp.dao.DaoGenerico;
|
||||
import com.qsoft.erp.dto.AuditoriaDTO;
|
||||
import com.qsoft.erp.model.Auditoria;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import javax.ejb.Asynchronous;
|
||||
import javax.ejb.Stateless;
|
||||
import javax.persistence.Query;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author james
|
||||
*/
|
||||
@Stateless
|
||||
public class AuditoriaUtil {
|
||||
|
||||
private static List<AuditoriaDTO> auditoriaDTOs;
|
||||
private final static Integer MAX_AUDIT = 10;
|
||||
private final static Long MAX_TIME = 30 * 60 * 1000l;
|
||||
private static Long time;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param auditoria
|
||||
*/
|
||||
@Asynchronous
|
||||
public void AddAuditoria(AuditoriaDTO auditoria){
|
||||
if(auditoriaDTOs == null){
|
||||
auditoriaDTOs = new LinkedList<>();
|
||||
time = System.currentTimeMillis();
|
||||
}
|
||||
auditoriaDTOs.add(auditoria);
|
||||
if(auditoriaDTOs.size() >= MAX_AUDIT || System.currentTimeMillis() <= (time + MAX_TIME)){
|
||||
insertAuditoria(auditoriaDTOs.toString());
|
||||
auditoriaDTOs.clear();
|
||||
time = System.currentTimeMillis();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Permite ejecutar el insert en la tabla auditoria
|
||||
* @param data
|
||||
*/
|
||||
private void insertAuditoria(String data){
|
||||
// String insert = QueryEnum.AUDINS.getParametro().getParValor();
|
||||
// String objects = data;
|
||||
// objects = objects.substring(objects.indexOf("[") + 1, objects.lastIndexOf("]"));
|
||||
// insert = String.format(insert, objects);
|
||||
// DaoGenerico<Auditoria, Integer> dao = new DaoGenerico<>(Auditoria.class);
|
||||
// Query query = dao.getEm().createNativeQuery(insert);
|
||||
// query.executeUpdate();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,205 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.qsoft.erp.dominio.util;
|
||||
|
||||
import com.qsoft.dao.exception.DaoException;
|
||||
import com.qsoft.erp.dao.DaoGenerico;
|
||||
import com.qsoft.erp.model.Catalogo;
|
||||
import com.qsoft.erp.model.DetalleCatalogo;
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.ejb.Stateless;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author james
|
||||
*/
|
||||
@Stateless
|
||||
public class CatalogoUtil {
|
||||
|
||||
@PostConstruct
|
||||
public void postConstruct() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param codigo
|
||||
* @return
|
||||
*/
|
||||
public DetalleCatalogo cargar(Integer codigo) {
|
||||
DaoGenerico<DetalleCatalogo, Integer> generico = new DaoGenerico<>(DetalleCatalogo.class);
|
||||
DetalleCatalogo det = null;
|
||||
try {
|
||||
if (codigo != null) {
|
||||
det = generico.cargar(codigo);
|
||||
}
|
||||
} catch (DaoException ex) {
|
||||
det = null;
|
||||
}
|
||||
return det;
|
||||
}
|
||||
|
||||
/**
|
||||
* Permite obtener un detalle catalogo desde un nemonico
|
||||
*
|
||||
* @param nemonico
|
||||
* @param tipo
|
||||
* @return
|
||||
*/
|
||||
public DetalleCatalogo getDetallePorNemonicoTipo(String nemonico, String tipo) {
|
||||
DaoGenerico<DetalleCatalogo, Integer> generico = new DaoGenerico<>(DetalleCatalogo.class);
|
||||
DetalleCatalogo det = null;
|
||||
try {
|
||||
det = new DetalleCatalogo();
|
||||
det.setDetNemonico(nemonico);
|
||||
det.setDetTipo(tipo);
|
||||
det = generico.buscarUnico(det);
|
||||
} catch (DaoException ex) {
|
||||
det = null;
|
||||
}
|
||||
return det;
|
||||
}
|
||||
|
||||
/**
|
||||
* Permite obtener un detalle catalogo desde un nemonico
|
||||
*
|
||||
* @param nemonico
|
||||
* @param tipo
|
||||
* @return
|
||||
*/
|
||||
public String validarDetalleNemonico(String nemonico,String nombreCampo){
|
||||
String error = null;
|
||||
if(getDetallePorNemonico(nemonico)== null){
|
||||
error = String.format("Error: no se ha encontrado el dato con nemónico \"%s\" referente al campo %s", nemonico, nombreCampo);
|
||||
}
|
||||
return error;
|
||||
}
|
||||
public String validarDetalleOrigen(String origen,String nombreCampo){
|
||||
String error = null;
|
||||
if(getDetallePorOrigen(origen)== null){
|
||||
error = String.format("Error: no se ha encontrado el dato relacionado con \"%s\" referente al campo %s", origen, nombreCampo);
|
||||
}
|
||||
return error;
|
||||
}
|
||||
public String validarDetalleOrigenTipo(String origen,String tipo,String nombreCampo){
|
||||
String error = null;
|
||||
if(getDetallePorOrigenTipo(origen, tipo)== null){
|
||||
error = String.format("Error: no se ha encontrado el dato relacionado con \"%s\" de tipo \"%s\" referente al campo %s", origen, tipo,nombreCampo);
|
||||
}
|
||||
return error;
|
||||
}
|
||||
public DetalleCatalogo getDetallePorNemonicoPadre(String nemonico, String padreNemonico) {
|
||||
DaoGenerico<DetalleCatalogo, Integer> generico = new DaoGenerico<>(DetalleCatalogo.class);
|
||||
DetalleCatalogo det = null;
|
||||
try {
|
||||
Catalogo padre = new Catalogo();
|
||||
padre.setCatNemonico(padreNemonico);
|
||||
det = new DetalleCatalogo();
|
||||
det.setDetNemonico(nemonico);
|
||||
det.setCatCodigo(padre);
|
||||
det = generico.buscarUnico(det);
|
||||
} catch (DaoException ex) {
|
||||
det = null;
|
||||
}
|
||||
return det;
|
||||
}
|
||||
public DetalleCatalogo getDetallePorOrigenTipo(String origen, String tipo) {
|
||||
DaoGenerico<DetalleCatalogo, Integer> generico = new DaoGenerico<>(DetalleCatalogo.class);
|
||||
DetalleCatalogo det = null;
|
||||
try {
|
||||
det = new DetalleCatalogo();
|
||||
det.setDetOrigen(origen);
|
||||
det.setDetTipo(tipo);
|
||||
det = generico.buscarUnico(det);
|
||||
} catch (DaoException ex) {
|
||||
det = null;
|
||||
}
|
||||
return det;
|
||||
}
|
||||
/**
|
||||
* Permite obtener un detalle catalogo desde un nemonico
|
||||
*
|
||||
* @param nemonico
|
||||
* @param tipo
|
||||
* @return
|
||||
*/
|
||||
public String getOrigenPorNemonicoTipo(String nemonico, String tipo) {
|
||||
DaoGenerico<DetalleCatalogo, Integer> generico = new DaoGenerico<>(DetalleCatalogo.class);
|
||||
DetalleCatalogo det = null;
|
||||
try {
|
||||
det = new DetalleCatalogo();
|
||||
det.setDetNemonico(nemonico);
|
||||
det.setDetTipo(tipo);
|
||||
det = generico.buscarUnico(det);
|
||||
} catch (DaoException ex) {
|
||||
det = null;
|
||||
}
|
||||
return det != null ? det.getDetOrigen() : "";
|
||||
}
|
||||
|
||||
/**
|
||||
* Permite obtener un detalle catalogo desde un nemonico
|
||||
*
|
||||
* @param nemonico
|
||||
* @return
|
||||
*/
|
||||
public DetalleCatalogo getDetallePorNemonico(String nemonico) {
|
||||
DaoGenerico<DetalleCatalogo, Integer> generico = new DaoGenerico<>(DetalleCatalogo.class);
|
||||
DetalleCatalogo det = null;
|
||||
try {
|
||||
det = new DetalleCatalogo();
|
||||
det.setDetNemonico(nemonico);
|
||||
det = generico.buscarUnico(det);
|
||||
} catch (DaoException ex) {
|
||||
det = null;
|
||||
}
|
||||
return det;
|
||||
}
|
||||
|
||||
public DetalleCatalogo getDetallePorNemonicoDao(String nemonico, DaoGenerico<DetalleCatalogo, Integer> generico) {
|
||||
DetalleCatalogo det = null;
|
||||
try {
|
||||
det = new DetalleCatalogo();
|
||||
det.setDetNemonico(nemonico);
|
||||
det = generico.buscarUnico(det);
|
||||
} catch (DaoException ex) {
|
||||
det = null;
|
||||
}
|
||||
return det;
|
||||
}
|
||||
|
||||
/**
|
||||
* Permite obtener un detalle catalogo desde un codigo de origen
|
||||
*
|
||||
* @param origen
|
||||
* @return
|
||||
*/
|
||||
public DetalleCatalogo getDetallePorOrigen(String origen) {
|
||||
DaoGenerico<DetalleCatalogo, Integer> generico = new DaoGenerico<>(DetalleCatalogo.class);
|
||||
DetalleCatalogo det = null;
|
||||
try {
|
||||
det = new DetalleCatalogo();
|
||||
det.setDetOrigen(origen);
|
||||
det = generico.buscarUnico(det);
|
||||
} catch (DaoException ex) {
|
||||
det = null;
|
||||
}
|
||||
return det;
|
||||
}
|
||||
|
||||
public DetalleCatalogo getDetallePorCodigo(Integer detCodigo) {
|
||||
DaoGenerico<DetalleCatalogo, Integer> generico = new DaoGenerico<>(DetalleCatalogo.class);
|
||||
DetalleCatalogo det = null;
|
||||
try {
|
||||
det = new DetalleCatalogo(detCodigo);
|
||||
det = generico.buscarUnico(det);
|
||||
} catch (DaoException ex) {
|
||||
det = null;
|
||||
}
|
||||
return det;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,267 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.qsoft.erp.dominio.util;
|
||||
|
||||
import com.qsoft.dao.exception.DaoException;
|
||||
import com.qsoft.dao.util.Fila;
|
||||
import com.qsoft.util.constantes.CodigoRespuesta;
|
||||
import com.qsoft.util.constantes.ErrorTipo;
|
||||
import com.qsoft.erp.constantes.DetalleCatalogoEnum;
|
||||
import com.qsoft.erp.constantes.DominioConstantes;
|
||||
import com.qsoft.erp.constantes.ParametroEnum;
|
||||
import com.qsoft.erp.constantes.QueryEnum;
|
||||
import com.qsoft.erp.dao.DaoGenerico;
|
||||
import com.qsoft.erp.dominio.exception.DominioExcepcion;
|
||||
import com.qsoft.erp.model.Agendamiento;
|
||||
import com.qsoft.erp.model.DetalleCatalogo;
|
||||
import com.qsoft.erp.model.Email;
|
||||
import com.qsoft.erp.model.EstadoLiquidacion;
|
||||
import com.qsoft.erp.model.EstadoPoliza;
|
||||
import com.qsoft.erp.model.Persona;
|
||||
import com.qsoft.erp.model.PersonaPoliza;
|
||||
import com.qsoft.erp.model.Poliza;
|
||||
import com.qsoft.erp.model.Usuario;
|
||||
import com.qsoft.erp.reportes.UtilitarioReporte;
|
||||
import com.qsoft.util.ms.pojo.HeaderMS;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.ejb.Stateless;
|
||||
import javax.transaction.Transactional;
|
||||
import org.apache.commons.lang3.math.NumberUtils;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author james
|
||||
*/
|
||||
@Stateless
|
||||
public class DBUtil {
|
||||
|
||||
@PostConstruct
|
||||
public void postConstruct() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param usuario
|
||||
* @return
|
||||
* @throws DaoException
|
||||
*/
|
||||
public Poliza getPolizaFromUser(Usuario usuario) throws DaoException {
|
||||
DaoGenerico<PersonaPoliza, Integer> daoppol = new DaoGenerico<>(PersonaPoliza.class);
|
||||
Poliza poliza = null;
|
||||
PersonaPoliza perpol = new PersonaPoliza();
|
||||
perpol.setPerCodigo(new Persona(NumberUtils.createInteger(usuario.getUsuIdOrigen())));
|
||||
perpol.setPepEstado(DominioConstantes.ACTIVO);
|
||||
perpol.setDetTipoPersona(DetalleCatalogoEnum.PTITU.getDetalle());
|
||||
for (PersonaPoliza pp : daoppol.buscarLista(perpol)) {
|
||||
poliza = pp.getPolCodigo();
|
||||
System.out.println("=================> POLIZA CONSULTADA " + poliza.getPolCodigo());
|
||||
}
|
||||
return poliza;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param usuario
|
||||
* @param estado
|
||||
* @param generar
|
||||
* @return
|
||||
* @throws DaoException
|
||||
* @throws com.qsoft.erp.dominio.exception.DominioExcepcion
|
||||
*/
|
||||
public Poliza actualizaPoliza(Usuario usuario, DetalleCatalogoEnum estado, boolean generar) throws DaoException, DominioExcepcion {
|
||||
DaoGenerico<PersonaPoliza, Integer> daoppol = new DaoGenerico<>(PersonaPoliza.class);
|
||||
DaoGenerico<Poliza, Integer> daopol = new DaoGenerico<>(Poliza.class);
|
||||
Poliza poliza = null;
|
||||
PersonaPoliza perpol = new PersonaPoliza();
|
||||
perpol.setPerCodigo(new Persona(NumberUtils.createInteger(usuario.getUsuIdOrigen())));
|
||||
perpol.setPepEstado(DominioConstantes.ACTIVO);
|
||||
perpol.setDetTipoPersona(DetalleCatalogoEnum.PTITU.getDetalle());
|
||||
Persona persona = null;
|
||||
for (PersonaPoliza pp : daoppol.buscarLista(perpol)) {
|
||||
poliza = daopol.cargar(pp.getPolCodigo().getPolCodigo());
|
||||
persona = pp.getPerCodigo();
|
||||
}
|
||||
for(EstadoPoliza es: poliza.getEstadoPolizaCollection()){
|
||||
if ((Objects.equals(DominioConstantes.ACTIVO, es.getEspEstado()))) {
|
||||
es.setEspFechaFin(new Date());
|
||||
es.setEspEstado(DominioConstantes.INACTIVO);
|
||||
}
|
||||
}
|
||||
poliza.getEstadoPolizaCollection().add(this.crearEstado(poliza, estado.getDetalle(), new Date(), null, true));
|
||||
String url = null;
|
||||
String acepta = null;
|
||||
if (generar) {
|
||||
try {
|
||||
System.out.println("===========> GENERAR REPORTE ");
|
||||
UtilitarioReporte reporte = new UtilitarioReporte();
|
||||
url = reporte.generarContrato(poliza, persona);
|
||||
System.out.println("===========> EVALUA EMPRESA " + poliza.getEmpCodigo().getEmpDinamico());
|
||||
if (poliza.getEmpCodigo().getEmpDinamico() == null || poliza.getEmpCodigo().getEmpDinamico().isBlank()
|
||||
|| !poliza.getEmpCodigo().getEmpDinamico().replace(" ", "").contains("\"ifi\":1")) {
|
||||
acepta = reporte.generarAceptacion(poliza, persona);
|
||||
poliza.setPolAceptacion(acepta);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
throw new DominioExcepcion(ErrorTipo.ERROR, CodigoRespuesta.CODIGO_ERROR_GENERICO, "ERROR no se pudo generar el contrato " + ex);
|
||||
}
|
||||
poliza.setPolObservacion(url);
|
||||
}
|
||||
if (estado.equals(DetalleCatalogoEnum.ESTACT)) {
|
||||
|
||||
}
|
||||
daopol.actualizar(poliza);
|
||||
return poliza;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param poliza
|
||||
* @param estado
|
||||
* @param fecIni
|
||||
* @param fecFin
|
||||
* @param activo
|
||||
* @return
|
||||
*/
|
||||
public EstadoPoliza crearEstado(Poliza poliza, DetalleCatalogo estado, Date fecIni, Date fecFin, boolean activo) {
|
||||
EstadoPoliza es = new EstadoPoliza();
|
||||
es.setDetEstado(estado);
|
||||
es.setEspEstado(activo? DominioConstantes.ACTIVO: DominioConstantes.INACTIVO);
|
||||
es.setEspFechaInicio(fecIni);
|
||||
es.setEspFechaFin(fecFin);
|
||||
es.setPolCodigo(poliza);
|
||||
es.setEspObservacion("Cambio de estado " + es.getDetEstado().getDetDescripcion());
|
||||
return es;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param header
|
||||
* @param tipoAgendamiento
|
||||
* @param perBeneficiario
|
||||
* @param polCodigo
|
||||
* @param copCodigo
|
||||
* @return
|
||||
*/
|
||||
@Transactional(Transactional.TxType.REQUIRES_NEW)
|
||||
public List<Map<String, Object>> getValoresAgenda(HeaderMS header, String tipoAgendamiento, String perBeneficiario, String polCodigo, String copCodigo) {
|
||||
List<Map<String, Object>> data = new ArrayList<>();
|
||||
Map<String, Object> fila = this.getValoresAgendamiento(tipoAgendamiento, perBeneficiario, polCodigo);
|
||||
|
||||
String query = QueryEnum.AGELIQ.getQuery();
|
||||
query = String.format(query, fila.get("coberturas"), "" + polCodigo, "" + perBeneficiario);
|
||||
System.out.println("QUERY AGELIQ => " + query);
|
||||
fila.remove("coberturas");
|
||||
DaoGenerico<Agendamiento, Integer> dao = new DaoGenerico<>(Agendamiento.class);
|
||||
List<Fila> result = dao.ejecutarConsultaNativaList(query);
|
||||
Double registrado = 0.0;
|
||||
Double objetado = 0.0;
|
||||
Double pagado = 0.0;
|
||||
for (Fila f : result) {
|
||||
//l.LIQ_CODIGO, p.POL_CODIGO, l.PER_BENEFICIARIO, dl.DEL_VALOR_REGISTRADO, dl.DEL_VALOR_OBJETADO, dl.DEL_VALOR_PAGADO , dc2.DET_NOMBRE
|
||||
registrado += f.getDouble(3) == null ? 0.0 : f.getDouble(3);
|
||||
objetado += f.getDouble(4) == null ? 0.0 : f.getDouble(4);
|
||||
pagado += f.getDouble(5) == null ? 0.0 : f.getDouble(5);
|
||||
}
|
||||
fila.put("liqRegistrado", registrado);
|
||||
fila.put("liqObjetado", objetado);
|
||||
fila.put("liqFacturado", pagado);
|
||||
data.add(fila);
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param tipoAgendamiento
|
||||
* @param perBeneficiario
|
||||
* @param polCodigo
|
||||
* @return
|
||||
*/
|
||||
private Map<String, Object> getValoresAgendamiento(String tipoAgendamiento, String perBeneficiario, String polCodigo) {
|
||||
String query = QueryEnum.AGEVAL.getQuery();
|
||||
query = String.format(query, perBeneficiario, polCodigo, tipoAgendamiento);
|
||||
System.out.println("QUERY AGEVAL => " + query);
|
||||
DaoGenerico<Agendamiento, Integer> dao = new DaoGenerico<>(Agendamiento.class);
|
||||
Double valor = 0.0;
|
||||
Double facturado = 0.0;
|
||||
Double cubierto = 0.0;
|
||||
Double cobertura = 0.0;
|
||||
Double topeCobertura = 0.0;
|
||||
String tipoAge = null;
|
||||
String estadoAge = null;
|
||||
String codDet = null;
|
||||
|
||||
for (Fila f : dao.ejecutarConsultaNativaList(query)) {
|
||||
//a.PER_BENEFICIARIO, a.POL_CODIGO, a.AGE_CODIGO, dc1.DET_NOMBRE, a.AGE_VALOR, a.AGE_FACTURADO, a.AGE_CUBIERTO, a.AGE_COBERTURA, dc.DET_NOMBRE , ea.ESA_ESTADO, dc1.DET_ORIGEN
|
||||
tipoAge = f.getString(3);
|
||||
valor += f.getDouble(4) == null ? 0.0 : f.getDouble(4);
|
||||
facturado += f.getDouble(5) == null ? 0.0 : f.getDouble(5);
|
||||
cubierto += f.getDouble(6) == null ? 0.0 : f.getDouble(6);
|
||||
cobertura += f.getDouble(7) == null ? 0.0 : f.getDouble(7);
|
||||
estadoAge = f.getString(8);
|
||||
if (f.getString(10) != null && !f.getString(10).isBlank()) {
|
||||
codDet = f.getString(10);
|
||||
}
|
||||
}
|
||||
|
||||
query = QueryEnum.AGELCO.getQuery();
|
||||
query = String.format(query, polCodigo, tipoAgendamiento);
|
||||
System.out.println("QUERY AGELCO => " + query);
|
||||
codDet = "";
|
||||
for (Fila f : dao.ejecutarConsultaNativaList(query)) {
|
||||
codDet += f.getEntero(0) + ",";
|
||||
topeCobertura = f.getDouble(1);
|
||||
}
|
||||
if (codDet.endsWith(",")) {
|
||||
codDet = codDet.substring(0, codDet.lastIndexOf(","));
|
||||
}
|
||||
|
||||
codDet = codDet == null ? "null" : codDet.isBlank() ? "null" : codDet;
|
||||
|
||||
System.out.println(">>>OK TOPE " + topeCobertura);
|
||||
Map<String, Object> data = new HashMap<>();
|
||||
data.put("tipoAgendamiento", tipoAge);
|
||||
data.put("ageValor", valor);
|
||||
data.put("ageFacturado", facturado);
|
||||
data.put("ageCubierto", cubierto);
|
||||
data.put("ageCobertura", cobertura);
|
||||
data.put("topeCobertura", topeCobertura);
|
||||
data.put("estadoAgendamiento", estadoAge);
|
||||
data.put("estadoAgendamiento", estadoAge);
|
||||
data.put("coberturas", codDet);
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param emaCodigo
|
||||
* @param observacion
|
||||
* @param estado
|
||||
* @param add
|
||||
*/
|
||||
@Transactional(Transactional.TxType.REQUIRES_NEW)
|
||||
public synchronized void actualizarNotificacion(Integer emaCodigo, String observacion, ParametroEnum estado, boolean add) {
|
||||
try {
|
||||
DaoGenerico<Email, Integer> dao = new DaoGenerico<>(Email.class);
|
||||
Email email = dao.cargar(emaCodigo);
|
||||
email.setParEstado(estado.getParametro());
|
||||
email.setEmaObservacion(observacion);
|
||||
if (add) {
|
||||
email.setEmaIntento((short) (email.getEmaIntento() + 1));
|
||||
}
|
||||
dao.actualizar(email);
|
||||
} catch (Exception ex) {
|
||||
System.out.println("ERROR al actualizar " + emaCodigo + ": " + ex.toString());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,537 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.qsoft.erp.dominio.util;
|
||||
|
||||
import com.qsoft.dao.exception.DaoException;
|
||||
import com.qsoft.dao.util.ConfiguracionEnum;
|
||||
import com.qsoft.dao.util.Constantes;
|
||||
import com.qsoft.dao.util.Fila;
|
||||
import com.qsoft.util.constantes.CodigoRespuesta;
|
||||
import com.qsoft.util.constantes.ErrorTipo;
|
||||
import com.qsoft.util.mapper.QParser;
|
||||
import com.qsoft.erp.constantes.DominioConstantes;
|
||||
import com.qsoft.erp.constantes.EntidadEnum;
|
||||
import com.qsoft.erp.constantes.QueryEnum;
|
||||
import com.qsoft.erp.dao.DaoGenerico;
|
||||
import com.qsoft.erp.dominio.exception.DominioExcepcion;
|
||||
import com.qsoft.erp.model.Parametro;
|
||||
import com.qsoft.erp.model.Usuario;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.Serializable;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.nio.file.StandardCopyOption;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
import javax.ejb.Stateless;
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author james
|
||||
*/
|
||||
@Stateless
|
||||
public class DominioUtil {
|
||||
|
||||
private static final String METODO_DTO = "getDto";
|
||||
private static final String METODO_ENTIDAD = "getEntidad";
|
||||
private static final String SEPARADOR = ":";
|
||||
private static final String PATRON_LIQUIDACION = "LQ%s";
|
||||
private static final String PATRON_AGENDA = "AGE%s";
|
||||
private static final String PATRON_POLIZA = "POL%s";
|
||||
private static final int LONGITUD = 10;
|
||||
public static final String TIPO_QUERY = "QUERY";
|
||||
|
||||
/**
|
||||
*
|
||||
* @param liquidacion
|
||||
* @return
|
||||
*/
|
||||
public Usuario getTitularLiquidacion(Integer liquidacion) {
|
||||
Usuario usuario = new Usuario();
|
||||
DaoGenerico<Usuario, Integer> dao = new DaoGenerico<>(Usuario.class);
|
||||
String query = String.format(QueryEnum.USULIQ.getParametro().getParValor(), liquidacion);
|
||||
System.out.println("======> EJECUTAR QUERY " + query);
|
||||
List<Fila> usuarios = dao.ejecutarConsultaNativaList(query);
|
||||
for (Fila fila : usuarios) {
|
||||
System.out.println("FILA " + fila);
|
||||
if (fila.getEntero(0) != null) {
|
||||
try {
|
||||
usuario = dao.cargar(fila.getEntero(0));
|
||||
} catch (DaoException ex) {
|
||||
usuario = new Usuario();
|
||||
}
|
||||
}
|
||||
}
|
||||
return usuario;
|
||||
}
|
||||
|
||||
/**
|
||||
* *
|
||||
* Permite generar un ZIP con el contenido de una carpeta permite indicar la carpeta el nombre del archivo de salida
|
||||
*
|
||||
* @param folder
|
||||
* @param nombreZip
|
||||
* @param incluirCarpetas
|
||||
* @return {@link ZipOutputStream}
|
||||
*/
|
||||
public File crearZip(String folder, String nombreZip, boolean incluirCarpetas) {
|
||||
File salida = new File(folder + Constantes.SEPARADOR + nombreZip);
|
||||
try {
|
||||
FileOutputStream fos = new FileOutputStream(salida);
|
||||
ZipOutputStream zos = new ZipOutputStream(new BufferedOutputStream(fos));
|
||||
this.addFiles(salida,zos, new File(folder), folder, incluirCarpetas);
|
||||
zos.close();
|
||||
System.out.println("OK creado el ZIP");
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace(System.err);
|
||||
}
|
||||
return salida;
|
||||
}
|
||||
|
||||
public void copiarArchivos(String origen, String destino, boolean incluirCarpetas) {
|
||||
try {
|
||||
Path origenPath = Paths.get(origen);
|
||||
Path destinoPath = Paths.get(destino);
|
||||
Files.copy(origenPath, destinoPath, StandardCopyOption.REPLACE_EXISTING);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace(System.err);
|
||||
}
|
||||
}
|
||||
|
||||
public String obtenerAnioDeFecha(Date fecha){
|
||||
return DominioConstantes.FORMAT_AÑO_SDF.format(fecha);
|
||||
}
|
||||
/**
|
||||
* Permite agregar archivos de forma recursiva a un ZIP
|
||||
*
|
||||
* @param zos
|
||||
* @param folder
|
||||
* @param incluirCarpetas
|
||||
*/
|
||||
private void addFiles(File zip, ZipOutputStream zos, File folder, String baseFolder, boolean incluirCarpetas) {
|
||||
for (File f : folder.listFiles()) {
|
||||
if (f.isDirectory()) {
|
||||
if (incluirCarpetas) {
|
||||
addFiles(zip,zos, f, baseFolder, incluirCarpetas);
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
String nombreArchivo = f.getAbsolutePath().replace(baseFolder, "");
|
||||
nombreArchivo = nombreArchivo.startsWith("/") ? nombreArchivo.replaceFirst("/", "") : nombreArchivo;
|
||||
if(!zip.getName().equals(nombreArchivo)){
|
||||
FileInputStream in = new FileInputStream(f);
|
||||
zos.putNextEntry(new ZipEntry(nombreArchivo ));
|
||||
zos.write(in.readAllBytes());
|
||||
in.close();
|
||||
zos.closeEntry();
|
||||
}
|
||||
|
||||
|
||||
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Validador de cedula ecuatoriana
|
||||
*
|
||||
* @param cedula
|
||||
* @return
|
||||
* @throws DominioExcepcion
|
||||
*/
|
||||
public String aStringLn(List<String> lst){
|
||||
StringBuilder sb = new StringBuilder("");
|
||||
for (String string : lst) {
|
||||
sb.append(string);
|
||||
sb.append(System.getProperty("line.separator"));
|
||||
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
public static String replaceLast(String text, String regex, String replacement) {
|
||||
return text.replaceFirst("(?s)"+regex+"(?!.*?"+regex+")", replacement);
|
||||
}
|
||||
public boolean validarCedula(String cedula) throws DominioExcepcion {
|
||||
boolean valida = false;
|
||||
byte primeros2, tercerD, Dverificador, multiplicar, suma = 0, aux;
|
||||
byte[] digitos = new byte[9];
|
||||
try {
|
||||
if (cedula.length() != 10) {
|
||||
throw new DominioExcepcion(ErrorTipo.ERROR, CodigoRespuesta.CODIGO_ERROR_CONSULTA_BDD,
|
||||
"La c\u00e9dula debe contener 10 d\u00edgitos sin espacios<--\n");
|
||||
}
|
||||
|
||||
Dverificador = Byte.parseByte("" + cedula.charAt(9));
|
||||
primeros2 = Byte.parseByte(cedula.substring(0, 2));
|
||||
tercerD = Byte.parseByte("" + cedula.charAt(2));
|
||||
for (byte i = 0; i < 9; i++) {
|
||||
digitos[i] = Byte.parseByte("" + cedula.charAt(i));
|
||||
}
|
||||
if (primeros2 >= 1 & primeros2 <= 24) {
|
||||
if (tercerD <= 6) {
|
||||
for (byte i = 0; i < 9; i = (byte) (i + 2)) {
|
||||
multiplicar = (byte) (digitos[i] * 2);
|
||||
if (multiplicar > 9) {
|
||||
multiplicar = (byte) (multiplicar - 9);
|
||||
}
|
||||
suma = (byte) (suma + multiplicar);
|
||||
}
|
||||
for (byte i = 1; i < 9; i = (byte) (i + 2)) {
|
||||
multiplicar = (byte) (digitos[i] * 1);
|
||||
suma = (byte) (suma + multiplicar);
|
||||
}
|
||||
aux = suma;
|
||||
while (aux % 10 != 0) {
|
||||
aux = (byte) (aux + 1);
|
||||
}
|
||||
suma = (byte) (aux - suma);
|
||||
valida = suma == Dverificador;
|
||||
}
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
throw new DominioExcepcion(ErrorTipo.ERROR, CodigoRespuesta.CODIGO_ERROR_CONSULTA_BDD,
|
||||
"La c\u00e9dula debe contener solo d\u00edgitos num\u00e9ricos<--\n");
|
||||
}
|
||||
return valida;
|
||||
}
|
||||
public boolean validarCedulaSinException(String cedula) throws DominioExcepcion {
|
||||
boolean valida = false;
|
||||
|
||||
byte primeros2, tercerD, Dverificador, multiplicar, suma = 0, aux;
|
||||
byte[] digitos = new byte[9];
|
||||
try {
|
||||
if (cedula.length() != 10) {
|
||||
valida = false;
|
||||
}else{
|
||||
Dverificador = Byte.parseByte("" + cedula.charAt(9));
|
||||
primeros2 = Byte.parseByte(cedula.substring(0, 2));
|
||||
tercerD = Byte.parseByte("" + cedula.charAt(2));
|
||||
for (byte i = 0; i < 9; i++) {
|
||||
digitos[i] = Byte.parseByte("" + cedula.charAt(i));
|
||||
}
|
||||
if (primeros2 >= 1 & primeros2 <= 24) {
|
||||
if (tercerD <= 6) {
|
||||
for (byte i = 0; i < 9; i = (byte) (i + 2)) {
|
||||
multiplicar = (byte) (digitos[i] * 2);
|
||||
if (multiplicar > 9) {
|
||||
multiplicar = (byte) (multiplicar - 9);
|
||||
}
|
||||
suma = (byte) (suma + multiplicar);
|
||||
}
|
||||
for (byte i = 1; i < 9; i = (byte) (i + 2)) {
|
||||
multiplicar = (byte) (digitos[i] * 1);
|
||||
suma = (byte) (suma + multiplicar);
|
||||
}
|
||||
aux = suma;
|
||||
while (aux % 10 != 0) {
|
||||
aux = (byte) (aux + 1);
|
||||
}
|
||||
suma = (byte) (aux - suma);
|
||||
valida = suma == Dverificador;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
} catch (NumberFormatException e) {
|
||||
valida = false;
|
||||
}
|
||||
return valida;
|
||||
}
|
||||
public boolean validarFecha(String fecha, SimpleDateFormat formato){
|
||||
boolean correcto = false;
|
||||
try {
|
||||
formato.setLenient(false);
|
||||
formato.parse(fecha);
|
||||
correcto = true;
|
||||
} catch (ParseException e) {
|
||||
correcto = false;
|
||||
}
|
||||
return correcto;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param numero
|
||||
* @return
|
||||
*/
|
||||
public String getCodLiquidacion(long numero) {
|
||||
String codigo = String.format(PATRON_LIQUIDACION, StringUtils.leftPad("" + numero, LONGITUD, "0"));
|
||||
return codigo;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param numero
|
||||
* @return
|
||||
*/
|
||||
public String getCodAgendamiento(long numero) {
|
||||
String codigo = String.format(PATRON_AGENDA, StringUtils.leftPad("" + numero, LONGITUD, "0"));
|
||||
return codigo;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param numero
|
||||
* @return
|
||||
*/
|
||||
public String getCodPoliza(long numero) {
|
||||
String codigo = String.format(PATRON_POLIZA, StringUtils.leftPad("" + numero, LONGITUD, "0"));
|
||||
return codigo;
|
||||
}
|
||||
|
||||
public Parametro
|
||||
getParametro(String nemonico, String tipo) {
|
||||
DaoGenerico<Parametro, Integer> dao = new DaoGenerico<>(Parametro.class
|
||||
);
|
||||
Parametro param = new Parametro();
|
||||
|
||||
param.setParNemonico(nemonico);
|
||||
|
||||
param.setParTipo(tipo);
|
||||
|
||||
try {
|
||||
param = dao.buscarUnico(param);
|
||||
} catch (DaoException ex) {
|
||||
param = null;
|
||||
}
|
||||
return param;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param valor
|
||||
* @return
|
||||
* @throws DominioExcepcion
|
||||
*/
|
||||
public String getSHAValor(String valor) throws DominioExcepcion {
|
||||
if (valor == null) {
|
||||
throw new DominioExcepcion(ErrorTipo.FATAL, CodigoRespuesta.CODIGO_IN_NULO,
|
||||
"EL valor a cifrar no puede ser nulo");
|
||||
}
|
||||
return DigestUtils.sha512Hex(valor);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param user
|
||||
* @param password
|
||||
* @return
|
||||
* @throws DominioExcepcion
|
||||
*/
|
||||
public String getSHAUsuario(String user, String password) throws DominioExcepcion {
|
||||
if (user == null || password == null) {
|
||||
throw new DominioExcepcion(ErrorTipo.FATAL, CodigoRespuesta.CODIGO_IN_NULO,
|
||||
"EL usuario y password no puede ser nulo");
|
||||
}
|
||||
return DigestUtils.sha512Hex(user + SEPARADOR + password);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param entidad
|
||||
* @return
|
||||
*/
|
||||
public DaoGenerico
|
||||
generarDao(String entidad) {
|
||||
EntidadEnum en = Enum.valueOf(EntidadEnum.class,
|
||||
entidad);
|
||||
return generarDao(en, ConfiguracionEnum.MAXIMO_REGISTROS.getInteger());
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param entidad
|
||||
* @param maxRegistros
|
||||
* @return
|
||||
*/
|
||||
public DaoGenerico
|
||||
generarDao(String entidad, Integer maxRegistros) {
|
||||
EntidadEnum en = Enum.valueOf(EntidadEnum.class,
|
||||
entidad);
|
||||
return generarDao(en, maxRegistros);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param entidad
|
||||
* @return
|
||||
*/
|
||||
public DaoGenerico generarDao(EntidadEnum entidad) {
|
||||
return generarDao(entidad, null);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param archivo
|
||||
* @return
|
||||
*/
|
||||
public static String getArchivo(String archivo) {
|
||||
String data = null;
|
||||
byte[] result = null;
|
||||
try {
|
||||
File f = new File(archivo);
|
||||
if (f.exists()) {
|
||||
result = FileUtils.readFileToByteArray(f);
|
||||
data = Base64.encodeBase64String(result);
|
||||
} else {
|
||||
result = ("No existe el archivo " + archivo).getBytes();
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
result = ex.toString().getBytes();
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param urlArchivo
|
||||
* @return
|
||||
*/
|
||||
public static String getNombreArchivo(String urlArchivo) {
|
||||
String name = urlArchivo;
|
||||
File f = new File(urlArchivo);
|
||||
if (f.exists()) {
|
||||
name = f.getName();
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param entidad
|
||||
* @param maxRegistros
|
||||
* @return
|
||||
*/
|
||||
public DaoGenerico generarDao(EntidadEnum entidad, Integer maxRegistros) {
|
||||
DaoGenerico dao = null;
|
||||
if (entidad != null) {
|
||||
if (maxRegistros != null && maxRegistros > 0) {
|
||||
dao = new DaoGenerico(entidad.getEntidad(), maxRegistros);
|
||||
} else {
|
||||
dao = new DaoGenerico(entidad.getEntidad());
|
||||
}
|
||||
}
|
||||
return dao;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param tipo
|
||||
* @param datos
|
||||
* @return
|
||||
*/
|
||||
public Serializable crearObjeto(Class tipo, Map<String, Object> datos) {
|
||||
Object obj = null;
|
||||
try {
|
||||
obj = tipo.getConstructor().newInstance();
|
||||
} catch (Exception ex) {
|
||||
System.out.println("Error obteniendo contructor " + ex);
|
||||
}
|
||||
for (Map.Entry<String, Object> e : datos.entrySet()) {
|
||||
Field f = null;
|
||||
try {
|
||||
f = obj.getClass().getDeclaredField(e.getKey());
|
||||
} catch (NoSuchFieldException | SecurityException ex) {
|
||||
System.out.println("Error obteniendo variable " + ex);
|
||||
}
|
||||
if (f != null) {
|
||||
try {
|
||||
f.setAccessible(true);
|
||||
if (Date.class.isAssignableFrom(f.getType()) && e.getValue() != null) {
|
||||
if (e.getValue().toString().length() > 10) {
|
||||
f.set(obj, DominioConstantes.getDateTime("" + e.getValue()));
|
||||
} else {
|
||||
f.set(obj, DominioConstantes.getDate("" + e.getValue()));
|
||||
}
|
||||
} else if (List.class.isAssignableFrom(f.getType())) {
|
||||
//TODO: Aqui a futuro evaluar listas si no se contempla falla
|
||||
} else if (!String.class.isAssignableFrom(f.getType()) && e.getValue() != null) {
|
||||
f.set(obj, QParser.parse(e.getValue().toString(), f.getType()));
|
||||
} else {
|
||||
f.set(obj, e.getValue());
|
||||
}
|
||||
} catch (SecurityException | IllegalAccessException | IllegalArgumentException ex) {
|
||||
System.out.println("Error Parsning crear objeto " + ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
return (Serializable) obj;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param mapper
|
||||
* @param entidad
|
||||
* @return
|
||||
*/
|
||||
public Object getDto(Class mapper, Object entidad) {
|
||||
Object result = ejecutaMetodo(mapper, entidad, METODO_DTO);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param mapper
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
public Object getEntidad(Class mapper, Object dto) {
|
||||
Object result = ejecutaMetodo(mapper, dto, METODO_ENTIDAD);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param mapper
|
||||
* @param entidad
|
||||
* @param nombreMetodo
|
||||
* @return
|
||||
*/
|
||||
public Object ejecutaMetodo(Class mapper, Object entidad, String nombreMetodo) {
|
||||
Object o = Mappers.getMapper(mapper);
|
||||
Method metodo = null;
|
||||
for (Method m : mapper.getMethods()) {
|
||||
if (m.getName().equals(nombreMetodo)) {
|
||||
metodo = m;
|
||||
break;
|
||||
}
|
||||
}
|
||||
Object result = null;
|
||||
if (metodo != null) {
|
||||
try {
|
||||
result = metodo.invoke(o, entidad);
|
||||
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) {
|
||||
ex.printStackTrace(System.out);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,248 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.qsoft.erp.dominio.util;
|
||||
|
||||
import com.qsoft.dao.exception.DaoException;
|
||||
import com.qsoft.dao.util.Fila;
|
||||
import com.qsoft.erp.constantes.DetalleCatalogoEnum;
|
||||
import com.qsoft.erp.constantes.QueryEnum;
|
||||
import com.qsoft.erp.dao.DaoGenerico;
|
||||
import com.qsoft.erp.dominio.transaccion.AuxLiquidacion;
|
||||
import com.qsoft.erp.dominio.transaccion.LiquidacionSum;
|
||||
import com.qsoft.erp.dto.ValoresLiquidacion;
|
||||
import com.qsoft.erp.model.CoberturasPlan;
|
||||
import com.qsoft.erp.model.DetalleCatalogo;
|
||||
import com.qsoft.erp.model.DetalleLiquidacion;
|
||||
import com.qsoft.erp.model.EstadoLiquidacion;
|
||||
import com.qsoft.erp.model.Liquidacion;
|
||||
import com.qsoft.erp.model.Persona;
|
||||
import com.qsoft.erp.model.PersonaPoliza;
|
||||
import com.qsoft.erp.model.Plan;
|
||||
import com.qsoft.erp.model.Poliza;
|
||||
import com.qsoft.erp.model.TarifaLiquidacion;
|
||||
import com.qsoft.erp.model.Tarifario;
|
||||
import com.qsoft.erp.reportes.UtilitarioReporte;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import javax.ejb.Stateless;
|
||||
import javax.transaction.Transactional;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author james
|
||||
*/
|
||||
@Stateless
|
||||
public class LiquidacionCalc {
|
||||
|
||||
private final static String LIMITE_CUPO = "Ha alcanzado el limite de cobertura para el asegurado";
|
||||
|
||||
/**
|
||||
*
|
||||
* @param liquidacion
|
||||
* @param proveedor
|
||||
* @return
|
||||
*/
|
||||
@Transactional(Transactional.TxType.REQUIRES_NEW)
|
||||
public Liquidacion procesarLiquidacion(Liquidacion liquidacion, boolean proveedor) {
|
||||
LiquidacionSum liqSum = this.cargarValores(liquidacion);
|
||||
try {
|
||||
liqSum = this.cargarRelaciones(liqSum);
|
||||
if (proveedor) {
|
||||
this.setObjetados(liqSum);
|
||||
}
|
||||
Double maximo = liqSum.getPlan().getPlaCoberturaMaxima() - liqSum.getPagoCubierto(liqSum.getBeneficiario());
|
||||
List<ValoresLiquidacion> deducibles = new ArrayList<>(liqSum.getDeducibles().values());
|
||||
Map<CoberturasPlan, ValoresLiquidacion> copagos = liqSum.getCopagos();
|
||||
System.out.println("============================= PROCESAR LIQUIDACION == " + copagos.size() + " => " + deducibles.size());
|
||||
if (maximo <= 0) {
|
||||
for (AuxLiquidacion aux : liqSum.getData()) {
|
||||
aux.getTalCodigo().setTarObservacion(LIMITE_CUPO);
|
||||
aux.getTalCodigo().setTalValorPagado(0.0);
|
||||
aux.getTalCodigo().setTalValorDeducible(0.0);
|
||||
aux.getTalCodigo().setTalValorCopago(0.0);
|
||||
}
|
||||
} else {
|
||||
liqSum.procesarPorCobertura(copagos, deducibles.isEmpty() ? null : deducibles.get(0), maximo);
|
||||
}
|
||||
Persona titular = new Persona();
|
||||
PersonaPoliza benf = null;
|
||||
for (PersonaPoliza p : liqSum.getLiquidacion().getPolCodigo().getPersonaPolizaCollection()) {
|
||||
if (p.getPerCodigo().getPerCodigo().equals(liqSum.getBeneficiario().getPerCodigo())) {
|
||||
benf = p;
|
||||
}
|
||||
if (p.getDetTipoPersona().getDetNemonico().equals(DetalleCatalogoEnum.PTITU.name())) {
|
||||
titular = p.getPerCodigo();
|
||||
}
|
||||
}
|
||||
System.out.println("*********************** FIN PROCESAR CALCULOS ***********************");
|
||||
this.registraBdd(liqSum);
|
||||
UtilitarioReporte repor = new UtilitarioReporte();
|
||||
benf.getPerCodigo();
|
||||
String reporte = repor.generarLiquidacion(liqSum.getLiquidacion().getPolCodigo(), liqSum.getLiquidacion(), liqSum.getDetalles(), titular, benf);
|
||||
liqSum.getLiquidacion().setLiqReporte(reporte);
|
||||
DaoGenerico<Liquidacion, Integer> daoliq = new DaoGenerico<>(Liquidacion.class);
|
||||
daoliq.actualizar(liqSum.getLiquidacion());
|
||||
System.out.println("============================= OK PROCESADA LIQUIDACION =============================");
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace(System.err);
|
||||
System.out.println("Error procesando " + ex);
|
||||
}
|
||||
return liqSum.getLiquidacion();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param liqSum
|
||||
*/
|
||||
private void setObjetados(LiquidacionSum liqSum) {
|
||||
for (AuxLiquidacion aux : liqSum.getData()) {
|
||||
aux.getTalCodigo().setTalValorObjetado(aux.getTalCodigo().getTalValorRegistrado());
|
||||
aux.getDelCodigo().setDelValorObjetado(aux.getDelCodigo().getDelValorRegistrado());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Permite cargar los valores de liquidacion
|
||||
*
|
||||
* @param liquidacion
|
||||
*/
|
||||
@Transactional(Transactional.TxType.REQUIRES_NEW)
|
||||
private LiquidacionSum cargarValores(Liquidacion liquidacion) {
|
||||
if (liquidacion == null || liquidacion.getPolCodigo() == null) {
|
||||
throw new IllegalArgumentException("ERROR, Se requiere el numero de poliza para procesar la liquidacion");
|
||||
}
|
||||
LiquidacionSum valor = new LiquidacionSum(liquidacion);
|
||||
|
||||
String query = String.format(QueryEnum.LIQPOL.getQuery(), liquidacion.getLiqCodigo());
|
||||
String historico = String.format(QueryEnum.LIQTOT.getQuery(),
|
||||
liquidacion.getPolCodigo().getPolCodigo(), liquidacion.getPerBeneficiario().getPerCodigo());
|
||||
DaoGenerico<Poliza, Integer> dao = new DaoGenerico<>(Poliza.class);
|
||||
for (Fila f : dao.ejecutarConsultaNativaList(query)) {
|
||||
AuxLiquidacion auxiliar = new AuxLiquidacion();
|
||||
auxiliar.setDetCie10(new DetalleCatalogo(f.getEntero(0)));
|
||||
auxiliar.setDetPrestacion(new DetalleCatalogo(f.getEntero(1)));
|
||||
auxiliar.setPlaCodigo(new Plan(f.getEntero(2)));
|
||||
auxiliar.setLiqCodigo(new Liquidacion(f.getEntero(3)));
|
||||
auxiliar.setPerBeneficiario(new Persona(f.getEntero(4)));
|
||||
auxiliar.setEslCodigo(new EstadoLiquidacion(f.getEntero(5)));
|
||||
auxiliar.setDelCodigo(new DetalleLiquidacion(f.getEntero(6)));
|
||||
auxiliar.setTalCodigo(new TarifaLiquidacion(f.getEntero(7)));
|
||||
auxiliar.setTarCodigo(new Tarifario(f.getEntero(8)));
|
||||
auxiliar.setCopCodigo(new CoberturasPlan(f.getEntero(9)));
|
||||
valor.getData().add(auxiliar);
|
||||
}
|
||||
for (Fila f : dao.ejecutarConsultaNativaList(historico)) {
|
||||
AuxLiquidacion auxiliar = new AuxLiquidacion();
|
||||
auxiliar.setDetCie10(new DetalleCatalogo(f.getEntero(0)));
|
||||
auxiliar.setDetPrestacion(new DetalleCatalogo(f.getEntero(1)));
|
||||
auxiliar.setPlaCodigo(new Plan(f.getEntero(2)));
|
||||
auxiliar.setLiqCodigo(new Liquidacion(f.getEntero(3)));
|
||||
auxiliar.setPerBeneficiario(new Persona(f.getEntero(4)));
|
||||
auxiliar.setEslCodigo(new EstadoLiquidacion(f.getEntero(5)));
|
||||
auxiliar.setDelCodigo(new DetalleLiquidacion(f.getEntero(6)));
|
||||
auxiliar.setTalCodigo(new TarifaLiquidacion(f.getEntero(7)));
|
||||
auxiliar.setTarCodigo(new Tarifario(f.getEntero(8)));
|
||||
auxiliar.setCopCodigo(new CoberturasPlan(f.getEntero(9)));
|
||||
valor.getHisto().add(auxiliar);
|
||||
}
|
||||
return valor;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param liqSum
|
||||
*/
|
||||
private void registraBdd(LiquidacionSum liqSum) {
|
||||
liqSum.mayorizar();
|
||||
for (AuxLiquidacion aux : liqSum.getData()) {
|
||||
aux.guardaTarifa();
|
||||
}
|
||||
for (DetalleLiquidacion del : liqSum.getDetalles()) {
|
||||
try {
|
||||
DaoGenerico<DetalleLiquidacion, Integer> daoDl = new DaoGenerico<>(DetalleLiquidacion.class);
|
||||
daoDl.actualizar(del);
|
||||
del.getCopCodigo().getDetTipo();
|
||||
} catch (DaoException ex) {
|
||||
System.out.println("No se puede actualizar Tarifa " + ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Transactional(Transactional.TxType.REQUIRES_NEW)
|
||||
private LiquidacionSum cargarRelaciones(LiquidacionSum liqSum) {
|
||||
DaoGenerico<Plan, Integer> daoPla = new DaoGenerico<>(Plan.class);
|
||||
DaoGenerico<DetalleCatalogo, Integer> daoDc = new DaoGenerico<>(DetalleCatalogo.class);
|
||||
DaoGenerico<Persona, Integer> daoPer = new DaoGenerico<>(Persona.class);
|
||||
DaoGenerico<DetalleLiquidacion, Integer> daoDl = new DaoGenerico<>(DetalleLiquidacion.class);
|
||||
DaoGenerico<CoberturasPlan, Integer> daoCp = new DaoGenerico<>(CoberturasPlan.class);
|
||||
DaoGenerico<TarifaLiquidacion, Integer> daoTl = new DaoGenerico<>(TarifaLiquidacion.class);
|
||||
try {
|
||||
Plan plan = null;
|
||||
DetalleCatalogo cie10 = null;
|
||||
Persona beneficiario = null;
|
||||
Map<Integer, DetalleLiquidacion> detalles = new HashMap<>();
|
||||
Map<Integer, CoberturasPlan> coberturas = new HashMap<>();
|
||||
System.out.println(">>>>>>>>>> Cargar relaciones " + liqSum.getData().size());
|
||||
for (AuxLiquidacion aux : liqSum.getData()) {
|
||||
if (plan == null) {
|
||||
plan = daoPla.cargar(aux.getPlaCodigo().getPlaCodigo());
|
||||
}
|
||||
if (cie10 == null) {
|
||||
cie10 = daoDc.cargar(aux.getDetCie10().getDetCodigo());
|
||||
}
|
||||
if (beneficiario == null) {
|
||||
beneficiario = daoPer.cargar(aux.getPerBeneficiario().getPerCodigo());
|
||||
}
|
||||
if (!detalles.containsKey(aux.getDelCodigo().getDelCodigo())) {
|
||||
detalles.put(aux.getDelCodigo().getDelCodigo(), daoDl.cargar(aux.getDelCodigo().getDelCodigo()));
|
||||
}
|
||||
if (!coberturas.containsKey(aux.getCopCodigo().getCopCodigo())) {
|
||||
coberturas.put(aux.getCopCodigo().getCopCodigo(), daoCp.cargar(aux.getCopCodigo().getCopCodigo()));
|
||||
}
|
||||
if (aux.getTalCodigo() != null && aux.getTalCodigo().getTalCodigo() != null) {
|
||||
aux.setTalCodigo(daoTl.cargar(aux.getTalCodigo().getTalCodigo()));
|
||||
}
|
||||
aux.setDelCodigo(detalles.get(aux.getDelCodigo().getDelCodigo()));
|
||||
aux.setCopCodigo(coberturas.get(aux.getCopCodigo().getCopCodigo()));
|
||||
aux.setPlaCodigo(plan);
|
||||
aux.setPerBeneficiario(beneficiario);
|
||||
aux.setDetCie10(cie10);
|
||||
}
|
||||
} catch (DaoException ex) {
|
||||
System.out.println("Error cargando datos " + ex);
|
||||
}
|
||||
try {
|
||||
Plan plan = null;
|
||||
|
||||
Map<Integer, DetalleLiquidacion> detalles = new HashMap<>();
|
||||
Map<Integer, CoberturasPlan> coberturas = new HashMap<>();
|
||||
System.out.println(">>>>>>>>>> Cargar histo " + liqSum.getHisto().size());
|
||||
for (AuxLiquidacion aux : liqSum.getHisto()) {
|
||||
if (plan == null) {
|
||||
plan = daoPla.cargar(aux.getPlaCodigo().getPlaCodigo());
|
||||
}
|
||||
if (!detalles.containsKey(aux.getDelCodigo().getDelCodigo())) {
|
||||
detalles.put(aux.getDelCodigo().getDelCodigo(), daoDl.cargar(aux.getDelCodigo().getDelCodigo()));
|
||||
}
|
||||
if (!coberturas.containsKey(aux.getCopCodigo().getCopCodigo())) {
|
||||
coberturas.put(aux.getCopCodigo().getCopCodigo(), daoCp.cargar(aux.getCopCodigo().getCopCodigo()));
|
||||
}
|
||||
aux.setTalCodigo(daoTl.cargar(aux.getTalCodigo().getTalCodigo()));
|
||||
aux.setDelCodigo(detalles.get(aux.getDelCodigo().getDelCodigo()));
|
||||
aux.setPlaCodigo(plan);
|
||||
}
|
||||
} catch (DaoException ex) {
|
||||
System.out.println("Error cargando datos " + ex);
|
||||
}
|
||||
return liqSum;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,450 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.qsoft.erp.dominio.util;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonParser;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.qsoft.dao.exception.DaoException;
|
||||
import com.qsoft.util.constantes.CodigoRespuesta;
|
||||
import com.qsoft.util.constantes.ErrorTipo;
|
||||
import com.qsoft.util.ms.pojo.HeaderMS;
|
||||
import com.qsoft.erp.constantes.DetalleCatalogoEnum;
|
||||
import com.qsoft.erp.constantes.DominioConstantes;
|
||||
import com.qsoft.erp.constantes.EntidadEnum;
|
||||
import com.qsoft.erp.constantes.EstadoLiquidacionEnum;
|
||||
import com.qsoft.erp.dao.DaoGenerico;
|
||||
import com.qsoft.erp.dto.DetalleLiquidacionDTO;
|
||||
import com.qsoft.erp.dto.DocumentoDTO;
|
||||
import com.qsoft.erp.dto.EstadoLiquidacionDTO;
|
||||
import com.qsoft.erp.dto.LiquidacionDTO;
|
||||
import com.qsoft.erp.model.DetalleCatalogo;
|
||||
import com.qsoft.erp.model.DetalleLiquidacion;
|
||||
import com.qsoft.erp.model.Documento;
|
||||
import com.qsoft.erp.model.EstadoLiquidacion;
|
||||
import com.qsoft.erp.model.Liquidacion;
|
||||
import com.qsoft.erp.model.Usuario;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.ejb.EJB;
|
||||
import javax.ejb.Stateless;
|
||||
import static com.qsoft.erp.dominio.AccionGenerica.ACTUALIZA;
|
||||
import static com.qsoft.erp.dominio.AccionGenerica.CONSULTA;
|
||||
import static com.qsoft.erp.dominio.AccionGenerica.ELIMINA;
|
||||
import static com.qsoft.erp.dominio.AccionGenerica.GUARDA;
|
||||
import static com.qsoft.erp.dominio.AccionGenerica.ACTUALIZA_ONSITE;
|
||||
import static com.qsoft.erp.dominio.AccionGenerica.CANCELA;
|
||||
import com.qsoft.erp.dominio.exception.DominioExcepcion;
|
||||
import com.qsoft.erp.dominio.mapper.DetalleLiquidacionMapper;
|
||||
import com.qsoft.erp.constantes.SecuenciaEnum;
|
||||
import com.qsoft.erp.dto.TarifaLiquidacionDTO;
|
||||
import com.qsoft.erp.model.Poliza;
|
||||
import com.qsoft.erp.model.TarifaLiquidacion;
|
||||
import java.util.HashMap;
|
||||
import java.util.Objects;
|
||||
import javax.transaction.Transactional;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author james
|
||||
*/
|
||||
@Stateless
|
||||
public class LiquidacionUtil {
|
||||
|
||||
@EJB
|
||||
private DominioUtil dominioUtil;
|
||||
|
||||
@EJB
|
||||
private LiquidacionCalc liquidacionCalcs;
|
||||
|
||||
@EJB
|
||||
private NotificadorUtil notificadorUtil;
|
||||
|
||||
@EJB
|
||||
private SecuenciaUtil secuenciaUtil;
|
||||
|
||||
@EJB
|
||||
private CatalogoUtil catalogoUtil;
|
||||
|
||||
@PostConstruct
|
||||
public void postConstruct() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param header
|
||||
* @param datos
|
||||
* @return
|
||||
* @throws DominioExcepcion
|
||||
*/
|
||||
@Transactional(Transactional.TxType.REQUIRES_NEW)
|
||||
public List<Liquidacion> guardarLiquidacion(HeaderMS header, Map<String, LiquidacionDTO> datos) throws DominioExcepcion {
|
||||
List<Liquidacion> data = new ArrayList<>();
|
||||
DaoGenerico<Liquidacion, Integer> daoliq = new DaoGenerico<>(Liquidacion.class);
|
||||
DaoGenerico<Usuario, Integer> daousu = new DaoGenerico<>(Usuario.class);
|
||||
DaoGenerico<Poliza, Integer> daopol = new DaoGenerico<>(Poliza.class);
|
||||
for (Map.Entry<String, LiquidacionDTO> entry : datos.entrySet()) {
|
||||
try {
|
||||
Liquidacion liq;
|
||||
System.out.println("==============> GUARDAR LIQUIDACION.....");
|
||||
liq = (Liquidacion) this.dominioUtil.getEntidad(EntidadEnum.Liquidacion.getMapper(), entry.getValue());
|
||||
long cod = this.secuenciaUtil.getSecuencia(SecuenciaEnum.LIQMED);
|
||||
liq.setLiqNemonico(this.dominioUtil.getCodLiquidacion(cod));
|
||||
Poliza pol = daopol.cargar(entry.getValue().getPolCodigo());
|
||||
liq.setPolCodigo(pol);
|
||||
liq.setLiqFechaRegistro(new Date());
|
||||
liq.setDocumentoCollection(this.crearDocumentos(liq, entry.getValue()));
|
||||
liq.setEstadoLiquidacionCollection(new ArrayList<>());
|
||||
Usuario usuario = EstadoLiquidacionEnum.ESTLI.getUsuarioGenerico();
|
||||
liq.getEstadoLiquidacionCollection().add(this.crearEstadoInicial(liq, usuario));
|
||||
daoliq.guardar(liq);
|
||||
Usuario user = new Usuario();
|
||||
user.setUsuUsuario(header.getUsuario());
|
||||
user.setUsuEstado(DominioConstantes.ACTIVO);
|
||||
user = daousu.buscarUnico(user);
|
||||
this.notificadorUtil.notificarLiquidacion(user, liq);
|
||||
data.add(liq);
|
||||
} catch (DaoException ex) {
|
||||
throw new DominioExcepcion(ErrorTipo.FATAL, CodigoRespuesta.CODIGO_VALOR_NULO,
|
||||
"Error registrando liquidacion en BDD " + ex);
|
||||
}
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param header
|
||||
* @param datos
|
||||
* @param tipoAccion
|
||||
* @return
|
||||
* @throws DominioExcepcion
|
||||
*/
|
||||
@Transactional(Transactional.TxType.REQUIRES_NEW)
|
||||
public List<Liquidacion> actualizarLiquidacion(HeaderMS header, Map<String, LiquidacionDTO> datos, int tipoAccion) throws DominioExcepcion {
|
||||
List<Liquidacion> data = new ArrayList<>();
|
||||
DaoGenerico<Liquidacion, Integer> daoliq = new DaoGenerico<>(Liquidacion.class);
|
||||
for (Map.Entry<String, LiquidacionDTO> entry : datos.entrySet()) {
|
||||
LiquidacionDTO liquidacion = entry.getValue();
|
||||
Liquidacion liq = null;
|
||||
//TODO: aqui puede ser consulta por CONTRATO
|
||||
liq = daoliq.buscar(liquidacion.getLiqCodigo());
|
||||
if (liq != null) {
|
||||
try {
|
||||
boolean saltoFlujo = false;
|
||||
EstadoLiquidacion estado = null;
|
||||
liq.getDocumentoCollection().addAll(this.crearDocumentos(liq, liquidacion));
|
||||
if (tipoAccion != ACTUALIZA_ONSITE) {
|
||||
EstadoLiquidacion previo = null;
|
||||
for (EstadoLiquidacion es : liq.getEstadoLiquidacionCollection()) {
|
||||
if (Objects.equals(DominioConstantes.ACTIVO, es.getEslEstado())) {
|
||||
es.setEslEstado(DominioConstantes.INACTIVO);
|
||||
es.setEslFechaFin(new Date());
|
||||
previo = es;
|
||||
}
|
||||
}
|
||||
if (liquidacion.getEstados() != null && !liquidacion.getEstados().isEmpty()) {
|
||||
System.out.println("=====> ATENCION? " + liq.getDetAtencion() + " => " + liquidacion.getDetAtencion());
|
||||
Integer codAt = liq.getDetAtencion() != null && liq.getDetAtencion().getDetCodigo() != null
|
||||
? liq.getDetAtencion().getDetCodigo() : liquidacion.getDetAtencion();
|
||||
DetalleCatalogo atencion = this.catalogoUtil.cargar(codAt);
|
||||
|
||||
saltoFlujo = atencion != null && atencion.getDetNemonico().equals(DetalleCatalogoEnum.ATHE.name())
|
||||
|| atencion != null && atencion.getDetNemonico().equals(DetalleCatalogoEnum.ATAH.name())
|
||||
|| atencion != null && atencion.getDetNemonico().equals(DetalleCatalogoEnum.ATHOS.name());
|
||||
for (EstadoLiquidacionDTO es : liquidacion.getEstados()) {
|
||||
estado = this.crearEstado(liq, es, previo, saltoFlujo, tipoAccion);
|
||||
liq.getEstadoLiquidacionCollection().add(estado);
|
||||
}
|
||||
}
|
||||
}
|
||||
daoliq.actualizar(liq);
|
||||
if (estado != null && estado.getDetEstado().getDetNemonico().equalsIgnoreCase(EstadoLiquidacionEnum.ESTLIC.name())
|
||||
&& liq.getDetTipo().getDetNemonico().equalsIgnoreCase(DetalleCatalogoEnum.TIPLQPR.name()) && !saltoFlujo && tipoAccion == GUARDA) {
|
||||
System.out.println("PROCESAR LIQUIDACION PRESTADOR ESTLIC");
|
||||
liq = this.liquidacionCalcs.procesarLiquidacion(liq, true);
|
||||
}
|
||||
if (estado != null && estado.getDetEstado().getDetNemonico().equalsIgnoreCase(EstadoLiquidacionEnum.ESTLQC.name())
|
||||
&& liq.getDetTipo().getDetNemonico().equalsIgnoreCase(DetalleCatalogoEnum.TIPLQPR.name()) && saltoFlujo && tipoAccion == GUARDA) {
|
||||
System.out.println("PROCESAR LIQUIDACION PRESTADOR ESTLQC");
|
||||
liq = this.liquidacionCalcs.procesarLiquidacion(liq, false);
|
||||
}
|
||||
if (estado != null && estado.getDetEstado().getDetNemonico().equalsIgnoreCase(EstadoLiquidacionEnum.ESTLQC.name())
|
||||
&& !liq.getDetTipo().getDetNemonico().equalsIgnoreCase(DetalleCatalogoEnum.TIPLQPR.name()) && tipoAccion == GUARDA) {
|
||||
System.out.println("PROCESAR LIQUIDACION NO PRESTADOR ESTLQC");
|
||||
liq = this.liquidacionCalcs.procesarLiquidacion(liq, false);
|
||||
}
|
||||
|
||||
Usuario user = this.dominioUtil.getTitularLiquidacion(liq.getLiqCodigo());
|
||||
if (tipoAccion != ACTUALIZA_ONSITE && estado != null) {
|
||||
this.notificadorUtil.notificarEstadoLiquidacion(liq, user, estado);
|
||||
}
|
||||
data.add(liq);
|
||||
} catch (DaoException ex) {
|
||||
throw new DominioExcepcion(ErrorTipo.FATAL, CodigoRespuesta.CODIGO_ERROR_GUARDA_BDD, "ERROR, " + ex);
|
||||
}
|
||||
} else {
|
||||
throw new DominioExcepcion(ErrorTipo.ERROR, CodigoRespuesta.CODIGO_VALOR_NULO, "ERROR, No existe la liquidacion con el codigo " + liquidacion.getLiqCodigo());
|
||||
}
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param header
|
||||
* @param entidades
|
||||
* @param tipoAccion
|
||||
* @return
|
||||
* @throws com.qsoft.erp.dominio.exception.DominioExcepcion
|
||||
*/
|
||||
@Transactional(Transactional.TxType.REQUIRES_NEW)
|
||||
public List<DetalleLiquidacion> procesarDetalleLiquidacion(HeaderMS header, List<Map<String, Object>> entidades, int tipoAccion) throws DominioExcepcion {
|
||||
List<DetalleLiquidacion> data = new ArrayList<>();
|
||||
for (Map<String, Object> ent : entidades) {
|
||||
DetalleLiquidacionDTO detalle = (DetalleLiquidacionDTO) dominioUtil.crearObjeto(DetalleLiquidacionDTO.class, ent);
|
||||
List<TarifaLiquidacionDTO> lista = new ArrayList<>();
|
||||
ObjectMapper maper = new ObjectMapper();
|
||||
maper.configure(JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES, true);
|
||||
if (ent.containsKey("detalle")) {
|
||||
for (Object row : (List<Object>) ent.get("detalle")) {
|
||||
TarifaLiquidacionDTO col = (TarifaLiquidacionDTO) dominioUtil.crearObjeto(TarifaLiquidacionDTO.class, (Map<String, Object>) row);
|
||||
lista.add(col);
|
||||
}
|
||||
}
|
||||
detalle.setDetalle(lista);
|
||||
DetalleLiquidacion result = crudDetalle(detalle, tipoAccion);
|
||||
data.add(result);
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param detalle
|
||||
* @param tipoAccion
|
||||
* @return
|
||||
* @throws DominioExcepcion
|
||||
*/
|
||||
@Transactional(Transactional.TxType.REQUIRES_NEW)
|
||||
private DetalleLiquidacion crudDetalle(DetalleLiquidacionDTO detalle, int tipoAccion) throws DominioExcepcion {
|
||||
DaoGenerico<DetalleLiquidacion, Integer> daodel = new DaoGenerico<>(DetalleLiquidacion.class);
|
||||
DetalleLiquidacion result;
|
||||
result = DetalleLiquidacionMapper.INSTANCE.getEntidad(detalle);
|
||||
result.setTarifaLiquidacionCollection(this.crearTarifas(detalle, result));
|
||||
switch (tipoAccion) {
|
||||
case CONSULTA: {
|
||||
throw new DominioExcepcion(ErrorTipo.ERROR, CodigoRespuesta.CODIGO_ERROR_GENERICO,
|
||||
"Operacion CONSULTA no soportada para el controlador de Accion");
|
||||
}
|
||||
case GUARDA: {
|
||||
try {
|
||||
daodel.guardar(result);
|
||||
} catch (DaoException ex) {
|
||||
throw new DominioExcepcion(ErrorTipo.FATAL, CodigoRespuesta.CODIGO_ERROR_GUARDA_BDD, ex.toString());
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ACTUALIZA: {
|
||||
try {
|
||||
DaoGenerico<TarifaLiquidacion, Integer> daotar = new DaoGenerico<>(TarifaLiquidacion.class);
|
||||
for (TarifaLiquidacion tar : result.getTarifaLiquidacionCollection()) {
|
||||
daotar.actualizar(tar);
|
||||
}
|
||||
result = daodel.actualizar(result);
|
||||
} catch (DaoException ex) {
|
||||
throw new DominioExcepcion(ErrorTipo.FATAL, CodigoRespuesta.CODIGO_ERROR_ACTUALIZA_BDD, ex.toString());
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ELIMINA: {
|
||||
throw new DominioExcepcion(ErrorTipo.ERROR, CodigoRespuesta.CODIGO_ERROR_GENERICO,
|
||||
"Operacion ELIMINACION aun no permitida, debe eliminar la Liquidacion");
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private EstadoLiquidacion crearEstadoInicial(Liquidacion liquidacion, Usuario usuario) throws DaoException {
|
||||
EstadoLiquidacion est = new EstadoLiquidacion();
|
||||
est.setDetEstado(EstadoLiquidacionEnum.ESTLI.getDetalle());
|
||||
est.setEslEstado(DominioConstantes.ACTIVO);
|
||||
est.setEslFechaInicio(new Date());
|
||||
est.setEslMensaje(DominioConstantes.MENSAJE_AUTO);
|
||||
est.setLiqCodigo(liquidacion);
|
||||
est.setUsuCodigo(usuario);
|
||||
return est;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param liquida
|
||||
* @param liquidacion
|
||||
* @throws DaoException
|
||||
*/
|
||||
private EstadoLiquidacion crearEstado(Liquidacion liquida, EstadoLiquidacionDTO estadoDto,
|
||||
EstadoLiquidacion previo, boolean saltoFlujo, int tipoAccion) throws DaoException {
|
||||
EstadoLiquidacion estado = new EstadoLiquidacion();
|
||||
DetalleCatalogo est = new DetalleCatalogo();
|
||||
|
||||
if (tipoAccion == GUARDA) { //TODO: Avanza estado
|
||||
if (liquida.getDetTipo().getDetNemonico().equalsIgnoreCase(DetalleCatalogoEnum.TIPLQPR.name())
|
||||
&& previo.getDetEstado().getDetNemonico().equals(EstadoLiquidacionEnum.ESTLI.name()) && !saltoFlujo) {
|
||||
est = EstadoLiquidacionEnum.ESTLIC.getDetalle();
|
||||
} else {
|
||||
est = EstadoLiquidacionEnum.getSiguiente(previo.getDetEstado().getDetCodigo(), true);
|
||||
}
|
||||
} else if (tipoAccion == ACTUALIZA) {//TODO: Retroceder estado, siempre retrocede al usuario previo
|
||||
if (liquida.getDetTipo().getDetNemonico().equalsIgnoreCase(DetalleCatalogoEnum.TIPLQPR.name())
|
||||
&& previo.getDetEstado().getDetNemonico().equals(EstadoLiquidacionEnum.ESTLIC.name()) && !saltoFlujo) {
|
||||
est = EstadoLiquidacionEnum.ESTLI.getDetalle();
|
||||
} else {
|
||||
est = EstadoLiquidacionEnum.getSiguiente(previo.getDetEstado().getDetCodigo(), false);
|
||||
}
|
||||
if (est != null && est.getDetNemonico().equalsIgnoreCase(EstadoLiquidacionEnum.ESTALI.name())) {
|
||||
estado.setUsuCodigo(this.dominioUtil.getTitularLiquidacion(liquida.getLiqCodigo()));
|
||||
}
|
||||
} else if (tipoAccion == CANCELA) {
|
||||
est = EstadoLiquidacionEnum.ESTCAN.getDetalle();
|
||||
estado.setUsuCodigo(previo.getUsuCodigo());
|
||||
} else {
|
||||
throw new DaoException("Especificar si desea avanzar o retroceder de estado");
|
||||
}
|
||||
for (EstadoLiquidacion esli : liquida.getEstadoLiquidacionCollection()) {
|
||||
if (esli.getDetEstado().getDetNemonico().equals(est.getDetNemonico())) {
|
||||
estado.setUsuCodigo(esli.getUsuCodigo());
|
||||
}
|
||||
}
|
||||
if (estado.getUsuCodigo() == null || estado.getUsuCodigo().getUsuCodigo() == null) {
|
||||
EstadoLiquidacionEnum enu = EstadoLiquidacionEnum.valueOf(est.getDetNemonico());
|
||||
System.out.println("No hay usuario, vamos a obtener el generico " + enu);
|
||||
estado.setUsuCodigo(enu.getUsuarioGenerico());
|
||||
}
|
||||
estado.setDetEstado(est);
|
||||
estado.setEslFechaInicio(new Date());
|
||||
estado.setEslEstado(DominioConstantes.ACTIVO);
|
||||
estado.setEslMensaje(estadoDto.getEslMensaje());
|
||||
estado.setLiqCodigo(liquida);
|
||||
return estado;
|
||||
}
|
||||
|
||||
public HashMap<String,String> obtenerTodosDocumentosLiquidacion(Integer liqCodigo) throws DaoException, DominioExcepcion{
|
||||
DaoGenerico<Liquidacion,Integer> daoliq = new DaoGenerico<>(Liquidacion.class);
|
||||
DaoGenerico<Documento,Integer> daodoc = new DaoGenerico<>(Documento.class);
|
||||
HashMap<String,String> result = new HashMap<>();
|
||||
Liquidacion liquidacion = daoliq.buscarUnico(new Liquidacion(liqCodigo));
|
||||
//List<String> result = new ArrayList<>();
|
||||
if(liquidacion == null){
|
||||
throw new DominioExcepcion(ErrorTipo.ERROR, CodigoRespuesta.CODIGO_ERROR_CONSULTA_BDD,
|
||||
"No se encontro la liquidacion para el codigo enviado");
|
||||
}
|
||||
Documento documentoPlantilla = new Documento();
|
||||
documentoPlantilla.setDocEstado(DominioConstantes.ACTIVO);
|
||||
documentoPlantilla.setLiqCodigo(liquidacion);
|
||||
List<Documento> lstDocumentos = daodoc.buscarLista(documentoPlantilla);
|
||||
if(lstDocumentos == null || lstDocumentos.isEmpty()){
|
||||
throw new DominioExcepcion(ErrorTipo.ERROR, CodigoRespuesta.CODIGO_ERROR_CONSULTA_BDD,
|
||||
String.format("No se ha encontrado documentos para la liquidacion %s", liquidacion.getLiqNemonico()));
|
||||
}
|
||||
|
||||
File archivoZip = procesarZipLiquidacion(liquidacion, lstDocumentos);
|
||||
result.put("nombre",archivoZip.getName());
|
||||
result.put("documento",dominioUtil.getArchivo(archivoZip.getAbsolutePath()));
|
||||
|
||||
archivoZip.delete();
|
||||
return result;
|
||||
}
|
||||
|
||||
private File procesarZipLiquidacion(Liquidacion liquidacion, List<Documento> lstDocumentos){
|
||||
String url = DetalleCatalogoEnum.URLLIQ.getDetalle().getDetOrigen();
|
||||
Documento primero = lstDocumentos.get(0);
|
||||
String nemonico = liquidacion.getLiqNemonico();
|
||||
String urlTmp = String.format("tmp", nemonico);
|
||||
|
||||
String folderPrimero = primero.getDocUrl();
|
||||
String folderAnio[] = folderPrimero.split("/".concat(primero.getDocNombre()));
|
||||
String folderArchivoPosible = folderAnio[0];
|
||||
File zip = dominioUtil.crearZip(folderArchivoPosible, liquidacion.getLiqNemonico().concat(".zip"), true);
|
||||
// /data/wmp/liquidacion/2020/LQ0000000080/img076.pdf
|
||||
|
||||
return zip;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param liquidacion
|
||||
*/
|
||||
private List<Documento> crearDocumentos(Liquidacion liquida, LiquidacionDTO liquidacion) throws DaoException {
|
||||
List<Documento> documentos = new ArrayList<>();
|
||||
if (liquidacion.getDocumentos() != null) {
|
||||
for (DocumentoDTO doc : liquidacion.getDocumentos()) {
|
||||
Documento dcto = (Documento) dominioUtil.getEntidad(EntidadEnum.Documento.getMapper(), doc);
|
||||
dcto.setDetTipo(DetalleCatalogoEnum.HABIL.getDetalle());
|
||||
dcto.setDocEstado(DominioConstantes.ACTIVO);
|
||||
dcto.setLiqCodigo(liquida);
|
||||
dcto.setPolCodigo(liquida.getPolCodigo());
|
||||
String url = this.grabaDocumento(doc, liquida.getLiqNemonico());
|
||||
dcto.setDocUrl(url);
|
||||
documentos.add(dcto);
|
||||
}
|
||||
}
|
||||
return documentos;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param doc
|
||||
* @param contrato
|
||||
* @param liquidacion
|
||||
* @return
|
||||
*/
|
||||
private String grabaDocumento(DocumentoDTO doc, String liquidacion) {
|
||||
String url = DetalleCatalogoEnum.URLLIQ.getDetalle().getDetOrigen();
|
||||
int year = Calendar.getInstance().get(Calendar.YEAR);
|
||||
url = String.format(url, "" + year, liquidacion);
|
||||
File file = new File(url);
|
||||
try {
|
||||
file.mkdirs();
|
||||
url = url.concat(doc.getDocNombre());
|
||||
FileOutputStream writer;
|
||||
writer = new FileOutputStream(new File(url));
|
||||
writer.write(doc.getData());
|
||||
writer.close();
|
||||
} catch (IOException | NullPointerException ex) {
|
||||
url = null;
|
||||
}
|
||||
return url;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param detalleDTO
|
||||
* @return
|
||||
* @throws DaoException
|
||||
*/
|
||||
private List<TarifaLiquidacion> crearTarifas(DetalleLiquidacionDTO detalleDTO, DetalleLiquidacion detalle) {
|
||||
List<TarifaLiquidacion> data = new ArrayList<>();
|
||||
for (TarifaLiquidacionDTO tarDto : detalleDTO.getDetalle()) {
|
||||
TarifaLiquidacion tarifa = (TarifaLiquidacion) dominioUtil.getEntidad(EntidadEnum.TarifaLiquidacion.getMapper(), tarDto);
|
||||
tarifa.setDelCodigo(detalle);
|
||||
data.add(tarifa);
|
||||
}
|
||||
System.out.println("=========> TARIFAS " + data);
|
||||
return data;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,687 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.qsoft.erp.dominio.util;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
import com.qsoft.dao.exception.DaoException;
|
||||
import com.qsoft.erp.constantes.DetalleCatalogoEnum;
|
||||
import com.qsoft.erp.constantes.DominioConstantes;
|
||||
import com.qsoft.erp.constantes.ParametroEnum;
|
||||
import com.qsoft.erp.constantes.PlantillaEnum;
|
||||
import com.qsoft.erp.dao.DaoGenerico;
|
||||
import com.qsoft.erp.dominio.exception.DominioExcepcion;
|
||||
import com.qsoft.erp.dominio.mapper.EmailMapper;
|
||||
import com.qsoft.erp.dto.EmailDTO;
|
||||
import com.qsoft.erp.model.DetalleCatalogo;
|
||||
import com.qsoft.erp.model.Email;
|
||||
import com.qsoft.erp.model.EstadoLiquidacion;
|
||||
import com.qsoft.erp.model.Liquidacion;
|
||||
import com.qsoft.erp.model.Persona;
|
||||
import com.qsoft.erp.model.Plantilla;
|
||||
import com.qsoft.erp.model.PlantillaSmtp;
|
||||
import com.qsoft.erp.model.Poliza;
|
||||
import com.qsoft.erp.model.Telefono;
|
||||
import com.qsoft.erp.model.Usuario;
|
||||
import com.qsoft.util.constantes.CodigoRespuesta;
|
||||
import com.qsoft.util.constantes.ErrorTipo;
|
||||
import com.qsoft.util.ms.pojo.HeaderMS;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.ejb.Asynchronous;
|
||||
import javax.ejb.EJB;
|
||||
import javax.ejb.Stateless;
|
||||
import javax.transaction.Transactional;
|
||||
import org.apache.commons.lang3.math.NumberUtils;
|
||||
import static com.qsoft.erp.dominio.AccionGenerica.ACTUALIZA;
|
||||
import static com.qsoft.erp.dominio.AccionGenerica.CONSULTA;
|
||||
import static com.qsoft.erp.dominio.AccionGenerica.ELIMINA;
|
||||
import static com.qsoft.erp.dominio.AccionGenerica.GUARDA;
|
||||
import static com.qsoft.erp.dominio.AccionGenerica.CANCELA;
|
||||
import com.qsoft.erp.model.PersonaPoliza;
|
||||
import java.util.Date;
|
||||
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author james
|
||||
*/
|
||||
@Stateless
|
||||
public class NotificadorUtil {
|
||||
|
||||
@EJB
|
||||
private DominioUtil dominioUtil;
|
||||
|
||||
@PostConstruct
|
||||
public void postConstruct() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param header
|
||||
* @param entidades
|
||||
* @param tipoAccion
|
||||
* @return
|
||||
* @throws DominioExcepcion
|
||||
*/
|
||||
@Transactional(Transactional.TxType.REQUIRED)
|
||||
public List<Email> notificar(HeaderMS header, List<Map<String, Object>> entidades, int tipoAccion) throws DominioExcepcion {
|
||||
List<Email> data = new ArrayList<>();
|
||||
for (Map<String, Object> ent : entidades) {
|
||||
EmailDTO emailDTO = (EmailDTO) this.dominioUtil.crearObjeto(EmailDTO.class, ent);
|
||||
Email n = crudNotificacion(header, emailDTO, tipoAccion);
|
||||
data.add(n);
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param header
|
||||
* @param emailDTO
|
||||
* @param tipoAccion
|
||||
* @return
|
||||
* @throws DominioExcepcion
|
||||
*/
|
||||
@Transactional(Transactional.TxType.REQUIRES_NEW)
|
||||
public Email crudNotificacion(HeaderMS header, EmailDTO emailDTO, int tipoAccion) throws DominioExcepcion{
|
||||
DaoGenerico<Email, Integer> daonot = new DaoGenerico<>(Email.class);
|
||||
Email result;
|
||||
result = EmailMapper.INSTANCE.getEntidad(emailDTO);
|
||||
switch (tipoAccion) {
|
||||
case CONSULTA: {
|
||||
throw new DominioExcepcion(ErrorTipo.ERROR, CodigoRespuesta.CODIGO_ERROR_GENERICO,
|
||||
"Operacion CONSULTA no soportada para el controlador de Accion");
|
||||
}
|
||||
case GUARDA: {
|
||||
try {
|
||||
result.setParEstado(ParametroEnum.REG.getParametro());
|
||||
result.setEmaIntento(DominioConstantes.INACTIVO);
|
||||
daonot.guardar(result);
|
||||
} catch (DaoException ex) {
|
||||
throw new DominioExcepcion(ErrorTipo.FATAL, CodigoRespuesta.CODIGO_ERROR_GUARDA_BDD, ex.toString());
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ACTUALIZA: {
|
||||
try {
|
||||
result = daonot.actualizar(result);
|
||||
} catch (DaoException ex) {
|
||||
throw new DominioExcepcion(ErrorTipo.FATAL, CodigoRespuesta.CODIGO_ERROR_ACTUALIZA_BDD, ex.toString());
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ELIMINA: {
|
||||
throw new DominioExcepcion(ErrorTipo.ERROR, CodigoRespuesta.CODIGO_ERROR_GENERICO,
|
||||
"Operacion ELIMINACION aun no permitida");
|
||||
}
|
||||
case CANCELA: {
|
||||
throw new DominioExcepcion(ErrorTipo.ERROR, CodigoRespuesta.CODIGO_ERROR_GENERICO,
|
||||
"Operacion CANCELAR aun no permitida");
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param usuario
|
||||
* @param poliza
|
||||
* @param password
|
||||
* @throws com.qsoft.dao.exception.DaoException
|
||||
*/
|
||||
public void notificarBienvenida(Usuario usuario, Poliza poliza, String password) throws DaoException {
|
||||
DaoGenerico<Email, Integer> daoMail = new DaoGenerico<>(Email.class);
|
||||
DaoGenerico<PlantillaSmtp, Integer> daoPlsmt = new DaoGenerico<>(PlantillaSmtp.class);
|
||||
DaoGenerico<Persona, Integer> daoPer = new DaoGenerico<>(Persona.class);
|
||||
|
||||
Plantilla plantilla = PlantillaEnum.NOTCAR.getPlantilla();
|
||||
Email mail = new Email();
|
||||
mail.setEmaAsunto(plantilla.getPlaAsunto());
|
||||
ObjectMapper obj = new ObjectMapper();
|
||||
Persona persona = null;
|
||||
if(usuario.getUsuIdOrigen() ==null || usuario.getUsuIdOrigen().trim().equals("")){
|
||||
Persona plantillaPersona = new Persona();
|
||||
plantillaPersona.setPerIdentificacion(usuario.getUsuUsuario());
|
||||
persona = daoPer.buscarUnico(plantillaPersona);
|
||||
}else{
|
||||
persona = this.getPersona(usuario);
|
||||
|
||||
}
|
||||
Map<String, String> parametros = getParametrosBienvenida(plantilla, persona, poliza, password);
|
||||
try {
|
||||
String jsonStr = obj.writeValueAsString(parametros);
|
||||
mail.setEmaContenido(jsonStr);
|
||||
} catch (JsonProcessingException ex) {
|
||||
ex.printStackTrace(System.err);
|
||||
}
|
||||
mail.setEmaDestinatiario(usuario.getUsuEmail());
|
||||
|
||||
mail.setEmaCopiaOculta(DetalleCatalogoEnum.COPMAI.getDetalle().getDetOrigen());
|
||||
mail.setEmaObservacion("NOTIFICACION DE BENVENIDA");
|
||||
mail.setParEstado(ParametroEnum.REG.getParametro());
|
||||
mail.setEmaIntento(DominioConstantes.INACTIVO);
|
||||
PlantillaSmtp psm = new PlantillaSmtp();
|
||||
psm.setPlaCodigo(plantilla);
|
||||
psm = daoPlsmt.buscarUnico(psm);
|
||||
mail.setPlsmCodigo(psm);
|
||||
daoMail.guardar(mail);
|
||||
|
||||
}
|
||||
public void notificarBienvenida(Usuario usuario, Poliza poliza, String password, Persona persona) throws DaoException {
|
||||
DaoGenerico<Email, Integer> daoMail = new DaoGenerico<>(Email.class);
|
||||
DaoGenerico<PlantillaSmtp, Integer> daoPlsmt = new DaoGenerico<>(PlantillaSmtp.class);
|
||||
|
||||
Plantilla plantilla = PlantillaEnum.NOTCAR.getPlantilla();
|
||||
Email mail = new Email();
|
||||
mail.setEmaAsunto(plantilla.getPlaAsunto());
|
||||
ObjectMapper obj = new ObjectMapper();
|
||||
Map<String, String> parametros = getParametrosBienvenida(plantilla, persona, poliza, password);
|
||||
try {
|
||||
String jsonStr = obj.writeValueAsString(parametros);
|
||||
mail.setEmaContenido(jsonStr);
|
||||
} catch (JsonProcessingException ex) {
|
||||
ex.printStackTrace(System.err);
|
||||
}
|
||||
mail.setEmaDestinatiario(usuario.getUsuEmail());
|
||||
|
||||
mail.setEmaCopiaOculta(DetalleCatalogoEnum.COPMAI.getDetalle().getDetOrigen());
|
||||
mail.setEmaObservacion("NOTIFICACION DE BENVENIDA");
|
||||
mail.setParEstado(ParametroEnum.REG.getParametro());
|
||||
mail.setEmaIntento(DominioConstantes.INACTIVO);
|
||||
PlantillaSmtp psm = new PlantillaSmtp();
|
||||
psm.setPlaCodigo(plantilla);
|
||||
psm = daoPlsmt.buscarUnico(psm);
|
||||
mail.setPlsmCodigo(psm);
|
||||
daoMail.guardar(mail);
|
||||
|
||||
}
|
||||
public void notificarMora(PersonaPoliza personaPoliza, Integer nMeses, Double valor) throws DaoException {
|
||||
DaoGenerico<Email, Integer> daoMail = new DaoGenerico<>(Email.class);
|
||||
DaoGenerico<PlantillaSmtp, Integer> daoPlsmt = new DaoGenerico<>(PlantillaSmtp.class);
|
||||
Plantilla plantilla = PlantillaEnum.NOTPOM.getPlantilla();
|
||||
Email mail = new Email();
|
||||
mail.setEmaAsunto(plantilla.getPlaAsunto());
|
||||
ObjectMapper obj = new ObjectMapper();
|
||||
Map<String, String> parametros = getParametrosPolizaMora(plantilla, personaPoliza, nMeses, valor);
|
||||
try {
|
||||
String jsonStr = obj.writeValueAsString(parametros);
|
||||
mail.setEmaContenido(jsonStr);
|
||||
} catch (JsonProcessingException ex) {
|
||||
ex.printStackTrace(System.err);
|
||||
}
|
||||
mail.setEmaDestinatiario(personaPoliza.getPerCodigo().getPerMail());
|
||||
|
||||
mail.setEmaCopiaOculta(DetalleCatalogoEnum.COPMAI.getDetalle().getDetOrigen());
|
||||
mail.setEmaObservacion("NOTIFICACION DE MORA");
|
||||
mail.setParEstado(ParametroEnum.REG.getParametro());
|
||||
mail.setEmaIntento(DominioConstantes.INACTIVO);
|
||||
PlantillaSmtp psm = new PlantillaSmtp();
|
||||
psm.setPlaCodigo(plantilla);
|
||||
psm = daoPlsmt.buscarUnico(psm);
|
||||
mail.setPlsmCodigo(psm);
|
||||
if(!buscarNotificacionPoliza(plantilla.getPlaAsunto(), mail.getEmaAdjunto(), daoMail)){
|
||||
daoMail.guardar(mail);
|
||||
}
|
||||
|
||||
}
|
||||
public boolean buscarNotificacionPoliza(String asunto, String emaContenido, DaoGenerico<Email, Integer> daoMail) throws DaoException{
|
||||
Email notificacion = new Email();
|
||||
notificacion.setEmaAsunto(asunto);
|
||||
notificacion.setEmaContenido(emaContenido);
|
||||
notificacion.setParEstado(ParametroEnum.ENV.getParametro());
|
||||
boolean retornar = false;
|
||||
Email correoOriginal = daoMail.buscarUnico(notificacion);
|
||||
if(correoOriginal != null){
|
||||
String observacion = correoOriginal.getEmaObservacion();
|
||||
if(observacion != null && observacion.contains(":")){
|
||||
String []fechaObservacion = observacion.split("T");
|
||||
String fechaActualString = DominioConstantes.FORMAT_OBS.format(new Date());
|
||||
if(fechaActualString.equals(fechaObservacion[0])){
|
||||
retornar = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return retornar;
|
||||
|
||||
}
|
||||
public void notificarAnulacion(PersonaPoliza personaPoliza, Integer nMeses, Double valor) throws DaoException {
|
||||
DaoGenerico<Email, Integer> daoMail = new DaoGenerico<>(Email.class);
|
||||
DaoGenerico<PlantillaSmtp, Integer> daoPlsmt = new DaoGenerico<>(PlantillaSmtp.class);
|
||||
|
||||
Plantilla plantilla = PlantillaEnum.NOTANP.getPlantilla();
|
||||
Email mail = new Email();
|
||||
mail.setEmaAsunto(plantilla.getPlaAsunto());
|
||||
ObjectMapper obj = new ObjectMapper();
|
||||
Map<String, String> parametros = getParametrosAnulacionPoliza(plantilla, personaPoliza, nMeses, valor);
|
||||
try {
|
||||
String jsonStr = obj.writeValueAsString(parametros);
|
||||
mail.setEmaContenido(jsonStr);
|
||||
} catch (JsonProcessingException ex) {
|
||||
ex.printStackTrace(System.err);
|
||||
}
|
||||
mail.setEmaDestinatiario(personaPoliza.getPerCodigo().getPerMail());
|
||||
|
||||
mail.setEmaCopiaOculta(DetalleCatalogoEnum.COPMAI.getDetalle().getDetOrigen());
|
||||
mail.setEmaObservacion("NOTIFICACION DE ANULACION DE POLIZA");
|
||||
mail.setParEstado(ParametroEnum.REG.getParametro());
|
||||
mail.setEmaIntento(DominioConstantes.INACTIVO);
|
||||
PlantillaSmtp psm = new PlantillaSmtp();
|
||||
psm.setPlaCodigo(plantilla);
|
||||
psm = daoPlsmt.buscarUnico(psm);
|
||||
mail.setPlsmCodigo(psm);
|
||||
if(!buscarNotificacionPoliza(plantilla.getPlaAsunto(), mail.getEmaAdjunto(), daoMail)){
|
||||
daoMail.guardar(mail);
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param usuario
|
||||
* @throws com.qsoft.dao.exception.DaoException
|
||||
*/
|
||||
public void notificarReset(Usuario usuario) throws DaoException {
|
||||
DaoGenerico<Email, Integer> daoMail = new DaoGenerico<>(Email.class);
|
||||
DaoGenerico<PlantillaSmtp, Integer> daoPlsmt = new DaoGenerico<>(PlantillaSmtp.class);
|
||||
|
||||
Plantilla plantilla = PlantillaEnum.NOTRES.getPlantilla();
|
||||
Email mail = new Email();
|
||||
mail.setEmaAsunto(plantilla.getPlaAsunto());
|
||||
ObjectMapper obj = new ObjectMapper();
|
||||
Map<String, String> parametros = getParametrosResetPassword(plantilla, usuario);
|
||||
try {
|
||||
String jsonStr = obj.writeValueAsString(parametros);
|
||||
mail.setEmaContenido(jsonStr);
|
||||
} catch (JsonProcessingException ex) {
|
||||
ex.printStackTrace(System.err);
|
||||
}
|
||||
mail.setEmaDestinatiario(usuario.getUsuEmail());
|
||||
mail.setEmaCopiaOculta(DetalleCatalogoEnum.COPMAI.getDetalle().getDetOrigen());
|
||||
mail.setEmaObservacion(plantilla.getPlaAsunto());
|
||||
mail.setParEstado(ParametroEnum.REG.getParametro());
|
||||
mail.setEmaIntento(DominioConstantes.INACTIVO);
|
||||
PlantillaSmtp psm = new PlantillaSmtp();
|
||||
psm.setPlaCodigo(plantilla);
|
||||
psm = daoPlsmt.buscarUnico(psm);
|
||||
mail.setPlsmCodigo(psm);
|
||||
daoMail.guardar(mail);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param usuario
|
||||
* @param poliza
|
||||
* @throws com.qsoft.dao.exception.DaoException
|
||||
*/
|
||||
public void notificarBienvenida(Usuario usuario, Poliza poliza) throws DaoException {
|
||||
DaoGenerico<Email, Integer> daoMail = new DaoGenerico<>(Email.class);
|
||||
DaoGenerico<PlantillaSmtp, Integer> daoPlsmt = new DaoGenerico<>(PlantillaSmtp.class);
|
||||
|
||||
Plantilla plantilla = PlantillaEnum.NOTPOL.getPlantilla();
|
||||
Email mail = new Email();
|
||||
mail.setEmaAsunto(plantilla.getPlaAsunto());
|
||||
ObjectMapper obj = new ObjectMapper();
|
||||
Map<String, String> parametros = getParametrosBienvenida(plantilla, this.getPersona(usuario), poliza);
|
||||
try {
|
||||
String jsonStr = obj.writeValueAsString(parametros);
|
||||
mail.setEmaContenido(jsonStr);
|
||||
} catch (JsonProcessingException ex) {
|
||||
ex.printStackTrace(System.err);
|
||||
}
|
||||
mail.setEmaDestinatiario(usuario.getUsuEmail());
|
||||
mail.setEmaCopiaOculta(DetalleCatalogoEnum.COPMAI.getDetalle().getDetOrigen());
|
||||
mail.setEmaObservacion(plantilla.getPlaAsunto());
|
||||
mail.setParEstado(ParametroEnum.REG.getParametro());
|
||||
mail.setEmaIntento(DominioConstantes.INACTIVO);
|
||||
mail.setEmaAdjunto(poliza.getPolObservacion());
|
||||
PlantillaSmtp psm = new PlantillaSmtp();
|
||||
psm.setPlaCodigo(plantilla);
|
||||
psm = daoPlsmt.buscarUnico(psm);
|
||||
mail.setPlsmCodigo(psm);
|
||||
daoMail.guardar(mail);
|
||||
|
||||
}
|
||||
|
||||
@Asynchronous
|
||||
public void enviarMensajeBienvenida(Usuario usuario, Poliza poliza, String pass) throws DaoException, MalformedURLException, IOException {
|
||||
URL url;
|
||||
Plantilla smsApo = PlantillaEnum.SMSAPO.getPlantilla();
|
||||
|
||||
String formatoMensaje = smsApo.getPlaParametros();
|
||||
Persona persona = getPersona(usuario);
|
||||
|
||||
String message = String.format(formatoMensaje,
|
||||
poliza.getPlaCodigo().getPlaNombre(),
|
||||
usuario.getUsuUsuario(),
|
||||
pass
|
||||
);
|
||||
|
||||
for (Telefono phoneNumber : persona.getTelefonoCollection()) {
|
||||
if (phoneNumber.getDetTipo().getDetNemonico().equals("MOVIL")) {
|
||||
|
||||
String urlString = String.format(smsApo.getPlaRuta(), phoneNumber.getTelNumero(), message.replaceAll(" ", "+"));
|
||||
url = new URL(urlString);
|
||||
URLConnection con = url.openConnection();
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
|
||||
String linea;
|
||||
while ((linea = in.readLine()) != null) {
|
||||
System.out.println(linea);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param usuario
|
||||
* @param otp
|
||||
* @throws com.qsoft.dao.exception.DaoException
|
||||
*/
|
||||
public void notificarOTP(Usuario usuario, String otp) throws DaoException {
|
||||
DaoGenerico<Email, Integer> daoMail = new DaoGenerico<>(Email.class);
|
||||
DaoGenerico<PlantillaSmtp, Integer> daoPlsmt = new DaoGenerico<>(PlantillaSmtp.class);
|
||||
|
||||
Plantilla plantilla = PlantillaEnum.NOTOTP.getPlantilla();
|
||||
Email mail = new Email();
|
||||
mail.setEmaAsunto(plantilla.getPlaAsunto());
|
||||
ObjectMapper obj = new ObjectMapper();
|
||||
Map<String, String> parametros = getParametrosOTP(plantilla, this.getPersona(usuario), otp);
|
||||
try {
|
||||
String jsonStr = obj.writeValueAsString(parametros);
|
||||
mail.setEmaContenido(jsonStr);
|
||||
} catch (JsonProcessingException ex) {
|
||||
ex.printStackTrace(System.err);
|
||||
}
|
||||
mail.setEmaDestinatiario(usuario.getUsuEmail());
|
||||
mail.setEmaCopiaOculta(DetalleCatalogoEnum.COPMAI.getDetalle().getDetOrigen());
|
||||
mail.setEmaObservacion(plantilla.getPlaAsunto());
|
||||
mail.setParEstado(ParametroEnum.REG.getParametro());
|
||||
mail.setEmaIntento(DominioConstantes.INACTIVO);
|
||||
PlantillaSmtp psm = new PlantillaSmtp();
|
||||
psm.setPlaCodigo(plantilla);
|
||||
psm = daoPlsmt.buscarUnico(psm);
|
||||
mail.setPlsmCodigo(psm);
|
||||
daoMail.guardar(mail);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param usuario
|
||||
* @param liquidacion
|
||||
* @throws com.qsoft.dao.exception.DaoException
|
||||
*/
|
||||
@Asynchronous
|
||||
public void notificarLiquidacion(Usuario usuario, Liquidacion liquidacion) throws DaoException {
|
||||
DaoGenerico<Email, Integer> daoMail = new DaoGenerico<>(Email.class);
|
||||
DaoGenerico<PlantillaSmtp, Integer> daoPlsmt = new DaoGenerico<>(PlantillaSmtp.class);
|
||||
|
||||
Plantilla plantilla = PlantillaEnum.NOTLQG.getPlantilla();
|
||||
Email mail = new Email();
|
||||
mail.setEmaAsunto(plantilla.getPlaAsunto());
|
||||
ObjectMapper obj = new ObjectMapper();
|
||||
|
||||
Map<String, String> parametros = getParametrosLiquidacion(plantilla, this.getPersona(usuario), liquidacion);
|
||||
try {
|
||||
String jsonStr = obj.writeValueAsString(parametros);
|
||||
mail.setEmaContenido(jsonStr);
|
||||
} catch (JsonProcessingException ex) {
|
||||
ex.printStackTrace(System.err);
|
||||
}
|
||||
mail.setEmaDestinatiario(usuario.getUsuEmail());
|
||||
mail.setEmaCopiaOculta(DetalleCatalogoEnum.COPMAI.getDetalle().getDetOrigen());
|
||||
mail.setEmaObservacion(plantilla.getPlaAsunto());
|
||||
mail.setParEstado(ParametroEnum.REG.getParametro());
|
||||
mail.setEmaIntento(DominioConstantes.INACTIVO);
|
||||
PlantillaSmtp psm = new PlantillaSmtp();
|
||||
psm.setPlaCodigo(plantilla);
|
||||
psm = daoPlsmt.buscarUnico(psm);
|
||||
mail.setPlsmCodigo(psm);
|
||||
daoMail.guardar(mail);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param usuario
|
||||
* @return
|
||||
*/
|
||||
private Persona getPersona(Usuario usuario) throws DaoException {
|
||||
DaoGenerico<Persona, Integer> daoPers = new DaoGenerico<>(Persona.class);
|
||||
Persona persona = daoPers.cargar(NumberUtils.createInteger(usuario.getUsuIdOrigen()));
|
||||
return persona;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param usuario
|
||||
* @param estado
|
||||
* @param liquidacion
|
||||
* @throws com.qsoft.dao.exception.DaoException
|
||||
*/
|
||||
@Asynchronous
|
||||
public void notificarEstadoLiquidacion(Liquidacion liquidacion, Usuario usuario, EstadoLiquidacion estado) throws DaoException {
|
||||
DaoGenerico<Email, Integer> daoMail = new DaoGenerico<>(Email.class);
|
||||
DaoGenerico<PlantillaSmtp, Integer> daoPlsmt = new DaoGenerico<>(PlantillaSmtp.class);
|
||||
|
||||
Plantilla plantilla = PlantillaEnum.NOTLQO.getPlantilla();
|
||||
Email mail = new Email();
|
||||
mail.setEmaAsunto(plantilla.getPlaAsunto());
|
||||
ObjectMapper obj = new ObjectMapper();
|
||||
Map<String, String> parametros = getParametrosEstadoLiquida(plantilla, liquidacion, this.getPersona(usuario), estado);
|
||||
try {
|
||||
String jsonStr = obj.writeValueAsString(parametros);
|
||||
mail.setEmaContenido(jsonStr);
|
||||
} catch (JsonProcessingException ex) {
|
||||
ex.printStackTrace(System.err);
|
||||
}
|
||||
mail.setEmaAdjunto(liquidacion.getLiqReporte());
|
||||
mail.setEmaDestinatiario(usuario.getUsuEmail());
|
||||
mail.setEmaCopiaOculta(DetalleCatalogoEnum.COPMAI.getDetalle().getDetOrigen());
|
||||
mail.setEmaObservacion(plantilla.getPlaAsunto());
|
||||
mail.setParEstado(ParametroEnum.REG.getParametro());
|
||||
mail.setEmaIntento(DominioConstantes.INACTIVO);
|
||||
PlantillaSmtp psm = new PlantillaSmtp();
|
||||
psm.setPlaCodigo(plantilla);
|
||||
psm = daoPlsmt.buscarUnico(psm);
|
||||
mail.setPlsmCodigo(psm);
|
||||
daoMail.guardar(mail);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param plantilla
|
||||
* @param persona
|
||||
* @return
|
||||
*/
|
||||
private Map getParametrosBienvenida(Plantilla plantilla, Persona persona, Poliza poliza, String password) {
|
||||
//{"[ASUNTO]":"","[CLIENTE]":"","[COBERTURA]":"","[COMPROBANTE]":"","[EMAIL]":"","[EMISOR]":"","[EMISOR_MAIL]":"","[EMISOR_WEB] ":"","[FECHAEMI]":"","[IDENTIFICACION]":"","[MONTO]":"","[NUMDOC]":"","[PLAN]":""}
|
||||
Map<String, String> parametros = new TreeMap<>();
|
||||
parametros.put("[ASUNTO]", plantilla.getPlaAsunto());
|
||||
parametros.put("[COMPROBANTE]", DominioConstantes.POLIZA);
|
||||
parametros.put("[IDENTIFICACION]", persona.getPerIdentificacion());
|
||||
parametros.put("[CLIENTE]", persona.getPerNombres() + " " + persona.getPerApellidos());
|
||||
parametros.put("[NUMDOC]", poliza.getPolContrato());
|
||||
parametros.put("[FECHAEMI]", DominioConstantes.getDateTime(poliza.getPolFechaInicio()));
|
||||
parametros.put("[COBERTURA]", "" + poliza.getPlaCodigo().getPlaCoberturaMaxima());
|
||||
parametros.put("[PLAN]", "" + poliza.getPlaCodigo().getPlaNombre());
|
||||
parametros.put("[PASSWORD]", password);
|
||||
parametros.put("[EMAIL]", persona.getPerMail());
|
||||
parametros.put("[EMISOR]", DominioConstantes.CARIDEL);
|
||||
parametros.put("[EMISOR_MAIL]", DominioConstantes.MAIL_CARIDEL);
|
||||
parametros.put("[EMISOR_WEB]", DominioConstantes.URL_CARIDEL);
|
||||
|
||||
return parametros;
|
||||
}
|
||||
private Map getParametrosAnulacionPoliza(Plantilla plantilla, PersonaPoliza personaPoliza,Integer nMeses, Double valor) {
|
||||
//{"[ASUNTO]":"","[CLIENTE]":"","[COBERTURA]":"","[COMPROBANTE]":"","[EMAIL]":"","[EMISOR]":"","[EMISOR_MAIL]":"","[EMISOR_WEB] ":"","[FECHAEMI]":"","[IDENTIFICACION]":"","[MONTO]":"","[NUMDOC]":"","[PLAN]":""}
|
||||
Map<String, String> parametros = new TreeMap<>();
|
||||
parametros.put("[ASUNTO]", plantilla.getPlaAsunto());
|
||||
parametros.put("[COMPROBANTE]", DominioConstantes.POLIZA);
|
||||
parametros.put("[POLIZA]", personaPoliza.getPolCodigo().getPolContrato());
|
||||
parametros.put("[NMESES]", nMeses.toString());
|
||||
parametros.put("[VALOR]", valor.toString());
|
||||
parametros.put("[IDENTIFICACION]", personaPoliza.getPerCodigo().getPerIdentificacion());
|
||||
parametros.put("[CLIENTE]", personaPoliza.getPerCodigo().getPerNombres() + " " + personaPoliza.getPerCodigo().getPerApellidos());
|
||||
parametros.put("[NUMDOC]", personaPoliza.getPolCodigo().getPolContrato());
|
||||
parametros.put("[FECHAEMI]", DominioConstantes.getDateTime(personaPoliza.getPolCodigo().getPolFechaInicio()));
|
||||
parametros.put("[COBERTURA]", "" + personaPoliza.getPolCodigo().getPlaCodigo().getPlaCoberturaMaxima());
|
||||
parametros.put("[PLAN]", "" + personaPoliza.getPolCodigo().getPlaCodigo().getPlaNombre());
|
||||
parametros.put("[EMAIL]", personaPoliza.getPerCodigo().getPerMail());
|
||||
parametros.put("[EMISOR]", DominioConstantes.CARIDEL);
|
||||
parametros.put("[EMISOR_MAIL]", DominioConstantes.MAIL_CARIDEL);
|
||||
parametros.put("[EMISOR_WEB]", DominioConstantes.URL_CARIDEL);
|
||||
|
||||
return parametros;
|
||||
}
|
||||
|
||||
private Map getParametrosPolizaMora(Plantilla plantilla,PersonaPoliza personaPoliza,Integer nMeses, Double valor) {
|
||||
//{"[ASUNTO]":"","[CLIENTE]":"","[COBERTURA]":"","[COMPROBANTE]":"","[EMAIL]":"","[EMISOR]":"","[EMISOR_MAIL]":"","[EMISOR_WEB] ":"","[FECHAEMI]":"","[IDENTIFICACION]":"","[MONTO]":"","[NUMDOC]":"","[PLAN]":""}
|
||||
Map<String, String> parametros = new TreeMap<>();
|
||||
parametros.put("[ASUNTO]", plantilla.getPlaAsunto());
|
||||
parametros.put("[NMESES]", nMeses.toString());
|
||||
parametros.put("[VALOR]", valor.toString());
|
||||
parametros.put("[POLIZA]", personaPoliza.getPolCodigo().getPolContrato());
|
||||
parametros.put("[MESESTOPE]", DominioConstantes.TOPE_MESES_MORA.toString());
|
||||
parametros.put("[EMAIL]", personaPoliza.getPerCodigo().getPerMail());
|
||||
parametros.put("[EMISOR]", DominioConstantes.CARIDEL);
|
||||
parametros.put("[EMISOR_MAIL]", DominioConstantes.MAIL_CARIDEL);
|
||||
parametros.put("[EMISOR_WEB]", DominioConstantes.URL_CARIDEL);
|
||||
|
||||
return parametros;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param plantilla
|
||||
* @param usuario
|
||||
* @return
|
||||
*/
|
||||
private Map getParametrosBienvenida(Plantilla plantilla, Persona persona, Poliza poliza) {
|
||||
Map<String, String> parametros = new TreeMap<>();
|
||||
parametros.put("[ASUNTO]", plantilla.getPlaAsunto());
|
||||
parametros.put("[COMPROBANTE]", DominioConstantes.POLIZA);
|
||||
parametros.put("[IDENTIFICACION]", persona.getPerIdentificacion());
|
||||
parametros.put("[CLIENTE]", persona.getPerNombres() + " " + persona.getPerApellidos());
|
||||
parametros.put("[NUMDOC]", poliza.getPolContrato());
|
||||
parametros.put("[FECHAEMI]", DominioConstantes.getDateTime(poliza.getPolFechaInicio()));
|
||||
parametros.put("[COBERTURA]", "" + poliza.getPlaCodigo().getPlaCoberturaMaxima());
|
||||
parametros.put("[PLAN]", "" + poliza.getPlaCodigo().getPlaNombre());
|
||||
parametros.put("[EMAIL]", persona.getPerMail());
|
||||
parametros.put("[ADJUNTO]", poliza.getPlaCodigo().getPlaRutaContrato());
|
||||
parametros.put("[EMISOR]", DominioConstantes.CARIDEL);
|
||||
parametros.put("[EMISOR_MAIL]", DominioConstantes.MAIL_CARIDEL);
|
||||
parametros.put("[EMISOR_WEB]", DominioConstantes.URL_CARIDEL);
|
||||
|
||||
return parametros;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param plantilla
|
||||
* @param persona
|
||||
* @return
|
||||
*/
|
||||
private Map getParametrosLiquidacion(Plantilla plantilla, Persona persona, Liquidacion liquidacion) {
|
||||
Map<String, String> parametros = new TreeMap<>();
|
||||
//{"[ASUNTO]":"","[LIQUIDACION]":"","[IDENTIFICACION]":"","[CLIENTE]":"","[NUMDOC]":"","[FECHAEMI]":"","[PLAN]":"","[EMAIL]":"","[EMISOR]":"","[EMISOR_MAIL]":""}
|
||||
parametros.put("[ASUNTO]", plantilla.getPlaAsunto());
|
||||
parametros.put("[LIQUIDACION]", liquidacion.getLiqNemonico());
|
||||
parametros.put("[IDENTIFICACION]", persona.getPerIdentificacion());
|
||||
parametros.put("[CLIENTE]", persona.getPerNombres() + " " + persona.getPerApellidos());
|
||||
parametros.put("[NUMDOC]", liquidacion.getLiqNemonico());
|
||||
parametros.put("[FECHAEMI]", DominioConstantes.getDateTime(liquidacion.getLiqFechaRegistro()));
|
||||
parametros.put("[PLAN]", "" + liquidacion.getPolCodigo().getPlaCodigo().getPlaNombre());
|
||||
parametros.put("[EMAIL]", persona.getPerMail());
|
||||
parametros.put("[EMISOR]", DominioConstantes.CARIDEL);
|
||||
parametros.put("[EMISOR_MAIL]", DominioConstantes.MAIL_CARIDEL);
|
||||
parametros.put("[EMISOR_WEB]", DominioConstantes.URL_CARIDEL);
|
||||
|
||||
return parametros;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param plantilla
|
||||
* @param persona
|
||||
* @return
|
||||
*/
|
||||
private Map getParametrosEstadoLiquida(Plantilla plantilla, Liquidacion liquidacion, Persona persona, EstadoLiquidacion estado) {
|
||||
//{"[ASUNTO]":"","[CLIENTE]":"","[LIQUIDACION]":"","[ESTADO]":"","[MENSAJE]":"","[IDENTIFICACION]":"","[FECHA]":"","[EMAIL]":"","[EMISOR]":"","[EMISOR_WEB]":"","[EMISOR_MAIL]":""}
|
||||
Map<String, String> parametros = new TreeMap<>();
|
||||
parametros.put("[ASUNTO]", plantilla.getPlaAsunto());
|
||||
parametros.put("[CLIENTE]", liquidacion.getPerBeneficiario().getPerNombres() + " " + liquidacion.getPerBeneficiario().getPerApellidos());
|
||||
parametros.put("[LIQUIDACION]", liquidacion.getLiqNemonico());
|
||||
parametros.put("[ESTADO]", estado.getDetEstado().getDetNombre());
|
||||
parametros.put("[MENSAJE]", estado.getEslMensaje());
|
||||
parametros.put("[IDENTIFICACION]", persona.getPerIdentificacion());
|
||||
parametros.put("[FECHA]", DominioConstantes.getDateTime(estado.getEslFechaInicio()));
|
||||
parametros.put("[EMAIL]", persona.getPerMail());
|
||||
parametros.put("[EMISOR]", DominioConstantes.CARIDEL);
|
||||
parametros.put("[EMISOR_MAIL]", DominioConstantes.MAIL_CARIDEL);
|
||||
parametros.put("[EMISOR_WEB]", DominioConstantes.URL_CARIDEL);
|
||||
return parametros;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param plantilla
|
||||
* @param usuario
|
||||
* @return
|
||||
*/
|
||||
private Map getParametrosResetPassword(Plantilla plantilla, Usuario usuario) {
|
||||
Map<String, String> parametros = new TreeMap<>();
|
||||
parametros.put("[ASUNTO]", plantilla.getPlaAsunto());
|
||||
DetalleCatalogo url = DetalleCatalogoEnum.URLPAS.getDetalle();
|
||||
parametros.put("[CAMBIO_CLAVE]", url.getDetOrigen().replace(DominioConstantes.PARAMETRO_URL, usuario.getUsuToken()));
|
||||
parametros.put("[EMAIL]", usuario.getUsuEmail());
|
||||
parametros.put("[EMISOR]", DominioConstantes.CARIDEL);
|
||||
parametros.put("[EMISOR_MAIL]", DominioConstantes.MAIL_CARIDEL);
|
||||
parametros.put("[EMISOR_WEB]", DominioConstantes.URL_CARIDEL);
|
||||
parametros.put("[FECHA]", DominioConstantes.getDateTime());
|
||||
return parametros;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param plantilla
|
||||
* @param usuario
|
||||
* @return
|
||||
*/
|
||||
private Map getParametrosOTP(Plantilla plantilla, Persona persona, String otp) {
|
||||
Map<String, String> parametros = new TreeMap<>();
|
||||
parametros.put("[ASUNTO]", plantilla.getPlaAsunto());
|
||||
DetalleCatalogo url = DetalleCatalogoEnum.URLPAS.getDetalle();
|
||||
parametros.put("[CLIENTE]", persona.getPerNombres() + " " + persona.getPerApellidos());
|
||||
parametros.put("[EMAIL]", persona.getPerMail());
|
||||
parametros.put("[IDENTIFICACION]", persona.getPerIdentificacion());
|
||||
parametros.put("[NUMOTP]", otp);
|
||||
parametros.put("[EMISOR]", DominioConstantes.CARIDEL);
|
||||
parametros.put("[EMISOR_MAIL]", DominioConstantes.MAIL_CARIDEL);
|
||||
parametros.put("[EMISOR_WEB]", DominioConstantes.URL_CARIDEL);
|
||||
parametros.put("[FECHA]", DominioConstantes.getDateTime());
|
||||
|
||||
return parametros;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,99 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.qsoft.erp.dominio.util;
|
||||
|
||||
import com.qsoft.dao.exception.DaoException;
|
||||
import com.qsoft.otp.OTP;
|
||||
import com.qsoft.erp.constantes.DominioConstantes;
|
||||
import com.qsoft.erp.constantes.ParametroEnum;
|
||||
import com.qsoft.erp.dao.DaoGenerico;
|
||||
import com.qsoft.erp.model.Otp;
|
||||
import com.qsoft.erp.model.Parametro;
|
||||
import com.qsoft.erp.model.Usuario;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.UUID;
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.ejb.Stateless;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author james
|
||||
*/
|
||||
@Stateless
|
||||
public class OTPUtil {
|
||||
|
||||
@PostConstruct
|
||||
public void postConstructor() {
|
||||
}
|
||||
|
||||
public Otp validarOtp(Usuario usuario, String otpCodigo) {
|
||||
DaoGenerico<Otp, Integer> otpDao = new DaoGenerico<>(Otp.class);
|
||||
|
||||
Otp otp = new Otp();
|
||||
String uuid = UUID.nameUUIDFromBytes(usuario.getUsuUsuario().getBytes()).toString().replace("-", "");
|
||||
otp.setOptUuid(uuid);
|
||||
otp.setOptValor(otpCodigo);
|
||||
try {
|
||||
Calendar cal = Calendar.getInstance();
|
||||
for (Otp o : otpDao.buscarLista(otp)) {
|
||||
cal.setTime(o.getOtpFechaRegistro());
|
||||
cal.add(Calendar.SECOND, o.getOtpTiempoVida());
|
||||
if (cal.getTimeInMillis() >= System.currentTimeMillis()) {
|
||||
otp = o;
|
||||
break;
|
||||
} else {
|
||||
o.setOtpFechaValidacion(new Date());
|
||||
o.setParEstado(new Parametro(ParametroEnum.OTPCAD.getCodigo()));
|
||||
otpDao.guardar(o);
|
||||
}
|
||||
}
|
||||
if (otp != null && otp.getOtpCodigo() != null) {
|
||||
otp.setOtpFechaValidacion(new Date());
|
||||
otp.setParEstado(new Parametro(ParametroEnum.OPTOK.getCodigo()));
|
||||
otpDao.guardar(otp);
|
||||
}
|
||||
} catch (DaoException ex) {
|
||||
otp = null;
|
||||
}
|
||||
|
||||
return otp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Genera y registra en BDD una OTP
|
||||
*
|
||||
* @param usuario
|
||||
* @param tipoOtp
|
||||
* @return
|
||||
*/
|
||||
public Otp generarOtp(Usuario usuario, ParametroEnum tipoOtp) {
|
||||
DaoGenerico<Otp, Integer> otpDao = new DaoGenerico<>(Otp.class);
|
||||
|
||||
Parametro param = tipoOtp.getParametro();
|
||||
Integer longitud = Integer.parseInt(param.getParDescripcion());
|
||||
Integer vida = Integer.parseInt(param.getParValor());
|
||||
String uuid = UUID.nameUUIDFromBytes(usuario.getUsuUsuario().getBytes()).toString().replace("-", "");
|
||||
String valorOtp = OTP.generate("" + uuid, "" + System.nanoTime(), longitud, OTP.TOTP);
|
||||
Otp otp = new Otp();
|
||||
otp.setOptUuid(uuid);
|
||||
otp.setOptValor(valorOtp);
|
||||
otp.setOtpFechaRegistro(new Date());
|
||||
otp.setOtpIntentos(0);
|
||||
otp.setOtpMaxIntentos(DominioConstantes.REINTENTOS_OTP);
|
||||
otp.setOtpTiempoVida(vida);
|
||||
otp.setParEstado(new Parametro(ParametroEnum.OTPGEN.getCodigo()));
|
||||
otp.setParTipo(new Parametro(tipoOtp.getCodigo()));
|
||||
try {
|
||||
otpDao.guardar(otp);
|
||||
} catch (DaoException ex) {
|
||||
System.out.println("ERROR registrando OTP " + ex);
|
||||
otp = null;
|
||||
}
|
||||
return otp;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.qsoft.erp.dominio.util;
|
||||
|
||||
import com.qsoft.dao.exception.DaoException;
|
||||
import com.qsoft.dao.util.Fila;
|
||||
import com.qsoft.erp.constantes.DominioConstantes;
|
||||
import com.qsoft.erp.dao.DaoGenerico;
|
||||
import com.qsoft.erp.model.Parametro;
|
||||
import java.util.List;
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.ejb.Stateless;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author christian
|
||||
*/
|
||||
@Stateless
|
||||
public class ParametroUtil {
|
||||
|
||||
@PostConstruct
|
||||
public void postConstruct() {
|
||||
|
||||
}
|
||||
public List<Fila> ejecutarConsulta(String nemonicoParametro) throws DaoException{
|
||||
DaoGenerico<Parametro, Integer> dao = new DaoGenerico<>(Parametro.class);
|
||||
Parametro plantillaQuery = new Parametro();
|
||||
plantillaQuery.setParNemonico(nemonicoParametro);
|
||||
plantillaQuery.setParEstado(DominioConstantes.ACTIVO);
|
||||
Parametro parQuery = dao.buscarUnico(plantillaQuery);
|
||||
if(parQuery == null){
|
||||
System.err.println("QUERY ".concat(nemonicoParametro).concat(" no existente"));
|
||||
}
|
||||
|
||||
return dao.ejecutarConsultaNativaList(parQuery.getParValor());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,515 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.qsoft.erp.dominio.util;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonParser;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.qsoft.dao.exception.DaoException;
|
||||
import com.qsoft.erp.constantes.DetalleCatalogoEnum;
|
||||
import com.qsoft.erp.constantes.DominioConstantes;
|
||||
import com.qsoft.erp.constantes.EntidadEnum;
|
||||
import com.qsoft.util.constantes.CodigoRespuesta;
|
||||
import com.qsoft.util.constantes.ErrorTipo;
|
||||
import com.qsoft.erp.dao.DaoGenerico;
|
||||
import com.qsoft.erp.dominio.exception.DominioExcepcion;
|
||||
import com.qsoft.erp.dominio.mapper.PersonaMapper;
|
||||
import com.qsoft.erp.dto.PersonaDTO;
|
||||
import com.qsoft.erp.dto.TelefonoDTO;
|
||||
import com.qsoft.erp.model.Persona;
|
||||
import com.qsoft.util.ms.pojo.HeaderMS;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.ejb.EJB;
|
||||
import javax.ejb.Stateless;
|
||||
import javax.transaction.Transactional;
|
||||
|
||||
import static com.qsoft.erp.dominio.AccionGenerica.ACTUALIZA;
|
||||
import static com.qsoft.erp.dominio.AccionGenerica.CONSULTA;
|
||||
import static com.qsoft.erp.dominio.AccionGenerica.ELIMINA;
|
||||
import static com.qsoft.erp.dominio.AccionGenerica.GUARDA;
|
||||
import static com.qsoft.erp.dominio.AccionGenerica.CANCELA;
|
||||
import com.qsoft.erp.dominio.mapper.CuentaBancariaMapper;
|
||||
import com.qsoft.erp.dominio.mapper.PersonaPolizaMapper;
|
||||
import com.qsoft.erp.dominio.mapper.TelefonoMapper;
|
||||
import com.qsoft.erp.dto.CuentaBancariaDTO;
|
||||
import com.qsoft.erp.dto.PersonaPolizaDTO;
|
||||
import com.qsoft.erp.model.CuentaBancaria;
|
||||
import com.qsoft.erp.model.DetalleCatalogo;
|
||||
import com.qsoft.erp.model.Localizacion;
|
||||
import com.qsoft.erp.model.PersonaPoliza;
|
||||
import com.qsoft.erp.model.Poliza;
|
||||
import com.qsoft.erp.model.Telefono;
|
||||
import com.qsoft.erp.model.Usuario;
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDate;
|
||||
import java.time.ZoneId;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.Objects;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author james
|
||||
*/
|
||||
@Stateless
|
||||
public class PersonaUtil {
|
||||
|
||||
@EJB
|
||||
private DominioUtil dominioUtil;
|
||||
@EJB
|
||||
private CatalogoUtil catalogoUtil;
|
||||
|
||||
@PostConstruct
|
||||
public void postConstruct() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param header
|
||||
* @param entidades
|
||||
* @param tipoAccion
|
||||
* @return
|
||||
* @throws DominioExcepcion
|
||||
*/
|
||||
@Transactional(Transactional.TxType.REQUIRED)
|
||||
public List<PersonaPoliza> crearPersonaPoliza(HeaderMS header, List<Map<String, Object>> entidades, int tipoAccion) throws DominioExcepcion {
|
||||
List<PersonaPoliza> data = new ArrayList<>();
|
||||
for (Map<String, Object> ent : entidades) {
|
||||
PersonaPoliza personaPoliza = (PersonaPoliza) dominioUtil.getEntidad(
|
||||
PersonaPolizaMapper.class, dominioUtil.crearObjeto(PersonaPolizaDTO.class, ent));
|
||||
PersonaPoliza result = null;
|
||||
try {
|
||||
Persona persona = personaPoliza.getPerCodigo();
|
||||
if (Objects.equals(DetalleCatalogoEnum.CED.getDetalle().getDetCodigo(), persona.getDetTipoIdentificacion().getDetCodigo())) {
|
||||
if (!this.dominioUtil.validarCedula(persona.getPerIdentificacion())) {
|
||||
throw new DominioExcepcion(ErrorTipo.ERROR, CodigoRespuesta.CODIGO_ERROR_CONSULTA_BDD,
|
||||
"La c\u00e9dula no cumple la validacion de d\u00edgito autoverificador<--\n");
|
||||
}
|
||||
}
|
||||
LocalDate fin = Instant.ofEpochMilli(new Date().getTime()).atZone(ZoneId.systemDefault()).toLocalDate();
|
||||
LocalDate ini = Instant.ofEpochMilli(persona.getPerFechaNacimiento().getTime()).atZone(ZoneId.systemDefault()).toLocalDate();
|
||||
if (ChronoUnit.YEARS.between(ini, fin) >= 71) {
|
||||
throw new DominioExcepcion(ErrorTipo.ERROR, CodigoRespuesta.CODIGO_ERROR_GENERICO,
|
||||
"El beneficiario excede el limite maximo de edad de cobertura");
|
||||
}
|
||||
|
||||
DaoGenerico<Poliza, Integer> daopol = new DaoGenerico<>(Poliza.class);
|
||||
DaoGenerico<Persona, Integer> daoper = new DaoGenerico<>(Persona.class);
|
||||
Poliza poliza = daopol.cargar(personaPoliza.getPolCodigo().getPolCodigo());
|
||||
Persona pers = new Persona();
|
||||
pers.setPerIdentificacion(persona.getPerIdentificacion());
|
||||
pers.setDetTipoIdentificacion(persona.getDetTipoIdentificacion());
|
||||
if (daoper.contarExistencias(pers) > 0) {
|
||||
result = this.actualizarBeneficiario(personaPoliza, pers, persona, poliza);
|
||||
} else {
|
||||
pers = persona;
|
||||
pers.setPerEstado(DominioConstantes.ACTIVO);
|
||||
pers.setPerFechaRegistro(new Date());
|
||||
pers.setPersonaPolizaCollection(new ArrayList<>());
|
||||
result = this.crearPersonaPoliza(persona, poliza, personaPoliza.getDetTipoPersona());
|
||||
pers.getPersonaPolizaCollection().add(result);
|
||||
daoper.guardar(pers);
|
||||
}
|
||||
data.add(result);
|
||||
} catch (DaoException ex) {
|
||||
throw new DominioExcepcion(ErrorTipo.FATAL, CodigoRespuesta.CODIGO_ERROR_GUARDA_BDD, ex.toString());
|
||||
}
|
||||
System.out.println("========> RETORNAR PERSONA POLIZA " + result);
|
||||
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param dto
|
||||
* @param nueva
|
||||
* @param persona
|
||||
* @return
|
||||
* @throws DominioExcepcion
|
||||
* @throws DaoException
|
||||
*/
|
||||
private PersonaPoliza actualizarBeneficiario(PersonaPoliza dto, Persona nueva, Persona persona, Poliza poliza) throws DominioExcepcion, DaoException {
|
||||
DaoGenerico<Persona, Integer> daoper = new DaoGenerico<>(Persona.class);
|
||||
DaoGenerico<PersonaPoliza, Integer> daoppol = new DaoGenerico<>(PersonaPoliza.class);
|
||||
nueva = daoper.buscarUnico(nueva);
|
||||
|
||||
PersonaPoliza aux = new PersonaPoliza();
|
||||
aux.setPerCodigo(nueva);
|
||||
aux.setPepEstado(DominioConstantes.ACTIVO);
|
||||
if (daoppol.contarExistencias(aux) > 0) {
|
||||
throw new DominioExcepcion(ErrorTipo.FATAL, CodigoRespuesta.CODIGO_ERROR_GUARDA_BDD,
|
||||
"Error la persona ya esta registrada como beneficiario de una poliza");
|
||||
}
|
||||
nueva.setPerApellidos(persona.getPerApellidos());
|
||||
nueva.setPerNombres(persona.getPerNombres());
|
||||
nueva.setPerFechaNacimiento(persona.getPerFechaNacimiento());
|
||||
nueva.setDetGenero(persona.getDetGenero());
|
||||
nueva.setPerNacionalidad(persona.getPerNacionalidad());
|
||||
nueva.setPerMail(persona.getPerMail());
|
||||
nueva.setPerDireccion(persona.getPerDireccion());
|
||||
nueva.setPerEstado(DominioConstantes.ACTIVO);
|
||||
daoper.actualizar(nueva);
|
||||
|
||||
aux = this.crearPersonaPoliza(nueva, poliza, dto.getDetTipoPersona());
|
||||
daoppol.guardar(aux);
|
||||
|
||||
return aux;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param persona
|
||||
* @param poliza
|
||||
* @param tipo
|
||||
* @return
|
||||
*/
|
||||
private PersonaPoliza crearPersonaPoliza(Persona persona, Poliza poliza, DetalleCatalogo tipo) {
|
||||
PersonaPoliza personaPoliza = new PersonaPoliza();
|
||||
personaPoliza.setPolCodigo(poliza);
|
||||
personaPoliza.setPerCodigo(persona);
|
||||
personaPoliza.setDetTipoPersona(tipo);
|
||||
personaPoliza.setPepEstado(DominioConstantes.ACTIVO);
|
||||
personaPoliza.setPepMontoCobertura(poliza.getPlaCodigo().getPlaCoberturaMaxima());
|
||||
return personaPoliza;
|
||||
}
|
||||
|
||||
/**
|
||||
* Permite registrar la persona con los telefonos
|
||||
*
|
||||
* @param header
|
||||
* @param entidades
|
||||
* @param tipoAccion
|
||||
* @return
|
||||
* @throws DominioExcepcion
|
||||
*/
|
||||
@Transactional(Transactional.TxType.REQUIRES_NEW)
|
||||
public List<Persona> procesarPersona(HeaderMS header, List<Map<String, Object>> entidades, int tipoAccion) throws DominioExcepcion {
|
||||
List<Persona> data = new ArrayList<>();
|
||||
for (Map<String, Object> ent : entidades) {
|
||||
PersonaDTO persona = (PersonaDTO) dominioUtil.crearObjeto(PersonaDTO.class, ent);
|
||||
List<TelefonoDTO> lista = new ArrayList<>();
|
||||
List<CuentaBancariaDTO> listaCuentasBancaris = new ArrayList<>();
|
||||
|
||||
ObjectMapper maper = new ObjectMapper();
|
||||
maper.configure(JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES, true);
|
||||
if (ent.containsKey("telefono")) {
|
||||
System.out.println("========> OK TELEFONOS " + ent.get("telefono"));
|
||||
for (Object row : (List<Object>) ent.get("telefono")) {
|
||||
TelefonoDTO col = (TelefonoDTO) dominioUtil.crearObjeto(TelefonoDTO.class, (Map<String, Object>) row);
|
||||
lista.add(col);
|
||||
}
|
||||
}
|
||||
|
||||
if (ent.containsKey("cuentasBancarias")) {
|
||||
System.out.println("========> OK CUENTAS BANCARIAS " + ent.get("cuentasBancarias"));
|
||||
for (Object row : (List<Object>) ent.get("cuentasBancarias")) {
|
||||
CuentaBancariaDTO col = (CuentaBancariaDTO) dominioUtil.crearObjeto(CuentaBancariaDTO.class, (Map<String, Object>) row);
|
||||
listaCuentasBancaris.add(col);
|
||||
}
|
||||
}
|
||||
persona.setCuentasBancarias(listaCuentasBancaris);
|
||||
persona.setTelefono(lista);
|
||||
Persona result = crudPersona(persona, tipoAccion);
|
||||
data.add(result);
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param persona
|
||||
* @param tipoAccion
|
||||
* @return
|
||||
* @throws DominioExcepcion
|
||||
*/
|
||||
@Transactional(Transactional.TxType.REQUIRES_NEW)
|
||||
private Persona generarPersona(PersonaDTO persona) throws DominioExcepcion{
|
||||
DaoGenerico<Persona, Integer> daoper = new DaoGenerico<>(Persona.class);
|
||||
|
||||
Persona result = PersonaMapper.INSTANCE.getEntidad(persona);
|
||||
try {
|
||||
result.setTelefonoCollection(this.crearTelefonos(persona, result));
|
||||
result.setCuentaBancariaCollection(this.crearCuentasBancarias(persona, result));
|
||||
|
||||
|
||||
daoper.guardar(result);
|
||||
} catch (DaoException ex) {
|
||||
throw new DominioExcepcion(ErrorTipo.FATAL, CodigoRespuesta.CODIGO_ERROR_GUARDA_BDD, ex.toString());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@Transactional(Transactional.TxType.REQUIRED)
|
||||
private Persona crudPersona(PersonaDTO persona, int tipoAccion) throws DominioExcepcion {
|
||||
DaoGenerico<Persona, Integer> daoper = new DaoGenerico<>(Persona.class);
|
||||
Persona result;
|
||||
result = PersonaMapper.INSTANCE.getEntidad(persona);
|
||||
switch (tipoAccion) {
|
||||
case CONSULTA: {
|
||||
throw new DominioExcepcion(ErrorTipo.ERROR, CodigoRespuesta.CODIGO_ERROR_GENERICO,
|
||||
"Operacion CONSULTA no soportada para el controlador de Accion");
|
||||
}
|
||||
case GUARDA: {
|
||||
try {
|
||||
if (Objects.equals(DetalleCatalogoEnum.CED.getDetalle().getDetCodigo(), result.getDetTipoIdentificacion().getDetCodigo())) {
|
||||
if (!this.dominioUtil.validarCedula(result.getPerIdentificacion())) {
|
||||
throw new DominioExcepcion(ErrorTipo.ERROR, CodigoRespuesta.CODIGO_ERROR_CONSULTA_BDD,
|
||||
"La c\u00e9dula no cumple la validación de d\u00edgito autoverificador<--\n");
|
||||
}
|
||||
}
|
||||
if (this.validarIndice(daoper, result.getDetTipoIdentificacion(), result.getPerIdentificacion())) {
|
||||
throw new DominioExcepcion(ErrorTipo.FATAL, CodigoRespuesta.CODIGO_ERROR_ACTUALIZA_BDD, "Error, ya existe una persona "
|
||||
+ "con la identificación y tipo de identificación ingresada");
|
||||
}
|
||||
result.setPerFechaRegistro(new Date());
|
||||
result.setPerEstado(DominioConstantes.ACTIVO);
|
||||
result.setTelefonoCollection(this.crearTelefonos(persona, result));
|
||||
result.setCuentaBancariaCollection(this.crearCuentasBancarias(persona, result));
|
||||
|
||||
daoper.guardar(result);
|
||||
} catch (DaoException ex) {
|
||||
throw new DominioExcepcion(ErrorTipo.FATAL, CodigoRespuesta.CODIGO_ERROR_GUARDA_BDD, ex.toString());
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ACTUALIZA: {
|
||||
try {
|
||||
result = this.actualizarPersona(daoper, result, persona);
|
||||
} catch (DaoException ex) {
|
||||
throw new DominioExcepcion(ErrorTipo.FATAL, CodigoRespuesta.CODIGO_ERROR_ACTUALIZA_BDD, ex.toString());
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ELIMINA: {
|
||||
throw new DominioExcepcion(ErrorTipo.ERROR, CodigoRespuesta.CODIGO_ERROR_GENERICO,
|
||||
"Operacion ELIMINACION aun no permitida");
|
||||
}
|
||||
case CANCELA: {
|
||||
throw new DominioExcepcion(ErrorTipo.ERROR, CodigoRespuesta.CODIGO_ERROR_GENERICO,
|
||||
"Operacion CANCELAR aun no permitida");
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param daoper
|
||||
* @param result
|
||||
* @return
|
||||
* @throws DominioExcepcion
|
||||
*/
|
||||
private Persona actualizarPersona(DaoGenerico<Persona, Integer> daoper, Persona result, PersonaDTO persona) throws DominioExcepcion, DaoException {
|
||||
DaoGenerico<Telefono, Integer> daotel = new DaoGenerico<>(Telefono.class);
|
||||
DaoGenerico<Usuario, Integer> daousu = new DaoGenerico<>(Usuario.class);
|
||||
DaoGenerico<CuentaBancaria, Integer> daocueban = new DaoGenerico<>(CuentaBancaria.class);
|
||||
|
||||
if (Objects.equals(DetalleCatalogoEnum.CED.getDetalle().getDetCodigo(), result.getDetTipoIdentificacion().getDetCodigo())) {
|
||||
if (!this.dominioUtil.validarCedula(result.getPerIdentificacion())) {
|
||||
throw new DominioExcepcion(ErrorTipo.ERROR, CodigoRespuesta.CODIGO_ERROR_CONSULTA_BDD,
|
||||
"La c\u00e9dula no cumple la validacion de d\u00edgito autoverificador<--\n");
|
||||
}
|
||||
}
|
||||
result.setTelefonoCollection(this.crearTelefonos(persona, result));
|
||||
for (Telefono telf : result.getTelefonoCollection()) {
|
||||
if (telf.getTelCodigo() != null) {
|
||||
daotel.actualizar(telf);
|
||||
} else {
|
||||
daotel.guardar(telf);
|
||||
}
|
||||
}
|
||||
result.setCuentaBancariaCollection(this.crearCuentasBancarias(persona, result));
|
||||
for (CuentaBancaria cuenBan : result.getCuentaBancariaCollection()) {
|
||||
if (cuenBan.getCueCodigo() != null) {
|
||||
System.out.println("ACTUALIZAR CUENTA " + cuenBan.getCueEstado() + " > " + cuenBan.getCueCodigo());
|
||||
daocueban.actualizar(cuenBan);
|
||||
} else {
|
||||
System.out.println("GUARDAR CUENTA " + cuenBan.getCueEstado() + " > " + cuenBan.getCueCuenta());
|
||||
daocueban.guardar(cuenBan);
|
||||
}
|
||||
}
|
||||
Persona prev = daoper.cargar(persona.getPerCodigo());
|
||||
String iden = prev != null ? prev.getPerIdentificacion() : "";
|
||||
result = daoper.actualizar(result);
|
||||
|
||||
Usuario usu = new Usuario();
|
||||
usu.setUsuOrigen(DominioConstantes.PERSONA);
|
||||
usu.setUsuIdOrigen("" + result.getPerCodigo());
|
||||
usu.setUsuUsuario(iden);
|
||||
usu.setUsuEstado(DominioConstantes.ACTIVO);
|
||||
usu = daousu.buscarUnico(usu); ///Que pasa si tiene mas de un usuario??
|
||||
if (usu != null && usu.getUsuCodigo() != null) {
|
||||
usu.setUsuEmail(result.getPerMail());
|
||||
if (iden != null && !iden.equalsIgnoreCase(result.getPerIdentificacion())) {
|
||||
for (PersonaPoliza perpol : result.getPersonaPolizaCollection()) {
|
||||
if (perpol.getDetTipoPersona().getDetNemonico().equals(DetalleCatalogoEnum.PTITU.name())
|
||||
&& !usu.getUsuUsuario().equals(result.getPerIdentificacion())) {
|
||||
usu.setUsuUsuario(result.getPerIdentificacion());
|
||||
}
|
||||
}
|
||||
daousu.actualizar(usu);
|
||||
}
|
||||
} else {
|
||||
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param daoper
|
||||
* @param tipoID
|
||||
* @param identificacion
|
||||
* @return
|
||||
* @throws DaoException
|
||||
*/
|
||||
private boolean validarIndice(DaoGenerico<Persona, Integer> daoper, DetalleCatalogo tipoID, String identificacion) throws DaoException {
|
||||
Persona verifi = new Persona();
|
||||
verifi.setPerIdentificacion(identificacion);
|
||||
verifi.setDetTipoIdentificacion(tipoID);
|
||||
return daoper.contarExistencias(verifi) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param personaDTO
|
||||
* @return
|
||||
* @throws DaoException
|
||||
*/
|
||||
private List<Telefono> crearTelefonos(PersonaDTO personaDTO, Persona persona) {
|
||||
List<Telefono> data = new ArrayList<>();
|
||||
for (TelefonoDTO telf : personaDTO.getTelefono()) {
|
||||
Telefono telefono = (Telefono) dominioUtil.getEntidad(EntidadEnum.Telefono.getMapper(), telf);
|
||||
telefono.setPerCodigo(persona);
|
||||
data.add(telefono);
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
private List<CuentaBancaria> crearCuentasBancarias(PersonaDTO personaDTO, Persona persona) {
|
||||
List<CuentaBancaria> data = new ArrayList<>();
|
||||
for (CuentaBancariaDTO cuen : personaDTO.getCuentasBancarias()) {
|
||||
CuentaBancaria cuentaBancaria = (CuentaBancaria) dominioUtil.getEntidad(EntidadEnum.CuentaBancaria.getMapper(), cuen);
|
||||
if (cuentaBancaria.getCueIdentificacion() == null || cuentaBancaria.getCueIdentificacion().isBlank()) {
|
||||
cuentaBancaria.setCueIdentificacion(persona.getPerIdentificacion());
|
||||
}
|
||||
if (cuentaBancaria.getCueNombreDebito() == null || cuentaBancaria.getCueNombreDebito().isBlank()) {
|
||||
cuentaBancaria.setCueNombreDebito(persona.getPerNombres() + " " + persona.getPerApellidos());
|
||||
}
|
||||
cuentaBancaria.setPerCodigo(persona);
|
||||
data.add(cuentaBancaria);
|
||||
}
|
||||
return data;
|
||||
}
|
||||
@Transactional(Transactional.TxType.REQUIRES_NEW)
|
||||
public Persona crearPersonaDTOCsv(String genero,String locCodigo, String tipoIdentificacion,String perIdentificacion, String perNombres, String perApellidos, String perMail, String fechaNacimiento,
|
||||
String telefono,String detIfi,String detTipoCuenta, String cueIdentificacion, String cueCuenta, String cueNombreDebito, Short cueDebito, DaoGenerico<Persona, Integer> daoper
|
||||
, DaoGenerico<Telefono, Integer> daotel, DaoGenerico<CuentaBancaria, Integer> daocuen) throws DaoException, DominioExcepcion{
|
||||
PersonaDTO personaDTO = crearPersonaDTO(catalogoUtil.getDetallePorOrigenTipo(genero, "GENERO").getDetCodigo(), catalogoUtil.getDetallePorOrigenTipo(tipoIdentificacion, "IDENTIFICACION").getDetCodigo(),
|
||||
locCodigo, perIdentificacion, perNombres, perApellidos, DominioConstantes.NACIONALIDAD, DominioConstantes.ACTUALIZAR, perMail, DominioConstantes.getDate(fechaNacimiento), null, null);
|
||||
List<TelefonoDTO> lstTelefonos = new ArrayList<>();
|
||||
List<CuentaBancariaDTO> lstCuentas = new ArrayList<>();
|
||||
|
||||
/**-------------------------------------------------telefono------------------------------------------------*/
|
||||
if(telefono != null){
|
||||
String []telefonos = telefono.split(",");
|
||||
for (int i = 0; i < telefonos.length; i++) {
|
||||
if(telefonos[i].length() == 10){
|
||||
lstTelefonos.add(crearTelefonoDTO(catalogoUtil.getDetallePorNemonico("MOVIL").getDetCodigo(), telefonos[i], DominioConstantes.DATO_MASIVO_POLIZA));
|
||||
}else if(telefonos[i].length() == 7 || (telefonos[i].length() == 9 && telefonos[i].startsWith("02"))){
|
||||
lstTelefonos.add(crearTelefonoDTO(catalogoUtil.getDetallePorNemonico("CASA").getDetCodigo(), telefonos[i], DominioConstantes.DATO_MASIVO_POLIZA));
|
||||
}else {
|
||||
lstTelefonos.add(crearTelefonoDTO(catalogoUtil.getDetallePorNemonico("TELEF").getDetCodigo(), telefonos[i], DominioConstantes.DATO_MASIVO_POLIZA));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
/**-------------------------------------------------CuentaBancaria------------------------------------------------*/
|
||||
CuentaBancaria cB = null;
|
||||
if(cueCuenta != null){
|
||||
if(cueCuenta.trim().equals("") || cueCuenta.equals("000") || cueCuenta.equals("0")){
|
||||
cueDebito = DominioConstantes.INACTIVO;
|
||||
}
|
||||
|
||||
lstCuentas.add(crearCuentaBancariaDTO(catalogoUtil.getDetallePorNemonico(detIfi).getDetCodigo() , catalogoUtil.getDetallePorOrigenTipo(detTipoCuenta, "TIPOCUEN").getDetCodigo(), cueIdentificacion,
|
||||
cueCuenta, cueNombreDebito, cueDebito));
|
||||
}
|
||||
|
||||
personaDTO.setTelefono(lstTelefonos);
|
||||
personaDTO.setCuentasBancarias(lstCuentas);
|
||||
Persona persona = generarPersona(personaDTO);
|
||||
|
||||
return persona;
|
||||
}
|
||||
|
||||
public CuentaBancariaDTO crearCuentaBancariaDTO(Integer detIfi,Integer detTipoCuenta, String cueIdentificacion, String cueCuenta, String cueNombreDebito, Short cueDebito){
|
||||
CuentaBancariaDTO cuentaBancariaDTO = new CuentaBancariaDTO();
|
||||
cuentaBancariaDTO.setDetIfi(detIfi);
|
||||
cuentaBancariaDTO.setDetTipoCuenta(detTipoCuenta);
|
||||
cuentaBancariaDTO.setCueIdentificacion(cueIdentificacion);
|
||||
cuentaBancariaDTO.setCueCuenta(cueCuenta);
|
||||
cuentaBancariaDTO.setCueNombreDebito(cueNombreDebito);
|
||||
cuentaBancariaDTO.setCueDebito(cueDebito);
|
||||
cuentaBancariaDTO.setCueEstado(DominioConstantes.ACTIVO);
|
||||
return cuentaBancariaDTO;
|
||||
}
|
||||
public TelefonoDTO crearTelefonoDTO(Integer detTipo,String telNumero, String telObservacion){
|
||||
TelefonoDTO telefonoDTO = new TelefonoDTO();
|
||||
telefonoDTO.setDetTipo(detTipo);
|
||||
telefonoDTO.setTelNumero(telNumero);
|
||||
telefonoDTO.setTelObservacion(telObservacion);
|
||||
telefonoDTO.setTelEstado(DominioConstantes.ACTIVO);
|
||||
return telefonoDTO;
|
||||
}
|
||||
|
||||
public Persona crearPersona(DetalleCatalogo detEstadoPoliza, DetalleCatalogo detGenero, DetalleCatalogo detTipoIdentificacion, Localizacion locCodigo, String perIdentificacion,
|
||||
String perNombres, String perApellidos, String perNacionalidad, String perDireccion, String perMail, Date perFechaNacimiento,String perDinamico, Integer perIdOdo){
|
||||
|
||||
Persona persona = new Persona();
|
||||
persona.setDetEstadoPoliza(detEstadoPoliza);
|
||||
persona.setDetGenero(detGenero);
|
||||
persona.setDetTipoIdentificacion(detTipoIdentificacion);
|
||||
persona.setLocCodigo(locCodigo);
|
||||
persona.setPerIdentificacion(perIdentificacion);
|
||||
persona.setPerNombres(perNombres);
|
||||
persona.setPerApellidos(perApellidos);
|
||||
persona.setPerNacionalidad(perNacionalidad);
|
||||
persona.setPerDireccion(perDireccion);
|
||||
persona.setPerMail(perMail);
|
||||
persona.setPerFechaRegistro(new Date());
|
||||
persona.setPerFechaNacimiento(perFechaNacimiento);
|
||||
persona.setPerDinamico(perDinamico);
|
||||
persona.setPerIdOdo(perIdOdo);
|
||||
persona.setPerEstado(DominioConstantes.ACTIVO);
|
||||
return persona;
|
||||
}
|
||||
public PersonaDTO crearPersonaDTO(Integer detGenero, Integer detTipoIdentificacion,String locCodigo, String perIdentificacion, String perNombres, String perApellidos, String perNacionalidad, String perDireccion,String perMail, Date perFechaNacimiento, String perDinamico, Integer perIdOdo){
|
||||
PersonaDTO personaDTO = new PersonaDTO();
|
||||
personaDTO.setDetEstadoPoliza(catalogoUtil.getDetallePorNemonico("NOBK").getDetCodigo());
|
||||
personaDTO.setDetGenero(detGenero);
|
||||
personaDTO.setDetTipoIdentificacion(detTipoIdentificacion);
|
||||
personaDTO.setLocCodigo(locCodigo);
|
||||
personaDTO.setPerIdentificacion(perIdentificacion);
|
||||
personaDTO.setPerNombres(perNombres);
|
||||
personaDTO.setPerApellidos(perApellidos);
|
||||
personaDTO.setPerNacionalidad(perNacionalidad);
|
||||
personaDTO.setPerDireccion(perDireccion);
|
||||
personaDTO.setPerMail(perMail);
|
||||
personaDTO.setPerFechaRegistro(new Date());
|
||||
personaDTO.setPerFechaNacimiento(perFechaNacimiento);
|
||||
personaDTO.setPerDinamico(perDinamico);
|
||||
personaDTO.setPerIdOdo(perIdOdo);
|
||||
personaDTO.setPerEstado(DominioConstantes.ACTIVO);
|
||||
return personaDTO;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,335 @@
|
|||
package com.qsoft.erp.dominio.util;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonParser;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.qsoft.dao.exception.DaoException;
|
||||
import com.qsoft.erp.constantes.DetalleCatalogoEnum;
|
||||
import com.qsoft.erp.constantes.DominioConstantes;
|
||||
import com.qsoft.erp.constantes.EntidadEnum;
|
||||
import com.qsoft.util.constantes.CodigoRespuesta;
|
||||
import com.qsoft.util.constantes.ErrorTipo;
|
||||
import com.qsoft.erp.dao.DaoGenerico;
|
||||
import com.qsoft.erp.dominio.exception.DominioExcepcion;
|
||||
import com.qsoft.erp.dto.PersonaDTO;
|
||||
import com.qsoft.erp.model.Persona;
|
||||
import com.qsoft.util.ms.pojo.HeaderMS;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.ejb.EJB;
|
||||
import javax.ejb.Stateless;
|
||||
import javax.transaction.Transactional;
|
||||
|
||||
import static com.qsoft.erp.dominio.AccionGenerica.ACTUALIZA;
|
||||
import static com.qsoft.erp.dominio.AccionGenerica.CONSULTA;
|
||||
import static com.qsoft.erp.dominio.AccionGenerica.ELIMINA;
|
||||
import static com.qsoft.erp.dominio.AccionGenerica.GUARDA;
|
||||
import static com.qsoft.erp.dominio.AccionGenerica.CANCELA;
|
||||
import com.qsoft.erp.dominio.mapper.PersonaPolizaMapper;
|
||||
import com.qsoft.erp.dominio.mapper.PlanMapper;
|
||||
import com.qsoft.erp.dto.CoberturasPlanDTO;
|
||||
import com.qsoft.erp.dto.CuentaBancariaDTO;
|
||||
import com.qsoft.erp.dto.PersonaPolizaDTO;
|
||||
import com.qsoft.erp.dto.PlanDTO;
|
||||
import com.qsoft.erp.model.CoberturasPlan;
|
||||
import com.qsoft.erp.model.CuentaBancaria;
|
||||
import com.qsoft.erp.model.DetalleCatalogo;
|
||||
import com.qsoft.erp.model.Empresa;
|
||||
import com.qsoft.erp.model.PersonaPoliza;
|
||||
import com.qsoft.erp.model.Plan;
|
||||
import com.qsoft.erp.model.PlanBroker;
|
||||
import com.qsoft.erp.model.Poliza;
|
||||
import com.qsoft.erp.model.Usuario;
|
||||
import java.util.Objects;
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @author christian
|
||||
*/
|
||||
@Stateless
|
||||
public class PlanUtil {
|
||||
|
||||
@EJB
|
||||
private DominioUtil dominioUtil;
|
||||
|
||||
@PostConstruct
|
||||
public void postConstruct() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param header
|
||||
* @param entidades
|
||||
* @param tipoAccion
|
||||
* @return
|
||||
* @throws DominioExcepcion
|
||||
*/
|
||||
@Transactional(Transactional.TxType.REQUIRED)
|
||||
public List<PersonaPoliza> crearPersonaPoliza(HeaderMS header, List<Map<String, Object>> entidades, int tipoAccion) throws DominioExcepcion {
|
||||
List<PersonaPoliza> data = new ArrayList<>();
|
||||
for (Map<String, Object> ent : entidades) {
|
||||
PersonaPoliza personaPoliza = (PersonaPoliza) dominioUtil.getEntidad(
|
||||
PersonaPolizaMapper.class, dominioUtil.crearObjeto(PersonaPolizaDTO.class, ent));
|
||||
PersonaPoliza result = null;
|
||||
try {
|
||||
Persona persona = personaPoliza.getPerCodigo();
|
||||
if (Objects.equals(DetalleCatalogoEnum.CED.getDetalle().getDetCodigo(), persona.getDetTipoIdentificacion().getDetCodigo())) {
|
||||
if (!this.dominioUtil.validarCedula(persona.getPerIdentificacion())) {
|
||||
throw new DominioExcepcion(ErrorTipo.ERROR, CodigoRespuesta.CODIGO_ERROR_CONSULTA_BDD,
|
||||
"La c\u00e9dula no cumple la validacion de d\u00edgito autoverificador<--\n");
|
||||
}
|
||||
}
|
||||
DaoGenerico<Poliza, Integer> daopol = new DaoGenerico<>(Poliza.class);
|
||||
DaoGenerico<Persona, Integer> daoper = new DaoGenerico<>(Persona.class);
|
||||
Poliza poliza = daopol.cargar(personaPoliza.getPolCodigo().getPolCodigo());
|
||||
Persona pers = new Persona();
|
||||
pers.setPerIdentificacion(persona.getPerIdentificacion());
|
||||
pers.setDetTipoIdentificacion(persona.getDetTipoIdentificacion());
|
||||
if (daoper.contarExistencias(pers) > 0) {
|
||||
result = this.actualizarBeneficiario(personaPoliza, pers, persona, poliza);
|
||||
} else {
|
||||
pers = persona;
|
||||
pers.setPerEstado(DominioConstantes.ACTIVO);
|
||||
pers.setPerFechaRegistro(new Date());
|
||||
pers.setPersonaPolizaCollection(new ArrayList<>());
|
||||
result = this.crearPersonaPoliza(persona, poliza, personaPoliza.getDetTipoPersona());
|
||||
pers.getPersonaPolizaCollection().add(result);
|
||||
daoper.guardar(pers);
|
||||
}
|
||||
data.add(result);
|
||||
} catch (DaoException ex) {
|
||||
throw new DominioExcepcion(ErrorTipo.FATAL, CodigoRespuesta.CODIGO_ERROR_GUARDA_BDD, ex.toString());
|
||||
}
|
||||
System.out.println("========> RETORNAR PERSONA POLIZA " + result);
|
||||
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param dto
|
||||
* @param nueva
|
||||
* @param persona
|
||||
* @return
|
||||
* @throws DominioExcepcion
|
||||
* @throws DaoException
|
||||
*/
|
||||
private PersonaPoliza actualizarBeneficiario(PersonaPoliza dto, Persona nueva, Persona persona, Poliza poliza) throws DominioExcepcion, DaoException {
|
||||
DaoGenerico<Persona, Integer> daoper = new DaoGenerico<>(Persona.class);
|
||||
DaoGenerico<PersonaPoliza, Integer> daoppol = new DaoGenerico<>(PersonaPoliza.class);
|
||||
nueva = daoper.buscarUnico(nueva);
|
||||
|
||||
PersonaPoliza aux = new PersonaPoliza();
|
||||
aux.setPerCodigo(nueva);
|
||||
aux.setPepEstado(DominioConstantes.ACTIVO);
|
||||
if (daoppol.contarExistencias(aux) > 0) {
|
||||
throw new DominioExcepcion(ErrorTipo.FATAL, CodigoRespuesta.CODIGO_ERROR_GUARDA_BDD,
|
||||
"Error la persona ya esta registrada como beneficiario de una poliza");
|
||||
}
|
||||
nueva.setPerApellidos(persona.getPerApellidos());
|
||||
nueva.setPerNombres(persona.getPerNombres());
|
||||
nueva.setPerFechaNacimiento(persona.getPerFechaNacimiento());
|
||||
nueva.setDetGenero(persona.getDetGenero());
|
||||
nueva.setPerNacionalidad(persona.getPerNacionalidad());
|
||||
nueva.setPerMail(persona.getPerMail());
|
||||
nueva.setPerDireccion(persona.getPerDireccion());
|
||||
nueva.setPerEstado(DominioConstantes.ACTIVO);
|
||||
daoper.actualizar(nueva);
|
||||
|
||||
aux = this.crearPersonaPoliza(nueva, poliza, dto.getDetTipoPersona());
|
||||
daoppol.guardar(aux);
|
||||
|
||||
return aux;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param persona
|
||||
* @param poliza
|
||||
* @param tipo
|
||||
* @return
|
||||
*/
|
||||
private PersonaPoliza crearPersonaPoliza(Persona persona, Poliza poliza, DetalleCatalogo tipo) {
|
||||
PersonaPoliza personaPoliza = new PersonaPoliza();
|
||||
personaPoliza.setPolCodigo(poliza);
|
||||
personaPoliza.setPerCodigo(persona);
|
||||
personaPoliza.setDetTipoPersona(tipo);
|
||||
personaPoliza.setPepEstado(DominioConstantes.ACTIVO);
|
||||
personaPoliza.setPepMontoCobertura(poliza.getPlaCodigo().getPlaCoberturaMaxima());
|
||||
return personaPoliza;
|
||||
}
|
||||
public Plan getPlanPorCodigo(Integer plaCodigo) {
|
||||
DaoGenerico<Plan, Integer> generico = new DaoGenerico<>(Plan.class);
|
||||
Plan plan = null;
|
||||
try {
|
||||
plan = new Plan();
|
||||
plan.setPlaCodigo(plaCodigo);
|
||||
plan = generico.buscarUnico(plan);
|
||||
} catch (DaoException ex) {
|
||||
plan = null;
|
||||
}
|
||||
return plan;
|
||||
}
|
||||
/**
|
||||
* Permite registrar la persona con los telefonos
|
||||
*
|
||||
* @param header
|
||||
* @param entidades
|
||||
* @param tipoAccion
|
||||
* @return
|
||||
* @throws DominioExcepcion
|
||||
*/
|
||||
@Transactional(Transactional.TxType.REQUIRED)
|
||||
public List<Plan> procesarPlan(HeaderMS header, List<Map<String, Object>> entidades, int tipoAccion) throws DominioExcepcion {
|
||||
List<Plan> data = new ArrayList<>();
|
||||
for (Map<String, Object> ent : entidades) {
|
||||
PlanDTO plan = (PlanDTO) dominioUtil.crearObjeto(PlanDTO.class, ent);
|
||||
List<CoberturasPlanDTO> lista = new ArrayList<>();
|
||||
|
||||
ObjectMapper maper = new ObjectMapper();
|
||||
maper.configure(JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES, true);
|
||||
if (ent.containsKey("coberturasPlan")) {
|
||||
System.out.println("========> OK COBERTURAS PLAN: " + ent.get("coberturasPlan"));
|
||||
for (Object row : (List<Object>) ent.get("coberturasPlan")) {
|
||||
CoberturasPlanDTO col = (CoberturasPlanDTO) dominioUtil.crearObjeto(CoberturasPlanDTO.class, (Map<String, Object>) row);
|
||||
lista.add(col);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
plan.setCoberturasPlan(lista);
|
||||
Plan result = crudPlan(plan, tipoAccion);
|
||||
data.add(result);
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param plan
|
||||
* @param tipoAccion
|
||||
* @return
|
||||
* @throws DominioExcepcion
|
||||
*/
|
||||
@Transactional(Transactional.TxType.SUPPORTS)
|
||||
private Plan crudPlan(PlanDTO plan, int tipoAccion) throws DominioExcepcion {
|
||||
DaoGenerico<Plan, Integer> daopla = new DaoGenerico<>(Plan.class);
|
||||
Plan result;
|
||||
result = PlanMapper.INSTANCE.getEntidad(plan);
|
||||
|
||||
|
||||
switch (tipoAccion) {
|
||||
case CONSULTA: {
|
||||
throw new DominioExcepcion(ErrorTipo.ERROR, CodigoRespuesta.CODIGO_ERROR_GENERICO,
|
||||
"Operacion CONSULTA no soportada para el controlador de Accion");
|
||||
}
|
||||
case GUARDA: {
|
||||
try {
|
||||
result.setPlaEstado(DominioConstantes.ACTIVO);
|
||||
result.setCoberturasPlanCollection(this.crearCoberturasPlan(plan, result));
|
||||
if(plan.getPlaBroker() != null){
|
||||
result.setPlanBrokerCollection(this.procesaPlanBrokers(plan, result));
|
||||
}
|
||||
daopla.guardar(result);
|
||||
} catch (DaoException ex) {
|
||||
throw new DominioExcepcion(ErrorTipo.FATAL, CodigoRespuesta.CODIGO_ERROR_GUARDA_BDD, ex.toString());
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ACTUALIZA: {
|
||||
try {
|
||||
DaoGenerico<CoberturasPlan, Integer> daotel = new DaoGenerico<>(CoberturasPlan.class);
|
||||
DaoGenerico<Usuario, Integer> daousu = new DaoGenerico<>(Usuario.class);
|
||||
DaoGenerico<CuentaBancaria, Integer> daocueban = new DaoGenerico<>(CuentaBancaria.class);
|
||||
result.setCoberturasPlanCollection(this.crearCoberturasPlan(plan, result));
|
||||
|
||||
for (CoberturasPlan cobplan : result.getCoberturasPlanCollection()) {
|
||||
if (cobplan.getCopCodigo() != null) {
|
||||
daotel.actualizar(cobplan);
|
||||
} else {
|
||||
daotel.guardar(cobplan);
|
||||
}
|
||||
}
|
||||
|
||||
result = daopla.actualizar(result);
|
||||
|
||||
} catch (DaoException ex) {
|
||||
throw new DominioExcepcion(ErrorTipo.FATAL, CodigoRespuesta.CODIGO_ERROR_ACTUALIZA_BDD, ex.toString());
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ELIMINA: {
|
||||
throw new DominioExcepcion(ErrorTipo.ERROR, CodigoRespuesta.CODIGO_ERROR_GENERICO,
|
||||
"Operacion ELIMINACION aun no permitida");
|
||||
}
|
||||
case CANCELA: {
|
||||
throw new DominioExcepcion(ErrorTipo.ERROR, CodigoRespuesta.CODIGO_ERROR_GENERICO,
|
||||
"Operacion CANCELAR aun no permitida");
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param personaDTO
|
||||
* @return
|
||||
* @throws DaoException
|
||||
*/
|
||||
private List<PlanBroker> procesaPlanBrokers(PlanDTO planDTO, Plan plan) throws DaoException, DominioExcepcion{
|
||||
List<PlanBroker> data = new ArrayList<>();
|
||||
DaoGenerico<Empresa,Integer> daoEmp = new DaoGenerico<>(Empresa.class);
|
||||
Empresa plantillaEmpresa = new Empresa();
|
||||
plantillaEmpresa.setEmpCodigo(planDTO.getPlaBroker());
|
||||
plantillaEmpresa.setEmpEstado(DominioConstantes.ACTIVO);
|
||||
Empresa empresaRetornar = daoEmp.buscarUnico(plantillaEmpresa);
|
||||
|
||||
if(empresaRetornar == null){
|
||||
throw new DominioExcepcion(ErrorTipo.ERROR, CodigoRespuesta.CODIGO_ERROR_GENERICO, "Error, broker enviado no encontrado");
|
||||
}
|
||||
PlanBroker plb = crearPlanBroker(empresaRetornar, plan, null, null, plan.getPlaNombre());
|
||||
data.add(plb);
|
||||
return data;
|
||||
}
|
||||
public PlanBroker crearPlanBroker(Empresa empCodigo, Plan plan, Double descuento, Double oferta, String observacion){
|
||||
PlanBroker planBroker = new PlanBroker();
|
||||
planBroker.setEmpCodigo(empCodigo);
|
||||
planBroker.setPlaCodigo(plan);
|
||||
planBroker.setPlbDescuento(descuento);
|
||||
planBroker.setPlbOferta(oferta);
|
||||
planBroker.setPlbObservacion(observacion);
|
||||
planBroker.setPlbEstado(DominioConstantes.ACTIVO);
|
||||
return planBroker;
|
||||
|
||||
}
|
||||
private List<CoberturasPlan> crearCoberturasPlan(PlanDTO personaDTO, Plan plan) {
|
||||
List<CoberturasPlan> data = new ArrayList<>();
|
||||
for (CoberturasPlanDTO cobpla : personaDTO.getCoberturasPlan()) {
|
||||
CoberturasPlan coberturasPlan = (CoberturasPlan) dominioUtil.getEntidad(EntidadEnum.CoberturasPlan.getMapper(), cobpla);
|
||||
|
||||
coberturasPlan.setPlaCodigo(plan);
|
||||
data.add(coberturasPlan);
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
private List<CuentaBancaria> crearCuentasBancarias(PersonaDTO personaDTO, Persona persona) {
|
||||
List<CuentaBancaria> data = new ArrayList<>();
|
||||
for (CuentaBancariaDTO cuen : personaDTO.getCuentasBancarias()) {
|
||||
CuentaBancaria cuentaBancaria = (CuentaBancaria) dominioUtil.getEntidad(EntidadEnum.CuentaBancaria.getMapper(), cuen);
|
||||
cuentaBancaria.setPerCodigo(persona);
|
||||
data.add(cuentaBancaria);
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,862 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.qsoft.erp.dominio.util;
|
||||
|
||||
import com.qsoft.dao.exception.DaoException;
|
||||
import com.qsoft.erp.constantes.DetalleCatalogoEnum;
|
||||
import com.qsoft.erp.constantes.DominioConstantes;
|
||||
import com.qsoft.erp.dao.DaoGenerico;
|
||||
import static com.qsoft.erp.dominio.AccionGenerica.ACTUALIZA;
|
||||
import static com.qsoft.erp.dominio.AccionGenerica.CANCELA;
|
||||
import static com.qsoft.erp.dominio.AccionGenerica.ELIMINA;
|
||||
import static com.qsoft.erp.dominio.AccionGenerica.GUARDA;
|
||||
import com.qsoft.erp.dominio.exception.DominioExcepcion;
|
||||
import com.qsoft.erp.dominio.mapper.PersonaPolizaMapper;
|
||||
import com.qsoft.erp.dominio.mapper.PolizaMapper;
|
||||
import com.qsoft.erp.dto.PersonaPolizaDTO;
|
||||
import com.qsoft.erp.constantes.SecuenciaEnum;
|
||||
import com.qsoft.erp.dto.PolizaDTO;
|
||||
import com.qsoft.erp.model.CuentaBancaria;
|
||||
import com.qsoft.erp.model.DetalleCatalogo;
|
||||
import com.qsoft.erp.model.Empresa;
|
||||
import com.qsoft.erp.model.EstadoPoliza;
|
||||
import com.qsoft.erp.model.Localizacion;
|
||||
import com.qsoft.erp.model.Pago;
|
||||
import com.qsoft.erp.model.Persona;
|
||||
import com.qsoft.erp.model.PersonaPoliza;
|
||||
import com.qsoft.erp.model.Plan;
|
||||
import com.qsoft.erp.model.Poliza;
|
||||
import com.qsoft.erp.model.Rol;
|
||||
import com.qsoft.erp.model.RolUsuario;
|
||||
import com.qsoft.erp.model.Usuario;
|
||||
import com.qsoft.erp.model.UsuarioPassword;
|
||||
import com.qsoft.util.constantes.CodigoRespuesta;
|
||||
import com.qsoft.util.constantes.ErrorTipo;
|
||||
import com.qsoft.util.ms.pojo.HeaderMS;
|
||||
import java.io.IOException;
|
||||
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 java.util.Objects;
|
||||
import javax.ejb.EJB;
|
||||
import javax.ejb.Stateless;
|
||||
import javax.transaction.Transactional;
|
||||
import javax.xml.datatype.DatatypeConfigurationException;
|
||||
import org.apache.commons.lang3.RandomStringUtils;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author james
|
||||
*/
|
||||
@Stateless
|
||||
public class PolizaUtil {
|
||||
|
||||
private static final int MESES = 12;
|
||||
|
||||
@EJB
|
||||
private DominioUtil dominioUtil;
|
||||
|
||||
@EJB
|
||||
private NotificadorUtil notificadorUtil;
|
||||
|
||||
@EJB
|
||||
private SecuenciaUtil contabilidadUtil;
|
||||
@EJB
|
||||
private CatalogoUtil catalogoUtil;
|
||||
/**
|
||||
* @param header
|
||||
* @param entidades
|
||||
* @param tipoAccion
|
||||
* @return
|
||||
* @throws com.qsoft.erp.dominio.exception.DominioExcepcion
|
||||
*/
|
||||
@Transactional(Transactional.TxType.REQUIRES_NEW)
|
||||
public List<Poliza> procesarPoliza(HeaderMS header, List<Map<String, Object>> entidades, int tipoAccion) throws DominioExcepcion, IOException {
|
||||
DaoGenerico<Usuario, Integer> daousu = new DaoGenerico<>(Usuario.class);
|
||||
List<Poliza> data = new ArrayList<>();
|
||||
Usuario user = new Usuario();
|
||||
user.setUsuUsuario(header.getUsuario());
|
||||
user.setUsuEstado(DominioConstantes.ACTIVO);
|
||||
try {
|
||||
user = daousu.buscarUnico(user);
|
||||
} catch (DaoException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
for (Map<String, Object> ent : entidades) {
|
||||
PolizaDTO poliza = (PolizaDTO) dominioUtil.crearObjeto(PolizaDTO.class, ent);
|
||||
Poliza result = crudPoliza(poliza, user, tipoAccion);
|
||||
data.add(result);
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param poliza
|
||||
* @param tipoAccion
|
||||
* @return
|
||||
* @throws DominioExcepcion
|
||||
*/
|
||||
@Transactional(Transactional.TxType.REQUIRES_NEW)
|
||||
private Poliza crudPoliza(PolizaDTO poliza, Usuario user, int tipoAccion) throws DominioExcepcion, IOException {
|
||||
Poliza result;
|
||||
result = PolizaMapper.INSTANCE.getEntidad(poliza);
|
||||
switch (tipoAccion) {
|
||||
case com.qsoft.erp.dominio.AccionGenerica.CONSULTA: {
|
||||
throw new DominioExcepcion(ErrorTipo.ERROR, CodigoRespuesta.CODIGO_ERROR_GENERICO,
|
||||
"Operacion CONSULTA no soportada para el controlador de Accion");
|
||||
}
|
||||
case GUARDA: {
|
||||
result = this.crearPoliza(poliza, user);
|
||||
}
|
||||
break;
|
||||
case ACTUALIZA: {
|
||||
|
||||
try {
|
||||
|
||||
result = this.registrarPoliza(null, poliza, user, true);
|
||||
} catch (DaoException ex) {
|
||||
throw new DominioExcepcion(ErrorTipo.ERROR, CodigoRespuesta.CODIGO_ERROR_ACTUALIZA_BDD,
|
||||
"Error intentando actualizar la poliza: " + ex);
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
case ELIMINA: {
|
||||
throw new DominioExcepcion(ErrorTipo.ERROR, CodigoRespuesta.CODIGO_ERROR_GENERICO,
|
||||
"Operacion ELIMINACION aun no permitida");
|
||||
}
|
||||
case CANCELA: {
|
||||
throw new DominioExcepcion(ErrorTipo.ERROR, CodigoRespuesta.CODIGO_ERROR_GENERICO,
|
||||
"Operacion CANCELAR aun no permitida");
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param poliza
|
||||
* @return
|
||||
* @throws com.qsoft.erp.dominio.exception.DominioExcepcion
|
||||
*/
|
||||
public void validarEstadoCreado(PolizaDTO poliza) throws DaoException, DominioExcepcion{
|
||||
DaoGenerico<EstadoPoliza,Integer> daoestpol = new DaoGenerico<>(EstadoPoliza.class);
|
||||
EstadoPoliza estadoAntiguo = this.buscarUltimoEstadoActivoPolCodigo(poliza.getPolCodigo(), daoestpol);
|
||||
if(Objects.equals(estadoAntiguo.getDetEstado().getDetCodigo(), DetalleCatalogoEnum.ESINI.getDetalle().getDetCodigo()) && (!Objects.equals(poliza.getDetEstado(), DetalleCatalogoEnum.ESTCAN.getDetalle().getDetCodigo()) )){
|
||||
throw new DominioExcepcion(ErrorTipo.ERROR, CodigoRespuesta.CODIGO_ERROR_ACTUALIZA_BDD, "Las polizas recientemente creadas solo pueden ser canceladas, recuerde seguir el proceso adecuadamente");
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional(Transactional.TxType.REQUIRES_NEW)
|
||||
public Poliza crearPolizaMasivo(Persona persona, PolizaDTO poliza, Usuario user) throws DaoException, DominioExcepcion{
|
||||
Poliza result = this.registrarPoliza(persona, poliza, user, false);
|
||||
|
||||
return result;
|
||||
}
|
||||
public Poliza crearPoliza(PolizaDTO poliza, Usuario user) throws DominioExcepcion, IOException {
|
||||
Poliza result = null;
|
||||
try {
|
||||
if (this.existePoliza(poliza.getPerCedulaTitular().trim(), poliza.getDetTipoIdentificacion(), null)) {
|
||||
throw new DatatypeConfigurationException("Error el cliente " + poliza.getPerCedulaTitular().trim()
|
||||
+ " ya posee una poliza activa no se modificara la informacion actual");
|
||||
}
|
||||
Persona persona = this.obtenerPersona(poliza);
|
||||
result = this.registrarPoliza(persona, poliza, user, false);
|
||||
this.crearUsuario(persona, result);
|
||||
} catch (DaoException | DatatypeConfigurationException ex) {
|
||||
throw new DominioExcepcion(ErrorTipo.ERROR, CodigoRespuesta.CODIGO_ERROR_GENERICO,
|
||||
"Error al registrar poliza " + ex);
|
||||
}
|
||||
System.out.println("========================> OK REGISTRO POLIZA ");
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param cedula
|
||||
* @param diagnostico
|
||||
* @return
|
||||
* @throws DominioExcepcion
|
||||
* @throws DaoException
|
||||
*/
|
||||
public List<Object> obtenerTitularDependienteFarma(String cedula, String diagnostico) throws DominioExcepcion, DaoException {
|
||||
DaoGenerico<PersonaPoliza, String> daoPerPol = new DaoGenerico<>(PersonaPoliza.class);
|
||||
Persona plantillaTitular = new Persona();
|
||||
List<Object> data = new ArrayList<>();
|
||||
|
||||
plantillaTitular.setPerIdentificacion(cedula);
|
||||
|
||||
PersonaPoliza plantillaPerPol = new PersonaPoliza();
|
||||
plantillaPerPol.setPerCodigo(plantillaTitular);
|
||||
|
||||
List<PersonaPoliza> listPersonaPoliza = daoPerPol.buscarLista(plantillaPerPol);
|
||||
|
||||
for (PersonaPoliza personaPoliza : listPersonaPoliza) {
|
||||
Map<String, Object> recTitular = new HashMap<String, Object>();
|
||||
|
||||
String tipoident = personaPoliza.getPerCodigo().getDetTipoIdentificacion().getDetNombre().charAt(0) + "";
|
||||
List<Object> dependientes = this.getHijos(personaPoliza, daoPerPol);
|
||||
recTitular.put("ti_tipoident", tipoident);
|
||||
recTitular.put("ti_cedula", personaPoliza.getPerCodigo().getPerIdentificacion());
|
||||
recTitular.put("ti_estado", "R");
|
||||
//TODO: Codigo estatico, revisar
|
||||
recTitular.put("ti_autnumcont", dependientes.size());
|
||||
//TODO: Codigo estatico, revisar
|
||||
recTitular.put("ti_codplan", personaPoliza.getPolCodigo().getPlaCodigo().getPlaCodigo());
|
||||
//TODO: Codigo estatico, revisar
|
||||
recTitular.put("ti_autcodigo", 1);
|
||||
//TODO: Codigo estatico, revisar
|
||||
recTitular.put("ti_nomplan", personaPoliza.getPolCodigo().getPlaCodigo().getPlaCodigo());
|
||||
//TODO: Codigo estatico, revisar
|
||||
PersonaPolizaDTO dto = PersonaPolizaMapper.INSTANCE.getDto(personaPoliza);
|
||||
recTitular.put("rec_dependiente", dependientes);
|
||||
|
||||
data.add(recTitular);
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param padre
|
||||
* @param daoPerPol
|
||||
* @return
|
||||
* @throws DominioExcepcion
|
||||
* @throws DaoException
|
||||
*/
|
||||
public List<Object> getHijos(PersonaPoliza padre, DaoGenerico<PersonaPoliza, String> daoPerPol) throws DominioExcepcion, DaoException {
|
||||
List<Object> listPerPolDTO = new ArrayList<>();
|
||||
PersonaPoliza plantilla = new PersonaPoliza();
|
||||
plantilla.setPolCodigo(padre.getPolCodigo());
|
||||
for (PersonaPoliza personaPoliza : daoPerPol.buscarLista(plantilla)) {
|
||||
Map<String, Object> recDependiente = new HashMap<String, Object>();
|
||||
|
||||
String tipoident = personaPoliza.getPerCodigo().getDetTipoIdentificacion().getDetNombre().charAt(0) + "";
|
||||
recDependiente.put("de_tipoident", tipoident);
|
||||
recDependiente.put("de_cedula", personaPoliza.getPerCodigo().getPerIdentificacion());
|
||||
recDependiente.put("de_nombre", personaPoliza.getPerCodigo().getPerNombres());
|
||||
recDependiente.put("de_mail", personaPoliza.getPerCodigo().getPerMail());
|
||||
recDependiente.put("de_tipo", personaPoliza.getDetTipoPersona().getDetNombre());
|
||||
recDependiente.put("de_autcodigo", 1);
|
||||
|
||||
listPerPolDTO.add(recDependiente);
|
||||
|
||||
}
|
||||
|
||||
return listPerPolDTO;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Permite crear la poliza
|
||||
*
|
||||
* @param persona
|
||||
* @param input
|
||||
* @return
|
||||
* @throws DaoException
|
||||
*/
|
||||
private Poliza registrarPoliza(Persona persona, PolizaDTO input, Usuario user, boolean actualiza) throws DaoException, DominioExcepcion {
|
||||
DaoGenerico<Poliza, Integer> daopol = new DaoGenerico<>(Poliza.class);
|
||||
DaoGenerico<DetalleCatalogo, Integer> daodet = new DaoGenerico<>(DetalleCatalogo.class);
|
||||
DaoGenerico<Pago, Integer> daopag = new DaoGenerico<>(Pago.class);
|
||||
DaoGenerico<EstadoPoliza, Integer> daoestpol = new DaoGenerico<>(EstadoPoliza.class);
|
||||
|
||||
Poliza polizaEstadoAnterior = daopol.buscarUnico(new Poliza(input.getPolCodigo()));
|
||||
|
||||
Poliza poliza = new Poliza();
|
||||
poliza = PolizaMapper.INSTANCE.getEntidad(input);
|
||||
DetalleCatalogo periodicidadMensual = catalogoUtil.getDetallePorNemonicoDao("MENS", daodet);
|
||||
DetalleCatalogo periodicidadAnual = catalogoUtil.getDetallePorNemonicoDao("ANUA", daodet);
|
||||
DetalleCatalogo estadoActual = null;
|
||||
Integer planPrevio = null;
|
||||
if (actualiza) {
|
||||
boolean cancela = false;
|
||||
|
||||
validarEstadoCreado(input);
|
||||
|
||||
if(input.getDetEstado() != null){
|
||||
cancela = Objects.equals(input.getDetEstado(), DetalleCatalogoEnum.ESTCAN.getDetalle().getDetCodigo());
|
||||
EstadoPoliza estadoAnteriorPoliza = buscarUltimoEstadoActivo(polizaEstadoAnterior, daoestpol);
|
||||
estadoActual = catalogoUtil.getDetallePorCodigo(input.getDetEstado());
|
||||
/**------------------------------- Buscar el ultimo estado valido*/
|
||||
if(estadoAnteriorPoliza == null || !estadoActual.getDetNemonico().equals(estadoAnteriorPoliza.getDetEstado().getDetNemonico()) ){
|
||||
this.anularEstadosPorPoliza(new ArrayList<EstadoPoliza>(polizaEstadoAnterior.getEstadoPolizaCollection()), daoestpol);
|
||||
|
||||
|
||||
EstadoPoliza ep= generarEstadoPoliza(estadoActual, polizaEstadoAnterior, String.format("Estado %s", estadoActual.getDetNombre()));
|
||||
daoestpol.guardar(ep);
|
||||
}
|
||||
|
||||
}
|
||||
planPrevio = daopol.cargar(input.getPolCodigo()).getPlaCodigo().getPlaCodigo();
|
||||
|
||||
if (cancela) {
|
||||
poliza.setPolFechaCancela(new Date());
|
||||
}
|
||||
if(input.getDetPeriodicidad() != null ){
|
||||
if(Objects.equals(polizaEstadoAnterior.getDetPeriodicidad().getDetCodigo(), periodicidadMensual.getDetCodigo()) && Objects.equals(input.getDetPeriodicidad(), periodicidadAnual.getDetCodigo())){
|
||||
cambiarMensualAAnual(poliza, polizaEstadoAnterior, periodicidadAnual, daodet, daopag, daopol);
|
||||
}else{
|
||||
throw new DominioExcepcion(ErrorTipo.ERROR, CodigoRespuesta.CODIGO_ERROR_GENERICO,
|
||||
String.format("Solo puede cambiarse de estado %s a estado %s en este momento", periodicidadMensual.getDetNombre(), periodicidadAnual.getDetNombre() ));
|
||||
}
|
||||
}
|
||||
|
||||
daopol.actualizar(poliza);
|
||||
if(poliza.getEstadoPolizaCollection() == null){
|
||||
poliza.setEstadoPolizaCollection(new ArrayList<>());
|
||||
}
|
||||
this.actualizaPlan(planPrevio, poliza, user, daopol);
|
||||
if (cancela) {
|
||||
this.cancelaPoliza(poliza);
|
||||
}
|
||||
} else {
|
||||
poliza.setEstadoPolizaCollection(new ArrayList<>());
|
||||
poliza = this.setData(poliza, user, input);
|
||||
|
||||
long cont;
|
||||
try {
|
||||
cont = this.contabilidadUtil.getSecuencia(SecuenciaEnum.POLMED);
|
||||
String contrat = this.dominioUtil.getCodPoliza(cont);
|
||||
poliza.setPolCertificado(contrat);
|
||||
poliza.setPolContrato(contrat);
|
||||
} catch (DominioExcepcion ex) {
|
||||
throw new DaoException(ex.getMensaje());
|
||||
}
|
||||
DaoGenerico<Plan, Integer> daopla = new DaoGenerico<>(Plan.class);
|
||||
Plan plan = daopla.cargar(poliza.getPlaCodigo().getPlaCodigo());
|
||||
poliza.setPlaCodigo(plan);
|
||||
poliza.setPagoCollection(this.crearPagos(poliza));
|
||||
poliza.setPersonaPolizaCollection(this.registrarPersonaPoliza(persona, poliza));
|
||||
daopol.guardar(poliza);
|
||||
}
|
||||
return poliza;
|
||||
}
|
||||
|
||||
public void cambiarMensualAAnual(Poliza polizaModificar,Poliza polizaAnterior, DetalleCatalogo periodicidadAnual, DaoGenerico<DetalleCatalogo, Integer> daodet, DaoGenerico<Pago, Integer> daopag, DaoGenerico<Poliza, Integer> daopol) throws DaoException{
|
||||
DetalleCatalogo tipoPagoPendiente = catalogoUtil.getDetallePorNemonicoDao("PAG1", daodet);
|
||||
DetalleCatalogo tipoPagoCancelado = catalogoUtil.getDetallePorNemonicoDao("PAGC", daodet);
|
||||
polizaModificar.setDetPeriodicidad(periodicidadAnual);
|
||||
Pago pagoPlantilla = new Pago();
|
||||
pagoPlantilla.setPolCodigo(polizaAnterior);
|
||||
pagoPlantilla.setDetEstado(tipoPagoPendiente);
|
||||
List<Pago> lstPagosPendientes = daopag.buscarLista(pagoPlantilla, new String[]{"pagFechaVencimiento","ASC"});
|
||||
Pago primerPagoCambiar = null;
|
||||
double unPagoAnual = 0.0;
|
||||
for (int i = 0; i < lstPagosPendientes.size(); i++) {
|
||||
unPagoAnual += lstPagosPendientes.get(i).getPagMonto() != null ? lstPagosPendientes.get(i).getPagMonto() : 0.0;
|
||||
if(i == 0){
|
||||
primerPagoCambiar = lstPagosPendientes.get(i);
|
||||
}else{
|
||||
lstPagosPendientes.get(i).setDetEstado(tipoPagoCancelado);
|
||||
daopag.actualizar(lstPagosPendientes.get(i));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(primerPagoCambiar != null){
|
||||
primerPagoCambiar.setPagMonto(unPagoAnual);
|
||||
daopag.actualizar(primerPagoCambiar);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public EstadoPoliza buscarUltimoEstadoActivo(Poliza poliza,DaoGenerico<EstadoPoliza, Integer> daoestpol) throws DaoException{
|
||||
EstadoPoliza plantilla = new EstadoPoliza();
|
||||
plantilla.setPolCodigo(poliza);
|
||||
plantilla.setEspEstado(DominioConstantes.ACTIVO);
|
||||
|
||||
return daoestpol.buscarUnico(plantilla);
|
||||
}
|
||||
public EstadoPoliza buscarUltimoEstadoActivoPolCodigo(Integer polCodigo,DaoGenerico<EstadoPoliza, Integer> daoestpol) throws DaoException{
|
||||
return buscarUltimoEstadoActivo(new Poliza(polCodigo), daoestpol);
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param poliza
|
||||
* @throws DaoException
|
||||
*/
|
||||
public void cancelaPolizaDao(Poliza poliza, DaoGenerico<Pago, Integer> daopa,DaoGenerico<PersonaPoliza, Integer> daopp, DaoGenerico<CuentaBancaria, Integer> daocb) throws DaoException {
|
||||
|
||||
Pago pag = new Pago();
|
||||
pag.setDetEstado(DetalleCatalogoEnum.PAG1.getDetalle());
|
||||
pag.setPolCodigo(new Poliza(poliza.getPolCodigo()));
|
||||
|
||||
for (Pago p : daopa.buscarLista(pag)) {
|
||||
if (this.esCancelable(p.getPagFechaVencimiento())) {
|
||||
p.setDetEstado(DetalleCatalogoEnum.PAGC.getDetalle());
|
||||
daopa.actualizar(p);
|
||||
}
|
||||
}
|
||||
PersonaPoliza perpol = new PersonaPoliza();
|
||||
perpol.setPolCodigo(new Poliza(poliza.getPolCodigo()));
|
||||
CuentaBancaria cuenta = new CuentaBancaria();
|
||||
for (PersonaPoliza pp : daopp.buscarLista(perpol)) {
|
||||
pp.setPepEstado(DominioConstantes.CANCELADO);
|
||||
daopp.actualizar(pp);
|
||||
if (pp.getDetTipoPersona().getDetNemonico().equals(DetalleCatalogoEnum.PTITU.name())) {
|
||||
cuenta.setPerCodigo(new Persona(pp.getPerCodigo().getPerCodigo()));
|
||||
}
|
||||
}
|
||||
cuenta.setCueDebito(DominioConstantes.ACTIVO);
|
||||
for (CuentaBancaria cb : daocb.buscarLista(cuenta)) {
|
||||
cb.setCueDebito(DominioConstantes.INACTIVO);
|
||||
daocb.actualizar(cb);
|
||||
}
|
||||
}
|
||||
public void cancelaPoliza(Poliza poliza) throws DaoException {
|
||||
System.out.println("========>>> CANCELA POLIZA......");
|
||||
DaoGenerico<Pago, Integer> daopa = new DaoGenerico<>(Pago.class);
|
||||
DaoGenerico<PersonaPoliza, Integer> daopp = new DaoGenerico<>(PersonaPoliza.class);
|
||||
DaoGenerico<CuentaBancaria, Integer> daocb = new DaoGenerico<>(CuentaBancaria.class);
|
||||
cancelaPolizaDao(poliza, daopa, daopp, daocb);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param fecha
|
||||
* @return
|
||||
*/
|
||||
private boolean esCancelable(Date fecha) {
|
||||
boolean estado = false;
|
||||
Calendar c = Calendar.getInstance();
|
||||
Calendar d = Calendar.getInstance();
|
||||
d.setTimeInMillis(fecha.getTime());
|
||||
c.set(Calendar.DAY_OF_MONTH, c.getMaximum(Calendar.DAY_OF_MONTH));
|
||||
estado = d.getTimeInMillis() > c.getTimeInMillis();
|
||||
System.out.println("\t====> " + DominioConstantes.getDate(d.getTime()) + " <=> " + DominioConstantes.getDate(c.getTime())
|
||||
+ " => " + estado);
|
||||
return estado;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param poliza
|
||||
* @return
|
||||
*/
|
||||
private EstadoPoliza getEstadoActivo(Poliza poliza) {
|
||||
EstadoPoliza result = null;
|
||||
for (EstadoPoliza es : poliza.getEstadoPolizaCollection()) {
|
||||
if (es.getEspEstado().equals(DominioConstantes.ACTIVO)) {
|
||||
result = es;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param poliza
|
||||
* @param usuario
|
||||
* @param estado
|
||||
* @return
|
||||
*/
|
||||
private EstadoPoliza getEstado(Poliza poliza, Usuario usuario, DetalleCatalogoEnum estado) {
|
||||
EstadoPoliza es = new EstadoPoliza();
|
||||
es.setPolCodigo(poliza);
|
||||
es.setDetEstado(estado.getDetalle());
|
||||
es.setEspEstado(DominioConstantes.ACTIVO);
|
||||
es.setPolCodigo(poliza);
|
||||
es.setEspFechaInicio(new Date());
|
||||
es.setUsuCodigo(usuario);
|
||||
es.setEspObservacion("Cambio de estado " + es.getDetEstado().getDetDescripcion());
|
||||
return es;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param planPrevio
|
||||
* @param poliza
|
||||
* @param daopol
|
||||
* @throws DaoException
|
||||
*/
|
||||
public void actualizaPlan(Integer planPrevio, Poliza poliza, Usuario user, DaoGenerico<Poliza, Integer> daopol) throws DaoException {
|
||||
if ((poliza.getPlaCodigo() != null && poliza.getPlaCodigo().getPlaCodigo() != null ) && !Objects.equals(planPrevio, poliza.getPlaCodigo().getPlaCodigo())) {
|
||||
System.out.print(">>> PlaNombre:"+ poliza.getPlaCodigo().getPlaNombre());
|
||||
System.out.print("Placodigo: "+ poliza.getPlaCodigo().getPlaCodigo());
|
||||
System.out.print("Placodigo: "+ poliza.getPlaCodigo());
|
||||
|
||||
DaoGenerico<Pago, Integer> daopa = new DaoGenerico<>(Pago.class);
|
||||
DaoGenerico<Plan, Integer> daopla = new DaoGenerico<>(Plan.class);
|
||||
DaoGenerico<PersonaPoliza, Integer> daopp = new DaoGenerico<>(PersonaPoliza.class);
|
||||
Plan plan = daopla.cargar(poliza.getPlaCodigo().getPlaCodigo());
|
||||
Pago pag = new Pago();
|
||||
pag.setDetEstado(DetalleCatalogoEnum.PAG1.getDetalle());
|
||||
pag.setPolCodigo(new Poliza(poliza.getPolCodigo()));
|
||||
for (Pago p : daopa.buscarLista(pag)) {
|
||||
if (p.getPagFechaVencimiento().getTime() > System.currentTimeMillis()) {
|
||||
p.setPagMonto(plan.getPlaValorMensual());
|
||||
daopa.actualizar(p);
|
||||
}
|
||||
}
|
||||
PersonaPoliza perpol = new PersonaPoliza();
|
||||
perpol.setPolCodigo(poliza);
|
||||
for (PersonaPoliza pp : daopp.buscarLista(perpol)) {
|
||||
pp.setPepMontoCobertura(plan.getPlaCoberturaMaxima());
|
||||
daopp.actualizar(pp);
|
||||
}
|
||||
poliza.setPolFechaCambio(new Date());
|
||||
poliza.getEstadoPolizaCollection().add(this.getEstado(poliza, user, DetalleCatalogoEnum.ESINI));
|
||||
daopol.actualizar(poliza);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param poliza
|
||||
* @param input
|
||||
* @return
|
||||
*/
|
||||
private Poliza setData(Poliza poliza, Usuario user, PolizaDTO input) {
|
||||
poliza.setPolPreexistencias(DominioConstantes.ACTIVO);
|
||||
poliza.setPolOrigen(poliza.getPolOrigen() == null ? DominioConstantes.ORIGEN_POLIZA : poliza.getPolOrigen());
|
||||
poliza.setPolDescripcion(poliza.getPolDescripcion() == null ? DominioConstantes.DESCRIPCION_POLIZA : poliza.getPolDescripcion());
|
||||
poliza.setPolEstado(DominioConstantes.INACTIVO);
|
||||
poliza.setPolDiasCobertura(DominioConstantes.DIAS_COBERTURA);
|
||||
Calendar cal = Calendar.getInstance();
|
||||
if(input.getPolFechaInicio() == null){
|
||||
cal.add(Calendar.MONTH, 1);
|
||||
cal.set(Calendar.DAY_OF_MONTH, 1);
|
||||
poliza.setPolFechaInicio(cal.getTime());
|
||||
cal.add(Calendar.YEAR, 1);
|
||||
poliza.setPolFechaFin(cal.getTime());
|
||||
}else{
|
||||
poliza.setPolFechaInicio(input.getPolFechaInicio());
|
||||
cal.setTime(input.getPolFechaInicio());
|
||||
cal.add(Calendar.YEAR, 1);
|
||||
poliza.setPolFechaFin(cal.getTime());
|
||||
}
|
||||
|
||||
poliza.setPolFechaRegistro(new Date());
|
||||
poliza.setEmpCodigo(new Empresa(input.getEmpCodigo()));
|
||||
poliza.setDetPeriodicidad(new DetalleCatalogo(input.getDetPeriodicidad()));
|
||||
poliza.getEstadoPolizaCollection().add(this.getEstado(poliza, user, DetalleCatalogoEnum.ESINI));
|
||||
poliza.setDetIfi(new DetalleCatalogo(input.getDetIfi()));
|
||||
poliza.setDetSucursalIfi(new DetalleCatalogo(input.getDetSucursalIfi()));
|
||||
poliza.setDetFormaPago(new DetalleCatalogo(input.getDetFormaPago()));
|
||||
poliza.setDetModalidad(new DetalleCatalogo(input.getDetModalidad()));
|
||||
poliza.setPlaCodigo(new Plan(input.getPlaCodigo()));
|
||||
return poliza;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param cedula
|
||||
* @param detTipoIden
|
||||
* @param perCodigo
|
||||
* @return
|
||||
* @throws DaoException
|
||||
*/
|
||||
public boolean existePoliza(String cedula, Integer detTipoIden, Integer perCodigo) throws DaoException {
|
||||
DaoGenerico<PersonaPoliza, Integer> daopp = new DaoGenerico<>(PersonaPoliza.class);
|
||||
Persona per = new Persona();
|
||||
if (perCodigo != null) {
|
||||
per.setPerCodigo(perCodigo);
|
||||
} else {
|
||||
per.setPerIdentificacion(cedula);
|
||||
per.setDetTipoIdentificacion(new DetalleCatalogo(detTipoIden));
|
||||
}
|
||||
PersonaPoliza pp = new PersonaPoliza();
|
||||
pp.setDetTipoPersona(DetalleCatalogoEnum.PTITU.getDetalle());
|
||||
pp.setPepEstado(DominioConstantes.ACTIVO);
|
||||
pp.setPerCodigo(per);
|
||||
return daopp.contarExistencias(pp) > 0;
|
||||
}
|
||||
|
||||
public boolean evaluarSiniestrado(String cedula) throws DaoException {
|
||||
DaoGenerico<Persona, Integer> daoper = new DaoGenerico<>(Persona.class);
|
||||
Persona personaPlantilla = new Persona();
|
||||
personaPlantilla.setPerIdentificacion(cedula);
|
||||
|
||||
Persona persona = daoper.buscarUnico(personaPlantilla);
|
||||
boolean evaluacion = true;
|
||||
if (persona.getDetEstadoPoliza() != null) {
|
||||
if (persona.getDetEstadoPoliza().getDetNemonico().equals("SINIES")) {
|
||||
evaluacion = false;
|
||||
}
|
||||
}
|
||||
return evaluacion;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param persona
|
||||
* @param poliza
|
||||
* @return
|
||||
* @throws DaoException
|
||||
*
|
||||
*/
|
||||
/**------------------------------ Crear usuario afuera -----------------------*/
|
||||
public Usuario creaUsuarioExt(Persona persona, Poliza poliza) throws DaoException, IOException{
|
||||
return crearUsuario(persona, poliza);
|
||||
}
|
||||
private Usuario crearUsuario(Persona persona, Poliza poliza) throws DaoException, IOException {
|
||||
DaoGenerico<Usuario, Integer> daouser = new DaoGenerico<>(Usuario.class);
|
||||
|
||||
Usuario user = new Usuario();
|
||||
user.setUsuUsuario(persona.getPerIdentificacion());
|
||||
String pass = "- SU PASSWORD ACTUAL -";
|
||||
if (daouser.contarExistencias(user) <= 0l) {
|
||||
user.setUsuUsuario(persona.getPerIdentificacion());
|
||||
user.setUsuOrigen(DominioConstantes.PERSONA);
|
||||
user.setUsuIdOrigen("" + persona.getPerCodigo());
|
||||
user.setUsuDescripcion(DominioConstantes.DATO_AUTO);
|
||||
user.setUsuEstado(DominioConstantes.ACTIVO);
|
||||
user.setUsuFechaRegistro(new Date());
|
||||
user.setUsuNombre(persona.getPerNombres());
|
||||
user.setUsuEmail(persona.getPerMail());
|
||||
pass = RandomStringUtils.randomAlphabetic(8);
|
||||
user.setUsuarioPasswordCollection(this.crearPassword(user, pass));
|
||||
user.setRolUsuarioCollection(this.crearRol(user));
|
||||
daouser.guardar(user);
|
||||
} else {
|
||||
user = daouser.buscarUnico(user);
|
||||
user.setUsuEmail(persona.getPerMail());
|
||||
daouser.actualizar(user);
|
||||
}
|
||||
// this.notificadorUtil.enviarMensajeBienvenida(user, poliza, pass);
|
||||
this.notificadorUtil.notificarBienvenida(user, poliza, pass);
|
||||
return user;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param user
|
||||
* @return
|
||||
*/
|
||||
private List<RolUsuario> crearRol(Usuario user) {
|
||||
List<RolUsuario> lista = new ArrayList<>();
|
||||
RolUsuario ru = new RolUsuario();
|
||||
ru.setRolCodigo(new Rol(DominioConstantes.ROL_CLI));
|
||||
ru.setRouDescripcion(DominioConstantes.DATO_AUTO);
|
||||
ru.setRouEstado(DominioConstantes.ACTIVO);
|
||||
ru.setRouFecha(new Date());
|
||||
ru.setUsuCodigo(user);
|
||||
lista.add(ru);
|
||||
return lista;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private List<UsuarioPassword> crearPassword(Usuario user, String password) throws DaoException {
|
||||
List<UsuarioPassword> lista = new ArrayList<>();
|
||||
try {
|
||||
UsuarioPassword usp = new UsuarioPassword();
|
||||
usp.setPasEstado(DominioConstantes.ACTIVO);
|
||||
usp.setPasFecha(new Date());
|
||||
usp.setUsuCodigo(user);
|
||||
String cifpas = this.dominioUtil.getSHAUsuario(user.getUsuUsuario(), password);
|
||||
usp.setPasValor(cifpas);
|
||||
lista.add(usp);
|
||||
} catch (DominioExcepcion ex) {
|
||||
ex.printStackTrace(System.out);
|
||||
}
|
||||
return lista;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param poliza
|
||||
* @return
|
||||
*/
|
||||
private List<Pago> crearPagos(Poliza poliza) throws DaoException {
|
||||
DaoGenerico<DetalleCatalogo, Integer> daodet = new DaoGenerico<>(DetalleCatalogo.class);
|
||||
|
||||
DetalleCatalogo periodicidad = daodet.cargar(poliza.getDetPeriodicidad().getDetCodigo());
|
||||
List<Pago> pagos = new ArrayList<>();
|
||||
Integer num = Integer.parseInt(periodicidad.getDetDestino().trim());
|
||||
Calendar cal = Calendar.getInstance();
|
||||
if(poliza.getPolFechaInicio() != null){
|
||||
cal.setTime(poliza.getPolFechaInicio());
|
||||
//cal.set(Calendar.DAY_OF_MONTH, 3);
|
||||
}else{
|
||||
cal.setTime(poliza.getPolFechaRegistro());
|
||||
cal.set(Calendar.DAY_OF_MONTH, 3);
|
||||
cal.add(Calendar.MONTH, 1);
|
||||
}
|
||||
|
||||
DetalleCatalogo estado = DetalleCatalogoEnum.PAG1.getDetalle();
|
||||
Pago pago = null;
|
||||
Double monto = poliza.getPlaCodigo().getPlaValorAnual();
|
||||
if (num == MESES) {
|
||||
monto = poliza.getPlaCodigo().getPlaValorMensual();
|
||||
}
|
||||
if (num == 2 && monto != null && monto > 0) {
|
||||
monto = monto / 2.0;
|
||||
}
|
||||
int add = MESES / num; // 12/12 = 1 12/2 = 6 12/1 = 12
|
||||
if (monto == null && num < MESES) {
|
||||
monto = poliza.getPlaCodigo().getPlaValorMensual();
|
||||
monto = monto * add;
|
||||
}
|
||||
System.out.println(">>>> PERIODICIDAD MENSUAL y CUOTA ??? " + num + " => " + add + " => " + monto);
|
||||
for (Integer i = 0; i < num; i++) {
|
||||
pago = new Pago();
|
||||
pago.setPagFechaVencimiento(cal.getTime());
|
||||
pago.setPagNumPago(i.shortValue());
|
||||
pago.setDetEstado(estado);
|
||||
pago.setPagMonto(monto);
|
||||
pago.setPolCodigo(poliza);
|
||||
pagos.add(pago);
|
||||
cal.add(Calendar.MONTH, add);
|
||||
}
|
||||
return pagos;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param poliza
|
||||
* @return
|
||||
*/
|
||||
private Persona obtenerPersona(PolizaDTO poliza) throws DaoException {
|
||||
DaoGenerico<Persona, Integer> daoper = new DaoGenerico<>(Persona.class);
|
||||
DaoGenerico<Localizacion, String> dao = new DaoGenerico<>(Localizacion.class);
|
||||
Persona per = new Persona();
|
||||
per.setPerIdentificacion(poliza.getPerCedulaTitular().trim());
|
||||
per.setDetTipoIdentificacion(new DetalleCatalogo(poliza.getDetTipoIdentificacion()));
|
||||
if (daoper.contarExistencias(per) > 0) {
|
||||
per = daoper.buscarUnico(per);
|
||||
this.crearCuentas(poliza, per);
|
||||
} else {
|
||||
throw new DaoException("Error, la persona seleccionada no se encuentra en el sistema");
|
||||
}
|
||||
return per;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param persona
|
||||
* @param poliza
|
||||
*/
|
||||
public PolizaDTO crearPolizaDTO(Integer empCodigo, Integer plaCodigo, String polBroker, Integer periodicidad, Integer codigoSucursal, Integer tipoCobro, String polDescripcion, Integer detModalidad, Integer detIfi, String fechaInicio, String polObservacion){
|
||||
PolizaDTO polizaDTO = new PolizaDTO();
|
||||
polizaDTO.setPolBroker(polBroker);
|
||||
polizaDTO.setPlaCodigo(plaCodigo);
|
||||
polizaDTO.setDetPeriodicidad(periodicidad);
|
||||
polizaDTO.setDetIfi(detIfi);
|
||||
polizaDTO.setDetSucursalIfi(codigoSucursal);
|
||||
polizaDTO.setEmpCodigo(empCodigo);
|
||||
polizaDTO.setDetFormaPago(tipoCobro);
|
||||
polizaDTO.setPolDescripcion(polDescripcion);
|
||||
polizaDTO.setPolObservacion(polObservacion);
|
||||
polizaDTO.setDetModalidad(detModalidad);
|
||||
polizaDTO.setPolFechaInicio(DominioConstantes.getDate(fechaInicio));
|
||||
return polizaDTO;
|
||||
}
|
||||
private List<PersonaPoliza> registrarPersonaPoliza(Persona persona, Poliza poliza) throws DaoException {
|
||||
List<PersonaPoliza> lista = new ArrayList<>();
|
||||
System.out.println("=============== REGISTRAR PERSONA POLIZA ===============");
|
||||
PersonaPoliza pp = new PersonaPoliza();
|
||||
pp.setDetTipoPersona(DetalleCatalogoEnum.PTITU.getDetalle());
|
||||
pp.setPepEstado(DominioConstantes.ACTIVO);
|
||||
pp.setPepMontoCobertura(poliza.getPlaCodigo().getPlaCoberturaMaxima());
|
||||
pp.setPepObservacion(DominioConstantes.DATO_AUTO);
|
||||
pp.setPerCodigo(persona);
|
||||
pp.setPolCodigo(poliza);
|
||||
lista.add(pp);
|
||||
return lista;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private List<CuentaBancaria> crearCuentas(PolizaDTO poliza, Persona persona) throws DaoException {
|
||||
DaoGenerico<CuentaBancaria, Integer> daocue = new DaoGenerico<>(CuentaBancaria.class);
|
||||
List<CuentaBancaria> cuentaBancarias = new ArrayList<>();
|
||||
CuentaBancaria cuenta = new CuentaBancaria();
|
||||
cuenta.setCueCuenta(poliza.getCuentaDebito());
|
||||
cuenta.setCueIdentificacion(poliza.getCedulaDebito());
|
||||
cuenta.setCueEstado(DominioConstantes.ACTIVO);
|
||||
cuenta.setDetIfi(new DetalleCatalogo(poliza.getDetIfi()));
|
||||
cuenta.setDetTipoCuenta(new DetalleCatalogo(poliza.getDetTipoCuenta()));
|
||||
cuenta.setPerCodigo(persona);
|
||||
cuenta.setCueDebito(DominioConstantes.ACTIVO);
|
||||
cuentaBancarias.add(cuenta);
|
||||
daocue.guardar(cuenta);
|
||||
return cuentaBancarias;
|
||||
}
|
||||
|
||||
/*----------------------------------------*/
|
||||
@Transactional(Transactional.TxType.REQUIRES_NEW)
|
||||
public void actualizarPolizaCaducada(DetalleCatalogo estadoCaducado,Poliza caducarPoliza, String descripcion, DaoGenerico<Poliza, Integer> daopol, DaoGenerico<EstadoPoliza,Integer> daoestpol) throws DaoException{
|
||||
|
||||
anularEstadosPorPoliza(new ArrayList<EstadoPoliza>(caducarPoliza.getEstadoPolizaCollection()), daoestpol);
|
||||
//caducarPoliza.setDetEstado(this.estadoCaducado);
|
||||
EstadoPoliza estadoActual = crearEstadoPoliza(estadoCaducado, caducarPoliza, descripcion, daoestpol);
|
||||
//caducarPoliza.setPolFechaca(new Date());
|
||||
caducarPoliza.setPolDescripcion(descripcion);
|
||||
/**------------------------------TEMPORAL*/
|
||||
caducarPoliza.setPolEstado(DominioConstantes.INACTIVO);
|
||||
daopol.actualizar(caducarPoliza);
|
||||
}
|
||||
/**--------------------------Matar EstadosPoliza */
|
||||
public void anularEstadosPorPoliza(List<EstadoPoliza> lstEstadosPoliza, DaoGenerico<EstadoPoliza,Integer> daoestpol) throws DaoException{
|
||||
for (EstadoPoliza estadoPoliza : lstEstadosPoliza) {
|
||||
if(Objects.equals(DominioConstantes.ACTIVO, estadoPoliza.getEspEstado())){
|
||||
inactivarEstado(estadoPoliza, daoestpol);
|
||||
}
|
||||
}
|
||||
}
|
||||
/**-------------------------------------------------------------- inactivar EstadoPoliza**/
|
||||
@Transactional(Transactional.TxType.REQUIRES_NEW)
|
||||
public EstadoPoliza inactivarEstado(EstadoPoliza estadoPoliza, DaoGenerico<EstadoPoliza,Integer> daoestpol) throws DaoException{
|
||||
estadoPoliza.setEspEstado(DominioConstantes.INACTIVO);
|
||||
estadoPoliza.setEspFechaFin(new Date());
|
||||
daoestpol.actualizar(estadoPoliza);
|
||||
return estadoPoliza;
|
||||
}
|
||||
@Transactional(Transactional.TxType.REQUIRES_NEW)
|
||||
public EstadoPoliza crearEstadoPoliza(DetalleCatalogo detEstadoNuevo, Poliza poliza, String espObservacion, DaoGenerico<EstadoPoliza,Integer> daoestpol ) throws DaoException{
|
||||
EstadoPoliza estadoPoliza = generarEstadoPoliza(detEstadoNuevo, poliza, espObservacion);
|
||||
daoestpol.guardar(estadoPoliza);
|
||||
return estadoPoliza;
|
||||
}
|
||||
public EstadoPoliza generarEstadoPoliza(DetalleCatalogo detEstadoNuevo, Poliza poliza, String espObservacion) throws DaoException{
|
||||
EstadoPoliza estadoPoliza = new EstadoPoliza();
|
||||
estadoPoliza.setPolCodigo(poliza);
|
||||
estadoPoliza.setDetEstado(detEstadoNuevo);
|
||||
estadoPoliza.setEspObservacion(espObservacion);
|
||||
estadoPoliza.setEspFechaInicio(new Date());
|
||||
estadoPoliza.setEspEstado(DominioConstantes.ACTIVO);
|
||||
return estadoPoliza;
|
||||
}
|
||||
/**------------------------------------------------ PARA LOS BATCHS*/
|
||||
@Transactional(Transactional.TxType.REQUIRES_NEW)
|
||||
public void actualizarPolizaSuspenida(Poliza polizaSuspender, String descripcion, DaoGenerico<Poliza, Integer> daopol, DetalleCatalogo estadoSuspendido, DaoGenerico<EstadoPoliza, Integer> daoestPol) throws DaoException{
|
||||
//polizaSuspender.setDetEstado(estadoSuspendido);
|
||||
anularEstadosPorPoliza(new ArrayList<EstadoPoliza>(polizaSuspender.getEstadoPolizaCollection()), daoestPol);
|
||||
crearEstadoPoliza(estadoSuspendido, polizaSuspender, descripcion, daoestPol);
|
||||
polizaSuspender.setPolFechaCancela(new Date());
|
||||
polizaSuspender.setPolDescripcion(descripcion);
|
||||
/**------------------------------TEMPORAL*/
|
||||
polizaSuspender.setPolEstado(DominioConstantes.INACTIVO);
|
||||
daopol.actualizar(polizaSuspender);
|
||||
}
|
||||
public void ejecutarCancelacionPersonasPoliza(Poliza poliza, DaoGenerico<PersonaPoliza, Integer> daoperpol) throws DaoException{
|
||||
PersonaPoliza plantilla = new PersonaPoliza();
|
||||
plantilla.setPolCodigo(poliza);
|
||||
List<PersonaPoliza> lstPersonaPoliza = daoperpol.buscarLista(plantilla);
|
||||
for (PersonaPoliza personaPoliza : lstPersonaPoliza) {
|
||||
ejecutarCancelacionPersonaPoliza(personaPoliza, daoperpol);
|
||||
}
|
||||
}
|
||||
public PersonaPoliza ejecutarCancelacionPersonaPoliza(PersonaPoliza personaPoliza, DaoGenerico<PersonaPoliza, Integer> daoperpol) throws DaoException{
|
||||
personaPoliza.setPepEstado(DominioConstantes.CANCELADO);
|
||||
daoperpol.actualizar(personaPoliza);
|
||||
return personaPoliza;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,143 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.qsoft.erp.dominio.util;
|
||||
|
||||
import com.qsoft.erp.constantes.SecuenciaEnum;
|
||||
import com.qsoft.dao.exception.DaoException;
|
||||
import com.qsoft.erp.dao.DaoGenerico;
|
||||
import com.qsoft.erp.dominio.exception.DominioExcepcion;
|
||||
import com.qsoft.erp.model.Secuencia;
|
||||
import com.qsoft.erp.model.SucursalEmpresa;
|
||||
import com.qsoft.util.constantes.CodigoRespuesta;
|
||||
import com.qsoft.util.constantes.ErrorTipo;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import javax.ejb.Stateless;
|
||||
import javax.transaction.Transactional;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author james
|
||||
*/
|
||||
@Stateless
|
||||
public class SecuenciaUtil {
|
||||
|
||||
public static DateFormat format = new SimpleDateFormat("yyyy");
|
||||
|
||||
/**
|
||||
* Perite obtener una secuencia de acuerdo a la sucursal, retorna los datos en el siguiente orden <p/>
|
||||
* [0].- Codigo de establecimiento
|
||||
* [1].- Codigo de punto de
|
||||
* [2].- Secuencial
|
||||
* @param codSucursal
|
||||
* @return
|
||||
* @throws com.qsoft.erp.dominio.exception.DominioExcepcion
|
||||
*/
|
||||
public String[] getSecuenciaFacturaVenta(Integer codSucursal) throws DominioExcepcion {
|
||||
return getSecuencia(codSucursal, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Perite obtener una secuencia de acuerdo
|
||||
*
|
||||
* @param codSucursal
|
||||
* @return
|
||||
* @throws com.qsoft.erp.dominio.exception.DominioExcepcion
|
||||
*/
|
||||
public String[] getSecuenciaNotaVenta(Integer codSucursal) throws DominioExcepcion {
|
||||
return getSecuencia(codSucursal, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param codSucursal
|
||||
* @param indice
|
||||
* @return
|
||||
* @throws DominioExcepcion
|
||||
*/
|
||||
@Transactional(Transactional.TxType.REQUIRES_NEW)
|
||||
private String[] getSecuencia(Integer codSucursal, Integer indice) throws DominioExcepcion {
|
||||
String result[] = null;
|
||||
String nemonico = null;
|
||||
DaoGenerico<SucursalEmpresa, Integer> dao = new DaoGenerico<>(SucursalEmpresa.class);
|
||||
if (codSucursal == null) {
|
||||
throw new DominioExcepcion(ErrorTipo.ERROR, CodigoRespuesta.CODIGO_VALOR_NULO, "El codigo de sucursal no puede ser nulo");
|
||||
}
|
||||
SucursalEmpresa sucursal;
|
||||
try {
|
||||
sucursal = dao.cargar(codSucursal);
|
||||
} catch (DaoException ex) {
|
||||
throw new DominioExcepcion(ErrorTipo.ERROR, CodigoRespuesta.CODIGO_ERROR_CONSULTA_BDD, "No existe la sucursal indicada");
|
||||
}
|
||||
if (indice != null) {
|
||||
nemonico = sucursal.getSucSecuencial().split(";")[indice];
|
||||
} else {
|
||||
nemonico = sucursal.getSucSecuencial();
|
||||
}
|
||||
Secuencia sec = this.nextValue(nemonico);
|
||||
Integer valor = 0;
|
||||
if (sec != null && sec.getSecSecuencia() != null) {
|
||||
valor = sec.getSecSecuencia();
|
||||
result = new String[3];
|
||||
result[0] = sucursal.getSucEstablecimiento();
|
||||
result[1] = sucursal.getSucPtoEmision();
|
||||
result[2] = StringUtils.leftPad(valor.toString(), sec.getSecLongitud(), "0");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param nemonico
|
||||
* @return
|
||||
* @throws DominioExcepcion
|
||||
*/
|
||||
public String getSecuenciaString(SecuenciaEnum nemonico) throws DominioExcepcion{
|
||||
if(nemonico == null || nemonico.name() == null ||nemonico.name().isBlank()){
|
||||
throw new DominioExcepcion(ErrorTipo.ERROR, CodigoRespuesta.CODIGO_VALOR_NULO, "No se puede buscar una secuencia nula");
|
||||
}
|
||||
Secuencia sec = this.nextValue(nemonico.name());
|
||||
String result = StringUtils.leftPad(sec.getSecSecuencia().toString(), sec.getSecLongitud(), "0");
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param nemonico
|
||||
* @return
|
||||
* @throws DominioExcepcion
|
||||
*/
|
||||
public Integer getSecuencia(SecuenciaEnum nemonico) throws DominioExcepcion{
|
||||
Integer numero = null;
|
||||
if(nemonico == null || nemonico.name() == null ||nemonico.name().isBlank()){
|
||||
throw new DominioExcepcion(ErrorTipo.ERROR, CodigoRespuesta.CODIGO_VALOR_NULO, "No se puede buscar una secuencia nula");
|
||||
}
|
||||
Secuencia sec = this.nextValue(nemonico.name());
|
||||
numero = sec.getSecSecuencia();
|
||||
return numero;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param nemonico
|
||||
* @return
|
||||
*/
|
||||
@Transactional(Transactional.TxType.REQUIRES_NEW)
|
||||
private synchronized Secuencia nextValue(String nemonico) {
|
||||
DaoGenerico<Secuencia, Integer> dao = new DaoGenerico<>(Secuencia.class);
|
||||
Secuencia dato = new Secuencia();
|
||||
dato.setSecNemonico(nemonico);
|
||||
try {
|
||||
dato = dao.buscarUnico(dato);
|
||||
dato.setSecSecuencia(dato.getSecSecuencia() + 1);
|
||||
dao.actualizar(dato);
|
||||
} catch (DaoException ex) {
|
||||
dato = null;
|
||||
}
|
||||
return dato;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,414 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.qsoft.erp.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.qsoft.erp.constantes.DominioConstantes;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author james
|
||||
*/
|
||||
public class AgendamientoDTO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 20725437083742L;
|
||||
|
||||
private Integer ageCodigo;
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = DominioConstantes.FORMATO_FECHA_FRONT, locale = "es-EC", timezone = "America/Guayaquil")
|
||||
private Date ageFechaRegistro;
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = DominioConstantes.FORMATO_FECHA_FRONT, locale = "es-EC", timezone = "America/Guayaquil")
|
||||
private Date ageFechaAgenda;
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = DominioConstantes.FORMATO_FECHA_FRONT, locale = "es-EC", timezone = "America/Guayaquil")
|
||||
private Date ageFechaCita;
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = DominioConstantes.FORMATO_FECHA_FRONT, locale = "es-EC", timezone = "America/Guayaquil")
|
||||
private Date ageFechaConfirma;
|
||||
private String ageSintomas;
|
||||
private Double ageValor;
|
||||
private String ageTelefono;
|
||||
private String ageObservaciones;
|
||||
private Short ageNotificado;
|
||||
private String ageEspecialidad;
|
||||
private String ageMedico;
|
||||
private String ageDocumentos;
|
||||
private String ageAprobacion;
|
||||
private String ageExamenes;
|
||||
private String ageDiagnostico;
|
||||
private Short agePreexistencia;
|
||||
private String ageIndicaciones;
|
||||
private String ageNemonico;
|
||||
private String locCodigo;
|
||||
private Integer perBeneficiario;
|
||||
private Integer preCodigo;
|
||||
private Integer polCodigo;
|
||||
private Integer detTipo;
|
||||
private Integer usuCodigo;
|
||||
private String locNombre;
|
||||
private String perNombres;
|
||||
private String perApellidos;
|
||||
private String perIdentificacion;
|
||||
private String polContrato;
|
||||
private String preNombre;
|
||||
private String detNemonico;
|
||||
private String detNombre;
|
||||
private String usuUsuario;
|
||||
private Double ageCobertura;
|
||||
private String ageObservaMedico;
|
||||
private Double ageFacturado;
|
||||
private Double ageCubierto;
|
||||
private Double ageNoCubierto;
|
||||
private Double ageCopago;
|
||||
private Double ageDeducible;
|
||||
private String ageMailPaciente;
|
||||
private List<EstadoAgendamientoDTO> estado;
|
||||
|
||||
public Integer getAgeCodigo() {
|
||||
return ageCodigo;
|
||||
}
|
||||
|
||||
public void setAgeCodigo(Integer ageCodigo) {
|
||||
this.ageCodigo = ageCodigo;
|
||||
}
|
||||
|
||||
public Date getAgeFechaRegistro() {
|
||||
return ageFechaRegistro;
|
||||
}
|
||||
|
||||
public void setAgeFechaRegistro(Date ageFechaRegistro) {
|
||||
this.ageFechaRegistro = ageFechaRegistro;
|
||||
}
|
||||
|
||||
public Date getAgeFechaAgenda() {
|
||||
return ageFechaAgenda;
|
||||
}
|
||||
|
||||
public List<EstadoAgendamientoDTO> getEstado() {
|
||||
return estado;
|
||||
}
|
||||
|
||||
public String getLocNombre() {
|
||||
return locNombre;
|
||||
}
|
||||
|
||||
public Double getAgeCobertura() {
|
||||
return ageCobertura;
|
||||
}
|
||||
|
||||
public void setAgeCobertura(Double ageCobertura) {
|
||||
this.ageCobertura = ageCobertura;
|
||||
}
|
||||
|
||||
public Double getAgeFacturado() {
|
||||
return ageFacturado;
|
||||
}
|
||||
|
||||
public void setAgeFacturado(Double ageFacturado) {
|
||||
this.ageFacturado = ageFacturado;
|
||||
}
|
||||
|
||||
public Double getAgeCubierto() {
|
||||
return ageCubierto;
|
||||
}
|
||||
|
||||
public void setAgeCubierto(Double ageCubierto) {
|
||||
this.ageCubierto = ageCubierto;
|
||||
}
|
||||
|
||||
public Double getAgeNoCubierto() {
|
||||
return ageNoCubierto;
|
||||
}
|
||||
|
||||
public void setAgeNoCubierto(Double ageNoCubierto) {
|
||||
this.ageNoCubierto = ageNoCubierto;
|
||||
}
|
||||
|
||||
public Double getAgeCopago() {
|
||||
return ageCopago;
|
||||
}
|
||||
|
||||
public void setAgeCopago(Double ageCopago) {
|
||||
this.ageCopago = ageCopago;
|
||||
}
|
||||
|
||||
public Double getAgeDeducible() {
|
||||
return ageDeducible;
|
||||
}
|
||||
|
||||
public void setAgeDeducible(Double ageDeducible) {
|
||||
this.ageDeducible = ageDeducible;
|
||||
}
|
||||
|
||||
public String getAgeObservaMedico() {
|
||||
return ageObservaMedico;
|
||||
}
|
||||
|
||||
public void setAgeObservaMedico(String ageObservaMedico) {
|
||||
this.ageObservaMedico = ageObservaMedico;
|
||||
}
|
||||
|
||||
public void setAgeMailPaciente(String ageMailPaciente) {
|
||||
this.ageMailPaciente = ageMailPaciente;
|
||||
}
|
||||
|
||||
public String getAgeMailPaciente() {
|
||||
return ageMailPaciente;
|
||||
}
|
||||
|
||||
public void setLocNombre(String locNombre) {
|
||||
this.locNombre = locNombre;
|
||||
}
|
||||
|
||||
public String getPerNombres() {
|
||||
return perNombres;
|
||||
}
|
||||
|
||||
public void setPerNombres(String perNombres) {
|
||||
this.perNombres = perNombres;
|
||||
}
|
||||
|
||||
public String getPerApellidos() {
|
||||
return perApellidos;
|
||||
}
|
||||
|
||||
public void setPerApellidos(String perApellidos) {
|
||||
this.perApellidos = perApellidos;
|
||||
}
|
||||
|
||||
public String getPerIdentificacion() {
|
||||
return perIdentificacion;
|
||||
}
|
||||
|
||||
public void setPerIdentificacion(String perIdentificacion) {
|
||||
this.perIdentificacion = perIdentificacion;
|
||||
}
|
||||
|
||||
public String getPolContrato() {
|
||||
return polContrato;
|
||||
}
|
||||
|
||||
public void setPolContrato(String polContrato) {
|
||||
this.polContrato = polContrato;
|
||||
}
|
||||
|
||||
public String getPreNombre() {
|
||||
return preNombre;
|
||||
}
|
||||
|
||||
public void setPreNombre(String preNombre) {
|
||||
this.preNombre = preNombre;
|
||||
}
|
||||
|
||||
public String getDetNemonico() {
|
||||
return detNemonico;
|
||||
}
|
||||
|
||||
public void setDetNemonico(String detNemonico) {
|
||||
this.detNemonico = detNemonico;
|
||||
}
|
||||
|
||||
public String getDetNombre() {
|
||||
return detNombre;
|
||||
}
|
||||
|
||||
public void setDetNombre(String detNombre) {
|
||||
this.detNombre = detNombre;
|
||||
}
|
||||
|
||||
public String getUsuUsuario() {
|
||||
return usuUsuario;
|
||||
}
|
||||
|
||||
public void setUsuUsuario(String usuUsuario) {
|
||||
this.usuUsuario = usuUsuario;
|
||||
}
|
||||
|
||||
public void setEstado(List<EstadoAgendamientoDTO> estado) {
|
||||
this.estado = estado;
|
||||
}
|
||||
|
||||
public void setAgeFechaAgenda(Date ageFechaAgenda) {
|
||||
this.ageFechaAgenda = ageFechaAgenda;
|
||||
}
|
||||
|
||||
public Date getAgeFechaCita() {
|
||||
return ageFechaCita;
|
||||
}
|
||||
|
||||
public void setAgeFechaCita(Date ageFechaCita) {
|
||||
this.ageFechaCita = ageFechaCita;
|
||||
}
|
||||
|
||||
public Date getAgeFechaConfirma() {
|
||||
return ageFechaConfirma;
|
||||
}
|
||||
|
||||
public void setAgeFechaConfirma(Date ageFechaConfirma) {
|
||||
this.ageFechaConfirma = ageFechaConfirma;
|
||||
}
|
||||
|
||||
public String getAgeSintomas() {
|
||||
return ageSintomas;
|
||||
}
|
||||
|
||||
public void setAgeSintomas(String ageSintomas) {
|
||||
this.ageSintomas = ageSintomas;
|
||||
}
|
||||
|
||||
public String getAgeNemonico() {
|
||||
return ageNemonico;
|
||||
}
|
||||
|
||||
public void setAgeNemonico(String ageNemonico) {
|
||||
this.ageNemonico = ageNemonico;
|
||||
}
|
||||
|
||||
public Integer getDetTipo() {
|
||||
return detTipo;
|
||||
}
|
||||
|
||||
public void setDetTipo(Integer detTipo) {
|
||||
this.detTipo = detTipo;
|
||||
}
|
||||
|
||||
public Double getAgeValor() {
|
||||
return ageValor;
|
||||
}
|
||||
|
||||
public void setAgeValor(Double ageValor) {
|
||||
this.ageValor = ageValor;
|
||||
}
|
||||
|
||||
public String getAgeTelefono() {
|
||||
return ageTelefono;
|
||||
}
|
||||
|
||||
public void setAgeTelefono(String ageTelefono) {
|
||||
this.ageTelefono = ageTelefono;
|
||||
}
|
||||
|
||||
public String getAgeObservaciones() {
|
||||
return ageObservaciones;
|
||||
}
|
||||
|
||||
public void setAgeObservaciones(String ageObservaciones) {
|
||||
this.ageObservaciones = ageObservaciones;
|
||||
}
|
||||
|
||||
public Short getAgeNotificado() {
|
||||
return ageNotificado;
|
||||
}
|
||||
|
||||
public void setAgeNotificado(Short ageNotificado) {
|
||||
this.ageNotificado = ageNotificado;
|
||||
}
|
||||
|
||||
public String getAgeEspecialidad() {
|
||||
return ageEspecialidad;
|
||||
}
|
||||
|
||||
public void setAgeEspecialidad(String ageEspecialidad) {
|
||||
this.ageEspecialidad = ageEspecialidad;
|
||||
}
|
||||
|
||||
public String getAgeMedico() {
|
||||
return ageMedico;
|
||||
}
|
||||
|
||||
public void setAgeMedico(String ageMedico) {
|
||||
this.ageMedico = ageMedico;
|
||||
}
|
||||
|
||||
public String getAgeDocumentos() {
|
||||
return ageDocumentos;
|
||||
}
|
||||
|
||||
public void setAgeDocumentos(String ageDocumentos) {
|
||||
this.ageDocumentos = ageDocumentos;
|
||||
}
|
||||
|
||||
public String getAgeAprobacion() {
|
||||
return ageAprobacion;
|
||||
}
|
||||
|
||||
public void setAgeAprobacion(String ageAprobacion) {
|
||||
this.ageAprobacion = ageAprobacion;
|
||||
}
|
||||
|
||||
public String getAgeExamenes() {
|
||||
return ageExamenes;
|
||||
}
|
||||
|
||||
public void setAgeExamenes(String ageExamenes) {
|
||||
this.ageExamenes = ageExamenes;
|
||||
}
|
||||
|
||||
public String getAgeDiagnostico() {
|
||||
return ageDiagnostico;
|
||||
}
|
||||
|
||||
public void setAgeDiagnostico(String ageDiagnostico) {
|
||||
this.ageDiagnostico = ageDiagnostico;
|
||||
}
|
||||
|
||||
public Short getAgePreexistencia() {
|
||||
return agePreexistencia;
|
||||
}
|
||||
|
||||
public void setAgePreexistencia(Short agePreexistencia) {
|
||||
this.agePreexistencia = agePreexistencia;
|
||||
}
|
||||
|
||||
public String getAgeIndicaciones() {
|
||||
return ageIndicaciones;
|
||||
}
|
||||
|
||||
public void setAgeIndicaciones(String ageIndicaciones) {
|
||||
this.ageIndicaciones = ageIndicaciones;
|
||||
}
|
||||
|
||||
public String getLocCodigo() {
|
||||
return locCodigo;
|
||||
}
|
||||
|
||||
public void setLocCodigo(String locCodigo) {
|
||||
this.locCodigo = locCodigo;
|
||||
}
|
||||
|
||||
public Integer getPerBeneficiario() {
|
||||
return perBeneficiario;
|
||||
}
|
||||
|
||||
public void setPerBeneficiario(Integer perBeneficiario) {
|
||||
this.perBeneficiario = perBeneficiario;
|
||||
}
|
||||
|
||||
public Integer getPolCodigo() {
|
||||
return polCodigo;
|
||||
}
|
||||
|
||||
public void setPolCodigo(Integer polCodigo) {
|
||||
this.polCodigo = polCodigo;
|
||||
}
|
||||
|
||||
public Integer getPreCodigo() {
|
||||
return preCodigo;
|
||||
}
|
||||
|
||||
public void setPreCodigo(Integer preCodigo) {
|
||||
this.preCodigo = preCodigo;
|
||||
}
|
||||
|
||||
public Integer getUsuCodigo() {
|
||||
return usuCodigo;
|
||||
}
|
||||
|
||||
public void setUsuCodigo(Integer usuCodigo) {
|
||||
this.usuCodigo = usuCodigo;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,59 @@
|
|||
package com.qsoft.erp.dto;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class AsientoComprobanteDTO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 98301763769672L;
|
||||
|
||||
private Integer ascCodigo;
|
||||
|
||||
private java.util.Date asiFecha;
|
||||
|
||||
private Integer asiCodigo;
|
||||
|
||||
private Integer facCodigo;
|
||||
|
||||
private Integer favCodigo;
|
||||
|
||||
public Integer getAscCodigo() {
|
||||
return ascCodigo;
|
||||
}
|
||||
|
||||
public void setAscCodigo(Integer ascCodigo) {
|
||||
this.ascCodigo = ascCodigo;
|
||||
}
|
||||
|
||||
public java.util.Date getAsiFecha() {
|
||||
return asiFecha;
|
||||
}
|
||||
|
||||
public void setAsiFecha(java.util.Date asiFecha) {
|
||||
this.asiFecha = asiFecha;
|
||||
}
|
||||
|
||||
public Integer getAsiCodigo() {
|
||||
return asiCodigo;
|
||||
}
|
||||
|
||||
public void setAsiCodigo(Integer asiCodigo) {
|
||||
this.asiCodigo = asiCodigo;
|
||||
}
|
||||
|
||||
public Integer getFacCodigo() {
|
||||
return facCodigo;
|
||||
}
|
||||
|
||||
public void setFacCodigo(Integer facCodigo) {
|
||||
this.facCodigo = facCodigo;
|
||||
}
|
||||
|
||||
public Integer getFavCodigo() {
|
||||
return favCodigo;
|
||||
}
|
||||
|
||||
public void setFavCodigo(Integer favCodigo) {
|
||||
this.favCodigo = favCodigo;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,129 @@
|
|||
package com.qsoft.erp.dto;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class AsientoDTO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 272463823424971L;
|
||||
|
||||
private Integer asiCodigo;
|
||||
|
||||
private Integer asiCanal;
|
||||
|
||||
private String asiConcepto;
|
||||
|
||||
private String asiDocumento;
|
||||
|
||||
private java.util.Date asiFecha;
|
||||
|
||||
private Double asiImporte;
|
||||
|
||||
private Integer asiNumero;
|
||||
|
||||
private String asiOperacion;
|
||||
|
||||
private Short asiEstado;
|
||||
|
||||
private Integer diaCodigo;
|
||||
|
||||
private String ejeCodigo;
|
||||
|
||||
private Integer empCodigo;
|
||||
|
||||
public Integer getAsiCodigo() {
|
||||
return asiCodigo;
|
||||
}
|
||||
|
||||
public void setAsiCodigo(Integer asiCodigo) {
|
||||
this.asiCodigo = asiCodigo;
|
||||
}
|
||||
|
||||
public Integer getAsiCanal() {
|
||||
return asiCanal;
|
||||
}
|
||||
|
||||
public void setAsiCanal(Integer asiCanal) {
|
||||
this.asiCanal = asiCanal;
|
||||
}
|
||||
|
||||
public String getAsiConcepto() {
|
||||
return asiConcepto;
|
||||
}
|
||||
|
||||
public void setAsiConcepto(String asiConcepto) {
|
||||
this.asiConcepto = asiConcepto;
|
||||
}
|
||||
|
||||
public String getAsiDocumento() {
|
||||
return asiDocumento;
|
||||
}
|
||||
|
||||
public void setAsiDocumento(String asiDocumento) {
|
||||
this.asiDocumento = asiDocumento;
|
||||
}
|
||||
|
||||
public java.util.Date getAsiFecha() {
|
||||
return asiFecha;
|
||||
}
|
||||
|
||||
public void setAsiFecha(java.util.Date asiFecha) {
|
||||
this.asiFecha = asiFecha;
|
||||
}
|
||||
|
||||
public Double getAsiImporte() {
|
||||
return asiImporte;
|
||||
}
|
||||
|
||||
public void setAsiImporte(Double asiImporte) {
|
||||
this.asiImporte = asiImporte;
|
||||
}
|
||||
|
||||
public Integer getAsiNumero() {
|
||||
return asiNumero;
|
||||
}
|
||||
|
||||
public void setAsiNumero(Integer asiNumero) {
|
||||
this.asiNumero = asiNumero;
|
||||
}
|
||||
|
||||
public String getAsiOperacion() {
|
||||
return asiOperacion;
|
||||
}
|
||||
|
||||
public void setAsiOperacion(String asiOperacion) {
|
||||
this.asiOperacion = asiOperacion;
|
||||
}
|
||||
|
||||
public Short getAsiEstado() {
|
||||
return asiEstado;
|
||||
}
|
||||
|
||||
public void setAsiEstado(Short asiEstado) {
|
||||
this.asiEstado = asiEstado;
|
||||
}
|
||||
|
||||
public Integer getDiaCodigo() {
|
||||
return diaCodigo;
|
||||
}
|
||||
|
||||
public void setDiaCodigo(Integer diaCodigo) {
|
||||
this.diaCodigo = diaCodigo;
|
||||
}
|
||||
|
||||
public String getEjeCodigo() {
|
||||
return ejeCodigo;
|
||||
}
|
||||
|
||||
public void setEjeCodigo(String ejeCodigo) {
|
||||
this.ejeCodigo = ejeCodigo;
|
||||
}
|
||||
|
||||
public Integer getEmpCodigo() {
|
||||
return empCodigo;
|
||||
}
|
||||
|
||||
public void setEmpCodigo(Integer empCodigo) {
|
||||
this.empCodigo = empCodigo;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,212 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.qsoft.erp.dto;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author james
|
||||
*/
|
||||
public class AuditoriaDTO implements Serializable{
|
||||
|
||||
private static final long serialVersionUID = 260611975539147L;
|
||||
private static final String UNION = "', '";
|
||||
|
||||
private Integer audCodigo;
|
||||
private String audDispositivo;
|
||||
private String audCanal;
|
||||
private String audMedio;
|
||||
private String audAplicacion;
|
||||
private String audTransaccion;
|
||||
private String audUsuario;
|
||||
private String audToken;
|
||||
private String audFecha;
|
||||
private String audIdioma;
|
||||
private String audEmpresa;
|
||||
private String audGeolocalizacion;
|
||||
private String audTipoEjecucion;
|
||||
private String audEntidad;
|
||||
private String audEndpoint;
|
||||
private String audServicio;
|
||||
private String audMetodo;
|
||||
private String audBackend;
|
||||
private Integer audTiempoEjecucion;
|
||||
private String audDinamico;
|
||||
|
||||
public Integer getAudCodigo() {
|
||||
return audCodigo;
|
||||
}
|
||||
|
||||
public void setAudCodigo(Integer audCodigo) {
|
||||
this.audCodigo = audCodigo;
|
||||
}
|
||||
|
||||
public String getAudDispositivo() {
|
||||
return audDispositivo;
|
||||
}
|
||||
|
||||
public void setAudDispositivo(String audDispositivo) {
|
||||
this.audDispositivo = audDispositivo;
|
||||
}
|
||||
|
||||
public String getAudCanal() {
|
||||
return audCanal;
|
||||
}
|
||||
|
||||
public void setAudCanal(String audCanal) {
|
||||
this.audCanal = audCanal;
|
||||
}
|
||||
|
||||
public String getAudMedio() {
|
||||
return audMedio;
|
||||
}
|
||||
|
||||
public void setAudMedio(String audMedio) {
|
||||
this.audMedio = audMedio;
|
||||
}
|
||||
|
||||
public String getAudAplicacion() {
|
||||
return audAplicacion;
|
||||
}
|
||||
|
||||
public void setAudAplicacion(String audAplicacion) {
|
||||
this.audAplicacion = audAplicacion;
|
||||
}
|
||||
|
||||
public String getAudTransaccion() {
|
||||
return audTransaccion;
|
||||
}
|
||||
|
||||
public void setAudTransaccion(String audTransaccion) {
|
||||
this.audTransaccion = audTransaccion;
|
||||
}
|
||||
|
||||
public String getAudUsuario() {
|
||||
return audUsuario;
|
||||
}
|
||||
|
||||
public void setAudUsuario(String audUsuario) {
|
||||
this.audUsuario = audUsuario;
|
||||
}
|
||||
|
||||
public String getAudToken() {
|
||||
return audToken;
|
||||
}
|
||||
|
||||
public void setAudToken(String audToken) {
|
||||
this.audToken = audToken;
|
||||
}
|
||||
|
||||
public String getAudFecha() {
|
||||
return audFecha;
|
||||
}
|
||||
|
||||
public void setAudFecha(String audFecha) {
|
||||
this.audFecha = audFecha;
|
||||
}
|
||||
|
||||
public String getAudIdioma() {
|
||||
return audIdioma;
|
||||
}
|
||||
|
||||
public void setAudIdioma(String audIdioma) {
|
||||
this.audIdioma = audIdioma;
|
||||
}
|
||||
|
||||
public String getAudEmpresa() {
|
||||
return audEmpresa;
|
||||
}
|
||||
|
||||
public void setAudEmpresa(String audEmpresa) {
|
||||
this.audEmpresa = audEmpresa;
|
||||
}
|
||||
|
||||
public String getAudGeolocalizacion() {
|
||||
return audGeolocalizacion;
|
||||
}
|
||||
|
||||
public void setAudGeolocalizacion(String audGeolocalizacion) {
|
||||
this.audGeolocalizacion = audGeolocalizacion;
|
||||
}
|
||||
|
||||
public String getAudTipoEjecucion() {
|
||||
return audTipoEjecucion;
|
||||
}
|
||||
|
||||
public void setAudTipoEjecucion(String audTipoEjecucion) {
|
||||
this.audTipoEjecucion = audTipoEjecucion;
|
||||
}
|
||||
|
||||
public String getAudEntidad() {
|
||||
return audEntidad;
|
||||
}
|
||||
|
||||
public void setAudEntidad(String audEntidad) {
|
||||
this.audEntidad = audEntidad;
|
||||
}
|
||||
|
||||
public String getAudEndpoint() {
|
||||
return audEndpoint;
|
||||
}
|
||||
|
||||
public void setAudEndpoint(String audEndpoint) {
|
||||
this.audEndpoint = audEndpoint;
|
||||
}
|
||||
|
||||
public String getAudServicio() {
|
||||
return audServicio;
|
||||
}
|
||||
|
||||
public void setAudServicio(String audServicio) {
|
||||
this.audServicio = audServicio;
|
||||
}
|
||||
|
||||
public String getAudMetodo() {
|
||||
return audMetodo;
|
||||
}
|
||||
|
||||
public void setAudMetodo(String audMetodo) {
|
||||
this.audMetodo = audMetodo;
|
||||
}
|
||||
|
||||
public String getAudBackend() {
|
||||
return audBackend;
|
||||
}
|
||||
|
||||
public void setAudBackend(String audBackend) {
|
||||
this.audBackend = audBackend;
|
||||
}
|
||||
|
||||
public Integer getAudTiempoEjecucion() {
|
||||
return audTiempoEjecucion;
|
||||
}
|
||||
|
||||
public void setAudTiempoEjecucion(Integer audTiempoEjecucion) {
|
||||
this.audTiempoEjecucion = audTiempoEjecucion;
|
||||
}
|
||||
|
||||
public String getAudDinamico() {
|
||||
return audDinamico;
|
||||
}
|
||||
|
||||
public void setAudDinamico(String audDinamico) {
|
||||
this.audDinamico = audDinamico;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder build = new StringBuilder();
|
||||
build.append("(null, '").append(audDispositivo).append(UNION).append(audCanal).append(UNION).append(audMedio);
|
||||
build.append(UNION).append(audAplicacion).append(UNION).append(audTransaccion).append(UNION).append(audUsuario);
|
||||
build.append(UNION).append(audToken).append(UNION).append(audFecha).append(UNION).append(audIdioma);
|
||||
build.append(UNION).append(audEmpresa).append(UNION).append(audGeolocalizacion).append(UNION).append(audTipoEjecucion);
|
||||
build.append(UNION).append(audEntidad).append(UNION).append(audEndpoint).append(UNION).append(audServicio).append(UNION);
|
||||
build.append(audMetodo).append(UNION).append(audBackend).append("' , ").append(audTiempoEjecucion).append(", '").append(audDinamico).append("')");
|
||||
return build.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,99 @@
|
|||
package com.qsoft.erp.dto;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class BodegaDTO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 898493877064396L;
|
||||
|
||||
private Integer bodCodigo;
|
||||
|
||||
private String bodNombre;
|
||||
|
||||
private String bodDireccion;
|
||||
|
||||
private String bodCodPostal;
|
||||
|
||||
private Double bodCapacidad;
|
||||
|
||||
private String bodObservacion;
|
||||
|
||||
private Short bodEstado;
|
||||
|
||||
private Integer empCodigo;
|
||||
|
||||
private Integer locCodigo;
|
||||
|
||||
public Integer getBodCodigo() {
|
||||
return bodCodigo;
|
||||
}
|
||||
|
||||
public void setBodCodigo(Integer bodCodigo) {
|
||||
this.bodCodigo = bodCodigo;
|
||||
}
|
||||
|
||||
public String getBodNombre() {
|
||||
return bodNombre;
|
||||
}
|
||||
|
||||
public void setBodNombre(String bodNombre) {
|
||||
this.bodNombre = bodNombre;
|
||||
}
|
||||
|
||||
public String getBodDireccion() {
|
||||
return bodDireccion;
|
||||
}
|
||||
|
||||
public void setBodDireccion(String bodDireccion) {
|
||||
this.bodDireccion = bodDireccion;
|
||||
}
|
||||
|
||||
public String getBodCodPostal() {
|
||||
return bodCodPostal;
|
||||
}
|
||||
|
||||
public void setBodCodPostal(String bodCodPostal) {
|
||||
this.bodCodPostal = bodCodPostal;
|
||||
}
|
||||
|
||||
public Double getBodCapacidad() {
|
||||
return bodCapacidad;
|
||||
}
|
||||
|
||||
public void setBodCapacidad(Double bodCapacidad) {
|
||||
this.bodCapacidad = bodCapacidad;
|
||||
}
|
||||
|
||||
public String getBodObservacion() {
|
||||
return bodObservacion;
|
||||
}
|
||||
|
||||
public void setBodObservacion(String bodObservacion) {
|
||||
this.bodObservacion = bodObservacion;
|
||||
}
|
||||
|
||||
public Short getBodEstado() {
|
||||
return bodEstado;
|
||||
}
|
||||
|
||||
public void setBodEstado(Short bodEstado) {
|
||||
this.bodEstado = bodEstado;
|
||||
}
|
||||
|
||||
public Integer getEmpCodigo() {
|
||||
return empCodigo;
|
||||
}
|
||||
|
||||
public void setEmpCodigo(Integer empCodigo) {
|
||||
this.empCodigo = empCodigo;
|
||||
}
|
||||
|
||||
public Integer getLocCodigo() {
|
||||
return locCodigo;
|
||||
}
|
||||
|
||||
public void setLocCodigo(Integer locCodigo) {
|
||||
this.locCodigo = locCodigo;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,118 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.qsoft.erp.dto;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author james
|
||||
*/
|
||||
public class CatalogoDTO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 8485542727231L;
|
||||
|
||||
private Integer catCodigo;
|
||||
private String catNemonico;
|
||||
private String catGrupo;
|
||||
private String catNombre;
|
||||
private String catDescripcion;
|
||||
private Short catEstado;
|
||||
private Integer empCodigo;
|
||||
|
||||
public CatalogoDTO() {
|
||||
}
|
||||
|
||||
public CatalogoDTO(Integer catCodigo) {
|
||||
this.catCodigo = catCodigo;
|
||||
}
|
||||
|
||||
public CatalogoDTO(Integer catCodigo, String catNemonico, String catGrupo, String catNombre) {
|
||||
this.catCodigo = catCodigo;
|
||||
this.catNemonico = catNemonico;
|
||||
this.catGrupo = catGrupo;
|
||||
this.catNombre = catNombre;
|
||||
}
|
||||
|
||||
public Integer getCatCodigo() {
|
||||
return catCodigo;
|
||||
}
|
||||
|
||||
public void setCatCodigo(Integer catCodigo) {
|
||||
this.catCodigo = catCodigo;
|
||||
}
|
||||
|
||||
public String getCatNemonico() {
|
||||
return catNemonico;
|
||||
}
|
||||
|
||||
public void setCatNemonico(String catNemonico) {
|
||||
this.catNemonico = catNemonico;
|
||||
}
|
||||
|
||||
public String getCatGrupo() {
|
||||
return catGrupo;
|
||||
}
|
||||
|
||||
public void setCatGrupo(String catGrupo) {
|
||||
this.catGrupo = catGrupo;
|
||||
}
|
||||
|
||||
public String getCatNombre() {
|
||||
return catNombre;
|
||||
}
|
||||
|
||||
public void setCatNombre(String catNombre) {
|
||||
this.catNombre = catNombre;
|
||||
}
|
||||
|
||||
public String getCatDescripcion() {
|
||||
return catDescripcion;
|
||||
}
|
||||
|
||||
public void setCatDescripcion(String catDescripcion) {
|
||||
this.catDescripcion = catDescripcion;
|
||||
}
|
||||
|
||||
public Short getCatEstado() {
|
||||
return catEstado;
|
||||
}
|
||||
|
||||
public void setCatEstado(Short catEstado) {
|
||||
this.catEstado = catEstado;
|
||||
}
|
||||
|
||||
public Integer getEmpCodigo() {
|
||||
return empCodigo;
|
||||
}
|
||||
|
||||
public void setEmpCodigo(Integer empCodigo) {
|
||||
this.empCodigo = empCodigo;
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
int hash = 0;
|
||||
hash += (catCodigo != null ? catCodigo.hashCode() : 0);
|
||||
return hash;
|
||||
}
|
||||
|
||||
public boolean equals(Object object) {
|
||||
// TODO: Warning - this method won't work in the case the id fields are not set
|
||||
if (!(object instanceof CatalogoDTO)) {
|
||||
return false;
|
||||
}
|
||||
CatalogoDTO other = (CatalogoDTO) object;
|
||||
if ((this.catCodigo == null && other.catCodigo != null) || (this.catCodigo != null && !this.catCodigo.equals(other.catCodigo))) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "com.qsoft.erp.model.CatalogoDTO[ catCodigo=" + catCodigo + " ]";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,263 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.qsoft.erp.dto;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author james
|
||||
*/
|
||||
public class CoberturasPlanDTO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 6173436637990L;
|
||||
|
||||
private Integer copCodigo;
|
||||
private Double copCopago;
|
||||
private Double copTope;
|
||||
private Short copEstado;
|
||||
private Integer detPrestacion;
|
||||
private String prestacionNemonico;
|
||||
private Integer detTipoModalidad;
|
||||
private String modalidadNemonico;
|
||||
private Integer detTipo;
|
||||
private String tipoNemonico;
|
||||
private Integer plaCodigo;
|
||||
private Integer detPais;
|
||||
private String paisNemonico;
|
||||
private String modalidadNombre;
|
||||
private String tipoNombre;
|
||||
private String prestacionNombre;
|
||||
private String paisNombre;
|
||||
private String modalidadDescripcion;
|
||||
private String tipoDescripcion;
|
||||
private String prestacionDescripcion;
|
||||
private String paisDescripcion;
|
||||
private Short copTipoTarifario;
|
||||
private Double copValorDeducible;
|
||||
private Integer detTipoDeducible;
|
||||
private String tipoDeducibleNemonico;
|
||||
private String tipoDeducibleNombre;
|
||||
|
||||
public Integer getCopCodigo() {
|
||||
return copCodigo;
|
||||
}
|
||||
|
||||
public String getModalidadDescripcion() {
|
||||
return modalidadDescripcion;
|
||||
}
|
||||
|
||||
public void setModalidadDescripcion(String modalidadDescripcion) {
|
||||
this.modalidadDescripcion = modalidadDescripcion;
|
||||
}
|
||||
|
||||
public String getTipoDescripcion() {
|
||||
return tipoDescripcion;
|
||||
}
|
||||
|
||||
public void setTipoDescripcion(String tipoDescripcion) {
|
||||
this.tipoDescripcion = tipoDescripcion;
|
||||
}
|
||||
|
||||
public Short getCopTipoTarifario() {
|
||||
return copTipoTarifario;
|
||||
}
|
||||
|
||||
public void setCopTipoTarifario(Short copTipoTarifario) {
|
||||
this.copTipoTarifario = copTipoTarifario;
|
||||
}
|
||||
|
||||
public String getTipoDeducibleNombre() {
|
||||
return tipoDeducibleNombre;
|
||||
}
|
||||
|
||||
public void setTipoDeducibleNombre(String tipoDeducibleNombre) {
|
||||
this.tipoDeducibleNombre = tipoDeducibleNombre;
|
||||
}
|
||||
|
||||
public Double getCopValorDeducible() {
|
||||
return copValorDeducible;
|
||||
}
|
||||
|
||||
public void setCopValorDeducible(Double copValorDeducible) {
|
||||
this.copValorDeducible = copValorDeducible;
|
||||
}
|
||||
|
||||
public Integer getDetTipoDeducible() {
|
||||
return detTipoDeducible;
|
||||
}
|
||||
|
||||
public void setDetTipoDeducible(Integer detTipoDeducible) {
|
||||
this.detTipoDeducible = detTipoDeducible;
|
||||
}
|
||||
|
||||
public String getTipoDeducibleNemonico() {
|
||||
return tipoDeducibleNemonico;
|
||||
}
|
||||
|
||||
public void setTipoDeducibleNemonico(String tipoDeducibleNemonico) {
|
||||
this.tipoDeducibleNemonico = tipoDeducibleNemonico;
|
||||
}
|
||||
|
||||
public String getPrestacionDescripcion() {
|
||||
return prestacionDescripcion;
|
||||
}
|
||||
|
||||
public void setPrestacionDescripcion(String prestacionDescripcion) {
|
||||
this.prestacionDescripcion = prestacionDescripcion;
|
||||
}
|
||||
|
||||
public String getPaisDescripcion() {
|
||||
return paisDescripcion;
|
||||
}
|
||||
|
||||
public void setPaisDescripcion(String paisDescripcion) {
|
||||
this.paisDescripcion = paisDescripcion;
|
||||
}
|
||||
|
||||
public String getPrestacionNemonico() {
|
||||
return prestacionNemonico;
|
||||
}
|
||||
|
||||
public String getModalidadNombre() {
|
||||
return modalidadNombre;
|
||||
}
|
||||
|
||||
public void setModalidadNombre(String modalidadNombre) {
|
||||
this.modalidadNombre = modalidadNombre;
|
||||
}
|
||||
|
||||
public String getTipoNombre() {
|
||||
return tipoNombre;
|
||||
}
|
||||
|
||||
public void setTipoNombre(String tipoNombre) {
|
||||
this.tipoNombre = tipoNombre;
|
||||
}
|
||||
|
||||
public String getPrestacionNombre() {
|
||||
return prestacionNombre;
|
||||
}
|
||||
|
||||
public void setPrestacionNombre(String prestacionNombre) {
|
||||
this.prestacionNombre = prestacionNombre;
|
||||
}
|
||||
|
||||
public String getPaisNombre() {
|
||||
return paisNombre;
|
||||
}
|
||||
|
||||
public void setPaisNombre(String paisNombre) {
|
||||
this.paisNombre = paisNombre;
|
||||
}
|
||||
|
||||
public void setPrestacionNemonico(String prestacionNemonico) {
|
||||
this.prestacionNemonico = prestacionNemonico;
|
||||
}
|
||||
|
||||
public String getModalidadNemonico() {
|
||||
return modalidadNemonico;
|
||||
}
|
||||
|
||||
public void setModalidadNemonico(String modalidadNemonico) {
|
||||
this.modalidadNemonico = modalidadNemonico;
|
||||
}
|
||||
|
||||
public String getTipoNemonico() {
|
||||
return tipoNemonico;
|
||||
}
|
||||
|
||||
public void setTipoNemonico(String tipoNemonico) {
|
||||
this.tipoNemonico = tipoNemonico;
|
||||
}
|
||||
|
||||
public String getPaisNemonico() {
|
||||
return paisNemonico;
|
||||
}
|
||||
|
||||
public void setPaisNemonico(String paisNemonico) {
|
||||
this.paisNemonico = paisNemonico;
|
||||
}
|
||||
|
||||
public void setCopCodigo(Integer copCodigo) {
|
||||
this.copCodigo = copCodigo;
|
||||
}
|
||||
|
||||
public Double getCopCopago() {
|
||||
return copCopago;
|
||||
}
|
||||
|
||||
public void setCopCopago(Double copCopago) {
|
||||
this.copCopago = copCopago;
|
||||
}
|
||||
|
||||
public Double getCopTope() {
|
||||
return copTope;
|
||||
}
|
||||
|
||||
public void setCopTope(Double copTope) {
|
||||
this.copTope = copTope;
|
||||
}
|
||||
|
||||
public Short getCopEstado() {
|
||||
return copEstado;
|
||||
}
|
||||
|
||||
public void setCopEstado(Short copEstado) {
|
||||
this.copEstado = copEstado;
|
||||
}
|
||||
|
||||
public Integer getDetPrestacion() {
|
||||
return detPrestacion;
|
||||
}
|
||||
|
||||
public void setDetPrestacion(Integer detPrestacion) {
|
||||
this.detPrestacion = detPrestacion;
|
||||
}
|
||||
|
||||
public Integer getDetTipoModalidad() {
|
||||
return detTipoModalidad;
|
||||
}
|
||||
|
||||
public void setDetTipoModalidad(Integer detTipoModalidad) {
|
||||
this.detTipoModalidad = detTipoModalidad;
|
||||
}
|
||||
|
||||
public Integer getDetTipo() {
|
||||
return detTipo;
|
||||
}
|
||||
|
||||
public void setDetTipo(Integer detTipo) {
|
||||
this.detTipo = detTipo;
|
||||
}
|
||||
|
||||
public Integer getPlaCodigo() {
|
||||
return plaCodigo;
|
||||
}
|
||||
|
||||
public void setPlaCodigo(Integer plaCodigo) {
|
||||
this.plaCodigo = plaCodigo;
|
||||
}
|
||||
|
||||
public Integer getDetPais() {
|
||||
return detPais;
|
||||
}
|
||||
|
||||
public void setDetPais(Integer detPais) {
|
||||
this.detPais = detPais;
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
int hash = 0;
|
||||
hash += (copCodigo != null ? copCodigo.hashCode() : 0);
|
||||
return hash;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "com.qsoft.erp.model.CoberturasPlan[ copCodigo=" + copCodigo + " ]";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,152 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.qsoft.erp.dto;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author james
|
||||
*/
|
||||
public class CuentaBancariaDTO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 8502680742813L;
|
||||
|
||||
private Integer cueCodigo;
|
||||
private String cueCuenta;
|
||||
private Short cueEstado;
|
||||
private Short cueDebito;
|
||||
private Integer detIfi;
|
||||
private Integer detTipoCuenta;
|
||||
private Integer perCodigo;
|
||||
private String detNombreIfi;
|
||||
private String detNombreTipoCuenta;
|
||||
private String cueIdentificacion;
|
||||
private String cueNombreDebito;
|
||||
|
||||
public CuentaBancariaDTO() {
|
||||
}
|
||||
|
||||
public CuentaBancariaDTO(Integer cueCodigo) {
|
||||
this.cueCodigo = cueCodigo;
|
||||
}
|
||||
|
||||
public CuentaBancariaDTO(Integer cueCodigo, String cueCuenta) {
|
||||
this.cueCodigo = cueCodigo;
|
||||
this.cueCuenta = cueCuenta;
|
||||
}
|
||||
|
||||
public Integer getCueCodigo() {
|
||||
return cueCodigo;
|
||||
}
|
||||
|
||||
public void setCueCodigo(Integer cueCodigo) {
|
||||
this.cueCodigo = cueCodigo;
|
||||
}
|
||||
|
||||
public String getCueIdentificacion() {
|
||||
return cueIdentificacion;
|
||||
}
|
||||
|
||||
public void setCueIdentificacion(String cueIdentificacion) {
|
||||
this.cueIdentificacion = cueIdentificacion;
|
||||
}
|
||||
|
||||
public String getCueNombreDebito() {
|
||||
return cueNombreDebito;
|
||||
}
|
||||
|
||||
public void setCueNombreDebito(String cueNombreDebito) {
|
||||
this.cueNombreDebito = cueNombreDebito;
|
||||
}
|
||||
|
||||
public String getCueCuenta() {
|
||||
return cueCuenta;
|
||||
}
|
||||
|
||||
public void setCueCuenta(String cueCuenta) {
|
||||
this.cueCuenta = cueCuenta;
|
||||
}
|
||||
|
||||
public Short getCueDebito() {
|
||||
return cueDebito;
|
||||
}
|
||||
|
||||
public void setCueDebito(Short cueDebito) {
|
||||
this.cueDebito = cueDebito;
|
||||
}
|
||||
|
||||
public Short getCueEstado() {
|
||||
return cueEstado;
|
||||
}
|
||||
|
||||
public void setCueEstado(Short cueEstado) {
|
||||
this.cueEstado = cueEstado;
|
||||
}
|
||||
|
||||
public Integer getDetIfi() {
|
||||
return detIfi;
|
||||
}
|
||||
|
||||
public void setDetIfi(Integer detIfi) {
|
||||
this.detIfi = detIfi;
|
||||
}
|
||||
|
||||
public Integer getDetTipoCuenta() {
|
||||
return detTipoCuenta;
|
||||
}
|
||||
|
||||
public void setDetTipoCuenta(Integer detTipoCuenta) {
|
||||
this.detTipoCuenta = detTipoCuenta;
|
||||
}
|
||||
|
||||
public Integer getPerCodigo() {
|
||||
return perCodigo;
|
||||
}
|
||||
|
||||
public void setPerCodigo(Integer perCodigo) {
|
||||
this.perCodigo = perCodigo;
|
||||
}
|
||||
/**------------------------------------Nombre de los detalles---------*/
|
||||
public String getDetNombreTipoCuenta() {
|
||||
return detNombreTipoCuenta;
|
||||
}
|
||||
public void setDetNombreTipoCuenta(String detNombreTipoCuenta) {
|
||||
this.detNombreTipoCuenta = detNombreTipoCuenta;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public String getDetNombreIfi() {
|
||||
return detNombreIfi;
|
||||
}
|
||||
|
||||
public void setDetNombreIfi(String detNombreIfi) {
|
||||
this.detNombreIfi = detNombreIfi;
|
||||
}
|
||||
public int hashCode() {
|
||||
int hash = 0;
|
||||
hash += (cueCodigo != null ? cueCodigo.hashCode() : 0);
|
||||
return hash;
|
||||
}
|
||||
|
||||
public boolean equals(Object object) {
|
||||
// TODO: Warning - this method won't work in the case the id fields are not set
|
||||
if (!(object instanceof CuentaBancariaDTO)) {
|
||||
return false;
|
||||
}
|
||||
CuentaBancariaDTO other = (CuentaBancariaDTO) object;
|
||||
if ((this.cueCodigo == null && other.cueCodigo != null) || (this.cueCodigo != null && !this.cueCodigo.equals(other.cueCodigo))) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "com.qsoft.erp.model.CuentaBancariaDTO[ cueCodigo=" + cueCodigo + " ]";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,109 @@
|
|||
package com.qsoft.erp.dto;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class CuentaBancoDTO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 614583681346726L;
|
||||
|
||||
private String cubCodigo;
|
||||
|
||||
private String cubCodSubcuenta;
|
||||
|
||||
private String cubCodsubcuentagasto;
|
||||
|
||||
private String cubDescripcion;
|
||||
|
||||
private String cubIban;
|
||||
|
||||
private String cubSwift;
|
||||
|
||||
private String cubSufijoSepa;
|
||||
|
||||
private Short cubEstado;
|
||||
|
||||
private Integer empCodigo;
|
||||
|
||||
private Integer perCodigo;
|
||||
|
||||
public String getCubCodigo() {
|
||||
return cubCodigo;
|
||||
}
|
||||
|
||||
public void setCubCodigo(String cubCodigo) {
|
||||
this.cubCodigo = cubCodigo;
|
||||
}
|
||||
|
||||
public String getCubCodSubcuenta() {
|
||||
return cubCodSubcuenta;
|
||||
}
|
||||
|
||||
public void setCubCodSubcuenta(String cubCodSubcuenta) {
|
||||
this.cubCodSubcuenta = cubCodSubcuenta;
|
||||
}
|
||||
|
||||
public String getCubCodsubcuentagasto() {
|
||||
return cubCodsubcuentagasto;
|
||||
}
|
||||
|
||||
public void setCubCodsubcuentagasto(String cubCodsubcuentagasto) {
|
||||
this.cubCodsubcuentagasto = cubCodsubcuentagasto;
|
||||
}
|
||||
|
||||
public String getCubDescripcion() {
|
||||
return cubDescripcion;
|
||||
}
|
||||
|
||||
public void setCubDescripcion(String cubDescripcion) {
|
||||
this.cubDescripcion = cubDescripcion;
|
||||
}
|
||||
|
||||
public String getCubIban() {
|
||||
return cubIban;
|
||||
}
|
||||
|
||||
public void setCubIban(String cubIban) {
|
||||
this.cubIban = cubIban;
|
||||
}
|
||||
|
||||
public String getCubSwift() {
|
||||
return cubSwift;
|
||||
}
|
||||
|
||||
public void setCubSwift(String cubSwift) {
|
||||
this.cubSwift = cubSwift;
|
||||
}
|
||||
|
||||
public String getCubSufijoSepa() {
|
||||
return cubSufijoSepa;
|
||||
}
|
||||
|
||||
public void setCubSufijoSepa(String cubSufijoSepa) {
|
||||
this.cubSufijoSepa = cubSufijoSepa;
|
||||
}
|
||||
|
||||
public Short getCubEstado() {
|
||||
return cubEstado;
|
||||
}
|
||||
|
||||
public void setCubEstado(Short cubEstado) {
|
||||
this.cubEstado = cubEstado;
|
||||
}
|
||||
|
||||
public Integer getEmpCodigo() {
|
||||
return empCodigo;
|
||||
}
|
||||
|
||||
public void setEmpCodigo(Integer empCodigo) {
|
||||
this.empCodigo = empCodigo;
|
||||
}
|
||||
|
||||
public Integer getPerCodigo() {
|
||||
return perCodigo;
|
||||
}
|
||||
|
||||
public void setPerCodigo(Integer perCodigo) {
|
||||
this.perCodigo = perCodigo;
|
||||
}
|
||||
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue