forked from Coded/SIPRP
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
403 lines
16 KiB
403 lines
16 KiB
package siprp.ficha;
|
|
|
|
import java.awt.Color;
|
|
import java.io.*;
|
|
import java.util.*;
|
|
|
|
import com.lowagie.text.*;
|
|
import com.lowagie.text.pdf.*;
|
|
|
|
public class ExamePDF {
|
|
// private static final Font FONT_BOLD = new Font( Font.TIMES_ROMAN, 9, Font.BOLD, new Color( 0, 0, 0 ) );
|
|
// private static final Font FONT_NORMAL = new Font( Font.TIMES_ROMAN, 9, Font.NORMAL, new Color( 0, 0, 0 ) );
|
|
private static final Font FONT_BOLD = FontFactory.getFont( "Arial", 8, Font.BOLD );
|
|
private static final Font FONT_NORMAL = FontFactory.getFont( "Arial", 8, Font.NORMAL );
|
|
private static final Font FONT_ZAPFDINGBATS = new Font( Font.ZAPFDINGBATS , 12, Font.NORMAL, new Color( 0, 0, 0 ) );
|
|
|
|
public ExamePDF()
|
|
{
|
|
}
|
|
|
|
public static void main( String[] args )
|
|
{
|
|
try
|
|
{
|
|
Hashtable ht = new Hashtable();
|
|
// designacao_social
|
|
// estabelecimentos.nome
|
|
// estabelecimentos.localidade
|
|
// servico_saude_tipo_interno
|
|
// servico_saude_tipo_interempresas
|
|
// servico_saude_tipo_externo
|
|
// servico_saude_tipo_sns
|
|
// servico_saude_designacao
|
|
// servico_higiene_tipo_interno
|
|
// servico_higiene_tipo_interempresas
|
|
// servico_higiene_tipo_externo
|
|
// servico_higiene_outro
|
|
// servico_higiene_designacao
|
|
// trabalhadores.nome
|
|
// sexo
|
|
// data_nascimento
|
|
// nacionalidade
|
|
// numero_mecanografico
|
|
// data_admissao
|
|
// categoria
|
|
// local_trabalho
|
|
// funcao_proposta
|
|
// data_admissao_funcao
|
|
// observacoes
|
|
// exames.data
|
|
// tipo_admissao
|
|
// tipo_periodico
|
|
// tipo_ocasional
|
|
// tipo_apos_doenca
|
|
// tipo_apos_acidente
|
|
// tipo_pedido_trabalhador
|
|
// tipo_pedido_empresa
|
|
// tipo_mudanca_funcao
|
|
// tipo_trabalho
|
|
// tipo_outro
|
|
// resultado_apto
|
|
// resultado_apto_condicionalmente
|
|
// resultado_inapto_temp
|
|
// resultado_inapto_def
|
|
// outra_funcao_1
|
|
// outra_funcao_2
|
|
// outra_funcao_3
|
|
// outra_funcao_4
|
|
// proximo_exame
|
|
// outras_recomendacoes
|
|
// medicos.nome
|
|
// numero_cedula
|
|
|
|
ht.put( "trabalhadores.nome", "Trabalhador do comércio" );
|
|
ht.put( "servico_saude_designacao", "Designacao servico saude" );
|
|
ht.put( "servico_saude_tipo_externo", Boolean.TRUE );
|
|
ht.put( "tipo_periodico", Boolean.TRUE );
|
|
ht.put( "resultado_inapto_temp", Boolean.TRUE );
|
|
FileOutputStream fos = new FileOutputStream( System.getProperty( "user.home" ) + "\\report.pdf" );
|
|
fos.write( new ExamePDF().createPDF( ht ) );
|
|
fos.close();
|
|
System.out.println( "File saved." );
|
|
Process proc = Runtime.getRuntime().exec( "cmd.exe /c \"" + System.getProperty( "user.home" ) + "\\report.pdf\"" );
|
|
proc.waitFor();
|
|
new File( System.getProperty( "user.home" ) + "\\report.pdf" ).delete();
|
|
System.out.println( "Done." );
|
|
}
|
|
catch( Exception e )
|
|
{
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
|
|
public void print( byte []pdf )
|
|
throws Exception
|
|
{
|
|
FileOutputStream fos = new FileOutputStream( System.getProperty( "user.home" ) + "\\report_ficha.pdf" );
|
|
fos.write( pdf );
|
|
fos.close();
|
|
System.out.println( "File saved." );
|
|
Process proc = Runtime.getRuntime().exec( "cmd.exe /c \"" + System.getProperty( "user.home" ) + "\\report_ficha.pdf\"" );
|
|
proc.waitFor();
|
|
new File( System.getProperty( "user.home" ) + "\\report_ficha.pdf" ).delete();
|
|
}
|
|
|
|
public byte[] createPDF( Hashtable values )
|
|
{
|
|
Document document = new Document();
|
|
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
|
|
|
document.setPageSize( PageSize.A4 );
|
|
|
|
try {
|
|
PdfWriter pdfw = PdfWriter.getInstance( document, bos );
|
|
|
|
document.addTitle( "Ficha de Aptid\u00e3o" );
|
|
document.addAuthor( "SIPRP" );
|
|
document.addCreator( "Evolute" );
|
|
|
|
document.open();
|
|
|
|
Paragraph conteudo = new Paragraph();
|
|
|
|
conteudo.add( new Chunk( "FICHA DE APTID\u00c3O\n",
|
|
// new Font( Font.TIMES_ROMAN, 10, Font.BOLD, new Color( 0, 0, 0 ) ) ) );
|
|
FontFactory.getFont( "Arial", 10, Font.BOLD ) ) );
|
|
conteudo.add( new Chunk( "(Portaria n\u00ba1031/2002, de 10 de Agosto)",
|
|
// new Font( Font.TIMES_ROMAN, 7, Font.NORMAL, new Color( 0, 0, 0 ) ) ) );
|
|
FontFactory.getFont( "Arial", 7, Font.BOLD ) ) );
|
|
|
|
conteudo.setAlignment( Element.ALIGN_CENTER );
|
|
|
|
document.add( conteudo );
|
|
|
|
Table table = new Table( 1 );
|
|
table.setBorderWidth( 1 );
|
|
table.setPadding( 5 );
|
|
table.setOffset( 0 );
|
|
table.setWidth( 100 );
|
|
|
|
table.addCell( new Phrase( "Empresa/Entidade",
|
|
FONT_BOLD ) );
|
|
|
|
StringBuffer texto = new StringBuffer();
|
|
Phrase ph = new Phrase( 12f );
|
|
|
|
Cell cell = new Cell();
|
|
texto.append( "DESIGNA\u00c7\u00c3O SOCIAL: " + values.get( "designacao_social" ) + "\n" );
|
|
texto.append( "ESTABELECIMENTO: " + values.get( "estabelecimentos.nome" )
|
|
+ " LOCALIDADE: " + values.get( "estabelecimentos.localidade" ) + "\n" );
|
|
texto.append( "SERVI\u00c7O DE SA\u00DaDE: Tipo " );
|
|
ph.add( new Chunk( texto.toString(), FONT_NORMAL ) );
|
|
|
|
texto = new StringBuffer( "Interno" );
|
|
ph.add( doCheckedPhrase( texto.toString(), values.get( "servico_saude_tipo_interno" ) != null ) );
|
|
|
|
texto = new StringBuffer( "Interempresas" );
|
|
ph.add( doCheckedPhrase( texto.toString(), values.get( "servico_saude_tipo_interempresas" ) != null, true ) );
|
|
|
|
texto = new StringBuffer( "Externo" );
|
|
ph.add( doCheckedPhrase( texto.toString(), values.get( "servico_saude_tipo_externo" ) != null, true ) );
|
|
|
|
texto = new StringBuffer( "Servi\u00e7o Nacional de Sa\u00fade\n" );
|
|
ph.add( doCheckedPhrase( texto.toString(), values.get( "servico_saude_tipo_sns" ) != null, true ) );
|
|
|
|
texto = new StringBuffer();
|
|
|
|
texto.append( "DESIGNA\u00c7\u00c3O: " + values.get( "servico_saude_designacao" ) + "\n" );
|
|
texto.append( "SERVI\u00c7O DE HIGIENE E SEGURAN\u00c7A: Tipo " );
|
|
ph.add( new Chunk( texto.toString(), FONT_NORMAL ) );
|
|
|
|
texto = new StringBuffer( "Interno" );
|
|
ph.add( doCheckedPhrase( texto.toString(), values.get( "servico_higiene_tipo_interno" ) != null ) );
|
|
|
|
texto = new StringBuffer( "Interempresas" );
|
|
ph.add( doCheckedPhrase( texto.toString(), values.get( "servico_higiene_tipo_interempresas" ) != null, true ) );
|
|
|
|
texto = new StringBuffer( "Externo" );
|
|
ph.add( doCheckedPhrase( texto.toString(), values.get( "servico_higiene_tipo_externo" ) != null, true ) );
|
|
|
|
texto = new StringBuffer( "Outro\n" );
|
|
ph.add( doCheckedPhrase( texto.toString(), values.get( "servico_higiene_outro" ) != null, true ) );
|
|
|
|
texto = new StringBuffer();
|
|
|
|
texto.append( "DESIGNA\u00c7\u00c3O: " + values.get( "servico_higiene_designacao" ) + "" );
|
|
|
|
ph.add( new Chunk( texto.toString(), FONT_NORMAL ) );
|
|
|
|
cell.addElement( ph );
|
|
//cell.addElement( new Phrase( 12f, texto.toString(), FONT_NORMAL ) );
|
|
table.addCell( cell );
|
|
document.add( table );
|
|
|
|
table = new Table( 1 );
|
|
table.setBorderWidth( 1 );
|
|
table.setPadding( 5 );
|
|
table.setOffset( 0 );
|
|
table.setWidth( 100 );
|
|
|
|
table.addCell( new Phrase( "Trabalhador",
|
|
FONT_BOLD ) );
|
|
|
|
texto = new StringBuffer();
|
|
|
|
texto.append( "NOME: " + values.get( "trabalhadores.nome" ) + "\n" );
|
|
texto.append( "SEXO: " + values.get( "sexo" ) + " DATA DE NASCIMENTO: "
|
|
+ values.get( "data_nascimento" ) + " NACIONALIDADE: "
|
|
+ values.get( "nacionalidade" ) + "\n" );
|
|
texto.append( "N\u00daMERO MECANOGR\u00c1FICO/OUTRO: " + values.get( "numero_mecanografico" )
|
|
+ " DATA DE ADMISS\u00c3O: " + values.get( "data_admissao" ) + "\n" );
|
|
texto.append( "CATEGORIA PROFISSIONAL: " + values.get( "categoria" )
|
|
+ " LOCAL DE TRABALHO: " + values.get( "local_trabalho" ) + "\n" );
|
|
texto.append( "FUN\u00c7\u00c3O PROPOSTA: " + values.get( "funcao_proposta" )
|
|
+ " DATA DE ADMISS\u00c3O NA FUN\u00c7\u00c3O: "
|
|
+ values.get( "data_admissao_funcao" ) + "" );
|
|
|
|
table.addCell( new Phrase( 12f, texto.toString(), FONT_NORMAL ) );
|
|
document.add( table );
|
|
|
|
table = new Table( 1 );
|
|
table.setBorderWidth( 1 );
|
|
table.setOffset( 0 );
|
|
table.setPadding( 5 );
|
|
table.setWidth( 100 );
|
|
|
|
table.addCell( new Phrase( "Observa\u00e7\u00f5es",
|
|
FONT_BOLD ) );
|
|
|
|
texto = new StringBuffer();
|
|
texto.append( values.get( "observacoes" ) );
|
|
|
|
table.addCell( new Phrase( 12f, texto.toString(), FONT_NORMAL ) );
|
|
document.add( table );
|
|
|
|
table = new Table( 2 );
|
|
table.setBorderWidth( 1 );
|
|
table.setOffset( 0 );
|
|
table.setPadding( 5 );
|
|
table.setWidth( 100 );
|
|
|
|
cell = new Cell( new Phrase( "Exame M\u00e9dico",
|
|
FONT_BOLD ) );
|
|
|
|
cell.setColspan( 2 );
|
|
table.addCell( cell );
|
|
|
|
texto = new StringBuffer();
|
|
ph = new Phrase( 12f );
|
|
texto.append( "DATA DO EXAME: " + values.get( "exames.data" ) + "\n" );
|
|
texto.append( "TIPO\n" );
|
|
ph.add( new Chunk( texto.toString(), FONT_NORMAL ) );
|
|
|
|
//texto = new StringBuffer( "ADMISS\u00c3O ...................................................................................... " );
|
|
texto = new StringBuffer( "ADMISS\u00c3O\n" );
|
|
ph.add( doCheckedPhrase( texto.toString(), values.get( "tipo_admissao" ) != null ) );
|
|
|
|
//texto = new StringBuffer( "PERI\u00d3DICO ..................................................................................... " );
|
|
texto = new StringBuffer( "PERI\u00d3DICO\n" );
|
|
ph.add( doCheckedPhrase( texto.toString(), values.get( "tipo_periodico" ) != null ) );
|
|
|
|
//texto = new StringBuffer( "OCASIONAL .................................................................................... " );
|
|
texto = new StringBuffer( "OCASIONAL\n" );
|
|
ph.add( doCheckedPhrase( texto.toString(), values.get( "tipo_ocasional" ) != null ) );
|
|
|
|
//texto = new StringBuffer( " AP\u00d3S DOEN\u00c7A ...................................................................... " );
|
|
texto = new StringBuffer( "AP\u00d3S DOEN\u00c7A\n" );
|
|
ph.add( doCheckedPhrase( texto.toString(), values.get( "tipo_apos_doenca" ) != null, true ) );
|
|
|
|
//texto = new StringBuffer( " AP\u00d3S ACIDENTE ................................................................... " );
|
|
texto = new StringBuffer( "AP\u00d3S ACIDENTE\n" );
|
|
ph.add( doCheckedPhrase( texto.toString(), values.get( "tipo_apos_acidente" ) != null, true ) );
|
|
|
|
//texto = new StringBuffer( " A PEDIDO DO TRABALHADOR ............................................. " );
|
|
texto = new StringBuffer( "A PEDIDO DO TRABALHADOR\n" );
|
|
ph.add( doCheckedPhrase( texto.toString(), values.get( "tipo_pedido_trabalhador" ) != null, true ) );
|
|
|
|
//texto = new StringBuffer( " A PEDIDO DO SERVI\u00c7O ........................................................ " );
|
|
texto = new StringBuffer( "A PEDIDO DO SERVI\u00c7O\n" );
|
|
ph.add( doCheckedPhrase( texto.toString(), values.get( "tipo_pedido_empresa" ) != null, true ) );
|
|
|
|
//texto = new StringBuffer( " POR MUDAN\u00c7A DE FUN\u00c7\u00c3O ................................................ " );
|
|
texto = new StringBuffer( "POR MUDAN\u00c7A DE FUN\u00c7\u00c3O\n" );
|
|
ph.add( doCheckedPhrase( texto.toString(), values.get( "tipo_mudanca_funcao" ) != null, true ) );
|
|
|
|
//texto = new StringBuffer( " POR ALTERA\u00c7\u00c3O DAS CONDI\u00c7\u00d5ES DE TRABALHO ......... " );
|
|
texto = new StringBuffer( "POR ALTERA\u00c7\u00c3O DAS CONDI\u00c7\u00d5ES DE TRABALHO\n" );
|
|
ph.add( doCheckedPhrase( texto.toString(), values.get( "tipo_trabalho" ) != null, true ) );
|
|
|
|
//texto = new StringBuffer( "OUTRO ............................................................................................ " );
|
|
texto = new StringBuffer( "OUTRO\n" );
|
|
ph.add( doCheckedPhrase( texto.toString(), values.get( "tipo_outro" ) != null ) );
|
|
|
|
texto = new StringBuffer();
|
|
texto.append( "ESPECIFIQUE: "
|
|
+ ( ( values.get( "tipo_outro" ) == null ) ? "" : values.get( "tipo_outro" ) ) + "" );
|
|
|
|
ph.add( new Chunk( texto.toString(), FONT_NORMAL ) );
|
|
|
|
table.addCell( ph );
|
|
//table.addCell( new Phrase( texto.toString(), FONT_NORMAL ) );
|
|
|
|
texto = new StringBuffer();
|
|
ph = new Phrase( 12f );
|
|
texto.append( "RESULTADO\n" );
|
|
ph.add( new Chunk( texto.toString(), FONT_NORMAL ) );
|
|
//texto = new StringBuffer( "\nAPTO ............................................................................................ " );
|
|
texto = new StringBuffer( "APTO\n" );
|
|
ph.add( doCheckedPhrase( texto.toString(), values.get( "resultado_apto" ) != null ) );
|
|
|
|
//texto = new StringBuffer( "\nAPTO CONDICIONALMENTE ..................................................... " );
|
|
texto = new StringBuffer( "APTO CONDICIONALMENTE\n\n" );
|
|
ph.add( doCheckedPhrase( texto.toString(), values.get( "resultado_apto_condicionalmente" ) != null ) );
|
|
|
|
//texto = new StringBuffer( "INAPTO TEMPORARIAMENTE ................................................... " );
|
|
texto = new StringBuffer( "INAPTO TEMPORARIAMENTE\n" );
|
|
ph.add( doCheckedPhrase( texto.toString(), values.get( "resultado_inapto_temp" ) != null ) );
|
|
|
|
//texto = new StringBuffer( "INAPTO DEFINITIVAMENTE ....................................................... " );
|
|
texto = new StringBuffer( "INAPTO DEFINITIVAMENTE\n\n" );
|
|
ph.add( doCheckedPhrase( texto.toString(), values.get( "resultado_inapto_def" ) != null ) );
|
|
|
|
texto = new StringBuffer();
|
|
texto.append( "OUTRAS FUN\u00c7\u00d5ES QUE PODE DESEMPENHAR\n" );
|
|
texto.append( " 1 "
|
|
+ ( ( values.get( "outra_funcao_1" ) == null ) ? "" : values.get( "outra_funcao_1" ) ) + "\n" );
|
|
texto.append( " 2 "
|
|
+ ( ( values.get( "outra_funcao_2" ) == null ) ? "" : values.get( "outra_funcao_2" ) ) + "\n" );
|
|
texto.append( " 3 "
|
|
+ ( ( values.get( "outra_funcao_3" ) == null ) ? "" : values.get( "outra_funcao_3" ) ) + "\n" );
|
|
texto.append( " 4 "
|
|
+ ( ( values.get( "outra_funcao_4" ) == null ) ? "" : values.get( "outra_funcao_4" ) ) + "" );
|
|
ph.add( new Chunk( texto.toString(), FONT_NORMAL ) );
|
|
// table.addCell( new Phrase( 14f, texto.toString(), FONT_NORMAL ) );
|
|
table.addCell( ph );
|
|
|
|
document.add( table );
|
|
|
|
table = new Table( 1 );
|
|
table.setBorderWidth( 1 );
|
|
table.setOffset( 0 );
|
|
table.setPadding( 5 );
|
|
table.setWidth( 100 );
|
|
|
|
table.addCell( new Phrase( "Outras Recomenda\u00e7\u00f5es",
|
|
FONT_BOLD ) );
|
|
|
|
texto = new StringBuffer();
|
|
|
|
texto.append( "PR\u00d3XIMO EXAME: " + values.get( "proximo_exame" ) + "\n" );
|
|
texto.append( "" + values.get( "outras_recomendacoes" ) + "" );
|
|
|
|
table.addCell( new Phrase( 12f, texto.toString(), FONT_NORMAL ) );
|
|
document.add( table );
|
|
|
|
|
|
table = new Table( 1 );
|
|
table.setBorderWidth( 1 );
|
|
table.setOffset( 0 );
|
|
table.setPadding( 5 );
|
|
table.setWidth( 100 );
|
|
|
|
texto = new StringBuffer();
|
|
|
|
texto.append( "M\u00c9DICO DO TRABALHO: "
|
|
+ values.get( "medicos.nome" ) + " C.P. " + values.get( "numero_cedula" ) + "\n\n" );
|
|
texto.append( "ASSINATURA _____________________________________________________________________________________\n\n" );
|
|
texto.append( "TOMEI CONHECIMENTO ___________________________________________________________ DATA:____/____/________\n" );
|
|
texto.append( " O RESPONS\u00c1VEL DOS RECURSOS HUMANOS" );
|
|
|
|
table.addCell( new Phrase( 18f, texto.toString(), FONT_NORMAL ) );
|
|
document.add( table );
|
|
|
|
}
|
|
catch( Exception e ) {
|
|
e.printStackTrace();
|
|
return null;
|
|
}
|
|
|
|
document.close();
|
|
return bos.toByteArray();
|
|
}
|
|
|
|
private Phrase doCheckedPhrase( String text, boolean checked, boolean indent )
|
|
{
|
|
Phrase p = new Phrase( 12f );
|
|
if( indent )
|
|
{
|
|
p.add( new Chunk( " " + ( char )( checked? 110: 111) + " ", FONT_ZAPFDINGBATS ) );
|
|
}
|
|
else
|
|
{
|
|
p.add( new Chunk( "" + ( char )( checked? 110: 111) + " ", FONT_ZAPFDINGBATS ) );
|
|
}
|
|
p.add( new Chunk( text, FONT_NORMAL ) );
|
|
return p;
|
|
}
|
|
|
|
private Phrase doCheckedPhrase( String text, boolean checked )
|
|
{
|
|
return doCheckedPhrase( text, checked, false );
|
|
}
|
|
} |