142 lines
6.4 KiB
Java
142 lines
6.4 KiB
Java
import it.acxent.art.Articolo;
|
|
import it.acxent.art.ArticoloCR;
|
|
import it.acxent.db.ApplParm;
|
|
import it.acxent.db.ApplParmFull;
|
|
import it.acxent.db.ResParm;
|
|
import it.acxent.util.DbConsole;
|
|
import it.acxent.util.Vectumerator;
|
|
import java.sql.Time;
|
|
import java.util.StringTokenizer;
|
|
|
|
public class CCArticoliEAN extends DbConsole {
|
|
public static void main(String[] args) {
|
|
CCArticoliEAN bean = new CCArticoliEAN();
|
|
bean.doImport();
|
|
System.exit(0);
|
|
}
|
|
|
|
public void doImport() {
|
|
String db = "ccxx";
|
|
int i = 0;
|
|
int se1 = 10;
|
|
int se2 = 100;
|
|
String hostname = "localhost";
|
|
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);
|
|
System.out.println("ciclo articoli con ean duplicati... li cancello.....");
|
|
String idArticoli = "82982,82864,82860,82865,82984,82985,82988,82987,82989,82990,82991,82994,82995,82577,82997,82998,83000,83002,82571,83004,82573,83005,83006,82666,83007,82675,83008,83009,83010,83011,83012,83013,83014,83015,83016,83017,83020,82674,83022,83023,83025,83026,83027,83028,83029,83030,83032,83033,83034,83037,83038,83039,83040,83041,83042,83043,83045,82603,83046,83047,83048,82678,83049,83050,83051,83052,83053,82673,83054,83056,83057,83058,83059,83060,83061,83064,83065,83066,83068,83070,83071,83072,83073,83074,83088,83091,84673,83094,83095,83096,83097,83098,82602,83099,83100,83364,83101,82830,85396,82833,82836,82828,85400,83104,83105,83106,85395,85401,85391,85388,83112,83114,83115,84828,84829,84832,82641,83131,82834,83133";
|
|
StringTokenizer st = new StringTokenizer(idArticoli, ",");
|
|
long noEs = 0L, escg = 0L;
|
|
StringBuilder s_noEs = new StringBuilder();
|
|
StringBuilder s_escg = new StringBuilder();
|
|
StringBuilder s_ebay = new StringBuilder();
|
|
Articolo row = new Articolo(apTarget);
|
|
Articolo art = new Articolo(apTarget);
|
|
ArticoloCR CR = new ArticoloCR(apTarget);
|
|
while (st.hasMoreTokens()) {
|
|
long l_id_articolo = Long.parseLong(st.nextToken());
|
|
row.findByPrimaryKey(l_id_articolo);
|
|
if (row.getId_articolo() > 0L)
|
|
if (row.getCodiciAlternativi().indexOf("ES_") >= 0) {
|
|
if (row.getCodiciAlternativi().indexOf("CG_") >= 0) {
|
|
System.out.println("da cancellare ma sie esprinet che cgross... controllare: flgvis:" +
|
|
row.getFlgEscludiWeb() + " " + row.getCodice());
|
|
escg++;
|
|
s_escg.append(row.getId_articolo());
|
|
s_escg.append(",");
|
|
if (!row.getCodiceEan().isEmpty()) {
|
|
CR.setCodiceEan(row.getCodiceEan());
|
|
Vectumerator<Articolo> vect = art.findByCR(CR, 0, 0);
|
|
while (vect.hasMoreElements()) {
|
|
Articolo articolo = (Articolo)vect.nextElement();
|
|
if (articolo.getFlgEscludiWeb() > 0L)
|
|
articolo.delete();
|
|
}
|
|
}
|
|
} else if (row.isEbayPubblicato()) {
|
|
System.out.println("da cancellare ma su ebay......");
|
|
s_ebay.append(row.getId_articolo());
|
|
s_ebay.append(",");
|
|
} else {
|
|
System.out.println("Cancello: flgvis:" + row.getFlgEscludiWeb() + " " + row.getCodice());
|
|
row.delete();
|
|
}
|
|
} else {
|
|
noEs++;
|
|
s_noEs.append(row.getId_articolo());
|
|
s_noEs.append(",");
|
|
if (!row.getCodiceEan().isEmpty()) {
|
|
CR.setCodiceEan(row.getCodiceEan());
|
|
Vectumerator<Articolo> vect = art.findByCR(CR, 0, 0);
|
|
while (vect.hasMoreElements()) {
|
|
Articolo articolo = (Articolo)vect.nextElement();
|
|
if (articolo.getFlgEscludiWeb() > 0L) {
|
|
articolo.delete();
|
|
System.out.println("*");
|
|
continue;
|
|
}
|
|
if (articolo.getCodiciAlternativi().indexOf("ES_") >= 0) {
|
|
if (row.isEbayPubblicato()) {
|
|
System.out.println("no es .. trovato es su ebay......");
|
|
s_ebay.append(row.getId_articolo());
|
|
s_ebay.append(",");
|
|
continue;
|
|
}
|
|
System.out.println("*X " + articolo.getCodice());
|
|
ResParm rp = articolo.delete();
|
|
if (!rp.getStatus())
|
|
System.out.println("ERR " + rp.getMsg());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
row.save();
|
|
i++;
|
|
if (se1 > 0 && i % se1 == 0)
|
|
System.out.print(".");
|
|
if (se2 > 0 && i % se2 == 0)
|
|
System.out.println(i);
|
|
}
|
|
System.out.println("\n-----" + noEs + " no esprinet:\n" + s_noEs.toString());
|
|
System.out.println("\n-----" + escg + " es+cg:\n" + s_escg.toString());
|
|
System.out.println("\n-----ebay:\n" + s_ebay.toString());
|
|
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;
|
|
}
|
|
}
|
|
}
|