410 lines
12 KiB
Java
410 lines
12 KiB
Java
package it.acxent.tex.anag;
|
|
|
|
import it.acxent.anag.Iva;
|
|
import it.acxent.anag.MagFisico;
|
|
import it.acxent.anag._AnagAdapter;
|
|
import it.acxent.art.Articolo;
|
|
import it.acxent.art.Tipo;
|
|
import it.acxent.art.TipologiaArticolo;
|
|
import it.acxent.contab.RigaDocumento;
|
|
import it.acxent.db.ApplParmFull;
|
|
import it.acxent.db.ResParm;
|
|
import it.acxent.db.WcString;
|
|
import it.acxent.util.DoubleOperator;
|
|
import it.acxent.util.Vectumerator;
|
|
import java.io.Serializable;
|
|
import java.sql.Date;
|
|
import java.sql.PreparedStatement;
|
|
import java.sql.ResultSet;
|
|
import java.sql.SQLException;
|
|
import java.util.StringTokenizer;
|
|
|
|
public class ArticoloFilato extends _AnagAdapter implements Serializable {
|
|
private static final long serialVersionUID = 1468228166479L;
|
|
|
|
private long id_articoloFilato;
|
|
|
|
private String descrizione;
|
|
|
|
private long titolo;
|
|
|
|
private long nCapi;
|
|
|
|
private long flgNaturaTinto;
|
|
|
|
private long id_tipo;
|
|
|
|
private Tipo tipo;
|
|
|
|
private long id_iva;
|
|
|
|
private Iva iva;
|
|
|
|
private long flgDispo;
|
|
|
|
private boolean quantitaCalcolate;
|
|
|
|
private double quantitaEffettiva;
|
|
|
|
private double quantitaImpegnata;
|
|
|
|
private double quantitaInArrivo;
|
|
|
|
private String quantitaMagazzinoMovimentoHtml;
|
|
|
|
private double quantitaW;
|
|
|
|
private String codiceAF;
|
|
|
|
private double quantita;
|
|
|
|
private long id_magFisico;
|
|
|
|
private MagFisico magFisico;
|
|
|
|
public ArticoloFilato(ApplParmFull newApplParmFull) {
|
|
super(newApplParmFull);
|
|
}
|
|
|
|
public ArticoloFilato() {}
|
|
|
|
public void setId_articoloFilato(long newId_articoloFilato) {
|
|
this.id_articoloFilato = newId_articoloFilato;
|
|
}
|
|
|
|
public void setDescrizione(String newDescrizione) {
|
|
this.descrizione = newDescrizione;
|
|
}
|
|
|
|
public void setTitolo(long newTitolo) {
|
|
this.titolo = newTitolo;
|
|
}
|
|
|
|
public void setNCapi(long newNCapi) {
|
|
this.nCapi = newNCapi;
|
|
}
|
|
|
|
public void setFlgNaturaTinto(long newFlgNaturaTinto) {
|
|
this.flgNaturaTinto = newFlgNaturaTinto;
|
|
}
|
|
|
|
public long getId_articoloFilato() {
|
|
return this.id_articoloFilato;
|
|
}
|
|
|
|
public String getDescrizione() {
|
|
return (this.descrizione == null) ? getCodiceAF() : this.descrizione.trim();
|
|
}
|
|
|
|
public long getTitolo() {
|
|
return this.titolo;
|
|
}
|
|
|
|
public long getNCapi() {
|
|
return this.nCapi;
|
|
}
|
|
|
|
public long getFlgNaturaTinto() {
|
|
return this.flgNaturaTinto;
|
|
}
|
|
|
|
protected ResParm checkDeleteCascade() {
|
|
return new ResParm(true);
|
|
}
|
|
|
|
protected void deleteCascade() {}
|
|
|
|
public Vectumerator<ArticoloFilato> findByCR(ArticoloFilatoCR CR, int pageNumber, int pageRows) {
|
|
String s_Sql_Find = "select A.* from ARTICOLO_FILATO AS A ";
|
|
String s_Sql_Order = " order by A.codiceAF,A.descrizione";
|
|
if ((!CR.getSearchTxt().isEmpty() && !CR.getSearchTxt().equals("*")) || CR.getFlgQta() == 1L)
|
|
s_Sql_Find = s_Sql_Find + " LEFT JOIN ARTICOLO_FILATO_COLORE AS B ON A.id_articoloFilato=B.id_articoloFilato";
|
|
WcString wc = new WcString();
|
|
if (!CR.getSearchTxt().trim().isEmpty()) {
|
|
StringTokenizer st = new StringTokenizer(CR.getSearchTxt().trim(), " ");
|
|
StringBuffer txt = new StringBuffer("(");
|
|
while (st.hasMoreTokens()) {
|
|
String token = st.nextToken();
|
|
txt.append("(A.descrizione like '%" + token + "%')");
|
|
if (st.hasMoreTokens())
|
|
txt.append(" and ");
|
|
}
|
|
txt.append(")");
|
|
wc.addWc(txt.toString());
|
|
}
|
|
if (CR.getId_tipo() > 0L)
|
|
wc.addWc("A.id_tipo=" + CR.getId_tipo());
|
|
if (CR.getFlgQta() == 1L)
|
|
if (CR.getQtaDa() == 0L) {
|
|
wc.addWc("(A.quantitaW<=" + CR.getQtaA() + " or B.quantitaAfc<=" + CR.getQtaA() + ")");
|
|
} else {
|
|
wc.addWc("(A.quantitaW>=" + CR.getQtaDa() + " or B.quantitaAfc>=" + CR.getQtaDa() + ")");
|
|
wc.addWc("(A.quantitaW<=" + CR.getQtaA() + " or B.quantitaAfc<=" + CR.getQtaA() + ")");
|
|
}
|
|
try {
|
|
PreparedStatement stmt = getConn().prepareStatement(s_Sql_Find + s_Sql_Find + wc.toString());
|
|
return findRows(stmt, pageNumber, pageRows);
|
|
} catch (SQLException e) {
|
|
removeCPConnection();
|
|
handleDebug(e);
|
|
return AB_EMPTY_VECTUMERATOR;
|
|
}
|
|
}
|
|
|
|
public long getId_tipo() {
|
|
return this.id_tipo;
|
|
}
|
|
|
|
public Tipo getTipo() {
|
|
this.tipo = (Tipo)getSecondaryObject(this.tipo, Tipo.class, getId_tipo());
|
|
return this.tipo;
|
|
}
|
|
|
|
public void setId_tipo(long id_tipo) {
|
|
this.id_tipo = id_tipo;
|
|
setTipo(null);
|
|
}
|
|
|
|
public void setTipo(Tipo tipo) {
|
|
this.tipo = tipo;
|
|
}
|
|
|
|
public TipologiaArticolo getTipologiaArticolo() {
|
|
return getTipo().getTipologiaArticolo();
|
|
}
|
|
|
|
public long getId_iva() {
|
|
return this.id_iva;
|
|
}
|
|
|
|
public Iva getIva() {
|
|
this.iva = (Iva)getSecondaryObject(this.iva, Iva.class, getId_iva());
|
|
return this.iva;
|
|
}
|
|
|
|
public void setId_iva(long newId_iva) {
|
|
this.id_iva = newId_iva;
|
|
setIva(null);
|
|
}
|
|
|
|
public void setIva(Iva newIva) {
|
|
this.iva = newIva;
|
|
}
|
|
|
|
public Iva getIva(it.acxent.anag.Clifor l_clifor) {
|
|
this.iva = null;
|
|
if (l_clifor == null || l_clifor.getId_clifor() == 0L) {
|
|
this.iva = (Iva)getSecondaryObject(this.iva, Iva.class, new Long(getId_iva()));
|
|
} else {
|
|
this.iva = new Iva(getApFull());
|
|
this.iva.findByPrimaryKey(getId_iva(l_clifor));
|
|
}
|
|
return this.iva;
|
|
}
|
|
|
|
public long getId_iva(it.acxent.anag.Clifor l_clifor) {
|
|
if (l_clifor != null && l_clifor.getId_clifor() != 0L) {
|
|
if (l_clifor.getFlgArt8() == 1L)
|
|
return getCodiceIvaArt8_A();
|
|
return this.id_iva;
|
|
}
|
|
return this.id_iva;
|
|
}
|
|
|
|
public ResParm superSave() {
|
|
return save();
|
|
}
|
|
|
|
private synchronized void calcolaQuantita() {
|
|
if ((!isQuantitaCalcolate() ? true : false) & ((this.id_articoloFilato != 0L) ? true : false)) {
|
|
long l_flgDispo;
|
|
RigaDocumento rd = new RigaDocumento(getApFull());
|
|
rd.findMagFilatoDisponibilita(0L, getId_articoloFilato(), 0L, null, 0L, 0L, 0L, null);
|
|
double q = rd.getQuantita();
|
|
double nr = rd.getNr();
|
|
double kg = rd.getKg();
|
|
double mt = rd.getMt();
|
|
setQuantitaW(q);
|
|
setQuantita(q);
|
|
setQuantitaImpegnata(new RigaDocumento(getApFull()).getQuantitaImpegnataFilatoByArticoloFilatoColoreSeriale(0L,
|
|
getId_articoloFilato(), 0L, ""));
|
|
double q1 = new RigaDocumento(getApFull()).getQuantitaFilatoInArrivoByArticoloFilatoColoreSeriale(0L, getId_articoloFilato(), 0L, "");
|
|
setQuantitaInArrivo(q1);
|
|
if (getTipo().getFlgTipoMagazzino() != 9L && getTipo().getFlgTipoMagazzino() != 9L) {
|
|
DoubleOperator dop = new DoubleOperator(q);
|
|
dop.add(this.quantitaInArrivo);
|
|
dop.subtract(this.quantitaImpegnata);
|
|
setQuantitaEffettiva(dop.getResult());
|
|
}
|
|
this.quantitaMagazzinoMovimentoHtml = Articolo.getMovimentoHtmlDesc(getTipologiaArticolo(), q, nr, kg, mt, this.quantitaInArrivo, this.quantitaImpegnata, this.quantitaEffettiva,
|
|
usaMagazzino(), getParm("USA_MAGAZZINO").isTrue(),
|
|
getNf());
|
|
if (!usaMagazzino()) {
|
|
l_flgDispo = 1L;
|
|
} else {
|
|
l_flgDispo = (this.quantitaW > 0.0D) ? 1L : 0L;
|
|
}
|
|
String temp = "update ARTICOLO_FILATO set quantitaMagazzinoMovimentoHtml='" + this.quantitaMagazzinoMovimentoHtml + "', quantitaW=" + this.quantitaW + ", quantitaEffettiva=" + this.quantitaEffettiva + ", quantitaImpegnata=" + this.quantitaImpegnata + ", quantitaCalcolate=true, flgDispo=" + l_flgDispo + " where id_articoloFilato=" +
|
|
|
|
getId_articoloFilato();
|
|
update(temp);
|
|
setQuantitaCalcolate(true);
|
|
}
|
|
}
|
|
|
|
public double getQuantitaEffettiva() {
|
|
if (!isQuantitaCalcolate() && this.id_articoloFilato != 0L)
|
|
calcolaQuantita();
|
|
return this.quantitaEffettiva;
|
|
}
|
|
|
|
public double getQuantitaImpegnata() {
|
|
if (!isQuantitaCalcolate() && this.id_articoloFilato != 0L)
|
|
calcolaQuantita();
|
|
return this.quantitaImpegnata;
|
|
}
|
|
|
|
public double getQuantitaInArrivo() {
|
|
if (!isQuantitaCalcolate() && this.id_articoloFilato != 0L)
|
|
calcolaQuantita();
|
|
return this.quantitaInArrivo;
|
|
}
|
|
|
|
public String getQuantitaMagazzinoMovimentoHtml() {
|
|
if (getParm("USA_MAGAZZINO").isTrue())
|
|
return "--";
|
|
if (!isQuantitaCalcolate() && this.id_articoloFilato != 0L)
|
|
calcolaQuantita();
|
|
return (this.quantitaMagazzinoMovimentoHtml == null) ? "" : this.quantitaMagazzinoMovimentoHtml;
|
|
}
|
|
|
|
public double getQuantitaW() {
|
|
if (!isQuantitaCalcolate() && this.id_articoloFilato != 0L)
|
|
calcolaQuantita();
|
|
return this.quantitaW;
|
|
}
|
|
|
|
public boolean isQuantitaCalcolate() {
|
|
return this.quantitaCalcolate;
|
|
}
|
|
|
|
public void setQuantitaCalcolate(boolean quantitaCalcolate) {
|
|
this.quantitaCalcolate = quantitaCalcolate;
|
|
}
|
|
|
|
public void setQuantitaEffettiva(double quantitaEffettiva) {
|
|
this.quantitaEffettiva = quantitaEffettiva;
|
|
}
|
|
|
|
public void setQuantitaImpegnata(double quantitaImpegnata) {
|
|
this.quantitaImpegnata = quantitaImpegnata;
|
|
}
|
|
|
|
public void setQuantitaInArrivo(double quantitaInArrivo) {
|
|
this.quantitaInArrivo = quantitaInArrivo;
|
|
}
|
|
|
|
public void setQuantitaMagazzinoMovimentoHtml(String quantitaMagazzinoMovimentoHtml) {
|
|
this.quantitaMagazzinoMovimentoHtml = quantitaMagazzinoMovimentoHtml;
|
|
}
|
|
|
|
public void setQuantitaW(double quantitaW) {
|
|
this.quantitaW = quantitaW;
|
|
}
|
|
|
|
public long getFlgDispo() {
|
|
return this.flgDispo;
|
|
}
|
|
|
|
public void setFlgDispo(long flgDispo) {
|
|
this.flgDispo = flgDispo;
|
|
}
|
|
|
|
public void resetCalcoloQuantita() {
|
|
if (getId_articoloFilato() > 0L) {
|
|
update("update ARTICOLO_FILATO set quantitaCalcolate=false where id_articoloFilato=" + getId_articoloFilato());
|
|
setQuantitaCalcolate(false);
|
|
}
|
|
}
|
|
|
|
public boolean usaMagazzino() {
|
|
if (getTipo().getFlgTipoMagazzino() == 9L || getTipo().getFlgTipoMagazzino() == 0L)
|
|
return false;
|
|
return true;
|
|
}
|
|
|
|
public String getCodiceAF() {
|
|
return (this.codiceAF == null) ? "" : this.codiceAF.trim();
|
|
}
|
|
|
|
public void setCodiceAF(String nota) {
|
|
this.codiceAF = nota;
|
|
}
|
|
|
|
public String getDescrizioneCompleta() {
|
|
return getCodiceAF() + " " + getCodiceAF();
|
|
}
|
|
|
|
public void findByCodice(String l_codiceAF) {
|
|
String s_Sql_Find = "select A.* from ARTICOLO_FILATO AS A";
|
|
String s_Sql_Order = "";
|
|
WcString wc = new WcString();
|
|
wc.addWc("A.codiceAF='" + l_codiceAF + "'");
|
|
try {
|
|
PreparedStatement stmt = getConn().prepareStatement(s_Sql_Find + s_Sql_Find + wc.toString());
|
|
findFirstRecord(stmt);
|
|
} catch (SQLException e) {
|
|
removeCPConnection();
|
|
handleDebug(e);
|
|
}
|
|
}
|
|
|
|
public double getQuantita() {
|
|
return getQuantita(null);
|
|
}
|
|
|
|
public void setQuantita(double quantita) {
|
|
this.quantita = quantita;
|
|
}
|
|
|
|
public double getQuantita(Date data) {
|
|
if (!usaMagazzino())
|
|
return 0.0D;
|
|
if (getParm("USA_MAGAZZINO").isFalse()) {
|
|
RigaDocumento rd = new RigaDocumento(getApFull());
|
|
rd.findMagFilatoDisponibilita(0L, getId_articoloFilato(), 0L, null, 0L, getId_magFisico(), 0L, data);
|
|
return rd.getQuantita();
|
|
}
|
|
return this.quantita;
|
|
}
|
|
|
|
public long getId_magFisico() {
|
|
return this.id_magFisico;
|
|
}
|
|
|
|
public MagFisico getMagFisico() {
|
|
this.magFisico = (MagFisico)getSecondaryObject(this.magFisico, MagFisico.class, getId_magFisico());
|
|
return this.magFisico;
|
|
}
|
|
|
|
public void setId_magFisico(long id_magFisico) {
|
|
this.id_magFisico = id_magFisico;
|
|
setMagFisico(null);
|
|
}
|
|
|
|
public void setMagFisico(MagFisico magFisico) {
|
|
this.magFisico = magFisico;
|
|
}
|
|
|
|
protected void fillFields(ResultSet rst) {
|
|
super.fillFields(rst);
|
|
try {
|
|
if (isColumnInResultSet(rst, "id_magFisico"))
|
|
setId_magFisico(rst.getLong("id_magFisico"));
|
|
if (isColumnInResultSet(rst, "quantita"))
|
|
setQuantita(rst.getDouble("quantita"));
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
}
|