diff --git a/nb-configuration.xml b/nb-configuration.xml index 8e8a342..154ec0a 100755 --- a/nb-configuration.xml +++ b/nb-configuration.xml @@ -24,6 +24,7 @@ Any value defined here will override the pom.xml file value but is only applicab /scss:/css js/libs - pfv3ee6 + pfv5ee8 + true diff --git a/src/main/java/com/qsoft/wmp/services/rest/MultipartResource.java b/src/main/java/com/qsoft/wmp/services/rest/MultipartResource.java index baa3c03..00315bd 100644 --- a/src/main/java/com/qsoft/wmp/services/rest/MultipartResource.java +++ b/src/main/java/com/qsoft/wmp/services/rest/MultipartResource.java @@ -15,10 +15,12 @@ import com.qsoft.erp.constantes.EntidadEnum; import com.qsoft.erp.dominio.MultipartService; import com.qsoft.erp.dominio.exception.DominioExcepcion; import com.qsoft.erp.dominio.util.AuditoriaUtil; +import com.qsoft.erp.dominio.util.DominioUtil; import com.qsoft.erp.dto.AuditoriaDTO; import com.qsoft.erp.dto.DocumentoDTO; import com.qsoft.erp.dto.LiquidacionDTO; import com.qsoft.wmp.services.util.ServiceUtil; +import com.qsoft.wmp.services.xsd.EntradaAccion; import com.qsoft.wmp.services.xsd.EntradaLiquidacion; import com.qsoft.wmp.services.xsd.SalidaConsulta; import java.io.IOException; @@ -58,6 +60,9 @@ public class MultipartResource { @Inject private AuditoriaUtil auditoria; + + @Inject + private DominioUtil dominioUtil; @Context private HttpServletRequest request; @@ -130,7 +135,7 @@ public class MultipartResource { "Uno o mas documentos enviados son nulos por favor verifique la informacion"); } EntidadEnum entidad = Enum.valueOf(EntidadEnum.class, entrada.getBodyIn().getEntidad()); - data = this.multipart.multipartGenerico(entrada.getHeaderIn(), entidad, + data = this.multipart.multipartLiquidacion(entrada.getHeaderIn(), entidad, entrada.getBodyIn().getParametros(), entrada.getBodyIn().getTipoConsulta()); HeaderMS header = entrada.getHeaderIn(); header.setFechaHora(DominioConstantes.getDateTime()); @@ -156,6 +161,100 @@ public class MultipartResource { return salida; } + @POST + @Path("documento") + @Consumes(MediaType.MULTIPART_FORM_DATA) + @Produces(MediaType.APPLICATION_JSON) + public SalidaConsulta postDocumento(FormDataMultiPart input) { + SalidaConsulta salida = null; + EntradaAccion entrada = null; + Long time = System.currentTimeMillis(); + if (input != null) { + List data = new ArrayList<>(); + Map> parts = input.getFields(); + int i = 0; + try { + List documentoDTOs = new ArrayList<>(); + for (List p : parts.values()) { + System.out.println("FormDataBodyPart p.get(0) =>: " + p.get(0)); + FormDataBodyPart bodyPart = p.get(0); + if (i == 0) { + entrada = getEntradaAccion(bodyPart); + if (entrada != null && entrada.getBodyIn() != null) { + AuditoriaDTO dto = ServiceUtil.crearAuditoria(entrada.getHeaderIn(), entrada.getBodyIn().getEntidad(), + super.getClass().getName() + ".posFile", request.getRequestURL().toString(), + MultipartService.class.getName() + ".multipartGenerico", ServiceUtil.REQUEST, + "" + entrada.getBodyIn().getTipoAccion(), 0, ServiceUtil.getJson(entrada)); + this.auditoria.AddAuditoria(dto); + } + } else { + InputStream in = bodyPart.getValueAs(InputStream.class); + try { + if (in != null && entrada != null && entrada.getBodyIn().getEntidades() != null) { + System.out.println("===== Entro a la condicion ====="); + DocumentoDTO doc = (DocumentoDTO) this.dominioUtil.crearObjeto(DocumentoDTO.class, entrada.getBodyIn().getEntidades().get(i - 1)); + doc.setData(in.readAllBytes()); + documentoDTOs.add(doc); + } + } catch (IOException ex) { + System.out.println("ERROR CARGANDO ARCHIVO " + ex); + } + } + i++; + } + if (!validarEntrada(entrada, documentoDTOs)) { + throw new DominioExcepcion(ErrorTipo.ERROR, CodigoRespuesta.CODIGO_VALOR_NULO, + "Uno o mas documentos enviados son nulos por favor verifique la informacion"); + } + EntidadEnum entidad = Enum.valueOf(EntidadEnum.class, entrada.getBodyIn().getEntidad()); + data = this.multipart.multipartGenerico(entrada.getHeaderIn(), entidad, + entrada.getBodyIn().getEntidades(), entrada.getBodyIn().getTipoAccion(), documentoDTOs); + HeaderMS header = entrada.getHeaderIn(); + header.setFechaHora(DominioConstantes.getDateTime()); + salida = ServiceUtil.crearSalidaConsultaOk(header, entrada.getBodyIn().getEntidad(), data); + } catch (DominioExcepcion ex) { + salida = ServiceUtil.crearSalidaConsultaError(ex.getCodigo(), ex.getMensaje()); + ex.printStackTrace(); + } catch (Exception ex) { + salida = ServiceUtil.crearSalidaConsultaError(CodigoRespuesta.CODIGO_ERROR_GENERICO, ex.toString()); + ex.printStackTrace(); + } + + } else { + ServiceUtil.crearSalidaConsultaError(CodigoRespuesta.CODIGO_VALOR_NULO, "ERROR. La entrada no puede ser nula"); + } + time = System.currentTimeMillis() - time; + AuditoriaDTO dto = ServiceUtil.crearAuditoria(salida.getHeaderOut(), salida.getBodyOut().getEntidad(), + super.getClass().getName() + ".posFile", request.getRequestURL().toString(), + MultipartService.class.getName() + ".multipartGenerico", ServiceUtil.RESPONSE, + "", time.intValue(), ServiceUtil.getJson(salida.getError())); + this.auditoria.AddAuditoria(dto); + + return salida; + } + + /** + * + * @param entrada + * @return + */ + private boolean validarEntrada(EntradaAccion entrada, List docs) { + boolean estado = true; + if (entrada == null || entrada.getBodyIn() == null || entrada.getBodyIn().getEntidades() == null) { + return false; + } + if (entrada.getBodyIn() != null && entrada.getBodyIn().getEntidades() != null) { + for (DocumentoDTO docMap : docs) { + System.out.println("Docmap => " + docMap.toString()); + if (docMap == null || docMap.getData() == null) { + estado = false; + break; + } + } + } + return estado; + } + /** * * @param entrada @@ -181,6 +280,31 @@ public class MultipartResource { return estado; } + /** + * Crea la entrada a partir de la consulta del servicio + * + * @param bp + * @return + */ + public EntradaAccion getEntradaAccion(FormDataBodyPart bp) throws DominioExcepcion { + EntradaAccion entrada = null; + System.out.println("=====> entrada"); + InputStream in = bp.getValueAs(InputStream.class); + if (in != null) { + System.out.println("======> in: " + in.toString()); + try { + String json = new String(in.readAllBytes()); + ObjectMapper maper = new ObjectMapper(); + maper.configure(JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES, true); + entrada = maper.readValue(json, EntradaAccion.class); + } catch (IOException ex) { + throw new DominioExcepcion(ErrorTipo.ERROR, CodigoRespuesta.CODIGO_VALOR_NULO, "No es posible convertir el JSON " + ex.toString()); + } + } + System.out.println("CREO ENTRADA... " + entrada); + return entrada; + } + /** * Crea la entrada a partir de la consulta del servicio * diff --git a/src/test/java/com/qsoft/test/salida.json b/src/test/java/com/qsoft/test/salida.json index 12674e2..df937a7 100644 --- a/src/test/java/com/qsoft/test/salida.json +++ b/src/test/java/com/qsoft/test/salida.json @@ -1,38 +1,10 @@ + { - "headerIn": { - "dispositivo": "WeLaptop", - "canal": null, - "medio": null, - "aplicacion": "WeMedicalProV1.0", - "tipoTransaccion": "0101112", - "usuario": "james", - "uuid": "be00033837a8ebec86c9f17e1df8f4527815684c7f45b8214d2f3839ef678a71", - "fechaHora": null, - "idioma": null, - "empresa": null, - "geolocalizacion": null - }, - "bodyIn": { - "tipoAccion": 1, - "entidad": "Poliza", - "entidades": [ - { - "polBroker": "PANDILLA", - "detModalidad": 26, - "detPeriodicidad": 17202, - "detSucursalIfi": 23484, - "plaCodigo": 71, - "detFormaPago": 23516, - "empCodigo": 3, - "perCedulaTitular": "1103969430", - "detTipoIdentificacion": 3, - "detIfi": 23610, - "detTipoCuenta": 17187, - "polDebito": "MIguel triana", - "detPromocion": -1, - "cedulaDebito": "0920752326", - "cuentaDebito": "45454545" - } - ] - } -} \ No newline at end of file + "contacto": ["Sr don daviik"], + "contactoContable": ["Contador demo"], + "emailContable": ["facturas@test.com"], + "teléfonoContable": [], + "telefono": ["02365487", "03569748", "0996852147"], + "telefonoContacto": ["0965479965"], + "email": ["email1@test.com", "email2@test.com"] +} diff --git a/src/test/java/com/qsoft/test/testJson.json b/src/test/java/com/qsoft/test/testJson.json index 5d81328..b21f67d 100644 --- a/src/test/java/com/qsoft/test/testJson.json +++ b/src/test/java/com/qsoft/test/testJson.json @@ -4,9 +4,9 @@ "canal": null, "medio": null, "aplicacion": "WeMedicalProV1.0", - "tipoTransaccion": "0101115", + "tipoTransaccion": "0101116", "usuario": "1715060073", - "uuid": "32c039d54d17cdb903c400e636379625aff689effbf08617b653bae17af76629", + "uuid": "sak8743892ur89w37493q3ure213098r320", "fechaHora": null, "idioma": null, "empresa": null, @@ -14,40 +14,18 @@ }, "bodyIn": { "tipoAccion": 1, - "entidad": "Plan", - "entidades": [{ - "empCodigo": 3, - "detTipo": 23888, - "detModalidad": 27, - "detDeducible": 30, - "detTarifario": 32, - "plaNombre": "aaa", - "plaRutaContrato": "/data/wmp/plan/aaa", - "plaValorAnual": 22, - "plaValorMensual": 1231, - "plaImpuesto": 12, - "plaPorDescuento": 12, - "plaEdadHijos": 12, - "plaEdadminTitular": 12, - "plaEdadTitular": 22, - "plaNumBeneficiarios": 22, - "plaProducto": "22", - "plaCoberturaMaxima": 22, - "plaValorDeducible": 22, - "plaCodAcess": "12", - "plaEstado": 1, - "plaTipo": "21", - "plaCodExt": "22aa", - "coberturasPlan": [{ - "detTipo": 23900, - "detPrestacion": 15044, - "detTipoModalidad": 25, - "detPais": 24, - "copCopago": 0.11, - "copTope": 222, - "copTipoTarifario": 2, - "copEstado": 1 - }] - }] + "entidad": "Usuario", + "entidades": [ + { + "usuUsuario": "1722779285", + "usuNombre": "Diego Alejandro Panchi Ponce", + "usuDescripcion": "Usuario Diego Panchi suscripciones", + "usuEmail": "suscripcion@segurosmedi.com", + "usuPassword": "Diego@2020*", + "usuEstado": 1, + "usuIdOrigen": "20423", + "usuOrigen": "PERSONA" + } + ] } } \ No newline at end of file diff --git a/target/surefire-reports/com.qsoft.test.Tester/Command line test.html b/target/surefire-reports/com.qsoft.test.Tester/Command line test.html index 36b6fbb..4463062 100644 --- a/target/surefire-reports/com.qsoft.test.Tester/Command line test.html +++ b/target/surefire-reports/com.qsoft.test.Tester/Command line test.html @@ -57,7 +57,7 @@ function toggleAllBoxes() { Tests passed/Failed/Skipped:0/0/0 -Started on:Fri Dec 11 19:39:26 ECT 2020 +Started on:Mon Jun 28 10:44:08 ECT 2021 Total time:0 seconds (5 ms) diff --git a/target/surefire-reports/com.qsoft.test.Tester/Command line test.xml b/target/surefire-reports/com.qsoft.test.Tester/Command line test.xml index b08860c..be33e95 100644 --- a/target/surefire-reports/com.qsoft.test.Tester/Command line test.xml +++ b/target/surefire-reports/com.qsoft.test.Tester/Command line test.xml @@ -1,4 +1,4 @@ - + diff --git a/target/surefire-reports/testng-results.xml b/target/surefire-reports/testng-results.xml index 33fb2e1..7eb3273 100644 --- a/target/surefire-reports/testng-results.xml +++ b/target/surefire-reports/testng-results.xml @@ -2,10 +2,10 @@ - + - +