forked from Coded/SIPRP
git-svn-id: https://svn.coded.pt/svn/SIPRP@1572 bb69d46d-e84e-40c8-a05a-06db0d633741
parent
0081f21ed1
commit
14d90ae619
Binary file not shown.
Binary file not shown.
@ -0,0 +1,101 @@
|
|||||||
|
/*
|
||||||
|
* To change this template, choose Tools | Templates
|
||||||
|
* and open the template in the editor.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package utils;
|
||||||
|
|
||||||
|
import com.evolute.utils.arrays.Virtual2DArray;
|
||||||
|
import com.evolute.utils.db.Executer;
|
||||||
|
import com.evolute.utils.sql.Assignment;
|
||||||
|
import com.evolute.utils.sql.Expression;
|
||||||
|
import com.evolute.utils.sql.Field;
|
||||||
|
import com.evolute.utils.sql.Select2;
|
||||||
|
import com.evolute.utils.sql.Update;
|
||||||
|
import db.providers.EvoBaseProvider;
|
||||||
|
import java.util.Date;
|
||||||
|
import shst.companydataloaders.SIPRPPropertiesLoader;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author dneves
|
||||||
|
*/
|
||||||
|
public class PlanosUpdater
|
||||||
|
{
|
||||||
|
|
||||||
|
public static void main( String[] args )
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
SIPRPPropertiesLoader props = SIPRPPropertiesLoader.getInstance();
|
||||||
|
props.load();
|
||||||
|
|
||||||
|
EvoBaseProvider provider = EvoBaseProvider.getInstance();
|
||||||
|
Executer executer = provider.getExecuter();
|
||||||
|
Executer localExecuter = provider.getLocalExecuter();
|
||||||
|
|
||||||
|
// Expression whereExpression = new Field( "planos_actuacao.deleted_date" ).isEqual( null );
|
||||||
|
Expression whereExpression = null;
|
||||||
|
Select2 query = new Select2(
|
||||||
|
new String[] { "planos_actuacao" },
|
||||||
|
new Integer[] {},
|
||||||
|
new Expression[] {},
|
||||||
|
new String[] { "planos_actuacao.id", "planos_actuacao.estabelecimento_id", "planos_actuacao.data_visita" },
|
||||||
|
whereExpression,
|
||||||
|
new String[] { "planos_actuacao.estabelecimento_id", "planos_actuacao.data_visita" },
|
||||||
|
null, null, null
|
||||||
|
);
|
||||||
|
Virtual2DArray array = executer.executeQuery( query );
|
||||||
|
if ( array != null )
|
||||||
|
{
|
||||||
|
System.out.println( array.columnLength() + " : " );
|
||||||
|
|
||||||
|
for ( int i = 0; i < array.columnLength(); i++ )
|
||||||
|
{
|
||||||
|
Integer planoID = array.get( i, 0 );
|
||||||
|
Integer estabelecimentoID = array.get( i, 1 );
|
||||||
|
Date dataVisita = array.get( i, 2 );
|
||||||
|
|
||||||
|
System.out.println( planoID + " : " + estabelecimentoID + " : " + dataVisita );
|
||||||
|
|
||||||
|
Integer relatorioID = null;
|
||||||
|
Date dataDisponibilizacao = null;
|
||||||
|
|
||||||
|
Expression whereExpression2 = new Field( "marcacoes_estabelecimento.data" ).isEqual( dataVisita ).and(
|
||||||
|
new Field( "marcacoes_estabelecimento.estabelecimento_id" ).isEqual( estabelecimentoID )
|
||||||
|
);
|
||||||
|
Select2 query2 = new Select2(
|
||||||
|
new String[] { "hs_relatorio", "marcacoes_estabelecimento" },
|
||||||
|
new Integer[] { Select2.JOIN_INNER },
|
||||||
|
new Expression[] {
|
||||||
|
new Field( "marcacoes_estabelecimento.id" ).isEqual( new Field( "hs_relatorio.marcacao_id" ) )
|
||||||
|
},
|
||||||
|
new String[] { "hs_relatorio.id", "hs_relatorio.is_submetido" },
|
||||||
|
whereExpression2,
|
||||||
|
null,
|
||||||
|
null, null, null
|
||||||
|
);
|
||||||
|
Virtual2DArray array2 = localExecuter.executeQuery( query2 );
|
||||||
|
if ( array2 != null && array2.columnLength() > 0 )
|
||||||
|
{
|
||||||
|
relatorioID = array2.get( 0, 0 );
|
||||||
|
dataDisponibilizacao = array2.get( 0, 1 );
|
||||||
|
}
|
||||||
|
|
||||||
|
System.out.println( "\tRelatorioID : " + relatorioID );
|
||||||
|
|
||||||
|
Update upd = new Update( "planos_actuacao", new Assignment[] {
|
||||||
|
new Assignment( new Field( "hs_relatorio_id" ), relatorioID ),
|
||||||
|
new Assignment( new Field( "data_disponibilizacao" ), dataDisponibilizacao )
|
||||||
|
}, new Field( "id" ).isEqual( planoID ) );
|
||||||
|
executer.executeQuery( upd );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch ( Exception e )
|
||||||
|
{
|
||||||
|
System.out.println( e.getMessage() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in new issue