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

lxbfYeaa
Diogo Neves 16 years ago
parent 058a15e20f
commit debca72c11

@ -15,6 +15,9 @@ import java.util.List;
* @author lluis * @author lluis
*/ */
public class PlanoActuacao { public class PlanoActuacao {
private static final SimpleDateFormat D_F = new SimpleDateFormat( "dd-MM-yyyy" );
private Integer id; private Integer id;
private Integer estabelecimento_id; private Integer estabelecimento_id;
private String nome_estabelecimento; private String nome_estabelecimento;
@ -62,6 +65,12 @@ public class PlanoActuacao {
private Date data_email_controlo; private Date data_email_controlo;
private Boolean concluido_por_desactivacao; private Boolean concluido_por_desactivacao;
private Date data_desactivacao;
private Integer tecnico_superior_hs_id;
private String tecnico_superior_hs_nome;
private String tecnicos_nomes;
public Integer getId() { public Integer getId() {
return id; return id;
@ -123,11 +132,27 @@ public class PlanoActuacao {
} }
public String getFase_nome() { public String getFase_nome() {
if ( fase.intValue() == Global.FASE_CONCLUIDO && getConcluidoPorDesactivacao() != null && getConcluidoPorDesactivacao() ) String fn = fase_nome;
if ( fase.intValue() == Global.FASE_CONCLUIDO )
{ {
return "Prazo Expirado"; if ( getConcluidoPorDesactivacao() != null && getConcluidoPorDesactivacao() )
{
fn = "Prazo Expirado";
if ( getDataDesactivacao() != null )
{
fn += " (em " + D_F.format( getDataDesactivacao() ) + ")";
}
} }
return fase_nome; }
return fn;
// if ( fase.intValue() == Global.FASE_CONCLUIDO && getConcluidoPorDesactivacao() != null && getConcluidoPorDesactivacao() )
// {
// return "Prazo Expirado";
// }
// return fase_nome;
} }
public void setFase_nome(String fase_nome) { public void setFase_nome(String fase_nome) {
@ -392,4 +417,50 @@ public class PlanoActuacao {
{ {
this.concluido_por_desactivacao = value; this.concluido_por_desactivacao = value;
} }
public Date getDataDesactivacao()
{
return data_desactivacao;
}
public void setDataDesactivacao( Date data_desactivacao )
{
this.data_desactivacao = data_desactivacao;
}
public Integer getTecnico_superior_hs_id()
{
return tecnico_superior_hs_id;
}
public void setTecnico_superior_hs_id( Integer tecnico_superior_hs_id )
{
this.tecnico_superior_hs_id = tecnico_superior_hs_id;
}
public String getTecnico_superior_hs_nome() {
return tecnico_superior_hs_nome;
}
public void setTecnico_superior_hs_nome(String tecnico_superior_hs_nome) {
this.tecnico_superior_hs_nome = tecnico_superior_hs_nome;
}
public String getTecnicos_nomes()
{
String nomes = getTecnico_hs_nome();
if ( getTecnico_superior_hs_nome() != null )
{
nomes = nomes == null ? getTecnico_superior_hs_nome() : nomes + ", " + getTecnico_superior_hs_nome();
}
setTecnicos_nomes( nomes );
return tecnicos_nomes;
}
public void setTecnicos_nomes(String tecnicos_nomes) {
this.tecnicos_nomes = tecnicos_nomes;
}
} }

@ -481,7 +481,7 @@ public class CreatePlanosDataProvider {
{ {
Statement st = createStatement(); Statement st = createStatement();
Integer newId = getMaxTableId("planos_actuacao"); Integer newId = getMaxTableId("planos_actuacao");
String sql = "insert into planos_actuacao (id, estabelecimento_id, fase, data_visita, data_relatorio, nome_estabelecimento, empresa_id, nome_empresa, data_controlo, tecnico_hs_id, tecnico_hs_nome) values ("; String sql = "insert into planos_actuacao (id, estabelecimento_id, fase, data_visita, data_relatorio, nome_estabelecimento, empresa_id, nome_empresa, data_controlo, tecnico_hs_id, tecnico_hs_nome, tecnico_superior_hs_id, tecnico_superior_hs_nome, data_desactivacao) values (";
sql += newId + ", "; sql += newId + ", ";
sql += p.getEstabelecimento_id() + ", "; sql += p.getEstabelecimento_id() + ", ";
sql += p.getFase() + ", '"; sql += p.getFase() + ", '";
@ -495,6 +495,8 @@ public class CreatePlanosDataProvider {
Date today = new Date(); Date today = new Date();
sqlDate = new java.sql.Date(today.getTime()); sqlDate = new java.sql.Date(today.getTime());
sql += sqlDate + "', "; sql += sqlDate + "', ";
//tecnico
sql += p.getTecnico_hs_id() + ", "; sql += p.getTecnico_hs_id() + ", ";
if(p.getTecnico_hs_nome() == null) if(p.getTecnico_hs_nome() == null)
{ {
@ -505,6 +507,15 @@ public class CreatePlanosDataProvider {
sql += "'" + p.getTecnico_hs_nome() + "'"; sql += "'" + p.getTecnico_hs_nome() + "'";
} }
//tecnico_superior
sql += ", ";
sql += p.getTecnico_superior_hs_id() + ", ";
sql += p.getTecnico_superior_hs_nome() == null ? null : "'" + p.getTecnico_superior_hs_nome() + "'";
//data_desactivacao
sql += ", ";
sql += "null";
sql += ")"; sql += ")";
System.out.println("SQL CREATE PLANO : " + sql); System.out.println("SQL CREATE PLANO : " + sql);

@ -35,7 +35,7 @@ public class PlanosDataProvider extends GenericDataProvider{
{ {
Statement st = createStatement(); Statement st = createStatement();
Integer newId = getMaxTableId("planos_actuacao"); Integer newId = getMaxTableId("planos_actuacao");
String sql = "insert into planos_actuacao (id, estabelecimento_id, fase, data_visita, data_relatorio, nome_estabelecimento, empresa_id, nome_empresa, data_controlo, tecnico_hs_id, tecnico_hs_nome, concluido_por_desactivacao) values ("; String sql = "insert into planos_actuacao (id, estabelecimento_id, fase, data_visita, data_relatorio, nome_estabelecimento, empresa_id, nome_empresa, data_controlo, tecnico_hs_id, tecnico_hs_nome, concluido_por_desactivacao, data_desactivacao, tecnico_superior_hs_id, tecnico_superior_hs_nome) values (";
sql += newId + ", "; sql += newId + ", ";
sql += p.getEstabelecimento_id() + ", "; sql += p.getEstabelecimento_id() + ", ";
sql += p.getFase() + ", '"; sql += p.getFase() + ", '";
@ -63,11 +63,21 @@ public class PlanosDataProvider extends GenericDataProvider{
if ( p.getConcluidoPorDesactivacao() == null ) if ( p.getConcluidoPorDesactivacao() == null )
{ {
sql += Boolean.FALSE; sql += Boolean.FALSE;
sql += ", null";
} }
else else
{ {
sql += p.getConcluidoPorDesactivacao(); sql += p.getConcluidoPorDesactivacao();
if ( p.getConcluidoPorDesactivacao() )
{
sql += ", now()";
}
} }
sql += ", ";
sql += p.getTecnico_superior_hs_id() + ", ";
sql += p.getTecnico_superior_hs_nome() == null ? null : "'" + p.getTecnico_superior_hs_nome() + "'";
sql += ")"; sql += ")";
System.out.println("SQL CREATE PLANO : " + sql); System.out.println("SQL CREATE PLANO : " + sql);
@ -130,6 +140,7 @@ public class PlanosDataProvider extends GenericDataProvider{
sql += "correcao = '" + p.getCorrecao() + "', "; sql += "correcao = '" + p.getCorrecao() + "', ";
sql += "fase_antes_correcao = " + p.getFase_antes_correcao() + ", "; sql += "fase_antes_correcao = " + p.getFase_antes_correcao() + ", ";
sql += "concluido_por_desactivacao = " + p.getConcluidoPorDesactivacao() + ", "; sql += "concluido_por_desactivacao = " + p.getConcluidoPorDesactivacao() + ", ";
sql += "data_desactivacao = " + new java.sql.Date( p.getDataDesactivacao().getTime() ) + ", ";
if(p.getData_validacao_dir_loja() == null) if(p.getData_validacao_dir_loja() == null)
{ {
@ -444,7 +455,7 @@ public class PlanosDataProvider extends GenericDataProvider{
{ {
nome = StringPlainer.convertString( nome.trim() ); nome = StringPlainer.convertString( nome.trim() );
nome = nome.replaceAll( " ", "%" ); nome = nome.replaceAll( " ", "%" );
whereExpression += "AND plain_utf8( planos_actuacao.tecnico_hs_nome ) LIKE '%" + nome + "%' "; whereExpression += "AND ( plain_utf8( planos_actuacao.tecnico_hs_nome ) LIKE '%" + nome + "%' OR plain_utf8( planos_actuacao.tecnico_superior_hs_nome ) LIKE '%" + nome + "%' ) ";
} }
if ( estabelecimento != null ) if ( estabelecimento != null )
{ {
@ -748,6 +759,9 @@ public class PlanosDataProvider extends GenericDataProvider{
pa.setTecnico_hs_id(new Integer(rs.getInt("tecnico_hs_id"))); pa.setTecnico_hs_id(new Integer(rs.getInt("tecnico_hs_id")));
pa.setTecnico_hs_nome(rs.getString("tecnico_hs_nome")); pa.setTecnico_hs_nome(rs.getString("tecnico_hs_nome"));
pa.setConcluidoPorDesactivacao( new Boolean( rs.getBoolean( "concluido_por_desactivacao" ) ) ); pa.setConcluidoPorDesactivacao( new Boolean( rs.getBoolean( "concluido_por_desactivacao" ) ) );
pa.setDataDesactivacao( rs.getDate( "data_desactivacao" ) );
pa.setTecnico_superior_hs_id( new Integer( rs.getInt( "tecnico_superior_hs_id" ) ) );
pa.setTecnico_superior_hs_nome( rs.getString( "tecnico_superior_hs_nome" ) );
list.add(pa); list.add(pa);

@ -587,20 +587,25 @@ public class ListaPlanos extends AbstractPageBean {
return "ver_plano"; return "ver_plano";
} }
public String goImprimirPlano_action() { private void createPdf( Integer pID )
// TODO: Process the action. Return value is a navigation {
// case name where null will return to the same page.
PlanoActuacao p = getTableActivosRowData();
PlanoActuacaoPDFCreator pdfCreator = new PlanoActuacaoPDFCreator(); PlanoActuacaoPDFCreator pdfCreator = new PlanoActuacaoPDFCreator();
try try
{ {
byte[] pdf = pdfCreator.createPDF(p.getId(), true); byte[] pdf = pdfCreator.createPDF( pID, true );
showPdf(pdf); showPdf( pdf );
} }
catch(Exception ex) catch(Exception ex)
{ {
ErrorLogger.logException( ex ); ErrorLogger.logException( ex );
} }
}
public String goImprimirPlano_action() {
// TODO: Process the action. Return value is a navigation
// case name where null will return to the same page.
PlanoActuacao p = getTableActivosRowData();
createPdf( p.getId() );
return null; return null;
} }
@ -609,16 +614,7 @@ public class ListaPlanos extends AbstractPageBean {
// TODO: Process the action. Return value is a navigation // TODO: Process the action. Return value is a navigation
// case name where null will return to the same page. // case name where null will return to the same page.
PlanoActuacao p = getTableSeguimentoRowData(); PlanoActuacao p = getTableSeguimentoRowData();
PlanoActuacaoPDFCreator pdfCreator = new PlanoActuacaoPDFCreator(); createPdf( p.getId() );
try
{
byte[] pdf = pdfCreator.createPDF(p.getId(), true);
showPdf(pdf);
}
catch(Exception ex)
{
ErrorLogger.logException( ex );
}
return null; return null;
} }
@ -627,18 +623,11 @@ public class ListaPlanos extends AbstractPageBean {
// TODO: Process the action. Return value is a navigation // TODO: Process the action. Return value is a navigation
// case name where null will return to the same page. // case name where null will return to the same page.
PlanoActuacao p = getTableConcluidosRowData(); PlanoActuacao p = getTableConcluidosRowData();
PlanoActuacaoPDFCreator pdfCreator = new PlanoActuacaoPDFCreator(); if ( ! p.getConcluidoPorDesactivacao() )
try
{
byte[] pdf = pdfCreator.createPDF(p.getId(), true);
showPdf(pdf);
}
catch(Exception ex)
{ {
ErrorLogger.logException( ex ); createPdf( p.getId() );
} }
return null; return null;
} }

@ -188,6 +188,12 @@ public class PlanosActuacao {
p.setTecnico_hs_nome(relatorio.getToHsMarcacoesEstabelecimento().getToMarcacoesTecnicosHst().getNome()); p.setTecnico_hs_nome(relatorio.getToHsMarcacoesEstabelecimento().getToMarcacoesTecnicosHst().getNome());
} }
if ( relatorio.getToHsMarcacoesEstabelecimento().getToMarcacoesTecnicosSuperioresHst() != null )
{
p.setTecnico_superior_hs_id( relatorio.getToHsMarcacoesEstabelecimento().getToMarcacoesTecnicosSuperioresHst().getId() );
p.setTecnico_superior_hs_nome( relatorio.getToHsMarcacoesEstabelecimento().getToMarcacoesTecnicosSuperioresHst().getNome() );
}
///////// /////////
p.setFase(new Integer(Global.FASE_SEGURANCA_PREENCHIMENTO)); p.setFase(new Integer(Global.FASE_SEGURANCA_PREENCHIMENTO));
p.setEstabelecimento_id(relatorio.getToHsMarcacoesEstabelecimento().getToEstabelecimentos().getId()); p.setEstabelecimento_id(relatorio.getToHsMarcacoesEstabelecimento().getToEstabelecimentos().getId());

Loading…
Cancel
Save