|
|
@ -21,6 +21,7 @@ import org.zkoss.zul.Radio;
|
|
|
|
|
|
|
|
|
|
|
|
import com.rjconsultores.ventaboletos.entidad.Pricing;
|
|
|
|
import com.rjconsultores.ventaboletos.entidad.Pricing;
|
|
|
|
import com.rjconsultores.ventaboletos.entidad.PricingOcupaAntecipa;
|
|
|
|
import com.rjconsultores.ventaboletos.entidad.PricingOcupaAntecipa;
|
|
|
|
|
|
|
|
import com.rjconsultores.ventaboletos.exception.BusinessException;
|
|
|
|
import com.rjconsultores.ventaboletos.service.PricingOcupaAntecipaService;
|
|
|
|
import com.rjconsultores.ventaboletos.service.PricingOcupaAntecipaService;
|
|
|
|
import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado;
|
|
|
|
import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado;
|
|
|
|
import com.rjconsultores.ventaboletos.web.utilerias.ConstraintPorcentagem;
|
|
|
|
import com.rjconsultores.ventaboletos.web.utilerias.ConstraintPorcentagem;
|
|
|
@ -45,9 +46,11 @@ public class EditarPricingOcupaAntecipaAutomaticoController extends MyGenericFor
|
|
|
|
private Intbox ocupacioninicial;
|
|
|
|
private Intbox ocupacioninicial;
|
|
|
|
private Intbox ocupacionfinal;
|
|
|
|
private Intbox ocupacionfinal;
|
|
|
|
private Intbox cantdiasmin;
|
|
|
|
private Intbox cantdiasmin;
|
|
|
|
|
|
|
|
|
|
|
|
private MyTextboxDecimal porcentaje;
|
|
|
|
private MyTextboxDecimal porcentaje;
|
|
|
|
|
|
|
|
|
|
|
|
private List<PricingOcupaAntecipa> lsPricingOcupaAntecipa;
|
|
|
|
private List<PricingOcupaAntecipa> lsPricingOcupaAntecipa;
|
|
|
|
private List<PricingOcupaAntecipa> novaListaPricingOcupaAntecipa;
|
|
|
|
|
|
|
|
private Radio rdOcupacao;
|
|
|
|
private Radio rdOcupacao;
|
|
|
|
private Boolean hasNoElements;
|
|
|
|
private Boolean hasNoElements;
|
|
|
|
|
|
|
|
|
|
|
@ -63,26 +66,33 @@ public class EditarPricingOcupaAntecipaAutomaticoController extends MyGenericFor
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
* Transformar a tabela (valores de exemplo) :
|
|
|
|
* Transformar a tabela (valores de exemplo) :
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Qtd. Dias Qtd. Dias Ocup. Min. Ocup. Máx. Porcentagem Minimo Máximo
|
|
|
|
* Qtd. Dias Qtd. Dias Ocup. Min. Ocup. Máx. Porcentagem
|
|
|
|
*
|
|
|
|
* Minimo Máximo
|
|
|
|
* 12 * 0% 20% -30% 12 * 21% 80% -15% 12 * 81% 90% -10% 8 11 0% 80% -15% 8 11 81% 90% -10% 4 7 0% 90% -10%
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* 12 * 0% 20% -30%
|
|
|
|
|
|
|
|
* 12 * 21% 80% -15%
|
|
|
|
|
|
|
|
* 12 * 81% 90% -10%
|
|
|
|
|
|
|
|
* 8 11 0% 80% -15%
|
|
|
|
|
|
|
|
* 8 11 81% 90% -10%
|
|
|
|
|
|
|
|
* 4 7 0% 90% -10%
|
|
|
|
|
|
|
|
*
|
|
|
|
* Na forma:
|
|
|
|
* Na forma:
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* 12 dias ----> 30% (ocupação de 0% -> 20%) 08 dias ----> 15% (ocupação de 21% -> 80%) 04 dias ----> 10% (ocupação de 81% -> 90%)
|
|
|
|
* 12 dias ----> 30% (ocupação de 0% -> 20%)
|
|
|
|
|
|
|
|
* 08 dias ----> 15% (ocupação de 21% -> 80%)
|
|
|
|
|
|
|
|
* 04 dias ----> 10% (ocupação de 81% -> 90%)
|
|
|
|
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
argList = (List<PricingOcupaAntecipa>) Executions.getCurrent().getArg().get("clasePricingOcupaAntecipaList");
|
|
|
|
argList = (List<PricingOcupaAntecipa>) Executions.getCurrent().getArg().get("clasePricingOcupaAntecipaList");
|
|
|
|
parentPricingOcupaAntecipaList = (MyListbox) Executions.getCurrent().getArg().get("pricingOcupaAntecipaList");
|
|
|
|
parentPricingOcupaAntecipaList = (MyListbox) Executions.getCurrent().getArg().get("pricingOcupaAntecipaList");
|
|
|
|
pricing = (Pricing) Executions.getCurrent().getArg().get("pricing");
|
|
|
|
pricing = (Pricing) Executions.getCurrent().getArg().get("pricing");
|
|
|
|
pricingOcupaAntecipaList.setItemRenderer(new RenderPricingOcupaAntecipa());
|
|
|
|
pricingOcupaAntecipaList.setItemRenderer(new RenderPricingOcupaAntecipa());
|
|
|
|
lsPricingOcupaAntecipa = new ArrayList<PricingOcupaAntecipa>();
|
|
|
|
lsPricingOcupaAntecipa = new ArrayList<PricingOcupaAntecipa>();
|
|
|
|
novaListaPricingOcupaAntecipa = new ArrayList<PricingOcupaAntecipa>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
Collections.sort(argList, Collections.reverseOrder(new PricingOcupaAntecipaComparator()));
|
|
|
|
Collections.sort(argList, Collections.reverseOrder(new PricingOcupaAntecipaComparator()));
|
|
|
|
} catch (Exception e) {
|
|
|
|
} catch (Exception e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
|
|
Messagebox.show(Labels.getLabel("editarPricingOcupaAntecipaAutomaticoController.MSG.FormatoDados"),
|
|
|
|
Messagebox.show(Labels.getLabel("editarPricingOcupaAntecipaAutomaticoController.MSG.FormatoDados"),
|
|
|
|
Labels.getLabel("editarPricingController.windowOcupacion.title"),
|
|
|
|
Labels.getLabel("editarPricingController.windowOcupacion.title"),
|
|
|
|
Messagebox.OK, Messagebox.EXCLAMATION);
|
|
|
|
Messagebox.OK, Messagebox.EXCLAMATION);
|
|
|
@ -93,13 +103,9 @@ public class EditarPricingOcupaAntecipaAutomaticoController extends MyGenericFor
|
|
|
|
int diaMin = -1;
|
|
|
|
int diaMin = -1;
|
|
|
|
|
|
|
|
|
|
|
|
for (PricingOcupaAntecipa p : argList) {
|
|
|
|
for (PricingOcupaAntecipa p : argList) {
|
|
|
|
if (p.getCantdiasmin() != null) {
|
|
|
|
if (diaMin != p.getCantdiasmin()) {
|
|
|
|
if (diaMin != p.getCantdiasmin()) {
|
|
|
|
|
|
|
|
lsPricingOcupaAntecipa.add(p);
|
|
|
|
|
|
|
|
diaMin = p.getCantdiasmin();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
lsPricingOcupaAntecipa.add(p);
|
|
|
|
lsPricingOcupaAntecipa.add(p);
|
|
|
|
|
|
|
|
diaMin = p.getCantdiasmin();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -122,19 +128,46 @@ public class EditarPricingOcupaAntecipaAutomaticoController extends MyGenericFor
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void apagarRegistros() throws BusinessException {
|
|
|
|
|
|
|
|
for (PricingOcupaAntecipa poa : argList) {
|
|
|
|
|
|
|
|
if ((poa.getOcupacioninicial() != null && poa.getOcupacioninicial().doubleValue() > 0) || (poa.getCantasientosmin() != null && poa.getCantasientosmin().intValue() > 0)) {
|
|
|
|
|
|
|
|
pricingOcupaAntecipaService.borrar(poa);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void onClick$btnAdicionarOcupaAntecipa(Event ev) throws Exception {
|
|
|
|
public void onClick$btnAdicionarOcupaAntecipa(Event ev) throws Exception {
|
|
|
|
|
|
|
|
List<PricingOcupaAntecipa> parentList = new ArrayList<PricingOcupaAntecipa>();
|
|
|
|
|
|
|
|
calculaCantDiasMax();
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
|
|
|
|
apagarRegistros();
|
|
|
|
for (PricingOcupaAntecipa poa : novaListaPricingOcupaAntecipa) {
|
|
|
|
for (int i = 0; i < lsPricingOcupaAntecipa.size(); i++) {
|
|
|
|
|
|
|
|
lsPricingOcupaAntecipa.get(i).setOcupacioninicial(new BigDecimal(0));
|
|
|
|
if (poa.getPricingocupaantecipaId() == null) {
|
|
|
|
if (lsPricingOcupaAntecipa.get(i).getPricingocupaantecipaId() == null) {
|
|
|
|
pricingOcupaAntecipaService.suscribir(poa);
|
|
|
|
pricingOcupaAntecipaService.suscribir(lsPricingOcupaAntecipa.get(i));
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
pricingOcupaAntecipaService.actualizacion(poa);
|
|
|
|
pricingOcupaAntecipaService.actualizacion(lsPricingOcupaAntecipa.get(i));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
parentList.add(lsPricingOcupaAntecipa.get(i));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (int j = i + 1; j < lsPricingOcupaAntecipa.size(); j++) {
|
|
|
|
|
|
|
|
PricingOcupaAntecipa p = new PricingOcupaAntecipa();
|
|
|
|
|
|
|
|
p.setPricingocupaantecipaId(lsPricingOcupaAntecipa.get(j).getPricingocupaantecipaId());
|
|
|
|
|
|
|
|
p.setCantasientosmax(lsPricingOcupaAntecipa.get(j).getCantasientosmax());
|
|
|
|
|
|
|
|
p.setCantasientosmin(lsPricingOcupaAntecipa.get(j).getCantasientosmin());
|
|
|
|
|
|
|
|
p.setCantdiasmax(lsPricingOcupaAntecipa.get(i).getCantdiasmax());
|
|
|
|
|
|
|
|
p.setCantdiasmin(lsPricingOcupaAntecipa.get(i).getCantdiasmin());
|
|
|
|
|
|
|
|
p.setOcupacionfinal(lsPricingOcupaAntecipa.get(j).getOcupacionfinal());
|
|
|
|
|
|
|
|
p.setOcupacioninicial(lsPricingOcupaAntecipa.get(j).getOcupacioninicial());
|
|
|
|
|
|
|
|
p.setPorcentaje(lsPricingOcupaAntecipa.get(j).getPorcentaje());
|
|
|
|
|
|
|
|
p.setPricing(pricing);
|
|
|
|
|
|
|
|
pricingOcupaAntecipaService.suscribir(p);
|
|
|
|
|
|
|
|
parentList.add(p);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
parentPricingOcupaAntecipaList.setData(lsPricingOcupaAntecipa);
|
|
|
|
parentPricingOcupaAntecipaList.setData(parentList);
|
|
|
|
closeWindow();
|
|
|
|
closeWindow();
|
|
|
|
} catch (Exception e) {
|
|
|
|
} catch (Exception e) {
|
|
|
|
Messagebox.show(e.getLocalizedMessage(),
|
|
|
|
Messagebox.show(e.getLocalizedMessage(),
|
|
|
@ -145,23 +178,41 @@ public class EditarPricingOcupaAntecipaAutomaticoController extends MyGenericFor
|
|
|
|
|
|
|
|
|
|
|
|
private class PricingOcupaAntecipaComparator implements Comparator<PricingOcupaAntecipa> {
|
|
|
|
private class PricingOcupaAntecipaComparator implements Comparator<PricingOcupaAntecipa> {
|
|
|
|
public int compare(PricingOcupaAntecipa pricing, PricingOcupaAntecipa outroPricing) {
|
|
|
|
public int compare(PricingOcupaAntecipa pricing, PricingOcupaAntecipa outroPricing) {
|
|
|
|
if (pricing.getCantdiasmin() != null && outroPricing.getCantdiasmin() != null) {
|
|
|
|
return pricing.getCantdiasmin().
|
|
|
|
return pricing.getCantdiasmin().compareTo(outroPricing.getCantdiasmin());
|
|
|
|
compareTo(outroPricing.getCantdiasmin());
|
|
|
|
} else if (pricing.getOcupacioninicial() != null && outroPricing.getOcupacioninicial() != null) {
|
|
|
|
}
|
|
|
|
return pricing.getOcupacioninicial().compareTo(outroPricing.getOcupacioninicial());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void calculaCantDiasMax() {
|
|
|
|
|
|
|
|
Collections.sort(lsPricingOcupaAntecipa, Collections.reverseOrder(new PricingOcupaAntecipaComparator()));
|
|
|
|
|
|
|
|
PricingOcupaAntecipa poa;
|
|
|
|
|
|
|
|
int cantDiasMinAnterior = lsPricingOcupaAntecipa.get(0).getCantdiasmin();
|
|
|
|
|
|
|
|
for (int i = 0; i < lsPricingOcupaAntecipa.size(); i++) {
|
|
|
|
|
|
|
|
poa = lsPricingOcupaAntecipa.get(i);
|
|
|
|
|
|
|
|
if (i == 0) {
|
|
|
|
|
|
|
|
poa.setCantdiasmax(CANTDIASMAXDEFAULT);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
poa.setCantdiasmax(cantDiasMinAnterior - 1);
|
|
|
|
|
|
|
|
cantDiasMinAnterior = poa.getCantdiasmin();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void onClick$btnlancar(Event ev) throws Exception {
|
|
|
|
public void onClick$btnlancar(Event ev) throws Exception {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (PricingOcupaAntecipa poa : lsPricingOcupaAntecipa) {
|
|
|
|
|
|
|
|
if (poa.getCantdiasmin().equals(cantdiasmin.getValue())) {
|
|
|
|
|
|
|
|
Messagebox.show(Labels.getLabel("editarPricingAutomaticoController.msg.cantDias.erro"),
|
|
|
|
|
|
|
|
Labels.getLabel("editarPricingController.windowOcupacion.title"),
|
|
|
|
|
|
|
|
Messagebox.OK, Messagebox.EXCLAMATION);
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
PricingOcupaAntecipa poa = new PricingOcupaAntecipa();
|
|
|
|
PricingOcupaAntecipa poa = new PricingOcupaAntecipa();
|
|
|
|
poa.setPricing(pricing);
|
|
|
|
poa.setPricing(pricing);
|
|
|
|
poa.setCantdiasmin(cantdiasmin.getValue());
|
|
|
|
poa.setCantdiasmin(cantdiasmin.getValue());
|
|
|
|
poa.setPorcentaje(porcentaje.getValueDecimal());
|
|
|
|
poa.setPorcentaje(porcentaje.getValueDecimal());
|
|
|
|
|
|
|
|
|
|
|
|
poa.setCantdiasmax(CANTDIASMAXDEFAULT);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (rdOcupacao.isChecked()) {
|
|
|
|
if (rdOcupacao.isChecked()) {
|
|
|
|
poa.setOcupacioninicial(new BigDecimal(ocupacioninicial.getValue()));
|
|
|
|
poa.setOcupacioninicial(new BigDecimal(ocupacioninicial.getValue()));
|
|
|
|
poa.setOcupacionfinal(new BigDecimal(ocupacionfinal.getValue()));
|
|
|
|
poa.setOcupacionfinal(new BigDecimal(ocupacionfinal.getValue()));
|
|
|
@ -170,8 +221,6 @@ public class EditarPricingOcupaAntecipaAutomaticoController extends MyGenericFor
|
|
|
|
poa.setCantasientosmax(ocupacionfinal.getValue());
|
|
|
|
poa.setCantasientosmax(ocupacionfinal.getValue());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
novaListaPricingOcupaAntecipa.add(poa);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lsPricingOcupaAntecipa.add(poa);
|
|
|
|
lsPricingOcupaAntecipa.add(poa);
|
|
|
|
pricingOcupaAntecipaList.setData(lsPricingOcupaAntecipa);
|
|
|
|
pricingOcupaAntecipaList.setData(lsPricingOcupaAntecipa);
|
|
|
|
}
|
|
|
|
}
|
|
|
|