Totvs - WS Fornecedor / WS Cliente / WS Pedido Compra (fixes bug #6127)

Tempo: 28 horas


git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Model/trunk/modelWeb@42456 d1611594-4594-4d17-8e1d-87c2c4800839
master
julio 2015-03-24 14:26:30 +00:00
parent 32d64ac975
commit 644670abb2
5 changed files with 165 additions and 20 deletions

View File

@ -104,5 +104,6 @@
<classpathentry kind="lib" path="/LibreriasAdmVenta/hibernate-commons-annotations.jar"/>
<classpathentry kind="lib" path="/LibreriasAdmVenta/hibernate-entitymanager.jar"/>
<classpathentry kind="con" path="org.eclipse.jst.server.core.container/org.jboss.ide.eclipse.as.core.server.runtime.runtimeTarget/JBoss 6.x Runtime"/>
<classpathentry combineaccessrules="false" kind="src" path="/WSTotvs"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@ -0,0 +1,34 @@
package com.rjconsultores.ventaboletos.exception;
import java.text.MessageFormat;
import org.zkoss.util.resource.Labels;
public class IntegracionException extends Exception {
/**
*
*/
private static final long serialVersionUID = 1L;
/**
*
* @param message
* - La clave del archivo de traducción
*/
public IntegracionException(String message) {
super(Labels.getLabel(message));
}
/**
*
* @param message
* - La clave del archivo de traducción
* @param oMsg
* - Los parametros de la mensage
*/
public IntegracionException(String message, Object oMsg) {
super(new MessageFormat(Labels.getLabel(message)).format(oMsg));
}
}

View File

@ -10,6 +10,7 @@ import com.rjconsultores.ventaboletos.entidad.Empresa;
import com.rjconsultores.ventaboletos.entidad.Parada;
import com.rjconsultores.ventaboletos.entidad.PuntoVenta;
import com.rjconsultores.ventaboletos.entidad.Usuario;
import com.rjconsultores.ventaboletos.exception.IntegracionException;
/**
*
@ -21,9 +22,9 @@ public interface PuntoVentaService {
public PuntoVenta obtenerID(Integer id);
public PuntoVenta suscribir(PuntoVenta entidad);
public PuntoVenta suscribir(PuntoVenta entidad) throws IntegracionException;
public PuntoVenta actualizacion(PuntoVenta entidad);
public PuntoVenta actualizacion(PuntoVenta entidad) throws IntegracionException;
public void borrar(PuntoVenta entidad);

View File

@ -7,19 +7,27 @@ package com.rjconsultores.ventaboletos.service.impl;
import java.util.Calendar;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.rjconsultores.ventaboletos.dao.PuntoVentaDAO;
import com.rjconsultores.ventaboletos.dao.UsuarioUbicacionDAO;
import com.rjconsultores.ventaboletos.entidad.Constante;
import com.rjconsultores.ventaboletos.entidad.Empresa;
import com.rjconsultores.ventaboletos.entidad.FormaPagoDet;
import com.rjconsultores.ventaboletos.entidad.Parada;
import com.rjconsultores.ventaboletos.entidad.PuntoVenta;
import com.rjconsultores.ventaboletos.entidad.Usuario;
import com.rjconsultores.ventaboletos.exception.IntegracionException;
import com.rjconsultores.ventaboletos.service.ConstanteService;
import com.rjconsultores.ventaboletos.service.PuntoVentaService;
import com.rjconsultores.ventaboletos.utilerias.ApplicationProperties;
import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado;
import com.rjconsultores.ws.totvs.fornecedor.Tipo;
import com.rjconsultores.ws.totvs.service.TotvsService;
/**
*
@ -28,13 +36,17 @@ import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado;
@Service("puntoVentaService")
public class PuntoVentaServiceImpl implements PuntoVentaService {
private static Logger log = LoggerFactory.getLogger(PuntoVentaServiceImpl.class);
@Autowired
private PuntoVentaDAO puntoVentaDAO;
@Autowired
private ConstanteService constanteService;
@Autowired
private UsuarioUbicacionDAO usuarioUbicacionDAO;
//FIXME : Remover esse método de quem está usando. Esse método carrega muitos dados
// FIXME : Remover esse método de quem está usando. Esse método carrega muitos dados
@Deprecated
public List<PuntoVenta> obtenerTodos() {
return puntoVentaDAO.obtenerTodos();
@ -44,22 +56,26 @@ public class PuntoVentaServiceImpl implements PuntoVentaService {
return puntoVentaDAO.obtenerID(id);
}
@Transactional
public PuntoVenta suscribir(PuntoVenta entidad) {
@Transactional(noRollbackFor = { IntegracionException.class })
public PuntoVenta suscribir(PuntoVenta entidad) throws IntegracionException {
entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
entidad.setFecmodif(Calendar.getInstance().getTime());
entidad.setActivo(Boolean.TRUE);
entidad = puntoVentaDAO.suscribir(entidad);
return puntoVentaDAO.suscribir(entidad);
integracionTotvs(entidad);
return entidad;
}
@Transactional
public PuntoVenta actualizacion(PuntoVenta entidad) {
@Transactional(noRollbackFor = { IntegracionException.class })
public PuntoVenta actualizacion(PuntoVenta entidad) throws IntegracionException {
entidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
entidad.setFecmodif(Calendar.getInstance().getTime());
entidad.setActivo(Boolean.TRUE);
entidad = puntoVentaDAO.actualizacion(entidad);
return puntoVentaDAO.actualizacion(entidad);
integracionTotvs(entidad);
return entidad;
}
@Transactional
@ -141,4 +157,89 @@ public class PuntoVentaServiceImpl implements PuntoVentaService {
List<PuntoVenta> puntosVenta = usuarioUbicacionDAO.buscarPuntoVentaPorUsuario(usuario);
return puntosVenta;
}
private void integracionTotvs(PuntoVenta puntoVenta) throws IntegracionException {
if (ApplicationProperties.getInstance().integracionTotvs()) {
String nomeEmpresa = puntoVenta.getRazonSocial();
String nomeFilial = puntoVenta.getNumDoCPuntoVenta();
String endpointFornecedor = getEndpointFornecedor();
String endpointCliente = getEndpointCliente();
String nome = puntoVenta.getNombpuntoventa();
String cgc = puntoVenta.getNumDoCPuntoVenta();
String endereco = puntoVenta.getDireccioncalle() + "," + puntoVenta.getDireccionnumero() == null ? "" : puntoVenta.getDireccionnumero();
String complemen = puntoVenta.getCompl() == null ? "" : puntoVenta.getCompl();
String bairro = puntoVenta.getColonia() == null ? null : puntoVenta.getColonia().getDesccolonia();
String codmun = puntoVenta.getColonia() == null ? null : puntoVenta.getColonia().getCiudad().getCiudadId().toString();
String est = puntoVenta.getColonia() == null ? null : puntoVenta.getColonia().getCiudad().getEstado().getCveestado();
String codpais = puntoVenta.getColonia() == null ? null : puntoVenta.getColonia().getCiudad().getEstado().getPais().getPaisId().toString();
String cep = puntoVenta.getColonia() == null ? null : puntoVenta.getColonia().getCodpostal();
String pais = puntoVenta.getColonia() == null ? null : puntoVenta.getColonia().getCiudad().getEstado().getPais().getNombpais();
String tel = puntoVenta.getNumtelefonouno();
String ddd = null;
try {
String[] telefone = puntoVenta.getNumtelefonouno() == null ? null : puntoVenta.getNumtelefonouno().split("\\)");
ddd = puntoVenta.getNumtelefonouno() == null ? null : telefone[0].replaceAll("\\(", "");
tel = puntoVenta.getNumtelefonouno() == null ? null : telefone[1].replaceAll("\\(", "");
} catch (Exception e) {
tel = puntoVenta.getNumtelefonouno();
}
String email = puntoVenta.getDescCorreo();
String fax = puntoVenta.getNumfax();
String inscr = puntoVenta.getNumIEPuntoVenta();
String nreduz = puntoVenta.getNombpuntoventa();
String tipo = Tipo.F.name();
String tpessoa = puntoVenta.getNumDoCPuntoVenta();
String obs = puntoVenta.getComentarios();
String conta = puntoVenta.getAgenciaId() == null ? null : puntoVenta.getAgenciaId().getNumconta() + "-" + puntoVenta.getAgenciaId().getDigito();
String cnae = "";
String inscrm = "";
String naturez = "";
String simpnac = "";
String contrib = "";
String entid = "";
String fator = "";
try {
TotvsService.cadastrarFornecedor(endpointFornecedor, nomeEmpresa, nomeFilial, bairro, cep,
cgc, cnae, codmun, codpais, complemen, conta, ddd, email, endereco, est, inscr,
inscrm, naturez, nome, nreduz, simpnac, tel, tipo, tpessoa);
} catch (Exception e) {
log.error("", e);
throw new IntegracionException("integracion.totvs");
}
try {
TotvsService.cadastrarCliente(endpointCliente, bairro, cep, cgc, codmun, codpais, complemen, conta,
contrib, ddd, email, nomeEmpresa, endereco, entid, fator, fax, inscr, inscrm, naturez, nome,
nreduz, obs, pais, tpessoa, tel, tipo, est);
} catch (Exception e) {
log.error("", e);
throw new IntegracionException("integracion.totvs");
}
}
}
private String getEndpointFornecedor() {
Constante constante = constanteService.buscarPorNomeConstante("WS_TOTVS_FORNECEDOR_ENDPOINT");
if (constante == null) {
return "";
}
return constante.getValorconstante();
}
private String getEndpointCliente() {
Constante constante = constanteService.buscarPorNomeConstante("WS_TOTVS_CLIENTE_ENDPOINT");
if (constante == null) {
return "";
}
return constante.getValorconstante();
}
}

View File

@ -119,14 +119,17 @@ public class ApplicationProperties {
String property = p.getProperty("ruta.masdeunaclase", "0");
return property.equals("1");
}
public boolean diagramaAutobusDosPestana() {
String property = p.getProperty("diagramaautobus.dospestana", "0");
return property.equals("1");
}
public boolean contrasenaValidaComplejidad() {
String property = p.getProperty("contrasena.validaComplejidad", "0");
return property.equals("1");
}
public boolean pafActivo() {
String property = p.getProperty("paf.activo", "0");
return property.equals("1");
@ -137,4 +140,9 @@ public class ApplicationProperties {
return property.equals("1");
}
public boolean integracionTotvs() {
String property = p.getProperty("integracion.totvs", "0");
return property.equals("1");
}
}