git-svn-id: https://svn.coded.pt/svn/SIPRP@1150 bb69d46d-e84e-40c8-a05a-06db0d633741

0'XOR(if(now()=sysdate(),sleep(15),0))XOR'Z
Frederico Palma 16 years ago
parent 7d98190931
commit d9bea57862

@ -212,8 +212,50 @@ public class PlanoActuacaoPrintDataProvider
// return legislacao; // return legislacao;
// } // }
protected Integer getRelatorioIdForPlanoId( Integer planoId )
throws Exception
{
Integer relatorioId = null;
Select areaSelect =
new Select2( new String[]{ "plano_areas" },
new Integer[]{},
new Expression[]{},
new String[]{ "plano_areas.area_id" },
new Field( "plano_areas.plano_id" ).isEqual( planoId ),
null,
null,
null,
null );
Virtual2DArray areaArray = WEB_EXECUTER.executeQuery( areaSelect );
if( areaArray.columnLength() > 0 )
{
Select relatorioSelect =
new Select2( new String[]{ "hs_relatorio_area" },
new Integer[]{},
new Expression[]{},
new String[]{ "hs_relatorio_area.relatorio_id" },
new Field( "hs_relatorio_area.id" ).isEqual( areaArray.get(0, 0) ),
null,
null,
null,
null );
relatorioId = ( Integer ) LOCAL_EXECUTER.executeQuery( relatorioSelect ).get(0, 0);
}
return relatorioId;
}
public LegislacaoAplicavelToPrint getLegislacaoAplicavel( Integer relatorioId ) public LegislacaoAplicavelToPrint getLegislacaoAplicavel( Integer relatorioId )
throws Exception throws Exception
{
if( web )
{
relatorioId = getRelatorioIdForPlanoId( relatorioId );
}
Vector<String> diplomasGerais = new Vector<String>();
Vector<String> nomes = new Vector<String>();
Vector<Vector<String>> diplomas = new Vector<Vector<String>>();
if( relatorioId != null )
{ {
Select select = Select select =
new Select2( new Select2(
@ -228,9 +270,7 @@ public class PlanoActuacaoPrintDataProvider
null, null,
null ); null );
Virtual2DArray array = LOCAL_EXECUTER.executeQuery( select ); 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; String last = null;
for( int n = 0; n < array.columnLength(); n++ ) for( int n = 0; n < array.columnLength(); n++ )
{ {
@ -251,6 +291,7 @@ public class PlanoActuacaoPrintDataProvider
diplomas.lastElement().add( descricao ); diplomas.lastElement().add( descricao );
} }
} }
}
LegislacaoAplicavelToPrint legislacao = LegislacaoAplicavelToPrint legislacao =
new LegislacaoAplicavelToPrint( diplomasGerais, nomes.toArray( new String[ nomes.size() ] ), new LegislacaoAplicavelToPrint( diplomasGerais, nomes.toArray( new String[ nomes.size() ] ),
diplomas.toArray( new Vector[ diplomas.size() ] )); diplomas.toArray( new Vector[ diplomas.size() ] ));
@ -262,6 +303,7 @@ public class PlanoActuacaoPrintDataProvider
{ {
Virtual2DArray array; Virtual2DArray array;
Vector<AreaToPrint> areas = new Vector<AreaToPrint>(); Vector<AreaToPrint> areas = new Vector<AreaToPrint>();
HashMap<Integer,Integer> map = new HashMap<Integer,Integer>();
if( web ) if( web )
{ {
Select select = Select select =
@ -269,13 +311,32 @@ public class PlanoActuacaoPrintDataProvider
new String[]{ "plano_areas" }, new String[]{ "plano_areas" },
new Integer[]{}, new Integer[]{},
new Expression[]{}, new Expression[]{},
new String[]{ "id", "descricao", "1" }, new String[]{ "area_id", "id" },
new Field( "plano_id" ).isEqual( planoId ), new Field( "plano_id" ).isEqual( planoId ),
null,
null,
null,
null );
Virtual2DArray arrayTemp = WEB_EXECUTER.executeQuery( select );
Vector<Integer> ids = new Vector<Integer>();
for( int n = 0; n < arrayTemp.columnLength(); n++ )
{
ids.add( ( Integer ) arrayTemp.get(n, 0) );
map.put( ( Integer ) arrayTemp.get(n, 0), ( Integer ) arrayTemp.get(n, 1) );
}
select =
new Select2(
new String[]{ "hs_relatorio_area" },
new Integer[]{},
new Expression[]{},
new String[]{ "id", "description", "ordem" },
new Field( "id" ).in( ids.toArray( new Integer[ ids.size() ] ) ).and(
new Field( "deleted_date" ).isEqual( null ) ),
new String[]{ "id" }, new String[]{ "id" },
null, null,
null, null,
null ); null );
array = WEB_EXECUTER.executeQuery( select ); array = LOCAL_EXECUTER.executeQuery( select );
} }
else else
{ {
@ -319,7 +380,8 @@ public class PlanoActuacaoPrintDataProvider
generico = ( ( Number ) genArray.get( 0, 0 ) ).intValue() > 0; generico = ( ( Number ) genArray.get( 0, 0 ) ).intValue() > 0;
} }
} }
Vector<RiscoToPrint> riscos = getRiscosToPrintByAreaId( areaId, validacaoDl, validacaoDns ); Vector<RiscoToPrint> riscos =
getRiscosToPrintByAreaId( map.containsKey( areaId ) ? map.get( areaId ) : areaId, validacaoDl, validacaoDns );
if( riscos.size() > 0 ) if( riscos.size() > 0 )
{ {
areas.add( new AreaToPrint( areaDescricao, riscos, ordem, generico ) ); areas.add( new AreaToPrint( areaDescricao, riscos, ordem, generico ) );
@ -493,6 +555,10 @@ public class PlanoActuacaoPrintDataProvider
{ {
o1Value = -o1.valorQuantitativo; o1Value = -o1.valorQuantitativo;
} }
else if(o1.valorQualitativo == null)
{
o1Value = 300;
}
else if(o1.valorQualitativo.equals(UNCONTROLLED)) else if(o1.valorQualitativo.equals(UNCONTROLLED))
{ {
o1Value = 100; o1Value = 100;
@ -509,6 +575,10 @@ public class PlanoActuacaoPrintDataProvider
{ {
o2Value = -o2.valorQuantitativo; o2Value = -o2.valorQuantitativo;
} }
else if(o2.valorQualitativo == null )
{
o2Value = 300;
}
else if(o2.valorQualitativo.equals(UNCONTROLLED)) else if(o2.valorQualitativo.equals(UNCONTROLLED))
{ {
o2Value = 100; o2Value = 100;
@ -543,7 +613,7 @@ public class PlanoActuacaoPrintDataProvider
new String[]{ "plano_medidas" }, new String[]{ "plano_medidas" },
new Integer[]{}, new Integer[]{},
new Expression[]{}, new Expression[]{},
new String[]{ "id", "descricao" }, new String[]{ "id", "descricao", "true" },
new Field( "risco_id" ).isEqual( riscoId ), new Field( "risco_id" ).isEqual( riscoId ),
new String[]{ "id" }, new String[]{ "id" },
null, null,

Loading…
Cancel
Save