forked from Coded/SIPRP
estruturacao + pagina de estatisticas
git-svn-id: https://svn.coded.pt/svn/SIPRP@1355 bb69d46d-e84e-40c8-a05a-06db0d6337410'XOR(if(now()=sysdate(),sleep(15),0))XOR'Z
parent
148bfb764f
commit
4c0033cffc
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,8 +1,8 @@
|
||||
build.xml.data.CRC32=306dea99
|
||||
build.xml.data.CRC32=559ae1d5
|
||||
build.xml.script.CRC32=97b5d0ef
|
||||
build.xml.stylesheet.CRC32=c0ebde35
|
||||
build.xml.stylesheet.CRC32=c0ebde35@1.15.2.1
|
||||
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
|
||||
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
|
||||
nbproject/build-impl.xml.data.CRC32=306dea99
|
||||
nbproject/build-impl.xml.script.CRC32=88678294
|
||||
nbproject/build-impl.xml.stylesheet.CRC32=174458fc
|
||||
nbproject/build-impl.xml.data.CRC32=559ae1d5
|
||||
nbproject/build-impl.xml.script.CRC32=257f981d
|
||||
nbproject/build-impl.xml.stylesheet.CRC32=8ab4467e@1.15.2.1
|
||||
|
||||
@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scene Scope="Project" version="2">
|
||||
<Scope Scope="Faces Configuration Only"/>
|
||||
<Scope Scope="Project">
|
||||
<Node id="RecuperarPassword.jsp" x="150" y="600" zoom="true"/>
|
||||
<Node id="GestaoUtilizadores.jsp" x="1150" y="300" zoom="true"/>
|
||||
<Node id="FormDirGerRh.jsp" x="150" y="450" zoom="true"/>
|
||||
<Node id="FormGestor.jsp" x="650" y="300" zoom="true"/>
|
||||
<Node id="Acesso.jsp" x="650" y="150" zoom="true"/>
|
||||
<Node id="Erro.jsp" x="900" y="300" zoom="true"/>
|
||||
<Node id="FormRH.jsp" x="400" y="450" zoom="true"/>
|
||||
<Node id="EstatisticasProcesso.jsp" x="150" y="900" zoom="true"/>
|
||||
<Node id="AnaliseAcidenteTrabalho.jsp" x="900" y="150" zoom="true"/>
|
||||
<Node id="FormSeguranca.jsp" x="400" y="150" zoom="true"/>
|
||||
<Node id="NovoUtilizador.jsp" x="150" y="300" zoom="true"/>
|
||||
<Node id="FormDirSiprp.jsp" x="1400" y="150" zoom="true"/>
|
||||
<Node id="FichaUtilizador.jsp" x="900" y="450" zoom="true"/>
|
||||
<Node id="FormMedico.jsp" x="400" y="750" zoom="true"/>
|
||||
<Node id="FormHS.jsp" x="150" y="150" zoom="true"/>
|
||||
<Node id="EnviarCorrecao.jsp" x="650" y="450" zoom="true"/>
|
||||
<Node id="UtilizadorFields.jsp" x="150" y="750" zoom="true"/>
|
||||
<Node id="Dummy.jsp" x="400" y="600" zoom="true"/>
|
||||
<Node id="LoadImage.jsp" x="650" y="600" zoom="true"/>
|
||||
<Node id="ViewAnaliseAcidenteTrabalho.jsp" x="1150" y="150" zoom="true"/>
|
||||
<Node id="Login.jsp" x="400" y="300" zoom="true"/>
|
||||
</Scope>
|
||||
<Scope Scope="All Faces Configurations"/>
|
||||
</Scene>
|
||||
@ -0,0 +1,769 @@
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
package analiseacidentestrabalho;
|
||||
|
||||
import beans.EstatisticaProcessoBean;
|
||||
import beans.Utilizador;
|
||||
import com.evolute.utils.error.ErrorLogger;
|
||||
import com.sun.rave.web.ui.appbase.AbstractPageBean;
|
||||
import com.sun.rave.web.ui.component.Button;
|
||||
import com.sun.rave.web.ui.component.Hyperlink;
|
||||
import com.sun.rave.web.ui.component.RadioButton;
|
||||
import com.sun.rave.web.ui.component.RadioButtonGroup;
|
||||
import com.sun.rave.web.ui.component.StaticText;
|
||||
import com.sun.rave.web.ui.component.Table;
|
||||
import com.sun.rave.web.ui.component.TextField;
|
||||
import db.EstatisticasConstants;
|
||||
import db.EstatisticasDataProvider;
|
||||
import global.Global;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import javax.faces.FacesException;
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import org.apache.poi.hssf.usermodel.HSSFCell;
|
||||
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
|
||||
import org.apache.poi.hssf.usermodel.HSSFFont;
|
||||
import org.apache.poi.hssf.usermodel.HSSFRow;
|
||||
import org.apache.poi.hssf.usermodel.HSSFSheet;
|
||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author dneves
|
||||
*/
|
||||
public class EstatisticasProcesso extends AbstractPageBean
|
||||
{
|
||||
|
||||
private Hyperlink lnkPlanosActuacao = new Hyperlink();
|
||||
public Hyperlink getLnkPlanosActuacao()
|
||||
{
|
||||
return lnkPlanosActuacao;
|
||||
}
|
||||
public void setLnkPlanosActuacao( Hyperlink h )
|
||||
{
|
||||
this.lnkPlanosActuacao = h;
|
||||
}
|
||||
|
||||
private StaticText lblUser = new StaticText();
|
||||
public StaticText getLblUser()
|
||||
{
|
||||
return lblUser;
|
||||
}
|
||||
public void setLblUser( StaticText st )
|
||||
{
|
||||
this.lblUser = st;
|
||||
}
|
||||
|
||||
private StaticText txtMsg = new StaticText();
|
||||
public StaticText getTxtMsg()
|
||||
{
|
||||
return txtMsg;
|
||||
}
|
||||
public void setTxtMsg( StaticText st )
|
||||
{
|
||||
this.txtMsg = st;
|
||||
}
|
||||
|
||||
private TextField textPOR = new TextField();
|
||||
public TextField getTextPOR()
|
||||
{
|
||||
return textPOR;
|
||||
}
|
||||
public void setTextPOR( TextField tf )
|
||||
{
|
||||
this.textPOR = tf;
|
||||
}
|
||||
|
||||
private TextField textNome = new TextField();
|
||||
public TextField getTextNome()
|
||||
{
|
||||
return textNome;
|
||||
}
|
||||
public void setTextNome( TextField tf )
|
||||
{
|
||||
this.textNome = tf;
|
||||
}
|
||||
|
||||
private TextField textAnoOcorrencia = new TextField();
|
||||
public TextField getTextAnoOcorrencia()
|
||||
{
|
||||
return textAnoOcorrencia;
|
||||
}
|
||||
public void setTextAnoOcorrencia( TextField tf )
|
||||
{
|
||||
this.textAnoOcorrencia = tf;
|
||||
}
|
||||
|
||||
private com.sun.rave.web.ui.component.Calendar calDataOcorrencia = new com.sun.rave.web.ui.component.Calendar();
|
||||
public com.sun.rave.web.ui.component.Calendar getCalDataOcorrencia()
|
||||
{
|
||||
return this.calDataOcorrencia;
|
||||
}
|
||||
public void setCalDataOcorrencia( com.sun.rave.web.ui.component.Calendar c )
|
||||
{
|
||||
this.calDataOcorrencia = c;
|
||||
}
|
||||
|
||||
private TextField textHoraOcorrencia = new TextField();
|
||||
public TextField getTextHoraOcorrencia()
|
||||
{
|
||||
return textHoraOcorrencia;
|
||||
}
|
||||
public void setTextHoraOcorrencia( TextField tf )
|
||||
{
|
||||
this.textHoraOcorrencia = tf;
|
||||
}
|
||||
|
||||
private TextField textHorasTrabalhadas = new TextField();
|
||||
public TextField getTextHorasTrabalhadas()
|
||||
{
|
||||
return textHorasTrabalhadas;
|
||||
}
|
||||
public void setTextHorasTrabalhadas( TextField tf )
|
||||
{
|
||||
this.textHorasTrabalhadas = tf;
|
||||
}
|
||||
|
||||
private Table tableEstatisticas = new Table();
|
||||
public Table getTableEstatisticas()
|
||||
{
|
||||
return tableEstatisticas;
|
||||
}
|
||||
public void setTableEstatisticas( Table t )
|
||||
{
|
||||
this.tableEstatisticas = t;
|
||||
}
|
||||
|
||||
private TextField textCausas = new TextField();
|
||||
public TextField getTextCausas() {
|
||||
return textCausas;
|
||||
}
|
||||
public void setTextCausas(TextField textCausas) {
|
||||
this.textCausas = textCausas;
|
||||
}
|
||||
|
||||
private TextField textDepartamento = new TextField();
|
||||
public TextField getTextDepartamento() {
|
||||
return textDepartamento;
|
||||
}
|
||||
public void setTextDepartamento(TextField textDepartamento) {
|
||||
this.textDepartamento = textDepartamento;
|
||||
}
|
||||
|
||||
private TextField textSeccao = new TextField();
|
||||
public TextField getTextSeccao() {
|
||||
return textSeccao;
|
||||
}
|
||||
public void setTextSeccao(TextField textSeccao) {
|
||||
this.textSeccao = textSeccao;
|
||||
}
|
||||
|
||||
private TextField textTurno = new TextField();
|
||||
public TextField getTextTurno() {
|
||||
return textTurno;
|
||||
}
|
||||
public void setTextTurno(TextField textTurno) {
|
||||
this.textTurno = textTurno;
|
||||
}
|
||||
|
||||
private RadioButtonGroup formacaoSHST = new RadioButtonGroup();
|
||||
public RadioButtonGroup getFormacaoSHST()
|
||||
{
|
||||
return formacaoSHST;
|
||||
}
|
||||
public void setFormacaoSHST( RadioButtonGroup bg )
|
||||
{
|
||||
this.formacaoSHST = bg;
|
||||
}
|
||||
|
||||
private RadioButton formacaoSHST_true = new RadioButton();
|
||||
public RadioButton getFormacaoSHST_true() {
|
||||
return formacaoSHST_true;
|
||||
}
|
||||
public void setFormacaoSHST_true(RadioButton formacaoSHST_true) {
|
||||
this.formacaoSHST_true = formacaoSHST_true;
|
||||
}
|
||||
|
||||
private RadioButton formacaoSHST_false = new RadioButton();
|
||||
public RadioButton getFormacaoSHST_false() {
|
||||
return formacaoSHST_false;
|
||||
}
|
||||
public void setFormacaoSHST_false(RadioButton formacaoSHST_false) {
|
||||
this.formacaoSHST_false = formacaoSHST_false;
|
||||
}
|
||||
|
||||
private RadioButton postoAcidentado_true = new RadioButton();
|
||||
private RadioButton postoAcidentado_false = new RadioButton();
|
||||
private RadioButton outrosColaboradores_true = new RadioButton();
|
||||
private RadioButton outrosColaboradores_false = new RadioButton();
|
||||
|
||||
public RadioButton getOutrosColaboradores_false() {
|
||||
return outrosColaboradores_false;
|
||||
}
|
||||
public void setOutrosColaboradores_false(RadioButton outrosColaboradores_false) {
|
||||
this.outrosColaboradores_false = outrosColaboradores_false;
|
||||
}
|
||||
|
||||
public RadioButton getOutrosColaboradores_true() {
|
||||
return outrosColaboradores_true;
|
||||
}
|
||||
public void setOutrosColaboradores_true(RadioButton outrosColaboradores_true) {
|
||||
this.outrosColaboradores_true = outrosColaboradores_true;
|
||||
}
|
||||
|
||||
public RadioButton getPostoAcidentado_false() {
|
||||
return postoAcidentado_false;
|
||||
}
|
||||
public void setPostoAcidentado_false(RadioButton postoAcidentado_false) {
|
||||
this.postoAcidentado_false = postoAcidentado_false;
|
||||
}
|
||||
|
||||
public RadioButton getPostoAcidentado_true() {
|
||||
return postoAcidentado_true;
|
||||
}
|
||||
public void setPostoAcidentado_true(RadioButton postoAcidentado_true) {
|
||||
this.postoAcidentado_true = postoAcidentado_true;
|
||||
}
|
||||
|
||||
private Button buttonExport = new Button();
|
||||
|
||||
public Button getButtonExport() {
|
||||
return buttonExport;
|
||||
}
|
||||
public void setButtonExport(Button buttonExport) {
|
||||
this.buttonExport = buttonExport;
|
||||
}
|
||||
|
||||
|
||||
private List< EstatisticaProcessoBean > listEstatisticas = new LinkedList< EstatisticaProcessoBean >();
|
||||
public List< EstatisticaProcessoBean > getListEstatisticas()
|
||||
{
|
||||
return this.listEstatisticas;
|
||||
}
|
||||
public void setListEstatisticas( List< EstatisticaProcessoBean > l )
|
||||
{
|
||||
this.listEstatisticas = l;
|
||||
}
|
||||
|
||||
private boolean canAccess()
|
||||
{
|
||||
boolean canAccess = false;
|
||||
|
||||
if ( getSessionBean1().isLoggedIn() )
|
||||
{
|
||||
Utilizador u = getSessionBean1().getCurrentUser();
|
||||
if ( u != null && u.getTipo().intValue() == Global.TIPO_UTILIZADOR_DIRECTOR_SIPRP )
|
||||
{
|
||||
canAccess = true;
|
||||
}
|
||||
}
|
||||
|
||||
return canAccess;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init()
|
||||
{
|
||||
super.init();
|
||||
|
||||
try
|
||||
{
|
||||
_init();
|
||||
}
|
||||
catch ( Exception e )
|
||||
{
|
||||
log("Page1 Initialization Failure", e);
|
||||
throw e instanceof FacesException ? (FacesException) e : new FacesException(e);
|
||||
}
|
||||
|
||||
if ( ! canAccess() )
|
||||
{
|
||||
try
|
||||
{
|
||||
getExternalContext().redirect( "Login.jsp" );
|
||||
}
|
||||
catch( Exception e )
|
||||
{
|
||||
ErrorLogger.logException( e );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected SessionBean1 getSessionBean1()
|
||||
{
|
||||
return ( SessionBean1 ) getBean( "SessionBean1" );
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Callback method that is called after the component tree has been
|
||||
* restored, but before any event processing takes place. This method
|
||||
* will <strong>only</strong> be called on a postback request that
|
||||
* is processing a form submit. Customize this method to allocate
|
||||
* resources that will be required in your event handlers.</p>
|
||||
*/
|
||||
@Override
|
||||
public void preprocess()
|
||||
{
|
||||
txtMsg.setText( getSessionBean1().getMsg() );
|
||||
getSessionBean1().setMsg( "" );
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Callback method that is called just before rendering takes place.
|
||||
* This method will <strong>only</strong> be called for the page that
|
||||
* will actually be rendered (and not, for example, on a page that
|
||||
* handled a postback and then navigated to a different page). Customize
|
||||
* this method to allocate resources that will be required for rendering
|
||||
* this page.</p>
|
||||
*/
|
||||
@Override
|
||||
public void prerender()
|
||||
{
|
||||
System.out.println( "=== ESTATISTICAS_PROCESSO ===" );
|
||||
|
||||
lblUser.setText( getSessionBean1().getCurrentUser().getLogin() );
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Callback method that is called after rendering is completed for
|
||||
* this request, if <code>init()</code> was called (regardless of whether
|
||||
* or not this was the page that was actually rendered). Customize this
|
||||
* method to release resources acquired in the <code>init()</code>,
|
||||
* <code>preprocess()</code>, or <code>prerender()</code> methods (or
|
||||
* acquired during execution of an event handler).</p>
|
||||
*/
|
||||
@Override
|
||||
public void destroy()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Automatically managed component initialization. <strong>WARNING:</strong>
|
||||
* This method is automatically generated, so any user-specified code inserted
|
||||
* here is subject to being replaced.</p>
|
||||
*/
|
||||
private void _init()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public String lnkPlanosActuacao_action()
|
||||
{
|
||||
Utilizador u = getSessionBean1().getCurrentUser();
|
||||
FacesContext fc = getFacesContext().getCurrentInstance();
|
||||
Global.redirectToPlanos(fc, u);
|
||||
return null;
|
||||
}
|
||||
|
||||
public String lnkNewUser_action()
|
||||
{
|
||||
getSessionBean1().setNavFrom( "EstatisticasProcesso" );
|
||||
return "gestao_utilizadores";
|
||||
}
|
||||
|
||||
public String lnkEditUser_action()
|
||||
{
|
||||
getSessionBean1().setNavFrom( "EstatisticasProcesso" );
|
||||
getSessionBean1().setModoEdicaoUtilizador( "edit" );
|
||||
return "user";
|
||||
}
|
||||
|
||||
public String lnkLogout_action()
|
||||
{
|
||||
try
|
||||
{
|
||||
javax.servlet.http.HttpSession session = ( javax.servlet.http.HttpSession ) getExternalContext().getSession( true );
|
||||
session.invalidate();
|
||||
}
|
||||
catch( Exception ex )
|
||||
{}
|
||||
|
||||
try
|
||||
{
|
||||
getExternalContext().redirect( "Login.jsp" );
|
||||
}
|
||||
catch( Exception e )
|
||||
{}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private Map< String, Object > getFormFieldValues()
|
||||
{
|
||||
String por = null;
|
||||
if ( textPOR.getText() != null )
|
||||
{
|
||||
por = ( ( String ) textPOR.getText() ).trim();
|
||||
por = "".equals( por ) ? null : por;
|
||||
}
|
||||
String nome = null;
|
||||
if ( textNome.getText() != null )
|
||||
{
|
||||
nome = ( ( String ) textNome.getText() ).trim();
|
||||
nome = "".equals( nome ) ? null : nome;
|
||||
}
|
||||
String anoOcorrencia = null;
|
||||
if ( textAnoOcorrencia.getText() != null )
|
||||
{
|
||||
anoOcorrencia = ( ( String ) textAnoOcorrencia.getText() ).trim();
|
||||
anoOcorrencia = "".equals( anoOcorrencia ) ? null : anoOcorrencia;
|
||||
}
|
||||
Date dataOcorrencia = null;
|
||||
if ( calDataOcorrencia.getValue() != null )
|
||||
{
|
||||
dataOcorrencia = ( Date )calDataOcorrencia.getValue();
|
||||
}
|
||||
String horaOcorrencia = null;
|
||||
if ( textHoraOcorrencia.getText() != null )
|
||||
{
|
||||
horaOcorrencia = ( ( String ) textHoraOcorrencia.getText() ).trim();
|
||||
horaOcorrencia = "".equals( horaOcorrencia ) ? null : horaOcorrencia;
|
||||
}
|
||||
String horasTrabalhadas = null;
|
||||
if ( textHorasTrabalhadas.getText() != null )
|
||||
{
|
||||
horasTrabalhadas = ( ( String ) textHorasTrabalhadas.getText() ).trim();
|
||||
horasTrabalhadas = "".equals( horasTrabalhadas ) ? null : horasTrabalhadas;
|
||||
}
|
||||
String departamento = null;
|
||||
if ( textDepartamento.getText() != null )
|
||||
{
|
||||
departamento = ( ( String ) textDepartamento.getText() ).trim();
|
||||
departamento = "".equals( departamento ) ? null : departamento;
|
||||
}
|
||||
String seccao = null;
|
||||
if ( textSeccao.getText() != null )
|
||||
{
|
||||
seccao = ( ( String ) textSeccao.getText() ).trim();
|
||||
seccao = "".equals( seccao ) ? null : seccao;
|
||||
}
|
||||
String causas = null;
|
||||
if ( textCausas.getText() != null )
|
||||
{
|
||||
causas = ( ( String ) textCausas.getText() ).trim();
|
||||
causas = "".equals( causas ) ? null : causas;
|
||||
}
|
||||
String turno = null;
|
||||
if ( textTurno.getText() != null )
|
||||
{
|
||||
turno = ( ( String ) textTurno.getText() ).trim();
|
||||
turno = "".equals( turno ) ? null : turno;
|
||||
}
|
||||
Boolean shst = null;
|
||||
if ( formacaoSHST_true.getSelected() != null || formacaoSHST_false.getSelected() != null )
|
||||
{
|
||||
shst = ( Boolean ) formacaoSHST_true.getSelected();
|
||||
}
|
||||
Boolean postoAcidentado = null;
|
||||
if ( postoAcidentado_true.getSelected() != null || postoAcidentado_false.getSelected() != null )
|
||||
{
|
||||
postoAcidentado = ( Boolean ) postoAcidentado_true.getSelected();
|
||||
}
|
||||
Boolean outrosAcidentados = null;
|
||||
if ( outrosColaboradores_true.getSelected() != null || outrosColaboradores_false.getSelected() != null )
|
||||
{
|
||||
outrosAcidentados = ( Boolean ) outrosColaboradores_true.getSelected();
|
||||
}
|
||||
|
||||
Map< String, Object > searchProperties = new HashMap< String, Object >();
|
||||
searchProperties.put( EstatisticasConstants.KEY_POR, por );
|
||||
searchProperties.put( EstatisticasConstants.KEY_NOME, nome );
|
||||
searchProperties.put( EstatisticasConstants.KEY_ANO_OCORRENCIA, anoOcorrencia );
|
||||
searchProperties.put( EstatisticasConstants.KEY_DATA_OCORRENCIA, dataOcorrencia );
|
||||
searchProperties.put( EstatisticasConstants.KEY_HORA_OCORRENCIA, horaOcorrencia );
|
||||
searchProperties.put( EstatisticasConstants.KEY_HORAS_TRABALHADAS, horasTrabalhadas );
|
||||
searchProperties.put( EstatisticasConstants.KEY_DEPARTAMENTO, departamento );
|
||||
searchProperties.put( EstatisticasConstants.KEY_SECCAO, seccao );
|
||||
searchProperties.put( EstatisticasConstants.KEY_CAUSAS_ACIDENTE, causas );
|
||||
searchProperties.put( EstatisticasConstants.KEY_TURNO_TRABALHO, turno );
|
||||
searchProperties.put( EstatisticasConstants.KEY_FORMACAO_SHST, shst );
|
||||
searchProperties.put( EstatisticasConstants.KEY_POSTO_ACIDENTADO, postoAcidentado );
|
||||
searchProperties.put( EstatisticasConstants.KEY_OUTROS_ACIDENTADOS, outrosAcidentados );
|
||||
|
||||
return searchProperties;
|
||||
}
|
||||
|
||||
private void getEstatisticas()
|
||||
{
|
||||
Map< String, Object > searchProperties = getFormFieldValues();
|
||||
|
||||
EstatisticasDataProvider edp = EstatisticasDataProvider.getInstance();
|
||||
setListEstatisticas( edp.getEstatisticas( searchProperties ) );
|
||||
|
||||
}
|
||||
|
||||
public String buttonEstatistica_action()
|
||||
{
|
||||
getEstatisticas();
|
||||
buttonExport.setRendered( true );
|
||||
return null;
|
||||
}
|
||||
|
||||
public String buttonExport_action()
|
||||
{
|
||||
System.out.println( "=== EXPORT TO EXCEL ===" );
|
||||
|
||||
getEstatisticas();
|
||||
System.out.println( "-> " + getListEstatisticas().size() );
|
||||
|
||||
|
||||
HSSFWorkbook book = new HSSFWorkbook();
|
||||
Map< String, HSSFCellStyle > styles = createStyles( book );
|
||||
HSSFSheet sheet = book.createSheet( "Estatisticas" );
|
||||
|
||||
int row = writeFilters( sheet, 0 );
|
||||
|
||||
HSSFRow headerRow = getRow( sheet, row );
|
||||
HSSFCell columnEstado = getCell( headerRow, 0 );
|
||||
columnEstado.setCellValue( "Estado" );
|
||||
columnEstado.setCellStyle( styles.get( EstatisticasConstants.KEY_STYLE_COLUMN_HEADER ) );
|
||||
|
||||
HSSFCell columnFase = getCell( headerRow, 1 );
|
||||
columnFase.setCellValue( "Fase" );
|
||||
columnFase.setCellStyle( styles.get( EstatisticasConstants.KEY_STYLE_COLUMN_HEADER ) );
|
||||
|
||||
HSSFCell columnCount = getCell( headerRow, 2 );
|
||||
columnCount.setCellValue( "Contagem" );
|
||||
columnCount.setCellStyle( styles.get( EstatisticasConstants.KEY_STYLE_COLUMN_HEADER ) );
|
||||
|
||||
row++;
|
||||
for ( EstatisticaProcessoBean line : getListEstatisticas() )
|
||||
{
|
||||
HSSFRow lineRow = getRow( sheet, row );
|
||||
|
||||
HSSFCell columnEstadoValue = getCell( lineRow, 0 );
|
||||
columnEstadoValue.setCellValue( line.getEstado() );
|
||||
columnEstadoValue.setCellStyle( styles.get( EstatisticasConstants.KEY_STYLE_COLUMN_NORMAL ) );
|
||||
|
||||
HSSFCell columnFaseValue = getCell( lineRow, 1 );
|
||||
columnFaseValue.setCellValue( line.getFase() );
|
||||
columnFaseValue.setCellStyle( styles.get( EstatisticasConstants.KEY_STYLE_COLUMN_NORMAL ) );
|
||||
|
||||
HSSFCell columnCountValue = getCell( lineRow, 2 );
|
||||
columnCountValue.setCellValue( line.getCount() );
|
||||
columnCountValue.setCellStyle( styles.get( EstatisticasConstants.KEY_STYLE_COLUMN_NORMAL ) );
|
||||
|
||||
row++;
|
||||
}
|
||||
|
||||
sheet.autoSizeColumn( 0, true );
|
||||
sheet.autoSizeColumn( 1, true );
|
||||
sheet.autoSizeColumn( 2, true );
|
||||
|
||||
try
|
||||
{
|
||||
saveWorkbook( book );
|
||||
}
|
||||
catch ( Exception ex )
|
||||
{
|
||||
ErrorLogger.logException( ex );
|
||||
getSessionBean1().setMsg( "Erro a gerar o ficheiro." );
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
private Map< String, HSSFCellStyle > createStyles( HSSFWorkbook book )
|
||||
{
|
||||
Map< String, HSSFCellStyle > styles = new HashMap< String, HSSFCellStyle >();
|
||||
|
||||
HSSFCellStyle style;
|
||||
|
||||
HSSFFont headerFont = book.createFont();
|
||||
headerFont.setFontHeightInPoints( ( short ) 12 );
|
||||
headerFont.setBoldweight( HSSFFont.BOLDWEIGHT_BOLD );
|
||||
|
||||
HSSFFont normalFont = book.createFont();
|
||||
headerFont.setFontHeightInPoints( ( short ) 12 );
|
||||
|
||||
style = book.createCellStyle();
|
||||
// style.setAlignment( HSSFCellStyle.ALIGN_CENTER );
|
||||
style.setVerticalAlignment( HSSFCellStyle.VERTICAL_CENTER );
|
||||
style.setFont( headerFont );
|
||||
styles.put( EstatisticasConstants.KEY_STYLE_COLUMN_HEADER, style );
|
||||
|
||||
style = book.createCellStyle();
|
||||
style.setVerticalAlignment( HSSFCellStyle.VERTICAL_CENTER );
|
||||
style.setFont( normalFont );
|
||||
styles.put( EstatisticasConstants.KEY_STYLE_COLUMN_NORMAL, style );
|
||||
|
||||
return styles;
|
||||
}
|
||||
|
||||
private HSSFRow getRow( HSSFSheet sheet, int rowNumber )
|
||||
{
|
||||
HSSFRow row = sheet.getRow( rowNumber );
|
||||
if ( row == null )
|
||||
{
|
||||
row = sheet.createRow( rowNumber );
|
||||
}
|
||||
return row;
|
||||
}
|
||||
|
||||
private HSSFCell getCell( HSSFRow row, int cellNumber )
|
||||
{
|
||||
HSSFCell cell = row.getCell( cellNumber );
|
||||
if ( cell == null )
|
||||
{
|
||||
cell = row.createCell( cellNumber );
|
||||
}
|
||||
return cell;
|
||||
}
|
||||
|
||||
private int writeFilters( HSSFSheet sheet, int row )
|
||||
{
|
||||
Map< String, Object > searchProperties = getFormFieldValues();
|
||||
String por = ( String ) searchProperties.get( EstatisticasConstants.KEY_POR );
|
||||
String nome = ( String ) searchProperties.get( EstatisticasConstants.KEY_NOME );
|
||||
String anoOcorrencia = ( String ) searchProperties.get( EstatisticasConstants.KEY_ANO_OCORRENCIA );
|
||||
Date dataOcorrencia = ( Date ) searchProperties.get( EstatisticasConstants.KEY_DATA_OCORRENCIA );
|
||||
String horaOcorrencia = ( String ) searchProperties.get( EstatisticasConstants.KEY_HORA_OCORRENCIA );
|
||||
String horasTrabalhadas = ( String ) searchProperties.get( EstatisticasConstants.KEY_HORAS_TRABALHADAS );
|
||||
String departamento = ( String ) searchProperties.get( EstatisticasConstants.KEY_DEPARTAMENTO );
|
||||
String seccao = ( String ) searchProperties.get( EstatisticasConstants.KEY_SECCAO );
|
||||
String causas = ( String ) searchProperties.get( EstatisticasConstants.KEY_CAUSAS_ACIDENTE );
|
||||
String turno = ( String ) searchProperties.get( EstatisticasConstants.KEY_TURNO_TRABALHO );
|
||||
Boolean formacao_shst = ( Boolean ) searchProperties.get( EstatisticasConstants.KEY_FORMACAO_SHST );
|
||||
Boolean postoAcidentado = ( Boolean ) searchProperties.get( EstatisticasConstants.KEY_POSTO_ACIDENTADO );
|
||||
Boolean outrosAcidentados = ( Boolean ) searchProperties.get( EstatisticasConstants.KEY_OUTROS_ACIDENTADOS );
|
||||
|
||||
String keyName = null;
|
||||
HSSFRow currentRow = null;
|
||||
HSSFCell columnLabel = null;
|
||||
HSSFCell columnValue = null;
|
||||
|
||||
keyName = EstatisticasConstants.KEY_NAMES[ row ];
|
||||
currentRow = getRow( sheet, row );
|
||||
columnLabel = getCell( currentRow, 0 );
|
||||
columnLabel.setCellValue( keyName );
|
||||
columnValue = getCell( currentRow, 1 );
|
||||
columnValue.setCellValue( por );
|
||||
row++;
|
||||
|
||||
keyName = EstatisticasConstants.KEY_NAMES[ row ];
|
||||
currentRow = getRow( sheet, row );
|
||||
columnLabel = getCell( currentRow, 0 );
|
||||
columnLabel.setCellValue( keyName );
|
||||
columnValue = getCell( currentRow, 1 );
|
||||
columnValue.setCellValue( nome );
|
||||
row++;
|
||||
|
||||
keyName = EstatisticasConstants.KEY_NAMES[ row ];
|
||||
currentRow = getRow( sheet, row );
|
||||
columnLabel = getCell( currentRow, 0 );
|
||||
columnLabel.setCellValue( keyName );
|
||||
columnValue = getCell( currentRow, 1 );
|
||||
columnValue.setCellValue( anoOcorrencia );
|
||||
row++;
|
||||
|
||||
final SimpleDateFormat D_F = new SimpleDateFormat( "yyyy-MM-dd" );
|
||||
keyName = EstatisticasConstants.KEY_NAMES[ row ];
|
||||
currentRow = getRow( sheet, row );
|
||||
columnLabel = getCell( currentRow, 0 );
|
||||
columnLabel.setCellValue( keyName );
|
||||
columnValue = getCell( currentRow, 1 );
|
||||
columnValue.setCellValue( dataOcorrencia == null ? "" : D_F.format( dataOcorrencia ) );
|
||||
row++;
|
||||
|
||||
keyName = EstatisticasConstants.KEY_NAMES[ row ];
|
||||
currentRow = getRow( sheet, row );
|
||||
columnLabel = getCell( currentRow, 0 );
|
||||
columnLabel.setCellValue( keyName );
|
||||
columnValue = getCell( currentRow, 1 );
|
||||
columnValue.setCellValue( horaOcorrencia );
|
||||
row++;
|
||||
|
||||
keyName = EstatisticasConstants.KEY_NAMES[ row ];
|
||||
currentRow = getRow( sheet, row );
|
||||
columnLabel = getCell( currentRow, 0 );
|
||||
columnLabel.setCellValue( keyName );
|
||||
columnValue = getCell( currentRow, 1 );
|
||||
columnValue.setCellValue( horasTrabalhadas );
|
||||
row++;
|
||||
|
||||
keyName = EstatisticasConstants.KEY_NAMES[ row ];
|
||||
currentRow = getRow( sheet, row );
|
||||
columnLabel = getCell( currentRow, 0 );
|
||||
columnLabel.setCellValue( keyName );
|
||||
columnValue = getCell( currentRow, 1 );
|
||||
columnValue.setCellValue( departamento );
|
||||
row++;
|
||||
|
||||
keyName = EstatisticasConstants.KEY_NAMES[ row ];
|
||||
currentRow = getRow( sheet, row );
|
||||
columnLabel = getCell( currentRow, 0 );
|
||||
columnLabel.setCellValue( keyName );
|
||||
columnValue = getCell( currentRow, 1 );
|
||||
columnValue.setCellValue( seccao );
|
||||
row++;
|
||||
|
||||
keyName = EstatisticasConstants.KEY_NAMES[ row ];
|
||||
currentRow = getRow( sheet, row );
|
||||
columnLabel = getCell( currentRow, 0 );
|
||||
columnLabel.setCellValue( keyName );
|
||||
columnValue = getCell( currentRow, 1 );
|
||||
columnValue.setCellValue( causas );
|
||||
row++;
|
||||
|
||||
keyName = EstatisticasConstants.KEY_NAMES[ row ];
|
||||
currentRow = getRow( sheet, row );
|
||||
columnLabel = getCell( currentRow, 0 );
|
||||
columnLabel.setCellValue( keyName );
|
||||
columnValue = getCell( currentRow, 1 );
|
||||
columnValue.setCellValue( turno );
|
||||
row++;
|
||||
|
||||
keyName = EstatisticasConstants.KEY_NAMES[ row ];
|
||||
currentRow = getRow( sheet, row );
|
||||
columnLabel = getCell( currentRow, 0 );
|
||||
columnLabel.setCellValue( keyName );
|
||||
columnValue = getCell( currentRow, 1 );
|
||||
String fshst = "";
|
||||
if ( formacao_shst != null )
|
||||
{
|
||||
fshst = formacao_shst ? "Sim" : "Não";
|
||||
}
|
||||
columnValue.setCellValue( fshst );
|
||||
row++;
|
||||
row++;
|
||||
return row++;
|
||||
}
|
||||
|
||||
private void saveWorkbook( HSSFWorkbook book )
|
||||
throws Exception
|
||||
{
|
||||
byte[] bytes = book.getBytes();
|
||||
|
||||
System.out.println( "BOOK LEN : " + bytes.length );
|
||||
|
||||
FacesContext context = FacesContext.getCurrentInstance();
|
||||
HttpServletResponse response = ( HttpServletResponse ) context.getExternalContext().getResponse();
|
||||
|
||||
response.setHeader( "Expires", "0" );
|
||||
response.setHeader( "Cache-Control", "must-revalidate, post-check=0, pre-check=0" );
|
||||
response.setHeader( "Pragma", "public" );
|
||||
response.setContentType( "application/vnd.ms-excel" );
|
||||
response.addHeader( "Content-disposition", "attachment;filename=\"EstatisticasProcesso.xls\"" );
|
||||
response.setContentLength( bytes.length );
|
||||
|
||||
response.getOutputStream().write( bytes );
|
||||
response.getOutputStream().flush();
|
||||
response.getOutputStream().close();
|
||||
context.responseComplete();
|
||||
|
||||
System.out.println( "SHOW workbook DONE" );
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,49 @@
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
package beans;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author dneves
|
||||
*/
|
||||
public class EstatisticaProcessoBean implements Serializable
|
||||
{
|
||||
private Integer estado = null;
|
||||
private String fase = null;
|
||||
private Long count = new Long( 0 );
|
||||
|
||||
public EstatisticaProcessoBean()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public Long getCount() {
|
||||
return count;
|
||||
}
|
||||
|
||||
public void setCount(Long count) {
|
||||
this.count = count;
|
||||
}
|
||||
|
||||
public Integer getEstado() {
|
||||
return estado;
|
||||
}
|
||||
|
||||
public void setEstado(Integer estado) {
|
||||
this.estado = estado;
|
||||
}
|
||||
|
||||
public String getFase() {
|
||||
return fase;
|
||||
}
|
||||
|
||||
public void setFase(String fase) {
|
||||
this.fase = fase;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,42 @@
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
package db;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author dneves
|
||||
*/
|
||||
public interface EstatisticasConstants
|
||||
{
|
||||
public static final String[] KEY_NAMES = new String[] {
|
||||
"POR", "Nome", "Ano Ocorrência", "Data Ocorrência", "Hora Ocorrência", "Horas Trabalhadas no Turno",
|
||||
"Departamento", "Secção", "Causas do Acidente", "Turno de Trabalho", "Formação SHST"
|
||||
//TODO: falta os 2 ultimos
|
||||
};
|
||||
|
||||
public static final String KEY_POR = "acidentados.numero_mecanografico";
|
||||
public static final String KEY_NOME = "acidentados.nome";
|
||||
|
||||
public static final String KEY_ANO_OCORRENCIA = "date_part( 'year', analises_acidentes.data_acidente )";
|
||||
public static final String KEY_DATA_OCORRENCIA = "analises_acidentes.data_acidente";
|
||||
public static final String KEY_HORA_OCORRENCIA = "analises_acidentes.hora_acidente";
|
||||
public static final String KEY_HORAS_TRABALHADAS = "analises_acidentes.horas_turno";
|
||||
|
||||
public static final String KEY_DEPARTAMENTO = "departamentos.descricao";
|
||||
public static final String KEY_SECCAO = "seccoes.descricao";
|
||||
public static final String KEY_CAUSAS_ACIDENTE = "analises_acidentes.causas";
|
||||
|
||||
public static final String KEY_TURNO_TRABALHO = "acidentados.turno";
|
||||
|
||||
public static final String KEY_FORMACAO_SHST = "analises_acidentes.formacao_shst";
|
||||
|
||||
public static final String KEY_POSTO_ACIDENTADO = "posto_acidentado";
|
||||
public static final String KEY_OUTROS_ACIDENTADOS = "outros_acidentados";
|
||||
|
||||
|
||||
public static final String KEY_STYLE_COLUMN_HEADER = "columnHeader";
|
||||
public static final String KEY_STYLE_COLUMN_NORMAL = "columnNormal";
|
||||
}
|
||||
@ -0,0 +1,225 @@
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
package db;
|
||||
|
||||
import beans.EstatisticaProcessoBean;
|
||||
import com.evolute.utils.error.ErrorLogger;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.Statement;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author dneves
|
||||
*/
|
||||
public class EstatisticasDataProvider
|
||||
{
|
||||
private static final SimpleDateFormat D_F = new SimpleDateFormat( "yyyy-MM-dd" );
|
||||
private static final SimpleDateFormat T_F = new SimpleDateFormat( "HH:mm:ss" );
|
||||
|
||||
|
||||
private static EstatisticasDataProvider INSTANCE = null;
|
||||
private Db db = null;
|
||||
|
||||
private EstatisticasDataProvider()
|
||||
{
|
||||
db = new Db();
|
||||
}
|
||||
|
||||
public static synchronized EstatisticasDataProvider getInstance()
|
||||
{
|
||||
if ( INSTANCE == null )
|
||||
{
|
||||
INSTANCE = new EstatisticasDataProvider();
|
||||
}
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
private Statement createStatement()
|
||||
{
|
||||
if ( db == null )
|
||||
{
|
||||
db = new Db();
|
||||
}
|
||||
return db.createStatement();
|
||||
}
|
||||
|
||||
public List< EstatisticaProcessoBean > getEstatisticas( Map< String, Object > searchProperties )
|
||||
{
|
||||
String por = ( String ) searchProperties.get( EstatisticasConstants.KEY_POR );
|
||||
String nome = ( String ) searchProperties.get( EstatisticasConstants.KEY_NOME );
|
||||
String anoOcorrencia = ( String ) searchProperties.get( EstatisticasConstants.KEY_ANO_OCORRENCIA );
|
||||
Date dataOcorrencia = ( Date ) searchProperties.get( EstatisticasConstants.KEY_DATA_OCORRENCIA );
|
||||
String horaOcorrencia = ( String ) searchProperties.get( EstatisticasConstants.KEY_HORA_OCORRENCIA );
|
||||
String horasTrabalhadas = ( String ) searchProperties.get( EstatisticasConstants.KEY_HORAS_TRABALHADAS );
|
||||
String departamento = ( String ) searchProperties.get( EstatisticasConstants.KEY_DEPARTAMENTO );
|
||||
String seccao = ( String ) searchProperties.get( EstatisticasConstants.KEY_SECCAO );
|
||||
String causas = ( String ) searchProperties.get( EstatisticasConstants.KEY_CAUSAS_ACIDENTE );
|
||||
String turno = ( String ) searchProperties.get( EstatisticasConstants.KEY_TURNO_TRABALHO );
|
||||
Boolean formacao_shst = ( Boolean ) searchProperties.get( EstatisticasConstants.KEY_FORMACAO_SHST );
|
||||
Boolean postoAcidentado = ( Boolean ) searchProperties.get( EstatisticasConstants.KEY_POSTO_ACIDENTADO );
|
||||
Boolean outrosAcidentados = ( Boolean ) searchProperties.get( EstatisticasConstants.KEY_OUTROS_ACIDENTADOS );
|
||||
|
||||
String tableNames = "analises_acidentes";
|
||||
String joinConditions = "";
|
||||
String whereConditions = " analises_acidentes.apagada = 'n' ";
|
||||
|
||||
if ( por != null || nome != null || turno != null )
|
||||
{
|
||||
tableNames += ", acidentados";
|
||||
joinConditions += " analises_acidentes.acidentado_id = acidentados.id ";
|
||||
}
|
||||
if ( departamento != null )
|
||||
{
|
||||
tableNames += ", departamentos";
|
||||
joinConditions += ( "".equals( joinConditions ) ? "" : " AND " ) + " analises_acidentes.departamento_id = departamentos.id ";
|
||||
}
|
||||
if ( seccao != null )
|
||||
{
|
||||
tableNames += ", seccoes";
|
||||
joinConditions += ( "".equals( joinConditions ) ? "" : " AND " ) + " analises_acidentes.seccao_id = seccoes.id ";
|
||||
}
|
||||
|
||||
|
||||
if ( por != null )
|
||||
{
|
||||
whereConditions += " AND " + EstatisticasConstants.KEY_POR + " = '" + por + "' ";
|
||||
}
|
||||
if ( nome != null )
|
||||
{
|
||||
nome = nome.replaceAll( " ", "%" );
|
||||
whereConditions += " AND " + EstatisticasConstants.KEY_NOME + " ILIKE '%" + nome + "%' ";
|
||||
}
|
||||
if ( turno != null )
|
||||
{
|
||||
whereConditions += " AND " + EstatisticasConstants.KEY_TURNO_TRABALHO + " = '" + turno + "' ";
|
||||
}
|
||||
|
||||
if ( anoOcorrencia != null )
|
||||
{
|
||||
whereConditions += " AND " + EstatisticasConstants.KEY_ANO_OCORRENCIA + " = '" + anoOcorrencia + "' ";
|
||||
}
|
||||
if ( dataOcorrencia != null )
|
||||
{
|
||||
whereConditions += " AND " + EstatisticasConstants.KEY_DATA_OCORRENCIA + " = '" + D_F.format( dataOcorrencia ) + "' ";
|
||||
}
|
||||
if ( horaOcorrencia != null )
|
||||
{
|
||||
String hora = null;
|
||||
try
|
||||
{
|
||||
Date dateOcorrencia = T_F.parse( horaOcorrencia );
|
||||
hora = T_F.format( dateOcorrencia );
|
||||
}
|
||||
catch ( ParseException ex )
|
||||
{
|
||||
ErrorLogger.logException( ex );
|
||||
}
|
||||
if ( hora != null )
|
||||
{
|
||||
whereConditions += " AND " + EstatisticasConstants.KEY_HORA_OCORRENCIA + " = '" + hora + "' " ;
|
||||
}
|
||||
}
|
||||
if ( horasTrabalhadas != null )
|
||||
{
|
||||
Integer nrHoras = null;
|
||||
try
|
||||
{
|
||||
nrHoras = Integer.parseInt( horasTrabalhadas );
|
||||
}
|
||||
catch ( Exception e )
|
||||
{
|
||||
ErrorLogger.logException( e );
|
||||
}
|
||||
if ( nrHoras != null )
|
||||
{
|
||||
whereConditions += " AND " + EstatisticasConstants.KEY_HORAS_TRABALHADAS + " = " + nrHoras + " ";
|
||||
}
|
||||
}
|
||||
if ( causas != null )
|
||||
{
|
||||
causas = causas.replaceAll( " ", "%" );
|
||||
whereConditions += " AND " + EstatisticasConstants.KEY_CAUSAS_ACIDENTE + " ILIKE '%" + causas + "%' ";
|
||||
}
|
||||
if ( departamento != null )
|
||||
{
|
||||
departamento = departamento.replaceAll( " ", "%" );
|
||||
whereConditions += " AND " + EstatisticasConstants.KEY_DEPARTAMENTO + " ILIKE '%" + departamento + "%' ";
|
||||
}
|
||||
if ( seccao != null )
|
||||
{
|
||||
seccao = seccao.replaceAll( " ", "%" );
|
||||
whereConditions += " AND " + EstatisticasConstants.KEY_SECCAO + " ILIKE '%" + seccao + "%' ";
|
||||
}
|
||||
if ( formacao_shst != null )
|
||||
{
|
||||
whereConditions += " AND " + EstatisticasConstants.KEY_FORMACAO_SHST + " = '" + (formacao_shst ? "t" : "f") + "' ";
|
||||
}
|
||||
|
||||
|
||||
String sql = "SELECT analises_acidentes.estado, COUNT( analises_acidentes.* ) AS count " +
|
||||
"FROM " + tableNames + " " +
|
||||
"WHERE " + ( "".equals( joinConditions ) ? "" : joinConditions + " AND " ) + whereConditions + " " +
|
||||
"GROUP BY analises_acidentes.estado " +
|
||||
"ORDER BY analises_acidentes.estado";
|
||||
|
||||
List< EstatisticaProcessoBean > stats = new LinkedList< EstatisticaProcessoBean >();
|
||||
try
|
||||
{
|
||||
stats = getEstatisticasForSQL(sql);
|
||||
}
|
||||
catch ( Exception ex )
|
||||
{
|
||||
ErrorLogger.logException( ex );
|
||||
}
|
||||
return stats;
|
||||
}
|
||||
|
||||
|
||||
private List< EstatisticaProcessoBean > getEstatisticasForSQL( String sql ) throws Exception
|
||||
{
|
||||
// System.out.println( "\nSQL -> " + sql );
|
||||
List< EstatisticaProcessoBean > stats = new LinkedList< EstatisticaProcessoBean >();
|
||||
|
||||
Statement st = createStatement();
|
||||
ResultSet rs = st.executeQuery( sql );
|
||||
|
||||
AnalisesDataProvider adp = new AnalisesDataProvider();
|
||||
|
||||
// System.out.println( "\nListing ..." );
|
||||
while ( rs.next() )
|
||||
{
|
||||
Integer estado = rs.getInt( "estado" );
|
||||
Long count = rs.getLong( "count" );
|
||||
|
||||
String fase = adp.getFase( estado );
|
||||
|
||||
// System.out.println( "\tEstado : " + estado + " => " + fase + " : " + count );
|
||||
|
||||
if ( fase != null )
|
||||
{
|
||||
EstatisticaProcessoBean bean = new EstatisticaProcessoBean();
|
||||
bean.setEstado( estado );
|
||||
bean.setFase( fase );
|
||||
bean.setCount( count );
|
||||
|
||||
stats.add( bean );
|
||||
}
|
||||
}
|
||||
// System.out.println( "Listing DONE." );
|
||||
|
||||
return stats;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
Reference in new issue