|
|
|
|
@ -10,8 +10,8 @@ import java.io.*;
|
|
|
|
|
import java.lang.reflect.Array;
|
|
|
|
|
import javax.servlet.*;
|
|
|
|
|
import javax.servlet.http.*;
|
|
|
|
|
import java.sql.*;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.sql.SQLException;
|
|
|
|
|
|
|
|
|
|
import org.apache.velocity.*;
|
|
|
|
|
import org.apache.velocity.app.*;
|
|
|
|
|
@ -57,7 +57,7 @@ public class doGetListaTrabalhadoresPendentes
|
|
|
|
|
// TEXTOS_ESTADOS.put( new Integer( ESTADO_TRATADO ), "green" );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected java.sql.Date today;
|
|
|
|
|
protected Date today;
|
|
|
|
|
protected long todayMillis;
|
|
|
|
|
|
|
|
|
|
/** Creates a new instance of doGetListaTrabalhadores */
|
|
|
|
|
@ -227,43 +227,46 @@ public class doGetListaTrabalhadoresPendentes
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
public doGetListaTrabalhadoresPendentes(HttpServletRequest req, HttpServletResponse res, boolean print )
|
|
|
|
|
public doGetListaTrabalhadoresPendentes( HttpServletRequest req, HttpServletResponse res, boolean print )
|
|
|
|
|
throws IOException
|
|
|
|
|
{
|
|
|
|
|
System.out.println( "\ndoGetListaTrabalhadoresPendentes() : " );
|
|
|
|
|
|
|
|
|
|
ServletOutputStream out = res.getOutputStream();
|
|
|
|
|
String userRole, empresaId, estabelecimentoId;
|
|
|
|
|
HttpSession session = req.getSession(false);
|
|
|
|
|
HttpSession session = req.getSession( false );
|
|
|
|
|
Vector links = new Vector();
|
|
|
|
|
Vector desc = new Vector();
|
|
|
|
|
Vector descAdicional = new Vector();
|
|
|
|
|
// today = new java.util.Date();
|
|
|
|
|
// todayMillis = today.getTime();
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
Executer executer = getExecuter();
|
|
|
|
|
Virtual2DArray array = executer.executeQuery( new Select( "SELECT CURRENT_DATE" ) );
|
|
|
|
|
today = ( java.sql.Date ) array.get( 0, 0 );
|
|
|
|
|
today = new Date();
|
|
|
|
|
todayMillis = today.getTime();
|
|
|
|
|
|
|
|
|
|
userRole = (String)session.getAttribute(sessionUserRole);
|
|
|
|
|
empresaId = (String)session.getAttribute(sessionEmpresaId);
|
|
|
|
|
estabelecimentoId = (String)session.getAttribute(sessionEstabelecimentoId);
|
|
|
|
|
userRole = ( String ) session.getAttribute( sessionUserRole );
|
|
|
|
|
empresaId = ( String ) session.getAttribute( sessionEmpresaId );
|
|
|
|
|
estabelecimentoId = ( String ) session.getAttribute( sessionEstabelecimentoId );
|
|
|
|
|
|
|
|
|
|
System.out.println( "\tuserRole : " + userRole );
|
|
|
|
|
System.out.println( "\tempresaID : " + empresaId );
|
|
|
|
|
System.out.println( "\testabelecimentoID : " + estabelecimentoId );
|
|
|
|
|
|
|
|
|
|
if ( userRole.equals ( superUserRole ) || userRole.equals ( empresaId ) )
|
|
|
|
|
{
|
|
|
|
|
if ( verificaEstabelecimento(null, empresaId, estabelecimentoId) ) // estabelecimento pertence 'a empresa ??
|
|
|
|
|
if ( verificaEstabelecimento( null, empresaId, estabelecimentoId ) ) // estabelecimento pertence 'a empresa ??
|
|
|
|
|
{
|
|
|
|
|
//Class.forName(super.bdDriver);
|
|
|
|
|
//con = DriverManager.getConnection( super.bdUrl, super.bdUsername, super.bdPassword );
|
|
|
|
|
String query = "( SELECT trabalhadores.id, trabalhadores.nome, "
|
|
|
|
|
+ "marcacoes_trabalhador.tipo, marcacoes_trabalhador.data, marcacoes_trabalhador.estado, "
|
|
|
|
|
+ " trabalhadores.nome_plain, marcacoes_trabalhador.motivo, marcacoes_trabalhador.data "
|
|
|
|
|
+ "FROM trabalhadores LEFT JOIN marcacoes_trabalhador ON ( marcacoes_trabalhador.trabalhador_id = trabalhadores.id ) "
|
|
|
|
|
+ "WHERE estabelecimento_id = " + estabelecimentoId
|
|
|
|
|
+ " AND trabalhadores.inactivo <> 'y' AND data_demissao IS NULL "
|
|
|
|
|
+ " AND marcacoes_trabalhador.estado NOT IN ( 3, 4, 5) "
|
|
|
|
|
+ " AND marcacoes_trabalhador.estado NOT IN ( 2, 3, 4, 5 ) "
|
|
|
|
|
+ " AND marcacoes_trabalhador.tipo = " + TIPO_MARCACAO_CONSULTA
|
|
|
|
|
+ " AND marcacoes_trabalhador.deleted_stamp is null"
|
|
|
|
|
+ " AND marcacoes_trabalhador.data < now()"
|
|
|
|
|
+ " AND marcacoes_trabalhador.motivo <> " + MOTIVO_OCASIONAL + " )"
|
|
|
|
|
+ " UNION "
|
|
|
|
|
+ "( SELECT trabalhadores.id, trabalhadores.nome, "
|
|
|
|
|
@ -272,10 +275,12 @@ public class doGetListaTrabalhadoresPendentes
|
|
|
|
|
+ "FROM trabalhadores LEFT JOIN marcacoes_trabalhador ON ( marcacoes_trabalhador.trabalhador_id = trabalhadores.id ) "
|
|
|
|
|
+ "WHERE estabelecimento_id = " + estabelecimentoId
|
|
|
|
|
+ " AND trabalhadores.inactivo <> 'y' AND data_demissao IS NULL "
|
|
|
|
|
+ " AND marcacoes_trabalhador.estado NOT IN ( 3, 4, 5) "
|
|
|
|
|
+ " AND marcacoes_trabalhador.estado NOT IN ( 2, 3, 4, 5 ) "
|
|
|
|
|
+ " AND marcacoes_trabalhador.deleted_stamp is null"
|
|
|
|
|
+ " AND marcacoes_trabalhador.data < now()"
|
|
|
|
|
+ " AND marcacoes_trabalhador.tipo = " + TIPO_MARCACAO_EXAMES + " )"
|
|
|
|
|
+ "ORDER BY 6, 8, 3 DESC ";
|
|
|
|
|
array = executer.executeQuery( new Select( query ) );
|
|
|
|
|
+ " ORDER BY 6, 8, 3 DESC ";
|
|
|
|
|
Virtual2DArray array = executer.executeQuery( new Select( query ) );
|
|
|
|
|
|
|
|
|
|
query = "SELECT trabalhadores.id, trabalhadores.nome, "
|
|
|
|
|
+ "marcacoes_trabalhador.tipo, marcacoes_trabalhador.data, marcacoes_trabalhador.estado, "
|
|
|
|
|
@ -283,9 +288,11 @@ public class doGetListaTrabalhadoresPendentes
|
|
|
|
|
+ "FROM trabalhadores LEFT JOIN marcacoes_trabalhador ON ( marcacoes_trabalhador.trabalhador_id = trabalhadores.id ) "
|
|
|
|
|
+ "WHERE estabelecimento_id = " + estabelecimentoId
|
|
|
|
|
+ " AND trabalhadores.inactivo <> 'y' AND data_demissao IS NULL "
|
|
|
|
|
+ " AND marcacoes_trabalhador.estado NOT IN ( 3, 4, 5) "
|
|
|
|
|
+ " AND marcacoes_trabalhador.estado NOT IN ( 2, 3, 4, 5 ) "
|
|
|
|
|
+ " AND marcacoes_trabalhador.tipo = " + TIPO_MARCACAO_CONSULTA
|
|
|
|
|
+ " AND marcacoes_trabalhador.motivo = " + MOTIVO_OCASIONAL
|
|
|
|
|
+ " AND marcacoes_trabalhador.data < now()"
|
|
|
|
|
+ " AND marcacoes_trabalhador.deleted_stamp is null"
|
|
|
|
|
+ " ORDER BY 6, 8, 3 DESC";
|
|
|
|
|
Virtual2DArray ocasionaisArray = executer.executeQuery( new Select( query ) );
|
|
|
|
|
|
|
|
|
|
@ -306,13 +313,13 @@ public class doGetListaTrabalhadoresPendentes
|
|
|
|
|
preencherMarcacoes( array, nomesPorID, marcacoesPorID );
|
|
|
|
|
preencherMarcacoes( ocasionaisArray, nomesPorID, ocasionaisPorID );
|
|
|
|
|
|
|
|
|
|
Integer ids[] = ( Integer[] ) nomesPorID.keySet().toArray( new Integer[0] );
|
|
|
|
|
Integer ids[] = ( Integer[] ) nomesPorID.keySet().toArray( new Integer[ 0 ] );
|
|
|
|
|
IDObject trabalhadores[] = new IDObject[ ids.length ];
|
|
|
|
|
for( int n = 0; n < ids.length; n++ )
|
|
|
|
|
{
|
|
|
|
|
trabalhadores[ n ] = new MappableObject( ids[ n ], nomesPorID.get( ids[ n ] ) );
|
|
|
|
|
}
|
|
|
|
|
Arrays.sort( trabalhadores, new Comparator(){
|
|
|
|
|
Arrays.sort( trabalhadores, new Comparator() {
|
|
|
|
|
public int compare( Object o1, Object o2 )
|
|
|
|
|
{
|
|
|
|
|
String nome1 = StringPlainer.convertString( o1.toString() );
|
|
|
|
|
@ -323,30 +330,25 @@ public class doGetListaTrabalhadoresPendentes
|
|
|
|
|
|
|
|
|
|
for( int n = 0; n < trabalhadores.length; n++ )
|
|
|
|
|
{
|
|
|
|
|
Object marcacoes[][];
|
|
|
|
|
if( marcacoesPorID.containsKey( trabalhadores[ n ].getID() ) )
|
|
|
|
|
{
|
|
|
|
|
marcacoes = ( Object[][] ) ( ( Vector )marcacoesPorID.get( trabalhadores[ n ].getID() ) ).toArray( new Object[ 0 ][] );
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
marcacoes = new Object[0][];
|
|
|
|
|
}
|
|
|
|
|
Object ocasionais[][];
|
|
|
|
|
if( ocasionaisPorID.containsKey( trabalhadores[ n ].getID() ) )
|
|
|
|
|
Integer trabalhadorID = trabalhadores[ n ].getID();
|
|
|
|
|
|
|
|
|
|
Object marcacoes[][] = new Object[ 0 ][ ];
|
|
|
|
|
if ( marcacoesPorID.containsKey( trabalhadorID ) )
|
|
|
|
|
{
|
|
|
|
|
ocasionais = ( Object[][] ) ( ( Vector )ocasionaisPorID.get( trabalhadores[ n ].getID() ) ).toArray( new Object[ 0 ][] );
|
|
|
|
|
marcacoes = ( Object[][] ) ( ( Vector ) marcacoesPorID.get( trabalhadorID ) ).toArray( new Object[ 0 ][] );
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
Object ocasionais[][] = new Object[ 0 ][ ];
|
|
|
|
|
if( ocasionaisPorID.containsKey( trabalhadorID ) )
|
|
|
|
|
{
|
|
|
|
|
ocasionais = new Object[ 0 ][];
|
|
|
|
|
ocasionais = ( Object[][] ) ( ( Vector ) ocasionaisPorID.get( trabalhadorID ) ).toArray( new Object[ 0 ][] );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Object agrupadas[][] = agruparMarcacoes( marcacoes, ocasionais );
|
|
|
|
|
acrescentarTrabalhador( empresaId, estabelecimentoId,
|
|
|
|
|
trabalhadores[ n ], null,
|
|
|
|
|
agrupadas, links, desc,
|
|
|
|
|
perfilTemConsultas( trabalhadores[ n ].getID(), new Integer( empresaId ) ),
|
|
|
|
|
perfilTemExames( trabalhadores[ n ].getID(), new Integer( empresaId ) ) );
|
|
|
|
|
perfilTemConsultas( trabalhadorID, new Integer( empresaId ) ),
|
|
|
|
|
perfilTemExames( trabalhadorID, new Integer( empresaId ) ) );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
HashMap hmValues = new HashMap();
|
|
|
|
|
@ -356,64 +358,64 @@ public class doGetListaTrabalhadoresPendentes
|
|
|
|
|
hmValues.put( "estabelecimento_id", estabelecimentoId );
|
|
|
|
|
hmValues.put( "userRole", userRole );
|
|
|
|
|
hmValues.put( "userName", session.getAttribute( sessionUser ) );
|
|
|
|
|
hmValues.put( msgTemplate , "<b>"+nomeEmpresa(null,empresaId)+"</b><br><br><i>"
|
|
|
|
|
+nomeEstabelecimento(null, estabelecimentoId)+"</i>" ) ;
|
|
|
|
|
hmValues.put( templateUserRole, userRole);
|
|
|
|
|
hmValues.put( msgTemplate , "<b>" + nomeEmpresa( null, empresaId ) + "</b><br><br><i>"
|
|
|
|
|
+ nomeEstabelecimento( null, estabelecimentoId ) + "</i>" ) ;
|
|
|
|
|
hmValues.put( templateUserRole, userRole );
|
|
|
|
|
hmValues.put( templateQuery, "trabalhadores_pendentes" );
|
|
|
|
|
hmValues.put( templateVector1,links);
|
|
|
|
|
hmValues.put( templateVector2,desc);
|
|
|
|
|
hmValues.put( templateVector3,null);
|
|
|
|
|
if( !print )
|
|
|
|
|
hmValues.put( templateVector1, links );
|
|
|
|
|
hmValues.put( templateVector2, desc );
|
|
|
|
|
hmValues.put( templateVector3, null );
|
|
|
|
|
if ( ! print )
|
|
|
|
|
{
|
|
|
|
|
out.println( mergeTemplate( hmValues, super.authenticatedUserTemplate));
|
|
|
|
|
out.println( mergeTemplate( hmValues, super.authenticatedUserTemplate ) );
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
out.println( mergeTemplate( hmValues, super.authenticatedUserPrintTemplate));
|
|
|
|
|
out.println( mergeTemplate( hmValues, super.authenticatedUserPrintTemplate ) );
|
|
|
|
|
}
|
|
|
|
|
// out.println( mergeTemplate( sBuffer.toString(), userRole, super.queryStringTrabalhadores, links, desc, null, super.authenticatedUserTemplate) );
|
|
|
|
|
}
|
|
|
|
|
else // est nao pertence 'a empresa
|
|
|
|
|
{
|
|
|
|
|
out.println( mergeTemplate( super.msgLinkFormatError , userRole, super.errorTemplate) );
|
|
|
|
|
out.println( mergeTemplate( super.msgLinkFormatError, userRole, super.errorTemplate ) );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else // Role nao permite ver esta informacao
|
|
|
|
|
{
|
|
|
|
|
out.println( mergeTemplate( super.msgAcessoNegado , userRole, super.errorTemplate) );
|
|
|
|
|
out.println( mergeTemplate( super.msgAcessoNegado, userRole, super.errorTemplate ) );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch ( SQLException e )
|
|
|
|
|
{
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
out.println( mergeTemplate( super.msgErroBd , super.errorTemplate) );
|
|
|
|
|
out.println( mergeTemplate( super.msgErroBd, super.errorTemplate ) );
|
|
|
|
|
}
|
|
|
|
|
catch ( Exception e )
|
|
|
|
|
{
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
out.println( mergeTemplate( super.msgGenericError , super.errorTemplate) );
|
|
|
|
|
out.println( mergeTemplate( super.msgGenericError, super.errorTemplate ) );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected void preencherMarcacoes( Virtual2DArray array, Hashtable nomesPorID, Hashtable marcacoesPorID )
|
|
|
|
|
{
|
|
|
|
|
int max = array.columnLength();
|
|
|
|
|
for( int index = 0; index < max; index++ )
|
|
|
|
|
for ( int index = 0; index < array.columnLength(); index++ )
|
|
|
|
|
{
|
|
|
|
|
Integer id = index < max ? ( Integer ) array.get( index, 0 ) : new Integer( -1 );
|
|
|
|
|
Integer id = ( Integer ) array.get( index, 0 );
|
|
|
|
|
Integer tipo = ( Integer ) array.get( index, 2 );
|
|
|
|
|
String nome = ( String ) array.get( index, 1 );
|
|
|
|
|
java.util.Date data = ( java.util.Date ) array.get( index, 3 );
|
|
|
|
|
Integer estado = ( Integer ) array.get( index, 4 );
|
|
|
|
|
Integer motivo = ( Integer ) array.get( index, 6 );
|
|
|
|
|
if( !marcacoesPorID.containsKey( id ) )
|
|
|
|
|
|
|
|
|
|
if ( ! marcacoesPorID.containsKey( id ) )
|
|
|
|
|
{
|
|
|
|
|
nomesPorID.put( id, nome );
|
|
|
|
|
marcacoesPorID.put( id, new Vector() );
|
|
|
|
|
}
|
|
|
|
|
if( data != null )
|
|
|
|
|
if ( data != null )
|
|
|
|
|
{
|
|
|
|
|
Object marcacao[] = new Object[]{ data, estado, motivo, tipo };
|
|
|
|
|
Object marcacao[] = new Object[] { data, estado, motivo, tipo };
|
|
|
|
|
( ( Vector ) marcacoesPorID.get( id ) ).add( marcacao );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@ -430,11 +432,11 @@ public class doGetListaTrabalhadoresPendentes
|
|
|
|
|
Object grupo[] = null;
|
|
|
|
|
Vector grupos = new Vector();
|
|
|
|
|
|
|
|
|
|
if( marcacoes != null )
|
|
|
|
|
if ( marcacoes != null )
|
|
|
|
|
{
|
|
|
|
|
for( int n = 0; n < marcacoes.length; n++ )
|
|
|
|
|
for ( int n = 0; n < marcacoes.length; n++ )
|
|
|
|
|
{
|
|
|
|
|
if( grupo == null )
|
|
|
|
|
if ( grupo == null )
|
|
|
|
|
{
|
|
|
|
|
grupo = new Object[ 5 ];
|
|
|
|
|
dataExame = null;
|
|
|
|
|
@ -497,9 +499,9 @@ public class doGetListaTrabalhadoresPendentes
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if( ocasionais != null )
|
|
|
|
|
if ( ocasionais != null )
|
|
|
|
|
{
|
|
|
|
|
for( int n = 0; n < ocasionais.length; n++ )
|
|
|
|
|
for ( int n = 0; n < ocasionais.length; n++ )
|
|
|
|
|
{
|
|
|
|
|
grupo = new Object[ 5 ];
|
|
|
|
|
for( int i = 0; i < 3; i++ )
|
|
|
|
|
@ -511,7 +513,8 @@ public class doGetListaTrabalhadoresPendentes
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Object agrupadas[][] = ( Object[][] ) grupos.toArray( new Object[ grupos.size() ][] );
|
|
|
|
|
Arrays.sort( agrupadas, new Comparator(){
|
|
|
|
|
Arrays.sort( agrupadas, new Comparator()
|
|
|
|
|
{
|
|
|
|
|
public int compare( Object o1, Object o2 )
|
|
|
|
|
{
|
|
|
|
|
Object g1[] = ( Object[] ) o1;
|
|
|
|
|
@ -529,20 +532,32 @@ public class doGetListaTrabalhadoresPendentes
|
|
|
|
|
Object marcacoes[][], Vector links, Vector dados,
|
|
|
|
|
boolean perfilConsultas, boolean perfilExames )
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// System.out.println( "\ndoGetListaTrabalhadoresPendentes . acrescentarTrabalhador( " + empresaID + ", " + estabelecimentoID + ", "
|
|
|
|
|
// + trabalhador + ", " + dataFicha + ", " + marcacoes + ", " + links + ", " + dados + ", " + perfilConsultas + ", " + perfilExames + " ) : " );
|
|
|
|
|
// System.out.println( "\tTrabalhador : " + trabalhador.getID() );
|
|
|
|
|
|
|
|
|
|
int estado[] = new int[ 2 ];
|
|
|
|
|
int index = 0;
|
|
|
|
|
boolean pendente = false;
|
|
|
|
|
if( marcacoes.length == 0 )
|
|
|
|
|
if ( marcacoes.length == 0 )
|
|
|
|
|
{
|
|
|
|
|
// System.out.println( "\tmarcacoes.length == 0 : true" );
|
|
|
|
|
|
|
|
|
|
estado[ 0 ] = perfilConsultas ? ESTADO_PENDENTE : ESTADO_NAO_APLICAVEL;
|
|
|
|
|
estado[ 1 ] = perfilExames ? ESTADO_PENDENTE : ESTADO_NAO_APLICAVEL;
|
|
|
|
|
|
|
|
|
|
// System.out.println( "\t\testado[ 0 ] : " + estado[ 0 ] );
|
|
|
|
|
// System.out.println( "\t\testado[ 1 ] : " + estado[ 1 ] );
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// System.out.println( "\tmarcacoes.length == 0 : false" );
|
|
|
|
|
|
|
|
|
|
java.util.Date dataConsulta;
|
|
|
|
|
java.util.Date dataExame;
|
|
|
|
|
index = -1;
|
|
|
|
|
for( ; index + 1 < marcacoes.length; index++ )
|
|
|
|
|
for ( ; index + 1 < marcacoes.length; index++ )
|
|
|
|
|
{
|
|
|
|
|
int n = index + 1;
|
|
|
|
|
dataConsulta = ( java.util.Date ) marcacoes[ n ][ 0 ];
|
|
|
|
|
@ -553,21 +568,15 @@ public class doGetListaTrabalhadoresPendentes
|
|
|
|
|
boolean exameAntigo = temExame && dataExame.before( today );
|
|
|
|
|
|
|
|
|
|
if( ( temConsulta && consultaAntiga && temExame && exameAntigo ) ||
|
|
|
|
|
( temConsulta && consultaAntiga && !temExame && !exameAntigo ) ||
|
|
|
|
|
( !temConsulta && !consultaAntiga && temExame && exameAntigo ) )
|
|
|
|
|
( temConsulta && consultaAntiga && ! temExame && ! exameAntigo ) ||
|
|
|
|
|
( ! temConsulta && ! consultaAntiga && temExame && exameAntigo ) )
|
|
|
|
|
{
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if( index == -1 )
|
|
|
|
|
{
|
|
|
|
|
index = 0;
|
|
|
|
|
}
|
|
|
|
|
// else if( index < marcacoes.length - 1 )
|
|
|
|
|
// {
|
|
|
|
|
// index = 0;
|
|
|
|
|
// }
|
|
|
|
|
for( ; index < marcacoes.length; index++ )
|
|
|
|
|
|
|
|
|
|
index = index == -1 ? 0 : index;
|
|
|
|
|
for ( ; index < marcacoes.length; index++ )
|
|
|
|
|
{
|
|
|
|
|
dataConsulta = ( java.util.Date ) marcacoes[ index ][ 0 ];
|
|
|
|
|
dataExame = ( java.util.Date ) marcacoes[ index ][ 3 ];
|
|
|
|
|
@ -575,28 +584,29 @@ public class doGetListaTrabalhadoresPendentes
|
|
|
|
|
long diffConsulta = temConsulta ? dataConsulta.getTime() - today.getTime() : 0;
|
|
|
|
|
boolean temExame = dataExame != null;
|
|
|
|
|
long diffExame = temExame ? dataExame.getTime() - today.getTime() : 0;
|
|
|
|
|
if( ( temConsulta && diffConsulta < CATORZE_DIAS ) || ( temExame && diffExame < CATORZE_DIAS ) )
|
|
|
|
|
if ( ( temConsulta && diffConsulta < CATORZE_DIAS ) || ( temExame && diffExame < CATORZE_DIAS ) )
|
|
|
|
|
{
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if( index >= marcacoes.length )
|
|
|
|
|
|
|
|
|
|
if ( index >= marcacoes.length )
|
|
|
|
|
{
|
|
|
|
|
index = marcacoes.length - 1;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if( marcacoes.length > 1 )
|
|
|
|
|
if ( marcacoes.length > 1 )
|
|
|
|
|
{
|
|
|
|
|
dataConsulta = ( java.util.Date ) marcacoes[ index ][ 0 ];
|
|
|
|
|
dataExame = ( java.util.Date ) marcacoes[ index ][ 3 ];
|
|
|
|
|
Calendar calToday = Calendar.getInstance();
|
|
|
|
|
calToday.setTime( today );
|
|
|
|
|
calToday.add( Calendar.YEAR, -2 );
|
|
|
|
|
if( ( dataConsulta != null && dataConsulta.before( calToday.getTime() ) )
|
|
|
|
|
|| ( dataConsulta == null && dataExame != null && dataExame.before( calToday.getTime() ) ) )
|
|
|
|
|
if ( ( dataConsulta != null && dataConsulta.before( calToday.getTime() ) )
|
|
|
|
|
|| ( dataConsulta == null && dataExame != null && dataExame.before( calToday.getTime() ) ) )
|
|
|
|
|
{
|
|
|
|
|
if( index > 0 )
|
|
|
|
|
if ( index > 0 )
|
|
|
|
|
{
|
|
|
|
|
index--;
|
|
|
|
|
}
|
|
|
|
|
@ -612,13 +622,13 @@ public class doGetListaTrabalhadoresPendentes
|
|
|
|
|
Integer motivoConsulta = ( Integer ) marcacoes[ index ][ 2 ];
|
|
|
|
|
dataExame = ( java.util.Date ) marcacoes[ index ][ 3 ];
|
|
|
|
|
Integer estadoExame = ( Integer ) marcacoes[ index ][ 4 ];
|
|
|
|
|
if( perfilConsultas )
|
|
|
|
|
if ( perfilConsultas )
|
|
|
|
|
{
|
|
|
|
|
if( dataConsulta == null || pendente )
|
|
|
|
|
if ( dataConsulta == null || pendente )
|
|
|
|
|
{
|
|
|
|
|
estado[ 0 ] = ESTADO_PENDENTE;
|
|
|
|
|
}
|
|
|
|
|
else if( estadoConsulta == null || estadoConsulta.intValue() != 2 )
|
|
|
|
|
else if ( estadoConsulta == null || estadoConsulta.intValue() != 2 )
|
|
|
|
|
{
|
|
|
|
|
estado[ 0 ] = ESTADO_MARCADO;
|
|
|
|
|
}
|
|
|
|
|
@ -631,20 +641,15 @@ public class doGetListaTrabalhadoresPendentes
|
|
|
|
|
{
|
|
|
|
|
estado[ 0 ] = ESTADO_NAO_APLICAVEL;
|
|
|
|
|
}
|
|
|
|
|
if( perfilExames )
|
|
|
|
|
|
|
|
|
|
if ( perfilExames )
|
|
|
|
|
{
|
|
|
|
|
if( dataExame == null || pendente )
|
|
|
|
|
if ( dataExame == null || pendente )
|
|
|
|
|
{
|
|
|
|
|
if( motivoConsulta != null && motivoConsulta.intValue() != MOTIVO_OCASIONAL )
|
|
|
|
|
{
|
|
|
|
|
estado[ 1 ] = ESTADO_PENDENTE;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
estado[ 1 ] = ESTADO_NAO_APLICAVEL;
|
|
|
|
|
}
|
|
|
|
|
estado[ 1 ] = motivoConsulta != null && motivoConsulta.intValue() != MOTIVO_OCASIONAL ?
|
|
|
|
|
ESTADO_PENDENTE : ESTADO_NAO_APLICAVEL ;
|
|
|
|
|
}
|
|
|
|
|
else if( estadoExame == null || estadoExame.intValue() != 2 )
|
|
|
|
|
else if ( estadoExame == null || estadoExame.intValue() != 2 )
|
|
|
|
|
{
|
|
|
|
|
estado[ 1 ] = ESTADO_MARCADO;
|
|
|
|
|
}
|
|
|
|
|
@ -658,18 +663,29 @@ public class doGetListaTrabalhadoresPendentes
|
|
|
|
|
estado[ 1 ] = ESTADO_NAO_APLICAVEL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if( estado[ 0 ] == 1 || estado[ 0 ] == 2 ||
|
|
|
|
|
estado[ 1 ] == 1 || estado[ 1 ] == 2 )
|
|
|
|
|
|
|
|
|
|
// System.out.println( "\testado[ 0 ] : " + estado[ 0 ] );
|
|
|
|
|
// System.out.println( "\testado[ 1 ] : " + estado[ 1 ] );
|
|
|
|
|
|
|
|
|
|
if ( estado[ 0 ] == 1 || estado[ 0 ] == 2 || estado[ 1 ] == 1 || estado[ 1 ] == 2 )
|
|
|
|
|
{
|
|
|
|
|
links.add( "/"+servletName+"/?"+empresaID+"/"+estabelecimentoID+"/"+trabalhador.getID() );
|
|
|
|
|
// System.out.println( "\t\testado[ 0 ] == 1 || estado[ 0 ] == 2 || estado[ 1 ] == 1 || estado[ 1 ] == 2 : true" );
|
|
|
|
|
|
|
|
|
|
links.add( "/" + servletName + "/?" + empresaID + "/" + estabelecimentoID + "/" + trabalhador.getID() );
|
|
|
|
|
HashMap dadosTrabalhador = new HashMap();
|
|
|
|
|
dadosTrabalhador.put( "Nome", trabalhador.toString() );
|
|
|
|
|
dadosTrabalhador.put( "Consulta", CORES_ESTADOS.get( new Integer( estado[ 0 ] ) ) );
|
|
|
|
|
Object text = TEXTOS_ESTADOS.get( new Integer( estado[ 0 ] ) );
|
|
|
|
|
// System.out.println( "\t\t\tCONSULTA_ESTADO : " + text );
|
|
|
|
|
dadosTrabalhador.put( "Consulta_estado", text != null ? text : marcacoes[ index ][ 0 ] );
|
|
|
|
|
// System.out.println( "\t\t\t\tFinal : " + dadosTrabalhador.get( "Consulta_estado" ) );
|
|
|
|
|
|
|
|
|
|
dadosTrabalhador.put( "Exame", CORES_ESTADOS.get( new Integer( estado[ 1 ] ) ) );
|
|
|
|
|
text = TEXTOS_ESTADOS.get( new Integer( estado[ 1 ] ) );
|
|
|
|
|
// System.out.println( "\t\t\tEXAME_ESTADO : " + text );
|
|
|
|
|
dadosTrabalhador.put( "Exame_estado", text != null ? text : marcacoes[ index ][ 3 ] );
|
|
|
|
|
// System.out.println( "\t\t\t\tFinal : " + dadosTrabalhador.get( "Exame_estado" ) );
|
|
|
|
|
|
|
|
|
|
dados.add( dadosTrabalhador );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@ -677,43 +693,33 @@ public class doGetListaTrabalhadoresPendentes
|
|
|
|
|
protected boolean perfilTemConsultas( Integer trabalhadorID, Integer empresaID )
|
|
|
|
|
throws Exception
|
|
|
|
|
{
|
|
|
|
|
Executer executer = getExecuter();
|
|
|
|
|
String query = "SELECT a_consultas, b_consultas FROM empresas WHERE id = " + empresaID;
|
|
|
|
|
Virtual2DArray array = executer.executeQuery( new Select( query ) );
|
|
|
|
|
boolean consultas[] = new boolean[]{ "y".equals( array.get( 0, 0 ) ), "n".equals( array.get( 0, 0 ) ) };
|
|
|
|
|
query = "SELECT perfil FROM trabalhadores WHERE id = " + trabalhadorID;
|
|
|
|
|
array = executer.executeQuery( new Select( query ) );
|
|
|
|
|
Integer perfil = ( Integer )array.get( 0, 0 );
|
|
|
|
|
if( perfil != null )
|
|
|
|
|
{
|
|
|
|
|
return consultas[ perfil.intValue() - 1 ];
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return perfilTem( query, trabalhadorID );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected boolean perfilTemExames( Integer trabalhadorID, Integer empresaID )
|
|
|
|
|
throws Exception
|
|
|
|
|
{
|
|
|
|
|
Executer executer = getExecuter();
|
|
|
|
|
String query = "SELECT a_exames, b_exames FROM empresas WHERE id = " + empresaID;
|
|
|
|
|
return perfilTem( query, trabalhadorID );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private boolean perfilTem( String query, Integer trabalhadorID ) throws Exception
|
|
|
|
|
{
|
|
|
|
|
Executer executer = getExecuter();
|
|
|
|
|
Virtual2DArray array = executer.executeQuery( new Select( query ) );
|
|
|
|
|
boolean consultas[] = new boolean[]{ "y".equals( array.get( 0, 0 ) ), "n".equals( array.get( 0, 0 ) ) };
|
|
|
|
|
query = "SELECT perfil FROM trabalhadores WHERE id = " + trabalhadorID;
|
|
|
|
|
array = executer.executeQuery( new Select( query ) );
|
|
|
|
|
Integer perfil = ( Integer )array.get( 0, 0 );
|
|
|
|
|
if( perfil != null )
|
|
|
|
|
{
|
|
|
|
|
return consultas[ perfil.intValue() - 1 ];
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return perfil != null && consultas[ perfil.intValue() - 1 ];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// protected boolean verificarTrabalhador( Object consultas[][], Object exames[][] )
|
|
|
|
|
// {
|
|
|
|
|
// boolean estadoConsultas = false;
|
|
|
|
|
|