Regalamiunsorriso/decompiled-libs/www/acxent-common-1.0.1/it/acxent/cc/UpdateArticoli.java

162 lines
6.5 KiB
Java
Raw Normal View History

2026-04-22 18:41:37 +02:00
package it.acxent.cc;
import it.acxent.anag.Listino;
import it.acxent.art.Articolo;
import it.acxent.art.ArticoloCR;
import it.acxent.art.Marca;
import it.acxent.art.Tipo;
import it.acxent.db.ApplParm;
import it.acxent.db.ApplParmFull;
import it.acxent.util.DbConsole;
import it.acxent.util.Vectumerator;
import java.sql.Time;
import java.util.StringTokenizer;
public class UpdateArticoli extends DbConsole {
public static void main(String[] args) {
UpdateArticoli bean = new UpdateArticoli();
bean.doImport();
System.exit(0);
}
public void doImport() {
String db = "cc";
int i = 0;
int se1 = 10;
int se2 = 100;
String hostname = "10.0.0.5";
String temp = getCi().readLine("Hostname (" + hostname + "):");
if (!temp.isEmpty())
hostname = temp;
temp = getCi().readLine("Database name (" + db + "):");
if (!temp.isEmpty())
db = temp;
System.out.println("Db: " + db);
ApplParmFull apTarget = new ApplParmFull(new ApplParm(3, "//" + hostname + "/" + db, "root", "root", 1, 10, 300));
apTarget.setDebug(false);
StringBuffer msg = new StringBuffer();
try {
Articolo bean = new Articolo(apTarget);
long l_id_tipoEffettivo = 80L;
double ricarico = 13.0D;
long l_id_listinoEbay = 5L;
long l_qtaMax = 20L;
long l_qtaEbay = 15L;
String searchTxt = "ink";
long qtaMinRicerca = 5L;
long l_id_marcaRicerca = 2L;
long l_id_tipoRIcerca = 1L;
boolean caricaEbay = false;
long l_flgEbayPubblicato = -1L;
System.out.println("---------------- DATI DA INSERIRE ----------------");
temp = getCi().readLine("l_id_tipoEffettivo (" + l_id_tipoEffettivo + "):");
if (!temp.isEmpty())
l_id_tipoEffettivo = Long.parseLong(temp);
Tipo tipo = new Tipo(apTarget);
tipo.findByPrimaryKey(l_id_tipoEffettivo);
System.out.println("Tipo effettivo scelto: " + tipo.getDescrizioneCompleta());
temp = getCi().readLine("ricarico (" + ricarico + "):");
if (!temp.isEmpty())
ricarico = Double.parseDouble(temp);
temp = getCi().readLine("l_id_listinoEbay (" + l_id_listinoEbay + "):");
if (!temp.isEmpty())
l_id_listinoEbay = Long.parseLong(temp);
Listino listino = new Listino(apTarget);
listino.findByPrimaryKey(l_id_listinoEbay);
System.out.println("Listino ebay scelto: " + listino.getDescrizioneCompleta());
temp = getCi().readLine("l_qtaMax (" + l_qtaMax + "):");
if (!temp.isEmpty())
l_qtaMax = Long.parseLong(temp);
temp = getCi().readLine("l_qtaEbay (" + l_qtaEbay + "):");
if (!temp.isEmpty())
l_qtaEbay = Long.parseLong(temp);
temp = getCi().readLine("caricaebay (" + (caricaEbay ? "y" : "n") + " y/n):");
if (!temp.isEmpty())
caricaEbay = temp.toLowerCase().equals("y");
System.out.println("---------------- CRITERI DI RICERCA ----------------");
temp = getCi().readLine("l_id_tipoRIcerca (" + l_id_tipoRIcerca + "):");
if (!temp.isEmpty())
l_id_tipoRIcerca = Long.parseLong(temp);
tipo.findByPrimaryKey(l_id_tipoRIcerca);
System.out.println("Tipo ricerca scelto: " + tipo.getDescrizioneCompleta());
temp = getCi().readLine("searchTxt (" + searchTxt + "):");
if (!temp.isEmpty())
searchTxt = temp;
temp = getCi().readLine("qtaMinRicerca (" + qtaMinRicerca + "):");
if (!temp.isEmpty())
qtaMinRicerca = Long.parseLong(temp);
temp = getCi().readLine("l_id_marcaRicerca (" + l_id_marcaRicerca + "):");
if (!temp.isEmpty())
l_id_marcaRicerca = Long.parseLong(temp);
Marca marca = new Marca(apTarget);
marca.findByPrimaryKey(l_id_marcaRicerca);
System.out.println("Marca ricerca scelta: " + marca.getDescrizione());
temp = getCi().readLine("l_flgEbayPubblicato (" + l_flgEbayPubblicato + "):");
if (!temp.isEmpty())
l_flgEbayPubblicato = Long.parseLong(temp);
System.out.println("ciclo articoli");
ArticoloCR CR = new ArticoloCR();
CR.setSearchTxt(searchTxt);
CR.setFlgEscludiWeb(0L);
CR.setFlgQta(1L);
CR.setQtaDa(qtaMinRicerca);
CR.setId_marca(l_id_marcaRicerca);
CR.setId_tipo(l_id_tipoRIcerca);
CR.setFlgEbayPubblicato(l_flgEbayPubblicato);
Vectumerator<Articolo> vec = bean.findByCR(CR, 0, 0);
System.out.println("Tot Record: " + vec.getTotNumberOfRecords());
while (vec.hasMoreElements()) {
Articolo row = (Articolo)vec.nextElement();
System.out.println(row.getCodice() + " " + row.getCodice());
row.setId_tipo(l_id_tipoEffettivo);
row.superSave();
row.caricaIcecat();
row.setPercRicarico(ricarico);
row.setCostoNuovo(row.getCostoNetto());
row.setPrezzoIvatoBarrato(row.getStreetPriceIva());
row.setFlgEbay(1L);
row.setId_listinoEbay(l_id_listinoEbay);
row.setQtaMaxAcquistoWww(l_qtaMax);
row.setQtaEbay(l_qtaEbay);
row.setFlgGoogle(1L);
row.setFlgEscludiWebArt(0L);
row.save();
row.aggiornaPrezzoNettoConCostoNuovo();
if (caricaEbay && !row.isEbayPubblicato())
row.ebayPublishFull();
i++;
if (se1 > 0 && i % se1 == 0)
System.out.print(".");
if (se2 > 0 && i % se2 == 0)
System.out.println("" + i + " / " + i);
}
System.out.println("fine ciclo \n" + msg.toString());
} catch (Exception e) {
e.printStackTrace();
}
}
protected Time getTimeFromString(String theTime) {
try {
if (theTime.matches("[0-9][0-9][0-9][0-9]"))
theTime = theTime.substring(0, 2) + ":" + theTime.substring(0, 2);
if (theTime.matches("[0-9]{1,2}+:[0-9]{1,2}+")) {
StringTokenizer st = new StringTokenizer(theTime, ":");
int hour = Integer.parseInt(st.nextToken());
int min = Integer.parseInt(st.nextToken());
int sec = st.hasMoreElements() ? Integer.parseInt(st.nextToken()) : 0;
return new Time((long)((hour - 1) * 3600000 + min * 60000 + sec * 1000));
}
if (theTime.matches("[0-9]{1,2}+:[0-9]{1,2}+:[0-9]{1,2}+")) {
StringTokenizer st = new StringTokenizer(theTime, ":");
int hour = Integer.parseInt(st.nextToken());
int min = Integer.parseInt(st.nextToken());
int sec = st.hasMoreElements() ? Integer.parseInt(st.nextToken()) : 0;
return new Time((long)((hour - 1) * 3600000 + min * 60000 + sec * 1000));
}
return null;
} catch (Exception e) {
return null;
}
}
}