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")
|
||||
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
|
||||
private DataSource dataSource;
|
||||
|
||||
|
@ -161,6 +164,11 @@ public class EmpresaHibernateDAO extends GenericHibernateDAO<Empresa, Integer> i
|
|||
|
||||
Session session = getSessionFactory().getCurrentSession();
|
||||
session.saveOrUpdate(inscricaoEstadual);
|
||||
|
||||
if(inscricaoEstadual.getIndHabilitaIEDescentralizada()) {
|
||||
gerarSequenceBPeInscricaoEstadual(inscricaoEstadual);
|
||||
}
|
||||
|
||||
session.flush();
|
||||
}
|
||||
|
||||
|
@ -240,7 +248,7 @@ public class EmpresaHibernateDAO extends GenericHibernateDAO<Empresa, Integer> i
|
|||
}
|
||||
|
||||
private String obtemNomeFolio(Boolean isFolioBpe) {
|
||||
return isFolioBpe ? "FOLIO_SISTEMA_BPE_" : "FOLIO_SISTEMA_";
|
||||
return isFolioBpe ? FOLIO_SISTEMA_BPE : FOLIO_SISTEMA;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -344,5 +352,47 @@ public class EmpresaHibernateDAO extends GenericHibernateDAO<Empresa, Integer> i
|
|||
|
||||
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
|
||||
public int hashCode() {
|
||||
int hash = 0;
|
||||
hash += (estadoId != null ? estadoId.hashCode() : 0);
|
||||
hash += (getEstadoId() != null ? getEstadoId().hashCode() : 0);
|
||||
return hash;
|
||||
}
|
||||
|
||||
|
@ -261,7 +261,7 @@ public class Estado implements Serializable {
|
|||
return false;
|
||||
}
|
||||
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 true;
|
||||
|
|
|
@ -36,9 +36,11 @@ public class InscricaoEstadual {
|
|||
private String cnpj;
|
||||
private String equivalenciaAG;
|
||||
private Boolean isBPe;
|
||||
private Boolean indHabilitaIEDescentralizada;
|
||||
private Parada origemIEDescentralizada;
|
||||
|
||||
public InscricaoEstadual() {
|
||||
// TODO Auto-generated constructor stub
|
||||
super();
|
||||
}
|
||||
|
||||
public InscricaoEstadual(String inscricaoEstadual, Empresa empresa, Estado estado, Integer usuarioId,
|
||||
|
@ -208,6 +210,14 @@ public class InscricaoEstadual {
|
|||
public void setIsBPe(Boolean 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
|
||||
public boolean equals(Object object) {
|
||||
|
@ -215,7 +225,7 @@ public class InscricaoEstadual {
|
|||
return false;
|
||||
}
|
||||
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 true;
|
||||
|
@ -225,4 +235,23 @@ public class InscricaoEstadual {
|
|||
public String toString() {
|
||||
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,9 +145,10 @@ public enum CustomEnum {
|
|||
|
||||
IS_DESCONSIDERA_CLIENTE_NA_BASE("isDesconsideraClienteNaBase"),
|
||||
|
||||
IS_HABILITA_IE_DESCENTRALIZADA("isHabilitaIEDescentralizada"),
|
||||
|
||||
IS_VALIDAR_CONSTANTE_REMESSA("isValidarConstanteRemessa");
|
||||
|
||||
|
||||
private String descricao;
|
||||
|
||||
private CustomEnum(String descricao) {
|
||||
|
|
Loading…
Reference in New Issue