|
|
|
|
@ -1,10 +1,18 @@
|
|
|
|
|
package pdf;
|
|
|
|
|
|
|
|
|
|
import java.io.ByteArrayInputStream;
|
|
|
|
|
import java.io.ByteArrayOutputStream;
|
|
|
|
|
import java.io.InputStream;
|
|
|
|
|
import java.sql.Time;
|
|
|
|
|
import java.util.Calendar;
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
|
|
|
|
|
import org.jdom.Document;
|
|
|
|
|
import org.jdom.Element;
|
|
|
|
|
import org.jdom.output.XMLOutputter;
|
|
|
|
|
|
|
|
|
|
import com.evolute.utils.fop.FOPCreator;
|
|
|
|
|
import com.evolute.utils.fop.PDFCreator;
|
|
|
|
|
|
|
|
|
|
import analiseacidentestrabalho.Acidentado;
|
|
|
|
|
import analiseacidentestrabalho.AnaliseAcidente;
|
|
|
|
|
@ -15,23 +23,40 @@ import analiseacidentestrabalho.Utilizador;
|
|
|
|
|
|
|
|
|
|
public class PdfGenerator
|
|
|
|
|
{
|
|
|
|
|
protected final Utilizador utilizador;
|
|
|
|
|
protected final AnaliseAcidente analiseAcidente;
|
|
|
|
|
protected final Acidentado acidentado;
|
|
|
|
|
protected final Recomendacao recomendacoes[];
|
|
|
|
|
protected final Medida medidas[];
|
|
|
|
|
protected final Causa causa;
|
|
|
|
|
|
|
|
|
|
public PdfGenerator(
|
|
|
|
|
Utilizador utilizador,
|
|
|
|
|
AnaliseAcidente analiseAcidente,
|
|
|
|
|
Acidentado acidentado,
|
|
|
|
|
Recomendacao recomendacao,
|
|
|
|
|
Medida medida,
|
|
|
|
|
Recomendacao recomendacoes[],
|
|
|
|
|
Medida medidas[],
|
|
|
|
|
Causa causa )
|
|
|
|
|
{
|
|
|
|
|
this.utilizador = utilizador;
|
|
|
|
|
this.analiseAcidente = analiseAcidente;
|
|
|
|
|
this.acidentado = acidentado;
|
|
|
|
|
this.recomendacoes = recomendacoes;
|
|
|
|
|
this.medidas = medidas;
|
|
|
|
|
this.causa = causa;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public byte[] generatePdf()
|
|
|
|
|
throws Exception
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
|
|
Document doc = new Document( createXml() );
|
|
|
|
|
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
|
|
|
|
new XMLOutputter().output( doc, baos );
|
|
|
|
|
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
|
|
|
|
InputStream xmlIn = new ByteArrayInputStream( baos.toByteArray() );
|
|
|
|
|
InputStream xslStream = getClass().getClassLoader().getResourceAsStream( "pdf/analise_acidentes_trabalho.xsl" );
|
|
|
|
|
FOPCreator.getFOPCreator().createFOfromXML( xmlIn, xslStream, out );
|
|
|
|
|
return PDFCreator.getPDFCreator().createPdfFromFo( out.toByteArray() );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected Element createXml()
|
|
|
|
|
@ -40,13 +65,16 @@ public class PdfGenerator
|
|
|
|
|
Element numeroElement = new Element( "Numero" );
|
|
|
|
|
numeroElement.setText( analiseAcidente.getAnalise_nr() );
|
|
|
|
|
rootElement.addContent( numeroElement );
|
|
|
|
|
//PERGUNTAR
|
|
|
|
|
Date data = new Date();
|
|
|
|
|
Date data = analiseAcidente.getData_acidente();
|
|
|
|
|
rootElement.addContent( createDataElement( "Data", data ) );
|
|
|
|
|
rootElement.addContent( createEntidadeEmpregadoraElement() );
|
|
|
|
|
rootElement.addContent( createSeguroElement() );
|
|
|
|
|
rootElement.addContent( createEmpresaSHSTElement() );
|
|
|
|
|
rootElement.addContent( createAcidentadoElement() );
|
|
|
|
|
rootElement.addContent( createAcidenteElement() );
|
|
|
|
|
rootElement.addContent( createRecomendacoesSIPRPElement() );
|
|
|
|
|
rootElement.addContent( createMedidasElement() );
|
|
|
|
|
rootElement.addContent( createTomadaConhecimentoElement() );
|
|
|
|
|
return rootElement;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -114,50 +142,40 @@ public class PdfGenerator
|
|
|
|
|
{
|
|
|
|
|
Element acidentadoElement = new Element( "Acidentado" );
|
|
|
|
|
Element nomeElement = new Element( "Nome" );
|
|
|
|
|
nomeElement.setText( analiseAcidente.getNome_acidentado() );
|
|
|
|
|
nomeElement.setText( acidentado.getNome() );
|
|
|
|
|
acidentadoElement.addContent( nomeElement );
|
|
|
|
|
Element estabelecimentoOrigemElement = new Element( "EstabelecimentoOrigem" );
|
|
|
|
|
Element nomeEstabelecimentoOrigemElement = new Element( "Nome" );
|
|
|
|
|
//PERGUNTAR
|
|
|
|
|
nomeEstabelecimentoOrigemElement.setText( "" );
|
|
|
|
|
nomeEstabelecimentoOrigemElement.setText( acidentado.getEstabelecimento_origem() );
|
|
|
|
|
estabelecimentoOrigemElement.addContent( nomeEstabelecimentoOrigemElement );
|
|
|
|
|
acidentadoElement.addContent( estabelecimentoOrigemElement );
|
|
|
|
|
//PERGUNTAR
|
|
|
|
|
Date dataNascimento = new Date();
|
|
|
|
|
Date dataNascimento = acidentado.getData_nascimento();
|
|
|
|
|
acidentadoElement.addContent( createDataElement( "DataNascimento", dataNascimento ) );
|
|
|
|
|
Element biElement = new Element( "BilheteIdentidade" );
|
|
|
|
|
Element numeroBiElement = new Element( "Numero" );
|
|
|
|
|
//PERGUNTAR
|
|
|
|
|
numeroBiElement.setText( "" );
|
|
|
|
|
numeroBiElement.setText( acidentado.getBilhete_identidade() );
|
|
|
|
|
biElement.addContent( numeroBiElement );
|
|
|
|
|
acidentadoElement.addContent( biElement );
|
|
|
|
|
Element moradaElement = new Element( "Morada" );
|
|
|
|
|
//PERGUNTAR
|
|
|
|
|
moradaElement.setText( "" );
|
|
|
|
|
moradaElement.setText( acidentado.getMorada() + " " + acidentado.getCod_postal() );
|
|
|
|
|
acidentadoElement.addContent( moradaElement );
|
|
|
|
|
Element telefoneElement = new Element( "Telefone" );
|
|
|
|
|
//PERGUNTAR
|
|
|
|
|
telefoneElement.setText( "" );
|
|
|
|
|
telefoneElement.setText( acidentado.getContacto_telefonico() );
|
|
|
|
|
acidentadoElement.addContent( telefoneElement );
|
|
|
|
|
//PERGUNTAR
|
|
|
|
|
Date dataAdmissao = new Date();
|
|
|
|
|
Date dataAdmissao = acidentado.getData_admissao();
|
|
|
|
|
acidentadoElement.addContent( createDataElement( "DataAdmissao", dataAdmissao ) );
|
|
|
|
|
Element funcaoElement = new Element( "Funcao" );
|
|
|
|
|
//PERGUNTAR
|
|
|
|
|
funcaoElement.setText( "" );
|
|
|
|
|
funcaoElement.setText( acidentado.getFuncao() );
|
|
|
|
|
acidentadoElement.addContent( funcaoElement );
|
|
|
|
|
Element turnoElement = new Element( "Turno" );
|
|
|
|
|
//PERGUNTAR
|
|
|
|
|
turnoElement.setText( "" );
|
|
|
|
|
turnoElement.setText( acidentado.getTurno() );
|
|
|
|
|
acidentadoElement.addContent( turnoElement );
|
|
|
|
|
Element superiorElement = new Element( "Superior" );
|
|
|
|
|
Element nomeSuperiorElement = new Element( "Nome" );
|
|
|
|
|
//PERGUNTAR
|
|
|
|
|
nomeSuperiorElement.setText( "" );
|
|
|
|
|
nomeSuperiorElement.setText( acidentado.getNome_superior_hierarquico() );
|
|
|
|
|
superiorElement.addContent( nomeSuperiorElement );
|
|
|
|
|
Element emailSuperiorElement = new Element( "Email" );
|
|
|
|
|
//PERGUNTAR
|
|
|
|
|
emailSuperiorElement.setText( "" );
|
|
|
|
|
emailSuperiorElement.setText( acidentado.getEmail_superior_hierarquico() );
|
|
|
|
|
superiorElement.addContent( emailSuperiorElement );
|
|
|
|
|
acidentadoElement.addContent( superiorElement );
|
|
|
|
|
return acidentadoElement;
|
|
|
|
|
@ -168,54 +186,43 @@ public class PdfGenerator
|
|
|
|
|
Element acidenteElement = new Element( "Acidente" );
|
|
|
|
|
Element averiguadorElement = new Element( "Averiguador" );
|
|
|
|
|
Element nomeAveriguadorElement = new Element( "Nome" );
|
|
|
|
|
//PERGUNTAR
|
|
|
|
|
nomeAveriguadorElement.setText( "" );
|
|
|
|
|
nomeAveriguadorElement.setText( analiseAcidente.getAveriguador() );
|
|
|
|
|
averiguadorElement.addContent( nomeAveriguadorElement );
|
|
|
|
|
acidenteElement.addContent( averiguadorElement );
|
|
|
|
|
//PERGUNTAR
|
|
|
|
|
Date dataOcorrencia = new Date();
|
|
|
|
|
Date dataOcorrencia = analiseAcidente.getData_acidente();
|
|
|
|
|
acidenteElement.addContent( createDataElement( "DataOcorrencia", dataOcorrencia ) );
|
|
|
|
|
Time horaOcorrencia = analiseAcidente.getHora_acidente();
|
|
|
|
|
acidenteElement.addContent( createHoraElement( "HoraOcorrencia", horaOcorrencia ) );
|
|
|
|
|
Element horasTrabalhadasElement = new Element( "HorasTrabalhadas" );
|
|
|
|
|
//PERGUNTAR
|
|
|
|
|
horasTrabalhadasElement.setText( "" );
|
|
|
|
|
horasTrabalhadasElement.setText( "" + analiseAcidente.getHoras_turno() );
|
|
|
|
|
acidenteElement.addContent( horasTrabalhadasElement );
|
|
|
|
|
Element localElement = new Element( "Local" );
|
|
|
|
|
Element seccaoElement = new Element( "Seccao" );
|
|
|
|
|
//PERGUNTAR
|
|
|
|
|
seccaoElement.setText( "" );
|
|
|
|
|
seccaoElement.setText( analiseAcidente.getSeccao() );
|
|
|
|
|
localElement.addContent( seccaoElement );
|
|
|
|
|
Element localEspecificoElement = new Element( "LocalEspecifico" );
|
|
|
|
|
//PERGUNTAR
|
|
|
|
|
localEspecificoElement.setText( "" );
|
|
|
|
|
localEspecificoElement.setText( analiseAcidente.getLocal_trabalho() );
|
|
|
|
|
localElement.addContent( localEspecificoElement );
|
|
|
|
|
acidenteElement.addContent( localElement );
|
|
|
|
|
Element actividadeElement = new Element( "Actividade" );
|
|
|
|
|
Element descricaoActividadeElement = new Element( "Descricao" );
|
|
|
|
|
//PERGUNTAR
|
|
|
|
|
descricaoActividadeElement.setText( "" );
|
|
|
|
|
descricaoActividadeElement.setText( analiseAcidente.getTarefa() );
|
|
|
|
|
actividadeElement.addContent( descricaoActividadeElement );
|
|
|
|
|
Element objectosActividadeElement = new Element( "Objectos" );
|
|
|
|
|
//PERGUNTAR
|
|
|
|
|
objectosActividadeElement.setText( "" );
|
|
|
|
|
objectosActividadeElement.setText( analiseAcidente.getSubstancias() );
|
|
|
|
|
actividadeElement.addContent( objectosActividadeElement );
|
|
|
|
|
Element condicoesActividadeElement = new Element( "Condicoes" );
|
|
|
|
|
//PERGUNTAR
|
|
|
|
|
condicoesActividadeElement.setText( "" );
|
|
|
|
|
condicoesActividadeElement.setText( analiseAcidente.getCondicoes() );
|
|
|
|
|
actividadeElement.addContent( condicoesActividadeElement );
|
|
|
|
|
acidenteElement.addContent( actividadeElement );
|
|
|
|
|
Element testemunhasElement = new Element( "Testemunhas" );
|
|
|
|
|
//PERGUNTAR
|
|
|
|
|
testemunhasElement.setText( "" );
|
|
|
|
|
testemunhasElement.setText( analiseAcidente.getTestemunhas() );
|
|
|
|
|
acidenteElement.addContent( testemunhasElement );
|
|
|
|
|
Element causasElement = new Element( "Causas" );
|
|
|
|
|
//perguntar
|
|
|
|
|
causasElement.setText( "" );
|
|
|
|
|
causasElement.setText( causa.getCausa() );
|
|
|
|
|
acidenteElement.addContent( causasElement );
|
|
|
|
|
Element descricaoElement = new Element( "Descricao" );
|
|
|
|
|
//PERGUNTAR
|
|
|
|
|
descricaoElement.setText( "" );
|
|
|
|
|
descricaoElement.setText( analiseAcidente.getDescricao() );
|
|
|
|
|
acidenteElement.addContent( descricaoElement );
|
|
|
|
|
Element imagensElement = new Element( "Imagens" );
|
|
|
|
|
//PERGUNTAR
|
|
|
|
|
@ -229,12 +236,10 @@ public class PdfGenerator
|
|
|
|
|
}
|
|
|
|
|
acidenteElement.addContent( imagensElement );
|
|
|
|
|
Element conclusoesElement = new Element( "Conclusoes" );
|
|
|
|
|
//PERGUNTAR
|
|
|
|
|
conclusoesElement.setText( "" );
|
|
|
|
|
conclusoesElement.setText( analiseAcidente.getConclusoes() );
|
|
|
|
|
acidenteElement.addContent( conclusoesElement );
|
|
|
|
|
Element accoesTomadasElement = new Element( "AccoesTomadas" );
|
|
|
|
|
//PERGUNTAR
|
|
|
|
|
accoesTomadasElement.setText( "" );
|
|
|
|
|
accoesTomadasElement.setText( analiseAcidente.getAccoes() );
|
|
|
|
|
acidenteElement.addContent( accoesTomadasElement );
|
|
|
|
|
Element formacaoSHSTElement = new Element( "FormacaoSHST" );
|
|
|
|
|
Element teveFormacaoSHSTElement = new Element( "TeveFormacao" );
|
|
|
|
|
@ -313,53 +318,111 @@ public class PdfGenerator
|
|
|
|
|
incapacidadeElement.addContent( coeficienteIncapacidadeElement );
|
|
|
|
|
//PERGUNTAR
|
|
|
|
|
Date dataAvaliacao = new Date();
|
|
|
|
|
// <DataAvaliacao>
|
|
|
|
|
// <DataRevisao>
|
|
|
|
|
// <PeriodoIncapacidade>
|
|
|
|
|
// <Inicio>
|
|
|
|
|
// <Ano>
|
|
|
|
|
// <Mes>
|
|
|
|
|
// <Dia>
|
|
|
|
|
// <Fim>
|
|
|
|
|
// <Ano>
|
|
|
|
|
// <Mes>
|
|
|
|
|
// <Dia>
|
|
|
|
|
incapacidadeElement.addContent( createDataElement( "DataAvaliacao", dataAvaliacao ) );
|
|
|
|
|
//PERGUNTAR
|
|
|
|
|
Date dataRevisao = new Date();
|
|
|
|
|
incapacidadeElement.addContent( createDataElement( "DataRevisao", dataRevisao ) );
|
|
|
|
|
Element periodoIncapacidadeElement = new Element( "PeriodoIncapacidade" );
|
|
|
|
|
//PERGUNTAR
|
|
|
|
|
Date inicioIncapacidade = new Date();
|
|
|
|
|
periodoIncapacidadeElement.addContent( createDataElement( "Inicio", inicioIncapacidade ) );
|
|
|
|
|
//PERGUNTAR
|
|
|
|
|
Date fimIncapacidade = new Date();
|
|
|
|
|
periodoIncapacidadeElement.addContent( createDataElement( "Fim", fimIncapacidade ) );
|
|
|
|
|
incapacidadeElement.addContent( periodoIncapacidadeElement );
|
|
|
|
|
acidenteElement.addContent( incapacidadeElement );
|
|
|
|
|
return acidenteElement;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected Element createRecomendacoesSIPRPElement()
|
|
|
|
|
{
|
|
|
|
|
Element recomendacoesSIPRPElement = new Element( "RecomendacoesSIPRP" );
|
|
|
|
|
for( int r = 0; r < recomendacoes.length; r++ )
|
|
|
|
|
{
|
|
|
|
|
Element recomendacaoElement = new Element( "Recomendacao" );
|
|
|
|
|
recomendacaoElement.setText( recomendacoes[ r ].getRecomendacao() );
|
|
|
|
|
recomendacoesSIPRPElement.addContent( recomendacaoElement );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return recomendacoesSIPRPElement;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected Element createMedidasElement()
|
|
|
|
|
{
|
|
|
|
|
Element medidasElement = new Element( "MedidasAdoptar" );
|
|
|
|
|
for( int m = 0; m < medidas.length; m++ )
|
|
|
|
|
{
|
|
|
|
|
Element medidaElement = new Element( "Medida" );
|
|
|
|
|
medidaElement.setText( medidas[ m ].getMedida() );
|
|
|
|
|
medidasElement.addContent( medidaElement );
|
|
|
|
|
}
|
|
|
|
|
return medidasElement;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected Element createTomadaConhecimentoElement()
|
|
|
|
|
{
|
|
|
|
|
Element tomadaConhecimentoElement = new Element( "TomadaConhecimento" );
|
|
|
|
|
//PERGUNTAR
|
|
|
|
|
tomadaConhecimentoElement.addContent( createAssinaturaElement( "DepartamentoSeguranca", "", new Date() ) );
|
|
|
|
|
tomadaConhecimentoElement.addContent( createAssinaturaElement( "TecnicoHST", "", new Date() ) );
|
|
|
|
|
tomadaConhecimentoElement.addContent( createAssinaturaElement( "ResponsavelSeguranca", "", new Date() ) );
|
|
|
|
|
tomadaConhecimentoElement.addContent( createAssinaturaElement( "ResponsavelRH", "", new Date() ) );
|
|
|
|
|
tomadaConhecimentoElement.addContent( createAssinaturaElement( "SuperiorHierarquico", "", new Date() ) );
|
|
|
|
|
tomadaConhecimentoElement.addContent( createAssinaturaElement( "DepartamentoSeguranca", "", new Date() ) );
|
|
|
|
|
return tomadaConhecimentoElement;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected Element createAssinaturaElement( String nome, String nomeStr, Date data )
|
|
|
|
|
{
|
|
|
|
|
Element assinaturaElement = new Element( nome );
|
|
|
|
|
Element nomeElement = new Element( "Nome" );
|
|
|
|
|
nomeElement.setText( nomeStr );
|
|
|
|
|
assinaturaElement.addContent( nomeElement );
|
|
|
|
|
assinaturaElement.addContent( createDataElement( "Data", data ) );
|
|
|
|
|
return assinaturaElement;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected Element createDataElement( String nome, Date data )
|
|
|
|
|
{
|
|
|
|
|
Element dataElement = new Element( nome );
|
|
|
|
|
Calendar cal = Calendar.getInstance();
|
|
|
|
|
cal.setTime( data );
|
|
|
|
|
|
|
|
|
|
Element anoElement = new Element( "Ano" );
|
|
|
|
|
anoElement.setText( "" + cal.get( Calendar.YEAR ) );
|
|
|
|
|
dataElement.addContent( anoElement );
|
|
|
|
|
Element mesElement = new Element( "Mes" );
|
|
|
|
|
int mes = cal.get( Calendar.MONTH ) + 1;
|
|
|
|
|
mesElement.setText( mes > 9 ? ( "" + mes ) : ( "0" + mes ) );
|
|
|
|
|
dataElement.addContent( mesElement );
|
|
|
|
|
Element diaElement = new Element( "Dia" );
|
|
|
|
|
int dia = cal.get( Calendar.DAY_OF_MONTH );
|
|
|
|
|
diaElement.setText( dia > 9 ? ( "" + dia ) : ( "0" + dia ) );
|
|
|
|
|
dataElement.addContent( diaElement );
|
|
|
|
|
|
|
|
|
|
if( data != null )
|
|
|
|
|
{
|
|
|
|
|
Calendar cal = Calendar.getInstance();
|
|
|
|
|
cal.setTime( data );
|
|
|
|
|
anoElement.setText( "" + cal.get( Calendar.YEAR ) );
|
|
|
|
|
int mes = cal.get( Calendar.MONTH ) + 1;
|
|
|
|
|
mesElement.setText( mes > 9 ? ( "" + mes ) : ( "0" + mes ) );
|
|
|
|
|
int dia = cal.get( Calendar.DAY_OF_MONTH );
|
|
|
|
|
diaElement.setText( dia > 9 ? ( "" + dia ) : ( "0" + dia ) );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return dataElement;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected Element createHoraElement( String nome, Date hora )
|
|
|
|
|
{
|
|
|
|
|
Element horaElement = new Element( nome );
|
|
|
|
|
Calendar cal = Calendar.getInstance();
|
|
|
|
|
cal.setTime( hora );
|
|
|
|
|
Element horasElement = new Element( "Horas" );
|
|
|
|
|
int horas = cal.get( Calendar.HOUR_OF_DAY );
|
|
|
|
|
horasElement.setText( horas > 9 ? ( "" + horas ) : ( "0" + horas ) );
|
|
|
|
|
horaElement.addContent( horasElement );
|
|
|
|
|
Element minutosElement = new Element( "Minutos" );
|
|
|
|
|
int minutos = cal.get( Calendar.MINUTE );
|
|
|
|
|
minutosElement.setText( minutos > 9 ? ( "" + minutos ) : ( "0" + minutos ) );
|
|
|
|
|
horaElement.addContent( minutosElement );
|
|
|
|
|
if( hora != null )
|
|
|
|
|
{
|
|
|
|
|
Calendar cal = Calendar.getInstance();
|
|
|
|
|
cal.setTime( hora );
|
|
|
|
|
int horas = cal.get( Calendar.HOUR_OF_DAY );
|
|
|
|
|
horasElement.setText( horas > 9 ? ( "" + horas ) : ( "0" + horas ) );
|
|
|
|
|
int minutos = cal.get( Calendar.MINUTE );
|
|
|
|
|
minutosElement.setText( minutos > 9 ? ( "" + minutos ) : ( "0" + minutos ) );
|
|
|
|
|
}
|
|
|
|
|
return horaElement;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|