diff --git a/trunk/SIPRPSoft/src/siprp/planoactuacao/print/PlanoActuacaoPrintDataProvider.java b/trunk/SIPRPSoft/src/siprp/planoactuacao/print/PlanoActuacaoPrintDataProvider.java index 5325ff0e..da53be1e 100644 --- a/trunk/SIPRPSoft/src/siprp/planoactuacao/print/PlanoActuacaoPrintDataProvider.java +++ b/trunk/SIPRPSoft/src/siprp/planoactuacao/print/PlanoActuacaoPrintDataProvider.java @@ -212,43 +212,84 @@ public class PlanoActuacaoPrintDataProvider // 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 ) 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", - "COALESCE(hs_relatorio_legislacao.categoria,'A')"}, - new Field( "hs_relatorio_legislacao.hs_relatorio_id" ).isEqual( relatorioId ), - new String[]{ "COALESCE(hs_relatorio_legislacao.categoria,'A')", "ordem" }, - null, - null, - null ); - Virtual2DArray array = LOCAL_EXECUTER.executeQuery( select ); + if( web ) + { + relatorioId = getRelatorioIdForPlanoId( relatorioId ); + } Vector diplomasGerais = new Vector(); Vector nomes = new Vector(); Vector> diplomas = new Vector>(); - String last = null; - for( int n = 0; n < array.columnLength(); n++ ) + if( relatorioId != null ) { - String categoria = ( String ) array.get( n, 0 ); - String descricao = ( String ) array.get( n, 1 ); - if( categoria == null || categoria.trim().length() == 0 ) - { - diplomasGerais.add( descricao ); - } - else + Select select = + new Select2( + new String[]{ "hs_relatorio_legislacao" }, + new Integer[]{}, + new Expression[]{}, + new String[]{ "hs_relatorio_legislacao.categoria", "hs_relatorio_legislacao.descricao", + "COALESCE(hs_relatorio_legislacao.categoria,'A')"}, + new Field( "hs_relatorio_legislacao.hs_relatorio_id" ).isEqual( relatorioId ), + new String[]{ "COALESCE(hs_relatorio_legislacao.categoria,'A')", "ordem" }, + null, + null, + null ); + Virtual2DArray array = LOCAL_EXECUTER.executeQuery( select ); + + String last = null; + for( int n = 0; n < array.columnLength(); n++ ) { - if( !categoria.equals( last ) ) + String categoria = ( String ) array.get( n, 0 ); + String descricao = ( String ) array.get( n, 1 ); + if( categoria == null || categoria.trim().length() == 0 ) + { + diplomasGerais.add( descricao ); + } + else { - nomes.add( categoria ); - diplomas.add( new Vector() ); + if( !categoria.equals( last ) ) + { + nomes.add( categoria ); + diplomas.add( new Vector() ); + } + last = categoria; + diplomas.lastElement().add( descricao ); } - last = categoria; - diplomas.lastElement().add( descricao ); } } LegislacaoAplicavelToPrint legislacao = @@ -262,6 +303,7 @@ public class PlanoActuacaoPrintDataProvider { Virtual2DArray array; Vector areas = new Vector(); + HashMap map = new HashMap(); if( web ) { Select select = @@ -269,13 +311,32 @@ public class PlanoActuacaoPrintDataProvider new String[]{ "plano_areas" }, new Integer[]{}, new Expression[]{}, - new String[]{ "id", "descricao", "1" }, + new String[]{ "area_id", "id" }, new Field( "plano_id" ).isEqual( planoId ), + null, + null, + null, + null ); + Virtual2DArray arrayTemp = WEB_EXECUTER.executeQuery( select ); + Vector ids = new Vector(); + 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" }, null, null, null ); - array = WEB_EXECUTER.executeQuery( select ); + array = LOCAL_EXECUTER.executeQuery( select ); } else { @@ -319,7 +380,8 @@ public class PlanoActuacaoPrintDataProvider generico = ( ( Number ) genArray.get( 0, 0 ) ).intValue() > 0; } } - Vector riscos = getRiscosToPrintByAreaId( areaId, validacaoDl, validacaoDns ); + Vector riscos = + getRiscosToPrintByAreaId( map.containsKey( areaId ) ? map.get( areaId ) : areaId, validacaoDl, validacaoDns ); if( riscos.size() > 0 ) { areas.add( new AreaToPrint( areaDescricao, riscos, ordem, generico ) ); @@ -493,6 +555,10 @@ public class PlanoActuacaoPrintDataProvider { o1Value = -o1.valorQuantitativo; } + else if(o1.valorQualitativo == null) + { + o1Value = 300; + } else if(o1.valorQualitativo.equals(UNCONTROLLED)) { o1Value = 100; @@ -509,6 +575,10 @@ public class PlanoActuacaoPrintDataProvider { o2Value = -o2.valorQuantitativo; } + else if(o2.valorQualitativo == null ) + { + o2Value = 300; + } else if(o2.valorQualitativo.equals(UNCONTROLLED)) { o2Value = 100; @@ -543,7 +613,7 @@ public class PlanoActuacaoPrintDataProvider new String[]{ "plano_medidas" }, new Integer[]{}, new Expression[]{}, - new String[]{ "id", "descricao" }, + new String[]{ "id", "descricao", "true" }, new Field( "risco_id" ).isEqual( riscoId ), new String[]{ "id" }, null,