Algunos temas de farmaEnlace
This commit is contained in:
parent
6f669ebb76
commit
328424f285
|
|
@ -0,0 +1 @@
|
|||
/target/
|
||||
|
|
@ -24,6 +24,6 @@ Any value defined here will override the pom.xml file value but is only applicab
|
|||
<org-netbeans-modules-css-prep.less_2e_compiler_2e_options/>
|
||||
<org-netbeans-modules-css-prep.sass_2e_mappings>/scss:/css</org-netbeans-modules-css-prep.sass_2e_mappings>
|
||||
<org-netbeans-modules-web-clientproject-api.js_2e_libs_2e_folder>js/libs</org-netbeans-modules-web-clientproject-api.js_2e_libs_2e_folder>
|
||||
<org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_deploy_2e_server>pfv5ee8</org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_deploy_2e_server>
|
||||
<org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_deploy_2e_server>pfv3ee6</org-netbeans-modules-maven-j2ee.netbeans_2e_hint_2e_deploy_2e_server>
|
||||
</properties>
|
||||
</project-shared-configuration>
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ import com.qsoft.erp.dominio.exception.DominioExcepcion;
|
|||
import com.qsoft.wmp.services.util.ServiceUtil;
|
||||
import com.qsoft.wmp.services.xsd.EntradaAccion;
|
||||
import com.qsoft.wmp.services.xsd.SalidaAccion;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.inject.Inject;
|
||||
|
|
@ -118,7 +119,7 @@ public class AccionResource {
|
|||
* @return
|
||||
* @throws DominioExcepcion
|
||||
*/
|
||||
public SalidaAccion ejecutarAccion(EntradaAccion entrada, EntidadEnum entidad) throws DominioExcepcion {
|
||||
public SalidaAccion ejecutarAccion(EntradaAccion entrada, EntidadEnum entidad) throws DominioExcepcion, IOException {
|
||||
List<Object> resultado = accion.accionGenerica(entrada.getHeaderIn(), entidad, entrada.getBodyIn().getEntidades(), entrada.getBodyIn().getTipoAccion());
|
||||
String msg = "A continuacion se muestra el resultado de la accion.";
|
||||
HeaderMS header = entrada.getHeaderIn();
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ public class ApplicationConfig extends Application {
|
|||
resources.add(com.qsoft.wmp.filter.CorsFilter.class);
|
||||
resources.add(com.qsoft.wmp.services.rest.AccionResource.class);
|
||||
resources.add(com.qsoft.wmp.services.rest.ConsultaResource.class);
|
||||
resources.add(com.qsoft.wmp.services.rest.FarmaenlaceResource.class);
|
||||
resources.add(com.qsoft.wmp.services.rest.MultipartResource.class);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,190 @@
|
|||
/*
|
||||
* 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.wmp.services.rest;
|
||||
|
||||
import com.qsoft.dao.exception.DaoException;
|
||||
import com.qsoft.erp.constantes.DominioConstantes;
|
||||
import com.qsoft.erp.constantes.EntidadEnum;
|
||||
import com.qsoft.erp.dominio.AccionGenerica;
|
||||
import com.qsoft.erp.dominio.ConsultaGenerica;
|
||||
import com.qsoft.erp.dominio.exception.DominioExcepcion;
|
||||
import com.qsoft.erp.dto.PersonaPolizaDTO;
|
||||
import com.qsoft.util.constantes.CodigoRespuesta;
|
||||
import com.qsoft.util.constantes.ErrorTipo;
|
||||
import com.qsoft.util.ms.pojo.HeaderMS;
|
||||
import com.qsoft.wmp.services.util.ServiceUtil;
|
||||
import com.qsoft.wmp.services.xsd.EntradaAccion;
|
||||
import com.qsoft.wmp.services.xsd.EntradaConsulta;
|
||||
import com.qsoft.wmp.services.xsd.EntradaRecetas;
|
||||
import com.qsoft.wmp.services.xsd.SalidaAccion;
|
||||
import com.qsoft.wmp.services.xsd.SalidaAccionFarmaEnlace;
|
||||
import com.qsoft.wmp.services.xsd.SalidaConsulta;
|
||||
import java.util.HashMap;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.inject.Inject;
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
|
||||
/**
|
||||
* REST Web Service
|
||||
*
|
||||
* @author james
|
||||
*/
|
||||
@Path("ServicioConvenioExterno")
|
||||
public class FarmaenlaceResource {
|
||||
|
||||
@Inject
|
||||
private ConsultaGenerica consulta;
|
||||
|
||||
@Inject
|
||||
private AccionGenerica accion;
|
||||
|
||||
@PostConstruct
|
||||
public void postConstructor() {
|
||||
System.out.println("======> POST CONTRUCTOR " + consulta);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return an instance of java.lang.String
|
||||
*/
|
||||
@GET
|
||||
@Path("/cedula={cedula}&diagnostico={diagnostico}")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public Map<String, Object> getJson(@PathParam("cedula") String cedula,
|
||||
@PathParam("diagnostico") String diagnostico) {
|
||||
Map<String, Object> mapFarmaenlace = new HashMap<String, Object>();
|
||||
|
||||
|
||||
SalidaConsulta salida = null;
|
||||
List resultado = null;
|
||||
String message = "Mensaje OK";
|
||||
Boolean status = true;
|
||||
byte[] bytes = { 'c', 'd' };
|
||||
String autorizacion = UUID.nameUUIDFromBytes(bytes).toString().replace("-", "");
|
||||
Integer receta = 0;
|
||||
if (cedula == null || cedula.trim().equals("")) {
|
||||
salida = ServiceUtil.crearSalidaConsultaError(ErrorTipo.WARNING, CodigoRespuesta.CODIGO_IN_NULO, "La entrada no puede ser nula");
|
||||
}else{
|
||||
try {
|
||||
resultado = this.consulta.consultaGet(cedula, diagnostico);
|
||||
|
||||
} catch (DominioExcepcion ex) {
|
||||
Logger.getLogger(FarmaenlaceResource.class.getName()).log(Level.SEVERE, null, ex);
|
||||
} catch (DaoException ex) {
|
||||
Logger.getLogger(FarmaenlaceResource.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
if(resultado.size()<=0){
|
||||
message = "No se encontraron resultados correspondientes a la cedula ".concat(cedula);
|
||||
status = false;
|
||||
}
|
||||
mapFarmaenlace.put("rec_titular", resultado);
|
||||
Map<String, Object> mapResult = new HashMap<String, Object>();
|
||||
mapResult.put("status", status);
|
||||
mapResult.put("mensaje", message);
|
||||
mapResult.put("autorizacion", autorizacion);
|
||||
mapResult.put("receta", 0);
|
||||
|
||||
mapFarmaenlace.put("result", mapResult);
|
||||
mapFarmaenlace.put("tipo_facturacion", "TOTAL");
|
||||
|
||||
return mapFarmaenlace;
|
||||
/** SalidaConsulta salida = ServiceUtil.crearSalidaConsultaError(CodigoRespuesta.CODIGO_ERROR_GENERICO,
|
||||
"Acción no soportada por favor ejecute la consulta via POST");*/
|
||||
}
|
||||
|
||||
/**
|
||||
* PUT method for updating or creating an instance of ConsultaResource
|
||||
*
|
||||
* @param entrada
|
||||
* @return
|
||||
*/
|
||||
@POST
|
||||
@Path("/Confirmacion_Datos")
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public Map<String, Object> postJson(EntradaRecetas entrada) {
|
||||
Map<String, Object> salida = null;
|
||||
if (entrada == null) {
|
||||
//salida = ServiceUtil.crearSalidaAccionError(ErrorTipo.WARNING, CodigoRespuesta.CODIGO_IN_NULO, "La entrada no puede ser nula");
|
||||
} else {
|
||||
//EntidadEnum entidad = Enum.valueOf(EntidadEnum.class, entrada.getBodyIn().getEntidad());
|
||||
|
||||
try {
|
||||
|
||||
salida = ejecutarAccionFarmaenlace(entrada);
|
||||
|
||||
} catch (DominioExcepcion ex) {
|
||||
|
||||
//salida = ServiceUtil.crearSalidaAccionError(ex.getTipo(), ex.getCodigo(), ex.getMensaje());
|
||||
} catch (Exception ex) {
|
||||
System.out.println("============ ERROR NO CONTROLADO ==============");
|
||||
ex.printStackTrace(System.err);
|
||||
String msg = getCauses(ex, new StringBuilder());
|
||||
if (msg.contains("Duplicate entry")) {
|
||||
//salida = ServiceUtil.crearSalidaAccionError(ErrorTipo.ERROR, CodigoRespuesta.CODIGO_ERROR_GUARDA_BDD, "Error el registro " + entrada.getBodyIn().getEntidad() + " ya existe en la Base de datos");
|
||||
} else {
|
||||
//salida = ServiceUtil.crearSalidaAccionError(ErrorTipo.ERROR, CodigoRespuesta.CODIGO_ERROR_GENERICO, "ERROR NO CONTROLADO: " + msg);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return salida;
|
||||
}
|
||||
/**
|
||||
* @param e
|
||||
* @param build
|
||||
* @return
|
||||
*/
|
||||
private String getCauses(Throwable e, StringBuilder build) {
|
||||
build.append("\n").append(e.toString());
|
||||
for (Throwable t : e.getSuppressed()) {
|
||||
System.out.println("SUPRESS =====> " + t);
|
||||
build.append("\n").append(t.toString());
|
||||
getCauses(t, build);
|
||||
}
|
||||
System.out.println("CAUSE =====> " + e);
|
||||
if (e.getCause() != null) {
|
||||
getCauses(e.getCause(), build);
|
||||
}
|
||||
return build.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Ejecuta la accion
|
||||
*
|
||||
* @param entrada
|
||||
* @param entidad
|
||||
* @return
|
||||
* @throws DominioExcepcion
|
||||
*/
|
||||
public Map<String, Object> ejecutarAccionFarmaenlace(EntradaRecetas entrada) throws DominioExcepcion {
|
||||
//SalidaAccionFarmaEnlace salida = new SalidaAccionFarmaEnlace();
|
||||
Map<String, Object> salida = new HashMap<String, Object>();
|
||||
try {
|
||||
Map<String, Object> resultado = accion.accionFarmaenlace(entrada.getReceta(), entrada.getRec_items(), entrada.getRec_facturacion(), entrada.getRec_credito(), entrada.getTipo_facturacion());
|
||||
salida = ServiceUtil.crearSalidaAccionOkFarmaenlace(resultado);
|
||||
|
||||
} catch (Exception e) {
|
||||
}
|
||||
//String msg = "A continuacion se muestra el resultado de la accion.";
|
||||
//HeaderMS header = entrada.getHeaderIn();
|
||||
//header.setFechaHora(DominioConstantes.getDateTime());
|
||||
return salida;
|
||||
}
|
||||
}
|
||||
|
|
@ -9,6 +9,7 @@ import com.qsoft.util.constantes.CodigoRespuesta;
|
|||
import com.qsoft.util.constantes.ErrorTipo;
|
||||
import com.qsoft.util.ms.pojo.HeaderMS;
|
||||
import com.qsoft.wmp.services.xsd.SalidaAccion;
|
||||
import com.qsoft.wmp.services.xsd.SalidaAccionFarmaEnlace;
|
||||
import com.qsoft.wmp.services.xsd.SalidaConsulta;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
|
@ -105,11 +106,25 @@ public class ServiceUtil {
|
|||
/**
|
||||
* Crear salida ok
|
||||
*
|
||||
* @param <error>
|
||||
* @param header
|
||||
* @param estado
|
||||
* @param data
|
||||
* @return
|
||||
*/
|
||||
public static Map<String, Object> crearSalidaAccionOkFarmaenlace(Map<String, Object> resultado) {
|
||||
//SalidaAccionFarmaEnlace salida = new SalidaAccionFarmaEnlace();
|
||||
//salida.setStatus((Boolean) resultado.get("status"));
|
||||
//salida.setMensaje((String) resultado.get("mensaje"));
|
||||
//salida.setAutorizacion((String) resultado.get("autorizacion"));
|
||||
//salida.setReceta((Integer) resultado.get("receta"));
|
||||
|
||||
|
||||
//return salida;
|
||||
return resultado;
|
||||
}
|
||||
|
||||
|
||||
public static SalidaAccion crearSalidaAccionOk(HeaderMS header, String estado, List<Object> data) {
|
||||
SalidaAccion salida = new SalidaAccion();
|
||||
salida.setHeaderOut(header);
|
||||
|
|
@ -119,6 +134,7 @@ public class ServiceUtil {
|
|||
salida.getBodyOut().setEstado(estado);
|
||||
salida.getBodyOut().setResultados(data);
|
||||
return salida;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,62 @@
|
|||
/*
|
||||
* 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.wmp.services.xsd;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author james
|
||||
*/
|
||||
public class BodyRecetas {
|
||||
|
||||
private Integer tipoConsulta;
|
||||
private Integer maximoRegistros;
|
||||
private Integer registroInicio;
|
||||
private String entidad;
|
||||
private Map<String, Object> parametros;
|
||||
|
||||
public Integer getTipoConsulta() {
|
||||
return tipoConsulta;
|
||||
}
|
||||
|
||||
public void setTipoConsulta(Integer tipoConsulta) {
|
||||
this.tipoConsulta = tipoConsulta;
|
||||
}
|
||||
|
||||
public Map<String, Object> getParametros() {
|
||||
return parametros;
|
||||
}
|
||||
|
||||
public void setParametros(Map<String, Object> parametros) {
|
||||
this.parametros = parametros;
|
||||
}
|
||||
|
||||
public String getEntidad() {
|
||||
return entidad;
|
||||
}
|
||||
|
||||
public void setEntidad(String entidad) {
|
||||
this.entidad = entidad;
|
||||
}
|
||||
|
||||
public Integer getMaximoRegistros() {
|
||||
return maximoRegistros;
|
||||
}
|
||||
|
||||
public void setMaximoRegistros(Integer maximoRegistros) {
|
||||
this.maximoRegistros = maximoRegistros;
|
||||
}
|
||||
|
||||
public Integer getRegistroInicio() {
|
||||
return registroInicio;
|
||||
}
|
||||
|
||||
public void setRegistroInicio(Integer registroInicio) {
|
||||
this.registroInicio = registroInicio;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,92 @@
|
|||
/*
|
||||
* EntradaConsulta.java
|
||||
* 15 de feb. de 2017
|
||||
* Copyright 2017 TCS.
|
||||
* Todos los derechos reservados.
|
||||
*/
|
||||
package com.qsoft.wmp.services.xsd;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonAlias;
|
||||
import com.qsoft.util.ms.pojo.HeaderMS;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlSeeAlso;
|
||||
|
||||
/**
|
||||
* <b> Entrada del servicio web. </b>
|
||||
*
|
||||
* @author jaime Ruales
|
||||
* @version $1.0$
|
||||
*/
|
||||
@XmlSeeAlso({HeaderMS.class})
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
public class EntradaRecetas implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 8142263336233087792L;
|
||||
@XmlElement(name = "receta")
|
||||
@JsonAlias("receta")
|
||||
private Map<String, Object> receta;
|
||||
|
||||
@XmlElement(name = "rec_items")
|
||||
@JsonAlias("rec_items")
|
||||
private List<Map<String, Object>> rec_items;
|
||||
|
||||
@XmlElement(name = "rec_facturacion")
|
||||
@JsonAlias("rec_facturacion")
|
||||
private Map<String, Object> rec_facturacion;
|
||||
|
||||
@XmlElement(name = "rec_credito")
|
||||
@JsonAlias("rec_credito")
|
||||
private Map<String, Object> rec_credito;
|
||||
|
||||
@XmlElement(name = "tipo_facturacion")
|
||||
@JsonAlias("tipo_facturacion")
|
||||
private String tipo_facturacion;
|
||||
|
||||
public Map<String, Object> getReceta() {
|
||||
return receta;
|
||||
}
|
||||
|
||||
public void setReceta(Map<String, Object> receta) {
|
||||
this.receta = receta;
|
||||
}
|
||||
|
||||
public List<Map<String, Object>> getRec_items() {
|
||||
return rec_items;
|
||||
}
|
||||
|
||||
public void setRec_items(List<Map<String, Object>> rec_items) {
|
||||
this.rec_items = rec_items;
|
||||
}
|
||||
|
||||
public Map<String, Object> getRec_facturacion() {
|
||||
return rec_facturacion;
|
||||
}
|
||||
|
||||
public void setRec_facturacion(Map<String, Object> rec_facturacion) {
|
||||
this.rec_facturacion = rec_facturacion;
|
||||
}
|
||||
|
||||
public Map<String, Object> getRec_credito() {
|
||||
return rec_credito;
|
||||
}
|
||||
|
||||
public void setRec_credito(Map<String, Object> rec_credito) {
|
||||
this.rec_credito = rec_credito;
|
||||
}
|
||||
|
||||
public String getTipo_facturacion() {
|
||||
return tipo_facturacion;
|
||||
}
|
||||
|
||||
public void setTipo_facturacion(String tipo_facturacion) {
|
||||
this.tipo_facturacion = tipo_facturacion;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,78 @@
|
|||
package com.qsoft.wmp.services.xsd;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonAlias;
|
||||
import com.qsoft.util.ms.pojo.ErrorMS;
|
||||
import com.qsoft.util.ms.pojo.HeaderMS;
|
||||
import java.io.Serializable;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlSeeAlso;
|
||||
|
||||
|
||||
/**
|
||||
* <b> Salida del Servicio Web. </b>
|
||||
*
|
||||
* @author Jaime Ruales.
|
||||
* @version $1.0$
|
||||
*/
|
||||
@XmlSeeAlso({HeaderMS.class, ErrorMS.class})
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
public class SalidaAccionFarmaEnlace implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 5403227918589158188L;
|
||||
|
||||
@XmlElement(name = "status")
|
||||
@JsonAlias("status")
|
||||
protected Boolean status;
|
||||
|
||||
@XmlElement(name = "mensaje")
|
||||
@JsonAlias("mensaje")
|
||||
protected String mensaje;
|
||||
|
||||
@XmlElement(name = "autorizacion")
|
||||
@JsonAlias("autorizacion")
|
||||
protected String autorizacion;
|
||||
|
||||
@XmlElement(name = "receta")
|
||||
@JsonAlias("receta")
|
||||
protected Integer receta;
|
||||
|
||||
public static long getSerialVersionUID() {
|
||||
return serialVersionUID;
|
||||
}
|
||||
|
||||
public void setStatus(Boolean status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
|
||||
public void setMensaje(String mensaje) {
|
||||
this.mensaje = mensaje;
|
||||
}
|
||||
|
||||
public String getMensaje() {
|
||||
return mensaje;
|
||||
}
|
||||
|
||||
public void setAutorizacion(String autorizacion) {
|
||||
this.autorizacion = autorizacion;
|
||||
}
|
||||
|
||||
public String getAutorizacion() {
|
||||
return autorizacion;
|
||||
}
|
||||
|
||||
public void setReceta(Integer receta) {
|
||||
this.receta = receta;
|
||||
}
|
||||
|
||||
public Integer getReceta() {
|
||||
return receta;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue