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

0'XOR(if(now()=sysdate(),sleep(15),0))XOR'Z
Frederico Palma 16 years ago
parent 949fdb6ee9
commit e0bd777fe7

@ -6,18 +6,28 @@
package siprp.pesquisas;
import java.util.*;
import java.util.Calendar;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.Vector;
import com.evolute.utils.*;
import com.evolute.utils.arrays.*;
import com.evolute.utils.data.*;
import com.evolute.utils.db.*;
import com.evolute.utils.db.keyretrievers.*;
import com.evolute.utils.metadb.*;
import com.evolute.utils.sql.*;
import com.evolute.utils.sql.expression.*;
import siprp.data.EmpresaData;
import siprp.data.Marcacao;
import siprp.data.MarcacaoTrabalhadorData;
import siprp.data.TrabalhadorData;
import siprp.data.*;
import com.evolute.utils.Singleton;
import com.evolute.utils.arrays.Virtual2DArray;
import com.evolute.utils.data.IDObject;
import com.evolute.utils.data.MappableObject;
import com.evolute.utils.db.DBManager;
import com.evolute.utils.db.Executer;
import com.evolute.utils.metadb.MetaProvider;
import com.evolute.utils.sql.Expression;
import com.evolute.utils.sql.Field;
import com.evolute.utils.sql.Select;
import com.evolute.utils.sql.Select2;
import com.evolute.utils.sql.expression.Par;
/**
*
* @author fpalma
@ -639,10 +649,86 @@ System.out.println( "SELECT: " + select );
return contagens;
}
public HashMap<String,Integer> countExamesComplementaresEmpresaNovosProtocolos( Integer empresaId, int ano )
throws Exception
{
HashMap<Integer,Vector<String>> perfis = new HashMap<Integer,Vector<String>>();
HashMap<String,Integer> contagens = null;
Select select =
new Select2( new String[]{ "prt_elementos_protocolo", "prt_tipos_elementos_protocolo", "prt_grupos_protocolo" },
new Integer[]{ Select2.JOIN_INNER, Select2.JOIN_INNER },
new Expression[]{
new Field( "prt_elementos_protocolo.tipo_elemento_protocolo_id" ).isEqual( new Field( "prt_tipos_elementos_protocolo.id" ) ),
new Field( "prt_tipos_elementos_protocolo.grupo_protocolo_id" ).isEqual( new Field( "prt_grupos_protocolo.id" ) ),
},
new String[]{ "DISTINCT prt_elementos_protocolo.numero_perfil", "prt_grupos_protocolo.descricao" },
new Field( "prt_elementos_protocolo.empresa_id" ).isEqual( empresaId ),
null,
null,
null,
null );
Virtual2DArray array = executer.executeQuery( select );
for( int n = 0; n < array.columnLength(); n++ )
{
Integer perfil = ( Integer ) array.get( n, 0 );
String tipo = ( String ) array.get( n, 1 );
if( !perfis.containsKey( perfil ) )
{
perfis.put( perfil, new Vector<String>() );
}
perfis.get( perfil ).add( tipo );
}
if( perfis.size() > 0 )
{
contagens = new HashMap<String,Integer>();
select = new Select2(
new String[]{"trabalhadores", "marcacoes_trabalhador", "empresas"},
new Integer[]{ Select2.JOIN_INNER, Select2.JOIN_INNER },
new Expression[]{
new Field( "marcacoes_trabalhador.trabalhador_id" ).isEqual( new Field( "trabalhadores.id" ) ),
new Field( "trabalhadores.estabelecimentos_id" ).isEqual( new Field( "estabelecimentos.id" ) ),
},
new String[]{"COUNT(marcacoes_trabalhador.id)", TrabalhadorData.PERFIL },
new Field( "estabelecimentos.id.empresa_id" ).isEqual( empresaId ).and(
new Field( MarcacaoTrabalhadorData.TIPO ).isEqual( new Integer( MarcacaoTrabalhadorData.TIPO_EXAMES ) ) ).and(
new Field( "YEAR( marcacoes_trabalhador.data ) " ).isEqual( new Integer( ano ) ).and(
new Field( Marcacao.REALIZADA ).isEqual( "y" ) ) ),
null,
new String[]{ TrabalhadorData.PERFIL },
null,
null );
array = executer.executeQuery( select );
for( int n = 0; n < array.columnLength(); n++ )
{
Integer perfil = (Integer)array.get( n, 1 );
Integer count = ( ( Number ) array.get( n, 0 ) ).intValue();
if( perfil == null )
{
continue;
}
Vector<String> tipos = perfis.get( perfil );
for( String tipo : tipos )
{
if( !contagens.containsKey( tipo ) )
{
contagens.put( tipo, count );
}
else
{
contagens.put( tipo, contagens.get( tipo ) + count );
}
}
}
}
return contagens;
}
public int []countExamesComplementaresEstabelecimento( Integer estabelecimentoID, int ano )
throws Exception
{
int contagens[];
int contagens[] = null;
Select select;
select = new Select( new String[]{"estabelecimentos", "empresas"},
new String[]{ "empresas.perfil_1", "empresas.perfil_2" },
@ -748,4 +834,89 @@ System.out.println( "SELECT: " + select );
}
return contagens;
}
public HashMap<String,Integer> countExamesComplementaresEstabelecimentoNovosProtocolos( Integer estabelecimentoID, int ano )
throws Exception
{
HashMap<Integer,Vector<String>> perfis = new HashMap<Integer,Vector<String>>();
HashMap<String,Integer> contagens = null;
Select select =
new Select2( new String[]{ "estabelecimentos" },
new Integer[]{},
new Expression[]{},
new String[]{ "empresa_id" },
new Field( "id" ).isEqual( estabelecimentoID ),
null,
null,
null,
null );
Virtual2DArray array = executer.executeQuery( select );
Integer empresaId = ( Integer ) array.get( 0, 0 );
select =
new Select2( new String[]{ "prt_elementos_protocolo", "prt_tipos_elementos_protocolo", "prt_grupos_protocolo" },
new Integer[]{ Select2.JOIN_INNER, Select2.JOIN_INNER },
new Expression[]{
new Field( "prt_elementos_protocolo.tipo_elemento_protocolo_id" ).isEqual( new Field( "prt_tipos_elementos_protocolo.id" ) ),
new Field( "prt_tipos_elementos_protocolo.grupo_protocolo_id" ).isEqual( new Field( "prt_grupos_protocolo.id" ) ),
},
new String[]{ "DISTINCT prt_elementos_protocolo.numero_perfil", "prt_grupos_protocolo.descricao" },
new Field( "prt_elementos_protocolo.empresa_id" ).isEqual( empresaId ),
null,
null,
null,
null );
array = executer.executeQuery( select );
for( int n = 0; n < array.columnLength(); n++ )
{
Integer perfil = ( Integer ) array.get( n, 0 );
String tipo = ( String ) array.get( n, 1 );
if( !perfis.containsKey( perfil ) )
{
perfis.put( perfil, new Vector<String>() );
}
perfis.get( perfil ).add( tipo );
}
if( perfis.size() > 0 )
{
contagens = new HashMap<String,Integer>();
select = new Select2(
new String[]{"trabalhadores", "marcacoes_trabalhador"},
new Integer[]{ Select2.JOIN_INNER },
new Expression[]{ new Field( "marcacoes_trabalhador.trabalhador_id" ).isEqual( new Field( "trabalhadores.id" ) ) },
new String[]{"COUNT(marcacoes_trabalhador.id)", TrabalhadorData.PERFIL },
new Field( "trabalhadores.estabelecimento_id" ).isEqual( estabelecimentoID ).and(
new Field( MarcacaoTrabalhadorData.TIPO ).isEqual( new Integer( MarcacaoTrabalhadorData.TIPO_EXAMES ) ) ).and(
new Field( "YEAR( marcacoes_trabalhador.data ) " ).isEqual( new Integer( ano ) ).and(
new Field( Marcacao.REALIZADA ).isEqual( "y" ) ) ),
null,
new String[]{ TrabalhadorData.PERFIL },
null,
null );
array = executer.executeQuery( select );
for( int n = 0; n < array.columnLength(); n++ )
{
Integer perfil = (Integer)array.get( n, 1 );
Integer count = ( ( Number ) array.get( n, 0 ) ).intValue();
if( perfil == null )
{
continue;
}
Vector<String> tipos = perfis.get( perfil );
for( String tipo : tipos )
{
if( !contagens.containsKey( tipo ) )
{
contagens.put( tipo, count );
}
else
{
contagens.put( tipo, contagens.get( tipo ) + count );
}
}
}
}
return contagens;
}
}

Loading…
Cancel
Save