diff --git a/trunk/SIPRPSoft/src/siprp/planoactuacao/print/LogotiposDumper.java b/trunk/SIPRPSoft/src/siprp/planoactuacao/print/LogotiposDumper.java index 24ecfbda..b17d26f1 100644 --- a/trunk/SIPRPSoft/src/siprp/planoactuacao/print/LogotiposDumper.java +++ b/trunk/SIPRPSoft/src/siprp/planoactuacao/print/LogotiposDumper.java @@ -18,7 +18,7 @@ public class LogotiposDumper public static void dump( String path ) throws Exception { - Mappable[] logotipos = PlanoActuacaoPrintDataProvider.getProvider().getLogotipos(); + Mappable[] logotipos = PlanoActuacaoPrintDataProvider.getProvider( true ).getLogotipos(); for( Mappable logotipo : logotipos ) { File file = new File( path, "" + logotipo.getID() + ".png" ); diff --git a/trunk/SIPRPSoft/src/siprp/planoactuacao/print/LogotiposImporter.java b/trunk/SIPRPSoft/src/siprp/planoactuacao/print/LogotiposImporter.java index 4d568ace..a74ccac3 100644 --- a/trunk/SIPRPSoft/src/siprp/planoactuacao/print/LogotiposImporter.java +++ b/trunk/SIPRPSoft/src/siprp/planoactuacao/print/LogotiposImporter.java @@ -58,7 +58,7 @@ public class LogotiposImporter } Integer id = new Integer( file.getName().split( "[.]" )[ 0 ] ); - PlanoActuacaoPrintDataProvider.getProvider().updateLogotipo( id, data ); + PlanoActuacaoPrintDataProvider.getProvider( true ).updateLogotipo( id, data ); } } } diff --git a/trunk/SIPRPSoft/src/siprp/planoactuacao/print/PlanoActuacaoPDFCreator.java b/trunk/SIPRPSoft/src/siprp/planoactuacao/print/PlanoActuacaoPDFCreator.java index 996778af..95796971 100644 --- a/trunk/SIPRPSoft/src/siprp/planoactuacao/print/PlanoActuacaoPDFCreator.java +++ b/trunk/SIPRPSoft/src/siprp/planoactuacao/print/PlanoActuacaoPDFCreator.java @@ -12,10 +12,10 @@ import com.evolute.utils.xml.XSLTransformer; public class PlanoActuacaoPDFCreator { - public byte[] createPDF( Integer planoId ) + public byte[] createPDF( Integer planoId, boolean web ) throws Exception { - PlanoActuacaoToPrint plano = PlanoActuacaoPrintDataProvider.getProvider().getPlanoToPrint( planoId ); + PlanoActuacaoToPrint plano = PlanoActuacaoPrintDataProvider.getProvider( web ).getPlanoToPrint( planoId ); Document foDoc = new Document( plano.toJdomElement() ); XMLOutputter outputter = new XMLOutputter(); ByteArrayOutputStream foBaos = new ByteArrayOutputStream(); diff --git a/trunk/SIPRPSoft/src/siprp/planoactuacao/print/PlanoActuacaoPrintDataProvider.java b/trunk/SIPRPSoft/src/siprp/planoactuacao/print/PlanoActuacaoPrintDataProvider.java index 1cff584b..1c88c252 100644 --- a/trunk/SIPRPSoft/src/siprp/planoactuacao/print/PlanoActuacaoPrintDataProvider.java +++ b/trunk/SIPRPSoft/src/siprp/planoactuacao/print/PlanoActuacaoPrintDataProvider.java @@ -29,9 +29,12 @@ public class PlanoActuacaoPrintDataProvider protected final Executer WEB_EXECUTER; protected final Executer LOCAL_EXECUTER; - public PlanoActuacaoPrintDataProvider() + protected final boolean web; + + public PlanoActuacaoPrintDataProvider( boolean web ) throws Exception { + this.web = web; if( Singleton.getInstance( SingletonConstants.WEB_DBMANAGER ) == null ) { PlanoActuacaoDBInit.initDB(); @@ -42,14 +45,14 @@ public class PlanoActuacaoPrintDataProvider LOCAL_EXECUTER = LOCAL_DBMANAGER.getSharedExecuter( this ); } - public static PlanoActuacaoPrintDataProvider getProvider() + public static PlanoActuacaoPrintDataProvider getProvider( boolean web ) throws Exception { synchronized( LOCK ) { if( instance == null ) { - instance = new PlanoActuacaoPrintDataProvider(); + instance = new PlanoActuacaoPrintDataProvider( web ); } } return instance; @@ -58,23 +61,49 @@ public class PlanoActuacaoPrintDataProvider public PlanoActuacaoToPrint getPlanoToPrint( Integer id ) throws Exception { - - Select select = - new Select2( - new String[]{ "planos_actuacao" }, - new Integer[]{}, - new Expression[]{}, - new String[]{ "empresa_id", "nome_empresa", - "estabelecimento_id", "nome_estabelecimento", - "data_relatorio", "data_visita", "observacoes_dl", - "observacoes_dns", "validacao_director_loja", - "validacao_dns" }, - new Field( "id" ).isEqual( id ), - null, - null, - null, - null ); - Virtual2DArray array = WEB_EXECUTER.executeQuery( select ); + Virtual2DArray array; + if( web ) + { + Select select = + new Select2( + new String[]{ "planos_actuacao" }, + new Integer[]{}, + new Expression[]{}, + new String[]{ "empresa_id", "nome_empresa", + "estabelecimento_id", "nome_estabelecimento", + "data_relatorio", "data_visita", "observacoes_dl", + "observacoes_dns", "validacao_director_loja", + "validacao_dns" }, + new Field( "id" ).isEqual( id ), + null, + null, + null, + null ); + array = WEB_EXECUTER.executeQuery( select ); + } + else + { + Select select = + new Select2( + new String[]{ "hs_relatorio", "marcacoes_estabelecimento", "estabelecimentos", "empresas" }, + new Integer[]{ Select2.JOIN_INNER, Select2.JOIN_INNER, Select2.JOIN_INNER }, + new Expression[]{ + new Field( "hs_relatorio.marcacao_id" ).isEqual( new Field( "marcacoes_estabelecimento.id" ) ), + new Field( "marcacoes_estabelecimento.estabelecimento_id" ).isEqual( new Field( "estabelecimentos.id" ) ), + new Field( "estabelecimentos.empresa_id" ).isEqual( new Field( "empresas.id" ) ) + }, + new String[]{ "empresas.id", "empresas.designacao_social", + "estabelecimentos.id", "estabelecimentos.nome", + "hs_relatorio.data", "marcacoes_estabelecimento.data", "''", + "''", "false", + "false" }, + new Field( "hs_relatorio.id" ).isEqual( id ), + null, + null, + null, + null ); + array = LOCAL_EXECUTER.executeQuery( select ); + } Integer empresaId = ( Integer ) array.get( 0, 0 ); String nomeEmpresa = ( String ) array.get( 0, 1 ); Integer estabelecimentoId = ( Integer ) array.get( 0, 2 ); @@ -130,19 +159,39 @@ public class PlanoActuacaoPrintDataProvider public Vector getAreasToPrintByPlanoId( Integer planoId, boolean validacaoDl, boolean validacaoDns ) throws Exception { + Virtual2DArray array; Vector areas = new Vector(); - Select select = - new Select2( - new String[]{ "plano_areas" }, - new Integer[]{}, - new Expression[]{}, - new String[]{ "id", "descricao" }, - new Field( "plano_id" ).isEqual( planoId ), - new String[]{ "id" }, - null, - null, - null ); - Virtual2DArray array = WEB_EXECUTER.executeQuery( select ); + if( web ) + { + Select select = + new Select2( + new String[]{ "plano_areas" }, + new Integer[]{}, + new Expression[]{}, + new String[]{ "id", "descricao" }, + new Field( "plano_id" ).isEqual( planoId ), + new String[]{ "id" }, + null, + null, + null ); + array = WEB_EXECUTER.executeQuery( select ); + } + else + { + Select select = + new Select2( + new String[]{ "hs_relatorio_area" }, + new Integer[]{}, + new Expression[]{}, + new String[]{ "id", "description" }, + new Field( "relatorio_id" ).isEqual( planoId ).and( + new Field( "deleted_date" ).isEqual( null ) ), + new String[]{ "id" }, + null, + null, + null ); + array = LOCAL_EXECUTER.executeQuery( select ); + } for( int n = 0; n < array.columnLength(); n++ ) { Integer areaId = ( Integer ) array.get( n, 0 ); @@ -155,22 +204,55 @@ public class PlanoActuacaoPrintDataProvider public Vector getRiscosToPrintByAreaId( Integer areaId, boolean validacaoDl, boolean validacaoDns ) throws Exception { + Virtual2DArray array; Vector riscos = new Vector(); - Select select = - new Select2( - new String[]{ "plano_riscos" }, - new Integer[]{}, - new Expression[]{}, - new String[]{ "id", "descricao", "valor", "responsavel_execucao", - "recursos_necessarios", "data_inicio", "data_fim", - "parecer_dl", "parecer_dns", "verificacao_siprp"}, - new Field( "area_id" ).isEqual( areaId ).and( - new Field( "activo" ).isEqual( "y" ) ), - new String[]{ "id" }, - null, - null, - null ); - Virtual2DArray array = WEB_EXECUTER.executeQuery( select ); + if( web ) + { + Select select = + new Select2( + new String[]{ "plano_riscos" }, + new Integer[]{}, + new Expression[]{}, + new String[]{ "id", "descricao", "valor", "responsavel_execucao", + "recursos_necessarios", "data_inicio", "data_fim", + "parecer_dl", "parecer_dns", "verificacao_siprp"}, + new Field( "area_id" ).isEqual( areaId ).and( + new Field( "activo" ).isEqual( "y" ) ), + new String[]{ "id" }, + null, + null, + null ); + array = WEB_EXECUTER.executeQuery( select ); + } + else + { + 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 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 String[]{ "hs_relatorio_risco.id", + "hs_relatorio_risco.description", + "hs_relatorio_posto_risco.probabilidade * hs_relatorio_posto_risco.severidade", + "null", + "null", + "null", + "null", + "null", + "null", + "verificacao_siprp" }, + new Field( "hs_relatorio_area.area_id" ).isEqual( areaId ).and( + new Field( "hs_relatorio_risco.deleted_date" ).isEqual( null ) ).and( + new Field( "hs_relatorio_posto.deleted_date" ).isEqual( null ) ), + new String[]{ "id" }, + null, + null, + null ); + array = LOCAL_EXECUTER.executeQuery( select ); + } for( int n = 0; n < array.columnLength(); n++ ) { Integer id = ( Integer ) array.get( n, 0 ); diff --git a/trunk/SIPRPSoft/src/siprp/planoactuacao/print/TestPrint.java b/trunk/SIPRPSoft/src/siprp/planoactuacao/print/TestPrint.java index 04d66882..64f55c47 100644 --- a/trunk/SIPRPSoft/src/siprp/planoactuacao/print/TestPrint.java +++ b/trunk/SIPRPSoft/src/siprp/planoactuacao/print/TestPrint.java @@ -44,7 +44,7 @@ public class TestPrint // fos.write( fo ); // fos.close(); - byte pdf[] = new PlanoActuacaoPDFCreator().createPDF( 6 ); + byte pdf[] = new PlanoActuacaoPDFCreator().createPDF( 6, true ); FileOutputStream fos = new FileOutputStream( "/home/fpalma/Desktop/pdf.pdf" ); fos.write( pdf ); fos.close(); diff --git a/trunk/SIPRPSoft/src/siprp/planoactuacao/print/plano_actuacao.xsl b/trunk/SIPRPSoft/src/siprp/planoactuacao/print/plano_actuacao.xsl index 2a18fbef..28998c77 100644 --- a/trunk/SIPRPSoft/src/siprp/planoactuacao/print/plano_actuacao.xsl +++ b/trunk/SIPRPSoft/src/siprp/planoactuacao/print/plano_actuacao.xsl @@ -74,14 +74,14 @@ + src="url('http://www.evolute.pt/~siprp/planoactuacao/roda.jpg')" + height="9.899cm" width="9.899cm" /> + src="url('http://www.evolute.pt/~siprp/planoactuacao/siprp_land.jpg')" + height="11.007cm" width="2.941cm" /> + src="url('http://www.evolute.pt/~siprp/planoactuacao/capa1.jpg')" + height="4.211cm" width="6.279cm" /> + src="url('http://www.evolute.pt/~siprp/planoactuacao/capa2.jpg')" + height="4.211cm" width="6.279cm" /> + src="url('http://www.evolute.pt/~siprp/planoactuacao/capa3.jpg')" + height="4.211cm" width="6.279cm" /> + src="url('http://www.evolute.pt/~siprp/planoactuacao/capa4.jpg')" + height="4.211cm" width="6.279cm" /> + src="url('http://www.evolute.pt/~siprp/planoactuacao/siprp_logo.jpg')" + height="2cm" /> - - - - - + + + + + @@ -2414,20 +2417,18 @@ page - + - - - + + + - - @@ -2436,11 +2437,12 @@ margin-bottom="0in" margin-right="-0.0484in" text-indent="0in" margin-left="0in"> + src="url('http://www.evolute.pt/~siprp/planoactuacao/siprp_logo.jpg')" + height="2cm" /> @@ -2449,17 +2451,19 @@ margin-bottom="0in" margin-right="0in" text-indent="0in" margin-left="1.2307in">   - - - - - + + + + + @@ -2473,7 +2477,7 @@ @@ -2486,7 +2490,7 @@ @@ -2515,7 +2519,7 @@ @@ -2528,7 +2532,7 @@ @@ -2554,7 +2558,7 @@ @@ -2584,7 +2588,7 @@ @@ -2695,31 +2699,6 @@ Data prevista de conclusão - - - Parecer DL - - - - - Parecer DNS - - + column-width="1.6541in" /> + column-width="2.3568in" /> + column-width="1.1617in" /> + column-width="1.3589in" /> - - @@ -2963,40 +2938,6 @@ - - - - - - - - - - - - - - - - + src="url('http://www.evolute.pt/~siprp/planoactuacao/siprp_logo.jpg')" + height="2cm" />   - - + + @@ -3095,58 +3039,6 @@ - - - - - - - Observações Gerais DL: - - - - - - - - - - - - - - - - - - - Observações Gerais DNS: - - - - - - - - - - - - -