Se agrega funcionalidad de envío de correo.Fixes bug#AL-4549
parent
743f88ffc7
commit
b382513974
2
pom.xml
2
pom.xml
|
@ -4,7 +4,7 @@
|
|||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>br.com.rjconsultores</groupId>
|
||||
<artifactId>ventaboletosadm</artifactId>
|
||||
<version>1.119.1</version>
|
||||
<version>1.119.3</version>
|
||||
<packaging>war</packaging>
|
||||
|
||||
<properties>
|
||||
|
|
|
@ -2,12 +2,38 @@ package com.rjconsultores.ventaboletos.web.gui.controladores.expressos;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.security.KeyManagementException;
|
||||
import java.security.KeyStoreException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.cert.CertificateException;
|
||||
import java.security.cert.X509Certificate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.xml.bind.DatatypeConverter;
|
||||
|
||||
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||
import org.apache.http.client.methods.HttpPost;
|
||||
import org.apache.http.client.methods.HttpUriRequest;
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.http.HttpEntity;
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.NameValuePair;
|
||||
import org.apache.http.client.ClientProtocolException;
|
||||
import org.apache.http.client.HttpClient;
|
||||
import org.apache.http.client.entity.UrlEncodedFormEntity;
|
||||
import org.apache.http.conn.ssl.NoopHostnameVerifier;
|
||||
import org.apache.http.entity.mime.MultipartEntityBuilder;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
import org.apache.http.impl.client.HttpClientBuilder;
|
||||
import org.apache.http.impl.client.HttpClients;
|
||||
import org.apache.http.message.BasicNameValuePair;
|
||||
import org.apache.http.ssl.SSLContextBuilder;
|
||||
import org.apache.http.ssl.TrustStrategy;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Controller;
|
||||
|
@ -31,6 +57,7 @@ import com.rjconsultores.ventaboletos.entidad.Empresa;
|
|||
import com.rjconsultores.ventaboletos.entidad.SolicitudExpreso;
|
||||
import com.rjconsultores.ventaboletos.entidad.TrayectosExpresos;
|
||||
import com.rjconsultores.ventaboletos.service.CiudadService;
|
||||
import com.rjconsultores.ventaboletos.service.ConstanteService;
|
||||
import com.rjconsultores.ventaboletos.service.SolicitudExpresosService;
|
||||
import com.rjconsultores.ventaboletos.service.TrayectosExpresosService;
|
||||
import com.rjconsultores.ventaboletos.web.utilerias.MyGenericForwardComposer;
|
||||
|
@ -39,6 +66,7 @@ import com.rjconsultores.ventaboletos.web.utilerias.MyTextbox;
|
|||
import com.rjconsultores.ventaboletos.web.utilerias.paginacion.HibernateSearchObject;
|
||||
import com.rjconsultores.ventaboletos.web.utilerias.paginacion.PagedListWrapper;
|
||||
import com.rjconsultores.ventaboletos.web.utilerias.render.RenderTrayectosExpreso;
|
||||
import com.rjconsultores.ventaboletos.web.utilerias.spring.AppContext;
|
||||
|
||||
@Controller("cotizarExpresoController")
|
||||
@Scope("prototype")
|
||||
|
@ -156,7 +184,7 @@ public class CotizarExpresoController extends MyGenericForwardComposer{
|
|||
refreshLista();
|
||||
}
|
||||
|
||||
public void onClick$btnGuardarCotizacion(Event event) throws Exception {
|
||||
public void onClick$btnGuardarCotizacion(Event event) throws KeyManagementException, NoSuchAlgorithmException, KeyStoreException, Exception {
|
||||
if(docCotizacion == null) {
|
||||
Messagebox.show(
|
||||
Labels.getLabel("expresoController.MSG.errorArchivo"),
|
||||
|
@ -166,6 +194,8 @@ public class CotizarExpresoController extends MyGenericForwardComposer{
|
|||
expreso.setDocCotizacion(docCotizacion);
|
||||
expreso.setStatusSolicitudExpresoId(2);
|
||||
solicitudExpresosService.actualizacion(expreso);
|
||||
|
||||
enviarEmail();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -186,6 +216,52 @@ public class CotizarExpresoController extends MyGenericForwardComposer{
|
|||
refreshLista();
|
||||
}
|
||||
|
||||
private void enviarEmail() throws KeyManagementException, NoSuchAlgorithmException, KeyStoreException, ClientProtocolException, IOException, InterruptedException {
|
||||
ConstanteService constanteService = (ConstanteService) AppContext.getApplicationContext().getBean("constanteService");
|
||||
|
||||
String urlAPIRJ = constanteService.buscarPorNomeConstante("URL_API_RJ_INFOBIP").getValorconstante();
|
||||
String credenciais = constanteService.buscarPorNomeConstante("CREDENCIAIS_API_RJ").getValorconstante();
|
||||
String tenant = constanteService.buscarPorNomeConstante("TENANT_API_RJ").getValorconstante();
|
||||
|
||||
urlAPIRJ = urlAPIRJ.concat("EnviarEmailGenerico");
|
||||
|
||||
CloseableHttpClient httpClient = HttpClients.createDefault();
|
||||
|
||||
HttpPost request = new HttpPost(urlAPIRJ);
|
||||
|
||||
List<NameValuePair> urlParameters = new ArrayList<NameValuePair>();
|
||||
urlParameters.add(new BasicNameValuePair("emailCliente", expreso.getDescEmail()));
|
||||
urlParameters.add(new BasicNameValuePair("assunto", Labels.getLabel("expresoController.MSG.asuntoCorreoCotizacion")));
|
||||
urlParameters.add(new BasicNameValuePair("texto", Labels.getLabel("expresoController.MSG.cuerpoCorreoCotizacion", new Object[] { expreso.getDescNombre() + " " + expreso.getDescApellidos(), "[INSERT LINK HERE CONSTANTE empresa_notificacion_bolivariano]" })));
|
||||
urlParameters.add(new BasicNameValuePair("empresaId", "10")); // --> Cambiar por constante empresa_notificacion_bolivariano
|
||||
|
||||
UrlEncodedFormEntity params = new UrlEncodedFormEntity(urlParameters, "UTF-8");
|
||||
|
||||
request.addHeader("Authorization", "Basic " + new String(Base64.encodeBase64(credenciais.getBytes())));
|
||||
|
||||
if (StringUtils.isNotBlank(tenant)){
|
||||
request.addHeader("x-tenant-id", tenant);
|
||||
}
|
||||
|
||||
request.setEntity(params);
|
||||
|
||||
CloseableHttpResponse response = httpClient.execute(request);
|
||||
|
||||
if(response.getStatusLine().getStatusCode() == 200 && response.getStatusLine().getReasonPhrase().equalsIgnoreCase("OK")) {
|
||||
Messagebox.show(
|
||||
Labels.getLabel("expresoController.MSG.emailEnviado"),
|
||||
Labels.getLabel("expresosPorCotizarCotizar.window.title"),
|
||||
Messagebox.OK, Messagebox.INFORMATION);
|
||||
} else {
|
||||
Messagebox.show(
|
||||
Labels.getLabel("expresoController.MSG.emailNoEnviado"),
|
||||
Labels.getLabel("expresosPorCotizarCotizar.window.title"),
|
||||
Messagebox.OK, Messagebox.ERROR);
|
||||
}
|
||||
|
||||
this.closeWindow();
|
||||
}
|
||||
|
||||
public SolicitudExpreso getExpreso() {
|
||||
return expreso;
|
||||
}
|
||||
|
|
|
@ -7590,6 +7590,10 @@ expresosController.lbl.idaVuelta = Going
|
|||
|
||||
expresoController.MSG.errorArchivo = Invalid or null file
|
||||
cargaContratoController.MSG.errorExpresoNull = Select Express to Associate Contract
|
||||
cotizarExpresoController.MSG.emailEnviado = Correct Express Quote
|
||||
expresoController.MSG.emailNoEnviado = There's been a problem. Please check logs
|
||||
expresoController.MSG.asuntoCorreoCotizacion = Quoted Express Request
|
||||
expresoController.MSG.cuerpoCorreoCotizacion = Dear {0}, the express request has been quoted, in the following link {1} you can accept the quote and make the payment.
|
||||
#GR
|
||||
indexController.mnGR.label = Passing Stock
|
||||
#Gestao de Pricing
|
||||
|
|
|
@ -7461,6 +7461,10 @@ expresosController.lbl.idaVuelta = Ida
|
|||
|
||||
expresoController.MSG.errorArchivo = Archivo inválido o nulo
|
||||
cargaContratoController.MSG.errorExpresoNull = Seleccione Expreso a Asociar Contrato
|
||||
cotizarExpresoController.MSG.emailEnviado = Cotización de Expreso Correcta
|
||||
expresoController.MSG.emailNoEnviado = Ocurrió un problema. Favor de revisar logs
|
||||
expresoController.MSG.asuntoCorreoCotizacion = Solicitud de Expreso Cotizada
|
||||
expresoController.MSG.cuerpoCorreoCotizacion = Estimado/a {0}, la solicitud de expreso ha sido cotizada, en el siguiente link {1} podrá aceptar la cotización y realizar el pago.
|
||||
#GR
|
||||
indexController.mnGR.label = GR
|
||||
#Gestao de Pricing
|
||||
|
|
|
@ -7459,6 +7459,10 @@ expresosController.lbl.idaVuelta = En allant
|
|||
|
||||
expresoController.MSG.errorArchivo = Fichier invalide ou nul
|
||||
cargaContratoController.MSG.errorExpresoNull = Sélectionnez Express pour associer le contrat
|
||||
cotizarExpresoController.MSG.emailEnviado = Corriger le devis express
|
||||
expresoController.MSG.emailNoEnviado = Il y a eu un problème. Veuillez vérifier les journaux
|
||||
expresoController.MSG.asuntoCorreoCotizacion = Demande express citée
|
||||
expresoController.MSG.cuerpoCorreoCotizacion = Cher {0}, la demande expresse a été citée, dans le lien suivant {1} vous pouvez accepter le devis et effectuer le paiement.
|
||||
#GR
|
||||
indexController.mnGR.label = Passage de stock
|
||||
#Gestao de Pricing
|
||||
|
|
|
@ -7595,6 +7595,10 @@ expresosController.lbl.idaVuelta = Ida
|
|||
|
||||
expresoController.MSG.errorArchivo = Arquivo inválido ou nulo
|
||||
cargaContratoController.MSG.errorExpresoNull = Selecione Expresso para Associar Contrato
|
||||
cotizarExpresoController.MSG.emailEnviado = Cotação Expressa Correta
|
||||
expresoController.MSG.emailNoEnviado = Houve um problema. Verifique os registros
|
||||
expresoController.MSG.asuntoCorreoCotizacion = Solicitação expressa cotada
|
||||
expresoController.MSG.cuerpoCorreoCotizacion = Prezado {0}, o pedido expresso foi cotado, no link a seguir {1} você pode aceitar o orçamento e efetuar o pagamento.
|
||||
#GR
|
||||
indexController.mnGR.label = Estoque de Passagem
|
||||
#Gestao de Pricing
|
||||
|
|
Loading…
Reference in New Issue