299 lines
8.8 KiB
Java
299 lines
8.8 KiB
Java
package it.acxent.anag;
|
|
|
|
import it.acxent.contab.CausaleMagazzino;
|
|
import it.acxent.db.ApplParmFull;
|
|
import it.acxent.db.WcString;
|
|
import it.acxent.util.StringTokenizer;
|
|
import it.acxent.util.Vectumerator;
|
|
import java.io.Serializable;
|
|
import java.sql.PreparedStatement;
|
|
import java.sql.SQLException;
|
|
|
|
public class MagFisico extends _AnagAdapter implements Serializable {
|
|
private long id_magFisico;
|
|
|
|
private String descrizione;
|
|
|
|
private long id_clifor;
|
|
|
|
private Clifor clifor;
|
|
|
|
private long flgTipo;
|
|
|
|
private long flgFineLavorazione;
|
|
|
|
public static final long TIPO_MAGAZZINO_TUTTI = 0L;
|
|
|
|
public static final long TIPO_MAGAZZINO_INTERNO = 1L;
|
|
|
|
public static final long TIPO_MAGAZZINO_LAVORAZIONE = 2L;
|
|
|
|
public static final long TIPO_MAGAZZINO_ORDINATO_A_FORNITORI = 3L;
|
|
|
|
public static final long FINE_LAVORAZIONE_NO = 0L;
|
|
|
|
public static final long FINE_LAVORAZIONE_SI = 1L;
|
|
|
|
public MagFisico(ApplParmFull newApplParmFull) {
|
|
super(newApplParmFull);
|
|
}
|
|
|
|
public Vectumerator<MagFisico> findByClifor(long l_id_clifor) {
|
|
String s_Sql_Find = "select A.* from MAG_FISICO AS A";
|
|
String s_Sql_Order = " order by descrizione";
|
|
WcString wc = new WcString();
|
|
wc.addWc("A.id_clifor=" + l_id_clifor);
|
|
try {
|
|
PreparedStatement stmt = getConn().prepareStatement(s_Sql_Find + s_Sql_Find + wc.toString());
|
|
return findRows(stmt);
|
|
} catch (SQLException e) {
|
|
removeCPConnection();
|
|
handleDebug(e);
|
|
return AB_EMPTY_VECTUMERATOR;
|
|
}
|
|
}
|
|
|
|
public MagFisico() {}
|
|
|
|
public void setId_magFisico(long newId_magFisico) {
|
|
this.id_magFisico = newId_magFisico;
|
|
}
|
|
|
|
public void setDescrizione(String newDescrizione) {
|
|
this.descrizione = newDescrizione;
|
|
}
|
|
|
|
public void setId_clifor(long newId_clifor) {
|
|
this.id_clifor = newId_clifor;
|
|
setClifor(null);
|
|
}
|
|
|
|
public long getId_magFisico() {
|
|
return this.id_magFisico;
|
|
}
|
|
|
|
public String getDescrizione() {
|
|
return (this.descrizione == null) ? "" : this.descrizione.trim();
|
|
}
|
|
|
|
public long getId_clifor() {
|
|
return this.id_clifor;
|
|
}
|
|
|
|
public void setClifor(Clifor newClifor) {
|
|
this.clifor = newClifor;
|
|
}
|
|
|
|
public Clifor getClifor() {
|
|
this.clifor = (Clifor)getSecondaryObject(this.clifor, Clifor.class, getId_clifor());
|
|
return this.clifor;
|
|
}
|
|
|
|
protected void deleteCascade() {}
|
|
|
|
public Vectumerator findByCR(MagFisicoCR CR, int pageNumber, int pageRows) {
|
|
String s_Sql_Find = "select A.* from MAG_FISICO AS A";
|
|
String s_Sql_Order = "";
|
|
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.Cognome like '%" + token + "%' or A.Nome like '%" + token + "%')");
|
|
if (st.hasMoreTokens())
|
|
txt.append(" and ");
|
|
}
|
|
txt.append(")");
|
|
wc.addWc(txt.toString());
|
|
}
|
|
try {
|
|
PreparedStatement stmt = getConn().prepareStatement(s_Sql_Find + s_Sql_Find + wc.toString());
|
|
return findRows(stmt, pageNumber, pageRows);
|
|
} catch (SQLException e) {
|
|
handleDebug(e);
|
|
return AB_EMPTY_VECTUMERATOR;
|
|
}
|
|
}
|
|
|
|
public String getTipo() {
|
|
return getTipo(getFlgTipo());
|
|
}
|
|
|
|
public void setFlgTipo(long flgInterno) {
|
|
this.flgTipo = flgInterno;
|
|
}
|
|
|
|
public Vectumerator<MagFisico> findByTipo(long l_flgTipo) {
|
|
String s_Sql_Find = "select A.* from MAG_FISICO AS A";
|
|
String s_Sql_Order = "";
|
|
WcString wc = new WcString();
|
|
if (l_flgTipo > 0L)
|
|
wc.addWc(" A.flgTipo = " + l_flgTipo);
|
|
try {
|
|
PreparedStatement stmt = getConn().prepareStatement(s_Sql_Find + s_Sql_Find + wc.toString());
|
|
return findRows(stmt);
|
|
} catch (SQLException e) {
|
|
handleDebug(e);
|
|
return AB_EMPTY_VECTUMERATOR;
|
|
}
|
|
}
|
|
|
|
public Vectumerator<MagFisico> findByCausalePartenza(CausaleMagazzino cm) {
|
|
String s_Sql_Find = "select A.* from MAG_FISICO AS A";
|
|
String s_Sql_Order = "";
|
|
WcString wc = new WcString();
|
|
if (cm.getId_magFisicoPartenza() > 0L) {
|
|
wc.addWc(" A.id_magFisico = " + cm.getId_magFisicoPartenza());
|
|
} else if (cm.getFlgPartenzaInterno() == 1L && cm.getFlgPartenzaLavorazione() == 1L) {
|
|
wc.addWc("(A.flgTipo = 1 or A.flgTipo=2)");
|
|
} else if (cm.getFlgPartenzaInterno() == 1L && cm.getFlgPartenzaLavorazione() == 0L) {
|
|
wc.addWc("A.flgTipo = 1");
|
|
} else if (cm.getFlgPartenzaInterno() == 0L && cm.getFlgPartenzaLavorazione() == 1L) {
|
|
wc.addWc("A.flgTipo=2");
|
|
}
|
|
try {
|
|
PreparedStatement stmt = getConn().prepareStatement(s_Sql_Find + s_Sql_Find + wc.toString());
|
|
return findRows(stmt);
|
|
} catch (SQLException e) {
|
|
handleDebug(e);
|
|
return AB_EMPTY_VECTUMERATOR;
|
|
}
|
|
}
|
|
|
|
public Vectumerator<MagFisico> findByCausaleArrivo(CausaleMagazzino cm) {
|
|
String s_Sql_Find = "select A.* from MAG_FISICO AS A";
|
|
String s_Sql_Order = "";
|
|
WcString wc = new WcString();
|
|
if (cm.getId_magFisicoArrivo() > 0L) {
|
|
wc.addWc(" A.id_magFisico = " + cm.getId_magFisicoArrivo());
|
|
} else if (cm.getFlgArrivoInterno() == 1L && cm.getFlgArrivoLavorazione() == 1L) {
|
|
wc.addWc("(A.flgTipo = 1 or A.flgTipo=2)");
|
|
} else if (cm.getFlgArrivoInterno() == 1L && cm.getFlgArrivoLavorazione() == 0L) {
|
|
wc.addWc("A.flgTipo = 1");
|
|
} else if (cm.getFlgArrivoInterno() == 0L && cm.getFlgArrivoLavorazione() == 1L) {
|
|
wc.addWc("A.flgTipo=2");
|
|
}
|
|
try {
|
|
PreparedStatement stmt = getConn().prepareStatement(s_Sql_Find + s_Sql_Find + wc.toString());
|
|
return findRows(stmt);
|
|
} catch (SQLException e) {
|
|
handleDebug(e);
|
|
return AB_EMPTY_VECTUMERATOR;
|
|
}
|
|
}
|
|
|
|
public boolean isMagOrdinatoValorizzato() {
|
|
String s_Sql_Find = "select COUNT(*) as tot from MAG_FISICO AS A ";
|
|
String s_Sql_Order = "";
|
|
WcString wc = new WcString();
|
|
wc.addWc(" A.flgTipo = 3");
|
|
wc.addWc(" A.id_magFisico != " + getId_magFisico());
|
|
try {
|
|
PreparedStatement stmt = getConn().prepareStatement(s_Sql_Find + s_Sql_Find + wc.toString());
|
|
long tot = getCount(stmt, "tot");
|
|
if (tot > 0L)
|
|
return true;
|
|
return false;
|
|
} catch (SQLException e) {
|
|
handleDebug(e);
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public void findMagazzinoOrdinato() {
|
|
String s_Sql_Find = "select A.* from MAG_FISICO AS A";
|
|
String s_Sql_Order = "";
|
|
WcString wc = new WcString();
|
|
wc.addWc(" A.flgTipo = 3");
|
|
try {
|
|
PreparedStatement stmt = getConn().prepareStatement(s_Sql_Find + s_Sql_Find + wc.toString());
|
|
findFirstRecord(stmt);
|
|
} catch (SQLException e) {
|
|
handleDebug(e);
|
|
}
|
|
}
|
|
|
|
public String getDescrizioneCompleta() {
|
|
if (getDescrizione().isEmpty())
|
|
return "Nessuno";
|
|
return getDescrizione() + " " + getDescrizione();
|
|
}
|
|
|
|
public long getFlgTipo() {
|
|
return this.flgTipo;
|
|
}
|
|
|
|
public static final String getTipo(long l_flgTipo) {
|
|
switch ((int)l_flgTipo) {
|
|
case 1:
|
|
return "Interno";
|
|
case 2:
|
|
return "Lavorazione";
|
|
case 3:
|
|
return "Ordinato a Fornitori";
|
|
}
|
|
return "??";
|
|
}
|
|
|
|
public long getFlgFineLavorazione() {
|
|
return this.flgFineLavorazione;
|
|
}
|
|
|
|
public void setFlgFineLavorazione(long flgFineLavorazione) {
|
|
this.flgFineLavorazione = flgFineLavorazione;
|
|
}
|
|
|
|
public static final String getFineLavorazione(long l_flgFineLavorazione) {
|
|
switch ((int)l_flgFineLavorazione) {
|
|
case 0:
|
|
return "No (solo prelievo)";
|
|
case 1:
|
|
return "Si (scarico e prelievo)";
|
|
}
|
|
return "??";
|
|
}
|
|
|
|
public String getFineLavorazione() {
|
|
return getFineLavorazione(getFlgFineLavorazione());
|
|
}
|
|
|
|
public String getHtmlTableHeaderInterni() {
|
|
Vectumerator<MagFisico> vec = findByTipo(1L);
|
|
StringBuilder sb = new StringBuilder();
|
|
while (vec.hasMoreElements()) {
|
|
MagFisico row = (MagFisico)vec.nextElement();
|
|
sb.append("<th>");
|
|
sb.append(row.getDescrizione());
|
|
sb.append("</th>");
|
|
}
|
|
return sb.toString();
|
|
}
|
|
|
|
public String getHtmlTableHeaderInterniVuoti() {
|
|
Vectumerator<MagFisico> vec = findByTipo(1L);
|
|
StringBuilder sb = new StringBuilder();
|
|
sb.append("<th");
|
|
sb.append(" colspan='");
|
|
sb.append(vec.getTotNumberOfRecords());
|
|
sb.append("'> ");
|
|
sb.append("</th>");
|
|
return sb.toString();
|
|
}
|
|
|
|
public String getDescrizioneTipo() {
|
|
StringBuilder sb = new StringBuilder(getTipo());
|
|
if (getFlgTipo() == 2L) {
|
|
sb.append(" ");
|
|
sb.append("-");
|
|
sb.append(" ");
|
|
sb.append("Fine lav: ");
|
|
sb.append(getFineLavorazione());
|
|
sb.append(" ");
|
|
sb.append("-");
|
|
sb.append(" ");
|
|
sb.append(getClifor().getCognomeNome());
|
|
}
|
|
return sb.toString().trim();
|
|
}
|
|
}
|