bug#20497
dev: Valvevir qua: git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Web/trunk/ventaboletos@103877 d1611594-4594-4d17-8e1d-87c2c4800839master
parent
23aa8d5547
commit
a37afd8d1e
|
@ -0,0 +1,32 @@
|
||||||
|
package com.rjconsultores.ventaboletos.rest;
|
||||||
|
|
||||||
|
import javax.annotation.security.RolesAllowed;
|
||||||
|
import javax.ws.rs.Consumes;
|
||||||
|
import javax.ws.rs.POST;
|
||||||
|
import javax.ws.rs.Path;
|
||||||
|
import javax.ws.rs.Produces;
|
||||||
|
import javax.ws.rs.core.MediaType;
|
||||||
|
import javax.ws.rs.core.Response;
|
||||||
|
|
||||||
|
import com.rjconsultores.ventaboletos.rest.bean.ParamsSincronizarDispositivo;
|
||||||
|
import com.rjconsultores.ventaboletos.rest.service.SincronizarService;
|
||||||
|
import com.rjconsultores.ventaboletos.rest.service.exception.ServiceEmbarcadaException;
|
||||||
|
import com.rjconsultores.ventaboletos.web.utilerias.spring.AppContext;
|
||||||
|
|
||||||
|
@Path("/sincronizarDispositivoResumido")
|
||||||
|
public class SincronizarDispositivoResumido {
|
||||||
|
|
||||||
|
@POST
|
||||||
|
@Consumes({ MediaType.APPLICATION_JSON })
|
||||||
|
@RolesAllowed("EMBARCADA")
|
||||||
|
@Produces({ MediaType.APPLICATION_JSON })
|
||||||
|
public Response buscarDispositivo(ParamsSincronizarDispositivo params) throws Exception {
|
||||||
|
SincronizarService service = (SincronizarService) AppContext.getApplicationContext().getBean("sincronizarService");
|
||||||
|
|
||||||
|
try {
|
||||||
|
return Response.ok(service.getDispositivoEmbarcadaResumido(params), MediaType.APPLICATION_JSON).build();
|
||||||
|
} catch (ServiceEmbarcadaException e) {
|
||||||
|
return Response.status(Response.Status.NOT_FOUND).entity(e.getMessage()).build();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,6 +2,7 @@ package com.rjconsultores.ventaboletos.rest.service;
|
||||||
|
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -9,17 +10,24 @@ import org.slf4j.Logger;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import com.rjconsultores.routing.ReadOnlyConnection;
|
import com.rjconsultores.routing.ReadOnlyConnection;
|
||||||
|
import com.rjconsultores.ventaboletos.dao.DispositivoEmbarcadaDAO;
|
||||||
import com.rjconsultores.ventaboletos.dao.EmpresaDAO;
|
import com.rjconsultores.ventaboletos.dao.EmpresaDAO;
|
||||||
import com.rjconsultores.ventaboletos.dao.OperadorEmbarcadaDAO;
|
import com.rjconsultores.ventaboletos.dao.OperadorEmbarcadaDAO;
|
||||||
import com.rjconsultores.ventaboletos.dao.OperadorEmbarcadaLinhaDAO;
|
import com.rjconsultores.ventaboletos.dao.OperadorEmbarcadaLinhaDAO;
|
||||||
import com.rjconsultores.ventaboletos.dao.OperadorEmbarcadaServicoDAO;
|
import com.rjconsultores.ventaboletos.dao.OperadorEmbarcadaServicoDAO;
|
||||||
import com.rjconsultores.ventaboletos.dao.PuntoVentaDAO;
|
import com.rjconsultores.ventaboletos.dao.PuntoVentaDAO;
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.FormaPagoDet;
|
||||||
import com.rjconsultores.ventaboletos.entidad.OperadorEmbarcada;
|
import com.rjconsultores.ventaboletos.entidad.OperadorEmbarcada;
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.PtoVtaSeguro;
|
||||||
|
import com.rjconsultores.ventaboletos.entidad.PtovtaCatInd;
|
||||||
import com.rjconsultores.ventaboletos.entidad.PuntoVentaVO;
|
import com.rjconsultores.ventaboletos.entidad.PuntoVentaVO;
|
||||||
import com.rjconsultores.ventaboletos.rest.bean.ParamsSincronizarOperador;
|
import com.rjconsultores.ventaboletos.rest.bean.ParamsSincronizarOperador;
|
||||||
import com.rjconsultores.ventaboletos.rest.service.exception.ServiceEmbarcadaException;
|
import com.rjconsultores.ventaboletos.rest.service.exception.ServiceEmbarcadaException;
|
||||||
import com.rjconsultores.ventaboletos.vo.corrida.CorridaVO;
|
import com.rjconsultores.ventaboletos.vo.corrida.CorridaVO;
|
||||||
|
import com.rjconsultores.ventaboletos.vo.embarcada.FormaPagamentoVO;
|
||||||
import com.rjconsultores.ventaboletos.vo.embarcada.OperadorEmbarcadaVO;
|
import com.rjconsultores.ventaboletos.vo.embarcada.OperadorEmbarcadaVO;
|
||||||
|
import com.rjconsultores.ventaboletos.vo.embarcada.SeguroTaxaEmbarqueVO;
|
||||||
|
import com.rjconsultores.ventaboletos.vo.embarcada.TiposPassagensBloqueadasVO;
|
||||||
import com.rjconsultores.ventaboletos.vo.ruta.RutaVO;
|
import com.rjconsultores.ventaboletos.vo.ruta.RutaVO;
|
||||||
import com.rjconsultores.ventaboletos.web.utilerias.spring.AppContext;
|
import com.rjconsultores.ventaboletos.web.utilerias.spring.AppContext;
|
||||||
|
|
||||||
|
@ -43,6 +51,7 @@ public class SincronizarOperadorService {
|
||||||
|
|
||||||
EmpresaDAO empresaDAO = (EmpresaDAO)AppContext.getApplicationContext().getBean("empresaDAO");
|
EmpresaDAO empresaDAO = (EmpresaDAO)AppContext.getApplicationContext().getBean("empresaDAO");
|
||||||
OperadorEmbarcadaDAO operadorEmbarcadaDAO = (OperadorEmbarcadaDAO)AppContext.getApplicationContext().getBean("operadorEmbarcadaDAO");
|
OperadorEmbarcadaDAO operadorEmbarcadaDAO = (OperadorEmbarcadaDAO)AppContext.getApplicationContext().getBean("operadorEmbarcadaDAO");
|
||||||
|
DispositivoEmbarcadaDAO dispositivoEmbarcadaDAO = (DispositivoEmbarcadaDAO)AppContext.getApplicationContext().getBean("dispositivoEmbarcadaDAO");
|
||||||
OperadorEmbarcadaLinhaDAO operadorEmbarcadaLinhaDAO = (OperadorEmbarcadaLinhaDAO)AppContext.getApplicationContext().getBean("operadorEmbarcadaLinhaDAO");
|
OperadorEmbarcadaLinhaDAO operadorEmbarcadaLinhaDAO = (OperadorEmbarcadaLinhaDAO)AppContext.getApplicationContext().getBean("operadorEmbarcadaLinhaDAO");
|
||||||
OperadorEmbarcadaServicoDAO operadorEmbarcadaServicoDAO = (OperadorEmbarcadaServicoDAO)AppContext.getApplicationContext().getBean("operadorEmbarcadaServicoDAO");
|
OperadorEmbarcadaServicoDAO operadorEmbarcadaServicoDAO = (OperadorEmbarcadaServicoDAO)AppContext.getApplicationContext().getBean("operadorEmbarcadaServicoDAO");
|
||||||
PuntoVentaDAO puntoventaDAO = (PuntoVentaDAO)AppContext.getApplicationContext().getBean("puntoVentaDAO");
|
PuntoVentaDAO puntoventaDAO = (PuntoVentaDAO)AppContext.getApplicationContext().getBean("puntoVentaDAO");
|
||||||
|
@ -78,6 +87,41 @@ public class SincronizarOperadorService {
|
||||||
|
|
||||||
vo.setLsRutas(lsRutaVO);
|
vo.setLsRutas(lsRutaVO);
|
||||||
vo.setLsCorridas(lsCorridaVO);
|
vo.setLsCorridas(lsCorridaVO);
|
||||||
|
|
||||||
|
if (puntoVentaVO != null) {
|
||||||
|
vo.setLsFormasPagamento(new ArrayList<FormaPagamentoVO>());
|
||||||
|
vo.setLsSeguroTaxaEmbarque(new ArrayList<SeguroTaxaEmbarqueVO>());
|
||||||
|
vo.setLsTiposPassagensBloqueadas(new ArrayList<TiposPassagensBloqueadasVO>());
|
||||||
|
|
||||||
|
List<FormaPagoDet> listFP = dispositivoEmbarcadaDAO.getListaFormaPago(puntoVentaVO.getPuntoventaId());
|
||||||
|
for (FormaPagoDet dp : listFP) {
|
||||||
|
vo.getLsFormasPagamento().add(
|
||||||
|
new FormaPagamentoVO(
|
||||||
|
dp.getEmpresa().getEmpresaId(),
|
||||||
|
dp.getEmpresa().getNombempresa(),
|
||||||
|
dp.getFormaPago().getFormapagoId().intValue(),
|
||||||
|
dp.getFormaPago().getDescpago()));
|
||||||
|
}
|
||||||
|
|
||||||
|
List<PtoVtaSeguro> listSTx = dispositivoEmbarcadaDAO.getListaSeguroTaxaEmbarque(puntoVentaVO.getPuntoventaId());
|
||||||
|
for (PtoVtaSeguro st : listSTx) {
|
||||||
|
vo.getLsSeguroTaxaEmbarque().add(
|
||||||
|
new SeguroTaxaEmbarqueVO(
|
||||||
|
st.getEmpresa().getEmpresaId(),
|
||||||
|
st.getIndVendeSeguroOpcEmbarcada(),
|
||||||
|
st.getIndVendeSeguroTabelaEmbarcada(),
|
||||||
|
st.getIndTaxaEmbarqueEmbarcada()));
|
||||||
|
}
|
||||||
|
|
||||||
|
List<PtovtaCatInd> listTPB = dispositivoEmbarcadaDAO.getListaTiposPassagensBloqueadas(puntoVentaVO.getPuntoventaId());
|
||||||
|
for (PtovtaCatInd tpb : listTPB) {
|
||||||
|
vo.getLsTiposPassagensBloqueadas().add(
|
||||||
|
new TiposPassagensBloqueadasVO(
|
||||||
|
tpb.getCategoria().getCategoriaId(),
|
||||||
|
tpb.getUsuarioBloqueado().getUsuarioId(),
|
||||||
|
tpb.getEmpresa().getEmpresaId()));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return vo;
|
return vo;
|
||||||
|
|
|
@ -75,10 +75,6 @@ public class SincronizarService {
|
||||||
vo.setVersaoUltimaSinc(dispositivo.getVersaoUltimaSinc());
|
vo.setVersaoUltimaSinc(dispositivo.getVersaoUltimaSinc());
|
||||||
vo.setDataUltimaSinc( DateUtil.getStringDate( dispositivo.getDataUltimaSinc(), DateUtil.formatJson) );
|
vo.setDataUltimaSinc( DateUtil.getStringDate( dispositivo.getDataUltimaSinc(), DateUtil.formatJson) );
|
||||||
|
|
||||||
vo.setLsFormasPagamento(new ArrayList<FormaPagamentoVO>());
|
|
||||||
vo.setLsSeguroTaxaEmbarque(new ArrayList<SeguroTaxaEmbarqueVO>());
|
|
||||||
vo.setLsTiposPassagensBloqueadas(new ArrayList<TiposPassagensBloqueadasVO>());
|
|
||||||
|
|
||||||
Map<Estado, EmpresaImposto> impostos = getImpostos(empresa);
|
Map<Estado, EmpresaImposto> impostos = getImpostos(empresa);
|
||||||
|
|
||||||
for (PtovtaEmpresa e : puntoVenta.getLsPtovtaEmpresa()){
|
for (PtovtaEmpresa e : puntoVenta.getLsPtovtaEmpresa()){
|
||||||
|
@ -106,6 +102,44 @@ public class SincronizarService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
vo.setEnderecoEmpresa(empresa.getLogradouro()+", nº: "+empresa.getNumero()+". Cidade: "+empresa.getBairro());
|
||||||
|
Constante estacionEmbarcadaConst = constanteDAO.buscarPorNomeConstante(Constantes.ESTACAO_EMBARCADA);
|
||||||
|
|
||||||
|
if (estacionEmbarcadaConst == null || (estacionEmbarcadaConst != null && estacionEmbarcadaConst.getValorconstante() == null) ||
|
||||||
|
(estacionEmbarcadaConst != null && estacionEmbarcadaConst.getValorconstante().isEmpty())){
|
||||||
|
throw new ServiceEmbarcadaException("Error: Constante ESTACAO_EMBARCADA não cadastrada!");
|
||||||
|
}
|
||||||
|
|
||||||
|
String estacionIdEmbarcada = estacionEmbarcadaConst.getValorconstante();
|
||||||
|
vo.setEstacionId(estacionIdEmbarcada != null && !estacionIdEmbarcada.isEmpty() ? Integer.parseInt(estacionIdEmbarcada) : null);
|
||||||
|
|
||||||
|
for (CtrlSerieEmbarcada serie : dispositivo.getSeries()){
|
||||||
|
EstadoDispositivoEmbarcadaVO estado = new EstadoDispositivoEmbarcadaVO();
|
||||||
|
estado.setDescUf(serie.getEstado().getCveestado());
|
||||||
|
estado.setIdUf(serie.getEstado().getEstadoId().longValue());
|
||||||
|
estado.setNumBpe(serie.getNumeroCorrente());
|
||||||
|
estado.setSerie(serie.getSerie());
|
||||||
|
estado.setEmpresaId(serie.getEmpresa().getEmpresaId().longValue());
|
||||||
|
vo.add(estado);
|
||||||
|
}
|
||||||
|
|
||||||
|
return vo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DispositivoEmbarcadaVO getDispositivoEmbarcadaResumido(ParamsSincronizarDispositivo params) throws ServiceEmbarcadaException {
|
||||||
|
DispositivoEmbarcadaDAO dispositivoEmbarcadaDAO = (DispositivoEmbarcadaDAO)AppContext.getApplicationContext().getBean("dispositivoEmbarcadaDAO");
|
||||||
|
PuntoVentaDAO puntoVentaDAO = (PuntoVentaDAO)AppContext.getApplicationContext().getBean("puntoVentaDAO");
|
||||||
|
DispositivoEmbarcada dispositivo = dispositivoEmbarcadaDAO.buscarImei(params.getImei());
|
||||||
|
|
||||||
|
DispositivoEmbarcadaVO vo = getDispositivoEmbarcada(params);
|
||||||
|
PuntoVenta puntoVenta = puntoVentaDAO.obtenerID(dispositivo.getPuntoVenta().getPuntoventaId().intValue());
|
||||||
|
|
||||||
|
vo.setLsFormasPagamento(new ArrayList<FormaPagamentoVO>());
|
||||||
|
vo.setLsSeguroTaxaEmbarque(new ArrayList<SeguroTaxaEmbarqueVO>());
|
||||||
|
vo.setLsTiposPassagensBloqueadas(new ArrayList<TiposPassagensBloqueadasVO>());
|
||||||
|
|
||||||
|
for (PtovtaEmpresa e : puntoVenta.getLsPtovtaEmpresa()){
|
||||||
List<FormaPagoDet> listFP = dispositivoEmbarcadaDAO.getListaFormaPago(e.getPuntoVenta().getPuntoventaId());
|
List<FormaPagoDet> listFP = dispositivoEmbarcadaDAO.getListaFormaPago(e.getPuntoVenta().getPuntoventaId());
|
||||||
|
|
||||||
for (FormaPagoDet dp : listFP) {
|
for (FormaPagoDet dp : listFP) {
|
||||||
|
@ -138,26 +172,6 @@ public class SincronizarService {
|
||||||
tpb.getEmpresa().getEmpresaId()));
|
tpb.getEmpresa().getEmpresaId()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
vo.setEnderecoEmpresa(empresa.getLogradouro()+", nº: "+empresa.getNumero()+". Cidade: "+empresa.getBairro());
|
|
||||||
Constante estacionEmbarcadaConst = constanteDAO.buscarPorNomeConstante(Constantes.ESTACAO_EMBARCADA);
|
|
||||||
|
|
||||||
if (estacionEmbarcadaConst == null || (estacionEmbarcadaConst != null && estacionEmbarcadaConst.getValorconstante() == null) ||
|
|
||||||
(estacionEmbarcadaConst != null && estacionEmbarcadaConst.getValorconstante().isEmpty())){
|
|
||||||
throw new ServiceEmbarcadaException("Error: Constante ESTACAO_EMBARCADA não cadastrada!");
|
|
||||||
}
|
|
||||||
|
|
||||||
String estacionIdEmbarcada = estacionEmbarcadaConst.getValorconstante();
|
|
||||||
vo.setEstacionId(estacionIdEmbarcada != null && !estacionIdEmbarcada.isEmpty() ? Integer.parseInt(estacionIdEmbarcada) : null);
|
|
||||||
|
|
||||||
for (CtrlSerieEmbarcada serie : dispositivo.getSeries()){
|
|
||||||
EstadoDispositivoEmbarcadaVO estado = new EstadoDispositivoEmbarcadaVO();
|
|
||||||
estado.setDescUf(serie.getEstado().getCveestado());
|
|
||||||
estado.setIdUf(serie.getEstado().getEstadoId().longValue());
|
|
||||||
estado.setNumBpe(serie.getNumeroCorrente());
|
|
||||||
estado.setSerie(serie.getSerie());
|
|
||||||
estado.setEmpresaId(serie.getEmpresa().getEmpresaId().longValue());
|
|
||||||
vo.add(estado);
|
|
||||||
}
|
|
||||||
|
|
||||||
return vo;
|
return vo;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue