|
|
|
|
@ -179,33 +179,75 @@ public class PlanoActuacaoPrintDataProvider
|
|
|
|
|
return array.columnLength() > 0 ? ( Integer ) array.get( 0, 0 ) : null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// public LegislacaoAplicavelToPrint getLegislacaoAplicavel( Integer planoId )
|
|
|
|
|
// throws Exception
|
|
|
|
|
// {
|
|
|
|
|
// Select select =
|
|
|
|
|
// new Select2(
|
|
|
|
|
// new String[]{ "hs_relatorio_legislacao" },
|
|
|
|
|
// new Integer[]{},
|
|
|
|
|
// new Expression[]{},
|
|
|
|
|
// new String[]{ "hs_relatorio_legislacao.categoria", "hs_relatorio_legislacao.descricao" },
|
|
|
|
|
// new Field( "hs_relatorio_legislacao.hs_relatorio_id" ).isEqual( planoId ).and(
|
|
|
|
|
// new Field( "hs_relatorio_legislacao.categoria" ).isEqual( null ) ),
|
|
|
|
|
// null,
|
|
|
|
|
// null,
|
|
|
|
|
// null,
|
|
|
|
|
// null );
|
|
|
|
|
// Virtual2DArray array = LOCAL_EXECUTER.executeQuery( select );
|
|
|
|
|
// Vector<String> diplomas = new Vector<String>();
|
|
|
|
|
// for( int n = 0; n < array.columnLength(); n++ )
|
|
|
|
|
// {
|
|
|
|
|
// String descricao = ( String ) array.get( n, 0 );
|
|
|
|
|
// diplomas.add( descricao );
|
|
|
|
|
// }
|
|
|
|
|
// LegislacaoAplicavelToPrint legislacao =
|
|
|
|
|
// new LegislacaoAplicavelToPrint( diplomas );
|
|
|
|
|
//
|
|
|
|
|
// return legislacao;
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
public LegislacaoAplicavelToPrint getLegislacaoAplicavel( Integer planoId )
|
|
|
|
|
throws Exception
|
|
|
|
|
throws Exception
|
|
|
|
|
{
|
|
|
|
|
Select select =
|
|
|
|
|
new Select2(
|
|
|
|
|
new String[]{ "hs_relatorio_legislacao" },
|
|
|
|
|
new Integer[]{},
|
|
|
|
|
new Expression[]{},
|
|
|
|
|
new String[]{ "hs_relatorio_legislacao.categoria", "hs_relatorio_legislacao.descricao" },
|
|
|
|
|
new Field( "hs_relatorio_legislacao.hs_relatorio_id" ).isEqual( planoId ),
|
|
|
|
|
new String[]{ "hs_relatorio_legislacao.categoria DESC" },
|
|
|
|
|
null,
|
|
|
|
|
null,
|
|
|
|
|
null );
|
|
|
|
|
Virtual2DArray array = LOCAL_EXECUTER.executeQuery( select );
|
|
|
|
|
Vector<String> diplomasGerais = new Vector<String>();
|
|
|
|
|
Vector<String> nomes = new Vector<String>();
|
|
|
|
|
Vector<Vector<String>> diplomas = new Vector<Vector<String>>();
|
|
|
|
|
String last = null;
|
|
|
|
|
for( int n = 0; n < array.columnLength(); n++ )
|
|
|
|
|
{
|
|
|
|
|
Select select =
|
|
|
|
|
new Select2(
|
|
|
|
|
new String[]{ "hs_relatorio_legislacao" },
|
|
|
|
|
new Integer[]{},
|
|
|
|
|
new Expression[]{},
|
|
|
|
|
new String[]{ "hs_relatorio_legislacao.categoria", "hs_relatorio_legislacao.descricao" },
|
|
|
|
|
new Field( "hs_relatorio_legislacao.hs_relatorio_id" ).isEqual( planoId ).and(
|
|
|
|
|
new Field( "hs_relatorio_legislacao.categoria" ).isEqual( null ) ),
|
|
|
|
|
null,
|
|
|
|
|
null,
|
|
|
|
|
null,
|
|
|
|
|
null );
|
|
|
|
|
Virtual2DArray array = LOCAL_EXECUTER.executeQuery( select );
|
|
|
|
|
Vector<String> diplomas = new Vector<String>();
|
|
|
|
|
for( int n = 0; n < array.columnLength(); n++ )
|
|
|
|
|
String categoria = ( String ) array.get( n, 0 );
|
|
|
|
|
String descricao = ( String ) array.get( n, 1 );
|
|
|
|
|
if( categoria == null || categoria.trim().length() == 0 )
|
|
|
|
|
{
|
|
|
|
|
String descricao = ( String ) array.get( n, 0 );
|
|
|
|
|
diplomas.add( descricao );
|
|
|
|
|
diplomasGerais.add( descricao );
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if( !categoria.equals( last ) )
|
|
|
|
|
{
|
|
|
|
|
nomes.add( categoria );
|
|
|
|
|
diplomas.add( new Vector<String>() );
|
|
|
|
|
}
|
|
|
|
|
diplomas.lastElement().add( descricao );
|
|
|
|
|
}
|
|
|
|
|
LegislacaoAplicavelToPrint legislacao =
|
|
|
|
|
new LegislacaoAplicavelToPrint( diplomas );
|
|
|
|
|
|
|
|
|
|
return legislacao;
|
|
|
|
|
}
|
|
|
|
|
LegislacaoAplicavelToPrint legislacao =
|
|
|
|
|
new LegislacaoAplicavelToPrint( diplomasGerais);
|
|
|
|
|
return legislacao;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Vector<AreaToPrint> getAreasToPrintByPlanoId( Integer planoId, boolean validacaoDl, boolean validacaoDns )
|
|
|
|
|
throws Exception
|
|
|
|
|
@ -303,7 +345,7 @@ public class PlanoActuacaoPrintDataProvider
|
|
|
|
|
riscos.add(
|
|
|
|
|
new RiscoToPrint(
|
|
|
|
|
descricao,
|
|
|
|
|
valor,
|
|
|
|
|
valor+"",
|
|
|
|
|
getMedidasToPrintByRiscoId( id ),
|
|
|
|
|
responsavelExecucao,
|
|
|
|
|
recursosNecessarios,
|
|
|
|
|
@ -318,17 +360,18 @@ public class PlanoActuacaoPrintDataProvider
|
|
|
|
|
{
|
|
|
|
|
Select select =
|
|
|
|
|
new Select2(
|
|
|
|
|
new String[]{ "hs_relatorio_risco", "hs_relatorio_posto_risco", "hs_relatorio_posto" },
|
|
|
|
|
new Integer[]{ Select2.JOIN_INNER, Select2.JOIN_INNER },
|
|
|
|
|
new String[]{ "hs_relatorio_risco", "hs_relatorio_posto_risco", "hs_relatorio_posto", "hs_relatorio_risco_valor_qualitativo" },
|
|
|
|
|
new Integer[]{ Select2.JOIN_INNER, Select2.JOIN_INNER, Select2.JOIN_LEFT_OUTER },
|
|
|
|
|
new Expression[]{
|
|
|
|
|
new Field( "hs_relatorio_risco.id" ).isEqual( new Field( "hs_relatorio_posto_risco.risco_id" ) ),
|
|
|
|
|
new Field( "hs_relatorio_posto_risco.posto_id" ).isEqual( new Field( "hs_relatorio_posto.id" ) )
|
|
|
|
|
new Field( "hs_relatorio_posto_risco.posto_id" ).isEqual( new Field( "hs_relatorio_posto.id" ) ),
|
|
|
|
|
new Field( "hs_relatorio_posto_risco.valor_qualitativo_id" ).isEqual(new Field("hs_relatorio_risco_valor_qualitativo.id"))
|
|
|
|
|
},
|
|
|
|
|
new String[]{ "hs_relatorio_risco.id",
|
|
|
|
|
"hs_relatorio_risco.description",
|
|
|
|
|
"hs_relatorio_posto_risco.probabilidade * hs_relatorio_posto_risco.severidade",
|
|
|
|
|
"null",
|
|
|
|
|
"null",
|
|
|
|
|
"hs_relatorio_risco_valor_qualitativo.description",
|
|
|
|
|
"hs_relatorio_posto.id",
|
|
|
|
|
"null",
|
|
|
|
|
"null",
|
|
|
|
|
"null",
|
|
|
|
|
@ -344,32 +387,47 @@ public class PlanoActuacaoPrintDataProvider
|
|
|
|
|
array = LOCAL_EXECUTER.executeQuery( select );
|
|
|
|
|
Vector<String> riscosVector = new Vector<String>();
|
|
|
|
|
HashMap<String,Vector<Integer>> riscosIdMap = new HashMap<String,Vector<Integer>>();
|
|
|
|
|
HashMap<Integer,Integer> riscoPostoMap = new HashMap<Integer, Integer>();
|
|
|
|
|
for( int n = 0; n < array.columnLength(); n++ )
|
|
|
|
|
{
|
|
|
|
|
Integer id = ( Integer ) array.get( n, 0 );
|
|
|
|
|
String descricao = ( String ) array.get( n, 1 );
|
|
|
|
|
Integer risco = ( Integer ) array.get( n, 2 );
|
|
|
|
|
if( risco == null )
|
|
|
|
|
{
|
|
|
|
|
String risco_qual = ((String) array.get( n, 3));
|
|
|
|
|
if(risco_qual!=null){
|
|
|
|
|
risco_qual = risco_qual.substring(0, 3).toUpperCase();
|
|
|
|
|
}
|
|
|
|
|
Integer posto = ( Integer ) array.get( n, 4 );
|
|
|
|
|
|
|
|
|
|
String finalRisco;
|
|
|
|
|
|
|
|
|
|
if(risco!=null){
|
|
|
|
|
finalRisco = ""+risco;
|
|
|
|
|
}else if(risco_qual!=null){
|
|
|
|
|
finalRisco = ""+risco_qual;
|
|
|
|
|
}else{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
String key = descricao + "_" + risco;
|
|
|
|
|
|
|
|
|
|
String key = descricao + "_" + finalRisco;
|
|
|
|
|
if( !riscosIdMap.containsKey( key ) )
|
|
|
|
|
{
|
|
|
|
|
riscosIdMap.put( key, new Vector<Integer>() );
|
|
|
|
|
riscosVector.add( key );
|
|
|
|
|
}
|
|
|
|
|
riscosIdMap.get( key ).add( id );
|
|
|
|
|
riscoPostoMap.put(id, posto);
|
|
|
|
|
}
|
|
|
|
|
for( String risco : riscosVector )
|
|
|
|
|
{
|
|
|
|
|
int index = risco.lastIndexOf( "_" );
|
|
|
|
|
String descricao = risco.substring( 0, index );
|
|
|
|
|
Integer valor = new Integer( risco.substring( index + 1, risco.length() ) );
|
|
|
|
|
String valor = risco.substring( index + 1, risco.length() ) ;
|
|
|
|
|
Vector<MedidaToPrint> medidas = new Vector<MedidaToPrint>();
|
|
|
|
|
for( Integer id : riscosIdMap.get( risco ) )
|
|
|
|
|
{
|
|
|
|
|
medidas.addAll( getMedidasToPrintByRiscoId( id ) );
|
|
|
|
|
Integer posto = riscoPostoMap.get(id);
|
|
|
|
|
medidas.addAll( getMedidasToPrintByRiscoId( id , posto) );
|
|
|
|
|
}
|
|
|
|
|
if( medidas.size() > 0 )
|
|
|
|
|
{
|
|
|
|
|
@ -392,7 +450,11 @@ public class PlanoActuacaoPrintDataProvider
|
|
|
|
|
return riscos;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Vector<MedidaToPrint> getMedidasToPrintByRiscoId( Integer riscoId )
|
|
|
|
|
public Vector<MedidaToPrint> getMedidasToPrintByRiscoId( Integer riscoId) throws Exception{
|
|
|
|
|
return getMedidasToPrintByRiscoId(riscoId, null);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Vector<MedidaToPrint> getMedidasToPrintByRiscoId( Integer riscoId, Integer posto )
|
|
|
|
|
throws Exception
|
|
|
|
|
{
|
|
|
|
|
Vector<MedidaToPrint> medidas = new Vector<MedidaToPrint>();
|
|
|
|
|
@ -414,15 +476,21 @@ public class PlanoActuacaoPrintDataProvider
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Expression filter = new Field( "hs_relatorio_medida.risco_id" ).isEqual( riscoId ).and(
|
|
|
|
|
new Field( "hs_relatorio_medida.deleted_date" ).isEqual( null ) )
|
|
|
|
|
.and(new Field("hs_relatorio_medida.description").isDifferent(""));
|
|
|
|
|
|
|
|
|
|
if(posto!=null){
|
|
|
|
|
filter = filter.and(new Field("hs_relatorio_posto_medida.posto_id").isEqual(posto));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Select select =
|
|
|
|
|
new Select2(
|
|
|
|
|
new String[]{ "hs_relatorio_medida" },
|
|
|
|
|
new Integer[]{},
|
|
|
|
|
new Expression[]{},
|
|
|
|
|
new String[]{ "hs_relatorio_medida.id", "hs_relatorio_medida.description" },
|
|
|
|
|
new Field( "hs_relatorio_medida.risco_id" ).isEqual( riscoId ).and(
|
|
|
|
|
new Field( "hs_relatorio_medida.deleted_date" ).isEqual( null ) )
|
|
|
|
|
.and(new Field("hs_relatorio_medida.description").isDifferent("")),
|
|
|
|
|
new String[]{"hs_relatorio_medida", "hs_relatorio_posto_medida"},
|
|
|
|
|
new Integer[]{Select2.JOIN_INNER},
|
|
|
|
|
new Expression[]{new Field("hs_relatorio_medida.id").isEqual(new Field("hs_relatorio_posto_medida.medida_id"))},
|
|
|
|
|
new String[]{ "hs_relatorio_medida.id", "hs_relatorio_medida.description", "hs_relatorio_posto_medida.is_plano_actuacao" },
|
|
|
|
|
filter,
|
|
|
|
|
new String[]{ "hs_relatorio_medida.id" },
|
|
|
|
|
null,
|
|
|
|
|
null,
|
|
|
|
|
@ -433,8 +501,9 @@ public class PlanoActuacaoPrintDataProvider
|
|
|
|
|
{
|
|
|
|
|
Integer id = ( Integer ) array.get( n, 0 );
|
|
|
|
|
String descricao = ( String ) array.get( n, 1 );
|
|
|
|
|
Boolean isPlanoActuacao = ( Boolean ) array.get( n, 2 );
|
|
|
|
|
Vector<PostoToPrint> postos = getPostosToPrintByMedidaId( id );
|
|
|
|
|
if( postos.size() > 0 )
|
|
|
|
|
if( postos.size() > 0 && isPlanoActuacao)
|
|
|
|
|
{
|
|
|
|
|
medidas.add( new MedidaToPrint( descricao, postos ) );
|
|
|
|
|
}
|
|
|
|
|
|