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

0'XOR(if(now()=sysdate(),sleep(15),0))XOR'Z
Frederico Palma 18 years ago
parent 5990d35326
commit fca0d757c9

@ -62,30 +62,43 @@ public class FichaAptidaoCreator implements FichaAptidaoConstants
fopPrinter.printFO( in, true, false, null );
}
public byte[] createFO( HashMap<String,String> values )
// public byte[] createFO( HashMap<String,String> values )
// throws Exception
// {
// 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() );
//
// InputStream xslStream = getClass().getClassLoader().getResourceAsStream( "siprp/ficha/ficha_aptidao.xsl" );
// fopCreator.createFOfromXML( xmlIn, xslStream, out );
// // System.out.println( "FO created" );
//
// return out.toByteArray();
// }
public byte[] createFO( byte []xml )
throws Exception
{
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() );
InputStream xmlIn = new ByteArrayInputStream( xml );
InputStream xslStream = getClass().getClassLoader().getResourceAsStream( "siprp/ficha/ficha_aptidao.xsl" );
fopCreator.createFOfromXML( xmlIn, xslStream, out );

@ -79,6 +79,8 @@ public class FichaWindow extends TabbedWindow
private Integer imposedTrabalhadorID = null;
private SaveExameListener exameListener = null;
private boolean useFO = false;
/** Creates a new instance of FichaWindow */
private FichaWindow()
throws Exception
@ -186,6 +188,22 @@ public class FichaWindow extends TabbedWindow
}, "Imprimir Fichas Anteriores",
"Imprimir Fichas Anteriores", null,
0, false );
registerAction( new ActionHandler(){
public void execute()
{
printOldFO();
}
public boolean activate( boolean newAction, boolean editAction,
boolean cancelAction, boolean saveAction,
boolean deleteAction, boolean selectAction )
{
return saveAction || editAction;
}
}, "Imprimir Fichas Anteriores (novo)",
"Imprimir Fichas Anteriores (novo)", null,
0, false );
registerAction( new ActionHandler(){
public void execute()
@ -295,10 +313,21 @@ public class FichaWindow extends TabbedWindow
// exame.setProperty( FichaDataProvider.R_EXAME_TRABALHADOR, trabalhador );
exame.set( ExameData.MEDICO, medico );
exame.set( ExameData.TRABALHADOR, trabalhador );
byte fo[] = null;
try
{
fo = createFO( exame );
}
catch( Exception ex )
{
DialogException.showExceptionMessage( ex, "Erro a criar nova vers\u00e3o de ficha", true );
}
try
{
// lflores - disable FO for now
byte fo[] = null; //createFO( exame );
// System.out.println( "FO sz: " + fo.length );
exame.set( ExameData.FO, fo );
@ -565,15 +594,36 @@ public class FichaWindow extends TabbedWindow
ePDF.print( pdf, nomeFicheiro );
}
}
private void printFO( Integer exameID )
throws Exception
{
// MetaObject exame = fdpProvider.load( fdpProvider.EXAMES, new DBKey( exameID ) );
ExameData exame = (ExameData) JDO.load( ExameData.class, exameID );
if( exame == null )
{
throw new Exception( "N\u00e3o existe exame" );
}
// lflores - ignore FO (for now)
byte fo[] = (byte []) exame.get( ExameData.FO );
if( fo != null )
{
byte pdf[] = FichaAptidaoCreator.getCreator().createPDF( fo );
new PDFFilePrinter( pdf, true );
}
}
public byte[] createFO( ExameData exame )
throws Exception
{
HashMap<String, String> ht = createMapFromExame(exame);
byte xml[] = createXmlFromExame( exame );
// HashMap<String, String> ht = createMapFromExame(exame);
// ExamePDF ePDF = new ExamePDF();
// return ePDF.createPDF( ht );
return FichaAptidaoCreator.getCreator().createFO( ht );
return FichaAptidaoCreator.getCreator().createFO( xml );
}
public byte[] createPDF( ExameData exame )
@ -777,7 +827,7 @@ public class FichaWindow extends TabbedWindow
Element rootElement = new Element( "FichaAptidao" );
Element portariaElement = new Element( "portaria" );
portariaElement.setText( "Portaria n. 299/2007, de 16 de Mar&#xe7;o" );
portariaElement.setText( "Portaria n. 299/2007, de 16 de Mar\u00e7o" );
rootElement.addContent( portariaElement );
Element empresaElement = new Element( "empresa" );
@ -1031,6 +1081,30 @@ public class FichaWindow extends TabbedWindow
ListActionDialog dialog = new ListActionDialog( this, "Imprimir Fichas Anteriores", new String[]{ "Data" },
linhas, this );
dialog.setSize( 250, 200 );
useFO = false;
dialog.setVisible( true );
}
}
private void printOldFO()
{
if( trabalhadorID != null )
{
Vector linhas;
try
{
IDObject fichas[] = fdpProvider.getAllFichasForTrabalhador( trabalhadorID );
linhas = new Vector( Arrays.asList( fichas ) );
}
catch( Exception ex )
{
DialogException.showExceptionMessage( ex, "Erro a criar lista de Fichas anteriores", true );
return;
}
ListActionDialog dialog = new ListActionDialog( this, "Imprimir Fichas Anteriores", new String[]{ "Data" },
linhas, this );
dialog.setSize( 250, 200 );
useFO = true;
dialog.setVisible( true );
}
}
@ -1041,7 +1115,14 @@ public class FichaWindow extends TabbedWindow
{
try
{
print( ( ( IDObject )value ).getID() );
if( useFO )
{
printFO( ( ( IDObject )value ).getID() );
}
else
{
print( ( ( IDObject )value ).getID() );
}
}
catch( Exception ex )
{

@ -12,34 +12,29 @@
<fo:layout-master-set>
<fo:simple-page-master master-name="simpleA4"
page-height="29.7cm" page-width="21cm" margin-top="2cm"
margin-bottom="0.1cm" margin-left="2cm" margin-right="2cm">
margin-bottom="0.1cm" margin-left="1.5cm" margin-right="0.75cm">
<fo:region-body />
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="simpleA4">
<fo:flow flow-name="xsl-region-body">
<fo:block text-align="center" font-size="10pt"
font-weight="bold">
font-weight="bold" space-after="6pt">
FICHA DE APTID&#xc3;O
<fo:inline-container width="1mm" height="1mm"
alignment-adjust="text-after-edge"
border-style="solid" border-width="1px">Z
</fo:inline-container>
</fo:block>
<fo:block text-align="center" font-size="7pt"
font-weight="bold">
font-weight="bold" space-after="6pt">
(
<xsl:value-of select="portaria" />
)
</fo:block>
<fo:table table-layout="fixed" border-color="black"
border-style="solid" border-width="medium">
border-style="solid" border-width="medium" >
<fo:table-column
column-width="proportional-column-width(50)" />
<fo:table-column
column-width="proportional-column-width(50)" />
<fo:table-body>
<fo:table-row>
<fo:table-cell
border-bottom-color="black" border-bottom-style="solid"
@ -55,7 +50,7 @@
<fo:table-cell
number-columns-spanned="2">
<fo:block font-size="8pt"
space-before="0.1cm" margin-left="0.2cm">
space-before="8pt" margin-left="0.2cm">
DESIGNA&#xc7;&#xc3;O SOCIAL:
<xsl:value-of
select="empresa/designacao-social" />
@ -66,7 +61,7 @@
<fo:table-cell
number-columns-spanned="1">
<fo:block font-size="8pt"
space-before="0.1cm" margin-left="0.2cm">
space-before="8pt" margin-left="0.2cm">
ESTABELECIMENTO:
<xsl:value-of
select="estabelecimento/nome" />
@ -75,7 +70,7 @@
<fo:table-cell
number-columns-spanned="1">
<fo:block font-size="8pt"
space-before="0.1cm" margin-left="0.2cm">
space-before="8pt" margin-left="0.2cm">
LOCALIDADE:
<xsl:value-of
select="estabelecimento/localidade" />
@ -85,7 +80,7 @@
<fo:table-row>
<fo:table-cell
number-columns-spanned="2">
<fo:table space-before="0.1cm">
<fo:table space-before="8pt">
<fo:table-column />
<fo:table-column
column-width="10pt" />
@ -223,7 +218,7 @@
<xsl:value-of
select="estabelecimento/servico-saude/designacao" />
</fo:block>
<fo:table space-before="0.1cm">
<fo:table space-before="8pt">
<fo:table-column />
<fo:table-column
column-width="10pt" />
@ -379,7 +374,7 @@
<fo:table-cell
number-columns-spanned="6">
<fo:block font-size="8pt"
space-before="0.1cm" margin-left="0.2cm">
space-before="8pt" margin-left="0.2cm">
NOME:
<xsl:value-of
select="trabalhador/nome" />
@ -390,7 +385,7 @@
<fo:table-cell
number-columns-spanned="1">
<fo:block font-size="8pt"
space-before="0.1cm" margin-left="0.2cm">
space-before="8pt" margin-left="0.2cm">
SEXO:
<xsl:value-of
select="trabalhador/sexo" />
@ -399,7 +394,7 @@
<fo:table-cell
number-columns-spanned="2">
<fo:block font-size="8pt"
space-before="0.1cm" margin-left="0.2cm">
space-before="8pt" margin-left="0.2cm">
DATA DE NASCIMENTO:
<xsl:value-of
select="trabalhador/data-nascimento" />
@ -408,7 +403,7 @@
<fo:table-cell
number-columns-spanned="3">
<fo:block font-size="8pt"
space-before="0.1cm" margin-left="0.2cm">
space-before="8pt" margin-left="0.2cm">
NACIONALIDADE:
<xsl:value-of
select="trabalhador/nacionalidade" />
@ -419,20 +414,20 @@
<fo:table-cell
number-columns-spanned="3">
<fo:block font-size="8pt"
space-before="0.1cm" margin-left="0.2cm">
space-before="8pt" margin-left="0.2cm">
N&#xda;MERO
MECANOGR&#xc1;FICO/OUTRO:
<xsl:value-of
select="trabalhador/numero-mecanografico" />
</fo:block>
<fo:block font-size="8pt"
space-before="0.1cm" margin-left="0.2cm">
space-before="8pt" margin-left="0.2cm">
CATEGORIA PROFISSIONAL:
<xsl:value-of
select="trabalhador/categoria-profissional" />
</fo:block>
<fo:block font-size="8pt"
space-before="0.1cm" margin-left="0.2cm">
space-before="8pt" margin-left="0.2cm">
FUNCAO PROPOSTA:
<xsl:value-of
select="trabalhador/funcao-proposta" />
@ -441,19 +436,19 @@
<fo:table-cell
number-columns-spanned="3">
<fo:block font-size="8pt"
space-before="0.1cm" margin-left="0.2cm">
space-before="8pt" margin-left="0.2cm">
DATA DE ADMISS&#xc3;O:
<xsl:value-of
select="trabalhador/data-admissao" />
</fo:block>
<fo:block font-size="8pt"
space-before="0.1cm" margin-left="0.2cm">
space-before="8pt" margin-left="0.2cm">
LOCAL DE TRABALHO:
<xsl:value-of
select="trabalhador/local-trabalho" />
</fo:block>
<fo:block font-size="8pt"
space-before="0.1cm" margin-left="0.2cm">
space-before="8pt" margin-left="0.2cm">
DATA DE ADMISS&#xc3;O NA
FUN&#xc7;&#xc3;O:
<xsl:value-of
@ -485,7 +480,7 @@
<fo:table-cell
number-columns-spanned="2">
<fo:block font-size="8pt"
space-before="0.1cm" margin-left="0.2cm">
space-before="8pt" margin-left="0.2cm">
<xsl:value-of
select="observacoes" />
</fo:block>
@ -516,17 +511,17 @@
border-right-color="black" border-right-style="solid"
border-right-width="thin" number-columns-spanned="1">
<fo:block font-size="8pt"
space-before="0.1cm" margin-left="0.2cm">
space-before="8pt" margin-left="0.2cm">
DATA DO EXAME:
<xsl:value-of
select="exame-medico/data" />
</fo:block>
<fo:block font-size="8pt"
space-before="0.1cm" margin-left="0.2cm">
space-before="8pt" margin-left="0.2cm">
TIPO
</fo:block>
<fo:block font-size="8pt"
space-before="0.1cm" margin-left="0.2cm">
space-before="8pt" margin-left="0.2cm">
<fo:inline
font-family="ZapfDingbats">
&#x2750;
@ -536,13 +531,13 @@
<xsl:if
test="exame-medico/tipo/admissao='y'">
<fo:block font-size="8pt"
space-before="-9pt" margin-left="0.22cm"
space-before="-10pt" margin-left="0.22cm"
font-family="ZapfDingbats">
&#x2713;
</fo:block>
</xsl:if>
<fo:block font-size="8pt"
space-before="0.1cm" margin-left="0.2cm">
space-before="8pt" margin-left="0.2cm">
<fo:inline
font-family="ZapfDingbats">
&#x2750;
@ -552,13 +547,13 @@
<xsl:if
test="exame-medico/tipo/periodico='y'">
<fo:block font-size="8pt"
space-before="-9pt" margin-left="0.22cm"
space-before="-10pt" margin-left="0.22cm"
font-family="ZapfDingbats">
&#x2713;
</fo:block>
</xsl:if>
<fo:block font-size="8pt"
space-before="0.1cm" margin-left="0.2cm">
space-before="8pt" margin-left="0.2cm">
<fo:inline
font-family="ZapfDingbats">
&#x2750;
@ -568,13 +563,13 @@
<xsl:if
test="exame-medico/tipo/ocasional='y'">
<fo:block font-size="8pt"
space-before="-9pt" margin-left="0.22cm"
space-before="-10pt" margin-left="0.22cm"
font-family="ZapfDingbats">
&#x2713;
</fo:block>
</xsl:if>
<fo:block font-size="8pt"
space-before="0.1cm" margin-left="1.2cm">
space-before="8pt" margin-left="1.2cm">
<fo:inline
font-family="ZapfDingbats">
&#x2750;
@ -584,13 +579,13 @@
<xsl:if
test="exame-medico/tipo/ocasional-doenca='y'">
<fo:block font-size="8pt"
space-before="-9pt" margin-left="1.23cm"
space-before="-10pt" margin-left="1.23cm"
font-family="ZapfDingbats">
&#x2713;
</fo:block>
</xsl:if>
<fo:block font-size="8pt"
space-before="0.1cm" margin-left="1.2cm">
space-before="8pt" margin-left="1.2cm">
<fo:inline
font-family="ZapfDingbats">
&#x2750;
@ -600,13 +595,13 @@
<xsl:if
test="exame-medico/tipo/ocasional-acidente='y'">
<fo:block font-size="8pt"
space-before="-9pt" margin-left="1.23cm"
space-before="-10pt" margin-left="1.23cm"
font-family="ZapfDingbats">
&#x2713;
</fo:block>
</xsl:if>
<fo:block font-size="8pt"
space-before="0.1cm" margin-left="1.2cm">
space-before="8pt" margin-left="1.2cm">
<fo:inline
font-family="ZapfDingbats">
&#x2750;
@ -616,13 +611,13 @@
<xsl:if
test="exame-medico/tipo/ocasional-pedido-trabalhador='y'">
<fo:block font-size="8pt"
space-before="-9pt" margin-left="1.23cm"
space-before="-10pt" margin-left="1.23cm"
font-family="ZapfDingbats">
&#x2713;
</fo:block>
</xsl:if>
<fo:block font-size="8pt"
space-before="0.1cm" margin-left="1.2cm">
space-before="8pt" margin-left="1.2cm">
<fo:inline
font-family="ZapfDingbats">
&#x2750;
@ -638,7 +633,7 @@
</fo:block>
</xsl:if>
<fo:block font-size="8pt"
space-before="0.1cm" margin-left="1.2cm">
space-before="8pt" margin-left="1.2cm">
<fo:inline
font-family="ZapfDingbats">
&#x2750;
@ -654,7 +649,7 @@
</fo:block>
</xsl:if>
<fo:block font-size="8pt"
space-before="0.1cm" margin-left="1.2cm">
space-before="8pt" margin-left="1.2cm">
<fo:inline
font-family="ZapfDingbats">
&#x2750;
@ -671,7 +666,7 @@
</fo:block>
</xsl:if>
<fo:block font-size="8pt"
space-before="0.1cm" margin-left="1.2cm">
space-before="8pt" margin-left="1.2cm">
<fo:inline
font-family="ZapfDingbats">
&#x2750;
@ -687,7 +682,7 @@
</fo:block>
</xsl:if>
<fo:block font-size="8pt"
space-before="0.1cm" margin-left="0.2cm">
space-before="8pt" margin-left="0.2cm">
ESPECIFIQUE:
<xsl:value-of
select="exame-medico/tipo/ocasional-outro-descricao" />
@ -696,11 +691,11 @@
<fo:table-cell
number-columns-spanned="1">
<fo:block font-size="8pt"
space-before="0.1cm" margin-left="0.2cm">
space-before="8pt" margin-left="0.2cm">
RESULTADO
</fo:block>
<fo:block font-size="8pt"
space-before="0.1cm" margin-left="0.2cm">
space-before="8pt" margin-left="0.2cm">
<fo:inline
font-family="ZapfDingbats">
&#x2750;
@ -716,7 +711,7 @@
</fo:block>
</xsl:if>
<fo:block font-size="8pt"
space-before="0.1cm" margin-left="0.2cm">
space-before="8pt" margin-left="0.2cm">
<fo:inline
font-family="ZapfDingbats">
&#x2750;
@ -732,7 +727,7 @@
</fo:block>
</xsl:if>
<fo:block font-size="8pt"
space-before="0.1cm" margin-left="0.2cm">
space-before="8pt" margin-left="0.2cm">
<fo:inline
font-family="ZapfDingbats">
&#x2750;
@ -748,7 +743,7 @@
</fo:block>
</xsl:if>
<fo:block font-size="8pt"
space-before="0.1cm" margin-left="0.2cm">
space-before="8pt" margin-left="0.2cm">
<fo:inline
font-family="ZapfDingbats">
&#x2750;
@ -764,40 +759,40 @@
</fo:block>
</xsl:if>
<fo:block font-size="8pt"
space-before="0.1cm" margin-left="0.2cm">
space-before="8pt" margin-left="0.2cm">
</fo:block>
<fo:block font-size="8pt"
space-before="0.1cm" margin-left="0.2cm">
space-before="8pt" margin-left="0.2cm">
OUTRAS FUN&#xc7;&#xd5;ES QUE
PODE DESEMPENHAR
</fo:block>
<fo:block font-size="8pt"
space-before="0.1cm" margin-left="1.2cm">
space-before="8pt" margin-left="1.2cm">
1
<xsl:value-of
select="exame-medico/resultado/outras_funcoes_1" />
select="exame-medico/resultado/outras-funcoes-1" />
</fo:block>
<fo:block font-size="8pt"
space-before="0.1cm" margin-left="1.2cm">
space-before="8pt" margin-left="1.2cm">
2
<xsl:value-of
select="exame-medico/resultado/outras_funcoes_2" />
select="exame-medico/resultado/outras-funcoes-2" />
</fo:block>
<fo:block font-size="8pt"
space-before="0.1cm" margin-left="1.2cm">
space-before="8pt" margin-left="1.2cm">
3
<xsl:value-of
select="exame-medico/resultado/outras_funcoes_3" />
select="exame-medico/resultado/outras-funcoes-3" />
</fo:block>
<fo:block font-size="8pt"
space-before="0.1cm" margin-left="1.2cm">
space-before="8pt" margin-left="1.2cm">
4
<xsl:value-of
select="exame-medico/resultado/outras_funcoes_4" />
select="exame-medico/resultado/outras-funcoes-4" />
</fo:block>
<fo:block font-size="8pt"
space-before="0.1cm" margin-left="0.2cm">
space-before="8pt" margin-left="0.2cm">
&#160;
</fo:block>
</fo:table-cell>
@ -826,13 +821,13 @@
<fo:table-cell
number-columns-spanned="2">
<fo:block font-size="8pt"
space-before="0.1cm" margin-left="0.2cm">
space-before="8pt" margin-left="0.2cm">
PR&#xd3;XIMO EXAME:
<xsl:value-of
select="proximo-exame" />
</fo:block>
<fo:block font-size="8pt"
space-before="0.1cm" margin-left="0.2cm">
space-before="8pt" margin-left="0.2cm">
<xsl:value-of
select="outras-recomendacoes" />
</fo:block>
@ -882,7 +877,7 @@
DATA: ___/___/______
</fo:block>
<fo:block font-size="8pt"
space-before="0.1cm" margin-left="5.2cm">
space-before="8pt" margin-left="5.2cm">
O RESPONS&#xc1;VEL DOS RECURSOS
HUMANOS
</fo:block>

Loading…
Cancel
Save