frederico 2017-03-13 20:21:04 +00:00
parent 038e831c03
commit ddb04eacc7
6 changed files with 122 additions and 40 deletions

View File

@ -9,6 +9,7 @@ import java.util.Calendar;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
@ -45,21 +46,85 @@ public class RelatorioMovimentosAtraso extends Relatorio {
public void initDados() throws Exception {
Connection conexao = this.relatorio.getConexao();
definirFiltros(this.relatorio.getParametros());
List<MovimentosAtrasoVO> lsDadosRelatorio = processarRelatorio(conexao);
Boolean tipoRelatorio = (Boolean) relatorio.getParametros().get("eTipoConferencia");
List<MovimentosAtrasoVO> lsDadosRelatorio = processarRelatorio(conexao, tipoRelatorio);
setLsDadosRelatorio(lsDadosRelatorio);
}
});
}
private List<MovimentosAtrasoVO> processarRelatorio(Connection conexao) throws ParseException {
private List<MovimentosAtrasoVO> processarRelatorio(Connection conexao, Boolean eTipoConferencia) throws ParseException {
carregarDiasComMovimentos(conexao);
List<MovimentosAtrasoVO> lsDadosRelatorio = iniciarDados(conexao);
processarDiasConferidos(conexao, lsDadosRelatorio);
List<MovimentosAtrasoVO> lsDadosRelatorio = iniciarDados(conexao, eTipoConferencia);
if (eTipoConferencia) {
processarConfenciasNaoFinalizada(conexao, lsDadosRelatorio);
} else {
processarDiasConferidos(conexao, lsDadosRelatorio);
}
removerMovimentosSemAtraso(lsDadosRelatorio);
Collections.sort(lsDadosRelatorio);
return lsDadosRelatorio;
}
private void processarConfenciasNaoFinalizada(Connection conexao, List<MovimentosAtrasoVO> lsDadosRelatorio) {
ResultSet rset = null;
NamedParameterStatement stmt = null;
try {
StringBuilder sQuery = new StringBuilder();
sQuery.append("SELECT DISTINCT CO.DATAMOVIMENTO ")
.append("FROM CONFERENCIA CO ")
.append("JOIN PUNTO_VENTA PV ON PV.PUNTOVENTA_ID = CO.PUNTOVENTA_ID ")
.append("WHERE CO.ACTIVO = 1 ")
.append("AND CO.DATAMOVIMENTO BETWEEN :dataInicial AND :dataFinal ")
.append("AND CO.INDMALOTERECEBIDO = 1 ")
.append("AND CO.INDCONFERIDO = 0 ")
.append("AND CO.EMPRESA_ID = :empresaId ")
.append("AND CO.PUNTOVENTA_ID = :puntoventaId ")
.append("ORDER BY CO.DATAMOVIMENTO");
for(MovimentosAtrasoVO movimento : lsDadosRelatorio){
movimento.setDiasEmAtraso(new HashSet<Integer>());
log.info(sQuery.toString());
stmt = new NamedParameterStatement(conexao, sQuery.toString());
stmt.setInt("empresaId", empresaId);
stmt.setInt("puntoventaId", movimento.getPuntoventaId());
stmt.setDate("dataInicial", new java.sql.Date(dataInicial.getTime()));
stmt.setDate("dataFinal", new java.sql.Date(dataFinal.getTime()));
rset = stmt.executeQuery();
while (rset.next()) {
Date data = DateUtil.normalizar(rset.getDate("DATAMOVIMENTO"));
Calendar cal = Calendar.getInstance();
cal.setTime(data);
int day = cal.get(Calendar.DAY_OF_MONTH);
movimento.getDiasEmAtraso().add(day);
}
}
} catch (Exception e) {
log.error(e.getMessage(), e);
} finally {
try {
if(rset != null) {
rset.close();
}
if(stmt != null) {
stmt.close();
}
} catch (SQLException e) {
log.error(e.getMessage(), e);
}
}
}
private void removerMovimentosSemAtraso(List<MovimentosAtrasoVO> lsDadosRelatorio) {
List<MovimentosAtrasoVO> lsMovimentosSemAtraso = new ArrayList<MovimentosAtrasoVO>();
for (MovimentosAtrasoVO movimentosAtraso : lsDadosRelatorio) {
@ -200,7 +265,7 @@ public class RelatorioMovimentosAtraso extends Relatorio {
}
}
private List<MovimentosAtrasoVO> iniciarDados(Connection conexao) {
private List<MovimentosAtrasoVO> iniciarDados(Connection conexao, Boolean eTipoConferencia) {
ResultSet rset = null;
NamedParameterStatement stmt = null;
try {
@ -252,7 +317,7 @@ public class RelatorioMovimentosAtraso extends Relatorio {
movimentosAtraso.setUf(rset.getString("UF"));
movimentosAtraso.setNumtelefonouno(rset.getString("NUMTELEFONOUNO"));
carregarDiasMovimento(movimentosAtraso);
if(!movimentosAtraso.getDiasEmAtraso().isEmpty()) {
if(!movimentosAtraso.getDiasEmAtraso().isEmpty() || eTipoConferencia) {
lsMovimentosAtrasoVOs.add(movimentosAtraso);
}
}
@ -279,6 +344,7 @@ public class RelatorioMovimentosAtraso extends Relatorio {
movimentosAtrasoBase.setDiasEmAtraso(new TreeSet<Integer>());
Set<Integer> diasCompetencia = DateUtil.carregarDiasCompetencia(movimentosAtrasoBase.getCompetencia(), null);
Date dataAtual = DateUtil.normalizar(new Date());
Integer diasEmTransito = movimentosAtrasoBase.getDiasemtransito() != null ? movimentosAtrasoBase.getDiasemtransito() : 0;
diasEmTransito += movimentosAtrasoBase.getIntervalofechamento() != null ? movimentosAtrasoBase.getIntervalofechamento() : 0;
for (Integer dia : diasCompetencia) {
@ -293,7 +359,6 @@ public class RelatorioMovimentosAtraso extends Relatorio {
} else {
movimentosAtrasoBase.getDiasEmAtraso().clear();
}
}
public void setLsDadosRelatorio(List<MovimentosAtrasoVO> lsDadosRelatorio) {

View File

@ -22,3 +22,4 @@ label.uf=UF
label.subordinante=Subordinante
label.periodicidade=Periodicidade
label.diasEmAtraso=Dias Em Atraso
label.diasMaloteEntregue=Dias malote entregue não finalizados

View File

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="RelatorioMovimentosAtraso" pageWidth="842" pageHeight="595" orientation="Landscape" whenNoDataType="NoDataSection" columnWidth="822" leftMargin="10" rightMargin="10" topMargin="20" bottomMargin="20" uuid="84b9dfcf-8ec5-4f51-80cc-7339e3b158b4">
<property name="ireport.zoom" value="0.75"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="0"/>
<property name="ireport.zoom" value="1.607691607500001"/>
<property name="ireport.x" value="661"/>
<property name="ireport.y" value="32"/>
<style name="Crosstab Data Text" hAlign="Center"/>
<parameter name="empresa" class="java.lang.String"/>
<parameter name="noDataRelatorio" class="java.lang.String"/>
@ -17,6 +17,7 @@
<parameter name="competencia" class="java.lang.String"/>
<parameter name="puntoventa" class="java.lang.String"/>
<parameter name="statusFiltro" class="java.lang.String"/>
<parameter name="eTipoConferencia" class="java.lang.Boolean"/>
<queryString>
<![CDATA[]]>
</queryString>
@ -33,42 +34,42 @@
<title>
<band height="102" splitType="Stretch">
<textField>
<reportElement x="0" y="0" width="637" height="20" uuid="43b2c28d-4760-4890-b00d-25e931e79c74"/>
<reportElement uuid="43b2c28d-4760-4890-b00d-25e931e79c74" x="0" y="0" width="637" height="20"/>
<textElement markup="none">
<font size="14" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$R{cabecalho.nome}]]></textFieldExpression>
</textField>
<textField pattern="dd/MM/yyyy HH:mm">
<reportElement x="637" y="0" width="164" height="20" uuid="4d1bcd65-c9a6-44b4-8dca-cc3c4c20c9a5"/>
<reportElement uuid="4d1bcd65-c9a6-44b4-8dca-cc3c4c20c9a5" x="637" y="0" width="164" height="20"/>
<textElement textAlignment="Right">
<font isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[new java.util.Date()]]></textFieldExpression>
</textField>
<textField isBlankWhenNull="true">
<reportElement x="0" y="60" width="637" height="20" uuid="a16eb33b-78ca-4fb4-80c2-f5c85a0d09c3"/>
<reportElement uuid="a16eb33b-78ca-4fb4-80c2-f5c85a0d09c3" x="0" y="60" width="637" height="20"/>
<textElement>
<font size="6" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$R{cabecalho.puntoventa} + " " + $P{puntoventa}]]></textFieldExpression>
</textField>
<textField isBlankWhenNull="true">
<reportElement x="0" y="80" width="801" height="20" uuid="979b7126-0e47-4885-8a07-d8f9aa75a204"/>
<reportElement uuid="979b7126-0e47-4885-8a07-d8f9aa75a204" x="0" y="80" width="801" height="20"/>
<textElement>
<font size="6" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$R{cabecalho.usuario} + " " + $P{usuario}]]></textFieldExpression>
</textField>
<textField isBlankWhenNull="true">
<reportElement x="0" y="40" width="637" height="20" uuid="90cdfa43-be94-4edc-b974-e267d2c5e82a"/>
<reportElement uuid="90cdfa43-be94-4edc-b974-e267d2c5e82a" x="0" y="40" width="637" height="20"/>
<textElement>
<font size="6" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$R{cabecalho.empresa} + " " + $P{empresa}]]></textFieldExpression>
</textField>
<textField isBlankWhenNull="true">
<reportElement x="0" y="20" width="637" height="20" uuid="f75c1624-725f-4ed7-9db7-7d396221d505"/>
<reportElement uuid="f75c1624-725f-4ed7-9db7-7d396221d505" x="0" y="20" width="637" height="20"/>
<textElement>
<font size="6" isBold="true"/>
</textElement>
@ -79,10 +80,10 @@
<pageHeader>
<band height="21" splitType="Stretch">
<line>
<reportElement x="0" y="19" width="822" height="1" uuid="4f39b5b4-849a-4fe2-9365-06930866fbaa"/>
<reportElement uuid="4f39b5b4-849a-4fe2-9365-06930866fbaa" x="0" y="19" width="822" height="1"/>
</line>
<textField>
<reportElement x="637" y="0" width="164" height="20" uuid="6a8a0843-7236-40a3-98ae-5fbf59b4cfec"/>
<reportElement uuid="6a8a0843-7236-40a3-98ae-5fbf59b4cfec" x="637" y="0" width="164" height="20"/>
<textElement textAlignment="Right">
<font isBold="true"/>
</textElement>
@ -93,52 +94,55 @@
<columnHeader>
<band height="23" splitType="Stretch">
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement stretchType="RelativeToTallestObject" x="82" y="0" width="151" height="20" uuid="3f75c9b2-2080-4269-aadc-c7b914f07203"/>
<reportElement uuid="3f75c9b2-2080-4269-aadc-c7b914f07203" stretchType="RelativeToTallestObject" x="82" y="0" width="151" height="20"/>
<textElement>
<font size="6" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$R{label.puntoventa}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement stretchType="RelativeToTallestObject" x="233" y="0" width="105" height="20" uuid="0b6d3444-aed1-4928-8f1a-d4b48b269ec7"/>
<reportElement uuid="0b6d3444-aed1-4928-8f1a-d4b48b269ec7" stretchType="RelativeToTallestObject" x="233" y="0" width="105" height="20"/>
<textElement>
<font size="6" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$R{label.telefone}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement stretchType="RelativeToTallestObject" x="338" y="0" width="42" height="20" uuid="8b479f1f-b6d6-4b33-a8f4-d72551fa3def"/>
<reportElement uuid="8b479f1f-b6d6-4b33-a8f4-d72551fa3def" stretchType="RelativeToTallestObject" x="338" y="0" width="42" height="20"/>
<textElement>
<font size="6" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$R{label.uf}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement stretchType="RelativeToTallestObject" x="380" y="0" width="200" height="20" uuid="b2bbb907-984f-409e-9e36-c9f8e45361b6"/>
<reportElement uuid="b2bbb907-984f-409e-9e36-c9f8e45361b6" stretchType="RelativeToTallestObject" x="380" y="0" width="200" height="20"/>
<textElement>
<font size="6" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$R{label.subordinante}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement stretchType="RelativeToTallestObject" x="580" y="0" width="82" height="20" uuid="e0e1ce89-2e4d-4b99-bbc0-542bb917f3d7"/>
<reportElement uuid="e0e1ce89-2e4d-4b99-bbc0-542bb917f3d7" stretchType="RelativeToTallestObject" x="580" y="0" width="82" height="20"/>
<textElement>
<font size="6" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$R{label.periodicidade}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement stretchType="RelativeToTallestObject" x="662" y="0" width="160" height="20" uuid="8c5a026b-3efc-4830-994b-158fd657c748"/>
<reportElement uuid="8c5a026b-3efc-4830-994b-158fd657c748" stretchType="RelativeToTallestObject" x="662" y="0" width="160" height="20"/>
<textElement>
<font size="6" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$R{label.diasEmAtraso}]]></textFieldExpression>
<textFieldExpression><![CDATA[$P{eTipoConferencia} ?
$R{label.diasMaloteEntregue} :
$R{label.diasEmAtraso}
]]></textFieldExpression>
</textField>
<line>
<reportElement positionType="Float" x="0" y="21" width="822" height="1" uuid="6b6886e4-712a-4e4d-adff-5a705e28555d"/>
<reportElement uuid="6b6886e4-712a-4e4d-adff-5a705e28555d" positionType="Float" x="0" y="21" width="822" height="1"/>
</line>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement stretchType="RelativeToTallestObject" x="0" y="0" width="82" height="20" uuid="34f306b0-fcd2-421c-84b8-8b863c4ee958"/>
<reportElement uuid="34f306b0-fcd2-421c-84b8-8b863c4ee958" stretchType="RelativeToTallestObject" x="0" y="0" width="82" height="20"/>
<textElement>
<font size="6" isBold="true"/>
</textElement>
@ -149,49 +153,49 @@
<detail>
<band height="25">
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement stretchType="RelativeToTallestObject" x="662" y="0" width="160" height="20" uuid="dc1ce697-5085-42fb-aa3f-15dc7368cd50"/>
<reportElement uuid="dc1ce697-5085-42fb-aa3f-15dc7368cd50" stretchType="RelativeToTallestObject" x="662" y="0" width="160" height="20"/>
<textElement>
<font size="6"/>
</textElement>
<textFieldExpression><![CDATA[$F{strDiasEmAtraso}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement stretchType="RelativeToTallestObject" x="580" y="0" width="82" height="20" uuid="c479c5c1-f2f1-4c10-b812-19b8f371a912"/>
<reportElement uuid="c479c5c1-f2f1-4c10-b812-19b8f371a912" stretchType="RelativeToTallestObject" x="580" y="0" width="82" height="20"/>
<textElement>
<font size="6"/>
</textElement>
<textFieldExpression><![CDATA[$F{desIntervalofechamento}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement stretchType="RelativeToTallestObject" x="380" y="0" width="200" height="20" uuid="b1576f5b-e86a-4713-81ad-9d394c34fa7e"/>
<reportElement uuid="b1576f5b-e86a-4713-81ad-9d394c34fa7e" stretchType="RelativeToTallestObject" x="380" y="0" width="200" height="20"/>
<textElement>
<font size="6"/>
</textElement>
<textFieldExpression><![CDATA[$F{nombpuntoventaPadre}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement stretchType="RelativeToTallestObject" x="338" y="0" width="42" height="20" uuid="10823e45-0be5-4ac1-9948-a3428923d075"/>
<reportElement uuid="10823e45-0be5-4ac1-9948-a3428923d075" stretchType="RelativeToTallestObject" x="338" y="0" width="42" height="20"/>
<textElement>
<font size="6"/>
</textElement>
<textFieldExpression><![CDATA[$F{uf}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement stretchType="RelativeToTallestObject" x="233" y="0" width="105" height="20" uuid="673869d3-710d-4bbd-8545-9b2d70a18541"/>
<reportElement uuid="673869d3-710d-4bbd-8545-9b2d70a18541" stretchType="RelativeToTallestObject" x="233" y="0" width="105" height="20"/>
<textElement>
<font size="6"/>
</textElement>
<textFieldExpression><![CDATA[$F{numtelefonouno}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement stretchType="RelativeToTallestObject" x="0" y="0" width="82" height="20" uuid="426ff840-8693-4d88-8372-00797accab08"/>
<reportElement uuid="426ff840-8693-4d88-8372-00797accab08" stretchType="RelativeToTallestObject" x="0" y="0" width="82" height="20"/>
<textElement>
<font size="6"/>
</textElement>
<textFieldExpression><![CDATA[$F{numPuntoVenta}]]></textFieldExpression>
</textField>
<textField isStretchWithOverflow="true" isBlankWhenNull="true">
<reportElement stretchType="RelativeToTallestObject" x="82" y="0" width="151" height="20" uuid="f0fd7c82-9814-48bb-a6cd-a078eea4672c"/>
<reportElement uuid="f0fd7c82-9814-48bb-a6cd-a078eea4672c" stretchType="RelativeToTallestObject" x="82" y="0" width="151" height="20"/>
<textElement>
<font size="6"/>
</textElement>
@ -205,7 +209,7 @@
<noData>
<band height="35">
<textField isBlankWhenNull="true">
<reportElement positionType="Float" x="0" y="0" width="555" height="20" isPrintWhenDetailOverflows="true" uuid="d7df66c6-4dc0-4f3b-88f4-b22094d29091"/>
<reportElement uuid="d7df66c6-4dc0-4f3b-88f4-b22094d29091" positionType="Float" x="0" y="0" width="555" height="20" isPrintWhenDetailOverflows="true"/>
<textElement verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$R{msg.noData}]]></textFieldExpression>
</textField>

View File

@ -13,6 +13,7 @@ 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.Radio;
import org.zkoss.zul.Textbox;
import com.rjconsultores.ventaboletos.entidad.Empresa;
@ -39,6 +40,8 @@ public class RelatorioMovimentosAtrasoController extends MyGenericForwardCompose
private PuntoVenta puntoVenta;
private Empresa empresa;
private Radio rdbTipoConferencia;
@Override
public void doAfterCompose(Component comp) throws Exception {
super.doAfterCompose(comp);
@ -54,6 +57,7 @@ public class RelatorioMovimentosAtrasoController extends MyGenericForwardCompose
parametros.put("empresa", empresa.getNombempresa());
parametros.put("usuario", UsuarioLogado.getUsuarioLogado().getNombusuario());
parametros.put("status", SituacaoDiaMovimento.ATRASADO);
parametros.put("eTipoConferencia", rdbTipoConferencia.isChecked());
if(puntoVenta != null) {
parametros.put("puntoventaId", puntoVenta.getPuntoventaId());

View File

@ -9,7 +9,7 @@
title="${c:l('relatorioMovimentosAtrasoController.window.title')}"
apply="${relatorioMovimentosAtrasoController}"
contentStyle="overflow:auto"
height="185px"
height="215px"
width="450px"
border="normal" >
<toolbar>
@ -22,10 +22,18 @@
<grid fixedLayout="true">
<columns>
<column width="30%" />
<column width="70%" />
<column width="20%" />
<column width="80%" />
</columns>
<rows>
<row>
<label value="${c:l('relatorioMovimentosAtrasoController.radioTipo.label')}" />
<radiogroup id="rdgTipoRelatorio">
<radio id="rdbTipoMoviemnto" label="${c:l('relatorioMovimentosAtrasoController.radioTipo.tipoMovimentosEmAtraso')}" selected="true"/>
<radio id="rdbTipoConferencia" label="${c:l('relatorioMovimentosAtrasoController.radioTipo.tipoConferenciaEmAtraso')}"/>
</radiogroup>
</row>
<row>
<label value="${c:l('relatorioMovimentosAtrasoController.lbCompetencia.label')}"/>
<hbox>