fixes bug#13501
dev:JULIO qua: git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Model/trunk/modelWeb@90891 d1611594-4594-4d17-8e1d-87c2c4800839master
parent
5f225ceabd
commit
b09f9db7ff
|
@ -75,4 +75,10 @@ public class ClienteServiceImpl implements ClienteService {
|
|||
public List<Cliente> buscarPorDocumento(String documento) {
|
||||
return clienteDAO.buscarPorDocumento(documento);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Cliente buscarPorNumeroFidelidade(Integer numeroFidelidade) {
|
||||
// TODO Auto-generated method stub
|
||||
return clienteDAO.buscarPorNumeroFidelidade(numeroFidelidade);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,26 +1,50 @@
|
|||
package com.rjconsultores.ventaboletos.service.impl;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.Reader;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||
import org.apache.poi.ss.usermodel.Cell;
|
||||
import org.apache.poi.ss.usermodel.Row;
|
||||
import org.apache.poi.ss.usermodel.Sheet;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
import org.brazilutils.br.cpfcnpj.Cpf;
|
||||
import org.brazilutils.validation.ValidationException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.zkoss.util.media.Media;
|
||||
import org.zkoss.util.resource.Labels;
|
||||
|
||||
import com.rjconsultores.ventaboletos.entidad.Cliente;
|
||||
import com.rjconsultores.ventaboletos.entidad.ClienteDireccion;
|
||||
import com.rjconsultores.ventaboletos.entidad.ClienteFidelidad;
|
||||
import com.rjconsultores.ventaboletos.entidad.Empresa;
|
||||
import com.rjconsultores.ventaboletos.entidad.TarjetaFidelidad;
|
||||
import com.rjconsultores.ventaboletos.entidad.TipoIdentificacion;
|
||||
import com.rjconsultores.ventaboletos.passageirofrequente.vo.ClienteExcelVo;
|
||||
import com.rjconsultores.ventaboletos.service.ClienteService;
|
||||
import com.rjconsultores.ventaboletos.service.ImportacaoClientesService;
|
||||
import com.rjconsultores.ventaboletos.service.TipoIdentificacionService;
|
||||
import com.rjconsultores.ventaboletos.utilerias.ApplicationProperties;
|
||||
import com.rjconsultores.ventaboletos.utilerias.CustomEnum;
|
||||
import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado;
|
||||
|
||||
@Service("importacaoClientesService")
|
||||
public class ImportacaoClientesServiceImpl implements ImportacaoClientesService {
|
||||
|
||||
@Autowired
|
||||
TipoIdentificacionService tipoIdentificacionService;
|
||||
@Autowired
|
||||
private ClienteService clienteService;
|
||||
private static Logger log = Logger.getLogger(ImportacaoClientesServiceImpl.class);
|
||||
|
@ -117,4 +141,484 @@ public class ImportacaoClientesServiceImpl implements ImportacaoClientesService
|
|||
}
|
||||
return gravados;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] lerArquivoExcel(Media media, List<Empresa> empresas) {
|
||||
|
||||
List<TipoIdentificacion> lsTipoIdentificacion = tipoIdentificacionService.obtenerTodos();
|
||||
TipoIdentificacion tipoIdentificacionUno = null;
|
||||
TipoIdentificacion tipoIdentificacionDoos = null;
|
||||
|
||||
for (TipoIdentificacion t : lsTipoIdentificacion) {
|
||||
if (t.getDesctipo().equalsIgnoreCase("cpf")) {
|
||||
tipoIdentificacionUno = t;
|
||||
} else if (t.getDesctipo().equalsIgnoreCase("rg")) {
|
||||
tipoIdentificacionDoos = t;
|
||||
}
|
||||
if (tipoIdentificacionUno != null && tipoIdentificacionDoos != null)
|
||||
break;
|
||||
}
|
||||
|
||||
Boolean usaCPFComoFidelidade = false;
|
||||
Integer index = 1;
|
||||
StringBuilder qtdeGravados = new StringBuilder();
|
||||
StringBuilder erros = new StringBuilder();
|
||||
Integer inseridos = 0;
|
||||
Integer atualizados = 0;
|
||||
InputStream isMExcel = media.getStreamData();
|
||||
Sheet sheet = null;
|
||||
|
||||
if (media.getFormat().equals("xls")) {
|
||||
HSSFWorkbook wb;
|
||||
try {
|
||||
wb = new HSSFWorkbook(isMExcel);
|
||||
sheet = wb.getSheetAt(0);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
} else if (media.getFormat().equals("xlsx")) {
|
||||
XSSFWorkbook wb;
|
||||
try {
|
||||
wb = new XSSFWorkbook(isMExcel);
|
||||
sheet = wb.getSheetAt(0);
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
int rows = sheet.getPhysicalNumberOfRows();
|
||||
|
||||
if (validaSheet(sheet)) {
|
||||
usaCPFComoFidelidade = ApplicationProperties.getInstance().isCustomHabilitado(CustomEnum.USA_CPF_COMO_FIDELIDADE.getDescricao());
|
||||
try {
|
||||
for (index = 1; index < rows; index++) {
|
||||
Row row = sheet.getRow(index);
|
||||
Iterator<Cell> cellIterator = row.cellIterator();
|
||||
ClienteExcelVo cliente = new ClienteExcelVo();
|
||||
while (cellIterator.hasNext()) {
|
||||
Cell cell = cellIterator.next();
|
||||
switch (cell.getColumnIndex()) {
|
||||
case 0:
|
||||
cell.setCellType(Cell.CELL_TYPE_STRING);
|
||||
cliente.setCpf(cell.getStringCellValue());
|
||||
System.out.println(cliente.getCpf());
|
||||
break;
|
||||
case 1:
|
||||
cell.setCellType(Cell.CELL_TYPE_STRING);
|
||||
cliente.setRg(cell.getStringCellValue());
|
||||
break;
|
||||
case 2:
|
||||
cell.setCellType(Cell.CELL_TYPE_STRING);
|
||||
cliente.setNome(cell.getStringCellValue());
|
||||
break;
|
||||
case 3:
|
||||
cell.setCellType(Cell.CELL_TYPE_STRING);
|
||||
cliente.setEmail(cell.getStringCellValue());
|
||||
break;
|
||||
case 4:
|
||||
cell.setCellType(Cell.CELL_TYPE_STRING);
|
||||
cliente.setTelefone(cell.getStringCellValue());
|
||||
break;
|
||||
case 5:
|
||||
cell.setCellType(Cell.CELL_TYPE_STRING);
|
||||
cliente.setCelular(cell.getStringCellValue());
|
||||
break;
|
||||
case 6:
|
||||
cell.setCellType(Cell.CELL_TYPE_STRING);
|
||||
cliente.setFax(cell.getStringCellValue());
|
||||
break;
|
||||
case 7:
|
||||
cell.setCellType(Cell.CELL_TYPE_STRING);
|
||||
cliente.setNascimento(cell.getStringCellValue());
|
||||
break;
|
||||
case 8:
|
||||
cell.setCellType(Cell.CELL_TYPE_STRING);
|
||||
cliente.setSexo(cell.getStringCellValue());
|
||||
break;
|
||||
case 9:
|
||||
cell.setCellType(Cell.CELL_TYPE_STRING);
|
||||
cliente.setEndereco(cell.getStringCellValue());
|
||||
break;
|
||||
case 10:
|
||||
cell.setCellType(Cell.CELL_TYPE_STRING);
|
||||
cliente.setBairro(cell.getStringCellValue());
|
||||
break;
|
||||
case 11:
|
||||
cell.setCellType(Cell.CELL_TYPE_STRING);
|
||||
cliente.setCidade(cell.getStringCellValue());
|
||||
break;
|
||||
case 12:
|
||||
cell.setCellType(Cell.CELL_TYPE_STRING);
|
||||
cliente.setEstado(cell.getStringCellValue());
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (validaDadosPlanilha(cliente, erros)) {
|
||||
Integer[] gravados = salvarClienteExcel(empresas, usaCPFComoFidelidade, cliente, tipoIdentificacionUno, tipoIdentificacionDoos);
|
||||
inseridos = gravados[0] + inseridos;
|
||||
atualizados = gravados[1] + atualizados;
|
||||
|
||||
} else {
|
||||
erros.append("\n erro ao gravar o cliente na linha ");
|
||||
erros.append(index + 1).append(" do arquivo.");
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
qtdeGravados.append("Gravados ").append(inseridos + atualizados).append(" clientes de ").append(index).append(" importados.\n");
|
||||
qtdeGravados.append("Atualizados ").append(atualizados).append(" clientes.\n");
|
||||
qtdeGravados.append("Inseridos ").append(inseridos).append(" novos clientes.");
|
||||
String[] resultado = { qtdeGravados.toString(), erros.toString() };
|
||||
return resultado;
|
||||
|
||||
} catch (ArrayIndexOutOfBoundsException e) {
|
||||
e.printStackTrace();
|
||||
String msg = "Erro ao gravar cliente na linha " + (index + 1) + " do arquivo.";
|
||||
erros.append(msg);
|
||||
String[] resultado = { "Houve erro ao gravar os clientes, consulte o arquivo de erros.", erros.toString() };
|
||||
return resultado;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
erros.append("Linha ").append(index).append(" do arquivo de clientes, erro: ").append(e.getCause().getCause()).append("\n");
|
||||
String[] resultado = { "Houve erro ao gravar os clientes, consulte o arquivo de erros.", erros.toString() };
|
||||
return resultado;
|
||||
}
|
||||
|
||||
} else {
|
||||
erros.append("A estrutura do arquivo esta com erro ").append("\n");
|
||||
String[] resultado = { "Houve erro ao gravar os clientes, consulte o arquivo de erros.", erros.toString() };
|
||||
return resultado;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private Integer[] salvarClienteExcel(List<Empresa> empresas, Boolean usaCPFComoFidelidade, ClienteExcelVo cliente, TipoIdentificacion tipoIdentificacionUno, TipoIdentificacion tipoIdentificacionDoos) throws ParseException {
|
||||
Integer inseridos = new Integer(0);
|
||||
Integer atualizados = new Integer(0);
|
||||
Integer[] gravados = { 0, 0 };
|
||||
Cliente clienteGravar = new Cliente();
|
||||
List<Cliente> lsCliente = clienteService.buscarPorDocumento(cliente.getCpf());
|
||||
|
||||
if (lsCliente != null && !lsCliente.isEmpty()) {
|
||||
clienteGravar = lsCliente.get(0);
|
||||
}
|
||||
|
||||
if (true) {
|
||||
criarFidelidadesTodasEmpresas(clienteGravar, empresas, cliente);
|
||||
}
|
||||
clienteGravar.setFecnacimiento(StringUtils.isEmpty(cliente.getNascimento()) ? null : retornaDate(cliente.getNascimento()));
|
||||
clienteGravar.setDesccorreo(cliente.getEmail());
|
||||
clienteGravar.setNombcliente(cliente.getNome());
|
||||
clienteGravar.setNumfax(cliente.getFax());
|
||||
clienteGravar.setNumtelefono(cliente.getTelefone());
|
||||
clienteGravar.setNumtelefonodos(cliente.getCelular());
|
||||
clienteGravar.setIndsexo(cliente.getSexo());
|
||||
clienteGravar.setNumIdentificaUno(cliente.getCpf());
|
||||
clienteGravar.setTipoIdentificacionUno(tipoIdentificacionUno);
|
||||
if (!StringUtils.isEmpty(cliente.getRg())) {
|
||||
clienteGravar.setNumIdentificaDos(cliente.getRg());
|
||||
clienteGravar.setTipoIdentificacionDos(tipoIdentificacionDoos);
|
||||
}
|
||||
setDirecion(clienteGravar, cliente);
|
||||
if (clienteGravar.getClienteId() == null) {
|
||||
clienteGravar.setFecCadastro(new Date());
|
||||
clienteService.suscribir(clienteGravar);
|
||||
inseridos = inseridos + 1;
|
||||
gravados[0] = gravados[0] + inseridos;
|
||||
|
||||
} else {
|
||||
clienteService.actualizacion(clienteGravar);
|
||||
atualizados = atualizados + 1;
|
||||
gravados[1] = gravados[1] + atualizados;
|
||||
}
|
||||
|
||||
return gravados;
|
||||
}
|
||||
|
||||
private void setDirecion(Cliente cliente, ClienteExcelVo cExcel) {
|
||||
List<ClienteDireccion> lsDirecion = new ArrayList<ClienteDireccion>();
|
||||
ClienteDireccion direccion = new ClienteDireccion();
|
||||
if ((cliente.getLsClienteDireccion() != null)
|
||||
&& (!cliente.getLsClienteDireccion().isEmpty())) {
|
||||
if (cliente.getLsClienteDireccion().get(0) != null) {
|
||||
direccion = cliente.getLsClienteDireccion().get(0);
|
||||
cliente.getLsClienteDireccion().remove(0);
|
||||
}
|
||||
}
|
||||
direccion.setDesestado(cExcel.getEstado());
|
||||
direccion.setDesciudad(cExcel.getCidade());
|
||||
direccion.setDesccolonia(cExcel.getBairro());
|
||||
direccion.setDesccalle(cExcel.getEndereco());
|
||||
direccion.setActivo(true);
|
||||
direccion.setClienteId(cliente);
|
||||
lsDirecion.add(direccion);
|
||||
cliente.setLsClienteDireccion(lsDirecion);
|
||||
|
||||
}
|
||||
|
||||
private void criarFidelidadesTodasEmpresas(Cliente cliente, List<Empresa> empresas, ClienteExcelVo cExce) {
|
||||
|
||||
|
||||
|
||||
Boolean achou = false;
|
||||
List<ClienteFidelidad> fidelidades = null;
|
||||
|
||||
|
||||
if(cliente.getClienteId()==null){
|
||||
fidelidades = new ArrayList<ClienteFidelidad>();
|
||||
for (Empresa e : empresas) {
|
||||
fidelidades.add(criarFidelidade(e, cExce));
|
||||
}
|
||||
cliente.setListClienteFidelidad(fidelidades);
|
||||
|
||||
}else{
|
||||
fidelidades=cliente.getListClienteFidelidad();
|
||||
if (fidelidades == null || fidelidades.isEmpty()) {
|
||||
for (Empresa e : empresas) {
|
||||
fidelidades.add(criarFidelidade(e, cExce));
|
||||
}
|
||||
} else {
|
||||
for (Empresa e : empresas) {
|
||||
for (ClienteFidelidad f : fidelidades) {
|
||||
if (f.getEmpresa().equals(e)) {
|
||||
f.setActivo(true);
|
||||
f.setFecmodif(new Date());
|
||||
TarjetaFidelidad tarjetaFidelidad = f.getTarjetaFidelidad();
|
||||
if (tarjetaFidelidad != null) {
|
||||
tarjetaFidelidad.setActivo(true);
|
||||
tarjetaFidelidad.setFecmodif(new Date());
|
||||
}
|
||||
|
||||
achou = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!achou) {
|
||||
fidelidades.add(criarFidelidade(e, cExce));
|
||||
}
|
||||
achou = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// private List<ClienteFidelidad> criarFidelidadesTodasEmpresas(List<ClienteFidelidad> fidelidades, List<Empresa> empresas, ClienteExcelVo cExce) {
|
||||
//
|
||||
// List<ClienteFidelidad> result = new ArrayList<ClienteFidelidad>();
|
||||
// Boolean achou = false;
|
||||
// if (fidelidades==null || fidelidades.isEmpty()) {
|
||||
// for (Empresa e : empresas) {
|
||||
// result.add(criarFidelidade(e, cExce));
|
||||
// }
|
||||
// } else {
|
||||
// for (Empresa e : empresas) {
|
||||
// for (ClienteFidelidad f : fidelidades) {
|
||||
// if (f.getEmpresa().equals(e)) {
|
||||
// f.setActivo(true);
|
||||
// f.setFecmodif(new Date());
|
||||
// TarjetaFidelidad tarjetaFidelidad = f.getTarjetaFidelidad();
|
||||
// if(tarjetaFidelidad!=null){
|
||||
// tarjetaFidelidad.setActivo(true);
|
||||
// tarjetaFidelidad.setFecmodif(new Date());
|
||||
// }
|
||||
// result.add(f);
|
||||
// achou = true;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// if (!achou) {
|
||||
// result.add(criarFidelidade(e, cExce));
|
||||
// }
|
||||
// achou = false;
|
||||
// }
|
||||
// }
|
||||
// return result;
|
||||
// }
|
||||
|
||||
private ClienteFidelidad criarFidelidade(Empresa e, ClienteExcelVo cExcel) {
|
||||
ClienteFidelidad clienteFidelidad = new ClienteFidelidad();
|
||||
TarjetaFidelidad tarjetaFidelidad = new TarjetaFidelidad();
|
||||
tarjetaFidelidad.setNumTarjeta(new Long(cExcel.getCpf()));
|
||||
tarjetaFidelidad.setActivo(true);
|
||||
tarjetaFidelidad.setFecmodif(Calendar.getInstance().getTime());
|
||||
tarjetaFidelidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
|
||||
|
||||
clienteFidelidad.setEmpresa(e);
|
||||
clienteFidelidad.setActivo(true);
|
||||
clienteFidelidad.setFecmodif(Calendar.getInstance().getTime());
|
||||
clienteFidelidad.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
|
||||
clienteFidelidad.setTarjetaFidelidad(tarjetaFidelidad);
|
||||
|
||||
return clienteFidelidad;
|
||||
}
|
||||
|
||||
public Boolean validaDadosPlanilha(ClienteExcelVo cliente, StringBuilder erros) {
|
||||
|
||||
if (!StringUtils.isEmpty(cliente.getCpf())) {
|
||||
try {
|
||||
Long.parseLong(cliente.getCpf());
|
||||
if (!validarCPF(cliente.getCpf())) {
|
||||
erros.append("CPF inválido.");
|
||||
return false;
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
erros.append("O CPF deve possuir apenas números.");
|
||||
return false;
|
||||
|
||||
} catch (Exception e) {
|
||||
e.getMessage();
|
||||
erros.append("Erro ao obter o CPF.");
|
||||
return false;
|
||||
}
|
||||
|
||||
} else {
|
||||
erros.append("O CPF e obrigatório.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (StringUtils.isEmpty(cliente.getNome())) {
|
||||
erros.append("O NOME e obrigatório.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!StringUtils.isEmpty(cliente.getSexo())) {
|
||||
if (cliente.getSexo().length() != 1 || !(cliente.getSexo().equalsIgnoreCase("s") || cliente.getSexo().equalsIgnoreCase("m"))) {
|
||||
erros.append("Campo sexo foi informado incorretamente.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!StringUtils.isEmpty(cliente.getNascimento()) && cliente.getNascimento().matches("(0?[1-9]|[12][0-9]|3[01])/(0?[1-9]|1[012])/((19|20)\\d\\d)")) {
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
|
||||
try {
|
||||
dateFormat.parse(cliente.getNascimento());
|
||||
} catch (Exception e) {
|
||||
erros.append("Campo Nascimento foi informado incorretamente.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private Boolean validaSheet(Sheet sheet) {
|
||||
|
||||
Row row = sheet.getRow(0);
|
||||
Iterator<Cell> cellIterator = row.cellIterator();
|
||||
|
||||
while (cellIterator.hasNext()) {
|
||||
Cell cell = cellIterator.next();
|
||||
switch (cell.getColumnIndex()) {
|
||||
case 0:
|
||||
if (cell.getStringCellValue().equalsIgnoreCase(Labels.getLabel("importarClientesController.HEADERCOLUMN.cpf"))) {
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
case 1:
|
||||
if (cell.getStringCellValue().equalsIgnoreCase(Labels.getLabel("importarClientesController.HEADERCOLUMN.rg"))) {
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
case 2:
|
||||
if (cell.getStringCellValue().equalsIgnoreCase(Labels.getLabel("importarClientesController.HEADERCOLUMN.nome"))) {
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
case 3:
|
||||
if (cell.getStringCellValue().equalsIgnoreCase(Labels.getLabel("importarClientesController.HEADERCOLUMN.email"))) {
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
|
||||
case 4:
|
||||
if (cell.getStringCellValue().equalsIgnoreCase(Labels.getLabel("importarClientesController.HEADERCOLUMN.telefone"))) {
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
|
||||
case 5:
|
||||
if (cell.getStringCellValue().equalsIgnoreCase(Labels.getLabel("importarClientesController.HEADERCOLUMN.celular"))) {
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
|
||||
case 6:
|
||||
if (cell.getStringCellValue().equalsIgnoreCase(Labels.getLabel("importarClientesController.HEADERCOLUMN.fax"))) {
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
|
||||
case 7:
|
||||
if (cell.getStringCellValue().equalsIgnoreCase(Labels.getLabel("importarClientesController.HEADERCOLUMN.nascimento"))) {
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
|
||||
case 8:
|
||||
if (cell.getStringCellValue().equalsIgnoreCase(Labels.getLabel("importarClientesController.HEADERCOLUMN.sexo"))) {
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
case 9:
|
||||
if (cell.getStringCellValue().equalsIgnoreCase(Labels.getLabel("importarClientesController.HEADERCOLUMN.endereco"))) {
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
case 10:
|
||||
if (cell.getStringCellValue().equalsIgnoreCase(Labels.getLabel("importarClientesController.HEADERCOLUMN.bairro"))) {
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
case 11:
|
||||
if (cell.getStringCellValue().equalsIgnoreCase(Labels.getLabel("importarClientesController.HEADERCOLUMN.cidade"))) {
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
case 12:
|
||||
if (cell.getStringCellValue().equalsIgnoreCase(Labels.getLabel("importarClientesController.HEADERCOLUMN.estado"))) {
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private Date retornaDate(String date) throws ParseException {
|
||||
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
|
||||
Date data = null;
|
||||
data = (Date) dateFormat.parse(date);
|
||||
return data;
|
||||
|
||||
}
|
||||
|
||||
private Boolean validarCPF(String numDoc) {
|
||||
try {
|
||||
// https://dicasdeprogramacao.com.br/algoritmo-para-validar-cpf
|
||||
// O VAlidador não pegava os CPFs com todos os numeros iguais
|
||||
if (numDoc.length() != 11 || numDoc.equals("00000000000") || numDoc.equals("11111111111") || numDoc.equals("22222222222") ||
|
||||
numDoc.equals("33333333333") || numDoc.equals("44444444444") || numDoc.equals("55555555555") ||
|
||||
numDoc.equals("66666666666") || numDoc.equals("77777777777") || numDoc.equals("88888888888") ||
|
||||
numDoc.equals("99999999999")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Cpf cpf = new Cpf(numDoc);
|
||||
if (!cpf.isValid()) {
|
||||
return false;
|
||||
}
|
||||
} catch (ValidationException e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue