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-87c2c4800839master
parent
32d64ac975
commit
644670abb2
|
@ -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>
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
||||
}
|
|
@ -10,22 +10,23 @@ 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;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Administrador
|
||||
*/
|
||||
public interface PuntoVentaService {
|
||||
|
||||
|
||||
public List<PuntoVenta> obtenerTodos();
|
||||
|
||||
public PuntoVenta obtenerID(Integer id);
|
||||
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);
|
||||
public void borrar(PuntoVenta entidad);
|
||||
|
||||
public List<PuntoVenta> buscaLike(String strEstacion);
|
||||
|
||||
|
@ -36,8 +37,8 @@ public interface PuntoVentaService {
|
|||
public List<PuntoVenta> buscaPuntoVentaParada(Parada paradaId);
|
||||
|
||||
public List<PuntoVenta> buscarPuntoVentaSubordinados(PuntoVenta puntoVenta);
|
||||
|
||||
|
||||
public List<PuntoVenta> buscarPuntosVentaMovimentacionBilhetes(List<Empresa> empresas);
|
||||
|
||||
|
||||
public List<PuntoVenta> buscarPuntosVentaPorUsuario(Usuario usuario);
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
@ -138,7 +154,92 @@ public class PuntoVentaServiceImpl implements PuntoVentaService {
|
|||
}
|
||||
|
||||
public List<PuntoVenta> buscarPuntosVentaPorUsuario(Usuario usuario) {
|
||||
List<PuntoVenta> puntosVenta = usuarioUbicacionDAO.buscarPuntoVentaPorUsuario(usuario);
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -109,32 +109,40 @@ public class ApplicationProperties {
|
|||
String property = p.getProperty("no.cheque.folio", "0");
|
||||
return property.equals("1");
|
||||
}
|
||||
|
||||
|
||||
public boolean habilitarPricingCategoria() {
|
||||
String property = p.getProperty("pricing.categoria.habilitar", "0");
|
||||
return property.equals("1");
|
||||
}
|
||||
|
||||
|
||||
public boolean rutaConMasDeUnaClase() {
|
||||
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");
|
||||
}
|
||||
|
||||
|
||||
public boolean habilitarCustomSequence() {
|
||||
String property = p.getProperty("custom.sequence", "0");
|
||||
return property.equals("1");
|
||||
}
|
||||
|
||||
|
||||
public boolean integracionTotvs() {
|
||||
String property = p.getProperty("integracion.totvs", "0");
|
||||
return property.equals("1");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue