|
|
|
|
@ -80,13 +80,48 @@ public class AnalisesDataProvider {
|
|
|
|
|
c.setLast_analise_nr( new Integer( rs.getInt( "last_analise_nr" ) ) );
|
|
|
|
|
return c;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Controle getControloByAno(Integer ano) throws Exception
|
|
|
|
|
{
|
|
|
|
|
Controle c = null;
|
|
|
|
|
Statement st = createStatement();
|
|
|
|
|
String sql = "SELECT * FROM controle WHERE analise_year = " + ano;
|
|
|
|
|
ResultSet rs = st.executeQuery(sql);
|
|
|
|
|
|
|
|
|
|
if(rs.isBeforeFirst())
|
|
|
|
|
{
|
|
|
|
|
rs.first();
|
|
|
|
|
c = new Controle();
|
|
|
|
|
c.setId(new Integer( rs.getInt("id") ));
|
|
|
|
|
c.setAnalise_year( new Integer( rs.getInt( "analise_year" ) ));
|
|
|
|
|
c.setLast_analise_nr( new Integer( rs.getInt( "last_analise_nr" ) ) );
|
|
|
|
|
}
|
|
|
|
|
return c;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Controle createAnoNumeracao(Integer ano) throws Exception
|
|
|
|
|
{
|
|
|
|
|
Controle c = new Controle();
|
|
|
|
|
Integer newId = getMaxControleId();
|
|
|
|
|
c.setId(newId);
|
|
|
|
|
c.setAnalise_year(ano);
|
|
|
|
|
c.setLast_analise_nr(new Integer(0));
|
|
|
|
|
Statement st = createStatement();
|
|
|
|
|
|
|
|
|
|
String sql = "INSERT INTO controle (id, analise_year, last_analise_nr) VALUES (";
|
|
|
|
|
sql += c.getId() + ", ";
|
|
|
|
|
sql += c.getAnalise_year() + ", ";
|
|
|
|
|
sql += c.getLast_analise_nr() + ")";
|
|
|
|
|
st.execute(sql);
|
|
|
|
|
return c;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void updateControle( Controle c ) throws Exception
|
|
|
|
|
{
|
|
|
|
|
Statement st = createStatement();
|
|
|
|
|
String sql = "UPDATE controle SET analise_year = " + c.getAnalise_year() + ", ";
|
|
|
|
|
sql += "last_analise_nr = " + c.getLast_analise_nr() + " ";
|
|
|
|
|
sql += "WHERE id = 1";
|
|
|
|
|
sql += "WHERE id = " + c.getId();
|
|
|
|
|
st.execute(sql);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -1226,6 +1261,27 @@ public class AnalisesDataProvider {
|
|
|
|
|
System.out.println("SQL UPDATE ACIDENTADO : " + sql);
|
|
|
|
|
st.execute(sql);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Integer getMaxControleId()
|
|
|
|
|
{
|
|
|
|
|
Statement st = createStatement();
|
|
|
|
|
String sql = "SELECT max(controle.id)+1 AS MAXCONTROLEID FROM controle";
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
ResultSet rs = st.executeQuery(sql);
|
|
|
|
|
rs.first();
|
|
|
|
|
Integer newId = new Integer(rs.getInt("MAXCONTROLEID"));
|
|
|
|
|
if(newId.intValue() == 0 )
|
|
|
|
|
{
|
|
|
|
|
newId = new Integer(1);
|
|
|
|
|
}
|
|
|
|
|
return newId;
|
|
|
|
|
}
|
|
|
|
|
catch(Exception ex)
|
|
|
|
|
{
|
|
|
|
|
return new Integer(1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Integer getMaxAnaliseId()
|
|
|
|
|
{
|
|
|
|
|
@ -1251,7 +1307,7 @@ public class AnalisesDataProvider {
|
|
|
|
|
|
|
|
|
|
public AnaliseAcidente createAnalise(AnaliseAcidente a) throws Exception
|
|
|
|
|
{
|
|
|
|
|
Controle c = getControle();
|
|
|
|
|
//Controle c = getControle();
|
|
|
|
|
Statement st = createStatement();
|
|
|
|
|
Integer newId = getMaxAnaliseId();
|
|
|
|
|
|
|
|
|
|
@ -1262,6 +1318,11 @@ public class AnalisesDataProvider {
|
|
|
|
|
//cal.setTime(now);
|
|
|
|
|
cal.setTime(data_acidente);
|
|
|
|
|
int ano = cal.get(Calendar.YEAR);
|
|
|
|
|
Controle c = getControloByAno(new Integer(ano));
|
|
|
|
|
if(c == null)
|
|
|
|
|
{
|
|
|
|
|
c = createAnoNumeracao(new Integer(ano));
|
|
|
|
|
}
|
|
|
|
|
// if(c.getAnalise_year().intValue() != ano)
|
|
|
|
|
// {
|
|
|
|
|
// c.setAnalise_year(new Integer(ano));
|
|
|
|
|
@ -1674,7 +1735,9 @@ public class AnalisesDataProvider {
|
|
|
|
|
|
|
|
|
|
return newId;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void updateMedida(Medida m) throws Exception
|
|
|
|
|
{
|
|
|
|
|
Statement st = createStatement();
|
|
|
|
|
|