bug#16732
dev:thiago qua: git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Model/trunk/modelWeb@98766 d1611594-4594-4d17-8e1d-87c2c4800839master
parent
8328f31c37
commit
bb4f1ed8e2
|
@ -47,6 +47,9 @@ import com.rjconsultores.ventaboletos.vo.busquedapacotes.transformer.DatosEmpres
|
||||||
@Repository("empresaDAO")
|
@Repository("empresaDAO")
|
||||||
public class EmpresaHibernateDAO extends GenericHibernateDAO<Empresa, Integer> implements EmpresaDAO {
|
public class EmpresaHibernateDAO extends GenericHibernateDAO<Empresa, Integer> implements EmpresaDAO {
|
||||||
|
|
||||||
|
private static String FOLIO_SISTEMA_BPE = "FOLIO_SISTEMA_BPE_";
|
||||||
|
private static String FOLIO_SISTEMA = "FOLIO_SISTEMA_";
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private DataSource dataSource;
|
private DataSource dataSource;
|
||||||
|
|
||||||
|
@ -161,6 +164,11 @@ public class EmpresaHibernateDAO extends GenericHibernateDAO<Empresa, Integer> i
|
||||||
|
|
||||||
Session session = getSessionFactory().getCurrentSession();
|
Session session = getSessionFactory().getCurrentSession();
|
||||||
session.saveOrUpdate(inscricaoEstadual);
|
session.saveOrUpdate(inscricaoEstadual);
|
||||||
|
|
||||||
|
if(inscricaoEstadual.getIndHabilitaIEDescentralizada()) {
|
||||||
|
gerarSequenceBPeInscricaoEstadual(inscricaoEstadual);
|
||||||
|
}
|
||||||
|
|
||||||
session.flush();
|
session.flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -240,7 +248,7 @@ public class EmpresaHibernateDAO extends GenericHibernateDAO<Empresa, Integer> i
|
||||||
}
|
}
|
||||||
|
|
||||||
private String obtemNomeFolio(Boolean isFolioBpe) {
|
private String obtemNomeFolio(Boolean isFolioBpe) {
|
||||||
return isFolioBpe ? "FOLIO_SISTEMA_BPE_" : "FOLIO_SISTEMA_";
|
return isFolioBpe ? FOLIO_SISTEMA_BPE : FOLIO_SISTEMA;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -345,4 +353,46 @@ public class EmpresaHibernateDAO extends GenericHibernateDAO<Empresa, Integer> i
|
||||||
return qr.list();
|
return qr.list();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void gerarSequenceBPeInscricaoEstadual(InscricaoEstadual inscricaoEstadual) {
|
||||||
|
StringBuilder nomeSequence = new StringBuilder(FOLIO_SISTEMA_BPE);
|
||||||
|
nomeSequence.append(inscricaoEstadual.getEstado().getCveestado())
|
||||||
|
.append("_")
|
||||||
|
.append(inscricaoEstadual.getEmpresa().getEmpresaId())
|
||||||
|
.append("_IE_")
|
||||||
|
.append(inscricaoEstadual.getInscricaoestadualId())
|
||||||
|
.append("_SEQ");
|
||||||
|
|
||||||
|
if(!isSequenceBPeInscricaoEstadualCriada(nomeSequence.toString())) {
|
||||||
|
Connection conn = null;
|
||||||
|
try {
|
||||||
|
conn = dataSource.getConnection();
|
||||||
|
conn.createStatement().execute("CREATE SEQUENCE " + nomeSequence.toString() + " MINVALUE 1 MAXVALUE 999999999 INCREMENT BY 1 START WITH 1 ORDER NOCACHE CYCLE");
|
||||||
|
} catch (SQLException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}finally {
|
||||||
|
try {
|
||||||
|
if(conn != null && !conn.isClosed()){
|
||||||
|
conn.close();
|
||||||
|
}
|
||||||
|
} catch (SQLException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isSequenceBPeInscricaoEstadualCriada(String nomeSequence) {
|
||||||
|
StringBuilder sQuery = new StringBuilder();
|
||||||
|
sQuery.append("SELECT SEQUENCE_NAME FROM USER_SEQUENCES ")
|
||||||
|
.append("WHERE SEQUENCE_NAME LIKE :nomeSequence");
|
||||||
|
|
||||||
|
Query qr = getSession().createSQLQuery(sQuery.toString());
|
||||||
|
qr.setParameter("nomeSequence", nomeSequence);
|
||||||
|
qr.setMaxResults(1);
|
||||||
|
|
||||||
|
String result = (String) qr.uniqueResult();
|
||||||
|
|
||||||
|
return StringUtils.isNotBlank(result);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -251,7 +251,7 @@ public class Estado implements Serializable {
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
int hash = 0;
|
int hash = 0;
|
||||||
hash += (estadoId != null ? estadoId.hashCode() : 0);
|
hash += (getEstadoId() != null ? getEstadoId().hashCode() : 0);
|
||||||
return hash;
|
return hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -261,7 +261,7 @@ public class Estado implements Serializable {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Estado other = (Estado) object;
|
Estado other = (Estado) object;
|
||||||
if ((this.estadoId == null && other.estadoId != null) || (this.estadoId != null && !this.estadoId.equals(other.estadoId))) {
|
if ((this.getEstadoId() == null && other.getEstadoId() != null) || (this.getEstadoId() != null && !this.getEstadoId().equals(other.getEstadoId()))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -36,9 +36,11 @@ public class InscricaoEstadual {
|
||||||
private String cnpj;
|
private String cnpj;
|
||||||
private String equivalenciaAG;
|
private String equivalenciaAG;
|
||||||
private Boolean isBPe;
|
private Boolean isBPe;
|
||||||
|
private Boolean indHabilitaIEDescentralizada;
|
||||||
|
private Parada origemIEDescentralizada;
|
||||||
|
|
||||||
public InscricaoEstadual() {
|
public InscricaoEstadual() {
|
||||||
// TODO Auto-generated constructor stub
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
public InscricaoEstadual(String inscricaoEstadual, Empresa empresa, Estado estado, Integer usuarioId,
|
public InscricaoEstadual(String inscricaoEstadual, Empresa empresa, Estado estado, Integer usuarioId,
|
||||||
|
@ -209,13 +211,21 @@ public class InscricaoEstadual {
|
||||||
this.isBPe = isBPe;
|
this.isBPe = isBPe;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
final int prime = 31;
|
||||||
|
int result = 1;
|
||||||
|
result = prime * result + ((getInscricaoestadualId() == null) ? 0 : getInscricaoestadualId().hashCode());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object object) {
|
public boolean equals(Object object) {
|
||||||
if (!(object instanceof InscricaoEstadual)) {
|
if (!(object instanceof InscricaoEstadual)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
InscricaoEstadual other = (InscricaoEstadual) object;
|
InscricaoEstadual other = (InscricaoEstadual) object;
|
||||||
if ((this.inscricaoestadualId == null && other.inscricaoestadualId != null) || (this.inscricaoestadualId != null && !this.inscricaoestadualId.equals(other.inscricaoestadualId))) {
|
if ((this.getInscricaoestadualId() == null && other.getInscricaoestadualId() != null) || (this.getInscricaoestadualId() != null && !this.getInscricaoestadualId().equals(other.getInscricaoestadualId()))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -225,4 +235,23 @@ public class InscricaoEstadual {
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return String.format("%s-%s", estado.getCveestado(), numInscricaoEstadual);
|
return String.format("%s-%s", estado.getCveestado(), numInscricaoEstadual);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ManyToOne
|
||||||
|
@JoinColumn(name = "ORIGEM_ID_IEDESCENTRALIZADA")
|
||||||
|
public Parada getOrigemIEDescentralizada() {
|
||||||
|
return origemIEDescentralizada;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOrigemIEDescentralizada(Parada origemIEDescentralizada) {
|
||||||
|
this.origemIEDescentralizada = origemIEDescentralizada;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Column(name = "INDHABILITAIEDESCENTRALIZADA")
|
||||||
|
public Boolean getIndHabilitaIEDescentralizada() {
|
||||||
|
return indHabilitaIEDescentralizada != null ? indHabilitaIEDescentralizada : false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIndHabilitaIEDescentralizada(Boolean indHabilitaIEDescentralizada) {
|
||||||
|
this.indHabilitaIEDescentralizada = indHabilitaIEDescentralizada;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -145,8 +145,9 @@ public enum CustomEnum {
|
||||||
|
|
||||||
IS_DESCONSIDERA_CLIENTE_NA_BASE("isDesconsideraClienteNaBase"),
|
IS_DESCONSIDERA_CLIENTE_NA_BASE("isDesconsideraClienteNaBase"),
|
||||||
|
|
||||||
IS_VALIDAR_CONSTANTE_REMESSA("isValidarConstanteRemessa");
|
IS_HABILITA_IE_DESCENTRALIZADA("isHabilitaIEDescentralizada"),
|
||||||
|
|
||||||
|
IS_VALIDAR_CONSTANTE_REMESSA("isValidarConstanteRemessa");
|
||||||
|
|
||||||
private String descricao;
|
private String descricao;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue