fixes bug #7500
git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Model/trunk/modelWeb@57284 d1611594-4594-4d17-8e1d-87c2c4800839master
parent
13defe4848
commit
76e0cb2ad6
|
@ -115,11 +115,13 @@ public class ArchivoIntegracionECFReducaoZ {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BigDecimal dif = valorEcf.subtract(valorRedZ);
|
||||||
for (ImportacionFiscalReducaoZVO reZv : agpRedZ.getItens()) {
|
for (ImportacionFiscalReducaoZVO reZv : agpRedZ.getItens()) {
|
||||||
|
BigDecimal vendabrutadiaria = reZv.getVendabrutadiaria().add(dif);
|
||||||
|
reZv.setVendabrutadiaria(vendabrutadiaria);
|
||||||
listRedZValidos.add(reZv);
|
listRedZValidos.add(reZv);
|
||||||
}
|
}
|
||||||
|
|
||||||
BigDecimal dif = valorEcf.subtract(valorRedZ);
|
|
||||||
ImportacionFiscalReducaoZVO reZ = new ImportacionFiscalReducaoZVO(agpRedZ.getItens().get(0));
|
ImportacionFiscalReducaoZVO reZ = new ImportacionFiscalReducaoZVO(agpRedZ.getItens().get(0));
|
||||||
reZ.setAliquota(TipoPendencia.DIF_ECF.toString());
|
reZ.setAliquota(TipoPendencia.DIF_ECF.toString());
|
||||||
reZ.setImposto(dif);
|
reZ.setImposto(dif);
|
||||||
|
|
|
@ -0,0 +1,410 @@
|
||||||
|
package com.rjconsultores.ventaboletos.utilerias.archivointegracion;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.FileReader;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.apache.poi.hssf.usermodel.HSSFRow;
|
||||||
|
import org.apache.poi.hssf.usermodel.HSSFSheet;
|
||||||
|
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||||
|
|
||||||
|
public class ValidaIntegracionECFRedZxls {
|
||||||
|
|
||||||
|
private List<FiscalVO> listEcf;
|
||||||
|
private List<RedZVO> listRedZ;
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
ValidaIntegracionECFRedZxls ss = new ValidaIntegracionECFRedZxls();
|
||||||
|
ss.executar();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void executar() {
|
||||||
|
|
||||||
|
listEcf = verificaArquivoEcf();
|
||||||
|
listRedZ = verificaArquivoRedZ();
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
HSSFWorkbook workbook = new HSSFWorkbook();
|
||||||
|
HSSFSheet firstSheet = workbook.createSheet();
|
||||||
|
|
||||||
|
int linha = 0;
|
||||||
|
|
||||||
|
// Cabecalho
|
||||||
|
HSSFRow row = firstSheet.createRow(linha++);
|
||||||
|
row.createCell(0).setCellValue("EMPRESA");
|
||||||
|
row.createCell(1).setCellValue("DATA_MOVIMENTO");
|
||||||
|
row.createCell(2).setCellValue("SERIE");
|
||||||
|
row.createCell(3).setCellValue("PDV");
|
||||||
|
row.createCell(4).setCellValue("NUMERO_BILHETES");
|
||||||
|
row.createCell(5).setCellValue("VALOR_ECF");
|
||||||
|
row.createCell(6).setCellValue("VALOR_REDUCAO_Z");
|
||||||
|
row.createCell(7).setCellValue("STATUS_DIFERENÇA");
|
||||||
|
|
||||||
|
for (FiscalVO ecf : listEcf) {
|
||||||
|
|
||||||
|
RedZVO redz = buscaRegistroRedZ(ecf.getNumserie20(), ecf.getDatamov());
|
||||||
|
boolean isValoresIguais = true;
|
||||||
|
|
||||||
|
row = firstSheet.createRow(linha++);
|
||||||
|
row.createCell(0).setCellValue("UTIL");
|
||||||
|
row.createCell(1).setCellValue(ecf.getDatamov());
|
||||||
|
row.createCell(2).setCellValue(redz.getNumserie20());
|
||||||
|
row.createCell(3).setCellValue(ecf.getPdv());
|
||||||
|
row.createCell(4).setCellValue(ecf.getQuantidade());
|
||||||
|
row.createCell(5).setCellValue(ecf.getValorTotal().doubleValue());
|
||||||
|
row.createCell(6).setCellValue(redz.getValorTotal().doubleValue());
|
||||||
|
|
||||||
|
if (!redz.getValorTotal().equals(ecf.getValorTotal())) {
|
||||||
|
isValoresIguais = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isValoresIguais) {
|
||||||
|
row.createCell(7).setCellValue("VALIDO");
|
||||||
|
System.out.println(" VALIDO ---- SERIE: " + redz.getNumserie20() + " DATAMOV: " + ecf.getDatamov() + " VALOR ECF: " + ecf.getValorTotal() + " VALOR RED Z: " + redz.getValorTotal() + " CONT: " + ecf.getQuantidade() + " PDV: " + ecf.getPdv());
|
||||||
|
} else {
|
||||||
|
row.createCell(7).setCellValue("INVALIDO");
|
||||||
|
System.out.println(" !!! INVALIDO ---- SERIE: " + redz.getNumserie20() + " DATAMOV: " + ecf.getDatamov() + " VALOR ECF: " + ecf.getValorTotal() + " VALOR RED Z: " + redz.getValorTotal() + " CONT: " + ecf.getQuantidade() + " PDV: " + ecf.getPdv());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||||
|
workbook.write(bos);
|
||||||
|
|
||||||
|
File arquivo = new File("C:\\Users\\rjgw\\Desktop\\dif.xls");
|
||||||
|
|
||||||
|
FileOutputStream fos = new FileOutputStream(arquivo);
|
||||||
|
fos.write(bos.toByteArray());
|
||||||
|
fos.close();
|
||||||
|
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private RedZVO buscaRegistroRedZ(String numserie20, String datamov) {
|
||||||
|
try {
|
||||||
|
int index = listRedZ.indexOf(new RedZVO(datamov, numserie20));
|
||||||
|
return listRedZ.get(index);
|
||||||
|
} catch (ArrayIndexOutOfBoundsException e) {
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<RedZVO> verificaArquivoRedZ() {
|
||||||
|
|
||||||
|
List<RedZVO> list = new ArrayList<RedZVO>();
|
||||||
|
|
||||||
|
File arquivoTxt = new File("C:\\Users\\rjgw\\Desktop\\fiscal_reducao_z_201606240529438877750410577735828.txt");
|
||||||
|
BufferedReader br;
|
||||||
|
|
||||||
|
try {
|
||||||
|
br = new BufferedReader(new FileReader(arquivoTxt));
|
||||||
|
String linha = br.readLine();
|
||||||
|
|
||||||
|
RedZVO atual = null;
|
||||||
|
while (linha != null) {
|
||||||
|
|
||||||
|
if (linha.startsWith("1")) {
|
||||||
|
|
||||||
|
String datamov = linha.substring(1, 9).trim();
|
||||||
|
String numserie20 = linha.substring(39, 60).trim();
|
||||||
|
RedZVO novo = new RedZVO(datamov, numserie20);
|
||||||
|
novo.setPdv(linha.substring(56, 60).trim());
|
||||||
|
|
||||||
|
String valor = linha.substring(128, 140).trim();
|
||||||
|
try {
|
||||||
|
novo.setValorTotal(new BigDecimal(valor));
|
||||||
|
} catch (Exception e) {
|
||||||
|
}
|
||||||
|
|
||||||
|
if (atual == null) {
|
||||||
|
atual = novo;
|
||||||
|
|
||||||
|
} else if (atual.equals(novo)) {
|
||||||
|
|
||||||
|
} else {
|
||||||
|
list.add(atual);
|
||||||
|
atual = novo;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
linha = br.readLine();
|
||||||
|
}
|
||||||
|
|
||||||
|
list.add(atual);
|
||||||
|
|
||||||
|
br.close();
|
||||||
|
|
||||||
|
return list;
|
||||||
|
} catch (FileNotFoundException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<FiscalVO> verificaArquivoEcf() {
|
||||||
|
|
||||||
|
List<FiscalVO> list = new ArrayList<FiscalVO>();
|
||||||
|
|
||||||
|
File arquivoTxt = new File("C:\\Users\\rjgw\\Desktop\\fiscal_ecf_201606240529405088610479025318030.txt");
|
||||||
|
BufferedReader br;
|
||||||
|
|
||||||
|
try {
|
||||||
|
br = new BufferedReader(new FileReader(arquivoTxt));
|
||||||
|
String linha = br.readLine();
|
||||||
|
int cont = 0;
|
||||||
|
|
||||||
|
FiscalVO atual = null;
|
||||||
|
while (linha != null) {
|
||||||
|
|
||||||
|
if (linha.startsWith("1")) {
|
||||||
|
|
||||||
|
String datamov = linha.substring(1, 9).trim();
|
||||||
|
String pdv = linha.substring(32, 35).trim();
|
||||||
|
FiscalVO novo = new FiscalVO(datamov, pdv);
|
||||||
|
|
||||||
|
String valor = linha.substring(56, 70).trim();
|
||||||
|
|
||||||
|
if (atual == null) {
|
||||||
|
atual = novo;
|
||||||
|
atual.soma(valor);
|
||||||
|
cont++;
|
||||||
|
|
||||||
|
} else if (atual.equals(novo)) {
|
||||||
|
atual.soma(valor);
|
||||||
|
cont++;
|
||||||
|
} else {
|
||||||
|
atual.setQuantidade(cont);
|
||||||
|
list.add(atual);
|
||||||
|
|
||||||
|
cont = 0;
|
||||||
|
|
||||||
|
atual = novo;
|
||||||
|
atual.soma(valor);
|
||||||
|
cont++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (linha.startsWith("2")) {
|
||||||
|
atual.setNumserie20(linha.substring(212, 232).trim());
|
||||||
|
}
|
||||||
|
|
||||||
|
linha = br.readLine();
|
||||||
|
}
|
||||||
|
|
||||||
|
list.add(atual);
|
||||||
|
|
||||||
|
br.close();
|
||||||
|
|
||||||
|
return list;
|
||||||
|
} catch (FileNotFoundException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public class RedZVO {
|
||||||
|
private String datamov;
|
||||||
|
private String pdv;
|
||||||
|
private String numserie20;
|
||||||
|
private BigDecimal valorTotal;
|
||||||
|
|
||||||
|
public RedZVO(String datamov, String numserie20) {
|
||||||
|
this.datamov = datamov;
|
||||||
|
this.numserie20 = numserie20;
|
||||||
|
this.valorTotal = BigDecimal.ZERO;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void soma(String valor) {
|
||||||
|
BigDecimal vl = new BigDecimal(valor);
|
||||||
|
this.valorTotal = valorTotal.add(vl);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDatamov() {
|
||||||
|
return datamov;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDatamov(String datamov) {
|
||||||
|
this.datamov = datamov;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getNumserie20() {
|
||||||
|
return numserie20;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNumserie20(String numserie20) {
|
||||||
|
this.numserie20 = numserie20;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getValorTotal() {
|
||||||
|
return valorTotal;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setValorTotal(BigDecimal valorTotal) {
|
||||||
|
this.valorTotal = valorTotal;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPdv() {
|
||||||
|
return pdv;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPdv(String pdv) {
|
||||||
|
this.pdv = pdv;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
final int prime = 31;
|
||||||
|
int result = 1;
|
||||||
|
result = prime * result + getOuterType().hashCode();
|
||||||
|
result = prime * result + ((datamov == null) ? 0 : datamov.hashCode());
|
||||||
|
result = prime * result + ((numserie20 == null) ? 0 : numserie20.hashCode());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if (this == obj)
|
||||||
|
return true;
|
||||||
|
if (obj == null)
|
||||||
|
return false;
|
||||||
|
if (getClass() != obj.getClass())
|
||||||
|
return false;
|
||||||
|
RedZVO other = (RedZVO) obj;
|
||||||
|
if (!getOuterType().equals(other.getOuterType()))
|
||||||
|
return false;
|
||||||
|
if (datamov == null) {
|
||||||
|
if (other.datamov != null)
|
||||||
|
return false;
|
||||||
|
} else if (!datamov.equals(other.datamov))
|
||||||
|
return false;
|
||||||
|
if (numserie20 == null) {
|
||||||
|
if (other.numserie20 != null)
|
||||||
|
return false;
|
||||||
|
} else if (!numserie20.equals(other.numserie20))
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private ValidaIntegracionECFRedZxls getOuterType() {
|
||||||
|
return ValidaIntegracionECFRedZxls.this;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public class FiscalVO {
|
||||||
|
private String datamov;
|
||||||
|
private String pdv;
|
||||||
|
private String numserie20;
|
||||||
|
private BigDecimal valorTotal;
|
||||||
|
private int quantidade;
|
||||||
|
|
||||||
|
public FiscalVO(String datamov, String pdv) {
|
||||||
|
super();
|
||||||
|
this.datamov = datamov;
|
||||||
|
this.pdv = pdv;
|
||||||
|
this.valorTotal = BigDecimal.ZERO;
|
||||||
|
this.quantidade = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void soma(String valor) {
|
||||||
|
BigDecimal vl = new BigDecimal(valor);
|
||||||
|
this.valorTotal = valorTotal.add(vl);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDatamov() {
|
||||||
|
return datamov;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDatamov(String datamov) {
|
||||||
|
this.datamov = datamov;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getNumserie20() {
|
||||||
|
return numserie20;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNumserie20(String numserie20) {
|
||||||
|
this.numserie20 = numserie20;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getValorTotal() {
|
||||||
|
return valorTotal;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setValorTotal(BigDecimal valorTotal) {
|
||||||
|
this.valorTotal = valorTotal;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getQuantidade() {
|
||||||
|
return quantidade;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setQuantidade(int quantidade) {
|
||||||
|
this.quantidade = quantidade;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPdv() {
|
||||||
|
return pdv;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPdv(String pdv) {
|
||||||
|
this.pdv = pdv;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
final int prime = 31;
|
||||||
|
int result = 1;
|
||||||
|
result = prime * result + getOuterType().hashCode();
|
||||||
|
result = prime * result + ((datamov == null) ? 0 : datamov.hashCode());
|
||||||
|
result = prime * result + ((pdv == null) ? 0 : pdv.hashCode());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if (this == obj)
|
||||||
|
return true;
|
||||||
|
if (obj == null)
|
||||||
|
return false;
|
||||||
|
if (getClass() != obj.getClass())
|
||||||
|
return false;
|
||||||
|
FiscalVO other = (FiscalVO) obj;
|
||||||
|
if (!getOuterType().equals(other.getOuterType()))
|
||||||
|
return false;
|
||||||
|
if (datamov == null) {
|
||||||
|
if (other.datamov != null)
|
||||||
|
return false;
|
||||||
|
} else if (!datamov.equals(other.datamov))
|
||||||
|
return false;
|
||||||
|
if (pdv == null) {
|
||||||
|
if (other.pdv != null)
|
||||||
|
return false;
|
||||||
|
} else if (!pdv.equals(other.pdv))
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private ValidaIntegracionECFRedZxls getOuterType() {
|
||||||
|
return ValidaIntegracionECFRedZxls.this;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue