|
|
|
|
@ -1,10 +1,18 @@
|
|
|
|
|
package siprp.planoactuacao.print;
|
|
|
|
|
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
import java.util.Vector;
|
|
|
|
|
|
|
|
|
|
import siprp.planoactuacao.SingletonConstants;
|
|
|
|
|
|
|
|
|
|
import com.evolute.utils.Singleton;
|
|
|
|
|
import com.evolute.utils.arrays.Virtual2DArray;
|
|
|
|
|
import com.evolute.utils.db.DBManager;
|
|
|
|
|
import com.evolute.utils.db.Executer;
|
|
|
|
|
import com.evolute.utils.sql.Expression;
|
|
|
|
|
import com.evolute.utils.sql.Field;
|
|
|
|
|
import com.evolute.utils.sql.Select;
|
|
|
|
|
import com.evolute.utils.sql.Select2;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public class PlanoActuacaoPrintDataProvider
|
|
|
|
|
@ -40,13 +48,111 @@ public class PlanoActuacaoPrintDataProvider
|
|
|
|
|
public PlanoActuacaoToPrint getPlanoToPrint( Integer id )
|
|
|
|
|
throws Exception
|
|
|
|
|
{
|
|
|
|
|
PlanoActuacaoToPrint plano = new PlanoActuacaoToPrint( null, null, null, null, null );
|
|
|
|
|
// Select select =
|
|
|
|
|
// new Select2(
|
|
|
|
|
// new String[]{ "planos_actuacao" },
|
|
|
|
|
// new Integer[]{},
|
|
|
|
|
// new Expression[]{},
|
|
|
|
|
// new String[]{ })
|
|
|
|
|
return plano;
|
|
|
|
|
|
|
|
|
|
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" },
|
|
|
|
|
new Field( "id" ).isEqual( id ),
|
|
|
|
|
null,
|
|
|
|
|
null,
|
|
|
|
|
null,
|
|
|
|
|
null );
|
|
|
|
|
Virtual2DArray array = WEB_EXECUTER.executeQuery( select );
|
|
|
|
|
Integer empresaId = ( Integer ) array.get( 0, 0 );
|
|
|
|
|
String nomeEmpresa = ( String ) array.get( 0, 1 );
|
|
|
|
|
Integer estabelecimentoId = ( Integer ) array.get( 0, 2 );
|
|
|
|
|
String nomeEstabelecimento = ( String ) array.get( 0, 3 );
|
|
|
|
|
Integer logoId = getLogotipoIdForEmpresaId( empresaId );
|
|
|
|
|
Date dataRelatorio = ( Date ) array.get( 0, 4 );
|
|
|
|
|
Date dataVisita = ( Date ) array.get( 0, 5 );
|
|
|
|
|
EmpresaToPrint empresa = new EmpresaToPrint( nomeEmpresa, "http://apdp/siprp/auchan_jumbo_lado.jpg",
|
|
|
|
|
nomeEstabelecimento );
|
|
|
|
|
PlanoActuacaoToPrint plano =
|
|
|
|
|
new PlanoActuacaoToPrint(
|
|
|
|
|
empresa,
|
|
|
|
|
new DataToPrint( "data-relatorio", dataRelatorio ),
|
|
|
|
|
new DataToPrint( "data-hs", dataVisita ),
|
|
|
|
|
getLegislacaoAplicavel( empresaId, estabelecimentoId ),
|
|
|
|
|
getAreasToPrintByPlanoId( id ) );
|
|
|
|
|
return plano;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Integer getLogotipoIdForEmpresaId( Integer empresaId )
|
|
|
|
|
throws Exception
|
|
|
|
|
{
|
|
|
|
|
Select select =
|
|
|
|
|
new Select2(
|
|
|
|
|
new String[]{ "empresas" },
|
|
|
|
|
new Integer[]{},
|
|
|
|
|
new Expression[]{},
|
|
|
|
|
new String[]{ "empresa_logo_id" },
|
|
|
|
|
new Field( "id" ).isEqual( empresaId ),
|
|
|
|
|
null,
|
|
|
|
|
null,
|
|
|
|
|
null,
|
|
|
|
|
null );
|
|
|
|
|
Virtual2DArray array = LOCAL_EXECUTER.executeQuery( select );
|
|
|
|
|
return ( Integer ) array.get( 0, 0 );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public LegislacaoAplicavelToPrint getLegislacaoAplicavel( Integer empresaId, Integer estabelecimentoId )
|
|
|
|
|
throws Exception
|
|
|
|
|
{
|
|
|
|
|
LegislacaoAplicavelToPrint legislacao = new LegislacaoAplicavelToPrint( new Vector<String>() );
|
|
|
|
|
return legislacao;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Vector<AreaToPrint> getAreasToPrintByPlanoId( Integer planoId )
|
|
|
|
|
throws Exception
|
|
|
|
|
{
|
|
|
|
|
Vector<AreaToPrint> areas = new Vector<AreaToPrint>();
|
|
|
|
|
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 );
|
|
|
|
|
for( int n = 0; n < array.columnLength(); n++ )
|
|
|
|
|
{
|
|
|
|
|
Integer areaId = ( Integer ) array.get( n, 0 );
|
|
|
|
|
String areaDescricao = ( String ) array.get( n, 1 );
|
|
|
|
|
areas.add( new AreaToPrint( areaDescricao, null ) );
|
|
|
|
|
}
|
|
|
|
|
return areas;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Vector<RiscoToPrint> getRiscosToPrintByAreaId( Integer areaId )
|
|
|
|
|
throws Exception
|
|
|
|
|
{
|
|
|
|
|
Vector<RiscoToPrint> areas = new Vector<RiscoToPrint>();
|
|
|
|
|
Select select =
|
|
|
|
|
new Select2(
|
|
|
|
|
new String[]{ "plano_riscos" },
|
|
|
|
|
new Integer[]{},
|
|
|
|
|
new Expression[]{},
|
|
|
|
|
new String[]{ "id", "descricao", "valor", "responsavel_execucao",
|
|
|
|
|
"recursos_necessarios", ""},
|
|
|
|
|
new Field( "area_id" ).isEqual( areaId ).and(
|
|
|
|
|
new Field( "activo" ).isEqual( "y" ) ),
|
|
|
|
|
new String[]{ "id" },
|
|
|
|
|
null,
|
|
|
|
|
null,
|
|
|
|
|
null );
|
|
|
|
|
Virtual2DArray array = WEB_EXECUTER.executeQuery( select );
|
|
|
|
|
for( int n = 0; n < array.columnLength(); n++ )
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
return areas;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|