www in docker support
This commit is contained in:
parent
539a848e95
commit
c227fce036
2145 changed files with 399596 additions and 58 deletions
|
|
@ -0,0 +1,449 @@
|
|||
package it.acxent.cc;
|
||||
|
||||
import it.acxent.art.ArticoloCR;
|
||||
import it.acxent.art.Tipo;
|
||||
import it.acxent.common.StatusMsg;
|
||||
import it.acxent.db.ApplParmFull;
|
||||
import it.acxent.db.DBAdapter;
|
||||
import it.acxent.db.ResParm;
|
||||
import it.acxent.db.WcString;
|
||||
import it.acxent.mail.MailProperties;
|
||||
import it.acxent.util.Timer;
|
||||
import it.acxent.util.Vectumerator;
|
||||
import java.io.Serializable;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
|
||||
public class WwwAutomator extends DBAdapter implements Serializable {
|
||||
private static final long serialVersionUID = 1667311885432L;
|
||||
|
||||
private long id_wwwAutomator;
|
||||
|
||||
private long id_tipo;
|
||||
|
||||
private String categoriaImport;
|
||||
|
||||
private String searchTxt;
|
||||
|
||||
private String ultimaEsecuzione;
|
||||
|
||||
class ThreadAutomator extends Thread {
|
||||
private String TAG_THREAD_MSG = "AUTOMATOR ";
|
||||
|
||||
private ApplParmFull apFull;
|
||||
|
||||
private boolean sendEmail;
|
||||
|
||||
private WwwAutomatorCR CR;
|
||||
|
||||
public ThreadAutomator(ApplParmFull apFull, WwwAutomatorCR CR, boolean sendEmail) {
|
||||
this.apFull = apFull;
|
||||
this.sendEmail = sendEmail;
|
||||
this.CR = CR;
|
||||
if (!WwwAutomator.isThreadAttivo()) {
|
||||
WwwAutomator.threadAutomator = true;
|
||||
start();
|
||||
}
|
||||
}
|
||||
|
||||
public void run() {
|
||||
boolean debug = false;
|
||||
Timer timer = new Timer();
|
||||
timer.start();
|
||||
StatusMsg.updateMsgByTag(WwwAutomator.this.getApFull(), this.TAG_THREAD_MSG, "...inizio ...");
|
||||
ResParm rp = new ResParm(true);
|
||||
StringBuilder sb = new StringBuilder();
|
||||
int i = 1;
|
||||
int se1 = 10;
|
||||
int se2 = 100;
|
||||
WwwAutomator bean = new WwwAutomator(this.apFull);
|
||||
Vectumerator<WwwAutomator> vec = bean.findByCR(this.CR, 0, 0);
|
||||
while (vec.hasMoreElements()) {
|
||||
WwwAutomator row = (WwwAutomator)vec.nextElement();
|
||||
String temp = "Aggiornamento " + i + " su " + vec.getTotNumberOfRecords() + " - " + row.getDescrizione();
|
||||
StatusMsg.updateMsgByTag(WwwAutomator.this.getApFull(), this.TAG_THREAD_MSG, temp);
|
||||
DBAdapter.printDebug(debug, this.TAG_THREAD_MSG + this.TAG_THREAD_MSG);
|
||||
ArticoloBulkUpdate abu = new ArticoloBulkUpdate(this.apFull);
|
||||
ArticoloCR CR = new ArticoloCR(this.apFull);
|
||||
CR.setSearchTxt(row.getSearchTxt());
|
||||
CR.setCategoriaImport(row.getCategoriaImport());
|
||||
CR.setId_tipo(1L);
|
||||
abu.setFlgGoogleBA(row.getFlgGoogle());
|
||||
abu.setRicaricoBA(row.getRicarico());
|
||||
abu.setPrezzoPubblicoDaBA(row.getPrezzoPubblicoDa());
|
||||
abu.setRicaricoOltreBA(row.getRicaricoOltre());
|
||||
abu.setQtaMaxAcquistoWwwBA(row.getQtaMaxAcquistoWww());
|
||||
abu.setId_tipoBA(row.getId_tipo());
|
||||
abu.setPreviewSizes("");
|
||||
abu.setPreviewSizes1("");
|
||||
abu.setFlgEscludiWebArtBA(0L);
|
||||
rp = abu.starBulkUpdate(this.apFull, CR, row);
|
||||
StatusMsg.updateMsgByTag(WwwAutomator.this.getApFull(), this.TAG_THREAD_MSG, " in attesa di bulk update ..." + temp);
|
||||
while (true) {
|
||||
if (ArticoloBulkUpdate.isThreadAttivo()) {
|
||||
try {
|
||||
sleep(3000L);
|
||||
} catch (Exception e) {}
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (row.getUltimaEsecuzione().indexOf("record processati: 0") < 0) {
|
||||
sb.append("-------------------------------------------");
|
||||
sb.append("<br/>");
|
||||
sb.append(row.getDescrizione());
|
||||
sb.append(" ");
|
||||
sb.append(row.getUltimaEsecuzione());
|
||||
sb.append("<br/>");
|
||||
}
|
||||
DBAdapter.printDebug(debug, this.TAG_THREAD_MSG + " FINE CICLO.... RIPARTO... " + this.TAG_THREAD_MSG + "\n");
|
||||
i++;
|
||||
if (se1 > 0 && i % se1 == 0)
|
||||
System.out.print(".");
|
||||
if (se2 > 0 && i % se2 == 0)
|
||||
System.out.println("" + i + " / " + i);
|
||||
}
|
||||
timer.stop();
|
||||
rp.setMsg(this.TAG_THREAD_MSG + " concluso. DURATA: " + this.TAG_THREAD_MSG);
|
||||
if (this.sendEmail) {
|
||||
MailProperties mp = new MailProperties();
|
||||
String eMail = WwwAutomator.this.getApFull().getParm("TO").getTesto();
|
||||
mp.put("TO", eMail);
|
||||
mp.setProperty("FROM", WwwAutomator.this.getApFull().getParm("FROM").getTesto());
|
||||
mp.put("SUBJECT", this.TAG_THREAD_MSG);
|
||||
mp.put("ISHTML", "true");
|
||||
mp.setProperty("BCC", "");
|
||||
mp.setProperty("CC", "");
|
||||
mp.put("MSG", this.TAG_THREAD_MSG + " concluso. DURATA: " + this.TAG_THREAD_MSG + "<br/>" +
|
||||
timer.getDurataHourMin());
|
||||
try {
|
||||
WwwAutomator.this.sendMailMessage(mp);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
StatusMsg.updateMsgByTag(WwwAutomator.this.getApFull(), this.TAG_THREAD_MSG, rp.getMsg());
|
||||
try {
|
||||
sleep(10000L);
|
||||
} catch (Exception e) {}
|
||||
StatusMsg.deleteMsgByTag(WwwAutomator.this.getApFull(), this.TAG_THREAD_MSG);
|
||||
WwwAutomator.threadAutomator = false;
|
||||
System.out.println(rp.getMsg());
|
||||
}
|
||||
}
|
||||
|
||||
private long qtaMaxAcquistoWww = 5L;
|
||||
|
||||
private double ricarico = 7.0D;
|
||||
|
||||
private long flgGoogle = 1L;
|
||||
|
||||
private long flgAbilita = 1L;
|
||||
|
||||
private long ordine;
|
||||
|
||||
private Tipo tipo;
|
||||
|
||||
private double prezzoPubblicoDa;
|
||||
|
||||
private double ricaricoOltre;
|
||||
|
||||
private static boolean threadAutomator = false;
|
||||
|
||||
public WwwAutomator(ApplParmFull newApplParmFull) {
|
||||
super(newApplParmFull);
|
||||
}
|
||||
|
||||
public void setId_wwwAutomator(long newId_wwwAutomator) {
|
||||
this.id_wwwAutomator = newId_wwwAutomator;
|
||||
}
|
||||
|
||||
public void setId_tipo(long newId_tipo) {
|
||||
this.id_tipo = newId_tipo;
|
||||
setTipo(null);
|
||||
}
|
||||
|
||||
public void setCategoriaImport(String newCategoriaImport) {
|
||||
this.categoriaImport = newCategoriaImport;
|
||||
}
|
||||
|
||||
public void setSearchTxt(String newSearchTxt) {
|
||||
this.searchTxt = newSearchTxt;
|
||||
}
|
||||
|
||||
public void setQtaMaxAcquistoWww(long newQtaMaxAcquistoWww) {
|
||||
this.qtaMaxAcquistoWww = newQtaMaxAcquistoWww;
|
||||
}
|
||||
|
||||
public void setRicarico(double newRicaricoBA) {
|
||||
this.ricarico = newRicaricoBA;
|
||||
}
|
||||
|
||||
public void setFlgGoogle(long newFlgGoogle) {
|
||||
this.flgGoogle = newFlgGoogle;
|
||||
}
|
||||
|
||||
public long getId_wwwAutomator() {
|
||||
return this.id_wwwAutomator;
|
||||
}
|
||||
|
||||
public long getId_tipo() {
|
||||
return this.id_tipo;
|
||||
}
|
||||
|
||||
public String getCategoriaImport() {
|
||||
return (this.categoriaImport == null) ? "" : this.categoriaImport.trim();
|
||||
}
|
||||
|
||||
public String getSearchTxt() {
|
||||
return (this.searchTxt == null) ? "" : this.searchTxt.trim();
|
||||
}
|
||||
|
||||
public long getQtaMaxAcquistoWww() {
|
||||
return this.qtaMaxAcquistoWww;
|
||||
}
|
||||
|
||||
public double getRicarico() {
|
||||
return this.ricarico;
|
||||
}
|
||||
|
||||
public long getFlgGoogle() {
|
||||
return this.flgGoogle;
|
||||
}
|
||||
|
||||
public void setTipo(Tipo newTipo) {
|
||||
this.tipo = newTipo;
|
||||
}
|
||||
|
||||
public Tipo getTipo() {
|
||||
this.tipo = (Tipo)getSecondaryObject(this.tipo, Tipo.class, getId_tipo());
|
||||
return this.tipo;
|
||||
}
|
||||
|
||||
protected ResParm checkDeleteCascade() {
|
||||
return new ResParm(true);
|
||||
}
|
||||
|
||||
protected void deleteCascade() {}
|
||||
|
||||
public Vectumerator<WwwAutomator> findByCR(WwwAutomatorCR CR, int pageNumber, int pageRows) {
|
||||
String s_Sql_Find = "select A.* from WWW_AUTOMATOR AS A left join TIPO as B on A.id_tipo=B.id_tipo";
|
||||
String s_Sql_Order = " ORDER BY A.ORDINE, B.descrizione, A.searchTxt, A.categoriaImport";
|
||||
if (CR.getFlgOrderBy() == 99L)
|
||||
s_Sql_Order = " ORDER BY B.descrizioneR,A.ORDINE, A.searchTxt, A.categoriaImport";
|
||||
WcString wc = new WcString();
|
||||
if (CR.getId_wwwAutomator() > 0L)
|
||||
wc.addWc("A.id_wwwAutomator=" + CR.getId_wwwAutomator());
|
||||
if (CR.getId_tipo() > 0L)
|
||||
if (CR.getTipo().isFoglia()) {
|
||||
wc.addWc("A.id_tipo=" + CR.getId_tipo());
|
||||
} else {
|
||||
Vectumerator<Tipo> vecTipo = CR.getTipo().findFigliAll(CR.getId_tipo(), true);
|
||||
if (vecTipo.hasMoreElements()) {
|
||||
StringBuilder sb = new StringBuilder("(");
|
||||
while (vecTipo.hasMoreElements()) {
|
||||
Tipo row = (Tipo)vecTipo.nextElement();
|
||||
sb.append("A.id_tipo=" + row.getId_tipo());
|
||||
if (vecTipo.hasMoreElements())
|
||||
sb.append(" or ");
|
||||
}
|
||||
sb.append(")");
|
||||
wc.addWc(sb.toString());
|
||||
}
|
||||
}
|
||||
if (CR.getFlgAbilita() == 0L) {
|
||||
wc.addWc("(A.flgAbilita = o or A.flgAbilita is null)");
|
||||
} else if (CR.getFlgAbilita() > 0L) {
|
||||
wc.addWc("A.flgAbilita=" + CR.getFlgAbilita());
|
||||
}
|
||||
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 String getUltimaEsecuzione() {
|
||||
return (this.ultimaEsecuzione == null) ? "" : this.ultimaEsecuzione.trim();
|
||||
}
|
||||
|
||||
public void setUltimaEsecuzione(String ultimaEsecuzione) {
|
||||
this.ultimaEsecuzione = ultimaEsecuzione;
|
||||
}
|
||||
|
||||
public long getFlgAbilita() {
|
||||
return this.flgAbilita;
|
||||
}
|
||||
|
||||
public void setFlgAbilita(long flgAbilita) {
|
||||
this.flgAbilita = flgAbilita;
|
||||
}
|
||||
|
||||
public ResParm eseguiAutomator() {
|
||||
ResParm rp = new ResParm();
|
||||
if (getId_wwwAutomator() > 0L && getFlgAbilita() == 1L) {
|
||||
WwwAutomatorCR CR = new WwwAutomatorCR();
|
||||
CR.setId_wwwAutomator(getId_wwwAutomator());
|
||||
startAutomator(getApFull(), CR, false);
|
||||
}
|
||||
return rp;
|
||||
}
|
||||
|
||||
public final ResParm startAutomator(ApplParmFull apFull, WwwAutomatorCR CR, boolean sendEmail) {
|
||||
boolean test = false;
|
||||
if (!isThreadAttivo()) {
|
||||
new ThreadAutomator(apFull, CR, sendEmail);
|
||||
return new ResParm(true, "Thread AUTOMATOR avviato");
|
||||
}
|
||||
return new ResParm(false, "ATTENZIONE!! Thread in esecuzione!!!");
|
||||
}
|
||||
|
||||
public static boolean isThreadAttivo() {
|
||||
return threadAutomator;
|
||||
}
|
||||
|
||||
public String getDescrizione() {
|
||||
return "" + getOrdine() + " " + getOrdine() + " <b>" + getId_wwwAutomator() + "</b> cat: " + getTipo().getDescrizioneCompleta() + " search: " + getCategoriaImport();
|
||||
}
|
||||
|
||||
protected void initFields() {
|
||||
super.initFields();
|
||||
setFlgGoogle(1L);
|
||||
setFlgAbilita(1L);
|
||||
setQtaMaxAcquistoWww(5L);
|
||||
setRicarico(7.0D);
|
||||
}
|
||||
|
||||
private long calcolaOrdine() {
|
||||
try {
|
||||
String s_sqlFind = "select max(ordine) as _max from WWW_AUTOMATOR WHERE id_wwwAutomator!=" + getId_wwwAutomator();
|
||||
PreparedStatement ps = getConn().prepareStatement(s_sqlFind);
|
||||
long res = (long)getMax(ps, true) + 1L;
|
||||
long decine = res / 10L;
|
||||
return (decine + 1L) * 10L;
|
||||
} catch (Exception e) {
|
||||
handleDebug(e);
|
||||
return 0L;
|
||||
}
|
||||
}
|
||||
|
||||
public ResParm save() {
|
||||
if (getOrdine() == 0L)
|
||||
setOrdine(calcolaOrdine());
|
||||
ResParm rp = super.save();
|
||||
return rp;
|
||||
}
|
||||
|
||||
public long getOrdine() {
|
||||
return this.ordine;
|
||||
}
|
||||
|
||||
public void setOrdine(long ordine) {
|
||||
this.ordine = ordine;
|
||||
}
|
||||
|
||||
public ResParm spostaGiu() {
|
||||
ResParm rp = new ResParm();
|
||||
if (getDBState() == 1) {
|
||||
try {
|
||||
long ordineBean = getOrdine();
|
||||
String s_sqlFind = "select A.* from WWW_AUTOMATOR as A WHERE A.ordine>" + ordineBean + " order by A.ordine asc";
|
||||
PreparedStatement ps = getConn().prepareStatement(s_sqlFind);
|
||||
Vectumerator vec = findRows(ps);
|
||||
if (vec.hasMoreElements()) {
|
||||
WwwAutomator tg = (WwwAutomator)vec.nextElement();
|
||||
long ordineTG = tg.getOrdine();
|
||||
tg.setOrdine(-ordineBean);
|
||||
rp = tg.save();
|
||||
if (rp.getStatus()) {
|
||||
setOrdine(ordineTG);
|
||||
rp = save();
|
||||
if (rp.getStatus()) {
|
||||
tg.setOrdine(ordineBean);
|
||||
rp = tg.save();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
rp.setStatus(true);
|
||||
rp.setMsg("Raggiunto valore massimo!");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
handleDebug(e);
|
||||
}
|
||||
} else {
|
||||
rp.setStatus(false);
|
||||
rp.setMsg("Errore!. Record non salvato");
|
||||
}
|
||||
return rp;
|
||||
}
|
||||
|
||||
public ResParm spostaSu() {
|
||||
ResParm rp = new ResParm();
|
||||
if (getDBState() == 1) {
|
||||
try {
|
||||
long ordineBean = getOrdine();
|
||||
String s_sqlFind = "select A.* from WWW_AUTOMATOR as A WHERE A.ordine< " + ordineBean + " order by A.ordine desc";
|
||||
PreparedStatement ps = getConn().prepareStatement(s_sqlFind);
|
||||
Vectumerator vec = findRows(ps);
|
||||
if (vec.hasMoreElements()) {
|
||||
WwwAutomator tg = (WwwAutomator)vec.nextElement();
|
||||
long ordineTG = tg.getOrdine();
|
||||
tg.setOrdine(-ordineBean);
|
||||
rp = tg.save();
|
||||
if (rp.getStatus()) {
|
||||
setOrdine(ordineTG);
|
||||
rp = save();
|
||||
if (rp.getStatus()) {
|
||||
tg.setOrdine(ordineBean);
|
||||
rp = tg.save();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
rp.setStatus(true);
|
||||
rp.setMsg("Raggiunto valore minimo!");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
handleDebug(e);
|
||||
}
|
||||
} else {
|
||||
rp.setStatus(false);
|
||||
rp.setMsg("Errore!. Record non salvato");
|
||||
}
|
||||
return rp;
|
||||
}
|
||||
|
||||
public ResParm ripristinoOrdine() {
|
||||
WwwAutomatorCR CR = new WwwAutomatorCR();
|
||||
CR.setFlgOrderBy(99L);
|
||||
long currentOrdine = 10L;
|
||||
Vectumerator<WwwAutomator> vec = findByCR(CR, 0, 0);
|
||||
while (vec.hasMoreElements()) {
|
||||
WwwAutomator row = (WwwAutomator)vec.nextElement();
|
||||
row.setOrdine(currentOrdine);
|
||||
row.save();
|
||||
currentOrdine += 10L;
|
||||
}
|
||||
return new ResParm(true);
|
||||
}
|
||||
|
||||
public double getPrezzoPubblicoDa() {
|
||||
return this.prezzoPubblicoDa;
|
||||
}
|
||||
|
||||
public void setPrezzoPubblicoDa(double prezzoPubblicoA) {
|
||||
this.prezzoPubblicoDa = prezzoPubblicoA;
|
||||
}
|
||||
|
||||
public double getRicaricoOltre() {
|
||||
return this.ricaricoOltre;
|
||||
}
|
||||
|
||||
public void setRicaricoOltre(double ricaricoOltre) {
|
||||
this.ricaricoOltre = ricaricoOltre;
|
||||
}
|
||||
|
||||
public WwwAutomator() {}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue