no message

git-svn-id: https://svn.coded.pt/svn/SIPRP@382 bb69d46d-e84e-40c8-a05a-06db0d633741
Luis Flores 19 years ago
parent fc9ec96215
commit 41b3355a35

@ -27,6 +27,7 @@ public final class Exame implements JDOInnerObject
private Trabalhador trabalhador;
private Medico medico;
private byte[] pdf;
private byte[] fo;
private String inactivo;
public Exame()
@ -95,6 +96,10 @@ public final class Exame implements JDOInnerObject
{
return pdf;
}
else if( fieldName == ExameData.FO )
{
return fo;
}
else if( fieldName == ExameData.INACTIVO )
{
return inactivo;

@ -28,18 +28,19 @@ public final class ExameData extends JDOObject
public static final String TRABALHADOR = "trabalhador";
public static final String MEDICO = "medico";
public static final String PDF = "pdf";
public static final String FO = "fo";
public static final String INACTIVO = "inactivo";
public static final String FIELD_NAMES[] = new String[]{
DATA, TIPO, OCASIONAL, OUTRO_TIPO, RESULTADO, OUTRA_FUNCAO_1, OUTRA_FUNCAO_2,
OUTRA_FUNCAO_3, OUTRA_FUNCAO_4, PROXIMO_EXAME, OUTRAS_RECOMENDACOES,
TRABALHADOR, MEDICO, PDF, };
TRABALHADOR, MEDICO, PDF, FO, };
protected static final String ALL_FIELD_NAMES[] = new String[]{
ID, DATA, TIPO, OCASIONAL, OUTRO_TIPO, RESULTADO, OUTRA_FUNCAO_1, OUTRA_FUNCAO_2,
OUTRA_FUNCAO_3, OUTRA_FUNCAO_4, PROXIMO_EXAME, OUTRAS_RECOMENDACOES,
TRABALHADOR, MEDICO, PDF, INACTIVO, };
TRABALHADOR, MEDICO, PDF, FO, INACTIVO, };
private HashMap dataHash;

@ -1035,6 +1035,12 @@
<extension vendor-name="evolute" key="java-type" value="byte[]"/>
</field>
<field name="fo">
<extension vendor-name="jpox" key="column-name" value="fo"/>
<extension vendor-name="evolute" key="java-type" value="byte[]"/>
</field>
<field name="inactivo" null-value="default">
<extension vendor-name="jpox" key="column-name" value="inactivo"/>
<extension vendor-name="jpox" key="length" value="1"/>

@ -56,7 +56,7 @@ public class ExamePDF {
{
try
{
Hashtable ht = new Hashtable();
HashMap<String,String> ht = new HashMap<String,String>();
// designacao_social
// estabelecimentos.nome
// estabelecimentos.localidade
@ -107,9 +107,9 @@ public class ExamePDF {
ht.put( "trabalhadores.nome", "Trabalhador do com\u00e9rcio" );
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 );
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();
@ -133,7 +133,7 @@ public class ExamePDF {
FileOutputStream fos = new FileOutputStream( System.getProperty( "user.home" ) + System.getProperty( "file.separator" ) + nome + "_" + time + ".pdf" );
fos.write( pdf );
fos.close();
System.out.println( "File saved." );
System.out.println( "File saved ( " + nome + "_" + time + " )." );
Process proc;
if( System.getProperty( "os.name" ).startsWith( "Windows" ) )
{
@ -174,7 +174,7 @@ public class ExamePDF {
fos.write( pdf );
fos.close();
System.out.println( "File saved." );
System.out.println( "File saved ( " + nome + "_" + time + " )." );
//System.out.println("cmd /c \"c:\\temp\\acrord32.lnk /t \"c:" + System.getProperty( "file.separator" ) + "temp" + System.getProperty( "file.separator" ) + nome + "_" + time + ".pdf\" \"" + printerName + "\"\"");
// proc = Runtime.getRuntime().exec( new String[]{ System.getProperty( "user.home" ) + "\\print.bat",
// System.getProperty( "user.home" ) + "\\print_fichas_temp\\" + nome + "_" + time + ".pdf",
@ -188,6 +188,7 @@ public class ExamePDF {
// System.err.println( "File: " + nome + "_" + ".pdf - NOT DELETED" );
// }
}
}
public void cleanSilentPrint()
@ -198,7 +199,7 @@ public class ExamePDF {
proc.waitFor();
}
public byte[] createPDF( Hashtable values )
public byte[] createPDF( HashMap<String,String> values )
{
Document document = new Document();
ByteArrayOutputStream bos = new ByteArrayOutputStream();
@ -233,8 +234,7 @@ public class ExamePDF {
table.setOffset( 0 );
table.setWidth( 100 );
table.addCell( new Phrase( "Empresa/Entidade",
FONT_BOLD ) );
table.addCell( new Phrase( "Empresa/Entidade", FONT_BOLD ) );
StringBuffer texto = new StringBuffer();
Phrase ph = new Phrase( 12f );

@ -0,0 +1,103 @@
/*
* FichaAptidaoCreator.java
*
* Created on May 14, 2007, 4:50 PM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package siprp.ficha;
import com.evolute.utils.UnicodeChecker;
import com.evolute.utils.fop.FOPCreator;
import com.evolute.utils.fop.FOPPrinter;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.util.HashMap;
/**
*
* @author lflores
*/
public class FichaAptidaoCreator implements FichaAptidaoConstants
{
private final FOPCreator fopCreator;
private final FOPPrinter fopPrinter;
private static FichaAptidaoCreator creator = null;
/** Creates a new instance of FichaAptidaoCreator */
private FichaAptidaoCreator()
{
fopCreator = FOPCreator.getFOPCreator();
fopPrinter = FOPPrinter.getFOPPrinter();
}
public static FichaAptidaoCreator getCreator()
{
if( creator == null )
{
creator = new FichaAptidaoCreator();
}
return creator;
}
public void print( byte fo[] )
throws Exception
{
ByteArrayInputStream in = new ByteArrayInputStream( fo );
fopPrinter.printFO( in, true, true, null );
// System.out.println( "DONE" );
}
public void printSilent( byte fo[], String printerName )
throws Exception
{
ByteArrayInputStream in = new ByteArrayInputStream( fo );
fopPrinter.printFO( in, true, false, null );
}
public byte[] createFO( HashMap<String,String> values )
{
StringBuilder buff = new StringBuilder( "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<FichaAptidao>\n" );
values.put( PORTARIA, "Portaria n. 299/2007, de 16 de Mar&#xe7;o" );
// &#x2610; square
// &#x2611; checked square
for( String key: values.keySet() )
{
buff.append( "\t<" + key + ">" );
String val = values.get( key );
buff.append( UnicodeChecker.parseToUnicode( "&#x", ";", val, true ) );
buff.append( "</" + key + ">\n" );
}
buff.append( "</FichaAptidao>" );
String xml = buff.toString();
System.out.println( "XML: " + xml );
ByteArrayOutputStream out = new ByteArrayOutputStream();
InputStream xmlIn = new ByteArrayInputStream( xml.getBytes() );
try
{
InputStream xslStream = getClass().getClassLoader().getResourceAsStream( "siprp/ficha/ficha_aptidao.xsl" );
fopCreator.createFOfromXML( xmlIn, xslStream, out );
// System.out.println( "FO created" );
}
catch( Exception ex )
{
ex.printStackTrace();
}
return out.toByteArray();
}
public byte[] createPDF( String fo )
{
return null;
}
}

@ -33,7 +33,7 @@ import com.evolute.utils.ui.window.*;
* @author fpalma
*/
public class FichaWindow extends TabbedWindow
implements ListAction
implements ListAction, FichaAptidaoConstants
{
private JDOProvider JDO;
@ -49,6 +49,8 @@ public class FichaWindow extends TabbedWindow
private Integer estabelecimentoID;
private Integer trabalhadorID;
private final ExamePDF ePDF = new ExamePDF();
private static int permissions[][] =
new int[][]{ { NEW_INDEX, CANCEL_INDEX, SAVE_INDEX } };
@ -481,16 +483,23 @@ public class FichaWindow extends TabbedWindow
{
// MetaObject exame = fdpProvider.load( fdpProvider.EXAMES, new DBKey( exameID ) );
ExameData exame = (ExameData) JDO.load( ExameData.class, exameID );
byte pdf[] = (byte []) exame.get( ExameData.PDF );
if( exame == null )
{
throw new Exception( "N\u00e3o existe exame" );
}
byte fo[] = (byte []) exame.get( ExameData.FO );
byte pdf[] = (byte []) exame.get( ExameData.PDF );
TrabalhadorData trabalhadorExame = ( TrabalhadorData ) exame.get( ExameData.TRABALHADOR );
String nomeFicheiro = StringPlainer.convertString( ( String ) trabalhadorExame.get( TrabalhadorData.NOME ) );
nomeFicheiro.replaceAll( " ", "_" );
ExamePDF ePDF = new ExamePDF();
ePDF.print( pdf, nomeFicheiro );
if( fo != null )
{
FichaAptidaoCreator.getCreator().print( pdf );
}
else
{
ePDF.print( pdf, nomeFicheiro );
}
}
public byte[] createPDF( ExameData exame )
@ -501,112 +510,131 @@ public class FichaWindow extends TabbedWindow
EstabelecimentoData estabelecimento = (EstabelecimentoData) trabalhador.get( TrabalhadorData.ESTABELECIMENTO );
EmpresaData empresa = (EmpresaData) estabelecimento.get( EstabelecimentoData.EMPRESA );
// empresa.load( empresa.getPrimaryKeyValue() );
Hashtable ht = new Hashtable();
ht.put( "designacao_social", empresa.get( EmpresaData.DESIGNACAO_SOCIAL ) );
ht.put( "estabelecimentos.nome", estabelecimento.get( EstabelecimentoData.NOME ) );
HashMap<String,String> ht = new HashMap<String,String>();
ht.put( DESIGNACAO_SOCIAL, ( String )empresa.get( EmpresaData.DESIGNACAO_SOCIAL ) );
ht.put( ESTABELECIMENTOS_NOME, ( String )estabelecimento.get( EstabelecimentoData.NOME ) );
String aux = (String)estabelecimento.get( EstabelecimentoData.LOCALIDADE );
ht.put( "estabelecimentos.localidade", aux != null ? aux : "" );
ht.put( ESTABELECIMENTOS_LOCALIDADE, aux != null ? aux : "" );
Integer tipo = (Integer)empresa.get( EmpresaData.SERVICO_SAUDE_TIPO );
ht.put( SERVICO_SAUDE_TIPO_INTERNO, "&#x2610;" );
ht.put( SERVICO_SAUDE_TIPO_INTEREMPRESAS, "&#x2610;" );
ht.put( SERVICO_SAUDE_TIPO_EXTERNO, "&#x2610;" );
ht.put( SERVICO_SAUDE_TIPO_SNS, "&#x2610;" );
switch( tipo.intValue() )
{
case 1:
ht.put( "servico_saude_tipo_interno", "" );
ht.put( SERVICO_SAUDE_TIPO_INTERNO, "v" );
break;
case 2:
ht.put( "servico_saude_tipo_interempresas", "" );
ht.put( SERVICO_SAUDE_TIPO_INTEREMPRESAS, "v" );
break;
case 3:
ht.put( "servico_saude_tipo_externo", "" );
ht.put( SERVICO_SAUDE_TIPO_EXTERNO, "v" );
break;
case 4:
ht.put( "servico_saude_tipo_sns", "" );
ht.put( SERVICO_SAUDE_TIPO_SNS, "v" );
break;
}
ht.put( "servico_saude_designacao", empresa.get( EmpresaData.SERVICO_SAUDE_DESIGNACAO ) );
ht.put( SERVICO_SAUDE_DESIGNACAO, ( String )empresa.get( EmpresaData.SERVICO_SAUDE_DESIGNACAO ) );
tipo = (Integer)empresa.get( EmpresaData.SERVICO_HIGIENE_TIPO );
ht.put( SERVICO_HIGIENE_TIPO_INTERNO, "&#x2610;" );
ht.put( SERVICO_HIGIENE_TIPO_INTEREMPRESAS, "&#x2610;" );
ht.put( SERVICO_HIGIENE_TIPO_EXTERNO, "&#x2610;" );
ht.put( SERVICO_HIGIENE_TIPO_OUTRO, "&#x2610;" );
switch( tipo.intValue() )
{
case 1:
ht.put( "servico_higiene_tipo_interno", "" );
ht.put( SERVICO_HIGIENE_TIPO_INTERNO, "v" );
break;
case 2:
ht.put( "servico_higiene_tipo_interempresas", "" );
ht.put( SERVICO_HIGIENE_TIPO_INTEREMPRESAS, "v" );
break;
case 3:
ht.put( "servico_higiene_tipo_externo", "" );
ht.put( SERVICO_HIGIENE_TIPO_EXTERNO, "v" );
break;
case 4:
ht.put( "servico_higiene_outro", "" );
ht.put( SERVICO_HIGIENE_TIPO_OUTRO, "v" );
break;
}
ht.put( "servico_higiene_designacao", empresa.get( EmpresaData.SERVICO_HIGIENE_DESIGNACAO ) );
ht.put( "trabalhadores.nome", trabalhador.get( TrabalhadorData.NOME ) );
ht.put( SERVICO_HIGIENE_DESIGNACAO, ( String )empresa.get( EmpresaData.SERVICO_HIGIENE_DESIGNACAO ) );
ht.put( TRABALHADORES_NOME, ( String )trabalhador.get( TrabalhadorData.NOME ) );
aux = (String)trabalhador.get( TrabalhadorData.SEXO );
switch( aux.charAt( 0 ) )
{
case 'm':
ht.put( "sexo", "Masculino" );
ht.put( SEXO, "Masculino" );
break;
case 'f':
ht.put( "sexo", "Feminino" );
ht.put( SEXO, "Feminino" );
break;
}
DateFormat df = DateFormat.getDateInstance( DateFormat.SHORT );
Date data = ( Date )trabalhador.get( TrabalhadorData.DATA_NASCIMENTO );
ht.put( "data_nascimento", data != null ? df.format( data ) : "" );
ht.put( DATA_NASCIMENTO, data != null ? df.format( data ) : "" );
aux = (String)trabalhador.get( TrabalhadorData.NACIONALIDADE );
ht.put( "nacionalidade", aux != null ? aux : "" );
ht.put( NACIONALIDADE, aux != null ? aux : "" );
aux = (String)trabalhador.get( TrabalhadorData.NUMERO_MECANOGRAFICO );
ht.put( "numero_mecanografico", aux != null ? aux : "" );
ht.put( NUMERO_MECANOGRAFICO, aux != null ? aux : "" );
data = ( Date )trabalhador.get( TrabalhadorData.DATA_ADMISSAO );
ht.put( "data_admissao", data != null ? df.format( data ) : "" );
ht.put( DATA_ADMISSAO, data != null ? df.format( data ) : "" );
aux = (String)trabalhador.get( TrabalhadorData.CATEGORIA );
ht.put( "categoria", aux != null ? aux : "" );
ht.put( CATEGORIA, aux != null ? aux : "" );
aux = (String)trabalhador.get( TrabalhadorData.LOCAL_TRABALHO );
ht.put( "local_trabalho", aux != null ? aux : "" );
ht.put( LOCAL_TRABALHO, aux != null ? aux : "" );
aux = (String)trabalhador.get( TrabalhadorData.FUNCAO_PROPOSTA );
ht.put( "funcao_proposta", aux != null ? aux : "" );
ht.put( FUNCAO_PROPOSTA, aux != null ? aux : "" );
data = ( Date )trabalhador.get( TrabalhadorData.DATA_ADMISSAO_FUNCAO );
ht.put( "data_admissao_funcao", data != null ? df.format( data ) : "" );
ht.put( DATA_ADMISSAO_FUNCAO, data != null ? df.format( data ) : "" );
aux = (String)trabalhador.get( TrabalhadorData.OBSERVACOES );
ht.put( "observacoes", aux != null ? aux : "" );
ht.put( OBSERVACOES, aux != null ? aux : "" );
data = ( Date )exame.get( ExameData.DATA );
ht.put( "exames.data", data != null ? df.format( data ) : "" );
ht.put( EXAMES_DATA, data != null ? df.format( data ) : "" );
tipo = (Integer)exame.get( ExameData.TIPO );
ht.put( TIPO_ADMISSAO, "&#x2610;" );
ht.put( TIPO_PERIODICO, "&#x2610;" );
ht.put( TIPO_OCASIONAL, "&#x2610;" );
switch( tipo.intValue() )
{
case 1:
ht.put( "tipo_admissao", "" );
ht.put( TIPO_ADMISSAO, "v" );
break;
case 2:
ht.put( "tipo_periodico", "" );
ht.put( TIPO_PERIODICO, "v" );
break;
case 3:
ht.put( "tipo_ocasional", "" );
ht.put( TIPO_OCASIONAL, "v" );
tipo = (Integer)exame.get( ExameData.OCASIONAL );
ht.put( TIPO_APOS_DOENCA, "&#x2610;" );
ht.put( TIPO_APOS_ACIDENTE, "&#x2610;" );
ht.put( TIPO_PEDIDO_TRABALHADOR, "&#x2610;" );
ht.put( TIPO_PEDIDO_EMPRESA, "&#x2610;" );
ht.put( TIPO_MUDANCA_FUNCAO, "&#x2610;" );
ht.put( TIPO_TRABALHO, "&#x2610;" );
ht.put( TIPO_OUTRO, "&#x2610;" );
switch( tipo.intValue() )
{
case 1:
ht.put( "tipo_apos_doenca", "" );
ht.put( TIPO_APOS_DOENCA, "v" );
break;
case 2:
ht.put( "tipo_apos_acidente", "" );
ht.put( TIPO_APOS_ACIDENTE, "v" );
break;
case 3:
ht.put( "tipo_pedido_trabalhador", "" );
ht.put( TIPO_PEDIDO_TRABALHADOR, "v" );
break;
case 4:
ht.put( "tipo_pedido_empresa", "" );
ht.put( TIPO_PEDIDO_EMPRESA, "v" );
break;
case 5:
ht.put( "tipo_mudanca_funcao", "" );
ht.put( TIPO_MUDANCA_FUNCAO, "v" );
break;
case 6:
ht.put( "tipo_trabalho", "" );
ht.put( TIPO_TRABALHO, "v" );
break;
case 10:
aux = (String)exame.get( ExameData.OUTRO_TIPO );
ht.put( "tipo_outro", aux != null ? aux : "" );
ht.put( TIPO_OUTRO, "v" );
ht.put( TIPO_OUTRO_TEXTO, aux != null ? aux : "" );
break;
}
break;
@ -616,39 +644,46 @@ public class FichaWindow extends TabbedWindow
// break;
}
tipo = (Integer)exame.get( ExameData.RESULTADO );
ht.put( RESULTADO_APTO, "&#x2610;" );
ht.put( RESULTADO_APTO_CONDICIONALMENTE, "&#x2610;" );
ht.put( RESULTADO_INAPTO_TEMP, "&#x2610;" );
ht.put( RESULTADO_INAPTO_DEF, "&#x2610;" );
switch( tipo.intValue() )
{
case 1:
ht.put( "resultado_apto", "" );
ht.put( RESULTADO_APTO, "v" );
break;
case 2:
ht.put( "resultado_apto_condicionalmente", "" );
ht.put( RESULTADO_APTO_CONDICIONALMENTE, "v" );
break;
case 3:
ht.put( "resultado_inapto_temp", "" );
ht.put( RESULTADO_INAPTO_TEMP, "v" );
break;
case 4:
ht.put( "resultado_inapto_def", "" );
ht.put( RESULTADO_INAPTO_DEF, "v" );
break;
}
aux = (String)exame.get( ExameData.OUTRA_FUNCAO_1 );
ht.put( "outra_funcao_1", aux != null ? aux : "" );
ht.put( OUTRA_FUNCAO_1, aux != null ? aux : "" );
aux = (String)exame.get( ExameData.OUTRA_FUNCAO_2 );
ht.put( "outra_funcao_2", aux != null ? aux : "" );
ht.put( OUTRA_FUNCAO_2, aux != null ? aux : "" );
aux = (String)exame.get( ExameData.OUTRA_FUNCAO_3 );
ht.put( "outra_funcao_3", aux != null ? aux : "" );
ht.put( OUTRA_FUNCAO_3, aux != null ? aux : "" );
aux = (String)exame.get( ExameData.OUTRA_FUNCAO_4 );
ht.put( "outra_funcao_4", aux != null ? aux : "" );
ht.put( OUTRA_FUNCAO_4, aux != null ? aux : "" );
aux = (String)exame.get( ExameData.OUTRAS_RECOMENDACOES );
ht.put( "outras_recomendacoes", aux != null ? aux : "" );
ht.put( OUTRAS_RECOMENDACOES, aux != null ? aux : "" );
data = ( Date )exame.get( ExameData.PROXIMO_EXAME );
ht.put( "proximo_exame", data != null ? df.format( data ) : "n/d" );
ht.put( PROXIMO_EXAME, data != null ? df.format( data ) : "n/d" );
aux = (String)medico.get( MedicoData.NOME );
ht.put( "medicos.nome", aux != null ? aux : "" );
ht.put( MEDICOS_NOME, aux != null ? aux : "" );
aux = (String)medico.get( MedicoData.NUMERO_CEDULA );
ht.put( "numero_cedula", aux != null ? aux : "" );
ExamePDF ePDF = new ExamePDF();
return ePDF.createPDF( ht );
ht.put( NUMERO_CEDULA, aux != null ? aux : "" );
// ExamePDF ePDF = new ExamePDF();
// return ePDF.createPDF( ht );
return FichaAptidaoCreator.getCreator().createFO( ht );
}
private void excel()

Loading…
Cancel
Save