84 lines
2.9 KiB
Java
84 lines
2.9 KiB
Java
package com.rjconsultores.ventaboletos;
|
|
|
|
import java.io.File;
|
|
import java.math.BigDecimal;
|
|
import java.util.Date;
|
|
|
|
import com.rjconsultores.ventaboletos.blocos.RodapeRemessaPadrao;
|
|
import com.rjconsultores.ventaboletos.blocos.mercantil.ArquivoRemessaMercantil;
|
|
import com.rjconsultores.ventaboletos.blocos.mercantil.CabecalhoRemessaMercantil;
|
|
import com.rjconsultores.ventaboletos.blocos.mercantil.DetalheObrigatorioMercantil;
|
|
import com.rjconsultores.ventaboletos.enuns.BancoLayout;
|
|
import com.rjconsultores.ventaboletos.layouts.MercantilFlatFile;
|
|
import com.rjconsultores.ventaboletos.layouts.RemessaInterface;
|
|
|
|
public class Main {
|
|
|
|
public static void main(String[] args) {
|
|
|
|
ArquivoRemessaItem arquivoRemessaItem = new ArquivoRemessaMercantil();
|
|
|
|
CabecalhoRemessaMercantil cabecalhoRemessa = new CabecalhoRemessaMercantil();
|
|
|
|
cabecalhoRemessa.setCodigoEmpresa("123456");
|
|
cabecalhoRemessa.setAgenciaOrigem("0555");
|
|
cabecalhoRemessa.setDataGravacao(new Date());
|
|
cabecalhoRemessa.setCnpj(new Long("1452265658222"));
|
|
cabecalhoRemessa.setNumeroSequencialRemessa(1);
|
|
cabecalhoRemessa.setNumeroSequencialRegistro(9);
|
|
cabecalhoRemessa.setNomeEmpresa("RJ Consultores");
|
|
|
|
arquivoRemessaItem.setCabecalhoRemessa(cabecalhoRemessa);
|
|
|
|
DetalheObrigatorioMercantil titulo = new DetalheObrigatorioMercantil();
|
|
|
|
titulo.setValorTitulo(new BigDecimal("4567.88"));
|
|
titulo.setVencimento(new Date());
|
|
titulo.setCnpj(new Long("1452265658222"));
|
|
titulo.setCepPrefixo("32015");
|
|
titulo.setCepSufixo("490");
|
|
titulo.setNumeroDoDocumento("555666777");
|
|
titulo.setAgenciaOrigem("0555");
|
|
titulo.setEmissao( new Date() );
|
|
|
|
try {
|
|
arquivoRemessaItem.addTitulo(titulo.clone());
|
|
arquivoRemessaItem.addTitulo(titulo.clone());
|
|
arquivoRemessaItem.addTitulo(titulo.clone());
|
|
arquivoRemessaItem.addTitulo(titulo.clone());
|
|
arquivoRemessaItem.addTitulo(titulo.clone());
|
|
arquivoRemessaItem.addTitulo(titulo.clone());
|
|
arquivoRemessaItem.addTitulo(titulo.clone());
|
|
} catch (CloneNotSupportedException e1) {
|
|
// TODO Auto-generated catch block
|
|
e1.printStackTrace();
|
|
}
|
|
|
|
|
|
RemessaInterface remessaInterface = new MercantilFlatFile();
|
|
|
|
RodapeRemessaPadrao rodapeRemessa = new RodapeRemessaPadrao();
|
|
rodapeRemessa.setNumeroSequencialRegistro(9999);
|
|
|
|
arquivoRemessaItem.setRodapeRemessa(rodapeRemessa);
|
|
|
|
File arquivoRemessaFisico = new File("C:\\Fabio\\fabio.txt");
|
|
|
|
ArquivoRemessa arquivoRemessa = new ArquivoRemessa(BancoLayout.MERCANTIL_400_Envio);
|
|
|
|
try {
|
|
arquivoRemessa.addItem(arquivoRemessaItem.clone());
|
|
arquivoRemessa.addItem(arquivoRemessaItem.clone());
|
|
} catch (CloneNotSupportedException e1) {
|
|
e1.printStackTrace();
|
|
}
|
|
|
|
try {
|
|
remessaInterface.gerarRemessa(arquivoRemessaFisico, arquivoRemessa);
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
|
|
}
|