|
|
|
@ -6,6 +6,8 @@
|
|
|
|
package db.providers;
|
|
|
|
package db.providers;
|
|
|
|
|
|
|
|
|
|
|
|
import com.evolute.utils.error.ErrorLogger;
|
|
|
|
import com.evolute.utils.error.ErrorLogger;
|
|
|
|
|
|
|
|
import db.data.siprp_local.outer.EmpresasData;
|
|
|
|
|
|
|
|
import db.data.siprp_local.outer.ImageData;
|
|
|
|
import db.entidades.Area;
|
|
|
|
import db.entidades.Area;
|
|
|
|
import db.entidades.Medida;
|
|
|
|
import db.entidades.Medida;
|
|
|
|
import db.entidades.PlanoActuacao;
|
|
|
|
import db.entidades.PlanoActuacao;
|
|
|
|
@ -48,7 +50,7 @@ public class RelatoriosDataProvider extends GenericDataProvider
|
|
|
|
{
|
|
|
|
{
|
|
|
|
try
|
|
|
|
try
|
|
|
|
{
|
|
|
|
{
|
|
|
|
plano = getAreasByPlano(plano, relatorioId);
|
|
|
|
plano = getAreasByPlano(plano, relatorioId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch(Exception ex)
|
|
|
|
catch(Exception ex)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
@ -57,24 +59,23 @@ public class RelatoriosDataProvider extends GenericDataProvider
|
|
|
|
|
|
|
|
|
|
|
|
return plano;
|
|
|
|
return plano;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private PlanoActuacao getAreasByPlano(PlanoActuacao plano, Integer relatorioId) throws Exception
|
|
|
|
private PlanoActuacao getAreasByPlano( PlanoActuacao plano, Integer relatorioID ) throws Exception
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// Statement st = dblocal.createStatement();
|
|
|
|
|
|
|
|
Statement st = createLocalStatement();
|
|
|
|
Statement st = createLocalStatement();
|
|
|
|
|
|
|
|
|
|
|
|
String sql = "select distinct area_id, hs_relatorio_area.description as descricao from hs_relatorio_posto ";
|
|
|
|
String sql = "select distinct area_id, hs_relatorio_area.description as descricao from hs_relatorio_posto ";
|
|
|
|
sql += "inner join hs_relatorio_posto_medida on hs_relatorio_posto_medida.posto_id = hs_relatorio_posto.id ";
|
|
|
|
sql += "inner join hs_relatorio_posto_medida on hs_relatorio_posto_medida.posto_id = hs_relatorio_posto.id ";
|
|
|
|
sql += "inner join hs_relatorio_medida on hs_relatorio_medida.id = hs_relatorio_posto_medida.medida_id ";
|
|
|
|
sql += "inner join hs_relatorio_medida on hs_relatorio_medida.id = hs_relatorio_posto_medida.medida_id ";
|
|
|
|
sql += "inner join hs_relatorio_risco on hs_relatorio_risco.id = hs_relatorio_medida.risco_id ";
|
|
|
|
sql += "inner join hs_relatorio_risco on hs_relatorio_risco.id = hs_relatorio_medida.risco_id ";
|
|
|
|
sql += "inner join hs_relatorio on hs_relatorio.id = hs_relatorio_risco.relatorio_id ";
|
|
|
|
sql += "inner join hs_relatorio on hs_relatorio.id = hs_relatorio_risco.relatorio_id ";
|
|
|
|
sql += "inner join hs_relatorio_area on hs_relatorio_area.id = area_id ";
|
|
|
|
sql += "inner join hs_relatorio_area on hs_relatorio_area.id = area_id ";
|
|
|
|
sql += "where hs_relatorio.id = " + relatorioId + " ";
|
|
|
|
sql += "where hs_relatorio.id = " + relatorioID + " ";
|
|
|
|
sql += "order by area_id ";
|
|
|
|
sql += "order by area_id ";
|
|
|
|
System.out.println("AREAS BY PLANO SQL : " + sql);
|
|
|
|
System.out.println("AREAS BY PLANO SQL : " + sql);
|
|
|
|
ResultSet rs = st.executeQuery(sql);
|
|
|
|
ResultSet rs = st.executeQuery(sql);
|
|
|
|
|
|
|
|
|
|
|
|
List<Area> areas = new ArrayList();
|
|
|
|
List<Area> areas = new ArrayList();
|
|
|
|
if(rs.isBeforeFirst())
|
|
|
|
if(rs.isBeforeFirst())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
rs.first();
|
|
|
|
rs.first();
|
|
|
|
@ -88,20 +89,20 @@ public class RelatoriosDataProvider extends GenericDataProvider
|
|
|
|
a.setDescricao(Utils.unicodeToHTML(rs.getString("descricao")));
|
|
|
|
a.setDescricao(Utils.unicodeToHTML(rs.getString("descricao")));
|
|
|
|
try
|
|
|
|
try
|
|
|
|
{
|
|
|
|
{
|
|
|
|
a.setRiscos(getRiscosByArea(a));
|
|
|
|
a.setRiscos(getRiscosByArea(a));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch(Exception ex)
|
|
|
|
catch(Exception ex)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
System.out.println("ERRO RISCOS BY AREA !!!!");
|
|
|
|
System.out.println("ERRO RISCOS BY AREA !!!!");
|
|
|
|
ErrorLogger.logException( ex );
|
|
|
|
ErrorLogger.logException( ex );
|
|
|
|
a.setRiscos(null);
|
|
|
|
a.setRiscos(null);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
areas.add(a);
|
|
|
|
areas.add(a);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}while(rs.next());
|
|
|
|
}while(rs.next());
|
|
|
|
plano.setAreas(areas);
|
|
|
|
plano.setAreas(areas);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return plano;
|
|
|
|
return plano;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -416,45 +417,72 @@ public class RelatoriosDataProvider extends GenericDataProvider
|
|
|
|
|
|
|
|
|
|
|
|
public String getEmpresaNome(Integer empresa_id) throws Exception
|
|
|
|
public String getEmpresaNome(Integer empresa_id) throws Exception
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// Statement st = dblocal.createStatement();
|
|
|
|
String nome = "";
|
|
|
|
Statement st = createLocalStatement();
|
|
|
|
EmpresasData empresaData = getLocalProvider().load( EmpresasData.class, empresa_id, EmpresasData.ID );
|
|
|
|
|
|
|
|
if ( empresaData != null )
|
|
|
|
String sql ="SELECT designacao_social FROM empresas WHERE id = " + empresa_id;
|
|
|
|
{
|
|
|
|
ResultSet rslocal = st.executeQuery(sql);
|
|
|
|
nome = Utils.unicodeToHTML( empresaData.getDesignacao_social() );
|
|
|
|
rslocal.first();
|
|
|
|
}
|
|
|
|
String nome = Utils.unicodeToHTML(rslocal.getString("designacao_social"));
|
|
|
|
return nome;
|
|
|
|
return nome;
|
|
|
|
|
|
|
|
|
|
|
|
// Statement st = createLocalStatement();
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// String sql ="SELECT designacao_social FROM empresas WHERE id = " + empresa_id;
|
|
|
|
|
|
|
|
// ResultSet rslocal = st.executeQuery(sql);
|
|
|
|
|
|
|
|
// rslocal.first();
|
|
|
|
|
|
|
|
// String nome = Utils.unicodeToHTML(rslocal.getString("designacao_social"));
|
|
|
|
|
|
|
|
// return nome;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public byte[] getLogoByEmpresa( Integer empresaId )
|
|
|
|
public byte[] getLogoByEmpresa( Integer empresaId )
|
|
|
|
throws Exception
|
|
|
|
throws Exception
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// Statement st = dblocal.createStatement();
|
|
|
|
byte[] logo = null;
|
|
|
|
Statement st = createLocalStatement();
|
|
|
|
EmpresasData empresaData = getLocalProvider().load( EmpresasData.class, empresaId, EmpresasData.ID );
|
|
|
|
|
|
|
|
if ( empresaData != null )
|
|
|
|
String sql = "select empresa_logo_id from empresas where id = " + empresaId;
|
|
|
|
{
|
|
|
|
ResultSet rslocal = st.executeQuery(sql);
|
|
|
|
Integer logoID = empresaData.getEmpresa_logo_id();
|
|
|
|
if ( rslocal.isBeforeFirst() )
|
|
|
|
logo = getLogo( logoID );
|
|
|
|
{
|
|
|
|
}
|
|
|
|
rslocal.first();
|
|
|
|
return logo;
|
|
|
|
Integer logoId = new Integer( rslocal.getInt("empresa_logo_id") );
|
|
|
|
|
|
|
|
byte[] logo = getLogo( logoId );
|
|
|
|
|
|
|
|
return logo;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
// Statement st = createLocalStatement();
|
|
|
|
}
|
|
|
|
//
|
|
|
|
|
|
|
|
// String sql = "select empresa_logo_id from empresas where id = " + empresaId;
|
|
|
|
public byte[] getLogo(Integer logoId) throws Exception
|
|
|
|
// ResultSet rslocal = st.executeQuery(sql);
|
|
|
|
{
|
|
|
|
// if ( rslocal.isBeforeFirst() )
|
|
|
|
// Statement st = dblocal.createStatement();
|
|
|
|
// {
|
|
|
|
Statement st = createLocalStatement();
|
|
|
|
// rslocal.first();
|
|
|
|
|
|
|
|
// Integer logoId = new Integer( rslocal.getInt("empresa_logo_id") );
|
|
|
|
String sql = "select image_data from image where id = " + logoId;
|
|
|
|
// byte[] logo = getLogo( logoId );
|
|
|
|
ResultSet rslocal = st.executeQuery(sql);
|
|
|
|
// return logo;
|
|
|
|
rslocal.first();
|
|
|
|
// }
|
|
|
|
byte[] logo = rslocal.getBytes("image_data");
|
|
|
|
//
|
|
|
|
System.out.println("LOGO SIZE : " + logo.length);
|
|
|
|
// return null;
|
|
|
|
return logo;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public byte[] getLogo( Integer logoID ) throws Exception
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
byte[] logo = null;
|
|
|
|
|
|
|
|
ImageData imageData = getLocalProvider().load( ImageData.class, logoID, ImageData.ID );
|
|
|
|
|
|
|
|
if ( imageData != null )
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
logo = imageData.getImage_data();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
System.out.println( "\nRelatoriosDataProvider . getLogo( " + logoID + " ) : " + ( logo == null ? "null" : "size = " + logo.length ) );
|
|
|
|
|
|
|
|
return logo;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// public byte[] getLogo(Integer logoId) throws Exception
|
|
|
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
// Statement st = createLocalStatement();
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// String sql = "select image_data from image where id = " + logoId;
|
|
|
|
|
|
|
|
// ResultSet rslocal = st.executeQuery(sql);
|
|
|
|
|
|
|
|
// rslocal.first();
|
|
|
|
|
|
|
|
// byte[] logo = rslocal.getBytes("image_data");
|
|
|
|
|
|
|
|
// System.out.println("LOGO SIZE : " + logo.length);
|
|
|
|
|
|
|
|
// return logo;
|
|
|
|
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
}
|