From 998c20e15aba6a69dce08cd56b01ae19ab59905c Mon Sep 17 00:00:00 2001 From: wilian Date: Wed, 19 Feb 2020 20:50:31 +0000 Subject: [PATCH] bug#18029 bug#18028 dev:thiago qua: git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Web/trunk/ventaboletos@100307 d1611594-4594-4d17-8e1d-87c2c4800839 --- .../filters/AuthenticationPricingRS.java | 66 +++++ .../rest/bean/ParamsAlterarPricing.java | 94 +++++++ .../rest/pricing/AlteraPricingRS.java | 113 ++++++++ .../rest/returns/PricingRetorno.java | 19 ++ .../rest/service/AlteraPricingService.java | 242 ++++++++++++++++++ .../pricing/EditarPricingCtrlController.java | 103 ++++++++ .../EditarPricingOcupaAntecipaController.java | 31 ++- .../item/pricing/ItemMenuPricingCtrl.java | 26 ++ .../utilerias/menu/menu_original.properties | 2 +- src/java/spring-config.xml | 1 + web/WEB-INF/i3-label_es_MX.label | 24 ++ web/WEB-INF/i3-label_pt_BR.label | 24 ++ web/gui/pricing/editarPricing.zul | 2 +- web/gui/pricing/editarPricingCtrl.zul | 66 +++++ 14 files changed, 800 insertions(+), 13 deletions(-) create mode 100644 src/java/com/rjconsultores/ventaboletos/filters/AuthenticationPricingRS.java create mode 100644 src/java/com/rjconsultores/ventaboletos/rest/bean/ParamsAlterarPricing.java create mode 100644 src/java/com/rjconsultores/ventaboletos/rest/pricing/AlteraPricingRS.java create mode 100644 src/java/com/rjconsultores/ventaboletos/rest/returns/PricingRetorno.java create mode 100644 src/java/com/rjconsultores/ventaboletos/rest/service/AlteraPricingService.java create mode 100644 src/java/com/rjconsultores/ventaboletos/web/gui/controladores/pricing/EditarPricingCtrlController.java create mode 100644 src/java/com/rjconsultores/ventaboletos/web/utilerias/menu/item/pricing/ItemMenuPricingCtrl.java create mode 100644 web/gui/pricing/editarPricingCtrl.zul diff --git a/src/java/com/rjconsultores/ventaboletos/filters/AuthenticationPricingRS.java b/src/java/com/rjconsultores/ventaboletos/filters/AuthenticationPricingRS.java new file mode 100644 index 000000000..86342b958 --- /dev/null +++ b/src/java/com/rjconsultores/ventaboletos/filters/AuthenticationPricingRS.java @@ -0,0 +1,66 @@ +package com.rjconsultores.ventaboletos.filters; + +import java.io.IOException; + +import javax.servlet.Filter; +import javax.servlet.FilterChain; +import javax.servlet.FilterConfig; +import javax.servlet.ServletException; +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; +import javax.servlet.annotation.WebFilter; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.commons.lang.StringUtils; +import org.apache.log4j.Logger; + +import com.rjconsultores.ventaboletos.constantes.ConstantesFuncionSistema; +import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado; + +@WebFilter(filterName = "authenticationPricingRS", urlPatterns = "/rest/pricing/*") +public class AuthenticationPricingRS implements Filter { + + private static Logger log = Logger.getLogger(AuthenticationPricingRS.class); + + @Override + public void init(FilterConfig filterConfig) throws ServletException { + } + + @Override + public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { + try { + if (request instanceof HttpServletRequest) { + HttpServletRequest req = ((HttpServletRequest) request); + HttpServletResponse res = null; + + if (response instanceof HttpServletResponse) { + res = ((HttpServletResponse) response); + } + + if (req != null && res != null) { + String auth = req.getHeader("Authorization"); + if (StringUtils.isNotBlank(auth) && UsuarioLogado.getUsuarioLogado() != null && UsuarioLogado.getUsuarioLogado().isPermisoClave(ConstantesFuncionSistema.CLAVE_ADM_PRICING_MODIFICACAOMASSIVAWS)) { + chain.doFilter(request, response); + } else { + res.setHeader("WWW-Authenticate", "BASIC realm=\"AlteraPricingRS\""); + res.sendError(HttpServletResponse.SC_UNAUTHORIZED); + return; + } + } + } + } catch (Exception e) { + log.error(e.toString(), e); + + HttpServletResponse httpServletResponse = (HttpServletResponse) response; + httpServletResponse.setStatus(HttpServletResponse.SC_BAD_REQUEST); + + ((HttpServletResponse) response).sendError(HttpServletResponse.SC_BAD_REQUEST); + } + } + + @Override + public void destroy() { + } + +} diff --git a/src/java/com/rjconsultores/ventaboletos/rest/bean/ParamsAlterarPricing.java b/src/java/com/rjconsultores/ventaboletos/rest/bean/ParamsAlterarPricing.java new file mode 100644 index 000000000..565159dad --- /dev/null +++ b/src/java/com/rjconsultores/ventaboletos/rest/bean/ParamsAlterarPricing.java @@ -0,0 +1,94 @@ +package com.rjconsultores.ventaboletos.rest.bean; + +import java.util.List; + +import org.codehaus.jackson.annotate.JsonIgnoreProperties; + +import com.rjconsultores.ventaboletos.vo.pricing.Pricing; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class ParamsAlterarPricing { + + private Integer pricingId; + private String nomepricing; + private Integer empresaId; + private String dataViagemInicio; + private String dataViagemFim; + private Integer origemId; + private Integer destinoId; + private Integer diasFimViagem; + + private List pricings; + + public Integer getPricingId() { + return pricingId; + } + + public void setPricingId(Integer pricingId) { + this.pricingId = pricingId; + } + + public String getNomepricing() { + return nomepricing; + } + + public void setNomepricing(String nomepricing) { + this.nomepricing = nomepricing; + } + + public Integer getEmpresaId() { + return empresaId; + } + + public void setEmpresaId(Integer empresaId) { + this.empresaId = empresaId; + } + + public String getDataViagemInicio() { + return dataViagemInicio; + } + + public void setDataViagemInicio(String dataViagemInicio) { + this.dataViagemInicio = dataViagemInicio; + } + + public String getDataViagemFim() { + return dataViagemFim; + } + + public void setDataViagemFim(String dataViagemFim) { + this.dataViagemFim = dataViagemFim; + } + + public Integer getOrigemId() { + return origemId; + } + + public void setOrigemId(Integer origemId) { + this.origemId = origemId; + } + + public Integer getDestinoId() { + return destinoId; + } + + public void setDestinoId(Integer destinoId) { + this.destinoId = destinoId; + } + + public List getPricings() { + return pricings; + } + + public void setPricings(List pricings) { + this.pricings = pricings; + } + + public Integer getDiasFimViagem() { + return diasFimViagem; + } + + public void setDiasFimViagem(Integer diasFimViagem) { + this.diasFimViagem = diasFimViagem; + } +} diff --git a/src/java/com/rjconsultores/ventaboletos/rest/pricing/AlteraPricingRS.java b/src/java/com/rjconsultores/ventaboletos/rest/pricing/AlteraPricingRS.java new file mode 100644 index 000000000..125f0f4d5 --- /dev/null +++ b/src/java/com/rjconsultores/ventaboletos/rest/pricing/AlteraPricingRS.java @@ -0,0 +1,113 @@ +package com.rjconsultores.ventaboletos.rest.pricing; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +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 org.apache.commons.lang.StringUtils; +import org.slf4j.Logger; + +import com.rjconsultores.ventaboletos.constantes.Constantes; +import com.rjconsultores.ventaboletos.enums.PricingOperacaoWS; +import com.rjconsultores.ventaboletos.rest.bean.ParamsAlterarPricing; +import com.rjconsultores.ventaboletos.rest.returns.PricingRetorno; +import com.rjconsultores.ventaboletos.rest.service.AlteraPricingService; +import com.rjconsultores.ventaboletos.utilerias.DateUtil; +import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado; +import com.rjconsultores.ventaboletos.vo.pricing.Pricing; +import com.rjconsultores.ventaboletos.web.utilerias.spring.AppContext; + +@Path("pricing") +public class AlteraPricingRS { + + private static Logger log = org.slf4j.LoggerFactory.getLogger(AlteraPricingRS.class); + + @POST + @Consumes({ MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_JSON }) + @Path("recuperarPricing") + public Response recuperarPricing(ParamsAlterarPricing params) { + PricingRetorno pricingRetorno = new PricingRetorno(); + try { + AlteraPricingService service = (AlteraPricingService) AppContext.getApplicationContext().getBean("alteraPricingService"); + + Date dataViagemInicio = null; + Date dataViagemFim = null; + if(StringUtils.isNotBlank(params.getDataViagemInicio())) { + dataViagemInicio = DateUtil.inicioFecha(DateUtil.getDateFromString(params.getDataViagemInicio(), "dd/MM/yyyy")); + } + + if(StringUtils.isNotBlank(params.getDataViagemFim())) { + dataViagemFim = DateUtil.inicioFecha(DateUtil.getDateFromString(params.getDataViagemFim(), "dd/MM/yyyy")); + } + + List pricings = new ArrayList(); + pricings.addAll(service.buscar(params.getPricingId(), params.getNomepricing(), params.getEmpresaId(), + dataViagemInicio, dataViagemFim, params.getOrigemId(), params.getDestinoId())); + + pricingRetorno.setPricings(pricings); + return Response.ok(pricingRetorno, MediaType.APPLICATION_JSON + Constantes.CHARSET_UTF8).build(); + } catch (Exception e) { + log.error(e.getMessage(), e); + return Response.noContent().build(); + } + } + + @POST + @Consumes({ MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_JSON }) + @Path("alterarPricing") + public Response alterarPricing(ParamsAlterarPricing params) { + String retorno = "Tipo Operação não identificada"; + AlteraPricingService service = (AlteraPricingService) AppContext.getApplicationContext().getBean("alteraPricingService"); + + if(isUsuarioValido()) { + if(params != null && params.getPricings() != null) { + for (Pricing pricing : params.getPricings()) { + if(PricingOperacaoWS.INCLUIR.toString().equals(pricing.getPricingoperacao())) { + retorno = service.incluir(pricing); + } else if(PricingOperacaoWS.ALTERAR.toString().equals(pricing.getPricingoperacao())) { + retorno = service.alterar(pricing); + } else if(PricingOperacaoWS.EXCLUIR.toString().equals(pricing.getPricingoperacao())) { + retorno = service.excluir(pricing); + } else if(PricingOperacaoWS.INATIVAR.toString().equals(pricing.getPricingoperacao())) { + retorno = service.inativar(pricing); + } + } + } + } else { + retorno = "Usuário da operação não identificado ou inválido"; + } + + return Response.ok(retorno, MediaType.APPLICATION_JSON + Constantes.CHARSET_UTF8).build(); + } + + @POST + @Consumes({ MediaType.APPLICATION_JSON }) + @Produces({ MediaType.APPLICATION_JSON }) + @Path("excluirPricingDiasFimViagem") + public Response excluirPricingDiasFimViagem(ParamsAlterarPricing params) { + String retorno = "Dias Fim Viagem informado é inválido."; + if(isUsuarioValido()) { + if(params.getDiasFimViagem() != null || params.getDiasFimViagem() > 0) { + AlteraPricingService service = (AlteraPricingService) AppContext.getApplicationContext().getBean("alteraPricingService"); + retorno = service.excluir(params.getDiasFimViagem()); + } + } else { + retorno = "Usuário da operação não identificado ou inválido"; + } + return Response.ok(retorno, MediaType.APPLICATION_JSON + Constantes.CHARSET_UTF8).build(); + } + + private boolean isUsuarioValido() { + return UsuarioLogado.getUsuarioLogado() != null; + } + +} diff --git a/src/java/com/rjconsultores/ventaboletos/rest/returns/PricingRetorno.java b/src/java/com/rjconsultores/ventaboletos/rest/returns/PricingRetorno.java new file mode 100644 index 000000000..fa6e7420f --- /dev/null +++ b/src/java/com/rjconsultores/ventaboletos/rest/returns/PricingRetorno.java @@ -0,0 +1,19 @@ +package com.rjconsultores.ventaboletos.rest.returns; + +import java.util.List; + +import com.rjconsultores.ventaboletos.vo.pricing.Pricing; + +public class PricingRetorno { + + private List pricings; + + public List getPricings() { + return pricings; + } + + public void setPricings(List pricings) { + this.pricings = pricings; + } + +} diff --git a/src/java/com/rjconsultores/ventaboletos/rest/service/AlteraPricingService.java b/src/java/com/rjconsultores/ventaboletos/rest/service/AlteraPricingService.java new file mode 100644 index 000000000..19900fd9a --- /dev/null +++ b/src/java/com/rjconsultores/ventaboletos/rest/service/AlteraPricingService.java @@ -0,0 +1,242 @@ +package com.rjconsultores.ventaboletos.rest.service; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +import org.apache.commons.lang.StringUtils; +import org.apache.log4j.Logger; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import com.rjconsultores.ventaboletos.entidad.Empresa; +import com.rjconsultores.ventaboletos.service.PricingAsientoService; +import com.rjconsultores.ventaboletos.service.PricingCategoriaService; +import com.rjconsultores.ventaboletos.service.PricingClaseService; +import com.rjconsultores.ventaboletos.service.PricingCorridaService; +import com.rjconsultores.ventaboletos.service.PricingDiaService; +import com.rjconsultores.ventaboletos.service.PricingMarcaService; +import com.rjconsultores.ventaboletos.service.PricingMercadoService; +import com.rjconsultores.ventaboletos.service.PricingOcupaAntecipaService; +import com.rjconsultores.ventaboletos.service.PricingPuntoVentaService; +import com.rjconsultores.ventaboletos.service.PricingRutaService; +import com.rjconsultores.ventaboletos.service.PricingService; +import com.rjconsultores.ventaboletos.service.PricingTipoPtoVtaService; +import com.rjconsultores.ventaboletos.service.PricingTipoServicioService; +import com.rjconsultores.ventaboletos.service.PricingVigenciaService; +import com.rjconsultores.ventaboletos.utilerias.PricingConverterVOToEntidad; +import com.rjconsultores.ventaboletos.vo.pricing.Pricing; + +@Service("alteraPricingService") +public class AlteraPricingService { + + private static Logger log = Logger.getLogger(AlteraPricingService.class); + + @Autowired + PricingService pricingService; + + @Autowired + PricingAsientoService pricingAsientoService; + + @Autowired + PricingTipoPtoVtaService pricingTipoPtoVtaService; + + @Autowired + PricingCategoriaService pricingCategoriaService; + + @Autowired + PricingClaseService pricingClaseService; + + @Autowired + PricingCorridaService pricingCorridaService; + + @Autowired + PricingDiaService pricingDiaService; + + @Autowired + PricingOcupaAntecipaService pricingOcupaAntecipaService; + + @Autowired + PricingPuntoVentaService pricingPuntoVentaService; + + @Autowired + PricingRutaService pricingRutaService; + + @Autowired + PricingTipoServicioService pricingTipoServicioService; + + @Autowired + PricingMercadoService pricingMercadoService; + + @Autowired + PricingVigenciaService pricingVigenciaService; + + @Autowired + PricingMarcaService pricingMarcaService; + + public List buscar(Integer pricingId, String nomepricing, Integer empresaId, Date dataViagemInicio, Date dataViagemFim, Integer origemId, Integer destinoId) { + try { + List lsPricings = pricingService.buscar(pricingId, nomepricing, empresaId, + dataViagemInicio, dataViagemFim, origemId, destinoId); + List lsRetorno = new ArrayList(); + + for (com.rjconsultores.ventaboletos.entidad.Pricing pricing : lsPricings) { + Pricing pricingVO = new Pricing(pricing); + lsRetorno.add(pricingVO); + } + return lsRetorno; + } catch (Exception e) { + log.error(e.getMessage(), e); + } + return null; + } + + @Transactional + public String incluir(Pricing pricingVO) { + try { + com.rjconsultores.ventaboletos.entidad.Pricing pricing = PricingConverterVOToEntidad.getInstance().convertVOToEntidad(pricingVO); + pricing.setPricingId(null); + pricing = pricingService.suscribir(pricing); + + return "OK"; + } catch (Exception e) { + log.error(e.getMessage(), e); + } + + return "ERROR"; + } + + @Transactional + public String alterar(Pricing pricingVO) { + try { + com.rjconsultores.ventaboletos.entidad.Pricing pricing = pricingService.obtenerID(pricingVO.getPricingId()); + pricing.setPricingId(pricingVO.getPricingId()); + pricing.setNombPricing(pricingVO.getNomePricing()); + pricing.setCantboleto(pricingVO.getQtdePoltronas() != null ? pricingVO.getQtdePoltronas().shortValue() : null); + pricing.setDescuentoporcentaje(pricingVO.getPorcentagemIda()); + pricing.setDescuentoporcredondo(pricingVO.getPorcentagemIdaVolta()); + pricing.setIndtransferible(pricingVO.getPodeTransferir() != null ? pricingVO.getPodeTransferir().equals(1) : true); + pricing.setIndreservable(pricingVO.getPodeReservar() != null ? pricingVO.getPodeReservar().equals(1) : true); + pricing.setExibeVenda(pricingVO.getExibirVenda() != null ? pricingVO.getExibirVenda().equals(1) : true); + pricing.setIndcancelable(pricingVO.getPodeCancelar() != null ? pricingVO.getPodeCancelar().equals(1) : true); + pricing.setActivo(com.rjconsultores.ventaboletos.entidad.Pricing.ATIVO); + pricing.setFecmodif(new Date()); + pricing.setCantdiasanticipacion(pricingVO.getDiasAtencipacao()); + pricing.setEmpresa(new Empresa(pricingVO.getEmpresaId())); + pricing.setIndGeneraFeriadoViaje(StringUtils.isNotBlank(pricingVO.getAplicaFeriadoDtViagem()) ? pricingVO.getAplicaFeriadoDtViagem() : "S"); + pricing.setIndGeneraFeriadoVenta(StringUtils.isNotBlank(pricingVO.getAplicaFeriadoDtVenda()) ? pricingVO.getAplicaFeriadoDtVenda() : "S"); + + if(pricingVO.getPoltronas() != null && !pricingVO.getPoltronas().isEmpty()) { + pricingAsientoService.borrar(pricing.getPricingAsientoList()); + PricingConverterVOToEntidad.getInstance().convertVOToEntidadPoltronas(pricing, pricingVO); + } + + if(pricingVO.getCanalvendas() != null && !pricingVO.getCanalvendas().isEmpty()) { + pricingTipoPtoVtaService.borrar(pricing.getPricingTipoptovtaList()); + PricingConverterVOToEntidad.getInstance().convertVOToEntidadCanalVendas(pricing, pricingVO); + } + + if(pricingVO.getCategorias() != null && !pricingVO.getCategorias().isEmpty()) { + pricingCategoriaService.borrar(pricing.getPricingCategoriaList()); + PricingConverterVOToEntidad.getInstance().convertVOToEntidadCategorias(pricing, pricingVO); + } + + if(pricingVO.getClasses() != null && !pricingVO.getClasses().isEmpty()) { + pricingClaseService.borrar(pricing.getPricingClaseList()); + PricingConverterVOToEntidad.getInstance().convertVOToEntidadClasses(pricing, pricingVO); + } + + if(pricingVO.getServicos() != null && !pricingVO.getServicos().isEmpty()) { + pricingCorridaService.borrar(pricing.getPricingCorridaList()); + PricingConverterVOToEntidad.getInstance().convertVOToEntidadServicos(pricing, pricingVO); + } + + if(pricingVO.getDias() != null && !pricingVO.getDias().isEmpty()) { + pricingDiaService.borrar(pricing.getPricingDiaList()); + PricingConverterVOToEntidad.getInstance().convertVOToEntidadDias(pricing, pricingVO); + } + + if(pricingVO.getOcupacoes() != null && !pricingVO.getOcupacoes().isEmpty()) { + pricingOcupaAntecipaService.borrar(pricing.getPricingOcupaAntecipaList()); + PricingConverterVOToEntidad.getInstance().convertVOToEntidadOcupacoes(pricing, pricingVO); + } + + if(pricingVO.getPuntoventas() != null && !pricingVO.getPuntoventas().isEmpty()) { + pricingPuntoVentaService.borrar(pricing.getPricingPuntoventaList()); + PricingConverterVOToEntidad.getInstance().convertVOToEntidadPuntoventas(pricing, pricingVO); + } + + if(pricingVO.getLinhas() != null && !pricingVO.getLinhas().isEmpty()) { + pricingRutaService.borrar(pricing.getPricingRutaList()); + PricingConverterVOToEntidad.getInstance().convertVOToEntidadLinhas(pricing, pricingVO); + } + + if(pricingVO.getTiposervicos() != null && !pricingVO.getTiposervicos().isEmpty()) { + pricingTipoServicioService.borrar(pricing.getPricingTipoServicioList()); + PricingConverterVOToEntidad.getInstance().convertVOToEntidadTiposervicos(pricing, pricingVO); + } + + if(pricingVO.getMercados() != null && !pricingVO.getMercados().isEmpty()) { + pricingMercadoService.borrar(pricing.getPricingMercadoList()); + PricingConverterVOToEntidad.getInstance().convertVOToEntidadMercados(pricing, pricingVO); + } + + if(pricingVO.getVigencias() != null && !pricingVO.getVigencias().isEmpty()) { + pricingVigenciaService.borrar(pricing.getPricingVigenciaList()); + PricingConverterVOToEntidad.getInstance().convertVOToEntidadVigencias(pricing, pricingVO); + } + + if(pricingVO.getMarcas() != null && !pricingVO.getMarcas().isEmpty()) { + pricingMarcaService.borrar(pricing.getPricingMarcaList()); + PricingConverterVOToEntidad.getInstance().convertVOToEntidadMarcas(pricing, pricingVO); + } + + pricingService.actualizacion(pricing); + + return "OK"; + } catch (Exception e) { + log.error(e.getMessage(), e); + } + + return "ERROR"; + } + + @Transactional + public String excluir(Pricing pricingVO) { + try { + com.rjconsultores.ventaboletos.entidad.Pricing pricing = pricingService.obtenerID(pricingVO.getPricingId()); + pricingService.borrar(pricing); + return "OK"; + } catch (Exception e) { + log.error(e.getMessage(), e); + } + + return "ERROR"; + } + + @Transactional + public String excluir(Integer diasFimViagem) { + try { + pricingService.excluirPricing(diasFimViagem); + return "OK"; + } catch (Exception e) { + log.error(e.getMessage(), e); + } + + return "ERROR"; + } + + public String inativar(Pricing pricingVO) { + try { + com.rjconsultores.ventaboletos.entidad.Pricing pricing = pricingService.obtenerID(pricingVO.getPricingId()); + pricingService.inativar(pricing); + return "OK"; + } catch (Exception e) { + log.error(e.getMessage(), e); + } + + return "ERROR"; + } + +} diff --git a/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/pricing/EditarPricingCtrlController.java b/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/pricing/EditarPricingCtrlController.java new file mode 100644 index 000000000..5a3f6ce7f --- /dev/null +++ b/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/pricing/EditarPricingCtrlController.java @@ -0,0 +1,103 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package com.rjconsultores.ventaboletos.web.gui.controladores.pricing; + +import org.apache.log4j.Logger; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Controller; +import org.zkoss.util.resource.Labels; +import org.zkoss.zk.ui.Component; +import org.zkoss.zk.ui.event.Event; +import org.zkoss.zul.Messagebox; + +import com.rjconsultores.ventaboletos.entidad.PricingCtrl; +import com.rjconsultores.ventaboletos.service.PricingCtrlService; +import com.rjconsultores.ventaboletos.web.utilerias.MyGenericForwardComposer; + +/** + * + * @author Rafius + */ +@Controller("editarPricingCtrlController") +@Scope("prototype") +public class EditarPricingCtrlController extends MyGenericForwardComposer { + + private static Logger log = Logger.getLogger(EditarPricingCtrlController.class); + + private static final long serialVersionUID = 1L; + + @Autowired + private PricingCtrlService pricingCtrlService; + + private PricingCtrl pricingCtrl; + + @Override + public void doAfterCompose(Component comp) throws Exception { + super.doAfterCompose(comp); + + pricingCtrl = pricingCtrlService.obtenerPricingCtrl(); + if(pricingCtrl == null) { + pricingCtrl = new PricingCtrl(); + } + + } + + public void onClick$btnSalvar(Event ev) throws InterruptedException { + try { + + pricingCtrl = pricingCtrlService.suscribirOrActualizacion(pricingCtrl); + + Messagebox.show( + Labels.getLabel("editarPricingCtrlController.MSG.suscribirOK"), + Labels.getLabel("editarPricingCtrlController.window.title"), + Messagebox.OK, Messagebox.INFORMATION); + + closeWindow(); + + } catch (Exception e) { + log.error(e.getMessage(), e); + Messagebox.show(e.getLocalizedMessage(), Labels.getLabel("editarPricingCtrlController.window.title"), Messagebox.OK, Messagebox.ERROR); + } + } + + public void onClick$btnApagar(Event ev) throws InterruptedException { + try { + int resp = Messagebox.show( + Labels.getLabel("editarPricingCtrlController.MSG.borrarPergunta"), + Labels.getLabel("editarPricingCtrlController.window.title"), + Messagebox.YES | Messagebox.NO, Messagebox.QUESTION); + + if (resp == Messagebox.YES) { + + pricingCtrlService.borrar(pricingCtrl); + + Messagebox.show( + Labels.getLabel("editarPricingCtrlController.MSG.borrarOK"), + Labels.getLabel("editarPricingCtrlController.window.title"), + Messagebox.OK, Messagebox.INFORMATION); + + closeWindow(); + } + } catch (Exception e) { + log.error(e.getMessage(), e); + Messagebox.show(e.getLocalizedMessage(), Labels.getLabel("editarPricingCtrlController.window.title"), Messagebox.OK, Messagebox.ERROR); + } + } + + public String getStatusAtual() { + return Labels.getLabel("editarPricingCtrlController.lbStatusAtual.value", + pricingCtrl != null && pricingCtrl.getPricingctrlId() != null ? new String[] {Labels.getLabel("MSG.ATIVADO")} : new String[] {Labels.getLabel("MSG.DESATIVADO")}); + } + + public Boolean getAtivado() { + return pricingCtrl != null && pricingCtrl.getPricingctrlId() != null; + } + + public Boolean getDesativado() { + return !getAtivado(); + } + +} diff --git a/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/pricing/EditarPricingOcupaAntecipaController.java b/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/pricing/EditarPricingOcupaAntecipaController.java index b4be4402c..fbe4464bc 100644 --- a/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/pricing/EditarPricingOcupaAntecipaController.java +++ b/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/pricing/EditarPricingOcupaAntecipaController.java @@ -18,8 +18,10 @@ import org.zkoss.zul.api.Comboitem; import com.rjconsultores.ventaboletos.entidad.Pricing; import com.rjconsultores.ventaboletos.entidad.PricingClasseTarifaria; +import com.rjconsultores.ventaboletos.entidad.PricingCtrl; import com.rjconsultores.ventaboletos.entidad.PricingOcupaAntecipa; import com.rjconsultores.ventaboletos.service.PricingClasseTarifariaService; +import com.rjconsultores.ventaboletos.service.PricingCtrlService; import com.rjconsultores.ventaboletos.service.PricingOcupaAntecipaService; import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado; import com.rjconsultores.ventaboletos.web.utilerias.ConstraintPorcentagem; @@ -35,6 +37,10 @@ public class EditarPricingOcupaAntecipaController extends MyGenericForwardCompos private static Logger log = Logger.getLogger(EditarPricingOcupaAntecipaController.class); @Autowired private PricingOcupaAntecipaService pricingOcupaAntecipaService; + + @Autowired + private PricingCtrlService pricingCtrlService; + private PricingOcupaAntecipa pricingOcupaAntecipa; private MyListbox pricingOcupaAntecipaList; private Intbox ocupacioninicial; @@ -100,6 +106,7 @@ public class EditarPricingOcupaAntecipaController extends MyGenericForwardCompos } public void onClick$btnAdicionarOcupaAntecipa(Event ev) throws Exception { + PricingCtrl pricingCtrl = pricingCtrlService.obtenerPricingCtrl(); if ((cantasientosmin.getValue() != null || cantasientosmax.getValue() != null) && (ocupacioninicial.getValue() != null || ocupacionfinal.getValue() != null)) { @@ -123,17 +130,19 @@ public class EditarPricingOcupaAntecipaController extends MyGenericForwardCompos return; } - if ((cantasientosmin.getValue() == null && cantasientosmax.getValue() != null) - || (cantasientosmin.getValue() != null && cantasientosmax.getValue() == null) - || (ocupacioninicial.getValue() == null && ocupacionfinal.getValue() != null) - || (ocupacioninicial.getValue() != null && ocupacionfinal.getValue() == null) - || (cantdiasmin.getValue() == null && cantdiasmax.getValue() != null) - || (cantdiasmin.getValue() != null && cantdiasmax.getValue() == null)) { - Messagebox.show(Labels.getLabel("editarPricingController.ocupacionErrada.MinMax"), - Labels.getLabel("editarPricingController.windowOcupacion.title"), - Messagebox.OK, Messagebox.EXCLAMATION); - - return; + if(pricingCtrl == null) { + if ((cantasientosmin.getValue() == null && cantasientosmax.getValue() != null) + || (cantasientosmin.getValue() != null && cantasientosmax.getValue() == null) + || (ocupacioninicial.getValue() == null && ocupacionfinal.getValue() != null) + || (ocupacioninicial.getValue() != null && ocupacionfinal.getValue() == null) + || (cantdiasmin.getValue() == null && cantdiasmax.getValue() != null) + || (cantdiasmin.getValue() != null && cantdiasmax.getValue() == null)) { + Messagebox.show(Labels.getLabel("editarPricingController.ocupacionErrada.MinMax"), + Labels.getLabel("editarPricingController.windowOcupacion.title"), + Messagebox.OK, Messagebox.EXCLAMATION); + + return; + } } Comboitem cbiClasseTarifaria = cmbPricingClasseTarifaria.getSelectedItem(); diff --git a/src/java/com/rjconsultores/ventaboletos/web/utilerias/menu/item/pricing/ItemMenuPricingCtrl.java b/src/java/com/rjconsultores/ventaboletos/web/utilerias/menu/item/pricing/ItemMenuPricingCtrl.java new file mode 100644 index 000000000..0fedba0f1 --- /dev/null +++ b/src/java/com/rjconsultores/ventaboletos/web/utilerias/menu/item/pricing/ItemMenuPricingCtrl.java @@ -0,0 +1,26 @@ +package com.rjconsultores.ventaboletos.web.utilerias.menu.item.pricing; + +import org.zkoss.util.resource.Labels; + +import com.rjconsultores.ventaboletos.web.utilerias.PantallaUtileria; +import com.rjconsultores.ventaboletos.web.utilerias.menu.DefaultItemMenuSistema; + +public class ItemMenuPricingCtrl extends DefaultItemMenuSistema { + + public ItemMenuPricingCtrl() { + super("indexController.mniPricingCtrl.label"); + } + + @Override + public String getClaveMenu() { + return "COM.RJCONSULTORES.ADMINISTRACION.GUI.PRICING.MENU.CONFIGURACAO"; + } + + @Override + public void ejecutar() { + PantallaUtileria.openWindow("/gui/pricing/editarPricingCtrl.zul", + Labels.getLabel("editarPricingCtrlController.window.title"), getArgs(), desktop); + + } + +} diff --git a/src/java/com/rjconsultores/ventaboletos/web/utilerias/menu/menu_original.properties b/src/java/com/rjconsultores/ventaboletos/web/utilerias/menu/menu_original.properties index c1062b4f8..d443a3a6e 100644 --- a/src/java/com/rjconsultores/ventaboletos/web/utilerias/menu/menu_original.properties +++ b/src/java/com/rjconsultores/ventaboletos/web/utilerias/menu/menu_original.properties @@ -1,4 +1,3 @@ -catalogos=com.rjconsultores.ventaboletos.web.utilerias.menu.item.catalogos.MenuCatalogos catalogos.mensagemRecusa=com.rjconsultores.ventaboletos.web.utilerias.menu.item.catalogos.ItemMenuMensagemRecusa catalogos.claseServicio=com.rjconsultores.ventaboletos.web.utilerias.menu.item.catalogos.ItemMenuClaseServicio catalogos.categoria=com.rjconsultores.ventaboletos.web.utilerias.menu.item.catalogos.ItemMenuCategoria @@ -128,6 +127,7 @@ tarifas.excepcionPeaje=com.rjconsultores.ventaboletos.web.utilerias.menu.item.co tarifas.redondeo=com.rjconsultores.ventaboletos.web.utilerias.menu.item.tarifas.ItemMenuRedondeo tarifas.cotacao=com.rjconsultores.ventaboletos.web.utilerias.menu.item.tarifas.ItemMenuCotacao pricing=com.rjconsultores.ventaboletos.web.utilerias.menu.item.pricing.MenuPricing +pricing.pricingCtrl=com.rjconsultores.ventaboletos.web.utilerias.menu.item.pricing.ItemMenuPricingCtrl pricing.general=com.rjconsultores.ventaboletos.web.utilerias.menu.item.pricing.ItemMenuPricing pricing.especifico=com.rjconsultores.ventaboletos.web.utilerias.menu.item.pricing.ItemMenuPricingEspecifico pricing.modificacionMassivaEspecifico=com.rjconsultores.ventaboletos.web.utilerias.menu.item.pricing.ItemMenuModificacionMassivaPricingEspecifico diff --git a/src/java/spring-config.xml b/src/java/spring-config.xml index 8e78b5b08..f4fefad06 100644 --- a/src/java/spring-config.xml +++ b/src/java/spring-config.xml @@ -495,6 +495,7 @@ com.rjconsultores.ventaboletos.entidad.TarifaEmbarcadaHist com.rjconsultores.ventaboletos.entidad.Cotacao com.rjconsultores.ventaboletos.entidad.AliquotaEstadoDestino + com.rjconsultores.ventaboletos.entidad.PricingCtrl diff --git a/web/WEB-INF/i3-label_es_MX.label b/web/WEB-INF/i3-label_es_MX.label index 2e9c468af..475b5bc16 100644 --- a/web/WEB-INF/i3-label_es_MX.label +++ b/web/WEB-INF/i3-label_es_MX.label @@ -62,6 +62,8 @@ MSG.Error.invalida.puntoVendaTodosNaoPermitido = Quando é informado Data Inicia MSG.Error.invalida.intervaloInvalido = Intervalo inválido, o período de pesquisa deve ser de MSG.Error.invalida.intervaloInvalidoDias = dia(s). MSG.Error.invalida.puntoVentaSemFechamentoParaEmpresa = Esta agência não possui fechamento para esta empresa. +MSG.ATIVADO = Ativado +MSG.DESATIVADO = Desativado # Labels Default lb.id = ID @@ -78,6 +80,8 @@ lb.numBpe = Número BP-e lb.chbpe = Chave BP-e lb.todas = TODAS lb.puntoventa = Punto Venta +lb.btnAtivar = Ativar +lb.btnDesativar = Desativar # Reporte relatorio.lb.btnExecutarRelatorio = Ejecutar reporte @@ -180,6 +184,7 @@ indexController.mniCambioVigencia.label = Cambiar/Copia vigencia indexController.mnAjuda.label = Ayuda indexController.mniVersion.label = Versión indexController.mniPricing.label = Pricing +indexController.mniPricingCtrl.label = Configurações do Pricing indexController.mniConfiguracionServicio.label = Configuración de producto o servicio de terceros indexController.mniPricingEspecifico.label = Pricing específico indexController.mnSeguridad.label = Seguridad @@ -8521,6 +8526,25 @@ reenvioBpeController.MSG.bpeNaoSelecionados = Nenhum BP-e selecionado para reenv reenvioBpeController.MSG.bpeDefinidosReenvio = BP-e(s) selecioando(s) definido(s) para reenvio com sucesso reenvioBpeController.MSG.bpeNaoLocalizado = Nenhum BP-e localizado com os filtros informados +# Princing Configurações +editarPricingCtrlController.window.title = Configurações do Pricing e Pricing Específicio +editarPricingCtrlController.btnApagar.tooltiptext = Excluir Configuração Pricing +editarPricingCtrlController.btnSalvar.tooltiptext = Salvar Configuração Pricing +editarPricingCtrlController.btnFechar.tooltiptext = Fechar Configuração Pricing +editarPricingCtrlController.lbStatusAtual.value = Status atual: {0} +editarPricingCtrlController.lbMsg.value = Ao ativar as configurações os seguintes comportamentos serão adotados: +editarPricingCtrlController.lbPriorcorrida.value = Priorizar Pricing com Serviços informados +editarPricingCtrlController.lbSomarcorridaruta.value = - Não Somar/Combinar Pricing com Serviços e Linhas informados +editarPricingCtrlController.lbSomarcorrida.value = - Somar/Combinar Pricing com Serviços informados +editarPricingCtrlController.lbSomarruta.value = - Não Somar/Combinar Pricing com Linhas informadas +editarPricingCtrlController.lbObrdiasminoumax.value = - Não é obrigatório informar dia mínimo e máximo Pricing +editarPricingCtrlController.lbManterprecoselasiento.value = - Manter valor Pricing após selecionar poltrona +editarPricingCtrlController.lbPriorizarPricingEspecifico.value = - Priorizar Pricing Específico com Trecho, Agência ou Canal de Venda específico definido +editarPricingCtrlController.MSG.suscribirOK = Configuração Pricing Ativada com Sucesso. +editarPricingCtrlController.MSG.borrarPergunta = Deseja Desativar esta Configuração do Pricing ? +editarPricingCtrlController.MSG.borrarOK = Configuração do Pricing Desativada com Sucesso. +reenvioBpeController.MSG.bpeNaoLocalizado = Nenhum BP-e localizado com os filtros informados + # Extrair BPe XML extrairBpeXmlController.window.title = Extrair BP-e XML extrairBpeXmlController.lbl.btnExtrairBpeXml = Extrair XML diff --git a/web/WEB-INF/i3-label_pt_BR.label b/web/WEB-INF/i3-label_pt_BR.label index 87955ec97..cb3aea78b 100644 --- a/web/WEB-INF/i3-label_pt_BR.label +++ b/web/WEB-INF/i3-label_pt_BR.label @@ -63,6 +63,8 @@ MSG.Error.necessita.puntoVenta = Ponto de Venda (Agência) Obrigatório MSG.Error.invalida.intervaloInvalido = Intervalo inválido, o período de pesquisa deve ser de MSG.Error.invalida.intervaloInvalidoDias = dia(s). MSG.Error.invalida.puntoVentaSemFechamentoParaEmpresa = Esta agência não possui fechamento para esta empresa. +MSG.ATIVADO = Ativado +MSG.DESATIVADO = Desativado # Labels Default lb.id = ID @@ -79,6 +81,8 @@ lb.numBpe = Número BP-e lb.chbpe = Chave BP-e lb.todas = TODAS lb.puntoventa = Ponto de Venda (Agência) +lb.btnAtivar = Ativar +lb.btnDesativar = Desativar # Relatório relatorio.lb.btnExecutarRelatorio = Executar Relatório @@ -183,6 +187,7 @@ indexController.mniCambioVigencia.label = Mudar/Copiar Vigência indexController.mnAjuda.label = Ajuda indexController.mniVersion.label = Versão indexController.mniPricing.label = Pricing +indexController.mniPricingCtrl.label = Configurações do Pricing indexController.mniConfiguracionServicio.label = Configuração de Produto ou Serviço Tercerizado indexController.mniPricingEspecifico.label = Pricing Específico indexController.mnSeguridad.label = Segurança @@ -9069,6 +9074,25 @@ reenvioBpeController.MSG.bpeNaoSelecionados = Nenhum BP-e selecionado para reenv reenvioBpeController.MSG.bpeDefinidosReenvio = BP-e(s) selecioando(s) definido(s) para reenvio com sucesso reenvioBpeController.MSG.bpeNaoLocalizado = Nenhum BP-e localizado com os filtros informados +# Princing Configurações +editarPricingCtrlController.window.title = Configurações do Pricing e Pricing Específicio +editarPricingCtrlController.btnApagar.tooltiptext = Excluir Configuração Pricing +editarPricingCtrlController.btnSalvar.tooltiptext = Salvar Configuração Pricing +editarPricingCtrlController.btnFechar.tooltiptext = Fechar Configuração Pricing +editarPricingCtrlController.lbStatusAtual.value = Status atual: {0} +editarPricingCtrlController.lbMsg.value = Ao ativar as configurações os seguintes comportamentos serão adotados: +editarPricingCtrlController.lbPriorcorrida.value = - Priorizar Pricing com Serviços informados +editarPricingCtrlController.lbSomarcorridaruta.value = - Não Somar/Combinar Pricing com Serviços e Linhas informados +editarPricingCtrlController.lbSomarcorrida.value = - Somar/Combinar Pricing com Serviços informados +editarPricingCtrlController.lbSomarruta.value = - Não Somar/Combinar Pricing com Linhas informadas +editarPricingCtrlController.lbObrdiasminoumax.value = - Não é obrigatório informar dia mínimo e máximo Pricing +editarPricingCtrlController.lbManterprecoselasiento.value = - Manter valor Pricing após selecionar poltrona +editarPricingCtrlController.lbPriorizarPricingEspecifico.value = - Priorizar Pricing Específico com Trecho, Agência ou Canal de Venda específico definido +editarPricingCtrlController.MSG.suscribirOK = Configuração Pricing Ativada com Sucesso. +editarPricingCtrlController.MSG.borrarPergunta = Deseja Desativar esta Configuração do Pricing ? +editarPricingCtrlController.MSG.borrarOK = Configuração do Pricing Desativada com Sucesso. +reenvioBpeController.MSG.bpeNaoLocalizado = Nenhum BP-e localizado com os filtros informados + # Extrair BPe XML extrairBpeXmlController.window.title = Extrair BP-e XML extrairBpeXmlController.lbl.btnExtrairBpeXml = Extrair XML diff --git a/web/gui/pricing/editarPricing.zul b/web/gui/pricing/editarPricing.zul index c194922dd..e0817823b 100644 --- a/web/gui/pricing/editarPricing.zul +++ b/web/gui/pricing/editarPricing.zul @@ -73,7 +73,7 @@