estatisticas corrigidas

git-svn-id: https://svn.coded.pt/svn/SIPRP@1602 bb69d46d-e84e-40c8-a05a-06db0d633741
lxbfYeaa
Diogo Neves 15 years ago
parent 43be0755ab
commit 4792130249

@ -6,24 +6,24 @@
<Node id="GestaoUtilizadores.jsp" x="400" y="450" zoom="true"/> <Node id="GestaoUtilizadores.jsp" x="400" y="450" zoom="true"/>
<Node id="FormDirGerRh.jsp" x="150" y="750" zoom="true"/> <Node id="FormDirGerRh.jsp" x="150" y="750" zoom="true"/>
<Node id="FormGestor.jsp" x="400" y="300" zoom="true"/> <Node id="FormGestor.jsp" x="400" y="300" zoom="true"/>
<Node id="Acesso.jsp" x="400" y="750" zoom="false"/>
<Node id="Erro.jsp" x="650" y="450" zoom="true"/> <Node id="Erro.jsp" x="650" y="450" zoom="true"/>
<Node id="Acesso.jsp" x="400" y="750" zoom="false"/>
<Node id="FormRH.jsp" x="400" y="600" zoom="true"/> <Node id="FormRH.jsp" x="400" y="600" zoom="true"/>
<Node id="EstatisticasProcesso.jsp" x="150" y="900" zoom="true"/> <Node id="EstatisticasProcesso.jsp" x="150" y="900" zoom="true"/>
<Node id="AnaliseAcidenteTrabalho.jsp" x="150" y="450" zoom="true"/>
<Node id="FormSeguranca.jsp" x="1150" y="150" zoom="true"/> <Node id="FormSeguranca.jsp" x="1150" y="150" zoom="true"/>
<Node id="AnaliseAcidenteTrabalho.jsp" x="150" y="450" zoom="true"/>
<Node id="NovoUtilizador.jsp" x="900" y="150" zoom="true"/> <Node id="NovoUtilizador.jsp" x="900" y="150" zoom="true"/>
<Node id="FormDirSiprp.jsp" x="1400" y="150" zoom="true"/> <Node id="FormDirSiprp.jsp" x="1400" y="150" zoom="true"/>
<Node id="FichaUtilizador.jsp" x="150" y="300" zoom="true"/> <Node id="FichaUtilizador.jsp" x="150" y="300" zoom="true"/>
<Node id="FormHS.jsp" x="900" y="300" zoom="true"/>
<Node id="FormMedico.jsp" x="900" y="450" zoom="true"/> <Node id="FormMedico.jsp" x="900" y="450" zoom="true"/>
<Node id="FormHS.jsp" x="900" y="300" zoom="true"/>
<Node id="EnviarCorrecao.jsp" x="150" y="150" zoom="true"/> <Node id="EnviarCorrecao.jsp" x="150" y="150" zoom="true"/>
<Node id="UtilizadorFields.jsp" x="1150" y="300" zoom="true"/> <Node id="UtilizadorFields.jsp" x="1150" y="300" zoom="true"/>
<Node id="ConfirmarDesactivar.jsp" x="1650" y="150" zoom="true"/> <Node id="ConfirmarDesactivar.jsp" x="1650" y="150" zoom="true"/>
<Node id="Dummy.jsp" x="150" y="600" zoom="true"/> <Node id="Dummy.jsp" x="150" y="600" zoom="true"/>
<Node id="LoadImage.jsp" x="650" y="600" zoom="true"/> <Node id="LoadImage.jsp" x="650" y="600" zoom="true"/>
<Node id="ViewAnaliseAcidenteTrabalho.jsp" x="650" y="150" zoom="true"/>
<Node id="Login.jsp" x="650" y="300" zoom="true"/> <Node id="Login.jsp" x="650" y="300" zoom="true"/>
<Node id="ViewAnaliseAcidenteTrabalho.jsp" x="650" y="150" zoom="true"/>
</Scope> </Scope>
<Scope Scope="All Faces Configurations"/> <Scope Scope="All Faces Configurations"/>
</Scene> </Scene>

@ -13754,33 +13754,27 @@ public class AnaliseAcidenteTrabalho extends AbstractPageBean {
return null; return null;
} }
public String lnkAnalisesAcidente_action() { public String lnkAnalisesAcidente_action()
// TODO: Replace with your code {
// savePageState(); getSessionBean1().setIeBug( true );
// getSessionBean1().setNavFrom("AnaliseAcidenteTrabalho"); ServletContext theApplicationsServletContext = ( ServletContext ) this.getExternalContext().getContext();
// getSessionBean1().setModoEdicaoUtilizador("edit");
// return "user";
getSessionBean1().setIeBug(true);
ServletContext theApplicationsServletContext =
(ServletContext) this.getExternalContext().getContext();
// String imageFileFolderTmp = theApplicationsServletContext.getRealPath(Global.IMAGE_FOLDER + "/tmp" + getSessionBean1().getCurrentUser().getLogin());
String imageFileFolderTmp = Global.IMAGE_FOLDER + "/tmp" + getSessionBean1().getCurrentUser().getLogin(); String imageFileFolderTmp = Global.IMAGE_FOLDER + "/tmp" + getSessionBean1().getCurrentUser().getLogin();
File ftmp = new File(imageFileFolderTmp); File ftmp = new File(imageFileFolderTmp);
if( ftmp.exists() ) if( ftmp.exists() )
{ {
File files[] = ftmp.listFiles(); File files[] = ftmp.listFiles();
for( int i = 0; i < files.length; i++ )
for(int i=0;i<files.length;i++)
{ {
if(files[i].isFile()) if ( files[ i ].isFile() )
{ {
files[i].delete(); files[ i ].delete();
} }
} }
ftmp.delete(); ftmp.delete();
} }
String navFrom = getSessionBean1().getNavFrom(); String navFrom = getSessionBean1().getNavFrom();
if(navFrom.matches("FormSeguranca")) if(navFrom.matches("FormSeguranca"))
{ {

@ -19,6 +19,7 @@ import com.sun.rave.web.ui.component.Table;
import com.sun.rave.web.ui.component.TextField; import com.sun.rave.web.ui.component.TextField;
import com.sun.rave.web.ui.model.Option; import com.sun.rave.web.ui.model.Option;
import db.EstatisticasConstants; import db.EstatisticasConstants;
import db.data.siprp.outer.SeccoesData;
import db.providers.EstatisticasDataProvider; import db.providers.EstatisticasDataProvider;
import global.Global; import global.Global;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
@ -55,6 +56,17 @@ public class EstatisticasProcesso extends AbstractPageBean
this.lnkPlanosActuacao = h; this.lnkPlanosActuacao = h;
} }
private Hyperlink lnkAnaliseAcidentes = new Hyperlink();
public Hyperlink getLnkAnaliseAcidentes()
{
return lnkAnaliseAcidentes;
}
public void setLnkAnaliseAcidentes( Hyperlink lnkAnaliseAcidentes )
{
this.lnkAnaliseAcidentes = lnkAnaliseAcidentes;
}
private StaticText lblUser = new StaticText(); private StaticText lblUser = new StaticText();
public StaticText getLblUser() public StaticText getLblUser()
{ {
@ -155,24 +167,14 @@ public class EstatisticasProcesso extends AbstractPageBean
this.dropCausas = dropCausas; this.dropCausas = dropCausas;
} }
// private TextField textDepartamento = new TextField();
// public TextField getTextDepartamento() {
// private TextField textCausas = new TextField(); // return textDepartamento;
// public TextField getTextCausas() {
// return textCausas;
// } // }
// public void setTextCausas(TextField textCausas) { // public void setTextDepartamento(TextField textDepartamento) {
// this.textCausas = textCausas; // this.textDepartamento = textDepartamento;
// } // }
private TextField textDepartamento = new TextField();
public TextField getTextDepartamento() {
return textDepartamento;
}
public void setTextDepartamento(TextField textDepartamento) {
this.textDepartamento = textDepartamento;
}
private DropDown dropSeccoes = new DropDown(); private DropDown dropSeccoes = new DropDown();
public DropDown getDropSeccoes() { public DropDown getDropSeccoes() {
@ -183,15 +185,6 @@ public class EstatisticasProcesso extends AbstractPageBean
this.dropSeccoes = dropSeccoes; this.dropSeccoes = dropSeccoes;
} }
// private TextField textSeccao = new TextField();
// public TextField getTextSeccao() {
// return textSeccao;
// }
// public void setTextSeccao(TextField textSeccao) {
// this.textSeccao = textSeccao;
// }
private DropDown dropTurno = new DropDown(); private DropDown dropTurno = new DropDown();
public DropDown getDropTurno() { public DropDown getDropTurno() {
@ -201,14 +194,6 @@ public class EstatisticasProcesso extends AbstractPageBean
public void setDropTurno(DropDown dropTurno) { public void setDropTurno(DropDown dropTurno) {
this.dropTurno = dropTurno; this.dropTurno = dropTurno;
} }
// private TextField textTurno = new TextField();
// public TextField getTextTurno() {
// return textTurno;
// }
// public void setTextTurno(TextField textTurno) {
// this.textTurno = textTurno;
// }
private RadioButtonGroup formacaoSHST = new RadioButtonGroup(); private RadioButtonGroup formacaoSHST = new RadioButtonGroup();
public RadioButtonGroup getFormacaoSHST() public RadioButtonGroup getFormacaoSHST()
@ -236,6 +221,18 @@ public class EstatisticasProcesso extends AbstractPageBean
this.formacaoSHST_false = formacaoSHST_false; this.formacaoSHST_false = formacaoSHST_false;
} }
private RadioButton formacaoSHST_none = new RadioButton();
public RadioButton getFormacaoSHST_none()
{
return formacaoSHST_none;
}
public void setFormacaoSHST_none( RadioButton formacaoSHST_none )
{
this.formacaoSHST_none = formacaoSHST_none;
}
private RadioButton postoAcidentado_true = new RadioButton(); private RadioButton postoAcidentado_true = new RadioButton();
private RadioButton postoAcidentado_false = new RadioButton(); private RadioButton postoAcidentado_false = new RadioButton();
private RadioButton outrosColaboradores_true = new RadioButton(); private RadioButton outrosColaboradores_true = new RadioButton();
@ -322,6 +319,8 @@ public class EstatisticasProcesso extends AbstractPageBean
ErrorLogger.logException( e ); ErrorLogger.logException( e );
} }
} }
formacaoSHST_none.setSelected( true );
} }
protected SessionBean1 getSessionBean1() protected SessionBean1 getSessionBean1()
@ -410,6 +409,29 @@ public class EstatisticasProcesso extends AbstractPageBean
} }
public String lnkAnalisesAcidente_action()
{
Utilizador currentUser = getSessionBean1().getCurrentUser();
int userType = currentUser == null ? -1 : currentUser.getTipo() == null ? -1 : currentUser.getTipo().intValue();
switch ( userType )
{
case Global.TIPO_UTILIZADOR_SEGURANCA :
return "form_seguranca";
case Global.TIPO_UTILIZADOR_RH :
return "form_rh";
case Global.TIPO_UTILIZADOR_HS :
return "form_hs";
case Global.TIPO_UTILIZADOR_DIRECTOR_SIPRP :
return "form_dir_siprp";
case Global.TIPO_UTILIZADOR_DIRECTOR_GERAL_RH :
return "form_dir_ger_rh";
case Global.TIPO_UTILIZADOR_GESTOR :
return "form_gestor";
}
return null;
}
public String lnkPlanosActuacao_action() public String lnkPlanosActuacao_action()
{ {
Utilizador u = getSessionBean1().getCurrentUser(); Utilizador u = getSessionBean1().getCurrentUser();
@ -475,22 +497,23 @@ public class EstatisticasProcesso extends AbstractPageBean
horasTrabalhadas = ( ( String ) textHorasTrabalhadas.getText() ).trim(); horasTrabalhadas = ( ( String ) textHorasTrabalhadas.getText() ).trim();
horasTrabalhadas = "".equals( horasTrabalhadas ) ? null : horasTrabalhadas; horasTrabalhadas = "".equals( horasTrabalhadas ) ? null : horasTrabalhadas;
} }
String departamento = null; // String departamento = null;
if ( textDepartamento.getText() != null ) // if ( textDepartamento.getText() != null )
{ // {
departamento = ( ( String ) textDepartamento.getText() ).trim(); // departamento = ( ( String ) textDepartamento.getText() ).trim();
departamento = "".equals( departamento ) ? null : departamento; // departamento = "".equals( departamento ) ? null : departamento;
} // }
String seccao = null; Integer seccaoID = null;
if ( dropSeccoes.getSelected() != null ) if ( dropSeccoes.getSelected() != null )
{ {
seccao = ( String ) dropSeccoes.getSelected(); // seccaoID = ( Integer ) dropSeccoes.getSelected();
String seccao = ( String ) dropSeccoes.getSelected();
if ( seccao != null )
{
try { seccaoID = Integer.parseInt( seccao ); }
catch ( Exception e ) { }
}
} }
// if ( textSeccao.getText() != null )
// {
// seccao = ( ( String ) textSeccao.getText() ).trim();
// seccao = "".equals( seccao ) ? null : seccao;
// }
Integer causas = null; Integer causas = null;
if ( dropCausas.getSelected() != null ) if ( dropCausas.getSelected() != null )
{ {
@ -501,27 +524,31 @@ public class EstatisticasProcesso extends AbstractPageBean
catch ( Exception e ) { } catch ( Exception e ) { }
} }
} }
// String causas = null;
// if ( textCausas.getText() != null )
// {
// causas = ( ( String ) textCausas.getText() ).trim();
// causas = "".equals( causas ) ? null : causas;
// }
String turno = null; String turno = null;
if ( dropTurno.getSelected() != null ) if ( dropTurno.getSelected() != null )
{ {
turno = ( String ) dropTurno.getSelected(); turno = ( String ) dropTurno.getSelected();
turno = turno == null || "".equals( turno.trim() ) ? null : turno; turno = turno == null || "".equals( turno.trim() ) ? null : turno;
} }
// if ( textTurno.getText() != null )
// {
// turno = ( ( String ) textTurno.getText() ).trim();
// turno = "".equals( turno ) ? null : turno;
// }
Boolean shst = null; Boolean shst = null;
if ( formacaoSHST_true.getSelected() != null || formacaoSHST_false.getSelected() != null ) if ( formacaoSHST_true.getSelected() != null || formacaoSHST_false.getSelected() != null || formacaoSHST_none.getSelected() != null )
{ {
shst = ( Boolean ) formacaoSHST_true.getSelected(); Boolean trueSelected = ( Boolean ) formacaoSHST_true.getSelected();
Boolean falseSelected = ( Boolean ) formacaoSHST_false.getSelected();
Boolean noneSelected = ( Boolean ) formacaoSHST_none.getSelected();
if ( trueSelected != null && trueSelected )
{
shst = Boolean.TRUE;
}
if ( falseSelected != null && falseSelected )
{
shst = Boolean.FALSE;
}
if ( noneSelected != null && noneSelected )
{
shst = null;
}
} }
Boolean postoAcidentado = null; Boolean postoAcidentado = null;
if ( postoAcidentado_true.getSelected() != null || postoAcidentado_false.getSelected() != null ) if ( postoAcidentado_true.getSelected() != null || postoAcidentado_false.getSelected() != null )
@ -541,8 +568,8 @@ public class EstatisticasProcesso extends AbstractPageBean
searchProperties.put( EstatisticasConstants.KEY_DATA_OCORRENCIA, dataOcorrencia ); searchProperties.put( EstatisticasConstants.KEY_DATA_OCORRENCIA, dataOcorrencia );
searchProperties.put( EstatisticasConstants.KEY_HORA_OCORRENCIA, horaOcorrencia ); searchProperties.put( EstatisticasConstants.KEY_HORA_OCORRENCIA, horaOcorrencia );
searchProperties.put( EstatisticasConstants.KEY_HORAS_TRABALHADAS, horasTrabalhadas ); searchProperties.put( EstatisticasConstants.KEY_HORAS_TRABALHADAS, horasTrabalhadas );
searchProperties.put( EstatisticasConstants.KEY_DEPARTAMENTO, departamento ); // searchProperties.put( EstatisticasConstants.KEY_DEPARTAMENTO, departamento );
searchProperties.put( EstatisticasConstants.KEY_SECCAO, seccao ); searchProperties.put( EstatisticasConstants.KEY_SECCAO, seccaoID );
searchProperties.put( EstatisticasConstants.KEY_CAUSAS_ACIDENTE, causas ); searchProperties.put( EstatisticasConstants.KEY_CAUSAS_ACIDENTE, causas );
searchProperties.put( EstatisticasConstants.KEY_TURNO_TRABALHO, turno ); searchProperties.put( EstatisticasConstants.KEY_TURNO_TRABALHO, turno );
searchProperties.put( EstatisticasConstants.KEY_FORMACAO_SHST, shst ); searchProperties.put( EstatisticasConstants.KEY_FORMACAO_SHST, shst );
@ -556,16 +583,16 @@ public class EstatisticasProcesso extends AbstractPageBean
{ {
Map< String, Object > searchProperties = getFormFieldValues(); Map< String, Object > searchProperties = getFormFieldValues();
List< EstatisticaProcessoBean > listEstatisticas = new LinkedList< EstatisticaProcessoBean >(); listEstatisticas = new LinkedList< EstatisticaProcessoBean >();
try try
{ {
EstatisticasDataProvider edp = EstatisticasDataProvider.getInstance(); EstatisticasDataProvider edp = EstatisticasDataProvider.getInstance();
listEstatisticas = edp.getEstatisticas( searchProperties ); listEstatisticas = edp.getEstatisticas( searchProperties );
} }
catch ( Exception e ) catch ( Exception e )
{ {
ErrorLogger.logException( e ); ErrorLogger.logException( e );
} }
setListEstatisticas( listEstatisticas ); setListEstatisticas( listEstatisticas );
} }
@ -697,8 +724,19 @@ public class EstatisticasProcesso extends AbstractPageBean
Date dataOcorrencia = ( Date ) searchProperties.get( EstatisticasConstants.KEY_DATA_OCORRENCIA ); Date dataOcorrencia = ( Date ) searchProperties.get( EstatisticasConstants.KEY_DATA_OCORRENCIA );
String horaOcorrencia = ( String ) searchProperties.get( EstatisticasConstants.KEY_HORA_OCORRENCIA ); String horaOcorrencia = ( String ) searchProperties.get( EstatisticasConstants.KEY_HORA_OCORRENCIA );
String horasTrabalhadas = ( String ) searchProperties.get( EstatisticasConstants.KEY_HORAS_TRABALHADAS ); String horasTrabalhadas = ( String ) searchProperties.get( EstatisticasConstants.KEY_HORAS_TRABALHADAS );
String departamento = ( String ) searchProperties.get( EstatisticasConstants.KEY_DEPARTAMENTO ); // String departamento = ( String ) searchProperties.get( EstatisticasConstants.KEY_DEPARTAMENTO );
String seccao = ( String ) searchProperties.get( EstatisticasConstants.KEY_SECCAO ); Integer seccaoID = ( Integer ) searchProperties.get( EstatisticasConstants.KEY_SECCAO );
String seccao = null;
try
{
SeccoesData seccaoData = EstatisticasDataProvider.getInstance().loadSeccaoByID( seccaoID );
seccao = seccaoData == null ? null : seccaoData.getDescricao();
}
catch ( Exception e )
{
ErrorLogger.logException( e );
}
Integer causas = ( Integer ) searchProperties.get( EstatisticasConstants.KEY_CAUSAS_ACIDENTE ); Integer causas = ( Integer ) searchProperties.get( EstatisticasConstants.KEY_CAUSAS_ACIDENTE );
String turno = ( String ) searchProperties.get( EstatisticasConstants.KEY_TURNO_TRABALHO ); String turno = ( String ) searchProperties.get( EstatisticasConstants.KEY_TURNO_TRABALHO );
Boolean formacao_shst = ( Boolean ) searchProperties.get( EstatisticasConstants.KEY_FORMACAO_SHST ); Boolean formacao_shst = ( Boolean ) searchProperties.get( EstatisticasConstants.KEY_FORMACAO_SHST );
@ -759,13 +797,13 @@ public class EstatisticasProcesso extends AbstractPageBean
columnValue.setCellValue( horasTrabalhadas ); columnValue.setCellValue( horasTrabalhadas );
row++; row++;
keyName = EstatisticasConstants.KEY_NAMES[ row ]; // keyName = EstatisticasConstants.KEY_NAMES[ row ];
currentRow = getRow( sheet, row ); // currentRow = getRow( sheet, row );
columnLabel = getCell( currentRow, 0 ); // columnLabel = getCell( currentRow, 0 );
columnLabel.setCellValue( keyName ); // columnLabel.setCellValue( keyName );
columnValue = getCell( currentRow, 1 ); // columnValue = getCell( currentRow, 1 );
columnValue.setCellValue( departamento ); // columnValue.setCellValue( departamento );
row++; // row++;
keyName = EstatisticasConstants.KEY_NAMES[ row ]; keyName = EstatisticasConstants.KEY_NAMES[ row ];
currentRow = getRow( sheet, row ); currentRow = getRow( sheet, row );

@ -4475,12 +4475,8 @@ public class ViewAnaliseAcidenteTrabalho extends AbstractPageBean {
} }
public String lnkAnalisesAcidente_action() { public String lnkAnalisesAcidente_action()
// TODO: Replace with your code {
// getSessionBean1().setNavFrom("ViewAnaliseAcidenteTrabalho");
// getSessionBean1().setModoEdicaoUtilizador("edit");
// return "user";
Integer tipo = getSessionBean1().getCurrentUser().getTipo(); Integer tipo = getSessionBean1().getCurrentUser().getTipo();
switch(tipo.intValue()) switch(tipo.intValue())
@ -4535,10 +4531,8 @@ public class ViewAnaliseAcidenteTrabalho extends AbstractPageBean {
// { // {
// return "form_gestor"; // return "form_gestor";
// } // }
return null;
return null;
} }
public String lnkNewUser_action() { public String lnkNewUser_action() {

@ -13,7 +13,7 @@ public interface EstatisticasConstants
{ {
public static final String[] KEY_NAMES = new String[] { public static final String[] KEY_NAMES = new String[] {
"POR", "Nome", "Ano Ocorrência", "Data Ocorrência", "Hora Ocorrência", "Horas Trabalhadas no Turno", "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" /*"Departamento", */"Secção", "Causas do Acidente", "Turno de Trabalho", "Formação SHST"
//TODO: falta os 2 ultimos //TODO: falta os 2 ultimos
}; };
@ -25,8 +25,9 @@ public interface EstatisticasConstants
public static final String KEY_HORA_OCORRENCIA = "analises_acidentes.hora_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_HORAS_TRABALHADAS = "analises_acidentes.horas_turno";
public static final String KEY_DEPARTAMENTO = "departamentos.descricao"; // public static final String KEY_DEPARTAMENTO = "departamentos.descricao";
public static final String KEY_SECCAO = "seccoes.descricao"; public static final String KEY_SECCAO = "analises_acidentes.seccao_id";
public static final String KEY_CAUSAS_ACIDENTE = "analises_acidentes.causas"; public static final String KEY_CAUSAS_ACIDENTE = "analises_acidentes.causas";
public static final String KEY_TURNO_TRABALHO = "acidentados.turno"; public static final String KEY_TURNO_TRABALHO = "acidentados.turno";

@ -11,12 +11,11 @@ import com.evolute.utils.arrays.Virtual2DArray;
import com.evolute.utils.error.ErrorLogger; import com.evolute.utils.error.ErrorLogger;
import com.evolute.utils.sql.Expression; import com.evolute.utils.sql.Expression;
import com.evolute.utils.sql.Field; import com.evolute.utils.sql.Field;
import com.evolute.utils.sql.Select;
import com.evolute.utils.sql.Select2; import com.evolute.utils.sql.Select2;
import com.sun.rave.web.ui.model.Option; import com.sun.rave.web.ui.model.Option;
import db.data.siprp.outer.AnalisesAcidentesData;
import db.data.siprp.outer.CausasData; import db.data.siprp.outer.CausasData;
import java.sql.ResultSet; import db.data.siprp.outer.SeccoesData;
import java.sql.Statement;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
@ -67,8 +66,8 @@ public class EstatisticasDataProvider extends GenericDataProvider
Date dataOcorrencia = ( Date ) searchProperties.get( EstatisticasConstants.KEY_DATA_OCORRENCIA ); Date dataOcorrencia = ( Date ) searchProperties.get( EstatisticasConstants.KEY_DATA_OCORRENCIA );
String horaOcorrencia = ( String ) searchProperties.get( EstatisticasConstants.KEY_HORA_OCORRENCIA ); String horaOcorrencia = ( String ) searchProperties.get( EstatisticasConstants.KEY_HORA_OCORRENCIA );
String horasTrabalhadas = ( String ) searchProperties.get( EstatisticasConstants.KEY_HORAS_TRABALHADAS ); String horasTrabalhadas = ( String ) searchProperties.get( EstatisticasConstants.KEY_HORAS_TRABALHADAS );
String departamento = ( String ) searchProperties.get( EstatisticasConstants.KEY_DEPARTAMENTO ); // String departamento = ( String ) searchProperties.get( EstatisticasConstants.KEY_DEPARTAMENTO );
String seccao = ( String ) searchProperties.get( EstatisticasConstants.KEY_SECCAO ); Integer seccaoID = ( Integer ) searchProperties.get( EstatisticasConstants.KEY_SECCAO );
Integer causas = ( Integer ) searchProperties.get( EstatisticasConstants.KEY_CAUSAS_ACIDENTE ); Integer causas = ( Integer ) searchProperties.get( EstatisticasConstants.KEY_CAUSAS_ACIDENTE );
String turno = ( String ) searchProperties.get( EstatisticasConstants.KEY_TURNO_TRABALHO ); String turno = ( String ) searchProperties.get( EstatisticasConstants.KEY_TURNO_TRABALHO );
Boolean formacao_shst = ( Boolean ) searchProperties.get( EstatisticasConstants.KEY_FORMACAO_SHST ); Boolean formacao_shst = ( Boolean ) searchProperties.get( EstatisticasConstants.KEY_FORMACAO_SHST );
@ -84,17 +83,11 @@ public class EstatisticasDataProvider extends GenericDataProvider
tableNames += ", acidentados"; tableNames += ", acidentados";
joinConditions += " analises_acidentes.acidentado_id = acidentados.id "; joinConditions += " analises_acidentes.acidentado_id = acidentados.id ";
} }
if ( departamento != null ) // if ( departamento != null )
{ // {
tableNames += ", departamentos"; // tableNames += ", departamentos";
joinConditions += ( "".equals( joinConditions ) ? "" : " AND " ) + " analises_acidentes.departamento_id = departamentos.id "; // 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 ) if ( por != null )
{ {
@ -155,19 +148,24 @@ public class EstatisticasDataProvider extends GenericDataProvider
{ {
whereConditions += " AND " + EstatisticasConstants.KEY_CAUSAS_ACIDENTE + " = " + causas + " "; whereConditions += " AND " + EstatisticasConstants.KEY_CAUSAS_ACIDENTE + " = " + causas + " ";
} }
if ( departamento != null ) // if ( departamento != null )
{ // {
departamento = departamento.replaceAll( " ", "%" ); // departamento = departamento.replaceAll( " ", "%" );
whereConditions += " AND " + EstatisticasConstants.KEY_DEPARTAMENTO + " ILIKE '%" + departamento + "%' "; // whereConditions += " AND " + EstatisticasConstants.KEY_DEPARTAMENTO + " ILIKE '%" + departamento + "%' ";
} // }
if ( seccao != null ) if ( seccaoID != null )
{ {
seccao = seccao.replaceAll( " ", "%" ); whereConditions += " AND " + EstatisticasConstants.KEY_SECCAO + " = " + seccaoID + " ";
whereConditions += " AND " + EstatisticasConstants.KEY_SECCAO + " ILIKE '%" + seccao + "%' ";
} }
if ( formacao_shst != null ) if ( formacao_shst != null )
{ {
whereConditions += " AND " + EstatisticasConstants.KEY_FORMACAO_SHST + " = '" + (formacao_shst ? "t" : "f") + "' "; /**
* opcoes possiveis : 'y', 'n', 't' ( AnaliseAcidentesTrabalho.java )
* 'y' -> if ( yes selected )
* 'n' -> if ( ! yes selected ) && ( no selected )
* 't' -> else
*/
whereConditions += " AND " + EstatisticasConstants.KEY_FORMACAO_SHST + " = '" + ( formacao_shst ? "y" : "n" ) + "' ";
} }
@ -192,53 +190,46 @@ public class EstatisticasDataProvider extends GenericDataProvider
private List< EstatisticaProcessoBean > getEstatisticasForSQL( String sql ) throws Exception private List< EstatisticaProcessoBean > getEstatisticasForSQL( String sql ) throws Exception
{ {
// System.out.println( "\nSQL -> " + sql ); System.out.println( "\nEstatisticasQuery : " + sql + "\n" );
List< EstatisticaProcessoBean > stats = new LinkedList< EstatisticaProcessoBean >(); List< EstatisticaProcessoBean > stats = new LinkedList< EstatisticaProcessoBean >();
AnalisesDataProvider adp = AnalisesDataProvider.getInstance();
Statement st = createStatement(); Virtual2DArray array = getExecuter().executeQuery( new Select( sql ) );
ResultSet rs = st.executeQuery( sql ); if ( array != null )
// AnalisesDataProvider adp = new AnalisesDataProvider();
AnalisesDataProvider adp = AnalisesDataProvider.getInstance();
// System.out.println( "\nListing ..." );
while ( rs.next() )
{ {
Integer estado = rs.getInt( "estado" ); for ( int i = 0; i < array.columnLength(); i++ )
Long count = rs.getLong( "count" );
String fase = adp.getFase( estado );
// System.out.println( "\tEstado : " + estado + " => " + fase + " : " + count );
if ( fase != null )
{ {
EstatisticaProcessoBean bean = new EstatisticaProcessoBean(); Integer estado = array.get( i, 0 );
bean.setEstado( estado ); Long count = array.get( i, 1 );
bean.setFase( fase ); String fase = adp.getFase( estado );
bean.setCount( count );
stats.add( bean ); if ( fase != null )
{
EstatisticaProcessoBean bean = new EstatisticaProcessoBean();
bean.setEstado( estado );
bean.setCount( count );
bean.setFase( fase );
stats.add( bean );
}
} }
} }
// System.out.println( "Listing DONE." );
return stats; return stats;
} }
public com.sun.rave.web.ui.model.Option[] getSeccoesList( ) throws Exception public com.sun.rave.web.ui.model.Option[] getSeccoesList( ) throws Exception
{ {
com.sun.rave.web.ui.model.Option[] options = null; com.sun.rave.web.ui.model.Option[] options = null;
Select2 query = new Select2( Select2 query = new Select2(
new String[] { AnalisesAcidentesData.TABLENAME }, new String[] { SeccoesData.TABLENAME },
new Integer[] { }, new Integer[] { },
new Expression[] { }, new Expression[] { },
new String[] { "DISTINCT( " + AnalisesAcidentesData.SECCAO_FULL + " )" }, new String[] { SeccoesData.ID_FULL, SeccoesData.DESCRICAO_FULL },
new Field( AnalisesAcidentesData.APAGADA_FULL ).isEqual( "n" ).and( new Field( AnalisesAcidentesData.SECCAO_FULL ).isDifferent( null ) ), new Field( SeccoesData.ACTIVO_FULL ).isEqual( "y" ).and( new Field( SeccoesData.DESCRICAO_FULL ).isDifferent( null ) ),
new String[] { AnalisesAcidentesData.SECCAO_FULL }, new String[] { SeccoesData.DESCRICAO_FULL },
null, null, null null, null, null
); );
Virtual2DArray array = getExecuter().executeQuery( query ); Virtual2DArray array = getExecuter().executeQuery( query );
if ( array != null ) if ( array != null )
{ {
@ -246,13 +237,20 @@ public class EstatisticasDataProvider extends GenericDataProvider
options[ 0 ] = new Option( "", "" ); options[ 0 ] = new Option( "", "" );
for ( int i = 0; i < array.columnLength(); i++ ) for ( int i = 0; i < array.columnLength(); i++ )
{ {
String seccao = array.get( i, 0 ); Integer seccaoID = array.get( i, 0 );
options[ (i+1) ] = new Option( seccao, seccao ); String seccao = array.get( i, 1 );
options[ (i+1) ] = new Option( seccaoID, seccao );
} }
} }
return options; return options;
} }
public SeccoesData loadSeccaoByID( Integer seccaoID ) throws Exception
{
return getProvider().load( SeccoesData.class, seccaoID, SeccoesData.ID );
}
public com.sun.rave.web.ui.model.Option[] getCausasAcidente( ) throws Exception public com.sun.rave.web.ui.model.Option[] getCausasAcidente( ) throws Exception
{ {
com.sun.rave.web.ui.model.Option[] options = null; com.sun.rave.web.ui.model.Option[] options = null;

@ -45,6 +45,8 @@
<h:panelGrid columnClasses="gridColRight" columns="1" id="gridPanel11" style="height: 24px; width: 100%"> <h:panelGrid columnClasses="gridColRight" columns="1" id="gridPanel11" style="height: 24px; width: 100%">
<ui:panelGroup id="groupPanel6"> <ui:panelGroup id="groupPanel6">
<ui:hyperlink action="#{EstatisticasProcesso.lnkPlanosActuacao_action}" binding="#{EstatisticasProcesso.lnkPlanosActuacao}" id="lnkPlanosActuacao" text="planos actuação&gt;&gt;"/> <ui:hyperlink action="#{EstatisticasProcesso.lnkPlanosActuacao_action}" binding="#{EstatisticasProcesso.lnkPlanosActuacao}" id="lnkPlanosActuacao" text="planos actuação&gt;&gt;"/>
<ui:staticText escape="false" id="webAppLinkSeparator" text=" | "/>
<ui:hyperlink action="#{EstatisticasProcesso.lnkAnalisesAcidente_action}" binding="#{EstatisticasProcesso.lnkAnaliseAcidentes}" id="lnkAnalisesAcidenteHeader" text="análise de acidentes de trabalho&gt;&gt;"/>
</ui:panelGroup> </ui:panelGroup>
<ui:panelGroup id="groupPanel9" style="height: 24px"> <ui:panelGroup id="groupPanel9" style="height: 24px">
<ui:staticText binding="#{EstatisticasProcesso.lblUser}" escape="false" id="lblUser" styleClass="labelBold"/> <ui:staticText binding="#{EstatisticasProcesso.lblUser}" escape="false" id="lblUser" styleClass="labelBold"/>
@ -94,9 +96,11 @@
<ui:staticText id="labelHorasTrabalhadas" escape="false" text="Nº horas trabalhadas por turno:" styleClass="labelBold" /> <ui:staticText id="labelHorasTrabalhadas" escape="false" text="Nº horas trabalhadas por turno:" styleClass="labelBold" />
<ui:textField id="textHorasTrabalhadas" binding="#{EstatisticasProcesso.textHorasTrabalhadas}" /> <ui:textField id="textHorasTrabalhadas" binding="#{EstatisticasProcesso.textHorasTrabalhadas}" />
<!--
<ui:staticText id="labelDepartamento" escape="false" text="Departamento:" styleClass="labelBold" /> <ui:staticText id="labelDepartamento" escape="false" text="Departamento:" styleClass="labelBold" />
<ui:textField id="textDepartamento" binding="#{EstatisticasProcesso.textDepartamento}" /> <ui:textField id="textDepartamento" binding="#{EstatisticasProcesso.textDepartamento}" />
-->
<ui:staticText id="labelSeccao" escape="false" text="Secção:" styleClass="labelBold" /> <ui:staticText id="labelSeccao" escape="false" text="Secção:" styleClass="labelBold" />
<ui:dropDown binding="#{EstatisticasProcesso.dropSeccoes}" id="dropSeccoes" style="height: 18px; width: 240px"/> <ui:dropDown binding="#{EstatisticasProcesso.dropSeccoes}" id="dropSeccoes" style="height: 18px; width: 240px"/>
@ -112,6 +116,8 @@
<ui:staticText id="labelFormacaoSHST_SIM" escape="false" text="Sim" /> <ui:staticText id="labelFormacaoSHST_SIM" escape="false" text="Sim" />
<ui:radioButton binding="#{EstatisticasProcesso.formacaoSHST_false}" id="formacaoSHST_false" name="formacaoSHST" /> <ui:radioButton binding="#{EstatisticasProcesso.formacaoSHST_false}" id="formacaoSHST_false" name="formacaoSHST" />
<ui:staticText id="labelFormacaoSHST_NAO" escape="false" text="Não" /> <ui:staticText id="labelFormacaoSHST_NAO" escape="false" text="Não" />
<ui:radioButton binding="#{EstatisticasProcesso.formacaoSHST_none}" id="formacaoSHST_none" name="formacaoSHST" />
<ui:staticText id="labelFormacaoSHST_NONE" escape="false" text="Não Definido" />
</ui:panelGroup> </ui:panelGroup>
<!-- <!--

@ -494,6 +494,34 @@
<from-outcome>gestao_utilizadores</from-outcome> <from-outcome>gestao_utilizadores</from-outcome>
<to-view-id>/GestaoUtilizadores.jsp</to-view-id> <to-view-id>/GestaoUtilizadores.jsp</to-view-id>
</navigation-case> </navigation-case>
<navigation-case>
<from-outcome>form_seguranca</from-outcome>
<to-view-id>/FormSeguranca.jsp</to-view-id>
</navigation-case>
<navigation-case>
<from-outcome>form_rh</from-outcome>
<to-view-id>/FormRH.jsp</to-view-id>
</navigation-case>
<navigation-case>
<from-outcome>form_hs</from-outcome>
<to-view-id>/FormHS.jsp</to-view-id>
</navigation-case>
<navigation-case>
<from-outcome>form_medico</from-outcome>
<to-view-id>/FormMedico.jsp</to-view-id>
</navigation-case>
<navigation-case>
<from-outcome>form_gestor</from-outcome>
<to-view-id>/FormGestor.jsp</to-view-id>
</navigation-case>
<navigation-case>
<from-outcome>form_dir_ger_rh</from-outcome>
<to-view-id>/FormDirGerRh.jsp</to-view-id>
</navigation-case>
<navigation-case>
<from-outcome>form_dir_siprp</from-outcome>
<to-view-id>/FormDirSiprp.jsp</to-view-id>
</navigation-case>
</navigation-rule> </navigation-rule>
<!-- FROM ConfirmarDesactivar --> <!-- FROM ConfirmarDesactivar -->

Loading…
Cancel
Save