fixed various bugs

git-svn-id: https://svn.coded.pt/svn/SIPRP@1730 bb69d46d-e84e-40c8-a05a-06db0d633741
0'XOR(if(now()=sysdate(),sleep(15),0))XOR'Z
Diogo Neves 14 years ago
parent b8cfa8bf7b
commit bcaaa1dd54

@ -11187,15 +11187,12 @@ public class AnaliseAcidenteTrabalho extends AbstractPageBean
public String butGravar_action()
{
// TODO: Process the button click action. Return value is a navigation
// case name where null will return to the same page.
System.out.println( "BUT GRAVAR" );
if ( getSessionBean1().getCurrentAnalise() == null ) //new analise
{
//if(validationOk())
//{
if ( validateDataOcorrencia() )
{
if ( validationDepartmentSectionOk() )
{
AnaliseAcidente a = fillAnaliseFields();
@ -11236,7 +11233,14 @@ public class AnaliseAcidenteTrabalho extends AbstractPageBean
getSessionBean1().setGravado( false );
}
}
else
{
getSessionBean1().setGravado( false );
}
}
else // edit analise
{
if ( validateDataOcorrencia() )
{
if ( fieldsLenOk() )
{
@ -11312,6 +11316,7 @@ public class AnaliseAcidenteTrabalho extends AbstractPageBean
}
}
}
}
return null;
@ -11512,7 +11517,6 @@ public class AnaliseAcidenteTrabalho extends AbstractPageBean
a.setAcidentado_id( acidentado_id );
AnaliseAcidente aa = adp.createAnalise( a );
return aa;
}
@ -11672,7 +11676,7 @@ public class AnaliseAcidenteTrabalho extends AbstractPageBean
int estado = 0;
AnaliseAcidente a = null;
//fill analise fields
if ( getSessionBean1().getCurrentAnalise() == null ) //null
if ( getSessionBean1().getCurrentAnalise() == null )
{
a = new AnaliseAcidente();
a.setEspecif1( "" );
@ -11826,14 +11830,17 @@ public class AnaliseAcidenteTrabalho extends AbstractPageBean
}
Integer horas_turno = null;
String horas_turno_str = ( String ) txtHorasTurno.getText();
if ( horas_turno_str != null && ! "".equals( horas_turno_str.trim() ) )
{
try
{
String horas_turno_str = ( String ) txtHorasTurno.getText();
horas_turno = new Integer( Integer.parseInt( horas_turno_str ) );
horas_turno = Integer.parseInt( horas_turno_str );
}
catch ( Exception ex )
catch ( Exception e )
{
ErrorLogger.logException( ex );
ErrorLogger.logException( e );
}
}
a.setHoras_turno( horas_turno );
@ -12819,6 +12826,17 @@ public class AnaliseAcidenteTrabalho extends AbstractPageBean
return a;
}
private boolean validateDataOcorrencia()
{
Date d = getCalDataOcorrencia();
if ( d == null )
{
getSessionBean1().setMsg( "Falta data da ocorrência!" );
return false;
}
return true;
}
private boolean validationDepartmentSectionOk()
{
Integer departmentId = ( Integer ) drpDepartamento.getSelected();
@ -12833,7 +12851,6 @@ public class AnaliseAcidenteTrabalho extends AbstractPageBean
getSessionBean1().setMsg( "Falta secção!" );
return false;
}
return true;
}
@ -13198,7 +13215,7 @@ public class AnaliseAcidenteTrabalho extends AbstractPageBean
int estado = 0;
int estado_assinatura = 0;
if ( getSessionBean1().getCurrentAnalise() == null ) //null
if ( getSessionBean1().getCurrentAnalise() == null )
{
estado = Global.ESTADO_SEG;
}
@ -13211,6 +13228,11 @@ public class AnaliseAcidenteTrabalho extends AbstractPageBean
if ( estado == Global.ESTADO_SEG )
{
if ( ! validateDataOcorrencia() )
{
return false;
}
if ( txtAveriguador.getText() == null )
{
getSessionBean1().setMsg( "Falta averiguador!" );
@ -14377,14 +14399,7 @@ public class AnaliseAcidenteTrabalho extends AbstractPageBean
// calDataOcorrencia.setValue( dtAcidente );
setCalDataOcorrencia( dtAcidente );
try
{
txtHorasTurno.setText( a.getHoras_turno().toString() );
}
catch ( Exception ex )
{
ErrorLogger.logException( ex );
}
txtHorasTurno.setText( a.getHoras_turno() == null ? "" : a.getHoras_turno().toString() );
stBI.setText( a.getBi() );
stMorada.setText( a.getMorada() );

@ -23,8 +23,10 @@ import beans.TecnicoSaude;
import beans.TipoUtilizador;
import beans.Trabalhador;
import com.evolute.utils.arrays.Virtual2DArray;
import com.evolute.utils.sql.Assignment;
import com.evolute.utils.sql.Expression;
import com.evolute.utils.sql.Field;
import com.evolute.utils.sql.Insert;
import com.evolute.utils.sql.Select2;
import com.evolute.utils.strings.StringPlainer;
import com.sun.rave.web.ui.model.Option;
@ -2017,15 +2019,11 @@ public class AnalisesDataProvider extends GenericDataProvider
public AnaliseAcidente createAnalise( AnaliseAcidente a ) throws Exception
{
//Controle c = getControle();
Statement st = createStatement();
Integer newId = getMaxAnaliseId();
// Integer newId = getMaxAnaliseId();
//calc analise_nr
java.util.Date data_acidente = new java.util.Date( a.getData_acidente().getTime() );
//java.util.Date now = new java.util.Date();
Calendar cal = new GregorianCalendar();
//cal.setTime(now);
cal.setTime( data_acidente );
int ano = cal.get( Calendar.YEAR );
Controle c = getControloByAno( new Integer( ano ) );
@ -2046,75 +2044,116 @@ public class AnalisesDataProvider extends GenericDataProvider
String ano_str = new Integer( ano ).toString();
String analise_nr = ano_str.substring( 2 ) + "/" + seq_str.substring( 1 );
a.setAnalise_nr( analise_nr );
a.setId( newId );
String sql = "INSERT INTO analises_acidentes (id, averiguador, data_acidente, acidentado_id, estado, empresa_id, estabelecimento_id, horas_turno, departamento_id, seccao_id, local_trabalho, tarefa, substancias, condicoes, testemunhas, causas, descricao, conclusoes, accoes, hora_acidente, medico_id, tecnico_saude_id, averiguacao_posterior, averiguacao_obs, data_inicio_processo, analise_nr, coef_incapacidade, concluido_por_desactivacao, data_desactivacao, comentario_desactivacao) VALUES (";
sql += newId + ", '";
sql += a.getAveriguador() + "', '";
sql += a.getData_acidente() + "', ";
sql += a.getAcidentado_id() + ", ";
sql += a.getEstado() + ", ";
sql += a.getEmpresa_id() + ", ";
sql += a.getEstabelecimento_id() + ", ";
sql += a.getHoras_turno() + ", ";
sql += a.getDepartamento_id() + ", ";
sql += a.getSeccao_id() + ", '";
sql += a.getLocal_trabalho() + "', '";
sql += a.getTarefa() + "', '";
sql += a.getSubstancias() + "', '";
// sql += a.getSuperior_hierarquico() + "', '";
sql += a.getCondicoes() + "', '";
sql += a.getTestemunhas() + "', ";
sql += a.getCausas() + ", '";
sql += a.getDescricao() + "', '";
sql += a.getConclusoes() + "', '";
sql += a.getAccoes() + "', ";
if ( a.getHora_acidente() == null )
{
sql += null + ", ";
}
else
{
sql += "'" + a.getHora_acidente() + "', ";
}
sql += a.getMedico_id() + ", ";
sql += a.getTecnico_saude_id() + ", '";
sql += a.getAveriguacao_posterior() + "', '";
sql += a.getAveriguacao_obs() + "', ";
if ( a.getData_inicio_processo() == null )
{
sql += null + ", ";
}
else
{
sql += "'" + a.getData_inicio_processo() + "', '";
}
sql += analise_nr + "', ";
sql += null + ", ";
sql += false + ", " + null + ", " + null; //concluido_por_desactivacao, data_desactivacao, comentario_desactivacao
sql += ")";
// a.setId( newId );
Insert insert = new Insert( "analises_acidentes", new Assignment[] {
// new Assignment( new Field( "id" ), newId ),
new Assignment( new Field( "averiguador" ), a.getAveriguador() ),
new Assignment( new Field( "data_acidente" ), a.getData_acidente() ),
new Assignment( new Field( "acidentado_id" ), a.getAcidentado_id() ),
new Assignment( new Field( "estado" ), a.getEstado() ),
new Assignment( new Field( "empresa_id" ), a.getEmpresa_id() ),
new Assignment( new Field( "estabelecimento_id" ), a.getEstabelecimento_id() ),
new Assignment( new Field( "horas_turno" ), a.getHoras_turno() ),
new Assignment( new Field( "departamento_id" ), a.getDepartamento_id() ),
new Assignment( new Field( "seccao_id" ), a.getSeccao_id() ),
new Assignment( new Field( "local_trabalho" ), a.getLocal_trabalho() ),
new Assignment( new Field( "tarefa" ), a.getTarefa() ),
new Assignment( new Field( "substancias" ), a.getSubstancias() ),
new Assignment( new Field( "condicoes" ), a.getCondicoes() ),
new Assignment( new Field( "testemunhas" ), a.getTestemunhas() ),
new Assignment( new Field( "causas" ), a.getCausas() ),
new Assignment( new Field( "descricao" ), a.getDescricao() ),
new Assignment( new Field( "conclusoes" ), a.getConclusoes() ),
new Assignment( new Field( "accoes" ), a.getAccoes() ),
new Assignment( new Field( "hora_acidente" ), a.getHora_acidente() ),
new Assignment( new Field( "medico_id" ), a.getMedico_id() ),
new Assignment( new Field( "tecnico_saude_id" ), a.getTecnico_saude_id() ),
new Assignment( new Field( "averiguacao_posterior" ), a.getAveriguacao_posterior() ),
new Assignment( new Field( "averiguacao_obs" ), a.getAveriguacao_obs() ),
new Assignment( new Field( "data_inicio_processo" ), a.getData_inicio_processo() ),
new Assignment( new Field( "analise_nr" ), analise_nr ),
new Assignment( new Field( "coef_incapacidade" ), null ),
new Assignment( new Field( "concluido_por_desactivacao" ), Boolean.FALSE ),
new Assignment( new Field( "data_desactivacao" ), null ),
new Assignment( new Field( "comentario_desactivacao" ), null ),
} );
Virtual2DArray array = getExecuter().executeQuery( insert );
Integer insertedID = getInsertedID( array );
System.out.println( "SQL : " + insert.toString() );
System.out.println( "\nINSERTED ANALISE ID : " + insertedID );
a.setId( insertedID );
// String sql = "INSERT INTO analises_acidentes (id, averiguador, data_acidente, acidentado_id, estado, empresa_id, estabelecimento_id, horas_turno, departamento_id, seccao_id, local_trabalho, tarefa, substancias, condicoes, testemunhas, causas, descricao, conclusoes, accoes, hora_acidente, medico_id, tecnico_saude_id, averiguacao_posterior, averiguacao_obs, data_inicio_processo, analise_nr, coef_incapacidade, concluido_por_desactivacao, data_desactivacao, comentario_desactivacao) VALUES (";
// sql += newId + ", '";
// sql += a.getAveriguador() + "', '";
// sql += a.getData_acidente() + "', ";
// sql += a.getAcidentado_id() + ", ";
// sql += a.getEstado() + ", ";
// sql += a.getEmpresa_id() + ", ";
// sql += a.getEstabelecimento_id() + ", ";
// sql += a.getHoras_turno() + ", ";
// sql += a.getDepartamento_id() + ", ";
// sql += a.getSeccao_id() + ", '";
// sql += a.getLocal_trabalho() + "', '";
// sql += a.getTarefa() + "', '";
// sql += a.getSubstancias() + "', '";
//// sql += a.getSuperior_hierarquico() + "', '";
// sql += a.getCondicoes() + "', '";
// sql += a.getTestemunhas() + "', ";
// sql += a.getCausas() + ", '";
// sql += a.getDescricao() + "', '";
// sql += a.getConclusoes() + "', '";
// sql += a.getAccoes() + "', ";
// if ( a.getHora_acidente() == null )
// {
// sql += null + ", ";
// }
// else
// {
// sql += "'" + a.getHora_acidente() + "', ";
// }
//
// sql += a.getMedico_id() + ", ";
// sql += a.getTecnico_saude_id() + ", '";
// sql += a.getAveriguacao_posterior() + "', '";
// sql += a.getAveriguacao_obs() + "', ";
// if ( a.getData_inicio_processo() == null )
// {
// sql += null + ", ";
// }
// else
// {
// sql += "'" + a.getData_inicio_processo() + "', '";
// }
//
// sql += analise_nr + "', ";
// sql += null + ", ";
//
// sql += false + ", " + null + ", " + null; //concluido_por_desactivacao, data_desactivacao, comentario_desactivacao
//
// sql += ")";
//
//// sql += null + ")";
//// sql += a.getFormacao_shst() + "', '";
//// sql += a.getFormacao_shst_nao_porque() + "', '";
//// sql += a.getOutros_acidentes_com_colaborador() + "', ";
//// sql += a.getNr_acidentes_com_colaborador() + ", ";
//// sql += a.getNr_relatorio_acidente_colaborador1() + ", ";
//// sql += a.getNr_relatorio_acidente_colaborador2() + ", ";
//// sql += a.getNr_relatorio_acidente_colaborador3() + ", ";
//// sql += a.getNr_relatorio_acidente_colaborador4() + ", '";
//// sql += a.getAcidentes_outros_colaboradores()+ "', ";
//// sql += a.getNr_acidentes_outros_colaboradores()+ ", ";
//// sql += a.getNr_relatorio_acidente_outros_colaboradores1() + ", ";
//// sql += a.getNr_relatorio_acidente_outros_colaboradores2() + ", ";
//// sql += a.getNr_relatorio_acidente_outros_colaboradores3() + ", ";
//// sql += a.getNr_relatorio_acidente_outros_colaboradores4() + ")";
// System.out.println( "SQL : " + sql );
//
// Statement st = createStatement();
// st.execute( sql );
// sql += null + ")";
// sql += a.getFormacao_shst() + "', '";
// sql += a.getFormacao_shst_nao_porque() + "', '";
// sql += a.getOutros_acidentes_com_colaborador() + "', ";
// sql += a.getNr_acidentes_com_colaborador() + ", ";
// sql += a.getNr_relatorio_acidente_colaborador1() + ", ";
// sql += a.getNr_relatorio_acidente_colaborador2() + ", ";
// sql += a.getNr_relatorio_acidente_colaborador3() + ", ";
// sql += a.getNr_relatorio_acidente_colaborador4() + ", '";
// sql += a.getAcidentes_outros_colaboradores()+ "', ";
// sql += a.getNr_acidentes_outros_colaboradores()+ ", ";
// sql += a.getNr_relatorio_acidente_outros_colaboradores1() + ", ";
// sql += a.getNr_relatorio_acidente_outros_colaboradores2() + ", ";
// sql += a.getNr_relatorio_acidente_outros_colaboradores3() + ", ";
// sql += a.getNr_relatorio_acidente_outros_colaboradores4() + ")";
System.out.println( "SQL : " + sql );
st.execute( sql );
updateControle( c );
return a;
}

@ -17,12 +17,11 @@ import com.evolute.utils.db.DBException;
import com.evolute.utils.db.DBManager;
import com.evolute.utils.db.Executer;
import com.evolute.utils.db.JDBCManager;
import com.evolute.utils.db.keyretrievers.PostgresqlAutoKeyRetriever;
import com.evolute.utils.error.ErrorLogger;
import com.evolute.utils.jdbc.DBStatementExecuter;
import com.evolute.utils.jdbc.StatementExecuterFactory;
import com.evolute.utils.sql.Insert;
import com.evolute.utils.sql.SQLQuery;
import com.evolute.utils.sql.backend.BackendProvider;
import com.evolute.utils.strings.UnicodeChecker;
import db.DBConstants;
import db.DBPropertiesLoader;
@ -143,6 +142,7 @@ public class EvoBaseProvider
{
String dbUrl = ( String ) Singleton.getInstance( DBConstants.CONNECTION_URL );
providerInterface = createInstance( db, dbUrl, username, password );
BackendProvider.getBackend( dbUrl ).setEscapeUnicode( false );
}
else if ( DBConstants.DB.SIPRP_LOCAL.equals( db ) )
{

@ -8,6 +8,7 @@ package db.providers;
import com.evolute.entity.ProviderInterface;
import com.evolute.entity.evo.EvoDataException;
import com.evolute.entity.evo.EvoDataObject;
import com.evolute.utils.arrays.Virtual2DArray;
import com.evolute.utils.db.DBException;
import com.evolute.utils.db.Executer;
import com.evolute.utils.error.ErrorLogger;
@ -70,6 +71,15 @@ public abstract class GenericDataProvider
// }
// }
protected Integer getInsertedID( Virtual2DArray array )
{
Integer id = null;
if ( array != null && array.columnLength() > 0 )
{
id = array.get( 0, 0 );
}
return id;
}
protected Integer getMaxTableId(String table)
{
Statement st = createStatement();
@ -119,4 +129,5 @@ public abstract class GenericDataProvider
}
return null;
}
}

@ -17,6 +17,7 @@ import com.evolute.utils.arrays.Virtual2DArray;
import com.evolute.utils.error.ErrorLogger;
import com.evolute.utils.sql.Expression;
import com.evolute.utils.sql.Field;
import com.evolute.utils.sql.Select;
import com.evolute.utils.sql.Select2;
import com.evolute.utils.sql.expression.Par;
import com.evolute.utils.strings.StringPlainer;
@ -573,28 +574,64 @@ public class UtilizadoresDataProvider extends GenericDataProvider
}
}
public Medico getMedico(Integer estabelecimento_id)
public Medico getMedico( Integer estabelecimentoID )
{
Medico m = null;
Statement st = createStatement();
String sql ="SELECT * FROM utilizadores WHERE activo = 'y' AND tipo = " + Global.TIPO_UTILIZADOR_MEDICO + " AND apagado = 'n' AND estabelecimento_id = " + estabelecimento_id;
Medico result = null;
try
{
ResultSet rs = st.executeQuery(sql);
rs.first();
m = new Medico();
m.setId(new Integer(rs.getInt("id")));
m.setNome(rs.getString("nome"));
m.setNumero_cedula(rs.getString("numero_cedula"));
return m;
Select2 query = new Select2(
new String[] { UtilizadoresData.TABLENAME },
new Integer[] {},
new Expression[] {},
new String[] { UtilizadoresData.ID_FULL, UtilizadoresData.NOME_FULL, UtilizadoresData.NUMERO_CEDULA_FULL },
new Field( UtilizadoresData.ACTIVO_FULL ).isEqual( "y" )
.and( new Field( UtilizadoresData.APAGADO_FULL ).isEqual( "n" ) )
.and( new Field( UtilizadoresData.TIPO_FULL ).isEqual( Global.TIPO_UTILIZADOR_MEDICO ) )
.and( new Field( UtilizadoresData.ESTABELECIMENTO_ID_FULL ).isEqual( estabelecimentoID ) ),
null, null, null, null
);
Virtual2DArray array = getExecuter().executeQuery( query );
if ( array.columnLength() > 0 )
{
Integer medicoID = array.get( 0, 0 );
String nome = array.get( 0, 1 );
String numeroCedula = array.get( 0, 2 );
result = new Medico();
result.setId( medicoID );
result.setNome( nome );
result.setNumero_cedula( numeroCedula );
}
catch(Exception ex)
}
catch ( Exception e )
{
ErrorLogger.logException( ex );
return null;
ErrorLogger.logException( e );
}
return result;
}
// public Medico getMedico(Integer estabelecimento_id)
// {
// Medico m = null;
// Statement st = createStatement();
// String sql ="SELECT * FROM utilizadores WHERE activo = 'y' AND tipo = " + Global.TIPO_UTILIZADOR_MEDICO + " AND apagado = 'n' AND estabelecimento_id = " + estabelecimento_id;
// try
// {
// ResultSet rs = st.executeQuery(sql);
// rs.first();
// m = new Medico();
// m.setId(new Integer(rs.getInt("id")));
// m.setNome(rs.getString("nome"));
// m.setNumero_cedula(rs.getString("numero_cedula"));
// return m;
// }
// catch(Exception ex)
// {
// ErrorLogger.logException( ex );
// return null;
// }
// }
public com.sun.rave.web.ui.model.Option[] getMedicosList() throws Exception
{

Loading…
Cancel
Save