From 1700ad09e73c6cc7042b4522928ab761ba869e2e Mon Sep 17 00:00:00 2001 From: Frederico Palma Date: Wed, 29 Mar 2006 00:20:05 +0000 Subject: [PATCH] no message git-svn-id: https://svn.coded.pt/svn/SIPRP@241 bb69d46d-e84e-40c8-a05a-06db0d633741 --- trunk/siprp/FichaDataProvider.java | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/trunk/siprp/FichaDataProvider.java b/trunk/siprp/FichaDataProvider.java index cbcb94f1..0b797a73 100644 --- a/trunk/siprp/FichaDataProvider.java +++ b/trunk/siprp/FichaDataProvider.java @@ -456,12 +456,32 @@ public class FichaDataProvider extends MetaProvider implements SearchExecuter { public Integer getMarcacaoIDByTrabalhador( Integer trabalhadorID ) throws Exception { - Select select = + Select realizadaSelect = new Select( new String[]{ "marcacoes_trabalhador" }, - new String[]{ "id" }, + new String[]{ "MAX(data)" }, new Field( "trabalhador_id" ).isEqual( trabalhadorID ).and( - new Field( "data" ).isGreater( new Date() ) ).and( + new Field( "estado" ).isEqual( new Integer( 2 ) ) ).and( new Field( "tipo" ).isEqual( new Integer( siprp.data.MarcacaoTrabalhadorData.TIPO_CONSULTA ) ) ) ); + Virtual2DArray realizadaArray = executer.executeQuery( realizadaSelect ); + Date realizada = (Date) realizadaArray.get( 0, 0 ); + Select select; + if( realizada == null ) + { + select = new Select( new String[]{ "marcacoes_trabalhador" }, + new String[]{ "MIN(id)" }, + new Field( "trabalhador_id" ).isEqual( trabalhadorID ).and( + new Field( "estado" ).isEqual( new Integer( 0 ) ) ).and( + new Field( "tipo" ).isEqual( new Integer( siprp.data.MarcacaoTrabalhadorData.TIPO_CONSULTA ) ) ) ); + } + else + { + select = new Select( new String[]{ "marcacoes_trabalhador" }, + new String[]{ "MIN(id)" }, + new Field( "trabalhador_id" ).isEqual( trabalhadorID ).and( + new Field( "estado" ).isEqual( new Integer( 0 ) ) ).and( + new Field( "data" ).isGreater( realizada ) ).and( + new Field( "tipo" ).isEqual( new Integer( siprp.data.MarcacaoTrabalhadorData.TIPO_CONSULTA ) ) ) ); + } Virtual2DArray array = executer.executeQuery( select ); if( array.columnLength() == 0 ) {