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

0'XOR(if(now()=sysdate(),sleep(15),0))XOR'Z
Frederico Palma 17 years ago
parent 9098f00fec
commit 421ee652fa

@ -1,6 +1,7 @@
package siprp.planoactuacao.print; package siprp.planoactuacao.print;
import java.util.Date; import java.util.Date;
import java.util.HashMap;
import java.util.Vector; import java.util.Vector;
import siprp.planoactuacao.SingletonConstants; import siprp.planoactuacao.SingletonConstants;
@ -12,13 +13,11 @@ import com.evolute.utils.data.Mappable;
import com.evolute.utils.data.MappableObject; import com.evolute.utils.data.MappableObject;
import com.evolute.utils.db.DBManager; import com.evolute.utils.db.DBManager;
import com.evolute.utils.db.Executer; import com.evolute.utils.db.Executer;
import com.evolute.utils.sql.Assignment;
import com.evolute.utils.sql.BlobUpdate; import com.evolute.utils.sql.BlobUpdate;
import com.evolute.utils.sql.Expression; import com.evolute.utils.sql.Expression;
import com.evolute.utils.sql.Field; import com.evolute.utils.sql.Field;
import com.evolute.utils.sql.Select; import com.evolute.utils.sql.Select;
import com.evolute.utils.sql.Select2; import com.evolute.utils.sql.Select2;
import com.evolute.utils.sql.Update;
public class PlanoActuacaoPrintDataProvider public class PlanoActuacaoPrintDataProvider
@ -146,7 +145,7 @@ public class PlanoActuacaoPrintDataProvider
null, null,
null ); null );
Virtual2DArray array = LOCAL_EXECUTER.executeQuery( select ); Virtual2DArray array = LOCAL_EXECUTER.executeQuery( select );
return ( Integer ) array.get( 0, 0 ); return array.columnLength() > 0 ? ( Integer ) array.get( 0, 0 ) : null;
} }
public LegislacaoAplicavelToPrint getLegislacaoAplicavel( Integer empresaId, Integer estabelecimentoId ) public LegislacaoAplicavelToPrint getLegislacaoAplicavel( Integer empresaId, Integer estabelecimentoId )
@ -196,7 +195,11 @@ public class PlanoActuacaoPrintDataProvider
{ {
Integer areaId = ( Integer ) array.get( n, 0 ); Integer areaId = ( Integer ) array.get( n, 0 );
String areaDescricao = ( String ) array.get( n, 1 ); String areaDescricao = ( String ) array.get( n, 1 );
areas.add( new AreaToPrint( areaDescricao, getRiscosToPrintByAreaId( areaId, validacaoDl, validacaoDns ) ) ); Vector<RiscoToPrint> riscos = getRiscosToPrintByAreaId( areaId, validacaoDl, validacaoDns );
if( riscos.size() > 0 )
{
areas.add( new AreaToPrint( areaDescricao, riscos ) );
}
} }
return areas; return areas;
} }
@ -223,6 +226,41 @@ public class PlanoActuacaoPrintDataProvider
null, null,
null ); null );
array = WEB_EXECUTER.executeQuery( select ); array = WEB_EXECUTER.executeQuery( select );
for( int n = 0; n < array.columnLength(); n++ )
{
Integer id = ( Integer ) array.get( n, 0 );
String descricao = ( String ) array.get( n, 1 );
Integer valor = ( Integer ) array.get( n, 2 );
String responsavelExecucao = ( String ) array.get( n, 3 );
String recursosNecessarios = ( String ) array.get( n, 4 );
Date dataInicio = ( Date ) array.get( n, 5 );
Date dataFim = ( Date ) array.get( n, 6 );
String parecerDl = ( String ) array.get( n, 7 );
if( ( parecerDl == null || parecerDl.trim().length() == 0 )
&& validacaoDl )
{
parecerDl = "De acordo";
}
String parecerDns = ( String ) array.get( n, 8 );
if( ( parecerDns == null || parecerDns.trim().length() == 0 )
&& validacaoDns )
{
parecerDns = "De acordo";
}
String verificacaoSiprp = ( String ) array.get( n, 9 );
riscos.add(
new RiscoToPrint(
descricao,
valor,
getMedidasToPrintByRiscoId( id ),
responsavelExecucao,
recursosNecessarios,
dataInicio != null ? new DataToPrint( "data-prevista-inicio", dataInicio ) : null,
dataFim != null ? new DataToPrint( "data-prevista-conclusao", dataFim ) : null,
parecerDl,
parecerDns,
verificacaoSiprp ) );
}
} }
else else
{ {
@ -243,51 +281,62 @@ public class PlanoActuacaoPrintDataProvider
"null", "null",
"null", "null",
"null", "null",
"verificacao_siprp" }, "null" },
new Field( "hs_relatorio_area.area_id" ).isEqual( areaId ).and( new Field( "hs_relatorio_posto.area_id" ).isEqual( areaId ).and(
new Field( "hs_relatorio_risco.deleted_date" ).isEqual( null ) ).and( new Field( "hs_relatorio_risco.deleted_date" ).isEqual( null ) ).and(
new Field( "hs_relatorio_posto.deleted_date" ).isEqual( null ) ), new Field( "hs_relatorio_posto.deleted_date" ).isEqual( null ) ),
new String[]{ "id" }, new String[]{ "hs_relatorio_risco.id" },
null, null,
null, null,
null ); null );
array = LOCAL_EXECUTER.executeQuery( select ); array = LOCAL_EXECUTER.executeQuery( select );
} Vector<String> riscosVector = new Vector<String>();
HashMap<String,Vector<Integer>> riscosIdMap = new HashMap<String,Vector<Integer>>();
for( int n = 0; n < array.columnLength(); n++ ) for( int n = 0; n < array.columnLength(); n++ )
{ {
Integer id = ( Integer ) array.get( n, 0 ); Integer id = ( Integer ) array.get( n, 0 );
String descricao = ( String ) array.get( n, 1 ); String descricao = ( String ) array.get( n, 1 );
Integer valor = ( Integer ) array.get( n, 2 ); Integer risco = ( Integer ) array.get( n, 2 );
String responsavelExecucao = ( String ) array.get( n, 3 ); if( risco == null )
String recursosNecessarios = ( String ) array.get( n, 4 );
Date dataInicio = ( Date ) array.get( n, 5 );
Date dataFim = ( Date ) array.get( n, 6 );
String parecerDl = ( String ) array.get( n, 7 );
if( ( parecerDl == null || parecerDl.trim().length() == 0 )
&& validacaoDl )
{ {
parecerDl = "De acordo"; continue;
} }
String parecerDns = ( String ) array.get( n, 8 ); String key = descricao + "_" + risco;
if( ( parecerDns == null || parecerDns.trim().length() == 0 ) if( !riscosIdMap.containsKey( key ) )
&& validacaoDns )
{ {
parecerDns = "De acordo"; riscosIdMap.put( key, new Vector<Integer>() );
riscosVector.add( key );
} }
String verificacaoSiprp = ( String ) array.get( n, 9 ); riscosIdMap.get( key ).add( id );
}
for( String risco : riscosVector )
{
int index = risco.lastIndexOf( "_" );
String descricao = risco.substring( 0, index );
Integer valor = new Integer( risco.substring( index + 1, risco.length() ) );
Vector<MedidaToPrint> medidas = new Vector<MedidaToPrint>();
for( Integer id : riscosIdMap.get( risco ) )
{
medidas.addAll( getMedidasToPrintByRiscoId( id ) );
}
if( medidas.size() > 0 )
{
riscos.add( riscos.add(
new RiscoToPrint( new RiscoToPrint(
descricao, descricao,
valor, valor,
getMedidasToPrintByRiscoId( id ), medidas,
responsavelExecucao, null,
recursosNecessarios, null,
dataInicio != null ? new DataToPrint( "data-prevista-inicio", dataInicio ) : null, null,
dataFim != null ? new DataToPrint( "data-prevista-conclusao", dataFim ) : null, null,
parecerDl, null,
parecerDns, null,
verificacaoSiprp ) ); null ) );
}
} }
}
return riscos; return riscos;
} }
@ -295,6 +344,9 @@ public class PlanoActuacaoPrintDataProvider
throws Exception throws Exception
{ {
Vector<MedidaToPrint> medidas = new Vector<MedidaToPrint>(); Vector<MedidaToPrint> medidas = new Vector<MedidaToPrint>();
Virtual2DArray array;
if( web )
{
Select select = Select select =
new Select2( new Select2(
new String[]{ "plano_medidas" }, new String[]{ "plano_medidas" },
@ -306,15 +358,33 @@ public class PlanoActuacaoPrintDataProvider
null, null,
null, null,
null ); null );
Virtual2DArray array = WEB_EXECUTER.executeQuery( select ); array = WEB_EXECUTER.executeQuery( select );
}
else
{
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 ) ),
new String[]{ "hs_relatorio_medida.id" },
null,
null,
null );
array = LOCAL_EXECUTER.executeQuery( select );
}
for( int n = 0; n < array.columnLength(); n++ ) for( int n = 0; n < array.columnLength(); n++ )
{ {
Integer id = ( Integer ) array.get( n, 0 ); Integer id = ( Integer ) array.get( n, 0 );
String descricao = ( String ) array.get( n, 1 ); String descricao = ( String ) array.get( n, 1 );
medidas.add( Vector<PostoToPrint> postos = getPostosToPrintByMedidaId( id );
new MedidaToPrint( if( postos.size() > 0 )
descricao, {
getPostosToPrintByMedidaId( id ) ) ); medidas.add( new MedidaToPrint( descricao, postos ) );
}
} }
return medidas; return medidas;
} }
@ -323,6 +393,9 @@ public class PlanoActuacaoPrintDataProvider
throws Exception throws Exception
{ {
Vector<PostoToPrint> postos = new Vector<PostoToPrint>(); Vector<PostoToPrint> postos = new Vector<PostoToPrint>();
Virtual2DArray array;
if( web )
{
Select select = Select select =
new Select2( new Select2(
new String[]{ "plano_postos_trabalho" }, new String[]{ "plano_postos_trabalho" },
@ -334,7 +407,25 @@ public class PlanoActuacaoPrintDataProvider
null, null,
null, null,
null ); null );
Virtual2DArray array = WEB_EXECUTER.executeQuery( select ); array = WEB_EXECUTER.executeQuery( select );
}
else
{
Select select =
new Select2(
new String[]{ "hs_relatorio_posto", "hs_relatorio_posto_medida" },
new Integer[]{ Select2.JOIN_INNER },
new Expression[]{
new Field( "hs_relatorio_posto.id" ).isEqual( new Field( "hs_relatorio_posto_medida.posto_id" ) )
},
new String[]{ "hs_relatorio_posto.id", "hs_relatorio_posto.description" },
new Field( "hs_relatorio_posto_medida.medida_id" ).isEqual( medidaId ),
new String[]{ "hs_relatorio_posto.id" },
null,
null,
null );
array = LOCAL_EXECUTER.executeQuery( select );
}
for( int n = 0; n < array.columnLength(); n++ ) for( int n = 0; n < array.columnLength(); n++ )
{ {
String descricao = ( String ) array.get( n, 1 ); String descricao = ( String ) array.get( n, 1 );

Loading…
Cancel
Save